Skip to content

Commit b0f250a

Browse files
committed
networking: use >= when checking for full updates!
1 parent 89c2428 commit b0f250a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

source/modules/networking.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ struct EntityTransmitCache // Well.... Still kinda acts as a tick-based cache, t
12731273
static EntityTransmitCache g_nEntityTransmitCache;
12741274

12751275
// Full cache persisting across ticks, reset only when the player disconnects.
1276+
static ConVar* sv_stressbots = nullptr;
12761277
static ConVar networking_transmit_newweapons("holylib_networking_transmit_newweapons", "1", 0, "Experimental - If enabled, weapons that a player equipped/was given are networked for the first x ticks");
12771278
static ConVar networking_transmit_ticks("holylib_networking_transmit_ticks", "-1", 0, "Experimental - How many ticks to use for transmit_newweapons & transmit_onfullupdate. -1 will instead ensure they are networked until the client acknowledges them");
12781279
static ConVar networking_transmit_onfullupdate("holylib_networking_transmit_onfullupdate", "1", 0, "Experimental - If enabled, players and their own weapons are transmitted for the first x ticks when they had a full update");
@@ -1281,19 +1282,26 @@ struct PlayerTransmitCache
12811282
{
12821283
inline void NextTick(const CBaseEntity* pPlayer, const int nTick)
12831284
{
1285+
if (!sv_stressbots && g_pCVar)
1286+
sv_stressbots = g_pCVar->FindVar("sv_stressbots");
1287+
12841288
int nTransmitTicks = networking_transmit_ticks.GetInt();
12851289
if (nTransmitTicks == -1) {
12861290
CBaseClient* pClient = Util::GetClientByPlayer((const CBasePlayer*)pPlayer);
12871291
if (pClient) {
1288-
nLastAcknowledgedTick = pClient->GetMaxAckTickCount();
1292+
nLastAcknowledgedTick = pClient->GetMaxAckTickCount(); // pClient->m_nDeltaTick;
1293+
// Verify: GetMaxAckTickCount may be inaccurate for our use case since we need m_nDeltaTick?
1294+
// if (pClient->m_nDeltaTick != pClient->GetMaxAckTickCount())
1295+
// DevMsg(PROJECT_NAME " - networking: Interresting... for client %i (ent index) the delta tick %i differs from the MaxAckTick %i (%i)\n", pPlayer->edict()->m_EdictIndex, pClient->m_nDeltaTick, pClient->GetMaxAckTickCount(), nFullUpdateTick);
1296+
if (pClient->IsFakeClient() && sv_stressbots && !sv_stressbots->GetBool())
1297+
nLastAcknowledgedTick = gpGlobals->tickcount;
12891298
} else {
12901299
DevMsg(PROJECT_NAME " - networking: Failed to get CBaseClient for player %i (ent index)\n", pPlayer->edict()->m_EdictIndex);
12911300
nLastAcknowledgedTick = nTick - 100; // Fallback though should never happen
12921301
}
12931302
} else {
12941303
nLastAcknowledgedTick = nTick - nTransmitTicks;
12951304
}
1296-
12971305

12981306
for (int i=0; i<MAX_WEAPONS; ++i)
12991307
{
@@ -1330,6 +1338,7 @@ struct PlayerTransmitCache
13301338

13311339
void MarkFullUpdate()
13321340
{
1341+
// DevMsg(PROJECT_NAME " - networking: Triggered fullupdate %i\n", gpGlobals->tickcount);
13331342
nFullUpdateTick = gpGlobals->tickcount;
13341343
}
13351344

@@ -1341,7 +1350,8 @@ struct PlayerTransmitCache
13411350
// If the client relative to his own last acknowledged tick
13421351
bool InFullUpdate() const
13431352
{
1344-
return nFullUpdateTick > nLastAcknowledgedTick;
1353+
// DevMsg(PROJECT_NAME " - networking: InFullUpdate %i - %i\n", nFullUpdateTick, nLastAcknowledgedTick);
1354+
return nFullUpdateTick >= nLastAcknowledgedTick;
13451355
}
13461356

13471357
bool bIsValid = false;
@@ -1575,6 +1585,7 @@ static void hook_CBaseCombatCharacter_SetTransmit(CBaseCombatCharacter* pCharact
15751585
const PlayerTransmitCache& pCache = g_pPlayerTransmitCache[pCharacterEdict->m_EdictIndex-1];
15761586
if (networking_transmit_onfullupdate.GetBool() && pCache.InFullUpdate())
15771587
{
1588+
// DevMsg(PROJECT_NAME " - networking: Doing full weapon transmit for %i...\n", pCharacterEdict->m_EdictIndex);
15781589
for (int i=0; i < MAX_WEAPONS; ++i)
15791590
{
15801591
CBaseEntity *pWeapon = GetMyWeapon(pCharacter, i);

0 commit comments

Comments
 (0)