summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-11-15 10:38:04 +0000
committerrubidium <rubidium@openttd.org>2009-11-15 10:38:04 +0000
commit884561f431301d60fae96be21daae933b5562311 (patch)
tree3f73d32d539d6df28b64c76bbc0aa7d6e447fb35 /src
parent9396a701fe74a998f9e677c15a4a768f5f3bd121 (diff)
downloadopenttd-884561f431301d60fae96be21daae933b5562311.tar.xz
(svn r18088) -Codechange: remove CompareWidgetArrays
Diffstat (limited to 'src')
-rw-r--r--src/widget.cpp60
-rw-r--r--src/widget_type.h2
-rw-r--r--src/window.cpp2
3 files changed, 3 insertions, 61 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 214570578..adaaef7eb 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -2329,50 +2329,6 @@ static Widget *InitializeNWidgets(NWidgetBase *nwid, bool rtl, int biggest_index
return widgets;
}
-/**
- * Compare two widget arrays with each other, and report differences.
- * @param orig Pointer to original widget array.
- * @param gen Pointer to generated widget array (from the nested widgets).
- * @param report Report differences to 'misc' debug stream.
- * @return Both widget arrays are equal.
- */
-bool CompareWidgetArrays(const Widget *orig, const Widget *gen, bool report)
-{
-#define CHECK(var, prn) \
- if (ow->var != gw->var) { \
- same = false; \
- if (report) DEBUG(misc, 1, "index %d, \"" #var "\" field: original " prn ", generated " prn, idx, ow->var, gw->var); \
- }
-#define CHECK_COORD(var) \
- if (ow->var != gw->var) { \
- same = false; \
- if (report) DEBUG(misc, 1, "index %d, \"" #var "\" field: original %d, generated %d, (difference %d)", idx, ow->var, gw->var, ow->var - gw->var); \
- }
-
- bool same = true;
- for (int idx = 0; ; idx++) {
- const Widget *ow = orig + idx;
- const Widget *gw = gen + idx;
-
- CHECK(type, "%d")
- CHECK(display_flags, "0x%x")
- CHECK(colour, "%d")
- CHECK_COORD(left)
- CHECK_COORD(right)
- CHECK_COORD(top)
- CHECK_COORD(bottom)
- CHECK(data, "%u")
- CHECK(tooltips, "%u")
-
- if (ow->type == WWT_LAST || gw->type == WWT_LAST) break;
- }
-
- return same;
-
-#undef CHECK
-#undef CHECK_COORD
-}
-
/* == Conversion code from NWidgetPart array to NWidgetBase* tree == */
/**
@@ -2592,14 +2548,13 @@ NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest
* Also cache the result and use the cache if possible.
* @param[in] parts Array with parts of the widgets.
* @param parts_length Length of the \a parts array.
- * @param[in] orig_wid Pointer to original widget array.
* @param wid_cache Pointer to the cache for storing the generated widget array (use \c NULL to prevent caching).
* @return Cached value if available, otherwise the generated widget array. If \a wid_cache is \c NULL, the caller should free the returned array.
*
* @pre Before the first call, \c *wid_cache should be \c NULL.
* @post The widget array stored in the \c *wid_cache should be free-ed by the caller.
*/
-const Widget *InitializeWidgetArrayFromNestedWidgets(const NWidgetPart *parts, int parts_length, const Widget *orig_wid, Widget **wid_cache)
+const Widget *InitializeWidgetArrayFromNestedWidgets(const NWidgetPart *parts, int parts_length, Widget **wid_cache)
{
const bool rtl = false; // Direction of the language is left-to-right
@@ -2609,19 +2564,6 @@ const Widget *InitializeWidgetArrayFromNestedWidgets(const NWidgetPart *parts, i
int biggest_index = -1;
NWidgetContainer *nwid = MakeNWidgets(parts, parts_length, &biggest_index);
Widget *gen_wid = InitializeNWidgets(nwid, rtl, biggest_index);
-
- if (!rtl && orig_wid) {
- /* There are two descriptions, compare them.
- * Comparing only makes sense when using a left-to-right language.
- */
- bool ok = CompareWidgetArrays(orig_wid, gen_wid, false);
- if (ok) {
- DEBUG(misc, 1, "Nested widgets are equal, min-size(%u, %u)", nwid->smallest_x, nwid->smallest_y);
- } else {
- DEBUG(misc, 0, "Nested widgets give different results");
- CompareWidgetArrays(orig_wid, gen_wid, true);
- }
- }
delete nwid;
if (wid_cache != NULL) *wid_cache = gen_wid;
diff --git a/src/widget_type.h b/src/widget_type.h
index 9c01a8b95..17c1e1413 100644
--- a/src/widget_type.h
+++ b/src/widget_type.h
@@ -829,6 +829,6 @@ static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container = NULL);
-const Widget *InitializeWidgetArrayFromNestedWidgets(const NWidgetPart *parts, int parts_length, const Widget *orig_wid, Widget **wid_cache);
+const Widget *InitializeWidgetArrayFromNestedWidgets(const NWidgetPart *parts, int parts_length, Widget **wid_cache);
#endif /* WIDGET_TYPE_H */
diff --git a/src/window.cpp b/src/window.cpp
index 0c3c8fbab..444e5cca5 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -81,7 +81,7 @@ WindowDesc::WindowDesc(int16 left, int16 top, int16 min_width, int16 min_height,
const Widget *WindowDesc::GetWidgets() const
{
if (this->nwid_parts != NULL) {
- InitializeWidgetArrayFromNestedWidgets(this->nwid_parts, this->nwid_length, NULL, &this->new_widgets);
+ InitializeWidgetArrayFromNestedWidgets(this->nwid_parts, this->nwid_length, &this->new_widgets);
}
const Widget *wids = this->new_widgets;
assert(wids != NULL);