Merge pull request #10880 from Gymnasiast/refactor/some-define

Replace some hard coded numbers with constants
This commit is contained in:
Michael Steenbeek 2020-03-05 20:53:16 +01:00 committed by GitHub
commit ae3ca0b2b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 32 additions and 32 deletions

View File

@ -71,7 +71,7 @@ void land_tool_show_surface_style_dropdown(rct_window* w, rct_widget* widget, ui
gDropdownItemsArgs[itemIndex] = surfaceObj->IconImageId; gDropdownItemsArgs[itemIndex] = surfaceObj->IconImageId;
if (surfaceObj->Colour != 255) if (surfaceObj->Colour != 255)
{ {
gDropdownItemsArgs[itemIndex] |= surfaceObj->Colour << 19 | IMAGE_TYPE_REMAP; gDropdownItemsArgs[itemIndex] |= SPRITE_ID_PALETTE_COLOUR_1(surfaceObj->Colour);
} }
if (i == currentSurfaceType) if (i == currentSurfaceType)
{ {

View File

@ -951,7 +951,7 @@ static void window_footpath_start_bridge_at_point(const ScreenCoordsXY& screenCo
_window_footpath_provisional_path_arrow_timer = 0; _window_footpath_provisional_path_arrow_timer = 0;
gFootpathConstructSlope = 0; gFootpathConstructSlope = 0;
gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL; gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL;
gFootpathConstructValidDirections = 255; gFootpathConstructValidDirections = INVALID_DIRECTION;
window_footpath_set_enabled_and_pressed_widgets(); window_footpath_set_enabled_and_pressed_widgets();
} }
@ -977,7 +977,7 @@ static void window_footpath_construct()
if (gFootpathConstructSlope == 0) if (gFootpathConstructSlope == 0)
{ {
gFootpathConstructValidDirections = 0xFF; gFootpathConstructValidDirections = INVALID_DIRECTION;
} }
else else
{ {
@ -1049,7 +1049,7 @@ static void footpath_remove_tile_element(TileElement* tileElement)
gFootpathConstructFromPosition.y -= CoordsDirectionDelta[edge].y; gFootpathConstructFromPosition.y -= CoordsDirectionDelta[edge].y;
gFootpathConstructFromPosition.z = z; gFootpathConstructFromPosition.z = z;
gFootpathConstructDirection = edge; gFootpathConstructDirection = edge;
gFootpathConstructValidDirections = 255; gFootpathConstructValidDirections = INVALID_DIRECTION;
} }
/** /**
@ -1179,7 +1179,7 @@ static void window_footpath_set_enabled_and_pressed_widgets()
// Enable / disable directional widgets // Enable / disable directional widgets
direction = gFootpathConstructValidDirections; direction = gFootpathConstructValidDirections;
if (direction != 255) if (direction != INVALID_DIRECTION)
{ {
disabledWidgets |= (1 << WIDX_DIRECTION_NW) | (1 << WIDX_DIRECTION_NE) | (1 << WIDX_DIRECTION_SW) disabledWidgets |= (1 << WIDX_DIRECTION_NW) | (1 << WIDX_DIRECTION_NE) | (1 << WIDX_DIRECTION_SW)
| (1 << WIDX_DIRECTION_SE); | (1 << WIDX_DIRECTION_SE);

View File

@ -305,7 +305,7 @@ static void window_land_invalidate(rct_window* w)
surfaceImage = surfaceObj->IconImageId; surfaceImage = surfaceObj->IconImageId;
if (surfaceObj->Colour != 255) if (surfaceObj->Colour != 255)
{ {
surfaceImage |= surfaceObj->Colour << 19 | IMAGE_TYPE_REMAP; surfaceImage |= SPRITE_ID_PALETTE_COLOUR_1(surfaceObj->Colour);
} }
} }
const auto edgeObj = static_cast<TerrainEdgeObject*>( const auto edgeObj = static_cast<TerrainEdgeObject*>(

View File

@ -745,7 +745,7 @@ static void window_mapgen_base_invalidate(rct_window* w)
surfaceImage = surfaceObj->IconImageId; surfaceImage = surfaceObj->IconImageId;
if (surfaceObj->Colour != 255) if (surfaceObj->Colour != 255)
{ {
surfaceImage |= surfaceObj->Colour << 19 | IMAGE_TYPE_REMAP; surfaceImage |= SPRITE_ID_PALETTE_COLOUR_1(surfaceObj->Colour);
} }
} }
const auto edgeObj = static_cast<TerrainEdgeObject*>(objManager.GetLoadedObject(OBJECT_TYPE_TERRAIN_EDGE, _wallTexture)); const auto edgeObj = static_cast<TerrainEdgeObject*>(objManager.GetLoadedObject(OBJECT_TYPE_TERRAIN_EDGE, _wallTexture));
@ -1048,7 +1048,7 @@ static void window_mapgen_simplex_invalidate(rct_window* w)
surfaceImage = surfaceObj->IconImageId; surfaceImage = surfaceObj->IconImageId;
if (surfaceObj->Colour != 255) if (surfaceObj->Colour != 255)
{ {
surfaceImage |= surfaceObj->Colour << 19 | IMAGE_TYPE_REMAP; surfaceImage |= SPRITE_ID_PALETTE_COLOUR_1(surfaceObj->Colour);
} }
} }
const auto edgeObj = static_cast<TerrainEdgeObject*>(objManager.GetLoadedObject(OBJECT_TYPE_TERRAIN_EDGE, _wallTexture)); const auto edgeObj = static_cast<TerrainEdgeObject*>(objManager.GetLoadedObject(OBJECT_TYPE_TERRAIN_EDGE, _wallTexture));

View File

@ -366,7 +366,7 @@ static void window_maze_construction_entrance_tooldown(const ScreenCoordsXY& scr
if (entranceOrExitCoords.isNull()) if (entranceOrExitCoords.isNull())
return; return;
if (gRideEntranceExitPlaceDirection == 0xFF) if (gRideEntranceExitPlaceDirection == INVALID_DIRECTION)
return; return;
ride_id_t rideIndex = gRideEntranceExitPlaceRideIndex; ride_id_t rideIndex = gRideEntranceExitPlaceRideIndex;

View File

@ -3673,7 +3673,7 @@ void ride_construction_toolupdate_entrance_exit(const ScreenCoordsXY& screenCoor
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
CoordsXYZD entranceOrExitCoords = ride_get_entrance_or_exit_position_from_screen_position(screenCoords); CoordsXYZD entranceOrExitCoords = ride_get_entrance_or_exit_position_from_screen_position(screenCoords);
if (gRideEntranceExitPlaceDirection == 255) if (gRideEntranceExitPlaceDirection == INVALID_DIRECTION)
{ {
ride_construction_invalidate_current_track(); ride_construction_invalidate_current_track();
return; return;
@ -3914,7 +3914,7 @@ static void ride_construction_tooldown_entrance_exit(const ScreenCoordsXY& scree
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
CoordsXYZD entranceOrExitCoords = ride_get_entrance_or_exit_position_from_screen_position(screenCoords); CoordsXYZD entranceOrExitCoords = ride_get_entrance_or_exit_position_from_screen_position(screenCoords);
if (gRideEntranceExitPlaceDirection == 255) if (gRideEntranceExitPlaceDirection == INVALID_DIRECTION)
return; return;
auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction( auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction(

View File

@ -237,7 +237,7 @@ private:
newPeep->pathfind_goal.x = 0xFF; newPeep->pathfind_goal.x = 0xFF;
newPeep->pathfind_goal.y = 0xFF; newPeep->pathfind_goal.y = 0xFF;
newPeep->pathfind_goal.z = 0xFF; newPeep->pathfind_goal.z = 0xFF;
newPeep->pathfind_goal.direction = 0xFF; newPeep->pathfind_goal.direction = INVALID_DIRECTION;
uint8_t colour = staff_get_colour(_staffType); uint8_t colour = staff_get_colour(_staffType);
newPeep->tshirt_colour = colour; newPeep->tshirt_colour = colour;

View File

@ -51,7 +51,7 @@ void TerrainSurfaceObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, in
uint32_t imageId = GetImageId({}, 1, 0, 0, false, false); uint32_t imageId = GetImageId({}, 1, 0, 0, false, false);
if (Colour != 255) if (Colour != 255)
{ {
imageId |= Colour << 19 | IMAGE_TYPE_REMAP; imageId |= SPRITE_ID_PALETTE_COLOUR_1(Colour);
} }
int32_t x0 = 0; int32_t x0 = 0;

View File

@ -355,9 +355,9 @@ void virtual_floor_paint(paint_session* session)
} }
} }
uint32_t remap_base = COLOUR_DARK_PURPLE << 19 | IMAGE_TYPE_REMAP; uint32_t remap_base = SPRITE_ID_PALETTE_COLOUR_1(COLOUR_DARK_PURPLE);
uint32_t remap_edge = COLOUR_WHITE << 19 | IMAGE_TYPE_REMAP; uint32_t remap_edge = SPRITE_ID_PALETTE_COLOUR_1(COLOUR_WHITE);
uint32_t remap_lit = COLOUR_DARK_BROWN << 19 | IMAGE_TYPE_REMAP; uint32_t remap_lit = SPRITE_ID_PALETTE_COLOUR_1(COLOUR_DARK_BROWN);
// Edges which are internal to objects (i.e., the tile on both sides // Edges which are internal to objects (i.e., the tile on both sides
// is occupied/lit) are not rendered to provide visual clarity. // is occupied/lit) are not rendered to provide visual clarity.

View File

@ -315,7 +315,7 @@ static uint32_t get_surface_image(
{ session->MapPosition.x >> 5, session->MapPosition.y >> 5 }, grassLength, rotation, offset, grid, underground); { session->MapPosition.x >> 5, session->MapPosition.y >> 5 }, grassLength, rotation, offset, grid, underground);
if (obj->Colour != 255) if (obj->Colour != 255)
{ {
image |= obj->Colour << 19 | IMAGE_TYPE_REMAP; image |= SPRITE_ID_PALETTE_COLOUR_1(obj->Colour);
} }
} }
return image; return image;
@ -330,7 +330,7 @@ static uint32_t get_surface_pattern(uint8_t index, int32_t offset)
image = obj->PatternBaseImageId + offset; image = obj->PatternBaseImageId + offset;
if (obj->Colour != 255) if (obj->Colour != 255)
{ {
image |= obj->Colour << 19 | IMAGE_TYPE_REMAP; image |= SPRITE_ID_PALETTE_COLOUR_1(obj->Colour);
} }
} }
return image; return image;

View File

@ -171,7 +171,7 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons
} }
int32_t primaryColour = tile_element->AsWall()->GetPrimaryColour(); int32_t primaryColour = tile_element->AsWall()->GetPrimaryColour();
uint32_t imageColourFlags = primaryColour << 19 | IMAGE_TYPE_REMAP; uint32_t imageColourFlags = SPRITE_ID_PALETTE_COLOUR_1(primaryColour);
uint32_t dword_141F718 = imageColourFlags + 0x23800006; uint32_t dword_141F718 = imageColourFlags + 0x23800006;
if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR)

View File

@ -1749,7 +1749,7 @@ Peep* Peep::Generate(const CoordsXYZ& coords)
peep->pathfind_goal.x = 0xFF; peep->pathfind_goal.x = 0xFF;
peep->pathfind_goal.y = 0xFF; peep->pathfind_goal.y = 0xFF;
peep->pathfind_goal.z = 0xFF; peep->pathfind_goal.z = 0xFF;
peep->pathfind_goal.direction = 0xFF; peep->pathfind_goal.direction = INVALID_DIRECTION;
peep->item_standard_flags = 0; peep->item_standard_flags = 0;
peep->item_extra_flags = 0; peep->item_extra_flags = 0;
peep->guest_heading_to_ride_id = RIDE_ID_NULL; peep->guest_heading_to_ride_id = RIDE_ID_NULL;
@ -3196,7 +3196,7 @@ void peep_reset_pathfind_goal(Peep* peep)
peep->pathfind_goal.x = 0xFF; peep->pathfind_goal.x = 0xFF;
peep->pathfind_goal.y = 0xFF; peep->pathfind_goal.y = 0xFF;
peep->pathfind_goal.z = 0xFF; peep->pathfind_goal.z = 0xFF;
peep->pathfind_goal.direction = 0xFF; peep->pathfind_goal.direction = INVALID_DIRECTION;
} }
/** /**

View File

@ -616,7 +616,7 @@ static bool staff_path_finding_handyman(Peep* peep)
{ {
peep->staff_mowing_timeout++; peep->staff_mowing_timeout++;
uint8_t litterDirection = 0xFF; uint8_t litterDirection = INVALID_DIRECTION;
uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->NextLoc.x, peep->NextLoc.y); uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->NextLoc.x, peep->NextLoc.y);
if ((peep->staff_orders & STAFF_ORDERS_SWEEPING) && ((gCurrentTicks + peep->sprite_index) & 0xFFF) > 110) if ((peep->staff_orders & STAFF_ORDERS_SWEEPING) && ((gCurrentTicks + peep->sprite_index) & 0xFFF) > 110)
@ -625,7 +625,7 @@ static bool staff_path_finding_handyman(Peep* peep)
} }
Direction direction = INVALID_DIRECTION; Direction direction = INVALID_DIRECTION;
if (litterDirection == 0xFF && (peep->staff_orders & STAFF_ORDERS_MOWING) && peep->staff_mowing_timeout >= 12) if (litterDirection == INVALID_DIRECTION && (peep->staff_orders & STAFF_ORDERS_MOWING) && peep->staff_mowing_timeout >= 12)
{ {
direction = staff_handyman_direction_to_uncut_grass(peep, validDirections); direction = staff_handyman_direction_to_uncut_grass(peep, validDirections);
} }
@ -651,7 +651,7 @@ static bool staff_path_finding_handyman(Peep* peep)
else else
{ {
bool chooseRandom = true; bool chooseRandom = true;
if (litterDirection != 0xFF && pathDirections & (1 << litterDirection)) if (litterDirection != INVALID_DIRECTION && pathDirections & (1 << litterDirection))
{ {
if ((scenario_rand() & 0xFFFF) >= 0x1999) if ((scenario_rand() & 0xFFFF) >= 0x1999)
{ {

View File

@ -1529,7 +1529,7 @@ private:
dst->pathfind_goal.x = 0xFF; dst->pathfind_goal.x = 0xFF;
dst->pathfind_goal.y = 0xFF; dst->pathfind_goal.y = 0xFF;
dst->pathfind_goal.z = 0xFF; dst->pathfind_goal.z = 0xFF;
dst->pathfind_goal.direction = 0xFF; dst->pathfind_goal.direction = INVALID_DIRECTION;
// Guests' favourite ride was only saved in LL. // Guests' favourite ride was only saved in LL.
// Set it to N/A if the save comes from the original or AA. // Set it to N/A if the save comes from the original or AA.

View File

@ -119,7 +119,7 @@ uint8_t gRideEntranceExitPlaceType;
ride_id_t gRideEntranceExitPlaceRideIndex; ride_id_t gRideEntranceExitPlaceRideIndex;
uint8_t gRideEntranceExitPlaceStationIndex; uint8_t gRideEntranceExitPlaceStationIndex;
uint8_t gRideEntranceExitPlacePreviousRideConstructionState; uint8_t gRideEntranceExitPlacePreviousRideConstructionState;
uint8_t gRideEntranceExitPlaceDirection; Direction gRideEntranceExitPlaceDirection;
uint8_t gLastEntranceStyle; uint8_t gLastEntranceStyle;
@ -1091,7 +1091,7 @@ void ride_remove_peeps(Ride* ride)
int32_t exitX = 0; int32_t exitX = 0;
int32_t exitY = 0; int32_t exitY = 0;
int32_t exitZ = 0; int32_t exitZ = 0;
int32_t exitDirection = 255; int32_t exitDirection = INVALID_DIRECTION;
if (stationIndex != -1) if (stationIndex != -1)
{ {
TileCoordsXYZD location = ride_get_exit_location(ride, stationIndex); TileCoordsXYZD location = ride_get_exit_location(ride, stationIndex);
@ -1130,7 +1130,7 @@ void ride_remove_peeps(Ride* ride)
peep->Invalidate(); peep->Invalidate();
if (exitDirection == 255) if (exitDirection == INVALID_DIRECTION)
{ {
CoordsXYZ newLoc = { peep->NextLoc.ToTileCentre(), peep->NextLoc.z }; CoordsXYZ newLoc = { peep->NextLoc.ToTileCentre(), peep->NextLoc.z };
if (peep->GetNextIsSloped()) if (peep->GetNextIsSloped())
@ -6145,7 +6145,7 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(const ScreenC
Ride* ride; Ride* ride;
CoordsXYZD entranceExitCoords{}; CoordsXYZD entranceExitCoords{};
gRideEntranceExitPlaceDirection = 255; gRideEntranceExitPlaceDirection = INVALID_DIRECTION;
CoordsXY unusedCoords; CoordsXY unusedCoords;
get_map_coordinates_from_pos(screenCoords, 0xFFFB, unusedCoords, &interactionType, &tileElement, &viewport); get_map_coordinates_from_pos(screenCoords, 0xFFFB, unusedCoords, &interactionType, &tileElement, &viewport);
if (interactionType != 0) if (interactionType != 0)
@ -6256,7 +6256,7 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(const ScreenC
} }
entranceExitCoords.direction = (entranceExitCoords.direction + 1) & 3; entranceExitCoords.direction = (entranceExitCoords.direction + 1) & 3;
} }
gRideEntranceExitPlaceDirection = 0xFF; gRideEntranceExitPlaceDirection = INVALID_DIRECTION;
} }
else else
{ {
@ -6879,14 +6879,14 @@ void sub_6CB945(Ride* ride)
CoordsXYZ location = { ride->stations[stationId].Start.x * 32, ride->stations[stationId].Start.y * 32, CoordsXYZ location = { ride->stations[stationId].Start.x * 32, ride->stations[stationId].Start.y * 32,
ride->stations[stationId].GetBaseZ() }; ride->stations[stationId].GetBaseZ() };
auto tileHeight = TileCoordsXYZ(location).z; auto tileHeight = TileCoordsXYZ(location).z;
uint8_t direction = 0xFF; uint8_t direction = INVALID_DIRECTION;
bool specialTrack = false; bool specialTrack = false;
TileElement* tileElement = nullptr; TileElement* tileElement = nullptr;
while (true) while (true)
{ {
if (direction != 0xFF) if (direction != INVALID_DIRECTION)
{ {
location.x -= CoordsDirectionDelta[direction].x; location.x -= CoordsDirectionDelta[direction].x;
location.y -= CoordsDirectionDelta[direction].y; location.y -= CoordsDirectionDelta[direction].y;