diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 8d94a3d479..62382c4a88 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -247,7 +247,7 @@ static void window_sign_mouseup(rct_window *w, rct_widgetindex widgetIndex) } game_do_command( x, - 1 | ((tile_element->type&0x3) << 8), + 1 | ((tile_element->type & TILE_ELEMENT_DIRECTION_MASK) << 8), y, tile_element->base_height | (scenery_large_get_sequence(tile_element) << 8), GAME_COMMAND_REMOVE_LARGE_SCENERY, @@ -510,9 +510,9 @@ static void window_sign_small_mouseup(rct_window *w, rct_widgetindex widgetIndex gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; game_do_command( x, - 1 | ((tile_element->type & 0x3) << 8), + 1 | ((tile_element->type & TILE_ELEMENT_DIRECTION_MASK) << 8), y, - (tile_element->base_height << 8) | (tile_element->type & 0x3), + (tile_element->base_height << 8) | (tile_element->type & TILE_ELEMENT_DIRECTION_MASK), GAME_COMMAND_REMOVE_WALL, 0, 0); diff --git a/src/openrct2/rct1/RCT1.h b/src/openrct2/rct1/RCT1.h index c99a191219..403dd2ca97 100644 --- a/src/openrct2/rct1/RCT1.h +++ b/src/openrct2/rct1/RCT1.h @@ -1222,6 +1222,17 @@ enum { RCT1_WATER_ORANGE }; +enum { + RCT1_SCENERY_TULIPS_1 = 65, + RCT1_SCENERY_TULIPS_2 = 68, + + RCT1_SCENERY_GEOMETRIC_SCULPTURE_1 = 157, // TGE1 + RCT1_SCENERY_GEOMETRIC_SCULPTURE_2 = 162, // TGE2 + RCT1_SCENERY_GEOMETRIC_SCULPTURE_3 = 168, // TGE3 + RCT1_SCENERY_GEOMETRIC_SCULPTURE_4 = 170, // TGE4 + RCT1_SCENERY_GEOMETRIC_SCULPTURE_5 = 171, // TGE5 +}; + ParkLoadResult * load_from_sv4(const char *path); ParkLoadResult * load_from_sc4(const char *path); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 688cab05d0..cd198f085e 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -62,6 +62,10 @@ #include "../world/Scenery.h" #include "../world/SmallScenery.h" +static uint8 GetPathType(rct_tile_element * tileElement); +static sint32 GetWallType(rct_tile_element * tileElement, sint32 edge); +static uint8 GetWallColour(rct_tile_element * tileElement); + class EntryList { private: @@ -481,10 +485,7 @@ private: switch (tile_element_get_type(tileElement)) { case TILE_ELEMENT_TYPE_PATH: { - uint8 pathColour = tile_element_get_direction(tileElement); - uint8 pathType = footpath_element_get_type(tileElement); - - pathType = (pathType << 2) | pathColour; + uint8 pathType = GetPathType(tileElement); uint8 pathAdditionsType = tileElement->properties.path.additions & 0x0F; AddEntryForPath(pathType); @@ -499,17 +500,12 @@ private: break; case TILE_ELEMENT_TYPE_WALL: { - uint8 var_05 = tileElement->properties.wall.colour_3; - uint16 var_06 = tileElement->properties.wall.colour_1 | - (tileElement->properties.wall.animation << 8); - for (sint32 edge = 0; edge < 4; edge++) { - sint32 typeA = (var_05 >> (edge * 2)) & 3; - sint32 typeB = (var_06 >> (edge * 4)) & 0x0F; - if (typeB != 0x0F) + sint32 type = GetWallType(tileElement, edge); + + if (type != -1) { - uint8 type = typeA | (typeB << 2); AddEntryForWall(type); } } @@ -1916,7 +1912,7 @@ private: { rct_object_entry entry; entry.flags = 0x00008000 + objectType; - std::copy_n(objectName, 8, entry.name); + std::copy_n(objectName, DAT_NAME_LENGTH, entry.name); entry.checksum = 0; const ObjectRepositoryItem * ori = objectRepository->FindObject(&entry); @@ -2428,36 +2424,28 @@ private: { if (tileElement->base_height != 255) { - switch (tile_element_get_type(tileElement)) { + // This skips walls, which are fixed later. + switch (tile_element_get_type(tileElement)) + { case TILE_ELEMENT_TYPE_SMALL_SCENERY: colour = RCT1::GetColour(scenery_small_get_primary_colour(tileElement)); scenery_small_set_primary_colour(tileElement, colour); // Copied from [rct2: 0x006A2956] switch (tileElement->properties.scenery.type) { - case 157: // TGE1 (Geometric Sculpture) - case 162: // TGE2 (Geometric Sculpture) - case 168: // TGE3 (Geometric Sculpture) - case 170: // TGE4 (Geometric Sculpture) - case 171: // TGE5 (Geometric Sculpture) + case RCT1_SCENERY_GEOMETRIC_SCULPTURE_1: + case RCT1_SCENERY_GEOMETRIC_SCULPTURE_2: + case RCT1_SCENERY_GEOMETRIC_SCULPTURE_3: + case RCT1_SCENERY_GEOMETRIC_SCULPTURE_4: + case RCT1_SCENERY_GEOMETRIC_SCULPTURE_5: scenery_small_set_secondary_colour(tileElement, COLOUR_WHITE); break; - case 65: - case 68: + case RCT1_SCENERY_TULIPS_1: + case RCT1_SCENERY_TULIPS_2: scenery_small_set_primary_colour(tileElement, COLOUR_BRIGHT_RED); scenery_small_set_secondary_colour(tileElement, COLOUR_YELLOW); } break; - case TILE_ELEMENT_TYPE_WALL: - colour = ((tileElement->type & 0xC0) >> 3) | - ((tileElement->properties.wall.type & 0xE0) >> 5); - colour = RCT1::GetColour(colour); - - tileElement->type &= 0x3F; - tileElement->properties.wall.type &= 0x1F; - tileElement->type |= (colour & 0x18) << 3; - tileElement->properties.wall.type |= (colour & 7) << 5; - break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: colour = RCT1::GetColour(scenery_large_get_primary_colour(tileElement)); scenery_large_set_primary_colour(tileElement, colour); @@ -2496,22 +2484,19 @@ private: case TILE_ELEMENT_TYPE_PATH: { // Type - uint8 pathColour = tileElement->type & 3; - uint8 pathType = footpath_element_get_type(tileElement); - - pathType = (pathType << 2) | pathColour; + uint8 pathType = GetPathType(tileElement); uint8 entryIndex = _pathTypeToEntryMap[pathType]; - tileElement->type &= 0xFC; - tileElement->flags &= ~0x60; - tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN; - tileElement->properties.path.type &= 0x0F; - footpath_scenery_set_is_ghost(tileElement, false); + tileElement->type &= ~TILE_ELEMENT_DIRECTION_MASK; + tileElement->flags &= ~(TILE_ELEMENT_FLAG_BROKEN | TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE); + + footpath_element_set_type(tileElement, entryIndex); if (RCT1::PathIsQueue(pathType)) { - tileElement->type |= 1; + footpath_element_set_queue(tileElement); } - tileElement->properties.path.type |= entryIndex << 4; + + footpath_scenery_set_is_ghost(tileElement, false); // Additions uint8 additionType = footpath_element_get_path_scenery(tileElement); @@ -2563,25 +2548,25 @@ private: rct_tile_element originalTileElement = *tileElement; tile_element_remove(tileElement); - uint8 var_05 = originalTileElement.properties.wall.colour_3; - uint16 var_06 = originalTileElement.properties.wall.colour_1 | - (originalTileElement.properties.wall.animation << 8); - for (sint32 edge = 0; edge < 4; edge++) { - sint32 typeA = (var_05 >> (edge * 2)) & 3; - sint32 typeB = (var_06 >> (edge * 4)) & 0x0F; - if (typeB != 0x0F) + sint32 type = GetWallType(&originalTileElement, edge); + + if (type != -1) { - sint32 type = typeA | (typeB << 2); - sint32 colourA = ((originalTileElement.type & 0xC0) >> 3) | - (originalTileElement.properties.wall.type >> 5); + sint32 colourA = RCT1::GetColour(GetWallColour(&originalTileElement)); sint32 colourB = 0; sint32 colourC = 0; ConvertWall(&type, &colourA, &colourB, &colourC); type = _wallTypeToEntryMap[type]; - wall_place(type, x * 32, y * 32, 0, edge, colourA, colourB, colourC, 169); + const uint8 flags = + GAME_COMMAND_FLAG_APPLY | + GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | + GAME_COMMAND_FLAG_5 | + GAME_COMMAND_FLAG_PATH_SCENERY; + + wall_place(type, x * 32, y * 32, 0, edge, colourA, colourB, colourC, flags); } } break; @@ -2889,3 +2874,34 @@ ParkLoadResult * load_from_sc4(const utf8 * path) return result; } +static uint8 GetPathType(rct_tile_element * tileElement) +{ + uint8 pathColour = tileElement->type & 3; + uint8 pathType = (tileElement->properties.path.type & FOOTPATH_PROPERTIES_TYPE_MASK) >> 2; + + pathType = pathType | pathColour; + return pathType; +} + +static sint32 GetWallType(rct_tile_element * tileElement, sint32 edge) +{ + uint8 var_05 = tileElement->properties.wall.colour_3; + uint16 var_06 = tileElement->properties.wall.colour_1 | (tileElement->properties.wall.animation << 8); + + sint32 typeA = (var_05 >> (edge * 2)) & 3; + sint32 typeB = (var_06 >> (edge * 4)) & 0x0F; + + if (typeB != 0x0F) + { + return typeA | (typeB << 2); + } + else + { + return -1; + } +} + +static uint8 GetWallColour(rct_tile_element * tileElement) +{ + return ((tileElement->type & 0xC0) >> 3) | ((tileElement->properties.wall.type & 0xE0) >> 5); +} \ No newline at end of file diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 4f5a293c16..cf88beb878 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -213,7 +213,7 @@ static money32 footpath_element_insert(sint32 type, sint32 x, sint32 y, sint32 z } // Do not attempt to build a crossing with a queue or a sloped. - uint8 crossingMode = (type & 0x80) || (slope != TILE_ELEMENT_SLOPE_FLAT) ? CREATE_CROSSING_MODE_NONE : CREATE_CROSSING_MODE_PATH_OVER_TRACK; + uint8 crossingMode = (type & FOOTPATH_ELEMENT_INSERT_QUEUE) || (slope != TILE_ELEMENT_SLOPE_FLAT) ? CREATE_CROSSING_MODE_NONE : CREATE_CROSSING_MODE_PATH_OVER_TRACK; if (!entrancePath && !gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z, zHigh, &map_place_non_scenery_clear_func, bl, flags, &gFootpathPrice, crossingMode)) return MONEY32_UNDEFINED; @@ -246,7 +246,8 @@ static money32 footpath_element_insert(sint32 type, sint32 x, sint32 y, sint32 z tileElement->clearance_height = z + 4 + ((slope & TILE_ELEMENT_SLOPE_NE_SIDE_UP) ? 2 : 0); footpath_element_set_type(tileElement, type); tileElement->properties.path.type |= (slope & TILE_ELEMENT_SLOPE_W_CORNER_DN); - tileElement->type |= type >> 7; + if (type & FOOTPATH_ELEMENT_INSERT_QUEUE) + footpath_element_set_queue(tileElement); tileElement->properties.path.additions = pathItemType; tileElement->properties.path.addition_status = 255; tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN; @@ -622,7 +623,7 @@ static money32 footpath_place_from_track(sint32 type, sint32 x, sint32 y, sint32 } // Do not attempt to build a crossing with a queue or a sloped. - uint8 crossingMode = (type & 0x80) || (slope != TILE_ELEMENT_SLOPE_FLAT) ? CREATE_CROSSING_MODE_NONE : CREATE_CROSSING_MODE_PATH_OVER_TRACK; + uint8 crossingMode = (type & FOOTPATH_ELEMENT_INSERT_QUEUE) || (slope != TILE_ELEMENT_SLOPE_FLAT) ? CREATE_CROSSING_MODE_NONE : CREATE_CROSSING_MODE_PATH_OVER_TRACK; if (!entrancePath && !gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z, zHigh, &map_place_non_scenery_clear_func, bl, flags, &gFootpathPrice, crossingMode)) return MONEY32_UNDEFINED; @@ -1381,7 +1382,7 @@ static void loc_6A6C85( return; if (tile_element_get_type(tileElement) == TILE_ELEMENT_TYPE_ENTRANCE) { - if (!entrance_has_direction(tileElement, (direction - tileElement->type) & 3)) { + if (!entrance_has_direction(tileElement, (direction - tile_element_get_direction(tileElement)) & 3)) { return; } } @@ -1561,7 +1562,7 @@ void footpath_chain_ride_queue(sint32 rideIndex, sint32 entranceIndex, sint32 x, if (rideIndex != 255 && lastPathElement != nullptr) { if (footpath_element_is_queue(lastPathElement)) { - lastPathElement->properties.path.type |= (1 << 3); // Set the ride sign flag + lastPathElement->properties.path.type |= FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER; lastPathElement->type &= 0x3F; // Clear the ride sign direction footpath_element_set_direction(lastPathElement, lastPathDirection); // set the ride sign direction @@ -1820,6 +1821,16 @@ bool footpath_element_is_queue(const rct_tile_element * tileElement) return (tileElement->type & FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE) != 0; } +void footpath_element_set_queue(rct_tile_element * tileElement) +{ + tileElement->type |= FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE; +} + +void footpath_element_clear_queue(rct_tile_element * tileElement) +{ + tileElement->type &= ~FOOTPATH_ELEMENT_TYPE_FLAG_IS_QUEUE; +} + bool footpath_element_has_queue_banner(const rct_tile_element * tileElement) { return (tileElement->properties.path.type & FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER) != 0; diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index e8c8cd7ecd..0234de34a3 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -28,6 +28,8 @@ enum PROVISIONAL_PATH_FLAG_2 = (1 << 2), }; +#define FOOTPATH_ELEMENT_INSERT_QUEUE 0x80 + #pragma pack(push, 1) struct rct_footpath_entry { rct_string_id string_idx; // 0x00 @@ -150,6 +152,8 @@ bool footpath_element_is_sloped(const rct_tile_element * tileElement); void footpath_element_set_sloped(rct_tile_element * tileElement, bool isSloped); uint8 footpath_element_get_slope_direction(const rct_tile_element * tileElement); bool footpath_element_is_queue(const rct_tile_element * tileElement); +void footpath_element_set_queue(rct_tile_element * tileElement); +void footpath_element_clear_queue(rct_tile_element * tileElement); bool footpath_element_has_queue_banner(const rct_tile_element * tileElement); bool footpath_element_is_wide(const rct_tile_element * tileElement); uint8 footpath_element_get_type(const rct_tile_element * tileElement);