Merge: Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
@@ -88,9 +88,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, _cur_railtype);
|
||||
uint16 cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE, _cur_railtype);
|
||||
if (cb_res == CALLBACK_FAILED) return true;
|
||||
|
||||
return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res);
|
||||
@@ -270,7 +270,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);
|
||||
@@ -287,7 +287,7 @@ static void GenericPlaceSignals(TileIndex tile)
|
||||
SB(p1, 18, 1, _settings_client.gui.adv_sig_bridge_tun_modes);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -446,7 +446,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);
|
||||
@@ -795,7 +795,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);
|
||||
}
|
||||
@@ -893,7 +893,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);
|
||||
}
|
||||
|
||||
@@ -980,12 +980,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;
|
||||
@@ -1025,7 +1025,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)) {
|
||||
@@ -1055,7 +1055,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();
|
||||
@@ -1088,7 +1088,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();
|
||||
@@ -1117,7 +1117,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);
|
||||
@@ -1137,7 +1137,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 {
|
||||
@@ -1197,7 +1197,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));
|
||||
}
|
||||
}
|
||||
@@ -1299,7 +1299,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);
|
||||
}
|
||||
}
|
||||
@@ -1308,7 +1308,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1340,8 +1340,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)) {
|
||||
@@ -1375,8 +1375,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)) {
|
||||
@@ -1401,8 +1401,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);
|
||||
@@ -1411,7 +1411,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);
|
||||
@@ -1748,7 +1748,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;
|
||||
|
||||
@@ -1955,7 +1955,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)
|
||||
@@ -2083,7 +2083,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();
|
||||
}
|
||||
@@ -2130,7 +2130,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2145,7 +2145,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_button);
|
||||
}
|
||||
|
Reference in New Issue
Block a user