From dcabdeb8058e41aadf4a5b4e1c5a99d6ae9ce332 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Mon, 17 Sep 2018 14:22:17 +0200 Subject: [PATCH] Move wall colour functions over to the struct methods --- src/openrct2-ui/windows/Sign.cpp | 4 +- src/openrct2-ui/windows/TopToolbar.cpp | 6 +-- .../paint/tile_element/Paint.Wall.cpp | 8 +-- src/openrct2/ride/TrackDesignSave.cpp | 8 +-- src/openrct2/world/Map.cpp | 4 +- src/openrct2/world/Wall.cpp | 51 +++---------------- src/openrct2/world/Wall.h | 6 --- 7 files changed, 21 insertions(+), 66 deletions(-) diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 20bd35662c..6d05f66b22 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -423,8 +423,8 @@ rct_window* window_sign_small_open(rct_windownumber number) int32_t view_z = tile_element->base_height << 3; w->frame_no = view_z; - w->list_information_type = wall_get_primary_colour(tile_element); - w->var_492 = wall_get_secondary_colour(tile_element); + w->list_information_type = tile_element->AsWall()->GetPrimaryColour(); + w->var_492 = tile_element->AsWall()->GetSecondaryColour(); w->var_48C = tile_element->properties.wall.type; view_x += 16; diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 58b23967f8..950d0e6c9a 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -1087,9 +1087,9 @@ static void scenery_eyedropper_tool_down(int16_t x, int16_t y, rct_widgetindex w int32_t sceneryId = get_scenery_id_from_entry_index(OBJECT_TYPE_WALLS, entryIndex); if (sceneryId != -1 && window_scenery_set_selected_item(sceneryId)) { - gWindowSceneryPrimaryColour = wall_get_primary_colour(tileElement); - gWindowScenerySecondaryColour = wall_get_secondary_colour(tileElement); - gWindowSceneryTertiaryColour = wall_get_tertiary_colour(tileElement); + gWindowSceneryPrimaryColour = tileElement->AsWall()->GetPrimaryColour(); + gWindowScenerySecondaryColour = tileElement->AsWall()->GetSecondaryColour(); + gWindowSceneryTertiaryColour = tileElement->AsWall()->GetTertiaryColour(); gWindowSceneryEyedropperEnabled = false; } } diff --git a/src/openrct2/paint/tile_element/Paint.Wall.cpp b/src/openrct2/paint/tile_element/Paint.Wall.cpp index 2738dd9b9b..1eed64340f 100644 --- a/src/openrct2/paint/tile_element/Paint.Wall.cpp +++ b/src/openrct2/paint/tile_element/Paint.Wall.cpp @@ -170,20 +170,20 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons frameNum = (gCurrentTicks & 7) * 2; } - int32_t primaryColour = wall_get_primary_colour(tile_element); + int32_t primaryColour = tile_element->AsWall()->GetPrimaryColour(); uint32_t imageColourFlags = primaryColour << 19 | IMAGE_TYPE_REMAP; uint32_t dword_141F718 = imageColourFlags + 0x23800006; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { - uint8_t secondaryColour = wall_get_secondary_colour(tile_element); + uint8_t secondaryColour = tile_element->AsWall()->GetSecondaryColour(); imageColourFlags |= secondaryColour << 24 | IMAGE_TYPE_REMAP_2_PLUS; } uint32_t tertiaryColour = 0; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { - tertiaryColour = wall_get_tertiary_colour(tile_element); + tertiaryColour = tile_element->AsWall()->GetTertiaryColour(); imageColourFlags &= 0x0DFFFFFFF; } @@ -413,7 +413,7 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons set_format_arg(0, uint32_t, 0); set_format_arg(4, uint32_t, 0); - uint8_t secondaryColour = wall_get_secondary_colour(tile_element); + uint8_t secondaryColour = tile_element->AsWall()->GetSecondaryColour(); if (dword_141F710 != 0) { diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index 1cce540877..9f8f00df2c 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -359,10 +359,10 @@ static void track_design_save_add_wall(int32_t x, int32_t y, rct_tile_element* t uint8_t flags = 0; flags |= tileElement->type & 3; - flags |= wall_get_tertiary_colour(tileElement) << 2; + flags |= tileElement->AsWall()->GetTertiaryColour() << 2; - uint8_t secondaryColour = wall_get_secondary_colour(tileElement); - uint8_t primaryColour = wall_get_primary_colour(tileElement); + uint8_t secondaryColour = tileElement->AsWall()->GetSecondaryColour(); + uint8_t primaryColour = tileElement->AsWall()->GetPrimaryColour(); track_design_save_push_tile_element(x, y, tileElement); track_design_save_push_tile_element_desc(entry, x, y, tileElement->base_height, flags, primaryColour, secondaryColour); @@ -547,7 +547,7 @@ static void track_design_save_remove_wall(int32_t x, int32_t y, rct_tile_element uint8_t flags = 0; flags |= tileElement->type & 3; - flags |= wall_get_tertiary_colour(tileElement) << 2; + flags |= tileElement->AsWall()->GetTertiaryColour() << 2; track_design_save_pop_tile_element(x, y, tileElement); track_design_save_pop_tile_element_desc(entry, x, y, tileElement->base_height, flags); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 67e2d90151..26c6e005cb 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -4408,8 +4408,8 @@ void game_command_set_sign_style( *ebx = 0; return; } - wall_set_primary_colour(tileElement, mainColour); - wall_set_secondary_colour(tileElement, textColour); + tileElement->AsWall()->SetPrimaryColour(mainColour); + tileElement->AsWall()->SetSecondaryColour(textColour); map_invalidate_tile(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8); } diff --git a/src/openrct2/world/Wall.cpp b/src/openrct2/world/Wall.cpp index 008e7f4cbb..69019a8234 100644 --- a/src/openrct2/world/Wall.cpp +++ b/src/openrct2/world/Wall.cpp @@ -515,8 +515,8 @@ static money32 WallPlace( tileElement->type = edgeSlope | edge | TILE_ELEMENT_TYPE_WALL; - wall_set_primary_colour(tileElement, primaryColour); - wall_set_secondary_colour(tileElement, secondaryColour); + tileElement->AsWall()->SetPrimaryColour(primaryColour); + tileElement->AsWall()->SetSecondaryColour(secondaryColour); if (wallAcrossTrack) { @@ -531,7 +531,7 @@ static money32 WallPlace( if (wallEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { - wall_set_tertiary_colour(tileElement, tertiaryColour); + tileElement->AsWall()->SetTertiaryColour(tertiaryColour); } if (flags & GAME_COMMAND_FLAG_GHOST) @@ -583,12 +583,12 @@ static money32 WallSetColour( if (flags & GAME_COMMAND_FLAG_APPLY) { rct_scenery_entry* scenery_entry = get_wall_entry(wallElement->properties.wall.type); - wall_set_primary_colour(wallElement, primaryColour); - wall_set_secondary_colour(wallElement, secondaryColour); + wallElement->AsWall()->SetPrimaryColour(primaryColour); + wallElement->AsWall()->SetSecondaryColour(secondaryColour); if (scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { - wall_set_tertiary_colour(wallElement, tertiaryColour); + wallElement->AsWall()->SetTertiaryColour(tertiaryColour); } map_invalidate_tile_zoom1(x, y, z, z + 72); } @@ -607,45 +607,6 @@ void wall_set_animation_frame(rct_tile_element* wallElement, uint8_t frameNum) wallElement->properties.wall.animation |= (frameNum & 0xF) << 3; } -colour_t wall_get_primary_colour(const rct_tile_element* tileElement) -{ - return tileElement->properties.wall.colour_1 & TILE_ELEMENT_COLOUR_MASK; -} - -colour_t wall_get_secondary_colour(const rct_tile_element* wallElement) -{ - uint8_t secondaryColour = (wallElement->properties.wall.colour_1 & ~TILE_ELEMENT_COLOUR_MASK) >> 5; - secondaryColour |= (wallElement->flags & 0x60) >> 2; - return secondaryColour; -} - -colour_t wall_get_tertiary_colour(const rct_tile_element* tileElement) -{ - return tileElement->properties.wall.colour_3 & TILE_ELEMENT_COLOUR_MASK; -} - -void wall_set_primary_colour(rct_tile_element* tileElement, colour_t colour) -{ - assert(colour <= 31); - tileElement->properties.wall.colour_1 &= ~TILE_ELEMENT_COLOUR_MASK; - tileElement->properties.wall.colour_1 |= colour; -} - -void wall_set_secondary_colour(rct_tile_element* wallElement, colour_t secondaryColour) -{ - wallElement->properties.wall.colour_1 &= TILE_ELEMENT_COLOUR_MASK; - wallElement->properties.wall.colour_1 |= (secondaryColour & 0x7) << 5; - wallElement->flags &= ~0x60; - wallElement->flags |= (secondaryColour & 0x18) << 2; -} - -void wall_set_tertiary_colour(rct_tile_element* tileElement, colour_t colour) -{ - assert(colour <= 31); - tileElement->properties.wall.colour_3 &= ~TILE_ELEMENT_COLOUR_MASK; - tileElement->properties.wall.colour_3 |= colour; -} - /** * * rct2: 0x006E588E diff --git a/src/openrct2/world/Wall.h b/src/openrct2/world/Wall.h index 29b352148f..4232395034 100644 --- a/src/openrct2/world/Wall.h +++ b/src/openrct2/world/Wall.h @@ -20,12 +20,6 @@ enum WALL_ANIMATION_FLAG_ALL_FLAGS = WALL_ANIMATION_FLAG_ACROSS_TRACK | WALL_ANIMATION_FLAG_DIRECTION_BACKWARD }; -colour_t wall_get_primary_colour(const rct_tile_element* tileElement); -colour_t wall_get_secondary_colour(const rct_tile_element* wallElement); -colour_t wall_get_tertiary_colour(const rct_tile_element* tileElement); -void wall_set_primary_colour(rct_tile_element* tileElement, colour_t colour); -void wall_set_secondary_colour(rct_tile_element* wallElement, colour_t secondaryColour); -void wall_set_tertiary_colour(rct_tile_element* tileElement, colour_t colour); uint8_t wall_get_animation_frame(const rct_tile_element* fenceElement); void wall_set_animation_frame(rct_tile_element* wallElement, uint8_t frameNum);