From e0a16e06443871fb73d288d96ba440148b86d388 Mon Sep 17 00:00:00 2001 From: def Date: Sat, 11 Oct 2014 12:58:27 +0200 Subject: [PATCH] /mapinfo: Show mapper name --- src/game/server/ddracechat.cpp | 6 +++--- src/game/server/ddracechat.h | 2 +- src/game/server/gamecontext.h | 2 +- src/game/server/score.h | 2 +- src/game/server/score/file_score.cpp | 2 +- src/game/server/score/file_score.h | 2 +- src/game/server/score/sql_score.cpp | 16 +++++++++------- src/game/server/score/sql_score.h | 4 ++-- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index ee8a7004e..1aa64a92b 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -538,7 +538,7 @@ void CGameContext::ConMap(IConsole::IResult *pResult, void *pUserData) #endif } -void CGameContext::ConMapPoints(IConsole::IResult *pResult, void *pUserData) +void CGameContext::ConMapInfo(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (!CheckClientID(pResult->m_ClientID)) @@ -555,9 +555,9 @@ void CGameContext::ConMapPoints(IConsole::IResult *pResult, void *pUserData) #endif if (pResult->NumArguments() > 0) - pSelf->Score()->MapPoints(pResult->m_ClientID, pResult->GetString(0)); + pSelf->Score()->MapInfo(pResult->m_ClientID, pResult->GetString(0)); else - pSelf->Score()->MapPoints(pResult->m_ClientID, g_Config.m_SvMap); + pSelf->Score()->MapInfo(pResult->m_ClientID, g_Config.m_SvMap); #if defined(CONF_SQL) if(g_Config.m_SvUseSQL) diff --git a/src/game/server/ddracechat.h b/src/game/server/ddracechat.h index f4ae5abf9..98294c69e 100644 --- a/src/game/server/ddracechat.h +++ b/src/game/server/ddracechat.h @@ -20,7 +20,7 @@ CHAT_COMMAND("converse", "r", CFGFLAG_CHAT|CFGFLAG_SERVER, ConConverse, this, "C CHAT_COMMAND("pause", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTogglePause, this, "Toggles pause") CHAT_COMMAND("spec", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConToggleSpec, this, "Toggles spec (if not activated on the server, it toggles pause)") CHAT_COMMAND("dnd", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConDND, this, "Toggle Do Not Disturb (no chat and server messages)") -CHAT_COMMAND("mapinfo", "?r", CFGFLAG_CHAT|CFGFLAG_SERVER, ConMapPoints, this, "Show info about the map with name r gives (current map by default)") +CHAT_COMMAND("mapinfo", "?r", CFGFLAG_CHAT|CFGFLAG_SERVER, ConMapInfo, this, "Show info about the map with name r gives (current map by default)") CHAT_COMMAND("timeout", "s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTimeout, this, "Set timeout protection code s") CHAT_COMMAND("save", "s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSave, this, "Save team with code s") CHAT_COMMAND("load", "s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConLoad, this, "Load with code s") diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index 7d1d1c8a8..0be050612 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -268,7 +268,7 @@ private: static void ConUTF8(IConsole::IResult *pResult, void *pUserData); static void ConDND(IConsole::IResult *pResult, void *pUserData); - static void ConMapPoints(IConsole::IResult *pResult, void *pUserData); + static void ConMapInfo(IConsole::IResult *pResult, void *pUserData); static void ConTimeout(IConsole::IResult *pResult, void *pUserData); static void ConSave(IConsole::IResult *pResult, void *pUserData); static void ConLoad(IConsole::IResult *pResult, void *pUserData); diff --git a/src/game/server/score.h b/src/game/server/score.h index 15fa5e8e2..11d25a427 100644 --- a/src/game/server/score.h +++ b/src/game/server/score.h @@ -43,7 +43,7 @@ public: CPlayerData *PlayerData(int ID) { return &m_aPlayerData[ID]; } - virtual void MapPoints(int ClientID, const char* MapName) = 0; + virtual void MapInfo(int ClientID, const char* MapName) = 0; virtual void MapVote(int ClientID, const char* MapName) = 0; virtual void LoadScore(int ClientID) = 0; virtual void SaveScore(int ClientID, float Time, float CpTime[NUM_CHECKPOINTS]) = 0; diff --git a/src/game/server/score/file_score.cpp b/src/game/server/score/file_score.cpp index 8b24734a5..f54119db6 100644 --- a/src/game/server/score/file_score.cpp +++ b/src/game/server/score/file_score.cpp @@ -54,7 +54,7 @@ std::string SaveFile() return oss.str(); } -void CFileScore::MapPoints(int ClientID, const char* MapName) +void CFileScore::MapInfo(int ClientID, const char* MapName) { // TODO: implement } diff --git a/src/game/server/score/file_score.h b/src/game/server/score/file_score.h index 141599134..2f6c5876f 100644 --- a/src/game/server/score/file_score.h +++ b/src/game/server/score/file_score.h @@ -63,7 +63,7 @@ public: ~CFileScore(); virtual void LoadScore(int ClientID); - virtual void MapPoints(int ClientID, const char* MapName); + virtual void MapInfo(int ClientID, const char* MapName); virtual void MapVote(int ClientID, const char* MapName); virtual void SaveScore(int ClientID, float Time, float CpTime[NUM_CHECKPOINTS]); diff --git a/src/game/server/score/sql_score.cpp b/src/game/server/score/sql_score.cpp index e3303f297..0086b78f9 100644 --- a/src/game/server/score/sql_score.cpp +++ b/src/game/server/score/sql_score.cpp @@ -172,7 +172,7 @@ void CSqlScore::Init() str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_teamrace (Map VARCHAR(128) BINARY NOT NULL, Name VARCHAR(%d) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Time FLOAT DEFAULT 0, ID VARBINARY(16) NOT NULL, KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix, MAX_NAME_LENGTH); m_pStatement->execute(aBuf); - str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_maps (Map VARCHAR(128) BINARY NOT NULL, Server VARCHAR(32) BINARY NOT NULL, Points INT DEFAULT 0, Stars INT DEFAULT 0, UNIQUE KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix); + str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_maps (Map VARCHAR(128) BINARY NOT NULL, Server VARCHAR(32) BINARY NOT NULL, Mapper VARCHAR(128) BINARY NOT NULL, Points INT DEFAULT 0, Stars INT DEFAULT 0, UNIQUE KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix); m_pStatement->execute(aBuf); str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_saves (Savegame TEXT CHARACTER SET utf8 BINARY NOT NULL, Map VARCHAR(128) BINARY NOT NULL, Code VARCHAR(128) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY (Map, Code)) CHARACTER SET utf8 ;", m_pPrefix); @@ -502,20 +502,20 @@ void CSqlScore::MapVoteThread(void *pUser) lock_release(gs_SqlLock); } -void CSqlScore::MapPoints(int ClientID, const char* MapName) +void CSqlScore::MapInfo(int ClientID, const char* MapName) { CSqlMapData *Tmp = new CSqlMapData(); Tmp->m_ClientID = ClientID; str_copy(Tmp->m_aMap, MapName, 128); Tmp->m_pSqlData = this; - void *InfoThread = thread_create(MapPointsThread, Tmp); + void *InfoThread = thread_create(MapInfoThread, Tmp); #if defined(CONF_FAMILY_UNIX) pthread_detach((pthread_t)InfoThread); #endif } -void CSqlScore::MapPointsThread(void *pUser) +void CSqlScore::MapInfoThread(void *pUser) { lock_wait(gs_SqlLock); @@ -532,7 +532,7 @@ void CSqlScore::MapPointsThread(void *pUser) try { char aBuf[768]; - str_format(aBuf, sizeof(aBuf), "SELECT l.Map, l.Server, Points, Stars, count(*) as Finishes FROM ((SELECT Map, Server, Points, Stars FROM %s_maps WHERE Map LIKE '%s' COLLATE utf8_general_ci ORDER BY LENGTH(Map), Map LIMIT 1) as l) LEFT JOIN %s_race as r on l.Map = r.Map;", pData->m_pSqlData->m_pPrefix, pData->m_aMap, pData->m_pSqlData->m_pPrefix); + str_format(aBuf, sizeof(aBuf), "SELECT l.Map, l.Server, Mapper, Points, Stars, count(*) as Finishes FROM ((SELECT Map, Server, Mapper, Points, Stars FROM %s_maps WHERE Map LIKE '%s' COLLATE utf8_general_ci ORDER BY LENGTH(Map), Map LIMIT 1) as l) LEFT JOIN %s_race as r on l.Map = r.Map;", pData->m_pSqlData->m_pPrefix, pData->m_aMap, pData->m_pSqlData->m_pPrefix); pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf); if(pData->m_pSqlData->m_pResults->rowsCount() != 1) @@ -549,6 +549,8 @@ void CSqlScore::MapPointsThread(void *pUser) strcpy(aMap, pData->m_pSqlData->m_pResults->getString("Map").c_str()); char aServer[32]; strcpy(aServer, pData->m_pSqlData->m_pResults->getString("Server").c_str()); + char aMapper[128]; + strcpy(aMapper, pData->m_pSqlData->m_pResults->getString("Mapper").c_str()); char aStars[20]; switch(stars) @@ -563,9 +565,9 @@ void CSqlScore::MapPointsThread(void *pUser) aServer[0] = toupper(aServer[0]); if (points == 1) - str_format(aBuf, sizeof(aBuf), "\"%s\" on %s (%s, %d point, %d finishes)", aMap, aServer, aStars, points, finishes); + str_format(aBuf, sizeof(aBuf), "\"%s\" by %s on %s (%s, %d point, %d finishes)", aMap, aMapper, aServer, aStars, points, finishes); else - str_format(aBuf, sizeof(aBuf), "\"%s\" on %s (%s, %d points, %d finishes)", aMap, aServer, aStars, points, finishes); + str_format(aBuf, sizeof(aBuf), "\"%s\" by %s on %s (%s, %d points, %d finishes)", aMap, aMapper, aServer, aStars, points, finishes); } pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf); diff --git a/src/game/server/score/sql_score.h b/src/game/server/score/sql_score.h index 0be84da1e..dd8bdec13 100644 --- a/src/game/server/score/sql_score.h +++ b/src/game/server/score/sql_score.h @@ -40,7 +40,7 @@ class CSqlScore: public IScore return m_pServer; } - static void MapPointsThread(void *pUser); + static void MapInfoThread(void *pUser); static void MapVoteThread(void *pUser); static void LoadScoreThread(void *pUser); static void SaveScoreThread(void *pUser); @@ -74,7 +74,7 @@ public: ~CSqlScore(); virtual void LoadScore(int ClientID); - virtual void MapPoints(int ClientID, const char* MapName); + virtual void MapInfo(int ClientID, const char* MapName); virtual void MapVote(int ClientID, const char* MapName); virtual void SaveScore(int ClientID, float Time, float CpTime[NUM_CHECKPOINTS]);