Refactorio / RedMew

The RedMew scenario code for Factorio.
https://redmew.com
GNU General Public License v3.0
177 stars 80 forks source link

Fixes for incorrect chest behaviors in DO:Expanse #1410

Closed RedRafe closed 5 months ago

RedRafe commented 6 months ago

Scenario changes:

Then mainly bugfixes for incorrect chest behaviors & chunk position computation that lead into map locks during 1st run

RedRafe commented 6 months ago

On previous version, these chests spawning too close to chunk's intersection could be troublesome as they were too close to empty chunks even when invalid. So it's now not possible to spawn chests too close to the intersections, as per defined radius (RADIUS = 3) used to search for nearby empty chunks

Screenshot from 2024-04-17 13-36-46

RedRafe commented 6 months ago

Yes, looking at how your system is implemented, I think I could change it to that since I don't need the table to stay ordered and I'm actively traversing it rather than reacting to events. But I would probably need to get rid of the chest removing at on_chunk_unlocked since I couldn't go back to the data from the entity.unit_number (well, I could simply iterate the list and compare IDs but at that point, I'd just wait for on_tick to catch up and do the cleaning itself)

grilledham commented 6 months ago

But I would probably need to get rid of the chest removing at on_chunk_unlocked ...

Why would you need to remove chests when a chunk is unloaded? Unless you can have multiple chests that unlock the same chunk?

My naïve thinking of how this would work is, you would look to add chests when a new chunk is unlocked and remove completed chests on_tick and generate the chunk. (I haven't properly read through the code yet, so I might be missing something obvious.)

RedRafe commented 6 months ago

Unless you can have multiple chests that unlock the same chunk?

Yes, when 2+ active chunks form an angle, the hidden chunk in between them can be unlocked by any of the adjacent chunks. So when a new chunk is unlocked, I search the nearby chunks for those "obvious invalid chests" to remove them promptly instead of waiting for the on_tick cleaner to loop them

RedRafe commented 5 months ago

@grilledham can I get an update on this thread? Since this map seems to be the next one coming up on S13, would be better to integrate the 1st round of fixes & eventually leave this open for further improvements/code refactors thanks to the 2nd round of play testing Let me know 😄

grilledham commented 5 months ago

Ok, let's merge it now.