From bb483b0c5f039844473c5cf489d3911b11fbd105 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Fri, 17 Nov 2017 17:15:55 +0100 Subject: [PATCH] Replace direct access to large scenery colour with helper functions --- src/openrct2-ui/windows/Sign.cpp | 24 ++++++----- src/openrct2-ui/windows/TopToolbar.cpp | 32 ++++++++------ src/openrct2/interface/colour.h | 6 +-- src/openrct2/interface/viewport_interaction.c | 7 ++-- src/openrct2/paint/tile_element/fence.c | 6 +-- .../paint/tile_element/scenery_multiple.c | 12 +++--- src/openrct2/rct1/S4Importer.cpp | 11 +++-- src/openrct2/ride/track_design_save.c | 28 +++++++------ src/openrct2/windows/TileInspector.cpp | 7 ++-- src/openrct2/world/SmallScenery.cpp | 2 +- src/openrct2/world/Wall.cpp | 42 +++++++++++++++---- src/openrct2/world/map.c | 41 ++++++++---------- src/openrct2/world/map.h | 2 - src/openrct2/world/scenery.c | 21 +++++----- 14 files changed, 133 insertions(+), 108 deletions(-) diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 0174ce0a0d..6dbd4f5a17 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -161,13 +161,15 @@ rct_window * window_sign_open(rct_windownumber number) rct_tile_element* tile_element = map_get_first_element_at(view_x / 32, view_y / 32); - while (1){ - if (tile_element_get_type(tile_element) == TILE_ELEMENT_TYPE_SCENERY_MULTIPLE) { + while (1) + { + if (tile_element_get_type(tile_element) == TILE_ELEMENT_TYPE_SCENERY_MULTIPLE) + { rct_scenery_entry* scenery_entry = get_large_scenery_entry(scenery_large_get_type(tile_element)); - if (scenery_entry->large_scenery.scrolling_mode != 0xFF){ - sint32 id = (tile_element->type & 0xC0) | - ((tile_element->properties.scenerymultiple.colour[0] & 0xE0) >> 2) | - ((tile_element->properties.scenerymultiple.colour[1] & 0xE0) >> 5); + if (scenery_entry->large_scenery.scrolling_mode != 0xFF) + { + sint32 id = scenery_large_get_banner_id(tile_element); + if (id == w->number) break; } @@ -226,8 +228,10 @@ static void window_sign_mouseup(rct_window *w, rct_widgetindex widgetIndex) window_close(w); break; case WIDX_SIGN_DEMOLISH: - while (1){ - if (tile_element_get_type(tile_element) == TILE_ELEMENT_TYPE_SCENERY_MULTIPLE) { + while (1) + { + if (tile_element_get_type(tile_element) == TILE_ELEMENT_TYPE_SCENERY_MULTIPLE) + { rct_scenery_entry* scenery_entry = get_large_scenery_entry(scenery_large_get_type(tile_element)); if (scenery_entry->large_scenery.scrolling_mode != 0xFF) { @@ -441,8 +445,8 @@ rct_window * window_sign_small_open(rct_windownumber number){ sint32 view_z = tile_element->base_height << 3; w->frame_no = view_z; - w->list_information_type = tile_element->properties.wall.colour_1 & 0x1F; - w->var_492 = wall_element_get_secondary_colour(tile_element); + w->list_information_type = wall_get_primary_colour(tile_element); + w->var_492 = wall_get_secondary_colour(tile_element); 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 d8be9e2f82..fca0857c35 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -1050,12 +1050,14 @@ static void scenery_eyedropper_tool_down(sint16 x, sint16 y, rct_widgetindex wid { sint32 entryIndex = tileElement->properties.scenery.type; rct_scenery_entry * sceneryEntry = get_small_scenery_entry(entryIndex); - if (sceneryEntry != nullptr) { + if (sceneryEntry != nullptr) + { sint32 sceneryId = get_scenery_id_from_entry_index(OBJECT_TYPE_SMALL_SCENERY, entryIndex); - if (sceneryId != -1 && window_scenery_set_selected_item(sceneryId)) { + if (sceneryId != -1 && window_scenery_set_selected_item(sceneryId)) + { gWindowSceneryRotation = (get_current_rotation() + tile_element_get_direction(tileElement)) & 3; - gWindowSceneryPrimaryColour = tileElement->properties.scenery.colour_1 & 0x1F; - gWindowScenerySecondaryColour = tileElement->properties.scenery.colour_2 & 0x1F; + gWindowSceneryPrimaryColour = scenery_small_get_primary_colour(tileElement); + gWindowScenerySecondaryColour = scenery_small_get_secondary_colour(tileElement); gWindowSceneryEyedropperEnabled = false; } } @@ -1065,12 +1067,14 @@ static void scenery_eyedropper_tool_down(sint16 x, sint16 y, rct_widgetindex wid { sint32 entryIndex = tileElement->properties.wall.type; rct_scenery_entry * sceneryEntry = get_wall_entry(entryIndex); - if (sceneryEntry != nullptr) { + if (sceneryEntry != nullptr) + { sint32 sceneryId = get_scenery_id_from_entry_index(OBJECT_TYPE_WALLS, entryIndex); - if (sceneryId != -1 && window_scenery_set_selected_item(sceneryId)) { - gWindowSceneryPrimaryColour = tileElement->properties.wall.colour_1 & 0x1F; - gWindowScenerySecondaryColour = wall_element_get_secondary_colour(tileElement); - gWindowSceneryTertiaryColour = tileElement->properties.wall.colour_3 & 0x1F; + 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); gWindowSceneryEyedropperEnabled = false; } } @@ -1080,12 +1084,14 @@ static void scenery_eyedropper_tool_down(sint16 x, sint16 y, rct_widgetindex wid { sint32 entryIndex = scenery_large_get_type(tileElement); rct_scenery_entry * sceneryEntry = get_large_scenery_entry(entryIndex); - if (sceneryEntry != nullptr) { + if (sceneryEntry != nullptr) + { sint32 sceneryId = get_scenery_id_from_entry_index(OBJECT_TYPE_LARGE_SCENERY, entryIndex); - if (sceneryId != -1 && window_scenery_set_selected_item(sceneryId)) { + if (sceneryId != -1 && window_scenery_set_selected_item(sceneryId)) + { gWindowSceneryRotation = (get_current_rotation() + tile_element_get_direction(tileElement)) & 3; - gWindowSceneryPrimaryColour = tileElement->properties.scenerymultiple.colour[0] & 0x1F; - gWindowScenerySecondaryColour = tileElement->properties.scenerymultiple.colour[1] & 0x1F; + gWindowSceneryPrimaryColour = scenery_large_get_primary_colour(tileElement); + gWindowScenerySecondaryColour = scenery_large_get_secondary_colour(tileElement); gWindowSceneryEyedropperEnabled = false; } } diff --git a/src/openrct2/interface/colour.h b/src/openrct2/interface/colour.h index 5efb4a8d21..7dc0148e13 100644 --- a/src/openrct2/interface/colour.h +++ b/src/openrct2/interface/colour.h @@ -126,9 +126,9 @@ enum { COLOUR_FLAG_8 = (1 << 8) }; -#define TRANSLUCENT(x) ((x) | COLOUR_FLAG_TRANSLUCENT) -#define NOT_TRANSLUCENT(x) ((x) & ~COLOUR_FLAG_TRANSLUCENT) -#define BASE_COLOUR(x) ((x) & 0x1F) +#define TRANSLUCENT(x) ((x) | COLOUR_FLAG_TRANSLUCENT) +#define NOT_TRANSLUCENT(x) ((x) & ~COLOUR_FLAG_TRANSLUCENT) +#define BASE_COLOUR(x) ((x) & 0x1F) typedef struct rct_colour_map { diff --git a/src/openrct2/interface/viewport_interaction.c b/src/openrct2/interface/viewport_interaction.c index f6c9a60d65..acb4df0d6c 100644 --- a/src/openrct2/interface/viewport_interaction.c +++ b/src/openrct2/interface/viewport_interaction.c @@ -533,10 +533,9 @@ static void viewport_interaction_remove_large_scenery(rct_tile_element *tileElem { rct_scenery_entry *sceneryEntry = get_large_scenery_entry(scenery_large_get_type(tileElement)); - if (sceneryEntry->large_scenery.scrolling_mode != 0xFF){ - sint32 id = (tileElement->type & 0xC0) | - ((tileElement->properties.scenerymultiple.colour[0] & 0xE0) >> 2) | - ((tileElement->properties.scenerymultiple.colour[1] & 0xE0) >> 5); + if (sceneryEntry->large_scenery.scrolling_mode != 0xFF) + { + sint32 id = scenery_large_get_banner_id(tileElement); context_open_detail_window(WD_SIGN, id); } else { gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; diff --git a/src/openrct2/paint/tile_element/fence.c b/src/openrct2/paint/tile_element/fence.c index 27fd80db4f..6405b470bb 100644 --- a/src/openrct2/paint/tile_element/fence.c +++ b/src/openrct2/paint/tile_element/fence.c @@ -146,12 +146,12 @@ void fence_paint(paint_session * session, uint8 direction, sint32 height, rct_ti } - sint32 primaryColour = tile_element->properties.wall.colour_1 & 0x1F; + sint32 primaryColour = wall_get_primary_colour(tile_element); uint32 imageColourFlags = primaryColour << 19 | IMAGE_TYPE_REMAP; uint32 dword_141F718 = imageColourFlags + 0x23800006; if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { - uint8 secondaryColour = wall_element_get_secondary_colour(tile_element); + uint8 secondaryColour = wall_get_secondary_colour(tile_element); imageColourFlags |= secondaryColour << 24 | IMAGE_TYPE_REMAP_2_PLUS; } @@ -346,7 +346,7 @@ void fence_paint(paint_session * session, uint8 direction, sint32 height, rct_ti set_format_arg(0, uint32, 0); set_format_arg(4, uint32, 0); - uint8 secondaryColour = wall_element_get_secondary_colour(tile_element); + uint8 secondaryColour = wall_get_secondary_colour(tile_element); if (dword_141F710 != 0) { secondaryColour = COLOUR_GREY; diff --git a/src/openrct2/paint/tile_element/scenery_multiple.c b/src/openrct2/paint/tile_element/scenery_multiple.c index ac737cf93a..322c36f7a0 100644 --- a/src/openrct2/paint/tile_element/scenery_multiple.c +++ b/src/openrct2/paint/tile_element/scenery_multiple.c @@ -183,7 +183,7 @@ static const boundbox s98E3C4[] = { * * rct2: 0x006B7F0C */ -void scenery_multiple_paint(paint_session * session, uint8 direction, uint16 height, rct_tile_element *tileElement) +void scenery_multiple_paint(paint_session * session, uint8 direction, uint16 height, rct_tile_element * tileElement) { session->InteractionType = VIEWPORT_INTERACTION_ITEM_LARGE_SCENERY; uint32 sequenceNum = scenery_large_get_sequence(tileElement); @@ -194,7 +194,7 @@ void scenery_multiple_paint(paint_session * session, uint8 direction, uint16 hei uint32 image_id = (sequenceNum << 2) + entry->image + 4 + direction; rct_large_scenery_tile *tile = &entry->large_scenery.tiles[sequenceNum]; uint32 dword_F4387C = 0; - image_id |= ((tileElement->properties.scenerymultiple.colour[0] & 0x1F) << 19) | ((tileElement->properties.scenerymultiple.colour[1] & 0x1F) << 24) | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS; + image_id |= SPRITE_ID_PALETTE_COLOUR_2(scenery_large_get_primary_colour(tileElement), scenery_large_get_secondary_colour(tileElement)); LocationXYZ16 boxlength; LocationXYZ16 boxoffset; if (gTrackDesignSaveMode) { @@ -252,12 +252,12 @@ void scenery_multiple_paint(paint_session * session, uint8 direction, uint16 hei // Draw sign text: set_format_arg(0, uint32, 0); set_format_arg(4, uint32, 0); - sint32 textColour = tileElement->properties.scenerymultiple.colour[1] & 0x1F; + sint32 textColour = scenery_large_get_secondary_colour(tileElement); if (dword_F4387C) { textColour = COLOUR_GREY; } textColour = (textColour << 19) | IMAGE_TYPE_REMAP; - uint32 bannerIndex = (tileElement->type & 0xC0) | ((tileElement->properties.scenerymultiple.colour[0] & 0xE0) >> 2) | ((tileElement->properties.scenerymultiple.colour[1] & 0xE0) >> 5); + uint32 bannerIndex = scenery_large_get_banner_id(tileElement); rct_banner *banner = &gBanners[bannerIndex]; rct_string_id stringId = banner->string_idx; if (banner->flags & BANNER_FLAG_LINKED_TO_RIDE) { @@ -337,7 +337,7 @@ void scenery_multiple_paint(paint_session * session, uint8 direction, uint16 hei // Draw scrolling text: set_format_arg(0, uint32, 0); set_format_arg(4, uint32, 0); - uint8 textColour = tileElement->properties.banner.unused & 0x1F; + uint8 textColour = scenery_large_get_secondary_colour(tileElement); if (dword_F4387C) { textColour = COLOUR_GREY; } @@ -346,7 +346,7 @@ void scenery_multiple_paint(paint_session * session, uint8 direction, uint16 hei } // 6B809A: set_format_arg(7, uint8, textColour); - uint32 bannerIndex = (tileElement->type & 0xC0) | ((tileElement->properties.scenerymultiple.colour[0] & 0xE0) >> 2) | ((tileElement->properties.scenerymultiple.colour[1] & 0xE0) >> 5); + uint32 bannerIndex = scenery_large_get_banner_id(tileElement); uint16 scrollMode = entry->large_scenery.scrolling_mode + ((direction + 1) & 0x3); rct_banner *banner = &gBanners[bannerIndex]; set_format_arg(0, rct_string_id, banner->string_idx); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index c3e7c130d5..30ab979b94 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2306,13 +2306,12 @@ private: tileElement->properties.wall.type |= (colour & 7) << 5; break; case TILE_ELEMENT_TYPE_SCENERY_MULTIPLE: - colour = RCT1::GetColour(tileElement->properties.scenerymultiple.colour[0] & 0x1F); - tileElement->properties.scenerymultiple.colour[0] &= 0xE0; - tileElement->properties.scenerymultiple.colour[0] |= colour; + colour = RCT1::GetColour(scenery_large_get_primary_colour(tileElement)); + scenery_large_set_primary_colour(tileElement, colour); + + colour = RCT1::GetColour(scenery_large_get_secondary_colour(tileElement)); + scenery_large_set_secondary_colour(tileElement, colour); - colour = RCT1::GetColour(tileElement->properties.scenerymultiple.colour[1] & 0x1F); - tileElement->properties.scenerymultiple.colour[1] &= 0xE0; - tileElement->properties.scenerymultiple.colour[1] |= colour; break; } } diff --git a/src/openrct2/ride/track_design_save.c b/src/openrct2/ride/track_design_save.c index 7fcc0c3fe2..3deab2b5a8 100644 --- a/src/openrct2/ride/track_design_save.c +++ b/src/openrct2/ride/track_design_save.c @@ -327,11 +327,13 @@ static void track_design_save_add_large_scenery(sint32 x, sint32 y, rct_tile_ele y = y0 + offsetY; z = (z0 + tile->z_offset) / 8; tileElement = map_get_large_scenery_segment(x, y, z, direction, sequence); - if (tileElement != NULL) { - if (sequence == 0) { + if (tileElement != NULL) + { + if (sequence == 0) + { uint8 flags = tileElement->type & 3; - uint8 primaryColour = tileElement->properties.scenerymultiple.colour[0] & 0x1F; - uint8 secondaryColour = tileElement->properties.scenerymultiple.colour[1] & 0x1F; + uint8 primaryColour = scenery_large_get_primary_colour(tileElement); + uint8 secondaryColour = scenery_large_get_secondary_colour(tileElement); track_design_save_push_tile_element_desc(entry, x, y, z, flags, primaryColour, secondaryColour); } @@ -349,8 +351,8 @@ static void track_design_save_add_wall(sint32 x, sint32 y, rct_tile_element *til flags |= tileElement->type & 3; flags |= tileElement->properties.wall.colour_3 << 2; - uint8 secondaryColour = wall_element_get_secondary_colour(tileElement); - uint8 primaryColour = tileElement->properties.wall.colour_1 & 0x1F; + uint8 secondaryColour = wall_get_secondary_colour(tileElement); + uint8 primaryColour = wall_get_primary_colour(tileElement); 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); @@ -510,11 +512,13 @@ static void track_design_save_remove_large_scenery(sint32 x, sint32 y, rct_tile_ y = y0 + offsetY; z = (z0 + tile->z_offset) / 8; tileElement = map_get_large_scenery_segment(x, y, z, direction, sequence); - if (tileElement != NULL) { - if (sequence == 0) { + if (tileElement != NULL) + { + if (sequence == 0) + { uint8 flags = tileElement->type & 3; - uint8 primaryColour = tileElement->properties.scenerymultiple.colour[0] & 0x1F; - uint8 secondaryColour = tileElement->properties.scenerymultiple.colour[1] & 0x1F; + uint8 primaryColour = scenery_large_get_primary_colour(tileElement); + uint8 secondaryColour = scenery_large_get_secondary_colour(tileElement); track_design_save_pop_tile_element_desc(entry, x, y, z, flags, primaryColour, secondaryColour); } @@ -532,8 +536,8 @@ static void track_design_save_remove_wall(sint32 x, sint32 y, rct_tile_element * flags |= tileElement->type & 3; flags |= tileElement->properties.wall.colour_3 << 2; - uint8 secondaryColour = wall_element_get_secondary_colour(tileElement); - uint8 primaryColour = tileElement->properties.wall.colour_1 & 0x1F; + uint8 secondaryColour = wall_get_secondary_colour(tileElement); + uint8 primaryColour = wall_get_primary_colour(tileElement); track_design_save_pop_tile_element(x, y, tileElement); track_design_save_pop_tile_element_desc(entry, x, y, tileElement->base_height, flags, primaryColour, secondaryColour); diff --git a/src/openrct2/windows/TileInspector.cpp b/src/openrct2/windows/TileInspector.cpp index 0979eb701c..e723aae749 100644 --- a/src/openrct2/windows/TileInspector.cpp +++ b/src/openrct2/windows/TileInspector.cpp @@ -1883,10 +1883,9 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) // Banner info rct_scenery_entry *largeSceneryEntry = get_large_scenery_entry(scenery_large_get_type(tileElement)); - if (largeSceneryEntry->large_scenery.scrolling_mode != 0xFF) { - const sint32 bannerIndex = (tileElement->type & 0xC0) | - ((tileElement->properties.scenerymultiple.colour[0] & 0xE0) >> 2) | - ((tileElement->properties.scenerymultiple.colour[1] & 0xE0) >> 5); + if (largeSceneryEntry->large_scenery.scrolling_mode != 0xFF) + { + const sint32 bannerIndex = scenery_large_get_banner_id(tileElement); //window_sign_open(bannerIndex); gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRY_BANNER_TEXT, &gBanners[bannerIndex].string_idx, COLOUR_DARK_GREEN, x, y + 22); } diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index 88ee978474..75b0dbcb27 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -562,4 +562,4 @@ extern "C" *ebx & 0xFF ); } -} \ No newline at end of file +} diff --git a/src/openrct2/world/Wall.cpp b/src/openrct2/world/Wall.cpp index 65b98df087..99846818e6 100644 --- a/src/openrct2/world/Wall.cpp +++ b/src/openrct2/world/Wall.cpp @@ -533,8 +533,8 @@ static money32 WallPlace(uint8 wallType, tileElement->type = edgeSlope | edge | TILE_ELEMENT_TYPE_WALL; - tileElement->properties.wall.colour_1 = primaryColour; - wall_element_set_secondary_colour(tileElement, secondaryColour); + wall_set_primary_colour(tileElement, primaryColour); + wall_set_secondary_colour(tileElement, secondaryColour); if (wallAcrossTrack) { @@ -670,8 +670,8 @@ static money32 WallSetColour(sint16 x, if (flags & GAME_COMMAND_FLAG_APPLY) { rct_scenery_entry * scenery_entry = get_wall_entry(wallElement->properties.wall.type); - wallElement->properties.wall.colour_1 = primaryColour; - wall_element_set_secondary_colour(wallElement, secondaryColour); + wall_set_primary_colour(wallElement, primaryColour); + wall_set_secondary_colour(wallElement, secondaryColour); if (scenery_entry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { @@ -696,21 +696,45 @@ extern "C" wallElement->properties.wall.animation |= (frameNum & 0xF) << 3; } - uint8 wall_element_get_secondary_colour(rct_tile_element * wallElement) + colour_t wall_get_primary_colour(const rct_tile_element * tileElement) { - uint8 secondaryColour = (wallElement->properties.wall.colour_1 & 0xE0) >> 5; + return tileElement->properties.wall.colour_1 & TILE_ELEMENT_COLOUR_MASK; + } + + colour_t wall_get_secondary_colour(rct_tile_element * wallElement) + { + uint8 secondaryColour = (wallElement->properties.wall.colour_1 &~ TILE_ELEMENT_COLOUR_MASK) >> 5; secondaryColour |= (wallElement->flags & 0x60) >> 2; return secondaryColour; } - void wall_element_set_secondary_colour(rct_tile_element * wallElement, uint8 secondaryColour) + colour_t wall_get_tertiary_colour(const rct_tile_element * tileElement) { - wallElement->properties.wall.colour_1 &= 0x1F; + 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 &= 0x9F; + 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/map.c b/src/openrct2/world/map.c index bc964ff363..d3b4dca09e 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -1080,10 +1080,8 @@ void game_command_set_large_scenery_colour(sint32* eax, sint32* ebx, sint32* ecx tile_element_direction, i); - tileElement->properties.scenerymultiple.colour[0] &= 0xE0; - tileElement->properties.scenerymultiple.colour[0] |= colour1; - tileElement->properties.scenerymultiple.colour[1] &= 0xE0; - tileElement->properties.scenerymultiple.colour[1] |= colour2; + scenery_large_set_primary_colour(tileElement, colour1); + scenery_large_set_secondary_colour(tileElement, colour2); map_invalidate_tile_full(currentTile.x, currentTile.y); } @@ -2648,8 +2646,8 @@ void game_command_place_large_scenery(sint32* eax, sint32* ebx, sint32* ecx, sin sint32 x = (sint16)*eax; sint32 y = (sint16)*ecx; sint32 z = (sint16)*ebp; - uint8 colour1 = *edx; - uint8 colour2 = *edx >> 8; + colour_t colour1 = *edx & TILE_ELEMENT_COLOUR_MASK; + colour_t colour2 = (*edx >> 8) & TILE_ELEMENT_COLOUR_MASK; uint8 flags = *ebx; uint8 rotation = *ebx >> 8; uint8 entry_index = *edi; @@ -2840,13 +2838,12 @@ void game_command_place_large_scenery(sint32* eax, sint32* ebx, sint32* ecx, sin scenery_large_set_type(new_tile_element, entry_index); scenery_large_set_sequence(new_tile_element, tile_num); - new_tile_element->properties.scenerymultiple.colour[0] = colour1; - new_tile_element->properties.scenerymultiple.colour[1] = colour2; + scenery_large_set_primary_colour(new_tile_element, colour1); + scenery_large_set_secondary_colour(new_tile_element, colour2); - if (banner_id != 0xFF) { - new_tile_element->type |= banner_id & 0xC0; - new_tile_element->properties.scenerymultiple.colour[0] |= (banner_id & 0x38) << 2; - new_tile_element->properties.scenerymultiple.colour[1] |= (banner_id & 7) << 5; + if (banner_id != 0xFF) + { + scenery_large_set_banner_id(new_tile_element, banner_id); } if (flags & GAME_COMMAND_FLAG_GHOST) { @@ -3481,10 +3478,7 @@ sint32 tile_element_get_banner_index(rct_tile_element *tileElement) if (sceneryEntry->large_scenery.scrolling_mode == 0xFF) return -1; - return - (tileElement->type & TILE_ELEMENT_QUADRANT_MASK) | - ((tileElement->properties.scenerymultiple.colour[0] & 0xE0) >> 2) | - ((tileElement->properties.scenerymultiple.colour[1] & 0xE0) >> 5); + return scenery_large_get_banner_id(tileElement); case TILE_ELEMENT_TYPE_WALL: sceneryEntry = get_wall_entry(tileElement->properties.wall.type); if (sceneryEntry == NULL || sceneryEntry->wall.scrolling_mode == 0xFF) @@ -3581,7 +3575,7 @@ void map_extend_boundary_surface() newTileElement = map_get_surface_element_at(x, y); newTileElement->type = (newTileElement->type & 0x7C) | (existingTileElement->type & 0x83); - newTileElement->properties.surface.slope = existingTileElement->properties.surface.slope & 0xE0; + newTileElement->properties.surface.slope = existingTileElement->properties.surface.slope & TILE_ELEMENT_SLOPE_EDGE_STYLE_MASK; newTileElement->properties.surface.terrain = existingTileElement->properties.surface.terrain; newTileElement->properties.surface.grass_length = existingTileElement->properties.surface.grass_length; newTileElement->properties.surface.ownership = 0; @@ -3912,11 +3906,10 @@ bool sign_set_colour(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 sequ y = y0 + offsetY; z = (z0 + tile->z_offset) / 8; tileElement = map_get_large_scenery_segment(x, y, z, direction, sequence); - if (tileElement != NULL) { - tileElement->properties.scenerymultiple.colour[0] &= 0xE0; - tileElement->properties.scenerymultiple.colour[1] &= 0xE0; - tileElement->properties.scenerymultiple.colour[0] |= mainColour; - tileElement->properties.scenerymultiple.colour[1] |= textColour; + if (tileElement != NULL) + { + scenery_large_set_primary_colour(tileElement, mainColour); + scenery_large_set_secondary_colour(tileElement, textColour); map_invalidate_tile(x, y, tileElement->base_height * 8 , tileElement->clearance_height * 8); } @@ -4230,8 +4223,8 @@ void game_command_set_sign_style(sint32* eax, sint32* ebx, sint32* ecx, sint32* *ebx = 0; return; } - tile_element->properties.wall.colour_1 = mainColour; - wall_element_set_secondary_colour(tile_element, textColour); + wall_set_primary_colour(tile_element, mainColour); + wall_set_secondary_colour(tile_element, textColour); map_invalidate_tile(x, y, tile_element->base_height * 8, tile_element->clearance_height * 8); } else { // large sign diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index 378573e824..fc1af17bbc 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -542,8 +542,6 @@ bool map_is_location_at_edge(sint32 x, sint32 y); void map_obstruction_set_error_text(rct_tile_element *tileElement); uint8 wall_element_get_animation_frame(rct_tile_element *fenceElement); void wall_element_set_animation_frame(rct_tile_element * wallElement, uint8 frameNum); -uint8 wall_element_get_secondary_colour(rct_tile_element * wallElement); -void wall_element_set_secondary_colour(rct_tile_element * wallElement, uint8 secondaryColour); uint32 map_get_available_peep_spawn_index_list(uint32* peepSpawnIndexList); uint16 check_max_allowable_land_rights_for_tile(uint8 x, uint8 y, uint8 base_z); diff --git a/src/openrct2/world/scenery.c b/src/openrct2/world/scenery.c index 48fd14474d..c41736fb64 100644 --- a/src/openrct2/world/scenery.c +++ b/src/openrct2/world/scenery.c @@ -325,37 +325,36 @@ sint32 get_scenery_id_from_entry_index(uint8 objectType, sint32 entryIndex) } } -sint32 scenery_small_get_primary_colour(const rct_tile_element *tileElement) +sint32 scenery_small_get_primary_colour(const rct_tile_element * tileElement) { - return (tileElement->properties.scenery.colour_1 & 0x1F); + return tileElement->properties.scenery.colour_1 & TILE_ELEMENT_COLOUR_MASK; } -sint32 scenery_small_get_secondary_colour(const rct_tile_element *tileElement) +sint32 scenery_small_get_secondary_colour(const rct_tile_element * tileElement) { - return (tileElement->properties.scenery.colour_2 & 0x1F); + return tileElement->properties.scenery.colour_2 & TILE_ELEMENT_COLOUR_MASK; } -void scenery_small_set_primary_colour(rct_tile_element *tileElement, uint32 colour) +void scenery_small_set_primary_colour(rct_tile_element * tileElement, uint32 colour) { assert(colour <= 31); - tileElement->properties.scenery.colour_1 &= ~0x1F; + tileElement->properties.scenery.colour_1 &= ~TILE_ELEMENT_COLOUR_MASK; tileElement->properties.scenery.colour_1 |= colour; - } -void scenery_small_set_secondary_colour(rct_tile_element *tileElement, uint32 colour) +void scenery_small_set_secondary_colour(rct_tile_element * tileElement, uint32 colour) { assert(colour <= 31); - tileElement->properties.scenery.colour_2 &= ~0x1F; + tileElement->properties.scenery.colour_2 &= ~TILE_ELEMENT_COLOUR_MASK; tileElement->properties.scenery.colour_2 |= colour; } -bool scenery_small_get_supports_needed(const rct_tile_element *tileElement) +bool scenery_small_get_supports_needed(const rct_tile_element * tileElement) { return (bool)(tileElement->properties.scenery.colour_1 & MAP_ELEM_SMALL_SCENERY_COLOUR_FLAG_NEEDS_SUPPORTS); } -void scenery_small_set_supports_needed(rct_tile_element *tileElement) +void scenery_small_set_supports_needed(rct_tile_element * tileElement) { tileElement->properties.scenery.colour_1 |= MAP_ELEM_SMALL_SCENERY_COLOUR_FLAG_NEEDS_SUPPORTS; }