-
-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathverbs.dm
More file actions
61 lines (57 loc) · 2.62 KB
/
verbs.dm
File metadata and controls
61 lines (57 loc) · 2.62 KB
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
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//
/**
* Declares an admin verb.
*
* * Verbs declared in this way will have the calling client as `client/invoker`. Do not define your
* own client / usr calls.
* * You may safely assume that the verb is only accessible by them if they have the right permissions.
* * Set `CATEGORY` to null to not have it show up in verb panel.
*/
#define ADMIN_VERB_DEF(PATH_SUFFIX, REQUIRED_RIGHTS, NAME, DESC, CATEGORY, HEADER...) \
_ADMIN_VERB_DEF_INTERNAL(PATH_SUFFIX, REQUIRED_RIGHTS, NAME, DESC, CATEGORY, TRUE, ##HEADER)
/**
* Declares an admin verb that does not show up in the popup menu.
*
* * Verbs declared in this way will have the calling client as `client/invoker`. Do not define your
* own client / usr calls.
* * You may safely assume that the verb is only accessible by them if they have the right permissions.
* * Set `CATEGORY` to null to not have it show up in verb panel.
*/
#define ADMIN_VERB_DEF_PANEL_ONLY(PATH_SUFFIX, REQUIRED_RIGHTS, NAME, DESC, CATEGORY, HEADER...) \
_ADMIN_VERB_DEF_INTERNAL(PATH_SUFFIX, REQUIRED_RIGHTS, NAME, DESC, CATEGORY, FALSE, ##HEADER)
/**
* Do not use.
*/
#define _ADMIN_VERB_DEF_INTERNAL(PATH_SUFFIX, REQUIRED_RIGHTS, NAME, DESC, CATEGORY, POPUP_MENU, HEADER...) \
/datum/admin_verb_descriptor/##PATH_SUFFIX { \
id = #PATH_SUFFIX; \
required_rights = ##REQUIRED_RIGHTS; \
verb_path = /datum/admin_verb_abstraction/proc/verb__##PATH_SUFFIX; \
reflection_path = /datum/admin_verb_abstraction/proc/verb__invoke_##PATH_SUFFIX; \
}; \
/datum/admin_verb_abstraction/proc/verb__##PATH_SUFFIX(##HEADER) { \
set name = ##NAME; \
set desc = ##DESC; \
set hidden = FALSE; \
set popup_menu = ##POPUP_MENU; \
set category = ##CATEGORY; \
if(!((usr?.client?.holder?.rights & ##REQUIRED_RIGHTS) == ##REQUIRED_RIGHTS)) {\
CRASH("attempted invocation with insufficient rights."); \
}; \
do { \
metric_increment_nested_numerical(/datum/metric/nested_numerical/admin_verb_invocation, #PATH_SUFFIX, 1); \
log_admin("[key_name(usr)] invoked admin verb '[#PATH_SUFFIX]'"); \
} \
while(FALSE); \
call(usr.client, /datum/admin_verb_abstraction::verb__invoke_##PATH_SUFFIX())(arglist(list(usr.client) + args)); \
}; \
/datum/admin_verb_abstraction/proc/verb__invoke_##PATH_SUFFIX(client/user, ##HEADER)
/**
* Abstract datum with no variables. Used to hold the proc definitions for admin verbs.
*
* * The way this works is black magic, so, uh, no touchy I guess.
*/
VV_PROTECT_READONLY(/datum/admin_verb_abstraction)
/datum/admin_verb_abstraction
abstract_type = /datum/admin_verb_abstraction