MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Unit_HouseUnitCount_Remove

Function Unit_HouseUnitCount_Remove

src/unit.c:2620–2649  ·  view source on GitHub ↗

* This unit is about to disapear from the map. So remove it from the house * statistics about allies/enemies. * @param unit The unit to remove. */

Source from the content-addressed store, hash-verified

2618 * @param unit The unit to remove.
2619 */
2620void Unit_HouseUnitCount_Remove(Unit *unit)
2621{
2622 PoolFindStruct find;
2623
2624 if (unit == NULL) return;
2625 if (unit->o.seenByHouses == 0) return;
2626
2627 find.houseID = HOUSE_INVALID;
2628 find.index = 0xFFFF;
2629 find.type = 0xFFFF;
2630
2631 while (true) {
2632 House *h;
2633
2634 h = House_Find(&find);
2635 if (h == NULL) break;
2636
2637 if ((unit->o.seenByHouses & (1 << h->index)) == 0) continue;
2638
2639 if (!House_AreAllied((uint8)h->index, Unit_GetHouseID(unit))) {
2640 h->unitCountEnemy--;
2641 } else {
2642 h->unitCountAllied--;
2643 }
2644
2645 unit->o.seenByHouses &= ~(1 << h->index);
2646 }
2647
2648 if (g_dune2_enhanced) unit->o.seenByHouses = 0;
2649}
2650
2651/**
2652 * This unit is about to appear on the map. So add it from the house

Callers 5

Unit_RemoveFunction · 0.85
Unit_HideFunction · 0.85
Unit_UpdateMapFunction · 0.85
Script_Unit_DieFunction · 0.85
Script_Unit_FireFunction · 0.85

Calls 3

House_FindFunction · 0.85
House_AreAlliedFunction · 0.85
Unit_GetHouseIDFunction · 0.85

Tested by

no test coverage detected