Codechange: rename byte to uint8_t (#12308)
This commit is contained in:
@@ -188,7 +188,7 @@ static void UpdateExclusiveRights()
|
||||
*/
|
||||
}
|
||||
|
||||
static const byte convert_currency[] = {
|
||||
static const uint8_t convert_currency[] = {
|
||||
0, 1, 12, 8, 3,
|
||||
10, 14, 19, 4, 5,
|
||||
9, 11, 13, 6, 17,
|
||||
@@ -490,12 +490,12 @@ static uint FixVehicleInclination(Vehicle *v, Direction dir)
|
||||
case INVALID_DIR: break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
byte entry_z = GetSlopePixelZ(entry_x, entry_y, true);
|
||||
uint8_t entry_z = GetSlopePixelZ(entry_x, entry_y, true);
|
||||
|
||||
/* Compute middle of the tile. */
|
||||
int middle_x = (v->x_pos & ~TILE_UNIT_MASK) + TILE_SIZE / 2;
|
||||
int middle_y = (v->y_pos & ~TILE_UNIT_MASK) + TILE_SIZE / 2;
|
||||
byte middle_z = GetSlopePixelZ(middle_x, middle_y, true);
|
||||
uint8_t middle_z = GetSlopePixelZ(middle_x, middle_y, true);
|
||||
|
||||
/* middle_z == entry_z, no height change. */
|
||||
if (middle_z == entry_z) return 0;
|
||||
@@ -2129,7 +2129,7 @@ bool AfterLoadGame()
|
||||
}
|
||||
|
||||
/* Use old layout randomizer code */
|
||||
byte layout = TileHash(TileX(t->xy), TileY(t->xy)) % 6;
|
||||
uint8_t layout = TileHash(TileX(t->xy), TileY(t->xy)) % 6;
|
||||
switch (layout) {
|
||||
default: break;
|
||||
case 5: layout = 1; break;
|
||||
@@ -2365,8 +2365,8 @@ bool AfterLoadGame()
|
||||
/* Airport tile animation uses animation frame instead of other graphics id */
|
||||
if (IsSavegameVersionBefore(SLV_137)) {
|
||||
struct AirportTileConversion {
|
||||
byte old_start;
|
||||
byte num_frames;
|
||||
uint8_t old_start;
|
||||
uint8_t num_frames;
|
||||
};
|
||||
static const AirportTileConversion atc[] = {
|
||||
{31, 12}, // APT_RADAR_GRASS_FENCE_SW
|
||||
@@ -2382,7 +2382,7 @@ bool AfterLoadGame()
|
||||
for (auto t : Map::Iterate()) {
|
||||
if (IsAirportTile(t)) {
|
||||
StationGfx old_gfx = GetStationGfx(t);
|
||||
byte offset = 0;
|
||||
uint8_t offset = 0;
|
||||
for (uint i = 0; i < lengthof(atc); i++) {
|
||||
if (old_gfx < atc[i].old_start) {
|
||||
SetStationGfx(t, old_gfx - offset);
|
||||
@@ -2535,9 +2535,9 @@ bool AfterLoadGame()
|
||||
const DiagDirection vdir = DirToDiagDir(v->direction);
|
||||
|
||||
/* Have we passed the visibility "switch" state already? */
|
||||
byte pos = (DiagDirToAxis(vdir) == AXIS_X ? v->x_pos : v->y_pos) & TILE_UNIT_MASK;
|
||||
byte frame = (vdir == DIAGDIR_NE || vdir == DIAGDIR_NW) ? TILE_SIZE - 1 - pos : pos;
|
||||
extern const byte _tunnel_visibility_frame[DIAGDIR_END];
|
||||
uint8_t pos = (DiagDirToAxis(vdir) == AXIS_X ? v->x_pos : v->y_pos) & TILE_UNIT_MASK;
|
||||
uint8_t frame = (vdir == DIAGDIR_NE || vdir == DIAGDIR_NW) ? TILE_SIZE - 1 - pos : pos;
|
||||
extern const uint8_t _tunnel_visibility_frame[DIAGDIR_END];
|
||||
|
||||
/* Should the vehicle be hidden or not? */
|
||||
bool hidden;
|
||||
@@ -2583,7 +2583,7 @@ bool AfterLoadGame()
|
||||
|
||||
bool loading = rv->current_order.IsType(OT_LOADING) || rv->current_order.IsType(OT_LEAVESTATION);
|
||||
if (HasBit(rv->state, RVS_IN_ROAD_STOP)) {
|
||||
extern const byte _road_stop_stop_frame[];
|
||||
extern const uint8_t _road_stop_stop_frame[];
|
||||
SB(rv->state, RVS_ENTERED_STOP, 1, loading || rv->frame > _road_stop_stop_frame[rv->state - RVSB_IN_ROAD_STOP + (_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)]);
|
||||
} else if (HasBit(rv->state, RVS_IN_DT_ROAD_STOP)) {
|
||||
SB(rv->state, RVS_ENTERED_STOP, 1, loading || rv->frame > RVC_DRIVE_THROUGH_STOP_FRAME);
|
||||
|
@@ -348,7 +348,7 @@ public:
|
||||
void Load(LoggedAction *la) const override
|
||||
{
|
||||
if (IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY)) {
|
||||
byte type;
|
||||
uint8_t type;
|
||||
while ((type = SlReadByte()) != GLCT_NONE) {
|
||||
if (type >= GLCT_END) SlErrorCorrupt("Invalid gamelog change type");
|
||||
LoadChange(la, (GamelogChangeType)type);
|
||||
@@ -384,7 +384,7 @@ struct GLOGChunkHandler : ChunkHandler {
|
||||
const std::vector<SaveLoad> slt = SlCompatTableHeader(_gamelog_desc, _gamelog_sl_compat);
|
||||
|
||||
if (IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY)) {
|
||||
byte type;
|
||||
uint8_t type;
|
||||
while ((type = SlReadByte()) != GLAT_NONE) {
|
||||
if (type >= GLAT_END) SlErrorCorrupt("Invalid gamelog action type");
|
||||
|
||||
|
@@ -71,7 +71,7 @@ struct MAPTChunkHandler : ChunkHandler {
|
||||
|
||||
void Load() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
for (TileIndex i = 0; i != size;) {
|
||||
@@ -82,7 +82,7 @@ struct MAPTChunkHandler : ChunkHandler {
|
||||
|
||||
void Save() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
SlSetLength(size);
|
||||
@@ -98,7 +98,7 @@ struct MAPHChunkHandler : ChunkHandler {
|
||||
|
||||
void Load() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
for (TileIndex i = 0; i != size;) {
|
||||
@@ -109,7 +109,7 @@ struct MAPHChunkHandler : ChunkHandler {
|
||||
|
||||
void Save() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
SlSetLength(size);
|
||||
@@ -125,7 +125,7 @@ struct MAPOChunkHandler : ChunkHandler {
|
||||
|
||||
void Load() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
for (TileIndex i = 0; i != size;) {
|
||||
@@ -136,7 +136,7 @@ struct MAPOChunkHandler : ChunkHandler {
|
||||
|
||||
void Save() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
SlSetLength(size);
|
||||
@@ -182,7 +182,7 @@ struct M3LOChunkHandler : ChunkHandler {
|
||||
|
||||
void Load() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
for (TileIndex i = 0; i != size;) {
|
||||
@@ -193,7 +193,7 @@ struct M3LOChunkHandler : ChunkHandler {
|
||||
|
||||
void Save() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
SlSetLength(size);
|
||||
@@ -209,7 +209,7 @@ struct M3HIChunkHandler : ChunkHandler {
|
||||
|
||||
void Load() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
for (TileIndex i = 0; i != size;) {
|
||||
@@ -220,7 +220,7 @@ struct M3HIChunkHandler : ChunkHandler {
|
||||
|
||||
void Save() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
SlSetLength(size);
|
||||
@@ -236,7 +236,7 @@ struct MAP5ChunkHandler : ChunkHandler {
|
||||
|
||||
void Load() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
for (TileIndex i = 0; i != size;) {
|
||||
@@ -247,7 +247,7 @@ struct MAP5ChunkHandler : ChunkHandler {
|
||||
|
||||
void Save() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
SlSetLength(size);
|
||||
@@ -263,7 +263,7 @@ struct MAPEChunkHandler : ChunkHandler {
|
||||
|
||||
void Load() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
if (IsSavegameVersionBefore(SLV_42)) {
|
||||
@@ -287,7 +287,7 @@ struct MAPEChunkHandler : ChunkHandler {
|
||||
|
||||
void Save() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
SlSetLength(size);
|
||||
@@ -303,7 +303,7 @@ struct MAP7ChunkHandler : ChunkHandler {
|
||||
|
||||
void Load() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
for (TileIndex i = 0; i != size;) {
|
||||
@@ -314,7 +314,7 @@ struct MAP7ChunkHandler : ChunkHandler {
|
||||
|
||||
void Save() const override
|
||||
{
|
||||
std::array<byte, MAP_SL_BUF_SIZE> buf;
|
||||
std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
|
||||
uint size = Map::Size();
|
||||
|
||||
SlSetLength(size);
|
||||
|
@@ -28,7 +28,7 @@
|
||||
|
||||
extern TileIndex _cur_tileloop_tile;
|
||||
extern uint16_t _disaster_delay;
|
||||
extern byte _trees_tick_ctr;
|
||||
extern uint8_t _trees_tick_ctr;
|
||||
|
||||
/* Keep track of current game position */
|
||||
int _saved_scrollpos_x;
|
||||
@@ -76,7 +76,7 @@ void ResetViewportAfterLoadGame()
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
|
||||
byte _age_cargo_skip_counter; ///< Skip aging of cargo? Used before savegame version 162.
|
||||
uint8_t _age_cargo_skip_counter; ///< Skip aging of cargo? Used before savegame version 162.
|
||||
extern TimeoutTimer<TimerGameTick> _new_competitor_timeout;
|
||||
|
||||
static const SaveLoad _date_desc[] = {
|
||||
|
@@ -33,10 +33,10 @@ static inline OldChunkType GetOldChunkType(OldChunkType type) {return (OldCh
|
||||
static inline OldChunkType GetOldChunkVarType(OldChunkType type) {return (OldChunkType)(GB(type, 8, 8) << 8);}
|
||||
static inline OldChunkType GetOldChunkFileType(OldChunkType type) {return (OldChunkType)(GB(type, 16, 8) << 16);}
|
||||
|
||||
static inline byte CalcOldVarLen(OldChunkType type)
|
||||
static inline uint8_t CalcOldVarLen(OldChunkType type)
|
||||
{
|
||||
static const byte type_mem_size[] = {0, 1, 1, 2, 2, 4, 4, 8};
|
||||
byte length = GB(type, 8, 8);
|
||||
static const uint8_t type_mem_size[] = {0, 1, 1, 2, 2, 4, 4, 8};
|
||||
uint8_t length = GB(type, 8, 8);
|
||||
assert(length != 0 && length < lengthof(type_mem_size));
|
||||
return type_mem_size[length];
|
||||
}
|
||||
@@ -46,7 +46,7 @@ static inline byte CalcOldVarLen(OldChunkType type)
|
||||
* Reads a byte from a file (do not call yourself, use ReadByte())
|
||||
*
|
||||
*/
|
||||
static byte ReadByteFromFile(LoadgameState *ls)
|
||||
static uint8_t ReadByteFromFile(LoadgameState *ls)
|
||||
{
|
||||
/* To avoid slow reads, we read BUFFER_SIZE of bytes per time
|
||||
and just return a byte per time */
|
||||
@@ -73,7 +73,7 @@ static byte ReadByteFromFile(LoadgameState *ls)
|
||||
* Reads a byte from the buffer and decompress if needed
|
||||
*
|
||||
*/
|
||||
byte ReadByte(LoadgameState *ls)
|
||||
uint8_t ReadByte(LoadgameState *ls)
|
||||
{
|
||||
/* Old savegames have a nice compression algorithm (RLE)
|
||||
which means that we have a chunk, which starts with a length
|
||||
@@ -116,8 +116,8 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
|
||||
continue;
|
||||
}
|
||||
|
||||
byte *ptr = (byte*)chunk->ptr;
|
||||
if (chunk->type & OC_DEREFERENCE_POINTER) ptr = *(byte**)ptr;
|
||||
uint8_t *ptr = (uint8_t*)chunk->ptr;
|
||||
if (chunk->type & OC_DEREFERENCE_POINTER) ptr = *(uint8_t**)ptr;
|
||||
|
||||
for (uint i = 0; i < chunk->amount; i++) {
|
||||
/* Handle simple types */
|
||||
@@ -155,7 +155,7 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
|
||||
if (base == nullptr && chunk->ptr == nullptr) continue;
|
||||
|
||||
/* Chunk refers to a struct member, get address in base. */
|
||||
if (chunk->ptr == nullptr) ptr = (byte *)chunk->offset(base);
|
||||
if (chunk->ptr == nullptr) ptr = (uint8_t *)chunk->offset(base);
|
||||
|
||||
/* Write the data */
|
||||
switch (GetOldChunkVarType(chunk->type)) {
|
||||
|
@@ -22,11 +22,11 @@ struct LoadgameState {
|
||||
uint chunk_size;
|
||||
|
||||
bool decoding;
|
||||
byte decode_char;
|
||||
uint8_t decode_char;
|
||||
|
||||
uint buffer_count;
|
||||
uint buffer_cur;
|
||||
byte buffer[BUFFER_SIZE];
|
||||
uint8_t buffer[BUFFER_SIZE];
|
||||
|
||||
uint total_read;
|
||||
};
|
||||
@@ -94,7 +94,7 @@ struct OldChunks {
|
||||
};
|
||||
|
||||
extern uint _bump_assert_value;
|
||||
byte ReadByte(LoadgameState *ls);
|
||||
uint8_t ReadByte(LoadgameState *ls);
|
||||
bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks);
|
||||
|
||||
bool LoadTTDMain(LoadgameState *ls);
|
||||
@@ -102,7 +102,7 @@ bool LoadTTOMain(LoadgameState *ls);
|
||||
|
||||
inline uint16_t ReadUint16(LoadgameState *ls)
|
||||
{
|
||||
byte x = ReadByte(ls);
|
||||
uint8_t x = ReadByte(ls);
|
||||
return x | ReadByte(ls) << 8;
|
||||
}
|
||||
|
||||
|
@@ -41,7 +41,7 @@
|
||||
|
||||
static bool _read_ttdpatch_flags; ///< Have we (tried to) read TTDPatch extra flags?
|
||||
static uint16_t _old_extra_chunk_nums; ///< Number of extra TTDPatch chunks
|
||||
static byte _old_vehicle_multiplier; ///< TTDPatch vehicle multiplier
|
||||
static uint8_t _old_vehicle_multiplier; ///< TTDPatch vehicle multiplier
|
||||
|
||||
void FixOldMapArray()
|
||||
{
|
||||
@@ -111,7 +111,7 @@ static void FixTTDDepots()
|
||||
|
||||
#define FIXNUM(x, y, z) (((((x) << 16) / (y)) + 1) << z)
|
||||
|
||||
static uint32_t RemapOldTownName(uint32_t townnameparts, byte old_town_name_type)
|
||||
static uint32_t RemapOldTownName(uint32_t townnameparts, uint8_t old_town_name_type)
|
||||
{
|
||||
switch (old_town_name_type) {
|
||||
case 0: case 3: // English, American
|
||||
@@ -304,7 +304,7 @@ static bool FixTTOMapArray()
|
||||
|
||||
case MP_TUNNELBRIDGE:
|
||||
if (HasBit(tile.m5(), 7)) { // bridge
|
||||
byte m5 = tile.m5();
|
||||
uint8_t m5 = tile.m5();
|
||||
tile.m5() = m5 & 0xE1; // copy bits 7..5, 1
|
||||
if (GB(m5, 1, 2) == 1) tile.m5() |= 0x02; // road bridge
|
||||
if (GB(m5, 1, 2) == 3) tile.m2() |= 0xA0; // monorail bridge -> tubular, steel bridge
|
||||
@@ -1281,7 +1281,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
|
||||
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN: {
|
||||
static const byte spriteset_rail[] = {
|
||||
static const uint8_t spriteset_rail[] = {
|
||||
0, 2, 4, 4, 8, 10, 12, 14, 16, 18, 20, 22, 40, 42, 44, 46,
|
||||
48, 52, 54, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 120, 122,
|
||||
124, 126, 128, 130, 132, 134, 136, 138, 140
|
||||
@@ -1508,7 +1508,7 @@ static bool LoadOldMapPart1(LoadgameState *ls, int)
|
||||
}
|
||||
auto range = Map::Iterate();
|
||||
for (auto it = range.begin(); it != range.end(); /* nothing. */) {
|
||||
byte b = ReadByte(ls);
|
||||
uint8_t b = ReadByte(ls);
|
||||
for (int i = 0; i < 8; i += 2, ++it) (*it).m6() = GB(b, i, 2);
|
||||
}
|
||||
}
|
||||
@@ -1586,8 +1586,8 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int)
|
||||
|
||||
extern TileIndex _cur_tileloop_tile;
|
||||
extern uint16_t _disaster_delay;
|
||||
extern byte _trees_tick_ctr;
|
||||
extern byte _age_cargo_skip_counter; // From misc_sl.cpp
|
||||
extern uint8_t _trees_tick_ctr;
|
||||
extern uint8_t _age_cargo_skip_counter; // From misc_sl.cpp
|
||||
extern uint8_t _old_diff_level;
|
||||
extern uint8_t _old_units;
|
||||
static const OldChunks main_chunk[] = {
|
||||
@@ -1808,7 +1808,7 @@ bool LoadTTOMain(LoadgameState *ls)
|
||||
|
||||
_read_ttdpatch_flags = false;
|
||||
|
||||
std::array<byte, 103 * sizeof(Engine)> engines; // we don't want to call Engine constructor here
|
||||
std::array<uint8_t, 103 * sizeof(Engine)> engines; // we don't want to call Engine constructor here
|
||||
_old_engines = (Engine *)engines.data();
|
||||
std::array<StringID, 800> vehnames;
|
||||
_old_vehicle_names = vehnames.data();
|
||||
|
@@ -61,7 +61,7 @@ FileToSaveLoad _file_to_saveload; ///< File to save or load in the openttd loop.
|
||||
|
||||
uint32_t _ttdp_version; ///< version of TTDP savegame (if applicable)
|
||||
SaveLoadVersion _sl_version; ///< the major savegame version identifier
|
||||
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
|
||||
uint8_t _sl_minor_version; ///< the minor savegame version, DO NOT USE!
|
||||
std::string _savegame_format; ///< how to compress savegames
|
||||
bool _do_autosave; ///< are we doing an autosave at the moment?
|
||||
|
||||
@@ -85,9 +85,9 @@ static const size_t MEMORY_CHUNK_SIZE = 128 * 1024;
|
||||
|
||||
/** A buffer for reading (and buffering) savegame data. */
|
||||
struct ReadBuffer {
|
||||
byte buf[MEMORY_CHUNK_SIZE]; ///< Buffer we're going to read from.
|
||||
byte *bufp; ///< Location we're at reading the buffer.
|
||||
byte *bufe; ///< End of the buffer we can read from.
|
||||
uint8_t buf[MEMORY_CHUNK_SIZE]; ///< Buffer we're going to read from.
|
||||
uint8_t *bufp; ///< Location we're at reading the buffer.
|
||||
uint8_t *bufe; ///< End of the buffer we can read from.
|
||||
std::shared_ptr<LoadFilter> reader; ///< The filter used to actually read.
|
||||
size_t read; ///< The amount of read bytes so far from the filter.
|
||||
|
||||
@@ -99,7 +99,7 @@ struct ReadBuffer {
|
||||
{
|
||||
}
|
||||
|
||||
inline byte ReadByte()
|
||||
inline uint8_t ReadByte()
|
||||
{
|
||||
if (this->bufp == this->bufe) {
|
||||
size_t len = this->reader->Read(this->buf, lengthof(this->buf));
|
||||
@@ -126,9 +126,9 @@ struct ReadBuffer {
|
||||
|
||||
/** Container for dumping the savegame (quickly) to memory. */
|
||||
struct MemoryDumper {
|
||||
std::vector<byte *> blocks; ///< Buffer with blocks of allocated memory.
|
||||
byte *buf; ///< Buffer we're going to write to.
|
||||
byte *bufe; ///< End of the buffer we write to.
|
||||
std::vector<uint8_t *> blocks; ///< Buffer with blocks of allocated memory.
|
||||
uint8_t *buf; ///< Buffer we're going to write to.
|
||||
uint8_t *bufe; ///< End of the buffer we write to.
|
||||
|
||||
/** Initialise our variables. */
|
||||
MemoryDumper() : buf(nullptr), bufe(nullptr)
|
||||
@@ -146,11 +146,11 @@ struct MemoryDumper {
|
||||
* Write a single byte into the dumper.
|
||||
* @param b The byte to write.
|
||||
*/
|
||||
inline void WriteByte(byte b)
|
||||
inline void WriteByte(uint8_t b)
|
||||
{
|
||||
/* Are we at the end of this chunk? */
|
||||
if (this->buf == this->bufe) {
|
||||
this->buf = CallocT<byte>(MEMORY_CHUNK_SIZE);
|
||||
this->buf = CallocT<uint8_t>(MEMORY_CHUNK_SIZE);
|
||||
this->blocks.push_back(this->buf);
|
||||
this->bufe = this->buf + MEMORY_CHUNK_SIZE;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ struct MemoryDumper {
|
||||
struct SaveLoadParams {
|
||||
SaveLoadAction action; ///< are we doing a save or a load atm.
|
||||
NeedLength need_length; ///< working in NeedLength (Autolength) mode?
|
||||
byte block_mode; ///< ???
|
||||
uint8_t block_mode; ///< ???
|
||||
bool error; ///< did an error occur or not
|
||||
|
||||
size_t obj_len; ///< the length of the current object we are busy with
|
||||
@@ -402,7 +402,7 @@ void ProcessAsyncSaveFinish()
|
||||
* Wrapper for reading a byte from the buffer.
|
||||
* @return The read byte.
|
||||
*/
|
||||
byte SlReadByte()
|
||||
uint8_t SlReadByte()
|
||||
{
|
||||
return _sl.reader->ReadByte();
|
||||
}
|
||||
@@ -411,7 +411,7 @@ byte SlReadByte()
|
||||
* Wrapper for writing a byte to the dumper.
|
||||
* @param b The byte to write.
|
||||
*/
|
||||
void SlWriteByte(byte b)
|
||||
void SlWriteByte(uint8_t b)
|
||||
{
|
||||
_sl.dumper->WriteByte(b);
|
||||
}
|
||||
@@ -511,21 +511,21 @@ static void SlWriteSimpleGamma(size_t i)
|
||||
if (i >= (1 << 21)) {
|
||||
if (i >= (1 << 28)) {
|
||||
assert(i <= UINT32_MAX); // We can only support 32 bits for now.
|
||||
SlWriteByte((byte)(0xF0));
|
||||
SlWriteByte((byte)(i >> 24));
|
||||
SlWriteByte((uint8_t)(0xF0));
|
||||
SlWriteByte((uint8_t)(i >> 24));
|
||||
} else {
|
||||
SlWriteByte((byte)(0xE0 | (i >> 24)));
|
||||
SlWriteByte((uint8_t)(0xE0 | (i >> 24)));
|
||||
}
|
||||
SlWriteByte((byte)(i >> 16));
|
||||
SlWriteByte((uint8_t)(i >> 16));
|
||||
} else {
|
||||
SlWriteByte((byte)(0xC0 | (i >> 16)));
|
||||
SlWriteByte((uint8_t)(0xC0 | (i >> 16)));
|
||||
}
|
||||
SlWriteByte((byte)(i >> 8));
|
||||
SlWriteByte((uint8_t)(i >> 8));
|
||||
} else {
|
||||
SlWriteByte((byte)(0x80 | (i >> 8)));
|
||||
SlWriteByte((uint8_t)(0x80 | (i >> 8)));
|
||||
}
|
||||
}
|
||||
SlWriteByte((byte)i);
|
||||
SlWriteByte((uint8_t)i);
|
||||
}
|
||||
|
||||
/** Return how many bytes used to encode a gamma value */
|
||||
@@ -599,7 +599,7 @@ static uint8_t GetSavegameFileType(const SaveLoad &sld)
|
||||
*/
|
||||
static inline uint SlCalcConvMemLen(VarType conv)
|
||||
{
|
||||
static const byte conv_mem_size[] = {1, 1, 1, 2, 2, 4, 4, 8, 8, 0};
|
||||
static const uint8_t conv_mem_size[] = {1, 1, 1, 2, 2, 4, 4, 8, 8, 0};
|
||||
|
||||
switch (GetVarMemType(conv)) {
|
||||
case SLE_VAR_STR:
|
||||
@@ -619,9 +619,9 @@ static inline uint SlCalcConvMemLen(VarType conv)
|
||||
* @param conv VarType type of variable that is used for calculating the size
|
||||
* @return Return the size of this type in bytes
|
||||
*/
|
||||
static inline byte SlCalcConvFileLen(VarType conv)
|
||||
static inline uint8_t SlCalcConvFileLen(VarType conv)
|
||||
{
|
||||
static const byte conv_file_size[] = {0, 1, 1, 2, 2, 4, 4, 8, 8, 2};
|
||||
static const uint8_t conv_file_size[] = {0, 1, 1, 2, 2, 4, 4, 8, 8, 2};
|
||||
|
||||
switch (GetVarFileType(conv)) {
|
||||
case SLE_FILE_STRING:
|
||||
@@ -761,7 +761,7 @@ void SlSetLength(size_t length)
|
||||
*/
|
||||
static void SlCopyBytes(void *ptr, size_t length)
|
||||
{
|
||||
byte *p = (byte *)ptr;
|
||||
uint8_t *p = (uint8_t *)ptr;
|
||||
|
||||
switch (_sl.action) {
|
||||
case SLA_LOAD_CHECK:
|
||||
@@ -793,7 +793,7 @@ int64_t ReadValue(const void *ptr, VarType conv)
|
||||
switch (GetVarMemType(conv)) {
|
||||
case SLE_VAR_BL: return (*(const bool *)ptr != 0);
|
||||
case SLE_VAR_I8: return *(const int8_t *)ptr;
|
||||
case SLE_VAR_U8: return *(const byte *)ptr;
|
||||
case SLE_VAR_U8: return *(const uint8_t *)ptr;
|
||||
case SLE_VAR_I16: return *(const int16_t *)ptr;
|
||||
case SLE_VAR_U16: return *(const uint16_t*)ptr;
|
||||
case SLE_VAR_I32: return *(const int32_t *)ptr;
|
||||
@@ -817,7 +817,7 @@ void WriteValue(void *ptr, VarType conv, int64_t val)
|
||||
switch (GetVarMemType(conv)) {
|
||||
case SLE_VAR_BL: *(bool *)ptr = (val != 0); break;
|
||||
case SLE_VAR_I8: *(int8_t *)ptr = val; break;
|
||||
case SLE_VAR_U8: *(byte *)ptr = val; break;
|
||||
case SLE_VAR_U8: *(uint8_t *)ptr = val; break;
|
||||
case SLE_VAR_I16: *(int16_t *)ptr = val; break;
|
||||
case SLE_VAR_U16: *(uint16_t*)ptr = val; break;
|
||||
case SLE_VAR_I32: *(int32_t *)ptr = val; break;
|
||||
@@ -865,7 +865,7 @@ static void SlSaveLoadConv(void *ptr, VarType conv)
|
||||
/* Read a value from the file */
|
||||
switch (GetVarFileType(conv)) {
|
||||
case SLE_FILE_I8: x = (int8_t )SlReadByte(); break;
|
||||
case SLE_FILE_U8: x = (byte )SlReadByte(); break;
|
||||
case SLE_FILE_U8: x = (uint8_t )SlReadByte(); break;
|
||||
case SLE_FILE_I16: x = (int16_t )SlReadUint16(); break;
|
||||
case SLE_FILE_U16: x = (uint16_t)SlReadUint16(); break;
|
||||
case SLE_FILE_I32: x = (int32_t )SlReadUint32(); break;
|
||||
@@ -1006,8 +1006,8 @@ static void SlCopyInternal(void *object, size_t length, VarType conv)
|
||||
if (conv == SLE_INT8 || conv == SLE_UINT8) {
|
||||
SlCopyBytes(object, length);
|
||||
} else {
|
||||
byte *a = (byte*)object;
|
||||
byte mem_size = SlCalcConvMemLen(conv);
|
||||
uint8_t *a = (uint8_t*)object;
|
||||
uint8_t mem_size = SlCalcConvMemLen(conv);
|
||||
|
||||
for (; length != 0; length --) {
|
||||
SlSaveLoadConv(a, conv);
|
||||
@@ -1052,7 +1052,7 @@ static inline size_t SlCalcArrayLen(size_t length, VarType conv)
|
||||
* Save/Load the length of the array followed by the array of SL_VAR elements.
|
||||
* @param array The array being manipulated
|
||||
* @param length The length of the array in elements
|
||||
* @param conv VarType type of the atomic array (int, byte, uint64_t, etc.)
|
||||
* @param conv VarType type of the atomic array (int, uint8_t, uint64_t, etc.)
|
||||
*/
|
||||
static void SlArray(void *array, size_t length, VarType conv)
|
||||
{
|
||||
@@ -1962,7 +1962,7 @@ void ChunkHandler::LoadCheck(size_t len) const
|
||||
*/
|
||||
static void SlLoadChunk(const ChunkHandler &ch)
|
||||
{
|
||||
byte m = SlReadByte();
|
||||
uint8_t m = SlReadByte();
|
||||
|
||||
_sl.block_mode = m & CH_TYPE_MASK;
|
||||
_sl.obj_len = 0;
|
||||
@@ -2015,7 +2015,7 @@ static void SlLoadChunk(const ChunkHandler &ch)
|
||||
*/
|
||||
static void SlLoadCheckChunk(const ChunkHandler &ch)
|
||||
{
|
||||
byte m = SlReadByte();
|
||||
uint8_t m = SlReadByte();
|
||||
|
||||
_sl.block_mode = m & CH_TYPE_MASK;
|
||||
_sl.obj_len = 0;
|
||||
@@ -2189,7 +2189,7 @@ struct FileReader : LoadFilter {
|
||||
this->file = nullptr;
|
||||
}
|
||||
|
||||
size_t Read(byte *buf, size_t size) override
|
||||
size_t Read(uint8_t *buf, size_t size) override
|
||||
{
|
||||
/* We're in the process of shutting down, i.e. in "failure" mode. */
|
||||
if (this->file == nullptr) return 0;
|
||||
@@ -2224,7 +2224,7 @@ struct FileWriter : SaveFilter {
|
||||
this->Finish();
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(uint8_t *buf, size_t size) override
|
||||
{
|
||||
/* We're in the process of shutting down, i.e. in "failure" mode. */
|
||||
if (this->file == nullptr) return;
|
||||
@@ -2263,18 +2263,18 @@ struct LZOLoadFilter : LoadFilter {
|
||||
if (lzo_init() != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize decompressor");
|
||||
}
|
||||
|
||||
size_t Read(byte *buf, size_t ssize) override
|
||||
size_t Read(uint8_t *buf, size_t ssize) override
|
||||
{
|
||||
assert(ssize >= LZO_BUFFER_SIZE);
|
||||
|
||||
/* Buffer size is from the LZO docs plus the chunk header size. */
|
||||
byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32_t) * 2];
|
||||
uint8_t out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32_t) * 2];
|
||||
uint32_t tmp[2];
|
||||
uint32_t size;
|
||||
lzo_uint len = ssize;
|
||||
|
||||
/* Read header*/
|
||||
if (this->chain->Read((byte*)tmp, sizeof(tmp)) != sizeof(tmp)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE, "File read failed");
|
||||
if (this->chain->Read((uint8_t*)tmp, sizeof(tmp)) != sizeof(tmp)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE, "File read failed");
|
||||
|
||||
/* Check if size is bad */
|
||||
((uint32_t*)out)[0] = size = tmp[1];
|
||||
@@ -2305,17 +2305,17 @@ struct LZOSaveFilter : SaveFilter {
|
||||
* Initialise this filter.
|
||||
* @param chain The next filter in this chain.
|
||||
*/
|
||||
LZOSaveFilter(std::shared_ptr<SaveFilter> chain, byte) : SaveFilter(chain)
|
||||
LZOSaveFilter(std::shared_ptr<SaveFilter> chain, uint8_t) : SaveFilter(chain)
|
||||
{
|
||||
if (lzo_init() != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(uint8_t *buf, size_t size) override
|
||||
{
|
||||
const lzo_bytep in = buf;
|
||||
/* Buffer size is from the LZO docs plus the chunk header size. */
|
||||
byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32_t) * 2];
|
||||
byte wrkmem[LZO1X_1_MEM_COMPRESS];
|
||||
uint8_t out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32_t) * 2];
|
||||
uint8_t wrkmem[LZO1X_1_MEM_COMPRESS];
|
||||
lzo_uint outlen;
|
||||
|
||||
do {
|
||||
@@ -2349,7 +2349,7 @@ struct NoCompLoadFilter : LoadFilter {
|
||||
{
|
||||
}
|
||||
|
||||
size_t Read(byte *buf, size_t size) override
|
||||
size_t Read(uint8_t *buf, size_t size) override
|
||||
{
|
||||
return this->chain->Read(buf, size);
|
||||
}
|
||||
@@ -2361,11 +2361,11 @@ struct NoCompSaveFilter : SaveFilter {
|
||||
* Initialise this filter.
|
||||
* @param chain The next filter in this chain.
|
||||
*/
|
||||
NoCompSaveFilter(std::shared_ptr<SaveFilter> chain, byte) : SaveFilter(chain)
|
||||
NoCompSaveFilter(std::shared_ptr<SaveFilter> chain, uint8_t) : SaveFilter(chain)
|
||||
{
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(uint8_t *buf, size_t size) override
|
||||
{
|
||||
this->chain->Write(buf, size);
|
||||
}
|
||||
@@ -2381,7 +2381,7 @@ struct NoCompSaveFilter : SaveFilter {
|
||||
/** Filter using Zlib compression. */
|
||||
struct ZlibLoadFilter : LoadFilter {
|
||||
z_stream z; ///< Stream state we are reading from.
|
||||
byte fread_buf[MEMORY_CHUNK_SIZE]; ///< Buffer for reading from the file.
|
||||
uint8_t fread_buf[MEMORY_CHUNK_SIZE]; ///< Buffer for reading from the file.
|
||||
|
||||
/**
|
||||
* Initialise this filter.
|
||||
@@ -2399,7 +2399,7 @@ struct ZlibLoadFilter : LoadFilter {
|
||||
inflateEnd(&this->z);
|
||||
}
|
||||
|
||||
size_t Read(byte *buf, size_t size) override
|
||||
size_t Read(uint8_t *buf, size_t size) override
|
||||
{
|
||||
this->z.next_out = buf;
|
||||
this->z.avail_out = (uint)size;
|
||||
@@ -2425,14 +2425,14 @@ struct ZlibLoadFilter : LoadFilter {
|
||||
/** Filter using Zlib compression. */
|
||||
struct ZlibSaveFilter : SaveFilter {
|
||||
z_stream z; ///< Stream state we are writing to.
|
||||
byte fwrite_buf[MEMORY_CHUNK_SIZE]; ///< Buffer for writing to the file.
|
||||
uint8_t fwrite_buf[MEMORY_CHUNK_SIZE]; ///< Buffer for writing to the file.
|
||||
|
||||
/**
|
||||
* Initialise this filter.
|
||||
* @param chain The next filter in this chain.
|
||||
* @param compression_level The requested level of compression.
|
||||
*/
|
||||
ZlibSaveFilter(std::shared_ptr<SaveFilter> chain, byte compression_level) : SaveFilter(chain)
|
||||
ZlibSaveFilter(std::shared_ptr<SaveFilter> chain, uint8_t compression_level) : SaveFilter(chain)
|
||||
{
|
||||
memset(&this->z, 0, sizeof(this->z));
|
||||
if (deflateInit(&this->z, compression_level) != Z_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
|
||||
@@ -2450,7 +2450,7 @@ struct ZlibSaveFilter : SaveFilter {
|
||||
* @param len Amount of bytes to write.
|
||||
* @param mode Mode for deflate.
|
||||
*/
|
||||
void WriteLoop(byte *p, size_t len, int mode)
|
||||
void WriteLoop(uint8_t *p, size_t len, int mode)
|
||||
{
|
||||
uint n;
|
||||
this->z.next_in = p;
|
||||
@@ -2478,7 +2478,7 @@ struct ZlibSaveFilter : SaveFilter {
|
||||
} while (this->z.avail_in || !this->z.avail_out);
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(uint8_t *buf, size_t size) override
|
||||
{
|
||||
this->WriteLoop(buf, size, 0);
|
||||
}
|
||||
@@ -2510,7 +2510,7 @@ static const lzma_stream _lzma_init = LZMA_STREAM_INIT;
|
||||
/** Filter without any compression. */
|
||||
struct LZMALoadFilter : LoadFilter {
|
||||
lzma_stream lzma; ///< Stream state that we are reading from.
|
||||
byte fread_buf[MEMORY_CHUNK_SIZE]; ///< Buffer for reading from the file.
|
||||
uint8_t fread_buf[MEMORY_CHUNK_SIZE]; ///< Buffer for reading from the file.
|
||||
|
||||
/**
|
||||
* Initialise this filter.
|
||||
@@ -2528,7 +2528,7 @@ struct LZMALoadFilter : LoadFilter {
|
||||
lzma_end(&this->lzma);
|
||||
}
|
||||
|
||||
size_t Read(byte *buf, size_t size) override
|
||||
size_t Read(uint8_t *buf, size_t size) override
|
||||
{
|
||||
this->lzma.next_out = buf;
|
||||
this->lzma.avail_out = size;
|
||||
@@ -2553,14 +2553,14 @@ struct LZMALoadFilter : LoadFilter {
|
||||
/** Filter using LZMA compression. */
|
||||
struct LZMASaveFilter : SaveFilter {
|
||||
lzma_stream lzma; ///< Stream state that we are writing to.
|
||||
byte fwrite_buf[MEMORY_CHUNK_SIZE]; ///< Buffer for writing to the file.
|
||||
uint8_t fwrite_buf[MEMORY_CHUNK_SIZE]; ///< Buffer for writing to the file.
|
||||
|
||||
/**
|
||||
* Initialise this filter.
|
||||
* @param chain The next filter in this chain.
|
||||
* @param compression_level The requested level of compression.
|
||||
*/
|
||||
LZMASaveFilter(std::shared_ptr<SaveFilter> chain, byte compression_level) : SaveFilter(chain), lzma(_lzma_init)
|
||||
LZMASaveFilter(std::shared_ptr<SaveFilter> chain, uint8_t compression_level) : SaveFilter(chain), lzma(_lzma_init)
|
||||
{
|
||||
if (lzma_easy_encoder(&this->lzma, compression_level, LZMA_CHECK_CRC32) != LZMA_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
|
||||
}
|
||||
@@ -2577,7 +2577,7 @@ struct LZMASaveFilter : SaveFilter {
|
||||
* @param len Amount of bytes to write.
|
||||
* @param action Action for lzma_code.
|
||||
*/
|
||||
void WriteLoop(byte *p, size_t len, lzma_action action)
|
||||
void WriteLoop(uint8_t *p, size_t len, lzma_action action)
|
||||
{
|
||||
size_t n;
|
||||
this->lzma.next_in = p;
|
||||
@@ -2597,7 +2597,7 @@ struct LZMASaveFilter : SaveFilter {
|
||||
} while (this->lzma.avail_in || !this->lzma.avail_out);
|
||||
}
|
||||
|
||||
void Write(byte *buf, size_t size) override
|
||||
void Write(uint8_t *buf, size_t size) override
|
||||
{
|
||||
this->WriteLoop(buf, size, LZMA_RUN);
|
||||
}
|
||||
@@ -2621,11 +2621,11 @@ struct SaveLoadFormat {
|
||||
uint32_t tag; ///< the 4-letter tag by which it is identified in the savegame
|
||||
|
||||
std::shared_ptr<LoadFilter> (*init_load)(std::shared_ptr<LoadFilter> chain); ///< Constructor for the load filter.
|
||||
std::shared_ptr<SaveFilter> (*init_write)(std::shared_ptr<SaveFilter> chain, byte compression); ///< Constructor for the save filter.
|
||||
std::shared_ptr<SaveFilter> (*init_write)(std::shared_ptr<SaveFilter> chain, uint8_t compression); ///< Constructor for the save filter.
|
||||
|
||||
byte min_compression; ///< the minimum compression level of this format
|
||||
byte default_compression; ///< the default compression level of this format
|
||||
byte max_compression; ///< the maximum compression level of this format
|
||||
uint8_t min_compression; ///< the minimum compression level of this format
|
||||
uint8_t default_compression; ///< the default compression level of this format
|
||||
uint8_t max_compression; ///< the maximum compression level of this format
|
||||
};
|
||||
|
||||
/** The different saveload formats known/understood by OpenTTD. */
|
||||
@@ -2665,7 +2665,7 @@ static const SaveLoadFormat _saveload_formats[] = {
|
||||
* @param compression_level Output for telling what compression level we want.
|
||||
* @return Pointer to SaveLoadFormat struct giving all characteristics of this type of savegame
|
||||
*/
|
||||
static const SaveLoadFormat *GetSavegameFormat(const std::string &full_name, byte *compression_level)
|
||||
static const SaveLoadFormat *GetSavegameFormat(const std::string &full_name, uint8_t *compression_level)
|
||||
{
|
||||
const SaveLoadFormat *def = lastof(_saveload_formats);
|
||||
|
||||
@@ -2786,12 +2786,12 @@ static void SaveFileError()
|
||||
static SaveOrLoadResult SaveFileToDisk(bool threaded)
|
||||
{
|
||||
try {
|
||||
byte compression;
|
||||
uint8_t compression;
|
||||
const SaveLoadFormat *fmt = GetSavegameFormat(_savegame_format, &compression);
|
||||
|
||||
/* We have written our stuff to memory, now write it to file! */
|
||||
uint32_t hdr[2] = { fmt->tag, TO_BE32(SAVEGAME_VERSION << 16) };
|
||||
_sl.sf->Write((byte*)hdr, sizeof(hdr));
|
||||
_sl.sf->Write((uint8_t*)hdr, sizeof(hdr));
|
||||
|
||||
_sl.sf = fmt->init_write(_sl.sf, compression);
|
||||
_sl.dumper->Flush(_sl.sf);
|
||||
@@ -2902,7 +2902,7 @@ static SaveOrLoadResult DoLoad(std::shared_ptr<LoadFilter> reader, bool load_che
|
||||
}
|
||||
|
||||
uint32_t hdr[2];
|
||||
if (_sl.lf->Read((byte*)hdr, sizeof(hdr)) != sizeof(hdr)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
|
||||
if (_sl.lf->Read((uint8_t*)hdr, sizeof(hdr)) != sizeof(hdr)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
|
||||
|
||||
/* see if we have any loader for this type. */
|
||||
const SaveLoadFormat *fmt = _saveload_formats;
|
||||
|
@@ -674,7 +674,7 @@ enum VarTypes {
|
||||
typedef uint32_t VarType;
|
||||
|
||||
/** Type of data saved. */
|
||||
enum SaveLoadType : byte {
|
||||
enum SaveLoadType : uint8_t {
|
||||
SL_VAR = 0, ///< Save/load a variable.
|
||||
SL_REF = 1, ///< Save/load a reference.
|
||||
SL_STRUCT = 2, ///< Save/load a struct.
|
||||
@@ -1212,10 +1212,10 @@ inline constexpr bool SlCheckVarSize(SaveLoadType cmd, VarType type, size_t leng
|
||||
* @param minor Minor number of the version to check against. If \a minor is 0 or not specified, only the major number is checked.
|
||||
* @return Savegame version is earlier than the specified version.
|
||||
*/
|
||||
inline bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor = 0)
|
||||
inline bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor = 0)
|
||||
{
|
||||
extern SaveLoadVersion _sl_version;
|
||||
extern byte _sl_minor_version;
|
||||
extern uint8_t _sl_minor_version;
|
||||
return _sl_version < major || (minor > 0 && _sl_version == major && _sl_minor_version < minor);
|
||||
}
|
||||
|
||||
@@ -1278,8 +1278,8 @@ void SlSetLength(size_t length);
|
||||
size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld);
|
||||
size_t SlCalcObjLength(const void *object, const SaveLoadTable &slt);
|
||||
|
||||
byte SlReadByte();
|
||||
void SlWriteByte(byte b);
|
||||
uint8_t SlReadByte();
|
||||
void SlWriteByte(uint8_t b);
|
||||
|
||||
void SlGlobList(const SaveLoadTable &slt);
|
||||
void SlCopy(void *object, size_t length, VarType conv);
|
||||
|
@@ -34,7 +34,7 @@ struct LoadFilter {
|
||||
* @param len The number of bytes to read.
|
||||
* @return The number of actually read bytes.
|
||||
*/
|
||||
virtual size_t Read(byte *buf, size_t len) = 0;
|
||||
virtual size_t Read(uint8_t *buf, size_t len) = 0;
|
||||
|
||||
/**
|
||||
* Reset this filter to read from the beginning of the file.
|
||||
@@ -78,7 +78,7 @@ struct SaveFilter {
|
||||
* @param buf The bytes to write.
|
||||
* @param len The number of bytes to write.
|
||||
*/
|
||||
virtual void Write(byte *buf, size_t len) = 0;
|
||||
virtual void Write(uint8_t *buf, size_t len) = 0;
|
||||
|
||||
/**
|
||||
* Prepare everything to finish writing the savegame.
|
||||
@@ -95,7 +95,7 @@ struct SaveFilter {
|
||||
* @param compression_level The requested level of compression.
|
||||
* @tparam T The type of save filter to create.
|
||||
*/
|
||||
template <typename T> std::shared_ptr<SaveFilter> CreateSaveFilter(std::shared_ptr<SaveFilter> chain, byte compression_level)
|
||||
template <typename T> std::shared_ptr<SaveFilter> CreateSaveFilter(std::shared_ptr<SaveFilter> chain, uint8_t compression_level)
|
||||
{
|
||||
return std::make_shared<T>(chain, compression_level);
|
||||
}
|
||||
|
@@ -70,7 +70,7 @@ std::string CopyFromOldName(StringID id)
|
||||
std::ostringstream tmp;
|
||||
std::ostreambuf_iterator<char> strto(tmp);
|
||||
for (; *strfrom != '\0'; strfrom++) {
|
||||
char32_t c = (byte)*strfrom;
|
||||
char32_t c = (uint8_t)*strfrom;
|
||||
|
||||
/* Map from non-ISO8859-15 characters to UTF-8. */
|
||||
switch (c) {
|
||||
|
@@ -249,7 +249,7 @@ static void CheckValidVehicles()
|
||||
}
|
||||
}
|
||||
|
||||
extern byte _age_cargo_skip_counter; // From misc_sl.cpp
|
||||
extern uint8_t _age_cargo_skip_counter; // From misc_sl.cpp
|
||||
|
||||
/** Called after load to update coordinates */
|
||||
void AfterLoadVehicles(bool part_of_load)
|
||||
|
Reference in New Issue
Block a user