diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-03-25 12:58:22 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-03-25 12:58:22 -0400 |
| commit | 025ef8554016a2647f31244cf6413d80dba91847 (patch) | |
| tree | 32280de04737bf4a90f96cfe3120c3fd10a06a76 | |
| parent | 563f3e3960221fd9144e9adbde53c09392f772dd (diff) | |
| download | artery-025ef8554016a2647f31244cf6413d80dba91847.tar.gz artery-025ef8554016a2647f31244cf6413d80dba91847.tar.bz2 artery-025ef8554016a2647f31244cf6413d80dba91847.zip | |
Fix #3
Allows pacs that have been loaded on join to be removed
Also loads player data much sooner after the player spawns in.
| -rw-r--r-- | gamemode/client/cl_inventory.lua | 1 | ||||
| -rw-r--r-- | gamemode/core/editor/editor.lua | 3 | ||||
| -rw-r--r-- | gamemode/core/inventory/common/items.lua | 2 | ||||
| -rw-r--r-- | gamemode/core/inventory/inventory.lua | 7 | ||||
| -rw-r--r-- | gamemode/core/inventory/sv_invtracker.lua | 1 | ||||
| -rw-r--r-- | gamemode/core/pac/cl_pac.lua | 18 | ||||
| -rw-r--r-- | gamemode/core/pac/sv_pac.lua | 10 | ||||
| -rw-r--r-- | gamemode/server/sv_loadplayer.lua | 12 |
8 files changed, 36 insertions, 18 deletions
diff --git a/gamemode/client/cl_inventory.lua b/gamemode/client/cl_inventory.lua index 1e8fed8..f0c4d07 100644 --- a/gamemode/client/cl_inventory.lua +++ b/gamemode/client/cl_inventory.lua @@ -118,6 +118,7 @@ function inv.ShowInventory() local froment = panels[1].info.owner local fromid = panels[1].info.id local frompos = panels[1].info.pos + assert(froment:IsValid(), "Tried to drop an item from an entity that isn't valid!") itm.DropItem(froment,fromid,frompos) end,{}) end diff --git a/gamemode/core/editor/editor.lua b/gamemode/core/editor/editor.lua new file mode 100644 index 0000000..23c5991 --- /dev/null +++ b/gamemode/core/editor/editor.lua @@ -0,0 +1,3 @@ +--[[ + Allow admins to develop the world in-game. +]] diff --git a/gamemode/core/inventory/common/items.lua b/gamemode/core/inventory/common/items.lua index 0a32f27..65d8e4a 100644 --- a/gamemode/core/inventory/common/items.lua +++ b/gamemode/core/inventory/common/items.lua @@ -3,6 +3,7 @@ --@shared items.lua --@alias items +local log = nrequire("log.lua") local items = {} -- local function drop_provided(ent,invid,frompos) @@ -28,6 +29,7 @@ function items.DropItem(ent_or_tbl,invid,frompos) end ]] assert(CLIENT,"requested to drop an item when we are not the client!") + log.debug("Drop item was requested, ent_or_tbl is" .. tostring(ent_or_tbl)) net.Start("art_RequestInvDrop") net.WriteEntity(ent_or_tbl) net.WriteUInt(invid,32) diff --git a/gamemode/core/inventory/inventory.lua b/gamemode/core/inventory/inventory.lua index ff9cc8c..52443a8 100644 --- a/gamemode/core/inventory/inventory.lua +++ b/gamemode/core/inventory/inventory.lua @@ -174,9 +174,12 @@ function inv.CreateInventoryFromData(name,data,owner) --print("tinv was", tinv) --PrintTable(tinv) local ret = tinv:DeSerialize(data) - --print("is now",tinv) - --PrintTable(tinv) + print("is now",ret) + PrintTable(ret) assert(ret != nil, "Failed to create inventory " .. name .. ", returned nil") + assert(ret.Owner != nil, "Creating inventory with no owner!") + assert(ret.Owner:IsValid(), "Owner of inventory was not valid!") + assert(ret.Owner != Entity(0), "Owner was worldspawn! something went wrong!") return ret end diff --git a/gamemode/core/inventory/sv_invtracker.lua b/gamemode/core/inventory/sv_invtracker.lua index 257410b..8795d2a 100644 --- a/gamemode/core/inventory/sv_invtracker.lua +++ b/gamemode/core/inventory/sv_invtracker.lua @@ -77,6 +77,7 @@ net.Receive("art_RequestInvDrop",function(len,ply) local froment = net.ReadEntity() local frominvid = net.ReadUInt(32) local frompos = net.ReadTable() + log.debug("Requesting invdrop from " .. tostring(froment)) assert(not froment:IsPlayer() or froment == ply, "Player tried to drop an item that was from another players inventory") local frominv = froment.data.inventories[frominvid] local item = frominv:Get(frompos) diff --git a/gamemode/core/pac/cl_pac.lua b/gamemode/core/pac/cl_pac.lua index 490ad31..477d65d 100644 --- a/gamemode/core/pac/cl_pac.lua +++ b/gamemode/core/pac/cl_pac.lua @@ -19,22 +19,28 @@ if pac == nil then return --Don't execute this file! end -timer.Simple(0,function() - net.Start("artery_getworldpacs") - net.SendToServer() -end) - local CLIENT_PAC_DIR = "artery/client/pacs" file.CreateDir(CLIENT_PAC_DIR) local function loadpac(ent,name,hash) + if (not ent) or (not ent:IsValid()) then + timer.Simple(1,function() + loadpac(ent,name,hash) + end) + return + end print("Told to apply pac", name, "to ent", ent) local filepath = string.format(CLIENT_PAC_DIR .. "/%s.txt",name) local filetext = file.Read(filepath,"DATA") if ent.AttachPACPart == nil then pac.SetupENT(ent) - assert(ent.AttachPACPart ~= nil,"Failed to set up ent",ent) + if ent.AttachPACPart == nil then + timer.Simple(1,function() + loadpac(ent,name,hash) + end) + return + end end if filetext and (tonumber(util.CRC(filetext)) == hash) then print("The file on our local system is up to date, applying!") diff --git a/gamemode/core/pac/sv_pac.lua b/gamemode/core/pac/sv_pac.lua index 916430c..6c9a731 100644 --- a/gamemode/core/pac/sv_pac.lua +++ b/gamemode/core/pac/sv_pac.lua @@ -140,10 +140,12 @@ function p3.GetPacs(what) end --If a player joins the server, tell them all about the pacs that are applied -net.Receive("artery_getworldpacs",function(ln,ply) - net.Start("artery_giveworldpacs") - net.WriteTable(appliedpacs) - net.Send(ply) +hook.Add("PlayerLoadout","send_world_pacs",function(ply) + timer.Simple(1,function() + net.Start("artery_giveworldpacs") + net.WriteTable(appliedpacs) + net.Send(ply) + end) end) local max_pacs_in_cache = 10 diff --git a/gamemode/server/sv_loadplayer.lua b/gamemode/server/sv_loadplayer.lua index faeaaf3..9e8c72d 100644 --- a/gamemode/server/sv_loadplayer.lua +++ b/gamemode/server/sv_loadplayer.lua @@ -16,12 +16,12 @@ local function delayplayerload(ply) end end -hook.Add("PlayerInitialSpawn","ArteryPlayerLoad",function(pl) - local modelnum = pl:UniqueID() % (#models) - timer.Simple(10,function() +hook.Add("PlayerLoadout","ArteryPlayerLoad",function(pl) + timer.Simple(1,function() + local modelnum = pl:UniqueID() % (#models) delayplayerload(pl) + pl:SetModel(models[modelnum]) + pl:Give("hands") + pl:SelectWeapon("hands") end) - pl:SetModel(models[modelnum]) - pl:Give("hands") - pl:SelectWeapon("hands") end) |
