mirror of
https://github.com/wiremod/advdupe2.git
synced 2025-03-04 03:03:05 -05:00
Add max size for advdupe2 dupes (#470)
This commit is contained in:
parent
0c1d194c52
commit
238d02d289
@ -10,6 +10,7 @@
|
||||
|
||||
local REVISION = 5
|
||||
AdvDupe2.CodecRevision = REVISION
|
||||
AdvDupe2.MaxDupeSize = 32e6 -- 32 MB
|
||||
|
||||
include( "sh_codec_legacy.lua" )
|
||||
AddCSLuaFile( "sh_codec_legacy.lua" )
|
||||
@ -411,12 +412,12 @@ end
|
||||
|
||||
versions[4] = function(encodedDupe)
|
||||
local info, dupestring = getInfo(encodedDupe:sub(7))
|
||||
return deserialize(decompress(dupestring), read4), info
|
||||
return deserialize(decompress(dupestring, AdvDupe2.MaxDupeSize), read4), info
|
||||
end
|
||||
|
||||
versions[5] = function(encodedDupe)
|
||||
local info, dupestring = getInfo(encodedDupe:sub(7))
|
||||
return deserialize(decompress(dupestring), read5), info
|
||||
return deserialize(decompress(dupestring, AdvDupe2.MaxDupeSize), read5), info
|
||||
end
|
||||
|
||||
function AdvDupe2.CheckValidDupe(dupe, info)
|
||||
@ -508,11 +509,8 @@ function AdvDupe2.Decode(encodedDupe)
|
||||
if success then
|
||||
success, tbl = AdvDupe2.CheckValidDupe(tbl, info)
|
||||
end
|
||||
|
||||
if success then
|
||||
info.revision = rev
|
||||
else
|
||||
ErrorNoHalt(tbl)
|
||||
end
|
||||
|
||||
return success, tbl, info
|
||||
|
@ -37,6 +37,11 @@ concommand.Add("AdvDupe2_SaveFile", SaveFile)
|
||||
|
||||
function AdvDupe2.SendToClient(ply, data, autosave)
|
||||
if(not IsValid(ply))then return end
|
||||
if #data > AdvDupe2.MaxDupeSize then
|
||||
AdvDupe2.Notify(ply,"Copied duplicator filesize is too big!",NOTIFY_ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
ply.AdvDupe2.Downloading = true
|
||||
AdvDupe2.InitProgressBar(ply,"Saving:")
|
||||
|
||||
|
@ -835,6 +835,10 @@ if(SERVER) then
|
||||
|
||||
Tab.Map = true
|
||||
AdvDupe2.Encode( Tab, AdvDupe2.GenerateDupeStamp(ply), function(data)
|
||||
if #data > AdvDupe2.MaxDupeSize then
|
||||
AdvDupe2.Notify(ply, "Copied duplicator filesize is too big!",NOTIFY_ERROR)
|
||||
return
|
||||
end
|
||||
if(not file.IsDir("advdupe2_maps", "DATA")) then
|
||||
file.CreateDir("advdupe2_maps")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user