Codechange: migrate size related functions to Map structure

This commit is contained in:
Rubidium
2023-01-21 10:43:03 +01:00
committed by rubidium42
parent d481f78b24
commit fe2bcd2a58
56 changed files with 334 additions and 343 deletions

View File

@@ -529,12 +529,12 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
Aircraft *u = v->Next();
int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
int safe_y = Clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
int safe_x = Clamp(x, 0, Map::MaxX() * TILE_SIZE);
int safe_y = Clamp(y - 1, 0, Map::MaxY() * TILE_SIZE);
u->x_pos = x;
u->y_pos = y - ((v->z_pos - GetSlopePixelZ(safe_x, safe_y)) >> 3);
safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
safe_y = Clamp(u->y_pos, 0, Map::MaxY() * TILE_SIZE);
u->z_pos = GetSlopePixelZ(safe_x, safe_y);
u->sprite_cache.sprite_seq.CopyWithoutPalette(v->sprite_cache.sprite_seq); // the shadow is never coloured
@@ -696,8 +696,8 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE,
*/
int GetTileHeightBelowAircraft(const Vehicle *v)
{
int safe_x = Clamp(v->x_pos, 0, MapMaxX() * TILE_SIZE);
int safe_y = Clamp(v->y_pos, 0, MapMaxY() * TILE_SIZE);
int safe_x = Clamp(v->x_pos, 0, Map::MaxX() * TILE_SIZE);
int safe_y = Clamp(v->y_pos, 0, Map::MaxY() * TILE_SIZE);
return TileHeight(TileVirtXY(safe_x, safe_y)) * TILE_HEIGHT;
}
@@ -1164,7 +1164,7 @@ static bool HandleCrashedAircraft(Aircraft *v)
/* make aircraft crash down to the ground */
if (v->crashed_counter < 500 && st == nullptr && ((v->crashed_counter % 3) == 0) ) {
int z = GetSlopePixelZ(Clamp(v->x_pos, 0, MapMaxX() * TILE_SIZE), Clamp(v->y_pos, 0, MapMaxY() * TILE_SIZE));
int z = GetSlopePixelZ(Clamp(v->x_pos, 0, Map::MaxX() * TILE_SIZE), Clamp(v->y_pos, 0, Map::MaxY() * TILE_SIZE));
v->z_pos -= 1;
if (v->z_pos == z) {
v->crashed_counter = 500;