diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index f4da301a48..bf9f70fc80 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -642,7 +642,7 @@ namespace OpenRCT2 gLastAutoSaveUpdate = AUTOSAVE_PAUSE; bool sendMap = false; - if (info.Type == FILE_TYPE::SAVED_GAME) + if (info.Type == FILE_TYPE::PARK || info.Type == FILE_TYPE::SAVED_GAME) { if (network_get_mode() == NETWORK_MODE_CLIENT) { diff --git a/src/openrct2/ParkFile.cpp b/src/openrct2/ParkFile.cpp index 688528ec86..67659f6699 100644 --- a/src/openrct2/ParkFile.cpp +++ b/src/openrct2/ParkFile.cpp @@ -8,6 +8,7 @@ #include "interface/Viewport.h" #include "interface/Window.h" #include "localisation/Date.h" +#include "localisation/Localisation.h" #include "object/Object.h" #include "object/ObjectManager.h" #include "object/ObjectRepository.h" @@ -122,6 +123,7 @@ namespace OpenRCT2 WriteAuthoringChunk(); WriteObjectsChunk(); + WriteScenarioChunk(); WriteGeneralChunk(); WriteInterfaceChunk(); WriteTilesChunk(); @@ -220,6 +222,15 @@ namespace OpenRCT2 _buffer.write(&nullt, sizeof(nullt)); } + void WriteStringTable(const std::string_view& lcode, const std::string_view& value) + { + BeginArray(); + WriteString(lcode); + WriteString(value); + NextArrayElement(); + EndArray(); + } + void WriteAuthoringChunk() { BeginChunk(ParkFileChunkType::AUTHORING); @@ -258,6 +269,39 @@ namespace OpenRCT2 EndChunk(); } + void WriteScenarioChunk() + { + BeginChunk(ParkFileChunkType::SCENARIO); + WriteValue(gS6Info.category); + WriteStringTable("en-GB", gScenarioName); + char parkName[128]; + format_string(parkName, sizeof(parkName), gParkName, &gParkNameArgs); + WriteStringTable("en-GB", parkName); + WriteStringTable("en-GB", gScenarioDetails); + + WriteValue(gScenarioObjectiveType); + WriteValue(gScenarioObjectiveYear); // year + WriteValue(gScenarioObjectiveNumGuests); // guests + WriteValue(600); // rating + WriteValue(gScenarioObjectiveCurrency); // excitement + WriteValue(gScenarioObjectiveNumGuests); // length + WriteValue(gScenarioObjectiveCurrency); // park value + WriteValue(gScenarioObjectiveCurrency); // ride profit + WriteValue(gScenarioObjectiveCurrency); // shop profit + + WriteValue(gScenarioCompletedCompanyValue); + if (gScenarioCompletedCompanyValue == MONEY32_UNDEFINED || + gScenarioCompletedCompanyValue == (money32)0x80000001) + { + WriteString(""); + } + else + { + WriteString(gScenarioCompletedBy); + } + EndChunk(); + } + void WriteGeneralChunk() { BeginChunk(ParkFileChunkType::GENERAL); @@ -367,6 +411,7 @@ namespace OpenRCT2 void Import() { ReadTilesChunk(); + ReadScenarioChunk(); ReadGeneralChunk(); ReadInterfaceChunk(); } @@ -431,6 +476,54 @@ namespace OpenRCT2 return buffer; } + std::string ReadStringTable() + { + std::string result; + auto len = ReadArray(); + for (size_t i = 0; i < len; i++) + { + auto lcode = ReadString(); + auto value = ReadString(); + if (i == 0) + { + result = value; + } + } + return result; + } + + void ReadScenarioChunk() + { + if (SeekChunk(ParkFileChunkType::SCENARIO)) + { + ReadValue(); + + String::Set(gScenarioName, sizeof(gScenarioName), ReadStringTable().c_str()); + String::Set(gS6Info.name, sizeof(gS6Info.name), gScenarioName); + ReadStringTable(); // park name + String::Set(gScenarioDetails, sizeof(gScenarioDetails), ReadStringTable().c_str()); + String::Set(gS6Info.details, sizeof(gS6Info.details), gScenarioName); + + gScenarioObjectiveType = ReadValue(); + gScenarioObjectiveYear = ReadValue(); // year + gScenarioObjectiveNumGuests = ReadValue(); // guests + ReadValue(); // rating + ReadValue(); // excitement + ReadValue(); // length + gScenarioObjectiveCurrency = ReadValue(); // park value + ReadValue(); // ride profit + ReadValue(); // shop profit + + gScenarioCompletedCompanyValue = ReadValue(); + String::Set(gScenarioCompletedBy, sizeof(gScenarioCompletedBy), ReadString().c_str()); + EndChunk(); + } + else + { + throw std::runtime_error("No scenario chunk found."); + } + } + void ReadGeneralChunk() { if (SeekChunk(ParkFileChunkType::GENERAL))