@@ -380,8 +380,9 @@ function DataController.ReceiveData(key, data)
|
|||||||
|
|
||||||
|
|
||||||
TOC_DEBUG.print("ReceiveData for " .. key)
|
TOC_DEBUG.print("ReceiveData for " .. key)
|
||||||
if data == {} or data == nil then
|
|
||||||
error("Data is nil, new character or something is wrong")
|
if data == nil or data.limbs == nil then
|
||||||
|
TOC_DEBUG.print("Data is nil, new character or something is wrong")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get DataController instance if there was none for that user and reapply the correct ModData table as a reference
|
-- Get DataController instance if there was none for that user and reapply the correct ModData table as a reference
|
||||||
@@ -399,7 +400,8 @@ function DataController.ReceiveData(key, data)
|
|||||||
if handler.isResetForced then
|
if handler.isResetForced then
|
||||||
TOC_DEBUG.print("Forced reset")
|
TOC_DEBUG.print("Forced reset")
|
||||||
handler:setup(key)
|
handler:setup(key)
|
||||||
elseif data then
|
elseif data and data.limbs then
|
||||||
|
-- Let's validate that the data structure is actually valid to prevent issues
|
||||||
if data.isUpdateFromServer then
|
if data.isUpdateFromServer then
|
||||||
TOC_DEBUG.print("Update from the server")
|
TOC_DEBUG.print("Update from the server")
|
||||||
end
|
end
|
||||||
@@ -474,4 +476,12 @@ function DataController.GetInstance(username)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function DataController.DestroyInstance(username)
|
||||||
|
if DataController.instances[username] ~= nil then
|
||||||
|
DataController.instances[username] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
return DataController
|
return DataController
|
||||||
@@ -6,7 +6,7 @@ require("TOC/Events")
|
|||||||
|
|
||||||
---@class Main
|
---@class Main
|
||||||
local Main = {
|
local Main = {
|
||||||
_version = "2.0.6"
|
_version = "2.0.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Main.Start()
|
function Main.Start()
|
||||||
@@ -36,16 +36,15 @@ function Main.InitializePlayer()
|
|||||||
CommonMethods.SafeStartEvent("OnTick", TryToInitialize)
|
CommonMethods.SafeStartEvent("OnTick", TryToInitialize)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Clean the TOC table for that SP player, to prevent from clogging it up
|
---Clean the TOC table for that SP player, to prevent it from clogging ModData up
|
||||||
---@param player IsoPlayer
|
---@param player IsoPlayer
|
||||||
function Main.WipeData(player)
|
function Main.WipeData(player)
|
||||||
TOC_DEBUG.print("Wiping data after death")
|
local username = player:getUsername()
|
||||||
local key = CommandsData.GetKey(player:getUsername())
|
TOC_DEBUG.print("Wiping data after death: " .. username)
|
||||||
|
local key = CommandsData.GetKey(username)
|
||||||
|
|
||||||
--ModData.remove(key)
|
--ModData.remove(key)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not isClient() then
|
if not isClient() then
|
||||||
-- For SP, it's enough just removing the data this way
|
-- For SP, it's enough just removing the data this way
|
||||||
ModData.remove(key)
|
ModData.remove(key)
|
||||||
@@ -54,7 +53,14 @@ function Main.WipeData(player)
|
|||||||
-- at the next character by passing an empty mod data
|
-- at the next character by passing an empty mod data
|
||||||
ModData.add(key, {})
|
ModData.add(key, {})
|
||||||
ModData.transmit(key)
|
ModData.transmit(key)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Let's wipe the instance too just to be sure
|
||||||
|
local DataController = require("TOC/Controllers/DataController")
|
||||||
|
DataController.DestroyInstance(username)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--* Events *--
|
--* Events *--
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ function ServerDataHandler.AddTable(key, table)
|
|||||||
ModData.add(key, table) -- Add it to the server mod data
|
ModData.add(key, table) -- Add it to the server mod data
|
||||||
ServerDataHandler.modData[key] = table
|
ServerDataHandler.modData[key] = table
|
||||||
|
|
||||||
|
|
||||||
|
-- Check integrity of table. if it doesn't contains toc data, it means that we received a reset
|
||||||
|
if table.limbs == nil then return end
|
||||||
|
|
||||||
-- Since this could be triggered by a different client than the one referenced in the key, we're gonna
|
-- Since this could be triggered by a different client than the one referenced in the key, we're gonna
|
||||||
-- apply the changes back to the key client again to be sure that everything is in sync
|
-- apply the changes back to the key client again to be sure that everything is in sync
|
||||||
local username = CommandsData.GetUsername(key)
|
local username = CommandsData.GetUsername(key)
|
||||||
|
|||||||
2
mod.info
2
mod.info
@@ -4,5 +4,5 @@ description=You've been bitten. You have only two choices.
|
|||||||
id=TheOnlyCure
|
id=TheOnlyCure
|
||||||
icon=icon.png
|
icon=icon.png
|
||||||
url=https://github.com/ZioPao/The-Only-Cure
|
url=https://github.com/ZioPao/The-Only-Cure
|
||||||
modversion=2.0.6
|
modversion=2.0.7
|
||||||
pzversion=41.65
|
pzversion=41.65
|
||||||
|
|||||||
Reference in New Issue
Block a user