diff options
Diffstat (limited to 'src/sst.c')
-rw-r--r-- | src/sst.c | 38 |
1 files changed, 30 insertions, 8 deletions
@@ -1,5 +1,5 @@ /* - * 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 @@ -28,6 +28,8 @@ #include "engineapi.h" #include "errmsg.h" #include "event.h" +#include "extmalloc.h" // for freevars() in generated code +#include "feature.h" #include "fixes.h" #include "gamedata.h" #include "gameinfo.h" @@ -239,7 +241,7 @@ DEF_CCMD_HERE(sst_printversion, "Display plugin version information", 0) { // cvar to the top of the demo. this will be removed later, once there's a less // stupid way of achieving the same goal. #if VERSION_MAJOR != 0 || VERSION_MINOR != 9 -#error Need to change this manually, since codegen requires it to be spelled \ +#error Need to change this manually, since gluegen requires it to be spelled \ out in DEF_CVAR - better yet, can we get rid of this yet? #endif DEF_CVAR(__sst_0_9_beta, "", 0, CON_HIDDEN | CON_DEMO) @@ -271,7 +273,28 @@ static const char *updatenotes = "\ * More behind-the-scenes changes, as always\n\ "; -#include <featureinit.gen.h> // generated by build/codegen.c +enum { // used in generated code, must line up with + REQFAIL = _FEAT_INTERNAL_STATUSES, + NOGD, + NOGLOBAL +}; +static const char *const featmsgs[] = { // " + " [ OK! ] %s\n", + " [ FAILED! ] %s (error in initialisation)\n", + " [ unsupported ] %s (incompatible with this game or engine)\n", + " [ skipped ] %s (requires another feature)\n", + " [ unsupported ] %s (missing required gamedata entry)\n", + " [ FAILED! ] %s (failed to access engine)\n" +}; + +static inline void successbanner(void) { // called by generated code + con_colourmsg(&(struct rgba){64, 255, 64, 255}, + LONGNAME " v" VERSION " successfully loaded"); + con_colourmsg(&(struct rgba){255, 255, 255, 255}, " for game "); + con_colourmsg(&(struct rgba){0, 255, 255, 255}, "%s\n", gameinfo_title); +} + +#include <glue.gen.h> // generated by build/gluegen.c static void do_featureinit(void) { engineapi_lateinit(); @@ -297,7 +320,7 @@ static void do_featureinit(void) { "InputSystemVersion001", 0))) { errmsg_warnx("missing input system interface"); } - // ... and now for the real magic! + // ... and now for the real magic! (n.b. this also registers feature cvars) initfeatures(); // if we're autoloaded and the external autoupdate script downloaded a new @@ -374,7 +397,7 @@ static con_cmdcb orig_plugin_load_cb, orig_plugin_unload_cb; static int ownidx; // XXX: super hacky way of getting this to do_unload() static bool ispluginv1(const struct CPlugin *plugin) { - // basename string is set with strncmp(), so if there's null bytes with more + // basename string is set with strncpy(), so if there's null bytes with more // stuff after, we can't be looking at a v2 struct. and we expect null bytes // in ifacever, since it's a small int value return (plugin->v2.basename[0] == 0 || plugin->v2.basename[0] == 1) && @@ -437,6 +460,7 @@ static bool do_load(ifacefactory enginef, ifacefactory serverf) { *p++ = (void *)&nop_ipipp_v; // OnQueryCvarValueFinished (002+) *p++ = (void *)&nop_p_v; // OnEdictAllocated *p = (void *)&nop_p_v; // OnEdictFreed + preinitfeatures(); if (!deferinit()) { do_featureinit(); fixes_apply(); } if_hot (pluginhandler) { cmd_plugin_load = con_findcmd("plugin_load"); @@ -468,6 +492,7 @@ static void do_unload(void) { } endfeatures(); con_disconnect(); + freevars(); } static bool VCALLCONV Load(void *this, ifacefactory enginef, @@ -547,7 +572,4 @@ export const void *CreateInterface(const char *name, int *ret) { return 0; } -// no better place to put this lol -#include <evglue.gen.h> // generated by src/build/codegen.c - // vi: sw=4 ts=4 noet tw=80 cc=80 |