Fix SQL queries

This commit is contained in:
def 2014-02-14 21:15:40 +01:00
parent 8bb7d84366
commit 3c39b4460b

View file

@ -420,8 +420,10 @@ void CSqlScore::MapPointsThread(void *pUser)
strcpy(originalMap,pData->m_aMap); strcpy(originalMap,pData->m_aMap);
pData->m_pSqlData->ClearString(pData->m_aMap); pData->m_pSqlData->ClearString(pData->m_aMap);
try
{
char aBuf[768]; char aBuf[768];
str_format(aBuf, sizeof(aBuf), "SELECT Points FROM %s_maps WHERE Map ='%s'", pData->m_pSqlData->m_pPrefix, originalMap); str_format(aBuf, sizeof(aBuf), "SELECT Points FROM %s_maps WHERE Map ='%s'", pData->m_pSqlData->m_pPrefix, pData->m_aMap);
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf); pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
if(pData->m_pSqlData->m_pResults->rowsCount() != 1) if(pData->m_pSqlData->m_pResults->rowsCount() != 1)
@ -437,6 +439,15 @@ void CSqlScore::MapPointsThread(void *pUser)
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf); pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
delete pData->m_pSqlData->m_pResults; delete pData->m_pSqlData->m_pResults;
}
catch (sql::SQLException &e)
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "MySQL Error: %s", e.what());
dbg_msg("SQL", aBuf);
dbg_msg("SQL", "ERROR: Could not update time");
}
pData->m_pSqlData->Disconnect(); pData->m_pSqlData->Disconnect();
} }
@ -1048,10 +1059,10 @@ void CSqlScore::ShowTimes(int ClientID, const char* pName, int Debut)
void CSqlScore::ClearString(char *pString) void CSqlScore::ClearString(char *pString)
{ {
char newString[MAX_NAME_LENGTH*2-1]; char newString[32*2-1];
int pos = 0; int pos = 0;
for(int i=0;i<MAX_NAME_LENGTH;i++) for(int i=0;i<32;i++)
{ {
if(pString[i] == '\\') if(pString[i] == '\\')
{ {