* This unit is about to appear on the map. So add it from the house * statistics about allies/enemies, and do some other logic. * @param unit The unit to add. * @param houseID The house registering the add. */
| 2655 | * @param houseID The house registering the add. |
| 2656 | */ |
| 2657 | void Unit_HouseUnitCount_Add(Unit *unit, uint8 houseID) |
| 2658 | { |
| 2659 | const UnitInfo *ui; |
| 2660 | uint16 houseIDBit; |
| 2661 | House *hp; |
| 2662 | House *h; |
| 2663 | |
| 2664 | if (unit == NULL) return; |
| 2665 | |
| 2666 | hp = House_Get_ByIndex(g_playerHouseID); |
| 2667 | ui = &g_table_unitInfo[unit->o.type]; |
| 2668 | h = House_Get_ByIndex(houseID); |
| 2669 | houseIDBit = (1 << houseID); |
| 2670 | |
| 2671 | if (houseID == HOUSE_ATREIDES && unit->o.type != UNIT_SANDWORM) { |
| 2672 | houseIDBit |= (1 << HOUSE_FREMEN); |
| 2673 | } |
| 2674 | |
| 2675 | if ((unit->o.seenByHouses & houseIDBit) != 0 && h->flags.isAIActive) { |
| 2676 | unit->o.seenByHouses |= houseIDBit; |
| 2677 | return; |
| 2678 | } |
| 2679 | |
| 2680 | if (!ui->flags.isNormalUnit && unit->o.type != UNIT_SANDWORM) { |
| 2681 | return; |
| 2682 | } |
| 2683 | |
| 2684 | if ((unit->o.seenByHouses & houseIDBit) == 0) { |
| 2685 | if (House_AreAllied(houseID, Unit_GetHouseID(unit))) { |
| 2686 | h->unitCountAllied++; |
| 2687 | } else { |
| 2688 | h->unitCountEnemy++; |
| 2689 | } |
| 2690 | } |
| 2691 | |
| 2692 | if (ui->movementType != MOVEMENT_WINGER) { |
| 2693 | if (!House_AreAllied(houseID, Unit_GetHouseID(unit))) { |
| 2694 | h->flags.isAIActive = true; |
| 2695 | House_Get_ByIndex(Unit_GetHouseID(unit))->flags.isAIActive = true; |
| 2696 | } |
| 2697 | } |
| 2698 | |
| 2699 | if (houseID == g_playerHouseID && g_selectionType != SELECTIONTYPE_MENTAT) { |
| 2700 | if (unit->o.type == UNIT_SANDWORM) { |
| 2701 | if (hp->timerSandwormAttack == 0) { |
| 2702 | if (g_musicInBattle == 0) g_musicInBattle = 1; |
| 2703 | |
| 2704 | Sound_Output_Feedback(37); |
| 2705 | |
| 2706 | if (g_config.language == LANGUAGE_ENGLISH) { |
| 2707 | GUI_DisplayHint(STR_WARNING_SANDWORMS_SHAIHULUD_ROAM_DUNE_DEVOURING_ANYTHING_ON_THE_SAND, 105); |
| 2708 | } |
| 2709 | |
| 2710 | hp->timerSandwormAttack = 8; |
| 2711 | } |
| 2712 | } else if (!House_AreAllied(g_playerHouseID, Unit_GetHouseID(unit))) { |
| 2713 | Team *t; |
| 2714 |
no test coverage detected