Much like players can flag portions of ground as “NPCs shouldn’t pick up items here”, would it be possible for them to flag a contiguous set of overmap tiles they have cleared as “there is a fortification here”? It would cheapen the flood-fill approach by letting the algorithm discard all other overmap tiles.
Once the impassable vs passable bitmap is generated, an outside-in approach to this flood fill could mean not having to check any overmap tiles that are surrounded by fortification.
Construction and destruction of terrain would still cause re-checking of the fortification’s integrity, this could be alleviated by starting with re-evaluating that overmap tile, straght from the tile that just fell.
I don’t know if it’d be better to drop the bucket of paint on the tile and seeing where it goes, or running along the wall that just broke, trying to find the smallest room it belongs to, and then painting the room.
In either case, the flooding wouldn’t need to extend to adjacent map tiles unless the paint reaches it’s edge.
Since this is all happening using a bitmap+support data structure rather than the actual map, it doesn’t really matter if the entire fortress is loaded on memory or not.
Hmm, this could be accelerated by remembering what tiles were painted ‘outside’ by the previous run of the flood algorithm. Perhaps with a second bitmap, or perhaps by extending the number of colors to “inside, outside, impassable”, or even “inside, outside, inner_wall, outer_wall”.
I like the seocond one. No need to re-run flooding if what fell or what changed was an inner wall, or if a wall was added on a place that was already inside terrain.