summaryrefslogtreecommitdiff
path: root/src/newgrf_commons.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/newgrf_commons.cpp
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/newgrf_commons.cpp')
-rw-r--r--src/newgrf_commons.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp
index e05217fee..c80f0e350 100644
--- a/src/newgrf_commons.cpp
+++ b/src/newgrf_commons.cpp
@@ -235,9 +235,9 @@ uint16 IndustryOverrideManager::AddEntityID(byte grf_local_id, uint32 grfid, byt
const IndustrySpec *inds = GetIndustrySpec(id);
/* This industry must be one that is not available(enabled), mostly because of climate.
- * And it must not already be used by a grf (grffile == NULL).
+ * And it must not already be used by a grf (grffile == nullptr).
* So reserve this slot here, as it is the chosen one */
- if (!inds->enabled && inds->grf_prop.grffile == NULL) {
+ if (!inds->enabled && inds->grf_prop.grffile == nullptr) {
EntityIDMapping *map = &mapping_ID[id];
if (map->entity_id == 0 && map->grfid == 0) {
@@ -463,13 +463,13 @@ uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
/**
* Returns company information like in vehicle var 43 or station var 43.
* @param owner Owner of the object.
- * @param l Livery of the object; NULL to use default.
+ * @param l Livery of the object; nullptr to use default.
* @return NewGRF company information.
*/
uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
{
- if (l == NULL && Company::IsValidID(owner)) l = &Company::Get(owner)->livery[LS_DEFAULT];
- return owner | (Company::IsValidAiID(owner) ? 0x10000 : 0) | (l != NULL ? (l->colour1 << 24) | (l->colour2 << 28) : 0);
+ if (l == nullptr && Company::IsValidID(owner)) l = &Company::Get(owner)->livery[LS_DEFAULT];
+ return owner | (Company::IsValidAiID(owner) ? 0x10000 : 0) | (l != nullptr ? (l->colour1 << 24) | (l->colour2 << 28) : 0);
}
/**
@@ -587,8 +587,8 @@ bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_r
*/
void NewGRFSpriteLayout::Clone(const DrawTileSeqStruct *source)
{
- assert(this->seq == NULL);
- assert(source != NULL);
+ assert(this->seq == nullptr);
+ assert(source != nullptr);
size_t count = 1; // 1 for the terminator
const DrawTileSeqStruct *element;
@@ -607,7 +607,7 @@ void NewGRFSpriteLayout::Clone(const NewGRFSpriteLayout *source)
{
this->Clone((const DrawTileSprites*)source);
- if (source->registers != NULL) {
+ if (source->registers != nullptr) {
size_t count = 1; // 1 for the ground sprite
const DrawTileSeqStruct *element;
foreach_draw_tile_seq(element, source->seq) count++;
@@ -625,7 +625,7 @@ void NewGRFSpriteLayout::Clone(const NewGRFSpriteLayout *source)
*/
void NewGRFSpriteLayout::Allocate(uint num_sprites)
{
- assert(this->seq == NULL);
+ assert(this->seq == nullptr);
DrawTileSeqStruct *sprites = CallocT<DrawTileSeqStruct>(num_sprites + 1);
sprites[num_sprites].MakeTerminator();
@@ -637,8 +637,8 @@ void NewGRFSpriteLayout::Allocate(uint num_sprites)
*/
void NewGRFSpriteLayout::AllocateRegisters()
{
- assert(this->seq != NULL);
- assert(this->registers == NULL);
+ assert(this->seq != nullptr);
+ assert(this->registers == nullptr);
size_t count = 1; // 1 for the ground sprite
const DrawTileSeqStruct *element;
@@ -685,7 +685,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun
bool ground = true;
foreach_draw_tile_seq(result, result_seq.data()) {
TileLayoutFlags flags = TLF_NOTHING;
- if (regs != NULL) flags = regs->flags;
+ if (regs != nullptr) flags = regs->flags;
/* Record var10 value for the sprite */
if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) {
@@ -697,7 +697,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun
if (!(flags & TLF_SPRITE)) {
if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
result->image.sprite += ground ? newgrf_ground_offset : newgrf_offset;
- if (constr_stage > 0 && regs != NULL) result->image.sprite += GetConstructionStageOffset(constr_stage, regs->max_sprite_offset);
+ if (constr_stage > 0 && regs != nullptr) result->image.sprite += GetConstructionStageOffset(constr_stage, regs->max_sprite_offset);
} else {
result->image.sprite += orig_offset;
}
@@ -713,12 +713,12 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun
if (!(flags & TLF_PALETTE)) {
if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
result->image.sprite += ground ? newgrf_ground_offset : newgrf_offset;
- if (constr_stage > 0 && regs != NULL) result->image.sprite += GetConstructionStageOffset(constr_stage, regs->max_palette_offset);
+ if (constr_stage > 0 && regs != nullptr) result->image.sprite += GetConstructionStageOffset(constr_stage, regs->max_palette_offset);
}
}
ground = false;
- if (regs != NULL) regs++;
+ if (regs != nullptr) regs++;
}
return var10_values;
@@ -739,7 +739,7 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_
bool ground = true;
foreach_draw_tile_seq(result, result_seq.data()) {
TileLayoutFlags flags = TLF_NOTHING;
- if (regs != NULL) flags = regs->flags;
+ if (regs != nullptr) flags = regs->flags;
/* Is the sprite or bounding box affected by an action-1-2-3 chain? */
if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) {
@@ -794,6 +794,6 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_
}
ground = false;
- if (regs != NULL) regs++;
+ if (regs != nullptr) regs++;
}
}