diff options
| author | 2025-12-30 20:29:48 +0000 | |
|---|---|---|
| committer | 2026-04-04 01:37:54 +0100 | |
| commit | 0fdf9b3ed716a8baf048e7e302c4d9e727999df2 (patch) | |
| tree | 675114ca44ca4209dc60b69f3b3e86a76e6aaa66 | |
| parent | 7d49288bff1fa4e5bacc0eb69ed46c69db622b76 (diff) | |
| download | sst-0fdf9b3ed716a8baf048e7e302c4d9e727999df2.tar.gz sst-0fdf9b3ed716a8baf048e7e302c4d9e727999df2.zip | |
Size-optimise a little more, and tweak minor stuff
This isn't really making a difference right now but maybe it will in
future builds with different section padding or LTO optimiser
interactions or whatever.
| -rw-r--r-- | src/build/gluegen.c | 2 | ||||
| -rw-r--r-- | src/con_.c | 10 | ||||
| -rw-r--r-- | src/fixes.c | 6 | ||||
| -rw-r--r-- | src/inputhud.c | 20 | ||||
| -rw-r--r-- | src/sst.c | 10 | ||||
| -rw-r--r-- | src/trace.c | 4 |
6 files changed, 22 insertions, 30 deletions
diff --git a/src/build/gluegen.c b/src/build/gluegen.c index b0649ca..9c64eeb 100644 --- a/src/build/gluegen.c +++ b/src/build/gluegen.c @@ -739,7 +739,7 @@ F( "extern struct con_var *%.*s;", cvar_names[i].len, cvar_names[i].s); F( "extern struct con_cmd *%.*s;", ccmd_names[i].len, ccmd_names[i].s); } _( "") -_( "static inline void preinitfeatures() {") +_( "static inline opt_small void preinitfeatures() {") for (int i = 1; i < nmods; ++i) { if (mod_flags[i] & HAS_PREINIT) { F( " feats.preinit_%.*s = _feat_preinit_%.*s();", @@ -490,18 +490,16 @@ static bool find_Con_ColorPrintf() { } #endif -static void helpuserhelpus(int pluginver, char ifaceverchar) { +// note: for now at least, not using errmsg_*() macros here because it doesn't +// really make sense for these messages to be coming from "con" +static cold void helpuserhelpus(int pluginver, char ifaceverchar) { con_msg("\n"); con_msg("-- Please include ALL of the following if asking for help:\n"); con_msg("-- plugin: " LONGNAME " v" VERSION "\n"); con_msg("-- interfaces: %d/%c\n", pluginver, ifaceverchar); con_msg("\n"); } - -// note: for now at least, not using errmsg_*() macros here because it doesn't -// really make sense for these messages to be coming from "con" - -static void badver() { +static inline void badver() { con_warn("sst: error: this engine version is not yet supported\n"); } diff --git a/src/fixes.c b/src/fixes.c index b7e3bcd..e5b31b2 100644 --- a/src/fixes.c +++ b/src/fixes.c @@ -28,11 +28,9 @@ #include "ppmagic.h" #include "sst.h" -static inline void chflags(const char *name, int unset, int unset_ne, int set) { +static void chflags(const char *name, int unset, int unset_ne, int set) { struct con_var *v = con_findvar(name); - if_hot (!GAMETYPE_MATCHES(OE)) { - unset |= unset_ne; - } + if_hot (!GAMETYPE_MATCHES(OE)) unset |= unset_ne; if (v) { struct con_var *p = con_getvarcommon(v)->parent; p->base.flags = p->base.flags & ~unset | set; diff --git a/src/inputhud.c b/src/inputhud.c index fe19afc..f40126f 100644 --- a/src/inputhud.c +++ b/src/inputhud.c @@ -164,10 +164,7 @@ static inline int bsf(uint x) { } // IMPORTANT: these things must all match the button order in engineapi.h -static const struct { - hud_wchar len; - hud_wchar s[6]; -} text[] = { // 7 * 20 = 140B +static const struct { hud_wchar len, s[6]; } text[] = { // 2 * 7 * 20 = 280B /* IN_ATTACK */ {3, L"Pri"}, /* IN_JUMP */ {4, L"Jump"}, /* IN_DUCK */ {4, L"Duck"}, @@ -191,14 +188,14 @@ static const struct { // ignoring the rest }; -struct layout_header { +struct layout_header { // 4B // current IN_* things go up to 25 bits (1 << 24) however we don't use // anything past IN_ZOOM here (1 << 19) u32 mask : 24; // our max width is currently 15; max height is 7 but allow some room here u32 w : 4, h : 4; }; -struct layout_btn { u8 x : 4, y : 4; }; +struct layout_btn { u8 x : 4, y : 4; }; // 1B struct layout { struct layout_header hdr; struct layout_btn btns[]; @@ -216,7 +213,7 @@ struct layout { // XXX: just manually sizing these unions for flexible arrays right now. // not ideal, but simple enough... I guess. -static const LAYOUT_FLEX(20) layout_hl2 = { +static const LAYOUT_FLEX(20) layout_hl2 = { // 24B IN_ATTACK | IN_JUMP | IN_DUCK | IN_FORWARD | IN_BACK | IN_USE | IN_MOVELEFT | IN_MOVERIGHT | IN_ATTACK2 | IN_RELOAD | IN_SPEED | IN_WALK | IN_ZOOM, @@ -242,7 +239,7 @@ static const LAYOUT_FLEX(20) layout_hl2 = { } }; -static const LAYOUT_FLEX(12) layout_portal1 = { +static const LAYOUT_FLEX(12) layout_portal1 = { // 16B IN_ATTACK | IN_JUMP | IN_DUCK | IN_FORWARD | IN_BACK | IN_USE | IN_MOVELEFT | IN_MOVERIGHT | IN_ATTACK2, 11, 7, @@ -264,7 +261,7 @@ static const LAYOUT_FLEX(12) layout_portal1 = { }; // TODO(compat): add portal2 layout once there's hud gamedata for portal 2 -//static const LAYOUT_FLEX(20) layout_portal2 = { +//static const LAYOUT_FLEX(20) layout_portal2 = { // 24B // IN_ATTACK | IN_JUMP | IN_DUCK | IN_FORWARD | IN_BACK | IN_USE | // IN_MOVELEFT | IN_MOVERIGHT | IN_ATTACK2 | IN_ZOOM, // 11, 7, @@ -289,7 +286,7 @@ static const LAYOUT_FLEX(12) layout_portal1 = { // } //}; -static const LAYOUT_FLEX(20) layout_l4d = { +static const LAYOUT_FLEX(20) layout_l4d = { // 24B IN_ATTACK | IN_JUMP | IN_DUCK | IN_FORWARD | IN_BACK | IN_USE | IN_MOVELEFT | IN_MOVERIGHT | IN_ATTACK2 | IN_RELOAD | IN_SPEED | IN_ZOOM, 13, 7, @@ -328,10 +325,9 @@ static const char *const fontnames[] = { }; static struct { ulong h; int sz; } fonts[countof(fontnames)]; - static int lastw = 0, lasth = 0; -static void reloadfonts() { +static cold void reloadfonts() { for (int i = 0; i < countof(fontnames); ++i) { if (fonts[i].h = hud_getfont(fontnames[i], true)) { int dummy; @@ -466,7 +466,7 @@ enum unload_action { UNLOAD_SELF, UNLOAD_OTHER }; -static int hook_plugin_unload_common(int argc, const char **argv) { +static opt_small int hook_plugin_unload_common(int argc, const char **argv) { if (argc > 1) { if (!CHECK_AllowPluginLoading(false)) return UNLOAD_SKIP; if (!*argv[1]) { @@ -513,7 +513,7 @@ static int hook_plugin_unload_common(int argc, const char **argv) { return UNLOAD_OTHER; } -static void hook_plugin_unload_cbv1() { +static opt_small void hook_plugin_unload_cbv1() { extern int *_con_argc; extern const char **_con_argv; int action = hook_plugin_unload_common(*_con_argc, _con_argv); @@ -527,7 +527,7 @@ static void hook_plugin_unload_cbv1() { EMIT_PluginUnloaded(); } } -static void hook_plugin_unload_cbv2(struct con_cmdargs *args) { +static opt_small void hook_plugin_unload_cbv2(struct con_cmdargs *args) { int action = hook_plugin_unload_common(args->argc, args->argv); switch_exhaust_enum(unload_action, action) { case UNLOAD_SKIP: @@ -540,7 +540,7 @@ static void hook_plugin_unload_cbv2(struct con_cmdargs *args) { } } -static bool do_load(ifacefactory enginef, ifacefactory serverf) { +static inline bool do_load(ifacefactory enginef, ifacefactory serverf) { factory_engine = enginef; factory_server = serverf; if_cold (!engineapi_init(ifacever)) return false; if (GAMETYPE_MATCHES(OE)) shuntvars(); // see also comment in con_detect() @@ -574,7 +574,7 @@ static bool do_load(ifacefactory enginef, ifacefactory serverf) { return true; } -static void do_unload() { +static inline void do_unload() { // slow path: reloading shouldn't happen all the time, prioritise fast exit if_cold (sst_userunloaded) { // note: if we're here, pluginhandler is set unhook_plugin_load_cb(cmd_plugin_load); diff --git a/src/trace.c b/src/trace.c index 1118bdf..d5a191f 100644 --- a/src/trace.c +++ b/src/trace.c @@ -29,10 +29,10 @@ GAMESPECIFIC(L4D) struct ray { // these have type VectorAligned in the engine, which occupies 16 bytes - struct vec3f _Alignas(16) start, delta, startoff, extents; + alignas(16) struct vec3f start, delta, startoff, extents; // align to 16 since "extents" is supposed to occupy 16 bytes. // TODO(compat): this member isn't in every engine branch - const float _Alignas(16) (*worldaxistransform)[3][4]; + alignas(16) const float (*worldaxistransform)[3][4]; bool isray, isswept; }; |
