2016-05-04 19:24:41 +02:00
|
|
|
/*****************************************************************************
|
2024-01-01 12:52:28 +01:00
|
|
|
* Copyright (c) 2014-2024 OpenRCT2 developers
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-05-04 19:24:41 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2016-04-17 16:21:35 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-31 00:08:04 +01:00
|
|
|
#include "common.h"
|
2018-06-22 23:25:16 +02:00
|
|
|
#include "core/String.hpp"
|
2020-08-05 04:26:59 +02:00
|
|
|
#include "object/Object.h"
|
2021-09-12 21:25:22 +02:00
|
|
|
#include "object/ObjectList.h"
|
2018-06-22 23:25:16 +02:00
|
|
|
|
2018-04-20 23:16:37 +02:00
|
|
|
#include <memory>
|
2017-01-31 20:15:48 +01:00
|
|
|
#include <string>
|
2017-07-01 02:26:23 +02:00
|
|
|
#include <vector>
|
2016-04-17 16:21:35 +02:00
|
|
|
|
2020-07-30 23:19:53 +02:00
|
|
|
struct IObjectManager;
|
|
|
|
struct IObjectRepository;
|
2021-09-12 21:25:22 +02:00
|
|
|
|
2020-07-30 23:01:22 +02:00
|
|
|
namespace OpenRCT2
|
|
|
|
{
|
2020-07-30 23:19:53 +02:00
|
|
|
struct IStream;
|
2023-12-28 00:29:06 +01:00
|
|
|
struct GameState_t;
|
|
|
|
} // namespace OpenRCT2
|
2020-07-30 23:19:53 +02:00
|
|
|
|
2023-02-13 21:30:16 +01:00
|
|
|
struct ScenarioIndexEntry;
|
2017-01-30 23:58:48 +01:00
|
|
|
|
2017-07-01 02:26:23 +02:00
|
|
|
struct ParkLoadResult final
|
|
|
|
{
|
|
|
|
public:
|
2021-09-12 21:25:22 +02:00
|
|
|
ObjectList RequiredObjects;
|
2022-04-17 00:47:15 +02:00
|
|
|
bool SemiCompatibleVersion{};
|
|
|
|
uint32_t MinVersion{};
|
|
|
|
uint32_t TargetVersion{};
|
2018-05-21 01:11:42 +02:00
|
|
|
|
2021-09-12 21:25:22 +02:00
|
|
|
explicit ParkLoadResult(ObjectList&& requiredObjects)
|
2020-04-16 13:13:13 +02:00
|
|
|
: RequiredObjects(std::move(requiredObjects))
|
2018-05-21 01:11:42 +02:00
|
|
|
{
|
|
|
|
}
|
2017-07-01 02:26:23 +02:00
|
|
|
};
|
|
|
|
|
2016-04-17 16:21:35 +02:00
|
|
|
/**
|
2017-01-31 00:08:04 +01:00
|
|
|
* Interface to import scenarios and saved games.
|
2016-04-17 16:21:35 +02:00
|
|
|
*/
|
2020-07-30 23:19:53 +02:00
|
|
|
struct IParkImporter
|
2016-04-17 16:21:35 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-01-31 00:08:04 +01:00
|
|
|
virtual ~IParkImporter() = default;
|
2017-07-01 02:26:23 +02:00
|
|
|
|
2023-02-13 21:30:16 +01:00
|
|
|
virtual ParkLoadResult Load(const u8string& path) abstract;
|
|
|
|
virtual ParkLoadResult LoadSavedGame(const u8string& path, bool skipObjectCheck = false) abstract;
|
|
|
|
virtual ParkLoadResult LoadScenario(const u8string& path, bool skipObjectCheck = false) abstract;
|
2018-06-22 23:25:16 +02:00
|
|
|
virtual ParkLoadResult LoadFromStream(
|
2023-02-13 21:30:16 +01:00
|
|
|
OpenRCT2::IStream* stream, bool isScenario, bool skipObjectCheck = false, const u8string& path = {}) abstract;
|
2017-07-01 02:26:23 +02:00
|
|
|
|
2023-12-28 00:29:06 +01:00
|
|
|
virtual void Import(OpenRCT2::GameState_t& gameState) abstract;
|
2023-02-13 21:30:16 +01:00
|
|
|
virtual bool GetDetails(ScenarioIndexEntry* dst) abstract;
|
2016-04-17 16:21:35 +02:00
|
|
|
};
|
2016-09-08 22:31:46 +02:00
|
|
|
|
2017-01-31 20:15:48 +01:00
|
|
|
namespace ParkImporter
|
|
|
|
{
|
2021-08-23 20:09:43 +02:00
|
|
|
[[nodiscard]] std::unique_ptr<IParkImporter> Create(const std::string& hintPath);
|
|
|
|
[[nodiscard]] std::unique_ptr<IParkImporter> CreateS4();
|
|
|
|
[[nodiscard]] std::unique_ptr<IParkImporter> CreateS6(IObjectRepository& objectRepository);
|
2021-10-27 14:21:14 +02:00
|
|
|
[[nodiscard]] std::unique_ptr<IParkImporter> CreateParkFile(IObjectRepository& objectRepository);
|
2017-01-31 20:15:48 +01:00
|
|
|
|
2022-01-09 21:48:11 +01:00
|
|
|
bool ExtensionIsOpenRCT2ParkFile(std::string_view extension);
|
|
|
|
bool ExtensionIsRCT1(std::string_view extension);
|
|
|
|
bool ExtensionIsScenario(std::string_view extension);
|
2018-06-22 23:25:16 +02:00
|
|
|
} // namespace ParkImporter
|
2017-01-31 20:15:48 +01:00
|
|
|
|
2018-05-21 20:06:21 +02:00
|
|
|
class ObjectLoadException : public std::exception
|
2018-05-21 01:11:42 +02:00
|
|
|
{
|
|
|
|
public:
|
2021-09-12 21:25:22 +02:00
|
|
|
std::vector<ObjectEntryDescriptor> const MissingObjects;
|
2018-05-21 01:11:42 +02:00
|
|
|
|
2021-09-12 21:25:22 +02:00
|
|
|
explicit ObjectLoadException(std::vector<ObjectEntryDescriptor>&& missingObjects)
|
2021-01-11 22:14:15 +01:00
|
|
|
: MissingObjects(std::move(missingObjects))
|
2018-05-21 01:11:42 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-01 14:49:43 +01:00
|
|
|
class UnsupportedRideTypeException : public std::exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ObjectEntryIndex const Type;
|
|
|
|
|
|
|
|
explicit UnsupportedRideTypeException(ObjectEntryIndex type)
|
|
|
|
: Type(type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
2022-04-17 00:47:15 +02:00
|
|
|
|
|
|
|
class UnsupportedVersionException : public std::exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
uint32_t const MinVersion;
|
|
|
|
uint32_t const TargetVersion;
|
|
|
|
|
|
|
|
explicit UnsupportedVersionException(uint32_t minVersion, uint32_t targetVersion)
|
|
|
|
: MinVersion(minVersion)
|
|
|
|
, TargetVersion(targetVersion)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|