mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
/mapinfo: Show mapper name
This commit is contained in:
parent
1ea495c7e2
commit
e0a16e0644
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in a new issue