Skip to content

Commit 4cd4362

Browse files
committed
Handle null players kind of
1 parent 6daa595 commit 4cd4362

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

addons/sourcemod/scripting/shavit-checkpoints.sp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,7 +2326,15 @@ public void VScript_OnScriptVMInitialized()
23262326

23272327
MRESReturn Detour_Timer_SetCheckpointCustomData(DHookParam params)
23282328
{
2329-
int client = VScript_HScriptToEntity(params.Get(1));
2329+
HSCRIPT clienthandle = params.Get(1);
2330+
2331+
if (clienthandle == view_as<HSCRIPT>(0))
2332+
{
2333+
// null object passed in probably
2334+
return MRES_Supercede;
2335+
}
2336+
2337+
int client = VScript_HScriptToEntity(clienthandle);
23302338

23312339
if (client < 1 || client > MaxClients || !IsClientInGame(client))
23322340
{
@@ -2352,7 +2360,15 @@ MRESReturn Detour_Timer_SetCheckpointCustomData(DHookParam params)
23522360

23532361
MRESReturn Detour_Timer_GetCheckpointCustomData(DHookReturn hret, DHookParam params)
23542362
{
2355-
int client = VScript_HScriptToEntity(params.Get(1));
2363+
HSCRIPT clienthandle = params.Get(1);
2364+
2365+
if (clienthandle == view_as<HSCRIPT>(0))
2366+
{
2367+
// null object passed in probably
2368+
return MRES_Supercede;
2369+
}
2370+
2371+
int client = VScript_HScriptToEntity(clienthandle);
23562372

23572373
if (client < 1 || client > MaxClients || !IsClientInGame(client))
23582374
{

addons/sourcemod/scripting/shavit-core.sp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3929,11 +3929,21 @@ public void VScript_OnScriptVMInitialized()
39293929

39303930
MRESReturn Detour_Timer_GetTime(DHookReturn hret, DHookParam params)
39313931
{
3932-
int client = VScript_HScriptToEntity(params.Get(1));
3932+
HSCRIPT clienthandle = params.Get(1);
3933+
3934+
if (clienthandle == view_as<HSCRIPT>(0))
3935+
{
3936+
// null object passed in probably
3937+
hret.Value = 0.0;
3938+
return MRES_Supercede;
3939+
}
3940+
3941+
int client = VScript_HScriptToEntity(clienthandle);
39333942

39343943
if (client < 1 || client > MaxClients || !IsClientInGame(client))
39353944
{
39363945
// Log error or something...
3946+
hret.Value = 0.0;
39373947
return MRES_Supercede;
39383948
}
39393949

@@ -3944,11 +3954,21 @@ MRESReturn Detour_Timer_GetTime(DHookReturn hret, DHookParam params)
39443954

39453955
MRESReturn Detour_Timer_GetStatus(DHookReturn hret, DHookParam params)
39463956
{
3947-
int client = VScript_HScriptToEntity(params.Get(1));
3957+
HSCRIPT clienthandle = params.Get(1);
3958+
3959+
if (clienthandle == view_as<HSCRIPT>(0))
3960+
{
3961+
// null object passed in probably
3962+
hret.Value = 0;
3963+
return MRES_Supercede;
3964+
}
3965+
3966+
int client = VScript_HScriptToEntity(clienthandle);
39483967

39493968
if (client < 1 || client > MaxClients || !IsClientInGame(client))
39503969
{
39513970
// Log error or something...
3971+
hret.Value = 0;
39523972
return MRES_Supercede;
39533973
}
39543974

0 commit comments

Comments
 (0)