From 9edf95c0e7c648202f07b9e1cdbc7c423c624174 Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Wed, 5 Feb 2020 21:13:51 +0100 Subject: [PATCH] Cache bug fix --- gamemode/engine/lib/server/sv_networking.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gamemode/engine/lib/server/sv_networking.lua b/gamemode/engine/lib/server/sv_networking.lua index 48338f3..56d6b7d 100644 --- a/gamemode/engine/lib/server/sv_networking.lua +++ b/gamemode/engine/lib/server/sv_networking.lua @@ -43,6 +43,10 @@ local function checkCacheTable( ply, cache_id, dt ) end local function CacheDatatableMethod( id, datatable, ply ) + if( ply.cache == nil ) then + ply.cache = {} + Quantum.Error( "Players cache is nil, creating..." ) + end -- failsafe ply.cache[id] = checkCacheTable( ply, id, datatable ) -- check caching tables etc Quantum.Debug( "(" .. tostring(ply) .. " | " .. tostring(id) .. ") Removing known data in cache from datatable..." ) if( ply.cache[id] ~= nil ) then @@ -60,7 +64,7 @@ local function CacheDatatableMethod( id, datatable, ply ) end end end - --datatable.id = id -- give it the id so that the client side could handle it + -- Always give the id since it is highly "valuable". -- Don't want the client mixing up the NPC, which this caching system could do if not handled correctly. return { id = id, cont = datatable } @@ -83,6 +87,7 @@ local function SendDatatableToClient( client, dt, type ) end function Quantum.Net.OpenMenu( pl, type, dt ) + if( pl.cache == nil ) then Quantum.Error( "Warning! " .. tostring(pl) .. " tried to open a menu before they had loaded into the server!" ) end SendDatatableToClient( pl, dt, type ) end