diff options
author | Henry Wilson <m3henry@googlemail.com> | 2019-04-10 22:07:06 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-04-10 23:22:20 +0200 |
commit | 7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch) | |
tree | 99f134b7e66367cf11e10bc5061896eab4a3264f /src/train_gui.cpp | |
parent | 3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff) | |
download | openttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz |
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/train_gui.cpp')
-rw-r--r-- | src/train_gui.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 31b7a2ec0..c927d42ce 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -33,17 +33,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); @@ -65,8 +65,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; @@ -112,7 +112,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); @@ -292,7 +292,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()); } /** @@ -306,7 +306,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; } @@ -324,7 +324,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; } @@ -337,7 +337,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()); @@ -375,7 +375,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po bool rtl = _current_text_dir == TD_RTL; Direction dir = rtl ? DIR_E : DIR_W; int x = rtl ? right : left; - 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 */ @@ -388,7 +388,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) { 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); @@ -399,7 +399,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) { @@ -450,7 +450,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(); |