mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-07-09 04:31:53 +00:00
Fix for pluto update
This commit is contained in:
@ -7,51 +7,20 @@ namespace scripting
|
||||
{
|
||||
namespace
|
||||
{
|
||||
std::unordered_map<std::string, uint16_t> lowercase_map(
|
||||
const std::unordered_map<std::string_view, uint16_t>& old_map)
|
||||
{
|
||||
std::unordered_map<std::string, uint16_t> new_map{};
|
||||
for (auto& entry : old_map)
|
||||
{
|
||||
new_map[utils::string::to_lower(entry.first.data())] = entry.second;
|
||||
}
|
||||
|
||||
return new_map;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, uint16_t>& get_methods()
|
||||
{
|
||||
static auto methods = lowercase_map(*game::plutonium::method_map_rev);
|
||||
return methods;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, uint16_t>& get_functions()
|
||||
{
|
||||
static auto function = lowercase_map(*game::plutonium::function_map_rev);
|
||||
return function;
|
||||
}
|
||||
|
||||
int find_function_index(const std::string& name, const bool prefer_global)
|
||||
int find_function_index(const std::string& name, [[maybe_unused]] const bool prefer_global)
|
||||
{
|
||||
const auto target = utils::string::to_lower(name);
|
||||
auto const& first = (*game::plutonium::gsc_ctx)->func_map();
|
||||
auto const& second = (*game::plutonium::gsc_ctx)->meth_map();
|
||||
|
||||
const auto& primary_map = prefer_global
|
||||
? get_functions()
|
||||
: get_methods();
|
||||
const auto& secondary_map = !prefer_global
|
||||
? get_functions()
|
||||
: get_methods();
|
||||
|
||||
auto function_entry = primary_map.find(target);
|
||||
if (function_entry != primary_map.end())
|
||||
if (const auto itr = first.find(name); itr != first.end())
|
||||
{
|
||||
return function_entry->second;
|
||||
return static_cast<int>(itr->second);
|
||||
}
|
||||
|
||||
function_entry = secondary_map.find(target);
|
||||
if (function_entry != secondary_map.end())
|
||||
if (const auto itr = second.find(name); itr != second.end())
|
||||
{
|
||||
return function_entry->second;
|
||||
return static_cast<int>(itr->second);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -73,16 +42,7 @@ namespace scripting
|
||||
|
||||
std::string find_token(unsigned int id)
|
||||
{
|
||||
const auto& token_map = *game::plutonium::token_map_rev;
|
||||
for (const auto& token : token_map)
|
||||
{
|
||||
if (token.second == id)
|
||||
{
|
||||
return token.first;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
return (*game::plutonium::gsc_ctx)->token_name(id);
|
||||
}
|
||||
|
||||
std::string find_file(unsigned int id)
|
||||
@ -92,21 +52,16 @@ namespace scripting
|
||||
|
||||
int find_token_id(const std::string& name)
|
||||
{
|
||||
const auto& token_map = *game::plutonium::token_map_rev;
|
||||
const auto result = token_map.find(name);
|
||||
|
||||
if (result != token_map.end())
|
||||
{
|
||||
return result->second;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return (*game::plutonium::gsc_ctx)->token_id(name);
|
||||
}
|
||||
|
||||
script_function find_function(const std::string& name, const bool prefer_global)
|
||||
{
|
||||
const auto index = find_function_index(name, prefer_global);
|
||||
if (index < 0) return nullptr;
|
||||
if (index < 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return get_function_by_index(index);
|
||||
}
|
||||
|
@ -86,9 +86,7 @@ namespace game
|
||||
|
||||
namespace plutonium
|
||||
{
|
||||
WEAK symbol<std::unordered_map<std::string_view, std::uint16_t>> function_map_rev{0};
|
||||
WEAK symbol<std::unordered_map<std::string_view, std::uint16_t>> method_map_rev{0};
|
||||
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> token_map_rev{0};
|
||||
WEAK symbol<std::unique_ptr<xsk::gsc::iw5_pc::context>> gsc_ctx{0};
|
||||
WEAK symbol<int(const char* fmt, ...)> printf{0};
|
||||
WEAK symbol<void*> function_table{0};
|
||||
WEAK symbol<void*> method_table{0};
|
||||
|
Reference in New Issue
Block a user