forked from alterware/iw6-mod
Added timescale support for sounds during demo playback.
This commit is contained in:
@@ -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<void>(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<float>();
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace game
|
||||
|
||||
WEAK symbol<void(const char* cmdName, void (), cmd_function_t* allocedCmd)> Cmd_AddCommandInternal{0x1403B3570, 0x1403F7070};
|
||||
WEAK symbol<void(int localClientNum, int controllerIndex, const char* text)> Cmd_ExecuteSingleCommand{0x1403B3B10, 0x1403F7680};
|
||||
WEAK symbol<float()> Com_GetTimescaleForSnd{0, 0x140413860};
|
||||
WEAK symbol<int(int msec)> Com_TimeScaleMsec{0, 0x140415D50};
|
||||
|
||||
WEAK symbol<void(XAssetType type, void (__cdecl *func)(XAssetHeader, void*), void* inData, bool includeOverride)> DB_EnumXAssets_FastFile{0x140271F50, 0x14031EF90};
|
||||
|
||||
Reference in New Issue
Block a user