Merge lp:~widelands-dev/widelands/bug-1535065 into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7775
Proposed branch: lp:~widelands-dev/widelands/bug-1535065
Merge into: lp:widelands
Diff against target: 34 lines (+16/-1)
1 file modified
src/editor/map_generator.cc (+16/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1535065
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+284658@code.launchpad.net

Commit message

Unset player starting position in MapGenerator if coordinates are illegal.

Description of the change

This fixes a crash with the random map generator where coordinates of player positions would be outside of the map.

The player positions generated aren't necessarily viable, but that's a problem for another day.

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

Hi, I am bunnybot (https://github.com/widelands/bunnybot).

I am keeping the source branch lp:~widelands-dev/widelands/bug-1535065 mirrored to https://github.com/widelands/widelands/tree/_widelands_dev_widelands_bug_1535065

You can give me commands by starting a line with @bunnybot <command>. I understand:
 merge: Merges the source branch into the target branch, closing the merge proposal. I will use the proposed commit message if it is set.

Revision history for this message
kaputtnik (franku) wrote :

So a user make a random map, saves it and when trying to start a game with this map an error message is shown because no player position is set. Then he has to start the editor again, load the map again and probably figure out how to set player positions... And he may think he has to do this always when creating a random map.

Providing a feature which does not work properly is not a good solution in my mind. Also regarding the generated player positions, which may not be viable.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I agree that this still needs more fixing - right now, I just want to get rid of the crash.

I tried fiddling wit it a bit, but as soon as I try to get the FCoords from the Coords, the player positions get messed up, and I have no idea why yet.

So, I am for merging this and leaving the bug open.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 507. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/106288371.
Appveyor build 388. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1535065-388.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 534. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/106464683.
Appveyor build 388. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1535065-388.

Revision history for this message
SirVer (sirver) :
review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/editor/map_generator.cc'
2--- src/editor/map_generator.cc 2016-01-28 05:24:34 +0000
3+++ src/editor/map_generator.cc 2016-02-02 13:02:30 +0000
4@@ -741,7 +741,7 @@
5 const std::string ai = map_.get_scenario_player_ai(1);
6 map_.set_nrplayers(map_info_.numPlayers);
7 FindNodeSize functor(FindNodeSize::sizeBig);
8- Coords playerstart;
9+ Coords playerstart(-1, -1);
10
11 // Build a basic structure how player start positions are placed
12 uint8_t line[3];
13@@ -850,6 +850,21 @@
14 coords2 = playerstart;
15 }
16
17+ // Remove coordinates if they are an illegal starting position.
18+ if (coords2.x < 0 || coords2.x > map_.get_width() - 1 ||
19+ coords2.y < 0 || coords2.y > map_.get_height() - 1) {
20+
21+ // TODO(GunChleoc): If we check for buildcaps here, this always fails.
22+ // we should bulldoze a bit of terrain to increase the chance that starting positions
23+ // do not fail:
24+ // map_.get_fcoords(coords2).field->nodecaps() & Widelands::BUILDCAPS_SIZEMASK
25+ // != Widelands::BUILDCAPS_BIG)
26+
27+ log("WARNING: Player %u has no starting position - illegal coordinates (%d, %d).\n",
28+ n, coords2.x, coords2.y);
29+ coords2 = Coords(-1, -1);
30+ }
31+
32 // Finally set the found starting position
33 map_.set_starting_pos(n, coords2);
34 }

Subscribers

People subscribed via source and target branches

to status/vote changes: