-
Notifications
You must be signed in to change notification settings - Fork 1
/
_globals.dm
85 lines (65 loc) · 3.1 KB
/
_globals.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//See also controllers/globals.dm
/// Creates a global initializer with a given InitValue expression, do not use
#define GLOBAL_MANAGED(X, InitValue)\
/datum/controller/global_vars/proc/InitGlobal##X(){\
##X = ##InitValue;\
gvars_datum_init_order += #X;\
}
/// Creates an empty global initializer, do not use
#define GLOBAL_UNMANAGED(X) /datum/controller/global_vars/proc/InitGlobal##X() { return; }
/// Creates name keyed subtype instance list
#define GLOBAL_SUBTYPE_INDEXED(X, TypePath, Index)\
/datum/controller/global_vars/proc/InitGlobal##X(){\
##X = list();\
for(var/t in subtypesof(TypePath)){\
var##TypePath/A = new t;\
##X[A.##Index] = A;\
}\
gvars_datum_init_order += #X;\
}
/// Prevents a given global from being VV'd
#ifndef TESTING
#define GLOBAL_PROTECT(X)\
/datum/controller/global_vars/InitGlobal##X(){\
..();\
gvars_datum_protected_varlist[#X] = TRUE;\
}
#else
#define GLOBAL_PROTECT(X)
#endif
#define GLOBAL_SORTED(X)\
/datum/controller/global_vars/InitGlobal##X(){\
..();\
##X = sortAssoc(##X);\
}
/// Standard BYOND global, do not use
#define GLOBAL_REAL_VAR(X) var/global/##X
/// Standard typed BYOND global, do not use
#define GLOBAL_REAL(X, Typepath) var/global##Typepath/##X
/// Defines a global var on the controller, do not use
#define GLOBAL_RAW(X) /datum/controller/global_vars/var/global##X
/// Create an untyped global with an initializer expression
#define GLOBAL_VAR_INIT(X, InitValue) GLOBAL_RAW(/##X); GLOBAL_MANAGED(X, InitValue)
/// Create a global const var, do not use
#define GLOBAL_VAR_CONST(X, InitValue) GLOBAL_RAW(/const/##X) = InitValue; GLOBAL_UNMANAGED(X)
/// Create a list global with an initializer expression
#define GLOBAL_LIST_INIT(X, InitValue) GLOBAL_RAW(/list/##X); GLOBAL_MANAGED(X, InitValue)
/// Create a list global that is initialized as an empty list
#define GLOBAL_LIST_EMPTY(X) GLOBAL_LIST_INIT(X, list())
/// Create a typed list global with an initializer expression
#define GLOBAL_LIST_INIT_TYPED(X, Typepath, InitValue) GLOBAL_RAW(/list##Typepath/X); GLOBAL_MANAGED(X, InitValue)
/// Create a typed list global that is initialized as an empty list
#define GLOBAL_LIST_EMPTY_TYPED(X, Typepath) GLOBAL_LIST_INIT_TYPED(X, Typepath, list())
/// Create a typed global with an initializer expression
#define GLOBAL_DATUM_INIT(X, Typepath, InitValue) GLOBAL_RAW(Typepath/##X); GLOBAL_MANAGED(X, InitValue)
/// Create an untyped null global
#define GLOBAL_VAR(X) GLOBAL_RAW(/##X); GLOBAL_UNMANAGED(X)
/// Create a null global list
#define GLOBAL_LIST(X) GLOBAL_RAW(/list/##X); GLOBAL_UNMANAGED(X)
/// Create a typed null global
#define GLOBAL_DATUM(X, Typepath) GLOBAL_RAW(Typepath/##X); GLOBAL_UNMANAGED(X)
/// Load a file in as a global list
#define GLOBAL_LIST_FILE_LOAD(X, F) GLOBAL_LIST_INIT(X, file2list(F))
/// Creates datum reference list
#define GLOBAL_REFERENCE_LIST_INDEXED(X, TypePath, Index) GLOBAL_RAW(/list##TypePath/##X); GLOBAL_SUBTYPE_INDEXED(X, TypePath, Index)
#define GLOBAL_REFERENCE_LIST_INDEXED_SORTED(X, TypePath, Index) GLOBAL_RAW(/list##TypePath/##X); GLOBAL_SUBTYPE_INDEXED(X, TypePath, Index); GLOBAL_SORTED(X)