From 013f852e7e5b696c1ae20fae6a3bd9e655c2a5da Mon Sep 17 00:00:00 2001 From: ZioPao Date: Mon, 6 May 2024 17:14:45 +0200 Subject: [PATCH] Fixed huge bug that would break things after a player died --- media/lua/client/TOC/Controllers/DataController.lua | 8 +++++--- media/lua/client/TOC/Main.lua | 2 +- media/lua/server/TOC/ServerDataHandler.lua | 4 ++++ mod.info | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/media/lua/client/TOC/Controllers/DataController.lua b/media/lua/client/TOC/Controllers/DataController.lua index a9d5fae..80c3cdd 100644 --- a/media/lua/client/TOC/Controllers/DataController.lua +++ b/media/lua/client/TOC/Controllers/DataController.lua @@ -380,8 +380,9 @@ function DataController.ReceiveData(key, data) 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 -- 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 TOC_DEBUG.print("Forced reset") 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 TOC_DEBUG.print("Update from the server") end diff --git a/media/lua/client/TOC/Main.lua b/media/lua/client/TOC/Main.lua index 6568811..78b4bb0 100644 --- a/media/lua/client/TOC/Main.lua +++ b/media/lua/client/TOC/Main.lua @@ -6,7 +6,7 @@ require("TOC/Events") ---@class Main local Main = { - _version = "2.0.6" + _version = "2.0.7" } function Main.Start() diff --git a/media/lua/server/TOC/ServerDataHandler.lua b/media/lua/server/TOC/ServerDataHandler.lua index 68fea34..35db61b 100644 --- a/media/lua/server/TOC/ServerDataHandler.lua +++ b/media/lua/server/TOC/ServerDataHandler.lua @@ -34,6 +34,10 @@ function ServerDataHandler.AddTable(key, table) ModData.add(key, table) -- Add it to the server mod data 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 -- apply the changes back to the key client again to be sure that everything is in sync local username = CommandsData.GetUsername(key) diff --git a/mod.info b/mod.info index f5ff42c..0f8c10d 100644 --- a/mod.info +++ b/mod.info @@ -4,5 +4,5 @@ description=You've been bitten. You have only two choices. id=TheOnlyCure icon=icon.png url=https://github.com/ZioPao/The-Only-Cure -modversion=2.0.6 +modversion=2.0.7 pzversion=41.65