From 9442a463d46284bc85cfac927bc1b7dc1ef6d832 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Mon, 1 Apr 2024 21:43:50 +0200 Subject: [PATCH 001/525] Shrink drawlists, take 2 Approximately 2/3rds smaller --- src/lua_hudlib_drawlist.c | 45 ++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index de1f234c3..7ec5398e4 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -37,27 +37,32 @@ typedef struct drawitem_s { enum drawitem_e type; fixed_t x; fixed_t y; - fixed_t w; - fixed_t h; - INT32 c; - fixed_t scale; - fixed_t hscale; - fixed_t vscale; - patch_t *patch; - INT32 flags; - UINT16 basecolor; - UINT16 outlinecolor; + union { + INT32 flags; + INT32 c; + }; + + union { + fixed_t scale; // drawScaled + fixed_t hscale; // drawStretched + fixed_t w; // drawFill + INT32 align; // drawString + INT32 num; // drawNum, drawPaddedNum, drawPingNum + UINT16 color; // fadeScreen + }; + union { + fixed_t vscale; // drawStretched + fixed_t h; // drawFill + INT32 digits; // drawPaddedNum + UINT8 strength; // fadeScreen + }; + + // pointers (and size_t's) last, for potentially better packing + union { + patch_t *patch; + size_t stroffset; // offset into strbuf to get str + }; const UINT8 *colormap; - UINT8 *basecolormap; - UINT8 *outlinecolormap; - fixed_t sx; - fixed_t sy; - INT32 num; - INT32 digits; - size_t stroffset; // offset into strbuf to get str - UINT16 color; - UINT8 strength; - INT32 align; } drawitem_t; // The internal structure of a drawlist. -- 2.54.0 From 5f69bfcf222535b73bae57a7d0c8a702f1298566 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Tue, 2 Apr 2024 03:22:24 +0200 Subject: [PATCH 002/525] Split game drawlist per displayplayer --- src/lua_hud.h | 2 +- src/lua_hudlib.c | 29 +++++------------------------ src/st_stuff.c | 13 ++++++++----- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/lua_hud.h b/src/lua_hud.h index d0fec7f1e..ce9f6e7a8 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -44,7 +44,7 @@ extern boolean hud_running; boolean LUA_HudEnabled(enum hud option); -void LUAh_GameHUD(player_t *stplyr, huddrawlist_h list); +void LUAh_GameHUD(huddrawlist_h list); void LUAh_ScoresHUD(huddrawlist_h list); void LUAh_IntermissionHUD(huddrawlist_h list); void LUAh_VoteHUD(huddrawlist_h list); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 2f81d98bf..3ec03537b 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1413,7 +1413,7 @@ boolean LUA_HudEnabled(enum hud option) } // Hook for HUD rendering -void LUAh_GameHUD(player_t *stplayr, huddrawlist_h list) +void LUAh_GameHUD(huddrawlist_h list) { if (!gL || !(hudAvailable & (1< 2 && stplayr == &players[displayplayers[3]]) - { - LUA_PushUserdata(gL, &camera[3], META_CAMERA); - camnum = 4; - } - else if (splitscreen > 1 && stplayr == &players[displayplayers[2]]) - { - LUA_PushUserdata(gL, &camera[2], META_CAMERA); - camnum = 3; - } - else if (splitscreen && stplayr == &players[displayplayers[1]]) - { - LUA_PushUserdata(gL, &camera[1], META_CAMERA); - camnum = 2; - } - else - { - LUA_PushUserdata(gL, &camera[0], META_CAMERA); - camnum = 1; - } + LUA_PushUserdata(gL, stplyr, META_PLAYER); + LUA_PushUserdata(gL, &camera[stplyrnum], META_CAMERA); + camnum = stplyrnum + 1; lua_pushnil(gL); while (lua_next(gL, -5) != 0) { lua_pushvalue(gL, -5); // graphics library (HUD[1]) - lua_pushvalue(gL, -5); // stplayr + lua_pushvalue(gL, -5); // stplyr lua_pushvalue(gL, -5); // camera LUA_Call(gL, 3, 0, 1); } diff --git a/src/st_stuff.c b/src/st_stuff.c index 2ecfd73d5..3e64e6626 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -193,7 +193,7 @@ hudinfo_t hudinfo[NUMHUDITEMS] = { 240, 160}, // HUD_LAP }; -static huddrawlist_h luahuddrawlist_game; +static huddrawlist_h luahuddrawlist_game[MAXSPLITSCREENPLAYERS]; // variable to stop mayonaka static from flickering consvar_t cv_lessflicker = {"lessflicker", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -473,7 +473,8 @@ void ST_Init(void) ST_LoadGraphics(); - luahuddrawlist_game = LUA_HUD_CreateDrawList(); + for (int i = 0; i < MAXSPLITSCREENPLAYERS; i++) + luahuddrawlist_game[i] = LUA_HUD_CreateDrawList(); } // change the status bar too, when pressing F12 while viewing a demo. @@ -846,7 +847,7 @@ static void ST_overlayDrawer(void) { if (renderisnewtic) { - LUAh_GameHUD(stplyr, luahuddrawlist_game); + LUAh_GameHUD(luahuddrawlist_game[stplyrnum]); } } @@ -1024,7 +1025,8 @@ void ST_Drawer(void) { if (renderisnewtic) { - LUA_HUD_ClearDrawList(luahuddrawlist_game); + for (i = 0; i <= splitscreen; i++) + LUA_HUD_ClearDrawList(luahuddrawlist_game[i]); } // No deadview! @@ -1035,7 +1037,8 @@ void ST_Drawer(void) ST_overlayDrawer(); } - LUA_HUD_DrawList(luahuddrawlist_game); + for (i = 0; i <= splitscreen; i++) + LUA_HUD_DrawList(luahuddrawlist_game[i]); // draw Midnight Channel's overlay ontop if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff. -- 2.54.0 From b2f9a29eb0bca107ad4bbe7ce65832d48bcb57f3 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:00:23 +0200 Subject: [PATCH 003/525] Lua HUD interpolation --- src/lua_hud.h | 3 + src/lua_hudlib.c | 31 +++++++++ src/lua_hudlib_drawlist.c | 142 +++++++++++++++++++++++++++++--------- 3 files changed, 144 insertions(+), 32 deletions(-) diff --git a/src/lua_hud.h b/src/lua_hud.h index ce9f6e7a8..8601192b6 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -41,6 +41,9 @@ enum hud { }; extern boolean hud_running; +extern UINT8 hud_interptag; +extern UINT32 hud_interpcounter; +extern boolean hud_interpstring; boolean LUA_HudEnabled(enum hud option); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 3ec03537b..62aa30c37 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -32,6 +32,9 @@ #define HUDONLY if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!"); boolean hud_running = false; +UINT8 hud_interptag = 0; +UINT32 hud_interpcounter = 0; +boolean hud_interpstring = false; static UINT8 hud_enabled[(hud_MAX/8)+1]; static UINT8 hudAvailable; // hud hooks field @@ -1178,6 +1181,20 @@ static int libd_getDrawInfo(lua_State *L) return 3; } +static int libd_interpolate(lua_State *L) +{ + HUDONLY + hud_interptag = luaL_checkinteger(L, 1); + return 0; +} + +static int libd_interpString(lua_State *L) +{ + HUDONLY + hud_interpstring = luaL_checkboolean(L, 1); + return 0; +} + static luaL_Reg lib_draw[] = { {"patchExists", libd_patchExists}, {"cachePatch", libd_cachePatch}, @@ -1205,6 +1222,8 @@ static luaL_Reg lib_draw[] = { {"getDrawInfo", libd_getDrawInfo}, {"getHudColor", libd_getHudColor}, {"useColorHud", libd_useColorHud}, + {"interpolate", libd_interpolate}, + {"interpString", libd_interpString}, {NULL, NULL} }; @@ -1438,8 +1457,11 @@ void LUAh_GameHUD(huddrawlist_h list) LUA_PushUserdata(gL, &camera[stplyrnum], META_CAMERA); camnum = stplyrnum + 1; + hud_interpcounter = 0; lua_pushnil(gL); while (lua_next(gL, -5) != 0) { + hud_interptag = 0; + hud_interpcounter++; lua_pushvalue(gL, -5); // graphics library (HUD[1]) lua_pushvalue(gL, -5); // stplyr lua_pushvalue(gL, -5); // camera @@ -1474,7 +1496,10 @@ void LUAh_ScoresHUD(huddrawlist_h list) I_Assert(lua_istable(gL, -1)); lua_remove(gL, -3); // pop HUD lua_pushnil(gL); + hud_interpcounter = 0; while (lua_next(gL, -3) != 0) { + hud_interptag = 0; + hud_interpcounter++; lua_pushvalue(gL, -3); // graphics library (HUD[1]) LUA_Call(gL, 1, 0, 1); } @@ -1507,7 +1532,10 @@ void LUAh_IntermissionHUD(huddrawlist_h list) I_Assert(lua_istable(gL, -1)); lua_remove(gL, -3); // pop HUD lua_pushnil(gL); + hud_interpcounter = 0; while (lua_next(gL, -3) != 0) { + hud_interptag = 0; + hud_interpcounter++; lua_pushvalue(gL, -3); // graphics library (HUD[1]) LUA_Call(gL, 1, 0, 1); } @@ -1540,7 +1568,10 @@ void LUAh_VoteHUD(huddrawlist_h list) I_Assert(lua_istable(gL, -1)); lua_remove(gL, -3); // pop HUD lua_pushnil(gL); + hud_interpcounter = 0; while (lua_next(gL, -3) != 0) { + hud_interptag = 0; + hud_interpcounter++; lua_pushvalue(gL, -3); // graphics library (HUD[1]) LUA_Call(gL, 1, 0, 1); } diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 7ec5398e4..14a24d90e 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -11,11 +11,16 @@ /// \brief a data structure for managing cached drawlists for the Lua hud lib #include "lua_hudlib_drawlist.h" +#include "lua_hud.h" +#include "blua/lstate.h" // shhhhhh +#include "lua_libs.h" #include #include "v_video.h" #include "z_zone.h" +#include "r_main.h" +#include "r_fps.h" enum drawitem_e { DI_Draw = 0, @@ -34,6 +39,7 @@ enum drawitem_e { // A single draw item with all possible arguments needed for a draw call. typedef struct drawitem_s { + UINT64 id; enum drawitem_e type; fixed_t x; fixed_t y; @@ -68,8 +74,10 @@ typedef struct drawitem_s { // The internal structure of a drawlist. struct huddrawlist_s { drawitem_t *items; - size_t items_capacity; size_t items_len; + drawitem_t *olditems; + size_t olditems_len; + size_t capacity; char *strbuf; size_t strbuf_capacity; size_t strbuf_len; @@ -93,8 +101,10 @@ huddrawlist_h LUA_HUD_CreateDrawList(void) drawlist = (huddrawlist_h) Z_Calloc(sizeof(struct huddrawlist_s), PU_STATIC, NULL); drawlist->items = NULL; - drawlist->items_capacity = 0; drawlist->items_len = 0; + drawlist->olditems = NULL; + drawlist->olditems_len = 0; + drawlist->capacity = 0; drawlist->strbuf = NULL; drawlist->strbuf_capacity = 0; drawlist->strbuf_len = 0; @@ -104,15 +114,14 @@ huddrawlist_h LUA_HUD_CreateDrawList(void) void LUA_HUD_ClearDrawList(huddrawlist_h list) { + // swap the old and new lists + void *tmp = list->olditems; + list->olditems = list->items; + list->items = tmp; + // rather than deallocate, we'll just save the existing allocation and empty // it out for reuse - - // this memset probably isn't necessary - if (list->items) - { - memset(list->items, 0, sizeof(drawitem_t) * list->items_capacity); - } - + list->olditems_len = list->items_len; list->items_len = 0; if (list->strbuf) @@ -130,6 +139,10 @@ void LUA_HUD_DestroyDrawList(huddrawlist_h list) { Z_Free(list->items); } + if (list->olditems) + { + Z_Free(list->olditems); + } if (list->strbuf) { Z_Free(list->strbuf); @@ -148,11 +161,11 @@ boolean LUA_HUD_IsDrawListValid(huddrawlist_h list) static size_t AllocateDrawItem(huddrawlist_h list) { if (!list) I_Error("can't allocate draw item: invalid list"); - if (list->items_capacity <= list->items_len + 1) + if (list->capacity <= list->items_len) { - if (list->items_capacity == 0) list->items_capacity = 128; - else list->items_capacity *= 2; - list->items = (drawitem_t *) Z_Realloc(list->items, sizeof(struct drawitem_s) * list->items_capacity, PU_STATIC, NULL); + list->capacity = list->capacity == 0 ? 128 : list->capacity * 2; + list->items = Z_Realloc(list->items, sizeof(struct drawitem_s) * list->capacity, PU_STATIC, NULL); + list->olditems = Z_Realloc(list->olditems, sizeof(struct drawitem_s) * list->capacity, PU_STATIC, NULL); } return list->items_len++; @@ -183,6 +196,14 @@ static size_t CopyString(huddrawlist_h list, const char* str) } } +// leave bit 0 free for the string mode +#define INTERP_LATCH 1 + +#define GETITEMID \ + item->id = hud_interptag \ + ? (((UINT64)gL->savedpc << 32) | (hud_interpcounter << 9) | (hud_interptag << 1) | (hud_interpstring ? INTERP_LATCH : 0)) \ + : 0; + void LUA_HUD_AddDraw( huddrawlist_h list, INT32 x, @@ -194,9 +215,10 @@ void LUA_HUD_AddDraw( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_Draw; - item->x = x; - item->y = y; + item->x = x << FRACBITS; + item->y = y << FRACBITS; item->patch = patch; item->flags = flags; item->colormap = colormap; @@ -214,6 +236,7 @@ void LUA_HUD_AddDrawScaled( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_DrawScaled; item->x = x; item->y = y; @@ -236,6 +259,7 @@ void LUA_HUD_AddDrawStretched( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_DrawStretched; item->x = x; item->y = y; @@ -256,6 +280,7 @@ void LUA_HUD_AddDrawNum( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_DrawNum; item->x = x; item->y = y; @@ -274,6 +299,7 @@ void LUA_HUD_AddDrawPaddedNum( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_DrawPaddedNum; item->x = x; item->y = y; @@ -293,6 +319,7 @@ void LUA_HUD_AddDrawPingNum( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_DrawPingNum; item->x = x; item->y = y; @@ -312,6 +339,7 @@ void LUA_HUD_AddDrawFill( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_DrawFill; item->x = x; item->y = y; @@ -331,6 +359,7 @@ void LUA_HUD_AddDrawString( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_DrawString; item->x = x; item->y = y; @@ -349,6 +378,7 @@ void LUA_HUD_AddDrawKartString( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_DrawKartString; item->x = x; item->y = y; @@ -366,6 +396,7 @@ void LUA_HUD_AddDrawLevelTitle( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + GETITEMID item->type = DI_DrawLevelTitle; item->x = x; item->y = y; @@ -389,6 +420,11 @@ void LUA_HUD_AddFadeScreen( void LUA_HUD_DrawList(huddrawlist_h list) { size_t i; + size_t j = 0; + fixed_t frac = R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT; + fixed_t lerpx = 0, lerpy = 0; + drawitem_t *latchitem = NULL; + drawitem_t *oldlatchitem = NULL; if (!list) I_Error("HUD drawlist invalid"); if (list->items_len <= 0) return; @@ -397,68 +433,110 @@ void LUA_HUD_DrawList(huddrawlist_h list) for (i = 0; i < list->items_len; i++) { drawitem_t *item = &list->items[i]; + drawitem_t *olditem = NULL; const char *itemstr = &list->strbuf[item->stroffset]; + if (item->id) { + // find the old one too + // this is kinda cursed... we need to check every item + // but stop when the first-checked item is reached again + size_t stop = j; + while(true) + { + if (j == list->olditems_len) + { + // wrap around + j = 0; + if (j == stop) // i'm dumb + break; + } + drawitem_t *old = &list->olditems[j++]; + if (old->id == item->id) + { + // gotcha! + olditem = old; + if (item->id & INTERP_LATCH) { + if (!latchitem) { + lerpx = FixedMul(frac, item->x - olditem->x); + lerpy = FixedMul(frac, item->y - olditem->y); + latchitem = item; + oldlatchitem = olditem; + } + } else { + lerpx = FixedMul(frac, item->x - olditem->x); + lerpy = FixedMul(frac, item->y - olditem->y); + latchitem = NULL; + } + break; + } + if (j == stop) + break; + } + } + + #define LERP(it) (olditem ? olditem->it + FixedMul(frac, item->it - olditem->it) : item->it) + #define LERPS(it) (olditem ? (latchitem ? (latchitem->it + (item->it - latchitem->it)) - (latchitem->it - oldlatchitem->it) : olditem->it) + lerp##it : item->it) + switch (item->type) { case DI_Draw: - V_DrawFixedPatch(item->x<y<flags, item->patch, item->colormap); + V_DrawFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap); break; case DI_DrawScaled: - V_DrawFixedPatch(item->x, item->y, item->scale, item->flags, item->patch, item->colormap); + V_DrawFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap); break; case DI_DrawStretched: - V_DrawStretchyFixedPatch(item->x, item->y, item->hscale, item->vscale, item->flags, item->patch, item->colormap); + V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap); break; case DI_DrawNum: - V_DrawTallNum(item->x, item->y, item->flags, item->num); + V_DrawTallNum(LERPS(x), LERPS(y), item->flags, item->num); break; case DI_DrawPaddedNum: - V_DrawPaddedTallNum(item->x, item->y, item->flags, item->num, item->digits); + V_DrawPaddedTallNum(LERPS(x), LERPS(y), item->flags, item->num, item->digits); break; case DI_DrawPingNum: - V_DrawPingNum(item->x, item->y, item->flags, item->num, item->colormap); + V_DrawPingNum(LERPS(x), LERPS(y), item->flags, item->num, item->colormap); break; case DI_DrawFill: - V_DrawFill(item->x, item->y, item->w, item->h, item->c); + V_DrawFill(LERPS(x), LERPS(y), item->w, item->h, item->c); break; case DI_DrawString: switch(item->align) { // hu_font case align_left: - V_DrawString(item->x, item->y, item->flags, itemstr); + V_DrawString(LERPS(x), LERPS(y), item->flags, itemstr); break; case align_center: - V_DrawCenteredString(item->x, item->y, item->flags, itemstr); + V_DrawCenteredString(LERPS(x), LERPS(y), item->flags, itemstr); break; case align_right: - V_DrawRightAlignedString(item->x, item->y, item->flags, itemstr); + V_DrawRightAlignedString(LERPS(x), LERPS(y), item->flags, itemstr); break; case align_fixed: - V_DrawStringAtFixed(item->x, item->y, item->flags, itemstr); + V_DrawStringAtFixed(LERPS(x), LERPS(y), item->flags, itemstr); break; // hu_font, 0.5x scale case align_small: - V_DrawSmallString(item->x, item->y, item->flags, itemstr); + V_DrawSmallString(LERPS(x), LERPS(y), item->flags, itemstr); break; case align_smallright: - V_DrawRightAlignedSmallString(item->x, item->y, item->flags, itemstr); + V_DrawRightAlignedSmallString(LERPS(x), LERPS(y), item->flags, itemstr); break; // tny_font case align_thin: - V_DrawThinString(item->x, item->y, item->flags, itemstr); + V_DrawThinString(LERPS(x), LERPS(y), item->flags, itemstr); break; case align_thinright: - V_DrawRightAlignedThinString(item->x, item->y, item->flags, itemstr); + V_DrawRightAlignedThinString(LERPS(x), LERPS(y), item->flags, itemstr); break; } break; case DI_DrawKartString: - V_DrawKartString(item->x, item->y, item->flags, itemstr); + V_DrawKartString(LERPS(x), LERPS(y), item->flags, itemstr); break; case DI_DrawLevelTitle: - V_DrawLevelTitle(item->x, item->y, item->flags, itemstr); + V_DrawLevelTitle(LERPS(x), LERPS(y), item->flags, itemstr); break; case DI_FadeScreen: V_DrawFadeScreen(item->color, item->strength); -- 2.54.0 From aeb5ae994ecd92cfea78da5c423af52cc76db854 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Wed, 3 Apr 2024 01:37:24 +0200 Subject: [PATCH 004/525] Subpixel interpolation for strings and drawfill --- src/lua_hudlib_drawlist.c | 119 +++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 2 deletions(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 14a24d90e..8aaaa67ff 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -196,6 +196,116 @@ static size_t CopyString(huddrawlist_h list, const char* str) } } +static void CalcCoords(huddrawlist_h list, drawitem_t *item) +{ + if (!(item->flags & V_NOSCALESTART) && cv_uncappedhud.value) + { + INT32 dupx = vid.dupx; + INT32 dupy = vid.dupy; + + item->flags |= V_NOSCALESTART; + + if (item->flags & V_SCALEPATCHMASK) switch ((item->flags & V_SCALEPATCHMASK) >> V_SCALEPATCHSHIFT) + { + case 1: // V_NOSCALEPATCH + dupx = dupy = 1; + break; + case 2: // V_SMALLSCALEPATCH + dupx = vid.smalldupx; + dupy = vid.smalldupy; + break; + case 3: // V_MEDSCALEPATCH + dupx = vid.meddupx; + dupy = vid.meddupy; + break; + default: + break; + } + + // only use one dup, to avoid stretching (har har) + dupx = dupy = (dupx < dupy ? dupx : dupy); + + INT32 x = item->x * dupx; + INT32 y = item->y * dupy; + + if (vid.width != BASEVIDWIDTH * dupx) + { + // dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx, + // so center this imaginary screen + if ((item->flags & (V_HORZSCREEN|V_SNAPTOLEFT)) == (V_HORZSCREEN|V_SNAPTOLEFT)) + x += (vid.width/2 - (BASEVIDWIDTH/2 * dupx)); + else if (item->flags & V_SNAPTORIGHT) + x += (vid.width - (BASEVIDWIDTH * dupx)); + else if (!(item->flags & V_SNAPTOLEFT)) + x += (vid.width - (BASEVIDWIDTH * dupx)) / 2; + } + if (vid.height != BASEVIDHEIGHT * dupy) + { + // same thing here + if ((item->flags & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) + y += (vid.height/2 - (BASEVIDHEIGHT/2 * dupy)); + else if (item->flags & V_SNAPTOBOTTOM) + y += (vid.height - (BASEVIDHEIGHT * dupy)); + else if (!(item->flags & V_SNAPTOTOP)) + y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; + } + + // need to compensate for dup here + + if (item->align == align_center) + x -= (V_StringWidth(&list->strbuf[item->stroffset], item->flags) * (dupx - 1))/2; + if (item->align == align_right) + x -= V_StringWidth(&list->strbuf[item->stroffset], item->flags) * (dupx - 1); + if (item->align == align_thinright) + x -= V_ThinStringWidth(&list->strbuf[item->stroffset], item->flags) * (dupx - 1); + + item->x = x; + item->y = y; + } +} + +static void CalcFillCoords(drawitem_t *item) +{ + if (!(item->flags & V_NOSCALESTART) && cv_uncappedhud.value) + { + INT32 dupx = vid.dupx; + INT32 dupy = vid.dupy; + INT32 x = item->x * dupx; + INT32 y = item->y * dupy; + INT32 c = item->c; + + item->flags |= V_NOSCALESTART; + item->w *= dupx; + item->h *= dupy; + + // Center it if necessary + if (vid.width != BASEVIDWIDTH * dupx) + { + // dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx, + // so center this imaginary screen + if (c & V_SNAPTORIGHT) + x += (vid.width - (BASEVIDWIDTH * dupx)); + else if (!(c & V_SNAPTOLEFT)) + x += (vid.width - (BASEVIDWIDTH * dupx)) / 2; + } + if (vid.height != BASEVIDHEIGHT * dupy) + { + // same thing here + if (c & V_SNAPTOBOTTOM) + y += (vid.height - (BASEVIDHEIGHT * dupy)); + else if (!(c & V_SNAPTOTOP)) + y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; + } + if (c & V_SPLITSCREEN) + y += (BASEVIDHEIGHT * dupy)/2; + if (c & V_HORZSCREEN) + x += (BASEVIDWIDTH * dupx)/2; + + item->x = x; + item->y = y; + } +} + // leave bit 0 free for the string mode #define INTERP_LATCH 1 @@ -346,6 +456,7 @@ void LUA_HUD_AddDrawFill( item->w = w; item->h = h; item->c = c; + CalcFillCoords(item); } void LUA_HUD_AddDrawString( @@ -366,6 +477,7 @@ void LUA_HUD_AddDrawString( item->stroffset = CopyString(list, str); item->flags = flags; item->align = align; + CalcCoords(list, item); } void LUA_HUD_AddDrawKartString( @@ -436,7 +548,7 @@ void LUA_HUD_DrawList(huddrawlist_h list) drawitem_t *olditem = NULL; const char *itemstr = &list->strbuf[item->stroffset]; - if (item->id) { + if (item->id && cv_uncappedhud.value) { // find the old one too // this is kinda cursed... we need to check every item // but stop when the first-checked item is reached again @@ -475,7 +587,10 @@ void LUA_HUD_DrawList(huddrawlist_h list) } #define LERP(it) (olditem ? olditem->it + FixedMul(frac, item->it - olditem->it) : item->it) - #define LERPS(it) (olditem ? (latchitem ? (latchitem->it + (item->it - latchitem->it)) - (latchitem->it - oldlatchitem->it) : olditem->it) + lerp##it : item->it) + + // half of this could be done when the coordinates are latched... zzzzzz + #define LERPS(it) (latchitem ? ((latchitem->it + (item->it - latchitem->it)) - (latchitem->it - oldlatchitem->it)) + lerp##it : (olditem ? olditem->it + lerp##it : item->it)) + //define LERPS(it) (olditem ? (latchitem ? (latchitem->it + (item->it - latchitem->it)) - (latchitem->it - oldlatchitem->it) : olditem->it) + lerp##it : item->it) switch (item->type) { -- 2.54.0 From 18e0485f399b928ac970814f365c4ebacbf64232 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Thu, 4 Apr 2024 23:21:41 +0200 Subject: [PATCH 005/525] Make this less insufferable * Zero is now a valid tag for v.interpolate * Reset lerp coordinates when v.interpString is called again * Leaving string mode enabled on exit no longer breaks other scripts * Fix fadeScreen having an uninitialized ID --- src/lua_hud.h | 3 ++ src/lua_hudlib.c | 36 ++++++++++++++++++---- src/lua_hudlib_drawlist.c | 63 +++++++++++++++++++++++++-------------- 3 files changed, 73 insertions(+), 29 deletions(-) diff --git a/src/lua_hud.h b/src/lua_hud.h index 8601192b6..ccaed738d 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -41,9 +41,12 @@ enum hud { }; extern boolean hud_running; + +extern boolean hud_interpolate; extern UINT8 hud_interptag; extern UINT32 hud_interpcounter; extern boolean hud_interpstring; +extern boolean hud_interplatch; boolean LUA_HudEnabled(enum hud option); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 62aa30c37..bceb9ebc4 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -32,9 +32,12 @@ #define HUDONLY if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!"); boolean hud_running = false; + +boolean hud_interpolate = false; UINT8 hud_interptag = 0; UINT32 hud_interpcounter = 0; boolean hud_interpstring = false; +boolean hud_interplatch = false; static UINT8 hud_enabled[(hud_MAX/8)+1]; static UINT8 hudAvailable; // hud hooks field @@ -1184,14 +1187,35 @@ static int libd_getDrawInfo(lua_State *L) static int libd_interpolate(lua_State *L) { HUDONLY - hud_interptag = luaL_checkinteger(L, 1); + + // do type checking even if interpolation is disabled + boolean newinterpolate; + UINT8 newtag; + + if (lua_isnumber(L, 1)) + { + newinterpolate = true; + newtag = luaL_checkinteger(L, 1); + } + else + { + newinterpolate = luaL_checkboolean(L, 1); + newtag = 0; + } + + if (!cv_uncappedhud.value) + return 0; + + hud_interpolate = newinterpolate; + hud_interptag = newtag; + return 0; } static int libd_interpString(lua_State *L) { HUDONLY - hud_interpstring = luaL_checkboolean(L, 1); + hud_interpstring = hud_interplatch = luaL_checkboolean(L, 1); return 0; } @@ -1460,7 +1484,7 @@ void LUAh_GameHUD(huddrawlist_h list) hud_interpcounter = 0; lua_pushnil(gL); while (lua_next(gL, -5) != 0) { - hud_interptag = 0; + hud_interpolate = hud_interpstring = hud_interplatch = false; hud_interpcounter++; lua_pushvalue(gL, -5); // graphics library (HUD[1]) lua_pushvalue(gL, -5); // stplyr @@ -1498,7 +1522,7 @@ void LUAh_ScoresHUD(huddrawlist_h list) lua_pushnil(gL); hud_interpcounter = 0; while (lua_next(gL, -3) != 0) { - hud_interptag = 0; + hud_interpolate = hud_interpstring = hud_interplatch = false; hud_interpcounter++; lua_pushvalue(gL, -3); // graphics library (HUD[1]) LUA_Call(gL, 1, 0, 1); @@ -1534,7 +1558,7 @@ void LUAh_IntermissionHUD(huddrawlist_h list) lua_pushnil(gL); hud_interpcounter = 0; while (lua_next(gL, -3) != 0) { - hud_interptag = 0; + hud_interpolate = hud_interpstring = hud_interplatch = false; hud_interpcounter++; lua_pushvalue(gL, -3); // graphics library (HUD[1]) LUA_Call(gL, 1, 0, 1); @@ -1570,7 +1594,7 @@ void LUAh_VoteHUD(huddrawlist_h list) lua_pushnil(gL); hud_interpcounter = 0; while (lua_next(gL, -3) != 0) { - hud_interptag = 0; + hud_interpolate = hud_interpstring = hud_interplatch = false; hud_interpcounter++; lua_pushvalue(gL, -3); // graphics library (HUD[1]) LUA_Call(gL, 1, 0, 1); diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 8aaaa67ff..65e6cef42 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -306,13 +306,27 @@ static void CalcFillCoords(drawitem_t *item) } } -// leave bit 0 free for the string mode #define INTERP_LATCH 1 +#define INTERP_STRING 2 -#define GETITEMID \ - item->id = hud_interptag \ - ? (((UINT64)gL->savedpc << 32) | (hud_interpcounter << 9) | (hud_interptag << 1) | (hud_interpstring ? INTERP_LATCH : 0)) \ - : 0; +static UINT64 GetItemId(void) +{ + if (!hud_interpolate) + return 0; + + // leave bits 0 and 1 free for the string mode + UINT64 id = ((UINT64)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2); + + if (hud_interplatch) + { + id |= INTERP_LATCH; + hud_interplatch = false; + } + if (hud_interpstring) + id |= INTERP_STRING; + + return id; +} void LUA_HUD_AddDraw( huddrawlist_h list, @@ -325,7 +339,7 @@ void LUA_HUD_AddDraw( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_Draw; item->x = x << FRACBITS; item->y = y << FRACBITS; @@ -346,7 +360,7 @@ void LUA_HUD_AddDrawScaled( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_DrawScaled; item->x = x; item->y = y; @@ -369,7 +383,7 @@ void LUA_HUD_AddDrawStretched( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_DrawStretched; item->x = x; item->y = y; @@ -390,7 +404,7 @@ void LUA_HUD_AddDrawNum( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_DrawNum; item->x = x; item->y = y; @@ -409,7 +423,7 @@ void LUA_HUD_AddDrawPaddedNum( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_DrawPaddedNum; item->x = x; item->y = y; @@ -429,7 +443,7 @@ void LUA_HUD_AddDrawPingNum( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_DrawPingNum; item->x = x; item->y = y; @@ -449,7 +463,7 @@ void LUA_HUD_AddDrawFill( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_DrawFill; item->x = x; item->y = y; @@ -470,7 +484,7 @@ void LUA_HUD_AddDrawString( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_DrawString; item->x = x; item->y = y; @@ -490,7 +504,7 @@ void LUA_HUD_AddDrawKartString( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_DrawKartString; item->x = x; item->y = y; @@ -508,7 +522,7 @@ void LUA_HUD_AddDrawLevelTitle( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; - GETITEMID + item->id = GetItemId(); item->type = DI_DrawLevelTitle; item->x = x; item->y = y; @@ -524,6 +538,8 @@ void LUA_HUD_AddFadeScreen( { size_t i = AllocateDrawItem(list); drawitem_t *item = &list->items[i]; + // nothing to interpolate here + item->id = 0; item->type = DI_FadeScreen; item->color = color; item->strength = strength; @@ -548,7 +564,7 @@ void LUA_HUD_DrawList(huddrawlist_h list) drawitem_t *olditem = NULL; const char *itemstr = &list->strbuf[item->stroffset]; - if (item->id && cv_uncappedhud.value) { + if (item->id) { // find the old one too // this is kinda cursed... we need to check every item // but stop when the first-checked item is reached again @@ -568,13 +584,11 @@ void LUA_HUD_DrawList(huddrawlist_h list) // gotcha! olditem = old; if (item->id & INTERP_LATCH) { - if (!latchitem) { - lerpx = FixedMul(frac, item->x - olditem->x); - lerpy = FixedMul(frac, item->y - olditem->y); - latchitem = item; - oldlatchitem = olditem; - } - } else { + lerpx = FixedMul(frac, item->x - olditem->x); + lerpy = FixedMul(frac, item->y - olditem->y); + latchitem = item; + oldlatchitem = olditem; + } else if (!(item->id & INTERP_STRING)) { lerpx = FixedMul(frac, item->x - olditem->x); lerpy = FixedMul(frac, item->y - olditem->y); latchitem = NULL; @@ -584,6 +598,9 @@ void LUA_HUD_DrawList(huddrawlist_h list) if (j == stop) break; } + } else { + lerpx = lerpy = 0; + latchitem = NULL; } #define LERP(it) (olditem ? olditem->it + FixedMul(frac, item->it - olditem->it) : item->it) -- 2.54.0 From 60e42472e32679b025615bc8257e2a9bf0f43386 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:00:54 +0200 Subject: [PATCH 006/525] Do string coordinate calcs on all functions (and fix) --- src/lua_hudlib_drawlist.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 65e6cef42..4a58371c8 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -196,7 +196,7 @@ static size_t CopyString(huddrawlist_h list, const char* str) } } -static void CalcCoords(huddrawlist_h list, drawitem_t *item) +static void CalcStringCoords(drawitem_t *item, const char *string) { if (!(item->flags & V_NOSCALESTART) && cv_uncappedhud.value) { @@ -228,6 +228,12 @@ static void CalcCoords(huddrawlist_h list, drawitem_t *item) INT32 x = item->x * dupx; INT32 y = item->y * dupy; + if (item->flags & V_SPLITSCREEN) + y += (BASEVIDHEIGHT * (dupy - 1))/2; + + if (item->flags & V_HORZSCREEN) + x += (BASEVIDWIDTH * (dupx - 1))/2; + if (vid.width != BASEVIDWIDTH * dupx) { // dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx, @@ -251,13 +257,17 @@ static void CalcCoords(huddrawlist_h list, drawitem_t *item) } // need to compensate for dup here - - if (item->align == align_center) - x -= (V_StringWidth(&list->strbuf[item->stroffset], item->flags) * (dupx - 1))/2; - if (item->align == align_right) - x -= V_StringWidth(&list->strbuf[item->stroffset], item->flags) * (dupx - 1); - if (item->align == align_thinright) - x -= V_ThinStringWidth(&list->strbuf[item->stroffset], item->flags) * (dupx - 1); + if (item->type == DI_DrawString) + { + if (item->align == align_center) + x -= (V_StringWidth(string, item->flags) * (dupx - 1))/2; + if (item->align == align_right) + x -= V_StringWidth(string, item->flags) * (dupx - 1); + if (item->align == align_smallright) + x -= V_SmallStringWidth(string, item->flags) * (dupx - 1); + if (item->align == align_thinright) + x -= V_ThinStringWidth(string, item->flags) * (dupx - 1); + } item->x = x; item->y = y; @@ -410,6 +420,7 @@ void LUA_HUD_AddDrawNum( item->y = y; item->num = num; item->flags = flags; + CalcStringCoords(item, NULL); } void LUA_HUD_AddDrawPaddedNum( @@ -430,6 +441,7 @@ void LUA_HUD_AddDrawPaddedNum( item->num = num; item->digits = digits; item->flags = flags; + CalcStringCoords(item, NULL); } void LUA_HUD_AddDrawPingNum( @@ -450,6 +462,7 @@ void LUA_HUD_AddDrawPingNum( item->num = num; item->flags = flags; item->colormap = colormap; + CalcStringCoords(item, NULL); } void LUA_HUD_AddDrawFill( @@ -491,7 +504,8 @@ void LUA_HUD_AddDrawString( item->stroffset = CopyString(list, str); item->flags = flags; item->align = align; - CalcCoords(list, item); + if (item->align != align_fixed) + CalcStringCoords(item, str); } void LUA_HUD_AddDrawKartString( @@ -510,6 +524,7 @@ void LUA_HUD_AddDrawKartString( item->y = y; item->stroffset = CopyString(list, str); item->flags = flags; + CalcStringCoords(item, str); } void LUA_HUD_AddDrawLevelTitle( @@ -528,6 +543,7 @@ void LUA_HUD_AddDrawLevelTitle( item->y = y; item->stroffset = CopyString(list, str); item->flags = flags; + CalcStringCoords(item, str); } void LUA_HUD_AddFadeScreen( -- 2.54.0 From 995777c676657f45b0db2b5d158edc63a9b070cd Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:36:23 +0200 Subject: [PATCH 007/525] Exclude string mode flags from olditem search --- src/lua_hudlib_drawlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 4a58371c8..c621512ba 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -595,7 +595,7 @@ void LUA_HUD_DrawList(huddrawlist_h list) break; } drawitem_t *old = &list->olditems[j++]; - if (old->id == item->id) + if ((old->id & ~3) == (item->id & ~3)) { // gotcha! olditem = old; -- 2.54.0 From 1abf6a4ce1302d46073c28c8b97cecee8e19962a Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:17:06 +0200 Subject: [PATCH 008/525] Add interpolation docs to LUASTUFF --- LUASTUFF.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/LUASTUFF.md b/LUASTUFF.md index 05ca33bd0..96df6b5f8 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -52,6 +52,45 @@ Returns the displayplayer's HUD color. Returns true if colorization is enabled, false otherwise. +## v.interpolate(true) + +Enables HUD interpolation. Each call to a drawing function will have its coordinates interpolated +by assigning an unique ID to every call. +For example, three successive calls to `v.draw` will each have their own ID and interpolation offsets. +Pass `true` to enable interpolation, `false` to disable. + +Alternatively, pass a number to enable interpolation with the specified tag. +Tags allow HUD items drawn by the same call to a drawing function to be differentiated. +Valid tags range from 0-255. +For example, when iterating players, use a unique tag for each player to avoid artifacting: +```lua +for p in players.iterate do + -- enable interpolation, using player numbers as the tag + -- every draw will have different interp offsets per player + v.interpolate(#p) + + -- doesn't matter for unconditional draws like this one... + v.draw(...) + + -- but it does matter if there's a condition! + -- without tags, this patch would warp between players + -- whenever their `someVar` changes + if p.someVar then v.draw(...) end +end + +-- don't want interpolation anymore? then disable it +v.interpolate(false) +``` +NOTE: The default tag for `true` is 0. + +## v.interpString(true) + +Enables string interpolation mode. The next call to a drawing function will have its interpolation offsets +latched and reused for all following draw calls. +Disable with `false` when done. + +When using a custom string drawer, enable this mode to avoid interpolation artifacting when the string changes. + ## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields Same fields as in SRB2 2.2 -- 2.54.0 From 73d0154b6c01757522a02b6c482316bec42924b6 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 May 2024 20:58:41 +0200 Subject: [PATCH 009/525] encore flipcam support --- src/doomtype.h | 3 ++- src/hardware/hw_defs.h | 1 + src/hardware/hw_main.c | 5 +++++ src/hardware/r_opengl/r_opengl.c | 2 ++ src/p_mobj.c | 7 +++++-- src/p_user.c | 17 ++++++++++++----- src/v_video.c | 13 +++++++++++++ 7 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index 3541e2cf6..1dcf47ea7 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -349,7 +349,8 @@ typedef enum postimg_motion, postimg_flip, postimg_heat, - postimg_mirror + postimg_mirror, + postimg_mirrorflip } postimg_t; typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index b55c10bb9..419549d73 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -153,6 +153,7 @@ typedef struct FLOAT centerx, centery; #ifdef USE_FTRANSFORM_MIRROR boolean mirror; // SRB2Kart: Encore Mode + boolean mirrorflip; // Encore Mode with Flipcam #endif boolean shearing; // 14042019 angle_t viewaiming; // 17052019 diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 53f0e8786..aedf40f34 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5449,6 +5449,7 @@ void HWR_DrawSkyBackground(float fpov) dometransform.flip = atransform.flip; dometransform.mirror = atransform.mirror; + dometransform.mirrorflip = atransform.mirrorflip; dometransform.shearing = atransform.shearing; dometransform.viewaiming = atransform.viewaiming; @@ -5575,6 +5576,10 @@ void HWR_SetTransform(float fpov, player_t *player) if (*postprocessor == postimg_mirror) atransform.mirror = true; + atransform.mirrorflip = false; + if (*postprocessor == postimg_mirrorflip) + atransform.mirrorflip = true; + // Set transform. HWD.pfnSetTransform(&atransform); } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 0ea12a793..64bc0d949 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2927,6 +2927,8 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) // mirroring from Kart if (stransform->mirror) pglScalef(-stransform->scalex, stransform->scaley, -stransform->scalez); + else if (stransform->mirrorflip) + pglScalef(-stransform->scalex, -stransform->scaley, -stransform->scalez); else #endif if (stransform->flip) diff --git a/src/p_mobj.c b/src/p_mobj.c index 608d9e821..f6001d457 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3232,6 +3232,7 @@ void P_DestroyRobots(void) boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled) { boolean itsatwodlevel = false; + boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); postimg_t postimg = postimg_none; UINT8 i; @@ -3254,10 +3255,12 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled } } - if (encoremode) + if (encoremode && !flipcam) postimg = postimg_mirror; - else if (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP) + else if (!encoremode && flipcam) postimg = postimg_flip; + else if (encoremode && flipcam) + postimg = postimg_mirrorflip; else if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { camera_t dummycam; diff --git a/src/p_user.c b/src/p_user.c index 6b076a132..4cf785529 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4143,8 +4143,18 @@ static void P_CalcPostImg(player_t *player) } } - if (player->mo->eflags & MFE_VERTICALFLIP) - *type = postimg_flip; + if (!encoremode) // srb2kart + { + if (player->mo->eflags & MFE_VERTICALFLIP) + *type = postimg_flip; + } + else + { + if (player->mo->eflags & MFE_VERTICALFLIP) + *type = postimg_mirrorflip; + else + *type = postimg_mirror; + } #if 1 (void)param; @@ -4159,9 +4169,6 @@ static void P_CalcPostImg(player_t *player) *param = 5; } #endif - - if (encoremode) // srb2kart - *type = postimg_mirror; } void P_DoTimeOver(player_t *player) diff --git a/src/v_video.c b/src/v_video.c index 4ea028cc3..bc1dd4159 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3314,6 +3314,19 @@ Unoptimized version tmpscr[y*vid.width + x2] = srcscr[y*vid.width + x]; } + VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, + viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); + } + else if (type == postimg_mirrorflip) // Flip the screen upside-down and on the x axis + { + UINT8 *tmpscr = screens[4]; + UINT8 *srcscr = screens[0]; + INT32 y, x; + + for (y = yoffset; y < yoffset + viewheight; y++) + for (x = xoffset; x < xoffset + viewwidth; x++) + tmpscr[((yoffset + viewheight - 1 - y) * vid.width) + xoffset + viewwidth - (x - xoffset) - 1] = srcscr[(y * vid.width) + x]; + VID_BlitLinearScreen(tmpscr+vid.width*vid.bpp*yoffset+xoffset, screens[0]+vid.width*vid.bpp*yoffset+xoffset, viewwidth*vid.bpp, viewheight, vid.width*vid.bpp, vid.width); } -- 2.54.0 From 9cd1233c3224bf2000180a1ce866348c4bdd268f Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Thu, 23 May 2024 16:36:26 +0200 Subject: [PATCH 010/525] Dust this crap off a bit --- src/lua_hud.h | 10 +++++----- src/lua_hudlib_drawlist.c | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/lua_hud.h b/src/lua_hud.h index ccaed738d..5d1f41c83 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -42,11 +42,11 @@ enum hud { extern boolean hud_running; -extern boolean hud_interpolate; -extern UINT8 hud_interptag; -extern UINT32 hud_interpcounter; -extern boolean hud_interpstring; -extern boolean hud_interplatch; +extern boolean hud_interpolate; // interpolation enabled +extern UINT8 hud_interptag; // current tag +extern UINT32 hud_interpcounter; // number of HUD hooks ran +extern boolean hud_interpstring; // string mode +extern boolean hud_interplatch; // string mode was toggled boolean LUA_HudEnabled(enum hud option); diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index c621512ba..98f0d45e7 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -318,6 +318,7 @@ static void CalcFillCoords(drawitem_t *item) #define INTERP_LATCH 1 #define INTERP_STRING 2 +#define INTERP_FLAGS 3 // all bits combined static UINT64 GetItemId(void) { @@ -325,7 +326,7 @@ static UINT64 GetItemId(void) return 0; // leave bits 0 and 1 free for the string mode - UINT64 id = ((UINT64)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2); + UINT64 id = ((uintptr_t)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2); if (hud_interplatch) { @@ -580,7 +581,8 @@ void LUA_HUD_DrawList(huddrawlist_h list) drawitem_t *olditem = NULL; const char *itemstr = &list->strbuf[item->stroffset]; - if (item->id) { + if (item->id) + { // find the old one too // this is kinda cursed... we need to check every item // but stop when the first-checked item is reached again @@ -595,16 +597,19 @@ void LUA_HUD_DrawList(huddrawlist_h list) break; } drawitem_t *old = &list->olditems[j++]; - if ((old->id & ~3) == (item->id & ~3)) + if ((old->id & ~INTERP_FLAGS) == (item->id & ~INTERP_FLAGS)) // don't include flags in search { // gotcha! olditem = old; - if (item->id & INTERP_LATCH) { + if (item->id & INTERP_LATCH) + { lerpx = FixedMul(frac, item->x - olditem->x); lerpy = FixedMul(frac, item->y - olditem->y); latchitem = item; oldlatchitem = olditem; - } else if (!(item->id & INTERP_STRING)) { + } + else if (!(item->id & INTERP_STRING)) + { lerpx = FixedMul(frac, item->x - olditem->x); lerpy = FixedMul(frac, item->y - olditem->y); latchitem = NULL; @@ -614,7 +619,9 @@ void LUA_HUD_DrawList(huddrawlist_h list) if (j == stop) break; } - } else { + } + else + { lerpx = lerpy = 0; latchitem = NULL; } -- 2.54.0 From 8de340edbe374e5bbe121792a563f81b62078891 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 May 2024 19:11:11 +0200 Subject: [PATCH 011/525] allow gamepad dpad to hold scroll shit in menu aaa absolute arsepain cant wait to see this breaking kek --- src/d_main.c | 39 +++++++++++++++++++++++++++++++++++++++ src/m_menu.c | 40 +++++++++++++++++++++++++++++++++++++++- src/m_menu.h | 5 +++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 17325e904..f32c825f4 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -617,6 +617,7 @@ static void D_Display(void) // ========================================================================= tic_t rendergametic; +static int menuInputDelayTimer = 0; void D_SRB2Loop(void) { @@ -779,6 +780,44 @@ void D_SRB2Loop(void) } #endif + // this is absolutely awful and i hate it lmao + if (menuactive && (UPKEY || DOWNKEY || LEFTKEY || RIGHTKEY)) + { + event_t myev; + myev.type = ev_keydown; + + if (renderisnewtic) + { + menuInputDelayTimer++; + + if (menuInputDelayTimer >= 19) + { + if (UPKEY) + { + myev.data1 = KEY_UPARROW; + M_Responder(&myev); + } + else if (DOWNKEY) + { + myev.data1 = KEY_DOWNARROW; + M_Responder(&myev); + } + else if (LEFTKEY) + { + myev.data1 = KEY_LEFTARROW; + M_Responder(&myev); + } + else if (RIGHTKEY) + { + myev.data1 = KEY_RIGHTARROW; + M_Responder(&myev); + } + } + } + } + else + menuInputDelayTimer = 0; + // Fully completed frame made. finishprecise = I_GetPreciseTime(); if (!singletics) diff --git a/src/m_menu.c b/src/m_menu.c index cc7d45d33..2dd0a6a38 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3433,6 +3433,11 @@ static void Command_Manual_f(void) itemOn = 0; } +boolean UPKEY = false; +boolean DOWNKEY = false; +boolean LEFTKEY = false; +boolean RIGHTKEY = false; + // // M_Responder // @@ -3464,7 +3469,6 @@ boolean M_Responder(event_t *ev) { ch = ev->data1; - // added 5-2-98 remap virtual keys (mouse & joystick buttons) switch (ch) { case KEY_MOUSE1: @@ -3492,6 +3496,40 @@ boolean M_Responder(event_t *ev) ch = KEY_RIGHTARROW; break; } + + switch (ev->data1) + { + case KEY_HAT1: + UPKEY = true; + break; + case KEY_HAT1 + 1: + DOWNKEY = true; + break; + case KEY_HAT1 + 2: + LEFTKEY = true; + break; + case KEY_HAT1 + 3: + RIGHTKEY = true; + break; + } + } + else if (ev->type == ev_keyup) + { + switch (ev->data1) + { + case KEY_HAT1: + UPKEY = false; + break; + case KEY_HAT1 + 1: + DOWNKEY = false; + break; + case KEY_HAT1 + 2: + LEFTKEY = false; + break; + case KEY_HAT1 + 3: + RIGHTKEY = false; + break; + } } else if (menuactive) { diff --git a/src/m_menu.h b/src/m_menu.h index bba8d3db3..530622ffe 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -74,6 +74,11 @@ typedef enum } menumessagetype_t; void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtype); +extern boolean UPKEY; +extern boolean DOWNKEY; +extern boolean LEFTKEY; +extern boolean RIGHTKEY; + typedef enum { M_NOT_WAITING, -- 2.54.0 From 9f692c1f6a9ba1fd8ca5b41f0a2ef214395f7c68 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 May 2024 19:25:04 +0200 Subject: [PATCH 012/525] change names to be less basic --- src/d_main.c | 12 ++++++------ src/m_menu.c | 28 ++++++++++++++-------------- src/m_menu.h | 8 ++++---- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f32c825f4..bdfa7557d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -781,7 +781,7 @@ void D_SRB2Loop(void) #endif // this is absolutely awful and i hate it lmao - if (menuactive && (UPKEY || DOWNKEY || LEFTKEY || RIGHTKEY)) + if (menuactive && (DPADUPSCROLL || DPADDOWNSCROLL || DPADLEFTSCROLL || DPADRIGHTSCROLL)) { event_t myev; myev.type = ev_keydown; @@ -790,24 +790,24 @@ void D_SRB2Loop(void) { menuInputDelayTimer++; - if (menuInputDelayTimer >= 19) + if (menuInputDelayTimer >= 19) // TICRATE * ( (k+2) (1 - [wz + h + j - q]^2 - [(gk + 2g + k + 1)(h + j) + h - z]^2 - [16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2]^2 calculated by my butt { - if (UPKEY) + if (DPADUPSCROLL) { myev.data1 = KEY_UPARROW; M_Responder(&myev); } - else if (DOWNKEY) + else if (DPADDOWNSCROLL) { myev.data1 = KEY_DOWNARROW; M_Responder(&myev); } - else if (LEFTKEY) + else if (DPADLEFTSCROLL) { myev.data1 = KEY_LEFTARROW; M_Responder(&myev); } - else if (RIGHTKEY) + else if (DPADRIGHTSCROLL) { myev.data1 = KEY_RIGHTARROW; M_Responder(&myev); diff --git a/src/m_menu.c b/src/m_menu.c index 2dd0a6a38..d7dc233b1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3433,10 +3433,10 @@ static void Command_Manual_f(void) itemOn = 0; } -boolean UPKEY = false; -boolean DOWNKEY = false; -boolean LEFTKEY = false; -boolean RIGHTKEY = false; +boolean DPADUPSCROLL = false; +boolean DPADDOWNSCROLL = false; +boolean DPADLEFTSCROLL = false; +boolean DPADRIGHTSCROLL = false; // // M_Responder @@ -3497,37 +3497,37 @@ boolean M_Responder(event_t *ev) break; } - switch (ev->data1) + switch (ev->data1) // if you pressed it set those to true { case KEY_HAT1: - UPKEY = true; + DPADUPSCROLL = true; break; case KEY_HAT1 + 1: - DOWNKEY = true; + DPADDOWNSCROLL = true; break; case KEY_HAT1 + 2: - LEFTKEY = true; + DPADLEFTSCROLL = true; break; case KEY_HAT1 + 3: - RIGHTKEY = true; + DPADRIGHTSCROLL = true; break; } } else if (ev->type == ev_keyup) { - switch (ev->data1) + switch (ev->data1) // if you let go of those set those to false { case KEY_HAT1: - UPKEY = false; + DPADUPSCROLL = false; break; case KEY_HAT1 + 1: - DOWNKEY = false; + DPADDOWNSCROLL = false; break; case KEY_HAT1 + 2: - LEFTKEY = false; + DPADLEFTSCROLL = false; break; case KEY_HAT1 + 3: - RIGHTKEY = false; + DPADRIGHTSCROLL = false; break; } } diff --git a/src/m_menu.h b/src/m_menu.h index 530622ffe..a01c2ddef 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -74,10 +74,10 @@ typedef enum } menumessagetype_t; void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtype); -extern boolean UPKEY; -extern boolean DOWNKEY; -extern boolean LEFTKEY; -extern boolean RIGHTKEY; +extern boolean DPADUPSCROLL; +extern boolean DPADDOWNSCROLL; +extern boolean DPADLEFTSCROLL; +extern boolean DPADRIGHTSCROLL; typedef enum { -- 2.54.0 From 837746c0a99bf540b18ef36de0b527675456cd21 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 May 2024 00:01:58 +0200 Subject: [PATCH 013/525] =?UTF-8?q?declare=20outside=20of=20l=C3=B6=C3=B6p?= =?UTF-8?q?=20also=20add=20const=20in=20r=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hardware/hw_main.c | 9 ++++++--- src/r_bsp.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index aedf40f34..afddd9365 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3530,14 +3530,16 @@ static boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) static void HWR_RenderBSPNode(INT32 bspnum) { + const node_t *bsp; + INT32 side; ps_numbspcalls.value.i++; while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? { - const node_t *bsp = &nodes[bspnum]; + bsp = &nodes[bspnum]; // Decide which side the view point is on. - INT32 side = R_PointOnSide(viewx, viewy, bsp); + side = R_PointOnSide(viewx, viewy, bsp); // Recursively divide front space. if (HWR_PortalCheckBBox(bsp->bbox[side])) @@ -3553,7 +3555,8 @@ static void HWR_RenderBSPNode(INT32 bspnum) // PORTAL CULLING if (portalclipline && portalcullsector) { - if (portalcullsector != subsectors[bspnum & ~NF_SUBSECTOR].sector) + sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector; + if (sect != portalcullsector) return; portalcullsector = NULL; } diff --git a/src/r_bsp.c b/src/r_bsp.c index 83f530f2a..81569186d 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1311,7 +1311,7 @@ INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside) void R_RenderBSPNode(INT32 bspnum) { - node_t *bsp; + const node_t *bsp; INT32 side; ps_numbspcalls.value.i++; -- 2.54.0 From d794de3e83ac0be660d0832fdc3f1584bd27140f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 May 2024 02:21:04 +0200 Subject: [PATCH 014/525] Cull BSP behind a raised floor or lowered ceiling that covers the entire screen https://git.do.srb2.org/KartKrew/RingRacers/-/commit/7b8a564f69688515319ccd425f2b88ffe8b7b120 --- src/r_bsp.c | 25 +++++++++++++++++++------ src/r_bsp.h | 1 + src/r_segs.c | 25 ++++++++++++++----------- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index 81569186d..02f4d8c83 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -39,6 +39,10 @@ drawseg_t *ds_p = NULL; // indicates doors closed wrt automap bugfix: INT32 doorclosed; +// A wall was drawn covering the whole screen, which means we +// can block off the BSP across that seg. +boolean g_walloffscreen; + boolean R_NoEncore(sector_t *sector, boolean ceiling) { boolean invertencore = (GETSECSPECIAL(sector->special, 2) == 15); @@ -163,7 +167,7 @@ crunch: // Clips the given range of columns, but does not include it in the clip list. // Does handle windows, e.g. LineDefs with upper and lower texture. // -static inline void R_ClipPassWallSegment(INT32 first, INT32 last) +static inline void R_ClipPassWallSegment(INT32 first, INT32 last, boolean soliddontrender) { cliprange_t *start; @@ -178,12 +182,14 @@ static inline void R_ClipPassWallSegment(INT32 first, INT32 last) if (last < start->first - 1) { // Post is entirely visible (above start). - R_StoreWallRange(first, last); + if (!soliddontrender) + R_StoreWallRange(first, last); return; } // There is a fragment above *start. - R_StoreWallRange(first, start->first - 1); + if (!soliddontrender) + R_StoreWallRange(first, start->first - 1); } // Bottom contained in start? @@ -193,7 +199,8 @@ static inline void R_ClipPassWallSegment(INT32 first, INT32 last) while (last >= (start+1)->first - 1) { // There is a fragment between two posts. - R_StoreWallRange(start->last + 1, (start+1)->first - 1); + if (!soliddontrender) + R_StoreWallRange(start->last + 1, (start+1)->first - 1); start++; if (last <= start->last) @@ -201,7 +208,8 @@ static inline void R_ClipPassWallSegment(INT32 first, INT32 last) } // There is a fragment after *next. - R_StoreWallRange(start->last + 1, last); + if (!soliddontrender) + R_StoreWallRange(start->last + 1, last); } // @@ -579,10 +587,15 @@ static void R_AddLine(seg_t *line) return; clippass: - R_ClipPassWallSegment(x1, x2 - 1); + g_walloffscreen = false; + if (g_walloffscreen) + R_ClipPassWallSegment(x1, x2 - 1, true); + else + R_ClipPassWallSegment(x1, x2 - 1, false); return; clipsolid: + g_walloffscreen = false; R_ClipSolidWallSegment(x1, x2 - 1); } diff --git a/src/r_bsp.h b/src/r_bsp.h index f0db9066f..2803a90e4 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -32,6 +32,7 @@ extern INT32 checkcoord[12][4]; extern drawseg_t *drawsegs; extern drawseg_t *ds_p; extern INT32 doorclosed; +extern boolean g_walloffscreen; // BSP? void R_ClearClipSegs(void); diff --git a/src/r_segs.c b/src/r_segs.c index 8325e0fa0..6dd66e40f 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2596,23 +2596,26 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (toptexture) { - pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); - pixhighstep = -FixedMul (rw_scalestep,worldhigh); + fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldhighslope, ds_p->scale2); - if (backsector->c_slope) { - fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldhighslope, ds_p->scale2); - pixhighstep = (topfracend-pixhigh)/(range); - } + pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); + pixhighstep = (topfracend-pixhigh)/(range); + + // If the lowest part of a ceiling stretching down covers the entire screen + if (min(pixhigh, topfracend)>>HEIGHTBITS >= viewheight-1) + g_walloffscreen = true; } if (bottomtexture) { + fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2); + pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); - pixlowstep = -FixedMul (rw_scalestep,worldlow); - if (backsector->f_slope) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2); - pixlowstep = (bottomfracend-pixlow)/(range); - } + pixlowstep = (bottomfracend-pixlow)/(range); + + // If the highest part of a floor stretching up covers the entire screen + if ((max(pixlow, bottomfracend)+HEIGHTUNIT-1)>>HEIGHTBITS <= 0) + g_walloffscreen = true; } { -- 2.54.0 From a17a5387ff294d0a0a8916f8f97be508d2f6aec7 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Sat, 25 May 2024 14:08:52 +0200 Subject: [PATCH 015/525] Rename interpString to interpLatch --- src/lua_hudlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index bceb9ebc4..bc56e6688 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1212,7 +1212,7 @@ static int libd_interpolate(lua_State *L) return 0; } -static int libd_interpString(lua_State *L) +static int libd_interpLatch(lua_State *L) { HUDONLY hud_interpstring = hud_interplatch = luaL_checkboolean(L, 1); @@ -1247,7 +1247,7 @@ static luaL_Reg lib_draw[] = { {"getHudColor", libd_getHudColor}, {"useColorHud", libd_useColorHud}, {"interpolate", libd_interpolate}, - {"interpString", libd_interpString}, + {"interpLatch", libd_interpLatch}, {NULL, NULL} }; -- 2.54.0 From 142c01f516f839d48e292ff115203b3b8f0677c0 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Sat, 25 May 2024 14:09:20 +0200 Subject: [PATCH 016/525] Update docs for interpLatch --- LUASTUFF.md | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/LUASTUFF.md b/LUASTUFF.md index 96df6b5f8..79e2a2545 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -83,12 +83,37 @@ v.interpolate(false) ``` NOTE: The default tag for `true` is 0. -## v.interpString(true) +## v.interpLatch(true) -Enables string interpolation mode. The next call to a drawing function will have its interpolation offsets -latched and reused for all following draw calls. -Disable with `false` when done. +Enables interpolation offset latching. The next call to a drawing function will have its lerp offsets +saved and reused for all following draw calls. Disable with `false` when done. +Interpolation cannot easily "snap" between two points; latching can help overcome this by manually +setting the lerp offsets. +```lua +v.interpolate(true) +-- X coordinate for the HUD item +-- every so often, this will wrap around to zero +local x = (leveltime*4) % 256 + +-- draw an interpolated patch, but... when X rolls back to zero, +-- the patch will slide all the way across the screen! +v.draw(x, 100, ...) + +-- this is where interpLatch comes into play +-- enable latching, then draw an invisible patch, +-- moving at the same speed as the visible patch +-- the exact coordinates don't matter, it just has to move at the right speed +v.interpLatch(true) +v.draw(leveltime*4, 0, v.cachePatch("K_TRNULL")) + +-- now we can draw the patch again, and when X becomes zero, +-- it'll snap right back without sliding across the screen +v.draw(x, 150, ...) + +-- don't forget to turn off latching! +v.interpLatch(false) +``` When using a custom string drawer, enable this mode to avoid interpolation artifacting when the string changes. ## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields -- 2.54.0 From 157c95a785ca006d710b5133e1623ae457ef1f2d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 May 2024 14:37:30 +0200 Subject: [PATCH 017/525] super smol optimization to R_DrawRepeatMaskedColumn only maths once not twice lul --- src/r_segs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 6dd66e40f..219b142e0 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -634,12 +634,15 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // Loop through R_DrawMaskedColumn calls static void R_DrawRepeatMaskedColumn(column_t *col) { - while (sprtopscreen < sprbotscreen) { + INT64 z; + while (sprtopscreen < sprbotscreen) + { R_DrawMaskedColumn(col); - if (sprtopscreen + (INT64)dc_texheight*spryscale > (INT64)INT32_MAX) // prevent overflow + z = sprtopscreen + (INT64)dc_texheight*spryscale; + if (z > (INT64)INT32_MAX) // prevent overflow sprtopscreen = INT32_MAX; else - sprtopscreen += dc_texheight*spryscale; + sprtopscreen = z; } } -- 2.54.0 From 518ac3ca280d24287a5c613c054efe03ee40d86c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 May 2024 14:43:52 +0200 Subject: [PATCH 018/525] Turn of FBO downsampling when you turn off screen textures fbo downsampling needs those and if theyre disabled youre essentially seeing nothing at all lol --- src/hardware/hw_main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index afddd9365..24dd67a97 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -185,7 +185,12 @@ static void CV_screentextures_ONChange(void) { ONLY_IF_GL_LOADED if (cv_grscreentextures.value != 3) + { +#ifdef USE_FBO_OGL + CV_Set(&cv_grframebuffer, "Off"); +#endif CV_Set(&cv_grpaletterendering, "Off"); + } HWD.pfnSetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_grscreentextures.value); } -- 2.54.0 From 8774b14fdf6645ead740befc08063b8343a8b3ba Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 May 2024 14:52:58 +0200 Subject: [PATCH 019/525] move some cvars to be registerrerd latur in ogl --- src/hardware/hw_main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 24dd67a97..0a922bbf3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5995,9 +5995,6 @@ void HWR_TogglePaletteRendering(void) //added by Hurdler: console varibale that are saved void HWR_AddCommands(void) { -#ifdef USE_FBO_OGL - CV_RegisterVar(&cv_grframebuffer); -#endif CV_RegisterVar(&cv_grfiltermode); CV_RegisterVar(&cv_granisotropicmode); CV_RegisterVar(&cv_grsolvetjoin); @@ -6007,9 +6004,7 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_fofzfightfix); CV_RegisterVar(&cv_splitwallfix); CV_RegisterVar(&cv_slopepegfix); - - CV_RegisterVar(&cv_grscreentextures); - + CV_RegisterVar(&cv_grrenderdistance); CV_RegisterVar(&cv_grfakecontrast); @@ -6037,6 +6032,12 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grpaletterendering); CV_RegisterVar(&cv_grpalettedepth); CV_RegisterVar(&cv_grflashpal); + +#ifdef USE_FBO_OGL + CV_RegisterVar(&cv_grframebuffer); +#endif + + CV_RegisterVar(&cv_grscreentextures); } // -------------------------------------------------------------------------- -- 2.54.0 From b310168c126c6437ada26ab20ce0061b63827486 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 25 May 2024 16:39:16 +0300 Subject: [PATCH 020/525] Store hooks in a table with integer keys instead of registry with string keys --- src/lua_hooklib.c | 423 +++++++++++++++++++++++++++++----------------- 1 file changed, 271 insertions(+), 152 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index a1ea4fdaf..d7f89bffd 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -86,8 +86,6 @@ struct hook_s }; typedef struct hook_s* hook_p; -#define FMT_HOOKID "hook_%d" - // For each mobj type, a linked list to its thinker and collision hooks. // That way, we don't have to iterate through all the hooks. // We could do that with all other mobj hooks, but it would probably just be @@ -237,9 +235,9 @@ static int lib_addHook(lua_State *L) *lastp = hookp; // set the hook function in the registry. - lua_pushfstring(L, FMT_HOOKID, hook.id); + lua_getfield(L, LUA_REGISTRYINDEX, "hooks"); lua_pushvalue(L, 1); - lua_settable(L, LUA_REGISTRYINDEX); + lua_rawseti(L, -2, hook.id); return 0; } @@ -248,6 +246,10 @@ int LUA_HookLib(lua_State *L) memset(hooksAvailable,0,sizeof(UINT8[(hook_MAX/8)+1])); roothook = NULL; lua_register(L, "addHook", lib_addHook); + + lua_newtable(L); + lua_setfield(L, LUA_REGISTRYINDEX, "hooks"); + return 0; } @@ -255,26 +257,30 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[which/8] & (1<<(which%8)))) return false; I_Assert(mo->type < NUMMOBJTYPES); - + if (!(mobjhooks[MT_NULL] || mobjhooks[mo->type])) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // Look for all generic mobj hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) if (hookp->type == which) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -292,10 +298,9 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) if (hookp->type == which) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -317,20 +322,24 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[which/8] & (1<<(which%8)))) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = playerhooks; hookp; hookp = hookp->next) if (hookp->type == which) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) LUA_PushUserdata(gL, plr, META_PLAYER); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -352,25 +361,30 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which) void LUAh_MapChange(INT16 mapnumber) { hook_p hookp; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_MapChange/8] & (1<<(hook_MapChange%8)))) return; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + lua_pushinteger(gL, mapnumber); for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_MapChange) { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } } - + lua_settop(gL, 0); } @@ -378,22 +392,27 @@ void LUAh_MapChange(INT16 mapnumber) void LUAh_MapLoad(void) { hook_p hookp; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_MapLoad/8] & (1<<(hook_MapLoad%8)))) return; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + lua_pushinteger(gL, gamemap); for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_MapLoad) { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } } lua_settop(gL, 0); @@ -403,25 +422,30 @@ void LUAh_MapLoad(void) void LUAh_PlayerJoin(int playernum) { hook_p hookp; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_PlayerJoin/8] & (1<<(hook_PlayerJoin%8)))) return; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + lua_pushinteger(gL, playernum); for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerJoin) { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } } - + lua_settop(gL, 0); } @@ -429,22 +453,26 @@ void LUAh_PlayerJoin(int playernum) void LUAh_PreThinkFrame(void) { hook_p hookp; + int HOOKSINDEX; // variables used by perf stats int hook_index = 0; precise_t time_taken = 0; if (!gL || !(hooksAvailable[hook_PreThinkFrame/8] & (1<<(hook_PreThinkFrame%8)))) return; - + lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type == hook_PreThinkFrame) - { + { if (cv_perfstats.value == 4) time_taken = I_GetPreciseTime(); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -456,22 +484,22 @@ void LUAh_PreThinkFrame(void) lua_Debug ar; time_taken = I_GetPreciseTime() - time_taken; // we need the function, let's just retrieve it again - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_getinfo(gL, ">S", &ar); PS_SetPreThinkFrameHookInfo(hook_index, time_taken, ar.short_src); hook_index++; } } - + } - lua_pop(gL, 1); // Pop error handler + lua_pop(gL, 2); // Pop error handler and hooks table } // Hook for frame (after mobj and player thinkers) void LUAh_ThinkFrame(void) { hook_p hookp; + int HOOKSINDEX; // variables used by perf stats int hook_index = 0; precise_t time_taken = 0; @@ -481,14 +509,17 @@ void LUAh_ThinkFrame(void) lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type == hook_ThinkFrame) { if (cv_perfstats.value == 3) time_taken = I_GetPreciseTime(); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -500,8 +531,7 @@ void LUAh_ThinkFrame(void) lua_Debug ar; time_taken = I_GetPreciseTime() - time_taken; // we need the function, let's just retrieve it again - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_getinfo(gL, ">S", &ar); PS_SetThinkFrameHookInfo(hook_index, time_taken, ar.short_src); hook_index++; @@ -509,13 +539,14 @@ void LUAh_ThinkFrame(void) } } - lua_pop(gL, 1); // Pop error handler + lua_pop(gL, 2); // Pop error handler and hooks table } // Hook for frame (at end of tick, ie after overlays, precipitation, specials) void LUAh_PostThinkFrame(void) { hook_p hookp; + int HOOKSINDEX; // variables used by perf stats int hook_index = 0; precise_t time_taken = 0; @@ -524,14 +555,17 @@ void LUAh_PostThinkFrame(void) lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type == hook_PostThinkFrame) { if (cv_perfstats.value == 5) time_taken = I_GetPreciseTime(); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -543,8 +577,7 @@ void LUAh_PostThinkFrame(void) lua_Debug ar; time_taken = I_GetPreciseTime() - time_taken; // we need the function, let's just retrieve it again - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_getinfo(gL, ">S", &ar); PS_SetPostThinkFrameHookInfo(hook_index, time_taken, ar.short_src); hook_index++; @@ -552,25 +585,29 @@ void LUAh_PostThinkFrame(void) } } - lua_pop(gL, 1); // Pop error handler + lua_pop(gL, 2); // Pop error handler and hooks table } // Hook for Y_Ticker void LUAh_IntermissionThinker(void) { hook_p hookp; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8)))) return; - lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_pushcfunction(gL, LUA_GetErrorMessage);; + + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type == hook_IntermissionThinker) { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -580,25 +617,29 @@ void LUAh_IntermissionThinker(void) } } - lua_pop(gL, 1); // Pop error handler + lua_pop(gL, 2); // Pop error handler and hooks table } // Hook for Y_VoteTicker void LUAh_VoteThinker(void) { hook_p hookp; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_VoteThinker/8] & (1<<(hook_VoteThinker%8)))) return; lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type == hook_VoteThinker) { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); @@ -608,7 +649,7 @@ void LUAh_VoteThinker(void) } } - lua_pop(gL, 1); // Pop error handler + lua_pop(gL, 2); // Pop error handler and hooks table } @@ -617,29 +658,33 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) { hook_p hookp; UINT8 shouldCollide = 0; // 0 = default, 1 = force yes, 2 = force no. + int HOOKSINDEX; if (!gL || !(hooksAvailable[which/8] & (1<<(which%8)))) return 0; I_Assert(thing1->type < NUMMOBJTYPES); - + if (!(mobjcollidehooks[MT_NULL] || mobjcollidehooks[thing1->type])) return 0; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // Look for all generic mobj collision hooks for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next) if (hookp->type == which) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, thing1, META_MOBJ); LUA_PushUserdata(gL, thing2, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -663,13 +708,12 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) if (hookp->type == which) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, thing1, META_MOBJ); LUA_PushUserdata(gL, thing2, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -698,25 +742,29 @@ boolean LUAh_MobjThinker(mobj_t *mo) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_MobjThinker/8] & (1<<(hook_MobjThinker%8)))) return false; I_Assert(mo->type < NUMMOBJTYPES); - + if (!(mobjthinkerhooks[MT_NULL] || mobjthinkerhooks[mo->type])) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // Look for all generic mobj thinker hooks for (hookp = mobjthinkerhooks[MT_NULL]; hookp; hookp = hookp->next) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -733,10 +781,9 @@ boolean LUAh_MobjThinker(mobj_t *mo) for (hookp = mobjthinkerhooks[mo->type]; hookp; hookp = hookp->next) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -2); if (lua_pcall(gL, 1, 1, 1)) { if (!hookp->error || cv_debug & DBG_LUA) @@ -759,29 +806,33 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_TouchSpecial/8] & (1<<(hook_TouchSpecial%8)))) return false; I_Assert(special->type < NUMMOBJTYPES); - - if (!(mobjhooks[MT_NULL] || mobjhooks[special->type])) + + if (!(mobjhooks[MT_NULL] || mobjhooks[special->type])) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // Look for all generic touch special hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) if (hookp->type == hook_TouchSpecial) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, special, META_MOBJ); LUA_PushUserdata(gL, toucher, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -800,13 +851,12 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) if (hookp->type == hook_TouchSpecial) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, special, META_MOBJ); LUA_PushUserdata(gL, toucher, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -830,31 +880,35 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 { hook_p hookp; UINT8 shouldDamage = 0; // 0 = default, 1 = force yes, 2 = force no. + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_ShouldDamage/8] & (1<<(hook_ShouldDamage%8)))) return 0; I_Assert(target->type < NUMMOBJTYPES); - + if (!(mobjhooks[MT_NULL] || mobjhooks[target->type])) return 0; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // Look for all generic should damage hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) if (hookp->type == hook_ShouldDamage) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); lua_pushinteger(gL, damage); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); @@ -880,15 +934,14 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 if (hookp->type == hook_ShouldDamage) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); lua_pushinteger(gL, damage); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); @@ -919,31 +972,35 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_MobjDamage/8] & (1<<(hook_MobjDamage%8)))) return false; I_Assert(target->type < NUMMOBJTYPES); - + if (!(mobjhooks[MT_NULL] || mobjhooks[target->type])) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // Look for all generic mobj damage hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) if (hookp->type == hook_MobjDamage) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); lua_pushinteger(gL, damage); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); @@ -964,15 +1021,14 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 if (hookp->type == hook_MobjDamage) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); lua_pushinteger(gL, damage); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); lua_pushvalue(gL, -5); @@ -998,29 +1054,33 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_MobjDeath/8] & (1<<(hook_MobjDeath%8)))) return false; I_Assert(target->type < NUMMOBJTYPES); - + if (!(mobjhooks[MT_NULL] || mobjhooks[target->type])) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // Look for all generic mobj death hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) if (hookp->type == hook_MobjDeath) { - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1040,14 +1100,13 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source) if (hookp->type == hook_MobjDeath) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, target, META_MOBJ); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1072,22 +1131,26 @@ boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_BotTiccmd/8] & (1<<(hook_BotTiccmd%8)))) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_BotTiccmd) { - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, bot, META_PLAYER); LUA_PushUserdata(gL, cmd, META_TICCMD); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1112,23 +1175,27 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_PlayerCmd/8] & (1<<(hook_PlayerCmd%8)))) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + hook_cmd_running = true; for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerCmd) { - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, cmd, META_TICCMD); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 1, 1)) { @@ -1153,23 +1220,27 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_BotAI/8] & (1<<(hook_BotAI%8)))) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_BotAI && (hookp->s.skinname == NULL || !strcmp(hookp->s.skinname, ((skin_t*)tails->skin)->name))) { - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, sonic, META_MOBJ); LUA_PushUserdata(gL, tails, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 8, 1)) { @@ -1181,10 +1252,10 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) } // This turns forward, backward, left, right, jump, and spin into a proper ticcmd for tails. - if (lua_istable(gL, 2+1)) { + if (lua_istable(gL, -8)) { boolean forward=false, backward=false, left=false, right=false, strafeleft=false, straferight=false, jump=false, spin=false; #define CHECKFIELD(field) \ - lua_getfield(gL, 2+1, #field);\ + lua_getfield(gL, -8, #field);\ if (lua_toboolean(gL, -1))\ field = true;\ lua_pop(gL, 1); @@ -1200,7 +1271,7 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) #undef CHECKFIELD B_KeysToTiccmd(tails, cmd, forward, backward, left, right, strafeleft, straferight, jump, spin); } else - B_KeysToTiccmd(tails, cmd, lua_toboolean(gL, 2+1), lua_toboolean(gL, 2+2), lua_toboolean(gL, 2+3), lua_toboolean(gL, 2+4), lua_toboolean(gL, 2+5), lua_toboolean(gL, 2+6), lua_toboolean(gL, 2+7), lua_toboolean(gL, 2+8)); + B_KeysToTiccmd(tails, cmd, lua_toboolean(gL, -8), lua_toboolean(gL, -7), lua_toboolean(gL, -6), lua_toboolean(gL, -5), lua_toboolean(gL, -4), lua_toboolean(gL, -3), lua_toboolean(gL, -2), lua_toboolean(gL, -1)); lua_pop(gL, 8); hooked = true; @@ -1215,30 +1286,34 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_LinedefExecute/8] & (1<<(hook_LinedefExecute%8)))) return 0; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = linedefexecutorhooks; hookp; hookp = hookp->next) if (!strcmp(hookp->s.funcname, line->text)) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, line, META_LINE); LUA_PushUserdata(gL, mo, META_MOBJ); LUA_PushUserdata(gL, sector, META_SECTOR); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); if (lua_pcall(gL, 3, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } hooked = true; } @@ -1254,16 +1329,21 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_PlayerMsg/8] & (1<<(hook_PlayerMsg%8)))) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerMsg) { - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c @@ -1285,8 +1365,7 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute) else lua_pushboolean(gL, false); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); lua_pushvalue(gL, -6); @@ -1313,24 +1392,28 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_HurtMsg/8] & (1<<(hook_HurtMsg%8)))) return false; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_HurtMsg && (hookp->s.mt == MT_NULL || (inflictor && hookp->s.mt == inflictor->type))) { - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1354,61 +1437,69 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) { hook_p hookp; int errorhandlerindex; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_NetVars/8] & (1<<(hook_NetVars%8)))) return; // stack: tables I_Assert(lua_gettop(gL) > 0); I_Assert(lua_istable(gL, -1)); - + lua_pushcfunction(gL, LUA_GetErrorMessage); errorhandlerindex = lua_gettop(gL); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // tables becomes an upvalue of archFunc - lua_pushvalue(gL, -2); + lua_pushvalue(gL, -3); lua_pushcclosure(gL, archFunc, 1); // stack: tables, archFunc for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_NetVars) { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -2); // archFunc if (lua_pcall(gL, 1, 0, errorhandlerindex)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } } - lua_pop(gL, 2); // Pop archFunc and error handler + lua_pop(gL, 3); // Pop archFunc, error handler and hooks table // stack: tables } void LUAh_PlayerQuit(player_t *plr, int reason) { hook_p hookp; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_PlayerQuit/8] & (1<<(hook_PlayerQuit%8)))) return; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerQuit) { - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit lua_pushinteger(gL, reason); // Reason for quitting } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -3); lua_pushvalue(gL, -3); if (lua_pcall(gL, 2, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } } @@ -1421,6 +1512,7 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_MusicChange/8] & (1<<(hook_MusicChange%8)))) return false; @@ -1428,11 +1520,14 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_MusicChange) { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushstring(gL, oldname); lua_pushstring(gL, newname); lua_pushinteger(gL, *mflags); @@ -1480,26 +1575,30 @@ UINT8 LUAh_ShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source) { hook_p hookp; UINT8 shouldDamage = 0; // 0 = default, 1 = force yes, 2 = force no. + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_ShouldSpin/8] & (1<<(hook_ShouldSpin%8)))) return 0; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // We can afford not to check for mobj type because it will always be MT_PLAYER in this case. for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_ShouldSpin) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1529,26 +1628,30 @@ UINT8 LUAh_ShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source) { hook_p hookp; UINT8 shouldDamage = 0; // 0 = default, 1 = force yes, 2 = force no. + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_ShouldExplode/8] & (1<<(hook_ShouldExplode%8)))) return 0; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // We can afford not to check for mobj type because it will always be MT_PLAYER in this case. for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_ShouldExplode) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1578,26 +1681,30 @@ UINT8 LUAh_ShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source) { hook_p hookp; UINT8 shouldDamage = 0; // 0 = default, 1 = force yes, 2 = force no. + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_ShouldSquish/8] & (1<<(hook_ShouldSquish%8)))) return 0; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // We can afford not to check for mobj type because it will always be MT_PLAYER in this case. for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_ShouldSquish) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1627,26 +1734,30 @@ boolean LUAh_PlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_PlayerSpin/8] & (1<<(hook_PlayerSpin%8)))) return 0; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // We can afford not to look for target->type because it will always be MT_PLAYER. for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerSpin) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1670,26 +1781,30 @@ boolean LUAh_PlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_PlayerSquish/8] & (1<<(hook_PlayerSquish%8)))) return 0; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // We can afford not to look for target->type because it will always be MT_PLAYER. for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerSquish) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1713,26 +1828,30 @@ boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source) { hook_p hookp; boolean hooked = false; + int HOOKSINDEX; if (!gL || !(hooksAvailable[hook_PlayerExplode/8] & (1<<(hook_PlayerExplode%8)))) return 0; lua_settop(gL, 0); lua_pushcfunction(gL, LUA_GetErrorMessage); + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + // We can afford not to look for target->type because it will always be MT_PLAYER. for (hookp = roothook; hookp; hookp = hookp->next) if (hookp->type == hook_PlayerExplode) { ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 1) + if (lua_gettop(gL) == 2) { LUA_PushUserdata(gL, player, META_PLAYER); LUA_PushUserdata(gL, inflictor, META_MOBJ); LUA_PushUserdata(gL, source, META_MOBJ); } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); lua_pushvalue(gL, -4); @@ -1749,4 +1868,4 @@ boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source) } lua_settop(gL, 0); return hooked; -} \ No newline at end of file +} -- 2.54.0 From 8cf6050d10ae94245a87f10ce7ea2299ef969336 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 May 2024 01:35:44 +0200 Subject: [PATCH 021/525] Only call the Lua API for overridden actions --- src/dehacked.c | 33 ++-- src/dehacked.h | 1 + src/info.h | 225 +++++++++++++++++++++++++ src/lua_infolib.c | 22 +-- src/lua_script.c | 5 + src/p_enemy.c | 406 +++++++++++++++++++++++----------------------- 6 files changed, 457 insertions(+), 235 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8b181a563..c7ab9a536 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1419,25 +1419,10 @@ static void readhuditem(MYFILE *f, INT32 num) Z_Free(s); } -/* -Sprite number = 10 -Sprite subnumber = 32968 -Duration = 200 -Next frame = 200 -*/ -/** Action pointer for reading actions from Dehacked lumps. - */ -typedef struct -{ - actionf_t action; ///< Function pointer corresponding to the actual action. - const char *name; ///< Name of the action in ALL CAPS. -} actionpointer_t; - -/** Array mapping action names to action functions. - * Names must be in ALL CAPS for case insensitive comparisons. - */ -static actionpointer_t actionpointers[] = +// IMPORTANT! +// DO NOT FORGET TO SYNC THIS LIST WITH THE ACTIONNUM ENUM IN INFO.H +actionpointer_t actionpointers[] = { {{A_Explode}, "A_EXPLODE"}, {{A_Pain}, "A_PAIN"}, @@ -1592,6 +1577,7 @@ static actionpointer_t actionpointers[] = {{A_FZBoomSmoke}, "A_FZBOOMSMOKE"}, //SRB2kart {{A_RandomShadowFrame}, "A_RANDOMSHADOWFRAME"}, //SRB2kart {{A_RoamingShadowThinker}, "A_ROAMINGSHADOWTHINKER"}, //SRB2kart + {{A_MayonakaArrow}, "A_MAYONAKAARROW"}, //SRB2kart {{A_ReaperThinker}, "A_REAPERTHINKER"}, //SRB2kart {{A_MementosTPParticles}, "A_MEMENTOSTPPARTICLES"}, //SRB2kart {{A_FlameParticle}, "A_FLAMEPARTICLE"}, // SRB2kart @@ -9422,4 +9408,13 @@ void LUA_SetActionByName(void *state, const char *actiontocompare) return; } } -} \ No newline at end of file +} + +enum actionnum LUA_GetActionNumByName(const char *actiontocompare) +{ + size_t z; + for (z = 0; actionpointers[z].name; z++) + if (fasticmp(actiontocompare, actionpointers[z].name)) + return z; + return z; +} diff --git a/src/dehacked.h b/src/dehacked.h index 51a838127..33621a3ac 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -41,6 +41,7 @@ fixed_t get_number(const char *word); boolean LUA_SetLuaAction(void *state, const char *actiontocompare); const char *LUA_GetActionName(void *action); void LUA_SetActionByName(void *state, const char *actiontocompare); +enum actionnum LUA_GetActionNumByName(const char *actiontocompare); extern boolean deh_loaded; diff --git a/src/info.h b/src/info.h index 9b931ff65..b1955340b 100644 --- a/src/info.h +++ b/src/info.h @@ -22,6 +22,229 @@ // dehacked.c now has lists for the more named enums! PLEASE keep them up to date! // For great modding!! +/** Action pointer for reading actions from Dehacked lumps. + */ +typedef struct +{ + actionf_t action; ///< Function pointer corresponding to the actual action. + const char *name; ///< Name of the action in ALL CAPS. +} actionpointer_t; + +/** Array mapping action names to action functions. + * Names must be in ALL CAPS for case insensitive comparisons. + */ +extern actionpointer_t actionpointers[]; + +// IMPORTANT! +// DO NOT FORGET TO SYNC THIS LIST WITH THE ACTIONPOINTERS ARRAY IN DEHACKED.C +enum actionnum +{ + A_EXPLODE = 0, + A_PAIN, + A_FALL, + A_MONITORPOP, + A_LOOK, + A_CHASE, + A_FACESTABCHASE, + A_FACETARGET, + A_FACETRACER, + A_SCREAM, + A_BOSSDEATH, + A_CUSTOMPOWER, + A_GIVEWEAPON, + A_RINGSHIELD, + A_RINGBOX, + A_INVINCIBILITY, + A_SUPERSNEAKERS, + A_BUNNYHOP, + A_BUBBLESPAWN, + A_FANBUBBLESPAWN, + A_BUBBLERISE, + A_BUBBLECHECK, + A_AWARDSCORE, + A_EXTRALIFE, + A_BOMBSHIELD, + A_JUMPSHIELD, + A_WATERSHIELD, + A_FORCESHIELD, + A_PITYSHIELD, + A_GRAVITYBOX, + A_SCORERISE, + A_PARTICLESPAWN, + A_ATTRACTCHASE, + A_DROPMINE, + A_FISHJUMP, + A_THROWNRING, + A_GRENADERING, // SRB2kart + A_SETSOLIDSTEAM, + A_UNSETSOLIDSTEAM, + A_SIGNPLAYER, + A_OVERLAYTHINK, + A_JETCHASE, + A_JETBTHINK, + A_JETGTHINK, + A_JETGSHOOT, + A_SHOOTBULLET, + A_MINUSDIGGING, + A_MINUSPOPUP, + A_MINUSCHECK, + A_CHICKENCHECK, + A_MOUSETHINK, + A_DETONCHASE, + A_CAPECHASE, + A_ROTATESPIKEBALL, + A_SLINGAPPEAR, + A_MACEROTATE, + A_UNIDUSBALL, + A_ROCKSPAWN, + A_SETFUSE, + A_CRAWLACOMMANDERTHINK, + A_SMOKETRAILER, + A_RINGEXPLODE, + A_OLDRINGEXPLODE, + A_MIXUP, + A_RECYCLEPOWERS, + A_BOSS1CHASE, + A_FOCUSTARGET, + A_BOSS2CHASE, + A_BOSS2POGO, + A_BOSSZOOM, + A_BOSSSCREAM, + A_BOSS2TAKEDAMAGE, + A_BOSS7CHASE, + A_GOOPSPLAT, + A_BOSS2POGOSFX, + A_BOSS2POGOTARGET, + A_BOSSJETFUME, + A_EGGMANBOX, + A_TURRETFIRE, + A_SUPERTURRETFIRE, + A_TURRETSTOP, + A_JETJAWROAM, + A_JETJAWCHOMP, + A_POINTYTHINK, + A_CHECKBUDDY, + A_HOODTHINK, + A_ARROWCHECK, + A_SNAILERTHINK, + A_SHARPCHASE, + A_SHARPSPIN, + A_VULTUREVTOL, + A_VULTURECHECK, + A_SKIMCHASE, + A_1UPTHINKER, + A_SKULLATTACK, + A_LOBSHOT, + A_FIRESHOT, + A_SUPERFIRESHOT, + A_BOSSFIRESHOT, + A_BOSS7FIREMISSILES, + A_BOSS1LASER, + A_BOSS4REVERSE, + A_BOSS4SPEEDUP, + A_BOSS4RAISE, + A_SPARKFOLLOW, + A_BUZZFLY, + A_GUARDCHASE, + A_EGGSHIELD, + A_SETREACTIONTIME, + A_BOSS1SPIKEBALLS, + A_BOSS3TAKEDAMAGE, + A_BOSS3PATH, + A_LINEDEFEXECUTE, + A_PLAYSEESOUND, + A_PLAYATTACKSOUND, + A_PLAYACTIVESOUND, + A_SPAWNOBJECTABSOLUTE, + A_SPAWNOBJECTRELATIVE, + A_CHANGEANGLERELATIVE, + A_CHANGEANGLEABSOLUTE, + A_ROLLANGLE, + A_CHANGEROLLANGLERELATIVE, + A_CHANGEROLLANGLEABSOLUTE, + A_PLAYSOUND, + A_FINDTARGET, + A_FINDTRACER, + A_SETTICS, + A_SETRANDOMTICS, + A_CHANGECOLORRELATIVE, + A_CHANGECOLORABSOLUTE, + A_MOVERELATIVE, + A_MOVEABSOLUTE, + A_THRUST, + A_ZTHRUST, + A_SETTARGETSTARGET, + A_SETOBJECTFLAGS, + A_SETOBJECTFLAGS2, + A_RANDOMSTATE, + A_RANDOMSTATERANGE, + A_DUALACTION, + A_REMOTEACTION, + A_TOGGLEFLAMEJET, + A_ITEMPOP, // SRB2kart + A_JAWZCHASE, // SRB2kart + A_JAWZEXPLODE, // SRB2kart + A_SPBCHASE, // SRB2kart + A_MINEEXPLODE, // SRB2kart + A_BALLHOGEXPLODE, // SRB2kart + A_LIGHTNINGFOLLOWPLAYER, //SRB2kart + A_FZBOOMFLASH, //SRB2kart + A_FZBOOMSMOKE, //SRB2kart + A_RANDOMSHADOWFRAME, //SRB2kart + A_ROAMINGSHADOWTHINKER, //SRB2kart + A_MAYONAKAARROW, //SRB2kart + A_REAPERTHINKER, //SRB2kart + A_MEMENTOSTPPARTICLES, //SRB2kart + A_FLAMEPARTICLE, // SRB2kart + A_ORBITNIGHTS, + A_GHOSTME, + A_SETOBJECTSTATE, + A_SETOBJECTTYPESTATE, + A_KNOCKBACK, + A_PUSHAWAY, + A_RINGDRAIN, + A_SPLITSHOT, + A_MISSILESPLIT, + A_MULTISHOT, + A_INSTALOOP, + A_CUSTOM3DROTATE, + A_SEARCHFORPLAYERS, + A_CHECKRANDOM, + A_CHECKTARGETRINGS, + A_CHECKRINGS, + A_CHECKTOTALRINGS, + A_CHECKHEALTH, + A_CHECKRANGE, + A_CHECKHEIGHT, + A_CHECKTRUERANGE, + A_CHECKTHINGCOUNT, + A_CHECKAMBUSH, + A_CHECKCUSTOMVALUE, + A_CHECKCUSVALMEMO, + A_SETCUSTOMVALUE, + A_USECUSVALMEMO, + A_RELAYCUSTOMVALUE, + A_CUSVALACTION, + A_FORCESTOP, + A_FORCEWIN, + A_SPIKERETRACT, + A_INFOSTATE, + A_REPEAT, + A_SETSCALE, + A_REMOTEDAMAGE, + A_HOMINGCHASE, + A_TRAPSHOT, + A_VILETARGET, + A_VILEATTACK, + A_VILEFIRE, + A_BRAKCHASE, + A_BRAKFIRESHOT, + A_BRAKLOBSHOT, + A_NAPALMSCATTER, + A_SPAWNFRESHCOPY, + NUMACTIONS +}; + // IMPORTANT NOTE: If you add/remove from this list of action // functions, don't forget to update them in dehacked.c! void A_Explode(); @@ -228,6 +451,8 @@ void A_BrakLobShot(); void A_NapalmScatter(); void A_SpawnFreshCopy(); +extern boolean actionsoverridden[NUMACTIONS]; + // ratio of states to sprites to mobj types is roughly 6 : 1 : 1 #define NUMMOBJFREESLOTS 1024 #define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS diff --git a/src/lua_infolib.c b/src/lua_infolib.c index c94b42b5b..c8b60d165 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -23,7 +23,7 @@ #include "lua_hud.h" // hud_running errors #include "lua_hook.h" // cmd errors -boolean LUA_CallAction(const char *action, mobj_t *actor); +boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); state_t *astate; enum sfxinfo_read { @@ -52,6 +52,8 @@ const char *const sfxinfo_wopt[] = { "flags", NULL}; +boolean actionsoverridden[NUMACTIONS] = {false}; + // // Sprite Names // @@ -276,27 +278,21 @@ boolean LUA_SetLuaAction(void *stv, const char *action) return true; // action successfully set. } -boolean LUA_CallAction(const char *csaction, mobj_t *actor) +boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor) { - I_Assert(csaction != NULL); I_Assert(actor != NULL); - if (!gL) // Lua isn't loaded, + if (!actionsoverridden[actionnum]) // The action is not overriden, return false; // action not called. - if (superstack && fasticmp(csaction, superactions[superstack-1])) // the action is calling itself, - return false; // let it call the hardcoded function instead. + if (superstack && fasticmp(actionpointers[actionnum].name, superactions[superstack-1])) // the action is calling itself, + return false; // let it call the hardcoded function lua_pushcfunction(gL, LUA_GetErrorMessage); // grab function by uppercase name. lua_getfield(gL, LUA_REGISTRYINDEX, LREG_ACTIONS); - { - char *action = Z_StrDup(csaction); - strupr(action); - lua_getfield(gL, -1, action); - Z_Free(action); - } + lua_getfield(gL, -1, actionpointers[actionnum].name); lua_remove(gL, -2); // pop LREG_ACTIONS if (lua_isnil(gL, -1)) // no match @@ -319,7 +315,7 @@ boolean LUA_CallAction(const char *csaction, mobj_t *actor) lua_pushinteger(gL, var1); lua_pushinteger(gL, var2); - superactions[superstack] = csaction; + superactions[superstack] = actionpointers[actionnum].name; ++superstack; LUA_Call(gL, 3, 0, -(2 + 3)); diff --git a/src/lua_script.c b/src/lua_script.c index 3af655efe..9ba412202 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -152,6 +152,7 @@ static int noglobals(lua_State *L) { const char *csname; char *name; + enum actionnum actionnum; lua_remove(L, 1); // we're not gonna be using _G csname = lua_tostring(L, 1); @@ -170,6 +171,10 @@ static int noglobals(lua_State *L) lua_rawset(L, -3); // rawset doesn't trigger this metatable again. // otherwise we would've used setfield, obviously. + actionnum = LUA_GetActionNumByName(name); + if (actionnum < NUMACTIONS) + actionsoverridden[actionnum] = true; + Z_Free(name); return 0; } diff --git a/src/p_enemy.c b/src/p_enemy.c index 42fc2bcf7..caa85e331 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -29,7 +29,7 @@ #include "hardware/hw3sound.h" #endif -boolean LUA_CallAction(const char *action, mobj_t *actor); +boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); INT32 var1; INT32 var2; @@ -781,7 +781,7 @@ void A_Look(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Look", actor)) + if (LUA_CallAction(A_LOOK, actor)) return; if (!P_LookForPlayers(actor, locvar1 & 65535, false , FixedMul((locvar1 >> 16)*FRACUNIT, actor->scale))) @@ -817,7 +817,7 @@ void A_Chase(mobj_t *actor) INT32 delta; INT32 locvar1 = var1; - if (LUA_CallAction("A_Chase", actor)) + if (LUA_CallAction(A_CHASE, actor)) return; I_Assert(actor != NULL); @@ -908,7 +908,7 @@ void A_FaceStabChase(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_FaceStabChase", actor)) + if (LUA_CallAction(A_FACESTABCHASE, actor)) return; if (actor->reactiontime) @@ -994,7 +994,7 @@ nomissile: // void A_JetJawRoam(mobj_t *actor) { - if (LUA_CallAction("A_JetJawRoam", actor)) + if (LUA_CallAction(A_JETJAWROAM, actor)) return; if (actor->reactiontime) @@ -1023,7 +1023,7 @@ void A_JetJawChomp(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_JetJawChomp", actor)) + if (LUA_CallAction(A_JETJAWCHOMP, actor)) return; // turn towards movement direction if not there yet @@ -1070,7 +1070,7 @@ void A_PointyThink(mobj_t *actor) boolean firsttime = true; INT32 sign; - if (LUA_CallAction("A_PointyThink", actor)) + if (LUA_CallAction(A_POINTYTHINK, actor)) return; actor->momx = actor->momy = actor->momz = 0; @@ -1168,7 +1168,7 @@ void A_CheckBuddy(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_CheckBuddy", actor)) + if (LUA_CallAction(A_CHECKBUDDY, actor)) return; if (locvar1 && (!actor->tracer || actor->tracer->health <= 0)) @@ -1186,7 +1186,7 @@ void A_CheckBuddy(mobj_t *actor) // void A_HoodThink(mobj_t *actor) { - if (LUA_CallAction("A_HoodThink", actor)) + if (LUA_CallAction(A_HOODTHINK, actor)) return; // Currently in the air... @@ -1247,7 +1247,7 @@ void A_ArrowCheck(mobj_t *actor) angle_t angle; fixed_t dist; - if (LUA_CallAction("A_ArrowCheck", actor)) + if (LUA_CallAction(A_ARROWCHECK, actor)) return; // Movement vector @@ -1285,7 +1285,7 @@ void A_ArrowCheck(mobj_t *actor) // void A_SnailerThink(mobj_t *actor) { - if (LUA_CallAction("A_SnailerThink", actor)) + if (LUA_CallAction(A_SNAILERTHINK, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) @@ -1358,7 +1358,7 @@ void A_SnailerThink(mobj_t *actor) // void A_SharpChase(mobj_t *actor) { - if (LUA_CallAction("A_SharpChase", actor)) + if (LUA_CallAction(A_SHARPCHASE, actor)) return; if (!actor->health) @@ -1416,7 +1416,7 @@ void A_SharpChase(mobj_t *actor) // void A_SharpSpin(mobj_t *actor) { - if (LUA_CallAction("A_SharpSpin", actor)) + if (LUA_CallAction(A_SHARPSPIN, actor)) return; if (!actor->health) @@ -1452,7 +1452,7 @@ void A_SharpSpin(mobj_t *actor) // void A_VultureVtol(mobj_t *actor) { - if (LUA_CallAction("A_VultureVtol", actor)) + if (LUA_CallAction(A_VULTUREVTOL, actor)) return; if (!actor->target) @@ -1487,7 +1487,7 @@ void A_VultureVtol(mobj_t *actor) // void A_VultureCheck(mobj_t *actor) { - if (LUA_CallAction("A_VultureCheck", actor)) + if (LUA_CallAction(A_VULTURECHECK, actor)) return; if (actor->momx || actor->momy) @@ -1513,7 +1513,7 @@ void A_SkimChase(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_SkimChase", actor)) + if (LUA_CallAction(A_SKIMCHASE, actor)) return; if (actor->reactiontime) @@ -1599,7 +1599,7 @@ nomissile: // void A_FaceTarget(mobj_t *actor) { - if (LUA_CallAction("A_FaceTarget", actor)) + if (LUA_CallAction(A_FACETARGET, actor)) return; if (!actor->target) @@ -1617,7 +1617,7 @@ void A_FaceTarget(mobj_t *actor) // void A_FaceTracer(mobj_t *actor) { - if (LUA_CallAction("A_FaceTracer", actor)) + if (LUA_CallAction(A_FACETRACER, actor)) return; if (!actor->tracer) @@ -1646,7 +1646,7 @@ void A_LobShot(mobj_t *actor) fixed_t vertical, horizontal; fixed_t airtime = var2 & 65535; - if (LUA_CallAction("A_LobShot", actor)) + if (LUA_CallAction(A_LOBSHOT, actor)) return; if (!actor->target) @@ -1746,7 +1746,7 @@ void A_FireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_FireShot", actor)) + if (LUA_CallAction(A_FIRESHOT, actor)) return; if (!actor->target) @@ -1784,7 +1784,7 @@ void A_SuperFireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SuperFireShot", actor)) + if (LUA_CallAction(A_SUPERFIRESHOT, actor)) return; if (!actor->target) @@ -1830,7 +1830,7 @@ void A_BossFireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_BossFireShot", actor)) + if (LUA_CallAction(A_BOSSFIRESHOT, actor)) return; if (!actor->target) @@ -1911,7 +1911,7 @@ void A_Boss7FireMissiles(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Boss7FireMissiles", actor)) + if (LUA_CallAction(A_BOSS7FIREMISSILES, actor)) return; if (!actor->target) @@ -1968,7 +1968,7 @@ void A_Boss1Laser(mobj_t *actor) angle_t angle; mobj_t *point; - if (LUA_CallAction("A_Boss1Laser", actor)) + if (LUA_CallAction(A_BOSS1LASER, actor)) return; if (!actor->target) @@ -2069,7 +2069,7 @@ void A_FocusTarget(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_FocusTarget", actor)) + if (LUA_CallAction(A_FOCUSTARGET, actor)) return; if (actor->target) @@ -2119,7 +2119,7 @@ void A_Boss4Reverse(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; - if (LUA_CallAction("A_Boss4Reverse", actor)) + if (LUA_CallAction(A_BOSS4REVERSE, actor)) return; S_StartSound(NULL, locvar1); @@ -2141,7 +2141,7 @@ void A_Boss4SpeedUp(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; - if (LUA_CallAction("A_Boss4SpeedUp", actor)) + if (LUA_CallAction(A_BOSS4SPEEDUP, actor)) return; S_StartSound(NULL, locvar1); @@ -2159,7 +2159,7 @@ void A_Boss4Raise(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; - if (LUA_CallAction("A_Boss4Raise", actor)) + if (LUA_CallAction(A_BOSS4RAISE, actor)) return; S_StartSound(NULL, locvar1); @@ -2189,7 +2189,7 @@ void A_SkullAttack(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SkullAttack", actor)) + if (LUA_CallAction(A_SKULLATTACK, actor)) return; if (!actor->target) @@ -2239,7 +2239,7 @@ void A_BossZoom(mobj_t *actor) angle_t an; INT32 dist; - if (LUA_CallAction("A_BossZoom", actor)) + if (LUA_CallAction(A_BOSSZOOM, actor)) return; if (!actor->target) @@ -2279,7 +2279,7 @@ void A_BossScream(mobj_t *actor) INT32 locvar2 = var2; mobjtype_t explodetype; - if (LUA_CallAction("A_BossScream", actor)) + if (LUA_CallAction(A_BOSSSCREAM, actor)) return; switch (locvar1) @@ -2326,7 +2326,7 @@ void A_BossScream(mobj_t *actor) // void A_Scream(mobj_t *actor) { - if (LUA_CallAction("A_Scream", actor)) + if (LUA_CallAction(A_SCREAM, actor)) return; if (actor->tracer && (actor->tracer->type == MT_SHELL || actor->tracer->type == MT_FIREBALL)) @@ -2344,7 +2344,7 @@ void A_Scream(mobj_t *actor) // void A_Pain(mobj_t *actor) { - if (LUA_CallAction("A_Pain", actor)) + if (LUA_CallAction(A_PAIN, actor)) return; if (actor->info->painsound) @@ -2363,7 +2363,7 @@ void A_Pain(mobj_t *actor) // void A_Fall(mobj_t *actor) { - if (LUA_CallAction("A_Fall", actor)) + if (LUA_CallAction(A_FALL, actor)) return; // actor is on ground, it can be walked over @@ -2392,7 +2392,7 @@ void A_1upThinker(mobj_t *actor) fixed_t temp; INT32 closestplayer = -1; - if (LUA_CallAction("A_1upThinker", actor)) + if (LUA_CallAction(A_1UPTHINKER, actor)) return; for (i = 0; i < MAXPLAYERS; i++) @@ -2450,7 +2450,7 @@ void A_MonitorPop(mobj_t *actor) mobjtype_t item = 0; //mobjtype_t newbox; - if (LUA_CallAction("A_MonitorPop", actor)) + if (LUA_CallAction(A_MONITORPOP, actor)) return; // de-solidify @@ -2588,7 +2588,7 @@ for (i = cvar.value; i; --i) spawnchance[numchoices++] = type // void A_Explode(mobj_t *actor) { - if (LUA_CallAction("A_Explode", actor)) + if (LUA_CallAction(A_EXPLODE, actor)) return; P_RadiusAttack(actor, actor->target, actor->info->damage); @@ -2608,7 +2608,7 @@ void A_BossDeath(mobj_t *mo) line_t junk; INT32 i; - if (LUA_CallAction("A_BossDeath", mo)) + if (LUA_CallAction(A_BOSSDEATH, mo)) return; P_LinedefExecute(LE_BOSSDEAD, mo, NULL); @@ -2777,7 +2777,7 @@ void A_CustomPower(mobj_t *actor) INT32 locvar2 = var2; boolean spawnshield = false; - if (LUA_CallAction("A_CustomPower", actor)) + if (LUA_CallAction(A_CUSTOMPOWER, actor)) return; if (!actor->target || !actor->target->player) @@ -2817,7 +2817,7 @@ void A_GiveWeapon(mobj_t *actor) player_t *player; INT32 locvar1 = var1; - if (LUA_CallAction("A_GiveWeapon", actor)) + if (LUA_CallAction(A_GIVEWEAPON, actor)) return; if (!actor->target || !actor->target->player) @@ -2850,7 +2850,7 @@ void A_JumpShield(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_JumpShield", actor)) + if (LUA_CallAction(A_JUMPSHIELD, actor)) return; if (!actor->target || !actor->target->player) @@ -2881,7 +2881,7 @@ void A_RingShield(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_RingShield", actor)) + if (LUA_CallAction(A_RINGSHIELD, actor)) return; if (!actor->target || !actor->target->player) @@ -2913,7 +2913,7 @@ void A_RingBox(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_RingBox", actor)) + if (LUA_CallAction(A_RINGBOX, actor)) return; if (!actor->target || !actor->target->player) @@ -2940,7 +2940,7 @@ void A_Invincibility(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_Invincibility", actor)) + if (LUA_CallAction(A_INVINCIBILITY, actor)) return; if (!actor->target || !actor->target->player) @@ -2972,7 +2972,7 @@ void A_SuperSneakers(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_SuperSneakers", actor)) + if (LUA_CallAction(A_SUPERSNEAKERS, actor)) return; if (!actor->target || !actor->target->player) @@ -3008,7 +3008,7 @@ void A_AwardScore(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_AwardScore", actor)) + if (LUA_CallAction(A_AWARDSCORE, actor)) return; if (!actor->target || !actor->target->player) @@ -3035,7 +3035,7 @@ void A_ExtraLife(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_ExtraLife", actor)) + if (LUA_CallAction(A_EXTRALIFE, actor)) return; if (!actor->target || !actor->target->player) @@ -3074,7 +3074,7 @@ void A_BombShield(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_BombShield", actor)) + if (LUA_CallAction(A_BOMBSHIELD, actor)) return; if (!actor->target || !actor->target->player) @@ -3105,7 +3105,7 @@ void A_WaterShield(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_WaterShield", actor)) + if (LUA_CallAction(A_WATERSHIELD, actor)) return; if (!actor->target || !actor->target->player) @@ -3143,7 +3143,7 @@ void A_ForceShield(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_ForceShield", actor)) + if (LUA_CallAction(A_FORCESHIELD, actor)) return; if (!actor->target || !actor->target->player) @@ -3180,7 +3180,7 @@ void A_PityShield(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_PityShield", actor)) + if (LUA_CallAction(A_PITYSHIELD, actor)) return; if (!actor->target || !actor->target->player) @@ -3212,7 +3212,7 @@ void A_GravityBox(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_GravityBox", actor)) + if (LUA_CallAction(A_GRAVITYBOX, actor)) return; if (!actor->target || !actor->target->player) @@ -3236,7 +3236,7 @@ void A_GravityBox(mobj_t *actor) // void A_ScoreRise(mobj_t *actor) { - if (LUA_CallAction("A_ScoreRise", actor)) + if (LUA_CallAction(A_SCORERISE, actor)) return; // make logo rise! @@ -3257,7 +3257,7 @@ void A_ParticleSpawn(mobj_t *actor) mobjtype_t type; mobj_t *spawn; - if (LUA_CallAction("A_ParticleSpawn", actor)) + if (LUA_CallAction(A_PARTICLESPAWN, actor)) return; if (!actor->spawnpoint) @@ -3293,7 +3293,7 @@ void A_BunnyHop(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_BunnyHop", actor)) + if (LUA_CallAction(A_BUNNYHOP, actor)) return; if (((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz) @@ -3317,7 +3317,7 @@ void A_BubbleSpawn(mobj_t *actor) UINT8 prandom; mobj_t *bubble = NULL; - if (LUA_CallAction("A_BubbleSpawn", actor)) + if (LUA_CallAction(A_BUBBLESPAWN, actor)) return; if (!(actor->eflags & MFE_UNDERWATER)) @@ -3370,7 +3370,7 @@ void A_FanBubbleSpawn(mobj_t *actor) mobj_t *bubble = NULL; fixed_t hz = actor->z + (4*actor->height)/5; - if (LUA_CallAction("A_FanBubbleSpawn", actor)) + if (LUA_CallAction(A_FANBUBBLESPAWN, actor)) return; if (!(actor->eflags & MFE_UNDERWATER)) @@ -3416,7 +3416,7 @@ void A_BubbleRise(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_BubbleRise", actor)) + if (LUA_CallAction(A_BUBBLERISE, actor)) return; if (actor->type == MT_EXTRALARGEBUBBLE) @@ -3452,7 +3452,7 @@ void A_BubbleRise(mobj_t *actor) // void A_BubbleCheck(mobj_t *actor) { - if (LUA_CallAction("A_BubbleCheck", actor)) + if (LUA_CallAction(A_BUBBLECHECK, actor)) return; if (actor->eflags & MFE_UNDERWATER) @@ -3470,7 +3470,7 @@ void A_BubbleCheck(mobj_t *actor) // void A_AttractChase(mobj_t *actor) { - if (LUA_CallAction("A_AttractChase", actor)) + if (LUA_CallAction(A_ATTRACTCHASE, actor)) return; if (actor->flags2 & MF2_NIGHTSPULL || !actor->health) @@ -3542,7 +3542,7 @@ void A_DropMine(mobj_t *actor) fixed_t z; mobj_t *mine; - if (LUA_CallAction("A_DropMine", actor)) + if (LUA_CallAction(A_DROPMINE, actor)) return; if (locvar2 & 65535) @@ -3589,7 +3589,7 @@ void A_FishJump(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_FishJump", actor)) + if (LUA_CallAction(A_FISHJUMP, actor)) return; if ((actor->z <= actor->floorz) || (actor->z <= actor->watertop - FixedMul((64 << FRACBITS), actor->scale))) @@ -3625,7 +3625,7 @@ void A_ThrownRing(mobj_t *actor) player_t *player; fixed_t dist; - if (LUA_CallAction("A_ThrownRing", actor)) + if (LUA_CallAction(A_THROWNRING, actor)) return; if (leveltime % (TICRATE/7) == 0) @@ -3831,7 +3831,7 @@ void A_GrenadeRing(mobj_t *actor) INT32 bx, by, xl, xh, yl, yh; explodedist = FixedMul(actor->info->painchance, mapobjectscale); - if (LUA_CallAction("A_GrenadeRing", actor)) + if (LUA_CallAction(A_GRENADERING, actor)) return; if (actor->flags2 & MF2_DEBRIS) @@ -3902,7 +3902,7 @@ void A_MineExplode(mobj_t *actor) mobjtype_t type; explodedist = FixedMul((3*actor->info->painchance)/2, mapobjectscale); - if (LUA_CallAction("A_MineExplode", actor)) + if (LUA_CallAction(A_MINEEXPLODE, actor)) return; if (actor->flags2 & MF2_DEBRIS) @@ -3947,7 +3947,7 @@ void A_MineExplode(mobj_t *actor) // void A_SetSolidSteam(mobj_t *actor) { - if (LUA_CallAction("A_SetSolidSteam", actor)) + if (LUA_CallAction(A_SETSOLIDSTEAM, actor)) return; actor->flags &= ~MF_NOCLIP; @@ -3980,7 +3980,7 @@ void A_SetSolidSteam(mobj_t *actor) void A_UnsetSolidSteam(mobj_t *actor) { - if (LUA_CallAction("A_UnsetSolidSteam", actor)) + if (LUA_CallAction(A_UNSETSOLIDSTEAM, actor)) return; actor->flags &= ~MF_SOLID; @@ -3998,7 +3998,7 @@ void A_SignPlayer(mobj_t *actor) { mobj_t *ov; - if (LUA_CallAction("A_SignPlayer", actor)) + if (LUA_CallAction(A_SIGNPLAYER, actor)) return; if (!actor->target) @@ -4042,7 +4042,7 @@ void A_OverlayThink(mobj_t *actor) { fixed_t destx, desty; - if (LUA_CallAction("A_OverlayThink", actor)) + if (LUA_CallAction(A_OVERLAYTHINK, actor)) return; if (!actor->target) @@ -4094,7 +4094,7 @@ void A_JetChase(mobj_t *actor) { fixed_t thefloor; - if (LUA_CallAction("A_JetChase", actor)) + if (LUA_CallAction(A_JETCHASE, actor)) return; if (actor->flags2 & MF2_AMBUSH) @@ -4190,7 +4190,7 @@ void A_JetbThink(mobj_t *actor) sector_t *nextsector; fixed_t thefloor; - if (LUA_CallAction("A_JetbThink", actor)) + if (LUA_CallAction(A_JETBTHINK, actor)) return; if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz @@ -4254,7 +4254,7 @@ void A_JetgShoot(mobj_t *actor) { fixed_t dist; - if (LUA_CallAction("A_JetgShoot", actor)) + if (LUA_CallAction(A_JETGSHOOT, actor)) return; if (!actor->target) @@ -4294,7 +4294,7 @@ void A_ShootBullet(mobj_t *actor) { fixed_t dist; - if (LUA_CallAction("A_ShootBullet", actor)) + if (LUA_CallAction(A_SHOOTBULLET, actor)) return; if (!actor->target) @@ -4321,7 +4321,7 @@ void A_ShootBullet(mobj_t *actor) // void A_MinusDigging(mobj_t *actor) { - if (LUA_CallAction("A_MinusDigging", actor)) + if (LUA_CallAction(A_MINUSDIGGING, actor)) return; actor->flags &= ~MF_SPECIAL; @@ -4373,7 +4373,7 @@ void A_MinusDigging(mobj_t *actor) void A_MinusPopup(mobj_t *actor) { - if (LUA_CallAction("A_MinusPopup", actor)) + if (LUA_CallAction(A_MINUSPOPUP, actor)) return; P_SetObjectMomZ(actor, 10*FRACUNIT, false); @@ -4394,7 +4394,7 @@ void A_MinusPopup(mobj_t *actor) // void A_MinusCheck(mobj_t *actor) { - if (LUA_CallAction("A_MinusCheck", actor)) + if (LUA_CallAction(A_MINUSCHECK, actor)) return; if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) @@ -4421,7 +4421,7 @@ void A_MinusCheck(mobj_t *actor) // void A_ChickenCheck(mobj_t *actor) { - if (LUA_CallAction("A_ChickenCheck", actor)) + if (LUA_CallAction(A_CHICKENCHECK, actor)) return; if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) @@ -4452,7 +4452,7 @@ void A_JetgThink(mobj_t *actor) fixed_t thefloor; - if (LUA_CallAction("A_JetgThink", actor)) + if (LUA_CallAction(A_JETGTHINK, actor)) return; if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz @@ -4502,7 +4502,7 @@ void A_JetgThink(mobj_t *actor) // void A_MouseThink(mobj_t *actor) { - if (LUA_CallAction("A_MouseThink", actor)) + if (LUA_CallAction(A_MOUSETHINK, actor)) return; if (actor->reactiontime) @@ -4539,7 +4539,7 @@ void A_DetonChase(mobj_t *actor) angle_t exact; fixed_t xydist, dist; - if (LUA_CallAction("A_DetonChase", actor)) + if (LUA_CallAction(A_DETONCHASE, actor)) return; // modify tracer threshold @@ -4685,7 +4685,7 @@ void A_CapeChase(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CapeChase", actor)) + if (LUA_CallAction(A_CAPECHASE, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_CapeChase called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -4743,7 +4743,7 @@ void A_RotateSpikeBall(mobj_t *actor) INT32 locvar1 = var1; const fixed_t radius = FixedMul(12*actor->info->speed, actor->scale); - if (LUA_CallAction("A_RotateSpikeBall", actor)) + if (LUA_CallAction(A_ROTATESPIKEBALL, actor)) return; if (actor->type == MT_SPECIALSPIKEBALL) // don't remove this, these spikeballs share the same states as the rotating spikeballs @@ -4797,7 +4797,7 @@ void A_UnidusBall(mobj_t *actor) INT32 locvar1 = var1; boolean canthrow = false; - if (LUA_CallAction("A_UnidusBall", actor)) + if (LUA_CallAction(A_UNIDUSBALL, actor)) return; actor->angle += ANGLE_11hh; @@ -4894,7 +4894,7 @@ void A_RockSpawn(mobj_t *actor) fixed_t dist; fixed_t randomoomph; - if (LUA_CallAction("A_RockSpawn", actor)) + if (LUA_CallAction(A_ROCKSPAWN, actor)) return; if (i == -1) @@ -4948,7 +4948,7 @@ void A_SlingAppear(mobj_t *actor) UINT8 mlength = 4; mobj_t *spawnee; - if (LUA_CallAction("A_SlingAppear", actor)) + if (LUA_CallAction(A_SLINGAPPEAR, actor)) return; P_UnsetThingPosition(actor); @@ -5008,7 +5008,7 @@ void A_MaceRotate(mobj_t *actor) TVector *res; fixed_t radius; - if (LUA_CallAction("A_MaceRotate", actor)) + if (LUA_CallAction(A_MACEROTATE, actor)) return; // Target was removed. @@ -5120,7 +5120,7 @@ void A_SetFuse(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetFuse", actor)) + if (LUA_CallAction(A_SETFUSE, actor)) return; if ((!actor->fuse || (locvar2 >> 16)) && (locvar2 >> 16) != 2) // set the actor's fuse value @@ -5148,7 +5148,7 @@ void A_CrawlaCommanderThink(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CrawlaCommanderThink", actor)) + if (LUA_CallAction(A_CRAWLACOMMANDERTHINK, actor)) return; if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz @@ -5286,7 +5286,7 @@ void A_RingExplode(mobj_t *actor) thinker_t *th; angle_t d; - if (LUA_CallAction("A_RingExplode", actor)) + if (LUA_CallAction(A_RINGEXPLODE, actor)) return; for (d = 0; d < 16; d++) @@ -5332,7 +5332,7 @@ void A_OldRingExplode(mobj_t *actor) { //INT32 locvar2 = var2; boolean changecolor = (actor->target && actor->target->player); - if (LUA_CallAction("A_OldRingExplode", actor)) + if (LUA_CallAction(A_OLDRINGEXPLODE, actor)) return; for (i = 0; i < 32; i++) @@ -5408,7 +5408,7 @@ void A_MixUp(mobj_t *actor) boolean teleported[MAXPLAYERS]; INT32 i, numplayers = 0, prandom = 0; - if (LUA_CallAction("A_MixUp", actor)) + if (LUA_CallAction(A_MIXUP, actor)) return; if (!multiplayer) @@ -5664,7 +5664,7 @@ void A_RecyclePowers(mobj_t *actor) INT32 weapons[MAXPLAYERS]; INT32 weaponheld[MAXPLAYERS]; - if (LUA_CallAction("A_RecyclePowers", actor)) + if (LUA_CallAction(A_RECYCLEPOWERS, actor)) return; if (!multiplayer) @@ -5757,7 +5757,7 @@ void A_Boss1Chase(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_Boss1Chase", actor)) + if (LUA_CallAction(A_BOSS1CHASE, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) @@ -5877,7 +5877,7 @@ void A_Boss2Chase(mobj_t *actor) boolean reverse = false; INT32 speedvar; - if (LUA_CallAction("A_Boss2Chase", actor)) + if (LUA_CallAction(A_BOSS2CHASE, actor)) return; if (actor->health <= 0) @@ -6003,7 +6003,7 @@ void A_Boss2Chase(mobj_t *actor) // void A_Boss2Pogo(mobj_t *actor) { - if (LUA_CallAction("A_Boss2Pogo", actor)) + if (LUA_CallAction(A_BOSS2POGO, actor)) return; if (actor->z <= actor->floorz + FixedMul(8*FRACUNIT, actor->scale) && actor->momz <= 0) @@ -6051,7 +6051,7 @@ void A_Boss2TakeDamage(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_Boss2TakeDamage", actor)) + if (LUA_CallAction(A_BOSS2TAKEDAMAGE, actor)) return; A_Pain(actor); @@ -6074,7 +6074,7 @@ void A_Boss7Chase(mobj_t *actor) INT32 delta; INT32 i; - if (LUA_CallAction("A_Boss7Chase", actor)) + if (LUA_CallAction(A_BOSS7CHASE, actor)) return; if (actor->z != actor->floorz) @@ -6204,7 +6204,7 @@ void A_Boss7Chase(mobj_t *actor) // void A_GoopSplat(mobj_t *actor) { - if (LUA_CallAction("A_GoopSplat", actor)) + if (LUA_CallAction(A_GOOPSPLAT, actor)) return; P_UnsetThingPosition(actor); @@ -6229,7 +6229,7 @@ void A_Boss2PogoSFX(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Boss2PogoSFX", actor)) + if (LUA_CallAction(A_BOSS2POGOSFX, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) @@ -6271,7 +6271,7 @@ void A_Boss2PogoTarget(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Boss2PogoTarget", actor)) + if (LUA_CallAction(A_BOSS2POGOTARGET, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE) || (actor->target->player && actor->target->player->powers[pw_flashing]) @@ -6356,7 +6356,7 @@ void A_Boss2PogoTarget(mobj_t *actor) // void A_EggmanBox(mobj_t *actor) { - if (LUA_CallAction("A_EggmanBox", actor)) + if (LUA_CallAction(A_EGGMANBOX, actor)) return; if (!actor->target || !actor->target->player) @@ -6382,7 +6382,7 @@ void A_TurretFire(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_TurretFire", actor)) + if (LUA_CallAction(A_TURRETFIRE, actor)) return; if (locvar2) @@ -6420,7 +6420,7 @@ void A_SuperTurretFire(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SuperTurretFire", actor)) + if (LUA_CallAction(A_SUPERTURRETFIRE, actor)) return; if (locvar2) @@ -6456,7 +6456,7 @@ void A_TurretStop(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_TurretStop", actor)) + if (LUA_CallAction(A_TURRETSTOP, actor)) return; actor->flags2 &= ~MF2_FIRING; @@ -6475,7 +6475,7 @@ void A_TurretStop(mobj_t *actor) // void A_SparkFollow(mobj_t *actor) { - if (LUA_CallAction("A_SparkFollow", actor)) + if (LUA_CallAction(A_SPARKFOLLOW, actor)) return; if ((!actor->target || (actor->target->health <= 0)) @@ -6511,7 +6511,7 @@ void A_BuzzFly(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_BuzzFly", actor)) + if (LUA_CallAction(A_BUZZFLY, actor)) return; if (actor->flags2 & MF2_AMBUSH) @@ -6610,7 +6610,7 @@ void A_GuardChase(mobj_t *actor) { INT32 delta; - if (LUA_CallAction("A_GuardChase", actor)) + if (LUA_CallAction(A_GUARDCHASE, actor)) return; if (actor->reactiontime) @@ -6685,7 +6685,7 @@ void A_EggShield(mobj_t *actor) fixed_t movex, movey; angle_t angle; - if (LUA_CallAction("A_EggShield", actor)) + if (LUA_CallAction(A_EGGSHIELD, actor)) return; if (!actor->target || !actor->target->health) @@ -6767,7 +6767,7 @@ void A_EggShield(mobj_t *actor) // void A_SetReactionTime(mobj_t *actor) { - if (LUA_CallAction("A_SetReactionTime", actor)) + if (LUA_CallAction(A_SETREACTIONTIME, actor)) return; if (var1) @@ -6789,7 +6789,7 @@ void A_Boss1Spikeballs(mobj_t *actor) INT32 locvar2 = var2; mobj_t *ball; - if (LUA_CallAction("A_Boss1Spikeballs", actor)) + if (LUA_CallAction(A_BOSS1SPIKEBALLS, actor)) return; ball = P_SpawnMobj(actor->x, actor->y, actor->z, MT_EGGMOBILE_BALL); @@ -6811,7 +6811,7 @@ void A_Boss1Spikeballs(mobj_t *actor) // void A_Boss3TakeDamage(mobj_t *actor) { - if (LUA_CallAction("A_Boss3TakeDamage", actor)) + if (LUA_CallAction(A_BOSS3TAKEDAMAGE, actor)) return; actor->movecount = var1; @@ -6829,7 +6829,7 @@ void A_Boss3TakeDamage(mobj_t *actor) // void A_Boss3Path(mobj_t *actor) { - if (LUA_CallAction("A_Boss3Path", actor)) + if (LUA_CallAction(A_BOSS3PATH, actor)) return; if (actor->tracer && actor->tracer->health && actor->tracer->movecount) @@ -6955,7 +6955,7 @@ void A_LinedefExecute(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_LinedefExecute", actor)) + if (LUA_CallAction(A_LINEDEFEXECUTE, actor)) return; tagnum = locvar1; @@ -6979,7 +6979,7 @@ void A_LinedefExecute(mobj_t *actor) // void A_PlaySeeSound(mobj_t *actor) { - if (LUA_CallAction("A_PlaySeeSound", actor)) + if (LUA_CallAction(A_PLAYSEESOUND, actor)) return; if (actor->info->seesound) @@ -6995,7 +6995,7 @@ void A_PlaySeeSound(mobj_t *actor) // void A_PlayAttackSound(mobj_t *actor) { - if (LUA_CallAction("A_PlayAttackSound", actor)) + if (LUA_CallAction(A_PLAYATTACKSOUND, actor)) return; if (actor->info->attacksound) @@ -7011,7 +7011,7 @@ void A_PlayAttackSound(mobj_t *actor) // void A_PlayActiveSound(mobj_t *actor) { - if (LUA_CallAction("A_PlayActiveSound", actor)) + if (LUA_CallAction(A_PLAYACTIVESOUND, actor)) return; if (actor->info->activesound) @@ -7030,7 +7030,7 @@ void A_SmokeTrailer(mobj_t *actor) mobj_t *th; INT32 locvar1 = var1; - if (LUA_CallAction("A_SmokeTrailer", actor)) + if (LUA_CallAction(A_SMOKETRAILER, actor)) return; if (leveltime % 4) @@ -7071,7 +7071,7 @@ void A_SpawnObjectAbsolute(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SpawnObjectAbsolute", actor)) + if (LUA_CallAction(A_SPAWNOBJECTABSOLUTE, actor)) return; x = (INT16)(locvar1>>16); @@ -7107,7 +7107,7 @@ void A_SpawnObjectRelative(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SpawnObjectRelative", actor)) + if (LUA_CallAction(A_SPAWNOBJECTRELATIVE, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_SpawnObjectRelative called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7147,7 +7147,7 @@ void A_ChangeAngleRelative(mobj_t *actor) const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - if (LUA_CallAction("A_ChangeAngleRelative", actor)) + if (LUA_CallAction(A_CHANGEANGLERELATIVE, actor)) return; #ifdef PARANOIA @@ -7172,7 +7172,7 @@ void A_ChangeAngleAbsolute(mobj_t *actor) const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - if (LUA_CallAction("A_ChangeAngleAbsolute", actor)) + if (LUA_CallAction(A_CHANGEANGLEABSOLUTE, actor)) return; #ifdef PARANOIA @@ -7196,7 +7196,7 @@ void A_RollAngle(mobj_t *actor) INT32 locvar2 = var2; const angle_t angle = FixedAngle(locvar1*FRACUNIT); - if (LUA_CallAction("A_RollAngle", actor)) + if (LUA_CallAction(A_ROLLANGLE, actor)) return; // relative (default) @@ -7221,7 +7221,7 @@ void A_ChangeRollAngleRelative(mobj_t *actor) const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - if (LUA_CallAction("A_ChangeRollAngleRelative", actor)) + if (LUA_CallAction(A_CHANGEROLLANGLERELATIVE, actor)) return; #ifdef PARANOIA @@ -7246,7 +7246,7 @@ void A_ChangeRollAngleAbsolute(mobj_t *actor) const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - if (LUA_CallAction("A_ChangeRollAngleAbsolute", actor)) + if (LUA_CallAction(A_CHANGEROLLANGLEABSOLUTE, actor)) return; #ifdef PARANOIA @@ -7271,7 +7271,7 @@ void A_PlaySound(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_PlaySound", actor)) + if (LUA_CallAction(A_PLAYSOUND, actor)) return; S_StartSound(locvar2 ? actor : NULL, locvar1); @@ -7293,7 +7293,7 @@ void A_FindTarget(mobj_t *actor) mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; - if (LUA_CallAction("A_FindTarget", actor)) + if (LUA_CallAction(A_FINDTARGET, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_FindTarget called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7357,7 +7357,7 @@ void A_FindTracer(mobj_t *actor) mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; - if (LUA_CallAction("A_FindTracer", actor)) + if (LUA_CallAction(A_FINDTRACER, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_FindTracer called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7417,7 +7417,7 @@ void A_SetTics(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetTics", actor)) + if (LUA_CallAction(A_SETTICS, actor)) return; if (locvar1) @@ -7438,7 +7438,7 @@ void A_SetRandomTics(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetRandomTics", actor)) + if (LUA_CallAction(A_SETRANDOMTICS, actor)) return; actor->tics = P_RandomRange(locvar1, locvar2); @@ -7456,7 +7456,7 @@ void A_ChangeColorRelative(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_ChangeColorRelative", actor)) + if (LUA_CallAction(A_CHANGECOLORRELATIVE, actor)) return; if (locvar1) @@ -7481,7 +7481,7 @@ void A_ChangeColorAbsolute(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_ChangeColorAbsolute", actor)) + if (LUA_CallAction(A_CHANGECOLORABSOLUTE, actor)) return; if (locvar1) @@ -7505,7 +7505,7 @@ void A_MoveRelative(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_MoveRelative", actor)) + if (LUA_CallAction(A_MOVERELATIVE, actor)) return; P_Thrust(actor, actor->angle+FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); @@ -7523,7 +7523,7 @@ void A_MoveAbsolute(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_MoveAbsolute", actor)) + if (LUA_CallAction(A_MOVEABSOLUTE, actor)) return; P_InstaThrust(actor, FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); @@ -7541,7 +7541,7 @@ void A_Thrust(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Thrust", actor)) + if (LUA_CallAction(A_THRUST, actor)) return; if (!locvar1) @@ -7567,7 +7567,7 @@ void A_ZThrust(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_ZThrust", actor)) + if (LUA_CallAction(A_ZTHRUST, actor)) return; if (!locvar1) @@ -7601,7 +7601,7 @@ void A_SetTargetsTarget(mobj_t *actor) INT32 locvar2 = var2; mobj_t *oldtarg = NULL, *newtarg = NULL; - if (LUA_CallAction("A_SetTargetsTarget", actor)) + if (LUA_CallAction(A_SETTARGETSTARGET, actor)) return; // actor's target @@ -7645,7 +7645,7 @@ void A_SetObjectFlags(mobj_t *actor) INT32 locvar2 = var2; boolean unlinkthings = false; - if (LUA_CallAction("A_SetObjectFlags", actor)) + if (LUA_CallAction(A_SETOBJECTFLAGS, actor)) return; if (locvar2 == 2) @@ -7686,7 +7686,7 @@ void A_SetObjectFlags2(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetObjectFlags2", actor)) + if (LUA_CallAction(A_SETOBJECTFLAGS2, actor)) return; if (locvar2 == 2) @@ -7713,7 +7713,7 @@ void A_BossJetFume(mobj_t *actor) mobj_t *filler; INT32 locvar1 = var1; - if (LUA_CallAction("A_BossJetFume", actor)) + if (LUA_CallAction(A_BOSSJETFUME, actor)) return; if (locvar1 == 0) // Boss1 jet fumes @@ -7823,7 +7823,7 @@ void A_RandomState(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_RandomState", actor)) + if (LUA_CallAction(A_RANDOMSTATE, actor)) return; P_SetMobjState(actor, P_RandomChance(FRACUNIT/2) ? locvar1 : locvar2); @@ -7841,7 +7841,7 @@ void A_RandomStateRange(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_RandomStateRange", actor)) + if (LUA_CallAction(A_RANDOMSTATERANGE, actor)) return; P_SetMobjState(actor, P_RandomRange(locvar1, locvar2)); @@ -7859,7 +7859,7 @@ void A_DualAction(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_DualAction", actor)) + if (LUA_CallAction(A_DUALACTION, actor)) return; CONS_Debug(DBG_GAMELOGIC, "A_DualAction called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7892,7 +7892,7 @@ void A_RemoteAction(mobj_t *actor) INT32 locvar2 = var2; mobj_t *originaltarget = actor->target; // Hold on to the target for later. - if (LUA_CallAction("A_RemoteAction", actor)) + if (LUA_CallAction(A_REMOTEACTION, actor)) return; // If >=0, find the closest target. @@ -7974,7 +7974,7 @@ void A_RemoteAction(mobj_t *actor) // void A_ToggleFlameJet(mobj_t* actor) { - if (LUA_CallAction("A_ToggleFlameJet", actor)) + if (LUA_CallAction(A_TOGGLEFLAMEJET, actor)) return; // threshold - off delay @@ -8002,7 +8002,7 @@ void A_ItemPop(mobj_t *actor) mobj_t *remains; mobjtype_t explode; - if (LUA_CallAction("A_ItemPop", actor)) + if (LUA_CallAction(A_ITEMPOP, actor)) return; if (!(actor->target && actor->target->player)) @@ -8068,7 +8068,7 @@ void A_JawzChase(mobj_t *actor) { player_t *player; - if (LUA_CallAction("A_JawzChase", actor)) + if (LUA_CallAction(A_JAWZCHASE, actor)) return; if (actor->tracer) @@ -8113,7 +8113,7 @@ void A_JawzExplode(mobj_t *actor) INT32 shrapnel = 2; mobj_t *truc; - if (LUA_CallAction("A_JawzExplode", actor)) + if (LUA_CallAction(A_JAWZEXPLODE, actor)) return; truc = P_SpawnMobj(actor->x, actor->y, actor->z, MT_BOOMEXPLODE); @@ -8153,7 +8153,7 @@ void A_SPBChase(mobj_t *actor) angle_t hang, vang; fixed_t wspeed, xyspeed, zspeed; - if (LUA_CallAction("A_SPBChase", actor)) + if (LUA_CallAction(A_SPBCHASE, actor)) return; // Default speed @@ -8432,7 +8432,7 @@ void A_BallhogExplode(mobj_t *actor) { mobj_t *mo2; - if (LUA_CallAction("A_BallhogExplode", actor)) + if (LUA_CallAction(A_BALLHOGEXPLODE, actor)) return; mo2 = P_SpawnMobj(actor->x, actor->y, actor->z, MT_BALLHOGBOOM); @@ -8448,7 +8448,7 @@ void A_LightningFollowPlayer(mobj_t *actor) { fixed_t sx, sy; - if (LUA_CallAction("A_LightningFollowPlayer", actor)) + if (LUA_CallAction(A_LIGHTNINGFOLLOWPLAYER, actor)) return; if (!actor->target) @@ -8477,7 +8477,7 @@ void A_FZBoomFlash(mobj_t *actor) { UINT8 i; - if (LUA_CallAction("A_FZBoomFlash", actor)) + if (LUA_CallAction(A_FZBOOMFLASH, actor)) return; for (i = 0; i < MAXPLAYERS; i++) @@ -8500,7 +8500,7 @@ void A_FZBoomSmoke(mobj_t *actor) INT32 i; INT32 rad = 47+(23*var1); - if (LUA_CallAction("A_FZBoomSmoke", actor)) + if (LUA_CallAction(A_FZBOOMSMOKE, actor)) return; for (i = 0; i < 8+(4*var1); i++) @@ -8522,7 +8522,7 @@ void A_RandomShadowFrame(mobj_t *actor) mobj_t *fire; mobj_t *fake; - if (LUA_CallAction("A_RandomShadowFrame", (actor))) + if (LUA_CallAction(A_RANDOMSHADOWFRAME, actor)) return; if (!actor->extravalue1) // Hack that spawns thoks that look like random shadows. Otherwise the state would overwrite our frame and that's a pain. @@ -8569,7 +8569,7 @@ void A_RoamingShadowThinker(mobj_t *actor) { mobj_t *wind; - if (LUA_CallAction("A_RoamingShadowThinker", (actor))) + if (LUA_CallAction(A_ROAMINGSHADOWTHINKER, actor)) return; // extravalue1 replaces "movetimer" @@ -8627,7 +8627,7 @@ void A_MayonakaArrow(mobj_t *actor) INT32 flip = 0; INT32 iswarning; - if (LUA_CallAction("A_MayonakaArrow", (actor))) + if (LUA_CallAction(A_MAYONAKAARROW, actor)) return; iswarning = actor->spawnpoint->options & MTF_OBJECTSPECIAL; // is our object a warning sign? @@ -8667,7 +8667,7 @@ void A_MementosTPParticles(mobj_t *actor) int i = 0; thinker_t *th; - if (LUA_CallAction("A_MementosTPParticles", (actor))) + if (LUA_CallAction(A_MEMENTOSTPPARTICLES, actor)) return; for (; i<4; i++) @@ -8716,7 +8716,7 @@ void A_ReaperThinker(mobj_t *actor) player_t *player; // used as a shortcut in a loop. mobj_t *targetplayermo = NULL; // the player mo we can eventually target, or whatever. - if (LUA_CallAction("A_ReaperThinker", (actor))) + if (LUA_CallAction(A_REAPERTHINKER, actor)) return; // We don't have custom variables or whatever so we'll do with whatever the fuck we have left. @@ -8887,7 +8887,7 @@ void A_FlameParticle(mobj_t *actor) fixed_t rad = actor->radius>>FRACBITS, hei = actor->radius>>FRACBITS; mobj_t *par; - if (LUA_CallAction("A_FlameParticle", actor)) + if (LUA_CallAction(A_FLAMEPARTICLE, actor)) return; par = P_SpawnMobj( @@ -8912,7 +8912,7 @@ void A_OrbitNights(mobj_t* actor) INT32 ofs = (var2 & 0xFFFF); boolean ishelper = (var2 & 0xFFFF0000); - if (LUA_CallAction("A_OrbitNights", actor)) + if (LUA_CallAction(A_ORBITNIGHTS, actor)) return; if (!actor->target || !actor->target->player || @@ -8955,7 +8955,7 @@ void A_OrbitNights(mobj_t* actor) // void A_GhostMe(mobj_t *actor) { - if (LUA_CallAction("A_GhostMe", actor)) + if (LUA_CallAction(A_GHOSTME, actor)) return; P_SpawnGhostMobj(actor); @@ -8976,7 +8976,7 @@ void A_SetObjectState(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; - if (LUA_CallAction("A_SetObjectState", actor)) + if (LUA_CallAction(A_SETOBJECTSTATE, actor)) return; if ((!locvar2 && !actor->target) || (locvar2 && !actor->tracer)) @@ -9020,7 +9020,7 @@ void A_SetObjectTypeState(mobj_t *actor) mobj_t *mo2; fixed_t dist = 0; - if (LUA_CallAction("A_SetObjectTypeState", actor)) + if (LUA_CallAction(A_SETOBJECTTYPESTATE, actor)) return; for (th = thinkercap.next; th != &thinkercap; th = th->next) @@ -9062,7 +9062,7 @@ void A_KnockBack(mobj_t *actor) INT32 locvar1 = var1; mobj_t *target; - if (LUA_CallAction("A_KnockBack", actor)) + if (LUA_CallAction(A_KNOCKBACK, actor)) return; if (!locvar1) @@ -9097,7 +9097,7 @@ void A_PushAway(mobj_t *actor) mobj_t *target; // target angle_t an; // actor to target angle - if (LUA_CallAction("A_PushAway", actor)) + if (LUA_CallAction(A_PUSHAWAY, actor)) return; if ((!(locvar2 >> 16) && !actor->target) || ((locvar2 >> 16) && !actor->tracer)) @@ -9131,7 +9131,7 @@ void A_RingDrain(mobj_t *actor) INT32 locvar1 = var1; player_t *player; - if (LUA_CallAction("A_RingDrain", actor)) + if (LUA_CallAction(A_RINGDRAIN, actor)) return; if (!actor->target || !actor->target->player) @@ -9163,7 +9163,7 @@ void A_SplitShot(mobj_t *actor) const fixed_t offs = (fixed_t)(locvar1*FRACUNIT); const fixed_t hoffs = (fixed_t)(loc2up*FRACUNIT); - if (LUA_CallAction("A_SplitShot", actor)) + if (LUA_CallAction(A_SPLITSHOT, actor)) return; A_FaceTarget(actor); @@ -9197,7 +9197,7 @@ void A_MissileSplit(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_MissileSplit", actor)) + if (LUA_CallAction(A_MISSILESPLIT, actor)) return; if (actor->eflags & MFE_VERTICALFLIP) @@ -9225,7 +9225,7 @@ void A_MultiShot(mobj_t *actor) INT32 count = 0; fixed_t ad; - if (LUA_CallAction("A_MultiShot", actor)) + if (LUA_CallAction(A_MULTISHOT, actor)) return; if (actor->target) @@ -9286,7 +9286,7 @@ void A_InstaLoop(mobj_t *actor) const fixed_t ac = FINECOSINE(fa); const fixed_t as = FINESINE(fa); - if (LUA_CallAction("A_InstaLoop", actor)) + if (LUA_CallAction(A_INSTALOOP, actor)) return; P_InstaThrust(actor, actor->angle, FixedMul(ac, FixedMul(force, actor->scale))); @@ -9319,7 +9319,7 @@ void A_Custom3DRotate(mobj_t *actor) const fixed_t hspeed = FixedMul(loc2up*FRACUNIT/10, actor->scale); const fixed_t vspeed = FixedMul(loc2lw*FRACUNIT/10, actor->scale); - if (LUA_CallAction("A_Custom3DRotate", actor)) + if (LUA_CallAction(A_CUSTOM3DROTATE, actor)) return; if (!actor->target) // Ensure we actually have a target first. @@ -9379,7 +9379,7 @@ void A_SearchForPlayers(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SearchForPlayers", actor)) + if (LUA_CallAction(A_SEARCHFORPLAYERS, actor)) return; if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) @@ -9411,7 +9411,7 @@ void A_CheckRandom(mobj_t *actor) INT32 locvar2 = var2; fixed_t chance = FRACUNIT; - if (LUA_CallAction("A_CheckRandom", actor)) + if (LUA_CallAction(A_CHECKRANDOM, actor)) return; if ((locvar1 & 0xFFFF) == 0) @@ -9438,7 +9438,7 @@ void A_CheckTargetRings(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CheckTargetRings", actor)) + if (LUA_CallAction(A_CHECKTARGETRINGS, actor)) return; if (!(actor->target) || !(actor->target->player)) @@ -9461,7 +9461,7 @@ void A_CheckRings(mobj_t *actor) INT32 locvar2 = var2; INT32 i, cntr = 0; - if (LUA_CallAction("A_CheckRings", actor)) + if (LUA_CallAction(A_CHECKRINGS, actor)) return; for (i = 0; i < MAXPLAYERS; i++) @@ -9485,7 +9485,7 @@ void A_CheckTotalRings(mobj_t *actor) INT32 i, cntr = 0; - if (LUA_CallAction("A_CheckTotalRings", actor)) + if (LUA_CallAction(A_CHECKTOTALRINGS, actor)) return; for (i = 0; i < MAXPLAYERS; i++) @@ -9507,7 +9507,7 @@ void A_CheckHealth(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CheckHealth", actor)) + if (LUA_CallAction(A_CHECKHEALTH, actor)) return; if (actor->health <= locvar1) @@ -9529,7 +9529,7 @@ void A_CheckRange(mobj_t *actor) INT32 locvar2 = var2; fixed_t dist; - if (LUA_CallAction("A_CheckRange", actor)) + if (LUA_CallAction(A_CHECKRANGE, actor)) return; if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) @@ -9559,7 +9559,7 @@ void A_CheckHeight(mobj_t *actor) INT32 locvar2 = var2; fixed_t height; - if (LUA_CallAction("A_CheckHeight", actor)) + if (LUA_CallAction(A_CHECKHEIGHT, actor)) return; if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) @@ -9591,7 +9591,7 @@ void A_CheckTrueRange(mobj_t *actor) fixed_t dist; // horizontal range fixed_t l; // true range - if (LUA_CallAction("A_CheckTrueRange", actor)) + if (LUA_CallAction(A_CHECKTRUERANGE, actor)) return; if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) @@ -9642,7 +9642,7 @@ void A_CheckThingCount(mobj_t *actor) mobj_t *mo2; fixed_t dist = 0; - if (LUA_CallAction("A_CheckThingCount", actor)) + if (LUA_CallAction(A_CHECKTHINGCOUNT, actor)) return; for (th = thinkercap.next; th != &thinkercap; th = th->next) @@ -9687,7 +9687,7 @@ void A_CheckAmbush(mobj_t *actor) angle_t atp; // actor to target angle angle_t an; // angle between at and atp - if (LUA_CallAction("A_CheckAmbush", actor)) + if (LUA_CallAction(A_CHECKAMBUSH, actor)) return; if ((!locvar1 && !actor->target) || (locvar1 && !actor->tracer)) @@ -9725,7 +9725,7 @@ void A_CheckCustomValue(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CheckCustomValue", actor)) + if (LUA_CallAction(A_CHECKCUSTOMVALUE, actor)) return; if (actor->cusval >= locvar1) @@ -9744,7 +9744,7 @@ void A_CheckCusValMemo(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CheckCusValMemo", actor)) + if (LUA_CallAction(A_CHECKCUSVALMEMO, actor)) return; if (actor->cvmem >= locvar1) @@ -9769,7 +9769,7 @@ void A_SetCustomValue(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_SetCustomValue", actor)) + if (LUA_CallAction(A_SETCUSTOMVALUE, actor)) return; if (cv_debug) @@ -9819,7 +9819,7 @@ void A_UseCusValMemo(mobj_t *actor) INT32 temp = actor->cusval; // value being manipulated INT32 tempM = actor->cvmem; // value used to manipulate temp with - if (LUA_CallAction("A_UseCusValMemo", actor)) + if (LUA_CallAction(A_USECUSVALMEMO, actor)) return; if (locvar1 == 1) // cvmem being changed using cusval @@ -9882,7 +9882,7 @@ void A_RelayCustomValue(mobj_t *actor) INT32 temp; // reference value - var1 lower 16 bits changes this INT32 tempT; // target's value - changed to tracer if var1 upper 16 bits set, then modified to become final value - if (LUA_CallAction("A_RelayCustomValue", actor)) + if (LUA_CallAction(A_RELAYCUSTOMVALUE, actor)) return; if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) @@ -9941,7 +9941,7 @@ void A_CusValAction(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_CusValAction", actor)) + if (LUA_CallAction(A_CUSVALACTION, actor)) return; if (locvar2 == 5) @@ -9992,7 +9992,7 @@ void A_ForceStop(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_ForceStop", actor)) + if (LUA_CallAction(A_FORCESTOP, actor)) return; actor->momx = actor->momy = 0; @@ -10011,7 +10011,7 @@ void A_ForceWin(mobj_t *actor) { INT32 i; - if (LUA_CallAction("A_ForceWin", actor)) + if (LUA_CallAction(A_FORCEWIN, actor)) return; for (i = 0; i < MAXPLAYERS; i++) @@ -10041,7 +10041,7 @@ void A_SpikeRetract(mobj_t *actor) { INT32 locvar1 = var1; - if (LUA_CallAction("A_SpikeRetract", actor)) + if (LUA_CallAction(A_SPIKERETRACT, actor)) return; if (actor->flags & MF_NOBLOCKMAP) @@ -10125,7 +10125,7 @@ void A_Repeat(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_Repeat", actor)) + if (LUA_CallAction(A_REPEAT, actor)) return; if ((!(actor->extravalue2)) || actor->extravalue2 > locvar1) @@ -10150,7 +10150,7 @@ void A_SetScale(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; - if (LUA_CallAction("A_SetScale", actor)) + if (LUA_CallAction(A_SETSCALE, actor)) return; if (locvar1 <= 0) @@ -10195,7 +10195,7 @@ void A_RemoteDamage(mobj_t *actor) mobj_t *target; // we MUST have a target mobj_t *source = NULL; // on the other hand we don't necessarily need a source - if (LUA_CallAction("A_RemoteDamage", actor)) + if (LUA_CallAction(A_REMOTEDAMAGE, actor)) return; if (locvar1 == 1) @@ -10248,7 +10248,7 @@ void A_HomingChase(mobj_t *actor) fixed_t dist; fixed_t speedmul; - if (LUA_CallAction("A_HomingChase", actor)) + if (LUA_CallAction(A_HOMINGCHASE, actor)) return; if (locvar2 == 1) @@ -10296,7 +10296,7 @@ void A_TrapShot(mobj_t *actor) fixed_t x, y, z; fixed_t speed; - if (LUA_CallAction("A_TrapShot", actor)) + if (LUA_CallAction(A_TRAPSHOT, actor)) return; x = actor->x + P_ReturnThrustX(actor, actor->angle, FixedMul(frontoff*FRACUNIT, actor->scale)); @@ -10349,7 +10349,7 @@ void A_VileTarget(mobj_t *actor) mobjtype_t fogtype; INT32 i; - if (LUA_CallAction("A_VileTarget", actor)) + if (LUA_CallAction(A_VILETARGET, actor)) return; if (!actor->target) @@ -10436,7 +10436,7 @@ void A_VileAttack(mobj_t *actor) mobj_t *fire; INT32 i; - if (LUA_CallAction("A_VileAttack", actor)) + if (LUA_CallAction(A_VILEATTACK, actor)) return; if (!actor->target) @@ -10548,7 +10548,7 @@ void A_VileFire(mobj_t *actor) INT32 locvar2 = var2; mobj_t *dest; - if (LUA_CallAction("A_VileFire", actor)) + if (LUA_CallAction(A_VILEFIRE, actor)) return; dest = actor->tracer; @@ -10634,7 +10634,7 @@ void A_BrakChase(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; - if (LUA_CallAction("A_BrakChase", actor)) + if (LUA_CallAction(A_BRAKCHASE, actor)) return; // Set new tics NOW, in case the state changes while we're doing this and we try applying this to the painstate or something silly @@ -10754,7 +10754,7 @@ void A_BrakFireShot(mobj_t *actor) fixed_t x, y, z; INT32 locvar1 = var1; - if (LUA_CallAction("A_BrakFireShot", actor)) + if (LUA_CallAction(A_BRAKFIRESHOT, actor)) return; if (!actor->target) @@ -10817,7 +10817,7 @@ void A_BrakLobShot(mobj_t *actor) INT32 locvar2 = var2 & 0x0000FFFF; INT32 aimDirect = var2 & 0xFFFF0000; - if (LUA_CallAction("A_BrakLobShot", actor)) + if (LUA_CallAction(A_BRAKLOBSHOT, actor)) return; if (!actor->target) @@ -10923,7 +10923,7 @@ void A_NapalmScatter(mobj_t *actor) INT32 i; // for-loop cursor mobj_t *mo; // each and every spawned napalm burst - if (LUA_CallAction("A_NapalmScatter", actor)) + if (LUA_CallAction(A_NAPALMSCATTER, actor)) return; // Some quick sanity-checking @@ -10975,7 +10975,7 @@ void A_SpawnFreshCopy(mobj_t *actor) { mobj_t *newObject; - if (LUA_CallAction("A_SpawnFreshCopy", actor)) + if (LUA_CallAction(A_SPAWNFRESHCOPY, actor)) return; newObject = P_SpawnMobj(actor->x, actor->y, actor->z, actor->type); -- 2.54.0 From 05a56512606ce4c1e04b4fea0075aa2dd71bcf41 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Sat, 25 May 2024 17:05:08 +0200 Subject: [PATCH 022/525] Finishing touches Some cleanup, also interpolate drawfill size (dunno why it wasn't before) --- src/lua_hudlib_drawlist.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 98f0d45e7..ff98c6e8b 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -318,7 +318,7 @@ static void CalcFillCoords(drawitem_t *item) #define INTERP_LATCH 1 #define INTERP_STRING 2 -#define INTERP_FLAGS 3 // all bits combined +#define INTERP_FLAGMASK 0x3 static UINT64 GetItemId(void) { @@ -587,17 +587,15 @@ void LUA_HUD_DrawList(huddrawlist_h list) // this is kinda cursed... we need to check every item // but stop when the first-checked item is reached again size_t stop = j; - while(true) + do { if (j == list->olditems_len) { - // wrap around j = 0; - if (j == stop) // i'm dumb - break; + continue; } drawitem_t *old = &list->olditems[j++]; - if ((old->id & ~INTERP_FLAGS) == (item->id & ~INTERP_FLAGS)) // don't include flags in search + if ((old->id & ~INTERP_FLAGMASK) == (item->id & ~INTERP_FLAGMASK)) { // gotcha! olditem = old; @@ -616,9 +614,8 @@ void LUA_HUD_DrawList(huddrawlist_h list) } break; } - if (j == stop) - break; } + while (j != stop); } else { @@ -653,7 +650,7 @@ void LUA_HUD_DrawList(huddrawlist_h list) V_DrawPingNum(LERPS(x), LERPS(y), item->flags, item->num, item->colormap); break; case DI_DrawFill: - V_DrawFill(LERPS(x), LERPS(y), item->w, item->h, item->c); + V_DrawFill(LERPS(x), LERPS(y), LERP(w), LERP(h), item->c); break; case DI_DrawString: switch(item->align) -- 2.54.0 From ddddc7a89804e3c3fe1cf2732ff3d2bacc63a9d5 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 May 2024 00:52:09 +0200 Subject: [PATCH 023/525] draw a black screen instead of "nothing" during wipes on disabled screentextures should resolve the intense flashing that can occur --- src/hardware/hw_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0a922bbf3..d2a5b8189 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6247,6 +6247,12 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) lumpnum_t lumpnum; size_t lsize; + if (cv_grscreentextures.value == 0) + { + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // just draw a black screen instead of flashing and crap + return; + } + if (wipenum > 99 || scrnnum > 99) // not a valid wipe number return; // shouldn't end up here really, the loop should've stopped running beforehand -- 2.54.0 From 67aa71170fea7b5a7f006a589b02b5cb4bf8bce2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 May 2024 00:52:40 +0200 Subject: [PATCH 024/525] when not using screentextures draw kart bg on intermission screen --- src/hardware/hw_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d2a5b8189..fc137c109 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6238,7 +6238,12 @@ void HWR_EndScreenWipe(void) void HWR_DrawIntermissionBG(void) { - HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); + patch_t *bgpatch = W_CachePatchName("SRB2BACK", PU_CACHE); + + if (cv_grscreentextures.value != 3) + V_DrawPatchFill(bgpatch); // use the neato kart bg for intermission on disabled screen textures + else + HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); } void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) -- 2.54.0 From 086d0113c5bbd58aaccaddcb487f7ee7cde1c347 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 May 2024 18:14:59 +0200 Subject: [PATCH 025/525] Optimize field lookups in Lua metatables https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2024#cd5b5ee262bf5129c4d400ad60d006e1fa917c1f --- src/lua_consolelib.c | 56 ++++++++-- src/lua_hudlib.c | 12 ++- src/lua_infolib.c | 231 ++++++++++++++++++++++++++++++----------- src/lua_maplib.c | 238 ++++++++++++++++++++++++++++++++++--------- src/lua_mobjlib.c | 148 ++++++++++++++++++--------- src/lua_playerlib.c | 83 +++++++++++---- src/lua_script.c | 37 +++++-- src/lua_script.h | 4 +- src/lua_skinlib.c | 7 +- 9 files changed, 622 insertions(+), 194 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 7d9cd67ec..ad1df2b22 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -580,27 +580,59 @@ static luaL_Reg lib[] = { {NULL, NULL} }; +enum cvar_e +{ + cvar_name, + cvar_defaultvalue, + cvar_flags, + cvar_value, + cvar_string, + cvar_changed, +}; + +static const char *const cvar_opt[] = { + "name", + "defaultvalue", + "flags", + "value", + "string", + "changed", + NULL, +}; + +static int cvar_fields_ref = LUA_NOREF; + static int cvar_get(lua_State *L) { consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR); - const char *field = luaL_checkstring(L, 2); + enum cvar_e field = Lua_optoption(L, 2, -1, cvar_fields_ref); - if(fastcmp(field,"name")) + switch (field) + { + case cvar_name: lua_pushstring(L, cvar->name); - else if(fastcmp(field,"defaultvalue")) + break; + case cvar_defaultvalue: lua_pushstring(L, cvar->defaultvalue); - else if(fastcmp(field,"flags")) + break; + case cvar_flags: lua_pushinteger(L, cvar->flags); - else if(fastcmp(field,"value")) + break; + case cvar_value: lua_pushinteger(L, cvar->value); - else if(fastcmp(field,"string")) + break; + case cvar_string: lua_pushstring(L, cvar->string); - else if(fastcmp(field,"changed")) + break; + case cvar_changed: lua_pushboolean(L, cvar->changed); - else if (devparm) - return luaL_error(L, LUA_QL("consvar_t") " has no field named " LUA_QS, field); - else - return 0; + break; + default: + if (devparm) + return luaL_error(L, LUA_QL("consvar_t") " has no field named " LUA_QS, field); + else + return 0; + } return 1; } @@ -612,6 +644,8 @@ int LUA_ConsoleLib(lua_State *L) lua_setfield(L, -2, "__index"); lua_pop(L,1); + cvar_fields_ref = Lua_CreateFieldTable(L, cvar_opt); + // Set empty registry tables lua_newtable(L); lua_setfield(L, LUA_REGISTRYINDEX, "COM_Command"); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index bc56e6688..0af7f2c36 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -106,6 +106,8 @@ static const char *const hudhook_opt[] = { "vote", NULL}; +static int patch_fields_ref = LUA_NOREF; + // alignment types for v.drawString enum align { align_left = 0, @@ -229,6 +231,8 @@ static const char *const hud_drawinfo_options[] = { "minimap", NULL}; +static int camera_fields_ref = LUA_NOREF; + static int lib_getHudInfo(lua_State *L) { UINT32 i; @@ -298,7 +302,7 @@ static int colormap_get(lua_State *L) static int patch_get(lua_State *L) { patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH)); - enum patch field = luaL_checkoption(L, 2, NULL, patch_opt); + enum patch field = Lua_optoption(L, 2, -1, patch_fields_ref); // patches are CURRENTLY always valid, expected to be cached with PU_STATIC // this may change in the future, so patch.valid still exists @@ -333,7 +337,7 @@ static int patch_set(lua_State *L) static int camera_get(lua_State *L) { camera_t *cam = *((camera_t **)luaL_checkudata(L, 1, META_CAMERA)); - enum cameraf field = luaL_checkoption(L, 2, NULL, camera_opt); + enum cameraf field = Lua_optoption(L, 2, -1, camera_fields_ref); // cameras should always be valid unless I'm a nutter I_Assert(cam != NULL); @@ -1439,11 +1443,15 @@ int LUA_HudLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L,1); + patch_fields_ref = Lua_CreateFieldTable(L, patch_opt); + luaL_newmetatable(L, META_CAMERA); lua_pushcfunction(L, camera_get); lua_setfield(L, -2, "__index"); lua_pop(L,1); + camera_fields_ref = Lua_CreateFieldTable(L, camera_opt); + luaL_register(L, "hud", lib_hud); return 0; } diff --git a/src/lua_infolib.c b/src/lua_infolib.c index c94b42b5b..5c6918890 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -565,75 +565,161 @@ static int lib_mobjinfolen(lua_State *L) return 1; } +enum mobjinfo_e +{ + mobjinfo_doomednum, + mobjinfo_spawnstate, + mobjinfo_spawnhealth, + mobjinfo_seestate, + mobjinfo_seesound, + mobjinfo_reactiontime, + mobjinfo_attacksound, + mobjinfo_painstate, + mobjinfo_painchance, + mobjinfo_painsound, + mobjinfo_meleestate, + mobjinfo_missilestate, + mobjinfo_deathstate, + mobjinfo_xdeathstate, + mobjinfo_deathsound, + mobjinfo_speed, + mobjinfo_radius, + mobjinfo_height, + mobjinfo_dispoffset, + mobjinfo_mass, + mobjinfo_damage, + mobjinfo_activesound, + mobjinfo_flags, + mobjinfo_raisestate, +}; + +const char *const mobjinfo_opt[] = { + "doomednum", + "spawnstate", + "spawnhealth", + "seestate", + "seesound", + "reactiontime", + "attacksound", + "painstate", + "painchance", + "painsound", + "meleestate", + "missilestate", + "deathstate", + "xdeathstate", + "deathsound", + "speed", + "radius", + "height", + "dispoffset", + "mass", + "damage", + "activesound", + "flags", + "raisestate", + NULL, +}; + +static int mobjinfo_fields_ref = LUA_NOREF; + // mobjinfo_t *, field -> number static int mobjinfo_get(lua_State *L) { mobjinfo_t *info = *((mobjinfo_t **)luaL_checkudata(L, 1, META_MOBJINFO)); - const char *field = luaL_checkstring(L, 2); + enum mobjinfo_e field = luaL_checkoption(L, 2, mobjinfo_opt[0], mobjinfo_opt); I_Assert(info != NULL); I_Assert(info >= mobjinfo); - if (fastcmp(field,"doomednum")) + switch (field) + { + case mobjinfo_doomednum: lua_pushinteger(L, info->doomednum); - else if (fastcmp(field,"spawnstate")) + break; + case mobjinfo_spawnstate: lua_pushinteger(L, info->spawnstate); - else if (fastcmp(field,"spawnhealth")) + break; + case mobjinfo_spawnhealth: lua_pushinteger(L, info->spawnhealth); - else if (fastcmp(field,"seestate")) + break; + case mobjinfo_seestate: lua_pushinteger(L, info->seestate); - else if (fastcmp(field,"seesound")) + break; + case mobjinfo_seesound: lua_pushinteger(L, info->seesound); - else if (fastcmp(field,"reactiontime")) + break; + case mobjinfo_reactiontime: lua_pushinteger(L, info->reactiontime); - else if (fastcmp(field,"attacksound")) + break; + case mobjinfo_attacksound: lua_pushinteger(L, info->attacksound); - else if (fastcmp(field,"painstate")) + break; + case mobjinfo_painstate: lua_pushinteger(L, info->painstate); - else if (fastcmp(field,"painchance")) + break; + case mobjinfo_painchance: lua_pushinteger(L, info->painchance); - else if (fastcmp(field,"painsound")) + break; + case mobjinfo_painsound: lua_pushinteger(L, info->painsound); - else if (fastcmp(field,"meleestate")) + break; + case mobjinfo_meleestate: lua_pushinteger(L, info->meleestate); - else if (fastcmp(field,"missilestate")) + break; + case mobjinfo_missilestate: lua_pushinteger(L, info->missilestate); - else if (fastcmp(field,"deathstate")) + break; + case mobjinfo_deathstate: lua_pushinteger(L, info->deathstate); - else if (fastcmp(field,"xdeathstate")) + break; + case mobjinfo_xdeathstate: lua_pushinteger(L, info->xdeathstate); - else if (fastcmp(field,"deathsound")) + break; + case mobjinfo_deathsound: lua_pushinteger(L, info->deathsound); - else if (fastcmp(field,"speed")) + break; + case mobjinfo_speed: lua_pushinteger(L, info->speed); // sometimes it's fixed_t, sometimes it's not... - else if (fastcmp(field,"radius")) + break; + case mobjinfo_radius: lua_pushfixed(L, info->radius); - else if (fastcmp(field,"height")) + break; + case mobjinfo_height: lua_pushfixed(L, info->height); - else if (fastcmp(field,"dispoffset")) + break; + case mobjinfo_dispoffset: lua_pushinteger(L, info->dispoffset); - else if (fastcmp(field,"mass")) + break; + case mobjinfo_mass: lua_pushinteger(L, info->mass); - else if (fastcmp(field,"damage")) + break; + case mobjinfo_damage: lua_pushinteger(L, info->damage); - else if (fastcmp(field,"activesound")) + break; + case mobjinfo_activesound: lua_pushinteger(L, info->activesound); - else if (fastcmp(field,"flags")) + break; + case mobjinfo_flags: lua_pushinteger(L, info->flags); - else if (fastcmp(field,"raisestate")) + break; + case mobjinfo_raisestate: lua_pushinteger(L, info->raisestate); - else { + break; + default: lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); lua_pushlightuserdata(L, info); lua_rawget(L, -2); if (!lua_istable(L, -1)) { // no extra values table - CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "mobjinfo_t", field); + CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "mobjinfo_t", lua_tostring(L, 2)); return 0; } - lua_getfield(L, -1, field); + lua_pushvalue(L, 2); // field name + lua_gettable(L, -2); if (lua_isnil(L, -1)) // no value for this field - CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "mobjinfo_t", field); + CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "mobjinfo_t", lua_tostring(L, 2)); + break; } return 1; } @@ -642,7 +728,7 @@ static int mobjinfo_get(lua_State *L) static int mobjinfo_set(lua_State *L) { mobjinfo_t *info = *((mobjinfo_t **)luaL_checkudata(L, 1, META_MOBJINFO)); - const char *field = luaL_checkstring(L, 2); + enum mobjinfo_e field = Lua_optoption(L, 2, -1, mobjinfo_fields_ref); if (hud_running) return luaL_error(L, "Do not alter mobjinfo in HUD rendering code!"); @@ -652,55 +738,81 @@ static int mobjinfo_set(lua_State *L) I_Assert(info != NULL); I_Assert(info >= mobjinfo); - if (fastcmp(field,"doomednum")) + switch (field) + { + case mobjinfo_doomednum: info->doomednum = (INT32)luaL_checkinteger(L, 3); - else if (fastcmp(field,"spawnstate")) + break; + case mobjinfo_spawnstate: info->spawnstate = luaL_checkinteger(L, 3); - else if (fastcmp(field,"spawnhealth")) + break; + case mobjinfo_spawnhealth: info->spawnhealth = (INT32)luaL_checkinteger(L, 3); - else if (fastcmp(field,"seestate")) + break; + case mobjinfo_seestate: info->seestate = luaL_checkinteger(L, 3); - else if (fastcmp(field,"seesound")) + break; + case mobjinfo_seesound: info->seesound = luaL_checkinteger(L, 3); - else if (fastcmp(field,"reactiontime")) + break; + case mobjinfo_reactiontime: info->reactiontime = (INT32)luaL_checkinteger(L, 3); - else if (fastcmp(field,"attacksound")) + break; + case mobjinfo_attacksound: info->attacksound = luaL_checkinteger(L, 3); - else if (fastcmp(field,"painstate")) + break; + case mobjinfo_painstate: info->painstate = luaL_checkinteger(L, 3); - else if (fastcmp(field,"painchance")) + break; + case mobjinfo_painchance: info->painchance = (INT32)luaL_checkinteger(L, 3); - else if (fastcmp(field,"painsound")) + break; + case mobjinfo_painsound: info->painsound = luaL_checkinteger(L, 3); - else if (fastcmp(field,"meleestate")) + break; + case mobjinfo_meleestate: info->meleestate = luaL_checkinteger(L, 3); - else if (fastcmp(field,"missilestate")) + break; + case mobjinfo_missilestate: info->missilestate = luaL_checkinteger(L, 3); - else if (fastcmp(field,"deathstate")) + break; + case mobjinfo_deathstate: info->deathstate = luaL_checkinteger(L, 3); - else if (fastcmp(field,"xdeathstate")) + break; + case mobjinfo_xdeathstate: info->xdeathstate = luaL_checkinteger(L, 3); - else if (fastcmp(field,"deathsound")) + break; + case mobjinfo_deathsound: info->deathsound = luaL_checkinteger(L, 3); - else if (fastcmp(field,"speed")) + break; + case mobjinfo_speed: info->speed = luaL_checkfixed(L, 3); - else if (fastcmp(field,"radius")) + break; + case mobjinfo_radius: info->radius = luaL_checkfixed(L, 3); - else if (fastcmp(field,"height")) + break; + case mobjinfo_height: info->height = luaL_checkfixed(L, 3); - else if (fastcmp(field,"dispoffset")) + break; + case mobjinfo_dispoffset: info->dispoffset = (INT32)luaL_checkinteger(L, 3); - else if (fastcmp(field,"mass")) + break; + case mobjinfo_mass: info->mass = (INT32)luaL_checkinteger(L, 3); - else if (fastcmp(field,"damage")) + break; + case mobjinfo_damage: info->damage = (INT32)luaL_checkinteger(L, 3); - else if (fastcmp(field,"activesound")) + break; + case mobjinfo_activesound: info->activesound = luaL_checkinteger(L, 3); - else if (fastcmp(field,"flags")) + break; + case mobjinfo_flags: info->flags = (INT32)luaL_checkinteger(L, 3); - else if (fastcmp(field,"raisestate")) + break; + case mobjinfo_raisestate: info->raisestate = luaL_checkinteger(L, 3); - else { + break; + default: lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); lua_pushlightuserdata(L, info); @@ -708,18 +820,17 @@ static int mobjinfo_set(lua_State *L) if (lua_isnil(L, -1)) { // This index doesn't have a table for extra values yet, let's make one. lua_pop(L, 1); - CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; adding it as Lua data.\n"), "mobjinfo_t", field); + CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; adding it as Lua data.\n"), "mobjinfo_t", lua_tostring(L, 2)); lua_newtable(L); lua_pushlightuserdata(L, info); lua_pushvalue(L, -2); // ext value table lua_rawset(L, -4); // LREG_EXTVARS table } + lua_pushvalue(L, 2); // key lua_pushvalue(L, 3); // value to store - lua_setfield(L, -2, field); + lua_settable(L, -3); lua_pop(L, 2); } - //else - //return luaL_error(L, LUA_QL("mobjinfo_t") " has no field named " LUA_QS, field); return 0; } @@ -921,6 +1032,8 @@ int LUA_InfoLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + mobjinfo_fields_ref = Lua_CreateFieldTable(L, mobjinfo_opt); + luaL_newmetatable(L, META_SFXINFO); lua_pushcfunction(L, sfxinfo_get); lua_setfield(L, -2, "__index"); diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 96222ba0a..2ae2ce395 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -71,6 +71,8 @@ enum subsector_e { subsector_firstline, }; +static int sector_fields_ref = LUA_NOREF; + static const char *const subsector_opt[] = { "valid", "sector", @@ -78,6 +80,8 @@ static const char *const subsector_opt[] = { "firstline", NULL}; +static int subsector_fields_ref = LUA_NOREF; + enum line_e { line_valid = 0, line_v1, @@ -120,6 +124,8 @@ static const char *const line_opt[] = { "callcount", NULL}; +static int line_fields_ref = LUA_NOREF; + enum side_e { side_valid = 0, side_textureoffset, @@ -146,6 +152,8 @@ static const char *const side_opt[] = { "text", NULL}; +static int side_fields_ref = LUA_NOREF; + enum vertex_e { vertex_valid = 0, vertex_x, @@ -160,6 +168,8 @@ static const char *const vertex_opt[] = { "z", NULL}; +static int vertex_fields_ref = LUA_NOREF; + enum ffloor_e { ffloor_valid = 0, ffloor_topheight, @@ -196,6 +206,8 @@ static const char *const ffloor_opt[] = { "alpha", NULL}; +static int ffloor_fields_ref = LUA_NOREF; + enum slope_e { slope_valid = 0, slope_o, @@ -222,6 +234,8 @@ static const char *const slope_opt[] = { "flags", NULL}; +static int slope_fields_ref = LUA_NOREF; + // shared by both vector2_t and vector3_t enum vector_e { vector_x = 0, @@ -387,7 +401,7 @@ static int sectorlines_num(lua_State *L) static int sector_get(lua_State *L) { sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); - enum sector_e field = luaL_checkoption(L, 2, sector_opt[0], sector_opt); + enum sector_e field = Lua_optoption(L, 2, sector_valid, sector_fields_ref); INT16 i; if (!sector) @@ -473,7 +487,7 @@ static int sector_get(lua_State *L) static int sector_set(lua_State *L) { sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); - enum sector_e field = luaL_checkoption(L, 2, sector_opt[0], sector_opt); + enum sector_e field = Lua_optoption(L, 2, sector_valid, sector_fields_ref); if (!sector) return luaL_error(L, "accessed sector_t doesn't exist anymore."); @@ -551,7 +565,7 @@ static int sector_num(lua_State *L) static int subsector_get(lua_State *L) { subsector_t *subsector = *((subsector_t **)luaL_checkudata(L, 1, META_SUBSECTOR)); - enum subsector_e field = luaL_checkoption(L, 2, subsector_opt[0], subsector_opt); + enum subsector_e field = Lua_optoption(L, 2, subsector_valid, subsector_fields_ref); if (!subsector) { @@ -590,7 +604,7 @@ static int subsector_num(lua_State *L) static int line_get(lua_State *L) { line_t *line = *((line_t **)luaL_checkudata(L, 1, META_LINE)); - enum line_e field = luaL_checkoption(L, 2, line_opt[0], line_opt); + enum line_e field = Lua_optoption(L, 2, line_valid, line_fields_ref); if (!line) { @@ -715,7 +729,7 @@ static int sidenum_get(lua_State *L) static int side_get(lua_State *L) { side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE)); - enum side_e field = luaL_checkoption(L, 2, side_opt[0], side_opt); + enum side_e field = Lua_optoption(L, 2, side_valid, side_fields_ref); if (!side) { @@ -765,7 +779,7 @@ static int side_get(lua_State *L) static int side_set(lua_State *L) { side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE)); - enum side_e field = luaL_checkoption(L, 2, side_opt[0], side_opt); + enum side_e field = Lua_optoption(L, 2, side_valid, side_fields_ref); if (!side) { @@ -816,7 +830,7 @@ static int side_num(lua_State *L) static int vertex_get(lua_State *L) { vertex_t *vertex = *((vertex_t **)luaL_checkudata(L, 1, META_VERTEX)); - enum vertex_e field = luaL_checkoption(L, 2, vertex_opt[0], vertex_opt); + enum vertex_e field = Lua_optoption(L, 2, vertex_valid, vertex_fields_ref); if (!vertex) { @@ -1085,7 +1099,7 @@ static int lib_numvertexes(lua_State *L) static int ffloor_get(lua_State *L) { ffloor_t *ffloor = *((ffloor_t **)luaL_checkudata(L, 1, META_FFLOOR)); - enum ffloor_e field = luaL_checkoption(L, 2, ffloor_opt[0], ffloor_opt); + enum ffloor_e field = Lua_optoption(L, 2, ffloor_valid, ffloor_fields_ref); INT16 i; if (!ffloor) @@ -1161,7 +1175,7 @@ static int ffloor_get(lua_State *L) static int ffloor_set(lua_State *L) { ffloor_t *ffloor = *((ffloor_t **)luaL_checkudata(L, 1, META_FFLOOR)); - enum ffloor_e field = luaL_checkoption(L, 2, ffloor_opt[0], ffloor_opt); + enum ffloor_e field = Lua_optoption(L, 2, ffloor_valid, ffloor_fields_ref); if (!ffloor) return luaL_error(L, "accessed ffloor_t doesn't exist anymore."); @@ -1239,7 +1253,7 @@ static int ffloor_set(lua_State *L) static int slope_get(lua_State *L) { pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE)); - enum slope_e field = luaL_checkoption(L, 2, slope_opt[0], slope_opt); + enum slope_e field = Lua_optoption(L, 2, slope_valid, slope_fields_ref); if (!slope) { @@ -1289,7 +1303,7 @@ static int slope_get(lua_State *L) static int slope_set(lua_State *L) { pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE)); - enum slope_e field = luaL_checkoption(L, 2, slope_opt[0], slope_opt); + enum slope_e field = Lua_optoption(L, 2, slope_valid, slope_fields_ref); if (!slope) return luaL_error(L, "accessed pslope_t doesn't exist anymore."); @@ -1446,86 +1460,197 @@ static int lib_nummapheaders(lua_State *L) return 1; } +enum mapheaderinfo_e +{ + mapheaderinfo_lvlttl, + mapheaderinfo_subttl, + mapheaderinfo_zonttl, + mapheaderinfo_actnum, + mapheaderinfo_typeoflevel, + mapheaderinfo_nextlevel, + mapheaderinfo_musname, + mapheaderinfo_mustrack, + mapheaderinfo_muspos, + mapheaderinfo_musinterfadeout, + mapheaderinfo_musintername, + mapheaderinfo_forcecharacter, + mapheaderinfo_weather, + mapheaderinfo_skynum, + mapheaderinfo_skybox_scalex, + mapheaderinfo_skybox_scaley, + mapheaderinfo_skybox_scalez, + mapheaderinfo_interscreen, + mapheaderinfo_runsoc, + mapheaderinfo_scriptname, + mapheaderinfo_precutscenenum, + mapheaderinfo_cutscenenum, + mapheaderinfo_countdown, + mapheaderinfo_palette, + mapheaderinfo_numlaps, + mapheaderinfo_unlockrequired, + mapheaderinfo_levelselect, + mapheaderinfo_bonustype, + mapheaderinfo_saveoverride, + mapheaderinfo_levelflags, + mapheaderinfo_menuflags, + //mapheaderinfo_automap, + mapheaderinfo_mobj_scale, +}; + +static const char *const mapheaderinfo_opt[] = { + "lvlttl", + "subttl", + "zonttl", + "actnum", + "typeoflevel", + "nextlevel", + "musname", + "mustrack", + "muspos", + "musinterfadeout", + "musintername", + "forcecharacter", + "weather", + "skynum", + "skybox_scalex", + "skybox_scaley", + "skybox_scalez", + "interscreen", + "runsoc", + "scriptname", + "precutscenenum", + "cutscenenum", + "countdown", + "palette", + "numlaps", + "unlockrequired", + "levelselect", + "bonustype", + "saveoverride", + "levelflags", + "menuflags", + //"automap", + "mobj_scale", + NULL, +}; + +static int mapheaderinfo_fields_ref = LUA_NOREF; + static int mapheaderinfo_get(lua_State *L) { mapheader_t *header = *((mapheader_t **)luaL_checkudata(L, 1, META_MAPHEADER)); - const char *field = luaL_checkstring(L, 2); + enum mapheaderinfo_e field = Lua_optoption(L, 2, -1, mapheaderinfo_fields_ref); INT16 i; - if (fastcmp(field,"lvlttl")) + switch (field) + { + case mapheaderinfo_lvlttl: lua_pushstring(L, header->lvlttl); - else if (fastcmp(field,"subttl")) + break; + case mapheaderinfo_subttl: lua_pushstring(L, header->subttl); - else if (fastcmp(field,"zonttl")) + break; + case mapheaderinfo_zonttl: lua_pushstring(L, header->zonttl); - else if (fastcmp(field,"actnum")) + break; + case mapheaderinfo_actnum: lua_pushstring(L, header->actnum); - else if (fastcmp(field,"typeoflevel")) + break; + case mapheaderinfo_typeoflevel: lua_pushinteger(L, header->typeoflevel); - else if (fastcmp(field,"nextlevel")) + break; + case mapheaderinfo_nextlevel: lua_pushinteger(L, header->nextlevel); - else if (fastcmp(field,"musname")) + break; + case mapheaderinfo_musname: lua_pushstring(L, header->musname); - else if (fastcmp(field,"mustrack")) + break; + case mapheaderinfo_mustrack: lua_pushinteger(L, header->mustrack); - else if (fastcmp(field,"muspos")) + break; + case mapheaderinfo_muspos: lua_pushinteger(L, header->muspos); - else if (fastcmp(field,"musinterfadeout")) + break; + case mapheaderinfo_musinterfadeout: lua_pushinteger(L, header->musinterfadeout); - else if (fastcmp(field,"musintername")) + break; + case mapheaderinfo_musintername: lua_pushstring(L, header->musintername); - else if (fastcmp(field,"forcecharacter")) + break; + case mapheaderinfo_forcecharacter: lua_pushstring(L, header->forcecharacter); - else if (fastcmp(field,"weather")) + break; + case mapheaderinfo_weather: lua_pushinteger(L, header->weather); - else if (fastcmp(field,"skynum")) + break; + case mapheaderinfo_skynum: lua_pushinteger(L, header->skynum); - else if (fastcmp(field,"skybox_scalex")) + break; + case mapheaderinfo_skybox_scalex: lua_pushinteger(L, header->skybox_scalex); - else if (fastcmp(field,"skybox_scaley")) + break; + case mapheaderinfo_skybox_scaley: lua_pushinteger(L, header->skybox_scaley); - else if (fastcmp(field,"skybox_scalez")) + break; + case mapheaderinfo_skybox_scalez: lua_pushinteger(L, header->skybox_scalez); - else if (fastcmp(field,"interscreen")) { + break; + case mapheaderinfo_interscreen: for (i = 0; i < 8; i++) if (!header->interscreen[i]) break; lua_pushlstring(L, header->interscreen, i); - } else if (fastcmp(field,"runsoc")) + break; + case mapheaderinfo_runsoc: lua_pushstring(L, header->runsoc); - else if (fastcmp(field,"scriptname")) + break; + case mapheaderinfo_scriptname: lua_pushstring(L, header->scriptname); - else if (fastcmp(field,"precutscenenum")) + break; + case mapheaderinfo_precutscenenum: lua_pushinteger(L, header->precutscenenum); - else if (fastcmp(field,"cutscenenum")) + break; + case mapheaderinfo_cutscenenum: lua_pushinteger(L, header->cutscenenum); - else if (fastcmp(field,"countdown")) + break; + case mapheaderinfo_countdown: lua_pushinteger(L, header->countdown); - else if (fastcmp(field,"palette")) + break; + case mapheaderinfo_palette: lua_pushinteger(L, header->palette); - else if (fastcmp(field,"numlaps")) + break; + case mapheaderinfo_numlaps: lua_pushinteger(L, header->numlaps); - else if (fastcmp(field,"unlockrequired")) + break; + case mapheaderinfo_unlockrequired: lua_pushinteger(L, header->unlockrequired); - else if (fastcmp(field,"levelselect")) + break; + case mapheaderinfo_levelselect: lua_pushinteger(L, header->levelselect); - else if (fastcmp(field,"bonustype")) + break; + case mapheaderinfo_bonustype: lua_pushinteger(L, header->bonustype); - else if (fastcmp(field,"saveoverride")) + break; + case mapheaderinfo_saveoverride: lua_pushinteger(L, header->saveoverride); - else if (fastcmp(field,"levelflags")) + break; + case mapheaderinfo_levelflags: lua_pushinteger(L, header->levelflags); - else if (fastcmp(field,"menuflags")) + break; + case mapheaderinfo_menuflags: lua_pushinteger(L, header->menuflags); - /*else if (fastcmp(field,"automap")) - lua_pushboolean(L, header->automap);*/ - else if (fastcmp(field,"mobj_scale")) + break; + /*case mapheaderinfo_automap: + lua_pushstring(L, header->selectheading); + break;*/ + case mapheaderinfo_mobj_scale: lua_pushfixed(L, header->mobj_scale); + break; // TODO add support for reading numGradedMares and grades - else { + default: // Read custom vars now // (note: don't include the "LUA." in your lua scripts!) UINT8 j = 0; - for (;j < header->numCustomOptions && !fastcmp(field, header->customopts[j].option); ++j); + for (;j < header->numCustomOptions && !fastcmp(lua_tostring(L, 2), header->customopts[j].option); ++j); if(j < header->numCustomOptions) lua_pushstring(L, header->customopts[j].value); @@ -1533,6 +1658,7 @@ static int mapheaderinfo_get(lua_State *L) lua_pushnil(L); } return 1; + } int LUA_MapLib(lua_State *L) @@ -1556,6 +1682,8 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + sector_fields_ref = Lua_CreateFieldTable(L, sector_opt); + luaL_newmetatable(L, META_SUBSECTOR); lua_pushcfunction(L, subsector_get); lua_setfield(L, -2, "__index"); @@ -1564,6 +1692,8 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + subsector_fields_ref = Lua_CreateFieldTable(L, subsector_opt); + luaL_newmetatable(L, META_LINE); lua_pushcfunction(L, line_get); lua_setfield(L, -2, "__index"); @@ -1572,6 +1702,8 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + line_fields_ref = Lua_CreateFieldTable(L, line_opt); + luaL_newmetatable(L, META_SIDENUM); lua_pushcfunction(L, sidenum_get); lua_setfield(L, -2, "__index"); @@ -1588,6 +1720,8 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + side_fields_ref = Lua_CreateFieldTable(L, side_opt); + luaL_newmetatable(L, META_VERTEX); lua_pushcfunction(L, vertex_get); lua_setfield(L, -2, "__index"); @@ -1596,6 +1730,8 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + vertex_fields_ref = Lua_CreateFieldTable(L, vertex_opt); + luaL_newmetatable(L, META_FFLOOR); lua_pushcfunction(L, ffloor_get); lua_setfield(L, -2, "__index"); @@ -1604,6 +1740,8 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L, 1); + ffloor_fields_ref = Lua_CreateFieldTable(L, ffloor_opt); + luaL_newmetatable(L, META_SLOPE); lua_pushcfunction(L, slope_get); lua_setfield(L, -2, "__index"); @@ -1612,6 +1750,8 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L, 1); + slope_fields_ref = Lua_CreateFieldTable(L, slope_opt); + luaL_newmetatable(L, META_VECTOR2); lua_pushcfunction(L, vector2_get); lua_setfield(L, -2, "__index"); @@ -1630,6 +1770,8 @@ int LUA_MapLib(lua_State *L) //lua_setfield(L, -2, "__len"); lua_pop(L, 1); + mapheaderinfo_fields_ref = Lua_CreateFieldTable(L, mapheaderinfo_opt); + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getSector); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 7b1db5327..866ea6550 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -769,14 +769,41 @@ static int mobj_set(lua_State *L) #undef NOSETPOS #undef NOFIELD +enum mapthing_e { + mapthing_valid = 0, + mapthing_x, + mapthing_y, + mapthing_angle, + mapthing_type, + mapthing_options, + mapthing_z, + mapthing_extrainfo, + mapthing_mobj, +}; + +const char *const mapthing_opt[] = { + "valid", + "x", + "y", + "angle", + "type", + "options", + "z", + "extrainfo", + "mobj", + NULL, +}; + +static int mapthing_fields_ref = LUA_NOREF; + static int mapthing_get(lua_State *L) { mapthing_t *mt = *((mapthing_t **)luaL_checkudata(L, 1, META_MAPTHING)); - const char *field = luaL_checkstring(L, 2); - lua_Integer number; + enum mapthing_e field = Lua_optoption(L, 2, -1, mapthing_fields_ref); + lua_settop(L, 2); if (!mt) { - if (fastcmp(field,"valid")) { + if (field == mapthing_valid) { lua_pushboolean(L, false); return 1; } @@ -785,39 +812,50 @@ static int mapthing_get(lua_State *L) return 0; } - if (fastcmp(field,"valid")) { - lua_pushboolean(L, true); - return 1; - } else if(fastcmp(field,"x")) - number = mt->x; - else if(fastcmp(field,"y")) - number = mt->y; - else if(fastcmp(field,"angle")) - number = mt->angle; - else if(fastcmp(field,"type")) - number = mt->type; - else if(fastcmp(field,"options")) - number = mt->options; - else if(fastcmp(field,"z")) - number = mt->z; - else if(fastcmp(field,"extrainfo")) - number = mt->extrainfo; - else if(fastcmp(field,"mobj")) { - LUA_PushUserdata(L, mt->mobj, META_MOBJ); - return 1; - } else if (devparm) - return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field); - else - return 0; + switch (field) + { + case mapthing_valid: + lua_pushboolean(L, true); + break; + case mapthing_x: + lua_pushinteger(L, mt->x); + break; + case mapthing_y: + lua_pushinteger(L, mt->y); + break; + case mapthing_angle: + lua_pushinteger(L, mt->angle); + break; + case mapthing_type: + lua_pushinteger(L, mt->type); + break; + case mapthing_options: + lua_pushinteger(L, mt->options); + break; + case mapthing_z: + lua_pushinteger(L, mt->z); + break; + case mapthing_extrainfo: + lua_pushinteger(L, mt->extrainfo); + break; + case mapthing_mobj: + LUA_PushUserdata(L, mt->mobj, META_MOBJ); + break; + default: + if (devparm) + return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field); + else + return 0; + } - lua_pushinteger(L, number); return 1; } static int mapthing_set(lua_State *L) { mapthing_t *mt = *((mapthing_t **)luaL_checkudata(L, 1, META_MAPTHING)); - const char *field = luaL_checkstring(L, 2); + enum mapthing_e field = Lua_optoption(L, 2, -1, mapthing_fields_ref); + lua_settop(L, 3); if (!mt) return luaL_error(L, "accessed mapthing_t doesn't exist anymore."); @@ -827,24 +865,38 @@ static int mapthing_set(lua_State *L) if (hook_cmd_running) return luaL_error(L, "Do not alter mapthing_t in BuildCMD code!"); - if(fastcmp(field,"x")) - mt->x = (INT16)luaL_checkinteger(L, 3); - else if(fastcmp(field,"y")) - mt->y = (INT16)luaL_checkinteger(L, 3); - else if(fastcmp(field,"angle")) - mt->angle = (INT16)luaL_checkinteger(L, 3); - else if(fastcmp(field,"type")) - mt->type = (UINT16)luaL_checkinteger(L, 3); - else if(fastcmp(field,"options")) - mt->options = (UINT16)luaL_checkinteger(L, 3); - else if(fastcmp(field,"z")) - mt->z = (INT16)luaL_checkinteger(L, 3); - else if(fastcmp(field,"extrainfo")) - mt->extrainfo = (UINT8)luaL_checkinteger(L, 3); - else if(fastcmp(field,"mobj")) - mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); - else - return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field); + switch (field) + { + case mapthing_x: + mt->x = (INT16)luaL_checkinteger(L, 3); + break; + case mapthing_y: + mt->y = (INT16)luaL_checkinteger(L, 3); + break; + case mapthing_angle: + mt->angle = (INT16)luaL_checkinteger(L, 3); + break; + case mapthing_type: + mt->type = (UINT16)luaL_checkinteger(L, 3); + break; + case mapthing_options: + mt->options = (UINT16)luaL_checkinteger(L, 3); + break; + case mapthing_z: + mt->z = (INT16)luaL_checkinteger(L, 3); + break; + case mapthing_extrainfo: + INT32 extrainfo = luaL_checkinteger(L, 3); + if (extrainfo & ~15) + return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15); + mt->extrainfo = (UINT8)extrainfo; + break; + case mapthing_mobj: + mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + break; + default: + return luaL_error(L, LUA_QL("mapthing_t") " has no field named " LUA_QS, field); + } return 0; } @@ -915,6 +967,8 @@ int LUA_MobjLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L,1); + mapthing_fields_ref = Lua_CreateFieldTable(L, mapthing_opt); + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getMapthing); diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 70324fa02..2d79d536d 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -694,30 +694,65 @@ static int kartstuff_len(lua_State *L) } #define NOFIELD luaL_error(L, LUA_QL("ticcmd_t") " has no field named " LUA_QS, field) +#define NOSET luaL_error(L, LUA_QL("ticcmd_t") " field " LUA_QS " should not be set directly.", field) + +enum ticcmd_e +{ + ticcmd_forwardmove, + ticcmd_sidemove, + ticcmd_angleturn, + ticcmd_aiming, + ticcmd_buttons, + ticcmd_driftturn, + ticcmd_latency, +}; + +static const char *const ticcmd_opt[] = { + "forwardmove", + "sidemove", + "angleturn", + "aiming", + "buttons", + "driftturn", + "latency", + NULL, +}; + +static int ticcmd_fields_ref = LUA_NOREF; static int ticcmd_get(lua_State *L) { ticcmd_t *cmd = *((ticcmd_t **)luaL_checkudata(L, 1, META_TICCMD)); - const char *field = luaL_checkstring(L, 2); + enum ticcmd_e field = Lua_optoption(L, 2, -1, ticcmd_fields_ref); if (!cmd) return LUA_ErrInvalid(L, "player_t"); - if (fastcmp(field,"forwardmove")) + switch (field) + { + case ticcmd_forwardmove: lua_pushinteger(L, cmd->forwardmove); - else if (fastcmp(field,"sidemove")) + break; + case ticcmd_sidemove: lua_pushinteger(L, cmd->sidemove); - else if (fastcmp(field,"angleturn")) + break; + case ticcmd_angleturn: lua_pushinteger(L, cmd->angleturn); - else if (fastcmp(field,"aiming")) + break; + case ticcmd_aiming: lua_pushinteger(L, cmd->aiming); - else if (fastcmp(field,"buttons")) + break; + case ticcmd_buttons: lua_pushinteger(L, cmd->buttons); - else if (fastcmp(field,"driftturn")) + break; + case ticcmd_driftturn: lua_pushinteger(L, cmd->driftturn); - else if (fastcmp(field,"latency")) + break; + case ticcmd_latency: lua_pushinteger(L, cmd->latency); - else + break; + default: return NOFIELD; + } return 1; } @@ -725,32 +760,44 @@ static int ticcmd_get(lua_State *L) static int ticcmd_set(lua_State *L) { ticcmd_t *cmd = *((ticcmd_t **)luaL_checkudata(L, 1, META_TICCMD)); - const char *field = luaL_checkstring(L, 2); + enum ticcmd_e field = Lua_optoption(L, 2, -1, ticcmd_fields_ref); if (!cmd) return LUA_ErrInvalid(L, "ticcmd_t"); if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); - if (fastcmp(field,"forwardmove")) + switch (field) + { + case ticcmd_forwardmove: cmd->forwardmove = (SINT8)luaL_checkinteger(L, 3); - else if (fastcmp(field,"sidemove")) + break; + case ticcmd_sidemove: cmd->sidemove = (SINT8)luaL_checkinteger(L, 3); - else if (fastcmp(field,"angleturn")) + break; + case ticcmd_angleturn: cmd->angleturn = (INT16)luaL_checkinteger(L, 3); - else if (fastcmp(field,"aiming")) + break; + case ticcmd_aiming: cmd->aiming = (INT16)luaL_checkinteger(L, 3); - else if (fastcmp(field,"buttons")) + break; + case ticcmd_buttons: cmd->buttons = (UINT16)luaL_checkinteger(L, 3); - else if (fastcmp(field,"driftturn")) + break; + case ticcmd_driftturn: cmd->driftturn = (INT16)luaL_checkinteger(L, 3); - else + break; + case ticcmd_latency: + return NOSET; + default: return NOFIELD; + } return 0; } #undef NOFIELD +#undef NOSET int LUA_PlayerLib(lua_State *L) { @@ -797,6 +844,8 @@ int LUA_PlayerLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L,1); + ticcmd_fields_ref = Lua_CreateFieldTable(L, ticcmd_opt); + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getPlayer); diff --git a/src/lua_script.c b/src/lua_script.c index 3af655efe..381448e72 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1678,13 +1678,36 @@ void LUA_UnArchiveDemo(void) } // For mobj_t, player_t, etc. to take custom variables. -int Lua_optoption(lua_State *L, int narg, - const char *def, const char *const lst[]) +int Lua_optoption(lua_State *L, int narg, int def, int list_ref) { - const char *name = (def) ? luaL_optstring(L, narg, def) : luaL_checkstring(L, narg); - int i; - for (i=0; lst[i]; i++) - if (fastcmp(lst[i], name)) - return i; + if (lua_isnoneornil(L, narg)) + return def; + + I_Assert(lua_checkstack(L, 2)); + luaL_checkstring(L, narg); + + lua_rawgeti(L, LUA_REGISTRYINDEX, list_ref); + I_Assert(lua_istable(L, -1)); + lua_pushvalue(L, narg); + lua_rawget(L, -2); + + if (lua_isnumber(L, -1)) + return lua_tointeger(L, -1); return -1; +} + + +int Lua_CreateFieldTable(lua_State *L, const char *const lst[]) +{ + int i; + + lua_newtable(L); + for (i = 0; lst[i] != NULL; i++) + { + lua_pushstring(L, lst[i]); + lua_pushinteger(L, i); + lua_settable(L, -3); + } + + return luaL_ref(L, LUA_REGISTRYINDEX); } \ No newline at end of file diff --git a/src/lua_script.h b/src/lua_script.h index a22e47c12..9903315c2 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -63,8 +63,8 @@ void LUA_UnArchiveDemo(void); void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c void LUA_CVarChanged(const char *name); // lua_consolelib.c -int Lua_optoption(lua_State *L, int narg, - const char *def, const char *const lst[]); +int Lua_optoption(lua_State *L, int narg, int def, int list_ref); +int Lua_CreateFieldTable(lua_State *L, const char *const lst[]); void LUAh_NetArchiveHook(lua_CFunction archFunc); // Console wrapper diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 286e983c1..403ac834e 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -38,6 +38,7 @@ enum skin { skin_highresscale, skin_soundsid }; + static const char *const skin_opt[] = { "valid", "name", @@ -61,10 +62,12 @@ static const char *const skin_opt[] = { #define UNIMPLEMENTED luaL_error(L, LUA_QL("skin_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", skin_opt[field]) +static int skin_fields_ref = LUA_NOREF; + static int skin_get(lua_State *L) { skin_t *skin = *((skin_t **)luaL_checkudata(L, 1, META_SKIN)); - enum skin field = luaL_checkoption(L, 2, NULL, skin_opt); + enum skin field = Lua_optoption(L, 2, -1, skin_fields_ref); INT32 i; // skins are always valid, only added, never removed @@ -253,6 +256,8 @@ int LUA_SkinLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L,1); + skin_fields_ref = Lua_CreateFieldTable(L, skin_opt); + luaL_newmetatable(L, META_SOUNDSID); lua_pushcfunction(L, soundsid_get); lua_setfield(L, -2, "__index"); -- 2.54.0 From 4847e4e3cb19a60c9b38a0e5bb2ad880e199f4c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 May 2024 22:22:48 +0200 Subject: [PATCH 026/525] that should be there lul --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index dfe05dbdf..183b6b93e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2029,6 +2029,7 @@ void R_AddPrecipitationSprites(void) INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th, *next; + // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off if (drawdist == 0) { return; @@ -2036,7 +2037,6 @@ void R_AddPrecipitationSprites(void) R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh); - // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off for (bx = xl; bx <= xh; bx++) { for (by = yl; by <= yh; by++) -- 2.54.0 From 455bbe47c283620d182e264b24931e814fcc7cc9 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 May 2024 22:38:20 +0200 Subject: [PATCH 027/525] smth smth encore magic numbers idk --- src/hardware/hw_cache.c | 8 +++++--- src/hardware/hw_main.c | 4 ++-- src/r_draw8.c | 4 ++-- src/r_main.h | 3 +++ src/r_plane.c | 4 ++-- src/r_segs.c | 16 ++++++++-------- src/r_things.c | 4 ++-- 7 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 848f8243f..2a5ec4ff5 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -26,6 +26,7 @@ #include "../z_zone.h" #include "../v_video.h" #include "../r_draw.h" +#include "../r_main.h" #include "../r_patch.h" // patch rotation INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes @@ -344,7 +345,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe #ifdef GLENCORE if (encoremap && !noencore) - grtex->mipmap.colormap += (256*32); + grtex->mipmap.colormap += COLORMAP_REMAPOFFSET; #endif blockwidth = texture->width; @@ -647,7 +648,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) #ifdef GLENCORE if (!noencoremap && encoremap) - grmip->colormap += (256*32); + grmip->colormap += COLORMAP_REMAPOFFSET; #endif if (!grmip->downloaded && !grmip->data) @@ -729,7 +730,8 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap) { GLMipmap_t *grmip, *newmip; - if (colormap == colormaps || colormap == NULL) + // Blatant hack for encore colormapping aside... + if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET)) { // Load the default (green) color in doom cache (temporary?) AND hardware cache HWR_GetPatch(gpatch); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fc137c109..4893bd5f3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5285,7 +5285,7 @@ void HWR_ProjectSprite(mobj_t *thing) vis->colormap = colormaps; #ifdef GLENCORE if (encoremap && !(thing->flags & MF_DONTENCOREMAP)) - vis->colormap += (256*32); + vis->colormap += COLORMAP_REMAPOFFSET; #endif } @@ -5416,7 +5416,7 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #ifdef GLENCORE if (encoremap && !(thing->flags & MF_DONTENCOREMAP)) - vis->colormap += (256*32); + vis->colormap += COLORMAP_REMAPOFFSET; #endif // set top/bottom coords diff --git a/src/r_draw8.c b/src/r_draw8.c index 93a0796a3..f3ebf0ff9 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -1696,7 +1696,7 @@ void R_DrawColumnShadowed_8(void) { dc_colormap = dc_lightlist[i].rcolormap; if (encoremap) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; if (solid && dc_yl < bheight) dc_yl = bheight; continue; @@ -1714,7 +1714,7 @@ void R_DrawColumnShadowed_8(void) dc_colormap = dc_lightlist[i].rcolormap; if (encoremap) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; } dc_yh = realyh; if (dc_yl <= realyh) diff --git a/src/r_main.h b/src/r_main.h index 56e351138..7c2249873 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -64,6 +64,9 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; // There a 0-31, i.e. 32 LUT in the COLORMAP lump. #define NUMCOLORMAPS 32 +#define COLORMAP_SIZE (256*LIGHTLEVELS) +#define COLORMAP_REMAPOFFSET COLORMAP_SIZE + // Utility functions. INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *node); INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line); diff --git a/src/r_plane.c b/src/r_plane.c index f89e10330..6bd6f212d 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -295,7 +295,7 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) ds_colormap = planezlight[pindex]; } if (encoremap && !currentplane->noencore) - ds_colormap += (256*32); + ds_colormap += COLORMAP_REMAPOFFSET; if (currentplane->extra_colormap) ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps); @@ -675,7 +675,7 @@ static void R_DrawSkyPlane(visplane_t *pl) // by INVUL inverse mapping. dc_colormap = colormaps; if (encoremap) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; dc_texturemid = skytexturemid; dc_texheight = textureheight[skytexture] >>FRACBITS; diff --git a/src/r_segs.c b/src/r_segs.c index 219b142e0..4a231938b 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -208,7 +208,7 @@ static void R_DrawWallSplats(void) pindex = MAXLIGHTSCALE - 1; dc_colormap = walllights[pindex]; if (encoremap && !(seg->linedef->flags & ML_TFERLINE)) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; if (frontsector->extra_colormap) dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); @@ -573,7 +573,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) { dc_colormap = rlight->rcolormap; if (encoremap && !(ldef->flags & ML_TFERLINE)) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; continue; } @@ -594,7 +594,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) windowtop = windowbottom + 1; dc_colormap = rlight->rcolormap; if (encoremap && !(ldef->flags & ML_TFERLINE)) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; } windowbottom = realbot; if (windowtop < windowbottom) @@ -612,7 +612,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) dc_colormap = walllights[pindex]; if (encoremap && !(ldef->flags & ML_TFERLINE)) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; if (frontsector->extra_colormap) dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); @@ -1107,7 +1107,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { dc_colormap = rlight->rcolormap; if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; } if (solid && windowtop < bheight) windowtop = bheight; @@ -1139,7 +1139,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { dc_colormap = rlight->rcolormap; if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; } } windowbottom = sprbotscreen; @@ -1160,7 +1160,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) dc_colormap = walllights[pindex]; if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap) dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps); @@ -1396,7 +1396,7 @@ static void R_RenderSegLoop (void) dc_colormap = walllights[pindex]; if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; dc_x = rw_x; dc_iscale = 0xffffffffu / (unsigned)rw_scale; diff --git a/src/r_things.c b/src/r_things.c index 183b6b93e..933181ce7 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -816,7 +816,7 @@ static void R_DrawVisSprite(vissprite_t *vis) dc_colormap = colormaps; if (encoremap && !vis->mobj->color && !(vis->mobj->flags & MF_DONTENCOREMAP)) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; dc_texturemid = vis->texturemid; dc_texheight = 0; @@ -939,7 +939,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) dc_colormap = colormaps; if (encoremap) - dc_colormap += (256*32); + dc_colormap += COLORMAP_REMAPOFFSET; dc_iscale = FixedDiv(FRACUNIT, vis->scale); dc_texturemid = vis->texturemid; -- 2.54.0 From 37d3e2ae1a679f437c6333d7b58074d9e84801d1 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 May 2024 20:02:54 +0200 Subject: [PATCH 028/525] scale sprite draw distance with mapobjscale --- src/hardware/hw_main.c | 8 ++++---- src/r_things.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4893bd5f3..750b245fc 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4795,12 +4795,12 @@ void HWR_AddSprites(sector_t *sec) { // Use the smaller setting if (cv_drawdist.value) - limit_dist = min(current_bsp_culling_distance, cv_drawdist.value << FRACBITS); + limit_dist = min(current_bsp_culling_distance, (fixed_t)(cv_drawdist.value) * mapobjectscale); else limit_dist = current_bsp_culling_distance; } else - limit_dist = cv_drawdist.value << FRACBITS; + limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; // Handle all things in sector. // If a limit exists, handle things a tiny bit different. @@ -4903,9 +4903,9 @@ static void HWR_AddPrecipitationSprites(void) precipmobj_t *th; if (current_bsp_culling_distance) - drawdist = min(current_bsp_culling_distance, cv_drawdist_precip.value * mapobjectscale); + drawdist = min(current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * mapobjectscale); else - drawdist = cv_drawdist_precip.value * mapobjectscale; + drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale; // No to infinite precipitation draw distance. if (drawdist == 0) diff --git a/src/r_things.c b/src/r_things.c index 933181ce7..64468ffa9 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1932,7 +1932,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - if ((limit_dist = (fixed_t)(/*(maptol & TOL_NIGHTS) ? cv_drawdist_nights.value : */cv_drawdist.value) << FRACBITS)) + if ((limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale)) { for (thing = sec->thinglist; thing; thing = thing->snext) { @@ -2024,7 +2024,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // void R_AddPrecipitationSprites(void) { - const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; + const fixed_t drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale; INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th, *next; -- 2.54.0 From faa5dbd0e73057bb19cacfa7daa3a18d86f260ee Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 May 2024 20:55:03 +0200 Subject: [PATCH 029/525] split sprite draw loops so crap doesent constantly check for papersprites on all sprites --- src/r_things.c | 61 ++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 64468ffa9..1ea932ac3 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -724,9 +724,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) static void R_DrawVisSprite(vissprite_t *vis) { column_t *column; -#ifdef RANGECHECK INT32 texturecolumn; -#endif fixed_t frac; patch_t *patch = vis->patch; fixed_t this_scale = vis->thingscale; @@ -874,12 +872,16 @@ static void R_DrawVisSprite(vissprite_t *vis) } #endif - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) +#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) + + // Split drawing loops for paper and non-paper to reduce conditional checks per sprite + if (vis->scalestep) { fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); - if (vis->scalestep) // currently papersprites only - { + // Papersprite drawing loop + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) + { #ifndef RANGECHECK if ((frac>>FRACBITS) < 0 || (frac>>FRACBITS) >= SHORT(patch->width)) // if this doesn't work i'm removing papersprites break; @@ -887,22 +889,30 @@ static void R_DrawVisSprite(vissprite_t *vis) sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); dc_iscale = (0xffffffffu / (unsigned)spryscale); spryscale += scalestep; + + texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + + if (vis->vflip) + R_DrawFlippedMaskedColumn(column, patch->height); + else + R_DrawMaskedColumn(column); } -#ifdef RANGECHECK - texturecolumn = frac>>FRACBITS; - - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) - I_Error("R_DrawSpriteRange: bad texturecolumn"); - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); -#else - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); -#endif - if (vis->vflip) - R_DrawFlippedMaskedColumn(column, patch->height); - else - R_DrawMaskedColumn(column); } + else + { + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) + { + texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + if (vis->vflip) + R_DrawFlippedMaskedColumn(column, patch->height); + else + R_DrawMaskedColumn(column); + } + } +#undef CLAMP colfunc = basecolfunc; dc_hires = 0; @@ -914,9 +924,7 @@ static void R_DrawVisSprite(vissprite_t *vis) static void R_DrawPrecipitationVisSprite(vissprite_t *vis) { column_t *column; -#ifdef RANGECHECK INT32 texturecolumn; -#endif fixed_t frac; patch_t *patch; INT64 overflow_test; @@ -956,20 +964,15 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) if (vis->x2 >= vid.width) vis->x2 = vid.width-1; +#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) { -#ifdef RANGECHECK - texturecolumn = frac>>FRACBITS; - - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) - I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn"); - + texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); -#else - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); -#endif + R_DrawMaskedColumn(column); } +#undef CLAMP colfunc = basecolfunc; } -- 2.54.0 From 040ddb1f40b17c84427c95a241a102c0e8f633bb Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 30 May 2024 19:23:14 +0300 Subject: [PATCH 030/525] Revert "Revert "Don't traverse the entire HOME directory to find wads"" This reverts commit 443905ffb3dd8904c395c9c50570ccc17b42dd27. --- src/sdl/i_system.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 9574d6ec5..48e513afc 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -4039,12 +4039,16 @@ static const char *locateWad(void) #endif #ifndef NOHOME // find in $HOME - I_OutputMsg(",HOME"); + I_OutputMsg(",HOME/" DEFAULTDIR); if ((envstr = I_GetEnv("HOME")) != NULL) { + char *tmp = malloc(strlen(envstr) + sizeof(DEFAULTDIR)); + strcpy(tmp, envstr); + strcat(tmp, DEFAULTDIR); WadPath = searchWad(envstr); if (WadPath) return WadPath; + free(tmp); } #endif #ifdef DEFAULTSEARCHPATH1 -- 2.54.0 From 6269c7c827feed85ef1bb246b4bed51c565bc6d5 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 30 May 2024 19:32:18 +0300 Subject: [PATCH 031/525] Use tmp variable for searchWad since envstr doesn't get changed --- src/sdl/i_system.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 48e513afc..7a5f79f58 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -4042,13 +4042,14 @@ static const char *locateWad(void) I_OutputMsg(",HOME/" DEFAULTDIR); if ((envstr = I_GetEnv("HOME")) != NULL) { - char *tmp = malloc(strlen(envstr) + sizeof(DEFAULTDIR)); + char *tmp = malloc(strlen(envstr) + sizeof(PATHSEP) + sizeof(DEFAULTDIR)); strcpy(tmp, envstr); + strcat(tmp, PATHSEP); strcat(tmp, DEFAULTDIR); - WadPath = searchWad(envstr); + WadPath = searchWad(tmp); + free(tmp); if (WadPath) return WadPath; - free(tmp); } #endif #ifdef DEFAULTSEARCHPATH1 -- 2.54.0 From dc03359f3a44481338715be809ebf9038bd47e6f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 30 May 2024 19:59:01 +0200 Subject: [PATCH 032/525] theres no value 3 oops i shouldnt do stuff after waking up at 4 in the morning lol --- src/hardware/hw_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 750b245fc..3cf998d84 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -184,7 +184,7 @@ static void CV_anisotropic_ONChange(void) static void CV_screentextures_ONChange(void) { ONLY_IF_GL_LOADED - if (cv_grscreentextures.value != 3) + if (cv_grscreentextures.value != 2) { #ifdef USE_FBO_OGL CV_Set(&cv_grframebuffer, "Off"); @@ -6240,10 +6240,10 @@ void HWR_DrawIntermissionBG(void) { patch_t *bgpatch = W_CachePatchName("SRB2BACK", PU_CACHE); - if (cv_grscreentextures.value != 3) - V_DrawPatchFill(bgpatch); // use the neato kart bg for intermission on disabled screen textures - else + if (cv_grscreentextures.value == 2) HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); + else + V_DrawPatchFill(bgpatch); // use the neato kart bg for intermission on disabled screen textures } void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) -- 2.54.0 From b01a2836ea51bfd8d52b8b1116df8ee93052db3d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Jun 2024 16:29:40 +0200 Subject: [PATCH 033/525] cleanup some super old stuff that did nothing lul --- src/hardware/hw_glob.h | 2 -- src/r_defs.h | 9 +-------- src/r_patch.c | 4 ++-- src/r_things.c | 42 +++++++++++++++--------------------------- src/r_things.h | 2 -- 5 files changed, 18 insertions(+), 41 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index a5b66a429..542a99b33 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -30,11 +30,9 @@ typedef struct gr_vissprite_s float gz, gzt; float tz, ty; float scale; - //lumpnum_t patchlumpnum; float spritexscale, spriteyscale; float spritexoffset, spriteyoffset; UINT32 renderflags; - UINT8 rotateflags; GLPatch_t *gpatch; boolean flip; UINT8 translucency; //alpha level 0-255 diff --git a/src/r_defs.h b/src/r_defs.h index 81e3f0c3a..40a4db023 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -649,15 +649,8 @@ typedef struct INT16 leftoffset; // pixels to the left of origin INT16 topoffset; // pixels below the origin INT32 columnofs[8]; // only [width] used - UINT8 *columns; // Software column data // the [0] is &columnofs[width] - - void *hardware; // OpenGL patch, allocated whenever necessary - -#ifdef ROTSPRITE - rotsprite_t *rotated; // Rotated patches -#endif -} patch_t; +}ATTRPACK patch_t; #ifdef _MSC_VER #pragma warning(disable : 4200) diff --git a/src/r_patch.c b/src/r_patch.c index 597a1a0de..bf0f28aa9 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -48,8 +48,8 @@ boolean R_CheckIfPatch(lumpnum_t lump) patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); - width = patch->width; - height = patch->height; + width = SHORT(patch->width); + height = SHORT(patch->height); result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4)); diff --git a/src/r_things.c b/src/r_things.c index 1ea932ac3..8def2ff83 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -152,7 +152,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch } #endif/*ROTSPRITE*/ - if (rotation == 0) { // the lump should be used for all rotations @@ -578,10 +577,8 @@ static vissprite_t *R_GetVisSprite(UINT32 num) static vissprite_t *R_NewVisSprite(void) { - if (visspritecount == MAXVISSPRITES) { - //CONS_Alert(CONS_ERROR, M_GetText("R_NewVisSprite: too many vissprites requested (maximum is %i)\n"), MAXVISSPRITES); + if (visspritecount == MAXVISSPRITES) return &overflowsprite; - } return R_GetVisSprite(visspritecount++); } @@ -656,8 +653,6 @@ void R_DrawMaskedColumn(column_t *column) dc_texturemid = basetexturemid; } -INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height - static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) { INT32 topscreen; @@ -860,9 +855,6 @@ static void R_DrawVisSprite(vissprite_t *vis) if (vis->x2 >= vid.width) vis->x2 = vid.width-1; - lengthcol = SHORT(patch->height); - -#if 1 // Something is occasionally setting 1px-wide sprites whose frac is exactly the width of the sprite, causing crashes due to // accessing invalid column info. Until the cause is found, let's try to correct those manually... { @@ -870,7 +862,6 @@ static void R_DrawVisSprite(vissprite_t *vis) if (temp > 0) vis->x2 -= temp; } -#endif #define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) @@ -1177,6 +1168,7 @@ static void R_ProjectSprite(mobj_t *thing) // rotsprite fixed_t spr_width, spr_height; fixed_t spr_offset, spr_topoffset; + #ifdef ROTSPRITE patch_t *rotsprite = NULL; INT32 rollangle = 0; @@ -1482,7 +1474,6 @@ static void R_ProjectSprite(mobj_t *thing) scalestep = (yscale2 - yscale)/(x2 - x1); scalestep = scalestep ? scalestep : 1; - // The following two are alternate sorting methods which might be more applicable in some circumstances. TODO - maybe enable via MF2? // sortscale = max(yscale, yscale2); @@ -1558,16 +1549,13 @@ static void R_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { - fixed_t top = gzt; - fixed_t bottom = interp.z; - if (viewz < sectors[phs].floorheight ? - bottom >= sectors[heightsec].floorheight : - top < sectors[heightsec].floorheight) + interp.z >= sectors[heightsec].floorheight : + gzt < sectors[heightsec].floorheight) return; if (viewz > sectors[phs].ceilingheight ? - top < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : - bottom >= sectors[heightsec].ceilingheight) + gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : + interp.z >= sectors[heightsec].ceilingheight) return; } @@ -1594,6 +1582,15 @@ static void R_ProjectSprite(mobj_t *thing) vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; + // PORTAL SEMI-CLIPPING + if (portalrender) + { + if (vis->x1 < portalclipstart) + vis->x1 = portalclipstart; + if (vis->x2 > portalclipend) + vis->x2 = portalclipend; + } + vis->sector = thing->subsector->sector; vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS); vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS); @@ -1604,15 +1601,6 @@ static void R_ProjectSprite(mobj_t *thing) else vis->extra_colormap = thing->subsector->sector->extra_colormap; - // PORTAL SEMI-CLIPPING - if (portalrender) - { - if (vis->x1 < portalclipstart) - vis->x1 = portalclipstart; - if (vis->x2 > portalclipend) - vis->x2 = portalclipend; - } - vis->xscale = FixedMul(spritexscale, xscale); //SoM: 4/17/2000 vis->scale = FixedMul(spriteyscale, yscale); //<thingscale = interp.scale; diff --git a/src/r_things.h b/src/r_things.h index 88e1abdab..da2e90168 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -172,12 +172,10 @@ typedef struct vissprite_s spritecut_e cut; UINT32 renderflags; - UINT8 rotateflags; fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; - INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH]; boolean precip; -- 2.54.0 From 37a394ebaa63db043ff11a3526100fcb4938239e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 31 May 2024 23:04:26 +0200 Subject: [PATCH 034/525] flexible array stuff for columnofs hopefully this fixes some crashes or smth --- src/r_defs.h | 2 +- src/r_patch.c | 28 ++++++++++++---------------- src/r_things.c | 3 +-- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/r_defs.h b/src/r_defs.h index 40a4db023..99a185c7a 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -648,7 +648,7 @@ typedef struct INT16 height; INT16 leftoffset; // pixels to the left of origin INT16 topoffset; // pixels below the origin - INT32 columnofs[8]; // only [width] used + INT32 columnofs[]; // only [width] used // the [0] is &columnofs[width] }ATTRPACK patch_t; diff --git a/src/r_patch.c b/src/r_patch.c index bf0f28aa9..eea97cfbb 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -772,6 +772,17 @@ static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) return 0xFF00; } +#ifdef HWRENDER +static patch_t *R_CreateHardwarePatch(patch_t *patch) +{ + GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); + grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); + grPatch->rawpatch = patch; + HWR_MakePatch(patch, grPatch, grPatch->mipmap, false); + return (patch_t *)grPatch; +} +#endif + #ifdef ROTSPRITE // // R_GetRollAngle @@ -792,11 +803,7 @@ INT32 R_GetRollAngle(angle_t rollangle) return ra; } -patch_t *Patch_GetRotatedSprite( - spriteframe_t *sprite, - size_t frame, size_t spriteangle, - boolean flip, boolean adjustfeet, - void *info, INT32 rotationangle) +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, boolean adjustfeet, void *info, INT32 rotationangle) { rotsprite_t *rotsprite; spriteinfo_t *sprinfo = (spriteinfo_t *)info; @@ -882,17 +889,6 @@ static void RotatedPatch_CalculateDimensions( *newheight = max(height, max(h1, h2)); } -#ifdef HWRENDER -static patch_t *R_CreateHardwarePatch(patch_t *patch) -{ - GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); - grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); - grPatch->rawpatch = patch; - HWR_MakePatch(patch, grPatch, grPatch->mipmap, false); - return (patch_t *)grPatch; -} -#endif - void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) { UINT32 i; diff --git a/src/r_things.c b/src/r_things.c index 8def2ff83..c0efbf751 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1370,8 +1370,7 @@ static void R_ProjectSprite(mobj_t *thing) rollsum += thing->rollangle; rollangle = R_GetRollAngle(rollsum); - rotsprite = Patch_GetRotatedSprite( - sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); if (rotsprite != NULL) { -- 2.54.0 From 8052eb1c3a0bf58fe531485ba709b528d75ba0fe Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Jun 2024 16:29:20 +0200 Subject: [PATCH 035/525] fix papersprites in software (hopefully) lul --- src/r_things.c | 178 ++++++++++++++++++++++++++++++++++++------------- src/r_things.h | 3 + 2 files changed, 133 insertions(+), 48 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index c0efbf751..daf589980 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -863,25 +863,27 @@ static void R_DrawVisSprite(vissprite_t *vis) vis->x2 -= temp; } -#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) - // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) { + fixed_t horzscale = FixedMul(vis->spritexscale, this_scale); fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); // Papersprite drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep) { -#ifndef RANGECHECK - if ((frac>>FRACBITS) < 0 || (frac>>FRACBITS) >= SHORT(patch->width)) // if this doesn't work i'm removing papersprites - break; -#endif + angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF; + texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale; + + if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) + continue; + + if (vis->xiscale < 0) // Flipped sprite + texturecolumn = SHORT(patch->width) - 1 - texturecolumn; + sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); dc_iscale = (0xffffffffu / (unsigned)spryscale); - spryscale += scalestep; - texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); if (vis->vflip) @@ -892,9 +894,12 @@ static void R_DrawVisSprite(vissprite_t *vis) } else { + // Non-paper drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) { +#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); +#undef CLAMP column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); if (vis->vflip) @@ -903,7 +908,7 @@ static void R_DrawVisSprite(vissprite_t *vis) R_DrawMaskedColumn(column); } } -#undef CLAMP + colfunc = basecolfunc; dc_hires = 0; @@ -1126,12 +1131,14 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) static void R_ProjectSprite(mobj_t *thing) { mobj_t *oldthing = thing; + fixed_t tr_x, tr_y; fixed_t gxt, gyt; fixed_t tx, tz; fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! INT32 x1, x2; + INT32 x1test = 0, x2test = 0; spritedef_t *sprdef; spriteframe_t *sprframe; @@ -1157,6 +1164,7 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t scalestep; // toast '16 fixed_t offset, offset2; boolean papersprite = (thing->frame & FF_PAPERSPRITE); + fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; //SoM: 3/17/2000 fixed_t gz, gzt; @@ -1176,8 +1184,6 @@ static void R_ProjectSprite(mobj_t *thing) angle_t pitchnroll = 0; angle_t sliptiderollangle = 0; #endif - - fixed_t ang_scale = FRACUNIT; INT32 dist = -1; @@ -1209,7 +1215,7 @@ static void R_ProjectSprite(mobj_t *thing) tz = gxt-gyt; // thing is behind view plane? - if (!(papersprite) && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later + if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later return; gxt = -FixedMul(tr_x, viewsin); @@ -1280,14 +1286,9 @@ static void R_ProjectSprite(mobj_t *thing) { ang = R_PointToAngle (interp.x, interp.y) - interp.angle; camang = R_PointToAngle (interp.x, interp.y); - } - - if (sprframe->rotate != SRF_SINGLE || papersprite) - { + if (mirrored) ang = InvAngle(ang); - if (papersprite) - ang_scale = abs(FINESINE(ang>>ANGLETOFINESHIFT)); } if (sprframe->rotate == SRF_SINGLE) @@ -1387,10 +1388,11 @@ static void R_ProjectSprite(mobj_t *thing) } #endif + flip = !flip != !hflip; + // calculate edges of the shape spritexscale = interp.spritexscale; spriteyscale = interp.spriteyscale; - if (spritexscale < 1 || spriteyscale < 1) return; @@ -1409,39 +1411,19 @@ static void R_ProjectSprite(mobj_t *thing) spr_offset += interp.spritexoffset * flipoffset; spr_topoffset += interp.spriteyoffset * flipoffset; } - - flip = !flip != !hflip; if (flip) offset = spr_offset - spr_width; else offset = -spr_offset; - //offset = FixedMul(offset, FixedMul(spritexscale, this_scale)); - //offset2 = FixedMul(spr_width, FixedMul(spritexscale, this_scale)); // OH GOD I'M REVOOOOORTINGGGG AHHHHHHH - offset = FixedMul(offset, FixedMul(spritexscale, this_scale)); - tx += FixedMul(offset, ang_scale); - x1 = (centerxfrac + FixedMul (tx,xscale)) >>FRACBITS; - - // off the right side? - if (x1 > viewwidth) - return; - offset2 = FixedMul(spr_width, FixedMul(spritexscale, this_scale)); - tx += FixedMul(offset2, ang_scale); - x2 = ((centerxfrac + FixedMul (tx,xscale)) >> FRACBITS) - 1; - - // off the left side - if (x2 < 0) - return; if (papersprite) { - fixed_t yscale2, cosmul, sinmul, tz2; - - if (x2 <= x1) - return; + fixed_t xscale2, yscale2, cosmul, sinmul, tx2, tz2; + INT32 range; if (ang >= ANGLE_180) { @@ -1458,7 +1440,22 @@ static void R_ProjectSprite(mobj_t *thing) gyt = -FixedMul(tr_y, viewsin); tz = gxt-gyt; yscale = FixedDiv(projectiony, tz); - if (yscale < 64) return; // Fix some funky visuals + + gxt = -FixedMul(tr_x, viewsin); + gyt = FixedMul(tr_y, viewcos); + tx = -(gyt + gxt); + xscale = FixedDiv(projection, tz); + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + + // Get paperoffset (offset) and paperoffset (distance) + paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul); + paperdistance = -FixedMul(tr_x, sinmul) + FixedMul(tr_y, cosmul); + if (paperdistance < 0) + { + paperoffset = -paperoffset; + paperdistance = -paperdistance; + } + centerangle = viewangle - interp.angle; tr_x += FixedMul(offset2, cosmul); tr_y += FixedMul(offset2, sinmul); @@ -1466,13 +1463,72 @@ static void R_ProjectSprite(mobj_t *thing) gyt = -FixedMul(tr_y, viewsin); tz2 = gxt-gyt; yscale2 = FixedDiv(projectiony, tz2); - if (yscale2 < 64) return; // ditto + //if (yscale2 < 64) return; // ditto + + gxt = -FixedMul(tr_x, viewsin); + gyt = FixedMul(tr_y, viewcos); + tx2 = -(gyt + gxt); + xscale2 = FixedDiv(projection, tz2); + x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS); if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; - scalestep = (yscale2 - yscale)/(x2 - x1); - scalestep = scalestep ? scalestep : 1; + // Needs partially clipped + if (tz < FixedMul(MINZ, this_scale)) + { + fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz); + tx += FixedDiv(tx2-tx, div); + tz = FixedMul(MINZ, this_scale); + } + else if (tz2 < FixedMul(MINZ, this_scale)) + { + fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2); + tx2 += FixedDiv(tx-tx2, div); + tz2 = FixedMul(MINZ, this_scale); + } + + if ((tx2 / 4) < -(FixedMul(tz2, fovtan)) || (tx / 4) > FixedMul(tz, fovtan)) // too far off the side? + return; + + yscale = FixedDiv(projectiony, tz); + xscale = FixedDiv(projection, tz); + + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + + // off the right side? + if (x1 > viewwidth) + return; + + yscale2 = FixedDiv(projectiony, tz2); + xscale2 = FixedDiv(projection, tz2); + + x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; + + // off the left side + if (x2 < 0) + return; + + range = x2 - x1; + + if (range < 0) + return; + + range++; // fencepost problem + + if (range > 32767) + { + // If the range happens to be too large for fixed_t, + // abort the draw to avoid xscale becoming negative due to arithmetic overflow. + return; + } + + scalestep = ((yscale2 - yscale)/range) ?: 1; + + if (scalestep == 0) + scalestep = 1; + + xscale = FixedDiv(range<>FRACBITS; + x1 = centerx + (FixedMul(tx,xscale) / FRACUNIT); - xscale = FixedMul(xscale, ang_scale); + x1test = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + + if (x1test > viewwidth) + x1test = 0; + + // off the right side? + if (x1 > viewwidth) + return; + + tx += offset2; + //x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; + x2 = (centerx + (FixedMul(tx,xscale) / FRACUNIT)) - 1; + + x2test = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS) - 1; + + if (x2test < 0) + x2test = 0; + + // off the left side + if (x2 < 0) + return; + } // PORTAL SPRITE CLIPPING if (portalrender) @@ -1575,6 +1654,9 @@ static void R_ProjectSprite(mobj_t *thing) vis->pzt = vis->pz + vis->thingheight; vis->texturemid = FixedDiv(gzt - viewz, spriteyscale); vis->scalestep = scalestep; + vis->paperoffset = paperoffset; + vis->paperdistance = paperdistance; + vis->centerangle = centerangle; vis->mobj = thing; // Easy access! Tails 06-07-2002 diff --git a/src/r_things.h b/src/r_things.h index da2e90168..5b74eea02 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -149,8 +149,11 @@ typedef struct vissprite_s fixed_t thingscale; // the object's scale fixed_t sortscale; // sortscale only differs from scale for flat sprites fixed_t scalestep; // only for flat sprites, 0 otherwise + fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle fixed_t xiscale; // negative if flipped + angle_t centerangle; // for paper sprites + fixed_t texturemid; patch_t *patch; -- 2.54.0 From 957159d4859b2c73221b55cd9d2444d925bf904f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Jun 2024 16:31:49 +0200 Subject: [PATCH 036/525] forgor to remove that --- src/r_things.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index daf589980..23208c622 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1138,7 +1138,6 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! INT32 x1, x2; - INT32 x1test = 0, x2test = 0; spritedef_t *sprdef; spriteframe_t *sprframe; @@ -1149,7 +1148,6 @@ static void R_ProjectSprite(mobj_t *thing) size_t rot; UINT8 flip; - /*boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(thing));*/ boolean mirrored = thing->mirrored; boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); @@ -1542,11 +1540,6 @@ static void R_ProjectSprite(mobj_t *thing) //x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; x1 = centerx + (FixedMul(tx,xscale) / FRACUNIT); - x1test = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; - - if (x1test > viewwidth) - x1test = 0; - // off the right side? if (x1 > viewwidth) return; @@ -1555,11 +1548,6 @@ static void R_ProjectSprite(mobj_t *thing) //x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; x2 = (centerx + (FixedMul(tx,xscale) / FRACUNIT)) - 1; - x2test = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS) - 1; - - if (x2test < 0) - x2test = 0; - // off the left side if (x2 < 0) return; -- 2.54.0 From 38633a85168f8577bfedd9899327821980f4dcfc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Jun 2024 17:03:27 +0200 Subject: [PATCH 037/525] stuffs --- src/r_things.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 23208c622..884da6302 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -744,7 +744,7 @@ static void R_DrawVisSprite(vissprite_t *vis) // TODO This check should not be necessary. But Papersprites near to the camera will sometimes create invalid values // for the vissprite's startfrac. This happens because they are not depth culled like other sprites. // Someone who is more familiar with papersprites pls check and try to fix <3 - if (vis->startfrac < 0 || vis->startfrac > (patch->width << FRACBITS)) + if (vis->startfrac < 0 || vis->startfrac > (SHORT(patch->width) << FRACBITS)) { // never draw vissprites with startfrac out of patch range return; @@ -1554,7 +1554,7 @@ static void R_ProjectSprite(mobj_t *thing) } // PORTAL SPRITE CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (x2 < portalclipstart || x1 > portalclipend) return; @@ -1652,7 +1652,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; // PORTAL SEMI-CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (vis->x1 < portalclipstart) vis->x1 = portalclipstart; @@ -1809,7 +1809,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) tx = -(gyt + gxt); // too far off the side? - if (abs(tx) > tz<<2) + if (abs(tx) > FixedMul(tz, fovtan)<<2) return; // aspect ratio stuff : @@ -1857,7 +1857,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; // PORTAL SPRITE CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (x2 < portalclipstart || x1 > portalclipend) return; @@ -1889,12 +1889,13 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; vis->scalestep = 0; + vis->paperdistance = 0; vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; // PORTAL SEMI-CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (vis->x1 < portalclipstart) vis->x1 = portalclipstart; -- 2.54.0 From da9d57a6246ee969db0f69ca115eea857f15d468 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 2 Jun 2024 00:39:22 +0300 Subject: [PATCH 038/525] Fix compilation for some gcc versions --- src/lua_maplib.c | 4 +++- src/lua_mobjlib.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 2ae2ce395..d92cd1f8b 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1647,6 +1647,7 @@ static int mapheaderinfo_get(lua_State *L) break; // TODO add support for reading numGradedMares and grades default: + { // Read custom vars now // (note: don't include the "LUA." in your lua scripts!) UINT8 j = 0; @@ -1657,6 +1658,7 @@ static int mapheaderinfo_get(lua_State *L) else lua_pushnil(L); } + } return 1; } @@ -1832,4 +1834,4 @@ int LUA_MapLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "mapheaderinfo"); return 0; -} \ No newline at end of file +} diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 866ea6550..f62e59486 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -886,11 +886,13 @@ static int mapthing_set(lua_State *L) mt->z = (INT16)luaL_checkinteger(L, 3); break; case mapthing_extrainfo: + { INT32 extrainfo = luaL_checkinteger(L, 3); if (extrainfo & ~15) return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15); mt->extrainfo = (UINT8)extrainfo; break; + } case mapthing_mobj: mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); break; @@ -979,4 +981,4 @@ int LUA_MobjLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "mapthings"); return 0; -} \ No newline at end of file +} -- 2.54.0 From 1747ebf481fab9e30d69aee23df7e59a9ec52d60 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 2 Jun 2024 00:43:09 +0300 Subject: [PATCH 039/525] Lua_optoption shouldn't change stack state at the end of call now --- src/lua_script.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index 381448e72..13cdf7bdf 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1680,6 +1680,8 @@ void LUA_UnArchiveDemo(void) // For mobj_t, player_t, etc. to take custom variables. int Lua_optoption(lua_State *L, int narg, int def, int list_ref) { + int result = -1; + if (lua_isnoneornil(L, narg)) return def; @@ -1692,8 +1694,11 @@ int Lua_optoption(lua_State *L, int narg, int def, int list_ref) lua_rawget(L, -2); if (lua_isnumber(L, -1)) - return lua_tointeger(L, -1); - return -1; + result = lua_tointeger(L, -1); + + lua_pop(L, 2); // Pop result and fields table + + return result; } @@ -1710,4 +1715,4 @@ int Lua_CreateFieldTable(lua_State *L, const char *const lst[]) } return luaL_ref(L, LUA_REGISTRYINDEX); -} \ No newline at end of file +} -- 2.54.0 From 0e927ce4bd087988c29487fd00f5e9055c1ad514 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 2 Jun 2024 00:43:42 +0300 Subject: [PATCH 040/525] Make sfxinfo_t and state_t use field tables too --- src/lua_infolib.c | 269 ++++++++++++++++++++++++++++++---------------- 1 file changed, 176 insertions(+), 93 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 5c6918890..3ab044188 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -26,32 +26,6 @@ boolean LUA_CallAction(const char *action, mobj_t *actor); state_t *astate; -enum sfxinfo_read { - sfxinfor_name = 0, - sfxinfor_singular, - sfxinfor_priority, - sfxinfor_flags, // "pitch" - sfxinfor_skinsound -}; -const char *const sfxinfo_ropt[] = { - "name", - "singular", - "priority", - "flags", - "skinsound", - NULL}; - -enum sfxinfo_write { - sfxinfow_singular = 0, - sfxinfow_priority, - sfxinfow_flags // "pitch" -}; -const char *const sfxinfo_wopt[] = { - "singular", - "priority", - "flags", - NULL}; - // // Sprite Names // @@ -101,7 +75,7 @@ static void A_Lua(mobj_t *actor) { boolean found = false; I_Assert(actor != NULL); - + lua_settop(gL, 0); // Just in case... lua_pushcfunction(gL, LUA_GetErrorMessage); @@ -286,7 +260,7 @@ boolean LUA_CallAction(const char *csaction, mobj_t *actor) if (superstack && fasticmp(csaction, superactions[superstack-1])) // the action is calling itself, return false; // let it call the hardcoded function instead. - + lua_pushcfunction(gL, LUA_GetErrorMessage); // grab function by uppercase name. @@ -330,49 +304,93 @@ boolean LUA_CallAction(const char *csaction, mobj_t *actor) return true; // action successfully called. } +enum state_e { + state_sprite = 0, + state_frame, + state_tics, + state_action, + state_var1, + state_var2, + state_nextstate, +}; + +const char *const state_opt[] = { + "sprite", + "frame", + "tics", + "action", + "var1", + "var2", + "nextstate", + NULL +}; + +static int state_fields_ref = LUA_NOREF; + // state_t *, field -> number static int state_get(lua_State *L) { state_t *st = *((state_t **)luaL_checkudata(L, 1, META_STATE)); - const char *field = luaL_checkstring(L, 2); + enum state_e field = Lua_optoption(L, 2, -1, state_fields_ref); lua_Integer number; - if (fastcmp(field,"sprite")) - number = st->sprite; - else if (fastcmp(field,"frame")) - number = st->frame; - else if (fastcmp(field,"tics")) - number = st->tics; - else if (fastcmp(field,"action")) { - const char *name; - if (!st->action.acp1) // Action is NULL. - return 0; // return nil. - if (st->action.acp1 == (actionf_p1)A_Lua) { // This is a Lua function? - lua_getfield(L, LUA_REGISTRYINDEX, LREG_STATEACTION); - I_Assert(lua_istable(L, -1)); - lua_pushlightuserdata(L, st); // Push the state pointer and - lua_rawget(L, -2); // use it to get the actual Lua function. - lua_remove(L, -2); // pop LREG_STATEACTION - return 1; // Return the Lua function. + switch (field) + { + case state_sprite: + number = st->sprite; + break; + + case state_frame: + number = st->frame; + break; + + case state_tics: + number = st->tics; + break; + + case state_action: + { + const char *name; + if (!st->action.acp1) // Action is NULL. + return 0; // return nil. + if (st->action.acp1 == (actionf_p1)A_Lua) { // This is a Lua function? + lua_getfield(L, LUA_REGISTRYINDEX, LREG_STATEACTION); + I_Assert(lua_istable(L, -1)); + lua_pushlightuserdata(L, st); // Push the state pointer and + lua_rawget(L, -2); // use it to get the actual Lua function. + lua_remove(L, -2); // pop LREG_STATEACTION + return 1; // Return the Lua function. + } + name = LUA_GetActionName(&st->action); // find a hardcoded function name + if (!name) // If it's not a hardcoded function and it's not a Lua function... + return 0; // Just what is this?? + // get the function from the global + // because the metatable will trigger. + lua_getglobal(L, name); // actually gets from LREG_ACTIONS if applicable, and pushes a new C closure if not. + lua_pushstring(L, name); // push the name we found. + return 2; // return both the function and its name, in case somebody wanted to do a comparison by name or something? } - name = LUA_GetActionName(&st->action); // find a hardcoded function name - if (!name) // If it's not a hardcoded function and it's not a Lua function... - return 0; // Just what is this?? - // get the function from the global - // because the metatable will trigger. - lua_getglobal(L, name); // actually gets from LREG_ACTIONS if applicable, and pushes a new C closure if not. - lua_pushstring(L, name); // push the name we found. - return 2; // return both the function and its name, in case somebody wanted to do a comparison by name or something? - } else if (fastcmp(field,"var1")) - number = st->var1; - else if (fastcmp(field,"var2")) - number = st->var2; - else if (fastcmp(field,"nextstate")) - number = st->nextstate; - else if (devparm) - return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, field); - else - return 0; + break; + + case state_var1: + number = st->var1; + break; + + case state_var2: + number = st->var2; + break; + + case state_nextstate: + number = st->nextstate; + break; + + default: + { + if (devparm) + return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, field); + return 0; + } + } lua_pushinteger(L, number); return 1; @@ -382,7 +400,7 @@ static int state_get(lua_State *L) static int state_set(lua_State *L) { state_t *st = *((state_t **)luaL_checkudata(L, 1, META_STATE)); - const char *field = luaL_checkstring(L, 2); + enum state_e field = Lua_optoption(L, 2, -1, state_fields_ref); lua_Integer value; if (hud_running) @@ -390,16 +408,24 @@ static int state_set(lua_State *L) if (hook_cmd_running) return luaL_error(L, "Do not alter states in BuildCMD code!"); - if (fastcmp(field,"sprite")) { + switch (field) + { + case state_sprite: value = luaL_checknumber(L, 3); if (value < SPR_NULL || value >= NUMSPRITES) return luaL_error(L, "sprite number %d is invalid.", value); st->sprite = (spritenum_t)value; - } else if (fastcmp(field,"frame")) + break; + + case state_frame: st->frame = (UINT32)luaL_checknumber(L, 3); - else if (fastcmp(field,"tics")) + break; + + case state_tics: st->tics = (INT32)luaL_checknumber(L, 3); - else if (fastcmp(field,"action")) { + break; + + case state_action: switch(lua_type(L, 3)) { case LUA_TNIL: // Null? Set the action to nothing, then. @@ -420,17 +446,26 @@ static int state_set(lua_State *L) default: // ?! return luaL_typerror(L, 3, "function"); } - } else if (fastcmp(field,"var1")) + break; + + case state_var1: st->var1 = (INT32)luaL_checknumber(L, 3); - else if (fastcmp(field,"var2")) + break; + + case state_var2: st->var2 = (INT32)luaL_checknumber(L, 3); - else if (fastcmp(field,"nextstate")) { + break; + + case state_nextstate: value = luaL_checkinteger(L, 3); if (value < S_NULL || value >= NUMSTATES) return luaL_error(L, "nextstate number %d is invalid.", value); st->nextstate = (statenum_t)value; - } else + break; + + default: return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, field); + } return 0; } @@ -627,7 +662,7 @@ static int mobjinfo_fields_ref = LUA_NOREF; static int mobjinfo_get(lua_State *L) { mobjinfo_t *info = *((mobjinfo_t **)luaL_checkudata(L, 1, META_MOBJINFO)); - enum mobjinfo_e field = luaL_checkoption(L, 2, mobjinfo_opt[0], mobjinfo_opt); + enum mobjinfo_e field = Lua_optoption(L, 2, -1, mobjinfo_fields_ref); I_Assert(info != NULL); I_Assert(info >= mobjinfo); @@ -863,6 +898,25 @@ static int lib_getSfxInfo(lua_State *L) return 1; } +enum sfxinfo_e { + sfxinfo_name = 0, + sfxinfo_singular, + sfxinfo_priority, + sfxinfo_flags, // "pitch" + sfxinfo_skinsound +}; + +const char *const sfxinfo_opt[] = { + "name", + "singular", + "priority", + "flags", + "skinsound", + NULL +}; + +static int sfxinfo_fields_ref = LUA_NOREF; + // stack: dummy, S_sfx[] table index, table of values to set. static int lib_setSfxInfo(lua_State *L) { @@ -886,22 +940,44 @@ static int lib_setSfxInfo(lua_State *L) lua_pushnil(L); while (lua_next(L, 1)) { - enum sfxinfo_write i; + enum sfxinfo_e i; if (lua_isnumber(L, 2)) - i = lua_tointeger(L, 2) - 1; // lua is one based, this enum is zero based. + { + int j = lua_tointeger(L, 2) - 1; + + // Read and Write enums were combined, need to do this switch now + switch (j) + { + case 1: + i = sfxinfo_singular; + break; + + case 2: + i = sfxinfo_priority; + break; + + case 3: + i = sfxinfo_flags; + break; + + default: + i = -1; + break; + } + } else - i = luaL_checkoption(L, 2, NULL, sfxinfo_wopt); + i = Lua_optoption(L, 2, -1, sfxinfo_fields_ref); switch(i) { - case sfxinfow_singular: + case sfxinfo_singular: info->singularity = luaL_checkboolean(L, 3); break; - case sfxinfow_priority: + case sfxinfo_priority: info->priority = (INT32)luaL_checkinteger(L, 3); break; - case sfxinfow_flags: + case sfxinfo_flags: info->pitch = (INT32)luaL_checkinteger(L, 3); break; default: @@ -923,29 +999,29 @@ static int lib_sfxlen(lua_State *L) static int sfxinfo_get(lua_State *L) { sfxinfo_t *sfx = *((sfxinfo_t **)luaL_checkudata(L, 1, META_SFXINFO)); - enum sfxinfo_read field = luaL_checkoption(L, 2, NULL, sfxinfo_ropt); + enum sfxinfo_e field = Lua_optoption(L, 2, -1, sfxinfo_fields_ref); I_Assert(sfx != NULL); switch (field) { - case sfxinfor_name: + case sfxinfo_name: lua_pushstring(L, sfx->name); return 1; - case sfxinfor_singular: + case sfxinfo_singular: lua_pushboolean(L, sfx->singularity); return 1; - case sfxinfor_priority: + case sfxinfo_priority: lua_pushinteger(L, sfx->priority); return 1; - case sfxinfor_flags: + case sfxinfo_flags: lua_pushinteger(L, sfx->pitch); return 1; - case sfxinfor_skinsound: + case sfxinfo_skinsound: lua_pushinteger(L, sfx->skinsound); return 1; default: - return luaL_error(L, "impossible error"); + return luaL_error(L, LUA_QL("sfxinfo_t") " has no field named " LUA_QS, lua_tostring(L, 2)); } return 0; } @@ -954,7 +1030,7 @@ static int sfxinfo_get(lua_State *L) static int sfxinfo_set(lua_State *L) { sfxinfo_t *sfx = *((sfxinfo_t **)luaL_checkudata(L, 1, META_SFXINFO)); - enum sfxinfo_write field = luaL_checkoption(L, 2, NULL, sfxinfo_wopt); + int field = Lua_optoption(L, 2, -1, sfxinfo_fields_ref); if (hud_running) return luaL_error(L, "Do not alter S_sfx in HUD rendering code!"); @@ -969,17 +1045,20 @@ static int sfxinfo_set(lua_State *L) switch (field) { - case sfxinfow_singular: + case sfxinfo_singular: sfx->singularity = luaL_checkboolean(L, 1); break; - case sfxinfow_priority: + case sfxinfo_priority: sfx->priority = luaL_checkinteger(L, 1); break; - case sfxinfow_flags: + case sfxinfo_flags: sfx->pitch = luaL_checkinteger(L, 1); break; default: - return luaL_error(L, "impossible error"); + if (field == -1) + return luaL_error(L, LUA_QL("sfxinfo_t") " has no field named " LUA_QS, lua_tostring(L, 2)); + else + return luaL_error(L, LUA_QL("sfxinfo_t") " field " LUA_QS " is read-only", lua_tostring(L, 2)); } return 0; } @@ -1021,6 +1100,8 @@ int LUA_InfoLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + state_fields_ref = Lua_CreateFieldTable(L, state_opt); + luaL_newmetatable(L, META_MOBJINFO); lua_pushcfunction(L, mobjinfo_get); lua_setfield(L, -2, "__index"); @@ -1045,6 +1126,8 @@ int LUA_InfoLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + sfxinfo_fields_ref = Lua_CreateFieldTable(L, sfxinfo_opt); + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getSprname); @@ -1096,4 +1179,4 @@ int LUA_InfoLib(lua_State *L) lua_setglobal(L, "S_sfx"); lua_setglobal(L, "sfxinfo"); return 0; -} \ No newline at end of file +} -- 2.54.0 From bf75644144290de36bca71126294b60e3938cd99 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 May 2024 20:28:27 +0200 Subject: [PATCH 041/525] make r_fps if else hell a bit more bearable to look at lol lmao --- src/r_fps.c | 67 ++++++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 91044b42e..52a89098f 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -287,6 +287,11 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to) return (R_LerpAngle(from, to, rendertimefrac)); }*/ +#define IFCHANGED(a, b)\ +if (mobj->a == mobj->b)\ +(out->a = mobj->b);\ +else + void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) { if (frac == FRACUNIT) @@ -308,44 +313,28 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) return; } - if (mobj->x == mobj->old_x) - out->x = mobj->x; - else + IFCHANGED(x, old_x) out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); - if (mobj->y == mobj->old_y) - out->y = mobj->y; - else + IFCHANGED(y, old_y) out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); - if (mobj->z == mobj->old_z) - out->z = mobj->z; - else + IFCHANGED(z, old_z) out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - if (mobj->spritexscale == mobj->old_spritexscale) - out->spritexscale = mobj->spritexscale; - else + IFCHANGED(spritexscale, old_spritexscale) out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); - if (mobj->spriteyscale == mobj->old_spriteyscale) - out->spriteyscale = mobj->spriteyscale; - else + IFCHANGED(spriteyscale, old_spriteyscale) out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); - if (mobj->spritexoffset == mobj->old_spritexoffset) - out->spritexoffset = mobj->spritexoffset; - else + IFCHANGED(spritexoffset, old_spritexoffset) out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); - if (mobj->spriteyoffset == mobj->old_spriteyoffset) - out->spriteyoffset = mobj->spriteyoffset; - else + IFCHANGED(spriteyoffset, old_spriteyoffset) out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); - if (mobj->scale == mobj->old_scale) // Tiny optimisation - scale is usually unchanging, so let's skip a lerp, two FixedMuls, and two FixedDivs - out->scale = mobj->scale; - else + IFCHANGED(scale, old_scale) out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac); if (cv_mobjssector.value) @@ -355,39 +344,27 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) if (mobj->player) { - if (mobj->angle == mobj->player->old_frameangle) - out->angle = mobj->player->frameangle; - else + IFCHANGED(angle, player->old_frameangle) out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac); } else { - if (mobj->angle == mobj->old_angle) - out->angle = mobj->angle; - else + IFCHANGED(angle, old_angle) out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); } // pitch roll stuff - if (mobj->pitch == mobj->old_pitch) - out->pitch = mobj->pitch; - else + IFCHANGED(pitch, old_pitch) out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); - if (mobj->roll == mobj->old_roll) - out->roll = mobj->roll; - else + IFCHANGED(roll, old_roll) out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); // and the slope stuff - if (mobj->slopepitch == mobj->old_slopepitch) - out->slopepitch = mobj->slopepitch; - else + IFCHANGED(slopepitch, old_slopepitch) out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); - if (mobj->sloperoll == mobj->old_sloperoll) - out->sloperoll = mobj->sloperoll; - else + IFCHANGED(sloperoll, old_sloperoll) out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); } @@ -422,12 +399,12 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst else out->subsector = mobj->subsector; - if (mobj->angle == mobj->old_angle) - out->angle = mobj->angle; - else + IFCHANGED(angle, old_angle) out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); } +#undef IFCHANGED + static void AddInterpolator(levelinterpolator_t* interpolator) { if (levelinterpolators_len >= levelinterpolators_size) -- 2.54.0 From ee2ec01eb9796c41f435cbfa41a7046bff4039c9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 2 Jun 2024 00:44:48 +0200 Subject: [PATCH 042/525] use shader to prevent sprite floor clipping from durr lul --- src/hardware/hw_main.c | 25 ------------------------- src/hardware/hw_shaders.c | 2 +- src/hardware/hw_shaders.h | 11 +++++++++++ 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3cf998d84..c5be8d185 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3970,18 +3970,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Let dispoffset work first since this adjust each vertex HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); - // push it toward the camera to mitigate floor-clipping sprites - { - float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz)); - float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; - for (i = 0; i < 4; i++) - { - baseWallVerts[i].x += (gr_viewx - baseWallVerts[i].x)*distfact; - baseWallVerts[i].z += (gr_viewy - baseWallVerts[i].z)*distfact; - baseWallVerts[i].y += (gr_viewz - baseWallVerts[i].y)*distfact; - } - } - realtop = top = baseWallVerts[3].y; realbot = bot = baseWallVerts[0].y; towtop = baseWallVerts[3].t; @@ -4252,19 +4240,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) // ...nah HWR_RotateSpritePolyToAim(spr, wallVerts, false); - // push it toward the camera to mitigate floor-clipping sprites - { - float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz)); - float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; - size_t i; - for (i = 0; i < 4; i++) - { - wallVerts[i].x += (gr_viewx - wallVerts[i].x)*distfact; - wallVerts[i].z += (gr_viewy - wallVerts[i].z)*distfact; - wallVerts[i].y += (gr_viewz - wallVerts[i].y)*distfact; - } - } - // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. // sprite lighting by modulating the RGB components /// \todo coloured diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 427bd1540..a20375981 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -33,7 +33,7 @@ static struct { {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Sprite shader - {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, + {GLSL_SPRITECLIP_HACK_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Model shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index eb705c34c..e817419a1 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -31,6 +31,17 @@ "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ "}\0" +// Sprite clipping makes me want to McFucking Die + +#define GLSL_SPRITECLIP_HACK_VERTEX_SHADER \ + "void main(void) {\n" \ + "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ + "gl_FrontColor = gl_Color;\n" \ + "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ + "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ + "gl_Position.z -= 80 / gl_Position.z;\n" \ + "}\0" + // ================== // Fragment shaders // ================== -- 2.54.0 From cae40928ad16d088168bc4ba890de890d9337ee6 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 3 Jun 2024 00:17:11 +0300 Subject: [PATCH 043/525] Use Z_Calloc to allocate wadfile_t to avoid having uninitialized fields --- src/w_wad.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index cd2968494..15c7db38c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -789,7 +789,7 @@ UINT16 W_InitFile(const char *filename, boolean local) // // link wad file to search files // - wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL); + wadfile = Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL); wadfile->filename = Z_StrDup(filename); wadfile->handle = handle; wadfile->numlumps = (UINT16)numlumps; @@ -798,7 +798,6 @@ UINT16 W_InitFile(const char *filename, boolean local) fseek(handle, 0, SEEK_END); wadfile->filesize = (unsigned)ftell(handle); wadfile->type = type; - wadfile->majormod = false; // already generated, just copy it over M_Memcpy(&wadfile->md5sum, &md5sum, 16); -- 2.54.0 From f977af6a802ffb4330a21d9c790a0e37c72c8e5b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Jun 2024 15:13:39 +0200 Subject: [PATCH 044/525] fix le dispoffset --- src/hardware/hw_defs.h | 1 + src/hardware/hw_main.c | 23 ++++++++++++++++++++++- src/hardware/hw_shaders.c | 4 ++++ src/hardware/hw_shaders.h | 2 +- src/r_things.c | 3 +-- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 419549d73..d16b490b7 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -174,6 +174,7 @@ enum SHADER_NONE = -1, SHADER_FLOOR = 0, SHADER_WALL, + SHADER_SPRITECLIPHACK, SHADER_MODEL, SHADER_SPRITE, SHADER_WATER, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c5be8d185..61d4e85e0 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3967,6 +3967,17 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) baseWallVerts[0].t = baseWallVerts[1].t = gpatch->max_t; } + // if it has a dispoffset, push it a little towards the camera + if (spr->dispoffset) + { + float co = -gr_viewcos*(0.05f*spr->dispoffset); + float si = -gr_viewsin*(0.05f*spr->dispoffset); + baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; + baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; + baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; + baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co; + } + // Let dispoffset work first since this adjust each vertex HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); @@ -4236,8 +4247,18 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) HWR_DrawSpriteShadow(spr, gpatch, this_scale); } + // if it has a dispoffset, push it a little towards the camera + if (spr->dispoffset) + { + float co = -gr_viewcos*(0.05f*spr->dispoffset); + float si = -gr_viewsin*(0.05f*spr->dispoffset); + wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; + wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; + wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; + wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; + } + // Let dispoffset work first since this adjust each vertex - // ...nah HWR_RotateSpritePolyToAim(spr, wallVerts, false); // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index a20375981..fb6b9661c 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -33,6 +33,9 @@ static struct { {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Sprite shader + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, + + // Sprite clipping hack shader (for pulling things out of the floor) {GLSL_SPRITECLIP_HACK_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Model shader @@ -424,6 +427,7 @@ customshaderxlat_t shaderxlat[] = {"Flat", SHADER_FLOOR}, {"WallTexture", SHADER_WALL}, {"Sprite", SHADER_SPRITE}, + {"SpriteClipHack", SHADER_SPRITECLIPHACK}, {"Model", SHADER_MODEL}, {"WaterRipple", SHADER_WATER}, {"Fog", SHADER_FOG}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index e817419a1..3840eaef1 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -39,7 +39,7 @@ "gl_FrontColor = gl_Color;\n" \ "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_Position.z -= 80 / gl_Position.z;\n" \ + "gl_Position.z -= 80.0 / gl_Position.z;\n" \ "}\0" // ================== diff --git a/src/r_things.c b/src/r_things.c index 884da6302..0fa96a4ce 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -299,8 +299,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, spritecachedinfo[numspritelumps].height = SHORT(patch.height)< Date: Mon, 3 Jun 2024 13:53:59 +0200 Subject: [PATCH 045/525] add toggle for beta intermission screen + smol cleanup --- src/d_netcmd.c | 4 ++++ src/d_netcmd.h | 2 ++ src/hardware/hw_main.c | 7 +------ src/y_inter.c | 29 ++++++++++++++++++----------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1e46da57f..8701448b4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -577,6 +577,8 @@ static CV_PossibleValue_t skinselectgridsort_t[] ={ }; consvar_t cv_skinselectgridsort ={ "skinselectgridsort", "Real name", CV_SAVE|CV_CALL|CV_NOINIT, skinselectgridsort_t, sortSkinGrid, 0, NULL, NULL, 0, 0, NULL }; +consvar_t cv_betainterscreen = {"betaintermissionscreen", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + INT16 gametype = GT_RACE; // SRB2kart boolean forceresetplayers = false; boolean deferencoremode = false; @@ -822,6 +824,8 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_netdemosyncquality); CV_RegisterVar(&cv_maxdemosize); CV_RegisterVar(&cv_keyboardlayout); + + CV_RegisterVar(&cv_betainterscreen); } // ========================================================================= diff --git a/src/d_netcmd.h b/src/d_netcmd.h index e9934e237..b02b68f00 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -205,6 +205,8 @@ extern consvar_t cv_showtrackaddon; extern consvar_t cv_showspecstuff; +extern consvar_t cv_betainterscreen; + typedef enum { SKINMENUTYPE_SCROLL = 0, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 61d4e85e0..af7fc8f37 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6234,12 +6234,7 @@ void HWR_EndScreenWipe(void) void HWR_DrawIntermissionBG(void) { - patch_t *bgpatch = W_CachePatchName("SRB2BACK", PU_CACHE); - - if (cv_grscreentextures.value == 2) - HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); - else - V_DrawPatchFill(bgpatch); // use the neato kart bg for intermission on disabled screen textures + HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); } void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) diff --git a/src/y_inter.c b/src/y_inter.c index cc1d7dd9c..58cfdc4e0 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -100,10 +100,10 @@ static y_data data; static patch_t *bgpatch = NULL; // INTERSCR static patch_t *widebgpatch = NULL; // INTERSCW static patch_t *bgtile = NULL; // SPECTILE/SRB2BACK -static patch_t *interpic = NULL; // custom picture defined in map header -static boolean usetile; +//static patch_t *interpic = NULL; // custom picture defined in map header +//static boolean usetile; boolean usebuffer = false; -static boolean useinterpic; +//static boolean useinterpic; static INT32 timer; static INT32 intertic; @@ -392,9 +392,16 @@ void Y_IntermissionDrawer(void) if (!usebuffer) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - if (useinterpic) - V_DrawScaledPatch(0, 0, 0, interpic); - else if (!usetile) + if (cv_betainterscreen.value +#ifdef HWRENDER + || (rendermode == render_opengl && cv_grscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures +#endif + ) + V_DrawPatchFill(bgtile); // use the neato kart bg for intermission on disabled screen textures + //else if (useinterpic) + //V_DrawScaledPatch(0, 0, 0, interpic); + //else if (!usetile) + else { if (rendermode == render_soft && usebuffer) VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); @@ -412,8 +419,8 @@ void Y_IntermissionDrawer(void) V_DrawScaledPatch(0, 0, 0, bgpatch); } } - else if (bgtile) - V_DrawPatchFill(bgtile); + //else if (bgtile) + //V_DrawPatchFill(bgtile); if (usebuffer) // Fade everything out V_DrawFadeScreen(0xFF00, 22); @@ -937,8 +944,8 @@ void Y_StartIntermission(void) //if (intertype == int_race || intertype == int_match) { - //bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); - usetile = useinterpic = false; + bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); + //usetile = useinterpic = false; usebuffer = true; } @@ -988,7 +995,7 @@ static void Y_UnloadData(void) UNLOAD(bgpatch); UNLOAD(widebgpatch); UNLOAD(bgtile); - UNLOAD(interpic); + //UNLOAD(interpic); } // SRB2Kart: Voting! -- 2.54.0 From 9de3db7c97492486264c7faf378598f5b8d77868 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Jun 2024 16:52:25 +0200 Subject: [PATCH 046/525] add shader for shadows to also fix sprite shadows in pal render --- src/hardware/hw_defs.h | 1 + src/hardware/hw_main.c | 8 +++++--- src/hardware/hw_shaders.c | 4 ++++ src/hardware/hw_shaders.h | 24 ++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index d16b490b7..9f95f8fcd 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -173,6 +173,7 @@ enum { SHADER_NONE = -1, SHADER_FLOOR = 0, + SHADER_SHADOW, SHADER_WALL, SHADER_SPRITECLIPHACK, SHADER_MODEL, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index af7fc8f37..6fae23c77 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3647,6 +3647,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t { FOutVector swallVerts[4]; FSurfaceInfo sSurf; + FBITFIELD blendmode = 0; fixed_t floorheight, mobjfloor; pslope_t *floorslope; fixed_t slopez; @@ -3802,13 +3803,14 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t if (sSurf.PolyColor.s.alpha > floorheight/4) { sSurf.PolyColor.s.alpha = (UINT8)(sSurf.PolyColor.s.alpha - floorheight/4); - + if (HWR_UseShader()) { - shader = SHADER_FLOOR; // floor shader + shader = SHADER_SHADOW; + blendmode |= PF_ColorMapped; } - HWR_ProcessPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated, shader, false); + HWR_ProcessPolygon(&sSurf, swallVerts, 4, blendmode|PF_Translucent|PF_Modulated, shader, false); } } diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index fb6b9661c..c4109837c 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -29,6 +29,9 @@ static struct { // Floor shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_FLOOR_FRAGMENT_SHADER}, + // Shadow shader + {GLSL_SPRITECLIP_HACK_VERTEX_SHADER, GLSL_SHADOW_FRAGMENT_SHADER}, + // Wall shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, @@ -425,6 +428,7 @@ static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum) customshaderxlat_t shaderxlat[] = { {"Flat", SHADER_FLOOR}, + {"Shadow", SHADER_SHADOW}, {"WallTexture", SHADER_WALL}, {"Sprite", SHADER_SPRITE}, {"SpriteClipHack", SHADER_SPRITECLIPHACK}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 3840eaef1..6c225b1a8 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -144,6 +144,26 @@ "gl_FragColor = final_color;\n" \ "}\n" \ "#endif\0" + +#define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \ + "uniform sampler2D tex;\n" \ + "uniform vec4 poly_color;\n" \ + "uniform vec4 tint_color;\n" \ + "uniform vec4 fade_color;\n" \ + "uniform float lighting;\n" \ + "uniform float fade_start;\n" \ + "uniform float fade_end;\n" \ + GLSL_DOOM_COLORMAP \ + GLSL_DOOM_LIGHT_EQUATION \ + "void main(void) {\n" \ + "vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \ + "vec4 base_color = texel * poly_color;\n" \ + "vec4 final_color = base_color;\n" \ + GLSL_SOFTWARE_TINT_EQUATION \ + GLSL_SOFTWARE_FADE_EQUATION \ + "final_color.a = texel.a * poly_color.a;\n" \ + "gl_FragColor = final_color;\n" \ + "}\n" \ // hand tuned adjustments for light level calculation #define GLSL_FLOOR_FUDGES \ @@ -161,6 +181,10 @@ #define GLSL_WALL_FRAGMENT_SHADER \ GLSL_WALL_FUDGES \ GLSL_SOFTWARE_FRAGMENT_SHADER + +#define GLSL_SHADOW_FRAGMENT_SHADER \ + GLSL_FLOOR_FUDGES \ + GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL // // Water surface shader -- 2.54.0 From ea510f95b899220be4251a8b95729f9b9e874db6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Jun 2024 17:15:36 +0200 Subject: [PATCH 047/525] Revert "fix le dispoffset" This reverts commit f977af6a802ffb4330a21d9c790a0e37c72c8e5b. --- src/hardware/hw_defs.h | 1 - src/hardware/hw_main.c | 23 +---------------------- src/hardware/hw_shaders.c | 4 ---- src/hardware/hw_shaders.h | 2 +- src/r_things.c | 3 ++- 5 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 9f95f8fcd..b19106fff 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -175,7 +175,6 @@ enum SHADER_FLOOR = 0, SHADER_SHADOW, SHADER_WALL, - SHADER_SPRITECLIPHACK, SHADER_MODEL, SHADER_SPRITE, SHADER_WATER, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 6fae23c77..eed9f9232 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3969,17 +3969,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) baseWallVerts[0].t = baseWallVerts[1].t = gpatch->max_t; } - // if it has a dispoffset, push it a little towards the camera - if (spr->dispoffset) - { - float co = -gr_viewcos*(0.05f*spr->dispoffset); - float si = -gr_viewsin*(0.05f*spr->dispoffset); - baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; - baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; - baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; - baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co; - } - // Let dispoffset work first since this adjust each vertex HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); @@ -4249,18 +4238,8 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) HWR_DrawSpriteShadow(spr, gpatch, this_scale); } - // if it has a dispoffset, push it a little towards the camera - if (spr->dispoffset) - { - float co = -gr_viewcos*(0.05f*spr->dispoffset); - float si = -gr_viewsin*(0.05f*spr->dispoffset); - wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; - wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; - wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; - wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; - } - // Let dispoffset work first since this adjust each vertex + // ...nah HWR_RotateSpritePolyToAim(spr, wallVerts, false); // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index c4109837c..17485f1be 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -36,9 +36,6 @@ static struct { {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Sprite shader - {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, - - // Sprite clipping hack shader (for pulling things out of the floor) {GLSL_SPRITECLIP_HACK_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Model shader @@ -431,7 +428,6 @@ customshaderxlat_t shaderxlat[] = {"Shadow", SHADER_SHADOW}, {"WallTexture", SHADER_WALL}, {"Sprite", SHADER_SPRITE}, - {"SpriteClipHack", SHADER_SPRITECLIPHACK}, {"Model", SHADER_MODEL}, {"WaterRipple", SHADER_WATER}, {"Fog", SHADER_FOG}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 6c225b1a8..45f3aed9e 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -39,7 +39,7 @@ "gl_FrontColor = gl_Color;\n" \ "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_Position.z -= 80.0 / gl_Position.z;\n" \ + "gl_Position.z -= 80 / gl_Position.z;\n" \ "}\0" // ================== diff --git a/src/r_things.c b/src/r_things.c index 0fa96a4ce..884da6302 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -299,7 +299,8 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, spritecachedinfo[numspritelumps].height = SHORT(patch.height)< Date: Mon, 3 Jun 2024 17:15:39 +0200 Subject: [PATCH 048/525] Revert "use shader to prevent sprite floor clipping" This reverts commit ee2ec01eb9796c41f435cbfa41a7046bff4039c9. --- src/hardware/hw_main.c | 25 +++++++++++++++++++++++++ src/hardware/hw_shaders.c | 2 +- src/hardware/hw_shaders.h | 11 ----------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index eed9f9232..007a05de1 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3972,6 +3972,18 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Let dispoffset work first since this adjust each vertex HWR_RotateSpritePolyToAim(spr, baseWallVerts, false); + // push it toward the camera to mitigate floor-clipping sprites + { + float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz)); + float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; + for (i = 0; i < 4; i++) + { + baseWallVerts[i].x += (gr_viewx - baseWallVerts[i].x)*distfact; + baseWallVerts[i].z += (gr_viewy - baseWallVerts[i].z)*distfact; + baseWallVerts[i].y += (gr_viewz - baseWallVerts[i].y)*distfact; + } + } + realtop = top = baseWallVerts[3].y; realbot = bot = baseWallVerts[0].y; towtop = baseWallVerts[3].t; @@ -4242,6 +4254,19 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) // ...nah HWR_RotateSpritePolyToAim(spr, wallVerts, false); + // push it toward the camera to mitigate floor-clipping sprites + { + float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz)); + float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; + size_t i; + for (i = 0; i < 4; i++) + { + wallVerts[i].x += (gr_viewx - wallVerts[i].x)*distfact; + wallVerts[i].z += (gr_viewy - wallVerts[i].z)*distfact; + wallVerts[i].y += (gr_viewz - wallVerts[i].y)*distfact; + } + } + // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. // sprite lighting by modulating the RGB components /// \todo coloured diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 17485f1be..658de5ef6 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -36,7 +36,7 @@ static struct { {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Sprite shader - {GLSL_SPRITECLIP_HACK_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Model shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 45f3aed9e..8f600fa79 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -31,17 +31,6 @@ "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ "}\0" -// Sprite clipping makes me want to McFucking Die - -#define GLSL_SPRITECLIP_HACK_VERTEX_SHADER \ - "void main(void) {\n" \ - "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_FrontColor = gl_Color;\n" \ - "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ - "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_Position.z -= 80 / gl_Position.z;\n" \ - "}\0" - // ================== // Fragment shaders // ================== -- 2.54.0 From 716685d809e836a8aa920732a52703fae420c0ad Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 3 Jun 2024 17:15:16 +0200 Subject: [PATCH 049/525] zzz... --- src/hardware/hw_shaders.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 658de5ef6..efebecc18 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -30,7 +30,7 @@ static struct { {GLSL_DEFAULT_VERTEX_SHADER, GLSL_FLOOR_FRAGMENT_SHADER}, // Shadow shader - {GLSL_SPRITECLIP_HACK_VERTEX_SHADER, GLSL_SHADOW_FRAGMENT_SHADER}, + {GLSL_DEFAULT_VERTEX_SHADER, GLSL_SHADOW_FRAGMENT_SHADER}, // Wall shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, -- 2.54.0 From 9b3eaa6fe85a1c9e9264219124516e9e365f53bb Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Jun 2024 17:10:24 +0200 Subject: [PATCH 050/525] smol optimization to skin loading --- src/r_things.c | 92 +++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 884da6302..c37807c73 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -275,58 +275,50 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, for (l = startlump; l < endlump; l++) { - if (memcmp(lumpinfo[l].name,sprname,4)==0) + if (memcmp(lumpinfo[l].name,sprname,4)) + continue; + + frame = R_Char2Frame(lumpinfo[l].name[4]); + rotation = (UINT8)(lumpinfo[l].name[5] - '0'); + + if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-... { - frame = R_Char2Frame(lumpinfo[l].name[4]); - rotation = (UINT8)(lumpinfo[l].name[5] - '0'); - - if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-... - { - CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l)); - continue; - } - - // skip NULL sprites from very old dmadds pwads - if (W_LumpLengthPwad(wadnum,l)<=8) - continue; - - // store sprite info in lookup tables - //FIXME : numspritelumps do not duplicate sprite replacements - W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0); - spritecachedinfo[numspritelumps].width = SHORT(patch.width)<0 && SHORT(patch.topoffset)= max_spritelumps) - { - max_spritelumps *= 2; - Z_Realloc(spritecachedinfo, max_spritelumps*sizeof(*spritecachedinfo), PU_STATIC, &spritecachedinfo); - } - - ++numadded; + CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l)); + continue; } + + // skip NULL sprites from very old dmadds pwads + if (W_LumpLengthPwad(wadnum,l)<=8) + continue; + + // store sprite info in lookup tables + //FIXME : numspritelumps do not duplicate sprite replacements + W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0); + spritecachedinfo[numspritelumps].width = SHORT(patch.width)<= max_spritelumps) + { + max_spritelumps *= 2; + Z_Realloc(spritecachedinfo, max_spritelumps*sizeof(*spritecachedinfo), PU_STATIC, &spritecachedinfo); + } + + ++numadded; } // -- 2.54.0 From 4246e429487eb58e3f81aa25bf8c001d3f5a077c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Jun 2024 02:27:18 +0200 Subject: [PATCH 051/525] minor sprite opitmizations --- src/hardware/hw_main.c | 136 +++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 66 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 007a05de1..3ef71658d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3062,13 +3062,13 @@ void HWR_AddPolyObjectPlanes(void) for (i = 0; i < numpolys; i++) { - polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector - if (!(po_ptrs[i]->flags & POF_RENDERPLANES)) // Only render planes when you should continue; if (po_ptrs[i]->translucency >= NUMTRANSMAPS) continue; + + polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector if (polyobjsector->floorheight <= gr_frontsector->ceilingheight && polyobjsector->floorheight >= gr_frontsector->floorheight @@ -4739,35 +4739,39 @@ void HWR_DrawSprites(void) for (i = 0; i < gr_visspritecount; i++) { gr_vissprite_t *spr = gr_vsprorder[i]; - if (spr->precip) - HWR_DrawPrecipitationSprite(spr); - else - if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) - { - md2_t *md2; - if (spr->mobj->localskin) - { - if (spr->mobj->skinlocal) - md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins]; - else - md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins]; - } - else - md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins]; - // 8/1/19: Only don't display player models if no default SPR_PLAY is found. - if (!cv_grmdls.value || ((md2->notfound || md2->scale < 0.0f) && ((!cv_grfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN]) - HWR_DrawSprite(spr); + if (spr->precip) + { + HWR_DrawPrecipitationSprite(spr); + continue; + } + + if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) + { + md2_t *md2; + if (spr->mobj->localskin) + { + if (spr->mobj->skinlocal) + md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins]; else - HWR_DrawMD2(spr); + md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins]; } else + md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins]; + + // 8/1/19: Only don't display player models if no default SPR_PLAY is found. + if (!cv_grmdls.value || ((md2->notfound || md2->scale < 0.0f) && ((!cv_grfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN]) + HWR_DrawSprite(spr); + else + HWR_DrawMD2(spr); + } + else { - if (!cv_grmdls.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) - HWR_DrawSprite(spr); - else - HWR_DrawMD2(spr); - } + if (!cv_grmdls.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) + HWR_DrawSprite(spr); + else + HWR_DrawMD2(spr); + } } } @@ -4806,7 +4810,46 @@ void HWR_AddSprites(sector_t *sec) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - if (limit_dist) + if (limit_dist == 0) + { + // Draw everything in sector, no checks + for (thing = sec->thinglist; thing; thing = thing->snext) + { + split_drawsprite = false; + + if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) + continue; + + splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); + + if (splitscreen && splitflags) + { + if (thing->eflags & MFE_DRAWONLYFORP1) + if (viewssnum == 0) + split_drawsprite = true; + + if (thing->eflags & MFE_DRAWONLYFORP2) + if (viewssnum == 1) + split_drawsprite = true; + + if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) + if (viewssnum == 2) + split_drawsprite = true; + + if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) + if (viewssnum == 3) + split_drawsprite = true; + } + else + split_drawsprite = true; + + if (!split_drawsprite) + continue; + + HWR_ProjectSprite(thing); + } + } + else { for (thing = sec->thinglist; thing; thing = thing->snext) { @@ -4849,45 +4892,6 @@ void HWR_AddSprites(sector_t *sec) HWR_ProjectSprite(thing); } } - else - { - // Draw everything in sector, no checks - for (thing = sec->thinglist; thing; thing = thing->snext) - { - split_drawsprite = false; - - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) - continue; - - splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); - - if (splitscreen && splitflags) - { - if (thing->eflags & MFE_DRAWONLYFORP1) - if (viewssnum == 0) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP2) - if (viewssnum == 1) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) - if (viewssnum == 2) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) - if (viewssnum == 3) - split_drawsprite = true; - } - else - split_drawsprite = true; - - if (!split_drawsprite) - continue; - - HWR_ProjectSprite(thing); - } - } } // -------------------------------------------------------------------------- -- 2.54.0 From 1503daf02bb1b4d3a64d119abacf4f59e2ecc0a4 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Jun 2024 14:42:23 +0200 Subject: [PATCH 052/525] more minor loop stuff --- src/hardware/hw_bsp.c | 14 ++-- src/hardware/hw_cache.c | 30 +++++--- src/hardware/hw_main.c | 165 +++++++++++++++++++++------------------- src/r_bsp.c | 32 ++++---- src/r_data.c | 61 ++++++++------- src/r_main.c | 20 ++--- src/r_plane.c | 46 ++++++----- src/r_segs.c | 5 +- src/r_things.c | 1 + 9 files changed, 196 insertions(+), 178 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index ebf18ed14..91759c819 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -772,9 +772,11 @@ static INT32 SolveTProblem(void) for (l = 0; l < addsubsector; l++) { p = extrasubsectors[l].planepoly; - if (p) - for (i = 0; i < p->numpts; i++) - SearchSegInBSP((INT32)numnodes-1, &p->pts[i], p); + if (!p) + continue; + + for (i = 0; i < p->numpts; i++) + SearchSegInBSP((INT32)numnodes-1, &p->pts[i], p); } //CONS_Debug(DBG_RENDER, "numsplitpoly %d\n", numsplitpoly); return numsplitpoly; @@ -802,8 +804,10 @@ static void AdjustSegs(void) count = subsectors[i].numlines; lseg = &segs[subsectors[i].firstline]; p = extrasubsectors[i].planepoly; - //if (!p) - //continue; + + if (!p) + continue; + for (; count--; lseg++) { float distv1,distv2,tmp; diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 2a5ec4ff5..98034970d 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -381,16 +381,17 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe realpatch); Z_Unlock(realpatch); } + //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( if (format2bpp(grtex->mipmap.format)==4) { for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp { - if (block[i] == 0) - { - grtex->mipmap.flags |= TF_TRANSPARENT; - break; - } + if (block[i] != 0) + continue; + + grtex->mipmap.flags |= TF_TRANSPARENT; + break; } } @@ -629,8 +630,12 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) #ifdef GLENCORE flat = grMipmap->data; for (steppy = 0; steppy < size; steppy++) - if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX) - flat[steppy] = grMipmap->colormap[flat[steppy]]; + { + if (flat[steppy] == HWR_PATCHES_CHROMAKEY_COLORINDEX) + continue; + + flat[steppy] = grMipmap->colormap[flat[steppy]]; + } #endif } @@ -743,11 +748,12 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap) for (grmip = gpatch->mipmap; grmip->nextcolormap; ) { grmip = grmip->nextcolormap; - if (grmip->colormap == colormap) - { - HWR_LoadMappedPatch(grmip, gpatch); - return; - } + + if (grmip->colormap != colormap) + continue; + + HWR_LoadMappedPatch(grmip, gpatch); + return; } // not found, create it! // If we are here, the sprite with the current colormap is not already in hardware memory diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3ef71658d..1cba83059 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -882,75 +882,75 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc for (i = 0; i < subsector->numlines; i++, line++) { - if (line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(viewx, viewy, line) == 0) + if (!(line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(viewx, viewy, line) == 0)) + continue; + + P_ClosestPointOnLine(viewx, viewy, line->linedef, &v); + dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y)); + + if (line->pv1) { - P_ClosestPointOnLine(viewx, viewy, line->linedef, &v); - dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y)); - - if (line->pv1) - { - x1 = ((polyvertex_t *)line->pv1)->x; - y1 = ((polyvertex_t *)line->pv1)->y; - } - else - { - x1 = FIXED_TO_FLOAT(line->v1->x); - y1 = FIXED_TO_FLOAT(line->v1->x); - } - if (line->pv2) - { - xd = ((polyvertex_t *)line->pv2)->x - x1; - yd = ((polyvertex_t *)line->pv2)->y - y1; - } - else - { - xd = FIXED_TO_FLOAT(line->v2->x) - x1; - yd = FIXED_TO_FLOAT(line->v2->y) - y1; - } + x1 = ((polyvertex_t *)line->pv1)->x; + y1 = ((polyvertex_t *)line->pv1)->y; + } + else + { + x1 = FIXED_TO_FLOAT(line->v1->x); + y1 = FIXED_TO_FLOAT(line->v1->x); + } + if (line->pv2) + { + xd = ((polyvertex_t *)line->pv2)->x - x1; + yd = ((polyvertex_t *)line->pv2)->y - y1; + } + else + { + xd = FIXED_TO_FLOAT(line->v2->x) - x1; + yd = FIXED_TO_FLOAT(line->v2->y) - y1; + } - // Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion - dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f; - if (dist > 100.0f) - numplanes = 100; - else - numplanes = (UINT8)dist + 1; + // Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion + dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f; + if (dist > 100.0f) + numplanes = 100; + else + numplanes = (UINT8)dist + 1; - for (j = 0; j < numplanes; j++) - { - // Left side - vx = x1 + xd * j / numplanes; - vy = y1 + yd * j / numplanes; - SETUP3DVERT((&horizonpts[1]), vx, vy); + for (j = 0; j < numplanes; j++) + { + // Left side + vx = x1 + xd * j / numplanes; + vy = y1 + yd * j / numplanes; + SETUP3DVERT((&horizonpts[1]), vx, vy); - dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2)); - vx = (vx - gr_viewx) * renderdist / dist + gr_viewx; - vy = (vy - gr_viewy) * renderdist / dist + gr_viewy; - SETUP3DVERT((&horizonpts[0]), vx, vy); + dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2)); + vx = (vx - gr_viewx) * renderdist / dist + gr_viewx; + vy = (vy - gr_viewy) * renderdist / dist + gr_viewy; + SETUP3DVERT((&horizonpts[0]), vx, vy); - // Right side - vx = x1 + xd * (j+1) / numplanes; - vy = y1 + yd * (j+1) / numplanes; - SETUP3DVERT((&horizonpts[2]), vx, vy); + // Right side + vx = x1 + xd * (j+1) / numplanes; + vy = y1 + yd * (j+1) / numplanes; + SETUP3DVERT((&horizonpts[2]), vx, vy); - dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2)); - vx = (vx - gr_viewx) * renderdist / dist + gr_viewx; - vy = (vy - gr_viewy) * renderdist / dist + gr_viewy; - SETUP3DVERT((&horizonpts[3]), vx, vy); + dist = sqrtf(powf(vx - gr_viewx, 2) + powf(vy - gr_viewy, 2)); + vx = (vx - gr_viewx) * renderdist / dist + gr_viewx; + vy = (vy - gr_viewy) * renderdist / dist + gr_viewy; + SETUP3DVERT((&horizonpts[3]), vx, vy); - // Horizon fills - vx = (horizonpts[0].x - gr_viewx) * farrenderdist / renderdist + gr_viewx; - vy = (horizonpts[0].z - gr_viewy) * farrenderdist / renderdist + gr_viewy; - SETUP3DVERT((&horizonpts[5]), vx, vy); - horizonpts[5].y = gr_viewz; + // Horizon fills + vx = (horizonpts[0].x - gr_viewx) * farrenderdist / renderdist + gr_viewx; + vy = (horizonpts[0].z - gr_viewy) * farrenderdist / renderdist + gr_viewy; + SETUP3DVERT((&horizonpts[5]), vx, vy); + horizonpts[5].y = gr_viewz; - vx = (horizonpts[3].x - gr_viewx) * farrenderdist / renderdist + gr_viewx; - vy = (horizonpts[3].z - gr_viewy) * farrenderdist / renderdist + gr_viewy; - SETUP3DVERT((&horizonpts[4]), vx, vy); + vx = (horizonpts[3].x - gr_viewx) * farrenderdist / renderdist + gr_viewx; + vy = (horizonpts[3].z - gr_viewy) * farrenderdist / renderdist + gr_viewy; + SETUP3DVERT((&horizonpts[4]), vx, vy); horizonpts[4].y = gr_viewz; - // Draw - HWR_ProcessPolygon(&Surf, horizonpts, 6, PolyFlags, shader, true); - } + // Draw + HWR_ProcessPolygon(&Surf, horizonpts, 6, PolyFlags, shader, true); } } } @@ -3230,11 +3230,11 @@ static void HWR_Subsector(size_t num) { sector_t *controlSec = §ors[rover->secnum]; - if (controlSec->moved == true) - { - anyMoved = true; - break; - } + if (controlSec->moved != true) + continue; + + anyMoved = true; + break; } } @@ -3635,8 +3635,11 @@ static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t hei delta1 = z - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)); delta2 = thingtop - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)); - if (*rover->topheight > floorz && abs(delta1) < abs(delta2)) - floorz = *rover->topheight; + + if (!(*rover->topheight > floorz && abs(delta1) < abs(delta2))) + continue; + + floorz = *rover->topheight; } } @@ -4041,13 +4044,13 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) for (i = 1; i < sector->numlights; i++) { fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); - if (h <= temp) - { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; - colormap = list[i-1].extra_colormap; - break; - } + if (!(h <= temp)) + continue; + + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; + colormap = list[i-1].extra_colormap; + break; } for (i = 0; i < sector->numlights; i++) @@ -5578,8 +5581,10 @@ void HWR_SetTransform(float fpov, player_t *player) for (i = 0; i <= splitscreen; i++) { - if (player == &players[displayplayers[i]]) - postprocessor = &postimgtype[i]; + if (player != &players[displayplayers[i]]) + continue; + + postprocessor = &postimgtype[i]; } atransform.flip = false; @@ -6146,11 +6151,11 @@ void HWR_DoPostProcessor(player_t *player) for (i = splitscreen; i > 0; i--) { - if (player == &players[displayplayers[i]]) - { - type = &postimgtype[i]; - break; - } + if (player != &players[displayplayers[i]]) + continue; + + type = &postimgtype[i]; + break; } // Armageddon Blast Flash! diff --git a/src/r_bsp.c b/src/r_bsp.c index 02f4d8c83..dc409feba 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -266,11 +266,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, for (i = 0; i <= splitscreen; i++) { - if (viewplayer == &players[displayplayers[i]] && camera[i].chase) - { - heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; - break; - } + if (!(viewplayer == &players[displayplayers[i]] && camera[i].chase)) + continue; + + heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; + break; } if (i > splitscreen && viewmobj) @@ -907,11 +907,11 @@ static void R_Subsector(size_t num) { sector_t *controlSec = §ors[rover->secnum]; - if (controlSec->moved == true) - { - anyMoved = true; - break; - } + if (controlSec->moved != true) + continue; + + anyMoved = true; + break; } } @@ -1185,13 +1185,13 @@ void R_Prep3DFloors(sector_t *sector) count = 1; for (rover = sector->ffloors; rover; rover = rover->next) { - if ((rover->flags & FF_EXISTS) && (!(rover->flags & FF_NOSHADE) - || (rover->flags & FF_CUTLEVEL) || (rover->flags & FF_CUTSPRITES))) - { + if (!((rover->flags & FF_EXISTS) && (!(rover->flags & FF_NOSHADE) + || (rover->flags & FF_CUTLEVEL) || (rover->flags & FF_CUTSPRITES)))) + continue; + + count++; + if (rover->flags & FF_DOUBLESHADOW) count++; - if (rover->flags & FF_DOUBLESHADOW) - count++; - } } if (count != sector->numlights) diff --git a/src/r_data.c b/src/r_data.c index 69b0ce1ac..ad8b420f3 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -429,22 +429,24 @@ void R_LoadTextures(void) } // Add all the textures between TX_START and TX_END - if (texstart != INT16_MAX && texend != INT16_MAX) + if (!(texstart != INT16_MAX && texend != INT16_MAX)) + continue; + + // PK3s have subfolders, so we can't just make a simple sum + if (W_FileHasFolders(wadfiles[w])) { - // PK3s have subfolders, so we can't just make a simple sum - if (W_FileHasFolders(wadfiles[w])) + for (j = texstart; j < texend; j++) { - for (j = texstart; j < texend; j++) - { - if (!W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it - numtextures++; - } - } - else - { - numtextures += (UINT32)(texend - texstart); + if (W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it + continue; + + numtextures++; } } + else + { + numtextures += (UINT32)(texend - texstart); + } } // If no textures found by this point, bomb out @@ -1003,26 +1005,26 @@ lumpnum_t R_GetFlatNumForName(const char *name) { switch (wadfiles[i]->type) { - case RET_WAD: - if ((start = W_CheckNumForNamePwad("F_START", (UINT16)i, 0)) == INT16_MAX) - { - if ((start = W_CheckNumForNamePwad("FF_START", (UINT16)i, 0)) == INT16_MAX) + case RET_WAD: + if ((start = W_CheckNumForNamePwad("F_START", (UINT16)i, 0)) == INT16_MAX) + { + if ((start = W_CheckNumForNamePwad("FF_START", (UINT16)i, 0)) == INT16_MAX) + continue; + else if ((end = W_CheckNumForNamePwad("FF_END", (UINT16)i, start)) == INT16_MAX) + continue; + } + else + if ((end = W_CheckNumForNamePwad("F_END", (UINT16)i, start)) == INT16_MAX) + continue; + break; + case RET_PK3: + if ((start = W_CheckNumForFolderStartPK3("Flats/", i, 0)) == INT16_MAX) continue; - else if ((end = W_CheckNumForNamePwad("FF_END", (UINT16)i, start)) == INT16_MAX) + if ((end = W_CheckNumForFolderEndPK3("Flats/", i, start)) == INT16_MAX) continue; - } - else - if ((end = W_CheckNumForNamePwad("F_END", (UINT16)i, start)) == INT16_MAX) - continue; - break; - case RET_PK3: - if ((start = W_CheckNumForFolderStartPK3("Flats/", i, 0)) == INT16_MAX) + break; + default: continue; - if ((end = W_CheckNumForFolderEndPK3("Flats/", i, start)) == INT16_MAX) - continue; - break; - default: - continue; } // Now find lump with specified name in that range. @@ -1310,6 +1312,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) { if (foundcolormaps[i] != LUMPERROR) continue; + if (maskcolor == extra_colormaps[i].maskcolor && fadecolor == extra_colormaps[i].fadecolor && fabs(maskamt - extra_colormaps[i].maskamt) < DBL_EPSILON diff --git a/src/r_main.c b/src/r_main.c index a15258c48..f1ffeebce 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1687,11 +1687,11 @@ void R_RenderPlayerView(player_t *player) // load previous saved value of skyVisible for the player for (i = 0; i <= splitscreen; i++) { - if (player == &players[displayplayers[i]]) - { - skyVisible = skyVisiblePerPlayer[i]; - break; - } + if (player != &players[displayplayers[i]]) + continue; + + skyVisible = skyVisiblePerPlayer[i]; + break; } portalrender = 0; @@ -1814,11 +1814,11 @@ void R_RenderPlayerView(player_t *player) // this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa for (i = 0; i <= splitscreen; i++) { - if (player == &players[displayplayers[i]]) - { - skyVisiblePerPlayer[i] = skyVisible; - break; - } + if (player != &players[displayplayers[i]]) + continue; + + skyVisiblePerPlayer[i] = skyVisible; + break; } } diff --git a/src/r_plane.c b/src/r_plane.c index 6bd6f212d..6299edd9e 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -674,25 +674,26 @@ static void R_DrawSkyPlane(visplane_t *pl) // Because of this hack, sky is not affected // by INVUL inverse mapping. dc_colormap = colormaps; + if (encoremap) dc_colormap += COLORMAP_REMAPOFFSET; + dc_texturemid = skytexturemid; - dc_texheight = textureheight[skytexture] - >>FRACBITS; + dc_texheight = textureheight[skytexture] >>FRACBITS; + for (x = pl->minx; x <= pl->maxx; x++) { dc_yl = pl->top[x]; dc_yh = pl->bottom[x]; - if (dc_yl <= dc_yh) - { - angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; - dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); - dc_x = x; - dc_source = - R_GetColumn(texturetranslation[skytexture], - angle); - wallcolfunc(); - } + + if (!(dc_yl <= dc_yh)) + continue; + + angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; + dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); + dc_x = x; + dc_source = R_GetColumn(texturetranslation[skytexture], angle); + wallcolfunc(); } } @@ -839,18 +840,15 @@ void R_DrawSinglePlane(visplane_t *pl) // Don't draw planes that shouldn't be drawn. for (rover = pl->ffloor->target->ffloors; rover; rover = rover->next) { - if ((pl->ffloor->flags & FF_CUTEXTRA) && (rover->flags & FF_EXTRA)) - { - if (pl->ffloor->flags & FF_EXTRA) - { - // The plane is from an extra 3D floor... Check the flags so - // there are no undesired cuts. - if (((pl->ffloor->flags & (FF_FOG|FF_SWIMMABLE)) == (rover->flags & (FF_FOG|FF_SWIMMABLE))) - && pl->height < *rover->topheight - && pl->height > *rover->bottomheight) - return; - } - } + if (!((pl->ffloor->flags & FF_CUTEXTRA) && (rover->flags & FF_EXTRA))) + continue; + + // The plane is from an extra 3D floor... Check the flags so + // there are no undesired cuts. + if (((pl->ffloor->flags & (FF_FOG|FF_SWIMMABLE)) == (rover->flags & (FF_FOG|FF_SWIMMABLE))) + && pl->height < *rover->topheight + && pl->height > *rover->bottomheight) + return; } if (pl->ffloor->flags & FF_TRANSLUCENT) diff --git a/src/r_segs.c b/src/r_segs.c index 4a231938b..b70e06ff6 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -496,7 +496,6 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } } - dc_texheight = textureheight[texnum]>>FRACBITS; // draw the columns @@ -983,7 +982,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) // draw the columns for (dc_x = x1; dc_x <= x2; dc_x++) { - if (maskedtexturecol[dc_x] != INT16_MAX) + if (maskedtexturecol[dc_x] == INT16_MAX) + continue; + { if (ffloortextureslide) { // skew FOF walls if (oldx != -1) diff --git a/src/r_things.c b/src/r_things.c index c37807c73..87cbc33d6 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -447,6 +447,7 @@ void R_AddSpriteDefs(UINT16 wadnum) for (i = 0; i < numsprites; i++) { spritename = sprnames[i]; + if (spritename[4] && wadnum >= (UINT16)spritename[4]) continue; -- 2.54.0 From 51392590372e0cef59ca7023296c1aedaafdf8b9 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Jun 2024 18:42:32 +0200 Subject: [PATCH 053/525] fix HAVE_CURL --- src/d_clisrv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 471d329a4..69c87a157 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1333,9 +1333,13 @@ static inline void CL_DrawConnectionStatus(void) { strncpy(tempname, filename, sizeof(tempname)-1); } - +#ifdef HAVE_CURL V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-30, 0, va(M_GetText("%s downloading"), ((cl_mode == CL_DOWNLOADHTTPFILES) ? "\x82""HTTP" : "\x85""Direct"))); +#else + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-30, 0, + va(M_GetText("%s downloading"),("\x85""Direct"))); +#endif V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP, va(M_GetText("\"%s\""), tempname)); V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE, @@ -2170,7 +2174,9 @@ static void M_ConfirmConnect(event_t *ev) static void AbortConnection(void) { +#ifdef HAVE_CURL CURLAbortFile(); +#endif D_QuitNetGame(); CL_Reset(); D_StartTitle(); -- 2.54.0 From cfe6e081689fd65267d10c7c708deaff587cdc68 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Jun 2024 18:47:06 +0200 Subject: [PATCH 054/525] fix masterserver ifdef --- src/mserv.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mserv.h b/src/mserv.h index 5a74771a4..76bd5fd28 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -90,9 +90,11 @@ char *GetMODVersion(int id); #endif char *GetMasterServerRules(void); +#endif void AddMServCommands(void); +#ifdef MASTERSERVER /* HTTP */ void HMS_set_api (char *api); int HMS_register (void); @@ -105,4 +107,4 @@ const char * HMS_fetch_rules (char *buffer, size_t size_of_buffer); #endif -#endif \ No newline at end of file +#endif -- 2.54.0 From f8a8b8ac6e1f02e038e0b17f6f6334cca869fe10 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Jun 2024 18:53:40 +0200 Subject: [PATCH 055/525] disable upx on nix by default --- src/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Makefile b/src/Makefile index 20f33a471..98351a8a2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -106,6 +106,8 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... else # if you on the *nix + NOUPX=1 + system:=$(shell uname -s) ifeq ($(system),Linux) -- 2.54.0 From 4abc2ab5bd32037f7889d055346ea2b28e50a744 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Jun 2024 18:57:04 +0200 Subject: [PATCH 056/525] fix redifinition warning --- src/sdl/IMG_xpm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sdl/IMG_xpm.c b/src/sdl/IMG_xpm.c index 458131620..7a68185fa 100644 --- a/src/sdl/IMG_xpm.c +++ b/src/sdl/IMG_xpm.c @@ -1198,6 +1198,8 @@ SDL_Surface *IMG_ReadXPMFromArray(const char **xpm) return load_xpm(xpm, NULL); } +#undef MAX + #else /* not LOAD_XPM */ /* See if an image is contained in a data source */ -- 2.54.0 From bd7103d109b026df8b737bbea157283c987e8c54 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Jun 2024 18:03:58 +0200 Subject: [PATCH 057/525] add check earlier in p_killmobj --- src/p_inter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 14c712033..68d02cdd9 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1908,8 +1908,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) mobj_t *mo; int ms; - //if (inflictor && (inflictor->type == MT_SHELL || inflictor->type == MT_FIREBALL)) - // P_SetTarget(&target->tracer, inflictor); + if (!target || P_MobjWasRemoved(target)) + return; if (!useNightsSS && G_IsSpecialStage(gamemap) && target->player && sstimer > 6) sstimer = 6; // Just let P_Ticker take care of the rest. -- 2.54.0 From 6ffb50530dff945c4b42b8bd1307186fb468e5f3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Jun 2024 18:13:17 +0200 Subject: [PATCH 058/525] add mobj check here --- src/p_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 4cf785529..8f2f1eaa7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1195,6 +1195,9 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) { mobj_t *ghost; + if (!mobj || P_MobjWasRemoved(mobj)) + return; + ghost = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_GHOST); P_SetScale(ghost, mobj->scale); -- 2.54.0 From 07d631e320e096b5190eb6e70fde329c346cc051 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Jun 2024 18:14:22 +0200 Subject: [PATCH 059/525] e --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 8f2f1eaa7..3bee5abcd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1196,7 +1196,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) mobj_t *ghost; if (!mobj || P_MobjWasRemoved(mobj)) - return; + return NULL; ghost = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_GHOST); -- 2.54.0 From d66e7e660d781b84e4281b4e697c9196e7b63fd4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Jun 2024 18:49:33 +0200 Subject: [PATCH 060/525] reset those here ig need a better place tbh but those occasionally could get stuck for some reason so just reset them when the menu gets opened --- src/m_menu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index d7dc233b1..8693d6f29 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4160,6 +4160,11 @@ void M_StartControlPanel(void) menuactive = true; + DPADUPSCROLL = false; + DPADDOWNSCROLL = false; + DPADLEFTSCROLL = false; + DPADRIGHTSCROLL = false; + if (demo.playback) { currentMenu = &PlaybackMenuDef; -- 2.54.0 From 3412bb5380a9ee4ae6ec21b80be156234c4c368d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Jun 2024 22:02:46 +0200 Subject: [PATCH 061/525] fix encore flipcam with ogl shearing --- src/hardware/r_opengl/r_opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 64bc0d949..12e70f945 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2960,7 +2960,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) if (shearing) { float dy = FIXED_TO_FLOAT(AIMINGTODY((stransform->viewaiming)) * 2)* ((float)vid.width / vid.height) / ((float)BASEVIDWIDTH / BASEVIDHEIGHT); //screen_width/BASEVIDWIDTH; - if (stransform->flip) + if (stransform->flip || stransform->mirrorflip) dy *= -1.0f; pglTranslatef(0.0f, -dy/BASEVIDHEIGHT, 0.0f); } -- 2.54.0 From 86395d4d8b3ba71c2a038b3541a3bba76ecfdb47 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 12 Jun 2024 21:04:50 +0300 Subject: [PATCH 062/525] Add a way to count number of handled packets (for debugging) --- src/d_clisrv.c | 20 ++++++++++++++++++++ src/d_net.c | 12 ++++++++++-- src/d_net.h | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 69c87a157..cab82e2cb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -75,6 +75,8 @@ #define MAX_REASONLENGTH 30 #define FORCECLOSE 0x8000 +static UINT64 packetstat[NUMPACKETTYPE+1] = {0}; + boolean server = true; // true or false but !server == client #define client (!server) boolean nodownload = false; @@ -3106,6 +3108,17 @@ static void Command_connect(void) botskin = 0; CL_ConnectToServer(); } + +static void Command_Packetstat(void) +{ + CONS_Printf("Number of packets handled:\n"); + + for (UINT8 i = 0; i <= NUMPACKETTYPE; ++i) + { + CONS_Printf("%16s: %lu%s", Net_GetPacketName(i), packetstat[i], (i % 2 == 1) ? "\n" : "\t|\t"); + } +} + #endif static void ResetNode(INT32 node); @@ -3271,6 +3284,7 @@ void CL_Reset(void) // make sure we don't leave any fileneeded gunk over from a failed join fileneedednum = 0; memset(fileneeded, 0, sizeof(fileneeded)); + memset(packetstat, 0, sizeof(packetstat)); #ifndef NONET totalfilesrequestednum = 0; @@ -4025,6 +4039,7 @@ void D_ClientServerInit(void) COM_AddCommand("connect", Command_connect); COM_AddCommand("nodes", Command_Nodes); COM_AddCommand("listplayers", Command_Listplayers); + COM_AddCommand("packetstat", Command_Packetstat); #ifdef HAVE_CURL COM_AddCommand("set_http_login", Command_set_http_login); COM_AddCommand("list_http_logins", Command_list_http_logins); @@ -4123,6 +4138,7 @@ void SV_ResetServer(void) // clear server_context memset(server_context, '-', 8); + memset(packetstat, 0, sizeof(packetstat)); DEBFILE("\n-=-=-=-=-=-=-= Server Reset =-=-=-=-=-=-=-\n\n"); } @@ -5522,6 +5538,10 @@ static void GetPackets(void) if (netbuffer->packettype == PT_PLAYERINFO) continue; // We do nothing with PLAYERINFO, that's for the MS browser. + // We also count unknown packets, hence "<=" + if (netbuffer->packettype <= NUMPACKETTYPE) + ++packetstat[netbuffer->packettype]; + // Packet received from someone already playing if (nodeingame[node]) HandlePacketFromPlayer(node); diff --git a/src/d_net.c b/src/d_net.c index 6b45e009d..04db5f7c5 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -793,7 +793,7 @@ static void fprintfstringnewline(char *s, size_t len) } /// \warning Keep this up-to-date if you add/remove/rename packet types -static const char *packettypename[NUMPACKETTYPE] = +const char *packettypename[NUMPACKETTYPE] = { "NOTHING", "SERVERCFG", @@ -838,11 +838,19 @@ static const char *packettypename[NUMPACKETTYPE] = "PING" }; +const char *Net_GetPacketName(UINT8 packettype) +{ + if (packettype >= NUMPACKETTYPE) + return "UNKNOWN"; + + return packettypename[packettype]; +} + static void DebugPrintpacket(const char *header) { fprintf(debugfile, "%-12s (node %d,ack %d,ackret %d,size %d) type(%d) : %s\n", header, doomcom->remotenode, netbuffer->ack, netbuffer->ackreturn, doomcom->datalength, - netbuffer->packettype, packettypename[netbuffer->packettype]); + netbuffer->packettype, Net_GetPacketName(netbuffer->packettype)); switch (netbuffer->packettype) { diff --git a/src/d_net.h b/src/d_net.h index e267f5268..471881847 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -65,5 +65,6 @@ void Net_ConnectionTimeout(INT32 node); void Net_AbortPacketType(UINT8 packettype); void Net_SendAcks(INT32 node); void Net_WaitAllAckReceived(UINT32 timeout); +const char *Net_GetPacketName(UINT8 packettype); #endif -- 2.54.0 From 5af7cf850a81c7b5cb5c310230f915bf78062018 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 12 Jun 2024 21:26:41 +0300 Subject: [PATCH 063/525] Fix string format warning for packetstat --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index cab82e2cb..fea914ddf 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -75,7 +75,7 @@ #define MAX_REASONLENGTH 30 #define FORCECLOSE 0x8000 -static UINT64 packetstat[NUMPACKETTYPE+1] = {0}; +static long long unsigned packetstat[NUMPACKETTYPE+1] = {0}; boolean server = true; // true or false but !server == client #define client (!server) @@ -3115,7 +3115,7 @@ static void Command_Packetstat(void) for (UINT8 i = 0; i <= NUMPACKETTYPE; ++i) { - CONS_Printf("%16s: %lu%s", Net_GetPacketName(i), packetstat[i], (i % 2 == 1) ? "\n" : "\t|\t"); + CONS_Printf("%16s: %llu%s", Net_GetPacketName(i), packetstat[i], (i % 2 == 1) ? "\n" : "\t|\t"); } } -- 2.54.0 From be7461ad5110bab6b65be7d361d1a1749c061eb7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Jun 2024 22:31:29 +0200 Subject: [PATCH 064/525] use sdl ogl render instead of software for software mode on nix oops --- src/sdl/i_video.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f90f5bb18..16f4c4336 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -2023,12 +2023,11 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) else if (cv_vidwait.value) flags |= SDL_RENDERER_PRESENTVSYNC; - // 3 August 2022 - // Possibly a Windows 11 issue; the default - // "direct3d" driver (D3D9) causes Drmingw exchndl - // to not write RPT files. Every other driver - // seems fine. +#ifdef _WIN32 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d11"); +#else + SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); +#endif renderer = SDL_CreateRenderer(window, -1, flags); if (renderer == NULL) -- 2.54.0 From 967220178cfeb8118495c61355f9fb36337f0b67 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Jun 2024 22:32:54 +0200 Subject: [PATCH 065/525] remove windows timing crap again it actually made stuff a little wonky so revert that --- src/sdl/i_system.c | 47 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 7a5f79f58..f1171342e 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3189,28 +3189,21 @@ ticcmd_t *I_BaseTiccmd4(void) return &emptycmd4; } +// +// I_GetTime +// returns time in 1/TICRATE second tics +// + static Uint64 timer_frequency; precise_t I_GetPreciseTime(void) { -#if defined(_WIN32) - LARGE_INTEGER counter; - QueryPerformanceCounter(&counter); - return counter.QuadPart; -#else return SDL_GetPerformanceCounter(); -#endif } UINT64 I_GetPrecisePrecision(void) { -#if defined(_WIN32) - LARGE_INTEGER frequency; - QueryPerformanceFrequency(&frequency); - return frequency.QuadPart; -#else return SDL_GetPerformanceFrequency(); -#endif } static UINT32 frame_rate; @@ -3237,24 +3230,14 @@ static void I_InitFrameTime(const UINT64 now, const UINT32 cap) } double I_GetFrameTime(void) -{ -#if defined(_WIN32) - LARGE_INTEGER now; - QueryPerformanceCounter(&now); - const UINT64 nowValue = now.QuadPart; -#else +{ const UINT64 now = SDL_GetPerformanceCounter(); -#endif const UINT32 cap = R_GetFramerateCap(); if (cap != frame_rate) { // Maybe do this in a OnChange function for cv_fpscap? -#if defined(_WIN32) - I_InitFrameTime(nowValue, cap); -#else I_InitFrameTime(now, cap); -#endif } if (frame_rate == 0) @@ -3264,17 +3247,10 @@ double I_GetFrameTime(void) } else { -#if defined(_WIN32) - elapsed_frames += (nowValue - frame_epoch) / frame_frequency; -#else elapsed_frames += (now - frame_epoch) / frame_frequency; -#endif } -#if defined(_WIN32) - frame_epoch = nowValue; // moving epoch -#else - frame_epoch = now; // moving epoch -#endif + + frame_epoch = now; // moving epoch return elapsed_frames; } @@ -3283,13 +3259,8 @@ double I_GetFrameTime(void) // void I_StartupTimer(void) { -#if defined(_WIN32) - LARGE_INTEGER frequency; - QueryPerformanceFrequency(&frequency); - timer_frequency = frequency.QuadPart; -#else timer_frequency = SDL_GetPerformanceFrequency(); -#endif + I_InitFrameTime(0, R_GetFramerateCap()); elapsed_frames = 0.0; } -- 2.54.0 From 335b10a69444900cf7af653918a61d45888915e8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Jun 2024 22:33:36 +0200 Subject: [PATCH 066/525] forgor --- src/sdl/i_system.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index f1171342e..b20eeba7d 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3306,12 +3306,7 @@ void I_SleepDuration(precise_t duration) // hard sleep function. if (sleepvalue > 0 && (dest - cur) > delaygranularity) { -#if defined(_WIN32) - DWORD sleepDuration = (DWORD)min((INT64)(dest - cur), sleepvalue); - SleepEx(sleepDuration, TRUE); -#else I_Sleep(sleepvalue); -#endif } // Otherwise, this is a spinloop. -- 2.54.0 From 225ecce676b53c1aa346098bf574be1c05df5012 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Jun 2024 12:59:23 +0200 Subject: [PATCH 067/525] lower min audio buffersize to 256 --- src/s_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index b140978a3..21d29b231 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -65,7 +65,7 @@ static void AmigaType_OnChange(void); consvar_t cv_samplerate = {"samplerate", "44100", 0, CV_Unsigned, NULL, 22050, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking? -static CV_PossibleValue_t audbuffersize_cons_t[] = {{512, "512"}, {1024, "1024"}, {2048, "2048"}, {4096, "4096"}, {0, NULL}}; +static CV_PossibleValue_t audbuffersize_cons_t[] = {{256, "256"}, {512, "512"}, {1024, "1024"}, {2048, "2048"}, {4096, "4096"}, {0, NULL}}; consvar_t cv_audbuffersize = {"buffersize", "2048", CV_SAVE, audbuffersize_cons_t, BufferSize_OnChange, 0, NULL, NULL, 0, 0, NULL}; // stereo reverse -- 2.54.0 From 41eb2ee9692e26773e5f20f81943baf90babe4b9 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Jun 2024 21:49:20 +0200 Subject: [PATCH 068/525] =?UTF-8?q?fix=20oopsie=20on=20titled=20software?= =?UTF-8?q?=20w=C3=B6ter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/r_draw8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index f3ebf0ff9..6b5d177db 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -943,7 +943,7 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; lightend = (iz + ds_szp->x*width) * planelightfloat; -- 2.54.0 From 953862f13314ed1bf3c2590290aaefe3eca6fc93 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 11 Jun 2024 10:02:23 +0200 Subject: [PATCH 069/525] change this to int64 cause it fixes the intermission thing on high res idk why that fixes it tbh but it does --- src/y_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index 58cfdc4e0..5d292f36c 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -437,7 +437,7 @@ void Y_IntermissionDrawer(void) if (sorttic != -1 && intertic >= sorttic && !demo.playback) { - INT32 count = (intertic - sorttic); + INT64 count = (intertic - sorttic); if (count < 8) x -= ((((count<>FRACBITS) / (8 * vid.dupx); -- 2.54.0 From 3a1a58bcfc7e26147d79454898a77987167887a0 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 11 Jun 2024 01:35:22 +0200 Subject: [PATCH 070/525] more interp fixes --- src/d_clisrv.c | 17 +++++++++++++++-- src/g_game.c | 1 + src/p_spec.c | 7 +------ src/p_telept.c | 20 ++++++++++++-------- src/p_tick.c | 7 ------- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 69c87a157..0174dc484 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -48,6 +48,7 @@ #include "s_sound.h" // sfx_syfail #include "m_perfstats.h" #include "d_main.h" +#include "r_fps.h" #ifdef CLIENT_LOADINGSCREEN // cl loading screen @@ -6083,6 +6084,8 @@ boolean TryRunTics(tic_t realtics) if (ticking) { + boolean tickInterp = true; + // run the count * tics while (neededtic > gametic) { @@ -6093,10 +6096,20 @@ boolean TryRunTics(tic_t realtics) if (update_stats) PS_START_TIMING(ps_tictime); - G_Ticker((gametic % NEWTICRATERATIO) == 0); + boolean run = (gametic % NEWTICRATERATIO) == 0; + + if (run && tickInterp) + { + // Update old view state BEFORE ticking so resetting + // the old interpolation state from game logic works. + R_UpdateViewInterpolation(); + tickInterp = false; // do not update again in sped-up tics + } + + G_Ticker(run); ExtraDataTicker(); gametic++; - consistancy[gametic%TICQUEUE] = Consistancy(); + consistancy[gametic % TICQUEUE] = Consistancy(); if (update_stats) { diff --git a/src/g_game.c b/src/g_game.c index 8352d0b98..2ce7bd6d1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2131,6 +2131,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = G_FindView(0, viewd, onlyactive, false); P_ResetCamera(&players[(*displayplayerp)], camerap); + R_ResetViewInterpolation(viewd); } } diff --git a/src/p_spec.c b/src/p_spec.c index 9fb1953ee..aace89a2a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2371,11 +2371,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) y = sides[line->sidenum[0]].rowoffset; z = line->frontsector->ceilingheight; - P_UnsetThingPosition(mo); - mo->x += x; - mo->y += y; - mo->z += z; - P_SetThingPosition(mo); + P_SetOrigin(mo, mo->x + x, mo->y + y, mo->z + z); if (mo->player) { @@ -2394,7 +2390,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) camera[i].reset = true; camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); R_RelativeTeleportViewInterpolation(i, x, y, z, 0); - R_ResetViewInterpolation(i + 1); // reset view interp as well break; } } diff --git a/src/p_telept.c b/src/p_telept.c index 9229079c9..4e7747315 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -84,8 +84,10 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, { if (thing->player != &players[displayplayers[i]]) continue; + if (camera[i].chase) P_ResetCamera(thing->player, &camera[i]); + R_ResetViewInterpolation(i + 1); break; } @@ -157,14 +159,16 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle // move chasecam at new player location for (i = 0; i <= splitscreen; i++) { - if (thing->player == &players[displayplayers[i]]) - { - localangle[i] = angle; - if (camera[i].chase) - P_ResetCamera(thing->player, &camera[i]); - R_ResetViewInterpolation(i + 1); - break; - } + if (thing->player != &players[displayplayers[i]]) + continue; + + localangle[i] = angle; + + if (camera[i].chase) + P_ResetCamera(thing->player, &camera[i]); + + R_ResetViewInterpolation(i + 1); + break; } // don't run in place after a teleport diff --git a/src/p_tick.c b/src/p_tick.c index 6416142ce..e9c550bc0 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -581,13 +581,6 @@ void P_Ticker(boolean run) if (playeringame[i]) ++players[i].jointime; - if (run) - { - // Update old view state BEFORE ticking so resetting - // the old interpolation state from game logic works. - R_UpdateViewInterpolation(); - } - if (objectplacing) { if (OP_FreezeObjectplace()) -- 2.54.0 From efe7dd23b695c08e34bf8e8707ea28b8797e5b6b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 12 Jun 2024 22:36:03 +0200 Subject: [PATCH 071/525] revert this part idk if that was netsafe so --- src/p_spec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index aace89a2a..9fb1953ee 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2371,7 +2371,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) y = sides[line->sidenum[0]].rowoffset; z = line->frontsector->ceilingheight; - P_SetOrigin(mo, mo->x + x, mo->y + y, mo->z + z); + P_UnsetThingPosition(mo); + mo->x += x; + mo->y += y; + mo->z += z; + P_SetThingPosition(mo); if (mo->player) { @@ -2390,6 +2394,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) camera[i].reset = true; camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); R_RelativeTeleportViewInterpolation(i, x, y, z, 0); + R_ResetViewInterpolation(i + 1); // reset view interp as well break; } } -- 2.54.0 From ea49d92932c90392c985f0f07c572a34d4b26f92 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 13 Jun 2024 14:47:20 +0200 Subject: [PATCH 072/525] add missing HAVE_THREADS --- src/d_netfil.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 9c32a41f4..4eb8f2dc3 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -1300,8 +1300,9 @@ void CURLPrepareFile(const char* url, int dfilenum) curl_starttime = time(NULL); curl_running = true; - +#ifdef HAVE_THREADS I_spawn_thread("http-download", (I_thread_fn)CURLGetFile, NULL); +#endif } } -- 2.54.0 From 0068312ce395c70f1fb5f3034eebc2bf1f862ba6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Jun 2024 12:51:57 +0200 Subject: [PATCH 073/525] Revert "revert this part" This reverts commit efe7dd23b695c08e34bf8e8707ea28b8797e5b6b. --- src/p_spec.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 9fb1953ee..aace89a2a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2371,11 +2371,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) y = sides[line->sidenum[0]].rowoffset; z = line->frontsector->ceilingheight; - P_UnsetThingPosition(mo); - mo->x += x; - mo->y += y; - mo->z += z; - P_SetThingPosition(mo); + P_SetOrigin(mo, mo->x + x, mo->y + y, mo->z + z); if (mo->player) { @@ -2394,7 +2390,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) camera[i].reset = true; camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); R_RelativeTeleportViewInterpolation(i, x, y, z, 0); - R_ResetViewInterpolation(i + 1); // reset view interp as well break; } } -- 2.54.0 From 2f55c10ce3d9e7201b6ec4694654a3b0abf2e459 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Jun 2024 12:52:00 +0200 Subject: [PATCH 074/525] Revert "more interp fixes" This reverts commit 3a1a58bcfc7e26147d79454898a77987167887a0. --- src/d_clisrv.c | 17 ++--------------- src/g_game.c | 1 - src/p_spec.c | 7 ++++++- src/p_telept.c | 20 ++++++++------------ src/p_tick.c | 7 +++++++ 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0174dc484..69c87a157 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -48,7 +48,6 @@ #include "s_sound.h" // sfx_syfail #include "m_perfstats.h" #include "d_main.h" -#include "r_fps.h" #ifdef CLIENT_LOADINGSCREEN // cl loading screen @@ -6084,8 +6083,6 @@ boolean TryRunTics(tic_t realtics) if (ticking) { - boolean tickInterp = true; - // run the count * tics while (neededtic > gametic) { @@ -6096,20 +6093,10 @@ boolean TryRunTics(tic_t realtics) if (update_stats) PS_START_TIMING(ps_tictime); - boolean run = (gametic % NEWTICRATERATIO) == 0; - - if (run && tickInterp) - { - // Update old view state BEFORE ticking so resetting - // the old interpolation state from game logic works. - R_UpdateViewInterpolation(); - tickInterp = false; // do not update again in sped-up tics - } - - G_Ticker(run); + G_Ticker((gametic % NEWTICRATERATIO) == 0); ExtraDataTicker(); gametic++; - consistancy[gametic % TICQUEUE] = Consistancy(); + consistancy[gametic%TICQUEUE] = Consistancy(); if (update_stats) { diff --git a/src/g_game.c b/src/g_game.c index 2ce7bd6d1..8352d0b98 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2131,7 +2131,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = G_FindView(0, viewd, onlyactive, false); P_ResetCamera(&players[(*displayplayerp)], camerap); - R_ResetViewInterpolation(viewd); } } diff --git a/src/p_spec.c b/src/p_spec.c index aace89a2a..9fb1953ee 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2371,7 +2371,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) y = sides[line->sidenum[0]].rowoffset; z = line->frontsector->ceilingheight; - P_SetOrigin(mo, mo->x + x, mo->y + y, mo->z + z); + P_UnsetThingPosition(mo); + mo->x += x; + mo->y += y; + mo->z += z; + P_SetThingPosition(mo); if (mo->player) { @@ -2390,6 +2394,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) camera[i].reset = true; camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); R_RelativeTeleportViewInterpolation(i, x, y, z, 0); + R_ResetViewInterpolation(i + 1); // reset view interp as well break; } } diff --git a/src/p_telept.c b/src/p_telept.c index 4e7747315..9229079c9 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -84,10 +84,8 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, { if (thing->player != &players[displayplayers[i]]) continue; - if (camera[i].chase) P_ResetCamera(thing->player, &camera[i]); - R_ResetViewInterpolation(i + 1); break; } @@ -159,16 +157,14 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle // move chasecam at new player location for (i = 0; i <= splitscreen; i++) { - if (thing->player != &players[displayplayers[i]]) - continue; - - localangle[i] = angle; - - if (camera[i].chase) - P_ResetCamera(thing->player, &camera[i]); - - R_ResetViewInterpolation(i + 1); - break; + if (thing->player == &players[displayplayers[i]]) + { + localangle[i] = angle; + if (camera[i].chase) + P_ResetCamera(thing->player, &camera[i]); + R_ResetViewInterpolation(i + 1); + break; + } } // don't run in place after a teleport diff --git a/src/p_tick.c b/src/p_tick.c index e9c550bc0..6416142ce 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -581,6 +581,13 @@ void P_Ticker(boolean run) if (playeringame[i]) ++players[i].jointime; + if (run) + { + // Update old view state BEFORE ticking so resetting + // the old interpolation state from game logic works. + R_UpdateViewInterpolation(); + } + if (objectplacing) { if (OP_FreezeObjectplace()) -- 2.54.0 From c35887f5ee44bccbb68a3e41118107f727114b23 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Jun 2024 12:52:09 +0200 Subject: [PATCH 075/525] Revert "fix some interpolation issues" This reverts commit e19f6f6656409b6a487dbb6f761ff3bc90daea33. --- src/g_game.c | 2 -- src/p_telept.c | 6 +----- src/p_tick.c | 8 +------- src/p_user.c | 1 + src/r_fps.c | 13 ++----------- 5 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 8352d0b98..aaa6b6fbe 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2117,8 +2117,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) { camerap = &camera[viewnum-1]; P_ResetCamera(&players[(*displayplayerp)], camerap); - - R_ResetViewInterpolation(viewnum); } if (viewnum > splits) diff --git a/src/p_telept.c b/src/p_telept.c index 9229079c9..7c9da2269 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -82,12 +82,8 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, // move chasecam at new player location for (i = 0; i <= splitscreen; i++) { - if (thing->player != &players[displayplayers[i]]) - continue; - if (camera[i].chase) + if (thing->player == &players[displayplayers[i]] && camera[i].chase) P_ResetCamera(thing->player, &camera[i]); - R_ResetViewInterpolation(i + 1); - break; } // don't run in place after a teleport diff --git a/src/p_tick.c b/src/p_tick.c index 6416142ce..183c42a4b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -581,13 +581,6 @@ void P_Ticker(boolean run) if (playeringame[i]) ++players[i].jointime; - if (run) - { - // Update old view state BEFORE ticking so resetting - // the old interpolation state from game logic works. - R_UpdateViewInterpolation(); - } - if (objectplacing) { if (OP_FreezeObjectplace()) @@ -834,6 +827,7 @@ void P_Ticker(boolean run) if (run) { R_UpdateLevelInterpolators(); + R_UpdateViewInterpolation(); // Hack: ensure newview is assigned every tic. // Ensures view interpolation is T-1 to T in poor network conditions diff --git a/src/p_user.c b/src/p_user.c index 3bee5abcd..de3ac7367 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3962,6 +3962,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { P_MoveChaseCamera(player, thiscam, false); R_ResetViewInterpolation(num + 1); + R_ResetViewInterpolation(num + 1); } return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); diff --git a/src/r_fps.c b/src/r_fps.c index 52a89098f..48990876a 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -23,8 +23,6 @@ #include "r_state.h" #include "z_zone.h" #include "console.h" // con_startup_loadprogress -#include "i_time.h" - #ifdef HWRENDER #include "hardware/hw_main.h" // for cv_grshearing #endif @@ -82,7 +80,6 @@ static viewvars_t skyview_old[MAXSPLITSCREENPLAYERS]; static viewvars_t skyview_new[MAXSPLITSCREENPLAYERS]; static viewvars_t *oldview = &pview_old[0]; -static tic_t last_view_update; static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; viewvars_t *newview = &pview_new[0]; @@ -203,27 +200,21 @@ void R_UpdateViewInterpolation(void) if (oldview_invalid[i]) oldview_invalid[i]--; } - - last_view_update = I_GetTime(); } void R_ResetViewInterpolation(UINT8 p) { - // Wait an extra tic if the interpolation state hasn't - // updated yet. - int t = last_view_update == I_GetTime() ? 1 : 2; - if (p == 0) { UINT8 i; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - oldview_invalid[i] = t; + oldview_invalid[i]++; } } else { - oldview_invalid[p - 1] = t; + oldview_invalid[p - 1]++; } } -- 2.54.0 From c13e780f2903a341014010e554ed36b38d16a009 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 20 Jun 2024 16:55:58 +0300 Subject: [PATCH 076/525] Try fix glib preallocating too much space for sound freeslots --- src/dehacked.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8b181a563..8c3d75db3 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9130,12 +9130,15 @@ int LUA_EnumLib(lua_State *L) char *str = NULL; int size = 0; + // Sound enum tables preallocated for sfx_freeslot0 elements because using NUMSFX may be too + // much if number of skins increased a lot (because of skinsound freeslots) + /* SFX (SFX_) */ lua_pushcfunction(L, lua_glib_new_enum); - lua_createtable(L, 0, NUMSFX); + lua_createtable(L, 0, sfx_freeslot0); for (int i = 0; i < NUMSFX; i++) { - if (!S_sfx[i].name) continue; + if (!S_sfx[i].name || !S_sfx[i].priority) continue; if (lua_enumlib_sprintf_upper(&str, &size, "SFX_%s", S_sfx[i].name) == NULL) return luaL_error(L, "Ran out of memory."); @@ -9150,10 +9153,10 @@ int LUA_EnumLib(lua_State *L) /* SFX (DS) */ lua_pushcfunction(L, lua_glib_new_enum); - lua_createtable(L, 0, NUMSFX); + lua_createtable(L, 0, sfx_freeslot0); for (int i = 0; i < NUMSFX; i++) { - if (!S_sfx[i].name) continue; + if (!S_sfx[i].name || !S_sfx[i].priority) continue; if (lua_enumlib_sprintf_upper(&str, &size, "DS%s", S_sfx[i].name) == NULL) return luaL_error(L, "Ran out of memory."); @@ -9188,10 +9191,10 @@ int LUA_EnumLib(lua_State *L) { /* SFX (sfx_) */ lua_pushcfunction(L, lua_glib_new_enum); - lua_createtable(L, 0, NUMSFX); + lua_createtable(L, 0, sfx_freeslot0); for (int i = 0; i < NUMSFX; i++) { - if (!S_sfx[i].name) continue; + if (!S_sfx[i].name || !S_sfx[i].priority) continue; lua_pushfstring(L, "sfx_%s", S_sfx[i].name); lua_pushinteger(L, i); @@ -9422,4 +9425,4 @@ void LUA_SetActionByName(void *state, const char *actiontocompare) return; } } -} \ No newline at end of file +} -- 2.54.0 From 112716dae58ee75794948f456241795308ef3c26 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Jun 2024 17:11:20 +0200 Subject: [PATCH 077/525] Do not access memory on misaligned addresses https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2438 --- src/byteptr.h | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/byteptr.h b/src/byteptr.h index 9756e7d95..0b3935e63 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -11,17 +11,12 @@ /// \brief Macros to read/write from/to a UINT8 *, /// used for packet creation and such -#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__) -#define DEALIGNED -#endif - #include "endian.h" #ifndef SRB2_BIG_ENDIAN // // Little-endian machines // -#ifdef DEALIGNED #define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0) @@ -31,20 +26,8 @@ #define WRITECHAR(p,b) do { char *p_tmp = (void *)p; const char tv = ( char)(b); memcpy(p, &tv, sizeof( char)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEFIXED(p,b) do { fixed_t *p_tmp = (void *)p; const fixed_t tv = (fixed_t)(b); memcpy(p, &tv, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEANGLE(p,b) do { angle_t *p_tmp = (void *)p; const angle_t tv = (angle_t)(b); memcpy(p, &tv, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; } while (0) -#else -#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) -#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) -#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) -#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) -#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) -#define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) -#define WRITECHAR(p,b) do { char *p_tmp = ( char *)p; *p_tmp = ( char)(b); p_tmp++; p = (void *)p_tmp; } while (0) -#define WRITEFIXED(p,b) do { fixed_t *p_tmp = (fixed_t *)p; *p_tmp = (fixed_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) -#define WRITEANGLE(p,b) do { angle_t *p_tmp = (angle_t *)p; *p_tmp = (angle_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) -#endif #ifdef __GNUC__ -#ifdef DEALIGNED #define READUINT8(p) ({ UINT8 *p_tmp = (void *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READSINT8(p) ({ SINT8 *p_tmp = (void *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READINT16(p) ({ INT16 *p_tmp = (void *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; b; }) @@ -55,17 +38,6 @@ #define READFIXED(p) ({ fixed_t *p_tmp = (void *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; b; }) #define READANGLE(p) ({ angle_t *p_tmp = (void *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; b; }) #else -#define READUINT8(p) ({ UINT8 *p_tmp = ( UINT8 *)p; UINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) -#define READSINT8(p) ({ SINT8 *p_tmp = ( SINT8 *)p; SINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) -#define READINT16(p) ({ INT16 *p_tmp = ( INT16 *)p; INT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) -#define READUINT16(p) ({ UINT16 *p_tmp = ( UINT16 *)p; UINT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) -#define READINT32(p) ({ INT32 *p_tmp = ( INT32 *)p; INT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) -#define READUINT32(p) ({ UINT32 *p_tmp = ( UINT32 *)p; UINT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) -#define READCHAR(p) ({ char *p_tmp = ( char *)p; char b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) -#define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) -#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) -#endif -#else #define READUINT8(p) *(( UINT8 *)p)++ #define READSINT8(p) *(( SINT8 *)p)++ #define READINT16(p) *(( INT16 *)p)++ @@ -148,8 +120,6 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = readulong(p); p_tmp++; p = (void *)p_tmp; b; }) #endif //SRB2_BIG_ENDIAN -#undef DEALIGNED - #define WRITESTRINGN(p, s, n) ({ \ size_t tmp_i; \ \ -- 2.54.0 From 2e7cd51ff8718751fe05081285305c391342a450 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Jun 2024 02:42:49 +0200 Subject: [PATCH 078/525] limit localskins to 32 hope this doesent just die lol --- src/doomdef.h | 1 + src/hardware/hw_md2.c | 6 ++++-- src/hardware/hw_md2.h | 2 +- src/r_draw.c | 2 +- src/r_things.c | 14 ++++++++++---- src/r_things.h | 4 ++-- src/st_stuff.c | 12 ++++++------ src/st_stuff.h | 12 ++++++------ 8 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 2b5f93b19..c032ec77b 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -211,6 +211,7 @@ extern char logfilename[1024]; #define MAXPLAYERS 16 #define MAXSKINS 255 +#define MAXLOCALSKINS 32 #define PLAYERSMASK (MAXPLAYERS-1) #define MAXPLAYERNAME 21 diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 5818f01b2..0b43095da 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -75,7 +75,7 @@ md2_t md2_models[NUMSPRITES]; md2_t md2_playermodels[MAXSKINS]; -md2_t md2_localplayermodels[MAXSKINS]; +md2_t md2_localplayermodels[MAXLOCALSKINS]; /* @@ -494,7 +494,9 @@ void HWR_InitMD2(void) md2_playermodels[s].skin = -1; md2_playermodels[s].notfound = true; md2_playermodels[s].error = false; - + } + for (s = 0; s < MAXLOCALSKINS; s++) + { md2_localplayermodels[s].scale = -1.0f; md2_localplayermodels[s].model = NULL; md2_localplayermodels[s].grpatch = NULL; diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index a6f06428e..7b58a6f97 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -37,7 +37,7 @@ typedef struct extern md2_t md2_models[NUMSPRITES]; extern md2_t md2_playermodels[MAXSKINS]; -extern md2_t md2_localplayermodels[MAXSKINS]; +extern md2_t md2_localplayermodels[MAXLOCALSKINS]; void HWR_InitMD2(void); void HWR_DrawMD2(gr_vissprite_t *spr); diff --git a/src/r_draw.c b/src/r_draw.c index c19febc8a..fa19a6ac2 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -143,7 +143,7 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; #define NUM_PALETTE_ENTRIES 256 static UINT8** translationtablecache[TT_CACHE_SIZE] = {NULL}; -static UINT8** localtranslationtablecache[MAXSKINS] = {NULL}; +static UINT8** localtranslationtablecache[MAXLOCALSKINS] = {NULL}; // See also the enum skincolors_t diff --git a/src/r_things.c b/src/r_things.c index 87cbc33d6..2ed6e636b 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2936,14 +2936,14 @@ UINT8 skinstatscount[9][9] = { {0, 0, 0, 0, 0, 0, 0, 0, 0} }; UINT8 skinsorted[MAXSKINS]; -skin_t localskins[MAXSKINS]; -skin_t allskins[MAXSKINS*2]; +skin_t localskins[MAXLOCALSKINS]; +skin_t allskins[MAXSKINS+MAXLOCALSKINS]; // FIXTHIS: don't work because it must be inistilised before the config load //#define SKINVALUES #ifdef SKINVALUES CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; -CV_PossibleValue_t localskin_cons_t[MAXSKINS+1]; +CV_PossibleValue_t localskin_cons_t[MAXLOCALSKINS+1]; #endif static void Sk_SetDefaultValue(skin_t *skin, boolean local) @@ -3383,11 +3383,17 @@ void R_AddSkins(UINT16 wadnum, boolean local) // advance by default lastlump = lump + 1; - if (( (local) ? numlocalskins : numskins ) >= MAXSKINS) + if (numskins >= MAXSKINS) { CONS_Alert(CONS_WARNING, M_GetText("Unable to add skin, too many characters are loaded (%d maximum)\n"), MAXSKINS); continue; // so we know how many skins couldn't be added } + if (numlocalskins >= MAXLOCALSKINS) + { + CONS_Alert(CONS_WARNING, M_GetText("Unable to add localskin, too many localskins are loaded (%d maximum)\n"), MAXLOCALSKINS); + continue; // so we know how many skins couldn't be added + } + buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); size = W_LumpLengthPwad(wadnum, lump); diff --git a/src/r_things.h b/src/r_things.h index 5b74eea02..3e2414da1 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -220,8 +220,8 @@ extern UINT8 skinstatscount[9][9]; extern UINT8 skinsorted[MAXSKINS]; void sortSkinGrid(void); -extern skin_t localskins[MAXSKINS]; -extern skin_t allskins[MAXSKINS*2]; +extern skin_t localskins[MAXLOCALSKINS]; +extern skin_t allskins[MAXSKINS+MAXLOCALSKINS]; boolean SetPlayerSkin(INT32 playernum,const char *skinname); void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 diff --git a/src/st_stuff.c b/src/st_stuff.c index 3e64e6626..b78f47519 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -56,17 +56,17 @@ patch_t *facerankprefix[MAXSKINS]; // ranking patch_t *facewantprefix[MAXSKINS]; // wanted patch_t *facemmapprefix[MAXSKINS]; // minimap -patch_t *localfacerankprefix[MAXSKINS]; // ranking -patch_t *localfacewantprefix[MAXSKINS]; // wanted -patch_t *localfacemmapprefix[MAXSKINS]; // minimap +patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking +patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted +patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap char *facerankprefix_name[MAXSKINS]; // ranking char *facewantprefix_name[MAXSKINS]; // wanted char *facemmapprefix_name[MAXSKINS]; // minimap -char *localfacerankprefix_name[MAXSKINS]; // ranking -char *localfacewantprefix_name[MAXSKINS]; // wanted -char *localfacemmapprefix_name[MAXSKINS]; // minimap +char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking +char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted +char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap // ------------------------------------------ // status bar overlay diff --git a/src/st_stuff.h b/src/st_stuff.h index 46fcc4d67..0c3258d01 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -78,15 +78,15 @@ extern patch_t *sboperiod; extern patch_t *facerankprefix[MAXSKINS]; // ranking extern patch_t *facewantprefix[MAXSKINS]; // wanted extern patch_t *facemmapprefix[MAXSKINS]; // minimap -extern patch_t *localfacerankprefix[MAXSKINS]; // ranking -extern patch_t *localfacewantprefix[MAXSKINS]; // wanted -extern patch_t *localfacemmapprefix[MAXSKINS]; // minimap +extern patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking +extern patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted +extern patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap extern char *facerankprefix_name[MAXSKINS]; // ranking extern char *facewantprefix_name[MAXSKINS]; // wanted extern char *facemmapprefix_name[MAXSKINS]; // minimap -extern char *localfacerankprefix_name[MAXSKINS]; // ranking -extern char *localfacewantprefix_name[MAXSKINS]; // wanted -extern char *localfacemmapprefix_name[MAXSKINS]; // minimap +extern char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking +extern char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted +extern char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap extern patch_t *livesback; extern patch_t *ngradeletters[7]; -- 2.54.0 From 1a96d968372f3bb3d4d99c16e6a6f394b2f74a5a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Jun 2024 03:00:48 +0200 Subject: [PATCH 079/525] forgor this --- src/r_things.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/r_things.c b/src/r_things.c index 2ed6e636b..5ca80d2aa 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2995,6 +2995,9 @@ void R_InitSkins(void) { skin_cons_t[i].value = 0; skin_cons_t[i].strvalue = NULL; + } + for (i = 0; i <= MAXLOCALSKINS; i++) + { localskin_cons_t[i].value = 0; localskin_cons_t[i].strvalue = NULL; } -- 2.54.0 From ca58c1dee2ad8e79d70660dd2ab13c4a700a4bfd Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Jun 2024 16:22:13 +0200 Subject: [PATCH 080/525] these appear to be unused so comment them out dont need 6 arrays being allocated with MAXSKINS for nothing lul --- src/st_stuff.c | 22 +++++++++++----------- src/st_stuff.h | 14 +++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index b78f47519..765f235d2 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -56,17 +56,17 @@ patch_t *facerankprefix[MAXSKINS]; // ranking patch_t *facewantprefix[MAXSKINS]; // wanted patch_t *facemmapprefix[MAXSKINS]; // minimap -patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking -patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted -patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap +patch_t *localfacerankprefix[MAXSKINS]; // ranking +patch_t *localfacewantprefix[MAXSKINS]; // wanted +patch_t *localfacemmapprefix[MAXSKINS]; // minimap -char *facerankprefix_name[MAXSKINS]; // ranking +/*char *facerankprefix_name[MAXSKINS]; // ranking char *facewantprefix_name[MAXSKINS]; // wanted char *facemmapprefix_name[MAXSKINS]; // minimap -char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking -char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted -char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap +char *localfacerankprefix_name[MAXSKINS]; // ranking +char *localfacewantprefix_name[MAXSKINS]; // wanted +char *localfacemmapprefix_name[MAXSKINS]; // minimap*/ // ------------------------------------------ // status bar overlay @@ -395,9 +395,9 @@ void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skin facewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX); facemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX); - facerankprefix_name[skinnum] = rankstr; + /*facerankprefix_name[skinnum] = rankstr; facewantprefix_name[skinnum] = wantstr; - facemmapprefix_name[skinnum] = mmapstr; + facemmapprefix_name[skinnum] = mmapstr;*/ } void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 skinnum) @@ -406,9 +406,9 @@ void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 localfacewantprefix[skinnum] = W_CachePatchName(wantstr, PU_HUDGFX); localfacemmapprefix[skinnum] = W_CachePatchName(mmapstr, PU_HUDGFX); - localfacerankprefix_name[skinnum] = rankstr; + /*localfacerankprefix_name[skinnum] = rankstr; localfacewantprefix_name[skinnum] = wantstr; - localfacemmapprefix_name[skinnum] = mmapstr; + localfacemmapprefix_name[skinnum] = mmapstr;*/ //CONS_Printf("Added rank prefix %s\n", rankstr); //CONS_Printf("Added want prefix %s\n", wantstr); diff --git a/src/st_stuff.h b/src/st_stuff.h index 0c3258d01..6809f90fc 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -78,15 +78,15 @@ extern patch_t *sboperiod; extern patch_t *facerankprefix[MAXSKINS]; // ranking extern patch_t *facewantprefix[MAXSKINS]; // wanted extern patch_t *facemmapprefix[MAXSKINS]; // minimap -extern patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking -extern patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted -extern patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap -extern char *facerankprefix_name[MAXSKINS]; // ranking +extern patch_t *localfacerankprefix[MAXSKINS]; // ranking +extern patch_t *localfacewantprefix[MAXSKINS]; // wanted +extern patch_t *localfacemmapprefix[MAXSKINS]; // minimap +/*extern char *facerankprefix_name[MAXSKINS]; // ranking extern char *facewantprefix_name[MAXSKINS]; // wanted extern char *facemmapprefix_name[MAXSKINS]; // minimap -extern char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking -extern char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted -extern char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap +extern char *localfacerankprefix_name[MAXSKINS]; // ranking +extern char *localfacewantprefix_name[MAXSKINS]; // wanted +extern char *localfacemmapprefix_name[MAXSKINS]; // minimap*/ extern patch_t *livesback; extern patch_t *ngradeletters[7]; -- 2.54.0 From 3d5e03315891ce020b2966f16df2d94e34b40eb3 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Jun 2024 21:13:50 +0200 Subject: [PATCH 081/525] oops --- src/st_stuff.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 765f235d2..681f2d920 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -56,17 +56,17 @@ patch_t *facerankprefix[MAXSKINS]; // ranking patch_t *facewantprefix[MAXSKINS]; // wanted patch_t *facemmapprefix[MAXSKINS]; // minimap -patch_t *localfacerankprefix[MAXSKINS]; // ranking -patch_t *localfacewantprefix[MAXSKINS]; // wanted -patch_t *localfacemmapprefix[MAXSKINS]; // minimap +patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking +patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted +patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap /*char *facerankprefix_name[MAXSKINS]; // ranking char *facewantprefix_name[MAXSKINS]; // wanted char *facemmapprefix_name[MAXSKINS]; // minimap -char *localfacerankprefix_name[MAXSKINS]; // ranking -char *localfacewantprefix_name[MAXSKINS]; // wanted -char *localfacemmapprefix_name[MAXSKINS]; // minimap*/ +char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking +char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted +char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap*/ // ------------------------------------------ // status bar overlay -- 2.54.0 From 74ce725e3de5c2d8f69857a13a14f592fcaa9adf Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 20 Jun 2024 21:16:04 +0200 Subject: [PATCH 082/525] oops 2 --- src/st_stuff.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/st_stuff.h b/src/st_stuff.h index 6809f90fc..250db1e7f 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -78,15 +78,15 @@ extern patch_t *sboperiod; extern patch_t *facerankprefix[MAXSKINS]; // ranking extern patch_t *facewantprefix[MAXSKINS]; // wanted extern patch_t *facemmapprefix[MAXSKINS]; // minimap -extern patch_t *localfacerankprefix[MAXSKINS]; // ranking -extern patch_t *localfacewantprefix[MAXSKINS]; // wanted -extern patch_t *localfacemmapprefix[MAXSKINS]; // minimap +extern patch_t *localfacerankprefix[MAXLOCALSKINS]; // ranking +extern patch_t *localfacewantprefix[MAXLOCALSKINS]; // wanted +extern patch_t *localfacemmapprefix[MAXLOCALSKINS]; // minimap /*extern char *facerankprefix_name[MAXSKINS]; // ranking extern char *facewantprefix_name[MAXSKINS]; // wanted extern char *facemmapprefix_name[MAXSKINS]; // minimap -extern char *localfacerankprefix_name[MAXSKINS]; // ranking -extern char *localfacewantprefix_name[MAXSKINS]; // wanted -extern char *localfacemmapprefix_name[MAXSKINS]; // minimap*/ +extern char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking +extern char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted +extern char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap*/ extern patch_t *livesback; extern patch_t *ngradeletters[7]; -- 2.54.0 From b19935416730e2d9462a841f67b70a7ea0ca2691 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 22 Jun 2024 03:43:11 +0200 Subject: [PATCH 083/525] this should be called on mapload --- src/p_setup.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index c99326116..4d6988e65 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3034,7 +3034,12 @@ boolean P_SetupLevel(boolean skipprecip) #ifdef HWRENDER // not win32 only 19990829 by Kin if (rendermode == render_opengl) + { + HWR_FreeExtraSubsectors(); + + // stuff like HWR_CreatePlanePolygons is called there HWR_LoadLevel(); + } #endif // oh god I hope this helps -- 2.54.0 From 9c5a0ed7ee455a28a067c83a6b730ac1a2b8af80 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 22 Jun 2024 07:14:33 +0200 Subject: [PATCH 084/525] move HWR_LoadLevel to hw_main --- src/hardware/hw_main.c | 19 +++++++++++++++++++ src/p_setup.c | 11 ----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1cba83059..5369c51a3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5960,6 +5960,25 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) HWR_RenderFrame(viewnumber, player, false); } +void HWR_LoadLevel(void) +{ + // Lactozilla (December 8, 2019) + // Level setup used to free EVERY mipmap from memory. + // Even mipmaps that aren't related to level textures. + // Presumably, the hardware render code used to store textures as level data. + // Meaning, they had memory allocated and marked with the PU_LEVEL tag. + // Level textures are only reloaded after R_LoadTextures, which is + // when the texture list is loaded. + + // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. + HWR_FreeMipmapCache(); + + HWR_CreatePlanePolygons((INT32)numnodes - 1); + + if (HWR_ShouldUsePaletteRendering()) + HWR_SetMapPalette(); +} + // enable or disable palette rendering state depending on settings and availability // called when relevant settings change // shader recompilation is done in the cvar callback diff --git a/src/p_setup.c b/src/p_setup.c index 4d6988e65..fbfde84a0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3308,17 +3308,6 @@ boolean P_SetupLevel(boolean skipprecip) return true; } -#ifdef HWRENDER -void HWR_LoadLevel(void) -{ - HWR_FreeMipmapCache(); - HWR_CreatePlanePolygons((INT32)numnodes - 1); - - if (HWR_ShouldUsePaletteRendering()) - HWR_SetMapPalette(); -} -#endif - // // P_RunSOC // -- 2.54.0 From 06248e5388226fd511023d23d73eb0cc27265b7b Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Sat, 22 Jun 2024 19:16:01 -0400 Subject: [PATCH 085/525] Linux customshader compilation fix https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2418/ --- src/hardware/hw_shaders.c | 101 +++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index efebecc18..6757d6fe4 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -446,6 +446,101 @@ void HWR_LoadAllCustomShaders(void) HWR_LoadCustomShadersFromFile(i, W_FileHasFolders(wadfiles[i])); } +static const char version_directives[][14] = { + "#version 330\n", + "#version 150\n", + "#version 140\n", + "#version 130\n", + "#version 120\n", + "#version 110\n", +}; + +static boolean HWR_VersionDirectiveExists(const char* source) +{ + return strncmp(source, "#version", 8) == 0; +} + +static char* HWR_PrependVersionDirective(const char* source, UINT32 version_index) +{ + const UINT32 version_len = sizeof(version_directives[version_index]) - 1; + const UINT32 source_len = strlen(source); + + char* result = Z_Malloc(source_len + version_len + 1, PU_STATIC, NULL); + strcpy(result, version_directives[version_index]); + strcpy(result + version_len, source); + + return result; +} + +static void HWR_ReplaceVersionInplace(char* shader, UINT32 version_index) +{ + shader[9] = version_directives[version_index][9]; + shader[10] = version_directives[version_index][10]; + shader[11] = version_directives[version_index][11]; +} + +static boolean HWR_CheckVersionDirectives(const char* vert, const char* frag) +{ + return HWR_VersionDirectiveExists(vert) && HWR_VersionDirectiveExists(frag); +} + +static void HWR_TryToCompileShaderWithImplicitVersion(INT32 shader_index, INT32 shaderxlat_id) +{ + char* vert_shader = gl_shaders[shader_index].vertex; + char* frag_shader = gl_shaders[shader_index].fragment; + + boolean vert_shader_version_exists = HWR_VersionDirectiveExists(vert_shader); + boolean frag_shader_version_exists = HWR_VersionDirectiveExists(frag_shader); + + if(!vert_shader_version_exists) { + CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: vertex shader '%s' is missing a #version directive\n", HWR_GetShaderName(shaderxlat_id)); + } + + if(!frag_shader_version_exists) { + CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: fragment shader '%s' is missing a #version directive\n", HWR_GetShaderName(shaderxlat_id)); + } + + // try to compile as is + HWR_CompileShader(shader_index); + if (gl_shaders[shader_index].compiled) + return; + + // try each version directive + for(UINT32 i = 0; i < sizeof(version_directives) / sizeof(version_directives[0]); ++i) { + CONS_Alert(CONS_NOTICE, "HWR_TryToCompileShaderWithImplicitVersion: Trying %s\n", version_directives[i]); + + if(!vert_shader_version_exists) { + // first time reallocation would have to be made + + if(i == 0) { + void* old = (void*)gl_shaders[shader_index].vertex; + vert_shader = gl_shaders[shader_index].vertex = HWR_PrependVersionDirective(vert_shader, i); + Z_Free(old); + } else { + HWR_ReplaceVersionInplace(vert_shader, i); + } + } + + if(!frag_shader_version_exists) { + if(i == 0) { + void* old = (void*)gl_shaders[shader_index].fragment; + frag_shader = gl_shaders[shader_index].fragment = HWR_PrependVersionDirective(frag_shader, i); + Z_Free(old); + } else { + HWR_ReplaceVersionInplace(frag_shader, i); + } + } + + HWR_CompileShader(shader_index); + if (gl_shaders[shader_index].compiled) { + CONS_Alert(CONS_NOTICE, "HWR_TryToCompileShaderWithImplicitVersion: Compiled with %s\n", + version_directives[i]); + CONS_Alert(CONS_WARNING, "Implicit GLSL version is used. Correct behavior is not guaranteed\n"); + return; + } + } +} + void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) { UINT16 lump; @@ -608,7 +703,11 @@ skip_field: gl_shaders[shader_index].fragment = Z_StrDup(gl_shadersources[i].fragment); if (!gl_shaders[shader_index].vertex) gl_shaders[shader_index].vertex = Z_StrDup(gl_shadersources[i].vertex); - HWR_CompileShader(shader_index); + if(!HWR_CheckVersionDirectives(gl_shaders[shader_index].vertex, gl_shaders[shader_index].fragment)) { + HWR_TryToCompileShaderWithImplicitVersion(shader_index, i); + } else { + HWR_CompileShader(shader_index); + } if (!gl_shaders[shader_index].compiled) CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: A compilation error occured for the %s shader in file %s. See the console messages above for more information.\n", shaderxlat[i].type, wadfiles[wadnum]->filename); } -- 2.54.0 From 0bd5ca5e3fb8a1e7a79aeb42f696a28f374ddab0 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Sat, 22 Jun 2024 19:21:21 -0400 Subject: [PATCH 086/525] Allow Users to Connect to Servers While In-Game https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2401/ --- src/d_clisrv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 69c87a157..5d5c2d28d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -23,6 +23,7 @@ #include "d_netfil.h" // fileneedednum #include "d_main.h" #include "g_game.h" +#include "m_menu.h" // M_ClearMenus #include "hu_stuff.h" #include "keys.h" #include "g_input.h" // JOY1 @@ -3046,8 +3047,17 @@ static void Command_connect(void) if (Playing() || demo.title) { - CONS_Printf(M_GetText("You cannot connect while in a game. End this game first.\n")); - return; + M_ClearMenus(true); + if (demo.title) + G_CheckDemoStatus(); + + if (netgame) + { + D_QuitNetGame(); + CL_Reset(); + } + + D_StartTitle(); } // modified game check: no longer handled -- 2.54.0 From d449a1b7141e8f71530c368d615cad0bc4117f38 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Jun 2024 13:39:33 +0200 Subject: [PATCH 087/525] remove this again --- src/p_user.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index de3ac7367..bd13b9852 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1195,9 +1195,6 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) { mobj_t *ghost; - if (!mobj || P_MobjWasRemoved(mobj)) - return NULL; - ghost = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_GHOST); P_SetScale(ghost, mobj->scale); -- 2.54.0 From ec2fd5b38f3a574d3c4d0a4039e03fa19a2848bc Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 30 Jun 2024 06:45:48 +0200 Subject: [PATCH 088/525] prevent crash in hw bsp --- src/hardware/hw_bsp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 91759c819..a5f76df06 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -667,9 +667,15 @@ static boolean PointInSeg(polyvertex_t *a,polyvertex_t *v1,polyvertex_t *v2) // v1 = origine ax= v2->x-v1->x; ay= v2->y-v1->y; - norm = (float)hypot(ax, ay); - ax /= norm; - ay /= norm; + norm = hypotf(ax, ay); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfloat-equal" + if (norm != 0) // yes, this can be exactly 0 +#pragma GCC diagnostic pop + { + ax /= norm; + ay /= norm; + } bx = a->x-v1->x; by = a->y-v1->y; //d = a.b -- 2.54.0 From 008a9b9b3f11b5fc8a6d32649627c468e8a89bf4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 30 Jun 2024 06:46:12 +0200 Subject: [PATCH 089/525] optimize ogl polyobjs slightly --- src/hardware/hw_main.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5369c51a3..c12261aac 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2854,9 +2854,6 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) void HWR_AddPolyObjectSegs(void) { size_t i, j; - seg_t gr_fakeline; - polyvertex_t pv1; - polyvertex_t pv2; // Sort through all the polyobjects for (i = 0; i < numpolys; ++i) @@ -2864,19 +2861,7 @@ void HWR_AddPolyObjectSegs(void) // Render the polyobject's lines for (j = 0; j < po_ptrs[i]->segCount; ++j) { - // Copy the info of a polyobject's seg, then convert it to OpenGL floating point - M_Memcpy(&gr_fakeline, po_ptrs[i]->segs[j], sizeof(seg_t)); - - // Now convert the line to float and add it to be rendered - pv1.x = FIXED_TO_FLOAT(gr_fakeline.v1->x); - pv1.y = FIXED_TO_FLOAT(gr_fakeline.v1->y); - pv2.x = FIXED_TO_FLOAT(gr_fakeline.v2->x); - pv2.y = FIXED_TO_FLOAT(gr_fakeline.v2->y); - - gr_fakeline.pv1 = &pv1; - gr_fakeline.pv2 = &pv2; - - HWR_AddLine(&gr_fakeline); + HWR_AddLine(po_ptrs[i]->segs[j]); } } } -- 2.54.0 From 266f5149b52e4de48be7043028516469a25a1c26 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 12:58:40 +0200 Subject: [PATCH 090/525] smoller opitmizations --- src/hardware/hw_main.c | 81 ++++++++++++++++++++++-------------------- src/r_things.c | 37 +++++++++---------- 2 files changed, 61 insertions(+), 57 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c12261aac..55a9ad485 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2107,20 +2107,20 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom INT32 texnum; line_t * newline = NULL; // Multi-Property FOF - if (!cv_grfofcut.value) - { - ///TODO add slope support (fixing cutoffs, proper wall clipping) - maybe just disable highcut/lowcut if either sector or FOF has a slope - /// to allow fun plane intersecting in OGL? But then people would abuse that and make software look bad. :C - highcut = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight; - lowcut = gr_frontsector->floorheight > gr_backsector->floorheight ? gr_frontsector->floorheight : gr_backsector->floorheight; - } - else + if (cv_grfofcut.value) { lowcut = max(worldbottom, worldlow); highcut = min(worldtop, worldhigh); lowcutslope = max(worldbottomslope, worldlowslope); highcutslope = min(worldtopslope, worldhighslope); } + else + { + ///TODO add slope support (fixing cutoffs, proper wall clipping) - maybe just disable highcut/lowcut if either sector or FOF has a slope + /// to allow fun plane intersecting in OGL? But then people would abuse that and make software look bad. :C + highcut = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight; + lowcut = gr_frontsector->floorheight > gr_backsector->floorheight ? gr_frontsector->floorheight : gr_backsector->floorheight; + } if (gr_backsector->ffloors) { @@ -2129,12 +2129,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || (rover->flags & FF_INVERTSIDES)) continue; - if (!cv_grfofcut.value) - { - if (*rover->topheight < lowcut || *rover->bottomheight > highcut) - continue; - } - else + if (cv_grfofcut.value) { SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) @@ -2142,6 +2137,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; } + else + { + if (*rover->topheight < lowcut || *rover->bottomheight > highcut) + continue; + } texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -2157,14 +2157,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom l = P_GetFFloorBottomZAt(rover, v1x, v1y); lS = P_GetFFloorBottomZAt(rover, v2x, v2y); - if (!cv_grfofcut.value) - { - if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) - h = hS = highcut; - if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut) - l = lS = lowcut; - } - else + if (cv_grfofcut.value) { // Adjust the heights so the FOF does not overlap with top and bottom textures. if (h >= highcut && hS >= highcutslope) @@ -2178,6 +2171,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lS = lowcutslope; } } + else + { + if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) + h = hS = highcut; + if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut) + l = lS = lowcut; + } //Hurdler: HW code starts here //FIXME: check if peging is correct @@ -2258,7 +2258,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); - }else{ + } + else + { lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = rover->master->frontsector->extra_colormap; } @@ -2300,12 +2302,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_ALLSIDES)) continue; - if (!cv_grfofcut.value) - { - if (*rover->topheight < lowcut || *rover->bottomheight > highcut) - continue; - } - else + if (cv_grfofcut.value) { SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) @@ -2313,7 +2310,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; } - + else + { + if (*rover->topheight < lowcut || *rover->bottomheight > highcut) + continue; + } texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -2329,14 +2330,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom l = P_GetFFloorBottomZAt(rover, v1x, v1y); lS = P_GetFFloorBottomZAt(rover, v2x, v2y); - if (!cv_grfofcut.value) - { - if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) - h = hS = highcut; - if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut) - l = lS = lowcut; - } - else + if (cv_grfofcut.value) { // Adjust the heights so the FOF does not overlap with top and bottom textures. if (h >= highcut && hS >= highcutslope) @@ -2350,6 +2344,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lS = lowcutslope; } } + else + { + if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) + h = hS = highcut; + if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut) + l = lS = lowcut; + } //Hurdler: HW code starts here //FIXME: check if peging is correct @@ -2397,7 +2398,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); - }else{ + } + else + { lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = rover->master->frontsector->extra_colormap; } diff --git a/src/r_things.c b/src/r_things.c index 5ca80d2aa..372ddb964 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -628,7 +628,7 @@ void R_DrawMaskedColumn(column_t *column) if (dc_yh >= vid.height) dc_yh = vid.height - 1; - if (dc_yl <= dc_yh && dc_yl < vid.height && dc_yh > 0) + if (dc_yl <= dc_yh && dc_yh > 0) { dc_source = (UINT8 *)column + 3; dc_texturemid = basetexturemid - (topdelta<length : for flipped column function pointers and multi-patch on 2sided wall = texture->height + +static void R_DrawFlippedMaskedColumn(column_t *column) { INT32 topscreen; INT32 bottomscreen; @@ -662,11 +664,10 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) if (topdelta <= prevdelta) topdelta += prevdelta; prevdelta = topdelta; - topdelta = texheight-column->length-topdelta; + topdelta = lengthcol-column->length-topdelta; topscreen = sprtopscreen + spryscale*topdelta; bottomscreen = sprbotscreen == INT32_MAX ? topscreen + spryscale*column->length : sprbotscreen + spryscale*column->length; - dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; dc_yh = (bottomscreen-1)>>FRACBITS; @@ -687,7 +688,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) if (dc_yh >= vid.height) dc_yh = vid.height - 1; - if (dc_yl <= dc_yh && dc_yl < vid.height && dc_yh > 0) + if (dc_yl <= dc_yh && dc_yh > 0) { dc_source = ZZ_Alloc(column->length); for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s) @@ -712,7 +713,9 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) static void R_DrawVisSprite(vissprite_t *vis) { column_t *column; + void (*localcolfunc)(column_t *); INT32 texturecolumn; + INT32 pwidth; fixed_t frac; patch_t *patch = vis->patch; fixed_t this_scale = vis->thingscale; @@ -856,11 +859,15 @@ static void R_DrawVisSprite(vissprite_t *vis) vis->x2 -= temp; } + localcolfunc = (vis->vflip) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn; + lengthcol = patch->height; + // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) { fixed_t horzscale = FixedMul(vis->spritexscale, this_scale); fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); + pwidth = SHORT(patch->width); // Papersprite drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep) @@ -868,37 +875,31 @@ static void R_DrawVisSprite(vissprite_t *vis) angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF; texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale; - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) + if (texturecolumn < 0 || texturecolumn >= pwidth) continue; if (vis->xiscale < 0) // Flipped sprite - texturecolumn = SHORT(patch->width) - 1 - texturecolumn; + texturecolumn = pwidth - 1 - texturecolumn; sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); dc_iscale = (0xffffffffu / (unsigned)spryscale); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); - if (vis->vflip) - R_DrawFlippedMaskedColumn(column, patch->height); - else - R_DrawMaskedColumn(column); + localcolfunc (column); } } else { + pwidth = SHORT(patch->width); + // Non-paper drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) { -#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) - texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); -#undef CLAMP + texturecolumn = CLAMP(frac >> FRACBITS, 0, pwidth - 1); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); - if (vis->vflip) - R_DrawFlippedMaskedColumn(column, patch->height); - else - R_DrawMaskedColumn(column); + localcolfunc (column); } } -- 2.54.0 From 09746257694a211188a49803392a042aaa1003ec Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 30 Jun 2024 10:04:22 +0200 Subject: [PATCH 091/525] no need for this --- src/hardware/hw_main.c | 101 +++++++++++------------------------------ 1 file changed, 26 insertions(+), 75 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 55a9ad485..edeb4ad1e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -54,6 +54,8 @@ #define SOFTLIGHT(llevel) HWR_ShouldUsePaletteRendering() ? ((llevel) >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : (llevel) +#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) + // ========================================================================== // the hardware driver object // ========================================================================== @@ -558,12 +560,8 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if else { light = light - (255 - light); - // Don't go out of bounds - if (light < 0) - light = 0; - else if (light > 255) - light = 255; + light = CLAMP(light, 0, 255); alpha = (realcolor.s.alpha*255)/25; @@ -602,11 +600,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t if (extralight != 0) { finallight += extralight; - - if (finallight < 0) - finallight = 0; - if (finallight > 255) - finallight = 255; + finallight = CLAMP(finallight, 0 , 255); } } @@ -646,11 +640,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta) if (extralight != 0) { finallight += extralight; - - if (finallight < 0) - finallight = 0; - if (finallight > 255) - finallight = 255; + finallight = CLAMP(finallight, 0 , 255); } } @@ -1135,27 +1125,15 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { if (pfloor && (pfloor->flags & FF_FOG)) { - if (HWR_ShouldUsePaletteRendering()) - { - lightnum = pfloor->master->frontsector->lightlevel; - colormap = pfloor->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); - }else{ - lightnum = HWR_CalcWallLight(pfloor->master->frontsector->lightlevel, v1x, v1y, v2x, v2y); - colormap = pfloor->master->frontsector->extra_colormap; - } + lightnum = pfloor->master->frontsector->lightlevel; + colormap = pfloor->master->frontsector->extra_colormap; + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); } else { - if (HWR_ShouldUsePaletteRendering()) - { - lightnum = *list[i].lightlevel; - colormap = list[i].extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); - }else{ - lightnum = HWR_CalcWallLight(*list[i].lightlevel, v1x, v1y, v2x, v2y); - colormap = list[i].extra_colormap; - } + lightnum = *list[i].lightlevel; + colormap = list[i].extra_colormap; + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); } } @@ -1522,17 +1500,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom cliplow = (float)texturehpeg; cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); - if (HWR_ShouldUsePaletteRendering()) - { - lightnum = gr_frontsector->lightlevel; - colormap = gr_frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); - } - else - { - lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); - colormap = gr_frontsector->extra_colormap; - } + lightnum = gr_frontsector->lightlevel; + colormap = gr_frontsector->extra_colormap; + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); if (gr_linedef->flags & ML_TFERLINE) noencore = true; @@ -2253,18 +2223,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode = PF_Fog|PF_NoTexture; - if (HWR_ShouldUsePaletteRendering()) - { - lightnum = rover->master->frontsector->lightlevel; - colormap = rover->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); - } - else - { - lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); - colormap = rover->master->frontsector->extra_colormap; - } - + lightnum = rover->master->frontsector->lightlevel; + colormap = rover->master->frontsector->extra_colormap; + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); + Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gr_frontsector->numlights) @@ -2393,17 +2355,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode = PF_Fog|PF_NoTexture; - if (HWR_ShouldUsePaletteRendering()) - { - lightnum = rover->master->frontsector->lightlevel; - colormap = rover->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); - } - else - { - lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); - colormap = rover->master->frontsector->extra_colormap; - } + lightnum = rover->master->frontsector->lightlevel; + colormap = rover->master->frontsector->extra_colormap; + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); @@ -4568,10 +4522,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean planeinfo->isceiling = isceiling; planeinfo->fixedheight = fixedheight; - if (HWR_ShouldUsePaletteRendering()) - planeinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel; - else - planeinfo->lightlevel = lightlevel; + planeinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel; planeinfo->lumpnum = lumpnum; planeinfo->xsub = xsub; @@ -4591,10 +4542,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, polyplaneinfo->isceiling = isceiling; polyplaneinfo->fixedheight = fixedheight; - if (HWR_ShouldUsePaletteRendering()) - polyplaneinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel; - else - polyplaneinfo->lightlevel = lightlevel; + polyplaneinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel; polyplaneinfo->lumpnum = lumpnum; polyplaneinfo->polysector = polysector; @@ -6307,4 +6255,7 @@ void HWR_DrawScreenFinalTexture(INT32 width, INT32 height) { HWD.pfnDrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height); } + +#undef CLAMP + #endif // HWRENDER -- 2.54.0 From 31b7482c3aaaa889c3bc91ff00c1d0ad86b87f95 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 30 Jun 2024 18:31:31 +0200 Subject: [PATCH 092/525] small optimization to batching --- src/hardware/hw_batching.c | 58 ++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index e0afb6054..f23505bd1 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -35,7 +35,7 @@ int finalVertexArrayAllocSize = 65536; PolygonArrayEntry* polygonArray = NULL;// contains the polygon data from DrawPolygon, waiting to be processed int polygonArraySize = 0; -UINT32* polygonIndexArray = NULL;// contains sorting pointers for polygonArray +PolygonArrayEntry **polygonArraySorted = NULL;// contains sorted pointers to polygonArray int polygonArrayAllocSize = 65536; FOutVector* unsortedVertexArray = NULL;// contains unsorted vertices and texture coordinates from DrawPolygon @@ -55,7 +55,7 @@ void HWR_StartBatching(void) finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector)); finalVertexIndexArray = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32)); polygonArray = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry)); - polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32)); + polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *)); unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector)); } @@ -96,8 +96,8 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt free(polygonArray); polygonArray = new_array; // also need to redo the index array, dont need to copy it though - free(polygonIndexArray); - polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32)); + free(polygonArraySorted); + polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *)); } while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize) @@ -134,10 +134,8 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt static int comparePolygons(const void *p1, const void *p2) { - unsigned int index1 = *(const unsigned int*)p1; - unsigned int index2 = *(const unsigned int*)p2; - PolygonArrayEntry* poly1 = &polygonArray[index1]; - PolygonArrayEntry* poly2 = &polygonArray[index2]; + PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1; + PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; int diff; INT64 diff64; UINT32 downloaded1 = 0; @@ -155,7 +153,7 @@ static int comparePolygons(const void *p1, const void *p2) // skywalls and horizon lines must retain their order for horizon lines to work if (shader1 == -1 && shader2 == -1) - return index1 - index2; + return poly1 - poly2; if (poly1->texture) downloaded1 = poly1->texture->downloaded; // there should be a opengl texture name here, usable for comparisons @@ -184,10 +182,8 @@ static int comparePolygons(const void *p1, const void *p2) static int comparePolygonsNoShaders(const void *p1, const void *p2) { - unsigned int index1 = *(const unsigned int*)p1; - unsigned int index2 = *(const unsigned int*)p2; - PolygonArrayEntry* poly1 = &polygonArray[index1]; - PolygonArrayEntry* poly2 = &polygonArray[index2]; + PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1; + PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; int diff; INT64 diff64; @@ -205,7 +201,7 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2) downloaded2 = texture2->downloaded; // skywalls and horizon lines must retain their order for horizon lines to work if (!texture1 && !texture2) - return index1 - index2; + return poly1 - poly2; diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; @@ -225,7 +221,7 @@ void HWR_RenderBatches(void) int finalVertexWritePos = 0;// position in finalVertexArray int finalIndexWritePos = 0;// position in finalVertexIndexArray - int polygonReadPos = 0;// position in polygonIndexArray + int polygonReadPos = 0;// position in polygonArraySorted int currentShader; int nextShader = 0; @@ -258,18 +254,18 @@ void HWR_RenderBatches(void) ps_hw_numcalls.value.i = ps_hw_numverts.value.i = 0; ps_hw_numshaders.value.i = ps_hw_numtextures.value.i = ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1; - // init polygonIndexArray + // init polygonArraySorted for (i = 0; i < polygonArraySize; i++) { - polygonIndexArray[i] = i; + polygonArraySorted[i] = &polygonArray[i]; } // sort polygons PS_START_TIMING(ps_hw_batchsorttime); if (cv_grshaders.value && gr_shadersavailable) - qs22j(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons); + qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygons); else - qs22j(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders); + qs22j(polygonArraySorted, polygonArraySize, sizeof(PolygonArrayEntry *), comparePolygonsNoShaders); PS_STOP_TIMING(ps_hw_batchsorttime); // sort order // 1. shader @@ -280,10 +276,10 @@ void HWR_RenderBatches(void) PS_START_TIMING(ps_hw_batchdrawtime); - currentShader = polygonArray[polygonIndexArray[0]].shader; - currentTexture = polygonArray[polygonIndexArray[0]].texture; - currentPolyFlags = polygonArray[polygonIndexArray[0]].polyFlags; - currentSurfaceInfo = polygonArray[polygonIndexArray[0]].surf; + currentShader = polygonArraySorted[0]->shader; + currentTexture = polygonArraySorted[0]->texture; + currentPolyFlags = polygonArraySorted[0]->polyFlags; + currentSurfaceInfo = polygonArraySorted[0]->surf; // For now, will sort and track the colors. Vertex attributes could be used instead of uniforms // and a color array could replace the color calls. @@ -322,8 +318,8 @@ void HWR_RenderBatches(void) // reset write pos // repeat loop - int index = polygonIndexArray[polygonReadPos++]; - int numVerts = polygonArray[index].numVerts; + PolygonArrayEntry *entry = polygonArraySorted[polygonReadPos++]; + int numVerts = entry->numVerts; // before writing, check if there is enough room // using 'while' instead of 'if' here makes sure that there will *always* be enough room. // probably never will this loop run more than once though @@ -344,7 +340,7 @@ void HWR_RenderBatches(void) finalVertexIndexArray = new_index_array; } // write the vertices of the polygon - memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[polygonArray[index].vertsIndex], + memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[entry->vertsIndex], numVerts * sizeof(FOutVector)); // write the indexes, pointing to the fan vertexes but in triangles format firstIndex = finalVertexWritePos; @@ -364,11 +360,11 @@ void HWR_RenderBatches(void) else { // check if a state change is required, set the change bools and next vars - int nextIndex = polygonIndexArray[polygonReadPos]; - nextShader = polygonArray[nextIndex].shader; - nextTexture = polygonArray[nextIndex].texture; - nextPolyFlags = polygonArray[nextIndex].polyFlags; - nextSurfaceInfo = polygonArray[nextIndex].surf; + PolygonArrayEntry *nextEntry = polygonArraySorted[polygonReadPos]; + nextShader = nextEntry->shader; + nextTexture = nextEntry->texture; + nextPolyFlags = nextEntry->polyFlags; + nextSurfaceInfo = nextEntry->surf; if (nextPolyFlags & PF_NoTexture) nextTexture = 0; if (currentShader != nextShader && cv_grshaders.value && gr_shadersavailable) -- 2.54.0 From 2316c117b1d4ba4d38f877b2b705e4dd022323a9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Jul 2024 16:07:11 +0200 Subject: [PATCH 093/525] improve teleport interpolation stuff --- src/g_game.c | 11 ++++++++++- src/p_spec.c | 6 +----- src/p_telept.c | 23 ++++++++++++++--------- src/s_sound.c | 2 +- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index aaa6b6fbe..887fd8ffd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2108,7 +2108,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) olddisplayplayer = (*displayplayerp); /* Check if anyone is available to view. */ - if (( playernum = G_FindView(playernum, viewnum, onlyactive, playernum < olddisplayplayer) ) == -1) + if ((playernum = G_FindView(playernum, viewnum, onlyactive, playernum < olddisplayplayer)) == -1) return; /* Focus our target view first so that we don't take its player. */ @@ -2117,6 +2117,10 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) { camerap = &camera[viewnum-1]; P_ResetCamera(&players[(*displayplayerp)], camerap); + + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(viewnum); } if (viewnum > splits) @@ -2129,6 +2133,11 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = G_FindView(0, viewd, onlyactive, false); P_ResetCamera(&players[(*displayplayerp)], camerap); + + + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(viewd); } } diff --git a/src/p_spec.c b/src/p_spec.c index 9fb1953ee..ddf938330 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2371,11 +2371,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) y = sides[line->sidenum[0]].rowoffset; z = line->frontsector->ceilingheight; - P_UnsetThingPosition(mo); - mo->x += x; - mo->y += y; - mo->z += z; - P_SetThingPosition(mo); + P_SetOrigin(mo, mo->x + x, mo->y + y, mo->z + z); if (mo->player) { diff --git a/src/p_telept.c b/src/p_telept.c index 7c9da2269..a7cef7b1d 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -82,8 +82,13 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, // move chasecam at new player location for (i = 0; i <= splitscreen; i++) { - if (thing->player == &players[displayplayers[i]] && camera[i].chase) + if (thing->player != &players[displayplayers[i]]) + continue; + + if (camera[i].chase) P_ResetCamera(thing->player, &camera[i]); + + R_ResetViewInterpolation(i + 1); } // don't run in place after a teleport @@ -153,14 +158,14 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle // move chasecam at new player location for (i = 0; i <= splitscreen; i++) { - if (thing->player == &players[displayplayers[i]]) - { - localangle[i] = angle; - if (camera[i].chase) - P_ResetCamera(thing->player, &camera[i]); - R_ResetViewInterpolation(i + 1); - break; - } + if (thing->player != &players[displayplayers[i]]) + continue; + + localangle[i] = angle; + if (camera[i].chase) + P_ResetCamera(thing->player, &camera[i]); + + R_ResetViewInterpolation(i + 1); } // don't run in place after a teleport diff --git a/src/s_sound.c b/src/s_sound.c index 21d29b231..ae036a3db 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1996,7 +1996,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 strncpy(newmusic, mmusic, 6); - if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) + if (LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) return; // No Music (empty string) -- 2.54.0 From 7f34a1d83e52204cf337574ff66df27cbddb2524 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Jul 2024 20:54:34 +0200 Subject: [PATCH 094/525] add gr_lightdithering to shader mhhm dithering --- src/hardware/hw_main.c | 15 ++++++++++++ src/hardware/hw_main.h | 1 + src/hardware/hw_shaders.c | 7 ++++++ src/hardware/hw_shaders.h | 42 +++++++++++++++++++++++++++++--- src/hardware/r_opengl/r_opengl.c | 6 +++++ 5 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index edeb4ad1e..6c98c8c97 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -81,6 +81,8 @@ static void CV_grshaders_OnChange(void); static void CV_grpaletterendering_OnChange(void); static void CV_grpalettedepth_OnChange(void); +static void CV_grlightdithering_OnChange(void); + static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "Standard"}, {2, "Smooth"}, {0, NULL}}; static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"}, @@ -157,6 +159,8 @@ consvar_t cv_grpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, C static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 bits"}, {0, NULL}}; consvar_t cv_grpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_grpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_lightdither = {"gr_lightdithering", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_grlightdithering_OnChange, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_grflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_grpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grmdls = {"gr_mdls", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -217,6 +221,15 @@ static void CV_grpaletterendering_OnChange(void) } } +static void CV_grlightdithering_OnChange(void) +{ + ONLY_IF_GL_LOADED + if (gr_shadersavailable) + { + HWR_CompileShaders(); + } +} + static void CV_grpalettedepth_OnChange(void) { ONLY_IF_GL_LOADED @@ -5999,6 +6012,8 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grpalettedepth); CV_RegisterVar(&cv_grflashpal); + CV_RegisterVar(&cv_lightdither); + #ifdef USE_FBO_OGL CV_RegisterVar(&cv_grframebuffer); #endif diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 1c51e2981..b5a775365 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -179,6 +179,7 @@ extern consvar_t cv_grrenderdistance; extern consvar_t cv_grpaletterendering; extern consvar_t cv_grpalettedepth; extern consvar_t cv_grflashpal; +extern consvar_t cv_lightdither; extern consvar_t cv_grscreentextures; extern consvar_t cv_grportals; extern consvar_t cv_nostencil; diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 6757d6fe4..b58ca4137 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -82,6 +82,7 @@ static shadertarget_t gl_shadertargets[NUMSHADERTARGETS]; #define WHITESPACE_CHARS " \t" #define PALETTE_RENDERING_DEFINE "#define SRB2_PALETTE_RENDERING" +#define LIGHT_DITHERING_DEFINE "#define SRB2_LIGHT_DITHER" // Initialize shader variables and the backend's shader system. Load the base shaders. // Returns false if shaders cannot be used. @@ -282,6 +283,9 @@ static char *HWR_PreprocessShader(char *original) if (cv_grpaletterendering.value) ADD_TO_LEN(PALETTE_RENDERING_DEFINE) + if (cv_lightdither.value) + ADD_TO_LEN(LIGHT_DITHERING_DEFINE) + #undef ADD_TO_LEN #define VERSION_PART "#version " @@ -323,6 +327,9 @@ static char *HWR_PreprocessShader(char *original) if (cv_grpaletterendering.value) WRITE_DEFINE(PALETTE_RENDERING_DEFINE) + if (cv_lightdither.value) + WRITE_DEFINE(LIGHT_DITHERING_DEFINE) + #undef WRITE_DEFINE // Write a #line directive, so compiler errors will report line numbers from the diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 8f600fa79..6f3ef225e 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -51,15 +51,49 @@ // // 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 halfResolutionx = scr_resolution.x;\n" \ + "float halfResolutiony = scr_resolution.y;\n" \ + "if (scr_resolution.x > 1280.0) {\n" \ + " halfResolutionx = scr_resolution.x * 0.5;\n" \ + "}\n" \ + "if (scr_resolution.y > 720.0) {\n" \ + " halfResolutiony = scr_resolution.y * 0.5;\n" \ + "}\n" \ + "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ + "int x = int(mod(normalizedPosition.x, 8.0));\n" \ + "int y = int(mod(normalizedPosition.y, 8.0));\n" \ + "float bayerMatrix[8][8] = float[8][8](\n" \ + "float[8](0.0, 32.0, 8.0, 40.0, 2.0, 34.0, 10.0, 42.0),\n" \ + "float[8](48.0, 16.0, 56.0, 24.0, 50.0, 18.0, 58.0, 26.0),\n" \ + "float[8](12.0, 44.0, 4.0, 36.0, 14.0, 46.0, 6.0, 38.0),\n" \ + "float[8](60.0, 28.0, 52.0, 20.0, 62.0, 30.0, 54.0, 22.0),\n" \ + "float[8](3.0, 35.0, 11.0, 43.0, 1.0, 33.0, 9.0, 41.0),\n" \ + "float[8](51.0, 19.0, 59.0, 27.0, 49.0, 17.0, 57.0, 25.0),\n" \ + "float[8](15.0, 47.0, 7.0, 39.0, 13.0, 45.0, 5.0, 37.0),\n" \ + "float[8](63.0, 31.0, 55.0, 23.0, 61.0, 29.0, 53.0, 21.0)\n" \ + ");\n" \ + "float threshold = bayerMatrix[y][x] / 64.0;\n" \ + "return baseValue + threshold - 0.5 / 64.0;\n" \ + +#define GLSL_DOOM_COLORMAP_NODITHER \ + "return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ + #define GLSL_DOOM_COLORMAP \ - "float R_DoomColormap(float light, float z)\n" \ + "uniform vec2 scr_resolution;\n" \ + "float R_DoomColormap(float light, float z, vec2 position)\n" \ "{\n" \ "float lightnum = clamp(light / 17.0, 0.0, 15.0);\n" \ "float lightz = clamp(z / 16.0, 0.0, 127.0);\n" \ "float startmap = (15.0 - lightnum) * 4.0;\n" \ "float scale = 160.0 / (lightz + 1.0);\n" \ "float cap = (155.0 - light) * 0.26;\n" \ - "return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ + "#ifdef SRB2_LIGHT_DITHER\n" \ + GLSL_DOOM_COLORMAP_DITHER \ + "#else\n" \ + GLSL_DOOM_COLORMAP_NODITHER \ + "#endif\n" \ "}\n" // lighting cap adjustment: // first num (155.0), increase to make it start to go dark sooner @@ -69,7 +103,7 @@ "float R_DoomLightingEquation(float light)\n" \ "{\n" \ "float z = gl_FragCoord.z / gl_FragCoord.w;\n" \ - "float colormap = floor(R_DoomColormap(light, z)) + 0.5;\n" \ + "float colormap = floor(R_DoomColormap(light, z, gl_FragCoord.xy)) + 0.5;\n" \ "return clamp(colormap, 0.0, 31.0) / 32.0;\n" \ "}\n" @@ -95,7 +129,7 @@ #define GLSL_PALETTE_RENDERING \ "float tex_pal_idx = texture3D(palette_lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0;\n" \ "float z = gl_FragCoord.z / gl_FragCoord.w;\n" \ - "float light_y = clamp(floor(R_DoomColormap(lighting, z)), 0.0, 31.0);\n" \ + "float light_y = clamp(floor(R_DoomColormap(lighting, z, gl_FragCoord.xy)), 0.0, 31.0);\n" \ "vec2 lighttable_coord = vec2((tex_pal_idx + 0.5) / 256.0, (light_y + 0.5) / 32.0);\n" \ "vec4 final_color = texture2D(lighttable_tex, lighttable_coord);\n" \ "final_color.a = texel.a * poly_color.a;\n" \ diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 12e70f945..50c686332 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -669,6 +669,8 @@ typedef enum // misc. gluniform_leveltime, + + gluniform_scr_resolution, gluniform_max, } gluniform_t; @@ -1836,6 +1838,8 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF UNIFORM_1(shader->uniforms[gluniform_leveltime], ((float)shader_leveltime) / TICRATE, pglUniform1f); + UNIFORM_2(shader->uniforms[gluniform_scr_resolution], vid.width, vid.height, pglUniform2f); + #undef UNIFORM_1 #undef UNIFORM_2 #undef UNIFORM_3 @@ -1953,6 +1957,8 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) shader->uniforms[gluniform_palette_lookup_tex] = GETUNI("palette_lookup_tex"); shader->uniforms[gluniform_lighttable_tex] = GETUNI("lighttable_tex"); + shader->uniforms[gluniform_scr_resolution] = GETUNI("scr_resolution"); + // misc. shader->uniforms[gluniform_leveltime] = GETUNI("leveltime"); #undef GETUNI -- 2.54.0 From 40143375fc674386e4dcae069c1f9bdb357d82d3 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 1 Jul 2024 22:42:25 +0300 Subject: [PATCH 095/525] If shader compilation failed, print info log --- src/hardware/r_opengl/r_opengl.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 50c686332..c3d0daf0d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -608,6 +608,7 @@ typedef void (APIENTRY *PFNglDeleteProgram) (GLuint); typedef void (APIENTRY *PFNglAttachShader) (GLuint, GLuint); typedef void (APIENTRY *PFNglLinkProgram) (GLuint); typedef void (APIENTRY *PFNglGetProgramiv) (GLuint, GLenum, GLint*); +typedef void (APIENTRY *PFNglGetProgramInfoLog) (GLuint, GLsizei, GLsizei*, GLchar*); typedef void (APIENTRY *PFNglUseProgram) (GLuint); typedef void (APIENTRY *PFNglUniform1i) (GLint, GLint); typedef void (APIENTRY *PFNglUniform1f) (GLint, GLfloat); @@ -630,6 +631,7 @@ static PFNglDeleteProgram pglDeleteProgram; static PFNglAttachShader pglAttachShader; static PFNglLinkProgram pglLinkProgram; static PFNglGetProgramiv pglGetProgramiv; +static PFNglGetProgramInfoLog pglGetProgramInfoLog; static PFNglUseProgram pglUseProgram; static PFNglUniform1i pglUniform1i; static PFNglUniform1f pglUniform1f; @@ -737,6 +739,7 @@ void SetupGLFunc4(void) pglAttachShader = GetGLFunc("glAttachShader"); pglLinkProgram = GetGLFunc("glLinkProgram"); pglGetProgramiv = GetGLFunc("glGetProgramiv"); + pglGetProgramInfoLog = GetGLFunc("glGetProgramInfoLog"); pglUseProgram = GetGLFunc("glUseProgram"); pglUniform1i = GetGLFunc("glUniform1i"); pglUniform1f = GetGLFunc("glUniform1f"); @@ -1854,6 +1857,7 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) GLint result; const GLchar *vert_shader = shader->vertex_shader; const GLchar *frag_shader = shader->fragment_shader; + GLchar info_log[512]; if (shader->program) pglDeleteProgram(shader->program); @@ -1883,7 +1887,10 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) pglGetShaderiv(gl_vertShader, GL_COMPILE_STATUS, &result); if (result == GL_FALSE) { - GL_MSG_Error("Error compiling vertex shader", gl_vertShader, i); + pglGetShaderInfoLog(gl_vertShader, 512, NULL, info_log); + + GL_MSG_Error("Error compiling vertex shader: %s\n", info_log); + pglDeleteShader(gl_vertShader); return false; } @@ -1910,7 +1917,9 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) pglGetShaderiv(gl_fragShader, GL_COMPILE_STATUS, &result); if (result == GL_FALSE) { - GL_MSG_Error("Error compiling fragment shader", gl_fragShader, i); + pglGetShaderInfoLog(gl_fragShader, 512, NULL, info_log); + + GL_MSG_Error("Error compiling fragment shader: %s\n", info_log); pglDeleteShader(gl_vertShader); pglDeleteShader(gl_fragShader); return false; @@ -1936,7 +1945,8 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) // couldn't link? if (result != GL_TRUE) { - GL_MSG_Error("Shader_CompileProgram: Error linking shader program %s\n", HWR_GetShaderName(i)); + pglGetProgramInfoLog(shader->program, 512, NULL, info_log); + GL_MSG_Error("Shader_CompileProgram: Error linking shader program %s: %s\n", HWR_GetShaderName(i), info_log); pglDeleteProgram(shader->program); return false; } -- 2.54.0 From 3456ef96a767f042b496caf49294c79a0a9d7f45 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 1 Jul 2024 23:15:59 +0300 Subject: [PATCH 096/525] Use a fake 2d array in dither shader so it compiles with older glsl versions (1.20 at least) --- src/hardware/hw_shaders.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 6f3ef225e..775a16db9 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -64,17 +64,17 @@ "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ "int x = int(mod(normalizedPosition.x, 8.0));\n" \ "int y = int(mod(normalizedPosition.y, 8.0));\n" \ - "float bayerMatrix[8][8] = float[8][8](\n" \ - "float[8](0.0, 32.0, 8.0, 40.0, 2.0, 34.0, 10.0, 42.0),\n" \ - "float[8](48.0, 16.0, 56.0, 24.0, 50.0, 18.0, 58.0, 26.0),\n" \ - "float[8](12.0, 44.0, 4.0, 36.0, 14.0, 46.0, 6.0, 38.0),\n" \ - "float[8](60.0, 28.0, 52.0, 20.0, 62.0, 30.0, 54.0, 22.0),\n" \ - "float[8](3.0, 35.0, 11.0, 43.0, 1.0, 33.0, 9.0, 41.0),\n" \ - "float[8](51.0, 19.0, 59.0, 27.0, 49.0, 17.0, 57.0, 25.0),\n" \ - "float[8](15.0, 47.0, 7.0, 39.0, 13.0, 45.0, 5.0, 37.0),\n" \ - "float[8](63.0, 31.0, 55.0, 23.0, 61.0, 29.0, 53.0, 21.0)\n" \ + "float bayerMatrix[8*8] = float[8*8](\n" \ + "0.0, 32.0, 8.0, 40.0, 2.0, 34.0, 10.0, 42.0,\n" \ + "48.0, 16.0, 56.0, 24.0, 50.0, 18.0, 58.0, 26.0,\n" \ + "12.0, 44.0, 4.0, 36.0, 14.0, 46.0, 6.0, 38.0,\n" \ + "60.0, 28.0, 52.0, 20.0, 62.0, 30.0, 54.0, 22.0,\n" \ + "3.0, 35.0, 11.0, 43.0, 1.0, 33.0, 9.0, 41.0,\n" \ + "51.0, 19.0, 59.0, 27.0, 49.0, 17.0, 57.0, 25.0,\n" \ + "15.0, 47.0, 7.0, 39.0, 13.0, 45.0, 5.0, 37.0,\n" \ + "63.0, 31.0, 55.0, 23.0, 61.0, 29.0, 53.0, 21.0\n" \ ");\n" \ - "float threshold = bayerMatrix[y][x] / 64.0;\n" \ + "float threshold = bayerMatrix[y*8 + x] / 64.0;\n" \ "return baseValue + threshold - 0.5 / 64.0;\n" \ #define GLSL_DOOM_COLORMAP_NODITHER \ @@ -190,10 +190,12 @@ // hand tuned adjustments for light level calculation #define GLSL_FLOOR_FUDGES \ + "#version 120\n" \ "#define STARTMAP_FUDGE 1.06\n" \ "#define SCALE_FUDGE 1.15\n" #define GLSL_WALL_FUDGES \ + "#version 120\n" \ "#define STARTMAP_FUDGE 1.05\n" \ "#define SCALE_FUDGE 2.2\n" -- 2.54.0 From d37a1c799fe02aeb8fe8e769715e0c02f122eccd Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Jul 2024 23:09:00 +0200 Subject: [PATCH 097/525] change dither matrix to 4x4 a little grittier also smol cleanup --- src/hardware/hw_shaders.h | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 775a16db9..4464acfca 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -56,26 +56,22 @@ "float halfResolutionx = scr_resolution.x;\n" \ "float halfResolutiony = scr_resolution.y;\n" \ "if (scr_resolution.x > 1280.0) {\n" \ - " halfResolutionx = scr_resolution.x * 0.5;\n" \ + "halfResolutionx = scr_resolution.x * 0.5;\n" \ "}\n" \ "if (scr_resolution.y > 720.0) {\n" \ - " halfResolutiony = scr_resolution.y * 0.5;\n" \ + "halfResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ - "int x = int(mod(normalizedPosition.x, 8.0));\n" \ - "int y = int(mod(normalizedPosition.y, 8.0));\n" \ - "float bayerMatrix[8*8] = float[8*8](\n" \ - "0.0, 32.0, 8.0, 40.0, 2.0, 34.0, 10.0, 42.0,\n" \ - "48.0, 16.0, 56.0, 24.0, 50.0, 18.0, 58.0, 26.0,\n" \ - "12.0, 44.0, 4.0, 36.0, 14.0, 46.0, 6.0, 38.0,\n" \ - "60.0, 28.0, 52.0, 20.0, 62.0, 30.0, 54.0, 22.0,\n" \ - "3.0, 35.0, 11.0, 43.0, 1.0, 33.0, 9.0, 41.0,\n" \ - "51.0, 19.0, 59.0, 27.0, 49.0, 17.0, 57.0, 25.0,\n" \ - "15.0, 47.0, 7.0, 39.0, 13.0, 45.0, 5.0, 37.0,\n" \ - "63.0, 31.0, 55.0, 23.0, 61.0, 29.0, 53.0, 21.0\n" \ + "int x = int(mod(normalizedPosition.x, 4.0));\n" \ + "int y = int(mod(normalizedPosition.y, 4.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 = bayerMatrix[y*8 + x] / 64.0;\n" \ - "return baseValue + threshold - 0.5 / 64.0;\n" \ + "float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \ + "return baseValue + threshold - 0.5 / 16.0;\n" \ #define GLSL_DOOM_COLORMAP_NODITHER \ "return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ -- 2.54.0 From fc014535440f0686f3fad08e7a18546a9f664f46 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Jul 2024 23:08:24 +0200 Subject: [PATCH 098/525] scale dithering a little diff for a little smoother "fade" in pal render --- src/hardware/hw_shaders.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 4464acfca..7b188f64b 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -70,7 +70,11 @@ "3.0, 11.0, 1.0, 9.0,\n" \ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ + "#ifdef SRB2_PALETTE_RENDERING\n" \ + "float threshold = bayerMatrix[y*4 + x] / 12.0;\n" \ + "#else\n" \ "float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \ + "#endif\n" \ "return baseValue + threshold - 0.5 / 16.0;\n" \ #define GLSL_DOOM_COLORMAP_NODITHER \ -- 2.54.0 From f73e84e0adc33a7faba99d1049a7a889388c8785 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Jul 2024 02:26:45 +0200 Subject: [PATCH 099/525] stuff --- src/g_game.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 887fd8ffd..68edfed35 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2251,13 +2251,14 @@ void G_Ticker(boolean run) buf = gametic % TICQUEUE; if (!demo.playback) - // read/write demo and check turbo cheat - for (i = 0; i < MAXPLAYERS; i++) { - cmd = &players[i].cmd; - - if (playeringame[i]) + for (i = 0; i < MAXPLAYERS; i++) // read/write demo and check turbo cheat { + cmd = &players[i].cmd; + + if (!playeringame[i]) + continue; + //@TODO all this throwdir stuff shouldn't be here! But it stays for now to maintain 1.0.4 compat... // Remove for 1.1! -- 2.54.0 From 606717d253616a8476155a2a08fc1bc34429e836 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Jun 2024 21:03:53 +0200 Subject: [PATCH 100/525] prevent potential crash when trying to kill bananachain --- src/p_inter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_inter.c b/src/p_inter.c index 68d02cdd9..e0e0986e6 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1955,7 +1955,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount]) { - if (target->target->hnext) + if (target->target->hnext && !P_MobjWasRemoved(target->target->hnext)) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; } -- 2.54.0 From c59564723c727f4e803ac3c3aaa7337a7d0fa39b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 13:04:11 +0200 Subject: [PATCH 101/525] Clamp lindex during vissprite light calculation Mitigates against negative or very large xscale values causing lindex to evaluate < 0, preventing a potential colormap indexing-related crash. --- src/r_things.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 372ddb964..a769960ea 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -954,7 +954,6 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) if (vis->x2 >= vid.width) vis->x2 = vid.width-1; -#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) { texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); @@ -962,7 +961,6 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) R_DrawMaskedColumn(column); } -#undef CLAMP colfunc = basecolfunc; } @@ -1048,8 +1046,9 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) { lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); - if (lindex >= MAXLIGHTSCALE) - lindex = MAXLIGHTSCALE-1; + // Mitigate against negative xscale and arithmetic overflow + lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1); + newsprite->colormap = spritelights[lindex]; } } @@ -1725,8 +1724,8 @@ static void R_ProjectSprite(mobj_t *thing) // diminished light lindex = FixedMul(xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); - if (lindex >= MAXLIGHTSCALE) - lindex = MAXLIGHTSCALE-1; + // Mitigate against negative xscale and arithmetic overflow + lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1); vis->colormap = spritelights[lindex]; } -- 2.54.0 From 66ce0871bc8ca89ed3930d450cb7f6ce300f515d Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Sat, 22 Jun 2024 18:48:56 -0400 Subject: [PATCH 102/525] Fix automap multiplayer crash https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2488 --- src/am_map.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/am_map.c b/src/am_map.c index 666113ddb..d94ec7262 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -1015,6 +1015,9 @@ static inline void AM_drawPlayers(void) { if (!playeringame[i] || players[i].spectator) continue; + + if (!players[i].mo) + continue; p = &players[i]; if (p->skincolor > 0) -- 2.54.0 From 8d968d7f89c7cbdc1cee88100b9312a945bb576d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 13:02:11 +0200 Subject: [PATCH 103/525] fix some clang warnings --- src/hardware/hw_batching.c | 2 ++ src/lua_mobjlib.c | 2 +- src/lua_playerlib.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index f23505bd1..7dde8b3bd 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -47,7 +47,9 @@ int unsortedVertexArrayAllocSize = 65536; void HWR_StartBatching(void) { if (currently_batching) + { I_Error("Repeat call to HWR_StartBatching without HWR_RenderBatches"); + } // init arrays if that has not been done yet if (!finalVertexArray) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index f62e59486..7385cccf6 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -147,7 +147,7 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, colorized, udatalib_getter_boolean, udatalib_setter_boolean), FIELD(mobj_t, mirrored, udatalib_getter_boolean, udatalib_setter_boolean), FIELD(mobj_t, rollmodel, udatalib_getter_boolean, udatalib_setter_boolean), - { NULL }, + { NULL, 0, NULL, NULL }, }; #undef FIELD diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 2d79d536d..74e6b0f32 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -160,7 +160,7 @@ static const udata_field_t player_fields[] = { // Same as player.name { "sliproll", 0, player_sliproll_getter, player_sliproll_noset }, { "ping", 0, player_ping_getter, player_ping_noset }, // Hmm originally setter doesn't exist so data is written as unreachable custom field... - { NULL }, + { NULL, 0, NULL, NULL }, }; #undef FIELD -- 2.54.0 From 4b4b2d5cbc7ea3db104ebe8f6a16c5c4c093a37b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 17:37:16 +0200 Subject: [PATCH 104/525] some crap from asan --- src/doomdef.h | 4 ++++ src/hardware/hw_main.c | 4 ---- src/k_kart.c | 5 ++--- src/lua_consolelib.c | 6 +++++- src/r_draw8.c | 3 +-- src/r_segs.c | 3 ++- src/sdl/mixer_sound.c | 1 + 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index c032ec77b..31734af84 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -529,6 +529,10 @@ INT32 I_GetKey(void); #define max(x, y) (((x) > (y)) ? (x) : (y)) #endif +#ifndef CLAMP +#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) +#endif + #ifndef M_PIl #define M_PIl 3.1415926535897932384626433832795029L #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 6c98c8c97..d5c789368 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -54,8 +54,6 @@ #define SOFTLIGHT(llevel) HWR_ShouldUsePaletteRendering() ? ((llevel) >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : (llevel) -#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) - // ========================================================================== // the hardware driver object // ========================================================================== @@ -6271,6 +6269,4 @@ void HWR_DrawScreenFinalTexture(INT32 width, INT32 height) HWD.pfnDrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height); } -#undef CLAMP - #endif // HWRENDER diff --git a/src/k_kart.c b/src/k_kart.c index 2857eddf3..7419387c4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9350,11 +9350,10 @@ static void K_drawDriftGauge(void) if (driftcharge >= driftval*4) // rainbow sparks { + int index = CLAMP((leveltime % 18) + 1, 0, 18 - 1); cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); for (i = 0; i < 4; i++) - { - V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[(leveltime % 18) + 1] + i*2) | V_NOSCALESTART|drifttrans); - } + V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[index] + i*2) | V_NOSCALESTART|drifttrans); } else // none/blue/red { diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index ad1df2b22..3e70ce008 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -453,9 +453,11 @@ static int lib_cvRegisterVar(lua_State *L) if (!(((cvar->flags & CV_HIDEN)) || (cvar->flags & CV_NOSHOWHELP)) && (cvar->PossibleValue || !(cvar->value == 0 && stricmp(cvar->string, "0")))) { + char *temp = NULL; + if (!category) { - char *temp = strdup(wadfiles[numwadfiles - 1]->filename); + temp = strdup(wadfiles[numwadfiles - 1]->filename); nameonly(temp); category = temp; @@ -465,6 +467,8 @@ static int lib_cvRegisterVar(lua_State *L) M_SlotCvarIntoModMenu(cvar, category, menu_name); else M_SlotCvarIntoModMenu(cvar, category, cvar->name); + + free (temp); } // return cvar userdata diff --git a/src/r_draw8.c b/src/r_draw8.c index 6b5d177db..b67311d76 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -43,16 +43,15 @@ void R_DrawColumn_8(void) // Use ylookup LUT to avoid multiply with ScreenWidth. // Use columnofs LUT for subwindows? - //dest = ylookup[dc_yl] + columnofs[dc_x]; dest = &topleft[dc_yl*vid.width + dc_x]; count++; // Determine scaling, which is the only mapping to be done. fracstep = dc_iscale; - //frac = dc_texturemid + (dc_yl - centery)*fracstep; frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); + // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. { diff --git a/src/r_segs.c b/src/r_segs.c index b70e06ff6..7cb7e7397 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1374,7 +1374,8 @@ static void R_RenderSegLoop (void) //SoM: Calculate offsets for Thick fake floors. // calculate texture offset angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; - texturecolumn = rw_offset-FixedMul(FINETANGENT(angle),rw_distance); + // Mask 4095 to guarantee this index is within bounds + texturecolumn = rw_offset-FixedMul(FINETANGENT(angle & 4095),rw_distance); if (oldtexturecolumn != -1) { rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn-texturecolumn); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index aef996772..806c77e47 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1115,6 +1115,7 @@ boolean I_LoadSong(char *data, size_t len) if (!gme_open_data(inflatedData, inflatedLen, &gme, SAMPLERATE)) { Z_Free(inflatedData); // GME supposedly makes a copy for itself, so we don't need this lying around + inflateEnd(&stream); return true; } } -- 2.54.0 From 27917a0e850eec7c639c64fc82255cfd41fd5add Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 10:39:38 +0200 Subject: [PATCH 105/525] shut up gcc --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7419387c4..93ddadd40 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9350,7 +9350,7 @@ static void K_drawDriftGauge(void) if (driftcharge >= driftval*4) // rainbow sparks { - int index = CLAMP((leveltime % 18) + 1, 0, 18 - 1); + int index = max((leveltime % 18) + 1, 18 - 1); cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); for (i = 0; i < 4; i++) V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[index] + i*2) | V_NOSCALESTART|drifttrans); -- 2.54.0 From 219979e20b0b9140bf0c0d0c5e0c9ca4bc47586e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 18:24:35 +0200 Subject: [PATCH 106/525] dont think kart even supports trivial maps so no need to constantly check for this --- src/r_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index f1ffeebce..fc753941c 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1119,8 +1119,8 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) subsector_t *ret; // single subsector is a special case - if (numnodes == 0) - return subsectors; + //if (numnodes == 0) + //return subsectors; nodenum = numnodes - 1; -- 2.54.0 From 711d7dcfccfa4ccd3e9620cc99c99d464de737c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 19:35:52 +0200 Subject: [PATCH 107/525] Always use system-specific path seperator https://git.srb2.org/KartKrew/RingRacers/-/commit/0f16c61d04f42b463db5c8987571fc986ae6ce9f --- src/filesrch.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/filesrch.c b/src/filesrch.c index 55d40d811..3a3a576ce 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -37,7 +37,6 @@ #include #define SUFFIX "*" -#define SLASH "\\" #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #ifndef INVALID_FILE_ATTRIBUTES @@ -135,7 +134,7 @@ opendir (const CHAR *szPath) /* Allocate enough space to store DIR structure and the complete * directory path given. */ nd = (DIR *) malloc (sizeof (DIR) + (strlen(szFullPath) + strlen (SLASH) + - strlen(SUFFIX) + 1) * sizeof (CHAR)); + strlen(PATHSEP) + 1) * sizeof (CHAR)); if (!nd) { @@ -149,10 +148,9 @@ opendir (const CHAR *szPath) /* Add on a slash if the path does not end with one. */ if (nd->dd_name[0] != '\0' && - nd->dd_name[strlen (nd->dd_name) - 1] != '/' && - nd->dd_name[strlen (nd->dd_name) - 1] != '\\') + nd->dd_name[strlen (nd->dd_name) - 1] != PATHSEP[0]) { - strcat (nd->dd_name, SLASH); + strcat (nd->dd_name, PATHSEP); } /* Add on the search pattern */ @@ -382,9 +380,9 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want return FS_NOTFOUND; } - if (searchpath[searchpathindex[depthleft]-2] != '/') + if (searchpath[searchpathindex[depthleft]-2] != PATHSEP[0]) { - searchpath[searchpathindex[depthleft]-1] = '/'; + searchpath[searchpathindex[depthleft]-1] = PATHSEP[0]; searchpath[searchpathindex[depthleft]] = 0; } else @@ -392,7 +390,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want while ((!found) && (depthleft < maxsearchdepth)) { - searchpath[searchpathindex[depthleft]]=0; + searchpath[searchpathindex[depthleft]] = 0; dent = readdir(dirhandle[depthleft]); if (!dent) @@ -419,7 +417,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want if (S_ISDIR(fsstat.st_mode)) dent->d_type = DT_DIR; else if (S_ISLNK(fsstat.st_mode)) - dent->d_type = DT_LNK; + dent->d_type = DT_LNK; } // Symlinks aren't always directory symlinks. Dunno if this would resolve recursive @@ -447,8 +445,8 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want depthleft++; } - searchpath[searchpathindex[depthleft]-1]='/'; - searchpath[searchpathindex[depthleft]]=0; + searchpath[searchpathindex[depthleft]-1] = PATHSEP[0]; + searchpath[searchpathindex[depthleft]] = 0; } else if (!strcasecmp(searchname, dent->d_name)) { -- 2.54.0 From edbf20d97569c1091148197a51018a1e8bf2e699 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 4 Jul 2024 08:50:45 +0200 Subject: [PATCH 108/525] oops this should be min --- src/k_kart.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 93ddadd40..52e2ceb95 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9350,10 +9350,9 @@ static void K_drawDriftGauge(void) if (driftcharge >= driftval*4) // rainbow sparks { - int index = max((leveltime % 18) + 1, 18 - 1); cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); for (i = 0; i < 4; i++) - V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[index] + i*2) | V_NOSCALESTART|drifttrans); + V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[min((leveltime % 18) + 1, 18 - 1)] + i*2) | V_NOSCALESTART|drifttrans); } else // none/blue/red { -- 2.54.0 From 66eb2014667c345072dcc7638109bbc1898fab02 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 4 Jul 2024 08:51:11 +0200 Subject: [PATCH 109/525] simplify this a little --- src/hardware/hw_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d5c789368..b50e05e61 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -533,10 +533,8 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } - light_level = SOFTLIGHT(light_level); - // Clamp the light level, since it can sometimes go out of the 0-255 range from animations - light_level = min(max(light_level, cv_secbright.value), 255); + light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); // in palette rendering mode, this is not needed since it properly takes the changes to the palette itself if (!HWR_ShouldUsePaletteRendering()) -- 2.54.0 From d9f25354023be0a217fc14a3ad23e5e780a5e8f9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jul 2024 06:02:01 +0200 Subject: [PATCH 110/525] scale and fade out dither pattern makes the image a bit cleaner and easier to look at in palrender --- src/hardware/hw_shaders.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 7b188f64b..f7a086186 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -61,6 +61,9 @@ "if (scr_resolution.y > 720.0) {\n" \ "halfResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ + "float zFactor = clamp((z - 768.0) / (2304.0 - 768.0), 0.0, 1.0);\n" \ + "halfResolutionx = mix(halfResolutionx, halfResolutionx * 2.0, zFactor);\n" \ + "halfResolutiony = mix(halfResolutiony, halfResolutiony * 2.0, zFactor);\n" \ "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ "int x = int(mod(normalizedPosition.x, 4.0));\n" \ "int y = int(mod(normalizedPosition.y, 4.0));\n" \ @@ -71,9 +74,9 @@ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ "#ifdef SRB2_PALETTE_RENDERING\n" \ - "float threshold = bayerMatrix[y*4 + x] / 12.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 11.0);\n" \ "#else\n" \ - "float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 16.0);\n" \ "#endif\n" \ "return baseValue + threshold - 0.5 / 16.0;\n" \ -- 2.54.0 From 58dd0b75914eeeef8878aafc8b8933e4efea7e02 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jul 2024 19:28:26 +0200 Subject: [PATCH 111/525] oops that actually didnt fade out at all lol --- src/hardware/hw_shaders.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index f7a086186..0ef5acccf 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -61,9 +61,9 @@ "if (scr_resolution.y > 720.0) {\n" \ "halfResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ - "float zFactor = clamp((z - 768.0) / (2304.0 - 768.0), 0.0, 1.0);\n" \ - "halfResolutionx = mix(halfResolutionx, halfResolutionx * 2.0, zFactor);\n" \ - "halfResolutiony = mix(halfResolutiony, halfResolutiony * 2.0, zFactor);\n" \ + "float zFactor = clamp((z - 768.0) / (3072.0 - 768.0), 0.0, 1.0);\n" \ + "halfResolutionx = mix(halfResolutionx, halfResolutionx * 4.0, zFactor);\n" \ + "halfResolutiony = mix(halfResolutiony, halfResolutiony * 4.0, zFactor);\n" \ "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ "int x = int(mod(normalizedPosition.x, 4.0));\n" \ "int y = int(mod(normalizedPosition.y, 4.0));\n" \ @@ -74,11 +74,11 @@ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ "#ifdef SRB2_PALETTE_RENDERING\n" \ - "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 11.0);\n" \ + "float threshold = bayerMatrix[y*4 + x] / 11.0;\n" \ "#else\n" \ - "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 16.0);\n" \ + "float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \ "#endif\n" \ - "return baseValue + threshold - 0.5 / 16.0;\n" \ + "return mix(baseValue + threshold - 0.5 / 16.0, baseValue, zFactor);\n" #define GLSL_DOOM_COLORMAP_NODITHER \ "return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ -- 2.54.0 From cbbde8dea54b02014c088ba2b6d03c93c99352e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jul 2024 19:37:04 +0200 Subject: [PATCH 112/525] more tweaks --- src/hardware/hw_shaders.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 0ef5acccf..6235d9e1f 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -61,9 +61,9 @@ "if (scr_resolution.y > 720.0) {\n" \ "halfResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ - "float zFactor = clamp((z - 768.0) / (3072.0 - 768.0), 0.0, 1.0);\n" \ - "halfResolutionx = mix(halfResolutionx, halfResolutionx * 4.0, zFactor);\n" \ - "halfResolutiony = mix(halfResolutiony, halfResolutiony * 4.0, zFactor);\n" \ + "float zFactor = clamp((z - 768.0) / (6144.0 - 768.0), 0.0, 1.0);\n" \ + "halfResolutionx = mix(halfResolutionx, halfResolutionx * 2.0, zFactor);\n" \ + "halfResolutiony = mix(halfResolutiony, halfResolutiony * 2.0, zFactor);\n" \ "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ "int x = int(mod(normalizedPosition.x, 4.0));\n" \ "int y = int(mod(normalizedPosition.y, 4.0));\n" \ @@ -74,9 +74,9 @@ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ "#ifdef SRB2_PALETTE_RENDERING\n" \ - "float threshold = bayerMatrix[y*4 + x] / 11.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 11.0);\n" \ "#else\n" \ - "float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 16.0);\n" \ "#endif\n" \ "return mix(baseValue + threshold - 0.5 / 16.0, baseValue, zFactor);\n" -- 2.54.0 From b5d7b84c1e3024296148b48918b1977c16d6722c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 9 Jul 2024 08:39:38 +0200 Subject: [PATCH 113/525] more changes to dither use interger for distance scales start z factor earlier rename halfResolution to endResolution --- src/hardware/hw_shaders.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 6235d9e1f..714b004b1 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -53,18 +53,19 @@ // 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 halfResolutionx = scr_resolution.x;\n" \ - "float halfResolutiony = scr_resolution.y;\n" \ + "float endResolutionx = scr_resolution.x;\n" \ + "float endResolutiony = scr_resolution.y;\n" \ "if (scr_resolution.x > 1280.0) {\n" \ - "halfResolutionx = scr_resolution.x * 0.5;\n" \ + "endResolutionx = scr_resolution.x * 0.5;\n" \ "}\n" \ "if (scr_resolution.y > 720.0) {\n" \ - "halfResolutiony = scr_resolution.y * 0.5;\n" \ + "endResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ - "float zFactor = clamp((z - 768.0) / (6144.0 - 768.0), 0.0, 1.0);\n" \ - "halfResolutionx = mix(halfResolutionx, halfResolutionx * 2.0, zFactor);\n" \ - "halfResolutiony = mix(halfResolutiony, halfResolutiony * 2.0, zFactor);\n" \ - "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\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 bayerMatrix[4*4] = float[4*4](\n" \ -- 2.54.0 From 0c6f9b6cc19d42c64c898555dcf7e875851e266f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 11 Jun 2024 01:16:35 +0200 Subject: [PATCH 114/525] basic frame skipping system --- src/d_main.c | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index bdfa7557d..5f7b375f0 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -242,8 +242,9 @@ void D_ProcessEvents(void) // added comment : there is a wipe eatch change of the gamestate gamestate_t wipegamestate = GS_LEVEL; -static void D_Display(void) +static boolean D_Display(void) { + boolean ranwipe = false; boolean forcerefresh = false; static boolean wipe = false; INT32 wipedefindex = 0; @@ -252,7 +253,7 @@ static void D_Display(void) if (!dedicated) { if (nodrawers) - return; // for comparative timing/profiling + return false; // for comparative timing/profiling // check for change of screen size (video mode) if (setmodeneeded && !wipe) @@ -302,6 +303,7 @@ static void D_Display(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); + ranwipe = true; } if (gamestate != GS_LEVEL && rendermode != render_none) @@ -315,12 +317,13 @@ static void D_Display(void) else //dedicated servers { F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); + ranwipe = true; wipegamestate = gamestate; } } if (dedicated) //bail out after wipe logic - return; + return false; // do buffered drawing switch (gamestate) @@ -561,6 +564,7 @@ static void D_Display(void) { F_WipeEndScreen(); F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); + ranwipe = true; } } @@ -610,6 +614,7 @@ static void D_Display(void) PS_STOP_TIMING(ps_swaptime); } + return ranwipe; } // ========================================================================= @@ -627,6 +632,7 @@ void D_SRB2Loop(void) boolean interp = false; boolean doDisplay = false; + int frameskip = 0; if (dedicated) server = true; @@ -670,6 +676,8 @@ void D_SRB2Loop(void) double budget = round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision()); capbudget = (precise_t) budget; } + + boolean ranwipe = false; I_UpdateTime(cv_timescale.value); @@ -703,9 +711,11 @@ void D_SRB2Loop(void) HW3S_BeginFrameUpdate(); #endif + renderisnewtic = (realtics > 0 || singletics); + refreshdirmenu = 0; // not sure where to put this, here as good as any? - if (realtics > 0 || singletics) + if (renderisnewtic) { // don't skip more than 10 frames at a time // (fadein / fadeout cause massive frame skip!) @@ -726,12 +736,6 @@ void D_SRB2Loop(void) { doDisplay = true; } - - renderisnewtic = true; - } - else - { - renderisnewtic = false; } if (interp) @@ -753,9 +757,9 @@ void D_SRB2Loop(void) rendertimefrac = FRACUNIT; } - if (interp || doDisplay) + if ((interp || doDisplay) && !frameskip) { - D_Display(); + ranwipe = D_Display(); } // Only take screenshots after drawing. @@ -820,6 +824,27 @@ void D_SRB2Loop(void) // Fully completed frame made. finishprecise = I_GetPreciseTime(); + + deltasecs = (double)((INT64)(finishprecise - enterprecise)) / I_GetPrecisePrecision(); + deltatics = deltasecs * NEWTICRATE; + + // If time spent this game loop exceeds a single tic, + // it's probably because of rendering. + // + // Skip rendering the next frame, up to a limit of 3 + // frames before a frame is rendered no matter what. + // + // Wipes run an inner loop and artificially increase + // the measured time. + if (!ranwipe && frameskip < 3 && deltatics > 1.0) + { + frameskip++; + } + else + { + frameskip = 0; + } + if (!singletics) { INT64 elapsed = (INT64)(finishprecise - enterprecise); @@ -834,8 +859,6 @@ void D_SRB2Loop(void) } // Capture the time once more to get the real delta time. finishprecise = I_GetPreciseTime(); - deltasecs = (double)((INT64)(finishprecise - enterprecise)) / I_GetPrecisePrecision(); - deltatics = deltasecs * NEWTICRATE; } } -- 2.54.0 From 48ac3353cb8e48a877b627ab3d1dfa180d4ac634 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 14 Jun 2024 04:01:30 +0200 Subject: [PATCH 115/525] Maybe hopefully fix ogl masterserver crash thing port from durr --- src/m_menu.c | 4 +++ src/mserv.c | 88 ++++++++++++++++++++++++++++++++++++++++++---------- src/mserv.h | 2 ++ 3 files changed, 78 insertions(+), 16 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 8693d6f29..5fc65994f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -82,6 +82,9 @@ // protocol handling #include "d_protocol.h" +#include "z_zone.h" +#include "mserv.h" + #if defined(HAVE_SDL) #include "SDL.h" #if SDL_VERSION_ATLEAST(2,0,0) @@ -10128,6 +10131,7 @@ static void M_StartServerMenu(INT32 choice) levellistmode = LLM_CREATESERVER; M_PrepareLevelSelect(); M_SetupNextMenu(&MP_ServerDef); + Get_rules(); M_PopupMasterServerRules(); } diff --git a/src/mserv.c b/src/mserv.c index 3b5d84b46..96fb2e6e9 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -17,6 +17,7 @@ #include "doomstat.h" #include "doomdef.h" +#include "console.h" // con_startup #include "command.h" #include "i_threads.h" #include "mserv.h" @@ -212,20 +213,50 @@ static void Command_Listserv_f(void) } #endif +static boolean firstmsrules = false; + +static void +Get_masterserver_rules (boolean checkfirst) +{ + char rules[256]; + + if (checkfirst) + { + boolean MSRulesExist; + + Lock_state(); + MSRulesExist = (MSRules != NULL); + Unlock_state(); + + if (MSRulesExist) + return; + } + + if (HMS_fetch_rules(rules, sizeof rules)) + { + Lock_state(); + Z_Free(MSRules); + MSRules = Z_StrDup(rules); + + if (MSRegistered == true) + { + CONS_Printf("\n"); + CONS_Alert(CONS_NOTICE, "%s\n", rules); + } + + firstmsrules = true; + + Unlock_state(); + } +} + static void Finish_registration (void) { int registered; - char *rules = GetMasterServerRules(); CONS_Printf("Registering this server on the master server...\n"); - if (rules) - { - CONS_Printf("\n"); - CONS_Alert(CONS_NOTICE, "%s\n", rules); - } - registered = HMS_register(); Lock_state(); @@ -237,6 +268,17 @@ Finish_registration (void) } Unlock_state(); + char *rules = GetMasterServerRules(); + if (rules == NULL) + { + Get_masterserver_rules(true); + } + else + { + CONS_Printf("\n"); + CONS_Alert(CONS_NOTICE, "%s\n", rules); + } + if (registered) CONS_Printf("Master server registration successful.\n"); } @@ -322,17 +364,10 @@ Finish_unlist (void) static void Finish_masterserver_change (char *api) { - char rules[256]; - HMS_set_api(api); - if (HMS_fetch_rules(rules, sizeof rules)) - { - Lock_state(); - Z_Free(MSRules); - MSRules = Z_StrDup(rules); - Unlock_state(); - } + if (!con_startup) + Get_masterserver_rules(false); } #ifdef HAVE_THREADS @@ -430,6 +465,13 @@ Change_masterserver_thread (char *api) Finish_masterserver_change(api); } + +static void +Get_masterserver_rules_thread (void) +{ + // THIS FUNC has its own lock check in it + Get_masterserver_rules(true); +} #endif/*HAVE_THREADS*/ void RegisterServer(void) @@ -540,6 +582,20 @@ Set_api (const char *api) #endif } +void +Get_rules (void) +{ + #ifdef HAVE_THREADS + I_spawn_thread( + "get-masterserver-rules", + (I_thread_fn)Get_masterserver_rules_thread, + NULL + ); + #else + Get_masterserver_rules(true); + #endif +} + #endif/*MASTERSERVER*/ static void diff --git a/src/mserv.h b/src/mserv.h index 76bd5fd28..8142716ef 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -82,6 +82,8 @@ extern I_mutex ms_ServerList_mutex; void RegisterServer(void); void UnregisterServer(void); +void Get_rules(void); + void MasterClient_Ticker(void); msg_server_t *GetShortServersList(int id); -- 2.54.0 From e2f1dd1ce83d0cd2a326172c74765c411dfb6c87 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Jun 2024 21:16:25 +0200 Subject: [PATCH 116/525] a --- src/mserv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mserv.c b/src/mserv.c index 96fb2e6e9..2f172d27d 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -472,6 +472,7 @@ Get_masterserver_rules_thread (void) // THIS FUNC has its own lock check in it Get_masterserver_rules(true); } + #endif/*HAVE_THREADS*/ void RegisterServer(void) @@ -585,15 +586,15 @@ Set_api (const char *api) void Get_rules (void) { - #ifdef HAVE_THREADS +#ifdef HAVE_THREADS I_spawn_thread( "get-masterserver-rules", (I_thread_fn)Get_masterserver_rules_thread, NULL ); - #else +#else Get_masterserver_rules(true); - #endif +#endif } #endif/*MASTERSERVER*/ -- 2.54.0 From fea89de0374572885144be391d6313f6bee7d697 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 04:53:28 +0200 Subject: [PATCH 117/525] fix some clang warnings --- src/info.h | 408 +++++++++++++++++++++++++------------------------- src/p_mobj.c | 340 ++++++++++++++++++++--------------------- src/r_draw8.c | 2 +- src/r_main.c | 4 - src/r_plane.c | 25 ++-- src/r_segs.c | 26 ++-- 6 files changed, 407 insertions(+), 398 deletions(-) diff --git a/src/info.h b/src/info.h index b1955340b..aff87a663 100644 --- a/src/info.h +++ b/src/info.h @@ -245,211 +245,213 @@ enum actionnum NUMACTIONS }; +struct mobj_s; + // IMPORTANT NOTE: If you add/remove from this list of action // functions, don't forget to update them in dehacked.c! -void A_Explode(); -void A_Pain(); -void A_Fall(); -void A_MonitorPop(); -void A_Look(); -void A_Chase(); -void A_FaceStabChase(); -void A_FaceTarget(); -void A_FaceTracer(); -void A_Scream(); -void A_BossDeath(); -void A_CustomPower(); // Use this for a custom power -void A_GiveWeapon(); // Gives the player weapon(s) -void A_JumpShield(); // Obtained Jump Shield -void A_RingShield(); // Obtained Ring Shield -void A_RingBox(); // Obtained Ring Box Tails -void A_Invincibility(); // Obtained Invincibility Box -void A_SuperSneakers(); // Obtained Super Sneakers Box -void A_BunnyHop(); // have bunny hop tails -void A_BubbleSpawn(); // Randomly spawn bubbles -void A_FanBubbleSpawn(); -void A_BubbleRise(); // Bubbles float to surface -void A_BubbleCheck(); // Don't draw if not underwater -void A_AwardScore(); -void A_ExtraLife(); // Extra Life -void A_BombShield(); // Obtained Bomb Shield -void A_WaterShield(); // Obtained Water Shield -void A_ForceShield(); // Obtained Force Shield -void A_PityShield(); // Obtained Pity Shield. We're... sorry. -void A_GravityBox(); -void A_ScoreRise(); // Rise the score logo -void A_ParticleSpawn(); -void A_AttractChase(); // Ring Chase -void A_DropMine(); // Drop Mine from Skim or Jetty-Syn Bomber -void A_FishJump(); // Fish Jump -void A_ThrownRing(); // Sparkle trail for red ring -void A_GrenadeRing(); // SRB2kart -void A_SetSolidSteam(); -void A_UnsetSolidSteam(); -void A_SignPlayer(); -void A_OverlayThink(); -void A_JetChase(); -void A_JetbThink(); // Jetty-Syn Bomber Thinker -void A_JetgThink(); // Jetty-Syn Gunner Thinker -void A_JetgShoot(); // Jetty-Syn Shoot Function -void A_ShootBullet(); // JetgShoot without reactiontime setting -void A_MinusDigging(); -void A_MinusPopup(); -void A_MinusCheck(); -void A_ChickenCheck(); -void A_MouseThink(); // Mouse Thinker -void A_DetonChase(); // Deton Chaser -void A_CapeChase(); // Fake little Super Sonic cape -void A_RotateSpikeBall(); // Spike ball rotation -void A_SlingAppear(); -void A_MaceRotate(); -void A_UnidusBall(); -void A_RockSpawn(); -void A_SetFuse(); -void A_CrawlaCommanderThink(); // Crawla Commander -void A_SmokeTrailer(); -void A_RingExplode(); -void A_OldRingExplode(); -void A_MixUp(); -void A_RecyclePowers(); -void A_BossScream(); -void A_Boss2TakeDamage(); -void A_GoopSplat(); -void A_Boss2PogoSFX(); -void A_Boss2PogoTarget(); -void A_EggmanBox(); -void A_TurretFire(); -void A_SuperTurretFire(); -void A_TurretStop(); -void A_JetJawRoam(); -void A_JetJawChomp(); -void A_PointyThink(); -void A_CheckBuddy(); -void A_HoodThink(); -void A_ArrowCheck(); -void A_SnailerThink(); -void A_SharpChase(); -void A_SharpSpin(); -void A_VultureVtol(); -void A_VultureCheck(); -void A_SkimChase(); -void A_SkullAttack(); -void A_LobShot(); -void A_FireShot(); -void A_SuperFireShot(); -void A_BossFireShot(); -void A_Boss7FireMissiles(); -void A_Boss1Laser(); -void A_FocusTarget(); -void A_Boss4Reverse(); -void A_Boss4SpeedUp(); -void A_Boss4Raise(); -void A_SparkFollow(); -void A_BuzzFly(); -void A_GuardChase(); -void A_EggShield(); -void A_SetReactionTime(); -void A_Boss1Spikeballs(); -void A_Boss3TakeDamage(); -void A_Boss3Path(); -void A_LinedefExecute(); -void A_PlaySeeSound(); -void A_PlayAttackSound(); -void A_PlayActiveSound(); -void A_1upThinker(); -void A_BossZoom(); //Unused -void A_Boss1Chase(); -void A_Boss2Chase(); -void A_Boss2Pogo(); -void A_Boss7Chase(); -void A_BossJetFume(); -void A_SpawnObjectAbsolute(); -void A_SpawnObjectRelative(); -void A_ChangeAngleRelative(); -void A_ChangeAngleAbsolute(); -void A_RollAngle(); -void A_ChangeRollAngleRelative(); -void A_ChangeRollAngleAbsolute(); -void A_PlaySound(); -void A_FindTarget(); -void A_FindTracer(); -void A_SetTics(); -void A_SetRandomTics(); -void A_ChangeColorRelative(); -void A_ChangeColorAbsolute(); -void A_MoveRelative(); -void A_MoveAbsolute(); -void A_Thrust(); -void A_ZThrust(); -void A_SetTargetsTarget(); -void A_SetObjectFlags(); -void A_SetObjectFlags2(); -void A_RandomState(); -void A_RandomStateRange(); -void A_DualAction(); -void A_RemoteAction(); -void A_ToggleFlameJet(); -void A_ItemPop(); // SRB2kart -void A_JawzChase(); // SRB2kart -void A_JawzExplode(); // SRB2kart -void A_SPBChase(); // SRB2kart -void A_MineExplode(); // SRB2kart -void A_BallhogExplode(); // SRB2kart -void A_LightningFollowPlayer(); // SRB2kart: Lightning shield effect player chasing -void A_FZBoomFlash(); // SRB2kart -void A_FZBoomSmoke(); // SRB2kart -void A_RandomShadowFrame(); //SRB2kart: Shadow spawner frame randomizer -void A_RoamingShadowThinker(); // SRB2kart: Roaming Shadow moving + attacking players. -void A_MayonakaArrow(); //SRB2kart: midnight channel arrow sign -void A_ReaperThinker(); //SRB2kart: mementos reaper -void A_MementosTPParticles(); //SRB2kart: mementos teleporter particles. Man that's a lot of actions for my shite. -void A_FlameParticle(); // SRB2kart -void A_OrbitNights(); -void A_GhostMe(); -void A_SetObjectState(); -void A_SetObjectTypeState(); -void A_KnockBack(); -void A_PushAway(); -void A_RingDrain(); -void A_SplitShot(); -void A_MissileSplit(); -void A_MultiShot(); -void A_InstaLoop(); -void A_Custom3DRotate(); -void A_SearchForPlayers(); -void A_CheckRandom(); -void A_CheckTargetRings(); -void A_CheckRings(); -void A_CheckTotalRings(); -void A_CheckHealth(); -void A_CheckRange(); -void A_CheckHeight(); -void A_CheckTrueRange(); -void A_CheckThingCount(); -void A_CheckAmbush(); -void A_CheckCustomValue(); -void A_CheckCusValMemo(); -void A_SetCustomValue(); -void A_UseCusValMemo(); -void A_RelayCustomValue(); -void A_CusValAction(); -void A_ForceStop(); -void A_ForceWin(); -void A_SpikeRetract(); -void A_InfoState(); -void A_Repeat(); -void A_SetScale(); -void A_RemoteDamage(); -void A_HomingChase(); -void A_TrapShot(); -void A_VileTarget(); -void A_VileAttack(); -void A_VileFire(); -void A_BrakChase(); -void A_BrakFireShot(); -void A_BrakLobShot(); -void A_NapalmScatter(); -void A_SpawnFreshCopy(); +void A_Explode(struct mobj_s *actor); +void A_Pain(struct mobj_s *actor); +void A_Fall(struct mobj_s *actor); +void A_MonitorPop(struct mobj_s *actor); +void A_Look(struct mobj_s *actor); +void A_Chase(struct mobj_s *actor); +void A_FaceStabChase(struct mobj_s *actor); +void A_FaceTarget(struct mobj_s *actor); +void A_FaceTracer(struct mobj_s *actor); +void A_Scream(struct mobj_s *actor); +void A_BossDeath(struct mobj_s *actor); +void A_CustomPower(struct mobj_s *actor); // Use this for a custom power +void A_GiveWeapon(struct mobj_s *actor); // Gives the player weapon(s) +void A_JumpShield(struct mobj_s *actor); // Obtained Jump Shield +void A_RingShield(struct mobj_s *actor); // Obtained Ring Shield +void A_RingBox(struct mobj_s *actor); // Obtained Ring Box Tails +void A_Invincibility(struct mobj_s *actor); // Obtained Invincibility Box +void A_SuperSneakers(struct mobj_s *actor); // Obtained Super Sneakers Box +void A_BunnyHop(struct mobj_s *actor); // have bunny hop tails +void A_BubbleSpawn(struct mobj_s *actor); // Randomly spawn bubbles +void A_FanBubbleSpawn(struct mobj_s *actor); +void A_BubbleRise(struct mobj_s *actor); // Bubbles float to surface +void A_BubbleCheck(struct mobj_s *actor); // Don't draw if not underwater +void A_AwardScore(struct mobj_s *actor); +void A_ExtraLife(struct mobj_s *actor); // Extra Life +void A_BombShield(struct mobj_s *actor); // Obtained Bomb Shield +void A_WaterShield(struct mobj_s *actor); // Obtained Water Shield +void A_ForceShield(struct mobj_s *actor); // Obtained Force Shield +void A_PityShield(struct mobj_s *actor); // Obtained Pity Shield. We're... sorry. +void A_GravityBox(struct mobj_s *actor); +void A_ScoreRise(struct mobj_s *actor); // Rise the score logo +void A_ParticleSpawn(struct mobj_s *actor); +void A_AttractChase(struct mobj_s *actor); // Ring Chase +void A_DropMine(struct mobj_s *actor); // Drop Mine from Skim or Jetty-Syn Bomber +void A_FishJump(struct mobj_s *actor); // Fish Jump +void A_ThrownRing(struct mobj_s *actor); // Sparkle trail for red ring +void A_GrenadeRing(struct mobj_s *actor); // SRB2kart +void A_SetSolidSteam(struct mobj_s *actor); +void A_UnsetSolidSteam(struct mobj_s *actor); +void A_SignPlayer(struct mobj_s *actor); +void A_OverlayThink(struct mobj_s *actor); +void A_JetChase(struct mobj_s *actor); +void A_JetbThink(struct mobj_s *actor); // Jetty-Syn Bomber Thinker +void A_JetgThink(struct mobj_s *actor); // Jetty-Syn Gunner Thinker +void A_JetgShoot(struct mobj_s *actor); // Jetty-Syn Shoot Function +void A_ShootBullet(struct mobj_s *actor); // JetgShoot without reactiontime setting +void A_MinusDigging(struct mobj_s *actor); +void A_MinusPopup(struct mobj_s *actor); +void A_MinusCheck(struct mobj_s *actor); +void A_ChickenCheck(struct mobj_s *actor); +void A_MouseThink(struct mobj_s *actor); // Mouse Thinker +void A_DetonChase(struct mobj_s *actor); // Deton Chaser +void A_CapeChase(struct mobj_s *actor); // Fake little Super Sonic cape +void A_RotateSpikeBall(struct mobj_s *actor); // Spike ball rotation +void A_SlingAppear(struct mobj_s *actor); +void A_MaceRotate(struct mobj_s *actor); +void A_UnidusBall(struct mobj_s *actor); +void A_RockSpawn(struct mobj_s *actor); +void A_SetFuse(struct mobj_s *actor); +void A_CrawlaCommanderThink(struct mobj_s *actor); // Crawla Commander +void A_SmokeTrailer(struct mobj_s *actor); +void A_RingExplode(struct mobj_s *actor); +void A_OldRingExplode(struct mobj_s *actor); +void A_MixUp(struct mobj_s *actor); +void A_RecyclePowers(struct mobj_s *actor); +void A_BossScream(struct mobj_s *actor); +void A_Boss2TakeDamage(struct mobj_s *actor); +void A_GoopSplat(struct mobj_s *actor); +void A_Boss2PogoSFX(struct mobj_s *actor); +void A_Boss2PogoTarget(struct mobj_s *actor); +void A_EggmanBox(struct mobj_s *actor); +void A_TurretFire(struct mobj_s *actor); +void A_SuperTurretFire(struct mobj_s *actor); +void A_TurretStop(struct mobj_s *actor); +void A_JetJawRoam(struct mobj_s *actor); +void A_JetJawChomp(struct mobj_s *actor); +void A_PointyThink(struct mobj_s *actor); +void A_CheckBuddy(struct mobj_s *actor); +void A_HoodThink(struct mobj_s *actor); +void A_ArrowCheck(struct mobj_s *actor); +void A_SnailerThink(struct mobj_s *actor); +void A_SharpChase(struct mobj_s *actor); +void A_SharpSpin(struct mobj_s *actor); +void A_VultureVtol(struct mobj_s *actor); +void A_VultureCheck(struct mobj_s *actor); +void A_SkimChase(struct mobj_s *actor); +void A_SkullAttack(struct mobj_s *actor); +void A_LobShot(struct mobj_s *actor); +void A_FireShot(struct mobj_s *actor); +void A_SuperFireShot(struct mobj_s *actor); +void A_BossFireShot(struct mobj_s *actor); +void A_Boss7FireMissiles(struct mobj_s *actor); +void A_Boss1Laser(struct mobj_s *actor); +void A_FocusTarget(struct mobj_s *actor); +void A_Boss4Reverse(struct mobj_s *actor); +void A_Boss4SpeedUp(struct mobj_s *actor); +void A_Boss4Raise(struct mobj_s *actor); +void A_SparkFollow(struct mobj_s *actor); +void A_BuzzFly(struct mobj_s *actor); +void A_GuardChase(struct mobj_s *actor); +void A_EggShield(struct mobj_s *actor); +void A_SetReactionTime(struct mobj_s *actor); +void A_Boss1Spikeballs(struct mobj_s *actor); +void A_Boss3TakeDamage(struct mobj_s *actor); +void A_Boss3Path(struct mobj_s *actor); +void A_LinedefExecute(struct mobj_s *actor); +void A_PlaySeeSound(struct mobj_s *actor); +void A_PlayAttackSound(struct mobj_s *actor); +void A_PlayActiveSound(struct mobj_s *actor); +void A_1upThinker(struct mobj_s *actor); +void A_BossZoom(struct mobj_s *actor); //Unused +void A_Boss1Chase(struct mobj_s *actor); +void A_Boss2Chase(struct mobj_s *actor); +void A_Boss2Pogo(struct mobj_s *actor); +void A_Boss7Chase(struct mobj_s *actor); +void A_BossJetFume(struct mobj_s *actor); +void A_SpawnObjectAbsolute(struct mobj_s *actor); +void A_SpawnObjectRelative(struct mobj_s *actor); +void A_ChangeAngleRelative(struct mobj_s *actor); +void A_ChangeAngleAbsolute(struct mobj_s *actor); +void A_RollAngle(struct mobj_s *actor); +void A_ChangeRollAngleRelative(struct mobj_s *actor); +void A_ChangeRollAngleAbsolute(struct mobj_s *actor); +void A_PlaySound(struct mobj_s *actor); +void A_FindTarget(struct mobj_s *actor); +void A_FindTracer(struct mobj_s *actor); +void A_SetTics(struct mobj_s *actor); +void A_SetRandomTics(struct mobj_s *actor); +void A_ChangeColorRelative(struct mobj_s *actor); +void A_ChangeColorAbsolute(struct mobj_s *actor); +void A_MoveRelative(struct mobj_s *actor); +void A_MoveAbsolute(struct mobj_s *actor); +void A_Thrust(struct mobj_s *actor); +void A_ZThrust(struct mobj_s *actor); +void A_SetTargetsTarget(struct mobj_s *actor); +void A_SetObjectFlags(struct mobj_s *actor); +void A_SetObjectFlags2(struct mobj_s *actor); +void A_RandomState(struct mobj_s *actor); +void A_RandomStateRange(struct mobj_s *actor); +void A_DualAction(struct mobj_s *actor); +void A_RemoteAction(struct mobj_s *actor); +void A_ToggleFlameJet(struct mobj_s *actor); +void A_ItemPop(struct mobj_s *actor); // SRB2kart +void A_JawzChase(struct mobj_s *actor); // SRB2kart +void A_JawzExplode(struct mobj_s *actor); // SRB2kart +void A_SPBChase(struct mobj_s *actor); // SRB2kart +void A_MineExplode(struct mobj_s *actor); // SRB2kart +void A_BallhogExplode(struct mobj_s *actor); // SRB2kart +void A_LightningFollowPlayer(struct mobj_s *actor); // SRB2kart: Lightning shield effect player chasing +void A_FZBoomFlash(struct mobj_s *actor); // SRB2kart +void A_FZBoomSmoke(struct mobj_s *actor); // SRB2kart +void A_RandomShadowFrame(struct mobj_s *actor); //SRB2kart: Shadow spawner frame randomizer +void A_RoamingShadowThinker(struct mobj_s *actor); // SRB2kart: Roaming Shadow moving + attacking players. +void A_MayonakaArrow(struct mobj_s *actor); //SRB2kart: midnight channel arrow sign +void A_ReaperThinker(struct mobj_s *actor); //SRB2kart: mementos reaper +void A_MementosTPParticles(struct mobj_s *actor); //SRB2kart: mementos teleporter particles. Man that's a lot of actions for my shite. +void A_FlameParticle(struct mobj_s *actor); // SRB2kart +void A_OrbitNights(struct mobj_s *actor); +void A_GhostMe(struct mobj_s *actor); +void A_SetObjectState(struct mobj_s *actor); +void A_SetObjectTypeState(struct mobj_s *actor); +void A_KnockBack(struct mobj_s *actor); +void A_PushAway(struct mobj_s *actor); +void A_RingDrain(struct mobj_s *actor); +void A_SplitShot(struct mobj_s *actor); +void A_MissileSplit(struct mobj_s *actor); +void A_MultiShot(struct mobj_s *actor); +void A_InstaLoop(struct mobj_s *actor); +void A_Custom3DRotate(struct mobj_s *actor); +void A_SearchForPlayers(struct mobj_s *actor); +void A_CheckRandom(struct mobj_s *actor); +void A_CheckTargetRings(struct mobj_s *actor); +void A_CheckRings(struct mobj_s *actor); +void A_CheckTotalRings(struct mobj_s *actor); +void A_CheckHealth(struct mobj_s *actor); +void A_CheckRange(struct mobj_s *actor); +void A_CheckHeight(struct mobj_s *actor); +void A_CheckTrueRange(struct mobj_s *actor); +void A_CheckThingCount(struct mobj_s *actor); +void A_CheckAmbush(struct mobj_s *actor); +void A_CheckCustomValue(struct mobj_s *actor); +void A_CheckCusValMemo(struct mobj_s *actor); +void A_SetCustomValue(struct mobj_s *actor); +void A_UseCusValMemo(struct mobj_s *actor); +void A_RelayCustomValue(struct mobj_s *actor); +void A_CusValAction(struct mobj_s *actor); +void A_ForceStop(struct mobj_s *actor); +void A_ForceWin(struct mobj_s *actor); +void A_SpikeRetract(struct mobj_s *actor); +void A_InfoState(struct mobj_s *actor); +void A_Repeat(struct mobj_s *actor); +void A_SetScale(struct mobj_s *actor); +void A_RemoteDamage(struct mobj_s *actor); +void A_HomingChase(struct mobj_s *actor); +void A_TrapShot(struct mobj_s *actor); +void A_VileTarget(struct mobj_s *actor); +void A_VileAttack(struct mobj_s *actor); +void A_VileFire(struct mobj_s *actor); +void A_BrakChase(struct mobj_s *actor); +void A_BrakFireShot(struct mobj_s *actor); +void A_BrakLobShot(struct mobj_s *actor); +void A_NapalmScatter(struct mobj_s *actor); +void A_SpawnFreshCopy(struct mobj_s *actor); extern boolean actionsoverridden[NUMACTIONS]; diff --git a/src/p_mobj.c b/src/p_mobj.c index f6001d457..ec60c28e4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -5883,7 +5883,6 @@ static void P_RemoveShadow(mobj_t *thing) } } -void A_BossDeath(mobj_t *mo); // AI for the Koopa boss. static void P_KoopaThinker(mobj_t *koopa) { @@ -8748,6 +8747,7 @@ void P_MobjThinker(mobj_t *mobj) } break; } + if (P_MobjWasRemoved(mobj)) return; @@ -8802,6 +8802,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->fuse) { mobj->fuse--; + if (!mobj->fuse) { subsector_t *ss; @@ -8809,196 +8810,199 @@ void P_MobjThinker(mobj_t *mobj) mobj_t *flagmo, *newmobj; if (!LUAh_MobjFuse(mobj) && !P_MobjWasRemoved(mobj)) - switch (mobj->type) { - // gargoyle and snowman handled in P_PushableThinker, not here - case MT_THROWNGRENADE: - case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: - P_SetMobjState(mobj, mobj->info->deathstate); - break; - case MT_BLUEFLAG: - case MT_REDFLAG: - if (mobj->spawnpoint) - { - x = mobj->spawnpoint->x << FRACBITS; - y = mobj->spawnpoint->y << FRACBITS; - ss = R_PointInSubsector(x, y); - if (mobj->spawnpoint->options & MTF_OBJECTFLIP) + switch (mobj->type) + { + // gargoyle and snowman handled in P_PushableThinker, not here + case MT_THROWNGRENADE: + case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: + P_SetMobjState(mobj, mobj->info->deathstate); + break; + case MT_BLUEFLAG: + case MT_REDFLAG: + if (mobj->spawnpoint) { - z = ss->sector->ceilingheight - mobjinfo[mobj->type].height; - if (mobj->spawnpoint->options >> ZSHIFT) - z -= (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; + x = mobj->spawnpoint->x << FRACBITS; + y = mobj->spawnpoint->y << FRACBITS; + ss = R_PointInSubsector(x, y); + if (mobj->spawnpoint->options & MTF_OBJECTFLIP) + { + z = ss->sector->ceilingheight - mobjinfo[mobj->type].height; + if (mobj->spawnpoint->options >> ZSHIFT) + z -= (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; + } + else + { + z = ss->sector->floorheight; + if (mobj->spawnpoint->options >> ZSHIFT) + z += (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; + } + flagmo = P_SpawnMobj(x, y, z, mobj->type); + flagmo->spawnpoint = mobj->spawnpoint; + if (mobj->spawnpoint->options & MTF_OBJECTFLIP) + { + flagmo->eflags |= MFE_VERTICALFLIP; + flagmo->flags2 |= MF2_OBJECTFLIP; + } + + if (mobj->type == MT_REDFLAG) + { + if (!(mobj->flags2 & MF2_JUSTATTACKED)) + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); + + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 1 || splitscreen) + S_StartSound(NULL, sfx_hoop1); + else if (players[consoleplayer].ctfteam == 2) + S_StartSound(NULL, sfx_hoop3); + + redflag = flagmo; + } + else // MT_BLUEFLAG + { + if (!(mobj->flags2 & MF2_JUSTATTACKED)) + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); + + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 2 || splitscreen) + S_StartSound(NULL, sfx_hoop1); + else if (players[consoleplayer].ctfteam == 1) + S_StartSound(NULL, sfx_hoop3); + + blueflag = flagmo; + } } - else + P_RemoveMobj(mobj); + return; + case MT_YELLOWTV: // Ring shield box + case MT_BLUETV: // Force shield box + case MT_GREENTV: // Water shield box + case MT_BLACKTV: // Bomb shield box + case MT_WHITETV: // Jump shield box + case MT_SNEAKERTV: // Super Sneaker box + case MT_SUPERRINGBOX: // 10-Ring box + case MT_REDRINGBOX: // Red Team 10-Ring box + case MT_BLUERINGBOX: // Blue Team 10-Ring box + case MT_INV: // Invincibility box + case MT_MIXUPBOX: // Teleporter Mixup box + case MT_RECYCLETV: // Recycler box + case MT_SCORETVSMALL: + case MT_SCORETVLARGE: + case MT_PRUP: // 1up! + case MT_EGGMANBOX: // Eggman box + case MT_GRAVITYBOX: // Gravity box + case MT_QUESTIONBOX: + if ((mobj->flags2 & MF2_AMBUSH || mobj->flags2 & MF2_STRONGBOX) && mobj->type != MT_QUESTIONBOX) { - z = ss->sector->floorheight; - if (mobj->spawnpoint->options >> ZSHIFT) - z += (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; - } - flagmo = P_SpawnMobj(x, y, z, mobj->type); - flagmo->spawnpoint = mobj->spawnpoint; - if (mobj->spawnpoint->options & MTF_OBJECTFLIP) - { - flagmo->eflags |= MFE_VERTICALFLIP; - flagmo->flags2 |= MF2_OBJECTFLIP; - } + mobjtype_t spawnchance[64]; + INT32 numchoices = 0, i = 0; - if (mobj->type == MT_REDFLAG) - { - if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); - - // Assumedly in splitscreen players will be on opposing teams - if (players[consoleplayer].ctfteam == 1 || splitscreen) - S_StartSound(NULL, sfx_hoop1); - else if (players[consoleplayer].ctfteam == 2) - S_StartSound(NULL, sfx_hoop3); - - redflag = flagmo; - } - else // MT_BLUEFLAG - { - if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); - - // Assumedly in splitscreen players will be on opposing teams - if (players[consoleplayer].ctfteam == 2 || splitscreen) - S_StartSound(NULL, sfx_hoop1); - else if (players[consoleplayer].ctfteam == 1) - S_StartSound(NULL, sfx_hoop3); - - blueflag = flagmo; - } - } - P_RemoveMobj(mobj); - return; - case MT_YELLOWTV: // Ring shield box - case MT_BLUETV: // Force shield box - case MT_GREENTV: // Water shield box - case MT_BLACKTV: // Bomb shield box - case MT_WHITETV: // Jump shield box - case MT_SNEAKERTV: // Super Sneaker box - case MT_SUPERRINGBOX: // 10-Ring box - case MT_REDRINGBOX: // Red Team 10-Ring box - case MT_BLUERINGBOX: // Blue Team 10-Ring box - case MT_INV: // Invincibility box - case MT_MIXUPBOX: // Teleporter Mixup box - case MT_RECYCLETV: // Recycler box - case MT_SCORETVSMALL: - case MT_SCORETVLARGE: - case MT_PRUP: // 1up! - case MT_EGGMANBOX: // Eggman box - case MT_GRAVITYBOX: // Gravity box - case MT_QUESTIONBOX: - if ((mobj->flags2 & MF2_AMBUSH || mobj->flags2 & MF2_STRONGBOX) && mobj->type != MT_QUESTIONBOX) - { - mobjtype_t spawnchance[64]; - INT32 numchoices = 0, i = 0; - -// This define should make it a lot easier to organize and change monitor weights + // This define should make it a lot easier to organize and change monitor weights #define SETMONITORCHANCES(type, strongboxamt, weakboxamt) \ -for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) spawnchance[numchoices++] = type + for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) spawnchance[numchoices++] = type - // Type SRM WRM - SETMONITORCHANCES(MT_SNEAKERTV, 0, 10); // Super Sneakers - SETMONITORCHANCES(MT_INV, 2, 0); // Invincibility - SETMONITORCHANCES(MT_WHITETV, 3, 8); // Whirlwind Shield - SETMONITORCHANCES(MT_GREENTV, 3, 8); // Elemental Shield - SETMONITORCHANCES(MT_YELLOWTV, 2, 0); // Attraction Shield - SETMONITORCHANCES(MT_BLUETV, 3, 3); // Force Shield - SETMONITORCHANCES(MT_BLACKTV, 2, 0); // Armageddon Shield - SETMONITORCHANCES(MT_MIXUPBOX, 0, 1); // Teleporters - SETMONITORCHANCES(MT_RECYCLETV, 0, 1); // Recycler - SETMONITORCHANCES(MT_PRUP, 1, 1); // 1-Up - // ====================================== - // Total 16 32 + // Type SRM WRM + SETMONITORCHANCES(MT_SNEAKERTV, 0, 10); // Super Sneakers + SETMONITORCHANCES(MT_INV, 2, 0); // Invincibility + SETMONITORCHANCES(MT_WHITETV, 3, 8); // Whirlwind Shield + SETMONITORCHANCES(MT_GREENTV, 3, 8); // Elemental Shield + SETMONITORCHANCES(MT_YELLOWTV, 2, 0); // Attraction Shield + SETMONITORCHANCES(MT_BLUETV, 3, 3); // Force Shield + SETMONITORCHANCES(MT_BLACKTV, 2, 0); // Armageddon Shield + SETMONITORCHANCES(MT_MIXUPBOX, 0, 1); // Teleporters + SETMONITORCHANCES(MT_RECYCLETV, 0, 1); // Recycler + SETMONITORCHANCES(MT_PRUP, 1, 1); // 1-Up + // ====================================== + // Total 16 32 #undef SETMONITORCHANCES - i = P_RandomKey(numchoices); // Gotta love those random numbers! - newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, spawnchance[i]); + i = P_RandomKey(numchoices); // Gotta love those random numbers! + newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, spawnchance[i]); - // Transfer flags2 (strongbox, objectflip, ambush) - newmobj->flags2 = mobj->flags2; - } - else - { - newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); - - // Transfer flags2 (strongbox, objectflip) - newmobj->flags2 = mobj->flags2; - } - P_RemoveMobj(mobj); // make sure they disappear - return; - case MT_RANDOMITEM: - if (G_BattleGametype()) - { - if (mobj->threshold != 69) - break; - } - else - { - // Respawn from mapthing if you have one! - if (mobj->spawnpoint) - { - P_SpawnMapThing(mobj->spawnpoint); - newmobj = mobj->spawnpoint->mobj; // this is set to the new mobj in P_SpawnMapThing + // Transfer flags2 (strongbox, objectflip, ambush) + newmobj->flags2 = mobj->flags2; } else + { newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); - // Transfer flags2 (strongbox, objectflip) - newmobj->flags2 = mobj->flags2 & ~MF2_DONTDRAW; - } - P_RemoveMobj(mobj); // make sure they disappear - return; - case MT_METALSONIC_BATTLE: - break; // don't remove - case MT_SPIKE: - P_SetMobjState(mobj, mobj->state->nextstate); - mobj->fuse = mobj->info->speed; - if (mobj->spawnpoint) - mobj->fuse += mobj->spawnpoint->angle; - break; - case MT_NIGHTSCORE: - P_RemoveMobj(mobj); - return; - case MT_PLAYER: - break; // don't remove - case MT_SMK_ICEBLOCK: - { - mobj_t *cur = mobj->hnext, *next; - UINT8 i; - - for (i = 0; i < 5; i++) - { - mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS); - debris->angle = FixedAngle(P_RandomRange(0,360)<angle, P_RandomRange(3,18)*(FRACUNIT/4)); - debris->momz = P_RandomRange(4,8)<flags2 = mobj->flags2; } - - while (cur && !P_MobjWasRemoved(cur)) + P_RemoveMobj(mobj); // make sure they disappear + return; + case MT_RANDOMITEM: + if (G_BattleGametype()) { - next = cur->hnext; - P_RemoveMobj(cur); - cur = next; + if (mobj->threshold != 69) + break; } + else + { + // Respawn from mapthing if you have one! + if (mobj->spawnpoint) + { + P_SpawnMapThing(mobj->spawnpoint); + newmobj = mobj->spawnpoint->mobj; // this is set to the new mobj in P_SpawnMapThing + } + else + newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); + // Transfer flags2 (strongbox, objectflip) + newmobj->flags2 = mobj->flags2 & ~MF2_DONTDRAW; + } + P_RemoveMobj(mobj); // make sure they disappear + return; + case MT_METALSONIC_BATTLE: + break; // don't remove + case MT_SPIKE: + P_SetMobjState(mobj, mobj->state->nextstate); + mobj->fuse = mobj->info->speed; + if (mobj->spawnpoint) + mobj->fuse += mobj->spawnpoint->angle; + break; + case MT_NIGHTSCORE: P_RemoveMobj(mobj); return; - } - default: - P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL. - break; + case MT_PLAYER: + break; // don't remove + case MT_SMK_ICEBLOCK: + { + mobj_t *cur = mobj->hnext, *next; + UINT8 i; + + for (i = 0; i < 5; i++) + { + mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS); + debris->angle = FixedAngle(P_RandomRange(0,360)<angle, P_RandomRange(3,18)*(FRACUNIT/4)); + debris->momz = P_RandomRange(4,8)<hnext; + P_RemoveMobj(cur); + cur = next; + } + + P_RemoveMobj(mobj); + return; + } + default: + P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL. + break; + } + + if (P_MobjWasRemoved(mobj)) + return; } - if (P_MobjWasRemoved(mobj)) - return; + else if (((mobj->type == MT_RANDOMITEM && mobj->threshold == 69) || mobj->type == MT_EGGMANITEM || mobj->type == MT_FALLINGROCK) && mobj->fuse <= TICRATE) + mobj->flags2 ^= MF2_DONTDRAW; } - else if (((mobj->type == MT_RANDOMITEM && mobj->threshold == 69) || mobj->type == MT_EGGMANITEM || mobj->type == MT_FALLINGROCK) && mobj->fuse <= TICRATE) - mobj->flags2 ^= MF2_DONTDRAW; } I_Assert(mobj != NULL); diff --git a/src/r_draw8.c b/src/r_draw8.c index b67311d76..4e69d58c7 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -643,7 +643,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) } } -#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) +#define PLANELIGHTFLOAT ((float)(BASEVIDWIDTH * BASEVIDWIDTH) / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) /** \brief The R_DrawTiltedSpan_8 function Draw slopes! Holy sheit! diff --git a/src/r_main.c b/src/r_main.c index fc753941c..fb91a8df8 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1667,7 +1667,6 @@ void R_RenderPlayerView(player_t *player) } // Draw over the fourth screen so you don't have to stare at a HOM :V else if (splitscreen == 2 && player == &players[displayplayers[2]]) -#if 1 { // V_DrawPatchFill, but for the fourth screen only patch_t *pat = W_CachePatchName("SRB2BACK", PU_CACHE); @@ -1680,9 +1679,6 @@ void R_RenderPlayerView(player_t *player) V_DrawScaledPatch(x, y, V_NOSCALESTART, pat); } } -#else - V_DrawFill(viewwidth, viewheight, viewwidth, viewheight, 31|V_NOSCALESTART); -#endif // load previous saved value of skyVisible for the player for (i = 0; i <= splitscreen; i++) diff --git a/src/r_plane.c b/src/r_plane.c index 6299edd9e..8a257f4de 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -332,10 +332,12 @@ void R_ClearPlanes(void) numffloors = 0; for (i = 0; i < MAXVISPLANES; i++) - for (*freehead = visplanes[i], visplanes[i] = NULL; - freehead && *freehead ;) { - freehead = &(*freehead)->next; + for (*freehead = visplanes[i], visplanes[i] = NULL; + freehead && *freehead ;) + { + freehead = &(*freehead)->next; + } } lastopening = openings; @@ -814,7 +816,8 @@ void R_DrawSinglePlane(visplane_t *pl) #endif spanfunc = basespanfunc; - if (pl->polyobj && pl->polyobj->translucency != 0) { + if (pl->polyobj && pl->polyobj->translucency != 0) + { spanfunc = R_DrawTranslucentSpan_8; // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) @@ -834,8 +837,8 @@ void R_DrawSinglePlane(visplane_t *pl) else light = LIGHTLEVELS-1; - } else - if (pl->ffloor) + } + else if (pl->ffloor) { // Don't draw planes that shouldn't be drawn. for (rover = pl->ffloor->target->ffloors; rover; rover = rover->next) @@ -1099,9 +1102,9 @@ void R_DrawSinglePlane(visplane_t *pl) spanfunc = R_DrawTiltedSpan_8; planezlight = scalelight[light]; - } else - - planezlight = zlight[light]; + } + else + planezlight = zlight[light]; // set the maximum value for unsigned pl->top[pl->maxx+1] = 0xffff; @@ -1210,9 +1213,9 @@ void R_PlaneBounds(visplane_t *plane) for (i = plane->minx + 1; i <= plane->maxx; i++) { if (plane->top[i] < hi) - hi = plane->top[i]; + hi = plane->top[i]; if (plane->bottom[i] > low) - low = plane->bottom[i]; + low = plane->bottom[i]; } plane->high = hi; plane->low = low; diff --git a/src/r_segs.c b/src/r_segs.c index 7cb7e7397..fababbef4 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -901,7 +901,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (slopeskew) dc_texturemid = left_top; else - dc_texturemid = *pfloor->topheight - viewz; + dc_texturemid = *pfloor->topheight - viewz; if (newline) { @@ -1696,7 +1696,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) lastopening = openings + pos; if (oldopenings == NULL) - return; + return; // borrowed fix from *cough* zdoom *cough* // [RH] We also need to adjust the openings pointers that @@ -1876,14 +1876,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) texheight = textureheight[midtexture]; // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; - if (linedef->flags & ML_EFFECT2) { + if (linedef->flags & ML_EFFECT2) + { if (linedef->flags & ML_DONTPEGBOTTOM) rw_midtexturemid = frontsector->floorheight + texheight - viewz; else rw_midtexturemid = frontsector->ceilingheight - viewz; } - else - if (linedef->flags & ML_DONTPEGBOTTOM) + else if (linedef->flags & ML_DONTPEGBOTTOM) { rw_midtexturemid = worldbottom + texheight; rw_midtextureslide = floorfrontslide; @@ -2358,32 +2358,36 @@ void R_StoreWallRange(INT32 start, INT32 stop) maskedtextureheight = ds_p->maskedtextureheight; // note to red, this == &(ds_p->maskedtextureheight[0]) - if (curline->polyseg) { // use REAL front and back floors please, so midtexture rendering isn't mucked up + if (curline->polyseg) + { // use REAL front and back floors please, so midtexture rendering isn't mucked up rw_midtextureslide = rw_midtexturebackslide = 0; if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; else rw_midtexturemid = rw_midtextureback = min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz; - } else - // Set midtexture starting height - if (linedef->flags & ML_EFFECT2) { // Ignore slopes when texturing + } + else if (linedef->flags & ML_EFFECT2) // Set midtexture starting height + { // Ignore slopes when texturing rw_midtextureslide = rw_midtexturebackslide = 0; if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) rw_midtexturemid = rw_midtextureback = max(frontsector->floorheight, backsector->floorheight) - viewz; else rw_midtexturemid = rw_midtextureback = min(frontsector->ceilingheight, backsector->ceilingheight) - viewz; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { + } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) + { rw_midtexturemid = worldbottom; rw_midtextureslide = floorfrontslide; rw_midtextureback = worldlow; rw_midtexturebackslide = floorbackslide; - } else { + } else + { rw_midtexturemid = worldtop; rw_midtextureslide = ceilingfrontslide; rw_midtextureback = worldhigh; rw_midtexturebackslide = ceilingbackslide; } + rw_midtexturemid += sidedef->rowoffset; rw_midtextureback += sidedef->rowoffset; -- 2.54.0 From 48f36ca8f3e6a0b7583916db69f567090cb92243 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 16 Jun 2024 16:17:24 +0200 Subject: [PATCH 118/525] 35/2 != 17 = 17.5 ? --- src/d_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 5f7b375f0..0b4b2cc1c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -626,7 +626,8 @@ static int menuInputDelayTimer = 0; void D_SRB2Loop(void) { - tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS; + tic_t entertic = 0, oldentertics = 0, realtics = 0; + double rendertimeout = INFTICS; double deltatics = 0.0; double deltasecs = 0.0; @@ -728,7 +729,7 @@ void D_SRB2Loop(void) if (lastdraw || singletics || gametic > rendergametic) { rendergametic = gametic; - rendertimeout = entertic + TICRATE/17; + rendertimeout = entertic + TICRATE/(TICRATE/2); doDisplay = true; } -- 2.54.0 From b6cf933159093dae76c639f618561f17162925b0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 09:50:25 +0200 Subject: [PATCH 119/525] remove R_Pointtoangle toggle its bloat, the difference is negigble at best --- src/hardware/hw_main.c | 36 ++++++------------------------------ src/m_menu.c | 4 ---- src/r_bsp.c | 25 ++++--------------------- src/r_main.c | 28 ---------------------------- src/r_main.h | 1 - src/tables.h | 2 +- 6 files changed, 11 insertions(+), 85 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b50e05e61..5b07ac065 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2590,16 +2590,8 @@ static void HWR_AddLine(seg_t *line) } // OPTIMIZE: quickly reject orthogonal back sides. - if (cv_pointoangleexor64.value) - { - angle1 = R_PointToAngle64(v1x, v1y); - angle2 = R_PointToAngle64(v2x, v2y); - } - else - { - angle1 = R_PointToAngleEx(viewx, viewy, v1x, v1y); - angle2 = R_PointToAngleEx(viewx, viewy, v2x, v2y); - } + angle1 = R_PointToAngle64(v1x, v1y); + angle2 = R_PointToAngle64(v2x, v2y); // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! if (angle2 - angle1 < ANGLE_180 || !gr_curline->linedef) @@ -2795,16 +2787,8 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) if (mindist > current_bsp_culling_distance) return false; } - if (cv_pointoangleexor64.value) - { - angle1 = R_PointToAngle64(px1, py1); - angle2 = R_PointToAngle64(px2, py2); - } - else - { - angle1 = R_PointToAngleEx(viewx, viewy, px1, py1); - angle2 = R_PointToAngleEx(viewx, viewy, px2, py2); - } + angle1 = R_PointToAngle64(px1, py1); + angle2 = R_PointToAngle64(px2, py2); return gld_clipper_SafeCheckRange(angle2, angle1); } @@ -5565,16 +5549,8 @@ static void HWR_PortalClipping(gl_portal_t *portal) line_t *line = &lines[portal->clipline]; - if (cv_pointoangleexor64.value) - { - angle1 = R_PointToAngle64(line->v1->x, line->v1->y); - angle2 = R_PointToAngle64(line->v2->x, line->v2->y); - } - else - { - angle1 = R_PointToAngleEx(viewx, viewy, line->v1->x, line->v1->y); - angle2 = R_PointToAngleEx(viewx, viewy, line->v2->x, line->v2->y); - } + angle1 = R_PointToAngle64(line->v1->x, line->v1->y); + angle2 = R_PointToAngle64(line->v2->x, line->v2->y); // clip things that are not inside the portal window from our viewpoint gld_clipper_SafeAddClipRange(angle2, angle1); diff --git a/src/m_menu.c b/src/m_menu.c index 5fc65994f..1440c0f83 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1462,8 +1462,6 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 42}, - {IT_STRING | IT_CVAR, NULL, "Clipping R_PointToAngle Version", &cv_pointoangleexor64, 49}, - {IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 56}, {IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 61}, #ifdef HWRENDER @@ -1489,7 +1487,6 @@ static const char* OP_ExpTooltips[] = "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", "When weather is on this will cut the object amount used in half.", "Toggle being able to see the sky.", - "Which version of R_PointToAngle should\nbe used for Sector Clipping?\n64 may fix rendering issues on larger maps\nat the cost of performance.", "Hides 3DFloors which are not visible\npotentially resulting in a performance boost.", "Hides Sprites which are not visible\npotentially resulting in a performance boost.", #ifdef HWRENDER @@ -1513,7 +1510,6 @@ enum op_exp_precipinter, op_exp_lessprecip, op_exp_skybox, - op_exp_angleshit, op_exp_ffclip, op_exp_sprclip, #ifdef HWRENDER diff --git a/src/r_bsp.c b/src/r_bsp.c index dc409feba..fbb2ea35a 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -420,17 +420,8 @@ static void R_AddLine(seg_t *line) return; // big room fix - - if (cv_pointoangleexor64.value) - { - angle1 = R_PointToAngle64(line->v1->x, line->v1->y); - angle2 = R_PointToAngle64(line->v2->x, line->v2->y); - } - else - { - angle1 = R_PointToAngleEx(viewx, viewy, line->v1->x, line->v1->y); - angle2 = R_PointToAngleEx(viewx, viewy, line->v2->x, line->v2->y); - } + angle1 = R_PointToAngle64(line->v1->x, line->v1->y); + angle2 = R_PointToAngle64(line->v2->x, line->v2->y); curline = line; @@ -638,16 +629,8 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) check = checkcoord[boxpos]; // big room fix - if (cv_pointoangleexor64.value) - { - angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; - angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; - } - else - { - angle1 = R_PointToAngleEx(viewx, viewy, bspcoord[check[0]], bspcoord[check[1]]) - viewangle; - angle2 = R_PointToAngleEx(viewx, viewy, bspcoord[check[2]], bspcoord[check[3]]) - viewangle; - } + angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; + angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; if ((signed)angle1 < (signed)angle2) { diff --git a/src/r_main.c b/src/r_main.c index fb91a8df8..3dec911e5 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -220,9 +220,6 @@ consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t pointoangle_cons_t[] = {{0, "Ex"}, {1, "64"}, {0, NULL}}; -consvar_t cv_pointoangleexor64 = {"r_pointtoangle", "64", CV_SAVE, pointoangle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - void SplitScreen_OnChange(void) { UINT8 i; @@ -426,29 +423,6 @@ angle_t R_PointToAngle64(INT64 x, INT64 y) 0; } -angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1) -{ - INT64 dx = x1-x2; - INT64 dy = y1-y2; - if (dx < INT32_MIN || dx > INT32_MAX || dy < INT32_MIN || dy > INT32_MAX) - { - x1 = (int)(dx / 2 + x2); - y1 = (int)(dy / 2 + y2); - } - return (y1 -= y2, (x1 -= x2) || y1) ? - x1 >= 0 ? - y1 >= 0 ? - (x1 > y1) ? tantoangle[SlopeDivEx(y1,x1)] : // octant 0 - ANGLE_90-tantoangle[SlopeDivEx(x1,y1)] : // octant 1 - x1 > (y1 = -y1) ? 0-tantoangle[SlopeDivEx(y1,x1)] : // octant 8 - ANGLE_270+tantoangle[SlopeDivEx(x1,y1)] : // octant 7 - y1 >= 0 ? (x1 = -x1) > y1 ? ANGLE_180-tantoangle[SlopeDivEx(y1,x1)] : // octant 3 - ANGLE_90 + tantoangle[SlopeDivEx(x1,y1)] : // octant 2 - (x1 = -x1) > (y1 = -y1) ? ANGLE_180+tantoangle[SlopeDivEx(y1,x1)] : // octant 4 - ANGLE_270-tantoangle[SlopeDivEx(x1,y1)] : // octant 5 - 0; -} - angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) { return (y -= pviewy, (x -= pviewx) || y) ? @@ -1902,8 +1876,6 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_uncappedhud); CV_RegisterVar(&cv_maxportals); - - CV_RegisterVar(&cv_pointoangleexor64); CV_RegisterVar(&cv_grmaxinterpdist); diff --git a/src/r_main.h b/src/r_main.h index 7c2249873..1a589088d 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -72,7 +72,6 @@ INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *node); INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line); angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); -angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1); angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); fixed_t R_PointToDist(fixed_t x, fixed_t y); fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); diff --git a/src/tables.h b/src/tables.h index 761a6499e..0ea09caf6 100644 --- a/src/tables.h +++ b/src/tables.h @@ -86,7 +86,7 @@ extern angle_t tantoangle[SLOPERANGE+1]; // Utility function, called by R_PointToAngle. FUNCMATH unsigned SlopeDiv(unsigned num, unsigned den); -// Only called by R_PointToAngleEx +// Only called by R_PointToAngle64 FUNCMATH UINT64 SlopeDivEx(unsigned int num, unsigned int den); // 360 - angle_t(ANGLE_45) = ANGLE_315 -- 2.54.0 From 59ab6572b1e31780ca79408211fa24248c844663 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 09:54:03 +0200 Subject: [PATCH 120/525] remove cv_fofzfightfix more bloat --- src/hardware/hw_main.c | 10 +++------- src/hardware/hw_main.h | 1 - 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5b07ac065..de11b2436 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -107,8 +107,6 @@ consvar_t cv_grframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT consvar_t cv_grfofcut = {"gr_fofcut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fofzfightfix = {"fofzfightfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_splitwallfix = {"splitwallfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_slopepegfix = {"slopepegfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1968,15 +1966,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Render midtextures on two-sided lines with a z-buffer offset. // This will cause the midtexture appear on top, if a FOF overlaps with it. - if (cv_fofzfightfix.value) - blendmode |= PF_Decal; + blendmode |= PF_Decal; if (!gl_drawing_stencil && gr_frontsector->numlights) { if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, cv_fofzfightfix.value ? PF_Decal : 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); else - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, cv_fofzfightfix.value ? PF_Decal : 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, PF_Decal); } else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); @@ -5952,7 +5949,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grbatching); CV_RegisterVar(&cv_grfofcut); - CV_RegisterVar(&cv_fofzfightfix); CV_RegisterVar(&cv_splitwallfix); CV_RegisterVar(&cv_slopepegfix); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index b5a775365..52510ad4a 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -156,7 +156,6 @@ extern consvar_t cv_grshaders; extern consvar_t cv_grframebuffer; #endif extern consvar_t cv_grfofcut; -extern consvar_t cv_fofzfightfix; extern consvar_t cv_splitwallfix; extern consvar_t cv_slopepegfix; extern consvar_t cv_grshearing; -- 2.54.0 From 18aa3689d910b79a73a21331e94e6233a23795b4 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 09:54:43 +0200 Subject: [PATCH 121/525] m_menu moment --- src/m_menu.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 1440c0f83..86c7227cf 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1474,7 +1474,6 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 87}, {IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 92}, - {IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 97}, {IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 102}, #endif }; @@ -1497,7 +1496,6 @@ static const char* OP_ExpTooltips[] = "Change the depth of the Palette in Palette rendering mod\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", "Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.", "Fixes issues that resulted in Textures not being properly skewed\n example: Fences on slopes that didnt show proper.\n This may be CPU heavy and result in worse performance in some cases.", - "Fixes issues that resulted in Textures on Floor over Floors\nZFighting heavily.", "Toggle for FOF wall cutoff with slopes.", #endif }; @@ -1520,7 +1518,6 @@ enum op_exp_paldepth, op_exp_spltwal, op_exp_pegging, - op_exp_fofzfight, op_exp_fofcut, #endif }; @@ -4526,7 +4523,6 @@ void M_Init(void) #endif OP_ExpOptionsMenu[op_exp_spltwal].status = IT_DISABLED; OP_ExpOptionsMenu[op_exp_pegging].status = IT_DISABLED; - OP_ExpOptionsMenu[op_exp_fofzfight].status = IT_DISABLED; OP_ExpOptionsMenu[op_exp_fofcut].status = IT_DISABLED; } -- 2.54.0 From cca9c51315569bed84a9313382b8489ae4f1f7c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 09:57:23 +0200 Subject: [PATCH 122/525] remove cv_slopepegfix same as the other ones --- src/hardware/hw_main.c | 108 ++++++++--------------------------------- src/hardware/hw_main.h | 1 - src/m_menu.c | 4 -- 3 files changed, 20 insertions(+), 93 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index de11b2436..7006fe43c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -109,8 +109,6 @@ consvar_t cv_grfofcut = {"gr_fofcut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NU consvar_t cv_splitwallfix = {"splitwallfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_slopepegfix = {"slopepegfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - static CV_PossibleValue_t grrenderdistance_cons_t[] = { {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, {6, "12288"}, {7, "16384"}, {0, NULL}}; @@ -1870,97 +1868,32 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); - if (cv_slopepegfix.value) + if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) { - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) - { - texturevpeg = midtexheight - h + polybottom; - texturevpegslope = midtexheight - hS + polybottomslope; - } - else - { - texturevpeg = polytop - h; - texturevpegslope = polytopslope - hS; - } - - wallVerts[3].t = texturevpeg * grTex->scaleY; - wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; - wallVerts[2].t = texturevpegslope * grTex->scaleY; - wallVerts[1].t = (hS - lS + texturevpegslope) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // set top/bottom coords - // Take the texture peg into account, rather than changing the offsets past - // where the polygon might not be. - wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[0].y = FIXED_TO_FLOAT(l); - wallVerts[2].y = FIXED_TO_FLOAT(hS); - wallVerts[1].y = FIXED_TO_FLOAT(lS); + texturevpeg = midtexheight - h + polybottom; + texturevpegslope = midtexheight - hS + polybottomslope; } else { - // PEGGING - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) - texturevpeg = textureheight[gr_sidedef->midtexture]*repeats - h + polybottom; - else - texturevpeg = polytop - h; - - wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (h - l + texturevpeg) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // set top/bottom coords - // Take the texture peg into account, rather than changing the offsets past - // where the polygon might not be. - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(l); - - // Correct to account for slopes - { - fixed_t midtextureslant; - - if (gr_linedef->flags & ML_EFFECT2) - midtextureslant = 0; - else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) - midtextureslant = worldlow < worldbottom - ? worldbottomslope-worldbottom - : worldlowslope-worldlow; - else - midtextureslant = worldtop < worldhigh - ? worldtopslope-worldtop - : worldhighslope-worldhigh; - - polytop += midtextureslant; - polybottom += midtextureslant; - - highcut += worldtop < worldhigh - ? worldtopslope-worldtop - : worldhighslope-worldhigh; - lowcut += worldlow < worldbottom - ? worldbottomslope-worldbottom - : worldlowslope-worldlow; - - // Texture stuff - h = min(highcut, polytop); - l = max(polybottom, lowcut); - - { - // PEGGING - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) - texturevpeg = textureheight[gr_sidedef->midtexture]*repeats - h + polybottom; - else - texturevpeg = polytop - h; - wallVerts[2].t = texturevpeg * grTex->scaleY; - wallVerts[1].t = (h - l + texturevpeg) * grTex->scaleY; - } - - wallVerts[2].y = FIXED_TO_FLOAT(h); - wallVerts[1].y = FIXED_TO_FLOAT(l); - } + texturevpeg = polytop - h; + texturevpegslope = polytopslope - hS; } + wallVerts[3].t = texturevpeg * grTex->scaleY; + wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; + wallVerts[2].t = texturevpegslope * grTex->scaleY; + wallVerts[1].t = (hS - lS + texturevpegslope) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // set top/bottom coords + // Take the texture peg into account, rather than changing the offsets past + // where the polygon might not be. + wallVerts[3].y = FIXED_TO_FLOAT(h); + wallVerts[0].y = FIXED_TO_FLOAT(l); + wallVerts[2].y = FIXED_TO_FLOAT(hS); + wallVerts[1].y = FIXED_TO_FLOAT(lS); + // TODO: Actually use the surface's flags so that I don't have to do this FUINT blendmode = Surf.PolyFlags; @@ -5950,7 +5883,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grbatching); CV_RegisterVar(&cv_grfofcut); CV_RegisterVar(&cv_splitwallfix); - CV_RegisterVar(&cv_slopepegfix); CV_RegisterVar(&cv_grrenderdistance); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 52510ad4a..ce97afba3 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -157,7 +157,6 @@ extern consvar_t cv_grframebuffer; #endif extern consvar_t cv_grfofcut; extern consvar_t cv_splitwallfix; -extern consvar_t cv_slopepegfix; extern consvar_t cv_grshearing; extern consvar_t cv_grfov; extern consvar_t cv_grmdls; diff --git a/src/m_menu.c b/src/m_menu.c index 86c7227cf..589772964 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1473,7 +1473,6 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 80}, {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 87}, - {IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 92}, {IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 102}, #endif }; @@ -1495,7 +1494,6 @@ static const char* OP_ExpTooltips[] = #endif "Change the depth of the Palette in Palette rendering mod\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", "Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.", - "Fixes issues that resulted in Textures not being properly skewed\n example: Fences on slopes that didnt show proper.\n This may be CPU heavy and result in worse performance in some cases.", "Toggle for FOF wall cutoff with slopes.", #endif }; @@ -1517,7 +1515,6 @@ enum #endif op_exp_paldepth, op_exp_spltwal, - op_exp_pegging, op_exp_fofcut, #endif }; @@ -4522,7 +4519,6 @@ void M_Init(void) OP_ExpOptionsMenu[op_exp_fbo].status = IT_DISABLED; #endif OP_ExpOptionsMenu[op_exp_spltwal].status = IT_DISABLED; - OP_ExpOptionsMenu[op_exp_pegging].status = IT_DISABLED; OP_ExpOptionsMenu[op_exp_fofcut].status = IT_DISABLED; } -- 2.54.0 From 988a672dea408c6728e6748efc9220a6ade37dfd Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 09:59:50 +0200 Subject: [PATCH 123/525] remove cv_grfofcut same story --- src/hardware/hw_main.c | 102 +++++++++++------------------------------ src/hardware/hw_main.h | 1 - src/m_menu.c | 3 -- 3 files changed, 27 insertions(+), 79 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7006fe43c..7d92454f7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -105,8 +105,6 @@ consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL consvar_t cv_grframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, CV_grframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL}; #endif -consvar_t cv_grfofcut = {"gr_fofcut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_splitwallfix = {"splitwallfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t grrenderdistance_cons_t[] = { @@ -2016,20 +2014,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom INT32 texnum; line_t * newline = NULL; // Multi-Property FOF - if (cv_grfofcut.value) - { - lowcut = max(worldbottom, worldlow); - highcut = min(worldtop, worldhigh); - lowcutslope = max(worldbottomslope, worldlowslope); - highcutslope = min(worldtopslope, worldhighslope); - } - else - { - ///TODO add slope support (fixing cutoffs, proper wall clipping) - maybe just disable highcut/lowcut if either sector or FOF has a slope - /// to allow fun plane intersecting in OGL? But then people would abuse that and make software look bad. :C - highcut = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight; - lowcut = gr_frontsector->floorheight > gr_backsector->floorheight ? gr_frontsector->floorheight : gr_backsector->floorheight; - } + lowcut = max(worldbottom, worldlow); + highcut = min(worldtop, worldhigh); + lowcutslope = max(worldbottomslope, worldlowslope); + highcutslope = min(worldtopslope, worldhighslope); if (gr_backsector->ffloors) { @@ -2038,19 +2026,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || (rover->flags & FF_INVERTSIDES)) continue; - if (cv_grfofcut.value) - { - SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) - SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) + SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) + SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) - if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) - continue; - } - else - { - if (*rover->topheight < lowcut || *rover->bottomheight > highcut) - continue; - } + if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) + continue; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -2066,26 +2046,16 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom l = P_GetFFloorBottomZAt(rover, v1x, v1y); lS = P_GetFFloorBottomZAt(rover, v2x, v2y); - if (cv_grfofcut.value) + // Adjust the heights so the FOF does not overlap with top and bottom textures. + if (h >= highcut && hS >= highcutslope) { - // Adjust the heights so the FOF does not overlap with top and bottom textures. - if (h >= highcut && hS >= highcutslope) - { - h = highcut; - hS = highcutslope; - } - if (l <= lowcut && lS <= lowcutslope) - { - l = lowcut; - lS = lowcutslope; - } + h = highcut; + hS = highcutslope; } - else + if (l <= lowcut && lS <= lowcutslope) { - if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) - h = hS = highcut; - if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut) - l = lS = lowcut; + l = lowcut; + lS = lowcutslope; } //Hurdler: HW code starts here @@ -2203,19 +2173,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_ALLSIDES)) continue; - if (cv_grfofcut.value) - { - SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) - SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) + SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) + SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) - if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) - continue; - } - else - { - if (*rover->topheight < lowcut || *rover->bottomheight > highcut) - continue; - } + if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) + continue; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -2231,26 +2193,16 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom l = P_GetFFloorBottomZAt(rover, v1x, v1y); lS = P_GetFFloorBottomZAt(rover, v2x, v2y); - if (cv_grfofcut.value) + // Adjust the heights so the FOF does not overlap with top and bottom textures. + if (h >= highcut && hS >= highcutslope) { - // Adjust the heights so the FOF does not overlap with top and bottom textures. - if (h >= highcut && hS >= highcutslope) - { - h = highcut; - hS = highcutslope; - } - if (l <= lowcut && lS <= lowcutslope) - { - l = lowcut; - lS = lowcutslope; - } + h = highcut; + hS = highcutslope; } - else + if (l <= lowcut && lS <= lowcutslope) { - if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) - h = hS = highcut; - if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut) - l = lS = lowcut; + l = lowcut; + lS = lowcutslope; } //Hurdler: HW code starts here @@ -5881,7 +5833,7 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grsolvetjoin); CV_RegisterVar(&cv_grbatching); - CV_RegisterVar(&cv_grfofcut); + CV_RegisterVar(&cv_splitwallfix); CV_RegisterVar(&cv_grrenderdistance); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index ce97afba3..5c99a77f4 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -155,7 +155,6 @@ extern consvar_t cv_grshaders; #ifdef USE_FBO_OGL extern consvar_t cv_grframebuffer; #endif -extern consvar_t cv_grfofcut; extern consvar_t cv_splitwallfix; extern consvar_t cv_grshearing; extern consvar_t cv_grfov; diff --git a/src/m_menu.c b/src/m_menu.c index 589772964..d6fa8a9e7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1473,7 +1473,6 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 80}, {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 87}, - {IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 102}, #endif }; @@ -1494,7 +1493,6 @@ static const char* OP_ExpTooltips[] = #endif "Change the depth of the Palette in Palette rendering mod\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", "Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.", - "Toggle for FOF wall cutoff with slopes.", #endif }; @@ -4519,7 +4517,6 @@ void M_Init(void) OP_ExpOptionsMenu[op_exp_fbo].status = IT_DISABLED; #endif OP_ExpOptionsMenu[op_exp_spltwal].status = IT_DISABLED; - OP_ExpOptionsMenu[op_exp_fofcut].status = IT_DISABLED; } if (rendermode == render_opengl) -- 2.54.0 From 8ef613ef9b2f3269b99c3c02d6ac5844288e37b0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 10:06:31 +0200 Subject: [PATCH 124/525] remove cv_mobjssector idk why it even checks for pointinsubsector --- src/m_menu.c | 3 --- src/r_fps.c | 14 ++++---------- src/r_fps.h | 1 - src/r_main.c | 3 --- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index d6fa8a9e7..56e4532fa 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1456,7 +1456,6 @@ static menuitem_t OP_ExpOptionsMenu[] = { {IT_HEADER, NULL, "Experimental Options", NULL, 10}, {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 20}, - {IT_STRING|IT_CVAR, NULL, "Mobj Subsector Interpolation", &cv_mobjssector, 25}, {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 30}, {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 35}, @@ -1480,7 +1479,6 @@ static const char* OP_ExpTooltips[] = { NULL, "How far Mobj interpolation should take effect.", - "Toggles Mobj Subsector Interpolation.", "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", "When weather is on this will cut the object amount used in half.", "Toggle being able to see the sky.", @@ -1500,7 +1498,6 @@ enum { op_exp_header, op_exp_interpdist, - op_exp_mobjssector, op_exp_precipinter, op_exp_lessprecip, op_exp_skybox, diff --git a/src/r_fps.c b/src/r_fps.c index 48990876a..961f36678 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -43,8 +43,6 @@ consvar_t cv_fpscap = {"fpscap", "Match refresh rate", CV_SAVE, fpscap_cons_t, N consvar_t cv_precipinterp = {"precipinterpolation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mobjssector = {"mobjsubsectorinterp", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - UINT32 R_GetFramerateCap(void) { if (rendermode == render_none) @@ -328,10 +326,8 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) IFCHANGED(scale, old_scale) out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac); - if (cv_mobjssector.value) - out->subsector = R_PointInSubsector(out->x, out->y); - else - out->subsector = mobj->subsector; + //out->subsector = R_PointInSubsector(out->x, out->y); // why was this even done? + out->subsector = mobj->subsector; if (mobj->player) { @@ -385,10 +381,8 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->spritexoffset = mobj->spritexoffset; out->spriteyoffset = mobj->spriteyoffset; - if (cv_mobjssector.value) - out->subsector = R_PointInSubsector(out->x, out->y); - else - out->subsector = mobj->subsector; + //out->subsector = R_PointInSubsector(out->x, out->y); // i dont understand lol + out->subsector = mobj->subsector; IFCHANGED(angle, old_angle) out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); diff --git a/src/r_fps.h b/src/r_fps.h index 14b7b2157..1b7b02cac 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -21,7 +21,6 @@ extern consvar_t cv_fpscap; extern consvar_t cv_precipinterp; -extern consvar_t cv_mobjssector; UINT32 R_GetFramerateCap(void); boolean R_UsingFrameInterpolation(void); diff --git a/src/r_main.c b/src/r_main.c index 3dec911e5..464fad847 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1812,10 +1812,8 @@ void R_RegisterEngineStuff(void) if (dedicated) return; - //CV_RegisterVar(&cv_precipdensity); CV_RegisterVar(&cv_translucency); CV_RegisterVar(&cv_drawdist); - //CV_RegisterVar(&cv_drawdist_nights); CV_RegisterVar(&cv_drawdist_precip); CV_RegisterVar(&cv_lessprecip); CV_RegisterVar(&cv_fov); @@ -1886,5 +1884,4 @@ void R_RegisterEngineStuff(void) // Frame interpolation/uncapped CV_RegisterVar(&cv_fpscap); CV_RegisterVar(&cv_precipinterp); - CV_RegisterVar(&cv_mobjssector); } -- 2.54.0 From 3d4e078a90ebd9a8b2d5c3827ecdc74db362df6e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 10:07:51 +0200 Subject: [PATCH 125/525] another m_menu moment --- src/m_menu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 56e4532fa..55cdd5481 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1510,7 +1510,6 @@ enum #endif op_exp_paldepth, op_exp_spltwal, - op_exp_fofcut, #endif }; -- 2.54.0 From 5ff665a0735c6b25b8e36ccf2cc746c948825b96 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 10:08:19 +0200 Subject: [PATCH 126/525] remove those 2 from experimental video menu no reason to ever toggle them off --- src/m_menu.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 55cdd5481..05166d240 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1461,8 +1461,6 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 42}, - {IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 56}, - {IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 61}, #ifdef HWRENDER {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 68}, #ifdef USE_FBO_OGL @@ -1482,8 +1480,6 @@ static const char* OP_ExpTooltips[] = "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", "When weather is on this will cut the object amount used in half.", "Toggle being able to see the sky.", - "Hides 3DFloors which are not visible\npotentially resulting in a performance boost.", - "Hides Sprites which are not visible\npotentially resulting in a performance boost.", #ifdef HWRENDER "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.", #ifdef USE_FBO_OGL @@ -1501,8 +1497,6 @@ enum op_exp_precipinter, op_exp_lessprecip, op_exp_skybox, - op_exp_ffclip, - op_exp_sprclip, #ifdef HWRENDER op_exp_grscrtx, #ifdef USE_FBO_OGL @@ -4517,8 +4511,6 @@ void M_Init(void) if (rendermode == render_opengl) { - OP_ExpOptionsMenu[op_exp_ffclip].status = IT_DISABLED; - OP_ExpOptionsMenu[op_exp_sprclip].status = IT_DISABLED; #ifdef USE_FBO_OGL if (!supportFBO) OP_ExpOptionsMenu[op_exp_fbo].status = IT_GRAYEDOUT; -- 2.54.0 From 7a9ffa7ee83e843259a74bc9552a449aae297a7a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 4 Jun 2024 17:11:30 +0200 Subject: [PATCH 127/525] test remove all the networking crap from rendering code --- src/d_main.c | 2 -- src/hardware/hw_main.c | 7 +------ src/r_main.c | 6 ------ 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 0b4b2cc1c..ac6785a53 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -568,8 +568,6 @@ static boolean D_Display(void) } } - NetUpdate(); // send out any new accumulation - // It's safe to end the game now. if (G_GetExitGameFlag()) { diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7d92454f7..4395570a4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4277,6 +4277,7 @@ static void HWR_SortVisSprites(void) { gr_vsprorder[i] = HWR_GetVisSprite(i); } + qs22j(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); } @@ -5679,9 +5680,6 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) } } - // check for new console commands. - NetUpdate(); - // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); @@ -5715,9 +5713,6 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) if (!skybox) HWR_DoPostProcessor(player); - // Check for new console commands. - NetUpdate(); - // added by Hurdler for correct splitscreen // moved here by hurdler so it works with the new near clipping plane HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); diff --git a/src/r_main.c b/src/r_main.c index 464fad847..58810c37b 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1717,9 +1717,6 @@ void R_RenderPlayerView(player_t *player) R_ClearVisibleFloorSplats(); #endif - // check for new console commands. - NetUpdate(); - // The head node is the last node output. ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0; @@ -1777,9 +1774,6 @@ void R_RenderPlayerView(player_t *player) R_DrawMasked(); PS_STOP_TIMING(ps_sw_maskedtime); - // Check for new console commands. - NetUpdate(); - // save value to skyVisiblePerPlayer // this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa for (i = 0; i <= splitscreen; i++) -- 2.54.0 From c5ec61baa5653029d5c01eeac3faca9ca1ff4538 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Jul 2024 21:20:40 +0200 Subject: [PATCH 128/525] Fix mobj reference management of player->mo https://git.do.srb2.org/KartKrew/RingRacers/-/commit/d0719ef5ba86a1da32fed171d74eb76c7254f4f6 --- src/g_game.c | 70 ++-------------------------------------------------- src/p_mobj.c | 4 ++- src/p_user.c | 2 +- 3 files changed, 6 insertions(+), 70 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 68edfed35..c7e13a7fb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3041,12 +3041,6 @@ void G_DoReborn(INT32 playernum) player_t *player = &players[playernum]; boolean starpost = false; - /*if (modeattacking) // Not needed for SRB2Kart. - { - M_EndModeAttackRun(); - return; - }*/ - // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); @@ -3060,74 +3054,13 @@ void G_DoReborn(INT32 playernum) oldmo = player->mo; // Don't leave your carcass stuck 10-billion feet in the ground! P_RemoveMobj(player->mo); + P_SetTarget(&player->mo, NULL); } B_RespawnBot(playernum); if (oldmo) G_ChangePlayerReferences(oldmo, players[playernum].mo); } - /*else if (countdowntimeup || (!multiplayer && !modeattacking)) - { - // reload the level from scratch - if (countdowntimeup) - { - player->starpostangle = 0; - player->starposttime = 0; - player->starpostx = 0; - player->starposty = 0; - player->starpostz = 0; - player->starpostnum = 0; - } - if (!countdowntimeup && (mapheaderinfo[gamemap-1]->levelflags & LF_NORELOAD)) - { - INT32 i; - - player->playerstate = PST_REBORN; - - P_LoadThingsOnly(); - - // Do a wipe - wipegamestate = -1; - - if (player->starpostnum) // SRB2kart - starpost = true; - - for (i = 0; i <= splitscreen; i++) - { - if (camera[i].chase) - P_ResetCamera(&players[displayplayers[i]], &camera[i]); - } - - // clear cmd building stuff - memset(gamekeydown, 0, sizeof (gamekeydown)); - for (i = 0;i < JOYAXISSET; i++) - { - joyxmove[i] = joyymove[i] = 0; - joy2xmove[i] = joy2ymove[i] = 0; - joy3xmove[i] = joy3ymove[i] = 0; - joy4xmove[i] = joy4ymove[i] = 0; - } - mousex = mousey = 0; - mouse2x = mouse2y = 0; - - // clear hud messages remains (usually from game startup) - CON_ClearHUD(); - - // Starpost support - G_SpawnPlayer(playernum, starpost); - - if (botingame) - { // Bots respawn next to their master. - players[displayplayers[1]].playerstate = PST_REBORN; - G_SpawnPlayer(displayplayers[1], false); - } - } - else - { - LUAh_MapChange(gamemap); - G_DoLoadLevel(true); - } - }*/ else { // respawn at the start @@ -3144,6 +3077,7 @@ void G_DoReborn(INT32 playernum) oldmo = player->mo; // Don't leave your carcass stuck 10-billion feet in the ground! P_RemoveMobj(player->mo); + P_SetTarget(&player->mo, NULL); } G_SpawnPlayer(playernum, starpost); diff --git a/src/p_mobj.c b/src/p_mobj.c index ec60c28e4..ac983fdfd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10560,7 +10560,9 @@ void P_SpawnPlayer(INT32 playernum) mobj = P_SpawnMobj(0, 0, 0, MT_PLAYER); I_Assert(mobj != NULL); - (mobj->player = p)->mo = mobj; + + mobj->player = p; + P_SetTarget(&p->mo, mobj); mobj->angle = 0; diff --git a/src/p_user.c b/src/p_user.c index bd13b9852..529838748 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4019,7 +4019,7 @@ boolean P_SpectatorJoinGame(player_t *player) if (player->mo) { P_RemoveMobj(player->mo); - player->mo = NULL; + P_SetTarget(&player->mo, NULL); } player->spectator = false; player->pflags &= ~PF_WANTSTOJOIN; -- 2.54.0 From d4886f892343c522f62b8727c48a47ba662e50f2 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 05:45:06 +0200 Subject: [PATCH 129/525] forgor this --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 529838748..74e9ae785 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4047,7 +4047,7 @@ boolean P_SpectatorJoinGame(player_t *player) if (player->mo) { P_RemoveMobj(player->mo); - player->mo = NULL; + P_SetTarget(&player->mo, NULL); } player->spectator = false; player->pflags &= ~PF_WANTSTOJOIN; -- 2.54.0 From 405cef6a0160314d18458fea9bfc2eabd7700db3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 18:31:39 +0200 Subject: [PATCH 130/525] fix IFCHANGED macro --- src/r_fps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_fps.c b/src/r_fps.c index 961f36678..5fda0313f 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -278,7 +278,7 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to) #define IFCHANGED(a, b)\ if (mobj->a == mobj->b)\ -(out->a = mobj->b);\ +(out->a = mobj->a);\ else void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) -- 2.54.0 From e6359663b1d398013cef09310eaf8f645b4c92a6 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 06:55:47 +0200 Subject: [PATCH 131/525] smol optimization to HWR_Addline --- src/hardware/hw_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4395570a4..9f9cc4a27 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2549,6 +2549,18 @@ doaddline: { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); + if ((gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then + { + if (!line->polyseg && + !line->sidedef->midtexture + && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) + || gr_frontsector->tag == gr_backsector->tag)) + return; // line is empty, don't even bother + // treat like wide open window instead + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + return; + } + if (CheckClip(gr_frontsector, gr_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); -- 2.54.0 From 17a5c6ed06b91b756ac3a26de6f4633cfaba241e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 07:12:58 +0200 Subject: [PATCH 132/525] shut up gcc --- src/hardware/hw_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9f9cc4a27..36c0be020 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2551,14 +2551,14 @@ doaddline: if ((gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then { - if (!line->polyseg && - !line->sidedef->midtexture + if (!line->polyseg && !line->sidedef->midtexture && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) || gr_frontsector->tag == gr_backsector->tag)) return; // line is empty, don't even bother // treat like wide open window instead - HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - return; + + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + return; } if (CheckClip(gr_frontsector, gr_backsector)) -- 2.54.0 From f949fa54af3e999cb2d39accebc632f9c3ce58b3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 09:21:58 +0200 Subject: [PATCH 133/525] dont do this with portals --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 36c0be020..71c7d2124 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2549,7 +2549,7 @@ doaddline: { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); - if ((gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then + if (!portalclipline && (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then { if (!line->polyseg && !line->sidedef->midtexture && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) -- 2.54.0 From 4c4f6f6d80d8a1f57053ea720d83c7d4063bf7f6 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 18:42:42 +0200 Subject: [PATCH 134/525] dont think precip mobj angle ever changes --- src/r_fps.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 5fda0313f..474cf3a48 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -384,8 +384,9 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst //out->subsector = R_PointInSubsector(out->x, out->y); // i dont understand lol out->subsector = mobj->subsector; - IFCHANGED(angle, old_angle) - out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); + //IFCHANGED(angle, old_angle) + //out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); + out->angle = mobj->angle; } #undef IFCHANGED -- 2.54.0 From 3c70963f563c465f6971f7b75ff4cb9b66a29022 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 18:43:20 +0200 Subject: [PATCH 135/525] only interpolate pitch and roll when using 3d models sprites dont need this for now --- src/r_fps.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 474cf3a48..fc39d6478 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -23,6 +23,7 @@ #include "r_state.h" #include "z_zone.h" #include "console.h" // con_startup_loadprogress + #ifdef HWRENDER #include "hardware/hw_main.h" // for cv_grshearing #endif @@ -340,19 +341,29 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); } - // pitch roll stuff - IFCHANGED(pitch, old_pitch) - out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); + if (cv_grmdls.value) + { + // pitch roll stuff + IFCHANGED(pitch, old_pitch) + out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); - IFCHANGED(roll, old_roll) - out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); + IFCHANGED(roll, old_roll) + out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); - // and the slope stuff - IFCHANGED(slopepitch, old_slopepitch) - out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); + // and the slope stuff + IFCHANGED(slopepitch, old_slopepitch) + out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); - IFCHANGED(sloperoll, old_sloperoll) - out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); + IFCHANGED(sloperoll, old_sloperoll) + out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); + } + else + { + out->pitch = mobj->pitch; + out->roll = mobj->roll; + out->slopepitch = mobj->slopepitch; + out->sloperoll = mobj->sloperoll; + } } void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjstate_t *out) -- 2.54.0 From 630d910a9e59e2b46cde9680a9d0bfecb2c0db76 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 22 Jun 2024 19:48:07 +0300 Subject: [PATCH 136/525] Add ServerJoin lua hook, which gets called when client joins a server (listen server hosts joining their server also count) --- src/d_clisrv.c | 2 ++ src/lua_hook.h | 5 ++++- src/lua_hooklib.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e8a06d860..98279839f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2748,6 +2748,8 @@ static void CL_ConnectToServer(void) DEBFILE(va("Synchronisation Finished\n")); displayplayers[0] = consoleplayer; + + LUAh_ServerJoin(); } #ifndef NONET diff --git a/src/lua_hook.h b/src/lua_hook.h index 14270dea5..921336cd2 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -55,6 +55,7 @@ enum hook { hook_PlayerCmd, //SRB2KART hook_IntermissionThinker, //SRB2KART hook_VoteThinker, //SRB2KART + hook_ServerJoin, // SRB2KART - Saturn 32p hook_MAX // last hook }; @@ -106,8 +107,10 @@ boolean LUAh_PlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_ExplodePlayer. Allows Lua to execute code and/or overwrite its behavior. boolean LUAh_PlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SquishPlayer. Allows Lua to execute code and/or overwrite its behavior. +void LUAh_ServerJoin(void); // SRB2KART - Saturn 32p: called by client when joining a server, allows lua to load any sort of config file + boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Allows to write to player cmd before the game does anything with them. void LUAh_IntermissionThinker(void); // Hook for Y_Ticker void LUAh_VoteThinker(void); // Hook for Y_VoteTicker -#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink \ No newline at end of file +#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index d7f89bffd..16e72d962 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -68,6 +68,7 @@ const char *const hookNames[hook_MAX+1] = { "PlayerCmd", "IntermissionThinker", "VoteThinker", + "ServerJoin", NULL }; @@ -219,6 +220,7 @@ static int lib_addHook(lua_State *L) case hook_PlayerSpin: case hook_PlayerExplode: case hook_PlayerSquish: + case hook_ServerJoin: default: lastp = &roothook; break; @@ -1869,3 +1871,34 @@ boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source) lua_settop(gL, 0); return hooked; } + +void LUAh_ServerJoin(void) +{ + hook_p hookp; + int HOOKSINDEX; + if (!gL || !(hooksAvailable[hook_ServerJoin/8] & (1<<(hook_ServerJoin%8)))) + return; + + lua_settop(gL, 0); + lua_pushcfunction(gL, LUA_GetErrorMessage); + + lua_getfield(gL, LUA_REGISTRYINDEX, "hooks"); + HOOKSINDEX = lua_gettop(gL); + I_Assert(lua_istable(L, HOOKSINDEX)); + + // We can afford not to look for target->type because it will always be MT_PLAYER. + + for (hookp = roothook; hookp; hookp = hookp->next) + if (hookp->type == hook_ServerJoin) + { + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + if (lua_pcall(gL, 0, 0, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + } + lua_settop(gL, 0); +} -- 2.54.0 From 6bf113d0ffd82daac8bfead653eaac6efe72ceed Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 28 Jun 2024 18:00:49 +0300 Subject: [PATCH 137/525] Add info about ServerJoin into LUASTUFF.md (so i don't forget to do it later) --- LUASTUFF.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LUASTUFF.md b/LUASTUFF.md index 79e2a2545..e72ae4c2a 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -130,3 +130,8 @@ if rawget(_G, "S_StopSoundByNum") ~= nil then ... -- Can use it end ``` + +## addHook("ServerJoin", function()) + +ServerJoin hook called when client joins server (starting a listen server also calls it for host). +Generally it was made to make loading custom config files less hacky, but can be used for anything else too. -- 2.54.0 From 33bc484d69e20fad40fb6d3d9fd889d7c9829a33 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 29 Jun 2024 17:43:21 +0300 Subject: [PATCH 138/525] Call ServerJoin hook when consoleplayer becomes available, since it is needed for configs (which what this hook is created for) --- src/d_clisrv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 98279839f..710f2687b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2748,8 +2748,6 @@ static void CL_ConnectToServer(void) DEBFILE(va("Synchronisation Finished\n")); displayplayers[0] = consoleplayer; - - LUAh_ServerJoin(); } #ifndef NONET @@ -4312,6 +4310,9 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) LUAh_PlayerJoin(newplayernum); + if (newplayernum == consoleplayer) + LUAh_ServerJoin(); + #ifdef HAVE_DISCORDRPC DRPC_UpdatePresence(); #endif -- 2.54.0 From 6088fa5134e6aa1a5b13af6595e6e8a6670c0528 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 19:25:49 +0200 Subject: [PATCH 139/525] Clean up graphic menus - Renamed Experimental Options to Advanced Options - Fixed the tooltips not displaying - Made it look good again --- src/m_menu.c | 64 +++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 05166d240..d9029cc9e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1355,7 +1355,7 @@ static menuitem_t OP_VideoOptionsMenu[] = #ifdef HWRENDER {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 155}, #endif - {IT_SUBMENU|IT_STRING, NULL, "Experimental Options...", &OP_ExpOptionsDef, 165}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_ExpOptionsDef, 165}, }; @@ -1379,7 +1379,7 @@ static const char* OP_VideoTooltips[] = #ifdef HWRENDER "Options for OpenGL renderer.", #endif - "Experimental graphical options.", + "Advanced graphical options.", }; @@ -1454,22 +1454,22 @@ static menuitem_t OP_ColorOptionsMenu[] = static menuitem_t OP_ExpOptionsMenu[] = { - {IT_HEADER, NULL, "Experimental Options", NULL, 10}, + {IT_HEADER, NULL, "Advanced Options", NULL, 10}, {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 20}, {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 30}, {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 35}, - {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 42}, + {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 45}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 68}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 55}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 73}, + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 60}, #endif - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 80}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 70}, - {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 87}, + {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 80}, #endif }; @@ -1511,23 +1511,24 @@ enum #ifdef HWRENDER static menuitem_t OP_OpenGLOptionsMenu[] = { - {IT_STRING | IT_CVAR, NULL, "3D Models", &cv_grmdls, 15}, - {IT_STRING | IT_CVAR, NULL, "Fallback Player 3D Model", &cv_grfallbackplayermodel, 20}, - {IT_STRING | IT_CVAR, NULL, "Shaders", &cv_grshaders, 25}, - {IT_STRING | IT_CVAR, NULL, "Palette Rendering", &cv_grpaletterendering, 30}, - {IT_STRING | IT_CVAR, NULL, "Flashpals in Palette Renderer", &cv_grflashpal, 35}, - {IT_STRING | IT_CVAR, NULL, "Min Shader Brightness", &cv_secbright, 40}, + {IT_STRING | IT_CVAR, NULL, "3D Models", &cv_grmdls, 15}, + {IT_STRING | IT_CVAR, NULL, "Fallback Player 3D Model", &cv_grfallbackplayermodel, 20}, + {IT_STRING | IT_CVAR, NULL, "Shaders", &cv_grshaders, 25}, + {IT_STRING | IT_CVAR, NULL, "Palette Rendering", &cv_grpaletterendering, 30}, + {IT_STRING | IT_CVAR, NULL, "Flashpals in Palette Renderer", &cv_grflashpal, 35}, + {IT_STRING | IT_CVAR, NULL, "Min Shader Brightness", &cv_secbright, 40}, - {IT_STRING|IT_CVAR, NULL, "Texture Quality", &cv_scr_depth, 50}, - {IT_STRING|IT_CVAR, NULL, "Texture Filter", &cv_grfiltermode, 55}, - {IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode, 60}, - {IT_STRING|IT_CVAR, NULL, "Visual Portals", &cv_grportals, 65}, + {IT_STRING|IT_CVAR, NULL, "Texture Quality", &cv_scr_depth, 50}, + {IT_STRING|IT_CVAR, NULL, "Texture Filter", &cv_grfiltermode, 55}, + {IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode, 60}, + {IT_STRING|IT_CVAR, NULL, "Visual Portals", &cv_grportals, 65}, {IT_STRING|IT_CVAR, NULL, "Wall Contrast Style", &cv_grfakecontrast, 75}, {IT_STRING|IT_CVAR, NULL, "Slope Contrast", &cv_grslopecontrast, 80}, - {IT_STRING|IT_CVAR, NULL, "Sprite Billboarding", &cv_grspritebillboarding, 85}, - {IT_STRING|IT_CVAR, NULL, "Software Perspective", &cv_grshearing, 90}, - {IT_STRING|IT_CVAR, NULL, "Rendering Distance", &cv_grrenderdistance, 95}, + {IT_STRING | IT_CVAR, NULL, "Dithered Lightning", &cv_lightdither, 85}, + {IT_STRING|IT_CVAR, NULL, "Sprite Billboarding", &cv_grspritebillboarding, 90}, + {IT_STRING|IT_CVAR, NULL, "Software Perspective", &cv_grshearing, 95}, + {IT_STRING|IT_CVAR, NULL, "Rendering Distance", &cv_grrenderdistance, 100}, }; static const char* OP_OpenGLTooltips[] = @@ -1544,6 +1545,7 @@ static const char* OP_OpenGLTooltips[] = "Recreates an effect from software mode that is used on some maps.", "The look of the wall contrast effect.", "Wall contrast but for slopes.", + "Should OpenGL lightning be dithered?", "Should sprites always face the camera?", "Recreates the look of software mode camera perspective.", "How far the game world should be drawn.", @@ -5043,16 +5045,6 @@ static void M_DrawGenericMenu(void) } } - if (currentMenu == &OP_ExpOptionsDef) - { - if (!(OP_ExpTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ExpTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - if (currentMenu == &OP_ChatOptionsDef) { if (!(OP_ChatOptionsTooltips[itemOn] == NULL)) @@ -5302,6 +5294,16 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } + + if (currentMenu == &OP_ExpOptionsDef) + { + if (!(OP_ExpTooltips[itemOn] == NULL)) + { + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ExpTooltips[itemOn], coolalphatimer); + if (coolalphatimer > 0 && interpTimerHackAllow) + coolalphatimer--; + } + } #endif if (currentMenu == &OP_SaturnDef) -- 2.54.0 From 970130e02bb3151a060b6da3ddf4bd7e3b5a81c1 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Jul 2024 03:00:01 +0200 Subject: [PATCH 140/525] mitigate dynamic slope desynchs Perform dynamic slope thinking before other thinkers. --- src/p_spec.c | 3 --- src/p_tick.c | 9 +++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index ddf938330..4923a9f6e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4980,9 +4980,6 @@ void P_UpdateSpecials(void) // POINT LIMIT P_CheckPointLimit(); - // Dynamic slopeness - P_RunDynamicSlopes(); - // ANIMATE TEXTURES for (anim = anims; anim < lastanim; anim++) { diff --git a/src/p_tick.c b/src/p_tick.c index 183c42a4b..379451a92 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -32,6 +32,9 @@ // Object place #include "m_cheat.h" +// Dynamic slopes +#include "p_slopes.h" + tic_t leveltime; // @@ -676,6 +679,9 @@ void P_Ticker(boolean run) if (run) { + // Dynamic slopeness + P_RunDynamicSlopes(); + PS_START_TIMING(ps_thinkertime); P_RunThinkers(); PS_STOP_TIMING(ps_thinkertime); @@ -892,6 +898,9 @@ void P_PreTicker(INT32 frames) memcpy(&players[i].cmd, &temptic, sizeof(ticcmd_t)); } + // Dynamic slopeness + P_RunDynamicSlopes(); + P_RunThinkers(); // Run any "after all the other thinkers" stuff -- 2.54.0 From ccf0905469d360cda7e4a71d9b91a05c0d5ba373 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 19:29:48 +0200 Subject: [PATCH 141/525] change when dynamic slopes run depending on if you joined midgame --- src/p_setup.c | 4 ++++ src/p_setup.h | 2 ++ src/p_spec.c | 4 ++++ src/p_tick.c | 13 +++++-------- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index fbfde84a0..30f995588 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -150,6 +150,8 @@ static SINT8 partadd_stage = -1; static boolean partadd_replacescurrentmap = false; static boolean partadd_important = false; +SINT8 midgamejoin = 0; + /** Logs an error about a map being corrupt, then terminate. * This allows reporting highly technical errors for usefulness, without * confusing a novice map designer who simply needs to run ZenNode. @@ -2704,6 +2706,7 @@ boolean P_SetupLevel(boolean skipprecip) INT32 i, loadprecip = 1, ranspecialwipe = 0; INT32 loademblems = 1; INT32 fromnetsave = 0; + midgamejoin = 0; boolean loadedbm = false; sector_t *ss; boolean chase; @@ -2903,6 +2906,7 @@ boolean P_SetupLevel(boolean skipprecip) fromnetsave = 1; loadprecip = 0; loademblems = 0; + midgamejoin = 1; } // internal game map diff --git a/src/p_setup.h b/src/p_setup.h index 9e66fff81..9b96225ad 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -18,6 +18,8 @@ #include "doomstat.h" #include "r_defs.h" +extern SINT8 midgamejoin; + // map md5, sent to players via PT_SERVERINFO extern unsigned char mapmd5[16]; diff --git a/src/p_spec.c b/src/p_spec.c index 4923a9f6e..d05f9fe74 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4977,6 +4977,10 @@ void P_UpdateSpecials(void) // LEVEL TIMER P_CheckTimeLimit(); + // Dynamic slopeness + if (!midgamejoin) // run here when not joined midgame to prevent any potential issues that may arise + P_RunDynamicSlopes(); + // POINT LIMIT P_CheckPointLimit(); diff --git a/src/p_tick.c b/src/p_tick.c index 379451a92..3913c5d62 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -18,6 +18,7 @@ #include "z_zone.h" #include "s_sound.h" #include "st_stuff.h" +#include "p_setup.h" #include "p_polyobj.h" #include "m_random.h" #include "lua_script.h" @@ -680,7 +681,8 @@ void P_Ticker(boolean run) if (run) { // Dynamic slopeness - P_RunDynamicSlopes(); + if (midgamejoin) // only run here if we joined midgame to fix some desynchs + P_RunDynamicSlopes(); PS_START_TIMING(ps_thinkertime); P_RunThinkers(); @@ -715,12 +717,6 @@ void P_Ticker(boolean run) if (!(modeattacking && !demo.playback) || leveltime >= starttime - TICRATE*4) timeinmap++; - /*if (G_TagGametype()) - P_DoTagStuff(); - - if (G_GametypeHasTeams()) - P_DoCTFStuff();*/ - if (run) { if (countdowntimer && --countdowntimer <= 0) @@ -899,7 +895,8 @@ void P_PreTicker(INT32 frames) } // Dynamic slopeness - P_RunDynamicSlopes(); + if (midgamejoin) + P_RunDynamicSlopes(); P_RunThinkers(); -- 2.54.0 From babf4ca06adc57d002b7fb7cd1d67492c6c2970b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 19:30:38 +0200 Subject: [PATCH 142/525] Map data lump interface cleans up code alot and stuff https://git.do.srb2.org/STJr/SRB2/-/merge_requests/535 --- src/p_saveg.c | 28 +-- src/p_setup.c | 568 +++++++++++++++++--------------------------------- src/p_spec.c | 20 +- src/w_wad.c | 98 +++++++++ src/w_wad.h | 19 ++ 5 files changed, 316 insertions(+), 417 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 6469574c8..e260321be 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -499,35 +499,16 @@ static void P_NetArchiveWorld(void) UINT8 *put; // reload the map just to see difference - mapsector_t *ms; - mapsidedef_t *msd; - maplinedef_t *mld; + virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); + mapsector_t *ms = (mapsector_t*) vres_Find(virt, "SECTORS")->data; + mapsidedef_t *msd = (mapsidedef_t*) vres_Find(virt, "SIDEDEFS")->data; + maplinedef_t *mld = (maplinedef_t*) vres_Find(virt, "LINEDEFS")->data; const sector_t *ss = sectors; UINT8 diff, diff2; WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD); put = save_p; - if (W_IsLumpWad(lastloadedmaplumpnum)) // welp it's a map wad in a pk3 - { // HACK: Open wad file rather quickly so we can get the data from the relevant lumps - UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); - filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); -#define retrieve_mapdata(d, f)\ - d = Z_Malloc((f)->size, PU_CACHE, NULL); \ - M_Memcpy(d, wadData + (f)->filepos, (f)->size) - retrieve_mapdata(ms, fileinfo + ML_SECTORS); - retrieve_mapdata(mld, fileinfo + ML_LINEDEFS); - retrieve_mapdata(msd, fileinfo + ML_SIDEDEFS); -#undef retrieve_mapdata - Z_Free(wadData); // we're done with this now - } - else // phew it's just a WAD - { - ms = W_CacheLumpNum(lastloadedmaplumpnum+ML_SECTORS, PU_CACHE); - mld = W_CacheLumpNum(lastloadedmaplumpnum+ML_LINEDEFS, PU_CACHE); - msd = W_CacheLumpNum(lastloadedmaplumpnum+ML_SIDEDEFS, PU_CACHE); - } - for (i = 0; i < numsectors; i++, ss++, ms++) { diff = diff2 = 0; @@ -737,6 +718,7 @@ static void P_NetArchiveWorld(void) WRITEUINT16(put, 0xffff); R_ClearTextureNumCache(false); + vres_Free(virt); save_p = put; } diff --git a/src/p_setup.c b/src/p_setup.c index 30f995588..5dd4fb4ee 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -379,27 +379,12 @@ UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade) return mapheaderinfo[map-1]->grades[mare].grade[grade-1]; } -/** Loads the vertexes for a level. - * - * \param lump VERTEXES lump number. - * \sa ML_VERTEXES - */ - -FUNCINLINE static ATTRINLINE void P_LoadRawVertexes(UINT8 *data, size_t i) +// Loads the vertexes for a level. +FUNCINLINE static ATTRINLINE void P_LoadRawVertexes(UINT8 *data) { - mapvertex_t *ml; - vertex_t *li; - - numvertexes = i / sizeof (mapvertex_t); - - if (numvertexes <= 0) - I_Error("Level has no vertices"); // instead of crashing - - // Allocate zone memory for buffer. - vertexes = Z_Calloc(numvertexes * sizeof (*vertexes), PU_LEVEL, NULL); - - ml = (mapvertex_t *)data; - li = vertexes; + mapvertex_t *ml = (mapvertex_t *)data; + vertex_t *li = vertexes; + size_t i; // Copy and convert vertex coordinates, internal representation as fixed. for (i = 0; i < numvertexes; i++, li++, ml++) @@ -409,13 +394,6 @@ FUNCINLINE static ATTRINLINE void P_LoadRawVertexes(UINT8 *data, size_t i) } } -static inline void P_LoadVertexes(lumpnum_t lumpnum) -{ - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawVertexes(data, W_LumpLength(lumpnum)); - Z_Free(data); -} - /** Computes the length of a seg in fracunits. * * \param seg Seg to compute length for. @@ -447,25 +425,16 @@ static inline float P_SegLengthFloat(seg_t *seg) } #endif -/** Loads the SEGS resource from a level. - * - * \param lump Lump number of the SEGS resource. - * \sa ::ML_SEGS - */ -static void P_LoadRawSegs(UINT8 *data, size_t i) + +// Loads the SEGS resource from a level. +static void P_LoadRawSegs(UINT8 *data) { INT32 linedef, side; - mapseg_t *ml; - seg_t *li; + mapseg_t *ml = (mapseg_t*)data; + seg_t *li = segs; line_t *ldef; + size_t i; - numsegs = i / sizeof (mapseg_t); - if (numsegs <= 0) - I_Error("Level has no segs"); // instead of crashing - segs = Z_Calloc(numsegs * sizeof (*segs), PU_LEVEL, NULL); - - ml = (mapseg_t *)data; - li = segs; for (i = 0; i < numsegs; i++, li++, ml++) { li->v1 = &vertexes[SHORT(ml->v1)]; @@ -486,7 +455,7 @@ static void P_LoadRawSegs(UINT8 *data, size_t i) li->side = side = SHORT(ml->side); li->sidedef = &sides[ldef->sidenum[side]]; li->frontsector = sides[ldef->sidenum[side]].sector; - if (ldef-> flags & ML_TWOSIDED) + if (ldef->flags & ML_TWOSIDED) li->backsector = sides[ldef->sidenum[side^1]].sector; else li->backsector = 0; @@ -496,30 +465,13 @@ static void P_LoadRawSegs(UINT8 *data, size_t i) } } -static void P_LoadSegs(lumpnum_t lumpnum) + +// Loads the SSECTORS resource from a level. +FUNCINLINE static ATTRINLINE void P_LoadRawSubsectors(void *data) { - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawSegs(data, W_LumpLength(lumpnum)); - Z_Free(data); -} - - -/** Loads the SSECTORS resource from a level. - * - * \param lump Lump number of the SSECTORS resource. - * \sa ::ML_SSECTORS - */ -FUNCINLINE static ATTRINLINE void P_LoadRawSubsectors(void *data, size_t i) -{ - mapsubsector_t *ms; - subsector_t *ss; - - numsubsectors = i / sizeof (mapsubsector_t); - if (numsubsectors <= 0) - I_Error("Level has no subsectors (did you forget to run it through a nodesbuilder?)"); - ss = subsectors = Z_Calloc(numsubsectors * sizeof (*subsectors), PU_LEVEL, NULL); - - ms = (mapsubsector_t *)data; + mapsubsector_t *ms = (mapsubsector_t*)data; + subsector_t *ss = subsectors; + size_t i; for (i = 0; i < numsubsectors; i++, ss++, ms++) { @@ -533,13 +485,6 @@ FUNCINLINE static ATTRINLINE void P_LoadRawSubsectors(void *data, size_t i) } } -static void P_LoadSubsectors(lumpnum_t lumpnum) -{ - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawSubsectors(data, W_LumpLength(lumpnum)); - Z_Free(data); -} - // // P_LoadSectors // @@ -672,20 +617,13 @@ INT32 P_CheckLevelFlat(const char *flatname) } // Sets up the ingame sectors structures. -// Lumpnum is the lumpnum of a SECTORS lump. -static void P_LoadRawSectors(UINT8 *data, size_t i) +static void P_LoadRawSectors(UINT8 *data) { - mapsector_t *ms; - sector_t *ss; + mapsector_t *ms = (mapsector_t *)data; + sector_t *ss = sectors; levelflat_t *foundflats; - // We count how many sectors we got. - numsectors = i / sizeof (mapsector_t); - if (numsectors <= 0) - I_Error("Level has no sectors"); - - // Allocate as much memory as we need into the global sectors table. - sectors = Z_Calloc(numsectors*sizeof (*sectors), PU_LEVEL, NULL); + size_t i; // Allocate a big chunk of memory as big as our MAXLEVELFLATS limit. //Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty @@ -696,8 +634,6 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) numlevelflats = 0; // For each counted sector, copy the sector raw data from our cache pointer ms, to the global table pointer ss. - ms = (mapsector_t *)data; - ss = sectors; for (i = 0; i < numsectors; i++, ss++, ms++) { ss->floorheight = SHORT(ms->floorheight)<flags = SHORT(mld->flags); ld->special = SHORT(mld->special); ld->tag = SHORT(mld->tag); - v1 = ld->v1 = &vertexes[SHORT(mld->v1)]; - v2 = ld->v2 = &vertexes[SHORT(mld->v2)]; - ld->dx = v2->x - v1->x; - ld->dy = v2->y - v1->y; + ld->v1 = &vertexes[SHORT(mld->v1)]; + ld->v2 = &vertexes[SHORT(mld->v2)]; + + ld->sidenum[0] = SHORT(mld->sidenum[0]); + ld->sidenum[1] = SHORT(mld->sidenum[1]); + } +} + +static void P_SetupLines(void) +{ + line_t *ld = lines; + size_t i; + + for (i = 0; i < numlines; i++, ld++) + { + vertex_t *v1 = ld->v1; + vertex_t *v2 = ld->v2; #ifdef WALLSPLATS ld->splats = NULL; #endif + ld->polyobj = NULL; + ld->dx = v2->x - v1->x; + ld->dy = v2->y - v1->y; + if (!ld->dx) ld->slopetype = ST_VERTICAL; else if (!ld->dy) @@ -1233,9 +1150,6 @@ static void P_LoadRawLineDefs(UINT8 *data, size_t i) ld->bbox[BOXTOP] = v1->y; } - ld->sidenum[0] = SHORT(mld->sidenum[0]); - ld->sidenum[1] = SHORT(mld->sidenum[1]); - { // cph 2006/09/30 - fix sidedef errors right away. // cph 2002/07/20 - these errors are fatal if not fixed, so apply them @@ -1255,38 +1169,29 @@ static void P_LoadRawLineDefs(UINT8 *data, size_t i) ld->validcount = 0; ld->firsttag = ld->nexttag = -1; ld->callcount = 0; - // killough 11/98: fix common wad errors (missing sidedefs): + // killough 11/98: fix common wad errors (missing sidedefs): if (ld->sidenum[0] == 0xffff) { ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side // cph - print a warning about the bug - CONS_Debug(DBG_SETUP, "P_LoadRawLineDefs: linedef %s missing first sidedef\n", sizeu1(numlines-i-1)); + CONS_Debug(DBG_SETUP, "Linedef %s missing first sidedef\n", sizeu1(numlines-i-1)); } if ((ld->sidenum[1] == 0xffff) && (ld->flags & ML_TWOSIDED)) { ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side // cph - print a warning about the bug - CONS_Debug(DBG_SETUP, "P_LoadRawLineDefs: linedef %s has two-sided flag set, but no second sidedef\n", sizeu1(numlines-i-1)); + CONS_Debug(DBG_SETUP, "Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1(numlines-i-1)); } if (ld->sidenum[0] != 0xffff && ld->special) sides[ld->sidenum[0]].special = ld->special; if (ld->sidenum[1] != 0xffff && ld->special) sides[ld->sidenum[1]].special = ld->special; - - ld->polyobj = NULL; } } -static void P_LoadLineDefs(lumpnum_t lumpnum) -{ - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawLineDefs(data, W_LumpLength(lumpnum)); - Z_Free(data); -} - static void P_LoadLineDefs2(void) { size_t i = numlines; @@ -1385,21 +1290,6 @@ static void P_LoadLineDefs2(void) } } - - -static inline void P_LoadRawSideDefs(size_t i) -{ - numsides = i / sizeof (mapsidedef_t); - if (numsides <= 0) - I_Error("Level has no sidedefs"); - sides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL); -} - -static inline void P_LoadSideDefs(lumpnum_t lumpnum) -{ - P_LoadRawSideDefs(W_LumpLength(lumpnum)); -} - static void P_LoadRawSideDefs2(void *data) { UINT16 i; @@ -1691,16 +1581,6 @@ static void P_LoadRawSideDefs2(void *data) R_ClearTextureNumCache(true); } - -// Delay loading texture names until after loaded linedefs. -static void P_LoadSideDefs2(lumpnum_t lumpnum) -{ - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawSideDefs2(data); - Z_Free(data); -} - - static boolean LineInBlock(fixed_t cx1, fixed_t cy1, fixed_t cx2, fixed_t cy2, fixed_t bx1, fixed_t by1) { fixed_t bbox[4]; @@ -1981,70 +1861,12 @@ static void P_ReadBlockMapLump(INT16 *wadblockmaplump, size_t count) } } -// -// P_LoadBlockMap -// -// Levels might not have a blockmap, so if one does not exist -// this should return false. -static boolean P_LoadBlockMap(lumpnum_t lumpnum) -{ - size_t count; - const char *lumpname = W_CheckNameForNum(lumpnum); - - // Check if the lump exists, and if it's named "BLOCKMAP" - if (!lumpname || memcmp(lumpname, "BLOCKMAP", 8) != 0) - { - return false; - } - - count = W_LumpLength(lumpnum); - - if (!count || count >= 0x20000) - return false; - - { - INT16 *wadblockmaplump = malloc(count); //INT16 *wadblockmaplump = W_CacheLumpNum (lump, PU_LEVEL); - if (!wadblockmaplump) - return false; - W_ReadLump(lumpnum, wadblockmaplump); - count /= 2; - P_ReadBlockMapLump(wadblockmaplump, count); - free(wadblockmaplump); - } - - bmaporgx = blockmaplump[0]<= 0x20000) return false; @@ -2170,47 +1992,11 @@ static void P_GroupLines(void) } } -// -// P_LoadReject -// -// Detect if the REJECT lump is valid, -// if not, rejectmatrix will be NULL -static void P_LoadReject(lumpnum_t lumpnum) -{ - size_t count; - const char *lumpname = W_CheckNameForNum(lumpnum); - - // Check if the lump exists, and if it's named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) - { - rejectmatrix = NULL; - CONS_Debug(DBG_SETUP, "P_LoadReject: No valid REJECT lump found\n"); - return; - } - - count = W_LumpLength(lumpnum); - - if (!count) // zero length, someone probably used ZDBSP - { - rejectmatrix = NULL; - CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT lump has size 0, will not be loaded\n"); - } - else - rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL); -} // PK3 version // -- Monster Iestyn 09/01/18 -static void P_LoadRawReject(UINT8 *data, size_t count, const char *lumpname) +static void P_LoadRawReject(UINT8 *data, size_t count) { - // Check if the lump is named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) - { - rejectmatrix = NULL; - CONS_Debug(DBG_SETUP, "P_LoadRawReject: No valid REJECT lump found\n"); - return; - } - if (!count) // zero length, someone probably used ZDBSP { rejectmatrix = NULL; @@ -2223,6 +2009,99 @@ static void P_LoadRawReject(UINT8 *data, size_t count, const char *lumpname) } } +static void P_LoadMapBSP(const virtres_t* virt) +{ + virtlump_t* virtssectors = vres_Find(virt, "SSECTORS"); + virtlump_t* virtsegs = vres_Find(virt, "SEGS"); + virtlump_t* virtnodes = vres_Find(virt, "NODES"); + + numsubsectors = virtssectors->size / sizeof(mapsubsector_t); + numnodes = virtnodes->size / sizeof(mapnode_t); + numsegs = virtsegs->size / sizeof(mapseg_t); + + if (numsubsectors <= 0) + I_Error("Level has no subsectors (did you forget to run it through a nodesbuilder?)"); + if (numnodes <= 0) + I_Error("Level has no nodes"); + if (numsegs <= 0) + I_Error("Level has no segs"); + + subsectors = Z_Calloc(numsubsectors * sizeof(*subsectors), PU_LEVEL, NULL); + nodes = Z_Calloc(numnodes * sizeof(*nodes), PU_LEVEL, NULL); + segs = Z_Calloc(numsegs * sizeof(*segs), PU_LEVEL, NULL); + + // Nodes + P_LoadRawSubsectors(virtssectors->data); + P_LoadRawNodes(virtnodes->data); + P_LoadRawSegs(virtsegs->data); +} + +static void P_LoadMapLUT(const virtres_t* virt) +{ + virtlump_t* virtblockmap = vres_Find(virt, "BLOCKMAP"); + virtlump_t* virtreject = vres_Find(virt, "REJECT"); + + // Lookup tables + if (virtreject) + P_LoadRawReject(virtreject->data, virtreject->size); + else + rejectmatrix = NULL; + + if (!(virtblockmap && P_LoadRawBlockMap(virtblockmap->data, virtblockmap->size))) + P_CreateBlockMap(); +} + +static void P_LoadMapData(const virtres_t* virt) +{ + virtlump_t* virtvertexes = NULL, * virtsectors = NULL, * virtsidedefs = NULL, * virtlinedefs = NULL, * virtthings = NULL; + + // Count map data. + virtthings = vres_Find(virt, "THINGS"); + virtvertexes = vres_Find(virt, "VERTEXES"); + virtsectors = vres_Find(virt, "SECTORS"); + virtsidedefs = vres_Find(virt, "SIDEDEFS"); + virtlinedefs = vres_Find(virt, "LINEDEFS"); + + if (!virtthings) + I_Error("THINGS lump not found"); + if (!virtvertexes) + I_Error("VERTEXES lump not found"); + if (!virtsectors) + I_Error("SECTORS lump not found"); + if (!virtsidedefs) + I_Error("SIDEDEFS lump not found"); + if (!virtlinedefs) + I_Error("LINEDEFS lump not found"); + + // Traditional doom map format just assumes the number of elements from the lump sizes. + numvertexes = virtvertexes->size / sizeof (mapvertex_t); + numsectors = virtsectors->size / sizeof (mapsector_t); + numsides = virtsidedefs->size / sizeof (mapsidedef_t); + numlines = virtlinedefs->size / sizeof (maplinedef_t); + nummapthings = virtthings->size / (5 * sizeof (INT16)); + + if (numvertexes <= 0) + I_Error("Level has no vertices"); + if (numsectors <= 0) + I_Error("Level has no sectors"); + if (numsides <= 0) + I_Error("Level has no sidedefs"); + if (numlines <= 0) + I_Error("Level has no linedefs"); + + vertexes = Z_Calloc(numvertexes * sizeof (*vertexes), PU_LEVEL, NULL); + sectors = Z_Calloc(numsectors * sizeof (*sectors), PU_LEVEL, NULL); + sides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL); + lines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL); + mapthings = Z_Calloc(nummapthings * sizeof (*mapthings), PU_LEVEL, NULL); + + // Strict map data + P_LoadRawVertexes(virtvertexes->data); + P_LoadRawSectors(virtsectors->data); + P_LoadRawLineDefs(virtlinedefs->data); + P_SetupLines(); + P_LoadRawSideDefs2(virtsidedefs->data); +} /** Sets up a sky texture to use for the level. * The sky texture is used instead of F_SKY1. @@ -2380,6 +2259,9 @@ void P_LoadThingsOnly(void) mobj_t *mo; thinker_t *think; + virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); + virtlump_t* vth = vres_Find(virt, "THINGS"); + for (think = thinkercap.next; think != &thinkercap; think = think->next) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) @@ -2393,18 +2275,11 @@ void P_LoadThingsOnly(void) P_LevelInitStuff(); - if (W_IsLumpWad(lastloadedmaplumpnum)) // welp it's a map wad in a pk3 - { // HACK: Open wad file rather quickly so we can use the things lump - UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); - filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); - fileinfo += ML_THINGS; // we only need the THINGS lump - P_PrepareRawThings(wadData + fileinfo->filepos, fileinfo->size); - Z_Free(wadData); // we're done with this now - } - else // phew it's just a WAD - P_PrepareThings(lastloadedmaplumpnum + ML_THINGS); + P_PrepareRawThings(vth->data); P_LoadThings(); + vres_Free(virt); + P_SpawnSecretItems(true); } @@ -2434,7 +2309,7 @@ static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock) #endif } -static void P_MakeMapMD5(lumpnum_t maplumpnum, void *dest) +static void P_MakeMapMD5(virtres_t* virt, void *dest) { unsigned char linemd5[16]; unsigned char sectormd5[16]; @@ -2445,20 +2320,15 @@ static void P_MakeMapMD5(lumpnum_t maplumpnum, void *dest) // Create a hash for the current map // get the actual lumps! - UINT8 *datalines = W_CacheLumpNum(maplumpnum + ML_LINEDEFS, PU_CACHE); - UINT8 *datasectors = W_CacheLumpNum(maplumpnum + ML_SECTORS, PU_CACHE); - UINT8 *datathings = W_CacheLumpNum(maplumpnum + ML_THINGS, PU_CACHE); - UINT8 *datasides = W_CacheLumpNum(maplumpnum + ML_SIDEDEFS, PU_CACHE); + virtlump_t* virtlines = vres_Find(virt, "LINEDEFS"); + virtlump_t* virtsectors = vres_Find(virt, "SECTORS"); + virtlump_t* virtmthings = vres_Find(virt, "THINGS"); + virtlump_t* virtsides = vres_Find(virt, "SIDEDEFS"); - P_MakeBufferMD5((char*)datalines, W_LumpLength(maplumpnum + ML_LINEDEFS), linemd5); - P_MakeBufferMD5((char*)datasectors, W_LumpLength(maplumpnum + ML_SECTORS), sectormd5); - P_MakeBufferMD5((char*)datathings, W_LumpLength(maplumpnum + ML_THINGS), thingmd5); - P_MakeBufferMD5((char*)datasides, W_LumpLength(maplumpnum + ML_SIDEDEFS), sidedefmd5); - - Z_Free(datalines); - Z_Free(datasectors); - Z_Free(datathings); - Z_Free(datasides); + P_MakeBufferMD5((char*)virtlines->data, virtlines->size, linemd5); + P_MakeBufferMD5((char*)virtsectors->data, virtsectors->size, sectormd5); + P_MakeBufferMD5((char*)virtmthings->data, virtmthings->size, thingmd5); + P_MakeBufferMD5((char*)virtsides->data, virtsides->size, sidedefmd5); for (i = 0; i < 16; i++) resmd5[i] = (linemd5[i] + sectormd5[i] + thingmd5[i] + sidedefmd5[i]) & 0xFF; @@ -2707,7 +2577,6 @@ boolean P_SetupLevel(boolean skipprecip) INT32 loademblems = 1; INT32 fromnetsave = 0; midgamejoin = 0; - boolean loadedbm = false; sector_t *ss; boolean chase; @@ -2924,98 +2793,33 @@ boolean P_SetupLevel(boolean skipprecip) // SRB2 determines the sky texture to be used depending on the map header. P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); - P_MakeMapMD5(lastloadedmaplumpnum, &mapmd5); + numdmstarts = numredctfstarts = numbluectfstarts = 0; - // HACK ALERT: Cache the WAD, get the map data into the tables, free memory. - // As it is implemented right now, we're assuming an uncompressed WAD. - // (As in, a normal PWAD, not ZWAD or anything. The lump itself can be compressed.) - // We're not accounting for extra lumps and scrambled lump positions. Any additional data will cause an error. - if (W_IsLumpWad(lastloadedmaplumpnum)) + // reset the player starts + for (i = 0; i < MAXPLAYERS; i++) + playerstarts[i] = NULL; + for (i = 0; i < 2; i++) + skyboxmo[i] = NULL; + + + P_MapStart(); + + if (lastloadedmaplumpnum) { - // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. - UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); - //filelump_t *fileinfo = wadData + ((wadinfo_t *)wadData)->infotableofs; - filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); - UINT32 numlumps = ((wadinfo_t *)wadData)->numlumps; + virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); - if (numlumps < ML_REJECT) // at least 9 lumps should be in the wad for a map to be loaded - { - I_Error("Bad WAD file for map %s!\n", maplumpname); - } - - if (numlumps > ML_BLOCKMAP) // enough room for a BLOCKMAP lump at least - { - loadedbm = P_LoadRawBlockMap( - wadData + (fileinfo + ML_BLOCKMAP)->filepos, - (fileinfo + ML_BLOCKMAP)->size, - (fileinfo + ML_BLOCKMAP)->name); - } - P_LoadRawVertexes(wadData + (fileinfo + ML_VERTEXES)->filepos, (fileinfo + ML_VERTEXES)->size); - P_LoadRawSectors(wadData + (fileinfo + ML_SECTORS)->filepos, (fileinfo + ML_SECTORS)->size); - P_LoadRawSideDefs((fileinfo + ML_SIDEDEFS)->size); - P_LoadRawLineDefs(wadData + (fileinfo + ML_LINEDEFS)->filepos, (fileinfo + ML_LINEDEFS)->size); - P_LoadRawSideDefs2(wadData + (fileinfo + ML_SIDEDEFS)->filepos); - P_LoadRawSubsectors(wadData + (fileinfo + ML_SSECTORS)->filepos, (fileinfo + ML_SSECTORS)->size); - P_LoadRawNodes(wadData + (fileinfo + ML_NODES)->filepos, (fileinfo + ML_NODES)->size); - P_LoadRawSegs(wadData + (fileinfo + ML_SEGS)->filepos, (fileinfo + ML_SEGS)->size); - if (numlumps > ML_REJECT) // enough room for a REJECT lump at least - { - P_LoadRawReject( - wadData + (fileinfo + ML_REJECT)->filepos, - (fileinfo + ML_REJECT)->size, - (fileinfo + ML_REJECT)->name); - } - else - { - rejectmatrix = NULL; - } - - // Important: take care of the ordering of the next functions. - if (!loadedbm) - P_CreateBlockMap(); // Graue 02-29-2004 - P_LoadLineDefs2(); - P_GroupLines(); - numdmstarts = numredctfstarts = numbluectfstarts = 0; - - // reset the player starts - for (i = 0; i < MAXPLAYERS; i++) - playerstarts[i] = NULL; - for (i = 0; i < 2; i++) - skyboxmo[i] = NULL; - P_MapStart(); - - P_PrepareRawThings(wadData + (fileinfo + ML_THINGS)->filepos, (fileinfo + ML_THINGS)->size); - Z_Free(wadData); - } - else - { - // Important: take care of the ordering of the next functions. - loadedbm = P_LoadBlockMap(lastloadedmaplumpnum + ML_BLOCKMAP); - P_LoadVertexes(lastloadedmaplumpnum + ML_VERTEXES); - P_LoadSectors(lastloadedmaplumpnum + ML_SECTORS); - P_LoadSideDefs(lastloadedmaplumpnum + ML_SIDEDEFS); - P_LoadLineDefs(lastloadedmaplumpnum + ML_LINEDEFS); - P_LoadSideDefs2(lastloadedmaplumpnum + ML_SIDEDEFS); - P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS); - P_LoadNodes(lastloadedmaplumpnum + ML_NODES); - P_LoadSegs(lastloadedmaplumpnum + ML_SEGS); - P_LoadReject(lastloadedmaplumpnum + ML_REJECT); - - // Important: take care of the ordering of the next functions. - if (!loadedbm) - P_CreateBlockMap(); // Graue 02-29-2004 + P_LoadMapData(virt); + P_LoadMapBSP(virt); + P_LoadMapLUT(virt); P_LoadLineDefs2(); P_GroupLines(); - numdmstarts = numredctfstarts = numbluectfstarts = 0; - // reset the player starts - for (i = 0; i < MAXPLAYERS; i++) - playerstarts[i] = NULL; - for (i = 0; i < 2; i++) - skyboxmo[i] = NULL; - P_MapStart(); - P_PrepareThings(lastloadedmaplumpnum + ML_THINGS); + P_PrepareRawThings(vres_Find(virt, "THINGS")->data); + + P_MakeMapMD5(virt, &mapmd5); + + vres_Free(virt); } P_ResetDynamicSlopes(); diff --git a/src/p_spec.c b/src/p_spec.c index d05f9fe74..1a5e02a78 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5691,6 +5691,7 @@ void P_SpawnSpecials(INT32 fromnetsave) thinkerlist_t *secthinkers; thinker_t *th; + virtres_t* virt = NULL; // This used to be used, and *should* be used in the future, // but currently isn't. (void)fromnetsave; @@ -6470,17 +6471,10 @@ void P_SpawnSpecials(INT32 fromnetsave) UINT8 *data; UINT16 b; - if (W_IsLumpWad(lastloadedmaplumpnum)) // welp it's a map wad in a pk3 - { // HACK: Open wad file rather quickly so we can get the data from the sidedefs lump - UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); - filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); - fileinfo += ML_SIDEDEFS; // we only need the SIDEDEFS lump - data = Z_Malloc(fileinfo->size, PU_STATIC, NULL); - M_Memcpy(data, wadData + fileinfo->filepos, fileinfo->size); // copy data - Z_Free(wadData); // we're done with this now - } - else // phew it's just a WAD - data = W_CacheLumpNum(lastloadedmaplumpnum + ML_SIDEDEFS,PU_STATIC); + if (!virt) + virt = vres_GetMap(lastloadedmaplumpnum); + + data = (UINT8*) vres_Find(virt, "SIDEDEFS")->data; for (b = 0; b < (INT16)numsides; b++) { @@ -6500,7 +6494,6 @@ void P_SpawnSpecials(INT32 fromnetsave) I_Error("Make-Your-Own-FOF (tag %d) needs a value in the linedef's second side upper texture field.", lines[i].tag); } } - Z_Free(data); } else I_Error("Make-Your-Own FOF (tag %d) found without a 2nd linedef side!", lines[i].tag); @@ -6708,6 +6701,9 @@ void P_SpawnSpecials(INT32 fromnetsave) } } + if (virt) + vres_Free(virt); + // Allocate each list for (i = 0; i < numsectors; i++) if(secthinkers[i].thinkers) diff --git a/src/w_wad.c b/src/w_wad.c index 15c7db38c..5d0e46f2b 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2118,3 +2118,101 @@ int W_VerifyNMUSlumps(const char *filename) }; return W_VerifyFile(filename, NMUSlist, false); } + +/** \brief Generates a virtual resource used for level data loading. + * + * \param lumpnum_t reference + * \return Virtual resource + * + */ +virtres_t* vres_GetMap(lumpnum_t lumpnum) +{ + UINT32 i; + virtres_t* vres = NULL; + virtlump_t* vlumps = NULL; + size_t numlumps = 0; + + if (W_IsLumpWad(lumpnum)) + { + // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. + UINT8 *wadData = W_CacheLumpNum(lumpnum, PU_LEVEL); + filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); + numlumps = ((wadinfo_t *)wadData)->numlumps; + vlumps = Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL); + + // Build the lumps. + for (i = 0; i < numlumps; i++) + { + vlumps[i].size = (size_t)(((filelump_t *)(fileinfo + i))->size); + // Play it safe with the name in this case. + memcpy(vlumps[i].name, (fileinfo + i)->name, 8); + vlumps[i].name[8] = '\0'; + vlumps[i].data = Z_Malloc(vlumps[i].size, PU_LEVEL, NULL); // This is memory inefficient, sorry about that. + memcpy(vlumps[i].data, wadData + (fileinfo + i)->filepos, vlumps[i].size); + } + + Z_Free(wadData); + } + else + { + // Count number of lumps until the end of resource OR up until next "MAPXX" lump. + lumpnum_t lumppos = lumpnum + 1; + for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++) + if (memcmp(W_CheckNameForNum(lumppos), "MAP", 3) == 0) + break; + numlumps++; + + vlumps = Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL); + for (i = 0; i < numlumps; i++, lumpnum++) + { + vlumps[i].size = W_LumpLength(lumpnum); + memcpy(vlumps[i].name, W_CheckNameForNum(lumpnum), 8); + vlumps[i].name[8] = '\0'; + vlumps[i].data = W_CacheLumpNum(lumpnum, PU_LEVEL); + } + } + vres = Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL); + vres->vlumps = vlumps; + vres->numlumps = numlumps; + + return vres; +} + +/** \brief Frees zone memory for a given virtual resource. + * + * \param Virtual resource + */ +void vres_Free(virtres_t* vres) +{ + while (vres->numlumps--) + Z_Free(vres->vlumps[vres->numlumps].data); + Z_Free(vres->vlumps); + Z_Free(vres); +} + +/** (Debug) Prints lumps from a virtual resource into console. + */ +/* + s *tatic void vres_Diag(const virtres_t* vres) + { + UINT32 i; + for (i = 0; i < vres->numlumps; i++) + CONS_Printf("%s\n", vres->vlumps[i].name); + } + */ + +/** \brief Finds a lump in a given virtual resource. + * + * \param Virtual resource + * \param Lump name to look for + * \return Virtual lump if found, NULL otherwise + * + */ +virtlump_t* vres_Find(const virtres_t* vres, const char* name) +{ + UINT32 i; + for (i = 0; i < vres->numlumps; i++) + if (fastcmp(name, vres->vlumps[i].name)) + return &vres->vlumps[i]; + return NULL; +} diff --git a/src/w_wad.h b/src/w_wad.h index 84ce9775e..4e84ea0e4 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -75,6 +75,25 @@ typedef struct compmethod compression; // lump compression method } lumpinfo_t; +// ========================================================================= +// 'VIRTUAL' RESOURCES +// ========================================================================= + +typedef struct { + char name[9]; + UINT8* data; + size_t size; +} virtlump_t; + +typedef struct { + size_t numlumps; + virtlump_t* vlumps; +} virtres_t; + +virtres_t* vres_GetMap(lumpnum_t); +void vres_Free(virtres_t*); +virtlump_t* vres_Find(const virtres_t*, const char*); + // ========================================================================= // DYNAMIC WAD LOADING // ========================================================================= -- 2.54.0 From d4370a181140718a5a386cd4275bb41adee5ba96 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 22 Jun 2024 07:09:01 +0200 Subject: [PATCH 143/525] clean up P_SetupLevel a little more --- src/p_setup.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 5dd4fb4ee..5cf964498 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2309,7 +2309,7 @@ static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock) #endif } -static void P_MakeMapMD5(virtres_t* virt, void *dest) +static void P_MakeMapMD5(virtres_t *virt, void *dest) { unsigned char linemd5[16]; unsigned char sectormd5[16]; @@ -2336,6 +2336,24 @@ static void P_MakeMapMD5(virtres_t* virt, void *dest) M_Memcpy(dest, &resmd5, 16); } +static void P_LoadMapFromFile(void) +{ + virtres_t *virt = vres_GetMap(lastloadedmaplumpnum); + + P_LoadMapData(virt); + P_LoadMapBSP(virt); + P_LoadMapLUT(virt); + + P_LoadLineDefs2(); + P_GroupLines(); + + P_PrepareRawThings(vres_Find(virt, "THINGS")->data); + + P_MakeMapMD5(virt, &mapmd5); + + vres_Free(virt); +} + static void P_RunLevelScript(const char *scriptname) { if (!(mapheaderinfo[gamemap-1]->levelflags & LF_SCRIPTISFILE)) @@ -2780,9 +2798,7 @@ boolean P_SetupLevel(boolean skipprecip) // internal game map maplumpname = G_BuildMapName(gamemap); - //lastloadedmaplumpnum = LUMPERROR; lastloadedmaplumpnum = W_CheckNumForName(maplumpname); - if (lastloadedmaplumpnum == INT16_MAX) I_Error("Map %s not found.\n", maplumpname); @@ -2804,23 +2820,11 @@ boolean P_SetupLevel(boolean skipprecip) P_MapStart(); + P_InitSlopes(); + if (lastloadedmaplumpnum) - { - virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); + P_LoadMapFromFile(); - P_LoadMapData(virt); - P_LoadMapBSP(virt); - P_LoadMapLUT(virt); - - P_LoadLineDefs2(); - P_GroupLines(); - - P_PrepareRawThings(vres_Find(virt, "THINGS")->data); - - P_MakeMapMD5(virt, &mapmd5); - - vres_Free(virt); - } P_ResetDynamicSlopes(); -- 2.54.0 From ee6dcfc67886a2738ad4d71419a2616beca7e326 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 05:26:27 +0200 Subject: [PATCH 144/525] fix conflict --- src/p_setup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 5cf964498..29b938496 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2820,8 +2820,6 @@ boolean P_SetupLevel(boolean skipprecip) P_MapStart(); - P_InitSlopes(); - if (lastloadedmaplumpnum) P_LoadMapFromFile(); -- 2.54.0 From e69413f1e8fee67ff8765e9a3b3d0e2c7bcd6722 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Jul 2024 05:50:01 +0200 Subject: [PATCH 145/525] smol cleanup --- src/p_setup.c | 54 --------------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 29b938496..fa490bb9f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2639,10 +2639,6 @@ boolean P_SetupLevel(boolean skipprecip) if (!dedicated) { - // Salt: CV_ClearChangedFlags() messes with your settings :( - /*if (!cv_cam_speed.changed) - CV_Set(&cv_cam_speed, cv_cam_speed.defaultvalue);*/ - if (!cv_chasecam.changed) CV_SetValue(&cv_chasecam, chase); @@ -2817,13 +2813,11 @@ boolean P_SetupLevel(boolean skipprecip) for (i = 0; i < 2; i++) skyboxmo[i] = NULL; - P_MapStart(); if (lastloadedmaplumpnum) P_LoadMapFromFile(); - P_ResetDynamicSlopes(); P_LoadThings(); @@ -2889,8 +2883,6 @@ boolean P_SetupLevel(boolean skipprecip) if (modeattacking == ATTACKING_RECORD && !demo.playback) P_LoadRecordGhosts(); - /*else if (modeattacking == ATTACKING_NIGHTS && !demo.playback) - P_LoadNightsGhosts();*/ if (G_TagGametype()) { @@ -2991,19 +2983,6 @@ boolean P_SetupLevel(boolean skipprecip) for (i = 0; i <= splitscreen; i++) P_SetupCamera(displayplayers[i], &camera[i]); - // Salt: CV_ClearChangedFlags() messes with your settings :( - /*if (!cv_cam_height.changed) - CV_Set(&cv_cam_height, cv_cam_height.defaultvalue); - - if (!cv_cam_dist.changed) - CV_Set(&cv_cam_dist, cv_cam_dist.defaultvalue); - - if (!cv_cam2_height.changed) - CV_Set(&cv_cam2_height, cv_cam2_height.defaultvalue); - - if (!cv_cam2_dist.changed) - CV_Set(&cv_cam2_dist, cv_cam2_dist.defaultvalue);*/ - // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P if (!cv_cam_rotate.changed) CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue); @@ -3017,42 +2996,9 @@ boolean P_SetupLevel(boolean skipprecip) if (!cv_cam4_rotate.changed) CV_Set(&cv_cam4_rotate, cv_cam4_rotate.defaultvalue); - /*if (!cv_analog.changed) - CV_SetValue(&cv_analog, 0); - if (!cv_analog2.changed) - CV_SetValue(&cv_analog2, 0); - if (!cv_analog3.changed) - CV_SetValue(&cv_analog3, 0); - if (!cv_analog4.changed) - CV_SetValue(&cv_analog4, 0);*/ - - // Shouldn't be necessary with render parity? - /*if (rendermode != render_none) - CV_Set(&cv_fov, cv_fov.defaultvalue);*/ - displayplayers[0] = consoleplayer; // Start with your OWN view, please! } - /*if (cv_useranalog.value) - CV_SetValue(&cv_analog, true); - - if ((splitscreen && cv_useranalog2.value) || botingame) - CV_SetValue(&cv_analog2, true); - - if (splitscreen > 1 && cv_useranalog3.value) - CV_SetValue(&cv_analog3, true); - - if (splitscreen > 2 && cv_useranalog4.value) - CV_SetValue(&cv_analog4, true); - - if (twodlevel) - { - CV_SetValue(&cv_analog4, false); - CV_SetValue(&cv_analog3, false); - CV_SetValue(&cv_analog2, false); - CV_SetValue(&cv_analog, false); - }*/ - // clear special respawning que iquehead = iquetail = 0; -- 2.54.0 From f4be7a80340fad67052bd0bf5ab9576cb7b7d00a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jul 2024 13:06:39 +0200 Subject: [PATCH 146/525] Revert "dont do this with portals" This reverts commit f949fa54af3e999cb2d39accebc632f9c3ce58b3. --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 71c7d2124..36c0be020 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2549,7 +2549,7 @@ doaddline: { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); - if (!portalclipline && (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then + if ((gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then { if (!line->polyseg && !line->sidedef->midtexture && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) -- 2.54.0 From bcb332e88fe0b65aab666813f4eaeaf7a8ef758c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jul 2024 13:06:42 +0200 Subject: [PATCH 147/525] Revert "shut up gcc" This reverts commit 17a5c6ed06b91b756ac3a26de6f4633cfaba241e. --- src/hardware/hw_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 36c0be020..9f9cc4a27 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2551,14 +2551,14 @@ doaddline: if ((gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then { - if (!line->polyseg && !line->sidedef->midtexture + if (!line->polyseg && + !line->sidedef->midtexture && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) || gr_frontsector->tag == gr_backsector->tag)) return; // line is empty, don't even bother // treat like wide open window instead - - HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - return; + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + return; } if (CheckClip(gr_frontsector, gr_backsector)) -- 2.54.0 From 837ed3535dafc42fe5415805fd27b1f54950eee2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jul 2024 13:06:45 +0200 Subject: [PATCH 148/525] Revert "smol optimization to HWR_Addline" This reverts commit e6359663b1d398013cef09310eaf8f645b4c92a6. --- src/hardware/hw_main.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9f9cc4a27..4395570a4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2549,18 +2549,6 @@ doaddline: { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); - if ((gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then - { - if (!line->polyseg && - !line->sidedef->midtexture - && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || gr_frontsector->tag == gr_backsector->tag)) - return; // line is empty, don't even bother - // treat like wide open window instead - HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - return; - } - if (CheckClip(gr_frontsector, gr_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); -- 2.54.0 From 28516c4833e7888dc4c82ed7db2c7cf0096226fc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jul 2024 14:54:55 +0200 Subject: [PATCH 149/525] fix NOHW compile --- src/r_fps.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/r_fps.c b/src/r_fps.c index fc39d6478..571a8e937 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -341,6 +341,7 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); } +#ifdef HWRENDER if (cv_grmdls.value) { // pitch roll stuff @@ -358,6 +359,7 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); } else +#endif { out->pitch = mobj->pitch; out->roll = mobj->roll; -- 2.54.0 From c78816a8d12d6ce83ed7d60e8cd05a5fbc922307 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jul 2024 15:12:43 +0200 Subject: [PATCH 150/525] also use IFCHANGED macro for levelinterpolators just looks a bit neater --- src/r_fps.c | 65 ++++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 41 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 571a8e937..a5e40ee97 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -598,6 +598,11 @@ void R_ClearLevelInterpolatorState(thinker_t *thinker) } } +#define IFCHANGED(a, b, c)\ +if (interp->a == interp->b)\ + (interp->a = interp->c);\ +else + void R_ApplyLevelInterpolators(fixed_t frac) { size_t i, ii; @@ -611,16 +616,12 @@ void R_ApplyLevelInterpolators(fixed_t frac) case LVLINTERP_SectorPlane: if (interp->sectorplane.ceiling) { - if (interp->sectorplane.sector->ceilingheight == interp->sectorplane.oldheight) - interp->sectorplane.sector->ceilingheight = interp->sectorplane.bakheight; - else + IFCHANGED(sectorplane.sector->ceilingheight, sectorplane.oldheight, sectorplane.bakheight) interp->sectorplane.sector->ceilingheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); } else { - if (interp->sectorplane.sector->floorheight == interp->sectorplane.oldheight) - interp->sectorplane.sector->floorheight = interp->sectorplane.bakheight; - else + IFCHANGED(sectorplane.sector->floorheight, sectorplane.oldheight, sectorplane.bakheight) interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); } interp->sectorplane.sector->moved = true; @@ -628,63 +629,43 @@ void R_ApplyLevelInterpolators(fixed_t frac) case LVLINTERP_SectorScroll: if (interp->sectorscroll.ceiling) { - if (interp->sectorscroll.sector->ceiling_xoffs == interp->sectorscroll.oldxoffs) - interp->sectorscroll.sector->ceiling_xoffs = interp->sectorscroll.bakxoffs; - else + IFCHANGED(sectorscroll.sector->ceiling_xoffs, sectorscroll.oldxoffs, sectorscroll.bakxoffs) interp->sectorscroll.sector->ceiling_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); - - if (interp->sectorscroll.sector->ceiling_yoffs == interp->sectorscroll.oldyoffs) - interp->sectorscroll.sector->ceiling_yoffs = interp->sectorscroll.bakyoffs; - else + + IFCHANGED(sectorscroll.sector->ceiling_yoffs, sectorscroll.oldyoffs, sectorscroll.bakyoffs) interp->sectorscroll.sector->ceiling_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } else { - if (interp->sectorscroll.sector->floor_xoffs == interp->sectorscroll.oldxoffs) - interp->sectorscroll.sector->floor_xoffs = interp->sectorscroll.bakxoffs; - else + IFCHANGED(sectorscroll.sector->floor_xoffs, sectorscroll.oldxoffs, sectorscroll.bakxoffs) interp->sectorscroll.sector->floor_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); - - if (interp->sectorscroll.sector->floor_yoffs == interp->sectorscroll.oldyoffs) - interp->sectorscroll.sector->floor_yoffs = interp->sectorscroll.bakyoffs; - else + + IFCHANGED(sectorscroll.sector->floor_yoffs, sectorscroll.oldyoffs, sectorscroll.bakyoffs) interp->sectorscroll.sector->floor_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } break; case LVLINTERP_SideScroll: - if (interp->sidescroll.side->textureoffset == interp->sidescroll.oldtextureoffset) - interp->sidescroll.side->textureoffset = interp->sidescroll.baktextureoffset; - else + IFCHANGED(sidescroll.side->textureoffset, sidescroll.oldtextureoffset, sidescroll.baktextureoffset) interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac); - - if (interp->sidescroll.side->rowoffset == interp->sidescroll.oldrowoffset) - interp->sidescroll.side->rowoffset = interp->sidescroll.bakrowoffset; - else + + IFCHANGED(sidescroll.side->rowoffset, sidescroll.oldrowoffset, sidescroll.bakrowoffset) interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac); break; case LVLINTERP_Polyobj: for (ii = 0; ii < interp->polyobj.vertices_size; ii++) { - if (interp->polyobj.polyobj->vertices[ii]->x == interp->polyobj.oldvertices[ii * 2 ]) - interp->polyobj.polyobj->vertices[ii]->x = interp->polyobj.bakvertices[ii * 2 ]; - else + IFCHANGED(polyobj.polyobj->vertices[ii]->x, polyobj.oldvertices[ii * 2 ], polyobj.bakvertices[ii * 2 ]) interp->polyobj.polyobj->vertices[ii]->x = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 ], interp->polyobj.bakvertices[ii * 2 ], frac); - if (interp->polyobj.polyobj->vertices[ii]->y == interp->polyobj.oldvertices[ii * 2 + 1]) - interp->polyobj.polyobj->vertices[ii]->y = interp->polyobj.bakvertices[ii * 2 + 1]; - else + IFCHANGED(polyobj.polyobj->vertices[ii]->y, polyobj.oldvertices[ii * 2 + 1], polyobj.bakvertices[ii * 2 + 1]) interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac); } - if (interp->polyobj.polyobj->centerPt.x == interp->polyobj.oldcx) - interp->polyobj.polyobj->centerPt.x = interp->polyobj.bakcx; - else + IFCHANGED(polyobj.polyobj->centerPt.x, polyobj.oldcx, polyobj.bakcx) interp->polyobj.polyobj->centerPt.x = R_LerpFixed(interp->polyobj.oldcx, interp->polyobj.bakcx, frac); - - if (interp->polyobj.polyobj->centerPt.y == interp->polyobj.oldcy) - interp->polyobj.polyobj->centerPt.y = interp->polyobj.bakcy; - else + + IFCHANGED(polyobj.polyobj->centerPt.y, polyobj.oldcy, polyobj.bakcy) interp->polyobj.polyobj->centerPt.y = R_LerpFixed(interp->polyobj.oldcy, interp->polyobj.bakcy, frac); - + break; /*case LVLINTERP_DynSlope: R_LerpVector3(&interp->dynslope.oldo, &interp->dynslope.bako, frac, &interp->dynslope.slope->o); @@ -695,6 +676,8 @@ void R_ApplyLevelInterpolators(fixed_t frac) } } +#undef IFCHANGED + void R_RestoreLevelInterpolators(void) { size_t i, ii; -- 2.54.0 From 2114afa536684f3d3c83ae7f929e23335c3b10e0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jul 2024 15:55:30 +0200 Subject: [PATCH 151/525] inline M_Memcpy --- src/m_fixed.c | 7 ------- src/m_misc.c | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/m_fixed.c b/src/m_fixed.c index 2da72fe05..ddd1ce63a 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -1011,13 +1011,6 @@ int main(int argc, char** argv) exit(0); } -static void *cpu_cpy(void *dest, const void *src, size_t n) -{ - return memcpy(dest, src, n); -} - -void *(*M_Memcpy)(void* dest, const void* src, size_t n) = cpu_cpy; - void I_Error(const char *error, ...) { (void)error; diff --git a/src/m_misc.c b/src/m_misc.c index 7d0ce6bfc..c40848ecd 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1938,7 +1938,7 @@ char *sizeu5(size_t num) return sizeu5_buf; } -void *M_Memcpy(void *dest, const void *src, size_t n) +FUNCINLINE ATTRINLINE void *M_Memcpy(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); } -- 2.54.0 From 715b106c9e1cc48229dff8977ec92c05522a1cbe Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 11 Jul 2024 10:36:27 +0200 Subject: [PATCH 152/525] shut up windoze --- src/r_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_defs.h b/src/r_defs.h index 99a185c7a..fae341890 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -650,7 +650,7 @@ typedef struct INT16 topoffset; // pixels below the origin INT32 columnofs[]; // only [width] used // the [0] is &columnofs[width] -}ATTRPACK patch_t; +} patch_t; #ifdef _MSC_VER #pragma warning(disable : 4200) -- 2.54.0 From ecde8a5e8bf7454080d7469ad787a7b6b842ba0e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 14 Jul 2024 10:17:47 +0200 Subject: [PATCH 153/525] shut up 32bit gcc --- src/lua_hudlib_drawlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index ff98c6e8b..2ee9b8156 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -326,7 +326,7 @@ static UINT64 GetItemId(void) return 0; // leave bits 0 and 1 free for the string mode - UINT64 id = ((uintptr_t)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2); + UINT64 id = ((UINT64)(uintptr_t)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2); if (hud_interplatch) { -- 2.54.0 From 8f4df0cecabf45fa31c3a67569bda0194904cc8a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 14 Jul 2024 10:18:27 +0200 Subject: [PATCH 154/525] version string otherwise i forger --- src/doomdef.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 31734af84..3540c3f4a 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -128,11 +128,11 @@ extern char logfilename[1024]; #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number #ifndef USE_FBO_OGL -#define VERSIONSTRING "Saturn v6.2 " -#define VERSIONSTRINGW L"Saturn v6.2" +#define VERSIONSTRING "Saturn v7 - Test " +#define VERSIONSTRINGW L"Saturn v7 - Test" #else -#define VERSIONSTRING "Saturn v6.2 - FBO " -#define VERSIONSTRINGW L"Saturn v6.2 - FBO" +#define VERSIONSTRING "Saturn v7 - Test - FBO " +#define VERSIONSTRINGW L"Saturn v7 - Test - FBO" #endif // Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates! // And change CMakeLists.txt (not src/, but in root), for CMake users! -- 2.54.0 From 28fc55b65310d71bb7a78780c0c5ccfd139c49df Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 14 Jul 2024 15:33:31 +0300 Subject: [PATCH 155/525] Refactor music name scrolling in music test --- src/m_menu.c | 136 ++++++++++++++++++++++----------------------------- 1 file changed, 58 insertions(+), 78 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index d9029cc9e..af8e330d6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8191,8 +8191,53 @@ static void M_HandleSoundTest(INT32 choice) static musicdef_t *curplaying = NULL; static INT32 st_sel = 0; static tic_t st_time = 0; -static size_t st_namescroll = 0; -static size_t st_namescrollstate = 0; +static tic_t st_musictime = 0; + +static void scrollMusicName(const char name[], size_t len, size_t maxlen, char result[]) +{ + // How much should we scroll. Not sure why +1 is needed, but without it this function skips 2 + // characters at once sometimes + const size_t amount = len - maxlen + 1; + + // Note: anything above 17 will cause zero division + const size_t MAXSPEED = 6; + const size_t t = st_musictime / (35/min(amount, MAXSPEED)); + + const size_t state = (t / amount) % 4; + + switch (state) + { + // Show beginning of the name + case 0: + memcpy(result, name, maxlen-1); + break; + + // Scroll towards end of the name + case 1: + { + const size_t advance = t % amount; + memcpy(result, name+advance, maxlen-1); + } + break; + + // Show end of the name + case 2: + memcpy(result, name+len+1-maxlen, maxlen-1); + break; + + // Scroll towards start of the name + case 3: + { + const size_t advance = t % amount; + memcpy(result, name+len+1-maxlen-advance, maxlen-1); + } + break; + } + + // Technically not necessary, since it gets set again after function call, but just in case + result[maxlen] = 0; +} + //static patch_t* st_radio[9]; //static patch_t* st_launchpad[4]; @@ -8335,7 +8380,7 @@ static void M_DrawMusicTest(void) x = 24; y = 64; - if (renderisnewtic) ++st_namescroll; + if (renderisnewtic) st_musictime++; while (t <= b) { @@ -8344,76 +8389,16 @@ static void M_DrawMusicTest(void) { const size_t MAXLENGTH = 34; - const tic_t SCROLLSPEED = TICRATE/5; // Number of tics for name being scrolled by 1 letter - size_t nameoffset = 0; - size_t namelength = strlen(soundtestdefs[t]->source); - if (soundtestdefs[t]->title[0]) - namelength = strlen(soundtestdefs[t]->title); + const char *songname = soundtestdefs[t]->title[0] ? soundtestdefs[t]->title : soundtestdefs[t]->source; + + size_t namelength = strlen(songname); char buf[MAXLENGTH+1]; if (t == st_sel && namelength > MAXLENGTH) - { - switch (st_namescrollstate) - { - case 0: - { - // Scroll forward - nameoffset = (st_namescroll/SCROLLSPEED) % (namelength - MAXLENGTH + 1); - - if (nameoffset == namelength - MAXLENGTH) - { - st_namescroll = 0; - st_namescrollstate++; - } - } - break; - - case 1: - { - nameoffset = namelength - MAXLENGTH; - - // Show name end for 1 second, then start scrolling back - if (st_namescroll == TICRATE) - { - st_namescroll = 0; - st_namescrollstate++; - } - } - break; - - case 2: - { - // Scroll back - nameoffset = (namelength - MAXLENGTH - 1) - (st_namescroll/SCROLLSPEED) % (namelength - MAXLENGTH); - - if (nameoffset == 0) - { - st_namescroll = 0; - st_namescrollstate++; - } - } - break; - - case 3: - { - nameoffset = 0; - - // Show name beginning for 1 second, then start scrolling forward again - if (st_namescroll == TICRATE) - { - st_namescroll = 0; - st_namescrollstate = 0; - } - } - break; - } - } - - if (soundtestdefs[t]->title[0]) - memcpy(buf, soundtestdefs[t]->title + nameoffset, MAXLENGTH); + scrollMusicName(songname, namelength, MAXLENGTH, buf); else - memcpy(buf, soundtestdefs[t]->source + nameoffset, MAXLENGTH); + strncpy(buf, songname, MAXLENGTH); buf[MAXLENGTH] = 0; V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); @@ -8440,8 +8425,7 @@ static void M_HandleMusicTest(INT32 choice) { S_StartSound(NULL, sfx_menu1); } - st_namescroll = 0; - st_namescrollstate = 0; + st_musictime = 0; break; case KEY_UPARROW: if (!st_sel--) @@ -8449,8 +8433,7 @@ static void M_HandleMusicTest(INT32 choice) { S_StartSound(NULL, sfx_menu1); } - st_namescroll = 0; - st_namescrollstate = 0; + st_musictime = 0; break; case KEY_PGDN: if (st_sel < numsoundtestdefs-1) @@ -8460,8 +8443,7 @@ static void M_HandleMusicTest(INT32 choice) st_sel = numsoundtestdefs-1; S_StartSound(NULL, sfx_menu1); } - st_namescroll = 0; - st_namescrollstate = 0; + st_musictime = 0; break; case KEY_PGUP: if (st_sel) @@ -8471,8 +8453,7 @@ static void M_HandleMusicTest(INT32 choice) st_sel = 0; S_StartSound(NULL, sfx_menu1); } - st_namescroll = 0; - st_namescrollstate = 0; + st_musictime = 0; break; case KEY_BACKSPACE: if (curplaying) @@ -8486,8 +8467,7 @@ static void M_HandleMusicTest(INT32 choice) break; case KEY_ESCAPE: exitmenu = true; - st_namescroll = 0; - st_namescrollstate = 0; + st_musictime = 0; break; case KEY_RIGHTARROW: -- 2.54.0 From b9b4de929d391efbf3954aa4cb7970390aef5d75 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 14 Jul 2024 17:15:31 +0200 Subject: [PATCH 156/525] this does nothing lol --- src/m_menu.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index af8e330d6..3f34fda2f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8190,7 +8190,6 @@ static void M_HandleSoundTest(INT32 choice) static musicdef_t *curplaying = NULL; static INT32 st_sel = 0; -static tic_t st_time = 0; static tic_t st_musictime = 0; static void scrollMusicName(const char name[], size_t len, size_t maxlen, char result[]) @@ -8252,7 +8251,6 @@ static void M_MusicTest(INT32 choice) } curplaying = NULL; - st_time = 0; st_sel = 0; @@ -8263,30 +8261,17 @@ static void M_DrawMusicTest(void) { INT32 x, y, i; - // let's handle the ticker first. ideally we'd tick this somewhere else, BUT... - if (curplaying) - { - { - fixed_t work; - work = st_time; - - if (st_time >= (FRACUNIT << (FRACBITS - 2))) // prevent overflow jump - takes about 15 minutes of loop on the same song to reach - st_time = work; - - st_time += renderdeltatics; - } - } - x = 90<usage[0]) V_DrawString(vid.dupx, vid.height - 10*vid.dupy, V_NOSCALESTART|V_ALLOWLOWERCASE, va("%.6s", curplaying->name)); - else { + else V_DrawSmallString(vid.dupx, vid.height - 5*vid.dupy, V_NOSCALESTART|V_ALLOWLOWERCASE, va("%.6s - %.255s\n", curplaying->name, curplaying->usage)); - } if (cv_showmusicfilename.value) V_DrawSmallString(0, 0, V_SNAPTOTOP|V_SNAPTOLEFT|V_ALLOWLOWERCASE, curplaying->filename); @@ -8461,7 +8445,6 @@ static void M_HandleMusicTest(INT32 choice) S_StopSounds(); S_StopMusic(); curplaying = NULL; - st_time = 0; S_StartSound(NULL, sfx_skid); } break; @@ -8475,7 +8458,6 @@ static void M_HandleMusicTest(INT32 choice) case KEY_ENTER: S_StopSounds(); S_StopMusic(); - st_time = 0; curplaying = soundtestdefs[st_sel]; S_ChangeMusicInternal(curplaying->name, true); break; -- 2.54.0 From 2437c5a19a0140d3a8fb9627fa5f9300e1a6ac24 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 14 Jul 2024 16:44:09 +0200 Subject: [PATCH 157/525] Free mipmaps before freeing tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ŝhould hopefully fix some random Z_free crashes --- src/hardware/hw_cache.c | 4 ++-- src/hardware/hw_main.c | 11 ----------- src/p_setup.c | 6 ++++++ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 98034970d..6a875543f 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -509,8 +509,8 @@ void HWR_FreeMipmapCache(void) // free all hardware-converted graphics cached in the heap // our gool is only the textures since user of the texture is the texture cache - Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); - Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); + //Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); + //Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); // Alam: free the Z_Blocks before freeing it's users diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4395570a4..cf95fdbcb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5760,17 +5760,6 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) void HWR_LoadLevel(void) { - // Lactozilla (December 8, 2019) - // Level setup used to free EVERY mipmap from memory. - // Even mipmaps that aren't related to level textures. - // Presumably, the hardware render code used to store textures as level data. - // Meaning, they had memory allocated and marked with the PU_LEVEL tag. - // Level textures are only reloaded after R_LoadTextures, which is - // when the texture list is loaded. - - // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. - HWR_FreeMipmapCache(); - HWR_CreatePlanePolygons((INT32)numnodes - 1); if (HWR_ShouldUsePaletteRendering()) diff --git a/src/p_setup.c b/src/p_setup.c index fa490bb9f..e5f947a87 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2770,6 +2770,12 @@ boolean P_SetupLevel(boolean skipprecip) // Clear pointers that would be left dangling by the purge R_FlushTranslationColormapCache(); +#ifdef HWRENDER + // Free GPU textures before freeing patches. + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) + HWR_FreeMipmapCache(); +#endif + Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); #if defined (WALLSPLATS) || defined (FLOORSPLATS) -- 2.54.0 From e9e281fd2a75fed10373c5df9f0aafe8de9b7a76 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 19:49:43 +0200 Subject: [PATCH 158/525] clean up some net stuff --- src/d_net.c | 27 +-------------------------- src/d_netfil.c | 1 - src/i_net.h | 20 -------------------- src/i_tcp.c | 6 ------ 4 files changed, 1 insertion(+), 53 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 04db5f7c5..7977e39ab 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -64,9 +64,6 @@ static doomdata_t reboundstore[MAXREBOUND]; static INT16 reboundsize[MAXREBOUND]; static INT32 rebound_head, rebound_tail; -/// \brief bandwith of netgame -INT32 net_bandwidth; - /// \brief max length per packet INT16 hardware_MAXPACKETLENGTH; @@ -1266,10 +1263,7 @@ void D_SetDoomcom(void) { if (doomcom) return; doomcom = Z_Calloc(sizeof (doomcom_t), PU_STATIC, NULL); - doomcom->id = DOOMCOM_ID; doomcom->numslots = doomcom->numnodes = 1; - doomcom->gametype = 0; - doomcom->consoleplayer = 0; doomcom->extratics = 0; } @@ -1294,7 +1288,6 @@ boolean D_CheckNetGame(void) I_NetMakeNodewPort = NULL; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - net_bandwidth = 30000; // I_InitNetwork sets doomcom and netgame // check and initialize the network driver multiplayer = false; @@ -1314,7 +1307,6 @@ boolean D_CheckNetGame(void) server = true; // WTF? server always true??? // no! The deault mode is server. Client is set elsewhere // when the client executes connect command. - doomcom->ticdup = 1; if (M_CheckParm("-extratic")) { @@ -1325,21 +1317,6 @@ boolean D_CheckNetGame(void) CONS_Printf(M_GetText("Set extratics to %d\n"), doomcom->extratics); } - if (M_CheckParm("-bandwidth")) - { - if (M_IsNextParm()) - { - net_bandwidth = atoi(M_GetNextParm()); - if (net_bandwidth < 1000) - net_bandwidth = 1000; - if (net_bandwidth > 100000) - hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - CONS_Printf(M_GetText("Network bandwidth set to %d\n"), net_bandwidth); - } - else - I_Error("usage: -bandwidth "); - } - software_MAXPACKETLENGTH = hardware_MAXPACKETLENGTH; if (M_CheckParm("-packetsize")) { @@ -1359,8 +1336,6 @@ boolean D_CheckNetGame(void) if (netgame) multiplayer = true; - if (doomcom->id != DOOMCOM_ID) - I_Error("Doomcom buffer invalid!"); if (doomcom->numnodes > MAXNETNODES) I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES); @@ -1373,7 +1348,7 @@ boolean D_CheckNetGame(void) if (M_CheckParm("-debugfile")) { char filename[21]; - INT32 k = doomcom->consoleplayer - 1; + INT32 k = consoleplayer - 1; if (M_IsNextParm()) k = atoi(M_GetNextParm()) - 1; while (!debugfile && k < MAXPLAYERS) diff --git a/src/d_netfil.c b/src/d_netfil.c index 4eb8f2dc3..7bf862f90 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -833,7 +833,6 @@ void SV_FileSendTicker(void) netbuffer->packettype = PT_FILEFRAGMENT; - // (((sendbytes-nowsentbyte)*TICRATE)/(I_GetTime()-starttime)<(UINT32)net_bandwidth) while (packetsent-- && filestosend != 0) { for (i = currentnode, j = 0; j < MAXNETNODES; diff --git a/src/i_net.h b/src/i_net.h index c3391a1ed..11dbc6341 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -34,7 +34,6 @@ #define NO_BAN_TIME (time_t)(-1) extern INT16 hardware_MAXPACKETLENGTH; -extern INT32 net_bandwidth; // in byte/s #if defined(_MSC_VER) #pragma pack(1) @@ -42,36 +41,17 @@ extern INT32 net_bandwidth; // in byte/s typedef struct { - /// Supposed to be DOOMCOM_ID - INT32 id; - - /// SRB2 executes an INT32 to execute commands. - INT16 intnum; - /// Communication between SRB2 and the driver. - /// Is CMD_SEND or CMD_GET. - INT16 command; /// Is dest for send, set by get (-1 = no packet). INT16 remotenode; - /// Number of bytes in doomdata to be sent INT16 datalength; /// Info common to all nodes. /// Console is always node 0. INT16 numnodes; - /// Flag: 1 = no duplication, 2-5 = dup for slow nets. - INT16 ticdup; /// Flag: 1 = send a backup tic in every packet. INT16 extratics; - /// kind of game - INT16 gametype; - /// Flag: -1 = new game, 0-5 = load savegame - INT16 savegame; - /// currect map - INT16 map; - /// Info specific to this node. - INT16 consoleplayer; /// Number of "slots": the highest player number in use plus one. INT16 numslots; diff --git a/src/i_tcp.c b/src/i_tcp.c index 81c221d27..77f8aac0c 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1692,8 +1692,6 @@ boolean I_InitTcpNetwork(void) // FIXME: for dedicated server, numnodes needs to be set to 0 upon start if (dedicated) doomcom->numnodes = 0; -/* else if (M_IsNextParm()) - doomcom->numnodes = (INT16)atoi(M_GetNextParm());*/ else doomcom->numnodes = 1; @@ -1707,7 +1705,6 @@ boolean I_InitTcpNetwork(void) // FIXME: // ??? and now ? // server on a big modem ??? 4*isdn - net_bandwidth = 16000; hardware_MAXPACKETLENGTH = INETPACKETLENGTH; ret = true; @@ -1738,7 +1735,6 @@ boolean I_InitTcpNetwork(void) // so we're on a LAN COM_BufAddText("connect any\n"); - net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } @@ -1763,8 +1759,6 @@ boolean I_InitTcpNetwork(void) { // so we're on a LAN COM_BufAddText("connect any\n"); - - net_bandwidth = 800000; hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } -- 2.54.0 From 35d40e1d37722be9a4f0d65b84471c05f009ab1f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 14 Jul 2024 17:30:44 +0200 Subject: [PATCH 159/525] ndef --- src/d_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_net.c b/src/d_net.c index 7977e39ab..15ab46b5c 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1213,7 +1213,7 @@ boolean HGetPacket(void) } break; } -#endif // ndef NONET +#endif // ifndef NONET return true; } -- 2.54.0 From bd8ff77fe00700aada3495b4b5c8ac583f1051ef Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 15 Jul 2024 13:56:28 +0200 Subject: [PATCH 160/525] more mobj reference fixes + cleanup --- src/g_game.c | 1 - src/lua_script.c | 24 ++++--- src/m_cheat.c | 5 +- src/p_enemy.c | 8 ++- src/p_floor.c | 24 ------- src/p_mobj.c | 71 ++++++++++---------- src/p_polyobj.c | 167 ++++++++++++++++++++--------------------------- src/p_saveg.c | 20 +++--- src/p_spec.c | 53 ++++++++------- src/p_user.c | 20 +++--- 10 files changed, 179 insertions(+), 214 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c7e13a7fb..d1a3106ae 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5622,7 +5622,6 @@ void G_ConsGhostTic(INT32 playernum) mobj = (mobj_t *)th; if (mobj->type == (mobjtype_t)type && mobj->x == x && mobj->y == y && mobj->z == z) break; - mobj = NULL; // wasn't this one, keep searching. } if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { diff --git a/src/lua_script.c b/src/lua_script.c index c01e4c99e..5413c007a 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1592,12 +1592,14 @@ void LUA_Archive(void) if (gamestate == GS_LEVEL) { for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - { - // archive function will determine when to skip mobjs, - // and write mobjnum in otherwise. - ArchiveExtVars(th, "mobj"); - } + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + // archive function will determine when to skip mobjs, + // and write mobjnum in otherwise. + ArchiveExtVars(th, "mobj"); + } } WRITEUINT32(save_p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. @@ -1627,9 +1629,13 @@ void LUA_UnArchive(void) do { mobjnum = READUINT32(save_p); // read a mobjnum for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker - && ((mobj_t *)th)->mobjnum == mobjnum) // find matching mobj - UnArchiveExtVars(th); // apply variables + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (((mobj_t *)th)->mobjnum != mobjnum) // find matching mobj + continue; + UnArchiveExtVars(th); // apply variables + } } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. LUAh_NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode diff --git a/src/m_cheat.c b/src/m_cheat.c index 91ca536c8..abada4be5 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -909,8 +909,9 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mo = (mobj_t *)th; // get offset from mt, which points to old mapthings, then add new location - if (mo->spawnpoint) - mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; + if (!mo->spawnpoint) + continue; + mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; } } diff --git a/src/p_enemy.c b/src/p_enemy.c index caa85e331..3a032fbf0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2418,9 +2418,11 @@ void A_1upThinker(mobj_t *actor) if (closestplayer == -1 || skins[players[closestplayer].skin].spritedef.numframes <= states[S_PLAY_BOX1].frame) { // Closest player not found (no players in game?? may be empty dedicated server!), or does not have correct sprite. actor->frame = 0; - if (actor->tracer) { - P_RemoveMobj(actor->tracer); - P_SetTarget(&actor->target, NULL); + if (actor->tracer) + { + mobj_t *tracer = actor->tracer; + P_SetTarget(&actor->tracer, NULL); + P_RemoveMobj(tracer); } return; } diff --git a/src/p_floor.c b/src/p_floor.c index 27460eda6..bebc9a272 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1968,32 +1968,8 @@ void T_ThwompSector(levelspecthink_t *thwomp) } else // Not going anywhere, so look for players. { - //thinker_t *th; - //mobj_t *mo; - thwomp->direction = -1; - /* // SRB2kart 170217 - Thwomps are automatic. - // scan the thinkers to find players! - if (!rover || (rover->flags & FF_EXISTS)) - { - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->player && !mo->player->spectator - && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) - { - thwomp->direction = -1; - break; - } - } - }*/ - thwomp->sector->ceilspeed = 0; thwomp->sector->floorspeed = 0; } diff --git a/src/p_mobj.c b/src/p_mobj.c index ac983fdfd..711bc8b33 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4114,11 +4114,21 @@ static void P_Boss3Thinker(mobj_t *mobj) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && mo2->spawnpoint->angle == mobj->threshold) - { - P_SetTarget(&mobj->target, mo2); - break; - } + + if (!mo2) + continue; + + if (mo2->type != MT_BOSS3WAYPOINT) + continue; + + if (!mo2->spawnpoint) + continue; + + if (mo2->spawnpoint->angle != mobj->threshold) + continue; + + P_SetTarget(&mobj->target, mo2); + break; } if (!mobj->target) // Should NEVER happen @@ -10005,28 +10015,19 @@ void P_RemoveMobj(mobj_t *mobj) // killough 11/98: // // Remove any references to other mobjs. - P_SetTarget(&mobj->target, P_SetTarget(&mobj->tracer, NULL)); + P_SetTarget(&mobj->target, NULL); + P_SetTarget(&mobj->tracer, NULL); - // repair hnext chain - { - mobj_t *cachenext = mobj->hnext; + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) + P_SetTarget(&mobj->hprev->hnext, mobj->hnext); - if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) - { - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); - P_SetTarget(&mobj->hnext, NULL); - } - - if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) - { - P_SetTarget(&mobj->hprev->hnext, cachenext); - P_SetTarget(&mobj->hprev, NULL); - } - } + P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); // clear the reference from the mapthing if (mobj->spawnpoint) - mobj->spawnpoint->mobj = NULL; + P_SetTarget(&mobj->spawnpoint->mobj, NULL); R_RemoveMobjInterpolator(mobj); @@ -11777,11 +11778,12 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) { P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; } else - mobj->hprev = mobj->hnext = NULL; + { + P_SetTarget(&mobj->hprev, NULL); + P_SetTarget(&mobj->hnext, NULL); + } nextmobj = mobj; } @@ -11807,11 +11809,9 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->z -= mobj->height/2; // Link all the collision sprites together. - mobj->hnext = NULL; + P_SetTarget(&mobj->hnext, NULL); P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; nextmobj = mobj; } @@ -11836,11 +11836,9 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->z -= mobj->height/2; // Link all the collision sprites together. - mobj->hnext = NULL; + P_SetTarget(&mobj->hnext, NULL); P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; nextmobj = mobj; } @@ -11923,11 +11921,12 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) { P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; } else - mobj->hprev = mobj->hnext = NULL; + { + P_SetTarget(&mobj->hprev, NULL); + P_SetTarget(&mobj->hnext, NULL); + } nextmobj = mobj; } @@ -11964,11 +11963,9 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->z -= mobj->height/2; // Link all the collision sprites together. - mobj->hnext = NULL; + P_SetTarget(&mobj->hnext, NULL); P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; nextmobj = mobj; } diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 9a3376595..bbf934231 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1826,11 +1826,14 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == th->sequence && mo2->health == th->pointnum) - { - target = mo2; - break; - } + if (mo2->threshold != th->sequence) + continue; + + if (mo2->health != th->pointnum) + continue; + + target = mo2; + break; } if (!target) @@ -1907,23 +1910,23 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == th->sequence) + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) { - if (th->direction == -1) + if (mo2->health == target->health - 1) { - if (mo2->health == target->health - 1) - { - waypoint = mo2; - break; - } + waypoint = mo2; + break; } - else + } + else + { + if (mo2->health == target->health + 1) { - if (mo2->health == target->health + 1) - { - waypoint = mo2; - break; - } + waypoint = mo2; + break; } } } @@ -1946,22 +1949,22 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == th->sequence) + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) { - if (th->direction == -1) + if (waypoint == NULL) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; + } + else + { + if (mo2->health == 0) { - if (waypoint == NULL) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; - } - else - { - if (mo2->health == 0) - { - waypoint = mo2; - break; - } + waypoint = mo2; + break; } } } @@ -1983,23 +1986,23 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == th->sequence) + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) { - if (th->direction == -1) + if (mo2->health == target->health - 1) { - if (mo2->health == target->health - 1) - { - waypoint = mo2; - break; - } + waypoint = mo2; + break; } - else + } + else + { + if (mo2->health == target->health + 1) { - if (mo2->health == target->health + 1) - { - waypoint = mo2; - break; - } + waypoint = mo2; + break; } } } @@ -2503,31 +2506,31 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == th->sequence) + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) // highest waypoint # { - if (th->direction == -1) // highest waypoint # + if (mo2->health == 0) + last = mo2; + else { - if (mo2->health == 0) - last = mo2; - else - { - if (first == NULL) - first = mo2; - else if (mo2->health > first->health) - first = mo2; - } - } - else // waypoint 0 - { - if (mo2->health == 0) + if (first == NULL) first = mo2; - else - { - if (last == NULL) - last = mo2; - else if (mo2->health > last->health) - last = mo2; - } + else if (mo2->health > first->health) + first = mo2; + } + } + else // waypoint 0 + { + if (mo2->health == 0) + first = mo2; + else + { + if (last == NULL) + last = mo2; + else if (mo2->health > last->health) + last = mo2; } } } @@ -2564,36 +2567,6 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) // Find the actual target movement waypoint target = first; - /*for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) - { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)wp; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == th->sequence) - { - if (th->direction == -1) // highest waypoint # - { - if (mo2->health == first->health - 1) - { - target = mo2; - break; - } - } - else // waypoint 0 - { - if (mo2->health == first->health + 1) - { - target = mo2; - break; - } - } - } - }*/ if (!target) { diff --git a/src/p_saveg.c b/src/p_saveg.c index e260321be..be393c51b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1881,8 +1881,10 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) continue; mobj = (mobj_t *)th; - if (mobj->mobjnum == oldposition) - return mobj; + if (mobj->mobjnum != oldposition) + continue; + + return mobj; } CONS_Debug(DBG_GAMELOGIC, "mobj not found\n"); return NULL; @@ -2881,12 +2883,14 @@ static void P_NetUnArchiveThinkers(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)T_ExecutorDelay) - { - delay = (void *)currentthinker; - if ((mobjnum = (UINT32)(size_t)delay->caller)) - delay->caller = P_FindNewPosition(mobjnum); - } + if (currentthinker->function.acp1 != (actionf_p1)T_ExecutorDelay) + continue; + + delay = (void *)currentthinker; + if (!(mobjnum = (UINT32)(size_t)delay->caller)) + continue; + + delay->caller = P_FindNewPosition(mobjnum); } } } diff --git a/src/p_spec.c b/src/p_spec.c index 1a5e02a78..e72cb5371 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3313,7 +3313,7 @@ boolean P_IsFlagAtBase(mobjtype_t flag) { thinker_t *think; mobj_t *mo; - INT32 specialnum = 0; + INT32 specialnum = (flag == MT_REDFLAG) ? 3 : 4; for (think = thinkercap.next; think != &thinkercap; think = think->next) { @@ -3325,11 +3325,6 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (mo->type != flag) continue; - if (mo->type == MT_REDFLAG) - specialnum = 3; - else if (mo->type == MT_BLUEFLAG) - specialnum = 4; - if (GETSECSPECIAL(mo->subsector->sector->special, 4) == specialnum) return true; else if (mo->subsector->sector->ffloors) // Check the 3D floors @@ -3344,9 +3339,11 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (GETSECSPECIAL(rover->master->frontsector->special, 4) != specialnum) continue; - if (mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) - && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector)) - return true; + if (!(mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) + && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))) + continue; + + return true; } } } @@ -3762,8 +3759,11 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_EGGTRAP) - P_KillMobj(mo2, NULL, player->mo); + + if (mo2->type != MT_EGGTRAP) + continue; + + P_KillMobj(mo2, NULL, player->mo); } // clear the special so you can't push the button twice. @@ -4104,12 +4104,15 @@ DoneSection2: mo2 = (mobj_t *)th; - if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence - && mo2->health == 0) - { - waypoint = mo2; - break; - } + if (mo2->type != MT_TUBEWAYPOINT) + continue; + if (mo2->threshold != sequence) + continue; + if (mo2->health != 0) + continue; + + waypoint = mo2; + break; } if (!waypoint) @@ -4180,13 +4183,15 @@ DoneSection2: mo2 = (mobj_t *)th; - if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence) - { - if (!waypoint) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; - } + if (mo2->type != MT_TUBEWAYPOINT) + continue; + if (mo2->threshold != sequence) + continue; + + if (!waypoint) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; } if (!waypoint) diff --git a/src/p_user.c b/src/p_user.c index 74e9ae785..c3dacfa60 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2629,15 +2629,17 @@ static void P_DoZoomTube(player_t *player) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == sequence) - { - if ((reverse && mo2->health == player->mo->tracer->health - 1) - || (!reverse && mo2->health == player->mo->tracer->health + 1)) - { - waypoint = mo2; - break; - } - } + if (mo2->threshold != sequence) + continue; + + if (reverse && mo2->health != player->mo->tracer->health - 1) + continue; + + if (!reverse && mo2->health != player->mo->tracer->health + 1) + continue; + + waypoint = mo2; + break; } if (waypoint) -- 2.54.0 From d324c917ad1509da03de6888867d223a2abe4f79 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 15 Jul 2024 20:57:09 +0200 Subject: [PATCH 161/525] Revert "fix some clang warnings" This reverts commit fea89de0374572885144be391d6313f6bee7d697. --- src/info.h | 408 +++++++++++++++++++++++++------------------------- src/p_mobj.c | 344 +++++++++++++++++++++--------------------- src/r_draw8.c | 2 +- src/r_main.c | 4 + src/r_plane.c | 25 ++-- src/r_segs.c | 26 ++-- 6 files changed, 400 insertions(+), 409 deletions(-) diff --git a/src/info.h b/src/info.h index aff87a663..b1955340b 100644 --- a/src/info.h +++ b/src/info.h @@ -245,213 +245,211 @@ enum actionnum NUMACTIONS }; -struct mobj_s; - // IMPORTANT NOTE: If you add/remove from this list of action // functions, don't forget to update them in dehacked.c! -void A_Explode(struct mobj_s *actor); -void A_Pain(struct mobj_s *actor); -void A_Fall(struct mobj_s *actor); -void A_MonitorPop(struct mobj_s *actor); -void A_Look(struct mobj_s *actor); -void A_Chase(struct mobj_s *actor); -void A_FaceStabChase(struct mobj_s *actor); -void A_FaceTarget(struct mobj_s *actor); -void A_FaceTracer(struct mobj_s *actor); -void A_Scream(struct mobj_s *actor); -void A_BossDeath(struct mobj_s *actor); -void A_CustomPower(struct mobj_s *actor); // Use this for a custom power -void A_GiveWeapon(struct mobj_s *actor); // Gives the player weapon(s) -void A_JumpShield(struct mobj_s *actor); // Obtained Jump Shield -void A_RingShield(struct mobj_s *actor); // Obtained Ring Shield -void A_RingBox(struct mobj_s *actor); // Obtained Ring Box Tails -void A_Invincibility(struct mobj_s *actor); // Obtained Invincibility Box -void A_SuperSneakers(struct mobj_s *actor); // Obtained Super Sneakers Box -void A_BunnyHop(struct mobj_s *actor); // have bunny hop tails -void A_BubbleSpawn(struct mobj_s *actor); // Randomly spawn bubbles -void A_FanBubbleSpawn(struct mobj_s *actor); -void A_BubbleRise(struct mobj_s *actor); // Bubbles float to surface -void A_BubbleCheck(struct mobj_s *actor); // Don't draw if not underwater -void A_AwardScore(struct mobj_s *actor); -void A_ExtraLife(struct mobj_s *actor); // Extra Life -void A_BombShield(struct mobj_s *actor); // Obtained Bomb Shield -void A_WaterShield(struct mobj_s *actor); // Obtained Water Shield -void A_ForceShield(struct mobj_s *actor); // Obtained Force Shield -void A_PityShield(struct mobj_s *actor); // Obtained Pity Shield. We're... sorry. -void A_GravityBox(struct mobj_s *actor); -void A_ScoreRise(struct mobj_s *actor); // Rise the score logo -void A_ParticleSpawn(struct mobj_s *actor); -void A_AttractChase(struct mobj_s *actor); // Ring Chase -void A_DropMine(struct mobj_s *actor); // Drop Mine from Skim or Jetty-Syn Bomber -void A_FishJump(struct mobj_s *actor); // Fish Jump -void A_ThrownRing(struct mobj_s *actor); // Sparkle trail for red ring -void A_GrenadeRing(struct mobj_s *actor); // SRB2kart -void A_SetSolidSteam(struct mobj_s *actor); -void A_UnsetSolidSteam(struct mobj_s *actor); -void A_SignPlayer(struct mobj_s *actor); -void A_OverlayThink(struct mobj_s *actor); -void A_JetChase(struct mobj_s *actor); -void A_JetbThink(struct mobj_s *actor); // Jetty-Syn Bomber Thinker -void A_JetgThink(struct mobj_s *actor); // Jetty-Syn Gunner Thinker -void A_JetgShoot(struct mobj_s *actor); // Jetty-Syn Shoot Function -void A_ShootBullet(struct mobj_s *actor); // JetgShoot without reactiontime setting -void A_MinusDigging(struct mobj_s *actor); -void A_MinusPopup(struct mobj_s *actor); -void A_MinusCheck(struct mobj_s *actor); -void A_ChickenCheck(struct mobj_s *actor); -void A_MouseThink(struct mobj_s *actor); // Mouse Thinker -void A_DetonChase(struct mobj_s *actor); // Deton Chaser -void A_CapeChase(struct mobj_s *actor); // Fake little Super Sonic cape -void A_RotateSpikeBall(struct mobj_s *actor); // Spike ball rotation -void A_SlingAppear(struct mobj_s *actor); -void A_MaceRotate(struct mobj_s *actor); -void A_UnidusBall(struct mobj_s *actor); -void A_RockSpawn(struct mobj_s *actor); -void A_SetFuse(struct mobj_s *actor); -void A_CrawlaCommanderThink(struct mobj_s *actor); // Crawla Commander -void A_SmokeTrailer(struct mobj_s *actor); -void A_RingExplode(struct mobj_s *actor); -void A_OldRingExplode(struct mobj_s *actor); -void A_MixUp(struct mobj_s *actor); -void A_RecyclePowers(struct mobj_s *actor); -void A_BossScream(struct mobj_s *actor); -void A_Boss2TakeDamage(struct mobj_s *actor); -void A_GoopSplat(struct mobj_s *actor); -void A_Boss2PogoSFX(struct mobj_s *actor); -void A_Boss2PogoTarget(struct mobj_s *actor); -void A_EggmanBox(struct mobj_s *actor); -void A_TurretFire(struct mobj_s *actor); -void A_SuperTurretFire(struct mobj_s *actor); -void A_TurretStop(struct mobj_s *actor); -void A_JetJawRoam(struct mobj_s *actor); -void A_JetJawChomp(struct mobj_s *actor); -void A_PointyThink(struct mobj_s *actor); -void A_CheckBuddy(struct mobj_s *actor); -void A_HoodThink(struct mobj_s *actor); -void A_ArrowCheck(struct mobj_s *actor); -void A_SnailerThink(struct mobj_s *actor); -void A_SharpChase(struct mobj_s *actor); -void A_SharpSpin(struct mobj_s *actor); -void A_VultureVtol(struct mobj_s *actor); -void A_VultureCheck(struct mobj_s *actor); -void A_SkimChase(struct mobj_s *actor); -void A_SkullAttack(struct mobj_s *actor); -void A_LobShot(struct mobj_s *actor); -void A_FireShot(struct mobj_s *actor); -void A_SuperFireShot(struct mobj_s *actor); -void A_BossFireShot(struct mobj_s *actor); -void A_Boss7FireMissiles(struct mobj_s *actor); -void A_Boss1Laser(struct mobj_s *actor); -void A_FocusTarget(struct mobj_s *actor); -void A_Boss4Reverse(struct mobj_s *actor); -void A_Boss4SpeedUp(struct mobj_s *actor); -void A_Boss4Raise(struct mobj_s *actor); -void A_SparkFollow(struct mobj_s *actor); -void A_BuzzFly(struct mobj_s *actor); -void A_GuardChase(struct mobj_s *actor); -void A_EggShield(struct mobj_s *actor); -void A_SetReactionTime(struct mobj_s *actor); -void A_Boss1Spikeballs(struct mobj_s *actor); -void A_Boss3TakeDamage(struct mobj_s *actor); -void A_Boss3Path(struct mobj_s *actor); -void A_LinedefExecute(struct mobj_s *actor); -void A_PlaySeeSound(struct mobj_s *actor); -void A_PlayAttackSound(struct mobj_s *actor); -void A_PlayActiveSound(struct mobj_s *actor); -void A_1upThinker(struct mobj_s *actor); -void A_BossZoom(struct mobj_s *actor); //Unused -void A_Boss1Chase(struct mobj_s *actor); -void A_Boss2Chase(struct mobj_s *actor); -void A_Boss2Pogo(struct mobj_s *actor); -void A_Boss7Chase(struct mobj_s *actor); -void A_BossJetFume(struct mobj_s *actor); -void A_SpawnObjectAbsolute(struct mobj_s *actor); -void A_SpawnObjectRelative(struct mobj_s *actor); -void A_ChangeAngleRelative(struct mobj_s *actor); -void A_ChangeAngleAbsolute(struct mobj_s *actor); -void A_RollAngle(struct mobj_s *actor); -void A_ChangeRollAngleRelative(struct mobj_s *actor); -void A_ChangeRollAngleAbsolute(struct mobj_s *actor); -void A_PlaySound(struct mobj_s *actor); -void A_FindTarget(struct mobj_s *actor); -void A_FindTracer(struct mobj_s *actor); -void A_SetTics(struct mobj_s *actor); -void A_SetRandomTics(struct mobj_s *actor); -void A_ChangeColorRelative(struct mobj_s *actor); -void A_ChangeColorAbsolute(struct mobj_s *actor); -void A_MoveRelative(struct mobj_s *actor); -void A_MoveAbsolute(struct mobj_s *actor); -void A_Thrust(struct mobj_s *actor); -void A_ZThrust(struct mobj_s *actor); -void A_SetTargetsTarget(struct mobj_s *actor); -void A_SetObjectFlags(struct mobj_s *actor); -void A_SetObjectFlags2(struct mobj_s *actor); -void A_RandomState(struct mobj_s *actor); -void A_RandomStateRange(struct mobj_s *actor); -void A_DualAction(struct mobj_s *actor); -void A_RemoteAction(struct mobj_s *actor); -void A_ToggleFlameJet(struct mobj_s *actor); -void A_ItemPop(struct mobj_s *actor); // SRB2kart -void A_JawzChase(struct mobj_s *actor); // SRB2kart -void A_JawzExplode(struct mobj_s *actor); // SRB2kart -void A_SPBChase(struct mobj_s *actor); // SRB2kart -void A_MineExplode(struct mobj_s *actor); // SRB2kart -void A_BallhogExplode(struct mobj_s *actor); // SRB2kart -void A_LightningFollowPlayer(struct mobj_s *actor); // SRB2kart: Lightning shield effect player chasing -void A_FZBoomFlash(struct mobj_s *actor); // SRB2kart -void A_FZBoomSmoke(struct mobj_s *actor); // SRB2kart -void A_RandomShadowFrame(struct mobj_s *actor); //SRB2kart: Shadow spawner frame randomizer -void A_RoamingShadowThinker(struct mobj_s *actor); // SRB2kart: Roaming Shadow moving + attacking players. -void A_MayonakaArrow(struct mobj_s *actor); //SRB2kart: midnight channel arrow sign -void A_ReaperThinker(struct mobj_s *actor); //SRB2kart: mementos reaper -void A_MementosTPParticles(struct mobj_s *actor); //SRB2kart: mementos teleporter particles. Man that's a lot of actions for my shite. -void A_FlameParticle(struct mobj_s *actor); // SRB2kart -void A_OrbitNights(struct mobj_s *actor); -void A_GhostMe(struct mobj_s *actor); -void A_SetObjectState(struct mobj_s *actor); -void A_SetObjectTypeState(struct mobj_s *actor); -void A_KnockBack(struct mobj_s *actor); -void A_PushAway(struct mobj_s *actor); -void A_RingDrain(struct mobj_s *actor); -void A_SplitShot(struct mobj_s *actor); -void A_MissileSplit(struct mobj_s *actor); -void A_MultiShot(struct mobj_s *actor); -void A_InstaLoop(struct mobj_s *actor); -void A_Custom3DRotate(struct mobj_s *actor); -void A_SearchForPlayers(struct mobj_s *actor); -void A_CheckRandom(struct mobj_s *actor); -void A_CheckTargetRings(struct mobj_s *actor); -void A_CheckRings(struct mobj_s *actor); -void A_CheckTotalRings(struct mobj_s *actor); -void A_CheckHealth(struct mobj_s *actor); -void A_CheckRange(struct mobj_s *actor); -void A_CheckHeight(struct mobj_s *actor); -void A_CheckTrueRange(struct mobj_s *actor); -void A_CheckThingCount(struct mobj_s *actor); -void A_CheckAmbush(struct mobj_s *actor); -void A_CheckCustomValue(struct mobj_s *actor); -void A_CheckCusValMemo(struct mobj_s *actor); -void A_SetCustomValue(struct mobj_s *actor); -void A_UseCusValMemo(struct mobj_s *actor); -void A_RelayCustomValue(struct mobj_s *actor); -void A_CusValAction(struct mobj_s *actor); -void A_ForceStop(struct mobj_s *actor); -void A_ForceWin(struct mobj_s *actor); -void A_SpikeRetract(struct mobj_s *actor); -void A_InfoState(struct mobj_s *actor); -void A_Repeat(struct mobj_s *actor); -void A_SetScale(struct mobj_s *actor); -void A_RemoteDamage(struct mobj_s *actor); -void A_HomingChase(struct mobj_s *actor); -void A_TrapShot(struct mobj_s *actor); -void A_VileTarget(struct mobj_s *actor); -void A_VileAttack(struct mobj_s *actor); -void A_VileFire(struct mobj_s *actor); -void A_BrakChase(struct mobj_s *actor); -void A_BrakFireShot(struct mobj_s *actor); -void A_BrakLobShot(struct mobj_s *actor); -void A_NapalmScatter(struct mobj_s *actor); -void A_SpawnFreshCopy(struct mobj_s *actor); +void A_Explode(); +void A_Pain(); +void A_Fall(); +void A_MonitorPop(); +void A_Look(); +void A_Chase(); +void A_FaceStabChase(); +void A_FaceTarget(); +void A_FaceTracer(); +void A_Scream(); +void A_BossDeath(); +void A_CustomPower(); // Use this for a custom power +void A_GiveWeapon(); // Gives the player weapon(s) +void A_JumpShield(); // Obtained Jump Shield +void A_RingShield(); // Obtained Ring Shield +void A_RingBox(); // Obtained Ring Box Tails +void A_Invincibility(); // Obtained Invincibility Box +void A_SuperSneakers(); // Obtained Super Sneakers Box +void A_BunnyHop(); // have bunny hop tails +void A_BubbleSpawn(); // Randomly spawn bubbles +void A_FanBubbleSpawn(); +void A_BubbleRise(); // Bubbles float to surface +void A_BubbleCheck(); // Don't draw if not underwater +void A_AwardScore(); +void A_ExtraLife(); // Extra Life +void A_BombShield(); // Obtained Bomb Shield +void A_WaterShield(); // Obtained Water Shield +void A_ForceShield(); // Obtained Force Shield +void A_PityShield(); // Obtained Pity Shield. We're... sorry. +void A_GravityBox(); +void A_ScoreRise(); // Rise the score logo +void A_ParticleSpawn(); +void A_AttractChase(); // Ring Chase +void A_DropMine(); // Drop Mine from Skim or Jetty-Syn Bomber +void A_FishJump(); // Fish Jump +void A_ThrownRing(); // Sparkle trail for red ring +void A_GrenadeRing(); // SRB2kart +void A_SetSolidSteam(); +void A_UnsetSolidSteam(); +void A_SignPlayer(); +void A_OverlayThink(); +void A_JetChase(); +void A_JetbThink(); // Jetty-Syn Bomber Thinker +void A_JetgThink(); // Jetty-Syn Gunner Thinker +void A_JetgShoot(); // Jetty-Syn Shoot Function +void A_ShootBullet(); // JetgShoot without reactiontime setting +void A_MinusDigging(); +void A_MinusPopup(); +void A_MinusCheck(); +void A_ChickenCheck(); +void A_MouseThink(); // Mouse Thinker +void A_DetonChase(); // Deton Chaser +void A_CapeChase(); // Fake little Super Sonic cape +void A_RotateSpikeBall(); // Spike ball rotation +void A_SlingAppear(); +void A_MaceRotate(); +void A_UnidusBall(); +void A_RockSpawn(); +void A_SetFuse(); +void A_CrawlaCommanderThink(); // Crawla Commander +void A_SmokeTrailer(); +void A_RingExplode(); +void A_OldRingExplode(); +void A_MixUp(); +void A_RecyclePowers(); +void A_BossScream(); +void A_Boss2TakeDamage(); +void A_GoopSplat(); +void A_Boss2PogoSFX(); +void A_Boss2PogoTarget(); +void A_EggmanBox(); +void A_TurretFire(); +void A_SuperTurretFire(); +void A_TurretStop(); +void A_JetJawRoam(); +void A_JetJawChomp(); +void A_PointyThink(); +void A_CheckBuddy(); +void A_HoodThink(); +void A_ArrowCheck(); +void A_SnailerThink(); +void A_SharpChase(); +void A_SharpSpin(); +void A_VultureVtol(); +void A_VultureCheck(); +void A_SkimChase(); +void A_SkullAttack(); +void A_LobShot(); +void A_FireShot(); +void A_SuperFireShot(); +void A_BossFireShot(); +void A_Boss7FireMissiles(); +void A_Boss1Laser(); +void A_FocusTarget(); +void A_Boss4Reverse(); +void A_Boss4SpeedUp(); +void A_Boss4Raise(); +void A_SparkFollow(); +void A_BuzzFly(); +void A_GuardChase(); +void A_EggShield(); +void A_SetReactionTime(); +void A_Boss1Spikeballs(); +void A_Boss3TakeDamage(); +void A_Boss3Path(); +void A_LinedefExecute(); +void A_PlaySeeSound(); +void A_PlayAttackSound(); +void A_PlayActiveSound(); +void A_1upThinker(); +void A_BossZoom(); //Unused +void A_Boss1Chase(); +void A_Boss2Chase(); +void A_Boss2Pogo(); +void A_Boss7Chase(); +void A_BossJetFume(); +void A_SpawnObjectAbsolute(); +void A_SpawnObjectRelative(); +void A_ChangeAngleRelative(); +void A_ChangeAngleAbsolute(); +void A_RollAngle(); +void A_ChangeRollAngleRelative(); +void A_ChangeRollAngleAbsolute(); +void A_PlaySound(); +void A_FindTarget(); +void A_FindTracer(); +void A_SetTics(); +void A_SetRandomTics(); +void A_ChangeColorRelative(); +void A_ChangeColorAbsolute(); +void A_MoveRelative(); +void A_MoveAbsolute(); +void A_Thrust(); +void A_ZThrust(); +void A_SetTargetsTarget(); +void A_SetObjectFlags(); +void A_SetObjectFlags2(); +void A_RandomState(); +void A_RandomStateRange(); +void A_DualAction(); +void A_RemoteAction(); +void A_ToggleFlameJet(); +void A_ItemPop(); // SRB2kart +void A_JawzChase(); // SRB2kart +void A_JawzExplode(); // SRB2kart +void A_SPBChase(); // SRB2kart +void A_MineExplode(); // SRB2kart +void A_BallhogExplode(); // SRB2kart +void A_LightningFollowPlayer(); // SRB2kart: Lightning shield effect player chasing +void A_FZBoomFlash(); // SRB2kart +void A_FZBoomSmoke(); // SRB2kart +void A_RandomShadowFrame(); //SRB2kart: Shadow spawner frame randomizer +void A_RoamingShadowThinker(); // SRB2kart: Roaming Shadow moving + attacking players. +void A_MayonakaArrow(); //SRB2kart: midnight channel arrow sign +void A_ReaperThinker(); //SRB2kart: mementos reaper +void A_MementosTPParticles(); //SRB2kart: mementos teleporter particles. Man that's a lot of actions for my shite. +void A_FlameParticle(); // SRB2kart +void A_OrbitNights(); +void A_GhostMe(); +void A_SetObjectState(); +void A_SetObjectTypeState(); +void A_KnockBack(); +void A_PushAway(); +void A_RingDrain(); +void A_SplitShot(); +void A_MissileSplit(); +void A_MultiShot(); +void A_InstaLoop(); +void A_Custom3DRotate(); +void A_SearchForPlayers(); +void A_CheckRandom(); +void A_CheckTargetRings(); +void A_CheckRings(); +void A_CheckTotalRings(); +void A_CheckHealth(); +void A_CheckRange(); +void A_CheckHeight(); +void A_CheckTrueRange(); +void A_CheckThingCount(); +void A_CheckAmbush(); +void A_CheckCustomValue(); +void A_CheckCusValMemo(); +void A_SetCustomValue(); +void A_UseCusValMemo(); +void A_RelayCustomValue(); +void A_CusValAction(); +void A_ForceStop(); +void A_ForceWin(); +void A_SpikeRetract(); +void A_InfoState(); +void A_Repeat(); +void A_SetScale(); +void A_RemoteDamage(); +void A_HomingChase(); +void A_TrapShot(); +void A_VileTarget(); +void A_VileAttack(); +void A_VileFire(); +void A_BrakChase(); +void A_BrakFireShot(); +void A_BrakLobShot(); +void A_NapalmScatter(); +void A_SpawnFreshCopy(); extern boolean actionsoverridden[NUMACTIONS]; diff --git a/src/p_mobj.c b/src/p_mobj.c index 711bc8b33..52c8116f1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -5893,6 +5893,7 @@ static void P_RemoveShadow(mobj_t *thing) } } +void A_BossDeath(mobj_t *mo); // AI for the Koopa boss. static void P_KoopaThinker(mobj_t *koopa) { @@ -8757,7 +8758,6 @@ void P_MobjThinker(mobj_t *mobj) } break; } - if (P_MobjWasRemoved(mobj)) return; @@ -8812,7 +8812,6 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->fuse) { mobj->fuse--; - if (!mobj->fuse) { subsector_t *ss; @@ -8820,199 +8819,196 @@ void P_MobjThinker(mobj_t *mobj) mobj_t *flagmo, *newmobj; if (!LUAh_MobjFuse(mobj) && !P_MobjWasRemoved(mobj)) + switch (mobj->type) { - switch (mobj->type) - { - // gargoyle and snowman handled in P_PushableThinker, not here - case MT_THROWNGRENADE: - case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: - P_SetMobjState(mobj, mobj->info->deathstate); - break; - case MT_BLUEFLAG: - case MT_REDFLAG: - if (mobj->spawnpoint) + // gargoyle and snowman handled in P_PushableThinker, not here + case MT_THROWNGRENADE: + case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: + P_SetMobjState(mobj, mobj->info->deathstate); + break; + case MT_BLUEFLAG: + case MT_REDFLAG: + if (mobj->spawnpoint) + { + x = mobj->spawnpoint->x << FRACBITS; + y = mobj->spawnpoint->y << FRACBITS; + ss = R_PointInSubsector(x, y); + if (mobj->spawnpoint->options & MTF_OBJECTFLIP) { - x = mobj->spawnpoint->x << FRACBITS; - y = mobj->spawnpoint->y << FRACBITS; - ss = R_PointInSubsector(x, y); - if (mobj->spawnpoint->options & MTF_OBJECTFLIP) - { - z = ss->sector->ceilingheight - mobjinfo[mobj->type].height; - if (mobj->spawnpoint->options >> ZSHIFT) - z -= (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; - } - else - { - z = ss->sector->floorheight; - if (mobj->spawnpoint->options >> ZSHIFT) - z += (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; - } - flagmo = P_SpawnMobj(x, y, z, mobj->type); - flagmo->spawnpoint = mobj->spawnpoint; - if (mobj->spawnpoint->options & MTF_OBJECTFLIP) - { - flagmo->eflags |= MFE_VERTICALFLIP; - flagmo->flags2 |= MF2_OBJECTFLIP; - } - - if (mobj->type == MT_REDFLAG) - { - if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); - - // Assumedly in splitscreen players will be on opposing teams - if (players[consoleplayer].ctfteam == 1 || splitscreen) - S_StartSound(NULL, sfx_hoop1); - else if (players[consoleplayer].ctfteam == 2) - S_StartSound(NULL, sfx_hoop3); - - redflag = flagmo; - } - else // MT_BLUEFLAG - { - if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); - - // Assumedly in splitscreen players will be on opposing teams - if (players[consoleplayer].ctfteam == 2 || splitscreen) - S_StartSound(NULL, sfx_hoop1); - else if (players[consoleplayer].ctfteam == 1) - S_StartSound(NULL, sfx_hoop3); - - blueflag = flagmo; - } + z = ss->sector->ceilingheight - mobjinfo[mobj->type].height; + if (mobj->spawnpoint->options >> ZSHIFT) + z -= (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; } - P_RemoveMobj(mobj); - return; - case MT_YELLOWTV: // Ring shield box - case MT_BLUETV: // Force shield box - case MT_GREENTV: // Water shield box - case MT_BLACKTV: // Bomb shield box - case MT_WHITETV: // Jump shield box - case MT_SNEAKERTV: // Super Sneaker box - case MT_SUPERRINGBOX: // 10-Ring box - case MT_REDRINGBOX: // Red Team 10-Ring box - case MT_BLUERINGBOX: // Blue Team 10-Ring box - case MT_INV: // Invincibility box - case MT_MIXUPBOX: // Teleporter Mixup box - case MT_RECYCLETV: // Recycler box - case MT_SCORETVSMALL: - case MT_SCORETVLARGE: - case MT_PRUP: // 1up! - case MT_EGGMANBOX: // Eggman box - case MT_GRAVITYBOX: // Gravity box - case MT_QUESTIONBOX: - if ((mobj->flags2 & MF2_AMBUSH || mobj->flags2 & MF2_STRONGBOX) && mobj->type != MT_QUESTIONBOX) + else { - mobjtype_t spawnchance[64]; - INT32 numchoices = 0, i = 0; + z = ss->sector->floorheight; + if (mobj->spawnpoint->options >> ZSHIFT) + z += (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; + } + flagmo = P_SpawnMobj(x, y, z, mobj->type); + flagmo->spawnpoint = mobj->spawnpoint; + if (mobj->spawnpoint->options & MTF_OBJECTFLIP) + { + flagmo->eflags |= MFE_VERTICALFLIP; + flagmo->flags2 |= MF2_OBJECTFLIP; + } - // This define should make it a lot easier to organize and change monitor weights + if (mobj->type == MT_REDFLAG) + { + if (!(mobj->flags2 & MF2_JUSTATTACKED)) + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); + + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 1 || splitscreen) + S_StartSound(NULL, sfx_hoop1); + else if (players[consoleplayer].ctfteam == 2) + S_StartSound(NULL, sfx_hoop3); + + redflag = flagmo; + } + else // MT_BLUEFLAG + { + if (!(mobj->flags2 & MF2_JUSTATTACKED)) + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); + + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 2 || splitscreen) + S_StartSound(NULL, sfx_hoop1); + else if (players[consoleplayer].ctfteam == 1) + S_StartSound(NULL, sfx_hoop3); + + blueflag = flagmo; + } + } + P_RemoveMobj(mobj); + return; + case MT_YELLOWTV: // Ring shield box + case MT_BLUETV: // Force shield box + case MT_GREENTV: // Water shield box + case MT_BLACKTV: // Bomb shield box + case MT_WHITETV: // Jump shield box + case MT_SNEAKERTV: // Super Sneaker box + case MT_SUPERRINGBOX: // 10-Ring box + case MT_REDRINGBOX: // Red Team 10-Ring box + case MT_BLUERINGBOX: // Blue Team 10-Ring box + case MT_INV: // Invincibility box + case MT_MIXUPBOX: // Teleporter Mixup box + case MT_RECYCLETV: // Recycler box + case MT_SCORETVSMALL: + case MT_SCORETVLARGE: + case MT_PRUP: // 1up! + case MT_EGGMANBOX: // Eggman box + case MT_GRAVITYBOX: // Gravity box + case MT_QUESTIONBOX: + if ((mobj->flags2 & MF2_AMBUSH || mobj->flags2 & MF2_STRONGBOX) && mobj->type != MT_QUESTIONBOX) + { + mobjtype_t spawnchance[64]; + INT32 numchoices = 0, i = 0; + +// This define should make it a lot easier to organize and change monitor weights #define SETMONITORCHANCES(type, strongboxamt, weakboxamt) \ - for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) spawnchance[numchoices++] = type +for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) spawnchance[numchoices++] = type - // Type SRM WRM - SETMONITORCHANCES(MT_SNEAKERTV, 0, 10); // Super Sneakers - SETMONITORCHANCES(MT_INV, 2, 0); // Invincibility - SETMONITORCHANCES(MT_WHITETV, 3, 8); // Whirlwind Shield - SETMONITORCHANCES(MT_GREENTV, 3, 8); // Elemental Shield - SETMONITORCHANCES(MT_YELLOWTV, 2, 0); // Attraction Shield - SETMONITORCHANCES(MT_BLUETV, 3, 3); // Force Shield - SETMONITORCHANCES(MT_BLACKTV, 2, 0); // Armageddon Shield - SETMONITORCHANCES(MT_MIXUPBOX, 0, 1); // Teleporters - SETMONITORCHANCES(MT_RECYCLETV, 0, 1); // Recycler - SETMONITORCHANCES(MT_PRUP, 1, 1); // 1-Up - // ====================================== - // Total 16 32 + // Type SRM WRM + SETMONITORCHANCES(MT_SNEAKERTV, 0, 10); // Super Sneakers + SETMONITORCHANCES(MT_INV, 2, 0); // Invincibility + SETMONITORCHANCES(MT_WHITETV, 3, 8); // Whirlwind Shield + SETMONITORCHANCES(MT_GREENTV, 3, 8); // Elemental Shield + SETMONITORCHANCES(MT_YELLOWTV, 2, 0); // Attraction Shield + SETMONITORCHANCES(MT_BLUETV, 3, 3); // Force Shield + SETMONITORCHANCES(MT_BLACKTV, 2, 0); // Armageddon Shield + SETMONITORCHANCES(MT_MIXUPBOX, 0, 1); // Teleporters + SETMONITORCHANCES(MT_RECYCLETV, 0, 1); // Recycler + SETMONITORCHANCES(MT_PRUP, 1, 1); // 1-Up + // ====================================== + // Total 16 32 #undef SETMONITORCHANCES - i = P_RandomKey(numchoices); // Gotta love those random numbers! - newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, spawnchance[i]); + i = P_RandomKey(numchoices); // Gotta love those random numbers! + newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, spawnchance[i]); - // Transfer flags2 (strongbox, objectflip, ambush) - newmobj->flags2 = mobj->flags2; + // Transfer flags2 (strongbox, objectflip, ambush) + newmobj->flags2 = mobj->flags2; + } + else + { + newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); + + // Transfer flags2 (strongbox, objectflip) + newmobj->flags2 = mobj->flags2; + } + P_RemoveMobj(mobj); // make sure they disappear + return; + case MT_RANDOMITEM: + if (G_BattleGametype()) + { + if (mobj->threshold != 69) + break; + } + else + { + // Respawn from mapthing if you have one! + if (mobj->spawnpoint) + { + P_SpawnMapThing(mobj->spawnpoint); + newmobj = mobj->spawnpoint->mobj; // this is set to the new mobj in P_SpawnMapThing } else - { newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); - // Transfer flags2 (strongbox, objectflip) - newmobj->flags2 = mobj->flags2; - } - P_RemoveMobj(mobj); // make sure they disappear - return; - case MT_RANDOMITEM: - if (G_BattleGametype()) - { - if (mobj->threshold != 69) - break; - } - else - { - // Respawn from mapthing if you have one! - if (mobj->spawnpoint) - { - P_SpawnMapThing(mobj->spawnpoint); - newmobj = mobj->spawnpoint->mobj; // this is set to the new mobj in P_SpawnMapThing - } - else - newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); + // Transfer flags2 (strongbox, objectflip) + newmobj->flags2 = mobj->flags2 & ~MF2_DONTDRAW; + } + P_RemoveMobj(mobj); // make sure they disappear + return; + case MT_METALSONIC_BATTLE: + break; // don't remove + case MT_SPIKE: + P_SetMobjState(mobj, mobj->state->nextstate); + mobj->fuse = mobj->info->speed; + if (mobj->spawnpoint) + mobj->fuse += mobj->spawnpoint->angle; + break; + case MT_NIGHTSCORE: + P_RemoveMobj(mobj); + return; + case MT_PLAYER: + break; // don't remove + case MT_SMK_ICEBLOCK: + { + mobj_t *cur = mobj->hnext, *next; + UINT8 i; - // Transfer flags2 (strongbox, objectflip) - newmobj->flags2 = mobj->flags2 & ~MF2_DONTDRAW; + for (i = 0; i < 5; i++) + { + mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS); + debris->angle = FixedAngle(P_RandomRange(0,360)<angle, P_RandomRange(3,18)*(FRACUNIT/4)); + debris->momz = P_RandomRange(4,8)<state->nextstate); - mobj->fuse = mobj->info->speed; - if (mobj->spawnpoint) - mobj->fuse += mobj->spawnpoint->angle; - break; - case MT_NIGHTSCORE: + + while (cur && !P_MobjWasRemoved(cur)) + { + next = cur->hnext; + P_RemoveMobj(cur); + cur = next; + } + P_RemoveMobj(mobj); return; - case MT_PLAYER: - break; // don't remove - case MT_SMK_ICEBLOCK: - { - mobj_t *cur = mobj->hnext, *next; - UINT8 i; - - for (i = 0; i < 5; i++) - { - mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS); - debris->angle = FixedAngle(P_RandomRange(0,360)<angle, P_RandomRange(3,18)*(FRACUNIT/4)); - debris->momz = P_RandomRange(4,8)<hnext; - P_RemoveMobj(cur); - cur = next; - } - - P_RemoveMobj(mobj); - return; - } - default: - P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL. - break; - } - - if (P_MobjWasRemoved(mobj)) - return; + } + default: + P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL. + break; } - else if (((mobj->type == MT_RANDOMITEM && mobj->threshold == 69) || mobj->type == MT_EGGMANITEM || mobj->type == MT_FALLINGROCK) && mobj->fuse <= TICRATE) - mobj->flags2 ^= MF2_DONTDRAW; + if (P_MobjWasRemoved(mobj)) + return; } + else if (((mobj->type == MT_RANDOMITEM && mobj->threshold == 69) || mobj->type == MT_EGGMANITEM || mobj->type == MT_FALLINGROCK) && mobj->fuse <= TICRATE) + mobj->flags2 ^= MF2_DONTDRAW; } I_Assert(mobj != NULL); diff --git a/src/r_draw8.c b/src/r_draw8.c index 4e69d58c7..b67311d76 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -643,7 +643,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) } } -#define PLANELIGHTFLOAT ((float)(BASEVIDWIDTH * BASEVIDWIDTH) / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) +#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) /** \brief The R_DrawTiltedSpan_8 function Draw slopes! Holy sheit! diff --git a/src/r_main.c b/src/r_main.c index 58810c37b..7a2defa51 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1641,6 +1641,7 @@ void R_RenderPlayerView(player_t *player) } // Draw over the fourth screen so you don't have to stare at a HOM :V else if (splitscreen == 2 && player == &players[displayplayers[2]]) +#if 1 { // V_DrawPatchFill, but for the fourth screen only patch_t *pat = W_CachePatchName("SRB2BACK", PU_CACHE); @@ -1653,6 +1654,9 @@ void R_RenderPlayerView(player_t *player) V_DrawScaledPatch(x, y, V_NOSCALESTART, pat); } } +#else + V_DrawFill(viewwidth, viewheight, viewwidth, viewheight, 31|V_NOSCALESTART); +#endif // load previous saved value of skyVisible for the player for (i = 0; i <= splitscreen; i++) diff --git a/src/r_plane.c b/src/r_plane.c index 8a257f4de..6299edd9e 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -332,12 +332,10 @@ void R_ClearPlanes(void) numffloors = 0; for (i = 0; i < MAXVISPLANES; i++) + for (*freehead = visplanes[i], visplanes[i] = NULL; + freehead && *freehead ;) { - for (*freehead = visplanes[i], visplanes[i] = NULL; - freehead && *freehead ;) - { - freehead = &(*freehead)->next; - } + freehead = &(*freehead)->next; } lastopening = openings; @@ -816,8 +814,7 @@ void R_DrawSinglePlane(visplane_t *pl) #endif spanfunc = basespanfunc; - if (pl->polyobj && pl->polyobj->translucency != 0) - { + if (pl->polyobj && pl->polyobj->translucency != 0) { spanfunc = R_DrawTranslucentSpan_8; // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) @@ -837,8 +834,8 @@ void R_DrawSinglePlane(visplane_t *pl) else light = LIGHTLEVELS-1; - } - else if (pl->ffloor) + } else + if (pl->ffloor) { // Don't draw planes that shouldn't be drawn. for (rover = pl->ffloor->target->ffloors; rover; rover = rover->next) @@ -1102,9 +1099,9 @@ void R_DrawSinglePlane(visplane_t *pl) spanfunc = R_DrawTiltedSpan_8; planezlight = scalelight[light]; - } - else - planezlight = zlight[light]; + } else + + planezlight = zlight[light]; // set the maximum value for unsigned pl->top[pl->maxx+1] = 0xffff; @@ -1213,9 +1210,9 @@ void R_PlaneBounds(visplane_t *plane) for (i = plane->minx + 1; i <= plane->maxx; i++) { if (plane->top[i] < hi) - hi = plane->top[i]; + hi = plane->top[i]; if (plane->bottom[i] > low) - low = plane->bottom[i]; + low = plane->bottom[i]; } plane->high = hi; plane->low = low; diff --git a/src/r_segs.c b/src/r_segs.c index fababbef4..7cb7e7397 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -901,7 +901,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (slopeskew) dc_texturemid = left_top; else - dc_texturemid = *pfloor->topheight - viewz; + dc_texturemid = *pfloor->topheight - viewz; if (newline) { @@ -1696,7 +1696,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) lastopening = openings + pos; if (oldopenings == NULL) - return; + return; // borrowed fix from *cough* zdoom *cough* // [RH] We also need to adjust the openings pointers that @@ -1876,14 +1876,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) texheight = textureheight[midtexture]; // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; - if (linedef->flags & ML_EFFECT2) - { + if (linedef->flags & ML_EFFECT2) { if (linedef->flags & ML_DONTPEGBOTTOM) rw_midtexturemid = frontsector->floorheight + texheight - viewz; else rw_midtexturemid = frontsector->ceilingheight - viewz; } - else if (linedef->flags & ML_DONTPEGBOTTOM) + else + if (linedef->flags & ML_DONTPEGBOTTOM) { rw_midtexturemid = worldbottom + texheight; rw_midtextureslide = floorfrontslide; @@ -2358,36 +2358,32 @@ void R_StoreWallRange(INT32 start, INT32 stop) maskedtextureheight = ds_p->maskedtextureheight; // note to red, this == &(ds_p->maskedtextureheight[0]) - if (curline->polyseg) - { // use REAL front and back floors please, so midtexture rendering isn't mucked up + if (curline->polyseg) { // use REAL front and back floors please, so midtexture rendering isn't mucked up rw_midtextureslide = rw_midtexturebackslide = 0; if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; else rw_midtexturemid = rw_midtextureback = min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz; - } - else if (linedef->flags & ML_EFFECT2) // Set midtexture starting height - { // Ignore slopes when texturing + } else + // Set midtexture starting height + if (linedef->flags & ML_EFFECT2) { // Ignore slopes when texturing rw_midtextureslide = rw_midtexturebackslide = 0; if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) rw_midtexturemid = rw_midtextureback = max(frontsector->floorheight, backsector->floorheight) - viewz; else rw_midtexturemid = rw_midtextureback = min(frontsector->ceilingheight, backsector->ceilingheight) - viewz; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) - { + } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { rw_midtexturemid = worldbottom; rw_midtextureslide = floorfrontslide; rw_midtextureback = worldlow; rw_midtexturebackslide = floorbackslide; - } else - { + } else { rw_midtexturemid = worldtop; rw_midtextureslide = ceilingfrontslide; rw_midtextureback = worldhigh; rw_midtexturebackslide = ceilingbackslide; } - rw_midtexturemid += sidedef->rowoffset; rw_midtextureback += sidedef->rowoffset; -- 2.54.0 From 2c4f5a68b95bce42f186adff8fa612b0c311e636 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 15 Jul 2024 21:10:11 +0200 Subject: [PATCH 162/525] fix A_ action protottypes --- src/info.h | 408 +++++++++++++++++++++++++++-------------------------- 1 file changed, 205 insertions(+), 203 deletions(-) diff --git a/src/info.h b/src/info.h index b1955340b..aff87a663 100644 --- a/src/info.h +++ b/src/info.h @@ -245,211 +245,213 @@ enum actionnum NUMACTIONS }; +struct mobj_s; + // IMPORTANT NOTE: If you add/remove from this list of action // functions, don't forget to update them in dehacked.c! -void A_Explode(); -void A_Pain(); -void A_Fall(); -void A_MonitorPop(); -void A_Look(); -void A_Chase(); -void A_FaceStabChase(); -void A_FaceTarget(); -void A_FaceTracer(); -void A_Scream(); -void A_BossDeath(); -void A_CustomPower(); // Use this for a custom power -void A_GiveWeapon(); // Gives the player weapon(s) -void A_JumpShield(); // Obtained Jump Shield -void A_RingShield(); // Obtained Ring Shield -void A_RingBox(); // Obtained Ring Box Tails -void A_Invincibility(); // Obtained Invincibility Box -void A_SuperSneakers(); // Obtained Super Sneakers Box -void A_BunnyHop(); // have bunny hop tails -void A_BubbleSpawn(); // Randomly spawn bubbles -void A_FanBubbleSpawn(); -void A_BubbleRise(); // Bubbles float to surface -void A_BubbleCheck(); // Don't draw if not underwater -void A_AwardScore(); -void A_ExtraLife(); // Extra Life -void A_BombShield(); // Obtained Bomb Shield -void A_WaterShield(); // Obtained Water Shield -void A_ForceShield(); // Obtained Force Shield -void A_PityShield(); // Obtained Pity Shield. We're... sorry. -void A_GravityBox(); -void A_ScoreRise(); // Rise the score logo -void A_ParticleSpawn(); -void A_AttractChase(); // Ring Chase -void A_DropMine(); // Drop Mine from Skim or Jetty-Syn Bomber -void A_FishJump(); // Fish Jump -void A_ThrownRing(); // Sparkle trail for red ring -void A_GrenadeRing(); // SRB2kart -void A_SetSolidSteam(); -void A_UnsetSolidSteam(); -void A_SignPlayer(); -void A_OverlayThink(); -void A_JetChase(); -void A_JetbThink(); // Jetty-Syn Bomber Thinker -void A_JetgThink(); // Jetty-Syn Gunner Thinker -void A_JetgShoot(); // Jetty-Syn Shoot Function -void A_ShootBullet(); // JetgShoot without reactiontime setting -void A_MinusDigging(); -void A_MinusPopup(); -void A_MinusCheck(); -void A_ChickenCheck(); -void A_MouseThink(); // Mouse Thinker -void A_DetonChase(); // Deton Chaser -void A_CapeChase(); // Fake little Super Sonic cape -void A_RotateSpikeBall(); // Spike ball rotation -void A_SlingAppear(); -void A_MaceRotate(); -void A_UnidusBall(); -void A_RockSpawn(); -void A_SetFuse(); -void A_CrawlaCommanderThink(); // Crawla Commander -void A_SmokeTrailer(); -void A_RingExplode(); -void A_OldRingExplode(); -void A_MixUp(); -void A_RecyclePowers(); -void A_BossScream(); -void A_Boss2TakeDamage(); -void A_GoopSplat(); -void A_Boss2PogoSFX(); -void A_Boss2PogoTarget(); -void A_EggmanBox(); -void A_TurretFire(); -void A_SuperTurretFire(); -void A_TurretStop(); -void A_JetJawRoam(); -void A_JetJawChomp(); -void A_PointyThink(); -void A_CheckBuddy(); -void A_HoodThink(); -void A_ArrowCheck(); -void A_SnailerThink(); -void A_SharpChase(); -void A_SharpSpin(); -void A_VultureVtol(); -void A_VultureCheck(); -void A_SkimChase(); -void A_SkullAttack(); -void A_LobShot(); -void A_FireShot(); -void A_SuperFireShot(); -void A_BossFireShot(); -void A_Boss7FireMissiles(); -void A_Boss1Laser(); -void A_FocusTarget(); -void A_Boss4Reverse(); -void A_Boss4SpeedUp(); -void A_Boss4Raise(); -void A_SparkFollow(); -void A_BuzzFly(); -void A_GuardChase(); -void A_EggShield(); -void A_SetReactionTime(); -void A_Boss1Spikeballs(); -void A_Boss3TakeDamage(); -void A_Boss3Path(); -void A_LinedefExecute(); -void A_PlaySeeSound(); -void A_PlayAttackSound(); -void A_PlayActiveSound(); -void A_1upThinker(); -void A_BossZoom(); //Unused -void A_Boss1Chase(); -void A_Boss2Chase(); -void A_Boss2Pogo(); -void A_Boss7Chase(); -void A_BossJetFume(); -void A_SpawnObjectAbsolute(); -void A_SpawnObjectRelative(); -void A_ChangeAngleRelative(); -void A_ChangeAngleAbsolute(); -void A_RollAngle(); -void A_ChangeRollAngleRelative(); -void A_ChangeRollAngleAbsolute(); -void A_PlaySound(); -void A_FindTarget(); -void A_FindTracer(); -void A_SetTics(); -void A_SetRandomTics(); -void A_ChangeColorRelative(); -void A_ChangeColorAbsolute(); -void A_MoveRelative(); -void A_MoveAbsolute(); -void A_Thrust(); -void A_ZThrust(); -void A_SetTargetsTarget(); -void A_SetObjectFlags(); -void A_SetObjectFlags2(); -void A_RandomState(); -void A_RandomStateRange(); -void A_DualAction(); -void A_RemoteAction(); -void A_ToggleFlameJet(); -void A_ItemPop(); // SRB2kart -void A_JawzChase(); // SRB2kart -void A_JawzExplode(); // SRB2kart -void A_SPBChase(); // SRB2kart -void A_MineExplode(); // SRB2kart -void A_BallhogExplode(); // SRB2kart -void A_LightningFollowPlayer(); // SRB2kart: Lightning shield effect player chasing -void A_FZBoomFlash(); // SRB2kart -void A_FZBoomSmoke(); // SRB2kart -void A_RandomShadowFrame(); //SRB2kart: Shadow spawner frame randomizer -void A_RoamingShadowThinker(); // SRB2kart: Roaming Shadow moving + attacking players. -void A_MayonakaArrow(); //SRB2kart: midnight channel arrow sign -void A_ReaperThinker(); //SRB2kart: mementos reaper -void A_MementosTPParticles(); //SRB2kart: mementos teleporter particles. Man that's a lot of actions for my shite. -void A_FlameParticle(); // SRB2kart -void A_OrbitNights(); -void A_GhostMe(); -void A_SetObjectState(); -void A_SetObjectTypeState(); -void A_KnockBack(); -void A_PushAway(); -void A_RingDrain(); -void A_SplitShot(); -void A_MissileSplit(); -void A_MultiShot(); -void A_InstaLoop(); -void A_Custom3DRotate(); -void A_SearchForPlayers(); -void A_CheckRandom(); -void A_CheckTargetRings(); -void A_CheckRings(); -void A_CheckTotalRings(); -void A_CheckHealth(); -void A_CheckRange(); -void A_CheckHeight(); -void A_CheckTrueRange(); -void A_CheckThingCount(); -void A_CheckAmbush(); -void A_CheckCustomValue(); -void A_CheckCusValMemo(); -void A_SetCustomValue(); -void A_UseCusValMemo(); -void A_RelayCustomValue(); -void A_CusValAction(); -void A_ForceStop(); -void A_ForceWin(); -void A_SpikeRetract(); -void A_InfoState(); -void A_Repeat(); -void A_SetScale(); -void A_RemoteDamage(); -void A_HomingChase(); -void A_TrapShot(); -void A_VileTarget(); -void A_VileAttack(); -void A_VileFire(); -void A_BrakChase(); -void A_BrakFireShot(); -void A_BrakLobShot(); -void A_NapalmScatter(); -void A_SpawnFreshCopy(); +void A_Explode(struct mobj_s *actor); +void A_Pain(struct mobj_s *actor); +void A_Fall(struct mobj_s *actor); +void A_MonitorPop(struct mobj_s *actor); +void A_Look(struct mobj_s *actor); +void A_Chase(struct mobj_s *actor); +void A_FaceStabChase(struct mobj_s *actor); +void A_FaceTarget(struct mobj_s *actor); +void A_FaceTracer(struct mobj_s *actor); +void A_Scream(struct mobj_s *actor); +void A_BossDeath(struct mobj_s *actor); +void A_CustomPower(struct mobj_s *actor); // Use this for a custom power +void A_GiveWeapon(struct mobj_s *actor); // Gives the player weapon(s) +void A_JumpShield(struct mobj_s *actor); // Obtained Jump Shield +void A_RingShield(struct mobj_s *actor); // Obtained Ring Shield +void A_RingBox(struct mobj_s *actor); // Obtained Ring Box Tails +void A_Invincibility(struct mobj_s *actor); // Obtained Invincibility Box +void A_SuperSneakers(struct mobj_s *actor); // Obtained Super Sneakers Box +void A_BunnyHop(struct mobj_s *actor); // have bunny hop tails +void A_BubbleSpawn(struct mobj_s *actor); // Randomly spawn bubbles +void A_FanBubbleSpawn(struct mobj_s *actor); +void A_BubbleRise(struct mobj_s *actor); // Bubbles float to surface +void A_BubbleCheck(struct mobj_s *actor); // Don't draw if not underwater +void A_AwardScore(struct mobj_s *actor); +void A_ExtraLife(struct mobj_s *actor); // Extra Life +void A_BombShield(struct mobj_s *actor); // Obtained Bomb Shield +void A_WaterShield(struct mobj_s *actor); // Obtained Water Shield +void A_ForceShield(struct mobj_s *actor); // Obtained Force Shield +void A_PityShield(struct mobj_s *actor); // Obtained Pity Shield. We're... sorry. +void A_GravityBox(struct mobj_s *actor); +void A_ScoreRise(struct mobj_s *actor); // Rise the score logo +void A_ParticleSpawn(struct mobj_s *actor); +void A_AttractChase(struct mobj_s *actor); // Ring Chase +void A_DropMine(struct mobj_s *actor); // Drop Mine from Skim or Jetty-Syn Bomber +void A_FishJump(struct mobj_s *actor); // Fish Jump +void A_ThrownRing(struct mobj_s *actor); // Sparkle trail for red ring +void A_GrenadeRing(struct mobj_s *actor); // SRB2kart +void A_SetSolidSteam(struct mobj_s *actor); +void A_UnsetSolidSteam(struct mobj_s *actor); +void A_SignPlayer(struct mobj_s *actor); +void A_OverlayThink(struct mobj_s *actor); +void A_JetChase(struct mobj_s *actor); +void A_JetbThink(struct mobj_s *actor); // Jetty-Syn Bomber Thinker +void A_JetgThink(struct mobj_s *actor); // Jetty-Syn Gunner Thinker +void A_JetgShoot(struct mobj_s *actor); // Jetty-Syn Shoot Function +void A_ShootBullet(struct mobj_s *actor); // JetgShoot without reactiontime setting +void A_MinusDigging(struct mobj_s *actor); +void A_MinusPopup(struct mobj_s *actor); +void A_MinusCheck(struct mobj_s *actor); +void A_ChickenCheck(struct mobj_s *actor); +void A_MouseThink(struct mobj_s *actor); // Mouse Thinker +void A_DetonChase(struct mobj_s *actor); // Deton Chaser +void A_CapeChase(struct mobj_s *actor); // Fake little Super Sonic cape +void A_RotateSpikeBall(struct mobj_s *actor); // Spike ball rotation +void A_SlingAppear(struct mobj_s *actor); +void A_MaceRotate(struct mobj_s *actor); +void A_UnidusBall(struct mobj_s *actor); +void A_RockSpawn(struct mobj_s *actor); +void A_SetFuse(struct mobj_s *actor); +void A_CrawlaCommanderThink(struct mobj_s *actor); // Crawla Commander +void A_SmokeTrailer(struct mobj_s *actor); +void A_RingExplode(struct mobj_s *actor); +void A_OldRingExplode(struct mobj_s *actor); +void A_MixUp(struct mobj_s *actor); +void A_RecyclePowers(struct mobj_s *actor); +void A_BossScream(struct mobj_s *actor); +void A_Boss2TakeDamage(struct mobj_s *actor); +void A_GoopSplat(struct mobj_s *actor); +void A_Boss2PogoSFX(struct mobj_s *actor); +void A_Boss2PogoTarget(struct mobj_s *actor); +void A_EggmanBox(struct mobj_s *actor); +void A_TurretFire(struct mobj_s *actor); +void A_SuperTurretFire(struct mobj_s *actor); +void A_TurretStop(struct mobj_s *actor); +void A_JetJawRoam(struct mobj_s *actor); +void A_JetJawChomp(struct mobj_s *actor); +void A_PointyThink(struct mobj_s *actor); +void A_CheckBuddy(struct mobj_s *actor); +void A_HoodThink(struct mobj_s *actor); +void A_ArrowCheck(struct mobj_s *actor); +void A_SnailerThink(struct mobj_s *actor); +void A_SharpChase(struct mobj_s *actor); +void A_SharpSpin(struct mobj_s *actor); +void A_VultureVtol(struct mobj_s *actor); +void A_VultureCheck(struct mobj_s *actor); +void A_SkimChase(struct mobj_s *actor); +void A_SkullAttack(struct mobj_s *actor); +void A_LobShot(struct mobj_s *actor); +void A_FireShot(struct mobj_s *actor); +void A_SuperFireShot(struct mobj_s *actor); +void A_BossFireShot(struct mobj_s *actor); +void A_Boss7FireMissiles(struct mobj_s *actor); +void A_Boss1Laser(struct mobj_s *actor); +void A_FocusTarget(struct mobj_s *actor); +void A_Boss4Reverse(struct mobj_s *actor); +void A_Boss4SpeedUp(struct mobj_s *actor); +void A_Boss4Raise(struct mobj_s *actor); +void A_SparkFollow(struct mobj_s *actor); +void A_BuzzFly(struct mobj_s *actor); +void A_GuardChase(struct mobj_s *actor); +void A_EggShield(struct mobj_s *actor); +void A_SetReactionTime(struct mobj_s *actor); +void A_Boss1Spikeballs(struct mobj_s *actor); +void A_Boss3TakeDamage(struct mobj_s *actor); +void A_Boss3Path(struct mobj_s *actor); +void A_LinedefExecute(struct mobj_s *actor); +void A_PlaySeeSound(struct mobj_s *actor); +void A_PlayAttackSound(struct mobj_s *actor); +void A_PlayActiveSound(struct mobj_s *actor); +void A_1upThinker(struct mobj_s *actor); +void A_BossZoom(struct mobj_s *actor); //Unused +void A_Boss1Chase(struct mobj_s *actor); +void A_Boss2Chase(struct mobj_s *actor); +void A_Boss2Pogo(struct mobj_s *actor); +void A_Boss7Chase(struct mobj_s *actor); +void A_BossJetFume(struct mobj_s *actor); +void A_SpawnObjectAbsolute(struct mobj_s *actor); +void A_SpawnObjectRelative(struct mobj_s *actor); +void A_ChangeAngleRelative(struct mobj_s *actor); +void A_ChangeAngleAbsolute(struct mobj_s *actor); +void A_RollAngle(struct mobj_s *actor); +void A_ChangeRollAngleRelative(struct mobj_s *actor); +void A_ChangeRollAngleAbsolute(struct mobj_s *actor); +void A_PlaySound(struct mobj_s *actor); +void A_FindTarget(struct mobj_s *actor); +void A_FindTracer(struct mobj_s *actor); +void A_SetTics(struct mobj_s *actor); +void A_SetRandomTics(struct mobj_s *actor); +void A_ChangeColorRelative(struct mobj_s *actor); +void A_ChangeColorAbsolute(struct mobj_s *actor); +void A_MoveRelative(struct mobj_s *actor); +void A_MoveAbsolute(struct mobj_s *actor); +void A_Thrust(struct mobj_s *actor); +void A_ZThrust(struct mobj_s *actor); +void A_SetTargetsTarget(struct mobj_s *actor); +void A_SetObjectFlags(struct mobj_s *actor); +void A_SetObjectFlags2(struct mobj_s *actor); +void A_RandomState(struct mobj_s *actor); +void A_RandomStateRange(struct mobj_s *actor); +void A_DualAction(struct mobj_s *actor); +void A_RemoteAction(struct mobj_s *actor); +void A_ToggleFlameJet(struct mobj_s *actor); +void A_ItemPop(struct mobj_s *actor); // SRB2kart +void A_JawzChase(struct mobj_s *actor); // SRB2kart +void A_JawzExplode(struct mobj_s *actor); // SRB2kart +void A_SPBChase(struct mobj_s *actor); // SRB2kart +void A_MineExplode(struct mobj_s *actor); // SRB2kart +void A_BallhogExplode(struct mobj_s *actor); // SRB2kart +void A_LightningFollowPlayer(struct mobj_s *actor); // SRB2kart: Lightning shield effect player chasing +void A_FZBoomFlash(struct mobj_s *actor); // SRB2kart +void A_FZBoomSmoke(struct mobj_s *actor); // SRB2kart +void A_RandomShadowFrame(struct mobj_s *actor); //SRB2kart: Shadow spawner frame randomizer +void A_RoamingShadowThinker(struct mobj_s *actor); // SRB2kart: Roaming Shadow moving + attacking players. +void A_MayonakaArrow(struct mobj_s *actor); //SRB2kart: midnight channel arrow sign +void A_ReaperThinker(struct mobj_s *actor); //SRB2kart: mementos reaper +void A_MementosTPParticles(struct mobj_s *actor); //SRB2kart: mementos teleporter particles. Man that's a lot of actions for my shite. +void A_FlameParticle(struct mobj_s *actor); // SRB2kart +void A_OrbitNights(struct mobj_s *actor); +void A_GhostMe(struct mobj_s *actor); +void A_SetObjectState(struct mobj_s *actor); +void A_SetObjectTypeState(struct mobj_s *actor); +void A_KnockBack(struct mobj_s *actor); +void A_PushAway(struct mobj_s *actor); +void A_RingDrain(struct mobj_s *actor); +void A_SplitShot(struct mobj_s *actor); +void A_MissileSplit(struct mobj_s *actor); +void A_MultiShot(struct mobj_s *actor); +void A_InstaLoop(struct mobj_s *actor); +void A_Custom3DRotate(struct mobj_s *actor); +void A_SearchForPlayers(struct mobj_s *actor); +void A_CheckRandom(struct mobj_s *actor); +void A_CheckTargetRings(struct mobj_s *actor); +void A_CheckRings(struct mobj_s *actor); +void A_CheckTotalRings(struct mobj_s *actor); +void A_CheckHealth(struct mobj_s *actor); +void A_CheckRange(struct mobj_s *actor); +void A_CheckHeight(struct mobj_s *actor); +void A_CheckTrueRange(struct mobj_s *actor); +void A_CheckThingCount(struct mobj_s *actor); +void A_CheckAmbush(struct mobj_s *actor); +void A_CheckCustomValue(struct mobj_s *actor); +void A_CheckCusValMemo(struct mobj_s *actor); +void A_SetCustomValue(struct mobj_s *actor); +void A_UseCusValMemo(struct mobj_s *actor); +void A_RelayCustomValue(struct mobj_s *actor); +void A_CusValAction(struct mobj_s *actor); +void A_ForceStop(struct mobj_s *actor); +void A_ForceWin(struct mobj_s *actor); +void A_SpikeRetract(struct mobj_s *actor); +void A_InfoState(struct mobj_s *actor); +void A_Repeat(struct mobj_s *actor); +void A_SetScale(struct mobj_s *actor); +void A_RemoteDamage(struct mobj_s *actor); +void A_HomingChase(struct mobj_s *actor); +void A_TrapShot(struct mobj_s *actor); +void A_VileTarget(struct mobj_s *actor); +void A_VileAttack(struct mobj_s *actor); +void A_VileFire(struct mobj_s *actor); +void A_BrakChase(struct mobj_s *actor); +void A_BrakFireShot(struct mobj_s *actor); +void A_BrakLobShot(struct mobj_s *actor); +void A_NapalmScatter(struct mobj_s *actor); +void A_SpawnFreshCopy(struct mobj_s *actor); extern boolean actionsoverridden[NUMACTIONS]; -- 2.54.0 From 3c224923e942e3fcdf245f907ffc74afff0d9b6b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 15 Jul 2024 21:19:25 +0200 Subject: [PATCH 163/525] fix some warnings in clang --- src/r_draw8.c | 2 +- src/r_main.c | 4 -- src/r_plane.c | 189 ++++++++++++++++++++++++++------------------------ src/r_segs.c | 68 ++++++++++-------- 4 files changed, 139 insertions(+), 124 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index b67311d76..57f5366aa 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -643,7 +643,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) } } -#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) +#define PLANELIGHTFLOAT ((float)BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) /** \brief The R_DrawTiltedSpan_8 function Draw slopes! Holy sheit! diff --git a/src/r_main.c b/src/r_main.c index 7a2defa51..58810c37b 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1641,7 +1641,6 @@ void R_RenderPlayerView(player_t *player) } // Draw over the fourth screen so you don't have to stare at a HOM :V else if (splitscreen == 2 && player == &players[displayplayers[2]]) -#if 1 { // V_DrawPatchFill, but for the fourth screen only patch_t *pat = W_CachePatchName("SRB2BACK", PU_CACHE); @@ -1654,9 +1653,6 @@ void R_RenderPlayerView(player_t *player) V_DrawScaledPatch(x, y, V_NOSCALESTART, pat); } } -#else - V_DrawFill(viewwidth, viewheight, viewwidth, viewheight, 31|V_NOSCALESTART); -#endif // load previous saved value of skyVisible for the player for (i = 0; i <= splitscreen; i++) diff --git a/src/r_plane.c b/src/r_plane.c index 6299edd9e..e30592816 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -332,10 +332,12 @@ void R_ClearPlanes(void) numffloors = 0; for (i = 0; i < MAXVISPLANES; i++) - for (*freehead = visplanes[i], visplanes[i] = NULL; - freehead && *freehead ;) { - freehead = &(*freehead)->next; + for (*freehead = visplanes[i], visplanes[i] = NULL; + freehead && *freehead ;) + { + freehead = &(*freehead)->next; + } } lastopening = openings; @@ -814,7 +816,8 @@ void R_DrawSinglePlane(visplane_t *pl) #endif spanfunc = basespanfunc; - if (pl->polyobj && pl->polyobj->translucency != 0) { + if (pl->polyobj && pl->polyobj->translucency != 0) + { spanfunc = R_DrawTranslucentSpan_8; // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) @@ -834,109 +837,111 @@ void R_DrawSinglePlane(visplane_t *pl) else light = LIGHTLEVELS-1; - } else - if (pl->ffloor) + } + else { - // Don't draw planes that shouldn't be drawn. - for (rover = pl->ffloor->target->ffloors; rover; rover = rover->next) + if (pl->ffloor) { - if (!((pl->ffloor->flags & FF_CUTEXTRA) && (rover->flags & FF_EXTRA))) - continue; + // Don't draw planes that shouldn't be drawn. + for (rover = pl->ffloor->target->ffloors; rover; rover = rover->next) + { + if (!((pl->ffloor->flags & FF_CUTEXTRA) && (rover->flags & FF_EXTRA))) + continue; - // The plane is from an extra 3D floor... Check the flags so - // there are no undesired cuts. - if (((pl->ffloor->flags & (FF_FOG|FF_SWIMMABLE)) == (rover->flags & (FF_FOG|FF_SWIMMABLE))) - && pl->height < *rover->topheight - && pl->height > *rover->bottomheight) - return; - } + // The plane is from an extra 3D floor... Check the flags so + // there are no undesired cuts. + if (((pl->ffloor->flags & (FF_FOG|FF_SWIMMABLE)) == (rover->flags & (FF_FOG|FF_SWIMMABLE))) + && pl->height < *rover->topheight + && pl->height > *rover->bottomheight) + return; + } - if (pl->ffloor->flags & FF_TRANSLUCENT) - { - spanfunc = R_DrawTranslucentSpan_8; + if (pl->ffloor->flags & FF_TRANSLUCENT) + { + spanfunc = R_DrawTranslucentSpan_8; - // Hacked up support for alpha value in software mode Tails 09-24-2002 - if (pl->ffloor->alpha < 12) - return; // Don't even draw it - else if (pl->ffloor->alpha < 38) - ds_transmap = transtables + ((tr_trans90-1)<ffloor->alpha < 64) - ds_transmap = transtables + ((tr_trans80-1)<ffloor->alpha < 89) - ds_transmap = transtables + ((tr_trans70-1)<ffloor->alpha < 115) - ds_transmap = transtables + ((tr_trans60-1)<ffloor->alpha < 140) - ds_transmap = transtables + ((tr_trans50-1)<ffloor->alpha < 166) - ds_transmap = transtables + ((tr_trans40-1)<ffloor->alpha < 192) - ds_transmap = transtables + ((tr_trans30-1)<ffloor->alpha < 217) - ds_transmap = transtables + ((tr_trans20-1)<ffloor->alpha < 243) - ds_transmap = transtables + ((tr_trans10-1)<ffloor->alpha < 12) + return; // Don't even draw it + else if (pl->ffloor->alpha < 38) + ds_transmap = transtables + ((tr_trans90-1)<ffloor->alpha < 64) + ds_transmap = transtables + ((tr_trans80-1)<ffloor->alpha < 89) + ds_transmap = transtables + ((tr_trans70-1)<ffloor->alpha < 115) + ds_transmap = transtables + ((tr_trans60-1)<ffloor->alpha < 140) + ds_transmap = transtables + ((tr_trans50-1)<ffloor->alpha < 166) + ds_transmap = transtables + ((tr_trans40-1)<ffloor->alpha < 192) + ds_transmap = transtables + ((tr_trans30-1)<ffloor->alpha < 217) + ds_transmap = transtables + ((tr_trans20-1)<ffloor->alpha < 243) + ds_transmap = transtables + ((tr_trans10-1)<extra_colormap && pl->extra_colormap->fog)) + if (spanfunc == splatfunc || (pl->extra_colormap && pl->extra_colormap->fog)) #else - if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) + if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) #endif + light = (pl->lightlevel >> LIGHTSEGSHIFT); + else + light = LIGHTLEVELS-1; + } + else if (pl->ffloor->flags & FF_FOG) + { + spanfunc = R_DrawFogSpan_8; light = (pl->lightlevel >> LIGHTSEGSHIFT); - else - light = LIGHTLEVELS-1; - } - else if (pl->ffloor->flags & FF_FOG) - { - spanfunc = R_DrawFogSpan_8; - light = (pl->lightlevel >> LIGHTSEGSHIFT); - } - else light = (pl->lightlevel >> LIGHTSEGSHIFT); + } + else light = (pl->lightlevel >> LIGHTSEGSHIFT); #ifndef NOWATER - if (pl->ffloor->flags & FF_RIPPLE) - { - INT32 top, bottom; - UINT8 *scr; - - planeripple.active = true; - - if (spanfunc == R_DrawTranslucentSpan_8) + if (pl->ffloor->flags & FF_RIPPLE) { - spanfunc = R_DrawTranslucentWaterSpan_8; + INT32 top, bottom; + UINT8 *scr; - // Copy the current scene, ugh - top = pl->high-8; - bottom = pl->low+8; + planeripple.active = true; - if (top < 0) - top = 0; - if (bottom > vid.height) - bottom = vid.height; + if (spanfunc == R_DrawTranslucentSpan_8) + { + spanfunc = R_DrawTranslucentWaterSpan_8; - if (splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need - scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth); - else if ((splitscreen == 1 && viewplayer == &players[displayplayers[1]]) - || (splitscreen > 1 && viewplayer == &players[displayplayers[2]])) - scr = (screens[0] + (top+(viewheight))*vid.width); - else if (splitscreen > 1 && viewplayer == &players[displayplayers[1]]) - scr = (screens[0] + ((top)*vid.width) + viewwidth); - else - scr = (screens[0] + ((top)*vid.width)); + // Copy the current scene, ugh + top = pl->high-8; + bottom = pl->low+8; - VID_BlitLinearScreen(scr, screens[1]+((top)*vid.width), - vid.width, bottom-top, - vid.width, vid.width); + if (top < 0) + top = 0; + if (bottom > vid.height) + bottom = vid.height; + + if (splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need + scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth); + else if ((splitscreen == 1 && viewplayer == &players[displayplayers[1]]) + || (splitscreen > 1 && viewplayer == &players[displayplayers[2]])) + scr = (screens[0] + (top+(viewheight))*vid.width); + else if (splitscreen > 1 && viewplayer == &players[displayplayers[1]]) + scr = (screens[0] + ((top)*vid.width) + viewwidth); + else + scr = (screens[0] + ((top)*vid.width)); + + VID_BlitLinearScreen(scr, screens[1]+((top)*vid.width), + vid.width, bottom-top, + vid.width, vid.width); + } } - } #endif + } + else light = (pl->lightlevel >> LIGHTSEGSHIFT); } - else light = (pl->lightlevel >> LIGHTSEGSHIFT); - if (!pl->slope) // Don't mess with angle on slopes! We'll handle this ourselves later - if (viewangle != pl->viewangle+pl->plangle) + if (!pl->slope && viewangle != pl->viewangle+pl->plangle) // Don't mess with angle on slopes! We'll handle this ourselves later { memset(cachedheight, 0, sizeof (cachedheight)); angle = (pl->viewangle+pl->plangle-ANGLE_90)>>ANGLETOFINESHIFT; @@ -1098,10 +1103,10 @@ void R_DrawSinglePlane(visplane_t *pl) else spanfunc = R_DrawTiltedSpan_8; - planezlight = scalelight[light]; - } else - - planezlight = zlight[light]; + planezlight = scalelight[light]; + } + else + planezlight = zlight[light]; // set the maximum value for unsigned pl->top[pl->maxx+1] = 0xffff; @@ -1210,9 +1215,9 @@ void R_PlaneBounds(visplane_t *plane) for (i = plane->minx + 1; i <= plane->maxx; i++) { if (plane->top[i] < hi) - hi = plane->top[i]; + hi = plane->top[i]; if (plane->bottom[i] > low) - low = plane->bottom[i]; + low = plane->bottom[i]; } plane->high = hi; plane->low = low; diff --git a/src/r_segs.c b/src/r_segs.c index 7cb7e7397..f5fdd782a 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -901,7 +901,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (slopeskew) dc_texturemid = left_top; else - dc_texturemid = *pfloor->topheight - viewz; + dc_texturemid = *pfloor->topheight - viewz; if (newline) { @@ -1876,14 +1876,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) texheight = textureheight[midtexture]; // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; - if (linedef->flags & ML_EFFECT2) { + if (linedef->flags & ML_EFFECT2) + { if (linedef->flags & ML_DONTPEGBOTTOM) rw_midtexturemid = frontsector->floorheight + texheight - viewz; else rw_midtexturemid = frontsector->ceilingheight - viewz; } - else - if (linedef->flags & ML_DONTPEGBOTTOM) + else if (linedef->flags & ML_DONTPEGBOTTOM) { rw_midtexturemid = worldbottom + texheight; rw_midtextureslide = floorfrontslide; @@ -2358,31 +2358,40 @@ void R_StoreWallRange(INT32 start, INT32 stop) maskedtextureheight = ds_p->maskedtextureheight; // note to red, this == &(ds_p->maskedtextureheight[0]) - if (curline->polyseg) { // use REAL front and back floors please, so midtexture rendering isn't mucked up + if (curline->polyseg) // use REAL front and back floors please, so midtexture rendering isn't mucked up + { rw_midtextureslide = rw_midtexturebackslide = 0; if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; else rw_midtexturemid = rw_midtextureback = min(curline->frontsector->ceilingheight, curline->backsector->ceilingheight) - viewz; - } else - // Set midtexture starting height - if (linedef->flags & ML_EFFECT2) { // Ignore slopes when texturing - rw_midtextureslide = rw_midtexturebackslide = 0; - if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) - rw_midtexturemid = rw_midtextureback = max(frontsector->floorheight, backsector->floorheight) - viewz; - else - rw_midtexturemid = rw_midtextureback = min(frontsector->ceilingheight, backsector->ceilingheight) - viewz; + } + else + { + // Set midtexture starting height + if (linedef->flags & ML_EFFECT2) // Ignore slopes when texturing + { + rw_midtextureslide = rw_midtexturebackslide = 0; + if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) + rw_midtexturemid = rw_midtextureback = max(frontsector->floorheight, backsector->floorheight) - viewz; + else + rw_midtexturemid = rw_midtextureback = min(frontsector->ceilingheight, backsector->ceilingheight) - viewz; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - rw_midtexturemid = worldbottom; - rw_midtextureslide = floorfrontslide; - rw_midtextureback = worldlow; - rw_midtexturebackslide = floorbackslide; - } else { - rw_midtexturemid = worldtop; - rw_midtextureslide = ceilingfrontslide; - rw_midtextureback = worldhigh; - rw_midtexturebackslide = ceilingbackslide; + } + else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) + { + rw_midtexturemid = worldbottom; + rw_midtextureslide = floorfrontslide; + rw_midtextureback = worldlow; + rw_midtexturebackslide = floorbackslide; + } + else + { + rw_midtexturemid = worldtop; + rw_midtextureslide = ceilingfrontslide; + rw_midtextureback = worldhigh; + rw_midtexturebackslide = ceilingbackslide; + } } rw_midtexturemid += sidedef->rowoffset; rw_midtextureback += sidedef->rowoffset; @@ -2473,22 +2482,27 @@ void R_StoreWallRange(INT32 start, INT32 stop) worldtopslope >>= 4; worldbottomslope >>= 4; - if (linedef->special == 41) { // HORIZON LINES + if (linedef->special == 41) // HORIZON LINES + { topstep = bottomstep = 0; topfrac = bottomfrac = (centeryfrac>>4); topfrac++; // Prevent 1px HOM - } else { + } + else + { topstep = -FixedMul (rw_scalestep, worldtop); topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); bottomstep = -FixedMul (rw_scalestep,worldbottom); bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); - if (frontsector->c_slope) { + if (frontsector->c_slope) + { fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2); topstep = (topfracend-topfrac)/(range); } - if (frontsector->f_slope) { + if (frontsector->f_slope) + { fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2); bottomstep = (bottomfracend-bottomfrac)/(range); } -- 2.54.0 From 4b1a82e14ef929fb23c201914764608e992e7969 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 15 Jul 2024 21:43:25 +0200 Subject: [PATCH 164/525] fix more warnings --- src/p_mobj.c | 328 +++++++++++++++++++++++++------------------------- src/r_plane.c | 2 +- 2 files changed, 166 insertions(+), 164 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 52c8116f1..03a8d851c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8819,190 +8819,192 @@ void P_MobjThinker(mobj_t *mobj) mobj_t *flagmo, *newmobj; if (!LUAh_MobjFuse(mobj) && !P_MobjWasRemoved(mobj)) - switch (mobj->type) { - // gargoyle and snowman handled in P_PushableThinker, not here - case MT_THROWNGRENADE: - case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: - P_SetMobjState(mobj, mobj->info->deathstate); - break; - case MT_BLUEFLAG: - case MT_REDFLAG: - if (mobj->spawnpoint) - { - x = mobj->spawnpoint->x << FRACBITS; - y = mobj->spawnpoint->y << FRACBITS; - ss = R_PointInSubsector(x, y); - if (mobj->spawnpoint->options & MTF_OBJECTFLIP) + switch (mobj->type) + { + // gargoyle and snowman handled in P_PushableThinker, not here + case MT_THROWNGRENADE: + case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: + P_SetMobjState(mobj, mobj->info->deathstate); + break; + case MT_BLUEFLAG: + case MT_REDFLAG: + if (mobj->spawnpoint) { - z = ss->sector->ceilingheight - mobjinfo[mobj->type].height; - if (mobj->spawnpoint->options >> ZSHIFT) - z -= (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; + x = mobj->spawnpoint->x << FRACBITS; + y = mobj->spawnpoint->y << FRACBITS; + ss = R_PointInSubsector(x, y); + if (mobj->spawnpoint->options & MTF_OBJECTFLIP) + { + z = ss->sector->ceilingheight - mobjinfo[mobj->type].height; + if (mobj->spawnpoint->options >> ZSHIFT) + z -= (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; + } + else + { + z = ss->sector->floorheight; + if (mobj->spawnpoint->options >> ZSHIFT) + z += (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; + } + flagmo = P_SpawnMobj(x, y, z, mobj->type); + flagmo->spawnpoint = mobj->spawnpoint; + if (mobj->spawnpoint->options & MTF_OBJECTFLIP) + { + flagmo->eflags |= MFE_VERTICALFLIP; + flagmo->flags2 |= MF2_OBJECTFLIP; + } + + if (mobj->type == MT_REDFLAG) + { + if (!(mobj->flags2 & MF2_JUSTATTACKED)) + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); + + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 1 || splitscreen) + S_StartSound(NULL, sfx_hoop1); + else if (players[consoleplayer].ctfteam == 2) + S_StartSound(NULL, sfx_hoop3); + + redflag = flagmo; + } + else // MT_BLUEFLAG + { + if (!(mobj->flags2 & MF2_JUSTATTACKED)) + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); + + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 2 || splitscreen) + S_StartSound(NULL, sfx_hoop1); + else if (players[consoleplayer].ctfteam == 1) + S_StartSound(NULL, sfx_hoop3); + + blueflag = flagmo; + } } - else + P_RemoveMobj(mobj); + return; + case MT_YELLOWTV: // Ring shield box + case MT_BLUETV: // Force shield box + case MT_GREENTV: // Water shield box + case MT_BLACKTV: // Bomb shield box + case MT_WHITETV: // Jump shield box + case MT_SNEAKERTV: // Super Sneaker box + case MT_SUPERRINGBOX: // 10-Ring box + case MT_REDRINGBOX: // Red Team 10-Ring box + case MT_BLUERINGBOX: // Blue Team 10-Ring box + case MT_INV: // Invincibility box + case MT_MIXUPBOX: // Teleporter Mixup box + case MT_RECYCLETV: // Recycler box + case MT_SCORETVSMALL: + case MT_SCORETVLARGE: + case MT_PRUP: // 1up! + case MT_EGGMANBOX: // Eggman box + case MT_GRAVITYBOX: // Gravity box + case MT_QUESTIONBOX: + if ((mobj->flags2 & MF2_AMBUSH || mobj->flags2 & MF2_STRONGBOX) && mobj->type != MT_QUESTIONBOX) { - z = ss->sector->floorheight; - if (mobj->spawnpoint->options >> ZSHIFT) - z += (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; - } - flagmo = P_SpawnMobj(x, y, z, mobj->type); - flagmo->spawnpoint = mobj->spawnpoint; - if (mobj->spawnpoint->options & MTF_OBJECTFLIP) - { - flagmo->eflags |= MFE_VERTICALFLIP; - flagmo->flags2 |= MF2_OBJECTFLIP; - } + mobjtype_t spawnchance[64]; + INT32 numchoices = 0, i = 0; - if (mobj->type == MT_REDFLAG) - { - if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); - - // Assumedly in splitscreen players will be on opposing teams - if (players[consoleplayer].ctfteam == 1 || splitscreen) - S_StartSound(NULL, sfx_hoop1); - else if (players[consoleplayer].ctfteam == 2) - S_StartSound(NULL, sfx_hoop3); - - redflag = flagmo; - } - else // MT_BLUEFLAG - { - if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); - - // Assumedly in splitscreen players will be on opposing teams - if (players[consoleplayer].ctfteam == 2 || splitscreen) - S_StartSound(NULL, sfx_hoop1); - else if (players[consoleplayer].ctfteam == 1) - S_StartSound(NULL, sfx_hoop3); - - blueflag = flagmo; - } - } - P_RemoveMobj(mobj); - return; - case MT_YELLOWTV: // Ring shield box - case MT_BLUETV: // Force shield box - case MT_GREENTV: // Water shield box - case MT_BLACKTV: // Bomb shield box - case MT_WHITETV: // Jump shield box - case MT_SNEAKERTV: // Super Sneaker box - case MT_SUPERRINGBOX: // 10-Ring box - case MT_REDRINGBOX: // Red Team 10-Ring box - case MT_BLUERINGBOX: // Blue Team 10-Ring box - case MT_INV: // Invincibility box - case MT_MIXUPBOX: // Teleporter Mixup box - case MT_RECYCLETV: // Recycler box - case MT_SCORETVSMALL: - case MT_SCORETVLARGE: - case MT_PRUP: // 1up! - case MT_EGGMANBOX: // Eggman box - case MT_GRAVITYBOX: // Gravity box - case MT_QUESTIONBOX: - if ((mobj->flags2 & MF2_AMBUSH || mobj->flags2 & MF2_STRONGBOX) && mobj->type != MT_QUESTIONBOX) - { - mobjtype_t spawnchance[64]; - INT32 numchoices = 0, i = 0; - -// This define should make it a lot easier to organize and change monitor weights + // This define should make it a lot easier to organize and change monitor weights #define SETMONITORCHANCES(type, strongboxamt, weakboxamt) \ -for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) spawnchance[numchoices++] = type + for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) spawnchance[numchoices++] = type - // Type SRM WRM - SETMONITORCHANCES(MT_SNEAKERTV, 0, 10); // Super Sneakers - SETMONITORCHANCES(MT_INV, 2, 0); // Invincibility - SETMONITORCHANCES(MT_WHITETV, 3, 8); // Whirlwind Shield - SETMONITORCHANCES(MT_GREENTV, 3, 8); // Elemental Shield - SETMONITORCHANCES(MT_YELLOWTV, 2, 0); // Attraction Shield - SETMONITORCHANCES(MT_BLUETV, 3, 3); // Force Shield - SETMONITORCHANCES(MT_BLACKTV, 2, 0); // Armageddon Shield - SETMONITORCHANCES(MT_MIXUPBOX, 0, 1); // Teleporters - SETMONITORCHANCES(MT_RECYCLETV, 0, 1); // Recycler - SETMONITORCHANCES(MT_PRUP, 1, 1); // 1-Up - // ====================================== - // Total 16 32 + // Type SRM WRM + SETMONITORCHANCES(MT_SNEAKERTV, 0, 10); // Super Sneakers + SETMONITORCHANCES(MT_INV, 2, 0); // Invincibility + SETMONITORCHANCES(MT_WHITETV, 3, 8); // Whirlwind Shield + SETMONITORCHANCES(MT_GREENTV, 3, 8); // Elemental Shield + SETMONITORCHANCES(MT_YELLOWTV, 2, 0); // Attraction Shield + SETMONITORCHANCES(MT_BLUETV, 3, 3); // Force Shield + SETMONITORCHANCES(MT_BLACKTV, 2, 0); // Armageddon Shield + SETMONITORCHANCES(MT_MIXUPBOX, 0, 1); // Teleporters + SETMONITORCHANCES(MT_RECYCLETV, 0, 1); // Recycler + SETMONITORCHANCES(MT_PRUP, 1, 1); // 1-Up + // ====================================== + // Total 16 32 #undef SETMONITORCHANCES - i = P_RandomKey(numchoices); // Gotta love those random numbers! - newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, spawnchance[i]); + i = P_RandomKey(numchoices); // Gotta love those random numbers! + newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, spawnchance[i]); - // Transfer flags2 (strongbox, objectflip, ambush) - newmobj->flags2 = mobj->flags2; - } - else - { - newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); - - // Transfer flags2 (strongbox, objectflip) - newmobj->flags2 = mobj->flags2; - } - P_RemoveMobj(mobj); // make sure they disappear - return; - case MT_RANDOMITEM: - if (G_BattleGametype()) - { - if (mobj->threshold != 69) - break; - } - else - { - // Respawn from mapthing if you have one! - if (mobj->spawnpoint) - { - P_SpawnMapThing(mobj->spawnpoint); - newmobj = mobj->spawnpoint->mobj; // this is set to the new mobj in P_SpawnMapThing + // Transfer flags2 (strongbox, objectflip, ambush) + newmobj->flags2 = mobj->flags2; } else + { newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); - // Transfer flags2 (strongbox, objectflip) - newmobj->flags2 = mobj->flags2 & ~MF2_DONTDRAW; - } - P_RemoveMobj(mobj); // make sure they disappear - return; - case MT_METALSONIC_BATTLE: - break; // don't remove - case MT_SPIKE: - P_SetMobjState(mobj, mobj->state->nextstate); - mobj->fuse = mobj->info->speed; - if (mobj->spawnpoint) - mobj->fuse += mobj->spawnpoint->angle; - break; - case MT_NIGHTSCORE: - P_RemoveMobj(mobj); - return; - case MT_PLAYER: - break; // don't remove - case MT_SMK_ICEBLOCK: - { - mobj_t *cur = mobj->hnext, *next; - UINT8 i; - - for (i = 0; i < 5; i++) - { - mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS); - debris->angle = FixedAngle(P_RandomRange(0,360)<angle, P_RandomRange(3,18)*(FRACUNIT/4)); - debris->momz = P_RandomRange(4,8)<flags2 = mobj->flags2; } - - while (cur && !P_MobjWasRemoved(cur)) + P_RemoveMobj(mobj); // make sure they disappear + return; + case MT_RANDOMITEM: + if (G_BattleGametype()) { - next = cur->hnext; - P_RemoveMobj(cur); - cur = next; + if (mobj->threshold != 69) + break; } + else + { + // Respawn from mapthing if you have one! + if (mobj->spawnpoint) + { + P_SpawnMapThing(mobj->spawnpoint); + newmobj = mobj->spawnpoint->mobj; // this is set to the new mobj in P_SpawnMapThing + } + else + newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); + // Transfer flags2 (strongbox, objectflip) + newmobj->flags2 = mobj->flags2 & ~MF2_DONTDRAW; + } + P_RemoveMobj(mobj); // make sure they disappear + return; + case MT_METALSONIC_BATTLE: + break; // don't remove + case MT_SPIKE: + P_SetMobjState(mobj, mobj->state->nextstate); + mobj->fuse = mobj->info->speed; + if (mobj->spawnpoint) + mobj->fuse += mobj->spawnpoint->angle; + break; + case MT_NIGHTSCORE: P_RemoveMobj(mobj); return; - } - default: - P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL. - break; + case MT_PLAYER: + break; // don't remove + case MT_SMK_ICEBLOCK: + { + mobj_t *cur = mobj->hnext, *next; + UINT8 i; + + for (i = 0; i < 5; i++) + { + mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS); + debris->angle = FixedAngle(P_RandomRange(0,360)<angle, P_RandomRange(3,18)*(FRACUNIT/4)); + debris->momz = P_RandomRange(4,8)<hnext; + P_RemoveMobj(cur); + cur = next; + } + + P_RemoveMobj(mobj); + return; + } + default: + P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL. + break; + } } if (P_MobjWasRemoved(mobj)) return; diff --git a/src/r_plane.c b/src/r_plane.c index e30592816..9ea06a277 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -1103,7 +1103,7 @@ void R_DrawSinglePlane(visplane_t *pl) else spanfunc = R_DrawTiltedSpan_8; - planezlight = scalelight[light]; + planezlight = scalelight[light]; } else planezlight = zlight[light]; -- 2.54.0 From 55eb984ccd73d36d1b9248ccdf2130249a6a508d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 15 Jul 2024 21:58:00 +0200 Subject: [PATCH 165/525] remove this check --- src/p_inter.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index e0e0986e6..1e03ab346 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1908,9 +1908,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) mobj_t *mo; int ms; - if (!target || P_MobjWasRemoved(target)) - return; - if (!useNightsSS && G_IsSpecialStage(gamemap) && target->player && sstimer > 6) sstimer = 6; // Just let P_Ticker take care of the rest. -- 2.54.0 From 9490b1235d316cf15f04939a6e46a84b885e958d Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Jul 2024 10:43:47 +0200 Subject: [PATCH 166/525] did not mean to add this lol --- src/hardware/hw_cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 6a875543f..98034970d 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -509,8 +509,8 @@ void HWR_FreeMipmapCache(void) // free all hardware-converted graphics cached in the heap // our gool is only the textures since user of the texture is the texture cache - //Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); - //Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); + Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); + Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); // Alam: free the Z_Blocks before freeing it's users -- 2.54.0 From 295d9768ced3907f127ffb034fa3d7d2094c34b9 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 16 Jul 2024 16:42:26 +0300 Subject: [PATCH 167/525] Fix linedef 415 executing random text if script lump doesn't have null terminator --- src/p_spec.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index e72cb5371..91f3b5bab 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2610,7 +2610,17 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) CONS_Debug(DBG_SETUP, "SOC Error: script lump %s not found/not valid.\n", newname); } else - COM_BufInsertText(W_CacheLumpNum(lumpnum, PU_CACHE)); + { + // W_CacheLumpNum may not have null terminator, so we need to do this :blobcatgooglyholditsheadinitshands: + size_t len = W_LumpLength(lumpnum); + char *script = Z_Malloc(len+1, PU_STATIC, NULL); + memcpy(script, W_CacheLumpNum(lumpnum, PU_CACHE), len); + script[len] = 0; + + COM_BufInsertText(script); + + Z_Free(script); + } } break; -- 2.54.0 From 79a5d174a54ea0bbabba485d83e7d9f21372f4a2 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 17 Jul 2024 09:21:15 +0200 Subject: [PATCH 168/525] clean up mapload code a little more --- src/p_setup.c | 74 ++++++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 51 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index e5f947a87..2b4799c5f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -496,6 +496,7 @@ FUNCINLINE static ATTRINLINE void P_LoadRawSubsectors(void *data) size_t numlevelflats; levelflat_t *levelflats; +levelflat_t *foundflats; //SoM: Other files want this info. size_t P_PrecacheLevelFlats(void) @@ -621,18 +622,8 @@ static void P_LoadRawSectors(UINT8 *data) { mapsector_t *ms = (mapsector_t *)data; sector_t *ss = sectors; - levelflat_t *foundflats; - size_t i; - // Allocate a big chunk of memory as big as our MAXLEVELFLATS limit. - //Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty - foundflats = calloc(MAXLEVELFLATS, sizeof (*foundflats)); - if (foundflats == NULL) - I_Error("Ran out of memory while loading sectors\n"); - - numlevelflats = 0; - // For each counted sector, copy the sector raw data from our cache pointer ms, to the global table pointer ss. for (i = 0; i < numsectors; i++, ss++, ms++) { @@ -693,16 +684,6 @@ static void P_LoadRawSectors(UINT8 *data) ss->floorspeed = 0; ss->ceilspeed = 0; } - - // set the sky flat num - skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats); - - // copy table for global usage - levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); - free(foundflats); - - // search for animated flats and set up - P_SetupLevelFlatAnims(); } // @@ -1489,7 +1470,7 @@ static void P_LoadRawSideDefs2(void *data) // always process if back sidedef, because we need that - symbol sd->text = Z_Malloc(7, PU_LEVEL, NULL); - if (i == 1 || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') + if (i == 1 || !(msd->toptexture[0] == '-' || msd->toptexture[1] == '\0')) { M_Memcpy(process,msd->toptexture,8); process[8] = '\0'; @@ -1578,7 +1559,6 @@ static void P_LoadRawSideDefs2(void *data) break; } } - R_ClearTextureNumCache(true); } static boolean LineInBlock(fixed_t cx1, fixed_t cy1, fixed_t cx2, fixed_t cy2, fixed_t bx1, fixed_t by1) @@ -2095,12 +2075,33 @@ static void P_LoadMapData(const virtres_t* virt) lines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL); mapthings = Z_Calloc(nummapthings * sizeof (*mapthings), PU_LEVEL, NULL); + // Allocate a big chunk of memory as big as our MAXLEVELFLATS limit. + //Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty + foundflats = calloc(MAXLEVELFLATS, sizeof (*foundflats)); + if (foundflats == NULL) + I_Error("Ran out of memory while loading sectors\n"); + + numlevelflats = 0; + // Strict map data P_LoadRawVertexes(virtvertexes->data); P_LoadRawSectors(virtsectors->data); P_LoadRawLineDefs(virtlinedefs->data); P_SetupLines(); P_LoadRawSideDefs2(virtsidedefs->data); + P_PrepareRawThings(virtthings->data); + + R_ClearTextureNumCache(true); + + // set the sky flat num + skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats); + + // copy table for global usage + levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); + free(foundflats); + + // search for animated flats and set up + P_SetupLevelFlatAnims(); } /** Sets up a sky texture to use for the level. @@ -2259,9 +2260,6 @@ void P_LoadThingsOnly(void) mobj_t *mo; thinker_t *think; - virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); - virtlump_t* vth = vres_Find(virt, "THINGS"); - for (think = thinkercap.next; think != &thinkercap; think = think->next) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) @@ -2275,11 +2273,8 @@ void P_LoadThingsOnly(void) P_LevelInitStuff(); - P_PrepareRawThings(vth->data); P_LoadThings(); - vres_Free(virt); - P_SpawnSecretItems(true); } @@ -2347,8 +2342,6 @@ static void P_LoadMapFromFile(void) P_LoadLineDefs2(); P_GroupLines(); - P_PrepareRawThings(vres_Find(virt, "THINGS")->data); - P_MakeMapMD5(virt, &mapmd5); vres_Free(virt); @@ -2557,28 +2550,7 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) static boolean P_CanSave(void) { -#if 0 - // Saving is completely ignored under these conditions: - if ((cursaveslot < 0) // Playing without saving - || (modifiedgame && !savemoddata) // Game is modified - || (netgame || multiplayer) // Not in single-player - || (demo.playback || demo.recording || metalrecording) // Currently in demo - || (players[consoleplayer].lives <= 0) // Completely dead - || (modeattacking || ultimatemode || G_IsSpecialStage(gamemap))) // Specialized instances - return false; - - if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_ALWAYS) - return true; // Saving should ALWAYS happen! - else if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_NEVER) - return false; // Saving should NEVER happen! - - // Default condition: In a non-hidden map, at the beginning of a zone or on a completed save-file, and not on save reload. - return (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) - && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete) - && (gamemap != lastmapsaved)); -#else return false; // SRB2Kart: no SP, no saving. -#endif } /** Loads a level from a lump or external wad. -- 2.54.0 From da64d3ccbf8b0436dee4f058fcf5b23dd8747d1c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 17 Jul 2024 11:12:58 +0200 Subject: [PATCH 169/525] vres_GetMap: Count resources in folders up until next 0-length lump justs in case the order of stuff may be weird fixes keepmapmusic crash on some maps --- src/w_wad.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 5d0e46f2b..6e7f9744d 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2158,8 +2158,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) // Count number of lumps until the end of resource OR up until next "MAPXX" lump. lumpnum_t lumppos = lumpnum + 1; for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++) - if (memcmp(W_CheckNameForNum(lumppos), "MAP", 3) == 0) + { + if (memcmp(W_CheckNameForNum(lumppos), "MAP", 3) == 0 || W_LumpLength(lumppos) == 0) + { break; + } + } numlumps++; vlumps = Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL); -- 2.54.0 From 15914c2f252b4256d678216f1d631f4c1de90f61 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 17 Jul 2024 11:13:07 +0200 Subject: [PATCH 170/525] Skip over empty entries when populating vres, saving memory --- src/w_wad.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 6e7f9744d..c4aa10b1e 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2134,23 +2134,43 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) if (W_IsLumpWad(lumpnum)) { + UINT32 realentry; + size_t *vsizecache; + // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. UINT8 *wadData = W_CacheLumpNum(lumpnum, PU_LEVEL); filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); - numlumps = ((wadinfo_t *)wadData)->numlumps; - vlumps = Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL); - // Build the lumps. - for (i = 0; i < numlumps; i++) + i = ((wadinfo_t *)wadData)->numlumps; + vsizecache = Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL); + + for (realentry = 0; realentry < i; realentry++) { - vlumps[i].size = (size_t)(((filelump_t *)(fileinfo + i))->size); - // Play it safe with the name in this case. - memcpy(vlumps[i].name, (fileinfo + i)->name, 8); - vlumps[i].name[8] = '\0'; - vlumps[i].data = Z_Malloc(vlumps[i].size, PU_LEVEL, NULL); // This is memory inefficient, sorry about that. - memcpy(vlumps[i].data, wadData + (fileinfo + i)->filepos, vlumps[i].size); + vsizecache[realentry] = (size_t)(((filelump_t *)(fileinfo + realentry))->size); + + if (!vsizecache[realentry]) + continue; + + numlumps++; } + vlumps = Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL); + + // Build the lumps, skipping over empty entries. + for (i = 0, realentry = 0; i < numlumps; realentry++) + { + if (vsizecache[realentry] == 0) + continue; + vlumps[i].size = vsizecache[realentry]; + // Play it safe with the name in this case. + memcpy(vlumps[i].name, (fileinfo + realentry)->name, 8); + vlumps[i].name[8] = '\0'; + vlumps[i].data = Z_Malloc(vlumps[i].size, PU_LEVEL, NULL); // This is memory inefficient, sorry about that. + memcpy(vlumps[i].data, wadData + (fileinfo + realentry)->filepos, vlumps[i].size); + i++; + } + + Z_Free(vsizecache); Z_Free(wadData); } else -- 2.54.0 From 82e33fd4e4e73a91b59eab3df9cb748dd20c0d52 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 17 Jul 2024 12:30:34 +0300 Subject: [PATCH 171/525] Attempt to fix possible use-after-free for awayviewmobj --- src/g_game.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index d1a3106ae..a8146014f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4388,6 +4388,11 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool players[i].starpostx = players[i].starposty = players[i].starpostz = 0; players[i].lives = 1; // SRB2Kart + // This should be cleared in P_SpawnPlayer but address sanitizer says "use-after-free" + // when reloading map sometimes + players[i].awayviewtics = 0; + players[i].awayviewmobj = NULL; + // The latter two should clear by themselves, but just in case players[i].pflags &= ~(PF_TAGIT|PF_TAGGED|PF_FULLSTASIS); -- 2.54.0 From deae234afa19687879004ce6397135b8b1955f64 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 17 Jul 2024 12:21:05 +0200 Subject: [PATCH 172/525] Revert "clean up mapload code a little more" This reverts commit 79a5d174a54ea0bbabba485d83e7d9f21372f4a2. --- src/p_setup.c | 74 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 23 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 2b4799c5f..e5f947a87 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -496,7 +496,6 @@ FUNCINLINE static ATTRINLINE void P_LoadRawSubsectors(void *data) size_t numlevelflats; levelflat_t *levelflats; -levelflat_t *foundflats; //SoM: Other files want this info. size_t P_PrecacheLevelFlats(void) @@ -622,8 +621,18 @@ static void P_LoadRawSectors(UINT8 *data) { mapsector_t *ms = (mapsector_t *)data; sector_t *ss = sectors; + levelflat_t *foundflats; + size_t i; + // Allocate a big chunk of memory as big as our MAXLEVELFLATS limit. + //Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty + foundflats = calloc(MAXLEVELFLATS, sizeof (*foundflats)); + if (foundflats == NULL) + I_Error("Ran out of memory while loading sectors\n"); + + numlevelflats = 0; + // For each counted sector, copy the sector raw data from our cache pointer ms, to the global table pointer ss. for (i = 0; i < numsectors; i++, ss++, ms++) { @@ -684,6 +693,16 @@ static void P_LoadRawSectors(UINT8 *data) ss->floorspeed = 0; ss->ceilspeed = 0; } + + // set the sky flat num + skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats); + + // copy table for global usage + levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); + free(foundflats); + + // search for animated flats and set up + P_SetupLevelFlatAnims(); } // @@ -1470,7 +1489,7 @@ static void P_LoadRawSideDefs2(void *data) // always process if back sidedef, because we need that - symbol sd->text = Z_Malloc(7, PU_LEVEL, NULL); - if (i == 1 || !(msd->toptexture[0] == '-' || msd->toptexture[1] == '\0')) + if (i == 1 || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') { M_Memcpy(process,msd->toptexture,8); process[8] = '\0'; @@ -1559,6 +1578,7 @@ static void P_LoadRawSideDefs2(void *data) break; } } + R_ClearTextureNumCache(true); } static boolean LineInBlock(fixed_t cx1, fixed_t cy1, fixed_t cx2, fixed_t cy2, fixed_t bx1, fixed_t by1) @@ -2075,33 +2095,12 @@ static void P_LoadMapData(const virtres_t* virt) lines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL); mapthings = Z_Calloc(nummapthings * sizeof (*mapthings), PU_LEVEL, NULL); - // Allocate a big chunk of memory as big as our MAXLEVELFLATS limit. - //Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty - foundflats = calloc(MAXLEVELFLATS, sizeof (*foundflats)); - if (foundflats == NULL) - I_Error("Ran out of memory while loading sectors\n"); - - numlevelflats = 0; - // Strict map data P_LoadRawVertexes(virtvertexes->data); P_LoadRawSectors(virtsectors->data); P_LoadRawLineDefs(virtlinedefs->data); P_SetupLines(); P_LoadRawSideDefs2(virtsidedefs->data); - P_PrepareRawThings(virtthings->data); - - R_ClearTextureNumCache(true); - - // set the sky flat num - skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats); - - // copy table for global usage - levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); - free(foundflats); - - // search for animated flats and set up - P_SetupLevelFlatAnims(); } /** Sets up a sky texture to use for the level. @@ -2260,6 +2259,9 @@ void P_LoadThingsOnly(void) mobj_t *mo; thinker_t *think; + virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); + virtlump_t* vth = vres_Find(virt, "THINGS"); + for (think = thinkercap.next; think != &thinkercap; think = think->next) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) @@ -2273,8 +2275,11 @@ void P_LoadThingsOnly(void) P_LevelInitStuff(); + P_PrepareRawThings(vth->data); P_LoadThings(); + vres_Free(virt); + P_SpawnSecretItems(true); } @@ -2342,6 +2347,8 @@ static void P_LoadMapFromFile(void) P_LoadLineDefs2(); P_GroupLines(); + P_PrepareRawThings(vres_Find(virt, "THINGS")->data); + P_MakeMapMD5(virt, &mapmd5); vres_Free(virt); @@ -2550,7 +2557,28 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) static boolean P_CanSave(void) { +#if 0 + // Saving is completely ignored under these conditions: + if ((cursaveslot < 0) // Playing without saving + || (modifiedgame && !savemoddata) // Game is modified + || (netgame || multiplayer) // Not in single-player + || (demo.playback || demo.recording || metalrecording) // Currently in demo + || (players[consoleplayer].lives <= 0) // Completely dead + || (modeattacking || ultimatemode || G_IsSpecialStage(gamemap))) // Specialized instances + return false; + + if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_ALWAYS) + return true; // Saving should ALWAYS happen! + else if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_NEVER) + return false; // Saving should NEVER happen! + + // Default condition: In a non-hidden map, at the beginning of a zone or on a completed save-file, and not on save reload. + return (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) + && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete) + && (gamemap != lastmapsaved)); +#else return false; // SRB2Kart: no SP, no saving. +#endif } /** Loads a level from a lump or external wad. -- 2.54.0 From fcda4c118821161a9e3757fcc7b8969cbca32953 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 17 Jul 2024 22:19:03 +0200 Subject: [PATCH 173/525] revert this in teleport --- src/p_spec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 91f3b5bab..21e44fce9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2371,7 +2371,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) y = sides[line->sidenum[0]].rowoffset; z = line->frontsector->ceilingheight; - P_SetOrigin(mo, mo->x + x, mo->y + y, mo->z + z); + P_UnsetThingPosition(mo); + mo->x += x; + mo->y += y; + mo->z += z; + P_SetThingPosition(mo); if (mo->player) { -- 2.54.0 From fbf7be88080722e8231c2dbfc5a28a1eedf57d87 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 18 Jul 2024 14:43:05 +0200 Subject: [PATCH 174/525] add audio buffer size into sound menu --- src/m_menu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 3f34fda2f..8f884d05c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1638,7 +1638,9 @@ static menuitem_t OP_SoundAdvancedMenu[] = {IT_HEADER, NULL, "Misc", NULL, 105}, {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 117}, - {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 137}, + {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 127}, + + {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 147}, }; static const char* OP_SoundAdvancedTooltips[] = @@ -1656,7 +1658,7 @@ static const char* OP_SoundAdvancedTooltips[] = NULL, "Should the Grow music be on or off?", "Should the Invulnerability music be on or off?", - + "Size of the Audio Buffer\nreducing it will result in less sound latency\nbut may cause issues such as crackling or distorted Sound.", }; static menuitem_t OP_DataOptionsMenu[] = -- 2.54.0 From 19eee66c39346b09970c75ab03b9a23816e52a8e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 14:38:38 +0200 Subject: [PATCH 175/525] make a packet to tell if a joined client is on saturn initial stuff works and seems to be vanilla compatible needs its own function and other things to be useful --- src/d_clisrv.c | 12 +++++++++++- src/d_clisrv.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 710f2687b..93b89ca41 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4672,6 +4672,8 @@ static void HandleConnect(SINT8 node) #ifdef JOININGAME if (nodewaiting[node]) { + netbuffer->packettype = PT_ISSATURN; + HSendPacket(node, false, 0, 0); if (node && newnode) { SV_SendSaveGame(node); // send a complete game state @@ -4995,6 +4997,11 @@ static void HandlePacketFromAwayNode(SINT8 node) break; /* FALLTHRU */ + case PT_ISSATURN: + CONS_Printf("hi im on saturn\n"); + client_is_saturn = true; + break; + default: DEBFILE(va("unknown packet received (%d) from unknown host\n",netbuffer->packettype)); Net_CloseConnection(node); @@ -5044,7 +5051,6 @@ static void HandlePacketFromPlayer(SINT8 node) tic_t realend, realstart; UINT8 *pak, *txtpak, numtxtpak; - txtpak = NULL; if (dedicated && node == 0) @@ -5499,6 +5505,10 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) Got_Filetxpak(); break; + case PT_ISSATURN: + CONS_Printf("hi im on saturn\n"); + client_is_saturn = true; + break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", netbuffer->packettype, node)); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 13c2bc353..6faf62d97 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -98,6 +98,7 @@ typedef enum PT_MOREFILESNEEDED, // Server, to client: "you need these (+ more on top of those)" PT_PING, // Packet sent to tell clients the other client's latency to server. + PT_ISSATURN, NUMPACKETTYPE } packettype_t; -- 2.54.0 From 9bff8dd91fa918c19b0112146497a966e737b758 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 14:39:23 +0200 Subject: [PATCH 176/525] whoopss remove test stuff --- src/d_clisrv.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 93b89ca41..5755a0343 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4997,11 +4997,6 @@ static void HandlePacketFromAwayNode(SINT8 node) break; /* FALLTHRU */ - case PT_ISSATURN: - CONS_Printf("hi im on saturn\n"); - client_is_saturn = true; - break; - default: DEBFILE(va("unknown packet received (%d) from unknown host\n",netbuffer->packettype)); Net_CloseConnection(node); @@ -5507,7 +5502,6 @@ static void HandlePacketFromPlayer(SINT8 node) break; case PT_ISSATURN: CONS_Printf("hi im on saturn\n"); - client_is_saturn = true; break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", -- 2.54.0 From b07c8848ca03e87d8468bee8840bab91782c53ff Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 14:43:19 +0200 Subject: [PATCH 177/525] make smol function for now --- src/d_clisrv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5755a0343..0c15386ec 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4423,6 +4423,12 @@ static boolean SV_AddWaitingPlayers(void) return newplayer; } +static inline void SendSaturnInfo(INT32 node) +{ + netbuffer->packettype = PT_ISSATURN; + HSendPacket(node, false, 0, 0); +} + void CL_AddSplitscreenPlayer(void) { if (cl_mode == CL_CONNECTED) @@ -4672,8 +4678,7 @@ static void HandleConnect(SINT8 node) #ifdef JOININGAME if (nodewaiting[node]) { - netbuffer->packettype = PT_ISSATURN; - HSendPacket(node, false, 0, 0); + SendSaturnInfo(node); if (node && newnode) { SV_SendSaveGame(node); // send a complete game state -- 2.54.0 From 2b5db9ff3f654a85bf634525083e0c908dbb344e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 14:46:24 +0200 Subject: [PATCH 178/525] make saturn packet reliable --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0c15386ec..526570bc9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4426,7 +4426,7 @@ static boolean SV_AddWaitingPlayers(void) static inline void SendSaturnInfo(INT32 node) { netbuffer->packettype = PT_ISSATURN; - HSendPacket(node, false, 0, 0); + HSendPacket(node, true, 0, 0); } void CL_AddSplitscreenPlayer(void) -- 2.54.0 From 800dbf5e789a4f57c2579372099340990b3aebb8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 15:00:45 +0200 Subject: [PATCH 179/525] add packet into packettypename --- src/d_net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/d_net.c b/src/d_net.c index 15ab46b5c..dd0b9d5e9 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -832,7 +832,9 @@ const char *packettypename[NUMPACKETTYPE] = "TELLFILESNEEDED", "MOREFILESNEEDED", - "PING" + "PING", + + "ISSATURN" }; const char *Net_GetPacketName(UINT8 packettype) -- 2.54.0 From 3f5c19bffddab3b642ab33d53621730f0bff9497 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 15:01:30 +0200 Subject: [PATCH 180/525] add boolean to tell if node is saturn --- src/d_clisrv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 526570bc9..a4222ace7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -136,6 +136,8 @@ static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server +boolean is_client_saturn[MAXNETNODES]; + static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen static UINT8 localtextcmd3[MAXTEXTCMD]; // splitscreen == 2 @@ -3175,6 +3177,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) SV_InitResynchVars(node); nodeingame[node] = false; + is_client_saturn[node] = false; Net_CloseConnection(node); ResetNode(node); } @@ -3280,6 +3283,7 @@ void CL_Reset(void) if (servernode > 0 && servernode < MAXNETNODES) { nodeingame[(UINT8)servernode] = false; + is_client_saturn[(UINT8)servernode] = false; Net_CloseConnection(servernode); } D_CloseConnection(); // netgame = false @@ -4086,6 +4090,7 @@ void D_ClientServerInit(void) static void ResetNode(INT32 node) { nodeingame[node] = false; + is_client_saturn[node] = false; nodetoplayer[node] = -1; nodetoplayer2[node] = -1; nodetoplayer3[node] = -1; @@ -5342,6 +5347,7 @@ static void HandlePacketFromPlayer(SINT8 node) } Net_CloseConnection(node); nodeingame[node] = false; + is_client_saturn[node] = false; break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_RESYNCHEND: @@ -5507,6 +5513,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; case PT_ISSATURN: CONS_Printf("hi im on saturn\n"); + is_client_saturn[node] = true; break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", -- 2.54.0 From 9cc42e6430ddb8888703a4455937b81c635efc08 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 19 Jul 2024 19:03:47 +0300 Subject: [PATCH 181/525] Add option to play power items sfx for growmusic and supermusic --- src/g_game.c | 5 +++-- src/k_kart.c | 25 ++++++++----------------- src/p_user.c | 4 ++-- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index a8146014f..e06379e0f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -417,8 +417,9 @@ consvar_t cv_songcredits = {"songcredits", "On", CV_SAVE, CV_OnOff, NULL, 0, NUL consvar_t cv_showfreeplay = { "showfreeplay", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; // We can disable special tunes! -consvar_t cv_growmusic = {"growmusic", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_supermusic = {"supermusic", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t powermusic_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "SFX"}, {0, NULL}}; +consvar_t cv_growmusic = {"growmusic", "On", CV_SAVE, powermusic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_supermusic = {"supermusic", "On", CV_SAVE, powermusic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; /*consvar_t cv_crosshair = {"crosshair", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_crosshair2 = {"crosshair2", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/k_kart.c b/src/k_kart.c index 52e2ceb95..d074593c2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4915,23 +4915,14 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) static void K_UpdateInvincibilitySounds(player_t *player) { INT32 sfxnum = sfx_None; + boolean localplayer = P_IsLocalPlayer(player); - if (player->mo->health > 0 && !P_IsLocalPlayer(player)) + if (player->mo->health > 0) { - if (cv_kartinvinsfx.value) - { - if (player->kartstuff[k_growshrinktimer] > 0) // Prioritize Grow - sfxnum = sfx_alarmg; - else if (player->kartstuff[k_invincibilitytimer] > 0) - sfxnum = sfx_alarmi; - } - else - { - if (player->kartstuff[k_growshrinktimer] > 0) - sfxnum = sfx_kgrow; - else if (player->kartstuff[k_invincibilitytimer] > 0) - sfxnum = sfx_kinvnc; - } + if (player->kartstuff[k_growshrinktimer] > 0 && (!localplayer || cv_growmusic.value == 2)) // Prioritize Grow + sfxnum = cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow; + else if (player->kartstuff[k_invincibilitytimer] > 0 && (!localplayer || cv_supermusic.value == 2)) + sfxnum = cv_kartinvinsfx.value ? sfx_alarmi : sfx_kinvnc; } if (sfxnum != sfx_None && !S_SoundPlaying(player->mo, sfxnum)) @@ -5993,7 +5984,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_SetScale(overlay, player->mo->scale); } player->kartstuff[k_invincibilitytimer] = itemtime+(2*TICRATE); // 10 seconds - if (P_IsLocalPlayer(player) && cv_supermusic.value && cv_birdmusic.value) + if (P_IsLocalPlayer(player) && cv_supermusic.value == 1 && cv_birdmusic.value) S_ChangeMusicSpecial("kinvnc"); else S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmi : sfx_kinvnc)); @@ -6198,7 +6189,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (cv_kartdebugshrink.value && !modeattacking && !player->bot) player->mo->destscale = (6*player->mo->destscale)/8; player->kartstuff[k_growshrinktimer] = itemtime+(4*TICRATE); // 12 seconds - if (P_IsLocalPlayer(player) && cv_growmusic.value && cv_birdmusic.value ) + if (P_IsLocalPlayer(player) && cv_growmusic.value == 1 && cv_birdmusic.value ) S_ChangeMusicSpecial("kgrow"); else S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow)); diff --git a/src/p_user.c b/src/p_user.c index c3dacfa60..2b3c8bf6b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -795,7 +795,7 @@ void P_RestoreMusic(player_t *player) } // Item - Grow - if (wantedmus == 2 && cv_growmusic.value) + if (wantedmus == 2 && cv_growmusic.value == 1) { S_ChangeMusicInternal("kgrow", true); @@ -803,7 +803,7 @@ void P_RestoreMusic(player_t *player) S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility - else if (wantedmus == 1 && cv_supermusic.value) + else if (wantedmus == 1 && cv_supermusic.value == 1) { S_ChangeMusicInternal("kinvnc", true); -- 2.54.0 From 36d598440a23cb360efcaf554e640967ecd06a27 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 18:52:53 +0200 Subject: [PATCH 182/525] disable hudoffsets in splitscreen --- src/k_kart.c | 59 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index d074593c2..e2fa2e748 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7498,50 +7498,50 @@ static void K_initKartHUD(void) if (splitscreen) // Splitscreen { - ITEM_X = 5 + cv_item_xoffset.value; - ITEM_Y = 3 + cv_item_yoffset.value; + ITEM_X = 5; + ITEM_Y = 3; - LAPS_Y = (BASEVIDHEIGHT/2)-24 + cv_laps_yoffset.value; + LAPS_Y = (BASEVIDHEIGHT/2)-24; - POSI_Y = (BASEVIDHEIGHT/2)- 2 + cv_posi_yoffset.value; + POSI_Y = (BASEVIDHEIGHT/2)- 2; - STCD_Y = BASEVIDHEIGHT/4 + cv_stcd_yoffset.value; + STCD_Y = BASEVIDHEIGHT/4; - MINI_Y = (BASEVIDHEIGHT/2) + cv_mini_yoffset.value; + MINI_Y = (BASEVIDHEIGHT/2); if (splitscreen > 1) // 3P/4P Small Splitscreen { // 1P (top left) - ITEM_X = -9 + cv_item_xoffset.value; - ITEM_Y = -8 + cv_item_yoffset.value; + ITEM_X = -9; + ITEM_Y = -8; - LAPS_X = 3 + cv_laps_xoffset.value; - LAPS_Y = (BASEVIDHEIGHT/2)-13 + cv_laps_yoffset.value; + LAPS_X = 3; + LAPS_Y = (BASEVIDHEIGHT/2)-13; - POSI_X = 24 + cv_posi_xoffset.value; - POSI_Y = (BASEVIDHEIGHT/2)- 16 + cv_posi_yoffset.value; + POSI_X = 24; + POSI_Y = (BASEVIDHEIGHT/2)- 16; // 2P (top right) - ITEM2_X = BASEVIDWIDTH-39 + cv_item_xoffset.value; - ITEM2_Y = -8 + cv_item_yoffset.value; + ITEM2_X = BASEVIDWIDTH-39; + ITEM2_Y = -8; - LAPS2_X = BASEVIDWIDTH-3 + cv_laps_xoffset.value; - LAPS2_Y = (BASEVIDHEIGHT/2)-13 + cv_laps_yoffset.value; + LAPS2_X = BASEVIDWIDTH-3; + LAPS2_Y = (BASEVIDHEIGHT/2)-13; - POSI2_X = BASEVIDWIDTH -4 + cv_posi_xoffset.value; - POSI2_Y = (BASEVIDHEIGHT/2)- 16 + cv_posi_yoffset.value; + POSI2_X = BASEVIDWIDTH -4; + POSI2_Y = (BASEVIDHEIGHT/2)- 16; // Reminder that 3P and 4P are just 1P and 2P splitscreen'd to the bottom. - STCD_X = BASEVIDWIDTH/4 + cv_stcd_xoffset.value; + STCD_X = BASEVIDWIDTH/4; - MINI_X = (3*BASEVIDWIDTH/4) + cv_mini_xoffset.value; - MINI_Y = (3*BASEVIDHEIGHT/4) + cv_mini_yoffset.value; + MINI_X = (3*BASEVIDWIDTH/4); + MINI_Y = (3*BASEVIDHEIGHT/4); if (splitscreen > 2) // 4P-only { - MINI_X = (BASEVIDWIDTH/2) + cv_mini_xoffset.value; - MINI_Y = (BASEVIDHEIGHT/2) + cv_mini_yoffset.value; + MINI_X = (BASEVIDWIDTH/2); + MINI_Y = (BASEVIDHEIGHT/2); } } } @@ -7757,8 +7757,17 @@ static void K_drawKartStats(void) spdoffset = 0; // Customizations c: - x += 18 + cv_stat_xoffset.value; - y += cv_stat_yoffset.value + (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0) + spdoffset; + if (!splitscreen) + { + x += 18 + cv_stat_xoffset.value; + y += cv_stat_yoffset.value + (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0) + spdoffset; + } + else + { + x += 18; + y += (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0) + spdoffset; + } + flags |= V_HUDTRANS; skin_t *fakeskin; -- 2.54.0 From 0b3284e23cdb945e2327157e146a97c4f2277f83 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 19:25:05 +0200 Subject: [PATCH 183/525] fix ScreenCoords on 2 plyr splitscreen and shearing + remove non 16:10 hack since that issue was fixed elsewhere --- src/k_kart.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e2fa2e748..1ce92dc30 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8996,11 +8996,11 @@ static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *targe offset = FixedMul(FINETANGENT(((aimingangle+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), xres); // this isn't fovtan... what am i even doing anymore if (splitscreen == 1) - offset = 17*offset/10; - // OpenGL with software perspective is miscentered on non-16:10 resolutions + offset = 17*offset/120; #ifdef HWRENDER - if (rendermode == render_opengl) - offset = FixedMul(offset, FixedDiv(104857, FixedDiv(xres, yres))); + // OpenGL with software perspective is miscentered on non-16:10 resolutions + //if (rendermode == render_opengl) + //offset = FixedMul(offset, FixedDiv(104857, FixedDiv(xres, yres))); #endif // thanks fickle offset = FixedDiv(offset, fovratio); @@ -9023,12 +9023,14 @@ static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *targe int splitindex = stplyrnum; // adjust coords for splitscreen - if (splitscreen == 1){ // 2P + if (splitscreen == 1) // 2P + { y = y>>1; if (splitindex) y = y + yres; } - if (splitscreen >= 2) { // 3P or 4P + if (splitscreen >= 2) // 3P or 4P + { x = x>>1; y = y>>1; if (splitindex & 1) -- 2.54.0 From df9ad5a31f7616433be9cf335dd51ce093670b5f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 21:26:02 +0200 Subject: [PATCH 184/525] dont access delayremoved thinkers uhhh --- src/d_clisrv.c | 8 +-- src/d_netcmd.c | 3 +- src/g_game.c | 12 +++- src/lua_script.c | 5 ++ src/m_cheat.c | 2 + src/p_enemy.c | 43 +++++++++++-- src/p_inter.c | 4 ++ src/p_mobj.c | 18 ++++++ src/p_polyobj.c | 85 ++++++++++---------------- src/p_saveg.c | 154 ++++++++++++++++++++++++----------------------- src/p_setup.c | 13 ++-- src/p_spec.c | 16 +++++ src/p_tick.c | 4 ++ src/p_user.c | 14 +++++ src/r_data.c | 3 +- 15 files changed, 235 insertions(+), 149 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 710f2687b..3e791f7ab 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5602,11 +5602,6 @@ static INT16 Consistancy(void) ret += P_GetRandSeed(); #ifdef MOBJCONSISTANCY - if (!thinkercap.next) - { - DEBFILE(va("Consistancy = %u\n", ret)); - return ret; - } if (gamestate == GS_LEVEL) { for (th = thinkercap.next; th != &thinkercap; th = th->next) @@ -5614,6 +5609,9 @@ static INT16 Consistancy(void) if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + mo = (mobj_t *)th; if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY)) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8701448b4..3cf64d065 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5781,7 +5781,8 @@ static void Command_Archivetest_f(void) i = 1; for (th = thinkercap.next; th != &thinkercap; th = th->next) if (th->function.acp1 == (actionf_p1)P_MobjThinker) - ((mobj_t *)th)->mobjnum = i++; + if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) + ((mobj_t *)th)->mobjnum = i++; // allocate buffer buf = save_p = ZZ_Alloc(1024); diff --git a/src/g_game.c b/src/g_game.c index e06379e0f..203b1aba5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3021,6 +3021,9 @@ void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo) if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + mo2 = (mobj_t *)th; if (!(mo2->flags & MF_MISSILE)) @@ -5625,11 +5628,13 @@ void G_ConsGhostTic(INT32 playernum) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mobj = (mobj_t *)th; if (mobj->type == (mobjtype_t)type && mobj->x == x && mobj->y == y && mobj->z == z) break; } - if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! + if ((th != &thinkercap && th->function.acp1 != (actionf_p1)P_MobjThinker) && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); @@ -8096,11 +8101,14 @@ void G_DoPlayMetal(void) if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + mo = (mobj_t *)th; if (mo->type == MT_METALSONIC_RACE) break; } - if (!mo) + if (th == &thinkercap && th->function.acp1 == (actionf_p1)P_MobjThinker) { CONS_Alert(CONS_ERROR, M_GetText("Failed to find bot entity.\n")); Z_Free(metalbuffer); diff --git a/src/lua_script.c b/src/lua_script.c index 5413c007a..160c92180 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1596,6 +1596,9 @@ void LUA_Archive(void) if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + // archive function will determine when to skip mobjs, // and write mobjnum in otherwise. ArchiveExtVars(th, "mobj"); @@ -1632,6 +1635,8 @@ void LUA_UnArchive(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; if (((mobj_t *)th)->mobjnum != mobjnum) // find matching mobj continue; UnArchiveExtVars(th); // apply variables diff --git a/src/m_cheat.c b/src/m_cheat.c index abada4be5..6b93461f3 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -906,6 +906,8 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)th; // get offset from mt, which points to old mapthings, then add new location diff --git a/src/p_enemy.c b/src/p_enemy.c index 3a032fbf0..1a23317ed 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2635,6 +2635,8 @@ void A_BossDeath(mobj_t *mo) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; if (mo2 != mo && (mo2->flags & MF_BOSS) && mo2->health > 0) @@ -2693,6 +2695,8 @@ bossjustdie: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -5300,6 +5304,8 @@ void A_RingExplode(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -6868,13 +6874,23 @@ void A_Boss3Path(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && mo2->spawnpoint->angle == actor->threshold) - { - P_SetTarget(&actor->target, mo2); - break; - } + + if (mo2->type != MT_BOSS3WAYPOINT) + continue; + + if(!mo2->spawnpoint) + continue; + + if (mo2->spawnpoint->angle != actor->threshold) + continue; + + + P_SetTarget(&actor->target, mo2); + break; } if (!actor->target) // Should NEVER happen @@ -7305,6 +7321,8 @@ void A_FindTarget(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -7369,6 +7387,8 @@ void A_FindTracer(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -7911,6 +7931,8 @@ void A_RemoteAction(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -8689,6 +8711,8 @@ void A_MementosTPParticles(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; if (mo2->type == MT_MEMENTOSTP && mo2 != actor) @@ -8788,6 +8812,8 @@ void A_ReaperThinker(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -8844,7 +8870,6 @@ void A_ReaperThinker(mobj_t *actor) // Waypoint behavior. if (actor->target->type == MT_REAPERWAYPOINT) { - if (R_PointToDist2(actor->x, actor->y, actor->target->x, actor->target->y) < 22<target, NULL); // remove target so we can default back to first waypoint if things go ham. @@ -8854,6 +8879,8 @@ void A_ReaperThinker(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -9029,6 +9056,8 @@ void A_SetObjectTypeState(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -9651,6 +9680,8 @@ void A_CheckThingCount(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; diff --git a/src/p_inter.c b/src/p_inter.c index 1e03ab346..4500d9e92 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1209,6 +1209,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; if (mo2->type == MT_KOOPA) @@ -2364,6 +2366,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)th; if (mo->type == (mobjtype_t)target->info->mass && mo->tracer == target) diff --git a/src/p_mobj.c b/src/p_mobj.c index 03a8d851c..fe05e7b1f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3213,6 +3213,8 @@ void P_DestroyRobots(void) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)think; if (mo->health <= 0 || !(mo->flags & MF_ENEMY || mo->flags & MF_BOSS)) @@ -4021,6 +4023,8 @@ static void P_Boss3Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; if (mo2->type == (mobjtype_t)mobj->info->mass && mo2->tracer == mobj) @@ -4112,6 +4116,8 @@ static void P_Boss3Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -4743,6 +4749,8 @@ static void P_Boss7Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint) @@ -4798,6 +4806,8 @@ static void P_Boss7Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && (mo2->spawnpoint->options & 7) == waypointNum) @@ -4921,6 +4931,8 @@ static void P_Boss9Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; if (mo2->type == MT_BOSS9GATHERPOINT) @@ -5354,6 +5366,8 @@ mobj_t *P_GetClosestAxis(mobj_t *source) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -10360,6 +10374,8 @@ void P_RespawnSpecials(void) if (th->function.acp1 != (actionf_p1)P_MobjThinker) // not a mobj continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; box = (mobj_t *)th; @@ -11506,6 +11522,8 @@ ML_NOCLIMB : Direction not controllable { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index bbf934231..03df03905 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1514,29 +1514,31 @@ void Polyobj_InitLevel(void) // the mobj_t pointers on a queue for use below. for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 == (actionf_p1)P_MobjThinker) + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mobj_t *mo = (mobj_t *)th; + + if (mo->info->doomednum == POLYOBJ_SPAWN_DOOMEDNUM || + mo->info->doomednum == POLYOBJ_SPAWNCRUSH_DOOMEDNUM) { - mobj_t *mo = (mobj_t *)th; + ++numPolyObjects; - if (mo->info->doomednum == POLYOBJ_SPAWN_DOOMEDNUM || - mo->info->doomednum == POLYOBJ_SPAWNCRUSH_DOOMEDNUM) - { - ++numPolyObjects; + qitem = malloc(sizeof(mobjqitem_t)); + memset(qitem, 0, sizeof(mobjqitem_t)); + qitem->mo = mo; + M_QueueInsert(&(qitem->mqitem), &spawnqueue); + } + else if (mo->info->doomednum == POLYOBJ_ANCHOR_DOOMEDNUM) + { + ++numAnchors; - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); - qitem->mo = mo; - M_QueueInsert(&(qitem->mqitem), &spawnqueue); - } - else if (mo->info->doomednum == POLYOBJ_ANCHOR_DOOMEDNUM) - { - ++numAnchors; - - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); - qitem->mo = mo; - M_QueueInsert(&(qitem->mqitem), &anchorqueue); - } + qitem = malloc(sizeof(mobjqitem_t)); + memset(qitem, 0, sizeof(mobjqitem_t)); + qitem->mo = mo; + M_QueueInsert(&(qitem->mqitem), &anchorqueue); } } @@ -1571,39 +1573,6 @@ void Polyobj_InitLevel(void) Polyobj_linkToBlockmap(&PolyObjects[i]); } -#if 0 - // haleyjd 02/22/06: temporary debug - printf("DEBUG: numPolyObjects = %d\n", numPolyObjects); - for (i = 0; i < numPolyObjects; ++i) - { - INT32 j; - polyobj_t *po = &PolyObjects[i]; - - printf("polyobj %d:\n", i); - printf("id = %d, first = %d, next = %d\n", po->id, po->first, po->next); - printf("segCount = %d, numSegsAlloc = %d\n", po->segCount, po->numSegsAlloc); - for (j = 0; j < po->segCount; ++j) - printf("\tseg %d: %p\n", j, po->segs[j]); - printf("numVertices = %d, numVerticesAlloc = %d\n", po->numVertices, po->numVerticesAlloc); - for (j = 0; j < po->numVertices; ++j) - { - printf("\tvtx %d: (%d, %d) / orig: (%d, %d)\n", - j, po->vertices[j]->x>>FRACBITS, po->vertices[j]->y>>FRACBITS, - po->origVerts[j].x>>FRACBITS, po->origVerts[j].y>>FRACBITS); - } - printf("numLines = %d, numLinesAlloc = %d\n", po->numLines, po->numLinesAlloc); - for (j = 0; j < po->numLines; ++j) - printf("\tline %d: %p\n", j, po->lines[j]); - printf("spawnSpot = (%d, %d)\n", po->spawnSpot.x >> FRACBITS, po->spawnSpot.y >> FRACBITS); - printf("centerPt = (%d, %d)\n", po->centerPt.x >> FRACBITS, po->centerPt.y >> FRACBITS); - printf("attached = %d, linked = %d, validcount = %d, isBad = %d\n", - po->attached, po->linked, po->validcount, po->isBad); - printf("blockbox: [%d, %d, %d, %d]\n", - po->blockbox[BOXLEFT], po->blockbox[BOXRIGHT], po->blockbox[BOXBOTTOM], - po->blockbox[BOXTOP]); - } -#endif - // done with mobj queues M_QueueFree(&spawnqueue); M_QueueFree(&anchorqueue); @@ -1820,6 +1789,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)wp; @@ -1904,6 +1875,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)wp; @@ -1943,6 +1916,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)wp; @@ -1980,6 +1955,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)wp; @@ -2500,6 +2477,8 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)wp; diff --git a/src/p_saveg.c b/src/p_saveg.c index be393c51b..ca41198ab 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1879,6 +1879,8 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mobj = (mobj_t *)th; if (mobj->mobjnum != oldposition) @@ -2999,11 +3001,12 @@ static inline void P_FinishMobjs(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) - { - mobj = (mobj_t *)currentthinker; - mobj->info = &mobjinfo[mobj->type]; - } + if (currentthinker->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (currentthinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + mobj = (mobj_t *)currentthinker; + mobj->info = &mobjinfo[mobj->type]; } } @@ -3017,69 +3020,71 @@ static void P_RelinkPointers(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) + if (currentthinker->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (currentthinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mobj = (mobj_t *)currentthinker; + + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + continue; + + if (mobj->tracer) { - mobj = (mobj_t *)currentthinker; - - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) - continue; - - if (mobj->tracer) - { - temp = (UINT32)(size_t)mobj->tracer; - mobj->tracer = NULL; - if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); - } - if (mobj->target) - { - temp = (UINT32)(size_t)mobj->target; - mobj->target = NULL; - if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); - } - if (mobj->hnext) - { - temp = (UINT32)(size_t)mobj->hnext; - mobj->hnext = NULL; - if (!P_SetTarget(&mobj->hnext, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); - } - if (mobj->hprev) - { - temp = (UINT32)(size_t)mobj->hprev; - mobj->hprev = NULL; - if (!P_SetTarget(&mobj->hprev, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->capsule) - { - temp = (UINT32)(size_t)mobj->player->capsule; - mobj->player->capsule = NULL; - if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis1) - { - temp = (UINT32)(size_t)mobj->player->axis1; - mobj->player->axis1 = NULL; - if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis2) - { - temp = (UINT32)(size_t)mobj->player->axis2; - mobj->player->axis2 = NULL; - if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->awayviewmobj) - { - temp = (UINT32)(size_t)mobj->player->awayviewmobj; - mobj->player->awayviewmobj = NULL; - if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); - } + temp = (UINT32)(size_t)mobj->tracer; + mobj->tracer = NULL; + if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); + } + if (mobj->target) + { + temp = (UINT32)(size_t)mobj->target; + mobj->target = NULL; + if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); + } + if (mobj->hnext) + { + temp = (UINT32)(size_t)mobj->hnext; + mobj->hnext = NULL; + if (!P_SetTarget(&mobj->hnext, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); + } + if (mobj->hprev) + { + temp = (UINT32)(size_t)mobj->hprev; + mobj->hprev = NULL; + if (!P_SetTarget(&mobj->hprev, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->capsule) + { + temp = (UINT32)(size_t)mobj->player->capsule; + mobj->player->capsule = NULL; + if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->axis1) + { + temp = (UINT32)(size_t)mobj->player->axis1; + mobj->player->axis1 = NULL; + if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->axis2) + { + temp = (UINT32)(size_t)mobj->player->axis2; + mobj->player->axis2 = NULL; + if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->awayviewmobj) + { + temp = (UINT32)(size_t)mobj->player->awayviewmobj; + mobj->player->awayviewmobj = NULL; + if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); } } } @@ -3455,13 +3460,14 @@ void P_SaveNetGame(void) { for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - { - mobj = (mobj_t *)th; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) - continue; - mobj->mobjnum = i++; - } + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + mobj = (mobj_t *)th; + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + continue; + mobj->mobjnum = i++; } } diff --git a/src/p_setup.c b/src/p_setup.c index e5f947a87..19107a02c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -750,6 +750,8 @@ void P_ReloadRings(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)th; @@ -2256,7 +2258,6 @@ static void P_LevelInitStuff(void) void P_LoadThingsOnly(void) { // Search through all the thinkers. - mobj_t *mo; thinker_t *think; virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); @@ -2265,12 +2266,10 @@ void P_LoadThingsOnly(void) for (think = thinkercap.next; think != &thinkercap; think = think->next) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (mo) - P_RemoveMobj(mo); + continue; + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + P_RemoveMobj((mobj_t *)think); } P_LevelInitStuff(); diff --git a/src/p_spec.c b/src/p_spec.c index 21e44fce9..1bde9a72e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3284,6 +3284,8 @@ void P_SetupSignExit(player_t *player) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; thing = (mobj_t *)think; if (thing->type != MT_SIGN) @@ -3333,6 +3335,8 @@ boolean P_IsFlagAtBase(mobjtype_t flag) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)think; @@ -3771,6 +3775,8 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -4115,6 +4121,8 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -4194,6 +4202,8 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -4416,6 +4426,8 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -4454,6 +4466,8 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -4481,6 +4495,8 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; diff --git a/src/p_tick.c b/src/p_tick.c index 3913c5d62..9b67502dd 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -154,6 +154,8 @@ void Command_CountMobjs_f(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; if (((mobj_t *)th)->type == i) count++; @@ -174,6 +176,8 @@ void Command_CountMobjs_f(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; if (((mobj_t *)th)->type == i) count++; diff --git a/src/p_user.c b/src/p_user.c index 2b3c8bf6b..bacdb920d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1143,6 +1143,8 @@ void P_SpawnShieldOrb(player_t *player) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; shieldobj = (mobj_t *)th; @@ -1871,6 +1873,8 @@ void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -2623,6 +2627,8 @@ static void P_DoZoomTube(player_t *player) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; @@ -2718,6 +2724,8 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)think; @@ -2798,6 +2806,8 @@ boolean P_LookForEnemies(player_t *player) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)think; if (!(mo->flags & (MF_ENEMY|MF_BOSS|MF_MONITOR|MF_SPRING))) @@ -2923,6 +2933,8 @@ void P_FindEmerald(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; if (mo2->type == MT_EMERHUNT) @@ -4636,6 +4648,8 @@ void P_PlayerThink(player_t *player) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo2 = (mobj_t *)th; diff --git a/src/r_data.c b/src/r_data.c index ad8b420f3..a725d2ac9 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1687,7 +1687,8 @@ void R_PrecacheLevel(void) for (th = thinkercap.next; th != &thinkercap; th = th->next) if (th->function.acp1 == (actionf_p1)P_MobjThinker) - spritepresent[((mobj_t *)th)->sprite] = 1; + if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) + spritepresent[((mobj_t *)th)->sprite] = 1; spritememory = 0; for (i = 0; i < numsprites; i++) -- 2.54.0 From 048ccf52b0de555b91a2bb7130dee04dc4427d58 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 21:26:42 +0200 Subject: [PATCH 185/525] Clean up mobj and thinker removal --- src/p_mobj.c | 43 ++++++++++++++++--------------------------- src/p_tick.c | 44 +++++++++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 46 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index fe05e7b1f..0423b00f3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10036,7 +10036,7 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->hprev->hnext, mobj->hnext); P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); - + // clear the reference from the mapthing if (mobj->spawnpoint) P_SetTarget(&mobj->spawnpoint->mobj, NULL); @@ -10044,45 +10044,34 @@ void P_RemoveMobj(mobj_t *mobj) R_RemoveMobjInterpolator(mobj); // free block - // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. - if (mobj->flags & MF_NOTHINK && !mobj->thinker.next) + if (!mobj->thinker.next) { // Uh-oh, the mobj doesn't think, P_RemoveThinker would never go through! + INT32 prevreferences; if (!mobj->thinker.references) { -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset(mobj, 0xff, sizeof(mobj_t)); -#endif - Z_Free(mobj); // No refrences? Can be removed immediately! :D - } - else - { // Add thinker just to delay removing it until refrences are gone. - mobj->flags &= ~MF_NOTHINK; - P_AddThinker((thinker_t *)mobj); -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); -#endif - P_RemoveThinker((thinker_t *)mobj); + Z_Free(mobj); // No references? Can be removed immediately! :D + return; } + + prevreferences = mobj->thinker.references; + P_AddThinker((thinker_t *)mobj); + mobj->thinker.references = prevreferences; } - else - { + + P_RemoveThinker((thinker_t *)mobj); + + // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. #ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); + // Invalidate mobj_t data to cause crashes if accessed! + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); #endif - P_RemoveThinker((thinker_t *)mobj); - } } // This does not need to be added to Lua. // To test it in Lua, check mobj.valid boolean P_MobjWasRemoved(mobj_t *mobj) { - if (mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker) - return false; - return true; + return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker); } void P_RemovePrecipMobj(precipmobj_t *mobj) diff --git a/src/p_tick.c b/src/p_tick.c index 9b67502dd..3bbc219ca 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -229,23 +229,27 @@ static thinker_t *currentthinker; // remove it, and set currentthinker to one node preceeding it, so // that the next step in P_RunThinkers() will get its successor. // -void P_RemoveThinkerDelayed(void *pthinker) +void P_RemoveThinkerDelayed(thinker_t *thinker) { - thinker_t *thinker = pthinker; - if (!thinker->references) - { - { - /* Remove from main thinker list */ - thinker_t *next = thinker->next; - /* Note that currentthinker is guaranteed to point to us, - * and since we're freeing our memory, we had better change that. So - * point it to thinker->prev, so the iterator will correctly move on to - * thinker->prev->next = thinker->next */ - (next->prev = currentthinker = thinker->prev)->next = next; - } - R_DestroyLevelInterpolators(thinker); - Z_Free(thinker); - } + thinker_t *next; +#ifdef PARANOIA + if (thinker->next) + thinker->next = NULL; + else if (thinker->references) // Usually gets cleared up in one frame; what's going on here, then? + CONS_Printf("Number of potentially faulty references: %d\n", thinker->references); +#endif + if (thinker->references) + return; + + /* Remove from main thinker list */ + next = thinker->next; + /* Note that currentthinker is guaranteed to point to us, + * and since we're freeing our memory, we had better change that. So + * point it to thinker->prev, so the iterator will correctly move on to + * thinker->prev->next = thinker->next */ + (next->prev = currentthinker = thinker->prev)->next = next; + R_DestroyLevelInterpolators(thinker); + Z_Free(thinker); } // @@ -263,7 +267,7 @@ void P_RemoveThinkerDelayed(void *pthinker) void P_RemoveThinker(thinker_t *thinker) { LUA_InvalidateUserdata(thinker); - thinker->function.acp1 = P_RemoveThinkerDelayed; + thinker->function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; } /* @@ -282,7 +286,7 @@ mobj_t *P_SetTarget(mobj_t **mop, mobj_t *targ) { if (*mop) // If there was a target already, decrease its refcount (*mop)->thinker.references--; -if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter + if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter targ->thinker.references++; return targ; } @@ -313,7 +317,9 @@ static inline void P_RunThinkers(void) { for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1) +#ifdef PARANOIA + I_Assert(currentthinker->function.acp1 != NULL) +#endif currentthinker->function.acp1(currentthinker); } } -- 2.54.0 From 8f195530b5fa02e13cc97be2b8f3c7992f13fd24 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 21:29:10 +0200 Subject: [PATCH 186/525] fix declaration --- src/p_tick.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.h b/src/p_tick.h index 169c54c8e..2cbbb8104 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -27,7 +27,7 @@ void Command_CountMobjs_f(void); void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); -void P_RemoveThinkerDelayed(void *pthinker); //killed +void P_RemoveThinkerDelayed(thinker_t *thinker); mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98 #endif -- 2.54.0 From b7e77e10b60d65670ebaa28ac251d2ece23e270a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 22:44:12 +0200 Subject: [PATCH 187/525] improve virtual resource management --- src/p_setup.c | 26 ++++++++++++++++++-------- src/p_setup.h | 2 ++ src/w_wad.c | 12 ++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 19107a02c..99dfc81d9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -109,6 +109,8 @@ INT32 numstarposts; boolean levelloading; UINT8 levelfadecol; +virtres_t *curmapvirt; + // BLOCKMAP // Created from axis aligned bounding box // of the map, a rectangular array of @@ -2337,20 +2339,26 @@ static void P_MakeMapMD5(virtres_t *virt, void *dest) static void P_LoadMapFromFile(void) { - virtres_t *virt = vres_GetMap(lastloadedmaplumpnum); - - P_LoadMapData(virt); - P_LoadMapBSP(virt); - P_LoadMapLUT(virt); + P_LoadMapData(curmapvirt); + P_LoadMapBSP(curmapvirt); + P_LoadMapLUT(curmapvirt); P_LoadLineDefs2(); P_GroupLines(); - P_PrepareRawThings(vres_Find(virt, "THINGS")->data); + P_PrepareRawThings(vres_Find(curmapvirt, "THINGS")->data); - P_MakeMapMD5(virt, &mapmd5); + P_MakeMapMD5(curmapvirt, &mapmd5); - vres_Free(virt); + // We do the following silly + // construction because vres_Free + // no-sells deletions of pointers + // that are == curmapvirt. + { + virtres_t *temp = curmapvirt; + curmapvirt = NULL; + vres_Free(temp); + } } static void P_RunLevelScript(const char *scriptname) @@ -2803,6 +2811,8 @@ boolean P_SetupLevel(boolean skipprecip) if (lastloadedmaplumpnum == INT16_MAX) I_Error("Map %s not found.\n", maplumpname); + curmapvirt = vres_GetMap(lastloadedmaplumpnum); + R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, (encoremode ? W_CheckNumForName(va("%sE", maplumpname)) : LUMPERROR)); CON_SetupBackColormap(); diff --git a/src/p_setup.h b/src/p_setup.h index 9b96225ad..5df0f0b68 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -17,6 +17,7 @@ #include "doomdata.h" #include "doomstat.h" #include "r_defs.h" +#include "w_wad.h" extern SINT8 midgamejoin; @@ -32,6 +33,7 @@ extern boolean levelloading; extern UINT8 levelfadecol; extern lumpnum_t lastloadedmaplumpnum; // for comparative savegame +extern virtres_t *curmapvirt; // // MAP used flats lookup table // diff --git a/src/w_wad.c b/src/w_wad.c index c4aa10b1e..04015d614 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2132,6 +2132,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) virtlump_t* vlumps = NULL; size_t numlumps = 0; + if (lastloadedmaplumpnum == lumpnum && curmapvirt != NULL) + { + // Avoid duplicating all our hard work. + return curmapvirt; + } + if (W_IsLumpWad(lumpnum)) { UINT32 realentry; @@ -2208,6 +2214,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) */ void vres_Free(virtres_t* vres) { + if (vres == curmapvirt) + { + // No-sell multiple references. + return; + } + while (vres->numlumps--) Z_Free(vres->vlumps[vres->numlumps].data); Z_Free(vres->vlumps); -- 2.54.0 From a4085cb155fbf1193eba5164038fc206e5c7dd37 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 22:42:50 +0200 Subject: [PATCH 188/525] fix hoop midjoin crash in the dumbest way possible cant figure out why it crashes so thisll do lol --- src/p_inter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_inter.c b/src/p_inter.c index 4500d9e92..90bb3f8da 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -17,6 +17,7 @@ #include "g_game.h" #include "m_random.h" #include "p_local.h" +#include "p_setup.h" #include "s_sound.h" #include "r_main.h" #include "st_stuff.h" @@ -1132,7 +1133,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) break; case MT_HOOPCOLLIDE: // This produces a kind of 'domino effect' with the hoop's pieces. - for (; special->hprev != NULL; special = special->hprev); // Move to the first sprite in the hoop + if (!midgamejoin) + for (; special->hprev != NULL; special = special->hprev); // Move to the first sprite in the hoop + i = 0; for (; special->type == MT_HOOP; special = special->hnext) { -- 2.54.0 From ea4998f66608ffcb9c8e9ac83c26118aa5db8e45 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 16:17:19 +0200 Subject: [PATCH 189/525] add gamestate resend ontop of resynch code lmao absolute hell will fallback to just normal resynching when the client doesent send gamestate request packet --- src/d_clisrv.c | 229 ++++++++++++++++++++++++++++++++++++++++--------- src/d_clisrv.h | 4 + src/d_main.c | 2 +- src/d_net.c | 6 +- src/g_game.c | 6 +- src/hu_stuff.c | 4 +- src/p_saveg.c | 64 +++++++++++--- src/p_saveg.h | 4 +- src/p_setup.c | 25 ++++-- src/p_setup.h | 2 +- 10 files changed, 274 insertions(+), 72 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5af4209a4..c67ef524b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -92,6 +92,8 @@ UINT8 playernode[MAXPLAYERS]; // The actual timeout will be longer depending on the savegame length tic_t jointimeout = (3*TICRATE); static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? +static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame? +static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again? static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout? UINT16 pingmeasurecount = 1; @@ -123,6 +125,7 @@ static UINT8 resynch_inprogress[MAXNETNODES]; static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. static UINT8 player_joining = false; UINT8 hu_resynching = 0; +UINT8 hu_redownloadinggamestate = 0; // kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks UINT8 hu_stopped = 0; @@ -135,6 +138,7 @@ static ticcmd_t localcmds4; static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server +static boolean cl_redownloadinggamestate = false; boolean is_client_saturn[MAXNETNODES]; @@ -1706,22 +1710,26 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.gametype = (UINT8)gametype; netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - // we fill these structs with FFs so that any players not in game get sent as 0xFFFF - // which is nice and easy for us to detect - memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); - memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); - memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); - - for (i = 0; i < MAXPLAYERS; i++) + if (!resendingsavegame[node]) { - netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; + // we fill these structs with FFs so that any players not in game get sent as 0xFFFF + // which is nice and easy for us to detect + memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); + memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); - if (!playeringame[i]) - continue; + memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); - netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; - netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; + for (i = 0; i < MAXPLAYERS; i++) + { + netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; + + if (!playeringame[i]) + continue; + + netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; + netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; + } } netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); @@ -1729,12 +1737,21 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.discordinvites = (boolean)cv_discordinvites.value; memcpy(netbuffer->u.servercfg.server_context, server_context, 8); - op = p = netbuffer->u.servercfg.varlengthinputs; - CV_SavePlayerNames(&p); - CV_SaveNetVars(&p, false); + if (!resendingsavegame[node]) { - const size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); + op = p = netbuffer->u.servercfg.varlengthinputs; + + CV_SavePlayerNames(&p); + CV_SaveNetVars(&p, false); + } + { + size_t len; + + if (resendingsavegame[node]) + len = sizeof (serverconfig_pak); + else + len = sizeof (serverconfig_pak) + (size_t)(p - op); #ifdef DEBUGFILE if (debugfile) @@ -1767,7 +1784,7 @@ static boolean SV_SendServerConfig(INT32 node) #ifdef JOININGAME #define SAVEGAMESIZE (768*1024) -static void SV_SendSaveGame(INT32 node) +static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; UINT8 *savebuffer; @@ -1785,7 +1802,7 @@ static void SV_SendSaveGame(INT32 node) // Leave room for the uncompressed length. save_p = savebuffer + sizeof(UINT32); - P_SaveNetGame(); + P_SaveNetGame(resending); length = save_p - savebuffer; if (length > SAVEGAMESIZE) @@ -1881,7 +1898,7 @@ static void SV_SavedGame(void) #define TMPSAVENAME "$$$.sav" -static void CL_LoadReceivedSavegame(void) +static void CL_LoadReceivedSavegame(boolean reloading) { UINT8 *savebuffer = NULL; size_t length, decompressedlen; @@ -1925,7 +1942,7 @@ static void CL_LoadReceivedSavegame(void) } // load a base level - if (P_LoadNetGame()) + if (P_LoadNetGame(reloading)) { CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap))); if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0) @@ -1940,15 +1957,6 @@ static void CL_LoadReceivedSavegame(void) } CON_LogMessage("\"\n"); } - else - { - CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); - Z_Free(savebuffer); - save_p = NULL; - if (unlink(tmpsave) == -1) - CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); - return; - } // done Z_Free(savebuffer); @@ -1957,6 +1965,34 @@ static void CL_LoadReceivedSavegame(void) CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); consistancy[gametic%TICQUEUE] = Consistancy(); CON_ToggleOff(); + + // Tell the server we have received and reloaded the gamestate + // so they know they can resume the game + netbuffer->packettype = PT_RECEIVEDGAMESTATE; + HSendPacket(servernode, true, 0, 0); +} + +static void CL_ReloadReceivedSavegame(void) +{ + INT32 i; + + for (i = 0; i < MAXPLAYERS; i++) + { + LUA_InvalidatePlayer(&players[i]); + sprintf(player_names[i], "Player %d", i + 1); + } + + CL_LoadReceivedSavegame(true); + + if (neededtic < gametic) + neededtic = gametic; + maketic = neededtic; + + camera->subsector = R_PointInSubsector(camera->x, camera->y); + + cl_redownloadinggamestate = false; + + CONS_Printf(M_GetText("Game state reloaded\n")); } #endif @@ -2570,7 +2606,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic if (fileneeded[0].status == FS_FOUND) { // Gamestate is now handled within CL_LoadReceivedSavegame() - CL_LoadReceivedSavegame(); + CL_LoadReceivedSavegame(false); cl_mode = CL_CONNECTED; break; } // don't break case continue to CL_CONNECTED @@ -3173,8 +3209,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) playerpernode[node]--; if (playerpernode[node] <= 0) { - // If a resynch was in progress, well, it no longer needs to be. - SV_InitResynchVars(node); + SV_InitResynchVars(node); // If a resynch was in progress, well, it no longer needs to be. nodeingame[node] = false; is_client_saturn[node] = false; @@ -3979,6 +4014,34 @@ static void Command_list_http_logins (void) } #endif/*HAVE_CURL*/ +static void Command_ResendGamestate(void) +{ + SINT8 playernum; + + if (COM_Argc() == 1) + { + CONS_Printf(M_GetText("resendgamestate : resend the game state to a player\n")); + return; + } + else if (client) + { + CONS_Printf(M_GetText("Only the server can use this.\n")); + return; + } + + playernum = nametonum(COM_Argv(1)); + if (playernum == -1 || playernum == 0) + return; + + // Send a PT_WILLRESENDGAMESTATE packet to the client so they know what's going on + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + if (!HSendPacket(playernode[playernum], true, 0, 0)) + { + CONS_Alert(CONS_ERROR, M_GetText("A problem occured, please try again.\n")); + return; + } +} + static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}}; consvar_t cv_netticbuffer = {"netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -4052,6 +4115,7 @@ void D_ClientServerInit(void) COM_AddCommand("reloadbans", Command_ReloadBan); COM_AddCommand("connect", Command_connect); COM_AddCommand("nodes", Command_Nodes); + COM_AddCommand("resendgamestate", Command_ResendGamestate); COM_AddCommand("listplayers", Command_Listplayers); COM_AddCommand("packetstat", Command_Packetstat); #ifdef HAVE_CURL @@ -4090,6 +4154,11 @@ void D_ClientServerInit(void) static void ResetNode(INT32 node) { nodeingame[node] = false; + + nodewaiting[node] = 0; + nettics[node] = gametic; + supposedtics[node] = gametic; + is_client_saturn[node] = false; nodetoplayer[node] = -1; nodetoplayer2[node] = -1; @@ -4100,6 +4169,8 @@ static void ResetNode(INT32 node) nodewaiting[node] = 0; playerpernode[node] = 0; sendingsavegame[node] = false; + resendingsavegame[node] = false; + savegameresendcooldown[node] = 0; bannednode[node].banid = SIZE_MAX; bannednode[node].timeleft = NO_BAN_TIME; } @@ -4120,8 +4191,8 @@ void SV_ResetServer(void) { ResetNode(i); - // Make sure resynch status doesn't get carried over! - SV_InitResynchVars(i); + //if (!(resendingsavegame[i] && is_client_saturn[i]))// Make sure resynch status doesn't get carried over! + SV_InitResynchVars(i); } for (i = 0; i < MAXPLAYERS; i++) @@ -4137,6 +4208,7 @@ void SV_ResetServer(void) mynode = 0; cl_packetmissed = false; + cl_redownloadinggamestate = false; if (dedicated) { @@ -4658,9 +4730,10 @@ static void HandleConnect(SINT8 node) /// \note Wait what??? /// What if the gamestate takes more than one second to get downloaded? - /// Or if a lagspike happens? + /// Or if a lagspike happdsfens? // you get a free second before desynch checks. use it wisely. - SV_InitResynchVars(node); + //if (!(resendingsavegame[node] && is_client_saturn[node])) + SV_InitResynchVars(node); #ifdef VANILLAJOINNEXTROUND if (cv_joinnextround.value && gameaction == ga_nothing) @@ -4686,7 +4759,7 @@ static void HandleConnect(SINT8 node) SendSaturnInfo(node); if (node && newnode) { - SV_SendSaveGame(node); // send a complete game state + SV_SendSaveGame(node, false); // send a complete game state DEBFILE("send savegame\n"); } SV_AddWaitingPlayers(); @@ -4755,6 +4828,44 @@ static void HandleServerInfo(SINT8 node) } #endif + +static void PT_WillResendGamestate(void) +{ + char tmpsave[264]; + + if (server || cl_redownloadinggamestate) + return; + + // Send back a PT_CANRECEIVEGAMESTATE packet to the server + // so they know they can start sending the game state + netbuffer->packettype = PT_CANRECEIVEGAMESTATE; + if (!HSendPacket(servernode, true, 0, 0)) + return; + + CONS_Printf(M_GetText("Reloading game state...\n")); + + sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + + // Don't get a corrupt savegame error because tmpsave already exists + if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) + I_Error("Can't delete %s\n", tmpsave); + + CL_PrepareDownloadSaveGame(tmpsave); + + cl_redownloadinggamestate = true; +} + +static void PT_CanReceiveGamestate(SINT8 node) +{ + if (client || sendingsavegame[node]) + return; + + CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]); + + SV_SendSaveGame(node, true); // Resend a complete game state + resendingsavegame[node] = true; +} + /** Handles a packet received from a node that isn't in game * * \param node The packet sender @@ -5179,11 +5290,23 @@ static void HandlePacketFromPlayer(SINT8 node) --resynch_delay[node]; break; } + // Check player consistancy during the level - if (realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL - && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) + if ((realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL + && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (/*is_client_saturn[node] &&*/ realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL + && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) + && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime())) { - SV_RequireResynch(node); + //if (!is_client_saturn[node]) + SV_RequireResynch(node); + //else + { + // Tell the client we are about to resend them the gamestate + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + HSendPacket(node, true, 0, 0); + + resendingsavegame[node] = true; + } if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) { @@ -5515,6 +5638,17 @@ static void HandlePacketFromPlayer(SINT8 node) CONS_Printf("hi im on saturn\n"); is_client_saturn[node] = true; break; + case PT_CANRECEIVEGAMESTATE: + PT_CanReceiveGamestate(node); + break; + case PT_RECEIVEDGAMESTATE: + sendingsavegame[node] = false; + resendingsavegame[node] = false; + savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; + break; + case PT_WILLRESENDGAMESTATE: + PT_WillResendGamestate(); + break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", netbuffer->packettype, node)); @@ -6476,6 +6610,16 @@ void NetUpdate(void) if (!resynch_local_inprogress) CL_SendClientCmd(); // Send tic cmd hu_resynching = resynch_local_inprogress; + + if (cl_redownloadinggamestate) + { + // If the client just finished redownloading the game state, load it + if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) + CL_ReloadReceivedSavegame(); + + CL_SendClientCmd(); // Send tic cmd + } + hu_redownloadinggamestate = cl_redownloadinggamestate; } else { @@ -6484,6 +6628,7 @@ void NetUpdate(void) INT32 counts; hu_resynching = false; + hu_redownloadinggamestate = false; firstticstosend = gametic; for (i = 0; i < MAXNETNODES; i++) @@ -6585,7 +6730,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) return NULL; save_p = rewind->savebuffer; - P_SaveNetGame(); + P_SaveNetGame(true); rewind->leveltime = leveltime; rewind->next = rewindhead; rewind->demopos = demopos; @@ -6609,7 +6754,7 @@ rewind_t *CL_RewindToTime(tic_t time) return NULL; save_p = rewindhead->savebuffer; - P_LoadNetGame(); + P_LoadNetGame(true); wipegamestate = gamestate; // No fading back in! timeinmap = leveltime; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 6faf62d97..31a0967bc 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -99,6 +99,9 @@ typedef enum PT_PING, // Packet sent to tell clients the other client's latency to server. PT_ISSATURN, + PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! + PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. + PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again! NUMPACKETTYPE } packettype_t; @@ -633,6 +636,7 @@ tic_t GetLag(INT32 node); UINT8 GetFreeXCmdSize(void); extern UINT8 hu_resynching; +extern UINT8 hu_redownloadinggamestate; extern UINT8 hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player typedef struct rewind_s { diff --git a/src/d_main.c b/src/d_main.c index ac6785a53..fc4b75731 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1998,7 +1998,7 @@ void D_SRB2Main(void) pagename = "TITLESKY"; levelstarttic = gametic; G_SetGamestate(GS_LEVEL); - if (!P_SetupLevel(false)) + if (!P_SetupLevel(false, false)) I_Quit(); // fail so reset game stuff } diff --git a/src/d_net.c b/src/d_net.c index dd0b9d5e9..312e90caa 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -834,7 +834,11 @@ const char *packettypename[NUMPACKETTYPE] = "PING", - "ISSATURN" + "ISSATURN", + + "WILLRESENDGAMESTATE", + "CANRECEIVEGAMESTATE", + "RECEIVEDGAMESTATE" }; const char *Net_GetPacketName(UINT8 packettype) diff --git a/src/g_game.c b/src/g_game.c index 203b1aba5..4262c2a3a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1188,7 +1188,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. // Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions - if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching) + if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching || hu_redownloadinggamestate) { cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); @@ -1638,7 +1638,7 @@ void G_DoLoadLevel(boolean resetplayer) } // Setup the level. - if (!P_SetupLevel(false)) + if (!P_SetupLevel(false,false)) { // fail so reset game stuff Command_ExitGame_f(); @@ -1661,6 +1661,8 @@ void G_DoLoadLevel(boolean resetplayer) Z_CheckHeap(-2); #endif + memset(localaiming, 0, sizeof(localaiming)); + for (i = 0; i <= splitscreen; i++) { if (camera[i].chase) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index cd0f42a9c..27a44f6d7 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1253,7 +1253,7 @@ void HU_Ticker(void) if (cechotimer > 0) --cechotimer; // Animate the desynch dots - if (hu_resynching) + if (hu_resynching || hu_redownloadinggamestate) resynch_ticker++; //tic tic tic tic tic HU_TickSongCredits(); @@ -2418,7 +2418,7 @@ void HU_Drawer(void) HU_DrawSongCredits(); // draw desynch text - if (hu_resynching) + if (hu_resynching || hu_redownloadinggamestate) { char resynch_text[14]; UINT32 i; diff --git a/src/p_saveg.c b/src/p_saveg.c index ca41198ab..e1569bcbc 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -107,7 +107,7 @@ static inline void P_UnArchivePlayer(void) // // P_NetArchivePlayers // -static void P_NetArchivePlayers(void) +static void P_NetArchivePlayers(boolean resending) { INT32 i, j; UINT16 flags; @@ -117,6 +117,9 @@ static void P_NetArchivePlayers(void) for (i = 0; i < MAXPLAYERS; i++) { + if (resending) + WRITESINT8(save_p, (SINT8)adminplayers[i]); + if (!playeringame[i]) continue; @@ -124,6 +127,9 @@ static void P_NetArchivePlayers(void) // no longer send ticcmds, player name, skin, or color + if (resending) + WRITESTRINGN(save_p, player_names[i], MAXPLAYERNAME); + WRITEANGLE(save_p, players[i].aiming); WRITEANGLE(save_p, players[i].awayviewaiming); WRITEINT32(save_p, players[i].awayviewtics); @@ -148,6 +154,13 @@ static void P_NetArchivePlayers(void) WRITEUINT16(save_p, players[i].flashpal); WRITEUINT16(save_p, players[i].flashcount); + if (resending) + { + WRITEUINT8(save_p, players[i].skincolor); + WRITEINT32(save_p, players[i].skin); + } + + WRITEUINT32(save_p, players[i].score); WRITEFIXED(save_p, players[i].dashspeed); WRITEINT32(save_p, players[i].dashtime); @@ -285,7 +298,7 @@ static void P_NetArchivePlayers(void) // // P_NetUnArchivePlayers // -static void P_NetUnArchivePlayers(void) +static void P_NetUnArchivePlayers(boolean resending) { INT32 i, j; UINT16 flags; @@ -295,6 +308,8 @@ static void P_NetUnArchivePlayers(void) for (i = 0; i < MAXPLAYERS; i++) { + if (resending) + adminplayers[i] = (INT32)READSINT8(save_p); // Do NOT memset player struct to 0 // other areas may initialize data elsewhere //memset(&players[i], 0, sizeof (player_t)); @@ -305,6 +320,9 @@ static void P_NetUnArchivePlayers(void) // sending player names, skin and color should not be necessary at all! // (that data is handled in the server config now) + if (resending) + READSTRINGN(save_p, player_names[i], MAXPLAYERNAME); + players[i].aiming = READANGLE(save_p); players[i].awayviewaiming = READANGLE(save_p); players[i].awayviewtics = READINT32(save_p); @@ -329,6 +347,12 @@ static void P_NetUnArchivePlayers(void) players[i].flashpal = READUINT16(save_p); players[i].flashcount = READUINT16(save_p); + if (resending) + { + players[i].skincolor = READUINT8(save_p); + players[i].skin = READINT32(save_p); + } + players[i].score = READUINT32(save_p); players[i].dashspeed = READFIXED(save_p); // dashing speed players[i].dashtime = READINT32(save_p); // dashing speed @@ -3233,19 +3257,25 @@ static inline void P_UnArchiveSPGame(INT16 mapoverride) playeringame[consoleplayer] = true; } -static void P_NetArchiveMisc(void) +static void P_NetArchiveMisc(boolean resending) { UINT32 pig = 0; INT32 i; WRITEUINT32(save_p, ARCHIVEBLOCK_MISC); + if (resending) + WRITEUINT32(save_p, gametic); + WRITEINT16(save_p, gamemap); if (gamestate != GS_LEVEL) WRITEINT16(save_p, GS_WAITINGPLAYERS); // nice hack to put people back into waitingplayers else WRITEINT16(save_p, gamestate); + if (resending) + WRITEINT16(save_p, gametype); + for (i = 0; i < MAXPLAYERS; i++) pig |= (playeringame[i] != 0)<data); P_LoadThings(); @@ -2593,7 +2596,7 @@ static boolean P_CanSave(void) * \param skipprecip If true, don't spawn precipitation. * \todo Clean up, refactor, split up; get rid of the bloat. */ -boolean P_SetupLevel(boolean skipprecip) +boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) { // use gamemap to get map number. // 99% of the things already did, so. @@ -2631,7 +2634,7 @@ boolean P_SetupLevel(boolean skipprecip) if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#') P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname); - P_LevelInitStuff(); + P_LevelInitStuff(reloadinggamestate); for (i = 0; i <= splitscreen; i++) postimgtype[i] = postimg_none; @@ -2664,9 +2667,12 @@ boolean P_SetupLevel(boolean skipprecip) // will be set by player think. players[consoleplayer].viewz = 1; + // Cancel all d_main.c fadeouts (keep fade in though). + if (reloadinggamestate) + wipegamestate = gamestate; // Don't fade if reloading the gamestate // Encore mode fade to pink to white // This is handled BEFORE sounds are stopped. - if (encoremode && !prevencoremode && !demo.rewinding) + else if (encoremode && !prevencoremode && !demo.rewinding) { tic_t locstarttime, endtime, nowtime; @@ -2725,13 +2731,14 @@ boolean P_SetupLevel(boolean skipprecip) // As oddly named as this is, this handles music only. // We should be fine starting it here. - S_Start(); + if (!reloadinggamestate) + S_Start(); levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120); // Let's fade to white here // But only if we didn't do the encore startup wipe - if (!ranspecialwipe && !demo.rewinding) + if (!ranspecialwipe && !demo.rewinding && !reloadinggamestate) { if(rendermode != render_none) { @@ -3020,7 +3027,7 @@ boolean P_SetupLevel(boolean skipprecip) P_MapEnd(); // Remove the loading shit from the screen - if (rendermode != render_none) + if (rendermode != render_none && (!reloadinggamestate)) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); if (precache || dedicated) diff --git a/src/p_setup.h b/src/p_setup.h index 5df0f0b68..057ea505f 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -63,7 +63,7 @@ void P_SetupLevelSky(INT32 skynum, boolean global); void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); #endif void P_LoadThingsOnly(void); -boolean P_SetupLevel(boolean skipprecip); +boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate); #ifdef HWRENDER void HWR_LoadLevel(void); #endif -- 2.54.0 From 13aadc41ffa4c872abe4c5376979562806403b5c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 16:22:51 +0200 Subject: [PATCH 190/525] should reset those here perhaps --- src/d_clisrv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c67ef524b..f4798aa90 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5644,6 +5644,8 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_RECEIVEDGAMESTATE: sendingsavegame[node] = false; resendingsavegame[node] = false; + resynch_inprogress[node] = false; + resynch_local_inprogress = false; savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; break; case PT_WILLRESENDGAMESTATE: -- 2.54.0 From 930bde785c5ab1d03ca27350592e7299c348f566 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 16:24:36 +0200 Subject: [PATCH 191/525] just reset everything resynchwise here --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f4798aa90..1bad4a0b3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5646,6 +5646,7 @@ static void HandlePacketFromPlayer(SINT8 node) resendingsavegame[node] = false; resynch_inprogress[node] = false; resynch_local_inprogress = false; + SV_InitResynchVars(node); savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; break; case PT_WILLRESENDGAMESTATE: -- 2.54.0 From 56fcca1f6b893a4087fa6c5bbe4a8f113081f6e9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 18:15:42 +0200 Subject: [PATCH 192/525] mark if node can receive savegame so it doesent run resynch code on em should prevent some issues for when a client received gamestate but thinks it needs to be resynched getting stuck --- src/d_clisrv.c | 33 ++++++++++++++++++++------------- src/d_clisrv.h | 2 ++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1bad4a0b3..55eae8c74 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -127,6 +127,8 @@ static UINT8 player_joining = false; UINT8 hu_resynching = 0; UINT8 hu_redownloadinggamestate = 0; +static boolean can_receive_gamestate[MAXNETNODES]; + // kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks UINT8 hu_stopped = 0; @@ -1711,7 +1713,7 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - if (!resendingsavegame[node]) + if (!can_receive_gamestate[node]) { // we fill these structs with FFs so that any players not in game get sent as 0xFFFF // which is nice and easy for us to detect @@ -1738,7 +1740,7 @@ static boolean SV_SendServerConfig(INT32 node) memcpy(netbuffer->u.servercfg.server_context, server_context, 8); - if (!resendingsavegame[node]) + if (!can_receive_gamestate[node]) { op = p = netbuffer->u.servercfg.varlengthinputs; @@ -1748,7 +1750,7 @@ static boolean SV_SendServerConfig(INT32 node) { size_t len; - if (resendingsavegame[node]) + if (can_receive_gamestate[node]) len = sizeof (serverconfig_pak); else len = sizeof (serverconfig_pak) + (size_t)(p - op); @@ -3213,6 +3215,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) nodeingame[node] = false; is_client_saturn[node] = false; + can_receive_gamestate[node] = false; Net_CloseConnection(node); ResetNode(node); } @@ -4170,6 +4173,7 @@ static void ResetNode(INT32 node) playerpernode[node] = 0; sendingsavegame[node] = false; resendingsavegame[node] = false; + can_receive_gamestate[node] = false; savegameresendcooldown[node] = 0; bannednode[node].banid = SIZE_MAX; bannednode[node].timeleft = NO_BAN_TIME; @@ -5297,16 +5301,20 @@ static void HandlePacketFromPlayer(SINT8 node) && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime())) { - //if (!is_client_saturn[node]) - SV_RequireResynch(node); - //else - { - // Tell the client we are about to resend them the gamestate - netbuffer->packettype = PT_WILLRESENDGAMESTATE; - HSendPacket(node, true, 0, 0); + // we need to send this so the client can tell us if it can receive the savegame + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + HSendPacket(node, true, 0, 0); + if (can_receive_gamestate[node]) + { resendingsavegame[node] = true; } + else + { + CONS_Printf("resynch"); + SV_RequireResynch(node); + resendingsavegame[node] = false; + } if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) { @@ -5471,6 +5479,7 @@ static void HandlePacketFromPlayer(SINT8 node) Net_CloseConnection(node); nodeingame[node] = false; is_client_saturn[node] = false; + can_receive_gamestate[node] = false; break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_RESYNCHEND: @@ -5639,14 +5648,12 @@ static void HandlePacketFromPlayer(SINT8 node) is_client_saturn[node] = true; break; case PT_CANRECEIVEGAMESTATE: + can_receive_gamestate[node] = true; PT_CanReceiveGamestate(node); break; case PT_RECEIVEDGAMESTATE: sendingsavegame[node] = false; resendingsavegame[node] = false; - resynch_inprogress[node] = false; - resynch_local_inprogress = false; - SV_InitResynchVars(node); savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; break; case PT_WILLRESENDGAMESTATE: diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 31a0967bc..b1afac2e0 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -98,10 +98,12 @@ typedef enum PT_MOREFILESNEEDED, // Server, to client: "you need these (+ more on top of those)" PT_PING, // Packet sent to tell clients the other client's latency to server. + PT_ISSATURN, PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again! + NUMPACKETTYPE } packettype_t; -- 2.54.0 From 550871f576fef13718234e375f4a0036dc0c3e97 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 18:21:19 +0200 Subject: [PATCH 193/525] smol cleanup --- src/d_clisrv.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 55eae8c74..747ae33b7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4195,8 +4195,8 @@ void SV_ResetServer(void) { ResetNode(i); - //if (!(resendingsavegame[i] && is_client_saturn[i]))// Make sure resynch status doesn't get carried over! - SV_InitResynchVars(i); + // Make sure resynch status doesn't get carried over! + SV_InitResynchVars(i); } for (i = 0; i < MAXPLAYERS; i++) @@ -4736,8 +4736,7 @@ static void HandleConnect(SINT8 node) /// What if the gamestate takes more than one second to get downloaded? /// Or if a lagspike happdsfens? // you get a free second before desynch checks. use it wisely. - //if (!(resendingsavegame[node] && is_client_saturn[node])) - SV_InitResynchVars(node); + SV_InitResynchVars(node); #ifdef VANILLAJOINNEXTROUND if (cv_joinnextround.value && gameaction == ga_nothing) @@ -5296,8 +5295,8 @@ static void HandlePacketFromPlayer(SINT8 node) } // Check player consistancy during the level - if ((realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL - && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (/*is_client_saturn[node] &&*/ realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL + if ((!can_receive_gamestate[node] && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL + && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime())) { -- 2.54.0 From 01c1ae42a140141766f272695973992e5219ff2d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 18:30:10 +0200 Subject: [PATCH 194/525] fix saturn packet going the wrong way --- src/d_clisrv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 747ae33b7..a6e9f3c2b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4759,7 +4759,6 @@ static void HandleConnect(SINT8 node) #ifdef JOININGAME if (nodewaiting[node]) { - SendSaturnInfo(node); if (node && newnode) { SV_SendSaveGame(node, false); // send a complete game state @@ -5057,6 +5056,8 @@ static void HandlePacketFromAwayNode(SINT8 node) #endif DEBFILE(va("Server accept join gametic=%u mynode=%d\n", gametic, mynode)); + SendSaturnInfo(node); + memset(playeringame, 0, sizeof(playeringame)); for (j = 0; j < MAXPLAYERS; j++) { @@ -5643,7 +5644,7 @@ static void HandlePacketFromPlayer(SINT8 node) Got_Filetxpak(); break; case PT_ISSATURN: - CONS_Printf("hi im on saturn\n"); + //CONS_Printf("hi im on saturn\n"); is_client_saturn[node] = true; break; case PT_CANRECEIVEGAMESTATE: -- 2.54.0 From e1d4f102234b04710f88eb1929c5562fb6da22a5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 11:49:21 +0200 Subject: [PATCH 195/525] add "gamestatecooldown" cvar to be able to change the cooldown between gamestate resends --- src/d_clisrv.c | 8 ++++---- src/d_clisrv.h | 2 +- src/d_netcmd.c | 1 + src/m_menu.c | 20 +++++++++++--------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a6e9f3c2b..1f14f4103 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4067,6 +4067,9 @@ consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, di static CV_PossibleValue_t resynchattempts_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchattempts = {"resynchattempts", "2", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; + +static CV_PossibleValue_t resynchcooldown_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; +consvar_t cv_resynchcooldown = {"gamestatecooldown", "5", CV_SAVE, resynchcooldown_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; consvar_t cv_blamecfail = {"blamecfail", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL }; // max file size to send to a player (in kilobytes) @@ -5306,12 +5309,9 @@ static void HandlePacketFromPlayer(SINT8 node) HSendPacket(node, true, 0, 0); if (can_receive_gamestate[node]) - { resendingsavegame[node] = true; - } else { - CONS_Printf("resynch"); SV_RequireResynch(node); resendingsavegame[node] = false; } @@ -5654,7 +5654,7 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_RECEIVEDGAMESTATE: sendingsavegame[node] = false; resendingsavegame[node] = false; - savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; + savegameresendcooldown[node] = I_GetTime() + cv_resynchcooldown.value * TICRATE; // I_GetTime() + 5 * TICRATE; break; case PT_WILLRESENDGAMESTATE: PT_WillResendGamestate(); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index b1afac2e0..19f5dae1e 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -573,7 +573,7 @@ extern consvar_t #ifdef VANILLAJOINNEXTROUND cv_joinnextround, #endif - cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; extern consvar_t cv_connectawaittime; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3cf64d065..4584ff3da 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -779,6 +779,7 @@ void D_RegisterServerCommands(void) // d_clisrv CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); + CV_RegisterVar(&cv_resynchcooldown); CV_RegisterVar(&cv_maxsend); CV_RegisterVar(&cv_noticedownload); CV_RegisterVar(&cv_downloadspeed); diff --git a/src/m_menu.c b/src/m_menu.c index 8f884d05c..674c33d3b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1912,17 +1912,18 @@ static menuitem_t OP_AdvServerOptionsMenu[] = NULL, "Server Browser Address", &cv_masterserver, 10}, #endif {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, - {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 50}, - {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 60}, - {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 70}, - {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 80}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, + {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 60}, + {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 70}, + {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 80}, + {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 90}, - {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 100}, - {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 110}, + {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 110}, + {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 120}, - {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 130}, - {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 140}, - {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 150}, + {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 140}, + {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 150}, + {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 160}, }; #endif @@ -1931,6 +1932,7 @@ static const char* OP_AdvServerOptionsTooltips[] = { "Server used for master server.", "Attempts to resynchronise player to server.", + "Cooldown in seconds before the Server attempts\nto resend the gamestate to a Saturn Client\nbetween resending attempts.", "Maximum allowed delay.", "Delay timeout in seconds.", "Connection timeout in tics.", -- 2.54.0 From 86950c26d0494650e0c38221d01d15e71b50ffaf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 11:49:48 +0200 Subject: [PATCH 196/525] add check here too --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1f14f4103..08f9f3a82 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5299,8 +5299,8 @@ static void HandlePacketFromPlayer(SINT8 node) } // Check player consistancy during the level - if ((!can_receive_gamestate[node] && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL - && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL + if (((!can_receive_gamestate[node]) && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL + && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (can_receive_gamestate[node] && realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime())) { -- 2.54.0 From db6f76d12da7fd54e0595f5ebe2a38ff05a83854 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:24:01 +0200 Subject: [PATCH 197/525] more reference fixes --- src/lua_blockmaplib.c | 4 +++- src/p_map.c | 18 ++++++++++-------- src/p_mobj.c | 27 ++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 0b93766b8..2367673cd 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -53,10 +53,12 @@ static UINT8 lib_searchBlockmap_Objects(lua_State *L, INT32 x, INT32 y, mobj_t * CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); blockfuncerror = true; + P_SetTarget(&bnext, NULL); return 0; // *shrugs* } if (!lua_isnil(gL, -1)) { // if nil, continue + P_SetTarget(&bnext, NULL); if (lua_toboolean(gL, -1)) return 2; // stop whole search else @@ -256,4 +258,4 @@ int LUA_BlockmapLib(lua_State *L) { lua_register(L, "searchBlockmap", lib_searchBlockmap); return 0; -} \ No newline at end of file +} diff --git a/src/p_map.c b/src/p_map.c index 6051d5d1c..bcb2b6a73 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1548,13 +1548,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmceilingslope = NULL; - tmfloorthing = thing; // needed for side collision + P_SetTarget(&tmfloorthing, thing); // needed for side collision } else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; tmceilingslope = NULL; - tmfloorthing = thing; // thing we may stand on + P_SetTarget(&tmfloorthing, thing); // thing we may stand on } } else @@ -1585,13 +1585,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmfloorslope = NULL; - tmfloorthing = thing; // needed for side collision + P_SetTarget(&tmfloorthing, thing); // needed for side collision } else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; tmfloorslope = NULL; - tmfloorthing = thing; // thing we may stand on + P_SetTarget(&tmfloorthing, thing); // thing we may stand on } } } @@ -1991,8 +1991,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } // tmfloorthing is set when tmfloorz comes from a thing's top - tmfloorthing = NULL; - tmhitthing = NULL; + P_SetTarget(&tmfloorthing, NULL); + P_SetTarget(&tmhitthing, NULL); validcount++; @@ -2489,8 +2489,10 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (tmceilingz - tmfloorz < thing->height) { - if (tmfloorthing) - tmhitthing = tmfloorthing; + if (tmfloorthing != NULL) + { + P_SetTarget(&tmhitthing, tmfloorthing); + } return false; // doesn't fit } diff --git a/src/p_mobj.c b/src/p_mobj.c index 0423b00f3..b25a30065 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6073,7 +6073,8 @@ void P_MobjThinker(mobj_t *mobj) mobj->flags2 &= ~MF2_PUSHED; mobj->eflags &= ~(MFE_SPRUNG|MFE_JUSTBOUNCEDWALL); - tmfloorthing = tmhitthing = NULL; + P_SetTarget(&tmfloorthing, NULL); + P_SetTarget(&tmhitthing, NULL); // 970 allows ANY mobj to trigger a linedef exec if (mobj->subsector && GETSECSPECIAL(mobj->subsector->sector->special, 2) == 8) @@ -10030,13 +10031,29 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); P_SetTarget(&mobj->tracer, NULL); + // repair hnext chain + mobj_t *cachenext = mobj->hnext; + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + { + if (mobj->hnext->hprev == mobj) + { + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + } + + P_SetTarget(&mobj->hnext, NULL); + } + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) - P_SetTarget(&mobj->hprev->hnext, mobj->hnext); - - P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); + { + if (mobj->hprev->hnext == mobj) + { + P_SetTarget(&mobj->hprev->hnext, cachenext); + } + P_SetTarget(&mobj->hprev, NULL); + } + // clear the reference from the mapthing if (mobj->spawnpoint) P_SetTarget(&mobj->spawnpoint->mobj, NULL); -- 2.54.0 From 147c59c26bbe1bd7813890fdc90a273250185979 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:07:23 +0200 Subject: [PATCH 198/525] smol cleanup also check for splitscreen and if not dont run a for loop lul --- src/p_tick.c | 262 ++------------------------------------------------- src/p_tick.h | 1 + 2 files changed, 10 insertions(+), 253 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 3bbc219ca..deb84a516 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -324,265 +324,25 @@ static inline void P_RunThinkers(void) } } -// -// P_DoAutobalanceTeams() -// -// Determine if the teams are unbalanced, and if so, move a player to the other team. -// -/*static void P_DoAutobalanceTeams(void) +void P_RunChaseCameras(void) { - changeteam_union NetPacket; - UINT16 usvalue; - INT32 i=0; - INT32 red=0, blue=0; - INT32 redarray[MAXPLAYERS], bluearray[MAXPLAYERS]; - INT32 redflagcarrier = 0, blueflagcarrier = 0; - INT32 totalred = 0, totalblue = 0; + UINT8 i; - NetPacket.value.l = NetPacket.value.b = 0; - memset(redarray, 0, sizeof(redarray)); - memset(bluearray, 0, sizeof(bluearray)); - - // Only do it if we have enough room in the net buffer to send it. - // Otherwise, come back next time and try again. - if (sizeof(usvalue) > GetFreeXCmdSize()) - return; - - //We have to store the players in an array with the rest of their team. - //We can then pick a random player to be forced to change teams. - for (i = 0; i < MAXPLAYERS; i++) + if (!splitscreen) { - if (playeringame[i] && players[i].ctfteam) - { - if (players[i].ctfteam == 1) - { - if (!players[i].gotflag) - { - redarray[red] = i; //store the player's node. - red++; - } - else - redflagcarrier++; - } - else - { - if (!players[i].gotflag) - { - bluearray[blue] = i; //store the player's node. - blue++; - } - else - blueflagcarrier++; - } - } - } - - totalred = red + redflagcarrier; - totalblue = blue + blueflagcarrier; - - if ((abs(totalred - totalblue) > cv_autobalance.value)) - { - if (totalred > totalblue) - { - i = M_RandomKey(red); - NetPacket.packet.newteam = 2; - NetPacket.packet.playernum = redarray[i]; - NetPacket.packet.verification = true; - NetPacket.packet.autobalance = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - - if (totalblue > totalred) - { - i = M_RandomKey(blue); - NetPacket.packet.newteam = 1; - NetPacket.packet.playernum = bluearray[i]; - NetPacket.packet.verification = true; - NetPacket.packet.autobalance = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - } -} - -// -// P_DoTeamscrambling() -// -// If a team scramble has been started, scramble one person from the -// pre-made scramble array. Said array is created in TeamScramble_OnChange() -// -void P_DoTeamscrambling(void) -{ - changeteam_union NetPacket; - UINT16 usvalue; - NetPacket.value.l = NetPacket.value.b = 0; - - // Only do it if we have enough room in the net buffer to send it. - // Otherwise, come back next time and try again. - if (sizeof(usvalue) > GetFreeXCmdSize()) - return; - - if (scramblecount < scrambletotal) - { - if (players[scrambleplayers[scramblecount]].ctfteam != scrambleteams[scramblecount]) - { - NetPacket.packet.newteam = scrambleteams[scramblecount]; - NetPacket.packet.playernum = scrambleplayers[scramblecount]; - NetPacket.packet.verification = true; - NetPacket.packet.scrambled = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - - scramblecount++; //Increment, and get to the next player when we come back here next time. + if (camera[consoleplayer].chase) + P_MoveChaseCamera(&players[consoleplayer], &camera[consoleplayer], false); } else - CV_SetValue(&cv_teamscramble, 0); -} - -static inline void P_DoSpecialStageStuff(void) -{ - boolean inwater = false; - INT32 i; - - // Can't drown in a special stage - for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) - continue; - - players[i].powers[pw_underwater] = players[i].powers[pw_spacetime] = 0; - } - - if (sstimer < 15*TICRATE+6 && sstimer > 7 && (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC)) - S_SpeedMusic(1.4f); - - if (sstimer < 7 && sstimer > 0) // The special stage time is up! - { - sstimer = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i <= splitscreen; i++) { - if (playeringame[i]) - { - players[i].exiting = raceexittime+1; - players[i].pflags &= ~PF_GLIDING; - } - - if (i == consoleplayer) - S_StartSound(NULL, sfx_lose); - } - - if (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC) - S_SpeedMusic(1.0f); - - stagefailed = true; - } - - if (sstimer > 1) // As long as time isn't up... - { - UINT32 ssrings = 0; - // Count up the rings of all the players and see if - // they've collected the required amount. - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - ssrings += (players[i].mo->health-1); - - // If in water, deplete timer 6x as fast. - if ((players[i].mo->eflags & MFE_TOUCHWATER) - || (players[i].mo->eflags & MFE_UNDERWATER)) - inwater = true; - } - - if (ssrings >= totalrings && totalrings > 0) - { - // Halt all the players - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - players[i].mo->momx = players[i].mo->momy = 0; - players[i].exiting = raceexittime+1; - } - - sstimer = 0; - - P_GiveEmerald(true); - } - - // Decrement the timer - if (!objectplacing) - { - if (inwater) - sstimer -= 6; - else - sstimer--; + if (camera[i].chase) + P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); } } } -static inline void P_DoTagStuff(void) -{ - INT32 i; - - // tell the netgame who the initial IT person is. - if (leveltime == TICRATE) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (players[i].pflags & PF_TAGIT) - { - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[i]); // Tell everyone who is it! - break; - } - } - } - - //increment survivor scores - if (leveltime % TICRATE == 0 && leveltime > (hidetime * TICRATE)) - { - INT32 participants = 0; - - for (i=0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator) - participants++; - } - - for (i=0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator && players[i].playerstate == PST_LIVE - && !(players[i].pflags & (PF_TAGIT|PF_TAGGED))) - //points given is the number of participating players divided by two. - P_AddPlayerScore(&players[i], participants/2); - } - } -} - -static inline void P_DoCTFStuff(void) -{ - // Automatic team balance for CTF and team match - if (leveltime % (TICRATE * 5) == 0) //only check once per five seconds for the sake of CPU conservation. - { - // Do not attempt to autobalance and scramble teams at the same time. - // Only the server should execute this. No verified admins, please. - if ((cv_autobalance.value && !cv_teamscramble.value) && cv_allowteamchange.value && server) - P_DoAutobalanceTeams(); - } - - // Team scramble code for team match and CTF. - if ((leveltime % (TICRATE/7)) == 0) - { - // If we run out of time in the level, the beauty is that - // the Y_Ticker() team scramble code will pick it up. - if (cv_teamscramble.value && server) - P_DoTeamscrambling(); - } -}*/ - // // P_Ticker // @@ -830,11 +590,7 @@ void P_Ticker(boolean run) } // Always move the camera. - for (i = 0; i <= splitscreen; i++) - { - if (camera[i].chase) - P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); - } + P_RunChaseCameras(); if (run) { diff --git a/src/p_tick.h b/src/p_tick.h index 2cbbb8104..11b5889ed 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -24,6 +24,7 @@ extern tic_t leveltime; void Command_Numthinkers_f(void); void Command_CountMobjs_f(void); +void P_RunChaseCameras(void); void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); -- 2.54.0 From 3e6cab1ec9a534fafde8e43d29c1d9a3458226ee Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:22:10 +0200 Subject: [PATCH 199/525] fix this oops --- src/p_tick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index deb84a516..af187bbea 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -330,8 +330,8 @@ void P_RunChaseCameras(void) if (!splitscreen) { - if (camera[consoleplayer].chase) - P_MoveChaseCamera(&players[consoleplayer], &camera[consoleplayer], false); + if (camera[0].chase) + P_MoveChaseCamera(&players[displayplayers[0]], &camera[0], false); } else { -- 2.54.0 From 6b4d02ae9986f4284c54321dda03b17e22409cb9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:07:39 +0200 Subject: [PATCH 200/525] stop yelling clang --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index fc4b75731..ff05e1a64 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -727,7 +727,7 @@ void D_SRB2Loop(void) if (lastdraw || singletics || gametic > rendergametic) { rendergametic = gametic; - rendertimeout = entertic + TICRATE/(TICRATE/2); + rendertimeout = entertic + TICRATE/17.5; doDisplay = true; } -- 2.54.0 From a771ebf0e832d0af43ad5e1a591c3637be53c9d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:21:01 +0200 Subject: [PATCH 201/525] cleanup r_things a little --- src/r_things.c | 55 +++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index a769960ea..068358802 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -38,12 +38,6 @@ #include "qs22j.h" -#ifdef PC_DOS -#include // for snprintf -int snprintf(char *str, size_t n, const char *fmt, ...); -//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap); -#endif - CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; static void R_InitSkins(void); @@ -532,15 +526,6 @@ void R_InitSprites(void) R_AddSkins((UINT16)i, false); R_LoadSpriteInfoLumps(i, wadfiles[i]->numlumps); } - - // - // check if all sprites have frames - // - /* - for (i = 0; i < numsprites; i++) - if (sprites[i].numframes < 1) - CONS_Debug(DBG_SETUP, "R_InitSprites: sprite %s has no frames at all\n", sprnames[i]); - */ } // @@ -1034,13 +1019,6 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) newsprite->extra_colormap = sector->lightlist[i].extra_colormap; -/* - if (thing->frame & FF_TRANSMASK) - ; - else if (thing->flags2 & MF2_SHADOW) - ; - else -*/ if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { @@ -1068,6 +1046,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) msecnode_t *node; sector_t *sector; ffloor_t *rover; + #define CHECKZ (isflipped ? z > thing->z+thing->height/2 && z < groundz : z < thing->z+thing->height/2 && z > groundz) for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next) @@ -1347,7 +1326,7 @@ static void R_ProjectSprite(mobj_t *thing) rollangle = thing->rollangle; } - if ((rollangle) || (pitchnroll) || (thing->player && thing->player->sliproll)) + if (rollangle || pitchnroll || (thing->player && thing->player->sliproll)) { rollsum = pitchnroll; @@ -1585,7 +1564,8 @@ static void R_ProjectSprite(mobj_t *thing) for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y) : thing->subsector->sector->lightlist[lightnum].height; - if (h <= gzt) { + if (h <= gzt) + { light = lightnum - 1; break; } @@ -3171,12 +3151,15 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) } } - if (cvar != NULL) { - if (player->localskin > 0) { + if (cvar != NULL) + { + if (player->localskin > 0) + { CV_StealthSet(&cv_fakelocalskin, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); CV_StealthSet(cvar, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); } - else { + else + { CV_StealthSet(&cv_fakelocalskin, "none"); CV_StealthSet(cvar, "none"); } @@ -3634,8 +3617,8 @@ next_token: CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); #ifdef SKINVALUES - ( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].value = ( (local) ? numlocalskins : numskins ); - ( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].strvalue = skin->name; + (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].value = (local ? numlocalskins : numskins); + (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].strvalue = skin->name; #endif // Update the forceskin possiblevalues @@ -3646,6 +3629,7 @@ next_token: } skin->localskin = local; + // so we dont have to guess if (local) skin->localnum = numlocalskins; @@ -3653,28 +3637,27 @@ next_token: skin->localnum = numskins; // add face graphics - if (local) { + if (local) ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins); - } else { + else ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins); - } #ifdef HWRENDER if (rendermode == render_opengl) - HWR_AddPlayerMD2(( (local) ? numlocalskins : numskins ), local); + HWR_AddPlayerMD2(((local) ? numlocalskins : numskins), local); #endif - if (!local) { + if (!local) + { skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins; CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight); skinstatscount[skin->kartspeed-1][skin->kartweight-1]++; CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]); - skinsorted[numskins] = numskins; } allskins[numallskins] = ( (local) ? localskins : skins )[( (local) ? numlocalskins : numskins )]; - ( (local) ? numlocalskins++ : numskins++ ); + local ? numlocalskins++ : numskins++; numallskins++; } -- 2.54.0 From f7bf3fe5105227d434a8a3dc326086bb038c55cc Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:23:21 +0200 Subject: [PATCH 202/525] cleanup hw_main --- src/hardware/hw_main.c | 266 ++++++++++++++++++++--------------------- 1 file changed, 127 insertions(+), 139 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index cf95fdbcb..c4449f512 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -490,6 +490,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GL_DEFAULTMIX; fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG; + // Clamp the light level, since it can sometimes go out of the 0-255 range from animations + light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); + // Crappy backup coloring if you can't do shaders if (!HWR_UseShader()) { @@ -527,9 +530,6 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } - // Clamp the light level, since it can sometimes go out of the 0-255 range from animations - light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); - // in palette rendering mode, this is not needed since it properly takes the changes to the palette itself if (!HWR_ShouldUsePaletteRendering()) { @@ -562,9 +562,8 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if } else { - light = light - (255 - light); // Don't go out of bounds - light = CLAMP(light, 0, 255); + light = CLAMP(light - (255 - light), 0, 255); alpha = (realcolor.s.alpha*255)/25; @@ -848,11 +847,11 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc if (HWR_UseShader()) { if (PolyFlags & PF_Fog) - shader = SHADER_FOG; // fog shader + shader = SHADER_FOG; else if (PolyFlags & PF_Ripple) - shader = SHADER_WATER; // water shader + shader = SHADER_WATER; else - shader = SHADER_FLOOR; // floor shader + shader = SHADER_FLOOR; PolyFlags |= PF_ColorMapped; } @@ -1012,7 +1011,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) } if (HWR_UseShader()) - shader = SHADER_WALL; // wall shader + shader = SHADER_WALL; HWR_ProcessPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal, shader, false); } @@ -1677,51 +1676,49 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // check BOTTOM TEXTURE if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! { + fixed_t texturevpegbottom = 0; // bottom + + grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); + + // PEGGING + if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) + texturevpegbottom = 0; + else if (gr_linedef->flags & ML_EFFECT1) + texturevpegbottom = worldbottom - worldlow; + else + texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; + + texturevpegbottom += gr_sidedef->rowoffset; + + // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway + texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // Adjust t value for sloped walls + if (!(gr_linedef->flags & ML_EFFECT1)) { - fixed_t texturevpegbottom = 0; // bottom - - grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); - - // PEGGING - if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) - texturevpegbottom = 0; - else if (gr_linedef->flags & ML_EFFECT1) - texturevpegbottom = worldbottom - worldlow; - else - texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; - - texturevpegbottom += gr_sidedef->rowoffset; - - // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // Adjust t value for sloped walls - if (!(gr_linedef->flags & ML_EFFECT1)) - { - // Unskewed - wallVerts[0].t -= (worldbottom - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[1].t -= (worldbottomslope - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[3].t -= (worldlow - gr_backsector->floorheight) * grTex->scaleY; - wallVerts[2].t -= (worldlowslope - gr_backsector->floorheight) * grTex->scaleY; - } - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) - { - // Skewed by bottom - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this - wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; - } - else - { - // Skewed by top - wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; - } + // Unskewed + wallVerts[0].t -= (worldbottom - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[1].t -= (worldbottomslope - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[3].t -= (worldlow - gr_backsector->floorheight) * grTex->scaleY; + wallVerts[2].t -= (worldlowslope - gr_backsector->floorheight) * grTex->scaleY; + } + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + { + // Skewed by bottom + wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; + //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this + wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; + } + else + { + // Skewed by top + wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; + wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; } // set top/bottom coords @@ -1900,12 +1897,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode |= PF_Decal; if (!gl_drawing_stencil && gr_frontsector->numlights) - { - if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); - else - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, PF_Decal); - } + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, PF_Decal); else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); else @@ -1915,41 +1907,44 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // Single sided line... Deal only with the middletexture (if one exists) - if (gr_midtexture && gr_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL { + fixed_t texturevpeg; + + // PEGGING + if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) + texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; + else + texturevpeg = gr_sidedef->rowoffset; // top of texture at top + + grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + + wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // Texture correction for slopes + if (gr_linedef->flags & ML_EFFECT2) { - fixed_t texturevpeg; - // PEGGING - if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) - texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) - texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; - else - // top of texture at top - texturevpeg = gr_sidedef->rowoffset; - - grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); - - wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // Texture correction for slopes - if (gr_linedef->flags & ML_EFFECT2) { - wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; - wallVerts[2].t += (gr_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; - wallVerts[0].t += (gr_frontsector->floorheight - worldbottom) * grTex->scaleY; - wallVerts[1].t += (gr_frontsector->floorheight - worldbottomslope) * grTex->scaleY; - } else if (gr_linedef->flags & ML_DONTPEGBOTTOM) { - wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; - wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; - } else { - wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; - wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; - } + wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; + wallVerts[2].t += (gr_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; + wallVerts[0].t += (gr_frontsector->floorheight - worldbottom) * grTex->scaleY; + wallVerts[1].t += (gr_frontsector->floorheight - worldbottomslope) * grTex->scaleY; } + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + { + wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; + wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; + } + else + { + wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; + wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; + } + //Set textures properly on single sided walls that are sloped wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); @@ -1958,8 +1953,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); - // I don't think that solid walls can use translucent linedef types... - else + else // I don't think that solid walls can use translucent linedef types... { if (grTex->mipmap.flags & TF_TRANSPARENT) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); @@ -2150,7 +2144,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); + Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gr_frontsector->numlights) @@ -2264,7 +2258,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); + Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gr_backsector->numlights) @@ -2280,7 +2274,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } } - #undef SLOPEPARAMS //Hurdler: end of 3d-floors test } @@ -2420,8 +2413,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) // Window. // We know it's a window when the above isn't true and the back and front sectors don't match - if (backc1 != frontc1 || backc2 != frontc2 - || backf1 != frontf1 || backf2 != frontf2) + if (backc1 != frontc1 || backc2 != frontc2 || backf1 != frontf1 || backf2 != frontf2) { checkforemptylines = false; return false; @@ -2554,6 +2546,7 @@ doaddline: gld_clipper_SafeAddClipRange(angle2, angle1); checkforemptylines = false; } + // Reject empty lines used for triggers and special events. // Identical floor and ceiling on both sides, // identical light levels on both sides, @@ -2862,11 +2855,11 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t if (HWR_UseShader()) { - shader = SHADER_FLOOR; // floor shader + shader = SHADER_FLOOR; blendmode |= PF_ColorMapped; } - HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); // floor shader + HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); } void HWR_AddPolyObjectPlanes(void) @@ -3022,7 +3015,6 @@ static void HWR_Subsector(size_t num) //SoM: 4/7/2000: Test to make Boom water work in Hardware mode. gr_frontsector = R_FakeFlat(gr_frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); - //FIXME: Use floorlightlevel and ceilinglightlevel insted of lightlevel. if (gr_portal == GRPORTAL_SEARCH) { @@ -3166,7 +3158,7 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gr_frontsector->lightlist[light].lightlevel, - max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3210,7 +3202,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, - max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3865,7 +3857,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) continue; if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; + lightlevel = *list[i-1].lightlevel; colormap = list[i-1].extra_colormap; break; } @@ -3879,7 +3871,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; + lightlevel = *list[i].lightlevel; colormap = list[i].extra_colormap; } @@ -4092,16 +4084,14 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) /// \todo coloured // colormap test - { - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + sector_t *sector = spr->mobj->subsector->sector; + UINT8 lightlevel = 255; + extracolormap_t *colormap = sector->extra_colormap; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = sector->lightlevel; - HWR_Lighting(&Surf, lightlevel, colormap); - } + HWR_Lighting(&Surf, lightlevel, colormap); { FBITFIELD blend = 0; @@ -4129,7 +4119,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) if (HWR_UseShader()) { - shader = SHADER_SPRITE; // sprite shader + shader = SHADER_SPRITE; blend |= PF_ColorMapped; } @@ -4187,34 +4177,32 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) HWR_GetMappedPatch(gpatch, spr->colormap); // colormap test + sector_t *sector = spr->mobj->subsector->sector; + UINT8 lightlevel = 255; + extracolormap_t *colormap = sector->extra_colormap; + + if (sector->numlights) { - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + INT32 light; - if (sector->numlights) - { - INT32 light; + light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before - light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = *sector->lightlist[light].lightlevel; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; - - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; - } - else - { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; - - if (sector->extra_colormap) - colormap = sector->extra_colormap; - } - - HWR_Lighting(&Surf, lightlevel, colormap); + if (sector->lightlist[light].extra_colormap) + colormap = sector->lightlist[light].extra_colormap; } + else + { + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = sector->lightlevel; + + if (sector->extra_colormap) + colormap = sector->extra_colormap; + } + + HWR_Lighting(&Surf, lightlevel, colormap); if (spr->mobj->frame & FF_TRANSMASK) blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); @@ -4402,7 +4390,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean planeinfo->lumpnum = lumpnum; planeinfo->xsub = xsub; - planeinfo->alpha = alpha; + planeinfo->alpha = CLAMP(alpha, 0, 255); planeinfo->FOFSector = FOFSector; planeinfo->blend = blend; planeinfo->fogplane = fogplane; @@ -4422,7 +4410,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, polyplaneinfo->lumpnum = lumpnum; polyplaneinfo->polysector = polysector; - polyplaneinfo->alpha = alpha; + polyplaneinfo->alpha = CLAMP(alpha, 0, 255); polyplaneinfo->FOFSector = FOFSector; polyplaneinfo->blend = blend; polyplaneinfo->planecolormap = planecolormap; @@ -5879,7 +5867,7 @@ void HWR_Startup(void) HWR_TogglePaletteRendering(); -#ifdef USE_FBO_OGL +#ifdef USE_FBO_OGL HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value); #endif -- 2.54.0 From 94bd1cb37b9b0e90e8c1fb00649aed96b2c0e20d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:24:01 +0200 Subject: [PATCH 203/525] more reference fixes --- src/lua_blockmaplib.c | 4 +++- src/p_map.c | 18 ++++++++++-------- src/p_mobj.c | 27 ++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 0b93766b8..2367673cd 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -53,10 +53,12 @@ static UINT8 lib_searchBlockmap_Objects(lua_State *L, INT32 x, INT32 y, mobj_t * CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); blockfuncerror = true; + P_SetTarget(&bnext, NULL); return 0; // *shrugs* } if (!lua_isnil(gL, -1)) { // if nil, continue + P_SetTarget(&bnext, NULL); if (lua_toboolean(gL, -1)) return 2; // stop whole search else @@ -256,4 +258,4 @@ int LUA_BlockmapLib(lua_State *L) { lua_register(L, "searchBlockmap", lib_searchBlockmap); return 0; -} \ No newline at end of file +} diff --git a/src/p_map.c b/src/p_map.c index 6051d5d1c..bcb2b6a73 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1548,13 +1548,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmceilingslope = NULL; - tmfloorthing = thing; // needed for side collision + P_SetTarget(&tmfloorthing, thing); // needed for side collision } else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; tmceilingslope = NULL; - tmfloorthing = thing; // thing we may stand on + P_SetTarget(&tmfloorthing, thing); // thing we may stand on } } else @@ -1585,13 +1585,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmfloorslope = NULL; - tmfloorthing = thing; // needed for side collision + P_SetTarget(&tmfloorthing, thing); // needed for side collision } else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; tmfloorslope = NULL; - tmfloorthing = thing; // thing we may stand on + P_SetTarget(&tmfloorthing, thing); // thing we may stand on } } } @@ -1991,8 +1991,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } // tmfloorthing is set when tmfloorz comes from a thing's top - tmfloorthing = NULL; - tmhitthing = NULL; + P_SetTarget(&tmfloorthing, NULL); + P_SetTarget(&tmhitthing, NULL); validcount++; @@ -2489,8 +2489,10 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (tmceilingz - tmfloorz < thing->height) { - if (tmfloorthing) - tmhitthing = tmfloorthing; + if (tmfloorthing != NULL) + { + P_SetTarget(&tmhitthing, tmfloorthing); + } return false; // doesn't fit } diff --git a/src/p_mobj.c b/src/p_mobj.c index 0423b00f3..b25a30065 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6073,7 +6073,8 @@ void P_MobjThinker(mobj_t *mobj) mobj->flags2 &= ~MF2_PUSHED; mobj->eflags &= ~(MFE_SPRUNG|MFE_JUSTBOUNCEDWALL); - tmfloorthing = tmhitthing = NULL; + P_SetTarget(&tmfloorthing, NULL); + P_SetTarget(&tmhitthing, NULL); // 970 allows ANY mobj to trigger a linedef exec if (mobj->subsector && GETSECSPECIAL(mobj->subsector->sector->special, 2) == 8) @@ -10030,13 +10031,29 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); P_SetTarget(&mobj->tracer, NULL); + // repair hnext chain + mobj_t *cachenext = mobj->hnext; + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + { + if (mobj->hnext->hprev == mobj) + { + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + } + + P_SetTarget(&mobj->hnext, NULL); + } + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) - P_SetTarget(&mobj->hprev->hnext, mobj->hnext); - - P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); + { + if (mobj->hprev->hnext == mobj) + { + P_SetTarget(&mobj->hprev->hnext, cachenext); + } + P_SetTarget(&mobj->hprev, NULL); + } + // clear the reference from the mapthing if (mobj->spawnpoint) P_SetTarget(&mobj->spawnpoint->mobj, NULL); -- 2.54.0 From aef62c45de1c611d71d613a7a3dabc7f01e04538 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:07:23 +0200 Subject: [PATCH 204/525] smol cleanup also check for splitscreen and if not dont run a for loop lul --- src/p_tick.c | 262 ++------------------------------------------------- src/p_tick.h | 1 + 2 files changed, 10 insertions(+), 253 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 3bbc219ca..deb84a516 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -324,265 +324,25 @@ static inline void P_RunThinkers(void) } } -// -// P_DoAutobalanceTeams() -// -// Determine if the teams are unbalanced, and if so, move a player to the other team. -// -/*static void P_DoAutobalanceTeams(void) +void P_RunChaseCameras(void) { - changeteam_union NetPacket; - UINT16 usvalue; - INT32 i=0; - INT32 red=0, blue=0; - INT32 redarray[MAXPLAYERS], bluearray[MAXPLAYERS]; - INT32 redflagcarrier = 0, blueflagcarrier = 0; - INT32 totalred = 0, totalblue = 0; + UINT8 i; - NetPacket.value.l = NetPacket.value.b = 0; - memset(redarray, 0, sizeof(redarray)); - memset(bluearray, 0, sizeof(bluearray)); - - // Only do it if we have enough room in the net buffer to send it. - // Otherwise, come back next time and try again. - if (sizeof(usvalue) > GetFreeXCmdSize()) - return; - - //We have to store the players in an array with the rest of their team. - //We can then pick a random player to be forced to change teams. - for (i = 0; i < MAXPLAYERS; i++) + if (!splitscreen) { - if (playeringame[i] && players[i].ctfteam) - { - if (players[i].ctfteam == 1) - { - if (!players[i].gotflag) - { - redarray[red] = i; //store the player's node. - red++; - } - else - redflagcarrier++; - } - else - { - if (!players[i].gotflag) - { - bluearray[blue] = i; //store the player's node. - blue++; - } - else - blueflagcarrier++; - } - } - } - - totalred = red + redflagcarrier; - totalblue = blue + blueflagcarrier; - - if ((abs(totalred - totalblue) > cv_autobalance.value)) - { - if (totalred > totalblue) - { - i = M_RandomKey(red); - NetPacket.packet.newteam = 2; - NetPacket.packet.playernum = redarray[i]; - NetPacket.packet.verification = true; - NetPacket.packet.autobalance = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - - if (totalblue > totalred) - { - i = M_RandomKey(blue); - NetPacket.packet.newteam = 1; - NetPacket.packet.playernum = bluearray[i]; - NetPacket.packet.verification = true; - NetPacket.packet.autobalance = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - } -} - -// -// P_DoTeamscrambling() -// -// If a team scramble has been started, scramble one person from the -// pre-made scramble array. Said array is created in TeamScramble_OnChange() -// -void P_DoTeamscrambling(void) -{ - changeteam_union NetPacket; - UINT16 usvalue; - NetPacket.value.l = NetPacket.value.b = 0; - - // Only do it if we have enough room in the net buffer to send it. - // Otherwise, come back next time and try again. - if (sizeof(usvalue) > GetFreeXCmdSize()) - return; - - if (scramblecount < scrambletotal) - { - if (players[scrambleplayers[scramblecount]].ctfteam != scrambleteams[scramblecount]) - { - NetPacket.packet.newteam = scrambleteams[scramblecount]; - NetPacket.packet.playernum = scrambleplayers[scramblecount]; - NetPacket.packet.verification = true; - NetPacket.packet.scrambled = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - - scramblecount++; //Increment, and get to the next player when we come back here next time. + if (camera[consoleplayer].chase) + P_MoveChaseCamera(&players[consoleplayer], &camera[consoleplayer], false); } else - CV_SetValue(&cv_teamscramble, 0); -} - -static inline void P_DoSpecialStageStuff(void) -{ - boolean inwater = false; - INT32 i; - - // Can't drown in a special stage - for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) - continue; - - players[i].powers[pw_underwater] = players[i].powers[pw_spacetime] = 0; - } - - if (sstimer < 15*TICRATE+6 && sstimer > 7 && (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC)) - S_SpeedMusic(1.4f); - - if (sstimer < 7 && sstimer > 0) // The special stage time is up! - { - sstimer = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i <= splitscreen; i++) { - if (playeringame[i]) - { - players[i].exiting = raceexittime+1; - players[i].pflags &= ~PF_GLIDING; - } - - if (i == consoleplayer) - S_StartSound(NULL, sfx_lose); - } - - if (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC) - S_SpeedMusic(1.0f); - - stagefailed = true; - } - - if (sstimer > 1) // As long as time isn't up... - { - UINT32 ssrings = 0; - // Count up the rings of all the players and see if - // they've collected the required amount. - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - ssrings += (players[i].mo->health-1); - - // If in water, deplete timer 6x as fast. - if ((players[i].mo->eflags & MFE_TOUCHWATER) - || (players[i].mo->eflags & MFE_UNDERWATER)) - inwater = true; - } - - if (ssrings >= totalrings && totalrings > 0) - { - // Halt all the players - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - players[i].mo->momx = players[i].mo->momy = 0; - players[i].exiting = raceexittime+1; - } - - sstimer = 0; - - P_GiveEmerald(true); - } - - // Decrement the timer - if (!objectplacing) - { - if (inwater) - sstimer -= 6; - else - sstimer--; + if (camera[i].chase) + P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); } } } -static inline void P_DoTagStuff(void) -{ - INT32 i; - - // tell the netgame who the initial IT person is. - if (leveltime == TICRATE) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (players[i].pflags & PF_TAGIT) - { - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[i]); // Tell everyone who is it! - break; - } - } - } - - //increment survivor scores - if (leveltime % TICRATE == 0 && leveltime > (hidetime * TICRATE)) - { - INT32 participants = 0; - - for (i=0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator) - participants++; - } - - for (i=0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator && players[i].playerstate == PST_LIVE - && !(players[i].pflags & (PF_TAGIT|PF_TAGGED))) - //points given is the number of participating players divided by two. - P_AddPlayerScore(&players[i], participants/2); - } - } -} - -static inline void P_DoCTFStuff(void) -{ - // Automatic team balance for CTF and team match - if (leveltime % (TICRATE * 5) == 0) //only check once per five seconds for the sake of CPU conservation. - { - // Do not attempt to autobalance and scramble teams at the same time. - // Only the server should execute this. No verified admins, please. - if ((cv_autobalance.value && !cv_teamscramble.value) && cv_allowteamchange.value && server) - P_DoAutobalanceTeams(); - } - - // Team scramble code for team match and CTF. - if ((leveltime % (TICRATE/7)) == 0) - { - // If we run out of time in the level, the beauty is that - // the Y_Ticker() team scramble code will pick it up. - if (cv_teamscramble.value && server) - P_DoTeamscrambling(); - } -}*/ - // // P_Ticker // @@ -830,11 +590,7 @@ void P_Ticker(boolean run) } // Always move the camera. - for (i = 0; i <= splitscreen; i++) - { - if (camera[i].chase) - P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); - } + P_RunChaseCameras(); if (run) { diff --git a/src/p_tick.h b/src/p_tick.h index 2cbbb8104..11b5889ed 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -24,6 +24,7 @@ extern tic_t leveltime; void Command_Numthinkers_f(void); void Command_CountMobjs_f(void); +void P_RunChaseCameras(void); void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); -- 2.54.0 From efcd1df365fe44d9fdc346d4fdb2be10ad8d2d91 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:22:10 +0200 Subject: [PATCH 205/525] fix this oops --- src/p_tick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index deb84a516..af187bbea 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -330,8 +330,8 @@ void P_RunChaseCameras(void) if (!splitscreen) { - if (camera[consoleplayer].chase) - P_MoveChaseCamera(&players[consoleplayer], &camera[consoleplayer], false); + if (camera[0].chase) + P_MoveChaseCamera(&players[displayplayers[0]], &camera[0], false); } else { -- 2.54.0 From 3ad3cdfa38a6ca0af92eade8a5c2b30d5cc45838 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:07:39 +0200 Subject: [PATCH 206/525] stop yelling clang --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index ac6785a53..75bfeaadc 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -727,7 +727,7 @@ void D_SRB2Loop(void) if (lastdraw || singletics || gametic > rendergametic) { rendergametic = gametic; - rendertimeout = entertic + TICRATE/(TICRATE/2); + rendertimeout = entertic + TICRATE/17.5; doDisplay = true; } -- 2.54.0 From 5824d9e803c662f73c499a96a3c73a7d3e8010d5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:21:01 +0200 Subject: [PATCH 207/525] cleanup r_things a little --- src/r_things.c | 55 +++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index a769960ea..068358802 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -38,12 +38,6 @@ #include "qs22j.h" -#ifdef PC_DOS -#include // for snprintf -int snprintf(char *str, size_t n, const char *fmt, ...); -//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap); -#endif - CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; static void R_InitSkins(void); @@ -532,15 +526,6 @@ void R_InitSprites(void) R_AddSkins((UINT16)i, false); R_LoadSpriteInfoLumps(i, wadfiles[i]->numlumps); } - - // - // check if all sprites have frames - // - /* - for (i = 0; i < numsprites; i++) - if (sprites[i].numframes < 1) - CONS_Debug(DBG_SETUP, "R_InitSprites: sprite %s has no frames at all\n", sprnames[i]); - */ } // @@ -1034,13 +1019,6 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) newsprite->extra_colormap = sector->lightlist[i].extra_colormap; -/* - if (thing->frame & FF_TRANSMASK) - ; - else if (thing->flags2 & MF2_SHADOW) - ; - else -*/ if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { @@ -1068,6 +1046,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) msecnode_t *node; sector_t *sector; ffloor_t *rover; + #define CHECKZ (isflipped ? z > thing->z+thing->height/2 && z < groundz : z < thing->z+thing->height/2 && z > groundz) for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next) @@ -1347,7 +1326,7 @@ static void R_ProjectSprite(mobj_t *thing) rollangle = thing->rollangle; } - if ((rollangle) || (pitchnroll) || (thing->player && thing->player->sliproll)) + if (rollangle || pitchnroll || (thing->player && thing->player->sliproll)) { rollsum = pitchnroll; @@ -1585,7 +1564,8 @@ static void R_ProjectSprite(mobj_t *thing) for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y) : thing->subsector->sector->lightlist[lightnum].height; - if (h <= gzt) { + if (h <= gzt) + { light = lightnum - 1; break; } @@ -3171,12 +3151,15 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) } } - if (cvar != NULL) { - if (player->localskin > 0) { + if (cvar != NULL) + { + if (player->localskin > 0) + { CV_StealthSet(&cv_fakelocalskin, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); CV_StealthSet(cvar, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); } - else { + else + { CV_StealthSet(&cv_fakelocalskin, "none"); CV_StealthSet(cvar, "none"); } @@ -3634,8 +3617,8 @@ next_token: CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); #ifdef SKINVALUES - ( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].value = ( (local) ? numlocalskins : numskins ); - ( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].strvalue = skin->name; + (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].value = (local ? numlocalskins : numskins); + (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].strvalue = skin->name; #endif // Update the forceskin possiblevalues @@ -3646,6 +3629,7 @@ next_token: } skin->localskin = local; + // so we dont have to guess if (local) skin->localnum = numlocalskins; @@ -3653,28 +3637,27 @@ next_token: skin->localnum = numskins; // add face graphics - if (local) { + if (local) ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins); - } else { + else ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins); - } #ifdef HWRENDER if (rendermode == render_opengl) - HWR_AddPlayerMD2(( (local) ? numlocalskins : numskins ), local); + HWR_AddPlayerMD2(((local) ? numlocalskins : numskins), local); #endif - if (!local) { + if (!local) + { skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins; CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight); skinstatscount[skin->kartspeed-1][skin->kartweight-1]++; CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]); - skinsorted[numskins] = numskins; } allskins[numallskins] = ( (local) ? localskins : skins )[( (local) ? numlocalskins : numskins )]; - ( (local) ? numlocalskins++ : numskins++ ); + local ? numlocalskins++ : numskins++; numallskins++; } -- 2.54.0 From 3653786e14707be63bdefe92023e93c3f048a90d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:23:21 +0200 Subject: [PATCH 208/525] cleanup hw_main --- src/hardware/hw_main.c | 266 ++++++++++++++++++++--------------------- 1 file changed, 127 insertions(+), 139 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index cf95fdbcb..c4449f512 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -490,6 +490,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GL_DEFAULTMIX; fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG; + // Clamp the light level, since it can sometimes go out of the 0-255 range from animations + light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); + // Crappy backup coloring if you can't do shaders if (!HWR_UseShader()) { @@ -527,9 +530,6 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } - // Clamp the light level, since it can sometimes go out of the 0-255 range from animations - light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); - // in palette rendering mode, this is not needed since it properly takes the changes to the palette itself if (!HWR_ShouldUsePaletteRendering()) { @@ -562,9 +562,8 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if } else { - light = light - (255 - light); // Don't go out of bounds - light = CLAMP(light, 0, 255); + light = CLAMP(light - (255 - light), 0, 255); alpha = (realcolor.s.alpha*255)/25; @@ -848,11 +847,11 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc if (HWR_UseShader()) { if (PolyFlags & PF_Fog) - shader = SHADER_FOG; // fog shader + shader = SHADER_FOG; else if (PolyFlags & PF_Ripple) - shader = SHADER_WATER; // water shader + shader = SHADER_WATER; else - shader = SHADER_FLOOR; // floor shader + shader = SHADER_FLOOR; PolyFlags |= PF_ColorMapped; } @@ -1012,7 +1011,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) } if (HWR_UseShader()) - shader = SHADER_WALL; // wall shader + shader = SHADER_WALL; HWR_ProcessPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal, shader, false); } @@ -1677,51 +1676,49 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // check BOTTOM TEXTURE if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! { + fixed_t texturevpegbottom = 0; // bottom + + grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); + + // PEGGING + if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) + texturevpegbottom = 0; + else if (gr_linedef->flags & ML_EFFECT1) + texturevpegbottom = worldbottom - worldlow; + else + texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; + + texturevpegbottom += gr_sidedef->rowoffset; + + // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway + texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // Adjust t value for sloped walls + if (!(gr_linedef->flags & ML_EFFECT1)) { - fixed_t texturevpegbottom = 0; // bottom - - grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); - - // PEGGING - if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) - texturevpegbottom = 0; - else if (gr_linedef->flags & ML_EFFECT1) - texturevpegbottom = worldbottom - worldlow; - else - texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; - - texturevpegbottom += gr_sidedef->rowoffset; - - // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // Adjust t value for sloped walls - if (!(gr_linedef->flags & ML_EFFECT1)) - { - // Unskewed - wallVerts[0].t -= (worldbottom - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[1].t -= (worldbottomslope - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[3].t -= (worldlow - gr_backsector->floorheight) * grTex->scaleY; - wallVerts[2].t -= (worldlowslope - gr_backsector->floorheight) * grTex->scaleY; - } - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) - { - // Skewed by bottom - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this - wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; - } - else - { - // Skewed by top - wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; - } + // Unskewed + wallVerts[0].t -= (worldbottom - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[1].t -= (worldbottomslope - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[3].t -= (worldlow - gr_backsector->floorheight) * grTex->scaleY; + wallVerts[2].t -= (worldlowslope - gr_backsector->floorheight) * grTex->scaleY; + } + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + { + // Skewed by bottom + wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; + //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this + wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; + } + else + { + // Skewed by top + wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; + wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; } // set top/bottom coords @@ -1900,12 +1897,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode |= PF_Decal; if (!gl_drawing_stencil && gr_frontsector->numlights) - { - if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); - else - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, PF_Decal); - } + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, PF_Decal); else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); else @@ -1915,41 +1907,44 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // Single sided line... Deal only with the middletexture (if one exists) - if (gr_midtexture && gr_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL { + fixed_t texturevpeg; + + // PEGGING + if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) + texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; + else + texturevpeg = gr_sidedef->rowoffset; // top of texture at top + + grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + + wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // Texture correction for slopes + if (gr_linedef->flags & ML_EFFECT2) { - fixed_t texturevpeg; - // PEGGING - if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) - texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) - texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; - else - // top of texture at top - texturevpeg = gr_sidedef->rowoffset; - - grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); - - wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // Texture correction for slopes - if (gr_linedef->flags & ML_EFFECT2) { - wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; - wallVerts[2].t += (gr_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; - wallVerts[0].t += (gr_frontsector->floorheight - worldbottom) * grTex->scaleY; - wallVerts[1].t += (gr_frontsector->floorheight - worldbottomslope) * grTex->scaleY; - } else if (gr_linedef->flags & ML_DONTPEGBOTTOM) { - wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; - wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; - } else { - wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; - wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; - } + wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; + wallVerts[2].t += (gr_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; + wallVerts[0].t += (gr_frontsector->floorheight - worldbottom) * grTex->scaleY; + wallVerts[1].t += (gr_frontsector->floorheight - worldbottomslope) * grTex->scaleY; } + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + { + wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; + wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; + } + else + { + wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; + wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; + } + //Set textures properly on single sided walls that are sloped wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); @@ -1958,8 +1953,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); - // I don't think that solid walls can use translucent linedef types... - else + else // I don't think that solid walls can use translucent linedef types... { if (grTex->mipmap.flags & TF_TRANSPARENT) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); @@ -2150,7 +2144,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); + Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gr_frontsector->numlights) @@ -2264,7 +2258,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); + Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gr_backsector->numlights) @@ -2280,7 +2274,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } } - #undef SLOPEPARAMS //Hurdler: end of 3d-floors test } @@ -2420,8 +2413,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) // Window. // We know it's a window when the above isn't true and the back and front sectors don't match - if (backc1 != frontc1 || backc2 != frontc2 - || backf1 != frontf1 || backf2 != frontf2) + if (backc1 != frontc1 || backc2 != frontc2 || backf1 != frontf1 || backf2 != frontf2) { checkforemptylines = false; return false; @@ -2554,6 +2546,7 @@ doaddline: gld_clipper_SafeAddClipRange(angle2, angle1); checkforemptylines = false; } + // Reject empty lines used for triggers and special events. // Identical floor and ceiling on both sides, // identical light levels on both sides, @@ -2862,11 +2855,11 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t if (HWR_UseShader()) { - shader = SHADER_FLOOR; // floor shader + shader = SHADER_FLOOR; blendmode |= PF_ColorMapped; } - HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); // floor shader + HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); } void HWR_AddPolyObjectPlanes(void) @@ -3022,7 +3015,6 @@ static void HWR_Subsector(size_t num) //SoM: 4/7/2000: Test to make Boom water work in Hardware mode. gr_frontsector = R_FakeFlat(gr_frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); - //FIXME: Use floorlightlevel and ceilinglightlevel insted of lightlevel. if (gr_portal == GRPORTAL_SEARCH) { @@ -3166,7 +3158,7 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gr_frontsector->lightlist[light].lightlevel, - max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3210,7 +3202,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, - max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3865,7 +3857,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) continue; if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; + lightlevel = *list[i-1].lightlevel; colormap = list[i-1].extra_colormap; break; } @@ -3879,7 +3871,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; + lightlevel = *list[i].lightlevel; colormap = list[i].extra_colormap; } @@ -4092,16 +4084,14 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) /// \todo coloured // colormap test - { - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + sector_t *sector = spr->mobj->subsector->sector; + UINT8 lightlevel = 255; + extracolormap_t *colormap = sector->extra_colormap; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = sector->lightlevel; - HWR_Lighting(&Surf, lightlevel, colormap); - } + HWR_Lighting(&Surf, lightlevel, colormap); { FBITFIELD blend = 0; @@ -4129,7 +4119,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) if (HWR_UseShader()) { - shader = SHADER_SPRITE; // sprite shader + shader = SHADER_SPRITE; blend |= PF_ColorMapped; } @@ -4187,34 +4177,32 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) HWR_GetMappedPatch(gpatch, spr->colormap); // colormap test + sector_t *sector = spr->mobj->subsector->sector; + UINT8 lightlevel = 255; + extracolormap_t *colormap = sector->extra_colormap; + + if (sector->numlights) { - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + INT32 light; - if (sector->numlights) - { - INT32 light; + light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before - light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = *sector->lightlist[light].lightlevel; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; - - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; - } - else - { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; - - if (sector->extra_colormap) - colormap = sector->extra_colormap; - } - - HWR_Lighting(&Surf, lightlevel, colormap); + if (sector->lightlist[light].extra_colormap) + colormap = sector->lightlist[light].extra_colormap; } + else + { + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = sector->lightlevel; + + if (sector->extra_colormap) + colormap = sector->extra_colormap; + } + + HWR_Lighting(&Surf, lightlevel, colormap); if (spr->mobj->frame & FF_TRANSMASK) blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); @@ -4402,7 +4390,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean planeinfo->lumpnum = lumpnum; planeinfo->xsub = xsub; - planeinfo->alpha = alpha; + planeinfo->alpha = CLAMP(alpha, 0, 255); planeinfo->FOFSector = FOFSector; planeinfo->blend = blend; planeinfo->fogplane = fogplane; @@ -4422,7 +4410,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, polyplaneinfo->lumpnum = lumpnum; polyplaneinfo->polysector = polysector; - polyplaneinfo->alpha = alpha; + polyplaneinfo->alpha = CLAMP(alpha, 0, 255); polyplaneinfo->FOFSector = FOFSector; polyplaneinfo->blend = blend; polyplaneinfo->planecolormap = planecolormap; @@ -5879,7 +5867,7 @@ void HWR_Startup(void) HWR_TogglePaletteRendering(); -#ifdef USE_FBO_OGL +#ifdef USE_FBO_OGL HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value); #endif -- 2.54.0 From 6ec96b37bdea72e3bb0d792653d95d2b360d17cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:38:51 +0200 Subject: [PATCH 209/525] remove hw_light --- src/CMakeLists.txt | 2 -- src/Makefile | 2 +- src/hardware/hw_light.c | 27 --------------------------- src/hardware/hw_light.h | 20 -------------------- src/hardware/hw_main.c | 4 +--- src/hardware/hw_md2.c | 1 - src/p_setup.c | 1 - src/p_user.c | 1 - 8 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 src/hardware/hw_light.c delete mode 100644 src/hardware/hw_light.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4bb035af..025365822 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -465,7 +465,6 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c @@ -483,7 +482,6 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h diff --git a/src/Makefile b/src/Makefile index 98351a8a2..9951ca91d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -280,7 +280,7 @@ ifdef NOHW OPTS+=-DNOHW else OPTS+=-DHWRENDER - OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o $(OBJDIR)/hw_light.o \ + OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o \ $(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o \ $(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o $(OBJDIR)/hw_shaders.o endif diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c deleted file mode 100644 index 079349c37..000000000 --- a/src/hardware/hw_light.c +++ /dev/null @@ -1,27 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2019 by Sonic Team Junior. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file - -#include "../doomdef.h" - -#ifdef HWRENDER -#include "hw_light.h" -#include "hw_drv.h" -#include "../i_video.h" -#include "../z_zone.h" -#include "../m_random.h" -#include "../m_bbox.h" -#include "../w_wad.h" -#include "../r_state.h" -#include "../r_main.h" -#include "../p_local.h" - -#endif // HWRENDER diff --git a/src/hardware/hw_light.h b/src/hardware/hw_light.h deleted file mode 100644 index fbc1d1f26..000000000 --- a/src/hardware/hw_light.h +++ /dev/null @@ -1,20 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2019 by Sonic Team Junior. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Dynamic lighting & coronas add on by Hurdler - -#ifndef _HW_LIGHTS_ -#define _HW_LIGHTS_ - -#include "hw_glob.h" -#include "hw_defs.h" - -#endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c4449f512..dddb895b2 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -12,6 +12,7 @@ /// \brief hardware renderer, using the standard HardWareRender driver DLL for SRB2 #include +#include // qsort #include "../doomstat.h" @@ -24,7 +25,6 @@ #include "hw_batching.h" #include "hw_md2.h" #include "hw_clip.h" -#include "hw_light.h" #include "../i_video.h" // for rendermode == render_glide #include "../v_video.h" @@ -48,8 +48,6 @@ #include "../m_argv.h" // parm functions for msaa #include "../p_slopes.h" -#include // qsort - #define ABS(x) ((x) < 0 ? -(x) : (x)) #define SOFTLIGHT(llevel) HWR_ShouldUsePaletteRendering() ? ((llevel) >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : (llevel) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 0b43095da..c71f47185 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -26,7 +26,6 @@ #ifdef HWRENDER #include "hw_drv.h" -#include "hw_light.h" #include "hw_md2.h" #include "../d_main.h" #include "../r_bsp.h" diff --git a/src/p_setup.c b/src/p_setup.c index 99dfc81d9..b5c92bdbc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -77,7 +77,6 @@ #endif #ifdef HWRENDER #include "hardware/hw_main.h" -#include "hardware/hw_light.h" #endif #include "p_slopes.h" diff --git a/src/p_user.c b/src/p_user.c index bacdb920d..1219414df 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -55,7 +55,6 @@ #endif #ifdef HWRENDER -#include "hardware/hw_light.h" #include "hardware/hw_main.h" #endif -- 2.54.0 From bd106308fc3f8f345e7befcac46a296ff616d44f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:46:01 +0200 Subject: [PATCH 210/525] revert this doesent do anything but complicate stuff lol --- src/d_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 75bfeaadc..e53cdfb6b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -624,8 +624,7 @@ static int menuInputDelayTimer = 0; void D_SRB2Loop(void) { - tic_t entertic = 0, oldentertics = 0, realtics = 0; - double rendertimeout = INFTICS; + tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS; double deltatics = 0.0; double deltasecs = 0.0; @@ -727,7 +726,7 @@ void D_SRB2Loop(void) if (lastdraw || singletics || gametic > rendergametic) { rendergametic = gametic; - rendertimeout = entertic + TICRATE/17.5; + rendertimeout = entertic + TICRATE/17; doDisplay = true; } -- 2.54.0 From e7d18580527656e6ba177ed39795a55282a5658f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 14:20:54 +0200 Subject: [PATCH 211/525] port director from RR --- src/Makefile | 1 + src/d_netcmd.c | 6 + src/d_netcmd.h | 3 + src/k_director.c | 371 +++++++++++++++++++++++++++++++++++++++++++++++ src/k_director.h | 21 +++ src/k_kart.c | 6 + src/p_setup.c | 3 + src/p_tick.c | 3 + 8 files changed, 414 insertions(+) create mode 100644 src/k_director.c create mode 100644 src/k_director.h diff --git a/src/Makefile b/src/Makefile index 9951ca91d..ee2e90cbc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -494,6 +494,7 @@ OBJS:=$(i_main_o) \ $(OBJDIR)/hu_stuff.o \ $(OBJDIR)/y_inter.o \ $(OBJDIR)/st_stuff.o \ + $(OBJDIR)/k_director.o \ $(OBJDIR)/k_kart.o \ $(OBJDIR)/m_aatree.o \ $(OBJDIR)/m_anigif.o \ diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3cf64d065..4f5717106 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -554,6 +554,9 @@ consvar_t cv_perfstats = {"perfstats", "Off", CV_CALL, perfstats_cons_t, PS_Perf consvar_t cv_ps_thinkframe_page = {"ps_thinkframe_page", "1", CV_CALL, CV_Natural, PS_ThinkFrame_Page_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + + static CV_PossibleValue_t ps_samplesize_cons_t[] = { {1, "MIN"}, {1000, "MAX"}, {0, NULL}}; consvar_t cv_ps_samplesize = {"ps_samplesize", "1", CV_CALL, ps_samplesize_cons_t, PS_SampleSize_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -979,6 +982,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_showtrackaddon); CV_RegisterVar(&cv_showviewpointtext); + CV_RegisterVar(&cv_director); + + CV_RegisterVar(&cv_luaimmersion); CV_RegisterVar(&cv_fakelocalskin); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index b02b68f00..e3d306315 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -201,6 +201,9 @@ extern consvar_t cv_ps_thinkframe_page; extern consvar_t cv_ps_samplesize; extern consvar_t cv_ps_descriptor; +extern consvar_t cv_director; + + extern consvar_t cv_showtrackaddon; extern consvar_t cv_showspecstuff; diff --git a/src/k_director.c b/src/k_director.c new file mode 100644 index 000000000..0c2cef1d3 --- /dev/null +++ b/src/k_director.c @@ -0,0 +1,371 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +/// \file k_director.c +/// \brief SRB2kart automatic spectator camera. + +//#include "k_kart.h" +#include "doomdef.h" +#include "g_game.h" +#include "v_video.h" +#include "k_director.h" +#include "d_netcmd.h" +#include "p_local.h" + +#define SWITCHTIME TICRATE * 5 // cooldown between unforced switches +#define BOREDOMTIME 3 * TICRATE / 2 // how long until players considered far apart? +#define TRANSFERTIME TICRATE // how long to delay reaction shots? +#define BREAKAWAYDIST 4000 // how *far* until players considered far apart? +#define WALKBACKDIST 600 // how close should a trailing player be before we switch? +#define PINCHDIST 30000 // how close should the leader be to be considered "end of race"? + +struct directorinfo directorinfo; + +static fixed_t P_ScaleFromMap(fixed_t n, fixed_t scale) +{ + return FixedMul(n, FixedDiv(scale, mapobjectscale)); +} + +void K_InitDirector(void) +{ + INT32 playernum; + + directorinfo.cooldown = SWITCHTIME; + directorinfo.freeze = 0; + directorinfo.attacker = 0; + directorinfo.maxdist = 0; + + for (playernum = 0; playernum < MAXPLAYERS; playernum++) + { + directorinfo.sortedplayers[playernum] = -1; + directorinfo.gap[playernum] = INT32_MAX; + directorinfo.boredom[playernum] = 0; + } +} + +/*static fixed_t K_GetFinishGap(INT32 leader, INT32 follower) +{ + fixed_t dista = players[follower].distancetofinish; + fixed_t distb = players[leader].distancetofinish; + + if (players[follower].position < players[leader].position) + { + return distb - dista; + } + else + { + return dista - distb; + } +}*/ + +static fixed_t K_GetDistanceToFinish(player_t player) +{ + mobj_t *mo; + fixed_t dist = 0; + int maxMoveCount = -1; + int maxAngle = -1; + + if (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)) + { + for (mo = waypointcap; mo != NULL; mo = mo->tracer) + { + if (mo->spawnpoint->angle != 0) + continue; + + dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x, + mo->y - player.mo->y), + mo->z - player.mo->z) / FRACUNIT; + + break; + } + } + else + { + for (mo = waypointcap; mo != NULL; mo = mo->tracer) + { + if (mo->movecount > maxMoveCount) + maxMoveCount = mo->movecount; + if (mo->spawnpoint->angle > maxAngle) + maxAngle = mo->spawnpoint->angle; + + if (!(mo->movecount == maxMoveCount && mo->spawnpoint->angle == maxAngle)) // sprint maps finishline waypoint is the one with highest movecount AND angle + continue; + + dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x, + mo->y - player.mo->y), + mo->z - player.mo->z) / FRACUNIT; + + break; + } + } + + CONS_Printf("dist %d \n", dist); + CONS_Printf("last movecount %d \n", maxMoveCount); + CONS_Printf("last angle %d \n", maxAngle); + + return dist; +} + +static fixed_t K_GetFinishGap(INT32 leader, INT32 follower) +{ + fixed_t dista = K_GetDistanceToFinish(players[follower]); + fixed_t distb = K_GetDistanceToFinish(players[leader]); + + CONS_Printf("dista %d \n", dista); + CONS_Printf("distb %d \n", distb); + + if (players[follower].kartstuff[k_position] < players[leader].kartstuff[k_position]) + { + return distb - dista; + } + else + { + return dista - distb; + } +} + +static void K_UpdateDirectorPositions(void) +{ + INT32 playernum; + INT32 position; + player_t* target; + + memset(directorinfo.sortedplayers, -1, sizeof(directorinfo.sortedplayers)); + + for (playernum = 0; playernum < MAXPLAYERS; playernum++) + { + target = &players[playernum]; + + if (playeringame[playernum] && !target->spectator && target->kartstuff[k_position] > 0) + { + directorinfo.sortedplayers[target->kartstuff[k_position] - 1] = playernum; + } + } + + for (position = 0; position < MAXPLAYERS - 1; position++) + { + directorinfo.gap[position] = INT32_MAX; + + if (directorinfo.sortedplayers[position] == -1 || directorinfo.sortedplayers[position + 1] == -1) + { + continue; + } + + directorinfo.gap[position] = P_ScaleFromMap(K_GetFinishGap(directorinfo.sortedplayers[position], directorinfo.sortedplayers[position + 1]), FRACUNIT); + + if (directorinfo.gap[position] >= BREAKAWAYDIST) + { + directorinfo.boredom[position] = min(BOREDOMTIME * 2, directorinfo.boredom[position] + 1); + } + else if (directorinfo.boredom[position] > 0) + { + directorinfo.boredom[position]--; + } + } + + directorinfo.maxdist = P_ScaleFromMap(K_GetDistanceToFinish(players[directorinfo.sortedplayers[0]]), FRACUNIT); +} + +static boolean K_CanSwitchDirector(void) +{ + /*INT32 *displayplayerp = &displayplayers[0]; + + if (players[*displayplayerp].trickpanel > 0) + { + return false; + }*/ + + if (directorinfo.cooldown > 0) + { + return false; + } + + return true; +} + +static void K_DirectorSwitch(INT32 player, boolean force) +{ + if (P_IsDisplayPlayer(&players[player])) + { + return; + } + + if (players[player].exiting) + { + return; + } + + if (!force && !K_CanSwitchDirector()) + { + return; + } + + G_ResetView(1, player, true); + directorinfo.cooldown = SWITCHTIME; +} + +static void K_DirectorForceSwitch(INT32 player, INT32 time) +{ + if (players[player].exiting) + { + return; + } + + directorinfo.attacker = player; + directorinfo.freeze = time; +} + +void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) +{ + if (!P_IsDisplayPlayer(player)) + { + return; + } + + if (inflictor && inflictor->player) + { + K_DirectorForceSwitch(inflictor->player - players, TRANSFERTIME); + } + else if (source && source->player) + { + K_DirectorForceSwitch(source->player - players, TRANSFERTIME); + } +} + +/*void K_DrawDirectorDebugger(void) +{ + INT32 position; + INT32 leader; + INT32 follower; + INT32 ytxt; + + if (!cv_kartdebugdirector.value) + { + return; + } + + V_DrawThinString(10, 0, V_70TRANS, va("PLACE")); + V_DrawThinString(40, 0, V_70TRANS, va("CONF?")); + V_DrawThinString(80, 0, V_70TRANS, va("GAP")); + V_DrawThinString(120, 0, V_70TRANS, va("BORED")); + V_DrawThinString(150, 0, V_70TRANS, va("COOLDOWN: %d", directorinfo.cooldown)); + V_DrawThinString(230, 0, V_70TRANS, va("MAXDIST: %d", directorinfo.maxdist)); + + for (position = 0; position < MAXPLAYERS - 1; position++) + { + ytxt = 10 * (position + 1); + leader = directorinfo.sortedplayers[position]; + follower = directorinfo.sortedplayers[position + 1]; + + if (leader == -1 || follower == -1) + break; + + V_DrawThinString(10, ytxt, V_70TRANS, va("%d", position)); + V_DrawThinString(20, ytxt, V_70TRANS, va("%d", position + 1)); + + if (players[leader].positiondelay) + { + V_DrawThinString(40, ytxt, V_70TRANS, va("NG")); + } + + V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfo.gap[position])); + + if (directorinfo.boredom[position] >= BOREDOMTIME) + { + V_DrawThinString(120, ytxt, V_70TRANS, va("BORED")); + } + else + { + V_DrawThinString(120, ytxt, V_70TRANS, va("%d", directorinfo.boredom[position])); + } + + V_DrawThinString(150, ytxt, V_70TRANS, va("%s", player_names[leader])); + V_DrawThinString(230, ytxt, V_70TRANS, va("%s", player_names[follower])); + } +}*/ + +void K_UpdateDirector(void) +{ + INT32 *displayplayerp = &displayplayers[0]; + INT32 targetposition; + + if (!cv_director.value) + { + return; + } + + K_UpdateDirectorPositions(); + + if (directorinfo.cooldown > 0) { + directorinfo.cooldown--; + } + + // handle pending forced switches + if (directorinfo.freeze > 0) + { + if (!(--directorinfo.freeze)) + K_DirectorSwitch(directorinfo.attacker, true); + + return; + } + + // if there's only one player left in the list, just switch to that player + if (directorinfo.sortedplayers[0] != -1 && directorinfo.sortedplayers[1] == -1) + { + K_DirectorSwitch(directorinfo.sortedplayers[0], false); + return; + } + + // aaight, time to walk through the standings to find the first interesting pair + // NB: targetposition/sortedplayers is 0-indexed, aiming at the "back half" of a given pair by default. + // we adjust for this when comparing to player->position or when looking at the leading player, Don't Freak Out + for (targetposition = 1; targetposition < MAXPLAYERS; targetposition++) + { + INT32 target; + + // you are out of players, try again + if (directorinfo.sortedplayers[targetposition] == -1) + { + break; + } + + // pair too far apart? try the next one + if (directorinfo.boredom[targetposition - 1] >= BOREDOMTIME) + { + continue; + } + + // pair finished? try the next one + if (players[directorinfo.sortedplayers[targetposition]].exiting) + { + continue; + } + + // don't risk switching away from forward pairs at race end, might miss something! + if (directorinfo.maxdist > PINCHDIST) + { + // if the "next" player is close enough, they should be able to see everyone fine! + // walk back through the standings to find a vantage that gets everyone in frame. + // (also creates a pretty cool effect w/ overtakes at speed) + while (targetposition < MAXPLAYERS && directorinfo.gap[targetposition] < WALKBACKDIST) + { + targetposition++; + } + } + + target = directorinfo.sortedplayers[targetposition]; + + // if we're certain the back half of the pair is actually in this position, try to switch + if (*displayplayerp != target /*&& !players[target].positiondelay*/) + { + K_DirectorSwitch(target, false); + } + + // even if we're not certain, if we're certain we're watching the WRONG player, try to switch + if (players[*displayplayerp].kartstuff[k_position] != targetposition+1 /*&& !players[target].positiondelay*/) + { + K_DirectorSwitch(target, false); + } + + break; + } +} diff --git a/src/k_director.h b/src/k_director.h new file mode 100644 index 000000000..db19fbe8b --- /dev/null +++ b/src/k_director.h @@ -0,0 +1,21 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +/// \file k_director.h +/// \brief SRB2kart automatic spectator camera. + +extern struct directorinfo +{ + tic_t cooldown; // how long has it been since we last switched? + tic_t freeze; // when nonzero, fixed switch pending, freeze logic! + INT32 attacker; // who to switch to when freeze delay elapses + INT32 maxdist; // how far is the closest player from finishing? + + INT32 sortedplayers[MAXPLAYERS]; // position-1 goes in, player index comes out. + INT32 gap[MAXPLAYERS]; // gap between a given position and their closest pursuer + INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? +} directorinfo; + +void K_InitDirector(void); +void K_UpdateDirector(void); +void K_DrawDirectorDebugger(void); +void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source); \ No newline at end of file diff --git a/src/k_kart.c b/src/k_kart.c index 1ce92dc30..fb955cde2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -31,6 +31,7 @@ #include "z_zone.h" #include "m_misc.h" #include "m_cond.h" +#include "k_director.h" #include "k_kart.h" #include "f_finale.h" #include "lua_hud.h" // For Lua hud checks @@ -2233,6 +2234,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto // PS: Inflictor is unused for all purposes here and is actually only ever relevant to Lua. It may be nil too. boolean force = false; // Used to check if Lua ShouldSpin should get us damaged reguardless of flashtics or heck knows what. UINT8 shouldForce = LUAh_ShouldSpin(player, inflictor, source); + if (P_MobjWasRemoved(player->mo)) return; // mobj was removed (in theory that shouldn't happen) if (shouldForce == 1) @@ -2240,6 +2242,8 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto else if (shouldForce == 2) return; + K_DirectorFollowAttack(player, inflictor, source); + if (!trapitem && G_BattleGametype()) { if (K_IsPlayerWanted(player)) @@ -2490,6 +2494,8 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b else if (shouldForce == 2) return; + K_DirectorFollowAttack(player, inflictor, source); + if (G_BattleGametype()) { if (K_IsPlayerWanted(player)) diff --git a/src/p_setup.c b/src/p_setup.c index b5c92bdbc..f27816c07 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -82,6 +82,7 @@ #include "p_slopes.h" // SRB2Kart +#include "k_director.h" // K_InitDirector #include "k_kart.h" // @@ -2956,6 +2957,8 @@ boolean P_SetupLevel(boolean skipprecip) G_BeginRecording(); //this has to move here, since dedicated servers dont run got_mapcmd } + K_InitDirector(); + wantedcalcdelay = wantedfrequency*2; indirectitemcooldown = 0; hyubgone = 0; diff --git a/src/p_tick.c b/src/p_tick.c index af187bbea..6bf32f1c3 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -23,6 +23,7 @@ #include "m_random.h" #include "lua_script.h" #include "lua_hook.h" +#include "k_director.h" #include "k_kart.h" #include "i_system.h" #include "r_main.h" @@ -589,6 +590,8 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_postthinkframe_time); } + K_UpdateDirector(); + // Always move the camera. P_RunChaseCameras(); -- 2.54.0 From 3f412373bc155ac616dbe5d8e28448943ab71f28 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 14:42:17 +0200 Subject: [PATCH 212/525] fix crash if everyone spectates --- src/k_director.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index 0c2cef1d3..54b1c1d60 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -98,10 +98,6 @@ static fixed_t K_GetDistanceToFinish(player_t player) } } - CONS_Printf("dist %d \n", dist); - CONS_Printf("last movecount %d \n", maxMoveCount); - CONS_Printf("last angle %d \n", maxAngle); - return dist; } @@ -110,9 +106,6 @@ static fixed_t K_GetFinishGap(INT32 leader, INT32 follower) fixed_t dista = K_GetDistanceToFinish(players[follower]); fixed_t distb = K_GetDistanceToFinish(players[leader]); - CONS_Printf("dista %d \n", dista); - CONS_Printf("distb %d \n", distb); - if (players[follower].kartstuff[k_position] < players[leader].kartstuff[k_position]) { return distb - dista; @@ -162,6 +155,12 @@ static void K_UpdateDirectorPositions(void) } } + if (directorinfo.sortedplayers[0] == -1) + { + directorinfo.maxdist = -1; + return; + } + directorinfo.maxdist = P_ScaleFromMap(K_GetDistanceToFinish(players[directorinfo.sortedplayers[0]]), FRACUNIT); } -- 2.54.0 From b94776063f805cc58ced582b9dc884774930cc90 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 14:42:48 +0200 Subject: [PATCH 213/525] only update director if consoleplayers specs or in demo playback dont need to update this ever if we dont even use it lol --- src/p_tick.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index 6bf32f1c3..f61484a1a 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -590,7 +590,8 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_postthinkframe_time); } - K_UpdateDirector(); + if (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || demo.playback)) + K_UpdateDirector(); // Always move the camera. P_RunChaseCameras(); -- 2.54.0 From bfcb906b1270261cb059c0f2b29ed91be27329cb Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 15:11:01 +0200 Subject: [PATCH 214/525] add stuff for directordebugger i forgor --- src/d_netcmd.c | 8 ++++---- src/d_netcmd.h | 3 +-- src/k_director.c | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4f5717106..b864cb9d7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -554,9 +554,6 @@ consvar_t cv_perfstats = {"perfstats", "Off", CV_CALL, perfstats_cons_t, PS_Perf consvar_t cv_ps_thinkframe_page = {"ps_thinkframe_page", "1", CV_CALL, CV_Natural, PS_ThinkFrame_Page_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - - static CV_PossibleValue_t ps_samplesize_cons_t[] = { {1, "MIN"}, {1000, "MAX"}, {0, NULL}}; consvar_t cv_ps_samplesize = {"ps_samplesize", "1", CV_CALL, ps_samplesize_cons_t, PS_SampleSize_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -564,6 +561,9 @@ static CV_PossibleValue_t ps_descriptor_cons_t[] = { {1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}}; consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugdirector = {"director", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_showtrackaddon = {"showtrackaddon", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t skinselectmenu_t[] = {{SKINMENUTYPE_SCROLL, "Scroll"}, {SKINMENUTYPE_2D, "2d"}, {SKINMENUTYPE_GRID, "Grid"}, {SKINMENUTYPE_EXTENDED, "Extended"}, {0, NULL}}; @@ -983,7 +983,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_showviewpointtext); CV_RegisterVar(&cv_director); - + CV_RegisterVar(&cv_kartdebugdirector); CV_RegisterVar(&cv_luaimmersion); CV_RegisterVar(&cv_fakelocalskin); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index e3d306315..ad4789313 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -201,8 +201,7 @@ extern consvar_t cv_ps_thinkframe_page; extern consvar_t cv_ps_samplesize; extern consvar_t cv_ps_descriptor; -extern consvar_t cv_director; - +extern consvar_t cv_director, cv_kartdebugdirector; extern consvar_t cv_showtrackaddon; diff --git a/src/k_director.c b/src/k_director.c index 54b1c1d60..a1c9f57c1 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -230,7 +230,7 @@ void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) } } -/*void K_DrawDirectorDebugger(void) +void K_DrawDirectorDebugger(void) { INT32 position; INT32 leader; @@ -261,10 +261,10 @@ void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) V_DrawThinString(10, ytxt, V_70TRANS, va("%d", position)); V_DrawThinString(20, ytxt, V_70TRANS, va("%d", position + 1)); - if (players[leader].positiondelay) + /*if (players[leader].positiondelay) { V_DrawThinString(40, ytxt, V_70TRANS, va("NG")); - } + }*/ V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfo.gap[position])); @@ -280,7 +280,7 @@ void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) V_DrawThinString(150, ytxt, V_70TRANS, va("%s", player_names[leader])); V_DrawThinString(230, ytxt, V_70TRANS, va("%s", player_names[follower])); } -}*/ +} void K_UpdateDirector(void) { -- 2.54.0 From 56a919eb606cb9ff922cf0e484eb7834f31a80fd Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 15:11:28 +0200 Subject: [PATCH 215/525] oops --- src/d_netcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b864cb9d7..409328f0c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -562,7 +562,7 @@ static CV_PossibleValue_t ps_descriptor_cons_t[] = { consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugdirector = {"director", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugdirector = {"debugdirector", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showtrackaddon = {"showtrackaddon", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -- 2.54.0 From 228252ee6f6b6d62f6f825cfcc58ba5f54d8dc98 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 21 Jul 2024 16:11:21 +0300 Subject: [PATCH 216/525] Add bind for director toggle --- src/g_game.c | 5 +++++ src/g_input.c | 1 + src/g_input.h | 1 + src/m_menu.c | 1 + 4 files changed, 8 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 203b1aba5..ab7b14e86 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1935,6 +1935,11 @@ boolean G_Responder(event_t *ev) COM_ImmedExecute("changeteam4 spectator"); } } + if (ev->data1 == gamecontrol[gc_director][0] + || ev->data1 == gamecontrol[gc_director][1]) + { + COM_ImmedExecute("add director 1"); + } return true; diff --git a/src/g_input.c b/src/g_input.c index b6e631309..536ea0c83 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -812,6 +812,7 @@ static const char *gamecontrolname[num_gamecontrols] = "custom1", "custom2", "custom3", + "director", }; #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) diff --git a/src/g_input.h b/src/g_input.h index dac8a3e23..635e1f64b 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -98,6 +98,7 @@ typedef enum gc_custom1, // Lua scriptable gc_custom2, // Lua scriptable gc_custom3, // Lua scriptable + gc_director, num_gamecontrols } gamecontrols_e; diff --git a/src/m_menu.c b/src/m_menu.c index 8f884d05c..f824f379b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1198,6 +1198,7 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Look Up", M_ChangeControl, gc_lookup }, {IT_CONTROL, NULL, "Look Down", M_ChangeControl, gc_lookdown }, {IT_CONTROL, NULL, "Center View", M_ChangeControl, gc_centerview }, + {IT_CONTROL, NULL, "Toggle Director", M_ChangeControl, gc_director }, {IT_HEADER, NULL, "Custom Lua Actions", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, {IT_CONTROL, NULL, "Custom Action 1", M_ChangeControl, gc_custom1 }, -- 2.54.0 From 43e3d07acb2d596a46aeed8578ed45e381952fe8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 15:45:53 +0200 Subject: [PATCH 217/525] fix cmake --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 025365822..258ff882c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -167,6 +167,7 @@ set(SRB2_CORE_GAME_SOURCES p_telept.c p_tick.c p_user.c + k_director.c k_kart.c i_time.c @@ -180,6 +181,7 @@ set(SRB2_CORE_GAME_SOURCES p_slopes.h p_spec.h p_tick.h + k_director.h k_kart.h ) -- 2.54.0 From 60e933eb001da251ef0d5afac2a76cf7d52323b8 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 21 Jul 2024 17:03:15 +0300 Subject: [PATCH 218/525] Add director hud indicator --- src/st_stuff.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/st_stuff.c b/src/st_stuff.c index 681f2d920..715ba53ae 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -796,6 +796,15 @@ static void ST_overlayDrawer(void) // Countdown timer for Race Mode // ...moved to k_kart.c so we can take advantage of the LAPS_Y value + if (demo.playback || !P_IsLocalPlayer(stplyr)) + { + char directortext[20] = {0}; + + snprintf(directortext, 20, "Director: %s", cv_director.value ? "On" : "Off"); + + V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANSHALF|V_ALLOWLOWERCASE, directortext); + } + if (cv_showviewpointtext.value) { if (!(multiplayer && demo.playback)) -- 2.54.0 From 7072332ab736c03063883c03f50b52456ce8ff9a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 19:35:08 +0200 Subject: [PATCH 219/525] clean director up a little toggling director now resets cooldown so it switches players immediately also consolidated condition to be active and ensure DirectorFollowAttack doesent always run when it doesent need to be --- src/g_game.c | 3 ++- src/k_director.c | 22 +++++++++++++++++++++- src/k_director.h | 3 ++- src/p_tick.c | 3 +-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ab7b14e86..552cedfd7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -50,6 +50,7 @@ #include "b_bot.h" #include "m_cond.h" // condition sets #include "md5.h" // demo checksums +#include "k_director.h" // SRB2kart #include "k_kart.h" // SRB2kart #include "r_fps.h" // frame interpolation/uncapped @@ -1938,7 +1939,7 @@ boolean G_Responder(event_t *ev) if (ev->data1 == gamecontrol[gc_director][0] || ev->data1 == gamecontrol[gc_director][1]) { - COM_ImmedExecute("add director 1"); + K_ToggleDirector(); } return true; diff --git a/src/k_director.c b/src/k_director.c index a1c9f57c1..01b2ff001 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -25,6 +25,11 @@ static fixed_t P_ScaleFromMap(fixed_t n, fixed_t scale) return FixedMul(n, FixedDiv(scale, mapobjectscale)); } +static boolean K_DirectorIsEnabled(void) +{ + return cv_director.value && (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || demo.playback)); +} + void K_InitDirector(void) { INT32 playernum; @@ -215,6 +220,11 @@ static void K_DirectorForceSwitch(INT32 player, INT32 time) void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) { + if (!K_DirectorIsEnabled()) + { + return; + } + if (!P_IsDisplayPlayer(player)) { return; @@ -287,7 +297,7 @@ void K_UpdateDirector(void) INT32 *displayplayerp = &displayplayers[0]; INT32 targetposition; - if (!cv_director.value) + if (!K_DirectorIsEnabled()) { return; } @@ -368,3 +378,13 @@ void K_UpdateDirector(void) break; } } + +void K_ToggleDirector(void) +{ + if (!K_DirectorIsEnabled()) + { + directorinfo.cooldown = 0; // switch immediately + } + + COM_ImmedExecute("add director 1"); +} diff --git a/src/k_director.h b/src/k_director.h index db19fbe8b..8842c7b8e 100644 --- a/src/k_director.h +++ b/src/k_director.h @@ -18,4 +18,5 @@ extern struct directorinfo void K_InitDirector(void); void K_UpdateDirector(void); void K_DrawDirectorDebugger(void); -void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source); \ No newline at end of file +void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source); +void K_ToggleDirector(void); diff --git a/src/p_tick.c b/src/p_tick.c index f61484a1a..6bf32f1c3 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -590,8 +590,7 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_postthinkframe_time); } - if (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || demo.playback)) - K_UpdateDirector(); + K_UpdateDirector(); // Always move the camera. P_RunChaseCameras(); -- 2.54.0 From 7ad5dc61ac6fc764dd69f78854ef397ad4d16c2b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 23:25:10 +0200 Subject: [PATCH 220/525] Revert "Free mipmaps before freeing tags" This reverts commit 2437c5a19a0140d3a8fb9627fa5f9300e1a6ac24. --- src/hardware/hw_main.c | 11 +++++++++++ src/p_setup.c | 6 ------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index dddb895b2..0b946ebeb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5746,6 +5746,17 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) void HWR_LoadLevel(void) { + // Lactozilla (December 8, 2019) + // Level setup used to free EVERY mipmap from memory. + // Even mipmaps that aren't related to level textures. + // Presumably, the hardware render code used to store textures as level data. + // Meaning, they had memory allocated and marked with the PU_LEVEL tag. + // Level textures are only reloaded after R_LoadTextures, which is + // when the texture list is loaded. + + // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. + HWR_FreeMipmapCache(); + HWR_CreatePlanePolygons((INT32)numnodes - 1); if (HWR_ShouldUsePaletteRendering()) diff --git a/src/p_setup.c b/src/p_setup.c index b5c92bdbc..0a868ef8c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2776,12 +2776,6 @@ boolean P_SetupLevel(boolean skipprecip) // Clear pointers that would be left dangling by the purge R_FlushTranslationColormapCache(); -#ifdef HWRENDER - // Free GPU textures before freeing patches. - if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) - HWR_FreeMipmapCache(); -#endif - Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); #if defined (WALLSPLATS) || defined (FLOORSPLATS) -- 2.54.0 From c447f25e0a5d268dac842d0a64c593338883a035 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 12:57:11 +0200 Subject: [PATCH 221/525] add missing copyright stuff to k_director --- src/k_director.c | 7 +++++++ src/k_director.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/k_director.c b/src/k_director.c index 01b2ff001..d57ffbb8e 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -1,5 +1,12 @@ // SONIC ROBO BLAST 2 KART //----------------------------------------------------------------------------- +// Copyright (C) 2024 by AJ "Tyron" Martinez. +// Copyright (C) 2024 by James Robert Roman. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- /// \file k_director.c /// \brief SRB2kart automatic spectator camera. diff --git a/src/k_director.h b/src/k_director.h index 8842c7b8e..7218cc7e3 100644 --- a/src/k_director.h +++ b/src/k_director.h @@ -1,5 +1,12 @@ // SONIC ROBO BLAST 2 KART //----------------------------------------------------------------------------- +// Copyright (C) 2024 by AJ "Tyron" Martinez. +// Copyright (C) 2024 by James Robert Roman. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- /// \file k_director.h /// \brief SRB2kart automatic spectator camera. -- 2.54.0 From b44617413b94df2ef34c5006c1c6841ca706f428 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 12:59:07 +0200 Subject: [PATCH 222/525] gitignore deez --- bin/Linux64/Release/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/Linux64/Release/.gitignore b/bin/Linux64/Release/.gitignore index 56dee6f95..c63fd53bc 100644 --- a/bin/Linux64/Release/.gitignore +++ b/bin/Linux64/Release/.gitignore @@ -1 +1 @@ -/lsdlsrb2 +/lsdl2srb2kart -- 2.54.0 From 02d115f119db9043497bde4d3ccc34d789e2cc8b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 18:08:26 +0200 Subject: [PATCH 223/525] don't check flippedness in HWR_RotateSpritePolyToAim if the mobj is actually a precipmobj! --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0b946ebeb..468b6dfbf 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3661,7 +3661,7 @@ static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts } } - if (P_MobjFlip(spr->mobj) == -1) + if (!precip && P_MobjFlip(spr->mobj) == -1) // precip doesn't have eflags so they can't flip { basey = FIXED_TO_FLOAT(interp.z + spr->mobj->height); } -- 2.54.0 From 824211c2f6ca52d711f7ddff01c78cd626dc4f2f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 18:13:06 +0200 Subject: [PATCH 224/525] prevent potential level load crash --- src/hardware/hw_main.c | 2 +- src/r_things.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 468b6dfbf..c36ecf4a9 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5024,7 +5024,7 @@ void HWR_ProjectSprite(mobj_t *thing) } heightsec = thing->subsector->sector->heightsec; - if (viewplayer->mo && viewplayer->mo->subsector) + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; else phs = -1; diff --git a/src/r_things.c b/src/r_things.c index 068358802..4345f8203 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1581,7 +1581,7 @@ static void R_ProjectSprite(mobj_t *thing) } heightsec = thing->subsector->sector->heightsec; - if (viewplayer->mo && viewplayer->mo->subsector) + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; else phs = -1; -- 2.54.0 From 6a1b10eaf94b133a750020bcf30ba5bb8f6bb2cb Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 19:03:14 +0200 Subject: [PATCH 225/525] Make polyobjects agree with sector lighting/colormap like a FOF. --- src/hardware/hw_main.c | 25 +++++++++++++++---------- src/hardware/hw_main.h | 1 - src/r_bsp.c | 17 ++++++++--------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c36ecf4a9..a8c74656b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2860,41 +2860,45 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); } -void HWR_AddPolyObjectPlanes(void) +static void HWR_AddPolyObjectPlanes(void) { size_t i; sector_t *polyobjsector; + INT32 light = 0; // Polyobject Planes need their own function for drawing because they don't have extrasubsectors by themselves // It should be okay because polyobjects should always be convex anyway for (i = 0; i < numpolys; i++) { + polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector + if (!(po_ptrs[i]->flags & POF_RENDERPLANES)) // Only render planes when you should continue; if (po_ptrs[i]->translucency >= NUMTRANSMAPS) continue; - - polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector if (polyobjsector->floorheight <= gr_frontsector->ceilingheight && polyobjsector->floorheight >= gr_frontsector->floorheight && (viewz < polyobjsector->floorheight)) { + light = R_GetPlaneLight(gr_frontsector, polyobjsector->floorheight, true); if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf; - FBITFIELD blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); + FBITFIELD blendmode; + memset(&Surf, 0x00, sizeof(Surf)); + blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight, - polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : gr_frontsector->lightlist[light].extra_colormap)); } else { HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum, R_NoEncore(polyobjsector, false)); HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude, - polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, - polyobjsector, 255, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), levelflats[polyobjsector->floorpic].lumpnum, + polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : gr_frontsector->lightlist[light].extra_colormap)); } } @@ -2902,6 +2906,7 @@ void HWR_AddPolyObjectPlanes(void) && polyobjsector->ceilingheight <= gr_frontsector->ceilingheight && (viewz > polyobjsector->ceilingheight)) { + light = R_GetPlaneLight(gr_frontsector, polyobjsector->ceilingheight, true); if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf; @@ -2909,14 +2914,14 @@ void HWR_AddPolyObjectPlanes(void) memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight, - polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : gr_frontsector->lightlist[light].extra_colormap)); } else { HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum, R_NoEncore(polyobjsector, true)); HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude, - polyobjsector->lightlevel, levelflats[polyobjsector->ceilingpic].lumpnum, - polyobjsector, 255, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), levelflats[polyobjsector->ceilingpic].lumpnum, + polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : gr_frontsector->lightlist[light].extra_colormap)); } } } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 5c99a77f4..dc87ee986 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -120,7 +120,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap); void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); -void HWR_AddPolyObjectPlanes(void); void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); // hw_main.c: Segs diff --git a/src/r_bsp.c b/src/r_bsp.c index fbb2ea35a..4559c0f58 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1071,10 +1071,10 @@ static void R_Subsector(size_t num) { light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); ffloor[numffloors].plane = R_FindPlane(polysec->floorheight, polysec->floorpic, - polysec->lightlevel, polysec->floor_xoffs, polysec->floor_yoffs, - polysec->floorpic_angle-po->angle, - NULL, NULL, po - , NULL // will ffloors be slopable eventually? + (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->floor_xoffs, polysec->floor_yoffs, + polysec->floorpic_angle-po->angle, + (light == -1 ? frontsector->extra_colormap : frontsector->lightlist[light].extra_colormap), NULL, po + ,NULL // will ffloors be slopable eventually? , R_NoEncore(polysec, false)); ffloor[numffloors].height = polysec->floorheight; @@ -1094,12 +1094,11 @@ static void R_Subsector(size_t num) && polysec->ceilingheight <= ceilingcenterz && (viewz > polysec->ceilingheight)) { - light = R_GetPlaneLight(frontsector, polysec->ceilingheight, viewz < polysec->ceilingheight); + light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic, - polysec->lightlevel, polysec->ceiling_xoffs, polysec->ceiling_yoffs, - polysec->ceilingpic_angle-po->angle, - NULL, NULL, po - , NULL // will ffloors be slopable eventually? + (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->ceiling_xoffs, polysec->ceiling_yoffs, polysec->ceilingpic_angle-po->angle, + (light == -1 ? frontsector->extra_colormap : frontsector->lightlist[light].extra_colormap), NULL, po + ,NULL // will ffloors be slopable eventually? , R_NoEncore(polysec, true)); ffloor[numffloors].polyobj = po; -- 2.54.0 From b4a737d91063cf0bd1fef4aa540549d10dc4206d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Jun 2024 21:28:07 +0200 Subject: [PATCH 226/525] Test: Restore save_p after P_LoadLevel P_LoadLevel calls some functions that save gamedata and unset save_p. this is kinda hacky but i perhaps will port the redone save buffer sometime --- src/p_saveg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index e1569bcbc..a6ed1b807 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3362,6 +3362,7 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(boolean reloading) { UINT32 pig; INT32 i; + UINT8 *old_save_p; if (READUINT32(save_p) != ARCHIVEBLOCK_MISC) I_Error("Bad $$$.sav at archive block Misc"); @@ -3399,12 +3400,17 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(boolean reloading) encoremode = (boolean)READUINT8(save_p); + // FIXME: save_p should not be global!!! + old_save_p = save_p; + if (!P_SetupLevel(true, reloading)) { CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); return false; } + save_p = old_save_p; + // get the time leveltime = READUINT32(save_p); totalrings = READUINT32(save_p); -- 2.54.0 From 4de22e9d669fde717012f0a62c0cf91023c805c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 23:09:04 +0200 Subject: [PATCH 227/525] add gamestateresendattempts so you can specify how often the game tries to resend gamestate to player in given time so they dont get stuck in a synch loop this is gamestateresendattempts value in the time of resynchcooldown *2 --- src/d_clisrv.c | 19 ++++++++++++++++++- src/d_clisrv.h | 2 +- src/d_netcmd.c | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 08f9f3a82..d7aaa1d1b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -10,6 +10,7 @@ /// \file d_clisrv.c /// \brief SRB2 Network game communication and protocol, all OS independent parts. +#include "doomdef.h" #include #ifdef __GNUC__ #include //for unlink @@ -129,6 +130,8 @@ UINT8 hu_redownloadinggamestate = 0; static boolean can_receive_gamestate[MAXNETNODES]; +static UINT8 gamestate_resend_counter[MAXNETNODES]; + // kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks UINT8 hu_stopped = 0; @@ -4068,6 +4071,11 @@ consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, di static CV_PossibleValue_t resynchattempts_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchattempts = {"resynchattempts", "2", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; + +static CV_PossibleValue_t gamestateattempts_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; +consvar_t cv_gamestateattempts = {"gamestateresendattempts", "5", CV_SAVE, gamestateattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; + + static CV_PossibleValue_t resynchcooldown_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchcooldown = {"gamestatecooldown", "5", CV_SAVE, resynchcooldown_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; consvar_t cv_blamecfail = {"blamecfail", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL }; @@ -5298,6 +5306,9 @@ static void HandlePacketFromPlayer(SINT8 node) break; } + if (gamestate_resend_counter[node] && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0)) + gamestate_resend_counter[node] = 0; + // Check player consistancy during the level if (((!can_receive_gamestate[node]) && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (can_receive_gamestate[node] && realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL @@ -5316,8 +5327,14 @@ static void HandlePacketFromPlayer(SINT8 node) resendingsavegame[node] = false; } - if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) + if ((!can_receive_gamestate[node] && cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) || (can_receive_gamestate[node] && (gamestate_resend_counter[node] < cv_gamestateattempts.value))) { + if (can_receive_gamestate[node] && resendingsavegame[node]) + { + gamestate_resend_counter[node]++; + DEBFILE(va("gamestate counter %d for player %d\n", gamestate_resend_counter[node], netconsole)); + } + if (cv_blamecfail.value) CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"), netconsole+1, player_names[netconsole], diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 19f5dae1e..ff7fb4a84 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -573,7 +573,7 @@ extern consvar_t #ifdef VANILLAJOINNEXTROUND cv_joinnextround, #endif - cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; extern consvar_t cv_connectawaittime; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4584ff3da..c09903823 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -779,6 +779,7 @@ void D_RegisterServerCommands(void) // d_clisrv CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); + CV_RegisterVar(&cv_gamestateattempts); CV_RegisterVar(&cv_resynchcooldown); CV_RegisterVar(&cv_maxsend); CV_RegisterVar(&cv_noticedownload); -- 2.54.0 From 283218f2d6561ef2d5d7aa32bb272f27bffa757f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 23:36:13 +0200 Subject: [PATCH 228/525] changuer how this works counter decrements - 1 double the cooldown time --- src/d_clisrv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d7aaa1d1b..dcb3a7eb7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4069,12 +4069,10 @@ static CV_PossibleValue_t discordinvites_cons_t[] = {{0, "Admins Only"}, {1, "Ev consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, discordinvites_cons_t, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t resynchattempts_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; -consvar_t cv_resynchattempts = {"resynchattempts", "2", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; - +consvar_t cv_resynchattempts = {"resynchattempts", "2", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t gamestateattempts_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; -consvar_t cv_gamestateattempts = {"gamestateresendattempts", "5", CV_SAVE, gamestateattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; - +consvar_t cv_gamestateattempts = {"gamestateresendattempts", "10", CV_SAVE, gamestateattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t resynchcooldown_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchcooldown = {"gamestatecooldown", "5", CV_SAVE, resynchcooldown_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; @@ -5306,8 +5304,8 @@ static void HandlePacketFromPlayer(SINT8 node) break; } - if (gamestate_resend_counter[node] && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0)) - gamestate_resend_counter[node] = 0; + if ((gamestate_resend_counter[node] != 0) && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0)) + gamestate_resend_counter[node]--; // Check player consistancy during the level if (((!can_receive_gamestate[node]) && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL -- 2.54.0 From c6351c6c536a310bf6825d8c8114e1391755a121 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 00:55:48 +0200 Subject: [PATCH 229/525] add to menu --- src/m_menu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 674c33d3b..6d3bd2c9a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1911,8 +1911,9 @@ static menuitem_t OP_AdvServerOptionsMenu[] = NULL, "Server Browser Address", &cv_masterserver, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, - {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, + {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 30}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 40}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 50}, {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 60}, {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 70}, {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 80}, @@ -1933,6 +1934,7 @@ static const char* OP_AdvServerOptionsTooltips[] = "Server used for master server.", "Attempts to resynchronise player to server.", "Cooldown in seconds before the Server attempts\nto resend the gamestate to a Saturn Client\nbetween resending attempts.", + "Attempts to resend the Gamestate to player\nThis increments a Counter everytime a gamestate resend occurs\nThis Counter decrements at double the time of the Cooldown\nonce the Counter reaches the threshold, the client gets kicked.", "Maximum allowed delay.", "Delay timeout in seconds.", "Connection timeout in tics.", -- 2.54.0 From 1f41cb9a3f2ac4b5cbfce8bc8c66f5aefc6c937f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 00:59:15 +0200 Subject: [PATCH 230/525] e --- src/m_menu.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 6d3bd2c9a..d88653b51 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1911,20 +1911,20 @@ static menuitem_t OP_AdvServerOptionsMenu[] = NULL, "Server Browser Address", &cv_masterserver, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 30}, - {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 40}, - {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 50}, - {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 60}, - {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 70}, - {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 80}, - {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 90}, + {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 60}, + {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 70}, + {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 80}, + {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 90}, + {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 100}, - {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 110}, - {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 120}, + {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 120}, + {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 130}, - {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 140}, - {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 150}, - {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 160}, + {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 150}, + {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 160}, + {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 170}, }; #endif -- 2.54.0 From 4b71d9a48d847452b7591c0c7cd2293ab8ec85a7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 17:07:59 +0200 Subject: [PATCH 231/525] add "allowsaturnjoin" cvar to let toggle allowjoin for saturn clients seperately --- src/d_clisrv.c | 6 +++++- src/d_clisrv.h | 3 ++- src/d_netcmd.c | 1 + src/m_menu.c | 26 ++++++++++++++------------ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index dcb3a7eb7..dbf2228e6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -146,6 +146,7 @@ static UINT8 mynode; // my address pointofview server static boolean cl_redownloadinggamestate = false; boolean is_client_saturn[MAXNETNODES]; +#define ISSATURN 69 static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen @@ -1441,6 +1442,7 @@ static boolean CL_SendJoin(void) netbuffer->u.clientcfg.subversion = SUBVERSION; strncpy(netbuffer->u.clientcfg.application, SRB2APPLICATION, sizeof netbuffer->u.clientcfg.application); + netbuffer->u.clientcfg.issaturn = ISSATURN; return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak)); } @@ -4057,6 +4059,8 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + #ifdef VANILLAJOINNEXTROUND consvar_t cv_joinnextround = {"joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done #endif @@ -4704,7 +4708,7 @@ static void HandleConnect(SINT8 node) { SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION)); } - else if (!cv_allownewplayer.value && node) + else if ((!cv_allownewplayer.value && node && netbuffer->u.clientcfg.issaturn != ISSATURN) || (!cv_allownewsaturnplayer.value && node && netbuffer->u.clientcfg.issaturn == ISSATURN)) { SV_SendRefuse(node, M_GetText(cv_joinrefusemessage.string)); } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index ff7fb4a84..535485672 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -369,6 +369,7 @@ typedef struct UINT8 subversion; // Contains build version UINT8 localplayers; // number of splitscreen players UINT8 mode; + UINT8 issaturn; } ATTRPACK clientconfig_pak; #define SV_SPEEDMASK 0x03 // used to send kartspeed @@ -573,7 +574,7 @@ extern consvar_t #ifdef VANILLAJOINNEXTROUND cv_joinnextround, #endif - cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_netticbuffer, cv_allownewplayer, cv_allownewsaturnplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; extern consvar_t cv_connectawaittime; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c09903823..db9ce03b8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -788,6 +788,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); + CV_RegisterVar(&cv_allownewsaturnplayer); CV_RegisterVar(&cv_joinrefusemessage); CV_RegisterVar(&cv_chatlogsize); #ifdef VANILLAJOINNEXTROUND diff --git a/src/m_menu.c b/src/m_menu.c index d88653b51..6d5d78c20 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1861,22 +1861,23 @@ static menuitem_t OP_ServerOptionsMenu[] = { #ifndef NONET {IT_STRING | IT_CVAR | IT_CV_STRING, - NULL, "Server Name", &cv_servername, 10}, + NULL, "Server Name", &cv_servername, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, - {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, - {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, - {IT_STRING | IT_CVAR, NULL, "Voting Rule Changes", &cv_kartvoterulechanges, 70}, + {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, + {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, + {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, + {IT_STRING | IT_CVAR, NULL, "Voting Rule Changes", &cv_kartvoterulechanges, 70}, #ifndef NONET - {IT_STRING | IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 90}, - {IT_STRING | IT_CVAR, NULL, "Allow Players to Join", &cv_allownewplayer, 100}, - {IT_STRING | IT_CVAR, NULL, "Allow Addon Downloading", &cv_downloading, 110}, - {IT_STRING | IT_CVAR, NULL, "Pause Permission", &cv_pause, 120}, - {IT_STRING | IT_CVAR, NULL, "Mute All Chat", &cv_mute, 130}, + {IT_STRING | IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 90}, + {IT_STRING | IT_CVAR, NULL, "Allow Vanilla Players to Join", &cv_allownewplayer, 100}, + {IT_STRING | IT_CVAR, NULL, "Allow Saturn Players to Join", &cv_allownewsaturnplayer,110}, + {IT_STRING | IT_CVAR, NULL, "Allow Addon Downloading", &cv_downloading, 120}, + {IT_STRING | IT_CVAR, NULL, "Pause Permission", &cv_pause, 130}, + {IT_STRING | IT_CVAR, NULL, "Mute All Chat", &cv_mute, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_AdvServerOptionsDef,150}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_AdvServerOptionsDef, 160}, #endif }; @@ -1891,7 +1892,8 @@ static const char* OP_ServerOptionsTooltips[] = "How often should other gamemodes appear.", #ifndef NONET "Max amount of players allowed in this server.", - "Allow players to join this server.", + "Allow Vanilla players to join this server.", + "Allow Saturn players to join this server.", "Allow players to download addons.", "Who has permission to pause the server?", "Completely mute in game chat.", -- 2.54.0 From 17dbe77cd3aefdbabef15e89aad087b7c4e9d173 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 17:45:00 +0200 Subject: [PATCH 232/525] allowjoin now sets saturnjoin to its value use CV_StealthSet to prevent its only for scripts pretty much so no need to toggle it seperately --- src/d_clisrv.c | 8 +++++++- src/m_menu.c | 26 ++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index dbf2228e6..9df6dba66 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4059,7 +4059,7 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE|CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef VANILLAJOINNEXTROUND consvar_t cv_joinnextround = {"joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done @@ -4106,6 +4106,12 @@ static void Joinable_OnChange(void) if (!server) return; + // disabling joins should also disable saturn joins unless its called with CV_StealthSet and vice versa to make life a bit easier + if (!cv_allownewplayer.value) + CV_Set(&cv_allownewsaturnplayer, "Off"); + else if (cv_allownewplayer.value) + CV_Set(&cv_allownewsaturnplayer, "On"); + maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); WRITEUINT8(p, maxplayer); diff --git a/src/m_menu.c b/src/m_menu.c index 6d5d78c20..d88653b51 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1861,23 +1861,22 @@ static menuitem_t OP_ServerOptionsMenu[] = { #ifndef NONET {IT_STRING | IT_CVAR | IT_CV_STRING, - NULL, "Server Name", &cv_servername, 10}, + NULL, "Server Name", &cv_servername, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, - {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, - {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, - {IT_STRING | IT_CVAR, NULL, "Voting Rule Changes", &cv_kartvoterulechanges, 70}, + {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, + {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, + {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, + {IT_STRING | IT_CVAR, NULL, "Voting Rule Changes", &cv_kartvoterulechanges, 70}, #ifndef NONET - {IT_STRING | IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 90}, - {IT_STRING | IT_CVAR, NULL, "Allow Vanilla Players to Join", &cv_allownewplayer, 100}, - {IT_STRING | IT_CVAR, NULL, "Allow Saturn Players to Join", &cv_allownewsaturnplayer,110}, - {IT_STRING | IT_CVAR, NULL, "Allow Addon Downloading", &cv_downloading, 120}, - {IT_STRING | IT_CVAR, NULL, "Pause Permission", &cv_pause, 130}, - {IT_STRING | IT_CVAR, NULL, "Mute All Chat", &cv_mute, 140}, + {IT_STRING | IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 90}, + {IT_STRING | IT_CVAR, NULL, "Allow Players to Join", &cv_allownewplayer, 100}, + {IT_STRING | IT_CVAR, NULL, "Allow Addon Downloading", &cv_downloading, 110}, + {IT_STRING | IT_CVAR, NULL, "Pause Permission", &cv_pause, 120}, + {IT_STRING | IT_CVAR, NULL, "Mute All Chat", &cv_mute, 130}, - {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_AdvServerOptionsDef, 160}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_AdvServerOptionsDef,150}, #endif }; @@ -1892,8 +1891,7 @@ static const char* OP_ServerOptionsTooltips[] = "How often should other gamemodes appear.", #ifndef NONET "Max amount of players allowed in this server.", - "Allow Vanilla players to join this server.", - "Allow Saturn players to join this server.", + "Allow players to join this server.", "Allow players to download addons.", "Who has permission to pause the server?", "Completely mute in game chat.", -- 2.54.0 From d6a9cdc45256cb1278a2532e86e686b1bad42d1e Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 18:54:27 +0200 Subject: [PATCH 233/525] fix up bird screen tilting removes old lerp variables that did nothing properly interpolated viewroll made it proper adjust to mobjscale doesent roll view when spectating general cleanup --- src/d_main.c | 3 +++ src/d_player.h | 5 ----- src/hardware/hw_main.c | 22 +++++++++++++-------- src/p_user.c | 35 +++++++++++++------------------- src/r_fps.c | 8 ++++++-- src/r_fps.h | 3 +++ src/r_main.c | 45 ++++++++++++++++++++++++++++++++++++++++-- src/r_main.h | 1 + src/r_state.h | 2 +- 9 files changed, 85 insertions(+), 39 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index e53cdfb6b..d223f8a5c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -263,7 +263,10 @@ static boolean D_Display(void) SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc() if (rendermode == render_soft && !splitscreen) + { + R_InterpolateViewRollAngle(rendertimefrac); R_CheckViewMorph(); + } // change the view size if needed if (setsizeneeded) diff --git a/src/d_player.h b/src/d_player.h index 4d61474fb..183991606 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -541,11 +541,6 @@ typedef struct player_s #ifdef HWRENDER fixed_t fovadd; // adjust FOV for hw rendering #endif - - struct { - angle_t aiming, awayviewaiming, frameangle; - angle_t viewrollangle; - } lerp; } player_t; #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a8c74656b..a4e30729e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -67,6 +67,8 @@ static boolean gr_palette_rendering_state = false; // Commands and console variables // ========================================================================== +static void HWR_RollTransform(FTransform *tr, angle_t roll); + #ifdef USE_FBO_OGL static void CV_grframebuffer_OnChange(void); #endif @@ -5278,8 +5280,7 @@ void HWR_DrawSkyBackground(float fpov) dometransform.scalez = 1; dometransform.fovxangle = fpov; // Tails dometransform.fovyangle = fpov; // Tails - dometransform.rollangle = atransform.rollangle; - dometransform.roll = atransform.roll; + HWR_RollTransform(&dometransform, viewroll); dometransform.splitscreen = splitscreen; HWR_GetTexture(texturetranslation[skytexture], false); @@ -5374,12 +5375,7 @@ void HWR_SetTransform(float fpov, player_t *player) atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails - if (player->viewrollangle != 0) - { - fixed_t rol = AngleFixed(player->viewrollangle); - atransform.rollangle = FIXED_TO_FLOAT(rol); - atransform.roll = true; - } + HWR_RollTransform(&atransform, viewroll); atransform.splitscreen = splitscreen; for (i = 0; i <= splitscreen; i++) @@ -5712,6 +5708,16 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) // ========================================================================== // Render the player view. // ========================================================================== + +static void HWR_RollTransform(FTransform *tr, angle_t roll) +{ + if (roll != 0) + { + tr->rollangle = roll / (float)ANG1; + tr->roll = true; + } +} + void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) { const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on diff --git a/src/p_user.c b/src/p_user.c index 1219414df..610e68dbf 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4253,6 +4253,7 @@ Quaketilt (player_t *player) tilt = ANGLE_22h; lowb = 10*FRACUNIT; } + lowb = FixedMul(lowb, player->mo->scale); moma = FixedMul(FixedDiv(delta, ANGLE_90), tilt); speed = abs( player->mo->momx + player->mo->momy ); if (speed < lowb) @@ -4269,6 +4270,13 @@ DoABarrelRoll (player_t *player) angle_t slope; angle_t delta; + fixed_t smoothing; + + if (player->exiting) + { + return; + } + if (player->mo->standingslope) { slope = player->mo->standingslope->real_zangle; @@ -4293,26 +4301,16 @@ DoABarrelRoll (player_t *player) slope -= Quaketilt(player); } - delta = (INT32)( slope - player->tilt )/ cv_tiltsmoothing.value; + delta = slope - player->tilt; + smoothing = FixedDiv(AbsAngle(slope), ANGLE_45); + + delta = FixedDiv(delta, cv_tiltsmoothing.value * + FixedDiv(FRACUNIT, FRACUNIT + smoothing)); if (delta) player->tilt += delta; else - player->tilt = slope; - - if (cv_tilting.value) - { - player->viewrollangle = player->tilt; - - if (cv_actionmovie.value) - { - player->viewrollangle += quake.roll; - } - } - else - { - player->viewrollangle = 0; - } + player->tilt = slope; } // @@ -4324,11 +4322,6 @@ void P_PlayerThink(player_t *player) ticcmd_t *cmd; const size_t playeri = (size_t)(player - players); - player->lerp.aiming = player->aiming; - player->lerp.awayviewaiming = player->awayviewaiming; - player->lerp.frameangle = player->frameangle; - player->lerp.viewrollangle = player->viewrollangle; - #ifdef PARANOIA if (!player->mo) I_Error("p_playerthink: players[%s].mo == NULL", sizeu1(playeri)); diff --git a/src/r_fps.c b/src/r_fps.c index a5e40ee97..17e357a16 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -145,6 +145,11 @@ static void R_SetupFreelook(void) #undef AIMINGTODY +void R_InterpolateViewRollAngle(fixed_t frac) +{ + viewroll = oldview->roll + R_LerpAngle(oldview->roll, newview->roll, frac); +} + void R_InterpolateView(fixed_t frac, boolean forceinvalid) { viewvars_t* prevview = oldview; @@ -176,12 +181,11 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid) viewangle = R_LerpAngle(prevview->angle, newview->angle, frac); aimingangle = R_LerpAngle(prevview->aim, newview->aim, frac); + viewroll = R_LerpAngle(prevview->roll, newview->roll, frac); viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - // this is gonna create some interesting visual errors for long distance teleports... - // might want to recalculate the view sector every frame instead... viewplayer = newview->player; viewsector = R_PointInSubsector(viewx, viewy)->sector; diff --git a/src/r_fps.h b/src/r_fps.h index 1b7b02cac..a4aef71cd 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -47,6 +47,7 @@ typedef struct { angle_t angle; angle_t aim; + angle_t roll; fixed_t cos; fixed_t sin; mobj_t *mobj; @@ -118,6 +119,8 @@ typedef struct levelinterpolator_s { // Interpolates the current view variables (r_state.h) against the selected view context in R_SetViewContext void R_InterpolateView(fixed_t frac, boolean forceinvalid); +// Special function just for software +void R_InterpolateViewRollAngle(fixed_t frac); // Buffer the current new views into the old views. Call once after each real tic. void R_UpdateViewInterpolation(void); // Reset the view states (e.g. after level load) so R_InterpolateView doesn't interpolate invalid data diff --git a/src/r_main.c b/src/r_main.c index 58810c37b..2b9882122 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -57,7 +57,7 @@ size_t framecount; size_t loopcount; fixed_t viewx, viewy, viewz; -angle_t viewangle, aimingangle; +angle_t viewangle, aimingangle, viewroll; UINT8 viewssnum; fixed_t viewcos, viewsin; boolean skyVisible; @@ -733,7 +733,7 @@ void R_CheckViewMorph(void) INT32 end, vx, vy, pos, usedpos; INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; - angle_t rollangle = players[displayplayers[0]].viewrollangle; + angle_t rollangle = viewroll; rollangle >>= ANGLETOFINESHIFT; rollangle = ((rollangle+2) & ~3) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. @@ -917,6 +917,45 @@ void R_ApplyViewMorph(void) vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); } +static inline int intsign(int n) { + return n < 0 ? -1 : n > 0 ? 1 : 0; +} + +angle_t R_ViewRollAngle(const player_t *player) +{ + angle_t roll = 0; + + if (gamestate != GS_LEVEL) + { + // FIXME: The way this is implemented is totally + // incompatible with cameras that aren't directly + // tied to the player. (podium, titlemap, + // MT_ALTVIEWMAN in general) + + // All of these player variables should affect their + // camera_t in P_MoveChaseCamera, and then this + // just returns that variable instead. + return 0; + } + + roll = player->viewrollangle; + + if (cv_tilting.value) + { + if (!player->spectator && !demo.freecam) + roll += player->tilt; + + if (cv_actionmovie.value) + { + int xs = intsign(quake.x), + ys = intsign(quake.y), + zs = intsign(quake.z); + roll += (xs ^ ys ^ zs) * ANG1; + } + } + + return roll; +} // // R_SetViewSize @@ -1188,6 +1227,7 @@ void R_SkyboxFrame(player_t *player) } } newview->angle += viewmobj->angle; + newview->roll = R_ViewRollAngle(player); newview->player = player; @@ -1471,6 +1511,7 @@ void R_SetupFrame(player_t *player, boolean skybox) } } } + newview->roll = R_ViewRollAngle(player); newview->z += quake.z; newview->player = player; diff --git a/src/r_main.h b/src/r_main.h index 1a589088d..6c59d9961 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -126,6 +126,7 @@ void R_Init(void); void R_CheckViewMorph(void); void R_ApplyViewMorph(void); +angle_t R_ViewRollAngle(const player_t *player); // just sets setsizeneeded true extern boolean setsizeneeded; diff --git a/src/r_state.h b/src/r_state.h index 670f800d1..5234d1d62 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -88,7 +88,7 @@ extern side_t *sides; // POV data. // extern fixed_t viewx, viewy, viewz; -extern angle_t viewangle, aimingangle; +extern angle_t viewangle, aimingangle, viewroll; extern UINT8 viewssnum; // splitscreen view number extern boolean viewsky, skyVisible; extern boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible of each splitscreen player -- 2.54.0 From 2e7f64458d41ef75a16af2aeff56015e060491a2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 18:56:51 +0200 Subject: [PATCH 234/525] forgor this --- src/tables.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tables.h b/src/tables.h index 0ea09caf6..f643895a5 100644 --- a/src/tables.h +++ b/src/tables.h @@ -94,6 +94,12 @@ FUNCMATH FUNCINLINE static ATTRINLINE angle_t InvAngle(angle_t a) { return (ANGLE_MAX-a)+1; } + +// 315 = 45 +FUNCMATH FUNCINLINE static ATTRINLINE angle_t AbsAngle(angle_t a) +{ + return a & ANGLE_180 ? InvAngle(a) : a; +} // angle_t to fixed_t f(ANGLE_45) = 45*FRACUNIT FUNCMATH fixed_t AngleFixed(angle_t af); // fixed_t to angle_t f(45*FRACUNIT) = ANGLE_45 -- 2.54.0 From 98c8176d59f9e59d2f1c1702122e0d932f775918 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 19:01:44 +0200 Subject: [PATCH 235/525] simplify this --- src/p_user.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 610e68dbf..fbdf5dd39 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4221,11 +4221,7 @@ Quaketilt (player_t *player) INT32 delta = (INT32)( player->mo->angle - moma ); fixed_t speed; - boolean sliptiding = - ( - player->kartstuff[k_aizdriftstrat] != 0 && - player->kartstuff[k_drift] == 0 - ); + boolean sliptiding = player->kartstuff[k_drift] ? 0 : player->kartstuff[k_aizdriftstrat]; if (delta == (INT32)ANGLE_180)/* FUCK YOU HAVE A HACK */ { -- 2.54.0 From 6655c0d8817f25d2e5fb8b048344e63b85a59123 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 20:02:20 +0200 Subject: [PATCH 236/525] reset tilt when respawning --- src/p_user.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index fbdf5dd39..9fda4f639 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4273,6 +4273,12 @@ DoABarrelRoll (player_t *player) return; } + if (player->kartstuff[k_respawn]) + { + player->tilt = 0; + return; + } + if (player->mo->standingslope) { slope = player->mo->standingslope->real_zangle; -- 2.54.0 From f6f9542d6e60b0d60087cb8a41e0a60d707c765a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 20:06:01 +0200 Subject: [PATCH 237/525] add cam check here --- src/p_mobj.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index b25a30065..5ac421e73 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3144,7 +3144,12 @@ static void P_SceneryCheckWater(mobj_t *mobj) static boolean P_CameraCheckHeat(camera_t *thiscam) { sector_t *sector; - fixed_t halfheight = thiscam->z + (thiscam->height >> 1); + fixed_t halfheight; + + if (!thiscam) + return false; + + halfheight = thiscam->z + (thiscam->height >> 1); // see if we are in water sector = thiscam->subsector->sector; @@ -3177,7 +3182,12 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) static boolean P_CameraCheckWater(camera_t *thiscam) { sector_t *sector; - fixed_t halfheight = thiscam->z + (thiscam->height >> 1); + fixed_t halfheight; + + if (!thiscam) + return false; + + halfheight = thiscam->z + (thiscam->height >> 1); // see if we are in water sector = thiscam->subsector->sector; -- 2.54.0 From 8dda86490972458840dfc00ee72fb99f53d37cfd Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 20:31:34 +0200 Subject: [PATCH 238/525] toggle palrendering and fbo off if screen textures are disabled --- src/hardware/hw_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a4e30729e..676c018d1 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -206,6 +206,10 @@ static void CV_grshaders_OnChange(void) static void CV_grpaletterendering_OnChange(void) { ONLY_IF_GL_LOADED + + if (cv_grscreentextures.value != 2) // can't do palette rendering without screen textures + CV_Set(&cv_grpaletterendering, "Off"); + if (gr_shadersavailable) { HWR_CompileShaders(); @@ -233,6 +237,12 @@ static void CV_grpalettedepth_OnChange(void) static void CV_grframebuffer_OnChange(void) { ONLY_IF_GL_LOADED + if (cv_grscreentextures.value != 2) + { // screen FBO needs screen textures +#ifdef USE_FBO_OGL + CV_Set(&cv_grframebuffer, "Off"); +#endif + } HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value); I_DownSample(); RefreshOGLSDLSurface(); -- 2.54.0 From 977ee8ccfc5ea4a197afd39d69f0563c3177319a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 21:48:38 +0200 Subject: [PATCH 239/525] make backup of kartconfig before writing to it --- src/m_misc.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/m_misc.h | 1 + 2 files changed, 50 insertions(+) diff --git a/src/m_misc.c b/src/m_misc.c index c40848ecd..8cf20fd65 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -334,6 +334,38 @@ boolean FIL_FileOK(char const *name) return access(name,6)+1; //R_OK|W_OK } +/** Copies contents of one file to another + * + * \param src File to copy from + * \param dst File to write into + * \return true if copy was succesful, false if it doesn't. + */ +boolean FIL_CopyFile(const char *src, const char *dst) +{ + FILE *srcFile = fopen(src, "rb"); + + if (srcFile == NULL) + return false; + + FILE *dstFile = fopen(dst, "wb"); + + if (dstFile == NULL) + { + fclose(srcFile); + return false; + } + + char buffer[1024]; + size_t n; + + while ((n = fread(buffer, 1, sizeof(buffer), srcFile)) > 0) + fwrite(buffer, 1, n, dstFile); + + fclose(srcFile); + fclose(dstFile); + + return true; +} /** Checks if a pathname has a file extension and adds the extension provided * if not. @@ -525,11 +557,28 @@ void M_SaveConfig(const char *filename) { FILE *f; char *filepath; + char backupfile[MAX_WADPATH+4]; // make sure not to write back the config until it's been correctly loaded if (!gameconfig_loaded) return; + // Create backup of the config file + snprintf(backupfile, sizeof backupfile, "%s.bak", configfile); + backupfile[sizeof backupfile - 1] = '\0'; + + FILE *config = fopen(configfile, "r"); + + if (config != NULL) + { + fclose(config); + if (FIL_CopyFile(configfile, backupfile) != false) + { + CONS_Alert(CONS_WARNING,"Failed to create a backup of the configuration file. Will not attempt to write to file\n"); + return; + } + } + // can change the file name if (filename) { diff --git a/src/m_misc.h b/src/m_misc.h index 103b1d88a..333398161 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -54,6 +54,7 @@ boolean FIL_FileExists(const char *name); boolean FIL_WriteFileOK(char const *name); boolean FIL_ReadFileOK(char const *name); boolean FIL_FileOK(char const *name); +boolean FIL_CopyFile(const char *src, const char *dst); void FIL_DefaultExtension (char *path, const char *extension); void FIL_ForceExtension(char *path, const char *extension); -- 2.54.0 From dff6b15263313790e1a3b73a47338a7661501f7c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 22:02:54 +0200 Subject: [PATCH 240/525] fix fail condition --- src/m_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_misc.c b/src/m_misc.c index 8cf20fd65..b8c88abb5 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -572,7 +572,7 @@ void M_SaveConfig(const char *filename) if (config != NULL) { fclose(config); - if (FIL_CopyFile(configfile, backupfile) != false) + if (FIL_CopyFile(configfile, backupfile) == false) { CONS_Alert(CONS_WARNING,"Failed to create a backup of the configuration file. Will not attempt to write to file\n"); return; -- 2.54.0 From 59e4f9ce4ab1d7d514eeab847dee095dc9e4db4b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 25 Jul 2024 16:42:33 +0200 Subject: [PATCH 241/525] let autoload run later to mitigate server join issues itll now run at a similar place to postautoload this may hopefully prevent some issuess with freeslotting lua however sadly this makes menu replacements not work at startup anymore --- src/d_clisrv.c | 11 ++--------- src/d_main.c | 36 +++++++++++++++++++++++++++++------- src/d_main.h | 3 +++ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3e791f7ab..c03584043 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1913,15 +1913,6 @@ static void CL_LoadReceivedSavegame(void) demo.title = false; automapactive = false; - if (!postautoloaded) - { - CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); - if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) - CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfilespost); - postautoloaded = true; - } - // load a base level if (P_LoadNetGame()) { @@ -4308,6 +4299,8 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) if (server && multiplayer && motd[0] != '\0') COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); + D_AddAutoloadFiles(); + LUAh_PlayerJoin(newplayernum); if (newplayernum == consoleplayer) diff --git a/src/d_main.c b/src/d_main.c index d223f8a5c..f1d05a1c0 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -103,11 +103,12 @@ static char *startupwadfiles[MAX_WADFILES]; static char *startuppwads[MAX_WADFILES]; // autoloading -static char *autoloadwadfiles[MAX_WADFILES]; +char *autoloadwadfiles[MAX_WADFILES]; char *autoloadwadfilespost[MAX_WADFILES]; boolean autoloading; boolean autoloaded; -boolean postautoloaded; +boolean postautoloaded = false; +boolean wasautoloaded = false; boolean devparm = false; // started game with -devparm @@ -1105,6 +1106,32 @@ static void D_FindAddonsToAutoload(void) fclose(autoloadconfigfile); } +void D_AddAutoloadFiles(void) +{ + if (wasautoloaded && postautoloaded) + return; + + if (!wasautoloaded && !modeattacking) + { + CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); + if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) + CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); + D_CleanFile(autoloadwadfiles); + + wasautoloaded = true; + } + + if ((!postautoloaded) && netgame) + { + CONS_Printf("D_AutoloadFile(): Loading postloaded addons...\n"); + if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) + CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); + D_CleanFile(autoloadwadfilespost); + + postautoloaded = true; + } +} + void D_CleanFile(char **filearray) { size_t pnumwadfiles; @@ -1791,11 +1818,6 @@ void D_SRB2Main(void) CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); - CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); - if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) - CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfiles); - // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) { diff --git a/src/d_main.h b/src/d_main.h index 23fb31619..d4d3e6e95 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -43,12 +43,15 @@ extern boolean statdp; // stat display for extended player setup extern boolean nametaggfx; // Nametag stuffs extern boolean driftgaugegfx; +void D_AddAutoloadFiles(void); extern boolean autoloading; extern boolean autoloaded; extern boolean postautoloaded; +extern boolean wasautoloaded; extern char *autoloadwadfilespost[MAX_WADFILES]; +extern char *autoloadwadfiles[MAX_WADFILES]; // the infinite loop of D_SRB2Loop() called from win_main for windows version void D_SRB2Loop(void) FUNCNORETURN; -- 2.54.0 From f614725fcb41ab6f7f63ccd93417d6f6f043c0fc Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 25 Jul 2024 19:05:44 +0200 Subject: [PATCH 242/525] some cleanup --- src/p_inter.c | 631 ++++--------------------------------------------- src/p_mobj.c | 83 ++++--- src/p_setup.c | 63 ----- src/p_setup.h | 3 - src/p_spec.c | 423 +-------------------------------- src/r_bsp.c | 4 +- src/r_things.c | 25 +- src/s_sound.c | 66 +++--- src/st_stuff.c | 145 ------------ src/v_video.c | 7 +- src/w_wad.c | 22 +- 11 files changed, 175 insertions(+), 1297 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 90bb3f8da..dbc6e6a3b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -254,26 +254,21 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (heightcheck) { - /*if (special->type == MT_FLINGEMERALD) // little hack here... - { // flingemerald sprites are low to the ground, so extend collision radius down some. - if (toucher->z > (special->z + special->height)) - return; - if (special->z - special->height > (toucher->z + toucher->height)) - return; - } - else*/ + if (toucher->momz < 0) { - if (toucher->momz < 0) { - if (toucher->z + toucher->momz > special->z + special->height) - return; - } else if (toucher->z > special->z + special->height) - return; - if (toucher->momz > 0) { - if (toucher->z + toucher->height + toucher->momz < special->z) - return; - } else if (toucher->z + toucher->height < special->z) + if (toucher->z + toucher->momz > special->z + special->height) return; } + else if (toucher->z > special->z + special->height) + return; + + if (toucher->momz > 0) + { + if (toucher->z + toucher->height + toucher->momz < special->z) + return; + } + else if (toucher->z + toucher->height < special->z) + return; } if (special->health <= 0) @@ -384,16 +379,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) player->kartstuff[k_roulettetype] = 2; } -#if 0 - // Eggbox snipe! - if (special->type == MT_EGGMANITEM && special->health > 1) - S_StartSound(toucher, sfx_bsnipe); -#endif - - { - mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); - S_StartSound(poof, special->info->deathsound); - } + mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); + S_StartSound(poof, special->info->deathsound); if (special->target && special->target->player) { @@ -584,10 +571,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) else K_SpinPlayer(player, special->target, 0, special, false); return; - /*case MT_EERIEFOG: - special->frame &= ~FF_TRANS80; - special->frame |= FF_TRANS90; - return;*/ case MT_SMK_MOLE: if (special->target && !P_MobjWasRemoved(special->target)) return; @@ -936,12 +919,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) player->flyangle = special->threshold; player->speed = FixedMul(special->info->speed, special->scale); - // Potentially causes axis transfer failures. - // Also rarely worked properly anyway. - //P_UnsetThingPosition(player->mo); - //player->mo->x = special->x; - //player->mo->y = special->y; - //P_SetThingPosition(player->mo); toucher->z = special->z+(special->height/4); } else // More like a spring @@ -986,140 +963,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } } return; - /*case MT_NIGHTSSUPERLOOP: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - player->powers[pw_nights_superloop] = (UINT16)special->info->speed; - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - players[i].powers[pw_nights_superloop] = (UINT16)special->info->speed; - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Super Paraloop")); - } - break; - case MT_NIGHTSDRILLREFILL: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - player->drillmeter = special->info->speed; - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - players[i].drillmeter = special->info->speed; - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Drill Refill")); - } - break; - case MT_NIGHTSHELPER: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - { - // A flicky orbits us now - mobj_t *flickyobj = P_SpawnMobj(toucher->x, toucher->y, toucher->z + toucher->info->height, MT_NIGHTOPIANHELPER); - P_SetTarget(&flickyobj->target, toucher); - - player->powers[pw_nights_helper] = (UINT16)special->info->speed; - } - else - { - mobj_t *flickyobj; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].pflags & PF_NIGHTSMODE) { - players[i].powers[pw_nights_helper] = (UINT16)special->info->speed; - flickyobj = P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->info->height, MT_NIGHTOPIANHELPER); - P_SetTarget(&flickyobj->target, players[i].mo); - } - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Nightopian Helper")); - } - break; - case MT_NIGHTSEXTRATIME: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - { - player->nightstime += special->info->speed; - player->startedtime += special->info->speed; - P_RestoreMusic(player); - } - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - { - players[i].nightstime += special->info->speed; - players[i].startedtime += special->info->speed; - P_RestoreMusic(&players[i]); - } - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Extra Time")); - } - break; - case MT_NIGHTSLINKFREEZE: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - { - player->powers[pw_nights_linkfreeze] = (UINT16)special->info->speed; - player->linktimer = 2*TICRATE; - } - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - { - players[i].powers[pw_nights_linkfreeze] += (UINT16)special->info->speed; - players[i].linktimer = 2*TICRATE; - } - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Link Freeze")); - } - break;*/ case MT_NIGHTSWING: if (G_IsSpecialStage(gamemap) && useNightsSS) { // Pseudo-ring. @@ -1515,23 +1358,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) || special->z > toucher->z + (toucher->height*2/3)) return; // Only go in the mouth - /* // SRB2kart - Can't drown. - // Eaten by player! - if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) - P_RestoreMusic(player); - - if (player->powers[pw_underwater] < underwatertics + 1) - player->powers[pw_underwater] = underwatertics + 1; - */ - - /* - if (!player->climbing) - { - P_SetPlayerMobjState(toucher, S_PLAY_GASP); - P_ResetPlayer(player); - } - */ - toucher->momx = toucher->momy = toucher->momz = 0; break; @@ -1588,26 +1414,7 @@ void P_CheckTimeLimit(void) if (gameaction == ga_completed) return; - //Tagmode round end but only on the tic before the - //XD_EXITLEVEL packet is received by all players. - /*if (G_TagGametype()) - { - if (leveltime == (timelimitintics + 1)) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator - || (players[i].pflags & PF_TAGGED) || (players[i].pflags & PF_TAGIT)) - continue; - - CONS_Printf(M_GetText("%s received double points for surviving the round.\n"), player_names[i]); - P_AddPlayerScore(&players[i], players[i].score); - } - } - } - - //Optional tie-breaker for Match/CTF - else*/ if (cv_overtime.value) + if (cv_overtime.value) { INT32 playerarray[MAXPLAYERS]; INT32 tempplayer = 0; @@ -1680,9 +1487,6 @@ void P_CheckTimeLimit(void) return; P_DoPlayerExit(&players[i]); } - - /*if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0);*/ } /** Checks if a player's score is over the pointlimit and the round should end. @@ -1704,127 +1508,27 @@ void P_CheckPointLimit(void) if (G_RaceGametype()) return; - // pointlimit is nonzero, check if it's been reached by this player - /*if (G_GametypeHasTeams()) + for (i = 0; i < MAXPLAYERS; i++) { - // Just check both teams - if ((UINT32)cv_pointlimit.value <= redscore || (UINT32)cv_pointlimit.value <= bluescore) - { - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - } - else*/ - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; + if (!playeringame[i] || players[i].spectator) + continue; - if ((UINT32)cv_pointlimit.value <= players[i].marescore) + if ((UINT32)cv_pointlimit.value <= players[i].marescore) + { + for (i = 0; i < MAXPLAYERS; i++) // AAAAA nested loop using the same iteration variable ;; { - for (i = 0; i < MAXPLAYERS; i++) // AAAAA nested loop using the same iteration variable ;; - { - if (!playeringame[i] || players[i].spectator) - continue; - if (players[i].exiting) - return; - P_DoPlayerExit(&players[i]); - } - - /*if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0);*/ - return; // good thing we're leaving the function immediately instead of letting the loop get mangled! + if (!playeringame[i] || players[i].spectator) + continue; + if (players[i].exiting) + return; + P_DoPlayerExit(&players[i]); } + + return; // good thing we're leaving the function immediately instead of letting the loop get mangled! } } } -/*Checks for untagged remaining players in both tag derivitave modes. - *If no untagged players remain, end the round. - *Also serves as error checking if the only IT player leaves.*/ -/*void P_CheckSurvivors(void) -{ - INT32 i; - INT32 survivors = 0; - INT32 taggers = 0; - INT32 spectators = 0; - INT32 survivorarray[MAXPLAYERS]; - - if (!D_NumPlayers()) //no players in the game, no check performed. - return; - - for (i=0; i < MAXPLAYERS; i++) //figure out counts of taggers, survivors and spectators. - { - if (playeringame[i]) - { - if (players[i].spectator) - spectators++; - else if (players[i].pflags & PF_TAGIT) - taggers++; - else if (!(players[i].pflags & PF_TAGGED)) - { - survivorarray[survivors] = i; - survivors++; - } - } - } - - if (!taggers) //If there are no taggers, pick a survivor at random to be it. - { - // Exception for hide and seek. If a round has started and the IT player leaves, end the round. - if (gametype == GT_HIDEANDSEEK && (leveltime >= (hidetime * TICRATE))) - { - CONS_Printf(M_GetText("The IT player has left the game.\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - - return; - } - - if (survivors) - { - INT32 newtagger = survivorarray[P_RandomKey(survivors)]; - - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[newtagger]); // Tell everyone who is it! - players[newtagger].pflags |= PF_TAGIT; - - survivors--; //Get rid of the guy we just made IT. - - //Yeah, we have an eligible tagger, but we may not have anybody for him to tag! - //If there is only one guy waiting on the game to fill or spectators to enter game, don't bother. - if (!survivors && (D_NumPlayers() - spectators) > 1) - { - CONS_Printf(M_GetText("All players have been tagged!\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - - return; - } - - //If we reach this point, no player can replace the one that was IT. - //Unless it is one player waiting on a game, end the round. - if ((D_NumPlayers() - spectators) > 1) - { - CONS_Printf(M_GetText("There are no players able to become IT.\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - - return; - } - - //If there are taggers, but no survivors, end the round. - //Except when the tagger is by himself and the rest of the game are spectators. - if (!survivors && (D_NumPlayers() - spectators) > 1) - { - CONS_Printf(M_GetText("All players have been tagged!\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } -}*/ - // Checks whether or not to end a race netgame. boolean P_CheckRacers(void) { @@ -1993,14 +1697,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (metalrecording) // Ack! Metal Sonic shouldn't die! Cut the tape, end recording! G_StopMetalRecording(); - /*if (gametype == GT_MATCH && cv_match_scoring.value == 0 // note, no team match suicide penalty - && ((target == source) || (source == NULL && inflictor == NULL) || (source && !source->player))) - { // Suicide penalty - Not in Kart - if (target->player->score >= 50) - target->player->score -= 50; - else - target->player->score = 0; - }*/ target->flags2 &= ~MF2_DONTDRAW; } @@ -2017,85 +1713,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->fuse = cv_itemrespawntime.value*TICRATE + 2; // Random box generation } } - - // Award Score Tails - /*{ // Enemies shouldn't award points in Kart - INT32 score = 0; - - if (maptol & TOL_NIGHTS) // Enemies always worth 200, bosses don't do anything. - { - if ((target->flags & MF_ENEMY) && !(target->flags & (MF_MISSILE|MF_BOSS))) - { - score = 200; - - if (source->player->bonustime) - score *= 2; - - // Also, add to the link. - // I don't know if NiGHTS did this, but - // Sonic Time Attacked did and it seems like a good enough incentive - // to make people want to actually dash towards/paraloop enemies - if (++source->player->linkcount > source->player->maxlink) - source->player->maxlink = source->player->linkcount; - source->player->linktimer = 2*TICRATE; - } - } - else - { - if (target->flags & MF_BOSS) - score = 1000; - else if ((target->flags & MF_ENEMY) && !(target->flags & MF_MISSILE)) - { - mobj_t *scoremobj; - UINT32 scorestate = mobjinfo[MT_SCORE].spawnstate; - - scoremobj = P_SpawnMobj(target->x, target->y, target->z + (target->height / 2), MT_SCORE); - - // On ground? No chain starts. - if (!source->player->powers[pw_invulnerability] && P_IsObjectOnGround(source)) - { - source->player->scoreadd = 0; - score = 100; - } - // Mario Mode has Mario-like chain point values - else if (mariomode) switch (++source->player->scoreadd) - { - case 1: score = 100; break; - case 2: score = 200; scorestate += 1; break; - case 3: score = 400; scorestate += 5; break; - case 4: score = 800; scorestate += 6; break; - case 5: score = 1000; scorestate += 3; break; - case 6: score = 2000; scorestate += 7; break; - case 7: score = 4000; scorestate += 8; break; - case 8: score = 8000; scorestate += 9; break; - default: // 1up for a chain this long - if (modeattacking) // but 1ups don't exist in record attack! - { // So we just go back to 10k points. - score = 10000; scorestate += 4; break; - } - P_GivePlayerLives(source->player, 1); - P_PlayLivesJingle(source->player); - scorestate += 10; - break; - } - // More Sonic-like point system - else switch (++source->player->scoreadd) - { - case 1: score = 100; break; - case 2: score = 200; scorestate += 1; break; - case 3: score = 500; scorestate += 2; break; - case 4: case 5: case 6: case 7: case 8: case 9: - case 10: case 11: case 12: case 13: case 14: - score = 1000; scorestate += 3; break; - default: score = 10000; scorestate += 4; break; - } - - P_SetMobjState(scoremobj, scorestate); - } - } - - P_AddPlayerScore(source->player, score); - }*/ } // if a player avatar dies... @@ -2159,42 +1776,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) if (target->player == &players[displayplayers[3]]) localaiming[3] = 0; - //tag deaths handled differently in suicide cases. Don't count spectators! - /*if (G_TagGametype() - && !(target->player->pflags & PF_TAGIT) && (!source || !source->player) && !(target->player->spectator)) - { - // if you accidentally die before you run out of time to hide, ignore it. - // allow them to try again, rather than sitting the whole thing out. - if (leveltime >= hidetime * TICRATE) - { - if (gametype == GT_TAG)//suiciding in survivor makes you IT. - { - target->player->pflags |= PF_TAGIT; - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[target->player-players]); // Tell everyone who is it! - P_CheckSurvivors(); - } - else - { - if (!(target->player->pflags & PF_TAGGED)) - { - //otherwise, increment the tagger's score. - //in hide and seek, suiciding players are counted as found. - INT32 w; - - for (w=0; w < MAXPLAYERS; w++) - { - if (players[w].pflags & PF_TAGIT) - P_AddPlayerScore(&players[w], 1); - } - - target->player->pflags |= PF_TAGGED; - CONS_Printf(M_GetText("%s was found!\n"), player_names[target->player-players]); - P_CheckSurvivors(); - } - } - } - } - else*/ if (G_BattleGametype()) + if (G_BattleGametype()) K_CheckBumpers(); target->player->kartstuff[k_pogospring] = 0; @@ -2611,26 +2193,6 @@ static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *sou return false; } - // The tag occurs so long as you aren't shooting another tagger with friendlyfire on. - /*if (source->player->pflags & PF_TAGIT && !(player->pflags & PF_TAGIT)) - { - P_AddPlayerScore(source->player, 1); //award points to tagger. - - if (gametype == GT_TAG) //survivor - { - player->pflags |= PF_TAGIT; //in survivor, the player becomes IT and helps hunt down the survivors. - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[player-players]); // Tell everyone who is it! - } - else - { - player->pflags |= PF_TAGGED; //in hide and seek, the player is tagged and stays stationary. - CONS_Printf(M_GetText("%s was found!\n"), player_names[player-players]); // Tell everyone who is it! - } - - //checks if tagger has tagged all players, if so, end round early. - P_CheckSurvivors(); - }*/ - P_DoPlayerPain(player, source, inflictor); // Check for a shield @@ -2669,15 +2231,6 @@ static inline boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj { player_t *player = target->player; - // You can't kill yourself, idiot... // Unless it's Mario kart. Which it is. In this mod. All the time. - //if (source == target) - // return false; - - // In COOP/RACE/CHAOS, you can't hurt other players unless cv_friendlyfire is on - // ...But in SRB2kart, you can! - //if (!cv_friendlyfire.value && (G_RaceGametype())) - // return false; - // Tag handling if (G_TagGametype()) return P_TagDamage(target, inflictor, source, damage); @@ -2729,32 +2282,6 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage) P_SetPlayerMobjState(player->mo, player->mo->info->deathstate); - /*if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - { - P_PlayerFlagBurst(player, false); - if (source && source->player) - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, 1); - } - } - if (source && source->player && !player->powers[pw_super]) //don't score points against super players - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, 1); - } - - // If the player was super, tell them he/she ain't so super nomore. - if (gametype != GT_COOP && player->powers[pw_super]) - { - S_StartSound(NULL, sfx_s3k66); //let all players hear it. - HU_SetCEchoFlags(0); - HU_SetCEchoDuration(5); - HU_DoCEcho(va("%s\\is no longer super.\\\\\\\\", player_names[player-players])); - }*/ - if (player->pflags & PF_TIMEOVER) { mobj_t *boom; @@ -2815,44 +2342,8 @@ void P_RemoveShield(player_t *player) player->powers[pw_shield] = player->powers[pw_shield] & SH_STACK; } -/* -static void P_ShieldDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) // SRB2kart - unused. -{ - // Must do pain first to set flashing -- P_RemoveShield can cause damage - P_DoPlayerPain(player, source, inflictor); - - P_RemoveShield(player); - - P_ForceFeed(player, 40, 10, TICRATE, 40 + min(damage, 100)*2); - - if (source && (source->type == MT_SPIKE || (source->type == MT_NULL && source->threshold == 43))) // spikes - S_StartSound(player->mo, sfx_spkdth); - else - S_StartSound (player->mo, sfx_shldls); // Ba-Dum! Shield loss. - - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - { - P_PlayerFlagBurst(player, false); - if (source && source->player) - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, 25); - } - } - if (source && source->player && !player->powers[pw_super]) //don't score points against super players - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, cv_match_scoring.value == 1 ? 25 : 50); - } -} -*/ - static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) { - //const UINT8 scoremultiply = ((K_IsWantedPlayer(player) && !trapitem) : 2 ? 1); - if (!(inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player) && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) { P_DoPlayerPain(player, source, inflictor); @@ -2863,24 +2354,6 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN S_StartSound(player->mo, sfx_spkdth); } - /*if (source && source->player && !player->powers[pw_super]) //don't score points against super players - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, scoremultiply); - } - - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - { - P_PlayerFlagBurst(player, false); - if (source && source->player) - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, scoremultiply); - } - }*/ - // Ring loss sound plays despite hitting spikes P_PlayRinglossSound(player->mo); // Ringledingle! } @@ -3680,32 +3153,30 @@ void P_PlayerFlagBurst(player_t *player, boolean toss) P_SetTarget(&flag->target, player->mo); // Flag text + char plname[MAXPLAYERNAME+4]; + const char *flagtext; + char flagcolor; + + snprintf(plname, sizeof(plname), "%s%s%s", + CTFTEAMCODE(player), + player_names[player - players], + CTFTEAMENDCODE(player)); + + if (type == MT_REDFLAG) { - char plname[MAXPLAYERNAME+4]; - const char *flagtext; - char flagcolor; - - snprintf(plname, sizeof(plname), "%s%s%s", - CTFTEAMCODE(player), - player_names[player - players], - CTFTEAMENDCODE(player)); - - if (type == MT_REDFLAG) - { - flagtext = M_GetText("Red flag"); - flagcolor = '\x85'; - } - else - { - flagtext = M_GetText("Blue flag"); - flagcolor = '\x84'; - } - - if (toss) - CONS_Printf(M_GetText("%s tossed the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); - else - CONS_Printf(M_GetText("%s dropped the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); + flagtext = M_GetText("Red flag"); + flagcolor = '\x85'; } + else + { + flagtext = M_GetText("Blue flag"); + flagcolor = '\x84'; + } + + if (toss) + CONS_Printf(M_GetText("%s tossed the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); + else + CONS_Printf(M_GetText("%s dropped the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); player->gotflag = 0; diff --git a/src/p_mobj.c b/src/p_mobj.c index 5ac421e73..5e5b9924b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4988,13 +4988,15 @@ static void P_Boss9Thinker(mobj_t *mobj) else mobj->momz = (mobj->watertop-mobj->z)/40; // Float to your desired position - if (mobj->movecount == 2) { + if (mobj->movecount == 2) + { mobj_t *spawner; fixed_t dist = 0; angle = 0x06000000*leveltime; // Alter your energy bubble's size/position - if (mobj->health > 3) { + if (mobj->health > 3) + { mobj->tracer->destscale = FRACUNIT + (4*TICRATE - mobj->fuse)*(FRACUNIT/2)/TICRATE + FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT),FRACUNIT/2); P_SetScale(mobj->tracer, mobj->tracer->destscale); P_SetOrigin(mobj->tracer, mobj->x, mobj->y, mobj->z + mobj->height/2 - mobj->tracer->height/2); @@ -5030,8 +5032,10 @@ static void P_Boss9Thinker(mobj_t *mobj) } // Pre-threshold reactiontime stuff for attack phases - if (mobj->reactiontime && mobj->movecount == 3) { - if (mobj->movedir == 0 || mobj->movedir == 2) { // Pausing between bounces in the pinball phase + if (mobj->reactiontime && mobj->movecount == 3) + { + if (mobj->movedir == 0 || mobj->movedir == 2) // Pausing between bounces in the pinball phase + { if (mobj->target->player->powers[pw_tailsfly]) // Trying to escape, eh? mobj->watertop = mobj->target->z + mobj->target->momz*6; // Readjust your aim. >:3 else @@ -5045,13 +5049,16 @@ static void P_Boss9Thinker(mobj_t *mobj) } // threshold is used for attacks/maneuvers. - if (mobj->threshold) { + if (mobj->threshold) + { fixed_t speed = 20*FRACUNIT + FixedMul(40*FRACUNIT, FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth<movecount == 3 && mobj->movedir == 1) { - if (!(mobj->threshold&1)) { + if (mobj->movecount == 3 && mobj->movedir == 1) + { + if (!(mobj->threshold&1)) + { mobj_t *missile; if (mobj->info->seesound) S_StartSound(mobj, mobj->info->seesound); @@ -5063,18 +5070,21 @@ static void P_Boss9Thinker(mobj_t *mobj) A_FaceTarget(mobj); missile = P_SpawnMissile(mobj, mobj->target, mobj->info->speed); - if (mobj->extravalue1 == 2 || mobj->extravalue1 == 3) { + if (mobj->extravalue1 == 2 || mobj->extravalue1 == 3) + { missile->destscale = FRACUNIT>>1; P_SetScale(missile, missile->destscale); } missile->fuse = 3*TICRATE; missile->z -= missile->height/2; - if (mobj->extravalue1 == 2) { + if (mobj->extravalue1 == 2) + { int i; mobj_t *spread; missile->flags |= MF_MISSILE; - for (i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) + { if (i == 2) continue; spread = P_SpawnMobj(missile->x, missile->y, missile->z, missile->type); @@ -5087,7 +5097,9 @@ static void P_Boss9Thinker(mobj_t *mobj) } missile->flags &= ~MF_MISSILE; } - } else { + } + else + { P_SetMobjState(mobj, mobj->state->nextstate); if (mobj->extravalue1 == 3) mobj->reactiontime = TICRATE/8; @@ -5101,7 +5113,8 @@ static void P_Boss9Thinker(mobj_t *mobj) P_SpawnGhostMobj(mobj); // Pinball attack! - if (mobj->movecount == 3 && (mobj->movedir == 0 || mobj->movedir == 2)) { + if (mobj->movecount == 3 && (mobj->movedir == 0 || mobj->movedir == 2)) + { if ((statenum_t)(mobj->state-states) != mobj->info->seestate) P_SetMobjState(mobj, mobj->info->seestate); if (mobj->movedir == 0) // mobj health == 1 @@ -5110,16 +5123,22 @@ static void P_Boss9Thinker(mobj_t *mobj) P_InstaThrust(mobj, mobj->angle, 22*FRACUNIT); else // mobj health == 2 P_InstaThrust(mobj, mobj->angle, 30*FRACUNIT); - if (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true)) { // Hit a wall? Find a direction to bounce + + if (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true)) // Hit a wall? Find a direction to bounce + { mobj->threshold--; - if (mobj->threshold) { + if (mobj->threshold) + { P_SetMobjState(mobj, mobj->state->nextstate); if (mobj->info->mass) S_StartSound(mobj, mobj->info->mass); - if (!(mobj->threshold%4)) { // We've decided to lock onto the player this bounce. + if (!(mobj->threshold%4)) // We've decided to lock onto the player this bounce. + { mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x + mobj->target->momx*4, mobj->target->y + mobj->target->momy*4); mobj->reactiontime = TICRATE; // targetting time - } else { // No homing, just use P_BounceMove + } + else // No homing, just use P_BounceMove + { P_BounceMove(mobj); mobj->angle = R_PointToAngle2(0,0,mobj->momx,mobj->momy); mobj->reactiontime = TICRATE/4; // just a pause before you bounce away @@ -5133,7 +5152,8 @@ static void P_Boss9Thinker(mobj_t *mobj) // Vector form dodge! mobj->angle += mobj->movedir; P_InstaThrust(mobj, mobj->angle, -speed); - while (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true) && tries++ < 16) { + while (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true) && tries++ < 16) + { mobj->angle += mobj->movedir; P_InstaThrust(mobj, mobj->angle, -speed); } @@ -5189,9 +5209,10 @@ static void P_Boss9Thinker(mobj_t *mobj) if (mobj->flags2 & MF2_FRET) return; - if (mobj->state == &states[mobj->info->raisestate]) - { // Charging energy - if (mobj->momx != 0 || mobj->momy != 0) { // Apply the air breaks + if (mobj->state == &states[mobj->info->raisestate]) // Charging energy + { + if (mobj->momx != 0 || mobj->momy != 0) // Apply the air breaks + { if (abs(mobj->momx)+abs(mobj->momy) < FRACUNIT) mobj->momx = mobj->momy = 0; else @@ -5216,7 +5237,8 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->watertop = mobj->target->floorz + 256*FRACUNIT; break; - case 1: { + case 1: + { // Okay, we're up? Good, time to gather energy... if (mobj->health > mobj->info->damage) { // No more bubble if we're broken (pinch phase) @@ -5242,7 +5264,8 @@ static void P_Boss9Thinker(mobj_t *mobj) P_SetTarget(&mobj->tracer, mobj->hnext); P_RemoveMobj(removemobj); } - if (mobj->health <= mobj->info->damage) { + if (mobj->health <= mobj->info->damage) + { // Attack 1: Pinball dash! if (mobj->health == 1) mobj->movedir = 0; @@ -5257,7 +5280,9 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->threshold = 32; // bounce 32 times mobj->watertop = mobj->target->floorz + 16*FRACUNIT; P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); - } else { + } + else + { // Attack 2: Energy shot! mobj->movedir = 1; @@ -5270,7 +5295,8 @@ static void P_Boss9Thinker(mobj_t *mobj) else mobj->extravalue1 = 3; - switch(mobj->extravalue1) { + switch(mobj->extravalue1) + { case 0: // shoot once case 2: // spread-shot default: @@ -5334,7 +5360,8 @@ static void P_Boss9Thinker(mobj_t *mobj) danger = false; if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) danger = false; - if (danger) { + if (danger) + { // An incoming attack is detected! What should we do?! // Go into vector form! mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth-1)<hnext; mo = mo->hnext) ; @@ -5881,7 +5909,8 @@ static void P_AddShadow(mobj_t *thing) if (shadowcap == NULL) P_SetTarget(&shadowcap, thing); - else { + else + { mobj_t *mo; for (mo = shadowcap; mo && mo->hnext; mo = mo->hnext) ; diff --git a/src/p_setup.c b/src/p_setup.c index 0a868ef8c..a1f0ff8e8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -800,69 +800,6 @@ void P_ReloadRings(void) } } -#ifdef SCANTHINGS -void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum) -{ - size_t i, n; - UINT8 *data, *datastart; - UINT16 type, maprings; - INT16 tol; - UINT32 flags; - - tol = mapheaderinfo[mapnum-1]->typeoflevel; - if (!(tol & TOL_SP)) - return; - flags = mapheaderinfo[mapnum-1]->levelflags; - - n = W_LumpLengthPwad(wadnum, lumpnum) / (5 * sizeof (INT16)); - //CONS_Printf("%u map things found!\n", n); - - maprings = 0; - data = datastart = W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); - for (i = 0; i < n; i++) - { - data += 3 * sizeof (INT16); // skip x y position, angle - type = READUINT16(data) & 4095; - data += sizeof (INT16); // skip options - - switch (type) - { - case 300: // MT_RING - case 1800: // MT_COIN - case 308: // red team ring - case 309: // blue team ring - maprings++; - break; - case 400: // MT_SUPERRINGBOX - case 414: // red ring box - case 415: // blue ring box - case 603: // 10 diagonal rings - maprings += 10; - break; - case 600: // 5 vertical rings - case 601: // 5 vertical rings - case 602: // 5 diagonal rings - maprings += 5; - break; - case 604: // 8 circle rings - case 609: // 16 circle rings & wings - maprings += 8; - break; - case 605: // 16 circle rings - maprings += 16; - break; - case 608: // 8 circle rings & wings - maprings += 4; - break; - } - } - Z_Free(datastart); - - if (maprings) - CONS_Printf("%s has %u rings\n", G_BuildMapName(mapnum), maprings); -} -#endif - // // P_LoadThings // diff --git a/src/p_setup.h b/src/p_setup.h index 5df0f0b68..8a77c690b 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -59,9 +59,6 @@ extern size_t nummapthings; extern mapthing_t *mapthings; void P_SetupLevelSky(INT32 skynum, boolean global); -#ifdef SCANTHINGS -void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); -#endif void P_LoadThingsOnly(void); boolean P_SetupLevel(boolean skipprecip); #ifdef HWRENDER diff --git a/src/p_spec.c b/src/p_spec.c index 1bde9a72e..e0092f1ee 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -622,48 +622,6 @@ void P_SetupLevelFlatAnims(void) // UTILITIES // -#if 0 -/** Gets a side from a sector line. - * - * \param currentSector Sector the line is in. - * \param line Index of the line within the sector. - * \param side 0 for front, 1 for back. - * \return Pointer to the side_t of the side you want. - * \sa getSector, twoSided, getNextSector - */ -static inline side_t *getSide(INT32 currentSector, INT32 line, INT32 side) -{ - return &sides[(sectors[currentSector].lines[line])->sidenum[side]]; -} - -/** Gets a sector from a sector line. - * - * \param currentSector Sector the line is in. - * \param line Index of the line within the sector. - * \param side 0 for front, 1 for back. - * \return Pointer to the ::sector_t of the sector on that side. - * \sa getSide, twoSided, getNextSector - */ -static inline sector_t *getSector(INT32 currentSector, INT32 line, INT32 side) -{ - return sides[(sectors[currentSector].lines[line])->sidenum[side]].sector; -} - -/** Determines whether a sector line is two-sided. - * Uses the Boom method, checking if the line's back side is set to -1, rather - * than looking for ::ML_TWOSIDED. - * - * \param sector The sector. - * \param line Line index within the sector. - * \return 1 if the sector is two-sided, 0 otherwise. - * \sa getSide, getSector, getNextSector - */ -static inline boolean twoSided(INT32 sector, INT32 line) -{ - return (sectors[sector].lines[line])->sidenum[1] != 0xffff; -} -#endif - /** Finds sector next to current. * * \param line Pointer to the line to cross. @@ -822,77 +780,6 @@ fixed_t P_FindNextLowestFloor(sector_t *sec, fixed_t currentheight) return currentheight; } -#if 0 -/** Finds next lowest ceiling in adjacent sectors. - * - * \param sec Sector to start in. - * \param currentheight Height to start at. - * \return Next lowest ceiling height in an adjacent sector, or currentheight - * if there are none lower. - * \sa P_FindLowestCeilingSurrounding, P_FindNextHighestCeiling, - * P_FindNextLowestFloor - * \author Lee Killough - */ -static fixed_t P_FindNextLowestCeiling(sector_t *sec, fixed_t currentheight) -{ - sector_t *other; - size_t i; - fixed_t height; - - for (i = 0; i < sec->linecount; i++) - { - other = getNextSector(sec->lines[i],sec); - if (other && other->ceilingheight < currentheight) - { - height = other->ceilingheight; - while (++i < sec->linecount) - { - other = getNextSector(sec->lines[i],sec); - if (other && other->ceilingheight > height - && other->ceilingheight < currentheight) - height = other->ceilingheight; - } - return height; - } - } - return currentheight; -} - -/** Finds next highest ceiling in adjacent sectors. - * - * \param sec Sector to start in. - * \param currentheight Height to start at. - * \return Next highest ceiling height in an adjacent sector, or currentheight - * if there are none higher. - * \sa P_FindHighestCeilingSurrounding, P_FindNextLowestCeiling, - * P_FindNextHighestFloor - * \author Lee Killough - */ -static fixed_t P_FindNextHighestCeiling(sector_t *sec, fixed_t currentheight) -{ - sector_t *other; - size_t i; - fixed_t height; - - for (i = 0; i < sec->linecount; i++) - { - other = getNextSector(sec->lines[i], sec); - if (other && other->ceilingheight > currentheight) - { - height = other->ceilingheight; - while (++i < sec->linecount) - { - other = getNextSector(sec->lines[i],sec); - if (other && other->ceilingheight < height - && other->ceilingheight > currentheight) - height = other->ceilingheight; - } - return height; - } - } - return currentheight; -} -#endif //////////////////////////// // End New Boom functions @@ -962,133 +849,6 @@ fixed_t P_FindHighestCeilingSurrounding(sector_t *sec) return height; } -#if 0 -//SoM: 3/7/2000: UTILS..... -// -// P_FindShortestTextureAround() -// -// Passed a sector number, returns the shortest lower texture on a -// linedef bounding the sector. -// -// -static fixed_t P_FindShortestTextureAround(INT32 secnum) -{ - fixed_t minsize = 32000<linecount; i++) - { - if (twoSided(secnum, i)) - { - side = getSide(secnum,i,0); - if (side->bottomtexture > 0) - if (textureheight[side->bottomtexture] < minsize) - minsize = textureheight[side->bottomtexture]; - side = getSide(secnum,i,1); - if (side->bottomtexture > 0) - if (textureheight[side->bottomtexture] < minsize) - minsize = textureheight[side->bottomtexture]; - } - } - return minsize; -} - -//SoM: 3/7/2000: Stuff.... (can you tell I'm getting tired? It's 12 : 30!) -// -// P_FindShortestUpperAround() -// -// Passed a sector number, returns the shortest upper texture on a -// linedef bounding the sector. -// -// -static fixed_t P_FindShortestUpperAround(INT32 secnum) -{ - fixed_t minsize = 32000<linecount; i++) - { - if (twoSided(secnum, i)) - { - side = getSide(secnum,i,0); - if (side->toptexture > 0) - if (textureheight[side->toptexture] < minsize) - minsize = textureheight[side->toptexture]; - side = getSide(secnum,i,1); - if (side->toptexture > 0) - if (textureheight[side->toptexture] < minsize) - minsize = textureheight[side->toptexture]; - } - } - return minsize; -} - -//SoM: 3/7/2000 -// -// P_FindModelFloorSector() -// -// Passed a floor height and a sector number, return a pointer to a -// a sector with that floor height across the lowest numbered two sided -// line surrounding the sector. -// -// Note: If no sector at that height bounds the sector passed, return NULL -// -// -static sector_t *P_FindModelFloorSector(fixed_t floordestheight, INT32 secnum) -{ - size_t i; - sector_t *sec = §ors[secnum]; - - for (i = 0; i < sec->linecount; i++) - { - if (twoSided(secnum, i)) - { - if (getSide(secnum,i,0)->sector-sectors == secnum) - sec = getSector(secnum,i,1); - else - sec = getSector(secnum,i,0); - - if (sec->floorheight == floordestheight) - return sec; - } - } - return NULL; -} - -// -// P_FindModelCeilingSector() -// -// Passed a ceiling height and a sector number, return a pointer to a -// a sector with that ceiling height across the lowest numbered two sided -// line surrounding the sector. -// -// Note: If no sector at that height bounds the sector passed, return NULL -// -static sector_t *P_FindModelCeilingSector(fixed_t ceildestheight, INT32 secnum) -{ - size_t i; - sector_t *sec = §ors[secnum]; - - for (i = 0; i < sec->linecount; i++) - { - if (twoSided(secnum, i)) - { - if (getSide(secnum, i, 0)->sector - sectors == secnum) - sec = getSector(secnum, i, 1); - else - sec = getSector(secnum, i, 0); - - if (sec->ceilingheight == ceildestheight) - return sec; - } - } - return NULL; -} -#endif /** Searches the tag lists for the next sector tagged to a line. * @@ -1176,37 +936,8 @@ static INT32 P_FindLineFromLineTag(const line_t *line, INT32 start) return start; } } -#if 0 -/** Searches the tag lists for the next line with a given tag and special. - * - * \param tag Tag number. - * \param start -1 to start anew, or the result of a previous call to keep - * searching. - * \return Number of next suitable line found. - * \sa P_FindLineFromLineTag - * \author Graue - */ -static INT32 P_FindLineFromTag(INT32 tag, INT32 start) -{ - if (tag == -1) - { - start++; - if (start >= numlines) - return -1; - return start; - } - else - { - start = start >= 0 ? lines[start].nexttag : - lines[(unsigned)tag % numlines].firsttag; - while (start >= 0 && lines[start].tag != tag) - start = lines[start].nexttag; - return start; - } -} -#endif // // P_FindSpecialLineFromTag // @@ -1707,17 +1438,11 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (actor && actor->player && triggerline->flags & ML_EFFECT4) { - /*if (maptol & TOL_NIGHTS) - lap = actor->player->mare; - else*/ - lap = actor->player->laps; + lap = actor->player->laps; } else { - /*if (maptol & TOL_NIGHTS) - lap = P_FindLowestMare(); - else*/ - lap = P_FindLowestLap(); + lap = P_FindLowestLap(); } if (triggerline->flags & ML_NOCLIMB) // Need higher than or equal to @@ -1754,12 +1479,6 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller switch (specialtype) { - /*case 305: // continuous - case 306: // each time - case 307: // once - if (!(actor && actor->player && actor->player->charability == dist/10)) - return false; - break;*/ case 309: // continuous case 310: // each time // Only red team members can activate this. @@ -1930,9 +1649,8 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller // "Trigger on X calls" linedefs reset if noclimb is set if ((specialtype == 321 || specialtype == 322) && triggerline->flags & ML_NOCLIMB) triggerline->callcount = sides[triggerline->sidenum[0]].textureoffset>>FRACBITS; - else // These special types work only once - if (specialtype == 302 // Once + else if (specialtype == 302 // Once || specialtype == 304 // Ring count - Once || specialtype == 307 // Character ability - Once || specialtype == 308 // Race only - Once @@ -2300,22 +2018,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) EV_DoCeiling(line, moveCeilingByFrontTexture); break; -/* case 405: // Lower floor by line, dx = speed, dy = amount to lower - EV_DoFloor(line, lowerFloorByLine); - break; - - case 406: // Raise floor by line, dx = speed, dy = amount to raise - EV_DoFloor(line, raiseFloorByLine); - break; - - case 407: // Lower ceiling by line, dx = speed, dy = amount to lower - EV_DoCeiling(line, lowerCeilingByLine); - break; - - case 408: // Raise ceiling by line, dx = speed, dy = amount to raise - EV_DoCeiling(line, raiseCeilingByLine); - break;*/ - case 409: // Change tagged sectors' tag // (formerly "Change calling sectors' tag", but behavior was changed) { @@ -2901,7 +2603,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Copy effect to bot if necessary // (Teleport them to you so they don't break it.) - if (bot && (bot->flags2 & MF2_TWOD) != (mo->flags2 & MF2_TWOD)) { + if (bot && (bot->flags2 & MF2_TWOD) != (mo->flags2 & MF2_TWOD)) + { bot->flags2 = (bot->flags2 & ~MF2_TWOD) | (mo->flags2 & MF2_TWOD); P_SetOrigin(bot, mo->x, mo->y, mo->z); } @@ -2934,7 +2637,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetTarget(&dummy->target, mo); A_CustomPower(dummy); - if (bot) { + if (bot) + { P_SetTarget(&dummy->target, bot); A_CustomPower(dummy); } @@ -3528,10 +3232,6 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar if (rover->master->frontsector != sector) continue; - // we're assuming the FOF existed when the first player touched it - //if (!(rover->flags & FF_EXISTS)) - // return false; - top = P_GetSpecialTopZ(mo, sector, targetsec); bottom = P_GetSpecialBottomZ(mo, sector, targetsec); @@ -4067,8 +3767,6 @@ DoneSection2: player->mo->momz = mobjinfo[MT_FAN].mass; P_ResetPlayer(player); - //if (player->panim != PA_FALL) // SRB2kart - // P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); break; case 6: // SRB2kart 190117 - Sneaker Panel @@ -4240,12 +3938,6 @@ DoneSection2: if (!(player->mo->state >= &states[S_KART_RUN1] && player->mo->state <= &states[S_KART_RUN2])) P_SetPlayerMobjState(player->mo, S_KART_RUN1); - - //if (!(player->mo->state >= &states[S_PLAY_ATK1] && player->mo->state <= &states[S_PLAY_ATK4])) // SRB2kart - //{ - // P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - // S_StartSound(player->mo, sfx_spin); - //} } break; @@ -4900,12 +4592,6 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) break; } - // Check Section 3 -/* switch(GETSECSPECIAL(sector->special, 3)) - { - - }*/ - // Check Section 4 switch(GETSECSPECIAL(sector->special, 4)) { @@ -5319,42 +5005,6 @@ static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline) R_CreateInterpolator_SectorPlane(&floater->thinker, sec, true); } -/** Adds a bridge thinker. - * Bridge thinkers cause a group of FOFs to behave like - * a bridge made up of pieces, that bows under weight. - * - * \param sec Control sector. - * \sa P_SpawnSpecials, T_BridgeThinker - * \author SSNTails - */ -/* -static inline void P_AddBridgeThinker(line_t *sourceline, sector_t *sec) -{ - levelspecthink_t *bridge; - - // create an initialize new thinker - bridge = Z_Calloc(sizeof (*bridge), PU_LEVSPEC, NULL); - P_AddThinker(&bridge->thinker); - - bridge->thinker.function.acp1 = (actionf_p1)T_BridgeThinker; - - bridge->sector = sec; - bridge->vars[0] = sourceline->frontsector->floorheight; - bridge->vars[1] = sourceline->frontsector->ceilingheight; - bridge->vars[2] = P_AproxDistance(sourceline->dx, sourceline->dy); // Speed - bridge->vars[2] = FixedDiv(bridge->vars[2], 16*FRACUNIT); - bridge->vars[3] = bridge->vars[2]; - - // Start tag and end tag are TARGET SECTORS, not CONTROL SECTORS - // Control sector tags should be End_Tag + (End_Tag - Start_Tag) - bridge->vars[4] = sourceline->tag; // Start tag - bridge->vars[5] = (sides[sourceline->sidenum[0]].textureoffset>>FRACBITS); // End tag - - // interpolation - R_CreateInterpolator_SectorPlane(&bridge->thinker, §ors[affectee], false); -} -*/ - /** Adds a Mario block thinker, which changes the block's texture between blank * and ? depending on whether it has contents. * Needed in case objects respawn inside. @@ -5772,12 +5422,6 @@ void P_SpawnSpecials(INT32 fromnetsave) break; } - // Process Section 3 -/* switch(GETSECSPECIAL(player->specialsector, 3)) - { - - }*/ - // Process Section 4 switch(GETSECSPECIAL(sector->special, 4)) { @@ -5863,16 +5507,6 @@ void P_SpawnSpecials(INT32 fromnetsave) lines[i].special = 0; continue; } - /*else -- commented out because irrelevant to kart. keeping here because we can use these flags for something else now - { - if ((players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) - || (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) - || (players[consoleplayer].charability == CA_GLIDEANDCLIMB && (lines[i].flags & ML_NOKNUX))) - { - lines[i].special = 0; - continue; - } - }*/ } switch (lines[i].special) @@ -6053,12 +5687,14 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 64: // Appearing/Disappearing FOF option - if (lines[i].flags & ML_BLOCKMONSTERS) { // Find FOFs by control sector tag + if (lines[i].flags & ML_BLOCKMONSTERS) // Find FOFs by control sector tag + { for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); - } else // Find FOFs by effect sector tag + } + else // Find FOFs by effect sector tag for (s = -1; (s = P_FindLineFromLineTag(lines + i, s)) >= 0 ;) { if ((size_t)s == i) @@ -6069,10 +5705,6 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 65: // Bridge Thinker - /* - // Disable this until it's working right! - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - P_AddBridgeThinker(&lines[i], §ors[s]);*/ break; case 100: // FOF (solid, opaque, shadows) @@ -7301,7 +6933,7 @@ void T_Disappear(disappear_t *d) if (*rover->t_slope) sectors[s].soundorg.z = P_GetZAt(*rover->t_slope, sectors[s].soundorg.x, sectors[s].soundorg.y); else - sectors[s].soundorg.z = *rover->topheight; + sectors[s].soundorg.z = *rover->topheight; S_StartSound(§ors[s].soundorg, sfx_appear); } } @@ -7375,17 +7007,6 @@ void T_Friction(friction_t *f) //{ referrer = sectors + f->referrer; - /* if (!(GETSECSPECIAL(referrer->special, 3) == 1 - || GETSECSPECIAL(referrer->special, 3) == 3)) - return; - } - else - { - if (!(GETSECSPECIAL(sec->special, 3) == 1 - || GETSECSPECIAL(sec->special, 3) == 3)) - return; - }*/ - // Assign the friction value to players on the floor, non-floating, // and clipped. Normally the object's friction value is kept at // ORIG_FRICTION and this thinker changes it for icy or muddy floors. @@ -7725,14 +7346,11 @@ void T_Pusher(pusher_t *p) { referrer = §ors[p->referrer]; - //if (!(GETSECSPECIAL(referrer->special, 3) == 2 - // || GETSECSPECIAL(referrer->special, 3) == 3)) if (GETSECSPECIAL(referrer->special, 3) != 2) return; } - //else if (!(GETSECSPECIAL(sec->special, 3) == 2 - // || GETSECSPECIAL(sec->special, 3) == 3)) else if (GETSECSPECIAL(sec->special, 3) != 2) + // For constant pushers (wind/current) there are 3 situations: // // 1) Affected Thing is above the floor. @@ -7970,14 +7588,6 @@ void T_Pusher(pusher_t *p) else localangle[3] += (thing->angle - localangle[3]) / 8; } - /*if (thing->player == &players[consoleplayer]) - localangle[0] = thing->angle; - else if (thing->player == &players[displayplayers[1]]) - localangle[1] = thing->angle; - else if (thing->player == &players[displayplayers[2]]) - localangle[2] = thing->angle; - else if (thing->player == &players[displayplayers[3]]) - localangle[3] = thing->angle;*/ } } @@ -8089,13 +7699,6 @@ static void P_SearchForDisableLinedefs(void) } else if ((lines[i].flags & ML_NETONLY) == ML_NETONLY) continue; // Net-only never triggers in single player - // commented out because irrelevant to kart. keeping here because we can use these flags for something else now - /*else if (players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) - continue; - else if (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) - continue; - else if (players[consoleplayer].charability == CA_GLIDEANDCLIMB && (lines[i].flags & ML_NOKNUX)) - continue;*/ // Disable any linedef specials with our tag. for (j = -1; (j = P_FindLineFromLineTag(&lines[i], j)) >= 0;) diff --git a/src/r_bsp.c b/src/r_bsp.c index 4559c0f58..58573eb99 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1142,7 +1142,7 @@ static void R_Subsector(size_t num) { // CONS_Debug(DBG_GAMELOGIC, "Adding normal line %d...(%d)\n", line->linedef-lines, leveltime); if (!line->polyseg) // ignore segs that belong to polyobjects - R_AddLine(line); + R_AddLine(line); line++; curline = NULL; /* cph 2001/11/18 - must clear curline now we're done with it, so stuff doesn't try using it for other things */ } @@ -1204,7 +1204,7 @@ void R_Prep3DFloors(sector_t *sector) rover->lastlight = 0; if (!(rover->flags & FF_EXISTS) || (rover->flags & FF_NOSHADE && !(rover->flags & FF_CUTLEVEL) && !(rover->flags & FF_CUTSPRITES))) - continue; + continue; heighttest = *rover->t_slope ? P_GetZAt(*rover->t_slope, sector->soundorg.x, sector->soundorg.y) : *rover->topheight; diff --git a/src/r_things.c b/src/r_things.c index 4345f8203..0f5da1873 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2202,13 +2202,15 @@ static void R_CreateDrawNodes(void) } } // Check for a polyobject plane, but only if this is a front line - if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) { + if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) + { plane = ds->curline->polyseg->visplane; R_PlaneBounds(plane); if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low) ; - else { + else + { // Put it in! entry = R_CreateDrawNode(&nodehead); entry->plane = plane; @@ -2231,6 +2233,7 @@ static void R_CreateDrawNodes(void) { if (!ds->ffloorplanes[p]) continue; + plane = ds->ffloorplanes[p]; R_PlaneBounds(plane); @@ -2303,10 +2306,12 @@ static void R_CreateDrawNodes(void) continue; // Effective height may be different for each comparison in the case of slopes - if (r2->plane->slope) { + if (r2->plane->slope) + { planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy); planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy); - } else + } + else planeobjectz = planecameraz = r2->plane->height; if (rover->mobjflags & MF_NOCLIPHEIGHT) @@ -2365,16 +2370,20 @@ static void R_CreateDrawNodes(void) if (scale <= rover->sortscale) continue; - if (*r2->ffloor->t_slope) { + if (*r2->ffloor->t_slope) + { topplaneobjectz = P_GetZAt(*r2->ffloor->t_slope, rover->gx, rover->gy); topplanecameraz = P_GetZAt(*r2->ffloor->t_slope, viewx, viewy); - } else + } + else topplaneobjectz = topplanecameraz = *r2->ffloor->topheight; - if (*r2->ffloor->b_slope) { + if (*r2->ffloor->b_slope) + { botplaneobjectz = P_GetZAt(*r2->ffloor->b_slope, rover->gx, rover->gy); botplanecameraz = P_GetZAt(*r2->ffloor->b_slope, viewx, viewy); - } else + } + else botplaneobjectz = botplanecameraz = *r2->ffloor->bottomheight; if ((topplanecameraz > viewz && botplanecameraz < viewz) || diff --git a/src/s_sound.c b/src/s_sound.c index ae036a3db..e6f2af24a 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1375,17 +1375,7 @@ void S_LoadMusicDefs(UINT16 wadnum) // Find music def while (stoken) { - /*if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#')) // skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - if (def) - stoken = strtok(NULL, "\r\n= "); - else - stoken = strtok(NULL, "\r\n "); - line++; - } - else*/ if (!stricmp(stoken, "lump")) + if (!stricmp(stoken, "lump")) { value = strtok(NULL, "\r\n "); @@ -1460,35 +1450,44 @@ skip_lump: return; } - if (!stricmp(stoken, "usage")) { + if (!stricmp(stoken, "usage")) + { STRBUFCPY(def->usage, value); for (value = def->usage; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set usage to '%s'\n", def->usage); - } else if (!stricmp(stoken, "source")) { + } + else if (!stricmp(stoken, "source")) + { STRBUFCPY(def->source, value); for (value = def->source; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "title")) { + } + else if (!stricmp(stoken, "title")) + { def->use_info = true; STRBUFCPY(def->title, value); for (value = def->title; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "alttitle")) { + } + else if (!stricmp(stoken, "alttitle")) + { STRBUFCPY(def->alttitle, value); for (value = def->alttitle; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "authors")) { + } + else if (!stricmp(stoken, "authors")) + { STRBUFCPY(def->authors, value); for (value = def->authors; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else { - CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); } + else + CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); skip_field: stoken = strtok(NULL, "\r\n= "); @@ -1559,17 +1558,7 @@ void S_LoadMTDefs(UINT16 wadnum) // Find music def while (stoken) { - /*if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#')) // skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - if (def) - stoken = strtok(NULL, "\r\n= "); - else - stoken = strtok(NULL, "\r\n "); - line++; - } - else*/ if (!stricmp(stoken, "lump")) + if (!stricmp(stoken, "lump")) { value = strtok(NULL, "\r\n "); @@ -1638,25 +1627,30 @@ skip_lump: return; } - if (!stricmp(stoken, "title")) { + if (!stricmp(stoken, "title")) + { def->use_info = true; STRBUFCPY(def->title, value); for (value = def->title; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "alttitle")) { + } + else if (!stricmp(stoken, "alttitle")) + { STRBUFCPY(def->alttitle, value); for (value = def->alttitle; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "authors")) { + } + else if (!stricmp(stoken, "authors")) + { STRBUFCPY(def->authors, value); for (value = def->authors; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else { - CONS_Alert(CONS_WARNING, "MUSCINFO: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); } + else + CONS_Alert(CONS_WARNING, "MUSCINFO: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); skip_field: stoken = strtok(NULL, "\r\n= "); @@ -2363,9 +2357,8 @@ static void Command_ShowMusicCredit_f(void) musicdef_t *def = S_FindMusicCredit(musname); - if (def) { + if (def) CONS_Printf("%.6s - %.255s\n", musname, def->source); - } } static void GameSounds_OnChange(void) @@ -2396,6 +2389,7 @@ static void SoundPrecache_OnChange(void) else if (!S_PrecacheSound()) { S_ClearSfx(); + if (!sound_disabled) S_InitSfxChannels(cv_soundvolume.value); } diff --git a/src/st_stuff.c b/src/st_stuff.c index 681f2d920..a89d49793 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -526,17 +526,7 @@ static void ST_drawDebugInfo(void) if (cv_debug & DBG_DETAILED) { - //V_DrawRightAlignedString(320, height - 104, V_MONOSPACE, va("SHIELD: %5x", stplyr->powers[pw_shield])); V_DrawRightAlignedString(320, height - 96, V_MONOSPACE, va("SCALE: %5d%%", (stplyr->mo->scale*100)/FRACUNIT)); - //V_DrawRightAlignedString(320, height - 88, V_MONOSPACE, va("DASH: %3d/%3d", stplyr->dashspeed>>FRACBITS, FixedMul(stplyr->maxdash,stplyr->mo->scale)>>FRACBITS)); - //V_DrawRightAlignedString(320, height - 80, V_MONOSPACE, va("AIR: %4d, %3d", stplyr->powers[pw_underwater], stplyr->powers[pw_spacetime])); - - // Flags - //V_DrawRightAlignedString(304-64, height - 72, V_MONOSPACE, "Flags:"); - //V_DrawString(304-60, height - 72, (stplyr->jumping) ? V_GREENMAP : V_REDMAP, "JM"); - //V_DrawString(304-40, height - 72, (stplyr->pflags & PF_JUMPED) ? V_GREENMAP : V_REDMAP, "JD"); - //V_DrawString(304-20, height - 72, (stplyr->pflags & PF_SPINNING) ? V_GREENMAP : V_REDMAP, "SP"); - //V_DrawString(304, height - 72, (stplyr->pflags & PF_STARTDASH) ? V_GREENMAP : V_REDMAP, "ST"); V_DrawRightAlignedString(320, height - 64, V_MONOSPACE, va("CEILZ: %6d", stplyr->mo->ceilingz>>FRACBITS)); V_DrawRightAlignedString(320, height - 56, V_MONOSPACE, va("FLOORZ: %6d", stplyr->mo->floorz>>FRACBITS)); @@ -570,132 +560,6 @@ static void ST_drawDebugInfo(void) V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10))); } -/* -static void ST_drawScore(void) -{ - // SCORE: - ST_DrawPatchFromHud(HUD_SCORE, sboscore); - if (objectplacing) - { - if (op_displayflags > UINT16_MAX) - ST_DrawOverlayPatch(SCX(hudinfo[HUD_SCORENUM].x-tallminus->width), SCY(hudinfo[HUD_SCORENUM].y), tallminus); - else - ST_DrawNumFromHud(HUD_SCORENUM, op_displayflags); - } - else - ST_DrawNumFromHud(HUD_SCORENUM, stplyr->score); -} -*/ - -/* -static void ST_drawTime(void) -{ - INT32 seconds, minutes, tictrn, tics; - - // TIME: - ST_DrawPatchFromHudWS(HUD_TIME, sbotime); - - if (objectplacing) - { - tics = objectsdrawn; - seconds = objectsdrawn%100; - minutes = objectsdrawn/100; - tictrn = 0; - } - else - { - tics = stplyr->realtime; - seconds = G_TicsToSeconds(tics); - minutes = G_TicsToMinutes(tics, true); - tictrn = G_TicsToCentiseconds(tics); - } - - if (cv_timetic.value == 1) // Tics only -- how simple is this? - ST_DrawNumFromHudWS(HUD_SECONDS, tics); - else - { - ST_DrawNumFromHudWS(HUD_MINUTES, minutes); // Minutes - ST_DrawPatchFromHudWS(HUD_TIMECOLON, sbocolon); // Colon - ST_DrawPadNumFromHudWS(HUD_SECONDS, seconds, 2); // Seconds - - if (!splitscreen && (cv_timetic.value == 2 || modeattacking)) // there's not enough room for tics in splitscreen, don't even bother trying! - { - ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod); // Period - ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2); // Tics - } - } -} -*/ - -/* -static inline void ST_drawRings(void) // SRB2kart - unused. -{ - INT32 ringnum = max(stplyr->health-1, 0); - - ST_DrawPatchFromHudWS(HUD_RINGS, ((stplyr->health <= 1 && leveltime/5 & 1) ? rrings : sborings)); - - if (objectplacing) - ringnum = op_currentdoomednum; - else if (!useNightsSS && G_IsSpecialStage(gamemap)) - { - INT32 i; - ringnum = 0; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].mo->health > 1) - ringnum += players[i].mo->health - 1; - } - - ST_DrawNumFromHudWS(HUD_RINGSNUM, ringnum); -} -*/ - -/* -static void ST_drawLives(void) // SRB2kart - unused. -{ - const INT32 v_splitflag = (splitscreen && stplyr == &players[displayplayers[0]] ? V_SPLITSCREEN : 0); - - if (!stplyr->skincolor) - return; // Just joined a server, skin isn't loaded yet! - - // face background - V_DrawSmallScaledPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, livesback); - - // face - if (stplyr->mo && stplyr->mo->color) - { - // skincolor face/super - UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->mo->color, GTC_CACHE); - patch_t *face = facerankprefix[stplyr->skin]; - if (stplyr->powers[pw_super] || stplyr->pflags & PF_NIGHTSMODE) - face = facewantprefix[stplyr->skin]; - V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,face, colormap); - } - else if (stplyr->skincolor) - { - // skincolor face - UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE); - V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,facerankprefix[stplyr->skin], colormap); - } - - // name - if (strlen(skins[stplyr->skin].hudname) > 8) - V_DrawThinString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0), - V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname); - else - V_DrawString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0), - V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname); - // x - V_DrawScaledPatch(hudinfo[HUD_LIVESX].x, hudinfo[HUD_LIVESX].y + (v_splitflag ? -4 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, stlivex); - // lives - V_DrawRightAlignedString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, va("%d",stplyr->lives)); -} -*/ - static void ST_drawLevelTitle(void) { char *lvlttl = mapheaderinfo[gamemap-1]->lvlttl; @@ -832,15 +696,6 @@ static void ST_overlayDrawer(void) } } } - - // This is where we draw all the fun cheese if you have the chasecam off! - /*if ((stplyr == &players[displayplayers[0]] && !camera[0].chase) - || ((splitscreen && stplyr == &players[displayplayers[1]]) && !camera[1].chase) - || ((splitscreen > 1 && stplyr == &players[displayplayers[2]]) && !camera[2].chase) - || ((splitscreen > 2 && stplyr == &players[displayplayers[3]]) && !camera[3].chase)) - { - ST_drawFirstPersonHUD(); - }*/ } if (!(netgame || multiplayer) || !hu_showscores) diff --git a/src/v_video.c b/src/v_video.c index bc1dd4159..4c5e1cfd3 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "r_local.h" +#include "p_local.h" #include "v_video.h" #include "hu_stuff.h" #include "r_draw.h" @@ -3135,7 +3136,7 @@ INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; // // Perform a particular image postprocessing function. // -#include "p_local.h" + void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) { #if NUMSCREENS < 5 @@ -3203,8 +3204,8 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) } } -/* -Unoptimized version + /* + Unoptimized version for (x = 0; x < vid.width*vid.bpp; x++) { newpix = (x + sine); diff --git a/src/w_wad.c b/src/w_wad.c index 04015d614..762cdc417 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -62,9 +62,6 @@ #include "md5.h" #include "lua_script.h" #include "st_stuff.h" -#ifdef SCANTHINGS -#include "p_setup.h" // P_ScanThings -#endif #include "m_misc.h" // M_MapNumber #include "p_setup.h" // P_PartialAddFile mayb @@ -117,7 +114,8 @@ void W_Shutdown(void) if (wad->handle) fclose(wad->handle); Z_Free(wad->filename); - while (wad->numlumps--) { + while (wad->numlumps--) + { Z_Free(wad->lumpinfo[wad->numlumps].longname); Z_Free(wad->lumpinfo[wad->numlumps].fullname); } @@ -287,22 +285,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) DEH_LoadDehackedLumpPwad(wadnum, lump); } } - -#ifdef SCANTHINGS - // Scan maps for emblems 'n shit - { - lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; - for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++) - { - const char *name = lump_p->name; - if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P' && name[5]=='\0') - { - INT16 mapnum = (INT16)M_MapNumber(name[3], name[4]); - P_ScanThings(mapnum, wadnum, lump + ML_THINGS); - } - } - } -#endif } /** Compute MD5 message digest for bytes read from STREAM of this filname. -- 2.54.0 From f545cce6febaf2bb3a7d688d8d7f9d5d87053ced Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 25 Jul 2024 22:50:53 +0300 Subject: [PATCH 243/525] Add check for if lua state exist in UnArchiveExtVars, since server can have local luas that may add player/mobj fields into savegame --- src/lua_script.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index 160c92180..6528a515e 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1432,7 +1432,12 @@ static void UnArchiveExtVars(void *pointer) if (field_count == 0) return; - I_Assert(gL != NULL); + + // Technically possible new, since server may have local lua scripts but no "public" ones, so + // field_count would be non zero (there is no way to tell local field from non-local, so + // everything gets archived) + if (!gL) + return; TABLESINDEX = lua_gettop(gL); lua_createtable(gL, 0, field_count); // pointer's ext vars subtable -- 2.54.0 From ce2398fdb774cee0b863a1a430db207b5a44f259 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 13:59:37 +0200 Subject: [PATCH 244/525] add some extra safety to orbit and bananachain funcs --- src/k_kart.c | 22 ++++++++++++++++------ src/p_inter.c | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1ce92dc30..a113eb6ae 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4086,6 +4086,9 @@ void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source) mobj_t *cachenext; killnext: + if (P_MobjWasRemoved(banana)) + return; + cachenext = banana->hnext; if (banana->health) @@ -4126,6 +4129,13 @@ void K_UpdateHnextList(player_t *player, boolean clean) P_RemoveMobj(work); } + + if (player->mo->hnext == NULL || P_MobjWasRemoved(player->mo->hnext)) + { + // Like below, try to clean up the pointer if it's NULL. + // Maybe this was a cause of the shrink/eggbox fails? + P_SetTarget(&player->mo->hnext, NULL); + } } // For getting hit! @@ -4373,10 +4383,8 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct - if (orbit->target && orbit->target->player) + if (orbit->target && orbit->target->player && !P_MobjWasRemoved(orbit->target)) { - player_t *player = orbit->target->player; - INT32 num = 0; mobj_t *cur = orbit->target->hnext; @@ -4386,14 +4394,14 @@ void K_RepairOrbitChain(mobj_t *orbit) { prev = cur; cur = cur->hnext; - if (++num > player->kartstuff[k_itemamount]) + if (++num > orbit->target->player->kartstuff[k_itemamount]) P_RemoveMobj(prev); else prev->movedir = num; } - if (player->kartstuff[k_itemamount] != num) - player->kartstuff[k_itemamount] = num; + if (orbit->target && !P_MobjWasRemoved(orbit->target) && orbit->target->player->kartstuff[k_itemamount] != num) + orbit->target->player->kartstuff[k_itemamount] = num; } } @@ -4406,6 +4414,7 @@ static void K_MoveHeldObjects(player_t *player) if (!player->mo->hnext) { player->kartstuff[k_bananadrag] = 0; + if (player->kartstuff[k_eggmanheld]) player->kartstuff[k_eggmanheld] = 0; else if (player->kartstuff[k_itemheld]) @@ -4421,6 +4430,7 @@ static void K_MoveHeldObjects(player_t *player) // we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic... P_SetTarget(&player->mo->hnext, NULL); player->kartstuff[k_bananadrag] = 0; + if (player->kartstuff[k_eggmanheld]) player->kartstuff[k_eggmanheld] = 0; else if (player->kartstuff[k_itemheld]) diff --git a/src/p_inter.c b/src/p_inter.c index dbc6e6a3b..c23bfe286 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1648,7 +1648,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) // SRB2kart // I wish I knew a better way to do this - if (target->target && target->target->player && target->target->player->mo) + if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) target->target->player->kartstuff[k_eggmanheld] = 0; @@ -1665,7 +1665,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; } - else + else if (target->target->player->kartstuff[k_itemamount]) target->target->player->kartstuff[k_itemamount]--; } else if ((target->type == MT_ORBINAUT_SHIELD && target->target->player->kartstuff[k_itemtype] == KITEM_ORBINAUT) // orbit items -- 2.54.0 From f83090e299eb9d08e96710693a7ec1bdb56dd5fe Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 15:03:01 +0200 Subject: [PATCH 245/525] when no autoload config is found skip everything in D_AddAutoloadFiles stuff doesent need to run if theres nothing to autoload so things can be skipped --- src/d_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index f1d05a1c0..f23e64566 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1039,7 +1039,10 @@ static void D_FindAddonsToAutoload(void) // If the file is found, run our shit if (!autoloadconfigfile) // nope outta here + { + wasautoloaded = postautoloaded = true; // so D_AddAutoloadFiles can skip everything since nothings there to autoload return; + } while (fgets(wadsToAutoload, sizeof wadsToAutoload, autoloadconfigfile) != NULL) { -- 2.54.0 From ae3b3f750d7f466092632504ed9970ec04181bc5 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 15:03:01 +0200 Subject: [PATCH 246/525] when no autoload config is found skip everything in D_AddAutoloadFiles stuff doesent need to run if theres nothing to autoload so things can be skipped --- src/d_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index c261e9bd0..8b3f3520b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1039,7 +1039,10 @@ static void D_FindAddonsToAutoload(void) // If the file is found, run our shit if (!autoloadconfigfile) // nope outta here + { + wasautoloaded = postautoloaded = true; // so D_AddAutoloadFiles can skip everything since nothings there to autoload return; + } while (fgets(wadsToAutoload, sizeof wadsToAutoload, autoloadconfigfile) != NULL) { -- 2.54.0 From 9bfe2d3138439280f793523e1821ce3f820bd91c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 19:14:08 +0200 Subject: [PATCH 247/525] add more sprite draw dist settings for 64bit clients --- src/r_main.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 2b9882122..048e3deb2 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -140,18 +140,25 @@ ps_metric_t ps_numsprites = {0}; ps_metric_t ps_numdrawnodes = {0}; ps_metric_t ps_numpolyobjects = {0}; +#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) +static CV_PossibleValue_t drawdist_cons_t[] = { + /*{256, "256"},*/ {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, + {8192, "8192"}, {12288, "Far"}, {20480, "Extreme"}, + {24576, "Penultimate"},{0, "Infinite"}, {0, NULL}}; + +static CV_PossibleValue_t drawdist_precip_cons_t[] = { + {256, "256"}, {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; +#else static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) -static CV_PossibleValue_t drawdist_precip_cons_t[] = { - {256, "256"}, {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; -#else static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, -- 2.54.0 From d5258786e5cb82a448dca31e5ca6b213d616aa03 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 19:15:23 +0200 Subject: [PATCH 248/525] raise MAXVISSPRITES for 64-bit again --- src/r_things.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.h b/src/r_things.h index 3e2414da1..f78766862 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -25,7 +25,7 @@ // number of sprite lumps for spritewidth,offset,topoffset lookup tables // Fab: this is a hack : should allocate the lookup tables per sprite #if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) -#define MAXVISSPRITES 4096 +#define MAXVISSPRITES 6140 #else #define MAXVISSPRITES 2048 // added 2-2-98 was 128 #endif -- 2.54.0 From b80762eaf5dd5409b873e27229574d100b89233f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 19:15:59 +0200 Subject: [PATCH 249/525] rename draw dist settings --- src/r_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 048e3deb2..6ea1433a8 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -145,13 +145,13 @@ static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {12288, "Far"}, {20480, "Extreme"}, - {24576, "Penultimate"},{0, "Infinite"}, {0, NULL}}; + {8192, "8192"}, {12288, "12288"}, {20480, "20480"}, + {24576, "24576"},{0, "Infinite"}, {0, NULL}}; static CV_PossibleValue_t drawdist_precip_cons_t[] = { - {256, "256"}, {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; + {256, "256"}, {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; #else static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, @@ -166,10 +166,10 @@ static CV_PossibleValue_t drawdist_precip_cons_t[] = { #endif static CV_PossibleValue_t maxinterpdist_cons_t[] = { - /*{256, "256"},*/ {512, "512"}, {768, "768"}, + /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; + {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; static CV_PossibleValue_t fov_cons_t[] = {{5*FRACUNIT, "MIN"}, {178*FRACUNIT, "MAX"}, {0, NULL}}; -- 2.54.0 From 034724b03e0b2b312d473c783a80c557b846055b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 22:18:49 +0200 Subject: [PATCH 250/525] Show last lap time on HUD god this is kinda ass lol doesent work when you join midgame so disabled for there --- src/d_player.h | 9 +++++ src/g_game.c | 24 +++++++++++++ src/k_kart.c | 92 +++++++++++++++++++++++++++----------------------- src/p_spec.c | 6 ++++ src/p_user.c | 14 ++++++++ 5 files changed, 103 insertions(+), 42 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 183991606..28ab11286 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -347,6 +347,14 @@ typedef enum RW_RAIL = 32 } ringweapons_t; +// enum for saved lap times +typedef enum +{ + LAP_CUR, + LAP_LAST, + LAP__MAX +} laptime_e; + // ======================================================================== // PLAYER STRUCTURE // ======================================================================== @@ -465,6 +473,7 @@ typedef struct player_s INT16 numboxes; // Number of item boxes obtained for Race Mode INT16 totalring; // Total number of rings obtained for Race Mode tic_t realtime; // integer replacement for leveltime + tic_t laptime[LAP__MAX]; UINT8 laps; // Number of laps (optional) //////////////////// diff --git a/src/g_game.c b/src/g_game.c index 203b1aba5..5735f4ad0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2494,6 +2494,10 @@ void G_PlayerReborn(INT32 player) boolean fade; boolean playing; + tic_t laptime[LAP__MAX]; + + INT32 i; + score = players[player].score; marescore = players[player].marescore; lives = players[player].lives; @@ -2535,6 +2539,21 @@ void G_PlayerReborn(INT32 player) bot = players[player].bot; pity = players[player].pity; + if (leveltime <= starttime) // man i really hope this crap works kek but need to reset this somehow at mapstart + { + for (i = 0; i < LAP__MAX; i++) + { + laptime[i] = 0; + } + } + else + { + for (i = 0; i < LAP__MAX; i++) + { + laptime[i] = players[player].laptime[i]; + } + } + // SRB2kart if (leveltime <= starttime || spectator == true) { @@ -2626,6 +2645,11 @@ void G_PlayerReborn(INT32 player) p->laps = laps; p->totalring = totalring; + for (i = 0; i < LAP__MAX; i++) + { + p->laptime[i] = laptime[i]; + } + p->mare = mare; if (bot) p->bot = 1; // reset to AI-controlled diff --git a/src/k_kart.c b/src/k_kart.c index a113eb6ae..7e324c533 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -16,6 +16,7 @@ #include "m_random.h" #include "m_menu.h" // ffdhidshfuisduifigergho9igj89dgodhfih AAAAAAAAAA #include "p_local.h" +#include "p_setup.h" #include "p_slopes.h" #include "r_defs.h" #include "r_draw.h" @@ -37,6 +38,7 @@ #include "lua_hook.h" // For MobjDamage and ShouldDamage #include "d_main.h" // found_extra_kart + #include "i_video.h" #ifdef HWRENDER @@ -8121,8 +8123,6 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI { // TIME_X = BASEVIDWIDTH-124; // 196 // TIME_Y = 6; // 6 - - tic_t worktime; INT32 splitflags = 0; if (!mode) @@ -8147,63 +8147,54 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI TX += 33; - worktime = drawtime/(60*TICRATE); - - if (mode && !drawtime) - V_DrawKartString(TX, TY+3, splitflags, va("--'--\"--")); - else if (worktime < 100) // 99:99:99 only + if (drawtime == UINT32_MAX) + ; + else if (mode && !drawtime) { + // apostrophe location _'__ __ + V_DrawKartString(TX+24, TY+3, splitflags, va("'")); + + // quotation mark location _ __"__ + V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); + } + else + { + tic_t worktime = drawtime/(60*TICRATE); + + if (worktime >= 100) + { + worktime = 99; + drawtime = (100*(60*TICRATE))-1; + } + if ((cv_timelimit.value && G_BattleGametype()) && (!players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2)) && cv_overtime.value)) // i hate this so much { V_DrawKartString(TX, TY+3, splitflags, va("OVERTIME")); - return; + return; } - - // zero minute - if (worktime < 10) - { - V_DrawKartString(TX, TY+3, splitflags, va("0")); - // minutes time 0 __ __ - V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime)); - } - // minutes time 0 __ __ - else - V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime)); + + // minutes time 00 __ __ + V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime%10)); // apostrophe location _'__ __ V_DrawKartString(TX+24, TY+3, splitflags, va("'")); worktime = (drawtime/TICRATE % 60); - // zero second _ 0_ __ - if (worktime < 10) - { - V_DrawKartString(TX+36, TY+3, splitflags, va("0")); - // seconds time _ _0 __ - V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime)); - } - // zero second _ 00 __ - else - V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime)); + // seconds time _ 00 __ + V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime%10)); // quotation mark location _ __"__ V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); worktime = G_TicsToCentiseconds(drawtime); - // zero tick _ __ 0_ - if (worktime < 10) - { - V_DrawKartString(TX+72, TY+3, splitflags, va("0")); - // tics _ __ _0 - V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime)); - } - // zero tick _ __ 00 - else - V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime)); + // tics _ __ 00 + V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime%10)); } - else if ((drawtime/TICRATE) & 1) - V_DrawKartString(TX, TY+3, splitflags, va("99'59\"99")); if (emblemmap && (modeattacking || (mode == 1)) && !demo.playback) // emblem time! { @@ -10502,9 +10493,26 @@ void K_drawKartHUD(void) // If not splitscreen, draw... if (!splitscreen && !demo.title) { + tic_t realtime = stplyr->realtime; + + if (stplyr->kartstuff[k_lapanimation] + && !stplyr->exiting + && stplyr->laptime[LAP_LAST] != 0 + && !midgamejoin) + { + if ((stplyr->kartstuff[k_lapanimation] / 5) & 1) + { + realtime = stplyr->laptime[LAP_LAST]; + } + else + { + realtime = UINT32_MAX; + } + } + // Draw the timestamp if (LUA_HudEnabled(hud_time)) - K_drawKartTimestamp(stplyr->realtime, TIME_X, TIME_Y, gamemap, 0); + K_drawKartTimestamp(realtime, TIME_X, TIME_Y, gamemap, 0); if (!modeattacking) { diff --git a/src/p_spec.c b/src/p_spec.c index e0092f1ee..4fa7a5275 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -29,6 +29,7 @@ #include "z_zone.h" #include "r_main.h" //Two extra includes. #include "r_sky.h" +#include "st_stuff.h" #include "p_polyobj.h" #include "p_slopes.h" #include "hu_stuff.h" @@ -3993,6 +3994,11 @@ DoneSection2: curlap = 0; } + // ONLY FOR HUD + player->laptime[LAP_LAST] = player->laptime[LAP_CUR]; + player->laptime[LAP_CUR] = 0; + // + player->starposttime = player->realtime; player->starpostnum = 0; diff --git a/src/p_user.c b/src/p_user.c index 9fda4f639..c14a4c541 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3002,12 +3002,19 @@ static void P_DeathThink(player_t *player) else curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V } + + if (player->spectator) + player->laptime[LAP_CUR] = 0; + else + player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; if (player == &players[consoleplayer]) curlap = 0; + + player->laptime[LAP_CUR] = 0; } } @@ -4549,12 +4556,19 @@ void P_PlayerThink(player_t *player) else curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V } + + if (player->spectator) + player->laptime[LAP_CUR] = 0; + else + player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; if (player == &players[consoleplayer]) curlap = 0; + + player->laptime[LAP_CUR] = 0; } } -- 2.54.0 From fb54b969d13b58daeb30be986259d7fcfd66f15d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jul 2024 14:38:25 +0200 Subject: [PATCH 251/525] toggle for laptimes --- src/k_kart.c | 5 ++++- src/k_kart.h | 1 + src/m_menu.c | 39 +++++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7e324c533..83a415f75 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -76,6 +76,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_showinput = {"showinput", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -722,6 +723,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_showstats); CV_RegisterVar(&cv_showinput); + CV_RegisterVar(&cv_showlaptimes); CV_RegisterVar(&cv_newspeedometer); CV_RegisterVar(&cv_battlespeedo); @@ -10495,7 +10497,8 @@ void K_drawKartHUD(void) { tic_t realtime = stplyr->realtime; - if (stplyr->kartstuff[k_lapanimation] + if (cv_showlaptimes.value + && stplyr->kartstuff[k_lapanimation] && !stplyr->exiting && stplyr->laptime[LAP_LAST] != 0 && !midgamejoin) diff --git a/src/k_kart.h b/src/k_kart.h index 06195280d..1f95aefe2 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -31,6 +31,7 @@ extern consvar_t cv_highresportrait; extern consvar_t cv_stat_xoffset; extern consvar_t cv_stat_yoffset; extern consvar_t cv_showstats; +extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; #define NUMSPEEDOSTUFF 6 diff --git a/src/m_menu.c b/src/m_menu.c index 8f884d05c..c220d2071 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2019,31 +2019,32 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 25}, {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 30}, {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 35}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 40}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 45}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 50}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 55}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 60}, - {IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 65}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 70}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 40}, + {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 45}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 50}, + {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 55}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 60}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 65}, + {IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 70}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 80}, + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 85}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 85}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 90}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 95}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 90}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 95}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 100}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 105}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 110}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 115}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 120}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 125}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 130}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 130}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 135}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 150}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 155}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 160}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2054,6 +2055,7 @@ static const char* OP_SaturnTooltips[] = "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", "Change what style the speedometer is.", "Enable the stat display.", + "Show Lap Time when doing a Lap on the Timer.", "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Enable colourized hud.", "Enable the colourized itembox when colourized hud is enabled.", @@ -2082,6 +2084,7 @@ enum sm_input, sm_speedometer, sm_statdisplay, + sm_laptime, sm_highresport, sm_colorhud, sm_coloritem, -- 2.54.0 From 26eedc334118fb02bac2785fe752cba99f70c358 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 20:41:26 +0200 Subject: [PATCH 252/525] small change to director for battle --- src/k_director.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index d57ffbb8e..eb4e458ed 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -27,6 +27,11 @@ struct directorinfo directorinfo; +static boolean race_rules() +{ + return gametype = GT_RACE; +} + static fixed_t P_ScaleFromMap(fixed_t n, fixed_t scale) { return FixedMul(n, FixedDiv(scale, mapobjectscale)); @@ -325,7 +330,9 @@ void K_UpdateDirector(void) } // if there's only one player left in the list, just switch to that player - if (directorinfo.sortedplayers[0] != -1 && directorinfo.sortedplayers[1] == -1) + if (directorinfo.sortedplayers[0] != -1 && (directorinfo.sortedplayers[1] == -1 || + // TODO: Battle; I just threw this together quick. Focus on leader. + !race_rules())) { K_DirectorSwitch(directorinfo.sortedplayers[0], false); return; -- 2.54.0 From dca2827154492c17671c7695689c13d88166b0e5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jul 2024 15:00:07 +0200 Subject: [PATCH 253/525] this is not a server cvar lol --- src/d_netcmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 409328f0c..fcbdc57ce 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -827,8 +827,6 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_netdemosyncquality); CV_RegisterVar(&cv_maxdemosize); CV_RegisterVar(&cv_keyboardlayout); - - CV_RegisterVar(&cv_betainterscreen); } // ========================================================================= @@ -1164,6 +1162,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_showmusicfilename); + CV_RegisterVar(&cv_betainterscreen); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); -- 2.54.0 From 40663eb2b5fbcd4dab4a69b620b98e43ee0ee05b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 23:28:29 +0200 Subject: [PATCH 254/525] lagless cam test --- src/d_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index f23e64566..def35967c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -736,6 +736,18 @@ void D_SRB2Loop(void) } else if (rendertimeout < entertic) // in case the server hang or netsplit { + // Lagless camera! Yay! + if (gamestate == GS_LEVEL && netgame) + { + // Evaluate the chase cam once for every local realtic + // This might actually be better suited inside G_Ticker or TryRunTics + for (tic_t chasecamtics = 0; chasecamtics < realtics; chasecamtics++) + { + P_RunChaseCameras(); + } + R_UpdateViewInterpolation(); + } + doDisplay = true; } } -- 2.54.0 From 80498a78eae7c2717b8faf217961ac006d284828 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jul 2024 15:02:47 +0200 Subject: [PATCH 255/525] lagless cam toggle --- src/d_main.c | 2 +- src/d_netcmd.c | 5 +++++ src/d_netcmd.h | 2 ++ src/m_menu.c | 52 +++++++++++++++++++++++++++----------------------- 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index def35967c..161ed604e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -737,7 +737,7 @@ void D_SRB2Loop(void) else if (rendertimeout < entertic) // in case the server hang or netsplit { // Lagless camera! Yay! - if (gamestate == GS_LEVEL && netgame) + if (cv_laglesscam.value && gamestate == GS_LEVEL && netgame) { // Evaluate the chase cam once for every local realtic // This might actually be better suited inside G_Ticker or TryRunTics diff --git a/src/d_netcmd.c b/src/d_netcmd.c index fcbdc57ce..c451cca4f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -299,6 +299,9 @@ consvar_t cv_usemouse2 = {"use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, //WTF consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +// Lagless camera! Yay! +consvar_t cv_laglesscam = {"laglesscamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + #if defined(HAVE_SDL) || defined(_WINDOWS) //joystick 1 and 2 consvar_t cv_usejoystick = {"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick, 0, NULL, NULL, 0, 0, NULL}; @@ -1164,6 +1167,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_betainterscreen); + CV_RegisterVar(&cv_laglesscam); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index ad4789313..dbb06409d 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -209,6 +209,8 @@ extern consvar_t cv_showspecstuff; extern consvar_t cv_betainterscreen; +extern consvar_t cv_laglesscam; + typedef enum { SKINMENUTYPE_SCROLL = 0, diff --git a/src/m_menu.c b/src/m_menu.c index 321125e5e..80b1d635a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2014,38 +2014,40 @@ static menuitem_t OP_SaturnMenu[] = { {IT_HEADER, NULL, "Saturn Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Serverqueue waittime", &cv_connectawaittime, 10}, + {IT_STRING | IT_CVAR, NULL, "Serverqueue waittime", &cv_connectawaittime, 10}, - {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, - {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 25}, - {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 30}, - {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 35}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 40}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 45}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 50}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 55}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 60}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 65}, - {IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 70}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, + {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, + {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 25}, + {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 30}, + {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 35}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 40}, + {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 45}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 50}, + {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 55}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 60}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 65}, + {IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 70}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 85}, + {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 85}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 90}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 95}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 100}, + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 95}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 110}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 100}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 105}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 110}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 120}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 120}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 130}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 135}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 130}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 145}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 150}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 140}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 145}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 160}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 155}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 160}, + + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 170}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2064,6 +2066,7 @@ static const char* OP_SaturnTooltips[] = "Show the big 'LAP' text on a lap change.", "Show player names on the minimap.", "Minimize the player icons on the minimap.", + "Makes the Camera Lagless in netgames.", "Uncaps the HUD framerate, making it appear smoother.", "Show the big Cecho Messages.", "Show Localskin Menus.", @@ -2093,6 +2096,7 @@ enum sm_lapemblem, sm_mapnames, sm_smallmap, + sm_laglesscam, sm_uncappedhud, sm_cechotogle, sm_showlocalskin, -- 2.54.0 From ab5bc92a9592c5fa1bda7d83e232a6b68b4a518f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jul 2024 15:49:39 +0200 Subject: [PATCH 256/525] Revert "raise MAXVISSPRITES for 64-bit again" This reverts commit d5258786e5cb82a448dca31e5ca6b213d616aa03. --- src/r_things.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.h b/src/r_things.h index f78766862..3e2414da1 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -25,7 +25,7 @@ // number of sprite lumps for spritewidth,offset,topoffset lookup tables // Fab: this is a hack : should allocate the lookup tables per sprite #if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) -#define MAXVISSPRITES 6140 +#define MAXVISSPRITES 4096 #else #define MAXVISSPRITES 2048 // added 2-2-98 was 128 #endif -- 2.54.0 From 88b81aa28b70a005b3c7f42aef3a299b0ac1a299 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jul 2024 15:56:44 +0200 Subject: [PATCH 257/525] e --- src/r_main.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 6ea1433a8..764d34403 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -140,7 +140,6 @@ ps_metric_t ps_numsprites = {0}; ps_metric_t ps_numdrawnodes = {0}; ps_metric_t ps_numpolyobjects = {0}; -#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, @@ -148,17 +147,12 @@ static CV_PossibleValue_t drawdist_cons_t[] = { {8192, "8192"}, {12288, "12288"}, {20480, "20480"}, {24576, "24576"},{0, "Infinite"}, {0, NULL}}; +#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; #else -static CV_PossibleValue_t drawdist_cons_t[] = { - /*{256, "256"},*/ {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; - static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, -- 2.54.0 From d09e02721bc1aa95290dd72e092da5433bfbc3b2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jul 2024 15:56:44 +0200 Subject: [PATCH 258/525] e --- src/r_main.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 6ea1433a8..764d34403 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -140,7 +140,6 @@ ps_metric_t ps_numsprites = {0}; ps_metric_t ps_numdrawnodes = {0}; ps_metric_t ps_numpolyobjects = {0}; -#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, @@ -148,17 +147,12 @@ static CV_PossibleValue_t drawdist_cons_t[] = { {8192, "8192"}, {12288, "12288"}, {20480, "20480"}, {24576, "24576"},{0, "Infinite"}, {0, NULL}}; +#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; #else -static CV_PossibleValue_t drawdist_cons_t[] = { - /*{256, "256"},*/ {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; - static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, -- 2.54.0 From 51ce092a6a204bf74ef875808fa7cc2ccfdf937f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 04:13:42 +0200 Subject: [PATCH 259/525] lower pinchdist in director since we cant get an accurate value for distance to finish line, this should do it perhaps --- src/k_director.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index eb4e458ed..60f9f896a 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -23,7 +23,7 @@ #define TRANSFERTIME TICRATE // how long to delay reaction shots? #define BREAKAWAYDIST 4000 // how *far* until players considered far apart? #define WALKBACKDIST 600 // how close should a trailing player be before we switch? -#define PINCHDIST 30000 // how close should the leader be to be considered "end of race"? +#define PINCHDIST 20000 // how close should the leader be to be considered "end of race"? struct directorinfo directorinfo; -- 2.54.0 From 01b060b0fe5238a6fd261f73bc96d6a285648913 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 04:13:51 +0200 Subject: [PATCH 260/525] cleanup k_director --- src/k_director.c | 30 ++++++++++++++---------------- src/k_director.h | 12 ------------ 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index 60f9f896a..4d94e4b81 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -25,7 +25,17 @@ #define WALKBACKDIST 600 // how close should a trailing player be before we switch? #define PINCHDIST 20000 // how close should the leader be to be considered "end of race"? -struct directorinfo directorinfo; +struct directorinfo +{ + tic_t cooldown; // how long has it been since we last switched? + tic_t freeze; // when nonzero, fixed switch pending, freeze logic! + INT32 attacker; // who to switch to when freeze delay elapses + INT32 maxdist; // how far is the closest player from finishing? + + INT32 sortedplayers[MAXPLAYERS]; // position-1 goes in, player index comes out. + INT32 gap[MAXPLAYERS]; // gap between a given position and their closest pursuer + INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? +} directorinfo; static boolean race_rules() { @@ -164,7 +174,7 @@ static void K_UpdateDirectorPositions(void) if (directorinfo.gap[position] >= BREAKAWAYDIST) { - directorinfo.boredom[position] = min(BOREDOMTIME * 2, directorinfo.boredom[position] + 1); + directorinfo.boredom[position] = (INT32)(min(BOREDOMTIME * 2, directorinfo.boredom[position] + 1)); } else if (directorinfo.boredom[position] > 0) { @@ -183,13 +193,6 @@ static void K_UpdateDirectorPositions(void) static boolean K_CanSwitchDirector(void) { - /*INT32 *displayplayerp = &displayplayers[0]; - - if (players[*displayplayerp].trickpanel > 0) - { - return false; - }*/ - if (directorinfo.cooldown > 0) { return false; @@ -283,11 +286,6 @@ void K_DrawDirectorDebugger(void) V_DrawThinString(10, ytxt, V_70TRANS, va("%d", position)); V_DrawThinString(20, ytxt, V_70TRANS, va("%d", position + 1)); - /*if (players[leader].positiondelay) - { - V_DrawThinString(40, ytxt, V_70TRANS, va("NG")); - }*/ - V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfo.gap[position])); if (directorinfo.boredom[position] >= BOREDOMTIME) @@ -378,13 +376,13 @@ void K_UpdateDirector(void) target = directorinfo.sortedplayers[targetposition]; // if we're certain the back half of the pair is actually in this position, try to switch - if (*displayplayerp != target /*&& !players[target].positiondelay*/) + if (*displayplayerp != target) { K_DirectorSwitch(target, false); } // even if we're not certain, if we're certain we're watching the WRONG player, try to switch - if (players[*displayplayerp].kartstuff[k_position] != targetposition+1 /*&& !players[target].positiondelay*/) + if (players[*displayplayerp].kartstuff[k_position] != targetposition+1) { K_DirectorSwitch(target, false); } diff --git a/src/k_director.h b/src/k_director.h index 7218cc7e3..3be71b675 100644 --- a/src/k_director.h +++ b/src/k_director.h @@ -10,18 +10,6 @@ /// \file k_director.h /// \brief SRB2kart automatic spectator camera. -extern struct directorinfo -{ - tic_t cooldown; // how long has it been since we last switched? - tic_t freeze; // when nonzero, fixed switch pending, freeze logic! - INT32 attacker; // who to switch to when freeze delay elapses - INT32 maxdist; // how far is the closest player from finishing? - - INT32 sortedplayers[MAXPLAYERS]; // position-1 goes in, player index comes out. - INT32 gap[MAXPLAYERS]; // gap between a given position and their closest pursuer - INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? -} directorinfo; - void K_InitDirector(void); void K_UpdateDirector(void); void K_DrawDirectorDebugger(void); -- 2.54.0 From 48bcaacada927af26f7917310033af7c1e33136e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 04:26:06 +0200 Subject: [PATCH 261/525] fix K_DrawDirectorDebugger --- src/k_kart.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index 3f134ef33..93a4006e0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10663,6 +10663,9 @@ void K_drawKartHUD(void) if (cv_kartdebugcheckpoint.value) K_drawCheckpointDebugger(); + if (cv_kartdebugdirector.value) + K_DrawDirectorDebugger(); + if (cv_kartdebugnodes.value) { UINT8 p; -- 2.54.0 From ffcff99a79bd1ed124109b6cac1987154248ad00 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 04:29:05 +0200 Subject: [PATCH 262/525] lower breakawaydist in director --- src/k_director.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index 4d94e4b81..326b81fe4 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -21,7 +21,7 @@ #define SWITCHTIME TICRATE * 5 // cooldown between unforced switches #define BOREDOMTIME 3 * TICRATE / 2 // how long until players considered far apart? #define TRANSFERTIME TICRATE // how long to delay reaction shots? -#define BREAKAWAYDIST 4000 // how *far* until players considered far apart? +#define BREAKAWAYDIST 2000 // how *far* until players considered far apart? #define WALKBACKDIST 600 // how close should a trailing player be before we switch? #define PINCHDIST 20000 // how close should the leader be to be considered "end of race"? -- 2.54.0 From 41e97ffa79cbf6439e46fa6c8481d2d0aadf0fee Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 16:40:37 +0200 Subject: [PATCH 263/525] another smol fix to director --- src/k_director.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/k_director.c b/src/k_director.c index 326b81fe4..225bfe70e 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -375,6 +375,12 @@ void K_UpdateDirector(void) target = directorinfo.sortedplayers[targetposition]; + // stop here since we're already viewing this player + if (displayplayers[0] == target) + { + break; + } + // if we're certain the back half of the pair is actually in this position, try to switch if (*displayplayerp != target) { -- 2.54.0 From 67542d3cf154b37ff5920edf504c7e9b27602cef Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 18:00:04 +0200 Subject: [PATCH 264/525] i didnt knew k_positiondelay exists --- src/k_director.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index 225bfe70e..c0687494d 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -286,6 +286,11 @@ void K_DrawDirectorDebugger(void) V_DrawThinString(10, ytxt, V_70TRANS, va("%d", position)); V_DrawThinString(20, ytxt, V_70TRANS, va("%d", position + 1)); + if (players[leader].kartstuff[k_positiondelay]) + { + V_DrawThinString(40, ytxt, V_70TRANS, va("NG")); + } + V_DrawThinString(80, ytxt, V_70TRANS, va("%d", directorinfo.gap[position])); if (directorinfo.boredom[position] >= BOREDOMTIME) @@ -376,19 +381,19 @@ void K_UpdateDirector(void) target = directorinfo.sortedplayers[targetposition]; // stop here since we're already viewing this player - if (displayplayers[0] == target) + if (*displayplayerp == target) { break; } // if we're certain the back half of the pair is actually in this position, try to switch - if (*displayplayerp != target) + if (!players[target].kartstuff[k_positiondelay]) { K_DirectorSwitch(target, false); } // even if we're not certain, if we're certain we're watching the WRONG player, try to switch - if (players[*displayplayerp].kartstuff[k_position] != targetposition+1) + if (players[*displayplayerp].kartstuff[k_position] != targetposition+1 && !players[*displayplayerp].kartstuff[k_positiondelay]) { K_DirectorSwitch(target, false); } -- 2.54.0 From 8b60fb6b6cd06b384b1e239fb60392565a9df9df Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 17:36:07 +0200 Subject: [PATCH 265/525] revert this --- src/k_kart.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 93a4006e0..628060743 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4139,13 +4139,6 @@ void K_UpdateHnextList(player_t *player, boolean clean) P_RemoveMobj(work); } - - if (player->mo->hnext == NULL || P_MobjWasRemoved(player->mo->hnext)) - { - // Like below, try to clean up the pointer if it's NULL. - // Maybe this was a cause of the shrink/eggbox fails? - P_SetTarget(&player->mo->hnext, NULL); - } } // For getting hit! -- 2.54.0 From 96ee117657018df5f686c340c56ff3a2aaf33e7a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 17:36:31 +0200 Subject: [PATCH 266/525] Revert "more reference fixes" This reverts commit 94bd1cb37b9b0e90e8c1fb00649aed96b2c0e20d. --- src/lua_blockmaplib.c | 4 +--- src/p_map.c | 18 ++++++++---------- src/p_mobj.c | 27 +++++---------------------- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 2367673cd..0b93766b8 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -53,12 +53,10 @@ static UINT8 lib_searchBlockmap_Objects(lua_State *L, INT32 x, INT32 y, mobj_t * CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); blockfuncerror = true; - P_SetTarget(&bnext, NULL); return 0; // *shrugs* } if (!lua_isnil(gL, -1)) { // if nil, continue - P_SetTarget(&bnext, NULL); if (lua_toboolean(gL, -1)) return 2; // stop whole search else @@ -258,4 +256,4 @@ int LUA_BlockmapLib(lua_State *L) { lua_register(L, "searchBlockmap", lib_searchBlockmap); return 0; -} +} \ No newline at end of file diff --git a/src/p_map.c b/src/p_map.c index bcb2b6a73..6051d5d1c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1548,13 +1548,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmceilingslope = NULL; - P_SetTarget(&tmfloorthing, thing); // needed for side collision + tmfloorthing = thing; // needed for side collision } else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; tmceilingslope = NULL; - P_SetTarget(&tmfloorthing, thing); // thing we may stand on + tmfloorthing = thing; // thing we may stand on } } else @@ -1585,13 +1585,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmfloorslope = NULL; - P_SetTarget(&tmfloorthing, thing); // needed for side collision + tmfloorthing = thing; // needed for side collision } else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; tmfloorslope = NULL; - P_SetTarget(&tmfloorthing, thing); // thing we may stand on + tmfloorthing = thing; // thing we may stand on } } } @@ -1991,8 +1991,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } // tmfloorthing is set when tmfloorz comes from a thing's top - P_SetTarget(&tmfloorthing, NULL); - P_SetTarget(&tmhitthing, NULL); + tmfloorthing = NULL; + tmhitthing = NULL; validcount++; @@ -2489,10 +2489,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (tmceilingz - tmfloorz < thing->height) { - if (tmfloorthing != NULL) - { - P_SetTarget(&tmhitthing, tmfloorthing); - } + if (tmfloorthing) + tmhitthing = tmfloorthing; return false; // doesn't fit } diff --git a/src/p_mobj.c b/src/p_mobj.c index 5e5b9924b..3cfb92f85 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6112,8 +6112,7 @@ void P_MobjThinker(mobj_t *mobj) mobj->flags2 &= ~MF2_PUSHED; mobj->eflags &= ~(MFE_SPRUNG|MFE_JUSTBOUNCEDWALL); - P_SetTarget(&tmfloorthing, NULL); - P_SetTarget(&tmhitthing, NULL); + tmfloorthing = tmhitthing = NULL; // 970 allows ANY mobj to trigger a linedef exec if (mobj->subsector && GETSECSPECIAL(mobj->subsector->sector->special, 2) == 8) @@ -10070,29 +10069,13 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); P_SetTarget(&mobj->tracer, NULL); - // repair hnext chain - mobj_t *cachenext = mobj->hnext; - if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) - { - if (mobj->hnext->hprev == mobj) - { - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); - } - - P_SetTarget(&mobj->hnext, NULL); - } - + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) - { - if (mobj->hprev->hnext == mobj) - { - P_SetTarget(&mobj->hprev->hnext, cachenext); - } + P_SetTarget(&mobj->hprev->hnext, mobj->hnext); + + P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); - P_SetTarget(&mobj->hprev, NULL); - } - // clear the reference from the mapthing if (mobj->spawnpoint) P_SetTarget(&mobj->spawnpoint->mobj, NULL); -- 2.54.0 From fd797436fa2a9cc2e616f4ea0101a1e363eb83df Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 17:36:53 +0200 Subject: [PATCH 267/525] Revert "fix declaration" This reverts commit 8f195530b5fa02e13cc97be2b8f3c7992f13fd24. --- src/p_tick.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.h b/src/p_tick.h index 11b5889ed..d22995a11 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -28,7 +28,7 @@ void P_RunChaseCameras(void); void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); -void P_RemoveThinkerDelayed(thinker_t *thinker); +void P_RemoveThinkerDelayed(void *pthinker); //killed mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98 #endif -- 2.54.0 From 6f53263107c77afed4d07567c7a40e4831660d99 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 17:37:06 +0200 Subject: [PATCH 268/525] Revert "Clean up mobj and thinker removal" This reverts commit 048ccf52b0de555b91a2bb7130dee04dc4427d58. --- src/p_mobj.c | 47 +++++++++++++++++++++++++++++------------------ src/p_tick.c | 44 +++++++++++++++++++------------------------- 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 3cfb92f85..d7d2b37c6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10075,7 +10075,7 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->hprev->hnext, mobj->hnext); P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); - + // clear the reference from the mapthing if (mobj->spawnpoint) P_SetTarget(&mobj->spawnpoint->mobj, NULL); @@ -10083,34 +10083,45 @@ void P_RemoveMobj(mobj_t *mobj) R_RemoveMobjInterpolator(mobj); // free block - if (!mobj->thinker.next) + // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. + if (mobj->flags & MF_NOTHINK && !mobj->thinker.next) { // Uh-oh, the mobj doesn't think, P_RemoveThinker would never go through! - INT32 prevreferences; if (!mobj->thinker.references) { - Z_Free(mobj); // No references? Can be removed immediately! :D - return; - } - - prevreferences = mobj->thinker.references; - P_AddThinker((thinker_t *)mobj); - mobj->thinker.references = prevreferences; - } - - P_RemoveThinker((thinker_t *)mobj); - - // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. #ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); + // Invalidate mobj_t data to cause crashes if accessed! + memset(mobj, 0xff, sizeof(mobj_t)); #endif + Z_Free(mobj); // No refrences? Can be removed immediately! :D + } + else + { // Add thinker just to delay removing it until refrences are gone. + mobj->flags &= ~MF_NOTHINK; + P_AddThinker((thinker_t *)mobj); +#ifdef SCRAMBLE_REMOVED + // Invalidate mobj_t data to cause crashes if accessed! + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); +#endif + P_RemoveThinker((thinker_t *)mobj); + } + } + else + { +#ifdef SCRAMBLE_REMOVED + // Invalidate mobj_t data to cause crashes if accessed! + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); +#endif + P_RemoveThinker((thinker_t *)mobj); + } } // This does not need to be added to Lua. // To test it in Lua, check mobj.valid boolean P_MobjWasRemoved(mobj_t *mobj) { - return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker); + if (mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker) + return false; + return true; } void P_RemovePrecipMobj(precipmobj_t *mobj) diff --git a/src/p_tick.c b/src/p_tick.c index 6bf32f1c3..edb57236a 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -230,27 +230,23 @@ static thinker_t *currentthinker; // remove it, and set currentthinker to one node preceeding it, so // that the next step in P_RunThinkers() will get its successor. // -void P_RemoveThinkerDelayed(thinker_t *thinker) +void P_RemoveThinkerDelayed(void *pthinker) { - thinker_t *next; -#ifdef PARANOIA - if (thinker->next) - thinker->next = NULL; - else if (thinker->references) // Usually gets cleared up in one frame; what's going on here, then? - CONS_Printf("Number of potentially faulty references: %d\n", thinker->references); -#endif - if (thinker->references) - return; - - /* Remove from main thinker list */ - next = thinker->next; - /* Note that currentthinker is guaranteed to point to us, - * and since we're freeing our memory, we had better change that. So - * point it to thinker->prev, so the iterator will correctly move on to - * thinker->prev->next = thinker->next */ - (next->prev = currentthinker = thinker->prev)->next = next; - R_DestroyLevelInterpolators(thinker); - Z_Free(thinker); + thinker_t *thinker = pthinker; + if (!thinker->references) + { + { + /* Remove from main thinker list */ + thinker_t *next = thinker->next; + /* Note that currentthinker is guaranteed to point to us, + * and since we're freeing our memory, we had better change that. So + * point it to thinker->prev, so the iterator will correctly move on to + * thinker->prev->next = thinker->next */ + (next->prev = currentthinker = thinker->prev)->next = next; + } + R_DestroyLevelInterpolators(thinker); + Z_Free(thinker); + } } // @@ -268,7 +264,7 @@ void P_RemoveThinkerDelayed(thinker_t *thinker) void P_RemoveThinker(thinker_t *thinker) { LUA_InvalidateUserdata(thinker); - thinker->function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; + thinker->function.acp1 = P_RemoveThinkerDelayed; } /* @@ -287,7 +283,7 @@ mobj_t *P_SetTarget(mobj_t **mop, mobj_t *targ) { if (*mop) // If there was a target already, decrease its refcount (*mop)->thinker.references--; - if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter +if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter targ->thinker.references++; return targ; } @@ -318,9 +314,7 @@ static inline void P_RunThinkers(void) { for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { -#ifdef PARANOIA - I_Assert(currentthinker->function.acp1 != NULL) -#endif + if (currentthinker->function.acp1) currentthinker->function.acp1(currentthinker); } } -- 2.54.0 From 5b9e1790170bb711a9d0b9c4fab03a642e87231f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 17:37:12 +0200 Subject: [PATCH 269/525] Revert "dont access delayremoved thinkers" This reverts commit df9ad5a31f7616433be9cf335dd51ce093670b5f. --- src/d_clisrv.c | 8 ++- src/d_netcmd.c | 3 +- src/g_game.c | 12 +--- src/lua_script.c | 5 -- src/m_cheat.c | 2 - src/p_enemy.c | 43 ++------------ src/p_inter.c | 4 -- src/p_mobj.c | 18 ------ src/p_polyobj.c | 85 ++++++++++++++++---------- src/p_saveg.c | 152 +++++++++++++++++++++++------------------------ src/p_setup.c | 13 ++-- src/p_spec.c | 16 ----- src/p_tick.c | 4 -- src/p_user.c | 14 ----- src/r_data.c | 3 +- 15 files changed, 148 insertions(+), 234 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c03584043..10d46689a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5595,6 +5595,11 @@ static INT16 Consistancy(void) ret += P_GetRandSeed(); #ifdef MOBJCONSISTANCY + if (!thinkercap.next) + { + DEBFILE(va("Consistancy = %u\n", ret)); + return ret; + } if (gamestate == GS_LEVEL) { for (th = thinkercap.next; th != &thinkercap; th = th->next) @@ -5602,9 +5607,6 @@ static INT16 Consistancy(void) if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - mo = (mobj_t *)th; if (mo->flags & (MF_SPECIAL | MF_SOLID | MF_PUSHABLE | MF_BOSS | MF_MISSILE | MF_SPRING | MF_MONITOR | MF_FIRE | MF_ENEMY | MF_PAIN | MF_STICKY)) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c451cca4f..a8e01a766 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5792,8 +5792,7 @@ static void Command_Archivetest_f(void) i = 1; for (th = thinkercap.next; th != &thinkercap; th = th->next) if (th->function.acp1 == (actionf_p1)P_MobjThinker) - if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) - ((mobj_t *)th)->mobjnum = i++; + ((mobj_t *)th)->mobjnum = i++; // allocate buffer buf = save_p = ZZ_Alloc(1024); diff --git a/src/g_game.c b/src/g_game.c index 22b051024..bc881c5d5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3051,9 +3051,6 @@ void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo) if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - mo2 = (mobj_t *)th; if (!(mo2->flags & MF_MISSILE)) @@ -5658,13 +5655,11 @@ void G_ConsGhostTic(INT32 playernum) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mobj = (mobj_t *)th; if (mobj->type == (mobjtype_t)type && mobj->x == x && mobj->y == y && mobj->z == z) break; } - if ((th != &thinkercap && th->function.acp1 != (actionf_p1)P_MobjThinker) && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! + if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); @@ -8131,14 +8126,11 @@ void G_DoPlayMetal(void) if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - mo = (mobj_t *)th; if (mo->type == MT_METALSONIC_RACE) break; } - if (th == &thinkercap && th->function.acp1 == (actionf_p1)P_MobjThinker) + if (!mo) { CONS_Alert(CONS_ERROR, M_GetText("Failed to find bot entity.\n")); Z_Free(metalbuffer); diff --git a/src/lua_script.c b/src/lua_script.c index 6528a515e..5a2f6448c 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1601,9 +1601,6 @@ void LUA_Archive(void) if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - // archive function will determine when to skip mobjs, // and write mobjnum in otherwise. ArchiveExtVars(th, "mobj"); @@ -1640,8 +1637,6 @@ void LUA_UnArchive(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; if (((mobj_t *)th)->mobjnum != mobjnum) // find matching mobj continue; UnArchiveExtVars(th); // apply variables diff --git a/src/m_cheat.c b/src/m_cheat.c index 6b93461f3..abada4be5 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -906,8 +906,6 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo = (mobj_t *)th; // get offset from mt, which points to old mapthings, then add new location diff --git a/src/p_enemy.c b/src/p_enemy.c index 1a23317ed..3a032fbf0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2635,8 +2635,6 @@ void A_BossDeath(mobj_t *mo) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; if (mo2 != mo && (mo2->flags & MF_BOSS) && mo2->health > 0) @@ -2695,8 +2693,6 @@ bossjustdie: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -5304,8 +5300,6 @@ void A_RingExplode(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -6874,23 +6868,13 @@ void A_Boss3Path(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; - - if (mo2->type != MT_BOSS3WAYPOINT) - continue; - - if(!mo2->spawnpoint) - continue; - - if (mo2->spawnpoint->angle != actor->threshold) - continue; - - - P_SetTarget(&actor->target, mo2); - break; + if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && mo2->spawnpoint->angle == actor->threshold) + { + P_SetTarget(&actor->target, mo2); + break; + } } if (!actor->target) // Should NEVER happen @@ -7321,8 +7305,6 @@ void A_FindTarget(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -7387,8 +7369,6 @@ void A_FindTracer(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -7931,8 +7911,6 @@ void A_RemoteAction(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -8711,8 +8689,6 @@ void A_MementosTPParticles(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; if (mo2->type == MT_MEMENTOSTP && mo2 != actor) @@ -8812,8 +8788,6 @@ void A_ReaperThinker(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -8870,6 +8844,7 @@ void A_ReaperThinker(mobj_t *actor) // Waypoint behavior. if (actor->target->type == MT_REAPERWAYPOINT) { + if (R_PointToDist2(actor->x, actor->y, actor->target->x, actor->target->y) < 22<target, NULL); // remove target so we can default back to first waypoint if things go ham. @@ -8879,8 +8854,6 @@ void A_ReaperThinker(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -9056,8 +9029,6 @@ void A_SetObjectTypeState(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -9680,8 +9651,6 @@ void A_CheckThingCount(mobj_t *actor) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; diff --git a/src/p_inter.c b/src/p_inter.c index c23bfe286..054ff16a1 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1055,8 +1055,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; if (mo2->type == MT_KOOPA) @@ -1951,8 +1949,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo = (mobj_t *)th; if (mo->type == (mobjtype_t)target->info->mass && mo->tracer == target) diff --git a/src/p_mobj.c b/src/p_mobj.c index d7d2b37c6..78fcb8f63 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3223,8 +3223,6 @@ void P_DestroyRobots(void) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker - if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo = (mobj_t *)think; if (mo->health <= 0 || !(mo->flags & MF_ENEMY || mo->flags & MF_BOSS)) @@ -4033,8 +4031,6 @@ static void P_Boss3Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; if (mo2->type == (mobjtype_t)mobj->info->mass && mo2->tracer == mobj) @@ -4126,8 +4122,6 @@ static void P_Boss3Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -4759,8 +4753,6 @@ static void P_Boss7Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint) @@ -4816,8 +4808,6 @@ static void P_Boss7Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && (mo2->spawnpoint->options & 7) == waypointNum) @@ -4941,8 +4931,6 @@ static void P_Boss9Thinker(mobj_t *mobj) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; if (mo2->type == MT_BOSS9GATHERPOINT) @@ -5403,8 +5391,6 @@ mobj_t *P_GetClosestAxis(mobj_t *source) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -10413,8 +10399,6 @@ void P_RespawnSpecials(void) if (th->function.acp1 != (actionf_p1)P_MobjThinker) // not a mobj continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; box = (mobj_t *)th; @@ -11561,8 +11545,6 @@ ML_NOCLIMB : Direction not controllable { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 03df03905..bbf934231 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1514,31 +1514,29 @@ void Polyobj_InitLevel(void) // the mobj_t pointers on a queue for use below. for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - - mobj_t *mo = (mobj_t *)th; - - if (mo->info->doomednum == POLYOBJ_SPAWN_DOOMEDNUM || - mo->info->doomednum == POLYOBJ_SPAWNCRUSH_DOOMEDNUM) + if (th->function.acp1 == (actionf_p1)P_MobjThinker) { - ++numPolyObjects; + mobj_t *mo = (mobj_t *)th; - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); - qitem->mo = mo; - M_QueueInsert(&(qitem->mqitem), &spawnqueue); - } - else if (mo->info->doomednum == POLYOBJ_ANCHOR_DOOMEDNUM) - { - ++numAnchors; + if (mo->info->doomednum == POLYOBJ_SPAWN_DOOMEDNUM || + mo->info->doomednum == POLYOBJ_SPAWNCRUSH_DOOMEDNUM) + { + ++numPolyObjects; - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); - qitem->mo = mo; - M_QueueInsert(&(qitem->mqitem), &anchorqueue); + qitem = malloc(sizeof(mobjqitem_t)); + memset(qitem, 0, sizeof(mobjqitem_t)); + qitem->mo = mo; + M_QueueInsert(&(qitem->mqitem), &spawnqueue); + } + else if (mo->info->doomednum == POLYOBJ_ANCHOR_DOOMEDNUM) + { + ++numAnchors; + + qitem = malloc(sizeof(mobjqitem_t)); + memset(qitem, 0, sizeof(mobjqitem_t)); + qitem->mo = mo; + M_QueueInsert(&(qitem->mqitem), &anchorqueue); + } } } @@ -1573,6 +1571,39 @@ void Polyobj_InitLevel(void) Polyobj_linkToBlockmap(&PolyObjects[i]); } +#if 0 + // haleyjd 02/22/06: temporary debug + printf("DEBUG: numPolyObjects = %d\n", numPolyObjects); + for (i = 0; i < numPolyObjects; ++i) + { + INT32 j; + polyobj_t *po = &PolyObjects[i]; + + printf("polyobj %d:\n", i); + printf("id = %d, first = %d, next = %d\n", po->id, po->first, po->next); + printf("segCount = %d, numSegsAlloc = %d\n", po->segCount, po->numSegsAlloc); + for (j = 0; j < po->segCount; ++j) + printf("\tseg %d: %p\n", j, po->segs[j]); + printf("numVertices = %d, numVerticesAlloc = %d\n", po->numVertices, po->numVerticesAlloc); + for (j = 0; j < po->numVertices; ++j) + { + printf("\tvtx %d: (%d, %d) / orig: (%d, %d)\n", + j, po->vertices[j]->x>>FRACBITS, po->vertices[j]->y>>FRACBITS, + po->origVerts[j].x>>FRACBITS, po->origVerts[j].y>>FRACBITS); + } + printf("numLines = %d, numLinesAlloc = %d\n", po->numLines, po->numLinesAlloc); + for (j = 0; j < po->numLines; ++j) + printf("\tline %d: %p\n", j, po->lines[j]); + printf("spawnSpot = (%d, %d)\n", po->spawnSpot.x >> FRACBITS, po->spawnSpot.y >> FRACBITS); + printf("centerPt = (%d, %d)\n", po->centerPt.x >> FRACBITS, po->centerPt.y >> FRACBITS); + printf("attached = %d, linked = %d, validcount = %d, isBad = %d\n", + po->attached, po->linked, po->validcount, po->isBad); + printf("blockbox: [%d, %d, %d, %d]\n", + po->blockbox[BOXLEFT], po->blockbox[BOXRIGHT], po->blockbox[BOXBOTTOM], + po->blockbox[BOXTOP]); + } +#endif + // done with mobj queues M_QueueFree(&spawnqueue); M_QueueFree(&anchorqueue); @@ -1789,8 +1820,6 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)wp; @@ -1875,8 +1904,6 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)wp; @@ -1916,8 +1943,6 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)wp; @@ -1955,8 +1980,6 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)wp; @@ -2477,8 +2500,6 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)wp; diff --git a/src/p_saveg.c b/src/p_saveg.c index ca41198ab..be393c51b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1879,8 +1879,6 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mobj = (mobj_t *)th; if (mobj->mobjnum != oldposition) @@ -3001,12 +2999,11 @@ static inline void P_FinishMobjs(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - if (currentthinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - mobj = (mobj_t *)currentthinker; - mobj->info = &mobjinfo[mobj->type]; + if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) + { + mobj = (mobj_t *)currentthinker; + mobj->info = &mobjinfo[mobj->type]; + } } } @@ -3020,71 +3017,69 @@ static void P_RelinkPointers(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - if (currentthinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; + if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) + { + mobj = (mobj_t *)currentthinker; - mobj = (mobj_t *)currentthinker; + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + continue; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) - continue; - - if (mobj->tracer) - { - temp = (UINT32)(size_t)mobj->tracer; - mobj->tracer = NULL; - if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); - } - if (mobj->target) - { - temp = (UINT32)(size_t)mobj->target; - mobj->target = NULL; - if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); - } - if (mobj->hnext) - { - temp = (UINT32)(size_t)mobj->hnext; - mobj->hnext = NULL; - if (!P_SetTarget(&mobj->hnext, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); - } - if (mobj->hprev) - { - temp = (UINT32)(size_t)mobj->hprev; - mobj->hprev = NULL; - if (!P_SetTarget(&mobj->hprev, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->capsule) - { - temp = (UINT32)(size_t)mobj->player->capsule; - mobj->player->capsule = NULL; - if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis1) - { - temp = (UINT32)(size_t)mobj->player->axis1; - mobj->player->axis1 = NULL; - if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis2) - { - temp = (UINT32)(size_t)mobj->player->axis2; - mobj->player->axis2 = NULL; - if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->awayviewmobj) - { - temp = (UINT32)(size_t)mobj->player->awayviewmobj; - mobj->player->awayviewmobj = NULL; - if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); + if (mobj->tracer) + { + temp = (UINT32)(size_t)mobj->tracer; + mobj->tracer = NULL; + if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); + } + if (mobj->target) + { + temp = (UINT32)(size_t)mobj->target; + mobj->target = NULL; + if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); + } + if (mobj->hnext) + { + temp = (UINT32)(size_t)mobj->hnext; + mobj->hnext = NULL; + if (!P_SetTarget(&mobj->hnext, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); + } + if (mobj->hprev) + { + temp = (UINT32)(size_t)mobj->hprev; + mobj->hprev = NULL; + if (!P_SetTarget(&mobj->hprev, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->capsule) + { + temp = (UINT32)(size_t)mobj->player->capsule; + mobj->player->capsule = NULL; + if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->axis1) + { + temp = (UINT32)(size_t)mobj->player->axis1; + mobj->player->axis1 = NULL; + if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->axis2) + { + temp = (UINT32)(size_t)mobj->player->axis2; + mobj->player->axis2 = NULL; + if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->awayviewmobj) + { + temp = (UINT32)(size_t)mobj->player->awayviewmobj; + mobj->player->awayviewmobj = NULL; + if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); + } } } } @@ -3460,14 +3455,13 @@ void P_SaveNetGame(void) { for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - mobj = (mobj_t *)th; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) - continue; - mobj->mobjnum = i++; + if (th->function.acp1 == (actionf_p1)P_MobjThinker) + { + mobj = (mobj_t *)th; + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + continue; + mobj->mobjnum = i++; + } } } diff --git a/src/p_setup.c b/src/p_setup.c index 2f17d6d24..c150a2f2f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -752,8 +752,6 @@ void P_ReloadRings(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo = (mobj_t *)th; @@ -2197,6 +2195,7 @@ static void P_LevelInitStuff(void) void P_LoadThingsOnly(void) { // Search through all the thinkers. + mobj_t *mo; thinker_t *think; virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); @@ -2205,10 +2204,12 @@ void P_LoadThingsOnly(void) for (think = thinkercap.next; think != &thinkercap; think = think->next) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - P_RemoveMobj((mobj_t *)think); + continue; // not a mobj thinker + + mo = (mobj_t *)think; + + if (mo) + P_RemoveMobj(mo); } P_LevelInitStuff(); diff --git a/src/p_spec.c b/src/p_spec.c index 4fa7a5275..2e8b09a12 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2989,8 +2989,6 @@ void P_SetupSignExit(player_t *player) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker - if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; thing = (mobj_t *)think; if (thing->type != MT_SIGN) @@ -3040,8 +3038,6 @@ boolean P_IsFlagAtBase(mobjtype_t flag) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker - if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo = (mobj_t *)think; @@ -3476,8 +3472,6 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -3820,8 +3814,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -3901,8 +3893,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -4124,8 +4114,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -4164,8 +4152,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -4193,8 +4179,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; diff --git a/src/p_tick.c b/src/p_tick.c index edb57236a..2bf7f1024 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -155,8 +155,6 @@ void Command_CountMobjs_f(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; if (((mobj_t *)th)->type == i) count++; @@ -177,8 +175,6 @@ void Command_CountMobjs_f(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; if (((mobj_t *)th)->type == i) count++; diff --git a/src/p_user.c b/src/p_user.c index c14a4c541..4a74657fd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1142,8 +1142,6 @@ void P_SpawnShieldOrb(player_t *player) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; shieldobj = (mobj_t *)th; @@ -1872,8 +1870,6 @@ void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -2626,8 +2622,6 @@ static void P_DoZoomTube(player_t *player) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -2723,8 +2717,6 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker - if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo = (mobj_t *)think; @@ -2805,8 +2797,6 @@ boolean P_LookForEnemies(player_t *player) { if (think->function.acp1 != (actionf_p1)P_MobjThinker) continue; // not a mobj thinker - if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo = (mobj_t *)think; if (!(mo->flags & (MF_ENEMY|MF_BOSS|MF_MONITOR|MF_SPRING))) @@ -2932,8 +2922,6 @@ void P_FindEmerald(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; if (mo2->type == MT_EMERHUNT) @@ -4656,8 +4644,6 @@ void P_PlayerThink(player_t *player) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; diff --git a/src/r_data.c b/src/r_data.c index a725d2ac9..ad8b420f3 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1687,8 +1687,7 @@ void R_PrecacheLevel(void) for (th = thinkercap.next; th != &thinkercap; th = th->next) if (th->function.acp1 == (actionf_p1)P_MobjThinker) - if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) - spritepresent[((mobj_t *)th)->sprite] = 1; + spritepresent[((mobj_t *)th)->sprite] = 1; spritememory = 0; for (i = 0; i < numsprites; i++) -- 2.54.0 From b3f16e935d59e13457092b09c2bda4bd4d674c3a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 17:37:46 +0200 Subject: [PATCH 270/525] Revert "more mobj reference fixes + cleanup" This reverts commit bd8ff77fe00700aada3495b4b5c8ac583f1051ef. --- src/g_game.c | 1 + src/lua_script.c | 24 +++---- src/m_cheat.c | 5 +- src/p_enemy.c | 8 +-- src/p_floor.c | 24 +++++++ src/p_mobj.c | 71 ++++++++++---------- src/p_polyobj.c | 165 +++++++++++++++++++++++++++-------------------- src/p_saveg.c | 20 +++--- src/p_spec.c | 53 +++++++-------- src/p_user.c | 20 +++--- 10 files changed, 213 insertions(+), 178 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index bc881c5d5..c1629af5a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5658,6 +5658,7 @@ void G_ConsGhostTic(INT32 playernum) mobj = (mobj_t *)th; if (mobj->type == (mobjtype_t)type && mobj->x == x && mobj->y == y && mobj->z == z) break; + mobj = NULL; // wasn't this one, keep searching. } if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { diff --git a/src/lua_script.c b/src/lua_script.c index 5a2f6448c..85aefbfbd 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1597,14 +1597,12 @@ void LUA_Archive(void) if (gamestate == GS_LEVEL) { for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - // archive function will determine when to skip mobjs, - // and write mobjnum in otherwise. - ArchiveExtVars(th, "mobj"); - } + if (th->function.acp1 == (actionf_p1)P_MobjThinker) + { + // archive function will determine when to skip mobjs, + // and write mobjnum in otherwise. + ArchiveExtVars(th, "mobj"); + } } WRITEUINT32(save_p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. @@ -1634,13 +1632,9 @@ void LUA_UnArchive(void) do { mobjnum = READUINT32(save_p); // read a mobjnum for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - if (((mobj_t *)th)->mobjnum != mobjnum) // find matching mobj - continue; - UnArchiveExtVars(th); // apply variables - } + if (th->function.acp1 == (actionf_p1)P_MobjThinker + && ((mobj_t *)th)->mobjnum == mobjnum) // find matching mobj + UnArchiveExtVars(th); // apply variables } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. LUAh_NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode diff --git a/src/m_cheat.c b/src/m_cheat.c index abada4be5..91ca536c8 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -909,9 +909,8 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mo = (mobj_t *)th; // get offset from mt, which points to old mapthings, then add new location - if (!mo->spawnpoint) - continue; - mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; + if (mo->spawnpoint) + mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; } } diff --git a/src/p_enemy.c b/src/p_enemy.c index 3a032fbf0..caa85e331 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2418,11 +2418,9 @@ void A_1upThinker(mobj_t *actor) if (closestplayer == -1 || skins[players[closestplayer].skin].spritedef.numframes <= states[S_PLAY_BOX1].frame) { // Closest player not found (no players in game?? may be empty dedicated server!), or does not have correct sprite. actor->frame = 0; - if (actor->tracer) - { - mobj_t *tracer = actor->tracer; - P_SetTarget(&actor->tracer, NULL); - P_RemoveMobj(tracer); + if (actor->tracer) { + P_RemoveMobj(actor->tracer); + P_SetTarget(&actor->target, NULL); } return; } diff --git a/src/p_floor.c b/src/p_floor.c index bebc9a272..27460eda6 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1968,8 +1968,32 @@ void T_ThwompSector(levelspecthink_t *thwomp) } else // Not going anywhere, so look for players. { + //thinker_t *th; + //mobj_t *mo; + thwomp->direction = -1; + /* // SRB2kart 170217 - Thwomps are automatic. + // scan the thinkers to find players! + if (!rover || (rover->flags & FF_EXISTS)) + { + // scan the thinkers to find players! + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo = (mobj_t *)th; + if (mo->type == MT_PLAYER && mo->health && mo->player && !mo->player->spectator + && mo->z <= thwomp->sector->ceilingheight + && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) + { + thwomp->direction = -1; + break; + } + } + }*/ + thwomp->sector->ceilspeed = 0; thwomp->sector->floorspeed = 0; } diff --git a/src/p_mobj.c b/src/p_mobj.c index 78fcb8f63..37af3777c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4124,21 +4124,11 @@ static void P_Boss3Thinker(mobj_t *mobj) continue; mo2 = (mobj_t *)th; - - if (!mo2) - continue; - - if (mo2->type != MT_BOSS3WAYPOINT) - continue; - - if (!mo2->spawnpoint) - continue; - - if (mo2->spawnpoint->angle != mobj->threshold) - continue; - - P_SetTarget(&mobj->target, mo2); - break; + if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && mo2->spawnpoint->angle == mobj->threshold) + { + P_SetTarget(&mobj->target, mo2); + break; + } } if (!mobj->target) // Should NEVER happen @@ -10052,19 +10042,28 @@ void P_RemoveMobj(mobj_t *mobj) // killough 11/98: // // Remove any references to other mobjs. - P_SetTarget(&mobj->target, NULL); - P_SetTarget(&mobj->tracer, NULL); + P_SetTarget(&mobj->target, P_SetTarget(&mobj->tracer, NULL)); - if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); - if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) - P_SetTarget(&mobj->hprev->hnext, mobj->hnext); + // repair hnext chain + { + mobj_t *cachenext = mobj->hnext; - P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) + { + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + P_SetTarget(&mobj->hnext, NULL); + } + + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) + { + P_SetTarget(&mobj->hprev->hnext, cachenext); + P_SetTarget(&mobj->hprev, NULL); + } + } // clear the reference from the mapthing if (mobj->spawnpoint) - P_SetTarget(&mobj->spawnpoint->mobj, NULL); + mobj->spawnpoint->mobj = NULL; R_RemoveMobjInterpolator(mobj); @@ -11815,12 +11814,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) { P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; } else - { - P_SetTarget(&mobj->hprev, NULL); - P_SetTarget(&mobj->hnext, NULL); - } + mobj->hprev = mobj->hnext = NULL; nextmobj = mobj; } @@ -11846,9 +11844,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->z -= mobj->height/2; // Link all the collision sprites together. - P_SetTarget(&mobj->hnext, NULL); + mobj->hnext = NULL; P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; nextmobj = mobj; } @@ -11873,9 +11873,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->z -= mobj->height/2; // Link all the collision sprites together. - P_SetTarget(&mobj->hnext, NULL); + mobj->hnext = NULL; P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; nextmobj = mobj; } @@ -11958,12 +11960,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) { P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; } else - { - P_SetTarget(&mobj->hprev, NULL); - P_SetTarget(&mobj->hnext, NULL); - } + mobj->hprev = mobj->hnext = NULL; nextmobj = mobj; } @@ -12000,9 +12001,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->z -= mobj->height/2; // Link all the collision sprites together. - P_SetTarget(&mobj->hnext, NULL); + mobj->hnext = NULL; P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); + //mobj->hprev = nextmobj; + //mobj->hprev->hnext = mobj; nextmobj = mobj; } diff --git a/src/p_polyobj.c b/src/p_polyobj.c index bbf934231..9a3376595 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1826,14 +1826,11 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (mo2->health != th->pointnum) - continue; - - target = mo2; - break; + if (mo2->threshold == th->sequence && mo2->health == th->pointnum) + { + target = mo2; + break; + } } if (!target) @@ -1910,23 +1907,23 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (th->direction == -1) + if (mo2->threshold == th->sequence) { - if (mo2->health == target->health - 1) + if (th->direction == -1) { - waypoint = mo2; - break; + if (mo2->health == target->health - 1) + { + waypoint = mo2; + break; + } } - } - else - { - if (mo2->health == target->health + 1) + else { - waypoint = mo2; - break; + if (mo2->health == target->health + 1) + { + waypoint = mo2; + break; + } } } } @@ -1949,22 +1946,22 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (th->direction == -1) + if (mo2->threshold == th->sequence) { - if (waypoint == NULL) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; - } - else - { - if (mo2->health == 0) + if (th->direction == -1) { - waypoint = mo2; - break; + if (waypoint == NULL) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; + } + else + { + if (mo2->health == 0) + { + waypoint = mo2; + break; + } } } } @@ -1986,23 +1983,23 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (th->direction == -1) + if (mo2->threshold == th->sequence) { - if (mo2->health == target->health - 1) + if (th->direction == -1) { - waypoint = mo2; - break; + if (mo2->health == target->health - 1) + { + waypoint = mo2; + break; + } } - } - else - { - if (mo2->health == target->health + 1) + else { - waypoint = mo2; - break; + if (mo2->health == target->health + 1) + { + waypoint = mo2; + break; + } } } } @@ -2506,31 +2503,31 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != th->sequence) - continue; - - if (th->direction == -1) // highest waypoint # + if (mo2->threshold == th->sequence) { - if (mo2->health == 0) - last = mo2; - else + if (th->direction == -1) // highest waypoint # { - if (first == NULL) - first = mo2; - else if (mo2->health > first->health) - first = mo2; + if (mo2->health == 0) + last = mo2; + else + { + if (first == NULL) + first = mo2; + else if (mo2->health > first->health) + first = mo2; + } } - } - else // waypoint 0 - { - if (mo2->health == 0) - first = mo2; - else + else // waypoint 0 { - if (last == NULL) - last = mo2; - else if (mo2->health > last->health) - last = mo2; + if (mo2->health == 0) + first = mo2; + else + { + if (last == NULL) + last = mo2; + else if (mo2->health > last->health) + last = mo2; + } } } } @@ -2567,6 +2564,36 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) // Find the actual target movement waypoint target = first; + /*for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + { + if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + continue; + + mo2 = (mobj_t *)wp; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold == th->sequence) + { + if (th->direction == -1) // highest waypoint # + { + if (mo2->health == first->health - 1) + { + target = mo2; + break; + } + } + else // waypoint 0 + { + if (mo2->health == first->health + 1) + { + target = mo2; + break; + } + } + } + }*/ if (!target) { diff --git a/src/p_saveg.c b/src/p_saveg.c index be393c51b..e260321be 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1881,10 +1881,8 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) continue; mobj = (mobj_t *)th; - if (mobj->mobjnum != oldposition) - continue; - - return mobj; + if (mobj->mobjnum == oldposition) + return mobj; } CONS_Debug(DBG_GAMELOGIC, "mobj not found\n"); return NULL; @@ -2883,14 +2881,12 @@ static void P_NetUnArchiveThinkers(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 != (actionf_p1)T_ExecutorDelay) - continue; - - delay = (void *)currentthinker; - if (!(mobjnum = (UINT32)(size_t)delay->caller)) - continue; - - delay->caller = P_FindNewPosition(mobjnum); + if (currentthinker->function.acp1 == (actionf_p1)T_ExecutorDelay) + { + delay = (void *)currentthinker; + if ((mobjnum = (UINT32)(size_t)delay->caller)) + delay->caller = P_FindNewPosition(mobjnum); + } } } } diff --git a/src/p_spec.c b/src/p_spec.c index 2e8b09a12..370afc056 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3032,7 +3032,7 @@ boolean P_IsFlagAtBase(mobjtype_t flag) { thinker_t *think; mobj_t *mo; - INT32 specialnum = (flag == MT_REDFLAG) ? 3 : 4; + INT32 specialnum = 0; for (think = thinkercap.next; think != &thinkercap; think = think->next) { @@ -3044,6 +3044,11 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (mo->type != flag) continue; + if (mo->type == MT_REDFLAG) + specialnum = 3; + else if (mo->type == MT_BLUEFLAG) + specialnum = 4; + if (GETSECSPECIAL(mo->subsector->sector->special, 4) == specialnum) return true; else if (mo->subsector->sector->ffloors) // Check the 3D floors @@ -3058,11 +3063,9 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (GETSECSPECIAL(rover->master->frontsector->special, 4) != specialnum) continue; - if (!(mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) - && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))) - continue; - - return true; + if (mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) + && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector)) + return true; } } } @@ -3474,11 +3477,8 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers continue; mo2 = (mobj_t *)th; - - if (mo2->type != MT_EGGTRAP) - continue; - - P_KillMobj(mo2, NULL, player->mo); + if (mo2->type == MT_EGGTRAP) + P_KillMobj(mo2, NULL, player->mo); } // clear the special so you can't push the button twice. @@ -3817,15 +3817,12 @@ DoneSection2: mo2 = (mobj_t *)th; - if (mo2->type != MT_TUBEWAYPOINT) - continue; - if (mo2->threshold != sequence) - continue; - if (mo2->health != 0) - continue; - - waypoint = mo2; - break; + if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence + && mo2->health == 0) + { + waypoint = mo2; + break; + } } if (!waypoint) @@ -3896,15 +3893,13 @@ DoneSection2: mo2 = (mobj_t *)th; - if (mo2->type != MT_TUBEWAYPOINT) - continue; - if (mo2->threshold != sequence) - continue; - - if (!waypoint) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; + if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence) + { + if (!waypoint) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; + } } if (!waypoint) diff --git a/src/p_user.c b/src/p_user.c index 4a74657fd..60661e4c2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2628,17 +2628,15 @@ static void P_DoZoomTube(player_t *player) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold != sequence) - continue; - - if (reverse && mo2->health != player->mo->tracer->health - 1) - continue; - - if (!reverse && mo2->health != player->mo->tracer->health + 1) - continue; - - waypoint = mo2; - break; + if (mo2->threshold == sequence) + { + if ((reverse && mo2->health == player->mo->tracer->health - 1) + || (!reverse && mo2->health == player->mo->tracer->health + 1)) + { + waypoint = mo2; + break; + } + } } if (waypoint) -- 2.54.0 From d675b98330e92035bc14b9589d71f0dc7b009b76 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 17:38:15 +0200 Subject: [PATCH 271/525] Revert "Fix mobj reference management of player->mo" This reverts commit c5ec61baa5653029d5c01eeac3faca9ca1ff4538. --- src/g_game.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++-- src/p_mobj.c | 4 +-- src/p_user.c | 2 +- 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c1629af5a..ff459c59a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3072,6 +3072,12 @@ void G_DoReborn(INT32 playernum) player_t *player = &players[playernum]; boolean starpost = false; + /*if (modeattacking) // Not needed for SRB2Kart. + { + M_EndModeAttackRun(); + return; + }*/ + // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); @@ -3085,13 +3091,74 @@ void G_DoReborn(INT32 playernum) oldmo = player->mo; // Don't leave your carcass stuck 10-billion feet in the ground! P_RemoveMobj(player->mo); - P_SetTarget(&player->mo, NULL); } B_RespawnBot(playernum); if (oldmo) G_ChangePlayerReferences(oldmo, players[playernum].mo); } + /*else if (countdowntimeup || (!multiplayer && !modeattacking)) + { + // reload the level from scratch + if (countdowntimeup) + { + player->starpostangle = 0; + player->starposttime = 0; + player->starpostx = 0; + player->starposty = 0; + player->starpostz = 0; + player->starpostnum = 0; + } + if (!countdowntimeup && (mapheaderinfo[gamemap-1]->levelflags & LF_NORELOAD)) + { + INT32 i; + + player->playerstate = PST_REBORN; + + P_LoadThingsOnly(); + + // Do a wipe + wipegamestate = -1; + + if (player->starpostnum) // SRB2kart + starpost = true; + + for (i = 0; i <= splitscreen; i++) + { + if (camera[i].chase) + P_ResetCamera(&players[displayplayers[i]], &camera[i]); + } + + // clear cmd building stuff + memset(gamekeydown, 0, sizeof (gamekeydown)); + for (i = 0;i < JOYAXISSET; i++) + { + joyxmove[i] = joyymove[i] = 0; + joy2xmove[i] = joy2ymove[i] = 0; + joy3xmove[i] = joy3ymove[i] = 0; + joy4xmove[i] = joy4ymove[i] = 0; + } + mousex = mousey = 0; + mouse2x = mouse2y = 0; + + // clear hud messages remains (usually from game startup) + CON_ClearHUD(); + + // Starpost support + G_SpawnPlayer(playernum, starpost); + + if (botingame) + { // Bots respawn next to their master. + players[displayplayers[1]].playerstate = PST_REBORN; + G_SpawnPlayer(displayplayers[1], false); + } + } + else + { + LUAh_MapChange(gamemap); + G_DoLoadLevel(true); + } + }*/ else { // respawn at the start @@ -3108,7 +3175,6 @@ void G_DoReborn(INT32 playernum) oldmo = player->mo; // Don't leave your carcass stuck 10-billion feet in the ground! P_RemoveMobj(player->mo); - P_SetTarget(&player->mo, NULL); } G_SpawnPlayer(playernum, starpost); diff --git a/src/p_mobj.c b/src/p_mobj.c index 37af3777c..a0d80b413 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10597,9 +10597,7 @@ void P_SpawnPlayer(INT32 playernum) mobj = P_SpawnMobj(0, 0, 0, MT_PLAYER); I_Assert(mobj != NULL); - - mobj->player = p; - P_SetTarget(&p->mo, mobj); + (mobj->player = p)->mo = mobj; mobj->angle = 0; diff --git a/src/p_user.c b/src/p_user.c index 60661e4c2..118c1d06d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4025,7 +4025,7 @@ boolean P_SpectatorJoinGame(player_t *player) if (player->mo) { P_RemoveMobj(player->mo); - P_SetTarget(&player->mo, NULL); + player->mo = NULL; } player->spectator = false; player->pflags &= ~PF_WANTSTOJOIN; -- 2.54.0 From 023cade51d742199e936c23bc45b13a10748d697 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 15:04:01 +0200 Subject: [PATCH 272/525] smol fix to frameskipping --- src/d_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 161ed604e..1c7fc63e1 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -839,6 +839,8 @@ void D_SRB2Loop(void) // Fully completed frame made. finishprecise = I_GetPreciseTime(); + // Use the time before sleep for frameskip calculations: + // post-sleep time is literally being intentionally wasted deltasecs = (double)((INT64)(finishprecise - enterprecise)) / I_GetPrecisePrecision(); deltatics = deltasecs * NEWTICRATE; @@ -873,6 +875,8 @@ void D_SRB2Loop(void) } // Capture the time once more to get the real delta time. finishprecise = I_GetPreciseTime(); + deltasecs = (double)((INT64)(finishprecise - enterprecise)) / I_GetPrecisePrecision(); + deltatics = deltasecs * NEWTICRATE; } } -- 2.54.0 From e11363db3a2d235d6771b24a3b0903125172a87a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 15:04:14 +0200 Subject: [PATCH 273/525] Fix sound falloff calculation overflow --- src/s_sound.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index e6f2af24a..fe44d51a1 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1046,7 +1046,8 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 if (sfxinfo->pitch & SF_OUTSIDESOUND) // Rain special case { - fixed_t x, y, yl, yh, xl, xh, newdist; + INT64 x, y, yl, yh, xl, xh; + fixed_t newdist; if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum) approx_dist = 0; -- 2.54.0 From 9fceabed8f2a27f6a3162416845fd01756aeb7e0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 15:04:25 +0200 Subject: [PATCH 274/525] Ensure Z_Malloc provides same alignment as libc --- src/z_zone.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/z_zone.c b/src/z_zone.c index b0223460b..dd10f36e3 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -25,6 +25,9 @@ /// allocator was fragmenting badly. Finally, this version is a bit /// simpler (about half the lines of code). +#include +#include + #include "doomdef.h" #include "doomstat.h" #include "r_patch.h" @@ -67,8 +70,9 @@ typedef struct memblock_s struct memblock_s *next, *prev; } memblock_t; -#define MEMORY(x) (void *)((uintptr_t)(x) + sizeof(memblock_t)) -#define MEMBLOCK(x) (memblock_t *)((uintptr_t)(x) - sizeof(memblock_t)) +#define ALIGNPAD (((sizeof (memblock_t) + (alignof (max_align_t) - 1)) & ~(alignof (max_align_t) - 1)) - sizeof (memblock_t)) +#define MEMORY(x) (void *)((uintptr_t)(x) + sizeof(memblock_t) + ALIGNPAD) +#define MEMBLOCK(x) (memblock_t *)((uintptr_t)(x) - ALIGNPAD - sizeof(memblock_t)) // both the head and tail of the zone memory block list static memblock_t head; @@ -219,15 +223,16 @@ void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) { memblock_t *block; void *ptr; - (void)(alignbits); // no longer used, so silence warnings. + + (void)(alignbits); // no longer used, so silence warnings. TODO we should figure out a solution for this #ifdef ZDEBUG2 CONS_Debug(DBG_MEMORY, "Z_Malloc %s:%d\n", file, line); #endif - block = xm(sizeof (memblock_t) + size); + block = xm(sizeof (memblock_t) + ALIGNPAD + size); ptr = MEMORY(block); - I_Assert((intptr_t)ptr % sizeof (void *) == 0); + I_Assert((intptr_t)ptr % alignof (max_align_t) == 0); #ifdef HAVE_VALGRIND Z_calloc = false; -- 2.54.0 From 99779629d0789f1775605cefdcca3721e2196ef9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 15:04:47 +0200 Subject: [PATCH 275/525] dont always reset texture depth in ogl --- src/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screen.c b/src/screen.c index e5c1ebff4..8fe00e821 100644 --- a/src/screen.c +++ b/src/screen.c @@ -331,7 +331,7 @@ void SCR_SetDefaultMode(void) // remember the default screen size CV_SetValue(&cv_scr_width, vid.width); CV_SetValue(&cv_scr_height, vid.height); - CV_SetValue(&cv_scr_depth, vid.bpp*8); + //CV_SetValue(&cv_scr_depth, vid.bpp*8); } // Change fullscreen on/off according to cv_fullscreen -- 2.54.0 From 685220140a2b1cd6e60ac9b62236712e0d156c7c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 15:05:19 +0200 Subject: [PATCH 276/525] fix potential crash on nix while quitting --- src/sdl/i_system.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index b20eeba7d..7a7cd7e7e 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3402,13 +3402,13 @@ INT32 I_StartupSystem(void) SDL_version SDLlinked; SDL_VERSION(&SDLcompiled) SDL_GetVersion(&SDLlinked); -#ifdef HAVE_THREADS - I_start_threads(); - I_AddExitFunc(I_stop_threads); -#endif I_StartupConsole(); #ifdef NEWSIGNALHANDLER I_Fork(); +#endif +#ifdef HAVE_THREADS + I_start_threads(); + I_AddExitFunc(I_stop_threads); #endif I_RegisterSignals(); I_OutputMsg("Compiled for SDL version: %d.%d.%d\n", -- 2.54.0 From 2448a0b735787265ed29bc1d0ce32760e89a1176 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 15:35:47 +0200 Subject: [PATCH 277/525] Cache pk3 central directory and Refactor ResFindSignature to work in chunks https://github.com/KartKrewDev/RingRacers/commit/8ca2dc77e75b1ba8c511380257f0bbaf6d21c27b https://github.com/KartKrewDev/RingRacers/commit/dedd0047bd8f9f73aba4defc19c429af7c987983 --- src/w_wad.c | 164 ++++++++++++++++++++++++++++------------------------ 1 file changed, 90 insertions(+), 74 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 762cdc417..8df0654f0 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -464,27 +464,53 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen */ static boolean ResFindSignature (FILE* handle, char endPat[], UINT32 startpos) { + //the Wii U has rather slow filesystem access, and fgetc is *unbearable* + //so I reimplemented this function to buffer 128k chunks char *s; int c; + fseek(handle, 0, SEEK_END); + size_t len = ftell(handle); + fseek(handle, startpos, SEEK_SET); + size_t remaining = len - startpos; + size_t chunkpos = startpos; + s = endPat; - while((c = fgetc(handle)) != EOF) - { - if (*s != c && s > endPat) // No match? - s = endPat; // We "reset" the counter by sending the s pointer back to the start of the array. - if (*s == c) - { - s++; - if (*s == 0x00) // The array pointer has reached the key char which marks the end. It means we have matched the signature. + + //128k buffers + size_t buffer_size = min(128 * 1024 * sizeof(char), remaining); + char* buffer = (char*)(malloc(buffer_size)); + + size_t bytes_read = 0; + while ((bytes_read = fread(buffer, 1, buffer_size, handle)) > 0) { + for (size_t i = 0; i < bytes_read; i++) { + c = (int)buffer[i]; + + if (*s != c && s > endPat) // No match? + s = endPat; // We "reset" the counter by sending the s pointer back to the start of the array. + if (*s == c) { - return true; + s++; + if (*s == 0x00) // The array pointer has reached the key char which marks the end. It means we have matched the signature. + { + //the original function would leave the FILE* seeked to the end of the match + size_t foundpos = chunkpos + i + 1; + fseek(handle, foundpos, SEEK_SET); + + free(buffer); + return true; + } } } + chunkpos += bytes_read; } + + free(buffer); return false; } + #if defined(_MSC_VER) #pragma pack(1) #endif @@ -544,7 +570,6 @@ typedef struct zlentry_s static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) { zend_t zend; - zentry_t zentry; zlentry_t zlentry; UINT16 numlumps = *nlmp; @@ -570,42 +595,45 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) CONS_Alert(CONS_ERROR, "Corrupt central directory (%s)\n", M_FileError(handle)); return NULL; } - numlumps = zend.entries; + numlumps = SHORT(zend.entries); lump_p = lumpinfo = Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL); - fseek(handle, zend.cdiroffset, SEEK_SET); + fseek(handle, LONG(zend.cdiroffset), SEEK_SET); + + char *cdir = (Z_MallocAlign(LONG(zend.cdirsize), PU_STATIC, &cdir, 7)); + + if (fread(cdir, 1, LONG(zend.cdirsize), handle) < (UINT32)(LONG(zend.cdirsize))) + { + CONS_Alert(CONS_ERROR, "Failed to read central directory (%s)\n", M_FileError(handle)); + Z_Free(cdir); + Z_Free(lumpinfo); + return NULL; + } + + size_t offset = 0; + for (i = 0; i < numlumps; i++, lump_p++) { + zentry_t *zentry = (zentry_t*)(cdir + offset); char* fullname; char* trimname; char* dotpos; - if (fread(&zentry, 1, sizeof(zentry_t), handle) < sizeof(zentry_t)) - { - CONS_Alert(CONS_ERROR, "Failed to read central directory (%s)\n", M_FileError(handle)); - Z_Free(lumpinfo); - return NULL; - } - if (memcmp(zentry.signature, pat_central, 4)) + if (memcmp(zentry->signature, pat_central, 4)) { CONS_Alert(CONS_ERROR, "Central directory is corrupt\n"); + Z_Free(cdir); Z_Free(lumpinfo); return NULL; } - lump_p->position = zentry.offset; // NOT ACCURATE YET: we still need to read the local entry to find our true position - lump_p->disksize = zentry.compsize; - lump_p->size = zentry.size; + lump_p->position = LONG(zentry->offset); // NOT ACCURATE YET: we still need to read the local entry to find our true position + lump_p->disksize = LONG(zentry->compsize); + lump_p->size = LONG(zentry->size); - fullname = malloc(zentry.namelen + 1); - if (fgets(fullname, zentry.namelen + 1, handle) != fullname) - { - CONS_Alert(CONS_ERROR, "Unable to read lumpname (%s)\n", M_FileError(handle)); - Z_Free(lumpinfo); - free(fullname); - return NULL; - } + fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); + strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != 0) @@ -622,10 +650,10 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) lump_p->longname = Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL); strlcpy(lump_p->longname, trimname, dotpos - trimname + 1); - lump_p->fullname = Z_Calloc(zentry.namelen + 1, PU_STATIC, NULL); - strncpy(lump_p->fullname, fullname, zentry.namelen); + lump_p->fullname = (char*)(Z_Calloc(SHORT(zentry->namelen) + 1, PU_STATIC, NULL)); + strncpy(lump_p->fullname, fullname, SHORT(zentry->namelen)); - switch(zentry.compression) + switch(SHORT(zentry->compression)) { case 0: lump_p->compression = CM_NOCOMPRESSION; @@ -646,14 +674,11 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) free(fullname); // skip and ignore comments/extra fields - if (fseek(handle, zentry.xtralen + zentry.commlen, SEEK_CUR) != 0) - { - CONS_Alert(CONS_ERROR, "Central directory is corrupt\n"); - Z_Free(lumpinfo); - return NULL; - } + offset += sizeof *zentry + SHORT(zentry->namelen) + SHORT(zentry->xtralen) + SHORT(zentry->commlen); } + Z_Free(cdir); + // Adjust lump position values properly for (i = 0, lump_p = lumpinfo; i < numlumps; i++, lump_p++) { @@ -665,7 +690,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) return NULL; } - lump_p->position += sizeof(zlentry_t) + zlentry.namelen + zlentry.xtralen; + lump_p->position += sizeof(zlentry_t) + SHORT(zlentry.namelen) + SHORT(zlentry.xtralen); } *nlmp = numlumps; @@ -1895,14 +1920,11 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) int verified = true; zend_t zend; - zentry_t zentry; zlentry_t zlentry; long file_size;/* size of zip file */ long data_size;/* size of data inside zip file */ - long old_position; - UINT16 numlumps; size_t i; @@ -1928,28 +1950,31 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) data_size = sizeof zend; - numlumps = zend.entries; + numlumps = SHORT(zend.entries); + + fseek(fp, LONG(zend.cdiroffset), SEEK_SET); + + char *cdir = (char*)(malloc(LONG(zend.cdirsize))); + + if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize))) + return true; + + size_t offset = 0; - fseek(fp, zend.cdiroffset, SEEK_SET); for (i = 0; i < numlumps; i++) { + zentry_t *zentry = (zentry_t*)(cdir + offset); char* fullname; char* trimname; char* dotpos; - if (fread(&zentry, 1, sizeof(zentry_t), fp) < sizeof(zentry_t)) - return true; - if (memcmp(zentry.signature, pat_central, 4)) + if (memcmp(zentry->signature, pat_central, 4) != 0) return true; if (verified == true) { - fullname = malloc(zentry.namelen + 1); - if (fgets(fullname, zentry.namelen + 1, fp) != fullname) - { - free(fullname); - return true; - } + fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); + strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != 0) @@ -1974,34 +1999,25 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) } free(fullname); + } - // skip and ignore comments/extra fields - if (fseek(fp, zentry.xtralen + zentry.commlen, SEEK_CUR) != 0) - return true; - } - else - { - if (fseek(fp, zentry.namelen + zentry.xtralen + zentry.commlen, SEEK_CUR) != 0) - return true; - } + offset += sizeof *zentry + SHORT(zentry->namelen) + SHORT(zentry->xtralen) + SHORT(zentry->commlen); data_size += - sizeof zentry + zentry.namelen + zentry.xtralen + zentry.commlen; + sizeof *zentry + SHORT(zentry->namelen) + SHORT(zentry->xtralen) + SHORT(zentry->commlen); - old_position = ftell(fp); - - if (fseek(fp, zentry.offset, SEEK_SET) != 0) + if (fseek(fp, LONG(zentry->offset), SEEK_SET) != 0) return true; if (fread(&zlentry, 1, sizeof(zlentry_t), fp) < sizeof (zlentry_t)) return true; data_size += - sizeof zlentry + zlentry.namelen + zlentry.xtralen + zlentry.compsize; - - fseek(fp, old_position, SEEK_SET); + sizeof zlentry + SHORT(zlentry.namelen) + SHORT(zlentry.xtralen) + LONG(zlentry.compsize); } + free(cdir); + if (data_size < file_size) { const char * error = "ZIP file has holes (%ld extra bytes)\n"; @@ -2127,14 +2143,14 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. UINT8 *wadData = W_CacheLumpNum(lumpnum, PU_LEVEL); - filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); + filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)wadData)->infotableofs)); - i = ((wadinfo_t *)wadData)->numlumps; + i = LONG(((wadinfo_t *)wadData)->numlumps); vsizecache = Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL); for (realentry = 0; realentry < i; realentry++) { - vsizecache[realentry] = (size_t)(((filelump_t *)(fileinfo + realentry))->size); + vsizecache[realentry] = (size_t)(LONG(((filelump_t *)(fileinfo + realentry))->size)); if (!vsizecache[realentry]) continue; @@ -2154,7 +2170,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) memcpy(vlumps[i].name, (fileinfo + realentry)->name, 8); vlumps[i].name[8] = '\0'; vlumps[i].data = Z_Malloc(vlumps[i].size, PU_LEVEL, NULL); // This is memory inefficient, sorry about that. - memcpy(vlumps[i].data, wadData + (fileinfo + realentry)->filepos, vlumps[i].size); + memcpy(vlumps[i].data, wadData + LONG((fileinfo + realentry)->filepos), vlumps[i].size); i++; } -- 2.54.0 From a6fc237c883bd6604d4ff60f0c23a15b20b8c813 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 15:37:23 +0200 Subject: [PATCH 278/525] try to prevent potential infinite SIGARBT hang in signal handler --- src/console.c | 8 ++++++-- src/i_system.h | 3 +++ src/sdl/i_system.c | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/console.c b/src/console.c index 90212469e..8bd8518f9 100644 --- a/src/console.c +++ b/src/console.c @@ -43,8 +43,12 @@ #ifdef HAVE_THREADS I_mutex con_mutex; -# define Lock_state() I_lock_mutex(&con_mutex) -# define Unlock_state() I_unlock_mutex(con_mutex) +// g_in_exiting_signal_handler is an evil hack +// to avoid infinite SIGABRT recursion in the signal handler +// due to poisoned locks or mach-o kernel not supporting locks in signals +// or something like that. idk +# define Lock_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&con_mutex); } +# define Unlock_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(con_mutex); } #else/*HAVE_THREADS*/ # define Lock_state() # define Unlock_state() diff --git a/src/i_system.h b/src/i_system.h index a78eb5c5e..f1d098e4a 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -34,6 +34,9 @@ extern UINT8 graphics_started; */ extern UINT8 keyboard_started; +/** \brief Set to true when inside a signal handler that will exit the program. */ +extern boolean g_in_exiting_signal_handler; + /** \brief The I_GetFreeMem function \param total total memory in the system diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 7a7cd7e7e..00bc3200f 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -446,6 +446,7 @@ SDL_bool consolevent = SDL_FALSE; SDL_bool framebuffer = SDL_FALSE; UINT8 keyboard_started = false; +boolean g_in_exiting_signal_handler = false; static void I_ReportSignal(int num, int coredumped) { @@ -512,6 +513,8 @@ static void I_ReportSignal(int num, int coredumped) #ifndef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { + g_in_exiting_signal_handler = true; + D_QuitNetGame(); // Fix server freezes #ifdef HAVE_LIBBACKTRACE -- 2.54.0 From 4b69b39d39cb3637f122ff99e4cec91e5259f903 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 15:49:01 +0200 Subject: [PATCH 279/525] HMS_fetch_rules: Return NULL if the curl connection failed, instead of producing garbled rules --- src/http-mserv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/http-mserv.c b/src/http-mserv.c index d1ef80ae4..9e32f9ea7 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -532,7 +532,9 @@ HMS_fetch_rules (char *buffer, size_t buffer_size) if (! hms) return NULL; - if (HMS_do(hms)) + boolean ok = HMS_do(hms); + + if (ok) { char *p = strstr(hms->buffer, "\n\n"); @@ -550,6 +552,9 @@ HMS_fetch_rules (char *buffer, size_t buffer_size) HMS_end(hms); + if (!ok) + return NULL; + return buffer; } -- 2.54.0 From fe6ad4f76269a2fef8c235c4c9cd9d8a90314fed Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 16:54:24 +0200 Subject: [PATCH 280/525] Do not run ST_Ticker if dedicated --- src/st_stuff.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 7e28edfc8..df4ba7db9 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -456,7 +456,9 @@ void ST_Start(void) ST_Stop(); ST_InitData(); - st_stopped = false; + + if (!dedicated) + st_stopped = false; } // -- 2.54.0 From 64ef0465d5bccf11d50dd990234df7b50c15f200 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 18:06:46 +0200 Subject: [PATCH 281/525] calloc soundchannels insteal of mallocing --- src/s_sound.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index fe44d51a1..0bc76bce2 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -311,8 +311,6 @@ void S_RegisterSoundStuff(void) static void SetChannelsNum(void) { - INT32 i; - // Allocating the internal channels for mixing // (the maximum number of sounds rendered // simultaneously) within zone memory. @@ -322,7 +320,6 @@ static void SetChannelsNum(void) Z_Free(channels); channels = NULL; - if (cv_numChannels.value == 999999999) //Alam_GBC: OH MY ROD!(ROD rimmiced with GOD!) CV_StealthSet(&cv_numChannels,cv_numChannels.defaultvalue); @@ -333,13 +330,10 @@ static void SetChannelsNum(void) return; } #endif - if (cv_numChannels.value) - channels = (channel_t *)Z_Malloc(cv_numChannels.value * sizeof (channel_t), PU_STATIC, NULL); - numofchannels = cv_numChannels.value; - // Free all channels for use - for (i = 0; i < numofchannels; i++) - channels[i].sfxinfo = 0; + if (cv_numChannels.value) + channels = (channel_t *)Z_Calloc(cv_numChannels.value * sizeof (channel_t), PU_STATIC, NULL); + numofchannels = (channels ? cv_numChannels.value : 0); } // Retrieve the lump number of sfx -- 2.54.0 From cd72bce3cbbb54e59a9d58c047bf6f9549c9cb49 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 18:13:28 +0200 Subject: [PATCH 282/525] dont reload palette until config was loaded --- src/d_main.c | 4 ++++ src/d_main.h | 2 ++ src/v_video.c | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 1c7fc63e1..3b6573e5c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -150,6 +150,8 @@ INT32 eventhead, eventtail; boolean dedicated = false; +boolean loaded_config = false; + // // D_PostEvent // Called by the I/O functions when input is detected @@ -1753,6 +1755,8 @@ void D_SRB2Main(void) savedata.lives = 0; // flag this as not-used + loaded_config = true; // so pallettechange doesent get called 500 times at startup lol + //------------------------------------------------ COMMAND LINE PARAMS // this must be done after loading gamedata, diff --git a/src/d_main.h b/src/d_main.h index d4d3e6e95..851eaa8b5 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -20,6 +20,8 @@ // make sure not to write back the config until it's been correctly loaded extern tic_t rendergametic; +extern boolean loaded_config; + extern char srb2home[256]; //Alam: My Home extern boolean usehome; //Alam: which path? extern const char *pandf; //Alam: how to path? diff --git a/src/v_video.c b/src/v_video.c index 4c5e1cfd3..202b5d288 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -14,6 +14,7 @@ /// Functions to blit a block to the screen. #include "doomdef.h" +#include "d_main.h" #include "r_local.h" #include "p_local.h" #include "v_video.h" @@ -132,6 +133,9 @@ static boolean InitCube(void) float globalgammamul, globalgammaoffs; boolean doinggamma; + if (loaded_config == false) + return false; + #define diffcons(cv) (cv.value != atoi(cv.defaultvalue)) doinggamma = diffcons(cv_globalgamma); @@ -568,6 +572,8 @@ void V_SetPaletteLump(const char *pal) static void CV_palette_OnChange(void) { + if (loaded_config == false) + return; // reload palette LoadMapPalette(); V_SetPalette(0); -- 2.54.0 From 5c7d9327e3bda82b1b0725be2cfd6ecb466ee147 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 18:18:29 +0200 Subject: [PATCH 283/525] SDL: only react to window focus changes if state actually changes --- src/sdl/i_video.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 16f4c4336..da055265e 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -775,6 +775,7 @@ void I_DownSample(void) static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { +#define FOCUSUNION (mousefocus | (kbfocus << 1)) static SDL_bool firsttimeonmouse = SDL_TRUE; static SDL_bool mousefocus = SDL_TRUE; static SDL_bool kbfocus = SDL_TRUE; @@ -782,6 +783,8 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) static SDL_bool windowmoved = SDL_FALSE; #endif + const unsigned int oldfocus = FOCUSUNION; + switch (evt.event) { case SDL_WINDOWEVENT_ENTER: @@ -807,6 +810,18 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) #endif } +#ifdef USE_FBO_OGL + if (windowmoved && rendermode == render_opengl) + { + I_DownSample(); + } +#endif + + if (FOCUSUNION == oldfocus) // No state change + { + return; + } + if (mousefocus && kbfocus) { // Tell game we got focus back, resume music if necessary @@ -843,13 +858,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) SDLdoUngrabMouse(); } } - -#ifdef USE_FBO_OGL - if (windowmoved && rendermode == render_opengl) - { - I_DownSample(); - } -#endif +#undef FOCUSUNION } static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) -- 2.54.0 From 4423fb300f8bac242c43ed10c7093d360f97e085 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jul 2024 19:54:08 +0200 Subject: [PATCH 284/525] set controller rgb to playercolor eh only for 1st player now no splitscreen support idk if everything here is even correct --- src/d_main.c | 4 ++++ src/d_netcmd.c | 2 ++ src/g_input.c | 19 +++++++++++++++++++ src/g_input.h | 2 ++ src/i_video.h | 2 ++ src/sdl/i_video.c | 17 +++++++++++++++++ 6 files changed, 46 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 3b6573e5c..62b8025bb 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -37,6 +37,7 @@ #include "d_net.h" #include "f_finale.h" #include "g_game.h" +#include "g_input.h" #include "hu_stuff.h" #include "i_sound.h" #include "i_system.h" @@ -1841,6 +1842,9 @@ void D_SRB2Main(void) CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); + if (!dedicated) + G_SetPlayerGamepadIndicatorToPlayerColor(); // no idea where else to throw it lol + // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) { diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a8e01a766..57b4a8824 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6079,6 +6079,8 @@ static void Color_OnChange(void) CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor); } + + G_SetPlayerGamepadIndicatorToPlayerColor(); } /** Sends a color change for the secondary splitscreen player, unless that diff --git a/src/g_input.c b/src/g_input.c index 536ea0c83..86094fbf8 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -14,11 +14,16 @@ #include "doomdef.h" #include "doomstat.h" #include "g_input.h" +#include "g_game.h" #include "keys.h" #include "hu_stuff.h" // need HUFONT start & end #include "d_net.h" #include "console.h" +#include "i_video.h" +#include "r_draw.h" +#include "v_video.h" + #define MAXMOUSESENSITIVITY 100 // sensitivity steps static CV_PossibleValue_t mousesens_cons_t[] = {{1, "MIN"}, {MAXMOUSESENSITIVITY, "MAX"}, {0, NULL}}; @@ -817,6 +822,20 @@ static const char *gamecontrolname[num_gamecontrols] = #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) +#include "k_kart.h" +// ehhhhhh ill maybe add splitscreen support eventually lol +void G_SetPlayerGamepadIndicatorToPlayerColor(void) +{ + UINT16 skincolor; + byteColor_t byte_color; + + skincolor = cv_playercolor.value; + + byte_color = V_GetColor(colortranslations[skincolor][8]).s; + + I_SetGamepadIndicatorColor(1, byte_color.red, byte_color.green, byte_color.blue); +} + // // Detach any keys associated to the given game control // - pass the pointer to the gamecontrol table for the player being edited diff --git a/src/g_input.h b/src/g_input.h index 635e1f64b..25b1dc119 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -130,6 +130,8 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // peace to my little coder fingers! // check a gamecontrol being active or not +void G_SetPlayerGamepadIndicatorToPlayerColor(void); + // remaps the input event to a game control. void G_MapEventsToControls(event_t *ev); diff --git a/src/i_video.h b/src/i_video.h index 708fde03c..553e3851a 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -139,6 +139,8 @@ UINT32 I_GetRefreshRate(void); boolean I_UseNativeKeyboard(void); +void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue); + #ifdef USE_FBO_OGL void RefreshOGLSDLSurface(void); void I_DownSample(void); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index da055265e..b94b81c19 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1529,6 +1529,23 @@ void I_StartupMouse(void) SDLdoUngrabMouse(); } +void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue) +{ +#if !(SDL_VERSION_ATLEAST(2,0,14)) + (void)device_id; +#else + I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher + + SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + if (controller == NULL) + { + return; + } + + SDL_GameControllerSetLED(controller, red, green, blue); +#endif +} + // // I_OsPolling // -- 2.54.0 From 754b028623424f8751b4bd74001d75daf65683c6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 01:11:54 +0200 Subject: [PATCH 285/525] give rgb custom color support, change rgb light color earlier in Color_OnChange so it always unconditionally changes the color also --- src/d_main.c | 3 --- src/d_netcmd.c | 4 ++-- src/g_input.c | 7 +++++-- src/g_input.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 62b8025bb..79f564e1f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1842,9 +1842,6 @@ void D_SRB2Main(void) CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); - if (!dedicated) - G_SetPlayerGamepadIndicatorToPlayerColor(); // no idea where else to throw it lol - // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) { diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 57b4a8824..2f8c4afaa 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6060,6 +6060,8 @@ static void Command_SkinSearch(void) */ static void Color_OnChange(void) { + G_SetPlayerGamepadIndicatorToPlayerColor(0); // i want this to always change so its here + if (!Playing()) return; // do whatever you want @@ -6079,8 +6081,6 @@ static void Color_OnChange(void) CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor); } - - G_SetPlayerGamepadIndicatorToPlayerColor(); } /** Sends a color change for the secondary splitscreen player, unless that diff --git a/src/g_input.c b/src/g_input.c index 86094fbf8..ad15f44ce 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -824,12 +824,15 @@ static const char *gamecontrolname[num_gamecontrols] = #include "k_kart.h" // ehhhhhh ill maybe add splitscreen support eventually lol -void G_SetPlayerGamepadIndicatorToPlayerColor(void) +void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color) { UINT16 skincolor; byteColor_t byte_color; - skincolor = cv_playercolor.value; + if (color) + skincolor = color; + else + skincolor = cv_playercolor.value; byte_color = V_GetColor(colortranslations[skincolor][8]).s; diff --git a/src/g_input.h b/src/g_input.h index 25b1dc119..13b0fa508 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -130,7 +130,7 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // peace to my little coder fingers! // check a gamecontrol being active or not -void G_SetPlayerGamepadIndicatorToPlayerColor(void); +void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color); // remaps the input event to a game control. void G_MapEventsToControls(event_t *ev); -- 2.54.0 From 694c1ad808b6861a5860dbeb7edf3db4eb5fcdc5 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 01:12:17 +0200 Subject: [PATCH 286/525] change color light when you cycle between colors in player setup --- src/m_menu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 80b1d635a..3807d1374 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11253,6 +11253,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor--; + G_SetPlayerGamepadIndicatorToPlayerColor(setupm_fakecolor); } break; @@ -11308,6 +11309,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor++; + G_SetPlayerGamepadIndicatorToPlayerColor(setupm_fakecolor); } break; @@ -11635,6 +11637,7 @@ static boolean M_QuitMultiPlayerMenu(void) // you know what? always putting these in the buffer won't hurt anything. COM_BufAddText (va("%s \"%s\"\n",setupm_cvskin->name,skins[setupm_fakeskin].name)); COM_BufAddText (va("%s %d\n",setupm_cvcolor->name,setupm_fakecolor)); + return true; } -- 2.54.0 From 9dc5e3d338a18644d9372c47d894fc677447bdba Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 01:39:33 +0200 Subject: [PATCH 287/525] ressting to defaultcolor should also set led color --- src/m_menu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/m_menu.c b/src/m_menu.c index 3807d1374..703bf3dc2 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11349,6 +11349,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor = col; + G_SetPlayerGamepadIndicatorToPlayerColor(setupm_fakecolor); } } break; -- 2.54.0 From fe8e00895a06003f5e618058cb076d2e7a3602f8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 02:59:42 +0200 Subject: [PATCH 288/525] simplify reduntand condition --- src/k_kart.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 628060743..293e5209b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -617,10 +617,8 @@ UINT8 K_GetKartColorByName(const char *name) UINT8 K_GetHudColor(void) { - if (cv_colorizedhud.value){ - if (cv_colorizedhudcolor.value) return cv_colorizedhudcolor.value; - } - if (stplyr && P_IsLocalPlayer(stplyr) && gamestate == GS_LEVEL) return stplyr->skincolor; + if (cv_colorizedhud.value && cv_colorizedhudcolor.value) return cv_colorizedhudcolor.value; + return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : cv_playercolor.value); } -- 2.54.0 From 7bd1808c882d0d15a3a852c695731d0ef1d8ab26 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 03:57:20 +0200 Subject: [PATCH 289/525] change gamepad rgb color when switching viewpoints --- src/d_netcmd.c | 2 ++ src/g_game.c | 5 +++++ src/g_input.c | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 2f8c4afaa..873824567 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6081,6 +6081,8 @@ static void Color_OnChange(void) CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor); } + + G_SetPlayerGamepadIndicatorToPlayerColor(0); // update again } /** Sends a color change for the secondary splitscreen player, unless that diff --git a/src/g_game.c b/src/g_game.c index ff459c59a..767c2e7bf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2150,6 +2150,8 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) if (viewnum == 1 && demo.playback) consoleplayer = displayplayers[0]; + + G_SetPlayerGamepadIndicatorToPlayerColor(0); } // @@ -8537,6 +8539,9 @@ boolean G_DemoTitleResponder(event_t *ev) void G_SetGamestate(gamestate_t newstate) { gamestate = newstate; + + G_SetPlayerGamepadIndicatorToPlayerColor(0); // dumb hack but works + #ifdef HAVE_DISCORDRPC DRPC_UpdatePresence(); #endif diff --git a/src/g_input.c b/src/g_input.c index ad15f44ce..c1ab6af57 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -823,6 +823,12 @@ static const char *gamecontrolname[num_gamecontrols] = #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) #include "k_kart.h" + +static UINT16 G_GetSkinColor(void) +{ + return ((gamestate == GS_LEVEL) ? players[displayplayers[0]].skincolor : cv_playercolor.value); +} + // ehhhhhh ill maybe add splitscreen support eventually lol void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color) { @@ -832,7 +838,7 @@ void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color) if (color) skincolor = color; else - skincolor = cv_playercolor.value; + skincolor = G_GetSkinColor(); byte_color = V_GetColor(colortranslations[skincolor][8]).s; -- 2.54.0 From c75e6ba63c114a4b2f768cce61534539384e7f48 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 20:40:13 +0200 Subject: [PATCH 290/525] add basic rumble support for gamepads --- src/d_netcmd.c | 2 ++ src/g_input.c | 12 ++++++++++++ src/g_input.h | 2 ++ src/i_video.h | 1 + src/p_tick.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/sdl/i_video.c | 19 +++++++++++++++++++ 6 files changed, 81 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 873824567..8d1584cd7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1073,6 +1073,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_controlperkey); CV_RegisterVar(&cv_turnsmooth); + CV_RegisterVar(&cv_rumble); + CV_RegisterVar(&cv_usemouse); CV_RegisterVar(&cv_usemouse2); CV_RegisterVar(&cv_invertmouse); diff --git a/src/g_input.c b/src/g_input.c index c1ab6af57..98495274a 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -38,6 +38,8 @@ consvar_t cv_mouseysens2 = {"mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_turnsmooth = {"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_rumble = {"gamepadrumble", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + INT32 mousex, mousey; INT32 mlooky; // like mousey but with a custom sensitivity for mlook @@ -845,6 +847,16 @@ void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color) I_SetGamepadIndicatorColor(1, byte_color.red, byte_color.green, byte_color.blue); } +void G_PlayerDeviceRumble(UINT16 low_strength, UINT16 high_strength) +{ + if (cv_rumble.value == 0) + { + return; + } + + I_GamepadRumble(1, low_strength, high_strength); +} + // // Detach any keys associated to the given game control // - pass the pointer to the gamecontrol table for the player being edited diff --git a/src/g_input.h b/src/g_input.h index 13b0fa508..3090f2117 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -106,6 +106,7 @@ typedef enum extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_mousesens2, cv_mouseysens2; extern consvar_t cv_controlperkey, cv_turnsmooth; +extern consvar_t cv_rumble; extern INT32 mousex, mousey; extern INT32 mlooky; //mousey with mlookSensitivity @@ -131,6 +132,7 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // check a gamecontrol being active or not void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color); +void G_PlayerDeviceRumble(UINT16 low_strength, UINT16 high_strength); // remaps the input event to a game control. void G_MapEventsToControls(event_t *ev); diff --git a/src/i_video.h b/src/i_video.h index 553e3851a..8cb332c5c 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -139,6 +139,7 @@ UINT32 I_GetRefreshRate(void); boolean I_UseNativeKeyboard(void); +void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength); void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue); #ifdef USE_FBO_OGL diff --git a/src/p_tick.c b/src/p_tick.c index 2bf7f1024..22def813f 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -315,6 +315,45 @@ static inline void P_RunThinkers(void) } } +static inline void P_DeviceRumbleTick(void) +{ + player_t *player; + UINT16 low = 0; + UINT16 high = 0; + + if (cv_rumble.value == 0) + { + return; + } + + if (paused) + return; + + player = &players[displayplayers[0]]; + + if (!P_IsLocalPlayer(player)) + return; + + if (player->mo != NULL && !player->exiting) + { + if (player->kartstuff[k_spinouttimer]) + { + low = high = 65536 / 4; + } + else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) + { + low = high = 65536 / 8; + } + else if ((player->kartstuff[k_offroad]) + && P_IsObjectOnGround(player->mo) && player->speed != 0) + { + low = high = 65536 / 64; + } + } + + G_PlayerDeviceRumble(low, high); +} + void P_RunChaseCameras(void) { UINT8 i; @@ -420,6 +459,12 @@ void P_Ticker(boolean run) } #endif } + + // Apply rumble to local players + if (!demo.playback) + { + P_DeviceRumbleTick(); + } ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index b94b81c19..c0f9d0bf1 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1529,6 +1529,25 @@ void I_StartupMouse(void) SDLdoUngrabMouse(); } +void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength) +{ +#if !(SDL_VERSION_ATLEAST(2,0,14)) + (void)device_id; + (void)left_strength; + (void)right_strength; +#else + I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher + + SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + if (controller == NULL) + { + return; + } + + SDL_GameControllerRumble(controller, low_strength, high_strength, 0); +#endif +} + void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue) { #if !(SDL_VERSION_ATLEAST(2,0,14)) -- 2.54.0 From 6efc8fdad374dea84b10f637a077013a5f063a97 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 21:41:18 +0200 Subject: [PATCH 291/525] add splitscreen support to gamepad led also add more proper device check --- src/d_netcmd.c | 10 ++++++-- src/g_game.c | 6 +++-- src/g_input.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++---- src/g_input.h | 2 +- src/m_menu.c | 16 ++++++++++--- 5 files changed, 83 insertions(+), 13 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8d1584cd7..9128f5e4d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6062,7 +6062,7 @@ static void Command_SkinSearch(void) */ static void Color_OnChange(void) { - G_SetPlayerGamepadIndicatorToPlayerColor(0); // i want this to always change so its here + G_SetPlayerGamepadIndicatorToPlayerColor(0, 0); // i want this to always change so its here if (!Playing()) return; // do whatever you want @@ -6084,7 +6084,7 @@ static void Color_OnChange(void) players[consoleplayer].skincolor); } - G_SetPlayerGamepadIndicatorToPlayerColor(0); // update again + G_SetPlayerGamepadIndicatorToPlayerColor(0, 0); // update again } /** Sends a color change for the secondary splitscreen player, unless that @@ -6107,6 +6107,8 @@ static void Color2_OnChange(void) CV_StealthSetValue(&cv_playercolor2, players[displayplayers[1]].skincolor); } + + G_SetPlayerGamepadIndicatorToPlayerColor(1, 0); } static void Color3_OnChange(void) @@ -6124,6 +6126,8 @@ static void Color3_OnChange(void) CV_StealthSetValue(&cv_playercolor3, players[displayplayers[2]].skincolor); } + + G_SetPlayerGamepadIndicatorToPlayerColor(2, 0); } static void Color4_OnChange(void) @@ -6141,6 +6145,8 @@ static void Color4_OnChange(void) CV_StealthSetValue(&cv_playercolor4, players[displayplayers[3]].skincolor); } + + G_SetPlayerGamepadIndicatorToPlayerColor(3, 0); } /** Displays the result of the chat being muted or unmuted. diff --git a/src/g_game.c b/src/g_game.c index 767c2e7bf..8c7431ff8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2151,7 +2151,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) if (viewnum == 1 && demo.playback) consoleplayer = displayplayers[0]; - G_SetPlayerGamepadIndicatorToPlayerColor(0); + G_SetPlayerGamepadIndicatorToPlayerColor(viewnum-1, 0); } // @@ -8538,9 +8538,11 @@ boolean G_DemoTitleResponder(event_t *ev) // void G_SetGamestate(gamestate_t newstate) { + SINT8 i; gamestate = newstate; - G_SetPlayerGamepadIndicatorToPlayerColor(0); // dumb hack but works + for (i = 0; i <= splitscreen; i++) + G_SetPlayerGamepadIndicatorToPlayerColor(i, 0); // dumb hack but works #ifdef HAVE_DISCORDRPC DRPC_UpdatePresence(); diff --git a/src/g_input.c b/src/g_input.c index 98495274a..46b44347c 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -826,25 +826,77 @@ static const char *gamecontrolname[num_gamecontrols] = #include "k_kart.h" -static UINT16 G_GetSkinColor(void) +static INT32 G_GetDeviceForPlayer(INT32 player) { - return ((gamestate == GS_LEVEL) ? players[displayplayers[0]].skincolor : cv_playercolor.value); + switch (player) + { + case 0: + return cv_usejoystick.value; + break; + case 1: + return cv_usejoystick2.value; + break; + case 2: + return cv_usejoystick3.value; + break; + case 3: + return cv_usejoystick4.value; + break; + default: + return 0; + break; + } +} + +static UINT16 G_GetSkinColor(INT32 player) +{ + if (gamestate == GS_LEVEL) + return players[displayplayers[player]].skincolor; + + switch (player) + { + case 0: + return cv_playercolor.value; + break; + case 1: + return cv_playercolor2.value; + break; + case 2: + return cv_playercolor3.value; + break; + case 3: + return cv_playercolor4.value; + break; + default: + return 0; + break; + } } // ehhhhhh ill maybe add splitscreen support eventually lol -void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color) +void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player, UINT16 color) { + INT32 device; UINT16 skincolor; byteColor_t byte_color; + I_Assert(player >= 0 && player < MAXSPLITSCREENPLAYERS); + + device = G_GetDeviceForPlayer(player); + + if (device <= 0) + { + return; + } + if (color) skincolor = color; else - skincolor = G_GetSkinColor(); + skincolor = G_GetSkinColor(player); byte_color = V_GetColor(colortranslations[skincolor][8]).s; - I_SetGamepadIndicatorColor(1, byte_color.red, byte_color.green, byte_color.blue); + I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue); } void G_PlayerDeviceRumble(UINT16 low_strength, UINT16 high_strength) diff --git a/src/g_input.h b/src/g_input.h index 3090f2117..978f377d6 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -131,7 +131,7 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // peace to my little coder fingers! // check a gamecontrol being active or not -void G_SetPlayerGamepadIndicatorToPlayerColor(UINT16 color); +void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player, UINT16 color); void G_PlayerDeviceRumble(UINT16 low_strength, UINT16 high_strength); // remaps the input event to a game control. diff --git a/src/m_menu.c b/src/m_menu.c index 703bf3dc2..08098fc88 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10412,6 +10412,8 @@ static UINT8 setupm_skinypos; static INT32 setupm_skinselect; static boolean setupm_skinlockedselect; +static UINT8 setupm_playernum; //brap + #define SELECTEDSTATSCOUNT skinstatscount[setupm_skinxpos][setupm_skinypos] #define LASTSELECTEDSTAT skinstats[setupm_skinxpos][setupm_skinypos][skinstatscount[setupm_skinxpos][setupm_skinypos]] @@ -11253,7 +11255,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor--; - G_SetPlayerGamepadIndicatorToPlayerColor(setupm_fakecolor); + G_SetPlayerGamepadIndicatorToPlayerColor(setupm_playernum, setupm_fakecolor); } break; @@ -11309,7 +11311,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor++; - G_SetPlayerGamepadIndicatorToPlayerColor(setupm_fakecolor); + G_SetPlayerGamepadIndicatorToPlayerColor(setupm_playernum, setupm_fakecolor); } break; @@ -11349,7 +11351,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor = col; - G_SetPlayerGamepadIndicatorToPlayerColor(setupm_fakecolor); + G_SetPlayerGamepadIndicatorToPlayerColor(setupm_playernum, setupm_fakecolor); } } break; @@ -11483,6 +11485,8 @@ static void M_SetupMultiPlayer(INT32 choice) setupm_skinypos = 0; setupm_skinlockedselect = false; + setupm_playernum = 0; + // For whatever reason this doesn't work right if you just use ->value setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string); if (setupm_fakeskin == -1) @@ -11522,6 +11526,8 @@ static void M_SetupMultiPlayer2(INT32 choice) setupm_skinypos = 0; setupm_skinlockedselect = false; + setupm_playernum = 1; + // For whatever reason this doesn't work right if you just use ->value setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string); if (setupm_fakeskin == -1) @@ -11561,6 +11567,8 @@ static void M_SetupMultiPlayer3(INT32 choice) setupm_skinypos = 0; setupm_skinlockedselect = false; + setupm_playernum = 2; + // For whatever reason this doesn't work right if you just use ->value setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string); if (setupm_fakeskin == -1) @@ -11600,6 +11608,8 @@ static void M_SetupMultiPlayer4(INT32 choice) setupm_skinypos = 0; setupm_skinlockedselect = false; + setupm_playernum = 3; + // For whatever reason this doesn't work right if you just use ->value setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string); if (setupm_fakeskin == -1) -- 2.54.0 From acb0144742bb1ffb0502f78343e766910b573f14 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 22:17:01 +0200 Subject: [PATCH 292/525] splitscreen support for rumble --- src/d_netcmd.c | 5 +++- src/g_input.c | 73 ++++++++++++++++++++++++++++++++++++++++++---- src/g_input.h | 5 ++-- src/i_system.h | 3 ++ src/i_video.h | 3 -- src/p_tick.c | 56 +++++++++++++++++++---------------- src/sdl/i_system.c | 36 +++++++++++++++++++++++ src/sdl/i_video.c | 36 ----------------------- 8 files changed, 144 insertions(+), 73 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9128f5e4d..03c3dc93e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1073,7 +1073,10 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_controlperkey); CV_RegisterVar(&cv_turnsmooth); - CV_RegisterVar(&cv_rumble); + CV_RegisterVar(&cv_rumble[0]); + CV_RegisterVar(&cv_rumble[1]); + CV_RegisterVar(&cv_rumble[2]); + CV_RegisterVar(&cv_rumble[3]); CV_RegisterVar(&cv_usemouse); CV_RegisterVar(&cv_usemouse2); diff --git a/src/g_input.c b/src/g_input.c index 46b44347c..4e5b8b1ba 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -16,10 +16,12 @@ #include "g_input.h" #include "g_game.h" #include "keys.h" +#include "k_kart.h" #include "hu_stuff.h" // need HUFONT start & end #include "d_net.h" #include "console.h" +#include "i_system.h" #include "i_video.h" #include "r_draw.h" #include "v_video.h" @@ -38,7 +40,45 @@ consvar_t cv_mouseysens2 = {"mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_turnsmooth = {"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_rumble = {"gamepadrumble", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static void G_ResetPlayerDeviceRumble(INT32 player); +static void rumble_off_handle(void); +static void rumble_off_handle2(void); +static void rumble_off_handle3(void); +static void rumble_off_handle4(void); + +consvar_t cv_rumble[MAXSPLITSCREENPLAYERS] = { + {"rumble", "Off", CV_SAVE, CV_OnOff, rumble_off_handle, 0, NULL, NULL, 0, 0, NULL}, + {"rumble2", "Off", CV_SAVE, CV_OnOff, rumble_off_handle2, 0, NULL, NULL, 0, 0, NULL}, + {"rumble3", "Off", CV_SAVE, CV_OnOff, rumble_off_handle3, 0, NULL, NULL, 0, 0, NULL}, + {"rumble4", "Off", CV_SAVE, CV_OnOff, rumble_off_handle4, 0, NULL, NULL, 0, 0, NULL} +}; + +static void rumble_off_handle(void) +{ + if (cv_rumble[0].value == 0) + G_ResetPlayerDeviceRumble(0); +} + + +static void rumble_off_handle2(void) +{ + if (cv_rumble[1].value == 0) + G_ResetPlayerDeviceRumble(1); +} + + +static void rumble_off_handle3(void) +{ + if (cv_rumble[2].value == 0) + G_ResetPlayerDeviceRumble(2); +} + + +static void rumble_off_handle4(void) +{ + if (cv_rumble[3].value == 0) + G_ResetPlayerDeviceRumble(3); +} INT32 mousex, mousey; INT32 mlooky; // like mousey but with a custom sensitivity for mlook @@ -824,8 +864,6 @@ static const char *gamecontrolname[num_gamecontrols] = #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) -#include "k_kart.h" - static INT32 G_GetDeviceForPlayer(INT32 player) { switch (player) @@ -899,14 +937,37 @@ void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player, UINT16 color) I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue); } -void G_PlayerDeviceRumble(UINT16 low_strength, UINT16 high_strength) +static void G_ResetPlayerDeviceRumble(INT32 player) { - if (cv_rumble.value == 0) + INT32 device_id; + + device_id = G_GetDeviceForPlayer(player); + + if (device_id < 1) { return; } - I_GamepadRumble(1, low_strength, high_strength); + I_GamepadRumble(device_id, 0, 0); +} + +void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength) +{ + INT32 device_id; + + if (cv_rumble[player].value == 0) + { + return; + } + + device_id = G_GetDeviceForPlayer(player); + + if (device_id < 1) + { + return; + } + + I_GamepadRumble(device_id, low_strength, high_strength); } // diff --git a/src/g_input.h b/src/g_input.h index 978f377d6..f3230b0f3 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -15,6 +15,7 @@ #define __G_INPUT__ #include "d_event.h" +#include "doomstat.h" #include "keys.h" #include "command.h" @@ -106,7 +107,7 @@ typedef enum extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_mousesens2, cv_mouseysens2; extern consvar_t cv_controlperkey, cv_turnsmooth; -extern consvar_t cv_rumble; +extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; extern INT32 mousex, mousey; extern INT32 mlooky; //mousey with mlookSensitivity @@ -132,7 +133,7 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // check a gamecontrol being active or not void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player, UINT16 color); -void G_PlayerDeviceRumble(UINT16 low_strength, UINT16 high_strength); +void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength); // remaps the input event to a game control. void G_MapEventsToControls(event_t *ev); diff --git a/src/i_system.h b/src/i_system.h index f1d098e4a..8239bade8 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -230,6 +230,9 @@ INT32 I_NumJoys(void); */ const char *I_GetJoyName(INT32 joyindex); +void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength); +void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue); + #ifndef NOMUMBLE #include "p_mobj.h" // mobj_t #include "s_sound.h" // listener_t diff --git a/src/i_video.h b/src/i_video.h index 8cb332c5c..708fde03c 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -139,9 +139,6 @@ UINT32 I_GetRefreshRate(void); boolean I_UseNativeKeyboard(void); -void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength); -void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue); - #ifdef USE_FBO_OGL void RefreshOGLSDLSurface(void); void I_DownSample(void); diff --git a/src/p_tick.c b/src/p_tick.c index 22def813f..0d98a0d59 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -317,11 +317,9 @@ static inline void P_RunThinkers(void) static inline void P_DeviceRumbleTick(void) { - player_t *player; - UINT16 low = 0; - UINT16 high = 0; + UINT8 i; - if (cv_rumble.value == 0) + if (cv_rumble[0].value && cv_rumble[1].value && cv_rumble[2].value && cv_rumble[3].value == 0) { return; } @@ -329,29 +327,37 @@ static inline void P_DeviceRumbleTick(void) if (paused) return; - player = &players[displayplayers[0]]; - - if (!P_IsLocalPlayer(player)) - return; - - if (player->mo != NULL && !player->exiting) + for (i = 0; i <= splitscreen; i++) { - if (player->kartstuff[k_spinouttimer]) - { - low = high = 65536 / 4; - } - else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) - { - low = high = 65536 / 8; - } - else if ((player->kartstuff[k_offroad]) - && P_IsObjectOnGround(player->mo) && player->speed != 0) - { - low = high = 65536 / 64; - } - } + player_t *player = &players[displayplayers[i]]; + UINT16 low = 0; + UINT16 high = 0; - G_PlayerDeviceRumble(low, high); + if (!P_IsLocalPlayer(player)) + continue; + + if (!playeringame[i]) + continue; + + if (player->mo != NULL && !player->exiting) + { + if (player->kartstuff[k_spinouttimer]) + { + low = high = 65536 / 4; + } + else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) + { + low = high = 65536 / 8; + } + else if ((player->kartstuff[k_offroad]) + && P_IsObjectOnGround(player->mo) && player->speed != 0) + { + low = high = 65536 / 64; + } + } + + G_PlayerDeviceRumble(i, low, high); + } } void P_RunChaseCameras(void) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 00bc3200f..454c1e295 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2666,6 +2666,42 @@ const char *I_GetJoyName(INT32 joyindex) return joyname; } +void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength) +{ +#if !(SDL_VERSION_ATLEAST(2,0,14)) + (void)device_id; + (void)left_strength; + (void)right_strength; +#else + I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher + + SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + if (controller == NULL) + { + return; + } + + SDL_GameControllerRumble(controller, low_strength, high_strength, 0); +#endif +} + +void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue) +{ +#if !(SDL_VERSION_ATLEAST(2,0,14)) + (void)device_id; +#else + I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher + + SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + if (controller == NULL) + { + return; + } + + SDL_GameControllerSetLED(controller, red, green, blue); +#endif +} + #ifndef NOMUMBLE #ifdef HAVE_MUMBLE // Best Mumble positional audio settings: diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c0f9d0bf1..da055265e 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1529,42 +1529,6 @@ void I_StartupMouse(void) SDLdoUngrabMouse(); } -void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength) -{ -#if !(SDL_VERSION_ATLEAST(2,0,14)) - (void)device_id; - (void)left_strength; - (void)right_strength; -#else - I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); - if (controller == NULL) - { - return; - } - - SDL_GameControllerRumble(controller, low_strength, high_strength, 0); -#endif -} - -void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue) -{ -#if !(SDL_VERSION_ATLEAST(2,0,14)) - (void)device_id; -#else - I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); - if (controller == NULL) - { - return; - } - - SDL_GameControllerSetLED(controller, red, green, blue); -#endif -} - // // I_OsPolling // -- 2.54.0 From 49fcf3e4865bb08be4a6f18a81f8347e1ea3af7f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 22:45:39 +0200 Subject: [PATCH 293/525] rename to G_SetPlayerGamepadIndicatorColor --- src/d_netcmd.c | 10 +++++----- src/g_game.c | 4 ++-- src/g_input.c | 6 +++--- src/g_input.h | 2 +- src/lua_baselib.c | 2 +- src/m_menu.c | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 03c3dc93e..3103b4fc8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6065,7 +6065,7 @@ static void Command_SkinSearch(void) */ static void Color_OnChange(void) { - G_SetPlayerGamepadIndicatorToPlayerColor(0, 0); // i want this to always change so its here + G_SetPlayerGamepadIndicatorColor(0, 0); // i want this to always change so its here if (!Playing()) return; // do whatever you want @@ -6087,7 +6087,7 @@ static void Color_OnChange(void) players[consoleplayer].skincolor); } - G_SetPlayerGamepadIndicatorToPlayerColor(0, 0); // update again + G_SetPlayerGamepadIndicatorColor(0, 0); // update again } /** Sends a color change for the secondary splitscreen player, unless that @@ -6111,7 +6111,7 @@ static void Color2_OnChange(void) players[displayplayers[1]].skincolor); } - G_SetPlayerGamepadIndicatorToPlayerColor(1, 0); + G_SetPlayerGamepadIndicatorColor(1, 0); } static void Color3_OnChange(void) @@ -6130,7 +6130,7 @@ static void Color3_OnChange(void) players[displayplayers[2]].skincolor); } - G_SetPlayerGamepadIndicatorToPlayerColor(2, 0); + G_SetPlayerGamepadIndicatorColor(2, 0); } static void Color4_OnChange(void) @@ -6149,7 +6149,7 @@ static void Color4_OnChange(void) players[displayplayers[3]].skincolor); } - G_SetPlayerGamepadIndicatorToPlayerColor(3, 0); + G_SetPlayerGamepadIndicatorColor(3, 0); } /** Displays the result of the chat being muted or unmuted. diff --git a/src/g_game.c b/src/g_game.c index 8c7431ff8..2101d9fb2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2151,7 +2151,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) if (viewnum == 1 && demo.playback) consoleplayer = displayplayers[0]; - G_SetPlayerGamepadIndicatorToPlayerColor(viewnum-1, 0); + G_SetPlayerGamepadIndicatorColor(viewnum-1, 0); } // @@ -8542,7 +8542,7 @@ void G_SetGamestate(gamestate_t newstate) gamestate = newstate; for (i = 0; i <= splitscreen; i++) - G_SetPlayerGamepadIndicatorToPlayerColor(i, 0); // dumb hack but works + G_SetPlayerGamepadIndicatorColor(i, 0); // dumb hack but works #ifdef HAVE_DISCORDRPC DRPC_UpdatePresence(); diff --git a/src/g_input.c b/src/g_input.c index 4e5b8b1ba..3177da488 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -16,7 +16,6 @@ #include "g_input.h" #include "g_game.h" #include "keys.h" -#include "k_kart.h" #include "hu_stuff.h" // need HUFONT start & end #include "d_net.h" #include "console.h" @@ -864,6 +863,8 @@ static const char *gamecontrolname[num_gamecontrols] = #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) +#include "k_kart.h" + static INT32 G_GetDeviceForPlayer(INT32 player) { switch (player) @@ -911,8 +912,7 @@ static UINT16 G_GetSkinColor(INT32 player) } } -// ehhhhhh ill maybe add splitscreen support eventually lol -void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player, UINT16 color) +void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color) { INT32 device; UINT16 skincolor; diff --git a/src/g_input.h b/src/g_input.h index f3230b0f3..dac5bd3f8 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -132,7 +132,7 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // peace to my little coder fingers! // check a gamecontrol being active or not -void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player, UINT16 color); +void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color); void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength); // remaps the input event to a game control. diff --git a/src/lua_baselib.c b/src/lua_baselib.c index be561e7ba..da0fd5724 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3266,4 +3266,4 @@ int LUA_BaseLib(lua_State *L) lua_pushvalue(L, LUA_GLOBALSINDEX); luaL_register(L, NULL, lib); return 0; -} \ No newline at end of file +} diff --git a/src/m_menu.c b/src/m_menu.c index 08098fc88..033cae5db 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11255,7 +11255,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor--; - G_SetPlayerGamepadIndicatorToPlayerColor(setupm_playernum, setupm_fakecolor); + G_SetPlayerGamepadIndicatorColor(setupm_playernum, setupm_fakecolor); } break; @@ -11311,7 +11311,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor++; - G_SetPlayerGamepadIndicatorToPlayerColor(setupm_playernum, setupm_fakecolor); + G_SetPlayerGamepadIndicatorColor(setupm_playernum, setupm_fakecolor); } break; @@ -11351,7 +11351,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor = col; - G_SetPlayerGamepadIndicatorToPlayerColor(setupm_playernum, setupm_fakecolor); + G_SetPlayerGamepadIndicatorColor(setupm_playernum, setupm_fakecolor); } } break; -- 2.54.0 From acad230daa5f95d0c7e06400c59694bc6dd1638b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 22:54:23 +0200 Subject: [PATCH 294/525] expose rumble and led to lua --- src/lua_baselib.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index da0fd5724..3ce53fad1 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -20,6 +20,7 @@ #include "m_random.h" #include "s_sound.h" #include "g_game.h" +#include "g_input.h" #include "hu_stuff.h" // HU_AddChatText #include "console.h" #include "k_kart.h" // SRB2Kart @@ -3000,6 +3001,56 @@ static int lib_kSetHyuCountdown(lua_State *L) return 0; } +// G_INPUT +//////////// + +static int lib_gSetPlayerGamepadIndicatorColor(lua_State *L) +{ + INT32 player = -1; + player_t *plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player + UINT16 color = (UINT16)luaL_checkinteger(L, 2); // skincolor + + for (int i = 0; i < MAXSPLITSCREENPLAYERS; ++i) + { + if (plr - players == displayplayers[i]) + { + player = i; + break; + } + } + + // Not a local player + if (player == -1) return 0; + + G_SetPlayerGamepadIndicatorColor(player, color); + + return 0; +} + +static int lib_gPlayerDeviceRumble(lua_State *L) +{ + INT32 player = -1; + player_t *plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player + UINT16 low_strength = (INT32)luaL_checkinteger(L, 2); + UINT16 high_strength = (INT32)luaL_checkinteger(L, 3); + + for (int i = 0; i < MAXSPLITSCREENPLAYERS; ++i) + { + if (plr - players == displayplayers[i]) + { + player = i; + break; + } + } + + // Not a local player + if (player == -1) return 0; + + G_PlayerDeviceRumble(player, low_strength, high_strength); + + return 0; +} + static luaL_Reg lib[] = { {"print", lib_print}, {"chatprint", lib_chatprint}, @@ -3247,6 +3298,10 @@ static luaL_Reg lib[] = { {"K_SetIndirectItemCooldown",lib_kSetIndirectItemCountdown}, {"K_SetHyudoroCooldown",lib_kSetHyuCountdown}, + //g_input + {"G_SetPlayerGamepadIndicatorColor",lib_gSetPlayerGamepadIndicatorColor}, + {"G_PlayerDeviceRumble",lib_gPlayerDeviceRumble}, + {NULL, NULL} }; -- 2.54.0 From 2afa18bbdd8808bf268c8776bb2101e194a28c46 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 23:27:36 +0200 Subject: [PATCH 295/525] add duration field to G_PlayerDeviceRumble duration is in ms --- src/g_input.c | 6 +++--- src/g_input.h | 2 +- src/i_system.h | 2 +- src/lua_baselib.c | 7 ++++--- src/p_tick.c | 2 +- src/sdl/i_system.c | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 3177da488..105e84532 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -948,10 +948,10 @@ static void G_ResetPlayerDeviceRumble(INT32 player) return; } - I_GamepadRumble(device_id, 0, 0); + I_GamepadRumble(device_id, 0, 0, 0); } -void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength) +void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { INT32 device_id; @@ -967,7 +967,7 @@ void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strengt return; } - I_GamepadRumble(device_id, low_strength, high_strength); + I_GamepadRumble(device_id, low_strength, high_strength, duration); } // diff --git a/src/g_input.h b/src/g_input.h index dac5bd3f8..92444cccc 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -133,7 +133,7 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // check a gamecontrol being active or not void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color); -void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength); +void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength, UINT32 duration); // remaps the input event to a game control. void G_MapEventsToControls(event_t *ev); diff --git a/src/i_system.h b/src/i_system.h index 8239bade8..f49bca4a1 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -230,7 +230,7 @@ INT32 I_NumJoys(void); */ const char *I_GetJoyName(INT32 joyindex); -void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength); +void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, UINT32 duration); void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue); #ifndef NOMUMBLE diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 3ce53fad1..381e20e79 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3031,8 +3031,9 @@ static int lib_gPlayerDeviceRumble(lua_State *L) { INT32 player = -1; player_t *plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player - UINT16 low_strength = (INT32)luaL_checkinteger(L, 2); - UINT16 high_strength = (INT32)luaL_checkinteger(L, 3); + UINT16 low_strength = (INT32)luaL_checkinteger(L, 2); // low frequency rumble motor strenght + UINT16 high_strength = (INT32)luaL_checkinteger(L, 3); // high frequency rumble motor strenght + UINT32 duration = (INT32)luaL_checkinteger(L, 4); // duration of rumble in ms for (int i = 0; i < MAXSPLITSCREENPLAYERS; ++i) { @@ -3046,7 +3047,7 @@ static int lib_gPlayerDeviceRumble(lua_State *L) // Not a local player if (player == -1) return 0; - G_PlayerDeviceRumble(player, low_strength, high_strength); + G_PlayerDeviceRumble(player, low_strength, high_strength, duration); return 0; } diff --git a/src/p_tick.c b/src/p_tick.c index 0d98a0d59..0c99660d8 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -356,7 +356,7 @@ static inline void P_DeviceRumbleTick(void) } } - G_PlayerDeviceRumble(i, low, high); + G_PlayerDeviceRumble(i, low, high, 0); } } diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 454c1e295..eabe017c4 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2666,7 +2666,7 @@ const char *I_GetJoyName(INT32 joyindex) return joyname; } -void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength) +void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { #if !(SDL_VERSION_ATLEAST(2,0,14)) (void)device_id; @@ -2681,7 +2681,7 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength) return; } - SDL_GameControllerRumble(controller, low_strength, high_strength, 0); + SDL_GameControllerRumble(controller, low_strength, high_strength, duration); #endif } -- 2.54.0 From b0880607d4f748ca00731e9c71bfb07b06c29e0f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jul 2024 23:35:32 +0200 Subject: [PATCH 296/525] fix cassting, make one tic duration default, but can still pass ms to it --- src/lua_baselib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 381e20e79..097fa9f33 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3031,9 +3031,9 @@ static int lib_gPlayerDeviceRumble(lua_State *L) { INT32 player = -1; player_t *plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player - UINT16 low_strength = (INT32)luaL_checkinteger(L, 2); // low frequency rumble motor strenght - UINT16 high_strength = (INT32)luaL_checkinteger(L, 3); // high frequency rumble motor strenght - UINT32 duration = (INT32)luaL_checkinteger(L, 4); // duration of rumble in ms + UINT16 low_strength = (UINT16)luaL_checkinteger(L, 2); // low frequency rumble motor strenght + UINT16 high_strength = (UINT16)luaL_checkinteger(L, 3); // high frequency rumble motor strenght + UINT32 duration = (UINT32)luaL_optinteger(L, 4, 28); // duration of rumble in ms for (int i = 0; i < MAXSPLITSCREENPLAYERS; ++i) { -- 2.54.0 From 11329d5794a95d066a85643f3d36a5e9e517cb0a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jul 2024 00:16:19 +0200 Subject: [PATCH 297/525] throw rumble ticker into right place --- src/p_tick.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 0c99660d8..e4b15feca 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -465,12 +465,6 @@ void P_Ticker(boolean run) } #endif } - - // Apply rumble to local players - if (!demo.playback) - { - P_DeviceRumbleTick(); - } ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; @@ -505,6 +499,12 @@ void P_Ticker(boolean run) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); + // Apply rumble to local players + if (!demo.playback) + { + P_DeviceRumbleTick(); + } + PS_START_TIMING(ps_lua_thinkframe_time); LUAh_ThinkFrame(); PS_STOP_TIMING(ps_lua_thinkframe_time); -- 2.54.0 From 4acbca4c8f6362448dae59dce90e27cfade16736 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jul 2024 00:20:13 +0200 Subject: [PATCH 298/525] do not constantly reset rumble so it can work from lua --- src/p_tick.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index e4b15feca..83dd8e993 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -356,7 +356,8 @@ static inline void P_DeviceRumbleTick(void) } } - G_PlayerDeviceRumble(i, low, high, 0); + if (low && high != 0) + G_PlayerDeviceRumble(i, low, high, 57); // hack alert! i just dont want this think constantly resetting the rumble lol } } -- 2.54.0 From 41dc34efe804d45cfab6efbac789d464bd4f9232 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jul 2024 00:20:26 +0200 Subject: [PATCH 299/525] set default duration to 84 --- src/lua_baselib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 097fa9f33..f5763dc09 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3033,7 +3033,7 @@ static int lib_gPlayerDeviceRumble(lua_State *L) player_t *plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player UINT16 low_strength = (UINT16)luaL_checkinteger(L, 2); // low frequency rumble motor strenght UINT16 high_strength = (UINT16)luaL_checkinteger(L, 3); // high frequency rumble motor strenght - UINT32 duration = (UINT32)luaL_optinteger(L, 4, 28); // duration of rumble in ms + UINT32 duration = (UINT32)luaL_optinteger(L, 4, 84); // duration of rumble in ms for (int i = 0; i < MAXSPLITSCREENPLAYERS; ++i) { -- 2.54.0 From 47d3cf3e62cba57bd8d022562e8b232c2e5d15ef Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jul 2024 00:59:06 +0200 Subject: [PATCH 300/525] change rumble ticker loop a bit --- src/p_tick.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 83dd8e993..afcfdbb78 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -336,28 +336,33 @@ static inline void P_DeviceRumbleTick(void) if (!P_IsLocalPlayer(player)) continue; - if (!playeringame[i]) + if (!playeringame[i] || player->spectator) continue; - if (player->mo != NULL && !player->exiting) + if (player->exiting) + continue; + + if (player->mo == NULL) + continue; + + if (player->kartstuff[k_spinouttimer]) { - if (player->kartstuff[k_spinouttimer]) - { - low = high = 65536 / 4; - } - else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) - { - low = high = 65536 / 8; - } - else if ((player->kartstuff[k_offroad]) - && P_IsObjectOnGround(player->mo) && player->speed != 0) - { - low = high = 65536 / 64; - } + low = high = 65536 / 4; + } + else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) + { + low = high = 65536 / 8; + } + else if ((player->kartstuff[k_offroad]) + && P_IsObjectOnGround(player->mo) && player->speed != 0) + { + low = high = 65536 / 64; } - if (low && high != 0) - G_PlayerDeviceRumble(i, low, high, 57); // hack alert! i just dont want this think constantly resetting the rumble lol + if (low == 0 && high == 0) + continue; + + G_PlayerDeviceRumble(i, low, high, 57); // hack alert! i just dont want this think constantly resetting the rumble lol } } -- 2.54.0 From c5eb81c26ad19fc3d09cfa82b7bb56205a3e1f72 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jul 2024 01:02:05 +0200 Subject: [PATCH 301/525] remove redundant check --- src/p_tick.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index afcfdbb78..8a0a95969 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -324,9 +324,6 @@ static inline void P_DeviceRumbleTick(void) return; } - if (paused) - return; - for (i = 0; i <= splitscreen; i++) { player_t *player = &players[displayplayers[i]]; -- 2.54.0 From 4301e0f750922e8b8e2e08a7f1978ba1294726cf Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jul 2024 01:04:24 +0200 Subject: [PATCH 302/525] make this more explicit --- src/p_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8a0a95969..15cd2f1fc 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -319,7 +319,7 @@ static inline void P_DeviceRumbleTick(void) { UINT8 i; - if (cv_rumble[0].value && cv_rumble[1].value && cv_rumble[2].value && cv_rumble[3].value == 0) + if (cv_rumble[0].value == 0 && cv_rumble[1].value == 0 && cv_rumble[2].value == 0 && cv_rumble[3].value == 0) { return; } -- 2.54.0 From 0eda508cf6e2e8c2abed557167ce3c2329fd1306 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jul 2024 01:43:56 +0200 Subject: [PATCH 303/525] revert some lightlevel stuff in hw_main --- src/hardware/hw_main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 676c018d1..0800bcb8a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -500,9 +500,6 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GL_DEFAULTMIX; fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG; - // Clamp the light level, since it can sometimes go out of the 0-255 range from animations - light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); - // Crappy backup coloring if you can't do shaders if (!HWR_UseShader()) { @@ -540,6 +537,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } + // Clamp the light level, since it can sometimes go out of the 0-255 range from animations + light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); + // in palette rendering mode, this is not needed since it properly takes the changes to the palette itself if (!HWR_ShouldUsePaletteRendering()) { @@ -3173,7 +3173,7 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gr_frontsector->lightlist[light].lightlevel, - rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3217,7 +3217,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, - rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3872,7 +3872,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) continue; if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i-1].lightlevel; + lightlevel = min(*list[i-1].lightlevel, 255); colormap = list[i-1].extra_colormap; break; } @@ -3886,7 +3886,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel; + lightlevel = min(*list[i-1].lightlevel, 255); colormap = list[i].extra_colormap; } @@ -4104,7 +4104,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) extracolormap_t *colormap = sector->extra_colormap; if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel; + lightlevel = min(sector->lightlevel, 255); HWR_Lighting(&Surf, lightlevel, colormap); @@ -4203,7 +4203,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *sector->lightlist[light].lightlevel; + lightlevel = min(*sector->lightlist[light].lightlevel, 255); if (sector->lightlist[light].extra_colormap) colormap = sector->lightlist[light].extra_colormap; @@ -4211,7 +4211,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) else { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel; + lightlevel = min(sector->lightlevel, 255); if (sector->extra_colormap) colormap = sector->extra_colormap; @@ -4405,7 +4405,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean planeinfo->lumpnum = lumpnum; planeinfo->xsub = xsub; - planeinfo->alpha = CLAMP(alpha, 0, 255); + planeinfo->alpha = alpha; planeinfo->FOFSector = FOFSector; planeinfo->blend = blend; planeinfo->fogplane = fogplane; @@ -4425,7 +4425,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, polyplaneinfo->lumpnum = lumpnum; polyplaneinfo->polysector = polysector; - polyplaneinfo->alpha = CLAMP(alpha, 0, 255); + polyplaneinfo->alpha = alpha; polyplaneinfo->FOFSector = FOFSector; polyplaneinfo->blend = blend; polyplaneinfo->planecolormap = planecolormap; -- 2.54.0 From 77a2976d05f02dfcc5124c0b27d815deab9f8b1f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jul 2024 23:54:49 +0200 Subject: [PATCH 304/525] smol interp fixes --- src/d_clisrv.c | 16 +++++++++++++++- src/g_game.c | 42 ++++++++++++++++++++++++------------------ src/p_spec.c | 9 +++++++++ src/p_tick.c | 1 - src/p_user.c | 1 - src/y_inter.c | 10 +++++++++- 6 files changed, 57 insertions(+), 22 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 10d46689a..2bc316c64 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -49,6 +49,7 @@ #include "s_sound.h" // sfx_syfail #include "m_perfstats.h" #include "d_main.h" +#include "r_fps.h" #ifdef CLIENT_LOADINGSCREEN // cl loading screen @@ -6109,6 +6110,8 @@ boolean TryRunTics(tic_t realtics) if (ticking) { + boolean tickInterp = true; + // run the count * tics while (neededtic > gametic) { @@ -6119,7 +6122,18 @@ boolean TryRunTics(tic_t realtics) if (update_stats) PS_START_TIMING(ps_tictime); - G_Ticker((gametic % NEWTICRATERATIO) == 0); + boolean run = (gametic % NEWTICRATERATIO) == 0; + + if (run && tickInterp) + { + // Update old view state BEFORE ticking so resetting + // the old interpolation state from game logic works. + R_UpdateViewInterpolation(); + tickInterp = false; // do not update again in sped-up tics + } + + G_Ticker(run); + ExtraDataTicker(); gametic++; consistancy[gametic%TICQUEUE] = Consistancy(); diff --git a/src/g_game.c b/src/g_game.c index 2101d9fb2..20aa54135 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -525,6 +525,8 @@ consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static void G_FixCamera(UINT8 view); + #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" #endif @@ -2083,7 +2085,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) UINT8 viewd; INT32 *displayplayerp; - camera_t *camerap; INT32 olddisplayplayer; INT32 playersviewable; @@ -2122,29 +2123,14 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = playernum; if ((*displayplayerp) != olddisplayplayer) { - camerap = &camera[viewnum-1]; - P_ResetCamera(&players[(*displayplayerp)], camerap); - - // Make sure the viewport doesn't interpolate at all into - // its new position -- just snap instantly into place. - R_ResetViewInterpolation(viewnum); + G_FixCamera(viewnum); } if (viewnum > splits) { for (viewd = splits+1; viewd < viewnum; ++viewd) { - displayplayerp = (&displayplayers[viewd-1]); - camerap = &camera[viewd]; - - (*displayplayerp) = G_FindView(0, viewd, onlyactive, false); - - P_ResetCamera(&players[(*displayplayerp)], camerap); - - - // Make sure the viewport doesn't interpolate at all into - // its new position -- just snap instantly into place. - R_ResetViewInterpolation(viewd); + G_FixCamera(viewd); } } @@ -2204,6 +2190,26 @@ void G_ResetViews(void) } } +// +// G_FixCamera +// Reset camera position, angle and interpolation on a view +// after changing state. +// +static void G_FixCamera(UINT8 view) +{ + player_t *player = &players[displayplayers[view - 1]]; + + // The order of displayplayers can change, which would + // invalidate localangle. + localangle[view - 1] = player->cmd.angleturn; + + P_ResetCamera(player, &camera[view - 1]); + + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(view); +} + // // G_Ticker // Make ticcmd_ts for the players. diff --git a/src/p_spec.c b/src/p_spec.c index 370afc056..87036a892 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2483,6 +2483,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 422: // Cut away to another view { mobj_t *altview; + INT32 i; if (!mo || !mo->player) // only players have views return; @@ -2497,6 +2498,14 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetTarget(&mo->player->awayviewmobj, altview); mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; + for (i = 0; i <= splitscreen; i++) + { + if (displayplayers[i] == (mo->player - players)) + { + R_ResetViewInterpolation(i + 1); + } + } + if (line->flags & ML_NOCLIMB) // lets you specify a vertical angle { INT32 aim; diff --git a/src/p_tick.c b/src/p_tick.c index 15cd2f1fc..0dc34b487 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -642,7 +642,6 @@ void P_Ticker(boolean run) if (run) { R_UpdateLevelInterpolators(); - R_UpdateViewInterpolation(); // Hack: ensure newview is assigned every tic. // Ensures view interpolation is T-1 to T in poor network conditions diff --git a/src/p_user.c b/src/p_user.c index 118c1d06d..d61044ba7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3965,7 +3965,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { P_MoveChaseCamera(player, thiscam, false); R_ResetViewInterpolation(num + 1); - R_ResetViewInterpolation(num + 1); } return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); diff --git a/src/y_inter.c b/src/y_inter.c index 5d292f36c..8527ff799 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -728,8 +728,16 @@ void Y_Ticker(void) return; } - if (intertic < TICRATE || intertic & 1 || endtic != -1) + if (intertic < TICRATE || endtic != -1) + { return; + } + + if (data.match.rankingsmode && intertic & 1) + { + memset(data.match.jitter, 0, sizeof (data.match.jitter)); + return; + } if (intertype == int_race || intertype == int_match) { -- 2.54.0 From 3f4afb604afab6aaad74a476d3767b471488446b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 31 Jul 2024 00:28:29 +0200 Subject: [PATCH 305/525] check if displayplayer skincolor is availible before returning it --- src/g_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_input.c b/src/g_input.c index 105e84532..f7057d4e4 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -889,7 +889,7 @@ static INT32 G_GetDeviceForPlayer(INT32 player) static UINT16 G_GetSkinColor(INT32 player) { - if (gamestate == GS_LEVEL) + if (players[displayplayers[player]].skincolor && gamestate == GS_LEVEL) return players[displayplayers[player]].skincolor; switch (player) -- 2.54.0 From 3a56bf2bb59a5501cfca18dfaf2b4a305d67c9fd Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 17:43:47 +0200 Subject: [PATCH 306/525] fix up ogl sprite drawers, fix floor clip fix remove ty and reduntand hires stuff --- src/hardware/hw_glob.h | 2 +- src/hardware/hw_main.c | 49 +++++++++++++----------------------------- 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 542a99b33..4a8a5dd9c 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -28,7 +28,7 @@ typedef struct gr_vissprite_s float x1, x2; float z1, z2; float gz, gzt; - float tz, ty; + float tz; float scale; float spritexscale, spriteyscale; float spritexoffset, spriteyoffset; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0800bcb8a..3b65f1e96 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3711,12 +3711,10 @@ static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts static void HWR_SplitSprite(gr_vissprite_t *spr) { - float this_scale = 1.0f; FOutVector wallVerts[4]; FOutVector baseWallVerts[4]; // This is what the verts should end up as GLPatch_t *gpatch; FSurfaceInfo Surf; - const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); extracolormap_t *colormap; FUINT lightlevel; FBITFIELD blend = 0; @@ -3736,11 +3734,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) fixed_t v1x, v1y, v2x, v2y; INT32 shader = SHADER_NONE; - this_scale = FIXED_TO_FLOAT(spr->mobj->scale); - - if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); - gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); // cache the patch in the graphics card memory @@ -3801,7 +3794,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // push it toward the camera to mitigate floor-clipping sprites { - float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz)); + float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz)); float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; for (i = 0; i < 4; i++) { @@ -3990,7 +3983,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // -----------------+ static void HWR_DrawSprite(gr_vissprite_t *spr) { - float this_scale = 1.0f; FOutVector wallVerts[4]; GLPatch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; @@ -4009,12 +4001,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) return; } - const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); - if (spr->mobj) - this_scale = FIXED_TO_FLOAT(spr->mobj->scale); - if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); - // cache sprite graphics //12/12/99: Hurdler: // OK, I don't change anything for MD2 support because I want to be @@ -4083,7 +4069,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) // push it toward the camera to mitigate floor-clipping sprites { - float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz)); + float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz)); float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist; size_t i; for (i = 0; i < 4; i++) @@ -4169,8 +4155,8 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) // 0--1 wallVerts[0].x = wallVerts[3].x = spr->x1; wallVerts[2].x = wallVerts[1].x = spr->x2; - wallVerts[2].y = wallVerts[3].y = spr->ty; - wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height; + wallVerts[2].y = wallVerts[3].y = spr->gzt; + wallVerts[0].y = wallVerts[1].y = spr->gz; // make a wall polygon (with 2 triangles), using the floor/ceiling heights, // and the 2d map coords of start/end vertices @@ -4767,7 +4753,7 @@ void HWR_ProjectSprite(mobj_t *thing) float x1, x2; float z1, z2; float rightsin, rightcos; - float this_scale, this_xscale, this_yscale; + float this_scale; float spritexscale, spriteyscale; float gz, gzt; spritedef_t *sprdef; @@ -5001,20 +4987,20 @@ void HWR_ProjectSprite(mobj_t *thing) rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); } - this_xscale = spritexscale * this_scale; - this_yscale = spriteyscale * this_scale; + spritexscale *= this_scale; + spriteyscale *= this_scale; flip = !flip != !hflip; if (flip) { - x1 = (FIXED_TO_FLOAT(spr_width - spr_offset) * this_xscale); - x2 = (FIXED_TO_FLOAT(spr_offset) * this_xscale); + x1 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); + x2 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); } else { - x1 = (FIXED_TO_FLOAT(spr_offset) * this_xscale); - x2 = (FIXED_TO_FLOAT(spr_width - spr_offset) * this_xscale); + x1 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); + x2 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); } z1 = tr_y + x1 * rightsin; @@ -5022,16 +5008,15 @@ void HWR_ProjectSprite(mobj_t *thing) x1 = tr_x + x1 * rightcos; x2 = tr_x - x2 * rightcos; - if (thing->eflags & MFE_VERTICALFLIP) { - gz = FIXED_TO_FLOAT(interp.z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale); - gzt = gz + (FIXED_TO_FLOAT(spr_height) * this_yscale); + gz = FIXED_TO_FLOAT(interp.z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); + gzt = gz + (FIXED_TO_FLOAT(spr_height) * spriteyscale); } else { - gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spr_topoffset) * this_yscale); - gz = gzt - (FIXED_TO_FLOAT(spr_height) * this_yscale); + gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); + gz = gzt - (FIXED_TO_FLOAT(spr_height) * spriteyscale); } if (thing->subsector->sector->cullheight) @@ -5114,8 +5099,6 @@ void HWR_ProjectSprite(mobj_t *thing) } // set top/bottom coords - vis->ty = gzt; - vis->gzt = gzt; vis->gz = gz; @@ -5244,8 +5227,6 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif // set top/bottom coords - vis->ty = FIXED_TO_FLOAT(interp.z + spritecachedinfo[lumpoff].topoffset); - vis->gzt = FIXED_TO_FLOAT(interp.z + spritecachedinfo[lumpoff].topoffset); vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height); -- 2.54.0 From 5e2b50c49e263ff2e73ee573c1eab3da86ffa660 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 31 Jul 2024 06:05:49 +0200 Subject: [PATCH 307/525] add very light rumble to brakedrift --- src/p_tick.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_tick.c b/src/p_tick.c index 0dc34b487..5acb8b5fb 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -355,6 +355,11 @@ static inline void P_DeviceRumbleTick(void) { low = high = 65536 / 64; } + else if (player->kartstuff[k_brakedrift]) + { + low = 0; + high = 65536 / 256; + } if (low == 0 && high == 0) continue; -- 2.54.0 From 5c3a2bf5be34c8e0880fc0b5f6f39e7f25cbd86b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 07:31:12 +0200 Subject: [PATCH 308/525] make inline macros for pointtodist --- src/r_main.c | 11 ----------- src/r_main.h | 6 ++++-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 764d34403..fb3ca1c1c 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -440,11 +440,6 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) 0; } -fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1) -{ - return FixedHypot(px1 - px2, py1 - py2); -} - angle_t R_PlayerSliptideAngle(player_t *player) { mobj_t *mo; @@ -489,12 +484,6 @@ angle_t R_PlayerSliptideAngle(player_t *player) return FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mo->player->sliproll*(mo->player->sliptidemem)); } -// Little extra utility. Works in the same way as R_PointToAngle2 -fixed_t R_PointToDist(fixed_t x, fixed_t y) -{ - return R_PointToDist2(viewx, viewy, x, y); -} - INT32 R_GetHudUncap(void) { return cv_uncappedhud.value ? rendertimefrac & FRACMASK : 0; diff --git a/src/r_main.h b/src/r_main.h index 6c59d9961..058a30c80 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -73,14 +73,16 @@ INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line); angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); -fixed_t R_PointToDist(fixed_t x, fixed_t y); -fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); angle_t R_PlayerSliptideAngle(player_t *player); fixed_t R_ScaleFromGlobalAngle(angle_t visangle); subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); +#define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y) +#define R_PointToDist2(px2, py2, px1, py1) FixedHypot(px1 - px2, py1 - py2) + + boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph); void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh); -- 2.54.0 From 8d9a648dce56ea3a7047c8219a4883436ee636dc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 18:02:21 +0200 Subject: [PATCH 309/525] misplaced this --- src/p_spec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 87036a892..79103fb03 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4692,13 +4692,13 @@ void P_UpdateSpecials(void) // LEVEL TIMER P_CheckTimeLimit(); + // POINT LIMIT + P_CheckPointLimit(); + // Dynamic slopeness if (!midgamejoin) // run here when not joined midgame to prevent any potential issues that may arise P_RunDynamicSlopes(); - // POINT LIMIT - P_CheckPointLimit(); - // ANIMATE TEXTURES for (anim = anims; anim < lastanim; anim++) { -- 2.54.0 From d60d101e755a752a25de85ac1a34d8afbf56c399 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 18:02:36 +0200 Subject: [PATCH 310/525] dont set localangle or smth --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 20aa54135..89d299c28 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2201,7 +2201,7 @@ static void G_FixCamera(UINT8 view) // The order of displayplayers can change, which would // invalidate localangle. - localangle[view - 1] = player->cmd.angleturn; + //localangle[view - 1] = player->cmd.angleturn; P_ResetCamera(player, &camera[view - 1]); -- 2.54.0 From 65e274a65feba507d955f754387b7d7a228ab797 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 3 Aug 2024 21:27:25 +0300 Subject: [PATCH 311/525] Smol safeguard for R_PointToDist2 --- src/r_main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.h b/src/r_main.h index 058a30c80..a271a3b1d 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -80,7 +80,7 @@ subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); #define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y) -#define R_PointToDist2(px2, py2, px1, py1) FixedHypot(px1 - px2, py1 - py2) +#define R_PointToDist2(px2, py2, px1, py1) FixedHypot((px1) - (px2), (py1) - (py2)) boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph); -- 2.54.0 From 7baa7117444c076071eb2a562869bc41330a67bf Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 20:48:31 +0200 Subject: [PATCH 312/525] this somehow was not reverted --- src/p_user.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index d61044ba7..fa998013a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3995,7 +3995,7 @@ boolean P_SpectatorJoinGame(player_t *player) // Pressing fire assigns you to a team that needs players if allowed. // Partial code reproduction from p_tick.c autobalance code. else if (G_GametypeHasTeams()) - { + { INT32 changeto = 0; INT32 z, numplayersred = 0, numplayersblue = 0; @@ -4048,11 +4048,11 @@ boolean P_SpectatorJoinGame(player_t *player) } // Joining in game from firing. else - { + { if (player->mo) { P_RemoveMobj(player->mo); - P_SetTarget(&player->mo, NULL); + player->mo = NULL; } player->spectator = false; player->pflags &= ~PF_WANTSTOJOIN; -- 2.54.0 From 352b958da165e11fe35a6965ee360e92feaf7bef Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 3 Aug 2024 22:05:17 +0300 Subject: [PATCH 313/525] Fix few remaining uses of `this_scale` and `ty` Not too sure if this is correct tho --- src/hardware/hw_main.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3b65f1e96..e92192f68 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3470,7 +3470,7 @@ static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t hei return floorz; } -static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float this_scale) +static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch) { FOutVector swallVerts[4]; FSurfaceInfo sSurf; @@ -3546,10 +3546,12 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t swallVerts[0].z = swallVerts[3].z = spr->z1; swallVerts[2].z = swallVerts[1].z = spr->z2; - if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) + // this_scale now doesn't exist (always 1.0 basically), so this condition is always false. Not + // too sure if this is correct, so will just comment out for now + /*if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) { // Always a pixel above the floor, perfectly flat. - swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->ty - gpatch->topoffset * this_scale - (floorheight+3); + swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->gzt - gpatch->topoffset * this_scale - (floorheight+3); // Now transform the TOP vertices along the floor in the direction of the camera swallVerts[3].x = spr->x1 + ((gpatch->height * this_scale) + offset) * gr_viewcos; @@ -3557,10 +3559,10 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t swallVerts[3].z = spr->z1 + ((gpatch->height * this_scale) + offset) * gr_viewsin; swallVerts[2].z = spr->z2 + ((gpatch->height * this_scale) + offset) * gr_viewsin; } - else + else*/ { // Always a pixel above the floor, perfectly flat. - swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->ty - gpatch->topoffset - (floorheight+3); + swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->gzt - gpatch->topoffset - (floorheight+3); // Now transform the TOP vertices along the floor in the direction of the camera swallVerts[3].x = spr->x1 + (gpatch->height + offset) * gr_viewcos; @@ -3750,7 +3752,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) //////////////////// // SHADOW SPRITE! // //////////////////// - HWR_DrawSpriteShadow(spr, gpatch, this_scale); + HWR_DrawSpriteShadow(spr, gpatch); } baseWallVerts[0].x = baseWallVerts[3].x = spr->x1; @@ -4060,7 +4062,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) //////////////////// // SHADOW SPRITE! // //////////////////// - HWR_DrawSpriteShadow(spr, gpatch, this_scale); + HWR_DrawSpriteShadow(spr, gpatch); } // Let dispoffset work first since this adjust each vertex -- 2.54.0 From 23596d25165629af03f2fd099843f3841978c833 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 21:25:31 +0200 Subject: [PATCH 314/525] add controller rumble to menu --- src/m_menu.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 033cae5db..baf13e6ec 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1217,11 +1217,13 @@ static menuitem_t OP_Joystick1Menu[] = {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis , 80}, {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis , 90}, {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis , 130}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis , 110}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis , 120}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis , 130}, {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone , 140}, {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone , 150}, + + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 170}, }; static menuitem_t OP_Joystick2Menu[] = @@ -1235,11 +1237,13 @@ static menuitem_t OP_Joystick2Menu[] = {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis2 , 80}, {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis2 , 90}, {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis2 , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis2 , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis2 , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis2 , 130}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis2 , 110}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis2 , 120}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis2 , 130}, {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone2 , 140}, {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone2 , 150}, + + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 170}, }; static menuitem_t OP_Joystick3Menu[] = @@ -1253,11 +1257,13 @@ static menuitem_t OP_Joystick3Menu[] = {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis3 , 80}, {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis3 , 90}, {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis3 , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis3 , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis3 , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis3 , 130}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis3 , 110}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis3 , 120}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis3 , 130}, {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone3 , 140}, {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone3 , 150}, + + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 170}, }; static menuitem_t OP_Joystick4Menu[] = @@ -1271,11 +1277,13 @@ static menuitem_t OP_Joystick4Menu[] = {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis4 , 80}, {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis4 , 90}, {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis4 , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis4 , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis4 , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis4 , 130}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis4 , 110}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis4 , 120}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis4 , 130}, {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone4 , 140}, {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone4 , 150}, + + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 170}, }; static menuitem_t OP_JoystickSetMenu[] = -- 2.54.0 From a77d8b4762050343a9c0dc226b3ae849dedd3ff6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 21:44:28 +0200 Subject: [PATCH 315/525] fix spriteshadows --- src/hardware/hw_main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e92192f68..2a0ff0c66 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3472,6 +3472,7 @@ static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t hei static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch) { + float this_scale = 1.0f; FOutVector swallVerts[4]; FSurfaceInfo sSurf; FBITFIELD blendmode = 0; @@ -3481,6 +3482,13 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch) float offset = 0; INT32 shader = SHADER_NONE; + + // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again + const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); + if (spr->mobj) + this_scale = FIXED_TO_FLOAT(spr->mobj->scale); + if (hires) + this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); R_GetShadowZ(spr->mobj, &floorslope); @@ -3546,9 +3554,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch) swallVerts[0].z = swallVerts[3].z = spr->z1; swallVerts[2].z = swallVerts[1].z = spr->z2; - // this_scale now doesn't exist (always 1.0 basically), so this condition is always false. Not - // too sure if this is correct, so will just comment out for now - /*if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) + if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) { // Always a pixel above the floor, perfectly flat. swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->gzt - gpatch->topoffset * this_scale - (floorheight+3); @@ -3559,7 +3565,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch) swallVerts[3].z = spr->z1 + ((gpatch->height * this_scale) + offset) * gr_viewsin; swallVerts[2].z = spr->z2 + ((gpatch->height * this_scale) + offset) * gr_viewsin; } - else*/ + else { // Always a pixel above the floor, perfectly flat. swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->gzt - gpatch->topoffset - (floorheight+3); -- 2.54.0 From 5d68fd690b3dd6c0c1b59b95b25b469bb56734aa Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 3 Aug 2024 23:19:43 +0300 Subject: [PATCH 316/525] Add ctrl-w (delete word), ctrl-left (move to word beginning) and ctrl-right (move to word end) shortcuts for console --- src/console.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 103 insertions(+), 6 deletions(-) diff --git a/src/console.c b/src/console.c index 8bd8518f9..5c2e04eb3 100644 --- a/src/console.c +++ b/src/console.c @@ -850,9 +850,36 @@ static void CON_InputAddString(const char *c) Unlock_state(); } +static void CON_InputDel(size_t start, size_t end) +{ + size_t len; + + Lock_state(); + + len = (end - start); + + if (end != input_len) + memmove(&inputlines[inputline][start], &inputlines[inputline][end], input_len-end); + memset(&inputlines[inputline][input_len - len], 0, len); + + input_len -= len; + + if (input_sel >= end) + input_sel -= len; + else if (input_sel > start) + input_sel = start; + + if (input_cur >= end) + input_cur -= len; + else if (input_cur > start) + input_cur = start; + + Unlock_state(); +} + static void CON_InputDelSelection(void) { - size_t start, end, len; + size_t start, end; Lock_state(); @@ -866,18 +893,56 @@ static void CON_InputDelSelection(void) start = input_cur; end = input_sel; } - len = (end - start); - if (end != input_len) - memmove(&inputlines[inputline][start], &inputlines[inputline][end], input_len-end); - memset(&inputlines[inputline][input_len - len], 0, len); + CON_InputDel(start, end); - input_len -= len; input_sel = input_cur = start; Unlock_state(); } +static void CON_ToWordEnd(boolean move_sel) +{ + Lock_state(); + + // Skip spaces + while (input_cur < input_len && isspace(inputlines[inputline][input_cur])) + ++input_cur; + + // Skip word + while (input_cur < input_len && !isspace(inputlines[inputline][input_cur])) + ++input_cur; + + if (move_sel) input_sel = input_cur; + + Unlock_state(); +} + +static void CON_ToWordBegin(boolean move_sel) +{ + Lock_state(); + + // Hack, always move back 1 character if possible so if we press ctrl-left at a word beginning + // we move to previous word + if (input_cur) --input_cur; + + // Skip spaces + while (input_cur && isspace(inputlines[inputline][input_cur])) + --input_cur; + + // Skip word + while (input_cur && !isspace(inputlines[inputline][input_cur])) + --input_cur; + + // Unless we reached beginning of line, we're pointing at a space before word, so move cursor + // forward to fix that + if (input_cur) ++input_cur; + + if (move_sel) input_sel = input_cur; + + Unlock_state(); +} + static void CON_InputAddChar(char c) { if (input_len >= CON_MAXPROMPTCHARS-1) @@ -1055,6 +1120,38 @@ boolean CON_Responder(event_t *ev) completion[0] = 0; return true; } + else if (key == 'w' || key == 'W') + { + size_t word_start, word_end, i; + word_end = i = input_cur; + + // Unless we're pointing at the beginning of line, decrement i so we only start + // removing symbols that come before the cursor + if (i) --i; + + // We might be pointing to spaces, skip them first + while (i && isspace(inputlines[inputline][i])) + --i; + + // Now skip the "word" + while (i && !isspace(inputlines[inputline][i])) + --i; + + // Unless we reached beginning of line, i is pointing at first space that was found + // before word start, and we don't want to remove it + if (i) ++i; + + word_start = i; + + if (word_start != word_end) + CON_InputDel(word_start, word_end); + + return true; + } + else if (key == KEY_RIGHTARROW) + CON_ToWordEnd(!shiftdown); + else if (key == KEY_LEFTARROW) + CON_ToWordBegin(!shiftdown); // Select all if (key == 'a' || key == 'A') -- 2.54.0 From 0f994a0676fac3ee7d9408e1ce8873e0e5107655 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 22:33:08 +0200 Subject: [PATCH 317/525] expose viewroll to lua --- src/lua_playerlib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 74e6b0f32..dd4cf7b03 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -51,6 +51,9 @@ int player_localskin_setter(lua_State *L); int player_sliproll_getter(lua_State *L); int player_sliproll_noset(lua_State *L); +int player_viewrollangle_getter(lua_State *L); +int player_viewrollangle_noset(lua_State *L); + #define FIELD(type, field_name, getter, setter) { #field_name, offsetof(type, field_name), getter, setter } static const udata_field_t player_fields[] = { // Player doesn't actually have field "name" so macro fails. Need to declare field manually. @@ -159,6 +162,7 @@ static const udata_field_t player_fields[] = { #endif // Same as player.name { "sliproll", 0, player_sliproll_getter, player_sliproll_noset }, + { "viewrollangle", 0, player_viewrollangle_getter, player_viewrollangle_noset }, { "ping", 0, player_ping_getter, player_ping_noset }, // Hmm originally setter doesn't exist so data is written as unreachable custom field... { NULL, 0, NULL, NULL }, }; @@ -217,6 +221,7 @@ NOSET(bot) NOSET(splitscreenindex) NOSET(ping) NOSET(sliproll) +NOSET(viewrollangle) #undef NOSET @@ -372,6 +377,15 @@ int player_sliproll_getter(lua_State *L) return 1; } +int player_viewrollangle_getter(lua_State *L) +{ + player_t *plr = GETPLAYER(); + + lua_pushangle(L, R_ViewRollAngle(plr)); + + return 1; +} + static int lib_iteratePlayers(lua_State *L) { INT32 i = -1; -- 2.54.0 From 22b9915ad7ed97ea19af15657f7d599d6d15e1c0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 22:44:57 +0200 Subject: [PATCH 318/525] smol fix to viewroll interp --- src/r_fps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_fps.c b/src/r_fps.c index 17e357a16..b46c6e51b 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -147,7 +147,7 @@ static void R_SetupFreelook(void) void R_InterpolateViewRollAngle(fixed_t frac) { - viewroll = oldview->roll + R_LerpAngle(oldview->roll, newview->roll, frac); + viewroll = R_LerpAngle(oldview->roll, newview->roll, frac); } void R_InterpolateView(fixed_t frac, boolean forceinvalid) -- 2.54.0 From 852651cefe57c1c68be2b9c1f8f2460a3704cd0f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 3 Aug 2024 23:49:31 +0200 Subject: [PATCH 319/525] better statdisplay offsets in splitscreen lots of trial and error..... --- src/k_kart.c | 79 ++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 46 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 293e5209b..a3cfb55b0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7712,49 +7712,6 @@ static void K_drawKartStats(void) if (!LUA_HudEnabled(hud_statdisplay)) return; - - // I tried my best, but this is still mess :/ - if (splitscreen) - { - if (splitscreen == 1) - { - // If we are in 2-player splitscreen, for player 1 we move hud to up and remove snapping - // to bottom - if (splitnum == 0) - { - y /= 2; - flags = V_SNAPTOLEFT; - } - else - { - // Can move it down a bit - y += 20; - } - } - else - { - // In 4-player splitscreen... - flags = 0; - - // ...For players 2 and 4, which are at right side, we move x coordinate... - if (splitnum == 1 || splitnum == 3) - x += BASEVIDWIDTH/2; - // ...Else, for players on left side we can snap position to left... - else - flags |= V_SNAPTOLEFT; - - // ...For players 1 and 2, which are at top side, we move y coordinate... - if (splitnum == 0 || splitnum == 1) - y /= 2; - // ...Else, for players on bottom side we can snap position to bottom - else - { - flags |= V_SNAPTOBOTTOM; - // Can move it down a bit - y += 20; - } - } - } //Internal offset for speedometer if (cv_kartspeedometer.value) @@ -7766,17 +7723,47 @@ static void K_drawKartStats(void) } else spdoffset = 0; - + // Customizations c: if (!splitscreen) { x += 18 + cv_stat_xoffset.value; y += cv_stat_yoffset.value + (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0) + spdoffset; } + else if (splitscreen == 1) // I tried my best, but this is still mess :/ < :Blobcatpats: c: + { + x -= 10; + y -= 40; + y += (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0); + + // If we are in 2-player splitscreen, for player 1 we move hud to up and remove snapping + // to bottom + if (splitnum == 0) + { + y /= 2; + flags = V_SNAPTOLEFT; + } + else + { + // Can move it down a bit + y += 45; + } + } else { - x += 18; - y += (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0) + spdoffset; + if (splitnum == 0 || splitnum == 2) // If we are P1 or P3... + { + // ye i just align it to position number lol + x = POSI_X + 19; + y = POSI_Y - 6; + flags = V_SNAPTOLEFT|((splitnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + x = POSI2_X - 75; + y = POSI2_Y - 6; + flags = V_SNAPTORIGHT|((splitnum == 3) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + } } flags |= V_HUDTRANS; -- 2.54.0 From 7b95df150ae4eb9b004ad0b0c352e30a26f9af25 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 4 Aug 2024 12:45:23 +0200 Subject: [PATCH 320/525] support gcc 14.2.1 + fix some stuff --- src/Makefile.cfg | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 77779f7d5..abf9ed1d3 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -12,7 +12,7 @@ # to avoid a false positive with the version detection... SUPPORTED_GCC_VERSIONS:=\ - 141 14\ + 142 141 14\ 132 131 130 13\ 123 122 121 120 12\ 114 113 112 111 110 11\ @@ -24,7 +24,7 @@ SUPPORTED_GCC_VERSIONS:=\ 55 54 53 52 51 50\ 49 48 47 46 45 44 43 42 41 40 -LATEST_GCC_VERSION=14.1 +LATEST_GCC_VERSION=14.2.1 # gcc or g++ ifdef PREFIX @@ -78,12 +78,20 @@ ifeq (,$(filter GCC%,$(.VARIABLES))) endif endif -ifdef GCC141 +ifdef GCC142 GCC141=1 endif +ifdef GCC141 +GCC140=1 +endif + ifdef GCC14 -GCC14=1 +GCC140=1 +endif + +ifdef GCC140 +GCC132=1 endif ifdef GCC132 -- 2.54.0 From caeec35c66642380952d04248cc85b2b6cacbd45 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 4 Aug 2024 12:46:30 +0200 Subject: [PATCH 321/525] fix warning in director --- src/k_director.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index c0687494d..fdf636d46 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -37,7 +37,7 @@ struct directorinfo INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? } directorinfo; -static boolean race_rules() +static boolean race_rules(void) { return gametype = GT_RACE; } @@ -69,21 +69,6 @@ void K_InitDirector(void) } } -/*static fixed_t K_GetFinishGap(INT32 leader, INT32 follower) -{ - fixed_t dista = players[follower].distancetofinish; - fixed_t distb = players[leader].distancetofinish; - - if (players[follower].position < players[leader].position) - { - return distb - dista; - } - else - { - return dista - distb; - } -}*/ - static fixed_t K_GetDistanceToFinish(player_t player) { mobj_t *mo; -- 2.54.0 From 6791f2e883e2909fee54da1a01a468b5fc254122 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 4 Aug 2024 12:50:31 +0200 Subject: [PATCH 322/525] forgor --- src/Makefile.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index abf9ed1d3..4c304539a 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -12,7 +12,7 @@ # to avoid a false positive with the version detection... SUPPORTED_GCC_VERSIONS:=\ - 142 141 14\ + 142 141 140 14\ 132 131 130 13\ 123 122 121 120 12\ 114 113 112 111 110 11\ -- 2.54.0 From 4235801ae45d334f1a9db7c418dafc6e746dd54a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 4 Aug 2024 13:01:45 +0200 Subject: [PATCH 323/525] proper pass fwrapv to gcc --- src/Makefile | 2 +- src/Makefile.cfg | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index ee2e90cbc..78dfdd4f7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -285,7 +285,7 @@ else $(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o $(OBJDIR)/hw_shaders.o endif -OPTS += -DCOMPVERSION +OPTS += -DCOMPVERSION -fwrapv ifndef NONX86 ifndef GCC29 diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 4c304539a..cba731b9c 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -445,9 +445,6 @@ endif ifdef GCC44 WFLAGS+=-Wno-error=array-bounds endif -ifdef GCC45 -opts+=-fwrapv -endif ifdef GCC46 WFLAGS+=-Wno-error=suggest-attribute=noreturn endif -- 2.54.0 From 9c4b2b0abf3c37ed9461b754f2b96c0731932776 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 4 Aug 2024 14:07:54 +0200 Subject: [PATCH 324/525] no need for this --- src/p_tick.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 5acb8b5fb..b3a934cd4 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -372,18 +372,10 @@ void P_RunChaseCameras(void) { UINT8 i; - if (!splitscreen) + for (i = 0; i <= splitscreen; i++) { - if (camera[0].chase) - P_MoveChaseCamera(&players[displayplayers[0]], &camera[0], false); - } - else - { - for (i = 0; i <= splitscreen; i++) - { - if (camera[i].chase) - P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); - } + if (camera[i].chase) + P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); } } -- 2.54.0 From a83d364ba77e826e6b53c9a7bc457ef7808dd48d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 4 Aug 2024 14:51:19 +0200 Subject: [PATCH 325/525] update led status in main loop makes this whole ordeal alot less hacky tbh player color always gets updated if it changes still allows for directly setting led color elsewhere by using G_SetPlayerGamepadIndicatorColor directly hoping crap doesent cost any perf but honestly shouldnt --- src/d_main.c | 28 ++++++++++++++++++++++++++++ src/d_netcmd.c | 10 ---------- src/g_game.c | 6 ------ src/g_input.c | 4 ++-- src/g_input.h | 2 ++ src/lua_baselib.c | 1 + 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 79f564e1f..ade74830c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -170,6 +170,31 @@ UINT8 ctrldown = 0; // 0x1 left, 0x2 right UINT8 altdown = 0; // 0x1 left, 0x2 right boolean capslock = 0; // gee i wonder what this does. +static inline void D_DeviceLEDTick(void) +{ + UINT8 i; + UINT16 color[MAXSPLITSCREENPLAYERS]; + UINT16 curcolor[MAXSPLITSCREENPLAYERS]; + + // no gamepads connected + if (I_NumJoys() == 0) + return; + + for (i = 0; i <= splitscreen; i++) + { + if (G_GetDeviceForPlayer(i) == 0) + continue; + + color[i] = G_GetSkinColor(i); + + if (curcolor[i] == color[i]) // dont update if same colour + continue; + + G_SetPlayerGamepadIndicatorColor(i, color[i]); + curcolor[i] = color[i]; + } +} + // // D_ProcessEvents // Send all the events of the given timestamp down the responder chain @@ -839,6 +864,9 @@ void D_SRB2Loop(void) else menuInputDelayTimer = 0; + if (!dedicated && renderisnewtic) // idk does this need dedi check?? + D_DeviceLEDTick(); + // Fully completed frame made. finishprecise = I_GetPreciseTime(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3103b4fc8..140bc7076 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -6065,8 +6065,6 @@ static void Command_SkinSearch(void) */ static void Color_OnChange(void) { - G_SetPlayerGamepadIndicatorColor(0, 0); // i want this to always change so its here - if (!Playing()) return; // do whatever you want @@ -6086,8 +6084,6 @@ static void Color_OnChange(void) CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor); } - - G_SetPlayerGamepadIndicatorColor(0, 0); // update again } /** Sends a color change for the secondary splitscreen player, unless that @@ -6110,8 +6106,6 @@ static void Color2_OnChange(void) CV_StealthSetValue(&cv_playercolor2, players[displayplayers[1]].skincolor); } - - G_SetPlayerGamepadIndicatorColor(1, 0); } static void Color3_OnChange(void) @@ -6129,8 +6123,6 @@ static void Color3_OnChange(void) CV_StealthSetValue(&cv_playercolor3, players[displayplayers[2]].skincolor); } - - G_SetPlayerGamepadIndicatorColor(2, 0); } static void Color4_OnChange(void) @@ -6148,8 +6140,6 @@ static void Color4_OnChange(void) CV_StealthSetValue(&cv_playercolor4, players[displayplayers[3]].skincolor); } - - G_SetPlayerGamepadIndicatorColor(3, 0); } /** Displays the result of the chat being muted or unmuted. diff --git a/src/g_game.c b/src/g_game.c index 89d299c28..e05e7fcc0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2136,8 +2136,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) if (viewnum == 1 && demo.playback) consoleplayer = displayplayers[0]; - - G_SetPlayerGamepadIndicatorColor(viewnum-1, 0); } // @@ -8544,12 +8542,8 @@ boolean G_DemoTitleResponder(event_t *ev) // void G_SetGamestate(gamestate_t newstate) { - SINT8 i; gamestate = newstate; - for (i = 0; i <= splitscreen; i++) - G_SetPlayerGamepadIndicatorColor(i, 0); // dumb hack but works - #ifdef HAVE_DISCORDRPC DRPC_UpdatePresence(); #endif diff --git a/src/g_input.c b/src/g_input.c index f7057d4e4..00a57d7bc 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -865,7 +865,7 @@ static const char *gamecontrolname[num_gamecontrols] = #include "k_kart.h" -static INT32 G_GetDeviceForPlayer(INT32 player) +INT32 G_GetDeviceForPlayer(INT32 player) { switch (player) { @@ -887,7 +887,7 @@ static INT32 G_GetDeviceForPlayer(INT32 player) } } -static UINT16 G_GetSkinColor(INT32 player) +inline UINT16 G_GetSkinColor(INT32 player) { if (players[displayplayers[player]].skincolor && gamestate == GS_LEVEL) return players[displayplayers[player]].skincolor; diff --git a/src/g_input.h b/src/g_input.h index 92444cccc..8522be618 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -132,6 +132,8 @@ extern INT32 gamecontrol4[num_gamecontrols][2]; // peace to my little coder fingers! // check a gamecontrol being active or not +UINT16 G_GetSkinColor(INT32 player); +INT32 G_GetDeviceForPlayer(INT32 player); void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color); void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength, UINT32 duration); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index f5763dc09..cd43e40bf 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3022,6 +3022,7 @@ static int lib_gSetPlayerGamepadIndicatorColor(lua_State *L) // Not a local player if (player == -1) return 0; + // pls update with color 0 when youre done with changing led stuff so it can get player color again G_SetPlayerGamepadIndicatorColor(player, color); return 0; -- 2.54.0 From dd6056a07ad023fd80796f9a5de1f16243549cf5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 4 Aug 2024 14:51:35 +0200 Subject: [PATCH 326/525] check if theres even controllers in rumble ticker --- src/p_tick.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index b3a934cd4..8054ee554 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -319,7 +319,7 @@ static inline void P_DeviceRumbleTick(void) { UINT8 i; - if (cv_rumble[0].value == 0 && cv_rumble[1].value == 0 && cv_rumble[2].value == 0 && cv_rumble[3].value == 0) + if (I_NumJoys() == 0 || (cv_rumble[0].value == 0 && cv_rumble[1].value == 0 && cv_rumble[2].value == 0 && cv_rumble[3].value == 0)) { return; } @@ -336,6 +336,9 @@ static inline void P_DeviceRumbleTick(void) if (!playeringame[i] || player->spectator) continue; + if (G_GetDeviceForPlayer(i) == 0) + continue; + if (player->exiting) continue; -- 2.54.0 From 6c764a8487cbe4417006928026c7fc678575162f Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 4 Aug 2024 16:52:14 +0300 Subject: [PATCH 327/525] Fix chat not saving in console Not sure why it was working before but broke now, maybe making va use snprintf instead of sprintf broke that --- src/hu_stuff.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index cd0f42a9c..934b77105 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -594,7 +594,10 @@ void HU_AddChatText(const char *text, boolean playsound) if (OLDCHAT) // if we're using oldchat, print directly in console CONS_Printf("%s\n", text); else // if we aren't, still save the message to log.txt - CON_LogMessage(va("%s\n", text)); + { + CON_LogMessage(text); + CON_LogMessage("\n"); // Add newline. Don't use va for that, since `text` might be refering to va's buffer itself + } #else (void)playsound; CONS_Printf("%s\n", text); -- 2.54.0 From 8f2d36aab0ecd25a52cad8c67719ee92fb71ec3a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 5 Aug 2024 12:40:06 +0200 Subject: [PATCH 328/525] smol cleanup --- src/hardware/hw_main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2a0ff0c66..ba8d8cef1 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4772,6 +4772,7 @@ void HWR_ProjectSprite(mobj_t *thing) size_t lumpoff; unsigned rot; UINT8 flip; + boolean vflip; boolean mirrored; boolean hflip; @@ -4795,6 +4796,7 @@ void HWR_ProjectSprite(mobj_t *thing) if (!thing) return; + vflip = (thing->eflags & MFE_VERTICALFLIP); mirrored = thing->mirrored; hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); papersprite = (thing->frame & FF_PAPERSPRITE); @@ -4924,7 +4926,7 @@ void HWR_ProjectSprite(mobj_t *thing) } if (thing->skin && ((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->flags & SF_HIRES) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->highresscale); + this_scale *= FIXED_TO_FLOAT(((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->highresscale); spr_width = spritecachedinfo[lumpoff].width; spr_height = spritecachedinfo[lumpoff].height; @@ -5016,7 +5018,7 @@ void HWR_ProjectSprite(mobj_t *thing) x1 = tr_x + x1 * rightcos; x2 = tr_x - x2 * rightcos; - if (thing->eflags & MFE_VERTICALFLIP) + if (vflip) { gz = FIXED_TO_FLOAT(interp.z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); gzt = gz + (FIXED_TO_FLOAT(spr_height) * spriteyscale); @@ -5076,7 +5078,6 @@ void HWR_ProjectSprite(mobj_t *thing) vis->mobj = thing; - //Hurdler: 25/04/2000: now support colormap in hardware mode if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { @@ -5113,10 +5114,7 @@ void HWR_ProjectSprite(mobj_t *thing) //CONS_Debug(DBG_RENDER, "------------------\nH: sprite : %d\nH: frame : %x\nH: type : %d\nH: sname : %s\n\n", // thing->sprite, thing->frame, thing->type, sprnames[thing->sprite]); - if (thing->eflags & MFE_VERTICALFLIP) - vis->vflip = true; - else - vis->vflip = false; + vis->vflip = vflip; vis->precip = false; } -- 2.54.0 From d25c6fa0b261a877d1532767838493763294893e Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 8 Aug 2024 16:51:39 +0300 Subject: [PATCH 329/525] Test replay search --- src/filesrch.c | 5 +++ src/filesrch.h | 1 + src/m_menu.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/filesrch.c b/src/filesrch.c index 3a3a576ce..623dbcaa2 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -326,6 +326,7 @@ consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, ad char menupath[1024]; size_t menupathindex[menudepth]; size_t menudepthleft = menudepth; +char *replayhutquery = NULL; char menusearch[MAXSTRINGLENGTH+1]; @@ -691,6 +692,8 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) if (replayhut) { if (strcasecmp(".lmp", dent->d_name+len-5)) continue; // Not a replay + if (replayhutquery != NULL && strcasestr(dent->d_name, replayhutquery) == NULL) + continue; } else if (!cv_addons_showall.value) { @@ -765,6 +768,8 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) if (replayhut) { if (strcasecmp(".lmp", dent->d_name+len-5)) continue; // Not a replay + if (replayhutquery != NULL && strcasestr(dent->d_name, replayhutquery) == NULL) + continue; ext = EXT_TXT; // This isn't used anywhere but better safe than sorry for messing with this... } else diff --git a/src/filesrch.h b/src/filesrch.h index dd0fb404a..9bf4caa24 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -33,6 +33,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want extern char menupath[1024]; extern size_t menupathindex[menudepth]; extern size_t menudepthleft; +extern char *replayhutquery; extern char menusearch[MAXSTRINGLENGTH+1]; diff --git a/src/m_menu.c b/src/m_menu.c index baf13e6ec..e864ad492 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6711,6 +6711,11 @@ static void M_HandleAddons(INT32 choice) // ---- REPLAY HUT ----- menudemo_t *demolist; +#define MAXREPLAYQUERY 30 +char replayqueryinput[MAXREPLAYQUERY+1]; +size_t replayquerypos = 0; +boolean replayqueryopen = false; + #define DF_ENCORE 0x40 static INT16 replayScrollTitle = 0; static SINT8 replayScrollDelay = TICRATE, replayScrollDir = 1; @@ -6756,6 +6761,13 @@ void M_ReplayHut(INT32 choice) snprintf(menupath, 1024, "%s"PATHSEP"replay"PATHSEP"online"PATHSEP, srb2home); menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath); } + + // Reset + replayhutquery = NULL; + memset(replayqueryinput, 0, 30); + replayquerypos = 0; + replayqueryopen = false; + if (!preparefilemenu(false, true)) { M_StartMessage("No replays found.\n\n(Press a key)\n", NULL, MM_NOTHING); @@ -6779,10 +6791,71 @@ void M_ReplayHut(INT32 choice) S_ChangeMusicInternal("replst", true); } -static void M_HandleReplayHutList(INT32 choice) +static boolean M_HandleReplayHutQuery(INT32 choice) { + if (!replayqueryopen) + return false; + switch (choice) { + case KEY_ENTER: + case KEY_ESCAPE: + replayqueryopen = false; + break; + + case KEY_BACKSPACE: + if (replayquerypos == 0) + break; + + S_StartSound(NULL,sfx_menu1); + + replayquerypos--; + replayqueryinput[replayquerypos] = 0; + + if (!replayquerypos) + replayhutquery = NULL; + + preparefilemenu(false, true); + dir_on[menudepthleft] = 0; + PrepReplayList(); + + break; + + default: + if (choice < 32 || choice > 127) + break; + + if (replayquerypos < MAXREPLAYQUERY) + { + S_StartSound(NULL,sfx_menu1); + + replayqueryinput[replayquerypos] = choice; + replayqueryinput[replayquerypos+1] = 0; + ++replayquerypos; + + replayhutquery = replayqueryinput; + + preparefilemenu(false, true); + dir_on[menudepthleft] = 0; + PrepReplayList(); + } + } + + return true; +} + +static void M_HandleReplayHutList(INT32 choice) +{ + if (M_HandleReplayHutQuery(choice)) + return; + + switch (choice) + { + case 'f': + case 'F': + replayqueryopen = true; + break; + case KEY_UPARROW: if (dir_on[menudepthleft]) dir_on[menudepthleft]--; @@ -7179,6 +7252,17 @@ static void M_DrawReplayHut(void) { DrawReplayHutReplayInfo(); } + + // Draw search query + if (replayqueryopen || replayquerypos) + { + M_DrawTextBox(8, 200 - 16, MAXREPLAYQUERY, 1); + V_DrawString(16, 200 - 8, V_ALLOWLOWERCASE, replayqueryinput); + + // draw text cursor for name + if (replayqueryopen && skullAnimCounter < 4) // blink cursor + V_DrawCharacter(16 + V_StringWidth(replayqueryinput, V_ALLOWLOWERCASE), 200 - 8, '_', false); + } } static void M_DrawReplayStartMenu(void) -- 2.54.0 From 0bd2c49dae43bac5bc62bad3b430e2eece393610 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 8 Aug 2024 18:43:03 +0300 Subject: [PATCH 330/525] Search replays using title instead of filename --- src/d_netcmd.c | 1 + src/filesrch.c | 5 -- src/filesrch.h | 1 - src/m_menu.c | 132 +++++++++++++++++++++++++++++++++++++++---------- src/m_menu.h | 1 + 5 files changed, 108 insertions(+), 32 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 140bc7076..2c0d9ebf3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -999,6 +999,7 @@ void D_RegisterClientCommands(void) //CV_RegisterVar(&cv_alwaysfreelook2); //CV_RegisterVar(&cv_chasefreelook); //CV_RegisterVar(&cv_chasefreelook2); + CV_RegisterVar(&cv_replaysearchrate); CV_RegisterVar(&cv_showfocuslost); CV_RegisterVar(&cv_pauseifunfocused); diff --git a/src/filesrch.c b/src/filesrch.c index 623dbcaa2..3a3a576ce 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -326,7 +326,6 @@ consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, ad char menupath[1024]; size_t menupathindex[menudepth]; size_t menudepthleft = menudepth; -char *replayhutquery = NULL; char menusearch[MAXSTRINGLENGTH+1]; @@ -692,8 +691,6 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) if (replayhut) { if (strcasecmp(".lmp", dent->d_name+len-5)) continue; // Not a replay - if (replayhutquery != NULL && strcasestr(dent->d_name, replayhutquery) == NULL) - continue; } else if (!cv_addons_showall.value) { @@ -768,8 +765,6 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) if (replayhut) { if (strcasecmp(".lmp", dent->d_name+len-5)) continue; // Not a replay - if (replayhutquery != NULL && strcasestr(dent->d_name, replayhutquery) == NULL) - continue; ext = EXT_TXT; // This isn't used anywhere but better safe than sorry for messing with this... } else diff --git a/src/filesrch.h b/src/filesrch.h index 9bf4caa24..dd0fb404a 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -33,7 +33,6 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want extern char menupath[1024]; extern size_t menupathindex[menudepth]; extern size_t menudepthleft; -extern char *replayhutquery; extern char menusearch[MAXSTRINGLENGTH+1]; diff --git a/src/m_menu.c b/src/m_menu.c index e864ad492..d02a809ee 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -386,6 +386,7 @@ menu_t OP_DriftGaugeDef; menu_t MISC_ReplayHutDef; menu_t MISC_ReplayOptionsDef; static void M_HandleReplayHutList(INT32 choice); +static void M_HutCheckReplays(size_t maxnum); static void M_DrawReplayHut(void); static void M_DrawReplayStartMenu(void); static boolean M_QuitReplayHut(void); @@ -464,6 +465,9 @@ static void Dummystaff_OnChange(void); // CONSOLE VARIABLES AND THEIR POSSIBLE VALUES GO HERE. // ========================================================================== +// How much replays are checked per frame when using search +consvar_t cv_replaysearchrate = {"replaysearchrate", "50", CV_SAVE, CV_Natural, NULL, 0, NULL, NULL, 0, 0, NULL }; + consvar_t cv_showfocuslost = {"showfocuslost", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL }; static CV_PossibleValue_t map_cons_t[] = { @@ -619,6 +623,7 @@ static menuitem_t MISC_ReplayOptionsMenu[] = {IT_CVAR|IT_STRING, NULL, "Record Replays", &cv_recordmultiplayerdemos, 0}, {IT_CVAR|IT_STRING, NULL, "Sync Check Interval", &cv_netdemosyncquality, 10}, {IT_CVAR|IT_STRING, NULL, "Max demo size (MiB)", &cv_maxdemosize, 20}, + {IT_CVAR|IT_STRING, NULL, "Replay Search Rate", &cv_replaysearchrate, 30}, }; static tic_t playback_last_menu_interaction_leveltime = 0; @@ -4430,6 +4435,9 @@ void M_Ticker(void) else playback_enterheld = 0; + if (currentMenu == &MISC_ReplayHutDef) + M_HutCheckReplays(cv_replaysearchrate.value); + interpTimerHackAllow = true; //added : 30-01-98 : test mode for five seconds @@ -6709,45 +6717,122 @@ static void M_HandleAddons(INT32 choice) } // ---- REPLAY HUT ----- -menudemo_t *demolist; +menudemo_t *demolist; // Replays that that have been checked to match with query +menudemo_t *demolist_all; // All replays #define MAXREPLAYQUERY 30 -char replayqueryinput[MAXREPLAYQUERY+1]; -size_t replayquerypos = 0; -boolean replayqueryopen = false; +char replayqueryinput[MAXREPLAYQUERY+1]; // The input typed +size_t replayquerypos = 0; // Position in input window +boolean replayqueryopen = false; // Is query window open? + +size_t replayqueryfound = 0; // Number of checked replay entries +size_t replayquerycheck = 0; // Index of next replay entry to check in demolist_all #define DF_ENCORE 0x40 static INT16 replayScrollTitle = 0; static SINT8 replayScrollDelay = TICRATE, replayScrollDir = 1; +static void ResetReplayQuery(void) +{ + memset(replayqueryinput, 0, MAXREPLAYQUERY); + replayquerypos = 0; + replayqueryopen = false; + + replayqueryfound = 0; + replayquerycheck = 0; +} + +static void AddCheckedReplay(void) +{ + memcpy(&demolist[replayqueryfound], &demolist_all[replayquerycheck], sizeof(menudemo_t)); + ++replayqueryfound; + ++replayquerycheck; +} + +// Check up to maxnum replays if they match with query +static void M_HutCheckReplays(size_t maxnum) +{ + // Already checked everything + if (replayquerycheck == sizedirmenu) + return; + + // If we don't have any query, just copy all demos and consider them checked + if (replayquerypos == 0) + { + // Mark as done + replayqueryfound = replayquerycheck = sizedirmenu; + + memcpy(demolist, demolist_all, sizeof(menudemo_t) * sizedirmenu); + + return; + } + + while (maxnum-- && replayquerycheck < sizedirmenu) + { + switch (demolist_all[replayquerycheck].type) + { + case MD_SUBDIR: + AddCheckedReplay(); // Just add subdirs + // Will also be decremented on next iteration. Basically, we just don't want to + // spend our number of tries on subdirs, since we don't check anything for them + ++maxnum; + break; + + case MD_NOTLOADED: + G_LoadDemoInfo(&demolist_all[replayquerycheck]); + ++maxnum; // Gonna check this one next iteration, don't decrease our number of tries yet + break; + + case MD_OUTDATED: + case MD_LOADED: + if (strcasestr(demolist_all[replayquerycheck].title, replayqueryinput) != NULL) + AddCheckedReplay(); // It matches, add it! + else + replayquerycheck++; // Doesn't match, moving on... + + break; + + // Don't show invalid replays + case MD_INVALID: + replayquerycheck++; + } + } +} + static void PrepReplayList(void) { size_t i; + replayquerycheck = replayqueryfound = 0; + if (demolist) Z_Free(demolist); + if (demolist_all) + Z_Free(demolist_all); + demolist = Z_Calloc(sizeof(menudemo_t) * sizedirmenu, PU_STATIC, NULL); + demolist_all = Z_Calloc(sizeof(menudemo_t) * sizedirmenu, PU_STATIC, NULL); for (i = 0; i < sizedirmenu; i++) { if (dirmenu[i][DIR_TYPE] == EXT_UP) { - demolist[i].type = MD_SUBDIR; - sprintf(demolist[i].title, "UP"); + demolist_all[i].type = MD_SUBDIR; + sprintf(demolist_all[i].title, "UP"); } else if (dirmenu[i][DIR_TYPE] == EXT_FOLDER) { - demolist[i].type = MD_SUBDIR; - strncpy(demolist[i].title, dirmenu[i] + DIR_STRING, 64); + demolist_all[i].type = MD_SUBDIR; + strncpy(demolist_all[i].title, dirmenu[i] + DIR_STRING, 64); } else { - demolist[i].type = MD_NOTLOADED; + demolist_all[i].type = MD_NOTLOADED; // FIXME - do something with buffer sizes. menupath is 1024 chars but filepath is only // 256. I'm not really sure what to do here but don't want to leave warnings... - snprintf(demolist[i].filepath, 255, "%.254s%s", menupath, dirmenu[i] + DIR_STRING); - sprintf(demolist[i].title, "....."); + snprintf(demolist_all[i].filepath, 255, "%.254s%s", menupath, dirmenu[i] + DIR_STRING); + sprintf(demolist_all[i].title, "....."); } } } @@ -6762,11 +6847,7 @@ void M_ReplayHut(INT32 choice) menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath); } - // Reset - replayhutquery = NULL; - memset(replayqueryinput, 0, 30); - replayquerypos = 0; - replayqueryopen = false; + ResetReplayQuery(); if (!preparefilemenu(false, true)) { @@ -6812,9 +6893,6 @@ static boolean M_HandleReplayHutQuery(INT32 choice) replayquerypos--; replayqueryinput[replayquerypos] = 0; - if (!replayquerypos) - replayhutquery = NULL; - preparefilemenu(false, true); dir_on[menudepthleft] = 0; PrepReplayList(); @@ -6833,8 +6911,6 @@ static boolean M_HandleReplayHutQuery(INT32 choice) replayqueryinput[replayquerypos+1] = 0; ++replayquerypos; - replayhutquery = replayqueryinput; - preparefilemenu(false, true); dir_on[menudepthleft] = 0; PrepReplayList(); @@ -6868,7 +6944,7 @@ static void M_HandleReplayHutList(INT32 choice) break; case KEY_DOWNARROW: - if (dir_on[menudepthleft] < sizedirmenu-1) + if (dir_on[menudepthleft] < replayqueryfound-1) dir_on[menudepthleft]++; else return; @@ -6908,6 +6984,7 @@ static void M_HandleReplayHutList(INT32 choice) { S_StartSound(NULL, sfx_menu1); dir_on[menudepthleft] = 1; + ResetReplayQuery(); PrepReplayList(); } } @@ -7127,7 +7204,7 @@ static void M_DrawReplayHut(void) if (itemOn > replaylistitem) { itemOn = replaylistitem; - dir_on[menudepthleft] = sizedirmenu-1; + dir_on[menudepthleft] = replayqueryfound-1; replayScrollTitle = 0; replayScrollDelay = TICRATE; replayScrollDir = 1; } else if (itemOn < replaylistitem) @@ -7141,7 +7218,7 @@ static void M_DrawReplayHut(void) INT32 maxy; // Scroll menu items if needed cursory = y + currentMenu->menuitems[replaylistitem].alphaKey + dir_on[menudepthleft]*10; - maxy = y + currentMenu->menuitems[replaylistitem].alphaKey + sizedirmenu*10; + maxy = y + currentMenu->menuitems[replaylistitem].alphaKey + replayqueryfound*10; if (cursory > maxy - 20) cursory = maxy - 20; @@ -7175,7 +7252,7 @@ static void M_DrawReplayHut(void) y += currentMenu->menuitems[replaylistitem].alphaKey; - for (i = 0; i < (INT16)sizedirmenu; i++) + for (i = 0; i < (INT16)replayqueryfound; i++) { INT32 localy = y+i*10; INT32 localx = x; @@ -7233,7 +7310,7 @@ static void M_DrawReplayHut(void) } // Draw scrollbar - y = sizedirmenu*10 + currentMenu->menuitems[replaylistitem].alphaKey + 30; + y = replayqueryfound*10 + currentMenu->menuitems[replaylistitem].alphaKey + 30; if (y > SCALEDVIEWHEIGHT-80) { V_DrawFill(BASEVIDWIDTH-4, 75, 4, SCALEDVIEWHEIGHT-80, V_SNAPTOTOP|V_SNAPTORIGHT|239); @@ -7262,6 +7339,9 @@ static void M_DrawReplayHut(void) // draw text cursor for name if (replayqueryopen && skullAnimCounter < 4) // blink cursor V_DrawCharacter(16 + V_StringWidth(replayqueryinput, V_ALLOWLOWERCASE), 200 - 8, '_', false); + + if (replayquerycheck < sizedirmenu) + V_DrawString(16, 200 - 24, V_ALLOWLOWERCASE, va("Searching %u/%u...", (unsigned)replayquerycheck, (unsigned)sizedirmenu)); } } diff --git a/src/m_menu.h b/src/m_menu.h index a01c2ddef..3d29963f2 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -255,6 +255,7 @@ 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; extern consvar_t cv_showallmaps; -- 2.54.0 From bb0c777cac7e67aac136c3c1a890e1f07a6e66ff Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 8 Aug 2024 21:31:09 +0300 Subject: [PATCH 331/525] Fix M_HutCheckReplays still being called in menu (hopefully) --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index d02a809ee..8b07ef019 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4435,7 +4435,7 @@ void M_Ticker(void) else playback_enterheld = 0; - if (currentMenu == &MISC_ReplayHutDef) + if (demo.inreplayhut) M_HutCheckReplays(cv_replaysearchrate.value); interpTimerHackAllow = true; -- 2.54.0 From 0758cf39c2f4e9b87d13fa48246a22b526af6186 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 8 Aug 2024 22:01:19 +0300 Subject: [PATCH 332/525] Greatly improve replay search perfomance by only reading replay name, and not entire file. Increase default search rate up to 1000 --- src/g_game.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/g_game.h | 1 + src/m_menu.c | 8 +++----- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index e05e7fcc0..117205b44 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -7211,6 +7211,58 @@ void G_LoadDemoInfo(menudemo_t *pdemo) Z_Free(infobuffer); } +void G_LoadDemoTitle(menudemo_t *pdemo) +{ + UINT8 infobuffer[96], *info_p; + UINT16 pdemoversion; + size_t count; + + FILE *handle = fopen(pdemo->filepath, "rb"); + + if (!handle) + { + CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); + sprintf(pdemo->title, "INVALID REPLAY"); + return; + } + + count = fread(infobuffer, 1, 96, handle); + fclose(handle); + info_p = infobuffer; + + // First check isn't too accurate technically, but well, valid replays should be larger than that anyway + if (count < 96 || memcmp(info_p, DEMOHEADER, 12)) + { + CONS_Alert(CONS_ERROR, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemo->filepath); + sprintf(pdemo->title, "INVALID REPLAY"); + Z_Free(infobuffer); + return; + } + + info_p += 12; // DEMOHEADER + + READUINT8(info_p); + READUINT8(info_p); + pdemoversion = READUINT16(info_p); + + switch(pdemoversion) + { + case DEMOVERSION: // latest always supported + // demo title + M_Memcpy(pdemo->title, info_p, 64); + break; +#ifdef DEMO_COMPAT_100 + case 0x0001: + sprintf(pdemo->title, "Legacy Replay"); + break; +#endif + // too old, cannot support. + default: + CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath); + sprintf(pdemo->title, "INVALID REPLAY"); + } +} + // // G_PlayDemo // diff --git a/src/g_game.h b/src/g_game.h index bfc158583..977cc4dc3 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -265,6 +265,7 @@ void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar void G_DoLoadLevel(boolean resetplayer); void G_LoadDemoInfo(menudemo_t *pdemo); +void G_LoadDemoTitle(menudemo_t *pdemo); // For use in replay search feature void G_DeferedPlayDemo(const char *demo); // Can be called by the startup code or M_Responder, calls P_SetupLevel. diff --git a/src/m_menu.c b/src/m_menu.c index 8b07ef019..c269b0b0a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -466,7 +466,7 @@ static void Dummystaff_OnChange(void); // ========================================================================== // How much replays are checked per frame when using search -consvar_t cv_replaysearchrate = {"replaysearchrate", "50", CV_SAVE, CV_Natural, NULL, 0, NULL, NULL, 0, 0, NULL }; +consvar_t cv_replaysearchrate = {"replaysearchrate", "1000", CV_SAVE, CV_Natural, NULL, 0, NULL, NULL, 0, 0, NULL }; consvar_t cv_showfocuslost = {"showfocuslost", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL }; @@ -6779,10 +6779,8 @@ static void M_HutCheckReplays(size_t maxnum) break; case MD_NOTLOADED: - G_LoadDemoInfo(&demolist_all[replayquerycheck]); - ++maxnum; // Gonna check this one next iteration, don't decrease our number of tries yet - break; - + G_LoadDemoTitle(&demolist_all[replayquerycheck]); + /* FALLTHRU */ case MD_OUTDATED: case MD_LOADED: if (strcasestr(demolist_all[replayquerycheck].title, replayqueryinput) != NULL) -- 2.54.0 From ee4869993d1cf29fe4f9325d09dad5647537cf57 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 8 Aug 2024 22:03:00 +0300 Subject: [PATCH 333/525] Oops shouldn't z_free that --- src/g_game.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 117205b44..bc2937838 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -7235,7 +7235,6 @@ void G_LoadDemoTitle(menudemo_t *pdemo) { CONS_Alert(CONS_ERROR, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemo->filepath); sprintf(pdemo->title, "INVALID REPLAY"); - Z_Free(infobuffer); return; } -- 2.54.0 From c9aa764444a75eaa052070f76ab678abc5c47984 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 8 Aug 2024 22:09:30 +0300 Subject: [PATCH 334/525] Add alternative button ('/') to open replay search --- src/m_menu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/m_menu.c b/src/m_menu.c index c269b0b0a..b667081e5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6925,6 +6925,7 @@ static void M_HandleReplayHutList(INT32 choice) switch (choice) { + case '/': case 'f': case 'F': replayqueryopen = true; -- 2.54.0 From 8db99291ac4e9f1603137c11b560f7c664b23640 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 8 Aug 2024 22:40:22 +0300 Subject: [PATCH 335/525] Visual improvements for replay search --- src/m_menu.c | 31 ++++++++++++++++++++----------- src/m_menu.h | 3 +++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index b667081e5..e7688f238 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4744,6 +4744,12 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) V_DrawFill(x+5, y+5, width*8+6, boxlines*8+6, 239); } +void M_DrawTextBoxFlags(INT32 x, INT32 y, INT32 width, INT32 boxlines, INT32 flags) +{ + // Solid color textbox. + V_DrawFill(x+5, y+5, width*8+6, boxlines*8+6, 239|flags); +} + // horizontally centered text static void M_CentreText(INT32 y, const char *string) { @@ -6720,7 +6726,7 @@ static void M_HandleAddons(INT32 choice) menudemo_t *demolist; // Replays that that have been checked to match with query menudemo_t *demolist_all; // All replays -#define MAXREPLAYQUERY 30 +#define MAXREPLAYQUERY 40 char replayqueryinput[MAXREPLAYQUERY+1]; // The input typed size_t replayquerypos = 0; // Position in input window boolean replayqueryopen = false; // Is query window open? @@ -7258,7 +7264,7 @@ static void M_DrawReplayHut(void) if (localy < 65) continue; - if (localy >= SCALEDVIEWHEIGHT) + if (localy >= SCALEDVIEWHEIGHT - 24) break; if (demolist[i].type == MD_NOTLOADED && !processed_one_this_frame) @@ -7329,19 +7335,22 @@ static void M_DrawReplayHut(void) DrawReplayHutReplayInfo(); } + x -= 40; + // Draw search query + M_DrawTextBoxFlags(x, 200 - 22, MAXREPLAYQUERY, 1, V_SNAPTOBOTTOM); + if (replayqueryopen || replayquerypos) - { - M_DrawTextBox(8, 200 - 16, MAXREPLAYQUERY, 1); - V_DrawString(16, 200 - 8, V_ALLOWLOWERCASE, replayqueryinput); + V_DrawString(x + 8, 200 - 14, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, replayqueryinput); + else + V_DrawString(x + 8, 200 - 14, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, "\x86Press '/' or 'f' to search replays"); - // draw text cursor for name - if (replayqueryopen && skullAnimCounter < 4) // blink cursor - V_DrawCharacter(16 + V_StringWidth(replayqueryinput, V_ALLOWLOWERCASE), 200 - 8, '_', false); + // draw text cursor for name + if (replayqueryopen && skullAnimCounter < 4) // blink cursor + V_DrawCharacter(x + 8 + V_StringWidth(replayqueryinput, V_ALLOWLOWERCASE), 200 - 14, '_'|V_SNAPTOBOTTOM, false); - if (replayquerycheck < sizedirmenu) - V_DrawString(16, 200 - 24, V_ALLOWLOWERCASE, va("Searching %u/%u...", (unsigned)replayquerycheck, (unsigned)sizedirmenu)); - } + if (replayquerycheck < sizedirmenu) + V_DrawString(x + 8, 200 - 30, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, va("Searching %u/%u...", (unsigned)replayquerycheck, (unsigned)sizedirmenu)); } static void M_DrawReplayStartMenu(void) diff --git a/src/m_menu.h b/src/m_menu.h index 3d29963f2..e74fd491f 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -59,6 +59,9 @@ void M_SortServerList(void); // Draws a box with a texture inside as background for messages void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines); +// Same but with extra flags applied +void M_DrawTextBoxFlags(INT32 x, INT32 y, INT32 width, INT32 boxlines, INT32 flags); + // Used in d_netcmd to restart time attack void M_ModeAttackRetry(INT32 choice); -- 2.54.0 From c2cfc96d879475edf1ecc5da09be8d8412b853c7 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 9 Aug 2024 16:05:48 +0300 Subject: [PATCH 336/525] Load replay titles in separate thread --- src/m_menu.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 102 insertions(+), 11 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e7688f238..55646f921 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6724,7 +6724,25 @@ static void M_HandleAddons(INT32 choice) // ---- REPLAY HUT ----- menudemo_t *demolist; // Replays that that have been checked to match with query + +// Locked behind Lock_search_state menudemo_t *demolist_all; // All replays +boolean replaynamesloaded = false; + +#ifdef HAVE_THREADS +I_mutex replayquerymutex; + +// g_in_exiting_signal_handler is an evil hack +// to avoid infinite SIGABRT recursion in the signal handler +// due to poisoned locks or mach-o kernel not supporting locks in signals +// or something like that. idk +# define Lock_search_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&replayquerymutex); } +# define Unlock_search_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(replayquerymutex); } +#else/*HAVE_THREADS*/ +# define Lock_search_state() +# define Unlock_search_state() +#endif/*HAVE_THREADS*/ + #define MAXREPLAYQUERY 40 char replayqueryinput[MAXREPLAYQUERY+1]; // The input typed @@ -6738,6 +6756,53 @@ size_t replayquerycheck = 0; // Index of next replay entry to check in demolist_ static INT16 replayScrollTitle = 0; static SINT8 replayScrollDelay = TICRATE, replayScrollDir = 1; +static void ReplayNamesLoadThread(void* userdata) +{ + + Lock_search_state(); + + size_t demolist_all_size = sizedirmenu; + menudemo_t *demolist_all_local = (menudemo_t*)malloc(sizeof(menudemo_t)*sizedirmenu); + memcpy(demolist_all_local, demolist_all, sizeof(menudemo_t)*sizedirmenu); + char *replaydirpath = (char*)userdata; + + Unlock_search_state(); + + for (size_t i = 0; i < demolist_all_size; ++i) + { + if (demolist_all_local[i].type != MD_SUBDIR) + G_LoadDemoTitle(&demolist_all_local[i]); + } + + Lock_search_state(); + + if (strcmp(menupath, replaydirpath) == 0) + { + memcpy(demolist_all, demolist_all_local, sizeof(menudemo_t)*sizedirmenu); + replaynamesloaded = true; + } + + Unlock_search_state(); + + // Was allocated before thread start, we need to free it + free(replaydirpath); +} + +static void LoadReplayNames(void) +{ + char *replaydirpath = strdup(menupath); + + Lock_search_state(); + replaynamesloaded = false; + Unlock_search_state(); + +#ifdef HAVE_THREADS + I_spawn_thread("replay-names-load", ReplayNamesLoadThread, replaydirpath); +#else + ReplayNamesLoadThread(replaydirpath); +#endif +} + static void ResetReplayQuery(void) { memset(replayqueryinput, 0, MAXREPLAYQUERY); @@ -6758,6 +6823,9 @@ static void AddCheckedReplay(void) // Check up to maxnum replays if they match with query static void M_HutCheckReplays(size_t maxnum) { + if (!replaynamesloaded) + return; + // Already checked everything if (replayquerycheck == sizedirmenu) return; @@ -6785,11 +6853,9 @@ static void M_HutCheckReplays(size_t maxnum) break; case MD_NOTLOADED: - G_LoadDemoTitle(&demolist_all[replayquerycheck]); - /* FALLTHRU */ case MD_OUTDATED: case MD_LOADED: - if (strcasestr(demolist_all[replayquerycheck].title, replayqueryinput) != NULL) + if (demolist_all[replayquerycheck].title[0] && strcasestr(demolist_all[replayquerycheck].title, replayqueryinput) != NULL) AddCheckedReplay(); // It matches, add it! else replayquerycheck++; // Doesn't match, moving on... @@ -6803,7 +6869,7 @@ static void M_HutCheckReplays(size_t maxnum) } } -static void PrepReplayList(void) +static void PrepReplayList(boolean reset) { size_t i; @@ -6812,10 +6878,16 @@ static void PrepReplayList(void) if (demolist) Z_Free(demolist); + demolist = Z_Calloc(sizeof(menudemo_t) * sizedirmenu, PU_STATIC, NULL); + + // If directory didn't change, keep demolist_all + if (!reset) return; + + Lock_search_state(); + if (demolist_all) Z_Free(demolist_all); - demolist = Z_Calloc(sizeof(menudemo_t) * sizedirmenu, PU_STATIC, NULL); demolist_all = Z_Calloc(sizeof(menudemo_t) * sizedirmenu, PU_STATIC, NULL); for (i = 0; i < sizedirmenu; i++) @@ -6839,6 +6911,10 @@ static void PrepReplayList(void) sprintf(demolist_all[i].title, "....."); } } + + Unlock_search_state(); + + LoadReplayNames(); } void M_ReplayHut(INT32 choice) @@ -6864,7 +6940,7 @@ void M_ReplayHut(INT32 choice) replayScrollTitle = 0; replayScrollDelay = TICRATE; replayScrollDir = 1; - PrepReplayList(); + PrepReplayList(true); menuactive = true; M_SetupNextMenu(&MISC_ReplayHutDef); @@ -6899,7 +6975,7 @@ static boolean M_HandleReplayHutQuery(INT32 choice) preparefilemenu(false, true); dir_on[menudepthleft] = 0; - PrepReplayList(); + PrepReplayList(false); break; @@ -6917,7 +6993,7 @@ static boolean M_HandleReplayHutQuery(INT32 choice) preparefilemenu(false, true); dir_on[menudepthleft] = 0; - PrepReplayList(); + PrepReplayList(false); } } @@ -6938,6 +7014,9 @@ static void M_HandleReplayHutList(INT32 choice) break; case KEY_UPARROW: + if (!replaynamesloaded) + return; + if (dir_on[menudepthleft]) dir_on[menudepthleft]--; else @@ -6949,6 +7028,9 @@ static void M_HandleReplayHutList(INT32 choice) break; case KEY_DOWNARROW: + if (!replaynamesloaded) + return; + if (dir_on[menudepthleft] < replayqueryfound-1) dir_on[menudepthleft]++; else @@ -6964,6 +7046,9 @@ static void M_HandleReplayHutList(INT32 choice) break; case KEY_ENTER: + if (!replaynamesloaded) + return; + switch (dirmenu[dir_on[menudepthleft]][DIR_TYPE]) { case EXT_FOLDER: @@ -6990,7 +7075,7 @@ static void M_HandleReplayHutList(INT32 choice) S_StartSound(NULL, sfx_menu1); dir_on[menudepthleft] = 1; ResetReplayQuery(); - PrepReplayList(); + PrepReplayList(true); } } else @@ -7008,7 +7093,7 @@ static void M_HandleReplayHutList(INT32 choice) M_QuitReplayHut(); return; } - PrepReplayList(); + PrepReplayList(true); break; default: // We can't just use M_SetupNextMenu because that'll run ReplayDef's quitroutine and boot us back to the title screen! @@ -7257,6 +7342,12 @@ static void M_DrawReplayHut(void) y += currentMenu->menuitems[replaylistitem].alphaKey; + if (!replaynamesloaded) + { + const char *msg = "Loading replays, please wait..."; + V_DrawCenteredString(160, 100, V_ALLOWLOWERCASE, msg); + } + for (i = 0; i < (INT16)replayqueryfound; i++) { INT32 localy = y+i*10; @@ -7349,7 +7440,7 @@ static void M_DrawReplayHut(void) if (replayqueryopen && skullAnimCounter < 4) // blink cursor V_DrawCharacter(x + 8 + V_StringWidth(replayqueryinput, V_ALLOWLOWERCASE), 200 - 14, '_'|V_SNAPTOBOTTOM, false); - if (replayquerycheck < sizedirmenu) + if (replaynamesloaded && replayquerycheck < sizedirmenu) V_DrawString(x + 8, 200 - 30, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, va("Searching %u/%u...", (unsigned)replayquerycheck, (unsigned)sizedirmenu)); } -- 2.54.0 From b4612d6bd430aebffce88612309f6cce583192af Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 9 Aug 2024 19:45:16 +0300 Subject: [PATCH 337/525] Fix smol memory leak in replay search thread oops --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 55646f921..d72a803ef 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6758,7 +6758,6 @@ static SINT8 replayScrollDelay = TICRATE, replayScrollDir = 1; static void ReplayNamesLoadThread(void* userdata) { - Lock_search_state(); size_t demolist_all_size = sizedirmenu; @@ -6786,6 +6785,7 @@ static void ReplayNamesLoadThread(void* userdata) // Was allocated before thread start, we need to free it free(replaydirpath); + free(demolist_all_local); } static void LoadReplayNames(void) -- 2.54.0 From a56ce0992378f1cb66a567b1fd79beace96a4242 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 11 Aug 2024 11:57:54 +0300 Subject: [PATCH 338/525] Fix LUA_EvalMath warnings being broken sometimes --- src/lua_script.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index 85aefbfbd..f4bf8a07a 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -399,8 +399,14 @@ fixed_t LUA_EvalMath(const char *word) if (luaL_dostring(mL, buf)) { p = lua_tostring(mL, -1); - while (*p++ != ':' && *p) ; - p += 3; // "1: " + + // If there is [string "..."]:1: text, skip it + if (strstr(p, ":") != NULL) + { + while (*p++ != ':' && *p); + + p += 3; // "1: " + } CONS_Alert(CONS_WARNING, "%s\n", p); } else -- 2.54.0 From 2398e60e89609ee35e45840a5435fc9f9df6b2ae Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 14 Aug 2024 14:10:16 +0200 Subject: [PATCH 339/525] fix director lol --- src/k_director.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index fdf636d46..a39e88292 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -37,12 +37,12 @@ struct directorinfo INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? } directorinfo; -static boolean race_rules(void) +static inline boolean race_rules(void) { - return gametype = GT_RACE; + return gametype == GT_RACE; } -static fixed_t P_ScaleFromMap(fixed_t n, fixed_t scale) +static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) { return FixedMul(n, FixedDiv(scale, mapobjectscale)); } @@ -90,7 +90,7 @@ static fixed_t K_GetDistanceToFinish(player_t player) break; } } - else + else // crappy optimization weeeee { for (mo = waypointcap; mo != NULL; mo = mo->tracer) { @@ -155,7 +155,7 @@ static void K_UpdateDirectorPositions(void) continue; } - directorinfo.gap[position] = P_ScaleFromMap(K_GetFinishGap(directorinfo.sortedplayers[position], directorinfo.sortedplayers[position + 1]), FRACUNIT); + directorinfo.gap[position] = ScaleFromMap(K_GetFinishGap(directorinfo.sortedplayers[position], directorinfo.sortedplayers[position + 1]), FRACUNIT); if (directorinfo.gap[position] >= BREAKAWAYDIST) { @@ -173,7 +173,7 @@ static void K_UpdateDirectorPositions(void) return; } - directorinfo.maxdist = P_ScaleFromMap(K_GetDistanceToFinish(players[directorinfo.sortedplayers[0]]), FRACUNIT); + directorinfo.maxdist = ScaleFromMap(K_GetDistanceToFinish(players[directorinfo.sortedplayers[0]]), FRACUNIT); } static boolean K_CanSwitchDirector(void) -- 2.54.0 From 5bdf8698bd85bb7bee204232a5bc0d941d04e3d0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 14 Aug 2024 14:44:22 +0200 Subject: [PATCH 340/525] completely disable director in splitscreen will eventually get to splitscreen support lul --- src/k_director.c | 7 ++++++- src/st_stuff.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index a39e88292..001e553ad 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -49,7 +49,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) static boolean K_DirectorIsEnabled(void) { - return cv_director.value && (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || demo.playback)); + return cv_director.value && (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || demo.playback)) && !splitscreen; } void K_InitDirector(void) @@ -188,6 +188,11 @@ static boolean K_CanSwitchDirector(void) static void K_DirectorSwitch(INT32 player, boolean force) { + if (!K_DirectorIsEnabled()) + { + return; + } + if (P_IsDisplayPlayer(&players[player])) { return; diff --git a/src/st_stuff.c b/src/st_stuff.c index df4ba7db9..afbf74b8f 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -662,7 +662,7 @@ static void ST_overlayDrawer(void) // Countdown timer for Race Mode // ...moved to k_kart.c so we can take advantage of the LAPS_Y value - if (demo.playback || !P_IsLocalPlayer(stplyr)) + if ((demo.playback || !P_IsLocalPlayer(stplyr)) && !splitscreen) { char directortext[20] = {0}; -- 2.54.0 From 94714fe57141691b0e28d7c44939ed9a49f17e62 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 14 Aug 2024 16:08:29 +0300 Subject: [PATCH 341/525] Fix increasing number of viewpoints in replays by more than 1 (like pressing '3' with only one viewpoint) crashing game --- src/g_game.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_game.c b/src/g_game.c index bc2937838..743fa52d5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2130,6 +2130,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) { for (viewd = splits+1; viewd < viewnum; ++viewd) { + displayplayers[viewd-1] = G_FindView(displayplayers[viewd-1], viewd, onlyactive, playernum < olddisplayplayer); G_FixCamera(viewd); } } -- 2.54.0 From 35f54822be55854e6b0b73b5eaa1a3228bbef99b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 16:38:05 +0200 Subject: [PATCH 342/525] smol cleanup HWR_RenderPlane --- src/hardware/hw_main.c | 43 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ba8d8cef1..ed2c1b0ef 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -667,31 +667,33 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta) // Render a floor or ceiling convex polygon void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap) { - polyvertex_t * pv; - float height; //constant y for all points on the convex flat polygon - FOutVector *v3d; - INT32 nrPlaneVerts; //verts original define of convex flat polygon - INT32 i; - float flatxref,flatyref; - float fflatsize; - INT32 flatflag; + FSurfaceInfo Surf; + FOutVector *v3d; + polyvertex_t *pv; + pslope_t *slope = NULL; + INT32 shader = SHADER_NONE; + + size_t nrPlaneVerts; + INT32 i; + + float height; // constant y for all points on the convex flat polygon + float flatxref, flatyref = 0.0f; + float fflatsize = 64.0f; + INT32 flatflag = 63; size_t len; + + float tempxsow, tempytow; float scrollx = 0.0f, scrolly = 0.0f; angle_t angle = 0; - FSurfaceInfo Surf; - fixed_t tempxsow, tempytow; - pslope_t *slope = NULL; static FOutVector *planeVerts = NULL; static UINT16 numAllocedPlaneVerts = 0; - - INT32 shader = SHADER_NONE; // no convex poly were generated for this subsector if (!xsub->planepoly) return; - pv = xsub->planepoly->pts; + pv = xsub->planepoly->pts; nrPlaneVerts = xsub->planepoly->numpts; if (nrPlaneVerts < 3) //not even a triangle ? @@ -800,12 +802,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc { angle = InvAngle(angle)>>ANGLETOFINESHIFT; - // This needs to be done so that it scrolls in a different direction after rotation like software - /*tempxsow = FLOAT_TO_FIXED(scrollx); - tempytow = FLOAT_TO_FIXED(scrolly); - scrollx = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - scrolly = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));*/ - // This needs to be done so everything aligns after rotation // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does tempxsow = FLOAT_TO_FIXED(flatxref); @@ -838,7 +834,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc vert->y = FIXED_TO_FLOAT(fixedheight);\ }\ } - for (i = 0, v3d = planeVerts; i < nrPlaneVerts; i++,v3d++,pv++) + for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++) SETUP3DVERT(v3d, pv->x, pv->y); if (slope) @@ -949,7 +945,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc vx = (horizonpts[3].x - gr_viewx) * farrenderdist / renderdist + gr_viewx; vy = (horizonpts[3].z - gr_viewy) * farrenderdist / renderdist + gr_viewy; SETUP3DVERT((&horizonpts[4]), vx, vy); - horizonpts[4].y = gr_viewz; + horizonpts[4].y = gr_viewz; // Draw HWR_ProcessPolygon(&Surf, horizonpts, 6, PolyFlags, shader, true); @@ -1325,7 +1321,7 @@ static void HWR_DrawSkyWallList(void) // Draw walls into the depth buffer so that anything behind is culled properly void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) { - //HWD.pfnSetTexture(NULL); + //HWR_SetCurrentTexture(NULL); // no texture wallVerts[3].t = wallVerts[2].t = 0; wallVerts[0].t = wallVerts[1].t = 0; @@ -1569,7 +1565,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_DrawSkyWall(wallVerts, &Surf); } - // Sky Floors wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); -- 2.54.0 From 808f7baf536b0128f763e451c52a2c8bbd7d3334 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 13:41:20 +0200 Subject: [PATCH 343/525] move this in coindition --- src/k_director.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_director.c b/src/k_director.c index 001e553ad..a0cb6f961 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -49,7 +49,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) static boolean K_DirectorIsEnabled(void) { - return cv_director.value && (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || demo.playback)) && !splitscreen; + return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || demo.playback)); } void K_InitDirector(void) -- 2.54.0 From 5393ac526ab6e03af4453d51f5427e962ed72838 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 15:19:11 +0200 Subject: [PATCH 344/525] move this in hw_main --- src/hardware/hw_cache.c | 1 - src/hardware/hw_main.c | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 98034970d..c079f2110 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -573,7 +573,6 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap); - HWR_SetCurrentTexture(&grtex->mipmap); // The system-memory data can be purged now. diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ed2c1b0ef..821233dc8 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5548,16 +5548,14 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe HWD.pfnSetTransform(&atransform); validcount++; - - if (cv_grbatching.value) - HWR_StartBatching(); - - HWR_AddPrecipitationSprites(); ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; PS_START_TIMING(ps_bsptime); + if (cv_grbatching.value) + HWR_StartBatching(); + if (!rootportal && portallist.base && !skybox)// if portals have been drawn in the main view, then render skywalls differently gr_collect_skywalls = true; @@ -5567,11 +5565,15 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe if (gr_portal != GRPORTAL_OFF) // if we already haven't hit the recursion limit or we already ended our portal shenanigans gr_portal = GRPORTAL_INSIDE; // TURN IT OFF + // Recursively "render" the BSP tree. HWR_RenderBSPNode((INT32)numnodes-1); + // woo we back gr_portal = oldgl_portal_state; + HWR_AddPrecipitationSprites(); + PS_STOP_TIMING(ps_bsptime); if (cv_grbatching.value) -- 2.54.0 From e100fff23025ea9cac1092f05a9994fa85a75744 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 15:47:10 +0200 Subject: [PATCH 345/525] check for changed state before everything else --- src/hardware/hw_batching.c | 54 ++++++++++++++++++++------------------ src/hardware/hw_batching.h | 2 +- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 7dde8b3bd..a4984a905 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -424,38 +424,40 @@ void HWR_RenderBatches(void) if (stopFlag) break; // change state according to change bools and next vars, update current vars and reset bools - if (changeShader) + if (changeState) { - HWD.pfnSetShader(nextShader); - currentShader = nextShader; - changeShader = false; + if (changeShader) + { + HWD.pfnSetShader(nextShader); + currentShader = nextShader; + changeShader = false; - ps_hw_numshaders.value.i++; - } - if (changeTexture) - { - // texture should be already ready for use from calls to SetTexture during batch collection - HWD.pfnSetTexture(nextTexture); - currentTexture = nextTexture; - changeTexture = false; + ps_hw_numshaders.value.i++; + } + if (changeTexture) + { + // texture should be already ready for use from calls to SetTexture during batch collection + HWD.pfnSetTexture(nextTexture); + currentTexture = nextTexture; + changeTexture = false; - ps_hw_numtextures.value.i++; - } - if (changePolyFlags) - { - currentPolyFlags = nextPolyFlags; - changePolyFlags = false; + ps_hw_numtextures.value.i++; + } + if (changePolyFlags) + { + currentPolyFlags = nextPolyFlags; + changePolyFlags = false; - ps_hw_numpolyflags.value.i++; - } - if (changeSurfaceInfo) - { - currentSurfaceInfo = nextSurfaceInfo; - changeSurfaceInfo = false; + ps_hw_numpolyflags.value.i++; + } + if (changeSurfaceInfo) + { + currentSurfaceInfo = nextSurfaceInfo; + changeSurfaceInfo = false; - ps_hw_numcolors.value.i++; + ps_hw_numcolors.value.i++; + } } - // and that should be it? } // reset the arrays (set sizes to 0) polygonArraySize = 0; diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index 7c108a4bd..22a4cc4c0 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -17,7 +17,7 @@ #include "hw_data.h" #include "hw_drv.h" -typedef struct +typedef struct { FSurfaceInfo surf;// surf also has its own polyflags for some reason, but it seems unused unsigned int vertsIndex;// location of verts in unsortedVertexArray -- 2.54.0 From 2100f11af77155e37a8f3d672aae8ddd0592318e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 17:32:15 +0200 Subject: [PATCH 346/525] remove duplicates in ResetNode --- src/d_clisrv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8b24616b6..071a92504 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4168,20 +4168,19 @@ void D_ClientServerInit(void) static void ResetNode(INT32 node) { nodeingame[node] = false; - nodewaiting[node] = 0; + nettics[node] = gametic; supposedtics[node] = gametic; is_client_saturn[node] = false; + nodetoplayer[node] = -1; nodetoplayer2[node] = -1; nodetoplayer3[node] = -1; nodetoplayer4[node] = -1; - nettics[node] = gametic; - supposedtics[node] = gametic; - nodewaiting[node] = 0; playerpernode[node] = 0; + sendingsavegame[node] = false; resendingsavegame[node] = false; can_receive_gamestate[node] = false; -- 2.54.0 From ac55d473e74a41ef03de3e3104d486735fc0ee8b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 17:33:18 +0200 Subject: [PATCH 347/525] smol cleanup --- src/d_clisrv.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 071a92504..57a990fb0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1718,7 +1718,6 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.gametype = (UINT8)gametype; netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - if (!can_receive_gamestate[node]) { // we fill these structs with FFs so that any players not in game get sent as 0xFFFF @@ -1753,24 +1752,23 @@ static boolean SV_SendServerConfig(INT32 node) CV_SavePlayerNames(&p); CV_SaveNetVars(&p, false); } - { - size_t len; - if (can_receive_gamestate[node]) - len = sizeof (serverconfig_pak); - else - len = sizeof (serverconfig_pak) + (size_t)(p - op); + size_t len; + + if (can_receive_gamestate[node]) + len = sizeof (serverconfig_pak); + else + len = sizeof (serverconfig_pak) + (size_t)(p - op); #ifdef DEBUGFILE - if (debugfile) - { - fprintf(debugfile, "ServerConfig Packet about to be sent, size of packet:%s to node:%d\n", - sizeu1(len), node); - } + if (debugfile) + { + fprintf(debugfile, "ServerConfig Packet about to be sent, size of packet:%s to node:%d\n", + sizeu1(len), node); + } #endif - waspacketsent = HSendPacket(node, true, 0, len); - } + waspacketsent = HSendPacket(node, true, 0, len); #ifdef DEBUGFILE if (debugfile) @@ -1967,8 +1965,11 @@ static void CL_LoadReceivedSavegame(boolean reloading) // Tell the server we have received and reloaded the gamestate // so they know they can resume the game - netbuffer->packettype = PT_RECEIVEDGAMESTATE; - HSendPacket(servernode, true, 0, 0); + if (reloading) + { + netbuffer->packettype = PT_RECEIVEDGAMESTATE; + HSendPacket(servernode, true, 0, 0); + } } static void CL_ReloadReceivedSavegame(void) -- 2.54.0 From ada1de7ad61683d5feba553b27d5b36a8e0445f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 23:40:54 +0200 Subject: [PATCH 348/525] dont change connect behaviour regardless of client + smol cleanup and fixes should hopefully fix any remaining issues --- src/d_clisrv.c | 77 ++++++++++++++++++++++---------------------------- src/g_game.c | 2 -- 2 files changed, 33 insertions(+), 46 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 57a990fb0..a9d121997 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1718,25 +1718,22 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.gametype = (UINT8)gametype; netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - if (!can_receive_gamestate[node]) + // we fill these structs with FFs so that any players not in game get sent as 0xFFFF + // which is nice and easy for us to detect + memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); + memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); + + memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); + + for (i = 0; i < MAXPLAYERS; i++) { - // we fill these structs with FFs so that any players not in game get sent as 0xFFFF - // which is nice and easy for us to detect - memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); - memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); + netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; - memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); + if (!playeringame[i]) + continue; - for (i = 0; i < MAXPLAYERS; i++) - { - netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; - - if (!playeringame[i]) - continue; - - netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; - netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; - } + netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; + netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; } netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); @@ -1745,20 +1742,12 @@ static boolean SV_SendServerConfig(INT32 node) memcpy(netbuffer->u.servercfg.server_context, server_context, 8); - if (!can_receive_gamestate[node]) - { - op = p = netbuffer->u.servercfg.varlengthinputs; + op = p = netbuffer->u.servercfg.varlengthinputs; - CV_SavePlayerNames(&p); - CV_SaveNetVars(&p, false); - } + CV_SavePlayerNames(&p); + CV_SaveNetVars(&p, false); - size_t len; - - if (can_receive_gamestate[node]) - len = sizeof (serverconfig_pak); - else - len = sizeof (serverconfig_pak) + (size_t)(p - op); + size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); #ifdef DEBUGFILE if (debugfile) @@ -4171,23 +4160,27 @@ static void ResetNode(INT32 node) nodeingame[node] = false; nodewaiting[node] = 0; - nettics[node] = gametic; - supposedtics[node] = gametic; - - is_client_saturn[node] = false; - nodetoplayer[node] = -1; nodetoplayer2[node] = -1; nodetoplayer3[node] = -1; nodetoplayer4[node] = -1; playerpernode[node] = 0; + nettics[node] = gametic; + supposedtics[node] = gametic; + sendingsavegame[node] = false; + + bannednode[node].banid = SIZE_MAX; + bannednode[node].timeleft = NO_BAN_TIME; + + // SATURN + is_client_saturn[node] = false; + resendingsavegame[node] = false; can_receive_gamestate[node] = false; savegameresendcooldown[node] = 0; - bannednode[node].banid = SIZE_MAX; - bannednode[node].timeleft = NO_BAN_TIME; + // } void SV_ResetServer(void) @@ -6651,18 +6644,14 @@ void NetUpdate(void) if (client) { + // If the client just finished redownloading the game state, load it + if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) + CL_ReloadReceivedSavegame(); + if (!resynch_local_inprogress) CL_SendClientCmd(); // Send tic cmd + hu_resynching = resynch_local_inprogress; - - if (cl_redownloadinggamestate) - { - // If the client just finished redownloading the game state, load it - if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) - CL_ReloadReceivedSavegame(); - - CL_SendClientCmd(); // Send tic cmd - } hu_redownloadinggamestate = cl_redownloadinggamestate; } else diff --git a/src/g_game.c b/src/g_game.c index e119c8ee8..daee674b3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1664,8 +1664,6 @@ void G_DoLoadLevel(boolean resetplayer) Z_CheckHeap(-2); #endif - memset(localaiming, 0, sizeof(localaiming)); - for (i = 0; i <= splitscreen; i++) { if (camera[i].chase) -- 2.54.0 From 9f8db631f0074de1c9e13dda27a48e44051d2b55 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 23:46:02 +0200 Subject: [PATCH 349/525] reset rumble when player is exiting --- src/p_tick.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8054ee554..cc2600f17 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -333,18 +333,21 @@ static inline void P_DeviceRumbleTick(void) if (!P_IsLocalPlayer(player)) continue; - if (!playeringame[i] || player->spectator) - continue; - if (G_GetDeviceForPlayer(i) == 0) continue; - if (player->exiting) + if (!playeringame[displayplayers[i]] || player->spectator) continue; if (player->mo == NULL) continue; + if (player->exiting) + { + G_PlayerDeviceRumble(i, low, high, 0); + continue; + } + if (player->kartstuff[k_spinouttimer]) { low = high = 65536 / 4; -- 2.54.0 From f6361e29bd0bd89198e047c4e2cb9cfa741f7938 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 23:46:02 +0200 Subject: [PATCH 350/525] reset rumble when player is exiting --- src/p_tick.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8054ee554..cc2600f17 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -333,18 +333,21 @@ static inline void P_DeviceRumbleTick(void) if (!P_IsLocalPlayer(player)) continue; - if (!playeringame[i] || player->spectator) - continue; - if (G_GetDeviceForPlayer(i) == 0) continue; - if (player->exiting) + if (!playeringame[displayplayers[i]] || player->spectator) continue; if (player->mo == NULL) continue; + if (player->exiting) + { + G_PlayerDeviceRumble(i, low, high, 0); + continue; + } + if (player->kartstuff[k_spinouttimer]) { low = high = 65536 / 4; -- 2.54.0 From 3973851dd2ba53bc4a0968d55faaabbd2b740262 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 16 Aug 2024 00:09:08 +0200 Subject: [PATCH 351/525] add toggles for gamepad led stuff --- src/d_main.c | 5 +++-- src/d_netcmd.c | 10 ++++++++++ src/g_input.c | 20 ++++++++++++++++++++ src/g_input.h | 2 ++ src/m_menu.c | 16 ++++++++++++---- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ade74830c..22a11171a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -176,9 +176,10 @@ static inline void D_DeviceLEDTick(void) UINT16 color[MAXSPLITSCREENPLAYERS]; UINT16 curcolor[MAXSPLITSCREENPLAYERS]; - // no gamepads connected - if (I_NumJoys() == 0) + if (I_NumJoys() == 0 || (cv_gamepadled[0].value == 0 && cv_gamepadled[1].value == 0 && cv_gamepadled[2].value == 0 && cv_gamepadled[3].value == 0)) + { return; + } for (i = 0; i <= splitscreen; i++) { diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 2c0d9ebf3..2480611c0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1079,6 +1079,16 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_rumble[2]); CV_RegisterVar(&cv_rumble[3]); + CV_RegisterVar(&cv_gamepadled[0]); + CV_RegisterVar(&cv_gamepadled[1]); + CV_RegisterVar(&cv_gamepadled[2]); + CV_RegisterVar(&cv_gamepadled[3]); + + CV_RegisterVar(&cv_ledpowerup[0]); + CV_RegisterVar(&cv_ledpowerup[1]); + CV_RegisterVar(&cv_ledpowerup[2]); + CV_RegisterVar(&cv_ledpowerup[3]); + CV_RegisterVar(&cv_usemouse); CV_RegisterVar(&cv_usemouse2); CV_RegisterVar(&cv_invertmouse); diff --git a/src/g_input.c b/src/g_input.c index 00a57d7bc..90de813b2 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -52,6 +52,20 @@ consvar_t cv_rumble[MAXSPLITSCREENPLAYERS] = { {"rumble4", "Off", CV_SAVE, CV_OnOff, rumble_off_handle4, 0, NULL, NULL, 0, 0, NULL} }; +consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = { + {"gamepadled", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"gamepadled2", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"gamepadled3", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"gamepadled4", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + +consvar_t cv_ledpowerup[MAXSPLITSCREENPLAYERS] = { + {"ledpowerup", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"ledpowerup2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"ledpowerup3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"ledpowerup4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + static void rumble_off_handle(void) { if (cv_rumble[0].value == 0) @@ -889,6 +903,9 @@ INT32 G_GetDeviceForPlayer(INT32 player) inline UINT16 G_GetSkinColor(INT32 player) { + if (gamestate == GS_LEVEL && cv_ledpowerup[player].value && (players[displayplayers[player]].kartstuff[k_invincibilitytimer] || players[displayplayers[player]].powers[pw_invulnerability] || players[displayplayers[player]].kartstuff[k_growshrinktimer])) + return players[displayplayers[player]].mo->color; + if (players[displayplayers[player]].skincolor && gamestate == GS_LEVEL) return players[displayplayers[player]].skincolor; @@ -920,6 +937,9 @@ void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color) I_Assert(player >= 0 && player < MAXSPLITSCREENPLAYERS); + if (cv_gamepadled[player].value == 0) + return; + device = G_GetDeviceForPlayer(player); if (device <= 0) diff --git a/src/g_input.h b/src/g_input.h index 8522be618..6799f6ca0 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -108,6 +108,8 @@ extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_mousesens2, cv_mouseysens2; extern consvar_t cv_controlperkey, cv_turnsmooth; extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_ledpowerup[MAXSPLITSCREENPLAYERS]; extern INT32 mousex, mousey; extern INT32 mlooky; //mousey with mlookSensitivity diff --git a/src/m_menu.c b/src/m_menu.c index d72a803ef..ab7e06b1b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1229,6 +1229,8 @@ static menuitem_t OP_Joystick1Menu[] = {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone , 150}, {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 170}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 180}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 190}, }; static menuitem_t OP_Joystick2Menu[] = @@ -1249,6 +1251,8 @@ static menuitem_t OP_Joystick2Menu[] = {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone2 , 150}, {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 170}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 180}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 190}, }; static menuitem_t OP_Joystick3Menu[] = @@ -1269,6 +1273,8 @@ static menuitem_t OP_Joystick3Menu[] = {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone3 , 150}, {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 170}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 180}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 190}, }; static menuitem_t OP_Joystick4Menu[] = @@ -1289,6 +1295,8 @@ static menuitem_t OP_Joystick4Menu[] = {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone4 , 150}, {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 170}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 180}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 190}, }; static menuitem_t OP_JoystickSetMenu[] = @@ -2812,10 +2820,10 @@ menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDe //WTF menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30); menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef); -menu_t OP_Joystick1Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 60, 30); -menu_t OP_Joystick2Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 60, 30); -menu_t OP_Joystick3Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 60, 30); -menu_t OP_Joystick4Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 60, 30); +menu_t OP_Joystick1Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 60, 16); +menu_t OP_Joystick2Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 60, 16); +menu_t OP_Joystick3Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 60, 16); +menu_t OP_Joystick4Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 60, 16); menu_t OP_JoystickSetDef = { "M_CONTRO", -- 2.54.0 From f6c170b53c2876c35a79e2478632977badde6d8b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 16 Aug 2024 00:34:08 +0200 Subject: [PATCH 352/525] add onchange func for led + fix rumble onchange --- src/g_input.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 90de813b2..e16761966 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -45,25 +45,31 @@ static void rumble_off_handle2(void); static void rumble_off_handle3(void); static void rumble_off_handle4(void); +static void G_ResetPlayerGamepadIndicatorColor(INT32 player); +static void led_off_handle(void); +static void led_off_handle2(void); +static void led_off_handle3(void); +static void led_off_handle4(void); + consvar_t cv_rumble[MAXSPLITSCREENPLAYERS] = { - {"rumble", "Off", CV_SAVE, CV_OnOff, rumble_off_handle, 0, NULL, NULL, 0, 0, NULL}, - {"rumble2", "Off", CV_SAVE, CV_OnOff, rumble_off_handle2, 0, NULL, NULL, 0, 0, NULL}, - {"rumble3", "Off", CV_SAVE, CV_OnOff, rumble_off_handle3, 0, NULL, NULL, 0, 0, NULL}, - {"rumble4", "Off", CV_SAVE, CV_OnOff, rumble_off_handle4, 0, NULL, NULL, 0, 0, NULL} + {"rumble", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, rumble_off_handle, 0, NULL, NULL, 0, 0, NULL}, + {"rumble2", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, rumble_off_handle2, 0, NULL, NULL, 0, 0, NULL}, + {"rumble3", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, rumble_off_handle3, 0, NULL, NULL, 0, 0, NULL}, + {"rumble4", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, rumble_off_handle4, 0, NULL, NULL, 0, 0, NULL} }; consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = { - {"gamepadled", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"gamepadled2", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"gamepadled3", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"gamepadled4", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} + {"gamepadled", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, led_off_handle, 0, NULL, NULL, 0, 0, NULL}, + {"gamepadled2", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, led_off_handle2, 0, NULL, NULL, 0, 0, NULL}, + {"gamepadled3", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, led_off_handle3, 0, NULL, NULL, 0, 0, NULL}, + {"gamepadled4", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, led_off_handle4, 0, NULL, NULL, 0, 0, NULL} }; consvar_t cv_ledpowerup[MAXSPLITSCREENPLAYERS] = { - {"ledpowerup", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"ledpowerup2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"ledpowerup3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"ledpowerup4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} + {"ledpowerup", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, led_off_handle, 0, NULL, NULL, 0, 0, NULL}, + {"ledpowerup2", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, led_off_handle2, 0, NULL, NULL, 0, 0, NULL}, + {"ledpowerup3", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, led_off_handle3, 0, NULL, NULL, 0, 0, NULL}, + {"ledpowerup4", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, led_off_handle4, 0, NULL, NULL, 0, 0, NULL} }; static void rumble_off_handle(void) @@ -93,6 +99,29 @@ static void rumble_off_handle4(void) G_ResetPlayerDeviceRumble(3); } +static void led_off_handle(void) +{ + G_ResetPlayerGamepadIndicatorColor(0); +} + + +static void led_off_handle2(void) +{ + G_ResetPlayerGamepadIndicatorColor(1); +} + + +static void led_off_handle3(void) +{ + G_ResetPlayerGamepadIndicatorColor(2); +} + + +static void led_off_handle4(void) +{ + G_ResetPlayerGamepadIndicatorColor(3); +} + INT32 mousex, mousey; INT32 mlooky; // like mousey but with a custom sensitivity for mlook @@ -957,6 +986,20 @@ void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color) I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue); } +static void G_ResetPlayerGamepadIndicatorColor(INT32 player) +{ + if (cv_gamepadled[player].value == 0) + { + INT32 device = G_GetDeviceForPlayer(player); + if (device <= 0) + return; + + I_SetGamepadIndicatorColor(device, 0, 0, 255); + } + else + G_SetPlayerGamepadIndicatorColor(player, 0); +} + static void G_ResetPlayerDeviceRumble(INT32 player) { INT32 device_id; -- 2.54.0 From 35029e826f6795c35e2d6d3f144d59e3620d1966 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 10 Aug 2024 13:54:16 +0300 Subject: [PATCH 353/525] Add delayed hit em sound (like in DRRR), togglable via 'karthitemdialog' cvar --- src/d_netcmd.c | 1 + src/d_netcmd.h | 1 + src/d_player.h | 3 ++ src/k_kart.c | 80 +++++++++++++++++++++++++++++++++++++++++++---- src/k_kart.h | 2 +- src/lua_baselib.c | 24 ++++++++++++-- src/p_inter.c | 6 ++-- src/p_local.h | 2 +- src/p_mobj.c | 2 ++ src/p_spec.c | 2 +- src/p_user.c | 22 +++++++++++-- 11 files changed, 129 insertions(+), 16 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 2480611c0..790bc2850 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -397,6 +397,7 @@ static CV_PossibleValue_t kartspeedometer_cons_t[] = {{0, "Off"}, {1, "Kilometer consvar_t cv_kartspeedometer = {"kartdisplayspeed", "Off", CV_SAVE, kartspeedometer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // use tics in display static CV_PossibleValue_t kartvoices_cons_t[] = {{0, "Never"}, {1, "Tasteful"}, {2, "Meme"}, {0, NULL}}; consvar_t cv_kartvoices = {"kartvoices", "Tasteful", CV_SAVE, kartvoices_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_karthitemdialog = {"karthitemdialog", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_karteliminatelast = {"karteliminatelast", "Yes", CV_NETVAR|CV_CHEAT|CV_CALL|CV_NOSHOWHELP, CV_YesNo, KartEliminateLast_OnChange, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index dbb06409d..81806b816 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -128,6 +128,7 @@ extern consvar_t cv_kartvoterulechanges; extern consvar_t cv_kartgametypepreference; extern consvar_t cv_kartspeedometer; extern consvar_t cv_kartvoices; +extern consvar_t cv_karthitemdialog; extern consvar_t cv_karteliminatelast; diff --git a/src/d_player.h b/src/d_player.h index 28ab11286..c2a5d32ce 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -546,6 +546,9 @@ typedef struct player_s tic_t grieftime; UINT8 griefstrikes; + tic_t hitemtimer; + UINT8 hitemvictim; + UINT8 splitscreenindex; #ifdef HWRENDER fixed_t fovadd; // adjust FOV for hw rendering diff --git a/src/k_kart.c b/src/k_kart.c index a3cfb55b0..6f3b6c7c0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -680,6 +680,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartgametypepreference); CV_RegisterVar(&cv_kartspeedometer); CV_RegisterVar(&cv_kartvoices); + CV_RegisterVar(&cv_karthitemdialog); CV_RegisterVar(&cv_karteliminatelast); CV_RegisterVar(&cv_votetime); @@ -1899,6 +1900,31 @@ static void K_RegularVoiceTimers(player_t *player) player->kartstuff[k_tauntvoices] = 4*TICRATE; } +static void K_PlayGenericCombatSound(mobj_t *source, mobj_t *other, sfxenum_t sfx_id) +{ + skin_t *skin = NULL; + + // I HATE LOCALSKINS! I HATE LOCALSKINS! :AAAAAAAAAA: + if (source->player) + { + INT32 skinnum = source->player->skinlocal ? (source->player->localskin - 1) : source->player->skin; + skin = &(source->player->skinlocal ? localskins : skins)[skinnum]; + } + + if (!skin) + return; + + boolean alwaysHear = false; + + if (other != NULL && P_MobjWasRemoved(other) == false && other->player != NULL) + alwaysHear = P_IsDisplayPlayer(other->player); + + if (cv_kartvoices.value) + S_StartSound(alwaysHear ? NULL : source, skin->soundsid[S_sfx[sfx_id].skinsound]); + + K_RegularVoiceTimers(source->player); +} + void K_PlayAttackTaunt(mobj_t *source) { sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons @@ -1947,10 +1973,22 @@ void K_PlayOvertakeSound(mobj_t *source) K_RegularVoiceTimers(source->player); } -void K_PlayHitEmSound(mobj_t *source) +void K_PlayHitEmSound(mobj_t *source, mobj_t *victim) { if (cv_kartvoices.value) - S_StartSound(source, sfx_khitem); + { + if (cv_karthitemdialog.value && victim && victim->player) + { + I_Assert(source->player != NULL); + + source->player->hitemtimer = TICRATE/2; + source->player->hitemvictim = victim->player - players; + + return; // Don't call K_RegularVoiceTimers yet, we didn't do any sound + } + else + S_StartSound(source, sfx_khitem); + } else S_StartSound(source, sfx_s1c9); // The only lost gameplay functionality with voices disabled @@ -1965,6 +2003,33 @@ void K_PlayPowerGloatSound(mobj_t *source) K_RegularVoiceTimers(source->player); } +static void K_HandleDelayedHitByEm(player_t *player) +{ + if (player->hitemtimer == 0) + { + return; + } + + player->hitemtimer--; + + if (player->hitemtimer == 0) + { + mobj_t *victim = NULL; + + if (player->hitemvictim < MAXPLAYERS && playeringame[player->hitemvictim]) + { + player_t *victimPlayer = &players[player->hitemvictim]; + + if (victimPlayer != NULL && victimPlayer->spectator == false) + { + victim = victimPlayer->mo; + } + } + + K_PlayGenericCombatSound(player->mo, victim, sfx_khitem); + } +} + void K_MomentumToFacing(player_t *player) { angle_t dangle = player->mo->angle - R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); @@ -2272,7 +2337,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto return; if (source && source != player->mo && source->player) - K_PlayHitEmSound(source); + K_PlayHitEmSound(source, player->mo); //player->kartstuff[k_sneakertimer] = 0; player->kartstuff[k_driftboost] = 0; @@ -2472,7 +2537,7 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor) if (player->mo->state != &states[S_KART_SQUISH]) // Squash P_SetPlayerMobjState(player->mo, S_KART_SQUISH); - P_PlayRinglossSound(player->mo); + P_PlayRinglossSound(player->mo, source); player->kartstuff[k_instashield] = 15; if (cv_kartdebughuddrop.value && !modeattacking) @@ -2524,7 +2589,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b return; if (source && source != player->mo && source->player) - K_PlayHitEmSound(source); + K_PlayHitEmSound(source, player->mo); player->kartstuff[k_sneakertimer] = 0; player->kartstuff[k_driftboost] = 0; @@ -2605,7 +2670,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b if (player->mo->state != &states[S_KART_SPIN]) P_SetPlayerMobjState(player->mo, S_KART_SPIN); - P_PlayRinglossSound(player->mo); + P_PlayRinglossSound(player->mo, source); if (P_IsLocalPlayer(player)) { @@ -5278,6 +5343,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) // Roulette Code K_KartItemRoulette(player, cmd); + // Used when karthitemdialog is On + K_HandleDelayedHitByEm(player); + // Handle invincibility sfx K_UpdateInvincibilitySounds(player); // Also thanks, VAda! diff --git a/src/k_kart.h b/src/k_kart.h index 1f95aefe2..647ae3bf0 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -92,7 +92,7 @@ void K_UpdateSpectateGrief(void); void K_PlayAttackTaunt(mobj_t *source); void K_PlayBoostTaunt(mobj_t *source); void K_PlayOvertakeSound(mobj_t *source); -void K_PlayHitEmSound(mobj_t *source); +void K_PlayHitEmSound(mobj_t *source, mobj_t *victim); void K_PlayPowerGloatSound(mobj_t *source); const char *K_GetItemPatch(UINT8 item, boolean tiny); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index cd43e40bf..3fbfd463d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1259,6 +1259,7 @@ static int lib_pPlayRinglossSound(lua_State *L) { mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); player_t *player = NULL; + mobj_t *damager = NULL; NOHUD if (!source) return LUA_ErrInvalid(L, "mobj_t"); @@ -1268,8 +1269,15 @@ static int lib_pPlayRinglossSound(lua_State *L) if (!player) return LUA_ErrInvalid(L, "player_t"); } + if (!lua_isnoneornil(L, 3)) + { + damager = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + + if (!damager) + return LUA_ErrInvalid(L, "mobj_t"); + } if (!player || P_IsLocalPlayer(player)) - P_PlayRinglossSound(source); + P_PlayRinglossSound(source, damager); return 0; } @@ -2557,10 +2565,22 @@ static int lib_kOvertakeSound(lua_State *L) static int lib_kHitEmSound(lua_State *L) { mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *victim = NULL; + + if (!lua_isnoneornil(L, 2)) + { + victim = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + if (!victim) + return LUA_ErrInvalid(L, "mobj_t"); + } + NOHUD if (!mobj->player) return luaL_error(L, "K_PlayHitEmSound: mobj_t isn't a player object."); //Nothing bad would happen if we let it run the func, but telling why it ain't doing anything is helpful. - K_PlayHitEmSound(mobj); + if (victim && !victim->player) + return luaL_error(L, "K_PlayHitEmSound: mobj_t isn't a player object."); //Same as above + + K_PlayHitEmSound(mobj, victim); return 0; } diff --git a/src/p_inter.c b/src/p_inter.c index 054ff16a1..d22f99112 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1310,7 +1310,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } else { - P_PlayRinglossSound(toucher); + P_PlayRinglossSound(toucher, NULL); if (toucher->health > 10) toucher->health -= 10; else @@ -2206,7 +2206,7 @@ static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *sou } else if (target->health > 1) // Ring loss { - P_PlayRinglossSound(target); + P_PlayRinglossSound(target, source); P_PlayerRingBurst(player, player->mo->health - 1); } @@ -2351,7 +2351,7 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN } // Ring loss sound plays despite hitting spikes - P_PlayRinglossSound(player->mo); // Ringledingle! + P_PlayRinglossSound(player->mo, source); // Ringledingle! } /** Damages an object, which may or may not be a player. diff --git a/src/p_local.h b/src/p_local.h index e1a07526a..fed4a2d34 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -215,7 +215,7 @@ boolean P_PlayerMoving(INT32 pnum); void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range); void P_PlayLivesJingle(player_t *player); -void P_PlayRinglossSound(mobj_t *source); +void P_PlayRinglossSound(mobj_t *source, mobj_t *damager); void P_PlayDeathSound(mobj_t *source); void P_PlayVictorySound(mobj_t *source); diff --git a/src/p_mobj.c b/src/p_mobj.c index a0d80b413..a156edd43 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10639,6 +10639,8 @@ void P_SpawnPlayer(INT32 playernum) //P_DoPityCheck(p); p->grieftime = 0; + p->hitemtimer = 0; + p->hitemvictim = 255; if (G_BattleGametype()) // SRB2kart { diff --git a/src/p_spec.c b/src/p_spec.c index 79103fb03..69d27270b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3375,7 +3375,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers } else if (player->mo->health > 1) { - P_PlayRinglossSound(player->mo); + P_PlayRinglossSound(player->mo, NULL); if (player->mo->health > 10) player->mo->health -= 10; else diff --git a/src/p_user.c b/src/p_user.c index fa998013a..bdb03e86e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -590,11 +590,29 @@ void P_PlayLivesJingle(player_t *player) } } -void P_PlayRinglossSound(mobj_t *source) +void P_PlayRinglossSound(mobj_t *source, mobj_t *damager) { sfxenum_t key = P_RandomKey(2); if (cv_kartvoices.value) - S_StartSound(source, (mariomode) ? sfx_mario8 : sfx_khurt1 + key); + { + if (cv_karthitemdialog.value && source != damager && damager && damager->player && P_IsLocalPlayer(damager->player)) + { + sfxenum_t sfx = sfx_khurt1 + key; + + INT32 skinnum = -1; + + // I HATE LOCALSKINS! I HATE LOCALSKINS! :AAAAAAAAAA: + if (source->player) + skinnum = source->player->skinlocal ? (source->player->localskin - 1) : source->player->skin; + + if (skinnum >= 0) + sfx = (source->player->skinlocal ? localskins : skins)[skinnum].soundsid[SKSKPAN1 + key]; + + S_StartSound(NULL, sfx); + } + else + S_StartSound(source, (mariomode) ? sfx_mario8 : sfx_khurt1 + key); + } else S_StartSound(source, sfx_slip); } -- 2.54.0 From 89f0521cce99da08ee427915ca64c9854d92399d Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 10 Aug 2024 14:02:05 +0300 Subject: [PATCH 354/525] Oops forgot to change that Dunno if this function ever gets called for non-player objects but just in case --- src/k_kart.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 6f3b6c7c0..48297e9e2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1977,10 +1977,8 @@ void K_PlayHitEmSound(mobj_t *source, mobj_t *victim) { if (cv_kartvoices.value) { - if (cv_karthitemdialog.value && victim && victim->player) + if (cv_karthitemdialog.value && source->player && victim && victim->player) { - I_Assert(source->player != NULL); - source->player->hitemtimer = TICRATE/2; source->player->hitemvictim = victim->player - players; -- 2.54.0 From 02dcf85c46bf3ae23b930ad838781968ad51f872 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 11 Aug 2024 23:32:59 +0300 Subject: [PATCH 355/525] Prioritize display players when assigning delayed 'hit em' --- src/k_kart.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 48297e9e2..2ef1ffa68 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1973,19 +1973,33 @@ void K_PlayOvertakeSound(mobj_t *source) K_RegularVoiceTimers(source->player); } +static boolean K_SetDelayedHitEm(player_t *player, player_t *victim) +{ + player_t *prevvictim = NULL; + + if (player->hitemtimer) + prevvictim = &players[player->hitemvictim]; + + // We prioritize local players to hear "hit em" sfx + if (prevvictim && P_IsDisplayPlayer(prevvictim) && !P_IsDisplayPlayer(victim)) + return false; + + player->hitemtimer = TICRATE/2; + player->hitemvictim = victim - players; + + return true; +} + void K_PlayHitEmSound(mobj_t *source, mobj_t *victim) { if (cv_kartvoices.value) { - if (cv_karthitemdialog.value && source->player && victim && victim->player) - { - source->player->hitemtimer = TICRATE/2; - source->player->hitemvictim = victim->player - players; - + if (cv_karthitemdialog.value + && source->player && victim && victim->player + && K_SetDelayedHitEm(source->player, victim->player)) return; // Don't call K_RegularVoiceTimers yet, we didn't do any sound - } - else - S_StartSound(source, sfx_khitem); + + S_StartSound(source, sfx_khitem); } else S_StartSound(source, sfx_s1c9); // The only lost gameplay functionality with voices disabled -- 2.54.0 From 6fc2681b3427baf084746546f6c4e5151f537a2b Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 16 Aug 2024 01:50:50 +0300 Subject: [PATCH 356/525] Add 'Hit Em Delay' option in menu --- src/m_menu.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ab7e06b1b..f7f81e532 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1597,20 +1597,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, - {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, - - {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, - {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, - - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} -#else - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, - {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 70}, - - {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 85}, - {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 95}, + {IT_STRING|IT_CVAR, NULL, "Hit Em Delay", &cv_karthitemdialog, 95}, {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 105}, {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 115}, @@ -1619,6 +1606,21 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 135}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 145}, {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 165} +#else + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, + {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 70}, + + {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 85}, + {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 95}, + {IT_STRING|IT_CVAR, NULL, "Hit Em Delay", &cv_karthitemdialog, 105}, + {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 115}, + + {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 125}, + {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 135}, + + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 145}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 155}, + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 175} #endif }; @@ -1636,6 +1638,7 @@ static const char* OP_SoundTooltips[] = "Surround Sound.", "Chat notification sound.", "Frequency of character voice lines.", + "Play 'Hit Em' character line after other player's hurt line.", "Should the powerup warning be a sound effect or music?", "Testing sounds...", "Testing music...", -- 2.54.0 From 1959edf357b4d65fd8389950bcadaa1f844afe8b Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 16 Aug 2024 01:58:33 +0300 Subject: [PATCH 357/525] Always allow typing replay search query, similar to addon search --- src/m_menu.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index f7f81e532..53d53254d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6758,7 +6758,6 @@ I_mutex replayquerymutex; #define MAXREPLAYQUERY 40 char replayqueryinput[MAXREPLAYQUERY+1]; // The input typed size_t replayquerypos = 0; // Position in input window -boolean replayqueryopen = false; // Is query window open? size_t replayqueryfound = 0; // Number of checked replay entries size_t replayquerycheck = 0; // Index of next replay entry to check in demolist_all @@ -6818,7 +6817,6 @@ static void ResetReplayQuery(void) { memset(replayqueryinput, 0, MAXREPLAYQUERY); replayquerypos = 0; - replayqueryopen = false; replayqueryfound = 0; replayquerycheck = 0; @@ -6965,16 +6963,8 @@ void M_ReplayHut(INT32 choice) static boolean M_HandleReplayHutQuery(INT32 choice) { - if (!replayqueryopen) - return false; - switch (choice) { - case KEY_ENTER: - case KEY_ESCAPE: - replayqueryopen = false; - break; - case KEY_BACKSPACE: if (replayquerypos == 0) break; @@ -6988,7 +6978,7 @@ static boolean M_HandleReplayHutQuery(INT32 choice) dir_on[menudepthleft] = 0; PrepReplayList(false); - break; + return true; default: if (choice < 32 || choice > 127) @@ -7006,9 +6996,11 @@ static boolean M_HandleReplayHutQuery(INT32 choice) dir_on[menudepthleft] = 0; PrepReplayList(false); } + + return true; } - return true; + return false; } static void M_HandleReplayHutList(INT32 choice) @@ -7018,12 +7010,6 @@ static void M_HandleReplayHutList(INT32 choice) switch (choice) { - case '/': - case 'f': - case 'F': - replayqueryopen = true; - break; - case KEY_UPARROW: if (!replaynamesloaded) return; @@ -7442,13 +7428,13 @@ static void M_DrawReplayHut(void) // Draw search query M_DrawTextBoxFlags(x, 200 - 22, MAXREPLAYQUERY, 1, V_SNAPTOBOTTOM); - if (replayqueryopen || replayquerypos) + if (replayquerypos) V_DrawString(x + 8, 200 - 14, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, replayqueryinput); else - V_DrawString(x + 8, 200 - 14, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, "\x86Press '/' or 'f' to search replays"); + V_DrawString(x + 8, 200 - 14, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, "\x86Type to search..."); // draw text cursor for name - if (replayqueryopen && skullAnimCounter < 4) // blink cursor + if (replayquerypos && skullAnimCounter < 4) // blink cursor V_DrawCharacter(x + 8 + V_StringWidth(replayqueryinput, V_ALLOWLOWERCASE), 200 - 14, '_'|V_SNAPTOBOTTOM, false); if (replaynamesloaded && replayquerycheck < sizedirmenu) -- 2.54.0 From 6ab99218f2bb4c92d63a130d9f5fb6e1b56ad7bd Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 15:25:12 +0200 Subject: [PATCH 358/525] precalc fakecontrast on mapload --- src/hardware/hw_main.c | 32 +++++++++++--------------------- src/p_setup.c | 12 ++++++++++++ src/r_defs.h | 6 ++++++ src/r_segs.c | 38 +++++++++++++------------------------- 4 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 821233dc8..7cb10fb68 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -584,30 +584,20 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if return surfcolor.s.alpha; } -static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y) +// Lightnum = current light +// line = the seg to get the light offset from +static FUINT HWR_CalcWallLight(seg_t *line, FUINT lightnum) { INT16 finallight = lightnum; if (cv_grfakecontrast.value != 0) { - const UINT8 contrast = 8; fixed_t extralight = 0; if (cv_grfakecontrast.value == 2) // Smooth setting - { - extralight = (-(contrast<> FRACBITS; - } + extralight += line->hwLightOffset; else - { - if (v1y == v2y) - extralight = -contrast; - else if (v1x == v2x) - extralight = contrast; - } + extralight += line->lightOffset * 8; if (extralight != 0) { @@ -1096,7 +1086,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, fixed_t v2y = FloatToFixed(wallVerts[1].z); const UINT8 alpha = Surf->PolyColor.s.alpha; - FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y); + FUINT lightnum = HWR_CalcWallLight(gr_curline, sector->lightlevel); extracolormap_t *colormap = NULL; realtop = top = wallVerts[3].y; @@ -1135,13 +1125,13 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { lightnum = pfloor->master->frontsector->lightlevel; colormap = pfloor->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); + lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); } else { lightnum = *list[i].lightlevel; colormap = list[i].extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); + lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); } } @@ -1510,7 +1500,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = gr_frontsector->lightlevel; colormap = gr_frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); + lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); if (gr_linedef->flags & ML_TFERLINE) noencore = true; @@ -2133,7 +2123,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); + lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); @@ -2247,7 +2237,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); + lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); diff --git a/src/p_setup.c b/src/p_setup.c index c150a2f2f..449fcface 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -435,6 +435,7 @@ static void P_LoadRawSegs(UINT8 *data) mapseg_t *ml = (mapseg_t*)data; seg_t *li = segs; line_t *ldef; + fixed_t extralight = 0; size_t i; for (i = 0; i < numsegs; i++, li++, ml++) @@ -464,6 +465,17 @@ static void P_LoadRawSegs(UINT8 *data) li->numlights = 0; li->rlights = NULL; + + extralight = -(8*FRACUNIT) + + FixedDiv(AngleFixed(R_PointToAngle2(0, 0, + abs(li->v1->x - li->v2->x), + abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * 16; + + // Between -1 and 1 for software, -8 and 8 for hardware + li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; +#ifdef HWRENDER + li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; +#endif } } diff --git a/src/r_defs.h b/src/r_defs.h index fae341890..f9ab3578e 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -533,6 +533,12 @@ typedef struct seg_s r_lightlist_t *rlights; polyobj_t *polyseg; boolean dontrenderme; + + // Fake contrast calculated on level load + SINT8 lightOffset; +#ifdef HWRENDER + INT16 hwLightOffset; +#endif } seg_t; // diff --git a/src/r_segs.c b/src/r_segs.c index f5fdd782a..8c072bbe2 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -406,10 +406,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (rlight->extra_colormap && rlight->extra_colormap->fog) ; - else if (curline->v1->y == curline->v2->y) - lightnum--; - else if (curline->v1->x == curline->v2->x) - lightnum++; + else + lightnum += curline->lightOffset; rlight->lightnum = lightnum; } @@ -429,10 +427,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (colfunc == R_DrawFogColumn_8 || (frontsector->extra_colormap && frontsector->extra_colormap->fog)) ; - else if (curline->v1->y == curline->v2->y) - lightnum--; - else if (curline->v1->x == curline->v2->x) - lightnum++; + else + lightnum += curline->lightOffset; if (lightnum < 0) walllights = scalelight[0]; @@ -836,10 +832,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog)) ; - else if (curline->v1->y == curline->v2->y) - rlight->lightnum--; - else if (curline->v1->x == curline->v2->x) - rlight->lightnum++; + else + rlight->lightnum += curline->lightOffset; p++; } @@ -859,11 +853,10 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) lightnum = R_FakeFlat(frontsector, &tempsec, &templight, &templight, false) ->lightlevel >> LIGHTSEGSHIFT; - if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog)); - else if (curline->v1->y == curline->v2->y) - lightnum--; - else if (curline->v1->x == curline->v2->x) - lightnum++; + if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog)) + ; + else + lightnum += curline->lightOffset; if (lightnum < 0) walllights = scalelight[0]; @@ -1416,10 +1409,8 @@ static void R_RenderSegLoop (void) if (dc_lightlist[i].extra_colormap) ; - else if (curline->v1->y == curline->v2->y) - lightnum--; - else if (curline->v1->x == curline->v2->x) - lightnum++; + else + lightnum += curline->lightOffset; if (lightnum < 0) xwalllights = scalelight[0]; @@ -2440,10 +2431,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) // OPTIMIZE: get rid of LIGHTSEGSHIFT globally lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); - if (curline->v1->y == curline->v2->y) - lightnum--; - else if (curline->v1->x == curline->v2->x) - lightnum++; + lightnum += curline->lightOffset; if (lightnum < 0) walllights = scalelight[0]; -- 2.54.0 From 7d4b1d0852e90cf7f5a9237aaa6efa594e0a9aa8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 15:28:37 +0200 Subject: [PATCH 359/525] Update light offset on polyobjects when they rotate --- src/p_polyobj.c | 3 +++ src/p_setup.c | 30 ++++++++++++++++++++---------- src/p_setup.h | 1 + 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 9a3376595..a56753e98 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1415,7 +1415,10 @@ static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings) { // update seg angles (used only by renderer) for (i = 0; i < po->segCount; ++i) + { po->segs[i]->angle += delta; + P_UpdateSegLightOffset(po->segs[i]); + } // update polyobject's angle po->angle += delta; diff --git a/src/p_setup.c b/src/p_setup.c index 449fcface..512b4a0e5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -427,6 +427,25 @@ static inline float P_SegLengthFloat(seg_t *seg) } #endif +/** Updates the light offset + * + * \param li Seg to update the light offsets of + */ +void P_UpdateSegLightOffset(seg_t *li) +{ + fixed_t extralight = 0; + + extralight = -(8*FRACUNIT) + + FixedDiv(AngleFixed(R_PointToAngle2(0, 0, + abs(li->v1->x - li->v2->x), + abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * 16; + + // Between -1 and 1 for software, -8 and 8 for hardware + li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; +#ifdef HWRENDER + li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; +#endif +} // Loads the SEGS resource from a level. static void P_LoadRawSegs(UINT8 *data) @@ -466,16 +485,7 @@ static void P_LoadRawSegs(UINT8 *data) li->numlights = 0; li->rlights = NULL; - extralight = -(8*FRACUNIT) + - FixedDiv(AngleFixed(R_PointToAngle2(0, 0, - abs(li->v1->x - li->v2->x), - abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * 16; - - // Between -1 and 1 for software, -8 and 8 for hardware - li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; -#ifdef HWRENDER - li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; -#endif + P_UpdateSegLightOffset(li); } } diff --git a/src/p_setup.h b/src/p_setup.h index 8a77c690b..36f2089aa 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -88,6 +88,7 @@ SINT8 P_PartialAddGetStage(void); boolean P_RunSOC(const char *socfilename); void P_WriteThings(lumpnum_t lump); +void P_UpdateSegLightOffset(seg_t *li); size_t P_PrecacheLevelFlats(void); void P_AllocMapHeader(INT16 i); -- 2.54.0 From f10db3900aa1768d8b43d24d4cadbd89401bdd48 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 15:30:04 +0200 Subject: [PATCH 360/525] Use a const for the contrast --- src/p_setup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 512b4a0e5..f652e2031 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -433,15 +433,16 @@ static inline float P_SegLengthFloat(seg_t *seg) */ void P_UpdateSegLightOffset(seg_t *li) { + const UINT8 contrast = 8; fixed_t extralight = 0; - extralight = -(8*FRACUNIT) + + extralight = -((fixed_t)contrast*FRACUNIT) + FixedDiv(AngleFixed(R_PointToAngle2(0, 0, abs(li->v1->x - li->v2->x), - abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * 16; + abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * ((fixed_t)contrast * 2); - // Between -1 and 1 for software, -8 and 8 for hardware - li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; + // Between -2 and 2 for software, -8 and 8 for hardware + li->lightOffset = FixedFloor((extralight / contrast) + (FRACUNIT / 2)) / FRACUNIT; #ifdef HWRENDER li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; #endif @@ -454,7 +455,6 @@ static void P_LoadRawSegs(UINT8 *data) mapseg_t *ml = (mapseg_t*)data; seg_t *li = segs; line_t *ldef; - fixed_t extralight = 0; size_t i; for (i = 0; i < numsegs; i++, li++, ml++) -- 2.54.0 From bab96b73e0765905b7abc42618991c0cbb409dc7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 15:37:24 +0200 Subject: [PATCH 361/525] smol changes --- src/hardware/hw_main.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7cb10fb68..16d15078e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -584,20 +584,18 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if return surfcolor.s.alpha; } -// Lightnum = current light -// line = the seg to get the light offset from -static FUINT HWR_CalcWallLight(seg_t *line, FUINT lightnum) +static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg) { INT16 finallight = lightnum; - if (cv_grfakecontrast.value != 0) + if (seg != NULL && cv_grfakecontrast.value != 0) { fixed_t extralight = 0; if (cv_grfakecontrast.value == 2) // Smooth setting - extralight += line->hwLightOffset; + extralight += seg->hwLightOffset; else - extralight += line->lightOffset * 8; + extralight += seg->lightOffset * 8; if (extralight != 0) { @@ -1086,7 +1084,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, fixed_t v2y = FloatToFixed(wallVerts[1].z); const UINT8 alpha = Surf->PolyColor.s.alpha; - FUINT lightnum = HWR_CalcWallLight(gr_curline, sector->lightlevel); + FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, gr_curline); extracolormap_t *colormap = NULL; realtop = top = wallVerts[3].y; @@ -1125,13 +1123,13 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { lightnum = pfloor->master->frontsector->lightlevel; colormap = pfloor->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); } else { lightnum = *list[i].lightlevel; colormap = list[i].extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); } } @@ -1500,7 +1498,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = gr_frontsector->lightlevel; colormap = gr_frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); if (gr_linedef->flags & ML_TFERLINE) noencore = true; @@ -2123,7 +2121,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); @@ -2237,7 +2235,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(gr_curline, lightnum); + lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); -- 2.54.0 From 87176cfd0bb0ee597c29f9c69822dc50a6ca68c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 15:55:39 +0200 Subject: [PATCH 362/525] better slope light --- src/hardware/hw_main.c | 27 +++++------------------ src/p_slopes.c | 50 ++++++++++++++++++++++++++++++++++++++---- src/r_defs.h | 6 +++++ src/r_plane.c | 5 +++++ 4 files changed, 62 insertions(+), 26 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 16d15078e..8223f7527 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -607,35 +607,18 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg) return (FUINT)finallight; } -static FUINT HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta) +static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope) { INT16 finallight = lightnum; - if (cv_grfakecontrast.value != 0 && cv_grslopecontrast.value != 0) + if (slope != NULL && cv_grfakecontrast.value != 0 && cv_grslopecontrast.value != 0) { - const UINT8 contrast = 8; fixed_t extralight = 0; if (cv_grfakecontrast.value == 2) // Smooth setting - { - fixed_t dirmul = abs(FixedDiv(AngleFixed(dir) - (180<> FRACBITS; - } + extralight += slope->hwLightOffset; else - { - dir = ((dir + ANGLE_45) / ANGLE_90) * ANGLE_90; - - if (dir == ANGLE_180) - extralight = -contrast; - else if (dir == 0) - extralight = contrast; - - if (delta >= FRACUNIT/2) - extralight *= 2; - } + extralight += slope->lightOffset * 8; if (extralight != 0) { @@ -826,7 +809,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc SETUP3DVERT(v3d, pv->x, pv->y); if (slope) - lightlevel = HWR_CalcSlopeLight(lightlevel, R_PointToAngle2(0, 0, slope->normal.x, slope->normal.y), abs(slope->zdelta)); + lightlevel = HWR_CalcSlopeLight(lightlevel, slope); HWR_Lighting(&Surf, lightlevel, planecolormap); diff --git a/src/p_slopes.c b/src/p_slopes.c index 112ba008b..52bb914ec 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -27,11 +27,47 @@ static pslope_t *slopelist = NULL; static UINT16 slopecount = 0; +// Calculate light +static void P_UpdateSlopeLightOffset(pslope_t *slope) +{ + const boolean ceiling = (slope->normal.z < 0); + const UINT8 contrast = 8; + + fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT; + fixed_t zMul = FRACUNIT; + angle_t slopeDir = ANGLE_MAX; + fixed_t extralight = 0; + + if (slope->normal.z == 0) + { + slope->lightOffset = slope->hwLightOffset = 0; + return; + } + + slopeDir = R_PointToAngle2(0, 0, abs(slope->normal.y), abs(slope->normal.x)); + if (ceiling == true) + { + slopeDir ^= ANGLE_180; + } + + zMul = min(FRACUNIT, abs(slope->zdelta)*3/2); // *3/2, to make 60 degree slopes match walls. + contrastFixed = FixedMul(contrastFixed, zMul); + extralight = -contrastFixed + FixedMul(FixedDiv(AngleFixed(slopeDir), 90*FRACUNIT), (contrastFixed * 2)); + + // Between -2 and 2 for software, -8 and 8 for hardware + slope->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; +#ifdef HWRENDER + slope->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; +#endif +} + // Calculate line normal void P_CalculateSlopeNormal(pslope_t *slope) { slope->normal.z = FINECOSINE(slope->zangle>>ANGLETOFINESHIFT); slope->normal.x = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), -slope->d.x); slope->normal.y = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), -slope->d.y); + + P_UpdateSlopeLightOffset(slope); } // With a vertex slope that has its vertices set, configure relevant slope info @@ -89,14 +125,19 @@ static void P_ReconfigureVertexSlope(pslope_t *slope) slope->real_xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180; slope->real_zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta)); - if (slope->normal.x == 0 && slope->normal.y == 0) { // Set some defaults for a non-sloped "slope" + if (slope->normal.x == 0 && slope->normal.y == 0) // Set some defaults for a non-sloped "slope" + { slope->zangle = slope->xydirection = 0; slope->zdelta = slope->d.x = slope->d.y = 0; - } else { + } + else + { slope->extent = extent; slope->xydirection = slope->real_xydirection; slope->zangle = slope->real_zangle; } + + P_UpdateSlopeLightOffset(slope); } // Recalculate dynamic slopes @@ -369,7 +410,8 @@ void P_SpawnSlope_Line(int linenum) P_CalculateSlopeNormal(fslope); } - if(frontceil) + + if (frontceil) { fixed_t highest, lowest; size_t l; @@ -934,4 +976,4 @@ void P_ButteredSlope(mobj_t *mo) P_Thrust(mo, mo->standingslope->xydirection, thrust); } -// EOF \ No newline at end of file +// EOF diff --git a/src/r_defs.h b/src/r_defs.h index f9ab3578e..2de7985e8 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -257,6 +257,12 @@ typedef struct pslope_s mapthing_t **vertices; // List should be three long for slopes made by vertex things, or one long for slopes using one vertex thing to anchor struct pslope_s *next; // Make a linked list of dynamic slopes, for easy reference later + + // Light offsets (see seg_t) + SINT8 lightOffset; +#ifdef HWRENDER + INT16 hwLightOffset; +#endif } pslope_t; typedef enum diff --git a/src/r_plane.c b/src/r_plane.c index 9ea06a277..8e98d9c32 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -419,6 +419,11 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, } } + if (slope != NULL) + { + lightlevel += (slope->lightOffset / 8); + } + // This appears to fix the Nimbus Ruins sky bug. if (picnum == skyflatnum && pfloor) { -- 2.54.0 From 164d7399d248e3512f66f0b84287d66db28a0bf7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 16:31:04 +0200 Subject: [PATCH 363/525] smol fix to slope light --- src/p_setup.c | 8 ++++---- src/p_slopes.c | 2 +- src/r_plane.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index f652e2031..c03dea812 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -434,12 +434,12 @@ static inline float P_SegLengthFloat(seg_t *seg) void P_UpdateSegLightOffset(seg_t *li) { const UINT8 contrast = 8; + const fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT; + fixed_t light = FRACUNIT; fixed_t extralight = 0; - extralight = -((fixed_t)contrast*FRACUNIT) + - FixedDiv(AngleFixed(R_PointToAngle2(0, 0, - abs(li->v1->x - li->v2->x), - abs(li->v1->y - li->v2->y))), 90*FRACUNIT) * ((fixed_t)contrast * 2); + light = FixedDiv(R_PointToAngle2(0, 0, abs(li->v1->x - li->v2->x), abs(li->v1->y - li->v2->y)), ANGLE_90); + extralight = -contrastFixed + FixedMul(light, contrastFixed * 2); // Between -2 and 2 for software, -8 and 8 for hardware li->lightOffset = FixedFloor((extralight / contrast) + (FRACUNIT / 2)) / FRACUNIT; diff --git a/src/p_slopes.c b/src/p_slopes.c index 52bb914ec..2b52d6153 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -52,7 +52,7 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) zMul = min(FRACUNIT, abs(slope->zdelta)*3/2); // *3/2, to make 60 degree slopes match walls. contrastFixed = FixedMul(contrastFixed, zMul); - extralight = -contrastFixed + FixedMul(FixedDiv(AngleFixed(slopeDir), 90*FRACUNIT), (contrastFixed * 2)); + extralight = -contrastFixed + FixedMul(FixedDiv(AngleFixed(slopeDir), ANGLE_90), (contrastFixed * 2)); // Between -2 and 2 for software, -8 and 8 for hardware slope->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; diff --git a/src/r_plane.c b/src/r_plane.c index 8e98d9c32..3e202993a 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -421,7 +421,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, if (slope != NULL) { - lightlevel += (slope->lightOffset / 8); + lightlevel += slope->lightOffset * 8; } // This appears to fix the Nimbus Ruins sky bug. -- 2.54.0 From b432491d34fe552ce81d7183d5b5e62e73dc0e17 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 19:54:56 +0200 Subject: [PATCH 364/525] throw saturnpacket and join stuff behind "SATURNPAK" ifdef, disable it for now --- src/d_clisrv.c | 26 ++++++++++++++++++++++++++ src/d_clisrv.h | 10 +++++++++- src/d_net.c | 2 ++ src/d_netcmd.c | 2 ++ src/doomdef.h | 4 ++++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a9d121997..ef1076b3b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -146,8 +146,10 @@ static boolean cl_packetmissed; static UINT8 mynode; // my address pointofview server static boolean cl_redownloadinggamestate = false; +#ifdef SATURNPAK boolean is_client_saturn[MAXNETNODES]; #define ISSATURN 69 +#endif static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen @@ -1443,7 +1445,9 @@ static boolean CL_SendJoin(void) netbuffer->u.clientcfg.subversion = SUBVERSION; strncpy(netbuffer->u.clientcfg.application, SRB2APPLICATION, sizeof netbuffer->u.clientcfg.application); +#ifdef SATURNPAK netbuffer->u.clientcfg.issaturn = ISSATURN; +#endif return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak)); } @@ -3201,7 +3205,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) SV_InitResynchVars(node); // If a resynch was in progress, well, it no longer needs to be. nodeingame[node] = false; +#ifdef SATURNPAK is_client_saturn[node] = false; +#endif can_receive_gamestate[node] = false; Net_CloseConnection(node); ResetNode(node); @@ -3308,7 +3314,9 @@ void CL_Reset(void) if (servernode > 0 && servernode < MAXNETNODES) { nodeingame[(UINT8)servernode] = false; +#ifdef SATURNPAK is_client_saturn[(UINT8)servernode] = false; +#endif Net_CloseConnection(servernode); } D_CloseConnection(); // netgame = false @@ -4041,7 +4049,9 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; +#ifdef SATURNPAK consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE|CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +#endif #ifdef VANILLAJOINNEXTROUND consvar_t cv_joinnextround = {"joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done @@ -4088,11 +4098,13 @@ static void Joinable_OnChange(void) if (!server) return; +#ifdef SATURNPAK // disabling joins should also disable saturn joins unless its called with CV_StealthSet and vice versa to make life a bit easier if (!cv_allownewplayer.value) CV_Set(&cv_allownewsaturnplayer, "Off"); else if (cv_allownewplayer.value) CV_Set(&cv_allownewsaturnplayer, "On"); +#endif maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); @@ -4175,7 +4187,9 @@ static void ResetNode(INT32 node) bannednode[node].timeleft = NO_BAN_TIME; // SATURN +#ifdef SATURNPAK is_client_saturn[node] = false; +#endif resendingsavegame[node] = false; can_receive_gamestate[node] = false; @@ -4510,11 +4524,13 @@ static boolean SV_AddWaitingPlayers(void) return newplayer; } +#ifdef SATURNPAK static inline void SendSaturnInfo(INT32 node) { netbuffer->packettype = PT_ISSATURN; HSendPacket(node, true, 0, 0); } +#endif void CL_AddSplitscreenPlayer(void) { @@ -4701,7 +4717,11 @@ static void HandleConnect(SINT8 node) { SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION)); } +#ifdef SATURNPAK else if ((!cv_allownewplayer.value && node && netbuffer->u.clientcfg.issaturn != ISSATURN) || (!cv_allownewsaturnplayer.value && node && netbuffer->u.clientcfg.issaturn == ISSATURN)) +#else + else if (!cv_allownewplayer.value && node) +#endif { SV_SendRefuse(node, M_GetText(cv_joinrefusemessage.string)); } @@ -5062,7 +5082,9 @@ static void HandlePacketFromAwayNode(SINT8 node) #endif DEBFILE(va("Server accept join gametic=%u mynode=%d\n", gametic, mynode)); +#ifdef SATURNPAK SendSaturnInfo(node); +#endif memset(playeringame, 0, sizeof(playeringame)); for (j = 0; j < MAXPLAYERS; j++) @@ -5490,7 +5512,9 @@ static void HandlePacketFromPlayer(SINT8 node) } Net_CloseConnection(node); nodeingame[node] = false; +#ifdef SATURNPAK is_client_saturn[node] = false; +#endif can_receive_gamestate[node] = false; break; // -------------------------------------------- CLIENT RECEIVE ---------- @@ -5655,10 +5679,12 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) Got_Filetxpak(); break; +#ifdef SATURNPAK case PT_ISSATURN: //CONS_Printf("hi im on saturn\n"); is_client_saturn[node] = true; break; +#endif case PT_CANRECEIVEGAMESTATE: can_receive_gamestate[node] = true; PT_CanReceiveGamestate(node); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 535485672..37a828788 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -99,7 +99,9 @@ typedef enum PT_PING, // Packet sent to tell clients the other client's latency to server. +#ifdef SATURNPAK PT_ISSATURN, +#endif PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again! @@ -369,7 +371,9 @@ typedef struct UINT8 subversion; // Contains build version UINT8 localplayers; // number of splitscreen players UINT8 mode; +#ifdef SATURNPAK UINT8 issaturn; +#endif } ATTRPACK clientconfig_pak; #define SV_SPEEDMASK 0x03 // used to send kartspeed @@ -574,7 +578,11 @@ extern consvar_t #ifdef VANILLAJOINNEXTROUND cv_joinnextround, #endif - cv_netticbuffer, cv_allownewplayer, cv_allownewsaturnplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_netticbuffer, cv_allownewplayer, +#ifdef SATURNPAK + cv_allownewsaturnplayer, +#endif + cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; extern consvar_t cv_connectawaittime; diff --git a/src/d_net.c b/src/d_net.c index 312e90caa..2f60eb3d4 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -834,7 +834,9 @@ const char *packettypename[NUMPACKETTYPE] = "PING", +#ifdef SATURNPAK "ISSATURN", +#endif "WILLRESENDGAMESTATE", "CANRECEIVEGAMESTATE", diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b69a5b437..a81b6d1bf 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -795,7 +795,9 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); +#ifdef SATURNPAK CV_RegisterVar(&cv_allownewsaturnplayer); +#endif CV_RegisterVar(&cv_joinrefusemessage); CV_RegisterVar(&cv_chatlogsize); #ifdef VANILLAJOINNEXTROUND diff --git a/src/doomdef.h b/src/doomdef.h index 3540c3f4a..37e553816 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -568,6 +568,10 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! +/// Server detection for if a connecting client is on Saturn. +/// For stuff like extra synching, joinblock, etc. +//#define SATURNPAK + /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -- 2.54.0 From daf8151a322b15809ecd2dcc84bd6adcf528178d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 19:56:14 +0200 Subject: [PATCH 365/525] Revert "Do not access memory on misaligned addresses" This reverts commit 112716dae58ee75794948f456241795308ef3c26. --- src/byteptr.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/byteptr.h b/src/byteptr.h index 0b3935e63..9756e7d95 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -11,12 +11,17 @@ /// \brief Macros to read/write from/to a UINT8 *, /// used for packet creation and such +#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__) +#define DEALIGNED +#endif + #include "endian.h" #ifndef SRB2_BIG_ENDIAN // // Little-endian machines // +#ifdef DEALIGNED #define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0) @@ -26,8 +31,20 @@ #define WRITECHAR(p,b) do { char *p_tmp = (void *)p; const char tv = ( char)(b); memcpy(p, &tv, sizeof( char)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEFIXED(p,b) do { fixed_t *p_tmp = (void *)p; const fixed_t tv = (fixed_t)(b); memcpy(p, &tv, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEANGLE(p,b) do { angle_t *p_tmp = (void *)p; const angle_t tv = (angle_t)(b); memcpy(p, &tv, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; } while (0) +#else +#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITECHAR(p,b) do { char *p_tmp = ( char *)p; *p_tmp = ( char)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEFIXED(p,b) do { fixed_t *p_tmp = (fixed_t *)p; *p_tmp = (fixed_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEANGLE(p,b) do { angle_t *p_tmp = (angle_t *)p; *p_tmp = (angle_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#endif #ifdef __GNUC__ +#ifdef DEALIGNED #define READUINT8(p) ({ UINT8 *p_tmp = (void *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READSINT8(p) ({ SINT8 *p_tmp = (void *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READINT16(p) ({ INT16 *p_tmp = (void *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; b; }) @@ -38,6 +55,17 @@ #define READFIXED(p) ({ fixed_t *p_tmp = (void *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; b; }) #define READANGLE(p) ({ angle_t *p_tmp = (void *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; b; }) #else +#define READUINT8(p) ({ UINT8 *p_tmp = ( UINT8 *)p; UINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READSINT8(p) ({ SINT8 *p_tmp = ( SINT8 *)p; SINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT16(p) ({ INT16 *p_tmp = ( INT16 *)p; INT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT16(p) ({ UINT16 *p_tmp = ( UINT16 *)p; UINT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT32(p) ({ INT32 *p_tmp = ( INT32 *)p; INT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT32(p) ({ UINT32 *p_tmp = ( UINT32 *)p; UINT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READCHAR(p) ({ char *p_tmp = ( char *)p; char b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#endif +#else #define READUINT8(p) *(( UINT8 *)p)++ #define READSINT8(p) *(( SINT8 *)p)++ #define READINT16(p) *(( INT16 *)p)++ @@ -120,6 +148,8 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = readulong(p); p_tmp++; p = (void *)p_tmp; b; }) #endif //SRB2_BIG_ENDIAN +#undef DEALIGNED + #define WRITESTRINGN(p, s, n) ({ \ size_t tmp_i; \ \ -- 2.54.0 From d24bcc9fd700c11842ec917b411093922eb386b9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 20:01:46 +0200 Subject: [PATCH 366/525] fix NOHW compile --- src/p_slopes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 2b52d6153..38201ad86 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -40,7 +40,11 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) if (slope->normal.z == 0) { - slope->lightOffset = slope->hwLightOffset = 0; + + slope->lightOffset = 0; +#ifdef HWRENDER + slope->hwLightOffset = 0; +#endif return; } -- 2.54.0 From f36ac0bb4bf6dee24b1e5640856e81f381631c45 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 20:03:35 +0200 Subject: [PATCH 367/525] this should not be in HWRENDER ifdef --- src/m_menu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 52955f1c5..897016b2b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5341,6 +5341,7 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } +#endif if (currentMenu == &OP_ExpOptionsDef) { @@ -5351,7 +5352,7 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } -#endif + if (currentMenu == &OP_SaturnDef) { -- 2.54.0 From fe7677c5c87a59079239225f96bbfca16831feb8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 19:56:14 +0200 Subject: [PATCH 368/525] Revert "Do not access memory on misaligned addresses" This reverts commit 112716dae58ee75794948f456241795308ef3c26. --- src/byteptr.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/byteptr.h b/src/byteptr.h index 0b3935e63..9756e7d95 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -11,12 +11,17 @@ /// \brief Macros to read/write from/to a UINT8 *, /// used for packet creation and such +#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__) +#define DEALIGNED +#endif + #include "endian.h" #ifndef SRB2_BIG_ENDIAN // // Little-endian machines // +#ifdef DEALIGNED #define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0) @@ -26,8 +31,20 @@ #define WRITECHAR(p,b) do { char *p_tmp = (void *)p; const char tv = ( char)(b); memcpy(p, &tv, sizeof( char)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEFIXED(p,b) do { fixed_t *p_tmp = (void *)p; const fixed_t tv = (fixed_t)(b); memcpy(p, &tv, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEANGLE(p,b) do { angle_t *p_tmp = (void *)p; const angle_t tv = (angle_t)(b); memcpy(p, &tv, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; } while (0) +#else +#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITECHAR(p,b) do { char *p_tmp = ( char *)p; *p_tmp = ( char)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEFIXED(p,b) do { fixed_t *p_tmp = (fixed_t *)p; *p_tmp = (fixed_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEANGLE(p,b) do { angle_t *p_tmp = (angle_t *)p; *p_tmp = (angle_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#endif #ifdef __GNUC__ +#ifdef DEALIGNED #define READUINT8(p) ({ UINT8 *p_tmp = (void *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READSINT8(p) ({ SINT8 *p_tmp = (void *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READINT16(p) ({ INT16 *p_tmp = (void *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; b; }) @@ -38,6 +55,17 @@ #define READFIXED(p) ({ fixed_t *p_tmp = (void *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; b; }) #define READANGLE(p) ({ angle_t *p_tmp = (void *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; b; }) #else +#define READUINT8(p) ({ UINT8 *p_tmp = ( UINT8 *)p; UINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READSINT8(p) ({ SINT8 *p_tmp = ( SINT8 *)p; SINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT16(p) ({ INT16 *p_tmp = ( INT16 *)p; INT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT16(p) ({ UINT16 *p_tmp = ( UINT16 *)p; UINT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT32(p) ({ INT32 *p_tmp = ( INT32 *)p; INT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT32(p) ({ UINT32 *p_tmp = ( UINT32 *)p; UINT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READCHAR(p) ({ char *p_tmp = ( char *)p; char b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#endif +#else #define READUINT8(p) *(( UINT8 *)p)++ #define READSINT8(p) *(( SINT8 *)p)++ #define READINT16(p) *(( INT16 *)p)++ @@ -120,6 +148,8 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = readulong(p); p_tmp++; p = (void *)p_tmp; b; }) #endif //SRB2_BIG_ENDIAN +#undef DEALIGNED + #define WRITESTRINGN(p, s, n) ({ \ size_t tmp_i; \ \ -- 2.54.0 From d5388e8dadba16cd81b4f4f1c1440cac29bf0240 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 20:01:46 +0200 Subject: [PATCH 369/525] fix NOHW compile --- src/p_slopes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 2b52d6153..38201ad86 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -40,7 +40,11 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) if (slope->normal.z == 0) { - slope->lightOffset = slope->hwLightOffset = 0; + + slope->lightOffset = 0; +#ifdef HWRENDER + slope->hwLightOffset = 0; +#endif return; } -- 2.54.0 From 87a2b74a88fbec2933c607c3012c9c11f8a88f33 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 20:03:35 +0200 Subject: [PATCH 370/525] this should not be in HWRENDER ifdef --- src/m_menu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 53d53254d..e9b8120a3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5337,6 +5337,7 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } +#endif if (currentMenu == &OP_ExpOptionsDef) { @@ -5347,7 +5348,7 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } -#endif + if (currentMenu == &OP_SaturnDef) { -- 2.54.0 From 9d359ef8c5d07ad6693c28aec8e79665e68f2658 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 18 Aug 2024 20:46:07 +0200 Subject: [PATCH 371/525] use qsort instead of qs22j for vissprite sorting seems to be actually faster in this case --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8223f7527..5c35dd8f6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4241,7 +4241,7 @@ static void HWR_SortVisSprites(void) gr_vsprorder[i] = HWR_GetVisSprite(i); } - qs22j(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); + qsort(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites); } // A drawnode is something that points to a 3D floor, 3D side, or masked -- 2.54.0 From b2129011c2f61c6f4415785454dd163151a90550 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 19 Aug 2024 01:17:13 -0400 Subject: [PATCH 372/525] Fix gamepad menus for green reses via scrolling --- src/m_menu.c | 136 +++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e9b8120a3..039a88cf1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1214,89 +1214,89 @@ static menuitem_t OP_AllControlsMenu[] = static menuitem_t OP_Joystick1Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis , 30}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis , 40}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis , 50}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis , 60}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis , 70}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis , 80}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis , 90}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis , 130}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone , 140}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone , 150}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis , 25}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis , 30}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis , 35}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis , 40}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis , 45}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis , 50}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis , 70}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone , 75}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone , 80}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 170}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 180}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 190}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 90}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 95}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 100}, }; static menuitem_t OP_Joystick2Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis2 , 30}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis2 , 40}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis2 , 50}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis2 , 60}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis2 , 70}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis2 , 80}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis2 , 90}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis2 , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis2 , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis2 , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis2 , 130}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone2 , 140}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone2 , 150}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis2 , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis2 , 25}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis2 , 30}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis2 , 35}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis2 , 40}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis2 , 45}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis2 , 50}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis2 , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis2 , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis2 , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis2 , 70}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone2 , 75}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone2 , 80}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 170}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 180}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 190}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 90}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 95}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 100}, }; static menuitem_t OP_Joystick3Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis3 , 30}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis3 , 40}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis3 , 50}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis3 , 60}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis3 , 70}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis3 , 80}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis3 , 90}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis3 , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis3 , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis3 , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis3 , 130}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone3 , 140}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone3 , 150}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis3 , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis3 , 25}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis3 , 30}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis3 , 35}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis3 , 40}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis3 , 45}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis3 , 50}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis3 , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis3 , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis3 , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis3 , 70}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone3 , 75}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone3 , 80}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 170}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 180}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 190}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 90}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 95}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 100}, }; static menuitem_t OP_Joystick4Menu[] = { {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis4 , 30}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis4 , 40}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis4 , 50}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis4 , 60}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis4 , 70}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis4 , 80}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis4 , 90}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis4 , 100}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis4 , 110}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis4 , 120}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis4 , 130}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone4 , 140}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone4 , 150}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis4 , 20}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis4 , 25}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis4 , 30}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis4 , 35}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis4 , 40}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis4 , 45}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis4 , 50}, + {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis4 , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis4 , 60}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis4 , 65}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis4 , 70}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone4 , 75}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone4 , 80}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 170}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 180}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 190}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 90}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 95}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 100}, }; static menuitem_t OP_JoystickSetMenu[] = @@ -2823,10 +2823,10 @@ menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDe //WTF menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30); menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef); -menu_t OP_Joystick1Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 60, 16); -menu_t OP_Joystick2Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 60, 16); -menu_t OP_Joystick3Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 60, 16); -menu_t OP_Joystick4Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 60, 16); +menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 60, 36); +menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 60, 36); +menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 60, 36); +menu_t OP_Joystick4Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 60, 36); menu_t OP_JoystickSetDef = { "M_CONTRO", -- 2.54.0 From 84a1f86037f8628ff3c229fe07f171533e3c54f6 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 19 Aug 2024 01:24:04 -0400 Subject: [PATCH 373/525] Allow the control binds menu to use lower case --- src/m_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 039a88cf1..677489efc 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12452,7 +12452,7 @@ static void M_DrawControl(void) if (currentMenu->menuitems[i].status == IT_CONTROL) { - V_DrawString(x, y, ((i == itemOn) ? highlightflags : 0), currentMenu->menuitems[i].text); + V_DrawString(x, y, ((i == itemOn) ? highlightflags|V_ALLOWLOWERCASE : V_ALLOWLOWERCASE), currentMenu->menuitems[i].text); keys[0] = setupcontrols[currentMenu->menuitems[i].alphaKey][0]; keys[1] = setupcontrols[currentMenu->menuitems[i].alphaKey][1]; @@ -12473,14 +12473,14 @@ static void M_DrawControl(void) strcat (tmp, G_KeynumToString (keys[1])); } - V_DrawRightAlignedString(BASEVIDWIDTH-currentMenu->x, y, highlightflags, tmp); + V_DrawRightAlignedString(BASEVIDWIDTH-currentMenu->x, y, highlightflags|V_ALLOWLOWERCASE, tmp); } /*else if (currentMenu->menuitems[i].status == IT_GRAYEDOUT2) V_DrawString(x, y, V_TRANSLUCENT, currentMenu->menuitems[i].text);*/ else if ((currentMenu->menuitems[i].status == IT_HEADER) && (i != max-1)) - V_DrawString(19, y+6, highlightflags, currentMenu->menuitems[i].text); + V_DrawString(19, y+6, highlightflags|V_ALLOWLOWERCASE, currentMenu->menuitems[i].text); else if (currentMenu->menuitems[i].status & IT_STRING) - V_DrawString(x, y, ((i == itemOn) ? highlightflags : 0), currentMenu->menuitems[i].text); + V_DrawString(x, y, ((i == itemOn) ? highlightflags|V_ALLOWLOWERCASE : V_ALLOWLOWERCASE), currentMenu->menuitems[i].text); y += SMALLLINEHEIGHT; } -- 2.54.0 From 707448193b453f4751737adbe12de1434d1523c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 11:52:14 +0200 Subject: [PATCH 374/525] Fix some tooltips so they don't go offscreen grr git not crediting neppy for some reason --- src/m_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 677489efc..2f76c53ef 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1505,7 +1505,7 @@ static const char* OP_ExpTooltips[] = #ifdef HWRENDER "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.", #ifdef USE_FBO_OGL - "Allows the game to downsample from a higher resolution than your display in OpenGL renderer mode\nrequires a GPU with atleast OpenGL 3.0 support.", + "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode requires a GPU with atleast OpenGL 3.0 support.", #endif "Change the depth of the Palette in Palette rendering mod\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", "Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.", @@ -1605,7 +1605,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 135}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 145}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 165} + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} #else {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 70}, @@ -1620,7 +1620,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 145}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 155}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 175} + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 165} #endif }; @@ -2086,7 +2086,7 @@ static const char* OP_SaturnTooltips[] = "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Enable colourized hud.", "Enable the colourized itembox when colourized hud is enabled.", - "The color to use instead of the player color when colourized hud is enabled.", + "The color to use instead of the player color when\ncolourized hud is enabled.", "Show the big 'LAP' text on a lap change.", "Show player names on the minimap.", "Minimize the player icons on the minimap.", -- 2.54.0 From fcc5c132748a16a65bd67379460814395380cd1b Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:28:46 -0400 Subject: [PATCH 375/525] Fix Compile without with out of date SDL --- src/sdl/i_system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index eabe017c4..66ce038f5 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2670,8 +2670,8 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, { #if !(SDL_VERSION_ATLEAST(2,0,14)) (void)device_id; - (void)left_strength; - (void)right_strength; + (void)low_strength; + (void)high_strength; #else I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher -- 2.54.0 From cfebe422d3d1fa349c0edd257ff8842649f1ceff Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 12:00:27 +0200 Subject: [PATCH 376/525] Fix typo --- src/m_menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 2f76c53ef..b7829fe31 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1505,9 +1505,9 @@ static const char* OP_ExpTooltips[] = #ifdef HWRENDER "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.", #ifdef USE_FBO_OGL - "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode requires a GPU with atleast OpenGL 3.0 support.", + "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode. Requires a GPU with atleast OpenGL 3.0 support.", #endif - "Change the depth of the Palette in Palette rendering mod\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", + "Change the depth of the Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", "Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.", #endif }; -- 2.54.0 From 54d897fc33d6a9bc10ad076ccb7e5131e9cac87f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 12:15:47 +0200 Subject: [PATCH 377/525] smol i_video cleanup --- src/sdl/i_video.c | 120 ++++++++++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 46 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index da055265e..258c34898 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -225,7 +225,7 @@ void RefreshOGLSDLSurface(void) } #endif -static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) +static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool reposition) { static SDL_bool wasfullscreen = SDL_FALSE; Uint32 rmask; @@ -254,16 +254,18 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) } // Reposition window only in windowed mode SDL_SetWindowSize(window, width, height); - SDL_SetWindowPosition(window, - SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), - SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) - ); + if (reposition) + { + SDL_SetWindowPosition(window, + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) + ); + } } } else { Impl_CreateWindow(fullscreen); - Impl_SetWindowIcon(); wasfullscreen = fullscreen; SDL_SetWindowSize(window, width, height); if (fullscreen) @@ -1942,7 +1944,7 @@ INT32 VID_SetMode(INT32 modeNum) I_DownSample(); #endif - SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); + SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, (setmodeneeded ? SDL_TRUE : SDL_FALSE)); Impl_VideoSetupBuffer(); if (rendermode == render_soft) @@ -1962,6 +1964,63 @@ INT32 VID_SetMode(INT32 modeNum) return SDL_TRUE; } + +static SDL_bool Impl_CreateContext(void) +{ + // Renderer-specific stuff +#ifdef HWRENDER + if ((rendermode == render_opengl) + && (vid.glstate != VID_GL_LIBRARY_ERROR)) + { + if (!sdlglcontext) + sdlglcontext = SDL_GL_CreateContext(window); + if (sdlglcontext == NULL) + { + SDL_DestroyWindow(window); + I_Error("Failed to create a GL context: %s\n", SDL_GetError()); + } + SDL_GL_MakeCurrent(window, sdlglcontext); + } + else +#endif + if (rendermode == render_soft) + { + int flags = 0; // Use this to set SDL_RENDERER_* flags now + if (usesdl2soft) + flags |= SDL_RENDERER_SOFTWARE; + else if (cv_vidwait.value) + { +#if SDL_VERSION_ATLEAST(2, 0, 18) + // If SDL is new enough, we can turn off vsync later. + flags |= SDL_RENDERER_PRESENTVSYNC; +#else + // However, if it isn't, we should just silently turn vid_wait off + // This is because the renderer will be created before the config + // is read and vid_wait is set from the user's preferences, and thus + // vid_wait will have no effect. + CV_StealthSetValue(&cv_vidwait, 0); +#endif + } + +#ifdef _WIN32 + SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d11"); +#else + SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); +#endif + + if (!renderer) + renderer = SDL_CreateRenderer(window, -1, flags); + if (renderer == NULL) + { + CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError()); + return SDL_FALSE; + } + SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT); + } + + return SDL_TRUE; +} + static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) { int flags = 0; @@ -2009,45 +2068,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) return SDL_FALSE; } - // Renderer-specific stuff -#ifdef HWRENDER - if ((rendermode == render_opengl) - && (vid.glstate != VID_GL_LIBRARY_ERROR)) - { - sdlglcontext = SDL_GL_CreateContext(window); - if (sdlglcontext == NULL) - { - SDL_DestroyWindow(window); - I_Error("Failed to create a GL context: %s\n", SDL_GetError()); - } - SDL_GL_MakeCurrent(window, sdlglcontext); - } - else -#endif - if (rendermode == render_soft) - { - flags = 0; // Use this to set SDL_RENDERER_* flags now - if (usesdl2soft) - flags |= SDL_RENDERER_SOFTWARE; - else if (cv_vidwait.value) - flags |= SDL_RENDERER_PRESENTVSYNC; - -#ifdef _WIN32 - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d11"); -#else - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); -#endif - - renderer = SDL_CreateRenderer(window, -1, flags); - if (renderer == NULL) - { - CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError()); - return SDL_FALSE; - } - SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT); - } - - return SDL_TRUE; + return Impl_CreateContext(); } /* @@ -2459,6 +2480,13 @@ static void Impl_SetVsync(void) #if SDL_VERSION_ATLEAST(2,0,18) if (renderer) SDL_RenderSetVSync(renderer, cv_vidwait.value); +#endif + } +#ifdef HWRENDER + else if (rendermode == render_opengl && sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) + { + SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); + } #endif } #endif -- 2.54.0 From 5b480be6dcb30df8aefa3f4b8d2faa604fc19b4b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 12:16:32 +0200 Subject: [PATCH 378/525] smol cleanup for downsample stuff --- src/sdl/i_video.c | 29 ++++++++++++++--------------- src/sdl/ogl_sdl.c | 3 --- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 258c34898..bf7c30c7b 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -277,6 +277,9 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool #ifdef HWRENDER if (rendermode == render_opengl) { +#ifdef USE_FBO_OGL + I_DownSample(); +#endif OglSdlSurface(vid.width, vid.height); } #endif @@ -751,7 +754,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) #ifdef USE_FBO_OGL void I_DownSample(void) { - if (!cv_grframebuffer.value || !(rendermode == render_opengl) || (!supportFBO)) //no sense to do this crap if we cant benefit from it + if (!cv_grframebuffer.value || !supportFBO) //no sense to do this crap if we cant benefit from it { downsample = false; return; @@ -760,18 +763,19 @@ void I_DownSample(void) int currentDisplayIndex = SDL_GetWindowDisplayIndex(window); SDL_DisplayMode curmode; - if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) == 0) + if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0) { - if ((vid.width > curmode.w) || (vid.height > curmode.h)) //check if current resolution is higher than current display resolution - { - downsample = true; - RefreshOGLSDLSurface(); - } - else - downsample = false; // its not so no need to do crap + downsample = false; // couldnt get display info so turn the thing off + return; + } + + if ((vid.width > curmode.w) || (vid.height > curmode.h)) //check if current resolution is higher than current display resolution + { + downsample = true; + RefreshOGLSDLSurface(); } else - downsample = false; // couldnt get display info so turn the thing off + downsample = false; // its not so no need to do crap } #endif @@ -1939,11 +1943,6 @@ INT32 VID_SetMode(INT32 modeNum) } //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); -#ifdef USE_FBO_OGL - if (rendermode == render_opengl) - I_DownSample(); -#endif - SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, (setmodeneeded ? SDL_TRUE : SDL_FALSE)); Impl_VideoSetupBuffer(); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 5bb6b7347..e5d0a4441 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -166,9 +166,6 @@ boolean OglSdlSurface(INT32 w, INT32 h) maximumAnisotropy = 1; granisotropicmode_cons_t[1].value = maximumAnisotropy; -#ifdef USE_FBO_OGL - I_DownSample(); -#endif } first_init = true; -- 2.54.0 From 9e8d79f2469f6e52954e4d261b6a84e8032b524e Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 19 Aug 2024 14:14:17 +0300 Subject: [PATCH 379/525] Fix compilation when SDL_VERSION_ATLEAST(2,0,18) is false (if its false then 'else' statement would not be valid) --- src/sdl/i_video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index bf7c30c7b..a467187bc 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -2480,9 +2480,8 @@ static void Impl_SetVsync(void) if (renderer) SDL_RenderSetVSync(renderer, cv_vidwait.value); #endif - } #ifdef HWRENDER - else if (rendermode == render_opengl && sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) + if (!renderer && rendermode == render_opengl && sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) { SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); } -- 2.54.0 From af18e2b7d10c78f684cecc45deb21a8d103ff4eb Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 19 Aug 2024 14:14:59 +0300 Subject: [PATCH 380/525] Don't execute exitgame command on dedicated servers --- src/d_netcmd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 790bc2850..62072d9ee 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5693,6 +5693,12 @@ void Command_ExitGame_f(void) { INT32 i; + if (dedicated) + { + CONS_Printf("This command cannot be used on dedicated server\n"); + return; + } + D_QuitNetGame(); CL_Reset(); CV_ClearChangedFlags(); -- 2.54.0 From 2259ef3f71f6bb28b9245d8f99a7a2a9c4bcf38e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 14:58:01 +0200 Subject: [PATCH 381/525] Update LUASTUFF idk i suck at explaining lmao but atleast those should be mentioned --- LUASTUFF.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/LUASTUFF.md b/LUASTUFF.md index e72ae4c2a..a8f285692 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -130,8 +130,24 @@ if rawget(_G, "S_StopSoundByNum") ~= nil then ... -- Can use it end ``` - ## addHook("ServerJoin", function()) ServerJoin hook called when client joins server (starting a listen server also calls it for host). Generally it was made to make loading custom config files less hacky, but can be used for anything else too. + +## player.viewrollangle field + +Returns player's current view roll angle for the Screen Tilting feature, useful for HUD elements. + +## G_SetPlayerGamepadIndicatorColor(player, skincolor) + +Set a custom color for Supported Gamepads with RGB LED functionality. +To be used with Displayplayers. +Only takes Skincolors. +Best to be used in a Loop to ensure the color wont get overwritten by the game. + +## G_PlayerDeviceRumble(player, low_strength, high_strength, -optional- duration) + +Add Gamepad Rumble support for things. +To be used with Displayplayers. +Duration is in milliseconds and is optional to set, default value is 84ms. -- 2.54.0 From 4d03fa06e1042e951c3a5e422001796b4b03d5e2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 17:16:48 +0200 Subject: [PATCH 382/525] raise maxpng res --- src/screen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/screen.h b/src/screen.h index a6a0eb477..4f3b0b1ff 100644 --- a/src/screen.h +++ b/src/screen.h @@ -45,8 +45,8 @@ #define BASEVIDHEIGHT 200 // resolution of the graphics. // max res for png capture; seperated it so both MAXVID values can be lower for software performance reasons; OpenGL does not care about those anyways -#define MAXPNGWIDTH 3840 -#define MAXPNGHEIGHT 2160 +#define MAXPNGWIDTH 7680 +#define MAXPNGHEIGHT 4320 // global video state typedef struct viddef_s -- 2.54.0 From a38aee7fe31f20e5a81e65c8085a20e1326fc604 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:25:25 -0400 Subject: [PATCH 383/525] Appimage compile pt1 --- AppImage_build.sh | 344 ++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile | 18 +++ 2 files changed, 362 insertions(+) create mode 100755 AppImage_build.sh diff --git a/AppImage_build.sh b/AppImage_build.sh new file mode 100755 index 000000000..31f8086a7 --- /dev/null +++ b/AppImage_build.sh @@ -0,0 +1,344 @@ +#!/bin/bash +set -e # Enable auto-exit for debugging :)) + +# Make Linux AppImage program data +# https://docs.appimage.org/reference/appdir.html + +# PWD: {repo_root}/build +# See deployer.sh for usage + +# Terminal stuff +RESET="$(tput sgr0)" #"\e[0m" # Resets terminal colors + +# Colors for various information types +FAILURE="$(tput setaf 1)" #"\e[91m" +SUCCESS="$(tput setaf 2)" #"\e[92m" +NOTICE="$(tput setaf 3)" #"\e[93m" +VERBOSE="$(tput setaf 4)" #"\e[94m" + +verbosity=0 # By default don't print anything unless it's *ultra* important. +quiet=0 # Also don't print anything if they supplied the quiet argument + +# URL from which to download appimagetool if there isn't one available in your $PATH +# at time of writing only aarch64, armhf, i686, and x86_64 versions are available via this method +# in those cases, and honestly even outside of those cases, it's better to just put a working one in your $PATH yourself.. +url="https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$(uname -m).AppImage" + +# A whitelist of libraries to include into SRB2's AppImage if SRB2 is dynamically linked. +# please don't add a newline at the end of this or i will cry :( +libraryWhitelist=" +libnsl +libSDL2 +libSDL2_mixer +libgme +libopenmpt +libpng +libfluidsynth +libpulse +libmodplug +libvorbisfile +libopusfile +libFLAC +libmad +libmpg123 +libvorbis +libpulsecommon +libsndfile +libsndio +libogg +libvorbisenc +libjson +libreadline +libwrap +libtinfo +libtirpc +libpng16" + +# these kinda look like macros don't they +function print { (( "$quiet" == 0 )) && echo "$@" || :; } # echo if not quiet +function coloredText { printf "$1"; print "${@:2}"; printf "$RESET"; } # use print to inherit quiet +function success { coloredText "$SUCCESS" "$@"; } # use coloredText to inherit quiet +function important { coloredText "$NOTICE" "$@"; } # use coloredText to inherit quiet +function verboseOnly { (( "$verbosity" >= $1 )) && (coloredText "$VERBOSE" "${@:2}") || :; } # use coloredText to inherit quiet + +# Parses an argument with a single dash +function parseSingleDashArg() { + while read -n 1 char; do + if [[ "$char" == '-' || "$char" == '' ]]; then + : + elif [[ "$char" == 'h' ]]; then + helppassed=1 + elif [[ "$char" == 'q' ]]; then + quiet=1 + elif [[ "$char" == 'v' ]]; then + verbosity="$((verbosity + 1))" + elif [[ "$char" == 'd' ]]; then + dry=1 + elif [[ "$char" == 's' ]]; then + small=1 + else + echo "$0: invalid option -- '$1'" + echo "Try '$0 --help' for more information." + return 1 + fi + done <<<"$1" +} + +# Simple help argument checker. +currentarg=1; # Which argument is --help... + +# For $arg in the argument array... +for arg in "$@"; do + # Is it a help argument? + if [[ "$arg" == "--help" ]]; then + helppassed=1; # Help is passed, set $helppassed! + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" # Remove argument from list + elif [[ "$arg" == "--quiet" ]]; then + quiet=1 + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" + elif [[ "$arg" == "--verbose" ]]; then + verbosity="$((verbosity + 1))" # Increase verbosity! + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" + elif [[ "$arg" == "--dry" ]]; then + dry=1; # Show parameters instead of using them. + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" + elif [[ "$arg" == "--small" ]]; then + small=1; # Don't copy assets to save on bandwidth. + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" + elif [[ ! "$arg" == *'--'* && "$arg" == *'-'* ]]; then + parseSingleDashArg "$arg" + + if [[ "$?" == 0 ]]; then + set -- "${@:1:$currentarg-1}" "${@:$currentarg+1}" # Remove argument from list + fi + elif [[ $arg == *'--'* ]]; then + print "$0: invalid option -- '$1'" + print "Try '$0 --help' for more information." + return 1 + else + currentarg="$((currentarg+1))" # Increment current argument number otherwise... + fi +done + +important "SRB2 AppImage Packager v1.0, by mazmazz and Golden." + +# Get root directory from the full path of this script. +__ROOT_DIR="$3" + +if [[ -z "$3" ]]; then + # finds out where this script is and goes to that directory and goes up one for the root + + scriptdir="$(dirname "${BASH_SOURCE[0]}")" + scriptbase="$(basename "${BASH_SOURCE[0]}")" + + __ROOT_DIR="$(cd "$scriptdir" && pwd -P)" +fi + +# If it starts with '.', put the current working directory behind it so things work. +if [[ "$__ROOT_DIR" == '.' || "$__ROOT_DIR" == '..' ]]; then + __ROOT_DIR="$PWD/$__ROOT_DIR" +fi + +# Set up defaults +__PROGRAM_NAME="${PROGRAM_NAME:-"SRB2Kart Neptune"}" +__PROGRAM_DESCRIPTION="${PROGRAM_DESCRIPTION:-"Modded version of SRB2kart with more features."}" +__PROGRAM_FILENAME="${PROGRAM_FILENAME:-"srb2kart-neptune"}" +__PROGRAM_ASSETS="${PROGRAM_ASSETS:-"$__ROOT_DIR/assets/installer"}" + +__BUILD_DIR="${1:-"$__ROOT_DIR/bin"}" +__OUTPUT_FILENAME="${2:-"$__PROGRAM_FILENAME.AppImage"}" + +__APPIMAGETOOL="${4:-"appimagetool"}" + +if (! command -v "$__APPIMAGETOOL" &> /dev/null); then + __APPIMAGETOOL= +fi + +# Stuff that prints and exits. + +# Prints setup text using method given by arguments. +# Example: printSetup "print" # print "Setup for AppImage... +function printSetup { + $@ "Setup for AppImage in BUILD_DIR: '$__BUILD_DIR'..." + $@ "With the OUTPUT_FILENAME: '$__OUTPUT_FILENAME'" + $@ "And SRB2 Repository Root ROOT_DIR: '$__ROOT_DIR'" + $@ "Using APPIMAGETOOL: '$([ -z "$__APPIMAGETOOL" ] && echo '(download)' || echo $__APPIMAGETOOL)'" + $@ "" + $@ "This should be run from a Makefile or from the directory of the build. If it is not, then change to that directory or specify that directory as an argument." + $@ "If ROOT_DIR isn't SRB2's repository root, specify that as an argument too." + $@ "Make must have built the program before you run this script." + $@ "" + $@ "Make sure these Environment Variables are correct." + $@ "If not, then enter: export PROGRAM_VARIABLE=value" + $@ "PROGRAM_NAME: $__PROGRAM_NAME" + $@ "PROGRAM_DESCRIPTION: $__PROGRAM_DESCRIPTION" + $@ "PROGRAM_FILENAME: $__PROGRAM_FILENAME" + $@ "PROGRAM_ASSETS: $__PROGRAM_ASSETS" +} + +if [[ "$helppassed" ]]; then + print "Usage: $(basename "$0") [OPTION]... [BUILD_DIR] [OUTPUT_NAME] [ROOT_DIR] [APPIMAGETOOL]" + print "Packages a SRB2 binary into an AppImage." + print "OPTIONs may be included anywhere within the arguments." + print "" + print "Arguments:" + print " -h, --help display this help and exit." + print " -q, --quiet don't display any text." + print " -v, --verbose make commands more verbose, will always print." + print " -s, --small don't copy SRB2 assets to save on bandwidth." + print " parameters regardless of --dry." + print " -d, --dry print parameters and exit." + print "" + if (( "$verbosity" > 0 )) || [[ "$dry" ]]; then + printSetup "print" + else + print "This should be run from a Makefile or from the directory of the build." + print "Make must have built the program before you run this script." + fi + exit; +fi + +if (( "$verbosity" > 0 )) || [[ "$dry" ]]; then + printSetup "verboseOnly" "0" + verboseOnly 0 "" + + if [[ "$dry" ]]; then + set -n # Enable debug mode and verbose for dry run. + fi +fi + +# End stuff that prints and exits. + +if (( "$verbosity" >= 4 )); then + set -v # Really verbose? Print *everything*! +fi + +# Define AppDir structure +mkdir -p "$__BUILD_DIR/AppDir/usr/bin" +mkdir -p "$__BUILD_DIR/AppDir/lib" +mkdir -p "$__BUILD_DIR/AppDir/usr/share/applications" +mkdir -p "$__BUILD_DIR/AppDir/usr/share/icons/hicolor/256x256/apps" + +# Copy program data +if [[ ! $small ]]; then + verboseOnly 1 "Packaging program assets..." + cp -r "$__PROGRAM_ASSETS"/* "$__BUILD_DIR/AppDir/usr/bin/" + cp -r "$__BUILD_DIR/$__PROGRAM_FILENAME" "$__BUILD_DIR/AppDir/usr/bin" +else + verboseOnly 1 "Skipping program asset packing, --small or -s passed..." +fi + +verboseOnly 1 "Packaging SRB2..." +verboseOnly 1 "Assuming executable name $__PROGRAM_FILENAME" +cp -r "$__BUILD_DIR/$__PROGRAM_FILENAME" "$__BUILD_DIR/AppDir/usr/bin" + +# Copy required dependencies, but only if the program is dynamically linked. +verboseOnly 1 "Testing if this build is dynamically linked..." + +set +e # Disable auto-exit for ldd. + +srb2Libraries="$(ldd "$__BUILD_DIR/$__PROGRAM_FILENAME")" +exitcode="$?" + +set -e # Enable it again! + +if (( $exitcode == 0 )); then + verboseOnly 1 "This build *is* dynamically linked! Packaging dependencies." + + # read the dynamic libraries of srb2, trim off beginning whitespace, and get the third field seperated by spaces + # this gives us a newline-seperated list of libraries with their full paths. + srb2Libraries="$(echo "$srb2Libraries" | cut -f 2 | cut -d ' ' -f 3)" + + # remove any extraneous newlines around the string + libraryWhitelist="$(echo $libraryWhitelist | head -c -1 | tr ' ' '\n')" + + # replace e.g. 'abc' with '(/abc\b)', and replace newlines with '|'. + # this converts it into a grep regular expression to check for any whitelisted library names. + libraryWhitelist="$(printf "%s" "$libraryWhitelist" | sed 's|.*|(/\0\\b)|' | tr '\n' '|')" + + # grab only the entries that match the regex + __LDD_LIST="$(printf "%s" "$srb2Libraries" | grep -E "$libraryWhitelist")" + + # use echo to convert the newline-seperated list into an argument list + __LDD_LIST="$(echo $__LDD_LIST)" + + # read into an array because i can't be bothered iterating the lines of a string today + # there's so many other things in this file that'd need to be adjusted to be POSIX-compliant anyway + IFS=' ' read -r -a paths <<< "$__LDD_LIST" + + for path in "${paths[@]}"; do + if [ -f "$path" ]; then + verboseOnly 2 "Packaging dependency $(basename "$path")..." + cp "$path" $__BUILD_DIR/AppDir/lib/ + else + verboseOnly 2 "Dependency $(basename "$path") not found" + fi + done +else + verboseOnly 1 "This SRB2 build is statically linked, skipping dependency packing." +fi + +cd "$__BUILD_DIR/AppDir" + +# Copy icons +verboseOnly 1 "Packaging resources..." +cp "$__ROOT_DIR/srb2.png" "./usr/share/icons/hicolor/256x256/apps/$__PROGRAM_FILENAME.png" +ln -sf "./usr/share/icons/hicolor/256x256/apps/$__PROGRAM_FILENAME.png" "./.DirIcon" +ln -sf "./usr/share/icons/hicolor/256x256/apps/$__PROGRAM_FILENAME.png" "./$__PROGRAM_FILENAME.png" + +# Make desktop descriptor +cat > "./usr/share/applications/$__PROGRAM_FILENAME.desktop" < ./AppRun +echo -e 'HERE="$(dirname "$(readlink -f "${0}")")"' >> ./AppRun +echo -e 'SRB2WADDIR=$HERE/usr/bin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HERE/lib exec $HERE/usr/bin/'"$__PROGRAM_FILENAME"' "$@"' >> ./AppRun +chmod +x ./AppRun + +cd .. # now in $__BUILD_DIR + +# Package AppImage +if [ -z "$__APPIMAGETOOL" ]; then + verboseOnly 1 "No valid appimagetool path given or detected, downloading appimagetool..." + + # Print notice for internet connection. + important "If the command hangs here, check your internet connection, or download appimagetool and add it to your \$PATH and try compiling again." + + (( "$verbosity" >= 3 )) && wget "$url" || wget -q "$url" + + APPIMAGETOOL="./$(basename "$url")" + chmod a+x "$APPIMAGETOOL" +else + verboseOnly 1 "appimagetool path given or detected, no download required." + APPIMAGETOOL="$__APPIMAGETOOL" +fi + +verboseOnly 1 "Packing AppImage $__OUTPUT_FILENAME" + +if (( verbosity >= 3 )); then + "$APPIMAGETOOL" ./AppDir "$__OUTPUT_FILENAME" +elif (( verbosity >= 2 )); then + "$APPIMAGETOOL" ./AppDir "$__OUTPUT_FILENAME" >/dev/null +else + "$APPIMAGETOOL" ./AppDir "$__OUTPUT_FILENAME" >/dev/null 2>&1 +fi + +success "AppImage ready!" +verboseOnly 1 "Cleaning up files..." +rm -r ./AppDir + +if [ -z "$__APPIMAGETOOL" ]; then + rm "$APPIMAGETOOL" +fi + +cd "$__ROOT_DIR" # snap back to reality diff --git a/src/Makefile b/src/Makefile index 78dfdd4f7..f1d879ce2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -157,6 +157,12 @@ NONX86=1 # LINUX64 does not imply X86_64=1; could mean ARM64 or Itanium endif +ifdef APPIMAGE +appimage:=$(EXENAME).AppImage +else +appimage:= +endif + ifdef MINGW64 MINGW=1 NONX86=1 @@ -633,6 +639,18 @@ ifndef NOUPX -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) endif endif + +ifdef APPIMAGE +$(appimage) : $(EXENAME) + @echo Building AppImage... +ifdef APPIMAGE_NOASSETS + $(.)../AppImage_build.sh --small $(BIN) $(EXENAME).AppImage .. appimagetool +else + $(.)../AppImage_build.sh $(BIN) $(EXENAME).AppImage .. appimagetool +endif + @echo AppImage build complete!, please look for $(EXENAME).AppImage in $(BIN) +endif + @echo Build is done, please look for $(EXENAME) in $(BIN), \(checking for post steps\) reobjdump: -- 2.54.0 From fffa7e44c51944cf24547a4dd132275b5ed76bf8 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:55:27 -0400 Subject: [PATCH 384/525] Appimage compile pt2 --- AppImage_build.sh | 3 ++- src/Makefile | 13 +++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/AppImage_build.sh b/AppImage_build.sh index 31f8086a7..ed668708c 100755 --- a/AppImage_build.sh +++ b/AppImage_build.sh @@ -120,7 +120,8 @@ for arg in "$@"; do fi done -important "SRB2 AppImage Packager v1.0, by mazmazz and Golden." +important "SRB2Kart AppImage Packager v1.0 modified for kart by NepDisk." +important "Orignal for SRB2 my mazmazz and Golden." # Get root directory from the full path of this script. __ROOT_DIR="$3" diff --git a/src/Makefile b/src/Makefile index f1d879ce2..72f82265b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -157,12 +157,6 @@ NONX86=1 # LINUX64 does not imply X86_64=1; could mean ARM64 or Itanium endif -ifdef APPIMAGE -appimage:=$(EXENAME).AppImage -else -appimage:= -endif - ifdef MINGW64 MINGW=1 NONX86=1 @@ -641,14 +635,13 @@ endif endif ifdef APPIMAGE -$(appimage) : $(EXENAME) @echo Building AppImage... ifdef APPIMAGE_NOASSETS - $(.)../AppImage_build.sh --small $(BIN) $(EXENAME).AppImage .. appimagetool + $(.)../AppImage_build.sh --small --quiet $(BIN)/ else - $(.)../AppImage_build.sh $(BIN) $(EXENAME).AppImage .. appimagetool + $(.)../AppImage_build.sh -q $(BIN)/ endif - @echo AppImage build complete!, please look for $(EXENAME).AppImage in $(BIN) + @echo AppImage build complete, please look for $(EXENAME).AppImage in $(BIN) endif @echo Build is done, please look for $(EXENAME) in $(BIN), \(checking for post steps\) -- 2.54.0 From cded0af06195c7d7055653606353da3552e92945 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 17:38:01 +0200 Subject: [PATCH 385/525] change some stuff for saturn --- AppImage_build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AppImage_build.sh b/AppImage_build.sh index ed668708c..2822d00d3 100755 --- a/AppImage_build.sh +++ b/AppImage_build.sh @@ -27,6 +27,7 @@ url="https://github.com/AppImage/AppImageKit/releases/download/continuous/appima # A whitelist of libraries to include into SRB2's AppImage if SRB2 is dynamically linked. # please don't add a newline at the end of this or i will cry :( libraryWhitelist=" +libbacktrace libnsl libSDL2 libSDL2_mixer @@ -141,9 +142,9 @@ if [[ "$__ROOT_DIR" == '.' || "$__ROOT_DIR" == '..' ]]; then fi # Set up defaults -__PROGRAM_NAME="${PROGRAM_NAME:-"SRB2Kart Neptune"}" +__PROGRAM_NAME="${PROGRAM_NAME:-"SRB2Kart Saturn"}" __PROGRAM_DESCRIPTION="${PROGRAM_DESCRIPTION:-"Modded version of SRB2kart with more features."}" -__PROGRAM_FILENAME="${PROGRAM_FILENAME:-"srb2kart-neptune"}" +__PROGRAM_FILENAME="${PROGRAM_FILENAME:-"lsdl2srb2kart"}" __PROGRAM_ASSETS="${PROGRAM_ASSETS:-"$__ROOT_DIR/assets/installer"}" __BUILD_DIR="${1:-"$__ROOT_DIR/bin"}" -- 2.54.0 From 0f94a26dc65ccae96a9911202b974406b746d3b0 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 19:36:22 +0200 Subject: [PATCH 386/525] dumbass workaround for issues on xwayland with nvidia this will run automatically when it detects an nvidia gpu even with gr_framebuffer disabled lol we have safeguards everywhere so shouldnt be an issue --- src/hardware/r_opengl/r_opengl.c | 4 ++-- src/i_video.h | 4 ++++ src/sdl/i_video.c | 24 ++++++++++++++++++++++++ src/sdl/ogl_sdl.c | 25 +++++++++++++++++++++++-- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index c3d0daf0d..ef8cc6395 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -775,8 +775,8 @@ static boolean GLFramebuffer_IsFuncAvailible(void) if (majorGL < 3) return false; - return((isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions)) && - (isExtAvailable("GL_ARB_framebuffer_object",gl_extensions)) && + return((isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions)) && + (isExtAvailable("GL_ARB_framebuffer_object",gl_extensions)) && (isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions))); return false; diff --git a/src/i_video.h b/src/i_video.h index 708fde03c..6a60f8036 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -140,6 +140,10 @@ UINT32 I_GetRefreshRate(void); boolean I_UseNativeKeyboard(void); #ifdef USE_FBO_OGL +#if defined (__unix__) +extern boolean xwaylandcrap; +#endif + void RefreshOGLSDLSurface(void); void I_DownSample(void); extern boolean downsample; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index a467187bc..9f6080266 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -217,6 +217,10 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); static void Impl_SetWindowIcon(void); #ifdef USE_FBO_OGL +#if defined (__unix__) +static void I_FixXwaylandNvidia(void); +boolean xwaylandcrap = false; +#endif boolean downsample = false; void RefreshOGLSDLSurface(void) { @@ -278,6 +282,9 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool if (rendermode == render_opengl) { #ifdef USE_FBO_OGL +#if defined (__unix__) + I_FixXwaylandNvidia(); +#endif I_DownSample(); #endif OglSdlSurface(vid.width, vid.height); @@ -777,6 +784,23 @@ void I_DownSample(void) else downsample = false; // its not so no need to do crap } + +#if defined (__unix__) +static void I_FixXwaylandNvidia(void) //dumbass crap, fix ur shit nvidia +{ + if (!supportFBO) + { + xwaylandcrap = false; + return; + } + + // enable fbo resize shit, update the ogl surface and turn crap back off lol + xwaylandcrap = true; + RefreshOGLSDLSurface(); + xwaylandcrap = false; + RefreshOGLSDLSurface(); +} +#endif #endif static void Impl_HandleWindowEvent(SDL_WindowEvent evt) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index e5d0a4441..2a6b80e95 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -68,6 +68,12 @@ PFNglGetIntegerv pglGetIntegerv; PFNglGetString pglGetString; #endif +#if defined (__unix__) +#ifdef USE_FBO_OGL +static boolean isnvidiagpu = false; +#endif +#endif + /** \brief SDL video display surface */ INT32 oglflags = 0; @@ -166,6 +172,13 @@ boolean OglSdlSurface(INT32 w, INT32 h) maximumAnisotropy = 1; granisotropicmode_cons_t[1].value = maximumAnisotropy; + +#if defined (__unix__) +#ifdef USE_FBO_OGL + if (strstr((const char*)gl_renderer, "NVIDIA")) + isnvidiagpu = true; +#endif +#endif } first_init = true; @@ -191,7 +204,11 @@ boolean OglSdlSurface(INT32 w, INT32 h) RenderToFramebuffer = FrameBufferEnabled; GLFramebuffer_Disable(); - if (RenderToFramebuffer && downsample) + if ((RenderToFramebuffer && downsample) +#if defined (__unix__) + || (isnvidiagpu && xwaylandcrap) +#endif + ) GLFramebuffer_Enable(); #endif @@ -229,7 +246,11 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_DrawScreenFinalTexture(sdlw, sdlh); #ifdef USE_FBO_OGL - if (RenderToFramebuffer && downsample) + if ((RenderToFramebuffer && downsample) +#if defined (__unix__) + || (isnvidiagpu && xwaylandcrap) +#endif + ) GLFramebuffer_Enable(); #endif -- 2.54.0 From f0d91a970826a72c328bd591ff73d0e6363f737a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 21:48:56 +0200 Subject: [PATCH 387/525] do not constantly query ogl extensions --- src/hardware/r_opengl/r_opengl.c | 28 +++++++++++----------------- src/hardware/r_opengl/r_opengl.h | 1 + src/sdl/ogl_sdl.c | 2 ++ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ef8cc6395..cca1b12b8 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -120,8 +120,6 @@ GLfloat projMatrix[16]; static GLint viewport[4]; #ifdef USE_FBO_OGL -static boolean GLFramebuffer_IsFuncAvailible(void); - GLuint FramebufferObject, FramebufferTexture, RenderbufferObject; GLboolean FrameBufferEnabled = GL_FALSE, RenderToFramebuffer = GL_FALSE; @@ -752,7 +750,7 @@ void SetupGLFunc4(void) pglGetUniformLocation = GetGLFunc("glGetUniformLocation"); #ifdef USE_FBO_OGL - if (GLFramebuffer_IsFuncAvailible()) + if (supportFBO) { pglGenFramebuffers = GetGLFunc("glGenFramebuffers"); pglBindFramebuffer = GetGLFunc("glBindFramebuffer"); @@ -769,17 +767,14 @@ void SetupGLFunc4(void) } #ifdef USE_FBO_OGL -static boolean GLFramebuffer_IsFuncAvailible(void) +void GLFramebuffer_IsFuncAvailible(void) { //this stuff needs atleast OGL 3.0 if (majorGL < 3) - return false; + supportFBO = false; - return((isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions)) && - (isExtAvailable("GL_ARB_framebuffer_object",gl_extensions)) && - (isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions))); - - return false; + if (isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_object",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)) + supportFBO = true; } #endif @@ -1045,7 +1040,7 @@ EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo) #ifdef USE_FBO_OGL void GLFramebuffer_Generate(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; // Generate the framebuffer @@ -1058,7 +1053,7 @@ void GLFramebuffer_Generate(void) void GLFramebuffer_Delete(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; // Unbind the framebuffer @@ -1073,7 +1068,7 @@ void GLFramebuffer_Delete(void) void GLFramebuffer_GenerateAttachments(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; // Bind the framebuffer @@ -1114,7 +1109,7 @@ void GLFramebuffer_GenerateAttachments(void) void GLFramebuffer_DeleteAttachments(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; // Unbind the framebuffer @@ -1132,7 +1127,7 @@ void GLFramebuffer_DeleteAttachments(void) void GLFramebuffer_Enable(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; if (FramebufferObject == 0) @@ -1146,7 +1141,7 @@ void GLFramebuffer_Enable(void) void GLFramebuffer_Disable(void) { - if (!GLFramebuffer_IsFuncAvailible()) + if (!supportFBO) return; pglBindFramebuffer(GL_FRAMEBUFFER, 0); @@ -2343,7 +2338,6 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) #ifdef USE_FBO_OGL case HWD_SET_FRAMEBUFFER: FrameBufferEnabled = Value ? GL_TRUE : GL_FALSE; - supportFBO = GLFramebuffer_IsFuncAvailible(); if (!supportFBO) { diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 255969d5a..29759b0a9 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -105,6 +105,7 @@ static PFNglEnableClientState pglEnableClientState; #endif #ifdef USE_FBO_OGL +void GLFramebuffer_IsFuncAvailible(void); void GLFramebuffer_Generate(void); void GLFramebuffer_Delete(void); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 2a6b80e95..a4d401248 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -157,6 +157,8 @@ boolean OglSdlSurface(INT32 w, INT32 h) "- GPU drivers are missing or broken. You may need to update your drivers."); } + GLFramebuffer_IsFuncAvailible(); + SetupGLInfo(); SetupGLFunc4(); -- 2.54.0 From cf5c0ca5f7b79dfc24ae61dbe72b5c427eef5d11 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Aug 2024 21:54:15 +0200 Subject: [PATCH 388/525] forgor return --- src/hardware/r_opengl/r_opengl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index cca1b12b8..3298a04c5 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -771,7 +771,10 @@ void GLFramebuffer_IsFuncAvailible(void) { //this stuff needs atleast OGL 3.0 if (majorGL < 3) + { supportFBO = false; + return; + } if (isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_object",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)) supportFBO = true; -- 2.54.0 From 31c64b63de65fbfe1d9202d6ae22561ba42889c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Aug 2024 03:57:43 +0200 Subject: [PATCH 389/525] make this more robust ig --- src/hardware/r_opengl/r_opengl.c | 21 +++++++++++---------- src/hardware/r_opengl/r_opengl.h | 1 - src/sdl/ogl_sdl.c | 8 +++----- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 3298a04c5..573a52c24 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -705,6 +705,7 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; +static boolean GLFramebuffer_IsFuncAvailible(void); void SetupGLFunc4(void) { @@ -750,7 +751,7 @@ void SetupGLFunc4(void) pglGetUniformLocation = GetGLFunc("glGetUniformLocation"); #ifdef USE_FBO_OGL - if (supportFBO) + if (GLFramebuffer_IsFuncAvailible()) { pglGenFramebuffers = GetGLFunc("glGenFramebuffers"); pglBindFramebuffer = GetGLFunc("glBindFramebuffer"); @@ -762,22 +763,22 @@ void SetupGLFunc4(void) pglDeleteRenderbuffers = GetGLFunc("glDeleteRenderbuffers"); pglRenderbufferStorage = GetGLFunc("glRenderbufferStorage"); pglFramebufferRenderbuffer = GetGLFunc("glFramebufferRenderbuffer"); + + supportFBO = true; } #endif } #ifdef USE_FBO_OGL -void GLFramebuffer_IsFuncAvailible(void) +static boolean GLFramebuffer_IsFuncAvailible(void) { //this stuff needs atleast OGL 3.0 if (majorGL < 3) - { - supportFBO = false; - return; - } + return false; - if (isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_object",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)) - supportFBO = true; + return (isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_object",gl_extensions) && isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)); + + return false; } #endif @@ -1128,7 +1129,7 @@ void GLFramebuffer_DeleteAttachments(void) RenderbufferObject = 0; } -void GLFramebuffer_Enable(void) +inline void GLFramebuffer_Enable(void) { if (!supportFBO) return; @@ -1142,7 +1143,7 @@ void GLFramebuffer_Enable(void) pglBindRenderbuffer(GL_RENDERBUFFER, RenderbufferObject); } -void GLFramebuffer_Disable(void) +inline void GLFramebuffer_Disable(void) { if (!supportFBO) return; diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 29759b0a9..255969d5a 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -105,7 +105,6 @@ static PFNglEnableClientState pglEnableClientState; #endif #ifdef USE_FBO_OGL -void GLFramebuffer_IsFuncAvailible(void); void GLFramebuffer_Generate(void); void GLFramebuffer_Delete(void); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index a4d401248..13751da83 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -157,8 +157,6 @@ boolean OglSdlSurface(INT32 w, INT32 h) "- GPU drivers are missing or broken. You may need to update your drivers."); } - GLFramebuffer_IsFuncAvailible(); - SetupGLInfo(); SetupGLFunc4(); @@ -203,10 +201,10 @@ boolean OglSdlSurface(INT32 w, INT32 h) pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); #ifdef USE_FBO_OGL - RenderToFramebuffer = FrameBufferEnabled; + RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); GLFramebuffer_Disable(); - if ((RenderToFramebuffer && downsample) + if (RenderToFramebuffer #if defined (__unix__) || (isnvidiagpu && xwaylandcrap) #endif @@ -242,7 +240,7 @@ void OglSdlFinishUpdate(boolean waitvbl) #ifdef USE_FBO_OGL GLFramebuffer_Disable(); - RenderToFramebuffer = FrameBufferEnabled; + RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); #endif HWR_DrawScreenFinalTexture(sdlw, sdlh); -- 2.54.0 From 9f8eb074420ac6c5fdd562f4f7458dfc886aa445 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Aug 2024 20:39:26 +0200 Subject: [PATCH 390/525] revert this in y_inter --- src/y_inter.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 8527ff799..ac05c6360 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -728,17 +728,11 @@ void Y_Ticker(void) return; } - if (intertic < TICRATE || endtic != -1) + if (intertic < TICRATE || intertic & 1 || endtic != -1) { return; } - if (data.match.rankingsmode && intertic & 1) - { - memset(data.match.jitter, 0, sizeof (data.match.jitter)); - return; - } - if (intertype == int_race || intertype == int_match) { if (netgame || multiplayer) -- 2.54.0 From 3d827570e64a14714dabedb887f0a95fe1d965b5 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Aug 2024 23:17:26 +0200 Subject: [PATCH 391/525] more changes to FBO stuff now it wont ever do anything when disabled also properly deletes the FBO when disabling it --- src/hardware/r_opengl/r_opengl.c | 19 ++++++++++++++----- src/hardware/r_opengl/r_opengl.h | 2 +- src/sdl/i_video.c | 4 ++++ src/sdl/ogl_sdl.c | 30 +++++++++++++++++------------- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 573a52c24..2f94f83cd 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1055,14 +1055,11 @@ void GLFramebuffer_Generate(void) GLFramebuffer_GenerateAttachments(); } -void GLFramebuffer_Delete(void) +static void GLFramebuffer_Delete(void) { if (!supportFBO) return; - // Unbind the framebuffer - pglBindFramebuffer(GL_FRAMEBUFFER, 0); - if (FramebufferObject) pglDeleteFramebuffers(1, &FramebufferObject); @@ -1118,6 +1115,7 @@ void GLFramebuffer_DeleteAttachments(void) // Unbind the framebuffer pglBindFramebuffer(GL_FRAMEBUFFER, 0); + pglBindRenderbuffer(GL_RENDERBUFFER, 0); if (FramebufferTexture) pglDeleteTextures(1, &FramebufferTexture); @@ -1129,6 +1127,15 @@ void GLFramebuffer_DeleteAttachments(void) RenderbufferObject = 0; } +inline void GLFramebuffer_Unbind(void) +{ + if (!supportFBO) + return; + + pglBindFramebuffer(GL_FRAMEBUFFER, 0); + pglBindRenderbuffer(GL_RENDERBUFFER, 0); +} + inline void GLFramebuffer_Enable(void) { if (!supportFBO) @@ -1143,13 +1150,15 @@ inline void GLFramebuffer_Enable(void) pglBindRenderbuffer(GL_RENDERBUFFER, RenderbufferObject); } -inline void GLFramebuffer_Disable(void) +void GLFramebuffer_Disable(void) { if (!supportFBO) return; pglBindFramebuffer(GL_FRAMEBUFFER, 0); pglBindRenderbuffer(GL_RENDERBUFFER, 0); + + GLFramebuffer_Delete(); } #endif diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 255969d5a..f916c950d 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -106,11 +106,11 @@ static PFNglEnableClientState pglEnableClientState; #ifdef USE_FBO_OGL void GLFramebuffer_Generate(void); -void GLFramebuffer_Delete(void); void GLFramebuffer_GenerateAttachments(void); void GLFramebuffer_DeleteAttachments(void); +void GLFramebuffer_Unbind(void); void GLFramebuffer_Enable(void); void GLFramebuffer_Disable(void); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 9f6080266..495c96e18 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -773,6 +773,7 @@ void I_DownSample(void) if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0) { downsample = false; // couldnt get display info so turn the thing off + RefreshOGLSDLSurface(); return; } @@ -782,7 +783,10 @@ void I_DownSample(void) RefreshOGLSDLSurface(); } else + { downsample = false; // its not so no need to do crap + RefreshOGLSDLSurface(); + } } #if defined (__unix__) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 13751da83..4adc3dae8 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -188,6 +188,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) if (screen_width != w || screen_height != h) { FlushScreenTextures(); + #ifdef USE_FBO_OGL GLFramebuffer_DeleteAttachments(); #endif @@ -201,15 +202,16 @@ boolean OglSdlSurface(INT32 w, INT32 h) pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); #ifdef USE_FBO_OGL - RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); - GLFramebuffer_Disable(); - - if (RenderToFramebuffer + RenderToFramebuffer = ((FrameBufferEnabled && supportFBO && downsample) #if defined (__unix__) - || (isnvidiagpu && xwaylandcrap) + || (isnvidiagpu && xwaylandcrap) #endif - ) + ); + + if (RenderToFramebuffer) GLFramebuffer_Enable(); + else + GLFramebuffer_Disable(); #endif HWR_Startup(); @@ -239,18 +241,20 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_MakeScreenFinalTexture(); #ifdef USE_FBO_OGL - GLFramebuffer_Disable(); - RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); + RenderToFramebuffer = ((FrameBufferEnabled && supportFBO && downsample) +#if defined (__unix__) + || (isnvidiagpu && xwaylandcrap) +#endif + ); + + if (RenderToFramebuffer) + GLFramebuffer_Unbind(); #endif HWR_DrawScreenFinalTexture(sdlw, sdlh); #ifdef USE_FBO_OGL - if ((RenderToFramebuffer && downsample) -#if defined (__unix__) - || (isnvidiagpu && xwaylandcrap) -#endif - ) + if (RenderToFramebuffer) GLFramebuffer_Enable(); #endif -- 2.54.0 From 6a14543e9e6008359e63454df6902d7ff8cc63b3 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Aug 2024 23:26:11 +0200 Subject: [PATCH 392/525] cleanup FBO on shutdown + make some stuff static --- src/hardware/hw_main.c | 3 ++ src/hardware/r_opengl/r_opengl.c | 52 ++++++++++++++++---------------- src/hardware/r_opengl/r_opengl.h | 3 -- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5c35dd8f6..72c232c1f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -26,6 +26,8 @@ #include "hw_md2.h" #include "hw_clip.h" +#include "r_opengl/r_opengl.h" + #include "../i_video.h" // for rendermode == render_glide #include "../v_video.h" #include "../p_local.h" @@ -5877,6 +5879,7 @@ void HWR_Shutdown(void) HWR_FreeMipmapCache(); HWR_FreeTextureCache(); HWD.pfnFlushScreenTextures(); + GLFramebuffer_Disable(); } void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 2f94f83cd..a5a1fc9f1 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1042,32 +1042,7 @@ EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo) } #ifdef USE_FBO_OGL -void GLFramebuffer_Generate(void) -{ - if (!supportFBO) - return; - - // Generate the framebuffer - if (FramebufferObject == 0) - pglGenFramebuffers(1, &FramebufferObject); - - if (pglCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) - GLFramebuffer_GenerateAttachments(); -} - -static void GLFramebuffer_Delete(void) -{ - if (!supportFBO) - return; - - if (FramebufferObject) - pglDeleteFramebuffers(1, &FramebufferObject); - - GLFramebuffer_DeleteAttachments(); - FramebufferObject = 0; -} - -void GLFramebuffer_GenerateAttachments(void) +static void GLFramebuffer_GenerateAttachments(void) { if (!supportFBO) return; @@ -1127,6 +1102,31 @@ void GLFramebuffer_DeleteAttachments(void) RenderbufferObject = 0; } +static void GLFramebuffer_Generate(void) +{ + if (!supportFBO) + return; + + // Generate the framebuffer + if (FramebufferObject == 0) + pglGenFramebuffers(1, &FramebufferObject); + + if (pglCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) + GLFramebuffer_GenerateAttachments(); +} + +static void GLFramebuffer_Delete(void) +{ + if (!supportFBO) + return; + + if (FramebufferObject) + pglDeleteFramebuffers(1, &FramebufferObject); + + GLFramebuffer_DeleteAttachments(); + FramebufferObject = 0; +} + inline void GLFramebuffer_Unbind(void) { if (!supportFBO) diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index f916c950d..baab44637 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -105,9 +105,6 @@ static PFNglEnableClientState pglEnableClientState; #endif #ifdef USE_FBO_OGL -void GLFramebuffer_Generate(void); - -void GLFramebuffer_GenerateAttachments(void); void GLFramebuffer_DeleteAttachments(void); void GLFramebuffer_Unbind(void); -- 2.54.0 From af6393af503c8f9b95d235ca75d7fa01d88ab60e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Aug 2024 15:38:40 +0200 Subject: [PATCH 393/525] forgor --- src/hardware/hw_main.c | 2 ++ src/hardware/r_opengl/r_opengl.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 72c232c1f..fb566e0ea 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5879,7 +5879,9 @@ void HWR_Shutdown(void) HWR_FreeMipmapCache(); HWR_FreeTextureCache(); HWD.pfnFlushScreenTextures(); +#ifdef USE_FBO_OGL GLFramebuffer_Disable(); +#endif } void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index a5a1fc9f1..96a608df6 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -705,7 +705,9 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; +#ifdef USE_FBO_OGL static boolean GLFramebuffer_IsFuncAvailible(void); +#endif void SetupGLFunc4(void) { -- 2.54.0 From 4a6635f8a83e55b521384950b85d5c99315b8e0d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Aug 2024 14:54:43 +0200 Subject: [PATCH 394/525] Revert "smol interp fixes" This reverts commit 77a2976d05f02dfcc5124c0b27d815deab9f8b1f. --- src/d_clisrv.c | 16 +--------------- src/g_game.c | 43 ++++++++++++++++++------------------------- src/p_spec.c | 9 --------- src/p_tick.c | 1 + src/p_user.c | 1 + src/y_inter.c | 2 -- 6 files changed, 21 insertions(+), 51 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2bc316c64..10d46689a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -49,7 +49,6 @@ #include "s_sound.h" // sfx_syfail #include "m_perfstats.h" #include "d_main.h" -#include "r_fps.h" #ifdef CLIENT_LOADINGSCREEN // cl loading screen @@ -6110,8 +6109,6 @@ boolean TryRunTics(tic_t realtics) if (ticking) { - boolean tickInterp = true; - // run the count * tics while (neededtic > gametic) { @@ -6122,18 +6119,7 @@ boolean TryRunTics(tic_t realtics) if (update_stats) PS_START_TIMING(ps_tictime); - boolean run = (gametic % NEWTICRATERATIO) == 0; - - if (run && tickInterp) - { - // Update old view state BEFORE ticking so resetting - // the old interpolation state from game logic works. - R_UpdateViewInterpolation(); - tickInterp = false; // do not update again in sped-up tics - } - - G_Ticker(run); - + G_Ticker((gametic % NEWTICRATERATIO) == 0); ExtraDataTicker(); gametic++; consistancy[gametic%TICQUEUE] = Consistancy(); diff --git a/src/g_game.c b/src/g_game.c index 743fa52d5..c15216a91 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -525,8 +525,6 @@ consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static void G_FixCamera(UINT8 view); - #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" #endif @@ -2085,6 +2083,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) UINT8 viewd; INT32 *displayplayerp; + camera_t *camerap; INT32 olddisplayplayer; INT32 playersviewable; @@ -2123,15 +2122,29 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = playernum; if ((*displayplayerp) != olddisplayplayer) { - G_FixCamera(viewnum); + camerap = &camera[viewnum-1]; + P_ResetCamera(&players[(*displayplayerp)], camerap); + + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(viewnum); } if (viewnum > splits) { for (viewd = splits+1; viewd < viewnum; ++viewd) { - displayplayers[viewd-1] = G_FindView(displayplayers[viewd-1], viewd, onlyactive, playernum < olddisplayplayer); - G_FixCamera(viewd); + displayplayerp = (&displayplayers[viewd-1]); + camerap = &camera[viewd]; + + (*displayplayerp) = G_FindView(0, viewd, onlyactive, false); + + P_ResetCamera(&players[(*displayplayerp)], camerap); + + + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(viewd); } } @@ -2189,26 +2202,6 @@ void G_ResetViews(void) } } -// -// G_FixCamera -// Reset camera position, angle and interpolation on a view -// after changing state. -// -static void G_FixCamera(UINT8 view) -{ - player_t *player = &players[displayplayers[view - 1]]; - - // The order of displayplayers can change, which would - // invalidate localangle. - //localangle[view - 1] = player->cmd.angleturn; - - P_ResetCamera(player, &camera[view - 1]); - - // Make sure the viewport doesn't interpolate at all into - // its new position -- just snap instantly into place. - R_ResetViewInterpolation(view); -} - // // G_Ticker // Make ticcmd_ts for the players. diff --git a/src/p_spec.c b/src/p_spec.c index 69d27270b..82372fc90 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2483,7 +2483,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 422: // Cut away to another view { mobj_t *altview; - INT32 i; if (!mo || !mo->player) // only players have views return; @@ -2498,14 +2497,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetTarget(&mo->player->awayviewmobj, altview); mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; - for (i = 0; i <= splitscreen; i++) - { - if (displayplayers[i] == (mo->player - players)) - { - R_ResetViewInterpolation(i + 1); - } - } - if (line->flags & ML_NOCLIMB) // lets you specify a vertical angle { INT32 aim; diff --git a/src/p_tick.c b/src/p_tick.c index cc2600f17..cf603af1d 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -645,6 +645,7 @@ void P_Ticker(boolean run) if (run) { R_UpdateLevelInterpolators(); + R_UpdateViewInterpolation(); // Hack: ensure newview is assigned every tic. // Ensures view interpolation is T-1 to T in poor network conditions diff --git a/src/p_user.c b/src/p_user.c index bdb03e86e..63c63b448 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3983,6 +3983,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { P_MoveChaseCamera(player, thiscam, false); R_ResetViewInterpolation(num + 1); + R_ResetViewInterpolation(num + 1); } return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); diff --git a/src/y_inter.c b/src/y_inter.c index ac05c6360..5d292f36c 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -729,9 +729,7 @@ void Y_Ticker(void) } if (intertic < TICRATE || intertic & 1 || endtic != -1) - { return; - } if (intertype == int_race || intertype == int_match) { -- 2.54.0 From 3b500add73b3d71f1d7928a5269cc2bda1c2f194 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:29:36 +0200 Subject: [PATCH 395/525] cleanup birdmusic crap again music_resync_powerups_only literally didnt do shit lol removed some other unused crap changed some conditions to better check for stuff etc idk i just rather remove this whole thing at this point but oh well --- src/g_game.c | 5 ++--- src/i_sound.h | 1 - src/m_menu.c | 1 - src/p_inter.c | 4 ++-- src/p_spec.c | 4 +++- src/p_user.c | 14 +++++--------- src/s_sound.c | 22 ++++------------------ src/s_sound.h | 9 --------- src/sdl/mixer_sound.c | 21 ++++++--------------- src/sdl/sdl_sound.c | 1 - 10 files changed, 22 insertions(+), 60 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c15216a91..0025782ed 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2705,8 +2705,7 @@ void G_PlayerReborn(INT32 player) } /* I'm putting this here because lol */ - - fade = (cv_fading.value && cv_birdmusic.value && P_IsLocalPlayer(p)); + fade = (cv_birdmusic.value && cv_fading.value && P_IsLocalPlayer(p)); if (fade) { @@ -2716,7 +2715,7 @@ void G_PlayerReborn(INT32 player) Fade it in with the same call to avoid max volume for a few milliseconds (?). */ - if (! playing) + if (!playing) S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); } diff --git a/src/i_sound.h b/src/i_sound.h index d0542cfb5..925be7596 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -159,7 +159,6 @@ boolean I_SetSongPosition(UINT32 position); UINT32 I_GetSongPosition(void); void I_UpdateSongLagThreshold (void); -void I_UpdateSongLagConditions (void); /// ------------------------ // MUSIC PLAYBACK diff --git a/src/m_menu.c b/src/m_menu.c index b7829fe31..5dee26366 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2437,7 +2437,6 @@ static menuitem_t OP_AdvancedBirdMenu[] = {IT_STRING | IT_CVAR, NULL, "Fade Back In While Respawning", &cv_respawnfademusicback, 40}, {IT_STRING | IT_CVAR, NULL, "Resync Threshold", &cv_music_resync_threshold, 60}, - {IT_STRING | IT_CVAR, NULL, "Resync Special Music Only", &cv_music_resync_powerups_only, 70}, }; static const char* OP_AdvancedBirdTooltips[] = diff --git a/src/p_inter.c b/src/p_inter.c index d22f99112..5ffaf6dba 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1737,7 +1737,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; - if (cv_fading.value && cv_birdmusic.value && P_IsLocalPlayer(target->player)) + if (cv_birdmusic.value && cv_fading.value && P_IsLocalPlayer(target->player)) { if (netgame || multiplayer) ms = cv_respawntime.value * 1000; @@ -1748,7 +1748,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) If the time spent with the music paused is less than half a second, continue playing the song (just mute it). */ - if (( ms - cv_respawnfademusicout.value ) < 500) + if ((ms - cv_respawnfademusicout.value) < 500) S_FadeMusic(0, cv_respawnfademusicout.value); else S_FadeOutStopMusic(cv_respawnfademusicout.value); diff --git a/src/p_spec.c b/src/p_spec.c index 82372fc90..97ad38015 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2179,7 +2179,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) mapmusflags |= MUSIC_FORCERESET; mapmusposition = position; - mapmusresume = 0; + + if (cv_birdmusic.value) + mapmusresume = 0; S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, !(line->flags & ML_EFFECT2) ? prefadems : 0, diff --git a/src/p_user.c b/src/p_user.c index 63c63b448..599312475 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -593,6 +593,7 @@ void P_PlayLivesJingle(player_t *player) void P_PlayRinglossSound(mobj_t *source, mobj_t *damager) { sfxenum_t key = P_RandomKey(2); + if (cv_kartvoices.value) { if (cv_karthitemdialog.value && source != damager && damager && damager->player && P_IsLocalPlayer(damager->player)) @@ -815,17 +816,13 @@ void P_RestoreMusic(player_t *player) if (wantedmus == 2 && cv_growmusic.value == 1) { S_ChangeMusicInternal("kgrow", true); - - if (cv_birdmusic.value) - S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); + S_SetRestoreMusicFadeInCvar(&cv_growmusicfade); } // Item - Invincibility else if (wantedmus == 1 && cv_supermusic.value == 1) { S_ChangeMusicInternal("kinvnc", true); - - if (cv_birdmusic.value) - S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); + S_SetRestoreMusicFadeInCvar(&cv_invincmusicfade); } else { @@ -842,13 +839,12 @@ void P_RestoreMusic(player_t *player) else position = mapmusposition; - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, - S_GetRestoreMusicFadeIn()); + S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); S_ClearRestoreMusicFadeInCvar(); } else S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); - + mapmusresume = 0; } } diff --git a/src/s_sound.c b/src/s_sound.c index 0bc76bce2..f3450b6f4 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -109,8 +109,6 @@ static CV_PossibleValue_t music_resync_threshold_cons_t[] = { }; consvar_t cv_music_resync_threshold = {"music_resync_threshold", "0", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagConditions, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -289,7 +287,6 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_pausemusic); CV_RegisterVar(&cv_music_resync_threshold); - CV_RegisterVar(&cv_music_resync_powerups_only); CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); @@ -1308,7 +1305,6 @@ static void *music_data; static UINT16 music_flags; static boolean music_looping; static consvar_t *music_refade_cv; -static int music_usage; static char queue_name[7]; static UINT16 queue_flags; @@ -1928,7 +1924,6 @@ static void S_UnloadMusic(void) music_looping = false; music_refade_cv = 0; - music_usage = 0; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) @@ -1936,8 +1931,7 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) if (S_MusicDisabled()) return false; - if (cv_birdmusic.value) - I_UpdateSongLagConditions(); + I_UpdateSongLagThreshold(); if ((!fadeinms && !I_PlaySong(looping)) || (fadeinms && !I_FadeInPlaySong(fadeinms, looping))) @@ -2132,6 +2126,9 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) void S_SetRestoreMusicFadeInCvar (consvar_t *cv) { + if (!cv_birdmusic.value) + return; + music_refade_cv = cv; } @@ -2143,17 +2140,6 @@ int S_GetRestoreMusicFadeIn (void) return 0; } -void S_SetMusicUsage (int type) -{ - music_usage = type; - I_UpdateSongLagConditions(); -} - -int S_MusicUsage (void) -{ - return music_usage; -} - /// ------------------------ /// Music Fading /// ------------------------ diff --git a/src/s_sound.h b/src/s_sound.h index 538e8713e..8787ea5e5 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -55,7 +55,6 @@ extern consvar_t cv_amigatype; //bird music stuff extern consvar_t cv_music_resync_threshold; -extern consvar_t cv_music_resync_powerups_only; extern consvar_t cv_invincmusicfade; extern consvar_t cv_growmusicfade; @@ -218,11 +217,6 @@ UINT32 S_GetMusicPosition(void); // Music Playback // -enum -{ - MUS_SPECIAL = 1,/* powerups--invincibility, grow */ -}; - // Start music track, arbitrary, given its name, and set whether looping // note: music flags 12 bits for tracknum (gme, other formats with more than one track) // 13-15 aren't used yet @@ -238,9 +232,6 @@ void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); S_SetRestoreMusicFadeInCvar(0) int S_GetRestoreMusicFadeIn (void); -void S_SetMusicUsage (int type); -int S_MusicUsage (void); - // Stops the music. void S_StopMusic(void); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 806c77e47..12abb7c65 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -93,8 +93,6 @@ static UINT16 SAMPLERATE = 44100; /// ------------------------ UINT8 sound_started = false; - -static UINT32 stutter_threshold_user; static UINT32 stutter_threshold; static Mix_Music *music; @@ -626,9 +624,10 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) return; + music_bytes += len; - if ((gamestate == GS_LEVEL) && (cv_birdmusic.value)) + if (cv_birdmusic.value && gamestate == GS_LEVEL) Countstutter(len); } @@ -1042,20 +1041,12 @@ UINT32 I_GetSongPosition(void) // 8M: 1 | 8S: 2 | 16M: 2 | 16S: 4 } -void -I_UpdateSongLagThreshold (void) +void I_UpdateSongLagThreshold (void) { - stutter_threshold_user = cv_music_resync_threshold.value/1000.0*(4*44100); - I_UpdateSongLagConditions(); -} + if (!cv_birdmusic.value) + return; -void -I_UpdateSongLagConditions (void) -{ - if (! cv_music_resync_powerups_only.value || S_MusicUsage() == MUS_SPECIAL) - stutter_threshold = stutter_threshold_user; - else - stutter_threshold = 0; + stutter_threshold = cv_music_resync_threshold.value/1000.0*(4*44100); } /// ------------------------ diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 503e7205a..33714f32a 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1410,7 +1410,6 @@ UINT32 I_GetSongPosition(void) } void I_UpdateSongLagThreshold (void) {} -void I_UpdateSongLagConditions (void) {} /// ------------------------ // MUSIC PLAYBACK -- 2.54.0 From 5ddd2e4fbcf81c7fd3bf7ff8dd13a1dfbbe5c1ba Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:31:00 +0200 Subject: [PATCH 396/525] cleanup P_DoSuperTransformation its still exposed to lua for whatever reason so cant really remove crap kek --- src/p_user.c | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 599312475..6aa3ee7a7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -499,44 +499,12 @@ void P_GivePlayerLives(player_t *player, INT32 numlives) // Transform into Super Sonic! void P_DoSuperTransformation(player_t *player, boolean giverings) { + (void)player; + (void)giverings; + return; // SRB2kart - this is not a thing we need - player->powers[pw_super] = 1; - if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC) && P_IsLocalPlayer(player)) - { - S_StopMusic(); - S_ChangeMusicInternal("supers", true); - } - - S_StartSound(NULL, sfx_supert); //let all players hear it -mattw_cfi - - // Transformation animation - //P_SetPlayerMobjState(player->mo, S_PLAY_SUPERTRANS1); - - player->mo->momx = player->mo->momy = player->mo->momz = 0; - - if (giverings) - { - player->mo->health = 51; - player->health = player->mo->health; - } - - // Just in case. - if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)) - { - player->powers[pw_extralife] = 0; - player->powers[pw_invulnerability] = 0; - player->powers[pw_sneakers] = 0; - } - - if (gametype != GT_COOP) - { - HU_SetCEchoFlags(0); - HU_SetCEchoDuration(5); - HU_DoCEcho(va("%s\\is now super.\\\\\\\\", player_names[player-players])); - } - - P_PlayerFlagBurst(player, false); } + // Adds to the player's score void P_AddPlayerScore(player_t *player, UINT32 amount) { -- 2.54.0 From 9022e02ccda63deda399099aecb06dd54e5821b8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:31:35 +0200 Subject: [PATCH 397/525] fix potential crash in P_TryCameraMove for dedi servers --- src/p_map.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index 6051d5d1c..cb2997552 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2245,6 +2245,9 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) floatok = false; + if (dedicated) // this crashes so don't even try it + return false; + if (twodlevel) itsatwodlevel = true; else -- 2.54.0 From aac89f270bcfd72cc9414d1d8749e9e03f0132d2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 05:44:13 +0200 Subject: [PATCH 398/525] Reapply "optimize precip thinker" This reverts commit dd73787c8b6bb8216fc646d4f7ce102347d713e5. --- src/hardware/hw_main.c | 16 ++--- src/info.c | 20 +++--- src/m_perfstats.c | 5 -- src/p_local.h | 1 + src/p_mobj.c | 157 +++++++++++++++++++++-------------------- src/p_mobj.h | 33 ++++----- src/p_spec.c | 5 +- src/p_tick.c | 58 ++++++++------- src/r_things.c | 20 ++---- 9 files changed, 155 insertions(+), 160 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fb566e0ea..1684bd6fe 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5112,6 +5112,12 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) // uncapped/interpolation interpmobjstate_t interp = {0}; + // okay... this is a hack, but weather isn't networked, so it should be ok + if (!P_PrecipThinker(thing)) + { + return; + } + // do interpolation if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { @@ -5205,16 +5211,6 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height); vis->precip = true; - - // okay... this is a hack, but weather isn't networked, so it should be ok - if (!(thing->precipflags & PCF_THUNK)) - { - if (thing->precipflags & PCF_RAIN) - P_RainThinker(thing); - else - P_SnowThinker(thing); - thing->precipflags |= PCF_THUNK; - } } static boolean drewsky = false; diff --git a/src/info.c b/src/info.c index b417c1135..f8cb9a6f1 100644 --- a/src/info.c +++ b/src/info.c @@ -1822,7 +1822,7 @@ state_t states[NUMSTATES] = // Rain {SPR_RAIN, FF_TRANS50, -1, {NULL}, 0, 0, S_NULL}, // S_RAIN1 - {SPR_RAIN, FF_TRANS50, 1, {NULL}, 0, 0, S_RAIN1}, // S_RAINRETURN + {SPR_NULL, 0, -1, {NULL}, 0, 0, S_NULL}, // S_RAINRETURN // Snowflake {SPR_SNO1, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SNOW1 @@ -1841,9 +1841,9 @@ state_t states[NUMSTATES] = {SPR_SPLH, FF_TRANS50|8, 2, {NULL}, 0, 0, S_NULL}, // S_SPLISH9 // Water Splash - {SPR_SPLA, FF_TRANS50 , 3, {NULL}, 0, 0, S_SPLASH2}, // S_SPLASH1 - {SPR_SPLA, FF_TRANS70|1, 3, {NULL}, 0, 0, S_SPLASH3}, // S_SPLASH2 - {SPR_SPLA, FF_TRANS90|2, 3, {NULL}, 0, 0, S_RAINRETURN}, // S_SPLASH3 + {SPR_SPLA, FF_TRANS50 , 3, {NULL}, 0, 0, S_SPLASH2}, // S_SPLASH1 + {SPR_SPLA, FF_TRANS70|1, 3, {NULL}, 0, 0, S_SPLASH3}, // S_SPLASH2 + {SPR_SPLA, FF_TRANS90|2, 3, {NULL}, 0, 0, S_NULL}, // S_SPLASH3 // Smoke {SPR_SMOK, FF_TRANS50 , 4, {NULL}, 0, 0, S_SMOKE2}, // S_SMOKE1 @@ -11198,22 +11198,22 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_RAIN1, // spawnstate 1000, // spawnhealth S_NULL, // seestate - sfx_None, // seesound - 8, // reactiontime + sfx_rainin, // seesound + 0, // reactiontime sfx_None, // attacksound S_NULL, // painstate 0, // painchance sfx_None, // painsound S_NULL, // meleestate S_NULL, // missilestate - S_NULL, // deathstate + S_SPLASH1, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound -72*FRACUNIT, // speed -- -24*FRACUNIT originally, srb2kart x3 (nya) 1*FRACUNIT, // radius 8*FRACUNIT, // height 0, // display offset - 4, // mass + 80, // mass 0, // damage sfx_None, // activesound MF_NOBLOCKMAP, // flags @@ -11226,7 +11226,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 1000, // spawnhealth S_NULL, // seestate sfx_None, // seesound - 8, // reactiontime + 0, // reactiontime sfx_None, // attacksound S_NULL, // painstate 0, // painchance @@ -11240,7 +11240,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 4*FRACUNIT, // radius 4*FRACUNIT, // height 0, // display offset - 4, // mass + 0, // mass 0, // damage sfx_None, // activesound MF_NOBLOCKMAP, // flags diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 04e51a657..a8f9550f4 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -58,7 +58,6 @@ static ps_metric_t ps_regularcount = {0}; static ps_metric_t ps_scenerycount = {0}; static ps_metric_t ps_nothinkcount = {0}; static ps_metric_t ps_otherthcount = {0}; -static ps_metric_t ps_precipcount = {0}; static ps_metric_t ps_removecount = {0}; ps_metric_t ps_checkposition_calls = {0}; @@ -173,7 +172,6 @@ perfstatrow_t thinkercount_rows[] = { {" scenery", " Scenery: ", &ps_scenerycount, PS_LEVEL}, {" nothink", " Nothink: ", &ps_nothinkcount, PS_HIDE_ZERO|PS_LEVEL}, {" other ", " Other: ", &ps_otherthcount, PS_LEVEL}, - {" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL}, {" remove ", " Pending removal:", &ps_removecount, PS_LEVEL}, {0} }; @@ -572,7 +570,6 @@ static void PS_CountThinkers(void) ps_scenerycount.value.i = 0; ps_nothinkcount.value.i = 0; ps_otherthcount.value.i = 0; - ps_precipcount.value.i = 0; ps_removecount.value.i = 0; for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { @@ -590,8 +587,6 @@ static void PS_CountThinkers(void) else ps_regularcount.value.i++; } - else if (thinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) - ps_precipcount.value.i++; else ps_otherthcount.value.i++; } diff --git a/src/p_local.h b/src/p_local.h index fed4a2d34..725aa20d1 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -70,6 +70,7 @@ extern thinker_t thinkercap; void P_InitThinkers(void); void P_AddThinker(thinker_t *thinker); void P_RemoveThinker(thinker_t *thinker); +void P_UnlinkThinker(thinker_t *thinker); // // P_USER diff --git a/src/p_mobj.c b/src/p_mobj.c index a156edd43..a69742842 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -338,7 +338,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state) if (state == S_NULL) { // Remove mobj - P_RemovePrecipMobj(mobj); + P_FreePrecipMobj(mobj); return false; } st = &states[state]; @@ -3603,67 +3603,86 @@ void P_RecalcPrecipInSector(sector_t *sector) // // P_NullPrecipThinker // -// For "Blank" precipitation +// Just the identification of a precip thinker. The thinker +// should never actually be called! // void P_NullPrecipThinker(precipmobj_t *mobj) { - //(void)mobj; - mobj->precipflags &= ~PCF_THUNK; - R_ResetPrecipitationMobjInterpolationState(mobj); + (void)mobj; + I_Assert("P_NullPrecipThinker should not be called" == 0); } -void P_SnowThinker(precipmobj_t *mobj) +boolean P_PrecipThinker(precipmobj_t *mobj) { + if (mobj->lastThink == leveltime) + return true; // already thinked this tick + + mobj->lastThink = leveltime; + + R_ResetPrecipitationMobjInterpolationState(mobj); P_CycleStateAnimation((mobj_t *)mobj); + if (mobj->state == &states[S_RAINRETURN]) + { + // Reset to ceiling! + if (!P_SetPrecipMobjState(mobj, mobj->info->spawnstate)) + return false; + + mobj->z = mobj->ceilingz; + mobj->momz = mobj->info->speed; + mobj->precipflags &= ~PCF_SPLASH; + } + + if (mobj->tics != -1) + { + if (mobj->tics) + { + mobj->tics--; + } + + if (mobj->tics == 0) + { + if ((mobj->precipflags & PCF_SPLASH) && (mobj->state->nextstate == S_NULL)) + { + // HACK: sprite changes are 1 tic late, so you would see splashes on the ceiling if not for this state. + // We need to use the settings from the previous state, since some of those are NOT 1 tic late. + INT32 frame = (mobj->frame & ~FF_FRAMEMASK); + + if (!P_SetPrecipMobjState(mobj, S_RAINRETURN)) + return false; + + mobj->frame = frame; + return true; + } + else + { + if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) + return false; + } + } + } + + if (mobj->precipflags & PCF_SPLASH) + return true; + // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) { - mobj->z = mobj->ceilingz; - R_ResetPrecipitationMobjInterpolationState(mobj); - } -} + if ((mobj->info->deathstate == S_NULL) || (mobj->precipflags & PCF_PIT)) // no splashes on sky or bottomless pits + { + mobj->z = mobj->ceilingz; + } + else + { + if (!P_SetPrecipMobjState(mobj, mobj->info->deathstate)) + return false; -void P_RainThinker(precipmobj_t *mobj) -{ - P_CycleStateAnimation((mobj_t *)mobj); - - if (mobj->state != &states[S_RAIN1]) - { - // cycle through states, - // calling action functions at transitions - if (mobj->tics <= 0) - return; - - if (--mobj->tics) - return; - - if (!P_SetPrecipMobjState(mobj, mobj->state->nextstate)) - return; - - if (mobj->state != &states[S_RAINRETURN]) - return; - - mobj->z = mobj->ceilingz; - R_ResetPrecipitationMobjInterpolationState(mobj); - P_SetPrecipMobjState(mobj, S_RAIN1); - - return; + mobj->z = mobj->floorz; + mobj->precipflags |= PCF_SPLASH; + } } - // adjust height - if ((mobj->z += mobj->momz) > mobj->floorz) - return; - - // no splashes on sky or bottomless pits - if (mobj->precipflags & PCF_PIT) - { - mobj->z = mobj->ceilingz; - return; - } - - mobj->z = mobj->floorz; - P_SetPrecipMobjState(mobj, S_SPLASH1); + return true; } static void P_RingThinker(mobj_t *mobj) @@ -9903,17 +9922,21 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { + const mobjinfo_t *info = &mobjinfo[type]; state_t *st; precipmobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); fixed_t starting_floorz; + mobj->type = type; + mobj->info = info; + mobj->x = x; mobj->y = y; - mobj->flags = mobjinfo[type].flags; + mobj->flags = info->flags; // do not set the state with P_SetMobjState, // because action routines can not be called yet - st = &states[mobjinfo[type].spawnstate]; + st = &states[info->spawnstate]; mobj->state = st; mobj->tics = st->tics; @@ -9928,7 +9951,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->ceilingz = P_GetSectorCeilingZAt(mobj->subsector->sector, x, y); mobj->z = z; - mobj->momz = mobjinfo[type].speed; + mobj->momz = info->speed; mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; P_AddThinker(&mobj->thinker); @@ -9947,21 +9970,6 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype return mobj; } -static inline precipmobj_t *P_SpawnRainMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) -{ - precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); - mo->precipflags |= PCF_RAIN; - //mo->thinker.function.acp1 = (actionf_p1)P_RainThinker; - return mo; -} - -static inline precipmobj_t *P_SpawnSnowMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) -{ - precipmobj_t *mo = P_SpawnPrecipMobj(x,y,z,type); - //mo->thinker.function.acp1 = (actionf_p1)P_SnowThinker; - return mo; -} - // // P_RemoveMobj // @@ -10109,7 +10117,7 @@ boolean P_MobjWasRemoved(mobj_t *mobj) return true; } -void P_RemovePrecipMobj(precipmobj_t *mobj) +void P_FreePrecipMobj(precipmobj_t *mobj) { // unlink from sector and block lists P_UnsetPrecipThingPosition(mobj); @@ -10121,7 +10129,9 @@ void P_RemovePrecipMobj(precipmobj_t *mobj) } // free block - P_RemoveThinker((thinker_t *)mobj); + // Precipmobjs don't actually think using their thinker, + // so the free cannot be delayed. + P_UnlinkThinker((thinker_t*)mobj); } // Clearing out stuff for savegames @@ -10157,12 +10167,7 @@ void P_RemoveSavegameMobj(mobj_t *mobj) // free block // Here we use the same code as R_RemoveThinkerDelayed, but without reference counting (we're removing everything so it shouldn't matter) and without touching currentthinker since we aren't in P_RunThinkers - { - thinker_t *thinker = (thinker_t *)mobj; - thinker_t *next = thinker->next; - (next->prev = thinker->prev)->next = next; - Z_Free(thinker); - } + P_UnlinkThinker((thinker_t*)mobj); } static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}}; @@ -10216,7 +10221,7 @@ void P_SpawnPrecipitation(void) if (curWeather == PRECIP_SNOW) { - rainmo = P_SpawnSnowMobj(x, y, height, MT_SNOWFLAKE); + rainmo = P_SpawnPrecipMobj(x, y, height, MT_SNOWFLAKE); mrand = M_RandomByte(); if (mrand < 64) P_SetPrecipMobjState(rainmo, S_SNOW3); @@ -10224,7 +10229,7 @@ void P_SpawnPrecipitation(void) P_SetPrecipMobjState(rainmo, S_SNOW2); } else // everything else. - rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN); + rainmo = P_SpawnPrecipMobj(x, y, height, MT_RAIN); floorz = rainmo->floorz >> FRACBITS; ceilingz = rainmo->ceilingz >> FRACBITS; diff --git a/src/p_mobj.h b/src/p_mobj.h index a824edc6a..f6b27ae49 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -254,24 +254,21 @@ typedef enum // PRECIPITATION flags ?! ?! ?! // typedef enum { - // Don't draw. - PCF_INVISIBLE = 1, - // Above pit. - PCF_PIT = 2, - // Above FOF. - PCF_FOF = 4, - // Above MOVING FOF (this means we need to keep floorz up to date...) - PCF_MOVINGFOF = 8, - // Is rain. - PCF_RAIN = 16, - // Ran the thinker this tic. - PCF_THUNK = 32, + PCF_INVISIBLE = 1, // Don't draw. + PCF_PIT = 1<<1, // Above pit. + PCF_FOF = 1<<2, // Above FOF. + PCF_MOVINGFOF = 1<<3, // Above MOVING FOF (this means we need to keep floorz up to date...) + PCF_SPLASH = 1<<4, // Splashed on the ground, return to the ceiling after the animation's over + PCF_THUNK = 1<<5, // Ran the thinker this tic. } precipflag_t; // Map Object definition. typedef struct mobj_s { // List: thinker links. thinker_t thinker; + + mobjtype_t type; + const mobjinfo_t *info; // &mobjinfo[mobj->type] // Info for drawing: position. fixed_t x, y, z; @@ -345,9 +342,6 @@ typedef struct mobj_s struct mobj_s *hnext; struct mobj_s *hprev; - mobjtype_t type; - const mobjinfo_t *info; // &mobjinfo[mobj->type] - INT32 health; // for player this is rings + 1 // Movement direction, movement generation (zig-zagging). @@ -426,6 +420,9 @@ typedef struct precipmobj_s // List: thinker links. thinker_t thinker; + mobjtype_t type; + const mobjinfo_t *info; // &mobjinfo[mobj->type] + // Info for drawing: position. fixed_t x, y, z; fixed_t old_x, old_y, old_z; // position interpolation @@ -479,6 +476,7 @@ typedef struct precipmobj_s INT32 tics; // state tic counter state_t *state; INT32 flags; // flags from mobjinfo tables + tic_t lastThink; } precipmobj_t; typedef struct actioncache_s @@ -518,10 +516,9 @@ void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 numb boolean P_BossTargetPlayer(mobj_t *actor, boolean closest); boolean P_SupermanLook4Players(mobj_t *actor); void P_DestroyRobots(void); -void P_SnowThinker(precipmobj_t *mobj); -void P_RainThinker(precipmobj_t *mobj); +boolean P_PrecipThinker(precipmobj_t *mobj); void P_NullPrecipThinker(precipmobj_t *mobj); -void P_RemovePrecipMobj(precipmobj_t *mobj); +void P_FreePrecipMobj(precipmobj_t *mobj); void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_XYMovement(mobj_t *mo); void P_EmeraldManager(void); diff --git a/src/p_spec.c b/src/p_spec.c index 97ad38015..0051a5fcf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1782,7 +1782,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj = (precipmobj_t *)think; - P_RemovePrecipMobj(precipmobj); + P_FreePrecipMobj(precipmobj); } } else if (swap && !((swap == PRECIP_BLANK && curWeather == PRECIP_STORM_NORAIN) || (swap == PRECIP_STORM_NORAIN && curWeather == PRECIP_BLANK))) // Rather than respawn all that crap, reuse it! @@ -1809,7 +1809,6 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->precipflags &= ~PCF_INVISIBLE; - precipmobj->precipflags |= PCF_RAIN; //think->function.acp1 = (actionf_p1)P_RainThinker; } else if (swap == PRECIP_SNOW) // Rain To Snow @@ -1833,7 +1832,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->frame = st->frame; precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed; - precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_RAIN); + precipmobj->precipflags &= ~(PCF_INVISIBLE); //think->function.acp1 = (actionf_p1)P_SnowThinker; } diff --git a/src/p_tick.c b/src/p_tick.c index cf603af1d..453818257 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -68,8 +68,6 @@ void Command_Numthinkers_f(void) CONS_Printf(M_GetText("numthinkers <#>: Count number of thinkers\n")); CONS_Printf( "\t1: P_MobjThinker\n" - /*"\t2: P_RainThinker\n" - "\t3: P_SnowThinker\n"*/ "\t2: P_NullPrecipThinker\n" "\t3: T_Friction\n" "\t4: T_Pusher\n" @@ -85,14 +83,6 @@ void Command_Numthinkers_f(void) action = (actionf_p1)P_MobjThinker; CONS_Printf(M_GetText("Number of %s: "), "P_MobjThinker"); break; - /*case 2: - action = (actionf_p1)P_RainThinker; - CONS_Printf(M_GetText("Number of %s: "), "P_RainThinker"); - break; - case 3: - action = (actionf_p1)P_SnowThinker; - CONS_Printf(M_GetText("Number of %s: "), "P_SnowThinker"); - break;*/ case 2: action = (actionf_p1)P_NullPrecipThinker; CONS_Printf(M_GetText("Number of %s: "), "P_NullPrecipThinker"); @@ -228,21 +218,39 @@ static thinker_t *currentthinker; // void P_RemoveThinkerDelayed(void *pthinker) { - thinker_t *thinker = pthinker; - if (!thinker->references) - { - { - /* Remove from main thinker list */ - thinker_t *next = thinker->next; - /* Note that currentthinker is guaranteed to point to us, - * and since we're freeing our memory, we had better change that. So - * point it to thinker->prev, so the iterator will correctly move on to - * thinker->prev->next = thinker->next */ - (next->prev = currentthinker = thinker->prev)->next = next; - } - R_DestroyLevelInterpolators(thinker); - Z_Free(thinker); - } +#ifdef PARANOIA + if (thinker->next) + thinker->next = NULL; + else if (thinker->references) // Usually gets cleared up in one frame; what's going on here, then? + CONS_Printf("Number of potentially faulty references: %d\n", thinker->references); +#endif + if (thinker->references) + return; + + R_DestroyLevelInterpolators(thinker); + + /* Note that currentthinker is guaranteed to point to us, + * and since we're freeing our memory, we had better change that. So + * point it to thinker->prev, so the iterator will correctly move on to + * thinker->prev->next = thinker->next */ + currentthinker = thinker->prev; + /* Remove from main thinker list */ + P_UnlinkThinker(thinker); +} + +// +// P_UnlinkThinker() +// +// Actually removes thinker from the list and frees its memory. +// +void P_UnlinkThinker(thinker_t *thinker) +{ + thinker_t *next = thinker->next; + + I_Assert(thinker->references == 0); + + (next->prev = thinker->prev)->next = next; + Z_Free(thinker); } // diff --git a/src/r_things.c b/src/r_things.c index 0f5da1873..d1cb66c1e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1754,6 +1754,12 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) // uncapped/interpolation interpmobjstate_t interp = {0}; + // okay... this is a hack, but weather isn't networked, so it should be ok + if (!P_PrecipThinker(thing)) + { + return; + } + // do interpolation if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { @@ -1846,7 +1852,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) if (thing->subsector->sector->cullheight) { if (R_DoCulling(thing->subsector->sector->cullheight, viewsector->cullheight, viewz, gz, gzt)) - goto weatherthink; + return; } // store information in a vissprite @@ -1911,18 +1917,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->precip = true; vis->vflip = false; vis->isScaled = false; - -weatherthink: - // okay... this is a hack, but weather isn't networked, so it should be ok - if (!(thing->precipflags & PCF_THUNK)) - { - if (thing->precipflags & PCF_RAIN) - P_RainThinker(thing); - else - P_SnowThinker(thing); - thing->precipflags |= PCF_THUNK; - } - } // R_AddSprites -- 2.54.0 From a8e4f6e2ea59f75e6678d4de3269fc1979968f01 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 31 Jul 2024 06:07:49 +0200 Subject: [PATCH 399/525] Reapply "lol" This reverts commit 340450a67ed7b0f72ef22a817828264f5ccba132. --- src/p_mobj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index a69742842..23a19e1d6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3631,6 +3631,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) mobj->z = mobj->ceilingz; mobj->momz = mobj->info->speed; mobj->precipflags &= ~PCF_SPLASH; + R_ResetPrecipitationMobjInterpolationState(mobj); } if (mobj->tics != -1) @@ -3671,6 +3672,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) if ((mobj->info->deathstate == S_NULL) || (mobj->precipflags & PCF_PIT)) // no splashes on sky or bottomless pits { mobj->z = mobj->ceilingz; + R_ResetPrecipitationMobjInterpolationState(mobj); } else { @@ -3679,6 +3681,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) mobj->z = mobj->floorz; mobj->precipflags |= PCF_SPLASH; + R_ResetPrecipitationMobjInterpolationState(mobj); } } -- 2.54.0 From a2f4430378116a42d8829342d2519f18b9eb5668 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 31 Jul 2024 07:37:17 +0200 Subject: [PATCH 400/525] stuff --- src/p_spec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 0051a5fcf..3a86970ae 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1773,15 +1773,17 @@ void P_SwitchWeather(INT32 weathernum) if (purge) { thinker_t *think; + thinker_t *next; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thinkercap.next; think != &thinkercap; think = next) { + next = think->next; + if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker precipmobj = (precipmobj_t *)think; - P_FreePrecipMobj(precipmobj); } } @@ -1795,6 +1797,7 @@ void P_SwitchWeather(INT32 weathernum) { if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker + precipmobj = (precipmobj_t *)think; if (swap == PRECIP_RAIN) // Snow To Rain -- 2.54.0 From 31c5d8d67cdb70a569dad4c433c7006b4be3b566 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 05:42:36 +0200 Subject: [PATCH 401/525] fix precip switching --- src/p_spec.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 3a86970ae..e5068f99b 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1802,6 +1802,8 @@ void P_SwitchWeather(INT32 weathernum) if (swap == PRECIP_RAIN) // Snow To Rain { + precipmobj->type = MT_RAIN; // proper set the type + precipmobj->info = &mobjinfo[MT_RAIN]; precipmobj->flags = mobjinfo[MT_RAIN].flags; st = &states[mobjinfo[MT_RAIN].spawnstate]; precipmobj->state = st; @@ -1810,14 +1812,14 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->frame = st->frame; precipmobj->momz = mobjinfo[MT_RAIN].speed; - precipmobj->precipflags &= ~PCF_INVISIBLE; - - //think->function.acp1 = (actionf_p1)P_RainThinker; + precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to } else if (swap == PRECIP_SNOW) // Rain To Snow { INT32 z; + precipmobj->type = MT_SNOWFLAKE; // proper set the type + precipmobj->info = &mobjinfo[MT_SNOWFLAKE]; precipmobj->flags = mobjinfo[MT_SNOWFLAKE].flags; z = M_RandomByte(); @@ -1835,14 +1837,10 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->frame = st->frame; precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed; - precipmobj->precipflags &= ~(PCF_INVISIBLE); - - //think->function.acp1 = (actionf_p1)P_SnowThinker; + precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to } else if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. { - //think->function.acp1 = (actionf_p1)P_NullPrecipThinker; - precipmobj->precipflags |= PCF_INVISIBLE; } } -- 2.54.0 From b8038130b8fcdf5883da9555a53c451e84c2dcd0 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 05:51:35 +0200 Subject: [PATCH 402/525] fix conflict --- src/p_tick.c | 4 ++-- src/p_tick.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 453818257..7cf876188 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -216,7 +216,7 @@ static thinker_t *currentthinker; // remove it, and set currentthinker to one node preceeding it, so // that the next step in P_RunThinkers() will get its successor. // -void P_RemoveThinkerDelayed(void *pthinker) +void P_RemoveThinkerDelayed(thinker_t *thinker) { #ifdef PARANOIA if (thinker->next) @@ -268,7 +268,7 @@ void P_UnlinkThinker(thinker_t *thinker) void P_RemoveThinker(thinker_t *thinker) { LUA_InvalidateUserdata(thinker); - thinker->function.acp1 = P_RemoveThinkerDelayed; + thinker->function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; } /* diff --git a/src/p_tick.h b/src/p_tick.h index d22995a11..11b5889ed 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -28,7 +28,7 @@ void P_RunChaseCameras(void); void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); -void P_RemoveThinkerDelayed(void *pthinker); //killed +void P_RemoveThinkerDelayed(thinker_t *thinker); mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98 #endif -- 2.54.0 From fe853d4beea87058f9395508f919a059a89245c6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:43:21 +0200 Subject: [PATCH 403/525] fix compileur warnings idk if this is right lol --- src/p_inter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 5ffaf6dba..39babc14d 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -463,8 +463,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } else if (special->target->player->kartstuff[k_comebackmode] == 1 && P_CanPickupItem(player, 1)) { - mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); - S_StartSound(poof, special->info->seesound); + mobj_t *poof2 = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); + S_StartSound(poof2, special->info->seesound); // Karma fireworks for (i = 0; i < 5; i++) @@ -490,10 +490,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } else if (special->target->player->kartstuff[k_comebackmode] == 2 && P_CanPickupItem(player, 2)) { - mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); + mobj_t *poof3 = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); UINT8 ptadd = 1; // No WANTED bonus for tricking - S_StartSound(poof, special->info->seesound); + S_StartSound(poof3, special->info->seesound); if (player->kartstuff[k_bumper] == 1) // If you have only one bumper left, and see if it's a 1v1 { -- 2.54.0 From 8581d87e414870a6ebedfc895c6256bcbac0cbd4 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 16:27:28 +0200 Subject: [PATCH 404/525] toggle to scale weather with mobjscale toggle since it may tank performance on certain maps for some + may make visability worse --- src/hardware/hw_main.c | 5 +-- src/m_menu.c | 15 +++++---- src/p_mobj.c | 72 ++++++++++++++++++++++++------------------ src/r_main.c | 2 ++ src/r_main.h | 2 +- src/r_things.c | 2 +- 6 files changed, 58 insertions(+), 40 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1684bd6fe..d75c9b17e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4684,14 +4684,15 @@ static void HWR_AddPrecipitationSprites(void) { //const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; fixed_t drawdist; + fixed_t precipscale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th; if (current_bsp_culling_distance) - drawdist = min(current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * mapobjectscale); + drawdist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * precipscale); else - drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale; + drawdist = (fixed_t)(cv_drawdist_precip.value) * precipscale; // No to infinite precipitation draw distance. if (drawdist == 0) diff --git a/src/m_menu.c b/src/m_menu.c index 5dee26366..4c2f9b9af 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1479,19 +1479,20 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_HEADER, NULL, "Advanced Options", NULL, 10}, {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 20}, {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 30}, - {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 35}, + {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 35}, + {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 40}, - {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 45}, + {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 50}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 55}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 60}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 60}, + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 65}, #endif - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 70}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 75}, - {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 80}, + {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 85}, #endif }; @@ -1500,6 +1501,7 @@ static const char* OP_ExpTooltips[] = NULL, "How far Mobj interpolation should take effect.", "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", + "Should weather be scaled with Mapobjectscale?.", "When weather is on this will cut the object amount used in half.", "Toggle being able to see the sky.", #ifdef HWRENDER @@ -1517,6 +1519,7 @@ enum op_exp_header, op_exp_interpdist, op_exp_precipinter, + op_exp_precipmoscale, op_exp_lessprecip, op_exp_skybox, #ifdef HWRENDER diff --git a/src/p_mobj.c b/src/p_mobj.c index 23a19e1d6..390035c8a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10182,8 +10182,9 @@ consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHE void P_SpawnPrecipitation(void) { - INT32 i, mrand; - fixed_t basex, basey, x, y, height; + INT32 i, j, k, mrand; + fixed_t basex, basey, x, y, z, height; + fixed_t precipscale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; @@ -10196,10 +10197,9 @@ void P_SpawnPrecipitation(void) basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE; basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE; - //for (j = 0; j < cv_precipdensity.value; ++j) -- density is 1 for kart always + for (j = 0; j < FRACUNIT; j += precipscale) { - INT32 floorz; - INT32 ceilingz; + UINT16 numparticles = 0; x = ((cv_lessprecip.value ? basex*1.5 : basex) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); y = ((cv_lessprecip.value ? basey*1.5 : basey) + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3)); @@ -10215,37 +10215,49 @@ void P_SpawnPrecipitation(void) if (precipsector->sector->ceilingpic != skyflatnum) continue; + height = precipsector->sector->ceilingheight - precipsector->sector->floorheight; + height = FixedDiv(height, precipscale); + // Exists, but is too small for reasonable precipitation. - if (!(precipsector->sector->floorheight <= precipsector->sector->ceilingheight - (32<sector->ceilingheight; + // Hack around a quirk of this entire system, where taller sectors look like they get less precipitation. + numparticles = 1 + (height / (MAPBLOCKUNITS<<4<sector->ceilingheight; - floorz = rainmo->floorz >> FRACBITS; - ceilingz = rainmo->ceilingz >> FRACBITS; + for (k = 0; k < numparticles; k++) + { + INT32 floorz; + INT32 ceilingz; - if (floorz < ceilingz) - { - // Randomly assign a height, now that floorz is set. - rainmo->z = M_RandomRange(floorz, ceilingz) << FRACBITS; - } - else - { - // ...except if the floor is above the ceiling. - rainmo->z = ceilingz << FRACBITS; + if (curWeather == PRECIP_SNOW) + { + rainmo = P_SpawnPrecipMobj(x, y, z, MT_SNOWFLAKE); + mrand = M_RandomByte(); + if (mrand < 64) + P_SetPrecipMobjState(rainmo, S_SNOW3); + else if (mrand < 144) + P_SetPrecipMobjState(rainmo, S_SNOW2); + } + else // everything else. + rainmo = P_SpawnPrecipMobj(x, y, z, MT_RAIN); + + floorz = rainmo->floorz >> FRACBITS; + ceilingz = rainmo->ceilingz >> FRACBITS; + + if (floorz < ceilingz) + { + // Randomly assign a height, now that floorz is set. + rainmo->z = M_RandomRange(floorz, ceilingz) << FRACBITS; + } + else + { + // ...except if the floor is above the ceiling. + rainmo->z = ceilingz << FRACBITS; + } } } } diff --git a/src/r_main.c b/src/r_main.c index fb3ca1c1c..a92fd8f43 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -210,6 +210,7 @@ consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, N consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1841,6 +1842,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_drawdist); CV_RegisterVar(&cv_drawdist_precip); CV_RegisterVar(&cv_lessprecip); + CV_RegisterVar(&cv_mobjscaleprecip); CV_RegisterVar(&cv_fov); CV_RegisterVar(&cv_chasecam); diff --git a/src/r_main.h b/src/r_main.h index a271a3b1d..490f793f9 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -117,7 +117,7 @@ extern consvar_t cv_flipcam, cv_flipcam2, cv_flipcam3, cv_flipcam4; extern consvar_t cv_shadow, cv_shadowoffs; extern consvar_t cv_ffloorclip, cv_spriteclip; extern consvar_t cv_translucency; -extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip; +extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip, cv_mobjscaleprecip; extern consvar_t cv_fov; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; diff --git a/src/r_things.c b/src/r_things.c index d1cb66c1e..ad1e3ca05 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2052,7 +2052,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // void R_AddPrecipitationSprites(void) { - const fixed_t drawdist = (fixed_t)(cv_drawdist_precip.value) * mapobjectscale; + fixed_t drawdist = (fixed_t)(cv_drawdist_precip.value) * (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th, *next; -- 2.54.0 From e2c3d5b20d6c20728f22a6a31936308eba7e2b62 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 16:28:45 +0200 Subject: [PATCH 405/525] respawn precip when toggling any of its settings --- src/r_main.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index a92fd8f43..f4867d63e 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -16,6 +16,7 @@ #include "doomdef.h" #include "g_game.h" #include "g_input.h" +#include "g_state.h" #include "r_local.h" #include "r_splats.h" // faB(21jan): testing #include "r_sky.h" @@ -185,6 +186,8 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); +static void Precipstuff_OnChange(void); + consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_chasecam = {"chasecam", "On", CV_CALL, CV_OnOff, ChaseCam_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_chasecam2 = {"chasecam2", "On", CV_CALL, CV_OnOff, ChaseCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -208,9 +211,9 @@ consvar_t cv_uncappedhud = {"uncappedhud", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NU consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE|CV_CALL|CV_NOINIT, drawdist_precip_cons_t, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -330,6 +333,29 @@ static void FlipCam4_OnChange(void) SendWeaponPref4(); } +static void Precipstuff_OnChange(void) +{ + if (gamestate != GS_LEVEL) + return; + + thinker_t *think; + thinker_t *next; + precipmobj_t *precipmobj; + + for (think = thinkercap.next; think != &thinkercap; think = next) + { + next = think->next; + + if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) + continue; // not a precipmobj thinker + + precipmobj = (precipmobj_t *)think; + P_FreePrecipMobj(precipmobj); + } + + P_SpawnPrecipitation(); +} + // // R_PointOnSide // Traverse BSP (sub) tree, -- 2.54.0 From d7c1b12dbd7811574ebd50116ff874777a76bc7c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Aug 2024 18:26:18 +0200 Subject: [PATCH 406/525] changes to saturn menu -Add new Saturn Hud options menu to declutter normal saturn options - If in any of the hud options the game will force display the kart hud and disable the fade background - i hate m_menu --- src/k_kart.c | 18 +++-- src/m_menu.c | 183 ++++++++++++++++++++++++++++++------------------- src/m_menu.h | 6 +- src/st_stuff.c | 4 +- 4 files changed, 133 insertions(+), 78 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 2ef1ffa68..ad175397a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -88,7 +88,7 @@ consvar_t cv_saltyhopsfx = {"hardcodehopsfx", "On", CV_SAVE, CV_OnOff, NULL, 0, consvar_t cv_saltysquish = {"hardcodehopsquish", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //Colourized HUD -consvar_t cv_colorizedhud = {"colorizedhud", "Off", CV_SAVE|CV_CALL, CV_OnOff, Saturn_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_colorizedhud = {"colorizedhud", "Off", CV_SAVE|CV_CALL, CV_OnOff, SaturnHud_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_colorizeditembox = {"colorizeditembox", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t HudColor_cons_t[MAXSKINCOLORS+1]; @@ -7637,7 +7637,7 @@ static void K_initKartHUD(void) } } - if (timeinmap > 113) + if (timeinmap > 113 || forceshowhud) hudtrans = cv_translucenthud.value; else if (timeinmap > 105) hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105); @@ -9366,9 +9366,17 @@ static void K_drawDriftGauge(void) 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 }; - if (!stplyr->mo || !stplyr->kartstuff[k_drift] || (!splitscreen && !camera->chase)) + if (!stplyr->mo || (!splitscreen && !camera->chase)) return; + if (forceshowhud) + goto skipcrap; // i will skip the drift early return and you cant stop me! + + if (!stplyr->kartstuff[k_drift]) + return; + +skipcrap: + if (!K_GetScreenCoords(&pos, stplyr, stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale), false)) return; @@ -9746,7 +9754,9 @@ static void K_drawKartMinimap(void) splitflags = info.flags; - if (timeinmap > 105) + if (forceshowhud) + minimaptrans = cv_kartminimap.value; + else if (timeinmap > 105) { minimaptrans = cv_kartminimap.value; if (timeinmap <= 113) diff --git a/src/m_menu.c b/src/m_menu.c index 4c2f9b9af..d4d2c6266 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -361,6 +361,7 @@ static void M_DeleteProtocol(void); // Saturn menu_t OP_SaturnDef; +menu_t OP_SaturnHudDef; menu_t OP_HudOffsetDef; menu_t OP_PlayerDistortDef; menu_t OP_SaturnCreditsDef; @@ -461,6 +462,9 @@ static void Newgametype_OnChange(void); static void Dummymenuplayer_OnChange(void); static void Dummystaff_OnChange(void); +// crap to force hud to show when in saturns hud options +boolean forceshowhud = false; + // ========================================================================== // CONSOLE VARIABLES AND THEIR POSSIBLE VALUES GO HERE. // ========================================================================== @@ -2044,37 +2048,19 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Serverqueue waittime", &cv_connectawaittime, 10}, {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, - {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 25}, - {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 30}, - {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 35}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 40}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 45}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 50}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 55}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 60}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 65}, - {IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 70}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, - {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 85}, + {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 30}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 95}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 40}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 45}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 100}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 105}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 110}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 55}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 120}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 65}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 130}, - - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 140}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 145}, - - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 155}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 160}, - - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 170}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 75}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 80}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 85}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2082,28 +2068,13 @@ static const char* OP_SaturnTooltips[] = NULL, "How long can the game wait before it kicks you out from the server\nconnecting screen.", "How much speen do you want?", - "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", - "Change what style the speedometer is.", - "Enable the stat display.", - "Show Lap Time when doing a Lap on the Timer.", - "Enable the use of the higher resolution want icons instead of rank\nfor some places.", - "Enable colourized hud.", - "Enable the colourized itembox when colourized hud is enabled.", - "The color to use instead of the player color when\ncolourized hud is enabled.", - "Show the big 'LAP' text on a lap change.", - "Show player names on the minimap.", - "Minimize the player icons on the minimap.", "Makes the Camera Lagless in netgames.", - "Uncaps the HUD framerate, making it appear smoother.", - "Show the big Cecho Messages.", "Show Localskin Menus.", "Force menu to only use uppercase.", "Use your desired Keyboard Layout for Text Input\nthis is either the Default, Native or Azerty\nNative does not affect Gameplay only Text!", "Disables the flicker effect on Midnight Channel.", - "Nametag Options.", - "Driftgauge Options.", + "Options for Saturn specific HUD things.", "Options for sprite distortion effects.", - "Move position of HUD elements.", "See the people who helped make this project possible!", }; @@ -2112,28 +2083,13 @@ enum sm_header, sm_waittime, sm_skinselspeed, - sm_input, - sm_speedometer, - sm_statdisplay, - sm_laptime, - sm_highresport, - sm_colorhud, - sm_coloritem, - sm_colorhud_customcolor, - sm_lapemblem, - sm_mapnames, - sm_smallmap, sm_laglesscam, - sm_uncappedhud, - sm_cechotogle, sm_showlocalskin, op_uppercase_menu, sm_nativkey, sm_pisschannel, - sm_nametagmen, - sm_driftgaugemen, + sm_hud, sm_distortionmenu, - sm_hudoffsets, sm_credits, }; @@ -2183,6 +2139,80 @@ enum saltsquishy, }; +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, "Input Display outside of RA", &cv_showinput, 15}, + + {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 20}, + + {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 25}, + + {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 30}, + + {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 35}, + {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 40}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 45}, + + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 55}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 60}, + + {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 65}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 70}, + + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 80}, + + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 90}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 95}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 105}, +}; + +static const char* OP_SaturnHudTooltips[] = +{ + NULL, + "Change what style the speedometer is.", + "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", + "Enable the stat display.", + "Show Lap Time when doing a Lap on the Timer.", + "Enable the use of the higher resolution want icons instead of rank\nfor some places.", + "Enable colourized hud.", + "Enable the colourized itembox when colourized hud is enabled.", + "The color to use instead of the player color when\ncolourized hud is enabled.", + "Show the big 'LAP' text on a lap change.", + "Show the big Cecho Messages.", + "Show player names on the minimap.", + "Minimize the player icons on the minimap.", + "Uncaps the HUD framerate, making it appear smoother.", + "Nametag Options.", + "Driftgauge Options.", + "Move position of HUD elements.", +}; + +enum +{ + sh_header, + sh_speedometer, + sh_input, + sh_laptime, + sh_statdisplay, + sh_highresport, + sh_colorhud, + sh_coloritem, + sh_colorhud_customcolor, + sh_lapemblem, + sh_cechotogle, + sh_mapname, + sh_smallmap, + sh_uncappedhud, + sh_nametagmen, + sh_driftgaugemen, + sh_hudoffsets, +}; + + static menuitem_t OP_HudOffsetMenu[] = { {IT_HEADER, NULL, "Kart Hud Offsets", NULL, 0}, @@ -2952,13 +2982,15 @@ menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOp menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30); menu_t OP_PlayerDistortDef = DEFAULTMENUSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30); -menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnDef, 30, 30); +menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30); +menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30); + menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 10); menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); -menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnDef, 30, 40); -menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnDef, 30, 60); +menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnHudDef, 30, 40); +menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnHudDef, 30, 40); menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60); menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60); @@ -3283,7 +3315,7 @@ void Bird_menu_Onchange(void) } //menu code is nice -void Saturn_menu_Onchange(void) +void SaturnHud_menu_Onchange(void) { UINT16 status; @@ -3292,8 +3324,8 @@ void Saturn_menu_Onchange(void) else status = IT_GRAYEDOUT; - OP_SaturnMenu[sm_coloritem].status = status; - OP_SaturnMenu[sm_colorhud_customcolor].status = status; + OP_SaturnHudMenu[sh_coloritem].status = status; + OP_SaturnHudMenu[sh_colorhud_customcolor].status = status; } // ========================================================================== @@ -4101,7 +4133,6 @@ boolean M_DemoResponder(event_t *ev) return eatinput; } - // // M_Drawer // Called after the view has been rendered, @@ -4112,10 +4143,12 @@ void M_Drawer(void) if (currentMenu == &MessageDef) menuactive = true; + forceshowhud = gamestate == GS_LEVEL && menuactive && (currentMenu == &OP_SaturnHudDef || currentMenu == &OP_HudOffsetDef || currentMenu == &OP_NametagDef || currentMenu == &OP_DriftGaugeDef); // holy fuick + if (menuactive) { // now that's more readable with a faded background (yeah like Quake...) - if (!WipeInAction && currentMenu != &PlaybackMenuDef) // Replay playback has its own background + if (!WipeInAction && currentMenu != &PlaybackMenuDef && !forceshowhud) // Replay playback has its own background V_DrawFadeScreen(0xFF00, 16); if (currentMenu->drawroutine) @@ -4560,7 +4593,7 @@ void M_Init(void) #endif if (!xtra_speedo && !kartzspeedo && !achi_speedo) // why bother? - OP_SaturnMenu[sm_speedometer].status = IT_GRAYEDOUT; + OP_SaturnHudMenu[sh_speedometer].status = IT_GRAYEDOUT; //if (!xtra_speedo && kartzspeedo) //OP_SaturnMenu[sm_speedometer].text = "Speedometer (No Small)"; @@ -4571,9 +4604,9 @@ void M_Init(void) if (!clr_hud) // uhguauhauguuhee { - OP_SaturnMenu[sm_colorhud].status = IT_GRAYEDOUT; - OP_SaturnMenu[sm_coloritem].status = IT_GRAYEDOUT; - OP_SaturnMenu[sm_colorhud_customcolor].status = IT_GRAYEDOUT; + OP_SaturnHudMenu[sh_colorhud].status = IT_GRAYEDOUT; + OP_SaturnHudMenu[sh_coloritem].status = IT_GRAYEDOUT; + OP_SaturnHudMenu[sh_colorhud_customcolor].status = IT_GRAYEDOUT; } if (!nametaggfx) @@ -5361,6 +5394,16 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } + + if (currentMenu == &OP_SaturnHudDef) + { + if (!(OP_SaturnHudTooltips[itemOn] == NULL)) + { + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SaturnHudTooltips[itemOn], coolalphatimer); + if (coolalphatimer > 0 && interpTimerHackAllow) + coolalphatimer--; + } + } } static void M_DrawPauseMenu(void) diff --git a/src/m_menu.h b/src/m_menu.h index e74fd491f..570d8a94d 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -21,6 +21,8 @@ #include "mserv.h" #include "r_things.h" // for SKINNAMESIZE +extern boolean forceshowhud; + // // MENUS // @@ -290,8 +292,8 @@ void PDistort_menu_Onchange(void); // Bird menu updating void Bird_menu_Onchange(void); -// Saturn menu updating -void Saturn_menu_Onchange(void); +// Saturn Hud menu updating +void SaturnHud_menu_Onchange(void); void M_ReplayHut(INT32 choice); void M_SetPlaybackMenuPointer(void); diff --git a/src/st_stuff.c b/src/st_stuff.c index afbf74b8f..419b527c2 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -709,7 +709,7 @@ static void ST_overlayDrawer(void) } } - if (!(netgame || multiplayer) || !hu_showscores) + if ((!(netgame || multiplayer) || !hu_showscores) && !forceshowhud) { if (renderisnewtic) { @@ -718,7 +718,7 @@ static void ST_overlayDrawer(void) } // draw level title Tails - if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) && LUA_HudEnabled(hud_stagetitle)) + if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) && LUA_HudEnabled(hud_stagetitle) && !forceshowhud) ST_drawLevelTitle(); if (!hu_showscores && netgame && !mapreset) -- 2.54.0 From c11d9255808774e607283c6fe42a2e4b356ab2dc Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Aug 2024 02:35:42 +0200 Subject: [PATCH 407/525] optimize z position checking for mobjs without collision and camera idk how much this does tbh only for stuff without collision since it may desynch otherwise based on https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2214 and https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2250 --- src/p_mobj.c | 8 ++++---- src/r_main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/r_main.h | 1 + 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 390035c8a..8a0147194 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -616,7 +616,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (((mobj->flags & MF_NOBLOCKMAP) && (mobj->flags & MF_NOCLIP)) ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -692,7 +692,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (((mobj->flags & MF_NOBLOCKMAP) && (mobj->flags & MF_NOCLIP)) ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -770,7 +770,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -847,7 +847,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point diff --git a/src/r_main.c b/src/r_main.c index f4867d63e..e6247ceae 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1125,6 +1125,51 @@ void R_Init(void) framecount = 0; } +// +// R_IsPointInSector +// +boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y) +{ + size_t i; + size_t passes = 0; + + for (i = 0; i < sector->linecount; i++) + { + line_t *line = sector->lines[i]; + vertex_t *v1, *v2; + + if (line->frontsector == line->backsector) + continue; + + v1 = line->v1; + v2 = line->v2; + + // make sure v1 is below v2 + if (v1->y > v2->y) + { + vertex_t *tmp = v1; + v1 = v2; + v2 = tmp; + } + else if (v1->y == v2->y) + // horizontal line, we can't match this + continue; + + if (v1->y < y && y <= v2->y) + { + // if the y axis in inside the line, find the point where we intersect on the x axis... + fixed_t vx = v1->x + (INT64)(v2->x - v1->x) * (y - v1->y) / (v2->y - v1->y); + + // ...and if that point is to the left of the point, count it as inside. + if (vx < x) + passes++; + } + } + + // and odd number of passes means we're inside the polygon. + return passes % 2; +} + // // R_PointInSubsector // diff --git a/src/r_main.h b/src/r_main.h index 490f793f9..81bff3811 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -76,6 +76,7 @@ angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); angle_t R_PlayerSliptideAngle(player_t *player); fixed_t R_ScaleFromGlobalAngle(angle_t visangle); +boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y); subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); -- 2.54.0 From 28d8e84d6bfefc23e6d3d7ac9e4cf920f9d3246d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Aug 2024 17:08:38 +0200 Subject: [PATCH 408/525] this can be static and inlined --- src/d_clisrv.c | 2 +- src/d_clisrv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 10d46689a..1efd88623 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -223,7 +223,7 @@ UINT16 software_MAXPACKETLENGTH; * \return The full tic value * */ -tic_t ExpandTics(INT32 low, tic_t basetic) +static inline tic_t ExpandTics(INT32 low, tic_t basetic) { INT32 delta; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 13c2bc353..6ddeb09bb 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -574,7 +574,7 @@ extern consvar_t cv_connectawaittime; extern consvar_t cv_discordinvites; // Used in d_net, the only dependence -tic_t ExpandTics(INT32 low, tic_t basetic); +//tic_t ExpandTics(INT32 low, tic_t basetic); void D_ClientServerInit(void); // Initialise the other field -- 2.54.0 From 42fa29f78b785ba8329a751d08f5adb18b8f52c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 17:39:17 +0200 Subject: [PATCH 409/525] =?UTF-8?q?make=20timer=20flash=20at=2099=C2=B459?= =?UTF-8?q?=C2=B499=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/k_kart.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ad175397a..e344a6d63 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8227,39 +8227,36 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI { tic_t worktime = drawtime/(60*TICRATE); - if (worktime >= 100) - { - worktime = 99; - drawtime = (100*(60*TICRATE))-1; - } - - if ((cv_timelimit.value && G_BattleGametype()) && (!players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2)) && cv_overtime.value)) // i hate this so much + if ((G_BattleGametype() && cv_timelimit.value) && (!players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2)) && cv_overtime.value)) // i hate this so much { V_DrawKartString(TX, TY+3, splitflags, va("OVERTIME")); - return; } + else if (worktime < 100) + { + // minutes time 00 __ __ + V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime%10)); - // minutes time 00 __ __ - V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime%10)); + // apostrophe location _'__ __ + V_DrawKartString(TX+24, TY+3, splitflags, va("'")); - // apostrophe location _'__ __ - V_DrawKartString(TX+24, TY+3, splitflags, va("'")); + worktime = (drawtime/TICRATE % 60); - worktime = (drawtime/TICRATE % 60); + // seconds time _ 00 __ + V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime%10)); - // seconds time _ 00 __ - V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime%10)); + // quotation mark location _ __"__ + V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); - // quotation mark location _ __"__ - V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); + worktime = G_TicsToCentiseconds(drawtime); - worktime = G_TicsToCentiseconds(drawtime); - - // tics _ __ 00 - V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime%10)); + // tics _ __ 00 + V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime%10)); + } + else if ((drawtime/TICRATE) & 1) + V_DrawKartString(TX, TY+3, splitflags, va("99'59\"99")); } if (emblemmap && (modeattacking || (mode == 1)) && !demo.playback) // emblem time! -- 2.54.0 From 91fac0880d22382b25f92301271401a4c3405cbe Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:01:12 +0200 Subject: [PATCH 410/525] add battlespeedometer to saturn hud menu + apply offset to bumper gfx when enabled --- src/k_kart.c | 8 ++++++++ src/m_menu.c | 34 +++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e344a6d63..7ed4f5482 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8924,6 +8924,14 @@ static void K_drawKartBumpersOrKarma(void) fy = info.y; fflags = info.flags; + if (cv_battlespeedo.value) + { + if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 5 && xtra_speedo3)) + fy -= -10; + else + fy -= -14; + } + if (splitscreen > 1) { if (stplyr->kartstuff[k_bumper] <= 0) diff --git a/src/m_menu.c b/src/m_menu.c index d4d2c6266..32ad2261f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2144,36 +2144,39 @@ 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, "Input Display outside of RA", &cv_showinput, 15}, + {IT_STRING | IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 20}, + {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 20}, - {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 25}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 25}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 30}, + {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 30}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 35}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 40}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 45}, + {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 35}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 55}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 60}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 40}, + {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 45}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 50}, - {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 65}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 70}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 60}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 65}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 80}, + {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 70}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 95}, + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 85}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 105}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 95}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 100}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 110}, }; static const char* OP_SaturnHudTooltips[] = { NULL, "Change what style the speedometer is.", + "Draw the Speedometer in Battle.", "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", "Enable the stat display.", "Show Lap Time when doing a Lap on the Timer.", @@ -2195,6 +2198,7 @@ enum { sh_header, sh_speedometer, + sh_battlespeedo, sh_input, sh_laptime, sh_statdisplay, -- 2.54.0 From 565f36d4b7c5cd4cde33820658e276ae3c0f292a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:10:52 +0200 Subject: [PATCH 411/525] forgor speedo doesent draw in splitscreen + change offsets --- src/k_kart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7ed4f5482..e3cf249b2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8924,12 +8924,12 @@ static void K_drawKartBumpersOrKarma(void) fy = info.y; fflags = info.flags; - if (cv_battlespeedo.value) + if (cv_battlespeedo.value && !splitscreen) { if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 5 && xtra_speedo3)) - fy -= -10; + fy += 5; else - fy -= -14; + fy += 7; } if (splitscreen > 1) -- 2.54.0 From 76ed4aae121735793acae72180e1be4b3eb972d1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:10:52 +0200 Subject: [PATCH 412/525] forgor speedo doesent draw in splitscreen + change offsets --- src/k_kart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7ed4f5482..e3cf249b2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8924,12 +8924,12 @@ static void K_drawKartBumpersOrKarma(void) fy = info.y; fflags = info.flags; - if (cv_battlespeedo.value) + if (cv_battlespeedo.value && !splitscreen) { if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 5 && xtra_speedo3)) - fy -= -10; + fy += 5; else - fy -= -14; + fy += 7; } if (splitscreen > 1) -- 2.54.0 From 3e245d49d8ac8d4d0f642a42010d4da4546fa2eb Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:34:37 +0200 Subject: [PATCH 413/525] super tiny cleanup m_menu again --- src/m_menu.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 6a888b0f7..4d69efe49 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1053,7 +1053,6 @@ static menuitem_t MP_MainMenu[] = }; #ifndef NONET - static menuitem_t MP_ServerMenu[] = { {IT_STRING|IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 10}, @@ -1069,7 +1068,6 @@ static menuitem_t MP_ServerMenu[] = {IT_WHITESTRING|IT_CALL, NULL, "Start", M_StartServer, 130}, }; - #endif // Separated offline and normal servers. @@ -1088,9 +1086,6 @@ static menuitem_t MP_PlayerSetupMenu[] = {IT_KEYHANDLER | IT_STRING, NULL, "Color", M_HandleSetupMultiPlayer, 152}, }; - - - #ifndef NONET static menuitem_t MP_ConnectMenu[] = { @@ -1895,7 +1890,6 @@ static menuitem_t OP_ServerOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Server Name", &cv_servername, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, @@ -1935,13 +1929,10 @@ static const char* OP_ServerOptionsTooltips[] = static menuitem_t OP_AdvServerOptionsMenu[] = { #ifndef MASTERSERVER - {IT_GRAYEDOUT, - - NULL, "Server Browser Address", NULL, 10}, + {IT_GRAYEDOUT, NULL, "Server Browser Address", NULL, 10}, #else {IT_STRING | IT_CVAR | IT_CV_STRING, - - NULL, "Server Browser Address", &cv_masterserver, 10}, + NULL, "Server Browser Address", &cv_masterserver, 10}, #endif {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, -- 2.54.0 From 594931e07e288917acbd790856e8ceeab685d619 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:44:28 +0200 Subject: [PATCH 414/525] when looking back camera momentum should inherit the mom of the player makes using shoes or any boost stuff less jarring when looking back --- src/p_user.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 6aa3ee7a7..14d60ddbd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3888,6 +3888,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { thiscam->momx = x - thiscam->x; thiscam->momy = y - thiscam->y; + + // when looking back, camera's momentum + // should inherit the momentum of the player + if (lookback && lookbackdelay[num]) + { + thiscam->momx += mo->momx; + thiscam->momy += mo->momy; + } + thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); } -- 2.54.0 From 783ce7bada0afb8ce0aafe0d95007f1b47c27aff Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:45:29 +0200 Subject: [PATCH 415/525] give camera lookback a toggle + extra option --- src/p_local.h | 2 ++ src/p_user.c | 10 +++++++--- src/r_main.c | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 725aa20d1..4eb927a58 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -144,6 +144,8 @@ extern consvar_t cv_tiltsmoothing; extern consvar_t cv_actionmovie; +extern consvar_t cv_lookbackmom; + extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; extern fixed_t t_cam3_dist, t_cam3_height, t_cam3_rotate; diff --git a/src/p_user.c b/src/p_user.c index 14d60ddbd..f9d909cd5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3073,6 +3073,9 @@ consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Extra Momentum"}, {0, NULL}}; +consvar_t cv_lookbackmom = {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + fixed_t t_cam_dist = -42; fixed_t t_cam_height = -42; fixed_t t_cam_rotate = -42; @@ -3891,10 +3894,11 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // when looking back, camera's momentum // should inherit the momentum of the player - if (lookback && lookbackdelay[num]) + // if value is 2, add extra + if (cv_lookbackmom.value && lookback && lookbackdelay[num]) { - thiscam->momx += mo->momx; - thiscam->momy += mo->momy; + thiscam->momx += cv_lookbackmom.value*mo->momx; + thiscam->momy += cv_lookbackmom.value*mo->momy; } thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); diff --git a/src/r_main.c b/src/r_main.c index e6247ceae..abf2d8310 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1959,6 +1959,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_tiltsmoothing); CV_RegisterVar(&cv_actionmovie); + CV_RegisterVar(&cv_lookbackmom); + CV_RegisterVar(&cv_driftsparkpulse); CV_RegisterVar(&cv_gravstretch); CV_RegisterVar(&cv_sloperoll); -- 2.54.0 From e2ac9708cb12ba06bf4eacc1597b2c5cf9b2c9d9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:34:37 +0200 Subject: [PATCH 416/525] super tiny cleanup m_menu again --- src/m_menu.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 32ad2261f..bd8718e63 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1053,7 +1053,6 @@ static menuitem_t MP_MainMenu[] = }; #ifndef NONET - static menuitem_t MP_ServerMenu[] = { {IT_STRING|IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 10}, @@ -1069,7 +1068,6 @@ static menuitem_t MP_ServerMenu[] = {IT_WHITESTRING|IT_CALL, NULL, "Start", M_StartServer, 130}, }; - #endif // Separated offline and normal servers. @@ -1088,9 +1086,6 @@ static menuitem_t MP_PlayerSetupMenu[] = {IT_KEYHANDLER | IT_STRING, NULL, "Color", M_HandleSetupMultiPlayer, 152}, }; - - - #ifndef NONET static menuitem_t MP_ConnectMenu[] = { @@ -1895,7 +1890,6 @@ static menuitem_t OP_ServerOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Server Name", &cv_servername, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, @@ -1935,13 +1929,10 @@ static const char* OP_ServerOptionsTooltips[] = static menuitem_t OP_AdvServerOptionsMenu[] = { #ifndef MASTERSERVER - {IT_GRAYEDOUT, - - NULL, "Server Browser Address", NULL, 10}, + {IT_GRAYEDOUT, NULL, "Server Browser Address", NULL, 10}, #else {IT_STRING | IT_CVAR | IT_CV_STRING, - - NULL, "Server Browser Address", &cv_masterserver, 10}, + NULL, "Server Browser Address", &cv_masterserver, 10}, #endif {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 50}, -- 2.54.0 From ba331caff607a85bc5e53cefc12ea3d4b175256c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:44:28 +0200 Subject: [PATCH 417/525] when looking back camera momentum should inherit the mom of the player makes using shoes or any boost stuff less jarring when looking back --- src/p_user.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 6aa3ee7a7..14d60ddbd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3888,6 +3888,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { thiscam->momx = x - thiscam->x; thiscam->momy = y - thiscam->y; + + // when looking back, camera's momentum + // should inherit the momentum of the player + if (lookback && lookbackdelay[num]) + { + thiscam->momx += mo->momx; + thiscam->momy += mo->momy; + } + thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); } -- 2.54.0 From 036df817f1c9cf061dfa6addf968f6ab3f8788bb Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:45:29 +0200 Subject: [PATCH 418/525] give camera lookback a toggle + extra option --- src/p_local.h | 2 ++ src/p_user.c | 10 +++++++--- src/r_main.c | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 725aa20d1..4eb927a58 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -144,6 +144,8 @@ extern consvar_t cv_tiltsmoothing; extern consvar_t cv_actionmovie; +extern consvar_t cv_lookbackmom; + extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; extern fixed_t t_cam3_dist, t_cam3_height, t_cam3_rotate; diff --git a/src/p_user.c b/src/p_user.c index 14d60ddbd..f9d909cd5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3073,6 +3073,9 @@ consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Extra Momentum"}, {0, NULL}}; +consvar_t cv_lookbackmom = {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + fixed_t t_cam_dist = -42; fixed_t t_cam_height = -42; fixed_t t_cam_rotate = -42; @@ -3891,10 +3894,11 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // when looking back, camera's momentum // should inherit the momentum of the player - if (lookback && lookbackdelay[num]) + // if value is 2, add extra + if (cv_lookbackmom.value && lookback && lookbackdelay[num]) { - thiscam->momx += mo->momx; - thiscam->momy += mo->momy; + thiscam->momx += cv_lookbackmom.value*mo->momx; + thiscam->momy += cv_lookbackmom.value*mo->momy; } thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); diff --git a/src/r_main.c b/src/r_main.c index e6247ceae..abf2d8310 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1959,6 +1959,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_tiltsmoothing); CV_RegisterVar(&cv_actionmovie); + CV_RegisterVar(&cv_lookbackmom); + CV_RegisterVar(&cv_driftsparkpulse); CV_RegisterVar(&cv_gravstretch); CV_RegisterVar(&cv_sloperoll); -- 2.54.0 From 0504a355d2722460ef8a39ad5e8f6a4509d7af4f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 19:51:49 +0200 Subject: [PATCH 419/525] add camera options menu --- src/m_menu.c | 186 +++++++++++++++++++++++++++++++++++++++++---------- src/p_user.c | 2 +- 2 files changed, 150 insertions(+), 38 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index bd8718e63..4fd5aa3bb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -324,6 +324,10 @@ static void M_AssignJoystick(INT32 choice); static void M_ChangeControl(INT32 choice); static void M_ResetControls(INT32 choice); +//camera options menu +menu_t OP_CamOptionsDef; +menu_t OP_Player1CamOptionsDef, OP_Player2CamOptionsDef, OP_Player3CamOptionsDef, OP_Player4CamOptionsDef; + // Video & Sound menu_t OP_VideoOptionsDef, OP_VideoModeDef, OP_ExpOptionsDef, OP_ColorOptionsDef; #ifdef HWRENDER @@ -1123,23 +1127,24 @@ static menuitem_t OP_MainMenu[] = { {IT_SUBMENU|IT_STRING, NULL, "Control Setup...", &OP_ControlsDef, 0}, - {IT_SUBMENU|IT_STRING, NULL, "Video Options...", &OP_VideoOptionsDef, 20}, - {IT_SUBMENU|IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 30}, + {IT_SUBMENU|IT_STRING, NULL, "Video Options...", &OP_VideoOptionsDef, 15}, + {IT_SUBMENU|IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 25}, - {IT_SUBMENU|IT_STRING, NULL, "HUD Options...", &OP_HUDOptionsDef, 50}, - {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 60}, - {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 70}, + {IT_SUBMENU|IT_STRING, NULL, "HUD Options...", &OP_HUDOptionsDef, 45}, + {IT_SUBMENU|IT_STRING, NULL, "Camera Options...", &OP_CamOptionsDef, 55}, + {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 65}, + {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 75}, - {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 90}, - {IT_CALL|IT_STRING, NULL, "Custom Options...", M_CustomCvarMenu, 100}, + {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 95}, + {IT_CALL|IT_STRING, NULL, "Custom Options...", M_CustomCvarMenu, 105}, - {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 110}, - {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 120}, + {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 115}, + {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 125}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 140}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 145}, - {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 150}, - {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 160}, + {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 155}, + {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 165}, }; static menuitem_t OP_ControlsMenu[] = @@ -1366,17 +1371,16 @@ static menuitem_t OP_VideoOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 65}, {IT_STRING | IT_CVAR, NULL, "Weather Draw Distance",&cv_drawdist_precip, 75}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Field of View", &cv_fov, 95}, - {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 105}, - {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 115}, - {IT_STRING | IT_CVAR, NULL, "FPS Cap", &cv_fpscap, 125}, - {IT_STRING | IT_CVAR, NULL, "Drift spark pulse size",&cv_driftsparkpulse, 135}, - {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 145}, + {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 95}, + {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 105}, + {IT_STRING | IT_CVAR, NULL, "FPS Cap", &cv_fpscap, 115}, + {IT_STRING | IT_CVAR, NULL, "Drift spark pulse size",&cv_driftsparkpulse, 125}, + {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 135}, #ifdef HWRENDER - {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 155}, + {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 145}, #endif - {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_ExpOptionsDef, 165}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_ExpOptionsDef, 155}, }; @@ -1391,7 +1395,6 @@ static const char* OP_VideoTooltips[] = "Advanced color settings of the game.", "How far away objects are drawn.", "How far away weather is drawn.", - "Player field of view.", "Show current game framerate and select the style.", "Sync game framerate to refresh rate of monitor.", "Set manual framerate cap.", @@ -1415,7 +1418,6 @@ enum op_video_color, op_video_dd, op_video_wdd, - op_video_fov, op_video_fps, op_video_vsync, op_video_fpscap, @@ -1787,7 +1789,7 @@ static menuitem_t OP_HUDOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "HUD Visibility", &cv_translucenthud, 20}, - {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...",&OP_ChatOptionsDef, 35}, + {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...", &OP_ChatOptionsDef, 35}, {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, @@ -1809,6 +1811,95 @@ static menuitem_t OP_HUDOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 165}, }; +static menuitem_t OP_CamOptionsMenu[] = +{ + {IT_HEADER, NULL, "Camera Options", NULL, 0}, + + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Field of View",&cv_fov, 30}, + + {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 50}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom, 60}, + + {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 80}, + {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 90}, + {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 100}, + {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 110}, +}; + +static const char* OP_CamOptionsTooltips[] = +{ + NULL, + "Player field of view.", + "Removes Camera Lag in netgames\nMay cause Camera stutters in poor net conditions.", + "Should looking back inherit the Players Momentum?\nEither inherit Player Momentum or double of it\nmay make looking back while boosting or going in high speed less jarring", + NULL, + NULL, + NULL, + NULL, +}; + +static menuitem_t OP_Player1CamOptionsMenu[] = +{ + {IT_HEADER, NULL, "Player 1 Camera Options", NULL, 0}, + + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam, 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist, 40}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height, 50}, + {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed, 60}, + {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed, 70}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam, 85}, +}; + +static menuitem_t OP_Player2CamOptionsMenu[] = +{ + {IT_HEADER, NULL, "Player 2 Camera Options", NULL, 0}, + + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam2, 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam2_dist, 40}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam2_height, 50}, + {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam2_speed, 60}, + {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam2_rotspeed, 70}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam2, 85}, +}; + +static menuitem_t OP_Player3CamOptionsMenu[] = +{ + {IT_HEADER, NULL, "Player 3 Camera Options", NULL, 0}, + + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam3, 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam3_dist, 40}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam3_height, 50}, + {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam3_speed, 60}, + {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam3_rotspeed, 70}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam3, 85}, +}; + +static menuitem_t OP_Player4CamOptionsMenu[] = +{ + {IT_HEADER, NULL, "Player 4 Camera Options", NULL, 0}, + + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam4, 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam4_dist, 40}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam4_height, 50}, + {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam4_speed, 60}, + {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam4_rotspeed, 70}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam4, 85}, +}; + +static const char* OP_PlayerCamOptionsTooltips[] = +{ + NULL, + "Should the Camera flip on gravity flipped sections?.", + "Camera distance relative to the Player.", + "Height of the Camera", + "Speed of the Camera", + "Speed of the Camera rotation", + "Toggle between Third or First Person camera", +}; // Ok it's still called chatoptions but we'll put ping display in here to be clean static menuitem_t OP_ChatOptionsMenu[] = @@ -2040,18 +2131,16 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, - {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 30}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 30}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 35}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 40}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 45}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 45}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 55}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 55}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 65}, - - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 75}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 80}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 85}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 65}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 70}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 75}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2059,7 +2148,6 @@ static const char* OP_SaturnTooltips[] = NULL, "How long can the game wait before it kicks you out from the server\nconnecting screen.", "How much speen do you want?", - "Makes the Camera Lagless in netgames.", "Show Localskin Menus.", "Force menu to only use uppercase.", "Use your desired Keyboard Layout for Text Input\nthis is either the Default, Native or Azerty\nNative does not affect Gameplay only Text!", @@ -2074,7 +2162,6 @@ enum sm_header, sm_waittime, sm_skinselspeed, - sm_laglesscam, sm_showlocalskin, op_uppercase_menu, sm_nativkey, @@ -2933,6 +3020,11 @@ menu_t OP_HUDOptionsDef = {NULL} }; +menu_t OP_CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_CamOptionsMenu, &OP_MainDef, 30, 30); +menu_t OP_Player1CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player1CamOptionsMenu, &OP_CamOptionsDef, 30, 30); +menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu, &OP_CamOptionsDef, 30, 30); +menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30); +menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30); menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30); @@ -5227,6 +5319,26 @@ static void M_DrawGenericMenu(void) coolalphatimer--; } } + + if (currentMenu == &OP_CamOptionsDef) + { + if (!(OP_CamOptionsTooltips[itemOn] == NULL)) + { + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_CamOptionsTooltips[itemOn], coolalphatimer); + if (coolalphatimer > 0 && interpTimerHackAllow) + coolalphatimer--; + } + } + + if (currentMenu == &OP_Player1CamOptionsDef || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef || currentMenu == &OP_Player4CamOptionsDef) + { + if (!(OP_PlayerCamOptionsTooltips[itemOn] == NULL)) + { + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_PlayerCamOptionsTooltips[itemOn], coolalphatimer); + if (coolalphatimer > 0 && interpTimerHackAllow) + coolalphatimer--; + } + } } static void M_DrawGenericBackgroundMenu(void) @@ -8019,11 +8131,11 @@ static void M_Options(INT32 choice) (void)choice; // if the player is not admin or server, disable gameplay & server options - OP_MainMenu[4].status = OP_MainMenu[5].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); + OP_MainMenu[5].status = OP_MainMenu[6].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); - OP_MainMenu[9].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // Play credits + OP_MainMenu[10].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // Play credits - OP_MainMenu[12].status = (!cv_showlocalskinmenus.value) ? (IT_DISABLED) : (IT_CALL|IT_STRING); + OP_MainMenu[13].status = (!cv_showlocalskinmenus.value) ? (IT_DISABLED) : (IT_CALL|IT_STRING); #ifdef HAVE_DISCORDRPC OP_DataOptionsMenu[4].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); // Erase data diff --git a/src/p_user.c b/src/p_user.c index f9d909cd5..f236614b6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3073,7 +3073,7 @@ consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Extra Momentum"}, {0, NULL}}; +static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Double"}, {0, NULL}}; consvar_t cv_lookbackmom = {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; fixed_t t_cam_dist = -42; -- 2.54.0 From 7d7429660444517b00b11bf07785aebb9d36a481 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 19:53:09 +0200 Subject: [PATCH 420/525] throw menu bg conditions into own function since it s terrible --- src/m_menu.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 4fd5aa3bb..a2be1f718 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4220,6 +4220,25 @@ boolean M_DemoResponder(event_t *ev) return eatinput; } +// mhhm yes +static boolean ShouldDrawMenuBG(void) +{ + if (WipeInAction) // dont ever draw stuff in wipes + return false; + + if (currentMenu == &PlaybackMenuDef) // Replay playback has its own background + return false; + + if (forceshowhud) + return false; + + // camera options stuff, only do when in level + if (gamestate == GS_LEVEL && !paused && (currentMenu == &OP_CamOptionsDef || currentMenu == &OP_Player1CamOptionsDef || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef || currentMenu == &OP_Player4CamOptionsDef)) + return false; + + return true; +} + // // M_Drawer // Called after the view has been rendered, @@ -4230,12 +4249,12 @@ void M_Drawer(void) if (currentMenu == &MessageDef) menuactive = true; - forceshowhud = gamestate == GS_LEVEL && menuactive && (currentMenu == &OP_SaturnHudDef || currentMenu == &OP_HudOffsetDef || currentMenu == &OP_NametagDef || currentMenu == &OP_DriftGaugeDef); // holy fuick + forceshowhud = (gamestate == GS_LEVEL && menuactive && (currentMenu == &OP_SaturnHudDef || currentMenu == &OP_HudOffsetDef || currentMenu == &OP_NametagDef || currentMenu == &OP_DriftGaugeDef)); // holy fuick if (menuactive) { // now that's more readable with a faded background (yeah like Quake...) - if (!WipeInAction && currentMenu != &PlaybackMenuDef && !forceshowhud) // Replay playback has its own background + if (ShouldDrawMenuBG()) V_DrawFadeScreen(0xFF00, 16); if (currentMenu->drawroutine) -- 2.54.0 From 2be4bd3d6a53e76fd6fc26d0fc4444b94cd1f362 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 20:15:34 +0200 Subject: [PATCH 421/525] update camera when paused and changing cam dist or height --- src/m_menu.c | 2 +- src/p_user.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 85 insertions(+), 9 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index a2be1f718..b76a2de61 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4233,7 +4233,7 @@ static boolean ShouldDrawMenuBG(void) return false; // camera options stuff, only do when in level - if (gamestate == GS_LEVEL && !paused && (currentMenu == &OP_CamOptionsDef || currentMenu == &OP_Player1CamOptionsDef || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef || currentMenu == &OP_Player4CamOptionsDef)) + if (gamestate == GS_LEVEL && (currentMenu == &OP_CamOptionsDef || currentMenu == &OP_Player1CamOptionsDef || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef || currentMenu == &OP_Player4CamOptionsDef)) return false; return true; diff --git a/src/p_user.c b/src/p_user.c index f236614b6..560cca10a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3039,29 +3039,105 @@ static CV_PossibleValue_t CV_CamSpeed[] = {{0, "MIN"}, {1*FRACUNIT, "MAX"}, {0, static CV_PossibleValue_t rotation_cons_t[] = {{1, "MIN"}, {45, "MAX"}, {0, NULL}}; static CV_PossibleValue_t CV_CamRotate[] = {{-720, "MIN"}, {720, "MAX"}, {0, NULL}}; -consvar_t cv_cam_dist = {"cam_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_height = {"cam_height", "50", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +static void CV_PlayerCam1_OnChange(void) +{ + if (gamestate != GS_LEVEL) + return; + + if (netgame) + return; + + if (!playeringame[displayplayers[0]] || players[displayplayers[0]].spectator) + return; + + // dont do stuff when cam speeen at map start + if (leveltime < starttime - TICRATE*4) + return; + + if (camera[displayplayers[0]].chase) + P_ResetCamera(&players[displayplayers[0]], &camera[0]); +} + +static void CV_PlayerCam2_OnChange(void) +{ + if (gamestate != GS_LEVEL) + return; + + if (netgame) + return; + + if (!playeringame[displayplayers[1]] || players[displayplayers[1]].spectator) + return; + + // dont do stuff when cam speeen at map start + if (leveltime < starttime - TICRATE*4) + return; + + if (camera[displayplayers[1]].chase) + P_ResetCamera(&players[displayplayers[1]], &camera[1]); +} + +static void CV_PlayerCam3_OnChange(void) +{ + if (gamestate != GS_LEVEL) + return; + + if (netgame) + return; + + if (!playeringame[displayplayers[2]] || players[displayplayers[2]].spectator) + return; + + // dont do stuff when cam speeen at map start + if (leveltime < starttime - TICRATE*4) + return; + + if (camera[displayplayers[2]].chase) + P_ResetCamera(&players[displayplayers[2]], &camera[2]); +} + +static void CV_PlayerCam4_OnChange(void) +{ + if (gamestate != GS_LEVEL) + return; + + if (netgame) + return; + + if (!playeringame[displayplayers[3]] || players[displayplayers[3]].spectator) + return; + + // dont do stuff when cam speeen at map start + if (leveltime < starttime - TICRATE*4) + return; + + if (camera[displayplayers[3]].chase) + P_ResetCamera(&players[displayplayers[3]], &camera[3]); +} + +consvar_t cv_cam_dist = {"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_height = {"cam_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam1_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_still = {"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_speed = {"cam_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_rotate = {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_rotspeed = {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_dist = {"cam2_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_height = {"cam2_height", "50", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_dist = {"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_height = {"cam2_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_still = {"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_speed = {"cam2_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_rotate = {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_rotspeed = {"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam3_dist = {"cam3_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam3_height = {"cam3_height", "50", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam3_dist = {"cam3_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam3_height = {"cam3_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam3_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam3_still = {"cam3_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam3_speed = {"cam3_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam3_rotate = {"cam3_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam3_rotspeed = {"cam3_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam4_dist = {"cam4_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam4_height = {"cam4_height", "50", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam4_dist = {"cam4_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam4_height = {"cam4_height", "50", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, NULL, CV_PlayerCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_still = {"cam4_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_speed = {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam4_rotate = {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL}; -- 2.54.0 From f8bec7296c5bc264560f007b1043281bdc3fbeca Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 20:19:06 +0200 Subject: [PATCH 422/525] no idea why i put those here --- src/p_user.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 560cca10a..582659c7b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3044,9 +3044,6 @@ static void CV_PlayerCam1_OnChange(void) if (gamestate != GS_LEVEL) return; - if (netgame) - return; - if (!playeringame[displayplayers[0]] || players[displayplayers[0]].spectator) return; @@ -3063,9 +3060,6 @@ static void CV_PlayerCam2_OnChange(void) if (gamestate != GS_LEVEL) return; - if (netgame) - return; - if (!playeringame[displayplayers[1]] || players[displayplayers[1]].spectator) return; @@ -3082,9 +3076,6 @@ static void CV_PlayerCam3_OnChange(void) if (gamestate != GS_LEVEL) return; - if (netgame) - return; - if (!playeringame[displayplayers[2]] || players[displayplayers[2]].spectator) return; @@ -3101,9 +3092,6 @@ static void CV_PlayerCam4_OnChange(void) if (gamestate != GS_LEVEL) return; - if (netgame) - return; - if (!playeringame[displayplayers[3]] || players[displayplayers[3]].spectator) return; -- 2.54.0 From 0523d98a1c5eeddf505dd1ce73c0a49f7a9bfe96 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 5 Aug 2024 14:12:00 +0200 Subject: [PATCH 423/525] Test: remove Z_Unlock and proper free some stuff --- src/hardware/hw_cache.c | 2 +- src/w_wad.c | 2 +- src/z_zone.h | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c079f2110..9f02007d4 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -379,7 +379,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noe blockwidth, blockheight, texture, patch, realpatch); - Z_Unlock(realpatch); + Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); } //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( diff --git a/src/w_wad.c b/src/w_wad.c index 8df0654f0..679e9c5ae 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1748,7 +1748,7 @@ void W_UnlockCachedPatch(void *patch) HWR_UnlockCachedPatch((GLPatch_t*)patch); else #endif - Z_Unlock(patch); + Z_ChangeTag(patch, PU_LEVEL); } void *W_CachePatchName(const char *name, INT32 tag) diff --git a/src/z_zone.h b/src/z_zone.h index 6125f2b3f..e4ee811f2 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -144,6 +144,5 @@ size_t Z_TagsUsage(INT32 lowtag, INT32 hightag); // Miscellaneous functions // char *Z_StrDup(const char *in); -#define Z_Unlock(p) (void)p // TODO: remove this now that NDS code has been removed #endif -- 2.54.0 From 8a1ff58dffa406802260e652a0b13b569c1944fa Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Sep 2024 20:43:40 +0200 Subject: [PATCH 424/525] free texture patchlumps proper in R_LoadTextures drastically reduces ram usage --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index ad8b420f3..e24b2d402 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -524,7 +524,7 @@ void R_LoadTextures(void) patch->wad = (UINT16)w; patch->lump = texstart + j; - Z_Unlock(patchlump); + Z_Free(patchlump); k = 1; while (k << 1 <= texture->width) -- 2.54.0 From 5830270bda1e48ae24f4620b91780df53b7fbb55 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Sep 2024 19:37:50 +0200 Subject: [PATCH 425/525] optimize polyobject spawn should speed up level loading with maps with polyobjects thx geezeedoom --- src/p_polyobj.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index a56753e98..fc6375d55 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -95,6 +95,8 @@ INT32 numPolyObjects; // Polyobject Blockmap -- initialized in P_LoadBlockMap polymaplink_t **polyblocklinks; +static size_t *KnownPolySides; +static size_t KnownPolySidesCount; // // Static Data @@ -152,6 +154,36 @@ FUNCINLINE static ATTRINLINE void PolyObj_AddThinker(thinker_t *th) thinkercap.next = th; } +static void FreeSideLists(void) +{ + free(KnownPolySides); + KnownPolySides = NULL; + KnownPolySidesCount = 0; +} + +//========================================================================== +// +// InitSideLists [RH] +// +// Group sides by vertex and collect side that are known to belong to a +// polyobject so that they can be initialized fast. +//========================================================================== +static void InitSideLists(void) +{ + size_t i; + FreeSideLists(); + KnownPolySides = malloc(numsegs * sizeof(KnownPolySides[0])); + for (i = 0; i < numsegs; i++) + { + if (segs[i].linedef && + (segs[i].linedef->special == POLYOBJ_START_LINE || + segs[i].linedef->special == POLYOBJ_EXPLICIT_LINE)) + { + KnownPolySides[KnownPolySidesCount++] = i; + } + } +} + // // P_PointInsidePolyobj // @@ -512,11 +544,12 @@ static void Polyobj_findExplicit(polyobj_t *po) size_t numSegItems = 0; size_t numSegItemsAlloc = 0; - size_t i; + size_t i, ii; // first loop: save off all segs with polyobject's id number - for (i = 0; i < numsegs; ++i) + for (ii = 0; ii < KnownPolySidesCount; ii++) { + i = KnownPolySides[ii]; INT32 polyID, parentID; if (segs[i].linedef->special != POLYOBJ_EXPLICIT_LINE) @@ -566,7 +599,7 @@ static void Polyobj_findExplicit(polyobj_t *po) // static void Polyobj_spawnPolyObj(INT32 num, mobj_t *spawnSpot, INT32 id) { - size_t i; + size_t i, ii; polyobj_t *po = &PolyObjects[num]; // don't spawn a polyobject more than once @@ -590,8 +623,9 @@ static void Polyobj_spawnPolyObj(INT32 num, mobj_t *spawnSpot, INT32 id) // 1. Search segs for "line start" special with tag matching this // polyobject's id number. If found, iterate through segs which // share common vertices and record them into the polyobject. - for (i = 0; i < numsegs; ++i) + for (ii = 0; ii < KnownPolySidesCount; ii++) { + i = KnownPolySides[ii]; seg_t *seg = &segs[i]; INT32 polyID, parentID; @@ -1553,6 +1587,9 @@ void Polyobj_InitLevel(void) for (i = 0; i < numPolyObjects; ++i) PolyObjects[i].first = PolyObjects[i].next = numPolyObjects; + // [RH] Make this faster + InitSideLists(); + // setup polyobjects for (i = 0; i < numPolyObjects; ++i) { @@ -1561,6 +1598,9 @@ void Polyobj_InitLevel(void) Polyobj_spawnPolyObj(i, qitem->mo, qitem->mo->spawnpoint->angle); } + // [RH] Don't need the side lists anymore + FreeSideLists(); + // move polyobjects to spawn points for (i = 0; i < numAnchors; ++i) { -- 2.54.0 From 341815c0ed9bd3639c51c01ec1b1c8c92f0f45de Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Sep 2024 12:10:24 +0200 Subject: [PATCH 426/525] this can be static --- src/hardware/hw_main.c | 3 ++- src/hardware/hw_main.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d75c9b17e..1ea6ccfe2 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -307,6 +307,7 @@ ps_metric_t ps_hw_batchsorttime = {0}; ps_metric_t ps_hw_batchdrawtime = {0}; static void HWR_AddPrecipitationSprites(void); +static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing); // ========================================================================== // View position @@ -5089,7 +5090,7 @@ void HWR_ProjectSprite(mobj_t *thing) } // Precipitation projector for hardware mode -void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) +static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) { gr_vissprite_t *vis; float tr_x, tr_y; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index dc87ee986..af95cd702 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -136,7 +136,7 @@ void HWR_AddPolyObjectSegs(void); // hw_main.c: Sprites void HWR_AddSprites(sector_t *sec); void HWR_ProjectSprite(mobj_t *thing); -void HWR_ProjectPrecipitationSprite(precipmobj_t *thing); +//void HWR_ProjectPrecipitationSprite(precipmobj_t *thing); void HWR_DrawSprites(void); // hw_bsp.c -- 2.54.0 From 4a469aebdcf51124799baaa96242c609dd50320c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Sep 2024 12:12:08 +0200 Subject: [PATCH 427/525] dont draw precip in skyboxes in opengl like software does --- src/hardware/hw_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1ea6ccfe2..41fe3909b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5543,7 +5543,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe // woo we back gr_portal = oldgl_portal_state; - HWR_AddPrecipitationSprites(); + if (allow_portals) // looks weird, but this is only true when its not skybox rendering skipping precip in skyboxes like software does + HWR_AddPrecipitationSprites(); PS_STOP_TIMING(ps_bsptime); -- 2.54.0 From 61fd11f7cd96e2f5bd2a639e163119bcd543fdb3 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Sep 2024 12:18:51 +0200 Subject: [PATCH 428/525] those are unused --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 41fe3909b..2d961a6d1 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -367,9 +367,9 @@ gl_portallist_t *currentportallist; INT32 portalviewside; // Linked list for portals. -gl_portal_t *portal_base_gl, *portal_cap_gl; +/*gl_portal_t *portal_base_gl, *portal_cap_gl; -/* For now, these aren't used. +//For now, these aren't used. // maybe at some point these could be organized better static void HWR_Portal_InitList (void) { -- 2.54.0 From 33910186063a25944c4d15612c4090321953fb2c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Sep 2024 17:40:05 +0200 Subject: [PATCH 429/525] some stuffs from lugstuff mostly just cleanup and smoler optimizations --- src/d_main.c | 36 +-- src/g_game.c | 68 ------ src/hardware/hw_clip.c | 4 +- src/hardware/hw_data.h | 1 - src/hardware/hw_defs.h | 2 +- src/hardware/hw_main.c | 41 ++-- src/hardware/hw_main.h | 2 - src/k_kart.c | 4 +- src/lua_script.c | 26 ++- src/m_cheat.c | 5 +- src/p_floor.c | 24 -- src/p_mobj.c | 492 +++++++++++++++++++++-------------------- src/p_polyobj.c | 48 +--- src/p_saveg.c | 168 +++++++------- src/p_spec.c | 22 +- src/r_defs.h | 1 - src/r_main.c | 1 - src/r_plane.c | 3 +- src/r_segs.c | 32 ++- src/sdl/i_video.c | 10 +- src/w_wad.c | 7 +- 21 files changed, 443 insertions(+), 554 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 22a11171a..3bde59775 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -518,8 +518,10 @@ static boolean D_Display(void) for (i = 0; i <= splitscreen; i++) { - if (postimgtype[i]) - V_DoPostProcessor(i, postimgtype[i], postimgparam[i]); + if (!postimgtype[i]) + continue; + + V_DoPostProcessor(i, postimgtype[i], postimgparam[i]); } } @@ -707,7 +709,7 @@ void D_SRB2Loop(void) double budget = round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision()); capbudget = (precise_t) budget; } - + boolean ranwipe = false; I_UpdateTime(cv_timescale.value); @@ -875,7 +877,7 @@ void D_SRB2Loop(void) // post-sleep time is literally being intentionally wasted deltasecs = (double)((INT64)(finishprecise - enterprecise)) / I_GetPrecisePrecision(); deltatics = deltasecs * NEWTICRATE; - + // If time spent this game loop exceeds a single tic, // it's probably because of rendering. // @@ -1018,7 +1020,7 @@ static INT32 D_DetectFileType(const char* filename) return 5; else if (!stricmp(&filename[strlen(filename) - 4], ".soc")) return 6; - + else if (!stricmp(&filename[strlen(filename) - 4], ".cfg")) return 7; else if (!stricmp(&filename[strlen(filename) - 4], ".txt")) @@ -1042,12 +1044,12 @@ static void D_AutoloadFile(const char *file, char **filearray) if (!newfile) I_Error("No more free memory to AutoloadFile %s",file); - if (!fileType) + if (!fileType) { CONS_Printf("D_AutoloadFile: File %s is unknown or invalid\n", file); return; } - + strcpy(newfile, file); if (fileType <= 6) @@ -1288,13 +1290,13 @@ static void IdentifyVersion(void) D_AddFile(va(pandf,srb2waddir,"extra.kart"), startupwadfiles); found_extra_kart = true; } - + // completely optional 2: Back with a vengence if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra2.kart"))) { D_AddFile(va(pandf,srb2waddir,"extra2.kart"), startupwadfiles); found_extra2_kart = true; } - + if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra3.kart"))) { D_AddFile(va(pandf,srb2waddir,"extra3.kart"), startupwadfiles); found_extra3_kart = true; @@ -1597,7 +1599,7 @@ void D_SRB2Main(void) if (found_extra_kart || found_extra2_kart || found_extra3_kart) // found the funny, add it in! { // HAYA: These are seperated for a reason lmao - if (found_extra_kart) + if (found_extra_kart) mainwads++; if (found_extra2_kart) mainwads++; @@ -1625,7 +1627,7 @@ void D_SRB2Main(void) achi_speedo_clr = true; // check for bigger lap count - if (W_CheckMultipleLumps("K_STLAPB", "K_STLA2B", NULL)) + if (W_CheckMultipleLumps("K_STLAPB", "K_STLA2B", NULL)) big_lap = true; // now check for colour hud stuff @@ -1634,7 +1636,7 @@ void D_SRB2Main(void) clr_hud = true; // check for bigger lap count but color** its color bitch - if (W_CheckMultipleLumps("K_SCLAPB", "K_SCLA2B", NULL)) + if (W_CheckMultipleLumps("K_SCLAPB", "K_SCLA2B", NULL)) big_lap_color = true; // kartzspeedo @@ -1649,16 +1651,16 @@ void D_SRB2Main(void) // stat display for extended player setup if (W_CheckMultipleLumps("K_STATNB", "K_STATN1", "K_STATN2", "K_STATN3", "K_STATN4", \ - "K_STATN5", "K_STATN6", NULL)) + "K_STATN5", "K_STATN6", NULL)) statdp = true; // Nametag stuffs - if (W_CheckMultipleLumps("NTLINE", "NTLINEV", "NTSP", "NTWH", NULL)) + if (W_CheckMultipleLumps("NTLINE", "NTLINEV", "NTSP", "NTWH", NULL)) nametaggfx = true; - if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) + if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) driftgaugegfx = true; - + if (found_extra3_kart) { // 80x11 speedometer crap @@ -1671,7 +1673,7 @@ void D_SRB2Main(void) if (W_LumpExists("SC_SM3TC")) xtra_speedo_clr3 = true; } - } + } #undef PUSHSPEEDO memcpy(speedo_cons_t, speedo_cons_temp, sizeof(speedo_cons_t)); diff --git a/src/g_game.c b/src/g_game.c index 0025782ed..936c8d464 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3071,12 +3071,6 @@ void G_DoReborn(INT32 playernum) player_t *player = &players[playernum]; boolean starpost = false; - /*if (modeattacking) // Not needed for SRB2Kart. - { - M_EndModeAttackRun(); - return; - }*/ - // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); @@ -3096,68 +3090,6 @@ void G_DoReborn(INT32 playernum) if (oldmo) G_ChangePlayerReferences(oldmo, players[playernum].mo); } - /*else if (countdowntimeup || (!multiplayer && !modeattacking)) - { - // reload the level from scratch - if (countdowntimeup) - { - player->starpostangle = 0; - player->starposttime = 0; - player->starpostx = 0; - player->starposty = 0; - player->starpostz = 0; - player->starpostnum = 0; - } - if (!countdowntimeup && (mapheaderinfo[gamemap-1]->levelflags & LF_NORELOAD)) - { - INT32 i; - - player->playerstate = PST_REBORN; - - P_LoadThingsOnly(); - - // Do a wipe - wipegamestate = -1; - - if (player->starpostnum) // SRB2kart - starpost = true; - - for (i = 0; i <= splitscreen; i++) - { - if (camera[i].chase) - P_ResetCamera(&players[displayplayers[i]], &camera[i]); - } - - // clear cmd building stuff - memset(gamekeydown, 0, sizeof (gamekeydown)); - for (i = 0;i < JOYAXISSET; i++) - { - joyxmove[i] = joyymove[i] = 0; - joy2xmove[i] = joy2ymove[i] = 0; - joy3xmove[i] = joy3ymove[i] = 0; - joy4xmove[i] = joy4ymove[i] = 0; - } - mousex = mousey = 0; - mouse2x = mouse2y = 0; - - // clear hud messages remains (usually from game startup) - CON_ClearHUD(); - - // Starpost support - G_SpawnPlayer(playernum, starpost); - - if (botingame) - { // Bots respawn next to their master. - players[displayplayers[1]].playerstate = PST_REBORN; - G_SpawnPlayer(displayplayers[1], false); - } - } - else - { - LUAh_MapChange(gamemap); - G_DoLoadLevel(true); - } - }*/ else { // respawn at the start diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 623527549..2c6e1d52e 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -337,16 +337,16 @@ angle_t gld_FrustumAngle(angle_t tiltangle) floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * clipfov / 90.0f; if (floatangle >= 180.0) return 0xffffffff; - a1 = ANG1 * (int)floatangle; + a1 = (angle_t)(ANG1 * (int)floatangle); return a1; } - // SRB2CB I don't think used any of this stuff, let's disable for now since SRB2 probably doesn't want it either // compiler complains about (p)glGetFloatv anyway, in case anyone wants this // only r_opengl.c can use the base gl funcs as it turns out, that's a problem for whoever wants sphere frustum checks // btw to renable define HAVE_SPHEREFRUSTRUM in hw_clip.h #ifdef HAVE_SPHEREFRUSTRUM + // // gld_FrustumSetup // diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 569548137..b149493c5 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -44,7 +44,6 @@ struct GLMipmap_s UINT16 width, height; UINT32 downloaded; // tex_downloaded - struct GLMipmap_s *nextmipmap; struct GLMipmap_s *nextcolormap; const UINT8 *colormap; }; diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index b19106fff..7d2d17532 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -175,8 +175,8 @@ enum SHADER_FLOOR = 0, SHADER_SHADOW, SHADER_WALL, - SHADER_MODEL, SHADER_SPRITE, + SHADER_MODEL, SHADER_WATER, SHADER_FOG, SHADER_SKY, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2d961a6d1..c2754aa01 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2655,7 +2655,7 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) // Adds all segs in all polyobjects in the given subsector. // Modified for hardware rendering. // -void HWR_AddPolyObjectSegs(void) +static inline void HWR_AddPolyObjectSegs(void) { size_t i, j; @@ -3182,7 +3182,7 @@ static void HWR_Subsector(size_t num) { light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false); HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, - &extrasubsectors[num], + &extrasubsectors[num], true, *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, @@ -4112,7 +4112,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) FOutVector wallVerts[4]; GLPatch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; - + INT32 shader = SHADER_NONE; if (!spr->mobj) @@ -4196,10 +4196,10 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) if (HWR_UseShader()) { - shader = SHADER_SPRITE; // sprite shader + shader = SHADER_SPRITE; blend |= PF_ColorMapped; } - + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); } @@ -4547,7 +4547,7 @@ void HWR_DrawSprites(void) HWR_DrawMD2(spr); } else - { + { if (!cv_grmdls.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) HWR_DrawSprite(spr); else @@ -4582,9 +4582,9 @@ void HWR_AddSprites(sector_t *sec) { // Use the smaller setting if (cv_drawdist.value) - limit_dist = min(current_bsp_culling_distance, (fixed_t)(cv_drawdist.value) * mapobjectscale); + limit_dist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist.value) * mapobjectscale); else - limit_dist = current_bsp_culling_distance; + limit_dist = (fixed_t)current_bsp_culling_distance; } else limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; @@ -4865,12 +4865,7 @@ void HWR_ProjectSprite(mobj_t *thing) flip = sprframe->flip; // Will only be 0x00 or 0xFF if (papersprite && ang < ANGLE_180) - { - if (flip) - flip = 0; - else - flip = 255; - } + flip ^= 0xFFFF; } else { @@ -4887,12 +4882,7 @@ void HWR_ProjectSprite(mobj_t *thing) flip = sprframe->flip & (1<skin && ((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->flags & SF_HIRES) @@ -5108,9 +5098,6 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) if (!thing) return; - if (cv_grmaxinterpdist.value) - dist = R_QuickCamDist(thing->x, thing->y); - // uncapped/interpolation interpmobjstate_t interp = {0}; @@ -5120,6 +5107,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) return; } + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); + // do interpolation if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { @@ -5263,7 +5253,7 @@ static inline void HWR_ClearView(void) (INT32)(gr_viewwindowx + gr_viewwidth), (INT32)(gr_viewwindowy + gr_viewheight), ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); - HWD.pfnClearBuffer(false, true, true, 0); + HWD.pfnClearBuffer(false, true, true, NULL); } @@ -5451,7 +5441,7 @@ static void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const // remove portal seg from stencil buffer HWR_SetTransform(fpov, player); HWR_ClearClipper(); - + HWR_SetStencilState(HWR_STENCIL_REVERSE, stencil_level); HWR_RenderPortalSeg(portal, GRPORTAL_STENCIL); @@ -5498,6 +5488,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe } else gr_portal = GRPORTAL_OFF;// there may be portals and they need to be drawn as regural walls + // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); if (!cv_portalonly.value || rootportal) diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index af95cd702..bd6258ef4 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -131,8 +131,6 @@ void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 t void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf); void HWR_DrawSkyBackground(float fpov); -void HWR_AddPolyObjectSegs(void); - // hw_main.c: Sprites void HWR_AddSprites(sector_t *sec); void HWR_ProjectSprite(mobj_t *thing); diff --git a/src/k_kart.c b/src/k_kart.c index e3cf249b2..fe0cd4eb9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8771,7 +8771,7 @@ static void K_drawKartLaps(void) else V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, kp_lapstickerclr, colormap); } - + if (stplyr->exiting) V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, "FIN"); else @@ -8786,7 +8786,7 @@ static void K_drawKartSpeedometer(void) return; fixed_t convSpeed = 0; - + //KartZ speedo fixed_t fuspeed = 0; INT32 spdpatch = 0; diff --git a/src/lua_script.c b/src/lua_script.c index f4bf8a07a..c4a0df135 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1603,12 +1603,14 @@ void LUA_Archive(void) if (gamestate == GS_LEVEL) { for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - { - // archive function will determine when to skip mobjs, - // and write mobjnum in otherwise. - ArchiveExtVars(th, "mobj"); - } + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + // archive function will determine when to skip mobjs, + // and write mobjnum in otherwise. + ArchiveExtVars(th, "mobj"); + } } WRITEUINT32(save_p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. @@ -1636,11 +1638,15 @@ void LUA_UnArchive(void) } do { - mobjnum = READUINT32(save_p); // read a mobjnum + mobjnum = READUINT32(save_p); // read a mobjnum for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker - && ((mobj_t *)th)->mobjnum == mobjnum) // find matching mobj - UnArchiveExtVars(th); // apply variables + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (((mobj_t *)th)->mobjnum != mobjnum) // find matching mobj + continue; + UnArchiveExtVars(th); // apply variables + } } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. LUAh_NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode diff --git a/src/m_cheat.c b/src/m_cheat.c index 91ca536c8..abada4be5 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -909,8 +909,9 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mo = (mobj_t *)th; // get offset from mt, which points to old mapthings, then add new location - if (mo->spawnpoint) - mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; + if (!mo->spawnpoint) + continue; + mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; } } diff --git a/src/p_floor.c b/src/p_floor.c index 27460eda6..bebc9a272 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1968,32 +1968,8 @@ void T_ThwompSector(levelspecthink_t *thwomp) } else // Not going anywhere, so look for players. { - //thinker_t *th; - //mobj_t *mo; - thwomp->direction = -1; - /* // SRB2kart 170217 - Thwomps are automatic. - // scan the thinkers to find players! - if (!rover || (rover->flags & FF_EXISTS)) - { - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->player && !mo->player->spectator - && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) - { - thwomp->direction = -1; - break; - } - } - }*/ - thwomp->sector->ceilspeed = 0; thwomp->sector->floorspeed = 0; } diff --git a/src/p_mobj.c b/src/p_mobj.c index 8a0147194..9fc06c0b7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -356,7 +356,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state) // // Special utility to return +1 or -1 depending on mobj's gravity // -SINT8 P_MobjFlip(mobj_t *mobj) +SINT8 P_MobjFlip(const mobj_t *mobj) { if (mobj && mobj->eflags & MFE_VERTICALFLIP) return -1; @@ -915,16 +915,18 @@ static void P_PlayerFlip(mobj_t *mo) for (i = 0; i <= splitscreen; i++) { - if (mo->player-players == displayplayers[i]) - { - localaiming[i] = mo->player->aiming; - if (camera[i].chase) { - camera[i].aiming = InvAngle(camera[i].aiming); - camera[i].z = mo->z - camera[i].z + mo->z; - if (mo->eflags & MFE_VERTICALFLIP) - camera[i].z += FixedMul(20*FRACUNIT, mo->scale); - } - } + if (!(mo->player-players == displayplayers[i])) + continue; + + localaiming[i] = mo->player->aiming; + + if (!camera[i].chase) + continue; + + camera[i].aiming = InvAngle(camera[i].aiming); + camera[i].z = mo->z - camera[i].z + mo->z; + if (mo->eflags & MFE_VERTICALFLIP) + camera[i].z += FixedMul(20*FRACUNIT, mo->scale); } } } @@ -1234,67 +1236,67 @@ static void P_PushableCheckBustables(mobj_t *mo) if (!node->m_sector) break; - if (node->m_sector->ffloors) + if (!(node->m_sector->ffloors)) + continue; + + ffloor_t *rover; + fixed_t topheight, bottomheight; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) { - ffloor_t *rover; - fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) continue; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) + if (!(rover->flags & FF_BUSTUP)) continue; + + // Needs ML_EFFECT4 flag for pushables to break it + if (!(rover->master->flags & ML_EFFECT4)) continue; + + if (rover->master->frontsector->crumblestate) + continue; + + topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); + bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); + // Height checks + if (rover->flags & FF_SHATTERBOTTOM) { - if (!(rover->flags & FF_EXISTS)) continue; + if (mo->z+mo->momz + mo->height < bottomheight) + continue; - if (!(rover->flags & FF_BUSTUP)) continue; - - // Needs ML_EFFECT4 flag for pushables to break it - if (!(rover->master->flags & ML_EFFECT4)) continue; - - if (!rover->master->frontsector->crumblestate) - { - topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); - bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); - // Height checks - if (rover->flags & FF_SHATTERBOTTOM) - { - if (mo->z+mo->momz + mo->height < bottomheight) - continue; - - if (mo->z+mo->height > bottomheight) - continue; - } - else if (rover->flags & FF_SPINBUST) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->height < bottomheight) - continue; - } - else if (rover->flags & FF_SHATTER) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->momz + mo->height < bottomheight) - continue; - } - else - { - if (mo->z >= topheight) - continue; - - if (mo->z+mo->height < bottomheight) - continue; - } - - EV_CrumbleChain(node->m_sector, rover); - - // Run a linedef executor?? - if (rover->master->flags & ML_EFFECT5) - P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector); - - goto bustupdone; - } + if (mo->z+mo->height > bottomheight) + continue; } + else if (rover->flags & FF_SPINBUST) + { + if (mo->z+mo->momz > topheight) + continue; + + if (mo->z+mo->height < bottomheight) + continue; + } + else if (rover->flags & FF_SHATTER) + { + if (mo->z+mo->momz > topheight) + continue; + + if (mo->z+mo->momz + mo->height < bottomheight) + continue; + } + else + { + if (mo->z >= topheight) + continue; + + if (mo->z+mo->height < bottomheight) + continue; + } + + EV_CrumbleChain(node->m_sector, rover); + + // Run a linedef executor?? + if (rover->master->flags & ML_EFFECT5) + P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector); + + goto bustupdone; } } bustupdone: @@ -2498,42 +2500,42 @@ static void P_PlayerZMovement(mobj_t *mo) if (newsubsec->sector != sec) continue; - if (newsubsec->polyList) + if (!newsubsec->polyList) + continue; + + polyobj_t *po = newsubsec->polyList; + sector_t *polysec; + + while(po) { - polyobj_t *po = newsubsec->polyList; - sector_t *polysec; - - while(po) + if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) { - if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) - { - po = (polyobj_t *)(po->link.next); - continue; - } - - // We're inside it! Yess... - polysec = po->lines[0]->backsector; - - // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red - if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker) - stopmovecut = true; - - if (!(po->flags & POF_LDEXEC)) - { - po = (polyobj_t *)(po->link.next); - continue; - } - - if (mo->z == polysec->ceilingheight) - { - // We're landing on a PO, so check for - // a linedef executor. - // Trigger tags are 32000 + the PO's ID number. - P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); - } - po = (polyobj_t *)(po->link.next); + continue; } + + // We're inside it! Yess... + polysec = po->lines[0]->backsector; + + // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red + if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker) + stopmovecut = true; + + if (!(po->flags & POF_LDEXEC)) + { + po = (polyobj_t *)(po->link.next); + continue; + } + + if (mo->z == polysec->ceilingheight) + { + // We're landing on a PO, so check for + // a linedef executor. + // Trigger tags are 32000 + the PO's ID number. + P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); + } + + po = (polyobj_t *)(po->link.next); } } } @@ -3072,16 +3074,16 @@ void P_MobjCheckWater(mobj_t *mobj) mobj->y + FixedMul((prandom[2]<<(FRACBITS-3)) * (prandom[0]&0x40 ? 1 : -1), mobj->scale), mobj->z + FixedMul((prandom[3]<<(FRACBITS-2)), mobj->scale), bubbletype); - if (bubble) - { - if (P_MobjFlip(mobj)*mobj->momz < 0) - bubble->momz = mobj->momz >> 4; - else - bubble->momz = 0; + if (!bubble) + continue; - bubble->destscale = mobj->scale; - P_SetScale(bubble, mobj->scale); - } + if (P_MobjFlip(mobj)*mobj->momz < 0) + bubble->momz = mobj->momz >> 4; + else + bubble->momz = 0; + + bubble->destscale = mobj->scale; + P_SetScale(bubble, mobj->scale); } } } @@ -3299,8 +3301,10 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled { for (i = 0; i <= splitscreen; i++) { - if (player == &players[displayplayers[i]]) - postimgtype[i] = postimg; + if (!(player == &players[displayplayers[i]])) + continue; + + postimgtype[i] = postimg; } } @@ -3473,20 +3477,20 @@ static void P_PlayerMobjThinker(mobj_t *mobj) for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { - if (node->m_sector->ffloors) - { - ffloor_t *rover; - // Get water boundaries first - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; + if (!node->m_sector->ffloors) + continue; - if (rover->flags & FF_SWIMMABLE) // Is there water? - { - thereiswater = true; - break; - } + ffloor_t *rover; + // Get water boundaries first + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (rover->flags & FF_SWIMMABLE) // Is there water? + { + thereiswater = true; + break; } } } @@ -3494,21 +3498,21 @@ static void P_PlayerMobjThinker(mobj_t *mobj) { for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { - if (node->m_sector->ffloors) - { - ffloor_t *rover; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_FLOATBOB)) - continue; + if (!node->m_sector->ffloors) + continue; - if ((!(mobj->eflags & MFE_VERTICALFLIP) && abs(*rover->topheight-mobj->z) <= abs(mobj->momz)) // The player is landing on the cheese! - || (mobj->eflags & MFE_VERTICALFLIP && abs(*rover->bottomheight-(mobj->z+mobj->height)) <= abs(mobj->momz))) - { - // Initiate a 'bouncy' elevator function - // which slowly diminishes. - EV_BounceSector(rover->master->frontsector, -mobj->momz, rover->master); - } + ffloor_t *rover; + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_FLOATBOB)) + continue; + + if ((!(mobj->eflags & MFE_VERTICALFLIP) && abs(*rover->topheight-mobj->z) <= abs(mobj->momz)) // The player is landing on the cheese! + || (mobj->eflags & MFE_VERTICALFLIP && abs(*rover->bottomheight-(mobj->z+mobj->height)) <= abs(mobj->momz))) + { + // Initiate a 'bouncy' elevator function + // which slowly diminishes. + EV_BounceSector(rover->master->frontsector, -mobj->momz, rover->master); } } } @@ -3781,20 +3785,20 @@ boolean P_SupermanLook4Players(mobj_t *actor) for (c = 0; c < MAXPLAYERS; c++) { - if (playeringame[c]) - { - if (players[c].health <= 0) - continue; // dead + if (!playeringame[c]) + continue; - if (players[c].pflags & PF_INVIS) - continue; // ignore notarget + if (players[c].health <= 0) + continue; // dead - if (!players[c].mo || players[c].bot) - continue; + if (players[c].pflags & PF_INVIS) + continue; // ignore notarget - playersinthegame[stop] = &players[c]; - stop++; - } + if (!players[c].mo || players[c].bot) + continue; + + playersinthegame[stop] = &players[c]; + stop++; } if (!stop) @@ -4146,11 +4150,21 @@ static void P_Boss3Thinker(mobj_t *mobj) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && mo2->spawnpoint->angle == mobj->threshold) - { - P_SetTarget(&mobj->target, mo2); - break; - } + + if (!mo2) + continue; + + if (mo2->type != MT_BOSS3WAYPOINT) + continue; + + if (!mo2->spawnpoint) + continue; + + if (mo2->spawnpoint->angle != mobj->threshold) + continue; + + P_SetTarget(&mobj->target, mo2); + break; } if (!mobj->target) // Should NEVER happen @@ -4302,18 +4316,20 @@ static void P_Boss4DestroyCage(void) { rsec = §ors[sector->attached[a]]; for (rover = rsec->ffloors; rover; rover = rover->next) - if (rover->flags & FF_EXISTS && rover->secnum == (size_t)snum) + { + if (!(rover->flags & FF_EXISTS && rover->secnum == (size_t)snum)) + continue; + + if (rover->flags & FF_RENDERALL) // checking for FF_RENDERANY. + EV_CrumbleChain(rsec, rover); // This FOF is visible to some extent? Crumble it. + else // Completely invisible FOF { - if (rover->flags & FF_RENDERALL) // checking for FF_RENDERANY. - EV_CrumbleChain(rsec, rover); // This FOF is visible to some extent? Crumble it. - else // Completely invisible FOF - { - // no longer exists (can't collide with again) - rover->flags &= ~FF_EXISTS; - sector->moved = true; - rsec->moved = true; - } + // no longer exists (can't collide with again) + rover->flags &= ~FF_EXISTS; + sector->moved = true; + rsec->moved = true; } + } } } } @@ -4328,8 +4344,10 @@ static void P_Boss4PopSpikeballs(mobj_t *mobj) next = base->tracer; P_SetTarget(&base->tracer, NULL); for (seg = base; seg; seg = seg->hnext) + { if (seg->health) P_KillMobj(seg, NULL, NULL); + } base = next; } } @@ -5406,22 +5424,22 @@ mobj_t *P_GetClosestAxis(mobj_t *source) mo2 = (mobj_t *)th; - if (mo2->type == MT_AXIS) + if (!(mo2->type == MT_AXIS)) + continue; + + if (closestaxis == NULL) { - if (closestaxis == NULL) + closestaxis = mo2; + dist2 = R_PointToDist2(source->x, source->y, mo2->x, mo2->y)-mo2->radius; + } + else + { + dist1 = R_PointToDist2(source->x, source->y, mo2->x, mo2->y)-mo2->radius; + + if (dist1 < dist2) { closestaxis = mo2; - dist2 = R_PointToDist2(source->x, source->y, mo2->x, mo2->y)-mo2->radius; - } - else - { - dist1 = R_PointToDist2(source->x, source->y, mo2->x, mo2->y)-mo2->radius; - - if (dist1 < dist2) - { - closestaxis = mo2; - dist2 = dist1; - } + dist2 = dist1; } } } @@ -7218,16 +7236,18 @@ void P_MobjThinker(mobj_t *mobj) INT32 i; P_SetTarget(&mobj->target, NULL); for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo - && players[i].mare == mobj->threshold && players[i].health > 1) - { - fixed_t dist = P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y); - if (dist < shortest) - { - P_SetTarget(&mobj->target, players[i].mo); - shortest = dist; - } - } + { + if (!(playeringame[i] && players[i].mo + && players[i].mare == mobj->threshold && players[i].health > 1)) + continue; + + fixed_t dist = P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y); + if (!(dist < shortest)) + continue; + + P_SetTarget(&mobj->target, players[i].mo); + shortest = dist; + } } break; case MT_EGGMOBILE2_POGO: @@ -9616,6 +9636,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { if (!playeringame[i]) continue; + pnum[pcount] = i; pcount++; } @@ -10056,20 +10077,26 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->target, P_SetTarget(&mobj->tracer, NULL)); // repair hnext chain - { - mobj_t *cachenext = mobj->hnext; + mobj_t *cachenext = mobj->hnext; - if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) + { + if (mobj->hnext->hprev == mobj) { P_SetTarget(&mobj->hnext->hprev, mobj->hprev); - P_SetTarget(&mobj->hnext, NULL); } - if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) + P_SetTarget(&mobj->hnext, NULL); + } + + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) + { + if (mobj->hprev->hnext == mobj) { P_SetTarget(&mobj->hprev->hnext, cachenext); - P_SetTarget(&mobj->hprev, NULL); } + + P_SetTarget(&mobj->hprev, NULL); } // clear the reference from the mapthing @@ -10078,46 +10105,40 @@ void P_RemoveMobj(mobj_t *mobj) R_RemoveMobjInterpolator(mobj); +#ifdef SCRAMBLE_REMOVED + // Invalidate mobj_t data to cause crashes if accessed! + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); +#endif + // free block - // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. - if (mobj->flags & MF_NOTHINK && !mobj->thinker.next) + if (!mobj->thinker.next) { // Uh-oh, the mobj doesn't think, P_RemoveThinker would never go through! + INT32 prevreferences; if (!mobj->thinker.references) { -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset(mobj, 0xff, sizeof(mobj_t)); -#endif - Z_Free(mobj); // No refrences? Can be removed immediately! :D - } - else - { // Add thinker just to delay removing it until refrences are gone. - mobj->flags &= ~MF_NOTHINK; - P_AddThinker((thinker_t *)mobj); -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); -#endif - P_RemoveThinker((thinker_t *)mobj); + Z_Free(mobj); // No references? Can be removed immediately! :D + return; } + + prevreferences = mobj->thinker.references; + P_AddThinker((thinker_t *)mobj); + mobj->thinker.references = prevreferences; } - else - { + + P_RemoveThinker((thinker_t *)mobj); + + // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. #ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); + // Invalidate mobj_t data to cause crashes if accessed! + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); #endif - P_RemoveThinker((thinker_t *)mobj); - } } // This does not need to be added to Lua. // To test it in Lua, check mobj.valid -boolean P_MobjWasRemoved(mobj_t *mobj) +FUNCINLINE ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj) { - if (mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker) - return false; - return true; + return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker); } void P_FreePrecipMobj(precipmobj_t *mobj) @@ -10357,15 +10378,16 @@ void P_PrecipitationEffects(void) xl = players[displayplayers[0]].mo->x - 1024*FRACUNIT; xh = players[displayplayers[0]].mo->x + 1024*FRACUNIT; closedist = 2048*FRACUNIT; + for (y = yl; y >= yl && y <= yh; y += FRACUNIT*64) for (x = xl; x >= xl && x <= xh; x += FRACUNIT*64) { - if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) // Found the outdoors! - { - newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, x, y, 0); - if (newdist < closedist) - closedist = newdist; - } + if (!(R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum)) // Found the outdoors! + continue; + + newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, x, y, 0); + if (newdist < closedist) + closedist = newdist; } volume = 255 - (closedist>>(FRACBITS+2)); @@ -10751,11 +10773,11 @@ void P_AfterPlayerSpawn(INT32 playernum) for (i = 0; i <= splitscreen; i++) { - if (camera[i].chase) - { - if (displayplayers[i] == playernum) - P_ResetCamera(p, &camera[i]); - } + if (!camera[i].chase) + continue; + + if (displayplayers[i] == playernum) + P_ResetCamera(p, &camera[i]); } if (CheckForReverseGravity) @@ -11834,8 +11856,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) { P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; } else mobj->hprev = mobj->hnext = NULL; @@ -11867,8 +11887,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->hnext = NULL; P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; nextmobj = mobj; } @@ -11896,8 +11914,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->hnext = NULL; P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; nextmobj = mobj; } @@ -11980,8 +11996,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) { P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; } else mobj->hprev = mobj->hnext = NULL; @@ -12024,8 +12038,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) mobj->hnext = NULL; P_SetTarget(&mobj->hprev, nextmobj); P_SetTarget(&mobj->hprev->hnext, mobj); - //mobj->hprev = nextmobj; - //mobj->hprev->hnext = mobj; nextmobj = mobj; } diff --git a/src/p_polyobj.c b/src/p_polyobj.c index fc6375d55..b9a9113de 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1551,7 +1551,8 @@ void Polyobj_InitLevel(void) // the mobj_t pointers on a queue for use below. for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 == (actionf_p1)P_MobjThinker) + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; { mobj_t *mo = (mobj_t *)th; @@ -1854,7 +1855,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) #endif // check for displacement due to override and reattach when possible - if (po->thinker == NULL) + if (!po->thinker) po->thinker = &th->thinker; // Find out target first. @@ -1869,11 +1870,14 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == th->sequence && mo2->health == th->pointnum) - { - target = mo2; - break; - } + if (mo2->threshold != th->sequence) + continue; + + if (mo2->health != th->pointnum) + continue; + + target = mo2; + break; } if (!target) @@ -2607,36 +2611,6 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) // Find the actual target movement waypoint target = first; - /*for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) - { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)wp; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == th->sequence) - { - if (th->direction == -1) // highest waypoint # - { - if (mo2->health == first->health - 1) - { - target = mo2; - break; - } - } - else // waypoint 0 - { - if (mo2->health == first->health + 1) - { - target = mo2; - break; - } - } - } - }*/ if (!target) { diff --git a/src/p_saveg.c b/src/p_saveg.c index e260321be..a0c1add47 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1856,7 +1856,7 @@ static void P_NetArchiveThinkers(void) continue; } #ifdef PARANOIA - else if (th->function.acv != P_RemoveThinkerDelayed) // wait garbage collection + else if (th->function.acp1 != P_RemoveThinkerDelayed) // wait garbage collection I_Error("unknown thinker type %p", th->function.acp1); #endif } @@ -1881,8 +1881,10 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) continue; mobj = (mobj_t *)th; - if (mobj->mobjnum == oldposition) - return mobj; + if (mobj->mobjnum != oldposition) + continue; + + return mobj; } CONS_Debug(DBG_GAMELOGIC, "mobj not found\n"); return NULL; @@ -2881,12 +2883,14 @@ static void P_NetUnArchiveThinkers(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)T_ExecutorDelay) - { - delay = (void *)currentthinker; - if ((mobjnum = (UINT32)(size_t)delay->caller)) - delay->caller = P_FindNewPosition(mobjnum); - } + if (currentthinker->function.acp1 != (actionf_p1)T_ExecutorDelay) + continue; + + delay = (void *)currentthinker; + if (!(mobjnum = (UINT32)(size_t)delay->caller)) + continue; + + delay->caller = P_FindNewPosition(mobjnum); } } } @@ -2995,11 +2999,10 @@ static inline void P_FinishMobjs(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) - { - mobj = (mobj_t *)currentthinker; - mobj->info = &mobjinfo[mobj->type]; - } + if (currentthinker->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + mobj = (mobj_t *)currentthinker; + mobj->info = &mobjinfo[mobj->type]; } } @@ -3013,69 +3016,69 @@ static void P_RelinkPointers(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) + if (currentthinker->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mobj = (mobj_t *)currentthinker; + + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + continue; + + if (mobj->tracer) { - mobj = (mobj_t *)currentthinker; - - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) - continue; - - if (mobj->tracer) - { - temp = (UINT32)(size_t)mobj->tracer; - mobj->tracer = NULL; - if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); - } - if (mobj->target) - { - temp = (UINT32)(size_t)mobj->target; - mobj->target = NULL; - if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); - } - if (mobj->hnext) - { - temp = (UINT32)(size_t)mobj->hnext; - mobj->hnext = NULL; - if (!P_SetTarget(&mobj->hnext, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); - } - if (mobj->hprev) - { - temp = (UINT32)(size_t)mobj->hprev; - mobj->hprev = NULL; - if (!P_SetTarget(&mobj->hprev, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->capsule) - { - temp = (UINT32)(size_t)mobj->player->capsule; - mobj->player->capsule = NULL; - if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis1) - { - temp = (UINT32)(size_t)mobj->player->axis1; - mobj->player->axis1 = NULL; - if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis2) - { - temp = (UINT32)(size_t)mobj->player->axis2; - mobj->player->axis2 = NULL; - if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->awayviewmobj) - { - temp = (UINT32)(size_t)mobj->player->awayviewmobj; - mobj->player->awayviewmobj = NULL; - if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); - } + temp = (UINT32)(size_t)mobj->tracer; + mobj->tracer = NULL; + if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); + } + if (mobj->target) + { + temp = (UINT32)(size_t)mobj->target; + mobj->target = NULL; + if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); + } + if (mobj->hnext) + { + temp = (UINT32)(size_t)mobj->hnext; + mobj->hnext = NULL; + if (!P_SetTarget(&mobj->hnext, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); + } + if (mobj->hprev) + { + temp = (UINT32)(size_t)mobj->hprev; + mobj->hprev = NULL; + if (!P_SetTarget(&mobj->hprev, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->capsule) + { + temp = (UINT32)(size_t)mobj->player->capsule; + mobj->player->capsule = NULL; + if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->axis1) + { + temp = (UINT32)(size_t)mobj->player->axis1; + mobj->player->axis1 = NULL; + if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->axis2) + { + temp = (UINT32)(size_t)mobj->player->axis2; + mobj->player->axis2 = NULL; + if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->awayviewmobj) + { + temp = (UINT32)(size_t)mobj->player->awayviewmobj; + mobj->player->awayviewmobj = NULL; + if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); } } } @@ -3451,13 +3454,12 @@ void P_SaveNetGame(void) { for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - { - mobj = (mobj_t *)th; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) - continue; - mobj->mobjnum = i++; - } + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + mobj = (mobj_t *)th; + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + continue; + mobj->mobjnum = i++; } } diff --git a/src/p_spec.c b/src/p_spec.c index e5068f99b..3e6603133 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3034,7 +3034,7 @@ boolean P_IsFlagAtBase(mobjtype_t flag) { thinker_t *think; mobj_t *mo; - INT32 specialnum = 0; + INT32 specialnum = (flag == MT_REDFLAG) ? 3 : 4; for (think = thinkercap.next; think != &thinkercap; think = think->next) { @@ -3046,11 +3046,6 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (mo->type != flag) continue; - if (mo->type == MT_REDFLAG) - specialnum = 3; - else if (mo->type == MT_BLUEFLAG) - specialnum = 4; - if (GETSECSPECIAL(mo->subsector->sector->special, 4) == specialnum) return true; else if (mo->subsector->sector->ffloors) // Check the 3D floors @@ -3065,9 +3060,11 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (GETSECSPECIAL(rover->master->frontsector->special, 4) != specialnum) continue; - if (mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) - && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector)) - return true; + if (!(mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) + && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))) + continue; + + return true; } } } @@ -3479,8 +3476,11 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_EGGTRAP) - P_KillMobj(mo2, NULL, player->mo); + + if (mo2->type != MT_EGGTRAP) + continue; + + P_KillMobj(mo2, NULL, player->mo); } // clear the special so you can't push the button twice. diff --git a/src/r_defs.h b/src/r_defs.h index 2de7985e8..3fe14545c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -25,7 +25,6 @@ #include "screen.h" // MAXVIDWIDTH, MAXVIDHEIGHT - // // ClipWallSegment // Clips the given range of columns diff --git a/src/r_main.c b/src/r_main.c index abf2d8310..44af40541 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1208,7 +1208,6 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) ret = &subsectors[nodenum & ~NF_SUBSECTOR]; for (i = 0; i < ret->numlines; i++) - //if (R_PointOnSegSide(x, y, &segs[ret->firstline + i])) -- breaks in ogl because polyvertex_t cast over vertex pointers if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) return 0; diff --git a/src/r_plane.c b/src/r_plane.c index 3e202993a..ec5aa90eb 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -533,8 +533,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) } else { - unsigned hash = - visplane_hash(pl->picnum, pl->lightlevel, pl->height); + unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height); new_pl = new_visplane(hash); } diff --git a/src/r_segs.c b/src/r_segs.c index 8c072bbe2..babad0ac1 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1545,8 +1545,7 @@ static void R_RenderSegLoop (void) if (maskedtexture || numthicksides) { - // save texturecol - // for backdrawing of masked mid texture + // save texturecol for backdrawing of masked mid texture maskedtexturecol[rw_x] = (INT16)texturecolumn; if (maskedtextureheight != NULL) { @@ -1979,19 +1978,17 @@ void R_StoreWallRange(INT32 start, INT32 stop) //SoM: 3/25/2000: This code fixes an automap bug that didn't check // frontsector->ceiling and backsector->floor to see if a door was closed. // Without the following code, sprites get displayed behind closed doors. + if (doorclosed || (worldhigh <= worldbottom && worldhighslope <= worldbottomslope)) { - if (doorclosed || (worldhigh <= worldbottom && worldhighslope <= worldbottomslope)) - { - ds_p->sprbottomclip = negonearray; - ds_p->bsilheight = INT32_MAX; - ds_p->silhouette |= SIL_BOTTOM; - } - if (doorclosed || (worldlow >= worldtop && worldlowslope >= worldtopslope)) - { // killough 1/17/98, 2/8/98 - ds_p->sprtopclip = screenheightarray; - ds_p->tsilheight = INT32_MIN; - ds_p->silhouette |= SIL_TOP; - } + ds_p->sprbottomclip = negonearray; + ds_p->bsilheight = INT32_MAX; + ds_p->silhouette |= SIL_BOTTOM; + } + if (doorclosed || (worldlow >= worldtop && worldlowslope >= worldtopslope)) + { // killough 1/17/98, 2/8/98 + ds_p->sprtopclip = screenheightarray; + ds_p->tsilheight = INT32_MIN; + ds_p->silhouette |= SIL_TOP; } } @@ -2092,9 +2089,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } // check BOTTOM TEXTURE - if (worldlow > worldbottom - || worldlowslope > worldbottomslope - ) //seulement si VISIBLE!!! + if (worldlow > worldbottom || worldlowslope > worldbottomslope) // Only if VISIBLE!!! { // bottom texture bottomtexture = R_GetTextureNum(sidedef->bottomtexture); @@ -2856,7 +2851,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) } else #endif - R_RenderSegLoop(); + + R_RenderSegLoop(); colfunc = wallcolfunc; if (portalline) // if curline is a portal, set portalrender for drawseg diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 495c96e18..92f39bba9 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -844,6 +844,11 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) #endif } + if (FOCUSUNION == oldfocus) // No state change + { + return; + } + #ifdef USE_FBO_OGL if (windowmoved && rendermode == render_opengl) { @@ -851,11 +856,6 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) } #endif - if (FOCUSUNION == oldfocus) // No state change - { - return; - } - if (mousefocus && kbfocus) { // Tell game we got focus back, resume music if necessary diff --git a/src/w_wad.c b/src/w_wad.c index 8df0654f0..be287d51e 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -181,8 +181,11 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors) { FILE *handle; - if (filenamebuf != *filename) { - // avoid overlap + // Officially, strncpy should not have overlapping buffers, since W_VerifyNMUSlumps is called after this, and it + // changes filename to point at filenamebuf, it would technically be doing that. I doubt any issue will occur since + // they point to the same location, but it's better to be safe and this is a simple change. + if (filenamebuf != *filename) + { strncpy(filenamebuf, *filename, MAX_WADPATH); filenamebuf[MAX_WADPATH - 1] = '\0'; *filename = filenamebuf; -- 2.54.0 From e0f46ea80d5db27a45dc1924c979297de6e31ee3 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Sep 2024 17:44:55 +0200 Subject: [PATCH 430/525] oop --- src/p_local.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 4eb927a58..0193ec09d 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -248,7 +248,7 @@ void P_RecalcPrecipInSector(sector_t *sector); void P_PrecipitationEffects(void); void P_RemoveMobj(mobj_t *th); -boolean P_MobjWasRemoved(mobj_t *th); +boolean P_MobjWasRemoved(const 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); @@ -291,7 +291,7 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 aimtype #define P_SpawnNameFinder(s,t) P_SPMAngle(s,t,s->angle,true,0) #endif void P_ColorTeamMissile(mobj_t *missile, player_t *source); -SINT8 P_MobjFlip(mobj_t *mobj); +SINT8 P_MobjFlip(const mobj_t *mobj); fixed_t P_GetMobjGravity(mobj_t *mo); FUNCMATH boolean P_WeaponOrPanel(mobjtype_t type); -- 2.54.0 From e614decae0991c6780d9623a33e027bf69a88a2c Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Sep 2024 17:45:57 +0200 Subject: [PATCH 431/525] optimize MT_TUBEWAYPOINT Store waypoints at map load instead of iterating through the thinker list to find them https://git.do.srb2.org/STJr/SRB2/-/merge_requests/938 --- src/doomstat.h | 12 ++++ src/p_mobj.c | 9 ++- src/p_polyobj.c | 144 +++--------------------------------------------- src/p_setup.c | 97 ++++++++++++++++++++++++++++++++ src/p_spec.c | 135 +++------------------------------------------ src/p_user.c | 26 +-------- 6 files changed, 133 insertions(+), 290 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 3f90eb531..35ae67d1b 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -510,6 +510,18 @@ extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF +#define WAYPOINTSEQUENCESIZE 256 +#define NUMWAYPOINTSEQUENCES 256 +extern mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE]; +extern UINT16 numwaypoints[NUMWAYPOINTSEQUENCES]; + +void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint); +mobj_t *P_GetFirstWaypoint(UINT8 sequence); +mobj_t *P_GetLastWaypoint(UINT8 sequence); +mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap); +mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap); +mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo); + // ===================================== // Internal parameters, used for engine. // ===================================== diff --git a/src/p_mobj.c b/src/p_mobj.c index 9fc06c0b7..f2a9a20d5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11453,9 +11453,14 @@ ML_NOCLIMB : Direction not controllable mobj->threshold = min(mthing->extrainfo, 7); break; case MT_TUBEWAYPOINT: - mobj->health = mthing->angle & 255; - mobj->threshold = mthing->angle >> 8; + { + UINT8 sequence = mthing->angle >> 8; + UINT8 id = mthing->angle & 255; + mobj->health = id; + mobj->threshold = sequence; + P_AddWaypoint(sequence, id, mobj); break; + } case MT_NIGHTSDRONE: if (mthing->angle > 0) mobj->health = mthing->angle; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index b9a9113de..887e1c751 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1833,12 +1833,12 @@ void T_PolyObjMove(polymove_t *th) // void T_PolyObjWaypoint(polywaypoint_t *th) { - mobj_t *mo2; mobj_t *target = NULL; mobj_t *waypoint = NULL; - thinker_t *wp; + mobj_t *mo2; fixed_t adjustx, adjusty, adjustz; fixed_t momx, momy, momz, dist; + thinker_t *wp; INT32 start; polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); polyobj_t *oldpo = po; @@ -1943,37 +1943,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { CONS_Debug(DBG_POLYOBJ, "Looking for next waypoint...\n"); - // Find next waypoint - for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) - { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)wp; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == th->sequence) - { - if (th->direction == -1) - { - if (mo2->health == target->health - 1) - { - waypoint = mo2; - break; - } - } - else - { - if (mo2->health == target->health + 1) - { - waypoint = mo2; - break; - } - } - } - } + waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false); if (!waypoint && th->wrap) // If specified, wrap waypoints { @@ -1983,35 +1953,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) th->stophere = true; } - for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) - { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)wp; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == th->sequence) - { - if (th->direction == -1) - { - if (waypoint == NULL) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; - } - else - { - if (mo2->health == 0) - { - waypoint = mo2; - break; - } - } - } - } + waypoint = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence); } else if (!waypoint && th->comeback) // Come back to the start { @@ -2020,36 +1962,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (!th->continuous) th->comeback = false; - for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) - { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)wp; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == th->sequence) - { - if (th->direction == -1) - { - if (mo2->health == target->health - 1) - { - waypoint = mo2; - break; - } - } - else - { - if (mo2->health == target->health + 1) - { - waypoint = mo2; - break; - } - } - } - } + waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false); } } @@ -2499,11 +2412,9 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) polyobj_t *po; polyobj_t *oldpo; polywaypoint_t *th; - mobj_t *mo2; mobj_t *first = NULL; mobj_t *last = NULL; mobj_t *target = NULL; - thinker_t *wp; INT32 start; if (!(po = Polyobj_GetForNum(pwdata->polyObjNum))) @@ -2529,10 +2440,7 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) th->polyObjNum = pwdata->polyObjNum; th->speed = pwdata->speed; th->sequence = pwdata->sequence; // Used to specify sequence # - if (pwdata->reverse) - th->direction = -1; - else - th->direction = 1; + th->direction = pwdata->reverse ? -1 : 1; th->comeback = pwdata->comeback; th->continuous = pwdata->continuous; @@ -2540,44 +2448,8 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) th->stophere = false; // Find the first waypoint we need to use - for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) - { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)wp; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == th->sequence) - { - if (th->direction == -1) // highest waypoint # - { - if (mo2->health == 0) - last = mo2; - else - { - if (first == NULL) - first = mo2; - else if (mo2->health > first->health) - first = mo2; - } - } - else // waypoint 0 - { - if (mo2->health == 0) - first = mo2; - else - { - if (last == NULL) - last = mo2; - else if (mo2->health > last->health) - last = mo2; - } - } - } - } + first = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence); + last = (th->direction == -1) ? P_GetFirstWaypoint(th->sequence) : P_GetLastWaypoint(th->sequence); if (!first) { diff --git a/src/p_setup.c b/src/p_setup.c index c03dea812..691ec0965 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -146,6 +146,101 @@ mapthing_t *playerstarts[MAXPLAYERS]; mapthing_t *bluectfstarts[MAXPLAYERS]; mapthing_t *redctfstarts[MAXPLAYERS]; +// Maintain waypoints +mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE]; +UINT16 numwaypoints[NUMWAYPOINTSEQUENCES]; + +void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint) +{ + waypoints[sequence][id] = waypoint; + if (id >= numwaypoints[sequence]) + numwaypoints[sequence] = id + 1; +} + +static void P_ResetWaypoints(void) +{ + UINT16 sequence, id; + for (sequence = 0; sequence < NUMWAYPOINTSEQUENCES; sequence++) + { + for (id = 0; id < numwaypoints[sequence]; id++) + waypoints[sequence][id] = NULL; + + numwaypoints[sequence] = 0; + } +} + +mobj_t *P_GetFirstWaypoint(UINT8 sequence) +{ + return waypoints[sequence][0]; +} + +mobj_t *P_GetLastWaypoint(UINT8 sequence) +{ + return waypoints[sequence][numwaypoints[sequence] - 1]; +} + +mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap) +{ + UINT8 sequence = current->threshold; + UINT8 id = current->health; + + if (id == 0) + { + if (!wrap) + return NULL; + + id = numwaypoints[sequence] - 1; + } + else + id--; + + return waypoints[sequence][id]; +} + +mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap) +{ + UINT8 sequence = current->threshold; + UINT8 id = current->health; + + if (id == numwaypoints[sequence] - 1) + { + if (!wrap) + return NULL; + + id = 0; + } + else + id++; + + return waypoints[sequence][id]; +} + +mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo) +{ + UINT8 wp; + mobj_t *mo2, *result = NULL; + fixed_t bestdist = 0; + fixed_t curdist; + + for (wp = 0; wp < numwaypoints[sequence]; wp++) + { + mo2 = waypoints[sequence][wp]; + + if (!mo2) + continue; + + curdist = P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z); + + if (result && curdist > bestdist) + continue; + + result = mo2; + bestdist = curdist; + } + + return result; +} + // Global state for PartialAddWadFile/MultiSetupWadFiles // Might be replacable with parameters, but non-trivial when the functions are called on separate tics static SINT8 partadd_stage = -1; @@ -2782,6 +2877,8 @@ boolean P_SetupLevel(boolean skipprecip) for (i = 0; i < 2; i++) skyboxmo[i] = NULL; + P_ResetWaypoints(); + P_MapStart(); if (lastloadedmaplumpnum) diff --git a/src/p_spec.c b/src/p_spec.c index 3e6603133..f09e06d75 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3789,9 +3789,7 @@ DoneSection2: INT32 sequence; fixed_t speed; INT32 lineindex; - thinker_t *th; mobj_t *waypoint = NULL; - mobj_t *mo2; angle_t an; if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) @@ -3810,22 +3808,7 @@ DoneSection2: speed = abs(lines[lineindex].dx)/8; sequence = abs(lines[lineindex].dy)>>FRACBITS; - // scan the thinkers - // to find the first waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence - && mo2->health == 0) - { - waypoint = mo2; - break; - } - } + waypoint = P_GetFirstWaypoint(sequence); if (!waypoint) { @@ -3865,9 +3848,7 @@ DoneSection2: INT32 sequence; fixed_t speed; INT32 lineindex; - thinker_t *th; mobj_t *waypoint = NULL; - mobj_t *mo2; angle_t an; if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) @@ -3886,23 +3867,7 @@ DoneSection2: speed = -(abs(lines[lineindex].dx)/8); // Negative means reverse sequence = abs(lines[lineindex].dy)>>FRACBITS; - // scan the thinkers - // to find the last waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence) - { - if (!waypoint) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; - } - } + waypoint = P_GetLastWaypoint(sequence); if (!waypoint) { @@ -4057,15 +4022,12 @@ DoneSection2: INT32 sequence; fixed_t speed; INT32 lineindex; - thinker_t *th; mobj_t *waypointmid = NULL; mobj_t *waypointhigh = NULL; mobj_t *waypointlow = NULL; - mobj_t *mo2; mobj_t *closest = NULL; line_t junk; vertex_t v1, v2, resulthigh, resultlow; - mobj_t *highest = NULL; if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) break; @@ -4105,98 +4067,16 @@ DoneSection2: // Determine the closest spot on the line between the three waypoints // Put player at that location. - // scan the thinkers - // to find the first waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; + waypointmid = P_GetClosestWaypoint(sequence, player->mo); - mo2 = (mobj_t *)th; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold != sequence) - continue; - - if (!highest) - highest = mo2; - else if (mo2->health > highest->health) // Find the highest waypoint # in case we wrap - highest = mo2; - - if (closest && P_AproxDistance(P_AproxDistance(player->mo->x-mo2->x, player->mo->y-mo2->y), - player->mo->z-mo2->z) > P_AproxDistance(P_AproxDistance(player->mo->x-closest->x, - player->mo->y-closest->y), player->mo->z-closest->z)) - continue; - - // Found a target - closest = mo2; - } - - waypointmid = closest; - - closest = NULL; - - if (waypointmid == NULL) + if (!waypointmid) { CONS_Debug(DBG_GAMELOGIC, "ERROR: WAYPOINT(S) IN SEQUENCE %d NOT FOUND.\n", sequence); break; } - // Find waypoint before this one (waypointlow) - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold != sequence) - continue; - - if (waypointmid->health == 0) - { - if (mo2->health != highest->health) - continue; - } - else if (mo2->health != waypointmid->health - 1) - continue; - - // Found a target - waypointlow = mo2; - break; - } - - // Find waypoint after this one (waypointhigh) - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold != sequence) - continue; - - if (waypointmid->health == highest->health) - { - if (mo2->health != 0) - continue; - } - else if (mo2->health != waypointmid->health + 1) - continue; - - // Found a target - waypointhigh = mo2; - break; - } + waypointlow = P_GetPreviousWaypoint(waypointmid, true); + waypointhigh = P_GetNextWaypoint(waypointmid, true); CONS_Debug(DBG_GAMELOGIC, "WaypointMid: %d; WaypointLow: %d; WaypointHigh: %d\n", waypointmid->health, waypointlow ? waypointlow->health : -1, waypointhigh ? waypointhigh->health : -1); @@ -4247,6 +4127,7 @@ DoneSection2: if (lines[lineindex].flags & ML_EFFECT1) // Don't wrap { + mobj_t *highest = P_GetLastWaypoint(sequence); highest->flags |= MF_SLIDEME; } @@ -4258,7 +4139,7 @@ DoneSection2: player->mo->y = resulthigh.y; player->mo->z = resulthigh.z - P_GetPlayerHeight(player); } - else if ((lines[lineindex].flags & ML_EFFECT1) && waypointmid->health == highest->health) + else if ((lines[lineindex].flags & ML_EFFECT1) && waypointmid->health == numwaypoints[sequence] - 1) { closest = waypointmid; player->mo->x = resultlow.x; diff --git a/src/p_user.c b/src/p_user.c index 582659c7b..3ceaab49c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2548,10 +2548,7 @@ static void P_MovePlayer(player_t *player) static void P_DoZoomTube(player_t *player) { - INT32 sequence; fixed_t speed; - thinker_t *th; - mobj_t *mo2; mobj_t *waypoint = NULL; fixed_t dist; boolean reverse; @@ -2567,8 +2564,6 @@ static void P_DoZoomTube(player_t *player) speed = abs(player->speed); - sequence = player->mo->tracer->threshold; - // change slope dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); @@ -2600,26 +2595,7 @@ static void P_DoZoomTube(player_t *player) CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n"); // Find next waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == sequence) - { - if ((reverse && mo2->health == player->mo->tracer->health - 1) - || (!reverse && mo2->health == player->mo->tracer->health + 1)) - { - waypoint = mo2; - break; - } - } - } + waypoint = reverse ? P_GetPreviousWaypoint(player->mo->tracer, false) : P_GetNextWaypoint(player->mo->tracer, false); if (waypoint) { -- 2.54.0 From 94ddd014272e4e701846d4f650934b2261bff440 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Sep 2024 14:22:58 +0200 Subject: [PATCH 432/525] optimize pointon functions --- src/p_maputl.c | 29 ++++++++--------------------- src/r_main.c | 7 ++++--- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index 3c91dc922..0063327e6 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -136,21 +136,16 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte // INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line) { - fixed_t dx, dy, left, right; - if (!line->dx) return x <= line->v1->x ? line->dy > 0 : line->dy < 0; if (!line->dy) return y <= line->v1->y ? line->dx < 0 : line->dx > 0; - dx = (x - line->v1->x); - dy = (y - line->v1->y); + x -= line->v1->x; + y -= line->v1->y; - left = FixedMul(line->dy>>FRACBITS, dx); - right = FixedMul(dy, line->dx>>FRACBITS); - - return right < left ? 0 : 1; + return FixedMul(y, line->dx>>FRACBITS) > FixedMul(line->dy>>FRACBITS, x); } // @@ -210,28 +205,20 @@ INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld) // static INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line) { - fixed_t dx, dy, left, right; - if (!line->dx) return x <= line->x ? line->dy > 0 : line->dy < 0; if (!line->dy) return y <= line->y ? line->dx < 0 : line->dx > 0; - dx = (x - line->x); - dy = (y - line->y); + x -= line->x; + y -= line->y; - // try to quickly decide by looking at sign bits - if ((line->dy ^ line->dx ^ dx ^ dy) & 0x80000000) - return ((line->dy ^ dx) & 0x80000000) ? 1 : 0; - - left = FixedMul(line->dy>>8, dx>>8); - right = FixedMul(dy>>8, line->dx>>8); - - return right < left ? 0 : 1; + INT32 mask = ((line->dy ^ line->dx ^ x ^ y) & 0x80000000); + return (mask & ((line->dy ^ x) & 0x80000000)) | + (~mask & (FixedMul(y>>8, line->dx>>8) > FixedMul(line->dy>>8, x>>8))); } - // // P_MakeDivline // diff --git a/src/r_main.c b/src/r_main.c index 44af40541..3bac8fba5 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -400,9 +400,10 @@ PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) y -= ly; // Try to quickly decide by looking at sign bits. - if ((ldy ^ ldx ^ x ^ y) < 0) - return (ldy ^ x) < 0; // (left is negative) - return FixedMul(y, ldx>>FRACBITS) >= FixedMul(ldy>>FRACBITS, x); + // also use a mask to avoid branch prediction + INT32 mask = (ldy ^ ldx ^ x ^ y) >> 31; + return (mask & ((ldy ^ x) < 0)) | // (left is negative) + (~mask & (FixedMul(y, ldx>>FRACBITS) >= FixedMul(ldy>>FRACBITS, x))); } // -- 2.54.0 From 882a3b7824cd359c7fa01a5ac811debee5c0770b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Sep 2024 17:58:35 +0200 Subject: [PATCH 433/525] revert this --- src/p_mobj.c | 60 ++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index f2a9a20d5..d50862da5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10081,21 +10081,13 @@ void P_RemoveMobj(mobj_t *mobj) if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) { - if (mobj->hnext->hprev == mobj) - { - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); - } - + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); P_SetTarget(&mobj->hnext, NULL); } if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) { - if (mobj->hprev->hnext == mobj) - { - P_SetTarget(&mobj->hprev->hnext, cachenext); - } - + P_SetTarget(&mobj->hprev->hnext, cachenext); P_SetTarget(&mobj->hprev, NULL); } @@ -10103,35 +10095,39 @@ void P_RemoveMobj(mobj_t *mobj) if (mobj->spawnpoint) mobj->spawnpoint->mobj = NULL; - R_RemoveMobjInterpolator(mobj); - -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); -#endif - // free block - if (!mobj->thinker.next) + // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. + if (mobj->flags & MF_NOTHINK && !mobj->thinker.next) { // Uh-oh, the mobj doesn't think, P_RemoveThinker would never go through! - INT32 prevreferences; if (!mobj->thinker.references) { - Z_Free(mobj); // No references? Can be removed immediately! :D - return; +#ifdef SCRAMBLE_REMOVED + // Invalidate mobj_t data to cause crashes if accessed! + memset(mobj, 0xff, sizeof(mobj_t)); +#endif + Z_Free(mobj); // No refrences? Can be removed immediately! :D } - - prevreferences = mobj->thinker.references; - P_AddThinker((thinker_t *)mobj); - mobj->thinker.references = prevreferences; + else + { // Add thinker just to delay removing it until refrences are gone. + mobj->flags &= ~MF_NOTHINK; + P_AddThinker((thinker_t *)mobj); +#ifdef SCRAMBLE_REMOVED + // Invalidate mobj_t data to cause crashes if accessed! + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); +#endif + P_RemoveThinker((thinker_t *)mobj); + } + } + else + { +#ifdef SCRAMBLE_REMOVED + // Invalidate mobj_t data to cause crashes if accessed! + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); +#endif + P_RemoveThinker((thinker_t *)mobj); } - P_RemoveThinker((thinker_t *)mobj); - - // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); -#endif + R_RemoveMobjInterpolator(mobj); } // This does not need to be added to Lua. -- 2.54.0 From df6a31767ec3c155b5a660f2045535d5c143e420 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 2 Sep 2024 21:43:24 +0300 Subject: [PATCH 434/525] Make server send serverinfo packet so client can know server name even when connecting just by ip --- src/d_clisrv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1efd88623..d738bad96 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4657,6 +4657,7 @@ static void HandleConnect(SINT8 node) /// \todo fix this !!! return; // restart the while } + SV_SendServerInfo(node, 0); // Dunno if 0 time is good idea //if (gamestate != GS_LEVEL) // GS_INTERMISSION, etc? // SV_SendPlayerConfigs(node); // send bare minimum player info G_SetGamestate(backupstate); @@ -4733,6 +4734,9 @@ static void HandleServerInfo(SINT8 node) netbuffer->u.serverinfo.gametype = (UINT8)((netbuffer->u.serverinfo.gametype == VANILLA_GT_MATCH) ? GT_MATCH : GT_RACE); SL_InsertServer(&netbuffer->u.serverinfo, node); + + if (client && cl_mode > CL_SEARCHING && node == servernode) + memcpy(connectedservername, netbuffer->u.serverinfo.servername, MAXSERVERNAME); } #endif -- 2.54.0 From 7ef4eedd06f274deafa595c73aa91a60f9ad4837 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 15:03:59 +0200 Subject: [PATCH 435/525] Revert "optimize pointon functions" This reverts commit 94ddd014272e4e701846d4f650934b2261bff440. may be readded in v7.1 since this is pretty sensitive code and i dont want to desynch or crap so this def needs more testing --- src/p_maputl.c | 29 +++++++++++++++++++++-------- src/r_main.c | 7 +++---- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index 0063327e6..3c91dc922 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -136,16 +136,21 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte // INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line) { + fixed_t dx, dy, left, right; + if (!line->dx) return x <= line->v1->x ? line->dy > 0 : line->dy < 0; if (!line->dy) return y <= line->v1->y ? line->dx < 0 : line->dx > 0; - x -= line->v1->x; - y -= line->v1->y; + dx = (x - line->v1->x); + dy = (y - line->v1->y); - return FixedMul(y, line->dx>>FRACBITS) > FixedMul(line->dy>>FRACBITS, x); + left = FixedMul(line->dy>>FRACBITS, dx); + right = FixedMul(dy, line->dx>>FRACBITS); + + return right < left ? 0 : 1; } // @@ -205,20 +210,28 @@ INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld) // static INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line) { + fixed_t dx, dy, left, right; + if (!line->dx) return x <= line->x ? line->dy > 0 : line->dy < 0; if (!line->dy) return y <= line->y ? line->dx < 0 : line->dx > 0; - x -= line->x; - y -= line->y; + dx = (x - line->x); + dy = (y - line->y); - INT32 mask = ((line->dy ^ line->dx ^ x ^ y) & 0x80000000); - return (mask & ((line->dy ^ x) & 0x80000000)) | - (~mask & (FixedMul(y>>8, line->dx>>8) > FixedMul(line->dy>>8, x>>8))); + // try to quickly decide by looking at sign bits + if ((line->dy ^ line->dx ^ dx ^ dy) & 0x80000000) + return ((line->dy ^ dx) & 0x80000000) ? 1 : 0; + + left = FixedMul(line->dy>>8, dx>>8); + right = FixedMul(dy>>8, line->dx>>8); + + return right < left ? 0 : 1; } + // // P_MakeDivline // diff --git a/src/r_main.c b/src/r_main.c index 3bac8fba5..44af40541 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -400,10 +400,9 @@ PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) y -= ly; // Try to quickly decide by looking at sign bits. - // also use a mask to avoid branch prediction - INT32 mask = (ldy ^ ldx ^ x ^ y) >> 31; - return (mask & ((ldy ^ x) < 0)) | // (left is negative) - (~mask & (FixedMul(y, ldx>>FRACBITS) >= FixedMul(ldy>>FRACBITS, x))); + if ((ldy ^ ldx ^ x ^ y) < 0) + return (ldy ^ x) < 0; // (left is negative) + return FixedMul(y, ldx>>FRACBITS) >= FixedMul(ldy>>FRACBITS, x); } // -- 2.54.0 From 17f8996afcd1061d21b2f9f7e01f576d7c470b2b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 15:23:14 +0200 Subject: [PATCH 436/525] revert pretty much all mobj changes for now might reapply them some other time, but since we need to maintain vanilla compat as much as possible gonna revert crap kinda sick of desynching stuffs and honestly most the mobj stuff rarely ever crashes --- src/k_kart.c | 13 ++++++------- src/p_inter.c | 4 ++-- src/p_mobj.c | 4 ++-- src/p_tick.c | 10 +++++----- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index fe0cd4eb9..cf1d59f42 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4171,9 +4171,6 @@ void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source) mobj_t *cachenext; killnext: - if (P_MobjWasRemoved(banana)) - return; - cachenext = banana->hnext; if (banana->health) @@ -4461,8 +4458,10 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct - if (orbit->target && orbit->target->player && !P_MobjWasRemoved(orbit->target)) + if (orbit->target && orbit->target->player) { + player_t *player = orbit->target->player; + INT32 num = 0; mobj_t *cur = orbit->target->hnext; @@ -4472,14 +4471,14 @@ void K_RepairOrbitChain(mobj_t *orbit) { prev = cur; cur = cur->hnext; - if (++num > orbit->target->player->kartstuff[k_itemamount]) + if (++num > player->kartstuff[k_itemamount]) P_RemoveMobj(prev); else prev->movedir = num; } - if (orbit->target && !P_MobjWasRemoved(orbit->target) && orbit->target->player->kartstuff[k_itemamount] != num) - orbit->target->player->kartstuff[k_itemamount] = num; + if (player->kartstuff[k_itemamount] != num) + player->kartstuff[k_itemamount] = num; } } diff --git a/src/p_inter.c b/src/p_inter.c index 39babc14d..9d00822f3 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1646,7 +1646,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) // SRB2kart // I wish I knew a better way to do this - if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) + if (target->target && target->target->player && target->target->player->mo) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) target->target->player->kartstuff[k_eggmanheld] = 0; @@ -1659,7 +1659,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount]) { - if (target->target->hnext && !P_MobjWasRemoved(target->target->hnext)) + if (target->target->hnext) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; } diff --git a/src/p_mobj.c b/src/p_mobj.c index d50862da5..fb450e1dd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10095,6 +10095,8 @@ void P_RemoveMobj(mobj_t *mobj) if (mobj->spawnpoint) mobj->spawnpoint->mobj = NULL; + R_RemoveMobjInterpolator(mobj); + // free block // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. if (mobj->flags & MF_NOTHINK && !mobj->thinker.next) @@ -10126,8 +10128,6 @@ void P_RemoveMobj(mobj_t *mobj) #endif P_RemoveThinker((thinker_t *)mobj); } - - R_RemoveMobjInterpolator(mobj); } // This does not need to be added to Lua. diff --git a/src/p_tick.c b/src/p_tick.c index 7cf876188..206228643 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -227,15 +227,15 @@ void P_RemoveThinkerDelayed(thinker_t *thinker) if (thinker->references) return; - R_DestroyLevelInterpolators(thinker); - + /* Remove from main thinker list */ + thinker_t *next = thinker->next; /* Note that currentthinker is guaranteed to point to us, * and since we're freeing our memory, we had better change that. So * point it to thinker->prev, so the iterator will correctly move on to * thinker->prev->next = thinker->next */ - currentthinker = thinker->prev; - /* Remove from main thinker list */ - P_UnlinkThinker(thinker); + (next->prev = currentthinker = thinker->prev)->next = next; + R_DestroyLevelInterpolators(thinker); + Z_Free(thinker); } // -- 2.54.0 From 821669d03d294638520b54a27209287f6589f5ca Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 15:23:28 +0200 Subject: [PATCH 437/525] Revert "optimize z position checking for mobjs without collision and camera" This reverts commit c11d9255808774e607283c6fe42a2e4b356ab2dc. --- src/p_mobj.c | 8 ++++---- src/r_main.c | 45 --------------------------------------------- src/r_main.h | 1 - 3 files changed, 4 insertions(+), 50 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index fb450e1dd..30455aa45 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -616,7 +616,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (((mobj->flags & MF_NOBLOCKMAP) && (mobj->flags & MF_NOCLIP)) ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -692,7 +692,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (((mobj->flags & MF_NOBLOCKMAP) && (mobj->flags & MF_NOCLIP)) ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -770,7 +770,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -847,7 +847,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point diff --git a/src/r_main.c b/src/r_main.c index 44af40541..b9b30a095 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1125,51 +1125,6 @@ void R_Init(void) framecount = 0; } -// -// R_IsPointInSector -// -boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y) -{ - size_t i; - size_t passes = 0; - - for (i = 0; i < sector->linecount; i++) - { - line_t *line = sector->lines[i]; - vertex_t *v1, *v2; - - if (line->frontsector == line->backsector) - continue; - - v1 = line->v1; - v2 = line->v2; - - // make sure v1 is below v2 - if (v1->y > v2->y) - { - vertex_t *tmp = v1; - v1 = v2; - v2 = tmp; - } - else if (v1->y == v2->y) - // horizontal line, we can't match this - continue; - - if (v1->y < y && y <= v2->y) - { - // if the y axis in inside the line, find the point where we intersect on the x axis... - fixed_t vx = v1->x + (INT64)(v2->x - v1->x) * (y - v1->y) / (v2->y - v1->y); - - // ...and if that point is to the left of the point, count it as inside. - if (vx < x) - passes++; - } - } - - // and odd number of passes means we're inside the polygon. - return passes % 2; -} - // // R_PointInSubsector // diff --git a/src/r_main.h b/src/r_main.h index 81bff3811..490f793f9 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -76,7 +76,6 @@ angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); angle_t R_PlayerSliptideAngle(player_t *player); fixed_t R_ScaleFromGlobalAngle(angle_t visangle); -boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y); subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); -- 2.54.0 From 8760886f579997740655655c24107beb5ba0a6f2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 3 Sep 2024 12:25:22 +0200 Subject: [PATCH 438/525] smol cleanup p_map --- src/p_map.c | 89 ++-------------------------------------------------- src/p_user.c | 2 +- 2 files changed, 4 insertions(+), 87 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index cb2997552..bd551829d 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -319,78 +319,6 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) } } -#if 0 -static void P_DoTailsCarry(player_t *sonic, player_t *tails) -{ - INT32 p; - fixed_t zdist; // z distance between the two players' bottoms - - if ((tails->pflags & PF_CARRIED) && tails->mo->tracer == sonic->mo) - return; - if ((sonic->pflags & PF_CARRIED) && sonic->mo->tracer == tails->mo) - return; - if (tails->bot == 1) - return; - - if (sonic->pflags & PF_NIGHTSMODE) - return; - - if (sonic->mo->tracer && sonic->mo->tracer->type == MT_TUBEWAYPOINT - && !(sonic->pflags & PF_ROPEHANG)) - return; // don't steal players from zoomtubes! - - if ((sonic->mo->eflags & MFE_VERTICALFLIP) != (tails->mo->eflags & MFE_VERTICALFLIP)) - return; // Both should be in same gravity - - if (tails->mo->eflags & MFE_VERTICALFLIP) - { - if (tails->mo->ceilingz - (tails->mo->z + tails->mo->height) < sonic->mo->height-FixedMul(2*FRACUNIT, sonic->mo->scale)) - return; - } - else if (tails->mo->z - tails->mo->floorz < sonic->mo->height-FixedMul(2*FRACUNIT, sonic->mo->scale)) - return; // No room to pick up this guy! - - // Search in case another player is already being carried by this fox. - for (p = 0; p < MAXPLAYERS; p++) - if (playeringame[p] && players[p].mo - && players[p].pflags & PF_CARRIED && players[p].mo->tracer == tails->mo) - return; - - if (tails->mo->eflags & MFE_VERTICALFLIP) - zdist = (sonic->mo->z + sonic->mo->height) - (tails->mo->z + tails->mo->height); - else - zdist = tails->mo->z - sonic->mo->z; - - if (zdist <= sonic->mo->height + FixedMul(FRACUNIT, sonic->mo->scale) - && zdist > sonic->mo->height*2/3 - && P_MobjFlip(tails->mo)*sonic->mo->momz <= 0) - { - // Why block opposing teams from tailsflying each other? - // Sneaking into the hands of a flying tails player in Race might be a viable strategy, who knows. - if (tails->spectator || sonic->spectator || G_RaceGametype()) // SRB2kart - sonic->pflags &= ~PF_CARRIED; - else - { - if (sonic-players == consoleplayer && botingame) - //CV_SetValue(&cv_analog2, false); - P_ResetPlayer(sonic); - P_SetTarget(&sonic->mo->tracer, tails->mo); - sonic->pflags |= PF_CARRIED; - S_StartSound(sonic->mo, sfx_s3k4a); - P_UnsetThingPosition(sonic->mo); - sonic->mo->x = tails->mo->x; - sonic->mo->y = tails->mo->y; - P_SetThingPosition(sonic->mo); - } - } - else { - if (sonic-players == consoleplayer && botingame) - //CV_SetValue(&cv_analog2, true); - sonic->pflags &= ~PF_CARRIED; - } -} -#endif - // // PIT_CheckThing // @@ -588,9 +516,6 @@ static boolean PIT_CheckThing(mobj_t *thing) // check for skulls slamming into things if (tmthing->flags2 & MF2_SKULLFLY) { - /*if (tmthing->type == MT_EGGMOBILE) // Don't make Eggman stop! - return true; // Let him RUN YOU RIGHT OVER. >:3 - else*/ { // see if it went over / under if (tmthing->z > thing->z + thing->height) @@ -1676,7 +1601,7 @@ static boolean PIT_CheckLine(line_t *ld) if (P_BoxOnLineSide(tmbbox, ld) != -1) return true; -if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. + if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. { fixed_t cosradius, sinradius; cosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); @@ -2477,14 +2402,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12) || GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 12) maxstep = 0; - - // Don't 'step up' while springing, - // Only step up "if needed". - /* // SRB2kart - don't need - if (thing->state == &states[S_PLAY_SPRING] - && P_MobjFlip(thing)*thing->momz > FixedMul(FRACUNIT, thing->scale)) - maxstep = 0; - */ } if (thing->type == MT_SKIM) @@ -4146,7 +4063,7 @@ static inline boolean PIT_GetSectors(line_t *ld) tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; + return true; if (P_BoxOnLineSide(tmbbox, ld) != -1) return true; @@ -4181,7 +4098,7 @@ static inline boolean PIT_GetPrecipSectors(line_t *ld) preciptmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || preciptmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || preciptmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; + return true; if (P_BoxOnLineSide(preciptmbbox, ld) != -1) return true; diff --git a/src/p_user.c b/src/p_user.c index 3ceaab49c..7d9e0e21f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4928,7 +4928,7 @@ void P_PlayerAfterThink(player_t *player) #ifdef SECTORSPECIALSAFTERTHINK if (player->onconveyor != 1 || !P_IsObjectOnGround(player->mo)) - player->onconveyor = 0; + player->onconveyor = 0; // check special sectors : damage & secrets if (!player->spectator) -- 2.54.0 From 0cc86430ca45fc54402726f4c900904bc726cf28 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 15:02:31 +0200 Subject: [PATCH 439/525] smol cleanup hw_shaders --- src/hardware/hw_shaders.c | 42 +++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index b58ca4137..d7924a675 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -499,47 +499,52 @@ static void HWR_TryToCompileShaderWithImplicitVersion(INT32 shader_index, INT32 boolean vert_shader_version_exists = HWR_VersionDirectiveExists(vert_shader); boolean frag_shader_version_exists = HWR_VersionDirectiveExists(frag_shader); - if(!vert_shader_version_exists) { + if (!vert_shader_version_exists) CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: vertex shader '%s' is missing a #version directive\n", HWR_GetShaderName(shaderxlat_id)); - } - if(!frag_shader_version_exists) { + if (!frag_shader_version_exists) CONS_Alert(CONS_WARNING, "HWR_LoadCustomShadersFromFile: fragment shader '%s' is missing a #version directive\n", HWR_GetShaderName(shaderxlat_id)); - } // try to compile as is HWR_CompileShader(shader_index); + if (gl_shaders[shader_index].compiled) return; // try each version directive - for(UINT32 i = 0; i < sizeof(version_directives) / sizeof(version_directives[0]); ++i) { + for (UINT32 i = 0; i < sizeof(version_directives) / sizeof(version_directives[0]); ++i) + { CONS_Alert(CONS_NOTICE, "HWR_TryToCompileShaderWithImplicitVersion: Trying %s\n", version_directives[i]); - if(!vert_shader_version_exists) { + if (!vert_shader_version_exists) + { // first time reallocation would have to be made - if(i == 0) { + if (i == 0) + { void* old = (void*)gl_shaders[shader_index].vertex; vert_shader = gl_shaders[shader_index].vertex = HWR_PrependVersionDirective(vert_shader, i); Z_Free(old); - } else { - HWR_ReplaceVersionInplace(vert_shader, i); } + else + HWR_ReplaceVersionInplace(vert_shader, i); } - if(!frag_shader_version_exists) { - if(i == 0) { + if (!frag_shader_version_exists) + { + if (i == 0) + { void* old = (void*)gl_shaders[shader_index].fragment; frag_shader = gl_shaders[shader_index].fragment = HWR_PrependVersionDirective(frag_shader, i); Z_Free(old); - } else { - HWR_ReplaceVersionInplace(frag_shader, i); } + else + HWR_ReplaceVersionInplace(frag_shader, i); } HWR_CompileShader(shader_index); - if (gl_shaders[shader_index].compiled) { + if (gl_shaders[shader_index].compiled) + { CONS_Alert(CONS_NOTICE, "HWR_TryToCompileShaderWithImplicitVersion: Compiled with %s\n", version_directives[i]); CONS_Alert(CONS_WARNING, "Implicit GLSL version is used. Correct behavior is not guaranteed\n"); @@ -704,17 +709,20 @@ skip_field: { int shader_index = i + NUMSHADERTARGETS; // index to gl_shaders gl_shadertargets[i].custom_shader = shader_index; + // if only one stage (vertex/fragment) is defined, the other one // is copied from the base shaders. if (!gl_shaders[shader_index].fragment) gl_shaders[shader_index].fragment = Z_StrDup(gl_shadersources[i].fragment); + if (!gl_shaders[shader_index].vertex) gl_shaders[shader_index].vertex = Z_StrDup(gl_shadersources[i].vertex); - if(!HWR_CheckVersionDirectives(gl_shaders[shader_index].vertex, gl_shaders[shader_index].fragment)) { + + if (!HWR_CheckVersionDirectives(gl_shaders[shader_index].vertex, gl_shaders[shader_index].fragment)) HWR_TryToCompileShaderWithImplicitVersion(shader_index, i); - } else { + else HWR_CompileShader(shader_index); - } + if (!gl_shaders[shader_index].compiled) CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: A compilation error occured for the %s shader in file %s. See the console messages above for more information.\n", shaderxlat[i].type, wadfiles[wadnum]->filename); } -- 2.54.0 From 853004dad9bef22b18208f75769c0556c90cf22d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 15:03:06 +0200 Subject: [PATCH 440/525] smol cleanup for led stuff again --- src/g_input.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index e16761966..a4046350d 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -932,12 +932,15 @@ INT32 G_GetDeviceForPlayer(INT32 player) inline UINT16 G_GetSkinColor(INT32 player) { - if (gamestate == GS_LEVEL && cv_ledpowerup[player].value && (players[displayplayers[player]].kartstuff[k_invincibilitytimer] || players[displayplayers[player]].powers[pw_invulnerability] || players[displayplayers[player]].kartstuff[k_growshrinktimer])) + // make rgb rainbow vomit when invul or flash blue when grow + if (cv_ledpowerup[player].value && gamestate == GS_LEVEL && players[displayplayers[player]].mo && (players[displayplayers[player]].kartstuff[k_invincibilitytimer] || players[displayplayers[player]].powers[pw_invulnerability] || players[displayplayers[player]].kartstuff[k_growshrinktimer])) return players[displayplayers[player]].mo->color; - if (players[displayplayers[player]].skincolor && gamestate == GS_LEVEL) + // take actual player skincolour when ingame + if (gamestate == GS_LEVEL && players[displayplayers[player]].skincolor) return players[displayplayers[player]].skincolor; + // otherwise just fallback to whatever the cvar is switch (player) { case 0: @@ -976,11 +979,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color) return; } - if (color) - skincolor = color; - else - skincolor = G_GetSkinColor(player); - + skincolor = color ? color : G_GetSkinColor(player); byte_color = V_GetColor(colortranslations[skincolor][8]).s; I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue); -- 2.54.0 From 94218a6549da9f4f542cc0882f7241afafa4be03 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 18:14:53 +0200 Subject: [PATCH 441/525] only call HWR_RenderPlayerView in ogl explictly --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 3bde59775..c42d2e550 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -463,7 +463,7 @@ static boolean D_Display(void) viewssnum = i; #ifdef HWRENDER - if (rendermode != render_soft) + if (rendermode == render_opengl) HWR_RenderPlayerView(i, &players[displayplayers[i]]); else #endif -- 2.54.0 From 596c8e2ecc5c9fffdc426f5a024fe880b1b5f1b9 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 18:30:37 +0200 Subject: [PATCH 442/525] also scale precip sprite with mobjscale when cv_mobjscaleprecip enabled --- src/hardware/hw_main.c | 10 ++++++++-- src/r_fps.c | 4 ++-- src/r_segs.c | 3 +-- src/r_things.c | 26 +++++++++++++++----------- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c2754aa01..a547533fa 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5088,6 +5088,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) float x1, x2; float z1, z2; float rightsin, rightcos; + float this_scale; spritedef_t *sprdef; spriteframe_t *sprframe; size_t lumpoff; @@ -5120,6 +5121,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) R_InterpolatePrecipMobjState(thing, FRACUNIT, &interp); } + this_scale = FIXED_TO_FLOAT(interp.scale); + // transform the origin point tr_x = FIXED_TO_FLOAT(interp.x) - gr_viewx; tr_y = FIXED_TO_FLOAT(interp.y) - gr_viewy; @@ -5172,6 +5175,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) x2 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); } + x1 *= this_scale; + x2 *= this_scale; + z1 = tr_y + x1 * rightsin; z2 = tr_y - x2 * rightsin; x1 = tr_x + x1 * rightcos; @@ -5199,8 +5205,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif // set top/bottom coords - vis->gzt = FIXED_TO_FLOAT(interp.z + spritecachedinfo[lumpoff].topoffset); - vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height); + vis->gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale); + vis->gz = vis->gzt - (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale); vis->precip = true; } diff --git a/src/r_fps.c b/src/r_fps.c index b46c6e51b..53e394785 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -379,7 +379,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->x = mobj->x; out->y = mobj->y; out->z = mobj->z; - out->scale = FRACUNIT; + out->scale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; out->subsector = mobj->subsector; out->angle = mobj->angle; out->spritexscale = mobj->spritexscale; @@ -392,7 +392,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - out->scale = FRACUNIT; + out->scale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; out->spritexscale = mobj->spritexscale; out->spriteyscale = mobj->spriteyscale; out->spritexoffset = mobj->spritexoffset; diff --git a/src/r_segs.c b/src/r_segs.c index babad0ac1..718f93f40 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1686,7 +1686,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) lastopening = openings + pos; if (oldopenings == NULL) - return; + return; // borrowed fix from *cough* zdoom *cough* // [RH] We also need to adjust the openings pointers that @@ -2692,7 +2692,6 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (rover->norender == leveltime) continue; - // Let the renderer know this sector is sloped. if (*rover->b_slope || *rover->t_slope) frontsector->hasslope = true; diff --git a/src/r_things.c b/src/r_things.c index ad1e3ca05..100ca87de 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -902,6 +902,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) INT32 texturecolumn; fixed_t frac; patch_t *patch; + fixed_t this_scale = vis->thingscale; INT64 overflow_test; //Fab : R_InitSprites now sets a wad lump number @@ -925,7 +926,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) dc_colormap += COLORMAP_REMAPOFFSET; dc_iscale = FixedDiv(FRACUNIT, vis->scale); - dc_texturemid = vis->texturemid; + dc_texturemid = FixedDiv(vis->texturemid, this_scale); dc_texheight = 0; frac = vis->startfrac; @@ -1744,7 +1745,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) fixed_t iscale; //SoM: 3/17/2000 - fixed_t gz ,gzt; + fixed_t gz, gzt; + fixed_t this_scale; INT32 dist = 1; @@ -1770,6 +1772,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) R_InterpolatePrecipMobjState(thing, FRACUNIT, &interp); } + this_scale = interp.scale; + // transform the origin point tr_x = interp.x - viewx; tr_y = interp.y - viewy; @@ -1780,7 +1784,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) tz = gxt - gyt; // thing is behind view plane? - if (tz < MINZ) + if (tz < FixedMul(MINZ, this_scale)) return; gxt = -FixedMul(tr_x, viewsin); @@ -1821,14 +1825,14 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) lump = sprframe->lumpid[0]; //Fab: see note above // calculate edges of the shape - tx -= spritecachedinfo[lump].offset; + tx -= FixedMul(spritecachedinfo[lump].offset, this_scale); x1 = (centerxfrac + FixedMul (tx,xscale)) >>FRACBITS; // off the right side? if (x1 > viewwidth) return; - tx += spritecachedinfo[lump].width; + tx += FixedMul(spritecachedinfo[lump].width, this_scale); x2 = ((centerxfrac + FixedMul (tx,xscale)) >>FRACBITS) - 1; // off the left side @@ -1846,8 +1850,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) } //SoM: 3/17/2000: Disregard sprites that are out of view.. - gzt = interp.z + spritecachedinfo[lump].topoffset; - gz = gzt - spritecachedinfo[lump].height; + gzt = interp.z + FixedMul(spritecachedinfo[lump].topoffset, this_scale); + gz = gzt - FixedMul(spritecachedinfo[lump].height, this_scale); if (thing->subsector->sector->cullheight) { @@ -1857,7 +1861,9 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) // store information in a vissprite vis = R_NewVisSprite(); - vis->scale = vis->sortscale = yscale; //<scale = FixedMul(yscale, this_scale); + vis->sortscale = yscale; //<thingscale = interp.scale; vis->dispoffset = 0; // Monster Iestyn: 23/11/15 vis->gx = interp.x; vis->gy = interp.y; @@ -1890,9 +1896,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) iscale = FixedDiv(FRACUNIT, xscale); vis->startfrac = 0; - vis->xiscale = iscale; - - vis->thingscale = interp.scale; + vis->xiscale = FixedDiv(iscale, this_scale); if (vis->x1 > x1) vis->startfrac += vis->xiscale*(vis->x1-x1); -- 2.54.0 From 20b517518074fad72662c0f74d3bdde2cdf08d4b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 18:31:01 +0200 Subject: [PATCH 443/525] scale precip momz with mobjscale when cv_mobjscaleprecip enabled --- src/p_mobj.c | 4 ++-- src/p_spec.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 30455aa45..a53025419 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3633,7 +3633,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) return false; mobj->z = mobj->ceilingz; - mobj->momz = mobj->info->speed; + mobj->momz = cv_mobjscaleprecip.value ? FixedMul(mobj->info->speed, mapobjectscale) : mobj->info->speed; mobj->precipflags &= ~PCF_SPLASH; R_ResetPrecipitationMobjInterpolationState(mobj); } @@ -9975,7 +9975,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->ceilingz = P_GetSectorCeilingZAt(mobj->subsector->sector, x, y); mobj->z = z; - mobj->momz = info->speed; + mobj->momz = cv_mobjscaleprecip.value ? FixedMul(info->speed, mapobjectscale) : info->speed; mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; P_AddThinker(&mobj->thinker); diff --git a/src/p_spec.c b/src/p_spec.c index f09e06d75..c022ef384 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1810,7 +1810,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->tics = st->tics; precipmobj->sprite = st->sprite; precipmobj->frame = st->frame; - precipmobj->momz = mobjinfo[MT_RAIN].speed; + precipmobj->momz = cv_mobjscaleprecip.value ? FixedMul(mobjinfo[MT_RAIN].speed, mapobjectscale) : mobjinfo[MT_RAIN].speed; precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to } @@ -1835,7 +1835,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->tics = st->tics; precipmobj->sprite = st->sprite; precipmobj->frame = st->frame; - precipmobj->momz = mobjinfo[MT_SNOWFLAKE].speed; + precipmobj->momz = cv_mobjscaleprecip.value ? FixedMul(mobjinfo[MT_SNOWFLAKE].speed, mapobjectscale) : mobjinfo[MT_SNOWFLAKE].speed; precipmobj->precipflags &= ~(PCF_INVISIBLE|PCF_SPLASH); // P_PrecipThinker will add this again if it needs to } -- 2.54.0 From ff9b35ab45d16f909b3ac0e6c02dd806658d2081 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 18:47:47 +0200 Subject: [PATCH 444/525] remove IFCHANGED macro, check directly in R_Lerp funcs + inline those basically does the same thing lol just looks better --- src/r_fps.c | 129 ++++++++++++++-------------------------------------- 1 file changed, 33 insertions(+), 96 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 53e394785..9ccba8a7b 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -90,13 +90,17 @@ static size_t levelinterpolators_len; static size_t levelinterpolators_size; -static fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac) +static inline fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac) { + if (from == to) + return to; return from + FixedMul(frac, to - from); } -static angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac) +static inline angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac) { + if (from == to) + return to; return from + FixedMul(frac, to - from); } @@ -281,11 +285,6 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to) return (R_LerpAngle(from, to, rendertimefrac)); }*/ -#define IFCHANGED(a, b)\ -if (mobj->a == mobj->b)\ -(out->a = mobj->a);\ -else - void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) { if (frac == FRACUNIT) @@ -307,60 +306,32 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) return; } - IFCHANGED(x, old_x) - out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); - - IFCHANGED(y, old_y) - out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); - - IFCHANGED(z, old_z) - out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - - IFCHANGED(spritexscale, old_spritexscale) - out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); - - IFCHANGED(spriteyscale, old_spriteyscale) - out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); - - IFCHANGED(spritexoffset, old_spritexoffset) - out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); - - IFCHANGED(spriteyoffset, old_spriteyoffset) - out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); - - IFCHANGED(scale, old_scale) - out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac); - + out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); + out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); + out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); + out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); + out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); + out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); + out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); + out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac); //out->subsector = R_PointInSubsector(out->x, out->y); // why was this even done? out->subsector = mobj->subsector; if (mobj->player) - { - IFCHANGED(angle, player->old_frameangle) - out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac); - } + out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac); else - { - IFCHANGED(angle, old_angle) - out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); - } + out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); #ifdef HWRENDER if (cv_grmdls.value) { // pitch roll stuff - IFCHANGED(pitch, old_pitch) - out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); - - IFCHANGED(roll, old_roll) - out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); + out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); + out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); // and the slope stuff - IFCHANGED(slopepitch, old_slopepitch) - out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); - - IFCHANGED(sloperoll, old_sloperoll) - out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); + out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); + out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); } else #endif @@ -400,14 +371,9 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst //out->subsector = R_PointInSubsector(out->x, out->y); // i dont understand lol out->subsector = mobj->subsector; - - //IFCHANGED(angle, old_angle) - //out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); - out->angle = mobj->angle; + out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); } -#undef IFCHANGED - static void AddInterpolator(levelinterpolator_t* interpolator) { if (levelinterpolators_len >= levelinterpolators_size) @@ -602,11 +568,6 @@ void R_ClearLevelInterpolatorState(thinker_t *thinker) } } -#define IFCHANGED(a, b, c)\ -if (interp->a == interp->b)\ - (interp->a = interp->c);\ -else - void R_ApplyLevelInterpolators(fixed_t frac) { size_t i, ii; @@ -619,57 +580,35 @@ void R_ApplyLevelInterpolators(fixed_t frac) { case LVLINTERP_SectorPlane: if (interp->sectorplane.ceiling) - { - IFCHANGED(sectorplane.sector->ceilingheight, sectorplane.oldheight, sectorplane.bakheight) - interp->sectorplane.sector->ceilingheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); - } + interp->sectorplane.sector->ceilingheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); else - { - IFCHANGED(sectorplane.sector->floorheight, sectorplane.oldheight, sectorplane.bakheight) - interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); - } + interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); interp->sectorplane.sector->moved = true; break; case LVLINTERP_SectorScroll: if (interp->sectorscroll.ceiling) { - IFCHANGED(sectorscroll.sector->ceiling_xoffs, sectorscroll.oldxoffs, sectorscroll.bakxoffs) - interp->sectorscroll.sector->ceiling_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); - - IFCHANGED(sectorscroll.sector->ceiling_yoffs, sectorscroll.oldyoffs, sectorscroll.bakyoffs) - interp->sectorscroll.sector->ceiling_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); + interp->sectorscroll.sector->ceiling_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); + interp->sectorscroll.sector->ceiling_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } else { - IFCHANGED(sectorscroll.sector->floor_xoffs, sectorscroll.oldxoffs, sectorscroll.bakxoffs) - interp->sectorscroll.sector->floor_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); - - IFCHANGED(sectorscroll.sector->floor_yoffs, sectorscroll.oldyoffs, sectorscroll.bakyoffs) - interp->sectorscroll.sector->floor_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); + interp->sectorscroll.sector->floor_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); + interp->sectorscroll.sector->floor_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } break; case LVLINTERP_SideScroll: - IFCHANGED(sidescroll.side->textureoffset, sidescroll.oldtextureoffset, sidescroll.baktextureoffset) - interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac); - - IFCHANGED(sidescroll.side->rowoffset, sidescroll.oldrowoffset, sidescroll.bakrowoffset) - interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac); + interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac); + interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac); break; case LVLINTERP_Polyobj: for (ii = 0; ii < interp->polyobj.vertices_size; ii++) { - IFCHANGED(polyobj.polyobj->vertices[ii]->x, polyobj.oldvertices[ii * 2 ], polyobj.bakvertices[ii * 2 ]) - interp->polyobj.polyobj->vertices[ii]->x = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 ], interp->polyobj.bakvertices[ii * 2 ], frac); - - IFCHANGED(polyobj.polyobj->vertices[ii]->y, polyobj.oldvertices[ii * 2 + 1], polyobj.bakvertices[ii * 2 + 1]) - interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac); + interp->polyobj.polyobj->vertices[ii]->x = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 ], interp->polyobj.bakvertices[ii * 2 ], frac); + interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac); } - IFCHANGED(polyobj.polyobj->centerPt.x, polyobj.oldcx, polyobj.bakcx) - interp->polyobj.polyobj->centerPt.x = R_LerpFixed(interp->polyobj.oldcx, interp->polyobj.bakcx, frac); - - IFCHANGED(polyobj.polyobj->centerPt.y, polyobj.oldcy, polyobj.bakcy) - interp->polyobj.polyobj->centerPt.y = R_LerpFixed(interp->polyobj.oldcy, interp->polyobj.bakcy, frac); - + interp->polyobj.polyobj->centerPt.x = R_LerpFixed(interp->polyobj.oldcx, interp->polyobj.bakcx, frac); + interp->polyobj.polyobj->centerPt.y = R_LerpFixed(interp->polyobj.oldcy, interp->polyobj.bakcy, frac); break; /*case LVLINTERP_DynSlope: R_LerpVector3(&interp->dynslope.oldo, &interp->dynslope.bako, frac, &interp->dynslope.slope->o); @@ -680,8 +619,6 @@ void R_ApplyLevelInterpolators(fixed_t frac) } } -#undef IFCHANGED - void R_RestoreLevelInterpolators(void) { size_t i, ii; -- 2.54.0 From b7d887d61029b9918c48017fa680f46bef70e291 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 23:17:37 +0200 Subject: [PATCH 445/525] add a little bit of safety to R_SetupFrame --- src/hardware/hw_main.c | 15 +++++++-------- src/r_main.c | 10 +++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a547533fa..6906b049c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5685,17 +5685,16 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) { const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on + FRGBAFloat ClearColor; + + ClearColor.red = 0.0f; + ClearColor.green = 0.0f; + ClearColor.blue = 0.0f; + ClearColor.alpha = 1.0f; + // Clear the color buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. if (viewnumber == 0) // Only do it if it's the first screen being rendered - { - FRGBAFloat ClearColor; - - ClearColor.red = 0.0f; - ClearColor.green = 0.0f; - ClearColor.blue = 0.0f; - ClearColor.alpha = 1.0f; HWD.pfnClearBuffer(true, false, false, &ClearColor); - } if (cv_grshaders.value) HWD.pfnSetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime. diff --git a/src/r_main.c b/src/r_main.c index b9b30a095..629358d50 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1468,12 +1468,12 @@ void R_SetupFrame(player_t *player, boolean skybox) else if (player->playerstate == PST_DEAD || player->exiting) chasecam = true; // force chasecam on - if (chasecam && !thiscam->chase) + if (chasecam && (thiscam && !thiscam->chase)) { P_ResetCamera(player, thiscam); thiscam->chase = true; } - else if (!chasecam) + else if (thiscam && !chasecam) thiscam->chase = false; newview->sky = !skybox; @@ -1486,7 +1486,7 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->aim = player->awayviewaiming; newview->angle = viewmobj->angle; } - else if (!player->spectator && chasecam) + else if (!player->spectator && (thiscam && chasecam)) // use outside cam view { viewmobj = NULL; @@ -1532,7 +1532,7 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->player = player; - if (chasecam && !player->awayviewtics && !player->spectator) + if ((thiscam && chasecam) && !player->awayviewtics && !player->spectator) { newview->x = thiscam->x; newview->y = thiscam->y; @@ -1551,7 +1551,7 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->x += quake.x; newview->y += quake.y; - if (viewmobj->subsector && thiscam->subsector->sector) + if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && thiscam && thiscam->subsector->sector) newview->sector = viewmobj->subsector->sector; else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; -- 2.54.0 From 43b6597ec097bef508c02e123858797ae2af46a3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Sep 2024 23:45:00 +0200 Subject: [PATCH 446/525] this should also check for screentex cvar value 2 dont run certain postprocessor effects when you dont have screentextures enabled --- src/hardware/hw_main.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 6906b049c..ca20cc003 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5854,12 +5854,7 @@ void HWR_Startup(void) #endif if (msaa) - { - if (a2c) - HWD.pfnSetSpecialState(HWD_SET_MSAA, 2); - else - HWD.pfnSetSpecialState(HWD_SET_MSAA, 1); - } + HWD.pfnSetSpecialState(HWD_SET_MSAA, a2c ? 2 : 1); } startupdone = true; } @@ -5962,7 +5957,7 @@ void HWR_DoPostProcessor(player_t *player) HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Translucent|PF_NoTexture|PF_NoDepthTest); } - if (!cv_grscreentextures.value) // screen textures are needed for the rest of the effects + if (cv_grscreentextures.value != 2) // screen textures are needed for the rest of the effects return; // Capture the screen for intermission and screen waving @@ -6010,7 +6005,7 @@ void HWR_DoPostProcessor(player_t *player) HWD.pfnPostImgRedraw(v); // Capture the screen again for screen waving on the intermission - if(gamestate != GS_INTERMISSION) + if (gamestate != GS_INTERMISSION) HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); } // Flipping of the screen isn't done here anymore -- 2.54.0 From 54ebb9dfecba9333c1ebc7cf6ae79b21611116ed Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Sep 2024 00:11:30 +0200 Subject: [PATCH 447/525] test also save replay on mapchange command --- src/d_netcmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 62072d9ee..b83777509 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2965,6 +2965,9 @@ static void Command_Map_f(void) } } + if (demo.recording && (modeattacking || demo.savemode != DSM_NOTSAVING)) + G_SaveDemo(); + fromlevelselect = false; D_MapChange(newmapnum, newgametype, newencoremode, newresetplayers, 0, false, false); -- 2.54.0 From d56b70a8e7420afab3e74c5ab3d3be3201ecab7f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Sep 2024 10:52:15 +0200 Subject: [PATCH 448/525] toggle for saving replays on changing to same map --- src/d_netcmd.c | 4 +++- src/g_game.c | 2 ++ src/g_game.h | 2 +- src/m_menu.c | 9 +++++---- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b83777509..9b6b7b2f3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -830,6 +830,8 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_recordmultiplayerdemos); CV_RegisterVar(&cv_netdemosyncquality); CV_RegisterVar(&cv_maxdemosize); + CV_RegisterVar(&cv_demosamemap); + CV_RegisterVar(&cv_keyboardlayout); } @@ -2965,7 +2967,7 @@ static void Command_Map_f(void) } } - if (demo.recording && (modeattacking || demo.savemode != DSM_NOTSAVING)) + if (demo.recording && demo.savemode != DSM_NOTSAVING && ((cv_demosamemap.value && newmapnum == gamemap) || newmapnum != gamemap)) G_SaveDemo(); fromlevelselect = false; diff --git a/src/g_game.c b/src/g_game.c index 936c8d464..2e3ff64b7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -346,6 +346,8 @@ consvar_t cv_netdemosyncquality = {"netdemo_syncquality", "1", CV_SAVE, netdemos static CV_PossibleValue_t maxdemosize_cons_t[] = {{10, "MIN"}, {100, "MAX"}, {0, NULL}}; consvar_t cv_maxdemosize = {"maxdemosize", "10", CV_SAVE, maxdemosize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_demosamemap = {"netdemo_savesamemap", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static UINT8 *savebuffer; // Analog Control diff --git a/src/g_game.h b/src/g_game.h index 977cc4dc3..432a10039 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -39,7 +39,7 @@ extern UINT8 *demo_p; // ====================================== // demoplaying back and demo recording -extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize; +extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demosamemap; // Publicly-accessible demo vars struct demovars_s { diff --git a/src/m_menu.c b/src/m_menu.c index b76a2de61..053ebb5a6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -628,10 +628,11 @@ static menuitem_t MISC_ReplayStartMenu[] = static menuitem_t MISC_ReplayOptionsMenu[] = { - {IT_CVAR|IT_STRING, NULL, "Record Replays", &cv_recordmultiplayerdemos, 0}, - {IT_CVAR|IT_STRING, NULL, "Sync Check Interval", &cv_netdemosyncquality, 10}, - {IT_CVAR|IT_STRING, NULL, "Max demo size (MiB)", &cv_maxdemosize, 20}, - {IT_CVAR|IT_STRING, NULL, "Replay Search Rate", &cv_replaysearchrate, 30}, + {IT_CVAR|IT_STRING, NULL, "Record Replays", &cv_recordmultiplayerdemos, 0}, + {IT_CVAR|IT_STRING, NULL, "Save Replays on Map restart", &cv_demosamemap, 10}, + {IT_CVAR|IT_STRING, NULL, "Sync Check Interval", &cv_netdemosyncquality, 20}, + {IT_CVAR|IT_STRING, NULL, "Max demo size (MiB)", &cv_maxdemosize, 30}, + {IT_CVAR|IT_STRING, NULL, "Replay Search Rate", &cv_replaysearchrate, 40}, }; static tic_t playback_last_menu_interaction_leveltime = 0; -- 2.54.0 From 9eefbcea72830f11307be12cc246ae85c36e5399 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Sep 2024 17:36:53 +0200 Subject: [PATCH 449/525] only save demo in map command if you atleast spend 35 seconds in one map --- src/d_netcmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9b6b7b2f3..e01e0d1f6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2967,7 +2967,8 @@ static void Command_Map_f(void) } } - if (demo.recording && demo.savemode != DSM_NOTSAVING && ((cv_demosamemap.value && newmapnum == gamemap) || newmapnum != gamemap)) + // spend atleast 35 seconds in one map + if (demo.recording && demo.savemode != DSM_NOTSAVING && (timeinmap > 1463) && ((cv_demosamemap.value && newmapnum == gamemap) || newmapnum != gamemap)) G_SaveDemo(); fromlevelselect = false; -- 2.54.0 From d10db6d1d26b4fb91d23835c16fef90a032c6f2f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 18:50:57 +0200 Subject: [PATCH 450/525] make this completely toggable actually --- src/d_netcmd.c | 4 ++-- src/g_game.c | 3 ++- src/g_game.h | 2 +- src/m_menu.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e01e0d1f6..00df2bc6a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -830,7 +830,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_recordmultiplayerdemos); CV_RegisterVar(&cv_netdemosyncquality); CV_RegisterVar(&cv_maxdemosize); - CV_RegisterVar(&cv_demosamemap); + CV_RegisterVar(&cv_demochangemap); CV_RegisterVar(&cv_keyboardlayout); } @@ -2968,7 +2968,7 @@ static void Command_Map_f(void) } // spend atleast 35 seconds in one map - if (demo.recording && demo.savemode != DSM_NOTSAVING && (timeinmap > 1463) && ((cv_demosamemap.value && newmapnum == gamemap) || newmapnum != gamemap)) + if (cv_demochangemap.value && demo.recording && demo.savemode != DSM_NOTSAVING && (timeinmap > 1463) && ((cv_demochangemap.value == 2 && newmapnum == gamemap) || newmapnum != gamemap)) G_SaveDemo(); fromlevelselect = false; diff --git a/src/g_game.c b/src/g_game.c index 2e3ff64b7..b6487e7c5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -346,7 +346,8 @@ consvar_t cv_netdemosyncquality = {"netdemo_syncquality", "1", CV_SAVE, netdemos static CV_PossibleValue_t maxdemosize_cons_t[] = {{10, "MIN"}, {100, "MAX"}, {0, NULL}}; consvar_t cv_maxdemosize = {"maxdemosize", "10", CV_SAVE, maxdemosize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_demosamemap = {"netdemo_savesamemap", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t demochangemap_cons_t[] = {{0, "Disabled"}, {1, "Diff Map"}, {2, "Always"}, {0, NULL}}; +consvar_t cv_demochangemap = {"netdemo_savemapchange", "Disabled", CV_SAVE, demochangemap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static UINT8 *savebuffer; diff --git a/src/g_game.h b/src/g_game.h index 432a10039..83d85ed91 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -39,7 +39,7 @@ extern UINT8 *demo_p; // ====================================== // demoplaying back and demo recording -extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demosamemap; +extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demochangemap; // Publicly-accessible demo vars struct demovars_s { diff --git a/src/m_menu.c b/src/m_menu.c index 053ebb5a6..60671d826 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -629,7 +629,7 @@ static menuitem_t MISC_ReplayStartMenu[] = static menuitem_t MISC_ReplayOptionsMenu[] = { {IT_CVAR|IT_STRING, NULL, "Record Replays", &cv_recordmultiplayerdemos, 0}, - {IT_CVAR|IT_STRING, NULL, "Save Replays on Map restart", &cv_demosamemap, 10}, + {IT_CVAR|IT_STRING, NULL, "Save Replays on Map change", &cv_demochangemap, 10}, {IT_CVAR|IT_STRING, NULL, "Sync Check Interval", &cv_netdemosyncquality, 20}, {IT_CVAR|IT_STRING, NULL, "Max demo size (MiB)", &cv_maxdemosize, 30}, {IT_CVAR|IT_STRING, NULL, "Replay Search Rate", &cv_replaysearchrate, 40}, -- 2.54.0 From 5efb0c7136143cbfcc61b7c90b3aadc6de8cd838 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 19:23:35 +0200 Subject: [PATCH 451/525] put saturn specific join allow stuff behind SATURNJOIN define so it can be seperate from SATURNPAK --- src/d_clisrv.c | 17 +++++++++-------- src/d_clisrv.h | 4 ++-- src/d_netcmd.c | 2 +- src/doomdef.h | 8 +++++++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7ab921aaf..2534a51e5 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -147,6 +147,9 @@ static boolean cl_redownloadinggamestate = false; #ifdef SATURNPAK boolean is_client_saturn[MAXNETNODES]; +#endif + +#ifdef SATURNJOIN #define ISSATURN 69 #endif @@ -1444,7 +1447,7 @@ static boolean CL_SendJoin(void) netbuffer->u.clientcfg.subversion = SUBVERSION; strncpy(netbuffer->u.clientcfg.application, SRB2APPLICATION, sizeof netbuffer->u.clientcfg.application); -#ifdef SATURNPAK +#ifdef SATURNJOIN netbuffer->u.clientcfg.issaturn = ISSATURN; #endif @@ -4048,7 +4051,7 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; -#ifdef SATURNPAK +#ifdef SATURNJOIN consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE|CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif @@ -4097,7 +4100,7 @@ static void Joinable_OnChange(void) if (!server) return; -#ifdef SATURNPAK +#ifdef SATURNJOIN // disabling joins should also disable saturn joins unless its called with CV_StealthSet and vice versa to make life a bit easier if (!cv_allownewplayer.value) CV_Set(&cv_allownewsaturnplayer, "Off"); @@ -4716,7 +4719,7 @@ static void HandleConnect(SINT8 node) { SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION)); } -#ifdef SATURNPAK +#ifdef SATURNJOIN else if ((!cv_allownewplayer.value && node && netbuffer->u.clientcfg.issaturn != ISSATURN) || (!cv_allownewsaturnplayer.value && node && netbuffer->u.clientcfg.issaturn == ISSATURN)) #else else if (!cv_allownewplayer.value && node) @@ -5088,7 +5091,6 @@ static void HandlePacketFromAwayNode(SINT8 node) #ifdef SATURNPAK SendSaturnInfo(node); #endif - memset(playeringame, 0, sizeof(playeringame)); for (j = 0; j < MAXPLAYERS; j++) { @@ -6532,13 +6534,12 @@ void NetKeepAlive(void) MasterClient_Ticker(); #endif - #ifdef HOLEPUNCH +#ifdef HOLEPUNCH if (netgame && serverrunning) { RenewHolePunch(); } - #endif - +#endif if (client) { diff --git a/src/d_clisrv.h b/src/d_clisrv.h index b5ad26eea..ed657d75c 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -371,7 +371,7 @@ typedef struct UINT8 subversion; // Contains build version UINT8 localplayers; // number of splitscreen players UINT8 mode; -#ifdef SATURNPAK +#ifdef SATURNJOIN UINT8 issaturn; #endif } ATTRPACK clientconfig_pak; @@ -579,7 +579,7 @@ extern consvar_t cv_joinnextround, #endif cv_netticbuffer, cv_allownewplayer, -#ifdef SATURNPAK +#ifdef SATURNJOIN cv_allownewsaturnplayer, #endif cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4ca65e956..9852307c1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -795,7 +795,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); -#ifdef SATURNPAK +#ifdef SATURNJOIN CV_RegisterVar(&cv_allownewsaturnplayer); #endif CV_RegisterVar(&cv_joinrefusemessage); diff --git a/src/doomdef.h b/src/doomdef.h index 37e553816..d8092d83c 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -568,10 +568,16 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! +//-- SATURN __\\ /// Server detection for if a connecting client is on Saturn. -/// For stuff like extra synching, joinblock, etc. +/// For stuff like extra synching, etc. //#define SATURNPAK +/// Detect if a client is on Saturn in the clientconfig. +/// To seperately allow them to join or block joining from vanilla clients. +//#define SATURNJOIN +//-- <( ̄︶ ̄)> __\\ + /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -- 2.54.0 From 65e66e8ace90e590f4f455fe1d68a2be51501c27 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 19:52:04 +0200 Subject: [PATCH 452/525] oops --- src/doomdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index d8092d83c..98357cea6 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -568,7 +568,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! -//-- SATURN __\\ +//-- SATURN __ /// Server detection for if a connecting client is on Saturn. /// For stuff like extra synching, etc. //#define SATURNPAK @@ -576,7 +576,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. //#define SATURNJOIN -//-- <( ̄︶ ̄)> __\\ +//-- <( ̄︶ ̄)> __ /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -- 2.54.0 From 6df675523f189fa69107e7937f8d7f64394851b7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 19:55:22 +0200 Subject: [PATCH 453/525] hide gamestate resynch stuff behind SATURNSYNCH ifdef --- src/d_clisrv.c | 86 +++++++++++++++++++++++++++++++++++++++++++++----- src/d_clisrv.h | 10 +++++- src/d_net.c | 3 +- src/d_netcmd.c | 2 ++ src/doomdef.h | 5 +++ src/g_game.c | 6 +++- src/hu_stuff.c | 12 +++++-- src/m_menu.c | 6 ++-- 8 files changed, 115 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2534a51e5..03d3166ec 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -93,8 +93,10 @@ UINT8 playernode[MAXPLAYERS]; // The actual timeout will be longer depending on the savegame length tic_t jointimeout = (3*TICRATE); static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? +#ifdef SATURNSYNCH static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame? static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again? +#endif static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout? UINT16 pingmeasurecount = 1; @@ -126,11 +128,12 @@ static UINT8 resynch_inprogress[MAXNETNODES]; static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. static UINT8 player_joining = false; UINT8 hu_resynching = 0; + +#ifdef SATURNSYNCH UINT8 hu_redownloadinggamestate = 0; - static boolean can_receive_gamestate[MAXNETNODES]; - static UINT8 gamestate_resend_counter[MAXNETNODES]; +#endif // kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks UINT8 hu_stopped = 0; @@ -143,15 +146,20 @@ static ticcmd_t localcmds4; static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server + +#ifdef SATURNSYNCH static boolean cl_redownloadinggamestate = false; +#endif #ifdef SATURNPAK boolean is_client_saturn[MAXNETNODES]; #endif +#ifdef SATURNSYNCH #ifdef SATURNJOIN #define ISSATURN 69 #endif +#endif static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen @@ -189,7 +197,6 @@ typedef struct textcmdtic_s ticcmd_t netcmds[TICQUEUE][MAXPLAYERS]; static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; - consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shownodeip = {"showipinnodelist", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1898,7 +1905,6 @@ static void SV_SavedGame(void) #endif #define TMPSAVENAME "$$$.sav" - static void CL_LoadReceivedSavegame(boolean reloading) { UINT8 *savebuffer = NULL; @@ -1958,6 +1964,7 @@ static void CL_LoadReceivedSavegame(boolean reloading) consistancy[gametic%TICQUEUE] = Consistancy(); CON_ToggleOff(); +#ifdef SATURNSYNCH // Tell the server we have received and reloaded the gamestate // so they know they can resume the game if (reloading) @@ -1965,8 +1972,10 @@ static void CL_LoadReceivedSavegame(boolean reloading) netbuffer->packettype = PT_RECEIVEDGAMESTATE; HSendPacket(servernode, true, 0, 0); } +#endif } +#ifdef SATURNSYNCH static void CL_ReloadReceivedSavegame(void) { INT32 i; @@ -1990,6 +1999,7 @@ static void CL_ReloadReceivedSavegame(void) CONS_Printf(M_GetText("Game state reloaded\n")); } #endif +#endif #ifndef NONET static void SendAskInfo(INT32 node) @@ -3210,7 +3220,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) #ifdef SATURNPAK is_client_saturn[node] = false; #endif +#ifdef SATURNSYNCH can_receive_gamestate[node] = false; +#endif Net_CloseConnection(node); ResetNode(node); } @@ -4014,6 +4026,7 @@ static void Command_list_http_logins (void) } #endif/*HAVE_CURL*/ +#ifdef SATURNSYNCH static void Command_ResendGamestate(void) { SINT8 playernum; @@ -4041,6 +4054,7 @@ static void Command_ResendGamestate(void) return; } } +#endif static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}}; consvar_t cv_netticbuffer = {"netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -4069,11 +4083,14 @@ consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, di static CV_PossibleValue_t resynchattempts_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchattempts = {"resynchattempts", "2", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +#ifdef SATURNSYNCH static CV_PossibleValue_t gamestateattempts_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; consvar_t cv_gamestateattempts = {"gamestateresendattempts", "10", CV_SAVE, gamestateattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t resynchcooldown_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchcooldown = {"gamestatecooldown", "5", CV_SAVE, resynchcooldown_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; +#endif + consvar_t cv_blamecfail = {"blamecfail", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL }; // max file size to send to a player (in kilobytes) @@ -4133,7 +4150,9 @@ void D_ClientServerInit(void) COM_AddCommand("reloadbans", Command_ReloadBan); COM_AddCommand("connect", Command_connect); COM_AddCommand("nodes", Command_Nodes); +#ifdef SATURNSYNCH COM_AddCommand("resendgamestate", Command_ResendGamestate); +#endif COM_AddCommand("listplayers", Command_Listplayers); COM_AddCommand("packetstat", Command_Packetstat); #ifdef HAVE_CURL @@ -4193,9 +4212,11 @@ static void ResetNode(INT32 node) is_client_saturn[node] = false; #endif +#ifdef SATURNSYNCH resendingsavegame[node] = false; can_receive_gamestate[node] = false; savegameresendcooldown[node] = 0; +#endif // } @@ -4232,7 +4253,9 @@ void SV_ResetServer(void) mynode = 0; cl_packetmissed = false; +#ifdef SATURNSYNCH cl_redownloadinggamestate = false; +#endif if (dedicated) { @@ -4762,7 +4785,7 @@ static void HandleConnect(SINT8 node) /// \note Wait what??? /// What if the gamestate takes more than one second to get downloaded? - /// Or if a lagspike happdsfens? + /// Or if a lagspike happens? // you get a free second before desynch checks. use it wisely. SV_InitResynchVars(node); @@ -4862,7 +4885,7 @@ static void HandleServerInfo(SINT8 node) } #endif - +#ifdef SATURNSYNCH static void PT_WillResendGamestate(void) { char tmpsave[264]; @@ -4885,7 +4908,6 @@ static void PT_WillResendGamestate(void) I_Error("Can't delete %s\n", tmpsave); CL_PrepareDownloadSaveGame(tmpsave); - cl_redownloadinggamestate = true; } @@ -4899,6 +4921,7 @@ static void PT_CanReceiveGamestate(SINT8 node) SV_SendSaveGame(node, true); // Resend a complete game state resendingsavegame[node] = true; } +#endif /** Handles a packet received from a node that isn't in game * @@ -5328,6 +5351,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; } +#ifdef SATURNSYNCH if ((gamestate_resend_counter[node] != 0) && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0)) gamestate_resend_counter[node]--; @@ -5383,6 +5407,43 @@ static void HandlePacketFromPlayer(SINT8 node) else if (resynch_score[node]) --resynch_score[node]; break; +#else + // Check player consistancy during the level + if (realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL + && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) + { + SV_RequireResynch(node); + + if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) + { + if (cv_blamecfail.value) + CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"), + netconsole+1, player_names[netconsole], + consistancy[realstart%TICQUEUE], + SHORT(netbuffer->u.clientpak.consistancy)); + DEBFILE(va("Restoring player %d (synch failure) [%update] %d!=%d\n", + netconsole, realstart, consistancy[realstart%TICQUEUE], + SHORT(netbuffer->u.clientpak.consistancy))); + break; + } + else + { + UINT8 buf[3]; + + buf[0] = (UINT8)netconsole; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", + netconsole, realstart, consistancy[realstart%TICQUEUE], + SHORT(netbuffer->u.clientpak.consistancy))); + break; + } + } + else if (resynch_score[node]) + --resynch_score[node]; + break; +#endif + case PT_BASICKEEPALIVE: if (client) break; @@ -5520,7 +5581,9 @@ static void HandlePacketFromPlayer(SINT8 node) #ifdef SATURNPAK is_client_saturn[node] = false; #endif +#ifdef SATURNSYNCH can_receive_gamestate[node] = false; +#endif break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_RESYNCHEND: @@ -5690,6 +5753,7 @@ static void HandlePacketFromPlayer(SINT8 node) is_client_saturn[node] = true; break; #endif +#ifdef SATURNSYNCH case PT_CANRECEIVEGAMESTATE: can_receive_gamestate[node] = true; PT_CanReceiveGamestate(node); @@ -5702,6 +5766,7 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_WILLRESENDGAMESTATE: PT_WillResendGamestate(); break; +#endif default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", netbuffer->packettype, node)); @@ -6661,15 +6726,18 @@ void NetUpdate(void) if (client) { +#ifdef SATURNSYNCH // If the client just finished redownloading the game state, load it if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) CL_ReloadReceivedSavegame(); - +#endif if (!resynch_local_inprogress) CL_SendClientCmd(); // Send tic cmd hu_resynching = resynch_local_inprogress; +#ifdef SATURNSYNCH hu_redownloadinggamestate = cl_redownloadinggamestate; +#endif } else { @@ -6678,7 +6746,9 @@ void NetUpdate(void) INT32 counts; hu_resynching = false; +#ifdef SATURNSYNCH hu_redownloadinggamestate = false; +#endif firstticstosend = gametic; for (i = 0; i < MAXNETNODES; i++) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index ed657d75c..5376abc43 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -102,9 +102,11 @@ typedef enum #ifdef SATURNPAK PT_ISSATURN, #endif +#ifdef SATURNSYNCH PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again! +#endif NUMPACKETTYPE } packettype_t; @@ -582,7 +584,11 @@ extern consvar_t #ifdef SATURNJOIN cv_allownewsaturnplayer, #endif - cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, +#ifdef SATURNSYNCH + cv_resynchcooldown, cv_gamestateattempts, +#endif + cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; extern consvar_t cv_connectawaittime; @@ -647,7 +653,9 @@ tic_t GetLag(INT32 node); UINT8 GetFreeXCmdSize(void); extern UINT8 hu_resynching; +#ifdef SATURNSYNCH extern UINT8 hu_redownloadinggamestate; +#endif extern UINT8 hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player typedef struct rewind_s { diff --git a/src/d_net.c b/src/d_net.c index 2f60eb3d4..4731ffcc3 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -837,10 +837,11 @@ const char *packettypename[NUMPACKETTYPE] = #ifdef SATURNPAK "ISSATURN", #endif - +#ifdef SATURNSYNCH "WILLRESENDGAMESTATE", "CANRECEIVEGAMESTATE", "RECEIVEDGAMESTATE" +#endif }; const char *Net_GetPacketName(UINT8 packettype) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9852307c1..033c94199 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -786,8 +786,10 @@ void D_RegisterServerCommands(void) // d_clisrv CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); +#ifdef SATURNSYNCH CV_RegisterVar(&cv_gamestateattempts); CV_RegisterVar(&cv_resynchcooldown); +#endif CV_RegisterVar(&cv_maxsend); CV_RegisterVar(&cv_noticedownload); CV_RegisterVar(&cv_downloadspeed); diff --git a/src/doomdef.h b/src/doomdef.h index 98357cea6..54429b30d 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -569,6 +569,11 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // Compile them at your own risk! //-- SATURN __ +/// Enable gamestate resynching between Saturn servers and clients +/// Like SRB2 and RR does +/// Still highly experimental +//#define SATURNSYNCH + /// Server detection for if a connecting client is on Saturn. /// For stuff like extra synching, etc. //#define SATURNPAK diff --git a/src/g_game.c b/src/g_game.c index 060b2e9e3..8e047b78b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1192,7 +1192,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. // Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions - if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching || hu_redownloadinggamestate) + if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching +#ifdef SATURNSYNCH + || hu_redownloadinggamestate +#endif + ) { cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index d363ce73b..0594d28cd 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1256,7 +1256,11 @@ void HU_Ticker(void) if (cechotimer > 0) --cechotimer; // Animate the desynch dots - if (hu_resynching || hu_redownloadinggamestate) + if (hu_resynching +#ifdef SATURNSYNCH + || hu_redownloadinggamestate +#endif + ) resynch_ticker++; //tic tic tic tic tic HU_TickSongCredits(); @@ -2421,7 +2425,11 @@ void HU_Drawer(void) HU_DrawSongCredits(); // draw desynch text - if (hu_resynching || hu_redownloadinggamestate) + if (hu_resynching +#ifdef SATURNSYNCH + || hu_redownloadinggamestate +#endif + ) { char resynch_text[14]; UINT32 i; diff --git a/src/m_menu.c b/src/m_menu.c index 83ed04ea7..4c8718847 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2027,8 +2027,10 @@ static menuitem_t OP_AdvServerOptionsMenu[] = NULL, "Server Browser Address", &cv_masterserver, 10}, #endif {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, +#ifdef SATURNSYNCH {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 60}, +#endif {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 70}, {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 80}, {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 90}, @@ -2041,15 +2043,15 @@ static menuitem_t OP_AdvServerOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 160}, {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 170}, }; -#endif -#ifndef NONET static const char* OP_AdvServerOptionsTooltips[] = { "Server used for master server.", "Attempts to resynchronise player to server.", +#ifdef SATURNSYNCH "Cooldown in seconds before the Server attempts\nto resend the gamestate to a Saturn Client\nbetween resending attempts.", "Attempts to resend the Gamestate to player\nThis increments a Counter everytime a gamestate resend occurs\nThis Counter decrements at double the time of the Cooldown\nonce the Counter reaches the threshold, the client gets kicked.", +#endif "Maximum allowed delay.", "Delay timeout in seconds.", "Connection timeout in tics.", -- 2.54.0 From d9affe2331fe9f4813018399704aae362dd7a995 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 19:59:39 +0200 Subject: [PATCH 454/525] oops again --- src/d_clisrv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 03d3166ec..dc62f8520 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -155,11 +155,9 @@ static boolean cl_redownloadinggamestate = false; boolean is_client_saturn[MAXNETNODES]; #endif -#ifdef SATURNSYNCH #ifdef SATURNJOIN #define ISSATURN 69 #endif -#endif static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen -- 2.54.0 From 406037dabec1d9a9ae674ed6df61baace593735b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 20:06:49 +0200 Subject: [PATCH 455/525] menu offset stuff for if not using SATURNSYNCH --- src/m_menu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 4c8718847..df30c38f5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2030,7 +2030,7 @@ static menuitem_t OP_AdvServerOptionsMenu[] = #ifdef SATURNSYNCH {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 60}, -#endif + {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 70}, {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 80}, {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 90}, @@ -2042,6 +2042,19 @@ static menuitem_t OP_AdvServerOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 150}, {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 160}, {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 170}, +#else + {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 50}, + {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 60}, + {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 70}, + {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 80}, + + {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 100}, + {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 110}, + + {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 130}, + {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 140}, + {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 150}, +#endif }; static const char* OP_AdvServerOptionsTooltips[] = -- 2.54.0 From c9c0c06763701f25faeffa88c69f0f107b446cf6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 20:36:20 +0200 Subject: [PATCH 456/525] reserve saturn packet even if unused to not cause any weird isssues if either one is undefined and stuff like that --- src/d_clisrv.h | 5 ++--- src/d_net.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 5376abc43..bd4d25c8a 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -99,13 +99,12 @@ typedef enum PT_PING, // Packet sent to tell clients the other client's latency to server. -#ifdef SATURNPAK - PT_ISSATURN, -#endif #ifdef SATURNSYNCH PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again! + + PT_ISSATURN, #endif NUMPACKETTYPE diff --git a/src/d_net.c b/src/d_net.c index 4731ffcc3..e73a120ab 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -832,15 +832,15 @@ const char *packettypename[NUMPACKETTYPE] = "TELLFILESNEEDED", "MOREFILESNEEDED", - "PING", - -#ifdef SATURNPAK - "ISSATURN", -#endif + "PING" #ifdef SATURNSYNCH + , + "WILLRESENDGAMESTATE", "CANRECEIVEGAMESTATE", - "RECEIVEDGAMESTATE" + "RECEIVEDGAMESTATE", + + "ISSATURN" #endif }; -- 2.54.0 From 915b4e9d15609164f2b32c9a36c27cf21b69ed7e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 21:02:16 +0200 Subject: [PATCH 457/525] set netgame save stuff to false for replays to retain max vanilla compat for replays dont want those breaking between clients --- src/d_clisrv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index dc62f8520..4a016796f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1881,7 +1881,7 @@ static void SV_SavedGame(void) return; } - P_SaveNetGame(); + P_SaveNetGame(false); length = save_p - savebuffer; if (length > SAVEGAMESIZE) @@ -6848,7 +6848,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) return NULL; save_p = rewind->savebuffer; - P_SaveNetGame(true); + P_SaveNetGame(false); rewind->leveltime = leveltime; rewind->next = rewindhead; rewind->demopos = demopos; @@ -6872,7 +6872,7 @@ rewind_t *CL_RewindToTime(tic_t time) return NULL; save_p = rewindhead->savebuffer; - P_LoadNetGame(true); + P_LoadNetGame(false); wipegamestate = gamestate; // No fading back in! timeinmap = leveltime; -- 2.54.0 From 51b79e58d3450ab881a861fd4fe9cee62507f480 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 21:05:21 +0200 Subject: [PATCH 458/525] smol cleanup + add comments --- src/d_clisrv.c | 12 ++++++------ src/d_clisrv.h | 3 ++- src/d_net.c | 1 + src/doomdef.h | 8 ++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4a016796f..9140d49b6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5745,12 +5745,6 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) Got_Filetxpak(); break; -#ifdef SATURNPAK - case PT_ISSATURN: - //CONS_Printf("hi im on saturn\n"); - is_client_saturn[node] = true; - break; -#endif #ifdef SATURNSYNCH case PT_CANRECEIVEGAMESTATE: can_receive_gamestate[node] = true; @@ -5764,6 +5758,12 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_WILLRESENDGAMESTATE: PT_WillResendGamestate(); break; +#endif +#ifdef SATURNPAK + case PT_ISSATURN: + //CONS_Printf("hi im on saturn&d\n", node); + is_client_saturn[node] = true; + break; #endif default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", diff --git a/src/d_clisrv.h b/src/d_clisrv.h index bd4d25c8a..cc123b1d2 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -104,7 +104,8 @@ typedef enum PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again! - PT_ISSATURN, + // we will reserve this for now even if unused, so order wont get mangled + PT_ISSATURN, // Saturn specific identifier packet #endif NUMPACKETTYPE diff --git a/src/d_net.c b/src/d_net.c index e73a120ab..ad031a76b 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -840,6 +840,7 @@ const char *packettypename[NUMPACKETTYPE] = "CANRECEIVEGAMESTATE", "RECEIVEDGAMESTATE", + // we will reserve this for now even if unused, so order wont get mangled "ISSATURN" #endif }; diff --git a/src/doomdef.h b/src/doomdef.h index 54429b30d..719900ced 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -574,13 +574,13 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Still highly experimental //#define SATURNSYNCH -/// Server detection for if a connecting client is on Saturn. -/// For stuff like extra synching, etc. -//#define SATURNPAK - /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. //#define SATURNJOIN + +/// Server detection for if a connecting client is on Saturn. +/// For stuff like extra synching, etc. +//#define SATURNPAK //-- <( ̄︶ ̄)> __ /// Undefine to use the new method of Gamma correction see colour cube in v_video.c -- 2.54.0 From 750f305c46c80e05771b6d294f0b1aca3851198c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 21:06:00 +0200 Subject: [PATCH 459/525] % --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 9140d49b6..369b42f5c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5761,7 +5761,7 @@ static void HandlePacketFromPlayer(SINT8 node) #endif #ifdef SATURNPAK case PT_ISSATURN: - //CONS_Printf("hi im on saturn&d\n", node); + //CONS_Printf("hi im on saturn%d\n", node); is_client_saturn[node] = true; break; #endif -- 2.54.0 From 2d61f5c861cd2311063f78d91d2ff49be85cccc7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 21:41:46 +0200 Subject: [PATCH 460/525] add compiler flags NOSATURNSYNCH, NOSATURNJOIN and NOSATURNPAK not building with SATURNSYNCH also will disable SATURNJOIN since it makes not much sense to have that when synch stuff is unused --- src/Makefile | 24 ++++++++++++++++++++++++ src/doomdef.h | 12 ++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 72f82265b..4668518b9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -207,6 +207,18 @@ USE_FBO_OGL=1 endif endif +ifndef NONET +ifndef NOSATURNSYNCH +DOSATURNSYNCH=1 +ifndef NOSATURNJOIN +DOSATURNJOIN=1 +endif +#ifndef NOSATURNPAK +#DOSATURNPAK=1 +#endif +endif +endif + ifdef MINGW include win32/Makefile.cfg endif #ifdef MINGW @@ -386,6 +398,18 @@ OPTS+=-DUSE_FBO_OGL endif endif +ifndef NONET +ifndef NOSATURNSYNCH +OPTS+=-DDOSATURNSYNCH +ifndef NOSATURNJOIN +OPTS+=-DDOSATURNJOIN +endif +#ifndef NOSATURNPAK +#OPTS+=-DDOSATURNPAK +#endif +endif +endif + ifdef HAVE_MINIUPNPC ifdef NONET HAVE_MINIUPNPC='' diff --git a/src/doomdef.h b/src/doomdef.h index 719900ced..9aba9b5c5 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -568,20 +568,28 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! +#ifndef NONET //-- SATURN __ /// Enable gamestate resynching between Saturn servers and clients /// Like SRB2 and RR does /// Still highly experimental -//#define SATURNSYNCH +#ifdef DOSATURNSYNCH +#define SATURNSYNCH /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. -//#define SATURNJOIN +#ifdef DOSATURNJOIN +#define SATURNJOIN +#endif +#endif /// Server detection for if a connecting client is on Saturn. /// For stuff like extra synching, etc. +//#ifdef DOSATURNPAK //#define SATURNPAK +//#endif //-- <( ̄︶ ̄)> __ +#endif /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -- 2.54.0 From d5101dd0b25327d799f3a2426fa2d84f513655af Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 7 Sep 2024 11:46:59 +0300 Subject: [PATCH 461/525] Document changes to lua P_PlayRinglossSound and K_PlayHitEmSound functions --- LUASTUFF.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/LUASTUFF.md b/LUASTUFF.md index a8f285692..d753723f1 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -151,3 +151,15 @@ Best to be used in a Loop to ensure the color wont get overwritten by the game. Add Gamepad Rumble support for things. To be used with Displayplayers. Duration is in milliseconds and is optional to set, default value is 84ms. + +# Other changes + +## P_PlayRinglossSound(source, damager) + +Add optional `damager` argument (should be `mobj_t`), which causes hurt sound also play for damager +if `karthitemdialog` option is enabled + +## K_PlayHitEmSound(mobj, victim) + +Add optional `victim` argument (should be a player's `mobj_t`), which causes "hit em" sound to be +delayed and played for victim too if `karthitemdialog` option is enabled -- 2.54.0 From f9210ee3bc9a634ae3a39cd9216d58ba399eca0c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 15:35:17 +0200 Subject: [PATCH 462/525] smol fixes for gamestate resend in P_SetupLevel - dont reset cameras during gamestate resynch - dont reinit director during gamesate resynch - dont reset view interpolators aswell - dont reset localaiming aswell should make resynching less jarring visually hopefully --- src/p_setup.c | 83 ++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index a21fd5f12..b3ba07e4d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2196,8 +2196,6 @@ static void P_LevelInitStuff(boolean reloadinggamestate) leveltime = 0; - memset(localaiming, 0, sizeof(localaiming)); - // map object scale mapobjectscale = mapheaderinfo[gamemap-1]->mobj_scale; @@ -2334,6 +2332,8 @@ void P_LoadThingsOnly(void) P_LevelInitStuff(false); + memset(localaiming, 0, sizeof(localaiming)); + P_PrepareRawThings(vth->data); P_LoadThings(); @@ -2620,30 +2620,36 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) } } +static void P_InitCamera(void) +{ + INT32 i; + + if (!dedicated) + { + if (!demo.freecam) + for (i = 0; i <= splitscreen; i++) + P_SetupCamera(displayplayers[i], &camera[i]); + + // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P + if (!cv_cam_rotate.changed) + CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue); + + if (!cv_cam2_rotate.changed) + CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue); + + if (!cv_cam3_rotate.changed) + CV_Set(&cv_cam3_rotate, cv_cam3_rotate.defaultvalue); + + if (!cv_cam4_rotate.changed) + CV_Set(&cv_cam4_rotate, cv_cam4_rotate.defaultvalue); + + displayplayers[0] = consoleplayer; // Start with your OWN view, please! + } +} + static boolean P_CanSave(void) { -#if 0 - // Saving is completely ignored under these conditions: - if ((cursaveslot < 0) // Playing without saving - || (modifiedgame && !savemoddata) // Game is modified - || (netgame || multiplayer) // Not in single-player - || (demo.playback || demo.recording || metalrecording) // Currently in demo - || (players[consoleplayer].lives <= 0) // Completely dead - || (modeattacking || ultimatemode || G_IsSpecialStage(gamemap))) // Specialized instances - return false; - - if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_ALWAYS) - return true; // Saving should ALWAYS happen! - else if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_NEVER) - return false; // Saving should NEVER happen! - - // Default condition: In a non-hidden map, at the beginning of a zone or on a completed save-file, and not on save reload. - return (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) - && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete) - && (gamemap != lastmapsaved)); -#else return false; // SRB2Kart: no SP, no saving. -#endif } /** Loads a level from a lump or external wad. @@ -2795,7 +2801,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) // But only if we didn't do the encore startup wipe if (!ranspecialwipe && !demo.rewinding && !reloadinggamestate) { - if(rendermode != render_none) + if (rendermode != render_none) { F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); @@ -3015,8 +3021,6 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) G_BeginRecording(); //this has to move here, since dedicated servers dont run got_mapcmd } - K_InitDirector(); - wantedcalcdelay = wantedfrequency*2; indirectitemcooldown = 0; hyubgone = 0; @@ -3052,26 +3056,11 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) // landing point for netgames. netgameskip: - if (!dedicated) + if (!reloadinggamestate) { - if (!demo.freecam) - for (i = 0; i <= splitscreen; i++) - P_SetupCamera(displayplayers[i], &camera[i]); - - // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P - if (!cv_cam_rotate.changed) - CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue); - - if (!cv_cam2_rotate.changed) - CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue); - - if (!cv_cam3_rotate.changed) - CV_Set(&cv_cam3_rotate, cv_cam3_rotate.defaultvalue); - - if (!cv_cam4_rotate.changed) - CV_Set(&cv_cam4_rotate, cv_cam4_rotate.defaultvalue); - - displayplayers[0] = consoleplayer; // Start with your OWN view, please! + P_InitCamera(); + memset(localaiming, 0, sizeof(localaiming)); + K_InitDirector(); } // clear special respawning que @@ -3080,7 +3069,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) P_MapEnd(); // Remove the loading shit from the screen - if (rendermode != render_none && (!reloadinggamestate)) + if (rendermode != render_none && !reloadinggamestate) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); if (precache || dedicated) @@ -3127,7 +3116,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) LUAh_MapLoad(); } - if (rendermode != render_none) + if (rendermode != render_none && !reloadinggamestate) { R_ResetViewInterpolation(0); R_ResetViewInterpolation(0); -- 2.54.0 From 62fae0ad8bb4877fdc42581482f2417cb53838f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 15:55:44 +0200 Subject: [PATCH 463/525] dont print "Map is now" everytime you resynch from gamestate resend --- src/d_clisrv.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 369b42f5c..8a6b502d1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1940,18 +1940,21 @@ static void CL_LoadReceivedSavegame(boolean reloading) // load a base level if (P_LoadNetGame(reloading)) { - CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap))); - if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0) + if (!reloading) { - CON_LogMessage(va(": %s", mapheaderinfo[gamemap-1]->lvlttl)); - if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) - CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->zonttl)); - else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) - CON_LogMessage(M_GetText(" Zone")); - if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) - CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->actnum)); + CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap))); + if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0) + { + CON_LogMessage(va(": %s", mapheaderinfo[gamemap-1]->lvlttl)); + if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) + CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->zonttl)); + else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) + CON_LogMessage(M_GetText(" Zone")); + if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) + CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->actnum)); + } + CON_LogMessage("\"\n"); } - CON_LogMessage("\"\n"); } // done @@ -4468,7 +4471,6 @@ static void Got_RemovePlayer(UINT8 **p, INT32 playernum) if (pnum == serverplayer) { CONS_Alert(CONS_WARNING, "Attempt to remove server player\n"); - return; } -- 2.54.0 From ea985151ddf0b851b7c9e47286392635fe82375d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 15:59:10 +0200 Subject: [PATCH 464/525] dont rerun levelload executors when gamestate resent --- src/p_setup.c | 2 +- src/p_spec.c | 5 +++-- src/p_spec.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index b3ba07e4d..3b2eb1281 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2910,7 +2910,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) globalweather = mapheaderinfo[gamemap-1]->weather; // set up world state - P_SpawnSpecials(fromnetsave); + P_SpawnSpecials(fromnetsave, reloadinggamestate); if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) P_SpawnPrecipitation(); diff --git a/src/p_spec.c b/src/p_spec.c index c022ef384..0fbddd085 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5236,7 +5236,7 @@ static void P_RunLevelLoadExecutors(void) * as they'll just be erased by UnArchiveThinkers. * \sa P_SpawnPrecipitation, P_SpawnFriction, P_SpawnPushers, P_SpawnScrollers */ -void P_SpawnSpecials(INT32 fromnetsave) +void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) { sector_t *sector; size_t i; @@ -6263,7 +6263,8 @@ void P_SpawnSpecials(INT32 fromnetsave) } } - P_RunLevelLoadExecutors(); + if (!reloadinggamestate) + P_RunLevelLoadExecutors(); } /** Adds 3Dfloors as appropriate based on a common control linedef. diff --git a/src/p_spec.h b/src/p_spec.h index 1231aeda8..477dd4950 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -32,7 +32,7 @@ void P_InitPicAnims(void); void P_SetupLevelFlatAnims(void); // at map load -void P_SpawnSpecials(INT32 fromnetsave); +void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate); // every tic void P_UpdateSpecials(void); -- 2.54.0 From ef8e71cb11733fd3f55ea73de28354ab0324f507 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 16:27:22 +0200 Subject: [PATCH 465/525] set camera angle to player angle in CL_ReloadReceivedSavegame hope i did this right lol should hopefully fix more jarring visual stuffs --- src/d_clisrv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8a6b502d1..41b88714d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1993,6 +1993,11 @@ static void CL_ReloadReceivedSavegame(void) neededtic = gametic; maketic = neededtic; + for (i = 0; i <= splitscreen; i++) + { + localangle[i] = players[displayplayers[i]].mo->angle; + } + camera->subsector = R_PointInSubsector(camera->x, camera->y); cl_redownloadinggamestate = false; -- 2.54.0 From 473e8431422f5fa36059f91a181fdd1ee074c57d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 16:46:23 +0200 Subject: [PATCH 466/525] this should use angleturn uhhh --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 41b88714d..97aecdf8f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1995,7 +1995,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i <= splitscreen; i++) { - localangle[i] = players[displayplayers[i]].mo->angle; + localangle[i] = players[displayplayers[i]].cmd.angleturn; } camera->subsector = R_PointInSubsector(camera->x, camera->y); -- 2.54.0 From e175a4e00b226851fc30d531182c8a09e8cdaa66 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 16:57:33 +0200 Subject: [PATCH 467/525] guh --- src/d_clisrv.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 97aecdf8f..03b7fa1f1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2011,13 +2011,13 @@ static void CL_ReloadReceivedSavegame(void) static void SendAskInfo(INT32 node) { tic_t asktime; - #ifdef HOLEPUNCH +#ifdef HOLEPUNCH if (node != 0 && node != BROADCASTADDR && cv_rendezvousserver.string[0]) { I_NetRequestHolePunch(node); } - #endif +#endif asktime = I_GetTime(); @@ -5787,7 +5787,6 @@ static void GetPackets(void) { SINT8 node; // The packet sender - player_joining = false; while (HGetPacket()) @@ -6722,12 +6721,12 @@ void NetUpdate(void) MasterClient_Ticker(); // Acking the Master Server #endif - #ifdef HOLEPUNCH +#ifdef HOLEPUNCH if (netgame && serverrunning) { RenewHolePunch(); } - #endif +#endif if (client) { -- 2.54.0 From 4f532b766f405276af14f33c80286b25c3c975fc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 17:04:00 +0200 Subject: [PATCH 468/525] this needs to be shifted --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 03b7fa1f1..3b7c08a0a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1995,7 +1995,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i <= splitscreen; i++) { - localangle[i] = players[displayplayers[i]].cmd.angleturn; + localangle[i] = players[displayplayers[i]].cmd.angleturn<<16; } camera->subsector = R_PointInSubsector(camera->x, camera->y); -- 2.54.0 From 8a8db796beeaafe1bc1a532c73bf841170d5c005 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 17:30:00 +0200 Subject: [PATCH 469/525] Show a console error if the gamestate contains too many tables --- src/d_clisrv.c | 1 - src/lua_script.c | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3b7c08a0a..8c10bcf55 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2642,7 +2642,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic // Call it only once by tic if (*oldtic != I_GetTime()) { - INT32 key; I_OsPolling(); diff --git a/src/lua_script.c b/src/lua_script.c index c4a0df135..9d5bef4a7 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -670,8 +670,17 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) lua_pop(gL, 1); } if (!found) + { t++; + if (t == 0) + { + CONS_Alert(CONS_ERROR, "Too many tables to archive!\n"); + WRITEUINT8(save_p, ARCH_NULL); + return 0; + } + } + WRITEUINT8(save_p, ARCH_TABLE); WRITEUINT16(save_p, t); -- 2.54.0 From 8824ba382469537181911ee8002927bc445621ec Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 17:52:13 +0200 Subject: [PATCH 470/525] this is literally broken and noone knows about it anyways lol --- src/p_setup.c | 61 --------------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 691ec0965..5ade38713 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1283,67 +1283,6 @@ static void P_LoadLineDefs2(void) break; } } - - // Optimize sidedefs - if (M_CheckParm("-compress")) - { - side_t *newsides; - size_t numnewsides = 0; - size_t z; - - for (i = 0; i < numsides; i++) - { - size_t j, k; - if (sides[i].sector == NULL) - continue; - - for (k = numlines, ld = lines; k--; ld++) - { - if (ld->sidenum[0] == i) - ld->sidenum[0] = (UINT16)numnewsides; - - if (ld->sidenum[1] == i) - ld->sidenum[1] = (UINT16)numnewsides; - } - - for (j = i+1; j < numsides; j++) - { - if (sides[j].sector == NULL) - continue; - - if (!memcmp(&sides[i], &sides[j], sizeof(side_t))) - { - // Find the linedefs that belong to this one - for (k = numlines, ld = lines; k--; ld++) - { - if (ld->sidenum[0] == j) - ld->sidenum[0] = (UINT16)numnewsides; - - if (ld->sidenum[1] == j) - ld->sidenum[1] = (UINT16)numnewsides; - } - sides[j].sector = NULL; // Flag for deletion - } - } - numnewsides++; - } - - // We're loading crap into this block anyhow, so no point in zeroing it out. - newsides = Z_Malloc(numnewsides * sizeof(*newsides), PU_LEVEL, NULL); - - // Copy the sides to their new block of memory. - for (i = 0, z = 0; i < numsides; i++) - { - if (sides[i].sector != NULL) - M_Memcpy(&newsides[z++], &sides[i], sizeof(side_t)); - } - - CONS_Debug(DBG_SETUP, "Old sides is %s, new sides is %s\n", sizeu1(numsides), sizeu1(numnewsides)); - - Z_Free(sides); - sides = newsides; - numsides = numnewsides; - } } static void P_LoadRawSideDefs2(void *data) -- 2.54.0 From f54d2fb0fe2f3d525eb8e7050600ee750f0510ff Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 20:06:11 +0200 Subject: [PATCH 471/525] clean up and improve ogl portals --- src/hardware/hw_main.c | 167 +++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 82 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ca20cc003..87e18d815 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -326,6 +326,9 @@ static float gr_viewludsin, gr_viewludcos; // Visual portals (attr. Hannu Hanhi) // ========================================================================== +static boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y); +static boolean HWR_PortalCheckBBox(const fixed_t *bspcoord); + enum { GRPORTAL_OFF, @@ -364,25 +367,35 @@ typedef struct gl_portallist_s // new thing gl_portallist_t *currentportallist; -INT32 portalviewside; - -// Linked list for portals. -/*gl_portal_t *portal_base_gl, *portal_cap_gl; - -//For now, these aren't used. -// maybe at some point these could be organized better -static void HWR_Portal_InitList (void) +// More precise version of R_PointToAngle2 using floats and atan2. +static angle_t R_PointToAngle2Precise(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) { - portalrender = 0; - portal_base_gl = portal_cap_gl = NULL; + fixed_t dx = x - pviewx; + fixed_t dy = y - pviewy; + float radians; + + if (!dx && !dy) + return 0; + + // no need for correct scale with FIXED_TO_FLOAT here + // since we're just calculating the angle + radians = atan2(dy, dx); + + return (angle_t)(radians / M_PI * ANGLE_180); } -static void HWR_Portal_Remove(gl_portal_t* portal) +// More precise version of R_PointToDist2 using floats and sqrt. +static fixed_t R_PointToDist2Precise(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1) { - portal_base_gl = portal->next; - Z_Free(portal); + // float-fixed conversions can be omitted here + // because they cancel each other out in this case + + float dx = px1 - px2; + float dy = py1 - py2; + double result = sqrt(dx*dx + dy*dy); + + return (fixed_t)result; } -*/ static void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *seg) { @@ -420,20 +433,33 @@ static void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *se // Offset the portal view by the linedef centers start = &lines[line1]; dest = &lines[line2]; - dangle = R_PointToAngle2(0,0,dest->dx,dest->dy) - R_PointToAngle2(start->dx,start->dy,0,0); + + // Most fixed-point calculations and trigonometric function tables are replaced by + // floats and cmath library calls in this part to improve the precision of the + // location and angle of the new viewpoint. + // + // This reduces artefacts on the edges of portals, showing thin lines/pixels + // of the underlying graphics. (for example the sky texture) It's not 100% + // perfectly aligned and artefact-free, but looks noticeably + // better than the original code. I'm not even sure if it's this + // code or the nodebuilder or hw_map or something else causing the remaining issues.. + + dangle = R_PointToAngle2Precise(0,0,dest->dx,dest->dy) - R_PointToAngle2Precise(start->dx,start->dy,0,0); // looking glass center - start_c.x = (start->v1->x + start->v2->x) / 2; - start_c.y = (start->v1->y + start->v2->y) / 2; + start_c.x = start->v1->x/2 + start->v2->x/2; + start_c.y = start->v1->y/2 + start->v2->y/2; // other side center - dest_c.x = (dest->v1->x + dest->v2->x) / 2; - dest_c.y = (dest->v1->y + dest->v2->y) / 2; + dest_c.x = dest->v1->x/2 + dest->v2->x/2; + dest_c.y = dest->v1->y/2 + dest->v2->y/2; - disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy); - angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); + disttopoint = R_PointToDist2Precise(start_c.x, start_c.y, viewx, viewy); + angtopoint = R_PointToAngle2Precise(start_c.x, start_c.y, viewx, viewy); angtopoint += dangle; + float fang = ((float)angtopoint / 4294967296.0f) * 2.0f * M_PI; + if (dangle == 0) { portal->viewx = viewx + dest_c.x - start_c.x; @@ -441,8 +467,8 @@ static void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *se } else { - portal->viewx = dest_c.x + FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); - portal->viewy = dest_c.y + FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); + portal->viewx = dest_c.x + (fixed_t)(cos(fang) * disttopoint); + portal->viewy = dest_c.y + (fixed_t)(sin(fang) * disttopoint); } portal->viewz = viewz + dest->frontsector->floorheight - start->frontsector->floorheight; portal->viewangle = viewangle + dangle; @@ -466,7 +492,6 @@ static void HWR_PortalFrame(gl_portal_t* portal) portalclipline = &lines[portal->clipline]; portalcullsector = portalclipline->frontsector; viewsector = portalclipline->frontsector; - portalviewside = P_PointOnLineSide(viewx, viewy, portalclipline); } else { @@ -2458,30 +2483,13 @@ static void HWR_AddLine(seg_t *line) gr_backsector = line->backsector; - // do an extra culling check when rendering portals - // check if any line vertex is on the viewable side of the portal target line - // if not, the line can be culled. - if (portalclipline)// portalclipline should be NULL when we are not rendering portal contents + // do extra checks on the seg when rendering portals: + // don't render segs that are behind the portal destination line + if (portalclipline && + !HWR_PortalCheckPointSide(line->v1->x, line->v1->y) && + !HWR_PortalCheckPointSide(line->v2->x, line->v2->y)) { - vertex_t closest_point; - boolean pass = false; - - // similar idea than in PortalCheckBBox, but checking the line vertices instead - // TODO could make the check more efficient and not check anything if pass==true from earlier or something - P_ClosestPointOnLine(line->v1->x, line->v1->y, portalclipline, &closest_point); - if (closest_point.x != line->v1->x || closest_point.y != line->v1->y) - { - if (P_PointOnLineSide(line->v1->x, line->v1->y, portalclipline) != portalviewside) - pass = true; - } - P_ClosestPointOnLine(line->v2->x, line->v2->y, portalclipline, &closest_point); - if (closest_point.x != line->v2->x || closest_point.y != line->v2->y) - { - if (P_PointOnLineSide(line->v2->x, line->v2->y, portalclipline) != portalviewside) - pass = true; - } - if (!pass) - return; + return; } if (gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH) @@ -3268,7 +3276,6 @@ skip_stuff_for_portals: // if its zero (or very close?) then dont return true, instead continue to next side check // it helped with center pillars! but other parts still have issues, probably because some of bounding box is on correct side. - // idea for further clipping improvement: // have a separate xyz coordinate for portal view side checking: one that is derived by moving the viewxyz forward // the new coords would be at the intersection of line_a and line_b, where @@ -3281,40 +3288,36 @@ skip_stuff_for_portals: // use returned value as multiplier for the added values from p_thrust thing // P_InterceptVector needs divlines which need dx and dy, dx=x2-x1 dy=y2-y1 -static boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) +// returns true if the point is on the correct (viewable) side of the +// portal destination line +static boolean HWR_PortalCheckPointSide(fixed_t x, fixed_t y) { - vertex_t closest_point; - if (!portalclipline) - return true; - - // we are looking for a bounding box corner that is on the viewable side of the portal exit. + // we are checking if the point is on the viewable side of the portal exit. // being exactly on the portal exit line is not enough to pass the test. // P_PointOnLineSide could behave differently from this expectation on this case, // so first check if the point is precisely on the line, and then if not, check the side. - P_ClosestPointOnLine(bspcoord[BOXLEFT], bspcoord[BOXTOP], portalclipline, &closest_point); - if (closest_point.x != bspcoord[BOXLEFT] || closest_point.y != bspcoord[BOXTOP]) + vertex_t closest_point; + P_ClosestPointOnLine(x, y, portalclipline, &closest_point); + if (closest_point.x != x || closest_point.y != y) { - if (P_PointOnLineSide(bspcoord[BOXLEFT], bspcoord[BOXTOP], portalclipline) != portalviewside) + if (P_PointOnLineSide(x, y, portalclipline) != 1) return true; } - P_ClosestPointOnLine(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], portalclipline, &closest_point); - if (closest_point.x != bspcoord[BOXLEFT] || closest_point.y != bspcoord[BOXBOTTOM]) + return false; +} + +static boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) +{ + if (!portalclipline) + return true; + + if (HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXTOP]) || + HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) || + HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) || + HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM])) { - if (P_PointOnLineSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], portalclipline) != portalviewside) - return true; - } - P_ClosestPointOnLine(bspcoord[BOXRIGHT], bspcoord[BOXTOP], portalclipline, &closest_point); - if (closest_point.x != bspcoord[BOXRIGHT] || closest_point.y != bspcoord[BOXTOP]) - { - if (P_PointOnLineSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP], portalclipline) != portalviewside) - return true; - } - P_ClosestPointOnLine(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM], portalclipline, &closest_point); - if (closest_point.x != bspcoord[BOXRIGHT] || closest_point.y != bspcoord[BOXBOTTOM]) - { - if (P_PointOnLineSide(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM], portalclipline) != portalviewside) - return true; + return true; } // we did not find any reason to pass the check, so return failure @@ -3353,11 +3356,12 @@ static void HWR_RenderBSPNode(INT32 bspnum) // PORTAL CULLING if (portalclipline && portalcullsector) { - sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector; - if (sect != portalcullsector) + if (portalcullsector != subsectors[bspnum & ~NF_SUBSECTOR].sector) return; - portalcullsector = NULL; + else + portalcullsector = NULL; } + // e6y: support for extended nodes HWR_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR); } @@ -5466,7 +5470,9 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe portallist.base = portallist.cap = NULL; const boolean skybox = (skyboxmo[0] && cv_skybox.value); - if (gr_maphasportals && allow_portals && cv_grportals.value && stencil_level < cv_maxportals.value)// if recursion limit is not reached + validcount++; + + if (cv_grportals.value && gr_maphasportals && allow_portals && stencil_level < cv_maxportals.value) // if recursion limit is not reached { // search for portals in current frame currentportallist = &portallist; @@ -5478,8 +5484,6 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe else HWR_PortalClipping(rootportal); - validcount++; - HWR_RenderBSPNode((INT32)numnodes-1);// no actual rendering happens // for each found portal: @@ -5515,8 +5519,6 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe // Set transform. HWD.pfnSetTransform(&atransform); - validcount++; - ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; PS_START_TIMING(ps_bsptime); @@ -5524,7 +5526,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe if (cv_grbatching.value) HWR_StartBatching(); - if (!rootportal && portallist.base && !skybox)// if portals have been drawn in the main view, then render skywalls differently + if (!rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently gr_collect_skywalls = true; // HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree. @@ -5575,6 +5577,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe ps_hw_nodedrawtime.value.p = 0; HWR_RenderDrawNodes(); } + // free memory from portal list allocated by calls to Add2Lines gl_portal_temp = portallist.base; while (gl_portal_temp) -- 2.54.0 From 863abe86caa5c190a9872a5662f3bd16206e3956 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 20:09:36 +0200 Subject: [PATCH 472/525] oops --- src/hardware/hw_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 87e18d815..49239ce51 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5470,8 +5470,6 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe portallist.base = portallist.cap = NULL; const boolean skybox = (skyboxmo[0] && cv_skybox.value); - validcount++; - if (cv_grportals.value && gr_maphasportals && allow_portals && stencil_level < cv_maxportals.value) // if recursion limit is not reached { // search for portals in current frame @@ -5484,6 +5482,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe else HWR_PortalClipping(rootportal); + validcount++; + HWR_RenderBSPNode((INT32)numnodes-1);// no actual rendering happens // for each found portal: @@ -5519,6 +5519,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe // Set transform. HWD.pfnSetTransform(&atransform); + validcount++; + ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; PS_START_TIMING(ps_bsptime); -- 2.54.0 From 0b12c9b5a89a58f4ce94381ed172b92e3332ff9e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Sep 2024 14:51:01 +0200 Subject: [PATCH 473/525] smol cleanup --- src/p_setup.c | 70 +------------------------------------------------- src/p_setup.h | 1 - src/p_slopes.c | 20 ++++++++------- 3 files changed, 12 insertions(+), 79 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 5ade38713..a0d746bb4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -584,7 +584,6 @@ static void P_LoadRawSegs(UINT8 *data) } } - // Loads the SSECTORS resource from a level. FUNCINLINE static ATTRINLINE void P_LoadRawSubsectors(void *data) { @@ -849,73 +848,6 @@ static void P_LoadRawNodes(UINT8 *data) } } - -// -// P_ReloadRings -// Used by NiGHTS, clears all ring/wing/etc items and respawns them -// -void P_ReloadRings(void) -{ - mobj_t *mo; - thinker_t *th; - size_t i, numHoops = 0; - // Okay, if you have more than 4000 hoops in your map, - // you're insane. - mapthing_t *hoopsToRespawn[4096]; - mapthing_t *mt = mapthings; - - // scan the thinkers to find rings/wings/hoops to unset - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - - if (mo->type == MT_HOOPCENTER) - { - // Hoops give me a headache - if (mo->threshold == 4242) // Dead hoop - { - hoopsToRespawn[numHoops++] = mo->spawnpoint; - P_RemoveMobj(mo); - } - continue; - } - if (!(mo->type == MT_RING || mo->type == MT_NIGHTSWING || mo->type == MT_COIN - || mo->type == MT_BLUEBALL)) - continue; - - // Don't auto-disintegrate things being pulled to us - if (mo->flags2 & MF2_NIGHTSPULL) - continue; - - P_RemoveMobj(mo); - } - - // Reiterate through mapthings - for (i = 0; i < nummapthings; i++, mt++) - { - // Notice an omission? We handle hoops differently. - if (mt->type == 300 || mt->type == 308 || mt->type == 309 - || mt->type == 1706 || (mt->type >= 600 && mt->type <= 609) - || mt->type == 1800) - { - mt->mobj = NULL; - - // Z for objects Tails 05-26-2002 - mt->z = (INT16)(R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS) - ->sector->floorheight>>FRACBITS); - - P_SpawnHoopsAndRings (mt); - } - } - for (i = 0; i < numHoops; i++) - { - P_SpawnHoopsAndRings(hoopsToRespawn[i]); - } -} - // // P_LoadThings // @@ -1642,8 +1574,8 @@ static void P_CreateBlockMap(void) { register size_t i; fixed_t minx = INT32_MAX, miny = INT32_MAX, maxx = INT32_MIN, maxy = INT32_MIN; - // First find limits of map + // First find limits of map for (i = 0; i < numvertexes; i++) { if (vertexes[i].x>>FRACBITS < minx) diff --git a/src/p_setup.h b/src/p_setup.h index 36f2089aa..fe8b4afb5 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -93,7 +93,6 @@ size_t P_PrecacheLevelFlats(void); void P_AllocMapHeader(INT16 i); // Needed for NiGHTS -void P_ReloadRings(void); void P_DeleteGrades(INT16 i); void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext); UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare); diff --git a/src/p_slopes.c b/src/p_slopes.c index 38201ad86..6270821b1 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -40,7 +40,6 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) if (slope->normal.z == 0) { - slope->lightOffset = 0; #ifdef HWRENDER slope->hwLightOffset = 0; @@ -66,7 +65,8 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) } // Calculate line normal -void P_CalculateSlopeNormal(pslope_t *slope) { +void P_CalculateSlopeNormal(pslope_t *slope) +{ slope->normal.z = FINECOSINE(slope->zangle>>ANGLETOFINESHIFT); slope->normal.x = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), -slope->d.x); slope->normal.y = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), -slope->d.y); @@ -145,7 +145,8 @@ static void P_ReconfigureVertexSlope(pslope_t *slope) } // Recalculate dynamic slopes -void P_RunDynamicSlopes(void) { +void P_RunDynamicSlopes(void) +{ pslope_t *slope; for (slope = slopelist; slope; slope = slope->next) { @@ -329,7 +330,7 @@ void P_SpawnSlope_Line(int linenum) origin.y = line->v1->y + (line->v2->y - line->v1->y)/2; // For FOF slopes, make a special function to copy to the xy origin & direction relative to the position of the FOF on the map! - if(frontfloor || frontceil) + if (frontfloor || frontceil) { line->frontsector->hasslope = true; // Tell the software renderer that we're sloped @@ -353,7 +354,7 @@ void P_SpawnSlope_Line(int linenum) // TODO: We take origin and point 's xy values and translate them to the center of an FOF! - if(frontfloor) + if (frontfloor) { fixed_t highest, lowest; size_t l; @@ -462,7 +463,7 @@ void P_SpawnSlope_Line(int linenum) P_CalculateSlopeNormal(cslope); } } - if(backfloor || backceil) + if (backfloor || backceil) { line->backsector->hasslope = true; // Tell the software renderer that we're sloped @@ -485,7 +486,7 @@ void P_SpawnSlope_Line(int linenum) direction.x = -direction.x; direction.y = -direction.y; - if(backfloor) + if (backfloor) { fixed_t highest, lowest; size_t l; @@ -530,7 +531,7 @@ void P_SpawnSlope_Line(int linenum) P_CalculateSlopeNormal(fslope); } - if(backceil) + if (backceil) { fixed_t highest, lowest; size_t l; @@ -680,7 +681,8 @@ pslope_t *P_SlopeById(UINT16 id) } // Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes -void P_ResetDynamicSlopes(void) { +void P_ResetDynamicSlopes(void) +{ size_t i; slopelist = NULL; -- 2.54.0 From 58815ae9c412f3f766df6d0035a49ba0e52c4073 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Sep 2024 14:51:16 +0200 Subject: [PATCH 474/525] fix potential rendering issues on large maps --- src/p_setup.c | 2 +- src/r_defs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index a0d746bb4..cb8cd5af1 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -595,7 +595,7 @@ FUNCINLINE static ATTRINLINE void P_LoadRawSubsectors(void *data) { ss->sector = NULL; ss->numlines = SHORT(ms->numsegs); - ss->firstline = SHORT(ms->firstseg); + ss->firstline = (UINT16)SHORT(ms->firstseg); #ifdef FLOORSPLATS ss->splats = NULL; #endif diff --git a/src/r_defs.h b/src/r_defs.h index 3fe14545c..71e13e4d4 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -459,7 +459,7 @@ typedef struct subsector_s { sector_t *sector; INT16 numlines; - UINT16 firstline; + UINT32 firstline; struct polyobj_s *polyList; // haleyjd 02/19/06: list of polyobjects #if 1//#ifdef FLOORSPLATS void *splats; // floorsplat_t list -- 2.54.0 From b19bc7d77ed2cd2df1ee1cd7c6d4c38386674766 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Sep 2024 16:53:52 +0200 Subject: [PATCH 475/525] slight portal cleanup --- src/hardware/hw_main.c | 177 ++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 92 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 49239ce51..7265d038d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -116,11 +116,8 @@ consvar_t cv_grrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, grrenderdi NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nostencil = {"nostencil", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_portalline = {"portalline", "0", 0, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_portalonly = {"portalonly", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -CV_PossibleValue_t secbright_cons_t[] = {{0, "MIN"}, {255, "MAX"}, {0, NULL}}; +CV_PossibleValue_t secbright_cons_t[] = {{0, "MIN"}, {255, "MAX"}, {0, NULL}}; consvar_t cv_secbright = {"secbright", "0", CV_SAVE, secbright_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -5389,7 +5386,7 @@ static void HWR_PortalClipping(gl_portal_t *portal) gld_clipper_SafeAddClipRange(angle2, angle1); } -enum +enum { HWR_STENCIL_NORMAL, HWR_STENCIL_BEGIN, @@ -5401,7 +5398,7 @@ enum // Changes the current stencil state. static void HWR_SetStencilState(int state, int level) { - if (!cv_nostencil.value && level > -1) + if (level > -1) HWD.pfnSetSpecialState(HWD_SET_STENCIL_LEVEL, level); HWD.pfnSetSpecialState(HWD_SET_PORTAL_MODE, state); } @@ -5469,8 +5466,9 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe gl_portal_t *gl_portal_temp; portallist.base = portallist.cap = NULL; const boolean skybox = (skyboxmo[0] && cv_skybox.value); + boolean useportals = gr_maphasportals && cv_grportals.value && allow_portals; - if (cv_grportals.value && gr_maphasportals && allow_portals && stencil_level < cv_maxportals.value) // if recursion limit is not reached + if (useportals && stencil_level < cv_maxportals.value) // if recursion limit is not reached { // search for portals in current frame currentportallist = &portallist; @@ -5490,8 +5488,6 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe // note: if necessary, could sort the portals here? for (portal = portallist.base; portal; portal = portal->next) { - if (cv_portalline.value && cv_portalline.value != portal->startline) - continue; HWR_RenderPortal(portal, rootportal, fpov, player, stencil_level); } gr_portal = GRPORTAL_INSIDE;// when portal walls are encountered in following bsp traversal, nothing should be drawn @@ -5501,13 +5497,14 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); - if (!cv_portalonly.value || rootportal) - { - HWR_SetTransform(fpov, player); - HWR_ClearClipper(); - HWR_ClearSprites(); + HWR_SetTransform(fpov, player); + HWR_ClearSprites(); + HWR_ClearClipper(); + + if (useportals) + { if (!rootportal) portalclipline = NULL; else @@ -5515,70 +5512,72 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe HWR_PortalFrame(rootportal);// for portalclipsector, it could have gone null from search HWR_PortalClipping(rootportal); } - - // Set transform. - HWD.pfnSetTransform(&atransform); - - validcount++; - - ps_numbspcalls.value.i = 0; - ps_numpolyobjects.value.i = 0; - PS_START_TIMING(ps_bsptime); - - if (cv_grbatching.value) - HWR_StartBatching(); - - if (!rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently - gr_collect_skywalls = true; - - // HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree. - // This fixes specific effects not working, such as horizon lines. - int oldgl_portal_state = gr_portal; - - if (gr_portal != GRPORTAL_OFF) // if we already haven't hit the recursion limit or we already ended our portal shenanigans - gr_portal = GRPORTAL_INSIDE; // TURN IT OFF - - // Recursively "render" the BSP tree. - HWR_RenderBSPNode((INT32)numnodes-1); - - // woo we back - gr_portal = oldgl_portal_state; - - if (allow_portals) // looks weird, but this is only true when its not skybox rendering skipping precip in skyboxes like software does - HWR_AddPrecipitationSprites(); - - PS_STOP_TIMING(ps_bsptime); - - if (cv_grbatching.value) - HWR_RenderBatches(); - - if (skyWallVertexArraySize)// if there are skywalls to draw using the alternate method - { - HWR_SetStencilState(HWR_STENCIL_SKY, -1); - HWR_DrawSkyWallList(); - HWR_SkyWallList_Clear(); - HWR_SetStencilState(HWR_STENCIL_NORMAL, 1); - drewsky = false; - HWR_DrawSkyBackground(fpov); - HWR_SetStencilState(HWR_STENCIL_NORMAL, 0); - HWD.pfnClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer - HWR_SetTransform(fpov, player);// restore transform - } - gr_collect_skywalls = false; - - ps_numsprites.value.i = gr_visspritecount; - PS_START_TIMING(ps_hw_spritesorttime); - HWR_SortVisSprites(); - PS_STOP_TIMING(ps_hw_spritesorttime); - PS_START_TIMING(ps_hw_spritedrawtime); - HWR_DrawSprites(); - PS_STOP_TIMING(ps_hw_spritedrawtime); - - ps_numdrawnodes.value.i = 0; - ps_hw_nodesorttime.value.p = 0; - ps_hw_nodedrawtime.value.p = 0; - HWR_RenderDrawNodes(); } + else + portalclipline = NULL; + + // Set transform. + HWD.pfnSetTransform(&atransform); + + validcount++; + + ps_numbspcalls.value.i = 0; + ps_numpolyobjects.value.i = 0; + PS_START_TIMING(ps_bsptime); + + if (cv_grbatching.value) + HWR_StartBatching(); + + if (useportals && !rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently + gr_collect_skywalls = true; + + // HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree. + // This fixes specific effects not working, such as horizon lines. + int oldgl_portal_state = gr_portal; + + if (gr_portal != GRPORTAL_OFF) // if we already haven't hit the recursion limit or we already ended our portal shenanigans + gr_portal = GRPORTAL_INSIDE; // TURN IT OFF + + // Recursively "render" the BSP tree. + HWR_RenderBSPNode((INT32)numnodes-1); + + // woo we back + gr_portal = oldgl_portal_state; + + if (allow_portals) // looks weird, but this is only true when its not skybox rendering skipping precip in skyboxes like software does + HWR_AddPrecipitationSprites(); + + PS_STOP_TIMING(ps_bsptime); + + if (cv_grbatching.value) + HWR_RenderBatches(); + + if (skyWallVertexArraySize) // if there are skywalls to draw using the alternate method + { + HWR_SetStencilState(HWR_STENCIL_SKY, -1); + HWR_DrawSkyWallList(); + HWR_SkyWallList_Clear(); + HWR_SetStencilState(HWR_STENCIL_NORMAL, 1); + drewsky = false; + HWR_DrawSkyBackground(fpov); + HWR_SetStencilState(HWR_STENCIL_NORMAL, 0); + HWD.pfnClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer + HWR_SetTransform(fpov, player);// restore transform + } + gr_collect_skywalls = false; + + ps_numsprites.value.i = gr_visspritecount; + PS_START_TIMING(ps_hw_spritesorttime); + HWR_SortVisSprites(); + PS_STOP_TIMING(ps_hw_spritesorttime); + PS_START_TIMING(ps_hw_spritedrawtime); + HWR_DrawSprites(); + PS_STOP_TIMING(ps_hw_spritedrawtime); + + ps_numdrawnodes.value.i = 0; + ps_hw_nodesorttime.value.p = 0; + ps_hw_nodedrawtime.value.p = 0; + HWR_RenderDrawNodes(); // free memory from portal list allocated by calls to Add2Lines gl_portal_temp = portallist.base; @@ -5588,9 +5587,6 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe Z_Free(gl_portal_temp); gl_portal_temp = nextportal; } - - // TODO: batching at some point - // TODO: is it okay if stencil test is on all the time even when its not needed? } @@ -5790,7 +5786,7 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grfiltermode); CV_RegisterVar(&cv_granisotropicmode); CV_RegisterVar(&cv_grsolvetjoin); - + CV_RegisterVar(&cv_grbatching); CV_RegisterVar(&cv_splitwallfix); @@ -5800,25 +5796,22 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grfakecontrast); CV_RegisterVar(&cv_grslopecontrast); CV_RegisterVar(&cv_grhorizonlines); - + CV_RegisterVar(&cv_grfovchange); - + CV_RegisterVar(&cv_grmdls); CV_RegisterVar(&cv_grfallbackplayermodel); - + CV_RegisterVar(&cv_grspritebillboarding); - + CV_RegisterVar(&cv_grshearing); - + CV_RegisterVar(&cv_grshaders); - + CV_RegisterVar(&cv_grportals); - CV_RegisterVar(&cv_nostencil); - CV_RegisterVar(&cv_portalline); - CV_RegisterVar(&cv_portalonly); - + CV_RegisterVar(&cv_secbright); - + CV_RegisterVar(&cv_grpaletterendering); CV_RegisterVar(&cv_grpalettedepth); CV_RegisterVar(&cv_grflashpal); -- 2.54.0 From 9fdfc09229493657b0852a520878449308722e9e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Sep 2024 23:09:09 +0200 Subject: [PATCH 476/525] dont trigger rumble in offroad when under hyu effect --- src/p_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index 206228643..ed7252dc6 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -364,7 +364,7 @@ static inline void P_DeviceRumbleTick(void) { low = high = 65536 / 8; } - else if ((player->kartstuff[k_offroad]) + else if ((player->kartstuff[k_offroad] && !player->kartstuff[k_hyudorotimer]) && P_IsObjectOnGround(player->mo) && player->speed != 0) { low = high = 65536 / 64; -- 2.54.0 From ba4c54004aeb8e0e5d8e0ad519603ee89f1af550 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Sep 2024 23:33:54 +0200 Subject: [PATCH 477/525] turn off director by default when playing replays and restore the setting when done you can still toggle it in replays no issues but you mostly want to watch yourself or a certain person during replays, so having to manually toggle it off always is weird --- src/g_game.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index b6487e7c5..dc3bf1737 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -336,6 +336,10 @@ boolean precache = true; // if true, load all graphics at start INT16 prevmap, nextmap; +// save if director is enabled +// so demos can disable it by default and restore it after +int directorstate = 0; + static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -7719,6 +7723,9 @@ post_compat: players[i].kartweight = kartweight[i]; } + directorstate = cv_director.value; + CV_SetValue(&cv_director, 0); + demo.deferstart = true; } #undef SKIPERRORS @@ -8285,6 +8292,11 @@ void G_StopDemo(void) { Z_Free(demobuffer); demobuffer = NULL; + if (demo.playback) + { + CV_SetValue(&cv_director, directorstate); + directorstate = 0; + } demo.playback = false; if (demo.title) modeattacking = false; -- 2.54.0 From 14bce36b955ff29d2ce47c1c56ce491e38c60cce Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Sep 2024 23:36:50 +0200 Subject: [PATCH 478/525] make it static actually --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index dc3bf1737..04c63e360 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -338,7 +338,7 @@ INT16 prevmap, nextmap; // save if director is enabled // so demos can disable it by default and restore it after -int directorstate = 0; +static int directorstate = 0; static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -- 2.54.0 From 9448a9857386d4587494bb0877ae7565f88f2481 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 09:21:35 +0200 Subject: [PATCH 479/525] disable director on title screen and record attack demos --- src/k_director.c | 2 +- src/st_stuff.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index a0cb6f961..025c3041b 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -49,7 +49,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) static boolean K_DirectorIsEnabled(void) { - return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || demo.playback)); + return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || (demo.playback && (!demo.title || !modeattacking)))); } void K_InitDirector(void) diff --git a/src/st_stuff.c b/src/st_stuff.c index 419b527c2..3795db0b4 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -659,10 +659,7 @@ static void ST_overlayDrawer(void) if (!hu_showscores) // hide the following if TAB is held { - // Countdown timer for Race Mode - // ...moved to k_kart.c so we can take advantage of the LAPS_Y value - - if ((demo.playback || !P_IsLocalPlayer(stplyr)) && !splitscreen) + if (((demo.playback && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !splitscreen) { char directortext[20] = {0}; -- 2.54.0 From 847b1f5cb7a9b140c767df5dbca40db9120bc025 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 10:38:30 +0200 Subject: [PATCH 480/525] fade director hud after 4 secs after toggling it --- src/g_game.c | 2 ++ src/g_game.h | 2 ++ src/st_stuff.c | 13 ++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 04c63e360..c2eb93416 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -339,6 +339,7 @@ INT16 prevmap, nextmap; // save if director is enabled // so demos can disable it by default and restore it after static int directorstate = 0; +tic_t directortoggletimer = 0; static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1947,6 +1948,7 @@ boolean G_Responder(event_t *ev) || ev->data1 == gamecontrol[gc_director][1]) { K_ToggleDirector(); + directortoggletimer = 0; } return true; diff --git a/src/g_game.h b/src/g_game.h index 83d85ed91..14decd858 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -218,6 +218,8 @@ extern angle_t localangle[MAXSPLITSCREENPLAYERS]; extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but signed extern boolean camspin[MAXSPLITSCREENPLAYERS]; // SRB2Kart +extern tic_t directortoggletimer; + // // GAME // diff --git a/src/st_stuff.c b/src/st_stuff.c index 3795db0b4..37db6085e 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -28,6 +28,9 @@ #include "m_menu.h" #include "m_cheat.h" #include "p_setup.h" // NiGHTS grading + +#include "i_time.h" + #include "k_kart.h" // SRB2kart //random index @@ -665,8 +668,16 @@ static void ST_overlayDrawer(void) snprintf(directortext, 20, "Director: %s", cv_director.value ? "On" : "Off"); - V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANSHALF|V_ALLOWLOWERCASE, directortext); + if (directortoggletimer < (I_GetTime() + 40 * TICRATE) % I_GetTime()) + { + V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANSHALF|V_ALLOWLOWERCASE, directortext); + directortoggletimer++; + } + else if (cv_translucenthud.value != 0) + V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_80TRANS|V_ALLOWLOWERCASE, directortext); // idk if V_80TRANS is good? } + else + directortoggletimer = 0; if (cv_showviewpointtext.value) { -- 2.54.0 From 1d40d8c4ef96954172f09b9dcde370a489a21bf8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 15:58:36 +0200 Subject: [PATCH 481/525] make this less complicated lol --- src/st_stuff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 37db6085e..6a0ace9ac 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -668,10 +668,11 @@ static void ST_overlayDrawer(void) snprintf(directortext, 20, "Director: %s", cv_director.value ? "On" : "Off"); - if (directortoggletimer < (I_GetTime() + 40 * TICRATE) % I_GetTime()) + if (directortoggletimer < 4*TICRATE) { V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANSHALF|V_ALLOWLOWERCASE, directortext); - directortoggletimer++; + if (renderisnewtic) + directortoggletimer++; } else if (cv_translucenthud.value != 0) V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_80TRANS|V_ALLOWLOWERCASE, directortext); // idk if V_80TRANS is good? -- 2.54.0 From b9779d4dba708ab2c364d39f50c190198b1f65fa Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 16:05:01 +0200 Subject: [PATCH 482/525] add toggle for director prompt cause ik some ppl will complain lol --- src/d_netcmd.c | 2 ++ src/d_netcmd.h | 2 +- src/m_menu.c | 12 ++++++++---- src/st_stuff.c | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 00df2bc6a..121feb96a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -567,6 +567,7 @@ consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_ consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugdirector = {"debugdirector", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showdirectorhud = {"showdirectorhud", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showtrackaddon = {"showtrackaddon", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -988,6 +989,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_director); CV_RegisterVar(&cv_kartdebugdirector); + CV_RegisterVar(&cv_showdirectorhud); CV_RegisterVar(&cv_luaimmersion); CV_RegisterVar(&cv_fakelocalskin); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 81806b816..f4ca00214 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -202,7 +202,7 @@ extern consvar_t cv_ps_thinkframe_page; extern consvar_t cv_ps_samplesize; extern consvar_t cv_ps_descriptor; -extern consvar_t cv_director, cv_kartdebugdirector; +extern consvar_t cv_director, cv_kartdebugdirector, cv_showdirectorhud; extern consvar_t cv_showtrackaddon; diff --git a/src/m_menu.c b/src/m_menu.c index 60671d826..02bdb7418 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2243,12 +2243,14 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 70}, {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 85}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 80}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 95}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 100}, + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 90}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 110}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 100}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 105}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 115}, }; static const char* OP_SaturnHudTooltips[] = @@ -2267,6 +2269,7 @@ static const char* OP_SaturnHudTooltips[] = "Show the big Cecho Messages.", "Show player names on the minimap.", "Minimize the player icons on the minimap.", + "Show the Director Toggle prompt when spectating.", "Uncaps the HUD framerate, making it appear smoother.", "Nametag Options.", "Driftgauge Options.", @@ -2289,6 +2292,7 @@ enum sh_cechotogle, sh_mapname, sh_smallmap, + sh_directorhud, sh_uncappedhud, sh_nametagmen, sh_driftgaugemen, diff --git a/src/st_stuff.c b/src/st_stuff.c index 6a0ace9ac..983ce4007 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -662,7 +662,7 @@ static void ST_overlayDrawer(void) if (!hu_showscores) // hide the following if TAB is held { - if (((demo.playback && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !splitscreen) + if (cv_showdirectorhud.value && ((demo.playback && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !splitscreen) { char directortext[20] = {0}; -- 2.54.0 From 0e9b9d15ea056a6ee23407703867ad95078b49b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 18:51:00 +0200 Subject: [PATCH 483/525] revert this ig --- src/sdl/i_video.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 92f39bba9..241f09e05 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -229,7 +229,7 @@ void RefreshOGLSDLSurface(void) } #endif -static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool reposition) +static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) { static SDL_bool wasfullscreen = SDL_FALSE; Uint32 rmask; @@ -258,13 +258,10 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool } // Reposition window only in windowed mode SDL_SetWindowSize(window, width, height); - if (reposition) - { - SDL_SetWindowPosition(window, - SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), - SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) - ); - } + SDL_SetWindowPosition(window, + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) + ); } } else @@ -1971,7 +1968,7 @@ INT32 VID_SetMode(INT32 modeNum) } //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); - SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, (setmodeneeded ? SDL_TRUE : SDL_FALSE)); + SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); Impl_VideoSetupBuffer(); if (rendermode == render_soft) -- 2.54.0 From c148ff5a058fe7c6d764fd80e402597712467df8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 21:50:24 +0200 Subject: [PATCH 484/525] fix off by one in sprite lightlevels --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7265d038d..6ae8a1951 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3857,7 +3857,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = min(*list[i-1].lightlevel, 255); + lightlevel = min(*list[i].lightlevel, 255); colormap = list[i].extra_colormap; } -- 2.54.0 From 7a91b1996271145ced25c8a0f9f4ee960be126ec Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 21:50:55 +0200 Subject: [PATCH 485/525] only change lightlevel/colormap behaviour in palette rendering --- src/hardware/hw_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 6ae8a1951..dce7b0886 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1131,13 +1131,13 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { lightnum = pfloor->master->frontsector->lightlevel; colormap = pfloor->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); + lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); } else { lightnum = *list[i].lightlevel; colormap = list[i].extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); + lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); } } @@ -1506,7 +1506,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = gr_frontsector->lightlevel; colormap = gr_frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); + lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); if (gr_linedef->flags & ML_TFERLINE) noencore = true; @@ -2129,7 +2129,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); + lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); @@ -2243,7 +2243,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; - lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); + lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); @@ -4365,7 +4365,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean planeinfo->isceiling = isceiling; planeinfo->fixedheight = fixedheight; - planeinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel; + planeinfo->lightlevel = (HWR_ShouldUsePaletteRendering() && (planecolormap && (planecolormap->fog & 1))) ? 255 : lightlevel; planeinfo->lumpnum = lumpnum; planeinfo->xsub = xsub; @@ -4385,7 +4385,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, polyplaneinfo->isceiling = isceiling; polyplaneinfo->fixedheight = fixedheight; - polyplaneinfo->lightlevel = (planecolormap && (planecolormap->fog & 1)) ? 255 : lightlevel; + polyplaneinfo->lightlevel = (HWR_ShouldUsePaletteRendering() && (planecolormap && (planecolormap->fog & 1))) ? 255 : lightlevel; polyplaneinfo->lumpnum = lumpnum; polyplaneinfo->polysector = polysector; -- 2.54.0 From 926287eb971a8af7dc0168bccab73dcac0e35eb0 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 22:02:49 +0200 Subject: [PATCH 486/525] remove redundant check --- src/hardware/hw_main.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index dce7b0886..7be14b1ed 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -236,12 +236,8 @@ static void CV_grpalettedepth_OnChange(void) static void CV_grframebuffer_OnChange(void) { ONLY_IF_GL_LOADED - if (cv_grscreentextures.value != 2) - { // screen FBO needs screen textures -#ifdef USE_FBO_OGL + if (cv_grscreentextures.value != 2) // screen FBO needs screen textures CV_Set(&cv_grframebuffer, "Off"); -#endif - } HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value); I_DownSample(); RefreshOGLSDLSurface(); -- 2.54.0 From 77c9badeca54377661903ee36012031f24437ee2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 22:31:38 +0200 Subject: [PATCH 487/525] smol optimization to HWR_AddLine --- src/hardware/hw_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 7be14b1ed..71b1bc17c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2521,6 +2521,18 @@ doaddline: { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); + if (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum + && gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then + { + if (!line->polyseg && + !line->sidedef->midtexture + && ((!gr_frontsector->ffloors && !gr_backsector->ffloors))) + return; // line is empty, don't even bother + // treat like wide open window instead + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + return; + } + if (CheckClip(gr_frontsector, gr_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); -- 2.54.0 From f9463d8efac7dc5067347ecc14e9ec1c7fba562e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 22:32:51 +0200 Subject: [PATCH 488/525] smol cleanup --- src/hardware/hw_main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 71b1bc17c..ca60fac28 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1515,7 +1515,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // two sided line if (gr_backsector) { - INT32 gr_toptexture, gr_bottomtexture; + INT32 gr_toptexture = 0, gr_bottomtexture = 0; SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight) @@ -2486,10 +2486,7 @@ static void HWR_AddLine(seg_t *line) } if (gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH) - { - gr_backsector = line->backsector; goto doaddline; - } if (line->linedef->special == 40) { -- 2.54.0 From 677cdc77e4eff4045e3e33947b1aabb802940614 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Sep 2024 22:54:18 +0200 Subject: [PATCH 489/525] smol optimization R_AddLine --- src/hardware/hw_main.c | 5 +++-- src/r_bsp.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ca60fac28..8bf6f715d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2523,8 +2523,9 @@ doaddline: { if (!line->polyseg && !line->sidedef->midtexture - && ((!gr_frontsector->ffloors && !gr_backsector->ffloors))) - return; // line is empty, don't even bother + && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) + || (gr_frontsector->tag == gr_backsector->tag))) + return; // line is empty, don't even bother // treat like wide open window instead HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D return; diff --git a/src/r_bsp.c b/src/r_bsp.c index 58573eb99..9043ecd60 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -500,6 +500,17 @@ static void R_AddLine(seg_t *line) doorclosed = 0; + if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum && backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then + { + if (!line->polyseg && + !line->sidedef->midtexture + && ((!frontsector->ffloors && !backsector->ffloors) + || (frontsector->tag == backsector->tag))) + return; // line is empty, don't even bother + + goto clippass; // treat like wide open window instead + } + // Closed door. if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope) { -- 2.54.0 From dd405532af50eeae05cb80bdf0d21065139a6619 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 9 Sep 2024 23:56:42 +0300 Subject: [PATCH 490/525] Snap title demo logo to bottom right corner --- src/k_kart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index cf1d59f42..03efb24c9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10620,6 +10620,7 @@ void K_drawKartHUD(void) if (demo.title) // Draw title logo instead in demo.titles { INT32 x = (BASEVIDWIDTH - 32)*FRACUNIT, y = 128*FRACUNIT, offs; + INT32 logoflags = V_SNAPTORIGHT|V_SNAPTOBOTTOM; if (splitscreen == 3) { @@ -10638,8 +10639,8 @@ void K_drawKartHUD(void) x += offs - frac; } - V_DrawSciencePatch(x - (54*FRACUNIT), y, 0, W_CachePatchName("TTKBANNR", PU_CACHE), FRACUNIT/4); - V_DrawSciencePatch(x - (54*FRACUNIT), y + (25*FRACUNIT), 0, W_CachePatchName("TTKART", PU_CACHE), FRACUNIT/4); + V_DrawSciencePatch(x - (54*FRACUNIT), y, logoflags, W_CachePatchName("TTKBANNR", PU_CACHE), FRACUNIT/4); + V_DrawSciencePatch(x - (54*FRACUNIT), y + (25*FRACUNIT), logoflags, W_CachePatchName("TTKART", PU_CACHE), FRACUNIT/4); } else if (G_RaceGametype()) // Race-only elements { -- 2.54.0 From c3a03d89c4919f5da98a7e68859aedfad7cd4bc0 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Sep 2024 10:31:13 +0200 Subject: [PATCH 491/525] Zzz... --- src/hardware/hw_main.c | 5 ----- src/r_bsp.c | 9 ++------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8bf6f715d..bdbe8a6b6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2521,11 +2521,6 @@ doaddline: if (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum && gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then { - if (!line->polyseg && - !line->sidedef->midtexture - && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || (gr_frontsector->tag == gr_backsector->tag))) - return; // line is empty, don't even bother // treat like wide open window instead HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D return; diff --git a/src/r_bsp.c b/src/r_bsp.c index 9043ecd60..d68816496 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -500,14 +500,9 @@ static void R_AddLine(seg_t *line) doorclosed = 0; - if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum && backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then + if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum + && backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then { - if (!line->polyseg && - !line->sidedef->midtexture - && ((!frontsector->ffloors && !backsector->ffloors) - || (frontsector->tag == backsector->tag))) - return; // line is empty, don't even bother - goto clippass; // treat like wide open window instead } -- 2.54.0 From ff591bce04ec98d439a1f1464c4b05017aeb7e1b Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Sep 2024 10:58:09 +0200 Subject: [PATCH 492/525] Revert "Zzz..." This reverts commit c3a03d89c4919f5da98a7e68859aedfad7cd4bc0. --- src/hardware/hw_main.c | 5 +++++ src/r_bsp.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bdbe8a6b6..8bf6f715d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2521,6 +2521,11 @@ doaddline: if (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum && gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then { + if (!line->polyseg && + !line->sidedef->midtexture + && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) + || (gr_frontsector->tag == gr_backsector->tag))) + return; // line is empty, don't even bother // treat like wide open window instead HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D return; diff --git a/src/r_bsp.c b/src/r_bsp.c index d68816496..9043ecd60 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -500,9 +500,14 @@ static void R_AddLine(seg_t *line) doorclosed = 0; - if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum - && backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then + if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum && backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then { + if (!line->polyseg && + !line->sidedef->midtexture + && ((!frontsector->ffloors && !backsector->ffloors) + || (frontsector->tag == backsector->tag))) + return; // line is empty, don't even bother + goto clippass; // treat like wide open window instead } -- 2.54.0 From 3b227932e950ea5d5d88a6594457f26f79a41fda Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Sep 2024 10:58:12 +0200 Subject: [PATCH 493/525] Revert "smol optimization R_AddLine" This reverts commit 677cdc77e4eff4045e3e33947b1aabb802940614. --- src/hardware/hw_main.c | 5 ++--- src/r_bsp.c | 11 ----------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8bf6f715d..ca60fac28 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2523,9 +2523,8 @@ doaddline: { if (!line->polyseg && !line->sidedef->midtexture - && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || (gr_frontsector->tag == gr_backsector->tag))) - return; // line is empty, don't even bother + && ((!gr_frontsector->ffloors && !gr_backsector->ffloors))) + return; // line is empty, don't even bother // treat like wide open window instead HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D return; diff --git a/src/r_bsp.c b/src/r_bsp.c index 9043ecd60..58573eb99 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -500,17 +500,6 @@ static void R_AddLine(seg_t *line) doorclosed = 0; - if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum && backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then - { - if (!line->polyseg && - !line->sidedef->midtexture - && ((!frontsector->ffloors && !backsector->ffloors) - || (frontsector->tag == backsector->tag))) - return; // line is empty, don't even bother - - goto clippass; // treat like wide open window instead - } - // Closed door. if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope) { -- 2.54.0 From 85a1636776f530e05ba2e3eeb100f263977ae2e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Sep 2024 10:58:15 +0200 Subject: [PATCH 494/525] Revert "smol optimization to HWR_AddLine" This reverts commit 77c9badeca54377661903ee36012031f24437ee2. --- src/hardware/hw_main.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ca60fac28..77dc56511 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2518,18 +2518,6 @@ doaddline: { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); - if (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum - && gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum) // everything's sky? let's save us a bit of time then - { - if (!line->polyseg && - !line->sidedef->midtexture - && ((!gr_frontsector->ffloors && !gr_backsector->ffloors))) - return; // line is empty, don't even bother - // treat like wide open window instead - HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - return; - } - if (CheckClip(gr_frontsector, gr_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); -- 2.54.0 From 31118254a0956551a2077efbf611244293697ac7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Sep 2024 19:51:52 +0200 Subject: [PATCH 495/525] this can be int16 --- src/k_director.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_director.c b/src/k_director.c index 025c3041b..952adf8da 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -73,8 +73,8 @@ static fixed_t K_GetDistanceToFinish(player_t player) { mobj_t *mo; fixed_t dist = 0; - int maxMoveCount = -1; - int maxAngle = -1; + INT16 maxMoveCount = -1; + INT16 maxAngle = -1; if (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)) { @@ -87,7 +87,7 @@ static fixed_t K_GetDistanceToFinish(player_t player) mo->y - player.mo->y), mo->z - player.mo->z) / FRACUNIT; - break; + break; } } else // crappy optimization weeeee -- 2.54.0 From 8d0601c2adbff89ec729e809da3d85d3a978be3d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 11 Sep 2024 19:43:57 +0200 Subject: [PATCH 496/525] add missing masterserver ifdef --- src/m_menu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 02bdb7418..b70de482a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10480,7 +10480,7 @@ static void M_DrawServerMenu(void) { M_DrawLevelSelectOnly(false, false); - #ifdef MASTERSERVER +#ifdef MASTERSERVER if (currentMenu == &MP_ServerDef && cv_advertise.value) // Remind players where they're hosting. { int mservflags = V_ALLOWLOWERCASE; @@ -10490,7 +10490,7 @@ static void M_DrawServerMenu(void) mservflags = mservflags|warningflags; V_DrawCenteredThinString(BASEVIDWIDTH/2, BASEVIDHEIGHT-12, mservflags, va("Master Server: %s", cv_masterserver.string)); } - #endif +#endif M_DrawGenericMenu(); } @@ -10523,7 +10523,9 @@ static void M_StartServerMenu(INT32 choice) levellistmode = LLM_CREATESERVER; M_PrepareLevelSelect(); M_SetupNextMenu(&MP_ServerDef); +#ifdef MASTERSERVER Get_rules(); +#endif M_PopupMasterServerRules(); } -- 2.54.0 From 241d1074853c6a74c2857e5546670b3cd12fb9d8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 11 Sep 2024 19:56:17 +0200 Subject: [PATCH 497/525] let item button toggle encore in mapselect screen guh --- src/m_menu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index b70de482a..2e1fcc1ba 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3655,6 +3655,15 @@ boolean M_Responder(event_t *ev) DPADRIGHTSCROLL = true; break; } + + if (currentMenu == &MISC_ChangeLevelDef || currentMenu == &MP_OfflineServerDef || currentMenu == &MP_ServerDef) + { + if (ev->data1 == gamecontrol[gc_fire][0] + || ev->data1 == gamecontrol[gc_fire][1]) + { + COM_ImmedExecute("add kartencore 1"); + } + } } else if (ev->type == ev_keyup) { @@ -10338,6 +10347,17 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) patch_t *PictureOfLevel; INT32 x, y, w, i, oldval, trans, dupadjust = ((vid.width/vid.dupx) - BASEVIDWIDTH)>>1; + char encoretoggle[32] = {0}; + const char *item1 = gamecontrol[gc_fire][0] != 0 ? G_KeynumToString(gamecontrol[gc_fire][0]) : NULL; + const char *item2 = gamecontrol[gc_fire][1] != 0 ? G_KeynumToString(gamecontrol[gc_fire][1]) : NULL; + + if (item1 != NULL && item2 != NULL) + snprintf(encoretoggle, 32, "%s/%s: Toggle Encore", item1, item2); + else + snprintf(encoretoggle, 32, "%s: Toggle Encore", item1 != NULL ? item1 : item2 != NULL ? item2 : "Item"); + + V_DrawThinString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_TRANSLUCENT|V_ALLOWLOWERCASE, encoretoggle); + // A 160x100 image of the level as entry MAPxxP if (cv_nextmap.value) { -- 2.54.0 From 1c8ca2b1102f32cd891d9f55e5abfdbb0f4990af Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 11 Sep 2024 20:11:15 +0200 Subject: [PATCH 498/525] apparently this always runs i am in pain --- src/m_menu.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 2e1fcc1ba..6bb6c561c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3640,28 +3640,31 @@ boolean M_Responder(event_t *ev) break; } - switch (ev->data1) // if you pressed it set those to true + if (menuactive) { - case KEY_HAT1: - DPADUPSCROLL = true; - break; - case KEY_HAT1 + 1: - DPADDOWNSCROLL = true; - break; - case KEY_HAT1 + 2: - DPADLEFTSCROLL = true; - break; - case KEY_HAT1 + 3: - DPADRIGHTSCROLL = true; - break; - } - - if (currentMenu == &MISC_ChangeLevelDef || currentMenu == &MP_OfflineServerDef || currentMenu == &MP_ServerDef) - { - if (ev->data1 == gamecontrol[gc_fire][0] - || ev->data1 == gamecontrol[gc_fire][1]) + switch (ev->data1) // if you pressed it set those to true { - COM_ImmedExecute("add kartencore 1"); + case KEY_HAT1: + DPADUPSCROLL = true; + break; + case KEY_HAT1 + 1: + DPADDOWNSCROLL = true; + break; + case KEY_HAT1 + 2: + DPADLEFTSCROLL = true; + break; + case KEY_HAT1 + 3: + DPADRIGHTSCROLL = true; + break; + } + + if (currentMenu == &MISC_ChangeLevelDef || currentMenu == &MP_OfflineServerDef || currentMenu == &MP_ServerDef) + { + if (ev->data1 == gamecontrol[gc_fire][0] + || ev->data1 == gamecontrol[gc_fire][1]) + { + COM_ImmedExecute("add kartencore 1"); + } } } } -- 2.54.0 From 41fc4c7cfd1897defa67cb9319b09a233c791c88 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 12 Sep 2024 01:05:05 +0200 Subject: [PATCH 499/525] delete DEH_WriteUndoline it literally does nothing lol --- src/dehacked.c | 138 ------------------------------------------------- src/dehacked.h | 2 - src/p_setup.c | 36 ------------- 3 files changed, 176 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 094e3d641..80a8e0ec1 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -291,8 +291,6 @@ static void readPlayer(MYFILE *f, INT32 num) INT32 i; boolean slotfound = false; - DEH_WriteUndoline("PLAYERTEXT", description[num].notes, UNDO_ENDTEXT); - do { if (myfgets(s, MAXLINELEN, f)) @@ -362,7 +360,6 @@ static void readPlayer(MYFILE *f, INT32 num) { if (!slotfound && (slotfound = findFreeSlot(&num)) == false) goto done; - DEH_WriteUndoline(word, &description[num].picname[0], UNDO_NONE); PlayerMenu[num].status = IT_CALL; strncpy(description[num].picname, word2, 8); } @@ -386,7 +383,6 @@ static void readPlayer(MYFILE *f, INT32 num) */ if (i != IT_DISABLED && !slotfound && (slotfound = findFreeSlot(&num)) == false) goto done; - DEH_WriteUndoline(word, va("%d", PlayerMenu[num].status), UNDO_NONE); PlayerMenu[num].status = (INT16)i; } else if (fastcmp(word, "SKINNAME")) @@ -394,7 +390,6 @@ static void readPlayer(MYFILE *f, INT32 num) // Send to free slot. if (!slotfound && (slotfound = findFreeSlot(&num)) == false) goto done; - DEH_WriteUndoline(word, description[num].skinname, UNDO_NONE); PlayerMenu[num].status = IT_CALL; strlcpy(description[num].skinname, word2, sizeof description[num].skinname); @@ -557,122 +552,98 @@ static void readthing(MYFILE *f, INT32 num) if (fastcmp(word, "MAPTHINGNUM") || fastcmp(word, "DOOMEDNUM")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].doomednum), UNDO_NONE); mobjinfo[num].doomednum = (INT32)atoi(word2); } else if (fastcmp(word, "SPAWNSTATE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].spawnstate), UNDO_NONE); mobjinfo[num].spawnstate = get_number(word2); } else if (fastcmp(word, "SPAWNHEALTH")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].spawnhealth), UNDO_NONE); mobjinfo[num].spawnhealth = (INT32)get_number(word2); } else if (fastcmp(word, "SEESTATE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].seestate), UNDO_NONE); mobjinfo[num].seestate = get_number(word2); } else if (fastcmp(word, "SEESOUND")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].seesound), UNDO_NONE); mobjinfo[num].seesound = get_number(word2); } else if (fastcmp(word, "REACTIONTIME")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].reactiontime), UNDO_NONE); mobjinfo[num].reactiontime = (INT32)get_number(word2); } else if (fastcmp(word, "ATTACKSOUND")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].attacksound), UNDO_NONE); mobjinfo[num].attacksound = get_number(word2); } else if (fastcmp(word, "PAINSTATE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].painstate), UNDO_NONE); mobjinfo[num].painstate = get_number(word2); } else if (fastcmp(word, "PAINCHANCE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].painchance), UNDO_NONE); mobjinfo[num].painchance = (INT32)get_number(word2); } else if (fastcmp(word, "PAINSOUND")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].painsound), UNDO_NONE); mobjinfo[num].painsound = get_number(word2); } else if (fastcmp(word, "MELEESTATE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].meleestate), UNDO_NONE); mobjinfo[num].meleestate = get_number(word2); } else if (fastcmp(word, "MISSILESTATE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].missilestate), UNDO_NONE); mobjinfo[num].missilestate = get_number(word2); } else if (fastcmp(word, "DEATHSTATE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].deathstate), UNDO_NONE); mobjinfo[num].deathstate = get_number(word2); } else if (fastcmp(word, "DEATHSOUND")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].deathsound), UNDO_NONE); mobjinfo[num].deathsound = get_number(word2); } else if (fastcmp(word, "XDEATHSTATE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].xdeathstate), UNDO_NONE); mobjinfo[num].xdeathstate = get_number(word2); } else if (fastcmp(word, "SPEED")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].speed), UNDO_NONE); mobjinfo[num].speed = get_number(word2); } else if (fastcmp(word, "RADIUS")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].radius), UNDO_NONE); mobjinfo[num].radius = get_number(word2); } else if (fastcmp(word, "HEIGHT")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].height), UNDO_NONE); mobjinfo[num].height = get_number(word2); } else if (fastcmp(word, "DISPOFFSET")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].dispoffset), UNDO_NONE); mobjinfo[num].dispoffset = get_number(word2); } else if (fastcmp(word, "MASS")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].mass), UNDO_NONE); mobjinfo[num].mass = (INT32)get_number(word2); } else if (fastcmp(word, "DAMAGE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].damage), UNDO_NONE); mobjinfo[num].damage = (INT32)get_number(word2); } else if (fastcmp(word, "ACTIVESOUND")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].activesound), UNDO_NONE); mobjinfo[num].activesound = get_number(word2); } else if (fastcmp(word, "FLAGS")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].flags), UNDO_NONE); mobjinfo[num].flags = (INT32)get_number(word2); } else if (fastcmp(word, "RAISESTATE")) { - DEH_WriteUndoline(word, va("%d", mobjinfo[num].raisestate), UNDO_NONE); mobjinfo[num].raisestate = get_number(word2); } else @@ -1110,8 +1081,6 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) UINT16 usi; UINT8 picid; - DEH_WriteUndoline("SCENETEXT", cutscenes[num]->scene[scenenum].text, UNDO_ENDTEXT); - do { if (myfgets(s, MAXLINELEN, f)) @@ -1188,7 +1157,6 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) if (fastcmp(word, "NUMBEROFPICS")) { - DEH_WriteUndoline(word, va("%d", cutscenes[num]->scene[scenenum].numpics), UNDO_NONE); cutscenes[num]->scene[scenenum].numpics = (UINT8)i; } else if (fastncmp(word, "PIC", 3)) @@ -1203,27 +1171,22 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) if (fastcmp(word+4, "NAME")) { - DEH_WriteUndoline(word, cutscenes[num]->scene[scenenum].picname[picid], UNDO_NONE); strncpy(cutscenes[num]->scene[scenenum].picname[picid], word2, 8); } else if (fastcmp(word+4, "HIRES")) { - DEH_WriteUndoline(word, va("%d", cutscenes[num]->scene[scenenum].pichires[picid]), UNDO_NONE); cutscenes[num]->scene[scenenum].pichires[picid] = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); } else if (fastcmp(word+4, "DURATION")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].picduration[picid]), UNDO_NONE); cutscenes[num]->scene[scenenum].picduration[picid] = usi; } else if (fastcmp(word+4, "XCOORD")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].xcoord[picid]), UNDO_NONE); cutscenes[num]->scene[scenenum].xcoord[picid] = usi; } else if (fastcmp(word+4, "YCOORD")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].ycoord[picid]), UNDO_NONE); cutscenes[num]->scene[scenenum].ycoord[picid] = usi; } else @@ -1231,14 +1194,12 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) } else if (fastcmp(word, "MUSIC")) { - DEH_WriteUndoline(word, cutscenes[num]->scene[scenenum].musswitch, UNDO_NONE); strncpy(cutscenes[num]->scene[scenenum].musswitch, word2, 7); cutscenes[num]->scene[scenenum].musswitch[6] = 0; } #ifdef MUSICSLOT_COMPATIBILITY else if (fastcmp(word, "MUSICSLOT")) { - DEH_WriteUndoline(word, cutscenes[num]->scene[scenenum].musswitch, UNDO_NONE); i = get_mus(word2, true); if (i && i <= 1035) snprintf(cutscenes[num]->scene[scenenum].musswitch, 7, "%sM", G_BuildMapName(i)); @@ -1251,42 +1212,34 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) #endif else if (fastcmp(word, "MUSICTRACK")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musswitchflags), UNDO_NONE); cutscenes[num]->scene[scenenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK; } else if (fastcmp(word, "MUSICPOS")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musswitchposition), UNDO_NONE); cutscenes[num]->scene[scenenum].musswitchposition = (UINT32)get_number(word2); } else if (fastcmp(word, "MUSICLOOP")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musicloop), UNDO_NONE); cutscenes[num]->scene[scenenum].musicloop = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); } else if (fastcmp(word, "TEXTXPOS")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].textxpos), UNDO_NONE); cutscenes[num]->scene[scenenum].textxpos = usi; } else if (fastcmp(word, "TEXTYPOS")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].textypos), UNDO_NONE); cutscenes[num]->scene[scenenum].textypos = usi; } else if (fastcmp(word, "FADEINID")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].fadenum), UNDO_NONE); cutscenes[num]->scene[scenenum].fadeinid = (UINT8)i; } else if (fastcmp(word, "FADEOUTID")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].fadenum), UNDO_NONE); cutscenes[num]->scene[scenenum].fadeoutid = (UINT8)i; } else if (fastcmp(word, "FADECOLOR")) { - DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].fadenum), UNDO_NONE); cutscenes[num]->scene[scenenum].fadecolor = (UINT8)i; } else @@ -1346,8 +1299,6 @@ static void readcutscene(MYFILE *f, INT32 num) if (1 <= value && value <= 128) { readcutscenescene(f, num, value - 1); - DEH_WriteUndoline(word, word2, UNDO_SPACE|UNDO_CUTLINE); - DEH_WriteUndoline("NUMSCENES", va("%d", oldnumscenes), UNDO_SPACE); } else deh_warning("Scene number %d out of range (1 - 128)", value); @@ -1403,12 +1354,10 @@ static void readhuditem(MYFILE *f, INT32 num) if (fastcmp(word, "X")) { - DEH_WriteUndoline(word, va("%d", hudinfo[num].x), UNDO_NONE); hudinfo[num].x = i; } else if (fastcmp(word, "Y")) { - DEH_WriteUndoline(word, va("%d", hudinfo[num].y), UNDO_NONE); hudinfo[num].y = i; } else @@ -1670,32 +1619,26 @@ static void readframe(MYFILE *f, INT32 num) if (fastcmp(word1, "SPRITENUMBER") || fastcmp(word1, "SPRITENAME")) { - DEH_WriteUndoline(word1, va("%u", states[num].sprite), UNDO_NONE); states[num].sprite = get_sprite(word2); } else if (fastcmp(word1, "SPRITESUBNUMBER") || fastcmp(word1, "SPRITEFRAME")) { - DEH_WriteUndoline(word1, va("%d", states[num].frame), UNDO_NONE); states[num].frame = (INT32)get_number(word2); // So the FF_ flags get calculated } else if (fastcmp(word1, "DURATION")) { - DEH_WriteUndoline(word1, va("%u", states[num].tics), UNDO_NONE); states[num].tics = (INT32)get_number(word2); // So TICRATE can be used } else if (fastcmp(word1, "NEXT")) { - DEH_WriteUndoline(word1, va("%d", states[num].nextstate), UNDO_NONE); states[num].nextstate = get_state(word2); } else if (fastcmp(word1, "VAR1")) { - DEH_WriteUndoline(word1, va("%d", states[num].var1), UNDO_NONE); states[num].var1 = (INT32)get_number(word2); } else if (fastcmp(word1, "VAR2")) { - DEH_WriteUndoline(word1, va("%d", states[num].var2), UNDO_NONE); states[num].var2 = (INT32)get_number(word2); } else if (fastcmp(word1, "ACTION")) @@ -1721,7 +1664,6 @@ static void readframe(MYFILE *f, INT32 num) { if (actionpointers[z].action.acv == states[num].action.acv) { - DEH_WriteUndoline(word1, actionpointers[z].name, UNDO_NONE); break; } } @@ -1781,17 +1723,14 @@ static void readsound(MYFILE *f, INT32 num, const char *savesfxnames[]) if (fastcmp(word, "SINGULAR")) { - DEH_WriteUndoline(word, va("%d", S_sfx[num].singularity), UNDO_NONE); S_sfx[num].singularity = value; } else if (fastcmp(word, "PRIORITY")) { - DEH_WriteUndoline(word, va("%d", S_sfx[num].priority), UNDO_NONE); S_sfx[num].priority = value; } else if (fastcmp(word, "FLAGS")) { - DEH_WriteUndoline(word, va("%d", S_sfx[num].pitch), UNDO_NONE); S_sfx[num].pitch = value; } else @@ -1851,16 +1790,6 @@ static void reademblemdata(MYFILE *f, INT32 num) INT32 value; // Reset all data initially - DEH_WriteUndoline("TYPE", va("%d", emblemlocations[num-1].type), UNDO_NONE); - DEH_WriteUndoline("X", va("%d", emblemlocations[num-1].x), UNDO_NONE); - DEH_WriteUndoline("Y", va("%d", emblemlocations[num-1].y), UNDO_NONE); - DEH_WriteUndoline("Z", va("%d", emblemlocations[num-1].z), UNDO_NONE); - DEH_WriteUndoline("MAPNUM", va("%d", emblemlocations[num-1].level), UNDO_NONE); - DEH_WriteUndoline("VAR", va("%d", emblemlocations[num-1].var), UNDO_NONE); - DEH_WriteUndoline("SPRITE", va("%d", emblemlocations[num-1].sprite), UNDO_NONE); - DEH_WriteUndoline("COLOR", va("%d", emblemlocations[num-1].color), UNDO_NONE); - DEH_WriteUndoline("HINT", extraemblems[num-1].hint, UNDO_NONE); - memset(&emblemlocations[num-1], 0, sizeof(emblem_t)); do @@ -1988,12 +1917,6 @@ static void readextraemblemdata(MYFILE *f, INT32 num) INT32 value; // Reset all data initially - DEH_WriteUndoline("NAME", extraemblems[num-1].name, UNDO_NONE); - DEH_WriteUndoline("OBJECTIVE", extraemblems[num-1].description, UNDO_NONE); - DEH_WriteUndoline("CONDITIONSET", va("%d", extraemblems[num-1].conditionset), UNDO_NONE); - DEH_WriteUndoline("SPRITE", va("%d", extraemblems[num-1].sprite), UNDO_NONE); - DEH_WriteUndoline("COLOR", va("%d", extraemblems[num-1].color), UNDO_NONE); - memset(&extraemblems[num-1], 0, sizeof(extraemblem_t)); do @@ -2072,15 +1995,6 @@ static void readunlockable(MYFILE *f, INT32 num) INT32 i; // Same deal with unlockables, clear all first - DEH_WriteUndoline("NAME", unlockables[num].name, UNDO_NONE); - DEH_WriteUndoline("OBJECTIVE", unlockables[num].objective, UNDO_NONE); - DEH_WriteUndoline("HEIGHT", va("%d", unlockables[num].height), UNDO_NONE); - DEH_WriteUndoline("CONDITIONSET", va("%d", unlockables[num].conditionset), UNDO_NONE); - DEH_WriteUndoline("TYPE", va("%d", unlockables[num].type), UNDO_NONE); - DEH_WriteUndoline("NOCECHO", va("%d", unlockables[num].nocecho), UNDO_NONE); - DEH_WriteUndoline("NOCHECKLIST", va("%d", unlockables[num].nochecklist), UNDO_NONE); - DEH_WriteUndoline("VAR", va("%d", unlockables[num].variable), UNDO_NONE); - memset(&unlockables[num], 0, sizeof(unlockable_t)); do @@ -2459,13 +2373,11 @@ static void readpatch(MYFILE *f, const char *name, UINT16 wad) // X position of the patch in the texture. if (fastcmp(word, "X")) { - //DEH_WriteUndoline(word, va("%d", patch->originx), UNDO_NONE); patch.originx = (INT16)value; } // Y position of the patch in the texture. else if (fastcmp(word, "Y")) { - //DEH_WriteUndoline(word, va("%d", patch->originy), UNDO_NONE); patch.originy = (INT16)value; } else @@ -2534,7 +2446,6 @@ static void readmaincfg(MYFILE *f) else value = get_number(word2); - DEH_WriteUndoline(word, va("%d", spstage_start), UNDO_NONE); spstage_start = (INT16)value; } else if (fastcmp(word, "SSTAGE_START")) @@ -2548,79 +2459,64 @@ static void readmaincfg(MYFILE *f) else value = get_number(word2); - DEH_WriteUndoline(word, va("%d", sstage_start), UNDO_NONE); sstage_start = (INT16)value; sstage_end = (INT16)(sstage_start+6); // 7 special stages total } else if (fastcmp(word, "USENIGHTSSS")) { - DEH_WriteUndoline(word, va("%d", useNightsSS), UNDO_NONE); useNightsSS = (value || word2[0] == 'T' || word2[0] == 'Y'); } else if (fastcmp(word, "REDTEAM")) { - DEH_WriteUndoline(word, va("%d", skincolor_redteam), UNDO_NONE); skincolor_redteam = (UINT8)get_number(word2); } else if (fastcmp(word, "BLUETEAM")) { - DEH_WriteUndoline(word, va("%d", skincolor_blueteam), UNDO_NONE); skincolor_blueteam = (UINT8)get_number(word2); } else if (fastcmp(word, "REDRING")) { - DEH_WriteUndoline(word, va("%d", skincolor_redring), UNDO_NONE); skincolor_redring = (UINT8)get_number(word2); } else if (fastcmp(word, "BLUERING")) { - DEH_WriteUndoline(word, va("%d", skincolor_bluering), UNDO_NONE); skincolor_bluering = (UINT8)get_number(word2); } else if (fastcmp(word, "INVULNTICS")) { - DEH_WriteUndoline(word, va("%u", invulntics), UNDO_NONE); invulntics = (UINT16)get_number(word2); } else if (fastcmp(word, "SNEAKERTICS")) { - DEH_WriteUndoline(word, va("%u", sneakertics), UNDO_NONE); sneakertics = (UINT16)get_number(word2); } else if (fastcmp(word, "FLASHINGTICS")) { - DEH_WriteUndoline(word, va("%u", flashingtics), UNDO_NONE); flashingtics = (UINT16)get_number(word2); } else if (fastcmp(word, "TAILSFLYTICS")) { - DEH_WriteUndoline(word, va("%u", tailsflytics), UNDO_NONE); tailsflytics = (UINT16)get_number(word2); } else if (fastcmp(word, "UNDERWATERTICS")) { - DEH_WriteUndoline(word, va("%u", underwatertics), UNDO_NONE); underwatertics = (UINT16)get_number(word2); } else if (fastcmp(word, "SPACETIMETICS")) { - DEH_WriteUndoline(word, va("%u", spacetimetics), UNDO_NONE); spacetimetics = (UINT16)get_number(word2); } else if (fastcmp(word, "EXTRALIFETICS")) { - DEH_WriteUndoline(word, va("%u", extralifetics), UNDO_NONE); extralifetics = (UINT16)get_number(word2); } else if (fastcmp(word, "GAMEOVERTICS")) { - DEH_WriteUndoline(word, va("%u", gameovertics), UNDO_NONE); gameovertics = get_number(word2); } else if (fastcmp(word, "INTROTOPLAY")) { - DEH_WriteUndoline(word, va("%d", introtoplay), UNDO_NONE); introtoplay = (UINT8)get_number(word2); // range check, you morons. if (introtoplay > 128) @@ -2628,17 +2524,14 @@ static void readmaincfg(MYFILE *f) } else if (fastcmp(word, "LOOPTITLE")) { - DEH_WriteUndoline(word, va("%d", looptitle), UNDO_NONE); looptitle = (value || word2[0] == 'T' || word2[0] == 'Y'); } else if (fastcmp(word, "TITLESCROLLSPEED")) { - DEH_WriteUndoline(word, va("%d", titlescrollspeed), UNDO_NONE); titlescrollspeed = get_number(word2); } else if (fastcmp(word, "CREDITSCUTSCENE")) { - DEH_WriteUndoline(word, va("%d", creditscutscene), UNDO_NONE); creditscutscene = (UINT8)get_number(word2); // range check, you morons. if (creditscutscene > 128) @@ -2646,27 +2539,22 @@ static void readmaincfg(MYFILE *f) } else if (fastcmp(word, "NUMDEMOS")) { - DEH_WriteUndoline(word, va("%d", numDemos), UNDO_NONE); numDemos = (UINT8)get_number(word2); } else if (fastcmp(word, "DEMODELAYTIME")) { - DEH_WriteUndoline(word, va("%d", demoDelayTime), UNDO_NONE); demoDelayTime = get_number(word2); } else if (fastcmp(word, "DEMOIDLETIME")) { - DEH_WriteUndoline(word, va("%d", demoIdleTime), UNDO_NONE); demoIdleTime = get_number(word2); } else if (fastcmp(word, "USE1UPSOUND")) { - DEH_WriteUndoline(word, va("%u", use1upSound), UNDO_NONE); use1upSound = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y'); } else if (fastcmp(word, "MAXXTRALIFE")) { - DEH_WriteUndoline(word, va("%u", maxXtraLife), UNDO_NONE); maxXtraLife = (UINT8)get_number(word2); } @@ -2680,7 +2568,6 @@ static void readmaincfg(MYFILE *f) I_Error("Maincfg: bad data file name '%s'\n", word2); G_SaveGameData(false); - DEH_WriteUndoline(word, gamedatafilename, UNDO_NONE); strlcpy(gamedatafilename, word2, sizeof (gamedatafilename)); strlwr(gamedatafilename); savemoddata = true; @@ -2701,12 +2588,10 @@ static void readmaincfg(MYFILE *f) } else if (fastcmp(word, "RESETDATA")) { - DEH_WriteUndoline(word, "0", UNDO_TODO); /// \todo P_ResetData(value); } else if (fastcmp(word, "CUSTOMVERSION")) { - DEH_WriteUndoline(word, customversionstring, UNDO_NONE); strlcpy(customversionstring, word2, sizeof (customversionstring)); } else @@ -2966,13 +2851,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { G_SetGameModified(multiplayer, true); readmaincfg(f); - DEH_WriteUndoline(word, "", UNDO_HEADER); continue; } else if (fastcmp(word, "WIPES")) { readwipes(f); - DEH_WriteUndoline(word, "", UNDO_HEADER); // This is not a major mod. continue; } @@ -2993,7 +2876,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Character %d out of range (0 - 31)", i); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); // This is not a major mod. continue; } @@ -3007,7 +2889,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { // Read patch from spec file. readpatch(f, word2, wad); - DEH_WriteUndoline(word, word2, UNDO_HEADER); // This is not a major mod. } else if (fastcmp(word, "THING") || fastcmp(word, "MOBJ") || fastcmp(word, "OBJECT")) @@ -3025,13 +2906,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Thing %d out of range (0 - %d)", i, NUMMOBJTYPES-1); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); } -/* else if (fastcmp(word, "ANIMTEX")) - { - readAnimTex(f, i); - // This is not a major mod. - }*/ else if (fastcmp(word, "LEVEL")) { // Support using the actual map name, @@ -3052,7 +2927,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Level number %d out of range (1 - %d)", i, NUMMAPS); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); } else if (fastcmp(word, "CUTSCENE")) { @@ -3063,8 +2937,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Cutscene number %d out of range (1 - 128)", i); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); - //G_SetGameModified(multiplayer, true); -- might have to reconsider in a future update } else if (fastcmp(word, "FRAME") || fastcmp(word, "STATE")) { @@ -3081,7 +2953,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Frame %d out of range (0 - %d)", i, NUMSTATES-1); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); } else if (fastcmp(word, "SOUND")) { @@ -3094,7 +2965,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Sound %d out of range (0 - %d)", i, NUMSFX-1); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); // This is not a major mod. } else if (fastcmp(word, "HUDITEM")) @@ -3108,7 +2978,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("HUD item number %d out of range (0 - %d)", i, NUMHUDITEMS-1); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); // This is not a major mod. } else if (fastcmp(word, "EMBLEM")) @@ -3129,7 +2998,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Emblem number %d out of range (1 - %d)", i, MAXEMBLEMS); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); } else if (fastcmp(word, "EXTRAEMBLEM")) { @@ -3149,7 +3017,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Extra emblem number %d out of range (1 - %d)", i, MAXEXTRAEMBLEMS); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); } else if (fastcmp(word, "UNLOCKABLE")) { @@ -3165,7 +3032,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Unlockable number %d out of range (1 - %d)", i, MAXUNLOCKABLES); ignorelines(f); } - DEH_WriteUndoline(word, word2, UNDO_HEADER); } else if (fastcmp(word, "CONDITIONSET")) { @@ -3181,15 +3047,12 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("Condition set number %d out of range (1 - %d)", i, MAXCONDITIONSETS); ignorelines(f); } - // no undo support for this insanity yet - //DEH_WriteUndoline(word, word2, UNDO_HEADER); } else if (fastcmp(word, "SRB2KART")) { INT32 ver = searchvalue(strtok(NULL, "\n")); if (ver != PATCHVERSION) deh_warning("Patch is for SRB2Kart version %d,\nonly version %d is supported", ver, PATCHVERSION); - //DEH_WriteUndoline(word, va("%d", ver), UNDO_NONE); } else if (fastcmp(word, "SRB2")) { @@ -3268,7 +3131,6 @@ void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump) f.curpos = f.data; f.data[f.size] = 0; DEH_LoadDehackedFile(&f, wad); - DEH_WriteUndoline(va("# uload for wad: %u, lump: %u", wad, lump), NULL, UNDO_DONE); Z_Free(f.data); } diff --git a/src/dehacked.h b/src/dehacked.h index 33621a3ac..677b40cef 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -27,8 +27,6 @@ typedef enum UNDO_DONE = 0, } undotype_f; -#define DEH_WriteUndoline(a,b,c) - void DEH_LoadDehackedLump(lumpnum_t lumpnum); void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump); diff --git a/src/p_setup.c b/src/p_setup.c index cb8cd5af1..6888966df 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -286,83 +286,47 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg) static void P_ClearSingleMapHeaderInfo(INT16 i) { const INT16 num = (INT16)(i-1); - DEH_WriteUndoline("LEVELNAME", mapheaderinfo[num]->lvlttl, UNDO_NONE); mapheaderinfo[num]->lvlttl[0] = '\0'; - DEH_WriteUndoline("SUBTITLE", mapheaderinfo[num]->subttl, UNDO_NONE); mapheaderinfo[num]->subttl[0] = '\0'; - DEH_WriteUndoline("ZONETITLE", mapheaderinfo[num]->zonttl, UNDO_NONE); // SRB2kart mapheaderinfo[num]->zonttl[0] = '\0'; - DEH_WriteUndoline("ACT", mapheaderinfo[num]->actnum, UNDO_NONE); // SRB2kart mapheaderinfo[num]->actnum[0] = '\0'; - DEH_WriteUndoline("TYPEOFLEVEL", va("%d", mapheaderinfo[num]->typeoflevel), UNDO_NONE); mapheaderinfo[num]->typeoflevel = 0; - DEH_WriteUndoline("NEXTLEVEL", va("%d", mapheaderinfo[num]->nextlevel), UNDO_NONE); mapheaderinfo[num]->nextlevel = (INT16)(i + 1); - DEH_WriteUndoline("MUSIC", mapheaderinfo[num]->musname, UNDO_NONE); snprintf(mapheaderinfo[num]->musname, 7, "%sM", G_BuildMapName(i)); mapheaderinfo[num]->musname[6] = 0; - DEH_WriteUndoline("MUSICTRACK", va("%d", mapheaderinfo[num]->mustrack), UNDO_NONE); mapheaderinfo[num]->mustrack = 0; - DEH_WriteUndoline("MUSICPOS", va("%d", mapheaderinfo[num]->muspos), UNDO_NONE); mapheaderinfo[num]->muspos = 0; - DEH_WriteUndoline("MUSICINTERFADEOUT", va("%d", mapheaderinfo[num]->musinterfadeout), UNDO_NONE); mapheaderinfo[num]->musinterfadeout = 0; - DEH_WriteUndoline("MUSICINTER", mapheaderinfo[num]->musintername, UNDO_NONE); mapheaderinfo[num]->musintername[0] = '\0'; - DEH_WriteUndoline("FORCECHARACTER", va("%d", mapheaderinfo[num]->forcecharacter), UNDO_NONE); mapheaderinfo[num]->forcecharacter[0] = '\0'; - DEH_WriteUndoline("WEATHER", va("%d", mapheaderinfo[num]->weather), UNDO_NONE); mapheaderinfo[num]->weather = 0; - DEH_WriteUndoline("SKYNUM", va("%d", mapheaderinfo[num]->skynum), UNDO_NONE); mapheaderinfo[num]->skynum = 1; - DEH_WriteUndoline("SKYBOXSCALEX", va("%d", mapheaderinfo[num]->skybox_scalex), UNDO_NONE); mapheaderinfo[num]->skybox_scalex = 16; - DEH_WriteUndoline("SKYBOXSCALEY", va("%d", mapheaderinfo[num]->skybox_scaley), UNDO_NONE); mapheaderinfo[num]->skybox_scaley = 16; - DEH_WriteUndoline("SKYBOXSCALEZ", va("%d", mapheaderinfo[num]->skybox_scalez), UNDO_NONE); mapheaderinfo[num]->skybox_scalez = 16; - DEH_WriteUndoline("INTERSCREEN", mapheaderinfo[num]->interscreen, UNDO_NONE); mapheaderinfo[num]->interscreen[0] = '#'; - DEH_WriteUndoline("RUNSOC", mapheaderinfo[num]->runsoc, UNDO_NONE); mapheaderinfo[num]->runsoc[0] = '#'; - DEH_WriteUndoline("SCRIPTNAME", mapheaderinfo[num]->scriptname, UNDO_NONE); mapheaderinfo[num]->scriptname[0] = '#'; - DEH_WriteUndoline("PRECUTSCENENUM", va("%d", mapheaderinfo[num]->precutscenenum), UNDO_NONE); mapheaderinfo[num]->precutscenenum = 0; - DEH_WriteUndoline("CUTSCENENUM", va("%d", mapheaderinfo[num]->cutscenenum), UNDO_NONE); mapheaderinfo[num]->cutscenenum = 0; - DEH_WriteUndoline("COUNTDOWN", va("%d", mapheaderinfo[num]->countdown), UNDO_NONE); mapheaderinfo[num]->countdown = 0; - DEH_WriteUndoline("PALLETE", va("%u", mapheaderinfo[num]->palette), UNDO_NONE); mapheaderinfo[num]->palette = UINT16_MAX; - DEH_WriteUndoline("ENCOREPAL", va("%u", mapheaderinfo[num]->encorepal), UNDO_NONE); mapheaderinfo[num]->encorepal = UINT16_MAX; - DEH_WriteUndoline("NUMLAPS", va("%u", mapheaderinfo[num]->numlaps), UNDO_NONE); mapheaderinfo[num]->numlaps = NUMLAPS_DEFAULT; - DEH_WriteUndoline("UNLOCKABLE", va("%s", mapheaderinfo[num]->unlockrequired), UNDO_NONE); mapheaderinfo[num]->unlockrequired = -1; - DEH_WriteUndoline("LEVELSELECT", va("%d", mapheaderinfo[num]->levelselect), UNDO_NONE); mapheaderinfo[num]->levelselect = 0; - DEH_WriteUndoline("BONUSTYPE", va("%d", mapheaderinfo[num]->bonustype), UNDO_NONE); mapheaderinfo[num]->bonustype = 0; - DEH_WriteUndoline("SAVEOVERRIDE", va("%d", mapheaderinfo[num]->saveoverride), UNDO_NONE); mapheaderinfo[num]->saveoverride = SAVE_DEFAULT; - DEH_WriteUndoline("LEVELFLAGS", va("%d", mapheaderinfo[num]->levelflags), UNDO_NONE); mapheaderinfo[num]->levelflags = 0; - DEH_WriteUndoline("MENUFLAGS", va("%d", mapheaderinfo[num]->menuflags), UNDO_NONE); mapheaderinfo[num]->menuflags = (mainwads ? 0 : LF2_EXISTSHACK); // see p_setup.c - prevents replacing maps in addons with easier versions // TODO grades support for delfile (pfft yeah right) P_DeleteGrades(num); // SRB2Kart - //DEH_WriteUndoline("AUTOMAP", va("%d", mapheaderinfo[num]->automap), UNDO_NONE); //mapheaderinfo[num]->automap = false; - DEH_WriteUndoline("MOBJSCALE", va("%d", mapheaderinfo[num]->mobj_scale), UNDO_NONE); mapheaderinfo[num]->mobj_scale = FRACUNIT; // an even further impossibility, delfile custom opts support mapheaderinfo[num]->customopts = NULL; mapheaderinfo[num]->numCustomOptions = 0; - - DEH_WriteUndoline(va("# uload for map %d", i), NULL, UNDO_DONE); } /** Allocates a new map-header structure. -- 2.54.0 From d628320c8d96c5a2e28fcc5e77189f6a26aa260f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 12 Sep 2024 01:04:33 +0200 Subject: [PATCH 500/525] forgor this --- src/dehacked.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/dehacked.h b/src/dehacked.h index 677b40cef..0d3778b28 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -15,18 +15,6 @@ #include "m_fixed.h" // for get_number -typedef enum -{ - UNDO_NONE = 0x00, - UNDO_NEWLINE = 0x01, - UNDO_SPACE = 0x02, - UNDO_CUTLINE = 0x04, - UNDO_HEADER = 0x07, - UNDO_ENDTEXT = 0x08, - UNDO_TODO = 0, - UNDO_DONE = 0, -} undotype_f; - void DEH_LoadDehackedLump(lumpnum_t lumpnum); void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump); -- 2.54.0 From 26f3806b3c7243cd80394440b599fec6058b9ea5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 12 Sep 2024 22:43:06 +0200 Subject: [PATCH 501/525] =?UTF-8?q?fix=20w=C3=B6ter=20shader=20interpolati?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit accidentally reverted that when redoing palette rendering --- src/hardware/r_opengl/r_opengl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 96a608df6..abfbfdd25 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -852,7 +852,7 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) switch (info) { case HWD_SHADERINFO_LEVELTIME: - shader_leveltime = value; + shader_leveltime = (((float)(value-1)) + FIXED_TO_FLOAT(rendertimefrac)) / TICRATE; break; default: break; @@ -1849,7 +1849,7 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF UNIFORM_1(shader->uniforms[gluniform_fade_end], (GLfloat)Surface->LightInfo.fade_end, pglUniform1f); } - UNIFORM_1(shader->uniforms[gluniform_leveltime], ((float)shader_leveltime) / TICRATE, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_leveltime], shader_leveltime, pglUniform1f); UNIFORM_2(shader->uniforms[gluniform_scr_resolution], vid.width, vid.height, pglUniform2f); -- 2.54.0 From 0926f6877624c118f784daba89396b2178fcafbd Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 00:16:28 +0200 Subject: [PATCH 502/525] clean up sprite stuff --- src/hardware/hw_main.c | 90 +++--------------------------- src/r_bsp.c | 6 +- src/r_main.c | 2 +- src/r_main.h | 2 + src/r_things.c | 122 +++++++++++++---------------------------- src/r_things.h | 3 + 6 files changed, 55 insertions(+), 170 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 77dc56511..a0e91df34 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4557,10 +4557,7 @@ void HWR_DrawSprites(void) void HWR_AddSprites(sector_t *sec) { mobj_t *thing; - fixed_t approx_dist, limit_dist; - - INT32 splitflags; - boolean split_drawsprite; // drawing with splitscreen flags + fixed_t limit_dist; // BSP is traversed by subsector. // A sector might have been split into several @@ -4584,88 +4581,15 @@ void HWR_AddSprites(sector_t *sec) limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; // Handle all things in sector. - // If a limit exists, handle things a tiny bit different. - if (limit_dist == 0) + for (thing = sec->thinglist; thing; thing = thing->snext) { - // Draw everything in sector, no checks - for (thing = sec->thinglist; thing; thing = thing->snext) - { - split_drawsprite = false; + if (!R_ThingWithinDist(thing, limit_dist)) + continue; - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) - continue; + if (!R_ThingVisible(thing)) + continue; - splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); - - if (splitscreen && splitflags) - { - if (thing->eflags & MFE_DRAWONLYFORP1) - if (viewssnum == 0) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP2) - if (viewssnum == 1) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) - if (viewssnum == 2) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) - if (viewssnum == 3) - split_drawsprite = true; - } - else - split_drawsprite = true; - - if (!split_drawsprite) - continue; - - HWR_ProjectSprite(thing); - } - } - else - { - for (thing = sec->thinglist; thing; thing = thing->snext) - { - split_drawsprite = false; - - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) - continue; - - splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); - - if (splitscreen && splitflags) - { - if (thing->eflags & MFE_DRAWONLYFORP1) - if (viewssnum == 0) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP2) - if (viewssnum == 1) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) - if (viewssnum == 2) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) - if (viewssnum == 3) - split_drawsprite = true; - } - else - split_drawsprite = true; - - if (!split_drawsprite) - continue; - - approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - - if (approx_dist > limit_dist) - continue; - - HWR_ProjectSprite(thing); - } + HWR_ProjectSprite(thing); } } diff --git a/src/r_bsp.c b/src/r_bsp.c index 58573eb99..3a68c648e 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -259,7 +259,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, else if (sec->heightsec != -1) { const sector_t *s = §ors[sec->heightsec]; - mobj_t *viewmobj = viewplayer->mo; + mobj_t *pviewmobj = viewplayer->mo; INT32 heightsec; boolean underwater; UINT8 i; @@ -273,8 +273,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, break; } - if (i > splitscreen && viewmobj) - heightsec = R_PointInSubsector(viewmobj->x, viewmobj->y)->sector->heightsec; + if (i > splitscreen && pviewmobj) + heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec; else return sec; diff --git a/src/r_main.c b/src/r_main.c index 629358d50..0e0e7020e 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1173,7 +1173,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) // R_SetupFrame // -static mobj_t *viewmobj; +mobj_t *viewmobj; void R_SkyboxFrame(player_t *player) { diff --git a/src/r_main.h b/src/r_main.h index 490f793f9..dbf1a141b 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -38,6 +38,8 @@ extern fixed_t renderdeltatics; // The current render is a new logical tic extern boolean renderisnewtic; +extern mobj_t *viewmobj; + // // Lighting LUT. // Used for z-depth cuing per column/row, diff --git a/src/r_things.c b/src/r_things.c index 100ca87de..b2364deae 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -20,6 +20,7 @@ #include "z_zone.h" #include "m_misc.h" #include "i_video.h" // rendermode +#include "r_main.h" // stplyr #include "r_fps.h" #include "r_things.h" #include "r_patch.h" @@ -1930,10 +1931,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) { mobj_t *thing; INT32 lightnum; - fixed_t approx_dist, limit_dist; - - INT32 splitflags; // check if a mobj has spliscreen flags - boolean split_drawsprite; // used for splitscreen flags + fixed_t limit_dist; if (rendermode != render_soft) return; @@ -1964,88 +1962,16 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - if ((limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale)) + limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; + for (thing = sec->thinglist; thing; thing = thing->snext) { - for (thing = sec->thinglist; thing; thing = thing->snext) - { - split_drawsprite = false; + if (!R_ThingWithinDist(thing, limit_dist)) + continue; - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) - continue; + if (!R_ThingVisible(thing)) + continue; - splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); - - if (splitscreen && splitflags) - { - if (thing->eflags & MFE_DRAWONLYFORP1) - if (viewssnum == 0) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP2) - if (viewssnum == 1) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) - if (viewssnum == 2) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) - if (viewssnum == 3) - split_drawsprite = true; - } - else - split_drawsprite = true; - - if (!split_drawsprite) - continue; - - approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - - if (approx_dist > limit_dist) - continue; - - R_ProjectSprite(thing); - } - } - else - { - // Draw everything in sector, no checks - for (thing = sec->thinglist; thing; thing = thing->snext) - { - - split_drawsprite = false; - - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) - continue; - - splitflags = thing->eflags & (MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); - - if (splitscreen && splitflags) - { - if (thing->eflags & MFE_DRAWONLYFORP1) - if (viewssnum == 0) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP2) - if (viewssnum == 1) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) - if (viewssnum == 2) - split_drawsprite = true; - - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) - if (viewssnum == 3) - split_drawsprite = true; - } - else - split_drawsprite = true; - - if (!split_drawsprite) - continue; - - R_ProjectSprite(thing); - } + R_ProjectSprite(thing); } } @@ -2849,6 +2775,36 @@ void R_ClipSprites(void) } } +/* Check if thing may be drawn from our current view. */ +boolean R_ThingVisible (mobj_t *thing) +{ + if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) + return false; + + if (viewmobj && (thing == viewmobj)) + return false; + + if ((viewssnum == 0 && (thing->renderflags & MFE_DRAWONLYFORP1)) + || (viewssnum == 1 && (thing->renderflags & MFE_DRAWONLYFORP2)) + || (viewssnum == 2 && (thing->renderflags & MFE_DRAWONLYFORP2)) + || (viewssnum == 3 && (thing->renderflags & MFE_DRAWONLYFORP4))) + return true; + + return true; +} + +boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist) +{ + const fixed_t dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); + + if (limit_dist && dist > limit_dist) + { + return false; + } + + return true; +} + // // R_DrawMasked // diff --git a/src/r_things.h b/src/r_things.h index 3e2414da1..0e99c490c 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -72,6 +72,9 @@ void R_InitSprites(void); void R_ClearSprites(void); void R_DrawMasked(void); +boolean R_ThingVisible (mobj_t *thing); +boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist); + // ----------- // SKINS STUFF // ----------- -- 2.54.0 From 924d79c20da2af1647ea8777c425e5c89bf6af87 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 00:22:57 +0200 Subject: [PATCH 503/525] only need to check all this when in splitscreen retains vanilla behaviour --- src/r_things.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index b2364deae..5b204a354 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2784,11 +2784,14 @@ boolean R_ThingVisible (mobj_t *thing) if (viewmobj && (thing == viewmobj)) return false; - if ((viewssnum == 0 && (thing->renderflags & MFE_DRAWONLYFORP1)) - || (viewssnum == 1 && (thing->renderflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 2 && (thing->renderflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 3 && (thing->renderflags & MFE_DRAWONLYFORP4))) - return true; + if (splitscreen) + { + if ((viewssnum == 0 && (thing->renderflags & MFE_DRAWONLYFORP1)) + || (viewssnum == 1 && (thing->renderflags & MFE_DRAWONLYFORP2)) + || (viewssnum == 2 && (thing->renderflags & MFE_DRAWONLYFORP2)) + || (viewssnum == 3 && (thing->renderflags & MFE_DRAWONLYFORP4))) + return true; + } return true; } @@ -3148,21 +3151,6 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) player->kartspeed = skin->kartspeed; player->kartweight = skin->kartweight; - /*if (!(cv_debug || devparm) && !(netgame || multiplayer || demo.playback || modeattacking)) - { - if (playernum == consoleplayer) - CV_StealthSetValue(&cv_playercolor, skin->prefcolor); - else if (playernum == displayplayers[1]) - CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); - else if (playernum == displayplayers[2]) - CV_StealthSetValue(&cv_playercolor3, skin->prefcolor); - else if (playernum == displayplayers[3]) - CV_StealthSetValue(&cv_playercolor4, skin->prefcolor); - player->skincolor = skin->prefcolor; - if (player->mo) - player->mo->color = player->skincolor; - }*/ - if (player->mo) P_SetScale(player->mo, player->mo->scale); -- 2.54.0 From 3714735c2af72ca946d676cb3b38d9cfa6e9101c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 12:17:21 +0200 Subject: [PATCH 504/525] small cleanup intermission drawer --- src/d_main.c | 1 - src/y_inter.c | 93 ++++++--------------------------------------------- 2 files changed, 10 insertions(+), 84 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index c42d2e550..aeee75c2e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -535,7 +535,6 @@ static boolean D_Display(void) if (rendermode == render_soft) { VID_BlitLinearScreen(screens[0], screens[1], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); - usebuffer = true; } lastdraw = false; } diff --git a/src/y_inter.c b/src/y_inter.c index 5d292f36c..9e6f66cef 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -100,10 +100,6 @@ static y_data data; static patch_t *bgpatch = NULL; // INTERSCR static patch_t *widebgpatch = NULL; // INTERSCW static patch_t *bgtile = NULL; // SPECTILE/SRB2BACK -//static patch_t *interpic = NULL; // custom picture defined in map header -//static boolean usetile; -boolean usebuffer = false; -//static boolean useinterpic; static INT32 timer; static INT32 intertic; @@ -389,41 +385,24 @@ void Y_IntermissionDrawer(void) if (intertype == int_none || rendermode == render_none) return; - if (!usebuffer) - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - if (cv_betainterscreen.value #ifdef HWRENDER || (rendermode == render_opengl && cv_grscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures #endif ) V_DrawPatchFill(bgtile); // use the neato kart bg for intermission on disabled screen textures - //else if (useinterpic) - //V_DrawScaledPatch(0, 0, 0, interpic); - //else if (!usetile) else { - if (rendermode == render_soft && usebuffer) + if (rendermode == render_soft) VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); #ifdef HWRENDER - else if(rendermode != render_soft && usebuffer) - { + else if(rendermode == render_opengl) HWR_DrawIntermissionBG(); - } #endif - else - { - if (widebgpatch && rendermode == render_soft && vid.width / vid.dupx == 400) - V_DrawScaledPatch(0, 0, V_SNAPTOLEFT, widebgpatch); - else if (bgpatch) - V_DrawScaledPatch(0, 0, 0, bgpatch); - } } - //else if (bgtile) - //V_DrawPatchFill(bgtile); - if (usebuffer) // Fade everything out - V_DrawFadeScreen(0xFF00, 22); + // Fade everything out + V_DrawFadeScreen(0xFF00, 22); if (!splitscreen) whiteplayer = demo.playback ? displayplayers[0] : consoleplayer; @@ -437,6 +416,7 @@ void Y_IntermissionDrawer(void) if (sorttic != -1 && intertic >= sorttic && !demo.playback) { + // yes this may actually overflow INT64 count = (intertic - sorttic); if (count < 8) @@ -445,48 +425,7 @@ void Y_IntermissionDrawer(void) x += (((((16 - count)<>FRACBITS) / (8 * vid.dupx); } - // SRB2kart 290117 - compeltely replaced this block. - /*if (intertype == int_timeattack) - { - // draw time - ST_DrawPatchFromHud(HUD_TIME, sbotime); - if (cv_timetic.value) - ST_DrawNumFromHud(HUD_SECONDS, data.coop.tics); - else - { - INT32 seconds, minutes, tictrn; - - seconds = G_TicsToSeconds(data.coop.tics); - minutes = G_TicsToMinutes(data.coop.tics, true); - tictrn = G_TicsToCentiseconds(data.coop.tics); - - ST_DrawNumFromHud(HUD_MINUTES, minutes); // Minutes - ST_DrawPatchFromHud(HUD_TIMECOLON, sbocolon); // Colon - ST_DrawPadNumFromHud(HUD_SECONDS, seconds, 2); // Seconds - - // SRB2kart - pulled from old coop block, just in case we need it - // we should show centiseconds on the intermission screen too, if the conditions are right. - if (modeattacking || cv_timetic.value == 2) - { - ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod); // Period - ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2); // Tics - } - - ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod); // Period - ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2); // Tics - } - - // draw the "got through act" lines and act number - V_DrawLevelTitle(data.coop.passedx1, 49, 0, data.coop.passed1); - V_DrawLevelTitle(data.coop.passedx2, 49+V_LevelNameHeight(data.coop.passed2)+2, 0, data.coop.passed2); - - if (strlen(mapheaderinfo[prevmap]->actnum) > 0) - V_DrawScaledPatch(244, 57, 0, data.coop.ttlnum); - - //if (gottimebonus && endtic != -1) - // V_DrawCenteredString(BASEVIDWIDTH/2, 172, V_YELLOWMAP, "TIME BONUS UNLOCKED!"); - } - else*/ if (intertype == int_race || intertype == int_match) + if (intertype == int_race || intertype == int_match) { #define NUMFORNEWCOLUMN 8 INT32 y = 41, gutter = ((data.match.numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); @@ -651,6 +590,7 @@ void Y_IntermissionDrawer(void) } if ((demo.recording || demo.savemode == DSM_SAVED) && !demo.playback) + { switch (demo.savemode) { case DSM_NOTSAVING: @@ -668,10 +608,7 @@ void Y_IntermissionDrawer(void) default: // Don't render any text here break; } - - // Make it obvious that scrambling is happening next round. - if (cv_scrambleonchange.value && cv_teamscramble.value && (intertic/TICRATE % 2 == 0)) - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, hilicol, M_GetText("Teams will be scrambled next round!")); + } if (renderisnewtic) { @@ -898,14 +835,10 @@ void Y_StartIntermission(void) if (gametype == GT_MATCH) intertype = int_match; - else //if (gametype == GT_RACE) + else intertype = int_race; } - // We couldn't display the intermission even if we wanted to. - // But we still need to give the players their score bonuses, dummy. - //if (dedicated) return; - // This should always exist, but just in case... if(!mapheaderinfo[prevmap]) P_AllocMapHeader(prevmap); @@ -942,12 +875,7 @@ void Y_StartIntermission(void) break; } - //if (intertype == int_race || intertype == int_match) - { - bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); - //usetile = useinterpic = false; - usebuffer = true; - } + bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); LUA_HUD_DestroyDrawList(luahuddrawlist_intermission); luahuddrawlist_intermission = LUA_HUD_CreateDrawList(); @@ -965,7 +893,6 @@ void Y_EndIntermission(void) endtic = -1; sorttic = -1; intertype = int_none; - usebuffer = false; } // -- 2.54.0 From c98b896fc8cfc3efd875b00733f9a93b386b7f79 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 12:27:57 +0200 Subject: [PATCH 505/525] add old line whatever in intermission add beta intermission visual to menu --- src/d_netcmd.c | 3 ++- src/m_menu.c | 12 ++++++++---- src/y_inter.c | 5 +++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 121feb96a..1f8c8e5f1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -585,7 +585,8 @@ static CV_PossibleValue_t skinselectgridsort_t[] ={ }; consvar_t cv_skinselectgridsort ={ "skinselectgridsort", "Real name", CV_SAVE|CV_CALL|CV_NOINIT, skinselectgridsort_t, sortSkinGrid, 0, NULL, NULL, 0, 0, NULL }; -consvar_t cv_betainterscreen = {"betaintermissionscreen", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t betainterscreen_t[] = {{0, "Off"}, {1, "On"}, {2, "NoBG"}, {0, NULL}}; +consvar_t cv_betainterscreen = {"betaintermissionscreen", "Off", CV_SAVE, betainterscreen_t, NULL, 0, NULL, NULL, 0, 0, NULL}; INT16 gametype = GT_RACE; // SRB2kart boolean forceresetplayers = false; diff --git a/src/m_menu.c b/src/m_menu.c index 6bb6c561c..ceee00ed7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2245,12 +2245,14 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 80}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 90}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 100}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 105}, + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 100}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 115}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 110}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 115}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 125}, }; static const char* OP_SaturnHudTooltips[] = @@ -2270,6 +2272,7 @@ static const char* OP_SaturnHudTooltips[] = "Show player names on the minimap.", "Minimize the player icons on the minimap.", "Show the Director Toggle prompt when spectating.", + "Make the Intermission screen look like in beta versions of Kart!\nEither with background or just the rest.", "Uncaps the HUD framerate, making it appear smoother.", "Nametag Options.", "Driftgauge Options.", @@ -2293,6 +2296,7 @@ enum sh_mapname, sh_smallmap, sh_directorhud, + sh_betainter, sh_uncappedhud, sh_nametagmen, sh_driftgaugemen, diff --git a/src/y_inter.c b/src/y_inter.c index 9e6f66cef..b62566e0a 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -9,6 +9,7 @@ /// \file y_inter.c /// \brief Tally screens, or "Intermissions" as they were formally called in Doom +#include "d_netcmd.h" #include "doomdef.h" #include "doomstat.h" #include "d_main.h" @@ -385,7 +386,7 @@ void Y_IntermissionDrawer(void) if (intertype == int_none || rendermode == render_none) return; - if (cv_betainterscreen.value + if (cv_betainterscreen.value == 1 #ifdef HWRENDER || (rendermode == render_opengl && cv_grscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures #endif @@ -429,7 +430,7 @@ void Y_IntermissionDrawer(void) { #define NUMFORNEWCOLUMN 8 INT32 y = 41, gutter = ((data.match.numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); - INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; + INT32 dupadjust = cv_betainterscreen.value ? 314 : (vid.width/vid.dupx), duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; const char *timeheader; if (data.match.rankingsmode) -- 2.54.0 From 4f1f1ede97b6cbca9ee8231bb04afe0b7149facd Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 12:33:49 +0200 Subject: [PATCH 506/525] smol menu visual cleanup --- src/m_menu.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ceee00ed7..4dbb3a3f0 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1381,7 +1381,7 @@ static menuitem_t OP_VideoOptionsMenu[] = #ifdef HWRENDER {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 145}, #endif - {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_ExpOptionsDef, 155}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Video Options...", &OP_ExpOptionsDef, 155}, }; @@ -1478,23 +1478,23 @@ static menuitem_t OP_ColorOptionsMenu[] = static menuitem_t OP_ExpOptionsMenu[] = { - {IT_HEADER, NULL, "Advanced Options", NULL, 10}, - {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 20}, - {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 30}, - {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 35}, - {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 40}, + {IT_HEADER, NULL, "Advanced Video Options", NULL, 10}, + {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 30}, + {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 40}, - {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 50}, + {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 60}, + {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 70}, + + {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 80}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 60}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 100}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 65}, + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 110}, #endif + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 130}, - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 75}, - - {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 85}, + {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 150}, #endif }; @@ -2227,7 +2227,7 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 20}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 25}, + {IT_STRING | IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 25}, {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 30}, @@ -2262,7 +2262,7 @@ static const char* OP_SaturnHudTooltips[] = "Draw the Speedometer in Battle.", "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", "Enable the stat display.", - "Show Lap Time when doing a Lap on the Timer.", + "Flash current Lap Time when doing a Lap on the Timer.", "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Enable colourized hud.", "Enable the colourized itembox when colourized hud is enabled.", @@ -2372,7 +2372,7 @@ static menuitem_t OP_SaturnCreditsMenu[] = {IT_STRING2+IT_SPACE, NULL, "Galactice for Galaxy", NULL, 180}, {IT_STRING+IT_SPACE, NULL, "", NULL, 190}, // dummy text II - {IT_STRING, NULL, "", NULL, 200}, // dummy text III + {IT_STRING, NULL, "", NULL, 250}, // dummy text III }; static const char* OP_CreditTooltips[] = @@ -3065,7 +3065,7 @@ menu_t OP_MonitorToggleDef = menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30); #endif -menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 35); +menu_t OP_ExpOptionsDef = DEFAULTMENUSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 30); menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30); menu_t OP_ScreenshotOptionsDef = DEFAULTMENUSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30); -- 2.54.0 From d5dc52d3d3685da1e623d0aa4e88ffaab692006a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 12:44:29 +0200 Subject: [PATCH 507/525] super smol optimization R_ThingWithinDist no need to run fixedhypot on every sprite when you dont use draw distance limit --- src/hardware/hw_main.c | 2 +- src/r_things.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a0e91df34..ba11cd7c4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4561,7 +4561,7 @@ void HWR_AddSprites(sector_t *sec) // BSP is traversed by subsector. // A sector might have been split into several - // subsectors during BSP building. + // subsectors during BSP building. // Thus we check whether its already added. if (sec->validcount == validcount) return; diff --git a/src/r_things.c b/src/r_things.c index 5b204a354..85fe49f63 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1931,14 +1931,13 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) { mobj_t *thing; INT32 lightnum; - fixed_t limit_dist; if (rendermode != render_soft) return; // BSP is traversed by subsector. // A sector might have been split into several - // subsectors during BSP building. + // subsectors during BSP building. // Thus we check whether its already added. if (sec->validcount == validcount) return; @@ -1962,7 +1961,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; + const fixed_t limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; for (thing = sec->thinglist; thing; thing = thing->snext) { if (!R_ThingWithinDist(thing, limit_dist)) @@ -2798,11 +2797,13 @@ boolean R_ThingVisible (mobj_t *thing) boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist) { - const fixed_t dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - - if (limit_dist && dist > limit_dist) + if (limit_dist) { - return false; + const fixed_t dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); + if (dist > limit_dist) + { + return false; + } } return true; -- 2.54.0 From c49aae8d497705243a0cfd04744da08324ba81d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 13:20:49 +0200 Subject: [PATCH 508/525] no need to save saturnjoin value + smol cleanup --- src/d_clisrv.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8c10bcf55..6b569af04 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4071,7 +4071,7 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; #ifdef SATURNJOIN -consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE|CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif #ifdef VANILLAJOINNEXTROUND @@ -4124,10 +4124,7 @@ static void Joinable_OnChange(void) #ifdef SATURNJOIN // disabling joins should also disable saturn joins unless its called with CV_StealthSet and vice versa to make life a bit easier - if (!cv_allownewplayer.value) - CV_Set(&cv_allownewsaturnplayer, "Off"); - else if (cv_allownewplayer.value) - CV_Set(&cv_allownewsaturnplayer, "On"); + CV_SetValue(&cv_allownewsaturnplayer, cv_allownewplayer.value); #endif maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); -- 2.54.0 From 1a16012a5c7547875b530b8e5c0ee6f90270e7e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 13:22:43 +0200 Subject: [PATCH 509/525] this used to be const --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6b569af04..abe821494 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1758,7 +1758,7 @@ static boolean SV_SendServerConfig(INT32 node) CV_SavePlayerNames(&p); CV_SaveNetVars(&p, false); - size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); + const size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); #ifdef DEBUGFILE if (debugfile) -- 2.54.0 From dd39a444f25d9bcc6783d12bdad291298d2c2241 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 13:30:23 +0200 Subject: [PATCH 510/525] add smol comment --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index abe821494..b6eb9930b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1993,6 +1993,7 @@ static void CL_ReloadReceivedSavegame(void) neededtic = gametic; maketic = neededtic; + // set camera angle to somewhat match where your player is turning for (i = 0; i <= splitscreen; i++) { localangle[i] = players[displayplayers[i]].cmd.angleturn<<16; -- 2.54.0 From 76bc184f6c249afb3fbd88b1cd82e0d57a65ce8e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 13:35:10 +0200 Subject: [PATCH 511/525] whoops wrong tooltip --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 4dbb3a3f0..b5bc6aafb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2261,8 +2261,8 @@ static const char* OP_SaturnHudTooltips[] = "Change what style the speedometer is.", "Draw the Speedometer in Battle.", "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", - "Enable the stat display.", "Flash current Lap Time when doing a Lap on the Timer.", + "Enable the stat display.", "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Enable colourized hud.", "Enable the colourized itembox when colourized hud is enabled.", -- 2.54.0 From 65006c11d384c2e14e74ce65871b582a194acf33 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 13:37:04 +0200 Subject: [PATCH 512/525] move credits a tiny bit --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index b5bc6aafb..e2d837bfe 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2141,7 +2141,7 @@ static menuitem_t OP_SaturnMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 65}, {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 70}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 75}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 80}, // uwu }; static const char* OP_SaturnTooltips[] = -- 2.54.0 From 5f570441189995407e49fc386c357d8dd4373fb0 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 14:02:15 +0200 Subject: [PATCH 513/525] replace tooltip crap with a macro + fix adv video options tooltips --- src/m_menu.c | 340 ++++----------------------------------------------- src/m_menu.h | 11 ++ 2 files changed, 36 insertions(+), 315 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e2d837bfe..e569cbea3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5200,185 +5200,26 @@ static void M_DrawGenericMenu(void) // dumb hack // tooltips - if (currentMenu == &OP_ControlsDef) - { - if (!(OP_ControlsTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ControlsTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_MouseOptionsDef) - { - if (!(OP_MouseTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_MouseTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_VideoOptionsDef) - { - if (!(OP_VideoTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_VideoTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_SoundOptionsDef) - { - if (!(OP_SoundTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_SoundAdvancedDef) - { - if (!(OP_SoundAdvancedTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundAdvancedTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_ChatOptionsDef) - { - if (!(OP_ChatOptionsTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ChatOptionsTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_GameOptionsDef) - { - if (!(OP_GameTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_GameTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_ServerOptionsDef) - { - if (!(OP_ServerOptionsTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ServerOptionsTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_AdvServerOptionsDef) - { - if (!(OP_AdvServerOptionsTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvServerOptionsTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_PlayerDistortDef) - { - if (!(OP_PlayerDistortTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_PlayerDistortTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_SaturnCreditsDef) // C: - { - if (!(OP_CreditTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_CreditTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_BirdDef) - { - if (!(OP_BirdTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_BirdTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_TiltDef) - { - if (!(OP_TiltTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_TiltTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_AdvancedBirdDef) - { - if (!(OP_AdvancedBirdTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvancedBirdTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_NametagDef) - { - if (!(OP_NametagTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_NametagTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_DriftGaugeDef) - { - if (!(OP_DriftGaugeTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_DriftGaugeTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_CamOptionsDef) - { - if (!(OP_CamOptionsTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_CamOptionsTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_Player1CamOptionsDef || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef || currentMenu == &OP_Player4CamOptionsDef) - { - if (!(OP_PlayerCamOptionsTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_PlayerCamOptionsTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } + // replaced with macro so it doesent look as terrible anymore lol + DoToolTips(OP_ControlsDef, OP_ControlsTooltips); + DoToolTips(OP_MouseOptionsDef, OP_MouseTooltips); + DoToolTips(OP_VideoOptionsDef, OP_VideoTooltips); + DoToolTips(OP_ExpOptionsDef, OP_ExpTooltips); + DoToolTips(OP_SoundOptionsDef, OP_SoundTooltips); + DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips); + DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); + DoToolTips(OP_GameOptionsDef, OP_GameTooltips); + DoToolTips(OP_ServerOptionsDef, OP_ServerOptionsTooltips); + DoToolTips(OP_AdvServerOptionsDef, OP_AdvServerOptionsTooltips); + DoToolTips(OP_PlayerDistortDef, OP_PlayerDistortTooltips); + DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C: + DoToolTips(OP_BirdDef, OP_BirdTooltips); + DoToolTips(OP_TiltDef, OP_TiltTooltips); + DoToolTips(OP_AdvancedBirdDef, OP_AdvancedBirdTooltips); + DoToolTips(OP_NametagDef, OP_NametagTooltips); + DoToolTips(OP_DriftGaugeDef, OP_DriftGaugeTooltips); + DoToolTips(OP_CamOptionsDef, OP_CamOptionsTooltips); + DoToolTips(OP_Player1CamOptionsDef || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef || currentMenu == &OP_Player4CamOptionsDef, OP_PlayerCamOptionsTooltips); // god this one is still terrible lmao } static void M_DrawGenericBackgroundMenu(void) @@ -5507,149 +5348,18 @@ static void M_DrawGenericScrollMenu(void) V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); -#ifdef HWRENDER // dumb hack // tooltips - if (currentMenu == &OP_OpenGLOptionsDef) - { - if (!(OP_OpenGLTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_OpenGLTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } + // same macro here +#ifdef HWRENDER + DoToolTips(OP_OpenGLOptionsDef, OP_OpenGLTooltips); #endif - - if (currentMenu == &OP_ExpOptionsDef) - { - if (!(OP_ExpTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ExpTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - - if (currentMenu == &OP_SaturnDef) - { - if (!(OP_SaturnTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SaturnTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } - - if (currentMenu == &OP_SaturnHudDef) - { - if (!(OP_SaturnHudTooltips[itemOn] == NULL)) - { - M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SaturnHudTooltips[itemOn], coolalphatimer); - if (coolalphatimer > 0 && interpTimerHackAllow) - coolalphatimer--; - } - } + DoToolTips(OP_SaturnDef, OP_SaturnTooltips); + DoToolTips(OP_SaturnHudDef, OP_SaturnHudTooltips); } static void M_DrawPauseMenu(void) { -#if 0 - if (!netgame && !multiplayer && (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)) - { - emblem_t *emblem_detail[3] = {NULL, NULL, NULL}; - char emblem_text[3][20]; - INT32 i; - - M_DrawTextBox(27, 16, 32, 6); - - // Draw any and all emblems at the top. - M_DrawMapEmblems(gamemap, 272, 28); - - if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) - { - if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) - V_DrawString(40, 28, highlightflags, va("%s %s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum)); - else - V_DrawString(40, 28, highlightflags, va("%s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl)); - } - else - { - if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) - V_DrawString(40, 28, highlightflags, va("%s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->actnum)); - else - V_DrawString(40, 28, highlightflags, mapheaderinfo[gamemap-1]->lvlttl); - } - - // Set up the detail boxes. - { - emblem_t *emblem = M_GetLevelEmblems(gamemap); - while (emblem) - { - INT32 emblemslot; - char targettext[9], currenttext[9]; - - switch (emblem->type) - { - case ET_TIME: - emblemslot = emblem->var; // dumb hack - snprintf(targettext, 9, "%i:%02i.%02i", - G_TicsToMinutes((tic_t)emblemslot, false), - G_TicsToSeconds((tic_t)emblemslot), - G_TicsToCentiseconds((tic_t)emblemslot)); - - emblemslot = (INT32)G_GetBestTime(gamemap); // dumb hack pt ii - if ((tic_t)emblemslot == UINT32_MAX) - snprintf(currenttext, 9, "-:--.--"); - else - snprintf(currenttext, 9, "%i:%02i.%02i", - G_TicsToMinutes((tic_t)emblemslot, false), - G_TicsToSeconds((tic_t)emblemslot), - G_TicsToCentiseconds((tic_t)emblemslot)); - - targettext[8] = 0; - currenttext[8] = 0; - - emblemslot = 1; - break; - default: - goto bademblem; - } - if (emblem_detail[emblemslot]) - goto bademblem; - - emblem_detail[emblemslot] = emblem; - snprintf(emblem_text[emblemslot], 20, "%8s /%8s", currenttext, targettext); - emblem_text[emblemslot][19] = 0; - - bademblem: - emblem = M_GetLevelEmblems(-1); - } - } - for (i = 0; i < 3; ++i) - { - emblem_t *emblem = emblem_detail[i]; - if (!emblem) - continue; - - if (emblem->collected) - V_DrawSmallMappedPatch(40, 44 + (i*8), 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE), - R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_MENUCACHE)); - else - V_DrawSmallScaledPatch(40, 44 + (i*8), 0, W_CachePatchName("NEEDIT", PU_CACHE)); - - switch (emblem->type) - { - case ET_TIME: - V_DrawString(56, 44 + (i*8), highlightflags, "TIME:"); - break; - } - V_DrawRightAlignedString(284, 44 + (i*8), V_MONOSPACE, emblem_text[i]); - } - } -#endif - #ifdef HAVE_DISCORDRPC // kind of hackily baked in here if (currentMenu == &MPauseDef && discordRequestList != NULL) diff --git a/src/m_menu.h b/src/m_menu.h index 570d8a94d..bd0cd0e69 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -403,4 +403,15 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na {NULL}\ } +#define DoToolTips(menu, tooltip)\ +if (currentMenu == &menu)\ +{\ + if (!(tooltip[itemOn] == NULL))\ + {\ + M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, tooltip[itemOn], coolalphatimer);\ + if (coolalphatimer > 0 && interpTimerHackAllow)\ + coolalphatimer--;\ + }\ +} + #endif //__X_MENU__ -- 2.54.0 From aeafd46f2485f986794096ed2942ceebe80a675f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 14:17:06 +0200 Subject: [PATCH 514/525] smol m_menu cleanup --- src/m_menu.c | 131 ++------------------------------------------------- 1 file changed, 3 insertions(+), 128 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e569cbea3..da0c53c3c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6544,8 +6544,9 @@ static void M_HandleAddons(INT32 choice) case EXT_KART: #endif case EXT_PK3: - if (browselocalskins) { - if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) { + if (browselocalskins) + { + if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) { M_StartMessage(va("%c%s\x80\nYou are loading a local skin.\nLocal skins will not be usable\nafter going back from\nthe title screen.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); COM_BufAddText(va("addskins \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); errorshitspam = 0; // reset it so it can show the warning screen again lmao @@ -8051,31 +8052,6 @@ static void M_DestroyRobots(INT32 choice) M_StartMessage(M_GetText("Do you want to destroy all\nrobots in the current level?\n\n(Press 'Y' to confirm)\n"),M_DestroyRobotsResponse,MM_YESNO); } -/*static void M_LevelSelectWarp(INT32 choice) -{ - boolean fromloadgame = (currentMenu == &SP_LevelSelectDef); - - (void)choice; - - if (W_CheckNumForName(G_BuildMapName(cv_nextmap.value)) == LUMPERROR) - { -// CONS_Alert(CONS_WARNING, "Internal game map '%s' not found\n", G_BuildMapName(cv_nextmap.value)); - return; - } - - startmap = (INT16)(cv_nextmap.value); - - fromlevelselect = true; - - if (fromloadgame) - G_LoadGame((UINT32)cursaveslot, startmap); - else - { - cursaveslot = -1; - M_SetupChoosePlayer(0); - } -}*/ - // ======== // SKY ROOM // ======== @@ -8418,9 +8394,6 @@ static void scrollMusicName(const char name[], size_t len, size_t maxlen, char r result[maxlen] = 0; } -//static patch_t* st_radio[9]; -//static patch_t* st_launchpad[4]; - static void M_MusicTest(INT32 choice) { (void)choice; @@ -9010,51 +8983,6 @@ void M_DrawTimeAttackMenu(void) V_DrawRightAlignedString(292, 80, highlightflags, "BEST TIME:"); K_drawKartTimestamp(time, 162, 86, cv_nextmap.value, 1); } - /*{ - char beststr[40]; - emblem_t *em; - - if (!mainrecords[cv_nextmap.value-1] || !mainrecords[cv_nextmap.value-1]->time) - sprintf(beststr, "(none)"); - else - sprintf(beststr, "%i:%02i.%02i", G_TicsToMinutes(mainrecords[cv_nextmap.value-1]->time, true), - G_TicsToSeconds(mainrecords[cv_nextmap.value-1]->time), - G_TicsToCentiseconds(mainrecords[cv_nextmap.value-1]->time)); - - V_DrawString(64, y+48, highlightflags, "BEST TIME:"); - V_DrawRightAlignedString(BASEVIDWIDTH - 64 - 24 - 8, y+48, V_ALLOWLOWERCASE, beststr); - - if (!mainrecords[cv_nextmap.value-1] || !mainrecords[cv_nextmap.value-1]->lap) - sprintf(beststr, "(none)"); - else - sprintf(beststr, "%i:%02i.%02i", G_TicsToMinutes(mainrecords[cv_nextmap.value-1]->lap, true), - G_TicsToSeconds(mainrecords[cv_nextmap.value-1]->lap), - G_TicsToCentiseconds(mainrecords[cv_nextmap.value-1]->lap)); - - V_DrawString(64, y+56, highlightflags, "BEST LAP:"); - V_DrawRightAlignedString(BASEVIDWIDTH - 64 - 24 - 8, y+56, V_ALLOWLOWERCASE, beststr); - - // Draw record emblems. - em = M_GetLevelEmblems(cv_nextmap.value); - while (em) - { - switch (em->type) - { - case ET_TIME: break; - default: - goto skipThisOne; - } - - if (em->collected) - V_DrawMappedPatch(BASEVIDWIDTH - 64 - 24, y+48, 0, W_CachePatchName(M_GetEmblemPatch(em), PU_CACHE), - R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_MENUCACHE)); - else - V_DrawScaledPatch(BASEVIDWIDTH - 64 - 24, y+48, 0, W_CachePatchName("NEEDIT", PU_CACHE)); - - skipThisOne: - em = M_GetLevelEmblems(-1); - } - }*/ // ALWAYS DRAW player name, level name, skin and color even when not on this menu! if (currentMenu != &SP_TimeAttackDef) @@ -10131,8 +10059,6 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) rubyfloattime += FixedMul(ANGLE_MAX/NEWTICRATE, renderdeltatics); } } - /*V_DrawDiag(x, y, 12, 31); - V_DrawDiag(x, y, 10, G_GetGametypeColor(cv_newgametype.value));*/ y += i/4; i = cv_nextmap.value - 1; @@ -12173,22 +12099,13 @@ static void M_Setup1PControlsMenu(INT32 choice) // Unhide P1-only controls OP_AllControlsMenu[15].status = IT_CONTROL; // Chat - //OP_AllControlsMenu[16].status = IT_CONTROL; // Team-chat OP_AllControlsMenu[16].status = IT_CONTROL; // Rankings - //OP_AllControlsMenu[17].status = IT_CONTROL; // Viewpoint // 18 is Reset Camera, 19 is Toggle Chasecam OP_AllControlsMenu[20].status = IT_CONTROL; // Pause OP_AllControlsMenu[21].status = IT_CONTROL; // Screenshot OP_AllControlsMenu[22].status = IT_CONTROL; // GIF OP_AllControlsMenu[23].status = IT_CONTROL; // System Menu OP_AllControlsMenu[24].status = IT_CONTROL; // Console - /*OP_AllControlsMenu[25].status = IT_HEADER; // Spectator Controls header - OP_AllControlsMenu[26].status = IT_SPACE; // Spectator Controls space - OP_AllControlsMenu[27].status = IT_CONTROL; // Spectate - OP_AllControlsMenu[28].status = IT_CONTROL; // Look Up - OP_AllControlsMenu[29].status = IT_CONTROL; // Look Down - OP_AllControlsMenu[30].status = IT_CONTROL; // Center View - */ M_SetupNextMenu(&OP_AllControlsDef); } @@ -12205,22 +12122,13 @@ static void M_Setup2PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat - //OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Team-chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - //OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Viewpoint // 18 is Reset Camera, 19 is Toggle Chasecam OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console - /*OP_AllControlsMenu[25].status = IT_GRAYEDOUT2; // Spectator Controls header - OP_AllControlsMenu[26].status = IT_GRAYEDOUT2; // Spectator Controls space - OP_AllControlsMenu[27].status = IT_GRAYEDOUT2; // Spectate - OP_AllControlsMenu[28].status = IT_GRAYEDOUT2; // Look Up - OP_AllControlsMenu[29].status = IT_GRAYEDOUT2; // Look Down - OP_AllControlsMenu[30].status = IT_GRAYEDOUT2; // Center View - */ M_SetupNextMenu(&OP_AllControlsDef); } @@ -12237,22 +12145,13 @@ static void M_Setup3PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat - //OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Team-chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - //OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Viewpoint // 18 is Reset Camera, 19 is Toggle Chasecam OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console - /*OP_AllControlsMenu[25].status = IT_GRAYEDOUT2; // Spectator Controls header - OP_AllControlsMenu[26].status = IT_GRAYEDOUT2; // Spectator Controls space - OP_AllControlsMenu[27].status = IT_GRAYEDOUT2; // Spectate - OP_AllControlsMenu[28].status = IT_GRAYEDOUT2; // Look Up - OP_AllControlsMenu[29].status = IT_GRAYEDOUT2; // Look Down - OP_AllControlsMenu[30].status = IT_GRAYEDOUT2; // Center View - */ M_SetupNextMenu(&OP_AllControlsDef); } @@ -12269,22 +12168,13 @@ static void M_Setup4PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat - //OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Team-chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - //OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Viewpoint // 18 is Reset Camera, 19 is Toggle Chasecam OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console - /*OP_AllControlsMenu[25].status = IT_GRAYEDOUT2; // Spectator Controls header - OP_AllControlsMenu[26].status = IT_GRAYEDOUT2; // Spectator Controls space - OP_AllControlsMenu[27].status = IT_GRAYEDOUT2; // Spectate - OP_AllControlsMenu[28].status = IT_GRAYEDOUT2; // Look Up - OP_AllControlsMenu[29].status = IT_GRAYEDOUT2; // Look Down - OP_AllControlsMenu[30].status = IT_GRAYEDOUT2; // Center View - */ M_SetupNextMenu(&OP_AllControlsDef); } @@ -12302,11 +12192,6 @@ static void M_DrawControl(void) x = currentMenu->x; y = currentMenu->y; - /*i = itemOn - (controlheight/2); - if (i < 0) - i = 0; - */ - iter = (controlheight/2); for (i = itemOn; ((iter || currentMenu->menuitems[i].status == IT_GRAYEDOUT2) && i > 0); i--) { @@ -12333,16 +12218,6 @@ static void M_DrawControl(void) } } - /*max = i + controlheight; - if (max > currentMenu->numitems) - { - max = currentMenu->numitems; - if (max < controlheight) - i = 0; - else - i = max - controlheight; - }*/ - // draw title (or big pic) M_DrawMenuTitle(); -- 2.54.0 From f70ec60ae485657c877370a0187a792cc12cb405 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Sep 2024 12:31:10 +0200 Subject: [PATCH 515/525] use continues in hooklib loops too idk if this is any faster, but it makes smth i wanna port over potentally easier --- src/lua_hooklib.c | 1589 +++++++++++++++++++++++---------------------- 1 file changed, 829 insertions(+), 760 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 16e72d962..e6faaef01 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -277,44 +277,48 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) // Look for all generic mobj hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == which) - { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - LUA_PushUserdata(gL, mo, META_MOBJ); - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; + { + if (hookp->type != which) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) + LUA_PushUserdata(gL, mo, META_MOBJ); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); + hookp->error = true; + continue; } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } for (hookp = mobjhooks[mo->type]; hookp; hookp = hookp->next) - if (hookp->type == which) - { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - LUA_PushUserdata(gL, mo, META_MOBJ); - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; + { + if (hookp->type != which) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) + LUA_PushUserdata(gL, mo, META_MOBJ); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); + hookp->error = true; + continue; } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -336,24 +340,26 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which) I_Assert(lua_istable(L, HOOKSINDEX)); for (hookp = playerhooks; hookp; hookp = hookp->next) - if (hookp->type == which) - { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - LUA_PushUserdata(gL, plr, META_PLAYER); - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; + { + if (hookp->type != which) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) + LUA_PushUserdata(gL, plr, META_PLAYER); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); + hookp->error = true; + continue; } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -377,15 +383,17 @@ void LUAh_MapChange(INT16 mapnumber) lua_pushinteger(gL, mapnumber); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_MapChange) - { - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + { + if (hookp->type != hook_MapChange) + continue; + + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } + } lua_settop(gL, 0); } @@ -408,15 +416,18 @@ void LUAh_MapLoad(void) lua_pushinteger(gL, gamemap); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_MapLoad) - { - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + { + if (hookp->type != hook_MapLoad) + continue; + + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } + } + lua_settop(gL, 0); } @@ -438,15 +449,17 @@ void LUAh_PlayerJoin(int playernum) lua_pushinteger(gL, playernum); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerJoin) - { - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + { + if (hookp->type != hook_PlayerJoin) + continue; + + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } + } lua_settop(gL, 0); } @@ -470,30 +483,30 @@ void LUAh_PreThinkFrame(void) for (hookp = roothook; hookp; hookp = hookp->next) { - if (hookp->type == hook_PreThinkFrame) - { - if (cv_perfstats.value == 4) - time_taken = I_GetPreciseTime(); - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } - if (cv_perfstats.value == 4) - { - lua_Debug ar; - time_taken = I_GetPreciseTime() - time_taken; - // we need the function, let's just retrieve it again - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_getinfo(gL, ">S", &ar); - PS_SetPreThinkFrameHookInfo(hook_index, time_taken, ar.short_src); - hook_index++; - } - } + if (hookp->type != hook_PreThinkFrame) + continue; + if (cv_perfstats.value == 4) + time_taken = I_GetPreciseTime(); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + if (lua_pcall(gL, 0, 0, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + } + if (cv_perfstats.value == 4) + { + lua_Debug ar; + time_taken = I_GetPreciseTime() - time_taken; + // we need the function, let's just retrieve it again + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_getinfo(gL, ">S", &ar); + PS_SetPreThinkFrameHookInfo(hook_index, time_taken, ar.short_src); + hook_index++; + } } + lua_pop(gL, 2); // Pop error handler and hooks table } @@ -517,27 +530,27 @@ void LUAh_ThinkFrame(void) for (hookp = roothook; hookp; hookp = hookp->next) { - if (hookp->type == hook_ThinkFrame) + if (hookp->type != hook_ThinkFrame) + continue; + + if (cv_perfstats.value == 3) + time_taken = I_GetPreciseTime(); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + if (lua_pcall(gL, 0, 0, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + } + if (cv_perfstats.value == 3) { - if (cv_perfstats.value == 3) - time_taken = I_GetPreciseTime(); + lua_Debug ar; + time_taken = I_GetPreciseTime() - time_taken; + // we need the function, let's just retrieve it again lua_rawgeti(gL, HOOKSINDEX, hookp->id); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } - if (cv_perfstats.value == 3) - { - lua_Debug ar; - time_taken = I_GetPreciseTime() - time_taken; - // we need the function, let's just retrieve it again - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_getinfo(gL, ">S", &ar); - PS_SetThinkFrameHookInfo(hook_index, time_taken, ar.short_src); - hook_index++; - } + lua_getinfo(gL, ">S", &ar); + PS_SetThinkFrameHookInfo(hook_index, time_taken, ar.short_src); + hook_index++; } } @@ -563,27 +576,27 @@ void LUAh_PostThinkFrame(void) for (hookp = roothook; hookp; hookp = hookp->next) { - if (hookp->type == hook_PostThinkFrame) + if (hookp->type != hook_PostThinkFrame) + continue; + + if (cv_perfstats.value == 5) + time_taken = I_GetPreciseTime(); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + if (lua_pcall(gL, 0, 0, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + } + if (cv_perfstats.value == 5) { - if (cv_perfstats.value == 5) - time_taken = I_GetPreciseTime(); + lua_Debug ar; + time_taken = I_GetPreciseTime() - time_taken; + // we need the function, let's just retrieve it again lua_rawgeti(gL, HOOKSINDEX, hookp->id); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } - if (cv_perfstats.value == 5) - { - lua_Debug ar; - time_taken = I_GetPreciseTime() - time_taken; - // we need the function, let's just retrieve it again - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_getinfo(gL, ">S", &ar); - PS_SetPostThinkFrameHookInfo(hook_index, time_taken, ar.short_src); - hook_index++; - } + lua_getinfo(gL, ">S", &ar); + PS_SetPostThinkFrameHookInfo(hook_index, time_taken, ar.short_src); + hook_index++; } } @@ -607,15 +620,15 @@ void LUAh_IntermissionThinker(void) for (hookp = roothook; hookp; hookp = hookp->next) { - if (hookp->type == hook_IntermissionThinker) - { - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } + if (hookp->type != hook_IntermissionThinker) + continue; + + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + if (lua_pcall(gL, 0, 0, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; } } @@ -639,15 +652,15 @@ void LUAh_VoteThinker(void) for (hookp = roothook; hookp; hookp = hookp->next) { - if (hookp->type == hook_VoteThinker) - { - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } + if (hookp->type != hook_VoteThinker) + continue; + + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + if (lua_pcall(gL, 0, 0, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; } } @@ -678,62 +691,66 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) // Look for all generic mobj collision hooks for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == which) + { + if (hookp->type != which) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, thing1, META_MOBJ); - LUA_PushUserdata(gL, thing2, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave shouldCollide = 0. - if (lua_toboolean(gL, -1)) - shouldCollide = 1; // Force yes - else - shouldCollide = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, thing1, META_MOBJ); + LUA_PushUserdata(gL, thing2, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { // if nil, leave shouldCollide = 0. + if (lua_toboolean(gL, -1)) + shouldCollide = 1; // Force yes + else + shouldCollide = 2; // Force no + } + lua_pop(gL, 1); + } for (hookp = mobjcollidehooks[thing1->type]; hookp; hookp = hookp->next) - if (hookp->type == which) + { + if (hookp->type != which) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, thing1, META_MOBJ); - LUA_PushUserdata(gL, thing2, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave shouldCollide = 0. - if (lua_toboolean(gL, -1)) - shouldCollide = 1; // Force yes - else - shouldCollide = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, thing1, META_MOBJ); + LUA_PushUserdata(gL, thing2, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { // if nil, leave shouldCollide = 0. + if (lua_toboolean(gL, -1)) + shouldCollide = 1; // Force yes + else + shouldCollide = 2; // Force no + } + lua_pop(gL, 1); + } lua_settop(gL, 0); return shouldCollide; @@ -826,52 +843,56 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) // Look for all generic touch special hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == hook_TouchSpecial) + { + if (hookp->type != hook_TouchSpecial) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, special, META_MOBJ); - LUA_PushUserdata(gL, toucher, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, special, META_MOBJ); + LUA_PushUserdata(gL, toucher, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } for (hookp = mobjhooks[special->type]; hookp; hookp = hookp->next) - if (hookp->type == hook_TouchSpecial) + { + if (hookp->type != hook_TouchSpecial) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, special, META_MOBJ); - LUA_PushUserdata(gL, toucher, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, special, META_MOBJ); + LUA_PushUserdata(gL, toucher, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -900,70 +921,74 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 // Look for all generic should damage hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == hook_ShouldDamage) + { + if (hookp->type != hook_ShouldDamage) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldDamage = 1; // Force yes - else - shouldDamage = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damage); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + if (lua_pcall(gL, 4, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { + if (lua_toboolean(gL, -1)) + shouldDamage = 1; // Force yes + else + shouldDamage = 2; // Force no + } + lua_pop(gL, 1); + } for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next) - if (hookp->type == hook_ShouldDamage) + { + if (hookp->type != hook_ShouldDamage) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldDamage = 1; // Force yes - else - shouldDamage = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damage); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + if (lua_pcall(gL, 4, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { + if (lua_toboolean(gL, -1)) + shouldDamage = 1; // Force yes + else + shouldDamage = 2; // Force no + } + lua_pop(gL, 1); + } lua_settop(gL, 0); return shouldDamage; @@ -992,60 +1017,64 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 // Look for all generic mobj damage hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == hook_MobjDamage) + { + if (hookp->type != hook_MobjDamage) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damage); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + if (lua_pcall(gL, 4, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next) - if (hookp->type == hook_MobjDamage) + { + if (hookp->type != hook_MobjDamage) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damage); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + if (lua_pcall(gL, 4, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -1074,55 +1103,59 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source) // Look for all generic mobj death hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == hook_MobjDeath) + { + if (hookp->type != hook_MobjDeath) + continue; + + if (lua_gettop(gL) == 2) { - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next) - if (hookp->type == hook_MobjDeath) + { + if (hookp->type != hook_MobjDeath) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -1145,27 +1178,29 @@ boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd) I_Assert(lua_istable(L, HOOKSINDEX)); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_BotTiccmd) + { + if (hookp->type != hook_BotTiccmd) + continue; + + if (lua_gettop(gL) == 2) { - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, bot, META_PLAYER); - LUA_PushUserdata(gL, cmd, META_TICCMD); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, bot, META_PLAYER); + LUA_PushUserdata(gL, cmd, META_TICCMD); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -1190,27 +1225,29 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd) hook_cmd_running = true; for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerCmd) + { + if (hookp->type != hook_PlayerCmd) + continue; + + if (lua_gettop(gL) == 2) { - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, cmd, META_TICCMD); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, cmd, META_TICCMD); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } hook_cmd_running = false; lua_settop(gL, 0); @@ -1234,50 +1271,52 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) I_Assert(lua_istable(L, HOOKSINDEX)); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_BotAI - && (hookp->s.skinname == NULL || !strcmp(hookp->s.skinname, ((skin_t*)tails->skin)->name))) + { + if (hookp->type != hook_BotAI + || (hookp->s.skinname && strcmp(hookp->s.skinname, ((skin_t*)tails->skin)->name))) + continue; + + if (lua_gettop(gL) == 2) { - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, sonic, META_MOBJ); - LUA_PushUserdata(gL, tails, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 8, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - - // This turns forward, backward, left, right, jump, and spin into a proper ticcmd for tails. - if (lua_istable(gL, -8)) { - boolean forward=false, backward=false, left=false, right=false, strafeleft=false, straferight=false, jump=false, spin=false; -#define CHECKFIELD(field) \ - lua_getfield(gL, -8, #field);\ - if (lua_toboolean(gL, -1))\ - field = true;\ - lua_pop(gL, 1); - - CHECKFIELD(forward) - CHECKFIELD(backward) - CHECKFIELD(left) - CHECKFIELD(right) - CHECKFIELD(strafeleft) - CHECKFIELD(straferight) - CHECKFIELD(jump) - CHECKFIELD(spin) -#undef CHECKFIELD - B_KeysToTiccmd(tails, cmd, forward, backward, left, right, strafeleft, straferight, jump, spin); - } else - B_KeysToTiccmd(tails, cmd, lua_toboolean(gL, -8), lua_toboolean(gL, -7), lua_toboolean(gL, -6), lua_toboolean(gL, -5), lua_toboolean(gL, -4), lua_toboolean(gL, -3), lua_toboolean(gL, -2), lua_toboolean(gL, -1)); - - lua_pop(gL, 8); - hooked = true; + LUA_PushUserdata(gL, sonic, META_MOBJ); + LUA_PushUserdata(gL, tails, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 8, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + + // This turns forward, backward, left, right, jump, and spin into a proper ticcmd for tails. + if (lua_istable(gL, -8)) { + boolean forward=false, backward=false, left=false, right=false, strafeleft=false, straferight=false, jump=false, spin=false; +#define CHECKFIELD(field) \ + lua_getfield(gL, -8, #field);\ + if (lua_toboolean(gL, -1))\ + field = true;\ + lua_pop(gL, 1); + + CHECKFIELD(forward) + CHECKFIELD(backward) + CHECKFIELD(left) + CHECKFIELD(right) + CHECKFIELD(strafeleft) + CHECKFIELD(straferight) + CHECKFIELD(jump) + CHECKFIELD(spin) +#undef CHECKFIELD + B_KeysToTiccmd(tails, cmd, forward, backward, left, right, strafeleft, straferight, jump, spin); + } else + B_KeysToTiccmd(tails, cmd, lua_toboolean(gL, -8), lua_toboolean(gL, -7), lua_toboolean(gL, -6), lua_toboolean(gL, -5), lua_toboolean(gL, -4), lua_toboolean(gL, -3), lua_toboolean(gL, -2), lua_toboolean(gL, -1)); + + lua_pop(gL, 8); + hooked = true; + } lua_settop(gL, 0); return hooked; @@ -1300,25 +1339,27 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) I_Assert(lua_istable(L, HOOKSINDEX)); for (hookp = linedefexecutorhooks; hookp; hookp = hookp->next) - if (!strcmp(hookp->s.funcname, line->text)) + { + if (strcmp(hookp->s.funcname, line->text)) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, line, META_LINE); - LUA_PushUserdata(gL, mo, META_MOBJ); - LUA_PushUserdata(gL, sector, META_SECTOR); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } - hooked = true; + LUA_PushUserdata(gL, line, META_LINE); + LUA_PushUserdata(gL, mo, META_MOBJ); + LUA_PushUserdata(gL, sector, META_SECTOR); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + } + hooked = true; + } lua_settop(gL, 0); return hooked; @@ -1343,47 +1384,49 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute) I_Assert(lua_istable(L, HOOKSINDEX)); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerMsg) + { + if (hookp->type != hook_PlayerMsg) + continue; + + if (lua_gettop(gL) == 2) { - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player - if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c - lua_pushinteger(gL, 3); // type - lua_pushnil(gL); // target - } else if (target == -1) { // sayteam - lua_pushinteger(gL, 1); // type - lua_pushnil(gL); // target - } else if (target == 0) { // say - lua_pushinteger(gL, 0); // type - lua_pushnil(gL); // target - } else { // sayto - lua_pushinteger(gL, 2); // type - LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target - } - lua_pushstring(gL, msg); // msg - if (mute) - lua_pushboolean(gL, true); // the message was supposed to be eaten by spamprotecc. - else - lua_pushboolean(gL, false); + LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player + if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c + lua_pushinteger(gL, 3); // type + lua_pushnil(gL); // target + } else if (target == -1) { // sayteam + lua_pushinteger(gL, 1); // type + lua_pushnil(gL); // target + } else if (target == 0) { // say + lua_pushinteger(gL, 0); // type + lua_pushnil(gL); // target + } else { // sayto + lua_pushinteger(gL, 2); // type + LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - lua_pushvalue(gL, -6); - if (lua_pcall(gL, 5, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + lua_pushstring(gL, msg); // msg + if (mute) + lua_pushboolean(gL, true); // the message was supposed to be eaten by spamprotecc. + else + lua_pushboolean(gL, false); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + if (lua_pcall(gL, 5, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -1406,30 +1449,32 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) I_Assert(lua_istable(L, HOOKSINDEX)); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_HurtMsg - && (hookp->s.mt == MT_NULL || (inflictor && hookp->s.mt == inflictor->type))) + { + if (hookp->type != hook_HurtMsg + || (hookp->s.mt && !(inflictor && hookp->s.mt == inflictor->type))) + continue; + + if (lua_gettop(gL) == 2) { - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -1460,15 +1505,17 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) // stack: tables, archFunc for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_NetVars) - { - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -2); // archFunc - if (lua_pcall(gL, 1, 0, errorhandlerindex)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + { + if (hookp->type != hook_NetVars) + continue; + + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -2); // archFunc + if (lua_pcall(gL, 1, 0, errorhandlerindex)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); } + } lua_pop(gL, 3); // Pop archFunc, error handler and hooks table // stack: tables @@ -1489,21 +1536,23 @@ void LUAh_PlayerQuit(player_t *plr, int reason) I_Assert(lua_istable(L, HOOKSINDEX)); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerQuit) + { + if (hookp->type != hook_PlayerQuit) + continue; + + if (lua_gettop(gL) == 2) { - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit - lua_pushinteger(gL, reason); // Reason for quitting - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 0, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - } + LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit + lua_pushinteger(gL, reason); // Reason for quitting } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 0, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + } + } lua_settop(gL, 0); } @@ -1527,46 +1576,48 @@ boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boo I_Assert(lua_istable(L, HOOKSINDEX)); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_MusicChange) - { - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushstring(gL, oldname); - lua_pushstring(gL, newname); - lua_pushinteger(gL, *mflags); - lua_pushboolean(gL, *looping); - lua_pushinteger(gL, *position); - lua_pushinteger(gL, *prefadems); - lua_pushinteger(gL, *fadeinms); - if (lua_pcall(gL, 7, 6, 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); - lua_pop(gL, 1); - continue; - } + { + if (hookp->type != hook_MusicChange) + continue; - // output 1: true, false, or string musicname override - if (lua_isboolean(gL, -6) && lua_toboolean(gL, -6)) - hooked = true; - else if (lua_isstring(gL, -6)) - strncpy(newname, lua_tostring(gL, -6), 7); - // output 2: mflags override - if (lua_isnumber(gL, -5)) - *mflags = lua_tonumber(gL, -5); - // output 3: looping override - if (lua_isboolean(gL, -4)) - *looping = lua_toboolean(gL, -4); - // output 4: position override - if (lua_isnumber(gL, -3)) - *position = lua_tonumber(gL, -3); - // output 5: prefadems override - if (lua_isnumber(gL, -2)) - *prefadems = lua_tonumber(gL, -2); - // output 6: fadeinms override - if (lua_isnumber(gL, -1)) - *fadeinms = lua_tonumber(gL, -1); - - lua_pop(gL, 6); + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushstring(gL, oldname); + lua_pushstring(gL, newname); + lua_pushinteger(gL, *mflags); + lua_pushboolean(gL, *looping); + lua_pushinteger(gL, *position); + lua_pushinteger(gL, *prefadems); + lua_pushinteger(gL, *fadeinms); + if (lua_pcall(gL, 7, 6, 1)) { + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); + lua_pop(gL, 1); + continue; } + // output 1: true, false, or string musicname override + if (lua_isboolean(gL, -6) && lua_toboolean(gL, -6)) + hooked = true; + else if (lua_isstring(gL, -6)) + strncpy(newname, lua_tostring(gL, -6), 7); + // output 2: mflags override + if (lua_isnumber(gL, -5)) + *mflags = lua_tonumber(gL, -5); + // output 3: looping override + if (lua_isboolean(gL, -4)) + *looping = lua_toboolean(gL, -4); + // output 4: position override + if (lua_isnumber(gL, -3)) + *position = lua_tonumber(gL, -3); + // output 5: prefadems override + if (lua_isnumber(gL, -2)) + *prefadems = lua_tonumber(gL, -2); + // output 6: fadeinms override + if (lua_isnumber(gL, -1)) + *fadeinms = lua_tonumber(gL, -1); + + lua_pop(gL, 6); + } + lua_settop(gL, 0); newname[6] = 0; return hooked; @@ -1591,35 +1642,37 @@ UINT8 LUAh_ShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source) // We can afford not to check for mobj type because it will always be MT_PLAYER in this case. for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_ShouldSpin) + { + if (hookp->type != hook_ShouldSpin) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldDamage = 1; // Force yes - else - shouldDamage = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { + if (lua_toboolean(gL, -1)) + shouldDamage = 1; // Force yes + else + shouldDamage = 2; // Force no + } + lua_pop(gL, 1); + } lua_settop(gL, 0); return shouldDamage; @@ -1644,35 +1697,37 @@ UINT8 LUAh_ShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source) // We can afford not to check for mobj type because it will always be MT_PLAYER in this case. for (hookp = roothook; hookp; hookp = hookp->next) + { if (hookp->type == hook_ShouldExplode) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldDamage = 1; // Force yes - else - shouldDamage = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { + if (lua_toboolean(gL, -1)) + shouldDamage = 1; // Force yes + else + shouldDamage = 2; // Force no + } + lua_pop(gL, 1); + } lua_settop(gL, 0); return shouldDamage; @@ -1697,35 +1752,37 @@ UINT8 LUAh_ShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source) // We can afford not to check for mobj type because it will always be MT_PLAYER in this case. for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_ShouldSquish) + { + if (hookp->type != hook_ShouldSquish) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldDamage = 1; // Force yes - else - shouldDamage = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { + if (lua_toboolean(gL, -1)) + shouldDamage = 1; // Force yes + else + shouldDamage = 2; // Force no + } + lua_pop(gL, 1); + } lua_settop(gL, 0); return shouldDamage; @@ -1750,30 +1807,33 @@ boolean LUAh_PlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source) // We can afford not to look for target->type because it will always be MT_PLAYER. for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerSpin) + { + if (hookp->type != hook_PlayerSpin) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + lua_settop(gL, 0); return hooked; } @@ -1797,30 +1857,33 @@ boolean LUAh_PlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source) // We can afford not to look for target->type because it will always be MT_PLAYER. for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerSquish) + { + if (hookp->type != hook_PlayerSquish) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + lua_settop(gL, 0); return hooked; } @@ -1844,30 +1907,33 @@ boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source) // We can afford not to look for target->type because it will always be MT_PLAYER. for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerExplode) + { + if (hookp->type != hook_PlayerExplode) + continue; + + ps_lua_mobjhooks.value.i++; + if (lua_gettop(gL) == 2) { - ps_lua_mobjhooks.value.i++; - if (lua_gettop(gL) == 2) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); } + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + lua_settop(gL, 0); return hooked; } @@ -1889,16 +1955,19 @@ void LUAh_ServerJoin(void) // We can afford not to look for target->type because it will always be MT_PLAYER. for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_ServerJoin) - { - lua_rawgeti(gL, HOOKSINDEX, hookp->id); - if (lua_pcall(gL, 0, 0, 1)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } + { + if (hookp->type != hook_ServerJoin) + continue; + + lua_rawgeti(gL, HOOKSINDEX, hookp->id); + if (lua_pcall(gL, 0, 0, 1)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; } + } + lua_settop(gL, 0); } -- 2.54.0 From 075097c219b779421fcc1d3f30defb95f55467ff Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 14 Sep 2024 16:40:17 +0300 Subject: [PATCH 516/525] Don't default to sonic if skin was changed to unknown skin, use current skin instead --- src/d_netcmd.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1f8c8e5f1..8e9bfb9e3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1687,8 +1687,9 @@ static void SendNameAndColor(void) cv_skin.value = R_SkinAvailable(cv_skin.string); if (cv_skin.value < 0) { - CV_StealthSet(&cv_skin, DEFAULTSKIN); - cv_skin.value = 0; + INT32 skinnum = players[consoleplayer].skin; + CV_StealthSet(&cv_skin, skins[skinnum].name); + cv_skin.value = skinnum; } // Finally write out the complete packet and send it off. @@ -1816,8 +1817,9 @@ static void SendNameAndColor2(void) cv_skin2.value = R_SkinAvailable(cv_skin2.string); if (cv_skin2.value < 0) { - CV_StealthSet(&cv_skin2, DEFAULTSKIN); - cv_skin2.value = 0; + INT32 skinnum = players[displayplayers[1]].skin; + CV_StealthSet(&cv_skin2, skins[skinnum].name); + cv_skin2.value = skinnum; } // Finally write out the complete packet and send it off. @@ -1936,8 +1938,9 @@ static void SendNameAndColor3(void) cv_skin3.value = R_SkinAvailable(cv_skin3.string); if (cv_skin3.value < 0) { - CV_StealthSet(&cv_skin3, DEFAULTSKIN); - cv_skin3.value = 0; + INT32 skinnum = players[displayplayers[2]].skin; + CV_StealthSet(&cv_skin3, skins[skinnum].name); + cv_skin3.value = skinnum; } // Finally write out the complete packet and send it off. @@ -2064,8 +2067,9 @@ static void SendNameAndColor4(void) cv_skin4.value = R_SkinAvailable(cv_skin4.string); if (cv_skin4.value < 0) { - CV_StealthSet(&cv_skin4, DEFAULTSKIN); - cv_skin4.value = 0; + INT32 skinnum = players[displayplayers[3]].skin; + CV_StealthSet(&cv_skin4, skins[skinnum].name); + cv_skin4.value = skinnum; } // Finally write out the complete packet and send it off. -- 2.54.0 From 71fe6ec9da01bff7aa10644db64387d6d81f9135 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 14 Sep 2024 19:04:51 +0300 Subject: [PATCH 517/525] should be != here --- src/lua_hooklib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index e6faaef01..1aadea9a3 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1698,7 +1698,7 @@ UINT8 LUAh_ShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source) for (hookp = roothook; hookp; hookp = hookp->next) { - if (hookp->type == hook_ShouldExplode) + if (hookp->type != hook_ShouldExplode) continue; ps_lua_mobjhooks.value.i++; -- 2.54.0 From 7d4898dd8b6b9a91fef8c7d9457d4038321ada85 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Sep 2024 18:43:00 +0200 Subject: [PATCH 518/525] remove code dupe in r_segs --- src/r_segs.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 718f93f40..07d217608 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1961,20 +1961,6 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (viewsector != frontsector && viewsector != backsector) { - if (worldhigh <= worldbottom && worldhighslope <= worldbottomslope) - { - ds_p->sprbottomclip = negonearray; - ds_p->bsilheight = INT32_MAX; - ds_p->silhouette |= SIL_BOTTOM; - } - - if (worldlow >= worldtop && worldlowslope >= worldtopslope) - { - ds_p->sprtopclip = screenheightarray; - ds_p->tsilheight = INT32_MIN; - ds_p->silhouette |= SIL_TOP; - } - //SoM: 3/25/2000: This code fixes an automap bug that didn't check // frontsector->ceiling and backsector->floor to see if a door was closed. // Without the following code, sprites get displayed behind closed doors. -- 2.54.0 From 4034658e447e2a3b67367b37d76b375e97ffd496 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Sep 2024 19:43:54 +0200 Subject: [PATCH 519/525] some cleanup --- src/p_mobj.c | 26 +++++++++++------- src/p_polyobj.c | 70 +++++++++++++------------------------------------ src/p_saveg.c | 10 ++++--- src/p_spec.c | 8 +++--- src/r_bsp.c | 17 +++++++----- 5 files changed, 55 insertions(+), 76 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index a53025419..c70f9816c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -915,7 +915,7 @@ static void P_PlayerFlip(mobj_t *mo) for (i = 0; i <= splitscreen; i++) { - if (!(mo->player-players == displayplayers[i])) + if (mo->player-players != displayplayers[i]) continue; localaiming[i] = mo->player->aiming; @@ -1236,7 +1236,7 @@ static void P_PushableCheckBustables(mobj_t *mo) if (!node->m_sector) break; - if (!(node->m_sector->ffloors)) + if (!node->m_sector->ffloors) continue; ffloor_t *rover; @@ -3301,7 +3301,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled { for (i = 0; i <= splitscreen; i++) { - if (!(player == &players[displayplayers[i]])) + if (player != &players[displayplayers[i]]) continue; postimgtype[i] = postimg; @@ -5424,7 +5424,7 @@ mobj_t *P_GetClosestAxis(mobj_t *source) mo2 = (mobj_t *)th; - if (!(mo2->type == MT_AXIS)) + if (mo2->type != MT_AXIS) continue; if (closestaxis == NULL) @@ -7237,11 +7237,17 @@ void P_MobjThinker(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); for (i = 0; i < MAXPLAYERS; i++) { - if (!(playeringame[i] && players[i].mo - && players[i].mare == mobj->threshold && players[i].health > 1)) + if (!playeringame[i] || !players[i].mo) continue; + if (players[i].mare != mobj->threshold) + continue; + + if (!(players[i].health > 1)) + continue; + fixed_t dist = P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y); + if (!(dist < shortest)) continue; @@ -10378,7 +10384,7 @@ void P_PrecipitationEffects(void) for (y = yl; y >= yl && y <= yh; y += FRACUNIT*64) for (x = xl; x >= xl && x <= xh; x += FRACUNIT*64) { - if (!(R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum)) // Found the outdoors! + if (R_PointInSubsector(x, y)->sector->ceilingpic != skyflatnum) // Found the outdoors! continue; newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, x, y, 0); @@ -10772,8 +10778,10 @@ void P_AfterPlayerSpawn(INT32 playernum) if (!camera[i].chase) continue; - if (displayplayers[i] == playernum) - P_ResetCamera(p, &camera[i]); + if (displayplayers[i] != playernum) + continue; + + P_ResetCamera(p, &camera[i]); } if (CheckForReverseGravity) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 887e1c751..7a21497e3 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1553,28 +1553,27 @@ void Polyobj_InitLevel(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + + mobj_t *mo = (mobj_t *)th; + + if (mo->info->doomednum == POLYOBJ_SPAWN_DOOMEDNUM || + mo->info->doomednum == POLYOBJ_SPAWNCRUSH_DOOMEDNUM) { - mobj_t *mo = (mobj_t *)th; + ++numPolyObjects; - if (mo->info->doomednum == POLYOBJ_SPAWN_DOOMEDNUM || - mo->info->doomednum == POLYOBJ_SPAWNCRUSH_DOOMEDNUM) - { - ++numPolyObjects; + qitem = malloc(sizeof(mobjqitem_t)); + memset(qitem, 0, sizeof(mobjqitem_t)); + qitem->mo = mo; + M_QueueInsert(&(qitem->mqitem), &spawnqueue); + } + else if (mo->info->doomednum == POLYOBJ_ANCHOR_DOOMEDNUM) + { + ++numAnchors; - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); - qitem->mo = mo; - M_QueueInsert(&(qitem->mqitem), &spawnqueue); - } - else if (mo->info->doomednum == POLYOBJ_ANCHOR_DOOMEDNUM) - { - ++numAnchors; - - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); - qitem->mo = mo; - M_QueueInsert(&(qitem->mqitem), &anchorqueue); - } + qitem = malloc(sizeof(mobjqitem_t)); + memset(qitem, 0, sizeof(mobjqitem_t)); + qitem->mo = mo; + M_QueueInsert(&(qitem->mqitem), &anchorqueue); } } @@ -1615,39 +1614,6 @@ void Polyobj_InitLevel(void) Polyobj_linkToBlockmap(&PolyObjects[i]); } -#if 0 - // haleyjd 02/22/06: temporary debug - printf("DEBUG: numPolyObjects = %d\n", numPolyObjects); - for (i = 0; i < numPolyObjects; ++i) - { - INT32 j; - polyobj_t *po = &PolyObjects[i]; - - printf("polyobj %d:\n", i); - printf("id = %d, first = %d, next = %d\n", po->id, po->first, po->next); - printf("segCount = %d, numSegsAlloc = %d\n", po->segCount, po->numSegsAlloc); - for (j = 0; j < po->segCount; ++j) - printf("\tseg %d: %p\n", j, po->segs[j]); - printf("numVertices = %d, numVerticesAlloc = %d\n", po->numVertices, po->numVerticesAlloc); - for (j = 0; j < po->numVertices; ++j) - { - printf("\tvtx %d: (%d, %d) / orig: (%d, %d)\n", - j, po->vertices[j]->x>>FRACBITS, po->vertices[j]->y>>FRACBITS, - po->origVerts[j].x>>FRACBITS, po->origVerts[j].y>>FRACBITS); - } - printf("numLines = %d, numLinesAlloc = %d\n", po->numLines, po->numLinesAlloc); - for (j = 0; j < po->numLines; ++j) - printf("\tline %d: %p\n", j, po->lines[j]); - printf("spawnSpot = (%d, %d)\n", po->spawnSpot.x >> FRACBITS, po->spawnSpot.y >> FRACBITS); - printf("centerPt = (%d, %d)\n", po->centerPt.x >> FRACBITS, po->centerPt.y >> FRACBITS); - printf("attached = %d, linked = %d, validcount = %d, isBad = %d\n", - po->attached, po->linked, po->validcount, po->isBad); - printf("blockbox: [%d, %d, %d, %d]\n", - po->blockbox[BOXLEFT], po->blockbox[BOXRIGHT], po->blockbox[BOXBOTTOM], - po->blockbox[BOXTOP]); - } -#endif - // done with mobj queues M_QueueFree(&spawnqueue); M_QueueFree(&anchorqueue); diff --git a/src/p_saveg.c b/src/p_saveg.c index a0c1add47..3d28a6eac 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1881,6 +1881,7 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) continue; mobj = (mobj_t *)th; + if (mobj->mobjnum != oldposition) continue; @@ -2887,10 +2888,9 @@ static void P_NetUnArchiveThinkers(void) continue; delay = (void *)currentthinker; - if (!(mobjnum = (UINT32)(size_t)delay->caller)) - continue; - delay->caller = P_FindNewPosition(mobjnum); + if ((mobjnum = (UINT32)(size_t)delay->caller)) + delay->caller = P_FindNewPosition(mobjnum); } } } @@ -3001,6 +3001,7 @@ static inline void P_FinishMobjs(void) { if (currentthinker->function.acp1 != (actionf_p1)P_MobjThinker) continue; + mobj = (mobj_t *)currentthinker; mobj->info = &mobjinfo[mobj->type]; } @@ -3456,9 +3457,12 @@ void P_SaveNetGame(void) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; + mobj = (mobj_t *)th; + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) continue; + mobj->mobjnum = i++; } } diff --git a/src/p_spec.c b/src/p_spec.c index c022ef384..378db7269 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3060,11 +3060,9 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (GETSECSPECIAL(rover->master->frontsector->special, 4) != specialnum) continue; - if (!(mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) - && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))) - continue; - - return true; + if (mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) + && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector)) + return true; } } } diff --git a/src/r_bsp.c b/src/r_bsp.c index 3a68c648e..54d6cada1 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -266,7 +266,10 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, for (i = 0; i <= splitscreen; i++) { - if (!(viewplayer == &players[displayplayers[i]] && camera[i].chase)) + if (viewplayer != &players[displayplayers[i]]) + continue; + + if (!camera[i].chase) continue; heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; @@ -1167,13 +1170,13 @@ void R_Prep3DFloors(sector_t *sector) count = 1; for (rover = sector->ffloors; rover; rover = rover->next) { - if (!((rover->flags & FF_EXISTS) && (!(rover->flags & FF_NOSHADE) - || (rover->flags & FF_CUTLEVEL) || (rover->flags & FF_CUTSPRITES)))) - continue; - - count++; - if (rover->flags & FF_DOUBLESHADOW) + if ((rover->flags & FF_EXISTS) && (!(rover->flags & FF_NOSHADE) + || (rover->flags & FF_CUTLEVEL) || (rover->flags & FF_CUTSPRITES))) + { count++; + if (rover->flags & FF_DOUBLESHADOW) + count++; + } } if (count != sector->numlights) -- 2.54.0 From aac3b8d02552d86bd4f2fe57075df85e1a095ca9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Sep 2024 19:45:23 +0200 Subject: [PATCH 520/525] forgor this one --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index e24b2d402..7e1067dbe 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -429,7 +429,7 @@ void R_LoadTextures(void) } // Add all the textures between TX_START and TX_END - if (!(texstart != INT16_MAX && texend != INT16_MAX)) + if (texstart == INT16_MAX && texend == INT16_MAX) continue; // PK3s have subfolders, so we can't just make a simple sum -- 2.54.0 From accef8f1e1a5e1a3a55c922d1eb302d33627a534 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Sep 2024 21:10:55 +0200 Subject: [PATCH 521/525] version change --- src/doomdef.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 9aba9b5c5..bdc82a0ca 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -128,11 +128,11 @@ extern char logfilename[1024]; #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number #ifndef USE_FBO_OGL -#define VERSIONSTRING "Saturn v7 - Test " -#define VERSIONSTRINGW L"Saturn v7 - Test" +#define VERSIONSTRING "Saturn v7" +#define VERSIONSTRINGW L"Saturn v7" #else -#define VERSIONSTRING "Saturn v7 - Test - FBO " -#define VERSIONSTRINGW L"Saturn v7 - Test - FBO" +#define VERSIONSTRING "Saturn v7 - FBO " +#define VERSIONSTRINGW L"Saturn v7 - FBO" #endif // Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates! // And change CMakeLists.txt (not src/, but in root), for CMake users! -- 2.54.0 From 84d3ee717053ac1ba071edcd7f55bee179a71cca Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Sep 2024 22:23:11 +0200 Subject: [PATCH 522/525] maths..... --- src/r_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_data.c b/src/r_data.c index 7e1067dbe..98431510d 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -429,7 +429,7 @@ void R_LoadTextures(void) } // Add all the textures between TX_START and TX_END - if (texstart == INT16_MAX && texend == INT16_MAX) + if (texstart == INT16_MAX || texend == INT16_MAX) continue; // PK3s have subfolders, so we can't just make a simple sum -- 2.54.0 From cb42bc581beca17e9e3f0dd1e8fde38539b05be6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 15 Sep 2024 11:43:03 +0200 Subject: [PATCH 523/525] squish options menu a little im honestly too lazy too move shit around just before release lmao --- src/m_menu.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index da0c53c3c..7df4aff91 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1131,21 +1131,21 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Video Options...", &OP_VideoOptionsDef, 15}, {IT_SUBMENU|IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 25}, - {IT_SUBMENU|IT_STRING, NULL, "HUD Options...", &OP_HUDOptionsDef, 45}, - {IT_SUBMENU|IT_STRING, NULL, "Camera Options...", &OP_CamOptionsDef, 55}, - {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 65}, - {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 75}, + {IT_SUBMENU|IT_STRING, NULL, "HUD Options...", &OP_HUDOptionsDef, 40}, + {IT_SUBMENU|IT_STRING, NULL, "Camera Options...", &OP_CamOptionsDef, 50}, + {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 60}, + {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 70}, - {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 95}, - {IT_CALL|IT_STRING, NULL, "Custom Options...", M_CustomCvarMenu, 105}, + {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 85}, + {IT_CALL|IT_STRING, NULL, "Custom Options...", M_CustomCvarMenu, 95}, - {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 115}, - {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 125}, + {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 105}, + {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 115}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 135}, - {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 155}, - {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 165}, + {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 145}, + {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 155}, }; static menuitem_t OP_ControlsMenu[] = -- 2.54.0 From 862f1fce2c5585ec1223fea063009fee2716b26b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 15 Sep 2024 11:47:33 +0200 Subject: [PATCH 524/525] ... --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 848d34783..06ebc55b6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1144,7 +1144,7 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 135}, - {IT_SUBMENU|IT_STRING, NULL, "Bird", &OP_BirdDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 145}, {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 155}, }; -- 2.54.0 From e079bac2830aa6bdf292ea7ec5edf7f51584390c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 15 Sep 2024 12:02:56 +0200 Subject: [PATCH 525/525] make advanced server menu scroll menu grrrrr green res --- src/m_menu.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 06ebc55b6..5a53d11bb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2026,34 +2026,34 @@ static menuitem_t OP_AdvServerOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Server Browser Address", &cv_masterserver, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, + {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 25}, #ifdef SATURNSYNCH - {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, - {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 60}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 35}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 40}, - {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 70}, - {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 80}, - {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 90}, - {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 100}, - - {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 120}, - {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 130}, - - {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 150}, - {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 160}, - {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 170}, -#else {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 50}, - {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 60}, - {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 70}, - {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 80}, + {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 55}, + {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 60}, + {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 65}, - {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 100}, - {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 110}, + {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 75}, + {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 80}, - {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 130}, - {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 140}, - {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 150}, + {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 90}, + {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 95}, + {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 100}, +#else + {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 35}, + {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 40}, + {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 45}, + {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 50}, + + {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 60}, + {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 65}, + + {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 70}, + {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 75}, + {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 80}, #endif }; @@ -3061,7 +3061,7 @@ menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE("M_SOUND", OP_SoundAdvancedMenu, & menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20); menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20); #ifndef NONET -menu_t OP_AdvServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_AdvServerOptionsMenu, &OP_ServerOptionsDef, 24, 20); +menu_t OP_AdvServerOptionsDef = DEFAULTSCROLLSTYLE("M_SERVER", OP_AdvServerOptionsMenu, &OP_ServerOptionsDef, 24, 30); #endif //menu_t OP_NetgameOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_NetgameOptionsMenu, &OP_ServerOptionsDef, 30, 30); @@ -5229,7 +5229,6 @@ static void M_DrawGenericMenu(void) DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); DoToolTips(OP_GameOptionsDef, OP_GameTooltips); DoToolTips(OP_ServerOptionsDef, OP_ServerOptionsTooltips); - DoToolTips(OP_AdvServerOptionsDef, OP_AdvServerOptionsTooltips); DoToolTips(OP_PlayerDistortDef, OP_PlayerDistortTooltips); DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C: DoToolTips(OP_BirdDef, OP_BirdTooltips); @@ -5375,6 +5374,7 @@ static void M_DrawGenericScrollMenu(void) #endif DoToolTips(OP_SaturnDef, OP_SaturnTooltips); DoToolTips(OP_SaturnHudDef, OP_SaturnHudTooltips); + DoToolTips(OP_AdvServerOptionsDef, OP_AdvServerOptionsTooltips); } static void M_DrawPauseMenu(void) -- 2.54.0