Fixes to ReceiveData

This commit is contained in:
ZioPao
2024-01-07 21:52:40 +01:00
parent 4cf97a2e79
commit 2cbf5aea8b
3 changed files with 10 additions and 11 deletions

View File

@@ -178,6 +178,7 @@ end
---Set a generic boolean that toggles varies function of the mod ---Set a generic boolean that toggles varies function of the mod
---@return boolean ---@return boolean
function ModDataHandler:getIsAnyLimbCut() function ModDataHandler:getIsAnyLimbCut()
--if self.isDataReady == false then return false end
return self.tocData.isAnyLimbCut return self.tocData.isAnyLimbCut
end end
@@ -318,7 +319,7 @@ function ModDataHandler:apply()
ModData.transmit(CommandsData.GetKey(self.username)) ModData.transmit(CommandsData.GetKey(self.username))
end end
function ModDataHandler.ReceiveData(key, table) function ModDataHandler.ReceiveData(key, data)
if not isClient() then if not isClient() then
TOC_DEBUG.print("SP, skipping ModDataHandler.ReceiveData") TOC_DEBUG.print("SP, skipping ModDataHandler.ReceiveData")
end end
@@ -326,23 +327,21 @@ function ModDataHandler.ReceiveData(key, table)
if key == "TOC_Bob" then return end if key == "TOC_Bob" then return end
TOC_DEBUG.print("[ModDataHandler] ReceiveData for " .. key) TOC_DEBUG.print("[ModDataHandler] ReceiveData for " .. key)
if table == {} or table == nil then if data == {} or data == nil then
TOC_DEBUG.print("table is nil... returning") TOC_DEBUG.print("table is nil... returning")
return return
end end
-- Create ModDataHandler instance if there was none for that user and reapply the correct ModData table as a reference -- Get ModDataHandler instance if there was none for that user and reapply the correct ModData table as a reference
local username = key:sub(5) local username = key:sub(5)
-- FIXME Triggers an error at startup during initialization
local handler = ModDataHandler.GetInstance(username) local handler = ModDataHandler.GetInstance(username)
if handler.isResetForced or data == nil or data == {} or data == false then
if handler.isResetForced then TOC_DEBUG.print("[ModDataHandler] Setup")
handler:setup(key) handler:setup(key)
handler.isResetForced = false handler.isResetForced = false
else else
handler:reapplyTocData(table) TOC_DEBUG.print("[ModDataHandler] Reapply")
handler:reapplyTocData(data)
end end

View File

@@ -98,7 +98,7 @@ function OverrideHealthPanelForTOC()
else else
if highestAmputations[side] == nil then return end if highestAmputations[side] == nil then return end
local limbName = highestAmputations[side] local limbName = highestAmputations[side]
TOC_DEBUG.print("Drawing " .. tostring(limbName) .. " for " .. username) --TOC_DEBUG.print("Drawing " .. tostring(limbName) .. " for " .. username)
local cicTime = ModDataHandler.GetInstance(username):getCicatrizationTime(limbName) local cicTime = ModDataHandler.GetInstance(username):getCicatrizationTime(limbName)
redColor = GetColorFromCicatrizationTime(cicTime, limbName) redColor = GetColorFromCicatrizationTime(cicTime, limbName)

View File

@@ -71,7 +71,7 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test)
context:addSubMenu(optionMain, subMenu) context:addSubMenu(optionMain, subMenu)
addMainOption = true addMainOption = true
end end
local option = subMenu:addOption(getText("ContextMenu_Limb_" .. limbName), limbName, Cauterize) local option = subMenu:addOption(getText("ContextMenu_Limb_" .. limbName), limbName, Cauterize)
option.notAvailable = isTempLow option.notAvailable = isTempLow
if isTempLow then if isTempLow then