Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions EEex/copy/EEex_scripts/EEex_Assembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1287,25 +1287,32 @@ end
-----------------------

EEex_UserDataAuxiliary = {}
EEex_UserDataAuxiliaryPersistent = {}

function EEex_DeleteUserDataAuxiliary(ud)
if type(ud) ~= "userdata" then
EEex_Error("ud is not a userdata object ("..type(ud)..")!")
end
EEex_UserDataAuxiliary[EEex_UDToLightUD(ud)] = nil
EEex_UDAux_Private_DeleteByLightUD(EEex_UDToLightUD(ud))
end
EEex_DeleteUDAux = EEex_DeleteUserDataAuxiliary

function EEex_GetUserDataAuxiliary(ud)
function EEex_GetUserDataAuxiliary(ud, persistent)
if type(ud) ~= "userdata" then
EEex_Error("ud is not a userdata object ("..type(ud)..")!")
end
if persistent ~= nil and type(persistent) ~= "boolean" then
EEex_Error("persistent must be nil or a boolean ("..type(persistent)..")!")
end
local lud = EEex_UDToLightUD(ud)
local auxiliary = EEex_UserDataAuxiliary[lud]
if not auxiliary then
auxiliary = {}
EEex_UserDataAuxiliary[lud] = auxiliary
end
if persistent then
EEex_UserDataAuxiliaryPersistent[lud] = true
end
return auxiliary
end
EEex_GetUDAux = EEex_GetUserDataAuxiliary
Expand Down
3 changes: 3 additions & 0 deletions EEex/copy/EEex_scripts/EEex_Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ EEex_Main_Private_StartupFiles = {
"EEex_Resource", --
"EEex_Script", --
"EEex_Script_Patch", --
"EEex_Marshal_Codec", --
"EEex_UDAux", --
"EEex_Sprite", --
"EEex_Sprite_Patch", --
"EEex_Stats", --
Expand All @@ -54,6 +56,7 @@ EEex_Main_Private_StartupFiles = {
"EEex_Fix", --
"EEex_Fix_Patch", --
"EEex_Marshal", --
"EEex_Marshal_Patch", --
"EEex_Module", --
"EEex_OptionsLate", -- Here so it can register listeners provided by other EEex files
"EEex_Profiler", --
Expand Down
75 changes: 75 additions & 0 deletions EEex/copy/EEex_scripts/EEex_Marshal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,85 @@ EEex_Sprite_AddMarshalHandlers("EEex",
end
)

EEex_Sprite_AddMarshalHandlers("EEex_UDAux",
function(sprite)

if EEex.IsMarshallingCopy() then
return nil
end

local toMarshal = {}

local exportEffectList = function(list, path)
local exported = {}
local i = 1
EEex_Utility_IterateCPtrList(list, function(effect)
exported[i] = EEex_UDAux_Private_Export(effect, path.."["..i.."]")
i = i + 1
end)
return next(exported) and exported or nil
end

local timedEffects = exportEffectList(sprite.m_timedEffectList, "CGameSprite.m_timedEffectList")
if timedEffects then
toMarshal["timedEffects"] = timedEffects
end

local equippedEffects = exportEffectList(sprite.m_equipedEffectList, "CGameSprite.m_equipedEffectList")
if equippedEffects then
toMarshal["equippedEffects"] = equippedEffects
end

local items = {}
for i = 0, 38 do
local item = sprite.m_equipment.m_items:get(i)
if item then
items[i] = EEex_UDAux_Private_Export(item, "CGameSprite.m_equipment.m_items["..i.."]")
end
end
if next(items) then
toMarshal["items"] = items
end

return next(toMarshal) and toMarshal or nil
end,
function(sprite, read)

local importEffectList = function(list, data)
if not data then
return
end
local i = 1
EEex_Utility_IterateCPtrList(list, function(effect)
local auxiliary = data[i]
if auxiliary then
EEex_UDAux_Private_Import(effect, auxiliary)
end
i = i + 1
end)
end

importEffectList(sprite.m_timedEffectList, read["timedEffects"])
importEffectList(sprite.m_equipedEffectList, read["equippedEffects"])

local items = read["items"]
if items then
-- The extra creature marshal block is read while the sprite is still being rebuilt.
-- Equipment item pointers can be unavailable at this point, so keep slot data on the
-- sprite and retry from normal post-load/update hooks until each item exists.
EEex_GetUDAux(sprite)["EEex_UDAux_PendingItemAux"] = items
EEex_UDAux_Private_ApplyPendingItemAux(sprite)
end
end
)

function EEex_Marshal_Private_OnSummonerLoaded(sprite, loadedSprite)
sprite.m_lSummonedBy:Set(loadedSprite:virtual_GetAIType())
end

EEex_Sprite_AddLoadedListener(EEex_UDAux_Private_ApplyPendingItemAux)
EEex_Opcode_AddListsResolvedListener(EEex_UDAux_Private_ApplyPendingItemAux)

EEex_Sprite_AddLoadedListener(function(sprite)
local summonerUUID = EEex_GetUDAux(sprite)["EEex_SummonerUUID"]
if summonerUUID then
Expand Down
Loading