aboutsummaryrefslogtreecommitdiff
path: root/src/con_.c
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-03-10 02:37:19 +0000
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-06 16:41:13 +0100
commit244fea664121acf12871ab5858a5fe95a2606b52 (patch)
treee42b1990ef97adc0f0ab48b9be7e11de7fee0558 /src/con_.c
parentd86b7b41453c69b3854baa7cdc05a79a3cdfe092 (diff)
downloadsst-244fea664121acf12871ab5858a5fe95a2606b52.tar.gz
sst-244fea664121acf12871ab5858a5fe95a2606b52.zip
Rewrite and redesign codegen and feature system
Also switch to somewhat proper C23 flags while we're at it. This is a huge change. It took me forever, in between being really busy. Sorry about that. But the good news is I'm now free to start integrating the various patches that have accumulated since last release. Well, at least in between still being really busy. Gotta manage expectations. The main benefit of introducing GAMESPECIFIC() is that features that don't apply to a particular game no longer show up *at all*, and less time is wasted on init. It also enables a cool optimisation wherein unnecessary REQUIRE_GAMEDATA() checks can elided at compile time whenever the gamedata is known up-front to always exist in supported games. The DEF_FEAT_CVAR macro family meanwhile makes it easier to manage the lifecycle of cvars/ccmds, with less manual registering, unhiding and such. Originally I was going to try and just hack these features into the existing codegen abomination, but it just got too terrible. This rewrite should make it easier to continue tweaking codegen behaviour in future. It also has slightly better error messages.
Diffstat (limited to 'src/con_.c')
-rw-r--r--src/con_.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/con_.c b/src/con_.c
index 6fc8857..1f306b8 100644
--- a/src/con_.c
+++ b/src/con_.c
@@ -1,6 +1,6 @@
/* THIS FILE SHOULD BE CALLED `con.c` BUT WINDOWS IS STUPID */
/*
- * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2025 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -69,8 +69,6 @@ static inline void initval(struct con_var *v) {
memcpy(v->strval, v->defaultval, v->strlen);
}
-#include <cmdinit.gen.h> // generated by build/codegen.c
-
// to try and match the engine even though it's probably not strictly required,
// we call the Internal* virtual functions via the actual vtable. since vtables
// are built dynamically (below), we store this index; other indices are just
@@ -303,8 +301,13 @@ struct _con_vtab_iconvar_wrap _con_vtab_iconvar_wrap = {
#endif
};
-void con_reg(void *cmd_or_var) {
- RegisterConCommand(_con_iface, cmd_or_var);
+void con_regvar(struct con_var *v) {
+ initval(v);
+ RegisterConCommand(_con_iface, v);
+}
+
+void con_regcmd(struct con_cmd *c) {
+ RegisterConCommand(_con_iface, c);
}
// XXX: these should use vcall/gamedata stuff as they're only used for the
@@ -384,8 +387,6 @@ void con_init(void) {
*pi++ = (void *)&IsFlagSet_thunk;
// last one: not in 004, but doesn't matter. one less branch!
*pi++ = (void *)&GetSplitScreenPlayerSlot;
-
- regcmds();
}
static void helpuserhelpus(int pluginver, char ifaceverchar) {
@@ -460,7 +461,6 @@ bool con_detect(int pluginver) {
void con_disconnect(void) {
UnregisterConCommands(_con_iface, dllid);
- freevars();
}
struct con_var *con_findvar(const char *name) {