summaryrefslogtreecommitdiff
path: root/src/rail_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-15 14:41:56 +0000
committerrubidium <rubidium@openttd.org>2008-05-15 14:41:56 +0000
commit6d880ada7f8e9e43961f71db503f18da3cd5d6a3 (patch)
tree43c72cfecc28dfa3d1fafc35fe5d61d59367a67c /src/rail_gui.cpp
parent31ab1e815a8f2af78bc1f17fa2e69b05e5806cd7 (diff)
downloadopenttd-6d880ada7f8e9e43961f71db503f18da3cd5d6a3.tar.xz
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
Diffstat (limited to 'src/rail_gui.cpp')
-rw-r--r--src/rail_gui.cpp35
1 files changed, 7 insertions, 28 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 12ddba97b..c56f014c4 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -653,12 +653,9 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
w->DisableWidget(RTW_REMOVE);
w->InvalidateWidget(RTW_REMOVE);
- w = FindWindowById(WC_BUILD_SIGNAL, 0);
- if (w != NULL) WP(w, def_d).close = true;
- w = FindWindowById(WC_BUILD_STATION, 0);
- if (w != NULL) WP(w, def_d).close = true;
- w = FindWindowById(WC_BUILD_DEPOT, 0);
- if (w != NULL) WP(w, def_d).close = true;
+ delete FindWindowById(WC_BUILD_SIGNAL, 0);
+ delete FindWindowById(WC_BUILD_STATION, 0);
+ delete FindWindowById(WC_BUILD_DEPOT, 0);
break;
case WE_PLACE_PRESIZE: {
@@ -875,8 +872,6 @@ static void StationBuildWndProc(Window *w, WindowEvent *e)
DrawPixelInfo tmp_dpi, *old_dpi;
const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
- if (WP(w, def_d).close) return;
-
if (_railstation.dragdrop) {
SetTileSelectSize(1, 1);
} else {
@@ -1123,15 +1118,11 @@ static void StationBuildWndProc(Window *w, WindowEvent *e)
break;
case WE_TICK:
- if (WP(w, def_d).close) {
- delete w;
- return;
- }
CheckRedrawStationCoverage(w);
break;
case WE_DESTROY:
- if (!WP(w, def_d).close) ResetObjectToPlace();
+ ResetObjectToPlace();
break;
}
}
@@ -1345,12 +1336,8 @@ static void SignalBuildWndProc(Window *w, WindowEvent *e)
w->SetDirty();
break;
- case WE_TICK:
- if (WP(w, def_d).close) delete w;
- return;
-
case WE_DESTROY:
- if (!WP(w, def_d).close) ResetObjectToPlace();
+ ResetObjectToPlace();
break;
}
}
@@ -1436,12 +1423,8 @@ static void BuildTrainDepotWndProc(Window *w, WindowEvent *e)
}
break;
- case WE_TICK:
- if (WP(w, def_d).close) delete w;
- return;
-
case WE_DESTROY:
- if (!WP(w, def_d).close) ResetObjectToPlace();
+ ResetObjectToPlace();
break;
}
}
@@ -1535,12 +1518,8 @@ static void BuildWaypointWndProc(Window *w, WindowEvent *e)
break;
}
- case WE_TICK:
- if (WP(w, def_d).close) delete w;
- break;
-
case WE_DESTROY:
- if (!WP(w, def_d).close) ResetObjectToPlace();
+ ResetObjectToPlace();
break;
}
}