Skip to content

Commit

Permalink
更新2个插件防止crash
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasylidong committed May 19, 2023
1 parent cff03e8 commit a325d0d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Binary file modified addons/sourcemod/plugins/linux_auto_restart.smx
Binary file not shown.
Binary file modified addons/sourcemod/plugins/optional/AnneHappy/l4d2_hunter_patch.smx
Binary file not shown.
30 changes: 25 additions & 5 deletions addons/sourcemod/scripting/AnneHappy/l4d2_hunter_patch.sp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma semicolon 1
#pragma newdecls required

#define VERSION "0.1"
#define VERSION "0.2"

#include <sourcemod>
#include <sourcescramble> // https://github.com/nosoop/SMExt-SourceScramble
Expand Down Expand Up @@ -34,16 +34,17 @@ public void OnPluginStart()
{
InitGameData();

CreateConVar("l4d2_hunter_patch_version", VERSION, "Version", FCVAR_NONE | FCVAR_DONTRECORD);
CreateConVar("l4d2_hunter_patch_version", VERSION, "Version", FCVAR_NOTIFY | FCVAR_DONTRECORD);

g_cvPatchs[0] = CreateConVar("l4d2_hunter_patch_convert_leap", "0", "Whether convert leap to pounce.\n0=game default, 1=always, 2=never.", FCVAR_NONE);
g_cvPatchs[1] = CreateConVar("l4d2_hunter_patch_crouch_pounce", "0", "While on the ground, Whether need press crouch button to pounce.\n0=game default, 1=always, 2=never.", FCVAR_NONE);
g_cvPatchs[2] = CreateConVar("l4d2_hunter_patch_bonus_damage", "0", "Whether enable bonus pounce damage.\n0=game default, 1=always, 2=never.", FCVAR_NONE);
g_cvPatchs[3] = CreateConVar("l4d2_hunter_patch_pounce_interrupt", "0", "Whether enable pounce interrupt.\n0=game default, 1=always, 2=never.", FCVAR_NONE);

AutoExecConfig(true, "l4d2_hunter_patch");

RegAdminCmd("sm_hunter_patch_print_cvars", Cmd_PrintCvars, ADMFLAG_ROOT);
HookEvent("lunge_pounce", Event_LungePounce);
}

public void OnConfigsExecuted()
Expand Down Expand Up @@ -115,6 +116,25 @@ void InitGameData()
if (!g_mPatchs[i][NEVER].Validate())
SetFailState("Verify patch: %s failed.", sName);
}

delete hGameData;
}
}

// Fixed crash in CTerrorPlayer::OnPouncedOnSurvivor function when the server is empty.
// HookEvent so that the function always returns a valid event pointer when CreateEvent.
// If there are other plugins already hooked 'lunge_pounce' event, it can also prevent crashes.
/*
IGameEvent *event = gameeventmanager->CreateEvent( "lunge_pounce" );
if ( event )
{
...
}
if ( CTerrorGameRules::HasPlayerControlledZombies() )
{
...
event->SetInt("damage", dmg ); // NULL pointer crash
}
*/
void Event_LungePounce(Event event, const char[] name, bool dontBroadcast)
{
}
7 changes: 6 additions & 1 deletion addons/sourcemod/scripting/extend/linux_auto_restart.sp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void OnPluginStart()
sb_all_bot_game = FindConVar("sb_all_bot_game");

CreateConVar("l4d2_auto_restart_version", VERSION, "插件版本", FCVAR_NONE | FCVAR_DONTRECORD);
g_cvDelayTime = CreateConVar("l4d2_auto_restart_delay", "20.0", "Restart grace period (in sec.)", FCVAR_NOTIFY);
g_cvDelayTime = CreateConVar("l4d2_auto_restart_delay", "30.0", "Restart grace period (in sec.)", FCVAR_NOTIFY);
g_fDelayTime = g_cvDelayTime.FloatValue;
g_cvDelayTime.AddChangeHook(OnConVarChanged);

Expand All @@ -54,6 +54,11 @@ void Event_PlayerDisconnect(Event event, const char[] name, bool dontBroadcast)
int client = GetClientOfUserId(event.GetInt("userid"));
if (client == 0 || !IsFakeClient(client))
{
char sNetworkid[4];
event.GetString("networkid", sNetworkid, sizeof(sNetworkid));
if (!strcmp(sNetworkid, "BOT", false))
return;

if (!HaveRealPlayer(client))
{
sv_hibernate_when_empty.IntValue = 0;
Expand Down

0 comments on commit a325d0d

Please sign in to comment.