Have anyone experienced this bug? Could it be appening because of Melindil's Special maps encounter fix? Nothing is certain, but from experience, I can tell you the game engine sometimes (quite often actually) get totally lost in its Special map encounters locations, sometimes even show me like 5 special maps encounter around the same line of travel, even if none have been place in that worldmap area! It also sometimes seems to forget the rightfull place of some Special encounter maps I deliberately placed in a square or another, or replace them with some other special map. The behaviour seem to happen at random, but when it happends, the engine seem completely lost within itself.
It is pretty stupid as sometimes, a "sea shore" Special map can appear in the middle of the desert. DAH!!....
If anyone could isolate this behaviour and find a way to solve it, that would be AMAZING..
Hugo
I'm not sure I can explain the first part (special encounters happening where none were listed), but I can explain the second (wrong encounters appearing).
The game keeps track of special encounters in an array (or, more accurately, a C++ vector) in the World object. At the start of a campaign, all special encounters are listed there, and locations on the map are indexed based on the position in the array. So, the first encounter in the array is numbered 1 (or 0, can't remember), and is marked on the world map with that corresponding ID.
However, once a special encounter is triggered, that encounter is actually removed from the array/vector. When this happens, all others with a higher index / ID are shifted down by 1. But the IDs assigned on the world map don't change, so now each map location is pointing to a different, wrong encounter. And whenever the ID in a map location is greater than the maximum index left in the array, the last entry in the array is used.
My fix should only take effect once the array becomes empty, bypassing code that dereferences the first entry in the array (as this causes a crash with an empty array). To confirm, you might check if the odd every-square-has-an-encounter issue still occurs with this patch disabled. If it does, then it's unrelated to the fix.
Fixing this will be non-trivial, as I haven't decoded anything in the campaign map structure, and so I can't yet go in and shift all the encounter location IDs down by one when an encounter triggers. Best-case workaround would be to have the earliest anticipated encounters for the player to hit at the end of the encounter list. This way, fewer encounters will be shifted when the player hits one.