Skip to content

Commit

Permalink
Fix OpenRCT2#13574: Object selection crashes if 'originalId' missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Gymnasiast authored Dec 23, 2020
1 parent 8bab0c7 commit 90964b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/openrct2/object/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ struct rct_object_entry
return static_cast<ObjectType>(flags & 0x0F);
}

void SetType(ObjectType newType)
{
flags &= ~0x0F;
flags |= (static_cast<uint8_t>(newType) & 0x0F);
}

std::optional<uint8_t> GetSceneryType() const;

ObjectSourceGame GetSourceGame() const
Expand Down
2 changes: 2 additions & 0 deletions src/openrct2/object/ObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ namespace ObjectFactory
originalName = originalId.substr(9, 8);
entry.checksum = std::stoul(originalId.substr(18, 8), nullptr, 16);
}
// Always set, since originalId might be missing or incorrect.
entry.SetType(objectType);
auto minLength = std::min<size_t>(8, originalName.length());
std::memcpy(entry.name, originalName.c_str(), minLength);

Expand Down

0 comments on commit 90964b3

Please sign in to comment.