diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index 31ce21f331..9fbcfcdd4f 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -184,7 +184,7 @@ namespace OpenRCT2::Ui::Windows auto dataLen = response.body.size(); auto& objRepo = GetContext()->GetObjectRepository(); - objRepo.AddObjectFromFile(ObjectGeneration::DAT, name, data, dataLen); + objRepo.AddObjectFromFile(ObjectGeneration::dat, name, data, dataLen); std::lock_guard guard(_downloadedEntriesMutex); _downloadedEntries.push_back(entry); @@ -548,7 +548,7 @@ namespace OpenRCT2::Ui::Windows drawText(rt, screenCoords, entry.GetName(), { Colour::darkGreen }); - if (entry.Generation == ObjectGeneration::DAT) + if (entry.Generation == ObjectGeneration::dat) { // ... source game ... const auto sourceStringId = ObjectManagerGetSourceGameString(entry.Entry.GetSourceGame()); diff --git a/src/openrct2/command_line/ParkInfoCommands.cpp b/src/openrct2/command_line/ParkInfoCommands.cpp index 9585e6d43b..db3a8fed58 100644 --- a/src/openrct2/command_line/ParkInfoCommands.cpp +++ b/src/openrct2/command_line/ParkInfoCommands.cpp @@ -126,7 +126,7 @@ namespace OpenRCT2 Console::WriteLine("ObjectType: %s, Number of Objects: %d", typeToName[EnumValue(objType)], list.size()); for (auto& obj : list) { - if (obj.Generation == ObjectGeneration::JSON && obj.Identifier.empty()) + if (obj.Generation == ObjectGeneration::json && obj.Identifier.empty()) { // Empty object slot don't output anything continue; @@ -135,7 +135,7 @@ namespace OpenRCT2 Console::WriteFormat("%s Object: ", sourceGameToName[EnumValue(ori->GetFirstSourceGame())]); std::string name{ obj.GetName() }; - if (obj.Generation == ObjectGeneration::DAT) + if (obj.Generation == ObjectGeneration::dat) { Console::WriteLine("%08X|%s|%08X", obj.Entry.flags, name.c_str(), obj.Entry.checksum); } diff --git a/src/openrct2/core/DataSerialiserTraits.h b/src/openrct2/core/DataSerialiserTraits.h index 2acf2c35cd..231716de06 100644 --- a/src/openrct2/core/DataSerialiserTraits.h +++ b/src/openrct2/core/DataSerialiserTraits.h @@ -640,7 +640,7 @@ namespace OpenRCT2 static void encode(IStream* stream, const ObjectEntryDescriptor& val) { stream->WriteValue(static_cast(val.Generation)); - if (val.Generation == ObjectGeneration::DAT) + if (val.Generation == ObjectGeneration::dat) { DataSerializerTraits s; s.encode(stream, val.Entry); @@ -655,7 +655,7 @@ namespace OpenRCT2 static void decode(IStream* stream, ObjectEntryDescriptor& val) { auto generation = static_cast(stream->ReadValue()); - if (generation == ObjectGeneration::DAT) + if (generation == ObjectGeneration::dat) { DataSerializerTraits s; RCTObjectEntry entry; diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 0464865886..91087818f8 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -1321,7 +1321,7 @@ namespace OpenRCT2::Network { std::string name(object.GetName()); LOG_VERBOSE("client requests object %s", name.c_str()); - if (object.Generation == ObjectGeneration::DAT) + if (object.Generation == ObjectGeneration::dat) { packet << static_cast(0); packet.write(&object.Entry, sizeof(RCTObjectEntry)); @@ -2633,7 +2633,7 @@ namespace OpenRCT2::Network std::string objectName; const ObjectRepositoryItem* item{}; - if (generation == static_cast(ObjectGeneration::DAT)) + if (generation == static_cast(ObjectGeneration::dat)) { const auto* entry = reinterpret_cast(packet.read(sizeof(RCTObjectEntry))); if (entry == nullptr) diff --git a/src/openrct2/object/Object.cpp b/src/openrct2/object/Object.cpp index fc65933f4c..821eb7afa1 100644 --- a/src/openrct2/object/Object.cpp +++ b/src/openrct2/object/Object.cpp @@ -35,20 +35,20 @@ namespace OpenRCT2 { if (!newEntry.IsEmpty()) { - Generation = ObjectGeneration::DAT; + Generation = ObjectGeneration::dat; Entry = newEntry; } } ObjectEntryDescriptor::ObjectEntryDescriptor(std::string_view newIdentifier) { - Generation = ObjectGeneration::JSON; + Generation = ObjectGeneration::json; Identifier = std::string(newIdentifier); } ObjectEntryDescriptor::ObjectEntryDescriptor(ObjectType type, std::string_view newIdentifier) { - Generation = ObjectGeneration::JSON; + Generation = ObjectGeneration::json; Identifier = std::string(newIdentifier); Type = type; } @@ -57,34 +57,34 @@ namespace OpenRCT2 { if (!ori.Identifier.empty()) { - Generation = ObjectGeneration::JSON; + Generation = ObjectGeneration::json; Identifier = std::string(ori.Identifier); } else { - Generation = ObjectGeneration::DAT; + Generation = ObjectGeneration::dat; Entry = ori.ObjectEntry; } } bool ObjectEntryDescriptor::HasValue() const { - return Generation != ObjectGeneration::JSON || !Identifier.empty(); + return Generation != ObjectGeneration::json || !Identifier.empty(); } ObjectType ObjectEntryDescriptor::GetType() const { - return Generation == ObjectGeneration::JSON ? Type : Entry.GetType(); + return Generation == ObjectGeneration::json ? Type : Entry.GetType(); } std::string_view ObjectEntryDescriptor::GetName() const { - return Generation == ObjectGeneration::JSON ? Identifier : Entry.GetName(); + return Generation == ObjectGeneration::json ? Identifier : Entry.GetName(); } std::string ObjectEntryDescriptor::ToString() const { - if (Generation == ObjectGeneration::DAT) + if (Generation == ObjectGeneration::dat) { char buffer[32]; std::snprintf(&buffer[0], 9, "%08X", Entry.flags); @@ -127,7 +127,7 @@ namespace OpenRCT2 { if (Generation != rhs.Generation) return false; - if (Generation == ObjectGeneration::DAT) + if (Generation == ObjectGeneration::dat) { return Entry == rhs.Entry; } diff --git a/src/openrct2/object/Object.h b/src/openrct2/object/Object.h index 0f68677d31..9027db0e27 100644 --- a/src/openrct2/object/Object.h +++ b/src/openrct2/object/Object.h @@ -99,13 +99,13 @@ namespace OpenRCT2 enum class ObjectGeneration : uint8_t { - DAT, - JSON, + dat, + json, }; struct ObjectEntryDescriptor { - ObjectGeneration Generation = ObjectGeneration::JSON; + ObjectGeneration Generation = ObjectGeneration::json; // DAT RCTObjectEntry Entry{}; @@ -214,7 +214,7 @@ namespace OpenRCT2 void MarkAsJsonObject() { - _generation = ObjectGeneration::JSON; + _generation = ObjectGeneration::json; } ObjectGeneration GetGeneration() const diff --git a/src/openrct2/object/ObjectList.cpp b/src/openrct2/object/ObjectList.cpp index 884164f6e7..11cd1cff0e 100644 --- a/src/openrct2/object/ObjectList.cpp +++ b/src/openrct2/object/ObjectList.cpp @@ -177,7 +177,7 @@ namespace OpenRCT2 auto& subList = GetList(type); for (size_t i = 0; i < subList.size(); i++) { - if (subList[i].Generation == ObjectGeneration::JSON && subList[i].Identifier == identifier) + if (subList[i].Generation == ObjectGeneration::json && subList[i].Identifier == identifier) { return static_cast(i); } @@ -191,7 +191,7 @@ namespace OpenRCT2 auto& subList = GetList(type); for (size_t i = 0; i < subList.size(); i++) { - if (subList[i].Generation == ObjectGeneration::DAT && subList[i].Entry.GetName() == identifier + if (subList[i].Generation == ObjectGeneration::dat && subList[i].Entry.GetName() == identifier && subList[i].Entry.GetSourceGame() != ObjectSourceGame::custom) { return static_cast(i); diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index 2ba8bbe57d..5cc5b4c3f5 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -91,7 +91,7 @@ namespace OpenRCT2 // All official DAT files have a JSON object counterpart. Avoid loading the obsolete .DAT versions, // which can happen if the user copies the official DAT objects to their custom content folder. if (object == nullptr - || (object->GetGeneration() == ObjectGeneration::DAT + || (object->GetGeneration() == ObjectGeneration::dat && object->GetObjectEntry().GetSourceGame() != ObjectSourceGame::custom)) { return std::nullopt; @@ -237,7 +237,7 @@ namespace OpenRCT2 const ObjectRepositoryItem* FindObject(const ObjectEntryDescriptor& entry) const override final { - if (entry.Generation == ObjectGeneration::DAT) + if (entry.Generation == ObjectGeneration::dat) return FindObject(&entry.Entry); return FindObject(entry.Identifier); @@ -304,7 +304,7 @@ namespace OpenRCT2 { LOG_VERBOSE("Adding object: [%s]", std::string(objectName).c_str()); u8string path; - if (generation == ObjectGeneration::JSON) + if (generation == ObjectGeneration::json) { path = GetPathForNewObject(objectName); } @@ -427,7 +427,7 @@ namespace OpenRCT2 return true; } // When there is a conflict between a DAT file and a JSON file, the JSON should take precedence. - else if (item.Generation == ObjectGeneration::JSON && conflict->Generation == ObjectGeneration::DAT) + else if (item.Generation == ObjectGeneration::json && conflict->Generation == ObjectGeneration::dat) { const auto id = conflict->Id; const auto oldPath = conflict->Path; diff --git a/src/openrct2/park/Legacy.cpp b/src/openrct2/park/Legacy.cpp index 4dbee3855d..c9a17923c1 100644 --- a/src/openrct2/park/Legacy.cpp +++ b/src/openrct2/park/Legacy.cpp @@ -2230,7 +2230,7 @@ const RCT2::FootpathMapping* GetFootpathMapping(const ObjectEntryDescriptor& des // GetFootpathSurfaceId expects an old-style DAT identifier. In early versions of the NSF, // we used JSON ids for legacy paths, so we have to map those to old DAT identifiers first. - if (desc.Generation == ObjectGeneration::JSON) + if (desc.Generation == ObjectGeneration::json) { auto datPathName = GetDATPathName(desc.Identifier); if (datPathName.has_value()) diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index 64caa1e14e..c6ca3003de 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -462,7 +462,7 @@ namespace OpenRCT2 { if (entry.HasValue()) { - if (entry.Generation == ObjectGeneration::JSON) + if (entry.Generation == ObjectGeneration::json) { cs.write(kDescriptorJson); cs.write(entry.Identifier); @@ -804,7 +804,7 @@ namespace OpenRCT2 if (objRepository.FindObjectLegacy(legacyIdentifier) == nullptr) { objRepository.AddObjectFromFile( - ObjectGeneration::DAT, legacyIdentifier, data.data(), data.size()); + ObjectGeneration::dat, legacyIdentifier, data.data(), data.size()); } } else if (type == kDescriptorParkObj) @@ -816,7 +816,7 @@ namespace OpenRCT2 cs.read(data.data(), data.size()); if (objRepository.FindObject(identifier) == nullptr) { - objRepository.AddObjectFromFile(ObjectGeneration::JSON, identifier, data.data(), data.size()); + objRepository.AddObjectFromFile(ObjectGeneration::json, identifier, data.data(), data.size()); } } else diff --git a/src/openrct2/scripting/bindings/object/ScInstalledObject.hpp b/src/openrct2/scripting/bindings/object/ScInstalledObject.hpp index 6fa521cee9..97a5c6b664 100644 --- a/src/openrct2/scripting/bindings/object/ScInstalledObject.hpp +++ b/src/openrct2/scripting/bindings/object/ScInstalledObject.hpp @@ -88,7 +88,7 @@ namespace OpenRCT2::Scripting auto installedObject = GetInstalledObject(thisVal); if (installedObject != nullptr) { - if (installedObject->Generation == ObjectGeneration::DAT) + if (installedObject->Generation == ObjectGeneration::dat) return JSFromStdString(ctx, "dat"); else return JSFromStdString(ctx, "json"); @@ -128,7 +128,7 @@ namespace OpenRCT2::Scripting auto installedObject = GetInstalledObject(thisVal); if (installedObject != nullptr) { - if (installedObject->Generation == ObjectGeneration::DAT) + if (installedObject->Generation == ObjectGeneration::dat) { return JSFromStdString(ctx, ObjectEntryDescriptor(installedObject->ObjectEntry).ToString()); } diff --git a/src/openrct2/scripting/bindings/object/ScObject.hpp b/src/openrct2/scripting/bindings/object/ScObject.hpp index e0f7d46853..753a69c5d5 100644 --- a/src/openrct2/scripting/bindings/object/ScObject.hpp +++ b/src/openrct2/scripting/bindings/object/ScObject.hpp @@ -105,7 +105,7 @@ namespace OpenRCT2::Scripting std::string str; if (obj != nullptr) { - if (obj->GetGeneration() == ObjectGeneration::DAT) + if (obj->GetGeneration() == ObjectGeneration::dat) { str = obj->GetDescriptor().ToString(); }