OpenRCT2/src/openrct2/ParkImporter.h

103 lines
2.7 KiB
C
Raw Normal View History

/*****************************************************************************
2020-07-21 15:04:34 +02:00
* Copyright (c) 2014-2020 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
2017-01-31 00:08:04 +01:00
#include "common.h"
2018-06-22 23:25:16 +02:00
#include "core/String.hpp"
#include "object/Object.h"
2021-04-01 02:13:31 +02:00
#include "object/ObjectList.h"
2018-06-22 23:25:16 +02:00
#include <memory>
#include <string>
#include <vector>
struct IObjectManager;
struct IObjectRepository;
2021-04-01 02:13:31 +02:00
namespace OpenRCT2
{
struct IStream;
}
struct scenario_index_entry;
struct ParkLoadResult final
{
public:
2021-04-01 02:13:31 +02:00
ObjectList RequiredObjects;
2021-04-01 02:13:31 +02:00
explicit ParkLoadResult(ObjectList&& requiredObjects)
: RequiredObjects(std::move(requiredObjects))
{
}
};
/**
2017-01-31 00:08:04 +01:00
* Interface to import scenarios and saved games.
*/
struct IParkImporter
{
public:
2017-01-31 00:08:04 +01:00
virtual ~IParkImporter() = default;
2018-06-22 23:25:16 +02:00
virtual ParkLoadResult Load(const utf8* path) abstract;
virtual ParkLoadResult LoadSavedGame(const utf8* path, bool skipObjectCheck = false) abstract;
virtual ParkLoadResult LoadScenario(const utf8* path, bool skipObjectCheck = false) abstract;
virtual ParkLoadResult LoadFromStream(
OpenRCT2::IStream* stream, bool isScenario, bool skipObjectCheck = false, const utf8* path = String::Empty) abstract;
virtual void Import() abstract;
virtual bool GetDetails(scenario_index_entry* dst) abstract;
};
namespace ParkImporter
{
[[nodiscard]] std::unique_ptr<IParkImporter> Create(const std::string& hintPath);
[[nodiscard]] std::unique_ptr<IParkImporter> CreateS4();
[[nodiscard]] std::unique_ptr<IParkImporter> CreateS6(IObjectRepository& objectRepository);
[[nodiscard]] std::unique_ptr<IParkImporter> CreateParkFile(IObjectRepository& objectRepository);
2018-06-22 23:25:16 +02:00
bool ExtensionIsRCT1(const std::string& extension);
bool ExtensionIsScenario(const std::string& extension);
} // namespace ParkImporter
2018-05-21 20:06:21 +02:00
class ObjectLoadException : public std::exception
{
public:
std::vector<ObjectEntryDescriptor> const MissingObjects;
explicit ObjectLoadException(std::vector<ObjectEntryDescriptor>&& missingObjects)
: MissingObjects(std::move(missingObjects))
{
}
};
2018-05-21 20:06:21 +02:00
class UnsupportedRCTCFlagException : public std::exception
{
public:
uint8_t const Flag;
explicit UnsupportedRCTCFlagException(uint8_t flag)
: Flag(flag)
{
}
};
class UnsupportedRideTypeException : public std::exception
{
public:
ObjectEntryIndex const Type;
explicit UnsupportedRideTypeException(ObjectEntryIndex type)
: Type(type)
{
}
};