Fixes for pluto update

This commit is contained in:
fed
2023-02-27 01:18:50 +01:00
parent 1d94fdd88d
commit 24b3a9369e
6 changed files with 45 additions and 30 deletions

View File

@ -8,12 +8,12 @@ namespace scripting
namespace
{
std::unordered_map<std::string, uint16_t> lowercase_map(
const std::unordered_map<std::string, uint16_t>& old_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)] = entry.second;
new_map[utils::string::to_lower(entry.first.data())] = entry.second;
}
return new_map;
@ -71,20 +71,6 @@ namespace scripting
}
}
std::string find_file(unsigned int id)
{
const auto& file_map = *game::plutonium::file_map_rev;
for (const auto& file : file_map)
{
if (file.second == id)
{
return file.first;
}
}
return {};
}
std::string find_token(unsigned int id)
{
const auto& token_map = *game::plutonium::token_map_rev;
@ -92,13 +78,18 @@ namespace scripting
{
if (token.second == id)
{
return token.first;
return token.first.data();
}
}
return {};
}
std::string find_file(unsigned int id)
{
return find_token(id);
}
int find_token_id(const std::string& name)
{
const auto& token_map = *game::plutonium::token_map_rev;

View File

@ -86,10 +86,10 @@ namespace game
namespace plutonium
{
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> function_map_rev{0};
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> method_map_rev{0};
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> file_map_rev{0};
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::unordered_map<std::uint16_t, std::string_view>> token_map{0};
WEAK symbol<int(const char* fmt, ...)> printf{0};
WEAK symbol<void*> function_table{0};
WEAK symbol<void*> method_table{0};