This commit is contained in:
def 2017-05-24 21:36:14 +02:00
parent 1f86e6c8df
commit 02995bf72f

View file

@ -1433,6 +1433,8 @@ bool CSqlScore::SaveTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData
try try
{ {
char aBuf[512]; char aBuf[512];
str_format(aBuf, sizeof(aBuf), "lock tables %s_saves write;", pSqlServer->GetPrefix());
pSqlServer->executeSql(aBuf);
str_format(aBuf, sizeof(aBuf), "select Savegame from %s_saves where Code = '%s' and Map = '%s';", pSqlServer->GetPrefix(), pData->m_Code.ClrStr(), pData->m_Map.ClrStr()); str_format(aBuf, sizeof(aBuf), "select Savegame from %s_saves where Code = '%s' and Map = '%s';", pSqlServer->GetPrefix(), pData->m_Code.ClrStr(), pData->m_Map.ClrStr());
pSqlServer->executeSqlQuery(aBuf); pSqlServer->executeSqlQuery(aBuf);
@ -1462,6 +1464,7 @@ bool CSqlScore::SaveTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData
dbg_msg("sql", "MySQL Error: %s", e.what()); dbg_msg("sql", "MySQL Error: %s", e.what());
dbg_msg("sql", "ERROR: Could not save the team"); dbg_msg("sql", "ERROR: Could not save the team");
pData->GameServer()->SendChatTarget(pData->m_ClientID, "MySQL Error: Could not save the team"); pData->GameServer()->SendChatTarget(pData->m_ClientID, "MySQL Error: Could not save the team");
pSqlServer->executeSql("unlock tables;");
return false; return false;
} }
catch (CGameContextError &e) catch (CGameContextError &e)
@ -1474,6 +1477,7 @@ bool CSqlScore::SaveTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData
dbg_msg("sql", "WARNING: Aborted saving team due to reload/change of map."); dbg_msg("sql", "WARNING: Aborted saving team due to reload/change of map.");
} }
pSqlServer->executeSql("unlock tables;");
return true; return true;
} }
@ -1498,7 +1502,7 @@ bool CSqlScore::LoadTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData
{ {
char aBuf[768]; char aBuf[768];
str_format(aBuf, sizeof(aBuf), "lock tables %s_saves write;", pSqlServer->GetPrefix()); str_format(aBuf, sizeof(aBuf), "lock tables %s_saves write;", pSqlServer->GetPrefix());
pSqlServer->executeSql("lock tables %s_saves;"); pSqlServer->executeSql(aBuf);
str_format(aBuf, sizeof(aBuf), "select Savegame, Server, UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(Timestamp) as Ago from %s_saves where Code = '%s' and Map = '%s';", pSqlServer->GetPrefix(), pData->m_Code.ClrStr(), pData->m_Map.ClrStr()); str_format(aBuf, sizeof(aBuf), "select Savegame, Server, UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(Timestamp) as Ago from %s_saves where Code = '%s' and Map = '%s';", pSqlServer->GetPrefix(), pData->m_Code.ClrStr(), pData->m_Map.ClrStr());
pSqlServer->executeSqlQuery(aBuf); pSqlServer->executeSqlQuery(aBuf);