Adding of _t to (u)int types, and WChar to char32_t

See: eaae0bb5e
This commit is contained in:
Jonathan G Rennison
2024-01-07 16:41:53 +00:00
parent 55d78a23be
commit 97e6f3062e
655 changed files with 7555 additions and 7555 deletions

View File

@@ -14,7 +14,7 @@
/** stub save header struct */
struct LongBridgeSignalStorageStub {
uint32 length;
uint32_t length;
};
static const SaveLoad _long_bridge_signal_storage_stub_desc[] = {
@@ -36,9 +36,9 @@ static void Load_XBSS()
static void RealSave_XBSS(const LongBridgeSignalStorage *lbss)
{
LongBridgeSignalStorageStub stub;
stub.length = (uint32)lbss->signal_red_bits.size();
stub.length = (uint32_t)lbss->signal_red_bits.size();
SlObject(&stub, _long_bridge_signal_storage_stub_desc);
SlArray(const_cast<uint64*>(lbss->signal_red_bits.data()), stub.length, SLE_UINT64);
SlArray(const_cast<uint64_t*>(lbss->signal_red_bits.data()), stub.length, SLE_UINT64);
}
static void Save_XBSS()
@@ -52,7 +52,7 @@ static void Save_XBSS()
static void Load_XBST()
{
size_t count = SlGetFieldLength() / sizeof(uint32);
size_t count = SlGetFieldLength() / sizeof(uint32_t);
for (size_t i = 0; i < count; i++) {
_bridge_signal_style_map.insert(SlReadUint32());
}
@@ -60,8 +60,8 @@ static void Load_XBST()
static void Save_XBST()
{
SlSetLength(_bridge_signal_style_map.size() * sizeof(uint32));
for (uint32 val : _bridge_signal_style_map) {
SlSetLength(_bridge_signal_style_map.size() * sizeof(uint32_t));
for (uint32_t val : _bridge_signal_style_map) {
SlWriteUint32(val);
}
}

View File

@@ -17,7 +17,7 @@
/** Temporary storage of cargo monitoring data for loading or saving it. */
struct TempStorage {
CargoMonitorID number;
uint32 amount;
uint32_t amount;
};
/** Description of the #TempStorage structure for the purpose of load and save. */
@@ -73,7 +73,7 @@ static void LoadDelivery()
if (fix) storage.number = FixupCargoMonitor(storage.number);
std::pair<CargoMonitorID, uint32> p(storage.number, storage.amount);
std::pair<CargoMonitorID, uint32_t> p(storage.number, storage.amount);
_cargo_deliveries.insert(p);
}
}
@@ -111,7 +111,7 @@ static void LoadPickup()
if (fix) storage.number = FixupCargoMonitor(storage.number);
std::pair<CargoMonitorID, uint32> p(storage.number, storage.amount);
std::pair<CargoMonitorID, uint32_t> p(storage.number, storage.amount);
_cargo_pickups.insert(p);
}
}

View File

@@ -17,7 +17,7 @@
#include "../safeguards.h"
extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
extern btree::btree_map<uint64_t, Money> _cargo_packet_deferred_payments;
/**
* Savegame conversion for cargopackets.
@@ -223,8 +223,8 @@ void Load_CPDP()
uint last_cargo_packet_id = std::numeric_limits<uint32_t>::max();
for (uint i = 0; i < count; i++) {
uint64 k = SlReadUint64();
uint64 v = SlReadUint64();
uint64_t k = SlReadUint64();
uint64_t v = SlReadUint64();
_cargo_packet_deferred_payments[k] = v;
if (k >> 32 != last_cargo_packet_id) {
last_cargo_packet_id = k >> 32;

View File

@@ -106,12 +106,12 @@ static void Load_CHTX()
CheatsExtLoad current_cheat;
uint32 chunk_flags = SlReadUint32();
uint32_t chunk_flags = SlReadUint32();
// flags are not in use yet, reserve for future expansion
if (chunk_flags != 0) SlErrorCorruptFmt("CHTX chunk: unknown chunk header flags: 0x%X", chunk_flags);
uint32 cheat_count = SlReadUint32();
for (uint32 i = 0; i < cheat_count; i++) {
uint32_t cheat_count = SlReadUint32();
for (uint32_t i = 0; i < cheat_count; i++) {
SlObject(&current_cheat, _cheats_ext_load_desc);
bool found = false;
@@ -148,7 +148,7 @@ static void Save_CHTX()
SlAutolength([](void *) {
SlWriteUint32(0); // flags
SlWriteUint32((uint32)(lengthof(_extra_cheat_descs) + _unknown_cheats.size())); // cheat count
SlWriteUint32((uint32_t)(lengthof(_extra_cheat_descs) + _unknown_cheats.size())); // cheat count
for (uint j = 0; j < lengthof(_extra_cheat_descs); j++) {
CheatsExtSave save = { _extra_cheat_descs[j].name, *(_extra_cheat_descs[j].cht) };
@@ -165,9 +165,9 @@ static void Save_CHTX()
* Internal structure used in SaveSettingsPatx() and SaveSettingsPlyx()
*/
struct SettingsExtSave {
uint32 flags;
uint32_t flags;
const char *name;
uint32 setting_length;
uint32_t setting_length;
};
static const SaveLoad _settings_ext_save_desc[] = {

View File

@@ -48,7 +48,7 @@
* @param face the face in the old format
* @return the face in the new format
*/
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face)
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32_t face)
{
CompanyManagerFace cmf = 0;
GenderEthnicity ge = GE_WM;
@@ -365,7 +365,7 @@ static const SaveLoad _company_economy_desc[] = {
/* We do need to read this single value, as the bigger it gets, the more data is stored */
struct CompanyOldAI {
uint8 num_build_rec;
uint8_t num_build_rec;
};
static const SaveLoad _company_ai_desc[] = {
@@ -584,7 +584,7 @@ static void Load_PLYP()
}
if (!_network_server) {
extern CompanyMask _saved_PLYP_invalid_mask;
extern std::vector<uint8> _saved_PLYP_data;
extern std::vector<uint8_t> _saved_PLYP_data;
_saved_PLYP_invalid_mask = invalid_mask;
_saved_PLYP_data.resize(size);
@@ -592,7 +592,7 @@ static void Load_PLYP()
return;
}
uint8 token[16];
uint8_t token[16];
ReadBuffer::GetCurrent()->CopyBytes(token, 16);
if (memcmp(token, _network_company_password_storage_token, 16) != 0) {
DEBUG(sl, 2, "Skipping encrypted company passwords");
@@ -600,25 +600,25 @@ static void Load_PLYP()
return;
}
uint8 nonce[24];
uint8 mac[16];
uint8_t nonce[24];
uint8_t mac[16];
ReadBuffer::GetCurrent()->CopyBytes(nonce, 24);
ReadBuffer::GetCurrent()->CopyBytes(mac, 16);
std::vector<uint8> buffer(size - 16 - 24 - 16);
std::vector<uint8_t> buffer(size - 16 - 24 - 16);
ReadBuffer::GetCurrent()->CopyBytes(buffer.data(), buffer.size());
if (crypto_aead_unlock(buffer.data(), mac, _network_company_password_storage_key, nonce, nullptr, 0, buffer.data(), buffer.size()) == 0) {
SlLoadFromBuffer(buffer.data(), buffer.size(), [invalid_mask]() {
_network_company_server_id.resize(SlReadUint32());
ReadBuffer::GetCurrent()->CopyBytes((uint8 *)_network_company_server_id.data(), _network_company_server_id.size());
ReadBuffer::GetCurrent()->CopyBytes((uint8_t *)_network_company_server_id.data(), _network_company_server_id.size());
while (true) {
uint16 cid = SlReadUint16();
uint16_t cid = SlReadUint16();
if (cid >= MAX_COMPANIES) break;
std::string password;
password.resize(SlReadUint32());
ReadBuffer::GetCurrent()->CopyBytes((uint8 *)password.data(), password.size());
ReadBuffer::GetCurrent()->CopyBytes((uint8_t *)password.data(), password.size());
if (!HasBit(invalid_mask, cid)) {
NetworkServerSetCompanyPassword((CompanyID)cid, password, true);
}
@@ -640,19 +640,19 @@ static void Save_PLYP()
}
if (!_network_server) {
extern CompanyMask _saved_PLYP_invalid_mask;
extern std::vector<uint8> _saved_PLYP_data;
extern std::vector<uint8_t> _saved_PLYP_data;
if (_saved_PLYP_data.empty()) {
SlSetLength(0);
} else {
SlSetLength(2 + _saved_PLYP_data.size());
SlWriteUint16(_saved_PLYP_invalid_mask);
MemoryDumper::GetCurrent()->CopyBytes((const uint8 *)_saved_PLYP_data.data(), _saved_PLYP_data.size());
MemoryDumper::GetCurrent()->CopyBytes((const uint8_t *)_saved_PLYP_data.data(), _saved_PLYP_data.size());
}
return;
}
uint8 nonce[24]; /* Use only once per key: random */
uint8_t nonce[24]; /* Use only once per key: random */
if (randombytes(nonce, 24) < 0) {
/* Can't get a random nonce, just give up */
SlSetLength(0);
@@ -660,21 +660,21 @@ static void Save_PLYP()
}
std::vector<byte> buffer = SlSaveToVector([]() {
SlWriteUint32((uint32)_network_company_server_id.size());
MemoryDumper::GetCurrent()->CopyBytes((const uint8 *)_network_company_server_id.data(), _network_company_server_id.size());
SlWriteUint32((uint32_t)_network_company_server_id.size());
MemoryDumper::GetCurrent()->CopyBytes((const uint8_t *)_network_company_server_id.data(), _network_company_server_id.size());
for (const Company *c : Company::Iterate()) {
SlWriteUint16(c->index);
const std::string &password = _network_company_states[c->index].password;
SlWriteUint32((uint32)password.size());
MemoryDumper::GetCurrent()->CopyBytes((const uint8 *)password.data(), password.size());
SlWriteUint32((uint32_t)password.size());
MemoryDumper::GetCurrent()->CopyBytes((const uint8_t *)password.data(), password.size());
}
SlWriteUint16(0xFFFF);
/* Add some random length padding to not make it too obvious from the length whether passwords are set or not */
uint8 padding[256];
uint8_t padding[256];
if (randombytes(padding, 256) >= 0) {
SlWriteByte(padding[0]);
MemoryDumper::GetCurrent()->CopyBytes(padding + 1, padding[0]);
@@ -684,7 +684,7 @@ static void Save_PLYP()
});
uint8 mac[16]; /* Message authentication code */
uint8_t mac[16]; /* Message authentication code */
/* Encrypt in place */
crypto_aead_lock(buffer.data(), mac, _network_company_password_storage_key, nonce, nullptr, 0, buffer.data(), buffer.size());

View File

@@ -18,7 +18,7 @@
/** Prices in pre 126 savegames */
static void Load_PRIC()
{
/* Old games store 49 base prices, very old games store them as int32 */
/* Old games store 49 base prices, very old games store them as int32_t */
int vt = IsSavegameVersionBefore(SLV_65) ? SLE_FILE_I32 : SLE_FILE_I64;
SlArray(nullptr, 49, vt | SLE_VAR_NULL);
SlArray(nullptr, 49, SLE_FILE_U16 | SLE_VAR_NULL);

View File

@@ -54,7 +54,7 @@ static std::vector<Engine*> _temp_engine;
*/
static Engine* CallocEngine()
{
uint8 *zero = CallocT<uint8>(sizeof(Engine));
uint8_t *zero = CallocT<uint8_t>(sizeof(Engine));
Engine *engine = new (zero) Engine();
return engine;
}

View File

@@ -13,17 +13,17 @@
* chunk IDs which are associated with an extended feature, these can be discarded if the feature is discarded.
* This information is stored in the SLXI chunk, the contents of which has the following format:
*
* uint32 chunk version
* uint32 chunk flags
* uint32 number of sub chunks/features
* uint32_t chunk version
* uint32_t chunk flags
* uint32_t number of sub chunks/features
* For each of N sub chunk/feature:
* uint32 feature flags (SlxiSubChunkFlags)
* uint16 feature version
* uint32_t feature flags (SlxiSubChunkFlags)
* uint16_t feature version
* SLE_STR feature name
* uint32* extra data length [only present iff feature flags & XSCF_EXTRA_DATA_PRESENT]
* uint32_t* extra data length [only present iff feature flags & XSCF_EXTRA_DATA_PRESENT]
* N bytes extra data
* uint32* chunk ID list count [only present iff feature flags & XSCF_CHUNK_ID_LIST_PRESENT]
* N x uint32 chunk ID list
* uint32_t* chunk ID list count [only present iff feature flags & XSCF_CHUNK_ID_LIST_PRESENT]
* N x uint32_t chunk ID list
*
* Extended features as recorded in the SLXI chunk, above, MAY add, remove, change, or otherwise modify fields in chunks
* not owned by the feature and therefore not listed in the sub chunk/feature information in the SLXI chunk.
@@ -51,27 +51,27 @@
#include "../safeguards.h"
std::array<uint16, XSLFI_SIZE> _sl_xv_feature_versions; ///< array of all known feature types and their current versions
std::array<uint16, XSLFI_SIZE> _sl_xv_feature_static_versions; ///< array of all known feature types and their static current version versions
bool _sl_is_ext_version; ///< is this an extended savegame version, with more info in the SLXI chunk?
bool _sl_is_faked_ext; ///< is this a faked extended savegame version, with no SLXI chunk? See: SlXvCheckSpecialSavegameVersions.
bool _sl_maybe_springpp; ///< is this possibly a SpringPP savegame?
bool _sl_maybe_chillpp; ///< is this possibly a ChillPP v8 savegame?
bool _sl_upstream_mode; ///< load game using upstream loader
std::vector<uint32> _sl_xv_discardable_chunk_ids; ///< list of chunks IDs which we can discard if no chunk loader exists
std::string _sl_xv_version_label; ///< optional SLXI version label
SaveLoadVersion _sl_xv_upstream_version; ///< optional SLXI upstream version
std::array<uint16_t, XSLFI_SIZE> _sl_xv_feature_versions; ///< array of all known feature types and their current versions
std::array<uint16_t, XSLFI_SIZE> _sl_xv_feature_static_versions; ///< array of all known feature types and their static current version versions
bool _sl_is_ext_version; ///< is this an extended savegame version, with more info in the SLXI chunk?
bool _sl_is_faked_ext; ///< is this a faked extended savegame version, with no SLXI chunk? See: SlXvCheckSpecialSavegameVersions.
bool _sl_maybe_springpp; ///< is this possibly a SpringPP savegame?
bool _sl_maybe_chillpp; ///< is this possibly a ChillPP v8 savegame?
bool _sl_upstream_mode; ///< load game using upstream loader
std::vector<uint32_t> _sl_xv_discardable_chunk_ids; ///< list of chunks IDs which we can discard if no chunk loader exists
std::string _sl_xv_version_label; ///< optional SLXI version label
SaveLoadVersion _sl_xv_upstream_version; ///< optional SLXI upstream version
static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version of SLXI chunk
static const uint32_t _sl_xv_slxi_chunk_version = 0; ///< current version of SLXI chunk
static void loadVL(const SlxiSubChunkInfo *info, uint32 length);
static uint32 saveVL(const SlxiSubChunkInfo *info, bool dry_run);
static void loadUV(const SlxiSubChunkInfo *info, uint32 length);
static uint32 saveUV(const SlxiSubChunkInfo *info, bool dry_run);
static void loadLC(const SlxiSubChunkInfo *info, uint32 length);
static uint32 saveLC(const SlxiSubChunkInfo *info, bool dry_run);
static void loadSTC(const SlxiSubChunkInfo *info, uint32 length);
static uint32 saveSTC(const SlxiSubChunkInfo *info, bool dry_run);
static void loadVL(const SlxiSubChunkInfo *info, uint32_t length);
static uint32_t saveVL(const SlxiSubChunkInfo *info, bool dry_run);
static void loadUV(const SlxiSubChunkInfo *info, uint32_t length);
static uint32_t saveUV(const SlxiSubChunkInfo *info, bool dry_run);
static void loadLC(const SlxiSubChunkInfo *info, uint32_t length);
static uint32_t saveLC(const SlxiSubChunkInfo *info, bool dry_run);
static void loadSTC(const SlxiSubChunkInfo *info, uint32_t length);
static uint32_t saveSTC(const SlxiSubChunkInfo *info, bool dry_run);
const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_VERSION_LABEL, XSCF_IGNORABLE_ALL, 1, 1, "version_label", saveVL, loadVL, nullptr },
@@ -222,7 +222,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
* and return the combination of the two tests using the operator defined in the constructor.
* Otherwise just returns the result of the savegame version test
*/
bool SlXvFeatureTest::IsFeaturePresent(const std::array<uint16, XSLFI_SIZE> &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const
bool SlXvFeatureTest::IsFeaturePresent(const std::array<uint16_t, XSLFI_SIZE> &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const
{
bool savegame_version_ok = savegame_version >= savegame_version_from && savegame_version < savegame_version_to;
@@ -248,7 +248,7 @@ bool SlXvFeatureTest::IsFeaturePresent(const std::array<uint16, XSLFI_SIZE> &fea
/**
* Returns true if @p feature is present and has a version inclusively bounded by @p min_version and @p max_version
*/
bool SlXvIsFeaturePresent(const std::array<uint16, XSLFI_SIZE> &feature_versions, SlXvFeatureIndex feature, uint16 min_version, uint16 max_version)
bool SlXvIsFeaturePresent(const std::array<uint16_t, XSLFI_SIZE> &feature_versions, SlXvFeatureIndex feature, uint16_t min_version, uint16_t max_version)
{
assert(feature < XSLFI_SIZE);
return feature_versions[feature] >= min_version && feature_versions[feature] <= max_version;
@@ -498,7 +498,7 @@ void SlXvChillPPSpecialSavegameVersions()
/**
* Return true if this chunk has been marked as discardable
*/
bool SlXvIsChunkDiscardable(uint32 id)
bool SlXvIsChunkDiscardable(uint32_t id)
{
for (size_t i = 0; i < _sl_xv_discardable_chunk_ids.size(); i++) {
if (_sl_xv_discardable_chunk_ids[i] == id) {
@@ -512,7 +512,7 @@ bool SlXvIsChunkDiscardable(uint32 id)
* Writes a chunk ID list string to the savegame, returns the number of chunks written
* In dry run mode, only returns the number of chunk which would have been written
*/
static uint32 WriteChunkIdList(const char *chunk_list, bool dry_run)
static uint32_t WriteChunkIdList(const char *chunk_list, bool dry_run)
{
unsigned int chunk_count = 0; // number of chunks output
unsigned int id_offset = 0; // how far are we into the ID
@@ -543,10 +543,10 @@ static void Save_SLXI()
};
// calculate lengths
uint32 item_count = 0;
uint32 length = 12;
std::vector<uint32> extra_data_lengths;
std::vector<uint32> chunk_counts;
uint32_t item_count = 0;
uint32_t length = 12;
std::vector<uint32_t> extra_data_lengths;
std::vector<uint32_t> chunk_counts;
extra_data_lengths.resize(XSLFI_SIZE);
chunk_counts.resize(XSLFI_SIZE);
const SlxiSubChunkInfo *info = _sl_xv_sub_chunk_infos;
@@ -554,16 +554,16 @@ static void Save_SLXI()
if (_sl_xv_feature_versions[info->index] > 0) {
item_count++;
length += 6;
length += (uint32)SlCalcObjLength(info, _xlsi_sub_chunk_desc);
length += (uint32_t)SlCalcObjLength(info, _xlsi_sub_chunk_desc);
if (info->save_proc) {
uint32 extra_data_length = info->save_proc(info, true);
uint32_t extra_data_length = info->save_proc(info, true);
if (extra_data_length) {
extra_data_lengths[info->index] = extra_data_length;
length += 4 + extra_data_length;
}
}
if (info->chunk_list) {
uint32 chunk_count = WriteChunkIdList(info->chunk_list, true);
uint32_t chunk_count = WriteChunkIdList(info->chunk_list, true);
if (chunk_count) {
chunk_counts[info->index] = chunk_count;
length += 4 * (1 + chunk_count);
@@ -581,12 +581,12 @@ static void Save_SLXI()
// write data
info = _sl_xv_sub_chunk_infos;
for (; info->index != XSLFI_NULL; ++info) {
uint16 save_version = _sl_xv_feature_versions[info->index];
uint16_t save_version = _sl_xv_feature_versions[info->index];
if (save_version > 0) {
SlxiSubChunkFlags flags = info->flags;
assert(!(flags & (XSCF_EXTRA_DATA_PRESENT | XSCF_CHUNK_ID_LIST_PRESENT)));
uint32 extra_data_length = extra_data_lengths[info->index];
uint32 chunk_count = chunk_counts[info->index];
uint32_t extra_data_length = extra_data_lengths[info->index];
uint32_t chunk_count = chunk_counts[info->index];
if (extra_data_length > 0) flags |= XSCF_EXTRA_DATA_PRESENT;
if (chunk_count > 0) flags |= XSCF_CHUNK_ID_LIST_PRESENT;
SlWriteUint32(flags);
@@ -618,10 +618,10 @@ static void Load_SLXI()
SlXvResetState();
_sl_is_ext_version = true;
uint32 version = SlReadUint32();
uint32_t version = SlReadUint32();
if (version > _sl_xv_slxi_chunk_version) SlErrorCorruptFmt("SLXI chunk: version: %u is too new (expected max: %u)", version, _sl_xv_slxi_chunk_version);
uint32 chunk_flags = SlReadUint32();
uint32_t chunk_flags = SlReadUint32();
// flags are not in use yet, reserve for future expansion
if (chunk_flags != 0) SlErrorCorruptFmt("SLXI chunk: unknown chunk header flags: 0x%X", chunk_flags);
@@ -630,15 +630,15 @@ static void Load_SLXI()
SLEG_STR(name_buffer, SLE_STRB),
};
auto version_error = [](StringID str, const char *feature, int64 p1, int64 p2) {
auto version_error = [](StringID str, const char *feature, int64_t p1, int64_t p2) {
auto tmp_params = MakeParameters(_sl_xv_version_label.empty() ? STR_EMPTY : STR_GAME_SAVELOAD_FROM_VERSION, _sl_xv_version_label, feature, p1, p2);
SlError(STR_JUST_RAW_STRING, GetStringWithArgs(str, tmp_params));
};
uint32 item_count = SlReadUint32();
for (uint32 i = 0; i < item_count; i++) {
uint32_t item_count = SlReadUint32();
for (uint32_t i = 0; i < item_count; i++) {
SlxiSubChunkFlags flags = static_cast<SlxiSubChunkFlags>(SlReadUint32());
uint16 version = SlReadUint16();
uint16_t version = SlReadUint16();
SlGlobList(xlsi_sub_chunk_name_desc);
// linearly scan through feature list until found name match
@@ -669,7 +669,7 @@ static void Load_SLXI()
_sl_xv_feature_versions[info->index] = version;
if (flags & XSCF_EXTRA_DATA_PRESENT) {
uint32 extra_data_size = SlReadUint32();
uint32_t extra_data_size = SlReadUint32();
if (extra_data_size) {
if (info->load_proc) {
size_t read = SlGetBytesRead();
@@ -701,9 +701,9 @@ static void Load_SLXI()
// at this point the extra data field should have been consumed
// handle chunk ID list field
if (flags & XSCF_CHUNK_ID_LIST_PRESENT) {
uint32 chunk_count = SlReadUint32();
for (uint32 j = 0; j < chunk_count; j++) {
uint32 chunk_id = SlReadUint32();
uint32_t chunk_count = SlReadUint32();
for (uint32_t j = 0; j < chunk_count; j++) {
uint32_t chunk_id = SlReadUint32();
if (discard_chunks) {
_sl_xv_discardable_chunk_ids.push_back(chunk_id);
DEBUG(sl, 2, "SLXI chunk: unknown feature: '%s', discarding chunk: %c%c%c%c", name_buffer, chunk_id >> 24, chunk_id >> 16, chunk_id >> 8, chunk_id);
@@ -713,27 +713,27 @@ static void Load_SLXI()
}
}
static void IgnoreWrongLengthExtraData(const SlxiSubChunkInfo *info, uint32 length)
static void IgnoreWrongLengthExtraData(const SlxiSubChunkInfo *info, uint32_t length)
{
DEBUG(sl, 1, "SLXI chunk: feature: '%s', version: %d, has data of wrong length: %u", info->name, _sl_xv_feature_versions[info->index], length);
ReadBuffer::GetCurrent()->SkipBytes(length);
}
static void loadVL(const SlxiSubChunkInfo *info, uint32 length)
static void loadVL(const SlxiSubChunkInfo *info, uint32_t length)
{
_sl_xv_version_label.resize(length);
ReadBuffer::GetCurrent()->CopyBytes(reinterpret_cast<byte *>(_sl_xv_version_label.data()), length);
DEBUG(sl, 2, "SLXI version label: %s", _sl_xv_version_label.c_str());
}
static uint32 saveVL(const SlxiSubChunkInfo *info, bool dry_run)
static uint32_t saveVL(const SlxiSubChunkInfo *info, bool dry_run)
{
const size_t length = strlen(_openttd_revision);
if (!dry_run) MemoryDumper::GetCurrent()->CopyBytes(reinterpret_cast<const byte *>(_openttd_revision), length);
return static_cast<uint32>(length);
return static_cast<uint32_t>(length);
}
static void loadUV(const SlxiSubChunkInfo *info, uint32 length)
static void loadUV(const SlxiSubChunkInfo *info, uint32_t length)
{
if (length == 2) {
_sl_xv_upstream_version = (SaveLoadVersion)SlReadUint16();
@@ -743,13 +743,13 @@ static void loadUV(const SlxiSubChunkInfo *info, uint32 length)
}
}
static uint32 saveUV(const SlxiSubChunkInfo *info, bool dry_run)
static uint32_t saveUV(const SlxiSubChunkInfo *info, bool dry_run)
{
if (!dry_run) SlWriteUint16(SL_MAX_VERSION - 1);
return 2;
}
static void loadLC(const SlxiSubChunkInfo *info, uint32 length)
static void loadLC(const SlxiSubChunkInfo *info, uint32_t length)
{
if (length == 1) {
_loaded_local_company = (CompanyID) ReadBuffer::GetCurrent()->ReadByte();
@@ -758,15 +758,15 @@ static void loadLC(const SlxiSubChunkInfo *info, uint32 length)
}
}
static uint32 saveLC(const SlxiSubChunkInfo *info, bool dry_run)
static uint32_t saveLC(const SlxiSubChunkInfo *info, bool dry_run)
{
if (!dry_run) MemoryDumper::GetCurrent()->WriteByte(_local_company);
return 1;
}
static void loadSTC(const SlxiSubChunkInfo *info, uint32 length)
static void loadSTC(const SlxiSubChunkInfo *info, uint32_t length)
{
extern uint64 _station_tile_cache_hash;
extern uint64_t _station_tile_cache_hash;
if (length == 8) {
_station_tile_cache_hash = SlReadUint64();
} else {
@@ -774,9 +774,9 @@ static void loadSTC(const SlxiSubChunkInfo *info, uint32 length)
}
}
static uint32 saveSTC(const SlxiSubChunkInfo *info, bool dry_run)
static uint32_t saveSTC(const SlxiSubChunkInfo *info, bool dry_run)
{
extern uint64 _station_tile_cache_hash;
extern uint64_t _station_tile_cache_hash;
if (!dry_run) SlWriteUint64(_station_tile_cache_hash);
return 8;
}

View File

@@ -16,7 +16,7 @@
#include <array>
#include <vector>
enum SaveLoadVersion : uint16;
enum SaveLoadVersion : uint16_t;
/**
* List of extended features, each feature has its own (16 bit) version
@@ -173,8 +173,8 @@ enum SlXvFeatureIndex {
XSLFI_SIZE, ///< Total count of features, including null feature
};
extern std::array<uint16, XSLFI_SIZE> _sl_xv_feature_versions;
extern std::array<uint16, XSLFI_SIZE> _sl_xv_feature_static_versions;
extern std::array<uint16_t, XSLFI_SIZE> _sl_xv_feature_versions;
extern std::array<uint16_t, XSLFI_SIZE> _sl_xv_feature_static_versions;
/**
* Operator to use when combining traditional savegame number test with an extended feature version test
@@ -188,11 +188,11 @@ enum SlXvFeatureTestOperator {
* Structure to describe an extended feature version test, and how it combines with a traditional savegame version test
*/
struct SlXvFeatureTest {
using TestFunctorPtr = bool (*)(uint16, bool, const std::array<uint16, XSLFI_SIZE> &); ///< Return true if feature present, first parameter is standard savegame version, second is whether standard savegame version is within bounds
using TestFunctorPtr = bool (*)(uint16_t, bool, const std::array<uint16_t, XSLFI_SIZE> &); ///< Return true if feature present, first parameter is standard savegame version, second is whether standard savegame version is within bounds
private:
uint16 min_version;
uint16 max_version;
uint16_t min_version;
uint16_t max_version;
SlXvFeatureIndex feature;
SlXvFeatureTestOperator op;
TestFunctorPtr functor = nullptr;
@@ -201,13 +201,13 @@ public:
SlXvFeatureTest()
: min_version(0), max_version(0), feature(XSLFI_NULL), op(XSLFTO_OR) { }
SlXvFeatureTest(SlXvFeatureTestOperator op_, SlXvFeatureIndex feature_, uint16 min_version_ = 1, uint16 max_version_ = 0xFFFF)
SlXvFeatureTest(SlXvFeatureTestOperator op_, SlXvFeatureIndex feature_, uint16_t min_version_ = 1, uint16_t max_version_ = 0xFFFF)
: min_version(min_version_), max_version(max_version_), feature(feature_), op(op_) { }
SlXvFeatureTest(TestFunctorPtr functor_)
: min_version(0), max_version(0), feature(XSLFI_NULL), op(XSLFTO_OR), functor(functor_) { }
bool IsFeaturePresent(const std::array<uint16, XSLFI_SIZE> &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const;
bool IsFeaturePresent(const std::array<uint16_t, XSLFI_SIZE> &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const;
inline bool IsFeaturePresent(SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const
{
@@ -215,9 +215,9 @@ public:
}
};
bool SlXvIsFeaturePresent(const std::array<uint16, XSLFI_SIZE> &feature_versions, SlXvFeatureIndex feature, uint16 min_version = 1, uint16 max_version = 0xFFFF);
bool SlXvIsFeaturePresent(const std::array<uint16_t, XSLFI_SIZE> &feature_versions, SlXvFeatureIndex feature, uint16_t min_version = 1, uint16_t max_version = 0xFFFF);
inline bool SlXvIsFeaturePresent(SlXvFeatureIndex feature, uint16 min_version = 1, uint16 max_version = 0xFFFF)
inline bool SlXvIsFeaturePresent(SlXvFeatureIndex feature, uint16_t min_version = 1, uint16_t max_version = 0xFFFF)
{
return SlXvIsFeaturePresent(_sl_xv_feature_versions, feature, min_version, max_version);
}
@@ -225,7 +225,7 @@ inline bool SlXvIsFeaturePresent(SlXvFeatureIndex feature, uint16 min_version =
/**
* Returns true if @p feature is missing (i.e. has a version of 0, or less than the specified minimum version)
*/
inline bool SlXvIsFeatureMissing(SlXvFeatureIndex feature, uint16 min_version = 1)
inline bool SlXvIsFeatureMissing(SlXvFeatureIndex feature, uint16_t min_version = 1)
{
return !SlXvIsFeaturePresent(feature, min_version);
}
@@ -233,7 +233,7 @@ inline bool SlXvIsFeatureMissing(SlXvFeatureIndex feature, uint16 min_version =
/**
* Returns true if @p feature is missing (i.e. has a version of 0, or less than the specified minimum version)
*/
inline bool SlXvIsFeatureMissing(const std::array<uint16, XSLFI_SIZE> &feature_versions, SlXvFeatureIndex feature, uint16 min_version = 1)
inline bool SlXvIsFeatureMissing(const std::array<uint16_t, XSLFI_SIZE> &feature_versions, SlXvFeatureIndex feature, uint16_t min_version = 1)
{
return !SlXvIsFeaturePresent(feature_versions, feature, min_version);
}
@@ -257,15 +257,15 @@ DECLARE_ENUM_AS_BIT_SET(SlxiSubChunkFlags)
struct SlxiSubChunkInfo;
typedef uint32 SlxiSubChunkSaveProc(const SlxiSubChunkInfo *info, bool dry_run); ///< sub chunk save procedure type, must return length and write no data when dry_run is true
typedef void SlxiSubChunkLoadProc(const SlxiSubChunkInfo *info, uint32 length); ///< sub chunk load procedure, must consume length bytes
typedef uint32_t SlxiSubChunkSaveProc(const SlxiSubChunkInfo *info, bool dry_run); ///< sub chunk save procedure type, must return length and write no data when dry_run is true
typedef void SlxiSubChunkLoadProc(const SlxiSubChunkInfo *info, uint32_t length); ///< sub chunk load procedure, must consume length bytes
/** Handlers and description of chunk. */
struct SlxiSubChunkInfo {
SlXvFeatureIndex index; ///< feature index, this is saved
SlxiSubChunkFlags flags; ///< flags, this is saved
uint16 save_version; ///< version to save
uint16 max_version; ///< maximum version to accept on load
uint16_t save_version; ///< version to save
uint16_t max_version; ///< maximum version to accept on load
const char *name; ///< feature name, this *IS* saved, so must be globally unique
SlxiSubChunkSaveProc *save_proc; ///< save procedure of the sub chunk, this may be nullptr in which case no extra chunk data is saved
SlxiSubChunkLoadProc *load_proc; ///< load procedure of the sub chunk, this may be nullptr in which case the extra chunk data must be missing or of 0 length
@@ -279,6 +279,6 @@ void SlXvSetStaticCurrentVersions();
bool SlXvCheckSpecialSavegameVersions();
bool SlXvIsChunkDiscardable(uint32 id);
bool SlXvIsChunkDiscardable(uint32_t id);
#endif /* SL_EXTENDED_VER_SL_H */

View File

@@ -99,7 +99,7 @@ void ResetLabelMaps()
/** Container for a label for SaveLoad system */
struct LabelObject {
uint32 label;
uint32_t label;
};
static const SaveLoad _label_object_desc[] = {

View File

@@ -20,7 +20,7 @@
typedef LinkGraph::BaseNode Node;
typedef LinkGraph::BaseEdge Edge;
static uint16 _num_nodes;
static uint16_t _num_nodes;
/**
* Get a SaveLoad array for a link graph.
@@ -153,7 +153,7 @@ static void FilterDescs()
*/
void Save_LinkGraph(LinkGraph &lg)
{
uint16 size = lg.Size();
uint16_t size = lg.Size();
auto edge_iter = lg.edges.begin();
auto edge_end = lg.edges.end();
for (NodeID from = 0; from < size; ++from) {

View File

@@ -21,8 +21,8 @@
#include "../safeguards.h"
static uint32 _map_dim_x;
static uint32 _map_dim_y;
static uint32_t _map_dim_x;
static uint32_t _map_dim_y;
extern bool _sl_maybe_chillpp;
@@ -88,7 +88,7 @@ static void Load_MAPH()
if (SlXvIsFeaturePresent(XSLFI_CHILLPP)) {
if (SlGetFieldLength() != 0) {
_sl_xv_feature_versions[XSLFI_HEIGHT_8_BIT] = 2;
std::array<uint16, MAP_SL_BUF_SIZE> buf;
std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
TileIndex size = MapSize();
for (TileIndex i = 0; i != size;) {
@@ -121,7 +121,7 @@ static void Load_MAP1()
static void Load_MAP2()
{
std::array<uint16, MAP_SL_BUF_SIZE> buf;
std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
TileIndex size = MapSize();
for (TileIndex i = 0; i != size;) {
@@ -203,7 +203,7 @@ static void Load_MAP7()
static void Load_MAP8()
{
std::array<uint16, MAP_SL_BUF_SIZE> buf;
std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
TileIndex size = MapSize();
for (TileIndex i = 0; i != size;) {
@@ -228,8 +228,8 @@ static void Load_WMAP()
reader->CheckBytes(8);
_m[i].type = reader->RawReadByte();
_m[i].height = reader->RawReadByte();
uint16 m2 = reader->RawReadByte();
m2 |= ((uint16) reader->RawReadByte()) << 8;
uint16_t m2 = reader->RawReadByte();
m2 |= ((uint16_t) reader->RawReadByte()) << 8;
_m[i].m2 = m2;
_m[i].m1 = reader->RawReadByte();
_m[i].m3 = reader->RawReadByte();
@@ -252,8 +252,8 @@ static void Load_WMAP()
reader->CheckBytes(4);
_me[i].m6 = reader->RawReadByte();
_me[i].m7 = reader->RawReadByte();
uint16 m8 = reader->RawReadByte();
m8 |= ((uint16) reader->RawReadByte()) << 8;
uint16_t m8 = reader->RawReadByte();
m8 |= ((uint16_t) reader->RawReadByte()) << 8;
_me[i].m8 = m8;
}
#endif
@@ -298,52 +298,52 @@ static void Save_WMAP()
}
struct MAPT {
typedef uint8 FieldT;
typedef uint8_t FieldT;
static const FieldT &GetField(TileIndex t) { return _m[t].type; }
};
struct MAPH {
typedef uint8 FieldT;
typedef uint8_t FieldT;
static const FieldT &GetField(TileIndex t) { return _m[t].height; }
};
struct MAP1 {
typedef uint8 FieldT;
typedef uint8_t FieldT;
static const FieldT &GetField(TileIndex t) { return _m[t].m1; }
};
struct MAP2 {
typedef uint16 FieldT;
typedef uint16_t FieldT;
static const FieldT &GetField(TileIndex t) { return _m[t].m2; }
};
struct MAP3 {
typedef uint8 FieldT;
typedef uint8_t FieldT;
static const FieldT &GetField(TileIndex t) { return _m[t].m3; }
};
struct MAP4 {
typedef uint8 FieldT;
typedef uint8_t FieldT;
static const FieldT &GetField(TileIndex t) { return _m[t].m4; }
};
struct MAP5 {
typedef uint8 FieldT;
typedef uint8_t FieldT;
static const FieldT &GetField(TileIndex t) { return _m[t].m5; }
};
struct MAP6 {
typedef uint8 FieldT;
typedef uint8_t FieldT;
static const FieldT &GetField(TileIndex t) { return _me[t].m6; }
};
struct MAP7 {
typedef uint8 FieldT;
typedef uint8_t FieldT;
static const FieldT &GetField(TileIndex t) { return _me[t].m7; }
};
struct MAP8 {
typedef uint16 FieldT;
typedef uint16_t FieldT;
static const FieldT &GetField(TileIndex t) { return _me[t].m8; }
};
@@ -351,13 +351,13 @@ template <typename T>
struct MAP_VarType {};
template <>
struct MAP_VarType<uint8>
struct MAP_VarType<uint8_t>
{
static const VarType var_type = SLE_UINT8;
};
template <>
struct MAP_VarType<uint16>
struct MAP_VarType<uint16_t>
{
static const VarType var_type = SLE_UINT16;
};
@@ -377,7 +377,7 @@ static void Save_MAP()
}
}
static ChunkSaveLoadSpecialOpResult Special_WMAP(uint32 chunk_id, ChunkSaveLoadSpecialOp op)
static ChunkSaveLoadSpecialOpResult Special_WMAP(uint32_t chunk_id, ChunkSaveLoadSpecialOp op)
{
switch (op) {
case CSLSO_SHOULD_SAVE_CHUNK:
@@ -390,7 +390,7 @@ static ChunkSaveLoadSpecialOpResult Special_WMAP(uint32 chunk_id, ChunkSaveLoadS
return CSLSOR_NONE;
}
static ChunkSaveLoadSpecialOpResult Special_MAP_Chunks(uint32 chunk_id, ChunkSaveLoadSpecialOp op)
static ChunkSaveLoadSpecialOpResult Special_MAP_Chunks(uint32_t chunk_id, ChunkSaveLoadSpecialOp op)
{
switch (op) {
case CSLSO_SHOULD_SAVE_CHUNK:

View File

@@ -29,9 +29,9 @@
extern TileIndex _cur_tileloop_tile;
extern TileIndex _aux_tileloop_tile;
extern uint16 _disaster_delay;
extern uint16_t _disaster_delay;
extern byte _trees_tick_ctr;
extern uint64 _aspect_cfg_hash;
extern uint64_t _aspect_cfg_hash;
extern std::string _savegame_id;
/* Keep track of current game position */

View File

@@ -26,7 +26,7 @@
static const int TTO_HEADER_SIZE = 41;
static const int TTD_HEADER_SIZE = 49;
uint32 _bump_assert_value;
uint32_t _bump_assert_value;
static inline OldChunkType GetOldChunkType(OldChunkType type) {return (OldChunkType)GB(type, 0, 4);}
static inline OldChunkType GetOldChunkVarType(OldChunkType type) {return (OldChunkType)(GB(type, 8, 8) << 8);}
@@ -82,7 +82,7 @@ byte ReadByte(LoadgameState *ls)
if (ls->chunk_size == 0) {
/* Read new chunk */
int8 new_byte = ReadByteFromFile(ls);
int8_t new_byte = ReadByteFromFile(ls);
if (new_byte < 0) {
/* Repeat next char for new_byte times */
@@ -139,15 +139,15 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
default: break;
}
} else {
uint64 res = 0;
uint64_t res = 0;
/* Reading from the file: bits 16 to 23 have the FILE type */
switch (GetOldChunkFileType(chunk->type)) {
case OC_FILE_I8: res = (int8)ReadByte(ls); break;
case OC_FILE_I8: res = (int8_t)ReadByte(ls); break;
case OC_FILE_U8: res = ReadByte(ls); break;
case OC_FILE_I16: res = (int16)ReadUint16(ls); break;
case OC_FILE_I16: res = (int16_t)ReadUint16(ls); break;
case OC_FILE_U16: res = ReadUint16(ls); break;
case OC_FILE_I32: res = (int32)ReadUint32(ls); break;
case OC_FILE_I32: res = (int32_t)ReadUint32(ls); break;
case OC_FILE_U32: res = ReadUint32(ls); break;
default: NOT_REACHED();
}
@@ -160,14 +160,14 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
/* Write the data */
switch (GetOldChunkVarType(chunk->type)) {
case OC_VAR_I8: *(int8 *)ptr = GB(res, 0, 8); break;
case OC_VAR_U8: *(uint8 *)ptr = GB(res, 0, 8); break;
case OC_VAR_I16:*(int16 *)ptr = GB(res, 0, 16); break;
case OC_VAR_U16:*(uint16*)ptr = GB(res, 0, 16); break;
case OC_VAR_I32:*(int32 *)ptr = res; break;
case OC_VAR_U32:*(uint32*)ptr = res; break;
case OC_VAR_I64:*(int64 *)ptr = res; break;
case OC_VAR_U64:*(uint64*)ptr = res; break;
case OC_VAR_I8: *(int8_t *)ptr = GB(res, 0, 8); break;
case OC_VAR_U8: *(uint8_t *)ptr = GB(res, 0, 8); break;
case OC_VAR_I16:*(int16_t *)ptr = GB(res, 0, 16); break;
case OC_VAR_U16:*(uint16_t*)ptr = GB(res, 0, 16); break;
case OC_VAR_I32:*(int32_t *)ptr = res; break;
case OC_VAR_U32:*(uint32_t*)ptr = res; break;
case OC_VAR_I64:*(int64_t *)ptr = res; break;
case OC_VAR_U64:*(uint64_t*)ptr = res; break;
default: NOT_REACHED();
}
@@ -211,7 +211,7 @@ static void InitLoading(LoadgameState *ls)
*/
static bool VerifyOldNameChecksum(char *title, uint len)
{
uint16 sum = 0;
uint16_t sum = 0;
for (uint i = 0; i < len - 2; i++) {
sum += title[i];
sum = ROL(sum, 1);
@@ -219,7 +219,7 @@ static bool VerifyOldNameChecksum(char *title, uint len)
sum ^= 0xAAAA; // computed checksum
uint16 sum2 = title[len - 2]; // checksum in file
uint16_t sum2 = title[len - 2]; // checksum in file
SB(sum2, 8, 8, title[len - 1]);
return sum == sum2;

View File

@@ -85,7 +85,7 @@ typedef bool OldChunkProc(LoadgameState *ls, int num);
struct OldChunks {
OldChunkType type; ///< Type of field
uint32 amount; ///< Amount of fields
uint32_t amount; ///< Amount of fields
void *ptr; ///< Pointer where to save the data (may only be set if offset is 0)
uint offset; ///< Offset from basepointer (may only be set if ptr is nullptr)
@@ -110,7 +110,7 @@ inline uint16_t ReadUint16(LoadgameState *ls)
inline uint32_t ReadUint32(LoadgameState *ls)
{
uint16 x = ReadUint16(ls);
uint16_t x = ReadUint16(ls);
return x | ReadUint16(ls) << 16;
}

View File

@@ -41,10 +41,10 @@
#include "../safeguards.h"
static bool _read_ttdpatch_flags; ///< Have we (tried to) read TTDPatch extra flags?
static uint16 _old_extra_chunk_nums; ///< Number of extra TTDPatch chunks
static uint16_t _old_extra_chunk_nums; ///< Number of extra TTDPatch chunks
static byte _old_vehicle_multiplier; ///< TTDPatch vehicle multiplier
static uint8 *_old_map3;
static uint8_t *_old_map3;
void FixOldMapArray()
{
@@ -120,7 +120,7 @@ static void FixTTDDepots()
#define FIXNUM(x, y, z) (((((x) << 16) / (y)) + 1) << z)
static uint32 RemapOldTownName(uint32 townnameparts, byte old_town_name_type)
static uint32_t RemapOldTownName(uint32_t townnameparts, byte old_town_name_type)
{
switch (old_town_name_type) {
case 0: case 3: // English, American
@@ -491,9 +491,9 @@ static inline uint RemapOrderIndex(uint x)
extern TimeoutTimer<TimerGameTick> _new_competitor_timeout;
extern char *_old_name_array;
static uint32 _old_town_index;
static uint16 _old_string_id;
static uint16 _old_string_id_2;
static uint32_t _old_town_index;
static uint16_t _old_string_id;
static uint16_t _old_string_id_2;
static void ReadTTDPatchFlags()
{
@@ -610,7 +610,7 @@ static bool LoadOldTown(LoadgameState *ls, int num)
return true;
}
static uint16 _old_order;
static uint16_t _old_order;
static const OldChunks order_chunk[] = {
OCL_VAR ( OC_UINT16, 1, &_old_order ),
OCL_END()
@@ -678,9 +678,9 @@ static bool LoadOldDepot(LoadgameState *ls, int num)
}
static StationID _current_station_id;
static uint16 _waiting_acceptance;
static uint8 _cargo_source;
static uint8 _cargo_periods;
static uint16_t _waiting_acceptance;
static uint8_t _cargo_source;
static uint8_t _cargo_periods;
static const OldChunks goods_chunk[] = {
OCL_VAR ( OC_UINT16, 1, &_waiting_acceptance ),
@@ -856,7 +856,7 @@ static bool LoadOldIndustry(LoadgameState *ls, int num)
}
static CompanyID _current_company_id;
static int32 _old_yearly;
static int32_t _old_yearly;
static const OldChunks _company_yearly_chunk[] = {
OCL_VAR( OC_INT32, 1, &_old_yearly ),
@@ -1023,8 +1023,8 @@ static bool LoadOldCompany(LoadgameState *ls, int num)
return true;
}
static uint32 _old_order_ptr;
static uint16 _old_next_ptr;
static uint32_t _old_order_ptr;
static uint16_t _old_next_ptr;
static VehicleID _current_vehicle_id;
static const OldChunks vehicle_train_chunk[] = {
@@ -1124,7 +1124,7 @@ static bool LoadOldVehicleUnion(LoadgameState *ls, int)
return res;
}
static uint16 _cargo_count;
static uint16_t _cargo_count;
static const OldChunks vehicle_chunk[] = {
OCL_SVAR( OC_UINT8, Vehicle, subtype ),
@@ -1524,8 +1524,8 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int)
DEBUG(oldloader, 2, "Found %d extra chunk(s)", _old_extra_chunk_nums);
for (int i = 0; i != _old_extra_chunk_nums; i++) {
uint16 id = ReadUint16(ls);
uint32 len = ReadUint32(ls);
uint16_t id = ReadUint16(ls);
uint32_t len = ReadUint32(ls);
switch (id) {
/* List of GRFIDs, used in the savegame. 0x8004 is the new ID
@@ -1537,7 +1537,7 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int)
ClearGRFConfigList(&_grfconfig);
while (len != 0) {
uint32 grfid = ReadUint32(ls);
uint32_t grfid = ReadUint32(ls);
if (ReadByte(ls) == 1) {
GRFConfig *c = new GRFConfig("TTDP game, no information");
@@ -1574,11 +1574,11 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int)
}
extern TileIndex _cur_tileloop_tile;
extern uint16 _disaster_delay;
extern uint16_t _disaster_delay;
extern byte _trees_tick_ctr;
extern byte _age_cargo_skip_counter; // From misc_sl.cpp
extern uint8 _old_diff_level;
extern uint8 _old_units;
extern uint8_t _old_diff_level;
extern uint8_t _old_units;
static const OldChunks main_chunk[] = {
OCL_ASSERT( OC_TTD, 0 ),
OCL_ASSERT( OC_TTO, 0 ),

View File

@@ -16,12 +16,12 @@
#include "../safeguards.h"
static uint32 _jokerpp_separation_mode;
static uint32_t _jokerpp_separation_mode;
std::vector<OrderList *> _jokerpp_auto_separation;
std::vector<OrderList *> _jokerpp_non_auto_separation;
static uint16 _old_scheduled_dispatch_start_full_date_fract;
btree::btree_map<DispatchSchedule *, uint16> _old_scheduled_dispatch_start_full_date_fract_map;
static uint16_t _old_scheduled_dispatch_start_full_date_fract;
btree::btree_map<DispatchSchedule *, uint16_t> _old_scheduled_dispatch_start_full_date_fract_map;
/**
* Converts this order from an old savegame's version;
@@ -29,7 +29,7 @@ btree::btree_map<DispatchSchedule *, uint16> _old_scheduled_dispatch_start_full_
*/
void Order::ConvertFromOldSavegame()
{
uint8 old_flags = this->flags;
uint8_t old_flags = this->flags;
this->flags = 0;
/* First handle non-stop - use value from savegame if possible, else use value from config file */
@@ -83,9 +83,9 @@ void Order::ConvertFromOldSavegame()
* @param packed packed order
* @return unpacked order
*/
static Order UnpackVersion4Order(uint16 packed)
static Order UnpackVersion4Order(uint16_t packed)
{
return Order(((uint64) GB(packed, 8, 8)) << 24 | ((uint64) GB(packed, 4, 4)) << 8 | ((uint64) GB(packed, 0, 4)));
return Order(((uint64_t) GB(packed, 8, 8)) << 24 | ((uint64_t) GB(packed, 4, 4)) << 8 | ((uint64_t) GB(packed, 0, 4)));
}
/**
@@ -93,9 +93,9 @@ static Order UnpackVersion4Order(uint16 packed)
* @param packed packed order
* @return unpacked order
*/
static Order UnpackVersion5Order(uint32 packed)
static Order UnpackVersion5Order(uint32_t packed)
{
return Order(((uint64) GB(packed, 16, 16)) << 24 | ((uint64) GB(packed, 8, 8)) << 8 | ((uint64) GB(packed, 0, 8)));
return Order(((uint64_t) GB(packed, 16, 16)) << 24 | ((uint64_t) GB(packed, 8, 8)) << 8 | ((uint64_t) GB(packed, 0, 8)));
}
/**
@@ -103,7 +103,7 @@ static Order UnpackVersion5Order(uint32 packed)
* @param packed packed order
* @return unpacked order
*/
Order UnpackOldOrder(uint16 packed)
Order UnpackOldOrder(uint16_t packed)
{
Order order = UnpackVersion4Order(packed);
@@ -163,9 +163,9 @@ static void Load_ORDR()
if (IsSavegameVersionBefore(SLV_5)) {
/* Pre-version 5 had another layout for orders
* (uint16 instead of uint32) */
len /= sizeof(uint16);
uint16 *orders = MallocT<uint16>(len + 1);
* (uint16_t instead of uint32_t) */
len /= sizeof(uint16_t);
uint16_t *orders = MallocT<uint16_t>(len + 1);
SlArray(orders, len, SLE_UINT16);
@@ -176,8 +176,8 @@ static void Load_ORDR()
free(orders);
} else if (IsSavegameVersionBefore(SLV_5, 2)) {
len /= sizeof(uint32);
uint32 *orders = MallocT<uint32>(len + 1);
len /= sizeof(uint32_t);
uint32_t *orders = MallocT<uint32_t>(len + 1);
SlArray(orders, len, SLE_UINT32);

View File

@@ -27,10 +27,10 @@ static const SaveLoad _plan_desc[] = {
static void RealSave_PLAN(Plan *p)
{
SlObject(p, _plan_desc);
SlWriteUint32((uint32)p->lines.size());
SlWriteUint32((uint32_t)p->lines.size());
for (size_t i = 0; i < p->lines.size(); i++) {
PlanLine *pl = p->lines[i];
SlWriteUint32((uint32)pl->tiles.size());
SlWriteUint32((uint32_t)pl->tiles.size());
SlArray(pl->tiles.data(), pl->tiles.size(), SLE_UINT32);
}
}

View File

@@ -74,10 +74,10 @@ extern const SaveLoadVersion MAX_LOAD_SAVEGAME_VERSION = (SaveLoadVersion)(SL_MA
const SaveLoadVersion SAVEGAME_VERSION_EXT = (SaveLoadVersion)(0x8000); ///< Savegame extension indicator mask
SavegameType _savegame_type; ///< type of savegame we are loading
SavegameType _savegame_type; ///< type of savegame we are loading
FileToSaveLoad _file_to_saveload; ///< File to save or load in the openttd loop.
uint32 _ttdp_version; ///< version of TTDP savegame (if applicable)
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!
std::string _savegame_format; ///< how to compress savegames
@@ -91,12 +91,12 @@ extern bool _sl_upstream_mode;
namespace upstream_sl {
void SlNullPointers();
void SlLoadChunks();
void SlLoadChunkByID(uint32 id);
void SlLoadChunkByID(uint32_t id);
void SlLoadCheckChunks();
void SlLoadCheckChunkByID(uint32 id);
void SlLoadCheckChunkByID(uint32_t id);
void SlFixPointers();
void SlFixPointerChunkByID(uint32 id);
void SlSaveChunkChunkByID(uint32 id);
void SlFixPointerChunkByID(uint32_t id);
void SlSaveChunkChunkByID(uint32_t id);
void SlResetLoadState();
}
@@ -531,13 +531,13 @@ int SlReadUint16()
return _sl.reader->RawReadUint16();
}
uint32 SlReadUint32()
uint32_t SlReadUint32()
{
_sl.reader->CheckBytes(4);
return _sl.reader->RawReadUint32();
}
uint64 SlReadUint64()
uint64_t SlReadUint64()
{
_sl.reader->CheckBytes(8);
return _sl.reader->RawReadUint64();
@@ -552,19 +552,19 @@ void SlWriteByte(byte b)
_sl.dumper->WriteByte(b);
}
void SlWriteUint16(uint16 v)
void SlWriteUint16(uint16_t v)
{
_sl.dumper->CheckBytes(2);
_sl.dumper->RawWriteUint16(v);
}
void SlWriteUint32(uint32 v)
void SlWriteUint32(uint32_t v)
{
_sl.dumper->CheckBytes(4);
_sl.dumper->RawWriteUint32(v);
}
void SlWriteUint64(uint64 v)
void SlWriteUint64(uint64_t v)
{
_sl.dumper->CheckBytes(8);
_sl.dumper->RawWriteUint64(v);
@@ -713,7 +713,7 @@ static inline uint SlCalcConvMemLen(VarType conv)
return SlReadArrayLength();
default:
uint8 type = GetVarMemType(conv) >> 4;
uint8_t type = GetVarMemType(conv) >> 4;
assert(type < lengthof(conv_mem_size));
return conv_mem_size[type];
}
@@ -727,7 +727,7 @@ static inline uint SlCalcConvMemLen(VarType conv)
*/
static inline byte SlCalcConvFileLen(VarType conv)
{
uint8 type = GetVarFileType(conv);
uint8_t type = GetVarFileType(conv);
if (type == SLE_FILE_VEHORDERID) return SlXvIsFeaturePresent(XSLFI_MORE_VEHICLE_ORDERS) ? 2 : 1;
static const byte conv_file_size[] = {1, 1, 2, 2, 4, 4, 8, 8, 2};
assert(type < lengthof(conv_file_size));
@@ -813,7 +813,7 @@ void SlSetLength(size_t length)
* The lower 24 bits are normal
* The uppermost 4 bits are bits 24:27
*
* If we have more than 28 bits, use an extra uint32 and
* If we have more than 28 bits, use an extra uint32_t and
* signal this using the extended chunk header */
#ifdef POINTER_IS_64BIT
assert(length < (1LL << 32));
@@ -821,11 +821,11 @@ void SlSetLength(size_t length)
if (length >= (1 << 28)) {
/* write out extended chunk header */
SlWriteByte(CH_EXT_HDR);
SlWriteUint32(static_cast<uint32>(SLCEHF_BIG_RIFF));
SlWriteUint32(static_cast<uint32_t>(SLCEHF_BIG_RIFF));
}
SlWriteUint32(static_cast<uint32>((length & 0xFFFFFF) | ((length >> 24) << 28)));
SlWriteUint32(static_cast<uint32_t>((length & 0xFFFFFF) | ((length >> 24) << 28)));
if (length >= (1 << 28)) {
SlWriteUint32(static_cast<uint32>(length >> 28));
SlWriteUint32(static_cast<uint32_t>(length >> 28));
}
break;
case CH_ARRAY:
@@ -882,18 +882,18 @@ size_t SlGetFieldLength()
* type, eg one with other flags because it is parsed
* @return returns the value of the pointer-setting
*/
int64 ReadValue(const void *ptr, VarType conv)
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 *)ptr;
case SLE_VAR_U8: return *(const byte *)ptr;
case SLE_VAR_I16: return *(const int16 *)ptr;
case SLE_VAR_U16: return *(const uint16*)ptr;
case SLE_VAR_I32: return *(const int32 *)ptr;
case SLE_VAR_U32: return *(const uint32*)ptr;
case SLE_VAR_I64: return *(const int64 *)ptr;
case SLE_VAR_U64: return *(const uint64*)ptr;
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_I16: return *(const int16_t *)ptr;
case SLE_VAR_U16: return *(const uint16_t*)ptr;
case SLE_VAR_I32: return *(const int32_t *)ptr;
case SLE_VAR_U32: return *(const uint32_t*)ptr;
case SLE_VAR_I64: return *(const int64_t *)ptr;
case SLE_VAR_U64: return *(const uint64_t*)ptr;
case SLE_VAR_NULL:return 0;
default: NOT_REACHED();
}
@@ -906,18 +906,18 @@ int64 ReadValue(const void *ptr, VarType conv)
* with other flags. It is parsed upon read
* @param val the new value being given to the variable
*/
void WriteValue(void *ptr, VarType conv, int64 val)
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 *)ptr = val; break;
case SLE_VAR_U8: *(byte *)ptr = val; break;
case SLE_VAR_I16: *(int16 *)ptr = val; break;
case SLE_VAR_U16: *(uint16*)ptr = val; break;
case SLE_VAR_I32: *(int32 *)ptr = val; break;
case SLE_VAR_U32: *(uint32*)ptr = val; break;
case SLE_VAR_I64: *(int64 *)ptr = val; break;
case SLE_VAR_U64: *(uint64*)ptr = val; break;
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_I16: *(int16_t *)ptr = val; break;
case SLE_VAR_U16: *(uint16_t*)ptr = val; break;
case SLE_VAR_I32: *(int32_t *)ptr = val; break;
case SLE_VAR_U32: *(uint32_t*)ptr = val; break;
case SLE_VAR_I64: *(int64_t *)ptr = val; break;
case SLE_VAR_U64: *(uint64_t*)ptr = val; break;
case SLE_VAR_NAME: *reinterpret_cast<std::string *>(ptr) = CopyFromOldName(val); break;
case SLE_VAR_CNAME: *(TinyString*)ptr = CopyFromOldName(val); break;
case SLE_VAR_NULL: break;
@@ -938,7 +938,7 @@ static void SlSaveLoadConvGeneric(void *ptr, VarType conv)
{
switch (action) {
case SLA_SAVE: {
int64 x = ReadValue(ptr, conv);
int64_t x = ReadValue(ptr, conv);
/* Write the value to the file and check if its value is in the desired range */
switch (GetVarFileType(conv)) {
@@ -949,7 +949,7 @@ static void SlSaveLoadConvGeneric(void *ptr, VarType conv)
case SLE_FILE_VEHORDERID:
case SLE_FILE_U16:assert(x >= 0 && x <= 65535); SlWriteUint16(x);break;
case SLE_FILE_I32:
case SLE_FILE_U32: SlWriteUint32((uint32)x);break;
case SLE_FILE_U32: SlWriteUint32((uint32_t)x);break;
case SLE_FILE_I64:
case SLE_FILE_U64: SlWriteUint64(x);break;
default: NOT_REACHED();
@@ -958,21 +958,21 @@ static void SlSaveLoadConvGeneric(void *ptr, VarType conv)
}
case SLA_LOAD_CHECK:
case SLA_LOAD: {
int64 x;
int64_t x;
/* Read a value from the file */
switch (GetVarFileType(conv)) {
case SLE_FILE_I8: x = (int8 )SlReadByte(); break;
case SLE_FILE_U8: x = (byte )SlReadByte(); break;
case SLE_FILE_I16: x = (int16 )SlReadUint16(); break;
case SLE_FILE_U16: x = (uint16)SlReadUint16(); break;
case SLE_FILE_I32: x = (int32 )SlReadUint32(); break;
case SLE_FILE_U32: x = (uint32)SlReadUint32(); break;
case SLE_FILE_I64: x = (int64 )SlReadUint64(); break;
case SLE_FILE_U64: x = (uint64)SlReadUint64(); break;
case SLE_FILE_STRINGID: x = RemapOldStringID((uint16)SlReadUint16()); break;
case SLE_FILE_I8: x = (int8_t )SlReadByte(); break;
case SLE_FILE_U8: x = (byte )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;
case SLE_FILE_U32: x = (uint32_t)SlReadUint32(); break;
case SLE_FILE_I64: x = (int64_t )SlReadUint64(); break;
case SLE_FILE_U64: x = (uint64_t)SlReadUint64(); break;
case SLE_FILE_STRINGID: x = RemapOldStringID((uint16_t)SlReadUint16()); break;
case SLE_FILE_VEHORDERID:
if (SlXvIsFeaturePresent(XSLFI_MORE_VEHICLE_ORDERS)) {
x = (uint16)SlReadUint16();
x = (uint16_t)SlReadUint16();
} else {
VehicleOrderID id = (byte)SlReadByte();
x = (id == 0xFF) ? INVALID_VEH_ORDER_ID : id;
@@ -1204,7 +1204,7 @@ static inline size_t SlCalcArrayLen(size_t length, VarType conv)
* Save/Load an array.
* @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, etc.)
* @param conv VarType type of the atomic array (int, byte, uint64_t, etc.)
*/
void SlArray(void *array, size_t length, VarType conv)
{
@@ -1227,7 +1227,7 @@ void SlArray(void *array, size_t length, VarType conv)
/* used for conversion of Money 32bit->64bit */
if (conv == (SLE_FILE_I32 | SLE_VAR_I64)) {
for (uint i = 0; i < length; i++) {
((int64*)array)[i] = (int32)BSWAP32(SlReadUint32());
((int64_t*)array)[i] = (int32_t)BSWAP32(SlReadUint32());
}
return;
}
@@ -1377,7 +1377,7 @@ void SlSaveLoadRef(void *ptr, VarType conv)
{
switch (_sl.action) {
case SLA_SAVE:
SlWriteUint32((uint32)ReferenceToInt(*(void **)ptr, (SLRefType)conv));
SlWriteUint32((uint32_t)ReferenceToInt(*(void **)ptr, (SLRefType)conv));
break;
case SLA_LOAD_CHECK:
case SLA_LOAD:
@@ -1441,7 +1441,7 @@ public:
switch (_sl.action) {
case SLA_SAVE:
SlWriteUint32((uint32)list->size());
SlWriteUint32((uint32_t)list->size());
for (auto &item : *list) {
SlSaveLoadMember(cmd, &item, conv);
@@ -1526,11 +1526,11 @@ static void SlRefList(void *list, SLRefType conv)
switch (_sl.action) {
case SLA_SAVE: {
SlWriteUint32((uint32)l->size());
SlWriteUint32((uint32_t)l->size());
for (auto iter = l->begin(); iter != l->end(); ++iter) {
void *ptr = *iter;
SlWriteUint32((uint32)ReferenceToInt(ptr, conv));
SlWriteUint32((uint32_t)ReferenceToInt(ptr, conv));
}
break;
}
@@ -1579,7 +1579,7 @@ static void SlVarList(void *list, VarType conv)
switch (_sl.action) {
case SLA_SAVE: {
SlWriteUint32((uint32)l->size());
SlWriteUint32((uint32_t)l->size());
typename PtrList::iterator iter;
for (iter = l->begin(); iter != l->end(); ++iter) {
@@ -1618,14 +1618,14 @@ static inline size_t SlCalcRingLen(const void *ring, VarType conv)
{
switch (GetVarMemType(conv)) {
case SLE_VAR_BL: return SlStorageHelper<ring_buffer, bool>::SlCalcLen(ring, conv);
case SLE_VAR_I8: return SlStorageHelper<ring_buffer, int8>::SlCalcLen(ring, conv);
case SLE_VAR_U8: return SlStorageHelper<ring_buffer, uint8>::SlCalcLen(ring, conv);
case SLE_VAR_I16: return SlStorageHelper<ring_buffer, int16>::SlCalcLen(ring, conv);
case SLE_VAR_U16: return SlStorageHelper<ring_buffer, uint16>::SlCalcLen(ring, conv);
case SLE_VAR_I32: return SlStorageHelper<ring_buffer, int32>::SlCalcLen(ring, conv);
case SLE_VAR_U32: return SlStorageHelper<ring_buffer, uint32>::SlCalcLen(ring, conv);
case SLE_VAR_I64: return SlStorageHelper<ring_buffer, int64>::SlCalcLen(ring, conv);
case SLE_VAR_U64: return SlStorageHelper<ring_buffer, uint64>::SlCalcLen(ring, conv);
case SLE_VAR_I8: return SlStorageHelper<ring_buffer, int8_t>::SlCalcLen(ring, conv);
case SLE_VAR_U8: return SlStorageHelper<ring_buffer, uint8_t>::SlCalcLen(ring, conv);
case SLE_VAR_I16: return SlStorageHelper<ring_buffer, int16_t>::SlCalcLen(ring, conv);
case SLE_VAR_U16: return SlStorageHelper<ring_buffer, uint16_t>::SlCalcLen(ring, conv);
case SLE_VAR_I32: return SlStorageHelper<ring_buffer, int32_t>::SlCalcLen(ring, conv);
case SLE_VAR_U32: return SlStorageHelper<ring_buffer, uint32_t>::SlCalcLen(ring, conv);
case SLE_VAR_I64: return SlStorageHelper<ring_buffer, int64_t>::SlCalcLen(ring, conv);
case SLE_VAR_U64: return SlStorageHelper<ring_buffer, uint64_t>::SlCalcLen(ring, conv);
default: NOT_REACHED();
}
}
@@ -1639,14 +1639,14 @@ static void SlRing(void *ring, VarType conv)
{
switch (GetVarMemType(conv)) {
case SLE_VAR_BL: SlStorageHelper<ring_buffer, bool>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I8: SlStorageHelper<ring_buffer, int8>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U8: SlStorageHelper<ring_buffer, uint8>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I16: SlStorageHelper<ring_buffer, int16>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U16: SlStorageHelper<ring_buffer, uint16>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I32: SlStorageHelper<ring_buffer, int32>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U32: SlStorageHelper<ring_buffer, uint32>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I64: SlStorageHelper<ring_buffer, int64>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U64: SlStorageHelper<ring_buffer, uint64>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I8: SlStorageHelper<ring_buffer, int8_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U8: SlStorageHelper<ring_buffer, uint8_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I16: SlStorageHelper<ring_buffer, int16_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U16: SlStorageHelper<ring_buffer, uint16_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I32: SlStorageHelper<ring_buffer, int32_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U32: SlStorageHelper<ring_buffer, uint32_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I64: SlStorageHelper<ring_buffer, int64_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U64: SlStorageHelper<ring_buffer, uint64_t>::SlSaveLoad(ring, conv); break;
default: NOT_REACHED();
}
}
@@ -1705,9 +1705,9 @@ size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld)
const size_t size_len = SlCalcConvMemLen(sld.conv);
switch (size_len) {
case 1: return SlCalcVarListLen<std::vector<byte>>(GetVariableAddress(object, sld), 1);
case 2: return SlCalcVarListLen<std::vector<uint16>>(GetVariableAddress(object, sld), 2);
case 4: return SlCalcVarListLen<std::vector<uint32>>(GetVariableAddress(object, sld), 4);
case 8: return SlCalcVarListLen<std::vector<uint64>>(GetVariableAddress(object, sld), 8);
case 2: return SlCalcVarListLen<std::vector<uint16_t>>(GetVariableAddress(object, sld), 2);
case 4: return SlCalcVarListLen<std::vector<uint32_t>>(GetVariableAddress(object, sld), 4);
case 8: return SlCalcVarListLen<std::vector<uint64_t>>(GetVariableAddress(object, sld), 8);
default: NOT_REACHED();
}
}
@@ -1827,7 +1827,7 @@ bool SlObjectMemberGeneric(void *object, const SaveLoad &sld)
case SL_REF: // Reference variable, translate
switch (action) {
case SLA_SAVE:
SlWriteUint32((uint32)ReferenceToInt(*(void **)ptr, (SLRefType)conv));
SlWriteUint32((uint32_t)ReferenceToInt(*(void **)ptr, (SLRefType)conv));
break;
case SLA_LOAD_CHECK:
case SLA_LOAD:
@@ -1852,9 +1852,9 @@ bool SlObjectMemberGeneric(void *object, const SaveLoad &sld)
const size_t size_len = SlCalcConvMemLen(sld.conv);
switch (size_len) {
case 1: SlVarList<std::vector<byte>>(ptr, conv); break;
case 2: SlVarList<std::vector<uint16>>(ptr, conv); break;
case 4: SlVarList<std::vector<uint32>>(ptr, conv); break;
case 8: SlVarList<std::vector<uint64>>(ptr, conv); break;
case 2: SlVarList<std::vector<uint16_t>>(ptr, conv); break;
case 4: SlVarList<std::vector<uint32_t>>(ptr, conv); break;
case 8: SlVarList<std::vector<uint64_t>>(ptr, conv); break;
default: NOT_REACHED();
}
break;
@@ -1869,7 +1869,7 @@ bool SlObjectMemberGeneric(void *object, const SaveLoad &sld)
* object description to use. */
case SL_WRITEBYTE:
switch (action) {
case SLA_SAVE: SlWriteByte(*(uint8 *)ptr); break;
case SLA_SAVE: SlWriteByte(*(uint8_t *)ptr); break;
case SLA_LOAD_CHECK:
case SLA_LOAD:
case SLA_PTRS:
@@ -1995,7 +1995,7 @@ void SlAutolength(AutolengthProc *proc, void *arg)
_sl.dumper->CopyBytes(result.first, result.second);
}
uint8 SlSaveToTempBufferSetup()
uint8_t SlSaveToTempBufferSetup()
{
assert(_sl.action == SLA_SAVE);
NeedLength orig_need_length = _sl.need_length;
@@ -2003,10 +2003,10 @@ uint8 SlSaveToTempBufferSetup()
_sl.need_length = NL_NONE;
_sl.dumper->StartAutoLength();
return (uint8) orig_need_length;
return (uint8_t) orig_need_length;
}
std::pair<byte *, size_t> SlSaveToTempBufferRestore(uint8 state)
std::pair<byte *, size_t> SlSaveToTempBufferRestore(uint8_t state)
{
NeedLength orig_need_length = (NeedLength)state;
@@ -2224,7 +2224,7 @@ static void SlLoadCheckChunk(const ChunkHandler *ch)
if (ext_flags & SLCEHF_BIG_RIFF) SlErrorCorrupt("XSLFI_RIFF_HEADER_60_BIT and SLCEHF_BIG_RIFF both present");
}
if (ext_flags & SLCEHF_BIG_RIFF) {
uint64 full_len = len | (static_cast<uint64>(SlReadUint32()) << 28);
uint64_t full_len = len | (static_cast<uint64_t>(SlReadUint32()) << 28);
if (full_len >= (1LL << 32)) {
SlErrorCorruptFmt("Chunk size too large: " OTTD_PRINTFHEX64, full_len);
}
@@ -2321,7 +2321,7 @@ static void SlSaveChunks()
* @param id the chunk in question
* @return returns the appropriate chunkhandler
*/
static const ChunkHandler *SlFindChunkHandler(uint32 id)
static const ChunkHandler *SlFindChunkHandler(uint32_t id)
{
for (auto &ch : ChunkHandlers()) if (ch.id == id) return &ch;
return nullptr;
@@ -2335,7 +2335,7 @@ static void SlLoadChunks()
return;
}
for (uint32 id = SlReadUint32(); id != 0; id = SlReadUint32()) {
for (uint32_t id = SlReadUint32(); id != 0; id = SlReadUint32()) {
DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id);
size_t read = 0;
if (_debug_sl_level >= 3) read = SlGetBytesRead();
@@ -2363,7 +2363,7 @@ static void SlLoadCheckChunks()
return;
}
uint32 id;
uint32_t id;
const ChunkHandler *ch;
for (id = SlReadUint32(); id != 0; id = SlReadUint32()) {
@@ -2508,16 +2508,16 @@ struct LZOLoadFilter : LoadFilter {
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) * 2];
uint32 tmp[2];
uint32 size;
byte 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");
/* Check if size is bad */
((uint32*)out)[0] = size = tmp[1];
((uint32_t*)out)[0] = size = tmp[1];
if (_sl_version != SL_MIN_VERSION) {
tmp[0] = TO_BE32(tmp[0]);
@@ -2527,13 +2527,13 @@ struct LZOLoadFilter : LoadFilter {
if (size >= sizeof(out)) SlErrorCorrupt("Inconsistent size");
/* Read block */
if (this->chain->Read(out + sizeof(uint32), size) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
if (this->chain->Read(out + sizeof(uint32_t), size) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
/* Verify checksum */
if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32))) SlErrorCorrupt("Bad checksum");
if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32_t))) SlErrorCorrupt("Bad checksum");
/* Decompress */
int ret = lzo1x_decompress_safe(out + sizeof(uint32) * 1, size, buf, &len, nullptr);
int ret = lzo1x_decompress_safe(out + sizeof(uint32_t) * 1, size, buf, &len, nullptr);
if (ret != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
return len;
}
@@ -2555,17 +2555,17 @@ struct LZOSaveFilter : SaveFilter {
{
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) * 2];
byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32_t) * 2];
byte wrkmem[LZO1X_1_MEM_COMPRESS];
lzo_uint outlen;
do {
/* Compress up to LZO_BUFFER_SIZE bytes at once. */
lzo_uint len = size > LZO_BUFFER_SIZE ? LZO_BUFFER_SIZE : (lzo_uint)size;
lzo1x_1_compress(in, len, out + sizeof(uint32) * 2, &outlen, wrkmem);
((uint32*)out)[1] = TO_BE32((uint32)outlen);
((uint32*)out)[0] = TO_BE32(lzo_adler32(0, out + sizeof(uint32), outlen + sizeof(uint32)));
this->chain->Write(out, outlen + sizeof(uint32) * 2);
lzo1x_1_compress(in, len, out + sizeof(uint32_t) * 2, &outlen, wrkmem);
((uint32_t*)out)[1] = TO_BE32((uint32_t)outlen);
((uint32_t*)out)[0] = TO_BE32(lzo_adler32(0, out + sizeof(uint32_t), outlen + sizeof(uint32_t)));
this->chain->Write(out, outlen + sizeof(uint32_t) * 2);
/* Move to next data chunk. */
size -= len;
@@ -2981,7 +2981,7 @@ DECLARE_ENUM_AS_BIT_SET(SaveLoadFormatFlags);
/** The format for a reader/writer type of a savegame */
struct SaveLoadFormat {
const char *name; ///< name of the compressor/decompressor (debug-only)
uint32 tag; ///< the 4-letter tag by which it is identified in the savegame
uint32_t tag; ///< the 4-letter tag by which it is identified in the savegame
LoadFilter *(*init_load)(LoadFilter *chain); ///< Constructor for the load filter.
SaveFilter *(*init_write)(SaveFilter *chain, byte compression); ///< Constructor for the save filter.
@@ -3175,7 +3175,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded)
DEBUG(sl, 3, "Using compression format: %s, level: %u", fmt->name, compression);
/* We have written our stuff to memory, now write it to file! */
uint32 hdr[2] = { fmt->tag, TO_BE32((uint32) (SAVEGAME_VERSION | SAVEGAME_VERSION_EXT) << 16) };
uint32_t hdr[2] = { fmt->tag, TO_BE32((uint32_t) (SAVEGAME_VERSION | SAVEGAME_VERSION_EXT) << 16) };
_sl.sf->Write((byte*)hdr, sizeof(hdr));
_sl.sf = fmt->init_write(_sl.sf, compression);
@@ -3413,7 +3413,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check)
SlResetTNNC();
});
uint32 hdr[2];
uint32_t hdr[2];
if (_sl.lf->Read((byte*)hdr, sizeof(hdr)) != sizeof(hdr)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
SaveLoadVersion original_sl_version = SL_MIN_VERSION;

View File

@@ -98,7 +98,7 @@ enum ChunkSaveLoadSpecialOpResult {
CSLSOR_DONT_SAVE_CHUNK,
CSLSOR_UPSTREAM_SAVE_CHUNK,
};
typedef ChunkSaveLoadSpecialOpResult ChunkSaveLoadSpecialProc(uint32, ChunkSaveLoadSpecialOp);
typedef ChunkSaveLoadSpecialOpResult ChunkSaveLoadSpecialProc(uint32_t, ChunkSaveLoadSpecialOp);
/** Type of a chunk. */
enum ChunkType {
@@ -112,7 +112,7 @@ enum ChunkType {
/** Handlers and description of chunk. */
struct ChunkHandler {
uint32 id; ///< Unique ID (4 letters).
uint32_t id; ///< Unique ID (4 letters).
ChunkSaveLoadProc *save_proc; ///< Save procedure of the chunk.
ChunkSaveLoadProc *load_proc; ///< Load procedure of the chunk.
ChunkSaveLoadProc *ptrs_proc; ///< Manipulate pointers in the chunk.
@@ -134,12 +134,12 @@ void SlExecWithSlVersion(SaveLoadVersion use_version, F proc)
}
namespace upstream_sl {
template <uint32 id, typename F>
template <uint32_t id, typename F>
ChunkHandler MakeUpstreamChunkHandler()
{
extern void SlLoadChunkByID(uint32);
extern void SlLoadCheckChunkByID(uint32);
extern void SlFixPointerChunkByID(uint32);
extern void SlLoadChunkByID(uint32_t);
extern void SlLoadCheckChunkByID(uint32_t);
extern void SlFixPointerChunkByID(uint32_t);
ChunkHandler ch = {
id,
@@ -149,7 +149,7 @@ namespace upstream_sl {
SlUnreachablePlaceholder,
CH_UNUSED
};
ch.special_proc = [](uint32 chunk_id, ChunkSaveLoadSpecialOp op) -> ChunkSaveLoadSpecialOpResult {
ch.special_proc = [](uint32_t chunk_id, ChunkSaveLoadSpecialOp op) -> ChunkSaveLoadSpecialOpResult {
assert(id == chunk_id);
switch (op) {
case CSLSO_PRE_LOAD:
@@ -176,12 +176,12 @@ namespace upstream_sl {
return ch;
}
template <uint32 id, typename F>
template <uint32_t id, typename F>
ChunkHandler MakeConditionallyUpstreamChunkHandler(ChunkSaveLoadProc *save_proc, ChunkSaveLoadProc *load_proc, ChunkSaveLoadProc *ptrs_proc, ChunkSaveLoadProc *load_check_proc, ChunkType type)
{
extern void SlLoadChunkByID(uint32);
extern void SlLoadCheckChunkByID(uint32);
extern void SlFixPointerChunkByID(uint32);
extern void SlLoadChunkByID(uint32_t);
extern void SlLoadCheckChunkByID(uint32_t);
extern void SlFixPointerChunkByID(uint32_t);
ChunkHandler ch = {
id,
@@ -191,7 +191,7 @@ namespace upstream_sl {
load_check_proc,
type
};
ch.special_proc = [](uint32 chunk_id, ChunkSaveLoadSpecialOp op) -> ChunkSaveLoadSpecialOpResult {
ch.special_proc = [](uint32_t chunk_id, ChunkSaveLoadSpecialOp op) -> ChunkSaveLoadSpecialOpResult {
assert(id == chunk_id);
switch (op) {
case CSLSO_PRE_LOAD:
@@ -307,16 +307,16 @@ inline constexpr size_t SlVarSize(VarType type)
return sizeof(bool);
case SLE_VAR_I8:
case SLE_VAR_U8:
return sizeof(int8);
return sizeof(int8_t);
case SLE_VAR_I16:
case SLE_VAR_U16:
return sizeof(int16);
return sizeof(int16_t);
case SLE_VAR_I32:
case SLE_VAR_U32:
return sizeof(int32);
return sizeof(int32_t);
case SLE_VAR_I64:
case SLE_VAR_U64:
return sizeof(int64);
return sizeof(int64_t);
case SLE_VAR_NAME:
return sizeof(std::string);
default:
@@ -925,8 +925,8 @@ inline void *GetVariableAddress(const void *object, const SaveLoad &sld)
return const_cast<byte *>((const byte *)object + (ptrdiff_t)sld.address);
}
int64 ReadValue(const void *ptr, VarType conv);
void WriteValue(void *ptr, VarType conv, int64 val);
int64_t ReadValue(const void *ptr, VarType conv);
void WriteValue(void *ptr, VarType conv, int64_t val);
void SlSetArrayIndex(uint index);
int SlIterateArray();
@@ -945,10 +945,10 @@ size_t SlCalcObjLength(const void *object, const SaveLoadTable &slt);
template <typename F>
span<byte> SlSaveToTempBuffer(F proc)
{
extern uint8 SlSaveToTempBufferSetup();
extern std::pair<byte *, size_t> SlSaveToTempBufferRestore(uint8 state);
extern uint8_t SlSaveToTempBufferSetup();
extern std::pair<byte *, size_t> SlSaveToTempBufferRestore(uint8_t state);
uint8 state = SlSaveToTempBufferSetup();
uint8_t state = SlSaveToTempBufferSetup();
proc();
auto result = SlSaveToTempBufferRestore(state);
return span<byte>(result.first, result.second);
@@ -961,15 +961,15 @@ span<byte> SlSaveToTempBuffer(F proc)
* @return a vector containing the saved data
*/
template <typename F>
std::vector<uint8> SlSaveToVector(F proc)
std::vector<uint8_t> SlSaveToVector(F proc)
{
span<byte> result = SlSaveToTempBuffer(proc);
return std::vector<uint8>(result.begin(), result.end());
return std::vector<uint8_t>(result.begin(), result.end());
}
struct SlConditionallySaveState {
size_t current_len;
uint8 need_length;
uint8_t need_length;
bool nested;
};

View File

@@ -77,7 +77,7 @@ struct ReadBuffer {
inline int RawReadUint16()
{
#if OTTD_ALIGNMENT == 0
int x = FROM_BE16(*((const unaligned_uint16*) this->bufp));
int x = FROM_BE16(*((const unaligned_uint16 *) this->bufp));
this->bufp += 2;
return x;
#else
@@ -86,28 +86,28 @@ struct ReadBuffer {
#endif
}
inline uint32 RawReadUint32()
inline uint32_t RawReadUint32()
{
#if OTTD_ALIGNMENT == 0
uint32 x = FROM_BE32(*((const unaligned_uint32*) this->bufp));
uint32_t x = FROM_BE32(*((const unaligned_uint32 *) this->bufp));
this->bufp += 4;
return x;
#else
uint32 x = this->RawReadUint16() << 16;
uint32_t x = this->RawReadUint16() << 16;
return x | this->RawReadUint16();
#endif
}
inline uint64 RawReadUint64()
inline uint64_t RawReadUint64()
{
#if OTTD_ALIGNMENT == 0
uint64 x = FROM_BE64(*((const unaligned_uint64*) this->bufp));
uint64_t x = FROM_BE64(*((const unaligned_uint64 *) this->bufp));
this->bufp += 8;
return x;
#else
uint32 x = this->RawReadUint32();
uint32 y = this->RawReadUint32();
return (uint64)x << 32 | y;
uint32_t x = this->RawReadUint32();
uint32_t y = this->RawReadUint32();
return (uint64_t)x << 32 | y;
#endif
}
@@ -214,7 +214,7 @@ struct MemoryDumper {
*this->buf++ = b;
}
inline void RawWriteUint16(uint16 v)
inline void RawWriteUint16(uint16_t v)
{
#if OTTD_ALIGNMENT == 0
*((unaligned_uint16 *) this->buf) = TO_BE16(v);
@@ -225,7 +225,7 @@ struct MemoryDumper {
this->buf += 2;
}
inline void RawWriteUint32(uint32 v)
inline void RawWriteUint32(uint32_t v)
{
#if OTTD_ALIGNMENT == 0
*((unaligned_uint32 *) this->buf) = TO_BE32(v);
@@ -238,7 +238,7 @@ struct MemoryDumper {
this->buf += 4;
}
inline void RawWriteUint64(uint64 v)
inline void RawWriteUint64(uint64_t v)
{
#if OTTD_ALIGNMENT == 0
*((unaligned_uint64 *) this->buf) = TO_BE64(v);

View File

@@ -38,7 +38,7 @@ namespace upstream_sl {
*
* Note that this list must not be reordered.
*/
enum SaveLoadVersion : uint16 {
enum SaveLoadVersion : uint16_t {
SL_MIN_VERSION, ///< First savegame version
SLV_1, ///< 1.0 0.1.x, 0.2.x
@@ -292,7 +292,7 @@ enum SaveLoadVersion : uint16 {
SLV_198, ///< 198 PR#6763 Switch town growth rate and counter to actual game ticks
SLV_EXTEND_CARGOTYPES, ///< 199 PR#6802 Extend cargotypes to 64
SLV_EXTEND_RAILTYPES, ///< 200 PR#6805 Extend railtypes to 64, adding uint16 to map array.
SLV_EXTEND_RAILTYPES, ///< 200 PR#6805 Extend railtypes to 64, adding uint16_t to map array.
SLV_EXTEND_PERSISTENT_STORAGE, ///< 201 PR#6885 Extend NewGRF persistent storages.
SLV_EXTEND_INDUSTRY_CARGO_SLOTS, ///< 202 PR#6867 Increase industry cargo slots to 16 in, 16 out
SLV_SHIP_PATH_CACHE, ///< 203 PR#7072 Add path cache for ships
@@ -410,12 +410,12 @@ byte SlReadByte();
void SlWriteByte(byte b);
int SlReadUint16();
uint32 SlReadUint32();
uint64 SlReadUint64();
uint32_t SlReadUint32();
uint64_t SlReadUint64();
void SlWriteUint16(uint16 v);
void SlWriteUint32(uint32 v);
void SlWriteUint64(uint64 v);
void SlWriteUint16(uint16_t v);
void SlWriteUint32(uint32_t v);
void SlWriteUint64(uint64_t v);
void SlSkipBytes(size_t length);

View File

@@ -56,15 +56,15 @@ void AfterLoadTemplateVehiclesUpdate();
void AfterLoadTemplateVehiclesUpdateImages();
void AfterLoadTemplateVehiclesUpdateProperties();
extern int32 _saved_scrollpos_x;
extern int32 _saved_scrollpos_y;
extern int32_t _saved_scrollpos_x;
extern int32_t _saved_scrollpos_y;
extern ZoomLevel _saved_scrollpos_zoom;
extern SavegameType _savegame_type;
extern uint32 _ttdp_version;
extern uint32_t _ttdp_version;
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face);
CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32_t face);
Order UnpackOldOrder(uint16 packed);
Order UnpackOldOrder(uint16_t packed);
#endif /* SL_SAVELOAD_INTERNAL_H */

View File

@@ -91,7 +91,7 @@ enum VarTypes {
SLF_ALLOW_NEWLINE = 1 << 9, ///< Allow new lines in the strings.
};
typedef uint32 VarType;
typedef uint32_t VarType;
/** Type of data saved. */
enum SaveLoadTypes {
@@ -120,7 +120,7 @@ struct SaveLoad {
bool global; ///< should we load a global variable or a non-global one
SaveLoadType cmd; ///< the action to take with the saved/loaded type, All types need different action
VarType conv; ///< type of the variable to be saved, int
uint16 length; ///< (conditional) length of the variable (eg. arrays) (max array size is 65536 elements)
uint16_t length; ///< (conditional) length of the variable (eg. arrays) (max array size is 65536 elements)
SaveLoadVersion version_from; ///< save/load the variable starting from this savegame version
SaveLoadVersion version_to; ///< save/load the variable until this savegame version
/* NOTE: This element either denotes the address of the variable for a global

View File

@@ -23,11 +23,11 @@
#include "../safeguards.h"
static byte _old_last_vehicle_type;
static uint8 _num_specs;
static uint8 _num_roadstop_specs;
static uint32 _num_roadstop_custom_tiles;
static uint8_t _num_specs;
static uint8_t _num_roadstop_specs;
static uint32_t _num_roadstop_custom_tiles;
static std::vector<TileIndex> _custom_road_stop_tiles;
static std::vector<uint16> _custom_road_stop_data;
static std::vector<uint16_t> _custom_road_stop_data;
/**
* Update the buoy orders to be waypoint orders.
@@ -231,11 +231,11 @@ static const SaveLoad _old_station_desc[] = {
SLE_CONDNULL(32, SLV_2, SL_MAX_VERSION),
};
static uint16 _waiting_acceptance;
static uint32 _num_flows;
static uint16 _cargo_source;
static uint32 _cargo_source_xy;
static uint8 _cargo_periods;
static uint16_t _waiting_acceptance;
static uint32_t _num_flows;
static uint16_t _cargo_source;
static uint32_t _cargo_source_xy;
static uint8_t _cargo_periods;
static Money _cargo_feeder_share;
static uint _cargo_reserved_count;
@@ -252,13 +252,13 @@ static const SaveLoad _roadstop_speclist_desc[] = {
};
CargoPacketList _packets;
uint32 _num_dests;
uint32_t _num_dests;
struct FlowSaveLoad {
FlowSaveLoad() : source(0), via(0), share(0), restricted(false) {}
StationID source;
StationID via;
uint32 share;
uint32_t share;
bool restricted;
};
@@ -537,9 +537,9 @@ static void SetupDescs_ROADSTOP()
static void RealSave_STNN(BaseStation *bst)
{
_num_specs = (uint8)bst->speclist.size();
_num_roadstop_specs = (uint8)bst->roadstop_speclist.size();
_num_roadstop_custom_tiles = (uint32)bst->custom_roadstop_tile_data.size();
_num_specs = (uint8_t)bst->speclist.size();
_num_roadstop_specs = (uint8_t)bst->roadstop_speclist.size();
_num_roadstop_custom_tiles = (uint32_t)bst->custom_roadstop_tile_data.size();
bool waypoint = (bst->facilities & FACIL_WAYPOINT) != 0;
SlObjectSaveFiltered(bst, waypoint ? SaveLoadTable(_filtered_waypoint_desc) : SaveLoadTable(_filtered_station_desc));
@@ -552,8 +552,8 @@ static void RealSave_STNN(BaseStation *bst)
const GoodsEntryData *ged = st->goods[i].data.get();
if (ged != nullptr) {
_cargo_reserved_count = ged->cargo.ReservedCount();
_num_dests = (uint32)ged->cargo.Packets()->MapSize();
_num_flows = (uint32)ged->flows.size();
_num_dests = (uint32_t)ged->cargo.Packets()->MapSize();
_num_flows = (uint32_t)ged->flows.size();
} else {
_cargo_reserved_count = 0;
_num_dests = 0;
@@ -562,12 +562,12 @@ static void RealSave_STNN(BaseStation *bst)
SlObjectSaveFiltered(&st->goods[i], _filtered_goods_desc);
if (ged == nullptr) continue;
for (FlowStatMap::const_iterator outer_it(ged->flows.begin()); outer_it != ged->flows.end(); ++outer_it) {
uint32 sum_shares = 0;
uint32_t sum_shares = 0;
FlowSaveLoad flow;
flow.source = outer_it->GetOrigin();
dumper->CheckBytes(2 + 4);
dumper->RawWriteUint16(flow.source);
dumper->RawWriteUint32((uint32)outer_it->size());
dumper->RawWriteUint32((uint32_t)outer_it->size());
FlowStat::const_iterator inner_it(outer_it->begin());
const FlowStat::const_iterator end(outer_it->end());
for (; inner_it != end; ++inner_it) {
@@ -673,18 +673,18 @@ static void Load_STNN()
StationID prev_source = INVALID_STATION;
if (SlXvIsFeaturePresent(XSLFI_FLOW_STAT_FLAGS)) {
ge.data->flows.reserve(_num_flows);
for (uint32 j = 0; j < _num_flows; ++j) {
for (uint32_t j = 0; j < _num_flows; ++j) {
FlowSaveLoad flow;
buffer->CheckBytes(2 + 4);
flow.source = buffer->RawReadUint16();
uint32 flow_count = buffer->RawReadUint32();
uint32_t flow_count = buffer->RawReadUint32();
buffer->CheckBytes(2 + 4 + 1);
flow.via = buffer->RawReadUint16();
flow.share = buffer->RawReadUint32();
flow.restricted = (buffer->RawReadByte() != 0);
FlowStat *fs = &(*(ge.data->flows.insert(ge.data->flows.end(), FlowStat(flow.source, flow.via, flow.share, flow.restricted))));
for (uint32 k = 1; k < flow_count; ++k) {
for (uint32_t k = 1; k < flow_count; ++k) {
buffer->CheckBytes(2 + 4 + 1);
flow.via = buffer->RawReadUint16();
flow.share = buffer->RawReadUint32();
@@ -696,7 +696,7 @@ static void Load_STNN()
} else if (SlXvIsFeatureMissing(XSLFI_CHILLPP)) {
FlowSaveLoad flow;
FlowStat *fs = nullptr;
for (uint32 j = 0; j < _num_flows; ++j) {
for (uint32_t j = 0; j < _num_flows; ++j) {
// SlObject(&flow, _flow_desc); /* this is highly performance-sensitive, manually unroll */
buffer->CheckBytes(2 + 2 + 4);
flow.source = buffer->RawReadUint16();
@@ -740,13 +740,13 @@ static void Load_STNN()
st->station_cargo_history.resize(CountBits(st->station_cargo_history_cargoes));
buffer->CheckBytes(st->station_cargo_history.size() * MAX_STATION_CARGO_HISTORY_DAYS * 2);
for (auto &history : st->station_cargo_history) {
for (uint16 &amount : history) {
for (uint16_t &amount : history) {
amount = buffer->RawReadUint16();
}
}
if (SlXvIsFeaturePresent(XSLFI_STATION_CARGO_HISTORY, 1, 1)) {
for (auto &history : st->station_cargo_history) {
for (uint16 &amount : history) {
for (uint16_t &amount : history) {
amount = RXCompressUint(amount);
}
}
@@ -780,7 +780,7 @@ static void Load_STNN()
if (SlXvIsFeaturePresent(XSLFI_GRF_ROADSTOPS, 1, 1)) {
for (size_t i = 0; i < _custom_road_stop_tiles.size(); i++) {
bst->custom_roadstop_tile_data.push_back({ _custom_road_stop_tiles[i], (uint8)GB(_custom_road_stop_data[i], 0, 8), (uint8)GB(_custom_road_stop_data[i], 8, 8) });
bst->custom_roadstop_tile_data.push_back({ _custom_road_stop_tiles[i], (uint8_t)GB(_custom_road_stop_data[i], 0, 8), (uint8_t)GB(_custom_road_stop_data[i], 8, 8) });
}
_custom_road_stop_tiles.clear();
_custom_road_stop_data.clear();

View File

@@ -47,7 +47,7 @@ static void Save_STORY_PAGE_ELEMENT()
static void Load_STORY_PAGE_ELEMENT()
{
int index;
uint32 max_sort_value = 0;
uint32_t max_sort_value = 0;
while ((index = SlIterateArray()) != -1) {
StoryPageElement *s = new (index) StoryPageElement();
SlObject(s, _story_page_elements_desc);
@@ -81,7 +81,7 @@ static void Save_STORY_PAGE()
static void Load_STORY_PAGE()
{
int index;
uint32 max_sort_value = 0;
uint32_t max_sort_value = 0;
while ((index = SlIterateArray()) != -1) {
StoryPage *s = new (index) StoryPage();
SlObject(s, _story_pages_desc);

View File

@@ -69,7 +69,7 @@ std::string CopyFromOldName(StringID id)
std::ostringstream tmp;
std::ostreambuf_iterator<char> strto(tmp);
for (; *strfrom != '\0'; strfrom++) {
WChar c = (byte)*strfrom;
char32_t c = (byte)*strfrom;
/* Map from non-ISO8859-15 characters to UTF-8. */
switch (c) {

View File

@@ -132,7 +132,7 @@ void AfterLoadTemplateVehiclesUpdateProperties()
StringID err;
Train* t = VirtualTrainFromTemplateVehicle(tv, err, 0);
if (t != nullptr) {
uint32 full_cargo_weight = 0;
uint32_t full_cargo_weight = 0;
for (Train *u = t; u != nullptr; u = u->Next()) {
full_cargo_weight += u->GetCargoWeight(u->cargo_cap);
}

View File

@@ -259,24 +259,24 @@ static const SaveLoad _town_desc[] = {
};
static const SaveLoad _town_supplied_desc[] = {
SLE_CONDVAR(TransportedCargoStat<uint32>, old_max, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32>, new_max, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32>, old_act, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32>, new_act, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32_t>, old_max, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32_t>, new_max, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32_t>, old_act, SLE_UINT32, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint32_t>, new_act, SLE_UINT32, SLV_165, SL_MAX_VERSION),
};
static const SaveLoad _town_received_desc[] = {
SLE_CONDVAR(TransportedCargoStat<uint16>, old_max, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16>, new_max, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16>, old_act, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16>, new_act, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, old_max, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, new_max, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, old_act, SLE_UINT16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, new_act, SLE_UINT16, SLV_165, SL_MAX_VERSION),
};
static const SaveLoad _town_received_desc_spp[] = {
SLE_CONDVAR(TransportedCargoStat<uint16>, old_max, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16>, new_max, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16>, old_act, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16>, new_act, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, old_max, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, new_max, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, old_act, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION),
SLE_CONDVAR(TransportedCargoStat<uint16_t>, new_act, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION),
};
std::vector<SaveLoad> _filtered_town_desc;
@@ -350,8 +350,8 @@ static void Load_TOWN()
if ((!IsSavegameVersionBefore(SLV_166) && IsSavegameVersionBefore(SLV_REMOVE_TOWN_CARGO_CACHE)) || SlXvIsFeaturePresent(XSLFI_TOWN_CARGO_MATRIX)) {
SlSkipBytes(4); // tile
uint16 w = SlReadUint16();
uint16 h = SlReadUint16();
uint16_t w = SlReadUint16();
uint16_t h = SlReadUint16();
if (w != 0) {
SlSkipBytes((SlXvIsFeaturePresent(XSLFI_TOWN_CARGO_MATRIX) ? 8 : 4) * ((uint)(w / 4) * (uint)(h / 4)));
}
@@ -387,7 +387,7 @@ void Save_TNNC()
}
size_t length = 8 + (Town::GetNumItems() * 6);
uint32 flags = 0;
uint32_t flags = 0;
if (IsGetTownZonesCallbackHandlerPresent()) {
flags |= 1;
@@ -397,7 +397,7 @@ void Save_TNNC()
SlSetLength(length);
SlWriteUint32(flags);
SlWriteUint32((uint32)Town::GetNumItems());
SlWriteUint32((uint32_t)Town::GetNumItems());
for (const Town *t : Town::Iterate()) {
SlWriteUint32(t->index);
@@ -419,13 +419,13 @@ void Load_TNNC()
return;
}
const uint32 flags = SlReadUint32();
const uint32 count = SlReadUint32();
const uint32_t flags = SlReadUint32();
const uint32_t count = SlReadUint32();
_town_noise_no_update = true;
_town_zone_radii_no_update = (flags & 1);
for (uint32 idx = 0; idx < count; idx++) {
for (uint32_t idx = 0; idx < count; idx++) {
Town *t = Town::Get(SlReadUint32());
t->noise_reached = SlReadUint16();
if (flags & 1) {
@@ -436,7 +436,7 @@ void Load_TNNC()
}
}
static ChunkSaveLoadSpecialOpResult Special_TNNC(uint32 chunk_id, ChunkSaveLoadSpecialOp op)
static ChunkSaveLoadSpecialOpResult Special_TNNC(uint32_t chunk_id, ChunkSaveLoadSpecialOp op)
{
switch (op) {
case CSLSO_SHOULD_SAVE_CHUNK:

View File

@@ -44,7 +44,7 @@ static void Save_TRRM()
/** program length save header struct */
struct TraceRestrictProgramStub {
uint32 length;
uint32_t length;
};
static const SaveLoad _trace_restrict_program_stub_desc[] = {
@@ -95,7 +95,7 @@ static void Load_TRRP()
static void RealSave_TRRP(TraceRestrictProgram *prog)
{
TraceRestrictProgramStub stub;
stub.length = (uint32)prog->items.size();
stub.length = (uint32_t)prog->items.size();
SlObject(&stub, _trace_restrict_program_stub_desc);
SlArray(prog->items.data(), stub.length, SLE_UINT32);
}
@@ -113,7 +113,7 @@ static void Save_TRRP()
/** program length save header struct */
struct TraceRestrictSlotStub {
uint32 length;
uint32_t length;
};
static const SaveLoad _trace_restrict_slot_stub_desc[] = {
@@ -151,7 +151,7 @@ static void RealSave_TRRS(TraceRestrictSlot *slot)
{
SlObject(slot, _trace_restrict_slot_desc);
TraceRestrictSlotStub stub;
stub.length = (uint32)slot->occupants.size();
stub.length = (uint32_t)slot->occupants.size();
SlObject(&stub, _trace_restrict_slot_stub_desc);
if (stub.length) SlArray(slot->occupants.data(), stub.length, SLE_UINT32);
}

View File

@@ -635,22 +635,22 @@ void FixupTrainLengths()
}
}
static uint8 _cargo_periods;
static uint16 _cargo_source;
static uint32 _cargo_source_xy;
static uint16 _cargo_count;
static uint16 _cargo_paid_for;
static uint8_t _cargo_periods;
static uint16_t _cargo_source;
static uint32_t _cargo_source_xy;
static uint16_t _cargo_count;
static uint16_t _cargo_paid_for;
static Money _cargo_feeder_share;
CargoPacketList _cpp_packets;
std::map<VehicleID, CargoPacketList> _veh_cpp_packets;
static std::vector<Trackdir> _path_td;
static std::vector<TileIndex> _path_tile;
static uint32 _path_layout_ctr;
static uint32_t _path_layout_ctr;
static uint32 _old_ahead_separation;
static uint16 _old_timetable_start_subticks;
static uint32_t _old_ahead_separation;
static uint16_t _old_timetable_start_subticks;
btree::btree_map<VehicleID, uint16> _old_timetable_start_subticks_map;
btree::btree_map<VehicleID, uint16_t> _old_timetable_start_subticks_map;
/**
* Make it possible to make the saveload tables "friends" of other classes.
@@ -715,10 +715,10 @@ SaveLoadTable GetVehicleDescription(VehicleType vt)
SLE_VAR(Vehicle, day_counter, SLE_UINT8),
SLE_VAR(Vehicle, tick_counter, SLE_UINT8),
SLE_CONDVAR_X(Vehicle, running_ticks, SLE_FILE_U8 | SLE_VAR_U16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16 version, bool version_in_range, const std::array<uint16, XSLFI_SIZE> &feature_versions) -> bool {
SLE_CONDVAR_X(Vehicle, running_ticks, SLE_FILE_U8 | SLE_VAR_U16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16_t version, bool version_in_range, const std::array<uint16_t, XSLFI_SIZE> &feature_versions) -> bool {
return version_in_range && !(SlXvIsFeaturePresent(feature_versions, XSLFI_SPRINGPP, 3) || SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_CHILLPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_VARIABLE_DAY_LENGTH, 2));
})),
SLE_CONDVAR_X(Vehicle, running_ticks, SLE_UINT16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16 version, bool version_in_range, const std::array<uint16, XSLFI_SIZE> &feature_versions) -> bool {
SLE_CONDVAR_X(Vehicle, running_ticks, SLE_UINT16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16_t version, bool version_in_range, const std::array<uint16_t, XSLFI_SIZE> &feature_versions) -> bool {
return version_in_range && (SlXvIsFeaturePresent(feature_versions, XSLFI_SPRINGPP, 2) || SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_CHILLPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_VARIABLE_DAY_LENGTH, 2));
})),
@@ -1139,7 +1139,7 @@ void Load_VEHS()
if (vtype == VEH_ROAD && !_path_td.empty() && _path_td.size() <= RV_PATH_CACHE_SEGMENTS && _path_td.size() == _path_tile.size()) {
RoadVehicle *rv = RoadVehicle::From(v);
rv->cached_path.reset(new RoadVehPathCache());
rv->cached_path->count = (uint8)_path_td.size();
rv->cached_path->count = (uint8_t)_path_td.size();
for (size_t i = 0; i < _path_td.size(); i++) {
rv->cached_path->td[i] = _path_td[i];
rv->cached_path->tile[i] = _path_tile[i];
@@ -1148,7 +1148,7 @@ void Load_VEHS()
} else if (vtype == VEH_SHIP && !_path_td.empty() && _path_td.size() <= SHIP_PATH_CACHE_LENGTH) {
Ship *s = Ship::From(v);
s->cached_path.reset(new ShipPathCache());
s->cached_path->count = (uint8)_path_td.size();
s->cached_path->count = (uint8_t)_path_td.size();
for (size_t i = 0; i < _path_td.size(); i++) {
s->cached_path->td[i] = _path_td[i];
}
@@ -1232,13 +1232,13 @@ struct train_venc {
VehicleID id;
GroundVehicleCache gvcache;
int cached_curve_speed_mod;
uint8 cached_tflags;
uint8 cached_num_engines;
uint16 cached_centre_mass;
uint16 cached_braking_length;
uint16 cached_veh_weight;
uint16 cached_uncapped_decel;
uint8 cached_deceleration;
uint8_t cached_tflags;
uint8_t cached_num_engines;
uint16_t cached_centre_mass;
uint16_t cached_braking_length;
uint16_t cached_veh_weight;
uint16_t cached_uncapped_decel;
uint8_t cached_deceleration;
byte user_def_data;
int cached_max_curve_speed;
};
@@ -1250,7 +1250,7 @@ struct roadvehicle_venc {
struct aircraft_venc {
VehicleID id;
uint16 cached_max_range;
uint16_t cached_max_range;
};
static std::vector<vehicle_venc> _vehicle_vencs;
@@ -1485,7 +1485,7 @@ void SlProcessVENC()
}
}
static ChunkSaveLoadSpecialOpResult Special_VENC(uint32 chunk_id, ChunkSaveLoadSpecialOp op)
static ChunkSaveLoadSpecialOpResult Special_VENC(uint32_t chunk_id, ChunkSaveLoadSpecialOp op)
{
switch (op) {
case CSLSO_SHOULD_SAVE_CHUNK:
@@ -1546,11 +1546,11 @@ const SaveLoadTable GetVehicleLookAheadCurveDescription()
static void RealSave_VLKA(TrainReservationLookAhead *lookahead)
{
SlObject(lookahead, GetVehicleLookAheadDescription());
SlWriteUint32((uint32)lookahead->items.size());
SlWriteUint32((uint32_t)lookahead->items.size());
for (TrainReservationLookAheadItem &item : lookahead->items) {
SlObject(&item, GetVehicleLookAheadItemDescription());
}
SlWriteUint32((uint32)lookahead->curves.size());
SlWriteUint32((uint32_t)lookahead->curves.size());
for (TrainReservationLookAheadCurve &curve : lookahead->curves) {
SlObject(&curve, GetVehicleLookAheadCurveDescription());
}
@@ -1574,12 +1574,12 @@ void Load_VLKA()
assert(t != nullptr);
t->lookahead.reset(new TrainReservationLookAhead());
SlObject(t->lookahead.get(), GetVehicleLookAheadDescription());
uint32 items = SlReadUint32();
uint32_t items = SlReadUint32();
t->lookahead->items.resize(items);
for (uint i = 0; i < items; i++) {
SlObject(&t->lookahead->items[i], GetVehicleLookAheadItemDescription());
}
uint32 curves = SlReadUint32();
uint32_t curves = SlReadUint32();
t->lookahead->curves.resize(curves);
for (uint i = 0; i < curves; i++) {
SlObject(&t->lookahead->curves[i], GetVehicleLookAheadCurveDescription());

View File

@@ -27,13 +27,13 @@ struct OldWaypoint {
TileIndex xy;
TownID town_index;
Town *town;
uint16 town_cn;
uint16_t town_cn;
StringID string_id;
TinyString name;
uint8 delete_ctr;
uint8_t delete_ctr;
Date build_date;
uint8 localidx;
uint32 grfid;
uint8_t localidx;
uint32_t grfid;
const StationSpec *spec;
Owner owner;