aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-09-08 18:48:13 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2017-09-08 18:48:13 -0400
commit22f3c6d96fcb560c13445d4a6135ca3f01d27197 (patch)
treebbabd4bc9d6b96acbbc6248833c602f8f3249a04 /gamemode/core
parent13a87c24b79ff4db6e1917409ce8a11b1d72b6e6 (diff)
downloadartery-22f3c6d96fcb560c13445d4a6135ca3f01d27197.tar.gz
artery-22f3c6d96fcb560c13445d4a6135ca3f01d27197.tar.bz2
artery-22f3c6d96fcb560c13445d4a6135ca3f01d27197.zip
Deleted a lot of code
Deleted code that was not being used, and some of the images too.
Diffstat (limited to 'gamemode/core')
-rw-r--r--gamemode/core/inventory/inventory.lua4
-rw-r--r--gamemode/core/inventory/item.lua5
-rw-r--r--gamemode/core/inventory/sv_invtracker.lua28
-rw-r--r--gamemode/core/pac/sv_pac.lua17
4 files changed, 28 insertions, 26 deletions
diff --git a/gamemode/core/inventory/inventory.lua b/gamemode/core/inventory/inventory.lua
index 5ff4c10..b96d168 100644
--- a/gamemode/core/inventory/inventory.lua
+++ b/gamemode/core/inventory/inventory.lua
@@ -46,6 +46,7 @@
]]
local inv = {}
+local log = nrequire("log.lua")
--Creates a partial copy of a table(tables are copied, functions are not)
local function TableCopy(tbl)
@@ -122,7 +123,7 @@ function inv.RegisterInventory(tbl)
--assert(inventories[tbl.Name] == nil,
-- string.format("Attempted to register 2 inventories with the same name: %q", tbl.Name))
if inventories[tbl.Name] ~= nil then
- MsgC(Color(255,255,0),"Registering 2 inventories with the same name:" .. tbl.Name)
+ log.warn(string.format("Registered 2 inventories with the same name %q, overwriteing",tbl.Name))
end
assert((tbl.AddObserver == nil and tbl.RemoveObserver == nil) or
(tbl.AddObserver ~= nil and tbl.RemoveObserver ~= nil),
@@ -131,6 +132,7 @@ function inv.RegisterInventory(tbl)
SetDefaultObservers(tbl)
end
inventories[tbl.Name] = tbl
+ log.info("Registered inventory: " .. tbl.Name)
--print("Registered inventory: " .. tbl.Name)
end
diff --git a/gamemode/core/inventory/item.lua b/gamemode/core/inventory/item.lua
index a598fc2..80e2a88 100644
--- a/gamemode/core/inventory/item.lua
+++ b/gamemode/core/inventory/item.lua
@@ -18,6 +18,7 @@
Items may also have methods from one or more interfaces registered with RegisterInterface
]]
+local log = nrequire("log.lua")
local itm = {}
local required_fields = {
"Name","Serialize","DeSerialize"
@@ -30,9 +31,9 @@ function itm.RegisterItem(tbl)
end
--assert(items[tbl.Name] == nil, string.format("Attempted to register 2 items with the same name %q",tbl.Name))
if items[tbl.Name] ~= nil then
- MsgC(Color(255,255,0),"WARNING: attemtpted to register 2 items with the same name " .. tbl.Name .. "\n")
+ log.warn(string.format("Attempted to register 2 items with the same name: %q, overwriteing previous",tbl.Name))
else
- MsgC(Color(0,255,0),"Registered Item " .. tbl.Name .. "\n")
+ log.info(string.format("Registered item %s",tbl.Name))
end
items[tbl.Name] = tbl
--print("Registered item: " .. tbl.Name)
diff --git a/gamemode/core/inventory/sv_invtracker.lua b/gamemode/core/inventory/sv_invtracker.lua
index ab39e41..537d61d 100644
--- a/gamemode/core/inventory/sv_invtracker.lua
+++ b/gamemode/core/inventory/sv_invtracker.lua
@@ -4,6 +4,7 @@
local inv = nrequire("inventory/inventory.lua")
local itm = nrequire("item.lua")
+local log = nrequire("log.lua")
local track = {}
for k,v in pairs({
@@ -33,30 +34,23 @@ end)
topos ::table
]]
net.Receive("art_RequestInvMove",function(len,ply)
- print("ply",ply,"requested inv move")
--Read the data from the net message
local froment,toent = net.ReadEntity(),net.ReadEntity()
local frominvid,toinvid = net.ReadUInt(32),net.ReadUInt(32)
local frompos,topos = net.ReadTable(),net.ReadTable()
+ log.debug(string.format("ply %q requested inventory move from (%q,%d) to (%q,%d)",tostring(ply),tostring(froment),frominvid,tostring(toent),toinvid))
--Make sure the player is not stealing!
assert(not (froment:IsPlayer() and toent:IsPlayer() and froment ~= toent), "Tried to move item between players!")
- print("froment",froment)
- print("froment.data:",froment.data)
- print("froment.data.inventories",froment.data.inventories)
- PrintTable(froment.data.inventories)
- print("invid:",froment.data.inventories[frominvid])
+ --Make sure the entity from has that inventory
assert(froment.data ~= nil and froment.data.inventories ~= nil and froment.data.inventories[frominvid] ~= nil, "From entity did not have that inventory!")
- print("toent",toent)
- print("toent.data",toent.data)
- print("toent.data.inventories",toent.data.inventories)
- PrintTable(toent.data.inventories)
- print("toinvid",toinvid)
- print("toent.data.inventories[invid]",toent.data.inventories[toinvid])
+ --Make sure the entity to has that inventory
assert(toent.data ~= nil and toent.data.inventories ~= nil and toent.data.inventories[toinvid] ~= nil, "To entity did not have that inventory!")
local frominv = froment.data.inventories[frominvid]
local toinv = toent.data.inventories[toinvid]
local item = frominv:Get(frompos)
+ --Make sure the frominv has an item at that pos
assert(item ~= nil, "Could not find an item at that position!")
+ --Make sure it can fit in toinv
assert(toinv:CanFitIn(topos,item), "Could not fit the item in that position!")
--If we've gotten here without error, we're all good! Move the item!
frominv:Remove(frompos)
@@ -245,11 +239,11 @@ function track.SendPlayerData(ply)
net.Send(ply)
end
-concommand.Add("artery_SendMeData",function(ply,cmd,args)
- track.ClearInventories(ply)
- track.GiveInventoryTo(ply,"Equipment")
- track.SendPlayerData(ply)
-end)
+-- concommand.Add("artery_SendMeData",function(ply,cmd,args)
+-- track.ClearInventories(ply)
+-- track.GiveInventoryTo(ply,"Equipment")
+-- track.SendPlayerData(ply)
+-- end)
concommand.Add("artery_ShowMyInventories",function(ply,cmd,args)
PrintTable(ply.data.inventories)
diff --git a/gamemode/core/pac/sv_pac.lua b/gamemode/core/pac/sv_pac.lua
index e9492e9..229b258 100644
--- a/gamemode/core/pac/sv_pac.lua
+++ b/gamemode/core/pac/sv_pac.lua
@@ -26,7 +26,7 @@
"artery_requestpac",
"artery_downloadpac"
]]
-
+local log = nrequire("log.lua")
local p3 = {}
local nwstrings = {
@@ -45,9 +45,14 @@ end
hook.Add("PrePACConfigApply", "stoppacs", function(ply, outfit_data)
if not ply:IsAdmin() then
return false, "You don't have permission to do that!"
- end
+ end
end)
+hook.Add( "PrePACEditorOpen", "stoppaceditor", function( ply )
+ return ply:IsSuperAdmin(), "This is accessable only to superadmins"
+end )
+
+
local pacsources = {
["data/artery/pacs/"] = "GAME"
}
@@ -80,7 +85,7 @@ end)
local appliedpacs = {}
function p3.ApplyPac(what, name)
- print("Applying pac", name, "to",what)
+ log.debug(string.format("Applying pac %q to %q",name,tostring(what)))
assert(pachashes[name],string.format("Tried to apply pac %s which didn't have a hash. Pac hashes are:%s",name,table.ToString(pachashes,"pachashes",true)))
appliedpacs[what] = appliedpacs[what] or {}
appliedpacs[what][name] = pachashes[name]
@@ -96,7 +101,7 @@ function p3.ApplyPac(what, name)
end
function p3.RemovePac(what, name)
- print("Removeing pac",what,"from",name)
+ log.debug(string.format("Removeing pac %q from %q",name,tostring(what)))
assert(appliedpacs[what][name],"Attempted to remove a pac that an entity is not wearing!")
appliedpacs[what][name] = nil
if #appliedpacs[what] == 0 then
@@ -170,10 +175,10 @@ end
net.Receive("artery_requestpac",function(ln,ply)
local pac_name = net.ReadString()
-
+ log.debug(string.format("Player %q requested pac %q",tostring(ply),pac_name))
--Double check that we're not executing a directory traversal attack https://www.owasp.org/index.php/Path_Traversal
if string.find(pac_name,"..",1,true) then
- Report(string.format("Directory traversal attack attempted by %s:%s using artery_requestpac string %q",ply:Nick(),ply:SteamID64(),pac_name))
+ log.report(string.format("Directory traversal attack attempted by %s:%s using artery_requestpac string %q",ply:Nick(),ply:SteamID64(),pac_name))
end
local pac_txt = cacheload(pac_name)