Editor crashes with random map regarding player positions

Bug #1535065 reported by kaputtnik
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Undecided
Unassigned

Bug Description

When creating random maps setting of player positions fails. Sometimes they are on uncommon terrain like water or mountains, sometimes the editor crashes when one wants to check the player positions:

WARNING: Could not find a suitable place for player 2
widelands: /home/kaputtnik/widelands-repo/trunk/src/wui/interactive_base.cc:448: void InteractiveBase::move_view_to(Widelands::Coords): Assertion `0 <= c.x' failed.
Abgebrochen (Speicherabzug geschrieben)

or:

widelands: /home/kaputtnik/widelands-repo/trunk/src/wui/interactive_base.cc:449: void InteractiveBase::move_view_to(Widelands::Coords): Assertion `c.x < egbase().map().get_width ()' failed.

Tags: crash editor

Related branches

Revision history for this message
GunChleoc (gunchleoc) wrote :

Do you remember which settings you used with the map generator when the crash happened?

Revision history for this message
kaputtnik (franku) wrote :

Just tested with trunk:

Create a random map, not adjusting any setting
All looks fine
Open player window
Click on blue player, normally the view jumps to the player position, now crash:

widelands: /home/kaputtnik/Quellcode/widelands-repo/trunk/src/wui/interactive_base.cc:444: void InteractiveBase::move_view_to(Widelands::Coords): Assertion `c.x < egbase().map().get_width ()' failed.
Abgebrochen (Speicherabzug geschrieben)

I created then another random map and tried to find the player positions by scrolling around... i couldn't find one.

Then i created a bigger map (160x160) to give the logic more space for player positions, but the result is the same: crash when trying to find the player position by clicking on the button in player window.

Saving such a map and investigating file "player_position" in the map folder shows bad values:

> [global]
> packet_version="2"
> player_1="17664 14283"
> player_2="17664 14283"

Both positions are equal and the values are much too high for a 64x64 map.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I still can't reproduce this, but I had an idea on how to fix it - could you please test the attached branch?

Revision history for this message
GunChleoc (gunchleoc) wrote :

I mean I can't reproduce the crash, the positions in the ocean etc. I do get.

kaputtnik (franku)
Changed in widelands:
status: New → Confirmed
Revision history for this message
kaputtnik (franku) wrote :

I tested your branch and get no immediate crash. Here is what i did:

Create random map without modifying settings, console output:
> WARNING: Player 1 has no starting position - illegal coordinates (-26920, -22738).
> WARNING: Player 2 has no starting position - illegal coordinates (-1, -1).

Creating another random map without modifying settings, console output:
> WARNING: Player 1 has no starting position - illegal coordinates (-26920, -22738).
> WARNING: Player 2 has no starting position - illegal coordinates (-1, -1).

Creating another random map without modifying settings, console output:
> WARNING: Player 1 has no starting position - illegal coordinates (-26920, -22738).
> WARNING: Player 2 has no starting position - illegal coordinates (-1, -1).

Creating another random map without modifying settings...
> WARNING: Player 1 has no starting position - illegal coordinates (-26920, -22738).
> WARNING: Player 2 has no starting position - illegal coordinates (-1, -1).

In the previous made random map i placed player positions by hand. Then creating another random map without modifying settings the editor crashes:

> widelands: /home/kaputtnik/Quellcode/widelands-repo/bug-1535065/src/logic/map.h:206: Widelands::Coords
 Widelands::Map::get_starting_pos(Widelands::PlayerNumber) const: Assertion `1 <= p && p <= get_nrplayers()' failed.
> Abgebrochen (Speicherabzug geschrieben)

I can reproduce the last crash as follows:

1. Create a random map
2. Place player positions by hand
3. Create another random map
4. Crash

Of course this is a uncommon usecase, but the editor should not crash through actions (placing players by hand) in a previous map...

As you can see the first three random maps contain always invalid player positions.

Saving a random map with placed player position by hand seems to be ok, the file player_position contains valid values and i could start a normal game with it.

Thanks for investigating this :-)

Revision history for this message
kaputtnik (franku) wrote :

Maybe we should schedule this bug for build 20? I believe random maps are not used very often so this feature could maybe deactivated for build19?

Revision history for this message
GunChleoc (gunchleoc) wrote :

I think we should just fix the crash, then take care of improving the starting positions later.

I did not think of people manipulating the starting positions by hand, I can add checks for that as well.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I just tested, those checks are already there, and the user gets a message box. So, this is safe now.

Revision history for this message
GunChleoc (gunchleoc) wrote : Re: Editor crashes with random map regarding player positions + starting positions that are not viable

The crash has been fixed, we still need to look into the starting positions that aren't viable.

summary: - Editor crashes with random map regarding player positions
+ Editor crashes with random map regarding player positions + starting
+ positions that are not viable
Changed in widelands:
milestone: none → build19-rc1
GunChleoc (gunchleoc)
Changed in widelands:
status: Confirmed → In Progress
assignee: nobody → GunChleoc (gunchleoc)
Revision history for this message
kaputtnik (franku) wrote :

Just found a similar bug: bug 1214659 (Random map: improve placement of initial HQs)

GunChleoc (gunchleoc)
Changed in widelands:
status: In Progress → Fix Committed
assignee: GunChleoc (gunchleoc) → nobody
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Found 2 crashes, one in Assertion failed: (1 <= p && p <= get_nrplayers()), function get_starting_pos, file /Users/klaus/develop/widelands-repo/rename_editor_files/src/logic/map.h, line 205.

The other one after repeated tries, got no assertion there :-(
Looks like repeatedly calling this may provoke this.

This woul be a goof candidate for some automated test, what do you think?
OTOH that function ist not really _vital_ for the game, so we could just log
the map-id so wet may find this in the long term?

Revision history for this message
GunChleoc (gunchleoc) wrote :

If you have a map ID, that would be really helpful :)

Changed in widelands:
status: Fix Committed → Confirmed
Revision history for this message
kaputtnik (franku) wrote :

The linked branch should log the mapID to stdout. After some tests i got a crash:

Create Random map with ID: wvsu-u2sy-hzsy-f4p7-sysk-dn74
WARNING: Player 1 has no starting position - illegal coordinates (-13256, 3314).
WARNING: Could not find a suitable place for player 2
widelands: /home/kaputtnik/Quellcode/widelands-repo/log_map_id/src/logic/map.h:205: Widelands::Coords Widelands::Map::get_starting_pos(Widelands::PlayerNumber) const: Assertion `1 <= p && p <= get_nrplayers()' failed.

I found also that changing the "Island mode" does not change the Map-ID in the UI.

Revision history for this message
kaputtnik (franku) wrote :

Seems there is more broken, because the map id couldn't be validated and the BUtton to create a map gets always disabled.

The Button is still disabled even when deleting the last character of the map id and afterwards put the same character in as before. Investigating this it seems that no worldname could be retrieved by the map ID: The function set_from_id_string() returns always false in line

http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/src/editor/map_generator.cc#L1048

Having a map ID is currently useless :-(

Revision history for this message
GunChleoc (gunchleoc) wrote :

#11 was probably https://bugs.launchpad.net/widelands/+bug/1573968

I am creating a new branch for the island mode and more log output.

Revision history for this message
kaputtnik (franku) wrote :

The player positions are always the same. I have created several random maps and the output is always:

> WARNING: Player 1 ... - illegal coordinates (-18168, 10612).
> WARNING: Player 2 ... - illegal coordinates (-1, -1).

And now the funny thing: Restarting widelands and creating random maps again the player positions are different:

> WARNING: Player 1 ... - illegal coordinates (-7128, -24358).
> WARNING: Player 2 ... - illegal coordinates (-1, -1).

But every random map in this session have the same values for player positions again.

The changing of values happens only, if you close widelands and restart it. Closing the editor is not enough. I guess it's because of random number generating?

A complete output:

============== Generating Map ==============
ID: han4-cfuk-1dyn-9u88-3ne8-3axu
Random number: 2419464316
Dimensions: 64 x 64
Players: 2
World: blackland
Resources: high
Land: 0.60% Water: 0.20% Wasteland: 0.00%
Using Island Mode

WARNING: Player 1 has no starting position - illegal coordinates (-7128, -24358).
WARNING: Player 2 has no starting position - illegal coordinates (-1, -1).

----------------

We have also different spelling of "Wasteland", which is "blackland" in the terminal output (see example output above). "Wasteland" is also used in the UI for different things:
1. For choosing "Climate"
2. For adjusting percent of unbuildable terrains (i believe it has this meaning here, where you could adjust percent of "Water" and "Land")

Revision history for this message
GunChleoc (gunchleoc) wrote :

> I guess it's because of random number generating?

I think so.

I tried getting the illegal starting positions with the values from your log, and I don't. I do get them sometimes though, but only the warning, and no crash. I haven't tried saveloading such a map though.

Revision history for this message
kaputtnik (franku) wrote :

Just to be clear: A crash is IMHO be prevented by you fix. At least i couldn't trigger any crash.

I think what is remaining are the not viable player positions.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Excellent!

Let's close this bug then and open a new one for the not viable starting positions - that's a very hard problem to fix though.

Changed in widelands:
status: Confirmed → Fix Committed
tags: added: editor
summary: - Editor crashes with random map regarding player positions + starting
- positions that are not viable
+ Editor crashes with random map regarding player positions
tags: added: crash
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.