Some fixes

This commit is contained in:
Federico Cecchetto 2022-01-10 01:03:16 +01:00
parent ee0e3db05c
commit d9b82ec72c
5 changed files with 19 additions and 13 deletions

View File

@ -482,6 +482,8 @@ namespace gui_debug
ImGui::ColorPicker4("color", entity_bound_settings.type_colors[entity_type::other]); ImGui::ColorPicker4("color", entity_bound_settings.type_colors[entity_type::other]);
ImGui::TreePop(); ImGui::TreePop();
} }
ImGui::TreePop();
} }
ImGui::SliderFloat("range", &entity_bound_settings.range, 0.f, 10000.f); ImGui::SliderFloat("range", &entity_bound_settings.range, 0.f, 10000.f);

View File

@ -44,7 +44,7 @@ namespace patches
if (hash == cg_fov_hash || hash == cg_fov_scale_hash) if (hash == cg_fov_hash || hash == cg_fov_scale_hash)
{ {
flags |= game::DvarFlags::DVAR_FLAG_SAVED; flags = game::DvarFlags::DVAR_FLAG_SAVED;
} }
return dvar_register_float_hook.invoke<game::dvar_t*>(hash, dvarName, value, min, max, flags); return dvar_register_float_hook.invoke<game::dvar_t*>(hash, dvarName, value, min, max, flags);
@ -77,8 +77,6 @@ namespace patches
gscr_set_save_dvar_hook.create(0x504C60_b, &gscr_set_save_dvar_stub); gscr_set_save_dvar_hook.create(0x504C60_b, &gscr_set_save_dvar_stub);
// Make cg_fov and cg_fovscale saved dvars // Make cg_fov and cg_fovscale saved dvars
dvar_register_float_hook.create(game::Dvar_RegisterFloat.get(), dvar_register_float_stub); dvar_register_float_hook.create(game::Dvar_RegisterFloat.get(), dvar_register_float_stub);
// Don't make the game reset cg_fov and cg_fovscale along with other dvars
utils::hook::nop(0x4C8A08_b, 5);
} }
}; };
} }

View File

@ -55,24 +55,14 @@ namespace scripting
vm_notify_hook.invoke<void>(notify_list_owner_id, string_value, top); vm_notify_hook.invoke<void>(notify_list_owner_id, string_value, top);
} }
void clear_shared_table()
{
shared_table.access([](shared_table_t& table)
{
table.clear();
});
}
void player_spawn_stub(const game::gentity_s* player) void player_spawn_stub(const game::gentity_s* player)
{ {
player_spawn_hook.invoke<void>(player); player_spawn_hook.invoke<void>(player);
clear_shared_table();
lua::engine::start(); lua::engine::start();
} }
void g_shutdown_game_stub(const int free_scripts) void g_shutdown_game_stub(const int free_scripts)
{ {
clear_shared_table();
lua::engine::stop(); lua::engine::stop();
g_shutdown_game_hook.invoke<void>(free_scripts); g_shutdown_game_hook.invoke<void>(free_scripts);
} }

View File

@ -556,6 +556,14 @@ namespace scripting::lua
return result; return result;
}; };
game_type["sharedclear"] = [](const game&)
{
scripting::shared_table.access([](scripting::shared_table_t& table)
{
table.clear();
});
};
game_type["getentbyref"] = [](const game&, const sol::this_state s, game_type["getentbyref"] = [](const game&, const sol::this_state s,
const unsigned int entnum, const unsigned int classnum) const unsigned int entnum, const unsigned int classnum)
{ {

View File

@ -1025,6 +1025,14 @@ namespace ui_scripting::lua
return result; return result;
}; };
game_type["sharedclear"] = [](const game&)
{
scripting::shared_table.access([](scripting::shared_table_t& table)
{
table.clear();
});
};
auto userdata_type = state.new_usertype<userdata>("userdata_"); auto userdata_type = state.new_usertype<userdata>("userdata_");
userdata_type["new"] = sol::property( userdata_type["new"] = sol::property(