Skip to content

Commit

Permalink
Fixed Scout perk being taken into account for mark_area_known function.
Browse files Browse the repository at this point in the history
* technically it should only effect the visibility of tiles when you're
exploring on the world map.

Fixed the incorrect coordinates for small/medium location circles when
highlighting their sub-tiles (one of bugs listed in #228)

Slightly adjusted the position/size for Local variables button in debug
editor.
  • Loading branch information
NovaRain committed Jun 17, 2019
1 parent 04d06a8 commit 28059ce
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 23 deletions.
4 changes: 2 additions & 2 deletions MPClient/DebugEditor.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions sfall/Modules/BugFixes.cpp
Expand Up @@ -2121,6 +2121,77 @@ static void __declspec(naked) action_use_an_item_on_object_hack() {
}
}

//static const DWORD wmAreaMarkVisitedState_Error = 0x4C4698;
static const DWORD wmAreaMarkVisitedState_Ret = 0x4C46A2;
static void __declspec(naked) wmAreaMarkVisitedState_hack() {
__asm {
mov [ecx + 0x40], esi; // wmAreaInfoList.visited
test esi, esi; // mark "unknown" state
jz skip;
mov eax, [ecx + 0x2C]; // wmAreaInfoList.world_posx
mov edx, [ecx + 0x30]; // wmAreaInfoList.world_posy
// fix loc coordinates
cmp [ecx + 0x34], 1; // wmAreaInfoList.size
jg largeLoc;
je mediumLoc;
//smallLoc:
sub eax, 5;
lea edx, [edx - 5];
mediumLoc:
sub eax, 10;
lea edx, [edx - 10];
largeLoc:
mov ebx, esp; // ppSubTile out
push edx;
push eax;
call fo::funcoffs::wmFindCurSubTileFromPos_;
// cmp eax, -1; // always return 0
// jz error;
pop eax;
pop edx;
mov ebx, [esp];
mov ebx, [ebx + 0x18]; // sub-tile state
test ebx, ebx;
jnz skip;
inc ebx; // 1
skip:
cmp [ecx + 0x38], 1; // wmAreaInfoList.start_state
jne hideLoc;
cmp esi, 2; // mark visited state
jne fix;
call fo::funcoffs::wmMarkSubTileRadiusVisited_;
hideLoc:
jmp wmAreaMarkVisitedState_Ret;
fix:
push ebx;
mov ebx, 1; // radius (fix w/o PERK_scout)
call fo::funcoffs::wmSubTileMarkRadiusVisited_;
pop ebx;
jmp wmAreaMarkVisitedState_Ret;
//error:
// add esp, 8;
// jmp wmAreaMarkVisitedState_Error;
}
}

static void __declspec(naked) wmWorldMap_hack() {
__asm {
mov ebx, [ebx + 0x34]; // wmAreaInfoList.size
cmp ebx, 1;
jg largeLoc;
je mediumLoc;
//smallLoc:
sub eax, 5;
lea edx, [edx - 5];
mediumLoc:
sub eax, 10;
lea edx, [edx - 10];
largeLoc:
xor ebx, ebx;
jmp fo::funcoffs::wmPartyInitWalking_;
}
}

void BugFixes::init()
{
#ifndef NDEBUG
Expand Down Expand Up @@ -2686,6 +2757,14 @@ void BugFixes::init()

// Fix for the player's movement in combat being interrupted when trying to use objects with Bonus Move APs available
MakeCall(0x411FD6, action_use_an_item_on_object_hack);

// Fix for Scout perk being taken into account when setting the visibility of locations with mark_area_known function
// also fix the incorrect coordinates for small/medium location circles when highlighting their sub-tiles
MakeJump(0x4C466F, wmAreaMarkVisitedState_hack);
SafeWrite8(0x4C46AB, 0x58); // esi > ebx

// Fix the position of the target marker for small/medium location circles
MakeCall(0x4C03AA, wmWorldMap_hack, 2);
}

}
21 changes: 0 additions & 21 deletions sfall/Modules/Worldmap.cpp
Expand Up @@ -344,24 +344,6 @@ static void __declspec(naked) wmMapInit_hack() {
}
}

static void __declspec(naked) wmWorldMap_hack() {
__asm {
mov ebx, [ebx + 0x34]; // wmAreaInfoList.size
cmp ebx, 1;
jg largeLoc;
je mediumLoc;
//smallLoc:
sub eax, 5;
sub edx, 5;
mediumLoc:
sub eax, 10;
sub edx, 10;
largeLoc:
xor ebx, ebx;
jmp fo::funcoffs::wmPartyInitWalking_;
}
}

static void RestRestore() {
if (!restMode) return;

Expand Down Expand Up @@ -554,9 +536,6 @@ void WorldMapInterfacePatch() {
SafeWrite8(0x4C2C7C, 0x43); // dec ebx > inc ebx
SafeWrite32(0x4C2C92, 181); // index of DNARWOFF.FRM
SafeWrite8(0x4C2D04, 0x46); // dec esi > inc esi

// Fix the position of the target marker for small/medium location circles
MakeCall(0x4C03AA, wmWorldMap_hack, 2);
}

void PipBoyAutomapsPatch() {
Expand Down

0 comments on commit 28059ce

Please sign in to comment.