MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / inspectSoldiers

Method inspectSoldiers

src/Savegame/SavedGame.cpp:1349–1383  ·  view source on GitHub ↗

* Checks how many soldiers of a rank exist and which one has the highest score. * @param highestRanked Pointer to store the highest-scoring soldier of that rank. * @param total Pointer to an int to store the total in. * @param rank Rank to inspect. */

Source from the content-addressed store, hash-verified

1347 * @param rank Rank to inspect.
1348 */
1349void SavedGame::inspectSoldiers(Soldier **highestRanked, size_t *total, int rank)
1350{
1351 int highestScore = 0;
1352 *total = 0;
1353
1354 for (std::vector<Base*>::iterator i = _bases.begin(); i != _bases.end(); ++i)
1355 {
1356 for (std::vector<Soldier*>::iterator j = (*i)->getSoldiers()->begin(); j != (*i)->getSoldiers()->end(); ++j)
1357 {
1358 if ((*j)->getRank() == (SoldierRank)rank)
1359 {
1360 (*total)++;
1361 int score = getSoldierScore(*j);
1362 if (score > highestScore)
1363 {
1364 highestScore = score;
1365 *highestRanked = (*j);
1366 }
1367 }
1368 }
1369 for (std::vector<Transfer*>::iterator j = (*i)->getTransfers()->begin(); j != (*i)->getTransfers()->end(); ++j)
1370 {
1371 if ((*j)->getType() == TRANSFER_SOLDIER && (*j)->getSoldier()->getRank() == (SoldierRank)rank)
1372 {
1373 (*total)++;
1374 int score = getSoldierScore((*j)->getSoldier());
1375 if (score > highestScore)
1376 {
1377 highestScore = score;
1378 *highestRanked = (*j)->getSoldier();
1379 }
1380 }
1381 }
1382 }
1383}
1384
1385/**
1386 * Evaluate the score of a soldier based on all of his stats, missions and kills.

Callers

nothing calls this directly

Calls 5

getTransfersMethod · 0.80
getSoldiersMethod · 0.45
getRankMethod · 0.45
getTypeMethod · 0.45
getSoldierMethod · 0.45

Tested by

no test coverage detected