Added timer to reduce join-spam when loading a new map by Floff aka LemonFace

removed an extra line
This commit is contained in:
GreYFoXGTi 2011-01-20 22:25:09 +02:00
parent 7d6c546fcb
commit 9891ab8a10
4 changed files with 25 additions and 14 deletions

View file

@ -190,6 +190,8 @@ CServer::CServer() : m_DemoRecorder(&m_SnapshotDelta)
m_MapReload = 0;
memset(m_aPrevStates, CClient::STATE_EMPTY, MAX_CLIENTS * sizeof(int));
m_RconClientId = -1;
Init();
@ -591,6 +593,7 @@ int CServer::DelClientCallback(int ClientId, const char *pReason, void *pUser)
pThis->m_aClients[ClientId].m_aClan[0] = 0;
pThis->m_aClients[ClientId].m_Authed = 0;
pThis->m_aClients[ClientId].m_AuthTries = 0;
pThis->m_aPrevStates[ClientId] = CClient::STATE_EMPTY;
memset(&pThis->m_aClients[ClientId].m_Addr, 0, sizeof(NETADDR));
pThis->m_aClients[ClientId].m_Snapshots.PurgeAll();
return 0;
@ -1147,6 +1150,11 @@ int CServer::LoadMap(const char *pMapName)
io_read(File, m_pCurrentMapData, m_CurrentMapSize);
io_close(File);
}
for(int i=0; i<MAX_CLIENTS; i++) {
m_aPrevStates[i] = m_aClients[i].m_State;
}
return 1;
}

View file

@ -109,6 +109,7 @@ public:
};
CClient m_aClients[MAX_CLIENTS];
int m_aPrevStates[MAX_CLIENTS];
CSnapshotDelta m_SnapshotDelta;
CSnapshotBuilder m_SnapshotBuilder;

View file

@ -647,21 +647,24 @@ void CGameContext::OnClientEnter(int ClientId)
Score()->PlayerData(ClientId)->m_CurrentTime = Score()->PlayerData(ClientId)->m_BestTime;
m_apPlayers[ClientId]->m_Score = (Score()->PlayerData(ClientId)->m_BestTime)?Score()->PlayerData(ClientId)->m_BestTime:-9999;
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the %s", Server()->ClientName(ClientId), m_pController->GetTeamName(m_apPlayers[ClientId]->GetTeam()));
SendChat(-1, CGameContext::CHAT_ALL, aBuf);
SendChatTarget(ClientId, "DDRace Mod. Version: " DDRACE_VERSION);
SendChatTarget(ClientId, "Official site: DDRace.info");
SendChatTarget(ClientId, "For more Info /cmdlist");
SendChatTarget(ClientId, "Or visit DDRace.info");
SendChatTarget(ClientId, "To see this again say /info");
SendChatTarget(ClientId, "Note This is an Alpha release, just for testing, your feedback is important!!");
if(((CServer *) Server())->m_aPrevStates[ClientId] < CServer::CClient::STATE_INGAME)
{
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the %s", Server()->ClientName(ClientId), m_pController->GetTeamName(m_apPlayers[ClientId]->GetTeam()));
SendChat(-1, CGameContext::CHAT_ALL, aBuf);
if(g_Config.m_SvWelcome[0]!=0) SendChatTarget(ClientId,g_Config.m_SvWelcome);
//str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), m_apPlayers[ClientId]->GetTeam());
SendChatTarget(ClientId, "DDRace Mod. Version: " DDRACE_VERSION);
SendChatTarget(ClientId, "Official site: DDRace.info");
SendChatTarget(ClientId, "For more Info /cmdlist");
SendChatTarget(ClientId, "Or visit DDRace.info");
SendChatTarget(ClientId, "To see this again say /info");
SendChatTarget(ClientId, "Note This is an Alpha release, just for testing, your feedback is important!!");
if(g_Config.m_SvWelcome[0]!=0) SendChatTarget(ClientId,g_Config.m_SvWelcome);
//str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), m_apPlayers[ClientId]->GetTeam());
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
}
m_VoteUpdate = true;
}

View file

@ -268,5 +268,4 @@ void CGameWorld::ReleaseHooked(int ClientId)
p->m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
p->m_Core.m_HookState = HOOK_RETRACTED;
}
}