mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
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:
parent
16f201794d
commit
cabecb7fa9
|
@ -437,7 +437,11 @@ void CClient::SetState(int s)
|
|||
{
|
||||
int Old = m_State;
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("client", "state change. last=%d current=%d", m_State, s);
|
||||
{
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "state change. last=%d current=%d", m_State, s);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf);
|
||||
}
|
||||
m_State = s;
|
||||
if(Old != s)
|
||||
GameClient()->OnStateChange(m_State, Old);
|
||||
|
@ -484,7 +488,8 @@ void CClient::Connect(const char *pAddress)
|
|||
|
||||
str_copy(m_aServerAddressStr, pAddress, sizeof(m_aServerAddressStr));
|
||||
|
||||
dbg_msg("client", "connecting to '%s'", m_aServerAddressStr);
|
||||
str_format(aBuf, sizeof(aBuf), "connecting to '%s'", m_aServerAddressStr);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf);
|
||||
|
||||
ServerInfoRequest();
|
||||
str_copy(aBuf, m_aServerAddressStr, sizeof(aBuf));
|
||||
|
@ -502,7 +507,9 @@ void CClient::Connect(const char *pAddress)
|
|||
// TODO: IPv6 support
|
||||
if(net_host_lookup(aBuf, &m_ServerAddress, NETTYPE_IPV4) != 0)
|
||||
{
|
||||
dbg_msg("client", "could not find the address of %s, connecting to localhost", aBuf);
|
||||
char aBufMsg[256];
|
||||
str_format(aBufMsg, sizeof(aBufMsg), "could not find the address of %s, connecting to localhost", aBuf);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBufMsg);
|
||||
net_host_lookup("localhost", &m_ServerAddress, NETTYPE_IPV4);
|
||||
}
|
||||
|
||||
|
@ -520,6 +527,10 @@ void CClient::Connect(const char *pAddress)
|
|||
|
||||
void CClient::DisconnectWithReason(const char *pReason)
|
||||
{
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason?pReason:"unknown");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf);
|
||||
|
||||
// stop demo playback and recorder
|
||||
m_DemoPlayer.Stop();
|
||||
m_DemoRecorder.Stop();
|
||||
|
@ -593,9 +604,9 @@ void CClient::SnapInvalidateItem(int SnapId, int Index)
|
|||
if(i)
|
||||
{
|
||||
if((char *)i < (char *)m_aSnapshots[SnapId]->m_pAltSnap || (char *)i > (char *)m_aSnapshots[SnapId]->m_pAltSnap + m_aSnapshots[SnapId]->m_SnapSize)
|
||||
dbg_msg("ASDFASDFASdf", "ASDFASDFASDF");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "snap invalidate problem");
|
||||
if((char *)i >= (char *)m_aSnapshots[SnapId]->m_pSnap && (char *)i < (char *)m_aSnapshots[SnapId]->m_pSnap + m_aSnapshots[SnapId]->m_SnapSize)
|
||||
dbg_msg("ASDFASDFASdf", "ASDFASDFASDF");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "snap invalidate problem");
|
||||
i->m_TypeAndID = -1;
|
||||
}
|
||||
}
|
||||
|
@ -764,7 +775,9 @@ const char *CClient::LoadMap(const char *pName, const char *pFilename, unsigned
|
|||
// stop demo recording if we loaded a new map
|
||||
m_DemoRecorder.Stop();
|
||||
|
||||
dbg_msg("client", "loaded map '%s'", pFilename);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "loaded map '%s'", pFilename);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", aBuf);
|
||||
m_RecivedSnapshots = 0;
|
||||
|
||||
str_copy(m_aCurrentMap, pName, sizeof(m_aCurrentMap));
|
||||
|
@ -779,7 +792,8 @@ const char *CClient::LoadMapSearch(const char *pMapName, int WantedCrc)
|
|||
{
|
||||
const char *pError = 0;
|
||||
char aBuf[512];
|
||||
dbg_msg("client", "loading map, map=%s wanted crc=%08x", pMapName, WantedCrc);
|
||||
str_format(aBuf, sizeof(aBuf), "loading map, map=%s wanted crc=%08x", pMapName, WantedCrc);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", aBuf);
|
||||
SetState(IClient::STATE_LOADING);
|
||||
|
||||
// try the normal maps folder
|
||||
|
@ -816,9 +830,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
unsigned char *pVersionData = (unsigned char*)pPacket->m_pData + sizeof(VERSIONSRV_VERSION);
|
||||
int VersionMatch = !mem_comp(pVersionData, VERSION_DATA, sizeof(VERSION_DATA));
|
||||
|
||||
dbg_msg("client/version", "version does %s (%d.%d.%d)",
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "version does %s (%d.%d.%d)",
|
||||
VersionMatch ? "match" : "NOT match",
|
||||
pVersionData[1], pVersionData[2], pVersionData[3]);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/version", aBuf);
|
||||
|
||||
// assume version is out of date when version-data doesn't match
|
||||
if (!VersionMatch)
|
||||
|
@ -954,7 +970,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
|
||||
if(!pError)
|
||||
{
|
||||
dbg_msg("client/network", "loading done");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", "loading done");
|
||||
SendReady();
|
||||
GameClient()->OnConnected();
|
||||
}
|
||||
|
@ -962,7 +978,9 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
{
|
||||
str_format(m_aMapdownloadFilename, sizeof(m_aMapdownloadFilename), "downloadedmaps/%s_%08x.map", pMap, MapCrc);
|
||||
|
||||
dbg_msg("client/network", "starting to download map to '%s'", m_aMapdownloadFilename);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "starting to download map to '%s'", m_aMapdownloadFilename);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", aBuf);
|
||||
|
||||
m_MapdownloadChunk = 0;
|
||||
str_copy(m_aMapdownloadName, pMap, sizeof(m_aMapdownloadName));
|
||||
|
@ -976,7 +994,10 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
|
||||
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("client/network", "requested chunk %d", m_MapdownloadChunk);
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "requested chunk %d", m_MapdownloadChunk);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client/network", aBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -999,7 +1020,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
if(Last)
|
||||
{
|
||||
const char *pError;
|
||||
dbg_msg("client/network", "download complete, loading map");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", "download complete, loading map");
|
||||
|
||||
io_close(m_MapdownloadFile);
|
||||
m_MapdownloadFile = 0;
|
||||
|
@ -1010,7 +1031,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
pError = LoadMap(m_aMapdownloadName, m_aMapdownloadFilename, m_MapdownloadCrc);
|
||||
if(!pError)
|
||||
{
|
||||
dbg_msg("client/network", "loading done");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client/network", "loading done");
|
||||
SendReady();
|
||||
GameClient()->OnConnected();
|
||||
}
|
||||
|
@ -1027,7 +1048,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
|
||||
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("client/network", "requested chunk %d", m_MapdownloadChunk);
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "requested chunk %d", m_MapdownloadChunk);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client/network", aBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(Msg == NETMSG_PING)
|
||||
|
@ -1048,7 +1073,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
GameClient()->OnRconLine(pLine);
|
||||
}
|
||||
else if(Msg == NETMSG_PING_REPLY)
|
||||
dbg_msg("client/network", "latency %.2f", (time_get() - m_PingStartTime)*1000 / (float)time_freq());
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "latency %.2f", (time_get() - m_PingStartTime)*1000 / (float)time_freq());
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client/network", aBuf);
|
||||
}
|
||||
else if(Msg == NETMSG_INPUTTIMING)
|
||||
{
|
||||
int InputPredTick = Unpacker.GetInt();
|
||||
|
@ -1143,7 +1172,11 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
// couldn't find the delta snapshots that the server used
|
||||
// to compress this snapshot. force the server to resync
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("client", "error, couldn't find the delta snapshot");
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "error, couldn't find the delta snapshot");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf);
|
||||
}
|
||||
|
||||
// ack snapshot
|
||||
// TODO: combine this with the input message
|
||||
|
@ -1172,7 +1205,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, pTmpBuffer3, pDeltaData, DeltaSize);
|
||||
if(SnapSize < 0)
|
||||
{
|
||||
dbg_msg("client", "delta unpack failed!");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "delta unpack failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1180,8 +1213,10 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
|
|||
{
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
dbg_msg("client", "snapshot crc error #%d - tick=%d wantedcrc=%d gotcrc=%d compressed_size=%d delta_tick=%d",
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "snapshot crc error #%d - tick=%d wantedcrc=%d gotcrc=%d compressed_size=%d delta_tick=%d",
|
||||
m_SnapCrcErrors, GameTick, Crc, pTmpBuffer3->Crc(), CompleteSize, DeltaTick);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf);
|
||||
}
|
||||
|
||||
m_SnapCrcErrors++;
|
||||
|
@ -1273,14 +1308,16 @@ void CClient::PumpNetwork()
|
|||
{
|
||||
SetState(IClient::STATE_OFFLINE);
|
||||
Disconnect();
|
||||
dbg_msg("client", "offline error='%s'", m_NetClient.ErrorString());
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "offline error='%s'", m_NetClient.ErrorString());
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf);
|
||||
}
|
||||
|
||||
//
|
||||
if(State() == IClient::STATE_CONNECTING && m_NetClient.State() == NETSTATE_ONLINE)
|
||||
{
|
||||
// we switched to online
|
||||
dbg_msg("client", "connected, sending info");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", "connected, sending info");
|
||||
SetState(IClient::STATE_LOADING);
|
||||
SendInfo();
|
||||
}
|
||||
|
@ -1434,7 +1471,7 @@ void CClient::Update()
|
|||
|
||||
if(NewPredTick < m_aSnapshots[SNAP_PREV]->m_Tick-SERVER_TICK_SPEED || NewPredTick > m_aSnapshots[SNAP_PREV]->m_Tick+SERVER_TICK_SPEED)
|
||||
{
|
||||
dbg_msg("client", "prediction time reset!");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", "prediction time reset!");
|
||||
m_PredictedTime.Init(m_aSnapshots[SNAP_CURRENT]->m_Tick*time_freq()/50);
|
||||
}
|
||||
|
||||
|
@ -1477,7 +1514,7 @@ void CClient::Update()
|
|||
{
|
||||
if(Now > ActionTaken+time_freq()*2)
|
||||
{
|
||||
dbg_msg("stress", "reconnecting!");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "stress", "reconnecting!");
|
||||
Connect(g_Config.m_DbgStressServer);
|
||||
ActionTaken = Now;
|
||||
}
|
||||
|
@ -1590,7 +1627,9 @@ void CClient::Run()
|
|||
return;
|
||||
|
||||
GameClient()->OnInit();
|
||||
dbg_msg("client", "version %s", GameClient()->NetVersion());
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "version %s", GameClient()->NetVersion());
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf);
|
||||
|
||||
// open socket
|
||||
{
|
||||
|
@ -1836,7 +1875,7 @@ const char *CClient::DemoPlayer_Play(const char *pFilename)
|
|||
// try to start playback
|
||||
m_DemoPlayer.SetListner(this);
|
||||
|
||||
if(m_DemoPlayer.Load(Storage(), pFilename))
|
||||
if(m_DemoPlayer.Load(Storage(), m_pConsole, pFilename))
|
||||
return "error loading demo";
|
||||
|
||||
// load map
|
||||
|
@ -1887,12 +1926,12 @@ void CClient::Con_Play(IConsole::IResult *pResult, void *pUserData)
|
|||
void CClient::DemoRecorder_Start(const char *pFilename)
|
||||
{
|
||||
if(State() != IClient::STATE_ONLINE)
|
||||
dbg_msg("demorec/record", "client is not online");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demorec/record", "client is not online");
|
||||
else
|
||||
{
|
||||
char aFilename[512];
|
||||
str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pFilename);
|
||||
m_DemoRecorder.Start(Storage(), aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_CurrentMapCrc, "client");
|
||||
m_DemoRecorder.Start(Storage(), m_pConsole, aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_CurrentMapCrc, "client");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <engine/graphics.h>
|
||||
#include <engine/storage.h>
|
||||
#include <engine/keys.h>
|
||||
#include <engine/console.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
@ -446,7 +447,9 @@ void CGraphics_OpenGL::ScreenshotDirect(const char *pFilename)
|
|||
io_close(File);
|
||||
|
||||
// save png
|
||||
dbg_msg("client", "saved screenshot to '%s'", aWholePath);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "saved screenshot to '%s'", aWholePath);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf);
|
||||
png_open_file_write(&Png, aWholePath); // ignore_convention
|
||||
png_set_data(&Png, w, h, 8, PNG_TRUECOLOR, (unsigned char *)pPixelData); // ignore_convention
|
||||
png_close_file(&Png); // ignore_convention
|
||||
|
@ -663,6 +666,7 @@ void CGraphics_OpenGL::QuadsText(float x, float y, float Size, float r, float g,
|
|||
bool CGraphics_OpenGL::Init()
|
||||
{
|
||||
m_pStorage = Kernel()->RequestInterface<IStorage>();
|
||||
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
||||
|
||||
// Set all z to -5.0f
|
||||
for(int i = 0; i < MAX_VERTICES; i++)
|
||||
|
|
|
@ -5,6 +5,7 @@ class CGraphics_OpenGL : public IEngineGraphics
|
|||
{
|
||||
protected:
|
||||
class IStorage *m_pStorage;
|
||||
class IConsole *m_pConsole;
|
||||
|
||||
//
|
||||
typedef struct { float x, y, z; } CPoint;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <engine/shared/engine.h>
|
||||
|
||||
#include <engine/masterserver.h>
|
||||
#include <engine/console.h>
|
||||
#include <engine/config.h>
|
||||
|
||||
#include <mastersrv/mastersrv.h>
|
||||
|
@ -62,6 +63,7 @@ void CServerBrowser::SetBaseInfo(class CNetClient *pClient, const char *pNetVers
|
|||
m_pNetClient = pClient;
|
||||
str_copy(m_aNetVersion, pNetVersion, sizeof(m_aNetVersion));
|
||||
m_pMasterServer = Kernel()->RequestInterface<IMasterServer>();
|
||||
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
||||
IConfig *pConfig = Kernel()->RequestInterface<IConfig>();
|
||||
if(pConfig)
|
||||
pConfig->RegisterCallback(ConfigSaveCallback, this);
|
||||
|
@ -514,7 +516,7 @@ void CServerBrowser::Refresh(int Type)
|
|||
}
|
||||
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("client", "broadcasting for servers");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", "broadcasting for servers");
|
||||
}
|
||||
else if(Type == IServerBrowser::TYPE_INTERNET)
|
||||
m_NeedRefresh = 1;
|
||||
|
@ -532,9 +534,11 @@ void CServerBrowser::RequestImpl(const NETADDR &Addr, CServerEntry *pEntry) cons
|
|||
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
dbg_msg("client", "requesting server info from %d.%d.%d.%d:%d",
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf),"requesting server info from %d.%d.%d.%d:%d",
|
||||
Addr.ip[0], Addr.ip[1], Addr.ip[2],
|
||||
Addr.ip[3], Addr.port);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", aBuf);
|
||||
}
|
||||
|
||||
/*mem_copy(buffer, SERVERBROWSE_GETINFO, sizeof(SERVERBROWSE_GETINFO));
|
||||
|
@ -595,7 +599,7 @@ void CServerBrowser::Update()
|
|||
}
|
||||
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("client", "requesting server list");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", "requesting server list");
|
||||
}
|
||||
|
||||
// do timeouts
|
||||
|
@ -676,7 +680,11 @@ void CServerBrowser::AddFavorite(const NETADDR &Addr)
|
|||
pEntry->m_Info.m_Favorite = 1;
|
||||
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("", "added fav, %d.%d.%d.%d:%d", Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port);
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "added fav, %d.%d.%d.%d:%d", Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], Addr.port);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", aBuf);
|
||||
}
|
||||
}
|
||||
|
||||
void CServerBrowser::RemoveFavorite(const NETADDR &Addr)
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
private:
|
||||
CNetClient *m_pNetClient;
|
||||
IMasterServer *m_pMasterServer;
|
||||
class IConsole *m_pConsole;
|
||||
char m_aNetVersion[128];
|
||||
|
||||
CHeap m_ServerlistHeap;
|
||||
|
|
|
@ -8,6 +8,13 @@ class IConsole : public IInterface
|
|||
MACRO_INTERFACE("console", 0)
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
OUTPUT_LEVEL_STANDARD=0,
|
||||
OUTPUT_LEVEL_ADDINFO,
|
||||
OUTPUT_LEVEL_DEBUG
|
||||
};
|
||||
|
||||
// TODO: rework this interface to reduce the amount of virtual calls
|
||||
class IResult
|
||||
{
|
||||
|
@ -51,7 +58,7 @@ public:
|
|||
virtual void ExecuteFile(const char *pFilename) = 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);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <engine/shared/network.h>
|
||||
#include <engine/shared/config.h>
|
||||
#include <engine/shared/engine.h>
|
||||
#include <engine/console.h>
|
||||
#include <engine/masterserver.h>
|
||||
|
||||
#include <mastersrv/mastersrv.h>
|
||||
|
@ -12,6 +13,7 @@ CRegister::CRegister()
|
|||
{
|
||||
m_pNetServer = 0;
|
||||
m_pMasterServer = 0;
|
||||
m_pConsole = 0;
|
||||
|
||||
m_RegisterState = REGISTERSTATE_START;
|
||||
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_pMasterServer = pMasterServer;
|
||||
m_pConsole = pConsole;
|
||||
}
|
||||
|
||||
void CRegister::RegisterUpdate()
|
||||
|
@ -109,7 +112,7 @@ void CRegister::RegisterUpdate()
|
|||
m_RegisterFirst = 1;
|
||||
RegisterNewState(REGISTERSTATE_UPDATE_ADDRS);
|
||||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -176,12 +179,14 @@ void CRegister::RegisterUpdate()
|
|||
m_RegisterRegisteredServer = Best;
|
||||
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);
|
||||
}
|
||||
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;
|
||||
RegisterNewState(REGISTERSTATE_HEARTBEAT);
|
||||
}
|
||||
|
@ -198,14 +203,14 @@ void CRegister::RegisterUpdate()
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if(m_RegisterState == REGISTERSTATE_REGISTERED)
|
||||
{
|
||||
if(m_RegisterFirst)
|
||||
dbg_msg("register", "server registered");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", "server registered");
|
||||
|
||||
m_RegisterFirst = 0;
|
||||
|
||||
|
@ -258,15 +263,17 @@ int CRegister::RegisterProcessPacket(CNetChunk *pPacket)
|
|||
mem_comp(pPacket->m_pData, SERVERBROWSE_FWOK, sizeof(SERVERBROWSE_FWOK)) == 0)
|
||||
{
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
else if(pPacket->m_DataSize == sizeof(SERVERBROWSE_FWERROR) &&
|
||||
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.");
|
||||
dbg_msg("register", "ERROR: configure your firewall/nat to let through udp on port %d.", g_Config.m_SvPort);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "register", "ERROR: the master server reports that clients can not connect to this server.");
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class CRegister
|
|||
|
||||
class CNetServer *m_pNetServer;
|
||||
class IEngineMasterServer *m_pMasterServer;
|
||||
class IConsole *m_pConsole;
|
||||
|
||||
int m_RegisterState;
|
||||
int64 m_RegisterStateStart;
|
||||
|
@ -40,7 +41,7 @@ class CRegister
|
|||
|
||||
public:
|
||||
CRegister();
|
||||
void Init(class CNetServer *pNetServer, class IEngineMasterServer *pMasterServer);
|
||||
void Init(class CNetServer *pNetServer, class IEngineMasterServer *pMasterServer, class IConsole *pConsole);
|
||||
void RegisterUpdate();
|
||||
int RegisterProcessPacket(class CNetChunk *pPacket);
|
||||
};
|
||||
|
|
|
@ -192,7 +192,9 @@ int CServer::TrySetClientName(int ClientID, const char *pName)
|
|||
// trim the name
|
||||
str_copy(aTrimmedName, StrLtrim(pName), sizeof(aTrimmedName));
|
||||
StrRtrim(aTrimmedName);
|
||||
dbg_msg("", "'%s' -> '%s'", pName, aTrimmedName);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' -> '%s'", pName, aTrimmedName);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
|
||||
pName = aTrimmedName;
|
||||
|
||||
|
||||
|
@ -535,10 +537,19 @@ int CServer::NewClientCallback(int ClientId, void *pUser)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CServer::DelClientCallback(int ClientId, void *pUser)
|
||||
int CServer::DelClientCallback(int ClientId, const char *pReason, void *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
|
||||
if(pThis->m_aClients[ClientId].m_State >= CClient::STATE_READY)
|
||||
pThis->GameServer()->OnClientDrop(ClientId);
|
||||
|
@ -670,7 +681,11 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
|||
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientId, true);
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -678,8 +693,10 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
|||
{
|
||||
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, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3]);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
|
||||
m_aClients[ClientId].m_State = CClient::STATE_READY;
|
||||
GameServer()->OnClientConnected(ClientId);
|
||||
}
|
||||
|
@ -690,8 +707,10 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
|||
{
|
||||
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, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3]);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||
m_aClients[ClientId].m_State = CClient::STATE_INGAME;
|
||||
GameServer()->OnClientEnter(ClientId);
|
||||
}
|
||||
|
@ -754,7 +773,9 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
|||
|
||||
if(Unpacker.Error() == 0 && m_aClients[ClientId].m_Authed)
|
||||
{
|
||||
dbg_msg("server", "ClientId=%d rcon='%s'", ClientId, pCmd);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "ClientId=%d rcon='%s'", ClientId, pCmd);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
|
||||
Console()->ExecuteLine(pCmd);
|
||||
}
|
||||
}
|
||||
|
@ -778,7 +799,9 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
|||
|
||||
m_aClients[ClientId].m_Authed = 1;
|
||||
SendRconLine(ClientId, "Authentication successful. Remote console access granted.");
|
||||
dbg_msg("server", "ClientId=%d authed", ClientId);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "ClientId=%d authed", ClientId);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -804,8 +827,10 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
|||
aBuf[b*3+3] = 0;
|
||||
}
|
||||
|
||||
dbg_msg("server", "strange message ClientId=%d msg=%d data_size=%d", ClientId, Msg, pPacket->m_DataSize);
|
||||
dbg_msg("server", "%s", aBuf);
|
||||
char aBufMsg[256];
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -963,7 +988,9 @@ int CServer::LoadMap(const char *pMapName)
|
|||
|
||||
// get the crc of the map
|
||||
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));
|
||||
//map_set(df);
|
||||
|
@ -986,9 +1013,9 @@ void CServer::InitEngine(const char *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()
|
||||
|
@ -1033,10 +1060,13 @@ int CServer::Run()
|
|||
|
||||
m_NetServer.SetCallbacks(NewClientCallback, DelClientCallback, this);
|
||||
|
||||
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();
|
||||
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
|
||||
m_pConsole->StoreCommands(false);
|
||||
|
@ -1050,7 +1080,10 @@ int CServer::Run()
|
|||
m_GameStartTime = time_get();
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -1086,7 +1119,8 @@ int CServer::Run()
|
|||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -1194,7 +1228,7 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1205,10 +1239,12 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser)
|
|||
Addr.port = 0;
|
||||
net_addr_str(&Addr, aAddrStr, sizeof(aAddrStr));
|
||||
|
||||
char aBuf[256];
|
||||
if(Minutes)
|
||||
dbg_msg("server", "banned %s for %d minutes", aAddrStr, Minutes);
|
||||
str_format(aBuf, sizeof(aBuf), "banned %s for %d minutes", aAddrStr, Minutes);
|
||||
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)
|
||||
|
@ -1217,19 +1253,27 @@ void CServer::ConUnban(IConsole::IResult *pResult, void *pUser)
|
|||
CServer *pServer = (CServer *)pUser;
|
||||
const char *pStr = pResult->GetString(0);
|
||||
|
||||
if(net_addr_from_str(&Addr, pStr) == 0)
|
||||
pServer->BanRemove(Addr);
|
||||
if(net_addr_from_str(&Addr, pStr) == 0 && !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))
|
||||
{
|
||||
int BanIndex = str_toint(pStr);
|
||||
CNetServer::CBanInfo Info;
|
||||
if(BanIndex < 0 || !pServer->m_NetServer.BanGet(BanIndex, &Info))
|
||||
dbg_msg("server", "invalid ban index");
|
||||
else
|
||||
pServer->BanRemove(Info.m_Addr);
|
||||
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid ban index");
|
||||
else if(!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
|
||||
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)
|
||||
|
@ -1254,12 +1298,10 @@ void CServer::ConBans(IConsole::IResult *pResult, void *pUser)
|
|||
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);
|
||||
}
|
||||
pServer->Console()->Print(aBuf);
|
||||
dbg_msg("server", "%s", aBuf);
|
||||
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf);
|
||||
}
|
||||
str_format(aBuf, sizeof(aBuf), "%d ban(s)", Num);
|
||||
pServer->Console()->Print(aBuf);
|
||||
dbg_msg("server", "%s", aBuf);
|
||||
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf);
|
||||
}
|
||||
|
||||
void CServer::ConStatus(IConsole::IResult *pResult, void *pUser)
|
||||
|
@ -1281,8 +1323,7 @@ void CServer::ConStatus(IConsole::IResult *pResult, void *pUser)
|
|||
else
|
||||
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);
|
||||
pServer->Console()->Print(aBuf);
|
||||
dbg_msg("server", "%s", aBuf);
|
||||
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1296,7 +1337,7 @@ void CServer::ConRecord(IConsole::IResult *pResult, void *pUser)
|
|||
{
|
||||
char aFilename[512];
|
||||
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)
|
||||
|
@ -1399,7 +1440,7 @@ int main(int argc, const char **argv) // ignore_convention
|
|||
IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); // ignore_convention
|
||||
IConfig *pConfig = CreateConfig();
|
||||
|
||||
pServer->InitRegister(&pServer->m_NetServer, pEngineMasterServer);
|
||||
pServer->InitRegister(&pServer->m_NetServer, pEngineMasterServer, pConsole);
|
||||
|
||||
{
|
||||
bool RegisterFail = false;
|
||||
|
|
|
@ -152,7 +152,7 @@ public:
|
|||
void DoSnapshot();
|
||||
|
||||
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 SendRconLine(int ClientId, const char *pLine);
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
int LoadMap(const char *pMapName);
|
||||
|
||||
void InitEngine(const char *pAppname);
|
||||
void InitRegister(CNetServer *pNetServer, IEngineMasterServer *pMasterServer);
|
||||
void InitRegister(CNetServer *pNetServer, IEngineMasterServer *pMasterServer, IConsole *pConsole);
|
||||
int Run();
|
||||
|
||||
static void ConKick(IConsole::IResult *pResult, void *pUser);
|
||||
|
|
|
@ -10,6 +10,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(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_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(ClEditor, cl_editor, 0, 0, 1, CFGFLAG_CLIENT, "")
|
||||
|
|
|
@ -157,11 +157,15 @@ void CConsole::RegisterPrintCallback(FPrintCallback pfnPrintCallback, void *pUse
|
|||
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);
|
||||
if (m_pfnPrintCallback)
|
||||
m_pfnPrintCallback(pStr, m_pPrintCallbackUserdata);
|
||||
dbg_msg(pFrom ,"%s", pStr);
|
||||
if (Level <= g_Config.m_ConsoleOutputLevel && m_pfnPrintCallback)
|
||||
{
|
||||
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)
|
||||
|
@ -218,7 +222,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr)
|
|||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "Invalid arguments... Usage: %s %s", pCommand->m_pName, pCommand->m_pParams);
|
||||
Print(aBuf);
|
||||
Print(OUTPUT_LEVEL_STANDARD, "Console", aBuf);
|
||||
}
|
||||
else if(m_StoreCommands && pCommand->m_Flags&CFGFLAG_STORE)
|
||||
{
|
||||
|
@ -234,7 +238,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr)
|
|||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "No such command: %s.", pResult->m_pCommand);
|
||||
Print(aBuf);
|
||||
Print(OUTPUT_LEVEL_STANDARD, "Console", aBuf);
|
||||
}
|
||||
|
||||
pStr = pNextPart;
|
||||
|
@ -298,12 +302,14 @@ void CConsole::ExecuteFile(const char *pFilename)
|
|||
// exec the file
|
||||
IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_READ);
|
||||
|
||||
char aBuf[256];
|
||||
if(File)
|
||||
{
|
||||
char *pLine;
|
||||
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);
|
||||
|
||||
while((pLine = lr.Get()))
|
||||
|
@ -312,14 +318,17 @@ void CConsole::ExecuteFile(const char *pFilename)
|
|||
io_close(File);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
void CConsole::Con_Echo(IResult *pResult, void *pUserData)
|
||||
{
|
||||
((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)
|
||||
|
@ -365,7 +374,7 @@ static void IntVariableCommand(IConsole::IResult *pResult, void *pUserData)
|
|||
{
|
||||
char aBuf[1024];
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,7 +388,7 @@ static void StrVariableCommand(IConsole::IResult *pResult, void *pUserData)
|
|||
{
|
||||
char aBuf[1024];
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,7 +475,9 @@ void CConsole::Chain(const char *pName, FChainCommandCallback pfnChainFunc, void
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ public:
|
|||
virtual void ExecuteFile(const char *pFilename);
|
||||
|
||||
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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <base/system.h>
|
||||
#include <engine/console.h>
|
||||
#include <engine/shared/protocol.h>
|
||||
#include <engine/storage.h>
|
||||
#include "demorec.h"
|
||||
|
@ -20,17 +21,20 @@ CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta)
|
|||
//static IOHANDLE m_File = 0;
|
||||
|
||||
// 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;
|
||||
if(m_File)
|
||||
return -1;
|
||||
|
||||
m_pConsole = pConsole;
|
||||
m_File = pStorage->OpenFile(pFilename, IOFLAG_WRITE);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -49,7 +53,9 @@ int CDemoRecorder::Start(class IStorage *pStorage, const char *pFilename, const
|
|||
m_LastKeyFrame = -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;
|
||||
}
|
||||
|
||||
|
@ -193,7 +199,7 @@ int CDemoRecorder::Stop()
|
|||
if(!m_File)
|
||||
return -1;
|
||||
|
||||
dbg_msg("demorec/record", "Stopped recording");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", "Stopped recording");
|
||||
io_close(m_File);
|
||||
m_File = 0;
|
||||
return 0;
|
||||
|
@ -348,7 +354,7 @@ void CDemoPlayer::DoTick()
|
|||
if(ReadChunkHeader(&ChunkType, &ChunkSize, &ChunkTick))
|
||||
{
|
||||
// stop on error or eof
|
||||
dbg_msg("demorec", "end of file");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", "end of file");
|
||||
Pause();
|
||||
break;
|
||||
}
|
||||
|
@ -359,7 +365,7 @@ void CDemoPlayer::DoTick()
|
|||
if(io_read(m_File, aCompresseddata, ChunkSize) != (unsigned)ChunkSize)
|
||||
{
|
||||
// stop on error or eof
|
||||
dbg_msg("demorec", "error reading chunk");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", "error reading chunk");
|
||||
Stop();
|
||||
break;
|
||||
}
|
||||
|
@ -368,7 +374,7 @@ void CDemoPlayer::DoTick()
|
|||
if(DataSize < 0)
|
||||
{
|
||||
// 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();
|
||||
break;
|
||||
}
|
||||
|
@ -377,7 +383,7 @@ void CDemoPlayer::DoTick()
|
|||
|
||||
if(DataSize < 0)
|
||||
{
|
||||
dbg_msg("demorec", "error during intpack decompression");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", "error during intpack decompression");
|
||||
Stop();
|
||||
break;
|
||||
}
|
||||
|
@ -401,7 +407,11 @@ void CDemoPlayer::DoTick()
|
|||
mem_copy(m_aLastSnapshotData, aNewsnap, DataSize);
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
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);
|
||||
m_File = 0;
|
||||
return -1;
|
||||
|
@ -599,8 +614,10 @@ int CDemoPlayer::Update()
|
|||
if(m_Info.m_Info.m_CurrentTick == m_Info.m_PreviousTick ||
|
||||
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_pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "demo_player", aBuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -612,7 +629,7 @@ int CDemoPlayer::Stop()
|
|||
if(!m_File)
|
||||
return -1;
|
||||
|
||||
dbg_msg("demorec/playback", "Stopped playback");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_player", "Stopped playback");
|
||||
io_close(m_File);
|
||||
m_File = 0;
|
||||
mem_free(m_pKeyFrames);
|
||||
|
|
|
@ -15,6 +15,7 @@ struct CDemoHeader
|
|||
|
||||
class CDemoRecorder : public IDemoRecorder
|
||||
{
|
||||
class IConsole *m_pConsole;
|
||||
IOHANDLE m_File;
|
||||
int m_LastTickMarker;
|
||||
int m_LastKeyFrame;
|
||||
|
@ -26,7 +27,7 @@ class CDemoRecorder : public IDemoRecorder
|
|||
public:
|
||||
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();
|
||||
|
||||
void RecordSnapshot(int Tick, const void *pData, int Size);
|
||||
|
@ -80,6 +81,7 @@ private:
|
|||
CKeyFrameSearch *m_pNext;
|
||||
};
|
||||
|
||||
class IConsole *m_pConsole;
|
||||
IOHANDLE m_File;
|
||||
CKeyFrame *m_pKeyFrames;
|
||||
|
||||
|
@ -99,7 +101,7 @@ public:
|
|||
|
||||
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();
|
||||
void Pause();
|
||||
void Unpause();
|
||||
|
|
|
@ -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);
|
||||
|
||||
struct CNetChunk
|
||||
|
|
|
@ -21,7 +21,7 @@ int CNetClient::Close()
|
|||
|
||||
int CNetClient::Disconnect(const char *pReason)
|
||||
{
|
||||
dbg_msg("netclient", "disconnected. reason=\"%s\"", pReason);
|
||||
//dbg_msg("netclient", "disconnected. reason=\"%s\"", pReason);
|
||||
m_Connection.Disconnect(pReason);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -79,16 +79,15 @@ int CNetServer::Drop(int ClientID, const char *pReason)
|
|||
// TODO: insert lots of checks here
|
||||
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,
|
||||
Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3],
|
||||
pReason
|
||||
);
|
||||
);*/
|
||||
if(m_pfnDelClient)
|
||||
m_pfnDelClient(ClientID, pReason, m_UserPtr);
|
||||
|
||||
m_aSlots[ClientID].m_Connection.Disconnect(pReason);
|
||||
|
||||
if(m_pfnDelClient)
|
||||
m_pfnDelClient(ClientID, m_UserPtr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -30,10 +30,12 @@ void CBinds::Bind(int KeyId, const char *pStr)
|
|||
return;
|
||||
|
||||
str_copy(m_aaKeyBindings[KeyId], pStr, sizeof(m_aaKeyBindings[KeyId]));
|
||||
char aBuf[256];
|
||||
if(!m_aaKeyBindings[KeyId][0])
|
||||
dbg_msg("binds", "unbound %s (%d)", Input()->KeyName(KeyId), KeyId);
|
||||
str_format(aBuf, sizeof(aBuf), "unbound %s (%d)", Input()->KeyName(KeyId), KeyId);
|
||||
else
|
||||
dbg_msg("binds", "bound %s (%d) = %s", Input()->KeyName(KeyId), KeyId, m_aaKeyBindings[KeyId]);
|
||||
str_format(aBuf, sizeof(aBuf), "bound %s (%d) = %s", Input()->KeyName(KeyId), KeyId, m_aaKeyBindings[KeyId]);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf);
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,7 +138,9 @@ void CBinds::ConBind(IConsole::IResult *pResult, void *pUserData)
|
|||
|
||||
if(!id)
|
||||
{
|
||||
dbg_msg("binds", "key %s not found", pKeyName);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "key %s not found", pKeyName);
|
||||
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -152,7 +156,9 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData)
|
|||
|
||||
if(!id)
|
||||
{
|
||||
dbg_msg("binds", "key %s not found", pKeyName);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "key %s not found", pKeyName);
|
||||
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -175,8 +181,8 @@ void CBinds::ConDumpBinds(IConsole::IResult *pResult, void *pUserData)
|
|||
{
|
||||
if(pBinds->m_aaKeyBindings[i][0] == 0)
|
||||
continue;
|
||||
str_format(aBuf, sizeof(aBuf), "[binds] %s (%d) = %s", pBinds->Input()->KeyName(i), i, pBinds->m_aaKeyBindings[i]);
|
||||
pBinds->Console()->Print(aBuf);
|
||||
str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pBinds->Input()->KeyName(i), i, pBinds->m_aaKeyBindings[i]);
|
||||
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void CChat::ConChat(IConsole::IResult *pResult, void *pUserData)
|
|||
else if(str_comp(pMode, "team") == 0)
|
||||
((CChat*)pUserData)->EnableMode(1);
|
||||
else
|
||||
dbg_msg("console", "expected all or team as mode");
|
||||
((CChat*)pUserData)->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", "expected all or team as mode");
|
||||
}
|
||||
|
||||
void CChat::ConShowChat(IConsole::IResult *pResult, void *pUserData)
|
||||
|
@ -165,8 +165,8 @@ void CChat::AddLine(int ClientId, int Team, const char *pLine)
|
|||
}
|
||||
|
||||
char aBuf[1024];
|
||||
str_format(aBuf, sizeof(aBuf), "[chat]%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText);
|
||||
Console()->Print(aBuf);
|
||||
str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat", aBuf);
|
||||
}
|
||||
|
||||
// play sound
|
||||
|
|
|
@ -699,7 +699,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
|
|||
static int s_JoinButton = 0;
|
||||
if(DoButton_Menu(&s_JoinButton, Localize("Connect"), 0, &Button) || m_EnterPressed)
|
||||
{
|
||||
dbg_msg("", "%s", g_Config.m_UiServerAddress);
|
||||
//dbg_msg("", "%s", g_Config.m_UiServerAddress);
|
||||
Client()->Connect(g_Config.m_UiServerAddress);
|
||||
m_EnterPressed = false;
|
||||
}
|
||||
|
|
|
@ -706,7 +706,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
if(OldSelected != s_SelectedLanguage)
|
||||
{
|
||||
str_copy(g_Config.m_ClLanguagefile, s_Languages[s_SelectedLanguage].m_FileName, sizeof(g_Config.m_ClLanguagefile));
|
||||
g_Localization.Load(s_Languages[s_SelectedLanguage].m_FileName);
|
||||
g_Localization.Load(s_Languages[s_SelectedLanguage].m_FileName, Console());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser)
|
|||
CImageInfo Info;
|
||||
if(!pSelf->Graphics()->LoadPNG(&Info, aBuf))
|
||||
{
|
||||
dbg_msg("game", "failed to load skin from %s", pName);
|
||||
str_format(aBuf, sizeof(aBuf), "failed to load skin from %s", pName);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -111,7 +112,8 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser)
|
|||
|
||||
// set skin data
|
||||
str_copy(pSelf->m_aSkins[pSelf->m_NumSkins].m_aName, pName, min((int)sizeof(pSelf->m_aSkins[pSelf->m_NumSkins].m_aName),l-3));
|
||||
dbg_msg("game", "load skin %s", pSelf->m_aSkins[pSelf->m_NumSkins].m_aName);
|
||||
str_format(aBuf, sizeof(aBuf), "load skin %s", pSelf->m_aSkins[pSelf->m_NumSkins].m_aName);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
|
||||
pSelf->m_NumSkins++;
|
||||
}
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ void CGameClient::OnInit()
|
|||
//m_pServerBrowser = Kernel()->RequestInterface<IServerBrowser>();
|
||||
|
||||
// set the language
|
||||
g_Localization.Load(g_Config.m_ClLanguagefile);
|
||||
g_Localization.Load(g_Config.m_ClLanguagefile, Console());
|
||||
|
||||
// init all components
|
||||
for(int i = 0; i < m_All.m_Num; i++)
|
||||
|
@ -288,7 +288,9 @@ void CGameClient::OnInit()
|
|||
m_All.m_paComponents[i]->OnReset();
|
||||
|
||||
int64 End = time_get();
|
||||
dbg_msg("", "%f.2ms", ((End-Start)*1000)/(float)time_freq());
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "initialisation finished after %f.2ms", ((End-Start)*1000)/(float)time_freq());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "gameclient", aBuf);
|
||||
|
||||
m_ServerMode = SERVERMODE_PURE;
|
||||
}
|
||||
|
@ -517,7 +519,9 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker);
|
||||
if(!pRawMsg)
|
||||
{
|
||||
dbg_msg("client", "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn());
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", aBuf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -635,7 +639,11 @@ void CGameClient::OnNewSnapshot()
|
|||
if(m_NetObjHandler.ValidateObj(Item.m_Type, pData, Item.m_DataSize) != 0)
|
||||
{
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("game", "invalidated index=%d type=%d (%s) size=%d id=%d", Index, Item.m_Type, m_NetObjHandler.GetObjName(Item.m_Type), Item.m_DataSize, Item.m_Id);
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "invalidated index=%d type=%d (%s) size=%d id=%d", Index, Item.m_Type, m_NetObjHandler.GetObjName(Item.m_Type), Item.m_DataSize, Item.m_Id);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
}
|
||||
Client()->SnapInvalidateItem(IClient::SNAP_CURRENT, Index);
|
||||
}
|
||||
}
|
||||
|
@ -904,11 +912,13 @@ void CGameClient::OnPredict()
|
|||
|
||||
if(mem_comp(&Before, &Now, sizeof(CNetObj_CharacterCore)) != 0)
|
||||
{
|
||||
dbg_msg("client", "prediction error");
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "prediction error");
|
||||
for(unsigned i = 0; i < sizeof(CNetObj_CharacterCore)/sizeof(int); i++)
|
||||
if(((int *)&Before)[i] != ((int *)&Now)[i])
|
||||
{
|
||||
dbg_msg("", "\t%d %d %d (%d %d)", i, ((int *)&Before)[i], ((int *)&Now)[i], ((int *)&BeforePrev)[i], ((int *)&NowPrev)[i]);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), " %d %d %d (%d %d)", i, ((int *)&Before)[i], ((int *)&Now)[i], ((int *)&BeforePrev)[i], ((int *)&NowPrev)[i]);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", aBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <engine/shared/config.h>
|
||||
#include <engine/shared/engine.h>
|
||||
#include <engine/client.h>
|
||||
#include <engine/console.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <engine/input.h>
|
||||
|
@ -1271,7 +1272,9 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
|
|||
if(!UI()->MouseButton(0))
|
||||
{
|
||||
// grab brush
|
||||
dbg_msg("editor", "grabbing %f %f %f %f", r.x, r.y, r.w, r.h);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf),"grabbing %f %f %f %f", r.x, r.y, r.w, r.h);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "editor", aBuf);
|
||||
|
||||
// TODO: do all layers
|
||||
int Grabs = 0;
|
||||
|
@ -1820,7 +1823,7 @@ static void ExtractName(const char *pFileName, char *pName)
|
|||
int FinalLen = End-Start;
|
||||
mem_copy(pName, &pFileName[Start], FinalLen);
|
||||
pName[FinalLen] = 0;
|
||||
dbg_msg("", "%s %s %d %d", pFileName, pName, Start, End);
|
||||
//dbg_msg("", "%s %s %d %d", pFileName, pName, Start, End);
|
||||
}
|
||||
|
||||
void CEditor::ReplaceImage(const char *pFileName, void *pUser)
|
||||
|
@ -3006,6 +3009,7 @@ void CEditor::Init()
|
|||
{
|
||||
m_pInput = Kernel()->RequestInterface<IInput>();
|
||||
m_pClient = Kernel()->RequestInterface<IClient>();
|
||||
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
||||
m_pGraphics = Kernel()->RequestInterface<IGraphics>();
|
||||
m_pTextRender = Kernel()->RequestInterface<ITextRender>();
|
||||
m_RenderTools.m_pGraphics = m_pGraphics;
|
||||
|
|
|
@ -427,6 +427,7 @@ class CEditor : public IEditor
|
|||
{
|
||||
class IInput *m_pInput;
|
||||
class IClient *m_pClient;
|
||||
class IConsole *m_pConsole;
|
||||
class IGraphics *m_pGraphics;
|
||||
class ITextRender *m_pTextRender;
|
||||
CRenderTools m_RenderTools;
|
||||
|
@ -434,6 +435,7 @@ class CEditor : public IEditor
|
|||
public:
|
||||
class IInput *Input() { return m_pInput; };
|
||||
class IClient *Client() { return m_pClient; };
|
||||
class IConsole *Console() { return m_pConsole; };
|
||||
class IGraphics *Graphics() { return m_pGraphics; };
|
||||
class ITextRender *TextRender() { return m_pTextRender; };
|
||||
CUI *UI() { return &m_UI; }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <engine/console.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/storage.h>
|
||||
#include <game/gamecore.h>
|
||||
|
@ -197,11 +198,14 @@ int CEditor::Save(const char *pFilename)
|
|||
|
||||
int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
||||
{
|
||||
dbg_msg("editor", "saving to '%s'...", pFileName);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "saving to '%s'...", pFileName);
|
||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "editor", aBuf);
|
||||
CDataFileWriter df;
|
||||
if(!df.Open(pStorage, pFileName))
|
||||
{
|
||||
dbg_msg("editor", "failed to open file '%s'...", pFileName);
|
||||
str_format(aBuf, sizeof(aBuf), "failed to open file '%s'...", pFileName);
|
||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "editor", aBuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -259,7 +263,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
{
|
||||
if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_TILES)
|
||||
{
|
||||
dbg_msg("editor", "saving tiles layer");
|
||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving tiles layer");
|
||||
CLayerTiles *pLayer = (CLayerTiles *)pGroup->m_lLayers[l];
|
||||
pLayer->PrepareForSave();
|
||||
|
||||
|
@ -288,7 +292,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
}
|
||||
else if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_QUADS)
|
||||
{
|
||||
dbg_msg("editor", "saving quads layer");
|
||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving quads layer");
|
||||
CLayerQuads *pLayer = (CLayerQuads *)pGroup->m_lLayers[l];
|
||||
if(pLayer->m_lQuads.size())
|
||||
{
|
||||
|
@ -346,7 +350,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName)
|
|||
|
||||
// finish the data file
|
||||
df.Finish();
|
||||
dbg_msg("editor", "done");
|
||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving done");
|
||||
|
||||
// send rcon.. if we can
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <base/math.h>
|
||||
|
||||
#include <engine/console.h>
|
||||
#include <engine/graphics.h>
|
||||
|
||||
#include "ed_editor.h"
|
||||
|
@ -124,7 +125,7 @@ int CLayerQuads::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
|
||||
if(px > Rect.x && px < Rect.x+Rect.w && py > Rect.y && py < Rect.y+Rect.h)
|
||||
{
|
||||
dbg_msg("", "grabbed one");
|
||||
m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "editor", "grabbed one");
|
||||
CQuad n;
|
||||
n = *q;
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <engine/console.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/input.h>
|
||||
#include <engine/keys.h>
|
||||
|
@ -19,7 +20,7 @@ static int g_UiNumPopups = 0;
|
|||
|
||||
void CEditor::UiInvokePopupMenu(void *Id, int Flags, float x, float y, float w, float h, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect), void *pExtra)
|
||||
{
|
||||
dbg_msg("", "invoked");
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "editor", "invoked");
|
||||
if(x + w > UI()->Screen()->w)
|
||||
x -= w;
|
||||
if(y + h > UI()->Screen()->h)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <base/tl/algorithm.h>
|
||||
|
||||
#include <engine/shared/linereader.h>
|
||||
#include <engine/console.h>
|
||||
|
||||
const char *Localize(const char *pStr)
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ void CLocalizationDatabase::AddString(const char *pOrgStr, const char *pNewStr)
|
|||
m_Strings.add(s);
|
||||
}
|
||||
|
||||
bool CLocalizationDatabase::Load(const char *pFilename)
|
||||
bool CLocalizationDatabase::Load(const char *pFilename, IConsole *pConsole)
|
||||
{
|
||||
// empty string means unload
|
||||
if(pFilename[0] == 0)
|
||||
|
@ -53,7 +54,9 @@ bool CLocalizationDatabase::Load(const char *pFilename)
|
|||
if(!IoHandle)
|
||||
return false;
|
||||
|
||||
dbg_msg("localization", "loaded '%s'", pFilename);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "loaded '%s'", pFilename);
|
||||
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf);
|
||||
m_Strings.clear();
|
||||
|
||||
CLineReader LineReader;
|
||||
|
@ -70,13 +73,14 @@ bool CLocalizationDatabase::Load(const char *pFilename)
|
|||
char *pReplacement = LineReader.Get();
|
||||
if(!pReplacement)
|
||||
{
|
||||
dbg_msg("", "unexpected end of file");
|
||||
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", "unexpected end of file");
|
||||
break;
|
||||
}
|
||||
|
||||
if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ')
|
||||
{
|
||||
dbg_msg("", "malform replacement line for '%s'", pLine);
|
||||
str_format(aBuf, sizeof(aBuf), "malform replacement line for '%s'", pLine);
|
||||
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class CLocalizationDatabase
|
|||
public:
|
||||
CLocalizationDatabase();
|
||||
|
||||
bool Load(const char *pFilename);
|
||||
bool Load(const char *pFilename, class IConsole *pConsole);
|
||||
|
||||
int Version() { return m_CurrentVersion; }
|
||||
|
||||
|
|
|
@ -604,7 +604,8 @@ void CCharacter::TickDefered()
|
|||
StartVelX.f = StartVel.x;
|
||||
StartVelY.f = StartVel.y;
|
||||
|
||||
dbg_msg("char_core", "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x",
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x",
|
||||
StuckBefore,
|
||||
StuckAfterMove,
|
||||
StuckAfterQuant,
|
||||
|
@ -612,6 +613,7 @@ void CCharacter::TickDefered()
|
|||
StartVel.x, StartVel.y,
|
||||
StartPosX.u, StartPosY.u,
|
||||
StartVelX.u, StartVelY.u);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
}
|
||||
|
||||
int Events = m_Core.m_TriggeredEvents;
|
||||
|
@ -669,9 +671,11 @@ void CCharacter::Die(int Killer, int Weapon)
|
|||
{
|
||||
int ModeSpecial = GameServer()->m_pController->OnCharacterDeath(this, GameServer()->m_apPlayers[Killer], Weapon);
|
||||
|
||||
dbg_msg("game", "kill killer='%d:%s' victim='%d:%s' weapon=%d special=%d",
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "kill killer='%d:%s' victim='%d:%s' weapon=%d special=%d",
|
||||
Killer, Server()->ClientName(Killer),
|
||||
m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
|
||||
// send the kill message
|
||||
CNetMsg_Sv_KillMsg Msg;
|
||||
|
|
|
@ -109,8 +109,10 @@ void CPickup::Tick()
|
|||
|
||||
if(RespawnTime >= 0)
|
||||
{
|
||||
dbg_msg("game", "pickup player='%d:%s' item=%d/%d",
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "pickup player='%d:%s' item=%d/%d",
|
||||
pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,10 +215,12 @@ void CGameContext::SendChatTarget(int To, const char *pText)
|
|||
|
||||
void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText)
|
||||
{
|
||||
char aBuf[256];
|
||||
if(ChatterClientId >= 0 && ChatterClientId < MAX_CLIENTS)
|
||||
dbg_msg("chat", "%d:%d:%s: %s", ChatterClientId, Team, Server()->ClientName(ChatterClientId), pText);
|
||||
str_format(aBuf, sizeof(aBuf), "%d:%d:%s: %s", ChatterClientId, Team, Server()->ClientName(ChatterClientId), pText);
|
||||
else
|
||||
dbg_msg("chat", "*** %s", pText);
|
||||
str_format(aBuf, sizeof(aBuf), "*** %s", pText);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "chat", aBuf);
|
||||
|
||||
if(Team == CHAT_ALL)
|
||||
{
|
||||
|
@ -353,7 +355,7 @@ void CGameContext::CheckPureTuning()
|
|||
CTuningParams p;
|
||||
if(mem_comp(&p, &m_Tuning, sizeof(p)) != 0)
|
||||
{
|
||||
dbg_msg("server", "resetting tuning due to pure server");
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "resetting tuning due to pure server");
|
||||
m_Tuning = p;
|
||||
}
|
||||
}
|
||||
|
@ -496,14 +498,12 @@ void CGameContext::OnClientEnter(int ClientId)
|
|||
{
|
||||
//world.insert_entity(&players[client_id]);
|
||||
m_apPlayers[ClientId]->Respawn();
|
||||
dbg_msg("game", "join player='%d:%s'", ClientId, Server()->ClientName(ClientId));
|
||||
|
||||
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "%s entered and joined the %s", Server()->ClientName(ClientId), m_pController->GetTeamName(m_apPlayers[ClientId]->GetTeam()));
|
||||
SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
|
||||
dbg_msg("game", "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), m_apPlayers[ClientId]->GetTeam());
|
||||
str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), m_apPlayers[ClientId]->GetTeam());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
|
||||
m_VoteUpdate = true;
|
||||
}
|
||||
|
@ -555,7 +555,9 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
|
||||
if(!pRawMsg)
|
||||
{
|
||||
dbg_msg("server", "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn());
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -813,13 +815,15 @@ void CGameContext::ConTuneParam(IConsole::IResult *pResult, void *pUserData)
|
|||
const char *pParamName = pResult->GetString(0);
|
||||
float NewValue = pResult->GetFloat(1);
|
||||
|
||||
char aBuf[256];
|
||||
if(pSelf->Tuning()->Set(pParamName, NewValue))
|
||||
{
|
||||
dbg_msg("tuning", "%s changed to %.2f", pParamName, NewValue);
|
||||
str_format(aBuf, sizeof(aBuf), "%s changed to %.2f", pParamName, NewValue);
|
||||
pSelf->SendTuningParams(-1);
|
||||
}
|
||||
else
|
||||
dbg_msg("tuning", "No such tuning parameter");
|
||||
str_format(aBuf, sizeof(aBuf), "No such tuning parameter");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", aBuf);
|
||||
}
|
||||
|
||||
void CGameContext::ConTuneReset(IConsole::IResult *pResult, void *pUserData)
|
||||
|
@ -828,17 +832,19 @@ void CGameContext::ConTuneReset(IConsole::IResult *pResult, void *pUserData)
|
|||
CTuningParams p;
|
||||
*pSelf->Tuning() = p;
|
||||
pSelf->SendTuningParams(-1);
|
||||
dbg_msg("tuning", "Tuning reset");
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", "Tuning reset");
|
||||
}
|
||||
|
||||
void CGameContext::ConTuneDump(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
char aBuf[256];
|
||||
for(int i = 0; i < pSelf->Tuning()->Num(); i++)
|
||||
{
|
||||
float v;
|
||||
pSelf->Tuning()->Get(i, &v);
|
||||
dbg_msg("tuning", "%s %.2f", pSelf->Tuning()->m_apNames[i], v);
|
||||
str_format(aBuf, sizeof(aBuf), "%s %.2f", pSelf->Tuning()->m_apNames[i], v);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", aBuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -875,7 +881,9 @@ void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
int ClientId = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||
int Team = clamp(pResult->GetInteger(1), -1, 1);
|
||||
|
||||
dbg_msg("", "%d %d", ClientId, Team);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "moved client %d to team %d", ClientId, Team);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||
|
||||
if(!pSelf->m_apPlayers[ClientId])
|
||||
return;
|
||||
|
@ -899,7 +907,9 @@ void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->m_pVoteOptionFirst = pOption;
|
||||
|
||||
mem_copy(pOption->m_aCommand, pResult->GetString(0), Len+1);
|
||||
dbg_msg("server", "added option '%s'", pOption->m_aCommand);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "added option '%s'", pOption->m_aCommand);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||
|
||||
CNetMsg_Sv_VoteOption OptionMsg;
|
||||
OptionMsg.m_pCommand = pOption->m_aCommand;
|
||||
|
@ -913,7 +923,9 @@ void CGameContext::ConVote(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_YES;
|
||||
else if(str_comp_nocase(pResult->GetString(0), "no") == 0)
|
||||
pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO;
|
||||
dbg_msg("server", "forcing vote %s", pResult->GetString(0));
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "forcing vote %s", pResult->GetString(0));
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||
}
|
||||
|
||||
void CGameContext::ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||
|
|
|
@ -200,7 +200,9 @@ void IGameController::StartRound()
|
|||
m_aTeamscore[0] = 0;
|
||||
m_aTeamscore[1] = 0;
|
||||
m_ForceBalanced = false;
|
||||
dbg_msg("game","start round type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "start round type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
}
|
||||
|
||||
void IGameController::ChangeMap(const char *pToMap)
|
||||
|
@ -213,7 +215,9 @@ void IGameController::CycleMap()
|
|||
{
|
||||
if(m_aMapWish[0] != 0)
|
||||
{
|
||||
dbg_msg("game", "rotating map to %s", m_aMapWish);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "rotating map to %s", m_aMapWish);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
str_copy(g_Config.m_SvMap, m_aMapWish, sizeof(g_Config.m_SvMap));
|
||||
m_aMapWish[0] = 0;
|
||||
m_RoundCount = 0;
|
||||
|
@ -255,26 +259,28 @@ void IGameController::CycleMap()
|
|||
pNextMap = pMapRotation;
|
||||
|
||||
// cut out the next map
|
||||
char Buf[512];
|
||||
char aBuf[512];
|
||||
for(int i = 0; i < 512; i++)
|
||||
{
|
||||
Buf[i] = pNextMap[i];
|
||||
aBuf[i] = pNextMap[i];
|
||||
if(IsSeparator(pNextMap[i]) || pNextMap[i] == 0)
|
||||
{
|
||||
Buf[i] = 0;
|
||||
aBuf[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// skip spaces
|
||||
int i = 0;
|
||||
while(IsSeparator(Buf[i]))
|
||||
while(IsSeparator(aBuf[i]))
|
||||
i++;
|
||||
|
||||
m_RoundCount = 0;
|
||||
|
||||
dbg_msg("game", "rotating map to %s", &Buf[i]);
|
||||
str_copy(g_Config.m_SvMap, &Buf[i], sizeof(g_Config.m_SvMap));
|
||||
char aBufMsg[256];
|
||||
str_format(aBufMsg, sizeof(aBufMsg), "rotating map to %s", &aBuf[i]);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
str_copy(g_Config.m_SvMap, &aBuf[i], sizeof(g_Config.m_SvMap));
|
||||
}
|
||||
|
||||
void IGameController::PostReset()
|
||||
|
@ -398,7 +404,7 @@ void IGameController::Tick()
|
|||
// do team-balancing
|
||||
if (IsTeamplay() && m_UnbalancedTick != -1 && Server()->Tick() > m_UnbalancedTick+g_Config.m_SvTeambalanceTime*Server()->TickSpeed()*60)
|
||||
{
|
||||
dbg_msg("game", "Balancing teams");
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", "Balancing teams");
|
||||
|
||||
int aT[2] = {0,0};
|
||||
float aTScore[2] = {0,0};
|
||||
|
@ -570,16 +576,19 @@ bool IGameController::CheckTeamBalance()
|
|||
aT[pP->GetTeam()]++;
|
||||
}
|
||||
|
||||
char aBuf[256];
|
||||
if(absolute(aT[0]-aT[1]) >= 2)
|
||||
{
|
||||
dbg_msg("game", "Team is NOT balanced (red=%d blue=%d)", aT[0], aT[1]);
|
||||
str_format(aBuf, sizeof(aBuf), "Team is NOT balanced (red=%d blue=%d)", aT[0], aT[1]);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
if(GameServer()->m_pController->m_UnbalancedTick == -1)
|
||||
GameServer()->m_pController->m_UnbalancedTick = Server()->Tick();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_msg("game", "Team is balanced (red=%d blue=%d)", aT[0], aT[1]);
|
||||
str_format(aBuf, sizeof(aBuf), "Team is balanced (red=%d blue=%d)", aT[0], aT[1]);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
GameServer()->m_pController->m_UnbalancedTick = -1;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -111,21 +111,22 @@ void CGameControllerCTF::Tick()
|
|||
m_aTeamscore[fi^1] += 100;
|
||||
F->m_pCarryingCharacter->GetPlayer()->m_Score += 5;
|
||||
|
||||
dbg_msg("game", "flag_capture player='%d:%s'",
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "flag_capture player='%d:%s'",
|
||||
F->m_pCarryingCharacter->GetPlayer()->GetCID(),
|
||||
Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()));
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
|
||||
char Buf[512];
|
||||
float CaptureTime = (Server()->Tick() - F->m_GrabTick)/(float)Server()->TickSpeed();
|
||||
if(CaptureTime <= 60)
|
||||
{
|
||||
str_format(Buf, sizeof(Buf), "The %s flag was captured by %s (%d.%s%d seconds)", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()), (int)CaptureTime%60, ((int)(CaptureTime*100)%100)<10?"0":"", (int)(CaptureTime*100)%100);
|
||||
str_format(aBuf, sizeof(aBuf), "The %s flag was captured by %s (%d.%s%d seconds)", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()), (int)CaptureTime%60, ((int)(CaptureTime*100)%100)<10?"0":"", (int)(CaptureTime*100)%100);
|
||||
}
|
||||
else
|
||||
{
|
||||
str_format(Buf, sizeof(Buf), "The %s flag was captured by %s", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()));
|
||||
str_format(aBuf, sizeof(aBuf), "The %s flag was captured by %s", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()));
|
||||
}
|
||||
GameServer()->SendChat(-1, -2, Buf);
|
||||
GameServer()->SendChat(-1, -2, aBuf);
|
||||
for(int i = 0; i < 2; i++)
|
||||
m_apFlags[i]->Reset();
|
||||
|
||||
|
@ -150,9 +151,11 @@ void CGameControllerCTF::Tick()
|
|||
CCharacter *pChr = apCloseCCharacters[i];
|
||||
pChr->GetPlayer()->m_Score += 1;
|
||||
|
||||
dbg_msg("game", "flag_return player='%d:%s'",
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "flag_return player='%d:%s'",
|
||||
pChr->GetPlayer()->GetCID(),
|
||||
Server()->ClientName(pChr->GetPlayer()->GetCID()));
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
|
||||
GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN);
|
||||
F->Reset();
|
||||
|
@ -171,9 +174,11 @@ void CGameControllerCTF::Tick()
|
|||
F->m_pCarryingCharacter = apCloseCCharacters[i];
|
||||
F->m_pCarryingCharacter->GetPlayer()->m_Score += 1;
|
||||
|
||||
dbg_msg("game", "flag_grab player='%d:%s'",
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "flag_grab player='%d:%s'",
|
||||
F->m_pCarryingCharacter->GetPlayer()->GetCID(),
|
||||
Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()));
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
|
||||
for(int c = 0; c < MAX_CLIENTS; c++)
|
||||
{
|
||||
|
|
|
@ -95,11 +95,12 @@ void CPlayer::OnDisconnect()
|
|||
|
||||
if(Server()->ClientIngame(m_ClientID))
|
||||
{
|
||||
char Buf[512];
|
||||
str_format(Buf, sizeof(Buf), "%s has left the game", Server()->ClientName(m_ClientID));
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, Buf);
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "%s has left the game", Server()->ClientName(m_ClientID));
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
|
||||
dbg_msg("game", "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID));
|
||||
str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID));
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,16 +152,17 @@ void CPlayer::SetTeam(int Team)
|
|||
if(m_Team == Team)
|
||||
return;
|
||||
|
||||
char Buf[512];
|
||||
str_format(Buf, sizeof(Buf), "%s joined the %s", Server()->ClientName(m_ClientID), GameServer()->m_pController->GetTeamName(Team));
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, Buf);
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "%s joined the %s", Server()->ClientName(m_ClientID), GameServer()->m_pController->GetTeamName(Team));
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
|
||||
KillCharacter();
|
||||
|
||||
m_Team = Team;
|
||||
// we got to wait 0.5 secs before respawning
|
||||
m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2;
|
||||
dbg_msg("game", "team_join player='%d:%s' m_Team=%d", m_ClientID, Server()->ClientName(m_ClientID), m_Team);
|
||||
str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' m_Team=%d", m_ClientID, Server()->ClientName(m_ClientID), m_Team);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
|
||||
GameServer()->m_pController->OnPlayerInfoChange(GameServer()->m_apPlayers[m_ClientID]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue