MCPcopy Create free account
hub / github.com/ddnet/ddnet / ShowTeamTop5

Method ShowTeamTop5

src/game/server/scoreworker.cpp:1111–1206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1109}
1110
1111bool CScoreWorker::ShowTeamTop5(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
1112{
1113 const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
1114 auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
1115 auto *paMessages = pResult->m_Data.m_aaMessages;
1116
1117 int LimitStart = maximum(absolute(pData->m_Offset) - 1, 0);
1118 const char *pOrder = pData->m_Offset >= 0 ? "ASC" : "DESC";
1119 const char *pAny = "%";
1120
1121 // check sort method
1122 char aBuf[1024];
1123
1124 str_format(aBuf, sizeof(aBuf),
1125 "SELECT Name, Time, Ranking, TeamSize "
1126 "FROM ("
1127 " SELECT TeamSize, Ranking, Id, Server "
1128 " FROM (" // teamrank score board
1129 " SELECT RANK() OVER w AS Ranking, COUNT(*) AS Teamsize, Id, Server "
1130 " FROM ("
1131 " SELECT tr.Map, tr.Time, tr.Id, ("
1132 " SELECT rr.Server FROM %s_race AS rr "
1133 " WHERE rr.Map = tr.Map AND rr.Name = tr.Name AND rr.Time = tr.Time "
1134 " LIMIT 1"
1135 " ) AS Server "
1136 " FROM %s_teamrace AS tr "
1137 " WHERE tr.Map = ? "
1138 " ) AS ll "
1139 " GROUP BY ID "
1140 " WINDOW w AS (ORDER BY Min(Time))"
1141 " ) as l1 "
1142 " WHERE Server LIKE ? "
1143 " ORDER BY Ranking %s "
1144 " LIMIT %d, ?"
1145 ") as l2 "
1146 "INNER JOIN %s_teamrace as r ON l2.Id = r.Id "
1147 "ORDER BY Ranking %s, r.Id, Name ASC",
1148 pSqlServer->GetPrefix(), pSqlServer->GetPrefix(), pOrder, LimitStart, pSqlServer->GetPrefix(), pOrder);
1149 if(!pSqlServer->PrepareStatement(aBuf, pError, ErrorSize))
1150 {
1151 return false;
1152 }
1153 pSqlServer->BindString(1, pData->m_aMap);
1154 pSqlServer->BindString(2, pAny);
1155 pSqlServer->BindInt(3, 5);
1156
1157 int Line = 0;
1158 str_copy(paMessages[Line++], "------- Team Top 5 -------", sizeof(paMessages[Line]));
1159
1160 bool End;
1161 if(!pSqlServer->Step(&End, pError, ErrorSize))
1162 {
1163 return false;
1164 }
1165 if(!End)
1166 {
1167 if(!CTeamrank::GetSqlTop5Team(pSqlServer, &End, pError, ErrorSize, paMessages, &Line, 5))
1168 {

Callers

nothing calls this directly

Calls 10

maximumFunction · 0.85
absoluteFunction · 0.85
str_formatFunction · 0.85
getMethod · 0.80
GetPrefixMethod · 0.80
str_copyFunction · 0.50
PrepareStatementMethod · 0.45
BindStringMethod · 0.45
BindIntMethod · 0.45
StepMethod · 0.45

Tested by

no test coverage detected