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

Block monster and map extra from being generated repeatedly #74703

Merged
merged 1 commit into from
Jun 23, 2024

Conversation

PatrikLundell
Copy link
Contributor

@PatrikLundell PatrikLundell commented Jun 21, 2024

Summary

None

Purpose of change

Fix #74697, i.e. map extras and monsters spawning on already spawned terrain when revisited.
Fix #74715, i.e. monsters in tunnels spawning at the surface.

Describe the solution

  • Add check to only perform mapgen and monster spawn if the map is actually generated.
  • Change the check for spawning monster locations to restrict the valid set to the current Z level. When tinymaps were used this was done implicitly.

Describe alternatives you've considered

Introduce a version of the operation that gives you points within a range that only returns the points on a single Z level and use that one rather than generate points on all levels only to reject all hits on other levels. That should probably be done, but this change is faster and less complicated, so I'll leave this for a separate PR.

Testing

Loaded the bug report save and traveled around, looking out for new map extras spawning on previously visited terrain, without finding any new anomalies.
Then continued out into the unexplored territory to verify they do still spawn there when the terrain is generated.

Teleport on top of mine tunnels using the bug report save. Before the change miners were spawning in droves on the surface and only a few in the tunnels. Now they stay in the tunnels where they belong.

Additional context

I've been highly suspicious of the processing of this code because I did not see anything blocking its execution when terrains wasn't generated in the location where the code was moved from. Thus, the code was moved without introduction of any such guard. Apparently I must have missed something that did provide such protection.

@github-actions github-actions bot added Map / Mapgen Overmap, Mapgen, Map extras, Map display [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Jun 21, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jun 21, 2024
@Maleclypse
Copy link
Member

Maleclypse commented Jun 22, 2024

Will this change prevent the EOCs that allow random encounters like the traveling free merchant trader from firing since those events only load on already created maps?

edit: EOC_RandEnc_Roadstop_camper_add and other eocs in the encounters folder.

@PatrikLundell
Copy link
Contributor Author

I don't know, but I don't expect that to be the case.

The code not called again is the map extra code and the monster generation code. I would expect the EOC code to not be part of that, but rather being triggered by you actually loading the tile into the reality bubble, whether from memory or file.

A further reason for why this would be the case is that if this code DID generate those then they'd only trigger on tiles you haven't visited within the current game session (because generate shouldn't be called when all Z levels of the tile is generated already while "uniform" tiles are regenerated only if they aren't in memory, and I think this only happens when loading from file, and I don't think there is anywhere the tiles are discarded (apart from not saved on saving, as they're regenerated on load instead).

However, it's something that would be good to test (and I'd need help with that, as I think I've only encountered these things once or twice in total, so the spawn rate would have to be increased massively to see if they do trigger).

@PatrikLundell PatrikLundell marked this pull request as draft June 22, 2024 16:01
@PatrikLundell PatrikLundell marked this pull request as ready for review June 22, 2024 16:07
@Maleclypse
Copy link
Member

I don't know, but I don't expect that to be the case.

The code not called again is the map extra code and the monster generation code. I would expect the EOC code to not be part of that, but rather being triggered by you actually loading the tile into the reality bubble, whether from memory or file.

A further reason for why this would be the case is that if this code DID generate those then they'd only trigger on tiles you haven't visited within the current game session (because generate shouldn't be called when all Z levels of the tile is generated already while "uniform" tiles are regenerated only if they aren't in memory, and I think this only happens when loading from file, and I don't think there is anywhere the tiles are discarded (apart from not saved on saving, as they're regenerated on load instead).

However, it's something that would be good to test (and I'd need help with that, as I think I've only encountered these things once or twice in total, so the spawn rate would have to be increased massively to see if they do trigger).

Ok if I have time tonight I’ll test that and see what happens. Thank you!

@Maleclypse
Copy link
Member

Ok I don't think that impacted the eoc updates.

@Maleclypse Maleclypse merged commit 9d91f03 into CleverRaven:master Jun 23, 2024
43 of 47 checks passed
@PatrikLundell PatrikLundell deleted the mapgen branch June 23, 2024 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
2 participants