Merge: Codechange: Use null pointer literal instead of the NULL macro

This commit is contained in:
Jonathan G Rennison
2019-04-11 18:14:13 +01:00
585 changed files with 6604 additions and 6604 deletions

View File

@@ -102,7 +102,7 @@ IndustryType GetIndustryType(TileIndex tile)
assert_tile(IsTileType(tile, MP_INDUSTRY), tile);
const Industry *ind = Industry::GetByTile(tile);
assert(ind != NULL);
assert(ind != nullptr);
return ind->type;
}
@@ -201,11 +201,11 @@ void Industry::PostDestructor(size_t index)
/**
* Return a random valid industry.
* @return random industry, NULL if there are no industries
* @return random industry, nullptr if there are no industries
*/
/* static */ Industry *Industry::GetRandom()
{
if (Industry::GetNumItems() == 0) return NULL;
if (Industry::GetNumItems() == 0) return nullptr;
int num = RandomRange((uint16)Industry::GetNumItems());
size_t index = MAX_UVALUE(size_t);
@@ -317,7 +317,7 @@ static void DrawTile_Industry(TileInfo *ti)
* DrawNewIndustry will return false if ever the resolver could not
* find any sprite to display. So in this case, we will jump on the
* substitute gfx instead. */
if (indts->grf_prop.spritegroup[0] != NULL && DrawNewIndustryTile(ti, ind, gfx, indts)) {
if (indts->grf_prop.spritegroup[0] != nullptr && DrawNewIndustryTile(ti, ind, gfx, indts)) {
return;
} else {
/* No sprite group (or no valid one) found, meaning no graphics associated.
@@ -386,7 +386,7 @@ static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh)
*/
if (gfx >= NEW_INDUSTRYTILEOFFSET) {
const IndustryTileSpec *indts = GetIndustryTileSpec(gfx);
if (indts->grf_prop.spritegroup[0] != NULL && HasBit(indts->callback_mask, CBM_INDT_DRAW_FOUNDATIONS)) {
if (indts->grf_prop.spritegroup[0] != nullptr && HasBit(indts->callback_mask, CBM_INDT_DRAW_FOUNDATIONS)) {
uint32 callback_res = GetIndustryTileCallback(CBID_INDTILE_DRAW_FOUNDATIONS, 0, 0, gfx, Industry::GetByTile(tile), tile);
if (callback_res != CALLBACK_FAILED && !ConvertBooleanCallback(indts->grf_prop.grffile, CBID_INDTILE_DRAW_FOUNDATIONS, callback_res)) return FOUNDATION_NONE;
}
@@ -476,7 +476,7 @@ static void GetTileDesc_Industry(TileIndex tile, TileDesc *td)
td->str = STR_LAI_TOWN_INDUSTRY_DESCRIPTION_UNDER_CONSTRUCTION;
}
if (is->grf_prop.grffile != NULL) {
if (is->grf_prop.grffile != nullptr) {
td->grf = GetGRFConfig(is->grf_prop.grffile->grfid)->GetName();
}
}
@@ -800,7 +800,7 @@ static void TileLoopIndustry_BubbleGenerator(TileIndex tile)
EV_BUBBLE
);
if (v != NULL) v->animation_substate = dir;
if (v != nullptr) v->animation_substate = dir;
}
static void TileLoop_Industry(TileIndex tile)
@@ -1107,7 +1107,7 @@ static void ChopLumberMillTrees(Industry *i)
}
TileIndex tile = i->location.tile;
if (CircularTileSearch(&tile, 40, SearchLumberMillTrees, NULL)) { // 40x40 tiles to search.
if (CircularTileSearch(&tile, 40, SearchLumberMillTrees, nullptr)) { // 40x40 tiles to search.
i->produced_cargo_waiting[0] = min(0xffff, i->produced_cargo_waiting[0] + 45); // Found a tree, add according value to waiting cargo.
}
}
@@ -1340,11 +1340,11 @@ static CheckNewIndustryProc * const _check_new_industry_procs[CHECK_END] = {
* Find a town for the industry, while checking for multiple industries in the same town.
* @param tile Position of the industry to build.
* @param type Industry type.
* @param[out] t Pointer to return town for the new industry, \c NULL is written if no good town can be found.
* @param[out] t Pointer to return town for the new industry, \c nullptr is written if no good town can be found.
* @return Succeeded or failed command.
*
* @pre \c *t != NULL
* @post \c *t points to a town on success, and \c NULL on failure.
* @pre \c *t != nullptr
* @post \c *t points to a town on success, and \c nullptr on failure.
*/
static CommandCost FindTownForIndustry(TileIndex tile, int type, Town **t)
{
@@ -1355,7 +1355,7 @@ static CommandCost FindTownForIndustry(TileIndex tile, int type, Town **t)
const Industry *i;
FOR_ALL_INDUSTRIES(i) {
if (i->type == (byte)type && i->town == *t) {
*t = NULL;
*t = nullptr;
return_cmd_error(STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN);
}
}
@@ -1392,7 +1392,7 @@ bool IsSlopeRefused(Slope current, Slope refused)
* @param[out] custom_shape_check Perform custom check for the site.
* @return Failed or succeeded command.
*/
static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type, bool *custom_shape_check = NULL)
static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type, bool *custom_shape_check = nullptr)
{
bool refused_slope = false;
bool custom_shape = false;
@@ -1454,7 +1454,7 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
}
} while ((++it)->ti.x != -0x80);
if (custom_shape_check != NULL) *custom_shape_check = custom_shape;
if (custom_shape_check != nullptr) *custom_shape_check = custom_shape;
/* It is almost impossible to have a fully flat land in TG, so what we
* do is that we check if we can make the land flat later on. See
@@ -1596,7 +1596,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
static CommandCost CheckIfFarEnoughFromConflictingIndustry(TileIndex tile, int type)
{
const IndustrySpec *indspec = GetIndustrySpec(type);
const Industry *i = NULL;
const Industry *i = nullptr;
/* On a large map with many industries, it may be faster to check an area. */
static const int dmax = 14;
@@ -1660,7 +1660,7 @@ static void AdvertiseIndustryOpening(const Industry *ind)
*/
static void PopulateStationsNearby(Industry *ind)
{
if (ind->neutral_station != NULL && !_settings_game.station.serve_neutral_industries) {
if (ind->neutral_station != nullptr && !_settings_game.station.serve_neutral_industries) {
/* Industry has a neutral station. Use it and ignore any other nearby stations. */
ind->stations_near.insert(ind->neutral_station);
ind->neutral_station->industries_near.clear();
@@ -1882,7 +1882,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
* @param[out] ip Pointer to store newly created industry.
* @return Succeeded or failed command.
*
* @post \c *ip contains the newly created industry if all checks are successful and the \a flags request actual creation, else it contains \c NULL afterwards.
* @post \c *ip contains the newly created industry if all checks are successful and the \a flags request actual creation, else it contains \c nullptr afterwards.
*/
static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, uint itspec_index, uint32 random_var8f, uint16 random_initial_bits, Owner founder, IndustryAvailabilityCallType creation_type, Industry **ip)
{
@@ -1890,7 +1890,7 @@ static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, Do
const IndustryTileTable *it = indspec->table[itspec_index];
bool custom_shape_check = false;
*ip = NULL;
*ip = nullptr;
std::vector<ClearedObjectArea> object_areas(_cleared_object_areas);
CommandCost ret = CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, random_initial_bits, founder, creation_type, &custom_shape_check);
@@ -1912,10 +1912,10 @@ static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, Do
ret = CheckIfFarEnoughFromConflictingIndustry(tile, type);
if (ret.Failed()) return ret;
Town *t = NULL;
Town *t = nullptr;
ret = FindTownForIndustry(tile, type, &t);
if (ret.Failed()) return ret;
assert(t != NULL);
assert(t != nullptr);
ret = CheckIfIndustryIsAllowed(tile, type, t);
if (ret.Failed()) return ret;
@@ -1971,7 +1971,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE);
const bool deity_prospect = _current_company == OWNER_DEITY && !HasBit(p1, 16);
Industry *ind = NULL;
Industry *ind = nullptr;
if (deity_prospect || (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry())) {
if (flags & DC_EXEC) {
/* Prospected industries are build as OWNER_TOWN to not e.g. be build on owned land of the founder */
@@ -2013,7 +2013,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (ret.Failed()) return ret;
}
if ((flags & DC_EXEC) && ind != NULL && _game_mode != GM_EDITOR) {
if ((flags & DC_EXEC) && ind != nullptr && _game_mode != GM_EDITOR) {
AdvertiseIndustryOpening(ind);
}
@@ -2026,7 +2026,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
* @param tile The location to build the industry.
* @param type The industry type to build.
* @param creation_type The circumstances the industry is created under.
* @return the created industry or NULL if it failed.
* @return the created industry or nullptr if it failed.
*/
static Industry *CreateNewIndustry(TileIndex tile, IndustryType type, IndustryAvailabilityCallType creation_type)
{
@@ -2034,9 +2034,9 @@ static Industry *CreateNewIndustry(TileIndex tile, IndustryType type, IndustryAv
uint32 seed = Random();
uint32 seed2 = Random();
Industry *i = NULL;
Industry *i = nullptr;
CommandCost ret = CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, RandomRange(indspec->num_table), seed, GB(seed2, 0, 16), OWNER_NONE, creation_type, &i);
assert(i != NULL || ret.Failed());
assert(i != nullptr || ret.Failed());
return i;
}
@@ -2118,16 +2118,16 @@ static uint GetNumberOfIndustries()
* than to try a few times before concluding it does not work.
* @param type Industry type of the desired industry.
* @param try_hard Try very hard to find a place. (Used to place at least one industry per type.)
* @return Pointer to created industry, or \c NULL if creation failed.
* @return Pointer to created industry, or \c nullptr if creation failed.
*/
static Industry *PlaceIndustry(IndustryType type, IndustryAvailabilityCallType creation_type, bool try_hard)
{
uint tries = try_hard ? 10000u : 2000u;
for (; tries > 0; tries--) {
Industry *ind = CreateNewIndustry(RandomTile(), type, creation_type);
if (ind != NULL) return ind;
if (ind != nullptr) return ind;
}
return NULL;
return nullptr;
}
/**
@@ -2393,7 +2393,7 @@ void IndustryBuildData::TryBuildNewIndustry()
/* Try to create the industry. */
const Industry *ind = PlaceIndustry(it, IACT_RANDOMCREATION, false);
if (ind == NULL) {
if (ind == nullptr) {
this->builddata[it].wait_count = this->builddata[it].max_wait + 1; // Compensate for decrementing below.
this->builddata[it].max_wait = min(1000, this->builddata[it].max_wait + 2);
} else {
@@ -2482,7 +2482,7 @@ static int WhoCanServiceIndustry(Industry *ind)
bool c_accepts = false;
bool c_produces = false;
if (v->type == VEH_TRAIN && v->IsFrontEngine()) {
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
CanCargoServiceIndustry(u->cargo_type, ind, &c_accepts, &c_produces);
}
} else if (v->type == VEH_ROAD || v->type == VEH_SHIP || v->type == VEH_AIRCRAFT) {
@@ -2501,7 +2501,7 @@ static int WhoCanServiceIndustry(Industry *ind)
if (o->IsType(OT_GOTO_STATION) && !(o->GetUnloadType() & OUFB_TRANSFER)) {
/* Vehicle visits a station to load or unload */
Station *st = Station::Get(o->GetDestination());
assert(st != NULL);
assert(st != nullptr);
/* Same cargo produced by industry is dropped here => not serviced by vehicle v */
if ((o->GetUnloadType() & OUFB_UNLOAD) && !c_accepts) break;
@@ -2782,7 +2782,7 @@ void IndustryDailyLoop()
_industry_builder.TryBuildNewIndustry();
} else {
Industry *i = Industry::GetRandom();
if (i != NULL) {
if (i != nullptr) {
ChangeIndustryProduction(i, false);
SetWindowDirty(WC_INDUSTRY_VIEW, i->index);
}
@@ -2940,8 +2940,8 @@ extern const TileTypeProcs _tile_type_industry_procs = {
AnimateTile_Industry, // animate_tile_proc
TileLoop_Industry, // tile_loop_proc
ChangeTileOwner_Industry, // change_tile_owner_proc
NULL, // add_produced_cargo_proc
NULL, // vehicle_enter_tile_proc
nullptr, // add_produced_cargo_proc
nullptr, // vehicle_enter_tile_proc
GetFoundation_Industry, // get_foundation_proc
TerraformTile_Industry, // terraform_tile_proc
};