changeset 8995:3e58e70db5ad draft

(svn r12790) -Codechange: code style fixes. Patch by Alberth.
author rubidium <rubidium@openttd.org>
date Sat, 19 Apr 2008 13:28:48 +0000
parents e4c3087abbde
children 6a811008eb9f
files src/window.cpp src/window_func.h src/window_gui.h
diffstat 3 files changed, 26 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -625,11 +625,11 @@
 {
 	Window* const *wz;
 
-	for (wz = _z_windows;; wz++) {
+	FOR_ALL_WINDOWS(wz) {
 		Window *w = *wz;
-		assert(wz < _last_z_window);
 		if (w->window_class != WC_MAIN_WINDOW && !IsVitalWindow(w)) return w;
 	}
+	NOT_REACHED();
 }
 
 bool IsWindowOfPrototype(const Window *w, const Widget *widget)
@@ -1021,9 +1021,7 @@
  * @return a pointer to the found window if any, NULL otherwise */
 Window *FindWindowFromPt(int x, int y)
 {
-	Window* const *wz;
-
-	for (wz = _last_z_window; wz != _z_windows;) {
+	for (Window * const *wz = _last_z_window; wz != _z_windows;) {
 		Window *w = *--wz;
 		if (IsInsideBS(x, w->left, w->width) && IsInsideBS(y, w->top, w->height)) {
 			return w;
@@ -1041,6 +1039,7 @@
 	IConsoleClose();
 
 	_last_z_window = _z_windows;
+	_mouseover_last_w = NULL;
 	_no_scroll = 0;
 }
 
@@ -1607,8 +1606,7 @@
 static bool MaybeBringWindowToFront(const Window *w)
 {
 	bool bring_to_front = false;
-	Window* const *wz;
-	Window* const *uz;
+	Window * const *wz;
 
 	if (w->window_class == WC_MAIN_WINDOW ||
 			IsVitalWindow(w) ||
@@ -1618,7 +1616,7 @@
 	}
 
 	wz = FindWindowZPosition(w);
-	for (uz = wz; ++uz != _last_z_window;) {
+	for (Window * const *uz = wz; ++uz != _last_z_window;) {
 		Window *u = *uz;
 
 		/* A modal child will prevent the activation of the parent window */
@@ -1792,9 +1790,6 @@
 	}
 }
 
-extern void UpdateTileSelection();
-extern bool VpHandlePlaceSizingDrag();
-
 /**
  * Local counter that is incremented each time an mouse input event is detected.
  * The counter is used to stop auto-scrolling.
@@ -1855,6 +1850,9 @@
 	TIME_BETWEEN_DOUBLE_CLICK = 500, ///< Time between 2 left clicks before it becoming a double click, in ms
 };
 
+extern void UpdateTileSelection();
+extern bool VpHandlePlaceSizingDrag();
+
 void MouseLoop(MouseClick click, int mousewheel)
 {
 	int x,y;
@@ -2155,13 +2153,17 @@
  */
 void CallWindowTickEvent()
 {
-	Window* const *wz;
-
-	for (wz = _last_z_window; wz != _z_windows;) {
+	for (Window * const *wz = _last_z_window; wz != _z_windows;) {
 		CallWindowEventNP(*--wz, WE_TICK);
 	}
 }
 
+/**
+ * Try to delete a non-vital window.
+ * Non-vital windows are windows other than the game selection, main toolbar,
+ * status bar, toolbar menu, and tooltip windows. Stickied windows are also
+ * considered vital.
+ */
 void DeleteNonVitalWindows()
 {
 	Window* const *wz;
--- a/src/window_func.h
+++ b/src/window_func.h
@@ -32,7 +32,6 @@
 void DeleteAllNonVitalWindows();
 void HideVitalWindows();
 void ShowVitalWindows();
-Window **FindWindowZPosition(const Window *w);
 
 void InvalidateWindow(WindowClass cls, WindowNumber number);
 void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -549,15 +549,9 @@
 
 bool IsWindowOfPrototype(const Window *w, const Widget *widget);
 void AssignWidgetToWindow(Window *w, const Widget *widget);
-Window *AllocateWindow(
-							int x,
-							int y,
-							int width,
-							int height,
-							WindowProc *proc,
-							WindowClass cls,
-							const Widget *widget,
-							void *data = NULL);
+Window *AllocateWindow(int x, int y, int width, int height,
+			WindowProc *proc, WindowClass cls, const Widget *widget,
+			void *data = NULL);
 
 Window *AllocateWindowDesc(const WindowDesc *desc, void *data = NULL);
 Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL);
@@ -594,12 +588,6 @@
 void DrawSortButtonState(const Window *w, int widget, SortButtonState state);
 
 
-Window *GetCallbackWnd();
-void DeleteNonVitalWindows();
-void DeleteAllNonVitalWindows();
-void HideVitalWindows();
-void ShowVitalWindows();
-Window **FindWindowZPosition(const Window *w);
 
 /* window.cpp */
 extern Window *_z_windows[];
@@ -624,6 +612,13 @@
 	WSM_PRESIZE  = 3,
 };
 
+Window *GetCallbackWnd();
+void DeleteNonVitalWindows();
+void DeleteAllNonVitalWindows();
+void HideVitalWindows();
+void ShowVitalWindows();
+Window **FindWindowZPosition(const Window *w);
+
 void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y);
 
 void ResizeButtons(Window *w, byte left, byte right);