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:
Rubidium
2023-05-08 19:01:06 +02:00
committed by rubidium42
parent 4f4810dc28
commit eaae0bb5e7
564 changed files with 4561 additions and 4561 deletions

View File

@@ -215,7 +215,7 @@ enum StationNaming {
/** Information to handle station action 0 property 24 correctly */
struct StationNameInformation {
uint32 free_names; ///< Current bitset of free names (we can remove names).
uint32_t free_names; ///< Current bitset of free names (we can remove names).
bool *indtypes; ///< Array of bools telling whether an industry type has been found.
};
@@ -245,7 +245,7 @@ static bool FindNearIndustryName(TileIndex tile, void *user_data)
static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming name_class)
{
static const uint32 _gen_station_name_bits[] = {
static const uint32_t _gen_station_name_bits[] = {
0, // STATIONNAMING_RAIL
0, // STATIONNAMING_ROAD
1U << M(STR_SV_STNAME_AIRPORT), // STATIONNAMING_AIRPORT
@@ -255,7 +255,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
};
const Town *t = st->town;
uint32 free_names = UINT32_MAX;
uint32_t free_names = UINT32_MAX;
bool indtypes[NUM_INDUSTRYTYPES];
memset(indtypes, 0, sizeof(indtypes));
@@ -301,7 +301,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
free_names = sni.free_names;
/* check default names */
uint32 tmp = free_names & _gen_station_name_bits[name_class];
uint32_t tmp = free_names & _gen_station_name_bits[name_class];
if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp);
/* check mine? */
@@ -343,7 +343,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
}
/* check direction compared to town */
static const int8 _direction_and_table[] = {
static const int8_t _direction_and_table[] = {
~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
@@ -1374,7 +1374,7 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
/* Check if the station is buildable */
if (HasBit(statspec->callback_mask, CBM_STATION_AVAIL)) {
uint16 cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE);
uint16_t cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE);
if (cb_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res)) return CMD_ERROR;
}
}
@@ -1442,10 +1442,10 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
if (statspec != nullptr) {
/* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */
uint32 platinfo = GetPlatformInfo(AXIS_X, GetStationGfx(tile), plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false);
uint32_t platinfo = GetPlatformInfo(AXIS_X, GetStationGfx(tile), plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false);
/* As the station is not yet completely finished, the station does not yet exist. */
uint16 callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, nullptr, tile);
uint16_t callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, nullptr, tile);
if (callback != CALLBACK_FAILED) {
if (callback < 8) {
SetStationGfx(tile, (callback & ~1) + axis);
@@ -1913,7 +1913,7 @@ static CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags
* @param adjacent Allow stations directly adjacent to other stations.
* @return The cost of this operation or an error.
*/
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through,
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through,
DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
{
if (!ValParamRoadType(rt) || !IsValidDiagDirection(ddir) || stop_type >= ROADSTOP_END) return CMD_ERROR;
@@ -1983,7 +1983,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, u
/* Check if the road stop is buildable */
if (HasBit(roadstopspec->callback_mask, CBM_ROAD_STOP_AVAIL)) {
uint16 cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, rt, is_truck_stop ? STATION_TRUCK : STATION_BUS, 0);
uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, rt, is_truck_stop ? STATION_TRUCK : STATION_BUS, 0);
if (cb_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(roadstopspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res)) return CMD_ERROR;
}
}
@@ -2199,7 +2199,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int repla
* @param remove_road Remove roads of drive-through stops?
* @return The cost of this operation or an error.
*/
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road)
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
{
if (stop_type >= ROADSTOP_END) return CMD_ERROR;
/* Check for incorrect width / height. */
@@ -2265,7 +2265,7 @@ CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width,
* @param distance minimum distance between town and airport
* @return the noise that will be generated, according to distance
*/
uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
uint8_t GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
{
/* 0 cannot be accounted, and 1 is the lowest that can be reduced from town.
* So no need to go any further*/
@@ -2275,7 +2275,7 @@ uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
* adding the town_council_tolerance 4 times, as a way to graduate, depending of the tolerance.
* Basically, it says that the less tolerant a town is, the bigger the distance before
* an actual decrease can be granted */
uint8 town_tolerance_distance = 8 + (_settings_game.difficulty.town_council_tolerance * 4);
uint8_t town_tolerance_distance = 8 + (_settings_game.difficulty.town_council_tolerance * 4);
/* now, we want to have the distance segmented using the distance judged bareable by town
* This will give us the coefficient of reduction the distance provides. */
@@ -2923,10 +2923,10 @@ static void DrawTile_Station(TileInfo *ti)
const NewGRFSpriteLayout *layout = nullptr;
DrawTileSprites tmp_rail_layout;
const DrawTileSprites *t = nullptr;
int32 total_offset;
int32_t total_offset;
const RailtypeInfo *rti = nullptr;
uint32 relocation = 0;
uint32 ground_relocation = 0;
uint32_t relocation = 0;
uint32_t ground_relocation = 0;
BaseStation *st = nullptr;
const StationSpec *statspec = nullptr;
uint tile_layout = 0;
@@ -2944,7 +2944,7 @@ static void DrawTile_Station(TileInfo *ti)
tile_layout = GetStationGfx(ti->tile);
if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) {
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile);
uint16_t callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile);
if (callback != CALLBACK_FAILED) tile_layout = (callback & ~1) + GetRailStationAxis(ti->tile);
}
@@ -3022,7 +3022,7 @@ static void DrawTile_Station(TileInfo *ti)
if (HasBit(statspec->flags, SSF_EXTENDED_FOUNDATIONS)) {
/* Station provides extended foundations. */
static const uint8 foundation_parts[] = {
static const uint8_t foundation_parts[] = {
0, 0, 0, 0, // Invalid, Invalid, Invalid, SLOPE_SW
0, 1, 2, 3, // Invalid, SLOPE_EW, SLOPE_SE, SLOPE_WSE
0, 4, 5, 6, // Invalid, SLOPE_NW, SLOPE_NS, SLOPE_NWS
@@ -3035,7 +3035,7 @@ static void DrawTile_Station(TileInfo *ti)
/* Each set bit represents one of the eight composite sprites to be drawn.
* 'Invalid' entries will not drawn but are included for completeness. */
static const uint8 composite_foundation_parts[] = {
static const uint8_t composite_foundation_parts[] = {
/* Invalid (00000000), Invalid (11010001), Invalid (11100100), SLOPE_SW (11100000) */
0x00, 0xD1, 0xE4, 0xE0,
/* Invalid (11001010), SLOPE_EW (11001001), SLOPE_SE (11000100), SLOPE_WSE (11000000) */
@@ -3046,7 +3046,7 @@ static void DrawTile_Station(TileInfo *ti)
0x4A, 0x09, 0x44
};
uint8 parts = composite_foundation_parts[ti->tileh];
uint8_t parts = composite_foundation_parts[ti->tileh];
/* If foundations continue beyond the tile's upper sides then
* mask out the last two pieces. */
@@ -3100,9 +3100,9 @@ draw_default_foundation:
if (layout != nullptr) {
/* Sprite layout which needs preprocessing */
bool separate_ground = HasBit(statspec->flags, SSF_SEPARATE_GROUND);
uint32 var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground);
for (uint8 var10 : SetBitIterator(var10_values)) {
uint32 var10_relocation = GetCustomStationRelocation(statspec, st, ti->tile, var10);
uint32_t var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground);
for (uint8_t var10 : SetBitIterator(var10_values)) {
uint32_t var10_relocation = GetCustomStationRelocation(statspec, st, ti->tile, var10);
layout->ProcessRegisters(var10, var10_relocation, separate_ground);
}
tmp_rail_layout.seq = layout->GetLayout(&tmp_rail_layout.ground);
@@ -3208,7 +3208,7 @@ draw_default_foundation:
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
{
int32 total_offset = 0;
int32_t total_offset = 0;
PaletteID pal = COMPANY_SPRITE_COLOUR(_local_company);
const DrawTileSprites *t = GetStationTileLayout(st, image);
const RailtypeInfo *railtype_info = nullptr;
@@ -3510,7 +3510,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i
return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); // enter station
} else if (x < stop) {
v->vehstatus |= VS_TRAIN_SLOWING;
uint16 spd = std::max(0, (stop - x) * 20 - 15);
uint16_t spd = std::max(0, (stop - x) * 20 - 15);
if (spd < v->cur_speed) v->cur_speed = spd;
}
}
@@ -3657,12 +3657,12 @@ static void UpdateStationRating(Station *st)
/* NewGRFs expect last speed to be 0xFF when no vehicle has arrived yet. */
uint last_speed = ge->HasVehicleEverTriedLoading() ? ge->last_speed : 0xFF;
uint32 var18 = ClampTo<uint8_t>(ge->time_since_pickup)
uint32_t var18 = ClampTo<uint8_t>(ge->time_since_pickup)
| (ClampTo<uint16_t>(ge->max_waiting_cargo) << 8)
| (ClampTo<uint8_t>(last_speed) << 24);
/* Convert to the 'old' vehicle types */
uint32 var10 = (st->last_vehicle_type == VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
uint16 callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs);
uint32_t var10 = (st->last_vehicle_type == VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
uint16_t callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs);
if (callback != CALLBACK_FAILED) {
skip = true;
rating = GB(callback, 0, 14);
@@ -3715,7 +3715,7 @@ static void UpdateStationRating(Station *st)
/* if rating is <= 127 and there are any items waiting, maybe remove some goods. */
if (rating <= 127 && waiting != 0) {
uint32 r = Random();
uint32_t r = Random();
if (rating <= (int)GB(r, 0, 7)) {
/* Need to have int, otherwise it will just overflow etc. */
waiting = std::max((int)waiting - (int)((GB(r, 8, 2) - 1) * num_dests), 0);
@@ -3889,7 +3889,7 @@ void DeleteStaleLinks(Station *from)
* @param usage Usage to add to link stat.
* @param mode Update mode to be applied.
*/
void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode)
void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode)
{
GoodsEntry &ge1 = st->goods[cargo];
Station *st2 = Station::Get(next_station_id);
@@ -3941,7 +3941,7 @@ void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint c
* @param front First vehicle in the consist.
* @param next_station_id Station the consist will be travelling to next.
*/
void IncreaseStats(Station *st, const Vehicle *front, StationID next_station_id, uint32 time)
void IncreaseStats(Station *st, const Vehicle *front, StationID next_station_id, uint32_t time)
{
for (const Vehicle *v = front; v != nullptr; v = v->Next()) {
if (v->refit_cap > 0) {
@@ -4527,7 +4527,7 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, in
*/
uint FlowStat::GetShare(StationID st) const
{
uint32 prev = 0;
uint32_t prev = 0;
for (const auto &it : this->shares) {
if (it.second == st) {
return it.first - prev;