-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Allow explosions outside of the reality bubble #75567
Conversation
So if you set up an explosion at the edge and another explosion at the explosion's edge etc. What happens? Do all the explosions get triggered? In what order? Or all at once? Can the user run out of memory with a sufficiently small amount of such explosions (255 maybe) and trigger a crash? Maybe it's not a problem for vanilla, but if I were to make a mod where the world is bombed everywhere, would it work or would it crash? |
A very good question I hadn't considered. Testing shows it doesn't work properly, and thus rework is required. I tested to place two map extra craters in neighboring tiles and approached them so the second one was beyond the first one (as opposed to side by side), and the one further away wasn't triggered. Debugging shows that there was a single entry in the _explosions vector when process_explosions is called, but two when the processing loop is exited after a single pass. _explosions.clear() is then called, which erases both entries. I suspect something similar might happen if they were side by side. Ideally, only the explosion(s) encountered by the reality bubble should be processed and removed, while those on submaps loaded by process_explosions should not. Edit: This was addressed by moving the recursion block from the explosion handling itself to block the actualization of recursive load operations. The corresponding part of the solution description text has been changed to reflect this. As to the question about the order in which explosions are triggered, it should be exactly the same as before, which seems to be whatever order submaps are loaded, and, within each submap, whatever order actualization happen to process the triggers in. This should also mean that an explosion destroying the item triggering a later explosion doesn't matter, because all explosion triggers are processed first, and all explosions after that. The exception would be when a creature is implied in the explosion, in which case an earlier explosion may blow up a creature, and the explosion handling would fail to find it, or the creature may have been moved to a different location. I haven't checked what the code does for those cases, but there is some kind of handling for the absence of the creature. |
Conflicts sorry. |
No worries. I knew this one was coming. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Nice one |
I'm trying to remember... As you say, you "plan" explosions with one of the And thanks for bringing it to my attention. |
This is weird... I see three weird effects:
I think I've found the cause of the issues, but there's need for further investigation to figure out how to solve it. Presumably this means there is something missing in the explosion map loading, as critters should be loaded and unloaded with the map. Edit: PR generated. |
Summary
None
Purpose of change
Describe the solution
Check whether the radius of the explosion would fall outside of the reality bubble. If not, it's triggered on the reality bubble map. If any part of the explosion radius would fall outside of the reality bubble a new map (i.e. full 11*11 submap one) is generated centered on the explosion and the explosion processing is done on that map. Note that this causes further OMTs to have their contents generated as a result on falling inside the new map, and so potentially be generated a little earlier than they should have been otherwise.
Note that the modified code allows for usage with a target location outside of the reality bubble, but the current code does not call it with any such locations.
The code required some juggling to handle creatures, since the related code only deals with the reality bubble's coordinates.
Loading of another map on the explosion location recursively would trigger actualization of all submaps within that area, and and actualization of the target submap itself would recursively trigger explosion processing again. In addition to that, actualization would also trigger pending explosions of any submaps loaded, which would, again, lead to recursion. Blocking recursive explosion handling doesn't work, because actualization doesn't only trigger the explosion, but also removes the trigger, so while it would work for the primary explosion itself, it would remove any follow on explosions, so those would never be triggered. Thus, actualization was blocked for the map loaded by the explosion handling.
Describe alternatives you've considered
Continue to encounter half craters.
Testing
Bomb crater with original code.
![Screenshot (622)](https://private-user-images.githubusercontent.com/22739822/356819504-a84f1e25-eff7-433c-92d5-00358ae2a81c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMDEzMzQsIm5iZiI6MTczOTMwMTAzNCwicGF0aCI6Ii8yMjczOTgyMi8zNTY4MTk1MDQtYTg0ZjFlMjUtZWZmNy00MzNjLTkyZDUtMDAzNThhZTJhODFjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDE5MTAzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBjN2I3MmM0ZDc1YTU3ODI0ZTA3NDc3NzYzZDA1NWJhNDUwYzBkZjBjNWVlZWIxZDVkODlkYjU0NmQ2ZWZjMTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.o44Lo5qXwwO0ra8HccMhEBU2amYKqMKgAL2-UoQGbL4)
![Screenshot (624)](https://private-user-images.githubusercontent.com/22739822/356819509-f35215bb-cb27-4b86-ae87-7036251a82b0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMDEzMzQsIm5iZiI6MTczOTMwMTAzNCwicGF0aCI6Ii8yMjczOTgyMi8zNTY4MTk1MDktZjM1MjE1YmItY2IyNy00Yjg2LWFlODctNzAzNjI1MWE4MmIwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDE5MTAzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVlYjk1ZDM3YTViMDZiYTcyOTY2Y2I5YzliODUyNTk5ZmZlZmViOTE1YTRiZjNmOWM4ZjdmMDM4NjM2MmZiNTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.CcmwIyNsgqv12yR9F0PUj3CVaQ3TiMbTwmaXpkwZ5nQ)
Bomb crater with modified code.
Additional context
I see two expanded usages of the functionality: