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:
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
static BuildingCounts<uint32> _building_counts;
|
||||
static BuildingCounts<uint32_t> _building_counts;
|
||||
static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
|
||||
|
||||
HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, NUM_HOUSES, INVALID_HOUSE_ID);
|
||||
@@ -53,8 +53,8 @@ static const GRFFile *GetHouseSpecGrf(HouseID house_id)
|
||||
* @param watched_cargo_triggers Cargo types that triggered the watched cargo callback.
|
||||
*/
|
||||
HouseResolverObject::HouseResolverObject(HouseID house_id, TileIndex tile, Town *town,
|
||||
CallbackID callback, uint32 param1, uint32 param2,
|
||||
bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers)
|
||||
CallbackID callback, uint32_t param1, uint32_t param2,
|
||||
bool not_yet_constructed, uint8_t initial_random_bits, CargoTypes watched_cargo_triggers)
|
||||
: ResolverObject(GetHouseSpecGrf(house_id), callback, param1, param2),
|
||||
house_scope(*this, house_id, tile, town, not_yet_constructed, initial_random_bits, watched_cargo_triggers),
|
||||
town_scope(*this, town, not_yet_constructed) // Don't access StorePSA if house is not yet constructed.
|
||||
@@ -67,12 +67,12 @@ GrfSpecFeature HouseResolverObject::GetFeature() const
|
||||
return GSF_HOUSES;
|
||||
}
|
||||
|
||||
uint32 HouseResolverObject::GetDebugID() const
|
||||
uint32_t HouseResolverObject::GetDebugID() const
|
||||
{
|
||||
return HouseSpec::Get(this->house_scope.house_id)->grf_prop.local_id;
|
||||
}
|
||||
|
||||
HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid)
|
||||
HouseClassID AllocateHouseClassID(byte grf_class_id, uint32_t grfid)
|
||||
{
|
||||
/* Start from 1 because 0 means that no class has been assigned. */
|
||||
for (int i = 1; i != lengthof(_class_mapping); i++) {
|
||||
@@ -136,21 +136,21 @@ void DecreaseBuildingCount(Town *t, HouseID house_id)
|
||||
if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--;
|
||||
}
|
||||
|
||||
/* virtual */ uint32 HouseScopeResolver::GetRandomBits() const
|
||||
/* virtual */ uint32_t HouseScopeResolver::GetRandomBits() const
|
||||
{
|
||||
/* Note: Towns build houses over houses. So during construction checks 'tile' may be a valid but unrelated house. */
|
||||
assert(IsValidTile(this->tile) && (this->not_yet_constructed || IsTileType(this->tile, MP_HOUSE)));
|
||||
return this->not_yet_constructed ? this->initial_random_bits : GetHouseRandomBits(this->tile);
|
||||
}
|
||||
|
||||
/* virtual */ uint32 HouseScopeResolver::GetTriggers() const
|
||||
/* virtual */ uint32_t HouseScopeResolver::GetTriggers() const
|
||||
{
|
||||
/* Note: Towns build houses over houses. So during construction checks 'tile' may be a valid but unrelated house. */
|
||||
assert(IsValidTile(this->tile) && (this->not_yet_constructed || IsTileType(this->tile, MP_HOUSE)));
|
||||
return this->not_yet_constructed ? 0 : GetHouseTriggers(this->tile);
|
||||
}
|
||||
|
||||
static uint32 GetNumHouses(HouseID house_id, const Town *town)
|
||||
static uint32_t GetNumHouses(HouseID house_id, const Town *town)
|
||||
{
|
||||
HouseClassID class_id = HouseSpec::Get(house_id)->class_id;
|
||||
|
||||
@@ -169,7 +169,7 @@ static uint32 GetNumHouses(HouseID house_id, const Town *town)
|
||||
* @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8.
|
||||
* @return a construction of bits obeying the newgrf format
|
||||
*/
|
||||
static uint32 GetNearbyTileInformation(byte parameter, TileIndex tile, bool grf_version8)
|
||||
static uint32_t GetNearbyTileInformation(byte parameter, TileIndex tile, bool grf_version8)
|
||||
{
|
||||
tile = GetNearbyTile(parameter, tile);
|
||||
return GetNearbyTileInformation(tile, grf_version8);
|
||||
@@ -262,7 +262,7 @@ static bool SearchNearbyHouseGRFID(TileIndex tile, void *user_data)
|
||||
* @param house the HouseID that is associated to the house, the callback is called for
|
||||
* @return the Manhattan distance from the center tile, if any, and 0 if failure
|
||||
*/
|
||||
static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseID house)
|
||||
static uint32_t GetDistanceFromNearbyHouse(uint8_t parameter, TileIndex tile, HouseID house)
|
||||
{
|
||||
static TestTileOnSearchProc * const search_procs[3] = {
|
||||
SearchNearbyHouseID,
|
||||
@@ -270,8 +270,8 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
|
||||
SearchNearbyHouseGRFID,
|
||||
};
|
||||
TileIndex found_tile = tile;
|
||||
uint8 searchtype = GB(parameter, 6, 2);
|
||||
uint8 searchradius = GB(parameter, 0, 6);
|
||||
uint8_t searchtype = GB(parameter, 6, 2);
|
||||
uint8_t searchradius = GB(parameter, 0, 6);
|
||||
if (searchtype >= lengthof(search_procs)) return 0; // do not run on ill-defined code
|
||||
if (searchradius < 1) return 0; // do not use a too low radius
|
||||
|
||||
@@ -289,7 +289,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
|
||||
/**
|
||||
* @note Used by the resolver to get values for feature 07 deterministic spritegroups.
|
||||
*/
|
||||
/* virtual */ uint32 HouseScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const
|
||||
/* virtual */ uint32_t HouseScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const
|
||||
{
|
||||
switch (variable) {
|
||||
/* Construction stage. */
|
||||
@@ -343,15 +343,15 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
|
||||
if (!IsValidCargoID(cid)) return 0;
|
||||
|
||||
/* Extract tile offset. */
|
||||
int8 x_offs = GB(GetRegister(0x100), 0, 8);
|
||||
int8 y_offs = GB(GetRegister(0x100), 8, 8);
|
||||
int8_t x_offs = GB(GetRegister(0x100), 0, 8);
|
||||
int8_t y_offs = GB(GetRegister(0x100), 8, 8);
|
||||
TileIndex testtile = Map::WrapToMap(this->tile + TileDiffXY(x_offs, y_offs));
|
||||
|
||||
StationFinder stations(TileArea(testtile, 1, 1));
|
||||
const StationList *sl = stations.GetStations();
|
||||
|
||||
/* Collect acceptance stats. */
|
||||
uint32 res = 0;
|
||||
uint32_t res = 0;
|
||||
for (Station *st : *sl) {
|
||||
if (HasBit(st->goods[cid].status, GoodsEntry::GES_EVER_ACCEPTED)) SetBit(res, 0);
|
||||
if (HasBit(st->goods[cid].status, GoodsEntry::GES_LAST_MONTH)) SetBit(res, 1);
|
||||
@@ -409,8 +409,8 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile,
|
||||
bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers)
|
||||
uint16_t GetHouseCallback(CallbackID callback, uint32_t param1, uint32_t param2, HouseID house_id, Town *town, TileIndex tile,
|
||||
bool not_yet_constructed, uint8_t initial_random_bits, CargoTypes watched_cargo_triggers)
|
||||
{
|
||||
assert(IsValidTile(tile) && (not_yet_constructed || IsTileType(tile, MP_HOUSE)));
|
||||
|
||||
@@ -426,7 +426,7 @@ static void DrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *grou
|
||||
const HouseSpec *hs = HouseSpec::Get(house_id);
|
||||
PaletteID palette = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOUR_START;
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) {
|
||||
uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile);
|
||||
uint16_t callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile);
|
||||
if (callback != CALLBACK_FAILED) {
|
||||
/* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */
|
||||
palette = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback;
|
||||
@@ -454,7 +454,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
|
||||
bool draw_old_one = true;
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_DRAW_FOUNDATIONS)) {
|
||||
/* Called to determine the type (if any) of foundation to draw for the house tile */
|
||||
uint32 callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile);
|
||||
uint32_t callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile);
|
||||
if (callback_res != CALLBACK_FAILED) draw_old_one = ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DRAW_FOUNDATIONS, callback_res);
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
|
||||
}
|
||||
|
||||
/* Simple wrapper for GetHouseCallback to keep the animation unified. */
|
||||
uint16 GetSimpleHouseCallback(CallbackID callback, uint32 param1, uint32 param2, const HouseSpec *spec, Town *town, TileIndex tile, CargoTypes extra_data)
|
||||
uint16_t GetSimpleHouseCallback(CallbackID callback, uint32_t param1, uint32_t param2, const HouseSpec *spec, Town *town, TileIndex tile, CargoTypes extra_data)
|
||||
{
|
||||
return GetHouseCallback(callback, param1, param2, spec - HouseSpec::Get(0), town, tile, false, 0, extra_data);
|
||||
}
|
||||
@@ -515,19 +515,19 @@ bool CanDeleteHouse(TileIndex tile)
|
||||
}
|
||||
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_DENY_DESTRUCTION)) {
|
||||
uint16 callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
||||
uint16_t callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
||||
return (callback_res == CALLBACK_FAILED || !ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DENY_DESTRUCTION, callback_res));
|
||||
} else {
|
||||
return !(hs->extra_flags & BUILDING_IS_PROTECTED);
|
||||
}
|
||||
}
|
||||
|
||||
static void AnimationControl(TileIndex tile, uint16 random_bits)
|
||||
static void AnimationControl(TileIndex tile, uint16_t random_bits)
|
||||
{
|
||||
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
|
||||
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) {
|
||||
uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random();
|
||||
uint32_t param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random();
|
||||
HouseAnimationBase::ChangeAnimationFrame(CBID_HOUSE_ANIMATION_START_STOP, hs, Town::GetByTile(tile), tile, param, 0);
|
||||
}
|
||||
}
|
||||
@@ -550,7 +550,7 @@ bool NewHouseTileLoop(TileIndex tile)
|
||||
* tile loop reaches them. This should only be enabled for the northern
|
||||
* tile, or strange things will happen (here, and in TTDPatch). */
|
||||
if (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) {
|
||||
uint16 random = GB(Random(), 0, 16);
|
||||
uint16_t random = GB(Random(), 0, 16);
|
||||
|
||||
if (hs->building_flags & BUILDING_HAS_1_TILE) AnimationControl(tile, random);
|
||||
if (hs->building_flags & BUILDING_2_TILES_Y) AnimationControl(TILE_ADDXY(tile, 0, 1), random);
|
||||
@@ -563,7 +563,7 @@ bool NewHouseTileLoop(TileIndex tile)
|
||||
|
||||
/* Check callback 21, which determines if a house should be destroyed. */
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_DESTRUCTION)) {
|
||||
uint16 callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
||||
uint16_t callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile);
|
||||
if (callback_res != CALLBACK_FAILED && Convert8bitBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DESTRUCTION, callback_res)) {
|
||||
ClearTownHouse(Town::GetByTile(tile), tile);
|
||||
return false;
|
||||
@@ -598,7 +598,7 @@ static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, byte base_rando
|
||||
/* Rerandomise bits. Scopes other than SELF are invalid for houses. For bug-to-bug-compatibility with TTDP we ignore the scope. */
|
||||
byte new_random_bits = Random();
|
||||
byte random_bits = GetHouseRandomBits(tile);
|
||||
uint32 reseed = object.GetReseedSum();
|
||||
uint32_t reseed = object.GetReseedSum();
|
||||
random_bits &= ~reseed;
|
||||
random_bits |= (first ? new_random_bits : base_random) & reseed;
|
||||
SetHouseRandomBits(tile, random_bits);
|
||||
@@ -634,10 +634,10 @@ void TriggerHouse(TileIndex t, HouseTrigger trigger)
|
||||
* @param trigger_cargoes Cargo types that triggered the callback.
|
||||
* @param random Random bits.
|
||||
*/
|
||||
void DoWatchedCargoCallback(TileIndex tile, TileIndex origin, CargoTypes trigger_cargoes, uint16 random)
|
||||
void DoWatchedCargoCallback(TileIndex tile, TileIndex origin, CargoTypes trigger_cargoes, uint16_t random)
|
||||
{
|
||||
TileIndexDiffC diff = TileIndexToTileIndexDiffC(origin, tile);
|
||||
uint32 cb_info = random << 16 | (uint8)diff.y << 8 | (uint8)diff.x;
|
||||
uint32_t cb_info = random << 16 | (uint8_t)diff.y << 8 | (uint8_t)diff.x;
|
||||
HouseAnimationBase::ChangeAnimationFrame(CBID_HOUSE_WATCHED_CARGO_ACCEPTED, HouseSpec::Get(GetHouseType(tile)), Town::GetByTile(tile), tile, 0, cb_info, trigger_cargoes);
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes)
|
||||
if (trigger_cargoes == 0) return;
|
||||
|
||||
/* Same random value for all tiles of a multi-tile house. */
|
||||
uint16 r = Random();
|
||||
uint16_t r = Random();
|
||||
|
||||
/* Do the callback, start at northern tile. */
|
||||
TileIndex north = tile + GetHouseNorthPart(id);
|
||||
|
Reference in New Issue
Block a user