diff --git a/src/OpenSHC/Map/Units/TribesState/trySpawnAdditionalWildlifeForTribe.cpp b/src/OpenSHC/Map/Units/TribesState/trySpawnAdditionalWildlifeForTribe.cpp index 340215f6bf..bb8e5040ad 100644 --- a/src/OpenSHC/Map/Units/TribesState/trySpawnAdditionalWildlifeForTribe.cpp +++ b/src/OpenSHC/Map/Units/TribesState/trySpawnAdditionalWildlifeForTribe.cpp @@ -26,7 +26,8 @@ namespace Map { if (tribeID <= 0) { return FALSE; } - if (this->tribes[tribeID].predatorNearby > 0) { + // A scare tick counter (0..800), not a flag: the original tests it for non-zero (> 0 loses the match) + if (this->tribes[tribeID].predatorNearby != 0) { return FALSE; } if (DAT_GameCore::instance.missionNumber1to20 == 38 && unitType == Map::Units::UT_CAMELSHBEAR) { @@ -44,7 +45,7 @@ namespace Map { int const _spawnX = DAT_UnitsState::instance.units[_unitID].x; int const _spawnY = DAT_UnitsState::instance.units[_unitID].y; int const _spawnHeight = DAT_UnitsState::instance.units[_unitID].terrainOrClimbHeight; - this->tribes[tribeID].field_0x288 = this->tribes[tribeID].field_0x288 + 1; + ++this->tribes[tribeID].field_0x288; if (this->tribes[tribeID].field_0x288 < spawnIntervalTicks) { return FALSE; } diff --git a/src/OpenSHC/Map/Units/TribesState/updateAnimalHerdBehaviorState.cpp b/src/OpenSHC/Map/Units/TribesState/updateAnimalHerdBehaviorState.cpp index bc2a4cd3df..90597f0426 100644 --- a/src/OpenSHC/Map/Units/TribesState/updateAnimalHerdBehaviorState.cpp +++ b/src/OpenSHC/Map/Units/TribesState/updateAnimalHerdBehaviorState.cpp @@ -11,14 +11,15 @@ namespace Map { // FUNCTION: STRONGHOLDCRUSADER 0x00523590 void TribesState::updateAnimalHerdBehaviorState(int tribeID) { - if (tribeID <= 0 || this->tribes[tribeID].predatorNearby > 0) { + // A scare tick counter (0..800), not a flag: the original tests it for non-zero (> 0 loses the match) + if (tribeID <= 0 || this->tribes[tribeID].predatorNearby != 0) { return; } - int unitSelectionIndex = 0; - while (unitSelectionIndex < this->tribes[tribeID].size) { + for (int unitSelectionIndex = 0; unitSelectionIndex < this->tribes[tribeID].size;) { int const unitID = MACRO_CALL_MEMBER(Map::Units::TribesState_Func::getUnitIDForIndexInTribe, this)( tribeID, unitSelectionIndex); - unitSelectionIndex = unitSelectionIndex + 1; + // Stepped here, right after the call (in the loop's header, the match is lost). + ++unitSelectionIndex; if (DAT_UnitsState::instance.units[unitID].logicalState == Map::Units::ULS_NORMAL && !DAT_UnitsState::instance.units[unitID].dying && DAT_UnitsState::instance.units[unitID].antelopeBasedRngValue == 2) {