Some changes
This commit is contained in:
parent
9e9848d915
commit
439e505f0a
@ -43,6 +43,8 @@ namespace scripting
|
|||||||
std::string current_file;
|
std::string current_file;
|
||||||
unsigned int current_file_id{};
|
unsigned int current_file_id{};
|
||||||
|
|
||||||
|
std::unordered_map<unsigned int, std::string> canonical_string_table;
|
||||||
|
|
||||||
void vm_notify_stub(const unsigned int notify_list_owner_id, const game::scr_string_t string_value,
|
void vm_notify_stub(const unsigned int notify_list_owner_id, const game::scr_string_t string_value,
|
||||||
game::VariableValue* top)
|
game::VariableValue* top)
|
||||||
{
|
{
|
||||||
@ -73,6 +75,11 @@ namespace scripting
|
|||||||
|
|
||||||
void g_shutdown_game_stub(const int free_scripts)
|
void g_shutdown_game_stub(const int free_scripts)
|
||||||
{
|
{
|
||||||
|
if (free_scripts)
|
||||||
|
{
|
||||||
|
canonical_string_table.clear();
|
||||||
|
}
|
||||||
|
|
||||||
lua::engine::stop();
|
lua::engine::stop();
|
||||||
g_shutdown_game_hook.invoke<void>(free_scripts);
|
g_shutdown_game_hook.invoke<void>(free_scripts);
|
||||||
}
|
}
|
||||||
@ -105,9 +112,21 @@ namespace scripting
|
|||||||
process_script_hook.invoke<void>(filename);
|
process_script_hook.invoke<void>(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> get_token_names(unsigned int id)
|
||||||
|
{
|
||||||
|
auto result = scripting::find_token(id);
|
||||||
|
|
||||||
|
if (canonical_string_table.find(id) != canonical_string_table.end())
|
||||||
|
{
|
||||||
|
result.push_back(canonical_string_table[id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void add_function(const std::string& file, unsigned int id, const char* pos)
|
void add_function(const std::string& file, unsigned int id, const char* pos)
|
||||||
{
|
{
|
||||||
const auto function_names = scripting::find_token(id);
|
const auto function_names = scripting::get_token_names(id);
|
||||||
for (const auto& name : function_names)
|
for (const auto& name : function_names)
|
||||||
{
|
{
|
||||||
script_function_table[file][name] = pos;
|
script_function_table[file][name] = pos;
|
||||||
@ -118,7 +137,7 @@ namespace scripting
|
|||||||
{
|
{
|
||||||
if (current_file_id)
|
if (current_file_id)
|
||||||
{
|
{
|
||||||
const auto names = scripting::find_token(current_file_id);
|
const auto names = scripting::get_token_names(current_file_id);
|
||||||
for (const auto& name : names)
|
for (const auto& name : names)
|
||||||
{
|
{
|
||||||
add_function(name, thread_name, code_pos);
|
add_function(name, thread_name, code_pos);
|
||||||
@ -147,7 +166,7 @@ namespace scripting
|
|||||||
unsigned int sl_get_canonical_string_stub(const char* str)
|
unsigned int sl_get_canonical_string_stub(const char* str)
|
||||||
{
|
{
|
||||||
const auto result = sl_get_canonical_string_hook.invoke<unsigned int>(str);
|
const auto result = sl_get_canonical_string_hook.invoke<unsigned int>(str);
|
||||||
scripting::token_map[str] = result;
|
canonical_string_table[result] = str;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1782,5 +1782,6 @@ namespace scripting
|
|||||||
{"main", 616},
|
{"main", 616},
|
||||||
{"player", 794},
|
{"player", 794},
|
||||||
{"default_start", 10126},
|
{"default_start", 10126},
|
||||||
|
{"maps/_utility", 42407},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user