From 9e0537b0aa417e88a6a61238484ddcef74080ae0 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sun, 7 May 2017 13:47:40 -0400 Subject: Added tons of stuff --- gamemode/core/pac/cl_pac.lua | 10 ++++++---- gamemode/core/pac/sv_pac.lua | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'gamemode/core/pac') diff --git a/gamemode/core/pac/cl_pac.lua b/gamemode/core/pac/cl_pac.lua index 9163d82..4f1890c 100644 --- a/gamemode/core/pac/cl_pac.lua +++ b/gamemode/core/pac/cl_pac.lua @@ -27,11 +27,13 @@ timer.Simple(0,function() net.SendToServer() end) -file.CreateDir("artery/pacs") +local CLIENT_PAC_DIR = "artery/client/pacs" + +file.CreateDir(CLIENT_PAC_DIR) local function loadpac(ent,name,hash) print("Told to apply pac", name, "to ent", ent) - local filepath = string.format("artery/pacs/%s.txt",name) + local filepath = string.format(CLIENT_PAC_DIR .. "/%s.txt",name) local filetext = file.Read(filepath,"DATA") if ent.AttachPACPart == nil then pac.SetupENT(ent) @@ -52,7 +54,7 @@ local function loadpac(ent,name,hash) end local function unloadpac(ent,name,hash) - local filepath = string.format("artery/pacs/%s.txt",name) + local filepath = string.format(CLIENT_PAC_DIR .. "/%s.txt",name) local filetext = file.Read(filepath,"DATA") local pactbl = CompileString(string.format("return {%s}",filetext),name)() ent:RemovePACPart(pactbl) @@ -62,7 +64,7 @@ net.Receive("artery_downloadpac",function() local pac_name = net.ReadString() local pac_txt = net.ReadString() local pac_hash = net.ReadUInt(32) - local filepath = string.format("artery/pacs/%s.txt",pac_name) + local filepath = string.format(CLIENT_PAC_DIR .."/%s.txt",pac_name) file.Write(filepath,pac_txt) end) diff --git a/gamemode/core/pac/sv_pac.lua b/gamemode/core/pac/sv_pac.lua index 3c5c6be..482dea6 100644 --- a/gamemode/core/pac/sv_pac.lua +++ b/gamemode/core/pac/sv_pac.lua @@ -108,12 +108,16 @@ local function cacheload(key) --If it's already in the cache, just update the time it was last used and return the pac. if pac_cache[key] ~= nil then pac_cache[key].time = CurTime() + if pac_cache[key].pac == nil then + PrintTable(pac_cache) + error("Pac was loaded, but the txt was nil!") + end return pac_cache[key].pac end --Otherwise, we need to load it. local pacpath = string.format("artery/pacs/%s.txt",key) - local pacfile = file.Read(pacpath,"LUA") + local pacfile = file.Read(pacpath,"DATA") --If we haven't reached max cache yet, just put it in if pacs_in_cache < max_pacs_in_cache then -- cgit v1.2.3-70-g09d2