mirror of https://github.com/OpenRCT2/OpenRCT2.git
Remove fixed sizes from legacy structs
This commit is contained in:
parent
f68b705f9f
commit
d8cb15bd50
|
@ -24,6 +24,34 @@
|
|||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
static rct_large_scenery_text ReadLegacy3DFont(OpenRCT2::IStream& stream)
|
||||
{
|
||||
rct_large_scenery_text _3dFontLegacy = {};
|
||||
_3dFontLegacy.offset[0].x = stream.ReadValue<int16_t>();
|
||||
_3dFontLegacy.offset[0].y = stream.ReadValue<int16_t>();
|
||||
_3dFontLegacy.offset[1].x = stream.ReadValue<int16_t>();
|
||||
_3dFontLegacy.offset[1].y = stream.ReadValue<int16_t>();
|
||||
_3dFontLegacy.max_width = stream.ReadValue<uint16_t>();
|
||||
stream.ReadValue<uint16_t>();
|
||||
_3dFontLegacy.flags = stream.ReadValue<uint8_t>();
|
||||
_3dFontLegacy.num_images = stream.ReadValue<uint8_t>();
|
||||
|
||||
auto ReadLegacyTextGlyph = [&stream]() {
|
||||
rct_large_scenery_text_glyph glyph{};
|
||||
glyph.image_offset = stream.ReadValue<uint8_t>();
|
||||
glyph.width = stream.ReadValue<uint8_t>();
|
||||
glyph.height = stream.ReadValue<uint8_t>();
|
||||
stream.ReadValue<uint8_t>();
|
||||
return glyph;
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < std::size(_3dFontLegacy.glyphs); ++i)
|
||||
{
|
||||
_3dFontLegacy.glyphs[i] = ReadLegacyTextGlyph();
|
||||
}
|
||||
return _3dFontLegacy;
|
||||
}
|
||||
|
||||
void LargeSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStream* stream)
|
||||
{
|
||||
stream->Seek(6, OpenRCT2::STREAM_SEEK_CURRENT);
|
||||
|
@ -43,8 +71,7 @@ void LargeSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre
|
|||
|
||||
if (_legacyType.flags & LARGE_SCENERY_FLAG_3D_TEXT)
|
||||
{
|
||||
rct_large_scenery_text _3dFontLegacy = {};
|
||||
stream->Read(&_3dFontLegacy);
|
||||
rct_large_scenery_text _3dFontLegacy = ReadLegacy3DFont(*stream);
|
||||
_3dFont = std::make_unique<LargeSceneryText>(_3dFontLegacy);
|
||||
_legacyType.text = _3dFont.get();
|
||||
}
|
||||
|
@ -129,11 +156,21 @@ void LargeSceneryObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int3
|
|||
std::vector<rct_large_scenery_tile> LargeSceneryObject::ReadTiles(OpenRCT2::IStream* stream)
|
||||
{
|
||||
auto tiles = std::vector<rct_large_scenery_tile>();
|
||||
|
||||
auto ReadLegacyTile = [&stream]() {
|
||||
rct_large_scenery_tile tile{};
|
||||
tile.x_offset = stream->ReadValue<int16_t>();
|
||||
tile.y_offset = stream->ReadValue<int16_t>();
|
||||
tile.z_offset = stream->ReadValue<int16_t>();
|
||||
tile.z_clearance = stream->ReadValue<uint8_t>();
|
||||
tile.flags = stream->ReadValue<uint16_t>();
|
||||
return tile;
|
||||
};
|
||||
|
||||
while (stream->ReadValue<uint16_t>() != 0xFFFF)
|
||||
{
|
||||
stream->Seek(-2, OpenRCT2::STREAM_SEEK_CURRENT);
|
||||
auto tile = stream->ReadValue<rct_large_scenery_tile>();
|
||||
tiles.push_back(std::move(tile));
|
||||
tiles.push_back(ReadLegacyTile());
|
||||
}
|
||||
tiles.push_back({ -1, -1, -1, 255, 0xFFFF });
|
||||
return tiles;
|
||||
|
|
|
@ -39,7 +39,6 @@ struct rct_large_scenery_tile
|
|||
// CCCC WWWW 0SS0 0000
|
||||
uint16_t flags;
|
||||
};
|
||||
assert_struct_size(rct_large_scenery_tile, 9);
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -54,7 +53,6 @@ struct rct_large_scenery_text_glyph
|
|||
uint8_t height;
|
||||
uint8_t pad_3;
|
||||
};
|
||||
assert_struct_size(rct_large_scenery_text_glyph, 4);
|
||||
|
||||
struct rct_large_scenery_text
|
||||
{
|
||||
|
@ -68,7 +66,6 @@ struct rct_large_scenery_text
|
|||
uint8_t num_images; // 0xD
|
||||
rct_large_scenery_text_glyph glyphs[256]; // 0xE
|
||||
};
|
||||
assert_struct_size(rct_large_scenery_text, 14 + 4 * 256);
|
||||
|
||||
enum LARGE_SCENERY_TEXT_FLAGS
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue