From dd9d6de0d661a2e235ce20b474a627dfc76038c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 14 Oct 2025 22:43:58 +0200 Subject: [PATCH 01/10] delet gl_viewwidth, gl_viewheight, gl_baseviewwindowx, gl_baseviewwindowy gl_basewindowcenterx, gl_basewindowcentery they were effectively unused --- src/hardware/hw_draw.c | 12 ++++++---- src/hardware/hw_main.cpp | 48 +++++++--------------------------------- src/hardware/hw_main.h | 4 ---- 3 files changed, 16 insertions(+), 48 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 2b8ace584..1c014ce4c 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -649,6 +649,7 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height) // ------------------ void HWR_DrawViewBorder(INT32 clearlines) { +#if 0 INT32 x, y; INT32 top, side; INT32 baseviewwidth, baseviewheight; @@ -659,10 +660,10 @@ void HWR_DrawViewBorder(INT32 clearlines) clearlines = BASEVIDHEIGHT; // refresh all // calc view size based on original game resolution - baseviewwidth = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewwidth), vid.fdup)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7; - baseviewheight = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewheight), vid.fdup)); - top = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowy), vid.fdup)); - side = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowx), vid.fdup)); + baseviewwidth = FixedInt(FixedDiv(viewwidth * FRACUNIT, vid.fdup)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7; + baseviewheight = FixedInt(FixedDiv(viewheight * FRACUNIT, vid.fdup)); + top = FixedInt(FixedDiv(baseviewwindowy * FRACUNIT, vid.fdup)); + side = FixedInt(FixedDiv(baseviewwindowx * FRACUNIT, vid.fdup)); // top HWR_DrawFlatFill(0, 0, @@ -759,6 +760,9 @@ void HWR_DrawViewBorder(INT32 clearlines) PU_PATCH), basewindowx + baseviewwidth, basewindowy + baseviewheight, 0); +#else + (void)clearlines; +#endif } diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 2ccb3f6d9..88584a9da 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -77,11 +77,6 @@ boolean gl_drawing_stencil = false; static INT32 current_bsp_culling_distance = 0; -// base values set at SetViewSize -float gl_baseviewwindowy, gl_baseviewwindowx; -static float gl_viewwindowy, gl_viewwindowx; // top left corner of view window -float gl_viewwidth, gl_viewheight; // viewport clipping boundaries (screen coords) - FTransform atransform; // Float variants of viewx, viewy, viewz, etc. @@ -5316,10 +5311,10 @@ static void HWR_DrawSkyBackground(void) // -----------------+ static inline void HWR_ClearView(void) { - GL_GClipRect((INT32)gl_viewwindowx, - (INT32)gl_viewwindowy, - (INT32)(gl_viewwindowx + gl_viewwidth), - (INT32)(gl_viewwindowy + gl_viewheight), + GL_GClipRect(viewwindowx, + viewwindowy, + (viewwindowx + viewwidth), + (viewwindowy + viewheight), ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); GL_ClearBuffer(false, true, true, NULL); } @@ -5329,19 +5324,6 @@ static inline void HWR_ClearView(void) // -----------------+ void HWR_SetViewSize(void) { - // setup view size - gl_viewwidth = (float)vid.width; - gl_viewheight = (float)vid.height; - - if (splitscreen) - gl_viewheight /= 2; - - if (splitscreen > 1) - gl_viewwidth /= 2; - - gl_baseviewwindowy = 0; - gl_baseviewwindowx = 0; - GL_FlushScreenTextures(); } @@ -5596,20 +5578,6 @@ extern "C" { // ========================================================================== static void HWR_RenderFrame(player_t *player, boolean skybox) { - // set window position - gl_viewwindowx = gl_baseviewwindowx; - gl_viewwindowy = gl_baseviewwindowy; - - if ((splitscreen == 1 && viewssnum == 1) || (splitscreen > 1 && viewssnum > 1)) - { - gl_viewwindowy += gl_viewheight; - } - - if (splitscreen > 1 && viewssnum & 1) - { - gl_viewwindowx += gl_viewwidth; - } - // check for new console commands. NetUpdate(); @@ -5625,10 +5593,10 @@ static void HWR_RenderFrame(player_t *player, boolean skybox) if (!skybox && cv_glrenderdistance.value) { - GL_GClipRect((INT32)gl_viewwindowx, - (INT32)gl_viewwindowy, - (INT32)(gl_viewwindowx + gl_viewwidth), - (INT32)(gl_viewwindowy + gl_viewheight), + GL_GClipRect(viewwindowx, + viewwindowy, + (viewwindowx + viewwidth), + (viewwindowy + viewheight), ZCLIP_PLANE, clipping_distances[cv_glrenderdistance.value - 1]); current_bsp_culling_distance = bsp_culling_distances[cv_glrenderdistance.value - 1]; } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 4060b6540..43a292c57 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -42,10 +42,6 @@ extern "C" { void HWR_Startup(void); void HWR_Shutdown(void); -extern float gl_viewwidth, gl_viewheight, gl_baseviewwindowx, gl_baseviewwindowy; - -extern float gl_basewindowcenterx, gl_basewindowcentery; - extern unsigned msaa; extern boolean a2c; From bb0a59540f037ddb40db611764b2415601df7be9 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 14 Oct 2025 22:45:08 +0200 Subject: [PATCH 02/10] use stdlibs abs for CompareDrawNodePlanes we dont need our own abs for this --- src/hardware/hw_main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 88584a9da..382143dcb 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -65,8 +65,6 @@ // Globals // ========================================================================== -#define ABS(x) ((x) < 0 ? -(x) : (x)) - // false if shaders have not been initialized yet, or if shaders are not available boolean gl_shadersavailable = false; @@ -4330,7 +4328,7 @@ static int CompareDrawNodePlanes(const void *p1, const void *p2) const INT32 n1 = *(const INT32*)p1; const INT32 n2 = *(const INT32*)p2; - return ABS(drawnodes[n2].u.plane.fixedheight - viewz) - ABS(drawnodes[n1].u.plane.fixedheight - viewz); + return abs(drawnodes[n2].u.plane.fixedheight - viewz) - abs(drawnodes[n1].u.plane.fixedheight - viewz); } // From 4f91a0b23460d41377292324a8fd22588c0e6d97 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 14 Oct 2025 23:13:39 +0200 Subject: [PATCH 03/10] remove dead renderer code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remove - broken viewborder code (if we really want it back for some reason, we should rather port RR´s fixed version of it) - remove console clipping code for software (this was broken eiherway) - remove hud message clearing stuff - remove renderscreen and linesize variables (they just pointed to vid.screen and vid.widht) --- src/Makefile.d/sdl.mk | 2 +- src/console.c | 31 ------- src/console.h | 5 -- src/d_main.c | 9 -- src/doomtype.h | 1 - src/hardware/hw_draw.c | 200 +---------------------------------------- src/hardware/hw_main.h | 2 - src/hu_stuff.c | 70 --------------- src/hu_stuff.h | 1 - src/i_video.h | 2 +- src/m_menu.c | 3 +- src/r_draw.cpp | 147 +----------------------------- src/r_draw.h | 34 +------ src/r_main.cpp | 2 - src/r_plane.cpp | 2 +- src/r_segs.cpp | 5 +- src/r_things.cpp | 2 - src/screen.c | 7 +- src/screen.h | 2 - src/sdl/Srb2SDL.dsp | 4 +- src/sdl/Srb2SDL.props | 4 +- src/st_stuff.c | 4 - 22 files changed, 14 insertions(+), 525 deletions(-) diff --git a/src/Makefile.d/sdl.mk b/src/Makefile.d/sdl.mk index c704a83eb..95fe34e6a 100644 --- a/src/Makefile.d/sdl.mk +++ b/src/Makefile.d/sdl.mk @@ -10,7 +10,7 @@ makedir:=$(makedir)/SDL -opts+=-DDIRECTFULLSCREEN -DHAVE_SDL +opts+=-DHAVE_SDL sources+=$(call List,sdl/Sourcefile) NOUPNP=1 diff --git a/src/console.c b/src/console.c index fe91df0f3..3959d9b98 100644 --- a/src/console.c +++ b/src/console.c @@ -69,14 +69,9 @@ static boolean consoleready; // console prompt is ready INT32 con_destlines; // vid lines used by console at final position static INT32 con_curlines; // vid lines currently used by console - INT32 con_clipviewtop; // (useless) - static UINT8 con_hudlines; // number of console heads up message lines static UINT32 con_hudtime[MAXHUDLINES]; // remaining time of display for hud msg lines - INT32 con_clearlines; // top screen lines to refresh when view reduced - boolean con_hudupdate; // when messages scroll, we need a backgrnd refresh - // console text output static char *con_line; // console text output current line static size_t con_cx; // cursor position in current line @@ -393,9 +388,6 @@ void CON_Init(void) Lock_state(); - //note: CON_Ticker should always execute at least once before D_Display() - con_clipviewtop = -1; // -1 does not clip - con_hudlines = atoi(cons_hudlines.defaultvalue); Unlock_state(); @@ -727,7 +719,6 @@ void CON_ToggleOff(void) con_curlines = 0; CON_ClearHUD(); con_forcepic = 0; - con_clipviewtop = -1; // remove console clipping of view I_SetTextInput(false); @@ -779,18 +770,6 @@ void CON_Ticker(void) } } - // clip the view, so that the part under the console is not drawn - con_clipviewtop = -1; - if (cons_backpic.value) // clip only when using an opaque background - { - if (con_curlines > 0) - con_clipviewtop = con_curlines - viewwindowy - 1 - 10; - // NOTE: BIG HACK::SUBTRACT 10, SO THAT WATER DON'T COPY LINES OF THE CONSOLE - // WINDOW!!! (draw some more lines behind the bottom of the console) - if (con_clipviewtop < 0) - con_clipviewtop = -1; // maybe not necessary, provided it's < 0 - } - // check if console ready for prompt if (con_destlines >= minheight) { @@ -1100,9 +1079,6 @@ static void CON_Linefeed(void) con_line = &con_buffer[(con_cy%con_totallines)*con_width]; memset(con_line, ' ', con_width); - - // make sure the view borders are refreshed if hud messages scroll - con_hudupdate = true; // see HU_Erase() } // Outputs text into the console text buffer @@ -1489,9 +1465,6 @@ static void CON_DrawHudlines(void) //V_DrawCharacter(x, y, (p[c]&0xff) | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value); y += charheight; } - - // top screen lines that might need clearing when view is reduced - con_clearlines = y; // this is handled by HU_Erase(); } // draw the console background, text, and prompt if enough place @@ -1509,10 +1482,6 @@ static void CON_DrawConsole(void) if (con_curlines <= 0) return; - //FIXME: refresh borders only when console bg is translucent - con_clearlines = con_curlines; // clear console draw from view borders - con_hudupdate = true; // always refresh while console is on - // draw console background if (cons_backpic.value || con_forcepic) { diff --git a/src/console.h b/src/console.h index e704a87f1..79af2e48f 100644 --- a/src/console.h +++ b/src/console.h @@ -30,14 +30,9 @@ extern boolean con_recalc; extern boolean con_startup; -// top clip value for view render: do not draw part of view hidden by console -extern INT32 con_clipviewtop; - // 0 means console if off, or moving out extern INT32 con_destlines; -extern INT32 con_clearlines; // lines of top of screen to refresh -extern boolean con_hudupdate; // hud messages have changed, need refresh extern UINT32 con_scalefactor; // console text scale factor extern consvar_t cons_backcolor, cons_menuhighlight; diff --git a/src/d_main.c b/src/d_main.c index dd13c7b77..33dc57689 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -522,19 +522,16 @@ static boolean D_Display(void) case GS_LEVEL: if (!gametic) break; - HU_Erase(); AM_Drawer(); break; case GS_INTERMISSION: Y_IntermissionDrawer(); - HU_Erase(); HU_Drawer(); break; case GS_VOTING: Y_VoteDrawer(); - HU_Erase(); HU_Drawer(); break; @@ -549,7 +546,6 @@ static boolean D_Display(void) case GS_CUTSCENE: F_CutsceneDrawer(); - HU_Erase(); HU_Drawer(); break; @@ -559,7 +555,6 @@ static boolean D_Display(void) case GS_EVALUATION: F_GameEvaluationDrawer(); - HU_Erase(); HU_Drawer(); break; @@ -569,7 +564,6 @@ static boolean D_Display(void) case GS_CREDITS: F_CreditDrawer(); - HU_Erase(); HU_Drawer(); break; @@ -586,7 +580,6 @@ static boolean D_Display(void) { // I don't think HOM from nothing drawing is independent... F_WaitingPlayersDrawer(); - HU_Erase(); HU_Drawer(); } case GS_TIMEATTACK: @@ -1925,9 +1918,7 @@ void D_SRB2Main(void) G_LoadGameData(); -#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen -#endif // set user default mode or mode set at cmdline SCR_CheckDefaultMode(); diff --git a/src/doomtype.h b/src/doomtype.h index 81c09c007..78867ed69 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -43,7 +43,6 @@ extern "C" { #define UINT64 uint64_t #ifdef __APPLE_CC__ -#define DIRECTFULLSCREEN 1 #define DEBUG_LOG #define NOIPX #endif diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 1c014ce4c..cf8ab29e3 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -31,11 +31,6 @@ #include "../st_stuff.h" #include -#include "../i_video.h" // for rendermode != render_glide - -#ifndef O_BINARY -#define O_BINARY 0 -#endif typedef struct { @@ -58,68 +53,6 @@ static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111 static const float FLOATBASEVIDWIDTH = (float)BASEVIDWIDTH; static const float FLOATBASEVIDHEIGHT = (float)BASEVIDHEIGHT; -// -// -----------------+ -// HWR_DrawPatch : Draw a 'tile' graphic -// Notes : x,y : positions relative to the original Doom resolution -// : textes(console+score) + menus + status bar -// -----------------+ -void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option) -{ - FOutVector v[4]; - FBITFIELD flags; - GLPatch_t *hwrPatch; - -// 3--2 -// | /| -// |/ | -// 0--1 - float sdup = FIXED_TO_FLOAT(vid.fdup)*2.0f; - float pdup = FIXED_TO_FLOAT(vid.fdup)*2.0f; - - // make patch ready in hardware cache - HWR_GetPatch(gpatch); - hwrPatch = ((GLPatch_t *)gpatch->hardware); - - switch (option & V_SCALEPATCHMASK) - { - case V_NOSCALEPATCH: - pdup = 2.0f; - break; - case V_SMALLSCALEPATCH: - pdup = 2.0f * FIXED_TO_FLOAT(vid.smalldup*FRACUNIT); - break; - case V_MEDSCALEPATCH: - pdup = 2.0f * FIXED_TO_FLOAT(vid.meddup*FRACUNIT); - break; - } - - if (option & V_NOSCALESTART) - sdup = 2.0f; - - v[0].x = v[3].x = (x*sdup-gpatch->leftoffset*pdup)/vid.width - 1; - v[2].x = v[1].x = (x*sdup+(gpatch->width - gpatch->leftoffset)*pdup)/vid.width - 1; - v[0].y = v[1].y = 1-(y*sdup-gpatch->topoffset*pdup)/vid.height; - v[2].y = v[3].y = 1-(y*sdup+(gpatch->height - gpatch->topoffset)*pdup)/vid.height; - - v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; - - v[0].s = v[3].s = 0.0f; - v[2].s = v[1].s = hwrPatch->max_s; - v[0].t = v[1].t = 0.0f; - v[2].t = v[3].t = hwrPatch->max_t; - - flags = PF_Translucent|PF_NoDepthTest; - - if (option & V_WRAPX) - flags |= PF_ForceWrapX; - if (option & V_WRAPY) - flags |= PF_ForceWrapY; - - // clip it since it is used for bunny scroll in doom I - GL_DrawPolygon(NULL, v, 4, flags); -} - void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags) { FOutVector v[4]; @@ -636,137 +569,6 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height) } -// ========================================================================== -// R_DRAW.C STUFF -// ========================================================================== - -// ------------------ -// HWR_DrawViewBorder -// Fill the space around the view window with a Doom flat texture, draw the -// beveled edges. -// 'clearlines' is useful to clear the heads up messages, when the view -// window is reduced, it doesn't refresh all the view borders. -// ------------------ -void HWR_DrawViewBorder(INT32 clearlines) -{ -#if 0 - INT32 x, y; - INT32 top, side; - INT32 baseviewwidth, baseviewheight; - INT32 basewindowx, basewindowy; - patch_t *patch; - - if (!clearlines) - clearlines = BASEVIDHEIGHT; // refresh all - - // calc view size based on original game resolution - baseviewwidth = FixedInt(FixedDiv(viewwidth * FRACUNIT, vid.fdup)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7; - baseviewheight = FixedInt(FixedDiv(viewheight * FRACUNIT, vid.fdup)); - top = FixedInt(FixedDiv(baseviewwindowy * FRACUNIT, vid.fdup)); - side = FixedInt(FixedDiv(baseviewwindowx * FRACUNIT, vid.fdup)); - - // top - HWR_DrawFlatFill(0, 0, - BASEVIDWIDTH, (top < clearlines ? top : clearlines), - st_borderpatchnum); - - // left - if (top < clearlines) - HWR_DrawFlatFill(0, top, side, - (clearlines-top < baseviewheight ? clearlines-top : baseviewheight), - st_borderpatchnum); - - // right - if (top < clearlines) - HWR_DrawFlatFill(side + baseviewwidth, top, side, - (clearlines-top < baseviewheight ? clearlines-top : baseviewheight), - st_borderpatchnum); - - // bottom - if (top + baseviewheight < clearlines) - HWR_DrawFlatFill(0, top + baseviewheight, - BASEVIDWIDTH, BASEVIDHEIGHT, st_borderpatchnum); - - // - // draw the view borders - // - - basewindowx = (BASEVIDWIDTH - baseviewwidth)>>1; - if (baseviewwidth == BASEVIDWIDTH) - basewindowy = 0; - else - basewindowy = top; - - // top edge - if (clearlines > basewindowy - 8) - { - patch = W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH); - for (x = 0; x < baseviewwidth; x += 8) - HWR_DrawPatch(patch, basewindowx + x, basewindowy - 8, - 0); - } - - // bottom edge - if (clearlines > basewindowy + baseviewheight) - { - patch = W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH); - for (x = 0; x < baseviewwidth; x += 8) - HWR_DrawPatch(patch, basewindowx + x, - basewindowy + baseviewheight, 0); - } - - // left edge - if (clearlines > basewindowy) - { - patch = W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH); - for (y = 0; y < baseviewheight && basewindowy + y < clearlines; - y += 8) - { - HWR_DrawPatch(patch, basewindowx - 8, basewindowy + y, - 0); - } - } - - // right edge - if (clearlines > basewindowy) - { - patch = W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH); - for (y = 0; y < baseviewheight && basewindowy+y < clearlines; - y += 8) - { - HWR_DrawPatch(patch, basewindowx + baseviewwidth, - basewindowy + y, 0); - } - } - - // Draw beveled corners. - if (clearlines > basewindowy - 8) - HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TL], - PU_PATCH), - basewindowx - 8, basewindowy - 8, 0); - - if (clearlines > basewindowy - 8) - HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TR], - PU_PATCH), - basewindowx + baseviewwidth, basewindowy - 8, 0); - - if (clearlines > basewindowy+baseviewheight) - HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BL], - PU_PATCH), - basewindowx - 8, basewindowy + baseviewheight, 0); - - if (clearlines > basewindowy + baseviewheight) - HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BR], - PU_PATCH), - basewindowx + baseviewwidth, - basewindowy + baseviewheight, 0); -#else - (void)clearlines; -#endif -} - - - // ========================================================================== // AM_MAP.C DRAWING STUFF // ========================================================================== @@ -1172,7 +974,7 @@ static inline boolean saveTGA(const char *file_name, void *buffer, INT32 i; UINT8 *buf8 = buffer; - fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); + fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd < 0) return false; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 43a292c57..30906b611 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -85,7 +85,6 @@ extern ps_metric_t ps_hw_batchdrawtime; extern boolean gl_shadersavailable; // hw_draw.c -void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option); void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags); void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); @@ -94,7 +93,6 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color); void HWR_drawAMline(const fline_t *fl, INT32 color); void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength); void HWR_DrawConsoleBack(UINT32 color, INT32 height); -void HWR_DrawViewBorder(INT32 clearlines); void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum); UINT8 *HWR_GetScreenshot(INT32 scale); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6ca275aff..fa7060dff 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2391,76 +2391,6 @@ void HU_Drawer(void) } } -//====================================================================== -// HUD MESSAGES CLEARING FROM SCREEN -//====================================================================== - -// Clear old messages from the borders around the view window -// (only for reduced view, refresh the borders when needed) -// -// startline: y coord to start clear, -// clearlines: how many lines to clear. -// -static INT32 oldclearlines; - -void HU_Erase(void) -{ - INT32 topline, bottomline; - INT32 y, yoffset; - -#ifdef HWRENDER - // clear hud msgs on double buffer (OpenGL mode) - boolean secondframe; - static INT32 secondframelines; -#endif - - if (con_clearlines == oldclearlines && !con_hudupdate && !chat_on) - return; - -#ifdef HWRENDER - // clear the other frame in double-buffer modes - secondframe = (con_clearlines != oldclearlines); - if (secondframe) - secondframelines = oldclearlines; -#endif - - // clear the message lines that go away, so use _oldclearlines_ - bottomline = oldclearlines; - oldclearlines = con_clearlines; - if (chat_on && OLDCHAT) - if (bottomline < 8) - bottomline = 8; // only do it for consolechat. consolechat is gay. - - if (automapactive || viewwindowx == 0) // hud msgs don't need to be cleared - return; - - // software mode copies view border pattern & beveled edges from the backbuffer - if (rendermode == render_soft) - { - topline = 0; - for (y = topline, yoffset = y*vid.width; y < bottomline; y++, yoffset += vid.width) - { - if (y < viewwindowy || y >= viewwindowy + viewheight) - R_VideoErase(yoffset, vid.width); // erase entire line - else - { - R_VideoErase(yoffset, viewwindowx); // erase left border - // erase right border - R_VideoErase(yoffset + viewwindowx + viewwidth, viewwindowx); - } - } - con_hudupdate = false; // if it was set.. - } -#ifdef HWRENDER - else if (rendermode != render_none) - { - // refresh just what is needed from the view borders - HWR_DrawViewBorder(secondframelines); - con_hudupdate = secondframe; - } -#endif -} - //====================================================================== // IN-LEVEL MULTIPLAYER RANKINGS //====================================================================== diff --git a/src/hu_stuff.h b/src/hu_stuff.h index d134f319e..64d369a33 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -117,7 +117,6 @@ void HU_TickSongCredits(void); void HU_DrawSongCredits(void); void HU_Drawer(void); char HU_dequeueChatChar(void); -void HU_Erase(void); void HU_clearChatChars(void); void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags); // Lat': Ping drawer for scoreboard. //void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); diff --git a/src/i_video.h b/src/i_video.h index 822a1bada..852645c30 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -94,8 +94,8 @@ INT32 VID_SetMode(INT32 modenum); \return name of video mode */ const char *VID_GetModeName(INT32 modenum); -void VID_PrepareModeList(void); /// note hack for SDL +void VID_PrepareModeList(void); /** \brief can video system do fullscreen */ diff --git a/src/m_menu.c b/src/m_menu.c index 95824c7dd..ed39e053f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9442,9 +9442,8 @@ static void M_VideoModeMenu(INT32 choice) memset(modedescs, 0, sizeof(modedescs)); -#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) VID_PrepareModeList(); // FIXME: hack -#endif + vidm_nummodes = 0; vidm_selected = 0; nummodes = VID_NumModes(); diff --git a/src/r_draw.cpp b/src/r_draw.cpp index c8a09745a..91de5e102 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -41,8 +41,7 @@ /** \brief view info */ -INT32 linesize, viewwidth, viewheight, viewwindowx, viewwindowy; -UINT8 *renderscreen; // haleyjd +INT32 viewwidth, viewheight, viewwindowx, viewwindowy; // ========================================================================= // COLUMN DRAWING CODE STUFF @@ -521,7 +520,6 @@ static void R_AllocViewMemory(void) R_AllocVisSpriteMemory(); } - void R_InitViewBuffer(INT32 width, INT32 height) { if (width > MAXVIDWIDTH) @@ -534,27 +532,7 @@ void R_InitViewBuffer(INT32 width, INT32 height) viewwindowx = 0; viewwindowy = 0; - linesize = vid.width; // killough 11/98 - renderscreen = vid.screens[0]; // haleyjd 07/02/14 -} -/** \brief viewborder patches lump numbers -*/ -lumpnum_t viewborderlump[8]; - -/** \brief Store the lumpnumber of the viewborder patches -*/ - -void R_InitViewBorder(void) -{ - viewborderlump[BRDR_T] = W_GetNumForName("brdr_t"); - viewborderlump[BRDR_B] = W_GetNumForName("brdr_b"); - viewborderlump[BRDR_L] = W_GetNumForName("brdr_l"); - viewborderlump[BRDR_R] = W_GetNumForName("brdr_r"); - viewborderlump[BRDR_TL] = W_GetNumForName("brdr_tl"); - viewborderlump[BRDR_BL] = W_GetNumForName("brdr_bl"); - viewborderlump[BRDR_TR] = W_GetNumForName("brdr_tr"); - viewborderlump[BRDR_BR] = W_GetNumForName("brdr_br"); } /** \brief The R_VideoErase function @@ -578,129 +556,6 @@ void R_VideoErase(size_t ofs, INT32 count) M_Memcpy(vid.screens[0] + ofs, vid.screens[1] + ofs, count); } - -#if 0 -/** \brief R_FillBackScreen - - Fills the back screen with a pattern for variable screen sizes - Also draws a beveled edge. -*/ -void R_FillBackScreen(void) -{ - UINT8 *src, *dest; - patch_t *patch; - INT32 x, y, step, boff; - - // quickfix, don't cache lumps in both modes - if (rendermode != render_soft) - return; - - // draw pattern around the status bar too (when hires), - // so return only when in full-screen without status bar. - if (scaledviewwidth == vid.width && viewheight == vid.height) - return; - - src = scr_borderpatch; - dest = vid.screens[1]; - - for (y = 0; y < vid.height; y++) - { - for (x = 0; x < vid.width/128; x++) - { - M_Memcpy (dest, src+((y&127)<<7), 128); - dest += 128; - } - - if (vid.width&127) - { - M_Memcpy(dest, src+((y&127)<<7), vid.width&127); - dest += (vid.width&127); - } - } - - // don't draw the borders when viewwidth is full vid.width. - if (scaledviewwidth == vid.width) - return; - - step = 8; - boff = 8; - - patch = W_CacheLumpNum(viewborderlump[BRDR_T], PU_CACHE); - for (x = 0; x < scaledviewwidth; x += step) - V_DrawPatch(viewwindowx + x, viewwindowy - boff, 1, patch); - - patch = W_CacheLumpNum(viewborderlump[BRDR_B], PU_CACHE); - for (x = 0; x < scaledviewwidth; x += step) - V_DrawPatch(viewwindowx + x, viewwindowy + viewheight, 1, patch); - - patch = W_CacheLumpNum(viewborderlump[BRDR_L], PU_CACHE); - for (y = 0; y < viewheight; y += step) - V_DrawPatch(viewwindowx - boff, viewwindowy + y, 1, patch); - - patch = W_CacheLumpNum(viewborderlump[BRDR_R],PU_CACHE); - for (y = 0; y < viewheight; y += step) - V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy + y, 1, - patch); - - // Draw beveled corners. - V_DrawPatch(viewwindowx - boff, viewwindowy - boff, 1, - W_CacheLumpNum(viewborderlump[BRDR_TL], PU_CACHE)); - V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy - boff, 1, - W_CacheLumpNum(viewborderlump[BRDR_TR], PU_CACHE)); - V_DrawPatch(viewwindowx - boff, viewwindowy + viewheight, 1, - W_CacheLumpNum(viewborderlump[BRDR_BL], PU_CACHE)); - V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy + viewheight, 1, - W_CacheLumpNum(viewborderlump[BRDR_BR], PU_CACHE)); -} - -/** \brief The R_DrawViewBorder - - Draws the border around the view - for different size windows? -*/ -void R_DrawViewBorder(void) -{ - INT32 top, side, ofs; - - if (rendermode == render_none) - return; -#ifdef HWRENDER - if (rendermode != render_soft) - { - HWR_DrawViewBorder(0); - return; - } - else -#endif - -#ifdef DEBUG - fprintf(stderr,"RDVB: vidwidth %d vidheight %d scaledviewwidth %d viewheight %d\n", - vid.width, vid.height, scaledviewwidth, viewheight); -#endif - - if (scaledviewwidth == vid.width) - return; - - top = (vid.height - viewheight)>>1; - side = (vid.width - scaledviewwidth)>>1; - - // copy top and one line of left side - R_VideoErase(0, top*vid.width+side); - - // copy one line of right side and bottom - ofs = (viewheight+top)*vid.width - side; - R_VideoErase(ofs, top*vid.width + side); - - // copy sides using wraparound - ofs = top*vid.width + vid.width-side; - side <<= 1; - - // simpler using our VID_Blit routine - VID_BlitLinearScreen(vid.screens[1] + ofs, vid.screens[0] + ofs, side, viewheight - 1, - vid.width, vid.width); -} -#endif - // ========================================================================== // INCLUDE DRAWING CODE HERE // ========================================================================== diff --git a/src/r_draw.h b/src/r_draw.h index bcd734e50..eaee19039 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -25,12 +25,10 @@ extern "C" { // ------------------------------- // COMMON STUFF FOR 8bpp AND 16bpp // ------------------------------- -extern UINT8 *renderscreen; -extern INT32 linesize; FUNCINLINE static ATTRINLINE UINT8 *R_Address(INT32 px, INT32 py) { - return renderscreen + (py + viewwindowy) * linesize + (viewwindowx + px); + return vid.screens[0] + (py + viewwindowy) * vid.width + (viewwindowx + px); } @@ -152,27 +150,8 @@ extern spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX]; void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column); -/// \brief Top border -#define BRDR_T 0 -/// \brief Bottom border -#define BRDR_B 1 -/// \brief Left border -#define BRDR_L 2 -/// \brief Right border -#define BRDR_R 3 -/// \brief Topleft border -#define BRDR_TL 4 -/// \brief Topright border -#define BRDR_TR 5 -/// \brief Bottomleft border -#define BRDR_BL 6 -/// \brief Bottomright border -#define BRDR_BR 7 - -extern lumpnum_t viewborderlump[8]; - // ------------------------------------------------ -// r_draw.c COMMON ROUTINES FOR BOTH 8bpp and 16bpp +// r_draw.c // ------------------------------------------------ #define GTC_CACHE 1 @@ -221,17 +200,8 @@ boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel); // Custom player skin translation void R_InitViewBuffer(INT32 width, INT32 height); -void R_InitViewBorder(void); void R_VideoErase(size_t ofs, INT32 count); -// Rendering function. -#if 0 -void R_FillBackScreen(void); - -// If the view size is not full screen, draws a border around it. -void R_DrawViewBorder(void); -#endif - #define TRANSPARENTPIXEL 247 // ----------------- diff --git a/src/r_main.cpp b/src/r_main.cpp index 08f1e68a1..a392db087 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1023,8 +1023,6 @@ void R_Init(void) //I_OutputMsg("\nR_InitData"); R_InitData(); - //I_OutputMsg("\nR_InitViewBorder"); - R_InitViewBorder(); R_SetViewSize(); // setsizeneeded is set true // this is now done by SCR_Recalc() at the first mode set diff --git a/src/r_plane.cpp b/src/r_plane.cpp index de713dc9c..484aab49c 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -787,7 +787,7 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), b drawcolumndata_t dc = {}; const INT32 texture = texturetranslation[skytexture]; - // Reset column drawer function (note: couldn't we just call walldrawerfunc directly?) + // Reset column drawer function (note: couldn't we just call colfuncs[BASEDRAWFUNC] directly?) // (that is, unless we'll need to switch drawers in future for some reason) R_SetColumnFunc(BASEDRAWFUNC); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index c83b45593..b4f8cdbcd 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -26,7 +26,6 @@ #include "p_local.h" // Camera... #include "p_setup.h" #include "p_slopes.h" -#include "console.h" // con_clipviewtop #include "screen.h" #include "core/memory.h" @@ -628,8 +627,6 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf sector_t tempsec; INT32 templight; INT32 i, p; - fixed_t bottombounds = viewheight << FRACBITS; - fixed_t topbounds = (con_clipviewtop - 1) << FRACBITS; fixed_t offsetvalue = 0; lightlist_t *light; r_lightlist_t *rlight; @@ -936,7 +933,7 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf bottom_frac += bottom_step; // SoM: If column is out of range, why bother with it?? - if (windowbottom < topbounds || windowtop > bottombounds) + if (windowbottom < 0 || windowtop > (viewheight << FRACBITS)) { if (dc->numlights) { diff --git a/src/r_things.cpp b/src/r_things.cpp index 12d02d329..d69e7ea4e 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2518,8 +2518,6 @@ void R_InitDrawNodes(void) // R_DrawSprite // //Fab : 26-04-98: -// NOTE : uses con_clipviewtop, so that when console is on, -// don't draw the part of sprites hidden under the console static void R_DrawSprite(vissprite_t *spr) { mfloorclip = spr->clipbot; diff --git a/src/screen.c b/src/screen.c index 8d2782ab8..9a8109066 100644 --- a/src/screen.c +++ b/src/screen.c @@ -80,10 +80,6 @@ consvar_t cv_accuratefps = {"fpssampling", "1", CV_SAVE, accuratefps_cons_t, NUL // SCREEN VARIABLES // ========================================================================= -UINT8 *scr_borderpatch; // flat used to fill the reduced view borders set at ST_Init() - -// ========================================================================= - static void SCR_SetDrawFuncs(void) { // @@ -298,7 +294,6 @@ void SCR_SetDefaultMode(void) // Change fullscreen on/off according to cv_fullscreen void SCR_ChangeFullscreen(void) { -#ifdef DIRECTFULLSCREEN I_SetBorderlessWindow(); // Running this here so we can have borderless window at startup // allow_fullscreen is set by VID_PrepareModeList @@ -311,8 +306,8 @@ void SCR_ChangeFullscreen(void) VID_PrepareModeList(); setmodeneeded = VID_GetModeForSize(vid.width, vid.height) + 1; } + return; -#endif } boolean SCR_IsAspectCorrect(INT32 width, INT32 height) diff --git a/src/screen.h b/src/screen.h index ecad24a64..fb234324f 100644 --- a/src/screen.h +++ b/src/screen.h @@ -84,8 +84,6 @@ enum extern viddef_t vid; extern INT32 setmodeneeded; // mode number to set if needed, or 0 -extern UINT8 *scr_borderpatch; // patch used to fill the view borders - extern consvar_t cv_scr_width, cv_scr_height, cv_renderview, cv_frameskip, cv_fullscreen, cv_vhseffect, cv_shittyscreen; extern consvar_t cv_parallelsoftware; extern consvar_t cv_paralleldrawmasked; diff --git a/src/sdl/Srb2SDL.dsp b/src/sdl/Srb2SDL.dsp index 47ede4126..96d3e8418 100644 --- a/src/sdl/Srb2SDL.dsp +++ b/src/sdl/Srb2SDL.dsp @@ -45,7 +45,7 @@ MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c +# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" # SUBTRACT RSC /x @@ -72,7 +72,7 @@ LINK32=link.exe # PROP Target_Dir "" MTL=midl.exe # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c +# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" diff --git a/src/sdl/Srb2SDL.props b/src/sdl/Srb2SDL.props index f02b9b35e..8c4799f20 100644 --- a/src/sdl/Srb2SDL.props +++ b/src/sdl/Srb2SDL.props @@ -6,9 +6,9 @@ - HAVE_ZLIB;HAVE_LIBGME;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) + HAVE_ZLIB;HAVE_LIBGME;USE_WGL_SWAP;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) - USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) + USE_WGL_SWAP;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) diff --git a/src/st_stuff.c b/src/st_stuff.c index f5634423c..fade7c484 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -219,10 +219,6 @@ void ST_UnloadGraphics(void) void ST_LoadGraphics(void) { - // SRB2 border patch - //st_borderpatchnum = W_GetNumForName("GFZFLR01"); - //scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX); - // the original Doom uses 'STF' as base name for all face graphics // Graue 04-08-2004: face/name graphics are now indexed by skins // but load them in R_AddSkins, that gets called From 64bdae5e5d37ab8f7913ffded4337c8eee9338d7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 14 Oct 2025 23:23:04 +0200 Subject: [PATCH 04/10] delet dead code ogl models --- src/hardware/hw_model.c | 145 ---------------------------------------- src/hardware/hw_model.h | 6 -- 2 files changed, 151 deletions(-) diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c index e77cf43ef..6a9825402 100644 --- a/src/hardware/hw_model.c +++ b/src/hardware/hw_model.c @@ -114,7 +114,6 @@ void UnloadModel(model_t *model) if (model->materials) Z_Free(model->materials); - DeleteVBOs(model); Z_Free(model); } @@ -194,7 +193,6 @@ model_t *LoadModel(const char *filename, int ztag) strcpy(model->mdlFilename, filename); Optimize(model); - GeneratePolygonNormals(model, ztag); // Default material properties for (i = 0 ; i < model->numMaterials; i++) @@ -246,13 +244,6 @@ void GenerateVertexNormals(model_t *model) M_Memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3); -/* if (!systemSucks) - { - memTag = Z_GetTag(frame->tangents); - float *newTangents = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag); - M_Memcpy(newTangents, frame->tangents, sizeof(float)*3*mesh->numTriangles*3); - }*/ - for (k = 0; k < mesh->numVertices; k++) { float x, y, z; @@ -288,32 +279,15 @@ void GenerateVertexNormals(model_t *model) if (vCount > 1) { -// Vector::Normalize(&normal); newNormals[3 * k + 0] = (float)normal.x; newNormals[3 * k + 1] = (float)normal.y; newNormals[3 * k + 2] = (float)normal.z; - -/* if (!systemSucks) - { - Vector::vector_t tangent; - Vector::Tangent(&normal, &tangent); - newTangents[3 * k + 0] = tangent.x; - newTangents[3 * k + 1] = tangent.y; - newTangents[3 * k + 2] = tangent.z; - }*/ } } oldNormals = frame->normals; frame->normals = newNormals; Z_Free(oldNormals); - -/* if (!systemSucks) - { - float *oldTangents = frame->tangents; - frame->tangents = newTangents; - Z_Free(oldTangents); - }*/ } } } @@ -404,15 +378,11 @@ void Optimize(model_t *model) newMesh->numTriangles = numTriangles; newMesh->numVertices = numTriangles * 3; newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0); -// if (node->material->lightmap) -// newMesh->lightuvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0); newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0); curFrame = &newMesh->frames[0]; curFrame->material = curMat; curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); -// if (!systemSucks) -// curFrame->tangents = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0); @@ -436,12 +406,6 @@ void Optimize(model_t *model) curMesh->uvs, sizeof(float)*2*curMesh->numTriangles*3); -/* if (node->material->lightmap) - { - M_Memcpy(&newMesh->lightuvs[uvCount], - curMesh->lightuvs, - sizeof(float)*2*curMesh->numTriangles*3); - }*/ uvCount += 2*curMesh->numTriangles*3; dest = (float*)newMesh->frames[0].vertices; @@ -456,15 +420,6 @@ void Optimize(model_t *model) src, sizeof(float)*3*curMesh->numTriangles*3); -/* if (!systemSucks) - { - dest = (float*)newMesh->frames[0].tangents; - src = (float*)curMesh->frames[0].tangents; - M_Memcpy(&dest[vertCount], - src, - sizeof(float)*3*curMesh->numTriangles*3); - }*/ - vertCount += 3 * curMesh->numTriangles * 3; destByte = (char*)newMesh->frames[0].colors; @@ -494,103 +449,3 @@ void Optimize(model_t *model) model->meshes = newMeshes; model->numMeshes = numMeshes; } - -void GeneratePolygonNormals(model_t *model, int ztag) -{ - int i; - for (i = 0; i < model->numMeshes; i++) - { - int j; - mesh_t *mesh = &model->meshes[i]; - - if (!mesh->frames) - continue; - - for (j = 0; j < mesh->numFrames; j++) - { - int k; - mdlframe_t *frame = &mesh->frames[j]; - const float *vertices = frame->vertices; - vector_t *polyNormals; - - frame->polyNormals = (vector_t*)Z_Malloc(sizeof(vector_t) * mesh->numTriangles, ztag, 0); - - polyNormals = frame->polyNormals; - - for (k = 0; k < mesh->numTriangles; k++) - { - /// TODO: normalize vectors - (void)vertices; - (void)polyNormals; -// Vector::Normal(vertices, polyNormals); - vertices += 3 * 3; - polyNormals++; - } - } - } -} - -// -// Reload -// -// Reload VBOs -// -#if 0 -static void Reload(void) -{ -/* model_t *node; - for (node = modelHead; node; node = node->next) - { - int i; - for (i = 0; i < node->numMeshes; i++) - { - mesh_t *mesh = &node->meshes[i]; - - if (mesh->frames) - { - int j; - for (j = 0; j < mesh->numFrames; j++) - CreateVBO(mesh, &mesh->frames[j]); - } - else if (mesh->tinyframes) - { - int j; - for (j = 0; j < mesh->numFrames; j++) - CreateVBO(mesh, &mesh->tinyframes[j]); - } - } - }*/ -} -#endif - -void DeleteVBOs(model_t *model) -{ - (void)model; -/* for (int i = 0; i < model->numMeshes; i++) - { - mesh_t *mesh = &model->meshes[i]; - - if (mesh->frames) - { - for (int j = 0; j < mesh->numFrames; j++) - { - mdlframe_t *frame = &mesh->frames[j]; - if (!frame->vboID) - continue; - bglDeleteBuffers(1, &frame->vboID); - frame->vboID = 0; - } - } - else if (mesh->tinyframes) - { - for (int j = 0; j < mesh->numFrames; j++) - { - tinyframe_t *frame = &mesh->tinyframes[j]; - if (!frame->vboID) - continue; - bglDeleteBuffers(1, &frame->vboID); - frame->vboID = 0; - } - } - }*/ -} diff --git a/src/hardware/hw_model.h b/src/hardware/hw_model.h index 1803f4c5c..fcd574bd4 100644 --- a/src/hardware/hw_model.h +++ b/src/hardware/hw_model.h @@ -28,8 +28,6 @@ typedef struct float ambient[4], diffuse[4], specular[4], emissive[4]; float shininess; boolean spheremap; -// Texture::texture_t *texture; -// Texture::texture_t *lightmap; } material_t; typedef struct @@ -40,7 +38,6 @@ typedef struct float *tangents; char *colors; unsigned int vboID; - vector_t *polyNormals; } mdlframe_t; typedef struct @@ -70,7 +67,6 @@ typedef struct mesh_s typedef struct tag_s { char name[64]; -// matrix_t transform; } tag_t; typedef struct model_s @@ -96,9 +92,7 @@ model_t *LoadModel(const char *filename, int ztag); void UnloadModel(model_t *model); void Optimize(model_t *model); void GenerateVertexNormals(model_t *model); -void GeneratePolygonNormals(model_t *model, int ztag); void CreateVBOTiny(mesh_t *mesh, tinyframe_t *frame); void CreateVBO(mesh_t *mesh, mdlframe_t *frame); -void DeleteVBOs(model_t *model); #endif From a87e07155af4a8b94397a9ac2e896d4a67893c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sat, 19 Apr 2025 11:13:14 +0200 Subject: [PATCH 05/10] Remove WINSOCK1 support WINSOCK2 has been supported since Windows XP and is required for IPv6, so I don't see a reason to support it anymore. --- src/i_addrinfo.c | 680 ----------------------------------------------- src/i_addrinfo.h | 71 ----- src/i_tcp.c | 131 +++------ 3 files changed, 44 insertions(+), 838 deletions(-) delete mode 100644 src/i_addrinfo.c delete mode 100644 src/i_addrinfo.h diff --git a/src/i_addrinfo.c b/src/i_addrinfo.c deleted file mode 100644 index f9d860bd1..000000000 --- a/src/i_addrinfo.c +++ /dev/null @@ -1,680 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 2011-2018 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 i_addrinfo.c -/// \brief getaddr stubs, for lesser OSes -/// -/// Some systems/SDKs, like PSL1GHT v2 does not have addrinfo functions -/// So a stub is needed -#include -#include -#include -#ifdef _WIN32 -#ifdef USE_WINSOCK2 -#include -#else -#include -#endif -#else -#include -#include -#include -#endif - -#include "i_addrinfo.h" - -/* - * This addrinfo stub have a testcases: - * To test the stub, use this command to compile the stub testcase: - * gcc -g -DTESTCASE -Dtest_stub -Wall -W i_addrinfo.c -o stub - * To test the real getaddrinfo API, use this command to get real one: - * gcc -g -DTESTCASE -Utest_stub -Wall -W i_addrinfo.c -o real - * For Win32,you need the WinSock library, version 1.1 or 2.2 - * for 1.1, add -lwsock32 - * i686-w64-mingw32-gcc -g -DTESTCASE -Dtest_stub -UUSE_WINSOCK2 -Wall -W i_addrinfo.c -o stub.exe -lwsock32 - * for 2.2, add -DUSE_WINSOCK2 -lws2_32 - * i686-w64-mingw32-gcc -g -DTESTCASE -Utest_stub -DUSE_WINSOCK2 -Wall -W i_addrinfo.c -o real.exe -lws2_32 - */ - -#ifndef I_getaddrinfo - -#include - -#ifdef _WIN32 -// it seems windows doesn't define that... maybe some other OS? OS/2 -static int inet_aton(const char *cp, struct in_addr *addr) -{ - if( cp == NULL || addr == NULL ) - { - return(0); - } - if (strcmp(cp, "255.255.255.225") == 0) - { - addr->s_addr = htonl(INADDR_BROADCAST); - return 0; - } - return (addr->s_addr = inet_addr(cp)) != htonl(INADDR_NONE); -} -#endif - -#ifdef USE_WINSOCK2 -static HMODULE ipv6dll = NULL; -typedef int (WSAAPI *p_getaddrinfo) (const char *, const char *, - const struct my_addrinfo *, - struct my_addrinfo **); -typedef void (WSAAPI *p_freeaddrinfo) (struct my_addrinfo *); - -static p_getaddrinfo WS_getaddrinfo = NULL; -static p_freeaddrinfo WS_freeaddrinfo = NULL; - -static HMODULE WS_getfunctions(HMODULE tmp) -{ - if (tmp != NULL) - { - WS_getaddrinfo = (p_getaddrinfo)(LPVOID)GetProcAddress(tmp, "getaddrinfo"); - if (WS_getaddrinfo == NULL) - return NULL; - WS_freeaddrinfo = (p_freeaddrinfo)(LPVOID)GetProcAddress(tmp, "freeaddrinfo"); - if (WS_freeaddrinfo == NULL) - { - WS_getaddrinfo = NULL; - return NULL; - } - } - return tmp; -} - -static void WS_addrinfosetup(void) -{ - if (WS_getaddrinfo && WS_freeaddrinfo) - return; // already have the functions - // why not hold it into ipv6dll? becase we already link with ws2_32, silly! - if (WS_getfunctions(GetModuleHandleA("ws2_32.dll")) == NULL) - ipv6dll = WS_getfunctions(LoadLibraryA("wship6.dll")); -} - -void WS_addrinfocleanup(void) -{ - if (ipv6dll) - FreeLibrary(ipv6dll); - ipv6dll = NULL; - WS_getaddrinfo = NULL; - WS_freeaddrinfo = NULL; -} -#else -void WS_addrinfocleanup(void) {} -#endif - -int I_getaddrinfo(const char *node, const char *service, - const struct my_addrinfo *hints, - struct my_addrinfo **res) -{ - struct hostent *nodename = NULL; - bool hostlookup = true, passivemode = false; - int flags = 0; - int socktype = 0; - int sockport = 0; - struct my_addrinfo *ai; - struct sockaddr_in *addr; - struct in_addr ipv4; - size_t addrlen = 1; - size_t ailen = 1, i = 0, j; - size_t famsize = sizeof(struct sockaddr_in); -#ifdef USE_WINSOCK2 - WS_addrinfosetup(); - if (WS_getaddrinfo) - return WS_getaddrinfo(node, service, hints, res); -#endif - - // param check - if (node == NULL && service == NULL) - return EAI_NONAME; - //note: testcase show NULL as res crashes libc - if (res == NULL) - return -1; - - // check hints - if (hints) - { - // no support for IPv6 - if (hints->ai_family != AF_INET && hints->ai_family != AF_UNSPEC) - return -1; //EAI_FAMILY -#ifdef AI_NUMERICHOST - // do not look up hostnames - if ((hints->ai_flags & AI_NUMERICHOST) == AI_NUMERICHOST) - { - hostlookup = false; - flags |= AI_NUMERICHOST; - } -#endif -#ifdef AI_PASSIVE - // return loopback or any address? - if ((hints->ai_flags & AI_PASSIVE) == AI_PASSIVE) - { - passivemode = true; - flags |= AI_PASSIVE; - } -#endif - // why no support for canon names? lazy - //AI_CANONNAME - // what kind of socket? - socktype = hints->ai_socktype; - } - else - { -#ifdef AI_V4MAPPED - flags |= AI_V4MAPPED; -#endif -#ifdef AI_ADDRCONFIG - flags |= AI_ADDRCONFIG; -#endif - } - - // we need gethostbyname to convert numeric strings - if (node && hostlookup) - { - if (node == NULL) - return -1; - nodename = gethostbyname(node); - if (nodename == NULL) - { - if (inet_aton(node, &ipv4) != 0) - addrlen = 1; - else - return -1; - } - else while (nodename->h_addr_list[addrlen] != NULL) - addrlen++; - } - else if (node) - { - if (inet_aton(node, &ipv4) != 0) - addrlen = 1; - else if (!hostlookup) - return EAI_NONAME; - } - else - addrlen = 1; - - if (service) //AI_NUMERICSERV - sockport = atoi(service); - - if (socktype == 0) - ailen = addrlen*3; - else - ailen = addrlen; - - ai = calloc(ailen, sizeof(struct my_addrinfo)); - if (ai == NULL) - return -1; - else - *res = ai; - - addr = calloc(ailen*2, famsize); - if (addr == NULL) - { - free(ai); - return -1; - } - else - ai->ai_addr = memset(addr, 0x00, ailen*ai->ai_addrlen); - - for (i = 0; i < ailen; i++) - { - ai = *res+i; - ai->ai_flags = flags; - ai->ai_family = AF_INET; - ai->ai_socktype = socktype; - switch (ai->ai_socktype) - { - case SOCK_STREAM: - ai->ai_protocol = IPPROTO_TCP; - break; - case SOCK_DGRAM: - ai->ai_protocol = IPPROTO_UDP; - break; - default: - ai->ai_protocol = 0; - } - ai->ai_addrlen = famsize; - ai->ai_addr = (struct sockaddr *)&addr[i]; - //ai_cannonname - ai->ai_next = ai+1; - } - ai->ai_next = NULL; - ai = *res; - - for (i = 0, j = 0; i < ailen; i++, j++) - { - ai = *res+i; - addr[i].sin_port = htons((UINT16)sockport); - if (nodename) - { - memcpy(&addr[i].sin_addr, nodename->h_addr_list[j], ai->ai_addrlen); - addr[i].sin_family = nodename->h_addrtype; - } - else if (node) - { - memcpy(&addr[i].sin_addr, &ipv4, ai->ai_addrlen); - addr[i].sin_family = AF_INET; - } - else - { - if (passivemode) - addr[i].sin_addr.s_addr = htonl(INADDR_ANY); - else - addr[i].sin_addr.s_addr = htonl(INADDR_LOOPBACK); - addr[i].sin_family = AF_INET; - } - if (socktype == 0) - { - ai->ai_socktype = SOCK_STREAM; - ai->ai_protocol = IPPROTO_TCP; - memcpy(&addr[i+1], &addr[i], ai->ai_addrlen); - i++; ai++; - ai->ai_socktype = SOCK_DGRAM; - ai->ai_protocol = IPPROTO_UDP; - memcpy(&addr[i+1], &addr[i], ai->ai_addrlen); - i++; ai++; - ai->ai_socktype = SOCK_RAW; - ai->ai_protocol = IPPROTO_IP; - } - } - return 0; -} -#endif - -#ifndef I_freeaddrinfo -void I_freeaddrinfo(struct my_addrinfo *res) -{ -#ifdef USE_WINSOCK2 - if (WS_freeaddrinfo) - { - WS_freeaddrinfo(res); - return; - } -#endif - if (!res) - return; - free(res->ai_addr); - free(res); -} -#endif - -#ifdef TESTCASE -#include - -#ifdef USE_WINSOCK2 -#define inet_ntop inet_ntopA -#define HAVE_NTOP -static const char* inet_ntopA(int af, const void *cp, char *buf, socklen_t len) -{ - DWORD Dlen = len, AFlen = 0; - SOCKADDR_STORAGE any; - LPSOCKADDR anyp = (LPSOCKADDR)&any; - LPSOCKADDR_IN any4 = (LPSOCKADDR_IN)&any; - LPSOCKADDR_IN6 any6 = (LPSOCKADDR_IN6)&any; - - if (!buf) - { - WSASetLastError(STATUS_INVALID_PARAMETER); - return NULL; - } - - if (af != AF_INET && af != AF_INET6) - { - WSASetLastError(WSAEAFNOSUPPORT); - return NULL; - } - - ZeroMemory(&any, sizeof(SOCKADDR_STORAGE)); - any.ss_family = af; - - switch (af) - { - case AF_INET: - { - CopyMemory(&any4->sin_addr, cp, sizeof(IN_ADDR)); - AFlen = sizeof(SOCKADDR_IN); - break; - } - case AF_INET6: - { - CopyMemory(&any6->sin6_addr, cp, sizeof(IN6_ADDR)); - AFlen = sizeof(SOCKADDR_IN6); - break; - } - } - - if (WSAAddressToStringA(anyp, AFlen, NULL, buf, &Dlen) == SOCKET_ERROR) - return NULL; - return buf; -} -#elif defined (_WIN32) -// w32api, ws2tcpip.h, r1.12 -static inline char* gai_strerror(int ecode) -{ - static char message[1024+1]; - DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_IGNORE_INSERTS - | FORMAT_MESSAGE_MAX_WIDTH_MASK; - DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT); - FormatMessageA(dwFlags, NULL, ecode, dwLanguageId, message, 1024, NULL); - return message; -} -#else -#define HAVE_NTOP -#endif - -#ifndef INET_ADDRSTRLEN -#define INET_ADDRSTRLEN 16 -#endif - -static inline void printflags(int ai_flags) -{ - printf("flags: %x(", ai_flags); - if (ai_flags == 0) - printf("NONE|"); -#ifdef AI_PASSIVE - if ((ai_flags & AI_PASSIVE) == AI_PASSIVE) - printf("AI_PASSIVE|"); - ai_flags &= ~AI_PASSIVE; -#endif -#ifdef AI_CANONNAME - if ((ai_flags & AI_CANONNAME) == AI_CANONNAME) - printf("AI_CANONNAME|"); - ai_flags &= ~AI_CANONNAME; -#endif -#ifdef AI_NUMERICHOST - if ((ai_flags & AI_NUMERICHOST) == AI_NUMERICHOST) - printf("AI_NUMERICHOST|"); - ai_flags &= ~AI_NUMERICHOST; -#endif -#ifdef AI_V4MAPPED - if ((ai_flags & AI_V4MAPPED) == AI_V4MAPPED) - printf("AI_V4MAPPED|"); - ai_flags &= ~AI_V4MAPPED; -#endif -#ifdef AI_ALL - if ((ai_flags & AI_ALL) == AI_ALL) - printf("AI_ALL|"); - ai_flags &= ~AI_ALL; -#endif -#ifdef AI_ADDRCONFIG - if ((ai_flags & AI_ADDRCONFIG) == AI_ADDRCONFIG) - printf("AI_ADDRCONFIG|"); - ai_flags &= ~AI_ADDRCONFIG; -#endif -#ifdef AI_IDN - if ((ai_flags & AI_IDN) == AI_IDN) - printf("AI_IDN|"); - ai_flags &= ~AI_IDN; -#endif -#ifdef AI_CANONIDN - if ((ai_flags & AI_CANONIDN) == AI_CANONIDN) - printf("AI_CANONIDN|"); - ai_flags &= ~AI_CANONIDN; -#endif -#ifdef AI_IDN_ALLOW_UNASSIGNED - if ((ai_flags & AI_IDN_ALLOW_UNASSIGNED) == AI_IDN_ALLOW_UNASSIGNED) - printf("AI_IDN_ALLOW_UNASSIGNED|"); - ai_flags &= ~AI_IDN_ALLOW_UNASSIGNED; -#endif -#ifdef AI_IDN_USE_STD3_ASCII_RULES - if ((ai_flags & AI_IDN_USE_STD3_ASCII_RULES) == AI_IDN_USE_STD3_ASCII_RULES) - printf("AI_IDN_USE_STD3_ASCII_RULES|"); - ai_flags &= ~AI_PASSIVE; -#endif -#ifdef AI_NUMERICSERV - if ((ai_flags & AI_NUMERICSERV) == AI_NUMERICSERV) - printf("AI_NUMERICSERV|"); - ai_flags &= ~AI_NUMERICSERV; -#endif - printf("%x", ai_flags); - printf(")\n"); -} - -static inline void printsocktype(int ai_socktype) -{ - printf("socktype: %d(", ai_socktype); - switch (ai_socktype) - { - case 0: - printf("SOCK_ Woe32"); - break; - case SOCK_STREAM: - printf("SOCK_STREAM"); - break; - case SOCK_DGRAM: - printf("SOCK_DGRAM"); - break; - case SOCK_RAW: - printf("SOCK_RAW"); - break; - default: - printf("SOCK_ERROR\n"); - exit(-1); - } - printf(")\n"); -} - -static inline void printprotocol(int ai_protocol) -{ - printf("protocol: %d(", ai_protocol); - switch (ai_protocol) - { - case IPPROTO_IP: - printf("IPPROTO_IP"); - break; - case IPPROTO_TCP: - printf("IPPROTO_TCP"); - break; - case IPPROTO_UDP: - printf("IPPROTO_UDP"); - break; - default: - printf("IPPROTO_ERROR\n"); - exit(-1); - } - printf(")\n"); -} - -static inline void printaddr(int ai_family, const struct sockaddr *ai_addr) -{ - char str[INET_ADDRSTRLEN+1] = "FAKE"; - printf("family: %d(", ai_family); - switch (ai_family) - { - case AF_UNSPEC: - printf("AF_UNSPEC"); - break; - case AF_INET: - printf("AF_INET"); - break; -#ifdef AF_INET6 - case AF_INET6: - printf("AF_INET6"); - break; -#endif - default: - printf("AF_ERROR\n"); - exit(-1); - } - printf(")\n"); - if (ai_family == AF_INET && ai_addr) - { - const struct sockaddr_in *ip4 = (void *)ai_addr; -#ifdef HAVE_NTOP - inet_ntop(ai_family, &ip4->sin_addr, str, INET_ADDRSTRLEN); -#else - strncpy(str, inet_ntoa(ip4->sin_addr), INET_ADDRSTRLEN); -#endif - printf("port: %d\n", ntohs(ip4->sin_port)); - } - printf("addr: %s\n", str); -} - -void printaddrinfo(const struct my_addrinfo *data) -{ - if(data == NULL) - { - printf("no data\n"); - return; - } - else - printf("starting addrinfo dump\n"); - while (data != NULL) - { - printflags(data->ai_flags); - printsocktype(data->ai_socktype); - printaddr(data->ai_family, data->ai_addr); - printprotocol(data->ai_protocol); - //addrlen - data = data->ai_next; - } -} - -int main(int argc, char **argv) -{ - struct my_addrinfo *res = NULL, hints; - int gaie; - - (void)argc; - (void)argv; - memset(&hints, 0x00, sizeof(struct my_addrinfo)); - hints.ai_family = AF_INET; - -#ifdef _WIN32 - { -#ifdef USE_WINSOCK2 - const WORD VerNeed = MAKEWORD(2,2); -#else - const WORD VerNeed = MAKEWORD(1,1); -#endif - WSADATA WSAData; - WSAStartup(VerNeed, &WSAData); - } -#endif - printf("-----------------------------------------------------------\n"); -#ifndef _WIN32 //NULL as res crashes Win32 - gaie = I_getaddrinfo(NULL, NULL, &hints, NULL); - if (gaie != EAI_NONAME) - printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie); - I_freeaddrinfo(res); -#endif -#if 0 //NULL as res crashes - gaie = I_getaddrinfo("localhost", "5029", NULL, NULL); - if (gaie == 0) - printf("NULL crashes: %s(%d)\n", gai_strerror(gaie), gaie); - I_freeaddrinfo(res); -#endif - gaie = I_getaddrinfo("localhost", NULL, &hints, &res); - //if (gaie != 0) - printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo(NULL, "5029", &hints, &res); - //if (gaie != 0) - printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo("localhost", "5029", &hints, &res); - //if (gaie != 0) - printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - printf("-----------------------------------------------------------\n"); - hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - gaie = I_getaddrinfo("localhost", NULL, &hints, &res); - //if (gaie != 0) - printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo(NULL, "5029", &hints, &res); - //if (gaie != 0) - printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo("localhost", "5029", &hints, &res); - //if (gaie != 0) - printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - printf("-----------------------------------------------------------\n"); - hints.ai_socktype = SOCK_DGRAM; - hints.ai_protocol = IPPROTO_UDP; - gaie = I_getaddrinfo("localhost", NULL, &hints, &res); - //if (gaie != 0) - printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo(NULL, "5029", &hints, &res); - //if (gaie != 0) - printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo("localhost", "5029", &hints, &res); - //if (gaie != 0) - printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - printf("-----------------------------------------------------------\n"); - hints.ai_flags = AI_NUMERICHOST; - gaie = I_getaddrinfo("localhost", NULL, &hints, &res); - //if (gaie != 0) - printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo(NULL, "5029", &hints, &res); - //if (gaie != 0) - printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo("localhost", "5029", &hints, &res); - //if (gaie != 0) - printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - printf("-----------------------------------------------------------\n"); - gaie = I_getaddrinfo("127.0.0.1", NULL, &hints, &res); - //if (gaie != 0) - printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo("127.0.0.1", "5029", &hints, &res); - //if (gaie != 0) - printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - printf("-----------------------------------------------------------\n"); - gaie = I_getaddrinfo("255.255.255.255", NULL, &hints, &res); - //if (gaie != 0) - printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo("255.255.255.255", "5029", &hints, &res); - //if (gaie != 0) - printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - printf("-----------------------------------------------------------\n"); - hints.ai_flags = AI_PASSIVE; - gaie = I_getaddrinfo("0.0.0.0", NULL, &hints, &res); - //if (gaie != 0) - printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - gaie = I_getaddrinfo("0.0.0.0", "5029", &hints, &res); - //if (gaie != 0) - printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie); - printaddrinfo(res); - I_freeaddrinfo(res); res = NULL; - return 0; -} -#endif diff --git a/src/i_addrinfo.h b/src/i_addrinfo.h deleted file mode 100644 index 7c3afc614..000000000 --- a/src/i_addrinfo.h +++ /dev/null @@ -1,71 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 2011-2018 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 i_addrinfo.h -/// \brief getaddrinfo stub - -#ifndef __I_ADDRINFO__ -#define __I_ADDRINFO__ - -#ifdef __GNUG__ -#pragma interface -#endif - -#ifndef AI_PASSIVE -#define AI_PASSIVE 0x01 -#endif -#ifndef AI_NUMERICHOST -#define AI_NUMERICHOST 0x04 -#endif -#ifndef AI_V4MAPPED -#define AI_V4MAPPED 0x08 -#endif -#ifndef AI_ADDRCONFIG -#define AI_ADDRCONFIG 0x20 -#endif - -#ifdef _WIN32 -#ifndef EAI_NONAME -#define EAI_NONAME WSAHOST_NOT_FOUND -#endif -#endif - -#ifndef EAI_NONAME -#define EAI_NONAME -2 -#endif - -#ifdef _WIN32 // already use the stub for Win32 -// w32api, ws2tcpip.h, r1.12 -struct my_addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - char *ai_canonname; - struct sockaddr *ai_addr; - struct my_addrinfo *ai_next; -}; -#else -#define my_addrinfo addrinfo -#endif - -void WS_addrinfocleanup(void); - -#ifndef my_addrinfo -void I_freeaddrinfo(struct my_addrinfo *res); -int I_getaddrinfo(const char *node, const char *service, - const struct my_addrinfo *hints, - struct my_addrinfo **res); -#elif !defined (test_stub) -#define I_getaddrinfo getaddrinfo -#define I_freeaddrinfo freeaddrinfo -#endif - - -#endif diff --git a/src/i_tcp.c b/src/i_tcp.c index f6152e3cd..09cba908f 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -29,42 +29,36 @@ #ifdef _WIN32 #define USE_WINSOCK -#if defined (_WIN64) || defined (HAVE_IPV6) -#define USE_WINSOCK2 -#else //_WIN64/HAVE_IPV6 -#define USE_WINSOCK1 -#endif #endif //WIN32 OS -#ifdef USE_WINSOCK2 +#ifdef USE_WINSOCK #include +#define addrinfo_t ADDRINFOA +#else +#define addrinfo_t struct addrinfo #endif #include "doomdef.h" +#ifndef USE_WINSOCK + #include + #ifdef __APPLE_CC__ + #ifndef _BSD_SOCKLEN_T_ + #define _BSD_SOCKLEN_T_ + #endif //_BSD_SOCKLEN_T_ + #endif //__APPLE_CC__ + #include + #include + #include + #include +#endif //normal BSD API + +#include #include -#ifdef USE_WINSOCK1 - #include -#else - #ifndef USE_WINSOCK - #include - #ifdef __APPLE_CC__ - #ifndef _BSD_SOCKLEN_T_ - #define _BSD_SOCKLEN_T_ - #endif //_BSD_SOCKLEN_T_ - #endif //__APPLE_CC__ - #include - #include - #include - #include - #endif //normal BSD API - #include - - #if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) - #include - #endif // UNIXCOMMON -#endif +#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) + #include +#endif // UNIXCOMMON #ifdef USE_WINSOCK // some undefined under win32 @@ -152,7 +146,6 @@ static UINT8 UPNP_support = TRUE; #define close closesocket #endif -#include "i_addrinfo.h" #define DEFAULTPORT "5029" #if defined (USE_WINSOCK) @@ -169,10 +162,6 @@ typedef unsigned long SOCKET_TYPE; #define IPV6_MULTICAST_ADDRESS "ff15::57e1:1a12" -#ifdef USE_WINSOCK1 -typedef int socklen_t; -#endif - typedef struct { mysockaddr_t address; @@ -232,9 +221,8 @@ static char *get_WSAErrorStr(int e) #define strerror get_WSAErrorStr #endif -#ifdef USE_WINSOCK2 +#ifdef USE_WINSOCK #define inet_ntop inet_ntopA -#define HAVE_NTOP static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len) { DWORD Dlen = len, AFlen = 0; @@ -278,8 +266,6 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len return NULL; return buf; } -#elif !defined (USE_WINSOCK1) -#define HAVE_NTOP #endif #ifdef HAVE_MINIUPNPC // based on old XChat patch @@ -360,7 +346,6 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk) static char s[64]; // 255.255.255.255:65535 or // [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:65535 -#ifdef HAVE_NTOP #ifdef HAVE_IPV6 int v6 = (sk->any.sa_family == AF_INET6); #else @@ -398,15 +383,7 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk) #endif else if(sk->any.sa_family == AF_INET && sk->ip4.sin_port != 0) strcat(s, va(":%d", ntohs(sk->ip4.sin_port))); -#else - if (sk->any.sa_family == AF_INET) - { - strcpy(s, inet_ntoa(sk->ip4.sin_addr)); - if (sk->ip4.sin_port != 0) strcat(s, va(":%d", ntohs(sk->ip4.sin_port))); - } - else - sprintf(s, "Unknown type"); -#endif + return s; } @@ -868,15 +845,11 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen #ifdef USE_WINSOCK { // Alam_GBC: disable the new UDP connection reset behavior for Win2k and up -#ifdef USE_WINSOCK2 DWORD dwBytesReturned = 0; BOOL bfalse = FALSE; rc = WSAIoctl(s, SIO_UDP_CONNRESET, &bfalse, sizeof(bfalse), NULL, 0, &dwBytesReturned, NULL, NULL); -#else - unsigned long falseval = false; - rc = ioctl(s, SIO_UDP_CONNRESET, &falseval); -#endif + if (rc == -1) { e = errno; @@ -1046,7 +1019,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen static boolean UDP_Socket(void) { size_t s; - struct my_addrinfo *ai, *runp, hints; + addrinfo_t *ai, *runp, hints; int gaie; #ifdef HAVE_IPV6 const INT32 b_ipv6 = M_CheckParm("-ipv6"); @@ -1075,7 +1048,7 @@ static boolean UDP_Socket(void) { while (M_IsNextParm()) { - gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai); + gaie = getaddrinfo(M_GetNextParm(), serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -1089,13 +1062,13 @@ static boolean UDP_Socket(void) } runp = runp->ai_next; } - I_freeaddrinfo(ai); + freeaddrinfo(ai); } } } else { - gaie = I_getaddrinfo("0.0.0.0", serv, &hints, &ai); + gaie = getaddrinfo("0.0.0.0", serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -1116,7 +1089,7 @@ static boolean UDP_Socket(void) } runp = runp->ai_next; } - I_freeaddrinfo(ai); + freeaddrinfo(ai); } } @@ -1128,7 +1101,7 @@ static boolean UDP_Socket(void) { while (M_IsNextParm()) { - gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai); + gaie = getaddrinfo(M_GetNextParm(), serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -1142,13 +1115,13 @@ static boolean UDP_Socket(void) } runp = runp->ai_next; } - I_freeaddrinfo(ai); + freeaddrinfo(ai); } } } else { - gaie = I_getaddrinfo("::", serv, &hints, &ai); + gaie = getaddrinfo("::", serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -1162,7 +1135,7 @@ static boolean UDP_Socket(void) } runp = runp->ai_next; } - I_freeaddrinfo(ai); + freeaddrinfo(ai); } } } @@ -1216,11 +1189,7 @@ boolean I_InitTcpDriver(void) if (!init_tcp_driver) { #ifdef USE_WINSOCK -#ifdef USE_WINSOCK2 const WORD VerNeed = MAKEWORD(2,2); -#else - const WORD VerNeed = MAKEWORD(1,1); -#endif WSADATA WSAData; const int WSAresult = WSAStartup(VerNeed, &WSAData); if (WSAresult != 0) @@ -1247,21 +1216,14 @@ boolean I_InitTcpDriver(void) if (WSAresult != WSAVERNOTSUPPORTED) CONS_Debug(DBG_NETPLAY, "WinSock(TCP/IP) error: %s\n",WSError); } -#ifdef USE_WINSOCK2 - if(LOBYTE(WSAData.wVersion) != 2 || + + if (LOBYTE(WSAData.wVersion) != 2 || HIBYTE(WSAData.wVersion) != 2) { WSACleanup(); CONS_Debug(DBG_NETPLAY, "No WinSock(TCP/IP) 2.2 driver detected\n"); } -#else - if (LOBYTE(WSAData.wVersion) != 1 || - HIBYTE(WSAData.wVersion) != 1) - { - WSACleanup(); - CONS_Debug(DBG_NETPLAY, "No WinSock(TCP/IP) 1.1 driver detected\n"); - } -#endif + CONS_Debug(DBG_NETPLAY, "WinSock description: %s\n",WSAData.szDescription); CONS_Debug(DBG_NETPLAY, "WinSock System Status: %s\n",WSAData.szSystemStatus); #endif @@ -1301,7 +1263,6 @@ void I_ShutdownTcpDriver(void) CONS_Printf("I_ShutdownTcpDriver: "); #ifdef USE_WINSOCK - WS_addrinfocleanup(); WSACleanup(); #endif CONS_Printf("shut down\n"); @@ -1310,24 +1271,24 @@ void I_ShutdownTcpDriver(void) static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const char *port, boolean test) { - struct my_addrinfo *ai = NULL, *runp, hints; + addrinfo_t *ai = NULL, *runp, hints; int gaie; size_t i; if (!port || !port[0]) port = DEFAULTPORT; - memset (&hints, 0x00, sizeof (hints)); + memset(&hints, 0x00, sizeof (hints)); hints.ai_flags = AI_ADDRCONFIG; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; - gaie = I_getaddrinfo(address, port, &hints, &ai); + gaie = getaddrinfo(address, port, &hints, &ai); if (gaie != 0) { - I_freeaddrinfo(ai); + freeaddrinfo(ai); return false; } @@ -1356,7 +1317,7 @@ static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const if (runp != NULL) memcpy(sin, runp->ai_addr, runp->ai_addrlen); - I_freeaddrinfo(ai); + freeaddrinfo(ai); return (runp != NULL); } @@ -1554,7 +1515,7 @@ static boolean SOCK_SetUnbanTime(time_t timestamp) static boolean SOCK_SetBanAddress(const char *address, const char *mask) { - struct my_addrinfo *ai, *runp, hints; + addrinfo_t *ai, *runp, hints; int gaie; if (!address) @@ -1566,7 +1527,7 @@ static boolean SOCK_SetBanAddress(const char *address, const char *mask) hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; - gaie = I_getaddrinfo(address, "0", &hints, &ai); + gaie = getaddrinfo(address, "0", &hints, &ai); if (gaie != 0) return false; @@ -1611,7 +1572,7 @@ static boolean SOCK_SetBanAddress(const char *address, const char *mask) runp = runp->ai_next; } - I_freeaddrinfo(ai); + freeaddrinfo(ai); return true; } @@ -1660,8 +1621,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; @@ -1746,5 +1705,3 @@ boolean I_InitTcpNetwork(void) return ret; } - -#include "i_addrinfo.c" From 951c090b35b6096fbafd316bbff2a50bddaebfe6 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 12 Apr 2025 15:24:54 +0000 Subject: [PATCH 06/10] set CURLOPT_MAXREDIRS to 30 --- src/http-mserv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/http-mserv.c b/src/http-mserv.c index 18690f28a..8e35f905d 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -253,6 +253,9 @@ HMS_connect (const char *format, ...) cc = curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)cv_masterserver_timeout.value); if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf); + cc = curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 30L); + if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf); + cc = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read); if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf); From e180918e48c70eff5b86309fab41d35f8e8a1c45 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sat, 30 Aug 2025 13:22:56 +0200 Subject: [PATCH 07/10] Do not archive nil table keys --- src/lua_script.c | 68 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index cd9ba1f85..a7ce910ba 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -797,8 +797,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { mobj_t *mobj = *((mobj_t **)lua_touserdata(gL, myindex)); if (!mobj) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_MOBJ); WRITEUINT32(*p, mobj->mobjnum); } @@ -808,8 +812,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { player_t *player = *((player_t **)lua_touserdata(gL, myindex)); if (!player) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_PLAYER); WRITEUINT8(*p, player - players); } @@ -819,8 +827,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { mapthing_t *mapthing = *((mapthing_t **)lua_touserdata(gL, myindex)); if (!mapthing) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_MAPTHING); WRITEUINT16(*p, mapthing - mapthings); } @@ -830,8 +842,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { vertex_t *vertex = *((vertex_t **)lua_touserdata(gL, myindex)); if (!vertex) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_VERTEX); WRITEUINT16(*p, vertex - vertexes); } @@ -841,8 +857,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { line_t *line = *((line_t **)lua_touserdata(gL, myindex)); if (!line) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_LINE); WRITEUINT16(*p, line - lines); } @@ -852,8 +872,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { side_t *side = *((side_t **)lua_touserdata(gL, myindex)); if (!side) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_SIDE); WRITEUINT16(*p, side - sides); } @@ -863,8 +887,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { subsector_t *subsector = *((subsector_t **)lua_touserdata(gL, myindex)); if (!subsector) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_SUBSECTOR); WRITEUINT16(*p, subsector - subsectors); } @@ -874,8 +902,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { sector_t *sector = *((sector_t **)lua_touserdata(gL, myindex)); if (!sector) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_SECTOR); WRITEUINT16(*p, sector - sectors); } @@ -885,8 +917,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex)); if (!slope) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_SLOPE); WRITEUINT16(*p, slope->id); } @@ -896,8 +932,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex)); if (!header) + { WRITEUINT8(*p, ARCH_NULL); - else { + return 3; + } + else + { WRITEUINT8(*p, ARCH_MAPHEADER); WRITEUINT16(*p, header - *mapheaderinfo); } @@ -1007,10 +1047,18 @@ static void ArchiveTables(UINT8 **p) CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -1), luaL_typename(gL, -1), i); lua_pop(gL, 1); } + else if (e == 3) // nil key due to invalid userdata. NOT an error. + { + lua_pop(gL, 1); + continue; + } + // Write value e = ArchiveValue(p, TABLESINDEX, -1); if (e == 1) + { n++; // the table contained a new table we'll have to archive. :( + } else if (e == 2) // invalid value type { lua_pushvalue(gL, -2); From 68f69049d44e5fe3f691d8059950c087241c5d95 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Tue, 10 Aug 2021 00:15:44 +0200 Subject: [PATCH 08/10] Fix incorrect error message during Lua archiving --- src/lua_script.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index a7ce910ba..723624ee2 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1043,9 +1043,7 @@ static void ArchiveTables(UINT8 **p) e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this. if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise) { - lua_pushvalue(gL, -2); - CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -1), luaL_typename(gL, -1), i); - lua_pop(gL, 1); + CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i); } else if (e == 3) // nil key due to invalid userdata. NOT an error. { @@ -1061,9 +1059,7 @@ static void ArchiveTables(UINT8 **p) } else if (e == 2) // invalid value type { - lua_pushvalue(gL, -2); - CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -1), luaL_typename(gL, -1)); - lua_pop(gL, 1); + CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1)); } lua_pop(gL, 1); From ae456fee3158ab691fa447d2064a5db3c581c0c5 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Oct 2025 17:02:24 +0200 Subject: [PATCH 09/10] force inline savegame archive stuff --- src/p_saveg.c | 64 +++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index a4b343554..d158cf91b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -61,7 +61,7 @@ typedef enum // // P_ArchivePlayer // -static inline void P_ArchivePlayer(savebuffer_t *save) +FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save) { const player_t *player = &players[consoleplayer]; INT32 pllives = player->lives; @@ -85,7 +85,7 @@ static inline void P_ArchivePlayer(savebuffer_t *save) // // P_UnArchivePlayer // -static inline void P_UnArchivePlayer(savebuffer_t *save) +FUNCINLINE static ATTRINLINE void P_UnArchivePlayer(savebuffer_t *save) { savedata.skincolor = READUINT8(save->p); savedata.skin = READUINT8(save->p); @@ -1043,25 +1043,25 @@ typedef enum tc_end } specials_e; -static inline UINT32 SaveMobjnum(const mobj_t *mobj) +FUNCINLINE static ATTRINLINE UINT32 SaveMobjnum(const mobj_t *mobj) { if (mobj) return mobj->mobjnum; return 0; } -static inline UINT32 SaveSector(const sector_t *sector) +FUNCINLINE static ATTRINLINE UINT32 SaveSector(const sector_t *sector) { if (sector) return (UINT32)(sector - sectors); return 0xFFFFFFFF; } -static inline UINT32 SaveLine(const line_t *line) +FUNCINLINE static ATTRINLINE UINT32 SaveLine(const line_t *line) { if (line) return (UINT32)(line - lines); return 0xFFFFFFFF; } -static inline UINT32 SavePlayer(const player_t *player) +FUNCINLINE static ATTRINLINE UINT32 SavePlayer(const player_t *player) { if (player) return (UINT32)(player - players); return 0xFFFFFFFF; @@ -1476,7 +1476,7 @@ static void SaveElevatorThinker(savebuffer_t *save, const thinker_t *th, const U // // Saves a scroll_t thinker // -static inline void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type) +FUNCINLINE static ATTRINLINE void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type) { const scroll_t *ht = (const void *)th; WRITEUINT8(save->p, type); @@ -1497,7 +1497,7 @@ static inline void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, co // // Saves a friction_t thinker // -static inline void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type) +FUNCINLINE static ATTRINLINE void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type) { const friction_t *ht = (const void *)th; WRITEUINT8(save->p, type); @@ -1513,7 +1513,7 @@ static inline void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th, // // Saves a pusher_t thinker // -static inline void SavePusherThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type) +FUNCINLINE static ATTRINLINE void SavePusherThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type) { const pusher_t *ht = (const void *)th; WRITEUINT8(save->p, type); @@ -1598,7 +1598,7 @@ static void SaveDisappearThinker(savebuffer_t *save, const thinker_t *th, const // // Saves a polyrotate_t thinker // -static inline void SavePolyrotatetThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type) +FUNCINLINE static ATTRINLINE void SavePolyrotatetThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type) { const polyrotate_t *ht = (const void *)th; WRITEUINT8(save->p, type); @@ -1935,25 +1935,25 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) return NULL; } -static inline mobj_t *LoadMobj(UINT32 mobjnum) +FUNCINLINE static ATTRINLINE mobj_t *LoadMobj(UINT32 mobjnum) { if (mobjnum == 0) return NULL; return (mobj_t *)(size_t)mobjnum; } -static inline sector_t *LoadSector(UINT32 sector) +FUNCINLINE static ATTRINLINE sector_t *LoadSector(UINT32 sector) { if (sector >= numsectors) return NULL; return §ors[sector]; } -static inline line_t *LoadLine(UINT32 line) +FUNCINLINE static ATTRINLINE line_t *LoadLine(UINT32 line) { if (line >= numlines) return NULL; return &lines[line]; } -static inline player_t *LoadPlayer(UINT32 player) +FUNCINLINE static ATTRINLINE player_t *LoadPlayer(UINT32 player) { if (player >= MAXPLAYERS) return NULL; return &players[player]; @@ -2529,7 +2529,7 @@ static void LoadScrollThinker(savebuffer_t *save, actionf_p1 thinker) // // Loads a friction_t from a save game // -static inline void LoadFrictionThinker(savebuffer_t *save, actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadFrictionThinker(savebuffer_t *save, actionf_p1 thinker) { friction_t *ht = (friction_t*)Z_LevelPoolMalloc(sizeof (*ht)); ht->thinker.alloctype = TAT_LEVELPOOL; @@ -2576,7 +2576,7 @@ static void LoadPusherThinker(savebuffer_t *save, actionf_p1 thinker) // // Loads a laserthink_t from a save game // -static inline void LoadLaserThinker(savebuffer_t *save, actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadLaserThinker(savebuffer_t *save, actionf_p1 thinker) { laserthink_t *ht = (laserthink_t*)Z_LevelPoolMalloc(sizeof (*ht)); ht->thinker.alloctype = TAT_LEVELPOOL; @@ -2621,7 +2621,7 @@ FUNCINLINE static ATTRINLINE void LoadLightlevelThinker(savebuffer_t *save, acti // // Loads a executor_t from a save game // -static inline void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker) { executor_t *ht = (executor_t*)Z_LevelPoolMalloc(sizeof (*ht)); ht->thinker.alloctype = TAT_LEVELPOOL; @@ -2639,7 +2639,7 @@ static inline void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker) // // Loads a disappear_t thinker // -static inline void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker) { disappear_t *ht = (disappear_t*)Z_LevelPoolMalloc(sizeof (*ht)); ht->thinker.alloctype = TAT_LEVELPOOL; @@ -2660,7 +2660,7 @@ static inline void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker) // // Loads a polyrotate_t thinker // -static inline void LoadPolyrotatetThinker(savebuffer_t *save, actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadPolyrotatetThinker(savebuffer_t *save, actionf_p1 thinker) { polyrotate_t *ht = (polyrotate_t*)Z_LevelPoolMalloc(sizeof (*ht)); ht->thinker.alloctype = TAT_LEVELPOOL; @@ -2720,7 +2720,7 @@ static void LoadPolymoveThinker(savebuffer_t *save, actionf_p1 thinker) // // Loads a polywaypoint_t thinker // -static inline void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinker) { polywaypoint_t *ht = (polywaypoint_t*)Z_LevelPoolMalloc(sizeof (*ht)); ht->thinker.alloctype = TAT_LEVELPOOL; @@ -2776,7 +2776,7 @@ static inline void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinke // // loads a polyslidedoor_t thinker // -static inline void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 thinker) { polyslidedoor_t *ht = (polyslidedoor_t*)Z_LevelPoolMalloc(sizeof (*ht)); ht->thinker.alloctype = TAT_LEVELPOOL; @@ -2814,7 +2814,7 @@ static inline void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 think // // Loads a polyswingdoor_t thinker // -static inline void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 thinker) { polyswingdoor_t *ht = (polyswingdoor_t*)Z_LevelPoolMalloc(sizeof (*ht)); ht->thinker.alloctype = TAT_LEVELPOOL; @@ -2847,7 +2847,7 @@ static inline void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 think // // Loads a polydisplace_t thinker // -static inline void LoadPolydisplaceThinker(savebuffer_t *save, actionf_p1 thinker) +FUNCINLINE static ATTRINLINE void LoadPolydisplaceThinker(savebuffer_t *save, actionf_p1 thinker) { polydisplace_t *ht = (polydisplace_t*)Z_LevelPoolMalloc(sizeof (*ht)); ht->thinker.alloctype = TAT_LEVELPOOL; @@ -3115,7 +3115,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) #define PD_FLAGS 0x01 #define PD_TRANS 0x02 -static inline void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po) +FUNCINLINE static ATTRINLINE void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po) { UINT8 diff = 0; WRITEINT32(save->p, po->id); @@ -3137,7 +3137,7 @@ static inline void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po) WRITEINT32(save->p, po->translucency); } -static inline void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po) +FUNCINLINE static ATTRINLINE void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po) { INT32 id; UINT32 angle; @@ -3172,7 +3172,7 @@ static inline void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po) Polyobj_MoveOnLoad(po, angle, x, y); } -static inline void P_ArchivePolyObjects(savebuffer_t *save) +FUNCINLINE static ATTRINLINE void P_ArchivePolyObjects(savebuffer_t *save) { INT32 i; @@ -3185,7 +3185,7 @@ static inline void P_ArchivePolyObjects(savebuffer_t *save) P_ArchivePolyObj(save, &PolyObjects[i]); } -static inline void P_UnArchivePolyObjects(savebuffer_t *save) +FUNCINLINE static ATTRINLINE void P_UnArchivePolyObjects(savebuffer_t *save) { INT32 i, numSavedPolys; @@ -3203,7 +3203,7 @@ static inline void P_UnArchivePolyObjects(savebuffer_t *save) // // P_FinishMobjs // -static inline void P_FinishMobjs(void) +FUNCINLINE static ATTRINLINE void P_FinishMobjs(void) { thinker_t *currentthinker; mobj_t *mobj; @@ -3220,7 +3220,7 @@ static inline void P_FinishMobjs(void) } } -static inline mobj_t *RelinkMobj(mobj_t **ptr) +FUNCINLINE static ATTRINLINE mobj_t *RelinkMobj(mobj_t **ptr) { UINT32 temp = (UINT32)(size_t)*ptr; *ptr = NULL; @@ -3269,7 +3269,7 @@ static void P_RelinkPointers(void) // // P_NetArchiveSpecials // -static inline void P_NetArchiveSpecials(savebuffer_t *save) +FUNCINLINE static ATTRINLINE void P_NetArchiveSpecials(savebuffer_t *save) { size_t i, z; @@ -3347,7 +3347,7 @@ static void P_NetUnArchiveSpecials(savebuffer_t *save) // ======================================================================= // Misc // ======================================================================= -static inline void P_ArchiveMisc(savebuffer_t *save) +FUNCINLINE static ATTRINLINE void P_ArchiveMisc(savebuffer_t *save) { if (gamecomplete) WRITEINT16(save->p, gamemap | 8192); @@ -3360,7 +3360,7 @@ static inline void P_ArchiveMisc(savebuffer_t *save) WRITESTRINGN(save->p, timeattackfolder, sizeof(timeattackfolder)); } -static inline void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride) +FUNCINLINE static ATTRINLINE void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride) { char testname[sizeof(timeattackfolder)]; From c262d3f532bf02a428afd23e97a9a95db2a5a897 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Oct 2025 20:36:29 +0200 Subject: [PATCH 10/10] prevent potential 0 division in CV_AddValue as repoted by clang-tidy --- src/command.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/command.c b/src/command.c index ee3b36247..47bd521b0 100644 --- a/src/command.c +++ b/src/command.c @@ -1913,13 +1913,14 @@ void CV_AddValue(consvar_t *var, INT32 increment) max = (M_SecretUnlocked(SECRET_HARDSPEED) ? 3 : 2); } #ifdef PARANOIA - if (currentindice == -1) - I_Error("CV_AddValue: current value %d not found in possible value\n", - var->value); + if (currentindice == -1 || max == 0) + I_Error("CV_AddValue: current value %d not found in possible value\n", var->value); #endif - - newindice = (currentindice + increment + max) % max; - CV_Set(var, var->PossibleValue[newindice].strvalue); + if (max > 0) + { + newindice = (currentindice + increment + max) % max; + CV_Set(var, var->PossibleValue[newindice].strvalue); + } } } else