From 228af15a30aa6a861747c5a27ebe886f7108002d Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 19 Apr 2016 01:11:16 +0100 Subject: [PATCH] add path object import --- src/rct1.h | 35 ++++++++------- src/rct1/S4Importer.cpp | 95 ++++++++++++++++++++++------------------- src/rct1/S4Importer.h | 3 ++ src/rct1/import.h | 2 + src/rct1/tables.cpp | 49 +++++++++++++++++++++ 5 files changed, 124 insertions(+), 60 deletions(-) diff --git a/src/rct1.h b/src/rct1.h index 05bef489b3..9ac235b9dd 100644 --- a/src/rct1.h +++ b/src/rct1.h @@ -557,22 +557,27 @@ enum { }; enum { - FOOTPATH_TYPE_QUEUE_BLUE, - FOOTPATH_TYPE_QUEUE_RED, - FOOTPATH_TYPE_QUEUE_YELLOW, - FOOTPATH_TYPE_QUEUE_GREEN, + RCT1_FOOTPATH_TYPE_QUEUE_BLUE, + RCT1_FOOTPATH_TYPE_QUEUE_RED, + RCT1_FOOTPATH_TYPE_QUEUE_YELLOW, + RCT1_FOOTPATH_TYPE_QUEUE_GREEN, - FOOTPATH_TYPE_TARMAC_GRAY, - FOOTPATH_TYPE_DIRT, - FOOTPATH_TYPE_CRAZY_PAVING, - FOOTPATH_TYPE_TILE, - FOOTPATH_TYPE_TARMAC_RED, - FOOTPATH_TYPE_TILE_GRAY, - FOOTPATH_TYPE_DIRT_BLACK, - FOOTPATH_TYPE_TARMAC_BROWN, - FOOTPATH_TYPE_TILE_RED, - FOOTPATH_TYPE_TARMAC_GREEN, - FOOTPATH_TYPE_TILE_GREEN, + RCT1_FOOTPATH_TYPE_TARMAC_GRAY, + RCT1_FOOTPATH_TYPE_TARMAC_RED, + RCT1_FOOTPATH_TYPE_TARMAC_BROWN, + RCT1_FOOTPATH_TYPE_TARMAC_GREEN, + + RCT1_FOOTPATH_TYPE_DIRT_RED, + RCT1_FOOTPATH_TYPE_DIRT_BLACK, + + RCT1_FOOTPATH_TYPE_CRAZY_PAVING = 12, + + RCT1_FOOTPATH_TYPE_ROADS = 16, + + RCT1_FOOTPATH_TYPE_TILE_PINK = 20, + RCT1_FOOTPATH_TYPE_TILE_GRAY, + RCT1_FOOTPATH_TYPE_TILE_RED, + RCT1_FOOTPATH_TYPE_TILE_GREEN, }; enum { diff --git a/src/rct1/S4Importer.cpp b/src/rct1/S4Importer.cpp index a78ed03518..354f989b78 100644 --- a/src/rct1/S4Importer.cpp +++ b/src/rct1/S4Importer.cpp @@ -74,6 +74,7 @@ void S4Importer::Initialise() Memory::Set(_smallSceneryTypeToEntryMap, 255, sizeof(_smallSceneryTypeToEntryMap)); Memory::Set(_largeSceneryTypeToEntryMap, 255, sizeof(_largeSceneryTypeToEntryMap)); Memory::Set(_wallTypeToEntryMap, 255, sizeof(_wallTypeToEntryMap)); + Memory::Set(_pathTypeToEntryMap, 255, sizeof(_pathTypeToEntryMap)); Memory::Set(_pathAdditionTypeToEntryMap, 255, sizeof(_pathAdditionTypeToEntryMap)); Memory::Set(_sceneryThemeTypeToEntryMap, 255, sizeof(_sceneryThemeTypeToEntryMap)); @@ -115,6 +116,17 @@ void S4Importer::CreateAvailableObjectMappings() "SCGWALLS" }); + _pathEntries.AddRange({ + "PATHASH ", + "PATHCRZY", + "PATHDIRT", + "PATHSPCE", + "TARMAC ", + "TARMACB ", + "TARMACG ", + "ROAD ", + }); + AddAvailableEntriesFromResearchList(); AddAvailableEntriesFromMap(); AddAvailableEntriesFromRides(); @@ -136,6 +148,7 @@ void S4Importer::CreateAvailableObjectMappings() case OBJECT_TYPE_SMALL_SCENERY: case OBJECT_TYPE_LARGE_SCENERY: case OBJECT_TYPE_WALLS: + case OBJECT_TYPE_PATHS: case OBJECT_TYPE_PATH_BITS: { List * entries = GetEntryList(objectType); @@ -227,8 +240,18 @@ void S4Importer::AddAvailableEntriesFromMap() { switch (map_element_get_type(mapElement)) { case MAP_ELEMENT_TYPE_PATH: - AddEntryForPathAddition(mapElement->properties.path.additions & 0x0F); + { + uint8 pathColour = mapElement->type & 3; + uint8 pathType = (mapElement->properties.path.type & 0xF0) >> 4; + uint8 supportsType = (mapElement->flags & 0x60) >> 5; + + pathType = (pathType << 2) | pathColour; + uint8 pathAdditionsType = mapElement->properties.path.additions & 0x0F; + + AddEntryForPath(pathType); + AddEntryForPathAddition(pathAdditionsType); break; + } case MAP_ELEMENT_TYPE_SCENERY: AddEntryForSmallScenery(mapElement->properties.scenery.type); break; @@ -330,6 +353,16 @@ void S4Importer::AddEntryForWall(uint8 wallType) } } +void S4Importer::AddEntryForPath(uint8 pathType) +{ + if (_pathTypeToEntryMap[pathType] == 255) + { + const char * entryName = RCT1::GetPathObject(pathType); + _pathTypeToEntryMap[pathType] = (uint8)_pathEntries.GetCount(); + _pathEntries.Add(entryName); + } +} + void S4Importer::AddEntryForPathAddition(uint8 pathAdditionType) { if (pathAdditionType == RCT1_PATH_ADDITION_NONE) return; @@ -612,17 +645,9 @@ void S4Importer::LoadObjects() LoadObjects(OBJECT_TYPE_SMALL_SCENERY, _smallSceneryEntries); LoadObjects(OBJECT_TYPE_LARGE_SCENERY, _largeSceneryEntries); LoadObjects(OBJECT_TYPE_WALLS, _wallEntries); + LoadObjects(OBJECT_TYPE_PATHS, _pathEntries); LoadObjects(OBJECT_TYPE_PATH_BITS, _pathAdditionEntries); LoadObjects(OBJECT_TYPE_SCENERY_SETS, _sceneryGroupEntries); - LoadObjects(OBJECT_TYPE_PATHS, List({ - "TARMAC ", - "TARMACB ", - "PATHSPCE", - "PATHDIRT", - "ROAD ", - "PATHCRZY", - "PATHASH " - })); LoadObjects(OBJECT_TYPE_BANNERS, List({ "BN1 ", "BN2 ", @@ -1028,35 +1053,6 @@ void S4Importer::FixZ() RCT2_GLOBAL(0x01359208, uint16) = 7; } -// rct2: 0x0098BC9F -static const uint8 RCT1PathTypeConversionTable[96] = -{ - 0x80 | 0, 0x80 | 1, 0x80 | 2, 0x80 | 3, // TARMAC, TARMACB, PATHSPCE, PATHDIRT - 0x80 | 0, 0x80 | 1, 0x80 | 2, 0x80 | 3, // TARMAC, TARMACB, PATHSPCE, PATHDIRT - 0x80 | 0, 0x80 | 1, 0x80 | 2, 0x80 | 3, // TARMAC, TARMACB, PATHSPCE, PATHDIRT - 0x80 | 0, 0x80 | 1, 0x80 | 2, 0x80 | 3, // TARMAC, TARMACB, PATHSPCE, PATHDIRT - 0, 0, 0, 0, // TARMAC - 2, 2, 2, 2, // PATHSPCE - 1, 1, 1, 1, // TARMACB - 0, 0, 0, 0, // TARMAC - 3, 3, 3, 3, // PATHDIRT - 6, 6, 6, 6, // PATHASH - 0, 0, 0, 0, // TARMAC - 0, 0, 0, 0, // TARMAC - 5, 5, 5, 5, // PATHCRZY - 5, 5, 5, 5, // PATHCRZY - 5, 5, 5, 5, // PATHCRZY - 5, 5, 5, 5, // PATHCRZY - 4, 4, 4, 4, // ROAD - 4, 4, 4, 4, // ROAD - 4, 4, 4, 4, // ROAD - 4, 4, 4, 4, // ROAD - 0, 0, 0, 0, // TARMAC - 0, 0, 0, 0, // TARMAC - 0, 0, 0, 0, // TARMAC - 0, 0, 0, 0, // TARMAC -}; - void S4Importer::FixPaths() { rct_map_element * mapElement = gMapElements; @@ -1066,20 +1062,23 @@ void S4Importer::FixPaths() case MAP_ELEMENT_TYPE_PATH: { // Type - uint8 pathType = ((mapElement->properties.path.type & 0xF0) >> 2) | (mapElement->type & 3); + uint8 pathColour = mapElement->type & 3; + uint8 pathType = (mapElement->properties.path.type & 0xF0) >> 4; uint8 supportsType = (mapElement->flags & 0x60) >> 5; - pathType = RCT1PathTypeConversionTable[pathType * 4 + supportsType]; + + pathType = (pathType << 2) | pathColour; + uint8 entryIndex = _pathTypeToEntryMap[pathType]; mapElement->type &= 0xFC; mapElement->flags &= ~0x60; mapElement->flags &= ~MAP_ELEMENT_FLAG_BROKEN; mapElement->properties.path.type &= 0x0F; footpath_scenery_set_is_ghost(mapElement, false); - if (pathType & 0x80) + if (RCT1::PathIsQueue(pathType)) { mapElement->type |= 1; } - mapElement->properties.path.type |= pathType << 4; + mapElement->properties.path.type |= entryIndex << 4; // Additions uint8 additionType = footpath_element_get_path_scenery(mapElement); @@ -1098,8 +1097,13 @@ void S4Importer::FixPaths() case MAP_ELEMENT_TYPE_ENTRANCE: if (mapElement->properties.entrance.type == ENTRANCE_TYPE_PARK_ENTRANCE) { - int pathType = mapElement->properties.entrance.path_type; - mapElement->properties.entrance.path_type = RCT1PathTypeConversionTable[pathType * 4] & 0x7F; + uint8 pathType = mapElement->properties.entrance.path_type; + if (pathType == 0) + { + pathType = RCT1_FOOTPATH_TYPE_TARMAC_GRAY; + } + uint8 entryIndex = _pathTypeToEntryMap[pathType]; + mapElement->properties.entrance.path_type = entryIndex & 0x7F; } break; } @@ -1299,6 +1303,7 @@ List * S4Importer::GetEntryList(uint8 objectType) case OBJECT_TYPE_SMALL_SCENERY: return &_smallSceneryEntries; case OBJECT_TYPE_LARGE_SCENERY: return &_largeSceneryEntries; case OBJECT_TYPE_WALLS: return &_wallEntries; + case OBJECT_TYPE_PATHS: return &_pathEntries; case OBJECT_TYPE_PATH_BITS: return &_pathAdditionEntries; case OBJECT_TYPE_SCENERY_SETS: return &_sceneryGroupEntries; } diff --git a/src/rct1/S4Importer.h b/src/rct1/S4Importer.h index 4bf996be4a..0fe3c1b093 100644 --- a/src/rct1/S4Importer.h +++ b/src/rct1/S4Importer.h @@ -28,6 +28,7 @@ private: List _smallSceneryEntries; List _largeSceneryEntries; List _wallEntries; + List _pathEntries; List _pathAdditionEntries; List _sceneryGroupEntries; @@ -37,6 +38,7 @@ private: uint8 _smallSceneryTypeToEntryMap[256]; uint8 _largeSceneryTypeToEntryMap[256]; uint8 _wallTypeToEntryMap[256]; + uint8 _pathTypeToEntryMap[16]; uint8 _pathAdditionTypeToEntryMap[16]; uint8 _sceneryThemeTypeToEntryMap[24]; @@ -60,6 +62,7 @@ private: void AddEntryForSmallScenery(uint8 smallSceneryType); void AddEntryForLargeScenery(uint8 largeSceneryType); void AddEntryForWall(uint8 wallType); + void AddEntryForPath(uint8 pathType); void AddEntryForPathAddition(uint8 pathAdditionType); void AddEntriesForSceneryTheme(uint8 sceneryThemeType); diff --git a/src/rct1/import.h b/src/rct1/import.h index 6f015df7a0..ad7c1f6a49 100644 --- a/src/rct1/import.h +++ b/src/rct1/import.h @@ -11,6 +11,7 @@ namespace RCT1 uint8 GetRideType(uint8 rideType); bool RideTypeHasVehicle(uint8 rideType); + bool PathIsQueue(uint8 pathType); uint8 NormalisePathAddition(uint8 pathAdditionType); const char * GetRideTypeObject(uint8 rideType); @@ -18,6 +19,7 @@ namespace RCT1 const char * GetSmallSceneryObject(uint8 smallSceneryType); const char * GetLargeSceneryObject(uint8 largeSceneryType); const char * GetWallObject(uint8 wallType); + const char * GetPathObject(uint8 pathType); const char * GetPathAddtionObject(uint8 pathAdditionType); const char * GetSceneryGroupObject(uint8 sceneryGroupType); diff --git a/src/rct1/tables.cpp b/src/rct1/tables.cpp index 8af91de5d7..54ffcb5dd2 100644 --- a/src/rct1/tables.cpp +++ b/src/rct1/tables.cpp @@ -228,6 +228,18 @@ namespace RCT1 } } + bool PathIsQueue(uint8 pathType) + { + switch (pathType) { + case RCT1_FOOTPATH_TYPE_QUEUE_BLUE: + case RCT1_FOOTPATH_TYPE_QUEUE_RED: + case RCT1_FOOTPATH_TYPE_QUEUE_GREEN: + case RCT1_FOOTPATH_TYPE_QUEUE_YELLOW: + return true; + } + return false; + } + uint8 NormalisePathAddition(uint8 pathAdditionType) { switch (pathAdditionType) { @@ -838,6 +850,43 @@ namespace RCT1 return map[wallType]; } + const char * GetPathObject(uint8 pathType) + { + static const char * map[] = + { + "TARMAC ", // RCT1_FOOTPATH_TYPE_QUEUE_BLUE + "PATHSPCE", // RCT1_FOOTPATH_TYPE_QUEUE_RED + "TARMACG ", // RCT1_FOOTPATH_TYPE_QUEUE_GREEN + "PATHDIRT", // RCT1_FOOTPATH_TYPE_QUEUE_YELLOW + + "TARMAC ", // RCT1_FOOTPATH_TYPE_TARMAC_GRAY + "PATHSPCE", // RCT1_FOOTPATH_TYPE_TARMAC_RED + "TARMACB ", // RCT1_FOOTPATH_TYPE_TARMAC_BROWN + "TARMACG ", // RCT1_FOOTPATH_TYPE_TARMAC_GREEN + + "PATHDIRT", // RCT1_FOOTPATH_TYPE_DIRT_RED + "PATHASH ", // RCT1_FOOTPATH_TYPE_DIRT_BLACK + " ", + " ", + + "PATHCRZY", // RCT1_FOOTPATH_TYPE_CRAZY_PAVING + " ", + " ", + " ", + + "ROAD ", // RCT1_FOOTPATH_TYPE_ROADS + " ", + " ", + " ", + + "PATHCRZY", // RCT1_FOOTPATH_TYPE_TILE_PINK + "PATHCRZY", // RCT1_FOOTPATH_TYPE_TILE_GRAY + "PATHCRZY", // RCT1_FOOTPATH_TYPE_TILE_RED + "PATHCRZY", // RCT1_FOOTPATH_TYPE_TILE_GREEN + }; + return map[pathType]; + } + const char * GetPathAddtionObject(uint8 pathAdditionType) { static const char * map[] =