Mercurial > hg > openttd
changeset 13566:30dc7b733ef3 draft
(svn r18088) -Codechange: remove CompareWidgetArrays
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 15 Nov 2009 10:38:04 +0000 |
parents | 40a13e194fd0 |
children | 14638a0897e7 |
files | src/widget.cpp src/widget_type.h src/window.cpp |
diffstat | 3 files changed, 3 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/widget.cpp +++ b/src/widget.cpp @@ -2329,50 +2329,6 @@ 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 @@ * 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 @@ 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;
--- a/src/widget_type.h +++ b/src/widget_type.h @@ -829,6 +829,6 @@ 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 */
--- a/src/window.cpp +++ b/src/window.cpp @@ -81,7 +81,7 @@ 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);