Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/game/iw3/mp/components/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,18 @@ void Events::Load_DelayStream_Hook()

Detour Events::Load_DelayStream_Detour;

void Events::Scr_ShutdownSystem_Hook(unsigned __int8 sys)
void Events::Scr_ShutdownSystem_Hook(int bComplete)
{
for (size_t i = 0; i < ARRAYSIZE(vmShutdownHandlers); ++i)
if (bComplete)
{
vmShutdownHandlers[i]();
for (size_t i = 0; i < ARRAYSIZE(vmShutdownHandlers); ++i)
{
vmShutdownHandlers[i]();
}
}

// Call original function after callbacks
Scr_ShutdownSystem_Detour.GetOriginal<Scr_ShutdownSystem_t>()(sys);
Scr_ShutdownSystem_Detour.GetOriginal<Scr_ShutdownSystem_t>()(bComplete);
}

Detour Events::Scr_ShutdownSystem_Detour;
Expand Down
2 changes: 1 addition & 1 deletion src/game/iw3/mp/components/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Events : public Module
static void Load_DelayStream_Hook();

static Detour Scr_ShutdownSystem_Detour;
static void Scr_ShutdownSystem_Hook(unsigned __int8 sys);
static void Scr_ShutdownSystem_Hook(int bComplete);

static Detour Com_InitDvars_Detour;
static void Com_InitDvars_Hook();
Expand Down
3 changes: 2 additions & 1 deletion src/game/iw3/mp/symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ typedef int (*CL_ConsolePrint_AddLine_t)(int localClientNum, int channel, const
unsigned int pixelWidth, char color, int flags);
static CL_ConsolePrint_AddLine_t CL_ConsolePrint_AddLine = reinterpret_cast<CL_ConsolePrint_AddLine_t>(0x822E1EB8);

typedef void (*Scr_ShutdownSystem_t)(unsigned __int8 sys);
// TU4 omits the sys argument; only bComplete remains.
typedef void (*Scr_ShutdownSystem_t)(int bComplete);
static Scr_ShutdownSystem_t Scr_ShutdownSystem = reinterpret_cast<Scr_ShutdownSystem_t>(0x82211FD0);

typedef void (*Com_InitDvars_t)();
Expand Down
6 changes: 3 additions & 3 deletions src/game/t4/mp/components/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void Events::Cmd_Init_Hook()

Detour Events::Cmd_Init_Detour;

void *Events::Scr_ShutdownSystem_Hook(scriptInstance_t inst, int sys, int bComplete)
void *Events::Scr_ShutdownSystem_Hook(scriptInstance_t inst, scrSystem_t sys, int bComplete)
{
// These handlers own server script state.
if (inst == SCRIPTINSTANCE_SERVER)
// These handlers own server script state and run only on complete shutdowns.
if (inst == SCRIPTINSTANCE_SERVER && bComplete)
{
for (size_t i = 0; i < ARRAYSIZE(vmShutdownHandlers); ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/t4/mp/components/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Events : public Module
static void Cmd_Init_Hook();

static Detour Scr_ShutdownSystem_Detour;
static void *Scr_ShutdownSystem_Hook(scriptInstance_t inst, int sys, int bComplete);
static void *Scr_ShutdownSystem_Hook(scriptInstance_t inst, scrSystem_t sys, int bComplete);

static Detour UI_Refresh_Detour;
static int UI_Refresh_Hook(int localClientNum);
Expand Down
5 changes: 5 additions & 0 deletions src/game/t4/mp/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ enum svscmd_type
SV_CMD_RELIABLE = 0x1,
};

enum scrSystem_t : __int32
{
SCR_SYS_GAME = 0x1,
};

enum scriptInstance_t : __int32
{
SCRIPTINSTANCE_SERVER = 0x0,
Expand Down
2 changes: 1 addition & 1 deletion src/game/t4/mp/symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static auto Scr_SetClientField =
reinterpret_cast<void (*)(gclient_s *client, int offset, scriptInstance_t inst)>(0x8220A2D0);
static auto Scr_SetGenericField =
reinterpret_cast<void (*)(unsigned __int8 *b, fieldtype_t type, int ofs, scriptInstance_t inst)>(0x82254E90);
typedef void *(*Scr_ShutdownSystem_t)(scriptInstance_t inst, int sys, int bComplete);
typedef void *(*Scr_ShutdownSystem_t)(scriptInstance_t inst, scrSystem_t sys, int bComplete);
static Scr_ShutdownSystem_t Scr_ShutdownSystem = reinterpret_cast<Scr_ShutdownSystem_t>(0x82345388);

static auto String_Parse = reinterpret_cast<int (*)(const char **p, char *out, int len)>(0x822A8680);
Expand Down
Loading