also, Goblin Fort level generation often fails. it struggles to put living quarters, and sometimes even forge room. for now i workarouned it by increasing level sizes a little — the crashes are still there, but they are less frequent. i also added `FailureIsNotFailure` flag to room definitions (creative name, i know), which indicates that failing to place this room should not lead to ABORT. this flag leaks memory, of course, and is prone to crashes itself, but meh… (it mostly works for rooms without monsters, and with little objects… and it works only sometimes.)
i know what exactly IVAN struggles to place because k8ivan records source file and line for all scripts, and prints which room script failed. the better solution would be something akin to worldmap generation: abandon current efforts, and start over, but i don't know how to properly implement that. i can throw exception instead of aborting, but at this time the level is in "half-backed" state, and i have absolutely no idea how to clean up the things.
i mean, ok, we can leave half-generated map alone and accept memory leaks (better than sudden crashes), yet at this stage we already have some entities created and registered in the game, without a way to properly unwind what we've done. at least i don't know the way.
saving and reloading the game (as an easy rewinding solution) is problematic too: at the time level generator is called, we are deep inside command handler, and have various pointers to objects lying around. they all will be invalidated on reload, leading to memory corruption and crashes.
if i'll ever find a way to properly unwind everything, this will not only make the game more stable, but will allow to better dungeon scripts testing. if we could rewind (or stop cleanly with half-generated level), we could show what the game already have (i.e. put the player there). so you'll be able to see how cramped the level is, what was generated so far, and so on. i believe that this will help with dungeon tweaking a lot.