From e4e51f0f80fb7deb9213c72bb374d0a7e4c3f03b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 18:05:51 +0100 Subject: [PATCH 01/25] Blua: implementation of fast track for gettable operations https://github.com/lua/lua/commit/e247c3ada3ff47a1352927e797263137f4e02e0e lets hope i converted this properly lul --- src/blua/lapi.c | 26 ++++++++++++++++++-------- src/blua/lvm.c | 39 ++++++++++++++++++++------------------- src/blua/lvm.h | 27 +++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 29 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 6a33983fe..990e17b6e 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -519,6 +519,23 @@ LUA_API int lua_pushthread (lua_State *L) { ** get functions (Lua -> stack) */ +static void auxgetstr (lua_State *L, TValue *t, const char *k) { + TValue *aux; + TValue key; + TString *str = luaS_new(L, k); + api_checkvalidindex(L, t); + if (luaV_fastget(L, t, str, aux, luaH_getstr)) { + setobj2s(L, L->top, aux); + api_incr_top(L); + } + else { + setsvalue(L, &key, str); + luaV_finishget(L, t, L->top, L->top, aux); + api_incr_top(L); + } + lua_unlock(L); +} + LUA_API void lua_gettable (lua_State *L, int idx) { StkId t; @@ -531,15 +548,8 @@ LUA_API void lua_gettable (lua_State *L, int idx) { LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { - StkId t; - TValue key; lua_lock(L); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - setsvalue(L, &key, luaS_new(L, k)); - luaV_gettable(L, t, &key, L->top); - api_incr_top(L); - lua_unlock(L); + auxgetstr(L, index2adr(L, idx), k); } diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 7afbbd572..64e670d2f 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -105,32 +105,33 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1, } -void luaV_gettable (lua_State *L, TValue *t, TValue *key, StkId val) { - int loop; +/* +** Complete a table access: if 't' is a table, 'tm' has its metamethod; +** otherwise, 'tm' is NULL. +*/ +void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, + TValue *tm) { + int loop; /* counter to avoid infinite loops */ + lua_assert(tm != NULL || !ttistable(t)); for (loop = 0; loop < MAXTAGLOOP; loop++) { - TValue *tm; - if (ttistable(t)) { /* `t' is a table? */ - Table *h = hvalue(t); - const TValue *res = luaH_get(h, key); /* do a primitive get */ - if (!ttisnil(res) || /* result is no nil? */ - (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ - setobj2s(L, val, res); - return; - } - /* else will try the tag method */ + if (tm == NULL) { /* no metamethod (from a table)? */ + if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) + luaG_typeerror(L, t, "index"); /* no metamethod */ } - else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) - luaG_typeerror(L, t, "index"); - if (ttisfunction(tm)) { - callTMres(L, val, tm, t, key); + if (ttisfunction(tm)) { /* metamethod is a function */ + callTMres(L, val, tm, t, key); /* call it */ return; } - t = tm; /* else repeat with `tm' */ + t = tm; /* else repeat access over 'tm' */ + if (luaV_fastget(L,t,key,tm,luaH_get)) { /* try fast track */ + setobj2s(L, val, tm); /* done */ + return; + } + /* else repeat */ } - luaG_runerror(L, "loop in gettable"); + luaG_runerror(L, "gettable chain too long; possible loop"); } - void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { int loop; for (loop = 0; loop < MAXTAGLOOP; loop++) { diff --git a/src/blua/lvm.h b/src/blua/lvm.h index f9226ee5d..2ffc80ace 100644 --- a/src/blua/lvm.h +++ b/src/blua/lvm.h @@ -22,12 +22,35 @@ (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) +/* +** fast track for 'gettable': 1 means 'aux' points to resulted value; +** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is +** the raw get function to use. +*/ +#define luaV_fastget(L,t,k,aux,f) \ + (!ttistable(t) \ + ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \ + : (aux = f(hvalue(t), k), /* else, do raw access */ \ + !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \ + : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\ + aux != NULL ? 0 /* has metamethod? must call it */ \ + : (aux = luaO_nilobject, 1)))) /* else, final result is nil */ + +/* +** standard implementation for 'gettable' +*/ +#define luaV_gettable(L,t,k,v) { TValue *aux; \ + if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ + else luaV_finishget(L,t,k,v,aux); } + + + LUAI_FUNC int luaV_lessthan (lua_State *L, TValue *l, TValue *r); LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); -LUAI_FUNC void luaV_gettable (lua_State *L, TValue *t, TValue *key, - StkId val); +LUAI_FUNC void luaV_finishget (lua_State *L, TValue *t, TValue *key, + StkId val, TValue *tm); LUAI_FUNC void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val); LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); From 84be9096b134e1f8d17b5f444ee4c516943f4beb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:00:29 +0100 Subject: [PATCH 02/25] Blua: fast track for 'settable' https://github.com/lua/lua/commit/3b795541c488c7e633567897c9112312007a20a0 https://github.com/lua/lua/commit/b91bc93fd33f2158745b37c9e091c6fa4d1a4fd5 had to adjust some things, hope this doesent explode lmao --- src/blua/lapi.c | 29 ++++++++++++++++++++--------- src/blua/lvm.c | 36 +++++++++++++++++++++++++----------- src/blua/lvm.h | 30 ++++++++++++++++++++++++++++-- 3 files changed, 73 insertions(+), 22 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 990e17b6e..420e4e20b 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -641,6 +641,25 @@ LUA_API void lua_getfenv (lua_State *L, int idx) { */ +static void auxsetstr (lua_State *L, TValue *t, const char *k) { + TValue key; + TValue *aux; + TString *str = luaS_new(L, k); + api_checknelems(L, 1); + api_checkvalidindex(L, t); + if (luaV_fastset(L, t, str, aux, luaH_setstr, L->top)) { + setobj2t(L, cast(TValue *, aux), L->top - 1); + L->top--; /* pop value */ + } + else { + setsvalue2s(L, &key, str); + luaV_finishset(L, t, &key, L->top - 1, aux); + L->top--; /* pop value */ + } + lua_unlock(L); +} + + LUA_API void lua_settable (lua_State *L, int idx) { StkId t; lua_lock(L); @@ -654,16 +673,8 @@ LUA_API void lua_settable (lua_State *L, int idx) { LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { - StkId t; - TValue key; lua_lock(L); - api_checknelems(L, 1); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - setsvalue(L, &key, luaS_new(L, k)); - luaV_settable(L, t, &key, L->top - 1); - L->top--; /* pop value */ - lua_unlock(L); + auxsetstr(L, index2adr(L, idx), k); } diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 64e670d2f..484329825 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -132,31 +132,45 @@ void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, luaG_runerror(L, "gettable chain too long; possible loop"); } -void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { - int loop; + +/* +** Main function for table assignment (invoking metamethods if needed). +** Compute 't[key] = val' +*/ +void luaV_finishset (lua_State *L, TValue *t, TValue *key, + StkId val, TValue *oldval) { + int loop; /* counter to avoid infinite loops */ for (loop = 0; loop < MAXTAGLOOP; loop++) { - TValue *tm = NULL; - if (ttistable(t)) { /* `t' is a table? */ + TValue *tm; + if (oldval != NULL) { + lua_assert(ttistable(t) && ttisnil(oldval)); Table *h = hvalue(t); - TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ + /* must check the metamethod */ /* oldval is nil=> look for newindex, oldval is not nil => look for usedindex */ if (!((ttisnil(oldval) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) || ((!ttisnil(oldval)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) { - setobj2t(L, oldval, val); + /* no metamethod and (now) there is an entry with given key */ + setobj2t(L, cast(TValue *, oldval), val); luaC_barriert(L, h, val); return; } - /* else will try the tag method */ + /* else will try the metamethod */ } - else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))) - luaG_typeerror(L, t, "index"); + else { /* not a table; check metamethod */ + if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))) + luaG_typeerror(L, t, "index"); + } + /* try the metamethod */ if (ttisfunction(tm)) { callTM(L, tm, t, key, val); return; } - t = tm; /* else repeat with `tm' */ + t = tm; /* else repeat assignment over 'tm' */ + if (luaV_fastset(L, t, key, oldval, luaH_set, val)) + return; /* done */ + /* else loop */ } - luaG_runerror(L, "loop in settable"); + luaG_runerror(L, "settable chain too long; possible loop"); } diff --git a/src/blua/lvm.h b/src/blua/lvm.h index 2ffc80ace..2f65098f0 100644 --- a/src/blua/lvm.h +++ b/src/blua/lvm.h @@ -44,6 +44,32 @@ else luaV_finishget(L,t,k,v,aux); } +/* +** Fast track for set table. If 't' is a table and 't[k]' is not nil, +** call GC barrier, do a raw 't[k]=v', and return true; otherwise, +** return false with 'slot' equal to NULL (if 't' is not a table) or +** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro +** returns true, there is no need to 'invalidateTMcache', because the +** call is not creating a new entry. +*/ +#define luaV_fastset(L,t,k,slot,f,v) \ + (!ttistable(t) \ + ? (slot = NULL, 0) \ + : (slot = f(L, hvalue(t), k), \ + ttisnil(slot) ? 0 \ + : (__extension__ ({ \ + if (valiswhite(v) && isblack(obj2gco(hvalue(t)))) \ + luaC_barrierback(L, hvalue(t)); \ + setobj2t(L, cast(TValue *,slot), v); \ + 1; \ + })))) + + +#define luaV_settable(L,t,k,v) { TValue *slot; \ + if (!luaV_fastset(L,t,k,slot,luaH_set,v)) \ + luaV_finishset(L,t,k,v,slot); } + + LUAI_FUNC int luaV_lessthan (lua_State *L, TValue *l, TValue *r); LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); @@ -51,8 +77,8 @@ LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); LUAI_FUNC void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, TValue *tm); -LUAI_FUNC void luaV_settable (lua_State *L, TValue *t, TValue *key, - StkId val); +LUAI_FUNC void luaV_finishset (lua_State *L, TValue *t, TValue *key, + StkId val, TValue *oldval); LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); From fdccc8026061806cef9c6f5cc2a4d9f752b4d00d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:12:59 +0100 Subject: [PATCH 03/25] Blua: 'Protect' in table operations is not needed in the fast track https://github.com/lua/lua/commit/df8b996bccd3830d6fe9d7ba80e8fccd6ac3cabf --- src/blua/lvm.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 484329825..7540bcdec 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -393,6 +393,21 @@ static void Arith (lua_State *L, StkId ra, TValue *rb, } +/* +** copy of 'luaV_gettable', but protecting call to potential metamethod +** (which can reallocate the stack) +*/ +#define gettableProtected(L,t,k,v) { TValue *aux; \ + if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ + else Protect(luaV_finishget(L,t,k,v,aux)); } + + +/* same for 'luaV_settable' */ +#define settableProtected(L,t,k,v) { TValue *slot; \ + if (!luaV_fastset(L,t,k,slot,luaH_set,v)) \ + Protect(luaV_finishset(L,t,k,v,slot)); } + + void luaV_execute (lua_State *L, int nexeccalls) { LClosure *cl; @@ -402,9 +417,9 @@ void luaV_execute (lua_State *L, int nexeccalls) { reentry: /* entry point */ lua_assert(isLua(L->ci)); pc = L->savedpc; - cl = &clvalue(L->ci->func)->l; - base = L->base; - k = cl->p->k; + cl = &clvalue(L->ci->func)->l; /* local reference to function's closure */ + k = cl->p->k; /* local reference to function's constant table */ + base = L->base; /* local copy of function's base */ /* main loop of interpreter */ for (;;) { const Instruction i = *pc++; @@ -464,7 +479,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { StkId ra = RA(i); StkId rb = RB(i); TValue *rc = RKC(i); - Protect(luaV_gettable(L, rb, rc, ra)); + gettableProtected(L, rb, rc, ra); continue; } case OP_SETGLOBAL: { @@ -486,7 +501,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { StkId ra = RA(i); TValue *rb = RKB(i); TValue *rc = RKC(i); - Protect(luaV_settable(L, ra, rb, rc)); + settableProtected(L, ra, rb, rc); continue; } case OP_NEWTABLE: { @@ -500,8 +515,9 @@ void luaV_execute (lua_State *L, int nexeccalls) { case OP_SELF: { StkId ra = RA(i); StkId rb = RB(i); - setobjs2s(L, ra+1, rb); - Protect(luaV_gettable(L, rb, RKC(i), ra)); + TValue *rc = RKC(i); + setobjs2s(L, ra + 1, rb); + gettableProtected(L, rb, rc, ra); continue; } case OP_ADD: { From c418fe3ef8419e1c626b8f894d93d210e35b94ec Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:21:36 +0100 Subject: [PATCH 04/25] Blua: 'luaV_fastget' only treats the real fast case (table with a non-nil value at given key, so that it does not need to check metamethods) https://github.com/lua/lua/commit/1a44e822009752513ce895b9eabc51a4ee4a195a --- src/blua/lapi.c | 16 ++++++------ src/blua/lvm.c | 66 ++++++++++++++++++++++++++++++------------------- src/blua/lvm.h | 25 +++++++++---------- 3 files changed, 61 insertions(+), 46 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 420e4e20b..bca24a90f 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -520,17 +520,17 @@ LUA_API int lua_pushthread (lua_State *L) { */ static void auxgetstr (lua_State *L, TValue *t, const char *k) { - TValue *aux; + TValue *slot; TValue key; TString *str = luaS_new(L, k); api_checkvalidindex(L, t); - if (luaV_fastget(L, t, str, aux, luaH_getstr)) { - setobj2s(L, L->top, aux); + if (luaV_fastget(L, t, str, slot, luaH_getstr)) { + setobj2s(L, L->top, slot); api_incr_top(L); } else { setsvalue(L, &key, str); - luaV_finishget(L, t, L->top, L->top, aux); + luaV_finishget(L, t, L->top, L->top, slot); api_incr_top(L); } lua_unlock(L); @@ -643,17 +643,17 @@ LUA_API void lua_getfenv (lua_State *L, int idx) { static void auxsetstr (lua_State *L, TValue *t, const char *k) { TValue key; - TValue *aux; + TValue *slot; TString *str = luaS_new(L, k); api_checknelems(L, 1); api_checkvalidindex(L, t); - if (luaV_fastset(L, t, str, aux, luaH_setstr, L->top)) { - setobj2t(L, cast(TValue *, aux), L->top - 1); + if (luaV_fastset(L, t, str, slot, luaH_setstr, L->top)) { + setobj2t(L, cast(TValue *, slot), L->top - 1); L->top--; /* pop value */ } else { setsvalue2s(L, &key, str); - luaV_finishset(L, t, &key, L->top - 1, aux); + luaV_finishset(L, t, &key, L->top - 1, slot); L->top--; /* pop value */ } lua_unlock(L); diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 7540bcdec..9db792fd6 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -106,51 +106,67 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1, /* -** Complete a table access: if 't' is a table, 'tm' has its metamethod; -** otherwise, 'tm' is NULL. +** Finish the table access 'val = t[key]'. +** if 'slot' is NULL, 't' is not a table; otherwise, 'slot' points to +** t[k] entry (which must be nil). */ void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, - TValue *tm) { + TValue *slot) { int loop; /* counter to avoid infinite loops */ - lua_assert(tm != NULL || !ttistable(t)); + TValue *tm; /* metamethod */ for (loop = 0; loop < MAXTAGLOOP; loop++) { - if (tm == NULL) { /* no metamethod (from a table)? */ - if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) + if (slot == NULL) { /* 't' is not a table? */ + lua_assert(!ttistable(t)); + tm = luaT_gettmbyobj(L, t, TM_INDEX); + if (l_unlikely(ttisnil(tm))) luaG_typeerror(L, t, "index"); /* no metamethod */ + /* else will try the metamethod */ } - if (ttisfunction(tm)) { /* metamethod is a function */ + else { /* 't' is a table */ + lua_assert(ttisnil(slot)); + tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */ + if (tm == NULL) { /* no metamethod? */ + setnilvalue(val); /* result is nil */ + return; + } + /* else will try the metamethod */ + } + if (ttisfunction(tm)) { /* is metamethod a function? */ callTMres(L, val, tm, t, key); /* call it */ return; } - t = tm; /* else repeat access over 'tm' */ - if (luaV_fastget(L,t,key,tm,luaH_get)) { /* try fast track */ - setobj2s(L, val, tm); /* done */ + t = tm; /* else try to access 'tm[key]' */ + if (luaV_fastget(L,t,key,slot,luaH_get)) { /* fast track? */ + setobj2s(L, val, slot); /* done */ return; } - /* else repeat */ + /* else repeat (tail call 'luaV_finishget') */ } - luaG_runerror(L, "gettable chain too long; possible loop"); + luaG_runerror(L, "'__index' chain too long; possible loop"); } /* -** Main function for table assignment (invoking metamethods if needed). -** Compute 't[key] = val' +** Finish a table assignment 't[key] = val'. +** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points +** to the entry 't[key]', or to 'luaO_nilobject' if there is no such +** entry. (The value at 'slot' must be nil, otherwise 'luaV_fastset' +** would have done the job.) */ void luaV_finishset (lua_State *L, TValue *t, TValue *key, - StkId val, TValue *oldval) { + StkId val, TValue *slot) { int loop; /* counter to avoid infinite loops */ for (loop = 0; loop < MAXTAGLOOP; loop++) { TValue *tm; - if (oldval != NULL) { - lua_assert(ttistable(t) && ttisnil(oldval)); + if (slot != NULL) { + lua_assert(ttistable(t) && ttisnil(slot)); Table *h = hvalue(t); /* must check the metamethod */ - /* oldval is nil=> look for newindex, oldval is not nil => look for usedindex */ - if (!((ttisnil(oldval) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) || - ((!ttisnil(oldval)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) { + /* slot is nil=> look for newindex, slot is not nil => look for usedindex */ + if (!((ttisnil(slot) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) || + ((!ttisnil(slot)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) { /* no metamethod and (now) there is an entry with given key */ - setobj2t(L, cast(TValue *, oldval), val); + setobj2t(L, cast(TValue *, slot), val); luaC_barriert(L, h, val); return; } @@ -166,7 +182,7 @@ void luaV_finishset (lua_State *L, TValue *t, TValue *key, return; } t = tm; /* else repeat assignment over 'tm' */ - if (luaV_fastset(L, t, key, oldval, luaH_set, val)) + if (luaV_fastset(L, t, key, slot, luaH_set, val)) return; /* done */ /* else loop */ } @@ -397,9 +413,9 @@ static void Arith (lua_State *L, StkId ra, TValue *rb, ** copy of 'luaV_gettable', but protecting call to potential metamethod ** (which can reallocate the stack) */ -#define gettableProtected(L,t,k,v) { TValue *aux; \ - if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ - else Protect(luaV_finishget(L,t,k,v,aux)); } +#define gettableProtected(L,t,k,v) { TValue *slot; \ + if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ + else Protect(luaV_finishget(L,t,k,v,slot)); } /* same for 'luaV_settable' */ diff --git a/src/blua/lvm.h b/src/blua/lvm.h index 2f65098f0..0c4c877f2 100644 --- a/src/blua/lvm.h +++ b/src/blua/lvm.h @@ -23,25 +23,24 @@ /* -** fast track for 'gettable': 1 means 'aux' points to resulted value; -** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is -** the raw get function to use. +** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, +** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise, +** return 0 (meaning it will have to check metamethod) with 'slot' +** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise). +** 'f' is the raw get function to use. */ -#define luaV_fastget(L,t,k,aux,f) \ +#define luaV_fastget(L,t,k,slot,f) \ (!ttistable(t) \ - ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \ - : (aux = f(hvalue(t), k), /* else, do raw access */ \ - !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \ - : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\ - aux != NULL ? 0 /* has metamethod? must call it */ \ - : (aux = luaO_nilobject, 1)))) /* else, final result is nil */ + ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ + : (slot = f(hvalue(t), k), /* else, do raw access */ \ + !ttisnil(slot))) /* result not nil? */ /* ** standard implementation for 'gettable' */ -#define luaV_gettable(L,t,k,v) { TValue *aux; \ - if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ - else luaV_finishget(L,t,k,v,aux); } +#define luaV_gettable(L,t,k,v) { TValue *slot; \ + if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ + else luaV_finishget(L,t,k,v,slot); } /* From 0fb752b7459673d8a3b38c917f9593602b03c4a0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:23:45 +0100 Subject: [PATCH 05/25] Blua: OP_SELF can use 'luaV_fastget' specialized for strings, as it is applied only to string keys https://github.com/lua/lua/commit/257961c601fdec1ea1f9640d460e0d31c39333a1 --- src/blua/lvm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 9db792fd6..4d617d62c 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -529,11 +529,16 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_SELF: { + TValue *slot; StkId ra = RA(i); StkId rb = RB(i); TValue *rc = RKC(i); + TString *key = rawtsvalue(rc); /* key must be a string */ setobjs2s(L, ra + 1, rb); - gettableProtected(L, rb, rc, ra); + if (luaV_fastget(L, rb, key, slot, luaH_getstr)) { + setobj2s(L, ra, slot); + } + else Protect(luaV_finishget(L, rb, rc, ra, slot)); continue; } case OP_ADD: { From 7684e6aa0750744e61cee0a29b948209c140d717 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:28:57 +0100 Subject: [PATCH 06/25] Blua: opcode OP_SELF operate only with string keys, so they can use fast-track table access https://github.com/lua/lua/commit/cb3d5dce30089512085f78a0bef79e30ef732e30 --- src/blua/lcode.c | 12 ++++++++++++ src/blua/lopcodes.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/blua/lcode.c b/src/blua/lcode.c index 567b88500..562ad3506 100644 --- a/src/blua/lcode.c +++ b/src/blua/lcode.c @@ -626,8 +626,20 @@ static void codenot (FuncState *fs, expdesc *e) { removevalues(fs, e->t); } +/* +** Check whether expression 'e' is a literal string +*/ +static int isKstr (FuncState *fs, expdesc *e) { + return (e->k == VK && ttisstring(&fs->f->k[e->u.s.info])); +} +/* +** Create expression 't[k]'. 't' must have its final result already in a +** register or upvalue. Upvalues can only be indexed by literal strings. +*/ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non string? */ + luaK_exp2anyreg(fs, t); /* put it in a register */ t->u.s.aux = luaK_exp2RK(fs, k); t->k = VINDEXED; } diff --git a/src/blua/lopcodes.h b/src/blua/lopcodes.h index 8b08b04e0..aa84da8d0 100644 --- a/src/blua/lopcodes.h +++ b/src/blua/lopcodes.h @@ -232,6 +232,8 @@ OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ (*) In OP_SETLIST, if (B == 0) then B = `top'; if (C == 0) then next `instruction' is real C + (*) In OP_SELF, the index must be a string. + (*) For comparisons, A specifies what condition the test should accept (true or false). From ab209448d19c27dff9433fbedf2bfbf6a6d07b12 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Mar 2026 20:38:21 +0100 Subject: [PATCH 07/25] Introduce GNU constructor and destructor attributes The constructor attribute causes the function to be called automatically before execution enters main (). Similarly, the destructor attribute causes the function to be called automatically after main () has completed or exit () has been called. Functions with these attributes are useful for initializing data that will be used implicitly during the execution of the program. added "used" attribute aswell so compiler does not omit non referenced functions (i hope) gotta test this a bit but seems cool for stuff like verstable maps --- src/doomdef.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/doomdef.h b/src/doomdef.h index 445b6951f..1543e68a9 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -573,6 +573,13 @@ INT32 I_GetKey(void); // NOTE: you WILL have nasal troubles if the variable is not initialized #define CLEANUP(f) __attribute__((__cleanup__(f))) +// the GNU constructor and destructor attributes +// The constructor attribute causes the function to be called automatically before execution enters main (). +// Similarly, the destructor attribute causes the function to be called automatically after main () has completed or exit () has been called. +// Functions with these attributes are useful for initializing data that will be used implicitly during the execution of the program. +#define CONSTRUCTOR __attribute__((constructor, used)) +#define DESTRUCTOR __attribute__((destructor, used)) + // An assert-type mechanism. #ifdef PARANOIA #define I_Assert(e) ((e) ? (void)0 : I_Error("assert failed: %s, file %s, line %d", #e, __FILE__, __LINE__)) From f6a0430a408861d091d5cdfa26bbaa83560b1cc2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Mar 2026 20:39:16 +0100 Subject: [PATCH 08/25] use constructor for W_Startup never liked having this inside i_system --- src/dedicated/i_system.c | 1 - src/sdl/i_system.cpp | 2 -- src/w_wad.c | 5 ++--- src/w_wad.h | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index ddc17d6a5..f6450134c 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1384,7 +1384,6 @@ static void I_Fork(void) INT32 I_StartupSystem(void) { - W_Startup(); I_StartupConsole(); #ifdef NEWSIGNALHANDLER // This is useful when debugging. It lets GDB attach to diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 407e5c3a0..c30e93d90 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1887,8 +1887,6 @@ INT32 I_StartupSystem(void) SDL_VERSION(&SDLcompiled) SDL_GetVersion(&SDLlinked); - W_Startup(); - I_StartupConsole(); #ifdef NEWSIGNALHANDLER // This is useful when debugging. It lets GDB attach to diff --git a/src/w_wad.c b/src/w_wad.c index 2ac8ae68d..8c7494898 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -158,8 +158,7 @@ void W_Shutdown(void) } // the lumpnum cache needs to be initialized before use -// call this as early as possible! -void W_Startup(void) +CONSTRUCTOR static void W_Startup(void) { lumpnum_map_init(&lumpnumcache); lumpnum_map_reserve(&lumpnumcache, LUMPNUMCACHESIZE); @@ -367,7 +366,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock) { precise_t t = I_GetPreciseTime(); - CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",filename); + CONS_Debug(DBG_SETUP, "Making MD5 for %s\n", filename); if (md5_stream(fhandle, resblock) == 1) { diff --git a/src/w_wad.h b/src/w_wad.h index ea4a98dd6..474f72c23 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -154,7 +154,6 @@ extern wadfile_t *wadfiles[MAX_WADFILES]; // ========================================================================= -void W_Startup(void); void W_Shutdown(void); // Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened From 7fb21c35ba822290ee5c7203491eeca1002f9e50 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Mar 2026 20:57:06 +0100 Subject: [PATCH 09/25] Experiment: speed up CV_FindVar and CV_FindNetVar oftentimes lua scripts call CV_FindVar a fuckton of times during runtime, with many cvars this can actually tank performance more than one might think ideally lua scripts should cache the result, but with so much stuff and servers we cant expect everyone to go through all scripts to do that using a hashtable for CV_FindNetVar might improve join times aswell, but needs further testing to confirm --- src/command.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/src/command.c b/src/command.c index c37b8f1d3..f19bb89c6 100644 --- a/src/command.c +++ b/src/command.c @@ -1165,6 +1165,39 @@ void VS_Print(vsbuf_t *buf, const char *data) // // ========================================================================= +#define NAME cvar_map_t +#define KEY_TY const char * +#define VAL_TY consvar_t * +#define HASH_FN vt_hash_string +#define CMPR_FN vt_cmpr_string +#include "verstable.h" + +#define NAME netvar_map_t +#define KEY_TY UINT16 +#define VAL_TY consvar_t * +#define HASH_FN vt_hash_integer +#define CMPR_FN vt_cmpr_integer +#include "verstable.h" + +static cvar_map_t cvar_map; +static netvar_map_t netvar_map; + +CONSTRUCTOR static void CV_InitMap(void) +{ + // ensure the map is initialized + cvar_map_t_init(&cvar_map); + cvar_map_t_reserve(&cvar_map, 512); + + netvar_map_t_init(&netvar_map); + netvar_map_t_reserve(&netvar_map, 256); +} + +DESTRUCTOR static void CV_DestroyMap(void) +{ + cvar_map_t_cleanup(&cvar_map); + netvar_map_t_cleanup(&netvar_map); +} + static const char *cv_null_string = ""; /** Searches if a variable has been registered. @@ -1175,11 +1208,17 @@ static const char *cv_null_string = ""; */ consvar_t *CV_FindVar(const char *name) { - consvar_t *cvar; + cvar_map_t_itr it = cvar_map_t_get(&cvar_map, name); + if (!cvar_map_t_is_end(it)) + return it.data->val; + // fallback linear search + /* + consvar_t *cvar; for (cvar = consvar_vars; cvar; cvar = cvar->next) if (fasticmp(name, cvar->name)) return cvar; + */ return NULL; } @@ -1213,11 +1252,17 @@ static inline UINT16 CV_ComputeNetid(const char *s) */ static consvar_t *CV_FindNetVar(UINT16 netid) { + netvar_map_t_itr it = netvar_map_t_get(&netvar_map, netid); + if (!netvar_map_t_is_end(it)) + return it.data->val; + + /* consvar_t *cvar; for (cvar = consvar_vars; cvar; cvar = cvar->next) if (cvar->netid == netid) return cvar; + */ if (netid == 44542) // ouch this hack return &cv_karteliminatelast; @@ -1283,6 +1328,11 @@ void CV_RegisterVar(consvar_t *variable) // the SetValue will set this bit variable->flags &= ~CV_MODIFIED; + + cvar_map_t_insert(&cvar_map, variable->name, variable); + + if (variable->flags & CV_NETVAR) + netvar_map_t_insert(&netvar_map, variable->netid, variable); } /** Finds the string value of a console variable. @@ -1588,9 +1638,21 @@ size_t CV_LoadNetVars(const UINT8 *bufstart) // prevent "invalid command received" serverloading = true; + // we can use our netvar map instead of going through all cvars each time + netvar_map_t_itr it; + for (it = netvar_map_t_first(&netvar_map); + !netvar_map_t_is_end(it); + it = netvar_map_t_next(it)) + { + cvar = it.data->val; + Setvalue(cvar, cvar->defaultvalue, true); + } + + /* for (cvar = consvar_vars; cvar; cvar = cvar->next) if (cvar->flags & CV_NETVAR) Setvalue(cvar, cvar->defaultvalue, true); + */ count = READUINT16(p); while (count--) From e543599598236f205c050b4f6cff248cb4b944fd Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 4 Apr 2026 16:53:01 +0300 Subject: [PATCH 10/25] Add option to hide skin name from stat display --- src/k_hud.c | 17 +++++++++++------ src/k_hud.h | 1 + src/m_menudefs.c | 48 +++++++++++++++++++++++++----------------------- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 6ded3a2f1..1efdcbdcb 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -83,6 +83,7 @@ IMPL_HUD_OFFSET(stat); // Stats // extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showstats_skinname = {"showstats_skinname", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_highresportrait = {"highresportrait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // make char potraits use their high-res version instead @@ -208,6 +209,7 @@ void K_RegisterKartHudStuff(void) CV_RegisterVar(&cv_kartspeedometer); CV_RegisterVar(&cv_showstats); + CV_RegisterVar(&cv_showstats_skinname); CV_RegisterVar(&cv_showinput); CV_RegisterVar(&cv_posanim); @@ -1436,13 +1438,16 @@ static void K_drawKartStats(void) fakeskin = K_GetPlayerSkin(stplyr); // Skin name - if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel + if (cv_showstats_skinname.value) { - V_DrawSmallString(x+20, y+12, flags2, fakeskin->realname); - } - else - { - V_DrawThinString(x+20, y+7, flags2, fakeskin->realname); + if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel + { + V_DrawSmallString(x+20, y+12, flags2, fakeskin->realname); + } + else + { + V_DrawThinString(x+20, y+7, flags2, fakeskin->realname); + } } // Icon and stats diff --git a/src/k_hud.h b/src/k_hud.h index c42996a4e..ca38f43ea 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -35,6 +35,7 @@ extern consvar_t cv_darkitembox; extern consvar_t cv_biglaps; extern consvar_t cv_highresportrait; extern consvar_t cv_showstats; +extern consvar_t cv_showstats_skinname; extern consvar_t cv_fancyroulette; extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 3f1b969ee..0b176fab3 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1828,8 +1828,8 @@ static menuitem_t OP_SaturnHudMenu[] = { {IT_HEADER, NULL, "Saturn Hud Options", NULL, 0}, - {IT_STRING|IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, - {IT_STRING|IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, + {IT_STRING|IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, + {IT_STRING|IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, {IT_STRING|IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 25}, {IT_STRING|IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 30}, @@ -1838,38 +1838,39 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING|IT_CVAR, NULL, "Input Display", &cv_showinput, 45}, {IT_STRING|IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, + {IT_STRING|IT_CVAR, NULL, "Skin Name in Stat Display", &cv_showstats_skinname, 60}, - {IT_STRING|IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 65}, + {IT_STRING|IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 70}, - {IT_STRING|IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 75}, - {IT_STRING|IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 80}, + {IT_STRING|IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 80}, + {IT_STRING|IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 85}, - {IT_STRING|IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, + {IT_STRING|IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 95}, - {IT_STRING|IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 100}, - {IT_STRING|IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 105}, - {IT_STRING|IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 110}, + {IT_STRING|IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 105}, + {IT_STRING|IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 110}, + {IT_STRING|IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 115}, - {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 120}, - {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 125}, + {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 125}, + {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 130}, - {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, - {IT_STRING|IT_CVAR, NULL, "Show Finished on Minimap", &cv_showminimapfinished, 140}, - {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 145}, - {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150}, - {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 155}, + {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 140}, + {IT_STRING|IT_CVAR, NULL, "Show Finished on Minimap", &cv_showminimapfinished, 145}, + {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 150}, + {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 155}, + {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 160}, - {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 165}, - {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 170}, + {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 170}, + {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 175}, - {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 180}, + {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 185}, - {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 190}, + {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 195}, - {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 200}, - {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 205}, + {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 205}, + {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 210}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 215}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 220}, }; static const char* OP_SaturnHudTooltips[] = @@ -1882,6 +1883,7 @@ static const char* OP_SaturnHudTooltips[] = "The color to use instead of the player color when\ncolourized hud is enabled.", "Displays the input display and lets you choose its style.", "Enable the stat display.", + "Show skin name in the stat display.", "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Make the Postionnumber half the size.", "Disable the animation of the Positionnumber\nwhen overtaking someone.", From 873cff447483c8f396456fbeae7b007b87d30546 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 10 Mar 2026 02:27:36 +0300 Subject: [PATCH 11/25] Display information about addon types loaded on server when joining (WIP) --- src/d_clisrv.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/d_netfil.c | 49 +++++++++++++++++++++++++++++++++++ src/d_netfil.h | 12 +++++++++ 3 files changed, 131 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f5e32b2e0..fb665a943 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1154,6 +1154,64 @@ static void CV_LoadPlayerNames(UINT8 **p) } } +static void CL_DrawAddonTypes(void) +{ + INT32 y = 0; + + INT32 addontypes_downloaded[NUMADDONTYPES] = {0}; + + for (INT32 i = 0; i < fileneedednum; ++i) + { + switch (fileneeded[i].status) + { + case FS_FOUND: + case FS_OPEN: + addontypes_downloaded[fileneeded[i].type]++; + break; + + default: + break; + } + } + + for (addontype_t type = 0; type < NUMADDONTYPES; ++type) + { + if (addontypes[type] == 0) + continue; + + INT32 flags = V_SNAPTOTOP|V_SNAPTOLEFT|V_ALLOWLOWERCASE; + + if (addontypes[type] == addontypes_downloaded[type]) + flags |= V_GREENMAP; + else + flags |= V_YELLOWMAP; + + const char *typestr = "Misc"; + + switch (type) + { + case ADDON_SCRIPT: + typestr = "Script"; + break; + + case ADDON_MAP: + typestr = "Map"; + break; + + case ADDON_CHARACTER: + typestr = "Character"; + break; + + default: + break; + } + + V_DrawSmallString(4, 4 + y, flags, va("%s addons", typestr)); + V_DrawRightAlignedSmallString(100, 4 + y, flags, va("%d/%d", addontypes_downloaded[type], addontypes[type])); + y += 6; + } +} + // // CL_DrawConnectionStatus // @@ -1269,6 +1327,8 @@ static void CL_DrawConnectionStatus(void) V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va(" %2u/%2u Files", checkednum, fileneedednum)); + + CL_DrawAddonTypes(); } else if (cl_mode == CL_LOADFILES) { @@ -1292,6 +1352,8 @@ static void CL_DrawConnectionStatus(void) V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va(" %2u/%2u Files", loadcompletednum, fileneedednum)); + + CL_DrawAddonTypes(); } else if (cl_mode == CL_VIEWSERVER) { @@ -1495,6 +1557,8 @@ static void CL_DrawConnectionStatus(void) V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); + + CL_DrawAddonTypes(); } else { @@ -1511,6 +1575,8 @@ static void CL_DrawConnectionStatus(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, M_GetText("Waiting to download files...")); + + CL_DrawAddonTypes(); } } } @@ -2559,6 +2625,7 @@ static void CL_ServerConnectionSearchTicker(tic_t *asksent) } cl_mode = cv_serverinfoscreen.value ? CL_VIEWSERVER : CL_CHECKFILES; + CL_CheckAddonTypes(); } else { @@ -2612,7 +2679,10 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_ASKFULLFILELIST: if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved + { cl_mode = cv_serverinfoscreen.value ? CL_VIEWSERVER : CL_CHECKFILES; + CL_CheckAddonTypes(); + } else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent) { if (CL_AskFileList(fileneedednum)) diff --git a/src/d_netfil.c b/src/d_netfil.c index aca8f35ba..8865ab618 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -116,6 +116,8 @@ static I_mutex downloadmutex; #endif char downloaddir[512] = "DOWNLOAD"; +INT32 addontypes[NUMADDONTYPES] = {0}; + file_download_t filedownload = {}; #ifdef HAVE_CURL @@ -135,6 +137,8 @@ HTTP_login *curl_logins = NULL; static void CURLGetFile(void); #endif +static addontype_t GetAddonType(const char *name); + /** Fills a serverinfo packet with information about wad files loaded. * * \todo Give this function a better name since it is in global scope. @@ -227,6 +231,9 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi fileneeded[i].file = NULL; // The file isn't open yet READSTRINGL(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name READMEM(p, fileneeded[i].md5sum, 16); // The last 16 bytes are the file checksum + + // Should be good place to calculate that? + fileneeded[i].type = GetAddonType(fileneeded[i].filename); } } @@ -575,6 +582,48 @@ INT32 CL_CheckFiles(void) return 1; //everything is FS_OPEN or FS_FOUND, proceed to loading } +static addontype_t GetAddonType(const char *name) +{ + const char *prefix = strchr(name, '_'); + + // Doesn't have prefix (no '_' character or it is too far and is probably not for prefix but for something like version) + // KRBCL_ is longest prefix i can think of so this should be enough + if (prefix == NULL || prefix - name > 5) + return ADDON_MISC; + + // Skip 'K' + if (*name == 'K') + ++name; + + switch (*name) + { + case 'L': + return ADDON_SCRIPT; + break; + + case 'R': + case 'B': + return ADDON_MAP; + break; + + case 'C': + return ADDON_CHARACTER; + break; + } + + return ADDON_MISC; +} + +void CL_CheckAddonTypes(void) +{ + memset(&addontypes, 0, sizeof(addontypes)); + + for (INT32 i = 0; i < fileneedednum; i++) + { + addontypes[fileneeded[i].type]++; + } +} + // Load it now boolean CL_LoadServerFiles(void) { diff --git a/src/d_netfil.h b/src/d_netfil.h index 268cd80be..4d4cdba74 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -40,6 +40,15 @@ typedef enum FS_FALLBACK, // HTTP failed } filestatus_t; +typedef enum addontype_e +{ + ADDON_SCRIPT, + ADDON_MAP, + ADDON_CHARACTER, + ADDON_MISC, + NUMADDONTYPES, +} addontype_t; + typedef struct { UINT8 willsend; // Is the server willing to send it? @@ -51,11 +60,13 @@ typedef struct UINT32 totalsize; filestatus_t status; // The value returned by recsearch boolean justdownloaded; // To prevent late fragments from causing an I_Error + addontype_t type; } fileneeded_t; extern INT32 fileneedednum; extern fileneeded_t fileneeded[MAX_WADFILES]; extern char downloaddir[512]; +extern INT32 addontypes[NUMADDONTYPES]; typedef struct { @@ -91,6 +102,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi void CL_PrepareDownloadSaveGame(const char *tmpsave); INT32 CL_CheckFiles(void); +void CL_CheckAddonTypes(void); boolean CL_LoadServerFiles(void); void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid); From 42fa435a0ba12a55a080fa2a1b381636b030b952 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 11 Mar 2026 17:26:12 +0300 Subject: [PATCH 12/25] Add toggle for server addon info --- src/d_clisrv.c | 5 +++++ src/d_clisrv.h | 2 ++ src/d_netcmd.c | 1 + 3 files changed, 8 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fb665a943..d9419a15b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1156,6 +1156,9 @@ static void CV_LoadPlayerNames(UINT8 **p) static void CL_DrawAddonTypes(void) { + if (!cv_serveraddoninfo.value) + return; + INT32 y = 0; INT32 addontypes_downloaded[NUMADDONTYPES] = {0}; @@ -4284,6 +4287,8 @@ consvar_t cv_connectawaittime = {"connectawaittime", "5", CV_SAVE, connectawaitt consvar_t cv_serverinfoscreen = {"serverinfoscreen", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_serveraddoninfo = {"serveraddoninfo", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static void Got_AddPlayer(const UINT8 **p, INT32 playernum); static void Got_RemovePlayer(const UINT8 **p, INT32 playernum); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index e6741b949..8392f13a1 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -600,6 +600,8 @@ extern consvar_t cv_discordinvites; extern consvar_t cv_serverinfoscreen; +extern consvar_t cv_serveraddoninfo; + // Used in d_net, the only dependence //tic_t ExpandTics(INT32 low, tic_t basetic); void D_ClientServerInit(void); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index aee7f20d4..828ad136a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -900,6 +900,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_mindelay); CV_RegisterVar(&cv_gentlemens); CV_RegisterVar(&cv_serverinfoscreen); + CV_RegisterVar(&cv_serveraddoninfo); #ifdef NETGAME_DEVMODE CV_RegisterVar(&cv_fishcake); From b84e6d89e20776174a50e9dfe949dd51668d25be Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 4 Apr 2026 17:24:58 +0300 Subject: [PATCH 13/25] Add toggle for server addons info hud into settings --- src/m_menudefs.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 0b176fab3..e2fd3305f 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1694,29 +1694,30 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Minimum Input Delay", &cv_mindelay, 20}, {IT_STRING | IT_CVAR, NULL, "Gentlemens Ping", &cv_gentlemens, 25}, {IT_STRING | IT_CVAR, NULL, "Server Info Screen", &cv_serverinfoscreen, 30}, + {IT_STRING | IT_CVAR, NULL, "Server Addons Info", &cv_serveraddoninfo, 35}, - {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 40}, + {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 45}, - {IT_STRING | IT_CVAR, NULL, "Colorized Speedlines", &cv_coloredspeedlines, 50}, - {IT_STRING | IT_CVAR, NULL, "Colorized Sneakertrails", &cv_coloredsneakertrail, 55}, + {IT_STRING | IT_CVAR, NULL, "Colorized Speedlines", &cv_coloredspeedlines, 55}, + {IT_STRING | IT_CVAR, NULL, "Colorized Sneakertrails", &cv_coloredsneakertrail, 60}, - {IT_STRING | IT_CVAR, NULL, "Player Blendeffects", &cv_playerblendeffects, 65}, + {IT_STRING | IT_CVAR, NULL, "Player Blendeffects", &cv_playerblendeffects, 70}, - {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 75}, + {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 80}, - {IT_STRING | IT_CVAR, NULL, "Midair Driftsparks", &cv_airsparks, 85}, + {IT_STRING | IT_CVAR, NULL, "Midair Driftsparks", &cv_airsparks, 90}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 95}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 100}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 105}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 110}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 115}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 120}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 125}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 130}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 135}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 145}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 140}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 150}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -1726,6 +1727,7 @@ static const char* OP_SaturnTooltips[] = "Practice for online play! 0 = instant response.", "Simulate online input delay when hosting a server.\nValue choosen by Player with the lowest ping", "Show a screen before joining a server displaying important information about it", + "Show a amount and types of addons loaded by server when joining", "How much speen do you want?", "Colourize the speedlines in your skincolor if you go fast enough!", "Colourize the sneaker flame trails in your skincolor!", From e6434c24ec246b31212c436762475109de5a622a Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 4 Apr 2026 18:01:10 +0300 Subject: [PATCH 14/25] Fix spelling in server addon info tooltip --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index e2fd3305f..9eb89515f 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1727,7 +1727,7 @@ static const char* OP_SaturnTooltips[] = "Practice for online play! 0 = instant response.", "Simulate online input delay when hosting a server.\nValue choosen by Player with the lowest ping", "Show a screen before joining a server displaying important information about it", - "Show a amount and types of addons loaded by server when joining", + "Show amount and types of addons that are loaded by server when joining", "How much speen do you want?", "Colourize the speedlines in your skincolor if you go fast enough!", "Colourize the sneaker flame trails in your skincolor!", From efd8c20d2677f9d0efeaa9d9b20cf3de2d66905e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Apr 2026 18:26:16 +0200 Subject: [PATCH 15/25] enable lto by default on makefile builds change flag to NOLTO to disable lto at this point we shouldnt have any issues anymore since the utter crapton of bugfixes --- src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 372594384..c930f87ed 100644 --- a/src/Makefile +++ b/src/Makefile @@ -93,7 +93,7 @@ # NOLDWARNING=1 - ? # NOSDLMAIN=1 - ? # SDLMAIN=1 - ? -# USELTO=1 - Enable building with LTO. +# NOLTO=1 - Disable link time optimizations # # Library configuration flags: # Everything here is an override. @@ -260,7 +260,7 @@ debug_opts=-D_DEBUG else # build a normal optimized version debug_opts=-DNDEBUG opts+=-O3 -ifdef USELTO +ifndef NOLTO # compile with LTO opts+=-flto=auto libs+=-flto=auto From 489a58f9fd65ff66dee0abd2321526d7948e256a Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 3 Mar 2026 03:24:08 +0300 Subject: [PATCH 16/25] Allocate all colormaps with PU_STATIC --- src/p_setup.c | 3 ++- src/r_draw.cpp | 7 ++++++- src/r_skins.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0d432e747..afc53234b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2586,7 +2586,8 @@ void P_FreeLevelState(void) } // Clear pointers that would be left dangling by the purge - R_FlushTranslationColormapCache(); + // Pointers are now PU_STATIC so they won't be freed :) + //R_FlushTranslationColormapCache(); #ifdef HWRENDER // Free GPU textures before freeing patches. diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 2e7c47e87..474496108 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -419,7 +419,7 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f // Generate the colormap if necessary if (!ret) { - ret = static_cast(Z_Malloc(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL)); + ret = static_cast(Z_Malloc(NUM_PALETTE_ENTRIES, PU_STATIC, NULL)); K_GenerateKartColormap(ret, skinnum, color, local); //R_GenerateTranslationColormap(ret, skinnum, color); // SRB2kart // Cache the colormap if desired @@ -487,6 +487,10 @@ patch_t* R_GetSkinFaceMini(player_t* ply) \return void */ + +/* There seems to be no reason to free cached colormaps tho? Not like they can change :ChonkBunckle: */ + +/* void R_FlushTranslationColormapCache(void) { INT32 i; @@ -499,6 +503,7 @@ void R_FlushTranslationColormapCache(void) if (localtranslationtablecache[i]) memset(localtranslationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**)); } +*/ // ========================================================================== // COMMON DRAWER FOR 8 AND 16 BIT COLOR MODES diff --git a/src/r_skins.c b/src/r_skins.c index 41971788c..9ab6e0fbf 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -774,7 +774,7 @@ void R_AddSkins(UINT16 wadnum, boolean local) // So just let the function in the while loop take care of it for us. } - R_FlushTranslationColormapCache(); + //R_FlushTranslationColormapCache(); CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); #ifdef SKINVALUES From 4ccf3dfaf98b1a88fb1e55ae8c450901f1c41b62 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Apr 2026 20:17:56 +0200 Subject: [PATCH 17/25] software: make R_DrawWallColumn being able to render "holey" textures not the most efficient but idk a better solution to this, and clipping code may cause some other undesired effects, but well were not supposed to be drawing textures with holes on single sided walls eitherways, but here we are basically this copies columns into a buffer filled with cyan pixels, so the holes become cyan instead of nothing, which we can cut again using the twomultipatch drawers fixes the "melt" effect on some things like spelunky or music plant (and well reading/writing oob) --- src/r_draw.cpp | 2 -- src/r_draw.h | 3 ++- src/r_segs.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/screen.c | 5 ++++- 4 files changed, 62 insertions(+), 6 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 474496108..b8f3fc903 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -515,8 +515,6 @@ void R_FlushTranslationColormapCache(void) // in reality, the few routines that can work for either mode, are // put here -enum columncontext_e columncontext = COLUMNCONTEXT_DIRECT; - enum ColumnFlushType { FLUSH_NONE = 0x0000, diff --git a/src/r_draw.h b/src/r_draw.h index a472b5537..a1d451fb4 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -105,7 +105,6 @@ enum columncontext_e COLUMNCONTEXT_FLUSH, }; -extern enum columncontext_e columncontext; void R_SetColumnContext(enum columncontext_e _columncontext); void R_ResetColumnBuffer(void); @@ -124,6 +123,8 @@ enum COLDRAWFUNC_TRANSTRANS, COLDRAWFUNC_TWOSMULTIPATCH, COLDRAWFUNC_TWOSMULTIPATCHTRANS, + COLDRAWFUNC_TWOSMULTIPATCH_DIRECT, + COLDRAWFUNC_TWOSMULTIPATCHTRANS_DIRECT, COLDRAWFUNC_FOG, COLDRAWFUNC_MAX diff --git a/src/r_segs.cpp b/src/r_segs.cpp index a53d40ec4..f94e72b4c 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -16,6 +16,7 @@ #include "r_sky.h" #include +#include #include "r_portal.h" #include "r_splats.h" @@ -1166,6 +1167,37 @@ static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bott // CALLED: CORE LOOPING ROUTINE. // +static std::vector holecol(256); + +// used for R_DrawWallColumn +// convert "holey" columns into contigous columns +// filled with cyan in place of holes +static UINT8 *R_GetHoleColumn(drawcolumndata_t* dc) +{ + column_t *col = (column_t *)(dc->source - 3); + + const INT32 texheight = dc->texheight; + holecol.resize(texheight); + + // fill in everything with cyan so we can skip it + memset(holecol.data(), TRANSPARENTPIXEL, texheight); + + // shamelessly copy pasted from R_GenerateTexture + INT32 topdelta, prevdelta = -1; + while (col->topdelta != 0xff) + { + topdelta = col->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + + memcpy(holecol.data() + topdelta, (UINT8*)col + 4, col->length); + col = (column_t *)((UINT8*)col + col->length + 4); + } + + return holecol.data(); +} + static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t mid, fixed_t texturecolumn, INT32 texture, boolean remap) { const INT32 itexturecolumn = texturecolumn >> FRACBITS; @@ -1175,13 +1207,35 @@ static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t m dc->source = R_GetColumn(texture, itexturecolumn); dc->texheight = textureheight[texture] >> FRACBITS; dc->sourcelength = dc->texheight; + R_SetColumnFunc(colfunctype); coldrawfunc_t* colfunccopy = colfunc; + + if (textures[texture]->holes) + { + dc->source = R_GetHoleColumn(dc); + + if (cv_softcyancut.value) + { + // need to use multipatch drawers to cut cyan pixels + if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == true) + { + colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS_DIRECT]; + } + else + { + colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCH_DIRECT]; + } + } + } + drawcolumndata_t dc_copy = *dc; + if (remap) { dc_copy.colormap += COLORMAP_REMAPOFFSET; } + colfunccopy(const_cast(&dc_copy)); } @@ -1390,7 +1444,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc) // calculate lighting pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; - if (pindex >= MAXLIGHTSCALE) + if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; dc->colormap = walllights[pindex]; @@ -1425,7 +1479,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc) pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; - if (pindex >= MAXLIGHTSCALE) + if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; if (dc->lightlist[i].extra_colormap) diff --git a/src/screen.c b/src/screen.c index b292c646d..ebc5abddf 100644 --- a/src/screen.c +++ b/src/screen.c @@ -120,6 +120,10 @@ static void SCR_SetDrawFuncs(enum columncontext_e _columncontext) colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn; } + // gotta keep a copy of those for R_DrawWallColumn..... + colfuncs[COLDRAWFUNC_TWOSMULTIPATCH_DIRECT] = R_Draw2sMultiPatchColumn; + colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS_DIRECT] = R_Draw2sMultiPatchTranslucentColumn; + colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn; R_SetColumnFunc(BASEDRAWFUNC); @@ -154,7 +158,6 @@ void SCR_SetMode(void) // effectively adding massive overhead due to excessive flushing, so we draw our masked thing directly to screen instead void R_SetColumnContext(enum columncontext_e _columncontext) { - columncontext = _columncontext; SCR_SetDrawFuncs(_columncontext); // set our column drawers } From 7177a9f57ff58e591ee83fe3678fec12de533bb5 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Apr 2026 17:53:11 +0200 Subject: [PATCH 18/25] raise version to v9.3 --- src/doomdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 1543e68a9..69347f05a 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -130,8 +130,8 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Saturn v9.2" -#define VERSIONSTRINGW L"Saturn v9.2" +#define VERSIONSTRING "Saturn v9.3" +#define VERSIONSTRINGW L"Saturn v9.3" #define SATURN_TESTING // comment out for saturn release builds! From d957bddc1f3630cf097f1621e02d982b6aecfb1b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 13:46:27 +0200 Subject: [PATCH 19/25] update opengl dithering shader now works more like i intended too by more or less scaling the pattern to be roughly the same size on each resolution and trying to reduce precision issues by using floor to convert float values to integer range --- src/hardware/hw_shaders.h | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 40f936f69..ff8b229de 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -78,33 +78,23 @@ // Include GLSL_FLOOR_FUDGES or GLSL_WALL_FUDGES or define the fudges in shaders that use this macro. #define GLSL_DOOM_COLORMAP_DITHER \ "float baseValue = max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ - "float endResolutionx = scr_resolution.x;\n" \ - "float endResolutiony = scr_resolution.y;\n" \ - "if (scr_resolution.x > 1280.0) {\n" \ - "endResolutionx = scr_resolution.x * 0.5;\n" \ - "}\n" \ - "if (scr_resolution.y > 720.0) {\n" \ - "endResolutiony = scr_resolution.y * 0.5;\n" \ - "}\n" \ - "float zFactor = clamp((z - 192.0) / (6144.0 - 192.0), 0.0, 1.0);\n" \ - "int scaleFactor = int(mix(1.0, 8.0, zFactor));\n" \ - "endResolutionx = endResolutionx * scaleFactor;\n" \ - "endResolutiony = endResolutiony * scaleFactor;\n" \ - "vec2 normalizedPosition = position * vec2(endResolutionx / scr_resolution.x, endResolutiony / scr_resolution.y);\n" \ - "int x = int(mod(normalizedPosition.x, 4.0));\n" \ - "int y = int(mod(normalizedPosition.y, 4.0));\n" \ + "float patscale = min(scr_resolution.x / 1280.0, scr_resolution.y / 720.0);\n" \ + "patscale = max(floor(patscale + 0.5), 1.0);\n" \ + "patscale = 1.0 / patscale;\n" \ + "ivec2 p = ivec2(mod(floor(position * patscale), 4.0));\n" \ + "float depthfactor = clamp((z - 192.0) / (6144.0 - 192.0), 0.0, 1.0);\n" \ "float bayerMatrix[4*4] = float[4*4](\n" \ "0.0, 8.0, 2.0, 10.0,\n" \ "12.0, 4.0, 14.0, 6.0,\n" \ "3.0, 11.0, 1.0, 9.0,\n" \ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ + "float threshold = 16.0;\n" \ "#ifdef SRB2_PALETTE_RENDERING\n" \ - "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 11.0);\n" \ - "#else\n" \ - "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 16.0);\n" \ + "threshold = 11.0;\n" \ "#endif\n" \ - "return mix(baseValue + threshold - 0.5 / 16.0, baseValue, zFactor);\n" + "threshold = (1.0 - pow(depthfactor, 2.0)) * (bayerMatrix[p.y*4 + p.x] / threshold);\n" \ + "return mix(baseValue + threshold - 0.5 / 16.0, baseValue, depthfactor);\n" #define GLSL_DOOM_COLORMAP_NODITHER \ "return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ From 5461a6dcbe18c5a409e2f699c7a7da3095bfad5c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 14:39:01 +0200 Subject: [PATCH 20/25] cleanup skinselect menu stuff slightly --- src/m_menu.c | 93 +++++++++++++++++++--------------------------------- 1 file changed, 34 insertions(+), 59 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 01b106d95..2dc7119e4 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7953,25 +7953,24 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 tw = 0; spritedef_t *sprdef; spriteframe_t *sprframe; - patch_t *statbg = (patch_t *)W_CachePatchName("K_STATBG", PU_PATCH); - patch_t *statlr = (patch_t *)W_CachePatchName("K_STATLR", PU_PATCH); - patch_t *statud = (patch_t *)W_CachePatchName("K_STATUD", PU_PATCH); - patch_t *statdot = (patch_t *)W_CachePatchName("K_SDOT0" , PU_PATCH); patch_t *patch; UINT8 frame; UINT8 speed; UINT8 weight; UINT8 i; UINT8 s, w; - const UINT8 *flashcol = V_GetStringColormap(highlightflags); INT32 skinnum = 0; INT32 statx, staty; UINT32 speenframe; INT32 sltw, actw, hetw; UINT8 skintodisplay; INT32 nameboxaddy = 0; - int statoffset = 0; - int gridyoffset = 0; + + const UINT8 *flashcol = V_GetStringColormap(highlightflags); + patch_t *statbg = (patch_t *)W_CachePatchName("K_STATBG", PU_PATCH); + patch_t *statlr = (patch_t *)W_CachePatchName("K_STATLR", PU_PATCH); + patch_t *statud = (patch_t *)W_CachePatchName("K_STATUD", PU_PATCH); + patch_t *statdot = (patch_t *)W_CachePatchName("K_SDOT0" , PU_PATCH); mx = MP_PlayerSetupDef.x; my = MP_PlayerSetupDef.y; @@ -7986,8 +7985,6 @@ static void M_DrawSetupMultiPlayerMenu(void) switch (cv_skinselectmenu.value) { case SKINMENUTYPE_EXTENDED: - nameboxaddy = 6; - break; case SKINMENUTYPE_GRID: nameboxaddy = 6; break; @@ -8003,39 +8000,23 @@ static void M_DrawSetupMultiPlayerMenu(void) else M_DrawTextInput(mx + 40, my + nameboxaddy, &setupm_input, 0); +#define GETSELECTEDSKINNAME (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].realname : skins[setupm_fakeskin].realname) +#define GETSELECTEDSPEED (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartspeed : skins[setupm_fakeskin].kartspeed) +#define GETSELECTEDWEIGHT (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartweight : skins[setupm_fakeskin].kartweight) + // draw skin string st = V_StringWidth(skins[setupm_fakeskin].realname, 0); switch (cv_skinselectmenu.value) { case SKINMENUTYPE_EXTENDED: -#define GETSELECTEDSKINNAME (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].realname : skins[setupm_fakeskin].realname) -#define GETSELECTEDSPEED (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartspeed : skins[setupm_fakeskin].kartspeed) -#define GETSELECTEDWEIGHT (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartweight : skins[setupm_fakeskin].kartweight) - - tw = V_StringWidth("Character", 0);//V_StringWidth(GETSELECTEDSKINNAME, 0); - st = V_StringWidth(GETSELECTEDSKINNAME, 0); - - V_DrawString((mx+(tw/2)) - (st/2), my + 37, - ((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0) | highlightflags | V_ALLOWLOWERCASE, - GETSELECTEDSKINNAME); - if (statdp == true) - statoffset = 50; - else - statoffset = 113; - - V_DrawString(statx - statoffset, staty - 10, V_6WIDTHSPACE, va("\x84%dS \x87%dW", GETSELECTEDSPEED, GETSELECTEDWEIGHT)); -#undef GETSELECTEDSKINNAME -#undef GETSELECTEDSPEED -#undef GETSELECTEDWEIGHT - break; + V_DrawString(statx - (statdp ? 50 : 113), staty - 10, V_6WIDTHSPACE, va("\x84%dS \x87%dW", GETSELECTEDSPEED, GETSELECTEDWEIGHT)); + /* FALLTHRU */ case SKINMENUTYPE_GRID: -#define GETSELECTEDSKINNAME (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].realname : skins[setupm_fakeskin].realname) - tw = V_StringWidth("Character", 0);//V_StringWidth(GETSELECTEDSKINNAME, 0); + tw = V_StringWidth("Character", 0); st = V_StringWidth(GETSELECTEDSKINNAME, 0); V_DrawString((mx+(tw/2)) - (st/2), my + 37, ((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0) | highlightflags | V_ALLOWLOWERCASE, GETSELECTEDSKINNAME); -#undef GETSELECTEDSKINNAME break; case SKINMENUTYPE_2D: @@ -8113,8 +8094,6 @@ static void M_DrawSetupMultiPlayerMenu(void) break; } -#define GRIDSTATOFFSET 0 - switch (cv_skinselectmenu.value) { case SKINMENUTYPE_EXTENDED: @@ -8126,9 +8105,6 @@ static void M_DrawSetupMultiPlayerMenu(void) if (itemOn == 1) V_DrawSmallString(statx+101, staty-37, V_6WIDTHSPACE|highlightflags, "BS: change"); -#define GETSELECTEDSPEED (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartspeed : skins[setupm_fakeskin].kartspeed) -#define GETSELECTEDWEIGHT (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartweight : skins[setupm_fakeskin].kartweight) - if (statdp == true) { //Background @@ -8158,22 +8134,19 @@ static void M_DrawSetupMultiPlayerMenu(void) } } -#undef GETSELECTEDSPEED -#undef GETSELECTEDWEIGHT - break; case SKINMENUTYPE_GRID: // SRB2Kart: draw the stat backer // labels - V_DrawSmallString(statx+12+GRIDSTATOFFSET, staty+67, V_6WIDTHSPACE|highlightflags, "Acceleration"); - V_DrawSmallString(statx+76+GRIDSTATOFFSET, staty+67, V_6WIDTHSPACE|highlightflags, "Max Speed"); - V_DrawSmallString(statx+14+GRIDSTATOFFSET, staty+75, V_6WIDTHSPACE|highlightflags, "Handling"); - V_DrawSmallString(statx+21+GRIDSTATOFFSET, staty+108, V_6WIDTHSPACE|highlightflags, "Weight"); + V_DrawSmallString(statx+12, staty+67, V_6WIDTHSPACE|highlightflags, "Acceleration"); + V_DrawSmallString(statx+76, staty+67, V_6WIDTHSPACE|highlightflags, "Max Speed"); + V_DrawSmallString(statx+14, staty+75, V_6WIDTHSPACE|highlightflags, "Handling"); + V_DrawSmallString(statx+21, staty+108, V_6WIDTHSPACE|highlightflags, "Weight"); // label arrows - V_DrawFixedPatch(((statx+61+GRIDSTATOFFSET)<>1), (staty+67)<>1, 0, statlr, flashcol); - V_DrawFixedPatch((statx+40+GRIDSTATOFFSET)<>1, 0, statud, flashcol); + V_DrawFixedPatch(((statx+61)<>1), (staty+67)<>1, 0, statlr, flashcol); + V_DrawFixedPatch((statx+40)<>1, 0, statud, flashcol); // bg - V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, NULL); + V_DrawFixedPatch(((statx+48)<>1), (staty+73)<>1, 0, statbg, NULL); for (i = 0; i < numskins; i++) // draw the stat dots { @@ -8181,7 +8154,7 @@ static void M_DrawSetupMultiPlayerMenu(void) { speed = skins[i].kartspeed; weight = skins[i].kartweight; - V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, NULL); + V_DrawFixedPatch((((statx+46) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, NULL); } } @@ -8207,9 +8180,9 @@ static void M_DrawSetupMultiPlayerMenu(void) #define TEXTVERTSHIFT 10 DRAWSLOW(statx - sltw - 2, staty); - DRAWSLOW(statx - sltw - 2, staty - TEXTVERTSHIFT+ (9 * 18) - 11); + DRAWSLOW(statx - sltw - 2, staty - TEXTVERTSHIFT + (9 * 18) - 11); DRAWFAST(statx + (9 * 18), staty); - DRAWFAST(statx + (9 * 18), staty - TEXTVERTSHIFT+ (9 * 18) - 11); + DRAWFAST(statx + (9 * 18), staty - TEXTVERTSHIFT + (9 * 18) - 11); DRAWACCEL(statx - actw - 2, staty + TEXTVERTSHIFT); DRAWACCEL(statx + (9 * 18), staty + TEXTVERTSHIFT); DRAWHEAVY(statx - hetw - 2, staty + (9 * 18) - 11); @@ -8246,15 +8219,18 @@ static void M_DrawSetupMultiPlayerMenu(void) break; } +#undef GETSELECTEDSKINNAME +#undef GETSELECTEDSPEED +#undef GETSELECTEDWEIGHT + switch (cv_skinselectmenu.value) { - //Skin grid stuff - case SKINMENUTYPE_EXTENDED: - gridyoffset = 10; + //Skin grid stuff + case SKINMENUTYPE_EXTENDED: for (s = 0; s < SKINGRIDNEWWIDTH*SKINGRIDNEWHEIGHT; s++) { INT32 x = ((s % SKINGRIDNEWWIDTH) * 18) + ((BASEVIDWIDTH / 2) - (18 * SKINGRIDNEWWIDTH) - 8) + 100 + SKINXSHIFT; //BASEVIDWIDTH / 2 - ((icons + 1) * 24) - 4; - INT32 y = ((s / SKINGRIDNEWWIDTH) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2)) + gridyoffset); //BASEVIDWIDTH / 2 - ((icons + 1) * 24) - 4; + INT32 y = ((s / SKINGRIDNEWWIDTH) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2)) + 10); //BASEVIDWIDTH / 2 - ((icons + 1) * 24) - 4; INT32 calcs = s + (setupm_skinypos * SKINGRIDNEWWIDTH); INT32 skinn; patch_t *face; @@ -8280,7 +8256,7 @@ static void M_DrawSetupMultiPlayerMenu(void) { patch_t *cursor; INT32 curx = (((setupm_skinselect % SKINGRIDNEWWIDTH) * 18) + ((BASEVIDWIDTH / 2) - (18 * SKINGRIDNEWWIDTH/2)) + SKINXSHIFT) + 20; - INT32 cury = (((setupm_skinselect / SKINGRIDNEWWIDTH) - setupm_skinypos) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2))+ gridyoffset); + INT32 cury = (((setupm_skinselect / SKINGRIDNEWWIDTH) - setupm_skinypos) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2))+ 10); UINT8 cursorframe = (I_GetTime() / 4) % 7; cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); @@ -8340,13 +8316,13 @@ static void M_DrawSetupMultiPlayerMenu(void) weight = skins[selectedskin].kartweight; statdot = (patch_t *)W_CachePatchName("K_SDOT1", PU_PATCH); if (skullAnimCounter < 4) // SRB2Kart: we draw this dot later so that it's not covered if there's multiple skins with the same stats - V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, flashcol); + V_DrawFixedPatch((((statx+46) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, flashcol); else - V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, NULL); + V_DrawFixedPatch((((statx+46) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, NULL); statdot = (patch_t *)W_CachePatchName("K_SDOT2", PU_PATCH); // coloured center if (setupm_fakecolor) - V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, R_GetTranslationColormap(0, setupm_fakecolor, GTC_MENUCACHE)); + V_DrawFixedPatch((((statx+46) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, R_GetTranslationColormap(0, setupm_fakecolor, GTC_MENUCACHE)); } break; case SKINMENUTYPE_2D: @@ -8397,7 +8373,6 @@ static void M_DrawSetupMultiPlayerMenu(void) } } break; -#undef GRIDSTATOFFSET #undef SKINXSHIFT default: speed = skins[setupm_fakeskin].kartspeed; From 898bcd336d2451367bb8bd46b308ee71e9dc22e5 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 18:53:35 +0200 Subject: [PATCH 21/25] should be :chonkbuncle: --- src/lua_hudlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 538463117..444733097 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1297,7 +1297,7 @@ static int lib_hudsetvotebackground(lua_State *L) if (strlen(prefix) != 4) { - return luaL_argerror(L, 1, "prefix should 4 characters wide"); + return luaL_argerror(L, 1, "prefix should be 4 characters wide"); } strncpy(VoteScreen.luaPrefix, prefix, 4); From 8c2132a98c029419429418345d088b4c446ec440 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 21:54:32 +0200 Subject: [PATCH 22/25] remove a few more unused things --- src/d_clisrv.c | 4 +-- src/d_main.c | 12 ++++----- src/dedicated/i_system.c | 4 +++ src/dehacked.c | 57 +++++++++++++++++++++------------------- src/doomstat.h | 7 ----- src/f_finale.c | 8 ------ src/g_demo.c | 5 ++-- src/g_game.c | 9 ------- src/g_game.h | 4 --- src/k_hud.c | 11 ++++++-- src/p_saveg.c | 4 --- src/p_tick.c | 4 +-- src/s_sound.c | 4 +-- 13 files changed, 57 insertions(+), 76 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d9419a15b..5da2b4ee2 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4361,7 +4361,7 @@ void D_ClientServerInit(void) playerinfo[i].node = 255; gametic = 0; - localgametic = 0; + leveltime = 0; // do not send anything before the real begin SV_StopServer(); @@ -6819,7 +6819,7 @@ boolean TryRunTics(tic_t realtics) { boolean update_stats = !(paused || P_AutoPause()); - DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); + DEBFILE(va("============ Running tic %d (local %d)\n", gametic, leveltime)); if (update_stats) PS_START_TIMING(ps_tictime); diff --git a/src/d_main.c b/src/d_main.c index a0b1f6fa4..5655d0532 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -697,16 +697,16 @@ void D_SRB2Loop(void) for (;;) { - if (I_Interrupted()) - { - I_Quit(); - } - // capbudget is the minimum precise_t duration of a single loop iteration precise_t capbudget; precise_t elapsed; precise_t enterprecise, finishprecise; + if (I_Interrupted()) + { + I_Quit(); + } + enterprecise = I_GetPreciseTime(); memset(&g_dc, 0, sizeof(g_dc)); @@ -2163,8 +2163,8 @@ void D_SRB2Main(void) if (dedicated && server) { - levelstarttic = gametic; G_SetGamestate(GS_LEVEL); + if (!P_SetupLevel(false, false)) I_Quit(); // fail so reset game stuff } diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 22ef96419..014533af8 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1424,6 +1424,7 @@ void I_Quit(void) /* prevent recursive I_Quit() */ if (quiting) goto death; + quiting = false; I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. @@ -1441,14 +1442,17 @@ void I_Quit(void) // use this for 1.28 19990220 by Kin I_ShutdownGraphics(); I_ShutdownSystem(); + /* if option -noendtxt is set, don't print the text */ if (!M_CheckParm("-noendtxt") && W_CheckNumForName("ENDOOM") != LUMPERROR) { printf("\r"); ShowEndTxt(); } + if (myargmalloc) free(myargv); // Deallocate allocated memory + death: W_Shutdown(); exit(0); diff --git a/src/dehacked.c b/src/dehacked.c index a4082c6f2..9f7889945 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2503,26 +2503,12 @@ static void readmaincfg(MYFILE *f) { flashingtics = (UINT16)get_number(word2); } - else if (fastcmp(word, "TAILSFLYTICS")) - { - tailsflytics = (UINT16)get_number(word2); - } - else if (fastcmp(word, "UNDERWATERTICS")) - { - underwatertics = (UINT16)get_number(word2); - } - else if (fastcmp(word, "SPACETIMETICS")) - { - spacetimetics = (UINT16)get_number(word2); - } else if (fastcmp(word, "EXTRALIFETICS")) { + // this modifies player->powers[pw_extralife] + // which still has some game behaviour attached to it... extralifetics = (UINT16)get_number(word2); } - else if (fastcmp(word, "GAMEOVERTICS")) - { - gameovertics = get_number(word2); - } else if (fastcmp(word, "INTROTOPLAY")) { @@ -2546,10 +2532,7 @@ static void readmaincfg(MYFILE *f) if (creditscutscene > 128) creditscutscene = 128; } - else if (fastcmp(word, "NUMDEMOS")) - { - numDemos = (UINT8)get_number(word2); - } + else if (fastcmp(word, "DEMODELAYTIME")) { demoDelayTime = get_number(word2); @@ -2562,10 +2545,6 @@ static void readmaincfg(MYFILE *f) { use1upSound = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y'); } - else if (fastcmp(word, "MAXXTRALIFE")) - { - continue; // unused - } else if (fastcmp(word, "GAMEDATA")) { // just ignore it but dont throw a warning @@ -2604,6 +2583,30 @@ static void readmaincfg(MYFILE *f) { strlcpy(customversionstring, word2, sizeof (customversionstring)); } + else if (fastcmp(word, "NUMDEMOS")) + { + continue; // unused + } + else if (fastcmp(word, "TAILSFLYTICS")) + { + continue; // unused + } + else if (fastcmp(word, "UNDERWATERTICS")) + { + continue; // unused + } + else if (fastcmp(word, "SPACETIMETICS")) + { + continue; // unused + } + else if (fastcmp(word, "GAMEOVERTICS")) + { + continue; // unused + } + else if (fastcmp(word, "MAXXTRALIFE")) + { + continue; // unused + } else deh_warning("Maincfg: unknown word '%s'", word); } @@ -8572,13 +8575,13 @@ FUNCINLINE static ATTRINLINE int lib_getenum(lua_State *L) const char *word; boolean mathlib = lua_toboolean(L, UV_MATHLIB); - if (lua_type(L,2) != LUA_TSTRING) + if (lua_type(L, 2) != LUA_TSTRING) return 0; - word = lua_tostring(L,2); + word = lua_tostring(L, 2); /* First check actions, as they can be overridden. */ - if (!mathlib && fastncmp("A_",word,2)) + if (!mathlib && fastncmp("A_", word, 2)) { char *caps; // Try to get a Lua action first. diff --git a/src/doomstat.h b/src/doomstat.h index f8216cc1e..e8eae7a4f 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -54,7 +54,6 @@ extern INT16 maptol; extern UINT8 globalweather; extern INT32 curWeather; extern INT32 cursaveslot; -extern INT16 lastmapsaved; extern boolean gamecomplete; #define PRECIP_NONE 0 @@ -78,7 +77,6 @@ extern boolean imcontinuing; // Temporary flag while continuing extern UINT8 modeattacking; // menu demo things -extern UINT8 numDemos; extern UINT32 demoDelayTime; extern UINT32 demoIdleTime; @@ -114,7 +112,6 @@ extern UINT8 paused; // Game paused? extern UINT8 window_notinfocus; // are we in focus? (backend independant -- handles auto pausing and display of "focus lost" message) extern boolean nodrawers; -extern boolean noblit; extern boolean lastdraw; #ifdef MOTIONBLUR @@ -402,9 +399,6 @@ extern boolean CheckForReverseGravity; extern UINT16 invulntics; extern UINT16 sneakertics; extern UINT16 flashingtics; -extern UINT16 tailsflytics; -extern UINT16 underwatertics; -extern UINT16 spacetimetics; extern UINT16 extralifetics; // SRB2kart @@ -490,7 +484,6 @@ extern UINT32 timesBeatenWithEmeralds; // WAD, partly set at startup time. extern tic_t gametic; -#define localgametic leveltime // Player spawn spots. extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative diff --git a/src/f_finale.c b/src/f_finale.c index f7efbbced..624b64739 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1110,14 +1110,6 @@ void F_TitleScreenTicker(boolean run) return; } - // Replay intro when done cycling through demos - /*if (curDemo == numDemos) -- uuuh... we have a LOT of maps AND a big devteam... probably not gonna see a repeat unless you're super unlucky :V - { - curDemo = 0; - F_StartIntro(); - return; - }*/ - mapname = G_BuildMapName(G_RandMap(TOL_RACE, -2, false, 0, false, NULL)+1); numstaff = 1; diff --git a/src/g_demo.c b/src/g_demo.c index c36b3273b..850e08048 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -66,12 +66,10 @@ #include // menu demo things -UINT8 numDemos = 0; //3; -- i'm FED UP of losing my skincolour to a broken demo. change this back when we make new ones UINT32 demoDelayTime = 15*TICRATE; UINT32 demoIdleTime = 3*TICRATE; boolean nodrawers = false; // for comparative timing purposes -boolean noblit = false; // for comparative timing purposes static tic_t demostarttime; // for comparative timing purposes //@TODO put these all in a struct for namespacing purposes? @@ -3512,10 +3510,11 @@ static INT32 restorecv_vidwait; void G_TimeDemo(const char *name) { nodrawers = M_CheckParm("-nodraw"); - noblit = M_CheckParm("-noblit"); + restorecv_vidwait = cv_vidwait.value; if (cv_vidwait.value) CV_Set(&cv_vidwait, "0"); + demo.timing = true; singletics = true; framecount = 0; diff --git a/src/g_game.c b/src/g_game.c index f41e7ad79..d2040bcb9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -87,7 +87,6 @@ INT16 maptol = 0; UINT8 globalweather = 0; INT32 curWeather = PRECIP_NONE; INT32 cursaveslot = -1; // Auto-save 1p savegame slot -INT16 lastmapsaved = 0; // Last map we auto-saved at boolean gamecomplete = false; UINT16 mainwads = 0; @@ -108,7 +107,6 @@ INT32 consoleplayer = 0; // player taking events and displaying INT32 displayplayers[MAXSPLITSCREENPLAYERS] = {}; // view being displayed tic_t gametic = 0; -tic_t levelstarttic = 0; // gametic at level start UINT32 totalrings = 0; // for intermission INT16 lastmap = 0; // last level you were at (returning from special stages) tic_t timeinmap = 0; // Ticker for time spent in level (used for levelcard display) @@ -186,9 +184,6 @@ boolean CheckForReverseGravity = false; UINT16 invulntics = 20*TICRATE; UINT16 sneakertics = 20*TICRATE; UINT16 flashingtics = 3*TICRATE/2; // SRB2kart -UINT16 tailsflytics = 8*TICRATE; -UINT16 underwatertics = 30*TICRATE; -UINT16 spacetimetics = 11*TICRATE + (TICRATE/2); UINT16 extralifetics = 4*TICRATE; // SRB2kart @@ -206,8 +201,6 @@ const INT32 wipeoutslowtime = 20; const INT32 wantedreduce = 5*TICRATE; const INT32 wantedfrequency = 10*TICRATE; -INT32 gameovertics = 15*TICRATE; - UINT8 use1upSound = 0; UINT8 introtoplay = 0; @@ -1298,8 +1291,6 @@ static void G_DoLoadLevel(boolean resetplayer) // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); - levelstarttic = gametic; // for time calculation - if (wipegamestate == GS_LEVEL) wipegamestate = -1; // force a wipe diff --git a/src/g_game.h b/src/g_game.h index 6ecc69dfa..76759d257 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -39,12 +39,8 @@ extern INT32 player_name_changes[MAXPLAYERS]; extern player_t players[MAXPLAYERS]; extern boolean playeringame[MAXPLAYERS]; -// gametic at level start -extern tic_t levelstarttic; - // for modding? extern INT16 prevmap, nextmap; -extern INT32 gameovertics; extern tic_t timeinmap; // Ticker for time spent in level (used for levelcard display) extern INT16 rw_maximums[NUM_WEAPONS]; diff --git a/src/k_hud.c b/src/k_hud.c index 1efdcbdcb..bed4c36be 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4022,6 +4022,7 @@ static void K_drawBattleFullscreen(void) { if (stplyrnum == 0) V_DrawFadeScreen(0xFF00, 16); + if (stplyr->exiting < 6*TICRATE && !stplyr->spectator) { if (stplyr->kartstuff[k_position] == 1) @@ -4337,7 +4338,7 @@ static void K_drawInput(void) } else { - const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; + const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[stplyrnum].value && Joystick[stplyrnum].bGamepadStyle; const UINT8 ssplayer = stplyrnum+1; @@ -4354,9 +4355,10 @@ static void K_drawInput(void) { hudforward += KART_FULLTURN; } + if (InputDown(gc_aimbackward, ssplayer) || (gamepadjoystickmove && axis > 0)) { - hudforward-= KART_FULLTURN; + hudforward -= KART_FULLTURN; } } @@ -4442,6 +4444,7 @@ static void K_drawChallengerScreen(void) 19,20,19,20,19,20,19,20,19,20, // frame 20-21, 1 tic, 5 alternating: all text vibrates from impact 21,22,23,24 // frame 22-25, 1 tic: CHALLENGER turns gold }; + const UINT8 offset = min(52-1, (3*TICRATE)-mapreset); V_DrawFadeScreen(0xFF00, 16); // Fade out @@ -4543,6 +4546,7 @@ static void K_drawDistributionDebugger(void) kp_orbinaut[4], kp_jawz[1] }; + INT32 useodds = 0; INT32 pingame = 0, bestbumper = 0; INT32 i; @@ -4559,8 +4563,10 @@ static void K_drawDistributionDebugger(void) if (!playeringame[i] || players[i].spectator) continue; pingame++; + if (players[i].exiting) dontforcespb = true; + if (players[i].kartstuff[k_bumper] > bestbumper) bestbumper = players[i].kartstuff[k_bumper]; } @@ -4714,6 +4720,7 @@ void K_drawKartHUD(void) { if (LUA_HudEnabled(hud_battlefullscreen)) K_drawBattleFullscreen(); + return; } diff --git a/src/p_saveg.c b/src/p_saveg.c index 64686dfd4..667ee5c47 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3308,8 +3308,6 @@ FUNCINLINE static ATTRINLINE void P_ArchiveMisc(savebuffer_t *save) else WRITEINT16(save->p, gamemap); - lastmapsaved = gamemap; - WRITEUINT16(save->p, (botskin ? (emeralds|(1<<10)) : emeralds)+357); WRITESTRINGN(save->p, timeattackfolder, sizeof(timeattackfolder)); } @@ -3333,8 +3331,6 @@ FUNCINLINE static ATTRINLINE void P_UnArchiveSPGame(savebuffer_t *save, INT16 ma if (!mapheaderinfo[gamemap-1]) P_AllocMapHeader(gamemap-1); - lastmapsaved = gamemap; - tokenlist = 0; token = 0; diff --git a/src/p_tick.c b/src/p_tick.c index 9365f5669..24142a823 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -706,6 +706,7 @@ void P_Ticker(boolean run) if (indirectitemcooldown > 0) indirectitemcooldown--; + if (hyubgone > 0) hyubgone--; @@ -713,8 +714,7 @@ void P_Ticker(boolean run) { K_UpdateSpectateGrief(); } - - if (G_BattleGametype()) + else if (G_BattleGametype()) { if (wantedcalcdelay && --wantedcalcdelay <= 0) K_CalculateBattleWanted(); diff --git a/src/s_sound.c b/src/s_sound.c index 5b959e063..40efbe909 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1398,8 +1398,8 @@ void S_LoadMusicDefs(UINT16 wadnum) for (int k = 0; k < 2; k++) { - const char *lumpname = (k == 1 ? "MUSCINFO" : "MUSICDEF"); - lumpnum = W_CheckNumForNamePwad(lumpname, wadnum, 0); //check for MUSCINFO lump on 2nd iteration + const char *lumpname = (k == 1 ? "MUSCINFO" : "MUSICDEF"); //check for MUSCINFO lump on 2nd iteration + lumpnum = W_CheckNumForNamePwad(lumpname, wadnum, 0); if (lumpnum == INT16_MAX) continue; From 71a0b25e32dfcd40031bc81c3579e14676c001e8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 22:33:09 +0200 Subject: [PATCH 23/25] remove old and unused menu player description stuff hope ignorelines is the correct thing to well ignore lines lol --- src/d_main.c | 4 - src/dehacked.c | 186 +++++++++-------------------------------------- src/doomdata.h | 2 +- src/m_menu.c | 63 ---------------- src/m_menu.h | 22 ------ src/m_menudefs.c | 6 -- 6 files changed, 34 insertions(+), 249 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 5655d0532..84abb528d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1786,10 +1786,6 @@ void D_SRB2Main(void) // Setup default unlockable conditions M_SetupDefaultConditionSets(); - // Setup character tables - // Have to be done here before files are loaded - M_InitCharacterTables(); - // load wad, including the main wad file CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n"); diff --git a/src/dehacked.c b/src/dehacked.c index 9f7889945..c35092a91 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -280,149 +280,6 @@ static void clear_levels(void) P_AllocMapHeader(gamemap-1); } -static boolean findFreeSlot(INT32 *num) -{ - // Send the character select entry to a free slot. - while (*num < MAXSKINS && PlayerMenu[*num].status != IT_DISABLED) - *num = *num+1; - - // No more free slots. :( - if (*num >= MAXSKINS) - return false; - - // Found one! ^_^ - return true; -} - -// Reads a player. -// For modifying the character select screen -static void readPlayer(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word; - char *word2; - INT32 i; - boolean slotfound = false; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - if (fastcmp(word, "PLAYERTEXT")) - { - char *playertext = NULL; - - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - PlayerMenu[num].status = IT_CALL; - - // A friendly neighborhood alias for brevity's sake - const size_t note_size = sizeof(description[num].notes); - - for (i = 0; i < (INT32)(MAXLINELEN-note_size-3); i++) - { - if (s[i] == '=') - { - playertext = &s[i+2]; - break; - } - } - - if (playertext) - { - strlcpy(description[num].notes, playertext, note_size); - strlcat(description[num].notes, - myhashfgets(playertext, note_size, f), note_size); - } - else - strcpy(description[num].notes, ""); - - // For some reason, cutting the string did not work above. Most likely due to strcpy or strcat... - // It works down here, though. - { - INT32 numline = 0; - for (i = 0; (size_t)i < note_size-1; i++) - { - if (numline < 20 && description[num].notes[i] == '\n') - numline++; - - if (numline >= 20 || description[num].notes[i] == '\0' || description[num].notes[i] == '#') - break; - } - } - - description[num].notes[strlen(description[num].notes)-1] = '\0'; - description[num].notes[i] = '\0'; - continue; - } - - word2 = strtok(NULL, " = "); - if (word2) - strupr(word2); - else - break; - - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - i = atoi(word2); - - if (fastcmp(word, "PICNAME")) - { - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - PlayerMenu[num].status = IT_CALL; - strncpy(description[num].picname, word2, 8); - } - else if (fastcmp(word, "STATUS")) - { - // Limit the status to only IT_DISABLED and IT_CALL - if (i) - i = IT_CALL; - else - i = IT_DISABLED; - - /* - You MAY disable previous entries if you so desire... - But try to enable something that's already enabled and you will be sent to a free slot. - - Because of this, you are allowed to edit any previous entrys you like, but only if you - signal that you are purposely doing so by disabling and then reenabling the slot. - - ... Or use MENUPOSITION first, that works too. Hell, you could edit multiple character - slots in a single section that way, due to how SOC editing works. - */ - if (i != IT_DISABLED && !slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - PlayerMenu[num].status = (INT16)i; - } - else if (fastcmp(word, "SKINNAME")) - { - // Send to free slot. - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - PlayerMenu[num].status = IT_CALL; - - strlcpy(description[num].skinname, word2, sizeof description[num].skinname); - strlwr(description[num].skinname); - } - else - deh_warning("readPlayer %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - -done: - Z_Free(s); -} - static int freeslotusage[2][2] = {{0, 0}, {0, 0}}; // [S_, MT_][max, previous .wad's max] void DEH_UpdateMaxFreeslots(void) @@ -2820,6 +2677,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) // it doesn't test the version of SRB2 and version of dehacked file dbg_line = -1; // start at -1 so the first line is 0. + while (!myfeof(f)) { char origpos[256]; @@ -2847,11 +2705,15 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) strncpy(origpos, s, size); origpos[size] = '\0'; - if (NULL != (word = strtok(s, " "))) { + if (NULL != (word = strtok(s, " "))) + { strupr(word); - if (word[strlen(word)-1] == '\n') - word[strlen(word)-1] = '\0'; + const size_t wordlen = strlen(word); + + if (word[wordlen-1] == '\n') + word[wordlen-1] = '\0'; } + if (word) { if (fastcmp(word, "FREESLOT")) @@ -2872,32 +2734,46 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) // This is not a major mod. continue; } + word2 = strtok(NULL, " "); + if (fastcmp(word, "CHARACTER")) { - if (word2) { + if (word2) + { strupr(word2); - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + const size_t wordlen = strlen(word2); + + if (word2[wordlen-1] == '\n') + word2[wordlen-1] = '\0'; + i = atoi(word2); - } else + } + else i = 0; + if (i >= 0 && i < 32) - readPlayer(f, i); + ignorelines(f); // unused else { deh_warning("Character %d out of range (0 - 31)", i); ignorelines(f); } + // This is not a major mod. continue; } + if (word2) { strupr(word2); - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + const size_t wordlen = strlen(word2); + + if (word2[wordlen-1] == '\n') + word2[wordlen-1] = '\0'; + i = atoi(word2); + if (fastcmp(word, "PATCH")) { // Read patch from spec file. @@ -2908,6 +2784,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_mobjtype(word2); // find a thing by name + if (i < NUMMOBJTYPES && i >= 0) { if (i < (MT_FIRSTFREESLOT+freeslotusage[1][1])) @@ -2955,6 +2832,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_state(word2); // find a state by name + if (i < NUMSTATES && i >= 0) { if (i < (S_FIRSTFREESLOT+freeslotusage[0][1])) @@ -2971,6 +2849,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_sfx(word2); // find a sound by name + if (i < NUMSFX && i >= 0) readsound(f, i, savesfxnames); else @@ -2984,6 +2863,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_huditem(word2); // find a huditem by name + if (i >= 0 && i < NUMHUDITEMS) readhuditem(f, i); else diff --git a/src/doomdata.h b/src/doomdata.h index a646686f1..2f5e014c7 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -61,7 +61,7 @@ enum typedef struct { INT16 x, y; -}ATTRPACK mapvertex_t; +} ATTRPACK mapvertex_t; // A SideDef, defining the visual appearance of a wall, // by setting textures and offsets. diff --git a/src/m_menu.c b/src/m_menu.c index 2dc7119e4..7b20b8f41 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -149,9 +149,6 @@ M_waiting_mode_t m_waiting_mode = M_NOT_WAITING; const char *quitmsg[NUM_QUITMESSAGES] = {}; -// Stuff for customizing the player select screen Tails 09-22-2003 -description_t description[MAXSKINS] = {}; - INT32 mapwads[NUMMAPS] = {}; boolean browselocalskins = false; @@ -1996,8 +1993,6 @@ void M_Ticker(void) // void M_Init(void) { - UINT8 i; - COM_AddCommand("manual", Command_Manual_f); CV_RegisterVar(&cv_nextmap); @@ -2043,15 +2038,6 @@ void M_Init(void) quitmsg[QUIT3MSG5] = M_GetText("You'll be back to play soon, though...\n...right?\n\n(Press 'Y' to quit)"); quitmsg[QUIT3MSG6] = M_GetText("Aww, is Eggman's Nightclub too\ndifficult for you?\n\n(Press 'Y' to quit)"); - // Setup PlayerMenu table - for (i = 0; i < MAXSKINS; i++) - { - PlayerMenu[i].status = (i == 0 ? IT_CALL : IT_DISABLED); - PlayerMenu[i].patch = PlayerMenu[i].text = NULL; - PlayerMenu[i].itemaction = M_ChoosePlayer; - PlayerMenu[i].alphaKey = 0; - } - #ifdef HWRENDER // Permanently hide some options based on render mode if (rendermode == render_soft) @@ -2106,55 +2092,6 @@ void M_Init(void) M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf); } -void M_InitCharacterTables(void) -{ - UINT8 i; - - // Setup PlayerMenu table - for (i = 0; i < MAXSKINS; i++) - { - PlayerMenu[i].status = (i < 4 ? IT_CALL : IT_DISABLED); - PlayerMenu[i].patch = PlayerMenu[i].text = NULL; - PlayerMenu[i].itemaction = M_ChoosePlayer; - PlayerMenu[i].alphaKey = 0; - } - - // Setup description table - for (i = 0; i < MAXSKINS; i++) - { - if (i == 0) - { - strcpy(description[i].notes, "\x82Sonic\x80 is the fastest of the three, but also the hardest to control. Beginners beware, but experts will find Sonic very powerful.\n\n\x82""Ability:\x80 Speed Thok\nDouble jump to zoom forward with a huge burst of speed.\n\n\x82Tip:\x80 Simply letting go of forward does not slow down in SRB2. To slow down, hold the opposite direction."); - strcpy(description[i].picname, ""); - strcpy(description[i].skinname, "sonic"); - } - else if (i == 1) - { - strcpy(description[i].notes, "\x82Tails\x80 is the most mobile of the three, but has the slowest speed. Because of his mobility, he's well-\nsuited to beginners.\n\n\x82""Ability:\x80 Fly\nDouble jump to start flying for a limited time. Repetitively hit the jump button to ascend.\n\n\x82Tip:\x80 To quickly descend while flying, hit the spin button."); - strcpy(description[i].picname, ""); - strcpy(description[i].skinname, "tails"); - } - else if (i == 2) - { - strcpy(description[i].notes, "\x82Knuckles\x80 is well-\nrounded and can destroy breakable walls simply by touching them, but he can't jump as high as the other two.\n\n\x82""Ability:\x80 Glide & Climb\nDouble jump to glide in the air as long as jump is held. Glide into a wall to climb it.\n\n\x82Tip:\x80 Press spin while climbing to jump off the wall; press jump instead to jump off\nand face away from\nthe wall."); - strcpy(description[i].picname, ""); - strcpy(description[i].skinname, "knuckles"); - } - else if (i == 3) - { - strcpy(description[i].notes, "\x82Sonic & Tails\x80 team up to take on Dr. Eggman!\nControl Sonic while Tails desperately struggles to keep up.\n\nPlayer 2 can control Tails directly by setting the controls in the options menu.\nTails's directional controls are relative to Player 1's camera.\n\nTails can pick up Sonic while flying and carry him around."); - strcpy(description[i].picname, "CHRS&T"); - strcpy(description[i].skinname, "sonic&tails"); - } - else - { - strcpy(description[i].notes, "???"); - strcpy(description[i].picname, ""); - strcpy(description[i].skinname, ""); - } - } -} - // ========================================================================== // SPECIAL MENU OPTION DRAW ROUTINES GO HERE // ========================================================================== diff --git a/src/m_menu.h b/src/m_menu.h index 2b048fe90..b1070bdc5 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -50,9 +50,6 @@ void M_Drawer(void); // Called by D_SRB2Main, loads the config file. void M_Init(void); -// Called by D_SRB2Main also, sets up the playermenu and description tables. -void M_InitCharacterTables(void); - // Called by intro code to force menu up upon a keypress, // does nothing if menu is already up. void M_StartControlPanel(void); @@ -84,11 +81,6 @@ typedef enum } menumessagetype_t; void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtype); -extern boolean DPADUPSCROLL; -extern boolean DPADDOWNSCROLL; -extern boolean DPADLEFTSCROLL; -extern boolean DPADRIGHTSCROLL; - typedef enum { M_NOT_WAITING, @@ -168,8 +160,6 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt); #define MAXMENUCCVARS 999 -#define MAXTOOLTIPS 255 - typedef union { struct menu_s *submenu; // IT_SUBMENU @@ -195,8 +185,6 @@ typedef struct menuitem_s UINT16 alphaKey; } menuitem_t; -extern menuitem_t PlayerMenu[MAXSKINS]; - typedef struct menu_s { const char *menutitlepic; @@ -227,14 +215,6 @@ extern menu_t SP_LoadDef; void M_SetupJoystickMenu(INT32 choice); extern menu_t OP_JoystickSetDef; -// Stuff for customizing the player select screen -typedef struct -{ - char notes[441]; - char picname[8]; - char skinname[SKINNAMESIZE*2+2]; // skin&skin\0 -} description_t; - // mode descriptions for video mode menu typedef struct { @@ -262,8 +242,6 @@ typedef struct extern INT32 mapwads[NUMMAPS]; -extern description_t description[MAXSKINS]; - extern consvar_t cv_replaysearchrate; extern consvar_t cv_showfocuslost; extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 9eb89515f..af6deacb8 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -495,12 +495,6 @@ static menuitem_t SP_LevelStatsMenu[] = {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLevelStats, '\0'}, // dummy menuitem for the control func }; -// A rare case. -// External files modify this menu, so we can't call it static. -// And I'm too lazy to go through and rename it everywhere. ARRGH! -#define M_ChoosePlayer NULL -menuitem_t PlayerMenu[MAXSKINS]; - // ----------------------------------- // Multiplayer and all of its submenus // ----------------------------------- From c039d14efc22786813a9ba9ca77710bfd421a41c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 22:41:35 +0200 Subject: [PATCH 24/25] remove even more unused stuff --- src/d_net.h | 1 - src/d_netcmd.h | 5 ---- src/dehacked.c | 3 ++ src/g_game.c | 3 +- src/g_state.h | 1 - src/hardware/hw_main.cpp | 2 +- src/hu_stuff.c | 16 ++-------- src/hu_stuff.h | 5 ---- src/i_joy.h | 3 -- src/m_cheat.c | 8 ----- src/m_cheat.h | 9 ------ src/p_enemy.c | 63 +++++++--------------------------------- src/p_local.h | 7 ----- src/p_mobj.c | 11 +------ src/p_user.c | 2 -- 15 files changed, 20 insertions(+), 119 deletions(-) diff --git a/src/d_net.h b/src/d_net.h index f170cdf05..739b4f2fb 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -27,7 +27,6 @@ extern "C" { // SINT8 is used for nodes sometimes >:( #define MAXNETNODES 127 #define BROADCASTADDR MAXNETNODES -#define NETSPLITSCREEN // Kart's splitscreen netgame feature #define STATLENGTH (TICRATE*2) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index c28df3e7d..c9520f1a7 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -93,11 +93,6 @@ extern consvar_t cv_pause; extern consvar_t cv_restrictskinchange, cv_allowteamchange, cv_ingamecap, cv_respawntime; extern consvar_t cv_spectatorreentry, cv_antigrief; -/*extern consvar_t cv_teleporters, cv_superring, cv_supersneakers, cv_invincibility; -extern consvar_t cv_jumpshield, cv_watershield, cv_ringshield, cv_forceshield, cv_bombshield; -extern consvar_t cv_1up, cv_eggmanbox; -extern consvar_t cv_recycler;*/ - // SRB2kart items extern consvar_t cv_sneaker, cv_rocketsneaker, cv_invincibility, cv_banana; extern consvar_t cv_eggmanmonitor, cv_orbinaut, cv_jawz, cv_mine; diff --git a/src/dehacked.c b/src/dehacked.c index c35092a91..323261243 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -43,6 +43,9 @@ #include "m_cond.h" +// idk how PUSHGETTER works, but this is unused +static UINT8 ultimatemode = false; + #define REQUIRE_MATHLIB_GUID "{748fcbc8-6480-4013-ac4e-7afce6cab766}" // Free slot names diff --git a/src/g_game.c b/src/g_game.c index d2040bcb9..0eb9ee506 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -61,7 +61,6 @@ gameaction_t gameaction = 0; gamestate_t gamestate = GS_NULL; -UINT8 ultimatemode = false; boolean botingame = false; UINT8 botskin = 0; @@ -3394,7 +3393,7 @@ static void G_DoContinued(void) token = 0; // Reset # of lives - pl->lives = (ultimatemode) ? 1 : 3; + pl->lives = 3; D_MapChange(gamemap, gametype, false, false, 0, false, false); diff --git a/src/g_state.h b/src/g_state.h index f9f1babd3..02d876d49 100644 --- a/src/g_state.h +++ b/src/g_state.h @@ -52,7 +52,6 @@ typedef enum } gameaction_t; extern gamestate_t gamestate; -extern UINT8 ultimatemode; // was sk_insane extern gameaction_t gameaction; extern boolean botingame; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 87192e2bd..8f2e33a40 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3862,7 +3862,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) wallVerts[1].y = endbot; // The x and y only need to be adjusted in the case that it's not a papersprite - if (cv_glspritebillboarding.value && sprmo && !papersprite) + if (cv_glspritebillboarding.value && !papersprite) { // Get the x and z of the vertices so billboarding draws correctly realheight = realbot - realtop; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 0f54d7bf8..8a60a1a9e 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1581,7 +1581,6 @@ static void HU_drawMiniChat(void) y = chaty - charheight*(msglines+1); -#ifdef NETSPLITSCREEN if (splitscreen) { y -= BASEVIDHEIGHT/2; @@ -1589,7 +1588,6 @@ static void HU_drawMiniChat(void) y += 16; } else -#endif y -= (cv_kartspeedometer.value ? 16 : 0); dx = 0; @@ -1687,18 +1685,15 @@ static void HU_drawChatLog(INT32 offset) if (chat_scroll > chat_maxscroll) chat_scroll = chat_maxscroll; -#ifdef NETSPLITSCREEN if (splitscreen) { boxh = max(6, boxh/2); if (splitscreen > 1) boxw = max(64, boxw/2); } -#endif y = chaty - offset*charheight - (chat_scroll*charheight) - boxh*charheight - 12; -#ifdef NETSPLITSCREEN if (splitscreen) { y -= BASEVIDHEIGHT/2; @@ -1706,7 +1701,6 @@ static void HU_drawChatLog(INT32 offset) y += 16; } else -#endif y -= (cv_kartspeedometer.value ? 16 : 0); @@ -1821,7 +1815,6 @@ static void HU_DrawChat(void) const char *talk = ntalk; const char *mute = "Chat has been muted."; -#ifdef NETSPLITSCREEN if (splitscreen) { y -= BASEVIDHEIGHT/2; @@ -1832,7 +1825,6 @@ static void HU_DrawChat(void) } } else -#endif y -= (cv_kartspeedometer.value ? 16 : 0); if (teamtalk) @@ -1933,7 +1925,7 @@ static void HU_DrawChat(void) INT32 count = 0; INT32 p_dispy = chaty - charheight - 1; size_t longest_name_length = 0; -#ifdef NETSPLITSCREEN + if (splitscreen) { p_dispy -= BASEVIDHEIGHT/2; @@ -1941,13 +1933,13 @@ static void HU_DrawChat(void) p_dispy += 16; } else -#endif p_dispy -= (cv_kartspeedometer.value ? 16 : 0); // Find longest player name, for drawing background for /pm list later for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) continue; + if (!playeringame[i]) + continue; longest_name_length = max(longest_name_length, strlen(player_names[i])); } @@ -2050,7 +2042,6 @@ static void HU_DrawChat(void) skip = 0; -#ifdef NETSPLITSCREEN if (splitscreen) { suggesty -= BASEVIDHEIGHT/2; @@ -2058,7 +2049,6 @@ static void HU_DrawChat(void) suggesty += 16; } else -#endif suggesty -= (cv_kartspeedometer.value ? 16 : 0); while ((suggest = M_FindEmote(complete, complete_len, skip)) != NULL) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 85ff630f5..8ba4bce19 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -68,12 +68,7 @@ typedef struct #define HU_MAXMSGLEN 223 #define HU_MSGBUFSIZE 255 #define MAX_CHAT_BUFSIZE 256 // that's enough messages, right? We'll delete the older ones when that gets out of hand. -#define NETSPLITSCREEN // why the hell WOULDN'T we want this? -#ifdef NETSPLITSCREEN #define OLDCHAT (cv_consolechat.value == 1 || dedicated || vid.width < 640) -#else -#define OLDCHAT (cv_consolechat.value == 1 || dedicated || vid.width < 640) -#endif #define CHAT_MUTE (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) // this still allows to open the chat but not to type. That's used for scrolling and whatnot. #define OLD_MUTE (OLDCHAT && cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) // this is used to prevent oldchat from opening when muted. diff --git a/src/i_joy.h b/src/i_joy.h index 20252b54d..d1282e945 100644 --- a/src/i_joy.h +++ b/src/i_joy.h @@ -44,9 +44,6 @@ extern "C" { struct JoyType_s { - /*! if true, we MUST Poll() to get new joystick data, - that is: we NEED the DIRECTINPUTDEVICE2 ! (watchout NT compatibility) */ - INT32 bJoyNeedPoll; /*! this joystick is a gamepad, read: digital axes if FALSE, interpret the joystick event data as JOYAXISRANGE (see above) */ INT32 bGamepadStyle; diff --git a/src/m_cheat.c b/src/m_cheat.c index 8223f2250..783ff3bcb 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -249,9 +249,6 @@ boolean cht_Responder(event_t *ev) #define REQUIRE_SINGLEPLAYER if (netgame || multiplayer)\ { CONS_Printf(M_GetText("This only works in single player.\n")); return; } -#define REQUIRE_NOULTIMATE if (ultimatemode)\ -{ CONS_Printf(M_GetText("You're too good to be cheating!\n")); return; } - // command that can be typed at the console! void Command_CheatNoClip_f(void) { @@ -259,7 +256,6 @@ void Command_CheatNoClip_f(void) REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; - REQUIRE_NOULTIMATE; plyr = &players[consoleplayer]; plyr->pflags ^= PF_NOCLIP; @@ -274,7 +270,6 @@ void Command_CheatGod_f(void) REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; - REQUIRE_NOULTIMATE; plyr = &players[consoleplayer]; plyr->pflags ^= PF_GODMODE; @@ -289,7 +284,6 @@ void Command_CheatNoTarget_f(void) REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; - REQUIRE_NOULTIMATE; plyr = &players[consoleplayer]; plyr->pflags ^= PF_INVIS; @@ -593,7 +587,6 @@ void Command_Devmode_f(void) #ifndef _DEBUG REQUIRE_SINGLEPLAYER; #endif - REQUIRE_NOULTIMATE; if (COM_Argc() > 1) { @@ -1048,7 +1041,6 @@ void Command_ObjectPlace_f(void) { REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; - REQUIRE_NOULTIMATE; G_SetGameModified(multiplayer, true); diff --git a/src/m_cheat.h b/src/m_cheat.h index f2944c27c..aaf038436 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -29,7 +29,6 @@ void Command_ObjectPlace_f(void); void Command_Writethings_f(void); extern consvar_t cv_opflags, cv_mapthingnum, cv_speed; -//extern consvar_t cv_snapto, cv_grid; extern boolean objectplacing; extern mobjtype_t op_currentthing; @@ -48,18 +47,10 @@ void Command_CheatNoClip_f(void); void Command_CheatGod_f(void); void Command_CheatNoTarget_f(void); void Command_Savecheckpoint_f(void); -/*void Command_Getallemeralds_f(void); -void Command_Resetemeralds_f(void); -void Command_Setrings_f(void); -void Command_Setlives_f(void); -void Command_Setcontinues_f(void);*/ void Command_Devmode_f(void); void Command_Scale_f(void); void Command_Gravflip_f(void); void Command_Hurtme_f(void); -/*void Command_JumpToAxis_f(void); -void Command_Charability_f(void); -void Command_Charspeed_f(void);*/ void Command_Teleport_f(void); void Command_RTeleport_f(void); void Command_Skynum_f(void); diff --git a/src/p_enemy.c b/src/p_enemy.c index cb9b16f2d..f1a0ed535 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1531,10 +1531,7 @@ void A_LobShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } @@ -1570,10 +1567,7 @@ void A_FireShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } @@ -1613,10 +1607,7 @@ void A_SuperFireShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } @@ -2870,12 +2861,6 @@ void A_ExtraLife(void *thing) if (actor->type == MT_1UPICO && !actor->tracer) actor->frame -= 2; // No lives icon for this player, use the default. - if (ultimatemode) //I don't THINK so! - { - S_StartSound(player->mo, sfx_lose); - return; - } - // In shooter gametypes, give the player 100 rings instead of an extra life. if (gametype != GT_COOP && gametype != GT_COMPETITION) P_GivePlayerRings(player, 100); @@ -4015,26 +4000,13 @@ void A_JetChase(void *thing) } // chase towards player - if (ultimatemode) - P_Thrust(actor, actor->angle, FixedMul(actor->info->speed/2, actor->scale)); - else - P_Thrust(actor, actor->angle, FixedMul(actor->info->speed/4, actor->scale)); + P_Thrust(actor, actor->angle, FixedMul(actor->info->speed/4, actor->scale)); // must adjust height - if (ultimatemode) - { - if (actor->z < (actor->target->z + actor->target->height + FixedMul((64<scale))) - actor->momz += FixedMul(FRACUNIT/2, actor->scale); - else - actor->momz -= FixedMul(FRACUNIT/2, actor->scale); - } + if (actor->z < (actor->target->z + actor->target->height + FixedMul((32<scale))) + actor->momz += FixedMul(FRACUNIT/2, actor->scale); else - { - if (actor->z < (actor->target->z + actor->target->height + FixedMul((32<scale))) - actor->momz += FixedMul(FRACUNIT/2, actor->scale); - else - actor->momz -= FixedMul(FRACUNIT/2, actor->scale); - } + actor->momz -= FixedMul(FRACUNIT/2, actor->scale); } // Function: A_JetbThink @@ -4137,10 +4109,7 @@ void A_JetgShoot(void *thing) A_FaceTarget(actor); P_SpawnMissile(actor, actor->target, (mobjtype_t)actor->info->raisestate); - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; if (actor->info->attacksound) S_StartSound(actor, actor->info->attacksound); @@ -6463,12 +6432,8 @@ void A_BuzzFly(void *thing) // chase towards player { INT32 dist, realspeed; - const fixed_t mf = 5*(FRACUNIT/4); - if (ultimatemode) - realspeed = FixedMul(FixedMul(actor->info->speed,mf), actor->scale); - else - realspeed = FixedMul(actor->info->speed, actor->scale); + realspeed = FixedMul(actor->info->speed, actor->scale); dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z); @@ -9256,10 +9221,7 @@ void A_MultiShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } @@ -10868,10 +10830,7 @@ void A_BrakFireShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } diff --git a/src/p_local.h b/src/p_local.h index 95020c022..b71e99ebd 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -99,9 +99,6 @@ typedef struct camera_s // Hold up/down to pan the camera vertically SINT8 dpad_y_held; - // Things used by FS cameras. - fixed_t viewheight; - angle_t startangle; // Camera demobjerization // Info for drawing: position. @@ -121,8 +118,6 @@ typedef struct camera_s fixed_t radius; fixed_t height; - fixed_t relativex; - // Momentums, used to update position. fixed_t momx, momy, momz; @@ -219,7 +214,6 @@ void P_DoJumpShield(player_t *player); void P_BlackOw(player_t *player); void P_ElementalFireTrail(player_t *player); -//void P_DoPityCheck(player_t *player); void P_PlayerThink(player_t *player); void P_PlayerAfterThink(player_t *player); void P_DoPlayerExit(player_t *player); @@ -280,7 +274,6 @@ void P_RemoveMobj(mobj_t *th); void P_RemoveSavegameMobj(mobj_t *th); boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state); boolean P_SetMobjState(mobj_t *mobj, statenum_t state); -//void P_RunShields(void); void P_RunOverlays(void); void P_RunShadows(void); void P_MobjThinker(mobj_t *mobj); diff --git a/src/p_mobj.c b/src/p_mobj.c index 28b85dea6..a413feda8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11163,16 +11163,7 @@ void P_SpawnMapThing(mapthing_t *mthing) } } - if (ultimatemode) - { - if (i == MT_PITYTV || i == MT_GREENTV || i == MT_YELLOWTV || i == MT_BLUETV || i == MT_BLACKTV || i == MT_WHITETV) - return; // No shields in Ultimate mode - - if (i == MT_SUPERRINGBOX) - return; // No rings in Ultimate mode (except special stages) - } - - if (i == MT_EMMY && (gametype != GT_COOP || ultimatemode || tokenbits == 30 || tokenlist & (1 << tokenbits++))) + if (i == MT_EMMY && (gametype != GT_COOP || tokenbits == 30 || tokenlist & (1 << tokenbits++))) return; // you already got this token, or there are too many, or the gametype's not right // Objectplace landing point diff --git a/src/p_user.c b/src/p_user.c index 24b646ee3..ba39f0472 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3478,8 +3478,6 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) } } - thiscam->relativex = 0; - thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); thiscam->radius = 20*FRACUNIT; From 27f22e4b5b44e159fd8d7c6c505cea289488525b Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 9 Apr 2026 19:09:27 +0300 Subject: [PATCH 25/25] Use case insensitive string hashing and compare functions for cvar hashtable --- src/command.c | 4 ++-- src/verstable.h | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index 2eac48a7f..f09f7bf47 100644 --- a/src/command.c +++ b/src/command.c @@ -1168,8 +1168,8 @@ void VS_Print(vsbuf_t *buf, const char *data) #define NAME cvar_map_t #define KEY_TY const char * #define VAL_TY consvar_t * -#define HASH_FN vt_hash_string -#define CMPR_FN vt_cmpr_string +#define HASH_FN FNV1a_HashLowercaseString +#define CMPR_FN vt_cmpr_casestring #include "verstable.h" #define NAME netvar_map_t diff --git a/src/verstable.h b/src/verstable.h index b3fe13f91..d7165e4e9 100644 --- a/src/verstable.h +++ b/src/verstable.h @@ -462,6 +462,8 @@ License (MIT): #include #include +#include "fastcmp.h" + // Two-way concatenation macro. #define VT_CAT_( a, b ) a##b #define VT_CAT( a, b ) VT_CAT_( a, b ) @@ -705,7 +707,12 @@ static inline FORCE_INLINE bool vt_cmpr_integer( uint64_t key_1, uint64_t key_2 static inline FORCE_INLINE bool vt_cmpr_string( const char *key_1, const char *key_2 ) { - return strcmp( key_1, key_2 ) == 0; + return fastcmp( key_1, key_2 ); +} + +static inline FORCE_INLINE bool vt_cmpr_casestring( const char *key_1, const char *key_2 ) +{ + return fasticmp( key_1, key_2 ); } // Default allocation and free functions.