display: Fix broken conditionals in display::scroll_to_tyles()

This purportedly fixes bug #18793.
(Candidate for 1.10, PLEASE TEST!)

The conditionals in question:

> if (scroll_type == ONSCREEN || ONSCREEN_WARP) {

This *always* evaluates to true when scroll_type != ONSCREEN, because
ONSCREEN_WARP is an enum member with a non-zero value. The bogus code is
effectively the same as:

> if ((scroll_type == ONSCREEN) || true) {

Which was most likely not the author's intention (fendrin in r49988).
Therefore, I've replaced the conditionals with what should be the
correct way to do what I suspect was meant above:

> if (scroll_type == ONSCREEN || scroll_type == ONSCREEN_WARP) {

This seems to fix the viewport centering issues for me, but it would be
nice if people reported their own experience with the fix before
backporting it to 1.10.
This commit is contained in:
Ignacio R. Morelle 2013-03-14 07:00:08 +00:00
parent 3ef2dbb656
commit b676c8cfe0
3 changed files with 6 additions and 2 deletions

View file

@ -65,6 +65,8 @@ Version 1.11.1+svn:
* Fixed (bug #18970): Moving a unit after closing a click dismiss dialogue.
* Increased bottom padding for story screen text when it reaches the bottom
of the screen.
* Fix viewport centering issues with actions such as the Next Unit command,
and the [scroll_to], [scroll_to_unit], and [message] WML actions (bug #18793).
* WML engine:
* [unit_overlay] and [remove_unit_overlay] now return a more meaningful
error message if the image= key is missing

View file

@ -45,6 +45,8 @@ Version 1.11.1+svn:
* Tooltip for the movement points display shows the movement costs.
* Updating the shroud after delaying shroud updates is done gradually instead
of instantly.
* Fixed viewport centering issues with the Next Unit action, and some WML
actions such as [scroll_to], [scroll_to_unit], and [message] (bug #18793).
* WML Engine:
* When a map is replaced the number of owned villages for a side is updated

View file

@ -2024,7 +2024,7 @@ void display::scroll_to_tiles(const std::vector<map_location>::const_iterator &
//if everything is fogged or the location list is empty
if(!valid) return;
if (scroll_type == ONSCREEN || ONSCREEN_WARP) {
if (scroll_type == ONSCREEN || scroll_type == ONSCREEN_WARP) {
SDL_Rect r = map_area();
int spacing = round_double(add_spacing*hex_size());
r.x += spacing;
@ -2047,7 +2047,7 @@ void display::scroll_to_tiles(const std::vector<map_location>::const_iterator &
int target_x = locs_bbox.x + locs_bbox.w/2;
int target_y = locs_bbox.y + locs_bbox.h/2;
if (scroll_type == ONSCREEN || ONSCREEN_WARP) {
if (scroll_type == ONSCREEN || scroll_type == ONSCREEN_WARP) {
// when doing an ONSCREEN scroll we do not center the target unless needed
SDL_Rect r = map_area();
int map_center_x = r.x + r.w/2;