From 9da5b5d513e1edaf4bce22641a77528d752e188d Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 20 Jan 2019 12:00:20 +0100 Subject: [PATCH 1/7] Rename path_paint_{box,pole}_support parameter --- .../paint/tile_element/Paint.Path.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 124bc3e130..ad7ae4d588 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -83,10 +83,10 @@ static constexpr const uint8_t byte_98D8A4[] = { void path_paint_box_support( paint_session* session, const TileElement* tileElement, int32_t height, rct_footpath_entry* footpathEntry, - rct_footpath_entry* railingEntry, bool hasFences, uint32_t imageFlags, uint32_t sceneryImageFlags); + rct_footpath_entry* railingEntry, bool hasSupports, uint32_t imageFlags, uint32_t sceneryImageFlags); void path_paint_pole_support( paint_session* session, const TileElement* tileElement, int16_t height, rct_footpath_entry* footpathEntry, - rct_footpath_entry* railingEntry, bool hasFences, uint32_t imageFlags, uint32_t sceneryImageFlags); + rct_footpath_entry* railingEntry, bool hasSupports, uint32_t imageFlags, uint32_t sceneryImageFlags); /* rct2: 0x006A5AE5 */ static void path_bit_lights_paint( @@ -981,7 +981,7 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile void path_paint_box_support( paint_session* session, const TileElement* tileElement, int32_t height, rct_footpath_entry* footpathEntry, - rct_footpath_entry* railingEntry, bool hasFences, uint32_t imageFlags, uint32_t sceneryImageFlags) + rct_footpath_entry* railingEntry, bool hasSupports, uint32_t imageFlags, uint32_t sceneryImageFlags) { PathElement* pathElement = tileElement->AsPath(); @@ -1036,7 +1036,7 @@ void path_paint_box_support( } } - if (!hasFences || !session->DidPassSurface) + if (!hasSupports || !session->DidPassSurface) { sub_98197C( session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, @@ -1073,7 +1073,7 @@ void path_paint_box_support( } } - sub_6A3F61(session, tileElement, edi, height, railingEntry, imageFlags, sceneryImageFlags, hasFences); + sub_6A3F61(session, tileElement, edi, height, railingEntry, imageFlags, sceneryImageFlags, hasSupports); uint16_t ax = 0; if (tileElement->AsPath()->IsSloped()) @@ -1098,7 +1098,7 @@ void path_paint_box_support( paint_util_set_general_support_height(session, height, 0x20); - if (pathElement->IsQueue() || (tileElement->AsPath()->GetEdgesAndCorners() != 0xFF && hasFences)) + if (pathElement->IsQueue() || (tileElement->AsPath()->GetEdgesAndCorners() != 0xFF && hasSupports)) { paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); return; @@ -1135,7 +1135,7 @@ void path_paint_box_support( void path_paint_pole_support( paint_session* session, const TileElement* tileElement, int16_t height, rct_footpath_entry* footpathEntry, - rct_footpath_entry* railingEntry, bool hasFences, uint32_t imageFlags, uint32_t sceneryImageFlags) + rct_footpath_entry* railingEntry, bool hasSupports, uint32_t imageFlags, uint32_t sceneryImageFlags) { PathElement* pathElement = tileElement->AsPath(); @@ -1190,7 +1190,7 @@ void path_paint_pole_support( } } - if (!hasFences || !session->DidPassSurface) + if (!hasSupports || !session->DidPassSurface) { sub_98197C( session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, @@ -1224,7 +1224,7 @@ void path_paint_pole_support( } } - sub_6A3F61(session, tileElement, edi, height, railingEntry, imageFlags, sceneryImageFlags, hasFences); // TODO: arguments + sub_6A3F61(session, tileElement, edi, height, railingEntry, imageFlags, sceneryImageFlags, hasSupports); // TODO: arguments uint16_t ax = 0; if (tileElement->AsPath()->IsSloped()) @@ -1255,7 +1255,7 @@ void path_paint_pole_support( paint_util_set_general_support_height(session, height, 0x20); - if (pathElement->IsQueue() || (tileElement->AsPath()->GetEdgesAndCorners() != 0xFF && hasFences)) + if (pathElement->IsQueue() || (tileElement->AsPath()->GetEdgesAndCorners() != 0xFF && hasSupports)) { paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); return; From 73e25399d329c82396937fc2781bea26ce31221b Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 20 Jan 2019 12:04:08 +0100 Subject: [PATCH 2/7] Rename footpathEntry to railingEntry where appropriate --- src/openrct2/paint/tile_element/Paint.Path.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index ad7ae4d588..3d28614af4 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -322,7 +322,7 @@ static void path_bit_jumping_fountains_paint( */ static void sub_6A4101( paint_session* session, const TileElement* tile_element, uint16_t height, uint32_t ebp, bool word_F3F038, - rct_footpath_entry* footpathEntry, uint32_t base_image_id, uint32_t imageFlags) + rct_footpath_entry* railingEntry, uint32_t base_image_id, uint32_t imageFlags) { if (tile_element->AsPath()->IsQueue()) { @@ -442,7 +442,7 @@ static void sub_6A4101( // If text shown if (direction < 2 && tile_element->AsPath()->GetRideIndex() != RIDE_ID_NULL && imageFlags == 0) { - uint16_t scrollingMode = footpathEntry->scrolling_mode; + uint16_t scrollingMode = railingEntry->scrolling_mode; scrollingMode += direction; set_format_arg(0, uint32_t, 0); @@ -486,7 +486,7 @@ static void sub_6A4101( // save ecx, ebp, esi uint32_t dword_F3EF80 = ebp; - if (!(footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) + if (!(railingEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) { dword_F3EF80 &= 0x0F; } @@ -661,13 +661,13 @@ static void sub_6A4101( * @param tile_element (esp[0]) * @param connectedEdges (bp) (relative to the camera's rotation) * @param height (dx) - * @param footpathEntry (0x00F3EF6C) + * @param railingEntry (0x00F3EF6C) * @param imageFlags (0x00F3EF70) * @param sceneryImageFlags (0x00F3EF74) */ static void sub_6A3F61( paint_session* session, const TileElement* tile_element, uint16_t connectedEdges, uint16_t height, - rct_footpath_entry* footpathEntry, uint32_t imageFlags, uint32_t sceneryImageFlags, bool word_F3F038) + rct_footpath_entry* railingEntry, uint32_t imageFlags, uint32_t sceneryImageFlags, bool word_F3F038) { // eax -- // ebx -- @@ -739,7 +739,7 @@ static void sub_6A3F61( // Redundant zoom-level check removed sub_6A4101( - session, tile_element, height, connectedEdges, word_F3F038, footpathEntry, footpathEntry->image | imageFlags, + session, tile_element, height, connectedEdges, word_F3F038, railingEntry, railingEntry->image | imageFlags, imageFlags); } From 2f0b6a9652afba20498a8e513df5314451c809f3 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 20 Jan 2019 12:07:29 +0100 Subject: [PATCH 3/7] Rename FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE --- src/openrct2/object/FootpathObject.cpp | 2 +- src/openrct2/paint/tile_element/Paint.Path.cpp | 6 +++--- src/openrct2/world/Footpath.h | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/openrct2/object/FootpathObject.cpp b/src/openrct2/object/FootpathObject.cpp index 4c8b302d4c..1915c4a4f2 100644 --- a/src/openrct2/object/FootpathObject.cpp +++ b/src/openrct2/object/FootpathObject.cpp @@ -77,7 +77,7 @@ void FootpathObject::ReadJson(IReadObjectContext* context, const json_t* root) properties, { { "hasSupportImages", FOOTPATH_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE }, - { "hasElevatedPathImages", FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE }, + { "hasElevatedPathImages", RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS }, { "editorOnly", FOOTPATH_ENTRY_FLAG_SHOW_ONLY_IN_SCENARIO_EDITOR }, }); diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 3d28614af4..da76759281 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -486,7 +486,7 @@ static void sub_6A4101( // save ecx, ebp, esi uint32_t dword_F3EF80 = ebp; - if (!(railingEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) + if (!(railingEntry->flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) { dword_F3EF80 &= 0x0F; } @@ -1061,7 +1061,7 @@ void path_paint_box_support( height + boundingBoxZOffset); // TODO: Revert this when path import works correctly. - if (!pathElement->IsQueue() && !(railingEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) + if (!pathElement->IsQueue() && !(railingEntry->flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) { // don't draw } @@ -1216,7 +1216,7 @@ void path_paint_pole_support( boundBoxOffset.y, height + boundingBoxZOffset); // TODO: Revert this when path import works correctly. - if (pathElement->IsQueue() || (railingEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) + if (pathElement->IsQueue() || (railingEntry->flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) { sub_98199C( session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index 3e98402270..ebb557b8a2 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -79,10 +79,14 @@ enum enum { FOOTPATH_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE = (1 << 0), - FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE = (1 << 1), // When elevated FOOTPATH_ENTRY_FLAG_SHOW_ONLY_IN_SCENARIO_EDITOR = (1 << 2), }; +enum +{ + RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS = (1 << 1), // When elevated +}; + enum { FOOTPATH_SEARCH_SUCCESS, From 1f6d4caf7c837ba7e97c050beff7eabf0b0a8326 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 20 Jan 2019 12:20:41 +0100 Subject: [PATCH 4/7] Rename some variables --- .../paint/tile_element/Paint.Path.cpp | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index da76759281..7890ea098f 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -321,12 +321,12 @@ static void path_bit_jumping_fountains_paint( * @param tile_element (esi) */ static void sub_6A4101( - paint_session* session, const TileElement* tile_element, uint16_t height, uint32_t ebp, bool word_F3F038, + paint_session* session, const TileElement* tile_element, uint16_t height, uint32_t connectedEdges, bool word_F3F038, rct_footpath_entry* railingEntry, uint32_t base_image_id, uint32_t imageFlags) { if (tile_element->AsPath()->IsQueue()) { - uint8_t local_ebp = ebp & 0x0F; + uint8_t local_ebp = connectedEdges & 0x0F; if (tile_element->AsPath()->IsSloped()) { switch ((tile_element->AsPath()->GetSlopeDirection() + session->CurrentRotation) @@ -485,10 +485,12 @@ static void sub_6A4101( } // save ecx, ebp, esi - uint32_t dword_F3EF80 = ebp; + uint32_t drawnEdges = connectedEdges; + // If the path is not drawn over the supports, then no corner sprites will be drawn (making double-width paths + // look like connected series of intersections). if (!(railingEntry->flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) { - dword_F3EF80 &= 0x0F; + drawnEdges &= FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; } if (tile_element->AsPath()->IsSloped()) @@ -521,8 +523,7 @@ static void sub_6A4101( return; } - uint8_t local_ebp = ebp & 0x0F; - switch (local_ebp) + switch (connectedEdges & FOOTPATH_PROPERTIES_EDGES_EDGES_MASK) { case 0: // purposely left empty @@ -557,7 +558,7 @@ static void sub_6A4101( sub_98197C( session, 77 + base_image_id, 28, 0, 1, 28, 7, height, 28, 4, height + 2); // bound_box_offset_y seems to be a bug - if (!(dword_F3EF80 & 0x10)) + if (!(drawnEdges & 0x10)) { sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); } @@ -565,7 +566,7 @@ static void sub_6A4101( case 6: sub_98197C(session, 77 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); sub_98197C(session, 78 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); - if (!(dword_F3EF80 & 0x20)) + if (!(drawnEdges & 0x20)) { sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); } @@ -573,7 +574,7 @@ static void sub_6A4101( case 9: sub_98197C(session, 75 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2); sub_98197C(session, 76 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2); - if (!(dword_F3EF80 & 0x80)) + if (!(drawnEdges & 0x80)) { sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); } @@ -583,7 +584,7 @@ static void sub_6A4101( sub_98197C( session, 78 + base_image_id, 0, 28, 28, 1, 7, height, 4, 28, height + 2); // bound_box_offset_x seems to be a bug - if (!(dword_F3EF80 & 0x40)) + if (!(drawnEdges & 0x40)) { sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); } @@ -591,63 +592,63 @@ static void sub_6A4101( case 7: sub_98197C(session, 74 + base_image_id, 0, 4, 32, 1, 7, height, 0, 4, height + 2); - if (!(dword_F3EF80 & 0x10)) + if (!(drawnEdges & 0x10)) { sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); } - if (!(dword_F3EF80 & 0x20)) + if (!(drawnEdges & 0x20)) { sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); } break; case 13: sub_98197C(session, 74 + base_image_id, 0, 28, 32, 1, 7, height, 0, 28, height + 2); - if (!(dword_F3EF80 & 0x40)) + if (!(drawnEdges & 0x40)) { sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); } - if (!(dword_F3EF80 & 0x80)) + if (!(drawnEdges & 0x80)) { sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); } break; case 14: sub_98197C(session, 73 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2); - if (!(dword_F3EF80 & 0x20)) + if (!(drawnEdges & 0x20)) { sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); } - if (!(dword_F3EF80 & 0x40)) + if (!(drawnEdges & 0x40)) { sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); } break; case 11: sub_98197C(session, 73 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2); - if (!(dword_F3EF80 & 0x10)) + if (!(drawnEdges & 0x10)) { sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); } - if (!(dword_F3EF80 & 0x80)) + if (!(drawnEdges & 0x80)) { sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); } break; case 15: - if (!(dword_F3EF80 & 0x10)) + if (!(drawnEdges & 0x10)) { sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); } - if (!(dword_F3EF80 & 0x20)) + if (!(drawnEdges & 0x20)) { sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); } - if (!(dword_F3EF80 & 0x40)) + if (!(drawnEdges & 0x40)) { sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); } - if (!(dword_F3EF80 & 0x80)) + if (!(drawnEdges & 0x80)) { sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); } From ad2698df0da6efbd31c2a46f943499401369ebee Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 20 Jan 2019 12:26:57 +0100 Subject: [PATCH 5/7] Move 'should draw path over supports' to tile element --- src/openrct2/paint/tile_element/Paint.Path.cpp | 6 +++--- src/openrct2/world/Footpath.cpp | 10 ++++++++++ src/openrct2/world/TileElement.h | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 7890ea098f..4d7cacb68b 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -488,7 +488,7 @@ static void sub_6A4101( uint32_t drawnEdges = connectedEdges; // If the path is not drawn over the supports, then no corner sprites will be drawn (making double-width paths // look like connected series of intersections). - if (!(railingEntry->flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) + if (!tile_element->AsPath()->ShouldDrawPathOverSupports()) { drawnEdges &= FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; } @@ -1062,7 +1062,7 @@ void path_paint_box_support( height + boundingBoxZOffset); // TODO: Revert this when path import works correctly. - if (!pathElement->IsQueue() && !(railingEntry->flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) + if (!pathElement->IsQueue() && !pathElement->ShouldDrawPathOverSupports()) { // don't draw } @@ -1217,7 +1217,7 @@ void path_paint_pole_support( boundBoxOffset.y, height + boundingBoxZOffset); // TODO: Revert this when path import works correctly. - if (pathElement->IsQueue() || (railingEntry->flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) + if (pathElement->IsQueue() || pathElement->ShouldDrawPathOverSupports()) { sub_98199C( session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index eed9ab5b8e..9b56365eee 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -2135,6 +2135,16 @@ void PathElement::SetQueueBannerDirection(uint8_t direction) type |= (direction << 6); } +bool PathElement::ShouldDrawPathOverSupports() +{ + return (GetRailingEntry()->flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS); +} + +void PathElement::SetShouldDrawPathOverSupports(bool on) +{ + log_verbose("Setting 'draw path over supports' to %d", (size_t)on); +} + /** * * rct2: 0x006A8B12 diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 7259e98d9c..990a7e75df 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -228,6 +228,9 @@ public: void SetAdditionStatus(uint8_t newStatus); uint8_t GetRCT1PathType() const; + + bool ShouldDrawPathOverSupports(); + void SetShouldDrawPathOverSupports(bool on); }; assert_struct_size(PathElement, 8); From d000457fb5671fb05bd6f73d2f8afd84dcc03415 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 20 Jan 2019 14:56:12 +0100 Subject: [PATCH 6/7] Rename more occurrences to railingEntry --- src/openrct2/object/FootpathObject.cpp | 2 +- src/openrct2/paint/Supports.cpp | 32 +++++++++++++------------- src/openrct2/paint/Supports.h | 4 ++-- src/openrct2/world/Footpath.h | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/openrct2/object/FootpathObject.cpp b/src/openrct2/object/FootpathObject.cpp index 1915c4a4f2..e9fa6d7ec3 100644 --- a/src/openrct2/object/FootpathObject.cpp +++ b/src/openrct2/object/FootpathObject.cpp @@ -76,7 +76,7 @@ void FootpathObject::ReadJson(IReadObjectContext* context, const json_t* root) _legacyType.flags = ObjectJsonHelpers::GetFlags( properties, { - { "hasSupportImages", FOOTPATH_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE }, + { "hasSupportImages", RAILING_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE }, { "hasElevatedPathImages", RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS }, { "editorOnly", FOOTPATH_ENTRY_FLAG_SHOW_ONLY_IN_SCENARIO_EDITOR }, }); diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index 3041e57a1d..e2c3a841c7 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -1076,14 +1076,14 @@ bool metal_b_supports_paint_setup( * @param special (ax) * @param height (dx) * @param imageColourFlags (ebp) - * @param pathEntry (0x00F3EF6C) + * @param railingEntry (0x00F3EF6C) * @param[out] underground (Carry Flag) * * @return Whether supports were drawn */ bool path_a_supports_paint_setup( paint_session* session, int32_t supportType, int32_t special, int32_t height, uint32_t imageColourFlags, - rct_footpath_entry* pathEntry, bool* underground) + rct_footpath_entry* railingEntry, bool* underground) { if (underground != nullptr) { @@ -1116,7 +1116,7 @@ bool path_a_supports_paint_setup( if (session->Support.slope & 0x20) { // save dx2 - sub_98196C(session, (pathEntry->bridge_image + 48) | imageColourFlags, 0, 0, 32, 32, 0, baseHeight - 2); + sub_98196C(session, (railingEntry->bridge_image + 48) | imageColourFlags, 0, 0, 32, 32, 0, baseHeight - 2); hasSupports = true; } else if (session->Support.slope & 0x10) @@ -1130,7 +1130,7 @@ bool path_a_supports_paint_setup( } uint32_t imageId = (supportType * 24) + word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK] - + pathEntry->bridge_image; + + railingEntry->bridge_image; sub_98197C(session, imageId | imageColourFlags, 0, 0, 32, 32, 11, baseHeight, 0, 0, baseHeight + 2); baseHeight += 16; @@ -1151,7 +1151,7 @@ bool path_a_supports_paint_setup( } uint32_t ebx = (supportType * 24) + word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK] - + pathEntry->bridge_image; + + railingEntry->bridge_image; sub_98197C(session, ebx | imageColourFlags, 0, 0, 32, 32, 11, baseHeight, 0, 0, baseHeight + 2); @@ -1163,7 +1163,7 @@ bool path_a_supports_paint_setup( { if (baseHeight & 0x10 || heightSteps == 1 || baseHeight + 16 == session->WaterHeight) { - uint32_t imageId = (supportType * 24) + pathEntry->bridge_image + 23; + uint32_t imageId = (supportType * 24) + railingEntry->bridge_image + 23; sub_98196C(session, imageId | imageColourFlags, 0, 0, 32, 32, ((heightSteps == 1) ? 7 : 12), baseHeight); heightSteps -= 1; @@ -1172,7 +1172,7 @@ bool path_a_supports_paint_setup( } else { - uint32_t imageId = (supportType * 24) + pathEntry->bridge_image + 22; + uint32_t imageId = (supportType * 24) + railingEntry->bridge_image + 22; sub_98196C(session, imageId | imageColourFlags, 0, 0, 32, 32, ((heightSteps == 2) ? 23 : 28), baseHeight); heightSteps -= 2; @@ -1185,7 +1185,7 @@ bool path_a_supports_paint_setup( { uint16_t specialIndex = (special - 1) & 0xFFFF; - uint32_t imageId = pathEntry->bridge_image + 55 + specialIndex; + uint32_t imageId = railingEntry->bridge_image + 55 + specialIndex; unk_supports_desc supportsDesc = byte_98D8D4[specialIndex]; unk_supports_desc_bound_box boundBox = supportsDesc.bounding_box; @@ -1224,13 +1224,13 @@ bool path_a_supports_paint_setup( * @param special (ax) * @param height (dx) * @param imageColourFlags (ebp) - * @param pathEntry (0x00F3EF6C) + * @param railingEntry (0x00F3EF6C) * * @return Whether supports were drawn */ bool path_b_supports_paint_setup( paint_session* session, int32_t segment, int32_t special, int32_t height, uint32_t imageColourFlags, - rct_footpath_entry* pathEntry) + rct_footpath_entry* railingEntry) { support_height* supportSegments = session->SupportSegments; @@ -1252,7 +1252,7 @@ bool path_b_supports_paint_setup( uint16_t baseHeight; if ((supportSegments[segment].slope & 0x20) || (height - supportSegments[segment].height < 6) - || !(pathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE)) + || !(railingEntry->flags & RAILING_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE)) { baseHeight = supportSegments[segment].height; } @@ -1262,7 +1262,7 @@ bool path_b_supports_paint_setup( baseHeight = supportSegments[segment].height; sub_98196C( - session, (pathEntry->bridge_image + 37 + imageOffset) | imageColourFlags, loc_97AF20[segment].x, + session, (railingEntry->bridge_image + 37 + imageOffset) | imageColourFlags, loc_97AF20[segment].x, loc_97AF20[segment].y, 0, 0, 5, baseHeight); baseHeight += 6; } @@ -1281,7 +1281,7 @@ bool path_b_supports_paint_setup( if (heightDiff > 0) { sub_98196C( - session, (pathEntry->bridge_image + 20 + (heightDiff - 1)) | imageColourFlags, loc_97AF20[segment].x, + session, (railingEntry->bridge_image + 20 + (heightDiff - 1)) | imageColourFlags, loc_97AF20[segment].x, loc_97AF20[segment].y, 0, 0, heightDiff - 1, baseHeight); } @@ -1314,7 +1314,7 @@ bool path_b_supports_paint_setup( } sub_98196C( - session, (pathEntry->bridge_image + 20 + (z - 1)) | imageColourFlags, loc_97AF20[segment].x, + session, (railingEntry->bridge_image + 20 + (z - 1)) | imageColourFlags, loc_97AF20[segment].x, loc_97AF20[segment].y, 0, 0, (z - 1), baseHeight); baseHeight += z; @@ -1325,7 +1325,7 @@ bool path_b_supports_paint_setup( break; } - uint32_t imageId = pathEntry->bridge_image + 20 + (z - 1); + uint32_t imageId = railingEntry->bridge_image + 20 + (z - 1); if (z == 16) { imageId += 1; @@ -1359,7 +1359,7 @@ bool path_b_supports_paint_setup( break; } - uint32_t imageId = pathEntry->bridge_image + 20 + (z - 1); + uint32_t imageId = railingEntry->bridge_image + 20 + (z - 1); sub_98197C( session, imageId | imageColourFlags, loc_97AF20[segment].x, loc_97AF20[segment].y, 0, 0, 0, baseHeight, loc_97AF20[segment].x, loc_97AF20[segment].y, baseHeight); diff --git a/src/openrct2/paint/Supports.h b/src/openrct2/paint/Supports.h index e71078eedd..75b7e3a47f 100644 --- a/src/openrct2/paint/Supports.h +++ b/src/openrct2/paint/Supports.h @@ -23,10 +23,10 @@ bool metal_b_supports_paint_setup( paint_session* session, uint8_t supportType, uint8_t segment, int32_t special, int32_t height, uint32_t imageColourFlags); bool path_a_supports_paint_setup( paint_session* session, int32_t supportType, int32_t special, int32_t height, uint32_t imageColourFlags, - rct_footpath_entry* pathEntry, bool* underground); + rct_footpath_entry* railingEntry, bool* underground); bool path_b_supports_paint_setup( paint_session* session, int32_t supportType, int32_t special, int32_t height, uint32_t imageColourFlags, - rct_footpath_entry* pathEntry); + rct_footpath_entry* railingEntry); // There are 13 types of metal supports. A graphic showing all of them is available here: // https://cloud.githubusercontent.com/assets/737603/19420485/7eaba28e-93ec-11e6-83cb-03190accc094.png diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index ebb557b8a2..f4c70171bc 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -78,12 +78,12 @@ enum enum { - FOOTPATH_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE = (1 << 0), FOOTPATH_ENTRY_FLAG_SHOW_ONLY_IN_SCENARIO_EDITOR = (1 << 2), }; enum { + RAILING_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE = (1 << 0), RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS = (1 << 1), // When elevated }; From cd8227c75683e3ecb7b09936f051c5791122ea68 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 20 Jan 2019 17:29:27 +0100 Subject: [PATCH 7/7] Clean up magic numbers in footpath corner drawing --- .../paint/tile_element/Paint.Path.cpp | 39 +++++++++---------- src/openrct2/world/Footpath.h | 8 ++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 4d7cacb68b..9fef67b038 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -484,13 +484,12 @@ static void sub_6A4101( return; } - // save ecx, ebp, esi - uint32_t drawnEdges = connectedEdges; + uint32_t drawnCorners = 0; // If the path is not drawn over the supports, then no corner sprites will be drawn (making double-width paths // look like connected series of intersections). - if (!tile_element->AsPath()->ShouldDrawPathOverSupports()) + if (tile_element->AsPath()->ShouldDrawPathOverSupports()) { - drawnEdges &= FOOTPATH_PROPERTIES_EDGES_EDGES_MASK; + drawnCorners = (connectedEdges & FOOTPATH_PROPERTIES_EDGES_CORNERS_MASK) >> 4; } if (tile_element->AsPath()->IsSloped()) @@ -558,7 +557,7 @@ static void sub_6A4101( sub_98197C( session, 77 + base_image_id, 28, 0, 1, 28, 7, height, 28, 4, height + 2); // bound_box_offset_y seems to be a bug - if (!(drawnEdges & 0x10)) + if (!(drawnCorners & FOOTPATH_CORNER_0)) { sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); } @@ -566,7 +565,7 @@ static void sub_6A4101( case 6: sub_98197C(session, 77 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); sub_98197C(session, 78 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); - if (!(drawnEdges & 0x20)) + if (!(drawnCorners & FOOTPATH_CORNER_1)) { sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); } @@ -574,7 +573,7 @@ static void sub_6A4101( case 9: sub_98197C(session, 75 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2); sub_98197C(session, 76 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2); - if (!(drawnEdges & 0x80)) + if (!(drawnCorners & FOOTPATH_CORNER_3)) { sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); } @@ -584,7 +583,7 @@ static void sub_6A4101( sub_98197C( session, 78 + base_image_id, 0, 28, 28, 1, 7, height, 4, 28, height + 2); // bound_box_offset_x seems to be a bug - if (!(drawnEdges & 0x40)) + if (!(drawnCorners & FOOTPATH_CORNER_2)) { sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); } @@ -592,63 +591,63 @@ static void sub_6A4101( case 7: sub_98197C(session, 74 + base_image_id, 0, 4, 32, 1, 7, height, 0, 4, height + 2); - if (!(drawnEdges & 0x10)) + if (!(drawnCorners & FOOTPATH_CORNER_0)) { sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); } - if (!(drawnEdges & 0x20)) + if (!(drawnCorners & FOOTPATH_CORNER_1)) { sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); } break; case 13: sub_98197C(session, 74 + base_image_id, 0, 28, 32, 1, 7, height, 0, 28, height + 2); - if (!(drawnEdges & 0x40)) + if (!(drawnCorners & FOOTPATH_CORNER_2)) { sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); } - if (!(drawnEdges & 0x80)) + if (!(drawnCorners & FOOTPATH_CORNER_3)) { sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); } break; case 14: sub_98197C(session, 73 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2); - if (!(drawnEdges & 0x20)) + if (!(drawnCorners & FOOTPATH_CORNER_1)) { sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); } - if (!(drawnEdges & 0x40)) + if (!(drawnCorners & FOOTPATH_CORNER_2)) { sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); } break; case 11: sub_98197C(session, 73 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2); - if (!(drawnEdges & 0x10)) + if (!(drawnCorners & FOOTPATH_CORNER_0)) { sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); } - if (!(drawnEdges & 0x80)) + if (!(drawnCorners & FOOTPATH_CORNER_3)) { sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); } break; case 15: - if (!(drawnEdges & 0x10)) + if (!(drawnCorners & FOOTPATH_CORNER_0)) { sub_98197C(session, 84 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); } - if (!(drawnEdges & 0x20)) + if (!(drawnCorners & FOOTPATH_CORNER_1)) { sub_98197C(session, 85 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); } - if (!(drawnEdges & 0x40)) + if (!(drawnCorners & FOOTPATH_CORNER_2)) { sub_98197C(session, 86 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); } - if (!(drawnEdges & 0x80)) + if (!(drawnCorners & FOOTPATH_CORNER_3)) { sub_98197C(session, 83 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); } diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index f4c70171bc..1457a4a387 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -111,6 +111,14 @@ enum RAISE_FOOTPATH_FLAG = (1 << 4) }; +enum +{ + FOOTPATH_CORNER_0 = (1 << 0), + FOOTPATH_CORNER_1 = (1 << 1), + FOOTPATH_CORNER_2 = (1 << 2), + FOOTPATH_CORNER_3 = (1 << 3), +}; + extern uint8_t gFootpathProvisionalFlags; extern LocationXYZ16 gFootpathProvisionalPosition; extern uint8_t gFootpathProvisionalType;