2017-04-24 22:38:16 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
2016-05-07 14:58:36 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
|
|
|
*****************************************************************************/
|
|
|
|
#pragma endregion
|
|
|
|
|
2017-01-31 19:37:55 +01:00
|
|
|
#include "../core/Console.hpp"
|
2016-05-07 14:58:36 +02:00
|
|
|
#include "../core/Exception.hpp"
|
2017-01-31 00:56:10 +01:00
|
|
|
#include "../core/FileStream.hpp"
|
2016-05-07 14:58:36 +02:00
|
|
|
#include "../core/IStream.hpp"
|
2017-01-31 00:56:10 +01:00
|
|
|
#include "../core/Path.hpp"
|
|
|
|
#include "../core/String.hpp"
|
2017-01-14 19:47:18 +01:00
|
|
|
#include "../management/award.h"
|
2016-06-03 23:03:22 +02:00
|
|
|
#include "../network/network.h"
|
2017-06-22 19:57:25 +02:00
|
|
|
#include "../object/ObjectManager.h"
|
2017-02-04 01:34:14 +01:00
|
|
|
#include "../object/ObjectRepository.h"
|
2017-06-06 15:34:30 +02:00
|
|
|
#include "../object/ObjectManager.h"
|
2017-01-31 00:56:10 +01:00
|
|
|
#include "../ParkImporter.h"
|
2017-02-05 03:33:15 +01:00
|
|
|
#include "../rct12/SawyerChunkReader.h"
|
2017-04-24 22:38:16 +02:00
|
|
|
#include "../rct12/SawyerEncoding.h"
|
2016-05-07 14:58:36 +02:00
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2017-02-18 16:45:10 +01:00
|
|
|
#include "../config/Config.h"
|
2016-05-07 18:37:50 +02:00
|
|
|
#include "../game.h"
|
2016-05-09 00:16:25 +02:00
|
|
|
#include "../interface/viewport.h"
|
2016-05-07 17:20:10 +02:00
|
|
|
#include "../localisation/date.h"
|
|
|
|
#include "../localisation/localisation.h"
|
|
|
|
#include "../management/finance.h"
|
|
|
|
#include "../management/marketing.h"
|
|
|
|
#include "../management/news_item.h"
|
|
|
|
#include "../management/research.h"
|
2016-12-11 01:12:29 +01:00
|
|
|
#include "../OpenRCT2.h"
|
2016-05-07 17:20:10 +02:00
|
|
|
#include "../peep/staff.h"
|
2016-11-30 12:07:10 +01:00
|
|
|
#include "../rct2.h"
|
2016-05-07 17:20:10 +02:00
|
|
|
#include "../ride/ride.h"
|
|
|
|
#include "../ride/ride_ratings.h"
|
2016-12-14 13:13:52 +01:00
|
|
|
#include "../scenario/scenario.h"
|
2016-05-07 14:58:36 +02:00
|
|
|
#include "../util/sawyercoding.h"
|
2017-03-11 12:24:18 +01:00
|
|
|
#include "../world/Climate.h"
|
2017-02-25 14:51:30 +01:00
|
|
|
#include "../world/entrance.h"
|
2016-05-07 17:20:10 +02:00
|
|
|
#include "../world/map_animation.h"
|
|
|
|
#include "../world/park.h"
|
2016-05-07 14:58:36 +02:00
|
|
|
}
|
|
|
|
|
2016-05-07 23:47:29 +02:00
|
|
|
class ObjectLoadException : public Exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ObjectLoadException() : Exception("Unable to load objects.") { }
|
2016-11-30 23:32:47 +01:00
|
|
|
explicit ObjectLoadException(const char * message) : Exception(message) { }
|
2016-05-07 23:47:29 +02:00
|
|
|
};
|
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
/**
|
|
|
|
* Class to import RollerCoaster Tycoon 2 scenarios (*.SC6) and saved games (*.SV6).
|
|
|
|
*/
|
|
|
|
class S6Importer final : public IParkImporter
|
2016-05-07 14:58:36 +02:00
|
|
|
{
|
2017-01-31 00:56:10 +01:00
|
|
|
private:
|
2017-06-22 19:57:25 +02:00
|
|
|
IObjectRepository * const _objectRepository;
|
|
|
|
IObjectManager * const _objectManager;
|
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
const utf8 * _s6Path = nullptr;
|
2017-01-31 21:27:53 +01:00
|
|
|
rct_s6_data _s6;
|
2017-01-31 00:56:10 +01:00
|
|
|
uint8 _gameVersion = 0;
|
2016-05-07 14:58:36 +02:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
public:
|
2017-06-22 19:57:25 +02:00
|
|
|
S6Importer(IObjectRepository * objectRepository, IObjectManager * objectManager)
|
|
|
|
: _objectRepository(objectRepository),
|
|
|
|
_objectManager(objectManager)
|
2017-01-31 21:27:53 +01:00
|
|
|
{
|
|
|
|
Memory::Set(&_s6, 0, sizeof(_s6));
|
|
|
|
}
|
|
|
|
|
2017-07-01 02:26:23 +02:00
|
|
|
ParkLoadResult Load(const utf8 * path) override
|
2016-05-08 02:22:32 +02:00
|
|
|
{
|
2017-01-31 00:56:10 +01:00
|
|
|
const utf8 * extension = Path::GetExtension(path);
|
|
|
|
if (String::Equals(extension, ".sc6", true))
|
|
|
|
{
|
2017-06-06 15:34:30 +02:00
|
|
|
return LoadScenario(path);
|
2017-01-31 00:56:10 +01:00
|
|
|
}
|
|
|
|
else if (String::Equals(extension, ".sv6", true))
|
|
|
|
{
|
2017-06-06 15:34:30 +02:00
|
|
|
return LoadSavedGame(path);
|
2017-01-31 00:56:10 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw Exception("Invalid RCT2 park extension.");
|
|
|
|
}
|
2016-05-07 14:58:36 +02:00
|
|
|
}
|
|
|
|
|
2017-07-01 02:26:23 +02:00
|
|
|
ParkLoadResult LoadSavedGame(const utf8 * path, bool skipObjectCheck = false) override
|
2016-05-07 23:47:29 +02:00
|
|
|
{
|
2017-01-31 00:56:10 +01:00
|
|
|
auto fs = FileStream(path, FILE_MODE_OPEN);
|
2017-07-01 02:26:23 +02:00
|
|
|
auto result = LoadFromStream(&fs, false, skipObjectCheck);
|
2017-01-31 00:56:10 +01:00
|
|
|
_s6Path = path;
|
2017-06-06 15:34:30 +02:00
|
|
|
return result;
|
2016-05-07 23:47:29 +02:00
|
|
|
}
|
|
|
|
|
2017-07-01 02:26:23 +02:00
|
|
|
ParkLoadResult LoadScenario(const utf8 * path, bool skipObjectCheck = false) override
|
2016-05-08 02:22:32 +02:00
|
|
|
{
|
2017-01-31 00:56:10 +01:00
|
|
|
auto fs = FileStream(path, FILE_MODE_OPEN);
|
2017-07-01 02:26:23 +02:00
|
|
|
auto result = LoadFromStream(&fs, true, skipObjectCheck);
|
2017-01-31 00:56:10 +01:00
|
|
|
_s6Path = path;
|
2017-06-06 15:34:30 +02:00
|
|
|
return result;
|
2016-05-07 14:58:36 +02:00
|
|
|
}
|
|
|
|
|
2017-07-01 02:26:23 +02:00
|
|
|
ParkLoadResult LoadFromStream(IStream * stream, bool isScenario, bool skipObjectCheck = false) override
|
2016-05-07 23:47:29 +02:00
|
|
|
{
|
2017-02-04 12:05:25 +01:00
|
|
|
if (isScenario && !gConfigGeneral.allow_loading_with_incorrect_checksum && !SawyerEncoding::ValidateChecksum(stream))
|
2017-01-31 21:19:26 +01:00
|
|
|
{
|
|
|
|
throw IOException("Invalid checksum.");
|
|
|
|
}
|
|
|
|
|
2017-02-05 03:33:15 +01:00
|
|
|
auto chunkReader = SawyerChunkReader(stream);
|
|
|
|
chunkReader.ReadChunk(&_s6.header, sizeof(_s6.header));
|
2016-05-07 23:47:29 +02:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
log_verbose("saved game classic_flag = 0x%02x\n", _s6.header.classic_flag);
|
|
|
|
if (isScenario)
|
|
|
|
{
|
|
|
|
if (_s6.header.type != S6_TYPE_SCENARIO)
|
|
|
|
{
|
|
|
|
throw Exception("Park is not a scenario.");
|
|
|
|
}
|
2017-02-05 03:33:15 +01:00
|
|
|
chunkReader.ReadChunk(&_s6.info, sizeof(_s6.info));
|
2017-01-31 00:56:10 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (_s6.header.type != S6_TYPE_SAVEDGAME)
|
|
|
|
{
|
|
|
|
throw Exception("Park is not a saved game.");
|
|
|
|
}
|
|
|
|
}
|
2016-05-07 14:58:36 +02:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
// Read packed objects
|
|
|
|
// TODO try to contain this more and not store objects until later
|
|
|
|
for (uint16 i = 0; i < _s6.header.num_packed_objects; i++)
|
|
|
|
{
|
2017-06-22 19:57:25 +02:00
|
|
|
_objectRepository->ExportPackedObject(stream);
|
2017-01-31 00:56:10 +01:00
|
|
|
}
|
2016-05-07 14:58:36 +02:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
if (isScenario)
|
|
|
|
{
|
2017-02-05 03:33:15 +01:00
|
|
|
chunkReader.ReadChunk(&_s6.objects, sizeof(_s6.objects));
|
|
|
|
chunkReader.ReadChunk(&_s6.elapsed_months, 16);
|
|
|
|
chunkReader.ReadChunk(&_s6.map_elements, sizeof(_s6.map_elements));
|
|
|
|
chunkReader.ReadChunk(&_s6.next_free_map_element_pointer_index, 2560076);
|
|
|
|
chunkReader.ReadChunk(&_s6.guests_in_park, 4);
|
|
|
|
chunkReader.ReadChunk(&_s6.last_guests_in_park, 8);
|
|
|
|
chunkReader.ReadChunk(&_s6.park_rating, 2);
|
|
|
|
chunkReader.ReadChunk(&_s6.active_research_types, 1082);
|
|
|
|
chunkReader.ReadChunk(&_s6.current_expenditure, 16);
|
|
|
|
chunkReader.ReadChunk(&_s6.park_value, 4);
|
|
|
|
chunkReader.ReadChunk(&_s6.completed_company_value, 483816);
|
2017-01-31 00:56:10 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-05 03:33:15 +01:00
|
|
|
chunkReader.ReadChunk(&_s6.objects, sizeof(_s6.objects));
|
|
|
|
chunkReader.ReadChunk(&_s6.elapsed_months, 16);
|
|
|
|
chunkReader.ReadChunk(&_s6.map_elements, sizeof(_s6.map_elements));
|
|
|
|
chunkReader.ReadChunk(&_s6.next_free_map_element_pointer_index, 3048816);
|
2017-01-31 00:56:10 +01:00
|
|
|
}
|
2017-06-06 15:34:30 +02:00
|
|
|
|
2017-07-01 02:26:23 +02:00
|
|
|
auto missingObjects = _objectManager->GetInvalidObjects(_s6.objects);
|
|
|
|
if (missingObjects.size() > 0)
|
2017-06-06 15:34:30 +02:00
|
|
|
{
|
2017-07-01 02:26:23 +02:00
|
|
|
return ParkLoadResult::CreateMissingObjects(missingObjects);
|
2017-06-06 15:34:30 +02:00
|
|
|
}
|
2017-07-01 02:26:23 +02:00
|
|
|
return ParkLoadResult::CreateOK();
|
2016-05-07 14:58:36 +02:00
|
|
|
}
|
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
bool GetDetails(scenario_index_entry * dst) override
|
2016-05-07 23:47:29 +02:00
|
|
|
{
|
2017-01-31 00:56:10 +01:00
|
|
|
Memory::Set(dst, 0, sizeof(scenario_index_entry));
|
|
|
|
return false;
|
2016-05-07 23:47:29 +02:00
|
|
|
}
|
2016-05-07 14:58:36 +02:00
|
|
|
|
2017-01-31 21:27:53 +01:00
|
|
|
void Import() override
|
2016-07-03 22:05:18 +02:00
|
|
|
{
|
2017-01-31 00:56:10 +01:00
|
|
|
Initialise();
|
2016-05-07 14:58:36 +02:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
// _s6.header
|
|
|
|
gS6Info = _s6.info;
|
2016-05-07 14:58:36 +02:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
gDateMonthsElapsed = _s6.elapsed_months;
|
2017-04-24 22:38:16 +02:00
|
|
|
gDateMonthTicks = _s6.current_day;
|
|
|
|
gScenarioTicks = _s6.scenario_ticks;
|
|
|
|
gScenarioSrand0 = _s6.scenario_srand_0;
|
|
|
|
gScenarioSrand1 = _s6.scenario_srand_1;
|
2017-01-23 14:00:46 +01:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
memcpy(gMapElements, _s6.map_elements, sizeof(_s6.map_elements));
|
2016-05-07 18:37:50 +02:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
gNextFreeMapElementPointerIndex = _s6.next_free_map_element_pointer_index;
|
|
|
|
for (sint32 i = 0; i < MAX_SPRITES; i++)
|
|
|
|
{
|
|
|
|
memcpy(get_sprite(i), &_s6.sprites[i], sizeof(rct_sprite));
|
|
|
|
}
|
2016-05-07 14:58:36 +02:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
for (sint32 i = 0; i < NUM_SPRITE_LISTS; i++)
|
|
|
|
{
|
2017-04-24 22:38:16 +02:00
|
|
|
gSpriteListHead[i] = _s6.sprite_lists_head[i];
|
2017-01-31 00:56:10 +01:00
|
|
|
gSpriteListCount[i] = _s6.sprite_lists_count[i];
|
|
|
|
}
|
|
|
|
gParkName = _s6.park_name;
|
|
|
|
// pad_013573D6
|
2017-04-24 22:38:16 +02:00
|
|
|
gParkNameArgs = _s6.park_name_args;
|
|
|
|
gInitialCash = _s6.initial_cash;
|
|
|
|
gBankLoan = _s6.current_loan;
|
|
|
|
gParkFlags = _s6.park_flags;
|
2017-01-31 00:56:10 +01:00
|
|
|
gParkEntranceFee = _s6.park_entrance_fee;
|
|
|
|
// rct1_park_entrance_x
|
|
|
|
// rct1_park_entrance_y
|
|
|
|
// pad_013573EE
|
|
|
|
// rct1_park_entrance_z
|
|
|
|
memcpy(gPeepSpawns, _s6.peep_spawns, sizeof(_s6.peep_spawns));
|
2017-04-24 22:38:16 +02:00
|
|
|
gGuestChangeModifier = _s6.guest_count_change_modifier;
|
2017-01-31 00:56:10 +01:00
|
|
|
gResearchFundingLevel = _s6.current_research_level;
|
|
|
|
// pad_01357400
|
|
|
|
memcpy(gResearchedRideTypes, _s6.researched_ride_types, sizeof(_s6.researched_ride_types));
|
|
|
|
memcpy(gResearchedRideEntries, _s6.researched_ride_entries, sizeof(_s6.researched_ride_entries));
|
2017-05-16 19:11:51 +02:00
|
|
|
// _s6.researched_track_types_a
|
|
|
|
// _s6.researched_track_types_b
|
2017-01-31 00:56:10 +01:00
|
|
|
|
2017-04-24 22:38:16 +02:00
|
|
|
gNumGuestsInPark = _s6.guests_in_park;
|
2017-01-31 00:56:10 +01:00
|
|
|
gNumGuestsHeadingForPark = _s6.guests_heading_for_park;
|
|
|
|
|
|
|
|
memcpy(gExpenditureTable, _s6.expenditure_table, sizeof(_s6.expenditure_table));
|
|
|
|
|
|
|
|
gNumGuestsInParkLastWeek = _s6.last_guests_in_park;
|
|
|
|
// pad_01357BCA
|
|
|
|
gStaffHandymanColour = _s6.handyman_colour;
|
|
|
|
gStaffMechanicColour = _s6.mechanic_colour;
|
|
|
|
gStaffSecurityColour = _s6.security_colour;
|
|
|
|
|
|
|
|
memcpy(gResearchedSceneryItems, _s6.researched_scenery_items, sizeof(_s6.researched_scenery_items));
|
|
|
|
|
|
|
|
gParkRating = _s6.park_rating;
|
|
|
|
|
|
|
|
memcpy(gParkRatingHistory, _s6.park_rating_history, sizeof(_s6.park_rating_history));
|
|
|
|
memcpy(gGuestsInParkHistory, _s6.guests_in_park_history, sizeof(_s6.guests_in_park_history));
|
|
|
|
|
2017-04-24 22:38:16 +02:00
|
|
|
gResearchPriorities = _s6.active_research_types;
|
|
|
|
gResearchProgressStage = _s6.research_progress_stage;
|
2017-01-31 00:56:10 +01:00
|
|
|
gResearchLastItemSubject = _s6.last_researched_item_subject;
|
|
|
|
// pad_01357CF8
|
2017-04-24 22:38:16 +02:00
|
|
|
gResearchNextItem = _s6.next_research_item;
|
|
|
|
gResearchProgress = _s6.research_progress;
|
|
|
|
gResearchNextCategory = _s6.next_research_category;
|
|
|
|
gResearchExpectedDay = _s6.next_research_expected_day;
|
|
|
|
gResearchExpectedMonth = _s6.next_research_expected_month;
|
|
|
|
gGuestInitialHappiness = _s6.guest_initial_happiness;
|
|
|
|
gParkSize = _s6.park_size;
|
2017-01-31 00:56:10 +01:00
|
|
|
_guestGenerationProbability = _s6.guest_generation_probability;
|
2017-04-24 22:38:16 +02:00
|
|
|
gTotalRideValue = _s6.total_ride_value;
|
|
|
|
gMaxBankLoan = _s6.maximum_loan;
|
|
|
|
gGuestInitialCash = _s6.guest_initial_cash;
|
|
|
|
gGuestInitialHunger = _s6.guest_initial_hunger;
|
|
|
|
gGuestInitialThirst = _s6.guest_initial_thirst;
|
|
|
|
gScenarioObjectiveType = _s6.objective_type;
|
|
|
|
gScenarioObjectiveYear = _s6.objective_year;
|
2017-01-31 00:56:10 +01:00
|
|
|
// pad_013580FA
|
2017-04-24 22:38:16 +02:00
|
|
|
gScenarioObjectiveCurrency = _s6.objective_currency;
|
2017-01-31 00:56:10 +01:00
|
|
|
gScenarioObjectiveNumGuests = _s6.objective_guests;
|
|
|
|
memcpy(gMarketingCampaignDaysLeft, _s6.campaign_weeks_left, sizeof(_s6.campaign_weeks_left));
|
|
|
|
memcpy(gMarketingCampaignRideIndex, _s6.campaign_ride_index, sizeof(_s6.campaign_ride_index));
|
|
|
|
|
|
|
|
memcpy(gCashHistory, _s6.balance_history, sizeof(_s6.balance_history));
|
|
|
|
|
2017-04-24 22:38:16 +02:00
|
|
|
gCurrentExpenditure = _s6.current_expenditure;
|
|
|
|
gCurrentProfit = _s6.current_profit;
|
2017-01-31 00:56:10 +01:00
|
|
|
gWeeklyProfitAverageDividend = _s6.weekly_profit_average_dividend;
|
2017-04-24 22:38:16 +02:00
|
|
|
gWeeklyProfitAverageDivisor = _s6.weekly_profit_average_divisor;
|
2017-01-31 00:56:10 +01:00
|
|
|
// pad_0135833A
|
|
|
|
|
|
|
|
memcpy(gWeeklyProfitHistory, _s6.weekly_profit_history, sizeof(_s6.weekly_profit_history));
|
|
|
|
|
|
|
|
gParkValue = _s6.park_value;
|
|
|
|
|
|
|
|
memcpy(gParkValueHistory, _s6.park_value_history, sizeof(_s6.park_value_history));
|
|
|
|
|
|
|
|
gScenarioCompletedCompanyValue = _s6.completed_company_value;
|
2017-04-24 22:38:16 +02:00
|
|
|
gTotalAdmissions = _s6.total_admissions;
|
|
|
|
gTotalIncomeFromAdmissions = _s6.income_from_admissions;
|
|
|
|
gCompanyValue = _s6.company_value;
|
2017-01-31 00:56:10 +01:00
|
|
|
memcpy(gPeepWarningThrottle, _s6.peep_warning_throttle, sizeof(_s6.peep_warning_throttle));
|
|
|
|
|
|
|
|
// Awards
|
|
|
|
for (sint32 i = 0; i < RCT12_MAX_AWARDS; i++)
|
|
|
|
{
|
|
|
|
rct12_award * src = &_s6.awards[i];
|
2017-04-24 22:38:16 +02:00
|
|
|
Award * dst = &gCurrentAwards[i];
|
|
|
|
dst->Time = src->time;
|
|
|
|
dst->Type = src->type;
|
2017-01-31 00:56:10 +01:00
|
|
|
}
|
2016-05-07 17:20:10 +02:00
|
|
|
|
2017-04-24 22:38:16 +02:00
|
|
|
gLandPrice = _s6.land_price;
|
2017-01-31 00:56:10 +01:00
|
|
|
gConstructionRightsPrice = _s6.construction_rights_price;
|
|
|
|
// unk_01358774
|
|
|
|
// pad_01358776
|
|
|
|
// _s6.cd_key
|
2017-04-24 22:38:16 +02:00
|
|
|
_gameVersion = _s6.game_version_number;
|
2017-01-31 00:56:10 +01:00
|
|
|
gScenarioCompanyValueRecord = _s6.completed_company_value_record;
|
|
|
|
// _s6.loan_hash;
|
|
|
|
gRideCount = _s6.ride_count;
|
|
|
|
// pad_013587CA
|
|
|
|
gHistoricalProfit = _s6.historical_profit;
|
|
|
|
// pad_013587D4
|
|
|
|
memcpy(gScenarioCompletedBy, _s6.scenario_completed_name, sizeof(_s6.scenario_completed_name));
|
|
|
|
gCashEncrypted = _s6.cash;
|
|
|
|
// pad_013587FC
|
2017-04-24 22:38:16 +02:00
|
|
|
gParkRatingCasualtyPenalty = _s6.park_rating_casualty_penalty;
|
|
|
|
gMapSizeUnits = _s6.map_size_units;
|
|
|
|
gMapSizeMinus2 = _s6.map_size_minus_2;
|
|
|
|
gMapSize = _s6.map_size;
|
|
|
|
gMapSizeMaxXY = _s6.map_max_xy;
|
|
|
|
gSamePriceThroughoutParkA = _s6.same_price_throughout;
|
|
|
|
_suggestedGuestMaximum = _s6.suggested_max_guests;
|
2017-01-31 00:56:10 +01:00
|
|
|
gScenarioParkRatingWarningDays = _s6.park_rating_warning_days;
|
2017-04-24 22:38:16 +02:00
|
|
|
gLastEntranceStyle = _s6.last_entrance_style;
|
2017-01-31 00:56:10 +01:00
|
|
|
// rct1_water_colour
|
|
|
|
// pad_01358842
|
|
|
|
memcpy(gResearchItems, _s6.research_items, sizeof(_s6.research_items));
|
|
|
|
gMapBaseZ = _s6.map_base_z;
|
|
|
|
memcpy(gScenarioName, _s6.scenario_name, sizeof(_s6.scenario_name));
|
|
|
|
memcpy(gScenarioDetails, _s6.scenario_description, sizeof(_s6.scenario_description));
|
|
|
|
gBankLoanInterestRate = _s6.current_interest_rate;
|
|
|
|
// pad_0135934B
|
|
|
|
gSamePriceThroughoutParkB = _s6.same_price_throughout_extended;
|
2017-02-11 20:13:15 +01:00
|
|
|
// Preserve compatibility with vanilla RCT2's save format.
|
2017-02-11 19:51:19 +01:00
|
|
|
for (uint8 i = 0; i < RCT12_MAX_PARK_ENTRANCES; i++)
|
|
|
|
{
|
2017-04-24 22:38:16 +02:00
|
|
|
gParkEntrances[i].x = _s6.park_entrance_x[i];
|
|
|
|
gParkEntrances[i].y = _s6.park_entrance_y[i];
|
|
|
|
gParkEntrances[i].z = _s6.park_entrance_z[i];
|
2017-02-11 19:51:19 +01:00
|
|
|
gParkEntrances[i].direction = _s6.park_entrance_direction[i];
|
|
|
|
}
|
2017-07-09 18:22:53 +02:00
|
|
|
String::Set(gScenarioFileName, sizeof(gScenarioFileName), _s6.scenario_filename);
|
2017-01-31 00:56:10 +01:00
|
|
|
memcpy(gScenarioExpansionPacks, _s6.saved_expansion_pack_names, sizeof(_s6.saved_expansion_pack_names));
|
|
|
|
memcpy(gBanners, _s6.banners, sizeof(_s6.banners));
|
|
|
|
memcpy(gUserStrings, _s6.custom_strings, sizeof(_s6.custom_strings));
|
|
|
|
gCurrentTicks = _s6.game_ticks_1;
|
2017-07-19 22:00:48 +02:00
|
|
|
|
|
|
|
ImportRides();
|
|
|
|
|
2017-04-24 22:38:16 +02:00
|
|
|
gSavedAge = _s6.saved_age;
|
|
|
|
gSavedViewX = _s6.saved_view_x;
|
|
|
|
gSavedViewY = _s6.saved_view_y;
|
|
|
|
gSavedViewZoom = _s6.saved_view_zoom;
|
2017-01-31 00:56:10 +01:00
|
|
|
gSavedViewRotation = _s6.saved_view_rotation;
|
|
|
|
memcpy(gAnimatedObjects, _s6.map_animations, sizeof(_s6.map_animations));
|
|
|
|
gNumMapAnimations = _s6.num_map_animations;
|
|
|
|
// pad_0138B582
|
|
|
|
|
|
|
|
gRideRatingsCalcData = _s6.ride_ratings_calc_data;
|
|
|
|
memcpy(gRideMeasurements, _s6.ride_measurements, sizeof(_s6.ride_measurements));
|
2017-04-24 22:38:16 +02:00
|
|
|
gNextGuestNumber = _s6.next_guest_index;
|
2017-01-31 00:56:10 +01:00
|
|
|
gGrassSceneryTileLoopPosition = _s6.grass_and_scenery_tilepos;
|
|
|
|
memcpy(gStaffPatrolAreas, _s6.patrol_areas, sizeof(_s6.patrol_areas));
|
|
|
|
memcpy(gStaffModes, _s6.staff_modes, sizeof(_s6.staff_modes));
|
|
|
|
// unk_13CA73E
|
|
|
|
// pad_13CA73F
|
|
|
|
gUnk13CA740 = _s6.byte_13CA740;
|
2017-04-24 22:38:16 +02:00
|
|
|
gClimate = _s6.climate;
|
2017-01-31 00:56:10 +01:00
|
|
|
// pad_13CA741;
|
|
|
|
// byte_13CA742
|
|
|
|
// pad_013CA747
|
2017-04-24 22:38:16 +02:00
|
|
|
gClimateUpdateTimer = _s6.climate_update_timer;
|
|
|
|
gClimateCurrentWeather = _s6.current_weather;
|
|
|
|
gClimateNextWeather = _s6.next_weather;
|
|
|
|
gClimateCurrentTemperature = _s6.temperature;
|
|
|
|
gClimateNextTemperature = _s6.next_temperature;
|
2017-01-31 00:56:10 +01:00
|
|
|
gClimateCurrentWeatherEffect = _s6.current_weather_effect;
|
2017-04-24 22:38:16 +02:00
|
|
|
gClimateNextWeatherEffect = _s6.next_weather_effect;
|
|
|
|
gClimateCurrentWeatherGloom = _s6.current_weather_gloom;
|
|
|
|
gClimateNextWeatherGloom = _s6.next_weather_gloom;
|
|
|
|
gClimateCurrentRainLevel = _s6.current_rain_level;
|
|
|
|
gClimateNextRainLevel = _s6.next_rain_level;
|
2017-01-31 00:56:10 +01:00
|
|
|
|
|
|
|
// News items
|
|
|
|
for (size_t i = 0; i < RCT12_MAX_NEWS_ITEMS; i++)
|
|
|
|
{
|
|
|
|
const rct12_news_item * src = &_s6.news_items[i];
|
2017-04-24 22:38:16 +02:00
|
|
|
NewsItem * dst = &gNewsItems[i];
|
2017-01-31 00:56:10 +01:00
|
|
|
|
2017-04-24 22:38:16 +02:00
|
|
|
dst->Type = src->Type;
|
|
|
|
dst->Flags = src->Flags;
|
|
|
|
dst->Assoc = src->Assoc;
|
|
|
|
dst->Ticks = src->Ticks;
|
2017-01-31 00:56:10 +01:00
|
|
|
dst->MonthYear = src->MonthYear;
|
2017-04-24 22:38:16 +02:00
|
|
|
dst->Day = src->Day;
|
2017-01-31 00:56:10 +01:00
|
|
|
memcpy(dst->Text, src->Text, sizeof(src->Text));
|
|
|
|
}
|
2016-05-07 17:20:10 +02:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
// pad_13CE730
|
|
|
|
// rct1_scenario_flags
|
|
|
|
gWidePathTileLoopX = _s6.wide_path_tile_loop_x;
|
|
|
|
gWidePathTileLoopY = _s6.wide_path_tile_loop_y;
|
|
|
|
// pad_13CE778
|
2017-01-14 19:47:18 +01:00
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
// Fix and set dynamic variables
|
2017-06-22 19:57:25 +02:00
|
|
|
if (!_objectManager->LoadObjects(_s6.objects, OBJECT_ENTRY_COUNT))
|
2017-01-31 00:56:10 +01:00
|
|
|
{
|
|
|
|
throw ObjectLoadException();
|
|
|
|
}
|
|
|
|
map_strip_ghost_flag_from_elements();
|
|
|
|
map_update_tile_pointers();
|
|
|
|
game_convert_strings_to_utf8();
|
|
|
|
map_count_remaining_land_rights();
|
2017-07-05 20:36:35 +02:00
|
|
|
|
|
|
|
// We try to fix the cycles on import, hence the 'true' parameter
|
|
|
|
check_for_sprite_list_cycles(true);
|
|
|
|
check_for_spatial_index_cycles(true);
|
2017-07-07 00:12:54 +02:00
|
|
|
sint32 disjoint_sprites_count = fix_disjoint_sprites();
|
|
|
|
// This one is less harmful, no need to assert for it ~janisozaur
|
|
|
|
if (disjoint_sprites_count > 0)
|
|
|
|
{
|
|
|
|
log_error("Found %d disjoint null sprites", disjoint_sprites_count);
|
|
|
|
}
|
2017-01-17 13:51:02 +01:00
|
|
|
}
|
|
|
|
|
2017-07-19 22:00:48 +02:00
|
|
|
void ImportRides()
|
|
|
|
{
|
|
|
|
for (uint16 index = 0; index < RCT2_MAX_RIDES_IN_PARK; index++)
|
|
|
|
{
|
|
|
|
if (_s6.rides[index].type != RIDE_TYPE_NULL)
|
|
|
|
{
|
|
|
|
ImportRide(get_ride(index), &_s6.rides[index]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportRide(rct_ride * dst, const rct_ride * src)
|
|
|
|
{
|
|
|
|
memset(dst, 0, sizeof(rct_ride));
|
|
|
|
|
|
|
|
dst->type = src->type;
|
|
|
|
dst->subtype = src->subtype;
|
|
|
|
// pad_002;
|
|
|
|
dst->mode = src->mode;
|
|
|
|
dst->colour_scheme_type = src->colour_scheme_type;
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < RCT2_MAX_CARS_PER_TRAIN; i ++)
|
|
|
|
{
|
|
|
|
dst->vehicle_colours[i] = src->vehicle_colours[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// pad_046;
|
|
|
|
dst->status = src->status;
|
|
|
|
dst->name = src->name;
|
|
|
|
dst->name_arguments = src->name_arguments;
|
|
|
|
|
|
|
|
dst->overall_view = src->overall_view;
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
|
|
|
|
{
|
|
|
|
dst->station_starts[i] = src->station_starts[i];
|
|
|
|
dst->station_heights[i] = src->station_heights[i];
|
|
|
|
dst->station_length[i] = src->station_length[i];
|
|
|
|
dst->station_depart[i] = src->station_depart[i];
|
|
|
|
dst->train_at_station[i] = src->train_at_station[i];
|
|
|
|
dst->entrances[i] = src->entrances[i];
|
|
|
|
dst->exits[i] = src->exits[i];
|
|
|
|
dst->last_peep_in_queue[i] = src->last_peep_in_queue[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < MAX_VEHICLES_PER_RIDE; i++)
|
|
|
|
{
|
|
|
|
dst->vehicles[i] = src->vehicles[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->depart_flags = src->depart_flags;
|
|
|
|
|
|
|
|
dst->num_stations = src->num_stations;
|
|
|
|
dst->num_vehicles = src->num_vehicles;
|
|
|
|
dst->num_cars_per_train = src->num_cars_per_train;
|
|
|
|
dst->proposed_num_vehicles = src->proposed_num_vehicles;
|
|
|
|
dst->proposed_num_cars_per_train = src->proposed_num_cars_per_train;
|
|
|
|
dst->max_trains = src->max_trains;
|
|
|
|
dst->min_max_cars_per_train = src->min_max_cars_per_train;
|
|
|
|
dst->min_waiting_time = src->min_waiting_time;
|
|
|
|
dst->max_waiting_time = src->max_waiting_time;
|
|
|
|
|
|
|
|
// Includes time_limit, num_laps, launch_speed, speed, rotations
|
|
|
|
dst->operation_option = src->operation_option;
|
|
|
|
|
|
|
|
dst->boat_hire_return_direction = src->boat_hire_return_direction;
|
|
|
|
dst->boat_hire_return_position = src->boat_hire_return_position;
|
|
|
|
|
|
|
|
dst->measurement_index = src->measurement_index;
|
|
|
|
|
|
|
|
dst->special_track_elements = src->special_track_elements;
|
|
|
|
// pad_0D6[2];
|
|
|
|
|
|
|
|
dst->max_speed = src->max_speed;
|
|
|
|
dst->average_speed = src->average_speed;
|
|
|
|
dst->current_test_segment = src->current_test_segment;
|
|
|
|
dst->average_speed_test_timeout = src->average_speed_test_timeout;
|
|
|
|
// pad_0E2[0x2];
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
|
|
|
|
{
|
|
|
|
dst->length[i] = src->length[i];
|
2017-07-22 10:24:51 +02:00
|
|
|
dst->time[i] = src->time[i];
|
2017-07-19 22:00:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dst->max_positive_vertical_g = src->max_positive_vertical_g;
|
|
|
|
dst->max_negative_vertical_g = src->max_negative_vertical_g;
|
|
|
|
dst->max_lateral_g = src->max_lateral_g;
|
|
|
|
dst->previous_vertical_g = src->previous_vertical_g;
|
|
|
|
dst->previous_lateral_g = src->previous_lateral_g;
|
|
|
|
// pad_106[0x2];
|
|
|
|
dst->testing_flags = src->testing_flags;
|
|
|
|
dst->cur_test_track_location = src->cur_test_track_location;
|
|
|
|
dst->turn_count_default = src->turn_count_default;
|
|
|
|
dst->turn_count_banked = src->turn_count_banked;
|
|
|
|
dst->turn_count_sloped = src->turn_count_sloped;
|
|
|
|
// Includes holes and (for some strange reason?!) sheltered_eights
|
|
|
|
dst->inversions = src->inversions;
|
|
|
|
dst->drops = src->drops;
|
|
|
|
dst->start_drop_height = src->start_drop_height;
|
|
|
|
dst->highest_drop_height = src->highest_drop_height;
|
|
|
|
dst->sheltered_length = src->sheltered_length;
|
|
|
|
dst->var_11C = src->var_11C;
|
|
|
|
dst->num_sheltered_sections = src->num_sheltered_sections;
|
|
|
|
dst->cur_test_track_z = src->cur_test_track_z;
|
|
|
|
|
|
|
|
dst->cur_num_customers = src->cur_num_customers;
|
|
|
|
dst->num_customers_timeout = src->num_customers_timeout;
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
dst->num_customers[i] = src->num_customers[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->price = src->price;
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
dst->chairlift_bullwheel_location[i] = src->chairlift_bullwheel_location[i];
|
|
|
|
dst->chairlift_bullwheel_z[i] = src->chairlift_bullwheel_z[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->ratings = src->ratings;
|
|
|
|
dst->value = src->value;
|
|
|
|
|
|
|
|
dst->chairlift_bullwheel_rotation = src->chairlift_bullwheel_rotation;
|
|
|
|
|
|
|
|
dst->satisfaction = src->satisfaction;
|
|
|
|
dst->satisfaction_time_out = src->satisfaction_time_out;
|
|
|
|
dst->satisfaction_next = src->satisfaction_next;
|
|
|
|
|
|
|
|
dst->window_invalidate_flags = src->window_invalidate_flags;
|
|
|
|
// pad_14E[0x02];
|
|
|
|
|
|
|
|
dst->total_customers = src->total_customers;
|
|
|
|
dst->total_profit = src->total_profit;
|
|
|
|
dst->popularity = src->popularity;
|
|
|
|
dst->popularity_time_out = src->popularity_time_out;
|
|
|
|
dst->popularity_next = src->popularity_next;
|
|
|
|
dst->num_riders = src->num_riders;
|
|
|
|
dst->music_tune_id = src->music_tune_id;
|
|
|
|
dst->slide_in_use = src->slide_in_use;
|
|
|
|
// Includes maze_tiles
|
|
|
|
dst->slide_peep = src->slide_peep;
|
|
|
|
// pad_160[0xE];
|
|
|
|
dst->slide_peep_t_shirt_colour = src->slide_peep_t_shirt_colour;
|
|
|
|
// pad_16F[0x7];
|
|
|
|
dst->spiral_slide_progress = src->spiral_slide_progress;
|
|
|
|
// pad_177[0x9];
|
|
|
|
dst->build_date = src->build_date;
|
|
|
|
dst->upkeep_cost = src->upkeep_cost;
|
|
|
|
dst->race_winner = src->race_winner;
|
|
|
|
// pad_186[0x02];
|
|
|
|
dst->music_position = src->music_position;
|
|
|
|
|
|
|
|
dst->breakdown_reason_pending = src->breakdown_reason_pending;
|
|
|
|
dst->mechanic_status = src->mechanic_status;
|
|
|
|
dst->mechanic = src->mechanic;
|
|
|
|
dst->inspection_station = src->inspection_station;
|
|
|
|
dst->broken_vehicle = src->broken_vehicle;
|
|
|
|
dst->broken_car = src->broken_car;
|
|
|
|
dst->breakdown_reason = src->breakdown_reason;
|
|
|
|
|
|
|
|
dst->price_secondary = src->price_secondary;
|
|
|
|
|
|
|
|
dst->reliability = src->reliability;
|
|
|
|
dst->unreliability_factor = src->unreliability_factor;
|
|
|
|
dst->downtime = src->downtime;
|
|
|
|
dst->inspection_interval = src->inspection_interval;
|
|
|
|
dst->last_inspection = src->last_inspection;
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
dst->downtime_history[i] = src->downtime_history[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->no_primary_items_sold = src->no_primary_items_sold;
|
|
|
|
dst->no_secondary_items_sold = src->no_secondary_items_sold;
|
|
|
|
|
|
|
|
dst->breakdown_sound_modifier = src->breakdown_sound_modifier;
|
|
|
|
dst->not_fixed_timeout = src->not_fixed_timeout;
|
|
|
|
dst->last_crash_type = src->last_crash_type;
|
|
|
|
dst->connected_message_throttle = src->connected_message_throttle;
|
|
|
|
|
|
|
|
dst->income_per_hour = src->income_per_hour;
|
|
|
|
dst->profit = src->profit;
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
|
|
|
|
{
|
|
|
|
dst->queue_time[i] = src->queue_time[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < RCT12_NUM_COLOUR_SCHEMES; i++)
|
|
|
|
{
|
|
|
|
dst->track_colour_main[i] = src->track_colour_main[i];
|
|
|
|
dst->track_colour_additional[i] = src->track_colour_additional[i];
|
|
|
|
dst->track_colour_supports[i] = src->track_colour_supports[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->music = src->music;
|
|
|
|
dst->entrance_style = src->entrance_style;
|
|
|
|
dst->vehicle_change_timeout = src->vehicle_change_timeout;
|
|
|
|
dst->num_block_brakes = src->num_block_brakes;
|
|
|
|
dst->lift_hill_speed = src->lift_hill_speed;
|
|
|
|
dst->guests_favourite = src->guests_favourite;
|
|
|
|
dst->lifecycle_flags = src->lifecycle_flags;
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < RCT2_MAX_CARS_PER_TRAIN; i++)
|
|
|
|
{
|
|
|
|
dst->vehicle_colours_extended[i] = src->vehicle_colours_extended[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
dst->total_air_time = src->total_air_time;
|
|
|
|
dst->current_test_station = src->current_test_station;
|
|
|
|
dst->num_circuits = src->num_circuits;
|
|
|
|
dst->cable_lift_x = src->cable_lift_x;
|
|
|
|
dst->cable_lift_y = src->cable_lift_y;
|
|
|
|
dst->cable_lift_z = src->cable_lift_z;
|
|
|
|
// pad_1FD;
|
|
|
|
dst->cable_lift = src->cable_lift;
|
|
|
|
|
|
|
|
for (uint8 i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
|
|
|
|
{
|
|
|
|
dst->queue_length[i] = src->queue_length[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// pad_208[0x58];
|
|
|
|
}
|
|
|
|
|
2017-01-31 00:56:10 +01:00
|
|
|
void Initialise()
|
2016-05-08 18:21:55 +02:00
|
|
|
{
|
2017-01-31 00:56:10 +01:00
|
|
|
game_init_all(_s6.map_size);
|
2016-05-08 18:21:55 +02:00
|
|
|
}
|
2017-01-31 00:56:10 +01:00
|
|
|
};
|
2017-01-23 14:00:46 +01:00
|
|
|
|
2017-06-22 19:57:25 +02:00
|
|
|
IParkImporter * ParkImporter::CreateS6(IObjectRepository * objectRepository, IObjectManager * objectManager)
|
2017-01-31 19:37:55 +01:00
|
|
|
{
|
2017-06-22 19:57:25 +02:00
|
|
|
return new S6Importer(objectRepository, objectManager);
|
2017-01-31 19:37:55 +01:00
|
|
|
}
|
|
|
|
|
2016-05-07 18:37:50 +02:00
|
|
|
extern "C"
|
|
|
|
{
|
2017-07-01 02:26:23 +02:00
|
|
|
ParkLoadResult * game_load_sv6_path(const char * path)
|
2016-10-03 20:14:26 +02:00
|
|
|
{
|
2017-07-01 02:26:23 +02:00
|
|
|
ParkLoadResult * result = nullptr;
|
2017-06-22 19:57:25 +02:00
|
|
|
auto s6Importer = new S6Importer(GetObjectRepository(), GetObjectManager());
|
2016-10-03 20:14:26 +02:00
|
|
|
try
|
|
|
|
{
|
2017-07-01 02:26:23 +02:00
|
|
|
result = new ParkLoadResult(s6Importer->LoadSavedGame(path));
|
2016-10-03 20:14:26 +02:00
|
|
|
|
2017-06-06 15:34:30 +02:00
|
|
|
// We mustn't import if there's something
|
|
|
|
// wrong with the park data
|
2017-07-01 02:26:23 +02:00
|
|
|
if (result->Error == PARK_LOAD_ERROR_OK)
|
2017-06-06 15:34:30 +02:00
|
|
|
{
|
|
|
|
s6Importer->Import();
|
|
|
|
|
|
|
|
game_fix_save_vars();
|
|
|
|
sprite_position_tween_reset();
|
|
|
|
}
|
2016-10-03 20:14:26 +02:00
|
|
|
}
|
2016-11-30 23:32:47 +01:00
|
|
|
catch (const ObjectLoadException &)
|
2016-10-03 20:14:26 +02:00
|
|
|
{
|
2017-04-24 22:38:16 +02:00
|
|
|
gErrorType = ERROR_TYPE_FILE_LOAD;
|
2017-06-06 15:34:30 +02:00
|
|
|
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
2016-10-03 20:14:26 +02:00
|
|
|
}
|
2016-11-30 23:32:47 +01:00
|
|
|
catch (const IOException &)
|
2016-10-03 20:14:26 +02:00
|
|
|
{
|
2017-04-24 22:38:16 +02:00
|
|
|
gErrorType = ERROR_TYPE_FILE_LOAD;
|
2016-10-03 20:14:26 +02:00
|
|
|
gErrorStringId = STR_GAME_SAVE_FAILED;
|
|
|
|
}
|
2016-11-30 23:32:47 +01:00
|
|
|
catch (const Exception &)
|
2016-10-03 20:14:26 +02:00
|
|
|
{
|
2017-04-24 22:38:16 +02:00
|
|
|
gErrorType = ERROR_TYPE_FILE_LOAD;
|
2016-10-03 20:14:26 +02:00
|
|
|
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
|
|
|
}
|
|
|
|
delete s6Importer;
|
|
|
|
|
2017-07-01 02:26:23 +02:00
|
|
|
if (result == nullptr)
|
|
|
|
{
|
|
|
|
result = new ParkLoadResult(ParkLoadResult::CreateUnknown());
|
|
|
|
}
|
|
|
|
if (result->Error == PARK_LOAD_ERROR_OK)
|
2017-06-06 15:34:30 +02:00
|
|
|
{
|
|
|
|
gScreenAge = 0;
|
|
|
|
gLastAutoSaveUpdate = AUTOSAVE_PAUSE;
|
|
|
|
}
|
2016-10-03 20:14:26 +02:00
|
|
|
return result;
|
2016-05-07 18:37:50 +02:00
|
|
|
}
|
2016-05-07 23:47:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00676053
|
|
|
|
* scenario (ebx)
|
|
|
|
*/
|
2017-07-01 02:26:23 +02:00
|
|
|
ParkLoadResult * scenario_load(const char * path)
|
2016-05-07 23:47:29 +02:00
|
|
|
{
|
2017-07-01 02:26:23 +02:00
|
|
|
ParkLoadResult * result = nullptr;
|
2017-06-22 19:57:25 +02:00
|
|
|
auto s6Importer = new S6Importer(GetObjectRepository(), GetObjectManager());
|
2016-05-07 23:47:29 +02:00
|
|
|
try
|
|
|
|
{
|
2017-07-01 02:26:23 +02:00
|
|
|
result = new ParkLoadResult(s6Importer->LoadScenario(path));
|
|
|
|
if (result->Error == PARK_LOAD_ERROR_OK)
|
2017-06-06 15:34:30 +02:00
|
|
|
{
|
|
|
|
s6Importer->Import();
|
2016-05-07 23:47:29 +02:00
|
|
|
|
2017-06-06 15:34:30 +02:00
|
|
|
game_fix_save_vars();
|
|
|
|
sprite_position_tween_reset();
|
|
|
|
}
|
2016-05-07 23:47:29 +02:00
|
|
|
}
|
2016-11-30 23:32:47 +01:00
|
|
|
catch (const ObjectLoadException &)
|
2016-05-07 23:47:29 +02:00
|
|
|
{
|
2017-04-24 22:38:16 +02:00
|
|
|
gErrorType = ERROR_TYPE_FILE_LOAD;
|
2016-07-09 16:36:48 +02:00
|
|
|
gErrorStringId = STR_GAME_SAVE_FAILED;
|
2016-05-07 23:47:29 +02:00
|
|
|
}
|
2016-11-30 23:32:47 +01:00
|
|
|
catch (const IOException &)
|
2016-05-07 23:47:29 +02:00
|
|
|
{
|
2017-04-24 22:38:16 +02:00
|
|
|
gErrorType = ERROR_TYPE_FILE_LOAD;
|
2016-05-08 02:22:32 +02:00
|
|
|
gErrorStringId = STR_GAME_SAVE_FAILED;
|
2016-05-07 23:47:29 +02:00
|
|
|
}
|
2016-11-30 23:32:47 +01:00
|
|
|
catch (const Exception &)
|
2016-05-07 23:47:29 +02:00
|
|
|
{
|
2017-04-24 22:38:16 +02:00
|
|
|
gErrorType = ERROR_TYPE_FILE_LOAD;
|
2016-05-07 23:47:29 +02:00
|
|
|
gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA;
|
|
|
|
}
|
|
|
|
delete s6Importer;
|
2017-07-01 02:26:23 +02:00
|
|
|
|
|
|
|
if (result == nullptr)
|
|
|
|
{
|
|
|
|
result = new ParkLoadResult(ParkLoadResult::CreateUnknown());
|
|
|
|
}
|
|
|
|
if (result->Error != PARK_LOAD_ERROR_OK)
|
2017-06-06 15:34:30 +02:00
|
|
|
{
|
|
|
|
gScreenAge = 0;
|
|
|
|
gLastAutoSaveUpdate = AUTOSAVE_PAUSE;
|
|
|
|
}
|
2016-05-07 23:47:29 +02:00
|
|
|
return result;
|
|
|
|
}
|
2016-05-07 14:58:36 +02:00
|
|
|
}
|