| 1507 | } |
| 1508 | |
| 1509 | bool CScoreWorker::RandomMap(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize) |
| 1510 | { |
| 1511 | const auto *pData = dynamic_cast<const CSqlRandomMapRequest *>(pGameData); |
| 1512 | auto *pResult = dynamic_cast<CScoreRandomMapResult *>(pGameData->m_pResult.get()); |
| 1513 | |
| 1514 | char aBuf[512]; |
| 1515 | if(in_range(pData->m_MinStars, 0, 5) && in_range(pData->m_MaxStars, 0, 5)) |
| 1516 | { |
| 1517 | str_format(aBuf, sizeof(aBuf), |
| 1518 | "SELECT Map FROM %s_maps " |
| 1519 | "WHERE Server = ? AND Map != ? AND Stars BETWEEN ? AND ? " |
| 1520 | "ORDER BY %s LIMIT 1", |
| 1521 | pSqlServer->GetPrefix(), pSqlServer->Random()); |
| 1522 | if(!pSqlServer->PrepareStatement(aBuf, pError, ErrorSize)) |
| 1523 | { |
| 1524 | return false; |
| 1525 | } |
| 1526 | pSqlServer->BindInt(3, pData->m_MinStars); |
| 1527 | pSqlServer->BindInt(4, pData->m_MaxStars); |
| 1528 | } |
| 1529 | else |
| 1530 | { |
| 1531 | str_format(aBuf, sizeof(aBuf), |
| 1532 | "SELECT Map FROM %s_maps " |
| 1533 | "WHERE Server = ? AND Map != ? " |
| 1534 | "ORDER BY %s LIMIT 1", |
| 1535 | pSqlServer->GetPrefix(), pSqlServer->Random()); |
| 1536 | if(!pSqlServer->PrepareStatement(aBuf, pError, ErrorSize)) |
| 1537 | { |
| 1538 | return false; |
| 1539 | } |
| 1540 | } |
| 1541 | pSqlServer->BindString(1, pData->m_aServerType); |
| 1542 | pSqlServer->BindString(2, pData->m_aCurrentMap); |
| 1543 | |
| 1544 | bool End; |
| 1545 | if(!pSqlServer->Step(&End, pError, ErrorSize)) |
| 1546 | { |
| 1547 | return false; |
| 1548 | } |
| 1549 | if(!End) |
| 1550 | { |
| 1551 | pSqlServer->GetString(1, pResult->m_aMap, sizeof(pResult->m_aMap)); |
| 1552 | } |
| 1553 | else |
| 1554 | { |
| 1555 | str_copy(pResult->m_aMessage, "No maps found on this server!", sizeof(pResult->m_aMessage)); |
| 1556 | } |
| 1557 | return true; |
| 1558 | } |
| 1559 | |
| 1560 | bool CScoreWorker::RandomUnfinishedMap(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize) |
| 1561 | { |
nothing calls this directly
no test coverage detected