This is stumping me a little bit and I'm wondering if I'm running into memory/heap corruption or something from SwapMaps. I've got a list of "hero" objects and when adding the second hero, the first one in the list is becoming null. I've tracked it down to the following line.
g_listOfActiveZLevels.Add(M.z1);
That line has nothing to do with the hero list but when I remove it, the first hero doesn't get nulled.
This code.
...
var/mob/Hero/h = new();
m_listOfHeroes.Add(h)
...
calls this code.
mob/Hero/New()
...
m_Map = Proc_CreateNewMapFromTemplate("CustomMap")
...
which calls this code.
proc/Proc_CreateNewMapFromTemplate(templateName)
var/swapmap/M = SwapMaps_CreateFromTemplate(templateName)
M.SetID("Map_[g_iMapCounter++]")
g_listOfActiveZLevels.Add(M.z1);
...
Which in turn is nulling out the first hero in m_listOfHeroes.
Ah, I just found an map_CustomMap.txt file in my maps directory with the following:
//Orphan savefile buffer '' found on Mon Mar 30 17:09:24 2015
//End of exported data.
Not sure how important that find is.
Anyway, stuck at this point.
Realizing the slowness is due to initializing static maps for the purposes of creating templates which is fine. I only need to call it once if it doesn't exist.
Repro Steps.
1. Start
2. Click on "Buy Hero" button.
3. Click on "Fight" arrow and wait for hero to enter dungeon.
4. When the hero gets into the dungeon, Click "Buy Hero" again.
Expecting:
Actual:
Also, if I remove this call from world/New() the issue goes away. It touches the same list.
list/g_listOfActiveZLevels = new();