mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 22:19:30 +01:00
Adds NAMEOF, VARSET_CALLBACK, and VARSET_LIST_CALLBACK (#33543)
* Adds NAMEOF and VARSET_CALLBACK * Fix VARSET_CALLBACK * Change names, add VARSET_LIST_CALLBACK * Fix var names * Additional macro safety. Update commen * ImprovedName * Fixing
This commit is contained in:
committed by
duncathan salt
parent
fc9b7eca53
commit
00c332a7be
@@ -1525,3 +1525,20 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
|
||||
for(var/V in GLOB.player_list)
|
||||
if(is_servant_of_ratvar(V) || isobserver(V))
|
||||
. += V
|
||||
|
||||
//datum may be null, but it does need to be a typed var
|
||||
#define NAMEOF(datum, X) (list(##datum.##X, #X)[2])
|
||||
|
||||
#define VARSET_LIST_CALLBACK(target, var_name, var_value) CALLBACK(GLOBAL_PROC, /proc/___callbackvarset, ##target, ##var_name, ##var_value)
|
||||
//dupe code because dm can't handle 3 level deep macros
|
||||
#define VARSET_CALLBACK(datum, var, var_value) CALLBACK(GLOBAL_PROC, /proc/___callbackvarset, ##datum, NAMEOF(##datum, ##var), ##var_value)
|
||||
|
||||
/proc/___callbackvarset(list_or_datum, var_name, var_value)
|
||||
if(length(list_or_datum))
|
||||
list_or_datum[var_name] = var_value
|
||||
return
|
||||
var/datum/D = list_or_datum
|
||||
if(IsAdminAdvancedProcCall())
|
||||
D.vv_edit_var(var_name, var_value) //same result generally, unless badmemes
|
||||
else
|
||||
D.vars[var_name] = var_value
|
||||
|
||||
Reference in New Issue
Block a user