From 94bd1cb37b9b0e90e8c1fb00649aed96b2c0e20d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:24:01 +0200 Subject: [PATCH 1/9] more reference fixes --- src/lua_blockmaplib.c | 4 +++- src/p_map.c | 18 ++++++++++-------- src/p_mobj.c | 27 ++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 0b93766b8..2367673cd 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -53,10 +53,12 @@ static UINT8 lib_searchBlockmap_Objects(lua_State *L, INT32 x, INT32 y, mobj_t * CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); blockfuncerror = true; + P_SetTarget(&bnext, NULL); return 0; // *shrugs* } if (!lua_isnil(gL, -1)) { // if nil, continue + P_SetTarget(&bnext, NULL); if (lua_toboolean(gL, -1)) return 2; // stop whole search else @@ -256,4 +258,4 @@ int LUA_BlockmapLib(lua_State *L) { lua_register(L, "searchBlockmap", lib_searchBlockmap); return 0; -} \ No newline at end of file +} diff --git a/src/p_map.c b/src/p_map.c index 6051d5d1c..bcb2b6a73 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1548,13 +1548,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmceilingslope = NULL; - tmfloorthing = thing; // needed for side collision + P_SetTarget(&tmfloorthing, thing); // needed for side collision } else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; tmceilingslope = NULL; - tmfloorthing = thing; // thing we may stand on + P_SetTarget(&tmfloorthing, thing); // thing we may stand on } } else @@ -1585,13 +1585,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmfloorslope = NULL; - tmfloorthing = thing; // needed for side collision + P_SetTarget(&tmfloorthing, thing); // needed for side collision } else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; tmfloorslope = NULL; - tmfloorthing = thing; // thing we may stand on + P_SetTarget(&tmfloorthing, thing); // thing we may stand on } } } @@ -1991,8 +1991,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } // tmfloorthing is set when tmfloorz comes from a thing's top - tmfloorthing = NULL; - tmhitthing = NULL; + P_SetTarget(&tmfloorthing, NULL); + P_SetTarget(&tmhitthing, NULL); validcount++; @@ -2489,8 +2489,10 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (tmceilingz - tmfloorz < thing->height) { - if (tmfloorthing) - tmhitthing = tmfloorthing; + if (tmfloorthing != NULL) + { + P_SetTarget(&tmhitthing, tmfloorthing); + } return false; // doesn't fit } diff --git a/src/p_mobj.c b/src/p_mobj.c index 0423b00f3..b25a30065 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6073,7 +6073,8 @@ void P_MobjThinker(mobj_t *mobj) mobj->flags2 &= ~MF2_PUSHED; mobj->eflags &= ~(MFE_SPRUNG|MFE_JUSTBOUNCEDWALL); - tmfloorthing = tmhitthing = NULL; + P_SetTarget(&tmfloorthing, NULL); + P_SetTarget(&tmhitthing, NULL); // 970 allows ANY mobj to trigger a linedef exec if (mobj->subsector && GETSECSPECIAL(mobj->subsector->sector->special, 2) == 8) @@ -10030,13 +10031,29 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); P_SetTarget(&mobj->tracer, NULL); + // repair hnext chain + mobj_t *cachenext = mobj->hnext; + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + { + if (mobj->hnext->hprev == mobj) + { + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + } + + P_SetTarget(&mobj->hnext, NULL); + } + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) - P_SetTarget(&mobj->hprev->hnext, mobj->hnext); - - P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); + { + if (mobj->hprev->hnext == mobj) + { + P_SetTarget(&mobj->hprev->hnext, cachenext); + } + P_SetTarget(&mobj->hprev, NULL); + } + // clear the reference from the mapthing if (mobj->spawnpoint) P_SetTarget(&mobj->spawnpoint->mobj, NULL); From aef62c45de1c611d71d613a7a3dabc7f01e04538 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:07:23 +0200 Subject: [PATCH 2/9] smol cleanup also check for splitscreen and if not dont run a for loop lul --- src/p_tick.c | 262 ++------------------------------------------------- src/p_tick.h | 1 + 2 files changed, 10 insertions(+), 253 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 3bbc219ca..deb84a516 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -324,265 +324,25 @@ static inline void P_RunThinkers(void) } } -// -// P_DoAutobalanceTeams() -// -// Determine if the teams are unbalanced, and if so, move a player to the other team. -// -/*static void P_DoAutobalanceTeams(void) +void P_RunChaseCameras(void) { - changeteam_union NetPacket; - UINT16 usvalue; - INT32 i=0; - INT32 red=0, blue=0; - INT32 redarray[MAXPLAYERS], bluearray[MAXPLAYERS]; - INT32 redflagcarrier = 0, blueflagcarrier = 0; - INT32 totalred = 0, totalblue = 0; + UINT8 i; - NetPacket.value.l = NetPacket.value.b = 0; - memset(redarray, 0, sizeof(redarray)); - memset(bluearray, 0, sizeof(bluearray)); - - // Only do it if we have enough room in the net buffer to send it. - // Otherwise, come back next time and try again. - if (sizeof(usvalue) > GetFreeXCmdSize()) - return; - - //We have to store the players in an array with the rest of their team. - //We can then pick a random player to be forced to change teams. - for (i = 0; i < MAXPLAYERS; i++) + if (!splitscreen) { - if (playeringame[i] && players[i].ctfteam) - { - if (players[i].ctfteam == 1) - { - if (!players[i].gotflag) - { - redarray[red] = i; //store the player's node. - red++; - } - else - redflagcarrier++; - } - else - { - if (!players[i].gotflag) - { - bluearray[blue] = i; //store the player's node. - blue++; - } - else - blueflagcarrier++; - } - } - } - - totalred = red + redflagcarrier; - totalblue = blue + blueflagcarrier; - - if ((abs(totalred - totalblue) > cv_autobalance.value)) - { - if (totalred > totalblue) - { - i = M_RandomKey(red); - NetPacket.packet.newteam = 2; - NetPacket.packet.playernum = redarray[i]; - NetPacket.packet.verification = true; - NetPacket.packet.autobalance = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - - if (totalblue > totalred) - { - i = M_RandomKey(blue); - NetPacket.packet.newteam = 1; - NetPacket.packet.playernum = bluearray[i]; - NetPacket.packet.verification = true; - NetPacket.packet.autobalance = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - } -} - -// -// P_DoTeamscrambling() -// -// If a team scramble has been started, scramble one person from the -// pre-made scramble array. Said array is created in TeamScramble_OnChange() -// -void P_DoTeamscrambling(void) -{ - changeteam_union NetPacket; - UINT16 usvalue; - NetPacket.value.l = NetPacket.value.b = 0; - - // Only do it if we have enough room in the net buffer to send it. - // Otherwise, come back next time and try again. - if (sizeof(usvalue) > GetFreeXCmdSize()) - return; - - if (scramblecount < scrambletotal) - { - if (players[scrambleplayers[scramblecount]].ctfteam != scrambleteams[scramblecount]) - { - NetPacket.packet.newteam = scrambleteams[scramblecount]; - NetPacket.packet.playernum = scrambleplayers[scramblecount]; - NetPacket.packet.verification = true; - NetPacket.packet.scrambled = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - - scramblecount++; //Increment, and get to the next player when we come back here next time. + if (camera[consoleplayer].chase) + P_MoveChaseCamera(&players[consoleplayer], &camera[consoleplayer], false); } else - CV_SetValue(&cv_teamscramble, 0); -} - -static inline void P_DoSpecialStageStuff(void) -{ - boolean inwater = false; - INT32 i; - - // Can't drown in a special stage - for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) - continue; - - players[i].powers[pw_underwater] = players[i].powers[pw_spacetime] = 0; - } - - if (sstimer < 15*TICRATE+6 && sstimer > 7 && (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC)) - S_SpeedMusic(1.4f); - - if (sstimer < 7 && sstimer > 0) // The special stage time is up! - { - sstimer = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i <= splitscreen; i++) { - if (playeringame[i]) - { - players[i].exiting = raceexittime+1; - players[i].pflags &= ~PF_GLIDING; - } - - if (i == consoleplayer) - S_StartSound(NULL, sfx_lose); - } - - if (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC) - S_SpeedMusic(1.0f); - - stagefailed = true; - } - - if (sstimer > 1) // As long as time isn't up... - { - UINT32 ssrings = 0; - // Count up the rings of all the players and see if - // they've collected the required amount. - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - ssrings += (players[i].mo->health-1); - - // If in water, deplete timer 6x as fast. - if ((players[i].mo->eflags & MFE_TOUCHWATER) - || (players[i].mo->eflags & MFE_UNDERWATER)) - inwater = true; - } - - if (ssrings >= totalrings && totalrings > 0) - { - // Halt all the players - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - players[i].mo->momx = players[i].mo->momy = 0; - players[i].exiting = raceexittime+1; - } - - sstimer = 0; - - P_GiveEmerald(true); - } - - // Decrement the timer - if (!objectplacing) - { - if (inwater) - sstimer -= 6; - else - sstimer--; + if (camera[i].chase) + P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); } } } -static inline void P_DoTagStuff(void) -{ - INT32 i; - - // tell the netgame who the initial IT person is. - if (leveltime == TICRATE) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (players[i].pflags & PF_TAGIT) - { - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[i]); // Tell everyone who is it! - break; - } - } - } - - //increment survivor scores - if (leveltime % TICRATE == 0 && leveltime > (hidetime * TICRATE)) - { - INT32 participants = 0; - - for (i=0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator) - participants++; - } - - for (i=0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator && players[i].playerstate == PST_LIVE - && !(players[i].pflags & (PF_TAGIT|PF_TAGGED))) - //points given is the number of participating players divided by two. - P_AddPlayerScore(&players[i], participants/2); - } - } -} - -static inline void P_DoCTFStuff(void) -{ - // Automatic team balance for CTF and team match - if (leveltime % (TICRATE * 5) == 0) //only check once per five seconds for the sake of CPU conservation. - { - // Do not attempt to autobalance and scramble teams at the same time. - // Only the server should execute this. No verified admins, please. - if ((cv_autobalance.value && !cv_teamscramble.value) && cv_allowteamchange.value && server) - P_DoAutobalanceTeams(); - } - - // Team scramble code for team match and CTF. - if ((leveltime % (TICRATE/7)) == 0) - { - // If we run out of time in the level, the beauty is that - // the Y_Ticker() team scramble code will pick it up. - if (cv_teamscramble.value && server) - P_DoTeamscrambling(); - } -}*/ - // // P_Ticker // @@ -830,11 +590,7 @@ void P_Ticker(boolean run) } // Always move the camera. - for (i = 0; i <= splitscreen; i++) - { - if (camera[i].chase) - P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); - } + P_RunChaseCameras(); if (run) { diff --git a/src/p_tick.h b/src/p_tick.h index 2cbbb8104..11b5889ed 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -24,6 +24,7 @@ extern tic_t leveltime; void Command_Numthinkers_f(void); void Command_CountMobjs_f(void); +void P_RunChaseCameras(void); void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); From efcd1df365fe44d9fdc346d4fdb2be10ad8d2d91 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:22:10 +0200 Subject: [PATCH 3/9] fix this oops --- src/p_tick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index deb84a516..af187bbea 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -330,8 +330,8 @@ void P_RunChaseCameras(void) if (!splitscreen) { - if (camera[consoleplayer].chase) - P_MoveChaseCamera(&players[consoleplayer], &camera[consoleplayer], false); + if (camera[0].chase) + P_MoveChaseCamera(&players[displayplayers[0]], &camera[0], false); } else { From 3ad3cdfa38a6ca0af92eade8a5c2b30d5cc45838 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:07:39 +0200 Subject: [PATCH 4/9] stop yelling clang --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index ac6785a53..75bfeaadc 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -727,7 +727,7 @@ void D_SRB2Loop(void) if (lastdraw || singletics || gametic > rendergametic) { rendergametic = gametic; - rendertimeout = entertic + TICRATE/(TICRATE/2); + rendertimeout = entertic + TICRATE/17.5; doDisplay = true; } From 5824d9e803c662f73c499a96a3c73a7d3e8010d5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:21:01 +0200 Subject: [PATCH 5/9] cleanup r_things a little --- src/r_things.c | 55 +++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index a769960ea..068358802 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -38,12 +38,6 @@ #include "qs22j.h" -#ifdef PC_DOS -#include // for snprintf -int snprintf(char *str, size_t n, const char *fmt, ...); -//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap); -#endif - CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; static void R_InitSkins(void); @@ -532,15 +526,6 @@ void R_InitSprites(void) R_AddSkins((UINT16)i, false); R_LoadSpriteInfoLumps(i, wadfiles[i]->numlumps); } - - // - // check if all sprites have frames - // - /* - for (i = 0; i < numsprites; i++) - if (sprites[i].numframes < 1) - CONS_Debug(DBG_SETUP, "R_InitSprites: sprite %s has no frames at all\n", sprnames[i]); - */ } // @@ -1034,13 +1019,6 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) newsprite->extra_colormap = sector->lightlist[i].extra_colormap; -/* - if (thing->frame & FF_TRANSMASK) - ; - else if (thing->flags2 & MF2_SHADOW) - ; - else -*/ if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { @@ -1068,6 +1046,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) msecnode_t *node; sector_t *sector; ffloor_t *rover; + #define CHECKZ (isflipped ? z > thing->z+thing->height/2 && z < groundz : z < thing->z+thing->height/2 && z > groundz) for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next) @@ -1347,7 +1326,7 @@ static void R_ProjectSprite(mobj_t *thing) rollangle = thing->rollangle; } - if ((rollangle) || (pitchnroll) || (thing->player && thing->player->sliproll)) + if (rollangle || pitchnroll || (thing->player && thing->player->sliproll)) { rollsum = pitchnroll; @@ -1585,7 +1564,8 @@ static void R_ProjectSprite(mobj_t *thing) for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y) : thing->subsector->sector->lightlist[lightnum].height; - if (h <= gzt) { + if (h <= gzt) + { light = lightnum - 1; break; } @@ -3171,12 +3151,15 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) } } - if (cvar != NULL) { - if (player->localskin > 0) { + if (cvar != NULL) + { + if (player->localskin > 0) + { CV_StealthSet(&cv_fakelocalskin, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); CV_StealthSet(cvar, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); } - else { + else + { CV_StealthSet(&cv_fakelocalskin, "none"); CV_StealthSet(cvar, "none"); } @@ -3634,8 +3617,8 @@ next_token: CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); #ifdef SKINVALUES - ( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].value = ( (local) ? numlocalskins : numskins ); - ( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].strvalue = skin->name; + (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].value = (local ? numlocalskins : numskins); + (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].strvalue = skin->name; #endif // Update the forceskin possiblevalues @@ -3646,6 +3629,7 @@ next_token: } skin->localskin = local; + // so we dont have to guess if (local) skin->localnum = numlocalskins; @@ -3653,28 +3637,27 @@ next_token: skin->localnum = numskins; // add face graphics - if (local) { + if (local) ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins); - } else { + else ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins); - } #ifdef HWRENDER if (rendermode == render_opengl) - HWR_AddPlayerMD2(( (local) ? numlocalskins : numskins ), local); + HWR_AddPlayerMD2(((local) ? numlocalskins : numskins), local); #endif - if (!local) { + if (!local) + { skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins; CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight); skinstatscount[skin->kartspeed-1][skin->kartweight-1]++; CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]); - skinsorted[numskins] = numskins; } allskins[numallskins] = ( (local) ? localskins : skins )[( (local) ? numlocalskins : numskins )]; - ( (local) ? numlocalskins++ : numskins++ ); + local ? numlocalskins++ : numskins++; numallskins++; } From 3653786e14707be63bdefe92023e93c3f048a90d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:23:21 +0200 Subject: [PATCH 6/9] cleanup hw_main --- src/hardware/hw_main.c | 266 ++++++++++++++++++++--------------------- 1 file changed, 127 insertions(+), 139 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index cf95fdbcb..c4449f512 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -490,6 +490,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GL_DEFAULTMIX; fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG; + // Clamp the light level, since it can sometimes go out of the 0-255 range from animations + light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); + // Crappy backup coloring if you can't do shaders if (!HWR_UseShader()) { @@ -527,9 +530,6 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } - // Clamp the light level, since it can sometimes go out of the 0-255 range from animations - light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); - // in palette rendering mode, this is not needed since it properly takes the changes to the palette itself if (!HWR_ShouldUsePaletteRendering()) { @@ -562,9 +562,8 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if } else { - light = light - (255 - light); // Don't go out of bounds - light = CLAMP(light, 0, 255); + light = CLAMP(light - (255 - light), 0, 255); alpha = (realcolor.s.alpha*255)/25; @@ -848,11 +847,11 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc if (HWR_UseShader()) { if (PolyFlags & PF_Fog) - shader = SHADER_FOG; // fog shader + shader = SHADER_FOG; else if (PolyFlags & PF_Ripple) - shader = SHADER_WATER; // water shader + shader = SHADER_WATER; else - shader = SHADER_FLOOR; // floor shader + shader = SHADER_FLOOR; PolyFlags |= PF_ColorMapped; } @@ -1012,7 +1011,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) } if (HWR_UseShader()) - shader = SHADER_WALL; // wall shader + shader = SHADER_WALL; HWR_ProcessPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal, shader, false); } @@ -1677,51 +1676,49 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // check BOTTOM TEXTURE if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! { + fixed_t texturevpegbottom = 0; // bottom + + grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); + + // PEGGING + if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) + texturevpegbottom = 0; + else if (gr_linedef->flags & ML_EFFECT1) + texturevpegbottom = worldbottom - worldlow; + else + texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; + + texturevpegbottom += gr_sidedef->rowoffset; + + // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway + texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // Adjust t value for sloped walls + if (!(gr_linedef->flags & ML_EFFECT1)) { - fixed_t texturevpegbottom = 0; // bottom - - grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); - - // PEGGING - if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) - texturevpegbottom = 0; - else if (gr_linedef->flags & ML_EFFECT1) - texturevpegbottom = worldbottom - worldlow; - else - texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; - - texturevpegbottom += gr_sidedef->rowoffset; - - // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // Adjust t value for sloped walls - if (!(gr_linedef->flags & ML_EFFECT1)) - { - // Unskewed - wallVerts[0].t -= (worldbottom - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[1].t -= (worldbottomslope - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[3].t -= (worldlow - gr_backsector->floorheight) * grTex->scaleY; - wallVerts[2].t -= (worldlowslope - gr_backsector->floorheight) * grTex->scaleY; - } - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) - { - // Skewed by bottom - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this - wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; - } - else - { - // Skewed by top - wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; - } + // Unskewed + wallVerts[0].t -= (worldbottom - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[1].t -= (worldbottomslope - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[3].t -= (worldlow - gr_backsector->floorheight) * grTex->scaleY; + wallVerts[2].t -= (worldlowslope - gr_backsector->floorheight) * grTex->scaleY; + } + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + { + // Skewed by bottom + wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; + //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this + wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; + } + else + { + // Skewed by top + wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; + wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; } // set top/bottom coords @@ -1900,12 +1897,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode |= PF_Decal; if (!gl_drawing_stencil && gr_frontsector->numlights) - { - if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); - else - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, PF_Decal); - } + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, PF_Decal); else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); else @@ -1915,41 +1907,44 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // Single sided line... Deal only with the middletexture (if one exists) - if (gr_midtexture && gr_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL { + fixed_t texturevpeg; + + // PEGGING + if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) + texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; + else + texturevpeg = gr_sidedef->rowoffset; // top of texture at top + + grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + + wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // Texture correction for slopes + if (gr_linedef->flags & ML_EFFECT2) { - fixed_t texturevpeg; - // PEGGING - if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) - texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) - texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; - else - // top of texture at top - texturevpeg = gr_sidedef->rowoffset; - - grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); - - wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // Texture correction for slopes - if (gr_linedef->flags & ML_EFFECT2) { - wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; - wallVerts[2].t += (gr_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; - wallVerts[0].t += (gr_frontsector->floorheight - worldbottom) * grTex->scaleY; - wallVerts[1].t += (gr_frontsector->floorheight - worldbottomslope) * grTex->scaleY; - } else if (gr_linedef->flags & ML_DONTPEGBOTTOM) { - wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; - wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; - } else { - wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; - wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; - } + wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; + wallVerts[2].t += (gr_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; + wallVerts[0].t += (gr_frontsector->floorheight - worldbottom) * grTex->scaleY; + wallVerts[1].t += (gr_frontsector->floorheight - worldbottomslope) * grTex->scaleY; } + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + { + wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; + wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; + } + else + { + wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; + wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; + } + //Set textures properly on single sided walls that are sloped wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); @@ -1958,8 +1953,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); - // I don't think that solid walls can use translucent linedef types... - else + else // I don't think that solid walls can use translucent linedef types... { if (grTex->mipmap.flags & TF_TRANSPARENT) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); @@ -2150,7 +2144,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); + Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gr_frontsector->numlights) @@ -2264,7 +2258,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); + Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gr_backsector->numlights) @@ -2280,7 +2274,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } } - #undef SLOPEPARAMS //Hurdler: end of 3d-floors test } @@ -2420,8 +2413,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) // Window. // We know it's a window when the above isn't true and the back and front sectors don't match - if (backc1 != frontc1 || backc2 != frontc2 - || backf1 != frontf1 || backf2 != frontf2) + if (backc1 != frontc1 || backc2 != frontc2 || backf1 != frontf1 || backf2 != frontf2) { checkforemptylines = false; return false; @@ -2554,6 +2546,7 @@ doaddline: gld_clipper_SafeAddClipRange(angle2, angle1); checkforemptylines = false; } + // Reject empty lines used for triggers and special events. // Identical floor and ceiling on both sides, // identical light levels on both sides, @@ -2862,11 +2855,11 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t if (HWR_UseShader()) { - shader = SHADER_FLOOR; // floor shader + shader = SHADER_FLOOR; blendmode |= PF_ColorMapped; } - HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); // floor shader + HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); } void HWR_AddPolyObjectPlanes(void) @@ -3022,7 +3015,6 @@ static void HWR_Subsector(size_t num) //SoM: 4/7/2000: Test to make Boom water work in Hardware mode. gr_frontsector = R_FakeFlat(gr_frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); - //FIXME: Use floorlightlevel and ceilinglightlevel insted of lightlevel. if (gr_portal == GRPORTAL_SEARCH) { @@ -3166,7 +3158,7 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gr_frontsector->lightlist[light].lightlevel, - max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3210,7 +3202,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, - max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3865,7 +3857,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) continue; if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; + lightlevel = *list[i-1].lightlevel; colormap = list[i-1].extra_colormap; break; } @@ -3879,7 +3871,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; + lightlevel = *list[i].lightlevel; colormap = list[i].extra_colormap; } @@ -4092,16 +4084,14 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) /// \todo coloured // colormap test - { - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + sector_t *sector = spr->mobj->subsector->sector; + UINT8 lightlevel = 255; + extracolormap_t *colormap = sector->extra_colormap; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = sector->lightlevel; - HWR_Lighting(&Surf, lightlevel, colormap); - } + HWR_Lighting(&Surf, lightlevel, colormap); { FBITFIELD blend = 0; @@ -4129,7 +4119,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) if (HWR_UseShader()) { - shader = SHADER_SPRITE; // sprite shader + shader = SHADER_SPRITE; blend |= PF_ColorMapped; } @@ -4187,34 +4177,32 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) HWR_GetMappedPatch(gpatch, spr->colormap); // colormap test + sector_t *sector = spr->mobj->subsector->sector; + UINT8 lightlevel = 255; + extracolormap_t *colormap = sector->extra_colormap; + + if (sector->numlights) { - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + INT32 light; - if (sector->numlights) - { - INT32 light; + light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before - light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = *sector->lightlist[light].lightlevel; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; - - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; - } - else - { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; - - if (sector->extra_colormap) - colormap = sector->extra_colormap; - } - - HWR_Lighting(&Surf, lightlevel, colormap); + if (sector->lightlist[light].extra_colormap) + colormap = sector->lightlist[light].extra_colormap; } + else + { + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = sector->lightlevel; + + if (sector->extra_colormap) + colormap = sector->extra_colormap; + } + + HWR_Lighting(&Surf, lightlevel, colormap); if (spr->mobj->frame & FF_TRANSMASK) blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); @@ -4402,7 +4390,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean planeinfo->lumpnum = lumpnum; planeinfo->xsub = xsub; - planeinfo->alpha = alpha; + planeinfo->alpha = CLAMP(alpha, 0, 255); planeinfo->FOFSector = FOFSector; planeinfo->blend = blend; planeinfo->fogplane = fogplane; @@ -4422,7 +4410,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, polyplaneinfo->lumpnum = lumpnum; polyplaneinfo->polysector = polysector; - polyplaneinfo->alpha = alpha; + polyplaneinfo->alpha = CLAMP(alpha, 0, 255); polyplaneinfo->FOFSector = FOFSector; polyplaneinfo->blend = blend; polyplaneinfo->planecolormap = planecolormap; @@ -5879,7 +5867,7 @@ void HWR_Startup(void) HWR_TogglePaletteRendering(); -#ifdef USE_FBO_OGL +#ifdef USE_FBO_OGL HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value); #endif From 6ec96b37bdea72e3bb0d792653d95d2b360d17cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:38:51 +0200 Subject: [PATCH 7/9] remove hw_light --- src/CMakeLists.txt | 2 -- src/Makefile | 2 +- src/hardware/hw_light.c | 27 --------------------------- src/hardware/hw_light.h | 20 -------------------- src/hardware/hw_main.c | 4 +--- src/hardware/hw_md2.c | 1 - src/p_setup.c | 1 - src/p_user.c | 1 - 8 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 src/hardware/hw_light.c delete mode 100644 src/hardware/hw_light.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4bb035af..025365822 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -465,7 +465,6 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c @@ -483,7 +482,6 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h diff --git a/src/Makefile b/src/Makefile index 98351a8a2..9951ca91d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -280,7 +280,7 @@ ifdef NOHW OPTS+=-DNOHW else OPTS+=-DHWRENDER - OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o $(OBJDIR)/hw_light.o \ + OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o \ $(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o \ $(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o $(OBJDIR)/hw_shaders.o endif diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c deleted file mode 100644 index 079349c37..000000000 --- a/src/hardware/hw_light.c +++ /dev/null @@ -1,27 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2019 by Sonic Team Junior. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file - -#include "../doomdef.h" - -#ifdef HWRENDER -#include "hw_light.h" -#include "hw_drv.h" -#include "../i_video.h" -#include "../z_zone.h" -#include "../m_random.h" -#include "../m_bbox.h" -#include "../w_wad.h" -#include "../r_state.h" -#include "../r_main.h" -#include "../p_local.h" - -#endif // HWRENDER diff --git a/src/hardware/hw_light.h b/src/hardware/hw_light.h deleted file mode 100644 index fbc1d1f26..000000000 --- a/src/hardware/hw_light.h +++ /dev/null @@ -1,20 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2019 by Sonic Team Junior. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Dynamic lighting & coronas add on by Hurdler - -#ifndef _HW_LIGHTS_ -#define _HW_LIGHTS_ - -#include "hw_glob.h" -#include "hw_defs.h" - -#endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c4449f512..dddb895b2 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -12,6 +12,7 @@ /// \brief hardware renderer, using the standard HardWareRender driver DLL for SRB2 #include +#include // qsort #include "../doomstat.h" @@ -24,7 +25,6 @@ #include "hw_batching.h" #include "hw_md2.h" #include "hw_clip.h" -#include "hw_light.h" #include "../i_video.h" // for rendermode == render_glide #include "../v_video.h" @@ -48,8 +48,6 @@ #include "../m_argv.h" // parm functions for msaa #include "../p_slopes.h" -#include // qsort - #define ABS(x) ((x) < 0 ? -(x) : (x)) #define SOFTLIGHT(llevel) HWR_ShouldUsePaletteRendering() ? ((llevel) >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : (llevel) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 0b43095da..c71f47185 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -26,7 +26,6 @@ #ifdef HWRENDER #include "hw_drv.h" -#include "hw_light.h" #include "hw_md2.h" #include "../d_main.h" #include "../r_bsp.h" diff --git a/src/p_setup.c b/src/p_setup.c index 99dfc81d9..b5c92bdbc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -77,7 +77,6 @@ #endif #ifdef HWRENDER #include "hardware/hw_main.h" -#include "hardware/hw_light.h" #endif #include "p_slopes.h" diff --git a/src/p_user.c b/src/p_user.c index bacdb920d..1219414df 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -55,7 +55,6 @@ #endif #ifdef HWRENDER -#include "hardware/hw_light.h" #include "hardware/hw_main.h" #endif From bd106308fc3f8f345e7befcac46a296ff616d44f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:46:01 +0200 Subject: [PATCH 8/9] revert this doesent do anything but complicate stuff lol --- src/d_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 75bfeaadc..e53cdfb6b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -624,8 +624,7 @@ static int menuInputDelayTimer = 0; void D_SRB2Loop(void) { - tic_t entertic = 0, oldentertics = 0, realtics = 0; - double rendertimeout = INFTICS; + tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS; double deltatics = 0.0; double deltasecs = 0.0; @@ -727,7 +726,7 @@ void D_SRB2Loop(void) if (lastdraw || singletics || gametic > rendergametic) { rendergametic = gametic; - rendertimeout = entertic + TICRATE/17.5; + rendertimeout = entertic + TICRATE/17; doDisplay = true; } From 7ad5dc61ac6fc764dd69f78854ef397ad4d16c2b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 23:25:10 +0200 Subject: [PATCH 9/9] Revert "Free mipmaps before freeing tags" This reverts commit 2437c5a19a0140d3a8fb9627fa5f9300e1a6ac24. --- src/hardware/hw_main.c | 11 +++++++++++ src/p_setup.c | 6 ------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index dddb895b2..0b946ebeb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5746,6 +5746,17 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) void HWR_LoadLevel(void) { + // Lactozilla (December 8, 2019) + // Level setup used to free EVERY mipmap from memory. + // Even mipmaps that aren't related to level textures. + // Presumably, the hardware render code used to store textures as level data. + // Meaning, they had memory allocated and marked with the PU_LEVEL tag. + // Level textures are only reloaded after R_LoadTextures, which is + // when the texture list is loaded. + + // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. + HWR_FreeMipmapCache(); + HWR_CreatePlanePolygons((INT32)numnodes - 1); if (HWR_ShouldUsePaletteRendering()) diff --git a/src/p_setup.c b/src/p_setup.c index b5c92bdbc..0a868ef8c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2776,12 +2776,6 @@ boolean P_SetupLevel(boolean skipprecip) // Clear pointers that would be left dangling by the purge R_FlushTranslationColormapCache(); -#ifdef HWRENDER - // Free GPU textures before freeing patches. - if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) - HWR_FreeMipmapCache(); -#endif - Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); #if defined (WALLSPLATS) || defined (FLOORSPLATS)