Skip to content

Commit b6d9dae

Browse files
authored
Merge pull request #266 from tmp64/bugfix/anti-flood-pause
Server: Use pfnTime for chat flood check
2 parents 2268b5d + 09a55d0 commit b6d9dae

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/game/server/client.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,20 +297,25 @@ void Host_Say(edict_t *pEntity, int teamonly)
297297
CBasePlayer *player = GetClassPtr((CBasePlayer *)pev);
298298

299299
// Flood check
300-
if (player->m_flNextChatTime > gpGlobals->time)
300+
// Note: Use g_engfuncs.pfnTime() instead of gpGlobals->time because it doesn't work in pause
301+
float asyncTime = g_engfuncs.pfnTime();
302+
303+
if (player->m_flNextChatTime > asyncTime)
301304
{
302305
if (player->m_iChatFlood >= CHAT_FLOOD)
303306
{
304-
player->m_flNextChatTime = gpGlobals->time + CHAT_INTERVAL + CHAT_PENALTY;
307+
player->m_flNextChatTime = asyncTime + CHAT_INTERVAL + CHAT_PENALTY;
305308
return;
306309
}
310+
307311
player->m_iChatFlood++;
308312
}
309313
else if (player->m_iChatFlood)
310314
{
311315
player->m_iChatFlood--;
312316
}
313-
player->m_flNextChatTime = gpGlobals->time + CHAT_INTERVAL;
317+
318+
player->m_flNextChatTime = asyncTime + CHAT_INTERVAL;
314319

315320
// We can get a raw string now, without the "say " prepended
316321
if (!_stricmp(pcmd, cpSay) || !_stricmp(pcmd, cpSayTeam))

src/game/server/player.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3471,7 +3471,7 @@ void CBasePlayer::Spawn(void)
34713471
m_lastx = m_lasty = 0;
34723472

34733473
m_iChatFlood = 0;
3474-
m_flNextChatTime = gpGlobals->time;
3474+
m_flNextChatTime = 0; // Not using gpGlobals->time - see Host_Say
34753475
m_flNextFullupdate[0] = gpGlobals->time;
34763476
m_flNextFullupdate[1] = gpGlobals->time;
34773477

0 commit comments

Comments
 (0)