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

Fixed crash when generating map #34148

Merged

Conversation

ipcyborg
Copy link
Contributor

@ipcyborg ipcyborg commented Sep 21, 2019

Summary

SUMMARY: Bugfixes "Crash when generating map"

Purpose of change

Fixes #33640, fixes #34028

Describe the solution

Originally the submap was inserted always at 0 z-level { gridx, gridy }, but used, saved and deleted on specific z-level i, j, p.z.
Fixed new submap inserting on correct z-level. Added some extra checks.

Describe alternatives you've considered

  1. Initialize full grid in map constructor, not in generate, when it is resized. Too much of a change, probably incorrect.
  2. Delay the initialization of grid until it is required (when getsubmap is used and there is nullptr there). Not sure if this is efficient.

Additional context

Thanks for a great mod Extra_Bandits.zip provided in #33640 - it was almost 100% reproducible.
Tested after the fix for about 10 new starts, no crash. Still more testing is required.

src/mapgen.cpp Outdated Show resolved Hide resolved
@ipcyborg ipcyborg changed the title Fixed crash when generating map [WIP] Fixed crash when generating map Sep 21, 2019
@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` Character / World Generation Issues and enhancements concerning stages of creating a character or a world Map / Mapgen Overmap, Mapgen, Map extras, Map display labels Sep 21, 2019
Removed grid initialization for all z-levels.
Ensured that new submap on generation will not overwrite existing one.
Setsubmap to null in grid after deletion.
@ipcyborg ipcyborg requested a review from BevapDin September 23, 2019 12:40
@ipcyborg ipcyborg changed the title [WIP] Fixed crash when generating map Fixed crash when generating map Sep 26, 2019
@ZhilkinSerg ZhilkinSerg merged commit 28028a5 into CleverRaven:master Sep 27, 2019
@ipcyborg ipcyborg deleted the fix-33640-crash-on-map-generate branch September 27, 2019 11:51
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` Character / World Generation Issues and enhancements concerning stages of creating a character or a world Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
3 participants