* 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. */
| 2618 | * @param unit The unit to remove. |
| 2619 | */ |
| 2620 | void 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 |
no test coverage detected