Skip to content

Commit

Permalink
Change remaining SendNetMessage usages to PostEventAbstract
Browse files Browse the repository at this point in the history
INetChannel is a very unstable interface, frequently breaking in CS2 updates. Since IGameEventSystem::PostEventAbstract can do the same thing and is generally more stable, switching over is a no brainer.
  • Loading branch information
Vauff committed Nov 13, 2024
1 parent 583712e commit 7dfb3e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/playermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@
#include "leader.h"
#include "tier0/vprof.h"
#include "networksystem/inetworkmessages.h"
#include "engine/igameeventsystem.h"

#include "tier0/memdbgon.h"


extern IVEngineServer2 *g_pEngineServer2;
extern CGameEntitySystem *g_pEntitySystem;
extern CGlobalVars *gpGlobals;
extern IGameEventSystem* g_gameEventSystem;

static int g_iAdminImmunityTargetting = 0;
static bool g_bEnableMapSteamIds = false;
Expand Down Expand Up @@ -531,7 +533,9 @@ void ZEPlayer::ReplicateConVar(const char* pszName, const char* pszValue)
cvarMsg->set_name(pszName);
cvarMsg->set_value(pszValue);

GetClientBySlot(GetPlayerSlot())->GetNetChannel()->SendNetMessage(data, BUF_RELIABLE);
CSingleRecipientFilter filter(GetPlayerSlot());
g_gameEventSystem->PostEventAbstract(-1, false, &filter, pNetMsg, data, 0);

delete data;
}

Expand Down
3 changes: 2 additions & 1 deletion src/zombiereborn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,8 @@ void ZR_InfectShake(CCSPlayerController *pController)
data->set_amplitude(g_flInfectShakeAmplitude);
data->set_command(0);

pController->GetServerSideClient()->GetNetChannel()->SendNetMessage(data, BUF_RELIABLE);
CSingleRecipientFilter filter(pController->GetPlayerSlot());
g_gameEventSystem->PostEventAbstract(-1, false, &filter, pNetMsg, data, 0);

delete data;
}
Expand Down

0 comments on commit 7dfb3e4

Please sign in to comment.