Skip to content

Commit

Permalink
Merge pull request #343 from spelunky-fyi/MorePatches
Browse files Browse the repository at this point in the history
More patches
  • Loading branch information
Dregu authored Oct 8, 2023
2 parents 340eaf5 + ba1612e commit 845e716
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/game_api/game_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ void patch_liquid_OOB()
write_mem_prot(new_code_addr + 6, rel, true);
write_mem_prot(new_code_addr + 16, rel - 10, true);

// replace "Ran out of liquids pool!" with jmp out of the main loop, which effectively
// fixes the problem of spawning too much liquid, simply removing some old ones when new is spawned
{
const size_t message_addr = offset - 0x10f;
// replace call MessageBoxA with
// jmp whatever (after of the main while do-while != 5 loop)
// nop
write_mem_prot(message_addr, "\xE9\x72\x01\x00\x00\x90"sv, true);
}

once = true;
}

Expand All @@ -284,3 +294,14 @@ void set_skip_tiamat_cutscene(bool skip)
else
recover_mem("set_skip_tiamat_cutscene");
}

void patch_ushabti_error()
{
// nops MessageBoxA("Number of generated Ushabti statues isn't 100!")
static bool once = false;
if (once)
return;
const auto offset = get_address("ushabti_error");
write_mem_prot(offset, "\x90\x90\x90\x90\x90\x90"sv, true);
once = true;
}
1 change: 1 addition & 0 deletions src/game_api/game_patches.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ void patch_liquid_OOB();
void set_skip_olmec_cutscene(bool skip);
void patch_tiamat_kill_crash();
void set_skip_tiamat_cutscene(bool skip);
void patch_ushabti_error();
8 changes: 8 additions & 0 deletions src/game_api/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2026,6 +2026,14 @@ std::unordered_map<std::string_view, AddressRule> g_address_rules{
.at_exe()
.function_start(),
},
{
"ushabti_error"sv,
// it's one of the few calls to MessageBoxA, nagging about some Ushabti statues
PatternCommandBuffer{}
.find_inst("4c 89 e8 4c 29 e0 48 3d 20 03 00 00"_gh)
.offset(0x21)
.at_exe(),
},
};
std::unordered_map<std::string_view, size_t> g_cached_addresses;

Expand Down
1 change: 1 addition & 0 deletions src/game_api/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ State& State::get()
patch_orbs_limit();
patch_olmec_kill_crash();
patch_liquid_OOB();
patch_ushabti_error();
}
else
{
Expand Down

0 comments on commit 845e716

Please sign in to comment.