diff --git a/src/client/component/demo_timescale.cpp b/src/client/component/demo_timescale.cpp index e22c2a7..f1706c1 100644 --- a/src/client/component/demo_timescale.cpp +++ b/src/client/component/demo_timescale.cpp @@ -14,6 +14,7 @@ namespace demo_timescale { utils::hook::detour Com_TimeScaleMsec_hook; utils::hook::detour LUI_Layout_hook; + utils::hook::detour Com_GetTimescaleForSnd_hook; game::dvar_t* demo_timescale; @@ -136,6 +137,16 @@ namespace demo_timescale LUI_Layout_hook.invoke(client_num, root_name, delta_time, lua_vm); } + + float get_timescale_for_sound() + { + if (!demo_playback::playing() || !demo_timescale || demo_timescale->current.value == 1.0f) + { + return Com_GetTimescaleForSnd_hook.invoke(); + } + + return demo_timescale->current.value; + } } class component final : public component_interface @@ -154,6 +165,9 @@ namespace demo_timescale // add timescale support for lua ui elements during demo playback LUI_Layout_hook.create(game::LUI_Layout, set_delta_time_ui_elements); + // add timescale support for sounds during demo playback + Com_GetTimescaleForSnd_hook.create(game::Com_GetTimescaleForSnd, get_timescale_for_sound); + // allow the user to control the timescale during demo playback demo_timescale = game::Dvar_RegisterFloat( "demotimescale", 1.0f, 0.0f, 1000.0f, game::DVAR_FLAG_NONE, "Set playback speed for demos"); diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index a602734..1dba57b 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -58,6 +58,7 @@ namespace game WEAK symbol Cmd_AddCommandInternal{0x1403B3570, 0x1403F7070}; WEAK symbol Cmd_ExecuteSingleCommand{0x1403B3B10, 0x1403F7680}; + WEAK symbol Com_GetTimescaleForSnd{0, 0x140413860}; WEAK symbol Com_TimeScaleMsec{0, 0x140415D50}; WEAK symbol DB_EnumXAssets_FastFile{0x140271F50, 0x14031EF90};