diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/client/components/binds.cpp | 18 | ||||
| -rw-r--r-- | src/game/client/components/chat.cpp | 6 | ||||
| -rw-r--r-- | src/game/client/components/menus_browser.cpp | 2 | ||||
| -rw-r--r-- | src/game/client/components/menus_settings.cpp | 2 | ||||
| -rw-r--r-- | src/game/client/components/skins.cpp | 6 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 22 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.cpp | 8 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.h | 2 | ||||
| -rw-r--r-- | src/game/editor/ed_io.cpp | 14 | ||||
| -rw-r--r-- | src/game/editor/ed_layer_quads.cpp | 3 | ||||
| -rw-r--r-- | src/game/editor/ed_popups.cpp | 3 | ||||
| -rw-r--r-- | src/game/localization.cpp | 12 | ||||
| -rw-r--r-- | src/game/localization.h | 2 | ||||
| -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 |
19 files changed, 145 insertions, 77 deletions
diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index 1fb5ecc5..4b0db425 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -30,10 +30,12 @@ void CBinds::Bind(int KeyId, const char *pStr) return; str_copy(m_aaKeyBindings[KeyId], pStr, sizeof(m_aaKeyBindings[KeyId])); + char aBuf[256]; if(!m_aaKeyBindings[KeyId][0]) - dbg_msg("binds", "unbound %s (%d)", Input()->KeyName(KeyId), KeyId); + str_format(aBuf, sizeof(aBuf), "unbound %s (%d)", Input()->KeyName(KeyId), KeyId); else - dbg_msg("binds", "bound %s (%d) = %s", Input()->KeyName(KeyId), KeyId, m_aaKeyBindings[KeyId]); + str_format(aBuf, sizeof(aBuf), "bound %s (%d) = %s", Input()->KeyName(KeyId), KeyId, m_aaKeyBindings[KeyId]); + Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); } @@ -136,7 +138,9 @@ void CBinds::ConBind(IConsole::IResult *pResult, void *pUserData) if(!id) { - dbg_msg("binds", "key %s not found", pKeyName); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "key %s not found", pKeyName); + pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); return; } @@ -152,7 +156,9 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData) if(!id) { - dbg_msg("binds", "key %s not found", pKeyName); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "key %s not found", pKeyName); + pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); return; } @@ -175,8 +181,8 @@ void CBinds::ConDumpBinds(IConsole::IResult *pResult, void *pUserData) { if(pBinds->m_aaKeyBindings[i][0] == 0) continue; - str_format(aBuf, sizeof(aBuf), "[binds] %s (%d) = %s", pBinds->Input()->KeyName(i), i, pBinds->m_aaKeyBindings[i]); - pBinds->Console()->Print(aBuf); + str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pBinds->Input()->KeyName(i), i, pBinds->m_aaKeyBindings[i]); + pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); } } diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 7b64aac7..21fa0e00 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -61,7 +61,7 @@ void CChat::ConChat(IConsole::IResult *pResult, void *pUserData) else if(str_comp(pMode, "team") == 0) ((CChat*)pUserData)->EnableMode(1); else - dbg_msg("console", "expected all or team as mode"); + ((CChat*)pUserData)->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", "expected all or team as mode"); } void CChat::ConShowChat(IConsole::IResult *pResult, void *pUserData) @@ -165,8 +165,8 @@ void CChat::AddLine(int ClientId, int Team, const char *pLine) } char aBuf[1024]; - str_format(aBuf, sizeof(aBuf), "[chat]%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); - Console()->Print(aBuf); + str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); + Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat", aBuf); } // play sound diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index c1ad18f2..bd643a3c 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -699,7 +699,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView) static int s_JoinButton = 0; if(DoButton_Menu(&s_JoinButton, Localize("Connect"), 0, &Button) || m_EnterPressed) { - dbg_msg("", "%s", g_Config.m_UiServerAddress); + //dbg_msg("", "%s", g_Config.m_UiServerAddress); Client()->Connect(g_Config.m_UiServerAddress); m_EnterPressed = false; } diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 364d0b82..3a97e3ec 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -706,7 +706,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) if(OldSelected != s_SelectedLanguage) { str_copy(g_Config.m_ClLanguagefile, s_Languages[s_SelectedLanguage].m_FileName, sizeof(g_Config.m_ClLanguagefile)); - g_Localization.Load(s_Languages[s_SelectedLanguage].m_FileName); + g_Localization.Load(s_Languages[s_SelectedLanguage].m_FileName, Console()); } } diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index 582adb10..73cf954d 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -29,7 +29,8 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser) CImageInfo Info; if(!pSelf->Graphics()->LoadPNG(&Info, aBuf)) { - dbg_msg("game", "failed to load skin from %s", pName); + str_format(aBuf, sizeof(aBuf), "failed to load skin from %s", pName); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf); return; } @@ -111,7 +112,8 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser) // set skin data str_copy(pSelf->m_aSkins[pSelf->m_NumSkins].m_aName, pName, min((int)sizeof(pSelf->m_aSkins[pSelf->m_NumSkins].m_aName),l-3)); - dbg_msg("game", "load skin %s", pSelf->m_aSkins[pSelf->m_NumSkins].m_aName); + str_format(aBuf, sizeof(aBuf), "load skin %s", pSelf->m_aSkins[pSelf->m_NumSkins].m_aName); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf); pSelf->m_NumSkins++; } diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index acf29eb7..8c500079 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -223,7 +223,7 @@ void CGameClient::OnInit() //m_pServerBrowser = Kernel()->RequestInterface<IServerBrowser>(); // set the language - g_Localization.Load(g_Config.m_ClLanguagefile); + g_Localization.Load(g_Config.m_ClLanguagefile, Console()); // init all components for(int i = 0; i < m_All.m_Num; i++) @@ -288,7 +288,9 @@ void CGameClient::OnInit() m_All.m_paComponents[i]->OnReset(); int64 End = time_get(); - dbg_msg("", "%f.2ms", ((End-Start)*1000)/(float)time_freq()); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "initialisation finished after %f.2ms", ((End-Start)*1000)/(float)time_freq()); + Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "gameclient", aBuf); m_ServerMode = SERVERMODE_PURE; } @@ -517,7 +519,9 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker) void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker); if(!pRawMsg) { - dbg_msg("client", "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, "client", aBuf); return; } @@ -635,7 +639,11 @@ void CGameClient::OnNewSnapshot() if(m_NetObjHandler.ValidateObj(Item.m_Type, pData, Item.m_DataSize) != 0) { if(g_Config.m_Debug) - dbg_msg("game", "invalidated index=%d type=%d (%s) size=%d id=%d", Index, Item.m_Type, m_NetObjHandler.GetObjName(Item.m_Type), Item.m_DataSize, Item.m_Id); + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "invalidated index=%d type=%d (%s) size=%d id=%d", Index, Item.m_Type, m_NetObjHandler.GetObjName(Item.m_Type), Item.m_DataSize, Item.m_Id); + Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); + } Client()->SnapInvalidateItem(IClient::SNAP_CURRENT, Index); } } @@ -904,11 +912,13 @@ void CGameClient::OnPredict() if(mem_comp(&Before, &Now, sizeof(CNetObj_CharacterCore)) != 0) { - dbg_msg("client", "prediction error"); + Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "prediction error"); for(unsigned i = 0; i < sizeof(CNetObj_CharacterCore)/sizeof(int); i++) if(((int *)&Before)[i] != ((int *)&Now)[i]) { - dbg_msg("", "\t%d %d %d (%d %d)", i, ((int *)&Before)[i], ((int *)&Now)[i], ((int *)&BeforePrev)[i], ((int *)&NowPrev)[i]); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), " %d %d %d (%d %d)", i, ((int *)&Before)[i], ((int *)&Now)[i], ((int *)&BeforePrev)[i], ((int *)&NowPrev)[i]); + Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf); } } } diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index a2ecfb7e..aa6b7829 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -8,6 +8,7 @@ #include <engine/shared/config.h> #include <engine/shared/engine.h> #include <engine/client.h> +#include <engine/console.h> #include <engine/graphics.h> #include <engine/textrender.h> #include <engine/input.h> @@ -1271,7 +1272,9 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) if(!UI()->MouseButton(0)) { // grab brush - dbg_msg("editor", "grabbing %f %f %f %f", r.x, r.y, r.w, r.h); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf),"grabbing %f %f %f %f", r.x, r.y, r.w, r.h); + Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "editor", aBuf); // TODO: do all layers int Grabs = 0; @@ -1820,7 +1823,7 @@ static void ExtractName(const char *pFileName, char *pName) int FinalLen = End-Start; mem_copy(pName, &pFileName[Start], FinalLen); pName[FinalLen] = 0; - dbg_msg("", "%s %s %d %d", pFileName, pName, Start, End); + //dbg_msg("", "%s %s %d %d", pFileName, pName, Start, End); } void CEditor::ReplaceImage(const char *pFileName, void *pUser) @@ -3006,6 +3009,7 @@ void CEditor::Init() { m_pInput = Kernel()->RequestInterface<IInput>(); m_pClient = Kernel()->RequestInterface<IClient>(); + m_pConsole = Kernel()->RequestInterface<IConsole>(); m_pGraphics = Kernel()->RequestInterface<IGraphics>(); m_pTextRender = Kernel()->RequestInterface<ITextRender>(); m_RenderTools.m_pGraphics = m_pGraphics; diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index 9ccb3203..bbc3c45f 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -427,6 +427,7 @@ class CEditor : public IEditor { class IInput *m_pInput; class IClient *m_pClient; + class IConsole *m_pConsole; class IGraphics *m_pGraphics; class ITextRender *m_pTextRender; CRenderTools m_RenderTools; @@ -434,6 +435,7 @@ class CEditor : public IEditor public: class IInput *Input() { return m_pInput; }; class IClient *Client() { return m_pClient; }; + class IConsole *Console() { return m_pConsole; }; class IGraphics *Graphics() { return m_pGraphics; }; class ITextRender *TextRender() { return m_pTextRender; }; CUI *UI() { return &m_UI; } diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp index 4d514051..6eae9fb5 100644 --- a/src/game/editor/ed_io.cpp +++ b/src/game/editor/ed_io.cpp @@ -1,3 +1,4 @@ +#include <engine/console.h> #include <engine/graphics.h> #include <engine/storage.h> #include <game/gamecore.h> @@ -197,11 +198,14 @@ int CEditor::Save(const char *pFilename) int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) { - dbg_msg("editor", "saving to '%s'...", pFileName); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "saving to '%s'...", pFileName); + m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "editor", aBuf); CDataFileWriter df; if(!df.Open(pStorage, pFileName)) { - dbg_msg("editor", "failed to open file '%s'...", pFileName); + str_format(aBuf, sizeof(aBuf), "failed to open file '%s'...", pFileName); + m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "editor", aBuf); return 0; } @@ -259,7 +263,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) { if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_TILES) { - dbg_msg("editor", "saving tiles layer"); + m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving tiles layer"); CLayerTiles *pLayer = (CLayerTiles *)pGroup->m_lLayers[l]; pLayer->PrepareForSave(); @@ -288,7 +292,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) } else if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_QUADS) { - dbg_msg("editor", "saving quads layer"); + m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving quads layer"); CLayerQuads *pLayer = (CLayerQuads *)pGroup->m_lLayers[l]; if(pLayer->m_lQuads.size()) { @@ -346,7 +350,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) // finish the data file df.Finish(); - dbg_msg("editor", "done"); + m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving done"); // send rcon.. if we can /* diff --git a/src/game/editor/ed_layer_quads.cpp b/src/game/editor/ed_layer_quads.cpp index 023fd29f..83fd4392 100644 --- a/src/game/editor/ed_layer_quads.cpp +++ b/src/game/editor/ed_layer_quads.cpp @@ -1,5 +1,6 @@ #include <base/math.h> +#include <engine/console.h> #include <engine/graphics.h> #include "ed_editor.h" @@ -124,7 +125,7 @@ int CLayerQuads::BrushGrab(CLayerGroup *pBrush, CUIRect Rect) if(px > Rect.x && px < Rect.x+Rect.w && py > Rect.y && py < Rect.y+Rect.h) { - dbg_msg("", "grabbed one"); + m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "editor", "grabbed one"); CQuad n; n = *q; diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp index 8152c67c..68f804b5 100644 --- a/src/game/editor/ed_popups.cpp +++ b/src/game/editor/ed_popups.cpp @@ -1,3 +1,4 @@ +#include <engine/console.h> #include <engine/graphics.h> #include <engine/input.h> #include <engine/keys.h> @@ -19,7 +20,7 @@ static int g_UiNumPopups = 0; void CEditor::UiInvokePopupMenu(void *Id, int Flags, float x, float y, float w, float h, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect), void *pExtra) { - dbg_msg("", "invoked"); + Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "editor", "invoked"); if(x + w > UI()->Screen()->w) x -= w; if(y + h > UI()->Screen()->h) diff --git a/src/game/localization.cpp b/src/game/localization.cpp index 02065e36..fc9ac3df 100644 --- a/src/game/localization.cpp +++ b/src/game/localization.cpp @@ -3,6 +3,7 @@ #include <base/tl/algorithm.h> #include <engine/shared/linereader.h> +#include <engine/console.h> const char *Localize(const char *pStr) { @@ -39,7 +40,7 @@ void CLocalizationDatabase::AddString(const char *pOrgStr, const char *pNewStr) m_Strings.add(s); } -bool CLocalizationDatabase::Load(const char *pFilename) +bool CLocalizationDatabase::Load(const char *pFilename, IConsole *pConsole) { // empty string means unload if(pFilename[0] == 0) @@ -53,7 +54,9 @@ bool CLocalizationDatabase::Load(const char *pFilename) if(!IoHandle) return false; - dbg_msg("localization", "loaded '%s'", pFilename); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "loaded '%s'", pFilename); + pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf); m_Strings.clear(); CLineReader LineReader; @@ -70,13 +73,14 @@ bool CLocalizationDatabase::Load(const char *pFilename) char *pReplacement = LineReader.Get(); if(!pReplacement) { - dbg_msg("", "unexpected end of file"); + pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", "unexpected end of file"); break; } if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ') { - dbg_msg("", "malform replacement line for '%s'", pLine); + str_format(aBuf, sizeof(aBuf), "malform replacement line for '%s'", pLine); + pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf); continue; } diff --git a/src/game/localization.h b/src/game/localization.h index 2e96ef04..e117c4ff 100644 --- a/src/game/localization.h +++ b/src/game/localization.h @@ -24,7 +24,7 @@ class CLocalizationDatabase public: CLocalizationDatabase(); - bool Load(const char *pFilename); + bool Load(const char *pFilename, class IConsole *pConsole); int Version() { return m_CurrentVersion; } 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]); } |