From 335c1daed4fa3e0671a6830fb192f71599f2908f Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 16 Dec 2018 23:24:04 +0000 Subject: [PATCH] Add more read code --- src/openrct2/ParkFile.cpp | 84 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/src/openrct2/ParkFile.cpp b/src/openrct2/ParkFile.cpp index 495c7e04ac..b9970819a5 100644 --- a/src/openrct2/ParkFile.cpp +++ b/src/openrct2/ParkFile.cpp @@ -391,6 +391,7 @@ namespace OpenRCT2 WriteValue(gStaffMechanicColour); WriteValue(gStaffSecurityColour); + // TODO use a uint64 or a list of active items WriteValue(gSamePriceThroughoutParkA); WriteValue(gSamePriceThroughoutParkB); @@ -540,8 +541,6 @@ namespace OpenRCT2 entry.flags = type & 0x7FFF; strncpy(entry.name, id.c_str(), 8); RequiredObjects.push_back(entry); - - ReadNextArrayElement(); } } } @@ -554,6 +553,7 @@ namespace OpenRCT2 ReadParkChunk(); ReadClimateChunk(); ReadResearchChunk(); + ReadNotifications(); ReadInterfaceChunk(); // Initial cash will eventually be removed @@ -691,7 +691,6 @@ namespace OpenRCT2 gPeepSpawns[i].y = ReadValue(); gPeepSpawns[i].z = ReadValue(); gPeepSpawns[i].direction = ReadValue(); - ReadNextArrayElement(); } gLandPrice = ReadValue(); @@ -735,10 +734,89 @@ namespace OpenRCT2 void ReadParkChunk() { + if (SeekChunk(ParkFileChunkType::PARK)) + { + gParkNameArgs = ReadValue(); + gCash = ReadValue(); + gBankLoan = ReadValue(); + gMaxBankLoan = ReadValue(); + gBankLoanInterestRate = ReadValue(); + gParkFlags = ReadValue(); + gParkEntranceFee = ReadValue(); + gStaffHandymanColour = ReadValue(); + gStaffMechanicColour = ReadValue(); + gStaffSecurityColour = ReadValue(); + + gSamePriceThroughoutParkA = ReadValue(); + gSamePriceThroughoutParkB = ReadValue(); + + // Marketing + auto numItems = ReadArray(); + for (size_t i = 0; i < numItems; i++) + { + gMarketingCampaignDaysLeft[i] = ReadValue(); + gMarketingCampaignRideIndex[i] = ReadValue(); + } + + // Awards + numItems = ReadArray(); + for (size_t i = 0; i < numItems; i++) + { + Award award; + award.Time = ReadValue(); + award.Type = ReadValue(); + } + + numItems = ReadArray(); + for (size_t i = 0; i < numItems; i++) + { + gPeepWarningThrottle[i] = ReadValue(); + } + + gParkRatingCasualtyPenalty = ReadValue(); + gCurrentExpenditure = ReadValue(); + gCurrentProfit = ReadValue(); + gTotalAdmissions = ReadValue(); + gTotalIncomeFromAdmissions = ReadValue(); + } + else + { + throw std::runtime_error("No park chunk found."); + } } void ReadResearchChunk() { + if (SeekChunk(ParkFileChunkType::RESEARCH)) + { + // Research status + gResearchFundingLevel = ReadValue(); + gResearchPriorities = ReadValue(); + gResearchProgressStage = ReadValue(); + gResearchProgress = ReadValue(); + gResearchExpectedMonth = ReadValue(); + gResearchExpectedDay = ReadValue(); + gResearchLastItem = ReadValue(); + gResearchNextItem = ReadValue(); + + // auto numItems = ReadArray(); + } + } + + void ReadNotifications() + { + if (SeekChunk(ParkFileChunkType::NOTIFICATIONS)) + { + NewsItem notification; + notification.Type = ReadValue(); + notification.Flags = ReadValue(); + notification.Assoc = ReadValue(); + notification.Ticks = ReadValue(); + notification.MonthYear = ReadValue(); + notification.Day = ReadValue(); + auto text = ReadString(); + String::Set(notification.Text, sizeof(notification.Text), text.c_str()); + } } void ReadTilesChunk()