diff --git a/libs/libbacktrace/include/backtrace.h b/libs/libbacktrace/include/backtrace.h index 777e1460b..de92a3afb 100644 --- a/libs/libbacktrace/include/backtrace.h +++ b/libs/libbacktrace/include/backtrace.h @@ -1,5 +1,5 @@ /* backtrace.h -- Public header file for stack backtrace library. - Copyright (C) 2012-2020 Free Software Foundation, Inc. + Copyright (C) 2012-2024 Free Software Foundation, Inc. Written by Ian Lance Taylor, Google. Redistribution and use in source and binary forms, with or without @@ -54,13 +54,14 @@ struct backtrace_state; invalid after this function returns. As a special case, the ERRNUM argument will be passed as -1 if no - debug info can be found for the executable, but the function - requires debug info (e.g., backtrace_full, backtrace_pcinfo). The - MSG in this case will be something along the lines of "no debug - info". Similarly, ERRNUM will be passed as -1 if there is no - symbol table, but the function requires a symbol table (e.g., - backtrace_syminfo). This may be used as a signal that some other - approach should be tried. */ + debug info can be found for the executable, or if the debug info + exists but has an unsupported version, but the function requires + debug info (e.g., backtrace_full, backtrace_pcinfo). The MSG in + this case will be something along the lines of "no debug info". + Similarly, ERRNUM will be passed as -1 if there is no symbol table, + but the function requires a symbol table (e.g., backtrace_syminfo). + This may be used as a signal that some other approach should be + tried. */ typedef void (*backtrace_error_callback) (void *data, const char *msg, int errnum); diff --git a/libs/libbacktrace/lib/x86_64/libbacktrace.a b/libs/libbacktrace/lib/x86_64/libbacktrace.a index 891dd11d6..4b4447b58 100644 Binary files a/libs/libbacktrace/lib/x86_64/libbacktrace.a and b/libs/libbacktrace/lib/x86_64/libbacktrace.a differ diff --git a/src/am_map.c b/src/am_map.c index f91273e8b..11b3796b0 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -197,7 +197,7 @@ static fixed_t scale_mtof = (fixed_t)INITSCALEMTOF; // used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof) static fixed_t scale_ftom; -static player_t *plr; // the player represented by an arrow +static player_t *plr = NULL; // the player represented by an arrow static boolean followplayer = true; // specifies whether to follow the player around @@ -237,7 +237,7 @@ static inline void AM_restoreScaleAndLoc(void) m_x = old_m_x; m_y = old_m_y; } - else + else if (plr && plr->mo) { m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2; m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2; @@ -318,7 +318,8 @@ static void AM_initVariables(void) break; plr = &players[pnum]; - if (plr != NULL && plr->mo != NULL) + + if (plr && plr->mo) { m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2; m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2; @@ -597,6 +598,9 @@ static inline void AM_changeWindowScale(void) static inline void AM_doFollowPlayer(void) { + if (!plr || !plr->mo) + return; + if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) { m_x = FTOM(MTOF(plr->mo->x >> FRACTOMAPBITS)) - m_w/2; diff --git a/src/command.c b/src/command.c index e7dd9cc01..3881246c1 100644 --- a/src/command.c +++ b/src/command.c @@ -240,7 +240,6 @@ void COM_ImmedExecute(const char *ptext) while (i < strlen(ptext)) { - quotes = 0; for (j = 0; i < strlen(ptext); i++,j++) { @@ -817,12 +816,17 @@ static void COM_Help_f(void) cvar = CV_FindVar(help); if (cvar) { + boolean floatmode = false; + const char *cvalue = NULL; CONS_Printf("\x82""Variable %s:\n", cvar->name); CONS_Printf(M_GetText(" flags: ")); if (cvar->flags & CV_SAVE) CONS_Printf("AUTOSAVE "); if (cvar->flags & CV_FLOAT) + { CONS_Printf("FLOAT "); + floatmode = true; + } if (cvar->flags & CV_NETVAR) CONS_Printf("NETVAR "); if (cvar->flags & CV_CALL) @@ -832,30 +836,43 @@ static void COM_Help_f(void) CONS_Printf("\n"); if (cvar->PossibleValue) { - if (!stricmp(cvar->PossibleValue[0].strvalue, "MIN") && !stricmp(cvar->PossibleValue[1].strvalue, "MAX")) { - CONS_Printf(" range from %d to %d\n", cvar->PossibleValue[0].value, - cvar->PossibleValue[1].value); - i = 2; - } + if (!stricmp(cvar->PossibleValue[0].strvalue, "MIN") && !stricmp(cvar->PossibleValue[1].strvalue, "MAX")) + { + if (floatmode) + { + float fu = FIXED_TO_FLOAT(cvar->PossibleValue[0].value); + float ck = FIXED_TO_FLOAT(cvar->PossibleValue[1].value); + CONS_Printf(" range from %ld%s to %ld%s\n", + (long)fu, M_Ftrim(fu), + (long)ck, M_Ftrim(ck)); + } + else + CONS_Printf(" range from %d to %d\n", cvar->PossibleValue[0].value, + cvar->PossibleValue[1].value); + i = 2; + } - { - const char *cvalue = NULL; //CONS_Printf(M_GetText(" possible value : %s\n"), cvar->name); while (cvar->PossibleValue[i].strvalue) { - CONS_Printf(" %-2d : %s\n", cvar->PossibleValue[i].value, - cvar->PossibleValue[i].strvalue); + if (floatmode) + CONS_Printf(" %-2f : %s\n", FIXED_TO_FLOAT(cvar->PossibleValue[i].value), + cvar->PossibleValue[i].strvalue); + else + CONS_Printf(" %-2d : %s\n", cvar->PossibleValue[i].value, + cvar->PossibleValue[i].strvalue); if (cvar->PossibleValue[i].value == cvar->value) cvalue = cvar->PossibleValue[i].strvalue; i++; } - if (cvalue) - CONS_Printf(" Current value: %s\n", cvalue); - else - CONS_Printf(" Current value: %d\n", cvar->value); } } + + if (cvalue) + CONS_Printf(" Current value: %s\n", cvalue); + else if (cvar->string) + CONS_Printf(" Current value: %s\n", cvar->string); else CONS_Printf(" Current value: %d\n", cvar->value); } @@ -1026,7 +1043,10 @@ static void COM_Add_f(void) } if (( cvar->flags & CV_FLOAT )) - CV_Set(cvar, va("%f", FIXED_TO_FLOAT (cvar->value) + atof(COM_Argv(2)))); + { + float n =FIXED_TO_FLOAT (cvar->value) + atof(COM_Argv(2)); + CV_Set(cvar, va("%ld%s", (long)n, M_Ftrim(n))); + } else CV_AddValue(cvar, atoi(COM_Argv(2))); } diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e07df96c3..a4a523813 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -87,6 +87,9 @@ boolean serverrunning = false; INT32 serverplayer = 0; char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support) +plrinfo playerinfo[MAXPLAYERS]; +SINT8 joinnode = 0; // used for CL_VIEWSERVER + // Server specific vars UINT8 playernode[MAXPLAYERS]; @@ -1068,6 +1071,7 @@ static void SV_RequireResynch(INT32 node) // Initial setup memset(resynch_sent[node], 0, MAXPLAYERS); + for (i = 0; i < MAXPLAYERS; ++i) { if (!playeringame[i]) // Player not in game so just drop it from required synch @@ -1187,6 +1191,7 @@ typedef enum #endif CL_CONNECTED, CL_ABORTED, + CL_VIEWSERVER, CL_ASKFULLFILELIST, CL_CONFIRMCONNECT, #ifdef HAVE_CURL @@ -1250,7 +1255,7 @@ static inline void CL_DrawConnectionStatus(void) if (!menuactive) // menu already draws its own fade V_DrawFadeScreen(0xFF00, 16); // force default - if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_LOADFILES && cl_mode != CL_CHECKFILES + if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_LOADFILES && cl_mode != CL_CHECKFILES && cl_mode != CL_VIEWSERVER #ifdef HAVE_CURL && cl_mode != CL_DOWNLOADHTTPFILES #endif @@ -1370,6 +1375,78 @@ static inline void CL_DrawConnectionStatus(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va(" %2u/%2u Files",loadcompletednum,fileneedednum)); } + else if (cl_mode == CL_VIEWSERVER) + { + V_DrawFill(8, 16, BASEVIDWIDTH - 16, 54, 239); + + V_DrawThinString(12 + 80, 18, V_ALLOWLOWERCASE, va("%s", serverlist[joinnode].info.servername)); + + const char *map = va("%sP", serverlist[joinnode].info.mapname); + patch_t *current_map = W_LumpExists(map) ? W_CachePatchName(map, PU_CACHE) : W_CachePatchName("BLANKLVL", PU_CACHE); + V_DrawSmallScaledPatch(10, 18, 0, current_map); + + V_DrawThinString(12 + 80, 38, V_ALLOWLOWERCASE, va("%s", serverlist[joinnode].info.maptitle)); + V_DrawThinString(12 + 80, 48, V_ALLOWLOWERCASE, va("%s", Gametype_Names[serverlist[joinnode].info.gametype])); + + if (fileneedednum > 0) + { + V_DrawThinString(12 + 80, 58, V_ALLOWLOWERCASE|V_ORANGEMAP, va("%i Addons", fileneedednum)); + } + else + { + V_DrawThinString(12 + 80, 58, V_ALLOWLOWERCASE|V_YELLOWMAP, "Vanilla"); + } + + if (serverlist[joinnode].info.cheatsenabled) + { + V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, 58, V_ALLOWLOWERCASE|V_GREENMAP, "Cheats"); + } + + V_DrawFill(8, 72, BASEVIDWIDTH - 16, 112, 239); + + V_DrawString(12, 74, V_ALLOWLOWERCASE|V_YELLOWMAP, "Players"); + V_DrawRightAlignedString(BASEVIDWIDTH - 12, 74, V_ALLOWLOWERCASE|V_YELLOWMAP, va("%i / %i", serverlist[joinnode].info.numberofplayer, serverlist[joinnode].info.maxplayer)); + + INT32 i; + INT32 count = 0; + INT32 x = 14; + INT32 y = 84; + INT32 statuscolor = 1; + char player_name[MAXPLAYERNAME+1]; + if (serverlist[joinnode].info.numberofplayer > 0) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (playerinfo[i].node < 255) + { + strncpy(player_name, playerinfo[i].name, MAXPLAYERNAME); + V_DrawThinString(x + 10, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, player_name); + + if (playerinfo[i].team == 0) { statuscolor = 184; } // playing + if (playerinfo[i].data & 0x20) { statuscolor = 86; } // tag IT + if (playerinfo[i].team == 1) { statuscolor = 128; } // ctf red team + if (playerinfo[i].team == 2) { statuscolor = 232; } // ctf blue team + if (playerinfo[i].team == 255) { statuscolor = 16; } // spectator or non-team + + V_DrawFill(x, y, 7, 7, 31); + V_DrawFill(x, y, 6, 6, statuscolor); + + y += 9; + count++; + if ((count == 11) || (count == 22)) + { + x += 104; + y = 84; + } + } + } + } + + // Buttons + V_DrawFill(8, BASEVIDHEIGHT - 14, BASEVIDWIDTH - 16, 12, 239); + V_DrawThinString(16, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sESC%s] = Abort", "\x82", "\x80")); + V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sENTER%s] = Join", "\x82", "\x80")); + } else if (filedownload.current != -1) { INT32 dldlength; @@ -1698,13 +1775,7 @@ static void SV_SendPlayerInfo(INT32 node) for (i = 0; i < MSCOMPAT_MAXPLAYERS; i++) { - if (i >= MAXPLAYERS) - { - netbuffer->u.playerinfo[i].node = 255; - continue; - } - - if (playeringame[i] == UINT8_MAX || !playeringame[i]) + if ((i >= MAXPLAYERS) || !playeringame[i]) { netbuffer->u.playerinfo[i].node = 255; // This slot is empty. continue; @@ -1791,8 +1862,6 @@ static boolean SV_SendServerConfig(INT32 node) 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++) { netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; @@ -2492,6 +2561,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) if (i < 0) return true; } + joinnode = i; // Quit here rather than downloading files and being refused later. if (serverlist[i].info.numberofplayer >= serverlist[i].info.maxplayer) @@ -2518,7 +2588,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) return true; } - cl_mode = CL_CHECKFILES; + cl_mode = (cv_serverinfoscreen.value) ? CL_VIEWSERVER : CL_CHECKFILES; } else { @@ -2572,7 +2642,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_ASKFULLFILELIST: if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved - cl_mode = CL_CHECKFILES; + cl_mode = (cv_serverinfoscreen.value) ? CL_VIEWSERVER : CL_CHECKFILES; else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent) { if (CL_AskFileList(fileneedednum)) @@ -2738,6 +2808,15 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic D_ProcessEvents(); //needed for menu system to receive inputs key = I_GetKey(); + + if (cl_mode == CL_VIEWSERVER) + { + if (key == KEY_ENTER || key == KEY_JOY1) + cl_mode = CL_CHECKFILES; + else if (key == KEY_ESCAPE || key == KEY_JOY1+1) + cl_mode = CL_ABORTED; + } + // Only ESC and non-keyboard keys abort connection if (!modeattacking && (key == KEY_ESCAPE || key == KEY_JOY1+1 || cl_mode == CL_ABORTED)) { @@ -3291,7 +3370,7 @@ void CL_ClearPlayer(INT32 playernum) P_RemoveMobj(players[playernum].mo); } - memset(&players[playernum], 0, sizeof (player_t)); + memset(&players[playernum], 0, sizeof(player_t)); } // @@ -4168,6 +4247,8 @@ consvar_t cv_downloadspeed = {"downloadspeed", "300", CV_SAVE, downloadspeed_con static CV_PossibleValue_t connectawaittime_cons_t[] = {{1, "MIN"}, {60, "MAX"}, {0, "Inf"}, {0, NULL}}; consvar_t cv_connectawaittime = {"connectawaittime", "5", CV_SAVE, connectawaittime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_serverinfoscreen = {"serverinfoscreen", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static void Got_AddPlayer(UINT8 **p, INT32 playernum); static void Got_RemovePlayer(UINT8 **p, INT32 playernum); @@ -4303,14 +4384,14 @@ void SV_ResetServer(void) sprintf(player_names[i], "Player %d", i + 1); } - memset(player_name_changes, 0, sizeof player_name_changes); + memset(player_name_changes, 0, sizeof(player_name_changes)); - memset(playeringame, false, sizeof playeringame); - memset(playernode, UINT8_MAX, sizeof playernode); + memset(playeringame, false, sizeof(playeringame)); + memset(playernode, UINT8_MAX, sizeof(playernode)); pingmeasurecount = 1; - memset(realpingtable, 0, sizeof realpingtable); - memset(playerpingtable, 0, sizeof playerpingtable); + memset(realpingtable, 0, sizeof(realpingtable)); + memset(playerpingtable, 0, sizeof(playerpingtable)); ClearAdminPlayers(); @@ -5255,6 +5336,10 @@ static void HandlePacketFromAwayNode(SINT8 node) case PT_CLIENTCMD: break; // This is not an "unknown packet" + + case PT_PLAYERINFO: + HandlePlayerInfo(node); + break; case PT_SERVERTICS: // Do not remove my own server (we have just get a out of order packet) @@ -5376,18 +5461,18 @@ static void HandlePacketFromPlayer(SINT8 node) /// \todo Use a separate cvar for that kind of timeout? freezetimeout[node] = I_GetTime() + connectiontimeout; - // If we've alredy received a ticcmd for this tic, just submit it for the next one. - tic_t faketic = maketic; - if ((!!(netcmds[maketic % BACKUPTICS][netconsole].angleturn & TICCMD_RECEIVED)) - && (maketic - firstticstosend < BACKUPTICS - 1)) - faketic++; - // Don't do anything for packets of type NODEKEEPALIVE? // Sryder 2018/07/01: Update the freezetimeout still! if (netbuffer->packettype == PT_NODEKEEPALIVE || netbuffer->packettype == PT_NODEKEEPALIVEMIS) break; + // If we've alredy received a ticcmd for this tic, just submit it for the next one. + tic_t faketic = maketic; + if ((!!(netcmds[maketic % BACKUPTICS][netconsole].angleturn & TICCMD_RECEIVED)) + && (maketic - firstticstosend < BACKUPTICS - 1)) + faketic++; + // Copy ticcmd G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1); @@ -5477,10 +5562,13 @@ static void HandlePacketFromPlayer(SINT8 node) } 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%BACKUPTICS], SHORT(netbuffer->u.clientpak.consistancy)); + } + DEBFILE(va("Restoring player %d (synch failure) [%update] %d!=%d\n", netconsole, realstart, consistancy[realstart%BACKUPTICS], SHORT(netbuffer->u.clientpak.consistancy))); @@ -5759,7 +5847,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; } - //Update client ping table from the server. + // Update client ping table from the server. if (client) { UINT8 i; @@ -5857,8 +5945,9 @@ static void GetPackets(void) } #endif - if (netbuffer->packettype == PT_PLAYERINFO) - continue; // We do nothing with PLAYERINFO, that's for the MS browser. + /*if (netbuffer->packettype == PT_PLAYERINFO) + continue; // We do nothing with PLAYERINFO, that's for the MS browser. Not quite true anymore :p*/ + // We also count unknown packets, hence "<=" if (netbuffer->packettype <= NUMPACKETTYPE) @@ -6577,7 +6666,6 @@ static inline void PingUpdate(void) if (pingtimeout[i] > 0) pingtimeout[i]--; } - } //kick lagging players... unless everyone but the server's ping sucks. diff --git a/src/d_clisrv.h b/src/d_clisrv.h index d16f4d71f..6ca5ff2e3 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -576,6 +576,9 @@ extern boolean acceptnewnode; extern SINT8 servernode; extern char connectedservername[MAXSERVERNAME+1]; +extern plrinfo playerinfo[MAXPLAYERS]; +extern SINT8 joinnode; + void Command_Ping_f(void); extern tic_t connectiontimeout; extern tic_t jointimeout; @@ -607,6 +610,8 @@ extern consvar_t cv_connectawaittime; extern consvar_t cv_discordinvites; +extern consvar_t cv_serverinfoscreen; + // Used in d_net, the only dependence //tic_t ExpandTics(INT32 low, tic_t basetic); void D_ClientServerInit(void); diff --git a/src/d_main.c b/src/d_main.c index 728a1a760..a47c8b756 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -197,12 +197,10 @@ static void D_PadMenuScrollInput(UINT8 input) // and pass it to the eventlist static void D_GamePadMenuScrollTicker(void) { + UINT8 i; static UINT8 menuInputDelayTimer = 0; - if (dedicated) - return; - - for (UINT8 i = 0; i < 4; i++) + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { if (dpadscrollstate[i]) { @@ -222,10 +220,10 @@ static void D_GamePadMenuScrollTicker(void) static void D_DeviceLEDTick(void) { UINT8 i; - static UINT16 color[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; - static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; + static UINT16 color[MAXSPLITSCREENPLAYERS] = {0}; + static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {0}; - if (dedicated || numcontrollers == 0) + if (numcontrollers == 0) { return; } @@ -252,7 +250,6 @@ static void D_DeviceLEDTick(void) void D_ProcessEvents(void) { event_t *ev; - boolean eaten; for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1)) @@ -291,8 +288,10 @@ void D_ProcessEvents(void) // Demo input: if (demo.playback) + { if (M_DemoResponder(ev)) continue; // demo ate the event + } // console input #ifdef HAVE_THREADS @@ -317,6 +316,88 @@ void D_ProcessEvents(void) // draw current display, possibly wiping it from the previous // +static void D_Renderview(void) +{ + UINT8 i; + + if (automapactive) + return; + + R_ApplyLevelInterpolators(rendertimefrac); + + for (i = 0; i <= splitscreen; i++) + { + const boolean issplitscreen = (i > 0); + + if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD) + { + viewssnum = i; + + if (!issplitscreen) // Initialize for P1 + { + viewwindowy = viewwindowx = 0; + topleft = screens[0]; + objectsdrawn = 0; + } + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + HWR_RenderPlayerView(); + R_RestoreLevelInterpolators(); + continue; + } +#endif + if (issplitscreen) // Splitscreen-specific + { + const INT32 len = viewheight*sizeof(ylookup[0]); + + switch (i) + { + case 1: + if (splitscreen > 1) + { + viewwindowx = viewwidth; + viewwindowy = 0; + } + else + { + viewwindowx = 0; + viewwindowy = viewheight; + } + M_Memcpy(ylookup, ylookup2, len); + break; + case 2: + viewwindowx = 0; + viewwindowy = viewheight; + M_Memcpy(ylookup, ylookup3, len); + break; + case 3: + viewwindowx = viewwidth; + viewwindowy = viewheight; + M_Memcpy(ylookup, ylookup4, len); + default: + break; + } + + topleft = screens[0] + viewwindowy*vid.width + viewwindowx; + } + + R_RenderPlayerView(&players[displayplayers[i]]); + + if (issplitscreen) + M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); + } + + if (!issplitscreen) + R_ApplyViewMorph(); + + V_DoPostProcessor(i, postimgparam[i]); + } + + R_RestoreLevelInterpolators(); +} + // wipegamestate can be set to -1 to force a wipe on the next draw // added comment : there is a wipe eatch change of the gamestate gamestate_t wipegamestate = GS_LEVEL; @@ -327,7 +408,6 @@ static boolean D_Display(void) boolean forcerefresh = false; static boolean wipe = false; INT32 wipedefindex = 0; - UINT8 i; if (!dedicated) { @@ -366,6 +446,7 @@ static boolean D_Display(void) { // set for all later wipedefindex = gamestate; // wipe_xxx_toblack + if (gamestate == GS_TITLESCREEN && wipegamestate != GS_INTRO) wipedefindex = wipe_timeattack_toblack; else if (gamestate == GS_INTERMISSION) @@ -378,26 +459,28 @@ static boolean D_Display(void) if (!dedicated) { - // Fade to black first - if (gamestate != GS_LEVEL // fades to black on its own timing, always - && wipedefs[wipedefindex] != UINT8_MAX) + if (gamestate != GS_LEVEL) { - F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - F_WipeEndScreen(); - F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); - ranwipe = true; - } + // Fade to black first + if (wipedefs[wipedefindex] != UINT8_MAX) // fades to black on its own timing, always + { + F_WipeStartScreen(); + 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) - { - V_SetPaletteLump("PLAYPAL"); // Reset the palette - R_ReInitColormaps(0, LUMPERROR); + if (rendermode != render_none) + { + V_SetPaletteLump("PLAYPAL"); // Reset the palette + R_ReInitColormaps(0, LUMPERROR); + } } F_WipeStartScreen(); } - else //dedicated servers + else // dedicated servers { F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); ranwipe = true; @@ -405,7 +488,7 @@ static boolean D_Display(void) } } - if (dedicated) //bail out after wipe logic + if (dedicated) // bail out after wipe logic return false; // do buffered drawing @@ -430,9 +513,6 @@ static boolean D_Display(void) HU_Drawer(); break; - case GS_TIMEATTACK: - break; - case GS_INTRO: F_IntroDrawer(); if (wipegamestate == (gamestate_t)-1) @@ -484,6 +564,7 @@ static boolean D_Display(void) HU_Erase(); HU_Drawer(); } + case GS_TIMEATTACK: case GS_DEDICATEDSERVER: case GS_NULL: break; @@ -492,89 +573,10 @@ static boolean D_Display(void) if (gamestate == GS_LEVEL) { // draw the view directly - if (cv_renderview.value && !automapactive) + if (cv_renderview.value) { PS_START_TIMING(ps_rendercalltime); - - R_ApplyLevelInterpolators(rendertimefrac); - - for (i = 0; i <= splitscreen; i++) - { - if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD) - { - viewssnum = i; - - if (i == 0) // Initialize for P1 - { - viewwindowy = 0; - viewwindowx = 0; - - topleft = screens[0] + viewwindowy*vid.width + viewwindowx; - objectsdrawn = 0; - } - -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_RenderPlayerView(); - else -#endif - if (rendermode != render_none) - { - if (i > 0) // Splitscreen-specific - { - switch (i) - { - case 1: - if (splitscreen > 1) - { - viewwindowx = viewwidth; - viewwindowy = 0; - } - else - { - viewwindowx = 0; - viewwindowy = viewheight; - } - M_Memcpy(ylookup, ylookup2, viewheight*sizeof (ylookup[0])); - break; - case 2: - viewwindowx = 0; - viewwindowy = viewheight; - M_Memcpy(ylookup, ylookup3, viewheight*sizeof (ylookup[0])); - break; - case 3: - viewwindowx = viewwidth; - viewwindowy = viewheight; - M_Memcpy(ylookup, ylookup4, viewheight*sizeof (ylookup[0])); - default: - break; - } - - - topleft = screens[0] + viewwindowy*vid.width + viewwindowx; - } - - R_RenderPlayerView(&players[displayplayers[i]]); - - if (i > 0) - M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); - } - } - } - - if (rendermode == render_soft) - { - if (!splitscreen) - R_ApplyViewMorph(); - - for (i = 0; i <= splitscreen; i++) - { - V_DoPostProcessor(i, postimgparam[i]); - } - } - - R_RestoreLevelInterpolators(); - + D_Renderview(); PS_STOP_TIMING(ps_rendercalltime); } @@ -584,6 +586,7 @@ static boolean D_Display(void) { VID_BlitLinearScreen(screens[0], screens[1], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); } + lastdraw = false; } @@ -606,13 +609,8 @@ static boolean D_Display(void) // draw pause pic if (paused && cv_showhud.value && !demo.playback) { - INT32 py; - patch_t *patch; - if (automapactive) - py = 4; - else - py = viewwindowy + 4; - patch = W_CachePatchName("M_PAUSE", PU_PATCH); + INT32 py = (automapactive) ? 4 : (viewwindowy + 4); + patch_t *patch = W_CachePatchName("M_PAUSE", PU_PATCH); V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - patch->width)/2, py, V_SNAPTOTOP, patch); } @@ -754,7 +752,7 @@ void D_SRB2Loop(void) // Casting the return value of a function is bad practice (apparently) double budget = ((R_GetFramerateCap() == 0) ? 0.0 : round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision())); - capbudget = (precise_t) budget; + capbudget = (precise_t)budget; boolean ranwipe = false; @@ -824,12 +822,15 @@ void D_SRB2Loop(void) doDisplay = true; } - if (menuactive) + if (!dedicated) { - D_GamePadMenuScrollTicker(); - } + if (menuactive) + { + D_GamePadMenuScrollTicker(); + } - D_DeviceLEDTick(); + D_DeviceLEDTick(); + } } if (interp) @@ -841,7 +842,9 @@ void D_SRB2Loop(void) ps_interp_frac.value.p = (precise_t)((FIXED_TO_FLOAT(g_time.timefrac)) * 1000.0f); ps_interp_lag.value.p = (precise_t)((deltasecs) * 1000.0f); - if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped) + const boolean lagging = ((deltatics >= 1.0) || hu_stopped); + + if (!(paused || P_AutoPause()) && !lagging) { rendertimefrac = g_time.timefrac; } @@ -850,7 +853,7 @@ void D_SRB2Loop(void) rendertimefrac = FRACUNIT; } - if ((deltatics < 1.0) && !hu_stopped) + if (!lagging) { rendertimefrac_unpaused = g_time.timefrac; } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5b8a8c18b..d73d6829a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -216,11 +216,8 @@ static CV_PossibleValue_t teamscramble_cons_t[] = {{0, "Off"}, {1, "Random"}, {2 static CV_PossibleValue_t startingliveslimit_cons_t[] = {{1, "MIN"}, {99, "MAX"}, {0, NULL}}; static CV_PossibleValue_t sleeping_cons_t[] = {{0, "MIN"}, {1000/TICRATE, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t competitionboxes_cons_t[] = {{0, "Normal"}, {1, "Random"}, {2, "Teleports"}, - {3, "None"}, {0, NULL}}; - -static CV_PossibleValue_t matchboxes_cons_t[] = {{0, "Normal"}, {1, "Random"}, {2, "Non-Random"}, - {3, "None"}, {0, NULL}}; +static CV_PossibleValue_t competitionboxes_cons_t[] = {{0, "Normal"}, {1, "Random"}, {2, "Teleports"}, {3, "None"}, {0, NULL}}; +static CV_PossibleValue_t matchboxes_cons_t[] = {{0, "Normal"}, {1, "Random"}, {2, "Non-Random"}, {3, "None"}, {0, NULL}}; //static CV_PossibleValue_t chances_cons_t[] = {{0, "MIN"}, {9, "MAX"}, {0, NULL}}; static CV_PossibleValue_t match_scoring_cons_t[] = {{0, "Normal"}, {1, "Classic"}, {0, NULL}}; @@ -905,6 +902,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_netticbuffer); CV_RegisterVar(&cv_mindelay); CV_RegisterVar(&cv_gentlemens); + CV_RegisterVar(&cv_serverinfoscreen); #ifdef NETGAME_DEVMODE CV_RegisterVar(&cv_fishcake); @@ -2777,7 +2775,7 @@ static void Command_Map_f(void) // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer else { - if (!mapheaderinfo[newmapnum-1] || mapheaderinfo[newmapnum-1] == NULL) + if (!mapheaderinfo[newmapnum-1]) { CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); Z_Free(realmapname); @@ -3031,9 +3029,14 @@ static void Command_ReplayMarker(void) adjustedleveltime = 0; char *title = G_BuildMapTitle(gamemap); - snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + if (title) + { + snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); Z_Free(title); + } + else + snprintf(demo.titlename, 64, "[%i:%02d/%.5s]", G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); CONS_Printf("Replay will be saved!\n"); } diff --git a/src/discord.c b/src/discord.c index cd7dafa8f..207a249a6 100644 --- a/src/discord.c +++ b/src/discord.c @@ -388,7 +388,7 @@ static void DRPC_GotServerIP(UINT32 address) --------------------------------------------------*/ static const char *DRPC_GetServerIP(void) { - const char *address; + const char *address; // If you're connected if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL) @@ -489,7 +489,7 @@ void DRPC_UpdatePresence(void) { #endif discordPresence.state = "Private"; -#ifdef MASTERSERVER +#ifdef MASTERSERVER } #endif @@ -571,9 +571,15 @@ void DRPC_UpdatePresence(void) { // Map name on tool tip char *title = G_BuildMapTitle(gamemap); - snprintf(mapname, 48, "Map: %s", title); + if (title) + { + snprintf(mapname, 48, "Map: %s", title); + Z_Free(title); + } + else + snprintf(mapname, 48, "Map: UNKNOWN"); + discordPresence.largeImageText = mapname; - Z_Free(title); } if (gamestate == GS_LEVEL && Playing()) diff --git a/src/doomdef.h b/src/doomdef.h index ab6385659..f9467199b 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -113,8 +113,8 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Saturn v8.1" -#define VERSIONSTRINGW L"Saturn v8.1" +#define VERSIONSTRING "Saturn v8.2" +#define VERSIONSTRINGW L"Saturn v8.2" // 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! // AND appveyor.yml, for the build bots! diff --git a/src/f_finale.c b/src/f_finale.c index dd024ecd0..b98570b48 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -531,8 +531,8 @@ static const char *credits[] = { "\"Xyzzy\"", "\"Chearii\"", " ", - "\"Sunflower\" aka \"AnimeSonic\"", - "\"Yuz\" aka \"Yuzler\"", + "\"Sunflower\"", + "\"Yuz\"", "\"Democrab\"", "\"EXpand\"", "\"Nexit\"", @@ -543,6 +543,7 @@ static const char *credits[] = { "\"Achii\"", "\"Anonimus\"", "\"scizor300\"", + "\"Lugent\"", "", "\1Special Thanks", "SEGA", diff --git a/src/g_game.c b/src/g_game.c index 620abdca3..70b9ffd19 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -385,7 +385,8 @@ consvar_t cv_consolechat = {"chatmode", "Window", CV_SAVE, consolechat_cons_t, N consvar_t cv_pauseifunfocused = {"pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; // Display song credits -consvar_t cv_songcredits = {"songcredits", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t songcredits_cons_t[] = {{0, "Off"}, {1, "Default"}, {2, "Box"}, {0, NULL}}; +consvar_t cv_songcredits = {"songcredits", "Default", CV_SAVE, songcredits_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // Show "FREE PLAY" when you're alone. :( consvar_t cv_showfreeplay = { "showfreeplay", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3998,7 +3999,6 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool } } - char *G_BuildMapTitle(INT32 mapnum) { char *title = NULL; @@ -5465,33 +5465,36 @@ void G_GhostTicker(void) break; } } - if (type == MT_GHOST) + if (type != -1) { - mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us - mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); - mobj->sprite = states[mobjinfo[type].spawnstate].sprite; - mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<tics = -1; // nope. - mobj->color = g->mo->color; - if (g->mo->eflags & MFE_VERTICALFLIP) + if (type == MT_GHOST) { - mobj->flags2 |= MF2_OBJECTFLIP; - mobj->eflags |= MFE_VERTICALFLIP; + mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us + mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<mo->scale); - mobj->destscale = g->mo->scale; + else + { + mobj = P_SpawnMobj(g->mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); + mobj->sprite = states[mobjinfo[type].spawnstate].sprite; + mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<tics = -1; // nope. + mobj->color = g->mo->color; + if (g->mo->eflags & MFE_VERTICALFLIP) + { + mobj->flags2 |= MF2_OBJECTFLIP; + mobj->eflags |= MFE_VERTICALFLIP; + } + P_SetScale(mobj, g->mo->scale); + mobj->destscale = g->mo->scale; + } + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z+mobj->height; + P_UnsetThingPosition(mobj); + mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... + P_SetThingPosition(mobj); + mobj->fuse = 8; + P_SetTarget(&mobj->target, g->mo); } - mobj->floorz = mobj->z; - mobj->ceilingz = mobj->z+mobj->height; - P_UnsetThingPosition(mobj); - mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... - P_SetThingPosition(mobj); - mobj->fuse = 8; - P_SetTarget(&mobj->target, g->mo); } if (ziptic & EZT_HIT) { // Spawn hit poofs for killing things! @@ -6068,15 +6071,19 @@ void G_BeginRecording(void) char *title = G_BuildMapTitle(gamemap); // Print to a separate temp buffer instead of demo.titlename, so we can use it in M_TextInputSetString - snprintf(demotitlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); + if (title) + { + snprintf(demotitlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); + Z_Free(title); + } + else + snprintf(demotitlename, 64, "%s", modeattacking ? "Time Attack" : connectedservername); // Init just in case it isn't initialized already M_TextInputInit(&demo.titlenameinput, demo.titlename, sizeof(demo.titlename)); // This will indirectly assign to demo.titlename too M_TextInputSetString(&demo.titlenameinput, demotitlename); - - Z_Free(title); } // demo checksum @@ -8140,7 +8147,7 @@ void G_SaveDemo(void) size_t i, strindex = 0; boolean dash = true; - for (i = 0; i < 127 && demo.titlename[i]; i++) + for (i = 0; demo.titlename[i] && i < 127; i++) { if ((demo.titlename[i] >= 'a' && demo.titlename[i] <= 'z') || (demo.titlename[i] >= '0' && demo.titlename[i] <= '9')) @@ -8231,6 +8238,11 @@ boolean G_DemoTitleResponder(event_t *ev) void G_SetGamestate(gamestate_t newstate) { gamestate = newstate; + + //HACK: reset musiccredits whenever we change gamestate + // since we allow them to run everywhere now + S_ResetMusicCredit(); + #ifdef HAVE_DISCORDRPC DRPC_UpdatePresence(); #endif diff --git a/src/g_input.c b/src/g_input.c index 43b7f48ca..8d5b38bf2 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1030,7 +1030,7 @@ INT32 G_KeyStringtoNum(const char *keystr) if (!keystr[0]) return 0; - if (!keystr[0] || (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z')) + if (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z') return keystr[0]; if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9') diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 3655beb8a..801442b6f 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -89,32 +89,23 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt { if (!pSurf) { - I_Error("Got a null FSurfaceInfo in batching");// nulls should not come in the stuff that batching currently applies to + I_Error("Got a null FSurfaceInfo in batching"); // nulls should not come in the stuff that batching currently applies to } if (polygonArraySize == polygonArrayAllocSize) { - PolygonArrayEntry* new_array; - // ran out of space, make new array double the size + // ran out of space, double the array size polygonArrayAllocSize *= 2; - new_array = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry)); - memcpy(new_array, polygonArray, polygonArraySize * sizeof(PolygonArrayEntry)); - free(polygonArray); - polygonArray = new_array; + polygonArray = realloc(polygonArray, polygonArrayAllocSize * sizeof(PolygonArrayEntry)); // also need to redo the index array, dont need to copy it though - free(polygonArraySorted); - polygonArraySorted = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry *)); + polygonArraySorted = realloc(polygonArraySorted, polygonArrayAllocSize * sizeof(PolygonArrayEntry*)); } while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize) { - FOutVector* new_array; // need more space for vertices in unsortedVertexArray unsortedVertexArrayAllocSize *= 2; - new_array = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector)); - memcpy(new_array, unsortedVertexArray, unsortedVertexArraySize * sizeof(FOutVector)); - free(unsortedVertexArray); - unsortedVertexArray = new_array; + unsortedVertexArray = realloc(unsortedVertexArray, unsortedVertexArrayAllocSize * sizeof(FOutVector)); } // add the polygon data to the arrays @@ -124,7 +115,7 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt polygonArray[polygonArraySize].numVerts = iNumPts; polygonArray[polygonArraySize].polyFlags = PolyFlags; polygonArray[polygonArraySize].texture = current_texture; - polygonArray[polygonArraySize].shader = (shader_target != -1) ? HWR_GetShaderFromTarget(shader_target) : shader_target; + polygonArray[polygonArraySize].shader = (shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target; polygonArray[polygonArraySize].horizonSpecial = horizonSpecial; polygonArraySize++; @@ -138,10 +129,11 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt } } + static int comparePolygons(const void *p1, const void *p2) { - PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1; - PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; + const PolygonArrayEntry *poly1 = *(PolygonArrayEntry *const *)p1; + const PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; int diff; INT64 diff64; @@ -177,9 +169,7 @@ static int comparePolygons(const void *p1, const void *p2) diff = poly1->surf.LightInfo.fade_end - poly2->surf.LightInfo.fade_end; if (diff != 0) return diff; - diff = poly1->surf.LightInfo.directional - poly2->surf.LightInfo.directional; - - return diff; + return poly1->surf.LightInfo.directional - poly2->surf.LightInfo.directional; } static int comparePolygonsNoShaders(const void *p1, const void *p2) @@ -328,19 +318,11 @@ void HWR_RenderBatches(void) // probably never will this loop run more than once though while (finalVertexWritePos + numVerts > finalVertexArrayAllocSize) { - FOutVector* new_array; - unsigned int* new_index_array; finalVertexArrayAllocSize *= 2; - new_array = malloc(finalVertexArrayAllocSize * sizeof(FOutVector)); - memcpy(new_array, finalVertexArray, finalVertexWritePos * sizeof(FOutVector)); - free(finalVertexArray); - finalVertexArray = new_array; + finalVertexArray = realloc(finalVertexArray, finalVertexArrayAllocSize * sizeof(FOutVector)); // also increase size of index array, 3x of vertex array since // going from fans to triangles increases vertex count to 3x - new_index_array = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32)); - memcpy(new_index_array, finalVertexIndexArray, finalIndexWritePos * sizeof(UINT32)); - free(finalVertexIndexArray); - finalVertexIndexArray = new_index_array; + finalVertexIndexArray = realloc(finalVertexIndexArray, finalVertexArrayAllocSize * 3 * sizeof(UINT32)); } // write the vertices of the polygon memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[entry->vertsIndex], diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 85e50465a..36f6a57a5 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -46,12 +46,16 @@ RGBA_t *HWR_GetTexturePalette(void) static INT32 format2bpp(GLTextureFormat_t format) { - if (format == GL_TEXFMT_RGBA) - return 4; - else if (format == GL_TEXFMT_ALPHA_INTENSITY_88 || format == GL_TEXFMT_AP_88) - return 2; - else - return 1; + switch (format) + { + case GL_TEXFMT_RGBA: + return 4; + case GL_TEXFMT_ALPHA_INTENSITY_88: + case GL_TEXFMT_AP_88: + return 2; + default: + return 1; + } } // This code was originally placed directly in HWR_DrawPatchInCache. @@ -221,8 +225,6 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, if (texture->width <= 0 || texture->height <= 0) return; - palette = HWR_GetTexturePalette(); - x1 = patch->originx; width = SHORT(realpatch->width); height = SHORT(realpatch->height); @@ -234,6 +236,8 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, if (patch->originy > texture->height || (patch->originy + height) < 0) return; // patch not located within texture's y bounds, ignore + palette = HWR_GetTexturePalette(); + // patch is actually inside the texture! // now check if texture is partly off-screen and adjust accordingly @@ -323,7 +327,6 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe boolean skyspecial = false; // poor hack for Legacy large skies.. RGBA_t *palette; - palette = HWR_GetTexturePalette(); texture = textures[texnum]; @@ -361,6 +364,8 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe INT32 j; RGBA_t col; + palette = HWR_GetTexturePalette(); + col = palette[HWR_CHROMAKEY_EQUIVALENTCOLORINDEX]; for (idx = 0, j = 0; j < blockheight; j++) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 08cce42c9..1da42770a 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -318,6 +318,8 @@ enum hwdsetspecialstate HWD_SET_TEXTUREFILTERMODE, HWD_SET_TEXTUREANISOTROPICMODE, + HWD_SET_WIREFRAME, + HWD_SET_MSAA, HWD_SET_SCREEN_TEXTURES, diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 9fd90fb09..7e996e083 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -241,16 +241,16 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p if (option & V_SNAPTORIGHT) cx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) - cx += (fvw - (FLOATBASEVIDWIDTH * dupx))/2; + cx += (fvw - (FLOATBASEVIDWIDTH * dupx))/2.0f; } if (fabsf(fvh - FLOATBASEVIDHEIGHT * dupy) > 1.0E-36f) { if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) - cy += (fvh/2 - (FLOATBASEVIDHEIGHT/2 * dupy)); + cy += (fvh/2.0f - (FLOATBASEVIDHEIGHT/2.0f * dupy)); else if (option & V_SNAPTOBOTTOM) cy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(option & V_SNAPTOTOP)) - cy += (fvh - (FLOATBASEVIDHEIGHT * dupy))/2; + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy))/2.0f; } } } @@ -305,10 +305,13 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[hudtrans]; - else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[hudtrans]; - else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans]; - else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; + switch (alphalevel) + { + case 13: Surf.PolyColor.s.alpha = softwaretranstogl_lo[hudtrans]; break; + case 14: Surf.PolyColor.s.alpha = softwaretranstogl[hudtrans]; break; + case 15: Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans]; break; + default: Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; break; + } flags |= PF_Modulated; GL_DrawPolygon(&Surf, v, 4, flags); @@ -392,16 +395,16 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (option & V_SNAPTORIGHT) cx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) - cx += (fvw - (FLOATBASEVIDWIDTH * dupx))/2; + cx += (fvw - (FLOATBASEVIDWIDTH * dupx))/2.0f; } if (fabsf(fvh - FLOATBASEVIDHEIGHT * dupy) > 1.0E-36f) { if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) - cy += (fvh/2 - (FLOATBASEVIDHEIGHT/2 * dupy)); + cy += (fvh/2.0f - (FLOATBASEVIDHEIGHT/2.0f * dupy)); else if (option & V_SNAPTOBOTTOM) cy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(option & V_SNAPTOTOP)) - cy += (fvh - (FLOATBASEVIDHEIGHT * dupy))/2; + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy))/2.0f; } } } @@ -467,10 +470,13 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[cv_translucenthud.value]; - else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[cv_translucenthud.value]; - else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value]; - else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; + switch (alphalevel) + { + case 13: Surf.PolyColor.s.alpha = softwaretranstogl_lo[cv_translucenthud.value]; break; + case 14: Surf.PolyColor.s.alpha = softwaretranstogl[cv_translucenthud.value]; break; + case 15: Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value]; break; + default: Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; break; + } flags |= PF_Modulated; GL_DrawPolygon(&Surf, v, 4, flags); @@ -487,7 +493,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // -------------------------------------------------------------------------- // Fills a box of pixels using a flat texture as a pattern // -------------------------------------------------------------------------- -void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum) +void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum) { FOutVector v[4]; double dflatsize; @@ -840,7 +846,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) if (color & V_SNAPTORIGHT) fx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(color & V_SNAPTOLEFT)) - fx += (fvw - (FLOATBASEVIDWIDTH * dupx)) / 2; + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)) / 2.0f; } if (fabsf(fvh - (FLOATBASEVIDHEIGHT * dupy)) > 1.0E-36f) { @@ -848,7 +854,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) if (color & V_SNAPTOBOTTOM) fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(color & V_SNAPTOTOP)) - fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)) / 2; + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)) / 2.0f; } } @@ -1122,10 +1128,13 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) if (alphalevel) { - if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[hudtrans]; - else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[hudtrans]; - else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans]; - else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; + switch (alphalevel) + { + case 13: Surf.PolyColor.s.alpha = softwaretranstogl_lo[hudtrans]; break; + case 14: Surf.PolyColor.s.alpha = softwaretranstogl[hudtrans]; break; + case 15: Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans]; break; + default: Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; break; + } } GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 88a2e9a1e..43cb25aed 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -226,6 +226,8 @@ consvar_t cv_glsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, consvar_t cv_glbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_glwireframe = {"gr_wireframe", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_glrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, glrenderdistance_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glhorizonlines = {"gr_horizonlines", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -338,6 +340,11 @@ static void HWR_SetShaderState(void) GL_SetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); } +static boolean HWR_IsWireframeMode(void) +{ + return (cv_glwireframe.value /*&& cv_debug*/); +} + static boolean HWR_OverrideObjectLightLevel(mobj_t *thing, INT32 *lightlevel) { if (R_ThingIsFullBright(thing)) @@ -4227,7 +4234,6 @@ static void *HWR_CreateDrawNode(gl_drawnode_type_t type) Z_Realloc(drawnodes, alloceddrawnodes * sizeof(gl_drawnode_t), PU_LEVEL, &drawnodes); } - drawnode = &drawnodes[numdrawnodes++]; drawnode->type = type; @@ -4458,7 +4464,10 @@ static void HWR_DrawModels(void) continue; } - if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) + if (!spr->mobj) + continue; + + if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { md2_t *md2; @@ -5259,6 +5268,9 @@ static void HWR_DrawSkyBackground(void) if (drewsky) return; + if (HWR_IsWireframeMode()) + return; + GL_SetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated); memcpy(&dometransform, &atransform, sizeof(FTransform)); @@ -5461,8 +5473,8 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_PortalClipping(rootportal); } - // Set transform. - GL_SetTransform(&atransform); + if (HWR_IsWireframeMode()) + GL_SetSpecialState(HWD_SET_WIREFRAME, 1); ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; @@ -5527,6 +5539,9 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl ps_hw_nodedrawtime.value.p = 0; HWR_RenderDrawNodes(); + if (HWR_IsWireframeMode()) + GL_SetSpecialState(HWD_SET_WIREFRAME, 0); + HWR_FreePortalList(portallist); } @@ -5750,7 +5765,7 @@ static void HWR_TogglePaletteRendering(void) // If the r_opengl "texture palette" stays the same during this switch, these textures // will not be cleared out. However they are still out of date since the // composite texture blending method has changed. Therefore they need to be cleared. - GL_ClearMipMapCache(); + HWR_LoadMapTextures(numtextures); } } else @@ -5764,7 +5779,7 @@ static void HWR_TogglePaletteRendering(void) // If the r_opengl "texture palette" stays the same during this switch, these textures // will not be cleared out. However they are still out of date since the // composite texture blending method has changed. Therefore they need to be cleared. - GL_ClearMipMapCache(); + HWR_LoadMapTextures(numtextures); } } } @@ -5801,6 +5816,8 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glbatching); + CV_RegisterVar(&cv_glwireframe); + CV_RegisterVar(&cv_glrenderdistance); CV_RegisterVar(&cv_glhorizonlines); @@ -5873,7 +5890,6 @@ static void COM_HWR_glinfo(void) CONS_Printf("Unrecognized argument: %s\n", argv); return; } - } CONS_Printf("\x88OpenGL %s\x80\n", gl_version); @@ -5993,19 +6009,19 @@ static void HWR_DoPostProcessor(player_t *player) if (cv_glscreentextures.value != 2) // screen textures are needed for the rest of the effects return; - // Capture the screen for intermission and screen waving - if (gamestate != GS_INTERMISSION) - GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); - - if (splitscreen) // Not supported in splitscreen - someone want to add support? - return; - - //UINT8 viewnum = R_GetViewNumber(); // see above + //UINT8 viewnum = R_GetViewNumber(); // see below //camera_t *thiscam = &camera[viewnum]; camera_t *thiscam = &camera[0]; + // Not supported in splitscreen - someone want to add support? + const boolean screenwave = (!splitscreen && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); + + // Capture the screen for intermission and screen waving + if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION) + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); + // Drunken vision! WooOOooo~ - if (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT) + if (screenwave) { // 10 by 10 grid. 2 coordinates (xy) float v[SCREENVERTS][SCREENVERTS][2]; @@ -6020,7 +6036,7 @@ static void HWR_DoPostProcessor(player_t *player) if (thiscam->postimg & POSTIMG_WATER) { WAVELENGTH = 5; - AMPLITUDE = 20; + AMPLITUDE = 40; FREQUENCY = 8; } else @@ -6039,6 +6055,7 @@ static void HWR_DoPostProcessor(player_t *player) v[x][y][1] = (y/((float)(SCREENVERTS-1.0f)/9.0f))-4.5f; } } + GL_PostImgRedraw(v); // Capture the screen again for screen waving on the intermission diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index b8d6ef939..6dc0d23a6 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -202,6 +202,8 @@ extern consvar_t cv_glsolvetjoin; extern consvar_t cv_glbatching; +extern consvar_t cv_glwireframe; + extern consvar_t cv_glrenderdistance; extern consvar_t cv_glhorizonlines; @@ -223,7 +225,7 @@ FUNCINLINE static ATTRINLINE boolean HWR_ShouldUsePaletteRendering(void) FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void) { - return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); + return (cv_glflashpal.value && HWR_ShouldUsePaletteRendering()); } #endif diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 12ec0cd97..07ceaf86f 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -350,6 +350,8 @@ typedef void (APIENTRY * PFNglDisable) (GLenum cap); static PFNglDisable pglDisable; typedef void (APIENTRY * PFNglGetFloatv) (GLenum pname, GLfloat *params); static PFNglGetFloatv pglGetFloatv; +typedef void (APIENTRY * PFNglPolygonMode) (GLenum, GLenum); +static PFNglPolygonMode pglPolygonMode; /* Depth Buffer */ typedef void (APIENTRY * PFNglClearDepth) (GLclampd depth); @@ -549,6 +551,7 @@ boolean SetupGLfunc(void) GETOPENGLFUNC(pglGetFloatv, glGetFloatv) GETOPENGLFUNC(pglGetIntegerv, glGetIntegerv) GETOPENGLFUNC(pglGetString, glGetString) + GETOPENGLFUNC(pglPolygonMode, glPolygonMode) GETOPENGLFUNC(pglClearDepth, glClearDepth) GETOPENGLFUNC(pglDepthFunc, glDepthFunc) @@ -2364,6 +2367,10 @@ void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value) GL_Flush(); //??? if we want to change filter mode by texture, remove this break; + case HWD_SET_WIREFRAME: + pglPolygonMode(GL_FRONT_AND_BACK, Value ? GL_LINE : GL_FILL); + break; + case HWD_SET_TEXTURE_FORMAT: gltexformat = (Value == 32) ? GL_RGBA : GL_RGB5_A1; GL_Flush(); diff --git a/src/http-mserv.c b/src/http-mserv.c index 61db5b103..74ea2ccd3 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -343,8 +343,8 @@ HMS_unlist (void) if (! hms) return 0; - curl_easy_setopt(hms->curl, CURLOPT_POST, 1); - curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDSIZE, 0); + curl_easy_setopt(hms->curl, CURLOPT_POST, (long)1); + curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDSIZE, (long)0); okay = HMS_do(hms); HMS_end(hms); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 2821c4021..0da2d9930 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2133,7 +2133,7 @@ void HU_TickSongCredits(void) } } -void HU_DrawSongCredits(void) +static void HU_DrawSongCreditsVanilla(void) { char *str; INT32 len; @@ -2141,9 +2141,6 @@ void HU_DrawSongCredits(void) INT32 y = (splitscreen ? (BASEVIDHEIGHT/2)-4 : 32); INT32 bgt; - if (!cursongcredit.def) // No def - return; - str = va("\x1F"" %s", cursongcredit.def->source); len = V_ThinStringWidth(str, V_ALLOWLOWERCASE|V_6WIDTHSPACE); destx = (len + 7) * FRACUNIT; @@ -2173,6 +2170,70 @@ void HU_DrawSongCredits(void) V_DrawRightAlignedThinString(cursongcredit.x / FRACUNIT, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_SNAPTOLEFT|(cursongcredit.trans<source; + INT32 strwidth = V_SmallStringWidth(str, V_ALLOWLOWERCASE) + 4; + + // dup dup dup dup + INT32 dup = min(vid.dupx, vid.dupy); + + // Center it + INT32 x = (BASEVIDWIDTH/2 - strwidth/2)*dup + ((vid.width - (BASEVIDWIDTH * vid.dupx)) / 2); + INT32 y = 0; + + INT32 flags = V_SNAPTOTOP|V_NOSCALESTART; + INT32 t = cursongcredit.anim; + INT32 bgt; + + fixed_t interpoffset = FixedMul(BOXCREDITHEIGHT*dup*FRACUNIT/(TICRATE/2), R_GetHudUncap()); + + if (t > BOXCREDITSLIDEIN) + { + // Sliding in + t = TICRATE/2 - (t - BOXCREDITSLIDEIN); + y = -BOXCREDITHEIGHT*dup + (FixedMul(BOXCREDITHEIGHT*FRACUNIT, FixedDiv(t*FRACUNIT, TICRATE*FRACUNIT/2))*dup + interpoffset)/FRACUNIT; + } + else if (t < TICRATE/2) + { + // Sliding out + y = -BOXCREDITHEIGHT*dup + (FixedMul(BOXCREDITHEIGHT*FRACUNIT, FixedDiv(t*FRACUNIT, TICRATE*FRACUNIT/2))*dup - interpoffset)/FRACUNIT; + } + + bgt = (NUMTRANSMAPS/2) + (cursongcredit.trans/2); + + if (bgt < NUMTRANSMAPS) + { + V_DrawFill(x, y, strwidth*dup, BOXCREDITHEIGHT*dup, 28|flags|(bgt< 1 ? 13 : 8), y = basey+(splitscreen > 1 ? 16 : 21); fixed_t scale = FRACUNIT/2; - player_t *p = &players[battlewanted[i]]; if (battlewanted[i] == -1) break; + player_t *p = &players[battlewanted[i]]; + if (numwanted == 1) scale = FRACUNIT; else @@ -10540,7 +10541,7 @@ static void K_drawKartWanted(void) y += 16; } - if (players[battlewanted[i]].skincolor) + if (p->skincolor) { colormap = R_GetTranslationColormap(TC_RAINBOW, p->skincolor, GTC_CACHE); V_DrawFixedPatch(x<menuitems[itemOn].status & IT_CV_BIGFLOAT) ? 0.5f : (1.0f/16.0f); - sprintf(s, "%f",FIXED_TO_FLOAT(cv->value)+(choice)*increment); + increment = FIXED_TO_FLOAT(cv->value)+(choice)*((currentMenu->menuitems[itemOn].status & IT_CV_BIGFLOAT) ? 0.5f : (1.0f/16.0f)); + sprintf(s,"%ld%s",(long)increment,M_Ftrim(increment)); CV_Set(cv, s); } else @@ -7167,8 +7168,11 @@ static void DrawReplayHutReplayInfo(void) if (mapheaderinfo[demolist[dir_on[menudepthleft]].map-1]) { char *title = G_BuildMapTitle(demolist[dir_on[menudepthleft]].map); - V_DrawString(x, y, V_SNAPTOTOP|MENUCAPS, title); - Z_Free(title); + if (title) + { + V_DrawString(x, y, V_SNAPTOTOP|MENUCAPS, title); + Z_Free(title); + } } else V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded."); @@ -8120,6 +8124,9 @@ UINT8 skyRoomMenuTranslations[MAXUNLOCKABLES]; static char *M_GetConditionString(condition_t cond) { + char *title = NULL; + char *response = NULL; + switch(cond.type) { case UC_PLAYTIME: @@ -8146,33 +8153,45 @@ static char *M_GetConditionString(condition_t cond) G_TicsToSeconds(cond.requirement)); case UC_MAPVISITED: { - char *title = G_BuildMapTitle(cond.requirement-1); - char *response = va("Visit %s", title); - Z_Free(title); + title = G_BuildMapTitle(cond.requirement-1); + if (title) + { + response = va("Visit %s", title); + Z_Free(title); + } return response; } case UC_MAPBEATEN: { - char *title = G_BuildMapTitle(cond.requirement-1); - char *response = va("Beat %s", title); - Z_Free(title); + title = G_BuildMapTitle(cond.requirement-1); + if (title) + { + response = va("Beat %s", title); + Z_Free(title); + } return response; } case UC_MAPALLEMERALDS: { - char *title = G_BuildMapTitle(cond.requirement-1); - char *response = va("Beat %s w/ all emeralds", title); - Z_Free(title); + title = G_BuildMapTitle(cond.requirement-1); + if (title) + { + response = va("Beat %s w/ all emeralds", title); + Z_Free(title); + } return response; } case UC_MAPTIME: { - char *title = G_BuildMapTitle(cond.extrainfo1-1); - char *response = va("Beat %s in %i:%02i.%02i", title, - G_TicsToMinutes(cond.requirement, true), - G_TicsToSeconds(cond.requirement), - G_TicsToCentiseconds(cond.requirement)); - Z_Free(title); + title = G_BuildMapTitle(cond.extrainfo1-1); + if (title) + { + response = va("Beat %s in %i:%02i.%02i", title, + G_TicsToMinutes(cond.requirement, true), + G_TicsToSeconds(cond.requirement), + G_TicsToCentiseconds(cond.requirement)); + Z_Free(title); + } return response; } case UC_TOTALEMBLEMS: diff --git a/src/m_misc.c b/src/m_misc.c index c44086f4c..944fbb73c 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1965,6 +1965,25 @@ char *M_GetToken(const char *inputString) return texturesToken; } + +const char * M_Ftrim (double f) +{ + static char dig[9];/* "0." + 6 digits (6 is printf's default) */ + int i; + /* I know I said it's the default, but just in case... */ + sprintf(dig, "%.6f", fabs(modf(f, &f))); + /* trim trailing zeroes */ + for (i = strlen(dig)-1; dig[i] == '0'; --i) + ; + if (dig[i] == '.')/* :NOTHING: */ + return ""; + else + { + dig[i + 1] = '\0'; + return &dig[1];/* skip the 0 */ + } +} + /** Count bits in a number. */ UINT8 M_CountBits(UINT32 num, UINT8 size) diff --git a/src/m_misc.h b/src/m_misc.h index 013da2235..98fbdaee7 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -104,6 +104,12 @@ boolean M_IsPathAbsolute (const char *path); void M_MkdirEach (const char *path, int start, int mode); void M_MkdirEachUntil (const char *path, int start, int end, int mode); +/* +Return dot and then the fractional part of a float, without +trailing zeros, or "" if the fractional part is zero. +*/ +const char * M_Ftrim (double); + // counting bits, for weapon ammo code, usually FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); diff --git a/src/md5.c b/src/md5.c index 66d563666..8292fb9ee 100644 --- a/src/md5.c +++ b/src/md5.c @@ -26,12 +26,6 @@ #if defined (STDC_HEADERS) || defined (_LIBC) #include -#else - #ifndef HAVE_MEMCPY - #if !(defined (_WIN32) && !defined (__CYGWIN__)) && !defined (__APPLE__) - #define memcpy(d, s, n) bcopy ((s), (d), (n)) - #endif - #endif #endif #include "md5.h" diff --git a/src/p_setup.c b/src/p_setup.c index db4641373..7a7ff208e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2747,8 +2747,6 @@ static void P_SetupPlayer(void) I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); I_mkdir(va("%s"PATHSEP"replay"PATHSEP"online", srb2home), 0755); G_RecordDemo(buf); - if (dedicated) - G_BeginRecording(); //this has to move here, since dedicated servers dont run got_mapcmd } wantedcalcdelay = wantedfrequency*2; @@ -2868,12 +2866,9 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); F_WipeEndScreen(); - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); - } - else //dedicated servers - { - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); } + + F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); } // Reset the palette now all fades have been done diff --git a/src/p_user.c b/src/p_user.c index 8151c28aa..bbf3d2478 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4296,19 +4296,17 @@ void P_DoTimeOver(player_t *player) exitcountdown = 5*TICRATE; } - /* gaysed script from me, based on Golden's sprite slope roll */ - +/* gaysed script from me, based on Golden's sprite slope roll */ // holy SHIT -static INT32 -Quaketilt (player_t *player) +static INT32 Quaketilt(player_t *player) { - angle_t tilt; + angle_t tilt, moma; fixed_t lowb; // this threshold for speed - angle_t moma = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - INT32 delta = (INT32)( player->mo->angle - moma ); + INT32 delta; fixed_t speed; - boolean sliptiding = player->kartstuff[k_drift] ? 0 : player->kartstuff[k_aizdriftstrat]; + moma = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); + delta = (INT32)( player->mo->angle - moma ); if (delta == (INT32)ANGLE_180)/* FUCK YOU HAVE A HACK */ { @@ -4318,6 +4316,9 @@ Quaketilt (player_t *player) // Hi! I'm "not a math guy"! if (abs(delta) > ANGLE_90) delta = (INT32)(( moma + ANGLE_180 ) - player->mo->angle ); + + const boolean sliptiding = player->kartstuff[k_drift] ? 0 : player->kartstuff[k_aizdriftstrat]; + if (P_IsObjectOnGround(player->mo)) { if (sliptiding) @@ -4336,23 +4337,24 @@ 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) { // ease out tilt as we slow... moma = FixedMul(moma, FixedDiv(speed, lowb)); } + return moma; } -static void -DoABarrelRoll (player_t *player) +static void DoABarrelRoll(player_t *player) { - angle_t slope; + angle_t slope = 0; angle_t delta; - fixed_t smoothing; if (player->exiting) @@ -4370,10 +4372,6 @@ DoABarrelRoll (player_t *player) { slope = player->mo->standingslope->real_zangle; } - else - { - slope = 0; - } if (abs((INT32)slope) > ANGLE_11hh) { @@ -4394,7 +4392,7 @@ DoABarrelRoll (player_t *player) smoothing = FixedDiv(AbsAngle(slope), ANGLE_45); delta = FixedDiv(delta, cv_tiltsmoothing.value * - FixedDiv(FRACUNIT, FRACUNIT + smoothing)); + FixedDiv(FRACUNIT, FRACUNIT + smoothing)); if (delta) player->tilt += delta; diff --git a/src/r_data.c b/src/r_data.c index 53f58de27..0b5b7badf 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -690,12 +690,15 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) // Patch identifier texturesToken = M_GetToken(NULL); + if (texturesToken == NULL) { I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch name should be"); } + texturesTokenLength = strlen(texturesToken); - if (texturesTokenLength>8) + + if (texturesTokenLength > 8) { I_Error("Error parsing TEXTURES lump: Patch name \"%s\" exceeds 8 characters",texturesToken); } @@ -713,10 +716,12 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) // Comma 1 Z_Free(texturesToken); texturesToken = M_GetToken(NULL); + if (texturesToken == NULL) { I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after \"%s\"'s patch name should be",patchName); } + if (strcmp(texturesToken,",")!=0) { I_Error("Error parsing TEXTURES lump: Expected \",\" after %s's patch name, got \"%s\"",patchName,texturesToken); @@ -725,14 +730,17 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) // XPos Z_Free(texturesToken); texturesToken = M_GetToken(NULL); + if (texturesToken == NULL) { I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch \"%s\"'s x coordinate should be",patchName); } + endPos = NULL; #ifndef AVOID_ERRNO errno = 0; #endif + patchXPos = strtol(texturesToken,&endPos,10); (void)patchXPos; //unused for now if (endPos == texturesToken // Empty string @@ -748,10 +756,12 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) // Comma 2 Z_Free(texturesToken); texturesToken = M_GetToken(NULL); + if (texturesToken == NULL) { I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after patch \"%s\"'s x coordinate should be",patchName); } + if (strcmp(texturesToken,",")!=0) { I_Error("Error parsing TEXTURES lump: Expected \",\" after patch \"%s\"'s x coordinate, got \"%s\"",patchName,texturesToken); @@ -760,6 +770,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) // YPos Z_Free(texturesToken); texturesToken = M_GetToken(NULL); + if (texturesToken == NULL) { I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch \"%s\"'s y coordinate should be",patchName); @@ -1131,9 +1142,9 @@ static void R_InitExtraColormaps(void) lumpnum_t R_GetFlatNumForName(const char *name) { INT32 i; - lumpnum_t lump; - lumpnum_t start; - lumpnum_t end; + lumpnum_t lump = LUMPERROR; + lumpnum_t start = LUMPERROR; + lumpnum_t end = LUMPERROR; // Scan wad files backwards so patched flats take preference. for (i = numwadfiles - 1; i >= 0; i--) @@ -1608,7 +1619,7 @@ const char *R_ColormapNameForNum(INT32 num) if (num == -1) return "NONE"; - if (num < 0 || num > MAXCOLORMAPS) + if (num < 0 || num >= MAXCOLORMAPS) I_Error("R_ColormapNameForNum: num %d is invalid!\n", num); if (foundcolormaps[num] == LUMPERROR) diff --git a/src/r_defs.h b/src/r_defs.h index 95f8a796d..a202b49ef 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -668,7 +668,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 softwarepatch_t; diff --git a/src/r_draw8.c b/src/r_draw8.c index f9e3e12e7..6edc9d6a6 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -782,10 +782,6 @@ void R_DrawSpan_8 (void) xposition <<= nflatshiftup; yposition <<= nflatshiftup; xstep <<= nflatshiftup; ystep <<= nflatshiftup; - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; - if (dest+8 > deststop) { return; diff --git a/src/r_main.c b/src/r_main.c index 5a7d77acd..490d6eda4 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -125,16 +125,17 @@ 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) +#if __SIZEOF_POINTER__ < 8 // only for 64bit static CV_PossibleValue_t drawdist_precip_cons_t[] = { - {256, "256"}, {512, "512"}, {768, "768"}, + {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; + {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"}, - {0, "None"}, {0, NULL}}; + {256, "256"}, {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; #endif static CV_PossibleValue_t maxinterpdist_cons_t[] = { @@ -1062,7 +1063,7 @@ static void R_SetupCommonFrame(player_t * player, sector_t * sector) static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) { - if (player->awayviewtics) + if (player->awayviewtics && player->awayviewmobj) { newview->aim = player->awayviewaiming; newview->angle = player->awayviewmobj->angle; @@ -1168,7 +1169,7 @@ void R_SkyboxFrame(int s) { mapheader_t *mh = mapheaderinfo[gamemap-1]; - if (player->awayviewtics) + if (player->awayviewtics && player->awayviewmobj) { SETUPSKYVIEW(player->awayviewmobj, (player->awayviewmobj->z + 20*FRACUNIT)); } @@ -1225,7 +1226,7 @@ void R_SetupFrame(int s, boolean skybox) R_SetupAimingFrame(player, thiscam); - if (player->awayviewtics) // cut-away view stuff + if (player->awayviewtics && player->awayviewmobj) // cut-away view stuff { viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN I_Assert(viewmobj != NULL); @@ -1234,7 +1235,7 @@ void R_SetupFrame(int s, boolean skybox) newview->y = viewmobj->y; newview->z = viewmobj->z + 20*FRACUNIT; - if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector) + if (viewmobj->subsector && viewmobj->subsector->sector) sector = viewmobj->subsector->sector; R_SetupCommonFrame(player, sector); @@ -1252,7 +1253,7 @@ void R_SetupFrame(int s, boolean skybox) R_SetupCommonFrame(player, sector); } - else // use the player's eyes view + else if (player->mo) // use the player's eyes view { viewmobj = player->mo; I_Assert(viewmobj != NULL); @@ -1261,7 +1262,7 @@ void R_SetupFrame(int s, boolean skybox) newview->y = viewmobj->y; newview->z = player->viewz; - if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector) + if (viewmobj->subsector && viewmobj->subsector->sector) sector = viewmobj->subsector->sector; R_SetupCommonFrame(player, sector); @@ -1349,10 +1350,10 @@ void R_RenderPlayerView(player_t *player) for (UINT8 j = 0; j <= splitscreen; j++) { - if (player == &players[displayplayers[i]] - && viewfov[i] != fov) + if (player == &players[displayplayers[j]] + && viewfov[j] != fov) { - viewfov[i] = fov; + viewfov[j] = fov; R_SetFov(fov); } } diff --git a/src/r_plane.c b/src/r_plane.c index 03dea56be..37930e89e 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -826,15 +826,18 @@ 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))) - continue; + if ((pl->ffloor->flags & FF_CUTEXTRA) && (rover->flags & FF_EXTRA)) + { + if (!(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) diff --git a/src/s_sound.c b/src/s_sound.c index 922d864d5..2f79e0540 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1436,6 +1436,11 @@ musicdef_t *S_FindMusicCredit(const char *musname) return NULL; } +void S_ResetMusicCredit(void) +{ + memset(&cursongcredit, 0, sizeof(cursongcredit)); +} + // // S_ShowSpecifiedMusicCredit // @@ -2042,9 +2047,12 @@ static boolean S_SkipIntroMusic(void) char *maptitle = G_BuildMapTitle(gamemap); // Zzz... - // check if menu music is playing, otherwise it may continue playing - if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // wandering balls changes its song when the race starts Zzz... - skip = false; + if (maptitle) + { + // check if menu music is playing, otherwise it may continue playing + if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // wandering balls changes its song when the race starts Zzz... + skip = false; + } Z_Free(maptitle); diff --git a/src/s_sound.h b/src/s_sound.h index 92e206e1b..eec99d802 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -206,6 +206,7 @@ void S_InitMTDefs(void); musicdef_t *S_FindMusicCredit(const char *musname); void S_ShowSpecifiedMusicCredit(const char *musname); void S_ShowMusicCredit(void); +void S_ResetMusicCredit(void); boolean S_PrepareSoundTest(void); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 647958653..9035e8241 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -213,10 +213,20 @@ void I_StartupSound(void) // call to start audio failed -- we do not have it return; } - + + SDL_version SDLmixcompiled; + const SDL_version *SDLmixlinked; + SDL_MIXER_VERSION(&SDLmixcompiled) + SDLmixlinked = Mix_Linked_Version(); + + I_OutputMsg("Compiled for SDL_mixer version: %d.%d.%d\n", + SDLmixcompiled.major, SDLmixcompiled.minor, SDLmixcompiled.patch); + I_OutputMsg("Linked with SDL_mixer version: %d.%d.%d\n", + SDLmixlinked->major, SDLmixlinked->minor, SDLmixlinked->patch); + #ifdef HAVE_OPENMPT - CONS_Printf("libopenmpt version: %s\n", openmpt_get_string("library_version")); - CONS_Printf("libopenmpt build date: %s\n", openmpt_get_string("build")); + I_OutputMsg("libopenmpt version: %s\n", openmpt_get_string("library_version")); + I_OutputMsg("libopenmpt build date: %s\n", openmpt_get_string("build")); #endif sound_started = true; diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index d4dec6124..c8701506e 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -212,7 +212,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) #ifdef USE_FBO_OGL char videodriver[4] = {'S','D','L',0}; if (supportFBO && strstr((const char*)gl_renderer, "NVIDIA") - && (*strncpy(videodriver, SDL_GetCurrentVideoDriver(), 4) != '\0') + && (*strncpy(videodriver, SDL_GetCurrentVideoDriver(), sizeof(videodriver)-1) != '\0') && (strncasecmp("x11",videodriver,4) == 0)) xwaylandcrap = true; #endif diff --git a/src/st_stuff.c b/src/st_stuff.c index 04523f577..4f5401aae 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -187,7 +187,7 @@ void ST_doPaletteStuff(void) #ifdef HWRENDER if (rendermode == render_opengl && !HWR_PalRenderFlashpal()) - palette = 0; // No flashpals here in OpenGL + palette = 0; // Don't set the palette to a flashpal in OpenGL's truecolor mode #endif palette = min(max(palette, 0), 13); diff --git a/src/v_video.c b/src/v_video.c index 0f3306696..7df5cacea 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -457,6 +457,9 @@ static void LoadPalette(const char *lumpname) #endif pLocalPalette[i].s.alpha = 0xFF; + if (!Cubeapply) + continue; + // lerp of colour cubing! if you want, make it smoother yourself V_CubeApply(&pLocalPalette[i].s.red, &pLocalPalette[i].s.green, &pLocalPalette[i].s.blue); } diff --git a/src/w_wad.c b/src/w_wad.c index 0c7fdbaf0..305e4b3bd 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2039,8 +2039,7 @@ static lumpchecklist_t folderblacklist[] = {NULL, 0}, }; -static int -W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) +static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) { int verified = true; @@ -2082,7 +2081,10 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) char *cdir = (char*)(malloc(LONG(zend.cdirsize))); if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize))) + { + free(cdir); return true; + } size_t offset = 0; @@ -2094,7 +2096,10 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) char* dotpos; if (memcmp(zentry->signature, pat_central, 4) != 0) + { + free(cdir); return true; + } if (verified == true) { @@ -2132,10 +2137,16 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) sizeof *zentry + SHORT(zentry->namelen) + SHORT(zentry->xtralen) + SHORT(zentry->commlen); if (fseek(fp, LONG(zentry->offset), SEEK_SET) != 0) + { + free(cdir); return true; + } if (fread(&zlentry, 1, sizeof(zlentry_t), fp) < sizeof (zlentry_t)) + { + free(cdir); return true; + } data_size += sizeof zlentry + SHORT(zlentry.namelen) + SHORT(zlentry.xtralen) + LONG(zlentry.compsize); @@ -2186,7 +2197,9 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist, goodfile = W_VerifyWAD(handle, checklist, status); } } + fclose(handle); + return goodfile; } @@ -2341,7 +2354,10 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) char *cdir = (char*)(malloc(LONG(zend.cdirsize))); if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize))) + { + free(cdir); return true; + } size_t offset = 0; @@ -2353,7 +2369,10 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) char* dotpos; if (memcmp(zentry->signature, pat_central, 4) != 0) + { + free(cdir); return false; + } fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); @@ -2373,11 +2392,19 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) strncpy(lumpname, trimname, min(8, dotpos - trimname)); if (W_NameStartsWith(lumpname, checklist)) + { + free(fullname); + free(cdir); return true; + } } if (W_NameStartsWith(fullname, checklist)) + { + free(fullname); + free(cdir); return true; + } free(fullname); @@ -2387,10 +2414,16 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) sizeof *zentry + SHORT(zentry->namelen) + SHORT(zentry->xtralen) + SHORT(zentry->commlen); if (fseek(fp, LONG(zentry->offset), SEEK_SET) != 0) + { + free(cdir); return false; + } if (fread(&zlentry, 1, sizeof(zlentry_t), fp) < sizeof (zlentry_t)) + { + free(cdir); return false; + } data_size += sizeof zlentry + SHORT(zlentry.namelen) + SHORT(zlentry.xtralen) + LONG(zlentry.compsize);