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
commit5ae795953afac677134e54f91a11436acb3c969d (patch)
tree43c72cfecc28dfa3d1fafc35fe5d61d59367a67c /src/rail_gui.cpp
parent8fff6e8638b848b129a3609ef22c0d0b611940e8 (diff)
downloadopenttd-5ae795953afac677134e54f91a11436acb3c969d.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;
}
}