Merge: Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
@@ -135,16 +135,16 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh
|
||||
|
||||
if (v == wagon) return;
|
||||
|
||||
if (wagon == NULL) {
|
||||
if (head != NULL) wagon = head->Last();
|
||||
if (wagon == nullptr) {
|
||||
if (head != nullptr) wagon = head->Last();
|
||||
} else {
|
||||
wagon = wagon->Previous();
|
||||
if (wagon == NULL) return;
|
||||
if (wagon == nullptr) return;
|
||||
}
|
||||
|
||||
if (wagon == v) return;
|
||||
|
||||
DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == NULL ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
|
||||
DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == nullptr ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
|
||||
}
|
||||
|
||||
static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]; ///< Cell size for vehicle images in the depot view.
|
||||
@@ -230,7 +230,7 @@ void InitDepotWindowBlockSizes()
|
||||
if (!e->IsEnabled()) continue;
|
||||
|
||||
uint w = TRAININFO_DEFAULT_VEHICLE_WIDTH;
|
||||
if (e->GetGRF() != NULL && is_custom_sprite(e->u.rail.image_index)) {
|
||||
if (e->GetGRF() != nullptr && is_custom_sprite(e->u.rail.image_index)) {
|
||||
w = e->GetGRF()->traininfo_vehicle_width;
|
||||
if (w != VEHICLEINFO_FULL_VEHICLE_WIDTH) {
|
||||
/* Hopeless.
|
||||
@@ -281,7 +281,7 @@ struct DepotWindow : Window {
|
||||
this->unitnumber_digits = 2;
|
||||
|
||||
this->CreateNestedTree();
|
||||
this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : NULL);
|
||||
this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : nullptr);
|
||||
this->vscroll = this->GetScrollbar(WID_D_V_SCROLL);
|
||||
/* Don't show 'rename button' of aircraft hangar */
|
||||
this->GetWidget<NWidgetStacked>(WID_D_SHOW_RENAME)->SetDisplayedPlane(type == VEH_AIRCRAFT ? SZSP_NONE : 0);
|
||||
@@ -471,8 +471,8 @@ struct DepotWindow : Window {
|
||||
/* Clicking on 'line' / 'block' without a vehicle */
|
||||
if (this->type == VEH_TRAIN) {
|
||||
/* End the dragging */
|
||||
d->head = NULL;
|
||||
d->wagon = NULL;
|
||||
d->head = nullptr;
|
||||
d->wagon = nullptr;
|
||||
return MODE_DRAG_VEHICLE;
|
||||
} else {
|
||||
return MODE_ERROR; // empty block, so no vehicle is selected
|
||||
@@ -492,7 +492,7 @@ struct DepotWindow : Window {
|
||||
wagon = true;
|
||||
}
|
||||
|
||||
const Train *v = NULL;
|
||||
const Train *v = nullptr;
|
||||
if (this->type == VEH_TRAIN) {
|
||||
v = Train::From(*veh);
|
||||
d->head = d->wagon = v;
|
||||
@@ -527,12 +527,12 @@ struct DepotWindow : Window {
|
||||
x -= this->header_width;
|
||||
|
||||
/* find the vehicle in this row that was clicked */
|
||||
for (; v != NULL; v = v->Next()) {
|
||||
for (; v != nullptr; v = v->Next()) {
|
||||
x -= v->GetDisplayImageWidth();
|
||||
if (x < 0) break;
|
||||
}
|
||||
|
||||
d->wagon = (v != NULL ? v->GetFirstEnginePart() : NULL);
|
||||
d->wagon = (v != nullptr ? v->GetFirstEnginePart() : nullptr);
|
||||
|
||||
return MODE_DRAG_VEHICLE;
|
||||
}
|
||||
@@ -544,8 +544,8 @@ struct DepotWindow : Window {
|
||||
*/
|
||||
void DepotClick(int x, int y)
|
||||
{
|
||||
GetDepotVehiclePtData gdvp = { NULL, NULL };
|
||||
const Vehicle *v = NULL;
|
||||
GetDepotVehiclePtData gdvp = { nullptr, nullptr };
|
||||
const Vehicle *v = nullptr;
|
||||
DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
|
||||
|
||||
if (this->type == VEH_TRAIN) v = gdvp.wagon;
|
||||
@@ -555,14 +555,14 @@ struct DepotWindow : Window {
|
||||
return;
|
||||
|
||||
case MODE_DRAG_VEHICLE: { // start dragging of vehicle
|
||||
if (v != NULL && VehicleClicked(v)) return;
|
||||
if (v != nullptr && VehicleClicked(v)) return;
|
||||
|
||||
VehicleID sel = this->sel;
|
||||
|
||||
if (this->type == VEH_TRAIN && sel != INVALID_VEHICLE) {
|
||||
this->sel = INVALID_VEHICLE;
|
||||
TrainDepotMoveVehicle(v, sel, gdvp.head);
|
||||
} else if (v != NULL) {
|
||||
} else if (v != nullptr) {
|
||||
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
||||
SetMouseCursorVehicle(v, EIT_IN_DEPOT);
|
||||
_cursor.vehchain = _ctrl_pressed;
|
||||
@@ -730,7 +730,7 @@ struct DepotWindow : Window {
|
||||
uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
||||
for (uint num = 0; num < this->vehicle_list.size(); num++) {
|
||||
uint width = 0;
|
||||
for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
|
||||
for (const Train *v = Train::From(this->vehicle_list[num]); v != nullptr; v = v->Next()) {
|
||||
width += v->GetDisplayImageWidth();
|
||||
}
|
||||
max_width = max(max_width, width);
|
||||
@@ -841,24 +841,24 @@ struct DepotWindow : Window {
|
||||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
if (str == NULL) return;
|
||||
if (str == nullptr) return;
|
||||
|
||||
/* Do depot renaming */
|
||||
DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), NULL, str);
|
||||
DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), nullptr, str);
|
||||
}
|
||||
|
||||
bool OnRightClick(Point pt, int widget) override
|
||||
{
|
||||
if (widget != WID_D_MATRIX) return false;
|
||||
|
||||
GetDepotVehiclePtData gdvp = { NULL, NULL };
|
||||
const Vehicle *v = NULL;
|
||||
GetDepotVehiclePtData gdvp = { nullptr, nullptr };
|
||||
const Vehicle *v = nullptr;
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_D_MATRIX);
|
||||
DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp);
|
||||
|
||||
if (this->type == VEH_TRAIN) v = gdvp.wagon;
|
||||
|
||||
if (v == NULL || mode != MODE_DRAG_VEHICLE) return false;
|
||||
if (v == nullptr || mode != MODE_DRAG_VEHICLE) return false;
|
||||
|
||||
CargoArray capacity, loaded;
|
||||
|
||||
@@ -867,7 +867,7 @@ struct DepotWindow : Window {
|
||||
|
||||
/* loop through vehicle chain and collect cargoes */
|
||||
uint num = 0;
|
||||
for (const Vehicle *w = v; w != NULL; w = w->Next()) {
|
||||
for (const Vehicle *w = v; w != nullptr; w = w->Next()) {
|
||||
if (w->cargo_cap > 0 && w->cargo_type < NUM_CARGO) {
|
||||
capacity[w->cargo_type] += w->cargo_cap;
|
||||
loaded [w->cargo_type] += w->cargo.StoredCount();
|
||||
@@ -913,7 +913,7 @@ struct DepotWindow : Window {
|
||||
if (_ctrl_pressed) {
|
||||
/* Share-clone, do not open new viewport, and keep tool active */
|
||||
DoCommandP(this->window_number, v->index, 1, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type),
|
||||
_settings_client.gui.open_vehicle_gui_clone_share ? CcCloneVehicle : NULL);
|
||||
_settings_client.gui.open_vehicle_gui_clone_share ? CcCloneVehicle : nullptr);
|
||||
} else {
|
||||
/* Copy-clone, open viewport for new vehicle, and deselect the tool (assume player wants to changs things on new vehicle) */
|
||||
if (DoCommandP(this->window_number, v->index, 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle)) {
|
||||
@@ -968,20 +968,20 @@ struct DepotWindow : Window {
|
||||
}
|
||||
|
||||
NWidgetBase *matrix = this->GetWidget<NWidgetBase>(widget);
|
||||
const Vehicle *v = NULL;
|
||||
GetDepotVehiclePtData gdvp = {NULL, NULL};
|
||||
const Vehicle *v = nullptr;
|
||||
GetDepotVehiclePtData gdvp = {nullptr, nullptr};
|
||||
|
||||
if (this->GetVehicleFromDepotWndPt(pt.x - matrix->pos_x, pt.y - matrix->pos_y, &v, &gdvp) != MODE_DRAG_VEHICLE) return;
|
||||
|
||||
VehicleID new_vehicle_over = INVALID_VEHICLE;
|
||||
if (gdvp.head != NULL) {
|
||||
if (gdvp.wagon == NULL && gdvp.head->Last()->index != this->sel) { // ..at the end of the train.
|
||||
if (gdvp.head != nullptr) {
|
||||
if (gdvp.wagon == nullptr && gdvp.head->Last()->index != this->sel) { // ..at the end of the train.
|
||||
/* NOTE: As a wagon can't be moved at the begin of a train, head index isn't used to mark a drag-and-drop
|
||||
* destination inside a train. This head index is then used to indicate that a wagon is inserted at
|
||||
* the end of the train.
|
||||
*/
|
||||
new_vehicle_over = gdvp.head->index;
|
||||
} else if (gdvp.wagon != NULL && gdvp.head != gdvp.wagon &&
|
||||
} else if (gdvp.wagon != nullptr && gdvp.head != gdvp.wagon &&
|
||||
gdvp.wagon->index != this->sel &&
|
||||
gdvp.wagon->Previous()->index != this->sel) { // ..over an existing wagon.
|
||||
new_vehicle_over = gdvp.wagon->index;
|
||||
@@ -998,7 +998,7 @@ struct DepotWindow : Window {
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_D_MATRIX: {
|
||||
const Vehicle *v = NULL;
|
||||
const Vehicle *v = nullptr;
|
||||
VehicleID sel = this->sel;
|
||||
|
||||
this->sel = INVALID_VEHICLE;
|
||||
@@ -1006,20 +1006,20 @@ struct DepotWindow : Window {
|
||||
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_D_MATRIX);
|
||||
if (this->type == VEH_TRAIN) {
|
||||
GetDepotVehiclePtData gdvp = { NULL, NULL };
|
||||
GetDepotVehiclePtData gdvp = { nullptr, nullptr };
|
||||
|
||||
if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != INVALID_VEHICLE) {
|
||||
if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
|
||||
if (gdvp.wagon != nullptr && gdvp.wagon->index == sel && _ctrl_pressed) {
|
||||
DoCommandP(Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true,
|
||||
CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE));
|
||||
} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
|
||||
} else if (gdvp.wagon == nullptr || gdvp.wagon->index != sel) {
|
||||
this->vehicle_over = INVALID_VEHICLE;
|
||||
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
|
||||
} else if (gdvp.head != NULL && gdvp.head->IsFrontEngine()) {
|
||||
} else if (gdvp.head != nullptr && gdvp.head->IsFrontEngine()) {
|
||||
ShowVehicleViewWindow(gdvp.head);
|
||||
}
|
||||
}
|
||||
} else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, NULL) == MODE_DRAG_VEHICLE && v != NULL && sel == v->index) {
|
||||
} else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, nullptr) == MODE_DRAG_VEHICLE && v != nullptr && sel == v->index) {
|
||||
ShowVehicleViewWindow(v);
|
||||
}
|
||||
break;
|
||||
@@ -1055,7 +1055,7 @@ struct DepotWindow : Window {
|
||||
this->RaiseWidget(WID_D_SELL);
|
||||
this->SetWidgetDirty(WID_D_SELL);
|
||||
}
|
||||
if (this->nested_array[WID_D_SELL] != NULL && !this->IsWidgetDisabled(WID_D_SELL_CHAIN)) {
|
||||
if (this->nested_array[WID_D_SELL] != nullptr && !this->IsWidgetDisabled(WID_D_SELL_CHAIN)) {
|
||||
this->RaiseWidget(WID_D_SELL_CHAIN);
|
||||
this->SetWidgetDirty(WID_D_SELL_CHAIN);
|
||||
}
|
||||
@@ -1101,7 +1101,7 @@ static void DepotSellAllConfirmationCallback(Window *win, bool confirmed)
|
||||
*/
|
||||
void ShowDepotWindow(TileIndex tile, VehicleType type)
|
||||
{
|
||||
if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != NULL) return;
|
||||
if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != nullptr) return;
|
||||
|
||||
WindowDesc *desc;
|
||||
switch (type) {
|
||||
@@ -1129,7 +1129,7 @@ void DeleteDepotHighlightOfVehicle(const Vehicle *v)
|
||||
if (_special_mouse_mode != WSM_DRAGDROP) return;
|
||||
|
||||
w = dynamic_cast<DepotWindow*>(FindWindowById(WC_VEHICLE_DEPOT, v->tile));
|
||||
if (w != NULL) {
|
||||
if (w != nullptr) {
|
||||
if (w->sel == v->index) ResetObjectToPlace();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user