# HG changeset patch # User bjarni # Date 1159365915 0 # Node ID bf6abb428dc8d66ae82cae99a413480eed41d4e5 # Parent 1a39612a62910f3f12fc86e4a6dde083360cea3e (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 diff -r 1a39612a6291 -r bf6abb428dc8 depot_gui.c --- a/depot_gui.c Wed Sep 27 13:53:59 2006 +0000 +++ b/depot_gui.c Wed Sep 27 14:05:15 2006 +0000 @@ -56,6 +56,7 @@ 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 @@ { 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;