Merge pull request #3 from ddnet/master

Merge
This commit is contained in:
houseme-kyle 2021-03-11 08:48:56 +02:00 committed by GitHub
commit 877bd9afbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 165 additions and 103 deletions

View file

@ -77,6 +77,9 @@
#undef main #undef main
#endif #endif
static const ColorRGBA ClientNetworkPrintColor{0.7f, 1, 0.7f, 1.0f};
static const ColorRGBA ClientNetworkErrPrintColor{1.0f, 0.25f, 0.25f, 1.0f};
void CGraph::Init(float Min, float Max) void CGraph::Init(float Min, float Max)
{ {
m_Min = Min; m_Min = Min;
@ -709,7 +712,7 @@ void CClient::Connect(const char *pAddress, const char *pPassword)
str_copy(m_aServerAddressStr, pAddress, sizeof(m_aServerAddressStr)); str_copy(m_aServerAddressStr, pAddress, sizeof(m_aServerAddressStr));
str_format(aBuf, sizeof(aBuf), "connecting to '%s'", m_aServerAddressStr); str_format(aBuf, sizeof(aBuf), "connecting to '%s'", m_aServerAddressStr);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ClientNetworkPrintColor);
bool is_websocket = false; bool is_websocket = false;
if(strncmp(m_aServerAddressStr, "ws://", 5) == 0) if(strncmp(m_aServerAddressStr, "ws://", 5) == 0)
{ {
@ -764,7 +767,7 @@ void CClient::DisconnectWithReason(const char *pReason)
{ {
char aBuf[512]; char aBuf[512];
str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason ? pReason : "unknown"); str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason ? pReason : "unknown");
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ClientNetworkPrintColor);
// stop demo playback and recorder // stop demo playback and recorder
m_DemoPlayer.Stop(); m_DemoPlayer.Stop();
@ -2564,7 +2567,7 @@ void CClient::PumpNetwork()
Disconnect(); Disconnect();
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "offline error='%s'", m_NetClient[CLIENT_MAIN].ErrorString()); str_format(aBuf, sizeof(aBuf), "offline error='%s'", m_NetClient[CLIENT_MAIN].ErrorString());
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ClientNetworkErrPrintColor);
} }
if(State() != IClient::STATE_OFFLINE && State() < IClient::STATE_QUITTING && m_DummyConnected && if(State() != IClient::STATE_OFFLINE && State() < IClient::STATE_QUITTING && m_DummyConnected &&
@ -2573,14 +2576,14 @@ void CClient::PumpNetwork()
DummyDisconnect(0); DummyDisconnect(0);
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "offline dummy error='%s'", m_NetClient[CLIENT_DUMMY].ErrorString()); str_format(aBuf, sizeof(aBuf), "offline dummy error='%s'", m_NetClient[CLIENT_DUMMY].ErrorString());
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ClientNetworkErrPrintColor);
} }
// //
if(State() == IClient::STATE_CONNECTING && m_NetClient[CLIENT_MAIN].State() == NETSTATE_ONLINE) if(State() == IClient::STATE_CONNECTING && m_NetClient[CLIENT_MAIN].State() == NETSTATE_ONLINE)
{ {
// we switched to online // we switched to online
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", "connected, sending info"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", "connected, sending info", ClientNetworkPrintColor);
SetState(IClient::STATE_LOADING); SetState(IClient::STATE_LOADING);
SendInfo(); SendInfo();
} }
@ -3119,7 +3122,7 @@ void CClient::Run()
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "version %s", GameClient()->NetVersion()); str_format(aBuf, sizeof(aBuf), "version %s", GameClient()->NetVersion());
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ColorRGBA{0.7f, 0.7f, 1, 1.0f});
// connect to the server if wanted // connect to the server if wanted
/* /*
@ -4085,11 +4088,20 @@ void CClient::LoadFont()
Kernel()->RequestInterface<IEngineTextRender>()->SetDefaultFont(pDefaultFont); Kernel()->RequestInterface<IEngineTextRender>()->SetDefaultFont(pDefaultFont);
} }
char aBuff[1024];
if(!pDefaultFont) if(!pDefaultFont)
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", "failed to load font. filename='%s'", pFontFile); {
str_format(aBuff, sizeof(aBuff) / sizeof(aBuff[0]), "failed to load font. filename='%s'", pFontFile);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", aBuff);
}
if(!LoadedFallbackFont) if(!LoadedFallbackFont)
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", "failed to load the fallback font. filename='%s'", pFallbackFontFile); {
str_format(aBuff, sizeof(aBuff) / sizeof(aBuff[0]), "failed to load the fallback font. filename='%s'", pFallbackFontFile);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", aBuff);
}
} }
void CClient::Notify(const char *pTitle, const char *pMessage) void CClient::Notify(const char *pTitle, const char *pMessage)

View file

@ -153,7 +153,8 @@ void CFriends::Friends()
for(int i = 0; i < m_NumFriends; ++i) for(int i = 0; i < m_NumFriends; ++i)
{ {
str_format(aBuf, sizeof(aBuf), "Name: %s, Clan: %s", m_aFriends[i].m_aName, m_aFriends[i].m_aClan); str_format(aBuf, sizeof(aBuf), "Name: %s, Clan: %s", m_aFriends[i].m_aName, m_aFriends[i].m_aClan);
pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, m_Foes ? "foes" : "friends", aBuf, true);
pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, m_Foes ? "foes" : "friends", aBuf, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor)));
} }
} }
} }

View file

@ -11,6 +11,8 @@ static const unsigned char gs_aHeaderMarker[8] = {'T', 'W', 'G', 'H', 'O', 'S',
static const unsigned char gs_CurVersion = 6; static const unsigned char gs_CurVersion = 6;
static const int gs_NumTicksOffset = 93; static const int gs_NumTicksOffset = 93;
static const ColorRGBA gs_GhostPrintColor{0.6f, 0.6f, 0.6f, 1.0f};
CGhostRecorder::CGhostRecorder() CGhostRecorder::CGhostRecorder()
{ {
m_File = 0; m_File = 0;
@ -31,7 +33,7 @@ int CGhostRecorder::Start(const char *pFilename, const char *pMap, SHA256_DIGEST
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Unable to open '%s' for ghost recording", pFilename); str_format(aBuf, sizeof(aBuf), "Unable to open '%s' for ghost recording", pFilename);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "ghost_recorder", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "ghost_recorder", aBuf, gs_GhostPrintColor);
return -1; return -1;
} }
@ -50,7 +52,7 @@ int CGhostRecorder::Start(const char *pFilename, const char *pMap, SHA256_DIGEST
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "ghost recording to '%s'", pFilename); str_format(aBuf, sizeof(aBuf), "ghost recording to '%s'", pFilename);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "ghost_recorder", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "ghost_recorder", aBuf, gs_GhostPrintColor);
return 0; return 0;
} }
@ -135,7 +137,7 @@ int CGhostRecorder::Stop(int Ticks, int Time)
if(!m_File) if(!m_File)
return -1; return -1;
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "ghost_recorder", "Stopped ghost recording"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "ghost_recorder", "Stopped ghost recording", gs_GhostPrintColor);
FlushChunk(); FlushChunk();

View file

@ -688,7 +688,7 @@ void CGraphics_Threaded::ScreenshotDirect()
// save png // save png
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "saved screenshot to '%s'", aWholePath); str_format(aBuf, sizeof(aBuf), "saved screenshot to '%s'", aWholePath);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ColorRGBA{0.75f, 0.4f, 0.0f, 1.0f});
png_open_file_write(&Png, aWholePath); // ignore_convention png_open_file_write(&Png, aWholePath); // ignore_convention
png_set_data(&Png, Image.m_Width, Image.m_Height, 8, PNG_TRUECOLOR, (unsigned char *)Image.m_pData); // ignore_convention png_set_data(&Png, Image.m_Width, Image.m_Height, 8, PNG_TRUECOLOR, (unsigned char *)Image.m_pData); // ignore_convention
png_close_file(&Png); // ignore_convention png_close_file(&Png); // ignore_convention

View file

@ -76,7 +76,7 @@ public:
}; };
typedef void (*FTeeHistorianCommandCallback)(int ClientID, int FlagMask, const char *pCmd, IResult *pResult, void *pUser); typedef void (*FTeeHistorianCommandCallback)(int ClientID, int FlagMask, const char *pCmd, IResult *pResult, void *pUser);
typedef void (*FPrintCallback)(const char *pStr, void *pUser, bool Highlighted); typedef void (*FPrintCallback)(const char *pStr, void *pUser, ColorRGBA PrintColor);
typedef void (*FPossibleCallback)(const char *pCmd, void *pUser); typedef void (*FPossibleCallback)(const char *pCmd, void *pUser);
typedef void (*FCommandCallback)(IResult *pResult, void *pUserData); typedef void (*FCommandCallback)(IResult *pResult, void *pUserData);
typedef void (*FChainCommandCallback)(IResult *pResult, void *pUserData, FCommandCallback pfnCallback, void *pCallbackUserData); typedef void (*FChainCommandCallback)(IResult *pResult, void *pUserData, FCommandCallback pfnCallback, void *pCallbackUserData);
@ -103,7 +103,7 @@ public:
virtual int RegisterPrintCallback(int OutputLevel, FPrintCallback pfnPrintCallback, void *pUserData) = 0; virtual int RegisterPrintCallback(int OutputLevel, FPrintCallback pfnPrintCallback, void *pUserData) = 0;
virtual void SetPrintOutputLevel(int Index, int OutputLevel) = 0; virtual void SetPrintOutputLevel(int Index, int OutputLevel) = 0;
virtual char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr) = 0; virtual char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr) = 0;
virtual void Print(int Level, const char *pFrom, const char *pStr, bool Highlighted = false) = 0; virtual void Print(int Level, const char *pFrom, const char *pStr, ColorRGBA PrintColor = {1, 1, 1, 1}) = 0;
virtual void SetTeeHistorianCommandCallback(FTeeHistorianCommandCallback pfnCallback, void *pUser) = 0; virtual void SetTeeHistorianCommandCallback(FTeeHistorianCommandCallback pfnCallback, void *pUser) = 0;
virtual void SetAccessLevel(int AccessLevel) = 0; virtual void SetAccessLevel(int AccessLevel) = 0;

View file

@ -227,7 +227,7 @@ void CServerBan::ConBanExt(IConsole::IResult *pResult, void *pUser)
CServerBan *pThis = static_cast<CServerBan *>(pUser); CServerBan *pThis = static_cast<CServerBan *>(pUser);
const char *pStr = pResult->GetString(0); const char *pStr = pResult->GetString(0);
int Minutes = pResult->NumArguments() > 1 ? clamp(pResult->GetInteger(1), 0, 44640) : 30; int Minutes = pResult->NumArguments() > 1 ? clamp(pResult->GetInteger(1), 0, 525600) : 30;
const char *pReason = pResult->NumArguments() > 2 ? pResult->GetString(2) : "No reason given"; const char *pReason = pResult->NumArguments() > 2 ? pResult->GetString(2) : "No reason given";
if(str_isallnum(pStr)) if(str_isallnum(pStr))
@ -1219,7 +1219,7 @@ void CServer::SendRconLine(int ClientID, const char *pLine)
SendMsg(&Msg, MSGFLAG_VITAL, ClientID); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
} }
void CServer::SendRconLineAuthed(const char *pLine, void *pUser, bool Highlighted) void CServer::SendRconLineAuthed(const char *pLine, void *pUser, ColorRGBA PrintColor)
{ {
CServer *pThis = (CServer *)pUser; CServer *pThis = (CServer *)pUser;
static volatile int s_ReentryGuard = 0; static volatile int s_ReentryGuard = 0;
@ -2685,6 +2685,11 @@ int CServer::Run()
m_UPnP.Shutdown(); m_UPnP.Shutdown();
#endif #endif
for(auto &Client : m_aClients)
{
free(Client.m_pPersistentData);
}
return ErrorShutdown(); return ErrorShutdown();
} }

View file

@ -319,7 +319,7 @@ public:
void SendMapData(int ClientID, int Chunk); void SendMapData(int ClientID, int Chunk);
void SendConnectionReady(int ClientID); void SendConnectionReady(int ClientID);
void SendRconLine(int ClientID, const char *pLine); void SendRconLine(int ClientID, const char *pLine);
static void SendRconLineAuthed(const char *pLine, void *pUser, bool Highlighted = false); static void SendRconLineAuthed(const char *pLine, void *pUser, ColorRGBA PrintColor = {1, 1, 1, 1});
void SendRconCmdAdd(const IConsole::CCommandInfo *pCommandInfo, int ClientID); void SendRconCmdAdd(const IConsole::CCommandInfo *pCommandInfo, int ClientID);
void SendRconCmdRem(const IConsole::CCommandInfo *pCommandInfo, int ClientID); void SendRconCmdRem(const IConsole::CCommandInfo *pCommandInfo, int ClientID);

View file

@ -313,7 +313,7 @@ char *CConsole::Format(char *pBuf, int Size, const char *pFrom, const char *pStr
return pBuf; return pBuf;
} }
void CConsole::Print(int Level, const char *pFrom, const char *pStr, bool Highlighted) void CConsole::Print(int Level, const char *pFrom, const char *pStr, ColorRGBA PrintColor)
{ {
dbg_msg(pFrom, "%s", pStr); dbg_msg(pFrom, "%s", pStr);
char aBuf[1024]; char aBuf[1024];
@ -322,7 +322,7 @@ void CConsole::Print(int Level, const char *pFrom, const char *pStr, bool Highli
{ {
if(Level <= m_aPrintCB[i].m_OutputLevel && m_aPrintCB[i].m_pfnPrintCallback) if(Level <= m_aPrintCB[i].m_OutputLevel && m_aPrintCB[i].m_pfnPrintCallback)
{ {
m_aPrintCB[i].m_pfnPrintCallback(aBuf, m_aPrintCB[i].m_pPrintCallbackUserdata, Highlighted); m_aPrintCB[i].m_pfnPrintCallback(aBuf, m_aPrintCB[i].m_pPrintCallbackUserdata, PrintColor);
} }
} }
} }

View file

@ -218,7 +218,7 @@ public:
virtual int RegisterPrintCallback(int OutputLevel, FPrintCallback pfnPrintCallback, void *pUserData); virtual int RegisterPrintCallback(int OutputLevel, FPrintCallback pfnPrintCallback, void *pUserData);
virtual void SetPrintOutputLevel(int Index, int OutputLevel); virtual void SetPrintOutputLevel(int Index, int OutputLevel);
virtual char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr); virtual char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr);
virtual void Print(int Level, const char *pFrom, const char *pStr, bool Highlighted = false); virtual void Print(int Level, const char *pFrom, const char *pStr, ColorRGBA PrintColor = {1, 1, 1, 1});
virtual void SetTeeHistorianCommandCallback(FTeeHistorianCommandCallback pfnCallback, void *pUser); virtual void SetTeeHistorianCommandCallback(FTeeHistorianCommandCallback pfnCallback, void *pUser);
void SetAccessLevel(int AccessLevel) { m_AccessLevel = clamp(AccessLevel, (int)(ACCESS_LEVEL_ADMIN), (int)(ACCESS_LEVEL_USER)); } void SetAccessLevel(int AccessLevel) { m_AccessLevel = clamp(AccessLevel, (int)(ACCESS_LEVEL_ADMIN), (int)(ACCESS_LEVEL_USER)); }

View file

@ -28,6 +28,8 @@ static const unsigned char s_VersionTickCompression = 5; // demo files with this
static const int s_LengthOffset = 152; static const int s_LengthOffset = 152;
static const int s_NumMarkersOffset = 176; static const int s_NumMarkersOffset = 176;
static const ColorRGBA gs_DemoPrintColor{0.7f, 0.7f, 0.7f, 1.0f};
CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta, bool NoMapData) CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta, bool NoMapData)
{ {
m_File = 0; m_File = 0;
@ -55,7 +57,7 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Unable to open '%s' for recording", pFilename); str_format(aBuf, sizeof(aBuf), "Unable to open '%s' for recording", pFilename);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", aBuf, gs_DemoPrintColor);
} }
return -1; return -1;
} }
@ -111,7 +113,7 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Unable to open mapfile '%s'", pMap); str_format(aBuf, sizeof(aBuf), "Unable to open mapfile '%s'", pMap);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", aBuf, gs_DemoPrintColor);
} }
return -1; return -1;
} }
@ -179,7 +181,7 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "Recording to '%s'", pFilename); str_format(aBuf, sizeof(aBuf), "Recording to '%s'", pFilename);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", aBuf); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", aBuf, gs_DemoPrintColor);
} }
m_File = DemoFile; m_File = DemoFile;
str_copy(m_aCurrentFilename, pFilename, sizeof(m_aCurrentFilename)); str_copy(m_aCurrentFilename, pFilename, sizeof(m_aCurrentFilename));
@ -377,7 +379,7 @@ int CDemoRecorder::Stop()
io_close(m_File); io_close(m_File);
m_File = 0; m_File = 0;
if(m_pConsole) if(m_pConsole)
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", "Stopped recording"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", "Stopped recording", gs_DemoPrintColor);
return 0; return 0;
} }
@ -398,7 +400,7 @@ void CDemoRecorder::AddDemoMarker()
m_aTimelineMarkers[m_NumTimelineMarkers++] = m_LastTickMarker; m_aTimelineMarkers[m_NumTimelineMarkers++] = m_LastTickMarker;
if(m_pConsole) if(m_pConsole)
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", "Added timeline marker"); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", "Added timeline marker", gs_DemoPrintColor);
} }
CDemoPlayer::CDemoPlayer(class CSnapshotDelta *pSnapshotDelta) CDemoPlayer::CDemoPlayer(class CSnapshotDelta *pSnapshotDelta)

View file

@ -36,7 +36,7 @@ int CEcon::DelClientCallback(int ClientID, const char *pReason, void *pUser)
return 0; return 0;
} }
void CEcon::SendLineCB(const char *pLine, void *pUserData, bool Highlighted) void CEcon::SendLineCB(const char *pLine, void *pUserData, ColorRGBA PrintColor)
{ {
static_cast<CEcon *>(pUserData)->Send(-1, pLine); static_cast<CEcon *>(pUserData)->Send(-1, pLine);
} }

View file

@ -38,7 +38,7 @@ class CEcon
int m_PrintCBIndex; int m_PrintCBIndex;
int m_UserClientID; int m_UserClientID;
static void SendLineCB(const char *pLine, void *pUserData, bool Highlighted); static void SendLineCB(const char *pLine, void *pUserData, ColorRGBA PrintColor = {1, 1, 1, 1});
static void ConchainEconOutputLevelUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainEconOutputLevelUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConLogout(IConsole::IResult *pResult, void *pUserData); static void ConLogout(IConsole::IResult *pResult, void *pUserData);

View file

@ -434,7 +434,7 @@ void CNetBan::ConBan(IConsole::IResult *pResult, void *pUser)
CNetBan *pThis = static_cast<CNetBan *>(pUser); CNetBan *pThis = static_cast<CNetBan *>(pUser);
const char *pStr = pResult->GetString(0); const char *pStr = pResult->GetString(0);
int Minutes = pResult->NumArguments() > 1 ? clamp(pResult->GetInteger(1), 0, 44640) : 30; int Minutes = pResult->NumArguments() > 1 ? clamp(pResult->GetInteger(1), 0, 525600) : 30;
const char *pReason = pResult->NumArguments() > 2 ? pResult->GetString(2) : "No reason given"; const char *pReason = pResult->NumArguments() > 2 ? pResult->GetString(2) : "No reason given";
NETADDR Addr; NETADDR Addr;
@ -450,7 +450,7 @@ void CNetBan::ConBanRange(IConsole::IResult *pResult, void *pUser)
const char *pStr1 = pResult->GetString(0); const char *pStr1 = pResult->GetString(0);
const char *pStr2 = pResult->GetString(1); const char *pStr2 = pResult->GetString(1);
int Minutes = pResult->NumArguments() > 2 ? clamp(pResult->GetInteger(2), 0, 44640) : 30; int Minutes = pResult->NumArguments() > 2 ? clamp(pResult->GetInteger(2), 0, 525600) : 30;
const char *pReason = pResult->NumArguments() > 3 ? pResult->GetString(3) : "No reason given"; const char *pReason = pResult->NumArguments() > 3 ? pResult->GetString(3) : "No reason given";
CNetRange Range; CNetRange Range;

View file

@ -4,6 +4,8 @@
#include <engine/config.h> #include <engine/config.h>
#include <engine/shared/config.h> #include <engine/shared/config.h>
static const ColorRGBA gs_BindPrintColor{1.0f, 1.0f, 0.8f, 1.0f};
bool CBinds::CBindsSpecial::OnInput(IInput::CEvent Event) bool CBinds::CBindsSpecial::OnInput(IInput::CEvent Event)
{ {
// only handle F and composed F binds // only handle F and composed F binds
@ -68,7 +70,7 @@ void CBinds::Bind(int KeyID, const char *pStr, bool FreeOnly, int Modifier)
str_copy(m_aapKeyBindings[Modifier][KeyID], pStr, Size); str_copy(m_aapKeyBindings[Modifier][KeyID], pStr, Size);
str_format(aBuf, sizeof(aBuf), "bound %s%s (%d) = %s", GetKeyBindModifiersName(Modifier), Input()->KeyName(KeyID), KeyID, m_aapKeyBindings[Modifier][KeyID]); str_format(aBuf, sizeof(aBuf), "bound %s%s (%d) = %s", GetKeyBindModifiersName(Modifier), Input()->KeyName(KeyID), KeyID, m_aapKeyBindings[Modifier][KeyID]);
} }
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
} }
int CBinds::GetModifierMask(IInput *i) int CBinds::GetModifierMask(IInput *i)
@ -274,7 +276,7 @@ void CBinds::ConBind(IConsole::IResult *pResult, void *pUserData)
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "key %s not found", pBindStr); str_format(aBuf, sizeof(aBuf), "key %s not found", pBindStr);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
return; return;
} }
@ -294,7 +296,7 @@ void CBinds::ConDumpBinds(IConsole::IResult *pResult, void *pUserData)
if(!id) if(!id)
{ {
str_format(aBuf, sizeof(aBuf), "key '%s' not found", pKeyName); str_format(aBuf, sizeof(aBuf), "key '%s' not found", pKeyName);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
} }
else else
{ {
@ -303,7 +305,7 @@ void CBinds::ConDumpBinds(IConsole::IResult *pResult, void *pUserData)
else else
str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pKeyName, id, pBinds->m_aapKeyBindings[Modifier][id]); str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pKeyName, id, pBinds->m_aapKeyBindings[Modifier][id]);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
} }
} }
else if(pResult->NumArguments() == 0) else if(pResult->NumArguments() == 0)
@ -317,7 +319,7 @@ void CBinds::ConDumpBinds(IConsole::IResult *pResult, void *pUserData)
continue; continue;
str_format(aBuf, sizeof(aBuf), "%s%s (%d) = %s", GetKeyBindModifiersName(i), pBinds->Input()->KeyName(j), j, pBinds->m_aapKeyBindings[i][j]); str_format(aBuf, sizeof(aBuf), "%s%s (%d) = %s", GetKeyBindModifiersName(i), pBinds->Input()->KeyName(j), j, pBinds->m_aapKeyBindings[i][j]);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
} }
} }
} }
@ -334,7 +336,7 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData)
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "key %s not found", pKeyName); str_format(aBuf, sizeof(aBuf), "key %s not found", pKeyName);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
return; return;
} }

View file

@ -57,7 +57,7 @@ void CBroadcast::OnMessage(int MsgType, void *pRawMsg)
aBuf[ii] = '\0'; aBuf[ii] = '\0';
ii = 0; ii = 0;
if(aBuf[0]) if(aBuf[0])
m_pClient->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "broadcast", aBuf, true); m_pClient->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "broadcast", aBuf, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor)));
} }
else else
{ {
@ -67,7 +67,7 @@ void CBroadcast::OnMessage(int MsgType, void *pRawMsg)
} }
aBuf[ii] = '\0'; aBuf[ii] = '\0';
if(aBuf[0]) if(aBuf[0])
m_pClient->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "broadcast", aBuf, true); m_pClient->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "broadcast", aBuf, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor)));
} }
} }
} }

View file

@ -663,6 +663,9 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
bool Highlighted = false; bool Highlighted = false;
char *p = const_cast<char *>(pLine); char *p = const_cast<char *>(pLine);
bool IsTeamLine = Team == 1;
bool IsWhisperLine = Team >= 2;
// Only empty string left // Only empty string left
if(*p == 0) if(*p == 0)
return; return;
@ -676,7 +679,27 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
char aBuf[1024]; char aBuf[1024];
str_format(aBuf, sizeof(aBuf), "%s%s%s", pLine->m_aName, pLine->m_ClientID >= 0 ? ": " : "", pLine->m_aText); str_format(aBuf, sizeof(aBuf), "%s%s%s", pLine->m_aName, pLine->m_ClientID >= 0 ? ": " : "", pLine->m_aText);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, pLine->m_Team >= 2 ? "whisper" : (pLine->m_Team ? "teamchat" : "chat"), aBuf, pLine->m_Highlighted);
ColorRGBA ChatLogColor{1, 1, 1, 1};
if(pLine->m_Highlighted)
{
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor));
}
else
{
if(pLine->m_Friend && g_Config.m_ClMessageFriend)
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageFriendColor));
else if(pLine->m_Team)
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageTeamColor));
else if(pLine->m_ClientID == -1) // system
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor));
else if(pLine->m_ClientID == -2) // client
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor));
else // regular message
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageColor));
}
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, pLine->m_Whisper ? "whisper" : (pLine->m_Team ? "teamchat" : "chat"), aBuf, ChatLogColor);
}; };
while(*p) while(*p)
@ -696,7 +719,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
CLine *pCurrentLine = &m_aLines[m_CurrentLine]; CLine *pCurrentLine = &m_aLines[m_CurrentLine];
// If it's a client message, m_aText will have ": " prepended so we have to work around it. // If it's a client message, m_aText will have ": " prepended so we have to work around it.
if(pCurrentLine->m_Team == Team && pCurrentLine->m_ClientID == ClientID && str_comp(pCurrentLine->m_aText, pLine) == 0) if(pCurrentLine->m_Team == IsTeamLine && pCurrentLine->m_Whisper == IsWhisperLine && pCurrentLine->m_ClientID == ClientID && str_comp(pCurrentLine->m_aText, pLine) == 0)
{ {
pCurrentLine->m_TimesRepeated++; pCurrentLine->m_TimesRepeated++;
if(pCurrentLine->m_TextContainerIndex != -1) if(pCurrentLine->m_TextContainerIndex != -1)
@ -722,7 +745,8 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
pCurrentLine->m_YOffset[0] = -1.0f; pCurrentLine->m_YOffset[0] = -1.0f;
pCurrentLine->m_YOffset[1] = -1.0f; pCurrentLine->m_YOffset[1] = -1.0f;
pCurrentLine->m_ClientID = ClientID; pCurrentLine->m_ClientID = ClientID;
pCurrentLine->m_Team = Team; pCurrentLine->m_Team = IsTeamLine;
pCurrentLine->m_Whisper = IsWhisperLine;
pCurrentLine->m_NameColor = -2; pCurrentLine->m_NameColor = -2;
if(pCurrentLine->m_TextContainerIndex != -1) if(pCurrentLine->m_TextContainerIndex != -1)
@ -779,7 +803,6 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "→ %s", m_pClient->m_aClients[ClientID].m_aName); str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "→ %s", m_pClient->m_aClients[ClientID].m_aName);
pCurrentLine->m_NameColor = TEAM_BLUE; pCurrentLine->m_NameColor = TEAM_BLUE;
pCurrentLine->m_Highlighted = false; pCurrentLine->m_Highlighted = false;
pCurrentLine->m_Team = 0;
Highlighted = false; Highlighted = false;
} }
else if(Team == 3) // whisper recv else if(Team == 3) // whisper recv
@ -787,7 +810,6 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "← %s", m_pClient->m_aClients[ClientID].m_aName); str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "← %s", m_pClient->m_aClients[ClientID].m_aName);
pCurrentLine->m_NameColor = TEAM_RED; pCurrentLine->m_NameColor = TEAM_RED;
pCurrentLine->m_Highlighted = true; pCurrentLine->m_Highlighted = true;
pCurrentLine->m_Team = 0;
Highlighted = true; Highlighted = true;
} }
else else

View file

@ -25,7 +25,8 @@ class CChat : public CComponent
int64 m_Time; int64 m_Time;
float m_YOffset[2]; float m_YOffset[2];
int m_ClientID; int m_ClientID;
int m_Team; bool m_Team;
bool m_Whisper;
int m_NameColor; int m_NameColor;
char m_aName[64]; char m_aName[64];
char m_aText[512]; char m_aText[512];

View file

@ -337,7 +337,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event)
} }
} }
void CGameConsole::CInstance::PrintLine(const char *pLine, bool Highlighted) void CGameConsole::CInstance::PrintLine(const char *pLine, ColorRGBA PrintColor)
{ {
int Len = str_length(pLine); int Len = str_length(pLine);
@ -346,7 +346,7 @@ void CGameConsole::CInstance::PrintLine(const char *pLine, bool Highlighted)
CBacklogEntry *pEntry = m_Backlog.Allocate(sizeof(CBacklogEntry) + Len); CBacklogEntry *pEntry = m_Backlog.Allocate(sizeof(CBacklogEntry) + Len);
pEntry->m_YOffset = -1.0f; pEntry->m_YOffset = -1.0f;
pEntry->m_Highlighted = Highlighted; pEntry->m_PrintColor = PrintColor;
mem_copy(pEntry->m_aText, pLine, Len); mem_copy(pEntry->m_aText, pLine, Len);
pEntry->m_aText[Len] = 0; pEntry->m_aText[Len] = 0;
} }
@ -639,8 +639,6 @@ void CGameConsole::OnRender()
} }
} }
ColorRGBA rgb = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor));
// render log (actual page, wrap lines) // render log (actual page, wrap lines)
CInstance::CBacklogEntry *pEntry = pConsole->m_Backlog.Last(); CInstance::CBacklogEntry *pEntry = pConsole->m_Backlog.Last();
float OffsetY = 0.0f; float OffsetY = 0.0f;
@ -650,10 +648,7 @@ void CGameConsole::OnRender()
{ {
while(pEntry) while(pEntry)
{ {
if(pEntry->m_Highlighted) TextRender()->TextColor(pEntry->m_PrintColor);
TextRender()->TextColor(rgb);
else
TextRender()->TextColor(1, 1, 1, 1);
// get y offset (calculate it if we haven't yet) // get y offset (calculate it if we haven't yet)
if(pEntry->m_YOffset < 0.0f) if(pEntry->m_YOffset < 0.0f)
@ -826,9 +821,9 @@ void CGameConsole::ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserD
((CGameConsole *)pUserData)->Dump(CONSOLETYPE_REMOTE); ((CGameConsole *)pUserData)->Dump(CONSOLETYPE_REMOTE);
} }
void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData, bool Highlighted) void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData, ColorRGBA PrintColor)
{ {
((CGameConsole *)pUserData)->m_LocalConsole.PrintLine(pStr, Highlighted); ((CGameConsole *)pUserData)->m_LocalConsole.PrintLine(pStr, PrintColor);
} }
void CGameConsole::ConConsolePageUp(IConsole::IResult *pResult, void *pUserData) void CGameConsole::ConConsolePageUp(IConsole::IResult *pResult, void *pUserData)

View file

@ -22,7 +22,7 @@ class CGameConsole : public CComponent
struct CBacklogEntry struct CBacklogEntry
{ {
float m_YOffset; float m_YOffset;
bool m_Highlighted; ColorRGBA m_PrintColor;
char m_aText[1]; char m_aText[1];
}; };
CStaticRingBuffer<CBacklogEntry, 64 * 1024, CRingBufferBase::FLAG_RECYCLE> m_Backlog; CStaticRingBuffer<CBacklogEntry, 64 * 1024, CRingBufferBase::FLAG_RECYCLE> m_Backlog;
@ -61,7 +61,7 @@ class CGameConsole : public CComponent
void ExecuteLine(const char *pLine); void ExecuteLine(const char *pLine);
void OnInput(IInput::CEvent Event); void OnInput(IInput::CEvent Event);
void PrintLine(const char *pLine, bool Highlighted = false); void PrintLine(const char *pLine, ColorRGBA PrintColor = {1, 1, 1, 1});
const char *GetString() const { return m_Input.GetString(); } const char *GetString() const { return m_Input.GetString(); }
static void PossibleCommandsCompleteCallback(const char *pStr, void *pUser); static void PossibleCommandsCompleteCallback(const char *pStr, void *pUser);
@ -85,7 +85,7 @@ class CGameConsole : public CComponent
void Dump(int Type); void Dump(int Type);
static void PossibleCommandsRenderCallback(const char *pStr, void *pUser); static void PossibleCommandsRenderCallback(const char *pStr, void *pUser);
static void ClientConsolePrintCallback(const char *pStr, void *pUserData, bool Highlighted); static void ClientConsolePrintCallback(const char *pStr, void *pUserData, ColorRGBA PrintColor = {1, 1, 1, 1});
static void ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData); static void ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData);
static void ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData); static void ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData);
static void ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData); static void ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData);

View file

@ -80,14 +80,14 @@ void CMotd::OnMessage(int MsgType, void *pRawMsg)
if(g_Config.m_ClPrintMotd && m_aServerMotd[k] == '\n') if(g_Config.m_ClPrintMotd && m_aServerMotd[k] == '\n')
{ {
m_aServerMotd[k] = '\0'; m_aServerMotd[k] = '\0';
m_pClient->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "motd", pLast, true); m_pClient->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "motd", pLast, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor)));
m_aServerMotd[k] = '\n'; m_aServerMotd[k] = '\n';
pLast = m_aServerMotd + k + 1; pLast = m_aServerMotd + k + 1;
} }
} }
m_aServerMotd[sizeof(m_aServerMotd) - 1] = '\0'; m_aServerMotd[sizeof(m_aServerMotd) - 1] = '\0';
if(g_Config.m_ClPrintMotd && *pLast != '\0') if(g_Config.m_ClPrintMotd && *pLast != '\0')
m_pClient->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "motd", pLast, true); m_pClient->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "motd", pLast, color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor)));
if(m_aServerMotd[0] && g_Config.m_ClMotdTime) if(m_aServerMotd[0] && g_Config.m_ClMotdTime)
m_ServerMotdTime = time() + time_freq() * g_Config.m_ClMotdTime; m_ServerMotdTime = time() + time_freq() * g_Config.m_ClMotdTime;

View file

@ -35,8 +35,8 @@ CHAT_COMMAND("teamrank", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTe
CHAT_COMMAND("rank", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConRank, this, "Shows the rank of player with name r (your rank by default)") CHAT_COMMAND("rank", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConRank, this, "Shows the rank of player with name r (your rank by default)")
CHAT_COMMAND("top5team", "?s[player name] ?i[rank to start with]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTeamTop5, this, "Shows five team ranks of the ladder or of a player beginning with rank i (1 by default, -1 for worst)") CHAT_COMMAND("top5team", "?s[player name] ?i[rank to start with]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTeamTop5, this, "Shows five team ranks of the ladder or of a player beginning with rank i (1 by default, -1 for worst)")
CHAT_COMMAND("teamtop5", "?s[player name] ?i[rank to start with]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTeamTop5, this, "Shows five team ranks of the ladder or of a player beginning with rank i (1 by default, -1 for worst)") CHAT_COMMAND("teamtop5", "?s[player name] ?i[rank to start with]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTeamTop5, this, "Shows five team ranks of the ladder or of a player beginning with rank i (1 by default, -1 for worst)")
CHAT_COMMAND("top", "?i[rank to start with]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTop, this, "Shows five ranks of the global and regional ladder beginning with rank i (1 by default, -1 for worst)") CHAT_COMMAND("top", "?i[rank to start with]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTop, this, "Shows the top ranks of the global and regional ladder beginning with rank i (1 by default, -1 for worst)")
CHAT_COMMAND("top5", "?i[rank to start with]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTop, this, "Shows five ranks of the global and regional ladder beginning with rank i (1 by default, -1 for worst)") CHAT_COMMAND("top5", "?i[rank to start with]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTop, this, "Shows the top ranks of the global and regional ladder beginning with rank i (1 by default, -1 for worst)")
CHAT_COMMAND("times", "?s[player name] ?i[number of times to skip]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTimes, this, "/times ?s?i shows last 5 times of the server or of a player beginning with name s starting with time i (i = 1 by default, -1 for first)") CHAT_COMMAND("times", "?s[player name] ?i[number of times to skip]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTimes, this, "/times ?s?i shows last 5 times of the server or of a player beginning with name s starting with time i (i = 1 by default, -1 for first)")
CHAT_COMMAND("points", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConPoints, this, "Shows the global points of a player beginning with name r (your rank by default)") CHAT_COMMAND("points", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConPoints, this, "Shows the global points of a player beginning with name r (your rank by default)")
CHAT_COMMAND("top5points", "?i[number]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTopPoints, this, "Shows five points of the global point ladder beginning with rank i (1 by default)") CHAT_COMMAND("top5points", "?i[number]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTopPoints, this, "Shows five points of the global point ladder beginning with rank i (1 by default)")

View file

@ -3642,7 +3642,7 @@ void CGameContext::SendChatResponseAll(const char *pLine, void *pUser)
ReentryGuard--; ReentryGuard--;
} }
void CGameContext::SendChatResponse(const char *pLine, void *pUser, bool Highlighted) void CGameContext::SendChatResponse(const char *pLine, void *pUser, ColorRGBA PrintColor)
{ {
CGameContext *pSelf = (CGameContext *)pUser; CGameContext *pSelf = (CGameContext *)pUser;
int ClientID = pSelf->m_ChatResponseTargetID; int ClientID = pSelf->m_ChatResponseTargetID;

View file

@ -448,7 +448,7 @@ public:
inline bool IsSpecVote() const { return m_VoteType == VOTE_TYPE_SPECTATE; }; inline bool IsSpecVote() const { return m_VoteType == VOTE_TYPE_SPECTATE; };
void SendRecord(int ClientID); void SendRecord(int ClientID);
static void SendChatResponse(const char *pLine, void *pUser, bool Highlighted = false); static void SendChatResponse(const char *pLine, void *pUser, ColorRGBA PrintColor = {1, 1, 1, 1});
static void SendChatResponseAll(const char *pLine, void *pUser); static void SendChatResponseAll(const char *pLine, void *pUser);
virtual void OnSetAuthed(int ClientID, int Level); virtual void OnSetAuthed(int ClientID, int Level);
virtual bool PlayerCollision(); virtual bool PlayerCollision();

View file

@ -933,18 +933,13 @@ void CPlayer::ProcessScoreResult(CScorePlayerResult &Result)
} }
break; break;
case CScorePlayerResult::ALL: case CScorePlayerResult::ALL:
{
int MessageClientId = m_ClientID;
for(auto &aMessage : Result.m_Data.m_aaMessages) for(auto &aMessage : Result.m_Data.m_aaMessages)
{ {
if(aMessage[0] == 0) if(aMessage[0] == 0)
break; break;
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aMessage, m_ClientID);
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aMessage, MessageClientId);
MessageClientId = -1; // Prevent multi-messages being flagged as spam.
} }
break; break;
}
case CScorePlayerResult::BROADCAST: case CScorePlayerResult::BROADCAST:
if(Result.m_Data.m_Broadcast[0] != 0) if(Result.m_Data.m_Broadcast[0] != 0)
GameServer()->SendBroadcast(Result.m_Data.m_Broadcast, -1); GameServer()->SendBroadcast(Result.m_Data.m_Broadcast, -1);

View file

@ -975,9 +975,9 @@ bool CScore::ShowTopThread(IDbConnection *pSqlServer, const ISqlData *pGameData,
// check sort method // check sort method
char aBuf[512]; char aBuf[512];
str_format(aBuf, sizeof(aBuf), str_format(aBuf, sizeof(aBuf),
"SELECT Name, Time, Rank " "SELECT Name, Time, Rank, Server "
"FROM (" "FROM ("
" SELECT RANK() OVER w AS Rank, Name, MIN(Time) AS Time " " SELECT RANK() OVER w AS Rank, Name, MIN(Time) AS Time, Server "
" FROM %s_race " " FROM %s_race "
" WHERE Map = ? " " WHERE Map = ? "
" AND Server LIKE ? " " AND Server LIKE ? "
@ -985,7 +985,7 @@ bool CScore::ShowTopThread(IDbConnection *pSqlServer, const ISqlData *pGameData,
" WINDOW w AS (ORDER BY Time)" " WINDOW w AS (ORDER BY Time)"
") as a " ") as a "
"ORDER BY Rank %s " "ORDER BY Rank %s "
"LIMIT %d, 3;", "LIMIT %d, ?;",
pSqlServer->GetPrefix(), pSqlServer->GetPrefix(),
pOrder, pOrder,
LimitStart); LimitStart);
@ -996,13 +996,17 @@ bool CScore::ShowTopThread(IDbConnection *pSqlServer, const ISqlData *pGameData,
} }
pSqlServer->BindString(1, pData->m_Map); pSqlServer->BindString(1, pData->m_Map);
pSqlServer->BindString(2, pAny); pSqlServer->BindString(2, pAny);
pSqlServer->BindInt(3, 6);
// show top // show top
str_copy(pResult->m_Data.m_aaMessages[0], "-----------< Global Top 3 >-----------", sizeof(pResult->m_Data.m_aaMessages[0])); int Line = 0;
str_copy(pResult->m_Data.m_aaMessages[Line], "------------ Global Top ------------", sizeof(pResult->m_Data.m_aaMessages[Line]));
Line++;
char aTime[32]; char aTime[32];
int Line = 1;
bool End = false; bool End = false;
bool HasLocal = false;
while(!pSqlServer->Step(&End, pError, ErrorSize) && !End) while(!pSqlServer->Step(&End, pError, ErrorSize) && !End)
{ {
char aName[MAX_NAME_LENGTH]; char aName[MAX_NAME_LENGTH];
@ -1012,9 +1016,22 @@ bool CScore::ShowTopThread(IDbConnection *pSqlServer, const ISqlData *pGameData,
int Rank = pSqlServer->GetInt(3); int Rank = pSqlServer->GetInt(3);
str_format(pResult->m_Data.m_aaMessages[Line], sizeof(pResult->m_Data.m_aaMessages[Line]), str_format(pResult->m_Data.m_aaMessages[Line], sizeof(pResult->m_Data.m_aaMessages[Line]),
"%d. %s Time: %s", Rank, aName, aTime); "%d. %s Time: %s", Rank, aName, aTime);
char aRecordServer[6];
pSqlServer->GetString(4, aRecordServer, sizeof(aRecordServer));
HasLocal = HasLocal || str_comp(aRecordServer, pData->m_Server) == 0;
Line++; Line++;
if(!HasLocal && Line == 4)
{
break;
}
} }
if(!HasLocal)
{
char aServerLike[16]; char aServerLike[16];
str_format(aServerLike, sizeof(aServerLike), "%%%s%%", pData->m_Server); str_format(aServerLike, sizeof(aServerLike), "%%%s%%", pData->m_Server);
@ -1024,9 +1041,10 @@ bool CScore::ShowTopThread(IDbConnection *pSqlServer, const ISqlData *pGameData,
} }
pSqlServer->BindString(1, pData->m_Map); pSqlServer->BindString(1, pData->m_Map);
pSqlServer->BindString(2, aServerLike); pSqlServer->BindString(2, aServerLike);
pSqlServer->BindInt(3, 3);
str_format(pResult->m_Data.m_aaMessages[Line], sizeof(pResult->m_Data.m_aaMessages[Line]), str_format(pResult->m_Data.m_aaMessages[Line], sizeof(pResult->m_Data.m_aaMessages[Line]),
"-----------< %s Top 3 >-----------", pData->m_Server); "------------ %s Top ------------", pData->m_Server);
Line++; Line++;
// show top // show top
@ -1041,6 +1059,13 @@ bool CScore::ShowTopThread(IDbConnection *pSqlServer, const ISqlData *pGameData,
"%d. %s Time: %s", Rank, aName, aTime); "%d. %s Time: %s", Rank, aName, aTime);
Line++; Line++;
} }
}
else
{
str_copy(pResult->m_Data.m_aaMessages[Line], "---------------------------------------",
sizeof(pResult->m_Data.m_aaMessages[Line]));
}
if(!End) if(!End)
{ {
return true; return true;