diff options
| author | GreYFoXGTi <GreYFoXGTi@GMaiL.CoM> | 2011-02-12 12:40:36 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-02-12 21:18:41 +0100 |
| commit | 1b2703aaba9ef21b8fca7c12b299fcd0fd4b9251 (patch) | |
| tree | d4b94b98105c3af23c79bae02a132bfe66738392 /src/game/server/gamecontext.cpp | |
| parent | e45ad2a085d8f02aadc5d823a1d7dda4e1da70aa (diff) | |
| download | zcatch-1b2703aaba9ef21b8fca7c12b299fcd0fd4b9251.tar.gz zcatch-1b2703aaba9ef21b8fca7c12b299fcd0fd4b9251.zip | |
Refactoring & fixed WEAPONSPEC_GUN in content.py
Diffstat (limited to 'src/game/server/gamecontext.cpp')
| -rw-r--r-- | src/game/server/gamecontext.cpp | 348 |
1 files changed, 174 insertions, 174 deletions
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index d0e13f47..5b82b785 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -74,52 +74,52 @@ void CGameContext::Clear() } -class CCharacter *CGameContext::GetPlayerChar(int ClientId) +class CCharacter *CGameContext::GetPlayerChar(int ClientID) { - if(ClientId < 0 || ClientId >= MAX_CLIENTS || !m_apPlayers[ClientId]) + if(ClientID < 0 || ClientID >= MAX_CLIENTS || !m_apPlayers[ClientID]) return 0; - return m_apPlayers[ClientId]->GetCharacter(); + return m_apPlayers[ClientID]->GetCharacter(); } -void CGameContext::CreateDamageInd(vec2 p, float Angle, int Amount) +void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount) { - float a = 3 * 3.14159f / 2 + Angle; + float A = 3 * 3.14159f / 2 + Angle; //float a = get_angle(dir); - float s = a-pi/3; - float e = a+pi/3; + float S = A-pi/3; + float E = A+pi/3; for(int i = 0; i < Amount; i++) { - float f = mix(s, e, float(i+1)/float(Amount+2)); - NETEVENT_DAMAGEIND *ev = (NETEVENT_DAMAGEIND *)m_Events.Create(NETEVENTTYPE_DAMAGEIND, sizeof(NETEVENT_DAMAGEIND)); - if(ev) + float F = mix(S, E, float(i+1)/float(Amount+2)); + NETEVENT_DAMAGEIND *pEvent = (NETEVENT_DAMAGEIND *)m_Events.Create(NETEVENTTYPE_DAMAGEIND, sizeof(NETEVENT_DAMAGEIND)); + if(pEvent) { - ev->m_X = (int)p.x; - ev->m_Y = (int)p.y; - ev->m_Angle = (int)(f*256.0f); + pEvent->m_X = (int)Pos.x; + pEvent->m_Y = (int)Pos.y; + pEvent->m_Angle = (int)(F*256.0f); } } } -void CGameContext::CreateHammerHit(vec2 p) +void CGameContext::CreateHammerHit(vec2 Pos) { // create the event - NETEVENT_HAMMERHIT *ev = (NETEVENT_HAMMERHIT *)m_Events.Create(NETEVENTTYPE_HAMMERHIT, sizeof(NETEVENT_HAMMERHIT)); - if(ev) + NETEVENT_HAMMERHIT *pEvent = (NETEVENT_HAMMERHIT *)m_Events.Create(NETEVENTTYPE_HAMMERHIT, sizeof(NETEVENT_HAMMERHIT)); + if(pEvent) { - ev->m_X = (int)p.x; - ev->m_Y = (int)p.y; + pEvent->m_X = (int)Pos.x; + pEvent->m_Y = (int)Pos.y; } } -void CGameContext::CreateExplosion(vec2 p, int Owner, int Weapon, bool NoDamage) +void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage) { // create the event - NETEVENT_EXPLOSION *ev = (NETEVENT_EXPLOSION *)m_Events.Create(NETEVENTTYPE_EXPLOSION, sizeof(NETEVENT_EXPLOSION)); - if(ev) + NETEVENT_EXPLOSION *pEvent = (NETEVENT_EXPLOSION *)m_Events.Create(NETEVENTTYPE_EXPLOSION, sizeof(NETEVENT_EXPLOSION)); + if(pEvent) { - ev->m_X = (int)p.x; - ev->m_Y = (int)p.y; + pEvent->m_X = (int)Pos.x; + pEvent->m_Y = (int)Pos.y; } if (!NoDamage) @@ -128,10 +128,10 @@ void CGameContext::CreateExplosion(vec2 p, int Owner, int Weapon, bool NoDamage) CCharacter *apEnts[MAX_CLIENTS]; float Radius = 135.0f; float InnerRadius = 48.0f; - int Num = m_World.FindEntities(p, Radius, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); + int Num = m_World.FindEntities(Pos, Radius, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); for(int i = 0; i < Num; i++) { - vec2 Diff = apEnts[i]->m_Pos - p; + vec2 Diff = apEnts[i]->m_Pos - Pos; vec2 ForceDir(0,1); float l = length(Diff); if(l) @@ -145,37 +145,37 @@ void CGameContext::CreateExplosion(vec2 p, int Owner, int Weapon, bool NoDamage) } /* -void create_smoke(vec2 p) +void create_smoke(vec2 P) { // create the event - EV_EXPLOSION *ev = (EV_EXPLOSION *)events.create(EVENT_SMOKE, sizeof(EV_EXPLOSION)); - if(ev) + EV_EXPLOSION *pEvent = (EV_EXPLOSION *)events.create(EVENT_SMOKE, sizeof(EV_EXPLOSION)); + if(pEvent) { - ev->x = (int)p.x; - ev->y = (int)p.y; + pEvent->x = (int)P.x; + pEvent->y = (int)P.y; } }*/ -void CGameContext::CreatePlayerSpawn(vec2 p) +void CGameContext::CreatePlayerSpawn(vec2 Pos) { // create the event NETEVENT_SPAWN *ev = (NETEVENT_SPAWN *)m_Events.Create(NETEVENTTYPE_SPAWN, sizeof(NETEVENT_SPAWN)); if(ev) { - ev->m_X = (int)p.x; - ev->m_Y = (int)p.y; + ev->m_X = (int)Pos.x; + ev->m_Y = (int)Pos.y; } } -void CGameContext::CreateDeath(vec2 p, int ClientId) +void CGameContext::CreateDeath(vec2 Pos, int ClientID) { // create the event - NETEVENT_DEATH *ev = (NETEVENT_DEATH *)m_Events.Create(NETEVENTTYPE_DEATH, sizeof(NETEVENT_DEATH)); - if(ev) + NETEVENT_DEATH *pEvent = (NETEVENT_DEATH *)m_Events.Create(NETEVENTTYPE_DEATH, sizeof(NETEVENT_DEATH)); + if(pEvent) { - ev->m_X = (int)p.x; - ev->m_Y = (int)p.y; - ev->m_ClientId = ClientId; + pEvent->m_X = (int)Pos.x; + pEvent->m_Y = (int)Pos.y; + pEvent->m_ClientID = ClientID; } } @@ -185,12 +185,12 @@ void CGameContext::CreateSound(vec2 Pos, int Sound, int Mask) return; // create a sound - NETEVENT_SOUNDWORLD *ev = (NETEVENT_SOUNDWORLD *)m_Events.Create(NETEVENTTYPE_SOUNDWORLD, sizeof(NETEVENT_SOUNDWORLD), Mask); - if(ev) + NETEVENT_SOUNDWORLD *pEvent = (NETEVENT_SOUNDWORLD *)m_Events.Create(NETEVENTTYPE_SOUNDWORLD, sizeof(NETEVENT_SOUNDWORLD), Mask); + if(pEvent) { - ev->m_X = (int)Pos.x; - ev->m_Y = (int)Pos.y; - ev->m_SoundId = Sound; + pEvent->m_X = (int)Pos.x; + pEvent->m_Y = (int)Pos.y; + pEvent->m_SoundID = Sound; } } @@ -200,7 +200,7 @@ void CGameContext::CreateSoundGlobal(int Sound, int Target) return; CNetMsg_Sv_SoundGlobal Msg; - Msg.m_Soundid = Sound; + Msg.m_SoundID = Sound; Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, Target); } @@ -209,17 +209,17 @@ void CGameContext::SendChatTarget(int To, const char *pText) { CNetMsg_Sv_Chat Msg; Msg.m_Team = 0; - Msg.m_Cid = -1; + Msg.m_ClientID = -1; Msg.m_pMessage = pText; Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, To); } -void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText) +void CGameContext::SendChat(int ChatterClientID, int Team, const char *pText) { char aBuf[256]; - if(ChatterClientId >= 0 && ChatterClientId < MAX_CLIENTS) - str_format(aBuf, sizeof(aBuf), "%d:%d:%s: %s", ChatterClientId, Team, Server()->ClientName(ChatterClientId), pText); + if(ChatterClientID >= 0 && ChatterClientID < MAX_CLIENTS) + str_format(aBuf, sizeof(aBuf), "%d:%d:%s: %s", ChatterClientID, Team, Server()->ClientName(ChatterClientID), pText); else str_format(aBuf, sizeof(aBuf), "*** %s", pText); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "chat", aBuf); @@ -228,7 +228,7 @@ void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText) { CNetMsg_Sv_Chat Msg; Msg.m_Team = 0; - Msg.m_Cid = ChatterClientId; + Msg.m_ClientID = ChatterClientID; Msg.m_pMessage = pText; Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); } @@ -236,7 +236,7 @@ void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText) { CNetMsg_Sv_Chat Msg; Msg.m_Team = 1; - Msg.m_Cid = ChatterClientId; + Msg.m_ClientID = ChatterClientID; Msg.m_pMessage = pText; // pack one for the recording only @@ -251,27 +251,27 @@ void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText) } } -void CGameContext::SendEmoticon(int ClientId, int Emoticon) +void CGameContext::SendEmoticon(int ClientID, int Emoticon) { CNetMsg_Sv_Emoticon Msg; - Msg.m_Cid = ClientId; + Msg.m_ClientID = ClientID; Msg.m_Emoticon = Emoticon; Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); } -void CGameContext::SendWeaponPickup(int ClientId, int Weapon) +void CGameContext::SendWeaponPickup(int ClientID, int Weapon) { CNetMsg_Sv_WeaponPickup Msg; Msg.m_Weapon = Weapon; - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId); + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); } -void CGameContext::SendBroadcast(const char *pText, int ClientId) +void CGameContext::SendBroadcast(const char *pText, int ClientID) { CNetMsg_Sv_Broadcast Msg; Msg.m_pMessage = pText; - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId); + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); } // @@ -307,7 +307,7 @@ void CGameContext::EndVote() SendVoteSet(-1); } -void CGameContext::SendVoteSet(int ClientId) +void CGameContext::SendVoteSet(int ClientID) { CNetMsg_Sv_VoteSet Msg; if(m_VoteCloseTime) @@ -322,10 +322,10 @@ void CGameContext::SendVoteSet(int ClientId) Msg.m_pDescription = ""; Msg.m_pCommand = ""; } - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId); + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); } -void CGameContext::SendVoteStatus(int ClientId, int Total, int Yes, int No) +void CGameContext::SendVoteStatus(int ClientID, int Total, int Yes, int No) { CNetMsg_Sv_VoteStatus Msg = {0}; Msg.m_Total = Total; @@ -333,13 +333,13 @@ void CGameContext::SendVoteStatus(int ClientId, int Total, int Yes, int No) Msg.m_No = No; Msg.m_Pass = Total - (Yes+No); - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId); + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); } -void CGameContext::AbortVoteKickOnDisconnect(int ClientId) +void CGameContext::AbortVoteKickOnDisconnect(int ClientID) { - if(m_VoteCloseTime && !str_comp_num(m_aVoteCommand, "kick ", 5) && str_toint(&m_aVoteCommand[5]) == ClientId) + if(m_VoteCloseTime && !str_comp_num(m_aVoteCommand, "kick ", 5) && str_toint(&m_aVoteCommand[5]) == ClientID) m_VoteCloseTime = -1; } @@ -363,7 +363,7 @@ void CGameContext::CheckPureTuning() } } -void CGameContext::SendTuningParams(int Cid) +void CGameContext::SendTuningParams(int ClientID) { CheckPureTuning(); @@ -371,7 +371,7 @@ void CGameContext::SendTuningParams(int Cid) int *pParams = (int *)&m_Tuning; for(unsigned i = 0; i < sizeof(m_Tuning)/sizeof(int); i++) Msg.AddInt(pParams[i]); - Server()->SendMsg(&Msg, MSGFLAG_VITAL, Cid); + Server()->SendMsg(&Msg, MSGFLAG_VITAL, ClientID); } void CGameContext::OnTick() @@ -496,26 +496,26 @@ void CGameContext::OnClientPredictedInput(int ClientID, void *pInput) m_apPlayers[ClientID]->OnPredictedInput((CNetObj_PlayerInput *)pInput); } -void CGameContext::OnClientEnter(int ClientId) +void CGameContext::OnClientEnter(int ClientID) { //world.insert_entity(&players[client_id]); - m_apPlayers[ClientId]->Respawn(); + m_apPlayers[ClientID]->Respawn(); char aBuf[512]; - str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the %s", Server()->ClientName(ClientId), m_pController->GetTeamName(m_apPlayers[ClientId]->GetTeam())); + 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); - str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), m_apPlayers[ClientId]->GetTeam()); + 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); m_VoteUpdate = true; } -void CGameContext::OnClientConnected(int ClientId) +void CGameContext::OnClientConnected(int ClientID) { // Check which team the player should be on - const int StartTeam = g_Config.m_SvTournamentMode ? TEAM_SPECTATORS : m_pController->GetAutoTeam(ClientId); + const int StartTeam = g_Config.m_SvTournamentMode ? TEAM_SPECTATORS : m_pController->GetAutoTeam(ClientID); - m_apPlayers[ClientId] = new(ClientId) CPlayer(this, ClientId, StartTeam); + m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, StartTeam); //players[client_id].init(client_id); //players[client_id].client_id = client_id; @@ -524,58 +524,58 @@ void CGameContext::OnClientConnected(int ClientId) #ifdef CONF_DEBUG if(g_Config.m_DbgDummies) { - if(ClientId >= MAX_CLIENTS-g_Config.m_DbgDummies) + if(ClientID >= MAX_CLIENTS-g_Config.m_DbgDummies) return; } #endif // send active vote if(m_VoteCloseTime) - SendVoteSet(ClientId); + SendVoteSet(ClientID); // send motd CNetMsg_Sv_Motd Msg; Msg.m_pMessage = g_Config.m_SvMotd; - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId); + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID); } -void CGameContext::OnClientDrop(int ClientId) +void CGameContext::OnClientDrop(int ClientID) { - AbortVoteKickOnDisconnect(ClientId); - m_apPlayers[ClientId]->OnDisconnect(); - delete m_apPlayers[ClientId]; - m_apPlayers[ClientId] = 0; + AbortVoteKickOnDisconnect(ClientID); + m_apPlayers[ClientID]->OnDisconnect(); + delete m_apPlayers[ClientID]; + m_apPlayers[ClientID] = 0; (void)m_pController->CheckTeamBalance(); m_VoteUpdate = true; } -void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) +void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { - void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker); - CPlayer *p = m_apPlayers[ClientId]; + void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgID, pUnpacker); + CPlayer *pPlayer = m_apPlayers[ClientID]; if(!pRawMsg) { char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn()); + str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn()); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); return; } - if(MsgId == NETMSGTYPE_CL_SAY) + if(MsgID == NETMSGTYPE_CL_SAY) { CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg; int Team = pMsg->m_Team; if(Team) - Team = p->GetTeam(); + Team = pPlayer->GetTeam(); else Team = CGameContext::CHAT_ALL; - if(g_Config.m_SvSpamprotection && p->m_Last_Chat && p->m_Last_Chat+Server()->TickSpeed() > Server()->Tick()) + if(g_Config.m_SvSpamprotection && pPlayer->m_Last_Chat && pPlayer->m_Last_Chat+Server()->TickSpeed() > Server()->Tick()) return; - p->m_Last_Chat = Server()->Tick(); + pPlayer->m_Last_Chat = Server()->Tick(); // check for invalid chars unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage; @@ -586,33 +586,33 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) pMessage++; } - SendChat(ClientId, Team, pMsg->m_pMessage); + SendChat(ClientID, Team, pMsg->m_pMessage); } - else if(MsgId == NETMSGTYPE_CL_CALLVOTE) + else if(MsgID == NETMSGTYPE_CL_CALLVOTE) { - if(g_Config.m_SvSpamprotection && p->m_Last_VoteTry && p->m_Last_VoteTry+Server()->TickSpeed()*3 > Server()->Tick()) + if(g_Config.m_SvSpamprotection && pPlayer->m_Last_VoteTry && pPlayer->m_Last_VoteTry+Server()->TickSpeed()*3 > Server()->Tick()) return; int64 Now = Server()->Tick(); - p->m_Last_VoteTry = Now; - if(p->GetTeam() == TEAM_SPECTATORS) + pPlayer->m_Last_VoteTry = Now; + if(pPlayer->GetTeam() == TEAM_SPECTATORS) { - SendChatTarget(ClientId, "Spectators aren't allowed to start a vote."); + SendChatTarget(ClientID, "Spectators aren't allowed to start a vote."); return; } if(m_VoteCloseTime) { - SendChatTarget(ClientId, "Wait for current vote to end before calling a new one."); + SendChatTarget(ClientID, "Wait for current vote to end before calling a new one."); return; } - int Timeleft = p->m_Last_VoteCall + Server()->TickSpeed()*60 - Now; - if(p->m_Last_VoteCall && Timeleft > 0) + int Timeleft = pPlayer->m_Last_VoteCall + Server()->TickSpeed()*60 - Now; + if(pPlayer->m_Last_VoteCall && Timeleft > 0) { char aChatmsg[512] = {0}; str_format(aChatmsg, sizeof(aChatmsg), "You must wait %d seconds before making another vote", (Timeleft/Server()->TickSpeed())+1); - SendChatTarget(ClientId, aChatmsg); + SendChatTarget(ClientID, aChatmsg); return; } @@ -627,7 +627,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) { if(str_comp_nocase(pMsg->m_Value, pOption->m_aCommand) == 0) { - str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s'", Server()->ClientName(ClientId), pOption->m_aCommand); + str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s'", Server()->ClientName(ClientID), pOption->m_aCommand); str_format(aDesc, sizeof(aDesc), "%s", pOption->m_aCommand); str_format(aCmd, sizeof(aCmd), "%s", pOption->m_aCommand); break; @@ -639,7 +639,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) if(!pOption) { str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value); - SendChatTarget(ClientId, aChatmsg); + SendChatTarget(ClientID, aChatmsg); return; } } @@ -647,48 +647,48 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) { if(!g_Config.m_SvVoteKick) { - SendChatTarget(ClientId, "Server does not allow voting to kick players"); + SendChatTarget(ClientID, "Server does not allow voting to kick players"); return; } - int KickId = str_toint(pMsg->m_Value); - if(KickId < 0 || KickId >= MAX_CLIENTS || !m_apPlayers[KickId]) + int KickID = str_toint(pMsg->m_Value); + if(KickID < 0 || KickID >= MAX_CLIENTS || !m_apPlayers[KickID]) { - SendChatTarget(ClientId, "Invalid client id to kick"); + SendChatTarget(ClientID, "Invalid client id to kick"); return; } - if(KickId == ClientId) + if(KickID == ClientID) { - SendChatTarget(ClientId, "You cant kick yourself"); + SendChatTarget(ClientID, "You cant kick yourself"); return; } - if(Server()->IsAuthed(KickId)) + if(Server()->IsAuthed(KickID)) { - SendChatTarget(ClientId, "You cant kick admins"); + SendChatTarget(ClientID, "You cant kick admins"); char aBufKick[128]; - str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientId)); - SendChatTarget(KickId, aBufKick); + str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID)); + SendChatTarget(KickID, aBufKick); return; } const char *pReason = "No reason given"; - for(const char *p = pMsg->m_Value; *p; ++p) + for(const char *pStr = pMsg->m_Value; *pStr; ++pStr) { - if(*p == ' ') + if(*pStr == ' ') { - pReason = p+1; + pReason = pStr+1; break; } } - str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientId), Server()->ClientName(KickId), pReason); - str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickId)); + str_format(aChatmsg, sizeof(aChatmsg), "'%s' called for vote to kick '%s' (%s)", Server()->ClientName(ClientID), Server()->ClientName(KickID), pReason); + str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickID)); if (!g_Config.m_SvVoteKickBantime) - str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickId); + str_format(aCmd, sizeof(aCmd), "kick %d Kicked by vote", KickID); else { char aBuf[64] = {0}; - Server()->GetClientIP(KickId, aBuf, sizeof(aBuf)); + Server()->GetClientIP(KickID, aBuf, sizeof(aBuf)); str_format(aCmd, sizeof(aCmd), "ban %s %d Banned by vote", aBuf, g_Config.m_SvVoteKickBantime); } } @@ -697,127 +697,127 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) { SendChat(-1, CGameContext::CHAT_ALL, aChatmsg); StartVote(aDesc, aCmd); - p->m_Vote = 1; - p->m_VotePos = m_VotePos = 1; - m_VoteCreator = ClientId; - p->m_Last_VoteCall = Now; + pPlayer->m_Vote = 1; + pPlayer->m_VotePos = m_VotePos = 1; + m_VoteCreator = ClientID; + pPlayer->m_Last_VoteCall = Now; } } - else if(MsgId == NETMSGTYPE_CL_VOTE) + else if(MsgID == NETMSGTYPE_CL_VOTE) { if(!m_VoteCloseTime) return; - if(p->m_Vote == 0) + if(pPlayer->m_Vote == 0) { CNetMsg_Cl_Vote *pMsg = (CNetMsg_Cl_Vote *)pRawMsg; if(!pMsg->m_Vote) return; - p->m_Vote = pMsg->m_Vote; - p->m_VotePos = ++m_VotePos; + pPlayer->m_Vote = pMsg->m_Vote; + pPlayer->m_VotePos = ++m_VotePos; m_VoteUpdate = true; } } - else if (MsgId == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused) + else if (MsgID == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused) { CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg; - if(p->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && p->m_Last_SetTeam && p->m_Last_SetTeam+Server()->TickSpeed()*3 > Server()->Tick())) + if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_Last_SetTeam && pPlayer->m_Last_SetTeam+Server()->TickSpeed()*3 > Server()->Tick())) return; // Switch team on given client and kill/respawn him - if(m_pController->CanJoinTeam(pMsg->m_Team, ClientId)) + if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID)) { - if(m_pController->CanChangeTeam(p, pMsg->m_Team)) + if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team)) { - p->m_Last_SetTeam = Server()->Tick(); - if(p->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS) + pPlayer->m_Last_SetTeam = Server()->Tick(); + if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS) m_VoteUpdate = true; - p->SetTeam(pMsg->m_Team); + pPlayer->SetTeam(pMsg->m_Team); (void)m_pController->CheckTeamBalance(); } else - SendBroadcast("Teams must be balanced, please join other team", ClientId); + SendBroadcast("Teams must be balanced, please join other team", ClientID); } else { char aBuf[128]; str_format(aBuf, sizeof(aBuf), "Only %d active players are allowed", g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots); - SendBroadcast(aBuf, ClientId); + SendBroadcast(aBuf, ClientID); } } - else if (MsgId == NETMSGTYPE_CL_CHANGEINFO || MsgId == NETMSGTYPE_CL_STARTINFO) + else if (MsgID == NETMSGTYPE_CL_CHANGEINFO || MsgID == NETMSGTYPE_CL_STARTINFO) { CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg; - if(g_Config.m_SvSpamprotection && p->m_Last_ChangeInfo && p->m_Last_ChangeInfo+Server()->TickSpeed()*5 > Server()->Tick()) + if(g_Config.m_SvSpamprotection && pPlayer->m_Last_ChangeInfo && pPlayer->m_Last_ChangeInfo+Server()->TickSpeed()*5 > Server()->Tick()) return; - p->m_Last_ChangeInfo = Server()->Tick(); + pPlayer->m_Last_ChangeInfo = Server()->Tick(); - p->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; - p->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; - p->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; + pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; + pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; + pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet; // copy old name char aOldName[MAX_NAME_LENGTH]; - str_copy(aOldName, Server()->ClientName(ClientId), MAX_NAME_LENGTH); + str_copy(aOldName, Server()->ClientName(ClientID), MAX_NAME_LENGTH); - Server()->SetClientName(ClientId, pMsg->m_pName); - if(MsgId == NETMSGTYPE_CL_CHANGEINFO && str_comp(aOldName, Server()->ClientName(ClientId)) != 0) + Server()->SetClientName(ClientID, pMsg->m_pName); + if(MsgID == NETMSGTYPE_CL_CHANGEINFO && str_comp(aOldName, Server()->ClientName(ClientID)) != 0) { char aChatText[256]; - str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientId)); + str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientID)); SendChat(-1, CGameContext::CHAT_ALL, aChatText); } // set skin - str_copy(p->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(p->m_TeeInfos.m_SkinName)); + str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); - m_pController->OnPlayerInfoChange(p); + m_pController->OnPlayerInfoChange(pPlayer); - if(MsgId == NETMSGTYPE_CL_STARTINFO) + if(MsgID == NETMSGTYPE_CL_STARTINFO) { // send vote options CNetMsg_Sv_VoteClearOptions ClearMsg; - Server()->SendPackMsg(&ClearMsg, MSGFLAG_VITAL, ClientId); + Server()->SendPackMsg(&ClearMsg, MSGFLAG_VITAL, ClientID); CVoteOption *pCurrent = m_pVoteOptionFirst; while(pCurrent) { CNetMsg_Sv_VoteOption OptionMsg; OptionMsg.m_pCommand = pCurrent->m_aCommand; - Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientId); + Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientID); pCurrent = pCurrent->m_pNext; } // send tuning parameters to client - SendTuningParams(ClientId); + SendTuningParams(ClientID); // CNetMsg_Sv_ReadyToEnter m; - Server()->SendPackMsg(&m, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientId); + Server()->SendPackMsg(&m, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID); } } - else if (MsgId == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused) + else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused) { CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg; - if(g_Config.m_SvSpamprotection && p->m_Last_Emote && p->m_Last_Emote+Server()->TickSpeed()*3 > Server()->Tick()) + if(g_Config.m_SvSpamprotection && pPlayer->m_Last_Emote && pPlayer->m_Last_Emote+Server()->TickSpeed()*3 > Server()->Tick()) return; - p->m_Last_Emote = Server()->Tick(); + pPlayer->m_Last_Emote = Server()->Tick(); - SendEmoticon(ClientId, pMsg->m_Emoticon); + SendEmoticon(ClientID, pMsg->m_Emoticon); } - else if (MsgId == NETMSGTYPE_CL_KILL && !m_World.m_Paused) + else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused) { - if(p->m_Last_Kill && p->m_Last_Kill+Server()->TickSpeed()*3 > Server()->Tick()) + if(pPlayer->m_Last_Kill && pPlayer->m_Last_Kill+Server()->TickSpeed()*3 > Server()->Tick()) return; - p->m_Last_Kill = Server()->Tick(); - p->KillCharacter(WEAPON_SELF); - p->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()*3; + pPlayer->m_Last_Kill = Server()->Tick(); + pPlayer->KillCharacter(WEAPON_SELF); + pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()*3; } } @@ -841,8 +841,8 @@ void CGameContext::ConTuneParam(IConsole::IResult *pResult, void *pUserData) void CGameContext::ConTuneReset(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; - CTuningParams p; - *pSelf->Tuning() = p; + CTuningParams TuningParams; + *pSelf->Tuning() = TuningParams; pSelf->SendTuningParams(-1); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", "Tuning reset"); } @@ -853,9 +853,9 @@ void CGameContext::ConTuneDump(IConsole::IResult *pResult, void *pUserData) char aBuf[256]; for(int i = 0; i < pSelf->Tuning()->Num(); i++) { - float v; - pSelf->Tuning()->Get(i, &v); - str_format(aBuf, sizeof(aBuf), "%s %.2f", pSelf->Tuning()->m_apNames[i], v); + float V; + pSelf->Tuning()->Get(i, &V); + str_format(aBuf, sizeof(aBuf), "%s %.2f", pSelf->Tuning()->m_apNames[i], V); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", aBuf); } } @@ -890,17 +890,17 @@ void CGameContext::ConSay(IConsole::IResult *pResult, void *pUserData) void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; - int ClientId = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1); + int ClientID = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1); int Team = clamp(pResult->GetInteger(1), -1, 1); char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "moved client %d to team %d", ClientId, Team); + str_format(aBuf, sizeof(aBuf), "moved client %d to team %d", ClientID, Team); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); - if(!pSelf->m_apPlayers[ClientId]) + if(!pSelf->m_apPlayers[ClientID]) return; - pSelf->m_apPlayers[ClientId]->SetTeam(Team); + pSelf->m_apPlayers[ClientID]->SetTeam(Team); (void)pSelf->m_pController->CheckTeamBalance(); } @@ -1112,16 +1112,16 @@ void CGameContext::OnShutdown() Clear(); } -void CGameContext::OnSnap(int ClientId) +void CGameContext::OnSnap(int ClientID) { - m_World.Snap(ClientId); - m_pController->Snap(ClientId); - m_Events.Snap(ClientId); + m_World.Snap(ClientID); + m_pController->Snap(ClientID); + m_Events.Snap(ClientID); for(int i = 0; i < MAX_CLIENTS; i++) { if(m_apPlayers[i]) - m_apPlayers[i]->Snap(ClientId); + m_apPlayers[i]->Snap(ClientID); } } void CGameContext::OnPreSnap() {} |