1
0
Fork 0

(svn r24589) -Codechange: Return early in HandleAutoscroll() instead of nesting ifs.

release/1.3
frosch 2012-10-13 08:34:10 +00:00
parent 9d877e888a
commit 2abe4ac280
1 changed files with 24 additions and 22 deletions

View File

@ -2290,13 +2290,17 @@ static int _input_events_this_tick = 0;
*/ */
static void HandleAutoscroll() static void HandleAutoscroll()
{ {
if (_settings_client.gui.autoscroll && _game_mode != GM_MENU && !HasModalProgress()) { if (_game_mode == GM_MENU || HasModalProgress()) return;
if (!_settings_client.gui.autoscroll) return;
int x = _cursor.pos.x; int x = _cursor.pos.x;
int y = _cursor.pos.y; int y = _cursor.pos.y;
Window *w = FindWindowFromPt(x, y); Window *w = FindWindowFromPt(x, y);
if (w == NULL || w->flags & WF_DISABLE_VP_SCROLL) return; if (w == NULL || w->flags & WF_DISABLE_VP_SCROLL) return;
ViewPort *vp = IsPtInWindowViewport(w, x, y); ViewPort *vp = IsPtInWindowViewport(w, x, y);
if (vp != NULL) { if (vp == NULL) return;
x -= vp->left; x -= vp->left;
y -= vp->top; y -= vp->top;
@ -2313,8 +2317,6 @@ static void HandleAutoscroll()
w->viewport->dest_scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * scrollspeed, vp->zoom); w->viewport->dest_scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * scrollspeed, vp->zoom);
} }
#undef scrollspeed #undef scrollspeed
}
}
} }
enum MouseClick { enum MouseClick {