The "old"-function leads (sometimes) to a segfault within the For local handler:TRoomHandler = EachIn oldHandlers.Values()-loop.
The other function does not segfault.
Function OLDonSaveGameLoad:int( triggerEvent:TEventBase )
TLogger.Log("TRoomHandlerCollection", "Savegame loaded - reassigning handlers", LOG_DEBUG | LOG_SAVELOAD)
local oldHandlers:TMap = GetInstance().handlers.Copy()
'request each handler to re-assign (the new instance of the handler)
'ATTENTION: this allows to handle this individually for each
' handler. The alternative (storing a "handle:string"-
' property in each handler) would lead to problems
' as soon as some offices have varying handlers
' or a handler wants to take care of multiply rooms
GetInstance().handlers.Clear()
For local handler:TRoomHandler = EachIn oldHandlers.Values()
if handler
handler.RegisterHandler()
print TTypeID.ForObject(handler).name() + " registered"
endif
Next
print "reregistered"
'inform the (new) handlers
For local handler:TRoomHandler = EachIn GetInstance().handlers.Values()
handler.onSaveGameLoad( triggerEvent )
Next
End Function
'called _after_ a game (and its data) got loaded
Function onSaveGameLoad:int( triggerEvent:TEventBase )
TLogger.Log("TRoomHandlerCollection", "Savegame loaded - reassigning handlers", LOG_DEBUG | LOG_SAVELOAD)
local oldHandlers:TRoomHandler[]
For local o:object = EachIn GetInstance().handlers.Values()
if TRoomHandler(o) then oldHandlers :+ [TRoomHandler(o)]
Next
'request each handler to re-assign (the new instance of the handler)
'ATTENTION: this allows to handle this individually for each
' handler. The alternative (storing a "handle:string"-
' property in each handler) would lead to problems
' as soon as some offices have varying handlers
' or a handler wants to take care of multiply rooms
GetInstance().handlers.Clear()
For local handler:TRoomHandler = EachIn oldHandlers
if handler
'this modifies "GetInstance().handlers"
handler.RegisterHandler()
print TTypeID.ForObject(handler).name() + " registered"
endif
Next
print "reregistered"
'inform the (new) handlers
For local handler:TRoomHandler = EachIn GetInstance().handlers.Values()
handler.onSaveGameLoad( triggerEvent )
Next
End Function
The "old"-function leads (sometimes) to a segfault within the
For local handler:TRoomHandler = EachIn oldHandlers.Values()
-loop.The other function does not segfault.