Jump to content

Repeated removal and addition of a compoment with assigned mod component action exhausts net_smallbytearray


Muche
  • Fixed

Adding a component to an entity checks all assigned mod component actions and adds them to modactioncomponents field, which is later used to fill actionreplica.modactioncomponents (net_smallbytearray).
Removing a component from an entity does not remove said actions from modactioncomponents field.
Adding the same component to the entity again adds duplicate component reference to modactioncomponents.
Repeating the removal and addition increases the field's size without limit, which net_smallbytearray can't hold and issues error Net array has 32 elements; exceeds maximum size of 31.

Thanks to @DejaVuZXY for noticing it and cooperation during investigation.

 

Steps to reproduce:

Enable (server) mod with this modmain.lua:

AddComponentAction("SCENE", "inspectable", function(inst, doer, actions, right) end)
AddComponentAction("SCENE", "workable", function(inst, doer, actions, right) end)
AddComponentAction("SCENE", "lootdropper", function(inst, doer, actions, right) end)

Join the world. Enter the following into the debug console:

e=c_find('evergreen'); dumptable(e.modactioncomponents)
e:RemoveComponent('inspectable'); e:AddComponent('inspectable'); dumptable(e.modactioncomponents)
e:RemoveComponent('inspectable'); e:AddComponent('inspectable'); dumptable(e.modactioncomponents)
e:RemoveComponent('inspectable'); e:AddComponent('inspectable'); dumptable(e.modactioncomponents)
e:RemoveComponent('inspectable'); e:AddComponent('inspectable'); dumptable(e.modactioncomponents)

Which produces:

    K:     Test3     V    table: 5B2B8868    
        K:     1     V:     1    
        K:     2     V:     2    
        K:     3     V:     3    
        K:     4     V:     1    
    K:     Test3     V    table: 5B2B8868    
        K:     1     V:     1    
        K:     2     V:     2    
        K:     3     V:     3    
        K:     4     V:     1    
        K:     5     V:     1    
    K:     Test3     V    table: 5B2B8868    
        K:     1     V:     1    
        K:     2     V:     2    
        K:     3     V:     3    
        K:     4     V:     1    
        K:     5     V:     1    
        K:     6     V:     1    
    K:     Test3     V    table: 5B2B8868    
        K:     1     V:     1    
        K:     2     V:     2    
        K:     3     V:     3    
        K:     4     V:     1    
        K:     5     V:     1    
        K:     6     V:     1    
        K:     7     V:     1    
    K:     Test3     V    table: 5B2B8868    
        K:     1     V:     1    
        K:     2     V:     2    
        K:     3     V:     3    
        K:     4     V:     1    
        K:     5     V:     1    
        K:     6     V:     1    
        K:     7     V:     1    
        K:     8     V:     1    

 


Steps to Reproduce
Moved above, because this can't handle [code] tags [/code].
  • Like 2



User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.

Why I can't see comments? It says "2 comments, There are no comments to display".

Spoiler


7696244.png

 

 

And now it says only 1 comment after my post. Is that magic?

Spoiler

7692148.png

Try to check other topics in Bug Tracker. Seems that comments are disappearing...

Share this comment


Link to comment
Share on other sites

This looks like a patch candidate (indent whitespace changes omitted):

--- componentactions.lua
+++ componentactions.patch.lua
@@ -949,10 +949,9 @@ function EntityScript:UnregisterComponentActions(name)
                 if self.actionreplica ~= nil then
                     self.actionreplica.actioncomponents:set(self.actioncomponents)
                 end
-                return
             end
         end
-    else
+	end
     for modname,modtable in pairs(MOD_ACTION_COMPONENT_IDS) do
         id = modtable[name]
         if id ~= nil then
@@ -962,8 +961,6 @@ function EntityScript:UnregisterComponentActions(name)
                     if self.actionreplica ~= nil then
                         self.actionreplica.modactioncomponents[modname]:set(self.modactioncomponents[modname])
                     end
-                        return
-                    end
                 end
             end
         end

 

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...