Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
This commit is contained in:
@@ -136,7 +136,7 @@ static byte MapAircraftMovementState(const Aircraft *v)
|
||||
if (st == nullptr) return AMS_TTDP_FLIGHT_TO_TOWER;
|
||||
|
||||
const AirportFTAClass *afc = st->airport.GetFTA();
|
||||
uint16 amdflag = afc->MovingData(v->pos)->flag;
|
||||
uint16_t amdflag = afc->MovingData(v->pos)->flag;
|
||||
|
||||
switch (v->state) {
|
||||
case HANGAR:
|
||||
@@ -304,12 +304,12 @@ static byte MapAircraftMovementAction(const Aircraft *v)
|
||||
}
|
||||
|
||||
|
||||
/* virtual */ uint32 VehicleScopeResolver::GetRandomBits() const
|
||||
/* virtual */ uint32_t VehicleScopeResolver::GetRandomBits() const
|
||||
{
|
||||
return this->v == nullptr ? 0 : this->v->random_bits;
|
||||
}
|
||||
|
||||
/* virtual */ uint32 VehicleScopeResolver::GetTriggers() const
|
||||
/* virtual */ uint32_t VehicleScopeResolver::GetTriggers() const
|
||||
{
|
||||
return this->v == nullptr ? 0 : this->v->waiting_triggers;
|
||||
}
|
||||
@@ -321,7 +321,7 @@ static byte MapAircraftMovementAction(const Aircraft *v)
|
||||
case VSG_SCOPE_SELF: return &this->self_scope;
|
||||
case VSG_SCOPE_PARENT: return &this->parent_scope;
|
||||
case VSG_SCOPE_RELATIVE: {
|
||||
int32 count = GB(relative, 0, 4);
|
||||
int32_t count = GB(relative, 0, 4);
|
||||
if (this->self_scope.v != nullptr && (relative != this->cached_relative_count || count == 0)) {
|
||||
/* Note: This caching only works as long as the VSG_SCOPE_RELATIVE cannot be used in
|
||||
* VarAct2 with procedure calls. */
|
||||
@@ -393,7 +393,7 @@ static const Livery *LiveryHelper(EngineID engine, const Vehicle *v)
|
||||
* with the same 'engine type'.
|
||||
* @return the position in the chain from front and tail and chain length.
|
||||
*/
|
||||
static uint32 PositionHelper(const Vehicle *v, bool consecutive)
|
||||
static uint32_t PositionHelper(const Vehicle *v, bool consecutive)
|
||||
{
|
||||
const Vehicle *u;
|
||||
byte chain_before = 0;
|
||||
@@ -412,7 +412,7 @@ static uint32 PositionHelper(const Vehicle *v, bool consecutive)
|
||||
return chain_before | chain_after << 8 | (chain_before + chain_after + consecutive) << 16;
|
||||
}
|
||||
|
||||
static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, byte variable, uint32 parameter, bool *available)
|
||||
static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, byte variable, uint32_t parameter, bool *available)
|
||||
{
|
||||
/* Calculated vehicle parameters */
|
||||
switch (variable) {
|
||||
@@ -437,11 +437,11 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
if (!HasBit(v->grf_cache.cache_valid, NCVV_CONSIST_CARGO_INFORMATION)) {
|
||||
const Vehicle *u;
|
||||
byte cargo_classes = 0;
|
||||
uint8 common_cargoes[NUM_CARGO];
|
||||
uint8 common_subtypes[256];
|
||||
uint8_t common_cargoes[NUM_CARGO];
|
||||
uint8_t common_subtypes[256];
|
||||
byte user_def_data = 0;
|
||||
CargoID common_cargo_type = CT_INVALID;
|
||||
uint8 common_subtype = 0xFF; // Return 0xFF if nothing is carried
|
||||
uint8_t common_subtype = 0xFF; // Return 0xFF if nothing is carried
|
||||
|
||||
/* Reset our arrays */
|
||||
memset(common_cargoes, 0, sizeof(common_cargoes));
|
||||
@@ -501,7 +501,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
* And this is only done by CheckCaches().
|
||||
*/
|
||||
const GRFFile *grffile = object->ro.grffile;
|
||||
uint8 common_bitnum = (common_cargo_type == CT_INVALID) ? 0xFF :
|
||||
uint8_t common_bitnum = (common_cargo_type == CT_INVALID) ? 0xFF :
|
||||
(grffile == nullptr || grffile->grf_version < 8) ? CargoSpec::Get(common_cargo_type)->bitnum : grffile->cargo_map[common_cargo_type];
|
||||
|
||||
return (v->grf_cache.consist_cargo_information & 0xFFFF00FF) | common_bitnum << 8;
|
||||
@@ -520,7 +520,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
{
|
||||
const Vehicle *w = v->Next();
|
||||
assert(w != nullptr);
|
||||
uint16 altitude = ClampTo<uint16_t>(v->z_pos - w->z_pos); // Aircraft height - shadow height
|
||||
uint16_t altitude = ClampTo<uint16_t>(v->z_pos - w->z_pos); // Aircraft height - shadow height
|
||||
byte airporttype = ATP_TTDP_LARGE;
|
||||
|
||||
const Station *st = GetTargetAirportIfValid(Aircraft::From(v));
|
||||
@@ -636,7 +636,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
if (object->ro.callback == CBID_NO_CALLBACK || object->ro.callback == CBID_RANDOM_TRIGGER || object->ro.callback == CBID_TRAIN_ALLOW_WAGON_ATTACH ||
|
||||
object->ro.callback == CBID_VEHICLE_START_STOP_CHECK || object->ro.callback == CBID_VEHICLE_32DAY_CALLBACK || object->ro.callback == CBID_VEHICLE_COLOUR_MAPPING ||
|
||||
object->ro.callback == CBID_VEHICLE_SPAWN_VISUAL_EFFECT) {
|
||||
Vehicle *u = v->Move((int32)GetRegister(0x10F));
|
||||
Vehicle *u = v->Move((int32_t)GetRegister(0x10F));
|
||||
if (u == nullptr) return 0; // available, but zero
|
||||
|
||||
if (parameter == 0x5F) {
|
||||
@@ -659,12 +659,12 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
*/
|
||||
if (!v->IsGroundVehicle()) return 0;
|
||||
|
||||
const Vehicle *u = v->Move((int8)parameter);
|
||||
const Vehicle *u = v->Move((int8_t)parameter);
|
||||
if (u == nullptr) return 0;
|
||||
|
||||
/* Get direction difference. */
|
||||
bool prev = (int8)parameter < 0;
|
||||
uint32 ret = prev ? DirDifference(u->direction, v->direction) : DirDifference(v->direction, u->direction);
|
||||
bool prev = (int8_t)parameter < 0;
|
||||
uint32_t ret = prev ? DirDifference(u->direction, v->direction) : DirDifference(v->direction, u->direction);
|
||||
if (ret > DIRDIFF_REVERSE) ret |= 0x08;
|
||||
|
||||
if (u->vehstatus & VS_HIDDEN) ret |= 0x80;
|
||||
@@ -709,7 +709,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
|
||||
case 0xFE:
|
||||
case 0xFF: {
|
||||
uint16 modflags = 0;
|
||||
uint16_t modflags = 0;
|
||||
|
||||
if (v->type == VEH_TRAIN) {
|
||||
const Train *t = Train::From(v);
|
||||
@@ -954,7 +954,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
/* virtual */ uint32 VehicleScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const
|
||||
/* virtual */ uint32_t VehicleScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const
|
||||
{
|
||||
if (this->v == nullptr) {
|
||||
/* Vehicle does not exist, so we're in a purchase list */
|
||||
@@ -1007,7 +1007,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
|
||||
|
||||
if (totalsets == 0) return nullptr;
|
||||
|
||||
uint set = (v->cargo.StoredCount() * totalsets) / std::max<uint16>(1u, v->cargo_cap);
|
||||
uint set = (v->cargo.StoredCount() * totalsets) / std::max<uint16_t>(1u, v->cargo_cap);
|
||||
set = std::min(set, totalsets - 1);
|
||||
|
||||
return in_motion ? group->loaded[set] : group->loading[set];
|
||||
@@ -1024,7 +1024,7 @@ GrfSpecFeature VehicleResolverObject::GetFeature() const
|
||||
}
|
||||
}
|
||||
|
||||
uint32 VehicleResolverObject::GetDebugID() const
|
||||
uint32_t VehicleResolverObject::GetDebugID() const
|
||||
{
|
||||
return Engine::Get(this->self_scope.self_type)->grf_prop.local_id;
|
||||
}
|
||||
@@ -1051,7 +1051,7 @@ static const GRFFile *GetEngineGrfFile(EngineID engine_type)
|
||||
* @param callback_param2 Second parameter (var 18) of the callback.
|
||||
*/
|
||||
VehicleResolverObject::VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool rotor_in_gui,
|
||||
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
|
||||
CallbackID callback, uint32_t callback_param1, uint32_t callback_param2)
|
||||
: ResolverObject(GetEngineGrfFile(engine_type), callback, callback_param1, callback_param2),
|
||||
self_scope(*this, engine_type, v, rotor_in_gui),
|
||||
parent_scope(*this, engine_type, ((v != nullptr) ? v->First() : v), rotor_in_gui),
|
||||
@@ -1096,7 +1096,7 @@ void GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction directio
|
||||
object.ResetState();
|
||||
object.callback_param1 = image_type | (stack << 8);
|
||||
const SpriteGroup *group = object.Resolve();
|
||||
uint32 reg100 = sprite_stack ? GetRegister(0x100) : 0;
|
||||
uint32_t reg100 = sprite_stack ? GetRegister(0x100) : 0;
|
||||
if (group != nullptr && group->GetNumResults() != 0) {
|
||||
result->seq[result->count].sprite = group->GetResult() + (direction % group->GetNumResults());
|
||||
result->seq[result->count].pal = GB(reg100, 0, 16); // zero means default recolouring
|
||||
@@ -1130,7 +1130,7 @@ void GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, EngineIma
|
||||
object.ResetState();
|
||||
object.callback_param1 = image_type | (stack << 8);
|
||||
const SpriteGroup *group = object.Resolve();
|
||||
uint32 reg100 = sprite_stack ? GetRegister(0x100) : 0;
|
||||
uint32_t reg100 = sprite_stack ? GetRegister(0x100) : 0;
|
||||
if (group != nullptr && group->GetNumResults() != 0) {
|
||||
result->seq[result->count].sprite = group->GetResult() + (rotor_pos % group->GetNumResults());
|
||||
result->seq[result->count].pal = GB(reg100, 0, 16); // zero means default recolouring
|
||||
@@ -1161,7 +1161,7 @@ bool UsesWagonOverride(const Vehicle *v)
|
||||
* @param v The vehicle to evaluate the callback for, or nullptr if it doesn't exist yet
|
||||
* @return The value the callback returned, or CALLBACK_FAILED if it failed
|
||||
*/
|
||||
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
|
||||
uint16_t GetVehicleCallback(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v)
|
||||
{
|
||||
VehicleResolverObject object(engine, v, VehicleResolverObject::WO_UNCACHED, false, callback, param1, param2);
|
||||
return object.ResolveCallback();
|
||||
@@ -1177,7 +1177,7 @@ uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, Eng
|
||||
* @param parent The vehicle to use for parent scope
|
||||
* @return The value the callback returned, or CALLBACK_FAILED if it failed
|
||||
*/
|
||||
uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent)
|
||||
uint16_t GetVehicleCallbackParent(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v, const Vehicle *parent)
|
||||
{
|
||||
VehicleResolverObject object(engine, v, VehicleResolverObject::WO_NONE, false, callback, param1, param2);
|
||||
object.parent_scope.SetVehicle(parent);
|
||||
@@ -1194,11 +1194,11 @@ int GetVehicleProperty(const Vehicle *v, PropertyID property, int orig_value, bo
|
||||
|
||||
int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, const Vehicle *v, bool is_signed)
|
||||
{
|
||||
uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, v);
|
||||
uint16_t callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, v);
|
||||
if (callback != CALLBACK_FAILED) {
|
||||
if (is_signed) {
|
||||
/* Sign extend 15 bit integer */
|
||||
return static_cast<int16>(callback << 1) / 2;
|
||||
return static_cast<int16_t>(callback << 1) / 2;
|
||||
} else {
|
||||
return callback;
|
||||
}
|
||||
@@ -1225,7 +1225,7 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16_t base_r
|
||||
|
||||
/* Rerandomise bits. Scopes other than SELF are invalid for rerandomisation. For bug-to-bug-compatibility with TTDP we ignore the scope. */
|
||||
uint16_t new_random_bits = Random();
|
||||
uint32 reseed = object.GetReseedSum();
|
||||
uint32_t reseed = object.GetReseedSum();
|
||||
v->random_bits &= ~reseed;
|
||||
v->random_bits |= (first ? new_random_bits : base_random_bits) & reseed;
|
||||
|
||||
|
Reference in New Issue
Block a user