Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash upon initial mapgen (after staring a new game, while generating the world for the first time). #36677

Merged
merged 1 commit into from
Jan 4, 2020

Conversation

BevapDin
Copy link
Contributor

@BevapDin BevapDin commented Jan 3, 2020

SUMMARY: None

When this triggers some specific map extras (e.g. max_corpse), game::is_empty is called, which in turn checks the main game map. However, that main game map is not loaded yet (we're in the middle of generating it).

This changes access to game::is_empty to access the local map instead. game::is_empty checks three things:

  • There is no critter there (we can't really replicate this check in the map instance).
  • The tile is passable (I replicated that check).
  • The tile is "LIQUID" (ignored that check).

Also use random_point instead of manual logic.

Access the local map instance instead.

Also use `random_point` instead of manual logic.
@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Map / Mapgen Overmap, Mapgen, Map extras, Map display labels Jan 3, 2020
@kevingranade kevingranade merged commit 5a05025 into CleverRaven:master Jan 4, 2020
@ZhilkinSerg
Copy link
Contributor

Must be causing #36690.

return g->is_empty( p ) && tmp.can_move_to( p );
// Checking for creatures via g is only meaningful if this is the main game map.
// If it's some local map instance, the coordinates will most likely not even match.
return ( !g || &g->m != this || g->critter_at( p ) ) && tmp.can_move_to( p );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critter check should be negated, so monsters could spawn to empty places. Now they are trying to spawn to non-empty tiles.

Also I think we could move !g and map check on top of the function to bail out early.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants