summaryrefslogtreecommitdiff
path: root/src/landscape.cpp
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-04-10 22:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-10 23:22:20 +0200
commit7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch)
tree99f134b7e66367cf11e10bc5061896eab4a3264f /src/landscape.cpp
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/landscape.cpp')
-rw-r--r--src/landscape.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/landscape.cpp b/src/landscape.cpp
index b36f5c884..66be73bd6 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -82,12 +82,12 @@ extern const byte _slope_to_sprite_offset[32] = {
/**
* Description of the snow line throughout the year.
*
- * If it is \c NULL, a static snowline height is used, as set by \c _settings_game.game_creation.snow_line_height.
+ * If it is \c nullptr, a static snowline height is used, as set by \c _settings_game.game_creation.snow_line_height.
* Otherwise it points to a table loaded from a newGRF file that describes the variable snowline.
* @ingroup SnowLineGroup
* @see GetSnowLine() GameCreationSettings
*/
-static SnowLine *_snow_line = NULL;
+static SnowLine *_snow_line = nullptr;
/**
* Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
@@ -104,7 +104,7 @@ static SnowLine *_snow_line = NULL;
*/
Point InverseRemapCoords2(int x, int y, bool clamp_to_map, bool *clamped)
{
- if (clamped != NULL) *clamped = false; // Not clamping yet.
+ if (clamped != nullptr) *clamped = false; // Not clamping yet.
/* Initial x/y world coordinate is like if the landscape
* was completely flat on height 0. */
@@ -122,7 +122,7 @@ Point InverseRemapCoords2(int x, int y, bool clamp_to_map, bool *clamped)
Point old_pt = pt;
pt.x = Clamp(pt.x, -extra_tiles * TILE_SIZE, max_x);
pt.y = Clamp(pt.y, -extra_tiles * TILE_SIZE, max_y);
- if (clamped != NULL) *clamped = (pt.x != old_pt.x) || (pt.y != old_pt.y);
+ if (clamped != nullptr) *clamped = (pt.x != old_pt.x) || (pt.y != old_pt.y);
}
/* Now find the Z-world coordinate by fix point iteration.
@@ -147,7 +147,7 @@ Point InverseRemapCoords2(int x, int y, bool clamp_to_map, bool *clamped)
Point old_pt = pt;
pt.x = Clamp(pt.x, min_coord, max_x);
pt.y = Clamp(pt.y, min_coord, max_y);
- if (clamped != NULL) *clamped = *clamped || (pt.x != old_pt.x) || (pt.y != old_pt.y);
+ if (clamped != nullptr) *clamped = *clamped || (pt.x != old_pt.x) || (pt.y != old_pt.y);
}
return pt;
@@ -418,7 +418,7 @@ void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2)
* If a tile does not have a foundation, the function returns the same as GetTileSlope.
*
* @param tile The tile of interest.
- * @param z returns the z of the foundation slope. (Can be NULL, if not needed)
+ * @param z returns the z of the foundation slope. (Can be nullptr, if not needed)
* @return The slope on top of the foundation.
*/
Slope GetFoundationSlope(TileIndex tile, int *z)
@@ -426,7 +426,7 @@ Slope GetFoundationSlope(TileIndex tile, int *z)
Slope tileh = GetTileSlope(tile, z);
Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh);
uint z_inc = ApplyFoundationToSlope(f, &tileh);
- if (z != NULL) *z += z_inc;
+ if (z != nullptr) *z += z_inc;
return tileh;
}
@@ -572,7 +572,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
void DoClearSquare(TileIndex tile)
{
/* If the tile can have animation and we clear it, delete it from the animated tile list. */
- if (_tile_type_procs[GetTileType(tile)]->animate_tile_proc != NULL) DeleteAnimatedTile(tile);
+ if (_tile_type_procs[GetTileType(tile)]->animate_tile_proc != nullptr) DeleteAnimatedTile(tile);
MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0);
MarkTileDirtyByTile(tile);
@@ -616,7 +616,7 @@ void GetTileDesc(TileIndex tile, TileDesc *td)
*/
bool IsSnowLineSet()
{
- return _snow_line != NULL;
+ return _snow_line != nullptr;
}
/**
@@ -645,7 +645,7 @@ void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS])
*/
byte GetSnowLine()
{
- if (_snow_line == NULL) return _settings_game.game_creation.snow_line_height;
+ if (_snow_line == nullptr) return _settings_game.game_creation.snow_line_height;
YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd);
@@ -659,7 +659,7 @@ byte GetSnowLine()
*/
byte HighestSnowLine()
{
- return _snow_line == NULL ? _settings_game.game_creation.snow_line_height : _snow_line->highest_value;
+ return _snow_line == nullptr ? _settings_game.game_creation.snow_line_height : _snow_line->highest_value;
}
/**
@@ -669,7 +669,7 @@ byte HighestSnowLine()
*/
byte LowestSnowLine()
{
- return _snow_line == NULL ? _settings_game.game_creation.snow_line_height : _snow_line->lowest_value;
+ return _snow_line == nullptr ? _settings_game.game_creation.snow_line_height : _snow_line->lowest_value;
}
/**
@@ -679,7 +679,7 @@ byte LowestSnowLine()
void ClearSnowLine()
{
free(_snow_line);
- _snow_line = NULL;
+ _snow_line = nullptr;
}
/**
@@ -702,8 +702,8 @@ CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
cost.AddCost(GetWaterClass(tile) == WATER_CLASS_CANAL ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]);
}
- Company *c = (flags & (DC_AUTO | DC_BANKRUPT)) ? NULL : Company::GetIfValid(_current_company);
- if (c != NULL && (int)GB(c->clear_limit, 16, 16) < 1) {
+ Company *c = (flags & (DC_AUTO | DC_BANKRUPT)) ? nullptr : Company::GetIfValid(_current_company);
+ if (c != nullptr && (int)GB(c->clear_limit, 16, 16) < 1) {
return_cmd_error(STR_ERROR_CLEARING_LIMIT_REACHED);
}
@@ -711,7 +711,7 @@ CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
/* If this tile was the first tile which caused object destruction, always
* pass it on to the tile_type_proc. That way multiple test runs and the exec run stay consistent. */
- if (coa != NULL && coa->first_tile != tile) {
+ if (coa != nullptr && coa->first_tile != tile) {
/* If this tile belongs to an object which was already cleared via another tile, pretend it has been
* already removed.
* However, we need to check stuff, which is not the same for all object tiles. (e.g. being on water or not) */
@@ -725,7 +725,7 @@ CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
}
if (flags & DC_EXEC) {
- if (c != NULL) c->clear_limit -= 1 << 16;
+ if (c != nullptr) c->clear_limit -= 1 << 16;
if (do_clear) DoClearSquare(tile);
}
return cost;
@@ -750,8 +750,8 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
CommandCost last_error = CMD_ERROR;
bool had_success = false;
- const Company *c = (flags & (DC_AUTO | DC_BANKRUPT)) ? NULL : Company::GetIfValid(_current_company);
- int limit = (c == NULL ? INT32_MAX : GB(c->clear_limit, 16, 16));
+ const Company *c = (flags & (DC_AUTO | DC_BANKRUPT)) ? nullptr : Company::GetIfValid(_current_company);
+ int limit = (c == nullptr ? INT32_MAX : GB(c->clear_limit, 16, 16));
TileIterator *iter = HasBit(p2, 0) ? (TileIterator *)new DiagonalTileIterator(tile, p1) : new OrthogonalTileIterator(tile, p1);
for (; *iter != INVALID_TILE; ++(*iter)) {
@@ -761,7 +761,7 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
last_error = ret;
/* We may not clear more tiles. */
- if (c != NULL && GB(c->clear_limit, 16, 16) < 1) break;
+ if (c != nullptr && GB(c->clear_limit, 16, 16) < 1) break;
continue;
}
@@ -862,7 +862,7 @@ static void GenerateTerrain(int type, uint flag)
uint32 r = Random();
const Sprite *templ = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845, ST_MAPGEN);
- if (templ == NULL) usererror("Map generator sprites could not be loaded");
+ if (templ == nullptr) usererror("Map generator sprites could not be loaded");
uint x = r & MapMaxX();
uint y = (r >> MapLogX()) & MapMaxY();
@@ -1065,7 +1065,7 @@ static bool MakeLake(TileIndex tile, void *user_data)
MakeRiver(tile, Random());
/* Remove desert directly around the river tile. */
TileIndex t = tile;
- CircularTileSearch(&t, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, NULL);
+ CircularTileSearch(&t, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, nullptr);
return false;
}
}
@@ -1132,12 +1132,12 @@ static void River_GetNeighbours(AyStar *aystar, OpenListNode *current)
/* AyStar callback when an route has been found. */
static void River_FoundEndNode(AyStar *aystar, OpenListNode *current)
{
- for (PathNode *path = &current->path; path != NULL; path = path->parent) {
+ for (PathNode *path = &current->path; path != nullptr; path = path->parent) {
TileIndex tile = path->node.tile;
if (!IsWaterTile(tile)) {
MakeRiver(tile, Random());
/* Remove desert directly around the river tile. */
- CircularTileSearch(&tile, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, NULL);
+ CircularTileSearch(&tile, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, nullptr);
}
}
}
@@ -1249,7 +1249,7 @@ static bool FlowRiver(TileIndex spring, TileIndex begin)
end = lakeCenter;
MakeRiver(lakeCenter, Random());
/* Remove desert directly around the river tile. */
- CircularTileSearch(&lakeCenter, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, NULL);
+ CircularTileSearch(&lakeCenter, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, nullptr);
lakeCenter = end;
uint range = RandomRange(8) + 3;
CircularTileSearch(&lakeCenter, range, MakeLake, &height);
@@ -1280,7 +1280,7 @@ static void CreateRivers()
IncreaseGeneratingWorldProgress(GWP_RIVER);
for (int tries = 0; tries < 128; tries++) {
TileIndex t = RandomTile();
- if (!CircularTileSearch(&t, 8, FindSpring, NULL)) continue;
+ if (!CircularTileSearch(&t, 8, FindSpring, nullptr)) continue;
if (FlowRiver(t, t)) break;
}
}