added output level for console print function, categorised the debug messages and merged them into the new functionality. Closes #8

This commit is contained in:
oy 2010-08-18 00:06:00 +02:00 committed by GreYFoXGTi
parent 521a028f7c
commit 41afca6db2
37 changed files with 411 additions and 190 deletions

View file

@ -437,7 +437,11 @@ void CClient::SetState(int s)
{ {
int Old = m_State; int Old = m_State;
if(g_Config.m_Debug) 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; m_State = s;
if(Old != s) if(Old != s)
GameClient()->OnStateChange(m_State, Old); GameClient()->OnStateChange(m_State, Old);
@ -484,7 +488,8 @@ void CClient::Connect(const char *pAddress)
str_copy(m_aServerAddressStr, pAddress, sizeof(m_aServerAddressStr)); 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(); ServerInfoRequest();
str_copy(aBuf, m_aServerAddressStr, sizeof(aBuf)); str_copy(aBuf, m_aServerAddressStr, sizeof(aBuf));
@ -502,7 +507,9 @@ void CClient::Connect(const char *pAddress)
// TODO: IPv6 support // TODO: IPv6 support
if(net_host_lookup(aBuf, &m_ServerAddress, NETTYPE_IPV4) != 0) 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); net_host_lookup("localhost", &m_ServerAddress, NETTYPE_IPV4);
} }
@ -520,6 +527,10 @@ void CClient::Connect(const char *pAddress)
void CClient::DisconnectWithReason(const char *pReason) 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 // stop demo playback and recorder
m_DemoPlayer.Stop(); m_DemoPlayer.Stop();
m_DemoRecorder.Stop(); m_DemoRecorder.Stop();
@ -593,9 +604,9 @@ void CClient::SnapInvalidateItem(int SnapId, int Index)
if(i) if(i)
{ {
if((char *)i < (char *)m_aSnapshots[SnapId]->m_pAltSnap || (char *)i > (char *)m_aSnapshots[SnapId]->m_pAltSnap + m_aSnapshots[SnapId]->m_SnapSize) 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) 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; 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 // stop demo recording if we loaded a new map
m_DemoRecorder.Stop(); 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; m_RecivedSnapshots = 0;
str_copy(m_aCurrentMap, pName, sizeof(m_aCurrentMap)); 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; const char *pError = 0;
char aBuf[512]; 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); SetState(IClient::STATE_LOADING);
// try the normal maps folder // 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); unsigned char *pVersionData = (unsigned char*)pPacket->m_pData + sizeof(VERSIONSRV_VERSION);
int VersionMatch = !mem_comp(pVersionData, VERSION_DATA, sizeof(VERSION_DATA)); 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", VersionMatch ? "match" : "NOT match",
pVersionData[1], pVersionData[2], pVersionData[3]); 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 // assume version is out of date when version-data doesn't match
if (!VersionMatch) if (!VersionMatch)
@ -954,7 +970,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
if(!pError) if(!pError)
{ {
dbg_msg("client/network", "loading done"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", "loading done");
SendReady(); SendReady();
GameClient()->OnConnected(); GameClient()->OnConnected();
} }
@ -962,7 +978,9 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
{ {
str_format(m_aMapdownloadFilename, sizeof(m_aMapdownloadFilename), "downloadedmaps/%s_%08x.map", pMap, MapCrc); 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; m_MapdownloadChunk = 0;
str_copy(m_aMapdownloadName, pMap, sizeof(m_aMapdownloadName)); str_copy(m_aMapdownloadName, pMap, sizeof(m_aMapdownloadName));
@ -976,7 +994,10 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH); SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
if(g_Config.m_Debug) 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) if(Last)
{ {
const char *pError; 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); io_close(m_MapdownloadFile);
m_MapdownloadFile = 0; m_MapdownloadFile = 0;
@ -1010,7 +1031,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
pError = LoadMap(m_aMapdownloadName, m_aMapdownloadFilename, m_MapdownloadCrc); pError = LoadMap(m_aMapdownloadName, m_aMapdownloadFilename, m_MapdownloadCrc);
if(!pError) if(!pError)
{ {
dbg_msg("client/network", "loading done"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", "loading done");
SendReady(); SendReady();
GameClient()->OnConnected(); GameClient()->OnConnected();
} }
@ -1027,7 +1048,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH); SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
if(g_Config.m_Debug) 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) else if(Msg == NETMSG_PING)
@ -1048,7 +1073,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
GameClient()->OnRconLine(pLine); GameClient()->OnRconLine(pLine);
} }
else if(Msg == NETMSG_PING_REPLY) 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) else if(Msg == NETMSG_INPUTTIMING)
{ {
int InputPredTick = Unpacker.GetInt(); int InputPredTick = Unpacker.GetInt();
@ -1143,7 +1172,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
// couldn't find the delta snapshots that the server used // couldn't find the delta snapshots that the server used
// to compress this snapshot. force the server to resync // to compress this snapshot. force the server to resync
if(g_Config.m_Debug) 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 // ack snapshot
// TODO: combine this with the input message // TODO: combine this with the input message
@ -1172,7 +1205,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, pTmpBuffer3, pDeltaData, DeltaSize); SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, pTmpBuffer3, pDeltaData, DeltaSize);
if(SnapSize < 0) if(SnapSize < 0)
{ {
dbg_msg("client", "delta unpack failed!"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "delta unpack failed!");
return; return;
} }
@ -1180,8 +1213,10 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
{ {
if(g_Config.m_Debug) 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_SnapCrcErrors, GameTick, Crc, pTmpBuffer3->Crc(), CompleteSize, DeltaTick);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf);
} }
m_SnapCrcErrors++; m_SnapCrcErrors++;
@ -1273,14 +1308,16 @@ void CClient::PumpNetwork()
{ {
SetState(IClient::STATE_OFFLINE); SetState(IClient::STATE_OFFLINE);
Disconnect(); 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) if(State() == IClient::STATE_CONNECTING && m_NetClient.State() == NETSTATE_ONLINE)
{ {
// we switched to 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); SetState(IClient::STATE_LOADING);
SendInfo(); 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) 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); 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) if(Now > ActionTaken+time_freq()*2)
{ {
dbg_msg("stress", "reconnecting!"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "stress", "reconnecting!");
Connect(g_Config.m_DbgStressServer); Connect(g_Config.m_DbgStressServer);
ActionTaken = Now; ActionTaken = Now;
} }
@ -1590,7 +1627,9 @@ void CClient::Run()
return; return;
GameClient()->OnInit(); 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 // open socket
{ {
@ -1836,7 +1875,7 @@ const char *CClient::DemoPlayer_Play(const char *pFilename)
// try to start playback // try to start playback
m_DemoPlayer.SetListner(this); m_DemoPlayer.SetListner(this);
if(m_DemoPlayer.Load(Storage(), pFilename)) if(m_DemoPlayer.Load(Storage(), m_pConsole, pFilename))
return "error loading demo"; return "error loading demo";
// load map // load map
@ -1887,12 +1926,12 @@ void CClient::Con_Play(IConsole::IResult *pResult, void *pUserData)
void CClient::DemoRecorder_Start(const char *pFilename) void CClient::DemoRecorder_Start(const char *pFilename)
{ {
if(State() != IClient::STATE_ONLINE) 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 else
{ {
char aFilename[512]; char aFilename[512];
str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pFilename); 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");
} }
} }

View file

@ -25,6 +25,7 @@
#include <engine/graphics.h> #include <engine/graphics.h>
#include <engine/storage.h> #include <engine/storage.h>
#include <engine/keys.h> #include <engine/keys.h>
#include <engine/console.h>
#include <math.h> #include <math.h>
#include <time.h> #include <time.h>
@ -446,7 +447,9 @@ void CGraphics_OpenGL::ScreenshotDirect(const char *pFilename)
io_close(File); io_close(File);
// save png // 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_open_file_write(&Png, aWholePath); // ignore_convention
png_set_data(&Png, w, h, 8, PNG_TRUECOLOR, (unsigned char *)pPixelData); // ignore_convention png_set_data(&Png, w, h, 8, PNG_TRUECOLOR, (unsigned char *)pPixelData); // ignore_convention
png_close_file(&Png); // 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() bool CGraphics_OpenGL::Init()
{ {
m_pStorage = Kernel()->RequestInterface<IStorage>(); m_pStorage = Kernel()->RequestInterface<IStorage>();
m_pConsole = Kernel()->RequestInterface<IConsole>();
// Set all z to -5.0f // Set all z to -5.0f
for(int i = 0; i < MAX_VERTICES; i++) for(int i = 0; i < MAX_VERTICES; i++)

View file

@ -5,6 +5,7 @@ class CGraphics_OpenGL : public IEngineGraphics
{ {
protected: protected:
class IStorage *m_pStorage; class IStorage *m_pStorage;
class IConsole *m_pConsole;
// //
typedef struct { float x, y, z; } CPoint; typedef struct { float x, y, z; } CPoint;

View file

@ -9,6 +9,7 @@
#include <engine/shared/engine.h> #include <engine/shared/engine.h>
#include <engine/masterserver.h> #include <engine/masterserver.h>
#include <engine/console.h>
#include <engine/config.h> #include <engine/config.h>
#include <mastersrv/mastersrv.h> #include <mastersrv/mastersrv.h>
@ -62,6 +63,7 @@ void CServerBrowser::SetBaseInfo(class CNetClient *pClient, const char *pNetVers
m_pNetClient = pClient; m_pNetClient = pClient;
str_copy(m_aNetVersion, pNetVersion, sizeof(m_aNetVersion)); str_copy(m_aNetVersion, pNetVersion, sizeof(m_aNetVersion));
m_pMasterServer = Kernel()->RequestInterface<IMasterServer>(); m_pMasterServer = Kernel()->RequestInterface<IMasterServer>();
m_pConsole = Kernel()->RequestInterface<IConsole>();
IConfig *pConfig = Kernel()->RequestInterface<IConfig>(); IConfig *pConfig = Kernel()->RequestInterface<IConfig>();
if(pConfig) if(pConfig)
pConfig->RegisterCallback(ConfigSaveCallback, this); pConfig->RegisterCallback(ConfigSaveCallback, this);
@ -514,7 +516,7 @@ void CServerBrowser::Refresh(int Type)
} }
if(g_Config.m_Debug) 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) else if(Type == IServerBrowser::TYPE_INTERNET)
m_NeedRefresh = 1; m_NeedRefresh = 1;
@ -532,9 +534,11 @@ void CServerBrowser::RequestImpl(const NETADDR &Addr, CServerEntry *pEntry) cons
if(g_Config.m_Debug) 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[0], Addr.ip[1], Addr.ip[2],
Addr.ip[3], Addr.port); Addr.ip[3], Addr.port);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", aBuf);
} }
/*mem_copy(buffer, SERVERBROWSE_GETINFO, sizeof(SERVERBROWSE_GETINFO)); /*mem_copy(buffer, SERVERBROWSE_GETINFO, sizeof(SERVERBROWSE_GETINFO));
@ -595,7 +599,7 @@ void CServerBrowser::Update()
} }
if(g_Config.m_Debug) 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 // do timeouts
@ -676,7 +680,11 @@ void CServerBrowser::AddFavorite(const NETADDR &Addr)
pEntry->m_Info.m_Favorite = 1; pEntry->m_Info.m_Favorite = 1;
if(g_Config.m_Debug) 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) void CServerBrowser::RemoveFavorite(const NETADDR &Addr)

View file

@ -50,6 +50,7 @@ public:
private: private:
CNetClient *m_pNetClient; CNetClient *m_pNetClient;
IMasterServer *m_pMasterServer; IMasterServer *m_pMasterServer;
class IConsole *m_pConsole;
char m_aNetVersion[128]; char m_aNetVersion[128];
CHeap m_ServerlistHeap; CHeap m_ServerlistHeap;

View file

@ -8,6 +8,13 @@ class IConsole : public IInterface
MACRO_INTERFACE("console", 0) MACRO_INTERFACE("console", 0)
public: public:
enum
{
OUTPUT_LEVEL_STANDARD=0,
OUTPUT_LEVEL_ADDINFO,
OUTPUT_LEVEL_DEBUG
};
// TODO: rework this interface to reduce the amount of virtual calls // TODO: rework this interface to reduce the amount of virtual calls
class IResult class IResult
{ {
@ -52,7 +59,7 @@ public:
virtual void ExecuteFile(const char *pFilename) = 0; virtual void ExecuteFile(const char *pFilename) = 0;
virtual void RegisterPrintCallback(FPrintCallback pfnPrintCallback, void *pUserData) = 0; virtual void RegisterPrintCallback(FPrintCallback pfnPrintCallback, void *pUserData) = 0;
virtual void Print(const char *pStr) = 0; virtual void Print(int Level, const char *pFrom, const char *pStr) = 0;
}; };
extern IConsole *CreateConsole(int FlagMask); extern IConsole *CreateConsole(int FlagMask);

View file

@ -2,6 +2,7 @@
#include <engine/shared/network.h> #include <engine/shared/network.h>
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include <engine/shared/engine.h> #include <engine/shared/engine.h>
#include <engine/console.h>
#include <engine/masterserver.h> #include <engine/masterserver.h>
#include <mastersrv/mastersrv.h> #include <mastersrv/mastersrv.h>
@ -12,6 +13,7 @@ CRegister::CRegister()
{ {
m_pNetServer = 0; m_pNetServer = 0;
m_pMasterServer = 0; m_pMasterServer = 0;
m_pConsole = 0;
m_RegisterState = REGISTERSTATE_START; m_RegisterState = REGISTERSTATE_START;
m_RegisterStateStart = 0; m_RegisterStateStart = 0;
@ -87,10 +89,11 @@ void CRegister::RegisterGotCount(CNetChunk *pChunk)
} }
} }
void CRegister::Init(CNetServer *pNetServer, IEngineMasterServer *pMasterServer) void CRegister::Init(CNetServer *pNetServer, IEngineMasterServer *pMasterServer, IConsole *pConsole)
{ {
m_pNetServer = pNetServer; m_pNetServer = pNetServer;
m_pMasterServer = pMasterServer; m_pMasterServer = pMasterServer;
m_pConsole = pConsole;
} }
void CRegister::RegisterUpdate() void CRegister::RegisterUpdate()
@ -109,7 +112,7 @@ void CRegister::RegisterUpdate()
m_RegisterFirst = 1; m_RegisterFirst = 1;
RegisterNewState(REGISTERSTATE_UPDATE_ADDRS); RegisterNewState(REGISTERSTATE_UPDATE_ADDRS);
m_pMasterServer->RefreshAddresses(); m_pMasterServer->RefreshAddresses();
dbg_msg("register", "refreshing ip addresses"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", "refreshing ip addresses");
} }
else if(m_RegisterState == REGISTERSTATE_UPDATE_ADDRS) else if(m_RegisterState == REGISTERSTATE_UPDATE_ADDRS)
{ {
@ -134,7 +137,7 @@ void CRegister::RegisterUpdate()
} }
} }
dbg_msg("register", "fetching server counts"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", "fetching server counts");
RegisterNewState(REGISTERSTATE_QUERY_COUNT); RegisterNewState(REGISTERSTATE_QUERY_COUNT);
} }
} }
@ -176,12 +179,14 @@ void CRegister::RegisterUpdate()
m_RegisterRegisteredServer = Best; m_RegisterRegisteredServer = Best;
if(m_RegisterRegisteredServer == -1) if(m_RegisterRegisteredServer == -1)
{ {
dbg_msg("register", "WARNING: No master servers. Retrying in 60 seconds"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", "WARNING: No master servers. Retrying in 60 seconds");
RegisterNewState(REGISTERSTATE_ERROR); RegisterNewState(REGISTERSTATE_ERROR);
} }
else else
{ {
dbg_msg("register", "choosen '%s' as master, sending heartbeats", m_pMasterServer->GetName(m_RegisterRegisteredServer)); char aBuf[256];
str_format(aBuf, sizeof(aBuf), "choosen '%s' as master, sending heartbeats", m_pMasterServer->GetName(m_RegisterRegisteredServer));
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", aBuf);
m_aMasterserverInfo[m_RegisterRegisteredServer].m_LastSend = 0; m_aMasterserverInfo[m_RegisterRegisteredServer].m_LastSend = 0;
RegisterNewState(REGISTERSTATE_HEARTBEAT); RegisterNewState(REGISTERSTATE_HEARTBEAT);
} }
@ -198,14 +203,14 @@ void CRegister::RegisterUpdate()
if(Now > m_RegisterStateStart+Freq*60) if(Now > m_RegisterStateStart+Freq*60)
{ {
dbg_msg("register", "WARNING: Master server is not responding, switching master"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", "WARNING: Master server is not responding, switching master");
RegisterNewState(REGISTERSTATE_START); RegisterNewState(REGISTERSTATE_START);
} }
} }
else if(m_RegisterState == REGISTERSTATE_REGISTERED) else if(m_RegisterState == REGISTERSTATE_REGISTERED)
{ {
if(m_RegisterFirst) if(m_RegisterFirst)
dbg_msg("register", "server registered"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", "server registered");
m_RegisterFirst = 0; m_RegisterFirst = 0;
@ -258,15 +263,17 @@ int CRegister::RegisterProcessPacket(CNetChunk *pPacket)
mem_comp(pPacket->m_pData, SERVERBROWSE_FWOK, sizeof(SERVERBROWSE_FWOK)) == 0) mem_comp(pPacket->m_pData, SERVERBROWSE_FWOK, sizeof(SERVERBROWSE_FWOK)) == 0)
{ {
if(m_RegisterFirst) if(m_RegisterFirst)
dbg_msg("register", "no firewall/nat problems detected"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", "no firewall/nat problems detected");
RegisterNewState(REGISTERSTATE_REGISTERED); RegisterNewState(REGISTERSTATE_REGISTERED);
return 1; return 1;
} }
else if(pPacket->m_DataSize == sizeof(SERVERBROWSE_FWERROR) && else if(pPacket->m_DataSize == sizeof(SERVERBROWSE_FWERROR) &&
mem_comp(pPacket->m_pData, SERVERBROWSE_FWERROR, sizeof(SERVERBROWSE_FWERROR)) == 0) mem_comp(pPacket->m_pData, SERVERBROWSE_FWERROR, sizeof(SERVERBROWSE_FWERROR)) == 0)
{ {
dbg_msg("register", "ERROR: the master server reports that clients can not connect to this server."); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", "ERROR: the master server reports that clients can not connect to this server.");
dbg_msg("register", "ERROR: configure your firewall/nat to let through udp on port %d.", g_Config.m_SvPort); char aBuf[256];
str_format(aBuf, sizeof(aBuf), "ERROR: configure your firewall/nat to let through udp on port %d.", g_Config.m_SvPort);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", aBuf);
RegisterNewState(REGISTERSTATE_ERROR); RegisterNewState(REGISTERSTATE_ERROR);
return 1; return 1;
} }

View file

@ -25,6 +25,7 @@ class CRegister
class CNetServer *m_pNetServer; class CNetServer *m_pNetServer;
class IEngineMasterServer *m_pMasterServer; class IEngineMasterServer *m_pMasterServer;
class IConsole *m_pConsole;
int m_RegisterState; int m_RegisterState;
int64 m_RegisterStateStart; int64 m_RegisterStateStart;
@ -42,7 +43,7 @@ class CRegister
public: public:
CRegister(); CRegister();
void Init(class CNetServer *pNetServer, class IEngineMasterServer *pMasterServer); void Init(class CNetServer *pNetServer, class IEngineMasterServer *pMasterServer, class IConsole *pConsole);
void RegisterUpdate(); void RegisterUpdate();
int RegisterProcessPacket(class CNetChunk *pPacket); int RegisterProcessPacket(class CNetChunk *pPacket);
}; };

View file

@ -194,7 +194,9 @@ int CServer::TrySetClientName(int ClientID, const char *pName)
// trim the name // trim the name
str_copy(aTrimmedName, StrLtrim(pName), sizeof(aTrimmedName)); str_copy(aTrimmedName, StrLtrim(pName), sizeof(aTrimmedName));
StrRtrim(aTrimmedName); StrRtrim(aTrimmedName);
//dbg_msg("", "'%s' -> '%s'", pName, aTrimmedName); Removed for the rainbow mod /*char aBuf[256];
str_format(aBuf, sizeof(aBuf), "'%s' -> '%s'", pName, aTrimmedName);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);*/
pName = aTrimmedName; pName = aTrimmedName;
@ -550,10 +552,19 @@ int CServer::NewClientCallback(int ClientId, void *pUser)
return 0; return 0;
} }
int CServer::DelClientCallback(int ClientId, void *pUser) int CServer::DelClientCallback(int ClientId, const char *pReason, void *pUser)
{ {
CServer *pThis = (CServer *)pUser; CServer *pThis = (CServer *)pUser;
NETADDR Addr = pThis->m_NetServer.ClientAddr(ClientId);
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "client dropped. cid=%d ip=%d.%d.%d.%d reason=\"%s\"",
ClientId,
Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3],
pReason
);
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
// notify the mod about the drop // notify the mod about the drop
if(pThis->m_aClients[ClientId].m_State >= CClient::STATE_READY) if(pThis->m_aClients[ClientId].m_State >= CClient::STATE_READY)
pThis->GameServer()->OnClientDrop(ClientId); pThis->GameServer()->OnClientDrop(ClientId);
@ -778,7 +789,11 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientId, true); SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientId, true);
if(g_Config.m_Debug) if(g_Config.m_Debug)
dbg_msg("server", "sending chunk %d with size %d", Chunk, ChunkSize); {
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "sending chunk %d with size %d", Chunk, ChunkSize);
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
}
} }
else if(Msg == NETMSG_READY) else if(Msg == NETMSG_READY)
{ {
@ -786,12 +801,14 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
{ {
//Addr = m_NetServer.ClientAddr(ClientId); //Addr = m_NetServer.ClientAddr(ClientId);
dbg_msg("server", "player is ready. ClientId=%x ip=%d.%d.%d.%d", char aBuf[256];
str_format(aBuf, sizeof(aBuf), "player is ready. ClientId=%x ip=%d.%d.%d.%d",
ClientId, ClientId,
m_aClients[ClientId].m_Addr.ip[0], m_aClients[ClientId].m_Addr.ip[0],
m_aClients[ClientId].m_Addr.ip[1], m_aClients[ClientId].m_Addr.ip[1],
m_aClients[ClientId].m_Addr.ip[2], m_aClients[ClientId].m_Addr.ip[2],
m_aClients[ClientId].m_Addr.ip[3]); m_aClients[ClientId].m_Addr.ip[3]);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
m_aClients[ClientId].m_State = CClient::STATE_READY; m_aClients[ClientId].m_State = CClient::STATE_READY;
GameServer()->OnClientConnected(ClientId); GameServer()->OnClientConnected(ClientId);
GameServer()->OnSetAuthed(ClientId, m_aClients[ClientId].m_Authed); GameServer()->OnSetAuthed(ClientId, m_aClients[ClientId].m_Authed);
@ -804,12 +821,14 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
{ {
//Addr = m_NetServer.ClientAddr(ClientId); //Addr = m_NetServer.ClientAddr(ClientId);
dbg_msg("server", "player has entered the game. ClientId=%x ip=%d.%d.%d.%d", char aBuf[256];
str_format(aBuf, sizeof(aBuf), "player has entered the game. ClientId=%x ip=%d.%d.%d.%d",
ClientId, ClientId,
m_aClients[ClientId].m_Addr.ip[0], m_aClients[ClientId].m_Addr.ip[0],
m_aClients[ClientId].m_Addr.ip[1], m_aClients[ClientId].m_Addr.ip[1],
m_aClients[ClientId].m_Addr.ip[2], m_aClients[ClientId].m_Addr.ip[2],
m_aClients[ClientId].m_Addr.ip[3]); m_aClients[ClientId].m_Addr.ip[3]);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
m_aClients[ClientId].m_State = CClient::STATE_INGAME; m_aClients[ClientId].m_State = CClient::STATE_INGAME;
GameServer()->OnClientEnter(ClientId); GameServer()->OnClientEnter(ClientId);
} }
@ -872,7 +891,10 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
if(Unpacker.Error() == 0/* && m_aClients[ClientId].m_Authed*/) if(Unpacker.Error() == 0/* && m_aClients[ClientId].m_Authed*/)
{ {
dbg_msg("server", "ClientId=%d Level=%d Rcon='%s'", ClientId, m_aClients[ClientId].m_Authed, pCmd); char aBuf[256];
str_format(aBuf, sizeof(aBuf), "ClientId=%d Level=%d Rcon='%s'", ClientId, m_aClients[ClientId].m_Authed, pCmd);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
Console()->ExecuteLine(pCmd);
//Addr = m_NetServer.ClientAddr(ClientId); //Addr = m_NetServer.ClientAddr(ClientId);
if(m_aClients[ClientId].m_Authed > 0) if(m_aClients[ClientId].m_Authed > 0)
{ {
@ -887,7 +909,6 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
//BanAdd(m_aClients[ClientId].m_Addr, g_Config.m_SvRconTriesBantime,"Trying Rcon commands withou permission"); // bye //BanAdd(m_aClients[ClientId].m_Addr, g_Config.m_SvRconTriesBantime,"Trying Rcon commands withou permission"); // bye
} }
} }
} }
else if(Msg == NETMSG_RCON_AUTH) else if(Msg == NETMSG_RCON_AUTH)
@ -956,8 +977,21 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
} }
} }
} }
else if(str_comp(pPw, g_Config.m_SvRconPassword) == 0)
{
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
Msg.AddInt(1);
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientId, true);
m_aClients[ClientId].m_Authed = 1;
SendRconLine(ClientId, "Authentication successful. Remote console access granted.");
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "ClientId=%d authed", ClientId);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
else else
{ {
SendRconLine(ClientId, "Wrong password.");
dbg_msg("server", "Client tried to authenticate with empty password. cid=%x ip=%d.%d.%d.%d", dbg_msg("server", "Client tried to authenticate with empty password. cid=%x ip=%d.%d.%d.%d",
ClientId, ClientId,
m_aClients[ClientId].m_Addr.ip[0], m_aClients[ClientId].m_Addr.ip[1], m_aClients[ClientId].m_Addr.ip[2], m_aClients[ClientId].m_Addr.ip[3] m_aClients[ClientId].m_Addr.ip[0], m_aClients[ClientId].m_Addr.ip[1], m_aClients[ClientId].m_Addr.ip[2], m_aClients[ClientId].m_Addr.ip[3]
@ -983,8 +1017,10 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
aBuf[b*3+3] = 0; aBuf[b*3+3] = 0;
} }
dbg_msg("server", "strange message ClientId=%d msg=%d data_size=%d", ClientId, Msg, pPacket->m_DataSize); char aBufMsg[256];
dbg_msg("server", "%s", aBuf); str_format(aBufMsg, sizeof(aBufMsg), "strange message ClientId=%d msg=%d data_size=%d", ClientId, Msg, pPacket->m_DataSize);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBufMsg);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
} }
} }
@ -1142,7 +1178,9 @@ int CServer::LoadMap(const char *pMapName)
// get the crc of the map // get the crc of the map
m_CurrentMapCrc = m_pMap->Crc(); m_CurrentMapCrc = m_pMap->Crc();
dbg_msg("server", "%s crc is %08x", aBuf, m_CurrentMapCrc); char aBufMsg[256];
str_format(aBufMsg, sizeof(aBufMsg), "%s crc is %08x", aBuf, m_CurrentMapCrc);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBufMsg);
str_copy(m_aCurrentMap, pMapName, sizeof(m_aCurrentMap)); str_copy(m_aCurrentMap, pMapName, sizeof(m_aCurrentMap));
//map_set(df); //map_set(df);
@ -1165,9 +1203,9 @@ void CServer::InitEngine(const char *pAppname)
m_Engine.Init(pAppname); m_Engine.Init(pAppname);
} }
void CServer::InitRegister(CNetServer *pNetServer, IEngineMasterServer *pMasterServer) void CServer::InitRegister(CNetServer *pNetServer, IEngineMasterServer *pMasterServer, IConsole *pConsole)
{ {
m_Register.Init(pNetServer, pMasterServer); m_Register.Init(pNetServer, pMasterServer, pConsole);
} }
int CServer::Run() int CServer::Run()
@ -1212,10 +1250,13 @@ int CServer::Run()
m_NetServer.SetCallbacks(NewClientCallback, DelClientCallback, this, 0); m_NetServer.SetCallbacks(NewClientCallback, DelClientCallback, this, 0);
dbg_msg("server", "server name is '%s'", g_Config.m_SvName); char aBuf[256];
str_format(aBuf, sizeof(aBuf), "server name is '%s'", g_Config.m_SvName);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
GameServer()->OnInit(); GameServer()->OnInit();
dbg_msg("server", "version %s", GameServer()->NetVersion()); str_format(aBuf, sizeof(aBuf), "version %s", GameServer()->NetVersion());
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
// process pending commands // process pending commands
m_pConsole->StoreCommands(false,-1); m_pConsole->StoreCommands(false,-1);
@ -1229,7 +1270,10 @@ int CServer::Run()
m_GameStartTime = time_get(); m_GameStartTime = time_get();
if(g_Config.m_Debug) if(g_Config.m_Debug)
dbg_msg("server", "baseline memory usage %dk", mem_stats()->allocated/1024); {
str_format(aBuf, sizeof(aBuf), "baseline memory usage %dk", mem_stats()->allocated/1024);
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
}
while(m_RunServer) while(m_RunServer)
{ {
@ -1270,7 +1314,8 @@ int CServer::Run()
} }
else else
{ {
dbg_msg("server", "failed to load map. mapname='%s'", g_Config.m_SvMap); str_format(aBuf, sizeof(aBuf), "failed to load map. mapname='%s'", g_Config.m_SvMap);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
str_copy(g_Config.m_SvMap, m_aCurrentMap, sizeof(g_Config.m_SvMap)); str_copy(g_Config.m_SvMap, m_aCurrentMap, sizeof(g_Config.m_SvMap));
} }
} }
@ -1399,7 +1444,7 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser, int ClientId1)
if(ClientId < 0 || ClientId >= MAX_CLIENTS || ((CServer *)pUser)->m_aClients[ClientId].m_State == CClient::STATE_EMPTY) if(ClientId < 0 || ClientId >= MAX_CLIENTS || ((CServer *)pUser)->m_aClients[ClientId].m_State == CClient::STATE_EMPTY)
{ {
dbg_msg("server", "invalid client id"); ((CServer *)pUser)->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid client id");
return; return;
} }
@ -1410,10 +1455,12 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser, int ClientId1)
Addr.port = 0; Addr.port = 0;
net_addr_str(&Addr, aAddrStr, sizeof(aAddrStr)); net_addr_str(&Addr, aAddrStr, sizeof(aAddrStr));
char aBuf[256];
if(Seconds) if(Seconds)
dbg_msg("server", "banned %s for %d Second(s)", aAddrStr, Seconds); str_format(aBuf, sizeof(aBuf), "banned %s for %d minutes", aAddrStr, Seconds);
else else
dbg_msg("server", "banned %s for life", aAddrStr); str_format(aBuf, sizeof(aBuf), "banned %s for life", aAddrStr);
((CServer *)pUser)->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
} }
void CServer::ConUnban(IConsole::IResult *pResult, void *pUser, int ClientId) void CServer::ConUnban(IConsole::IResult *pResult, void *pUser, int ClientId)
@ -1422,19 +1469,27 @@ void CServer::ConUnban(IConsole::IResult *pResult, void *pUser, int ClientId)
CServer *pServer = (CServer *)pUser; CServer *pServer = (CServer *)pUser;
const char *pStr = pResult->GetString(0); const char *pStr = pResult->GetString(0);
if(net_addr_from_str(&Addr, pStr) == 0) if(net_addr_from_str(&Addr, pStr) == 0 && !pServer->BanRemove(Addr))
pServer->BanRemove(Addr); {
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "unbanned %d.%d.%d.%d", Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3]);
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
else if(StrAllnum(pStr)) else if(StrAllnum(pStr))
{ {
int BanIndex = str_toint(pStr); int BanIndex = str_toint(pStr);
CNetServer::CBanInfo Info; CNetServer::CBanInfo Info;
if(BanIndex < 0 || !pServer->m_NetServer.BanGet(BanIndex, &Info)) if(BanIndex < 0 || !pServer->m_NetServer.BanGet(BanIndex, &Info))
dbg_msg("server", "invalid ban index"); pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid ban index");
else else if(!pServer->BanRemove(Info.m_Addr))
pServer->BanRemove(Info.m_Addr); {
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "unbanned %d.%d.%d.%d", Info.m_Addr.ip[0], Info.m_Addr.ip[1], Info.m_Addr.ip[2], Info.m_Addr.ip[3]);
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
} }
else else
dbg_msg("server", "invalid network address"); pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid network address");
} }
void CServer::ConBans(IConsole::IResult *pResult, void *pUser, int ClientId) void CServer::ConBans(IConsole::IResult *pResult, void *pUser, int ClientId)
@ -1460,12 +1515,10 @@ void CServer::ConBans(IConsole::IResult *pResult, void *pUser, int ClientId)
unsigned t = Info.m_Expires - Now; unsigned t = Info.m_Expires - Now;
str_format(aBuf, sizeof(aBuf), "#%d %d.%d.%d.%d for %d minutes and %d seconds", i, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], t/60, t%60); str_format(aBuf, sizeof(aBuf), "#%d %d.%d.%d.%d for %d minutes and %d seconds", i, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], t/60, t%60);
} }
pServer->Console()->Print(aBuf); pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf);
dbg_msg("server", "%s", aBuf);
} }
str_format(aBuf, sizeof(aBuf), "%d ban(s)", Num); str_format(aBuf, sizeof(aBuf), "%d ban(s)", Num);
pServer->Console()->Print(aBuf); pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf);
dbg_msg("server", "%s", aBuf);
} }
void CServer::ConStatus(IConsole::IResult *pResult, void *pUser, int ClientId) void CServer::ConStatus(IConsole::IResult *pResult, void *pUser, int ClientId)
@ -1487,8 +1540,7 @@ void CServer::ConStatus(IConsole::IResult *pResult, void *pUser, int ClientId)
else else
str_format(aBuf, sizeof(aBuf), "id=%d addr=%d.%d.%d.%d:%d connecting", str_format(aBuf, sizeof(aBuf), "id=%d addr=%d.%d.%d.%d:%d connecting",
i, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port); i, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port);
pServer->Console()->Print(aBuf); pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf);
dbg_msg("server", "%s", aBuf);
} }
} }
} }
@ -1502,7 +1554,7 @@ void CServer::ConRecord(IConsole::IResult *pResult, void *pUser, int ClientId)
{ {
char aFilename[512]; char aFilename[512];
str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pResult->GetString(0)); str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pResult->GetString(0));
((CServer *)pUser)->m_DemoRecorder.Start(((CServer *)pUser)->Storage(), aFilename, ((CServer *)pUser)->GameServer()->NetVersion(), ((CServer *)pUser)->m_aCurrentMap, ((CServer *)pUser)->m_CurrentMapCrc, "server"); ((CServer *)pUser)->m_DemoRecorder.Start(((CServer *)pUser)->Storage(), ((CServer *)pUser)->Console(), aFilename, ((CServer *)pUser)->GameServer()->NetVersion(), ((CServer *)pUser)->m_aCurrentMap, ((CServer *)pUser)->m_CurrentMapCrc, "server");
} }
void CServer::ConStopRecord(IConsole::IResult *pResult, void *pUser, int ClientId) void CServer::ConStopRecord(IConsole::IResult *pResult, void *pUser, int ClientId)
@ -1603,7 +1655,7 @@ int main(int argc, const char **argv) // ignore_convention
IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); // ignore_convention IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); // ignore_convention
IConfig *pConfig = CreateConfig(); IConfig *pConfig = CreateConfig();
pServer->InitRegister(&pServer->m_NetServer, pEngineMasterServer); pServer->InitRegister(&pServer->m_NetServer, pEngineMasterServer, pConsole);
{ {
bool RegisterFail = false; bool RegisterFail = false;

View file

@ -168,7 +168,7 @@ public:
void DoSnapshot(); void DoSnapshot();
static int NewClientCallback(int ClientId, void *pUser); static int NewClientCallback(int ClientId, void *pUser);
static int DelClientCallback(int ClientId, void *pUser); static int DelClientCallback(int ClientId, const char *pReason, void *pUser);
void SendMap(int ClientId); void SendMap(int ClientId);
void SendRconLine(int ClientId, const char *pLine); void SendRconLine(int ClientId, const char *pLine);
@ -188,7 +188,7 @@ public:
int LoadMap(const char *pMapName); int LoadMap(const char *pMapName);
void InitEngine(const char *pAppname); void InitEngine(const char *pAppname);
void InitRegister(CNetServer *pNetServer, IEngineMasterServer *pMasterServer); void InitRegister(CNetServer *pNetServer, IEngineMasterServer *pMasterServer, IConsole *pConsole);
int Run(); int Run();
static void ConKick(IConsole::IResult *pResult, void *pUser, int ClientId); static void ConKick(IConsole::IResult *pResult, void *pUser, int ClientId);

View file

@ -70,6 +70,7 @@ MACRO_CONFIG_STR(PlayerName, player_name, 24, "nameless tee", CFGFLAG_SAVE|CFGFL
MACRO_CONFIG_STR(ClanName, clan_name, 32, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "(not used)") MACRO_CONFIG_STR(ClanName, clan_name, 32, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "(not used)")
MACRO_CONFIG_STR(Password, password, 32, "", CFGFLAG_CLIENT|CFGFLAG_SERVER, "Password to the server") MACRO_CONFIG_STR(Password, password, 32, "", CFGFLAG_CLIENT|CFGFLAG_SERVER, "Password to the server")
MACRO_CONFIG_STR(Logfile, logfile, 128, "", CFGFLAG_SAVE|CFGFLAG_CLIENT|CFGFLAG_SERVER, "Filename to log all output to") MACRO_CONFIG_STR(Logfile, logfile, 128, "", CFGFLAG_SAVE|CFGFLAG_CLIENT|CFGFLAG_SERVER, "Filename to log all output to")
MACRO_CONFIG_INT(ConsoleOutputLevel, console_output_level, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Adjusts the amount of information in the console")
MACRO_CONFIG_INT(ClCpuThrottle, cl_cpu_throttle, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "") MACRO_CONFIG_INT(ClCpuThrottle, cl_cpu_throttle, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
MACRO_CONFIG_INT(ClEditor, cl_editor, 0, 0, 1, CFGFLAG_CLIENT, "") MACRO_CONFIG_INT(ClEditor, cl_editor, 0, 0, 1, CFGFLAG_CLIENT, "")

View file

@ -157,11 +157,15 @@ void CConsole::RegisterPrintCallback(FPrintCallback pfnPrintCallback, void *pUse
m_pPrintCallbackUserdata = pUserData; m_pPrintCallbackUserdata = pUserData;
} }
void CConsole::Print(const char *pStr) void CConsole::Print(int Level, const char *pFrom, const char *pStr)
{ {
dbg_msg("console" ,"%s", pStr); dbg_msg(pFrom ,"%s", pStr);
if (m_pfnPrintCallback) if (Level <= g_Config.m_ConsoleOutputLevel && m_pfnPrintCallback)
m_pfnPrintCallback(pStr, m_pPrintCallbackUserdata); {
char aBuf[1024];
str_format(aBuf, sizeof(aBuf), "[%s]: %s", pFrom, pStr);
m_pfnPrintCallback(aBuf, m_pPrintCallbackUserdata);
}
} }
void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int ClientLevel, const int ClientId) void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int ClientLevel, const int ClientId)
@ -218,7 +222,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int Client
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Invalid arguments... Usage: %s %s", pCommand->m_pName, pCommand->m_pParams); str_format(aBuf, sizeof(aBuf), "Invalid arguments... Usage: %s %s", pCommand->m_pName, pCommand->m_pParams);
Print(aBuf); Print(OUTPUT_LEVEL_STANDARD, "Console", aBuf);
} }
if (pCommand->m_Level <= ClientLevel) { if (pCommand->m_Level <= ClientLevel) {
pCommand->m_pfnCallback(pResult, pCommand->m_pUserData, ClientId); pCommand->m_pfnCallback(pResult, pCommand->m_pUserData, ClientId);
@ -238,7 +242,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, const int Client
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "No such command: %s.", pResult->m_pCommand); str_format(aBuf, sizeof(aBuf), "No such command: %s.", pResult->m_pCommand);
Print(aBuf); Print(OUTPUT_LEVEL_STANDARD, "Console", aBuf);
} }
pStr = pNextPart; pStr = pNextPart;
@ -302,12 +306,14 @@ void CConsole::ExecuteFile(const char *pFilename)
// exec the file // exec the file
IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_READ); IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_READ);
char aBuf[256];
if(File) if(File)
{ {
char *pLine; char *pLine;
CLineReader lr; CLineReader lr;
dbg_msg("console", "executing '%s'", pFilename); str_format(aBuf, sizeof(aBuf), "executing '%s'", pFilename);
Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
lr.Init(File); lr.Init(File);
while((pLine = lr.Get())) while((pLine = lr.Get()))
@ -316,14 +322,17 @@ void CConsole::ExecuteFile(const char *pFilename)
io_close(File); io_close(File);
} }
else else
dbg_msg("console", "failed to open '%s'", pFilename); {
str_format(aBuf, sizeof(aBuf), "failed to open '%s'", pFilename);
Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
}
m_pFirstExec = pPrev; m_pFirstExec = pPrev;
} }
void CConsole::Con_Echo(IResult *pResult, void *pUserData, int ClientId) void CConsole::Con_Echo(IResult *pResult, void *pUserData, int ClientId)
{ {
((CConsole*)pUserData)->Print(pResult->GetString(0)); ((CConsole*)pUserData)->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Console", pResult->GetString(0));
} }
void CConsole::Con_Exec(IResult *pResult, void *pUserData, int ClientId) void CConsole::Con_Exec(IResult *pResult, void *pUserData, int ClientId)
@ -369,7 +378,7 @@ static void IntVariableCommand(IConsole::IResult *pResult, void *pUserData, int
{ {
char aBuf[1024]; char aBuf[1024];
str_format(aBuf, sizeof(aBuf), "Value: %d", *(pData->m_pVariable)); str_format(aBuf, sizeof(aBuf), "Value: %d", *(pData->m_pVariable));
pData->m_pConsole->Print(aBuf); pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Console", aBuf);
} }
} }
@ -383,7 +392,7 @@ static void StrVariableCommand(IConsole::IResult *pResult, void *pUserData, int
{ {
char aBuf[1024]; char aBuf[1024];
str_format(aBuf, sizeof(aBuf), "Value: %s", pData->m_pStr); str_format(aBuf, sizeof(aBuf), "Value: %s", pData->m_pStr);
pData->m_pConsole->Print(aBuf); pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Console", aBuf);
} }
} }
@ -470,7 +479,9 @@ void CConsole::Chain(const char *pName, FChainCommandCallback pfnChainFunc, void
if(!pCommand) if(!pCommand)
{ {
dbg_msg("console", "failed to chain '%s'", pName); char aBuf[256];
str_format(aBuf, sizeof(aBuf), "failed to chain '%s'", pName);
Print(IConsole::OUTPUT_LEVEL_DEBUG, "console", aBuf);
return; return;
} }

View file

@ -123,7 +123,7 @@ public:
virtual void ExecuteFile(const char *pFilename); virtual void ExecuteFile(const char *pFilename);
virtual void RegisterPrintCallback(FPrintCallback pfnPrintCallback, void *pUserData); virtual void RegisterPrintCallback(FPrintCallback pfnPrintCallback, void *pUserData);
virtual void Print(const char *pStr); virtual void Print(int Level, const char *pFrom, const char *pStr);
}; };
#endif #endif

View file

@ -1,4 +1,5 @@
#include <base/system.h> #include <base/system.h>
#include <engine/console.h>
#include <engine/shared/protocol.h> #include <engine/shared/protocol.h>
#include <engine/storage.h> #include <engine/storage.h>
#include "demorec.h" #include "demorec.h"
@ -20,17 +21,20 @@ CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta)
//static IOHANDLE m_File = 0; //static IOHANDLE m_File = 0;
// Record // Record
int CDemoRecorder::Start(class IStorage *pStorage, const char *pFilename, const char *pNetVersion, const char *pMap, int Crc, const char *pType) int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetVersion, const char *pMap, int Crc, const char *pType)
{ {
CDemoHeader Header; CDemoHeader Header;
if(m_File) if(m_File)
return -1; return -1;
m_pConsole = pConsole;
m_File = pStorage->OpenFile(pFilename, IOFLAG_WRITE); m_File = pStorage->OpenFile(pFilename, IOFLAG_WRITE);
if(!m_File) if(!m_File)
{ {
dbg_msg("demorec/record", "Unable to open '%s' for recording", pFilename); char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Unable to open '%s' for recording", pFilename);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", aBuf);
return -1; return -1;
} }
@ -49,7 +53,9 @@ int CDemoRecorder::Start(class IStorage *pStorage, const char *pFilename, const
m_LastKeyFrame = -1; m_LastKeyFrame = -1;
m_LastTickMarker = -1; m_LastTickMarker = -1;
dbg_msg("demorec/record", "Recording to '%s'", pFilename); char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Recording to '%s'", pFilename);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", aBuf);
return 0; return 0;
} }
@ -193,7 +199,7 @@ int CDemoRecorder::Stop()
if(!m_File) if(!m_File)
return -1; return -1;
dbg_msg("demorec/record", "Stopped recording"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", "Stopped recording");
io_close(m_File); io_close(m_File);
m_File = 0; m_File = 0;
return 0; return 0;
@ -348,7 +354,7 @@ void CDemoPlayer::DoTick()
if(ReadChunkHeader(&ChunkType, &ChunkSize, &ChunkTick)) if(ReadChunkHeader(&ChunkType, &ChunkSize, &ChunkTick))
{ {
// stop on error or eof // stop on error or eof
dbg_msg("demorec", "end of file"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", "end of file");
Pause(); Pause();
break; break;
} }
@ -359,7 +365,7 @@ void CDemoPlayer::DoTick()
if(io_read(m_File, aCompresseddata, ChunkSize) != (unsigned)ChunkSize) if(io_read(m_File, aCompresseddata, ChunkSize) != (unsigned)ChunkSize)
{ {
// stop on error or eof // stop on error or eof
dbg_msg("demorec", "error reading chunk"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", "error reading chunk");
Stop(); Stop();
break; break;
} }
@ -368,7 +374,7 @@ void CDemoPlayer::DoTick()
if(DataSize < 0) if(DataSize < 0)
{ {
// stop on error or eof // stop on error or eof
dbg_msg("demorec", "error during network decompression"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", "error during network decompression");
Stop(); Stop();
break; break;
} }
@ -377,7 +383,7 @@ void CDemoPlayer::DoTick()
if(DataSize < 0) if(DataSize < 0)
{ {
dbg_msg("demorec", "error during intpack decompression"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", "error during intpack decompression");
Stop(); Stop();
break; break;
} }
@ -401,7 +407,11 @@ void CDemoPlayer::DoTick()
mem_copy(m_aLastSnapshotData, aNewsnap, DataSize); mem_copy(m_aLastSnapshotData, aNewsnap, DataSize);
} }
else else
dbg_msg("demorec", "error duing unpacking of delta, err=%d", DataSize); {
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "error during unpacking of delta, err=%d", DataSize);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", aBuf);
}
} }
else if(ChunkType == CHUNKTYPE_SNAPSHOT) else if(ChunkType == CHUNKTYPE_SNAPSHOT)
{ {
@ -452,12 +462,15 @@ void CDemoPlayer::Unpause()
} }
} }
int CDemoPlayer::Load(class IStorage *pStorage, const char *pFilename) int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename)
{ {
m_pConsole = pConsole;
m_File = pStorage->OpenFile(pFilename, IOFLAG_READ); m_File = pStorage->OpenFile(pFilename, IOFLAG_READ);
if(!m_File) if(!m_File)
{ {
dbg_msg("demorec/playback", "could not open '%s'", pFilename); char aBuf[256];
str_format(aBuf, sizeof(aBuf), "could not open '%s'", pFilename);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_player", aBuf);
return -1; return -1;
} }
@ -477,7 +490,9 @@ int CDemoPlayer::Load(class IStorage *pStorage, const char *pFilename)
io_read(m_File, &m_Info.m_Header, sizeof(m_Info.m_Header)); io_read(m_File, &m_Info.m_Header, sizeof(m_Info.m_Header));
if(mem_comp(m_Info.m_Header.m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) != 0) if(mem_comp(m_Info.m_Header.m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) != 0)
{ {
dbg_msg("demorec/playback", "'%s' is not a demo file", pFilename); char aBuf[256];
str_format(aBuf, sizeof(aBuf), "'%s' is not a demo file", pFilename);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_player", aBuf);
io_close(m_File); io_close(m_File);
m_File = 0; m_File = 0;
return -1; return -1;
@ -599,8 +614,10 @@ int CDemoPlayer::Update()
if(m_Info.m_Info.m_CurrentTick == m_Info.m_PreviousTick || if(m_Info.m_Info.m_CurrentTick == m_Info.m_PreviousTick ||
m_Info.m_Info.m_CurrentTick == m_Info.m_NextTick) m_Info.m_Info.m_CurrentTick == m_Info.m_NextTick)
{ {
dbg_msg("demorec/playback", "tick error prev=%d cur=%d next=%d", char aBuf[256];
str_format(aBuf, sizeof(aBuf), "tick error prev=%d cur=%d next=%d",
m_Info.m_PreviousTick, m_Info.m_Info.m_CurrentTick, m_Info.m_NextTick); m_Info.m_PreviousTick, m_Info.m_Info.m_CurrentTick, m_Info.m_NextTick);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", aBuf);
} }
} }
@ -612,7 +629,7 @@ int CDemoPlayer::Stop()
if(!m_File) if(!m_File)
return -1; return -1;
dbg_msg("demorec/playback", "Stopped playback"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_player", "Stopped playback");
io_close(m_File); io_close(m_File);
m_File = 0; m_File = 0;
mem_free(m_pKeyFrames); mem_free(m_pKeyFrames);

View file

@ -15,6 +15,7 @@ struct CDemoHeader
class CDemoRecorder : public IDemoRecorder class CDemoRecorder : public IDemoRecorder
{ {
class IConsole *m_pConsole;
IOHANDLE m_File; IOHANDLE m_File;
int m_LastTickMarker; int m_LastTickMarker;
int m_LastKeyFrame; int m_LastKeyFrame;
@ -26,7 +27,7 @@ class CDemoRecorder : public IDemoRecorder
public: public:
CDemoRecorder(class CSnapshotDelta *pSnapshotDelta); CDemoRecorder(class CSnapshotDelta *pSnapshotDelta);
int Start(class IStorage *pStorage, const char *pFilename, const char *pNetversion, const char *pMap, int MapCrc, const char *pType); int Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetversion, const char *pMap, int MapCrc, const char *pType);
int Stop(); int Stop();
void RecordSnapshot(int Tick, const void *pData, int Size); void RecordSnapshot(int Tick, const void *pData, int Size);
@ -80,6 +81,7 @@ private:
CKeyFrameSearch *m_pNext; CKeyFrameSearch *m_pNext;
}; };
class IConsole *m_pConsole;
IOHANDLE m_File; IOHANDLE m_File;
CKeyFrame *m_pKeyFrames; CKeyFrame *m_pKeyFrames;
@ -99,7 +101,7 @@ public:
void SetListner(IListner *pListner); void SetListner(IListner *pListner);
int Load(class IStorage *pStorage, const char *pFilename); int Load(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename);
int Play(); int Play();
void Pause(); void Pause();
void Unpause(); void Unpause();

View file

@ -79,7 +79,7 @@ enum
}; };
typedef int (*NETFUNC_DELCLIENT)(int ClientID, void *pUser); typedef int (*NETFUNC_DELCLIENT)(int ClientID, const char* pReason, void *pUser);
typedef int (*NETFUNC_NEWCLIENT)(int ClientID, void *pUser); typedef int (*NETFUNC_NEWCLIENT)(int ClientID, void *pUser);
struct CNetChunk struct CNetChunk

View file

@ -21,7 +21,7 @@ int CNetClient::Close()
int CNetClient::Disconnect(const char *pReason) int CNetClient::Disconnect(const char *pReason)
{ {
dbg_msg("netclient", "disconnected. reason=\"%s\"", pReason); //dbg_msg("netclient", "disconnected. reason=\"%s\"", pReason);
m_Connection.Disconnect(pReason); m_Connection.Disconnect(pReason);
return 0; return 0;
} }

View file

@ -80,11 +80,13 @@ int CNetServer::Drop(int ClientID, const char *pReason)
{ {
// TODO: insert lots of checks here // TODO: insert lots of checks here
NETADDR Addr = ClientAddr(ClientID); NETADDR Addr = ClientAddr(ClientID);
dbg_msg("net_server", "client dropped. cid=%d ip=%d.%d.%d.%d reason=\"%s\"", /*dbg_msg("net_server", "client dropped. cid=%d ip=%d.%d.%d.%d reason=\"%s\"",
ClientID, ClientID,
Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3],
pReason pReason
); );*/
if(m_pfnDelClient)
m_pfnDelClient(ClientID, pReason, m_UserPtr);
if(m_pfnDelClient) if(m_pfnDelClient)

View file

@ -30,10 +30,12 @@ void CBinds::Bind(int KeyId, const char *pStr)
return; return;
str_copy(m_aaKeyBindings[KeyId], pStr, sizeof(m_aaKeyBindings[KeyId])); str_copy(m_aaKeyBindings[KeyId], pStr, sizeof(m_aaKeyBindings[KeyId]));
char aBuf[256];
if(!m_aaKeyBindings[KeyId][0]) 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 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) 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; return;
} }
@ -152,7 +156,9 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData)
if(!id) 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; return;
} }
@ -175,8 +181,8 @@ void CBinds::ConDumpBinds(IConsole::IResult *pResult, void *pUserData)
{ {
if(pBinds->m_aaKeyBindings[i][0] == 0) if(pBinds->m_aaKeyBindings[i][0] == 0)
continue; continue;
str_format(aBuf, sizeof(aBuf), "[binds] %s (%d) = %s", pBinds->Input()->KeyName(i), i, pBinds->m_aaKeyBindings[i]); str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pBinds->Input()->KeyName(i), i, pBinds->m_aaKeyBindings[i]);
pBinds->Console()->Print(aBuf); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf);
} }
} }

View file

@ -62,7 +62,7 @@ void CChat::ConChat(IConsole::IResult *pResult, void *pUserData)
else if(str_comp(pMode, "team") == 0) else if(str_comp(pMode, "team") == 0)
((CChat*)pUserData)->EnableMode(1); ((CChat*)pUserData)->EnableMode(1);
else 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) void CChat::ConShowChat(IConsole::IResult *pResult, void *pUserData)
@ -166,8 +166,8 @@ void CChat::AddLine(int ClientId, int Team, const char *pLine)
} }
char aBuf[1024]; char aBuf[1024];
str_format(aBuf, sizeof(aBuf), "[chat]%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText);
Console()->Print(aBuf); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat", aBuf);
} }
// play sound // play sound

View file

@ -699,7 +699,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
static int s_JoinButton = 0; static int s_JoinButton = 0;
if(DoButton_Menu(&s_JoinButton, Localize("Connect"), 0, &Button) || m_EnterPressed) 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); Client()->Connect(g_Config.m_UiServerAddress);
m_EnterPressed = false; m_EnterPressed = false;
} }

View file

@ -706,7 +706,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
if(OldSelected != s_SelectedLanguage) if(OldSelected != s_SelectedLanguage)
{ {
str_copy(g_Config.m_ClLanguagefile, s_Languages[s_SelectedLanguage].m_FileName, sizeof(g_Config.m_ClLanguagefile)); 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());
} }
} }

View file

@ -29,7 +29,8 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser)
CImageInfo Info; CImageInfo Info;
if(!pSelf->Graphics()->LoadPNG(&Info, aBuf)) 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; return;
} }
@ -111,7 +112,8 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser)
// set skin data // 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)); 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++; pSelf->m_NumSkins++;
} }

View file

@ -224,7 +224,7 @@ void CGameClient::OnInit()
//m_pServerBrowser = Kernel()->RequestInterface<IServerBrowser>(); //m_pServerBrowser = Kernel()->RequestInterface<IServerBrowser>();
// set the language // set the language
g_Localization.Load(g_Config.m_ClLanguagefile); g_Localization.Load(g_Config.m_ClLanguagefile, Console());
// init all components // init all components
for(int i = 0; i < m_All.m_Num; i++) for(int i = 0; i < m_All.m_Num; i++)
@ -289,7 +289,9 @@ void CGameClient::OnInit()
m_All.m_paComponents[i]->OnReset(); m_All.m_paComponents[i]->OnReset();
int64 End = time_get(); 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; m_ServerMode = SERVERMODE_PURE;
} }
@ -518,7 +520,9 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker); void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker);
if(!pRawMsg) 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; return;
} }
@ -636,7 +640,11 @@ void CGameClient::OnNewSnapshot()
if(m_NetObjHandler.ValidateObj(Item.m_Type, pData, Item.m_DataSize) != 0) if(m_NetObjHandler.ValidateObj(Item.m_Type, pData, Item.m_DataSize) != 0)
{ {
if(g_Config.m_Debug) 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); Client()->SnapInvalidateItem(IClient::SNAP_CURRENT, Index);
} }
} }
@ -905,11 +913,13 @@ void CGameClient::OnPredict()
if(mem_comp(&Before, &Now, sizeof(CNetObj_CharacterCore)) != 0) 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++) for(unsigned i = 0; i < sizeof(CNetObj_CharacterCore)/sizeof(int); i++)
if(((int *)&Before)[i] != ((int *)&Now)[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);
} }
} }
} }

View file

@ -8,6 +8,7 @@
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include <engine/shared/engine.h> #include <engine/shared/engine.h>
#include <engine/client.h> #include <engine/client.h>
#include <engine/console.h>
#include <engine/graphics.h> #include <engine/graphics.h>
#include <engine/textrender.h> #include <engine/textrender.h>
#include <engine/input.h> #include <engine/input.h>
@ -1271,7 +1272,9 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
if(!UI()->MouseButton(0)) if(!UI()->MouseButton(0))
{ {
// grab brush // 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 // TODO: do all layers
int Grabs = 0; int Grabs = 0;
@ -1820,7 +1823,7 @@ static void ExtractName(const char *pFileName, char *pName)
int FinalLen = End-Start; int FinalLen = End-Start;
mem_copy(pName, &pFileName[Start], FinalLen); mem_copy(pName, &pFileName[Start], FinalLen);
pName[FinalLen] = 0; 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) void CEditor::ReplaceImage(const char *pFileName, void *pUser)
@ -3006,6 +3009,7 @@ void CEditor::Init()
{ {
m_pInput = Kernel()->RequestInterface<IInput>(); m_pInput = Kernel()->RequestInterface<IInput>();
m_pClient = Kernel()->RequestInterface<IClient>(); m_pClient = Kernel()->RequestInterface<IClient>();
m_pConsole = Kernel()->RequestInterface<IConsole>();
m_pGraphics = Kernel()->RequestInterface<IGraphics>(); m_pGraphics = Kernel()->RequestInterface<IGraphics>();
m_pTextRender = Kernel()->RequestInterface<ITextRender>(); m_pTextRender = Kernel()->RequestInterface<ITextRender>();
m_RenderTools.m_pGraphics = m_pGraphics; m_RenderTools.m_pGraphics = m_pGraphics;

View file

@ -427,6 +427,7 @@ class CEditor : public IEditor
{ {
class IInput *m_pInput; class IInput *m_pInput;
class IClient *m_pClient; class IClient *m_pClient;
class IConsole *m_pConsole;
class IGraphics *m_pGraphics; class IGraphics *m_pGraphics;
class ITextRender *m_pTextRender; class ITextRender *m_pTextRender;
CRenderTools m_RenderTools; CRenderTools m_RenderTools;
@ -434,6 +435,7 @@ class CEditor : public IEditor
public: public:
class IInput *Input() { return m_pInput; }; class IInput *Input() { return m_pInput; };
class IClient *Client() { return m_pClient; }; class IClient *Client() { return m_pClient; };
class IConsole *Console() { return m_pConsole; };
class IGraphics *Graphics() { return m_pGraphics; }; class IGraphics *Graphics() { return m_pGraphics; };
class ITextRender *TextRender() { return m_pTextRender; }; class ITextRender *TextRender() { return m_pTextRender; };
CUI *UI() { return &m_UI; } CUI *UI() { return &m_UI; }

View file

@ -1,3 +1,4 @@
#include <engine/console.h>
#include <engine/graphics.h> #include <engine/graphics.h>
#include <engine/storage.h> #include <engine/storage.h>
#include <game/gamecore.h> #include <game/gamecore.h>
@ -197,11 +198,14 @@ int CEditor::Save(const char *pFilename)
int CEditorMap::Save(class IStorage *pStorage, 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; CDataFileWriter df;
if(!df.Open(pStorage, pFileName)) 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; return 0;
} }
@ -259,7 +263,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
{ {
if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_TILES) 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]; CLayerTiles *pLayer = (CLayerTiles *)pGroup->m_lLayers[l];
pLayer->PrepareForSave(); 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) 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]; CLayerQuads *pLayer = (CLayerQuads *)pGroup->m_lLayers[l];
if(pLayer->m_lQuads.size()) if(pLayer->m_lQuads.size())
{ {
@ -346,7 +350,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
// finish the data file // finish the data file
df.Finish(); df.Finish();
dbg_msg("editor", "done"); m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving done");
// send rcon.. if we can // send rcon.. if we can
/* /*

View file

@ -1,5 +1,6 @@
#include <base/math.h> #include <base/math.h>
#include <engine/console.h>
#include <engine/graphics.h> #include <engine/graphics.h>
#include "ed_editor.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) 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; CQuad n;
n = *q; n = *q;

View file

@ -1,3 +1,4 @@
#include <engine/console.h>
#include <engine/graphics.h> #include <engine/graphics.h>
#include <engine/input.h> #include <engine/input.h>
#include <engine/keys.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) 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) if(x + w > UI()->Screen()->w)
x -= w; x -= w;
if(y + h > UI()->Screen()->h) if(y + h > UI()->Screen()->h)

View file

@ -3,6 +3,7 @@
#include <base/tl/algorithm.h> #include <base/tl/algorithm.h>
#include <engine/shared/linereader.h> #include <engine/shared/linereader.h>
#include <engine/console.h>
const char *Localize(const char *pStr) const char *Localize(const char *pStr)
{ {
@ -39,7 +40,7 @@ void CLocalizationDatabase::AddString(const char *pOrgStr, const char *pNewStr)
m_Strings.add(s); m_Strings.add(s);
} }
bool CLocalizationDatabase::Load(const char *pFilename) bool CLocalizationDatabase::Load(const char *pFilename, IConsole *pConsole)
{ {
// empty string means unload // empty string means unload
if(pFilename[0] == 0) if(pFilename[0] == 0)
@ -53,7 +54,9 @@ bool CLocalizationDatabase::Load(const char *pFilename)
if(!IoHandle) if(!IoHandle)
return false; 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(); m_Strings.clear();
CLineReader LineReader; CLineReader LineReader;
@ -70,13 +73,14 @@ bool CLocalizationDatabase::Load(const char *pFilename)
char *pReplacement = LineReader.Get(); char *pReplacement = LineReader.Get();
if(!pReplacement) if(!pReplacement)
{ {
dbg_msg("", "unexpected end of file"); pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", "unexpected end of file");
break; break;
} }
if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ') 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; continue;
} }

View file

@ -24,7 +24,7 @@ class CLocalizationDatabase
public: public:
CLocalizationDatabase(); CLocalizationDatabase();
bool Load(const char *pFilename); bool Load(const char *pFilename, class IConsole *pConsole);
int Version() { return m_CurrentVersion; } int Version() { return m_CurrentVersion; }

View file

@ -1000,7 +1000,8 @@ void CCharacter::TickDefered()
StartVelX.f = StartVel.x; StartVelX.f = StartVel.x;
StartVelY.f = StartVel.y; 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, StuckBefore,
StuckAfterMove, StuckAfterMove,
StuckAfterQuant, StuckAfterQuant,
@ -1008,6 +1009,7 @@ void CCharacter::TickDefered()
StartVel.x, StartVel.y, StartVel.x, StartVel.y,
StartPosX.u, StartPosY.u, StartPosX.u, StartPosY.u,
StartVelX.u, StartVelY.u); StartVelX.u, StartVelY.u);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
} }
int Events = m_Core.m_TriggeredEvents; int Events = m_Core.m_TriggeredEvents;
@ -1133,9 +1135,11 @@ void CCharacter::Die(int Killer, int Weapon)
{ {
int ModeSpecial = GameServer()->m_pController->OnCharacterDeath(this, GameServer()->m_apPlayers[Killer], 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), Killer, Server()->ClientName(Killer),
m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial); m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
// send the kill message // send the kill message
CNetMsg_Sv_KillMsg Msg; CNetMsg_Sv_KillMsg Msg;

View file

@ -127,8 +127,10 @@ void CPickup::Tick()
/* /*
if(RespawnTime >= 0) 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); 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; m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime;
}*/ }*/
} }

View file

@ -225,10 +225,12 @@ void CGameContext::SendChatTarget(int To, const char *pText)
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) 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 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) if(Team == CHAT_ALL)
{ {
@ -363,7 +365,7 @@ void CGameContext::CheckPureTuning()
CTuningParams p; CTuningParams p;
if(mem_comp(&p, &m_Tuning, sizeof(p)) != 0) 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; m_Tuning = p;
} }
} }
@ -519,9 +521,6 @@ void CGameContext::OnClientEnter(int ClientId)
{ {
//world.insert_entity(&players[client_id]); //world.insert_entity(&players[client_id]);
m_apPlayers[ClientId]->Respawn(); m_apPlayers[ClientId]->Respawn();
dbg_msg("game", "join player='%d:%s'", ClientId, Server()->ClientName(ClientId));
char aBuf[512]; 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); SendChat(-1, CGameContext::CHAT_ALL, aBuf);
@ -531,7 +530,8 @@ void CGameContext::OnClientEnter(int ClientId)
SendChatTarget(ClientId, "Or visit DDRace.info"); SendChatTarget(ClientId, "Or visit DDRace.info");
SendChatTarget(ClientId, "To see this again say /info"); SendChatTarget(ClientId, "To see this again say /info");
if (g_Config.m_SvWelcome[0]!=0) SendChatTarget(ClientId,g_Config.m_SvWelcome); if (g_Config.m_SvWelcome[0]!=0) SendChatTarget(ClientId,g_Config.m_SvWelcome);
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; m_VoteUpdate = true;
} }
@ -612,7 +612,9 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
if(!pRawMsg) 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; return;
} }
@ -1153,13 +1155,15 @@ void CGameContext::ConTuneParam(IConsole::IResult *pResult, void *pUserData, int
const char *pParamName = pResult->GetString(0); const char *pParamName = pResult->GetString(0);
float NewValue = pResult->GetFloat(1); float NewValue = pResult->GetFloat(1);
char aBuf[256];
if(pSelf->Tuning()->Set(pParamName, NewValue)) 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); pSelf->SendTuningParams(-1);
} }
else 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, int cid) void CGameContext::ConTuneReset(IConsole::IResult *pResult, void *pUserData, int cid)
@ -1168,17 +1172,19 @@ void CGameContext::ConTuneReset(IConsole::IResult *pResult, void *pUserData, int
CTuningParams p; CTuningParams p;
*pSelf->Tuning() = p; *pSelf->Tuning() = p;
pSelf->SendTuningParams(-1); 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, int cid) void CGameContext::ConTuneDump(IConsole::IResult *pResult, void *pUserData, int cid)
{ {
CGameContext *pSelf = (CGameContext *)pUserData; CGameContext *pSelf = (CGameContext *)pUserData;
char aBuf[256];
for(int i = 0; i < pSelf->Tuning()->Num(); i++) for(int i = 0; i < pSelf->Tuning()->Num(); i++)
{ {
float v; float v;
pSelf->Tuning()->Get(i, &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);
} }
} }
@ -1214,10 +1220,12 @@ void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData, int c
CGameContext *pSelf = (CGameContext *)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); int Team = clamp(pResult->GetInteger(1), -1, 1);
dbg_msg("set_team", "%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] || !compare_players(pSelf->m_apPlayers[cid], pSelf->m_apPlayers[ClientId])) if(!pSelf->m_apPlayers[ClientId] || !compare_players(pSelf->m_apPlayers[cid], pSelf->m_apPlayers[ClientId]))
if(!pSelf->m_apPlayers[ClientId])
return; return;
pSelf->m_apPlayers[ClientId]->SetTeam(Team); pSelf->m_apPlayers[ClientId]->SetTeam(Team);
@ -1239,7 +1247,9 @@ void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData, int C
pSelf->m_pVoteOptionFirst = pOption; pSelf->m_pVoteOptionFirst = pOption;
mem_copy(pOption->m_aCommand, pResult->GetString(0), Len+1); 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; CNetMsg_Sv_VoteOption OptionMsg;
OptionMsg.m_pCommand = pOption->m_aCommand; OptionMsg.m_pCommand = pOption->m_aCommand;
@ -1253,7 +1263,9 @@ void CGameContext::ConVote(IConsole::IResult *pResult, void *pUserData, int Clie
pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_YES; pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_YES;
else if(str_comp_nocase(pResult->GetString(0), "no") == 0) else if(str_comp_nocase(pResult->GetString(0), "no") == 0)
pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO; 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) void CGameContext::ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)

View file

@ -386,7 +386,9 @@ void IGameController::StartRound()
m_GameOverTick = -1; m_GameOverTick = -1;
GameServer()->m_World.m_Paused = false; GameServer()->m_World.m_Paused = false;
m_ForceBalanced = false; 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) void IGameController::ChangeMap(const char *pToMap)
@ -399,7 +401,9 @@ void IGameController::CycleMap()
{ {
if(m_aMapWish[0] != 0) 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)); str_copy(g_Config.m_SvMap, m_aMapWish, sizeof(g_Config.m_SvMap));
m_aMapWish[0] = 0; m_aMapWish[0] = 0;
m_RoundCount = 0; m_RoundCount = 0;
@ -441,26 +445,28 @@ void IGameController::CycleMap()
pNextMap = pMapRotation; pNextMap = pMapRotation;
// cut out the next map // cut out the next map
char Buf[512]; char aBuf[512];
for(int i = 0; i < 512; i++) for(int i = 0; i < 512; i++)
{ {
Buf[i] = pNextMap[i]; aBuf[i] = pNextMap[i];
if(IsSeparator(pNextMap[i]) || pNextMap[i] == 0) if(IsSeparator(pNextMap[i]) || pNextMap[i] == 0)
{ {
Buf[i] = 0; aBuf[i] = 0;
break; break;
} }
} }
// skip spaces // skip spaces
int i = 0; int i = 0;
while(IsSeparator(Buf[i])) while(IsSeparator(aBuf[i]))
i++; i++;
m_RoundCount = 0; m_RoundCount = 0;
dbg_msg("game", "rotating map to %s", &Buf[i]); char aBufMsg[256];
str_copy(g_Config.m_SvMap, &Buf[i], sizeof(g_Config.m_SvMap)); 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() void IGameController::PostReset()
@ -586,7 +592,7 @@ void IGameController::Tick()
// do team-balancing // do team-balancing
if (IsTeamplay() && m_UnbalancedTick != -1 && Server()->Tick() > m_UnbalancedTick+g_Config.m_SvTeambalanceTime*Server()->TickSpeed()*60) 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}; int aT[2] = {0,0};
float aTScore[2] = {0,0}; float aTScore[2] = {0,0};
@ -759,16 +765,19 @@ bool IGameController::CheckTeamBalance()
aT[pP->GetTeam()]++; aT[pP->GetTeam()]++;
} }
char aBuf[256];
if(absolute(aT[0]-aT[1]) >= 2) 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) if(GameServer()->m_pController->m_UnbalancedTick == -1)
GameServer()->m_pController->m_UnbalancedTick = Server()->Tick(); GameServer()->m_pController->m_UnbalancedTick = Server()->Tick();
return false; return false;
} }
else 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; GameServer()->m_pController->m_UnbalancedTick = -1;
return true; return true;
} }

View file

@ -111,21 +111,22 @@ void CGameControllerCTF::Tick()
m_aTeamscore[fi^1] += 100; m_aTeamscore[fi^1] += 100;
F->m_pCarryingCharacter->GetPlayer()->m_Score += 5; 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(), F->m_pCarryingCharacter->GetPlayer()->GetCID(),
Server()->ClientName(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(); float CaptureTime = (Server()->Tick() - F->m_GrabTick)/(float)Server()->TickSpeed();
if(CaptureTime <= 60) 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 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++) for(int i = 0; i < 2; i++)
m_apFlags[i]->Reset(); m_apFlags[i]->Reset();
@ -150,9 +151,11 @@ void CGameControllerCTF::Tick()
CCharacter *pChr = apCloseCCharacters[i]; CCharacter *pChr = apCloseCCharacters[i];
pChr->GetPlayer()->m_Score += 1; 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(), pChr->GetPlayer()->GetCID(),
Server()->ClientName(pChr->GetPlayer()->GetCID())); Server()->ClientName(pChr->GetPlayer()->GetCID()));
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN); GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN);
F->Reset(); F->Reset();
@ -171,9 +174,11 @@ void CGameControllerCTF::Tick()
F->m_pCarryingCharacter = apCloseCCharacters[i]; F->m_pCarryingCharacter = apCloseCCharacters[i];
F->m_pCarryingCharacter->GetPlayer()->m_Score += 1; 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(), F->m_pCarryingCharacter->GetPlayer()->GetCID(),
Server()->ClientName(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++) for(int c = 0; c < MAX_CLIENTS; c++)
{ {

View file

@ -142,12 +142,13 @@ void CPlayer::OnDisconnect()
if(Server()->ClientIngame(m_ClientID)) if(Server()->ClientIngame(m_ClientID))
{ {
char Buf[512]; char aBuf[512];
const char * Name = Server()->ClientName(m_ClientID); const char * Name = Server()->ClientName(m_ClientID);
str_format(Buf, sizeof(Buf), "%s has left the game", Name); str_format(aBuf, sizeof(aBuf), "%s has left the game", Server()->ClientName(m_ClientID));
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, Buf); GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
char Cmd[64]; char Cmd[64];
dbg_msg("game", "leave player='%d:%s'", m_ClientID, Name); str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID));
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf);
if(m_Muted > 0) { if(m_Muted > 0) {
str_format(Cmd, sizeof(Cmd), "ban %d %d '%s'", m_ClientID, m_Muted/Server()->TickSpeed(), "ppc"); str_format(Cmd, sizeof(Cmd), "ban %d %d '%s'", m_ClientID, m_Muted/Server()->TickSpeed(), "ppc");
GameServer()->Console()->ExecuteLine(Cmd, 3, -1); GameServer()->Console()->ExecuteLine(Cmd, 3, -1);
@ -204,16 +205,17 @@ void CPlayer::SetTeam(int Team)
if(m_Team == Team) if(m_Team == Team)
return; return;
char Buf[512]; char aBuf[512];
str_format(Buf, sizeof(Buf), "%s joined the %s", Server()->ClientName(m_ClientID), GameServer()->m_pController->GetTeamName(Team)); str_format(aBuf, sizeof(aBuf), "%s joined the %s", Server()->ClientName(m_ClientID), GameServer()->m_pController->GetTeamName(Team));
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, Buf); GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
KillCharacter(); KillCharacter();
m_Team = Team; m_Team = Team;
// we got to wait 0.5 secs before respawning // we got to wait 0.5 secs before respawning
m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2; 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]); //GameServer()->m_pController->OnPlayerInfoChange(GameServer()->m_apPlayers[m_ClientID]);
} }