← Back to team overview

widelands-dev team mailing list archive

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

 

kaputtnik has proposed merging lp:~widelands-dev/widelands/bug_1566720_set_origin into lp:widelands.

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

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1566720 in widelands: "Set Origin tool crashed the editor"
  https://bugs.launchpad.net/widelands/+bug/1566720

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug_1566720_set_origin/+merge/291207

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.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug_1566720_set_origin into lp:widelands.
=== modified file 'src/editor/tools/set_origin_tool.cc'
--- src/editor/tools/set_origin_tool.cc	2016-04-06 09:23:04 +0000
+++ src/editor/tools/set_origin_tool.cc	2016-04-07 06:58:09 +0000
@@ -45,8 +45,8 @@
                                       EditorActionArgs* /* args */,
 									  Widelands::Map* map) {
 	Widelands::Coords nc
-		(map->get_width()  - center.node.x,
-		 map->get_height() - center.node.y);
+		(map->get_width()  - 1 - center.node.x,
+		 map->get_height() - 1 - center.node.y);
 	map->set_origin(nc);
 	eia.map_changed(EditorInteractive::MapWas::kGloballyMutated);
 	eia.set_rel_viewpoint


Follow ups