Stack Sizes multiplying on plugin reloadSolved

No sure the best way to proceed here. I've been having some oddities with my server's stack sizes, I'd set the stacks and after a wipe I'd find that they're larger than what they should be.

StackSizeController.json

{
  "RevertStackSizesToVanillaOnUnload": true,
  "AllowStackingItemsWithDurability": true,
  "PreventStackingDifferentSkins": false,
  "HidePrefixWithPluginNameInMessages": false,
  "DisableDupeFixAndLeaveWeaponMagsAlone": false,
  "GlobalStackMultiplier": 1.0,
  "CategoryStackMultipliers": {
    "Weapon": 10.0,
    "Construction": 10.0,
    "Items": 10.0,
    "Resources": 5.0,
    "Attire": 10.0,
    "Tool": 10.0,
    "Medical": 10.0,
    "Food": 10.0,
    "Ammunition": 10.0,
    "Traps": 10.0,
    "Misc": 10.0,
    "All": 10.0,
    "Common": 10.0,
    "Component": 10.0,
    "Search": 10.0,
    "Favourite": 10.0,
    "Electrical": 10.0,
    "Fun": 10.0
  },
  "IndividualItemStackMultipliers": {},
  "CategoryStackHardLimits": {
    "Weapon": 0,
    "Construction": 0,
    "Items": 0,
    "Resources": 0,
    "Attire": 0,
    "Tool": 0,
    "Medical": 0,
    "Food": 0,
    "Ammunition": 0,
    "Traps": 0,
    "Misc": 0,
    "All": 0,
    "Common": 0,
    "Component": 0,
    "Search": 0,
    "Favourite": 0,
    "Electrical": 0,
    "Fun": 0
  },
  "IndividualItemStackHardLimits": {},
  "VersionNumber": {
    "Major": 3,
    "Minor": 4,
    "Patch": 3
  }
}​

Example of Stack Sizes between plugin reloads (using wood as an example for comparison). Originally my stack size for resources was 10.0, but I set this to 5.0 to see if it's the CategoryStackMultiplier that seems to be effecting this error.

> stacksizecontroller.itemsearch wood
Unique Id   Shortname                Category     Vanilla Stack Custom Stack
190184021   kayak                    Items        10,000        1,000,000
-1234735557 arrow.wooden             Ammunition   640,000       64,000,000
-1336109173 door.double.hinged.wood  Construction 10,000        1,000,000
1729120840  door.hinged.wood         Construction 10,000        1,000,000
-335089230  gates.external.high.wood Construction 10,000        1,000,000
-316250604  ladder.wooden.wall       Construction 50,000        5,000,000
99588025    wall.external.high       Construction 100,000       10,000,000
-1183726687 wall.window.bars.wood    Construction 100,000       10,000,000
-1023374709 shutter.wood.a           Construction 200,000       20,000,000
-463122489  watchtower.wood          Construction 50,000        5,000,000
-2094954543 wood.armor.helmet        Attire       10,000        1,000,000
418081930   wood.armor.jacket        Attire       10,000        1,000,000
832133926   wood.armor.pants         Attire       10,000        1,000,000
1373240771  barricade.wood.cover     Construction 100,000       10,000,000
866889860   barricade.wood           Construction 100,000       10,000,000
1382263453  barricade.woodwire       Construction 100,000       10,000,000
833533164   box.wooden.large         Items        10,000        1,000,000
-143132326  sign.wooden.huge         Items        50,000        5,000,000
1153652756  sign.wooden.large        Items        50,000        5,000,000
-1819233322 sign.wooden.medium       Items        50,000        5,000,000
-1138208076 sign.wooden.small        Items        50,000        5,000,000
-180129657  box.wooden               Items        10,000        1,000,000
1524980732  carvable.pumpkin         Items        10,000        1,000,000
573676040   coffin.storage           Misc         10,000        1,000,000
699075597   woodcross                Misc         10,000        1,000,000
1840570710  abovegroundpool          Fun          10,000        1,000,000
-135252633  sled.xmas                Fun          10,000        1,000,000
-333406828  sled                     Fun          10,000        1,000,000
-151838493  wood                     Resources    10,000,000    1,000,000,000
-541206665  woodtea.advanced         Food         100,000       10,000,000
-649128577  woodtea                  Food         100,000       10,000,000
-557539629  woodtea.pure             Food         100,000       10,000,000
-1878475007 explosive.satchel        Tool         100,000       10,000,000
-1583967946 stonehatchet             Tool         10,000        1,000,000
1602646136  spear.stone              Weapon       10,000        1,000,000
1540934679  spear.wooden             Weapon       10,000        1,000,000
1659447559  horse.armor.wood         Attire       10,000        1,000,000

Saved 29,154 ents, cache(0.05), write(0.01), disk(0.02).
Saving complete
> o.unload StackSizeController
Unloaded plugin Stack Size Controller v3.4.3 by AnExiledGod
> o.load StackSizeController
StackSizeController was compiled successfully in 2283ms
Loaded plugin Stack Size Controller v3.4.3 by AnExiledGod
> stacksizecontroller.itemsearch wood
Unique Id   Shortname                Category     Vanilla Stack Custom Stack
190184021   kayak                    Items        10,000        1,000,000
-1234735557 arrow.wooden             Ammunition   640,000       64,000,000
-1336109173 door.double.hinged.wood  Construction 10,000        1,000,000
1729120840  door.hinged.wood         Construction 10,000        1,000,000
-335089230  gates.external.high.wood Construction 10,000        1,000,000
-316250604  ladder.wooden.wall       Construction 50,000        5,000,000
99588025    wall.external.high       Construction 100,000       10,000,000
-1183726687 wall.window.bars.wood    Construction 100,000       10,000,000
-1023374709 shutter.wood.a           Construction 200,000       20,000,000
-463122489  watchtower.wood          Construction 50,000        5,000,000
-2094954543 wood.armor.helmet        Attire       10,000        1,000,000
418081930   wood.armor.jacket        Attire       10,000        1,000,000
832133926   wood.armor.pants         Attire       10,000        1,000,000
1373240771  barricade.wood.cover     Construction 100,000       10,000,000
866889860   barricade.wood           Construction 100,000       10,000,000
1382263453  barricade.woodwire       Construction 100,000       10,000,000
833533164   box.wooden.large         Items        10,000        1,000,000
-143132326  sign.wooden.huge         Items        50,000        5,000,000
1153652756  sign.wooden.large        Items        50,000        5,000,000
-1819233322 sign.wooden.medium       Items        50,000        5,000,000
-1138208076 sign.wooden.small        Items        50,000        5,000,000
-180129657  box.wooden               Items        10,000        1,000,000
1524980732  carvable.pumpkin         Items        10,000        1,000,000
573676040   coffin.storage           Misc         10,000        1,000,000
699075597   woodcross                Misc         10,000        1,000,000
1840570710  abovegroundpool          Fun          10,000        1,000,000
-135252633  sled.xmas                Fun          10,000        1,000,000
-333406828  sled                     Fun          10,000        1,000,000
-151838493  wood                     Resources    10,000,000    500,000,000
-541206665  woodtea.advanced         Food         100,000       10,000,000
-649128577  woodtea                  Food         100,000       10,000,000
-557539629  woodtea.pure             Food         100,000       10,000,000
-1878475007 explosive.satchel        Tool         100,000       10,000,000
-1583967946 stonehatchet             Tool         10,000        1,000,000
1602646136  spear.stone              Weapon       10,000        1,000,000
1540934679  spear.wooden             Weapon       10,000        1,000,000
1659447559  horse.armor.wood         Attire       10,000        1,000,000

If I unload SSC and delete data\StackSizeController_vanilla-defaults.json and data\StackSizeController.json they are regenerated when I reload the plugin, but still the same values (vanilla wood stack should be 1000 right?)

Even still, the Custom stack is 50x the vanilla stack, not 5.0.

Another issue I've just discovered during my troubleshooting, thinking something is not interpreting the "." properly, I set the resources stack size as "5" (not "5.0") when the plugin reloads, the config file is set back at "5.0" but the custom Stack is set as 0:

Unique Id   Shortname                Category     Vanilla Stack Custom Stack
-151838493  wood                     Resources    500,000,000   0

Changing my config back to "5.0" and reloading the plugin, it's setting the stack size literally:

Unique Id   Shortname                Category     Vanilla Stack Custom Stack
-151838493  wood                     Resources    500,000,000   5

Any ideas as to what the cause could be? I have nuked everything related to the plugin except my config file once before to fix the issue once before, but it has recurred after the latest wipe.

Sorry if I've flooded with too much information, just trying to gather info as best I can. Let me know if you need more clarification. Cheers.

First, do not modify vanilla-defaults, just pointing this out since it's such an insane issue for some reason.

Rust does not support a way to get original default stack sizes, so I store them in vanilla-defaults.json. However if the plugin is hot loaded (while the server is running) it'll grab defaults, which may have already been modified.

Because it was hotloaded in this case, you've identified an issue I overlooked when implementing category multipliers, as they rely ENTIRELY on the values in vanilla-defaults. Only way to resolve this is to do a server restart. You shouldn't have to delete vanilla-defaults, just restart, additionally reloading SHOULDN'T cause value multiplication, however if either of those are true please let me know as it means there's a bug.

I appreciate the detailed information. For me there can never be too much information, but there sure as hell can be way too little information, which you'll see in many bug "reports". The more information provided, the easier and faster I can provide solutions.

Thanks for reaching out and let me know if anything I've said isn't working correctly. I'm currently working on the next major release which will have significant simplicity improvements but I can definently release a patch if my solution doesn't work in your case.

Howdy,

So between my post and your reply I've done some more testing and more or less worked out the duplication is happening whenever SSC initialised as part of a server restart.

Hotloading does not cause a multiplication of data as originally thought.

If I remove SSC from the plugins folder before I restart the server, and load it back in after everything is running, all is good. During server start, if SSC is present I see the two line items in console:
"Calling 'SetAllStacksCommand' on 'StackSizeController v3.4.3' took 217ms"
"Calling 'OnTerrainInitialized' on 'StackSizeController v3.4.3' took 5284ms [GARBAGE COLLECT]"

This doesn't appear in console when the plugin is hotloaded.

I've seen your post of upcoming changes, and I'm going to guess that offloading the vanilla's to github will probably resolve this issue anyway.

Thanks for the reply, and support!

Yeah I THINK preserving vanilla defaults should resolve the issue but if it doesn't once the next version is released, please post again and I'll def take another look

Hey,

Just confirming this issue is fixed in 4.1.1. My server is monthly so I was a bit slow to test. I figured I'd just let it run broken for the wipe.

Thanks for the help and fix.

franky888

Hey,

Just confirming this issue is fixed in 4.1.1. My server is monthly so I was a bit slow to test. I figured I'd just let it run broken for the wipe.

Thanks for the help and fix.

can you change the status to Solved, saves going back to it,

Locked automatically