MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / Phase_Soldiers_Count

Method Phase_Soldiers_Count

Source/Fodder.cpp:1384–1425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1382}
1383
1384void cFodder::Phase_Soldiers_Count() {
1385 mGame_Data.mGamePhase_Data.mSoldiers_Required = 0;
1386 sSprite* Sprite = mSprites.data();
1387
1388 // TODO: This counter needs fixing
1389 // How many player sprites are on this map
1390 for (int16 mTmpCount = 0x1D; mTmpCount > 0; --mTmpCount, ++Sprite) {
1391 if (Sprite->field_0 != -32768) {
1392
1393 if (Sprite->field_18 == eSprite_Player)
1394 ++mGame_Data.mGamePhase_Data.mSoldiers_Required;
1395 }
1396 }
1397
1398 // How many recruits have already been allocated to the mission
1399 mGame_Data.mGamePhase_Data.mSoldiers_Allocated_Count = 0;
1400
1401 for( auto& Troop : mGame_Data.mSoldiers_Allocated) {
1402
1403 if (Troop.mRecruitID != -1) {
1404 --mGame_Data.mGamePhase_Data.mSoldiers_Required;
1405 ++mGame_Data.mGamePhase_Data.mSoldiers_Allocated_Count;
1406 }
1407 }
1408
1409 // Do we still require troops?
1410 int16 ax = mGame_Data.mGamePhase_Data.mSoldiers_Required;
1411 if (mGame_Data.mGamePhase_Data.mSoldiers_Required >= 0) {
1412
1413 // Do we need more than available?
1414 if (ax > mGame_Data.mRecruits_Available_Count)
1415 ax = mGame_Data.mRecruits_Available_Count;
1416
1417 // Set the Required amount
1418 mGame_Data.mGamePhase_Data.mSoldiers_Required = ax;
1419
1420 // Reduce the available recruits by the number taken by the mission
1421 mGame_Data.mRecruits_Available_Count -= ax;
1422 }
1423
1424 mGame_Data.mGamePhase_Data.mSoldiers_Available = mGame_Data.mGamePhase_Data.mSoldiers_Allocated_Count + ax;
1425}
1426
1427void cFodder::Phase_Soldiers_Prepare(const bool pPrebriefing) {
1428 Mission_Troops_Clear_Selected();

Callers 1

quickServiceScreenFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected