mirror of https://github.com/OpenTTD/OpenTTD
Codefix: Implement explicit ByteReader::PeekDWord() instead of type-punning pointer. (#12928)
parent
6deee5e5e2
commit
9631c68ce6
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include "core/backup_type.hpp"
|
||||||
#include "core/container_func.hpp"
|
#include "core/container_func.hpp"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "fileio_func.h"
|
#include "fileio_func.h"
|
||||||
|
@ -257,6 +258,12 @@ public:
|
||||||
return val | (ReadWord() << 16);
|
return val | (ReadWord() << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t PeekDWord()
|
||||||
|
{
|
||||||
|
AutoRestoreBackup backup(this->data, this->data);
|
||||||
|
return this->ReadDWord();
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ReadVarSize(uint8_t size)
|
uint32_t ReadVarSize(uint8_t size)
|
||||||
{
|
{
|
||||||
switch (size) {
|
switch (size) {
|
||||||
|
@ -290,11 +297,6 @@ public:
|
||||||
return data + count <= end;
|
return data + count <= end;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8_t *Data()
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Skip(size_t len)
|
inline void Skip(size_t len)
|
||||||
{
|
{
|
||||||
data += len;
|
data += len;
|
||||||
|
@ -1962,7 +1964,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte
|
||||||
NewGRFSpriteLayout *dts = &statspec->renderdata.emplace_back();
|
NewGRFSpriteLayout *dts = &statspec->renderdata.emplace_back();
|
||||||
dts->consistent_max_offset = UINT16_MAX; // Spritesets are unknown, so no limit.
|
dts->consistent_max_offset = UINT16_MAX; // Spritesets are unknown, so no limit.
|
||||||
|
|
||||||
if (buf.HasData(4) && *(uint32_t*)buf.Data() == 0) {
|
if (buf.HasData(4) && buf.PeekDWord() == 0) {
|
||||||
buf.Skip(4);
|
buf.Skip(4);
|
||||||
extern const DrawTileSprites _station_display_datas_rail[8];
|
extern const DrawTileSprites _station_display_datas_rail[8];
|
||||||
dts->Clone(&_station_display_datas_rail[t % 8]);
|
dts->Clone(&_station_display_datas_rail[t % 8]);
|
||||||
|
|
Loading…
Reference in New Issue