mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 03:23:15 +01:00
clang-format object
This commit is contained in:
committed by
Hielke Morsink
parent
e32189fd98
commit
a6a12af1ec
@@ -7,13 +7,12 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include "ObjectRepository.h"
|
||||
|
||||
#include "../common.h"
|
||||
#include "../Context.h"
|
||||
#include "../PlatformEnvironment.h"
|
||||
#include "../common.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/FileIndex.hpp"
|
||||
#include "../core/FileStream.hpp"
|
||||
@@ -23,31 +22,32 @@
|
||||
#include "../core/MemoryStream.h"
|
||||
#include "../core/Path.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../PlatformEnvironment.h"
|
||||
#include "../rct12/SawyerChunkReader.h"
|
||||
#include "../rct12/SawyerChunkWriter.h"
|
||||
#include "../scenario/ScenarioRepository.h"
|
||||
#include "Object.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "ObjectManager.h"
|
||||
#include "ObjectRepository.h"
|
||||
#include "RideObject.h"
|
||||
#include "StexObject.h"
|
||||
|
||||
#include "../config/Config.h"
|
||||
#include "../localisation/Localisation.h"
|
||||
#include "../localisation/LocalisationService.h"
|
||||
#include "../object/Object.h"
|
||||
#include "ObjectList.h"
|
||||
#include "../platform/platform.h"
|
||||
#include "../rct12/SawyerChunkReader.h"
|
||||
#include "../rct12/SawyerChunkWriter.h"
|
||||
#include "../scenario/ScenarioRepository.h"
|
||||
#include "../util/SawyerCoding.h"
|
||||
#include "../util/Util.h"
|
||||
#include "Object.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "ObjectList.h"
|
||||
#include "ObjectManager.h"
|
||||
#include "RideObject.h"
|
||||
#include "StexObject.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
struct ObjectEntryHash
|
||||
{
|
||||
size_t operator()(const rct_object_entry &entry) const
|
||||
size_t operator()(const rct_object_entry& entry) const
|
||||
{
|
||||
uint32_t hash = 5381;
|
||||
for (auto i : entry.name)
|
||||
@@ -60,7 +60,7 @@ struct ObjectEntryHash
|
||||
|
||||
struct ObjectEntryEqual
|
||||
{
|
||||
bool operator()(const rct_object_entry &lhs, const rct_object_entry &rhs) const
|
||||
bool operator()(const rct_object_entry& lhs, const rct_object_entry& rhs) const
|
||||
{
|
||||
return memcmp(&lhs.name, &rhs.name, 8) == 0;
|
||||
}
|
||||
@@ -78,23 +78,23 @@ private:
|
||||
IObjectRepository& _objectRepository;
|
||||
|
||||
public:
|
||||
explicit ObjectFileIndex(IObjectRepository& objectRepository, const IPlatformEnvironment& env) :
|
||||
FileIndex("object index",
|
||||
MAGIC_NUMBER,
|
||||
VERSION,
|
||||
env.GetFilePath(PATHID::CACHE_OBJECTS),
|
||||
std::string(PATTERN),
|
||||
std::vector<std::string>({
|
||||
env.GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::OBJECT),
|
||||
env.GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT) })),
|
||||
_objectRepository(objectRepository)
|
||||
explicit ObjectFileIndex(IObjectRepository& objectRepository, const IPlatformEnvironment& env)
|
||||
: FileIndex(
|
||||
"object index",
|
||||
MAGIC_NUMBER,
|
||||
VERSION,
|
||||
env.GetFilePath(PATHID::CACHE_OBJECTS),
|
||||
std::string(PATTERN),
|
||||
std::vector<std::string>({ env.GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::OBJECT),
|
||||
env.GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT) }))
|
||||
, _objectRepository(objectRepository)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
std::tuple<bool, ObjectRepositoryItem> Create([[maybe_unused]] int32_t language, const std::string& path) const override
|
||||
{
|
||||
Object * object = nullptr;
|
||||
Object* object = nullptr;
|
||||
auto extension = Path::GetExtension(path);
|
||||
if (String::Equals(extension, ".json", true))
|
||||
{
|
||||
@@ -122,36 +122,37 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void Serialise(IStream * stream, const ObjectRepositoryItem &item) const override
|
||||
void Serialise(IStream* stream, const ObjectRepositoryItem& item) const override
|
||||
{
|
||||
stream->WriteValue(item.ObjectEntry);
|
||||
stream->WriteString(item.Path);
|
||||
stream->WriteString(item.Name);
|
||||
|
||||
switch (object_entry_get_type(&item.ObjectEntry)) {
|
||||
case OBJECT_TYPE_RIDE:
|
||||
stream->WriteValue<uint8_t>(item.RideInfo.RideFlags);
|
||||
for (int32_t i = 0; i < MAX_CATEGORIES_PER_RIDE; i++)
|
||||
{
|
||||
stream->WriteValue<uint8_t>(item.RideInfo.RideCategory[i]);
|
||||
}
|
||||
for (int32_t i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
|
||||
{
|
||||
stream->WriteValue<uint8_t>(item.RideInfo.RideType[i]);
|
||||
}
|
||||
stream->WriteValue<uint8_t>(item.RideInfo.RideGroupIndex);
|
||||
break;
|
||||
case OBJECT_TYPE_SCENERY_GROUP:
|
||||
stream->WriteValue<uint16_t>((uint16_t)item.SceneryGroupInfo.Entries.size());
|
||||
for (const auto& entry : item.SceneryGroupInfo.Entries)
|
||||
{
|
||||
stream->WriteValue<rct_object_entry>(entry);
|
||||
}
|
||||
break;
|
||||
switch (object_entry_get_type(&item.ObjectEntry))
|
||||
{
|
||||
case OBJECT_TYPE_RIDE:
|
||||
stream->WriteValue<uint8_t>(item.RideInfo.RideFlags);
|
||||
for (int32_t i = 0; i < MAX_CATEGORIES_PER_RIDE; i++)
|
||||
{
|
||||
stream->WriteValue<uint8_t>(item.RideInfo.RideCategory[i]);
|
||||
}
|
||||
for (int32_t i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
|
||||
{
|
||||
stream->WriteValue<uint8_t>(item.RideInfo.RideType[i]);
|
||||
}
|
||||
stream->WriteValue<uint8_t>(item.RideInfo.RideGroupIndex);
|
||||
break;
|
||||
case OBJECT_TYPE_SCENERY_GROUP:
|
||||
stream->WriteValue<uint16_t>((uint16_t)item.SceneryGroupInfo.Entries.size());
|
||||
for (const auto& entry : item.SceneryGroupInfo.Entries)
|
||||
{
|
||||
stream->WriteValue<rct_object_entry>(entry);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ObjectRepositoryItem Deserialise(IStream * stream) const override
|
||||
ObjectRepositoryItem Deserialise(IStream* stream) const override
|
||||
{
|
||||
ObjectRepositoryItem item;
|
||||
|
||||
@@ -159,20 +160,21 @@ protected:
|
||||
item.Path = stream->ReadStdString();
|
||||
item.Name = stream->ReadStdString();
|
||||
|
||||
switch (object_entry_get_type(&item.ObjectEntry)) {
|
||||
case OBJECT_TYPE_RIDE:
|
||||
item.RideInfo.RideFlags = stream->ReadValue<uint8_t>();
|
||||
for (int32_t i = 0; i < MAX_CATEGORIES_PER_RIDE; i++)
|
||||
{
|
||||
item.RideInfo.RideCategory[i] = stream->ReadValue<uint8_t>();
|
||||
}
|
||||
for (int32_t i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
|
||||
{
|
||||
item.RideInfo.RideType[i] = stream->ReadValue<uint8_t>();
|
||||
}
|
||||
item.RideInfo.RideGroupIndex = stream->ReadValue<uint8_t>();
|
||||
break;
|
||||
case OBJECT_TYPE_SCENERY_GROUP:
|
||||
switch (object_entry_get_type(&item.ObjectEntry))
|
||||
{
|
||||
case OBJECT_TYPE_RIDE:
|
||||
item.RideInfo.RideFlags = stream->ReadValue<uint8_t>();
|
||||
for (int32_t i = 0; i < MAX_CATEGORIES_PER_RIDE; i++)
|
||||
{
|
||||
item.RideInfo.RideCategory[i] = stream->ReadValue<uint8_t>();
|
||||
}
|
||||
for (int32_t i = 0; i < MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
|
||||
{
|
||||
item.RideInfo.RideType[i] = stream->ReadValue<uint8_t>();
|
||||
}
|
||||
item.RideInfo.RideGroupIndex = stream->ReadValue<uint8_t>();
|
||||
break;
|
||||
case OBJECT_TYPE_SCENERY_GROUP:
|
||||
{
|
||||
auto numEntries = stream->ReadValue<uint16_t>();
|
||||
item.SceneryGroupInfo.Entries = std::vector<rct_object_entry>(numEntries);
|
||||
@@ -187,11 +189,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
bool IsTrackReadOnly(const std::string &path) const
|
||||
bool IsTrackReadOnly(const std::string& path) const
|
||||
{
|
||||
return
|
||||
String::StartsWith(path, SearchPaths[0]) ||
|
||||
String::StartsWith(path, SearchPaths[1]);
|
||||
return String::StartsWith(path, SearchPaths[0]) || String::StartsWith(path, SearchPaths[1]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -204,8 +204,8 @@ class ObjectRepository final : public IObjectRepository
|
||||
|
||||
public:
|
||||
explicit ObjectRepository(const std::shared_ptr<IPlatformEnvironment>& env)
|
||||
: _env(env),
|
||||
_fileIndex(*this, *env)
|
||||
: _env(env)
|
||||
, _fileIndex(*this, *env)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -234,12 +234,12 @@ public:
|
||||
return _items.size();
|
||||
}
|
||||
|
||||
const ObjectRepositoryItem * GetObjects() const override
|
||||
const ObjectRepositoryItem* GetObjects() const override
|
||||
{
|
||||
return _items.data();
|
||||
}
|
||||
|
||||
const ObjectRepositoryItem * FindObject(const utf8 * name) const override
|
||||
const ObjectRepositoryItem* FindObject(const utf8* name) const override
|
||||
{
|
||||
rct_object_entry entry = {};
|
||||
utf8 entryName[9] = { ' ' };
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const ObjectRepositoryItem * FindObject(const rct_object_entry * objectEntry) const override final
|
||||
const ObjectRepositoryItem* FindObject(const rct_object_entry* objectEntry) const override final
|
||||
{
|
||||
auto kvp = _itemMap.find(*objectEntry);
|
||||
if (kvp != _itemMap.end())
|
||||
@@ -264,7 +264,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Object * LoadObject(const ObjectRepositoryItem * ori) override
|
||||
Object* LoadObject(const ObjectRepositoryItem* ori) override
|
||||
{
|
||||
Guard::ArgumentNotNull(ori, GUARD_LINE);
|
||||
|
||||
@@ -283,30 +283,30 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterLoadedObject(const ObjectRepositoryItem * ori, Object * object) override
|
||||
void RegisterLoadedObject(const ObjectRepositoryItem* ori, Object* object) override
|
||||
{
|
||||
ObjectRepositoryItem * item = &_items[ori->Id];
|
||||
ObjectRepositoryItem* item = &_items[ori->Id];
|
||||
|
||||
Guard::Assert(item->LoadedObject == nullptr, GUARD_LINE);
|
||||
item->LoadedObject = object;
|
||||
}
|
||||
|
||||
void UnregisterLoadedObject(const ObjectRepositoryItem * ori, Object * object) override
|
||||
void UnregisterLoadedObject(const ObjectRepositoryItem* ori, Object* object) override
|
||||
{
|
||||
ObjectRepositoryItem * item = &_items[ori->Id];
|
||||
ObjectRepositoryItem* item = &_items[ori->Id];
|
||||
if (item->LoadedObject == object)
|
||||
{
|
||||
item->LoadedObject = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void AddObject(const rct_object_entry * objectEntry, const void * data, size_t dataSize) override
|
||||
void AddObject(const rct_object_entry* objectEntry, const void* data, size_t dataSize) override
|
||||
{
|
||||
utf8 objectName[9];
|
||||
object_entry_get_name_fixed(objectName, sizeof(objectName), objectEntry);
|
||||
|
||||
// Check that the object is loadable before writing it
|
||||
Object * object = ObjectFactory::CreateObjectFromLegacyData(*this, objectEntry, data, dataSize);
|
||||
Object* object = ObjectFactory::CreateObjectFromLegacyData(*this, objectEntry, data, dataSize);
|
||||
if (object == nullptr)
|
||||
{
|
||||
Console::Error::WriteLine("[%s] Unable to export object.", objectName);
|
||||
@@ -322,14 +322,14 @@ public:
|
||||
SaveObject(path, objectEntry, data, dataSize);
|
||||
ScanObject(path);
|
||||
}
|
||||
catch (const std::exception &)
|
||||
catch (const std::exception&)
|
||||
{
|
||||
Console::Error::WriteLine("Failed saving object: [%s] to '%s'.", objectName, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExportPackedObject(IStream * stream) override
|
||||
void ExportPackedObject(IStream* stream) override
|
||||
{
|
||||
auto chunkReader = SawyerChunkReader(stream);
|
||||
|
||||
@@ -347,10 +347,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void WritePackedObjects(IStream * stream, std::vector<const ObjectRepositoryItem *> &objects) override
|
||||
void WritePackedObjects(IStream* stream, std::vector<const ObjectRepositoryItem*>& objects) override
|
||||
{
|
||||
log_verbose("packing %u objects", objects.size());
|
||||
for (const auto &object : objects)
|
||||
for (const auto& object : objects)
|
||||
{
|
||||
Guard::ArgumentNotNull(object);
|
||||
|
||||
@@ -375,9 +375,7 @@ private:
|
||||
|
||||
void SortItems()
|
||||
{
|
||||
std::sort(_items.begin(), _items.end(), [](const ObjectRepositoryItem &a,
|
||||
const ObjectRepositoryItem &b) -> bool
|
||||
{
|
||||
std::sort(_items.begin(), _items.end(), [](const ObjectRepositoryItem& a, const ObjectRepositoryItem& b) -> bool {
|
||||
return String::Compare(a.Name, b.Name) < 0;
|
||||
});
|
||||
|
||||
@@ -396,7 +394,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void AddItems(const std::vector<ObjectRepositoryItem> &items)
|
||||
void AddItems(const std::vector<ObjectRepositoryItem>& items)
|
||||
{
|
||||
size_t numConflicts = 0;
|
||||
for (auto item : items)
|
||||
@@ -412,7 +410,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
bool AddItem(const ObjectRepositoryItem &item)
|
||||
bool AddItem(const ObjectRepositoryItem& item)
|
||||
{
|
||||
auto conflict = FindObject(&item.ObjectEntry);
|
||||
if (conflict == nullptr)
|
||||
@@ -432,7 +430,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void ScanObject(const std::string &path)
|
||||
void ScanObject(const std::string& path)
|
||||
{
|
||||
auto language = LocalisationService_GetCurrentLanguage();
|
||||
auto result = _fileIndex.Create(language, path);
|
||||
@@ -443,10 +441,8 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static void SaveObject(const utf8 * path,
|
||||
const rct_object_entry * entry,
|
||||
const void * data, size_t dataSize,
|
||||
bool fixChecksum = true)
|
||||
static void
|
||||
SaveObject(const utf8* path, const rct_object_entry* entry, const void* data, size_t dataSize, bool fixChecksum = true)
|
||||
{
|
||||
if (fixChecksum)
|
||||
{
|
||||
@@ -460,14 +456,14 @@ private:
|
||||
// Calculate the value of extra bytes that can be appended to the data so that the
|
||||
// data is then valid for the object's checksum
|
||||
size_t extraBytesCount = 0;
|
||||
void * extraBytes = CalculateExtraBytesToFixChecksum(realChecksum, entry->checksum, &extraBytesCount);
|
||||
void* extraBytes = CalculateExtraBytesToFixChecksum(realChecksum, entry->checksum, &extraBytesCount);
|
||||
|
||||
// Create new data blob with appended bytes
|
||||
size_t newDataSize = dataSize + extraBytesCount;
|
||||
uint8_t * newData = Memory::Allocate<uint8_t>(newDataSize);
|
||||
uint8_t * newDataSaltOffset = newData + dataSize;
|
||||
std::copy_n((const uint8_t *)data, dataSize, newData);
|
||||
std::copy_n((const uint8_t *)extraBytes, extraBytesCount, newDataSaltOffset);
|
||||
uint8_t* newData = Memory::Allocate<uint8_t>(newDataSize);
|
||||
uint8_t* newDataSaltOffset = newData + dataSize;
|
||||
std::copy_n((const uint8_t*)data, dataSize, newData);
|
||||
std::copy_n((const uint8_t*)extraBytes, extraBytesCount, newDataSaltOffset);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -487,7 +483,7 @@ private:
|
||||
Memory::Free(newData);
|
||||
Memory::Free(extraBytes);
|
||||
}
|
||||
catch (const std::exception &)
|
||||
catch (const std::exception&)
|
||||
{
|
||||
Memory::Free(newData);
|
||||
Memory::Free(extraBytes);
|
||||
@@ -502,8 +498,8 @@ private:
|
||||
sawyercoding_chunk_header chunkHeader;
|
||||
chunkHeader.encoding = object_entry_group_encoding[objectType];
|
||||
chunkHeader.length = (uint32_t)dataSize;
|
||||
uint8_t * encodedDataBuffer = Memory::Allocate<uint8_t>(0x600000);
|
||||
size_t encodedDataSize = sawyercoding_write_chunk_buffer(encodedDataBuffer, (uint8_t *)data, chunkHeader);
|
||||
uint8_t* encodedDataBuffer = Memory::Allocate<uint8_t>(0x600000);
|
||||
size_t encodedDataSize = sawyercoding_write_chunk_buffer(encodedDataBuffer, (uint8_t*)data, chunkHeader);
|
||||
|
||||
// Save to file
|
||||
try
|
||||
@@ -514,18 +510,19 @@ private:
|
||||
|
||||
Memory::Free(encodedDataBuffer);
|
||||
}
|
||||
catch (const std::exception &)
|
||||
catch (const std::exception&)
|
||||
{
|
||||
Memory::Free(encodedDataBuffer);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
static void * CalculateExtraBytesToFixChecksum(int32_t currentChecksum, int32_t targetChecksum, size_t * outSize)
|
||||
static void* CalculateExtraBytesToFixChecksum(int32_t currentChecksum, int32_t targetChecksum, size_t* outSize)
|
||||
{
|
||||
// Allocate 11 extra bytes to manipulate the checksum
|
||||
uint8_t * salt = Memory::Allocate<uint8_t>(11);
|
||||
if (outSize != nullptr) *outSize = 11;
|
||||
uint8_t* salt = Memory::Allocate<uint8_t>(11);
|
||||
if (outSize != nullptr)
|
||||
*outSize = 11;
|
||||
|
||||
// Next work out which bits need to be flipped to make the current checksum match the one in the file
|
||||
// The bitwise rotation compensates for the rotation performed during the checksum calculation*/
|
||||
@@ -550,7 +547,7 @@ private:
|
||||
return salt;
|
||||
}
|
||||
|
||||
void GetPathForNewObject(utf8 * buffer, size_t bufferSize, const char * name)
|
||||
void GetPathForNewObject(utf8* buffer, size_t bufferSize, const char* name)
|
||||
{
|
||||
char normalisedName[9] = { 0 };
|
||||
for (int32_t i = 0; i < 8; i++)
|
||||
@@ -565,7 +562,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &userObjPath = _env->GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT);
|
||||
const std::string& userObjPath = _env->GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT);
|
||||
String::Set(buffer, bufferSize, userObjPath.c_str());
|
||||
platform_ensure_directory_exists(buffer);
|
||||
|
||||
@@ -586,9 +583,9 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void WritePackedObject(IStream * stream, const rct_object_entry * entry)
|
||||
void WritePackedObject(IStream* stream, const rct_object_entry* entry)
|
||||
{
|
||||
const ObjectRepositoryItem * item = FindObject(entry);
|
||||
const ObjectRepositoryItem* item = FindObject(entry);
|
||||
if (item == nullptr)
|
||||
{
|
||||
throw std::runtime_error(String::StdFormat("Unable to find object '%.8s'", entry->name));
|
||||
@@ -616,7 +613,7 @@ std::unique_ptr<IObjectRepository> CreateObjectRepository(const std::shared_ptr<
|
||||
return std::make_unique<ObjectRepository>(env);
|
||||
}
|
||||
|
||||
bool IsObjectCustom(const ObjectRepositoryItem * object)
|
||||
bool IsObjectCustom(const ObjectRepositoryItem* object)
|
||||
{
|
||||
Guard::ArgumentNotNull(object);
|
||||
|
||||
@@ -624,9 +621,9 @@ bool IsObjectCustom(const ObjectRepositoryItem * object)
|
||||
return !(object->ObjectEntry.flags & 0xF0);
|
||||
}
|
||||
|
||||
const rct_object_entry * object_list_find(rct_object_entry * entry)
|
||||
const rct_object_entry* object_list_find(rct_object_entry* entry)
|
||||
{
|
||||
const rct_object_entry * result = nullptr;
|
||||
const rct_object_entry* result = nullptr;
|
||||
auto objRepo = GetContext()->GetObjectRepository();
|
||||
auto item = objRepo->FindObject(entry);
|
||||
if (item != nullptr)
|
||||
@@ -647,11 +644,11 @@ void object_list_load()
|
||||
objectManager->UnloadAll();
|
||||
}
|
||||
|
||||
void * object_repository_load_object(const rct_object_entry * objectEntry)
|
||||
void* object_repository_load_object(const rct_object_entry* objectEntry)
|
||||
{
|
||||
Object * object = nullptr;
|
||||
Object* object = nullptr;
|
||||
auto objRepository = GetContext()->GetObjectRepository();
|
||||
const ObjectRepositoryItem * ori = objRepository->FindObject(objectEntry);
|
||||
const ObjectRepositoryItem* ori = objRepository->FindObject(objectEntry);
|
||||
if (ori != nullptr)
|
||||
{
|
||||
object = objRepository->LoadObject(ori);
|
||||
@@ -660,10 +657,10 @@ void * object_repository_load_object(const rct_object_entry * objectEntry)
|
||||
object->Load();
|
||||
}
|
||||
}
|
||||
return (void *)object;
|
||||
return (void*)object;
|
||||
}
|
||||
|
||||
void scenario_translate(scenario_index_entry * scenarioEntry, const rct_object_entry * stexObjectEntry)
|
||||
void scenario_translate(scenario_index_entry* scenarioEntry, const rct_object_entry* stexObjectEntry)
|
||||
{
|
||||
rct_string_id localisedStringIds[3];
|
||||
if (language_get_localised_scenario_strings(scenarioEntry->name, localisedStringIds))
|
||||
@@ -683,10 +680,10 @@ void scenario_translate(scenario_index_entry * scenarioEntry, const rct_object_e
|
||||
if ((stexObjectEntry->flags & 0xFF) != 255)
|
||||
{
|
||||
auto objectRepository = GetContext()->GetObjectRepository();
|
||||
const ObjectRepositoryItem * ori = objectRepository->FindObject(stexObjectEntry);
|
||||
const ObjectRepositoryItem* ori = objectRepository->FindObject(stexObjectEntry);
|
||||
if (ori != nullptr)
|
||||
{
|
||||
Object * object = objectRepository->LoadObject(ori);
|
||||
Object* object = objectRepository->LoadObject(ori);
|
||||
if (object != nullptr)
|
||||
{
|
||||
auto stexObject = static_cast<StexObject*>(object);
|
||||
@@ -709,41 +706,41 @@ size_t object_repository_get_items_count()
|
||||
return objectRepository->GetNumObjects();
|
||||
}
|
||||
|
||||
const ObjectRepositoryItem * object_repository_get_items()
|
||||
const ObjectRepositoryItem* object_repository_get_items()
|
||||
{
|
||||
auto objectRepository = GetContext()->GetObjectRepository();
|
||||
return objectRepository->GetObjects();
|
||||
}
|
||||
|
||||
const ObjectRepositoryItem * object_repository_find_object_by_entry(const rct_object_entry * entry)
|
||||
const ObjectRepositoryItem* object_repository_find_object_by_entry(const rct_object_entry* entry)
|
||||
{
|
||||
auto objectRepository = GetContext()->GetObjectRepository();
|
||||
return objectRepository->FindObject(entry);
|
||||
}
|
||||
|
||||
const ObjectRepositoryItem * object_repository_find_object_by_name(const char * name)
|
||||
const ObjectRepositoryItem* object_repository_find_object_by_name(const char* name)
|
||||
{
|
||||
auto objectRepository = GetContext()->GetObjectRepository();
|
||||
return objectRepository->FindObject(name);
|
||||
}
|
||||
|
||||
void object_delete(void * object)
|
||||
void object_delete(void* object)
|
||||
{
|
||||
if (object != nullptr)
|
||||
{
|
||||
Object * baseObject = static_cast<Object *>(object);
|
||||
Object* baseObject = static_cast<Object*>(object);
|
||||
baseObject->Unload();
|
||||
delete baseObject;
|
||||
}
|
||||
}
|
||||
|
||||
void object_draw_preview(const void * object, rct_drawpixelinfo * dpi, int32_t width, int32_t height)
|
||||
void object_draw_preview(const void* object, rct_drawpixelinfo* dpi, int32_t width, int32_t height)
|
||||
{
|
||||
const Object * baseObject = static_cast<const Object *>(object);
|
||||
const Object* baseObject = static_cast<const Object*>(object);
|
||||
baseObject->DrawPreview(dpi, width, height);
|
||||
}
|
||||
|
||||
bool object_entry_compare(const rct_object_entry * a, const rct_object_entry * b)
|
||||
bool object_entry_compare(const rct_object_entry* a, const rct_object_entry* b)
|
||||
{
|
||||
// If an official object don't bother checking checksum
|
||||
if ((a->flags & 0xF0) || (b->flags & 0xF0))
|
||||
@@ -777,9 +774,9 @@ bool object_entry_compare(const rct_object_entry * a, const rct_object_entry * b
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t object_calculate_checksum(const rct_object_entry * entry, const void * data, size_t dataLength)
|
||||
int32_t object_calculate_checksum(const rct_object_entry* entry, const void* data, size_t dataLength)
|
||||
{
|
||||
const uint8_t * entryBytePtr = (uint8_t *)entry;
|
||||
const uint8_t* entryBytePtr = (uint8_t*)entry;
|
||||
|
||||
uint32_t checksum = 0xF369A75B;
|
||||
checksum ^= entryBytePtr[0];
|
||||
@@ -790,7 +787,7 @@ int32_t object_calculate_checksum(const rct_object_entry * entry, const void * d
|
||||
checksum = rol32(checksum, 11);
|
||||
}
|
||||
|
||||
uint8_t * dataBytes = (uint8_t *)data;
|
||||
uint8_t* dataBytes = (uint8_t*)data;
|
||||
const size_t dataLength32 = dataLength - (dataLength & 31);
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user