-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add runtime data parsing and demo accurate timer #446
Conversation
Im using filters for consistency, and is definitely over-engineered. Unescaping/decrypting an array would be simpler and require less code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff.
Please add Linux hooks as well:
diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp
index 852c73f..f683a01 100644
--- a/BunnymodXT/modules/HwDLL.cpp
+++ b/BunnymodXT/modules/HwDLL.cpp
@@ -317,6 +317,16 @@ extern "C" qboolean __cdecl CL_CheckGameDirectory(char *gamedir)
{
return HwDLL::HOOKED_CL_CheckGameDirectory(gamedir);
}
+
+extern "C" int __cdecl ValidStuffText(char *buf)
+{
+ return HwDLL::HOOKED_ValidStuffText(buf);
+}
+
+extern "C" qboolean __cdecl CL_ReadDemoMessage_OLD()
+{
+ return HwDLL::HOOKED_CL_ReadDemoMessage_OLD();
+}
#endif
void HwDLL::Hook(const std::wstring& moduleName, void* moduleHandle, void* moduleBase, size_t moduleLength, bool needToIntercept)
@@ -1021,6 +1031,18 @@ void HwDLL::FindStuff()
else
EngineDevWarning("[hw dll] Could not find CL_CheckGameDirectory.\n");
+ ORIG_ValidStuffText = reinterpret_cast<_ValidStuffText>(MemUtils::GetSymbolAddress(m_Handle, "ValidStuffText"));
+ if (ORIG_ValidStuffText)
+ EngineDevMsg("[hw dll] Found ValidStuffText at %p.\n", ORIG_ValidStuffText);
+ else
+ EngineDevWarning("[hw dll] Could not find ValidStuffText.\n");
+
+ ORIG_CL_ReadDemoMessage_OLD = reinterpret_cast<_CL_ReadDemoMessage_OLD>(MemUtils::GetSymbolAddress(m_Handle, "CL_ReadDemoMessage_OLD"));
+ if (ORIG_CL_ReadDemoMessage_OLD)
+ EngineDevMsg("[hw dll] Found CL_ReadDemoMessage_OLD at %p.\n", ORIG_CL_ReadDemoMessage_OLD);
+ else
+ EngineDevWarning("[hw dll] Could not find CL_ReadDemoMessage_OLD.\n");
+
if (!cls || !psv || !svs || !svmove || !ppmove || !host_client || !sv_player || !sv_areanodes || !cmd_text || !cmd_alias || !host_frametime || !cvar_vars || !movevars || !ORIG_SV_AddLinksToPM || !ORIG_SV_SetMoveVars)
ORIG_Cbuf_Execute = nullptr;
1e9d524
to
6de14da
Compare
Should probably be incorporated with the save data code, to avoid repeat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! Sorry for taking so long to look at this, I'm just completely buried in finishing TAS editor 2.
This is indeed a valuable feature to have, and it mostly matches how I would implement it. I just have a few comments, and we need to decide what to do about executing
.
Adds pattern and hook for ValidStuffText, CL_ReadDemoMessage_OLD. CL_ReadDemoMessage_OLD calls ValidStuffText to verify demo commands. We can use this to easily retirieve //BXTD0 command data for each frame.
Adds CustomHud::SetTime. Ensures that bxt_timer_stop and similar commands are called during demo, and that the timer stops after game end.
Adds 2 hw.dll hooks:
That are used to read the //BXTD0 commands and corresponding runtime data each frame. These have only been tested on latest steam version of Half-Life.
Conversion back to a vector was implemented by adding a decrypt filter and load template.
demo_data_visitor is then applied to the recovered data and should contain logic such as updating timer/health. This could arguably be part of the load template, but imo it's better for parse logic to be separate.
I currently set HwDll::executing to true whenever a demo frame is read, to make the timer resume after save/loads. This is scuffed, and the Cbuf_Execute hook should be fixed to resume in demos instead, but I dont know how to.
Can be used to resolve #294