Files
GS13NG/code/citadel/vore/trycatch_vr.dm
T
TalkingCactusandPoojawa 9d9a93335b Merge /vore into /master (#39)
* progress

* Compile errors fixed

No idea if it's test worthy tho as conflicts with race overhaul and
narky removal.

* Update admins.txt

* efforts continue

Fuck grab code, seriously

* grab code is cancer

* Execute the Narkism

Do not hesitate.

Show no mercy.

* holy shit grab code is awful

* have I bitched about grab code

My bitching, let me show you it

* código de agarre es una mierda

No really it is

* yeah I don't even know anymore.

* Lolnope. Fuck grab code

* I'm not even sure what to fix anymore

* Self eating is not an acceptable fate

* Taste the void, son.

* My code doesn't pass it's own sanity check.

Maybe it's a sign of things to come.

* uncommented and notes

* It Works and I Don't Know Why (#38)

* shuttle auto call

* it works and I don't know why
2016-09-09 23:31:01 -05:00

63 lines
1.7 KiB
Plaintext

/*
This file is for jamming single-line procs into Polaris procs.
It will prevent runtimes and allow their code to run if VOREStation's fails.
It will also log when we mess up our code rather than making it vague.
Call it at the top of a stock proc with...
if(attempt_vr(object,proc to call,args)) return
...if you are replacing an entire proc.
The proc you're attemping should return nonzero values on success.
*/
/proc/attempt_vr(callon, procname, list/args=null)
try
if(!callon || !procname)
// error("attempt_vr: Invalid obj/proc: [callon]/[procname]")
return 0
var/result = call(callon,procname)(arglist(args))
return result
catch
log_admin("attempt_vr runtimed when calling [procname] on [callon].")
// error("attempt_vr catch: [e] on [e.file]:[e.line]")
// return 0
/*
This is the _vr version of calling hooks.
It's meant to have different messages, and also the try/catch block.
For when you want hooks and want to know when you ruin everything,
vs when Polaris ruins everything.
Call it at the top of a stock proc with...
if(hook_vr(proc,args)) return
...if you are replacing an entire proc.
The hooks you're calling should return nonzero values on success.
*/
/proc/hook_vr(hook, list/args=null)
try
var/hook_path = text2path("/hook/[hook]")
if(!hook_path)
// error("hook_vr: Invalid hook '/hook/[hook]' called.")
return 0
var/caller = new hook_path
var/status = 1
for(var/P in typesof("[hook_path]/proc"))
if(!call(caller, P)(arglist(args)))
// error("hook_vr: Hook '[P]' failed or runtimed.")
status = 0
return status
catch
log_admin("hook_vr itself failed or runtimed. Exception below.")
// error("hook_vr catch: [e] on [e.file]:[e.line]")