YaLTeR / BunnymodXT

Speedrun and TAS tool for Half-Life & friends.
Other
201 stars 37 forks source link

`bxt_autorecord` in main menu results in ServerDLL::HOOKED_ClientCommand crash on CSCZ: Deleted Scenes #216

Closed chinese-soup closed 2 years ago

chinese-soup commented 3 years ago

latest master

#0  CBasePlayer::UpdateClientData (this=0xad5ea10) at ../czero/dlls/player.cpp:6127
#1  0xe90dbb49 in ServerDLL::HOOKED_ClientCommand_Func (this=0xe95a32c0 <ServerDLL::GetInstance()::instance>, pEntity=0xbbe1085c) at /home/unko/repos/BunnymodXT/BunnymodXT/modules/ServerDLL.cpp:1823
#2  0xe90dba3c in ServerDLL::HOOKED_ClientCommand (pEntity=0xbbe1085c) at /home/unko/repos/BunnymodXT/BunnymodXT/modules/ServerDLL.cpp:1792
#3  0xe90d4097 in ClientCommand (pEntity=0xbbe1085c) at /home/unko/repos/BunnymodXT/BunnymodXT/modules/ServerDLL.cpp:50
#4  0xe6ec1f8e in SV_FullUpdate_f () at ../engine/sv_user.c:2316
#5  0xe6e5b8de in Cmd_ExecuteStringWithPrivilegeCheck (text=0xe7047960 <string> "fullupdate", bIsPrivileged=<optimized out>, src=<optimized out>) at ../engine/cmd.c:1257
#6  0xe6ebe9c6 in SV_ParseStringCommand (pSenderClient=0xbbd00598) at ../engine/sv_user.c:1753
#7  0xe6ec1e65 in SV_ExecuteClientMessage (cl=0xbbd00598) at ../engine/sv_user.c:2226
#8  0xe6eb3e33 in SV_ReadPackets () at ../engine/sv_main.c:4976
#9  0xe6eb40ae in SV_Frame () at ../engine/sv_main.c:9350
#10 0xe90734dc in HwDLL::HOOKED_SV_Frame_Func (this=0xe95a2520 <HwDLL::GetInstance()::instance>) at /home/unko/repos/BunnymodXT/BunnymodXT/modules/HwDLL.cpp:4838
#11 0xe9073439 in HwDLL::HOOKED_SV_Frame () at /home/unko/repos/BunnymodXT/BunnymodXT/modules/HwDLL.cpp:4830
#12 0xe9061008 in SV_Frame () at /home/unko/repos/BunnymodXT/BunnymodXT/modules/HwDLL.cpp:80
#13 0xe6e737c6 in _Host_Frame (time=0.0630541369) at ../engine/host.c:1430
#14 0xe6e73c52 in Host_Frame (time=0.0630541369, iState=1, stateInfo=0xff91a49c) at ../engine/host.c:1548
#15 0xe6ea0b04 in CEngine::Frame (this=0xe70baaa0 <g_Engine>) at ../engine/sys_engine.cpp:245
#16 0xe6e9e58b in RunListenServer (instance=0x0, basedir=0x804b220 <szBaseDir> ".", cmdline=0x9cf6730 "./hl_linux -steam -game czeror", postRestartCmdLineArgs=0x804d360 <main::szNewCommandParams> "", 
    launcherFactory=0x8049350 <CreateInterfaceLocal(char const*, int*)>, filesystemFactory=0xe80dbd40 <CreateInterface(char const*, int*)>) at ../engine/sys_dll2.cpp:955
#17 0x08048d67 in main (argc=4, argv=0xff91a6e4) at ../launcher/launcher.cpp:439
HOOK_DEF_1(ServerDLL, void, __cdecl, ClientCommand, edict_t*, pEntity)
{
#ifdef _WIN32
    if (!ORIG_CBasePlayer__ForceClientDllUpdate) {
        ORIG_ClientCommand(pEntity);
        return;
    }
#else
    if (!ORIG_CBasePlayer__ForceClientDllUpdate_Linux) {
        ORIG_ClientCommand(pEntity);
        return;
    }
#endif

    const char *cmd = pEngfuncs->pfnCmd_Argv(0);
    if (std::strcmp(cmd, "fullupdate") != 0) {
        ORIG_ClientCommand(pEntity);
        return;
    }

    void *classPtr = pEntity->v.pContainingEntity->pvPrivateData;
    uintptr_t thisAddr = reinterpret_cast<uintptr_t>(classPtr);
    int *m_iClientFOV = reinterpret_cast<int *>(thisAddr + offm_iClientFOV);
    int *m_rgAmmoLast = reinterpret_cast<int *>(thisAddr + offm_rgAmmoLast);
    *m_iClientFOV = -1;
    for (int i = 0; i < maxAmmoSlots; i++)
        m_rgAmmoLast[i] = -1;

#ifdef _WIN32
    ORIG_CBasePlayer__ForceClientDllUpdate(classPtr);
#else
    ORIG_CBasePlayer__ForceClientDllUpdate_Linux(classPtr);
#endif
}

https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/player.cpp#L4168

For future reference mainly.

chinese-soup commented 3 years ago

Addendum: This happened because of a config file: bxt_autorecord run in userconfig.cfg/autoexec.cfg, start the game and then starting a new game (server) results in this crash.