Jump to content

Skin Approval GUI Not Working

Pending 3.1.0

punchinelli
punchinelli

Posted

The /skinrequests (or /srs) feature isn't working.  I'll post the console error below.  I'm fairly certain this has to do with the new indexing changes.  The skin's item ID isn't getting populated in the skin requests JSON file in /data.  It's returning 0 every time.  This is causing it to crash.


 

Quote

 

12/29 9:25:35 AM [Info] NullReferenceException: Object reference not set to an instance of an object.

12/29 9:25:35 AM [Info] at Oxide.Plugins.Skinner+BoxController.GetItemFromPool (System.UInt64 cachedSkin, ItemDefinition itemDef, System.Int32 pos) [0x00087] in <9e751855cb274f209d8951a142ba4bf9>:0

12/29 9:25:35 AM [Info] at Oxide.Plugins.Skinner+BoxController.InsertItem (System.UInt64 cachedSkin, ItemDefinition itemDef, System.Int32 amount, System.Int32 pos) [0x00000] in <9e751855cb274f209d8951a142ba4bf9>:0

12/29 9:25:35 AM [Info] at Oxide.Plugins.Skinner+BoxController.GetRequestSkins () [0x00195] in <9e751855cb274f209d8951a142ba4bf9>:0

12/29 9:25:35 AM [Info] at Oxide.Plugins.Skinner+BoxController.SkinRequests () [0x00041] in <9e751855cb274f209d8951a142ba4bf9>:0

12/29 9:25:35 AM [Info] at Oxide.Plugins.Skinner+<CheckforRequests>d__81.MoveNext () [0x000de] in <9e751855cb274f209d8951a142ba4bf9>:0

12/29 9:25:35 AM [Info] at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00026] in <470ec865e9cd405cbc45cdbc22bb3c0c>:0

 

 

punchinelli

Posted (edited)

Don't hate me - but ChatGPT Premium/"Thinking" seems to think the following.  I don't know if this is accurate or not, but providing as a courtesy, regardless. Sometimes it makes incorrect assumptions, but other times it fixes stuff like gangbusters with precision. - Punch

The GUI is failing because Skinner is trying to render “request items” with a null ItemDefinition, and then it dereferences itemDef.condition.max, which throws the NullReferenceException you’re seeing.

Where it blows up (and why)

In BoxController.GetItemFromPool(), the plugin unconditionally uses itemDef.condition.max (twice). If itemDef is null, you get your exact exception and the UI never completes.

That null itemDef originates here in the skin-requests UI fill loop:

  • It reads a RequestItem from _requestsData
  • It does ItemManager.FindItemDefinition(requestitem.itemID)
  • If itemID is 0/invalid, FindItemDefinition() returns null
  • It then calls InsertItem(..., itemDef, ...) anyway

So the immediate “problem” is: your request entries contain invalid itemID values (commonly 0), which causes itemDef to be null and the UI render to crash.

Why your _requestsData is ending up with bad itemIDs

The code that is supposed to populate RequestItem.itemID from the Steam API is bugged in two separate ways:

  1. Chunking bug (wrong indexing):
    1. In GetSteamWorkshopSkinRequests(), it loops batches using start, but it always reads _requestsData[i] instead of _requestsData[start + i]. That means every batch submits the same first chunk repeatedly (and can leave later entries unprocessed).
  2. Struct write-back bug (the big one):RequestItem is a struct.
    1. In the response processing loop, it does:
      1. RequestItem request = _requestsData[i]; ... request = new RequestItem { ... }; break;

That only updates the local variable. It never assigns back to _requestsData[i], so itemID in the list stays whatever it was (often 0). Result: _requestsData never gets valid itemIDs, and /skinrequests tries to render null ItemDefinitions and crashes.

Confirm quickly (no guessing)

Check the plugin data file Skinner uses for requests:

  • It loads requests from Skinner/SkinsRequestData
  • On disk that will typically be: oxide/data/Skinner/SkinsRequestData.json

If you open it and see entries like "itemID": 0, that directly explains the null ItemDefinition and the crash. (PUNCHINELLI'S NOTE:  YES, THIS IS HAPPENING!)

Recommended fixes (in order of impact)

Fix A : Correctly populate request itemID and save it

Apply both corrections in GetSteamWorkshopSkinRequests():

Fix the batching index:

// was: RequestItem request = _requestsData[i];
RequestItem request = _requestsData[start + i];

Write updated struct back into the list:

// was: request = new RequestItem { ... };
_requestsData[i] = new RequestItem { itemID = itemDef.itemid, skinID = workshopIdUlong, itemDisplayname = file.title };

After updating _requestsData, ensure it persists (either call SaveData() at the end of the coroutine, or rely on periodic save if enabled). The plugin does have periodic saves if config.periodicDataSave > 0.

Fix B : Make /skinrequests robust so one bad entry can’t brick the UI

Add a null-check in the requests UI loop before calling InsertItem():

ItemDefinition itemDef = ItemManager.FindItemDefinition(requestitem.itemID); 
if (itemDef == null) 
{ 
skinner.Puts($"Skin request {requestitem.skinID} has invalid itemID {requestitem.itemID}; skipping"); continue; 
} 
InsertItem(requestitem.skinID, itemDef, 1, i);

This prevents GetItemFromPool() from ever receiving a null itemDef (which currently guarantees the NRE).

Fix C : Defensive coding inside GetItemFromPool() (optional but advisable)

Right now InsertItem() accepts ItemDefinition?, but GetItemFromPool() assumes non-null and dereferences it.
Either make GetItemFromPool() accept nullable and return null early, or keep it strict and enforce non-null before calling it (Fix B).

 

Edited by punchinelli
RocketMyrr

Posted

Having the same issue would love a fix for this

2.1m

Downloads

Total number of downloads.

9.9k

Customers

Total customers served.

144.8k

Files Sold

Total number of files sold.

3.1m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.