diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 35031abed8..61f0604f5e 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3854,3 +3854,21 @@ STR_7060 :Guests watching construction of {STRINGID} STR_7061 :Guests looking at scenery STR_7062 :Guests leaving the park STR_7063 :Guests watching new ride being constructed +STR_7064 :Gold +STR_7065 :Amber +STR_7066 :Amethyst +STR_7067 :Asparagus +STR_7068 :Brown +STR_7069 :Burnt pink +STR_7070 :Cactus +STR_7071 :Caramel +STR_7072 :Copper +STR_7073 :Crimson +STR_7074 :Darker water +STR_7075 :Emerald +STR_7076 :Indigo +STR_7077 :Pesto +STR_7078 :Pine green +STR_7079 :Ruby +STR_7080 :Deep blue +STR_7081 :Silver diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 767ba7a6b7..deb3a4ca69 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,6 +1,7 @@ 0.5.6 (in development) ------------------------------------------------------------------------ - Feature: [#16014] Land surfaces and edges can now be recoloured. +- Feature: [#26894] Added 18 additional colours, including 5 from the base version of RCT1 (which were removed in later versions). - Feature: [#27153] [Plugin] Add `guestsEntertained` to `Entertainer` interface. - Feature: [#27184] [Plugin] Double limit of miscellaneous entities (e.g. crash particles, steam plumes and balloons) to 6400. - Feature: [objects#447] Track designer grid can now be used outside the Track Designer. diff --git a/resources/palettes/map_base/palette_map_amber.png b/resources/palettes/map_base/palette_map_amber.png new file mode 100644 index 0000000000..202b0e15db Binary files /dev/null and b/resources/palettes/map_base/palette_map_amber.png differ diff --git a/resources/palettes/map_base/palette_map_amethyst.png b/resources/palettes/map_base/palette_map_amethyst.png new file mode 100644 index 0000000000..d53c873c46 Binary files /dev/null and b/resources/palettes/map_base/palette_map_amethyst.png differ diff --git a/resources/palettes/map_base/palette_map_asparagus.png b/resources/palettes/map_base/palette_map_asparagus.png new file mode 100644 index 0000000000..9c0ecf529e Binary files /dev/null and b/resources/palettes/map_base/palette_map_asparagus.png differ diff --git a/resources/palettes/map_base/palette_map_brown.png b/resources/palettes/map_base/palette_map_brown.png new file mode 100644 index 0000000000..48923c709c Binary files /dev/null and b/resources/palettes/map_base/palette_map_brown.png differ diff --git a/resources/palettes/map_base/palette_map_burnt_pink.png b/resources/palettes/map_base/palette_map_burnt_pink.png new file mode 100644 index 0000000000..a1f6d57543 Binary files /dev/null and b/resources/palettes/map_base/palette_map_burnt_pink.png differ diff --git a/resources/palettes/map_base/palette_map_cactus.png b/resources/palettes/map_base/palette_map_cactus.png new file mode 100644 index 0000000000..bafff786d1 Binary files /dev/null and b/resources/palettes/map_base/palette_map_cactus.png differ diff --git a/resources/palettes/map_base/palette_map_caramel.png b/resources/palettes/map_base/palette_map_caramel.png new file mode 100644 index 0000000000..13d95161f8 Binary files /dev/null and b/resources/palettes/map_base/palette_map_caramel.png differ diff --git a/resources/palettes/map_base/palette_map_copper.png b/resources/palettes/map_base/palette_map_copper.png new file mode 100644 index 0000000000..65e879b13f Binary files /dev/null and b/resources/palettes/map_base/palette_map_copper.png differ diff --git a/resources/palettes/map_base/palette_map_crimson.png b/resources/palettes/map_base/palette_map_crimson.png new file mode 100644 index 0000000000..7a007d26f0 Binary files /dev/null and b/resources/palettes/map_base/palette_map_crimson.png differ diff --git a/resources/palettes/map_base/palette_map_darker_water.png b/resources/palettes/map_base/palette_map_darker_water.png new file mode 100644 index 0000000000..c3574020f8 Binary files /dev/null and b/resources/palettes/map_base/palette_map_darker_water.png differ diff --git a/resources/palettes/map_base/palette_map_deep_blue.png b/resources/palettes/map_base/palette_map_deep_blue.png new file mode 100644 index 0000000000..912e63c7a1 Binary files /dev/null and b/resources/palettes/map_base/palette_map_deep_blue.png differ diff --git a/resources/palettes/map_base/palette_map_emerald.png b/resources/palettes/map_base/palette_map_emerald.png new file mode 100644 index 0000000000..f5990eb96f Binary files /dev/null and b/resources/palettes/map_base/palette_map_emerald.png differ diff --git a/resources/palettes/map_base/palette_map_gold.png b/resources/palettes/map_base/palette_map_gold.png new file mode 100644 index 0000000000..48aba1404b Binary files /dev/null and b/resources/palettes/map_base/palette_map_gold.png differ diff --git a/resources/palettes/map_base/palette_map_indigo.png b/resources/palettes/map_base/palette_map_indigo.png new file mode 100644 index 0000000000..07cf5f444e Binary files /dev/null and b/resources/palettes/map_base/palette_map_indigo.png differ diff --git a/resources/palettes/map_base/palette_map_pesto.png b/resources/palettes/map_base/palette_map_pesto.png new file mode 100644 index 0000000000..5219040672 Binary files /dev/null and b/resources/palettes/map_base/palette_map_pesto.png differ diff --git a/resources/palettes/map_base/palette_map_pine_green.png b/resources/palettes/map_base/palette_map_pine_green.png new file mode 100644 index 0000000000..47de4c5eb4 Binary files /dev/null and b/resources/palettes/map_base/palette_map_pine_green.png differ diff --git a/resources/palettes/map_base/palette_map_ruby.png b/resources/palettes/map_base/palette_map_ruby.png new file mode 100644 index 0000000000..9ccffad1cf Binary files /dev/null and b/resources/palettes/map_base/palette_map_ruby.png differ diff --git a/resources/palettes/map_base/palette_map_silver.png b/resources/palettes/map_base/palette_map_silver.png new file mode 100644 index 0000000000..1ba4f090b4 Binary files /dev/null and b/resources/palettes/map_base/palette_map_silver.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_amber.png b/resources/palettes/map_glass/palette_map_glass_amber.png new file mode 100644 index 0000000000..3ee629aded Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_amber.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_amethyst.png b/resources/palettes/map_glass/palette_map_glass_amethyst.png new file mode 100644 index 0000000000..b6ddad8506 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_amethyst.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_asparagus.png b/resources/palettes/map_glass/palette_map_glass_asparagus.png new file mode 100644 index 0000000000..7af210a317 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_asparagus.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_brown.png b/resources/palettes/map_glass/palette_map_glass_brown.png new file mode 100644 index 0000000000..bf8d05266f Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_brown.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_burnt_pink.png b/resources/palettes/map_glass/palette_map_glass_burnt_pink.png new file mode 100644 index 0000000000..f77024a0cc Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_burnt_pink.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_cactus.png b/resources/palettes/map_glass/palette_map_glass_cactus.png new file mode 100644 index 0000000000..f2cfeb3fa9 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_cactus.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_caramel.png b/resources/palettes/map_glass/palette_map_glass_caramel.png new file mode 100644 index 0000000000..ce5e9831ab Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_caramel.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_copper.png b/resources/palettes/map_glass/palette_map_glass_copper.png new file mode 100644 index 0000000000..4f4120253c Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_copper.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_crimson.png b/resources/palettes/map_glass/palette_map_glass_crimson.png new file mode 100644 index 0000000000..522e27bc86 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_crimson.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_darker_water.png b/resources/palettes/map_glass/palette_map_glass_darker_water.png new file mode 100644 index 0000000000..8b29ee30c0 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_darker_water.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_deep_blue.png b/resources/palettes/map_glass/palette_map_glass_deep_blue.png new file mode 100644 index 0000000000..30e6af1040 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_deep_blue.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_emerald.png b/resources/palettes/map_glass/palette_map_glass_emerald.png new file mode 100644 index 0000000000..049710ac1f Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_emerald.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_gold.png b/resources/palettes/map_glass/palette_map_glass_gold.png new file mode 100644 index 0000000000..502f69e013 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_gold.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_indigo.png b/resources/palettes/map_glass/palette_map_glass_indigo.png new file mode 100644 index 0000000000..3019b8f544 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_indigo.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_pesto.png b/resources/palettes/map_glass/palette_map_glass_pesto.png new file mode 100644 index 0000000000..19c381b413 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_pesto.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_pine_green.png b/resources/palettes/map_glass/palette_map_glass_pine_green.png new file mode 100644 index 0000000000..01eea0975c Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_pine_green.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_ruby.png b/resources/palettes/map_glass/palette_map_glass_ruby.png new file mode 100644 index 0000000000..a71f5db3e6 Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_ruby.png differ diff --git a/resources/palettes/map_glass/palette_map_glass_silver.png b/resources/palettes/map_glass/palette_map_glass_silver.png new file mode 100644 index 0000000000..e44e2253ab Binary files /dev/null and b/resources/palettes/map_glass/palette_map_glass_silver.png differ diff --git a/resources/palettes/sprites.json b/resources/palettes/sprites.json index a55b506d22..a35008a4f9 100644 --- a/resources/palettes/sprites.json +++ b/resources/palettes/sprites.json @@ -664,6 +664,96 @@ "palette": "keep", "format": "raw" }, + { + "path": "map_base/palette_map_gold.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_amber.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_amethyst.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_asparagus.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_brown.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_burnt_pink.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_cactus.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_caramel.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_copper.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_crimson.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_darker_water.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_emerald.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_indigo.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_pesto.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_pine_green.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_ruby.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_deep_blue.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_base/palette_map_silver.png", + "palette": "keep", + "format": "raw" + }, { "path": "map_base/palette_map_water.png", "palette": "keep", @@ -1343,5 +1433,95 @@ "path": "map_glass/palette_map_glass_void.png", "palette": "keep", "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_gold.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_amber.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_amethyst.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_asparagus.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_brown.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_burnt_pink.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_cactus.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_caramel.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_copper.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_crimson.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_darker_water.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_emerald.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_indigo.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_pesto.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_pine_green.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_ruby.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_deep_blue.png", + "palette": "keep", + "format": "raw" + }, + { + "path": "map_glass/palette_map_glass_silver.png", + "palette": "keep", + "format": "raw" } ] diff --git a/src/openrct2-ui/UiStringIds.h b/src/openrct2-ui/UiStringIds.h index 55836af200..8c3c5a0ecc 100644 --- a/src/openrct2-ui/UiStringIds.h +++ b/src/openrct2-ui/UiStringIds.h @@ -91,6 +91,24 @@ namespace OpenRCT2 STR_COLOUR_DULL_GREEN_DARK_TIP = 6564, STR_COLOUR_DULL_GREEN_LIGHT_TIP = 6565, STR_COLOUR_DULL_PURPLE_LIGHT_TIP = 6563, + STR_COLOUR_GOLD_TIP = 7064, + STR_COLOUR_AMBER_TIP = 7065, + STR_COLOUR_AMETHYST_TIP = 7066, + STR_COLOUR_ASPARAGUS_TIP = 7067, + STR_COLOUR_BROWN_TIP = 7068, + STR_COLOUR_BURNT_PINK_TIP = 7069, + STR_COLOUR_CACTUS_TIP = 7070, + STR_COLOUR_CARAMEL_TIP = 7071, + STR_COLOUR_COPPER_TIP = 7072, + STR_COLOUR_CRIMSON_TIP = 7073, + STR_COLOUR_DARKER_WATER_TIP = 7074, + STR_COLOUR_EMERALD_TIP = 7075, + STR_COLOUR_INDIGO_TIP = 7076, + STR_COLOUR_PESTO_TIP = 7077, + STR_COLOUR_PINE_GREEN_TIP = 7078, + STR_COLOUR_RUBY_TIP = 7079, + STR_COLOUR_DEEP_BLUE_TIP = 7080, + STR_COLOUR_SILVER_TIP = 7081, STR_COLOUR_GRASS_GREEN_DARK_TIP = 6556, STR_COLOUR_GRASS_GREEN_LIGHT_TIP = 6557, STR_COLOUR_GREY_TIP = 5517, diff --git a/src/openrct2-ui/windows/Dropdown.cpp b/src/openrct2-ui/windows/Dropdown.cpp index 66d4db5ae2..af06d0e0fb 100644 --- a/src/openrct2-ui/windows/Dropdown.cpp +++ b/src/openrct2-ui/windows/Dropdown.cpp @@ -516,9 +516,13 @@ namespace OpenRCT2::Ui::Windows // Colour ordered for use in colour dropdown static constexpr Colour kColoursDropdownOrder[] = { Colour::black, Colour::saturatedRed, Colour::darkOrange, Colour::darkYellow, - Colour::forestGreen, Colour::saturatedGreen, Colour::deepWater, Colour::darkBlue, + Colour::forestGreen, Colour::saturatedGreen, Colour::deepWater, Colour::deepBlue, Colour::violet, + Colour::silver, Colour::ruby, Colour::amber, Colour::gold, + Colour::cactus, Colour::emerald, Colour::darkerWater, Colour::darkBlue, + Colour::amethyst, + Colour::grey, Colour::brightRed, Colour::lightOrange, Colour::yellow, Colour::mossGreen, Colour::brightGreen, Colour::darkWater, Colour::lightBlue, Colour::brightPurple, @@ -531,7 +535,11 @@ namespace OpenRCT2::Ui::Windows Colour::armyGreen, Colour::hunterGreen, Colour::viridian, Colour::darkPurple, Colour::darkPink, - Colour::darkBrown, Colour::bordeauxRed, Colour::salmonPink, Colour::lightBrown, + Colour::darkBrown, Colour::crimson, Colour::copper, Colour::caramel, + Colour::pesto, Colour::asparagus, Colour::pineGreen, Colour::indigo, + Colour::burntPink, + + Colour::brown, Colour::bordeauxRed, Colour::salmonPink, Colour::lightBrown, Colour::darkOliveGreen, Colour::oliveGreen, Colour::darkGreen, Colour::lightPurple, Colour::brightPink, @@ -550,9 +558,19 @@ namespace OpenRCT2::Ui::Windows STR_COLOUR_GRASS_GREEN_DARK_TIP, STR_COLOUR_SATURATED_GREEN_TIP, STR_COLOUR_DEEP_WATER_TIP, - STR_COLOUR_DARK_BLUE_TIP, + STR_COLOUR_DEEP_BLUE_TIP, STR_COLOUR_SATURATED_PURPLE_DARK_TIP, + STR_COLOUR_SILVER_TIP, + STR_COLOUR_RUBY_TIP, + STR_COLOUR_AMBER_TIP, + STR_COLOUR_GOLD_TIP, + STR_COLOUR_CACTUS_TIP, + STR_COLOUR_EMERALD_TIP, + STR_COLOUR_DARKER_WATER_TIP, + STR_COLOUR_DARK_BLUE_TIP, + STR_COLOUR_AMETHYST_TIP, + STR_COLOUR_GREY_TIP, STR_COLOUR_BRIGHT_RED_TIP, STR_COLOUR_LIGHT_ORANGE_TIP, @@ -584,6 +602,16 @@ namespace OpenRCT2::Ui::Windows STR_COLOUR_DARK_PINK_TIP, STR_COLOUR_DARK_BROWN_TIP, + STR_COLOUR_CRIMSON_TIP, + STR_COLOUR_COPPER_TIP, + STR_COLOUR_CARAMEL_TIP, + STR_COLOUR_PESTO_TIP, + STR_COLOUR_ASPARAGUS_TIP, + STR_COLOUR_PINE_GREEN_TIP, + STR_COLOUR_INDIGO_TIP, + STR_COLOUR_BURNT_PINK_TIP, + + STR_COLOUR_BROWN_TIP, STR_COLOUR_BORDEAUX_RED_TIP, STR_COLOUR_SALMON_PINK_TIP, STR_COLOUR_LIGHT_BROWN_TIP, @@ -606,6 +634,7 @@ namespace OpenRCT2::Ui::Windows STR_COLOUR_INVISIBLE_TIP, STR_COLOUR_VOID_TIP, }; + static_assert(kColourTooltips.size() == kColourNumTotal); Colour ColourDropDownIndexToColour(uint8_t ddidx) { diff --git a/src/openrct2/FileClassifier.cpp b/src/openrct2/FileClassifier.cpp index 70f857a640..67193d1811 100644 --- a/src/openrct2/FileClassifier.cpp +++ b/src/openrct2/FileClassifier.cpp @@ -15,6 +15,7 @@ #include "core/Path.hpp" #include "core/String.hpp" #include "park/ParkFile.h" +#include "rct1/RCT1File.h" #include "rct2/RCT2.h" #include "sawyer_coding/SawyerChunkReader.h" #include "sawyer_coding/SawyerCoding.h" @@ -134,21 +135,18 @@ static bool TryClassifyAsS4(IStream* stream, ClassifiedFileInfo* result) size_t dataLength = static_cast(stream->GetLength()); auto data = stream->ReadArray(dataLength); stream->SetPosition(originalPosition); - int32_t fileTypeVersion = DetectFileType(data.get(), dataLength); + auto fileTypeVersion = RCT1::detectFileType(data.get(), dataLength); - int32_t type = fileTypeVersion & FILE_TYPE_MASK; - int32_t version = fileTypeVersion & FILE_VERSION_MASK; - - if (type == FILE_TYPE_SV4) + if (fileTypeVersion.fileType == RCT1::RCT1FileType::sv4) { result->Type = FileType::savedGame; - result->Version = version; + result->Version = EnumValue(fileTypeVersion.version); success = true; } - else if (type == FILE_TYPE_SC4) + else if (fileTypeVersion.fileType == RCT1::RCT1FileType::sc4) { result->Type = FileType::scenario; - result->Version = version; + result->Version = EnumValue(fileTypeVersion.version); success = true; } } diff --git a/src/openrct2/SpriteIds.h b/src/openrct2/SpriteIds.h index d81a8e6c6d..500f1976b2 100644 --- a/src/openrct2/SpriteIds.h +++ b/src/openrct2/SpriteIds.h @@ -1286,6 +1286,24 @@ enum : ImageIndex SPR_PALETTE_DULL_BROWN_LIGHT, SPR_PALETTE_INVISIBLE, SPR_PALETTE_VOID, + SPR_PALETTE_GOLD, + SPR_PALETTE_AMBER, + SPR_PALETTE_AMETHYST, + SPR_PALETTE_ASPARAGUS, + SPR_PALETTE_BROWN, + SPR_PALETTE_BURNT_PINK, + SPR_PALETTE_CACTUS, + SPR_PALETTE_CARAMEL, + SPR_PALETTE_COPPER, + SPR_PALETTE_CRIMSON, + SPR_PALETTE_DARKER_WATER, + SPR_PALETTE_EMERALD, + SPR_PALETTE_INDIGO, + SPR_PALETTE_PESTO, + SPR_PALETTE_PINE_GREEN, + SPR_PALETTE_RUBY, + SPR_PALETTE_DEEP_BLUE, + SPR_PALETTE_SILVER, SPR_PALETTE_2_END, // Additional palettes dumped from G1 @@ -1431,6 +1449,24 @@ enum : ImageIndex SPR_PALETTE_GLASS_DULL_BROWN_LIGHT, SPR_PALETTE_GLASS_INVISIBLE, SPR_PALETTE_GLASS_VOID, + SPR_PALETTE_GLASS_GOLD, + SPR_PALETTE_GLASS_AMBER, + SPR_PALETTE_GLASS_AMETHYST, + SPR_PALETTE_GLASS_ASPARAGUS, + SPR_PALETTE_GLASS_BROWN, + SPR_PALETTE_GLASS_BURNT_PINK, + SPR_PALETTE_GLASS_CACTUS, + SPR_PALETTE_GLASS_CARAMEL, + SPR_PALETTE_GLASS_COPPER, + SPR_PALETTE_GLASS_CRIMSON, + SPR_PALETTE_GLASS_DARKER_WATER, + SPR_PALETTE_GLASS_EMERALD, + SPR_PALETTE_GLASS_INDIGO, + SPR_PALETTE_GLASS_PESTO, + SPR_PALETTE_GLASS_PINE_GREEN, + SPR_PALETTE_GLASS_RUBY, + SPR_PALETTE_GLASS_DEEP_BLUE, + SPR_PALETTE_GLASS_SILVER, SPR_PALETTE_END, // Sprite font characters diff --git a/src/openrct2/actions/ride/RideSetAppearanceAction.cpp b/src/openrct2/actions/ride/RideSetAppearanceAction.cpp index 9b6b00a772..19d7cb67e1 100644 --- a/src/openrct2/actions/ride/RideSetAppearanceAction.cpp +++ b/src/openrct2/actions/ride/RideSetAppearanceAction.cpp @@ -99,27 +99,27 @@ namespace OpenRCT2::GameActions switch (_type) { case RideSetAppearanceType::trackColourMain: - ride->trackColours[_index].main = static_cast(_value); + ride->trackColours[_index].main = Drawing::clampColour(_value); Drawing::GfxInvalidateScreen(); break; case RideSetAppearanceType::trackColourAdditional: - ride->trackColours[_index].additional = static_cast(_value); + ride->trackColours[_index].additional = Drawing::clampColour(_value); Drawing::GfxInvalidateScreen(); break; case RideSetAppearanceType::trackColourSupports: - ride->trackColours[_index].supports = static_cast(_value); + ride->trackColours[_index].supports = Drawing::clampColour(_value); Drawing::GfxInvalidateScreen(); break; case RideSetAppearanceType::vehicleColourBody: - ride->vehicleColours[_index].Body = static_cast(_value); + ride->vehicleColours[_index].Body = Drawing::clampColour(_value); RideUpdateVehicleColours(*ride); break; case RideSetAppearanceType::vehicleColourTrim: - ride->vehicleColours[_index].Trim = static_cast(_value); + ride->vehicleColours[_index].Trim = Drawing::clampColour(_value); RideUpdateVehicleColours(*ride); break; case RideSetAppearanceType::vehicleColourTertiary: - ride->vehicleColours[_index].Tertiary = static_cast(_value); + ride->vehicleColours[_index].Tertiary = Drawing::clampColour(_value); RideUpdateVehicleColours(*ride); break; case RideSetAppearanceType::vehicleColourScheme: diff --git a/src/openrct2/drawing/Colour.cpp b/src/openrct2/drawing/Colour.cpp index c23fbb1e4e..d383e0ba26 100644 --- a/src/openrct2/drawing/Colour.cpp +++ b/src/openrct2/drawing/Colour.cpp @@ -74,6 +74,24 @@ namespace OpenRCT2::Drawing { "dull_brown_light", Colour::beige }, { "invisible", Colour::invisible }, { "void", Colour::voidBackground }, + { "gold", Colour::gold }, + { "amber", Colour::amber }, + { "amethyst", Colour::amethyst }, + { "asparagus", Colour::asparagus }, + { "brown", Colour::brown }, + { "burnt_pink", Colour::burntPink }, + { "cactus", Colour::cactus }, + { "caramel", Colour::caramel }, + { "copper", Colour::copper }, + { "crimson", Colour::crimson }, + { "darker_water", Colour::darkerWater }, + { "emerald", Colour::emerald }, + { "indigo", Colour::indigo }, + { "pesto", Colour::pesto }, + { "pine_green", Colour::pineGreen }, + { "ruby", Colour::ruby }, + { "deep_blue", Colour::deepBlue }, + { "silver", Colour::silver }, }; Colour colourFromString(u8string s, Colour defaultValue) @@ -91,19 +109,27 @@ namespace OpenRCT2::Drawing return "black"; } + static Colour skipNonNormalColour(uint8_t input) + { + if (input >= EnumValue(Colour::invisible)) + return static_cast(input + 2); + + return static_cast(input); + } + Colour getRandomColour() { - return static_cast(UtilRand() % kColourNumNormal); + return skipNonNormalColour(UtilRand() % kColourNumNormal); } Colour getRandomColourNetworkSafe() { - return static_cast(ScenarioRandMax(kColourNumNormal)); + return skipNonNormalColour(ScenarioRandMax(kColourNumNormal)); } Colour getCycleColour(uint32_t ticks) { - return Colour((ticks / 32) % kColourNumNormal); + return skipNonNormalColour((ticks / 32) % kColourNumNormal); } Colour clampColour(uint8_t colour) diff --git a/src/openrct2/drawing/Colour.h b/src/openrct2/drawing/Colour.h index b84370b442..eaa64c02fb 100644 --- a/src/openrct2/drawing/Colour.h +++ b/src/openrct2/drawing/Colour.h @@ -80,10 +80,28 @@ namespace OpenRCT2::Drawing beige, invisible, voidBackground, + gold, + amber, + amethyst, + asparagus, + brown, + burntPink, + cactus, + caramel, + copper, + crimson, + darkerWater, + emerald, + indigo, + pesto, + pineGreen, + ruby, + deepBlue, + silver, }; - constexpr uint8_t kColourNumNormal = 54; - constexpr uint8_t kColourNumTotal = 56; + constexpr uint8_t kColourNumNormal = 72; + constexpr uint8_t kColourNumTotal = 74; constexpr auto kColourNull = static_cast(255); diff --git a/src/openrct2/drawing/Drawing.cpp b/src/openrct2/drawing/Drawing.cpp index b625934d1c..7498c2a5ac 100644 --- a/src/openrct2/drawing/Drawing.cpp +++ b/src/openrct2/drawing/Drawing.cpp @@ -85,6 +85,24 @@ static constexpr FilterPaletteID kGlassPaletteIds[kColourNumTotal] = { FilterPaletteID::paletteGlassDullBrownLight, FilterPaletteID::paletteGlassInvisible, FilterPaletteID::paletteGlassVoid, + FilterPaletteID::paletteGlassGold, + FilterPaletteID::paletteGlassAmber, + FilterPaletteID::paletteGlassAmethyst, + FilterPaletteID::paletteGlassAsparagus, + FilterPaletteID::paletteGlassBrown, + FilterPaletteID::paletteGlassBurntPink, + FilterPaletteID::paletteGlassCactus, + FilterPaletteID::paletteGlassCaramel, + FilterPaletteID::paletteGlassCopper, + FilterPaletteID::paletteGlassCrimson, + FilterPaletteID::paletteGlassDarkerWater, + FilterPaletteID::paletteGlassEmerald, + FilterPaletteID::paletteGlassIndigo, + FilterPaletteID::paletteGlassPesto, + FilterPaletteID::paletteGlassPineGreen, + FilterPaletteID::paletteGlassRuby, + FilterPaletteID::paletteGlassDeepBlue, + FilterPaletteID::paletteGlassSilver, }; // Previously 0x97FCBC use it to get the correct palette from g1_elements @@ -149,6 +167,24 @@ static constexpr uint16_t kPaletteToG1Offset[kPaletteTotalOffsets] = { SPR_PALETTE_DULL_BROWN_LIGHT, SPR_PALETTE_INVISIBLE, SPR_PALETTE_VOID, + SPR_PALETTE_GOLD, + SPR_PALETTE_AMBER, + SPR_PALETTE_AMETHYST, + SPR_PALETTE_ASPARAGUS, + SPR_PALETTE_BROWN, + SPR_PALETTE_BURNT_PINK, + SPR_PALETTE_CACTUS, + SPR_PALETTE_CARAMEL, + SPR_PALETTE_COPPER, + SPR_PALETTE_CRIMSON, + SPR_PALETTE_DARKER_WATER, + SPR_PALETTE_EMERALD, + SPR_PALETTE_INDIGO, + SPR_PALETTE_PESTO, + SPR_PALETTE_PINE_GREEN, + SPR_PALETTE_RUBY, + SPR_PALETTE_DEEP_BLUE, + SPR_PALETTE_SILVER, // Additional palettes SPR_PALETTE_WATER, @@ -293,6 +329,24 @@ static constexpr uint16_t kPaletteToG1Offset[kPaletteTotalOffsets] = { SPR_PALETTE_GLASS_DULL_BROWN_LIGHT, SPR_PALETTE_GLASS_INVISIBLE, SPR_PALETTE_GLASS_VOID, + SPR_PALETTE_GLASS_GOLD, + SPR_PALETTE_GLASS_AMBER, + SPR_PALETTE_GLASS_AMETHYST, + SPR_PALETTE_GLASS_ASPARAGUS, + SPR_PALETTE_GLASS_BROWN, + SPR_PALETTE_GLASS_BURNT_PINK, + SPR_PALETTE_GLASS_CACTUS, + SPR_PALETTE_GLASS_CARAMEL, + SPR_PALETTE_GLASS_COPPER, + SPR_PALETTE_GLASS_CRIMSON, + SPR_PALETTE_GLASS_DARKER_WATER, + SPR_PALETTE_GLASS_EMERALD, + SPR_PALETTE_GLASS_INDIGO, + SPR_PALETTE_GLASS_PESTO, + SPR_PALETTE_GLASS_PINE_GREEN, + SPR_PALETTE_GLASS_RUBY, + SPR_PALETTE_GLASS_DEEP_BLUE, + SPR_PALETTE_GLASS_SILVER, }; static constexpr TranslucentWindowPalette kWindowPaletteGrey = { FilterPaletteID::paletteTranslucentGrey, FilterPaletteID::paletteTranslucentGreyHighlight, FilterPaletteID::paletteTranslucentGreyShadow }; @@ -371,6 +425,24 @@ const TranslucentWindowPalette kTranslucentWindowPalettes[kColourNumTotal] = { kWindowPaletteDarkBrown, // Colour::beige { FilterPaletteID::paletteDarken1, FilterPaletteID::paletteDarken1, FilterPaletteID::paletteDarken1 }, { FilterPaletteID::paletteDarken2, FilterPaletteID::paletteDarken2, FilterPaletteID::paletteDarken2 }, + kWindowPaletteYellow, // Colour::gold + kWindowPaletteLightOrange, // Colour::amber + kWindowPaletteBrightPurple, // Colour::amethyst + kWindowPaletteOliveGreen, // Colour::asparagus + kWindowPaletteDarkBrown, // Colour::brown + kWindowPaletteBrightPink, // Colour::burntPink + kWindowPaletteMossGreen, // Colour::cactus + kWindowPaletteLightBrown, // Colour::caramel + kWindowPaletteSalmonPink, // Colour::copper + kWindowPaletteBordeauxRed, // Colour::crimson + kWindowPaletteTeal, // Colour::darkerWater + kWindowPaletteBrightGreen, // Colour::emerald + kWindowPaletteLightPurple, // Colour::indigo + kWindowPaletteDarkOliveGreen, // Colour::pesto + kWindowPaletteDarkGreen, // Colour::pineGreen + kWindowPaletteBrightRed, // Colour::ruby + kWindowPaletteLightBlue, // Colour::deepBlue + kWindowPaletteGrey, // Colour::silver }; // clang-format on diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index 360cd20399..2864a34af6 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -39,7 +39,8 @@ namespace OpenRCT2::Drawing }; } // namespace OpenRCT2::Drawing -constexpr uint8_t kPaletteTotalOffsets = 192; +// Every colour is represented two times as a FilterPaletteID, once as a regular colour and once as a glass colour. +constexpr uint16_t kPaletteTotalOffsets = 80 + (2 * OpenRCT2::Drawing::kColourNumTotal); extern const OpenRCT2::Drawing::TranslucentWindowPalette kTranslucentWindowPalettes[OpenRCT2::Drawing::kColourNumTotal]; diff --git a/src/openrct2/drawing/FilterPaletteIds.h b/src/openrct2/drawing/FilterPaletteIds.h index 6ad3f2981c..f0138eaed4 100644 --- a/src/openrct2/drawing/FilterPaletteIds.h +++ b/src/openrct2/drawing/FilterPaletteIds.h @@ -161,5 +161,23 @@ namespace OpenRCT2::Drawing paletteGlassDullBrownLight = paletteGlass + EnumValue(Colour::beige), paletteGlassInvisible = paletteGlass + EnumValue(Colour::invisible), paletteGlassVoid = paletteGlass + EnumValue(Colour::voidBackground), + paletteGlassGold = paletteGlass + EnumValue(Colour::gold), + paletteGlassAmber = paletteGlass + EnumValue(Colour::amber), + paletteGlassAmethyst = paletteGlass + EnumValue(Colour::amethyst), + paletteGlassAsparagus = paletteGlass + EnumValue(Colour::asparagus), + paletteGlassBrown = paletteGlass + EnumValue(Colour::brown), + paletteGlassBurntPink = paletteGlass + EnumValue(Colour::burntPink), + paletteGlassCactus = paletteGlass + EnumValue(Colour::cactus), + paletteGlassCaramel = paletteGlass + EnumValue(Colour::caramel), + paletteGlassCopper = paletteGlass + EnumValue(Colour::copper), + paletteGlassCrimson = paletteGlass + EnumValue(Colour::crimson), + paletteGlassDarkerWater = paletteGlass + EnumValue(Colour::darkerWater), + paletteGlassEmerald = paletteGlass + EnumValue(Colour::emerald), + paletteGlassIndigo = paletteGlass + EnumValue(Colour::indigo), + paletteGlassPesto = paletteGlass + EnumValue(Colour::pesto), + paletteGlassPineGreen = paletteGlass + EnumValue(Colour::pineGreen), + paletteGlassRuby = paletteGlass + EnumValue(Colour::ruby), + paletteGlassDeepBlue = paletteGlass + EnumValue(Colour::deepBlue), + paletteGlassSilver = paletteGlass + EnumValue(Colour::silver), }; } diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index a4d4d8a49d..60b10e0631 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -468,6 +468,7 @@ + @@ -1170,6 +1171,7 @@ + diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index c37757486d..2a9d6e9760 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -47,7 +47,7 @@ // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -constexpr uint8_t kStreamVersion = 1; +constexpr uint8_t kStreamVersion = 2; const std::string kStreamID = std::string(kOpenRCT2Version) + "-" + std::to_string(kStreamVersion); diff --git a/src/openrct2/park/Legacy.cpp b/src/openrct2/park/Legacy.cpp index 64b50188b0..ab7a063909 100644 --- a/src/openrct2/park/Legacy.cpp +++ b/src/openrct2/park/Legacy.cpp @@ -11,6 +11,7 @@ #include "../Context.h" #include "../Diagnostic.h" +#include "../core/OrcaStream.hpp" #include "../entity/EntityList.h" #include "../entity/Guest.h" #include "../entity/Staff.h" @@ -31,6 +32,7 @@ #include using namespace OpenRCT2; +using OpenRCT2::Drawing::Colour; static const std::unordered_map kOldObjectIds = { { "official.scgpanda", "rct2dlc.scenery_group.scgpanda" }, @@ -3173,3 +3175,36 @@ void updateSurfaceElementsColour( } } } + +Colour convertPre63Colour(uint8_t colour) +{ + // In many cases, colours are interpreted as FilterPaletteId. Of course, this has been abused to render rides + // using e.g. water effects (which start right after the last valid colour). Account for this by shifting the + // number by the number of newly added colours. + constexpr auto kOldNumColours = 56; + constexpr auto kNumNewColours = 18; + if (colour >= kOldNumColours) + { + colour += kNumNewColours; + } + + return static_cast(colour); +} + +Colour convertPre63Colour(Colour colour) +{ + return convertPre63Colour(EnumValue(colour)); +} + +void readWriteColour(OrcaStream::ChunkStream& cs, Colour& colourField, uint32_t parkFileVersion) +{ + if (parkFileVersion >= kExtendedColoursGoldVersion) + { + cs.readWrite(colourField); + return; + } + + uint8_t tempColour{}; + cs.readWrite(tempColour); + colourField = convertPre63Colour(tempColour); +} diff --git a/src/openrct2/park/Legacy.h b/src/openrct2/park/Legacy.h index 04fbf23c15..f2b985e6df 100644 --- a/src/openrct2/park/Legacy.h +++ b/src/openrct2/park/Legacy.h @@ -10,6 +10,7 @@ #pragma once #include "../core/FlagHolder.hpp" +#include "../core/OrcaStream.hpp" #include "../object/ObjectTypes.h" #include @@ -85,3 +86,6 @@ std::pair splitCombinedNumDropsPoweredLifts(uint8_t combinedVa void updateSurfaceElementsColour( OpenRCT2::GameState_t& gameState, std::span terrainSurfaceMap, std::span terrainEdgeMap); +OpenRCT2::Drawing::Colour convertPre63Colour(uint8_t colour); +OpenRCT2::Drawing::Colour convertPre63Colour(OpenRCT2::Drawing::Colour colour); +void readWriteColour(OpenRCT2::OrcaStream::ChunkStream& cs, OpenRCT2::Drawing::Colour& colourField, uint32_t parkFileVersion); diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index efd5ffca2b..9bb2e8ae57 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -55,10 +55,13 @@ #include "../world/Scenery.h" #include "../world/TileElementsView.h" #include "../world/Weather.h" +#include "../world/tile_element/BannerElement.h" +#include "../world/tile_element/LargeSceneryElement.h" #include "../world/tile_element/PathElement.h" #include "../world/tile_element/SmallSceneryElement.h" #include "../world/tile_element/SurfaceElement.h" #include "../world/tile_element/TrackElement.h" +#include "../world/tile_element/WallElement.h" #include "Legacy.h" #include "ParkPreview.h" @@ -986,9 +989,9 @@ namespace OpenRCT2 cs.readWrite(park.entranceFee); } - cs.readWrite(park.staffHandymanColour); - cs.readWrite(park.staffMechanicColour); - cs.readWrite(park.staffSecurityColour); + readWriteColour(cs, park.staffHandymanColour, version); + readWriteColour(cs, park.staffMechanicColour, version); + readWriteColour(cs, park.staffSecurityColour, version); cs.readWrite(park.samePriceThroughoutPark); // Finances @@ -1282,56 +1285,115 @@ namespace OpenRCT2 cs.read(tileElements.data(), tileElements.size() * sizeof(TileElement)); SetTileElements(gameState, std::move(tileElements)); + auto targetVersion = os.getHeader().targetVersion; TileElementIterator it; TileElementIteratorBegin(&it); while (TileElementIteratorNext(&it)) { - if (it.element->getType() == TileElementType::path) + switch (it.element->getType()) { - auto* pathElement = it.element->asPath(); - if (pathElement->hasLegacyPathEntry()) + case TileElementType::banner: { - auto pathEntryIndex = pathElement->getLegacyPathEntryIndex(); - if (pathToRailingsMap[pathEntryIndex] != kObjectEntryIndexNull) + if (targetVersion < kExtendedColoursGoldVersion) { - if (pathElement->isQueue()) - pathElement->setSurfaceEntryIndex(pathToQueueSurfaceMap[pathEntryIndex]); - else - pathElement->setSurfaceEntryIndex(pathToSurfaceMap[pathEntryIndex]); - - pathElement->setRailingsEntryIndex(pathToRailingsMap[pathEntryIndex]); + auto* banner = it.element->asBanner()->getBanner(); + if (banner != nullptr) + { + banner->colour = convertPre63Colour(banner->colour); + } } + break; } - } - else if (it.element->getType() == TileElementType::track) - { - auto* trackElement = it.element->asTrack(); - auto trackType = trackElement->getTrackType(); - if (TrackTypeMustBeMadeInvisible(*trackElement, os.getHeader().targetVersion)) + case TileElementType::surface: + break; + case TileElementType::path: { - it.element->setInvisible(true); + auto* pathElement = it.element->asPath(); + if (pathElement->hasLegacyPathEntry()) + { + auto pathEntryIndex = pathElement->getLegacyPathEntryIndex(); + if (pathToRailingsMap[pathEntryIndex] != kObjectEntryIndexNull) + { + if (pathElement->isQueue()) + pathElement->setSurfaceEntryIndex(pathToQueueSurfaceMap[pathEntryIndex]); + else + pathElement->setSurfaceEntryIndex(pathToSurfaceMap[pathEntryIndex]); + + pathElement->setRailingsEntryIndex(pathToRailingsMap[pathEntryIndex]); + } + } + break; } - if (os.getHeader().targetVersion < kBlockBrakeImprovementsVersion) + case TileElementType::track: { - if (trackType == TrackElemType::brakes) - trackElement->setBrakeClosed(true); - if (trackType == TrackElemType::blockBrakes) - trackElement->setBrakeBoosterSpeed(kRCT2DefaultBlockBrakeSpeed); + auto* trackElement = it.element->asTrack(); + auto trackType = trackElement->getTrackType(); + if (TrackTypeMustBeMadeInvisible(*trackElement, targetVersion)) + { + it.element->setInvisible(true); + } + if (targetVersion < kBlockBrakeImprovementsVersion) + { + if (trackType == TrackElemType::brakes) + trackElement->setBrakeClosed(true); + if (trackType == TrackElemType::blockBrakes) + trackElement->setBrakeBoosterSpeed(kRCT2DefaultBlockBrakeSpeed); + } + break; } - } - else if (it.element->getType() == TileElementType::smallScenery && os.getHeader().targetVersion < 23) - { - auto* sceneryElement = it.element->asSmallScenery(); - // Previous formats stored the needs supports flag in the primary colour - // We have moved it into a flags field to support extended colour sets - bool needsSupports = EnumValue(sceneryElement->getPrimaryColour()) - & kRCT12SmallSceneryElementNeedsSupportsFlag; - if (needsSupports) + case TileElementType::smallScenery: { - const auto valueWithoutFlag = EnumValue(sceneryElement->getPrimaryColour()) - & ~kRCT12SmallSceneryElementNeedsSupportsFlag; - sceneryElement->setPrimaryColour(static_cast(valueWithoutFlag)); - sceneryElement->setNeedsSupports(); + if (targetVersion < 23) + { + auto* sceneryElement = it.element->asSmallScenery(); + // Previous formats stored the needs supports flag in the primary colour + // We have moved it into a flags field to support extended colour sets + bool needsSupports = EnumValue(sceneryElement->getPrimaryColour()) + & kRCT12SmallSceneryElementNeedsSupportsFlag; + if (needsSupports) + { + const auto valueWithoutFlag = EnumValue(sceneryElement->getPrimaryColour()) + & ~kRCT12SmallSceneryElementNeedsSupportsFlag; + sceneryElement->setPrimaryColour(static_cast(valueWithoutFlag)); + sceneryElement->setNeedsSupports(); + } + } + if (targetVersion < kExtendedColoursGoldVersion) + { + auto* sceneryElement = it.element->asSmallScenery(); + sceneryElement->setPrimaryColour( + convertPre63Colour(sceneryElement->getPrimaryColour()), true); + sceneryElement->setSecondaryColour( + convertPre63Colour(sceneryElement->getSecondaryColour()), true); + sceneryElement->setTertiaryColour( + convertPre63Colour(sceneryElement->getTertiaryColour()), true); + } + break; + } + case TileElementType::entrance: + break; + case TileElementType::wall: + { + if (targetVersion < kExtendedColoursGoldVersion) + { + auto* wallElement = it.element->asWall(); + wallElement->setPrimaryColour(convertPre63Colour(wallElement->getPrimaryColour())); + wallElement->setSecondaryColour(convertPre63Colour(wallElement->getSecondaryColour())); + wallElement->setTertiaryColour(convertPre63Colour(wallElement->getTertiaryColour())); + } + break; + } + case TileElementType::largeScenery: + { + if (targetVersion < kExtendedColoursGoldVersion) + { + auto* sceneryElement = it.element->asLargeScenery(); + sceneryElement->setPrimaryColour(convertPre63Colour(sceneryElement->getPrimaryColour())); + sceneryElement->setSecondaryColour( + convertPre63Colour(sceneryElement->getSecondaryColour())); + sceneryElement->setTertiaryColour(convertPre63Colour(sceneryElement->getTertiaryColour())); + } + break; } } } @@ -1434,7 +1496,7 @@ namespace OpenRCT2 cs.readWrite(banner.type); cs.readWrite(banner.flags.holder); cs.readWrite(banner.text); - cs.readWrite(banner.colour); + readWriteColour(cs, banner.colour, version); cs.readWrite(banner.rideIndex); cs.readWrite(banner.textColour); cs.readWrite(banner.position.x); @@ -1516,17 +1578,17 @@ namespace OpenRCT2 // Colours cs.readWrite(ride.entranceStyle); cs.readWrite(ride.vehicleColourSettings); - cs.readWriteArray(ride.trackColours, [&cs](TrackColour& tc) { - cs.readWrite(tc.main); - cs.readWrite(tc.additional); - cs.readWrite(tc.supports); + cs.readWriteArray(ride.trackColours, [&cs, version](TrackColour& tc) { + readWriteColour(cs, tc.main, version); + readWriteColour(cs, tc.additional, version); + readWriteColour(cs, tc.supports, version); return true; }); - cs.readWriteArray(ride.vehicleColours, [&cs](VehicleColour& vc) { - cs.readWrite(vc.Body); - cs.readWrite(vc.Trim); - cs.readWrite(vc.Tertiary); + cs.readWriteArray(ride.vehicleColours, [&cs, version](VehicleColour& vc) { + readWriteColour(cs, vc.Body, version); + readWriteColour(cs, vc.Trim, version); + readWriteColour(cs, vc.Tertiary, version); return true; }); @@ -1590,7 +1652,7 @@ namespace OpenRCT2 cs.readWrite(ride.chairliftBullwheelRotation); cs.readWrite(ride.slideInUse); cs.readWrite(ride.slidePeep); - cs.readWrite(ride.slidePeepTShirtColour); + readWriteColour(cs, ride.slidePeepTShirtColour, version); cs.readWrite(ride.spiralSlideProgress); cs.readWrite(ride.raceWinner); cs.readWrite(ride.cableLift); @@ -1910,8 +1972,8 @@ namespace OpenRCT2 } } - cs.readWrite(entity.tShirtColour); - cs.readWrite(entity.trousersColour); + readWriteColour(cs, entity.tShirtColour, version); + readWriteColour(cs, entity.trousersColour, version); cs.readWrite(entity.destinationX); cs.readWrite(entity.destinationY); cs.readWrite(entity.destinationTolerance); @@ -2182,9 +2244,9 @@ namespace OpenRCT2 cs.readWrite(guest->angriness); cs.readWrite(guest->timeLost); cs.readWrite(guest->daysInQueue); - cs.readWrite(guest->balloonColour); - cs.readWrite(guest->umbrellaColour); - cs.readWrite(guest->hatColour); + readWriteColour(cs, guest->balloonColour, version); + readWriteColour(cs, guest->umbrellaColour, version); + readWriteColour(cs, guest->hatColour, version); cs.readWrite(guest->favouriteRide); cs.readWrite(guest->favouriteRideRating); } @@ -2264,6 +2326,7 @@ namespace OpenRCT2 template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, Vehicle& entity) { + auto version = os.getHeader().targetVersion; ReadWriteEntityCommon(cs, entity); cs.readWrite(entity.SubType); cs.readWrite(entity.pitch); @@ -2273,8 +2336,8 @@ namespace OpenRCT2 cs.readWrite(entity.acceleration); cs.readWrite(entity.ride); cs.readWrite(entity.vehicle_type); - cs.readWrite(entity.colours.Body); - cs.readWrite(entity.colours.Trim); + readWriteColour(cs, entity.colours.Body, version); + readWriteColour(cs, entity.colours.Trim, version); cs.readWrite(entity.track_progress); cs.readWrite(entity.BoatLocation); cs.readWrite(entity.TrackTypeAndDirection); @@ -2286,7 +2349,7 @@ namespace OpenRCT2 cs.readWrite(entity.next_vehicle_on_ride); cs.readWrite(entity.var_44); cs.readWrite(entity.mass); - if (cs.getMode() == OrcaStream::Mode::reading && os.getHeader().targetVersion < 18) + if (cs.getMode() == OrcaStream::Mode::reading && version < 18) { uint16_t updateFlags = 0; cs.readWrite(updateFlags); @@ -2305,7 +2368,7 @@ namespace OpenRCT2 for (size_t i = 0; i < std::size(entity.peep); i++) { cs.readWrite(entity.peep[i]); - cs.readWrite(entity.peep_tshirt_colours[i]); + readWriteColour(cs, entity.peep_tshirt_colours[i], version); } cs.readWrite(entity.num_seats); cs.readWrite(entity.num_peeps); @@ -2356,7 +2419,7 @@ namespace OpenRCT2 cs.readWrite(entity.mini_golf_current_animation); cs.readWrite(entity.miniGolfFlags.holder); cs.readWrite(entity.ride_subtype); - cs.readWrite(entity.colours.Tertiary); + readWriteColour(cs, entity.colours.Tertiary, version); cs.readWrite(entity.seat_rotation); cs.readWrite(entity.target_seat_rotation); if (cs.getMode() == OrcaStream::Mode::reading && os.getHeader().targetVersion < 18) @@ -2543,9 +2606,9 @@ namespace OpenRCT2 cs.readWrite(guest.angriness); cs.readWrite(guest.timeLost); cs.readWrite(guest.daysInQueue); - cs.readWrite(guest.balloonColour); - cs.readWrite(guest.umbrellaColour); - cs.readWrite(guest.hatColour); + readWriteColour(cs, guest.balloonColour, version); + readWriteColour(cs, guest.umbrellaColour, version); + readWriteColour(cs, guest.hatColour, version); cs.readWrite(guest.favouriteRide); cs.readWrite(guest.favouriteRideRating); cs.readWrite(guest.itemFlags.holder); @@ -2621,12 +2684,13 @@ namespace OpenRCT2 template<> void ParkFile::ReadWriteEntity(OrcaStream& os, OrcaStream::ChunkStream& cs, VehicleCrashParticle& vehicleCrashParticle) { + auto version = os.getHeader().targetVersion; ReadWriteEntityCommon(cs, vehicleCrashParticle); cs.readWrite(vehicleCrashParticle.frame); cs.readWrite(vehicleCrashParticle.timeToLive); cs.readWrite(vehicleCrashParticle.frame); - cs.readWrite(vehicleCrashParticle.colour[0]); - cs.readWrite(vehicleCrashParticle.colour[1]); + readWriteColour(cs, vehicleCrashParticle.colour[0], version); + readWriteColour(cs, vehicleCrashParticle.colour[1], version); cs.readWrite(vehicleCrashParticle.crashedSpriteBase); cs.readWrite(vehicleCrashParticle.velocityX); cs.readWrite(vehicleCrashParticle.velocityY); @@ -2677,7 +2741,7 @@ namespace OpenRCT2 cs.readWrite(balloon.popped); cs.readWrite(balloon.timeToMove); cs.readWrite(balloon.frame); - cs.readWrite(balloon.colour); + readWriteColour(cs, balloon.colour, os.getHeader().targetVersion); } template<> diff --git a/src/openrct2/park/ParkFile.h b/src/openrct2/park/ParkFile.h index 3bc88009d9..b265280513 100644 --- a/src/openrct2/park/ParkFile.h +++ b/src/openrct2/park/ParkFile.h @@ -19,7 +19,7 @@ namespace OpenRCT2 struct ObjectRepositoryItem; // Current version that is saved. - constexpr uint32_t kParkFileCurrentVersion = 62; + constexpr uint32_t kParkFileCurrentVersion = 63; // The minimum version that is forwards compatible with the current version. constexpr uint32_t kParkFileMinVersion = 57; @@ -62,6 +62,8 @@ namespace OpenRCT2 constexpr uint16_t kParkFileVersionUprightQuarterHelices = 60; constexpr uint16_t kExtendedInvertedRollerCoasterVersion = 61; constexpr uint16_t kColourableTerrainVersion = 62; + // Added 18 additional colours, including some removed colours from the RCT1 base game and betas. + constexpr uint16_t kExtendedColoursGoldVersion = 63; class ParkFileExporter { diff --git a/src/openrct2/rct1/RCT1File.cpp b/src/openrct2/rct1/RCT1File.cpp new file mode 100644 index 0000000000..27472877bf --- /dev/null +++ b/src/openrct2/rct1/RCT1File.cpp @@ -0,0 +1,55 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "RCT1File.h" + +#include "../core/Numerics.hpp" + +#include + +namespace OpenRCT2::RCT1 +{ + RCT1VersionAndFileType detectFileType(const uint8_t* src, size_t length) + { + if (length < 4) + { + throw std::length_error("Stream is (nearly) empty!"); + } + + // Currently can't detect TD4, as the checksum is the same as SC4 (need alternative method) + + uint32_t checksum = *(reinterpret_cast(&src[length - 4])); + uint32_t actualChecksum = 0; + for (size_t i = 0; i < length - 4; i++) + { + actualChecksum = (actualChecksum & 0xFFFFFF00) | (((actualChecksum & 0xFF) + static_cast(src[i])) & 0xFF); + actualChecksum = Numerics::rol32(actualChecksum, 3); + } + + return detectRCT1Version(checksum - actualChecksum); + } + + RCT1VersionAndFileType detectRCT1Version(int32_t gameVersion) + { + auto fileType = (gameVersion) > 0 ? RCT1FileType::sv4 : RCT1FileType::sc4; + gameVersion = abs(gameVersion); + + if (gameVersion >= 108000 && gameVersion < 110000) + return RCT1VersionAndFileType(RCT1Version::baseGame, fileType); + if (gameVersion >= 110000 && gameVersion < 120000) + return RCT1VersionAndFileType(RCT1Version::addedAttractions, fileType); + if (gameVersion >= 120000 && gameVersion < 130000) + return RCT1VersionAndFileType(RCT1Version::loopyLandscapes, fileType); + // RCTOA Acres sets this, and possibly some other user-created scenarios as well + if (gameVersion == 0) + return RCT1VersionAndFileType(RCT1Version::loopyLandscapes, fileType); + + throw std::length_error("Unrecognised game version!"); + } +} // namespace OpenRCT2::RCT1 diff --git a/src/openrct2/rct1/RCT1File.h b/src/openrct2/rct1/RCT1File.h new file mode 100644 index 0000000000..9803cec4ab --- /dev/null +++ b/src/openrct2/rct1/RCT1File.h @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include +#include + +namespace OpenRCT2::RCT1 +{ + enum class RCT1Version : uint8_t + { + baseGame, + addedAttractions, + loopyLandscapes, + }; + enum class RCT1FileType : uint8_t + { + td4, + sv4, + sc4, + }; + struct RCT1VersionAndFileType + { + RCT1Version version; + RCT1FileType fileType; + }; + + RCT1VersionAndFileType detectFileType(const uint8_t* src, size_t length); + RCT1VersionAndFileType detectRCT1Version(int32_t gameVersion); +} // namespace OpenRCT2::RCT1 diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 411425e2ae..10ac546496 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -42,8 +42,6 @@ #include "../object/ScenarioMetaObject.h" #include "../park/Legacy.h" #include "../peep/RideUseSystem.h" -#include "../rct1/RCT1.h" -#include "../rct1/Tables.h" #include "../rct12/CSStringConverter.h" #include "../rct12/EntryList.h" #include "../rct12/ScenarioPatcher.h" @@ -75,6 +73,7 @@ #include "../world/tile_element/TrackElement.h" #include "../world/tile_element/WallElement.h" #include "RCT1.h" +#include "RCT1File.h" #include "Tables.h" #include @@ -102,7 +101,7 @@ namespace OpenRCT2::RCT1 std::string _s4Path; S4 _s4 = {}; - uint8_t _gameVersion = 0; + RCT1Version _gameVersion = RCT1Version::baseGame; uint8_t _parkValueConversionFactor = kDefaultParkValueConversionFactor; bool _isScenario = false; @@ -178,7 +177,7 @@ namespace OpenRCT2::RCT1 _s4 = *ReadAndDecodeS4(stream, isScenario); _s4Path = path; _isScenario = isScenario; - _gameVersion = DetectRCT1Version(_s4.GameVersion) & FILE_VERSION_MASK; + _gameVersion = detectRCT1Version(_s4.GameVersion).version; // Only determine what objects we required to import this saved game InitialiseEntryMaps(); @@ -322,8 +321,8 @@ namespace OpenRCT2::RCT1 auto decodedData = std::make_unique(sizeof(S4)); size_t decodedSize; - int32_t fileType = DetectFileType(data.get(), dataSize); - if (isScenario && (fileType & FILE_VERSION_MASK) != FILE_VERSION_RCT1) + auto fileType = detectFileType(data.get(), dataSize); + if (isScenario && fileType.version != RCT1Version::baseGame) { decodedSize = DecodeSC4(data.get(), decodedData.get(), dataSize, sizeof(S4)); } @@ -627,14 +626,11 @@ namespace OpenRCT2::RCT1 void AddEntryForWater() { std::string_view entryName; - if (_gameVersion < FILE_VERSION_RCT1_LL) - { - entryName = GetWaterObject(RCT1_WATER_CYAN); - } - else - { + if (_gameVersion == RCT1Version::loopyLandscapes) entryName = GetWaterObject(_s4.WaterColour); - } + else + entryName = GetWaterObject(RCT1_WATER_CYAN); + _waterEntry.GetOrAddEntry(entryName); } @@ -644,7 +640,7 @@ namespace OpenRCT2::RCT1 if (_rideTypeToRideEntryMap[EnumValue(rideType)] == kObjectEntryIndexNull) { - auto entryName = GetRideTypeObject(rideType, _gameVersion == FILE_VERSION_RCT1_LL); + auto entryName = GetRideTypeObject(rideType, _gameVersion == RCT1Version::loopyLandscapes); if (!entryName.empty()) { auto entryIndex = _rideEntries.GetOrAddEntry(entryName); @@ -861,7 +857,7 @@ namespace OpenRCT2::RCT1 // Flags dst->flags.holder = src->flags; // These flags were not in the base game - if (_gameVersion == FILE_VERSION_RCT1) + if (_gameVersion == RCT1Version::baseGame) { dst->flags.unset(RideFlag::music, RideFlag::indestructible, RideFlag::indestructibleTrack); } @@ -966,7 +962,7 @@ namespace OpenRCT2::RCT1 dst->music = kObjectEntryIndexNull; if (GetRideTypeDescriptor(dst->type).flags.has(RtdFlag::allowMusic)) { - if (_gameVersion == FILE_VERSION_RCT1) + if (_gameVersion == RCT1Version::baseGame) { // Original RCT had no music settings, take default style auto style = GetStyleFromMusicIdentifier(GetRideTypeDescriptor(dst->type).DefaultMusic); @@ -1069,7 +1065,7 @@ namespace OpenRCT2::RCT1 dst->currentTestStation = StationIndex::GetNull(); dst->averageSpeedTestTimeout = src->averageSpeedTestTimeout; dst->slideInUse = src->slideInUse; - dst->slidePeepTShirtColour = GetColour(src->slidePeepTshirtColour); + dst->slidePeepTShirtColour = getColour(src->slidePeepTshirtColour, _gameVersion); dst->spiralSlideProgress = src->spiralSlideProgress; // Doubles as slidePeep dst->mazeTiles = src->mazeTiles; @@ -1104,11 +1100,11 @@ namespace OpenRCT2::RCT1 { // Colours dst->vehicleColourSettings = src->vehicleColourSettings; - if (_gameVersion == FILE_VERSION_RCT1) + if (_gameVersion == RCT1Version::baseGame) { - dst->trackColours[0].main = GetColour(src->trackPrimaryColour); - dst->trackColours[0].additional = GetColour(src->trackSecondaryColour); - dst->trackColours[0].supports = GetColour(src->trackSupportColour); + dst->trackColours[0].main = getColour(src->trackPrimaryColour, _gameVersion); + dst->trackColours[0].additional = getColour(src->trackSecondaryColour, _gameVersion); + dst->trackColours[0].supports = getColour(src->trackSupportColour, _gameVersion); // Balloons were always blue in the original RCT. if (src->type == RideType::balloonStall) @@ -1124,9 +1120,9 @@ namespace OpenRCT2::RCT1 { for (int i = 0; i < Limits::kNumColourSchemes; i++) { - dst->trackColours[i].main = GetColour(src->trackColourMain[i]); - dst->trackColours[i].additional = GetColour(src->trackColourAdditional[i]); - dst->trackColours[i].supports = GetColour(src->trackColourSupports[i]); + dst->trackColours[i].main = getColour(src->trackColourMain[i], _gameVersion); + dst->trackColours[i].additional = getColour(src->trackColourAdditional[i], _gameVersion); + dst->trackColours[i].supports = getColour(src->trackColourSupports[i], _gameVersion); } } @@ -1134,7 +1130,7 @@ namespace OpenRCT2::RCT1 if (dst->getRideTypeDescriptor().flags.has(RtdFlag::hasEntranceAndExit)) { // Entrance styles were introduced with AA. They correspond directly with those in RCT2. - if (_gameVersion == FILE_VERSION_RCT1) + if (_gameVersion == RCT1Version::baseGame) { dst->entranceStyle = 0; // plain entrance } @@ -1144,7 +1140,7 @@ namespace OpenRCT2::RCT1 } } - if (_gameVersion < FILE_VERSION_RCT1_LL && src->type == RideType::merryGoRound) + if (_gameVersion != RCT1Version::loopyLandscapes && src->type == RideType::merryGoRound) { // The merry-go-round in pre-LL versions was always yellow with red dst->vehicleColours[0].Body = Drawing::Colour::yellow; @@ -1158,11 +1154,11 @@ namespace OpenRCT2::RCT1 const auto colourSchemeCopyDescriptor = GetColourSchemeCopyDescriptor(src->vehicleType); if (colourSchemeCopyDescriptor.colour1 == kCopyColour1) { - dst->vehicleColours[i].Body = GetColour(src->vehicleColours[i].body); + dst->vehicleColours[i].Body = getColour(src->vehicleColours[i].body, _gameVersion); } else if (colourSchemeCopyDescriptor.colour1 == kCopyColour2) { - dst->vehicleColours[i].Body = GetColour(src->vehicleColours[i].trim); + dst->vehicleColours[i].Body = getColour(src->vehicleColours[i].trim, _gameVersion); } else { @@ -1171,11 +1167,11 @@ namespace OpenRCT2::RCT1 if (colourSchemeCopyDescriptor.colour2 == kCopyColour1) { - dst->vehicleColours[i].Trim = GetColour(src->vehicleColours[i].body); + dst->vehicleColours[i].Trim = getColour(src->vehicleColours[i].body, _gameVersion); } else if (colourSchemeCopyDescriptor.colour2 == kCopyColour2) { - dst->vehicleColours[i].Trim = GetColour(src->vehicleColours[i].trim); + dst->vehicleColours[i].Trim = getColour(src->vehicleColours[i].trim, _gameVersion); } else { @@ -1184,11 +1180,11 @@ namespace OpenRCT2::RCT1 if (colourSchemeCopyDescriptor.colour3 == kCopyColour1) { - dst->vehicleColours[i].Tertiary = GetColour(src->vehicleColours[i].body); + dst->vehicleColours[i].Tertiary = getColour(src->vehicleColours[i].body, _gameVersion); } else if (colourSchemeCopyDescriptor.colour3 == kCopyColour2) { - dst->vehicleColours[i].Tertiary = GetColour(src->vehicleColours[i].trim); + dst->vehicleColours[i].Tertiary = getColour(src->vehicleColours[i].trim, _gameVersion); } else { @@ -1201,7 +1197,7 @@ namespace OpenRCT2::RCT1 // LL has 4 types, like RCT2. For LL, only guard against invalid values. if (src->type == RideType::hedgeMaze) { - if (_gameVersion < FILE_VERSION_RCT1_LL || src->trackColourSupports[0] > 3) + if (_gameVersion != RCT1Version::loopyLandscapes || src->trackColourSupports[0] > 3) dst->trackColours[0].supports = static_cast(hedges); else dst->trackColours[0].supports = static_cast(src->trackColourSupports[0]); @@ -1288,11 +1284,11 @@ namespace OpenRCT2::RCT1 // RCT1 had no third colour if (colourSchemeCopyDescriptor.colour1 == kCopyColour1) { - dst->colours.Body = GetColour(src->Colours.BodyColour); + dst->colours.Body = getColour(src->Colours.BodyColour, _gameVersion); } else if (colourSchemeCopyDescriptor.colour1 == kCopyColour2) { - dst->colours.Body = GetColour(src->Colours.TrimColour); + dst->colours.Body = getColour(src->Colours.TrimColour, _gameVersion); } else { @@ -1301,11 +1297,11 @@ namespace OpenRCT2::RCT1 if (colourSchemeCopyDescriptor.colour2 == kCopyColour1) { - dst->colours.Trim = GetColour(src->Colours.BodyColour); + dst->colours.Trim = getColour(src->Colours.BodyColour, _gameVersion); } else if (colourSchemeCopyDescriptor.colour2 == kCopyColour2) { - dst->colours.Trim = GetColour(src->Colours.TrimColour); + dst->colours.Trim = getColour(src->Colours.TrimColour, _gameVersion); } else { @@ -1314,11 +1310,11 @@ namespace OpenRCT2::RCT1 if (colourSchemeCopyDescriptor.colour3 == kCopyColour1) { - dst->colours.Tertiary = GetColour(src->Colours.BodyColour); + dst->colours.Tertiary = getColour(src->Colours.BodyColour, _gameVersion); } else if (colourSchemeCopyDescriptor.colour3 == kCopyColour2) { - dst->colours.Tertiary = GetColour(src->Colours.TrimColour); + dst->colours.Tertiary = getColour(src->Colours.TrimColour, _gameVersion); } else { @@ -1364,8 +1360,8 @@ namespace OpenRCT2::RCT1 dst->nextFlags = src->NextFlags; dst->var37 = src->Var37; dst->stepProgress = src->StepProgress; - dst->tShirtColour = GetColour(src->TshirtColour); - dst->trousersColour = GetColour(src->TrousersColour); + dst->tShirtColour = getColour(src->TshirtColour, _gameVersion); + dst->trousersColour = getColour(src->TrousersColour, _gameVersion); dst->destinationX = src->DestinationX; dst->destinationY = src->DestinationY; dst->destinationTolerance = src->DestinationTolerance; @@ -1710,7 +1706,7 @@ namespace OpenRCT2::RCT1 } uint8_t railingsType = RCT1_PATH_SUPPORT_TYPE_TRUSS; - if (_gameVersion == FILE_VERSION_RCT1_LL) + if (_gameVersion == RCT1Version::loopyLandscapes) { railingsType = src2->GetRCT1SupportType(); } @@ -1795,7 +1791,7 @@ namespace OpenRCT2::RCT1 dst2->setEntryIndex(entryIndex); dst2->setAge(src2->GetAge()); dst2->setSceneryQuadrant(src2->GetSceneryQuadrant()); - dst2->setPrimaryColour(GetColour(EnumValue(src2->GetPrimaryColour()))); + dst2->setPrimaryColour(getColour(EnumValue(src2->GetPrimaryColour()), _gameVersion)); if (src2->NeedsSupports()) dst2->setNeedsSupports(); @@ -1856,7 +1852,7 @@ namespace OpenRCT2::RCT1 if (type == -1) continue; - Drawing::Colour colourA = GetColour(EnumValue(src2->GetRCT1WallColour())); + Drawing::Colour colourA = getColour(EnumValue(src2->GetRCT1WallColour()), _gameVersion); Drawing::Colour colourB = Drawing::Colour::black; Drawing::Colour colourC = Drawing::Colour::black; ConvertWall(type, &colourA, &colourB); @@ -1907,8 +1903,8 @@ namespace OpenRCT2::RCT1 auto type = src2->GetEntryIndex(); dst2->setEntryIndex(_largeSceneryTypeToEntryMap[type]); dst2->setSequenceIndex(src2->GetSequenceIndex()); - dst2->setPrimaryColour(GetColour(EnumValue(src2->GetPrimaryColour()))); - dst2->setSecondaryColour(GetColour(EnumValue(src2->GetSecondaryColour()))); + dst2->setPrimaryColour(getColour(EnumValue(src2->GetPrimaryColour()), _gameVersion)); + dst2->setSecondaryColour(getColour(EnumValue(src2->GetSecondaryColour()), _gameVersion)); return 1; } @@ -2068,7 +2064,7 @@ namespace OpenRCT2::RCT1 { InsertResearchVehicle(researchItem, researched); } - else if (!rideTypeInResearch[researchItem.RelatedRide] && _gameVersion == FILE_VERSION_RCT1_LL) + else if (!rideTypeInResearch[researchItem.RelatedRide] && _gameVersion == RCT1Version::loopyLandscapes) { vehiclesWithMissingRideTypes.push_back(researchItem); } @@ -2307,9 +2303,9 @@ namespace OpenRCT2::RCT1 park.guestGenerationProbability = _s4.GuestGenerationProbability; // Staff colours - park.staffHandymanColour = GetColour(_s4.HandymanColour); - park.staffMechanicColour = GetColour(_s4.MechanicColour); - park.staffSecurityColour = GetColour(_s4.SecurityGuardColour); + park.staffHandymanColour = getColour(_s4.HandymanColour, _gameVersion); + park.staffMechanicColour = getColour(_s4.MechanicColour, _gameVersion); + park.staffSecurityColour = getColour(_s4.SecurityGuardColour, _gameVersion); // Flags park.flags.holder = _s4.parkFlags.without(ParkFlag::antiCheatDeprecated).holder; @@ -2324,7 +2320,7 @@ namespace OpenRCT2::RCT1 park.size = _s4.ParkSize; park.totalRideValueForMoney = _s4.TotalRideValueForMoney; park.samePriceThroughoutPark = 0; - if (_gameVersion == FILE_VERSION_RCT1_LL) + if (_gameVersion == RCT1Version::loopyLandscapes) { park.samePriceThroughoutPark = _s4.SamePriceThroughout; } @@ -2526,7 +2522,7 @@ namespace OpenRCT2::RCT1 dst->text = GetUserString(src->StringID); } - dst->colour = GetColour(src->Colour); + dst->colour = getColour(src->Colour, _gameVersion); dst->textColour = src->textColour; dst->position.x = src->x; dst->position.y = src->y; @@ -2620,7 +2616,7 @@ namespace OpenRCT2::RCT1 const ResearchItem* GetResearchList(size_t* count) { // Loopy Landscapes stores research items in a different place - if (_gameVersion == FILE_VERSION_RCT1_LL) + if (_gameVersion == RCT1Version::loopyLandscapes) { *count = std::size(_s4.ResearchItemsLL); return _s4.ResearchItemsLL; @@ -2870,7 +2866,7 @@ namespace OpenRCT2::RCT1 dst->peep[i] = spriteIndex; if (!spriteIndex.IsNull()) { - dst->peep_tshirt_colours[i] = GetColour(src->PeepTshirtColours[i]); + dst->peep_tshirt_colours[i] = getColour(src->PeepTshirtColours[i], _gameVersion); } } @@ -2932,18 +2928,19 @@ namespace OpenRCT2::RCT1 dst->timeToConsume = src->TimeToConsume; dst->vandalismSeen = src->VandalismSeen; - // Balloons were always blue in RCT1 without AA/LL, umbrellas always red - if (_gameVersion == FILE_VERSION_RCT1) + // Balloons were always blue in RCT1 without AA/LL, umbrellas always red. Hats were only introduced in AA. + if (_gameVersion == RCT1Version::baseGame) { dst->umbrellaColour = Drawing::Colour::brightRed; dst->balloonColour = Drawing::Colour::lightBlue; + dst->hatColour = Drawing::Colour::brightRed; } else { - dst->umbrellaColour = GetColour(src->UmbrellaColour); - dst->balloonColour = GetColour(src->BalloonColour); + dst->umbrellaColour = getColour(src->UmbrellaColour, _gameVersion); + dst->balloonColour = getColour(src->BalloonColour, _gameVersion); + dst->hatColour = getColour(src->HatColour, _gameVersion); } - dst->hatColour = GetColour(src->HatColour); dst->happiness = src->Happiness; dst->happinessTarget = src->HappinessTarget; @@ -2980,7 +2977,7 @@ namespace OpenRCT2::RCT1 RideUse::GetTypeHistory().Set(dst->id, RCT12GetRideTypesBeenOn(src)); dst->photo1RideRef = RCT12RideIdToOpenRCT2RideId(src->Photo1RideRef); - dst->peepFlags.holder = src->getPeepFlags(_gameVersion == FILE_VERSION_RCT1_LL); + dst->peepFlags.holder = src->getPeepFlags(_gameVersion == RCT1Version::loopyLandscapes); for (size_t i = 0; i < std::size(src->Thoughts); i++) { @@ -3002,7 +2999,7 @@ namespace OpenRCT2::RCT1 dst->guestNextInQueue = EntityId::FromUnderlying(src->NextInQueue); // Guests' favourite ride was only saved in LL. // Set it to N/A if the save comes from the original or AA. - if (_gameVersion == FILE_VERSION_RCT1_LL) + if (_gameVersion == RCT1Version::loopyLandscapes) { dst->favouriteRide = RCT12RideIdToOpenRCT2RideId(src->FavouriteRide); dst->favouriteRideRating = src->FavouriteRideRating; @@ -3013,7 +3010,7 @@ namespace OpenRCT2::RCT1 dst->favouriteRideRating = 0; } - dst->setItemFlags(src->GetItemFlags(_gameVersion == FILE_VERSION_RCT1)); + dst->setItemFlags(src->GetItemFlags(_gameVersion == RCT1Version::baseGame)); } template<> @@ -3080,8 +3077,8 @@ namespace OpenRCT2::RCT1 ImportEntityCommonProperties(dst, src); dst->frame = src->Frame; dst->timeToLive = src->TimeToLive; - dst->colour[0] = GetColour(src->Colour[0]); - dst->colour[1] = GetColour(src->Colour[1]); + dst->colour[0] = getColour(src->Colour[0], _gameVersion); + dst->colour[1] = getColour(src->Colour[1], _gameVersion); dst->crashedSpriteBase = src->CrashedEntityBase; dst->velocityX = src->VelocityX; dst->velocityY = src->VelocityY; @@ -3149,13 +3146,13 @@ namespace OpenRCT2::RCT1 dst->popped = src->Popped; dst->timeToMove = src->TimeToMove; // Balloons were always blue in RCT1 without AA/LL - if (_gameVersion == FILE_VERSION_RCT1) + if (_gameVersion == RCT1Version::baseGame) { dst->colour = Drawing::Colour::lightBlue; } else { - dst->colour = GetColour(src->Colour); + dst->colour = getColour(src->Colour, _gameVersion); } } diff --git a/src/openrct2/rct1/T4Importer.cpp b/src/openrct2/rct1/T4Importer.cpp index e5bc04fd42..860498d1c7 100644 --- a/src/openrct2/rct1/T4Importer.cpp +++ b/src/openrct2/rct1/T4Importer.cpp @@ -127,9 +127,9 @@ namespace OpenRCT2::RCT1 for (int32_t i = 0; i < Limits::kNumColourSchemes; i++) { - td->appearance.trackColours[i].main = GetColour(td4aa.TrackSpineColour[i]); - td->appearance.trackColours[i].additional = GetColour(td4aa.TrackRailColour[i]); - td->appearance.trackColours[i].supports = GetColour(td4aa.TrackSupportColour[i]); + td->appearance.trackColours[i].main = getColour(td4aa.TrackSpineColour[i], RCT1Version::loopyLandscapes); + td->appearance.trackColours[i].additional = getColour(td4aa.TrackRailColour[i], RCT1Version::loopyLandscapes); + td->appearance.trackColours[i].supports = getColour(td4aa.TrackSupportColour[i], RCT1Version::loopyLandscapes); } // The maze style is saved in the support colour, but taking it through the conversion function // will mess up style 3 (wooden fences). @@ -148,9 +148,9 @@ namespace OpenRCT2::RCT1 _stream.Read(&td4, sizeof(TD4)); for (size_t i = 0; i < std::size(td->appearance.trackColours); i++) { - td->appearance.trackColours[i].main = GetColour(td4.TrackSpineColourV0); - td->appearance.trackColours[i].additional = GetColour(td4.TrackRailColourV0); - td->appearance.trackColours[i].supports = GetColour(td4.TrackSupportColourV0); + td->appearance.trackColours[i].main = getColour(td4.TrackSpineColourV0, RCT1Version::baseGame); + td->appearance.trackColours[i].additional = getColour(td4.TrackRailColourV0, RCT1Version::baseGame); + td->appearance.trackColours[i].supports = getColour(td4.TrackSupportColourV0, RCT1Version::baseGame); // Mazes were only hedges if (td4.Type == RideType::hedgeMaze) @@ -191,6 +191,7 @@ namespace OpenRCT2::RCT1 td->trackAndVehicle.vehicleObject = ObjectEntryDescriptor(vehicleObject); td->appearance.vehicleColourSettings = static_cast(td4Base.VersionAndColourScheme & 0x3); + auto gameVersion = (td->version == TD46Version::td4) ? RCT1Version::baseGame : RCT1Version::loopyLandscapes; // Vehicle colours for (int32_t i = 0; i < Limits::kMaxTrainsPerRide; i++) { @@ -199,11 +200,11 @@ namespace OpenRCT2::RCT1 td4Base.VehicleType); if (colourSchemeCopyDescriptor.colour1 == kCopyColour1) { - td->appearance.vehicleColours[i].Body = GetColour(td4Base.VehicleColours[i].BodyColour); + td->appearance.vehicleColours[i].Body = getColour(td4Base.VehicleColours[i].BodyColour, gameVersion); } else if (colourSchemeCopyDescriptor.colour1 == kCopyColour2) { - td->appearance.vehicleColours[i].Body = GetColour(td4Base.VehicleColours[i].TrimColour); + td->appearance.vehicleColours[i].Body = getColour(td4Base.VehicleColours[i].TrimColour, gameVersion); } else { @@ -212,11 +213,11 @@ namespace OpenRCT2::RCT1 if (colourSchemeCopyDescriptor.colour2 == kCopyColour1) { - td->appearance.vehicleColours[i].Trim = GetColour(td4Base.VehicleColours[i].BodyColour); + td->appearance.vehicleColours[i].Trim = getColour(td4Base.VehicleColours[i].BodyColour, gameVersion); } else if (colourSchemeCopyDescriptor.colour2 == kCopyColour2) { - td->appearance.vehicleColours[i].Trim = GetColour(td4Base.VehicleColours[i].TrimColour); + td->appearance.vehicleColours[i].Trim = getColour(td4Base.VehicleColours[i].TrimColour, gameVersion); } else { @@ -225,11 +226,11 @@ namespace OpenRCT2::RCT1 if (colourSchemeCopyDescriptor.colour3 == kCopyColour1) { - td->appearance.vehicleColours[i].Tertiary = GetColour(td4Base.VehicleColours[i].BodyColour); + td->appearance.vehicleColours[i].Tertiary = getColour(td4Base.VehicleColours[i].BodyColour, gameVersion); } else if (colourSchemeCopyDescriptor.colour3 == kCopyColour2) { - td->appearance.vehicleColours[i].Tertiary = GetColour(td4Base.VehicleColours[i].TrimColour); + td->appearance.vehicleColours[i].Tertiary = getColour(td4Base.VehicleColours[i].TrimColour, gameVersion); } else { diff --git a/src/openrct2/rct1/Tables.cpp b/src/openrct2/rct1/Tables.cpp index c22e8f8251..1bb24faedb 100644 --- a/src/openrct2/rct1/Tables.cpp +++ b/src/openrct2/rct1/Tables.cpp @@ -14,14 +14,32 @@ #include "../ride/Ride.h" #include "../ride/RideData.h" #include "RCT1.h" +#include "RCT1File.h" #include // clang-format off namespace OpenRCT2::RCT1 { - Drawing::Colour GetColour(uint8_t colour) + Drawing::Colour getColour(uint8_t colour, RCT1Version version) { + if (version == RCT1Version::baseGame) + { + switch (colour) + { + case 5: + return Drawing::Colour::deepBlue; + case 8: + return Drawing::Colour::emerald; + case 15: + return Drawing::Colour::gold; + case 17: + return Drawing::Colour::amber; + case 23: + return Drawing::Colour::ruby; + } + } + static constexpr Drawing::Colour map[] = { Drawing::Colour::black, diff --git a/src/openrct2/rct1/Tables.h b/src/openrct2/rct1/Tables.h index a1fc1e8e1b..7cd9d2cea5 100644 --- a/src/openrct2/rct1/Tables.h +++ b/src/openrct2/rct1/Tables.h @@ -11,6 +11,7 @@ #include "../drawing/Colour.h" #include "../rct12/RCT12.h" +#include "RCT1File.h" #include @@ -31,7 +32,7 @@ namespace OpenRCT2::RCT1 enum class RideType : uint8_t; enum class VehicleType : uint8_t; - Drawing::Colour GetColour(uint8_t colour); + Drawing::Colour getColour(uint8_t colour, RCT1Version version); RCT12PeepAnimationGroup GetPeepAnimationGroup(PeepAnimationGroup rct1AnimationGroup); uint8_t GetRideType(RideType rideType, VehicleType vehicleType); diff --git a/src/openrct2/sawyer_coding/SawyerCoding.cpp b/src/openrct2/sawyer_coding/SawyerCoding.cpp index 234f68db07..dcfea1ab22 100644 --- a/src/openrct2/sawyer_coding/SawyerCoding.cpp +++ b/src/openrct2/sawyer_coding/SawyerCoding.cpp @@ -381,42 +381,4 @@ namespace OpenRCT2::SawyerCoding } #pragma endregion - - int32_t DetectFileType(const uint8_t* src, size_t length) - { - if (length < 4) - { - throw std::length_error("Stream is (nearly) empty!"); - } - - // Currently can't detect TD4, as the checksum is the same as SC4 (need alternative method) - - uint32_t checksum = *(reinterpret_cast(&src[length - 4])); - uint32_t actualChecksum = 0; - for (size_t i = 0; i < length - 4; i++) - { - actualChecksum = (actualChecksum & 0xFFFFFF00) | (((actualChecksum & 0xFF) + static_cast(src[i])) & 0xFF); - actualChecksum = Numerics::rol32(actualChecksum, 3); - } - - return DetectRCT1Version(checksum - actualChecksum); - } - - int32_t DetectRCT1Version(int32_t gameVersion) - { - int32_t fileType = (gameVersion) > 0 ? FILE_TYPE_SV4 : FILE_TYPE_SC4; - gameVersion = abs(gameVersion); - - if (gameVersion >= 108000 && gameVersion < 110000) - return (FILE_VERSION_RCT1 | fileType); - if (gameVersion >= 110000 && gameVersion < 120000) - return (FILE_VERSION_RCT1_AA | fileType); - if (gameVersion >= 120000 && gameVersion < 130000) - return (FILE_VERSION_RCT1_LL | fileType); - // RCTOA Acres sets this, and possibly some other user-created scenarios as well - if (gameVersion == 0) - return (FILE_VERSION_RCT1_LL | fileType); - - return -1; - } } // namespace OpenRCT2::SawyerCoding diff --git a/src/openrct2/sawyer_coding/SawyerCoding.h b/src/openrct2/sawyer_coding/SawyerCoding.h index 71794b3020..3629212bd7 100644 --- a/src/openrct2/sawyer_coding/SawyerCoding.h +++ b/src/openrct2/sawyer_coding/SawyerCoding.h @@ -16,20 +16,6 @@ namespace OpenRCT2::SawyerCoding { - // TODO: make enum class in SawyerCoding namespace - enum - { - FILE_VERSION_MASK = (3 << 0), - FILE_VERSION_RCT1 = (0 << 0), - FILE_VERSION_RCT1_AA = (1 << 0), - FILE_VERSION_RCT1_LL = (2 << 0), - - FILE_TYPE_MASK = (3 << 2), - FILE_TYPE_TD4 = (0 << 2), - FILE_TYPE_SV4 = (1 << 2), - FILE_TYPE_SC4 = (2 << 2) - }; - uint32_t CalculateChecksum(const uint8_t* buffer, size_t length); size_t WriteChunkBuffer(uint8_t* dst_file, const uint8_t* src_buffer, ChunkHeader chunkHeader); size_t DecodeSV4(const uint8_t* src, uint8_t* dst, size_t length, size_t bufferLength); @@ -41,7 +27,4 @@ namespace OpenRCT2::SawyerCoding size_t EncodeChunkRLE(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length); size_t EncodeChunkRepeat(const uint8_t* src_buffer, uint8_t* dst_buffer, size_t length); void EncodeChunkRotate(uint8_t* buffer, size_t length); - - int32_t DetectFileType(const uint8_t* src, size_t length); - int32_t DetectRCT1Version(int32_t gameVersion); } // namespace OpenRCT2::SawyerCoding diff --git a/src/openrct2/scripting/bindings/ride/ScRide.hpp b/src/openrct2/scripting/bindings/ride/ScRide.hpp index 88cd167822..276487155c 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.hpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.hpp @@ -29,11 +29,10 @@ namespace OpenRCT2::Scripting inline VehicleColour JSToVehicleColours(JSContext* ctx, JSValue val) { VehicleColour result{}; - result.Body = static_cast(AsOrDefault(ctx, val, "body", 0)); - result.Trim = static_cast(AsOrDefault(ctx, val, "trim", 0)); - result.Tertiary = static_cast(AsOrDefault(ctx, val, "ternary", 0)); - result.Tertiary = static_cast( - AsOrDefault(ctx, val, "tertiary", static_cast(result.Tertiary))); + result.Body = Drawing::clampColour(AsOrDefault(ctx, val, "body", 0)); + result.Trim = Drawing::clampColour(AsOrDefault(ctx, val, "trim", 0)); + result.Tertiary = Drawing::clampColour(AsOrDefault(ctx, val, "ternary", 0)); + result.Tertiary = Drawing::clampColour(AsOrDefault(ctx, val, "tertiary", static_cast(result.Tertiary))); return result; } @@ -49,9 +48,9 @@ namespace OpenRCT2::Scripting inline TrackColour JSToTrackColour(JSContext* ctx, JSValue val) { TrackColour result{}; - result.main = static_cast(AsOrDefault(ctx, val, "main", 0)); - result.additional = static_cast(AsOrDefault(ctx, val, "additional", 0)); - result.supports = static_cast(AsOrDefault(ctx, val, "supports", 0)); + result.main = Drawing::clampColour(AsOrDefault(ctx, val, "main", 0)); + result.additional = Drawing::clampColour(AsOrDefault(ctx, val, "additional", 0)); + result.supports = Drawing::clampColour(AsOrDefault(ctx, val, "supports", 0)); return result; } diff --git a/src/openrct2/world/tile_element/SmallSceneryElement.cpp b/src/openrct2/world/tile_element/SmallSceneryElement.cpp index c7eab46a20..1a6e924ce1 100644 --- a/src/openrct2/world/tile_element/SmallSceneryElement.cpp +++ b/src/openrct2/world/tile_element/SmallSceneryElement.cpp @@ -87,21 +87,27 @@ namespace OpenRCT2 return colour[2]; } - void SmallSceneryElement::setPrimaryColour(Drawing::Colour newColour) + void SmallSceneryElement::setPrimaryColour(Drawing::Colour newColour, bool fromImport) { - assert(Drawing::colourIsValid(newColour)); + if (!fromImport) + newColour = Drawing::clampColour(newColour); + colour[0] = newColour; } - void SmallSceneryElement::setSecondaryColour(Drawing::Colour newColour) + void SmallSceneryElement::setSecondaryColour(Drawing::Colour newColour, bool fromImport) { - assert(Drawing::colourIsValid(newColour)); + if (!fromImport) + newColour = Drawing::clampColour(newColour); + colour[1] = newColour; } - void SmallSceneryElement::setTertiaryColour(Drawing::Colour newColour) + void SmallSceneryElement::setTertiaryColour(Drawing::Colour newColour, bool fromImport) { - assert(Drawing::colourIsValid(newColour)); + if (!fromImport) + newColour = Drawing::clampColour(newColour); + colour[2] = newColour; } diff --git a/src/openrct2/world/tile_element/SmallSceneryElement.h b/src/openrct2/world/tile_element/SmallSceneryElement.h index 0c85be6ea8..fe4de559c9 100644 --- a/src/openrct2/world/tile_element/SmallSceneryElement.h +++ b/src/openrct2/world/tile_element/SmallSceneryElement.h @@ -50,11 +50,11 @@ namespace OpenRCT2 uint8_t getSceneryQuadrant() const; void setSceneryQuadrant(uint8_t newQuadrant); Drawing::Colour getPrimaryColour() const; - void setPrimaryColour(Drawing::Colour colour); + void setPrimaryColour(Drawing::Colour colour, bool fromImport = false); Drawing::Colour getSecondaryColour() const; - void setSecondaryColour(Drawing::Colour colour); + void setSecondaryColour(Drawing::Colour colour, bool fromImport = false); Drawing::Colour getTertiaryColour() const; - void setTertiaryColour(Drawing::Colour colour); + void setTertiaryColour(Drawing::Colour colour, bool fromImport = false); bool needsSupports() const; void setNeedsSupports(); void updateAge(const CoordsXY& sceneryPos);