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

@@ -858,7 +858,7 @@ bool AfterLoadGame()
}
}
if (SlXvIsFeatureMissing(XSLFI_VARIABLE_DAY_LENGTH, 3)) {
_scaled_tick_counter = (uint64)((_tick_counter * _settings_game.economy.day_length_factor) + _tick_skip_counter);
_scaled_tick_counter = (uint64_t)((_tick_counter * _settings_game.economy.day_length_factor) + _tick_skip_counter);
}
/* Update current year
@@ -1586,7 +1586,7 @@ bool AfterLoadGame()
/* m2 signal state bit allocation has shrunk */
for (TileIndex t = 0; t < map_size; t++) {
if (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL && IsBridge(t) && IsTunnelBridgeSignalSimulationEntrance(t)) {
extern void ShiftBridgeEntranceSimulatedSignalsExtended(TileIndex t, int shift, uint64 in);
extern void ShiftBridgeEntranceSimulatedSignalsExtended(TileIndex t, int shift, uint64_t in);
const uint shift = 15 - BRIDGE_M2_SIGNAL_STATE_COUNT;
ShiftBridgeEntranceSimulatedSignalsExtended(t, shift, GB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_COUNT, shift));
SB(_m[t].m2, 0, 15, GB(_m[t].m2, 0, 15) << shift);
@@ -2313,7 +2313,7 @@ bool AfterLoadGame()
/* Replace "house construction year" with "house age" */
if (IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)) {
_m[t].m5 = ClampTo<uint8>(_cur_year - (_m[t].m5 + ORIGINAL_BASE_YEAR));
_m[t].m5 = ClampTo<uint8_t>(_cur_year - (_m[t].m5 + ORIGINAL_BASE_YEAR));
}
}
}
@@ -2684,7 +2684,7 @@ bool AfterLoadGame()
* So taking the 16 bit fractional part into account there are plenty of bits left
* for unmodified savegames ...
*/
uint64 aimed_inflation = (_economy.old_max_loan_unround << 16 | _economy.old_max_loan_unround_fract) / _settings_game.difficulty.max_loan;
uint64_t aimed_inflation = (_economy.old_max_loan_unround << 16 | _economy.old_max_loan_unround_fract) / _settings_game.difficulty.max_loan;
/* ... well, just clamp it then. */
if (aimed_inflation > MAX_INFLATION) aimed_inflation = MAX_INFLATION;
@@ -3134,7 +3134,7 @@ bool AfterLoadGame()
_settings_game.pf.reverse_at_signals = IsSavegameVersionBefore(SLV_100) || (_settings_game.pf.wait_oneway_signal != 255 && _settings_game.pf.wait_twoway_signal != 255 && _settings_game.pf.wait_for_pbs_path != 255);
for (Train *t : Train::Iterate()) {
_settings_game.vehicle.max_train_length = std::max<uint8>(_settings_game.vehicle.max_train_length, CeilDiv(t->gcache.cached_total_length, TILE_SIZE));
_settings_game.vehicle.max_train_length = std::max<uint8_t>(_settings_game.vehicle.max_train_length, CeilDiv(t->gcache.cached_total_length, TILE_SIZE));
}
}
@@ -3335,7 +3335,7 @@ bool AfterLoadGame()
}
if (IsSavegameVersionBefore(SLV_178)) {
extern uint8 _old_diff_level;
extern uint8_t _old_diff_level;
/* Initialise script settings profile */
_settings_game.script.settings_profile = IsInsideMM(_old_diff_level, SP_BEGIN, SP_END) ? _old_diff_level : (uint)SP_MEDIUM;
}
@@ -3364,7 +3364,7 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(SLV_184)) {
/* The global units configuration is split up in multiple configurations. */
extern uint8 _old_units;
extern uint8_t _old_units;
_settings_game.locale.units_velocity = Clamp(_old_units, 0, 2);
_settings_game.locale.units_power = Clamp(_old_units, 0, 2);
_settings_game.locale.units_weight = Clamp(_old_units, 1, 2);
@@ -3606,7 +3606,7 @@ bool AfterLoadGame()
v->timetable_start += _scaled_date_ticks.base() - _tick_counter;
}
} else if (!SlXvIsFeaturePresent(XSLFI_TIMETABLES_START_TICKS, 3)) {
extern btree::btree_map<VehicleID, uint16> _old_timetable_start_subticks_map;
extern btree::btree_map<VehicleID, uint16_t> _old_timetable_start_subticks_map;
for (Vehicle *v : Vehicle::Iterate()) {
if (v->timetable_start == 0) continue;
@@ -3885,7 +3885,7 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(SLV_GROUP_REPLACE_WAGON_REMOVAL)) {
/* Propagate wagon removal flag for compatibility */
/* Temporary bitmask of company wagon removal setting */
uint16 wagon_removal = 0;
uint16_t wagon_removal = 0;
for (const Company *c : Company::Iterate()) {
if (c->settings.renew_keep_length) SetBit(wagon_removal, c->index);
}
@@ -3902,7 +3902,7 @@ bool AfterLoadGame()
/* Use current order time to approximate last loading time */
if (IsSavegameVersionBefore(SLV_LAST_LOADING_TICK) && SlXvIsFeatureMissing(XSLFI_LAST_LOADING_TICK)) {
for (Vehicle *v : Vehicle::Iterate()) {
v->last_loading_tick = std::max(_scaled_tick_counter, static_cast<uint64>(v->current_order_time)) - v->current_order_time;
v->last_loading_tick = std::max(_scaled_tick_counter, static_cast<uint64_t>(v->current_order_time)) - v->current_order_time;
}
} else if (SlXvIsFeaturePresent(XSLFI_LAST_LOADING_TICK, 1, 1)) {
for (Vehicle *v : Vehicle::Iterate()) {
@@ -4192,7 +4192,7 @@ bool AfterLoadGame()
}
}
if (SlXvIsFeaturePresent(XSLFI_SCHEDULED_DISPATCH, 1, 4)) {
extern btree::btree_map<DispatchSchedule *, uint16> _old_scheduled_dispatch_start_full_date_fract_map;
extern btree::btree_map<DispatchSchedule *, uint16_t> _old_scheduled_dispatch_start_full_date_fract_map;
for (OrderList *order_list : OrderList::Iterate()) {
for (DispatchSchedule &ds : order_list->GetScheduledDispatchScheduleSet()) {

View File

@@ -51,7 +51,7 @@ struct ANITChunkHandler : ChunkHandler {
}
if (IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY)) {
size_t count = SlGetFieldLength() / sizeof(uint32);
size_t count = SlGetFieldLength() / sizeof(uint32_t);
_animated_tiles.clear();
for (uint i = 0; i < count; i++) {
_animated_tiles[SlReadUint32()] = {};

View File

@@ -21,7 +21,7 @@ namespace upstream_sl {
/** 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. */
@@ -83,7 +83,7 @@ struct CMDLChunkHandler : ChunkHandler {
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);
}
}
@@ -127,7 +127,7 @@ struct CMPUChunkHandler : ChunkHandler {
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

@@ -31,7 +31,7 @@ namespace upstream_sl {
/* 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;
};
class SlCompanyOldAIBuildRec : public DefaultSaveLoadHandler<SlCompanyOldAIBuildRec, CompanyOldAI> {
@@ -155,7 +155,7 @@ public:
void Load(CompanyProperties *c) const override
{
if (!IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH)) {
c->num_valid_stat_ent = (uint8)SlGetStructListLength(UINT8_MAX);
c->num_valid_stat_ent = (uint8_t)SlGetStructListLength(UINT8_MAX);
}
if (c->num_valid_stat_ent > lengthof(c->old_economy)) SlErrorCorrupt("Too many old economy entries");

View File

@@ -121,7 +121,7 @@ struct GSDTChunkHandler : ChunkHandler {
};
static std::string _game_saveload_string;
static uint32 _game_saveload_strings;
static uint32_t _game_saveload_strings;
class SlGameLanguageString : public DefaultSaveLoadHandler<SlGameLanguageString, LanguageStrings> {
public:
@@ -142,9 +142,9 @@ public:
void Load(LanguageStrings *ls) const override
{
uint32 length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _game_saveload_strings : (uint32)SlGetStructListLength(UINT32_MAX);
uint32_t length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _game_saveload_strings : (uint32_t)SlGetStructListLength(UINT32_MAX);
for (uint32 i = 0; i < length; i++) {
for (uint32_t i = 0; i < length; i++) {
SlObject(nullptr, this->GetLoadDescription());
ls->lines.emplace_back(_game_saveload_string);
}

View File

@@ -25,7 +25,7 @@ namespace upstream_sl {
/** Container for a label for SaveLoad system */
struct LabelObject {
uint32 label;
uint32_t label;
};
static const SaveLoad _label_object_desc[] = {

View File

@@ -24,7 +24,7 @@ namespace upstream_sl {
typedef LinkGraph::BaseNode Node;
typedef LinkGraph::BaseEdge Edge;
static uint16 _num_nodes;
static uint16_t _num_nodes;
static LinkGraph *_linkgraph; ///< Contains the current linkgraph being saved/loaded.
static NodeID _linkgraph_from; ///< Contains the current "from" node being saved/loaded.
static NodeID _edge_dest_node;
@@ -50,7 +50,7 @@ public:
void Load(Node *bn) const override
{
uint16 max_size = _linkgraph->Size();
uint16_t max_size = _linkgraph->Size();
if (IsSavegameVersionBefore(SLV_191)) {
NOT_REACHED();
@@ -109,7 +109,7 @@ public:
{
_linkgraph = lg;
uint16 length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _num_nodes : (uint16)SlGetStructListLength(UINT16_MAX);
uint16_t length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _num_nodes : (uint16_t)SlGetStructListLength(UINT16_MAX);
lg->Init(length);
for (NodeID from = 0; from < length; ++from) {
_linkgraph_from = from;

View File

@@ -22,8 +22,8 @@
namespace upstream_sl {
static uint32 _map_dim_x;
static uint32 _map_dim_y;
static uint32_t _map_dim_x;
static uint32_t _map_dim_y;
static const SaveLoad _map_desc[] = {
SLEG_CONDVAR("dim_x", _map_dim_x, SLE_UINT32, SLV_6, SL_MAX_VERSION),
@@ -156,7 +156,7 @@ struct MAP2ChunkHandler : ChunkHandler {
void Load() const override
{
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;) {
@@ -170,10 +170,10 @@ struct MAP2ChunkHandler : ChunkHandler {
void Save() const override
{
std::array<uint16, MAP_SL_BUF_SIZE> buf;
std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
TileIndex size = MapSize();
SlSetLength(size * sizeof(uint16));
SlSetLength(size * sizeof(uint16_t));
for (TileIndex i = 0; i != size;) {
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m2;
SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT16);
@@ -334,7 +334,7 @@ struct MAP8ChunkHandler : ChunkHandler {
void Load() const override
{
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;) {
@@ -345,10 +345,10 @@ struct MAP8ChunkHandler : ChunkHandler {
void Save() const override
{
std::array<uint16, MAP_SL_BUF_SIZE> buf;
std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
TileIndex size = MapSize();
SlSetLength(size * sizeof(uint16));
SlSetLength(size * sizeof(uint16_t));
for (TileIndex i = 0; i != size;) {
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _me[i++].m8;
SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT16);

View File

@@ -28,7 +28,7 @@
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 std::string _savegame_id;

View File

@@ -17,7 +17,7 @@ namespace upstream_sl {
struct NewGRFMappingChunkHandler : ChunkHandler {
OverrideManagerBase &mapping;
NewGRFMappingChunkHandler(uint32 id, OverrideManagerBase &mapping) : ChunkHandler(id, CH_TABLE), mapping(mapping) {}
NewGRFMappingChunkHandler(uint32_t id, OverrideManagerBase &mapping) : ChunkHandler(id, CH_TABLE), mapping(mapping) {}
void Save() const override;
void Load() const override;
};

View File

@@ -26,7 +26,7 @@ namespace upstream_sl {
* @param packed packed order
* @return unpacked order
*/
static Order UnpackVersion4Order(uint16 packed)
static Order UnpackVersion4Order(uint16_t packed)
{
return Order(GB(packed, 8, 8) << 16 | GB(packed, 4, 4) << 8 | GB(packed, 0, 4));
}
@@ -36,7 +36,7 @@ static Order UnpackVersion4Order(uint16 packed)
* @param packed packed order
* @return unpacked order
*/
Order UnpackOldOrder(uint16 packed)
Order UnpackOldOrder(uint16_t packed)
{
Order order = UnpackVersion4Order(packed);
@@ -88,9 +88,9 @@ struct ORDRChunkHandler : ChunkHandler {
if (IsSavegameVersionBefore(SLV_5)) {
/* Pre-version 5 had another layout for orders
* (uint16 instead of uint32) */
len /= sizeof(uint16);
std::vector<uint16> orders(len);
* (uint16_t instead of uint32_t) */
len /= sizeof(uint16_t);
std::vector<uint16_t> orders(len);
SlCopy(&orders[0], len, SLE_UINT16);
@@ -99,8 +99,8 @@ struct ORDRChunkHandler : ChunkHandler {
o->AssignOrder(UnpackVersion4Order(orders[i]));
}
} else if (IsSavegameVersionBefore(SLV_5, 2)) {
len /= sizeof(uint32);
std::vector<uint32> orders(len);
len /= sizeof(uint32_t);
std::vector<uint32_t> orders(len);
SlCopy(&orders[0], len, SLE_UINT32);

View File

@@ -294,7 +294,7 @@ static inline uint SlGetArrayLength(size_t length)
/**
* Return the type as saved/loaded inside the savegame.
*/
static uint8 GetSavegameFileType(const SaveLoad &sld)
static uint8_t GetSavegameFileType(const SaveLoad &sld)
{
switch (sld.cmd) {
case SL_VAR:
@@ -343,7 +343,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];
}
@@ -359,7 +359,7 @@ static inline byte SlCalcConvFileLen(VarType conv)
{
static const byte conv_file_size[] = {0, 1, 1, 2, 2, 4, 4, 8, 8, 2};
uint8 type = GetVarFileType(conv);
uint8_t type = GetVarFileType(conv);
assert(type < lengthof(conv_file_size));
return conv_file_size[type];
}
@@ -454,7 +454,7 @@ void SlSetLength(size_t length)
* The lower 24 bits are normal
* The uppermost 4 bits are bits 24:27 */
assert(length < (1 << 28));
SlWriteUint32((uint32)((length & 0xFFFFFF) | ((length >> 24) << 28)));
SlWriteUint32((uint32_t)((length & 0xFFFFFF) | ((length >> 24) << 28)));
break;
case CH_TABLE:
case CH_ARRAY:
@@ -516,18 +516,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();
}
@@ -540,18 +540,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_NULL: break;
default: NOT_REACHED();
@@ -570,7 +570,7 @@ static void SlSaveLoadConv(void *ptr, VarType conv)
{
switch (_sl.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)) {
@@ -580,7 +580,7 @@ static void SlSaveLoadConv(void *ptr, VarType conv)
case SLE_FILE_STRINGID:
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();
@@ -589,18 +589,18 @@ static void SlSaveLoadConv(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;
default: NOT_REACHED();
}
@@ -832,7 +832,7 @@ static void SlCopyInternal(void *object, 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*)object)[i] = (int32)BSWAP32(SlReadUint32());
((int64_t*)object)[i] = (int32_t)BSWAP32(SlReadUint32());
}
return;
}
@@ -889,7 +889,7 @@ static inline size_t SlCalcArrayLen(size_t length, VarType conv)
* Save/Load the length of the array followed by the array of SL_VAR elements.
* @param array The array being manipulated
* @param length The length of the array in elements
* @param conv VarType type of the atomic array (int, byte, uint64, etc.)
* @param conv VarType type of the atomic array (int, byte, uint64_t, etc.)
*/
static void SlArray(void *array, size_t length, VarType conv)
{
@@ -1050,7 +1050,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:
@@ -1246,14 +1246,14 @@ static inline size_t SlCalcRingLen(const void *ring, VarType conv)
{
switch (GetVarMemType(conv)) {
case SLE_VAR_BL: return SlStorageHelper<ring_buffer_sl, bool>::SlCalcLen(ring, conv);
case SLE_VAR_I8: return SlStorageHelper<ring_buffer_sl, int8>::SlCalcLen(ring, conv);
case SLE_VAR_U8: return SlStorageHelper<ring_buffer_sl, uint8>::SlCalcLen(ring, conv);
case SLE_VAR_I16: return SlStorageHelper<ring_buffer_sl, int16>::SlCalcLen(ring, conv);
case SLE_VAR_U16: return SlStorageHelper<ring_buffer_sl, uint16>::SlCalcLen(ring, conv);
case SLE_VAR_I32: return SlStorageHelper<ring_buffer_sl, int32>::SlCalcLen(ring, conv);
case SLE_VAR_U32: return SlStorageHelper<ring_buffer_sl, uint32>::SlCalcLen(ring, conv);
case SLE_VAR_I64: return SlStorageHelper<ring_buffer_sl, int64>::SlCalcLen(ring, conv);
case SLE_VAR_U64: return SlStorageHelper<ring_buffer_sl, uint64>::SlCalcLen(ring, conv);
case SLE_VAR_I8: return SlStorageHelper<ring_buffer_sl, int8_t>::SlCalcLen(ring, conv);
case SLE_VAR_U8: return SlStorageHelper<ring_buffer_sl, uint8_t>::SlCalcLen(ring, conv);
case SLE_VAR_I16: return SlStorageHelper<ring_buffer_sl, int16_t>::SlCalcLen(ring, conv);
case SLE_VAR_U16: return SlStorageHelper<ring_buffer_sl, uint16_t>::SlCalcLen(ring, conv);
case SLE_VAR_I32: return SlStorageHelper<ring_buffer_sl, int32_t>::SlCalcLen(ring, conv);
case SLE_VAR_U32: return SlStorageHelper<ring_buffer_sl, uint32_t>::SlCalcLen(ring, conv);
case SLE_VAR_I64: return SlStorageHelper<ring_buffer_sl, int64_t>::SlCalcLen(ring, conv);
case SLE_VAR_U64: return SlStorageHelper<ring_buffer_sl, uint64_t>::SlCalcLen(ring, conv);
default: NOT_REACHED();
}
}
@@ -1267,14 +1267,14 @@ static void SlRing(void *ring, VarType conv)
{
switch (GetVarMemType(conv)) {
case SLE_VAR_BL: SlStorageHelper<ring_buffer_sl, bool>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I8: SlStorageHelper<ring_buffer_sl, int8>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U8: SlStorageHelper<ring_buffer_sl, uint8>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I16: SlStorageHelper<ring_buffer_sl, int16>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U16: SlStorageHelper<ring_buffer_sl, uint16>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I32: SlStorageHelper<ring_buffer_sl, int32>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U32: SlStorageHelper<ring_buffer_sl, uint32>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I64: SlStorageHelper<ring_buffer_sl, int64>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U64: SlStorageHelper<ring_buffer_sl, uint64>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I8: SlStorageHelper<ring_buffer_sl, int8_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U8: SlStorageHelper<ring_buffer_sl, uint8_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I16: SlStorageHelper<ring_buffer_sl, int16_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U16: SlStorageHelper<ring_buffer_sl, uint16_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I32: SlStorageHelper<ring_buffer_sl, int32_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U32: SlStorageHelper<ring_buffer_sl, uint32_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_I64: SlStorageHelper<ring_buffer_sl, int64_t>::SlSaveLoad(ring, conv); break;
case SLE_VAR_U64: SlStorageHelper<ring_buffer_sl, uint64_t>::SlSaveLoad(ring, conv); break;
default: NOT_REACHED();
}
}
@@ -1288,14 +1288,14 @@ static inline size_t SlCalcVectorLen(const void *vector, VarType conv)
{
switch (GetVarMemType(conv)) {
case SLE_VAR_BL: NOT_REACHED(); // Not supported
case SLE_VAR_I8: return SlStorageHelper<std::vector, int8>::SlCalcLen(vector, conv);
case SLE_VAR_U8: return SlStorageHelper<std::vector, uint8>::SlCalcLen(vector, conv);
case SLE_VAR_I16: return SlStorageHelper<std::vector, int16>::SlCalcLen(vector, conv);
case SLE_VAR_U16: return SlStorageHelper<std::vector, uint16>::SlCalcLen(vector, conv);
case SLE_VAR_I32: return SlStorageHelper<std::vector, int32>::SlCalcLen(vector, conv);
case SLE_VAR_U32: return SlStorageHelper<std::vector, uint32>::SlCalcLen(vector, conv);
case SLE_VAR_I64: return SlStorageHelper<std::vector, int64>::SlCalcLen(vector, conv);
case SLE_VAR_U64: return SlStorageHelper<std::vector, uint64>::SlCalcLen(vector, conv);
case SLE_VAR_I8: return SlStorageHelper<std::vector, int8_t>::SlCalcLen(vector, conv);
case SLE_VAR_U8: return SlStorageHelper<std::vector, uint8_t>::SlCalcLen(vector, conv);
case SLE_VAR_I16: return SlStorageHelper<std::vector, int16_t>::SlCalcLen(vector, conv);
case SLE_VAR_U16: return SlStorageHelper<std::vector, uint16_t>::SlCalcLen(vector, conv);
case SLE_VAR_I32: return SlStorageHelper<std::vector, int32_t>::SlCalcLen(vector, conv);
case SLE_VAR_U32: return SlStorageHelper<std::vector, uint32_t>::SlCalcLen(vector, conv);
case SLE_VAR_I64: return SlStorageHelper<std::vector, int64_t>::SlCalcLen(vector, conv);
case SLE_VAR_U64: return SlStorageHelper<std::vector, uint64_t>::SlCalcLen(vector, conv);
default: NOT_REACHED();
}
}
@@ -1309,14 +1309,14 @@ static void SlVector(void *vector, VarType conv)
{
switch (GetVarMemType(conv)) {
case SLE_VAR_BL: NOT_REACHED(); // Not supported
case SLE_VAR_I8: SlStorageHelper<std::vector, int8>::SlSaveLoad(vector, conv); break;
case SLE_VAR_U8: SlStorageHelper<std::vector, uint8>::SlSaveLoad(vector, conv); break;
case SLE_VAR_I16: SlStorageHelper<std::vector, int16>::SlSaveLoad(vector, conv); break;
case SLE_VAR_U16: SlStorageHelper<std::vector, uint16>::SlSaveLoad(vector, conv); break;
case SLE_VAR_I32: SlStorageHelper<std::vector, int32>::SlSaveLoad(vector, conv); break;
case SLE_VAR_U32: SlStorageHelper<std::vector, uint32>::SlSaveLoad(vector, conv); break;
case SLE_VAR_I64: SlStorageHelper<std::vector, int64>::SlSaveLoad(vector, conv); break;
case SLE_VAR_U64: SlStorageHelper<std::vector, uint64>::SlSaveLoad(vector, conv); break;
case SLE_VAR_I8: SlStorageHelper<std::vector, int8_t>::SlSaveLoad(vector, conv); break;
case SLE_VAR_U8: SlStorageHelper<std::vector, uint8_t>::SlSaveLoad(vector, conv); break;
case SLE_VAR_I16: SlStorageHelper<std::vector, int16_t>::SlSaveLoad(vector, conv); break;
case SLE_VAR_U16: SlStorageHelper<std::vector, uint16_t>::SlSaveLoad(vector, conv); break;
case SLE_VAR_I32: SlStorageHelper<std::vector, int32_t>::SlSaveLoad(vector, conv); break;
case SLE_VAR_U32: SlStorageHelper<std::vector, uint32_t>::SlSaveLoad(vector, conv); break;
case SLE_VAR_I64: SlStorageHelper<std::vector, int64_t>::SlSaveLoad(vector, conv); break;
case SLE_VAR_U64: SlStorageHelper<std::vector, uint64_t>::SlSaveLoad(vector, conv); break;
default: NOT_REACHED();
}
}
@@ -1462,7 +1462,7 @@ static bool SlObjectMember(void *object, const SaveLoad &sld)
void *ptr = GetVariableAddress(object, sld);
switch (_sl.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:
@@ -1635,7 +1635,7 @@ std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt)
}
while (true) {
uint8 type = 0;
uint8_t type = 0;
SlSaveLoadConv(&type, SLE_UINT8);
if (type == SLE_FILE_END) break;
@@ -1676,7 +1676,7 @@ std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt)
* conversion. If this error triggers, that clearly didn't
* happen and this is a friendly poke to the developer to bump
* the savegame version and add conversion code. */
uint8 correct_type = GetSavegameFileType(*sld_it->second);
uint8_t correct_type = GetSavegameFileType(*sld_it->second);
if (correct_type != type) {
DEBUG(sl, 1, "Field type for '%s' was expected to be 0x%02X but 0x%02X was found", key.c_str(), correct_type, type);
SlErrorCorrupt("Field type is different than expected");
@@ -1705,7 +1705,7 @@ std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt)
/* Make sure we are not storing empty keys. */
assert(!sld.name.empty());
uint8 type = GetSavegameFileType(sld);
uint8_t type = GetSavegameFileType(sld);
assert(type != SLE_FILE_END);
SlSaveLoadConv(&type, SLE_UINT8);
@@ -1713,7 +1713,7 @@ std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt)
}
/* Add an end-of-header marker. */
uint8 type = SLE_FILE_END;
uint8_t type = SLE_FILE_END;
SlSaveLoadConv(&type, SLE_UINT8);
/* After the table, write down any sub-tables we might have. */
@@ -1944,7 +1944,7 @@ static void SlLoadCheckChunk(const ChunkHandler &ch)
* @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 (const ChunkHandler &ch : ChunkHandlers()) if (ch.id == id) return &ch;
return nullptr;
@@ -1955,7 +1955,7 @@ void SlLoadChunks()
{
_sl.action = SLA_LOAD;
uint32 id;
uint32_t id;
const ChunkHandler *ch;
for (id = SlReadUint32(); id != 0; id = SlReadUint32()) {
@@ -1968,7 +1968,7 @@ void SlLoadChunks()
}
/** Load a chunk */
void SlLoadChunkByID(uint32 id)
void SlLoadChunkByID(uint32_t id)
{
_sl.action = SLA_LOAD;
@@ -1984,7 +1984,7 @@ void SlLoadCheckChunks()
{
_sl.action = SLA_LOAD_CHECK;
uint32 id;
uint32_t id;
const ChunkHandler *ch;
for (id = SlReadUint32(); id != 0; id = SlReadUint32()) {
@@ -1997,7 +1997,7 @@ void SlLoadCheckChunks()
}
/** Load a chunk for savegame checking */
void SlLoadCheckChunkByID(uint32 id)
void SlLoadCheckChunkByID(uint32_t id)
{
_sl.action = SLA_LOAD_CHECK;
@@ -2021,7 +2021,7 @@ void SlFixPointers()
assert(_sl.action == SLA_PTRS);
}
void SlFixPointerChunkByID(uint32 id)
void SlFixPointerChunkByID(uint32_t id)
{
const ChunkHandler *ch = SlFindChunkHandler(id);
if (ch == nullptr) SlErrorCorrupt("Unknown chunk type");
@@ -2070,7 +2070,7 @@ static void SlSaveChunk(const ChunkHandler &ch)
}
/** Save a chunk of data */
void SlSaveChunkChunkByID(uint32 id)
void SlSaveChunkChunkByID(uint32_t id)
{
const ChunkHandler *ch = SlFindChunkHandler(id);
if (ch == nullptr) SlErrorCorrupt("Unknown chunk type");

View File

@@ -44,10 +44,10 @@ enum ChunkType {
/** Handlers and description of chunk. */
struct ChunkHandler {
uint32 id; ///< Unique ID (4 letters).
uint32_t id; ///< Unique ID (4 letters).
ChunkType type; ///< Type of the chunk. @see ChunkType
ChunkHandler(uint32 id, ChunkType type) : id(id), type(type) {}
ChunkHandler(uint32_t id, ChunkType type) : id(id), type(type) {}
virtual ~ChunkHandler() = default;
@@ -263,7 +263,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 SaveLoadType : byte {
@@ -294,7 +294,7 @@ struct SaveLoad {
std::string name; ///< Name of this field (optional, used for tables).
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; this field combines both FileVarType and MemVarType.
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 before this savegame version.
size_t size; ///< The sizeof size.
@@ -313,7 +313,7 @@ struct SaveLoad {
*/
struct SaveLoadCompat {
std::string name; ///< Name of the field.
uint16 length; ///< Length of the NULL field.
uint16_t length; ///< Length of the NULL field.
SaveLoadVersion version_from; ///< Save/load the variable starting from this savegame version.
SaveLoadVersion version_to; ///< Save/load the variable before this savegame version.
};
@@ -888,8 +888,8 @@ inline void *GetVariableAddress(const void *object, const SaveLoad &sld)
return sld.address_proc(const_cast<void *>(object), sld.extra_data);
}
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();

View File

@@ -116,7 +116,7 @@ static std::vector<SaveLoad> GetSettingsDesc(bool is_loading)
error("Unexpected save conv for %s: 0x%02X", sd->name, sd->save.conv);
}
/* economy.town_growth_rate is int8 here, but uint8 in upstream saves */
/* economy.town_growth_rate is int8_t here, but uint8_t in upstream saves */
if (is_loading && !SlXvIsFeaturePresent(XSLFI_TABLE_PATS) && strcmp(sd->name, "economy.town_growth_rate") == 0) {
SB(new_type, 0, 4, SLE_FILE_U8);
}

View File

@@ -31,22 +31,22 @@ static const SaveLoad _roadstop_desc[] = {
SLE_REF(RoadStop, next, REF_ROADSTOPS),
};
static uint16 _waiting_acceptance;
static uint32 _old_num_flows;
static uint16 _cargo_source;
static uint32 _cargo_source_xy;
static uint8 _cargo_periods;
static uint16_t _waiting_acceptance;
static uint32_t _old_num_flows;
static uint16_t _cargo_source;
static uint32_t _cargo_source_xy;
static uint8_t _cargo_periods;
static Money _cargo_feeder_share;
CargoPacketList _packets;
uint32 _old_num_dests;
uint32_t _old_num_dests;
uint _cargo_reserved_count;
struct FlowSaveLoad {
FlowSaveLoad() : source(0), via(0), share(0), restricted(false) {}
StationID source;
StationID via;
uint32 share;
uint32_t share;
bool restricted;
};
@@ -96,7 +96,7 @@ public:
void Load(BaseStation *bst) const override
{
uint8 num_specs = (uint8)SlGetStructListLength(UINT8_MAX);
uint8_t num_specs = (uint8_t)SlGetStructListLength(UINT8_MAX);
bst->speclist.resize(num_specs);
for (uint i = 0; i < num_specs; i++) {
@@ -124,7 +124,7 @@ public:
void Load(BaseStation *bst) const override
{
uint8 num_specs = (uint8)SlGetStructListLength(UINT8_MAX);
uint8_t num_specs = (uint8_t)SlGetStructListLength(UINT8_MAX);
bst->roadstop_speclist.resize(num_specs);
for (uint i = 0; i < num_specs; i++) {
@@ -191,7 +191,7 @@ public:
FlowSaveLoad flow;
FlowStat *fs = nullptr;
StationID prev_source = INVALID_STATION;
for (uint32 j = 0; j < num_flows; ++j) {
for (uint32_t j = 0; j < num_flows; ++j) {
SlObject(&flow, this->GetLoadDescription());
if (fs == nullptr || prev_source != flow.source) {
fs = &(*(ge->data->flows.insert(ge->data->flows.end(), FlowStat(flow.source, flow.via, flow.share, flow.restricted))));
@@ -344,7 +344,7 @@ public:
};
inline const static SaveLoadCompatTable compat_description = {};
static uint8 last_num_specs; ///< Number of specs of the last loaded station.
static uint8_t last_num_specs; ///< Number of specs of the last loaded station.
void Save(BaseStation *bst) const override
{
@@ -356,7 +356,7 @@ public:
void Load(BaseStation *bst) const override
{
uint32 num_tiles = (uint32)SlGetStructListLength(UINT32_MAX);
uint32_t num_tiles = (uint32_t)SlGetStructListLength(UINT32_MAX);
bst->custom_roadstop_tile_data.resize(num_tiles);
for (uint i = 0; i < num_tiles; i++) {
SlObject(&bst->custom_roadstop_tile_data[i], this->GetLoadDescription());

View File

@@ -46,7 +46,7 @@ struct STPEChunkHandler : ChunkHandler {
const std::vector<SaveLoad> slt = SlCompatTableHeader(_story_page_elements_desc, _story_page_elements_sl_compat);
int index;
uint32 max_sort_value = 0;
uint32_t max_sort_value = 0;
while ((index = SlIterateArray()) != -1) {
StoryPageElement *s = new (index) StoryPageElement();
SlObject(s, slt);
@@ -88,7 +88,7 @@ struct STPAChunkHandler : ChunkHandler {
const std::vector<SaveLoad> slt = SlCompatTableHeader(_story_pages_desc, _story_pages_sl_compat);
int index;
uint32 max_sort_value = 0;
uint32_t max_sort_value = 0;
while ((index = SlIterateArray()) != -1) {
StoryPage *s = new (index) StoryPage();
SlObject(s, slt);

View File

@@ -29,10 +29,10 @@ typedef TileMatrix<CargoTypes, 4> AcceptanceMatrix;
class SlTownSupplied : public DefaultSaveLoadHandler<SlTownSupplied, Town> {
public:
inline static const SaveLoad description[] = {
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),
};
inline const static SaveLoadCompatTable compat_description = _town_supplied_sl_compat;
@@ -68,10 +68,10 @@ public:
class SlTownReceived : public DefaultSaveLoadHandler<SlTownReceived, Town> {
public:
inline static const SaveLoad description[] = {
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),
};
inline const static SaveLoadCompatTable compat_description = _town_received_sl_compat;

View File

@@ -38,11 +38,11 @@ static std::vector<TileIndex> _path_tile;
namespace upstream_sl {
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;
class SlVehicleCommon : public DefaultSaveLoadHandler<SlVehicleCommon, Vehicle> {
@@ -271,7 +271,7 @@ public:
if (!_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];
@@ -312,7 +312,7 @@ public:
if (!_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];
}