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

@@ -35,17 +35,17 @@ void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p
if (result.Failed()) return;
/* find a locomotive in the depot. */
const Vehicle *found = NULL;
const Vehicle *found = nullptr;
const Train *t;
FOR_ALL_TRAINS(t) {
if (t->IsFrontEngine() && t->tile == tile && t->IsStoppedInDepot()) {
if (found != NULL) return; // must be exactly one.
if (found != nullptr) return; // must be exactly one.
found = t;
}
}
/* if we found a loco, */
if (found != NULL) {
if (found != nullptr) {
found = found->Last();
/* put the new wagon at the end of the loco. */
DoCommandP(0, _new_vehicle_id, found->index, CMD_MOVE_RAIL_VEHICLE);
@@ -68,8 +68,8 @@ static int HighlightDragPosition(int px, int max_width, VehicleID selection, boo
assert(selection != INVALID_VEHICLE);
int dragged_width = 0;
for (Train *t = Train::Get(selection); t != NULL; t = chain ? t->Next() : (t->HasArticulatedPart() ? t->GetNextArticulatedPart() : NULL)) {
dragged_width += t->GetDisplayImageWidth(NULL);
for (Train *t = Train::Get(selection); t != nullptr; t = chain ? t->Next() : (t->HasArticulatedPart() ? t->GetNextArticulatedPart() : nullptr)) {
dragged_width += t->GetDisplayImageWidth(nullptr);
}
int drag_hlight_left = rtl ? max(px - dragged_width + 1, 0) : px;
@@ -115,7 +115,7 @@ void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID select
bool sel_articulated = false;
bool dragging = (drag_dest != INVALID_VEHICLE);
bool drag_at_end_of_train = (drag_dest == v->index); // Head index is used to mark dragging at end of train.
for (; v != NULL && (rtl ? px > 0 : px < max_width); v = v->Next()) {
for (; v != nullptr && (rtl ? px > 0 : px < max_width); v = v->Next()) {
if (dragging && !drag_at_end_of_train && drag_dest == v->index) {
/* Highlight the drag-and-drop destination inside the train. */
int drag_hlight_width = HighlightDragPosition(px, max_width, selection, _cursor.vehchain);
@@ -348,7 +348,7 @@ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *su
item->capacity += v->cargo_cap;
item->amount += v->cargo.StoredCount();
if (item->source == INVALID_STATION) item->source = v->cargo.Source();
} while ((v = v->Next()) != NULL && v->IsArticulatedPart());
} while ((v = v->Next()) != nullptr && v->IsArticulatedPart());
}
/**
@@ -362,7 +362,7 @@ static uint GetLengthOfArticulatedVehicle(const Train *v)
do {
length += v->GetDisplayImageWidth();
} while ((v = v->Next()) != NULL && v->IsArticulatedPart());
} while ((v = v->Next()) != nullptr && v->IsArticulatedPart());
return length;
}
@@ -380,7 +380,7 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
if (det_tab == TDW_TAB_TOTALS) { // Total cargo tab
CargoArray act_cargo;
CargoArray max_cargo;
for (const Vehicle *v = Vehicle::Get(veh_id); v != NULL; v = v->Next()) {
for (const Vehicle *v = Vehicle::Get(veh_id); v != nullptr; v = v->Next()) {
act_cargo[v->cargo_type] += v->cargo.StoredCount();
max_cargo[v->cargo_type] += v->cargo_cap;
}
@@ -393,7 +393,7 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
}
num++; // needs one more because first line is description string
} else {
for (const Train *v = Train::Get(veh_id); v != NULL; v = v->GetNextVehicle()) {
for (const Train *v = Train::Get(veh_id); v != nullptr; v = v->GetNextVehicle()) {
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
num += max(1u, (unsigned)_cargo_summary.size());
@@ -433,7 +433,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
Direction dir = rtl ? DIR_E : DIR_W;
int x = rtl ? right : left;
byte line_number = 0;
for (; v != NULL && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
for (; v != nullptr && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
/* Draw sprites */
@@ -446,7 +446,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap && line_number == 0) {
int pitch = 0;
const Engine *e = Engine::Get(v->engine_type);
if (e->GetGRF() != NULL) {
if (e->GetGRF() != nullptr) {
pitch = ScaleGUITrad(e->GetGRF()->traininfo_vehicle_pitch);
}
PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
@@ -457,7 +457,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
px += rtl ? -width : width;
dx += width;
u = u->Next();
} while (u != NULL && u->IsArticulatedPart());
} while (u != nullptr && u->IsArticulatedPart());
bool separate_sprite_row = (dx > (uint)ScaleGUITrad(TRAIN_DETAILS_MAX_INDENT));
if (separate_sprite_row) {
@@ -514,7 +514,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
CargoArray max_cargo;
Money feeder_share = 0;
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
act_cargo[u->cargo_type] += u->cargo.StoredCount();
max_cargo[u->cargo_type] += u->cargo_cap;
feeder_share += u->cargo.FeederShare();