diff options
Diffstat (limited to 'src/game/server')
| -rw-r--r-- | src/game/server/entities/character.cpp | 8 | ||||
| -rw-r--r-- | src/game/server/entities/pickup.cpp | 4 | ||||
| -rw-r--r-- | src/game/server/gamecontext.cpp | 42 | ||||
| -rw-r--r-- | src/game/server/gamecontroller.cpp | 31 | ||||
| -rw-r--r-- | src/game/server/gamemodes/ctf.cpp | 19 | ||||
| -rw-r--r-- | src/game/server/player.cpp | 18 |
6 files changed, 78 insertions, 44 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 5dd212a9..ef60cd4c 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -604,7 +604,8 @@ void CCharacter::TickDefered() StartVelX.f = StartVel.x; StartVelY.f = StartVel.y; - dbg_msg("char_core", "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x", + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x", StuckBefore, StuckAfterMove, StuckAfterQuant, @@ -612,6 +613,7 @@ void CCharacter::TickDefered() StartVel.x, StartVel.y, StartPosX.u, StartPosY.u, StartVelX.u, StartVelY.u); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); } int Events = m_Core.m_TriggeredEvents; @@ -669,9 +671,11 @@ void CCharacter::Die(int Killer, int Weapon) { int ModeSpecial = GameServer()->m_pController->OnCharacterDeath(this, GameServer()->m_apPlayers[Killer], Weapon); - dbg_msg("game", "kill killer='%d:%s' victim='%d:%s' weapon=%d special=%d", + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "kill killer='%d:%s' victim='%d:%s' weapon=%d special=%d", Killer, Server()->ClientName(Killer), m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); // send the kill message CNetMsg_Sv_KillMsg Msg; diff --git a/src/game/server/entities/pickup.cpp b/src/game/server/entities/pickup.cpp index 9798e2c3..020b4c60 100644 --- a/src/game/server/entities/pickup.cpp +++ b/src/game/server/entities/pickup.cpp @@ -109,8 +109,10 @@ void CPickup::Tick() if(RespawnTime >= 0) { - dbg_msg("game", "pickup player='%d:%s' item=%d/%d", + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "pickup player='%d:%s' item=%d/%d", pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime; } } diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 3f7a5b14..1b96b812 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -215,10 +215,12 @@ void CGameContext::SendChatTarget(int To, const char *pText) void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText) { + char aBuf[256]; if(ChatterClientId >= 0 && ChatterClientId < MAX_CLIENTS) - dbg_msg("chat", "%d:%d:%s: %s", ChatterClientId, Team, Server()->ClientName(ChatterClientId), pText); + str_format(aBuf, sizeof(aBuf), "%d:%d:%s: %s", ChatterClientId, Team, Server()->ClientName(ChatterClientId), pText); else - dbg_msg("chat", "*** %s", pText); + str_format(aBuf, sizeof(aBuf), "*** %s", pText); + Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "chat", aBuf); if(Team == CHAT_ALL) { @@ -353,7 +355,7 @@ void CGameContext::CheckPureTuning() CTuningParams p; if(mem_comp(&p, &m_Tuning, sizeof(p)) != 0) { - dbg_msg("server", "resetting tuning due to pure server"); + Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "resetting tuning due to pure server"); m_Tuning = p; } } @@ -496,14 +498,12 @@ void CGameContext::OnClientEnter(int ClientId) { //world.insert_entity(&players[client_id]); m_apPlayers[ClientId]->Respawn(); - dbg_msg("game", "join player='%d:%s'", ClientId, Server()->ClientName(ClientId)); - - 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); - dbg_msg("game", "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; } @@ -555,7 +555,9 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) if(!pRawMsg) { - dbg_msg("server", "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn()); + char aBuf[256]; + 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; } @@ -813,13 +815,15 @@ void CGameContext::ConTuneParam(IConsole::IResult *pResult, void *pUserData) const char *pParamName = pResult->GetString(0); float NewValue = pResult->GetFloat(1); + char aBuf[256]; if(pSelf->Tuning()->Set(pParamName, NewValue)) { - dbg_msg("tuning", "%s changed to %.2f", pParamName, NewValue); + str_format(aBuf, sizeof(aBuf), "%s changed to %.2f", pParamName, NewValue); pSelf->SendTuningParams(-1); } else - dbg_msg("tuning", "No such tuning parameter"); + str_format(aBuf, sizeof(aBuf), "No such tuning parameter"); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", aBuf); } void CGameContext::ConTuneReset(IConsole::IResult *pResult, void *pUserData) @@ -828,17 +832,19 @@ void CGameContext::ConTuneReset(IConsole::IResult *pResult, void *pUserData) CTuningParams p; *pSelf->Tuning() = p; pSelf->SendTuningParams(-1); - dbg_msg("tuning", "Tuning reset"); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", "Tuning reset"); } void CGameContext::ConTuneDump(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; + char aBuf[256]; for(int i = 0; i < pSelf->Tuning()->Num(); i++) { float v; pSelf->Tuning()->Get(i, &v); - dbg_msg("tuning", "%s %.2f", pSelf->Tuning()->m_apNames[i], v); + str_format(aBuf, sizeof(aBuf), "%s %.2f", pSelf->Tuning()->m_apNames[i], v); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", aBuf); } } @@ -875,7 +881,9 @@ void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData) int ClientId = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1); int Team = clamp(pResult->GetInteger(1), -1, 1); - dbg_msg("", "%d %d", ClientId, Team); + char aBuf[256]; + 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]) return; @@ -899,7 +907,9 @@ void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData) pSelf->m_pVoteOptionFirst = pOption; mem_copy(pOption->m_aCommand, pResult->GetString(0), Len+1); - dbg_msg("server", "added option '%s'", pOption->m_aCommand); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "added option '%s'", pOption->m_aCommand); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); CNetMsg_Sv_VoteOption OptionMsg; OptionMsg.m_pCommand = pOption->m_aCommand; @@ -913,7 +923,9 @@ void CGameContext::ConVote(IConsole::IResult *pResult, void *pUserData) pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_YES; else if(str_comp_nocase(pResult->GetString(0), "no") == 0) pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO; - dbg_msg("server", "forcing vote %s", pResult->GetString(0)); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "forcing vote %s", pResult->GetString(0)); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); } void CGameContext::ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 04eb8c6e..854787d6 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -200,7 +200,9 @@ void IGameController::StartRound() m_aTeamscore[0] = 0; m_aTeamscore[1] = 0; m_ForceBalanced = false; - dbg_msg("game","start round type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "start round type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); } void IGameController::ChangeMap(const char *pToMap) @@ -213,7 +215,9 @@ void IGameController::CycleMap() { if(m_aMapWish[0] != 0) { - dbg_msg("game", "rotating map to %s", m_aMapWish); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "rotating map to %s", m_aMapWish); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); str_copy(g_Config.m_SvMap, m_aMapWish, sizeof(g_Config.m_SvMap)); m_aMapWish[0] = 0; m_RoundCount = 0; @@ -255,26 +259,28 @@ void IGameController::CycleMap() pNextMap = pMapRotation; // cut out the next map - char Buf[512]; + char aBuf[512]; for(int i = 0; i < 512; i++) { - Buf[i] = pNextMap[i]; + aBuf[i] = pNextMap[i]; if(IsSeparator(pNextMap[i]) || pNextMap[i] == 0) { - Buf[i] = 0; + aBuf[i] = 0; break; } } // skip spaces int i = 0; - while(IsSeparator(Buf[i])) + while(IsSeparator(aBuf[i])) i++; m_RoundCount = 0; - dbg_msg("game", "rotating map to %s", &Buf[i]); - str_copy(g_Config.m_SvMap, &Buf[i], sizeof(g_Config.m_SvMap)); + char aBufMsg[256]; + str_format(aBufMsg, sizeof(aBufMsg), "rotating map to %s", &aBuf[i]); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); + str_copy(g_Config.m_SvMap, &aBuf[i], sizeof(g_Config.m_SvMap)); } void IGameController::PostReset() @@ -398,7 +404,7 @@ void IGameController::Tick() // do team-balancing if (IsTeamplay() && m_UnbalancedTick != -1 && Server()->Tick() > m_UnbalancedTick+g_Config.m_SvTeambalanceTime*Server()->TickSpeed()*60) { - dbg_msg("game", "Balancing teams"); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", "Balancing teams"); int aT[2] = {0,0}; float aTScore[2] = {0,0}; @@ -570,16 +576,19 @@ bool IGameController::CheckTeamBalance() aT[pP->GetTeam()]++; } + char aBuf[256]; if(absolute(aT[0]-aT[1]) >= 2) { - dbg_msg("game", "Team is NOT balanced (red=%d blue=%d)", aT[0], aT[1]); + str_format(aBuf, sizeof(aBuf), "Team is NOT balanced (red=%d blue=%d)", aT[0], aT[1]); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); if(GameServer()->m_pController->m_UnbalancedTick == -1) GameServer()->m_pController->m_UnbalancedTick = Server()->Tick(); return false; } else { - dbg_msg("game", "Team is balanced (red=%d blue=%d)", aT[0], aT[1]); + str_format(aBuf, sizeof(aBuf), "Team is balanced (red=%d blue=%d)", aT[0], aT[1]); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); GameServer()->m_pController->m_UnbalancedTick = -1; return true; } diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index 3c052a91..4b25fc47 100644 --- a/src/game/server/gamemodes/ctf.cpp +++ b/src/game/server/gamemodes/ctf.cpp @@ -111,21 +111,22 @@ void CGameControllerCTF::Tick() m_aTeamscore[fi^1] += 100; F->m_pCarryingCharacter->GetPlayer()->m_Score += 5; - dbg_msg("game", "flag_capture player='%d:%s'", + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), "flag_capture player='%d:%s'", F->m_pCarryingCharacter->GetPlayer()->GetCID(), Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID())); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); - char Buf[512]; float CaptureTime = (Server()->Tick() - F->m_GrabTick)/(float)Server()->TickSpeed(); if(CaptureTime <= 60) { - str_format(Buf, sizeof(Buf), "The %s flag was captured by %s (%d.%s%d seconds)", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()), (int)CaptureTime%60, ((int)(CaptureTime*100)%100)<10?"0":"", (int)(CaptureTime*100)%100); + str_format(aBuf, sizeof(aBuf), "The %s flag was captured by %s (%d.%s%d seconds)", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()), (int)CaptureTime%60, ((int)(CaptureTime*100)%100)<10?"0":"", (int)(CaptureTime*100)%100); } else { - str_format(Buf, sizeof(Buf), "The %s flag was captured by %s", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID())); + str_format(aBuf, sizeof(aBuf), "The %s flag was captured by %s", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID())); } - GameServer()->SendChat(-1, -2, Buf); + GameServer()->SendChat(-1, -2, aBuf); for(int i = 0; i < 2; i++) m_apFlags[i]->Reset(); @@ -150,9 +151,11 @@ void CGameControllerCTF::Tick() CCharacter *pChr = apCloseCCharacters[i]; pChr->GetPlayer()->m_Score += 1; - dbg_msg("game", "flag_return player='%d:%s'", + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "flag_return player='%d:%s'", pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID())); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN); F->Reset(); @@ -171,9 +174,11 @@ void CGameControllerCTF::Tick() F->m_pCarryingCharacter = apCloseCCharacters[i]; F->m_pCarryingCharacter->GetPlayer()->m_Score += 1; - dbg_msg("game", "flag_grab player='%d:%s'", + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "flag_grab player='%d:%s'", F->m_pCarryingCharacter->GetPlayer()->GetCID(), Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID())); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); for(int c = 0; c < MAX_CLIENTS; c++) { diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 2d5d244f..cc89c11d 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -95,11 +95,12 @@ void CPlayer::OnDisconnect() if(Server()->ClientIngame(m_ClientID)) { - char Buf[512]; - str_format(Buf, sizeof(Buf), "%s has left the game", Server()->ClientName(m_ClientID)); - GameServer()->SendChat(-1, CGameContext::CHAT_ALL, Buf); + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), "%s has left the game", Server()->ClientName(m_ClientID)); + GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf); - dbg_msg("game", "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID)); + str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID)); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf); } } @@ -151,16 +152,17 @@ void CPlayer::SetTeam(int Team) if(m_Team == Team) return; - char Buf[512]; - str_format(Buf, sizeof(Buf), "%s joined the %s", Server()->ClientName(m_ClientID), GameServer()->m_pController->GetTeamName(Team)); - GameServer()->SendChat(-1, CGameContext::CHAT_ALL, Buf); + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), "%s joined the %s", Server()->ClientName(m_ClientID), GameServer()->m_pController->GetTeamName(Team)); + GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf); KillCharacter(); m_Team = Team; // we got to wait 0.5 secs before respawning m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2; - dbg_msg("game", "team_join player='%d:%s' m_Team=%d", m_ClientID, Server()->ClientName(m_ClientID), m_Team); + str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' m_Team=%d", m_ClientID, Server()->ClientName(m_ClientID), m_Team); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); GameServer()->m_pController->OnPlayerInfoChange(GameServer()->m_apPlayers[m_ClientID]); } |