(svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
--- a/src/airport_gui.cpp Sun May 04 08:56:59 2008 +0000
+++ b/src/airport_gui.cpp Sun May 04 09:39:16 2008 +0000
@@ -139,8 +139,8 @@
{
if (!IsValidPlayer(_current_player)) return;
- DeleteWindowById(WC_BUILD_TOOLBAR, 0);
- Window *w = AllocateWindowDescFront(&_air_toolbar_desc, 0);
+ DeleteWindowByClass(WC_BUILD_TOOLBAR);
+ Window *w = AllocateWindowDescFront(&_air_toolbar_desc, TRANSPORT_AIR);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}
--- a/src/dock_gui.cpp Sun May 04 08:56:59 2008 +0000
+++ b/src/dock_gui.cpp Sun May 04 09:39:16 2008 +0000
@@ -232,8 +232,8 @@
{
if (!IsValidPlayer(_current_player)) return;
- DeleteWindowById(WC_BUILD_TOOLBAR, 0);
- Window *w = AllocateWindowDesc(&_build_docks_toolbar_desc);
+ DeleteWindowByClass(WC_BUILD_TOOLBAR);
+ Window *w = AllocateWindowDescFront(&_build_docks_toolbar_desc, TRANSPORT_WATER);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}
--- a/src/openttd.h Sun May 04 08:56:59 2008 +0000
+++ b/src/openttd.h Sun May 04 09:39:16 2008 +0000
@@ -56,9 +56,10 @@
* the values for road and rail.
*/
TRANSPORT_BEGIN = 0,
- TRANSPORT_RAIL = 0,
- TRANSPORT_ROAD = 1,
- TRANSPORT_WATER, // = 2
+ TRANSPORT_RAIL = TRANSPORT_BEGIN,
+ TRANSPORT_ROAD,
+ TRANSPORT_WATER,
+ TRANSPORT_AIR,
TRANSPORT_END,
INVALID_TRANSPORT = 0xff,
};
--- a/src/rail_gui.cpp Sun May 04 08:56:59 2008 +0000
+++ b/src/rail_gui.cpp Sun May 04 09:39:16 2008 +0000
@@ -748,10 +748,10 @@
if (!ValParamRailtype(railtype)) return;
// don't recreate the window if we're clicking on a button and the window exists.
- if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
- DeleteWindowById(WC_BUILD_TOOLBAR, 0);
+ if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL))) {
+ DeleteWindowByClass(WC_BUILD_TOOLBAR);
_cur_railtype = railtype;
- w = AllocateWindowDesc(&_build_rail_desc);
+ w = AllocateWindowDescFront(&_build_rail_desc, TRANSPORT_RAIL);
SetupRailToolbar(railtype, w);
}
@@ -1597,8 +1597,8 @@
if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
Window *w;
_last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
- w = FindWindowById(WC_BUILD_TOOLBAR, 0);
- if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
+ w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
+ if (w != NULL) {
SetupRailToolbar(_cur_railtype, w);
SetWindowDirty(w);
}
@@ -1648,8 +1648,8 @@
}
_last_built_railtype = _cur_railtype = rt;
- Window *w = FindWindowById(WC_BUILD_TOOLBAR, 0);
- if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
+ Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
+ if (w != NULL) {
SetupRailToolbar(_cur_railtype, w);
SetWindowDirty(w);
}
--- a/src/road_gui.cpp Sun May 04 08:56:59 2008 +0000
+++ b/src/road_gui.cpp Sun May 04 09:39:16 2008 +0000
@@ -682,8 +682,8 @@
if (!IsValidPlayer(_current_player)) return;
_cur_roadtype = roadtype;
- DeleteWindowById(WC_BUILD_TOOLBAR, 0);
- Window *w = AllocateWindowDesc(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc);
+ DeleteWindowByClass(WC_BUILD_TOOLBAR);
+ Window *w = AllocateWindowDescFront(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}