* Update the position of the vehicle. * @param x The new X-coordinate. * @param y The new Y-coordinate. * @param z The new Z-coordinate. */
| 181 | * @param z The new Z-coordinate. |
| 182 | */ |
| 183 | void DisasterVehicle::UpdatePosition(int x, int y, int z) |
| 184 | { |
| 185 | this->x_pos = x; |
| 186 | this->y_pos = y; |
| 187 | this->z_pos = z; |
| 188 | this->tile = TileVirtXY(x, y); |
| 189 | |
| 190 | this->UpdateImage(); |
| 191 | this->UpdatePositionAndViewport(); |
| 192 | |
| 193 | DisasterVehicle *u = this->Next(); |
| 194 | if (u != nullptr) { |
| 195 | int safe_x = Clamp(x, 0, Map::MaxX() * TILE_SIZE); |
| 196 | int safe_y = Clamp(y - 1, 0, Map::MaxY() * TILE_SIZE); |
| 197 | |
| 198 | u->x_pos = x; |
| 199 | u->y_pos = y - 1 - (std::max(z - GetSlopePixelZ(safe_x, safe_y), 0) >> 3); |
| 200 | safe_y = Clamp(u->y_pos, 0, Map::MaxY() * TILE_SIZE); |
| 201 | u->z_pos = GetSlopePixelZ(safe_x, safe_y); |
| 202 | u->direction = this->direction; |
| 203 | |
| 204 | u->UpdateImage(); |
| 205 | u->UpdatePositionAndViewport(); |
| 206 | |
| 207 | if ((u = u->Next()) != nullptr) { |
| 208 | u->x_pos = x; |
| 209 | u->y_pos = y; |
| 210 | u->z_pos = z + ROTOR_Z_OFFSET; |
| 211 | u->UpdatePositionAndViewport(); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Zeppeliner handling, v->state states: |
no test coverage detected