http://www.byond.com/forum/post/2472559
To summarize my old thoughts and the new idea I've come to ask opinions on, I essentially want to find a standard that best balances efficiency and code readability when it comes to players disconnecting from the game while doing something (such as conversing with NPCs, doing battle, etc). A lot of the events in question will frequently stop and wait for user input -- naturally, if the user has logged out when they are presented with input, that needs to be handled. The existing tedious method I've been using is to simply spam null reference checks with the basic
if(!usr)
return
This is creating its own issue of practically doubling or tripling the lengths of certain procs, as they end up looking something like
FetchUserInput(arg, arg)
if(!usr)
return
FetchUserInput(arg, arg)
if(!usr)
return
FetchUserInput(arg, arg)
if(!usr)
return
...
Before I continue to pump out objs and turfs that are cluttered with these null reference checks, I'd like to find a better way to handle this. Now, this is where I've had a new idea I like the best.
Most of the objs and turfs belong to overarching structured groups. Rather than doing try/catch blocks for every single obj/turf, would it be possible to implement something following this generic pseudocode?
obj/Dungeon/proc
GeneralInspect()
try
Inspect()
catch
// handle it, because they're all similar
This way, instead of having every obj that is a derivative of the Dungeon class include its own try/catch blocks in every single Inspect(), would it be possible to rather somehow call the parent's (parent's parent's parent's ...) GeneralInspect() so that I can have just the one overarching try/catch? Or is this particular configuration impossible -- if that is the case, is there an alternative to what I am attempting to perform? Thanks in advance.