diff options
author | bjarni <bjarni@openttd.org> | 2006-09-27 14:05:15 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2006-09-27 14:05:15 +0000 |
commit | c256566715bae14bdd3fd6b90d62d30353bac426 (patch) | |
tree | ff924c14ad3f7844aced15ae024efa6d4436a90b | |
parent | 07500c2d698ca66f0684a073cb9bd9b873ca7764 (diff) | |
download | openttd-c256566715bae14bdd3fd6b90d62d30353bac426.tar.xz |
(svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
Really bad stuff will happen if one of them contains a different number of widgets ;)
This is meant as a protection against incorrect additions of code rather than verifying that the current code works
-rw-r--r-- | depot_gui.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/depot_gui.c b/depot_gui.c index 31ecd71f5..951141d27 100644 --- a/depot_gui.c +++ b/depot_gui.c @@ -56,6 +56,7 @@ typedef enum DepotWindowWidgets { DEPOT_WIDGET_CLONE, DEPOT_WIDGET_LOCATION, DEPOT_WIDGET_RESIZE, + DEPOT_WIDGET_LAST, // used to assert if DepotWindowWidgets and widget_moves got different lengths. Due to this usage, it needs to be last } DepotWindowWidget; /* Define how to move each widget. The order is important */ @@ -738,6 +739,10 @@ void ShowDepotWindow(TileIndex tile, byte type) { Window *w; + /* First we ensure that the widget counts are equal in all 3 lists to prevent bad stuff from happening */ + assert(lengthof(widget_moves) == lengthof(_depot_widgets)); + assert(lengthof(widget_moves) == DEPOT_WIDGET_LAST); + switch (type) { case VEH_Train: w = AllocateWindowDescFront(&_train_depot_desc, tile); break; case VEH_Road: w = AllocateWindowDescFront(&_road_depot_desc, tile); break; |