summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2017-08-27 13:14:37 +0000
committerfrosch <frosch@openttd.org>2017-08-27 13:14:37 +0000
commit09abccd3164aada3176fa879f7e109a5117bd2f5 (patch)
treef0f134c938ef9230c35676087be9efb9c6800747
parent80dffae1308cc598451887a6aa5e6c46ae8faaf9 (diff)
downloadopenttd-09abccd3164aada3176fa879f7e109a5117bd2f5.tar.xz
(svn r27901) -Codechange: GetWindowZPriority only needs a WindowClass; this way it can also be used for WindowDesc before a Window instance is created. (3298)
-rw-r--r--src/window.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/window.cpp b/src/window.cpp
index a447ef0a9..2ce1124ed 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1264,17 +1264,17 @@ static inline bool IsVitalWindow(const Window *w)
* Get the z-priority for a given window. This is used in comparison with other z-priority values;
* a window with a given z-priority will appear above other windows with a lower value, and below
* those with a higher one (the ordering within z-priorities is arbitrary).
- * @param w The window to get the z-priority for
- * @pre w->window_class != WC_INVALID
+ * @param wc The window class of window to get the z-priority for
+ * @pre wc != WC_INVALID
* @return The window's z-priority
*/
-static uint GetWindowZPriority(const Window *w)
+static uint GetWindowZPriority(WindowClass wc)
{
- assert(w->window_class != WC_INVALID);
+ assert(wc != WC_INVALID);
uint z_priority = 0;
- switch (w->window_class) {
+ switch (wc) {
case WC_ENDSCREEN:
++z_priority;
FALLTHROUGH;
@@ -1358,11 +1358,11 @@ static void AddWindowToZOrdering(Window *w)
/* Search down the z-ordering for its location. */
Window *v = _z_front_window;
uint last_z_priority = UINT_MAX;
- while (v != NULL && (v->window_class == WC_INVALID || GetWindowZPriority(v) > GetWindowZPriority(w))) {
+ while (v != NULL && (v->window_class == WC_INVALID || GetWindowZPriority(v->window_class) > GetWindowZPriority(w->window_class))) {
if (v->window_class != WC_INVALID) {
/* Sanity check z-ordering, while we're at it. */
- assert(last_z_priority >= GetWindowZPriority(v));
- last_z_priority = GetWindowZPriority(v);
+ assert(last_z_priority >= GetWindowZPriority(v->window_class));
+ last_z_priority = GetWindowZPriority(v->window_class);
}
v = v->z_back;