From 8e5cea1af7c7549a7e6e32349697bc1848ba0eb3 Mon Sep 17 00:00:00 2001 From: xensik Date: Sat, 16 Jul 2022 19:56:45 +0200 Subject: [PATCH] update h2 symbols --- src/h2/xsk/assembler.cpp | 2 +- src/h2/xsk/disassembler.cpp | 2 +- src/h2/xsk/resolver.cpp | 44 ------------------------------------- src/tool/xsk/main.cpp | 2 +- 4 files changed, 3 insertions(+), 47 deletions(-) diff --git a/src/h2/xsk/assembler.cpp b/src/h2/xsk/assembler.cpp index 1bf097d0..3c9858b3 100644 --- a/src/h2/xsk/assembler.cpp +++ b/src/h2/xsk/assembler.cpp @@ -429,7 +429,7 @@ void assembler::assemble_far_call(const instruction::ptr& inst, bool thread) script_->write(static_cast(std::stoi(inst->data[2]))); } - const auto file_id = resolver::file_id(inst->data[0]); + const auto file_id = resolver::token_id(inst->data[0]); const auto func_id = resolver::token_id(inst->data[1]); stack_->write(file_id); diff --git a/src/h2/xsk/disassembler.cpp b/src/h2/xsk/disassembler.cpp index 3cdbc753..7dbe8a78 100644 --- a/src/h2/xsk/disassembler.cpp +++ b/src/h2/xsk/disassembler.cpp @@ -338,7 +338,7 @@ void disassembler::disassemble_far_call(const instruction::ptr& inst, bool threa } const auto file_id = stack_->read(); - const auto file_name = file_id == 0 ? stack_->read_c_string() : resolver::file_name(file_id); + const auto file_name = file_id == 0 ? stack_->read_c_string() : resolver::token_name(file_id); const auto func_id = stack_->read(); const auto func_name = func_id == 0 ? stack_->read_c_string() : resolver::token_name(func_id); diff --git a/src/h2/xsk/resolver.cpp b/src/h2/xsk/resolver.cpp index c84073de..a592e48c 100644 --- a/src/h2/xsk/resolver.cpp +++ b/src/h2/xsk/resolver.cpp @@ -17,12 +17,10 @@ namespace xsk::gsc::h2 std::unordered_map opcode_map; std::unordered_map function_map; std::unordered_map method_map; -std::unordered_map file_map; std::unordered_map token_map; std::unordered_map opcode_map_rev; std::unordered_map function_map_rev; std::unordered_map method_map_rev; -std::unordered_map file_map_rev; std::unordered_map token_map_rev; std::unordered_map> files; read_cb_type read_callback = nullptr; @@ -120,35 +118,6 @@ auto resolver::method_name(std::uint16_t id) -> std::string return utils::string::va("_meth_%04X", id); } -auto resolver::file_id(const std::string& name) -> std::uint16_t -{ - if (name.starts_with("_id_")) - { - return static_cast(std::stoul(name.substr(4), nullptr, 16)); - } - - const auto itr = file_map_rev.find(name); - - if (itr != file_map_rev.end()) - { - return itr->second; - } - - return 0; -} - -auto resolver::file_name(std::uint16_t id) -> std::string -{ - const auto itr = file_map.find(id); - - if (itr != file_map.end()) - { - return std::string(itr->second); - } - - return utils::string::va("_id_%04X", id); -} - auto resolver::token_id(const std::string& name) -> std::uint16_t { if (name.starts_with("_id_")) @@ -2727,11 +2696,6 @@ const std::array, 1491> method_list { 0x85D2, "_meth_85D2" }, }}; -const std::array, 1> file_list -{{ - { 0, "null" }, -}}; - const std::array, 5> token_list {{ { 0x0000, "" }, @@ -2755,8 +2719,6 @@ struct __init__ function_map_rev.reserve(function_list.size()); method_map.reserve(method_list.size()); method_map_rev.reserve(method_list.size()); - file_map.reserve(file_list.size()); - file_map_rev.reserve(file_list.size()); token_map.reserve(token_list.size()); token_map_rev.reserve(token_list.size()); @@ -2778,12 +2740,6 @@ struct __init__ method_map_rev.insert({ entry.second, entry.first }); } - for (const auto& entry : file_list) - { - file_map.insert({ entry.first, entry.second }); - file_map_rev.insert({ entry.second, entry.first }); - } - for (const auto& entry : token_list) { token_map.insert({ entry.first, entry.second }); diff --git a/src/tool/xsk/main.cpp b/src/tool/xsk/main.cpp index 6af8332c..b2f75ace 100644 --- a/src/tool/xsk/main.cpp +++ b/src/tool/xsk/main.cpp @@ -115,7 +115,7 @@ auto choose_resolver_file_name(uint32_t id, game& game) -> std::string case game::H1: return h1::resolver::token_name(static_cast(id)); case game::H2: - return h2::resolver::file_name(static_cast(id)); + return h2::resolver::token_name(static_cast(id)); default: return ""; }