From 9597058ecc331522fa280b1a4137a1109d77c681 Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Fri, 7 Mar 2025 16:36:59 +0100 Subject: [PATCH] Prevent certain entities from accidentally recieving a SubType -1 description --- features/eid_api.lua | 28 ++++++++++++++++++++++++++++ features/eid_debugging.lua | 10 ++++++++++ 2 files changed, 38 insertions(+) diff --git a/features/eid_api.lua b/features/eid_api.lua index 07469f14..f5398886 100644 --- a/features/eid_api.lua +++ b/features/eid_api.lua @@ -141,6 +141,10 @@ local dynamicSpriteCache = {} -- used to store sprite objects of collectible ico function EID:addCollectible(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" + if id == -1 then + print("EID Error: Trying to add collectible description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + return + end local modName = EID._currentMod -- Glitched Items exception so they don't have a mod name if id > 4294960000 then modName = nil end @@ -156,6 +160,10 @@ end function EID:addTrinket(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" + if id == -1 then + print("EID Error: Trying to add trinket description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + return + end EID:CreateDescriptionTableIfMissing("custom", language) EID.descriptions[language].custom["5.350." .. id] = {id, itemName, description, EID._currentMod} end @@ -168,6 +176,10 @@ end function EID:addCharacterInfo(characterId, description, playerName, language) playerName = playerName or "Modded Character" language = language or "en_us" + if characterId == -1 then + print("EID Error: Trying to add character description to id = -1, which is not allowed! (Name: "..tostring(playerName).."; Description: "..tostring(description)..")") + return + end EID:CreateDescriptionTableIfMissing("CharacterInfo", language) EID.descriptions[language].CharacterInfo[characterId] = {playerName, description} end @@ -216,6 +228,10 @@ end function EID:addCard(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" + if id == -1 then + print("EID Error: Trying to add card description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + return + end EID:CreateDescriptionTableIfMissing("custom", language) EID.descriptions[language].custom["5.300." .. id] = {id, itemName, description, EID._currentMod} end @@ -242,6 +258,10 @@ end function EID:addPill(id, description, itemName, language) itemName = itemName or nil language = language or "en_us" + if id == -1 then + print("EID Error: Trying to add pill description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + return + end EID:CreateDescriptionTableIfMissing("pills", language) EID:CreateDescriptionTableIfMissing("horsepills", language) EID.descriptions[language].pills[id+1] = {id, itemName, description, EID._currentMod} @@ -260,6 +280,10 @@ function EID:addHorsePill(id, description, itemName, language) if not EID.isRepentance then return end itemName = itemName or nil language = language or "en_us" + if id == -1 then + print("EID Error: Trying to add horsepill description to id = -1, which is not allowed! (Name: "..tostring(itemName).."; Description: "..tostring(description)..")") + return + end EID:CreateDescriptionTableIfMissing("horsepills", language) EID.descriptions[language].horsepills[id+1] = {id, itemName, description, EID._currentMod} end @@ -283,6 +307,10 @@ end function EID:addBirthright(characterId, description, playerName, language) playerName = playerName or nil language = language or "en_us" + if characterId == -1 then + print("EID Error: Trying to add Birthright description to id = -1, which is not allowed! (Name: "..tostring(characterId).."; Description: "..tostring(description)..")") + return + end EID:CreateDescriptionTableIfMissing("birthright", language) EID.descriptions[language].birthright[characterId + 1] = {playerName, "", description} end diff --git a/features/eid_debugging.lua b/features/eid_debugging.lua index e56cd7a0..cc6d79ef 100644 --- a/features/eid_debugging.lua +++ b/features/eid_debugging.lua @@ -211,6 +211,16 @@ EID:addColor("ColorBlackBlink", nil, function(color) -- Test: Pill effect unidentifyable EID:SetPillEffectUnidentifyable(24, true) -- set "I can see forever" to always be unidentifyable +-- Test: Write error for id = -1 +EID:addCollectible(-1, "Desc", "Fail") +EID:addTrinket(-1, "Desc", "Fail") +EID:addCharacterInfo(-1, "Desc", "Fail") +EID:addCard(-1, "Desc", "Fail") +EID:addPill(-1, "Desc", "Fail") +EID:addHorsePill(-1, "Desc", "Fail") +EID:addBirthright(-1, "Desc", "Fail") + + local function onDebugRender() EID:renderHUDLocationIndicators()