Skip to content

Commit

Permalink
fix(s2): switch table strings with id 0
Browse files Browse the repository at this point in the history
  • Loading branch information
xensik committed Jan 25, 2025
1 parent d2614ca commit 2241c5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/gsc/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ auto assembler::assemble_switch_table(instruction const& inst) -> void
}
else
{
// TODO: Sledgehammer's shenanigans (string id == 0)
script_.write<u32>((ctx_->engine() == engine::iw9) ? 0 : i + 1);
stack_.write_cstr(encrypt_string(inst.data[1 + (4 * i) + 2]));
}
Expand Down
15 changes: 13 additions & 2 deletions src/gsc/disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,19 @@ auto disassembler::disassemble_switch_table(instruction& inst) -> void
{
if (data == 0)
{
stack_.read_cstr(); // [0x01 0x00] unencrypted
inst.data.push_back("default");
auto str = stack_.read_cstr(); // [0x01 0x00] unencrypted

// Sledgehammer's shenanigans
if (ctx_->engine() == engine::s2 && str != "\x01")
{
inst.data.push_back("case");
inst.data.push_back(std::format("{}", static_cast<int>(switch_type::string)));
inst.data.push_back(decrypt_string(str));
}
else
{
inst.data.push_back("default");
}
}
else if (data < 0x100000)
{
Expand Down

0 comments on commit 2241c5e

Please sign in to comment.