* Update the map around the Unit depending on the type (entering tile, leaving, staying). * @param type The type of action on the map. * @param unit The Unit doing the action. */
| 2464 | * @param unit The Unit doing the action. |
| 2465 | */ |
| 2466 | void Unit_UpdateMap(uint16 type, Unit *unit) |
| 2467 | { |
| 2468 | const UnitInfo *ui; |
| 2469 | tile32 position; |
| 2470 | uint16 packed; |
| 2471 | Tile *t; |
| 2472 | uint16 radius; |
| 2473 | |
| 2474 | if (unit == NULL || unit->o.flags.s.isNotOnMap || !unit->o.flags.s.used) return; |
| 2475 | |
| 2476 | ui = &g_table_unitInfo[unit->o.type]; |
| 2477 | |
| 2478 | if (ui->movementType == MOVEMENT_WINGER) { |
| 2479 | if (type != 0) { |
| 2480 | unit->o.flags.s.isDirty = true; |
| 2481 | g_dirtyAirUnitCount++; |
| 2482 | } |
| 2483 | |
| 2484 | Map_UpdateAround(g_table_unitInfo[unit->o.type].dimension, unit->o.position, unit, g_functions[0][type]); |
| 2485 | return; |
| 2486 | } |
| 2487 | |
| 2488 | position = unit->o.position; |
| 2489 | packed = Tile_PackTile(position); |
| 2490 | t = &g_map[packed]; |
| 2491 | |
| 2492 | if (t->isUnveiled || unit->o.houseID == g_playerHouseID) { |
| 2493 | Unit_HouseUnitCount_Add(unit, g_playerHouseID); |
| 2494 | } else { |
| 2495 | Unit_HouseUnitCount_Remove(unit); |
| 2496 | } |
| 2497 | |
| 2498 | if (type == 1) { |
| 2499 | if (House_AreAllied(Unit_GetHouseID(unit), g_playerHouseID) && !Map_IsPositionUnveiled(packed) && unit->o.type != UNIT_SANDWORM) { |
| 2500 | Tile_RemoveFogInRadius(position, 1); |
| 2501 | } |
| 2502 | |
| 2503 | if (Object_GetByPackedTile(packed) == NULL) { |
| 2504 | t->index = unit->o.index + 1; |
| 2505 | t->hasUnit = true; |
| 2506 | } |
| 2507 | } |
| 2508 | |
| 2509 | if (type != 0) { |
| 2510 | unit->o.flags.s.isDirty = true; |
| 2511 | g_dirtyUnitCount++; |
| 2512 | } |
| 2513 | |
| 2514 | radius = ui->dimension + 3; |
| 2515 | |
| 2516 | if (unit->o.flags.s.bulletIsBig || unit->o.flags.s.isSmoking || (unit->o.type == UNIT_HARVESTER && unit->actionID == ACTION_HARVEST)) radius = 33; |
| 2517 | |
| 2518 | Map_UpdateAround(radius, position, unit, g_functions[1][type]); |
| 2519 | |
| 2520 | if (unit->o.type != UNIT_HARVESTER) return; |
| 2521 | |
| 2522 | /* The harvester is the only 2x1 unit, so also update tiles in behind us. */ |
| 2523 | Map_UpdateAround(radius, unit->targetPreLast, unit, g_functions[1][type]); |
no test coverage detected