Caching improvement

master
gnomerd 5 years ago
parent 8148796afc
commit b35a9bb2de
  1. 1
      gamemode/cl_init.lua
  2. 6
      gamemode/engine/derma/cl_menu.lua

@ -9,6 +9,7 @@ if CLIENT then
include( "shared.lua" ) include( "shared.lua" )
--local gmfolder = GAMEMODE.FolderName || GM.FolderName --local gmfolder = GAMEMODE.FolderName || GM.FolderName
Quantum.Client = {} Quantum.Client = {}
Quantum.Client.Cache = {}
Quantum.Client.ResolutionScale = ScrH() / 1080 Quantum.Client.ResolutionScale = ScrH() / 1080
Quantum.Client.ServerBannerPath = "gamemodes/" .. GM.FolderName .. "/gamemode/content/materials/quantum/server_banner.png" Quantum.Client.ServerBannerPath = "gamemodes/" .. GM.FolderName .. "/gamemode/content/materials/quantum/server_banner.png"

@ -15,9 +15,13 @@ Quantum.Client.Menu.GetAPI = function( lib ) return include( libs[lib] ) end
net.Receive( "quantum_menu_net", function( len, pl ) net.Receive( "quantum_menu_net", function( len, pl )
local dt = net.ReadTable() -- TO DO: merge datatable with cached ( if same id/type ) local dt = net.ReadTable() -- TO DO: merge datatable with cached ( if same id/type )
if( Quantum.Client.Cache[dt.id] ~= nil && #Quantum.Client.Cache[dt.id] >= 1 ) then
table.Merge( dt, Quantum.Client.Cache[dt.id] )
end
Quantum.Client.Cache[dt.id] = dt || { id = dt.id }
if( Quantum.Client.EnableDebug ) then -- debug if( Quantum.Client.EnableDebug ) then -- debug
Quantum.Debug( "Datatable size: " .. len/8 .. " bytes" ) Quantum.Debug( "Datatable size: " .. len .. "b (" .. len/8 .. "B)" )
Quantum.Debug( "--Datatable contents--") Quantum.Debug( "--Datatable contents--")
PrintTable( dt ) PrintTable( dt )
Quantum.Debug( "--End of datatable contens--" ) Quantum.Debug( "--End of datatable contens--" )

Loading…
Cancel
Save