mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #7430 from IntelOrca/fix/scan-objects
Fix scan objects and run before tests
This commit is contained in:
commit
41b3a33af4
|
@ -185,7 +185,14 @@
|
||||||
<MSBuild Projects="openrct2.sln" Targets="Rebuild" Properties="$(SlnProperties)" />
|
<MSBuild Projects="openrct2.sln" Targets="Rebuild" Properties="$(SlnProperties)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="Test" DependsOnTargets="Build">
|
<Target Name="Test">
|
||||||
|
<!-- Scan repositories prior to running tests as it can take a while -->
|
||||||
|
<Message Text="Building OpenRCT2 repository indexes..." Importance="high" />
|
||||||
|
<Exec Command="$(TargetDir)openrct2.exe scan-objects"
|
||||||
|
WorkingDirectory="$(TargetDir)"
|
||||||
|
StandardOutputImportance="normal" />
|
||||||
|
|
||||||
|
<Message Text="Running tests..." Importance="high" />
|
||||||
<Exec Command="$(TargetDir)tests.exe "--gtest_output=xml:$(ArtifactsDir)test-results.xml""
|
<Exec Command="$(TargetDir)tests.exe "--gtest_output=xml:$(ArtifactsDir)test-results.xml""
|
||||||
WorkingDirectory="$(TargetDir)" />
|
WorkingDirectory="$(TargetDir)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
|
@ -28,15 +28,15 @@ pushd build
|
||||||
if [[ $TARGET == "docker64" ]]
|
if [[ $TARGET == "docker64" ]]
|
||||||
then
|
then
|
||||||
# CMAKE and MAKE opts from environment
|
# CMAKE and MAKE opts from environment
|
||||||
docker run -v "$PARENT":"$PARENT" -w "$PARENT"/build -i -t openrct2/openrct2:64bit-only bash -c "cmake ../ -DWITH_TESTS=on $OPENRCT2_CMAKE_OPTS && ninja all install $OPENRCT_MAKE_OPTS && ctest --output-on-failure"
|
docker run -v "$PARENT":"$PARENT" -w "$PARENT"/build -i -t openrct2/openrct2:64bit-only bash -c "cmake ../ -DWITH_TESTS=on $OPENRCT2_CMAKE_OPTS && ninja all install $OPENRCT_MAKE_OPTS && ./openrct2-cli scan-objects && ctest --output-on-failure"
|
||||||
elif [[ $TARGET == "ubuntu_i686" ]]
|
elif [[ $TARGET == "ubuntu_i686" ]]
|
||||||
then
|
then
|
||||||
# CMAKE and MAKE opts from environment
|
# CMAKE and MAKE opts from environment
|
||||||
docker run -v "$PARENT":"$PARENT" -w "$PARENT"/build -i -t openrct2/openrct2:ubuntu_i686 bash -c "cmake ../ -DWITH_TESTS=on $OPENRCT2_CMAKE_OPTS && ninja all testpaint install $OPENRCT_MAKE_OPTS && ctest --output-on-failure && ( ./testpaint --quiet || if [[ \$? -eq 1 ]] ; then echo Allowing failed tests to pass ; else echo here ; false; fi )"
|
docker run -v "$PARENT":"$PARENT" -w "$PARENT"/build -i -t openrct2/openrct2:ubuntu_i686 bash -c "cmake ../ -DWITH_TESTS=on $OPENRCT2_CMAKE_OPTS && ninja all testpaint install $OPENRCT_MAKE_OPTS && ./openrct2-cli scan-objects && ctest --output-on-failure && ( ./testpaint --quiet || if [[ \$? -eq 1 ]] ; then echo Allowing failed tests to pass ; else echo here ; false; fi )"
|
||||||
elif [[ $TARGET == "ubuntu_amd64" ]]
|
elif [[ $TARGET == "ubuntu_amd64" ]]
|
||||||
then
|
then
|
||||||
# CMAKE and MAKE opts from environment
|
# CMAKE and MAKE opts from environment
|
||||||
docker run -v "$PARENT":"$PARENT" -w "$PARENT"/build -i -t openrct2/openrct2:ubuntu_amd64 bash -c "cmake ../ -DWITH_TESTS=on $OPENRCT2_CMAKE_OPTS && ninja $OPENRCT_MAKE_OPTS install && ctest --output-on-failure"
|
docker run -v "$PARENT":"$PARENT" -w "$PARENT"/build -i -t openrct2/openrct2:ubuntu_amd64 bash -c "cmake ../ -DWITH_TESTS=on $OPENRCT2_CMAKE_OPTS && ninja $OPENRCT_MAKE_OPTS install && ./openrct2-cli scan-objects && ctest --output-on-failure"
|
||||||
elif [[ $TARGET == "windows" ]]
|
elif [[ $TARGET == "windows" ]]
|
||||||
then
|
then
|
||||||
# CMAKE and MAKE opts from environment
|
# CMAKE and MAKE opts from environment
|
||||||
|
|
|
@ -15,12 +15,13 @@
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "../config/Config.h"
|
#include "../config/Config.h"
|
||||||
|
#include "../Context.h"
|
||||||
#include "../platform/Crash.h"
|
#include "../platform/Crash.h"
|
||||||
#include "../platform/platform.h"
|
#include "../platform/platform.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
|
|
||||||
#include "../core/Console.hpp"
|
#include "../core/Console.hpp"
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/Path.hpp"
|
#include "../core/Path.hpp"
|
||||||
|
@ -394,12 +395,15 @@ static exitcode_t HandleCommandScanObjects([[maybe_unused]] CommandLineArgEnumer
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto env = OpenRCT2::CreatePlatformEnvironment();
|
gOpenRCT2Headless = true;
|
||||||
|
|
||||||
|
auto context = std::unique_ptr<OpenRCT2::IContext>(OpenRCT2::CreateContext());
|
||||||
|
auto env = context->GetPlatformEnvironment();
|
||||||
|
auto objectRepository = std::unique_ptr<IObjectRepository>(CreateObjectRepository(env));
|
||||||
|
|
||||||
// HACK: set gCurrentLanguage otherwise it be wrong for the index file
|
// HACK: set gCurrentLanguage otherwise it be wrong for the index file
|
||||||
gCurrentLanguage = gConfigGeneral.language;
|
gCurrentLanguage = gConfigGeneral.language;
|
||||||
|
|
||||||
auto objectRepository = CreateObjectRepository(env);
|
|
||||||
objectRepository->Construct();
|
objectRepository->Construct();
|
||||||
return EXITCODE_OK;
|
return EXITCODE_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
|
#include "../object/ObjectRepository.h"
|
||||||
#include "BannerObject.h"
|
#include "BannerObject.h"
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
|
@ -46,17 +47,21 @@ void BannerObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
|
||||||
|
|
||||||
// Add banners to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab.
|
// Add banners to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab.
|
||||||
// Since this is already done the other way round for original items, avoid adding those to prevent duplicates.
|
// Since this is already done the other way round for original items, avoid adding those to prevent duplicates.
|
||||||
const std::string identifier = GetIdentifier();
|
auto identifier = GetIdentifier();
|
||||||
const rct_object_entry * objectEntry = object_list_find_by_name(identifier.c_str());
|
|
||||||
static const rct_object_entry scgPathX = Object::GetScgPathXHeader();
|
|
||||||
|
|
||||||
if (objectEntry != nullptr &&
|
auto& objectRepository = context->GetObjectRepository();
|
||||||
(object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_WACKY_WORLDS ||
|
auto item = objectRepository.FindObject(identifier);
|
||||||
object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_TIME_TWISTER ||
|
if (item != nullptr)
|
||||||
object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_CUSTOM))
|
|
||||||
{
|
{
|
||||||
|
auto objectEntry = &item->ObjectEntry;
|
||||||
|
if (object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_WACKY_WORLDS ||
|
||||||
|
object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_TIME_TWISTER ||
|
||||||
|
object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_CUSTOM)
|
||||||
|
{
|
||||||
|
auto scgPathX = Object::GetScgPathXHeader();
|
||||||
SetPrimarySceneryGroup(&scgPathX);
|
SetPrimarySceneryGroup(&scgPathX);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BannerObject::Load()
|
void BannerObject::Load()
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "../interface/Cursors.h"
|
#include "../interface/Cursors.h"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
|
#include "../object/ObjectRepository.h"
|
||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
#include "FootpathItemObject.h"
|
#include "FootpathItemObject.h"
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
|
@ -49,17 +50,21 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext * context, IStream * stre
|
||||||
|
|
||||||
// Add path bits to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab.
|
// Add path bits to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab.
|
||||||
// Since this is already done the other way round for original items, avoid adding those to prevent duplicates.
|
// Since this is already done the other way round for original items, avoid adding those to prevent duplicates.
|
||||||
const std::string identifier = GetIdentifier();
|
auto identifier = GetIdentifier();
|
||||||
const rct_object_entry * objectEntry = object_list_find_by_name(identifier.c_str());
|
|
||||||
static const rct_object_entry scgPathX = Object::GetScgPathXHeader();
|
|
||||||
|
|
||||||
if (objectEntry != nullptr &&
|
auto& objectRepository = context->GetObjectRepository();
|
||||||
(object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_WACKY_WORLDS ||
|
auto item = objectRepository.FindObject(identifier);
|
||||||
object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_TIME_TWISTER ||
|
if (item != nullptr)
|
||||||
object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_CUSTOM))
|
|
||||||
{
|
{
|
||||||
|
auto sourceGame = object_entry_get_source_game(&item->ObjectEntry);
|
||||||
|
if (sourceGame == OBJECT_SOURCE_WACKY_WORLDS ||
|
||||||
|
sourceGame == OBJECT_SOURCE_TIME_TWISTER ||
|
||||||
|
sourceGame == OBJECT_SOURCE_CUSTOM)
|
||||||
|
{
|
||||||
|
auto scgPathX = Object::GetScgPathXHeader();
|
||||||
SetPrimarySceneryGroup(&scgPathX);
|
SetPrimarySceneryGroup(&scgPathX);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FootpathItemObject::Load()
|
void FootpathItemObject::Load()
|
||||||
|
|
|
@ -111,6 +111,7 @@ struct rct_object_filters {
|
||||||
assert_struct_size(rct_object_filters, 3);
|
assert_struct_size(rct_object_filters, 3);
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
interface IObjectRepository;
|
||||||
interface IStream;
|
interface IStream;
|
||||||
struct ObjectRepositoryItem;
|
struct ObjectRepositoryItem;
|
||||||
struct rct_drawpixelinfo;
|
struct rct_drawpixelinfo;
|
||||||
|
@ -119,6 +120,7 @@ interface IReadObjectContext
|
||||||
{
|
{
|
||||||
virtual ~IReadObjectContext() = default;
|
virtual ~IReadObjectContext() = default;
|
||||||
|
|
||||||
|
virtual IObjectRepository& GetObjectRepository() abstract;
|
||||||
virtual bool ShouldLoadImages() abstract;
|
virtual bool ShouldLoadImages() abstract;
|
||||||
|
|
||||||
virtual void LogWarning(uint32 code, const utf8 * text) abstract;
|
virtual void LogWarning(uint32 code, const utf8 * text) abstract;
|
||||||
|
@ -206,7 +208,6 @@ sint32 object_calculate_checksum(const rct_object_entry * entry, const void * da
|
||||||
bool find_object_in_entry_group(const rct_object_entry* entry, uint8* entry_type, uint8* entry_index);
|
bool find_object_in_entry_group(const rct_object_entry* entry, uint8* entry_type, uint8* entry_index);
|
||||||
void object_create_identifier_name(char* string_buffer, size_t size, const rct_object_entry* object);
|
void object_create_identifier_name(char* string_buffer, size_t size, const rct_object_entry* object);
|
||||||
|
|
||||||
const rct_object_entry * object_list_find_by_name(const char *name);
|
|
||||||
const rct_object_entry * object_list_find(rct_object_entry *entry);
|
const rct_object_entry * object_list_find(rct_object_entry *entry);
|
||||||
|
|
||||||
void object_entry_get_name_fixed(utf8 * buffer, size_t bufferSize, const rct_object_entry * entry);
|
void object_entry_get_name_fixed(utf8 * buffer, size_t bufferSize, const rct_object_entry * entry);
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
class ReadObjectContext : public IReadObjectContext
|
class ReadObjectContext : public IReadObjectContext
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
IObjectRepository& _objectRepository;
|
||||||
|
|
||||||
std::string _objectName;
|
std::string _objectName;
|
||||||
bool _loadImages;
|
bool _loadImages;
|
||||||
bool _wasWarning = false;
|
bool _wasWarning = false;
|
||||||
|
@ -50,12 +52,18 @@ public:
|
||||||
bool WasWarning() const { return _wasWarning; }
|
bool WasWarning() const { return _wasWarning; }
|
||||||
bool WasError() const { return _wasError; }
|
bool WasError() const { return _wasError; }
|
||||||
|
|
||||||
ReadObjectContext(const std::string &objectName, bool loadImages)
|
ReadObjectContext(IObjectRepository& objectRepository, const std::string &objectName, bool loadImages)
|
||||||
: _objectName(objectName),
|
: _objectRepository(objectRepository),
|
||||||
|
_objectName(objectName),
|
||||||
_loadImages(loadImages)
|
_loadImages(loadImages)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IObjectRepository& GetObjectRepository() override
|
||||||
|
{
|
||||||
|
return _objectRepository;
|
||||||
|
}
|
||||||
|
|
||||||
bool ShouldLoadImages() override
|
bool ShouldLoadImages() override
|
||||||
{
|
{
|
||||||
return _loadImages;
|
return _loadImages;
|
||||||
|
@ -101,9 +109,9 @@ namespace ObjectFactory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object * CreateObjectFromLegacyFile(const utf8 * path)
|
Object * CreateObjectFromLegacyFile(IObjectRepository& objectRepository, const utf8 * path)
|
||||||
{
|
{
|
||||||
log_verbose("CreateObjectFromLegacyFile(\"%s\")", path);
|
log_verbose("CreateObjectFromLegacyFile(..., \"%s\")", path);
|
||||||
|
|
||||||
Object * result = nullptr;
|
Object * result = nullptr;
|
||||||
try
|
try
|
||||||
|
@ -122,7 +130,7 @@ namespace ObjectFactory
|
||||||
log_verbose(" size: %zu", chunk->GetLength());
|
log_verbose(" size: %zu", chunk->GetLength());
|
||||||
|
|
||||||
auto chunkStream = MemoryStream(chunk->GetData(), chunk->GetLength());
|
auto chunkStream = MemoryStream(chunk->GetData(), chunk->GetLength());
|
||||||
auto readContext = ReadObjectContext(objectName, !gOpenRCT2Headless);
|
auto readContext = ReadObjectContext(objectRepository, objectName, !gOpenRCT2Headless);
|
||||||
ReadObjectLegacy(result, &readContext, &chunkStream);
|
ReadObjectLegacy(result, &readContext, &chunkStream);
|
||||||
if (readContext.WasError())
|
if (readContext.WasError())
|
||||||
{
|
{
|
||||||
|
@ -137,7 +145,7 @@ namespace ObjectFactory
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object * CreateObjectFromLegacyData(const rct_object_entry * entry, const void * data, size_t dataSize)
|
Object * CreateObjectFromLegacyData(IObjectRepository& objectRepository, const rct_object_entry * entry, const void * data, size_t dataSize)
|
||||||
{
|
{
|
||||||
Guard::ArgumentNotNull(entry, GUARD_LINE);
|
Guard::ArgumentNotNull(entry, GUARD_LINE);
|
||||||
Guard::ArgumentNotNull(data, GUARD_LINE);
|
Guard::ArgumentNotNull(data, GUARD_LINE);
|
||||||
|
@ -148,7 +156,7 @@ namespace ObjectFactory
|
||||||
utf8 objectName[DAT_NAME_LENGTH + 1];
|
utf8 objectName[DAT_NAME_LENGTH + 1];
|
||||||
object_entry_get_name_fixed(objectName, sizeof(objectName), entry);
|
object_entry_get_name_fixed(objectName, sizeof(objectName), entry);
|
||||||
|
|
||||||
auto readContext = ReadObjectContext(objectName, !gOpenRCT2Headless);
|
auto readContext = ReadObjectContext(objectRepository, objectName, !gOpenRCT2Headless);
|
||||||
auto chunkStream = MemoryStream(data, dataSize);
|
auto chunkStream = MemoryStream(data, dataSize);
|
||||||
ReadObjectLegacy(result, &readContext, &chunkStream);
|
ReadObjectLegacy(result, &readContext, &chunkStream);
|
||||||
|
|
||||||
|
@ -220,7 +228,7 @@ namespace ObjectFactory
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object * CreateObjectFromJsonFile(const std::string &path)
|
Object * CreateObjectFromJsonFile(IObjectRepository& objectRepository, const std::string &path)
|
||||||
{
|
{
|
||||||
log_verbose("CreateObjectFromJsonFile(\"%s\")", path.c_str());
|
log_verbose("CreateObjectFromJsonFile(\"%s\")", path.c_str());
|
||||||
|
|
||||||
|
@ -249,7 +257,7 @@ namespace ObjectFactory
|
||||||
memcpy(entry.name, originalName.c_str(), minLength);
|
memcpy(entry.name, originalName.c_str(), minLength);
|
||||||
|
|
||||||
result = CreateObject(entry);
|
result = CreateObject(entry);
|
||||||
auto readContext = ReadObjectContext(id, !gOpenRCT2Headless);
|
auto readContext = ReadObjectContext(objectRepository, id, !gOpenRCT2Headless);
|
||||||
result->ReadJson(&readContext, jRoot);
|
result->ReadJson(&readContext, jRoot);
|
||||||
if (readContext.WasError())
|
if (readContext.WasError())
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,14 +18,15 @@
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
|
interface IObjectRepository;
|
||||||
class Object;
|
class Object;
|
||||||
struct rct_object_entry;
|
struct rct_object_entry;
|
||||||
|
|
||||||
namespace ObjectFactory
|
namespace ObjectFactory
|
||||||
{
|
{
|
||||||
Object * CreateObjectFromLegacyFile(const utf8 * path);
|
Object * CreateObjectFromLegacyFile(IObjectRepository& objectRepository, const utf8 * path);
|
||||||
Object * CreateObjectFromLegacyData(const rct_object_entry * entry, const void * data, size_t dataSize);
|
Object * CreateObjectFromLegacyData(IObjectRepository& objectRepository, const rct_object_entry * entry, const void * data, size_t dataSize);
|
||||||
Object * CreateObject(const rct_object_entry &entry);
|
Object * CreateObject(const rct_object_entry &entry);
|
||||||
|
|
||||||
Object * CreateObjectFromJsonFile(const std::string &path);
|
Object * CreateObjectFromJsonFile(IObjectRepository& objectRepository, const std::string &path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ namespace ObjectJsonHelpers
|
||||||
{
|
{
|
||||||
std::vector<rct_g1_element> result;
|
std::vector<rct_g1_element> result;
|
||||||
auto objectPath = FindLegacyObject(name);
|
auto objectPath = FindLegacyObject(name);
|
||||||
auto obj = ObjectFactory::CreateObjectFromLegacyFile(objectPath.c_str());
|
auto obj = ObjectFactory::CreateObjectFromLegacyFile(context->GetObjectRepository(), objectPath.c_str());
|
||||||
if (obj != nullptr)
|
if (obj != nullptr)
|
||||||
{
|
{
|
||||||
auto &imgTable = static_cast<const Object *>(obj)->GetImageTable();
|
auto &imgTable = static_cast<const Object *>(obj)->GetImageTable();
|
||||||
|
|
|
@ -83,8 +83,10 @@ private:
|
||||||
static constexpr uint16 VERSION = 17;
|
static constexpr uint16 VERSION = 17;
|
||||||
static constexpr auto PATTERN = "*.dat;*.pob;*.json";
|
static constexpr auto PATTERN = "*.dat;*.pob;*.json";
|
||||||
|
|
||||||
|
IObjectRepository& _objectRepository;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ObjectFileIndex(IPlatformEnvironment * env) :
|
explicit ObjectFileIndex(IObjectRepository& objectRepository, IPlatformEnvironment * env) :
|
||||||
FileIndex("object index",
|
FileIndex("object index",
|
||||||
MAGIC_NUMBER,
|
MAGIC_NUMBER,
|
||||||
VERSION,
|
VERSION,
|
||||||
|
@ -92,7 +94,8 @@ public:
|
||||||
std::string(PATTERN),
|
std::string(PATTERN),
|
||||||
std::vector<std::string>({
|
std::vector<std::string>({
|
||||||
env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::OBJECT),
|
env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::OBJECT),
|
||||||
env->GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT) }))
|
env->GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT) })),
|
||||||
|
_objectRepository(objectRepository)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +105,7 @@ public:
|
||||||
auto extension = Path::GetExtension(path);
|
auto extension = Path::GetExtension(path);
|
||||||
if (String::Equals(extension, ".json", true))
|
if (String::Equals(extension, ".json", true))
|
||||||
{
|
{
|
||||||
auto object = ObjectFactory::CreateObjectFromJsonFile(path);
|
auto object = ObjectFactory::CreateObjectFromJsonFile(_objectRepository, path);
|
||||||
if (object != nullptr)
|
if (object != nullptr)
|
||||||
{
|
{
|
||||||
ObjectRepositoryItem item = { 0 };
|
ObjectRepositoryItem item = { 0 };
|
||||||
|
@ -116,7 +119,7 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto object = ObjectFactory::CreateObjectFromLegacyFile(path.c_str());
|
auto object = ObjectFactory::CreateObjectFromLegacyFile(_objectRepository, path.c_str());
|
||||||
if (object != nullptr)
|
if (object != nullptr)
|
||||||
{
|
{
|
||||||
ObjectRepositoryItem item = { 0 };
|
ObjectRepositoryItem item = { 0 };
|
||||||
|
@ -213,7 +216,7 @@ class ObjectRepository final : public IObjectRepository
|
||||||
public:
|
public:
|
||||||
explicit ObjectRepository(IPlatformEnvironment * env)
|
explicit ObjectRepository(IPlatformEnvironment * env)
|
||||||
: _env(env),
|
: _env(env),
|
||||||
_fileIndex(env)
|
_fileIndex(*this, env)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,11 +282,11 @@ public:
|
||||||
auto extension = Path::GetExtension(ori->Path);
|
auto extension = Path::GetExtension(ori->Path);
|
||||||
if (String::Equals(extension, ".json", true))
|
if (String::Equals(extension, ".json", true))
|
||||||
{
|
{
|
||||||
return ObjectFactory::CreateObjectFromJsonFile(ori->Path);
|
return ObjectFactory::CreateObjectFromJsonFile(*this, ori->Path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ObjectFactory::CreateObjectFromLegacyFile(ori->Path);
|
return ObjectFactory::CreateObjectFromLegacyFile(*this, ori->Path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +313,7 @@ public:
|
||||||
object_entry_get_name_fixed(objectName, sizeof(objectName), objectEntry);
|
object_entry_get_name_fixed(objectName, sizeof(objectName), objectEntry);
|
||||||
|
|
||||||
// Check that the object is loadable before writing it
|
// Check that the object is loadable before writing it
|
||||||
Object * object = ObjectFactory::CreateObjectFromLegacyData(objectEntry, data, dataSize);
|
Object * object = ObjectFactory::CreateObjectFromLegacyData(*this, objectEntry, data, dataSize);
|
||||||
if (object == nullptr)
|
if (object == nullptr)
|
||||||
{
|
{
|
||||||
Console::Error::WriteLine("[%s] Unable to export object.", objectName);
|
Console::Error::WriteLine("[%s] Unable to export object.", objectName);
|
||||||
|
@ -659,18 +662,6 @@ const rct_object_entry * object_list_find(rct_object_entry * entry)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rct_object_entry * object_list_find_by_name(const char * name)
|
|
||||||
{
|
|
||||||
const rct_object_entry * result = nullptr;
|
|
||||||
auto objRepo = GetContext()->GetObjectRepository();
|
|
||||||
auto item = objRepo->FindObject(name);
|
|
||||||
if (item != nullptr)
|
|
||||||
{
|
|
||||||
result = &item->ObjectEntry;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void object_list_load()
|
void object_list_load()
|
||||||
{
|
{
|
||||||
auto context = GetContext();
|
auto context = GetContext();
|
||||||
|
|
|
@ -551,10 +551,11 @@ private:
|
||||||
std::vector<const char *> objects = RCT1::GetSceneryObjects(sceneryTheme);
|
std::vector<const char *> objects = RCT1::GetSceneryObjects(sceneryTheme);
|
||||||
for (const char * objectName : objects)
|
for (const char * objectName : objects)
|
||||||
{
|
{
|
||||||
const rct_object_entry * foundEntry = object_list_find_by_name(objectName);
|
auto objectRepository = OpenRCT2::GetContext()->GetObjectRepository();
|
||||||
if (foundEntry != nullptr)
|
auto foundObject = objectRepository->FindObject(objectName);
|
||||||
|
if (foundObject != nullptr)
|
||||||
{
|
{
|
||||||
uint8 objectType = object_entry_get_type(foundEntry);
|
uint8 objectType = object_entry_get_type(&foundObject->ObjectEntry);
|
||||||
switch (objectType) {
|
switch (objectType) {
|
||||||
case OBJECT_TYPE_SMALL_SCENERY:
|
case OBJECT_TYPE_SMALL_SCENERY:
|
||||||
case OBJECT_TYPE_LARGE_SCENERY:
|
case OBJECT_TYPE_LARGE_SCENERY:
|
||||||
|
|
Loading…
Reference in New Issue