"One Click Wonder" denies Ctrl-Shift for reclaim labels

Everything about mods can be found here.

Moderator: Morax

"One Click Wonder" denies Ctrl-Shift for reclaim labels

Postby PsychoBoB » 21 Jun 2017, 22:12

Hi modders,

when the Mod "One Click Wonder (T2/T3 Mex Support) V5" is activated then Ctrl-Shift doesn't show the reclaim labels any more.
I deactivated all other mods (with and without "Common Mod Tools") and it's only when i activate One Click Wonder.
Then i tried to assign the reclaim label function to another hotkey but with no effect.

Can anybody take a look at this? Or just confirm my problem?

Thx in advance!

BoB
If you fear the dark you have never seen what light can cause!
PsychoBoB
Priest
 
Posts: 396
Joined: 12 Sep 2011, 09:25
Has liked: 152 times
Been liked: 29 times
FAF User Name: McNeil

Re: "One Click Wonder" denies Ctrl-Shift for reclaim labels

Postby R_Charger » 23 Jun 2017, 20:16

Problem confirmed!

Edit: had a look at the lua and it looks like a problem with UserSync.lua as the hooking file seems to be interfering with the updating of reclaim. I'm only just learning lua so it might take me some time to fix....others might be able to assist more quickly (or the mod author could fix it!).
R_Charger
Avatar-of-War
 
Posts: 141
Joined: 30 Jul 2016, 16:27
Has liked: 9 times
Been liked: 14 times
FAF User Name: Reckless_Charger

Re: "One Click Wonder" denies Ctrl-Shift for reclaim labels

Postby crispweed » 24 Jun 2017, 09:37

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)
Last edited by crispweed on 24 Jun 2017, 18:03, edited 1 time in total.
crispweed
Crusader
 
Posts: 33
Joined: 02 Jan 2017, 17:32
Has liked: 2 times
Been liked: 3 times
FAF User Name: crispweed

Re: "One Click Wonder" denies Ctrl-Shift for reclaim labels

Postby R_Charger » 24 Jun 2017, 16:45

But without the call to import('/lua/ui/game/commandmode.lua'
the Alt-click functionality for rebuilding structures doesn't work...
R_Charger
Avatar-of-War
 
Posts: 141
Joined: 30 Jul 2016, 16:27
Has liked: 9 times
Been liked: 14 times
FAF User Name: Reckless_Charger

Re: "One Click Wonder" denies Ctrl-Shift for reclaim labels

Postby crispweed » 24 Jun 2017, 18:09

R_Charger wrote:But without the call to import('/lua/ui/game/commandmode.lua'
the Alt-click functionality for rebuilding structures doesn't work...


Yeah, sorry, the import line shouldn't actually be removed.

(I accidentally removed that line when posting those before/after code snippets, when I removed some logging instrumentation, but I've edited the post now to put the line back in.)

All that you need to do, for the fix, is move the call to oldOnSync() from the end to the start of the hooking OnSync() function definition.

That fixes the issue with reclaim labels not being shown, for me, but I'm a bit concerned if there could be any other side effects of the logged error, and it might be a good idea to look into that further..
crispweed
Crusader
 
Posts: 33
Joined: 02 Jan 2017, 17:32
Has liked: 2 times
Been liked: 3 times
FAF User Name: crispweed

Re: "One Click Wonder" denies Ctrl-Shift for reclaim labels

Postby PsychoBoB » 25 Jun 2017, 11:36

Hi crispweed,

i tried your fix and it seems to work. Since i don't use the rebuild function of the mod it's ok for me now!

Thanks a lot for your help!
If you fear the dark you have never seen what light can cause!
PsychoBoB
Priest
 
Posts: 396
Joined: 12 Sep 2011, 09:25
Has liked: 152 times
Been liked: 29 times
FAF User Name: McNeil


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest