Merge: Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
@@ -233,7 +233,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) {
|
||||
@@ -285,7 +285,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();
|
||||
}
|
||||
@@ -332,7 +332,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;
|
||||
}
|
||||
@@ -343,7 +343,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;
|
||||
@@ -376,7 +376,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);
|
||||
@@ -438,7 +438,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 */
|
||||
@@ -452,13 +452,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;
|
||||
|
||||
@@ -468,7 +468,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) {
|
||||
@@ -517,7 +517,7 @@ CommandCost CmdCreateGroupFromList(TileIndex tile, DoCommandFlag flags, uint32 p
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
Group *g = Group::GetIfValid(_new_group_id);
|
||||
if (g == NULL || g->owner != _current_company) return CMD_ERROR;
|
||||
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
|
||||
|
||||
if (!StrEmpty(text)) {
|
||||
DoCommand(tile, g->index, 0, flags, CMD_ALTER_GROUP, text);
|
||||
@@ -557,7 +557,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);
|
||||
@@ -585,7 +585,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);
|
||||
@@ -596,7 +596,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;
|
||||
@@ -607,7 +607,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);
|
||||
}
|
||||
}
|
||||
@@ -651,7 +651,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);
|
||||
}
|
||||
}
|
||||
@@ -679,7 +679,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;
|
||||
@@ -716,7 +716,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;
|
||||
|
||||
@@ -768,7 +768,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)) {
|
||||
@@ -809,7 +809,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;
|
||||
@@ -836,7 +836,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