From 35b91037e8635111f40d1c7f29eae70467506eef Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 29 Jan 2017 10:15:29 +0000 Subject: [PATCH] Refactor of footpath labeling enums --- src/openrct2/object/FootpathObject.cpp | 6 ++--- src/openrct2/paint/map_element/path.c | 32 +++++++++++++------------- src/openrct2/paint/supports.c | 2 +- src/openrct2/world/footpath.h | 12 +++++++--- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/openrct2/object/FootpathObject.cpp b/src/openrct2/object/FootpathObject.cpp index e72b3fc171..ac89f49a2d 100644 --- a/src/openrct2/object/FootpathObject.cpp +++ b/src/openrct2/object/FootpathObject.cpp @@ -27,7 +27,7 @@ extern "C" void FootpathObject::ReadLegacy(IReadObjectContext * context, IStream * stream) { stream->Seek(10, STREAM_SEEK_CURRENT); - _legacyType.var_0A = stream->ReadValue(); + _legacyType.support_type = stream->ReadValue(); _legacyType.flags = stream->ReadValue(); _legacyType.scrolling_mode = stream->ReadValue(); stream->Seek(1, STREAM_SEEK_CURRENT); @@ -36,9 +36,9 @@ void FootpathObject::ReadLegacy(IReadObjectContext * context, IStream * stream) GetImageTable()->Read(context, stream); // Validate properties - if (_legacyType.var_0A > 1) + if (_legacyType.support_type >= FOOTPATH_ENTRY_SUPPORT_TYPE_COUNT) { - context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "VAR_0A can not be greater than 1."); + context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "SUPPORT_TYPE not supported."); } } diff --git a/src/openrct2/paint/map_element/path.c b/src/openrct2/paint/map_element/path.c index 6f5bf59374..89e8c5038c 100644 --- a/src/openrct2/paint/map_element/path.c +++ b/src/openrct2/paint/map_element/path.c @@ -82,9 +82,9 @@ const uint8 byte_98D8A4[] = { 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0 }; -void loc_6A37C9(rct_map_element * mapElement, sint32 height, rct_footpath_entry * footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); +void path_paint_pole_support(rct_map_element * mapElement, sint32 height, rct_footpath_entry * footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); -void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); +void path_paint_box_support(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags); /* rct2: 0x006A5AE5 */ static void path_bit_lights_paint(rct_scenery_entry* pathBitEntry, rct_map_element* mapElement, sint32 height, uint8 edges, uint32 pathBitImageFlags) { @@ -287,7 +287,7 @@ static void path_bit_jumping_fountains_paint(rct_scenery_entry* pathBitEntry, rc */ static void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, bool word_F3F038, rct_footpath_entry * footpathEntry, uint32 base_image_id, uint32 imageFlags) { - if (map_element->type & 1) { + if (footpath_element_is_queue(map_element)) { uint8 local_ebp = ebp & 0x0F; if (footpath_element_is_sloped(map_element)) { switch ((map_element->properties.path.type + get_current_rotation()) & 0x03) { @@ -429,7 +429,7 @@ static void sub_6A4101(rct_map_element * map_element, uint16 height, uint32 ebp, // save ecx, ebp, esi uint32 dword_F3EF80 = ebp; - if (!(footpathEntry->flags & FOOTPATH_ENTRY_FLAG_2)) { + if (!(footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) { dword_F3EF80 &= 0x0F; } @@ -680,7 +680,7 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) uint32 imageFlags = 0; if (gTrackDesignSaveMode) { - if (map_element->type & 1) { + if (footpath_element_is_queue(map_element)) { if (map_element->properties.path.ride_index != gTrackDesignSaveRideIndex) { return; } @@ -767,10 +767,10 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) uint8 pathType = (map_element->properties.path.type & 0xF0) >> 4; rct_footpath_entry * footpathEntry = gFootpathEntries[pathType]; - if (footpathEntry->var_0A == 0) { - loc_6A37C9(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); + if (footpathEntry->support_type == FOOTPATH_ENTRY_SUPPORT_TYPE_POLE) { + path_paint_pole_support(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); } else { - loc_6A3B57(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); + path_paint_box_support(map_element, height, footpathEntry, word_F3F038, imageFlags, sceneryImageFlags); } #ifdef __ENABLE_LIGHTFX__ @@ -796,7 +796,7 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) #endif } -void loc_6A37C9(rct_map_element * mapElement, sint32 height, rct_footpath_entry * footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags) +void path_paint_pole_support(rct_map_element * mapElement, sint32 height, rct_footpath_entry * footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags) { // Rol edges around rotation uint8 edges = ((mapElement->properties.path.edges << get_current_rotation()) & 0xF) | @@ -819,7 +819,7 @@ void loc_6A37C9(rct_map_element * mapElement, sint32 height, rct_footpath_entry } imageId += footpathEntry->image; - if (mapElement->type & 1) { + if (footpath_element_is_queue(mapElement)) { imageId += 51; } @@ -842,7 +842,7 @@ void loc_6A37C9(rct_map_element * mapElement, sint32 height, rct_footpath_entry sub_98197C(image_id | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); - if (!(mapElement->type & 1) && !(footpathEntry->flags & FOOTPATH_ENTRY_FLAG_2)) { + if (!footpath_element_is_queue(mapElement) && !(footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) { // don't draw } else { sub_98199C(imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); @@ -870,7 +870,7 @@ void loc_6A37C9(rct_map_element * mapElement, sint32 height, rct_footpath_entry paint_util_set_general_support_height(height, 0x20); - if ((mapElement->type & 1) + if (footpath_element_is_queue(mapElement) || (mapElement->properties.path.edges != 0xFF && hasFences) ) { paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); @@ -901,7 +901,7 @@ void loc_6A37C9(rct_map_element * mapElement, sint32 height, rct_footpath_entry } } -void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags) +void path_paint_box_support(rct_map_element* mapElement, sint16 height, rct_footpath_entry* footpathEntry, bool hasFences, uint32 imageFlags, uint32 sceneryImageFlags) { // Rol edges around rotation uint8 edges = ((mapElement->properties.path.edges << get_current_rotation()) & 0xF) | @@ -932,7 +932,7 @@ void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* imageId += footpathEntry->image; - if (mapElement->type & 1) { + if (footpath_element_is_queue(mapElement)) { imageId += 51; } @@ -959,7 +959,7 @@ void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* sub_98197C(bridgeImage | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); - if ((mapElement->type & 1) || (footpathEntry->flags & FOOTPATH_ENTRY_FLAG_2)) { + if (footpath_element_is_queue(mapElement) || (footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) { sub_98199C(imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); } } @@ -991,7 +991,7 @@ void loc_6A3B57(rct_map_element* mapElement, sint16 height, rct_footpath_entry* paint_util_set_general_support_height(height, 0x20); - if ((mapElement->type & 1) + if (footpath_element_is_queue(mapElement) || (mapElement->properties.path.edges != 0xFF && hasFences) ) { diff --git a/src/openrct2/paint/supports.c b/src/openrct2/paint/supports.c index ffdd6b61ba..cc08d421ab 100644 --- a/src/openrct2/paint/supports.c +++ b/src/openrct2/paint/supports.c @@ -1275,7 +1275,7 @@ bool path_b_supports_paint_setup(sint32 segment, sint32 special, sint32 height, if ((gSupportSegments[segment].slope & 0x20) || (height - gSupportSegments[segment].height < 6) - || !(pathEntry->flags & FOOTPATH_ENTRY_FLAG_1)) { + || !(pathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE)) { baseHeight = gSupportSegments[segment].height; } else { uint8 imageOffset = metal_supports_slope_image_map[gSupportSegments[segment].slope & 0x1F]; diff --git a/src/openrct2/world/footpath.h b/src/openrct2/world/footpath.h index 7103c9e56c..7c0f10faca 100644 --- a/src/openrct2/world/footpath.h +++ b/src/openrct2/world/footpath.h @@ -32,7 +32,7 @@ typedef struct rct_footpath_entry { rct_string_id string_idx; // 0x00 uint32 image; // 0x02 uint32 bridge_image; // 0x06 - uint8 var_0A; + uint8 support_type; // 0x0A uint8 flags; // 0x0B uint8 scrolling_mode; // 0x0C } rct_footpath_entry; @@ -40,8 +40,14 @@ assert_struct_size(rct_footpath_entry, 13); #pragma pack(pop) enum { - FOOTPATH_ENTRY_FLAG_1 = (1 << 0), - FOOTPATH_ENTRY_FLAG_2 = (1 << 1), + FOOTPATH_ENTRY_SUPPORT_TYPE_POLE = 0, + FOOTPATH_ENTRY_SUPPORT_TYPE_BOX = 1, + FOOTPATH_ENTRY_SUPPORT_TYPE_COUNT +}; + +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), };