It seems that moving the call to oldOnSync() up to the top of the hooking OnSync() function in One Click Wonder fixes this issue.
Before the fix:
- Code: Select all
local oldOnSync = OnSync
function OnSync()
local CM = import('/lua/ui/game/commandmode.lua')
for id, v in Sync.ReleaseIds do
-- SPEW('BOOM ' .. id)
local p = false
for x, row in CM.GetAliveStructs() or {} do
for y, col in row or {} do
if col[id] then
-- f*** yeah; hash functions!
local h = GetPositionHash(math.floor(col[id].pos[1]), math.floor(col[id].pos[3]))
CM.structs.dead[h] = col[id].bp
col[id] = nil
p = true
break
end
end
if p then break end
end
end
oldOnSync()
end
After the fix:
- Code: Select all
local oldOnSync = OnSync
function OnSync()
oldOnSync()
local CM = import('/lua/ui/game/commandmode.lua')
for id, v in Sync.ReleaseIds do
-- SPEW('BOOM ' .. id)
local p = false
for x, row in CM.GetAliveStructs() or {} do
for y, col in row or {} do
if col[id] then
-- f*** yeah; hash functions!
local h = GetPositionHash(math.floor(col[id].pos[1]), math.floor(col[id].pos[3]))
CM.structs.dead[h] = col[id].bp
col[id] = nil
p = true
break
end
end
if p then break end
end
end
end
The problem is that the first call to import('/lua/ui/game/commandmode.lua') crashes out with an error.
Here is some text copied from a log, that shows this:
- Code: Select all
INFO: One Click Wonder OnSync() entry count = 1
INFO: Hooked /lua/ui/game/commandmode.lua with /mods/ui-party/hook/lua/ui/game/commandmode.lua
INFO: Hooked /lua/ui/game/commandmode.lua with /mods/reminder/hook/lua/ui/game/commandmode.lua
INFO: Hooked /lua/ui/game/commandmode.lua with /mods/notify/hook/lua/ui/game/commandmode.lua
INFO: Hooked /lua/ui/game/commandmode.lua with /mods/logstartcommandmode/hook/lua/ui/game/commandmode.lua
INFO: Hooked /lua/ui/game/commandmode.lua with /mods/oneclickwonder/hook/lua/ui/game/commandmode.lua
INFO: Hooked /lua/ui/game/construction.lua with /mods/ui-party/hook/lua/ui/game/construction.lua
INFO: Hooked /lua/ui/game/construction.lua with /mods/notify/hook/lua/ui/game/construction.lua
INFO: Hooked /lua/ui/game/construction.lua with /mods/fixbuildmodetemplatesbug/hook/lua/ui/game/construction.lua
INFO: Hooked /lua/ui/game/buildmode.lua with /mods/replacebuildmode/hook/lua/ui/game/buildmode.lua
INFO: Hooked /lua/ui/game/buildmode.lua with /mods/makebuildmodemorevisible/hook/lua/ui/game/buildmode.lua
INFO: Hooked /lua/ui/game/tabs.lua with /mods/ui-party/hook/lua/ui/game/tabs.lua
INFO: Hooked /lua/ui/game/selection.lua with /schook/lua/ui/game/selection.lua
WARNING: ...orever\gamedata\lua.nx2\lua\ui\game\construction.lua(83): Attempt to set attribute 'HandleEvent' on nil
WARNING: stack traceback:
WARNING: [C]: in function `error'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\config.lua(12): in function <...alliance\gamedata\mohodata.scd\lua\system\config.lua:11>
WARNING: ...orever\gamedata\lua.nx2\lua\ui\game\construction.lua(83): in main chunk
WARNING: [C]: in function `doscript'
WARNING: [C]: in function `pcall'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\import.lua(48): in function `import'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\import.lua(37): in function `import'
WARNING: ...forever\gamedata\lua.nx2\lua\ui\game\commandmode.lua(10): in main chunk
WARNING: [C]: in function `doscript'
WARNING: [C]: in function `pcall'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\import.lua(48): in function `import'
WARNING: ...gramdata\faforever\gamedata\lua.nx2\lua\usersync.lua(441): in function `OnSync'
WARNING: [string "OnSync()"](1): in main chunk
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\import.lua(37): Error importing '/lua/ui/game/construction.lua'
WARNING: stack traceback:
WARNING: [C]: in function `error'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\import.lua(52): in function `import'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\import.lua(37): in function `import'
WARNING: ...forever\gamedata\lua.nx2\lua\ui\game\commandmode.lua(10): in main chunk
WARNING: [C]: in function `doscript'
WARNING: [C]: in function `pcall'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\import.lua(48): in function `import'
WARNING: ...gramdata\faforever\gamedata\lua.nx2\lua\usersync.lua(441): in function `OnSync'
WARNING: [string "OnSync()"](1): in main chunk
WARNING: Error running lua command: ...gramdata\faforever\gamedata\lua.nx2\lua\usersync.lua(441): Error importing '/lua/ui/game/commandmode.lua'
stack traceback:
[C]: in function `error'
...alliance\gamedata\mohodata.scd\lua\system\import.lua(52): in function `import'
...gramdata\faforever\gamedata\lua.nx2\lua\usersync.lua(441): in function `OnSync'
[string "OnSync()"](1): in main chunk
The "One Click Wonder OnSync() entry count" bit is some logging instrumentation I added to the code.
There was also some logging just after the import('/lua/ui/game/commandmode.lua') call, which was never reached.
So seems like it is probably not the fault of the author of OneClickWonder.
With the call to oldOnSync() at the end, other stuff depending on OnSync() misses the first call, and don't set things up properly.
But, with the call to oldOnSync() at the start, the other stuff depending on OnSync() gets run and everything limps on from there.
Note sure what is causing the actual error shown in the log..
(edit: fixed missing import in the before/after code snippets)