diff options
| author | oy <Tom_Adams@web.de> | 2010-08-18 00:06:00 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-08-18 00:06:00 +0200 |
| commit | cabecb7fa937b5e4efa859ea62722468f91a5089 (patch) | |
| tree | d9da92814dd049dfef7bdcfa9069955504341b8c /src/engine/client | |
| parent | 16f201794de61e237b4a7644d28f043dc1b987bb (diff) | |
| download | zcatch-cabecb7fa937b5e4efa859ea62722468f91a5089.tar.gz zcatch-cabecb7fa937b5e4efa859ea62722468f91a5089.zip | |
added output level for console print function, categorised the debug messages and merged them into the new functionality. Closes #8
Diffstat (limited to 'src/engine/client')
| -rw-r--r-- | src/engine/client/client.cpp | 91 | ||||
| -rw-r--r-- | src/engine/client/graphics.cpp | 6 | ||||
| -rw-r--r-- | src/engine/client/graphics.h | 1 | ||||
| -rw-r--r-- | src/engine/client/srvbrowse.cpp | 16 | ||||
| -rw-r--r-- | src/engine/client/srvbrowse.h | 1 |
5 files changed, 84 insertions, 31 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index ce27e46f..6ddf364f 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -437,7 +437,11 @@ void CClient::SetState(int s) { int Old = m_State; if(g_Config.m_Debug) - dbg_msg("client", "state change. last=%d current=%d", m_State, s); + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "state change. last=%d current=%d", m_State, s); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf); + } m_State = s; if(Old != s) GameClient()->OnStateChange(m_State, Old); @@ -484,7 +488,8 @@ void CClient::Connect(const char *pAddress) str_copy(m_aServerAddressStr, pAddress, sizeof(m_aServerAddressStr)); - dbg_msg("client", "connecting to '%s'", m_aServerAddressStr); + str_format(aBuf, sizeof(aBuf), "connecting to '%s'", m_aServerAddressStr); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); ServerInfoRequest(); str_copy(aBuf, m_aServerAddressStr, sizeof(aBuf)); @@ -502,7 +507,9 @@ void CClient::Connect(const char *pAddress) // TODO: IPv6 support if(net_host_lookup(aBuf, &m_ServerAddress, NETTYPE_IPV4) != 0) { - dbg_msg("client", "could not find the address of %s, connecting to localhost", aBuf); + char aBufMsg[256]; + str_format(aBufMsg, sizeof(aBufMsg), "could not find the address of %s, connecting to localhost", aBuf); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBufMsg); net_host_lookup("localhost", &m_ServerAddress, NETTYPE_IPV4); } @@ -520,6 +527,10 @@ void CClient::Connect(const char *pAddress) void CClient::DisconnectWithReason(const char *pReason) { + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason?pReason:"unknown"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); + // stop demo playback and recorder m_DemoPlayer.Stop(); m_DemoRecorder.Stop(); @@ -593,9 +604,9 @@ void CClient::SnapInvalidateItem(int SnapId, int Index) if(i) { if((char *)i < (char *)m_aSnapshots[SnapId]->m_pAltSnap || (char *)i > (char *)m_aSnapshots[SnapId]->m_pAltSnap + m_aSnapshots[SnapId]->m_SnapSize) - dbg_msg("ASDFASDFASdf", "ASDFASDFASDF"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "snap invalidate problem"); if((char *)i >= (char *)m_aSnapshots[SnapId]->m_pSnap && (char *)i < (char *)m_aSnapshots[SnapId]->m_pSnap + m_aSnapshots[SnapId]->m_SnapSize) - dbg_msg("ASDFASDFASdf", "ASDFASDFASDF"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "snap invalidate problem"); i->m_TypeAndID = -1; } } @@ -764,7 +775,9 @@ const char *CClient::LoadMap(const char *pName, const char *pFilename, unsigned // stop demo recording if we loaded a new map m_DemoRecorder.Stop(); - dbg_msg("client", "loaded map '%s'", pFilename); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "loaded map '%s'", pFilename); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", aBuf); m_RecivedSnapshots = 0; str_copy(m_aCurrentMap, pName, sizeof(m_aCurrentMap)); @@ -779,7 +792,8 @@ const char *CClient::LoadMapSearch(const char *pMapName, int WantedCrc) { const char *pError = 0; char aBuf[512]; - dbg_msg("client", "loading map, map=%s wanted crc=%08x", pMapName, WantedCrc); + str_format(aBuf, sizeof(aBuf), "loading map, map=%s wanted crc=%08x", pMapName, WantedCrc); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", aBuf); SetState(IClient::STATE_LOADING); // try the normal maps folder @@ -816,9 +830,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket) unsigned char *pVersionData = (unsigned char*)pPacket->m_pData + sizeof(VERSIONSRV_VERSION); int VersionMatch = !mem_comp(pVersionData, VERSION_DATA, sizeof(VERSION_DATA)); - dbg_msg("client/version", "version does %s (%d.%d.%d)", + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "version does %s (%d.%d.%d)", VersionMatch ? "match" : "NOT match", pVersionData[1], pVersionData[2], pVersionData[3]); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/version", aBuf); // assume version is out of date when version-data doesn't match if (!VersionMatch) @@ -954,7 +970,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket) if(!pError) { - dbg_msg("client/network", "loading done"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", "loading done"); SendReady(); GameClient()->OnConnected(); } @@ -962,7 +978,9 @@ void CClient::ProcessPacket(CNetChunk *pPacket) { str_format(m_aMapdownloadFilename, sizeof(m_aMapdownloadFilename), "downloadedmaps/%s_%08x.map", pMap, MapCrc); - dbg_msg("client/network", "starting to download map to '%s'", m_aMapdownloadFilename); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "starting to download map to '%s'", m_aMapdownloadFilename); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", aBuf); m_MapdownloadChunk = 0; str_copy(m_aMapdownloadName, pMap, sizeof(m_aMapdownloadName)); @@ -976,7 +994,10 @@ void CClient::ProcessPacket(CNetChunk *pPacket) SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH); if(g_Config.m_Debug) - dbg_msg("client/network", "requested chunk %d", m_MapdownloadChunk); + { + str_format(aBuf, sizeof(aBuf), "requested chunk %d", m_MapdownloadChunk); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client/network", aBuf); + } } } } @@ -999,7 +1020,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket) if(Last) { const char *pError; - dbg_msg("client/network", "download complete, loading map"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", "download complete, loading map"); io_close(m_MapdownloadFile); m_MapdownloadFile = 0; @@ -1010,7 +1031,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket) pError = LoadMap(m_aMapdownloadName, m_aMapdownloadFilename, m_MapdownloadCrc); if(!pError) { - dbg_msg("client/network", "loading done"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", "loading done"); SendReady(); GameClient()->OnConnected(); } @@ -1027,7 +1048,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket) SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH); if(g_Config.m_Debug) - dbg_msg("client/network", "requested chunk %d", m_MapdownloadChunk); + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "requested chunk %d", m_MapdownloadChunk); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client/network", aBuf); + } } } else if(Msg == NETMSG_PING) @@ -1048,7 +1073,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket) GameClient()->OnRconLine(pLine); } else if(Msg == NETMSG_PING_REPLY) - dbg_msg("client/network", "latency %.2f", (time_get() - m_PingStartTime)*1000 / (float)time_freq()); + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "latency %.2f", (time_get() - m_PingStartTime)*1000 / (float)time_freq()); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client/network", aBuf); + } else if(Msg == NETMSG_INPUTTIMING) { int InputPredTick = Unpacker.GetInt(); @@ -1143,7 +1172,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket) // couldn't find the delta snapshots that the server used // to compress this snapshot. force the server to resync if(g_Config.m_Debug) - dbg_msg("client", "error, couldn't find the delta snapshot"); + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "error, couldn't find the delta snapshot"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf); + } // ack snapshot // TODO: combine this with the input message @@ -1172,7 +1205,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket) SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, pTmpBuffer3, pDeltaData, DeltaSize); if(SnapSize < 0) { - dbg_msg("client", "delta unpack failed!"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "delta unpack failed!"); return; } @@ -1180,8 +1213,10 @@ void CClient::ProcessPacket(CNetChunk *pPacket) { if(g_Config.m_Debug) { - dbg_msg("client", "snapshot crc error #%d - tick=%d wantedcrc=%d gotcrc=%d compressed_size=%d delta_tick=%d", + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "snapshot crc error #%d - tick=%d wantedcrc=%d gotcrc=%d compressed_size=%d delta_tick=%d", m_SnapCrcErrors, GameTick, Crc, pTmpBuffer3->Crc(), CompleteSize, DeltaTick); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf); } m_SnapCrcErrors++; @@ -1273,14 +1308,16 @@ void CClient::PumpNetwork() { SetState(IClient::STATE_OFFLINE); Disconnect(); - dbg_msg("client", "offline error='%s'", m_NetClient.ErrorString()); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "offline error='%s'", m_NetClient.ErrorString()); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); } // if(State() == IClient::STATE_CONNECTING && m_NetClient.State() == NETSTATE_ONLINE) { // we switched to online - dbg_msg("client", "connected, sending info"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", "connected, sending info"); SetState(IClient::STATE_LOADING); SendInfo(); } @@ -1434,7 +1471,7 @@ void CClient::Update() if(NewPredTick < m_aSnapshots[SNAP_PREV]->m_Tick-SERVER_TICK_SPEED || NewPredTick > m_aSnapshots[SNAP_PREV]->m_Tick+SERVER_TICK_SPEED) { - dbg_msg("client", "prediction time reset!"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", "prediction time reset!"); m_PredictedTime.Init(m_aSnapshots[SNAP_CURRENT]->m_Tick*time_freq()/50); } @@ -1477,7 +1514,7 @@ void CClient::Update() { if(Now > ActionTaken+time_freq()*2) { - dbg_msg("stress", "reconnecting!"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "stress", "reconnecting!"); Connect(g_Config.m_DbgStressServer); ActionTaken = Now; } @@ -1590,7 +1627,9 @@ void CClient::Run() return; GameClient()->OnInit(); - dbg_msg("client", "version %s", GameClient()->NetVersion()); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "version %s", GameClient()->NetVersion()); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); // open socket { @@ -1836,7 +1875,7 @@ const char *CClient::DemoPlayer_Play(const char *pFilename) // try to start playback m_DemoPlayer.SetListner(this); - if(m_DemoPlayer.Load(Storage(), pFilename)) + if(m_DemoPlayer.Load(Storage(), m_pConsole, pFilename)) return "error loading demo"; // load map @@ -1887,12 +1926,12 @@ void CClient::Con_Play(IConsole::IResult *pResult, void *pUserData) void CClient::DemoRecorder_Start(const char *pFilename) { if(State() != IClient::STATE_ONLINE) - dbg_msg("demorec/record", "client is not online"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demorec/record", "client is not online"); else { char aFilename[512]; str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pFilename); - m_DemoRecorder.Start(Storage(), aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_CurrentMapCrc, "client"); + m_DemoRecorder.Start(Storage(), m_pConsole, aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_CurrentMapCrc, "client"); } } diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index 09ee4784..1e9a79cf 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -25,6 +25,7 @@ #include <engine/graphics.h> #include <engine/storage.h> #include <engine/keys.h> +#include <engine/console.h> #include <math.h> #include <time.h> @@ -446,7 +447,9 @@ void CGraphics_OpenGL::ScreenshotDirect(const char *pFilename) io_close(File); // save png - dbg_msg("client", "saved screenshot to '%s'", aWholePath); + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "saved screenshot to '%s'", aWholePath); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); png_open_file_write(&Png, aWholePath); // ignore_convention png_set_data(&Png, w, h, 8, PNG_TRUECOLOR, (unsigned char *)pPixelData); // ignore_convention png_close_file(&Png); // ignore_convention @@ -663,6 +666,7 @@ void CGraphics_OpenGL::QuadsText(float x, float y, float Size, float r, float g, bool CGraphics_OpenGL::Init() { m_pStorage = Kernel()->RequestInterface<IStorage>(); + m_pConsole = Kernel()->RequestInterface<IConsole>(); // Set all z to -5.0f for(int i = 0; i < MAX_VERTICES; i++) diff --git a/src/engine/client/graphics.h b/src/engine/client/graphics.h index cb8681f3..fa360a22 100644 --- a/src/engine/client/graphics.h +++ b/src/engine/client/graphics.h @@ -5,6 +5,7 @@ class CGraphics_OpenGL : public IEngineGraphics { protected: class IStorage *m_pStorage; + class IConsole *m_pConsole; // typedef struct { float x, y, z; } CPoint; diff --git a/src/engine/client/srvbrowse.cpp b/src/engine/client/srvbrowse.cpp index d0c8393d..aed0d514 100644 --- a/src/engine/client/srvbrowse.cpp +++ b/src/engine/client/srvbrowse.cpp @@ -9,6 +9,7 @@ #include <engine/shared/engine.h> #include <engine/masterserver.h> +#include <engine/console.h> #include <engine/config.h> #include <mastersrv/mastersrv.h> @@ -62,6 +63,7 @@ void CServerBrowser::SetBaseInfo(class CNetClient *pClient, const char *pNetVers m_pNetClient = pClient; str_copy(m_aNetVersion, pNetVersion, sizeof(m_aNetVersion)); m_pMasterServer = Kernel()->RequestInterface<IMasterServer>(); + m_pConsole = Kernel()->RequestInterface<IConsole>(); IConfig *pConfig = Kernel()->RequestInterface<IConfig>(); if(pConfig) pConfig->RegisterCallback(ConfigSaveCallback, this); @@ -514,7 +516,7 @@ void CServerBrowser::Refresh(int Type) } if(g_Config.m_Debug) - dbg_msg("client", "broadcasting for servers"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", "broadcasting for servers"); } else if(Type == IServerBrowser::TYPE_INTERNET) m_NeedRefresh = 1; @@ -532,9 +534,11 @@ void CServerBrowser::RequestImpl(const NETADDR &Addr, CServerEntry *pEntry) cons if(g_Config.m_Debug) { - dbg_msg("client", "requesting server info from %d.%d.%d.%d:%d", + char aBuf[256]; + str_format(aBuf, sizeof(aBuf),"requesting server info from %d.%d.%d.%d:%d", Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", aBuf); } /*mem_copy(buffer, SERVERBROWSE_GETINFO, sizeof(SERVERBROWSE_GETINFO)); @@ -595,7 +599,7 @@ void CServerBrowser::Update() } if(g_Config.m_Debug) - dbg_msg("client", "requesting server list"); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", "requesting server list"); } // do timeouts @@ -676,7 +680,11 @@ void CServerBrowser::AddFavorite(const NETADDR &Addr) pEntry->m_Info.m_Favorite = 1; if(g_Config.m_Debug) - dbg_msg("", "added fav, %d.%d.%d.%d:%d", Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port); + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "added fav, %d.%d.%d.%d:%d", Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", aBuf); + } } void CServerBrowser::RemoveFavorite(const NETADDR &Addr) diff --git a/src/engine/client/srvbrowse.h b/src/engine/client/srvbrowse.h index 1c255792..ecaed7ef 100644 --- a/src/engine/client/srvbrowse.h +++ b/src/engine/client/srvbrowse.h @@ -50,6 +50,7 @@ public: private: CNetClient *m_pNetClient; IMasterServer *m_pMasterServer; + class IConsole *m_pConsole; char m_aNetVersion[128]; CHeap m_ServerlistHeap; |