mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge branch 'DDRace64' of github.com:def-/teeworlds into DDRace64
This commit is contained in:
commit
2a573d54ff
|
@ -1008,6 +1008,11 @@ void CClient::ProcessConnlessPacket(CNetChunk *pPacket)
|
|||
CUnpacker Up;
|
||||
CServerInfo Info = {0};
|
||||
|
||||
CServerBrowser::CServerEntry *pEntry = m_ServerBrowser.Find(pPacket->m_Address);
|
||||
// Don't add info if we already got info64
|
||||
if(pEntry->m_Info.m_MaxClients > VANILLA_MAX_CLIENTS)
|
||||
return;
|
||||
|
||||
Up.Reset((unsigned char*)pPacket->m_pData+sizeof(SERVERBROWSE_INFO), pPacket->m_DataSize-sizeof(SERVERBROWSE_INFO));
|
||||
int Token = str_toint(Up.GetString());
|
||||
str_copy(Info.m_aVersion, Up.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), sizeof(Info.m_aVersion));
|
||||
|
|
|
@ -32,41 +32,54 @@ CSqlScore::CSqlScore(CGameContext *pGameServer) : m_pGameServer(pGameServer),
|
|||
gs_SqlLock = lock_create();
|
||||
|
||||
Init();
|
||||
LoadPointMapList();
|
||||
LoadPointMapListThread(this);
|
||||
}
|
||||
|
||||
void CSqlScore::LoadPointMapList()
|
||||
{
|
||||
//CSqlScoreData *Tmp = new CSqlScoreData();
|
||||
//Tmp->m_ClientID = ClientID;
|
||||
//str_copy(Tmp->m_aName, Server()->ClientName(ClientID), MAX_NAME_LENGTH);
|
||||
//Tmp->m_pSqlData = this;
|
||||
|
||||
void *LoadThread = thread_create(LoadPointMapListThread, this);
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)LoadThread);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSqlScore::LoadPointMapListThread(void *pUser)
|
||||
{
|
||||
lock_wait(gs_SqlLock);
|
||||
|
||||
m_PointsSize = 0;
|
||||
CSqlScore *pScore = (CSqlScore *)pUser;
|
||||
|
||||
std::ifstream f("points.cfg");
|
||||
if (f.fail())
|
||||
return;
|
||||
|
||||
if(!Connect())
|
||||
if(!pScore->Connect())
|
||||
return;
|
||||
|
||||
m_PointsSize = std::count(std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>(), '\n');
|
||||
pScore->m_PointsSize = std::count(std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>(), '\n');
|
||||
f.seekg(0);
|
||||
delete m_PointsInfos;
|
||||
m_PointsInfos = new CPointsInfo[m_PointsSize];
|
||||
delete pScore->m_PointsInfos;
|
||||
pScore->m_PointsInfos = new CPointsInfo[pScore->m_PointsSize];
|
||||
|
||||
char aBuf[256];
|
||||
unsigned int Position = 0;
|
||||
|
||||
while (f.getline(aBuf, 256) && Position < m_PointsSize)
|
||||
while (f.getline(aBuf, 256) && Position < pScore->m_PointsSize)
|
||||
{
|
||||
CPointsInfo& Info = m_PointsInfos[Position];
|
||||
CPointsInfo& Info = pScore->m_PointsInfos[Position];
|
||||
if (sscanf(aBuf, "%u %127[^\t\n]", &Info.m_Points, Info.m_aMapName) == 2)
|
||||
{
|
||||
NormalizeMapname(Info.m_aMapName);
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT count(Name) FROM %s_%s_race;", m_pPrefix, Info.m_aMapName);
|
||||
pScore->NormalizeMapname(Info.m_aMapName);
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT count(Name) FROM %s_%s_race;", pScore->m_pPrefix, Info.m_aMapName);
|
||||
try
|
||||
{
|
||||
m_pResults = m_pStatement->executeQuery(aBuf);
|
||||
delete m_pResults;
|
||||
pScore->m_pResults = pScore->m_pStatement->executeQuery(aBuf);
|
||||
delete pScore->m_pResults;
|
||||
}
|
||||
catch (sql::SQLException &e)
|
||||
{
|
||||
|
@ -76,11 +89,11 @@ void CSqlScore::LoadPointMapList()
|
|||
}
|
||||
}
|
||||
|
||||
m_PointsSize = Position;
|
||||
pScore->m_PointsSize = Position;
|
||||
|
||||
lock_release(gs_SqlLock);
|
||||
|
||||
Disconnect();
|
||||
pScore->Disconnect();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ class CSqlScore: public IScore
|
|||
return m_pServer;
|
||||
}
|
||||
|
||||
static void LoadPointMapListThread(void *pUser);
|
||||
static void LoadScoreThread(void *pUser);
|
||||
static void SaveScoreThread(void *pUser);
|
||||
static void SaveTeamScoreThread(void *pUser);
|
||||
|
|
Loading…
Reference in a new issue