diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b7ea0f472..cb5c003ae 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -121,7 +121,7 @@ UINT32 realpingtable[MAXPLAYERS] = {}; //the base table of ping where an average UINT32 playerpingtable[MAXPLAYERS] = {}; //table of player latency values. #define GENTLEMANSMOOTHING (TICRATE) -static tic_t reference_lag; +static tic_t reference_lag = 0; static UINT8 spike_time; tic_t lowest_lag = 0; tic_t simulated_lag = 0; @@ -505,10 +505,12 @@ static void ExtraDataTicker(void) } // If you are a client, you can safely forget the net commands for this tic - // If you are the server, you need to remember them until every client has been aknowledged, - // because if you need to resend a PT_SERVERTICS packet, you need to put the commands in it + // If you are the server, you need to remember them until every client has been acknowledged, + // because if you need to resend a PT_SERVERTICS packet, you will need to put the commands in it if (client) + { D_FreeTextcmd(gametic); + } } static void D_Clearticcmd(tic_t tic) @@ -1367,10 +1369,19 @@ static inline void CL_DrawConnectionStatus(void) V_DrawThinString(12 + 80, 58, V_ALLOWLOWERCASE|V_YELLOWMAP, "Vanilla"); } - if (serverlist[joinnode].info.cheatsenabled) + const UINT8 serverkartspeed = (serverlist[joinnode].info.kartvars & SV_SPEEDMASK); + + if (serverkartspeed == 2) + V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, 58, V_ALLOWLOWERCASE|V_REDMAP, "Hard Speed"); + else if (serverkartspeed == 1) + V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, 58, V_ALLOWLOWERCASE|V_BLUEMAP, "Normal Speed"); + else + V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, 58, V_ALLOWLOWERCASE|V_GREENMAP, "Easy Speed"); + + /*if (serverlist[joinnode].info.cheatsenabled) { V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, 58, V_ALLOWLOWERCASE|V_GREENMAP, "Cheats"); - } + }*/ V_DrawFill(8, 72, BASEVIDWIDTH - 16, 112, 239); @@ -1390,10 +1401,16 @@ static inline void CL_DrawConnectionStatus(void) if (playerinfo[i].node < 255) { strncpy(player_name, playerinfo[i].name, MAXPLAYERNAME); - V_DrawThinString(x + 10, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, player_name); + + // if we get a skin color + // try to colourize the player name + if (playerinfo[i].data > 0 && playerinfo[i].data < MAXSKINCOLORS) + V_DrawThinString(x + 10, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, va("%s%s ", HU_SkinColorToConsoleColor(playerinfo[i].data), player_name)); + else + 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].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 @@ -1736,16 +1753,19 @@ static void SV_SendPlayerInfo(INT32 node) // Extra data // Kart has extra skincolors, so we can't use this - netbuffer->u.playerinfo[i].data = 0; //netbuffer->u.playerinfo[i].data = players[i].skincolor; + //netbuffer->u.playerinfo[i].data = 0; //netbuffer->u.playerinfo[i].data = players[i].skincolor; - if (players[i].pflags & PF_TAGIT) - netbuffer->u.playerinfo[i].data |= 0x20; + // well why not, we only got like 100 of these? + netbuffer->u.playerinfo[i].data = players[i].skincolor; - if (players[i].gotflag) - netbuffer->u.playerinfo[i].data |= 0x40; + //if (players[i].pflags & PF_TAGIT) + //netbuffer->u.playerinfo[i].data |= 0x20; - if (players[i].powers[pw_super]) - netbuffer->u.playerinfo[i].data |= 0x80; + //if (players[i].gotflag) + //netbuffer->u.playerinfo[i].data |= 0x40; + + //if (players[i].powers[pw_super]) + //netbuffer->u.playerinfo[i].data |= 0x80; } HSendPacket(node, false, 0, sizeof(plrinfo) * MSCOMPAT_MAXPLAYERS); @@ -1928,7 +1948,7 @@ static boolean SV_ResendingSavegameToAnyone(void) static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; - savebuffer_t save; + savebuffer_t save = {0}; UINT8 *compressedsave; UINT8 *buffertosend; @@ -1998,7 +2018,7 @@ static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_O static void SV_SavedGame(void) { size_t length; - savebuffer_t save; + savebuffer_t save = {0}; char tmpsave[264]; if (!cv_dumpconsistency.value) @@ -2038,7 +2058,7 @@ static void SV_SavedGame(void) static void CL_LoadReceivedSavegame(boolean reloading) { - savebuffer_t save; + savebuffer_t save = {0}; size_t length, decompressedlen; char tmpsave[264]; @@ -7221,7 +7241,7 @@ void CL_ClearRewinds(void) rewind_t *CL_SaveRewindPoint(size_t demopos) { - savebuffer_t save; + savebuffer_t save = {0}; rewind_t *rewind; if (rewindhead && rewindhead->leveltime + REWIND_POINT_INTERVAL > leveltime) @@ -7244,7 +7264,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) rewind_t *CL_RewindToTime(tic_t time) { - savebuffer_t save; + savebuffer_t save = {0}; rewind_t *rewind; while (rewindhead && rewindhead->leveltime > time) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ed94e66f0..df832d9a3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5690,7 +5690,7 @@ static void Command_Togglemodified_f(void) static void Command_Archivetest_f(void) { - savebuffer_t save; + savebuffer_t save = {0}; UINT32 i, wrote; thinker_t *th; if (gamestate != GS_LEVEL) diff --git a/src/f_finale.c b/src/f_finale.c index d1d32285f..6f221ff4d 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -319,6 +319,7 @@ void F_IntroTicker(void) D_StartTitle(); return; } + if (finalecount == 8) S_StartSound(NULL, sfx_vroom); else if (finalecount == 47) @@ -697,7 +698,7 @@ void F_CreditTicker(void) // Draw credits text on top for (i = 0; credits[i]; i++) { - switch(credits[i][0]) + switch (credits[i][0]) { case 0: y += 80< 0; bufx--) @@ -3438,7 +3439,7 @@ void G_LoadGameData(void) INT32 i, j; UINT8 modded = false; UINT8 rtemp; - savebuffer_t save; + savebuffer_t save = {0}; //For records tic_t rectime; @@ -3571,7 +3572,7 @@ void G_SaveGameData(boolean force) size_t length; INT32 i, j; UINT8 btemp; - savebuffer_t save; + savebuffer_t save = {0}; (void)force; char backupfile[MAX_WADPATH+4]; @@ -3742,7 +3743,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) size_t length; char vcheck[VERSIONSIZE]; char savename[255]; - savebuffer_t save; + savebuffer_t save = {0}; // memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots memset(&savedata, 0, sizeof(savedata)); @@ -3828,7 +3829,7 @@ void G_SaveGame(UINT32 savegameslot) boolean saved; char savename[256] = ""; const char *backup; - savebuffer_t save; + savebuffer_t save = {0}; sprintf(savename, savegamename, savegameslot); backup = va("%s",savename); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 8b6b2abfe..921223d0f 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -381,7 +381,7 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 extralight = FixedMul(extralight, std::min(std::max(0, *lightlevel), 255) * FRACUNIT / 255); // simple OGL approximation - fixed_t tr = R_QuickCamDist(spr->mobj->x, spr->mobj->y) << FRACBITS; + fixed_t tr = R_QuickCamDist(spr->mobj->x, spr->mobj->y); fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); // Less change in contrast at further distances, to counteract DOOM diminished light @@ -2524,18 +2524,18 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) if (viewx < bspcoord[BOXLEFT]) // 1,4,6 { if (viewy > bspcoord[BOXTOP]) // 1 - mindist = R_QuickCamDist(bspcoord[BOXLEFT], bspcoord[BOXTOP]) << FRACBITS; + mindist = R_QuickCamDist(bspcoord[BOXLEFT], bspcoord[BOXTOP]); else if (viewy < bspcoord[BOXBOTTOM]) // 6 - mindist = R_QuickCamDist(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) << FRACBITS; + mindist = R_QuickCamDist(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]); else // 4 mindist = bspcoord[BOXLEFT] - viewx; } else if (viewx > bspcoord[BOXRIGHT]) // 3,5,8 { if (viewy > bspcoord[BOXTOP]) // 3 - mindist = R_QuickCamDist(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) << FRACBITS; + mindist = R_QuickCamDist(bspcoord[BOXRIGHT], bspcoord[BOXTOP]); else if (viewy < bspcoord[BOXBOTTOM]) // 8 - mindist = R_QuickCamDist(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]) << FRACBITS; + mindist = R_QuickCamDist(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]); else // 5 mindist = viewx - bspcoord[BOXRIGHT]; } diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 952bd0e66..aca1cffa0 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -120,8 +120,8 @@ void HWR_PortalFrame(gl_portal_t* portal) viewz = portal->viewz; viewangle = portal->viewangle; - viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); - viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); + //viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); + //viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); if (portal->clipline != -1) { diff --git a/src/k_hud.c b/src/k_hud.c index fa2ea7b31..12f8fd105 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4430,8 +4430,10 @@ static void K_drawLapStartAnim(void) UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); INT32 vflags = V_SNAPTOTOP|V_HUDTRANS; - fixed_t slideout = max(0, 32*(((progress - 76)*FRACUNIT) + R_GetTimeFrac(RTF_LEVEL))); - fixed_t slidein = max(0, 32*(((stplyr->kartstuff[k_lapanimation] - 76)*FRACUNIT) - R_GetTimeFrac(RTF_LEVEL))); + fixed_t slideout = 32*(((progress - 76)*FRACUNIT) + R_GetTimeFrac(RTF_LEVEL)); + slideout = max(0, slideout); + fixed_t slidein = 32*(((stplyr->kartstuff[k_lapanimation] - 76)*FRACUNIT) - R_GetTimeFrac(RTF_LEVEL)); + slidein = max(0, slidein); // First, draw the emblem and hand INT32 emblemx = (BASEVIDWIDTH << (FRACBITS - 1)) + slidein; diff --git a/src/k_kart.c b/src/k_kart.c index a73560fdc..0cbd11a9b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3423,7 +3423,7 @@ boolean K_CheckSlopeRollDist(mobj_t *mobj) return true; const fixed_t rolldist = (cv_sloperolldist.value * mapobjectscale); - const fixed_t m_dist = (R_QuickCamDist(mobj->x, mobj->y) << FRACBITS); + const fixed_t m_dist = R_QuickCamDist(mobj->x, mobj->y); return (m_dist <= rolldist); } @@ -6086,6 +6086,7 @@ static void K_KartDrift(player_t *player, boolean onground) else player->kartstuff[k_brakedrift] = 0; } + // // K_KartUpdatePosition // diff --git a/src/p_enemy.c b/src/p_enemy.c index 880f110cd..76f1af9a0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -8176,13 +8176,16 @@ void A_SPBChase(void *thing) // Smoothly rotate horz angle angle_t input = hang - actor->angle; boolean invert = (input > ANGLE_180); + fixed_t fixedinput; if (invert) input = InvAngle(input); + fixedinput = AngleFixed(input); // Slow down when turning; it looks better and makes U-turns not unfair - xyspeed = FixedMul(actor->cvmem, max(0, (((180<cvmem, max(0, xyspeed)); - input = FixedAngle(AngleFixed(input)/4); + input = FixedAngle(fixedinput/4); if (invert) input = InvAngle(input); @@ -8193,11 +8196,13 @@ void A_SPBChase(void *thing) invert = (input > ANGLE_180); if (invert) input = InvAngle(input); + fixedinput = AngleFixed(input); // Slow down when turning; might as well do it for momz, since we do it above too - zspeed = FixedMul(actor->cvmem, max(0, (((180<cvmem, max(0, zspeed)); - input = FixedAngle(AngleFixed(input)/4); + input = FixedAngle(fixedinput/4); if (invert) input = InvAngle(input); @@ -8301,13 +8306,17 @@ void A_SPBChase(void *thing) // Smoothly rotate horz angle angle_t input = hang - actor->angle; boolean invert = (input > ANGLE_180); + fixed_t fixedinput; + if (invert) input = InvAngle(input); + fixedinput = AngleFixed(input); // Slow down when turning; it looks better and makes U-turns not unfair - xyspeed = FixedMul(wspeed, max(0, (((180< ANGLE_180); if (invert) input = InvAngle(input); + fixedinput = AngleFixed(input); // Slow down when turning; might as well do it for momz, since we do it above too - zspeed = FixedMul(wspeed, max(0, (((180<flags & ML_NOSONIC) - flags |= SL_NOPHYSICS; - if (!(line->flags & ML_NOTAILS)) - flags |= SL_NODYNAMIC; - if (line->flags & ML_NOKNUX) - flags |= SL_ANCHORVERTEX; + + const boolean frontfloor = (special == 700 || special == 702 || special == 703); + const boolean backfloor = (special == 710 || special == 712 || special == 713); + const boolean frontceil = (special == 701 || special == 702 || special == 713); + const boolean backceil = (special == 711 || special == 712 || special == 703); if (!frontfloor && !backfloor && !frontceil && !backceil) { @@ -364,6 +357,13 @@ void P_SpawnSlope_Line(int linenum) return; } + if (line->flags & ML_NOSONIC) + flags |= SL_NOPHYSICS; + if (!(line->flags & ML_NOTAILS)) + flags |= SL_NODYNAMIC; + if (line->flags & ML_NOKNUX) + flags |= SL_ANCHORVERTEX; + fixed_t len = R_PointToDist2(0, 0, line->dx, line->dy); nx = FixedDiv(line->dy, len); ny = -FixedDiv(line->dx, len); @@ -809,7 +809,7 @@ void P_ResetDynamicSlopes(void) if (lines[i].flags & ML_NOKNUX) *slopetoset = P_NewVertexSlope(lines[i].tag, sides[lines[i].sidenum[which]].textureoffset >> FRACBITS, - sides[lines[i].sidenum[which]].rowoffset >> FRACBITS, flags); + sides[lines[i].sidenum[which]].rowoffset >> FRACBITS, flags); else *slopetoset = P_NewVertexSlope(lines[i].tag, lines[i].tag, lines[i].tag, flags); diff --git a/src/p_spec.c b/src/p_spec.c index cf8f76503..424e07043 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2087,13 +2087,17 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Seek offset from current song position if (line->flags & ML_EFFECT1) { + const UINT32 muslength = S_GetMusicLength(); + const UINT32 muspos = S_GetMusicPosition(); + const UINT32 muslooppoint = S_GetMusicLoopPoint(); + // adjust for loop point if subtracting - if (position < 0 && S_GetMusicLength() && - S_GetMusicPosition() > S_GetMusicLoopPoint() && - S_GetMusicPosition() + position < S_GetMusicLoopPoint()) - position = max(S_GetMusicLength() - (S_GetMusicLoopPoint() - (S_GetMusicPosition() + position)), 0); + if (position < 0 && muslength && + muspos > muslooppoint && + muspos + position < muslooppoint) + position = max(muslength - (muslooppoint - (muspos + position)), 0); else - position = max(S_GetMusicPosition() + position, 0); + position = max(muspos + position, 0); } // Fade current music to target volume (if music won't be changed) @@ -2160,11 +2164,13 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (sfxnum == sfx_None) return; // Do nothing! + if (sfxnum < sfx_None || sfxnum >= NUMSFX) { CONS_Debug(DBG_GAMELOGIC, "Line type 414 Executor: sfx number %d is invalid!\n", sfxnum); return; } + if (line->tag != 0) // Do special stuff only if a non-zero linedef tag is set { if (line->flags & ML_EFFECT5) // Repeat Midtexture diff --git a/src/p_tick.c b/src/p_tick.c index bda09969d..88e8fb2fd 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -836,10 +836,6 @@ void P_PreTicker(INT32 frames) } } - // Dynamic slopeness - if (midgamejoin) - P_RunDynamicSlopes(); - P_RunThinkers(); // Run any "after all the other thinkers" stuff diff --git a/src/p_user.c b/src/p_user.c index 5cff67f4b..0b743dcd1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -214,12 +214,11 @@ UINT8 P_GetNextEmerald(void) if (!(emeralds & EMERALD6)) return 5; return 6; } - else // Depends on stage - { - if (gamemap < sstage_start || gamemap > sstage_end) - return 0; - return (UINT8)(gamemap - sstage_start); - } + + // Depends on stage + if (gamemap < sstage_start || gamemap > sstage_end) + return 0; + return (UINT8)(gamemap - sstage_start); } // @@ -435,8 +434,8 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) if (!player->mo) return; - player->mo->health += num_rings; - player->health += num_rings; + //player->mo->health += num_rings; + //player->health += num_rings; player->totalring += num_rings; //{ SRB2kart - rings don't really do anything, but we don't want the player spilling them later. @@ -582,7 +581,8 @@ static boolean isPlayerLosing(player_t *player) if (players[i].marescore > player->marescore) ++pos; - maxpos = max(getPlayerPos(&players[i]), maxpos); + const UINT8 playerpos = getPlayerPos(&players[i]); + maxpos = max(playerpos, maxpos); } if (maxpos == 1) diff --git a/src/r_data.c b/src/r_data.c index da5a81dac..386f0e700 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -307,10 +307,10 @@ static boolean R_CheckTextureLumpLength(texture_t *texture, size_t patch) CONS_Alert( CONS_ERROR, "%.8s: texture lump data is too small. Expected %s bytes, got %s. (%s)\n", - texture->name, - sizeu1(offsetof(softwarepatch_t, columnofs)), - sizeu2(lumplength), - wadfiles[wadnum]->lumpinfo[lumpnum].fullname + texture->name, + sizeu1(offsetof(softwarepatch_t, columnofs)), + sizeu2(lumplength), + wadfiles[wadnum]->lumpinfo[lumpnum].fullname ); return false; @@ -717,38 +717,25 @@ static INT32 R_CountTextures(UINT16 wadnum) return count; } -static void -recallocuser -( void * user, - size_t old, - size_t new) -{ - char *p = Z_Realloc(*(void**)user, - new, PU_STATIC, user); - - if (new > old) - memset(&p[old], 0, (new - old)); -} - static void R_AllocateTextures(INT32 add) { const INT32 newtextures = (numtextures + add); const size_t newsize = newtextures * sizeof (void*); - const size_t oldsize = numtextures * sizeof (void*); + //const size_t oldsize = numtextures * sizeof (void*); INT32 i; // Allocate memory and initialize to 0 for all the textures we are initialising. - recallocuser(&textures, oldsize, newsize); + Z_Realloc(textures, newsize, PU_STATIC, &textures); // Allocate texture column offset table. - recallocuser(&texturecolumnofs, oldsize, newsize); + Z_Realloc(texturecolumnofs, newsize, PU_STATIC, &texturecolumnofs); // Allocate texture referencing cache. - recallocuser(&texturecache, oldsize, newsize); + Z_Realloc(texturecache, newsize, PU_STATIC, &texturecache); // Allocate texture width table. - recallocuser(&texturewidth, oldsize, newsize); + Z_Realloc(texturewidth, newsize, PU_STATIC, &texturewidth); // Allocate texture height table. - recallocuser(&textureheight, oldsize, newsize); + Z_Realloc(textureheight, newsize, PU_STATIC, &textureheight); // Create translation table for global animation. Z_Realloc(texturetranslation, (newtextures + 1) * sizeof(*texturetranslation), PU_STATIC, &texturetranslation); @@ -853,6 +840,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) { Z_Free(patchName); } + patchName = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL); memcpy(patchName,texturesToken,texturesTokenLength*sizeof(char)); patchName[texturesTokenLength] = '\0'; @@ -1249,60 +1237,6 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex) Z_Free((void *)texturesText); } -/* -static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list, size_t listsize) // SRB2kart - unused. -{ - size_t i; - UINT16 lump; - - for (i = listsize - 1; i < INT16_MAX; i--) - { - lump = W_CheckNumForNamePwad(name, list[i].wadfile, list[i].firstlump); - if (lump == INT16_MAX || lump > (list[i].firstlump + list[i].numlumps)) - continue; - else - return (list[i].wadfile<<16)+lump; - } - return LUMPERROR; -} -*/ - -/*static lumplist_t *colormaplumps = NULL; ///\todo free leak -static size_t numcolormaplumps = 0; - -static void R_InitExtraColormaps(void) -{ - lumpnum_t startnum, endnum; - UINT16 cfile, clump; - static size_t maxcolormaplumps = 16; - - for (cfile = clump = 0; cfile < numwadfiles; cfile++, clump = 0) - { - startnum = W_CheckNumForNamePwad("C_START", cfile, clump); - if (startnum == INT16_MAX) - continue; - - endnum = W_CheckNumForNamePwad("C_END", cfile, clump); - - if (endnum == INT16_MAX) - I_Error("R_InitExtraColormaps: C_START without C_END\n"); - - // This shouldn't be possible when you use the Pwad function, silly - //if (WADFILENUM(startnum) != WADFILENUM(endnum)) - //I_Error("R_InitExtraColormaps: C_START and C_END in different wad files!\n"); - - if (numcolormaplumps >= maxcolormaplumps) - maxcolormaplumps *= 2; - colormaplumps = Z_Realloc(colormaplumps, - sizeof (*colormaplumps) * maxcolormaplumps, PU_STATIC, NULL); - colormaplumps[numcolormaplumps].wadfile = cfile; - colormaplumps[numcolormaplumps].firstlump = startnum+1; - colormaplumps[numcolormaplumps].numlumps = endnum - (startnum + 1); - numcolormaplumps++; - } - CONS_Printf(M_GetText("Number of Extra Colormaps: %s\n"), sizeu1(numcolormaplumps)); -}*/ - // Search for flat name. lumpnum_t R_GetFlatNumForName(const char *name) { @@ -1430,7 +1364,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) encoremap = Z_Malloc(256 + 10, PU_LEVEL, NULL); W_ReadLump(newencoremap, encoremap); colormap_p = colormap_p2 = colormaps; - colormap_p += (256 * 32); + colormap_p += COLORMAP_REMAPOFFSET; for (p = 0; p < 32; p++) { @@ -1439,6 +1373,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) *colormap_p = colormap_p2[encoremap[i]]; colormap_p++; } + colormap_p2 += 256; } } @@ -1465,43 +1400,9 @@ void R_ClearColormaps(void) for (i = 0; i < MAXCOLORMAPS; i++) foundcolormaps[i] = LUMPERROR; - memset(extra_colormaps, 0, sizeof (extra_colormaps)); + memset(extra_colormaps, 0, sizeof(extra_colormaps)); } -/*INT32 R_ColormapNumForName(char *name) -{ - lumpnum_t lump, i; - - if (num_extra_colormaps == MAXCOLORMAPS) - I_Error("R_ColormapNumForName: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - - lump = R_CheckNumForNameList(name, colormaplumps, numcolormaplumps); - if (lump == LUMPERROR) - I_Error("R_ColormapNumForName: Cannot find colormap lump %.8s\n", name); - - for (i = 0; i < num_extra_colormaps; i++) - if (lump == foundcolormaps[i]) - return i; - - foundcolormaps[num_extra_colormaps] = lump; - - // aligned on 8 bit for asm code - extra_colormaps[num_extra_colormaps].colormap = Z_Malloc(W_LumpLength(lump), PU_LEVEL, NULL); - W_ReadLump(lump, extra_colormaps[num_extra_colormaps].colormap); - - // We set all params of the colormap to normal because there - // is no real way to tell how GL should handle a colormap lump anyway.. - extra_colormaps[num_extra_colormaps].maskcolor = 0xffff; - extra_colormaps[num_extra_colormaps].fadecolor = 0x0; - extra_colormaps[num_extra_colormaps].maskamt = 0x0; - extra_colormaps[num_extra_colormaps].fadestart = 0; - extra_colormaps[num_extra_colormaps].fadeend = 31; - extra_colormaps[num_extra_colormaps].fog = 0; - - num_extra_colormaps++; - return (INT32)num_extra_colormaps - 1; -}*/ - // // R_CreateColormap // diff --git a/src/r_draw.cpp b/src/r_draw.cpp index f27b0023c..639107daa 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -355,13 +355,14 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) // Return a normal translucency table if (--alphalevel >= 0) return transtables + (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); - else - return NULL; + + return NULL; } boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel) { - if (blendmode <= AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode >= AST_OVERLAY) + if (blendmode <= AST_COPY || blendmode == AST_SUBTRACT || + blendmode == AST_MODULATE || blendmode >= AST_OVERLAY) return true; return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]); @@ -412,7 +413,8 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f // Get colormap ret = tt[skintableindex][color]; } - else ret = NULL; + else + ret = NULL; // Generate the colormap if necessary if (!ret) @@ -435,36 +437,46 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags) UINT8* R_GetLocalTranslationColormap(skin_t *skin, skin_t *localskin, skincolors_t color, UINT8 flags, boolean local) { - if (localskin) - return RGetTranslationColormap(localskin - K_GetSkinArray(local), color, flags, local); - else - return RGetTranslationColormap((skin - skins), color, flags, false); + const INT32 skinnum = localskin ? (localskin - K_GetSkinArray(local)) : (skin - skins); + return RGetTranslationColormap(skinnum, color, flags, (localskin && local)); } patch_t* R_GetSkinFaceRank(player_t* ply) { - if (ply->skinlocal && ply->localskin) - return localfacerankprefix[ply->localskin - 1]; - else if (ply->localskin) + if (ply->localskin) + { + if (ply->skinlocal) + return localfacerankprefix[ply->localskin - 1]; + return facerankprefix[ply->localskin - 1]; + } + return facerankprefix[ply->skin]; } patch_t* R_GetSkinFaceWant(player_t* ply) { - if (ply->skinlocal && ply->localskin) - return localfacewantprefix[ply->localskin - 1]; - else if (ply->localskin) + if (ply->localskin) + { + if (ply->skinlocal) + return localfacewantprefix[ply->localskin - 1]; + return facewantprefix[ply->localskin - 1]; + } + return facewantprefix[ply->skin]; } patch_t* R_GetSkinFaceMini(player_t* ply) { - if (ply->skinlocal && ply->localskin) - return localfacemmapprefix[ply->localskin - 1]; - else if (ply->localskin) + if (ply->localskin) + { + if (ply->skinlocal) + return localfacemmapprefix[ply->localskin - 1]; + return facemmapprefix[ply->localskin - 1]; + } + return facemmapprefix[ply->skin]; } diff --git a/src/r_main.cpp b/src/r_main.cpp index 06c595809..0226d8288 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -433,10 +433,7 @@ fixed_t R_ScaleFromGlobalAngle(angle_t visangle) if (den > num>>16) { num = FixedDiv(num, den); - if (num > 64*FRACUNIT) - return 64*FRACUNIT; - if (num < 256) - return 256; + num = CLAMP(num, 256, 64*FRACUNIT); return num; } return 64*FRACUNIT; @@ -449,8 +446,8 @@ line_t *R_GetFFloorLine(const line_t *line, const ffloor_t *pfloor, const sector size_t linenum = std::min((size_t)(line - sector->lines[0]), pfloor->master->frontsector->linecount); return pfloor->master->frontsector->lines[0] + linenum; } - else - return pfloor->master; + + return pfloor->master; } side_t *R_GetFFloorSide(const line_t *line, const ffloor_t *pfloor, const sector_t *sector) @@ -460,8 +457,8 @@ side_t *R_GetFFloorSide(const line_t *line, const ffloor_t *pfloor, const sector line_t *newline = R_GetFFloorLine(line, pfloor, sector); return &sides[newline->sidenum[0]]; } - else - return &sides[pfloor->master->sidenum[0]]; + + return &sides[pfloor->master->sidenum[0]]; } // @@ -1095,7 +1092,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) // R_SetupFrame // -mobj_t *viewmobj; +mobj_t *viewmobj = NULL; static void R_SetupCommonFrame(player_t * player, sector_t * sector) { @@ -1258,13 +1255,7 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) R_SetViewContext(static_cast(VIEWCONTEXT_PLAYER1 + pnum)); - if (thiscam->reset) - { - R_ResetViewInterpolation(pnum); - thiscam->reset = false; - } - - if (player->spectator || thiscam->freecam) + if (player->spectator || (thiscam && thiscam->freecam)) { // Free flying spectator uses demo freecam. This // requires chasecam to be enabled. @@ -1274,13 +1265,22 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) if (player->playerstate == PST_DEAD || player->exiting) chasecam = true; // force chasecam on - if (chasecam && (thiscam && !thiscam->chase)) + if (thiscam) { - P_ResetCamera(player, thiscam); - thiscam->chase = true; + if (thiscam->reset) + { + R_ResetViewInterpolation(pnum); + thiscam->reset = false; + } + + if (chasecam && !thiscam->chase) + { + P_ResetCamera(player, thiscam); + thiscam->chase = true; + } + else if (!chasecam) + thiscam->chase = false; } - else if (thiscam && !chasecam) - thiscam->chase = false; newview->sky = !skybox; diff --git a/src/r_things.cpp b/src/r_things.cpp index 3cf92381e..1fe07b9db 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2908,7 +2908,7 @@ boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist) { if (limit_dist) { - if ((R_QuickCamDist(thing->x, thing->y) << FRACBITS)/mapobjectscale > limit_dist) + if (R_QuickCamDist(thing->x, thing->y)/mapobjectscale > limit_dist) { return false; } @@ -2952,7 +2952,7 @@ static boolean R_CheckInterpDist(T *thing) if (!R_UsingFrameInterpolation()) return false; - const INT32 dist = R_QuickCamDist(thing->x, thing->y); + const INT32 dist = R_QuickCamDist(thing->x, thing->y) >> FRACBITS; return (dist < cv_maxinterpdist.value); } diff --git a/src/r_things.h b/src/r_things.h index fd03a6611..b9c012b79 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -35,18 +35,25 @@ extern "C" { #define FEETADJUST (4<(absx, absy); +#else + return max(absx, absy); +#endif +} + // Takes 2 fixed-point coordinates, returns "distance" between them and camera, -// as an non-fixed-point integer. +// as an fixed-point integer. // It is very rough, tho it is used only for optimizing out unnecessary // interpolation, so it is kinda ok on big distances. - -#ifdef __cplusplus -#define R_QuickCamDist(x, y) std::max(std::abs(((x)>>FRACBITS) - (viewx>>FRACBITS)), std::abs(((y)>>FRACBITS) - (viewy>>FRACBITS))) -#define R_QuickDist(x1, y1, x, y) std::max(std::abs(((x)>>FRACBITS) - (x1>>FRACBITS)), std::abs(((y)>>FRACBITS) - (y1>>FRACBITS))) -#else -#define R_QuickCamDist(x, y) max(abs(((x)>>FRACBITS) - (viewx>>FRACBITS)), abs(((y)>>FRACBITS) - (viewy>>FRACBITS))) -#define R_QuickDist(x1, y1, x, y) max(abs(((x)>>FRACBITS) - (x1>>FRACBITS)), abs(((y)>>FRACBITS) - (y1>>FRACBITS))) -#endif +FUNCINLINE static ATTRINLINE fixed_t R_QuickCamDist(fixed_t x, fixed_t y) +{ + return R_QuickDist(viewx, viewy, x, y); +} // Constant arrays used for psprite clipping // and initializing clipping. @@ -67,6 +74,7 @@ FUNCINLINE static ATTRINLINE INT32 R_ThingLightLevel(mobj_t* thing) { return (INT32)thing->lightlevel; } + fixed_t R_GetSpriteDirectionalLighting(angle_t angle); fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); diff --git a/src/s_sound.c b/src/s_sound.c index 3bc48eba6..5bc830252 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -97,7 +97,6 @@ consvar_t cv_pausemusic = {"playmusicifpaused", "No", CV_SAVE, CV_YesNo, NULL, static CV_PossibleValue_t music_resync_threshold_cons_t[] = { {0, "MIN"}, {1000, "MAX"}, - {0} }; consvar_t cv_music_resync_threshold = {"music_resync_threshold", "0", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL}; @@ -1951,13 +1950,13 @@ static const char *musicexception_list[] = { // check if the current music is smth we dont want to keep (vote music, etc) static boolean S_CheckMusicException(void) { - if (!fasticmp(music.name, mapmusic.name)) - return true; - // dumb hack but dont keepmusic music that is supposed to reset if (music.flags & MUSIC_RELOADRESET) return true; + if (!fasticmp(music.name, mapmusic.name)) + return true; + // in case somehow the mapmusic was replaced with smth we dont want to keep for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) { @@ -2050,16 +2049,13 @@ static boolean S_SkipIntroMusic(void) if (fasticmp(music.name, "titles")) return false; - char *maptitle = G_BuildMapTitle(gamemap); // Zzz... + CLEANUP(Z_Pfree) char *maptitle = G_BuildMapTitle(gamemap); // Zzz... if (maptitle && fasticmp(maptitle, "Wandering Falls")) // wandering balls changes its song when the race starts Zzz... { - Z_Free(maptitle); return false; } - Z_Free(maptitle); - return true; } diff --git a/src/v_video.c b/src/v_video.c index fd7dab9fb..213db7bfc 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -546,7 +546,8 @@ void V_SetPalette(INT32 palettenum) V_ReloadPalette(); #ifdef HWRENDER - if (rendermode == render_soft || (rendermode == render_opengl && HWR_ShouldUsePaletteRendering())) // opengl without paletterendering hates subpalettes + if (rendermode == render_soft || + (rendermode == render_opengl && HWR_ShouldUsePaletteRendering())) // opengl without paletterendering hates subpalettes #endif { if (palettenum == 0)