summaryrefslogtreecommitdiffhomepage
path: root/src/alias.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-07-31 16:02:10 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-08-10 22:40:52 +0100
commit5e921bf59373d79d27c322ff86e8b5a37b151e45 (patch)
tree4d40e39543b085ce4c8cb9b1a7b3c0108de680c0 /src/alias.c
parentc8d7588251fd4fe63ac6afe2a90ca7066c786609 (diff)
Add magical feature codegen system, at long last
Diffstat (limited to 'src/alias.c')
-rw-r--r--src/alias.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/alias.c b/src/alias.c
index 3605800..b94a6d5 100644
--- a/src/alias.c
+++ b/src/alias.c
@@ -19,16 +19,27 @@
#include "alias.h"
#include "con_.h"
-#include "dbg.h"
#include "errmsg.h"
#include "extmalloc.h"
+#include "feature.h"
#include "gametype.h"
#include "mem.h"
#include "x86.h"
#include "x86util.h"
+FEATURE("alias management")
+
struct alias **_alias_head;
+void alias_nuke(void) {
+ for (struct alias *p = alias_head; p;) {
+ struct alias *next = p->next;
+ extfree(p->value); extfree(p);
+ p = next;
+ }
+ alias_head = 0;
+}
+
void alias_rm(const char *name) {
for (struct alias **p = _alias_head; *p; p = &(*p)->next) {
if (!strcmp((*p)->name, name)) {
@@ -40,7 +51,15 @@ void alias_rm(const char *name) {
}
}
-DEF_CCMD_HERE(sst_alias_remove, "Remove a command alias", 0) {
+DEF_CCMD_HERE_UNREG(sst_alias_clear, "Remove all command aliases", 0) {
+ if (cmd->argc != 1) {
+ con_warn("usage: sst_alias_clear");
+ return;
+ }
+ alias_nuke();
+}
+
+DEF_CCMD_HERE_UNREG(sst_alias_remove, "Remove a command alias", 0) {
if (cmd->argc != 2) {
con_warn("usage: sst_alias_remove name");
return;
@@ -52,23 +71,6 @@ DEF_CCMD_HERE(sst_alias_remove, "Remove a command alias", 0) {
alias_rm(cmd->argv[1]);
}
-void alias_nuke(void) {
- for (struct alias *p = alias_head; p;) {
- struct alias *next = p->next;
- extfree(p->value); extfree(p);
- p = next;
- }
- alias_head = 0;
-}
-
-DEF_CCMD_HERE(sst_alias_clear, "Remove all command aliases", 0) {
- if (cmd->argc != 1) {
- con_warn("usage: sst_alias_clear");
- return;
- }
- alias_nuke();
-}
-
static bool find_alias_head(con_cmdcb alias_cb) {
#ifdef _WIN32
for (uchar *p = (uchar *)alias_cb; p - (uchar *)alias_cb < 64;) {
@@ -88,7 +90,7 @@ static bool find_alias_head(con_cmdcb alias_cb) {
return false;
}
-bool alias_init(void) {
+INIT {
// TODO(compat): no idea why sst_alias_clear crashes in p2, figure out later
if (GAMETYPE_MATCHES(Portal2)) return false;
@@ -101,6 +103,8 @@ bool alias_init(void) {
errmsg_warnx("couldn't find alias list");
return false;
};
+ con_reg(sst_alias_clear);
+ con_reg(sst_alias_remove);
return true;
}