Skip to content

Commit

Permalink
Read and write version field of .park
Browse files Browse the repository at this point in the history
  • Loading branch information
spacek531 committed Nov 23, 2022
1 parent 0ea5f34 commit a617d39
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/openrct2/object/Object.h
Expand Up @@ -250,6 +250,7 @@ class Object
{
private:
std::string _identifier;
std::string _version;
ObjectEntryDescriptor _descriptor{};
StringTable _stringTable;
ImageTable _imageTable;
Expand Down Expand Up @@ -363,6 +364,14 @@ class Object

const std::vector<std::string>& GetAuthors() const;
void SetAuthors(std::vector<std::string>&& authors);
const std::string& GetVersion() const
{
return _version;
}
void SetVersion(const std::string& version)
{
_version = version;
}

const ImageTable& GetImageTable() const
{
Expand Down
4 changes: 3 additions & 1 deletion src/openrct2/object/ObjectFactory.cpp
Expand Up @@ -521,6 +521,7 @@ namespace ObjectFactory
if (id == OpenRCT2::Audio::AudioObjectIdentifiers::Rct2cBase)
id = OpenRCT2::Audio::AudioObjectIdentifiers::Rct2Base;

auto version = Json::GetString(jRoot["version"]);
ObjectEntryDescriptor descriptor;
auto originalId = Json::GetString(jRoot["originalId"]);
if (originalId.length() == 8 + 1 + 8 + 1 + 8)
Expand All @@ -539,8 +540,9 @@ namespace ObjectFactory
{
descriptor = ObjectEntryDescriptor(objectType, id);
}

descriptor.Version = version;
result = CreateObject(objectType);
result->SetVersion(version);
result->SetIdentifier(id);
result->SetDescriptor(descriptor);
result->MarkAsJsonObject();
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/object/ObjectRepository.cpp
Expand Up @@ -121,6 +121,7 @@ class ObjectFileIndex final : public FileIndex<ObjectRepositoryItem>
item.Generation = object->GetGeneration();
item.Identifier = object->GetIdentifier();
item.ObjectEntry = object->GetObjectEntry();
item.Version = object->GetVersion();
item.Path = path;
item.Name = object->GetName();
item.Authors = object->GetAuthors();
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/object/ObjectRepository.h
Expand Up @@ -43,6 +43,7 @@ struct ObjectRepositoryItem
rct_object_entry ObjectEntry;
std::string Path;
std::string Name;
std::string Version;
std::vector<std::string> Authors;
std::vector<ObjectSourceGame> Sources;
std::shared_ptr<Object> LoadedObject{};
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/park/ParkFile.cpp
Expand Up @@ -388,7 +388,7 @@ namespace OpenRCT2
{
cs.Write(DESCRIPTOR_JSON);
cs.Write(entry.Identifier);
cs.Write(""); // reserved for version
cs.Write(entry.Version);
}
else
{
Expand Down

0 comments on commit a617d39

Please sign in to comment.