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/rail_gui.cpp | |
parent | 3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff) | |
download | openttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz |
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/rail_gui.cpp')
-rw-r--r-- | src/rail_gui.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index e3d307dc9..54aaf61f6 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -78,9 +78,9 @@ static void ShowSignalBuilder(Window *parent); */ static bool IsStationAvailable(const StationSpec *statspec) { - if (statspec == NULL || !HasBit(statspec->callback_mask, CBM_STATION_AVAIL)) return true; + if (statspec == nullptr || !HasBit(statspec->callback_mask, CBM_STATION_AVAIL)) return true; - uint16 cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE); + uint16 cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE); if (cb_res == CALLBACK_FAILED) return true; return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res); @@ -234,7 +234,7 @@ static void GenericPlaceSignals(TileIndex tile) /* various bitstuffed elements for CmdBuildSingleSignal() */ uint32 p1 = track; - if (w != NULL) { + if (w != nullptr) { /* signal GUI is used */ SB(p1, 3, 1, _ctrl_pressed); SB(p1, 4, 1, _cur_signal_variant); @@ -250,7 +250,7 @@ static void GenericPlaceSignals(TileIndex tile) } DoCommandP(tile, p1, 0, CMD_BUILD_SIGNALS | - CMD_MSG((w != NULL && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE), + CMD_MSG((w != nullptr && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE), CcPlaySound_SPLAT_RAIL); } } @@ -388,7 +388,7 @@ static void HandleAutoSignalPlacement() const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); - if (w != NULL) { + if (w != nullptr) { /* signal GUI is used */ SB(p2, 3, 1, 0); SB(p2, 4, 1, _cur_signal_variant); @@ -683,7 +683,7 @@ struct BuildRailToolbarWindow : Window { void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override { /* no dragging if you have pressed the convert button */ - if (FindWindowById(WC_BUILD_SIGNAL, 0) != NULL && _convert_signal_button && this->IsWidgetLowered(WID_RAT_BUILD_SIGNALS)) return; + if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr && _convert_signal_button && this->IsWidgetLowered(WID_RAT_BUILD_SIGNALS)) return; VpSelectTilesWithMethod(pt.x, pt.y, select_method); } @@ -781,7 +781,7 @@ static EventState RailToolbarGlobalHotkeys(int hotkey) if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_TRAIN)) return ES_NOT_HANDLED; extern RailType _last_built_railtype; Window *w = ShowBuildRailToolbar(_last_built_railtype); - if (w == NULL) return ES_NOT_HANDLED; + if (w == nullptr) return ES_NOT_HANDLED; return w->OnHotkey(hotkey); } @@ -862,12 +862,12 @@ static WindowDesc _build_rail_desc( * If the terraform toolbar is linked to the toolbar, that window is also opened. * * @param railtype Rail type to open the window for - * @return newly opened rail toolbar, or NULL if the toolbar could not be opened. + * @return newly opened rail toolbar, or nullptr if the toolbar could not be opened. */ Window *ShowBuildRailToolbar(RailType railtype) { - if (!Company::IsValidID(_local_company)) return NULL; - if (!ValParamRailtype(railtype)) return NULL; + if (!Company::IsValidID(_local_company)) return nullptr; + if (!ValParamRailtype(railtype)) return nullptr; DeleteWindowByClass(WC_BUILD_TOOLBAR); _cur_railtype = railtype; @@ -907,7 +907,7 @@ private: */ void CheckSelectedSize(const StationSpec *statspec) { - if (statspec == NULL || _settings_client.gui.station_dragdrop) return; + if (statspec == nullptr || _settings_client.gui.station_dragdrop) return; /* If current number of tracks is not allowed, make it as big as possible */ if (HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) { @@ -937,7 +937,7 @@ public: BuildRailStationWindow(WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent) { this->coverage_height = 2 * FONT_HEIGHT_NORMAL + 3 * WD_PAR_VSEP_NORMAL; - this->vscroll = NULL; + this->vscroll = nullptr; _railstation.newstations = newstation; this->CreateNestedTree(); @@ -970,7 +970,7 @@ public: * type is 'selected'. */ _railstation.station_class = STAT_CLASS_DFLT; _railstation.station_type = 0; - this->vscroll2 = NULL; + this->vscroll2 = nullptr; } if (newstation) { _railstation.station_count = StationClass::Get(_railstation.station_class)->GetSpecCount(); @@ -999,7 +999,7 @@ public: void OnPaint() override { bool newstations = _railstation.newstations; - const StationSpec *statspec = newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : NULL; + const StationSpec *statspec = newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr; if (_settings_client.gui.station_dragdrop) { SetTileSelectSize(1, 1); @@ -1018,7 +1018,7 @@ public: for (uint bits = 0; bits < 7; bits++) { bool disable = bits >= _settings_game.station.station_spread; - if (statspec == NULL) { + if (statspec == nullptr) { this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, disable); this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, disable); } else { @@ -1078,7 +1078,7 @@ public: StationClass *stclass = StationClass::Get(statclass); for (uint16 j = 0; j < stclass->GetSpecCount(); j++) { const StationSpec *statspec = stclass->GetSpec(j); - SetDParam(0, (statspec != NULL && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT); + SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT); d = maxdim(d, GetStringBoundingBox(str)); } } @@ -1180,7 +1180,7 @@ public: void OnResize() override { - if (this->vscroll != NULL) { // New stations available. + if (this->vscroll != nullptr) { // New stations available. this->vscroll->SetCapacityFromWidget(this, WID_BRAS_NEWST_LIST); } } @@ -1189,7 +1189,7 @@ public: { if (widget == WID_BRAS_SHOW_NEWST_TYPE) { const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type); - SetDParam(0, (statspec != NULL && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT); + SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT); } } @@ -1221,8 +1221,8 @@ public: _settings_client.gui.station_dragdrop = false; - const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : NULL; - if (statspec != NULL && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) { + const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr; + if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) { /* The previously selected number of platforms in invalid */ for (uint i = 0; i < 7; i++) { if (!HasBit(statspec->disallowed_lengths, i)) { @@ -1256,8 +1256,8 @@ public: _settings_client.gui.station_dragdrop = false; - const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : NULL; - if (statspec != NULL && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) { + const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr; + if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) { /* The previously selected number of tracks in invalid */ for (uint i = 0; i < 7; i++) { if (!HasBit(statspec->disallowed_platforms, i)) { @@ -1282,8 +1282,8 @@ public: this->ToggleWidgetLoweredState(WID_BRAS_PLATFORM_DRAG_N_DROP); /* get the first allowed length/number of platforms */ - const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : NULL; - if (statspec != NULL && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) { + const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr; + if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) { for (uint i = 0; i < 7; i++) { if (!HasBit(statspec->disallowed_lengths, i)) { this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN); @@ -1292,7 +1292,7 @@ public: } } } - if (statspec != NULL && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) { + if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) { for (uint i = 0; i < 7; i++) { if (!HasBit(statspec->disallowed_platforms, i)) { this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN); @@ -1598,7 +1598,7 @@ public: /* If 'remove' button of rail build toolbar is active, disable it. */ if (_remove_button_clicked) { Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL); - if (w != NULL) ToggleRailButton_Remove(w); + if (w != nullptr) ToggleRailButton_Remove(w); } break; @@ -1768,7 +1768,7 @@ static const NWidgetPart _nested_build_depot_widgets[] = { }; static WindowDesc _build_depot_desc( - WDP_AUTO, NULL, 0, 0, + WDP_AUTO, nullptr, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_build_depot_widgets, lengthof(_nested_build_depot_widgets) @@ -1896,7 +1896,7 @@ void ReinitGuiAfterToggleElrail(bool disable) if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) { _last_built_railtype = _cur_railtype = RAILTYPE_RAIL; BuildRailToolbarWindow *w = dynamic_cast<BuildRailToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL)); - if (w != NULL) w->ModifyRailType(_cur_railtype); + if (w != nullptr) w->ModifyRailType(_cur_railtype); } MarkWholeScreenDirty(); } @@ -1943,7 +1943,7 @@ static void SetDefaultRailGui() _last_built_railtype = _cur_railtype = rt; BuildRailToolbarWindow *w = dynamic_cast<BuildRailToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL)); - if (w != NULL) w->ModifyRailType(_cur_railtype); + if (w != nullptr) w->ModifyRailType(_cur_railtype); } /** @@ -1958,7 +1958,7 @@ bool ResetSignalVariant(int32 p) if (new_variant != _cur_signal_variant) { Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); - if (w != NULL) { + if (w != nullptr) { w->SetDirty(); w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? WID_BS_ELECTRIC_NORM : WID_BS_SEMAPHORE_NORM) + _cur_signal_type); } |