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

Function Unit_MovementTick

src/unit.c:98–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98static void Unit_MovementTick(Unit *unit)
99{
100 uint16 speed;
101
102 if (unit->speed == 0) return;
103
104 speed = unit->speedRemainder;
105
106 /* Units in the air don't feel the effect of gameSpeed */
107 if (g_table_unitInfo[unit->o.type].movementType != MOVEMENT_WINGER) {
108 speed += Tools_AdjustToGameSpeed(unit->speedPerTick, 1, 255, false);
109 } else {
110 speed += unit->speedPerTick;
111 }
112
113 if ((speed & 0xFF00) != 0) {
114 Unit_Move(unit, min(unit->speed * 16, Tile_GetDistance(unit->o.position, unit->currentDestination) + 16));
115 }
116
117 unit->speedRemainder = speed & 0xFF;
118}
119
120/**
121 * Loop over all units, performing various of tasks.

Callers 1

GameLoop_UnitFunction · 0.85

Calls 3

Tools_AdjustToGameSpeedFunction · 0.85
Unit_MoveFunction · 0.85
Tile_GetDistanceFunction · 0.85

Tested by

no test coverage detected