Merge lp:~widelands-dev/widelands/bug_1566720_set_origin into lp:widelands

Proposed by kaputtnik
Status: Merged
Merged at revision: 7948
Proposed branch: lp:~widelands-dev/widelands/bug_1566720_set_origin
Merge into: lp:widelands
Diff against target: 14 lines (+2/-2)
1 file modified
src/editor/tools/set_origin_tool.cc (+2/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug_1566720_set_origin
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+291207@code.launchpad.net

Commit message

Fix miscalculation of map->get_width() and map->get_height() regarding coordinates.

Description of the change

This fixes bug 1566720.

The culprit was that map->get_width() and map->get_height() returns f.e. 64 with a map of 64x64. But internally calculations are made with range 0 to 63.

I have checked the other usages of map->get_width() and map->get_height() and it seems the other usages are fine.

Because i am not very familiar with the code someone else should may check the other usages of map->get_width() and map->get_height() to prevent some more bugs with this circumstance.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 978. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/121359254.
Appveyor build 811. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1566720_set_origin-811.

Revision history for this message
GunChleoc (gunchleoc) wrote :

LGTM. All other uses of map->get_width() seem to be OK. This was a classic indexing error.

@bunnybot merge

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/editor/tools/set_origin_tool.cc'
2--- src/editor/tools/set_origin_tool.cc 2016-04-06 09:23:04 +0000
3+++ src/editor/tools/set_origin_tool.cc 2016-04-07 06:58:09 +0000
4@@ -45,8 +45,8 @@
5 EditorActionArgs* /* args */,
6 Widelands::Map* map) {
7 Widelands::Coords nc
8- (map->get_width() - center.node.x,
9- map->get_height() - center.node.y);
10+ (map->get_width() - 1 - center.node.x,
11+ map->get_height() - 1 - center.node.y);
12 map->set_origin(nc);
13 eia.map_changed(EditorInteractive::MapWas::kGloballyMutated);
14 eia.set_rel_viewpoint

Subscribers

People subscribed via source and target branches

to status/vote changes: