mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-18 06:03:47 +03:00
Upload
This commit is contained in:
68
lua/pac3/editor/server/util.lua
Normal file
68
lua/pac3/editor/server/util.lua
Normal file
@@ -0,0 +1,68 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
function pace.dprint(fmt, ...)
|
||||
if pace.debug then
|
||||
MsgN("\n")
|
||||
MsgN(">>>PAC3>>>")
|
||||
MsgN(fmt:format(...))
|
||||
if pace.debug_trace then
|
||||
MsgN("==TRACE==")
|
||||
debug.Trace()
|
||||
MsgN("==TRACE==")
|
||||
end
|
||||
MsgN("<<<PAC3<<<")
|
||||
MsgN("\n")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function pace.CallHook(str, ...)
|
||||
return hook.Call("pac_" .. str, GAMEMODE, ...)
|
||||
end
|
||||
|
||||
|
||||
local function wrap_err(ok,...)
|
||||
if not ok then
|
||||
ErrorNoHalt(tostring((...)) .. "\n")
|
||||
end
|
||||
return ...
|
||||
end
|
||||
|
||||
function pace.PCallCriticalFunction(ply, func, ...)
|
||||
if ply.pac_pcall_last_error and ply.pac_pcall_last_error + 1 > SysTime() then
|
||||
local time = RealTime()
|
||||
if not ply.pac_pcall_next_print or ply.pac_pcall_next_print < time then
|
||||
pac.Message("cannot handle net message from ", ply, " because it errored less than 1 second ago")
|
||||
ply.pac_pcall_next_print = time + 1
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local ok, msg = xpcall(func, function(msg)
|
||||
debug.Trace()
|
||||
end, ...)
|
||||
|
||||
if ok then
|
||||
return ok, msg
|
||||
end
|
||||
|
||||
pac.Message("net receive error from ", ply, ": ", msg)
|
||||
|
||||
ply.pac_pcall_last_error = SysTime()
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function pace.PCallNetReceive(receive, id, func)
|
||||
receive(id, function(len, ply, ...)
|
||||
pace.PCallCriticalFunction(ply, func, len, ply, ...)
|
||||
end)
|
||||
end
|
||||
Reference in New Issue
Block a user