Fix gsc crash

This commit is contained in:
fed 2022-11-13 19:16:48 +01:00
parent 44c1a1ccd7
commit 0e056e6835
4 changed files with 12 additions and 7 deletions

View File

@ -772,9 +772,9 @@ namespace gsc
command::execute(cmd);
});
scripting::on_shutdown([](int free_scripts)
scripting::on_shutdown([](bool free_scripts, bool post_shutdown)
{
if (free_scripts)
if (free_scripts && post_shutdown)
{
xsk::gsc::h2::resolver::cleanup();
clear();

View File

@ -250,7 +250,7 @@ namespace notifies
scr_entity_damage_hook.create(0x1404BD2E0, scr_entity_damage_stub);
scripting::on_shutdown([](bool free_scripts)
scripting::on_shutdown([](bool free_scripts, bool /*post_shutdown*/)
{
if (free_scripts)
{

View File

@ -52,7 +52,7 @@ namespace scripting
std::string current_scriptfile;
unsigned int current_file_id{};
std::vector<std::function<void(bool)>> shutdown_callbacks;
std::vector<std::function<void(bool, bool)>> shutdown_callbacks;
std::unordered_map<unsigned int, std::string> canonical_string_table;
@ -113,12 +113,17 @@ namespace scripting
for (const auto& callback : shutdown_callbacks)
{
callback(free_scripts);
callback(free_scripts, false);
}
clear_scheduled_notifies();
lua::engine::stop();
g_shutdown_game_hook.invoke<void>(free_scripts);
for (const auto& callback : shutdown_callbacks)
{
callback(free_scripts, true);
}
}
void scr_add_class_field_stub(unsigned int classnum, game::scr_string_t name, unsigned int canonicalString, unsigned int offset)
@ -298,7 +303,7 @@ namespace scripting
return scripting::find_token_single(id);
}
void on_shutdown(const std::function<void(bool)>& callback)
void on_shutdown(const std::function<void(bool, bool)>& callback)
{
shutdown_callbacks.push_back(callback);
}

View File

@ -14,7 +14,7 @@ namespace scripting
extern std::string current_file;
void on_shutdown(const std::function<void(bool)>& callback);
void on_shutdown(const std::function<void(bool, bool)>& callback);
std::optional<std::string> get_canonical_string(const unsigned int id);
std::string get_token_single(unsigned int id);
}