mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-09-03 11:59:15 +00:00
Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
committed by
Michael Lutz
parent
3b4f224c0b
commit
7c8e7c6b6e
@@ -225,7 +225,7 @@ void GroupStatistics::Clear()
|
||||
g->statistics.ClearAutoreplace();
|
||||
}
|
||||
|
||||
for (EngineRenewList erl = c->engine_renew_list; erl != NULL; erl = erl->next) {
|
||||
for (EngineRenewList erl = c->engine_renew_list; erl != nullptr; erl = erl->next) {
|
||||
const Engine *e = Engine::Get(erl->from);
|
||||
GroupStatistics &stats = GroupStatistics::Get(company, erl->group_id, e->type);
|
||||
if (!stats.autoreplace_defined) {
|
||||
@@ -277,7 +277,7 @@ void PropagateChildLivery(const Group *g)
|
||||
Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->group_id == g->index && (!v->IsGroundVehicle() || v->IsFrontEngine())) {
|
||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
||||
for (Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
u->colourmap = PAL_NONE;
|
||||
u->InvalidateNewGRFCache();
|
||||
}
|
||||
@@ -324,7 +324,7 @@ CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
if (!Group::CanAllocateItem()) return CMD_ERROR;
|
||||
|
||||
const Group *pg = Group::GetIfValid(GB(p2, 0, 16));
|
||||
if (pg != NULL) {
|
||||
if (pg != nullptr) {
|
||||
if (pg->owner != _current_company) return CMD_ERROR;
|
||||
if (pg->vehicle_type != vt) return CMD_ERROR;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
g->vehicle_type = vt;
|
||||
g->parent = INVALID_GROUP;
|
||||
|
||||
if (pg == NULL) {
|
||||
if (pg == nullptr) {
|
||||
const Company *c = Company::Get(_current_company);
|
||||
g->livery.colour1 = c->livery[LS_DEFAULT].colour1;
|
||||
g->livery.colour2 = c->livery[LS_DEFAULT].colour2;
|
||||
@@ -368,7 +368,7 @@ CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Group *g = Group::GetIfValid(p1);
|
||||
if (g == NULL || g->owner != _current_company) return CMD_ERROR;
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
||||
/* Remove all vehicles from the group */
|
||||
DoCommand(0, p1, 0, flags, CMD_REMOVE_ALL_VEHICLES_GROUP);
|
||||
@@ -424,7 +424,7 @@ CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Group *g = Group::GetIfValid(GB(p1, 0, 16));
|
||||
if (g == NULL || g->owner != _current_company) return CMD_ERROR;
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
||||
if (!HasBit(p1, 16)) {
|
||||
/* Rename group */
|
||||
@@ -438,13 +438,13 @@ CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
/* Delete the old name */
|
||||
free(g->name);
|
||||
/* Assign the new one */
|
||||
g->name = reset ? NULL : stredup(text);
|
||||
g->name = reset ? nullptr : stredup(text);
|
||||
}
|
||||
} else {
|
||||
/* Set group parent */
|
||||
const Group *pg = Group::GetIfValid(GB(p2, 0, 16));
|
||||
|
||||
if (pg != NULL) {
|
||||
if (pg != nullptr) {
|
||||
if (pg->owner != _current_company) return CMD_ERROR;
|
||||
if (pg->vehicle_type != g->vehicle_type) return CMD_ERROR;
|
||||
|
||||
@@ -454,7 +454,7 @@ CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
g->parent = (pg == NULL) ? INVALID_GROUP : pg->index;
|
||||
g->parent = (pg == nullptr) ? INVALID_GROUP : pg->index;
|
||||
GroupStatistics::UpdateAutoreplace(g->owner);
|
||||
|
||||
if (g->livery.in_use == 0) {
|
||||
@@ -498,7 +498,7 @@ static void AddVehicleToGroup(Vehicle *v, GroupID new_g)
|
||||
case VEH_AIRCRAFT:
|
||||
if (v->IsEngineCountable()) UpdateNumEngineGroup(v, v->group_id, new_g);
|
||||
v->group_id = new_g;
|
||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
||||
for (Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
u->colourmap = PAL_NONE;
|
||||
u->InvalidateNewGRFCache();
|
||||
u->UpdateViewport(true);
|
||||
@@ -526,7 +526,7 @@ CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||
Vehicle *v = Vehicle::GetIfValid(GB(p2, 0, 20));
|
||||
GroupID new_g = p1;
|
||||
|
||||
if (v == NULL || (!Group::IsValidID(new_g) && !IsDefaultGroupID(new_g) && new_g != NEW_GROUP)) return CMD_ERROR;
|
||||
if (v == nullptr || (!Group::IsValidID(new_g) && !IsDefaultGroupID(new_g) && new_g != NEW_GROUP)) return CMD_ERROR;
|
||||
|
||||
if (Group::IsValidID(new_g)) {
|
||||
Group *g = Group::Get(new_g);
|
||||
@@ -537,7 +537,7 @@ CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||
|
||||
if (new_g == NEW_GROUP) {
|
||||
/* Create new group. */
|
||||
CommandCost ret = CmdCreateGroup(0, flags, v->type, 0, NULL);
|
||||
CommandCost ret = CmdCreateGroup(0, flags, v->type, 0, nullptr);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
new_g = _new_group_id;
|
||||
@@ -548,7 +548,7 @@ CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||
|
||||
if (HasBit(p2, 31)) {
|
||||
/* Add vehicles in the shared order list as well. */
|
||||
for (Vehicle *v2 = v->FirstShared(); v2 != NULL; v2 = v2->NextShared()) {
|
||||
for (Vehicle *v2 = v->FirstShared(); v2 != nullptr; v2 = v2->NextShared()) {
|
||||
if (v2->group_id != new_g) AddVehicleToGroup(v2, new_g);
|
||||
}
|
||||
}
|
||||
@@ -592,7 +592,7 @@ CommandCost CmdAddSharedVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32
|
||||
if (v->group_id != id_g) continue;
|
||||
|
||||
/* For each shared vehicles add it to the group */
|
||||
for (Vehicle *v2 = v->FirstShared(); v2 != NULL; v2 = v2->NextShared()) {
|
||||
for (Vehicle *v2 = v->FirstShared(); v2 != nullptr; v2 = v2->NextShared()) {
|
||||
if (v2->group_id != id_g) DoCommand(tile, id_g, v2->index, flags, CMD_ADD_VEHICLE_GROUP, text);
|
||||
}
|
||||
}
|
||||
@@ -620,7 +620,7 @@ CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, DoCommandFlag flags, uint3
|
||||
GroupID old_g = p1;
|
||||
Group *g = Group::GetIfValid(old_g);
|
||||
|
||||
if (g == NULL || g->owner != _current_company) return CMD_ERROR;
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
Vehicle *v;
|
||||
@@ -657,7 +657,7 @@ CommandCost CmdSetGroupLivery(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
bool primary = !HasBit(p2, 8);
|
||||
Colours colour = Extract<Colours, 16, 8>(p2);
|
||||
|
||||
if (g == NULL || g->owner != _current_company) return CMD_ERROR;
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
||||
if (colour >= COLOUR_END && colour != INVALID_COLOUR) return CMD_ERROR;
|
||||
|
||||
@@ -709,7 +709,7 @@ static void SetGroupReplaceProtection(Group *g, bool protect)
|
||||
CommandCost CmdSetGroupReplaceProtection(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Group *g = Group::GetIfValid(p1);
|
||||
if (g == NULL || g->owner != _current_company) return CMD_ERROR;
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (HasBit(p2, 1)) {
|
||||
@@ -750,7 +750,7 @@ void SetTrainGroupID(Train *v, GroupID new_g)
|
||||
|
||||
assert(v->IsFrontEngine() || IsDefaultGroupID(new_g));
|
||||
|
||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
||||
for (Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
if (u->IsEngineCountable()) UpdateNumEngineGroup(u, u->group_id, new_g);
|
||||
|
||||
u->group_id = new_g;
|
||||
@@ -777,7 +777,7 @@ void UpdateTrainGroupID(Train *v)
|
||||
assert(v->IsFrontEngine() || v->IsFreeWagon());
|
||||
|
||||
GroupID new_g = v->IsFrontEngine() ? v->group_id : (GroupID)DEFAULT_GROUP;
|
||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
||||
for (Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
if (u->IsEngineCountable()) UpdateNumEngineGroup(u, u->group_id, new_g);
|
||||
|
||||
u->group_id = new_g;
|
||||
|
Reference in New Issue
Block a user