From 9eff693d002a8b852766151e47f6efa84cec441f Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 27 Dec 2023 15:18:06 +0300 Subject: [PATCH 01/70] Fix noencore effect not working for walls in opengl renderer --- src/hardware/hw_cache.c | 12 ++--- src/hardware/hw_glob.h | 6 +-- src/hardware/hw_main.c | 97 ++++++++++++++++++++++------------------- src/hardware/hw_main.h | 2 +- 4 files changed, 62 insertions(+), 55 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index bfd5fa26d..7f7f031a6 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -320,7 +320,7 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap) // Create a composite texture from patches, adapt the texture size to a power of 2 // height and width for the hardware texture cache. // -static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) +static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex, boolean noencore) { UINT8 *block; texture_t *texture; @@ -354,7 +354,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) grtex->mipmap.colormap = colormaps; #ifdef GLENCORE - if (encoremap) + if (encoremap && !noencore) grtex->mipmap.colormap += (256*32); #endif @@ -552,7 +552,7 @@ void HWR_PrepLevelCache(size_t pnumtextures) HWR_FreeTextureCache(); gr_numtextures = pnumtextures; - gr_textures = calloc(pnumtextures, sizeof (*gr_textures)); + gr_textures = calloc(pnumtextures, sizeof (*gr_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore) if (gr_textures == NULL) I_Error("HWR_PrepLevelCache: can't alloc gr_textures"); } @@ -579,17 +579,17 @@ void HWR_SetPalette(RGBA_t *palette) // -------------------------------------------------------------------------- // Make sure texture is downloaded and set it as the source // -------------------------------------------------------------------------- -GLTexture_t *HWR_GetTexture(INT32 tex) +GLTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) { GLTexture_t *grtex; #ifdef PARANOIA if ((unsigned)tex >= gr_numtextures) I_Error("HWR_GetTexture: tex >= numtextures\n"); #endif - grtex = &gr_textures[tex]; + grtex = &gr_textures[tex*2 + (encoremap && !noencore ? 0 : 1)]; if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) - HWR_GenerateTexture(tex, grtex); + HWR_GenerateTexture(tex, grtex, noencore); HWD.pfnSetTexture(&grtex->mipmap); diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 1950a10da..d2a532c4c 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -62,7 +62,7 @@ void HWR_FreeExtraSubsectors(void); void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap); // ^ some flats must NOT be remapped to encore, since we remap them as we cache them for ease, adding a toggle here seems wise. -GLTexture_t *HWR_GetTexture(INT32 tex); +GLTexture_t *HWR_GetTexture(INT32 tex, boolean noencore); void HWR_GetPatch(GLPatch_t *gpatch); void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); void HWR_MakePatch(patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap); @@ -83,11 +83,11 @@ extern INT32 textureformat; // -------- // hw_main.c // originally hw_drawnodes.c from HWPortal branch // -------- -void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); +void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap); void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); void HWR_RenderDrawNodes(void); -#endif //_HW_GLOB_ \ No newline at end of file +#endif //_HW_GLOB_ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bc5888b2e..c25f3541d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -245,7 +245,7 @@ static line_t *gr_linedef; static sector_t *gr_frontsector; static sector_t *gr_backsector; -static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags); +static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, boolean noencore, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags); boolean gr_shadersavailable = true; @@ -1085,7 +1085,7 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend // // SoM: split up and light walls according to the lightlist. // This may also include leaving out parts of the wall that can't be seen -static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags) +static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, boolean noencore, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags) { float realtop, realbot, top, bot; float pegt, pegb, pegmul; @@ -1316,16 +1316,16 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cv_fofzfightfix.value) { if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); }else{ if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); } @@ -1370,16 +1370,16 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cv_fofzfightfix.value) { if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent|polyflags, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); }else{ if (cutflag & FF_FOG) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Fog|PF_NoTexture, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Translucent, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); } @@ -1712,7 +1712,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { fixed_t texturevpegtop; // top - grTex = HWR_GetTexture(gr_toptexture); + grTex = HWR_GetTexture(gr_toptexture, gr_linedef->flags & ML_TFERLINE); // PEGGING if (gr_linedef->flags & ML_DONTPEGTOP) @@ -1775,9 +1775,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #endif if (!gl_drawing_stencil && gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -1792,7 +1792,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { fixed_t texturevpegbottom = 0; // bottom - grTex = HWR_GetTexture(gr_bottomtexture); + grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); // PEGGING #ifdef ESLOPE @@ -1857,9 +1857,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #endif if (!gl_drawing_stencil && gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -1999,15 +1999,15 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom l = max(polybottom, lowcut); hS = min(highcutslope, polytopslope); lS = max(polybottomslope, lowcutslope); - + // PEGGING fixed_t texturevpeg, texturevpegslope; - - grTex = HWR_GetTexture(gr_midtexture); - + + grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + if (cv_slopepegfix.value) - { - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) + { + if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) { texturevpeg = midtexheight - h + polybottom; texturevpegslope = midtexheight - hS + polybottomslope; @@ -2017,7 +2017,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texturevpeg = polytop - h; texturevpegslope = polytopslope - hS; } - + wallVerts[3].t = texturevpeg * grTex->scaleY; wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; wallVerts[2].t = texturevpegslope * grTex->scaleY; @@ -2181,22 +2181,22 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (cv_fofzfightfix.value) { if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); + 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, &Surf, FF_CUTLEVEL, NULL, PF_Decal); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, PF_Decal); } }else{ if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_TRANSLUCENT, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, 0); else { - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); } - } + } } else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) - HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, blendmode, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); } @@ -2221,7 +2221,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // top of texture at top texturevpeg = gr_sidedef->rowoffset; - grTex = HWR_GetTexture(gr_midtexture); + 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; @@ -2257,12 +2257,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #endif if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, &Surf, FF_CUTLEVEL, NULL, 0); + 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 { if (grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -2328,6 +2328,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t high1, highslope1, low1, lowslope1; INT32 texnum; + boolean noencore = false; line_t * newline = NULL; // Multi-Property FOF if (!cv_grfofcut.value) @@ -2369,12 +2370,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); + noencore = false; if (rover->master->flags & ML_TFERLINE) { size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); + noencore = true; } #ifdef ESLOPE @@ -2463,7 +2466,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom #endif } - grTex = HWR_GetTexture(texnum); + grTex = HWR_GetTexture(texnum, noencore); #ifdef ESLOPE if (!slopeskew) // no skewing @@ -2519,9 +2522,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, 0, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gr_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); else - HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } else { @@ -2534,11 +2537,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gr_frontsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, 0); else { if (blendmode != PF_Masked) - HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, texnum, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -2569,12 +2572,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); + noencore = false; if (rover->master->flags & ML_TFERLINE) { size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); + noencore = true; } #ifdef ESLOPE //backsides h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight; @@ -2634,7 +2639,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } else { - grTex = HWR_GetTexture(texnum); + grTex = HWR_GetTexture(texnum, noencore); if (newline) { @@ -2670,9 +2675,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); if (gr_backsector->numlights) - HWR_SplitWall(gr_backsector, wallVerts, 0, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gr_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); else - HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } else { @@ -2685,11 +2690,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } if (gr_backsector->numlights) - HWR_SplitWall(gr_backsector, wallVerts, texnum, &Surf, rover->flags, rover, 0); + HWR_SplitWall(gr_backsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, 0); else { if (blendmode != PF_Masked) - HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, texnum, noencore, blendmode, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -4833,6 +4838,7 @@ typedef struct FOutVector wallVerts[4]; FSurfaceInfo Surf; INT32 texnum; + boolean noencore; FBITFIELD blend; boolean fogwall; INT32 lightlevel; @@ -4921,13 +4927,14 @@ static void *HWR_CreateDrawNode(gr_drawnode_type_t type) return NULL; } -void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) +void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) { wallinfo_t *wallinfo = HWR_CreateDrawNode(DRAWNODE_WALL); M_Memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts)); M_Memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo)); wallinfo->texnum = texnum; + wallinfo->noencore = noencore; wallinfo->blend = blend; wallinfo->fogwall = fogwall; wallinfo->lightlevel = lightlevel; @@ -5080,7 +5087,7 @@ void HWR_RenderDrawNodes(void) wallinfo_t *wall = &drawnode->u.wall; if (!(wall->blend & PF_NoTexture)) - HWR_GetTexture(wall->texnum); + HWR_GetTexture(wall->texnum, wall->noencore); HWR_RenderWall(wall->wallVerts, &wall->Surf, wall->blend, wall->fogwall, wall->lightlevel, wall->wallcolormap); } @@ -5797,7 +5804,7 @@ void HWR_DrawSkyBackground(float fpov) dometransform.roll = atransform.roll; dometransform.splitscreen = splitscreen; - HWR_GetTexture(texturetranslation[skytexture]); + HWR_GetTexture(texturetranslation[skytexture], false); HWD.pfnSetShader(7); // sky shader HWD.pfnRenderSkyDome(skytexture, textures[skytexture]->width, textures[skytexture]->height, dometransform); HWD.pfnSetShader(0); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 3dc18ccf8..195ff0e6f 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -132,7 +132,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap); -void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); +void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 texnum, boolean noencore, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); // moved HWR_SplitWall to hw_main.c void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf); void HWR_DrawSkyBackground(float fpov); -- 2.54.0 From 04ba08a8258d32862f1c15353a9c270b947e3ad9 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 27 Dec 2023 14:23:40 +0100 Subject: [PATCH 02/70] move noencore out of fof stuff idk if this is right lmao --- src/hardware/hw_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c25f3541d..136def751 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1492,6 +1492,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom FUINT lightnum = 0; // shut up compiler extracolormap_t *colormap; FSurfaceInfo Surf; + + boolean noencore = false; gr_sidedef = gr_curline->sidedef; gr_linedef = gr_curline->linedef; @@ -1575,6 +1577,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { INT32 gr_toptexture, gr_bottomtexture; // two sided line + + noencore = false; #ifdef ESLOPE SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) @@ -1584,6 +1588,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom worldlow = gr_backsector->floorheight; #endif + if (gr_linedef->flags & ML_TFERLINE) + noencore = true; + // Sky culling if (!gr_curline->polyseg) // Don't do it for polyobjects { @@ -2328,7 +2335,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t high1, highslope1, low1, lowslope1; INT32 texnum; - boolean noencore = false; line_t * newline = NULL; // Multi-Property FOF if (!cv_grfofcut.value) @@ -2370,14 +2376,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); - noencore = false; if (rover->master->flags & ML_TFERLINE) { size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); - noencore = true; } #ifdef ESLOPE @@ -2572,14 +2576,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); - noencore = false; if (rover->master->flags & ML_TFERLINE) { size_t linenum = min(gr_curline->linedef-gr_backsector->lines[0], rover->master->frontsector->linecount); newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); - noencore = true; } #ifdef ESLOPE //backsides h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight; -- 2.54.0 From 81a8fc3daa3afa35681a8f1d03aefd7b6cf68892 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 27 Dec 2023 15:02:57 +0100 Subject: [PATCH 03/70] move this out of gr_backsector --- src/hardware/hw_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 136def751..0d1b698d3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1569,7 +1569,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = gr_frontsector->extra_colormap; } - + + if (gr_linedef->flags & ML_TFERLINE) + noencore = true; + if (gr_frontsector) Surf.PolyColor.s.alpha = 255; @@ -1577,8 +1580,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { INT32 gr_toptexture, gr_bottomtexture; // two sided line - - noencore = false; #ifdef ESLOPE SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) @@ -1588,9 +1589,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom worldlow = gr_backsector->floorheight; #endif - if (gr_linedef->flags & ML_TFERLINE) - noencore = true; - // Sky culling if (!gr_curline->polyseg) // Don't do it for polyobjects { -- 2.54.0 From 6748d5ad303782584bb4e65f53cf872baa8094b3 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 27 Dec 2023 17:28:02 +0300 Subject: [PATCH 04/70] Remove unneeded condition for encore remap in opengl renderer (consistency with software renderer) --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 136def751..a2f59ab0c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5625,7 +5625,7 @@ void HWR_ProjectSprite(mobj_t *thing) { vis->colormap = colormaps; #ifdef GLENCORE - if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)) && !(thing->flags & MF_DONTENCOREMAP)) + if (encoremap && !(thing->flags & MF_DONTENCOREMAP)) vis->colormap += (256*32); #endif } -- 2.54.0 From b0f3b515d2b5a9f96b1a1b7606d30e48de9fe963 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 11 Feb 2024 14:53:16 +0100 Subject: [PATCH 05/70] Add cvar gr_maxinterpdist, which allows to control max distance on which mobjs will be interpolated --- src/hardware/hw_main.c | 14 ++++++++++---- src/hardware/hw_md2.c | 2 +- src/r_main.c | 10 ++++++++++ src/r_main.h | 1 + src/r_things.c | 4 ++-- src/r_things.h | 6 ++++++ 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 79d9e5085..68a0f7338 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4102,8 +4102,10 @@ static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts interpmobjstate_t interp = {0}; float basey, lowy; + INT32 dist = R_QuickCamDist(spr->mobj->x, spr->mobj->y); + // do interpolation - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { if (precip) { @@ -5315,7 +5317,9 @@ void HWR_ProjectSprite(mobj_t *thing) if (!thing) return; - if (R_UsingFrameInterpolation() && !paused) + INT32 dist = R_QuickCamDist(thing->x, thing->y); + + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolateMobjState(thing, rendertimefrac, &interp); } @@ -5655,12 +5659,14 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) if (!thing) return; - + + INT32 dist = R_QuickCamDist(thing->x, thing->y); + // uncapped/interpolation interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp); } diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index c64d77639..fd6cf4f16 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1157,7 +1157,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr) angle_t ang; interpmobjstate_t interp; - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || R_QuickCamDist(spr->mobj->x, spr->mobj->y) < cv_grmaxinterpdist.value)) { R_InterpolateMobjState(spr->mobj, rendertimefrac, &interp); } diff --git a/src/r_main.c b/src/r_main.c index 44c388ec8..274ea079a 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -153,6 +153,12 @@ static CV_PossibleValue_t drawdist_precip_cons_t[] = { {3072, "3072"}, {0, "None"}, {0, NULL}}; +static CV_PossibleValue_t maxinterpdist_cons_t[] = { + /*{256, "256"},*/ {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, + {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; + static CV_PossibleValue_t fov_cons_t[] = {{5*FRACUNIT, "MIN"}, {178*FRACUNIT, "MAX"}, {0, NULL}}; //static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}}; @@ -201,6 +207,8 @@ consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_pre consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", 0, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + // cap fov, fov too high tears software apart. consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -1885,6 +1893,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_maxportals); + CV_RegisterVar(&cv_grmaxinterpdist); + // Default viewheight is changeable, // initialized to standard viewheight //CV_RegisterVar(&cv_viewheight); diff --git a/src/r_main.h b/src/r_main.h index dadb1c9cf..f057db234 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -117,6 +117,7 @@ extern consvar_t /*cv_precipdensity,*/ cv_drawdist, /*cv_drawdist_nights,*/ cv_d extern consvar_t cv_fov; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; +extern consvar_t cv_grmaxinterpdist; // Called by startup code. void R_Init(void); diff --git a/src/r_things.c b/src/r_things.c index 6cc11b49f..1e9a116cc 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1357,7 +1357,7 @@ static void R_ProjectSprite(mobj_t *thing) interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || R_QuickCamDist(thing->x, thing->y) < cv_grmaxinterpdist.value)) { R_InterpolateMobjState(oldthing, rendertimefrac, &interp); } @@ -1881,7 +1881,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || R_QuickCamDist(thing->x, thing->y) < cv_grmaxinterpdist.value)) { R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp); } diff --git a/src/r_things.h b/src/r_things.h index 823bad9a8..e6470a952 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -32,6 +32,12 @@ #define FEETADJUST (4<>FRACBITS) - (viewx>>FRACBITS)), abs(((y)>>FRACBITS) - (viewy>>FRACBITS))) + // Constant arrays used for psprite clipping // and initializing clipping. extern INT16 negonearray[MAXVIDWIDTH]; -- 2.54.0 From 4732f9578204832a84492a6d06d07aa400eadcc1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 11 Feb 2024 14:51:14 +0100 Subject: [PATCH 06/70] toggable mobj subsector interpolation honestly couldnt spot any difference at all but R_PointinSubsector is quite expensive so making a toggle seems cool --- src/r_fps.c | 12 ++++++++++-- src/r_fps.h | 1 + src/r_main.c | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 041a51a05..efbf36564 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -39,6 +39,8 @@ consvar_t cv_fpscap = {"fpscap", "Match refresh rate", CV_SAVE, fpscap_cons_t, N consvar_t cv_precipinterp = {"precipinterpolation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mobjssector = {"mobjsubsectorinterp", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + UINT32 R_GetFramerateCap(void) { if (rendermode == render_none) @@ -315,7 +317,10 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) //out->spritexoffset = mobj->spritexoffset; //out->spriteyoffset = mobj->spriteyoffset; - out->subsector = R_PointInSubsector(out->x, out->y); + if (cv_mobjssector.value) + out->subsector = R_PointInSubsector(out->x, out->y); + else + out->subsector = mobj->subsector; if (mobj->player) { @@ -361,7 +366,10 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->spritexoffset = mobj->spritexoffset; out->spriteyoffset = mobj->spriteyoffset; - out->subsector = R_PointInSubsector(out->x, out->y); + if (cv_mobjssector.value) + out->subsector = R_PointInSubsector(out->x, out->y); + else + out->subsector = mobj->subsector; out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); } diff --git a/src/r_fps.h b/src/r_fps.h index deb0c8788..35585517d 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -21,6 +21,7 @@ extern consvar_t cv_fpscap; extern consvar_t cv_precipinterp; +extern consvar_t cv_mobjssector; UINT32 R_GetFramerateCap(void); boolean R_UsingFrameInterpolation(void); diff --git a/src/r_main.c b/src/r_main.c index 274ea079a..e78e88982 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1902,4 +1902,5 @@ void R_RegisterEngineStuff(void) // Frame interpolation/uncapped CV_RegisterVar(&cv_fpscap); CV_RegisterVar(&cv_precipinterp); + CV_RegisterVar(&cv_mobjssector); } -- 2.54.0 From 8ba926550cfeb739178920ccf0302cd062b1b028 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 11 Feb 2024 14:51:44 +0100 Subject: [PATCH 07/70] only interpolate pitch, roll, slopepitch and sloperoll when using sprite rotation --- src/r_fps.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index efbf36564..5a454c679 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -331,13 +331,23 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); } - // pitch roll stuff - out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); - out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); + if (cv_spriteroll.value) // no need to interpolate this if its disabled + { + // pitch roll stuff + out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); + out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); - // and the slope stuff - out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); - out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); + // and the slope stuff + out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); + out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); + } + else + { + out->pitch = mobj->pitch; + out->roll = mobj->roll; + out->slopepitch = mobj->slopepitch; + out->sloperoll = mobj->sloperoll; + } } void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjstate_t *out) -- 2.54.0 From 088426a654133afffe57f82832d202080847a3d5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 11 Feb 2024 15:05:58 +0100 Subject: [PATCH 08/70] only interpolate those if we use the stuff that uses them --- src/r_fps.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 5a454c679..7045e17ee 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -298,11 +298,29 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); - out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); - out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); - out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); - + + if (cv_gravstretch.value || cv_saltysquish.value) // for now we only use it for those two features so no need to interpolate this when we dont use stuff + { + out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); + out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); + } + else + { + out->spritexscale = mobj->spritexscale; + out->spriteyscale = mobj->spriteyscale; + } + + if (cv_saltyhop.value) // same here + { + out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); + out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); + } + else + { + out->spritexoffset = mobj->spritexoffset; + out->spriteyoffset = mobj->spriteyoffset; + } + if (mobj->scale == mobj->old_scale) // Tiny optimisation - scale is usually unchanging, so let's skip a lerp, two FixedMuls, and two FixedDivs { out->scale = mobj->scale; @@ -312,11 +330,6 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->scale = R_LerpFixed(mobj->old_scale, mobj->scale, frac); } - // Sprite offsets are not interpolated until we have a way to interpolate them explicitly in Lua. - // It seems existing mods visually break more often than not if it is interpolated. - //out->spritexoffset = mobj->spritexoffset; - //out->spriteyoffset = mobj->spriteyoffset; - if (cv_mobjssector.value) out->subsector = R_PointInSubsector(out->x, out->y); else -- 2.54.0 From 242df89d0e12830299c48d4e473aa60dabaebdec Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 11 Feb 2024 15:10:16 +0100 Subject: [PATCH 09/70] forgor --- src/r_fps.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/r_fps.c b/src/r_fps.c index 7045e17ee..11c88a987 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -16,6 +16,7 @@ #include "r_main.h" #include "g_game.h" +#include "k_kart.h" // saltyhop stuffs #include "i_video.h" #include "r_plane.h" #include "p_spec.h" -- 2.54.0 From 2ebb71fb6c55b94a1baa982b6d7ff15c9bb6c51f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 11 Feb 2024 15:21:20 +0100 Subject: [PATCH 10/70] add stuff to menu --- src/m_menu.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 80e0ba5db..4cd99404d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1485,28 +1485,32 @@ static menuitem_t OP_ColorOptionsMenu[] = static menuitem_t OP_ExpOptionsMenu[] = { {IT_HEADER, NULL, "Experimental Options", NULL, 10}, - {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 25}, - {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 35}, + {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_grmaxinterpdist, 25}, + {IT_STRING|IT_CVAR, NULL, "Mobj Subsector Interpolation", &cv_mobjssector, 35}, + {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 45}, + {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 55}, - {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 55}, + {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 75}, - {IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 75}, - {IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 85}, + {IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 95}, + {IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 105}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 75}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_grscreentextures, 95}, - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 85}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 105}, - {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 105}, - {IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 115}, - {IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 125}, - {IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 135}, + {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 125}, + {IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 135}, + {IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 145}, + {IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 155}, #endif }; static const char* OP_ExpTooltips[] = { NULL, + "How far Mobj interpolation should take effect.", + "Toggles Mobj Subsector Interpolation.", "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", "When weather is on this will cut the object amount used in half.", "Show a VHS-like effect when the game is paused\n or youre rewinding replays.", @@ -1525,6 +1529,8 @@ static const char* OP_ExpTooltips[] = enum { op_exp_header, + op_exp_interpdist, + op_exp_mobjssector, op_exp_precipinter, op_exp_lessprecip, op_exp_vhs, -- 2.54.0 From 2b1d192eddabb98fb1ab6b51c0a9a2e05cea05d0 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Feb 2024 20:22:05 +0100 Subject: [PATCH 11/70] make this save --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index e78e88982..90c749d9a 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -207,7 +207,7 @@ consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_pre consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", 0, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // cap fov, fov too high tears software apart. consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; -- 2.54.0 From 2fb75f7739ce203dbbad06a3c6229a27afc90b40 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Sun, 18 Feb 2024 17:44:38 +0100 Subject: [PATCH 12/70] Fix V_SPLITSCREEN on OpenGL Now matches v_video.c --- src/hardware/hw_draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8ff2ca972..ee0fd0b85 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -234,7 +234,7 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { - if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) + if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); @@ -385,7 +385,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { - if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) + if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); -- 2.54.0 From 9362d5abd4e077afa1d8a4ebed055a4044604d1c Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Mon, 19 Feb 2024 00:38:11 +0100 Subject: [PATCH 13/70] Add stplyrnum, move to st_stuff --- src/p_enemy.c | 1 - src/p_local.h | 3 --- src/st_stuff.c | 5 +++++ src/st_stuff.h | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index e617cfbce..cde88e607 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -33,7 +33,6 @@ boolean LUA_CallAction(const char *action, mobj_t *actor); #endif -player_t *stplyr; INT32 var1; INT32 var2; diff --git a/src/p_local.h b/src/p_local.h index df8df412e..e93d4b411 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -306,9 +306,6 @@ void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration); // P_ENEMY // -// main player in game -extern player_t *stplyr; // for splitscreen correct palette changes and overlay - // Is there a better place for these? extern INT32 var1; extern INT32 var2; diff --git a/src/st_stuff.c b/src/st_stuff.c index b4b4a3d49..e7352186b 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -150,6 +150,10 @@ static patch_t *hud_tv2; static patch_t *envelope; #endif +// current player for overlay drawing +player_t *stplyr; +UINT8 stplyrnum; + // SRB2kart hudinfo_t hudinfo[NUMHUDITEMS] = @@ -2223,6 +2227,7 @@ void ST_Drawer(void) for (i = 0; i <= splitscreen; i++) { stplyr = &players[displayplayers[i]]; + stplyrnum = i; ST_overlayDrawer(); } diff --git a/src/st_stuff.h b/src/st_stuff.h index 0dffa46c3..d46688e8f 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -68,6 +68,8 @@ boolean ST_SameTeam(player_t *a, player_t *b); extern boolean st_overlay; // sb overlay on or off when fullscreen extern INT32 st_palette; // 0 is default, any others are special palettes. +extern player_t *stplyr; // for splitscreen correct palette changes and overlay +extern UINT8 stplyrnum; extern lumpnum_t st_borderpatchnum; // patches, also used in intermission -- 2.54.0 From 913b374f9baa4ff7ee9e4ec401025f71883bd4ce Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:16:54 +0100 Subject: [PATCH 14/70] Lua functions for colorization, offsets, drawing HUD items Introduce drawinfo_t to pass coords/flags to both hardcode and Lua * v.getDrawInfo: return X/Y/flags for the given HUD item * v.drawItemBox: draw the item box, with support for all effects * v.drawItemMul: draw multi sticker, for convenience * v.getHudColor: return HUD color * v.useColorHud: return true if colorization is enabled * hud.getOffsets: return xoffset/yoffset for the given HUD item --- LUASTUFF.md | 35 ++++++- src/k_kart.c | 259 +++++++++++++++++++++++++++-------------------- src/k_kart.h | 14 +++ src/lua_hudlib.c | 133 ++++++++++++++++++++++++ 4 files changed, 327 insertions(+), 114 deletions(-) diff --git a/LUASTUFF.md b/LUASTUFF.md index 2ccd71dcb..13d4cea8f 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -2,7 +2,7 @@ ## mobj.localskin and player.localskin fields -Allow reading and assigning localskins to players. Local skins for other objects aren't supported currently. +Allow reading and assigning localskins. ## mobj.rollsum field @@ -20,9 +20,40 @@ Changes vote background texture prefix (game looks for PREFIX + "W" or "C" (depe ## hud.add(fn, "vote") and hud.add(fn, "intermission") Hud hooks for vote screen and intermission screen. They only get drawer (`v`) as argument. -To check if those hooks are available, check if globals FEATURE\_VOTEHUD and FEATURE\_INERMISSIONHUD +To check if those hooks are available, check if globals FEATURE\_VOTEHUD and FEATURE\_INTERMISSIONHUD exist. +## x, y = hud.getOffsets(item) + +Returns the values of the given HUD item's `xoffset`/`yoffset` cvars, or nil if unsupported. +Uses the same strings as `hud.enabled`. + +## x, y, flags = v.getDrawInfo(item) + +Returns the X, Y and flags where the given HUD item will be drawn for the current displayplayer. +Available for `item`, `gametypeinfo` and `minimap`. + +## v.drawItemBox(x, y, flags, small, dark, colormap) + +Draws an item box at the given coordinates. +`small`: true to draw small item box, false to draw large item box. +`dark`: true if item box should be darkened. +`colormap`: Colormap to draw the item box with. If nil, use displayplayer's HUD colormap. + +## v.drawItemMul(x, y, flags, small, colormap) + +Draws a multi-item sticker at the given coordinates. +`small`: true to draw small sticker, false to draw large sticker. +`colormap`: Colormap to draw the sticker with. If nil, use displayplayer's HUD colormap. + +## hudcolor = v.getHudColor() + +Returns the displayplayer's HUD color. + +## colorize = v.useColorHud() + +Returns true if colorization is enabled, false otherwise. + ## mobj.spritexscale, mobj.spriteyscale, mobj.spritexoffset, mobj.spriteyoffset, mobj.rollangle, mobj.sloperoll, mobj.rollmodel fields Same fields as in SRB2 2.2 diff --git a/src/k_kart.c b/src/k_kart.c index 920a607fb..40d519025 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7500,7 +7500,7 @@ static void K_initKartHUD(void) ITEM2_X = BASEVIDWIDTH-39 + cv_item_xoffset.value; ITEM2_Y = -8 + cv_item_yoffset.value; - LAPS2_X = BASEVIDWIDTH-40 + cv_laps_xoffset.value; + LAPS2_X = BASEVIDWIDTH-3 + cv_laps_xoffset.value; LAPS2_Y = (BASEVIDHEIGHT/2)-13 + cv_laps_yoffset.value; POSI2_X = BASEVIDWIDTH -4 + cv_posi_xoffset.value; @@ -7567,6 +7567,97 @@ INT32 K_calcSplitFlags(INT32 snapflags) return (splitflags|snapflags); } +drawinfo_t K_getItemBoxDrawinfo(void) +{ + INT32 fx, fy, fflags; + drawinfo_t info; + + // pain and suffering defined below + if (splitscreen < 2) // don't change shit for THIS splitscreen. + { + fx = ITEM_X; + fy = ITEM_Y; + fflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); + } + else // now we're having a fun game. + { + if (!(stplyrnum & 1)) // If we are P1 or P3... + { + fx = ITEM_X; + fy = ITEM_Y; + fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + fx = ITEM2_X; + fy = ITEM2_Y; + fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom + } + } + + info.x = fx; + info.y = fy; + info.flags = fflags; + return info; +} + +drawinfo_t K_getLapsDrawinfo(void) +{ + INT32 fx, fy, fflags; + drawinfo_t info; + + // pain and suffering defined below + if (splitscreen < 2) // don't change shit for THIS splitscreen. + { + fx = LAPS_X; + fy = LAPS_Y; + fflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); + } + else + { + if (!(stplyrnum & 1)) // If we are P1 or P3... + { + fx = LAPS_X; + fy = LAPS_Y; + fflags = V_SNAPTOLEFT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + } + else // else, that means we're P2 or P4. + { + fx = LAPS2_X; + fy = LAPS2_Y; + fflags = V_SNAPTORIGHT|(stplyrnum & 2 ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + } + } + + info.x = fx; + info.y = fy; + info.flags = fflags; + return info; +} + +drawinfo_t K_getMinimapDrawinfo(void) +{ + INT32 fx = MINI_X, fy = MINI_Y, fflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) + drawinfo_t info; + + info.x = fx; + info.y = fy; + info.flags = fflags; + return info; +} + +patch_t *K_getItemBoxPatch(boolean small, boolean dark) +{ + UINT8 ofs = (cv_darkitembox.value && dark ? 1 : 0) + (small ? 2 : 0); + return (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[ofs] : kp_itembg[ofs]; +} + +patch_t *K_getItemMulPatch(boolean small) +{ + UINT8 ofs = small ? 1 : 0; + return K_UseColorHud() ? kp_itemmulstickerclr[ofs] : kp_itemmulsticker[ofs]; +} + static void K_drawKartStats(void) { INT32 x, y, spdoffset, flags; @@ -7692,12 +7783,8 @@ static void K_drawKartItem(void) const UINT8 offset = ((splitscreen > 1) ? 1 : 0); patch_t *localpatch = kp_nodraw; patch_t *localbg; - - if (cv_colorizeditembox.value && K_UseColorHud()) - localbg = ((offset) ? kp_itembgclr[2] : kp_itembgclr[0]); - else - localbg = ((offset) ? kp_itembg[2] : kp_itembg[0]); - + boolean dark = false; + patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]); INT32 fx = 0, fy = 0, fflags = 0; // final coords for hud and flags... //INT32 splitflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); @@ -7708,9 +7795,9 @@ static void K_drawKartItem(void) UINT8 localcolor = SKINCOLOR_NONE; SINT8 colormode = TC_RAINBOW; UINT8 *colmap = NULL; - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - boolean flipamount = false; // Used for 3P/4P splitscreen to flip item amount stuff + UINT8 *colormap = NULL; + + boolean flipamount = splitscreen > 1 && stplyrnum & 1; // Used for 3P/4P splitscreen to flip item amount stuff if (stplyr->kartstuff[k_itemroulette]) { @@ -7857,8 +7944,7 @@ static void K_drawKartItem(void) break; case KITEM_INVINCIBILITY: localpatch = localinv; - if (cv_darkitembox.value) - localbg = (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[offset + 1] : kp_itembg[offset + 1]; + dark = true; break; case KITEM_BANANA: localpatch = kp_banana[offset]; @@ -7880,8 +7966,7 @@ static void K_drawKartItem(void) break; case KITEM_SPB: localpatch = kp_selfpropelledbomb[offset]; - if (cv_darkitembox.value) - localbg = (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[offset + 1] : kp_itembg[offset + 1]; + dark = true; break; case KITEM_GROW: localpatch = kp_grow[offset]; @@ -7891,8 +7976,7 @@ static void K_drawKartItem(void) break; case KITEM_THUNDERSHIELD: localpatch = kp_thundershield[offset]; - if (cv_darkitembox.value) - localbg = (cv_colorizeditembox.value && K_UseColorHud()) ? kp_itembgclr[offset + 1] : kp_itembg[offset + 1]; + dark = true; break; case KITEM_HYUDORO: localpatch = kp_hyudoro[offset]; @@ -7933,47 +8017,24 @@ static void K_drawKartItem(void) } } - // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. - { - fx = ITEM_X; - fy = ITEM_Y; - fflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); - } - else // now we're having a fun game. - { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... - { - fx = ITEM_X; - fy = ITEM_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = ITEM2_X; - fy = ITEM2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom - flipamount = true; - } - } + localbg = K_getItemBoxPatch((boolean)offset, dark); + drawinfo_t info = K_getItemBoxDrawinfo(); + fx = info.x; + fy = info.y; + fflags = info.flags; if (localcolor != SKINCOLOR_NONE) colmap = R_GetTranslationColormap(colormode, localcolor, GTC_CACHE); + if (K_UseColorHud()) + colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - if (cv_colorizeditembox.value && K_UseColorHud()) - V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg,colormap); - else - V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, localbg); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg, cv_colorizeditembox.value ? colormap : NULL); // Then, the numbers: if (stplyr->kartstuff[k_itemamount] >= numberdisplaymin && !stplyr->kartstuff[k_itemroulette]) { - if (!K_UseColorHud()) - V_DrawScaledPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), kp_itemmulsticker[offset]); - else //Colourized hud - V_DrawMappedPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), kp_itemmulstickerclr[offset], colormap); // flip this graphic for p2 and p4 in split and shift it. - + localbg = K_getItemMulPatch((boolean)offset); + V_DrawMappedPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), localbg, colormap); // flip this graphic for p2 and p4 in split and shift it. V_DrawFixedPatch(fx< 1 && stplyrnum & 1; // used for 3p or 4p INT32 stringw = 0; // used with the above - + + drawinfo_t info = K_getLapsDrawinfo(); + fx = info.x; + fy = info.y; + fflags = info.flags; + if (splitscreen > 1) { - // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = splitflags; - } - else - { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = LAPS2_X; - fy = LAPS2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom - flipstring = true; // make the string right aligned and other shit - } - } - if (stplyr->exiting) // draw stuff as god intended. { V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, kp_splitlapflag); @@ -8617,8 +8659,8 @@ static void K_drawKartLaps(void) { stringw = V_StringWidth(va("%d/%d", stplyr->laps+1, cv_numlaps.value), 0); - V_DrawScaledPatch(BASEVIDWIDTH-stringw-16, fy, V_HUDTRANS|fflags, kp_splitlapflag); - V_DrawRightAlignedString(BASEVIDWIDTH-3, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); + V_DrawScaledPatch(fx-stringw-13, fy, V_HUDTRANS|fflags, kp_splitlapflag); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); } else // draw stuff NORMALLY. { @@ -8631,23 +8673,23 @@ static void K_drawKartLaps(void) if (!K_UseColorHud()) { if (K_BigLapSticker()) - V_DrawScaledPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig)); + V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2 : kp_lapstickerbig)); else - V_DrawScaledPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, kp_lapsticker); + V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, kp_lapsticker); } else //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); if (K_BigLapSticker()) - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr), colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, ((stplyr->laps + 1 > 9) ? kp_lapstickerbig2clr : kp_lapstickerbigclr), colormap); else - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, kp_lapstickerclr, colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|splitflags, kp_lapstickerclr, colormap); } if (stplyr->exiting) - V_DrawKartString(LAPS_X+33, LAPS_Y+3, V_HUDTRANS|splitflags, "FIN"); + V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, "FIN"); else - V_DrawKartString(LAPS_X+33, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); + V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); } } @@ -8799,31 +8841,21 @@ static void K_drawKartSpeedometer(void) static void K_drawKartBumpersOrKarma(void) { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); - INT32 fx = 0, fy = 0, fflags = 0; - boolean flipstring = false; // same as laps, used for splitscreen + INT32 fx, fy, fflags; + boolean flipstring = splitscreen > 1 && stplyrnum & 1; // same as laps, used for splitscreen INT32 stringw = 0; // used with the above + drawinfo_t info = K_getLapsDrawinfo(); + fx = info.x; + fy = info.y; + fflags = info.flags; + if (splitscreen > 1) { - // we will reuse lap coords here since it's essentially the same shit. - - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... - { - fx = LAPS_X; - fy = LAPS_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. - } - else // else, that means we're P2 or P4. - { - fx = LAPS2_X; - fy = LAPS2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom - flipstring = true; - } - if (stplyr->kartstuff[k_bumper] <= 0) { + if (flipstring) + fx -= 37; V_DrawMappedPatch(fx, fy-1, V_HUDTRANS|fflags, kp_splitkarmabomb, colormap); V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); } @@ -8833,8 +8865,8 @@ static void K_drawKartBumpersOrKarma(void) { stringw = V_StringWidth(va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value), 0); - V_DrawMappedPatch(BASEVIDWIDTH-stringw-16, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); - V_DrawRightAlignedString(BASEVIDWIDTH-3, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); + V_DrawMappedPatch(fx-stringw-13, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); } else // draw bumpers normally. { @@ -8847,17 +8879,17 @@ static void K_drawKartBumpersOrKarma(void) { if (stplyr->kartstuff[k_bumper] <= 0) { - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker), colormap); - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker), colormap); + V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); } else { if (stplyr->kartstuff[k_bumper] > 9 && cv_kartbumpers.value > 9) - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide), colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide), colormap); else - V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|splitflags, (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker), colormap); + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker), colormap); - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); + V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); } } } @@ -9120,7 +9152,7 @@ static void K_drawKartMinimap(void) patch_t *AutomapPic; INT32 i = 0; INT32 x, y; - INT32 minimaptrans, splitflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) + INT32 minimaptrans, splitflags; SINT8 localplayers[4]; SINT8 numlocalplayers = 0; @@ -9139,8 +9171,11 @@ static void K_drawKartMinimap(void) else return; // no pic, just get outta here - x = MINI_X - (AutomapPic->width/2); - y = MINI_Y - (AutomapPic->height/2); + drawinfo_t info = K_getMinimapDrawinfo(); + x = info.x - (AutomapPic->width/2); + y = info.y - (AutomapPic->height/2); + splitflags = info.flags; + if (timeinmap > 105) { diff --git a/src/k_kart.h b/src/k_kart.h index 803594790..861d00991 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -18,6 +18,7 @@ void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor); void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, boolean local); UINT8 K_GetKartColorByName(const char *name); UINT8 K_GetHudColor(void); +boolean K_UseColorHud(void); void K_RegisterKartStuff(void); @@ -96,5 +97,18 @@ void K_drawKartHUD(void); void K_drawKartFreePlay(UINT32 flashtime); void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UINT8 mode); +typedef struct +{ + INT32 x; + INT32 y; + INT32 flags; +} drawinfo_t; + +patch_t *K_getItemBoxPatch(boolean small, boolean dark); +patch_t *K_getItemMulPatch(boolean small); +drawinfo_t K_getItemBoxDrawinfo(void); +drawinfo_t K_getLapsDrawinfo(void); +drawinfo_t K_getMinimapDrawinfo(void); + // ========================================================================= #endif // __K_KART__ diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index c7b1ec38e..a6dee3188 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -24,6 +24,7 @@ #include "v_video.h" #include "w_wad.h" #include "z_zone.h" +#include "k_kart.h" #include "lua_script.h" #include "lua_libs.h" @@ -744,6 +745,67 @@ static int libd_drawStretched(lua_State *L) return 0; } +static int libd_drawItemBox(lua_State *L) +{ + HUDONLY + INT32 x = luaL_checkinteger(L, 1); + INT32 y = luaL_checkinteger(L, 2); + INT32 flags = luaL_optinteger(L, 3, 0); + boolean small = lua_optboolean(L, 4); + boolean dark = lua_optboolean(L, 5); + UINT8 *colormap = NULL; + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + + if (!lua_isnoneornil(L, 6)) + colormap = *((UINT8 **)luaL_checkudata(L, 6, META_COLORMAP)); + else if (cv_colorizeditembox.value && K_UseColorHud()) + colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + + patch_t *localbg = K_getItemBoxPatch(small, dark); + + lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); + huddrawlist_h list = (huddrawlist_h) lua_touserdata(L, -1); + lua_pop(L, 1); + + if (LUA_HUD_IsDrawListValid(list)) + LUA_HUD_AddDraw(list, x, y, localbg, flags, colormap); + else + V_DrawMappedPatch(x, y, flags, localbg, colormap); + + return 0; +} + +static int libd_drawItemMul(lua_State *L) +{ + HUDONLY + INT32 x = luaL_checkinteger(L, 1); + INT32 y = luaL_checkinteger(L, 2); + INT32 flags = luaL_optinteger(L, 3, 0); + boolean small = lua_optboolean(L, 4); + UINT8 *colormap = NULL; + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + + if (!lua_isnoneornil(L, 5)) + colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP)); + else if (K_UseColorHud()) + colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + + patch_t *patch = K_getItemMulPatch(small); + + lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); + huddrawlist_h list = (huddrawlist_h) lua_touserdata(L, -1); + lua_pop(L, 1); + + if (LUA_HUD_IsDrawListValid(list)) + LUA_HUD_AddDraw(list, x, y, patch, flags, colormap); + else + V_DrawMappedPatch(x, y, flags, patch, colormap); + + return 0; +} + static int libd_drawNum(lua_State *L) { @@ -1007,6 +1069,21 @@ static int libd_getColormap(lua_State *L) return 1; } +static int libd_getHudColor(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, K_GetHudColor()); + return 1; +} + +static int libd_useColorHud(lua_State *L) +{ + HUDONLY + lua_pushboolean(L, K_UseColorHud()); + return 1; +} + + static int libd_width(lua_State *L) { HUDONLY @@ -1057,6 +1134,26 @@ static int libd_getlocaltransflag(lua_State *L) return 1; } +static int libd_getDrawInfo(lua_State *L) +{ + HUDONLY + enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); + drawinfo_t info; + + switch(option) { + case hud_item: info = K_getItemBoxDrawinfo(); break; + case hud_gametypeinfo: info = K_getLapsDrawinfo(); break; + case hud_minimap: info = K_getMinimapDrawinfo(); break; + default: + return 0; // not available + } + + lua_pushinteger(L, info.x); + lua_pushinteger(L, info.y); + lua_pushinteger(L, info.flags); + return 3; +} + static luaL_Reg lib_draw[] = { {"patchExists", libd_patchExists}, {"cachePatch", libd_cachePatch}, @@ -1080,6 +1177,11 @@ static luaL_Reg lib_draw[] = { {"renderer", libd_renderer}, {"localTransFlag", libd_getlocaltransflag}, {"drawOnMinimap", libd_drawOnMinimap}, + {"drawItemBox", libd_drawItemBox}, + {"drawItemMul", libd_drawItemMul}, + {"getDrawInfo", libd_getDrawInfo}, + {"getHudColor", libd_getHudColor}, + {"useColorHud", libd_useColorHud}, {NULL, NULL} }; @@ -1170,12 +1272,43 @@ static int lib_hudsetvotebackground(lua_State *L) return 0; } +static int lib_hudgetoffsets(lua_State *L) +{ + enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); + INT32 ofx, ofy; + +#define OFS(x, y) ofx = x.value; ofy = y.value; break; +#define OFY(y) ofx = 0; ofy = y.value; break; + switch(option) { + case hud_item: OFS(cv_item_xoffset, cv_item_yoffset) + case hud_time: OFS(cv_time_xoffset, cv_time_yoffset) + case hud_gametypeinfo: OFS(cv_laps_xoffset, cv_laps_yoffset) + //case TODO: OFS(cv_dnft_xoffset, cv_dnft_yoffset) + case hud_speedometer: OFS(cv_speed_xoffset, cv_speed_yoffset) + case hud_position: OFS(cv_posi_xoffset, cv_posi_yoffset) + case hud_minirankings: OFS(cv_face_xoffset, cv_face_yoffset) + //case TODO: OFS(cv_stcd_xoffset, cv_stcd_yoffset) + case hud_check: OFY(cv_chek_yoffset); + case hud_minimap: OFS(cv_mini_xoffset, cv_mini_yoffset) + case hud_wanted: OFS(cv_want_xoffset, cv_want_yoffset) + case hud_statdisplay: OFS(cv_stat_xoffset, cv_stat_yoffset) + default: + return 0; // not available + } +#undef OFS + + lua_pushinteger(L, ofx); + lua_pushinteger(L, ofy); + return 2; +} + static luaL_Reg lib_hud[] = { {"enable", lib_hudenable}, {"disable", lib_huddisable}, {"enabled", lib_hudenabled}, {"add", lib_hudadd}, {"setVoteBackground", lib_hudsetvotebackground}, + {"getOffsets", lib_hudgetoffsets}, {NULL, NULL} }; -- 2.54.0 From e6adc50e2b55eecac04e72d3a184c62f1c493e5b Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Thu, 22 Feb 2024 00:25:12 +0100 Subject: [PATCH 15/70] Replace draw functions with v.getColorHudPatch More flexible, more extensible --- LUASTUFF.md | 20 ++++----- src/lua_hudlib.c | 108 +++++++++++++++++++---------------------------- 2 files changed, 53 insertions(+), 75 deletions(-) diff --git a/LUASTUFF.md b/LUASTUFF.md index 13d4cea8f..df8539c87 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -33,18 +33,16 @@ Uses the same strings as `hud.enabled`. Returns the X, Y and flags where the given HUD item will be drawn for the current displayplayer. Available for `item`, `gametypeinfo` and `minimap`. -## v.drawItemBox(x, y, flags, small, dark, colormap) +## patch, colormap = v.getColorHudPatch(item) -Draws an item box at the given coordinates. -`small`: true to draw small item box, false to draw large item box. -`dark`: true if item box should be darkened. -`colormap`: Colormap to draw the item box with. If nil, use displayplayer's HUD colormap. - -## v.drawItemMul(x, y, flags, small, colormap) - -Draws a multi-item sticker at the given coordinates. -`small`: true to draw small sticker, false to draw large sticker. -`colormap`: Colormap to draw the sticker with. If nil, use displayplayer's HUD colormap. +Returns the patch and colormap to use for the given HUD item. Colorization is based on the user's settings. +Available for `item` and `itemmul`. +Extra arguments for some items: +### item +* `small`: true for small item box, false for big item box. +* `dark`: true to darken item box. Depends on `darkitembox`. +### itemmul +* `small`: true for small sticker, false for big sticker. ## hudcolor = v.getHudColor() diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index a6dee3188..71f8ec02f 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -170,6 +170,16 @@ static const char *const camera_opt[] = { "pnum", NULL}; +enum hudpatch { + hudpatch_item = 0, + hudpatch_itemmul +}; + +static const char *const hud_patch_options[] = { + "item", + "itemmul", + NULL}; + static int lib_getHudInfo(lua_State *L) { UINT32 i; @@ -745,68 +755,6 @@ static int libd_drawStretched(lua_State *L) return 0; } -static int libd_drawItemBox(lua_State *L) -{ - HUDONLY - INT32 x = luaL_checkinteger(L, 1); - INT32 y = luaL_checkinteger(L, 2); - INT32 flags = luaL_optinteger(L, 3, 0); - boolean small = lua_optboolean(L, 4); - boolean dark = lua_optboolean(L, 5); - UINT8 *colormap = NULL; - - flags &= ~V_PARAMMASK; // Don't let crashes happen. - - if (!lua_isnoneornil(L, 6)) - colormap = *((UINT8 **)luaL_checkudata(L, 6, META_COLORMAP)); - else if (cv_colorizeditembox.value && K_UseColorHud()) - colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - patch_t *localbg = K_getItemBoxPatch(small, dark); - - lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); - huddrawlist_h list = (huddrawlist_h) lua_touserdata(L, -1); - lua_pop(L, 1); - - if (LUA_HUD_IsDrawListValid(list)) - LUA_HUD_AddDraw(list, x, y, localbg, flags, colormap); - else - V_DrawMappedPatch(x, y, flags, localbg, colormap); - - return 0; -} - -static int libd_drawItemMul(lua_State *L) -{ - HUDONLY - INT32 x = luaL_checkinteger(L, 1); - INT32 y = luaL_checkinteger(L, 2); - INT32 flags = luaL_optinteger(L, 3, 0); - boolean small = lua_optboolean(L, 4); - UINT8 *colormap = NULL; - - flags &= ~V_PARAMMASK; // Don't let crashes happen. - - if (!lua_isnoneornil(L, 5)) - colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP)); - else if (K_UseColorHud()) - colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - - patch_t *patch = K_getItemMulPatch(small); - - lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); - huddrawlist_h list = (huddrawlist_h) lua_touserdata(L, -1); - lua_pop(L, 1); - - if (LUA_HUD_IsDrawListValid(list)) - LUA_HUD_AddDraw(list, x, y, patch, flags, colormap); - else - V_DrawMappedPatch(x, y, flags, patch, colormap); - - return 0; -} - - static int libd_drawNum(lua_State *L) { INT32 x, y, flags, num; @@ -1069,6 +1017,39 @@ static int libd_getColormap(lua_State *L) return 1; } +static int libd_getColorHudPatch(lua_State *L) +{ + HUDONLY + enum hudpatch option = luaL_checkoption(L, 1, NULL, hud_patch_options); + patch_t *patch; + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + boolean small, dark; + + switch (option) { + case hudpatch_item: + small = lua_optboolean(L, 2); + dark = lua_optboolean(L, 3); + patch = K_getItemBoxPatch(small, dark); + if (!cv_colorizeditembox.value) + colormap = NULL; + break; + case hudpatch_itemmul: + small = lua_optboolean(L, 2); + patch = K_getItemMulPatch(small); + break; + default: + return 0; // you shouldn't be here + } + + LUA_PushUserdata(L, patch, META_PATCH); + if (colormap && K_UseColorHud()) + LUA_PushUserdata(L, colormap, META_COLORMAP); + else + lua_pushnil(L); + + return 2; +} + static int libd_getHudColor(lua_State *L) { HUDONLY @@ -1177,8 +1158,7 @@ static luaL_Reg lib_draw[] = { {"renderer", libd_renderer}, {"localTransFlag", libd_getlocaltransflag}, {"drawOnMinimap", libd_drawOnMinimap}, - {"drawItemBox", libd_drawItemBox}, - {"drawItemMul", libd_drawItemMul}, + {"getColorHudPatch", libd_getColorHudPatch}, {"getDrawInfo", libd_getDrawInfo}, {"getHudColor", libd_getHudColor}, {"useColorHud", libd_useColorHud}, -- 2.54.0 From 5d215ea6333a1f49e524e24beca0322936e8bcee Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Thu, 22 Feb 2024 01:19:37 +0100 Subject: [PATCH 16/70] Add enums for drawinfo and offsets --- LUASTUFF.md | 4 +-- src/lua_hudlib.c | 85 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 23 deletions(-) diff --git a/LUASTUFF.md b/LUASTUFF.md index df8539c87..05ca33bd0 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -25,8 +25,8 @@ exist. ## x, y = hud.getOffsets(item) -Returns the values of the given HUD item's `xoffset`/`yoffset` cvars, or nil if unsupported. -Uses the same strings as `hud.enabled`. +Returns the values of the given HUD item's `xoffset`/`yoffset` cvars. +Available for any HUD item with offset cvars. ## x, y, flags = v.getDrawInfo(item) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 71f8ec02f..e0b742094 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -180,6 +180,48 @@ static const char *const hud_patch_options[] = { "itemmul", NULL}; +enum hudoffsets { + hudoffsets_item = 0, + hudoffsets_time, + hudoffsets_gametypeinfo, + hudoffsets_countdown, + hudoffsets_speedometer, + hudoffsets_position, + hudoffsets_minirankings, + hudoffsets_startcountdown, + hudoffsets_check, + hudoffsets_minimap, + hudoffsets_wanted, + hudoffsets_statdisplay +}; + +static const char *const hud_offsets_options[] = { + "item", + "time", + "gametypeinfo", + "countdown", + "speedometer", + "position", + "minirankings", + "startcountdown", + "check", + "minimap", + "wanted", + "statdisplay", + NULL}; + +enum huddrawinfo { + huddrawinfo_item = 0, + huddrawinfo_gametypeinfo, + huddrawinfo_minimap +}; + +static const char *const hud_drawinfo_options[] = { + "item", + "gametypeinfo", + "minimap", + NULL}; + static int lib_getHudInfo(lua_State *L) { UINT32 i; @@ -1118,15 +1160,15 @@ static int libd_getlocaltransflag(lua_State *L) static int libd_getDrawInfo(lua_State *L) { HUDONLY - enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); + enum huddrawinfo option = luaL_checkoption(L, 1, NULL, hud_drawinfo_options); drawinfo_t info; switch(option) { - case hud_item: info = K_getItemBoxDrawinfo(); break; - case hud_gametypeinfo: info = K_getLapsDrawinfo(); break; - case hud_minimap: info = K_getMinimapDrawinfo(); break; + case huddrawinfo_item: info = K_getItemBoxDrawinfo(); break; + case huddrawinfo_gametypeinfo: info = K_getLapsDrawinfo(); break; + case huddrawinfo_minimap: info = K_getMinimapDrawinfo(); break; default: - return 0; // not available + return 0; // unreachable } lua_pushinteger(L, info.x); @@ -1254,28 +1296,29 @@ static int lib_hudsetvotebackground(lua_State *L) static int lib_hudgetoffsets(lua_State *L) { - enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); + enum hudoffsets option = luaL_checkoption(L, 1, NULL, hud_offsets_options); INT32 ofx, ofy; -#define OFS(x, y) ofx = x.value; ofy = y.value; break; -#define OFY(y) ofx = 0; ofy = y.value; break; +#define OFS(it) ofx = cv_##it##_xoffset.value; ofy = cv_##it##_yoffset.value; break; +#define OFY(it) ofx = 0; ofy = cv_##it##_yoffset.value; break; switch(option) { - case hud_item: OFS(cv_item_xoffset, cv_item_yoffset) - case hud_time: OFS(cv_time_xoffset, cv_time_yoffset) - case hud_gametypeinfo: OFS(cv_laps_xoffset, cv_laps_yoffset) - //case TODO: OFS(cv_dnft_xoffset, cv_dnft_yoffset) - case hud_speedometer: OFS(cv_speed_xoffset, cv_speed_yoffset) - case hud_position: OFS(cv_posi_xoffset, cv_posi_yoffset) - case hud_minirankings: OFS(cv_face_xoffset, cv_face_yoffset) - //case TODO: OFS(cv_stcd_xoffset, cv_stcd_yoffset) - case hud_check: OFY(cv_chek_yoffset); - case hud_minimap: OFS(cv_mini_xoffset, cv_mini_yoffset) - case hud_wanted: OFS(cv_want_xoffset, cv_want_yoffset) - case hud_statdisplay: OFS(cv_stat_xoffset, cv_stat_yoffset) + case hudoffsets_item: OFS(item) + case hudoffsets_time: OFS(time) + case hudoffsets_gametypeinfo: OFS(laps) + case hudoffsets_countdown: OFS(dnft) + case hudoffsets_speedometer: OFS(speed) + case hudoffsets_position: OFS(posi) + case hudoffsets_minirankings: OFS(face) + case hudoffsets_startcountdown: OFS(stcd) + case hudoffsets_check: OFY(chek) + case hudoffsets_minimap: OFS(mini) + case hudoffsets_wanted: OFS(want) + case hudoffsets_statdisplay: OFS(stat) default: - return 0; // not available + return 0; // unreachable } #undef OFS +#undef OFY lua_pushinteger(L, ofx); lua_pushinteger(L, ofy); -- 2.54.0 From 1a91060573dc2da1e76a02a263168a839383839c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 21:04:35 +0100 Subject: [PATCH 17/70] dont interpolate unchanging things + remove unused dynslope interp code --- src/r_fps.c | 123 +++++++++++++++++++++++++++++++++++++++------------- src/r_fps.h | 2 +- 2 files changed, 94 insertions(+), 31 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index c9d862caf..f01730d50 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -98,7 +98,7 @@ static angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac) return from + FixedMul(frac, to - from); } -static vector2_t *R_LerpVector2(const vector2_t *from, const vector2_t *to, fixed_t frac, vector2_t *out) +/*static vector2_t *R_LerpVector2(const vector2_t *from, const vector2_t *to, fixed_t frac, vector2_t *out) { FV2_SubEx(to, from, out); FV2_MulEx(out, frac, out); @@ -112,7 +112,7 @@ static vector3_t *R_LerpVector3(const vector3_t *from, const vector3_t *to, fixe FV3_MulEx(out, frac, out); FV3_AddEx(from, out, out); return out; -} +}*/ // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). @@ -255,7 +255,7 @@ void R_SetViewContext(enum viewcontext_e _viewcontext) } } -fixed_t R_InterpolateFixed(fixed_t from, fixed_t to) +/*fixed_t R_InterpolateFixed(fixed_t from, fixed_t to) { if (!R_UsingFrameInterpolation()) { @@ -273,7 +273,7 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to) } return (R_LerpAngle(from, to, rendertimefrac)); -} +}*/ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) { @@ -296,14 +296,32 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) return; } - out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); - out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); - out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); + if (mobj->x == mobj->old_x) + out->x = mobj->old_x; + else + out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); + + if (mobj->y == mobj->old_y) + out->y = mobj->old_y; + else + out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); + + if (mobj->z == mobj->old_z) + out->z = mobj->old_z; + else + out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); if (cv_gravstretch.value || cv_saltysquish.value) // for now we only use it for those two features so no need to interpolate this when we dont use stuff { - out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); - out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); + if (mobj->spritexscale == mobj->old_spritexscale) + out->spritexscale = mobj->old_spritexscale; + else + out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); + + if (mobj->spriteyscale == mobj->old_spriteyscale) + out->spriteyscale = mobj->old_spriteyscale; + else + out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); } else { @@ -313,8 +331,15 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) if (cv_saltyhop.value) // same here { - out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); - out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); + if (mobj->spritexoffset == mobj->old_spritexoffset) + out->spritexoffset = mobj->old_spritexoffset; + else + out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); + + if (mobj->spriteyoffset == mobj->old_spriteyoffset) + out->spriteyoffset = mobj->old_spriteyoffset; + else + out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); } else { @@ -342,7 +367,10 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) } else { - out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); + if (mobj->angle == mobj->old_angle) + out->angle = mobj->old_angle; + else + out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); } if (cv_spriteroll.value) // no need to interpolate this if its disabled @@ -495,7 +523,7 @@ void R_CreateInterpolator_Polyobj(thinker_t *thinker, polyobj_t *polyobj) interp->polyobj.oldcy = interp->polyobj.bakcy = polyobj->centerPt.y; } -void R_CreateInterpolator_DynSlope(thinker_t *thinker, pslope_t *slope) +/*void R_CreateInterpolator_DynSlope(thinker_t *thinker, pslope_t *slope) { levelinterpolator_t *interp = CreateInterpolator(LVLINTERP_DynSlope, thinker); interp->dynslope.slope = slope; @@ -507,7 +535,7 @@ void R_CreateInterpolator_DynSlope(thinker_t *thinker, pslope_t *slope) FV2_Copy(&interp->dynslope.bakd, &slope->d); interp->dynslope.oldzdelta = interp->dynslope.bakzdelta = slope->zdelta; -} +}*/ void R_InitializeLevelInterpolators(void) { @@ -551,7 +579,7 @@ static void UpdateLevelInterpolatorState(levelinterpolator_t *interp) interp->polyobj.bakcx = interp->polyobj.polyobj->centerPt.x; interp->polyobj.bakcy = interp->polyobj.polyobj->centerPt.y; break; - case LVLINTERP_DynSlope: + /*case LVLINTERP_DynSlope: FV3_Copy(&interp->dynslope.oldo, &interp->dynslope.bako); FV2_Copy(&interp->dynslope.oldd, &interp->dynslope.bakd); interp->dynslope.oldzdelta = interp->dynslope.bakzdelta; @@ -559,7 +587,7 @@ static void UpdateLevelInterpolatorState(levelinterpolator_t *interp) FV3_Copy(&interp->dynslope.bako, &interp->dynslope.slope->o); FV2_Copy(&interp->dynslope.bakd, &interp->dynslope.slope->d); interp->dynslope.bakzdelta = interp->dynslope.slope->zdelta; - break; + break;*/ } } @@ -605,29 +633,56 @@ void R_ApplyLevelInterpolators(fixed_t frac) case LVLINTERP_SectorPlane: if (interp->sectorplane.ceiling) { - interp->sectorplane.sector->ceilingheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); + if (interp->sectorplane.sector->ceilingheight == interp->sectorplane.oldheight) + interp->sectorplane.sector->ceilingheight = interp->sectorplane.oldheight; + else + interp->sectorplane.sector->ceilingheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); } else { - interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); + if (interp->sectorplane.sector->floorheight == interp->sectorplane.oldheight) + interp->sectorplane.sector->floorheight = interp->sectorplane.oldheight; + else + interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); } interp->sectorplane.sector->moved = true; break; case LVLINTERP_SectorScroll: if (interp->sectorscroll.ceiling) { - interp->sectorscroll.sector->ceiling_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); - interp->sectorscroll.sector->ceiling_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); + if (interp->sectorscroll.sector->ceiling_xoffs == interp->sectorscroll.oldxoffs) + interp->sectorscroll.sector->ceiling_xoffs = interp->sectorscroll.oldxoffs; + else + interp->sectorscroll.sector->ceiling_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); + + if (interp->sectorscroll.sector->ceiling_yoffs == interp->sectorscroll.oldyoffs) + interp->sectorscroll.sector->ceiling_yoffs = interp->sectorscroll.oldyoffs; + else + interp->sectorscroll.sector->ceiling_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } else { - interp->sectorscroll.sector->floor_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); - interp->sectorscroll.sector->floor_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); + if (interp->sectorscroll.sector->floor_xoffs == interp->sectorscroll.oldxoffs) + interp->sectorscroll.sector->floor_xoffs = interp->sectorscroll.oldxoffs; + else + interp->sectorscroll.sector->floor_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); + + if (interp->sectorscroll.sector->floor_yoffs == interp->sectorscroll.oldyoffs) + interp->sectorscroll.sector->floor_yoffs = interp->sectorscroll.oldyoffs; + else + interp->sectorscroll.sector->floor_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } break; case LVLINTERP_SideScroll: - interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac); - interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac); + if (interp->sidescroll.side->textureoffset == interp->sidescroll.oldtextureoffset) + interp->sidescroll.side->textureoffset = interp->sidescroll.oldtextureoffset; + else + interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac); + + if (interp->sidescroll.side->rowoffset == interp->sidescroll.oldrowoffset) + interp->sidescroll.side->rowoffset = interp->sidescroll.oldrowoffset; + else + interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac); break; case LVLINTERP_Polyobj: for (ii = 0; ii < interp->polyobj.vertices_size; ii++) @@ -635,14 +690,22 @@ void R_ApplyLevelInterpolators(fixed_t frac) interp->polyobj.polyobj->vertices[ii]->x = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 ], interp->polyobj.bakvertices[ii * 2 ], frac); interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac); } - interp->polyobj.polyobj->centerPt.x = R_LerpFixed(interp->polyobj.oldcx, interp->polyobj.bakcx, frac); - interp->polyobj.polyobj->centerPt.y = R_LerpFixed(interp->polyobj.oldcy, interp->polyobj.bakcy, frac); + if (interp->polyobj.polyobj->centerPt.x == interp->polyobj.oldcx) + interp->polyobj.polyobj->centerPt.x = interp->polyobj.oldcx; + else + interp->polyobj.polyobj->centerPt.x = R_LerpFixed(interp->polyobj.oldcx, interp->polyobj.bakcx, frac); + + if (interp->polyobj.polyobj->centerPt.y == interp->polyobj.oldcy) + interp->polyobj.polyobj->centerPt.y = interp->polyobj.oldcy; + else + interp->polyobj.polyobj->centerPt.y = R_LerpFixed(interp->polyobj.oldcy, interp->polyobj.bakcy, frac); + break; - case LVLINTERP_DynSlope: + /*case LVLINTERP_DynSlope: R_LerpVector3(&interp->dynslope.oldo, &interp->dynslope.bako, frac, &interp->dynslope.slope->o); R_LerpVector2(&interp->dynslope.oldd, &interp->dynslope.bakd, frac, &interp->dynslope.slope->d); interp->dynslope.slope->zdelta = R_LerpFixed(interp->dynslope.oldzdelta, interp->dynslope.bakzdelta, frac); - break; + break;*/ } } } @@ -693,11 +756,11 @@ void R_RestoreLevelInterpolators(void) interp->polyobj.polyobj->centerPt.x = interp->polyobj.bakcx; interp->polyobj.polyobj->centerPt.y = interp->polyobj.bakcy; break; - case LVLINTERP_DynSlope: + /*case LVLINTERP_DynSlope: FV3_Copy(&interp->dynslope.slope->o, &interp->dynslope.bako); FV2_Copy(&interp->dynslope.slope->d, &interp->dynslope.bakd); interp->dynslope.slope->zdelta = interp->dynslope.bakzdelta; - break; + break;*/ } } } diff --git a/src/r_fps.h b/src/r_fps.h index 35585517d..1c0f1f884 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -78,7 +78,7 @@ typedef enum { LVLINTERP_SectorScroll, LVLINTERP_SideScroll, LVLINTERP_Polyobj, - LVLINTERP_DynSlope, + //LVLINTERP_DynSlope, } levelinterpolator_type_e; // Tagged union of a level interpolator -- 2.54.0 From 1e50ecb2cdab42f7b8af9e49b497f250a6bda84d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 21:41:44 +0100 Subject: [PATCH 18/70] fix ternary hell for palette rendering lightlevels --- src/hardware/hw_main.c | 55 ++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index a4c710420..f90d18450 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -53,6 +53,8 @@ #define ABS(x) ((x) < 0 ? -(x) : (x)) +#define SOFTLIGHT(llevel) HWR_ShouldUsePaletteRendering() ? ((llevel) >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : (llevel) + // ========================================================================== // the hardware driver object // ========================================================================== @@ -1129,7 +1131,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { if (HWR_ShouldUsePaletteRendering()) { - lightnum = (pfloor->master->frontsector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(pfloor->master->frontsector->lightlevel); colormap = pfloor->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); }else{ @@ -1141,7 +1143,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { if (HWR_ShouldUsePaletteRendering()) { - lightnum = (*list[i].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(*list[i].lightlevel); colormap = list[i].extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); }else{ @@ -1541,7 +1543,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (HWR_ShouldUsePaletteRendering()) { - lightnum = (gr_frontsector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(gr_frontsector->lightlevel); colormap = gr_frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); }else{ @@ -2489,7 +2491,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (HWR_ShouldUsePaletteRendering()) { - lightnum = (rover->master->frontsector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(rover->master->frontsector->lightlevel); colormap = rover->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); }else{ @@ -2640,7 +2642,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (HWR_ShouldUsePaletteRendering()) { - lightnum = (rover->master->frontsector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(rover->master->frontsector->lightlevel); colormap = rover->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); }else{ @@ -3479,12 +3481,12 @@ void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, locFloorHeight, false); if (gr_frontsector->floorlightsec == -1) - floorlightlevel = HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel; + floorlightlevel = SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel); floorcolormap = gr_frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(gr_frontsector, locCeilingHeight, false); if (gr_frontsector->ceilinglightsec == -1) - ceilinglightlevel = HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel;; + ceilinglightlevel = SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel); ceilingcolormap = gr_frontsector->lightlist[light].extra_colormap; } @@ -3559,16 +3561,13 @@ void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - if (HWR_ShouldUsePaletteRendering()) - alpha = HWR_FogBlockAlpha((*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT, rover->master->frontsector->extra_colormap); - else - alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, &extrasubsectors[num], false, *rover->bottomheight, - HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, + SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } @@ -3579,7 +3578,7 @@ void HWR_Subsector(size_t num) &extrasubsectors[num], false, *rover->bottomheight, - HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, + SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } @@ -3587,7 +3586,7 @@ void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gr_frontsector, false)); light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->bottompic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } } @@ -3613,17 +3612,14 @@ void HWR_Subsector(size_t num) UINT8 alpha; light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - - if (HWR_ShouldUsePaletteRendering()) - alpha = HWR_FogBlockAlpha((*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT, rover->master->frontsector->extra_colormap); - else - alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + + alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, &extrasubsectors[num], true, *rover->topheight, - HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, + SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } @@ -3634,7 +3630,7 @@ void HWR_Subsector(size_t num) &extrasubsectors[num], true, *rover->topheight, - HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, + SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } @@ -3642,7 +3638,7 @@ void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, true)); light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->toppic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } } @@ -4316,7 +4312,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Start with the lightlevel and colormap from the top of the sprite - lightlevel = HWR_ShouldUsePaletteRendering() ? (*list[sector->numlights - 1].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *list[sector->numlights - 1].lightlevel; + lightlevel = SOFTLIGHT(*list[sector->numlights - 1].lightlevel); colormap = list[sector->numlights - 1].extra_colormap; i = 0; @@ -4333,7 +4329,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (h <= temp) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i-1].lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (*list[i-1].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *list[i-1].lightlevel; + lightlevel = *list[i-1].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i-1].lightlevel); colormap = list[i-1].extra_colormap; break; } @@ -4341,7 +4337,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) #else i = R_GetPlaneLight(sector, temp, false); if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (*list[i].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *list[i].lightlevel; + lightlevel = *list[i].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i].lightlevel); colormap = list[i].extra_colormap; #endif @@ -4357,7 +4353,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 : HWR_ShouldUsePaletteRendering() ? (*list[i].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *list[i].lightlevel; + lightlevel = *list[i].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i].lightlevel); colormap = list[i].extra_colormap; } @@ -4648,7 +4644,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) extracolormap_t *colormap = sector->extra_colormap; if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (sector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : sector->lightlevel; + lightlevel = sector->lightlevel > 255 ? 255 : SOFTLIGHT(sector->lightlevel); HWR_Lighting(&Surf, lightlevel, colormap); } @@ -4749,7 +4745,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (*sector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *sector->lightlist[light].lightlevel; + lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : SOFTLIGHT(*sector->lightlist[light].lightlevel); if (sector->lightlist[light].extra_colormap) colormap = sector->lightlist[light].extra_colormap; @@ -4757,7 +4753,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) else { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (sector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : sector->lightlevel; + lightlevel = sector->lightlevel > 255 ? 255 : SOFTLIGHT(sector->lightlevel); if (sector->extra_colormap) colormap = sector->extra_colormap; @@ -4819,6 +4815,7 @@ static int CompareVisSprites(const void *p1, const void *p2) return -1; } +#undef SOFTLIGHT static void HWR_SortVisSprites(void) { -- 2.54.0 From 65cb5b265c03795c65607416f4eed0ce27bace8f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 21:41:44 +0100 Subject: [PATCH 19/70] fix ternary hell for palette rendering lightlevels --- src/hardware/hw_main.c | 55 ++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 13f819664..c7223d848 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -53,6 +53,8 @@ #define ABS(x) ((x) < 0 ? -(x) : (x)) +#define SOFTLIGHT(llevel) HWR_ShouldUsePaletteRendering() ? ((llevel) >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : (llevel) + // ========================================================================== // the hardware driver object // ========================================================================== @@ -1129,7 +1131,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { if (HWR_ShouldUsePaletteRendering()) { - lightnum = (pfloor->master->frontsector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(pfloor->master->frontsector->lightlevel); colormap = pfloor->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); }else{ @@ -1141,7 +1143,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { if (HWR_ShouldUsePaletteRendering()) { - lightnum = (*list[i].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(*list[i].lightlevel); colormap = list[i].extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, v1x, v1y, v2x, v2y); }else{ @@ -1541,7 +1543,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (HWR_ShouldUsePaletteRendering()) { - lightnum = (gr_frontsector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(gr_frontsector->lightlevel); colormap = gr_frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); }else{ @@ -2489,7 +2491,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (HWR_ShouldUsePaletteRendering()) { - lightnum = (rover->master->frontsector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(rover->master->frontsector->lightlevel); colormap = rover->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); }else{ @@ -2640,7 +2642,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (HWR_ShouldUsePaletteRendering()) { - lightnum = (rover->master->frontsector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT; + lightnum = SOFTLIGHT(rover->master->frontsector->lightlevel); colormap = rover->master->frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); }else{ @@ -3479,12 +3481,12 @@ void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, locFloorHeight, false); if (gr_frontsector->floorlightsec == -1) - floorlightlevel = HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel; + floorlightlevel = SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel); floorcolormap = gr_frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(gr_frontsector, locCeilingHeight, false); if (gr_frontsector->ceilinglightsec == -1) - ceilinglightlevel = HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel;; + ceilinglightlevel = SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel); ceilingcolormap = gr_frontsector->lightlist[light].extra_colormap; } @@ -3559,16 +3561,13 @@ void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - if (HWR_ShouldUsePaletteRendering()) - alpha = HWR_FogBlockAlpha((*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT, rover->master->frontsector->extra_colormap); - else - alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, &extrasubsectors[num], false, *rover->bottomheight, - HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, + SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } @@ -3579,7 +3578,7 @@ void HWR_Subsector(size_t num) &extrasubsectors[num], false, *rover->bottomheight, - HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, + SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } @@ -3587,7 +3586,7 @@ void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gr_frontsector, false)); light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->bottompic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } } @@ -3613,17 +3612,14 @@ void HWR_Subsector(size_t num) UINT8 alpha; light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - - if (HWR_ShouldUsePaletteRendering()) - alpha = HWR_FogBlockAlpha((*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT, rover->master->frontsector->extra_colormap); - else - alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + + alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, &extrasubsectors[num], true, *rover->topheight, - HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, + SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } @@ -3634,7 +3630,7 @@ void HWR_Subsector(size_t num) &extrasubsectors[num], true, *rover->topheight, - HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, + SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } @@ -3642,7 +3638,7 @@ void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, true)); light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, HWR_ShouldUsePaletteRendering() ? (*gr_frontsector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->toppic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } } @@ -4314,7 +4310,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Start with the lightlevel and colormap from the top of the sprite - lightlevel = HWR_ShouldUsePaletteRendering() ? (*list[sector->numlights - 1].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *list[sector->numlights - 1].lightlevel; + lightlevel = SOFTLIGHT(*list[sector->numlights - 1].lightlevel); colormap = list[sector->numlights - 1].extra_colormap; i = 0; @@ -4331,7 +4327,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (h <= temp) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i-1].lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (*list[i-1].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *list[i-1].lightlevel; + lightlevel = *list[i-1].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i-1].lightlevel); colormap = list[i-1].extra_colormap; break; } @@ -4339,7 +4335,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) #else i = R_GetPlaneLight(sector, temp, false); if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (*list[i].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *list[i].lightlevel; + lightlevel = *list[i].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i].lightlevel); colormap = list[i].extra_colormap; #endif @@ -4355,7 +4351,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 : HWR_ShouldUsePaletteRendering() ? (*list[i].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *list[i].lightlevel; + lightlevel = *list[i].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i].lightlevel); colormap = list[i].extra_colormap; } @@ -4646,7 +4642,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) extracolormap_t *colormap = sector->extra_colormap; if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (sector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : sector->lightlevel; + lightlevel = sector->lightlevel > 255 ? 255 : SOFTLIGHT(sector->lightlevel); HWR_Lighting(&Surf, lightlevel, colormap); } @@ -4747,7 +4743,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (*sector->lightlist[light].lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : *sector->lightlist[light].lightlevel; + lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : SOFTLIGHT(*sector->lightlist[light].lightlevel); if (sector->lightlist[light].extra_colormap) colormap = sector->lightlist[light].extra_colormap; @@ -4755,7 +4751,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) else { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : HWR_ShouldUsePaletteRendering() ? (sector->lightlevel >> LIGHTSEGSHIFT) << LIGHTSEGSHIFT : sector->lightlevel; + lightlevel = sector->lightlevel > 255 ? 255 : SOFTLIGHT(sector->lightlevel); if (sector->extra_colormap) colormap = sector->extra_colormap; @@ -4817,6 +4813,7 @@ static int CompareVisSprites(const void *p1, const void *p2) return -1; } +#undef SOFTLIGHT static void HWR_SortVisSprites(void) { -- 2.54.0 From c6e07015815c8f85b99e3d59de4398e70b87161d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 22:46:51 +0100 Subject: [PATCH 20/70] forgor those --- src/hardware/hw_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c7223d848..b2fea0c4f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2499,7 +2499,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom colormap = rover->master->frontsector->extra_colormap; } - Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); + Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(SOFTLIGHT(rover->master->frontsector->lightlevel), rover->master->frontsector->extra_colormap); if (gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, 0, &Surf, rover->flags, rover, 0); @@ -2650,7 +2650,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom colormap = rover->master->frontsector->extra_colormap; } - Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); + Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(SOFTLIGHT(rover->master->frontsector->lightlevel), rover->master->frontsector->extra_colormap); if (gr_backsector->numlights) HWR_SplitWall(gr_backsector, wallVerts, 0, &Surf, rover->flags, rover, 0); -- 2.54.0 From b96fe0a0223682895e977bf3fe2434311ea1455e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 22:53:04 +0100 Subject: [PATCH 21/70] those too --- src/hardware/hw_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b2fea0c4f..0da852f8a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3314,13 +3314,13 @@ void HWR_AddPolyObjectPlanes(void) FSurfaceInfo Surf; FBITFIELD blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight, - polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); + SOFTLIGHT(polyobjsector->lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); } else { HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum, R_NoEncore(polyobjsector, false)); HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude, - polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, + SOFTLIGHT(polyobjsector->lightlevel), levelflats[polyobjsector->floorpic].lumpnum, polyobjsector, 255, NULL); } } @@ -3336,13 +3336,13 @@ void HWR_AddPolyObjectPlanes(void) memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight, - polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); + SOFTLIGHT(polyobjsector->lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); } else { HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum, R_NoEncore(polyobjsector, true)); HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude, - polyobjsector->lightlevel, levelflats[polyobjsector->ceilingpic].lumpnum, + SOFTLIGHT(polyobjsector->lightlevel), levelflats[polyobjsector->ceilingpic].lumpnum, polyobjsector, 255, NULL); } } -- 2.54.0 From cd239b0f357a2d1003ac0d6186a28054ac870c61 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 23:26:18 +0100 Subject: [PATCH 22/70] fix conflicts --- src/hardware/hw_cache.c | 22 +++++++--------------- src/hardware/hw_glob.h | 3 +-- src/hardware/hw_main.c | 1 - 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index f4007b826..c32870fed 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -321,8 +321,7 @@ bpp = format2bpp(grMipmap->format); // Create a composite texture from patches, adapt the texture size to a power of 2 // height and width for the hardware texture cache. // -static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex, boolean noencore) -static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex) +static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, boolean noencore) { UINT8 *block; texture_t *texture; @@ -560,11 +559,10 @@ void HWR_LoadTextures(size_t pnumtextures) // -------------------------------------------------------------------------- // Make sure texture is downloaded and set it as the source // -------------------------------------------------------------------------- -GLTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) -GLMapTexture_t *HWR_GetTexture(INT32 tex) +GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore) { GLMapTexture_t *grtex; - + if (tex < 0 || tex >= (signed)gr_numtextures) { #ifdef PARANOIA @@ -572,20 +570,17 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex) #else tex = 0; #endif - grtex = &gr_textures[tex*2 + (encoremap && !noencore ? 0 : 1)]; } + + grtex = &gr_textures[tex*2 + (encoremap && !noencore ? 0 : 1)]; - grtex = &gr_textures[tex]; - - if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) - HWR_GenerateTexture(tex, grtex, noencore); if (!grtex->mipmap.data && !grtex->mipmap.downloaded) - HWR_GenerateTexture(tex, grtex); + HWR_GenerateTexture(tex, grtex, noencore); // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grtex->mipmap.downloaded) HWD.pfnSetTexture(&grtex->mipmap); - + HWR_SetCurrentTexture(&grtex->mipmap); // The system-memory data can be purged now. @@ -594,7 +589,6 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex) return grtex; } - static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) { #ifdef GLENCORE @@ -603,7 +597,6 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) #endif size_t size, pflatsize; - // setup the texture info grMipmap->format = GL_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; @@ -649,7 +642,6 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) #endif } - // Download a Doom 'flat' to the hardware cache and make it ready for use void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) { diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 60c3b1fae..742fd82ae 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -63,8 +63,7 @@ void HWR_FreeExtraSubsectors(void); void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap); // ^ some flats must NOT be remapped to encore, since we remap them as we cache them for ease, adding a toggle here seems wise. -GLMapTexture_t *HWR_GetTexture(INT32 tex); -GLTexture_t *HWR_GetTexture(INT32 tex, boolean noencore); +GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore); void HWR_GetPatch(GLPatch_t *gpatch); void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); void HWR_MakePatch(patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e83349fcf..8403c6565 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5812,7 +5812,6 @@ void HWR_DrawSkyBackground(float fpov) dometransform.roll = atransform.roll; dometransform.splitscreen = splitscreen; - HWR_GetTexture(texturetranslation[skytexture]); if (HWR_UseShader()) HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_SKY));// sky shader HWR_GetTexture(texturetranslation[skytexture], false); -- 2.54.0 From 0b1add2988dc7d1cb25ab508704063d98f0226eb Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 23:27:26 +0100 Subject: [PATCH 23/70] one more --- src/hardware/hw_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8403c6565..bb80441af 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5812,10 +5812,9 @@ void HWR_DrawSkyBackground(float fpov) dometransform.roll = atransform.roll; dometransform.splitscreen = splitscreen; + HWR_GetTexture(texturetranslation[skytexture], false); if (HWR_UseShader()) HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_SKY));// sky shader - HWR_GetTexture(texturetranslation[skytexture], false); - HWD.pfnSetShader(7); // sky shader HWD.pfnRenderSkyDome(skytexture, textures[skytexture]->width, textures[skytexture]->height, dometransform); } -- 2.54.0 From bee72c4646def39547de0bd721943120d4d82927 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 23:40:30 +0100 Subject: [PATCH 24/70] remove redundant check --- src/r_fps.c | 56 ++++++++++++++++------------------------------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index f01730d50..f29ffa88f 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -305,56 +305,36 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->y = mobj->old_y; else out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); - + if (mobj->z == mobj->old_z) out->z = mobj->old_z; else out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - if (cv_gravstretch.value || cv_saltysquish.value) // for now we only use it for those two features so no need to interpolate this when we dont use stuff - { - if (mobj->spritexscale == mobj->old_spritexscale) - out->spritexscale = mobj->old_spritexscale; - else - out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); - - if (mobj->spriteyscale == mobj->old_spriteyscale) - out->spriteyscale = mobj->old_spriteyscale; - else - out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); - } + if (mobj->spritexscale == mobj->old_spritexscale) + out->spritexscale = mobj->old_spritexscale; else - { - out->spritexscale = mobj->spritexscale; - out->spriteyscale = mobj->spriteyscale; - } + out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); - if (cv_saltyhop.value) // same here - { - if (mobj->spritexoffset == mobj->old_spritexoffset) - out->spritexoffset = mobj->old_spritexoffset; - else - out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); - - if (mobj->spriteyoffset == mobj->old_spriteyoffset) - out->spriteyoffset = mobj->old_spriteyoffset; - else - out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); - } + if (mobj->spriteyscale == mobj->old_spriteyscale) + out->spriteyscale = mobj->old_spriteyscale; else - { - out->spritexoffset = mobj->spritexoffset; - out->spriteyoffset = mobj->spriteyoffset; - } + out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); + + if (mobj->spritexoffset == mobj->old_spritexoffset) + out->spritexoffset = mobj->old_spritexoffset; + else + out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); + + if (mobj->spriteyoffset == mobj->old_spriteyoffset) + out->spriteyoffset = mobj->old_spriteyoffset; + else + out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); if (mobj->scale == mobj->old_scale) // Tiny optimisation - scale is usually unchanging, so let's skip a lerp, two FixedMuls, and two FixedDivs - { out->scale = mobj->scale; - } else - { out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac); - } if (cv_mobjssector.value) out->subsector = R_PointInSubsector(out->x, out->y); @@ -362,9 +342,7 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->subsector = mobj->subsector; if (mobj->player) - { out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac); - } else { if (mobj->angle == mobj->old_angle) -- 2.54.0 From 339aab8540b62a99e0add18f6631d09760c28840 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Feb 2024 23:45:26 +0100 Subject: [PATCH 25/70] use the current not old state also add dont interp precip angle if it doesent change --- src/r_fps.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index f29ffa88f..209886301 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -297,37 +297,37 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) } if (mobj->x == mobj->old_x) - out->x = mobj->old_x; + out->x = mobj->x; else out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); if (mobj->y == mobj->old_y) - out->y = mobj->old_y; + out->y = mobj->y; else out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); if (mobj->z == mobj->old_z) - out->z = mobj->old_z; + out->z = mobj->z; else out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); if (mobj->spritexscale == mobj->old_spritexscale) - out->spritexscale = mobj->old_spritexscale; + out->spritexscale = mobj->spritexscale; else out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac); if (mobj->spriteyscale == mobj->old_spriteyscale) - out->spriteyscale = mobj->old_spriteyscale; + out->spriteyscale = mobj->spriteyscale; else out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac); if (mobj->spritexoffset == mobj->old_spritexoffset) - out->spritexoffset = mobj->old_spritexoffset; + out->spritexoffset = mobj->spritexoffset; else out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac); if (mobj->spriteyoffset == mobj->old_spriteyoffset) - out->spriteyoffset = mobj->old_spriteyoffset; + out->spriteyoffset = mobj->spriteyoffset; else out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac); @@ -346,7 +346,7 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) else { if (mobj->angle == mobj->old_angle) - out->angle = mobj->old_angle; + out->angle = mobj->angle; else out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); } @@ -401,7 +401,10 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst else out->subsector = mobj->subsector; - out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); + if (mobj->angle == mobj->old_angle) + out->angle = mobj->angle; + else + out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); } static void AddInterpolator(levelinterpolator_t* interpolator) @@ -629,36 +632,36 @@ void R_ApplyLevelInterpolators(fixed_t frac) if (interp->sectorscroll.ceiling) { if (interp->sectorscroll.sector->ceiling_xoffs == interp->sectorscroll.oldxoffs) - interp->sectorscroll.sector->ceiling_xoffs = interp->sectorscroll.oldxoffs; + interp->sectorscroll.sector->ceiling_xoffs = interp->sectorscroll.bakxoffs; else interp->sectorscroll.sector->ceiling_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); if (interp->sectorscroll.sector->ceiling_yoffs == interp->sectorscroll.oldyoffs) - interp->sectorscroll.sector->ceiling_yoffs = interp->sectorscroll.oldyoffs; + interp->sectorscroll.sector->ceiling_yoffs = interp->sectorscroll.bakyoffs; else interp->sectorscroll.sector->ceiling_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } else { if (interp->sectorscroll.sector->floor_xoffs == interp->sectorscroll.oldxoffs) - interp->sectorscroll.sector->floor_xoffs = interp->sectorscroll.oldxoffs; + interp->sectorscroll.sector->floor_xoffs = interp->sectorscroll.bakxoffs; else interp->sectorscroll.sector->floor_xoffs = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac); if (interp->sectorscroll.sector->floor_yoffs == interp->sectorscroll.oldyoffs) - interp->sectorscroll.sector->floor_yoffs = interp->sectorscroll.oldyoffs; + interp->sectorscroll.sector->floor_yoffs = interp->sectorscroll.bakyoffs; else interp->sectorscroll.sector->floor_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac); } break; case LVLINTERP_SideScroll: if (interp->sidescroll.side->textureoffset == interp->sidescroll.oldtextureoffset) - interp->sidescroll.side->textureoffset = interp->sidescroll.oldtextureoffset; + interp->sidescroll.side->textureoffset = interp->sidescroll.baktextureoffset; else interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac); if (interp->sidescroll.side->rowoffset == interp->sidescroll.oldrowoffset) - interp->sidescroll.side->rowoffset = interp->sidescroll.oldrowoffset; + interp->sidescroll.side->rowoffset = interp->sidescroll.bakrowoffset; else interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac); break; @@ -669,12 +672,12 @@ void R_ApplyLevelInterpolators(fixed_t frac) interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac); } if (interp->polyobj.polyobj->centerPt.x == interp->polyobj.oldcx) - interp->polyobj.polyobj->centerPt.x = interp->polyobj.oldcx; + interp->polyobj.polyobj->centerPt.x = interp->polyobj.bakcx; else interp->polyobj.polyobj->centerPt.x = R_LerpFixed(interp->polyobj.oldcx, interp->polyobj.bakcx, frac); if (interp->polyobj.polyobj->centerPt.y == interp->polyobj.oldcy) - interp->polyobj.polyobj->centerPt.y = interp->polyobj.oldcy; + interp->polyobj.polyobj->centerPt.y = interp->polyobj.bakcy; else interp->polyobj.polyobj->centerPt.y = R_LerpFixed(interp->polyobj.oldcy, interp->polyobj.bakcy, frac); -- 2.54.0 From bcc15011b20f920e19a7c3d43380c90e2beb7d80 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Feb 2024 01:27:52 +0100 Subject: [PATCH 26/70] forgor those aswell --- src/r_fps.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 209886301..66441397e 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -351,23 +351,27 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac); } - if (cv_spriteroll.value) // no need to interpolate this if its disabled - { - // pitch roll stuff + // pitch roll stuff + if (mobj->pitch == mobj->old_pitch) + out->pitch = mobj->pitch; + else out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac); + + if (mobj->roll == mobj->old_roll) + out->roll = mobj->roll; + else out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac); - // and the slope stuff - out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); - out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); - } - else - { - out->pitch = mobj->pitch; - out->roll = mobj->roll; + // and the slope stuff + if (mobj->slopepitch == mobj->old_slopepitch) out->slopepitch = mobj->slopepitch; + else + out->slopepitch = mobj->resetinterp ? mobj->slopepitch : R_LerpAngle(mobj->old_slopepitch, mobj->slopepitch, frac); + + if (mobj->sloperoll == mobj->old_sloperoll) out->sloperoll = mobj->sloperoll; - } + else + out->sloperoll = mobj->resetinterp ? mobj->sloperoll : R_LerpAngle(mobj->old_sloperoll, mobj->sloperoll, frac); } void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjstate_t *out) @@ -615,14 +619,14 @@ void R_ApplyLevelInterpolators(fixed_t frac) if (interp->sectorplane.ceiling) { if (interp->sectorplane.sector->ceilingheight == interp->sectorplane.oldheight) - interp->sectorplane.sector->ceilingheight = interp->sectorplane.oldheight; + interp->sectorplane.sector->ceilingheight = interp->sectorplane.bakheight; else interp->sectorplane.sector->ceilingheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); } else { if (interp->sectorplane.sector->floorheight == interp->sectorplane.oldheight) - interp->sectorplane.sector->floorheight = interp->sectorplane.oldheight; + interp->sectorplane.sector->floorheight = interp->sectorplane.bakheight; else interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac); } @@ -668,8 +672,15 @@ void R_ApplyLevelInterpolators(fixed_t frac) case LVLINTERP_Polyobj: for (ii = 0; ii < interp->polyobj.vertices_size; ii++) { - interp->polyobj.polyobj->vertices[ii]->x = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 ], interp->polyobj.bakvertices[ii * 2 ], frac); - interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac); + if (interp->polyobj.polyobj->vertices[ii]->x == interp->polyobj.oldvertices[ii * 2 ]) + interp->polyobj.polyobj->vertices[ii]->x = interp->polyobj.bakvertices[ii * 2 ]; + else + interp->polyobj.polyobj->vertices[ii]->x = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 ], interp->polyobj.bakvertices[ii * 2 ], frac); + + if (interp->polyobj.polyobj->vertices[ii]->y == interp->polyobj.oldvertices[ii * 2 + 1]) + interp->polyobj.polyobj->vertices[ii]->y = interp->polyobj.bakvertices[ii * 2 + 1]; + else + interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac); } if (interp->polyobj.polyobj->centerPt.x == interp->polyobj.oldcx) interp->polyobj.polyobj->centerPt.x = interp->polyobj.bakcx; -- 2.54.0 From 9b4f05131237872f65b87e8394f11c0641a996e4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Feb 2024 01:35:49 +0100 Subject: [PATCH 27/70] this aswell --- src/r_fps.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/r_fps.c b/src/r_fps.c index 66441397e..33cd206c7 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -342,7 +342,12 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) out->subsector = mobj->subsector; if (mobj->player) - out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac); + { + if (mobj->angle == mobj->player->old_frameangle) + out->angle = mobj->player->frameangle; + else + out->angle = mobj->resetinterp ? mobj->player->frameangle : R_LerpAngle(mobj->player->old_frameangle, mobj->player->frameangle, frac); + } else { if (mobj->angle == mobj->old_angle) -- 2.54.0 From bd2c8969f1eafa232230763318abebe73e9f0be8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 24 Feb 2024 17:23:41 +0100 Subject: [PATCH 28/70] Revert "Refactor Batching code" This reverts commit 3dcf4f6f6472b76fe8cd124c52ee5c35c3bac8e4. --- src/hardware/hw_batching.c | 569 +++++++++++++++++++------------------ src/hardware/hw_batching.h | 12 + 2 files changed, 306 insertions(+), 275 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 388bb2023..aa0e05375 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -15,54 +15,29 @@ #include "hw_main.h" #include "../i_system.h" -typedef struct -{ - FSurfaceInfo surf; // surf also has its own polyflags for some reason, but it seems unused - unsigned int vertsIndex; // location of verts in unsortedVertices - FUINT numVerts; - FBITFIELD polyFlags; - GLMipmap_t *texture; - int shader; - // this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls - boolean horizonSpecial; -} DrawCallInfo; - // The texture for the next polygon given to HWR_ProcessPolygon. // Set with HWR_SetCurrentTexture. GLMipmap_t *current_texture = NULL; boolean currently_batching = false; -// Dynamic arrays for: -// - unsorted draw calls -// - sorted order of draw calls -// - unsorted vertices -// - final (sorted) vertices -// - vertex indices for sorted vertices +FOutVector* finalVertexArray = NULL;// contains subset of sorted vertices and texture coordinates to be sent to gpu +UINT32* finalVertexIndexArray = NULL;// contains indexes for glDrawElements, taking into account fan->triangles conversion +// NOTE have this alloced as 3x finalVertexArray size +int finalVertexArrayAllocSize = 65536; +//GLubyte* colorArray = NULL;// contains color data to be sent to gpu, if needed +//int colorArrayAllocSize = 65536; +// not gonna use this for now, just sort by color and change state when it changes +// later maybe when using vertex attributes if it's needed -// contains the draw calls from DrawPolygon, waiting to be processed -DrawCallInfo* drawCalls = NULL; -int drawCallsSize = 0; -int drawCallsCapacity = 65536; +PolygonArrayEntry* polygonArray = NULL;// contains the polygon data from DrawPolygon, waiting to be processed +int polygonArraySize = 0; +UINT32* polygonIndexArray = NULL;// contains sorting pointers for polygonArray +int polygonArrayAllocSize = 65536; -// contains sorted order (array indices) for drawCalls -// (therefore size and capacity shared with it) -UINT32* drawCallOrder = NULL; - -// contains unsorted vertices and texture coordinates from DrawPolygon -FOutVector* unsortedVertices = NULL; -int unsortedVerticesSize = 0; -int unsortedVerticesCapacity = 65536; - -// contains subset of sorted vertices and texture coordinates to be sent to gpu -FOutVector* finalVertices = NULL; -int finalVerticesSize = 0; -int finalVerticesCapacity = 65536; - -// contains vertex indices into finalVertices for glDrawElements, -// taking into account fan->triangles conversion -UINT32* finalIndices = NULL; // this is alloced with 3x finalVertices size -int finalIndicesSize = 0; +FOutVector* unsortedVertexArray = NULL;// contains unsorted vertices and texture coordinates from DrawPolygon +int unsortedVertexArraySize = 0; +int unsortedVertexArrayAllocSize = 65536; // Enables batching mode. HWR_ProcessPolygon will collect polygons instead of passing them directly to the rendering backend. // Call HWR_RenderBatches to render all the collected geometry. @@ -72,13 +47,13 @@ void HWR_StartBatching(void) I_Error("Repeat call to HWR_StartBatching without HWR_RenderBatches"); // init arrays if that has not been done yet - if (!finalVertices) + if (!finalVertexArray) { - finalVertices = malloc(finalVerticesCapacity * sizeof(FOutVector)); - finalIndices = malloc(finalVerticesCapacity * 3 * sizeof(UINT32)); - drawCalls = malloc(drawCallsCapacity * sizeof(DrawCallInfo)); - drawCallOrder = malloc(drawCallsCapacity * sizeof(UINT32)); - unsortedVertices = malloc(unsortedVerticesCapacity * sizeof(FOutVector)); + finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector)); + finalVertexIndexArray = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32)); + polygonArray = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry)); + polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32)); + unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector)); } currently_batching = true; @@ -89,55 +64,14 @@ void HWR_StartBatching(void) // Doing this was easier than getting a texture pointer to HWR_ProcessPolygon. void HWR_SetCurrentTexture(GLMipmap_t *texture) { - if (currently_batching) - current_texture = texture; - else - HWD.pfnSetTexture(texture); -} - -static void HWR_CollectDrawCallInfo(FSurfaceInfo *pSurf, FUINT iNumPts, FBITFIELD PolyFlags, int shader_target, boolean horizonSpecial) -{ - // make sure dynamic array has capacity - if (drawCallsSize == drawCallsCapacity) - { - DrawCallInfo* new_array; - // ran out of space, make new array double the size - drawCallsCapacity *= 2; - new_array = malloc(drawCallsCapacity * sizeof(DrawCallInfo)); - memcpy(new_array, drawCalls, drawCallsSize * sizeof(DrawCallInfo)); - free(drawCalls); - drawCalls = new_array; - // also need to redo the index array, dont need to copy it though - free(drawCallOrder); - drawCallOrder = malloc(drawCallsCapacity * sizeof(UINT32)); - } - // add entry to array - drawCalls[drawCallsSize].surf = *pSurf; - drawCalls[drawCallsSize].vertsIndex = unsortedVerticesSize; - drawCalls[drawCallsSize].numVerts = iNumPts; - drawCalls[drawCallsSize].polyFlags = PolyFlags; - drawCalls[drawCallsSize].texture = current_texture; - drawCalls[drawCallsSize].shader = (shader_target != -1) ? HWR_GetShaderFromTarget(shader_target) : shader_target; - drawCalls[drawCallsSize].horizonSpecial = horizonSpecial; - drawCallsSize++; -} - -static void HWR_CollectDrawCallVertices(FOutVector *pOutVerts, FUINT iNumPts) -{ - // make sure dynamic array has capacity - while (unsortedVerticesSize + (int)iNumPts > unsortedVerticesCapacity) - { - FOutVector* new_array; - // need more space for vertices in unsortedVertices - unsortedVerticesCapacity *= 2; - new_array = malloc(unsortedVerticesCapacity * sizeof(FOutVector)); - memcpy(new_array, unsortedVertices, unsortedVerticesSize * sizeof(FOutVector)); - free(unsortedVertices); - unsortedVertices = new_array; - } - // add vertices to array - memcpy(&unsortedVertices[unsortedVerticesSize], pOutVerts, iNumPts * sizeof(FOutVector)); - unsortedVerticesSize += iNumPts; + if (currently_batching) + { + current_texture = texture; + } + else + { + HWD.pfnSetTexture(texture); + } } // If batching is enabled, this function collects the polygon data and the chosen texture @@ -145,16 +79,48 @@ static void HWR_CollectDrawCallVertices(FOutVector *pOutVerts, FUINT iNumPts) // render the polygon immediately. void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader_target, boolean horizonSpecial) { - if (currently_batching) + if (currently_batching) { if (!pSurf) + I_Error("Got a null FSurfaceInfo in batching");// nulls should not come in the stuff that batching currently applies to + if (polygonArraySize == polygonArrayAllocSize) { - // handling null FSurfaceInfo is not implemented - I_Error("Got a null FSurfaceInfo in batching"); + PolygonArrayEntry* new_array; + // ran out of space, make new array double the size + polygonArrayAllocSize *= 2; + new_array = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry)); + memcpy(new_array, polygonArray, polygonArraySize * sizeof(PolygonArrayEntry)); + free(polygonArray); + polygonArray = new_array; + // also need to redo the index array, dont need to copy it though + free(polygonIndexArray); + polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32)); } - HWR_CollectDrawCallInfo(pSurf, iNumPts, PolyFlags, shader_target, horizonSpecial); - HWR_CollectDrawCallVertices(pOutVerts, iNumPts); + 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; + } + + // add the polygon data to the arrays + + polygonArray[polygonArraySize].surf = *pSurf; + polygonArray[polygonArraySize].vertsIndex = unsortedVertexArraySize; + polygonArray[polygonArraySize].numVerts = iNumPts; + polygonArray[polygonArraySize].polyFlags = PolyFlags; + polygonArray[polygonArraySize].texture = current_texture; + polygonArray[polygonArraySize].shader = shader; + polygonArray[polygonArraySize].horizonSpecial = horizonSpecial; + polygonArraySize++; + + memcpy(&unsortedVertexArray[unsortedVertexArraySize], pOutVerts, iNumPts * sizeof(FOutVector)); + unsortedVertexArraySize += iNumPts; } else { @@ -163,12 +129,12 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt } } -static int compareDrawCalls(const void *p1, const void *p2) +static int comparePolygons(const void *p1, const void *p2) { - UINT32 index1 = *(const UINT32*)p1; - UINT32 index2 = *(const UINT32*)p2; - DrawCallInfo* poly1 = &drawCalls[index1]; - DrawCallInfo* poly2 = &drawCalls[index2]; + unsigned int index1 = *(const unsigned int*)p1; + unsigned int index2 = *(const unsigned int*)p2; + PolygonArrayEntry* poly1 = &polygonArray[index1]; + PolygonArrayEntry* poly2 = &polygonArray[index2]; int diff; INT64 diff64; UINT32 downloaded1 = 0; @@ -213,12 +179,12 @@ static int compareDrawCalls(const void *p1, const void *p2) return diff; } -static int compareDrawCallsNoShaders(const void *p1, const void *p2) +static int comparePolygonsNoShaders(const void *p1, const void *p2) { - UINT32 index1 = *(const UINT32*)p1; - UINT32 index2 = *(const UINT32*)p2; - DrawCallInfo* poly1 = &drawCalls[index1]; - DrawCallInfo* poly2 = &drawCalls[index2]; + unsigned int index1 = *(const unsigned int*)p1; + unsigned int index2 = *(const unsigned int*)p2; + PolygonArrayEntry* poly1 = &polygonArray[index1]; + PolygonArrayEntry* poly2 = &polygonArray[index2]; int diff; INT64 diff64; @@ -249,155 +215,60 @@ static int compareDrawCallsNoShaders(const void *p1, const void *p2) return 0; } -static void HWR_CollectVerticesIntoBatch(DrawCallInfo *drawCall) -{ - int firstVIndex; - int lastVIndex; - int numVerts = drawCall->numVerts; - // before writing, check if there is enough room - // using 'while' instead of 'if' here makes sure that there will *always* be enough room. - // probably never will this loop run more than once though - while (finalVerticesSize + numVerts > finalVerticesCapacity) - { - FOutVector* new_array; - UINT32* new_index_array; - finalVerticesCapacity *= 2; - new_array = malloc(finalVerticesCapacity * sizeof(FOutVector)); - memcpy(new_array, finalVertices, finalVerticesSize * sizeof(FOutVector)); - free(finalVertices); - finalVertices = new_array; - // 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(finalVerticesCapacity * 3 * sizeof(UINT32)); - memcpy(new_index_array, finalIndices, finalIndicesSize * sizeof(UINT32)); - free(finalIndices); - finalIndices = new_index_array; - } - // write the vertices of the polygon - memcpy(&finalVertices[finalVerticesSize], &unsortedVertices[drawCall->vertsIndex], - numVerts * sizeof(FOutVector)); - // write the indexes, pointing to the fan vertexes but in triangles format - firstVIndex = finalVerticesSize; - lastVIndex = finalVerticesSize + numVerts; - finalVerticesSize += 2; - while (finalVerticesSize < lastVIndex) - { - finalIndices[finalIndicesSize++] = firstVIndex; - finalIndices[finalIndicesSize++] = finalVerticesSize - 1; - finalIndices[finalIndicesSize++] = finalVerticesSize++; - } -} - -static GLMipmap_t *HWR_GetDrawCallTexture(DrawCallInfo *dc) -{ - return (dc->polyFlags & PF_NoTexture) ? NULL : dc->texture; -} - -// flags returned by HWR_MarkStateChanges -#define SHADER_CHANGED 1 -#define TEXTURE_CHANGED 2 -#define POLYFLAGS_CHANGED 4 -#define SURFACEINFO_CHANGED 8 - -static unsigned int HWR_MarkStateChanges(DrawCallInfo *current, DrawCallInfo *next) -{ - unsigned int stateChanges = 0; - FSurfaceInfo *currentSI = ¤t->surf; - FSurfaceInfo *nextSI = &next->surf; - - // check if a state change is required and flag it to stateChanges - - if (current->shader != next->shader && cv_grshaders.value && gr_shadersavailable) - stateChanges |= SHADER_CHANGED; - if (HWR_GetDrawCallTexture(current) != HWR_GetDrawCallTexture(next)) - stateChanges |= TEXTURE_CHANGED; - if (current->polyFlags != next->polyFlags) - stateChanges |= POLYFLAGS_CHANGED; - if (cv_grshaders.value && gr_shadersavailable) - { - if (currentSI->PolyColor.rgba != nextSI->PolyColor.rgba || - currentSI->TintColor.rgba != nextSI->TintColor.rgba || - currentSI->FadeColor.rgba != nextSI->FadeColor.rgba || - currentSI->LightInfo.light_level != nextSI->LightInfo.light_level || - currentSI->LightInfo.fade_start != nextSI->LightInfo.fade_start || - currentSI->LightInfo.fade_end != nextSI->LightInfo.fade_end) - { - stateChanges |= SURFACEINFO_CHANGED; - } - } - else - { - if (currentSI->PolyColor.rgba != nextSI->PolyColor.rgba) - stateChanges |= SURFACEINFO_CHANGED; - } - - return stateChanges; -} - -static void HWR_ExecuteStateChanges(unsigned int stateChanges, DrawCallInfo *dc) -{ - if ((stateChanges & SHADER_CHANGED) && cv_grshaders.value && gr_shadersavailable) - { - HWD.pfnSetShader(dc->shader); - ps_hw_numshaders.value.i++; - } - if (stateChanges & TEXTURE_CHANGED) - { - // for PF_NoTexture the texture is set in DrawIndexedTriangles - if (!(dc->polyFlags & PF_NoTexture)) - { - // texture should be already ready for use from calls to - // SetTexture during batch collection - HWD.pfnSetTexture(dc->texture); - } - ps_hw_numtextures.value.i++; - } - // these two are just parameters to DrawIndexedTriangles - // (changes to polyflags states are tracked in r_opengl.c though) - if (stateChanges & POLYFLAGS_CHANGED) - ps_hw_numpolyflags.value.i++; - if (stateChanges & SURFACEINFO_CHANGED) - ps_hw_numcolors.value.i++; -} - - -static void HWR_InitBatchingStats(void) -{ - ps_hw_numpolys.value.i = drawCallsSize; - ps_hw_numcalls.value.i = ps_hw_numverts.value.i - = ps_hw_numshaders.value.i = ps_hw_numtextures.value.i - = ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 0; -} - -// This function organizes the geometry and draw calls collected by HWR_ProcessPolygon -// calls into batches and uses the rendering backend to draw them. +// This function organizes the geometry collected by HWR_ProcessPolygon calls into batches and uses +// the rendering backend to draw them. void HWR_RenderBatches(void) { - int drawCallReadPos = 0; // position in drawCallOrder + int finalVertexWritePos = 0;// position in finalVertexArray + int finalIndexWritePos = 0;// position in finalVertexIndexArray + + int polygonReadPos = 0;// position in polygonIndexArray + + int currentShader; + int nextShader = 0; + GLMipmap_t *currentTexture; + GLMipmap_t *nextTexture = NULL; + FBITFIELD currentPolyFlags = 0; + FBITFIELD nextPolyFlags = 0; + FSurfaceInfo currentSurfaceInfo; + FSurfaceInfo nextSurfaceInfo; + int i; - if (!currently_batching) + if (!currently_batching) I_Error("HWR_RenderBatches called without starting batching"); - currently_batching = false; // no longer collecting batches + nextSurfaceInfo.LightInfo.fade_end = 0; + nextSurfaceInfo.LightInfo.fade_start = 0; + nextSurfaceInfo.LightInfo.light_level = 0; - HWR_InitBatchingStats(); + currently_batching = false;// no longer collecting batches + if (!polygonArraySize) + { + ps_hw_numpolys.value.i = ps_hw_numcalls.value.i = ps_hw_numshaders.value.i + = ps_hw_numtextures.value.i = ps_hw_numpolyflags.value.i + = ps_hw_numcolors.value.i = 0; + return;// nothing to draw + } + // init stats vars + ps_hw_numpolys.value.i = polygonArraySize; + ps_hw_numcalls.value.i = ps_hw_numverts.value.i = 0; + ps_hw_numshaders.value.i = ps_hw_numtextures.value.i + = ps_hw_numpolyflags.value.i = ps_hw_numcolors.value.i = 1; + // init polygonIndexArray + for (i = 0; i < polygonArraySize; i++) + { + polygonIndexArray[i] = i; + } - if (!drawCallsSize) - return; // nothing to draw - - // init drawCallOrder - for (i = 0; i < drawCallsSize; i++) - drawCallOrder[i] = i; - - // sort the draw calls + // sort polygons PS_START_TIMING(ps_hw_batchsorttime); if (cv_grshaders.value && gr_shadersavailable) - qsort(drawCallOrder, drawCallsSize, sizeof(UINT32), compareDrawCalls); + qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygons); else - qsort(drawCallOrder, drawCallsSize, sizeof(UINT32), compareDrawCallsNoShaders); + qsort(polygonIndexArray, polygonArraySize, sizeof(unsigned int), comparePolygonsNoShaders); PS_STOP_TIMING(ps_hw_batchsorttime); - // sort grouping order + // sort order // 1. shader // 2. texture // 3. polyflags @@ -406,57 +277,205 @@ void HWR_RenderBatches(void) PS_START_TIMING(ps_hw_batchdrawtime); + currentShader = polygonArray[polygonIndexArray[0]].shader; + currentTexture = polygonArray[polygonIndexArray[0]].texture; + currentPolyFlags = polygonArray[polygonIndexArray[0]].polyFlags; + currentSurfaceInfo = polygonArray[polygonIndexArray[0]].surf; + // For now, will sort and track the colors. Vertex attributes could be used instead of uniforms + // and a color array could replace the color calls. + // set state for first batch - HWR_ExecuteStateChanges(0xFFFF, &drawCalls[drawCallOrder[0]]); - // - iterate through draw calls - // - accumulate converted vertices and indices into finalVertices and finalIndices - // and send them as a combined draw call when a state change occurs - while (1) + if (cv_grshaders.value && gr_shadersavailable) { + HWD.pfnSetShader(currentShader); + } + + if (currentPolyFlags & PF_NoTexture) + currentTexture = NULL; + else + HWD.pfnSetTexture(currentTexture); + + while (1)// note: remember handling notexture polyflag as having texture number 0 (also in comparePolygons) + { + int firstIndex; + int lastIndex; + boolean stopFlag = false; - unsigned int stateChanges = 0; // flags defined above HWR_MarkStateChanges - DrawCallInfo *currentDrawCall = &drawCalls[drawCallOrder[drawCallReadPos++]]; - DrawCallInfo *nextDrawCall = NULL; + boolean changeState = false; + boolean changeShader = false; + boolean changeTexture = false; + boolean changePolyFlags = false; + boolean changeSurfaceInfo = false; - HWR_CollectVerticesIntoBatch(currentDrawCall); + // steps: + // write vertices + // check for changes or end, otherwise go back to writing + // changes will affect the next vars and the change bools + // end could set flag for stopping + // execute draw call + // could check ending flag here + // change states according to next vars and change bools, updating the current vars and reseting the bools + // reset write pos + // repeat loop - if (drawCallReadPos >= drawCallsSize) // was that the last draw call? + int index = polygonIndexArray[polygonReadPos++]; + int numVerts = polygonArray[index].numVerts; + // before writing, check if there is enough room + // using 'while' instead of 'if' here makes sure that there will *always* be enough room. + // probably never will this loop run more than once though + 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; + // 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; + } + // write the vertices of the polygon + memcpy(&finalVertexArray[finalVertexWritePos], &unsortedVertexArray[polygonArray[index].vertsIndex], + numVerts * sizeof(FOutVector)); + // write the indexes, pointing to the fan vertexes but in triangles format + firstIndex = finalVertexWritePos; + lastIndex = finalVertexWritePos + numVerts; + finalVertexWritePos += 2; + while (finalVertexWritePos < lastIndex) + { + finalVertexIndexArray[finalIndexWritePos++] = firstIndex; + finalVertexIndexArray[finalIndexWritePos++] = finalVertexWritePos - 1; + finalVertexIndexArray[finalIndexWritePos++] = finalVertexWritePos++; + } + + if (polygonReadPos >= polygonArraySize) { stopFlag = true; } else { - nextDrawCall = &drawCalls[drawCallOrder[drawCallReadPos]]; - stateChanges = HWR_MarkStateChanges(currentDrawCall, nextDrawCall); + // check if a state change is required, set the change bools and next vars + int nextIndex = polygonIndexArray[polygonReadPos]; + nextShader = polygonArray[nextIndex].shader; + nextTexture = polygonArray[nextIndex].texture; + nextPolyFlags = polygonArray[nextIndex].polyFlags; + nextSurfaceInfo = polygonArray[nextIndex].surf; + if (nextPolyFlags & PF_NoTexture) + nextTexture = 0; + if (currentShader != nextShader && cv_grshaders.value && gr_shadersavailable) + { + changeState = true; + changeShader = true; + } + if (currentTexture != nextTexture) + { + changeState = true; + changeTexture = true; + } + if (currentPolyFlags != nextPolyFlags) + { + changeState = true; + changePolyFlags = true; + } + if ((cv_grshaders.value && gr_shadersavailable) && (HWR_ShouldUsePaletteRendering())) + { + if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba || + currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba || + currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba || + currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level || + currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start || + currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end || + currentSurfaceInfo.LightTableId != nextSurfaceInfo.LightTableId) + { + changeState = true; + changeSurfaceInfo = true; + } + } + else if (cv_grshaders.value && gr_shadersavailable) + { + if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba || + currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba || + currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba || + currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level || + currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start || + currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end) + { + changeState = true; + changeSurfaceInfo = true; + } + } + else + { + if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba) + { + changeState = true; + changeSurfaceInfo = true; + } + } } - if (stateChanges || stopFlag) + if (changeState || stopFlag) { - // execute combined draw call - HWD.pfnDrawIndexedTriangles(¤tDrawCall->surf, finalVertices, - finalIndicesSize, currentDrawCall->polyFlags, finalIndices); + // execute draw call + HWD.pfnDrawIndexedTriangles(¤tSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray); // update stats ps_hw_numcalls.value.i++; - ps_hw_numverts.value.i += finalIndicesSize; - // reset final geometry collection arrays - finalVerticesSize = 0; - finalIndicesSize = 0; + ps_hw_numverts.value.i += finalIndexWritePos; + // reset write positions + finalVertexWritePos = 0; + finalIndexWritePos = 0; } - else - continue; + else continue; // if we're here then either its time to stop or time to change state - if (stopFlag) - break; - else - HWR_ExecuteStateChanges(stateChanges, nextDrawCall); + if (stopFlag) break; + + // change state according to change bools and next vars, update current vars and reset bools + if (changeShader) + { + HWD.pfnSetShader(nextShader); + currentShader = nextShader; + changeShader = false; + + ps_hw_numshaders.value.i++; + } + if (changeTexture) + { + // texture should be already ready for use from calls to SetTexture during batch collection + HWD.pfnSetTexture(nextTexture); + currentTexture = nextTexture; + changeTexture = false; + + ps_hw_numtextures.value.i++; + } + if (changePolyFlags) + { + currentPolyFlags = nextPolyFlags; + changePolyFlags = false; + + ps_hw_numpolyflags.value.i++; + } + if (changeSurfaceInfo) + { + currentSurfaceInfo = nextSurfaceInfo; + changeSurfaceInfo = false; + + ps_hw_numcolors.value.i++; + } + // and that should be it? } // reset the arrays (set sizes to 0) - drawCallsSize = 0; - unsortedVerticesSize = 0; + polygonArraySize = 0; + unsortedVertexArraySize = 0; PS_STOP_TIMING(ps_hw_batchdrawtime); } + #endif // HWRENDER diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index b4e4bd9e3..bf0b7fc94 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -17,6 +17,18 @@ #include "hw_data.h" #include "hw_drv.h" +typedef struct +{ + FSurfaceInfo surf;// surf also has its own polyflags for some reason, but it seems unused + unsigned int vertsIndex;// location of verts in unsortedVertexArray + FUINT numVerts; + FBITFIELD polyFlags; + GLMipmap_t *texture; + int shader; + // this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls + boolean horizonSpecial; +} PolygonArrayEntry; + void HWR_StartBatching(void); void HWR_SetCurrentTexture(GLMipmap_t *texture); void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial); -- 2.54.0 From 6db95fc37b60a4ec47599aa9e3d87ecf478bf233 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 24 Feb 2024 16:56:28 +0100 Subject: [PATCH 29/70] fix conflict --- src/hardware/hw_batching.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index aa0e05375..85cd1c62e 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -115,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; + polygonArray[polygonArraySize].shader = (shader_target != -1) ? HWR_GetShaderFromTarget(shader_target) : shader_target; polygonArray[polygonArraySize].horizonSpecial = horizonSpecial; polygonArraySize++; -- 2.54.0 From 6b41cf676cc9f86776495367acf4fe100832a837 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 25 Feb 2024 19:42:21 +0100 Subject: [PATCH 30/70] connect loadingscreen should clear menus --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 248afd2f9..165d79942 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2581,7 +2581,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic // Call it only once by tic if (*oldtic != I_GetTime()) { - INT32 key; I_OsPolling(); @@ -2605,6 +2604,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic #ifdef CLIENT_LOADINGSCREEN if (client && cl_mode != CL_CONNECTED && cl_mode != CL_ABORTED) { + M_ClearMenus(false); F_TitleScreenTicker(true); F_TitleScreenDrawer(); CL_DrawConnectionStatus(); -- 2.54.0 From 612bde4e9a0ba4c5b7231bfb6a490a5b0b583aa1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 25 Feb 2024 19:47:52 +0100 Subject: [PATCH 31/70] dont quit addon downloading with the mousewheel lmao --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 165d79942..4e66872d9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2590,7 +2590,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic key = I_GetKey(); // Only ESC and non-keyboard keys abort connection - if (!modeattacking && (key == KEY_ESCAPE || key >= KEY_MOUSE1 || cl_mode == CL_ABORTED)) + if (!modeattacking && (key == KEY_ESCAPE || key == KEY_JOY1+1 || cl_mode == CL_ABORTED)) { CONS_Printf(M_GetText("Network game synchronization aborted.\n")); D_QuitNetGame(); -- 2.54.0 From 05195f4116ae196f0189bd62772ed61cfd1ac66d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 26 Feb 2024 01:29:31 +0100 Subject: [PATCH 32/70] Revert "connect loadingscreen should clear menus" This reverts commit 6b41cf676cc9f86776495367acf4fe100832a837. --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4e66872d9..1749d9aea 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2581,6 +2581,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic // Call it only once by tic if (*oldtic != I_GetTime()) { + INT32 key; I_OsPolling(); @@ -2604,7 +2605,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic #ifdef CLIENT_LOADINGSCREEN if (client && cl_mode != CL_CONNECTED && cl_mode != CL_ABORTED) { - M_ClearMenus(false); F_TitleScreenTicker(true); F_TitleScreenDrawer(); CL_DrawConnectionStatus(); -- 2.54.0 From 50023b0021043ae0c9c28abe060f69dae3ea2ba9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 26 Feb 2024 20:58:18 +0100 Subject: [PATCH 33/70] replace SCR_FPSflags with V_LocalTransFlag so we can actually display hud transparency stuff before the hud appears, since that doesent work with V_HUDTRANS --- src/screen.c | 16 +++------------- src/v_video.c | 6 ++++++ src/v_video.h | 2 ++ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/screen.c b/src/screen.c index d7aa1407e..9cebb5de9 100644 --- a/src/screen.c +++ b/src/screen.c @@ -70,8 +70,6 @@ consvar_t cv_shittyscreen = {"televisionsignal", "Okay", CV_NOSHOWHELP, shittysc static void SCR_ChangeFullscreen (void); -static INT32 SCR_FPSflags(void); - consvar_t cv_fullscreen = {"fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen, 0, NULL, NULL, 0, 0, NULL}; // ========================================================================= @@ -437,14 +435,6 @@ void SCR_CalculateFPS(void) #endif } -// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol -static INT32 SCR_FPSflags(void) -{ - if (!cv_translucenthud.value) return V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS; // eee kinda works ig - - return (((10-cv_translucenthud.value)*V_10TRANS) & V_ALPHAMASK) | V_SNAPTOBOTTOM|V_SNAPTORIGHT; -} - void SCR_DisplayTicRate(void) { const UINT8 *ticcntcolor = NULL; @@ -452,7 +442,7 @@ void SCR_DisplayTicRate(void) UINT32 benchmark = (cap == 0) ? I_GetRefreshRate() : cap; INT32 x = 318; double fps = round(averageFPS); - INT32 fpsflags = SCR_FPSflags(); + INT32 fpsflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; const char *fps_string; INT32 ticcntcolor2 = 0; @@ -520,12 +510,12 @@ void SCR_DisplayTicRate(void) void SCR_DisplayLocalPing(void) { UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P - INT32 fpsflags = SCR_FPSflags(); + INT32 pingflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain - HU_drawPing(308, dispy, ping, fpsflags); + HU_drawPing(308, dispy, ping, pingflags); } } diff --git a/src/v_video.c b/src/v_video.c index 0d0405208..db9b38081 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -477,6 +477,12 @@ static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0}; static UINT8 hudminusalpha[11] = { 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5}; UINT8 hudtrans = 0; +// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol +INT32 V_LocalTransFlag(void) +{ + return ((10-cv_translucenthud.value)*V_10TRANS); +} + static const UINT8 *v_colormap = NULL; static const UINT8 *v_translevel = NULL; diff --git a/src/v_video.h b/src/v_video.h index d65966731..bf98f6b11 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -61,6 +61,8 @@ extern RGBA_t *pLocalPalette; extern UINT8 hudtrans; +extern INT32 V_LocalTransFlag(void); + void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); // Retrieve the ARGB value from a palette color index -- 2.54.0 From 2d160cfc8936f6c09986fee6735aa2606328e7f7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Feb 2024 15:52:34 +0100 Subject: [PATCH 34/70] Toggle for R_Pointtoangle Ex or 64 Ex may perform better on 32bit clients and some cpus so lets just make it toggable --- src/hardware/hw_main.c | 37 +++++++++++++++++++++++++++++++------ src/m_menu.c | 5 +++++ src/r_bsp.c | 26 ++++++++++++++++++++++---- src/r_main.c | 33 ++++++++++++++++++++++++++++----- src/r_main.h | 1 + src/r_state.h | 2 ++ src/tables.h | 2 +- 7 files changed, 90 insertions(+), 16 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 19f63b6ef..e420119b3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2880,8 +2880,16 @@ void HWR_AddLine(seg_t *line) } // OPTIMIZE: quickly reject orthogonal back sides. - angle1 = R_PointToAngle64(v1x, v1y); - angle2 = R_PointToAngle64(v2x, v2y); + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(v1x, v1y); + angle2 = R_PointToAngle64(v2x, v2y); + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, v1x, v1y); + angle2 = R_PointToAngleEx(viewx, viewy, v2x, v2y); + } // do an extra culling check when rendering portals // check if any line vertex is on the viewable side of the portal target line @@ -3076,8 +3084,17 @@ boolean HWR_CheckBBox(fixed_t *bspcoord) if (mindist > current_bsp_culling_distance) return false; } - angle1 = R_PointToAngle64(px1, py1); - angle2 = R_PointToAngle64(px2, py2); + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(px1, py1); + angle2 = R_PointToAngle64(px2, py2); + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, px1, py1); + angle2 = R_PointToAngleEx(viewx, viewy, px2, py2); + } + return gld_clipper_SafeCheckRange(angle2, angle1); } @@ -5958,8 +5975,16 @@ static void HWR_PortalClipping(gl_portal_t *portal) line_t *line = &lines[portal->clipline]; - angle1 = R_PointToAngle64(line->v1->x, line->v1->y); - angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(line->v1->x, line->v1->y); + angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, line->v1->x, line->v1->y); + angle2 = R_PointToAngleEx(viewx, viewy, line->v2->x, line->v2->y); + } // clip things that are not inside the portal window from our viewpoint gld_clipper_SafeAddClipRange(angle2, angle1); diff --git a/src/m_menu.c b/src/m_menu.c index 44d87ba59..4886f788d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1413,6 +1413,8 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 75}, + {IT_STRING | IT_CVAR, NULL, "Clipping R_PointToAngle Version", &cv_pointoangleexor64, 85}, + {IT_STRING | IT_CVAR, NULL, "FFloorclip", &cv_ffloorclip, 95}, {IT_STRING | IT_CVAR, NULL, "Spriteclip", &cv_spriteclip, 105}, #ifdef HWRENDER @@ -1424,6 +1426,7 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Slope midtexture peg fix", &cv_slopepegfix, 135}, {IT_STRING | IT_CVAR, NULL, "ZFighting fix for fofs", &cv_fofzfightfix, 145}, {IT_STRING | IT_CVAR, NULL, "FOF wall cutoff for slopes", &cv_grfofcut, 155}, + #endif }; @@ -1435,6 +1438,7 @@ static const char* OP_ExpTooltips[] = "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", "When weather is on this will cut the object amount used in half.", "Show a VHS-like effect when the game is paused\n or youre rewinding replays.", + "Which version of R_PointToAngle should\nbe used for Sector Clipping?\n64 may fix rendering issues on larger maps\nat the cost of performance.", "Hides 3DFloors which are not visible\npotentially resulting in a performance boost.", "Hides Sprites which are not visible\npotentially resulting in a performance boost.", #ifdef HWRENDER @@ -1455,6 +1459,7 @@ enum op_exp_precipinter, op_exp_lessprecip, op_exp_vhs, + op_exp_angleshit, op_exp_ffclip, op_exp_sprclip, #ifdef HWRENDER diff --git a/src/r_bsp.c b/src/r_bsp.c index 2de30d2ab..e0b8039af 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -410,8 +410,18 @@ static void R_AddLine(seg_t *line) return; // big room fix - angle1 = R_PointToAngle64(line->v1->x, line->v1->y); - angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(line->v1->x, line->v1->y); + angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, line->v1->x, line->v1->y); + angle2 = R_PointToAngleEx(viewx, viewy, line->v2->x, line->v2->y); + } + curline = line; // Clip to view edges. @@ -613,8 +623,16 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) check = checkcoord[boxpos]; // big room fix - angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; - angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; + if (cv_pointoangleexor64.value) + { + angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; + angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; + } + else + { + angle1 = R_PointToAngleEx(viewx, viewy, bspcoord[check[0]], bspcoord[check[1]]) - viewangle; + angle2 = R_PointToAngleEx(viewx, viewy, bspcoord[check[2]], bspcoord[check[3]]) - viewangle; + } if ((signed)angle1 < (signed)angle2) { diff --git a/src/r_main.c b/src/r_main.c index ec1cd0bf9..8a975498d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -145,8 +145,6 @@ static CV_PossibleValue_t drawdist_cons_t[] = { {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -//static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}}; - static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, @@ -161,7 +159,6 @@ static CV_PossibleValue_t maxinterpdist_cons_t[] = { static CV_PossibleValue_t fov_cons_t[] = {{5*FRACUNIT, "MIN"}, {178*FRACUNIT, "MAX"}, {0, NULL}}; -//static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}}; static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; static CV_PossibleValue_t maxportals_cons_t[] = {{0, "MIN"}, {12, "MAX"}, {0, NULL}}; // lmao rendering 32 portals, you're a card static CV_PossibleValue_t homremoval_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Flash"}, {0, NULL}}; @@ -202,10 +199,8 @@ consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_c consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -//consvar_t cv_drawdist_nights = {"drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -//consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -217,6 +212,9 @@ consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t pointoangle_cons_t[] = {{0, "Ex"}, {1, "64"}, {0, NULL}}; +consvar_t cv_pointoangleexor64 = {"r_pointtoangle", "Ex", CV_SAVE, pointoangle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + void SplitScreen_OnChange(void) { UINT8 i; @@ -420,6 +418,29 @@ angle_t R_PointToAngle64(INT64 x, INT64 y) 0; } +angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1) +{ + INT64 dx = x1-x2; + INT64 dy = y1-y2; + if (dx < INT32_MIN || dx > INT32_MAX || dy < INT32_MIN || dy > INT32_MAX) + { + x1 = (int)(dx / 2 + x2); + y1 = (int)(dy / 2 + y2); + } + return (y1 -= y2, (x1 -= x2) || y1) ? + x1 >= 0 ? + y1 >= 0 ? + (x1 > y1) ? tantoangle[SlopeDivEx(y1,x1)] : // octant 0 + ANGLE_90-tantoangle[SlopeDivEx(x1,y1)] : // octant 1 + x1 > (y1 = -y1) ? 0-tantoangle[SlopeDivEx(y1,x1)] : // octant 8 + ANGLE_270+tantoangle[SlopeDivEx(x1,y1)] : // octant 7 + y1 >= 0 ? (x1 = -x1) > y1 ? ANGLE_180-tantoangle[SlopeDivEx(y1,x1)] : // octant 3 + ANGLE_90 + tantoangle[SlopeDivEx(x1,y1)] : // octant 2 + (x1 = -x1) > (y1 = -y1) ? ANGLE_180+tantoangle[SlopeDivEx(y1,x1)] : // octant 4 + ANGLE_270-tantoangle[SlopeDivEx(x1,y1)] : // octant 5 + 0; +} + angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) { return (y -= pviewy, (x -= pviewx) || y) ? @@ -1869,6 +1890,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_translucenthud); CV_RegisterVar(&cv_maxportals); + + CV_RegisterVar(&cv_pointoangleexor64); CV_RegisterVar(&cv_grmaxinterpdist); diff --git a/src/r_main.h b/src/r_main.h index 4767c38ea..63c7c3ab5 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -69,6 +69,7 @@ INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *node); INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line); angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); +angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1); angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); fixed_t R_PointToDist(fixed_t x, fixed_t y); fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); diff --git a/src/r_state.h b/src/r_state.h index e37bdf52e..670f800d1 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -102,6 +102,8 @@ extern INT32 portalclipstart, portalclipend; extern consvar_t cv_allowmlook; extern consvar_t cv_maxportals; +extern consvar_t cv_pointoangleexor64; + extern angle_t clipangle; extern angle_t doubleclipangle; diff --git a/src/tables.h b/src/tables.h index beea392ec..353bf591f 100644 --- a/src/tables.h +++ b/src/tables.h @@ -86,7 +86,7 @@ extern angle_t tantoangle[SLOPERANGE+1]; // Utility function, called by R_PointToAngle. FUNCMATH unsigned SlopeDiv(unsigned num, unsigned den); // Only called by R_PointToAngleEx -UINT64 SlopeDivEx(unsigned int num, unsigned int den); +FUNCMATH UINT64 SlopeDivEx(unsigned int num, unsigned int den); // 360 - angle_t(ANGLE_45) = ANGLE_315 FUNCMATH FUNCINLINE static ATTRINLINE angle_t InvAngle(angle_t a) -- 2.54.0 From 20bd4a8599e9a8159cd2957584c6c621b8bf62d2 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:37:22 +0100 Subject: [PATCH 35/70] Don't return aggregates --- src/k_kart.c | 42 ++++++++++++++++++++---------------------- src/k_kart.h | 6 +++--- src/lua_hudlib.c | 6 +++--- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 40d519025..82228dd9e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7567,10 +7567,9 @@ INT32 K_calcSplitFlags(INT32 snapflags) return (splitflags|snapflags); } -drawinfo_t K_getItemBoxDrawinfo(void) +void K_getItemBoxDrawinfo(drawinfo_t *out) { INT32 fx, fy, fflags; - drawinfo_t info; // pain and suffering defined below if (splitscreen < 2) // don't change shit for THIS splitscreen. @@ -7595,16 +7594,14 @@ drawinfo_t K_getItemBoxDrawinfo(void) } } - info.x = fx; - info.y = fy; - info.flags = fflags; - return info; + out->x = fx; + out->y = fy; + out->flags = fflags; } -drawinfo_t K_getLapsDrawinfo(void) +void K_getLapsDrawinfo(drawinfo_t *out) { INT32 fx, fy, fflags; - drawinfo_t info; // pain and suffering defined below if (splitscreen < 2) // don't change shit for THIS splitscreen. @@ -7629,21 +7626,18 @@ drawinfo_t K_getLapsDrawinfo(void) } } - info.x = fx; - info.y = fy; - info.flags = fflags; - return info; + out->x = fx; + out->y = fy; + out->flags = fflags; } -drawinfo_t K_getMinimapDrawinfo(void) +void K_getMinimapDrawinfo(drawinfo_t *out) { INT32 fx = MINI_X, fy = MINI_Y, fflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) - drawinfo_t info; - info.x = fx; - info.y = fy; - info.flags = fflags; - return info; + out->x = fx; + out->y = fy; + out->flags = fflags; } patch_t *K_getItemBoxPatch(boolean small, boolean dark) @@ -8018,7 +8012,8 @@ static void K_drawKartItem(void) } localbg = K_getItemBoxPatch((boolean)offset, dark); - drawinfo_t info = K_getItemBoxDrawinfo(); + drawinfo_t info; + K_getItemBoxDrawinfo(&info); fx = info.x; fy = info.y; fflags = info.flags; @@ -8642,7 +8637,8 @@ static void K_drawKartLaps(void) boolean flipstring = splitscreen > 1 && stplyrnum & 1; // used for 3p or 4p INT32 stringw = 0; // used with the above - drawinfo_t info = K_getLapsDrawinfo(); + drawinfo_t info; + K_getLapsDrawinfo(&info); fx = info.x; fy = info.y; fflags = info.flags; @@ -8845,7 +8841,8 @@ static void K_drawKartBumpersOrKarma(void) boolean flipstring = splitscreen > 1 && stplyrnum & 1; // same as laps, used for splitscreen INT32 stringw = 0; // used with the above - drawinfo_t info = K_getLapsDrawinfo(); + drawinfo_t info; + K_getLapsDrawinfo(&info); fx = info.x; fy = info.y; fflags = info.flags; @@ -9171,7 +9168,8 @@ static void K_drawKartMinimap(void) else return; // no pic, just get outta here - drawinfo_t info = K_getMinimapDrawinfo(); + drawinfo_t info; + K_getMinimapDrawinfo(&info); x = info.x - (AutomapPic->width/2); y = info.y - (AutomapPic->height/2); splitflags = info.flags; diff --git a/src/k_kart.h b/src/k_kart.h index 861d00991..cb9b9eced 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -106,9 +106,9 @@ typedef struct patch_t *K_getItemBoxPatch(boolean small, boolean dark); patch_t *K_getItemMulPatch(boolean small); -drawinfo_t K_getItemBoxDrawinfo(void); -drawinfo_t K_getLapsDrawinfo(void); -drawinfo_t K_getMinimapDrawinfo(void); +void K_getItemBoxDrawinfo(drawinfo_t *out); +void K_getLapsDrawinfo(drawinfo_t *out); +void K_getMinimapDrawinfo(drawinfo_t *out); // ========================================================================= #endif // __K_KART__ diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e0b742094..d58360186 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1164,9 +1164,9 @@ static int libd_getDrawInfo(lua_State *L) drawinfo_t info; switch(option) { - case huddrawinfo_item: info = K_getItemBoxDrawinfo(); break; - case huddrawinfo_gametypeinfo: info = K_getLapsDrawinfo(); break; - case huddrawinfo_minimap: info = K_getMinimapDrawinfo(); break; + case huddrawinfo_item: K_getItemBoxDrawinfo(&info); break; + case huddrawinfo_gametypeinfo: K_getLapsDrawinfo(&info); break; + case huddrawinfo_minimap: K_getMinimapDrawinfo(&info); break; default: return 0; // unreachable } -- 2.54.0 From 3a423981174aab1263ea52d3457a2b441c1c1ff3 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Feb 2024 20:05:09 +0100 Subject: [PATCH 36/70] wtf even --- src/hardware/hw_batching.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 85cd1c62e..2a59530b4 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -383,21 +383,7 @@ void HWR_RenderBatches(void) changeState = true; changePolyFlags = true; } - if ((cv_grshaders.value && gr_shadersavailable) && (HWR_ShouldUsePaletteRendering())) - { - if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba || - currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba || - currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba || - currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level || - currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start || - currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end || - currentSurfaceInfo.LightTableId != nextSurfaceInfo.LightTableId) - { - changeState = true; - changeSurfaceInfo = true; - } - } - else if (cv_grshaders.value && gr_shadersavailable) + if (cv_grshaders.value && gr_shadersavailable) { if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba || currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba || -- 2.54.0 From 253a7c3ee590eeb149c26343e8eca0cf309c1aee Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Feb 2024 20:09:53 +0100 Subject: [PATCH 37/70] some stuff i forgor --- src/hardware/hw_cache.c | 10 +++++++--- src/hardware/hw_drv.h | 2 +- src/hardware/hw_main.c | 5 ++--- src/hardware/hw_main.h | 2 +- src/hardware/hw_shaders.h | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c32870fed..1fdd88ad3 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -502,6 +502,9 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch) // Set the first colormap to the one that comes after it. next = pat->mipmap->nextcolormap; + if (!next) + break; + pat->mipmap->nextcolormap = next->nextcolormap; // Free image data from memory. @@ -646,6 +649,9 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) { GLMipmap_t *grmip; + + if (flatlumpnum == LUMPERROR) + return; grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap; @@ -662,7 +668,6 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grmip->downloaded) HWD.pfnSetTexture(grmip); - HWR_SetCurrentTexture(grmip); // The system-memory data can be purged now. @@ -1085,8 +1090,7 @@ UINT32 HWR_GetLightTableID(extracolormap_t *colormap) // call become invalid and must not be used. void HWR_ClearLightTables(void) { - //if (vid.glstate == VID_GL_LIBRARY_LOADED) // we have pfnInit which is essentially the same, but it doesent work here for whatever reason, since this should not be done in software renderer ever! - if (rendermode == render_opengl) + if (vid.glstate == VID_GL_LIBRARY_LOADED) HWD.pfnClearLightTables(); } diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index df4d431f9..7d58dc495 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -59,7 +59,7 @@ EXPORT void HWRAPI(FlushScreenTextures) (void); EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd); EXPORT void HWRAPI(DrawScreenTexture) (int tex, FSurfaceInfo *surf, FBITFIELD polyflags); EXPORT void HWRAPI(MakeScreenTexture) (int tex); -EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, int width, int height); +EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, INT32 width, INT32 height); EXPORT void HWRAPI(RenderVhsEffect) (fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e420119b3..2ca8f2a79 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -161,7 +161,6 @@ consvar_t cv_grfakecontrast = {"gr_fakecontrast", "Standard", CV_SAVE, grfakecon consvar_t cv_grslopecontrast = {"gr_slopecontrast", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grhorizonlines = {"gr_horizonlines", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - #define ONLY_IF_GL_LOADED if (vid.glstate != VID_GL_LIBRARY_LOADED) return; @@ -2669,7 +2668,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 = (UINT8)rover->alpha-1 > 255 ? 255 : rover->alpha-1; + Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); } if (gr_backsector->numlights) @@ -6699,7 +6698,7 @@ void HWR_MakeScreenFinalTexture(void) HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); } -void HWR_DrawScreenFinalTexture(int width, int height) +void HWR_DrawScreenFinalTexture(INT32 width, INT32 height) { HWD.pfnDrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height); } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 4725c720b..018f1bfbd 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -115,7 +115,7 @@ void HWR_DrawIntermissionBG(void); void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum); void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); void HWR_MakeScreenFinalTexture(void); -void HWR_DrawScreenFinalTexture(int width, int height); +void HWR_DrawScreenFinalTexture(INT32 width, INT32 height); // hw_main.c: Planes void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index eb705c34c..efd908226 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -76,7 +76,7 @@ #define GLSL_SOFTWARE_TINT_EQUATION \ "if (tint_color.a > 0.0) {\n" \ "float color_bright = sqrt((base_color.r * base_color.r) + (base_color.g * base_color.g) + (base_color.b * base_color.b));\n" \ - "float strength = sqrt(9.0 * tint_color.a);\n" \ + "float strength = sqrt(tint_color.a);\n" \ "final_color.r = clamp((color_bright * (tint_color.r * strength)) + (base_color.r * (1.0 - strength)), 0.0, 1.0);\n" \ "final_color.g = clamp((color_bright * (tint_color.g * strength)) + (base_color.g * (1.0 - strength)), 0.0, 1.0);\n" \ "final_color.b = clamp((color_bright * (tint_color.b * strength)) + (base_color.b * (1.0 - strength)), 0.0, 1.0);\n" \ -- 2.54.0 From 69fe26847be2e18c9f167d092aaf99b35dd1941f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Feb 2024 05:07:11 +0100 Subject: [PATCH 38/70] Fix con_hudlines being off by one, Fix con_hudtime overflow --- src/console.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/console.c b/src/console.c index 73eac9ff9..1327e561f 100644 --- a/src/console.c +++ b/src/console.c @@ -66,8 +66,8 @@ static INT32 con_curlines; // vid lines currently used by console INT32 con_clipviewtop; // (useless) -static INT32 con_hudlines; // number of console heads up message lines -static INT32 con_hudtime[MAXHUDLINES]; // remaining time of display for hud msg lines +static UINT8 con_hudlines; // number of console heads up message lines +static UINT32 con_hudtime[MAXHUDLINES]; // remaining time of display for hud msg lines INT32 con_clearlines; // top screen lines to refresh when view reduced boolean con_hudupdate; // when messages scroll, we need a backgrnd refresh @@ -117,11 +117,13 @@ static void CONS_backcolor_Change(void); static char con_buffer[CON_BUFFERSIZE]; -// how many seconds the hud messages lasts on the screen -static consvar_t cons_msgtimeout = {"con_hudtime", "5", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +// CV_Unsigned can overflow when multiplied by TICRATE later, so let's use a 3-year limit instead +static CV_PossibleValue_t hudtime_cons_t[] = {{0, "MIN"}, {99999999, "MAX"}, {0, NULL}}; +static consvar_t cons_hudtime = {"con_hudtime", "5", CV_SAVE, hudtime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // number of lines displayed on the HUD -static consvar_t cons_hudlines = {"con_hudlines", "5", CV_CALL|CV_SAVE, CV_Unsigned, CONS_hudlines_Change, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t hudlines_cons_t[] = {{0, "MIN"}, {MAXHUDLINES, "MAX"}, {0, NULL}}; +static consvar_t cons_hudlines = {"con_hudlines", "5", CV_CALL|CV_SAVE, hudlines_cons_t, CONS_hudlines_Change, 0, NULL, NULL, 0, 0, NULL}; // number of lines console move per frame // (con_speed needs a limit, apparently) @@ -181,11 +183,6 @@ static void CONS_hudlines_Change(void) for (i = 0; i < con_hudlines; i++) con_hudtime[i] = 0; - if (cons_hudlines.value < 1) - cons_hudlines.value = 1; - else if (cons_hudlines.value > MAXHUDLINES) - cons_hudlines.value = MAXHUDLINES; - con_hudlines = cons_hudlines.value; Unlock_state(); @@ -426,7 +423,7 @@ void CON_Init(void) Unlock_state(); - CV_RegisterVar(&cons_msgtimeout); + CV_RegisterVar(&cons_hudtime); CV_RegisterVar(&cons_hudlines); CV_RegisterVar(&cons_speed); CV_RegisterVar(&cons_height); @@ -743,9 +740,8 @@ void CON_Ticker(void) // make overlay messages disappear after a while for (i = 0; i < con_hudlines; i++) { - con_hudtime[i]--; - if (con_hudtime[i] < 0) - con_hudtime[i] = 0; + if (con_hudtime[i]) + con_hudtime[i]--; } Unlock_state(); @@ -1244,7 +1240,8 @@ boolean CON_Responder(event_t *ev) static void CON_Linefeed(void) { // set time for heads up messages - con_hudtime[con_cy%con_hudlines] = cons_msgtimeout.value*TICRATE; + if (con_hudlines) + con_hudtime[con_cy%con_hudlines] = cons_hudtime.value*TICRATE; con_cy++; con_cx = 0; @@ -1600,7 +1597,7 @@ static void CON_DrawHudlines(void) INT32 charwidth = 8 * con_scalefactor; INT32 charheight = 8 * con_scalefactor; - if (con_hudlines <= 0) + if (!con_hudlines) return; if (chat_on && OLDCHAT) @@ -1608,7 +1605,7 @@ static void CON_DrawHudlines(void) else y = 0; - for (i = con_cy - con_hudlines+1; i <= con_cy; i++) + for (i = con_cy - con_hudlines; i <= con_cy; i++) { size_t c; INT32 x; -- 2.54.0 From 1e232eec3b7798e8108fe9266b38fe741b5bd4ac Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Feb 2024 21:49:31 +0100 Subject: [PATCH 39/70] delete half of srb2 --- src/p_user.c | 3953 +------------------------------------------------- 1 file changed, 5 insertions(+), 3948 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index b8b1bfe0d..5be9f9a7d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2250,142 +2250,6 @@ static void P_CheckQuicksand(player_t *player) } } -// -// P_CheckSneakerAndLivesTimer -// -// Restores music from sneaker and life fanfares -// -/* // SRB2kart - Can't drown. -static void P_CheckSneakerAndLivesTimer(player_t *player) -{ - if ((player->powers[pw_underwater] <= 11*TICRATE + 1) - && (player->powers[pw_underwater] > 1)) - return; // don't restore music if drowning music is playing - - if (player->powers[pw_extralife] == 1) // Extra Life! - P_RestoreMusic(player); - - //if (player->powers[pw_sneakers] == 1) // SRB2kart - // P_RestoreMusic(player); -} -*/ - -// -// P_CheckUnderwaterAndSpaceTimer -// -// Restores music from underwater and space warnings, and handles number generation -// -/* // SRB2kart - Can't drown. -static void P_CheckUnderwaterAndSpaceTimer(player_t *player) -{ - fixed_t height; - mobj_t *numbermobj = NULL; - - if (player->mo->eflags & MFE_VERTICALFLIP) - height = player->mo->z - FixedMul(8*FRACUNIT - mobjinfo[MT_DROWNNUMBERS].height, player->mo->scale); - else - height = player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, player->mo->scale); - - if (player->powers[pw_underwater] == 11*TICRATE + 1 || player->powers[pw_spacetime] == 11*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+5); - } - else if (player->powers[pw_underwater] == 9*TICRATE + 1 || player->powers[pw_spacetime] == 9*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+4); - } - else if (player->powers[pw_underwater] == 7*TICRATE + 1 || player->powers[pw_spacetime] == 7*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+3); - } - else if (player->powers[pw_underwater] == 5*TICRATE + 1 || player->powers[pw_spacetime] == 5*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+2); - } - else if (player->powers[pw_underwater] == 3*TICRATE + 1 || player->powers[pw_spacetime] == 3*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+1); - } - else if (player->powers[pw_underwater] == 1*TICRATE + 1 || player->powers[pw_spacetime] == 1*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - //P_SetMobjState(numbermobj, numbermobj->info->spawnstate+0); - } - // Underwater timer runs out - else if (player->powers[pw_underwater] == 1) - { - mobj_t *killer; - - if ((netgame || multiplayer) && P_IsLocalPlayer(player)) - S_ChangeMusic(mapmusname, mapmusflags, true); - - killer = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_NULL); - killer->threshold = 42; // Special flag that it was drowning which killed you. - P_DamageMobj(player->mo, killer, killer, 10000); - } - else if (player->powers[pw_spacetime] == 1) - { - if ((netgame || multiplayer) && P_IsLocalPlayer(player)) - S_ChangeMusic(mapmusname, mapmusflags, true); - - P_DamageMobj(player->mo, NULL, NULL, 10000); - } - - if (numbermobj) - { - P_SetTarget(&numbermobj->target, player->mo); - numbermobj->threshold = 40; - S_StartSound(player->mo, sfx_dwnind); - numbermobj->destscale = player->mo->scale; - P_SetScale(numbermobj, player->mo->scale); - } - - if (!(player->mo->eflags & MFE_UNDERWATER) && player->powers[pw_underwater]) - { - if (player->powers[pw_underwater] <= 12*TICRATE + 1) - P_RestoreMusic(player); - - player->powers[pw_underwater] = 0; - } - - if (player->powers[pw_spacetime] > 1 && !P_InSpaceSector(player->mo)) - { - P_RestoreMusic(player); - player->powers[pw_spacetime] = 0; - } - - // Underwater audio cues - if (P_IsLocalPlayer(player) && !player->bot) - { - if (player->powers[pw_underwater] == 11*TICRATE + 1 - && player == &players[consoleplayer]) - { - S_StopMusic(); - S_ChangeMusicInternal("drown", false); - } - - if (player->powers[pw_underwater] == 25*TICRATE + 1) - S_StartSound(NULL, sfx_wtrdng); - else if (player->powers[pw_underwater] == 20*TICRATE + 1) - S_StartSound(NULL, sfx_wtrdng); - else if (player->powers[pw_underwater] == 15*TICRATE + 1) - S_StartSound(NULL, sfx_wtrdng); - } - - if (player->exiting) - { - if (player->powers[pw_underwater] > 1) - player->powers[pw_underwater] = 0; - - player->powers[pw_spacetime] = 0; - } -}*/ - // // P_CheckInvincibilityTimer // @@ -2396,44 +2260,24 @@ static void P_CheckInvincibilityTimer(player_t *player) if (!player->powers[pw_invulnerability] && !player->kartstuff[k_invincibilitytimer]) return; - //if (mariomode && !player->powers[pw_super]) // SRB2kart { player->mo->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); } - /*if (leveltime % (TICRATE/7) == 0) - { - mobj_t *sparkle = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_IVSP); - sparkle->destscale = player->mo->scale; - P_SetScale(sparkle, player->mo->scale); - }*/ // Resume normal music stuff. if (player->powers[pw_invulnerability] == 1 || player->kartstuff[k_invincibilitytimer] == 1) { if (!player->powers[pw_super]) { - //if (mariomode) { - //if (player->powers[pw_shield] & SH_FIREFLOWER) - //{ - // player->mo->color = SKINCOLOR_WHITE; - // G_GhostAddColor((INT32) (player - players), GHC_FIREFLOWER); - //} - //else - { - player->mo->color = player->skincolor; - G_GhostAddColor((INT32) (player - players), GHC_NORMAL); - } + player->mo->color = player->skincolor; + G_GhostAddColor((INT32) (player - players), GHC_NORMAL); } // If you had a shield, restore its visual significance P_SpawnShieldOrb(player); } - /*if ((player->powers[pw_underwater] <= 11*TICRATE + 1) - && (player->powers[pw_underwater] > 1)) - return; // don't restore music if drowning music is playing - if (!player->powers[pw_super] || (mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC))*/ P_RestoreMusic(player); } @@ -2470,35 +2314,6 @@ static void P_DoBubbleBreath(player_t *player) if (player->pflags & PF_NIGHTSMODE) // NiGHTS Super doesn't spawn flight bubbles return; - - // Tails stirs up the water while flying in it - /*if (player->powers[pw_tailsfly] && (leveltime & 1) && player->charability != CA_SWIM) - { - fixed_t radius = (3*player->mo->radius)>>1; - angle_t fa = ((leveltime%45)*FINEANGLES/8) & FINEMASK; - fixed_t stirwaterx = FixedMul(FINECOSINE(fa),radius); - fixed_t stirwatery = FixedMul(FINESINE(fa),radius); - fixed_t stirwaterz; - - if (player->mo->eflags & MFE_VERTICALFLIP) - stirwaterz = player->mo->z + player->mo->height - FixedDiv(player->mo->height,3*FRACUNIT/2); - else - stirwaterz = player->mo->z + FixedDiv(player->mo->height,3*FRACUNIT/2); - - bubble = P_SpawnMobj( - player->mo->x + stirwaterx, - player->mo->y + stirwatery, - stirwaterz, MT_SMALLBUBBLE); - bubble->destscale = player->mo->scale; - P_SetScale(bubble,bubble->destscale); - - bubble = P_SpawnMobj( - player->mo->x - stirwaterx, - player->mo->y - stirwatery, - stirwaterz, MT_SMALLBUBBLE); - bubble->destscale = player->mo->scale; - P_SetScale(bubble,bubble->destscale); - }*/ } // @@ -2553,1160 +2368,6 @@ static void P_DoPlayerHeadSigns(player_t *player) } } -// -// P_DoClimbing -// -// Handles player climbing -// -/* -static void P_DoClimbing(player_t *player) // SRB2kart - unused -{ - return; // SRB2kart - don't need - ticcmd_t *cmd = &player->cmd; - fixed_t platx; - fixed_t platy; - subsector_t *glidesector; - //boolean climb = true; // SRB2kart - unused - - platx = P_ReturnThrustX(player->mo, player->mo->angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); - platy = P_ReturnThrustY(player->mo, player->mo->angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); - - glidesector = R_IsPointInSubsector(player->mo->x + platx, player->mo->y + platy); - - if (!glidesector || glidesector->sector != player->mo->subsector->sector) - { - boolean floorclimb = false; - //boolean thrust = false; // SRB2kart - unused - //boolean boostup = false; // SRB2kart - unused - //boolean skyclimber = false; // SRB2kart - unused - fixed_t floorheight, ceilingheight; // ESLOPE - - if (!glidesector) - floorclimb = true; - else - { - floorheight = glidesector->sector->f_slope ? P_GetZAt(glidesector->sector->f_slope, player->mo->x, player->mo->y) - : glidesector->sector->floorheight; - ceilingheight = glidesector->sector->c_slope ? P_GetZAt(glidesector->sector->c_slope, player->mo->x, player->mo->y) - : glidesector->sector->ceilingheight; - - if (glidesector->sector->ffloors) - { - ffloor_t *rover; - fixed_t topheight, bottomheight; // ESLOPE - - for (rover = glidesector->sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; - - floorclimb = true; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - // Only supports rovers that are moving like an 'elevator', not just the top or bottom. - if (rover->master->frontsector->floorspeed && rover->master->frontsector->ceilspeed == 42) - { - if ((!(player->mo->eflags & MFE_VERTICALFLIP) && (bottomheight < player->mo->z+player->mo->height) - && (topheight >= player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale))) - || ((player->mo->eflags & MFE_VERTICALFLIP) && (topheight > player->mo->z) - && (bottomheight <= player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)))) - { - if (cmd->forwardmove != 0) - player->mo->momz += rover->master->frontsector->floorspeed; - else - { - player->mo->momz = rover->master->frontsector->floorspeed; - climb = false; - } - } - } - - // Gravity is flipped, so the comments are, too. - if (player->mo->eflags & MFE_VERTICALFLIP) - { - // Trying to climb down past the bottom of the FOF - if ((topheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= topheight)) - { - fixed_t bottomheight2; - ffloor_t *roverbelow; - boolean foundfof = false; - floorclimb = true; - boostup = false; - - // Is there a FOF directly below this one that we can move onto? - for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) - { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || (roverbelow->flags & FF_BUSTUP)) - continue; - - if (roverbelow == rover) - continue; - - bottomheight2 = *roverbelow->b_slope ? P_GetZAt(*roverbelow->b_slope, player->mo->x, player->mo->y) : *roverbelow->bottomheight; - - if (bottomheight2 < topheight + FixedMul(16*FRACUNIT, player->mo->scale)) - foundfof = true; - } - - if (!foundfof) - player->mo->momz = 0; - } - - // Below the FOF - if (topheight <= player->mo->z) - { - floorclimb = false; - boostup = false; - thrust = false; - } - - // Above the FOF - if (bottomheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale)) - { - floorclimb = false; - thrust = true; - boostup = true; - } - } - else - { - // Trying to climb down past the bottom of a FOF - if ((bottomheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= bottomheight)) - { - fixed_t topheight2; - ffloor_t *roverbelow; - boolean foundfof = false; - floorclimb = true; - boostup = false; - - // Is there a FOF directly below this one that we can move onto? - for (roverbelow = glidesector->sector->ffloors; roverbelow; roverbelow = roverbelow->next) - { - if (!(roverbelow->flags & FF_EXISTS) || !(roverbelow->flags & FF_BLOCKPLAYER) || (roverbelow->flags & FF_BUSTUP)) - continue; - - if (roverbelow == rover) - continue; - - topheight2 = *roverbelow->t_slope ? P_GetZAt(*roverbelow->t_slope, player->mo->x, player->mo->y) : *roverbelow->topheight; - - if (topheight2 > bottomheight - FixedMul(16*FRACUNIT, player->mo->scale)) - foundfof = true; - } - - if (!foundfof) - player->mo->momz = 0; - } - - // Below the FOF - if (bottomheight >= player->mo->z + player->mo->height) - { - floorclimb = false; - boostup = false; - thrust = false; - } - - // Above the FOF - if (topheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale)) - { - floorclimb = false; - thrust = true; - boostup = true; - } - } - - if (floorclimb) - { - if (rover->flags & FF_CRUMBLE && !(netgame && player->spectator)) - EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), player, rover->alpha, !(rover->flags & FF_NORETURN)); - break; - } - } - } - - // Gravity is flipped, so are comments. - if (player->mo->eflags & MFE_VERTICALFLIP) - { - // Trying to climb down past the upper texture area - if ((floorheight >= player->mo->z + player->mo->height) && ((player->mo->z + player->mo->height + player->mo->momz) >= floorheight)) - { - boolean foundfof = false; - floorclimb = true; - - // Is there a FOF directly below that we can move onto? - if (glidesector->sector->ffloors) - { - fixed_t bottomheight; - ffloor_t *rover; - for (rover = glidesector->sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; - - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - if (bottomheight < floorheight + FixedMul(16*FRACUNIT, player->mo->scale)) - { - foundfof = true; - break; - } - } - } - - if (!foundfof) - player->mo->momz = 0; - } - - // Reached the top of the lower texture area - if (!floorclimb && ceilingheight > player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) - && (glidesector->sector->ceilingpic == skyflatnum || floorheight < (player->mo->z - FixedMul(8*FRACUNIT, player->mo->scale)))) - { - thrust = true; - boostup = true; - // Play climb-up animation here - } - } - else - { - // Trying to climb down past the upper texture area - if ((ceilingheight <= player->mo->z) && ((player->mo->z + player->mo->momz) <= ceilingheight)) - { - boolean foundfof = false; - floorclimb = true; - - // Is there a FOF directly below that we can move onto? - if (glidesector->sector->ffloors) - { - fixed_t topheight; - ffloor_t *rover; - for (rover = glidesector->sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - - if (topheight > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) - { - foundfof = true; - break; - } - } - } - - if (!foundfof) - player->mo->momz = 0; - } - - // Allow climbing from a FOF or lower texture onto the upper texture and vice versa. - if (player->mo->z > ceilingheight - FixedMul(16*FRACUNIT, player->mo->scale)) - { - floorclimb = true; - thrust = false; - boostup = false; - } - - // Reached the top of the lower texture area - if (!floorclimb && floorheight < player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) - && (glidesector->sector->ceilingpic == skyflatnum || ceilingheight > (player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, player->mo->scale)))) - { - thrust = true; - boostup = true; - // Play climb-up animation here - } - } - - // Trying to climb on the sky - if ((ceilingheight < player->mo->z) && glidesector->sector->ceilingpic == skyflatnum) - { - skyclimber = true; - } - - // Climbing on the lower texture area? - if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + FixedMul(16*FRACUNIT, player->mo->scale) < floorheight) - || ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height <= floorheight)) - { - floorclimb = true; - - if (glidesector->sector->floorspeed) - { - if (cmd->forwardmove != 0) - player->mo->momz += glidesector->sector->floorspeed; - else - { - player->mo->momz = glidesector->sector->floorspeed; - climb = false; - } - } - } - // Climbing on the upper texture area? - else if ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z >= ceilingheight) - || ((player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height - FixedMul(16*FRACUNIT, player->mo->scale) > ceilingheight)) - { - floorclimb = true; - - if (glidesector->sector->ceilspeed) - { - if (cmd->forwardmove != 0) - player->mo->momz += glidesector->sector->ceilspeed; - else - { - player->mo->momz = glidesector->sector->ceilspeed; - climb = false; - } - } - } - } - - if (player->lastsidehit != -1 && player->lastlinehit != -1) - { - thinker_t *think; - scroll_t *scroller; - angle_t sideangle; - fixed_t dx, dy; - - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function.acp1 != (actionf_p1)T_Scroll) - continue; - - scroller = (scroll_t *)think; - - if (scroller->type != sc_side) - continue; - - if (scroller->affectee != player->lastsidehit) - continue; - - if (scroller->accel) - { - dx = scroller->vdx; - dy = scroller->vdy; - } - else - { - dx = scroller->dx; - dy = scroller->dy; - } - - if (cmd->forwardmove != 0) - { - player->mo->momz += dy; - climb = true; - } - else - { - player->mo->momz = dy; - climb = false; - } - - sideangle = R_PointToAngle2(lines[player->lastlinehit].v2->x,lines[player->lastlinehit].v2->y,lines[player->lastlinehit].v1->x,lines[player->lastlinehit].v1->y); - - if (cmd->sidemove != 0) - { - P_Thrust(player->mo, sideangle, dx); - climb = true; - } - else - { - P_InstaThrust(player->mo, sideangle, dx); - climb = false; - } - } - } - - if (cmd->sidemove != 0 || cmd->forwardmove != 0) - climb = true; - else - climb = false; - - if (player->climbing && climb && (player->mo->momx || player->mo->momy || player->mo->momz) - && !(player->mo->state >= &states[S_PLAY_CLIMB2] && player->mo->state <= &states[S_PLAY_CLIMB5])) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB2); - else if ((!(player->mo->momx || player->mo->momy || player->mo->momz) || !climb) && player->mo->state != &states[S_PLAY_CLIMB1]) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB1); - - if (!floorclimb) - { - if (boostup) - P_SetObjectMomZ(player->mo, 2*FRACUNIT, true); - if (thrust) - P_InstaThrust(player->mo, player->mo->angle, FixedMul(4*FRACUNIT, player->mo->scale)); // Lil' boost up. - - player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - - if (skyclimber) - { - player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - } - else - { - player->climbing = 0; - player->pflags |= PF_JUMPED; - //P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - - if (cmd->sidemove != 0 || cmd->forwardmove != 0) - climb = true; - else - climb = false; - - if (player->climbing && climb && (player->mo->momx || player->mo->momy || player->mo->momz) - && !(player->mo->state >= &states[S_PLAY_CLIMB2] && player->mo->state <= &states[S_PLAY_CLIMB5])) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB2); - else if ((!(player->mo->momx || player->mo->momy || player->mo->momz) || !climb) && player->mo->state != &states[S_PLAY_CLIMB1]) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB1); - - if (cmd->buttons & BT_BRAKE && !(player->pflags & PF_JUMPSTASIS)) - { - player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - P_SetObjectMomZ(player->mo, 4*FRACUNIT, false); - P_InstaThrust(player->mo, player->mo->angle, FixedMul(-4*FRACUNIT, player->mo->scale)); - } - - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - - if (player->climbing == 0) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - - - if (player->climbing && P_IsObjectOnGround(player->mo)) - { - P_ResetPlayer(player); - P_SetPlayerMobjState(player->mo, S_KART_STND1); // SRB2kart - } -} - -// -// PIT_CheckSolidsTeeter -// AKA: PIT_HacksToStopPlayersTeeteringOnGargoyles -// - -static mobj_t *teeterer; // the player checking for teetering -static boolean solidteeter; // saves whether the player can teeter on this or not -static fixed_t highesttop; // highest floor found so far -// reserved for standing on multiple objects -static boolean couldteeter; -static fixed_t teeterxl, teeterxh; -static fixed_t teeteryl, teeteryh; - -static boolean PIT_CheckSolidsTeeter(mobj_t *thing) // SRB2kart - unused. -{ - fixed_t blockdist; - fixed_t tiptop = FixedMul(MAXSTEPMOVE, mapobjectscale); - fixed_t thingtop = thing->z + thing->height; - fixed_t teeterertop = teeterer->z + teeterer->height; - - if (!teeterer || !thing) - return true; - - if (!(thing->flags & MF_SOLID)) - return true; - - if (thing->flags & MF_NOCLIP) - return true; - - if (thing == teeterer) - return true; - - if (thing->player && cv_tailspickup.value && gametype != GT_HIDEANDSEEK) - return true; - - blockdist = teeterer->radius + thing->radius; - - if (abs(thing->x - teeterer->x) >= blockdist || abs(thing->y - teeterer->y) >= blockdist) - return true; // didn't hit it - - if (teeterer->eflags & MFE_VERTICALFLIP) - { - if (thingtop < teeterer->z) - return true; - if (thing->z > highesttop) - return true; - highesttop = thing->z; - if (thing->z > teeterertop + tiptop) - { - solidteeter = true; - return true; - } - } - else - { - if (thing->z > teeterertop) - return true; - if (thingtop < highesttop) - return true; - highesttop = thingtop; - if (thingtop < teeterer->z - tiptop) - { - solidteeter = true; - return true; - } - } - - // are you standing on this? - if ((teeterer->eflags & MFE_VERTICALFLIP && thing->z - FixedMul(FRACUNIT, teeterer->scale) == teeterertop) - || (!(teeterer->eflags & MFE_VERTICALFLIP) && thingtop + FixedMul(FRACUNIT, teeterer->scale) == teeterer->z)) - { - fixed_t teeterdist = thing->radius - FixedMul(5*FRACUNIT, teeterer->scale); - // how far are you from the edge? - if (abs(teeterer->x - thing->x) > teeterdist || abs(teeterer->y - thing->y) > teeterdist) - { - if (couldteeter) // player is standing on another object already, see if we can stand on both and not teeter! - { - if (thing->x - teeterdist < teeterxl) - teeterxl = thing->x - teeterdist; - if (thing->x + teeterdist > teeterxh) - teeterxh = thing->x + teeterdist; - if (thing->y - teeterdist < teeteryl) - teeteryl = thing->y - teeterdist; - if (thing->y + teeterdist > teeteryh) - teeteryh = thing->y + teeterdist; - - if (teeterer->x < teeterxl) - return true; - if (teeterer->x > teeterxh) - return true; - if (teeterer->y < teeteryl) - return true; - if (teeterer->y > teeteryh) - return true; - - solidteeter = false; // you can stop teetering now! - couldteeter = false; // just in case... - return false; - } - else - { - // too far! don't change teeter status though - // save teeter x/y limits to bring up later - teeterxl = thing->x - teeterdist; - teeterxh = thing->x + teeterdist; - teeteryl = thing->y - teeterdist; - teeteryh = thing->y + teeterdist; - } - couldteeter = true; - return true; - } - solidteeter = false; - couldteeter = false; - return false; // you're definitely not teetering, that's the end of the matter - } - solidteeter = false; - return true; // you're not teetering but it's not neccessarily over, YET -} -*/ - -// -// P_DoTeeter -// -// Handles player teetering -// -/* -static void P_DoTeeter(player_t *player) // SRB2kart - unused. -{ - return; // SRB2kart - don't need - boolean teeter = false; - boolean roverfloor; // solid 3d floors? - fixed_t floorheight, ceilingheight; - fixed_t topheight, bottomheight; // for 3d floor usage - const fixed_t tiptop = FixedMul(MAXSTEPMOVE, mapobjectscale); // Distance you have to be above the ground in order to teeter. - - if (player->mo->standingslope && player->mo->standingslope->zdelta >= (FRACUNIT/2)) // Always teeter if the slope is too steep. - teeter = true; - else // Let's do some checks... - { - UINT8 i; - sector_t *sec; - fixed_t highestceilingheight = INT32_MIN; - fixed_t lowestfloorheight = INT32_MAX; - - teeter = false; - roverfloor = false; - for (i = 0; i < 4; i++) - { - ffloor_t *rover; - -#define xsign ((i & 1) ? -1 : 1) // 0 -> 1 | 1 -> -1 | 2 -> 1 | 3 -> -1 -#define ysign ((i & 2) ? 1 : -1) // 0 -> 1 | 1 -> 1 | 2 -> -1 | 3 -> -1 - fixed_t checkx = player->mo->x + (xsign*FixedMul(5*FRACUNIT, player->mo->scale)); - fixed_t checky = player->mo->y + (ysign*FixedMul(5*FRACUNIT, player->mo->scale)); -#undef xsign -#undef ysign - - sec = R_PointInSubsector(checkx, checky)->sector; - - ceilingheight = sec->ceilingheight; - floorheight = sec->floorheight; - if (sec->c_slope) - ceilingheight = P_GetZAt(sec->c_slope, checkx, checky); - if (sec->f_slope) - floorheight = P_GetZAt(sec->f_slope, checkx, checky); - highestceilingheight = (ceilingheight > highestceilingheight) ? ceilingheight : highestceilingheight; - lowestfloorheight = (floorheight < lowestfloorheight) ? floorheight : lowestfloorheight; - - if (!(sec->ffloors)) - continue; // move on to the next subsector - - for (rover = sec->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) continue; - - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; - - if (P_CheckSolidLava(player->mo, rover)) - ; - else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) - continue; // intangible 3d floor - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (bottomheight > ceilingheight) // Above the ceiling - continue; - - if (bottomheight > player->mo->z + player->mo->height + tiptop - || (topheight < player->mo->z - && player->mo->z + player->mo->height < ceilingheight - tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - else - { - if (topheight < floorheight) // Below the floor - continue; - - if (topheight < player->mo->z - tiptop - || (bottomheight > player->mo->z + player->mo->height - && player->mo->z > floorheight + tiptop)) - { - teeter = true; - roverfloor = true; - } - else - { - teeter = false; - roverfloor = true; - break; - } - } - } - break; // break out of loop now, we're done - } - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (!teeter && !roverfloor && (highestceilingheight > player->mo->ceilingz + tiptop)) - teeter = true; - } - else - { - if (!teeter && !roverfloor && (lowestfloorheight < player->mo->floorz - tiptop)) - teeter = true; - } - } - - { - INT32 bx, by, xl, xh, yl, yh; - - yh = (unsigned)(player->mo->y + player->mo->radius - bmaporgy)>>MAPBLOCKSHIFT; - yl = (unsigned)(player->mo->y - player->mo->radius - bmaporgy)>>MAPBLOCKSHIFT; - xh = (unsigned)(player->mo->x + player->mo->radius - bmaporgx)>>MAPBLOCKSHIFT; - xl = (unsigned)(player->mo->x - player->mo->radius - bmaporgx)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - // Polyobjects - validcount++; - - for (by = yl; by <= yh; by++) - for (bx = xl; bx <= xh; bx++) - { - INT32 offset; - polymaplink_t *plink; // haleyjd 02/22/06 - - if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) - continue; - - offset = by*bmapwidth + bx; - - // haleyjd 02/22/06: consider polyobject lines - plink = polyblocklinks[offset]; - - while (plink) - { - polyobj_t *po = plink->po; - - if (po->validcount != validcount) // if polyobj hasn't been checked - { - sector_t *polysec; - fixed_t polytop, polybottom; - - po->validcount = validcount; - - if (!(po->flags & POF_SOLID)) - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - if (!P_MobjInsidePolyobj(po, player->mo)) - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - // We're inside it! Yess... - polysec = po->lines[0]->backsector; - - if (po->flags & POF_CLIPPLANES) - { - polytop = polysec->ceilingheight; - polybottom = polysec->floorheight; - } - else - { - polytop = INT32_MAX; - polybottom = INT32_MIN; - } - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (polybottom > player->mo->ceilingz) // Above the ceiling - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - if (polybottom > player->mo->z + player->mo->height + tiptop - || (polytop < player->mo->z - && player->mo->z + player->mo->height < player->mo->ceilingz - tiptop)) - teeter = true; - else - { - teeter = false; - break; - } - } - else - { - if (polytop < player->mo->floorz) // Below the floor - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - if (polytop < player->mo->z - tiptop - || (polybottom > player->mo->z + player->mo->height - && player->mo->z > player->mo->floorz + tiptop)) - teeter = true; - else - { - teeter = false; - break; - } - } - } - plink = (polymaplink_t *)(plink->link.next); - } - } - if (teeter) // only bother with objects as a last resort if you were already teetering - { - mobj_t *oldtmthing = tmthing; - tmthing = teeterer = player->mo; - teeterxl = teeterxh = player->mo->x; - teeteryl = teeteryh = player->mo->y; - couldteeter = false; - solidteeter = teeter; - for (by = yl; by <= yh; by++) - for (bx = xl; bx <= xh; bx++) - { - highesttop = INT32_MIN; - if (!P_BlockThingsIterator(bx, by, PIT_CheckSolidsTeeter)) - goto teeterdone; // we've found something that stops us teetering at all, how about we stop already - } -teeterdone: - teeter = solidteeter; - tmthing = oldtmthing; // restore old tmthing, goodness knows what the game does with this before mobj thinkers - } - } - if (teeter) - { - if ((player->mo->state == &states[S_PLAY_STND] || player->mo->state == &states[S_PLAY_TAP1] || player->mo->state == &states[S_PLAY_TAP2] || player->mo->state == &states[S_PLAY_SUPERSTAND])) - P_SetPlayerMobjState(player->mo, S_PLAY_TEETER1); - } - else if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) - P_SetPlayerMobjState(player->mo, S_PLAY_STND); -} -*/ - -// -// P_SetWeaponDelay -// -// Sets weapon delay. Properly accounts for Knux's firing rate bonus. -// -/* -static void P_SetWeaponDelay(player_t *player, INT32 delay) // SRB2kart - unused. -{ - player->weapondelay = delay; - - if (player->skin == 2) // Knuckles - { - // Multiply before dividing. - // Loss of precision can make a surprisingly large difference. - player->weapondelay *= 2; - player->weapondelay /= 3; - } -} - -// -// P_DoFiring() -// -// Handles firing ring weapons and Mario fireballs. -// -static void P_DoFiring(player_t *player, ticcmd_t *cmd) // SRB2kart - unused. -{ - INT32 i; - - I_Assert(player != NULL); - I_Assert(!P_MobjWasRemoved(player->mo)); - - if (cmd->buttons & BT_ATTACK) - { - if (!(player->pflags & PF_ATTACKDOWN) && player->powers[pw_shield] & SH_FIREFLOWER && !player->climbing) - { - player->pflags |= PF_ATTACKDOWN; - P_SpawnPlayerMissile(player->mo, MT_FIREBALL, 0); - S_StartSound(player->mo, sfx_mario7); - } - else if (G_BattleGametype() && (!G_TagGametype() || player->pflags & PF_TAGIT) - && !player->weapondelay && !player->climbing - && !(player->pflags & PF_ATTACKDOWN)) - { - mobj_t *mo = NULL; - player->pflags |= PF_ATTACKDOWN; - - //if (cmd->buttons & BT_FIRENORMAL) // No powers, just a regular ring. - // goto firenormal; //code repetition sucks. - // Bounce ring - if (player->currentweapon == WEP_BOUNCE && player->powers[pw_bouncering]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, TICRATE/4); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNBOUNCE, MF2_BOUNCERING); - - if (mo) - mo->fuse = 3*TICRATE; // Bounce Ring time - - player->powers[pw_bouncering]--; - player->mo->health--; - player->health--; - } - // Rail ring - else if (player->currentweapon == WEP_RAIL && player->powers[pw_railring]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, (3*TICRATE)/2); - - mo = P_SpawnPlayerMissile(player->mo, MT_REDRING, MF2_RAILRING|MF2_DONTDRAW); - - // Rail has no unique thrown object, therefore its sound plays here. - S_StartSound(player->mo, sfx_rail1); - - player->powers[pw_railring]--; - player->mo->health--; - player->health--; - } - // Automatic - else if (player->currentweapon == WEP_AUTO && player->powers[pw_automaticring]) - { - if (player->health <= 1) - return; - player->pflags &= ~PF_ATTACKDOWN; - P_SetWeaponDelay(player, 2); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNAUTOMATIC, MF2_AUTOMATIC); - - player->powers[pw_automaticring]--; - player->mo->health--; - player->health--; - } - // Explosion - else if (player->currentweapon == WEP_EXPLODE && player->powers[pw_explosionring]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, (3*TICRATE)/2); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNEXPLOSION, MF2_EXPLOSION); - - player->powers[pw_explosionring]--; - player->mo->health--; - player->health--; - } - // Grenade - else if (player->currentweapon == WEP_GRENADE && player->powers[pw_grenadering]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, TICRATE/3); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNGRENADE, MF2_EXPLOSION); - - if (mo) - { - //P_InstaThrust(mo, player->mo->angle, FixedMul(mo->info->speed, player->mo->scale)); - mo->fuse = mo->info->mass; - } - - player->powers[pw_grenadering]--; - player->mo->health--; - player->health--; - } - // Scatter - // Note: Ignores MF2_RAILRING - else if (player->currentweapon == WEP_SCATTER && player->powers[pw_scatterring]) - { - fixed_t oldz = player->mo->z; - angle_t shotangle = player->mo->angle; - angle_t oldaiming = player->aiming; - - if (player->health <= 1) - return; - P_SetWeaponDelay(player, (2*TICRATE)/3); - - // Center - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNSCATTER, MF2_SCATTER); - if (mo) - shotangle = R_PointToAngle2(player->mo->x, player->mo->y, mo->x, mo->y); - - // Left - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle-ANG2, true, MF2_SCATTER); - - // Right - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle+ANG2, true, MF2_SCATTER); - - // Down - player->mo->z += FixedMul(12*FRACUNIT, player->mo->scale); - player->aiming += ANG1; - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle, true, MF2_SCATTER); - - // Up - player->mo->z -= FixedMul(24*FRACUNIT, player->mo->scale); - player->aiming -= ANG2; - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle, true, MF2_SCATTER); - - player->mo->z = oldz; - player->aiming = oldaiming; - - player->powers[pw_scatterring]--; - player->mo->health--; - player->health--; - return; - } - // No powers, just a regular ring. - else - { -//firenormal: - // Infinity ring was selected. - // Mystic wants this ONLY to happen specifically if it's selected, - // and to not be able to get around it EITHER WAY with firenormal. - - // Infinity Ring - if (player->currentweapon == 0 - && player->powers[pw_infinityring]) - { - P_SetWeaponDelay(player, TICRATE/4); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNINFINITY, 0); - - player->powers[pw_infinityring]--; - } - // Red Ring - else - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, TICRATE/4); - - mo = P_SpawnPlayerMissile(player->mo, MT_REDRING, 0); - - if (mo) - P_ColorTeamMissile(mo, player); - - player->mo->health--; - player->health--; - } - } - - if (mo) - { - if (mo->flags & MF_MISSILE && mo->flags2 & MF2_RAILRING) - { - const boolean nblockmap = !(mo->flags & MF_NOBLOCKMAP); - for (i = 0; i < 256; i++) - { - if (nblockmap) - { - P_UnsetThingPosition(mo); - mo->flags |= MF_NOBLOCKMAP; - P_SetThingPosition(mo); - } - - if (i&1) - P_SpawnMobj(mo->x, mo->y, mo->z, MT_SPARK); - - if (P_RailThinker(mo)) - break; // mobj was removed (missile hit a wall) or couldn't move - } - - // Other rail sound plays at contact point. - S_StartSound(mo, sfx_rail2); - } - } - } - return; - } - - // Not holding any firing buttons anymore. - // Release the grenade / whatever. - player->pflags &= ~PF_ATTACKDOWN; -} -*/ - -// -// P_DoSpinDash -// -// Player spindash handling -// -/* -static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) // SRB2kart - unused. -{ - return; // SRB2kart - what's a spindash? - if (player->pflags & PF_STASIS) - return; - -#ifdef HAVE_BLUA - if (cmd->buttons & BT_BRAKE) - { - if (LUAh_SpinSpecial(player)) - return; - } -#endif - - // Spinning and Spindashing - if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SLIDING) && !player->exiting - && !P_PlayerInPain(player)) // subsequent revs - { - if ((cmd->buttons & BT_BRAKE) && player->speed < FixedMul(5<mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING) - && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) - ) - { - player->mo->momx = player->cmomx; - player->mo->momy = player->cmomy; - player->pflags |= PF_STARTDASH|PF_SPINNING; - player->dashspeed = FixedMul(FRACUNIT, player->mo->scale); - player->dashtime = 0; - //P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - player->pflags |= PF_USEDOWN; - } - else if ((cmd->buttons & BT_BRAKE) && (player->pflags & PF_STARTDASH)) - { - player->dashspeed += FixedMul(FRACUNIT, player->mo->scale); - - if (!(player->dashtime++ % 5)) - { - if (!player->spectator && player->dashspeed < FixedMul(player->maxdash, player->mo->scale)) - S_StartSound(player->mo, sfx_spndsh); // Make the rev sound! - - // Now spawn the color thok circle. - P_SpawnSpinMobj(player, player->revitem); - if (demo.recording) - G_GhostAddRev((INT32) (player - players)); - } - } - // If not moving up or down, and travelling faster than a speed of four while not holding - // down the spin button and not spinning. - // AKA Just go into a spin on the ground, you idiot. ;) - else if ((cmd->buttons & BT_BRAKE || ((twodlevel || (player->mo->flags2 & MF2_TWOD)) && cmd->forwardmove < -20)) - && !player->climbing && !player->mo->momz && onground && (player->speed > FixedMul(5<mo->scale) - || (player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) - ) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING)) - { - player->pflags |= PF_SPINNING; - //P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - if (!player->spectator) - S_StartSound(player->mo, sfx_spin); - player->pflags |= PF_USEDOWN; - } - } - - // Rolling normally - if (onground && player->pflags & PF_SPINNING && !(player->pflags & PF_STARTDASH) - && player->speed < FixedMul(5*FRACUNIT,player->mo->scale) - && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) - ) - { - if (GETSECSPECIAL(player->mo->subsector->sector->special, 4) == 7 || (player->mo->ceilingz - player->mo->floorz < P_GetPlayerHeight(player))) - P_InstaThrust(player->mo, player->mo->angle, FixedMul(10*FRACUNIT, player->mo->scale)); - else - { - player->skidtime = 0; - player->pflags &= ~PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_KART_STND1); - player->mo->momx = player->cmomx; - player->mo->momy = player->cmomy; - } - } - - // Catapult the player from a spindash rev! - if (onground && !(player->pflags & PF_USEDOWN) && player->dashspeed && (player->pflags & PF_STARTDASH) && (player->pflags & PF_SPINNING)) - { - if (player->powers[pw_ingoop]) - player->dashspeed = 0; - - player->pflags &= ~PF_STARTDASH; - if (!((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE)) - { - P_InstaThrust(player->mo, player->mo->angle, player->dashspeed); // catapult forward ho!! - if (!player->spectator) - S_StartSound(player->mo, sfx_zoom); - } - player->dashspeed = 0; - } - - //if (onground && (player->pflags & PF_SPINNING) && !(player->panim == PA_ROLL)) - // P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); -} -*/ // // P_DoJumpShield @@ -3786,266 +2447,6 @@ boolean P_AnalogMove(player_t *player) return player->pflags & PF_ANALOGMODE; } -// -// P_GetPlayerControlDirection -// -// Determines if the player is pressing in the direction they are moving -// -// 0 = no controls pressed/no movement -// 1 = pressing in the direction of movement -// 2 = pressing in the opposite direction of movement -// -/*INT32 P_GetPlayerControlDirection(player_t *player) -{ - ticcmd_t *cmd = &player->cmd; - angle_t controllerdirection, controlplayerdirection; - camera_t *thiscam; - angle_t dangle; - fixed_t tempx = 0, tempy = 0; - angle_t tempangle, origtempangle; - - if (splitscreen > 2 && player == &players[displayplayers[3]]) - thiscam = &camera[3]; - else if (splitscreen > 1 && player == &players[displayplayers[2]]) - thiscam = &camera[2]; - else if (splitscreen && player == &players[displayplayers[1]]) - thiscam = &camera[1]; - else - thiscam = &camera[0]; - - if (!cmd->forwardmove && !cmd->sidemove) - return 0; - - if (!player->mo->momx && !player->mo->momy) - return 0; - - if (twodlevel || player->mo->flags2 & MF2_TWOD) - { - if (!cmd->sidemove) - return 0; - if (!player->mo->momx) - return 0; - origtempangle = tempangle = 0; // relative to the axis rather than the player! - controlplayerdirection = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - } - else if (P_AnalogMove(player) && thiscam->chase) - { - if (player->awayviewtics) - origtempangle = tempangle = player->awayviewmobj->angle; - else - origtempangle = tempangle = thiscam->angle; - controlplayerdirection = player->mo->angle; - } - else - { - origtempangle = tempangle = player->mo->angle; - controlplayerdirection = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - } - - // Calculate the angle at which the controls are pointing - // to figure out the proper mforward and mbackward. - tempangle >>= ANGLETOFINESHIFT; - if (!(twodlevel || player->mo->flags2 & MF2_TWOD)) // in 2d mode, sidemove is treated as the forwards/backwards direction - { - tempx += FixedMul(cmd->forwardmove*FRACUNIT,FINECOSINE(tempangle)); - tempy += FixedMul(cmd->forwardmove*FRACUNIT,FINESINE(tempangle)); - - tempangle = origtempangle-ANGLE_90; - tempangle >>= ANGLETOFINESHIFT; - } - tempx += FixedMul(cmd->sidemove*FRACUNIT,FINECOSINE(tempangle)); - tempy += FixedMul(cmd->sidemove*FRACUNIT,FINESINE(tempangle)); - - controllerdirection = R_PointToAngle2(0, 0, tempx, tempy); - - dangle = controllerdirection - controlplayerdirection; - - if (dangle > ANGLE_180) //flip to keep to one side - dangle = InvAngle(dangle); - - if (dangle > ANGLE_90) - return 2; // Controls pointing backwards from player - else - return 1; // Controls pointing in player's general direction -} - -// Control scheme for 2d levels. -static void P_2dMovement(player_t *player) -{ - ticcmd_t *cmd; - INT32 topspeed, acceleration, thrustfactor; - fixed_t movepushforward = 0; - angle_t movepushangle = 0; - fixed_t normalspd = FixedMul(player->normalspeed, player->mo->scale); - - cmd = &player->cmd; - - if (player->exiting || player->pflags & PF_STASIS) - { - cmd->forwardmove = cmd->sidemove = 0; - if (player->pflags & PF_GLIDING) - { - if (!player->skidtime) - player->pflags &= ~PF_GLIDING; - else if (player->exiting) - { - player->pflags &= ~PF_GLIDING; - P_SetPlayerMobjState(player->mo, S_KART_WALK1); // SRB2kart - was S_PLAY_RUN1 - player->skidtime = 0; - } - } - if (player->pflags & PF_SPINNING && !player->exiting) - { - player->pflags &= ~PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND - } - } - - // cmomx/cmomy stands for the conveyor belt speed. - if (player->onconveyor == 2) // Wind/Current - { - //if (player->mo->z > player->mo->watertop || player->mo->z + player->mo->height < player->mo->waterbottom) - if (!(player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) - player->cmomx = player->cmomy = 0; - } - else if (player->onconveyor == 4 && !P_IsObjectOnGround(player->mo)) // Actual conveyor belt - player->cmomx = player->cmomy = 0; - else if (player->onconveyor != 2 && player->onconveyor != 4 - && player->onconveyor != 1 - ) - player->cmomx = player->cmomy = 0; - - player->rmomx = player->mo->momx - player->cmomx; - player->rmomy = player->mo->momy - player->cmomy; - - // Calculates player's speed based on absolute-value-of-a-number formula - player->speed = abs(player->rmomx); - - if (player->pflags & PF_GLIDING) - { - // Angle fix. - if (player->mo->angle < ANGLE_180 && player->mo->angle > ANGLE_90) - player->mo->angle = ANGLE_180; - else if (player->mo->angle < ANGLE_90 && player->mo->angle > 0) - player->mo->angle = 0; - - if (cmd->sidemove > 0 && player->mo->angle != 0 && player->mo->angle >= ANGLE_180) - player->mo->angle += 1280<sidemove < 0 && player->mo->angle != ANGLE_180 && (player->mo->angle > ANGLE_180 || player->mo->angle == 0)) - player->mo->angle -= 1280<sidemove == 0) - { - if (player->mo->angle >= ANGLE_270) - player->mo->angle += 1280<mo->angle < ANGLE_270 && player->mo->angle > ANGLE_180) - player->mo->angle -= 1280<sidemove && !(player->climbing) && !P_PlayerInPain(player)) - { - if (cmd->sidemove > 0) - player->mo->angle = 0; - else if (cmd->sidemove < 0) - player->mo->angle = ANGLE_180; - } - - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - - if (player->pflags & PF_GLIDING) - movepushangle = player->mo->angle; - else - { - if (cmd->sidemove > 0) - movepushangle = 0; - else if (cmd->sidemove < 0) - movepushangle = ANGLE_180; - else - movepushangle = player->mo->angle; - } - - // Do not let the player control movement if not onground. - onground = P_IsObjectOnGround(player->mo); - - player->aiming = cmd->aiming<powers[pw_super] || player->powers[pw_sneakers]) - { - thrustfactor = player->thrustfactor*2; - acceleration = player->accelstart/2 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration/2; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER) && !(player->pflags & PF_SLIDING)) - { - topspeed = normalspd; - acceleration = 2*acceleration/3; - } - else - topspeed = normalspd * 2; - } - else - { - thrustfactor = player->thrustfactor; - acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd/2; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER) && !(player->pflags & PF_SLIDING)) - { - topspeed = normalspd/2; - acceleration = 2*acceleration/3; - } - else - topspeed = normalspd; - } - -////////////////////////////////////// - if (player->climbing) - { - if (cmd->forwardmove != 0) - P_SetObjectMomZ(player->mo, FixedDiv(cmd->forwardmove*FRACUNIT,10*FRACUNIT), false); - - if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - player->mo->momz *= 2; - - player->mo->momx = 0; - } - else if (cmd->sidemove != 0 && !(player->pflags & PF_GLIDING || player->exiting - || (P_PlayerInPain(player) && !onground))) - { - movepushforward = abs(cmd->sidemove) * (thrustfactor * acceleration); - - // allow very small movement while in air for gameplay - if (!onground) - movepushforward >>= 1; // Proper air movement - - // Allow a bit of movement while spinning - if (player->pflags & PF_SPINNING) - { - if (!(player->pflags & PF_STARTDASH)) - movepushforward = movepushforward/48; - else - movepushforward = 0; - } - - movepushforward = FixedMul(movepushforward, player->mo->scale); - if (player->rmomx < topspeed && cmd->sidemove > 0) // Sonic's Speed - P_Thrust(player->mo, movepushangle, movepushforward); - else if (player->rmomx > -topspeed && cmd->sidemove < 0) - P_Thrust(player->mo, movepushangle, movepushforward); - } -}*/ //#define OLD_MOVEMENT_CODE 1 static void P_3dMovement(player_t *player) @@ -4302,1291 +2703,6 @@ static void P_SpectatorMovement(player_t *player) }*/ } -// -// P_ShootLine -// -// Fun and fancy -// graphical indicator -// for building/debugging -// NiGHTS levels! -/*static void P_ShootLine(mobj_t *source, mobj_t *dest, fixed_t height) -{ - mobj_t *mo; - INT32 i; - fixed_t temp; - INT32 speed, seesound; - - temp = dest->z; - dest->z = height; - - seesound = mobjinfo[MT_REDRING].seesound; - speed = mobjinfo[MT_REDRING].speed; - mobjinfo[MT_REDRING].seesound = sfx_None; - mobjinfo[MT_REDRING].speed = 20*FRACUNIT; - - mo = P_SpawnXYZMissile(source, dest, MT_REDRING, source->x, source->y, height); - - dest->z = temp; - if (mo) - { - mo->flags2 |= MF2_RAILRING; - mo->flags2 |= MF2_DONTDRAW; - mo->flags |= MF_NOCLIPHEIGHT; - mo->flags |= MF_NOCLIP; - mo->flags &= ~MF_MISSILE; - mo->fuse = 3; - } - - for (i = 0; i < 32; i++) - { - if (mo) - { - if (!(mo->flags & MF_NOBLOCKMAP)) - { - P_UnsetThingPosition(mo); - mo->flags |= MF_NOBLOCKMAP; - P_SetThingPosition(mo); - } - if (i&1) - P_SpawnMobj(mo->x, mo->y, mo->z, MT_SPARK); - - P_UnsetThingPosition(mo); - mo->x += mo->momx; - mo->y += mo->momy; - mo->z += mo->momz; - P_SetThingPosition(mo); - } - else - { - mobjinfo[MT_REDRING].seesound = seesound; - mobjinfo[MT_REDRING].speed = speed; - return; - } - } - mobjinfo[MT_REDRING].seesound = seesound; - mobjinfo[MT_REDRING].speed = speed; -} - -#define MAXDRILLSPEED 14000 -#define MAXNORMALSPEED 6250 //6000 - -static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t radius) -{ - if (player->pflags & PF_TRANSFERTOCLOSEST) - { - const angle_t fa = R_PointToAngle2(player->axis1->x, player->axis1->y, player->axis2->x, player->axis2->y); - P_InstaThrust(player->mo, fa, xspeed/10); - } - else - { - const angle_t fa = player->angle_pos>>ANGLETOFINESHIFT; - const angle_t faold = player->old_angle_pos>>ANGLETOFINESHIFT; - player->mo->momx = FixedMul(FINECOSINE(fa),radius) - FixedMul(FINECOSINE(faold),radius); - player->mo->momy = FixedMul(FINESINE(fa),radius) - FixedMul(FINESINE(faold),radius); - } - - if (player->exiting) - return; - - // You're welcome, Rob. (Now with slightly less horrendous hacking -Red - player->mo->tracer->flags &= ~MF_NOCLIP; - player->mo->tracer->z = player->mo->z; - if (!P_TryMove(player->mo->tracer, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, true)) { - player->mo->tracer->flags |= MF_NOCLIP; - return; - } - player->mo->tracer->flags |= MF_NOCLIP; - { - const INT32 sequence = player->mo->target->threshold; - mobj_t *transfer1 = NULL; - mobj_t *transfer2 = NULL; - mobj_t *axis; - mobj_t *mo2; - thinker_t *th; - line_t transfer1line; - line_t transfer2line; - boolean transfer1last = false; - boolean transfer2last = false; - vertex_t vertices[4]; - fixed_t truexspeed = xspeed*(!(player->pflags & PF_TRANSFERTOCLOSEST) && player->mo->target->flags2 & MF2_AMBUSH ? -1 : 1); - - // Find next waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - // Axis things are only at beginning of list. - if (!(mo2->flags2 & MF2_AXIS)) - break; - - if ((mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE) - && mo2->threshold == sequence) - { - if (player->pflags & PF_TRANSFERTOCLOSEST) - { - if (mo2->health == player->axis1->health) - transfer1 = mo2; - else if (mo2->health == player->axis2->health) - transfer2 = mo2; - } - else - { - if (mo2->health == player->mo->target->health) - transfer1 = mo2; - else if (mo2->health == player->mo->target->health + 1) - transfer2 = mo2; - } - } - } - - // It might be possible that one wasn't found. - // Is it because we're at the end of the track? - // Look for a wrapper point. - if (!transfer1) - { - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - // Axis things are only at beginning of list. - if (!(mo2->flags2 & MF2_AXIS)) - break; - - if (mo2->threshold == sequence && (mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE)) - { - if (!transfer1) - { - transfer1 = mo2; - transfer1last = true; - } - else if (mo2->health > transfer1->health) - { - transfer1 = mo2; - transfer1last = true; - } - } - } - } - if (!transfer2) - { - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - // Axis things are only at beginning of list. - if (!(mo2->flags2 & MF2_AXIS)) - break; - - if (mo2->threshold == sequence && (mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE)) - { - if (!transfer2) - { - transfer2 = mo2; - transfer2last = true; - } - else if (mo2->health > transfer2->health) - { - transfer2 = mo2; - transfer2last = true; - } - } - } - } - - if (!(transfer1 && transfer2)) // We can't continue... - I_Error("Mare does not form a complete circuit!\n"); - - transfer1line.v1 = &vertices[0]; - transfer1line.v2 = &vertices[1]; - transfer2line.v1 = &vertices[2]; - transfer2line.v2 = &vertices[3]; - - if (cv_debug && (leveltime % TICRATE == 0)) - { - CONS_Debug(DBG_NIGHTS, "Transfer1 : %d\n", transfer1->health); - CONS_Debug(DBG_NIGHTS, "Transfer2 : %d\n", transfer2->health); - } - //CONS_Debug(DBG_NIGHTS, "Xspeed : %d", truexspeed); - - //CONS_Debug(DBG_NIGHTS, "T1 is at %d, %d\n", transfer1->x>>FRACBITS, transfer1->y>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "T2 is at %d, %d\n", transfer2->x>>FRACBITS, transfer2->y>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "Distance from T1: %d\n", P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS); - //CONS_Debug(DBG_NIGHTS, "Distance from T2: %d\n", P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS); - - // Transfer1 is closer to the player than transfer2 - if (P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS - < P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS) - { - //CONS_Debug(DBG_NIGHTS, " must be < 0 to transfer\n"); - - if (transfer1->type == MT_AXISTRANSFERLINE) - { - if (transfer1last) - axis = P_FindAxis(transfer1->threshold, transfer1->health-2); - else if (player->pflags & PF_TRANSFERTOCLOSEST) - axis = P_FindAxis(transfer1->threshold, transfer1->health-1); - else - axis = P_FindAxis(transfer1->threshold, transfer1->health); - - if (!axis) - { - CONS_Debug(DBG_NIGHTS, "Unable to find an axis - error code #1\n"); - return; - } - - //CONS_Debug(DBG_NIGHTS, "Drawing a line from %d to ", axis->health); - - transfer1line.v1->x = axis->x; - transfer1line.v1->y = axis->y; - - transfer1line.v2->x = transfer1->x; - transfer1line.v2->y = transfer1->y; - - if (cv_debug & DBG_NIGHTS) - P_ShootLine(axis, transfer1, player->mo->z); - - //CONS_Debug(DBG_NIGHTS, "closest %d\n", transfer1->health); - - transfer1line.dx = transfer1line.v2->x - transfer1line.v1->x; - transfer1line.dy = transfer1line.v2->y - transfer1line.v1->y; - - if (P_PointOnLineSide(player->mo->x, player->mo->y, &transfer1line) - != P_PointOnLineSide(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, &transfer1line) - && truexspeed < 0) - { - if (cv_debug & DBG_NIGHTS) - { - HU_SetCEchoDuration(1); - HU_DoCEcho("transfer!"); - HU_SetCEchoDuration(5); - S_StartSound(NULL, sfx_strpst); - } - if (player->pflags & PF_TRANSFERTOCLOSEST) - { - player->pflags &= ~PF_TRANSFERTOCLOSEST; - P_TransferToAxis(player, transfer1->health - 1); - } - else - { - player->pflags |= PF_TRANSFERTOCLOSEST; - P_SetTarget(&player->axis2, transfer1); - P_SetTarget(&player->axis1, P_FindAxisTransfer(transfer1->threshold, transfer1->health-1, MT_AXISTRANSFERLINE));//P_FindAxis(transfer1->threshold, axis->health-2); - } - } - } - else - { - // Transfer1 - if (transfer1last) - axis = P_FindAxis(transfer1->threshold, 1); - else - axis = P_FindAxis(transfer1->threshold, transfer1->health); - - if (!axis) - { - CONS_Debug(DBG_NIGHTS, "Unable to find an axis - error code #2\n"); - return; - } - - //CONS_Debug(DBG_NIGHTS, "Drawing a line from %d to ", axis->health); - - transfer1line.v1->x = axis->x; - transfer1line.v1->y = axis->y; - - if (cv_debug & DBG_NIGHTS) - P_ShootLine(transfer1, P_FindAxis(transfer1->threshold, transfer1->health-1), player->mo->z); - - //axis = P_FindAxis(transfer1->threshold, transfer1->health-1); - - //CONS_Debug(DBG_NIGHTS, "%d\n", axis->health); - - transfer1line.v2->x = transfer1->x; - transfer1line.v2->y = transfer1->y; - - transfer1line.dx = transfer1line.v2->x - transfer1line.v1->x; - transfer1line.dy = transfer1line.v2->y - transfer1line.v1->y; - - if (P_PointOnLineSide(player->mo->x, player->mo->y, &transfer1line) - != P_PointOnLineSide(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, &transfer1line) - && truexspeed < 0) - { - if (cv_debug & DBG_NIGHTS) - { - HU_SetCEchoDuration(1); - HU_DoCEcho("transfer!"); - HU_SetCEchoDuration(5); - S_StartSound(NULL, sfx_strpst); - } - if (player->mo->target->health < transfer1->health) - { - // Find the next axis with a ->health - // +1 from the current axis. - if (transfer1last) - P_TransferToAxis(player, transfer1->health - 1); - else - P_TransferToAxis(player, transfer1->health); - } - else if (player->mo->target->health >= transfer1->health) - { - // Find the next axis with a ->health - // -1 from the current axis. - P_TransferToAxis(player, transfer1->health - 1); - } - } - } - } - else - { - //CONS_Debug(DBG_NIGHTS, " must be > 0 to transfer\n"); - if (transfer2->type == MT_AXISTRANSFERLINE) - { - if (transfer2last) - axis = P_FindAxis(transfer2->threshold, 1); - else if (player->pflags & PF_TRANSFERTOCLOSEST) - axis = P_FindAxis(transfer2->threshold, transfer2->health); - else - axis = P_FindAxis(transfer2->threshold, transfer2->health - 1); - - if (!axis) - axis = P_FindAxis(transfer2->threshold, 1); - - if (!axis) - { - CONS_Debug(DBG_NIGHTS, "Unable to find an axis - error code #3\n"); - return; - } - - //CONS_Debug(DBG_NIGHTS, "Drawing a line from %d to ", axis->health); - - transfer2line.v1->x = axis->x; - transfer2line.v1->y = axis->y; - - transfer2line.v2->x = transfer2->x; - transfer2line.v2->y = transfer2->y; - - //CONS_Debug(DBG_NIGHTS, "closest %d\n", transfer2->health); - - if (cv_debug & DBG_NIGHTS) - P_ShootLine(axis, transfer2, player->mo->z); - - transfer2line.dx = transfer2line.v2->x - transfer2line.v1->x; - transfer2line.dy = transfer2line.v2->y - transfer2line.v1->y; - - if (P_PointOnLineSide(player->mo->x, player->mo->y, &transfer2line) - != P_PointOnLineSide(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, &transfer2line) - && truexspeed > 0) - { - if (cv_debug & DBG_NIGHTS) - { - HU_SetCEchoDuration(1); - HU_DoCEcho("transfer!"); - HU_SetCEchoDuration(5); - S_StartSound(NULL, sfx_strpst); - } - if (player->pflags & PF_TRANSFERTOCLOSEST) - { - player->pflags &= ~PF_TRANSFERTOCLOSEST; - - if (!P_FindAxis(transfer2->threshold, transfer2->health)) - transfer2last = true; - - if (transfer2last) - P_TransferToAxis(player, 1); - else - P_TransferToAxis(player, transfer2->health); - } - else - { - player->pflags |= PF_TRANSFERTOCLOSEST; - P_SetTarget(&player->axis1, transfer2); - P_SetTarget(&player->axis2, P_FindAxisTransfer(transfer2->threshold, transfer2->health+1, MT_AXISTRANSFERLINE));//P_FindAxis(transfer2->threshold, axis->health + 2); - } - } - } - else - { - // Transfer2 - if (transfer2last) - axis = P_FindAxis(transfer2->threshold, 1); - else - axis = P_FindAxis(transfer2->threshold, transfer2->health); - - if (!axis) - axis = P_FindAxis(transfer2->threshold, 1); - - if (!axis) - { - CONS_Debug(DBG_NIGHTS, "Unable to find an axis - error code #4\n"); - return; - } - - //CONS_Debug(DBG_NIGHTS, "Drawing a line from %d to ", axis->health); - - transfer2line.v1->x = axis->x; - transfer2line.v1->y = axis->y; - - if (cv_debug & DBG_NIGHTS) - P_ShootLine(transfer2, P_FindAxis(transfer2->threshold, transfer2->health-1), player->mo->z); - - //axis = P_FindAxis(transfer2->threshold, transfer2->health-1); - - //CONS_Debug(DBG_NIGHTS, "%d\n", axis->health); - - transfer2line.v2->x = transfer2->x; - transfer2line.v2->y = transfer2->y; - - transfer2line.dx = transfer2line.v2->x - transfer2line.v1->x; - transfer2line.dy = transfer2line.v2->y - transfer2line.v1->y; - - if (P_PointOnLineSide(player->mo->x, player->mo->y, &transfer2line) - != P_PointOnLineSide(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, &transfer2line) - && truexspeed > 0) - { - if (cv_debug & DBG_NIGHTS) - { - HU_SetCEchoDuration(1); - HU_DoCEcho("transfer!"); - HU_SetCEchoDuration(5); - S_StartSound(NULL, sfx_strpst); - } - if (player->mo->target->health < transfer2->health) - { - if (!P_FindAxis(transfer2->threshold, transfer2->health)) - transfer2last = true; - - if (transfer2last) - P_TransferToAxis(player, 1); - else - P_TransferToAxis(player, transfer2->health); - } - else if (player->mo->target->health >= transfer2->health) - P_TransferToAxis(player, transfer2->health - 1); - } - } - } - } -} - -// -// P_DoNiGHTSCapsule -// -// Handles blowing up the Ideya (emerald) capsule for NiGHTS mode -// -static void P_DoNiGHTSCapsule(player_t *player) -{ - INT32 i; - - if ((player->pflags & PF_NIGHTSMODE) && (player->mo->tracer->state < &states[S_NIGHTSHURT1] - || player->mo->tracer->state > &states[S_NIGHTSHURT32])) - P_SetMobjState(player->mo->tracer, S_NIGHTSHURT1); - - if (abs(player->mo->x-player->capsule->x) <= 2*FRACUNIT) - { - P_UnsetThingPosition(player->mo); - player->mo->x = player->capsule->x; - P_SetThingPosition(player->mo); - player->mo->momx = 0; - } - - if (abs(player->mo->y-player->capsule->y) <= 2*FRACUNIT) - { - P_UnsetThingPosition(player->mo); - player->mo->y = player->capsule->y; - P_SetThingPosition(player->mo); - player->mo->momy = 0; - } - - if (abs(player->mo->z - (player->capsule->z+(player->capsule->height/3))) <= 2*FRACUNIT) - { - player->mo->z = player->capsule->z+(player->capsule->height/3); - player->mo->momz = 0; - } - - if (player->mo->x > player->capsule->x) - player->mo->momx = -2*FRACUNIT; - else if (player->mo->x < player->capsule->x) - player->mo->momx = 2*FRACUNIT; - - if (player->mo->y > player->capsule->y) - player->mo->momy = -2*FRACUNIT; - else if (player->mo->y < player->capsule->y) - player->mo->momy = 2*FRACUNIT; - - if (player->mo->z > player->capsule->z+(player->capsule->height/3)) - player->mo->momz = -2*FRACUNIT; - else if (player->mo->z < player->capsule->z+(player->capsule->height/3)) - player->mo->momz = 2*FRACUNIT; - - if (G_IsSpecialStage(gamemap)) - { // In special stages, share rings. Everyone gives up theirs to the capsule player always, because we can't have any individualism here! - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (&players[i] != player) && players[i].mo->health > 1) - { - player->mo->health += players[i].mo->health-1; - player->health = player->mo->health; - players[i].mo->health = 1; - players[i].health = players[i].mo->health; - } - } - - // Time to blow it up! - if (player->mo->x == player->capsule->x - && player->mo->y == player->capsule->y - && player->mo->z == player->capsule->z+(player->capsule->height/3)) - { - if (player->mo->health > 1) - { - player->mo->health--; - player->health--; - player->capsule->health--; - player->capsule->extravalue1++; - - // Spawn a 'pop' for every 5 rings you deposit - if (!(player->capsule->extravalue1 % 5)) - S_StartSound(P_SpawnMobj(player->capsule->x + ((P_SignedRandom()/2)<capsule->y + ((P_SignedRandom()/2)<capsule->z + (player->capsule->height/2) + ((P_SignedRandom()/2)<capsule->health <= 0) - { - player->capsule->flags &= ~MF_NOGRAVITY; - player->capsule->momz = 5*FRACUNIT; - player->capsule->reactiontime = 0; - player->capsule->extravalue1 = -1; - - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !player->exiting && players[i].mare == player->mare) - { - players[i].bonustime = true; - players[i].texttimer = 4*TICRATE; - players[i].textvar = 1; // Time Bonus - players[i].finishedtime = players[i].nightstime; - if (!G_IsSpecialStage(gamemap)) - P_AddPlayerScore(&players[i], (players[i].finishedtime/TICRATE) * 100); - P_FlashPal(&players[i], PAL_WHITE, 8); - } - - if (G_IsSpecialStage(gamemap)) - { - // The Chaos Emerald begins to orbit us! - mobj_t *emmo; - UINT8 em = P_GetNextEmerald(); - tic_t lowest_time; - - if (player->mo->tracer) - { - // Only give it to ONE person, and THAT player has to get to the goal! - emmo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->info->height, MT_GOTEMERALD); - P_SetTarget(&emmo->target, player->mo); - P_SetMobjState(emmo, mobjinfo[MT_GOTEMERALD].meleestate + em); - P_SetTarget(&player->mo->tracer->target, emmo); - } - - // Okay, we're doing this down here because we're handling time weirdly for co-op special stages - // and because P_AddPlayerScore gives score to everyone in co-op special stages. - // Find the player with the lowest time remaining and award points based on that time instead. - lowest_time = player->finishedtime; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - if (players[i].finishedtime < lowest_time) - lowest_time = players[i].finishedtime; - P_AddPlayerScore(player, (lowest_time/TICRATE) * 100); - } - else - { - fixed_t z; - - z = player->capsule->z + player->capsule->height/2; - for (i = 0; i < 16; i++) - P_SpawnMobj(player->capsule->x, player->capsule->y, z, MT_BIRD); - } - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mare == player->mare) - P_SetTarget(&players[i].capsule, NULL); // Remove capsule from everyone now that it is dead! - S_StartScreamSound(player->mo, sfx_ngdone); - } - } - else - { - S_StartScreamSound(player->mo, sfx_lose); - player->texttimer = 4*TICRATE; - player->textvar = 3; // Get more rings! - player->capsule->reactiontime = 0; - player->capsule->extravalue1 = -1; - } - } - else - player->capsule->extravalue1 = -1; -} - -// -// P_NiGHTSMovement -// -// Movement code for NiGHTS! -// -static void P_NiGHTSMovement(player_t *player) -{ - fixed_t drillamt = 0; - boolean still = false, moved = false, backwardaxis = false, firstdrill; - INT16 newangle = 0; - fixed_t xspeed, yspeed; - thinker_t *th; - mobj_t *mo2; - mobj_t *closestaxis = NULL; - fixed_t newx, newy, radius; - angle_t movingangle; - ticcmd_t *cmd = &player->cmd; - INT32 thrustfactor; - INT32 i; - statenum_t flystate = S_NIGHTSFLY1A; - - player->pflags &= ~PF_DRILLING; - - firstdrill = false; - - if (player->drillmeter > 96*20) - player->drillmeter = 96*20; - - if (player->drilldelay) - player->drilldelay--; - - if (!(cmd->buttons & BT_DRIFT)) - { - // Always have just a TINY bit of drill power. - if (player->drillmeter <= 0) - player->drillmeter = TICRATE/10; - } - - if (!player->mo->tracer) - { - P_DeNightserizePlayer(player); - return; - } - - if (G_IsSpecialStage(gamemap)) - { - boolean capsule = false; - // NiGHTS special stages have a pseudo-shared timer, so check if ANYONE is feeding the capsule. - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] - && (players[i].capsule && players[i].capsule->reactiontime)) - capsule = true; - if (!capsule - && !(player->mo->tracer->state >= &states[S_SUPERTRANS1] - && player->mo->tracer->state <= &states[S_SUPERTRANS9]) - && !player->exiting) - player->nightstime--; - } - else if (!G_RaceGametype() - && !(player->mo->tracer->state >= &states[S_SUPERTRANS1] && player->mo->tracer->state <= &states[S_SUPERTRANS9]) - && !(player->capsule && player->capsule->reactiontime) - && !player->exiting) - player->nightstime--; - - if (!player->nightstime) - { - P_DeNightserizePlayer(player); - S_StartScreamSound(player->mo, sfx_s3k66); -// S_StopSoundByNum(sfx_timeup); // Kill the "out of time" music, if it's playing. Dummied out, as some on the dev team thought it wasn't Sonic-y enough (Mystic, notably). Uncomment to restore. -SH - P_RestoreMusic(player); // I have my doubts that this is the right place for this... - - return; - } - else if (P_IsLocalPlayer(player) && player->nightstime == 10*TICRATE) -// S_StartSound(NULL, sfx_timeup); // that creepy "out of time" music from NiGHTS. Dummied out, as some on the dev team thought it wasn't Sonic-y enough (Mystic, notably). Uncomment to restore. -SH - S_ChangeMusicInternal("drown",false); - - - if (player->mo->z < player->mo->floorz) - player->mo->z = player->mo->floorz; - - if (player->mo->z+player->mo->height > player->mo->ceilingz) - player->mo->z = player->mo->ceilingz - player->mo->height; - - newx = P_ReturnThrustX(player->mo, player->mo->angle, 3*FRACUNIT)+player->mo->x; - newy = P_ReturnThrustY(player->mo, player->mo->angle, 3*FRACUNIT)+player->mo->y; - - if (!player->mo->target) - { - fixed_t dist1, dist2 = 0; - - // scan the thinkers - // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_AXIS) - { - if (mo2->threshold == player->mare) - { - if (closestaxis == NULL) - { - closestaxis = mo2; - dist2 = R_PointToDist2(newx, newy, mo2->x, mo2->y)-mo2->radius; - } - else - { - dist1 = R_PointToDist2(newx, newy, mo2->x, mo2->y)-mo2->radius; - - if (dist1 < dist2) - { - closestaxis = mo2; - dist2 = dist1; - } - } - } - } - } - - P_SetTarget(&player->mo->target, closestaxis); - } - - if (!player->mo->target) // Uh-oh! - { - CONS_Debug(DBG_NIGHTS, "No axis points found!\n"); - return; - } - - // The 'ambush' flag says you should rotate - // the other way around the axis. - if (player->mo->target->flags2 & MF2_AMBUSH) - backwardaxis = true; - - player->angle_pos = R_PointToAngle2(player->mo->target->x, player->mo->target->y, player->mo->x, player->mo->y); - - player->old_angle_pos = player->angle_pos; - - radius = player->mo->target->radius; - - player->mo->flags |= MF_NOGRAVITY; - player->mo->flags2 |= MF2_DONTDRAW; - P_SetScale(player->mo->tracer, player->mo->scale); - - if (player->mo->eflags & MFE_VERTICALFLIP) - cmd->forwardmove = (SINT8)(-cmd->forwardmove); - - if (!(player->pflags & PF_TRANSFERTOCLOSEST)) - { - fixed_t realdist = R_PointToDist2(player->mo->x, player->mo->y, player->mo->target->x, player->mo->target->y); - // teleport player to correct radius if neccessary - if (realdist>>FRACBITS != radius>>FRACBITS) - { - CONS_Debug(DBG_NIGHTS, "Aligning player with axis\n"); - P_UnsetThingPosition(player->mo); - if (realdist == 0) // other method won't work if we're exactly on the target lol - { - const angle_t fa = player->old_angle_pos>>ANGLETOFINESHIFT; - player->mo->x = player->mo->target->x + FixedMul(FINECOSINE(fa), radius); - player->mo->y = player->mo->target->y + FixedMul(FINESINE(fa), radius); - } - else - { - player->mo->x = player->mo->target->x + FixedMul(FixedDiv(player->mo->x - player->mo->target->x, realdist), radius); - player->mo->y = player->mo->target->y + FixedMul(FixedDiv(player->mo->y - player->mo->target->y, realdist), radius); - } - P_SetThingPosition(player->mo); - } - } - - // Currently reeling from being hit. - if (player->powers[pw_flashing] > (2*K_GetKartFlashing(player))/3) - { - { - const angle_t fa = (FixedAngle(player->flyangle*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK; - const fixed_t speed = FixedDiv(player->speed*FRACUNIT,50*FRACUNIT); - - xspeed = FixedMul(FINECOSINE(fa),speed); - yspeed = FixedMul(FINESINE(fa),speed); - } - - if (!(player->pflags & PF_TRANSFERTOCLOSEST)) - { - xspeed = FixedMul(xspeed, FixedDiv(1024*FRACUNIT, player->mo->target->radius)); - - if (backwardaxis) - xspeed *= -1; - - player->angle_pos += FixedAngleC(FixedDiv(xspeed,5*FRACUNIT),40*FRACUNIT); - } - - player->mo->momz = 0; - - P_NightsTransferPoints(player, xspeed, radius); - return; - } - - if (player->mo->tracer->state >= &states[S_SUPERTRANS1] - && player->mo->tracer->state <= &states[S_SUPERTRANS9]) - { - player->mo->momx = player->mo->momy = player->mo->momz = 0; - return; - } - - if (player->exiting > 0 && player->exiting < 2*TICRATE) - { - player->mo->momx = player->mo->momy = 0; - - if (!G_RaceGametype()) - P_SetObjectMomZ(player->mo, 30*FRACUNIT, false); - - player->mo->tracer->angle += ANGLE_11hh; - - if (!(player->mo->tracer->state >= &states[S_NIGHTSDRONE1] - && player->mo->tracer->state <= &states[S_NIGHTSDRONE2])) - P_SetMobjState(player->mo->tracer, S_NIGHTSDRONE1); - - player->mo->tracer->flags |= MF_NOCLIPHEIGHT; - player->mo->flags |= MF_NOCLIPHEIGHT; - return; - } - - // Spawn the little sparkles on each side of the player. - if (leveltime & 1) - { - mobj_t *firstmobj; - mobj_t *secondmobj; - fixed_t spawndist = FixedMul(16*FRACUNIT, player->mo->scale); - fixed_t z = player->mo->z + player->mo->height/2; - - if (player->mo->eflags & MFE_VERTICALFLIP) - z -= FixedMul(mobjinfo[MT_NIGHTSPARKLE].height, player->mo->scale); - - firstmobj = P_SpawnMobj(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle+ANGLE_90, spawndist), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle+ANGLE_90, spawndist), z, MT_NIGHTSPARKLE); - secondmobj = P_SpawnMobj(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle-ANGLE_90, spawndist), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle-ANGLE_90, spawndist), z, MT_NIGHTSPARKLE); - - firstmobj->destscale = secondmobj->destscale = player->mo->scale; - P_SetTarget(&firstmobj->target, player->mo); - P_SetScale(firstmobj, player->mo->scale); - P_SetTarget(&secondmobj->target, player->mo); - P_SetScale(secondmobj, player->mo->scale); - - // Superloop turns sparkles red - if (player->powers[pw_nights_superloop]) - { - P_SetMobjState(firstmobj, mobjinfo[MT_NIGHTSPARKLE].seestate); - P_SetMobjState(secondmobj, mobjinfo[MT_NIGHTSPARKLE].seestate); - } - } - - // Paraloop helper is now separate from sparkles - // It also spawns every tic to avoid failed paraloops - { - mobj_t *helpermobj = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, MT_NIGHTSLOOPHELPER); - helpermobj->fuse = player->mo->fuse = leveltime; - P_SetTarget(&helpermobj->target, player->mo); - P_SetScale(helpermobj, player->mo->scale); - } - - if (player->bumpertime) - { - player->jumping = 1; - player->pflags |= PF_DRILLING; - newangle = (INT16)player->flyangle; - } - else if (cmd->buttons & BT_DRIFT && player->drillmeter && player->drilldelay == 0) - { - if (!player->jumping) - firstdrill = true; - - player->jumping = 1; - player->pflags |= PF_DRILLING; - } - else - { - player->jumping = 0; - - if (cmd->sidemove != 0) - moved = true; - - if (player->drillmeter & 1) - player->drillmeter++; // I'll be nice and give them one. - } - - if (cmd->forwardmove != 0) - moved = true; - - if (!player->bumpertime) - { - if (moved) - { - if (player->pflags & PF_DRILLING) - drillamt += 100*FRACUNIT; - else - { - const fixed_t fforward = abs(cmd->forwardmove)*FRACUNIT; - const fixed_t fside = abs(cmd->sidemove)*FRACUNIT; - const fixed_t dist = FixedHypot(fforward, fside); - - drillamt += dist > 50*FRACUNIT ? 50*FRACUNIT : dist; - - // Accel up from 50 * 2.5 - drillamt = FixedMul(drillamt, 5*FRACUNIT/2); - } - if ((player->pflags & PF_DRILLING && player->speed < MAXDRILLSPEED) || player->speed < MAXNORMALSPEED) - player->speed += FixedInt(drillamt); - } - - if (player->pflags & PF_DRILLING) - { - if (player->speed < MAXDRILLSPEED) - player->speed += 150; - - if (--player->drillmeter == 0) - player->drilldelay = TICRATE*2; - } - - if (player->speed < 0) - player->speed = 0; - - if (!cmd->forwardmove) - { - if (cmd->sidemove > 0) - newangle = 0; - else if (cmd->sidemove < 0) - newangle = 180; - } - else if (!cmd->sidemove) - { - if (cmd->forwardmove > 0) - newangle = 90; - else if (cmd->forwardmove < 0) - newangle = 270; - } - else // AngleFixed(R_PointToAngle2()) results in slight inaccuracy! Don't use it unless movement is on both axises. - newangle = (INT16)FixedInt(AngleFixed(R_PointToAngle2(0,0, cmd->sidemove*FRACUNIT, cmd->forwardmove*FRACUNIT))); - - newangle -= player->viewrollangle / ANG1; - - if (newangle < 0 && moved) - newangle = (INT16)(360+newangle); - } - - if (player->pflags & PF_DRILLING) - thrustfactor = 2; - else - { - thrustfactor = 8; - - // Decelerate while turning normally. - if (moved && player->flyangle != newangle && player->speed > 12000) - player->speed -= 60; - } - - for (i = 0; i < thrustfactor; i++) - { - if (moved && player->flyangle != newangle) - { - INT32 anglediff = (((newangle-player->flyangle)+360)%360); - INT32 angledif2 = (((player->flyangle-newangle)+360)%360); - - // player->flyangle is the one to move - // newangle is the "move to" - if (anglediff == 0 && angledif2 == 0) - break; - - if (anglediff>angledif2) - player->flyangle--; - else // if (anglediffflyangle++; - } - - // Buff out negatives, >360 angles... - player->flyangle = ((player->flyangle + 360) % 360); - } - - if (!(player->speed) - && cmd->forwardmove == 0) - still = true; - - // No more bumper braking - if (!player->bumpertime - && ((cmd->buttons & (BT_FORWARD|BT_BACKWARD)) == (BT_FORWARD|BT_BACKWARD) - || (cmd->buttons & BT_BRAKE))) - { - if (!(player->pflags & PF_SKIDDOWN)) - S_StartSound(player->mo, sfx_ngskid); - - // You can tap the button to only slow down a bit, - // or hold it to slow to a crawl as before, your choice. - if (player->speed > 8000) - player->speed -= 2000; - else if (player->speed > 1000) - player->speed -= (player->speed/4); - else { - player->speed -= 60; - if (player->speed < 0) - { - player->speed = 0; - still = true; - } - } - - player->pflags |= PF_SKIDDOWN; - } - else - player->pflags &= ~PF_SKIDDOWN; - - { - const angle_t fa = (FixedAngle(player->flyangle*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK; - const fixed_t speed = FixedDiv(player->speed*FRACUNIT,50*FRACUNIT); - xspeed = FixedMul(FINECOSINE(fa),speed); - yspeed = FixedMul(FINESINE(fa),speed); - } - - if (!(player->pflags & PF_TRANSFERTOCLOSEST)) - { - xspeed = FixedMul(xspeed, FixedDiv(1024*FRACUNIT, player->mo->target->radius)); - - if (backwardaxis) - xspeed *= -1; - - player->angle_pos += FixedAngleC(FixedDiv(xspeed,5*FRACUNIT),40*FRACUNIT); - } - - P_NightsTransferPoints(player, xspeed, radius); - - if (still) - player->mo->momz = -FRACUNIT; - else - player->mo->momz = yspeed/11; - - if (player->mo->momz > 20*FRACUNIT) - player->mo->momz = 20*FRACUNIT; - else if (player->mo->momz < -20*FRACUNIT) - player->mo->momz = -20*FRACUNIT; - - // You can create splashes as you fly across water. - if (((!(player->mo->eflags & MFE_VERTICALFLIP) - && player->mo->z + P_GetPlayerHeight(player) >= player->mo->watertop && player->mo->z <= player->mo->watertop) - || (player->mo->eflags & MFE_VERTICALFLIP - && player->mo->z + player->mo->height - P_GetPlayerHeight(player) <= player->mo->waterbottom && player->mo->z + player->mo->height >= player->mo->waterbottom)) - && player->speed > 9000 && leveltime % (TICRATE/7) == 0 && !player->spectator) - { - mobj_t *water = P_SpawnMobj(player->mo->x, player->mo->y, - ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_SPLISH].height, player->mo->scale) : player->mo->watertop), MT_SPLISH); - if (player->mo->eflags & MFE_GOOWATER) - S_StartSound(water, sfx_ghit); - else - S_StartSound(water, sfx_wslap); - if (player->mo->eflags & MFE_VERTICALFLIP) - { - water->flags2 |= MF2_OBJECTFLIP; - water->eflags |= MFE_VERTICALFLIP; - } - water->destscale = player->mo->scale; - P_SetScale(water, player->mo->scale); - } - - if (player->mo->momx || player->mo->momy) - player->mo->angle = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - - if (still) - { - player->anotherflyangle = 0; - movingangle = 0; - } - else - { - INT32 neg = 1; - - // Special cases to prevent the angle from being - // calculated incorrectly when wrapped. - if (backwardaxis && (player->old_angle_pos > ANG350 && player->angle_pos < ANG10)) - neg = -1; - else if (backwardaxis ^ (player->old_angle_pos < ANG10 && player->angle_pos > ANG350)) - neg = -1; - else if (player->angle_pos > player->old_angle_pos) - neg = -1; - - movingangle = R_PointToAngle2(0, 0, neg*R_PointToDist2(player->mo->momx, player->mo->momy, 0, 0), player->mo->momz); - player->anotherflyangle = (movingangle >> ANGLETOFINESHIFT) * 360/FINEANGLES; - } - - // NiGHTS flying state - // Yep, I just ripped out almost 1000 lines of code. - if ((player->anotherflyangle >= 12 && player->anotherflyangle <= 33) // +x +y - || (player->anotherflyangle >= 147 && player->anotherflyangle <= 168)) // -x +y - flystate = S_NIGHTSFLY2A; - else if ((player->anotherflyangle >= 34 && player->anotherflyangle <= 56) // +x +y - || (player->anotherflyangle >= 124 && player->anotherflyangle <= 146)) // -x +y - flystate = S_NIGHTSFLY3A; - else if ((player->anotherflyangle >= 57 && player->anotherflyangle <= 79) // +x +y - || (player->anotherflyangle >= 102 && player->anotherflyangle <= 123)) // -x +y - flystate = S_NIGHTSFLY4A; - else if (player->anotherflyangle >= 80 && player->anotherflyangle <= 101) - flystate = S_NIGHTSFLY5A; - else if ((player->anotherflyangle >= 192 && player->anotherflyangle <= 213) // -x -y - || (player->anotherflyangle >= 327 && player->anotherflyangle <= 348)) // +x -y - flystate = S_NIGHTSFLY6A; - else if ((player->anotherflyangle >= 214 && player->anotherflyangle <= 236) // -x -y - || (player->anotherflyangle >= 305 && player->anotherflyangle <= 326)) // +x -y - flystate = S_NIGHTSFLY7A; - else if ((player->anotherflyangle >= 237 && player->anotherflyangle <= 258) // -x -y - || (player->anotherflyangle >= 282 && player->anotherflyangle <= 304)) // +x -y - flystate = S_NIGHTSFLY8A; - else if (player->anotherflyangle >= 259 && player->anotherflyangle <= 281) - flystate = S_NIGHTSFLY9A; - else - flystate = S_NIGHTSFLY1A; - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (flystate >= S_NIGHTSFLY2A && flystate <= S_NIGHTSFLY5A) - flystate += 24; // shift to S_NIGHTSFLY6A - else if (flystate >= S_NIGHTSFLY6A && flystate <= S_NIGHTSFLY9A) - flystate -= 24; // shift to S_NIGHTSFLY2A - } - - if (player->pflags & PF_DRILLING) - { - const statenum_t drillstate = flystate + 2; - - if (!(player->mo->tracer->state >= &states[drillstate] - && player->mo->tracer->state <= &states[drillstate+4])) - { - if (!(player->mo->tracer->state >= &states[S_NIGHTSFLY1A] - && player->mo->tracer->state <= &states[S_NIGHTSFLY9B])) - { - const INT32 framenum = player->mo->tracer->state->frame & 3; - - if (framenum == 3) // Drilld special case - P_SetMobjStateNF(player->mo->tracer, drillstate); - else - P_SetMobjStateNF(player->mo->tracer, drillstate+framenum+1); - } - else - P_SetMobjStateNF(player->mo->tracer, drillstate); - } - } - else - P_SetMobjStateNF(player->mo->tracer, leveltime & 1 ? flystate : flystate+1); - - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - - if (still) - { - P_SetMobjStateNF(player->mo->tracer, S_NIGHTSDRONE1); - player->mo->tracer->angle = player->mo->angle; - } - - // Check for crushing in our new location - if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) - && !(player->mo->flags & MF_NOCLIP)) - { - // Flashing won't run out until you STOP being crushed. - if (player->powers[pw_flashing] == 1) - player->powers[pw_flashing] = 3; - else - P_DamageMobj(player->mo, NULL, NULL, 1); - } - - if (movingangle >= ANGLE_90 && movingangle <= ANGLE_180) - movingangle = movingangle - ANGLE_180; - else if (movingangle >= ANGLE_180 && movingangle <= ANGLE_270) - movingangle = movingangle - ANGLE_180; - else if (movingangle >= ANGLE_270) - movingangle = InvAngle(movingangle); - - if (player == &players[consoleplayer]) - localaiming[0] = movingangle; - else if (player == &players[displayplayers[1]]) - localaiming[1] = movingangle; - else if (player == &players[displayplayers[2]]) - localaiming[2] = movingangle; - else if (player == &players[displayplayers[3]]) - localaiming[3] = movingangle; - - player->mo->tracer->angle = player->mo->angle; - - if ((player->pflags & PF_DRILLING) && !player->bumpertime) - { - if (firstdrill) - { - S_StartSound(player->mo, sfx_drill1); - player->drilltimer = 32; - } - else if (--player->drilltimer <= 0) - { - player->drilltimer = 10; - S_StartSound(player->mo, sfx_drill2); - } - } - - if (objectplacing) - OP_NightsObjectplace(player); -}*/ - -// May be used in future for CTF -#if 0 -static void P_PlayerDropWeapon(player_t *player) -{ - mobj_t *mo = NULL; - - if (player->powers[pw_homingring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_HOMINGRING); - player->powers[pw_homingring] = 0; - } - else if (player->powers[pw_railring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_RAILRING); - player->powers[pw_railring] = 0; - } - else if (player->powers[pw_automaticring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_AUTOMATICRING); - player->powers[pw_automaticring] = 0; - } - else if (player->powers[pw_explosionring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_EXPLOSIONRING); - player->powers[pw_explosionring] = 0; - } - else if (player->powers[pw_scatterring]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_SCATTERRING); - player->powers[pw_scatterring] = 0; - } - else if (player->powers[pw_grenadering]) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z+(60*FRACUNIT), MT_GRENADERING); - player->powers[pw_grenadering] = 0; - } - - if (mo) - { - player->mo->health--; - P_InstaThrust(mo, player->mo->angle-ANGLE_180, 8*FRACUNIT); - P_SetObjectMomZ(mo, 4*FRACUNIT, false); - mo->flags2 |= MF2_DONTRESPAWN; - mo->flags &= ~MF_NOGRAVITY; - mo->flags &= ~MF_NOCLIPHEIGHT; - mo->fuse = 12*TICRATE; - } -} -#endif - void P_BlackOw(player_t *player) { INT32 i; @@ -5666,14 +2782,6 @@ static void P_MovePlayer(player_t *player) if (countdowntimeup) return; - /* // SRB2kart - junk - if (player->mo->state >= &states[S_PLAY_SUPERTRANS1] && player->mo->state <= &states[S_PLAY_SUPERTRANS9]) - { - player->mo->momx = player->mo->momy = player->mo->momz = 0; - return; - } - */ - cmd = &player->cmd; runspd = 14*player->mo->scale; //srb2kart @@ -5733,69 +2841,10 @@ static void P_MovePlayer(player_t *player) return; } - // Locate the capsule for this mare. - /*else if (maptol & TOL_NIGHTS) - { - if (!player->capsule && !player->bonustime) - { - thinker_t *th; - mobj_t *mo2; - - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_EGGCAPSULE - && mo2->threshold == player->mare) - P_SetTarget(&player->capsule, mo2); - } - } - else if (player->capsule && player->capsule->reactiontime > 0 && player == &players[player->capsule->reactiontime-1]) - { - P_DoNiGHTSCapsule(player); - return; - } - - // Test revamped NiGHTS movement. - if (player->pflags & PF_NIGHTSMODE) - { - P_NiGHTSMovement(player); - // No more goto blockchecking, let's just do all that here =D - if (CheckForBustableBlocks) - P_CheckBustableBlocks(player); - if (CheckForBouncySector) - P_CheckBouncySectors(player); - if (CheckForQuicksand) - P_CheckQuicksand(player); - return; - } - - if (player->pflags & PF_NIGHTSFALL && P_IsObjectOnGround(player->mo)) - { - if (G_IsSpecialStage(gamemap)) - { - if (player == &players[displayplayers[0]]) // only play the sound for yourself landing - S_StartSound(NULL, sfx_s3k6a); - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - players[i].exiting = raceexittime+1; - } - else if (player->health > 1) - P_DamageMobj(player->mo, NULL, NULL, 1); - player->pflags &= ~PF_NIGHTSFALL; - } - }*/ - ////////////////////// // MOVEMENT CODE // ////////////////////// - /*if (twodlevel || player->mo->flags2 & MF2_TWOD) // 2d-level, so special control applies. - P_2dMovement(player); - else*/ { INT16 angle_diff, max_left_turn, max_right_turn; boolean add_delta = true; @@ -5861,32 +2910,6 @@ static void P_MovePlayer(player_t *player) // MOVEMENT ANIMATIONS // ///////////////////////// - /* - if ((cmd->forwardmove != 0 || cmd->sidemove != 0) || (player->powers[pw_super] && player->mo->z > player->mo->floorz)) - { - // If the player is moving fast enough, - // break into a run! - if (player->speed >= runspd && player->panim == PA_WALK && !player->skidtime && (onground || player->powers[pw_super])) - P_SetPlayerMobjState (player->mo, S_KART_RUN1); // SRB2kart - was S_PLAY_SPD1 - - // Otherwise, just walk. - else if ((player->rmomx || player->rmomy) && player->panim == PA_IDLE) - P_SetPlayerMobjState (player->mo, S_KART_WALK1); // SRB2kart - was S_PLAY_RUN1 - } - */ - - // If your running animation is playing, and you're - // going too slow, switch back to the walking frames. - //if (player->panim == PA_RUN && player->speed < runspd && player->kartstuff[k_spinouttimer] == 0) - //P_SetPlayerMobjState(player->mo, S_KART_WALK1); // SRB2kart - was S_PLAY_RUN1 - - // If Springing, but travelling DOWNWARD, change back! - //if (player->mo->state == &states[S_PLAY_SPRING] && P_MobjFlip(player->mo)*player->mo->momz < 0) - // P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); - // If Springing but on the ground, change back! - //else if (onground && (player->mo->state == &states[S_PLAY_SPRING] || player->panim == PA_FALL || player->mo->state == &states[S_PLAY_CARRY]) && !player->mo->momz) - // P_SetPlayerMobjState(player->mo, S_PLAY_STND); - // Kart frames if (player->kartstuff[k_squishedtimer] > 0) { @@ -5969,104 +2992,13 @@ static void P_MovePlayer(player_t *player) P_SetPlayerMobjState(player->mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND } - if (/*!(player->charability == CA_GLIDEANDCLIMB) ||*/ player->gotflag) // If you can't glide, then why the heck would you be gliding? + if (player->gotflag) // If you can't glide, then why the heck would you be gliding? { - /* // SRB2kart - ??? - if (player->pflags & PF_GLIDING || player->climbing) - { - if (onground) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); - else - { - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - } - */ player->pflags &= ~PF_GLIDING; player->glidetime = 0; player->climbing = 0; } - // Glide MOMZ - // AKA my own gravity. =) - /* // SRB2kart - gliding is illegal, go to jail - if (player->pflags & PF_GLIDING) - { - fixed_t leeway; - fixed_t glidespeed = player->actionspd; - - if (player->powers[pw_super]) - glidespeed *= 2; - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if (player->mo->momz > FixedMul(2*FRACUNIT, player->mo->scale)) - player->mo->momz -= FixedMul(3*(FRACUNIT/4), player->mo->scale); - } - else - { - if (player->mo->momz < FixedMul(-2*FRACUNIT, player->mo->scale)) - player->mo->momz += FixedMul(3*(FRACUNIT/4), player->mo->scale); - } - - // Strafing while gliding. - leeway = FixedAngle(cmd->sidemove*(FRACUNIT/2)); - - if (player->skidtime) // ground gliding - { - fixed_t speed = FixedMul(glidespeed, FRACUNIT - (FRACUNIT>>2)); - if (player->mo->eflags & MFE_UNDERWATER) - speed >>= 1; - speed = FixedMul(speed - player->glidetime*FRACUNIT, player->mo->scale); - if (speed < 0) - speed = 0; - P_InstaThrust(player->mo, player->mo->angle-leeway, speed); - } - else if (player->mo->eflags & MFE_UNDERWATER) - P_InstaThrust(player->mo, player->mo->angle-leeway, FixedMul((glidespeed>>1) + player->glidetime*750, player->mo->scale)); - else - P_InstaThrust(player->mo, player->mo->angle-leeway, FixedMul(glidespeed + player->glidetime*1500, player->mo->scale)); - - player->glidetime++; - - if (!(player->pflags & PF_JUMPDOWN)) // If not holding the jump button - { - P_ResetPlayer(player); // down, stop gliding. - if (onground) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); - else if ((player->charability2 == CA2_MULTIABILITY) - || (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]) && player->charability == CA_GLIDEANDCLIMB)) - { - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - else - { - player->pflags |= PF_THOKKED; - player->mo->momx >>= 1; - player->mo->momy >>= 1; - P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); - } - } - } - else if (player->climbing) // 'Deceleration' for climbing on walls. - { - if (player->mo->momz > 0) - { - player->mo->momz -= FixedMul(FRACUNIT/2, player->mo->scale); - if (player->mo->momz < 0) - player->mo->momz = 0; - } - else if (player->mo->momz < 0) - { - player->mo->momz += FixedMul(FRACUNIT/2, player->mo->scale); - if (player->mo->momz > 0) - player->mo->momz = 0; - } - } - */ - // If you're running fast enough, you can create splashes as you run in shallow water. if (!player->climbing && ((!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z + player->mo->height >= player->mo->watertop && player->mo->z <= player->mo->watertop) @@ -6096,100 +3028,6 @@ static void P_MovePlayer(player_t *player) S_StartSound(player->mo, sfx_floush); } - //////////////// - //TAILS FLYING// - //////////////// - - /* // SRB2kart - nah - if (!(player->charability == CA_FLY || player->charability == CA_SWIM)) // why are you flying when you cannot fly?! - { - if (player->powers[pw_tailsfly] - || (player->mo->state >= &states[S_PLAY_SPC1] && player->mo->state <= &states[S_PLAY_SPC4])) - { - if (onground) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); - else - { - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - } - player->powers[pw_tailsfly] = 0; - } - - if (player->gotflag && player->powers[pw_tailsfly]) - player->powers[pw_tailsfly] = 1; - - // If not in a fly position, don't think you're flying! - if (player->panim != PA_ABILITY) - player->powers[pw_tailsfly] = 0; - - if (player->charability == CA_FLY || (player->charability == CA_SWIM && player->mo->eflags & MFE_UNDERWATER)) - { - // Fly counter for Tails. - if (player->powers[pw_tailsfly]) - { - const fixed_t actionspd = player->actionspd/100; - - if (player->charability2 == CA2_MULTIABILITY) - { - // Adventure-style flying by just holding the button down - if (cmd->buttons & BT_DRIFT && !(player->pflags & PF_STASIS) && !player->exiting) - P_SetObjectMomZ(player->mo, actionspd/4, true); - } - else - { - // Classic flying - if (player->fly1) - { - if (P_MobjFlip(player->mo)*player->mo->momz < FixedMul(5*actionspd, player->mo->scale)) - P_SetObjectMomZ(player->mo, actionspd/2, true); - - player->fly1--; - } - } - - // Tails Put-Put noise - if (player->charability == CA_FLY && player->bot != 1 && leveltime % 10 == 0 && !player->spectator) - S_StartSound(player->mo, sfx_putput); - - // Descend - if (cmd->buttons & BT_BRAKE && !(player->pflags & PF_STASIS) && !player->exiting) - if (P_MobjFlip(player->mo)*player->mo->momz > -FixedMul(5*actionspd, player->mo->scale)) - P_SetObjectMomZ(player->mo, -actionspd/2, true); - - } - else - { - // Tails-gets-tired Stuff - if (player->panim == PA_ABILITY) - P_SetPlayerMobjState(player->mo, S_PLAY_SPC4); - - if (player->charability == CA_FLY && (leveltime % 10 == 0) - && player->mo->state >= &states[S_PLAY_SPC1] - && player->mo->state <= &states[S_PLAY_SPC4] - && !player->spectator) - S_StartSound(player->mo, sfx_pudpud); - } - } - - // End your chain if you're on the ground or climbing a wall. - // But not if invincible! Allow for some crazy long chains with it. - // Also keep in mind the PF_JUMPED check. - // If we lacked this, stepping up while jumping up would reset score. - // (for instance, when climbing up off a wall.) - if ((onground || player->climbing) && !(player->pflags & PF_JUMPED) && player->powers[pw_invulnerability] <= 1) - P_ResetScore(player); - - // Show the "THOK!" graphic when spinning quickly across the ground. (even applies to non-spinners, in the case of zoom tubes) - if (player->pflags & PF_SPINNING && player->speed > FixedMul(15<mo->scale) && !(player->pflags & PF_JUMPED)) - { - P_SpawnSpinMobj(player, player->spinitem); - if (demo.recording) - G_GhostAddSpin((INT32) (player - players)); - } - */ - //////////////////////////// //SPINNING AND SPINDASHING// //////////////////////////// @@ -6206,253 +3044,18 @@ static void P_MovePlayer(player_t *player) K_DriftDustHandling(player->mo); - /* // SRB2kart - nadah - // If the player isn't on the ground, make sure they aren't in a "starting dash" position. - if (!onground) - { - player->pflags &= ~PF_STARTDASH; - player->dashspeed = 0; - } - - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL - && (player->pflags & PF_SPINNING) && player->speed > FixedMul(4<mo->scale) && onground && (leveltime & 1) - && !(player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) - P_ElementalFireTrail(player); - - P_DoSpinDash(player, cmd); - */ - // jumping - //P_DoJumpStuff(player, cmd); - - /* - // If you're not spinning, you'd better not be spindashing! - if (!(player->pflags & PF_SPINNING)) - player->pflags &= ~PF_STARTDASH; - */ - - ////////////////// - //ANALOG CONTROL// - ////////////////// - -#if 0 - // This really looks like it should be moved to P_3dMovement. -Red - if (P_AnalogMove(player) - && (cmd->forwardmove != 0 || cmd->sidemove != 0) && !player->climbing && !twodlevel && !(player->mo->flags2 & MF2_TWOD)) - { - // If travelling slow enough, face the way the controls - // point and not your direction of movement. - if (player->speed < FixedMul(5*FRACUNIT, player->mo->scale) || player->pflags & PF_GLIDING || !onground) - { - angle_t tempangle; - - tempangle = (cmd->angleturn << 16); - -#ifdef REDSANALOG // Ease to it. Chillax. ~Red - tempangle += R_PointToAngle2(0, 0, cmd->forwardmove*FRACUNIT, -cmd->sidemove*FRACUNIT); - { - fixed_t tweenvalue = max(abs(cmd->forwardmove), abs(cmd->sidemove)); - - if (tweenvalue < 10 && (cmd->buttons & (BT_FORWARD|BT_BACKWARD)) == (BT_FORWARD|BT_BACKWARD)) { - tempangle = (cmd->angleturn << 16); - tweenvalue = 16; - } - - tweenvalue *= tweenvalue*tweenvalue*1536; - - //if (player->pflags & PF_GLIDING) - //tweenvalue >>= 1; - - tempangle -= player->mo->angle; - - if (tempangle < ANGLE_180 && tempangle > tweenvalue) - player->mo->angle += tweenvalue; - else if (tempangle >= ANGLE_180 && InvAngle(tempangle) > tweenvalue) - player->mo->angle -= tweenvalue; - else - player->mo->angle += tempangle; - } -#else - // Less math this way ~Red - player->mo->angle = R_PointToAngle2(0, 0, cmd->forwardmove*FRACUNIT, -cmd->sidemove*FRACUNIT)+tempangle; -#endif - } - // Otherwise, face the direction you're travelling. - else if (player->panim == PA_WALK || player->panim == PA_RUN || player->panim == PA_ROLL - /*|| ((player->mo->state >= &states[S_PLAY_ABL1] && player->mo->state <= &states[S_PLAY_SPC4]) && player->charability == CA_FLY)*/) // SRB2kart - idk - player->mo->angle = R_PointToAngle2(0, 0, player->rmomx, player->rmomy); - - // Update the local angle control. - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - } -#endif - - /////////////////////////// - //BOMB SHIELD ACTIVATION,// - //HOMING, AND OTHER COOL // - //STUFF! // - /////////////////////////// - - /* // SRB2kart - what's a shield? Never heard of it. Never happened. Nope. - if (cmd->buttons & BT_BRAKE) // Spin button effects - { - if (player->pflags & PF_JUMPED) // If the player is jumping - { - if (!(player->pflags & PF_USEDOWN)) // If the player is not holding down BT_BRAKE - { - // Jump shield activation - if (!P_PlayerInPain(player) // If the player is not in pain - && !player->climbing // If the player is not climbing - && !(player->pflags & (PF_GLIDING|PF_SLIDING|PF_THOKKED)) // If the player is not gliding or sliding and hasn't used their ability - && !onground) // If the player isn't on the ground - { - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_JUMP && !player->powers[pw_super]) - P_DoJumpShield(player); - else if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]) && player->charability == CA_FLY) - { - P_DoJumpShield(player); - player->mo->momz *= 2; - } - } - // Bomb shield activation - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_BOMB) - { - // Don't let Super Sonic or invincibility use it - if (!(player->powers[pw_super] || player->powers[pw_invulnerability])) - P_BlackOw(player); - } - } - // Super Sonic move - if (player->skin == 0 && player->powers[pw_super] && player->speed > FixedMul(5<mo->scale) - && P_MobjFlip(player->mo)*player->mo->momz <= 0) - { - if (player->panim == PA_ROLL || player->mo->state == &states[S_PLAY_PAIN]) - P_SetPlayerMobjState(player->mo, S_PLAY_SUPERWALK1); - - player->mo->momz = 0; - player->pflags &= ~PF_SPINNING; - player->jumping = 0; // don't cut jump height after bouncing off something - } - } - } - - // HOMING option. - if (player->charability == CA_HOMINGTHOK) - { - // If you've got a target, chase after it! - if (player->homing && player->mo->tracer) - { - P_SpawnThokMobj(player); - P_HomingAttack(player->mo, player->mo->tracer); - - // But if you don't, then stop homing. - if (player->mo->tracer->health <= 0 || (player->mo->tracer->flags2 & MF2_FRET)) - { - if (player->mo->eflags & MFE_UNDERWATER) - P_SetObjectMomZ(player->mo, FixedDiv(457*FRACUNIT,72*FRACUNIT), false); - else - P_SetObjectMomZ(player->mo, 10*FRACUNIT, false); - - player->mo->momx = player->mo->momy = player->homing = 0; - - if (player->mo->tracer->flags2 & MF2_FRET) - P_InstaThrust(player->mo, player->mo->angle, -(player->speed>>3)); - - if (!(player->mo->tracer->flags & MF_BOSS)) - player->pflags &= ~PF_THOKKED; - } - } - - // If you're not jumping, then you obviously wouldn't be homing. - if (!(player->pflags & PF_JUMPED)) - player->homing = 0; - } - else - player->homing = 0; - - if (player->climbing == 1) - P_DoClimbing(player); - - if (player->climbing > 1) - { - P_InstaThrust(player->mo, player->mo->angle, FixedMul(4*FRACUNIT, player->mo->scale)); // Shove up against the wall - player->climbing--; - } - - if (!player->climbing) - { - player->lastsidehit = -1; - player->lastlinehit = -1; - } - - // Make sure you're not teetering when you shouldn't be. - if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER]) - && (player->mo->momx || player->mo->momy || player->mo->momz)) - P_SetPlayerMobjState(player->mo, S_PLAY_STND); - - // Check for teeter! - if (!(player->mo->momz || player->mo->momx || player->mo->momy) && !(player->mo->eflags & MFE_GOOWATER) - && player->panim == PA_IDLE && !(player->pflags & (PF_CARRIED|PF_ITEMHANG|PF_ROPEHANG))) - P_DoTeeter(player); - - // Toss a flag - if (G_GametypeHasTeams() && (cmd->buttons & BT_SPECTATE) && !(player->powers[pw_super]) && !(player->tossdelay)) - { - if (!(player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - P_PlayerEmeraldBurst(player, true); // Toss emeralds - else - P_PlayerFlagBurst(player, true); - } - - // check for fire - if (!player->exiting) - P_DoFiring(player, cmd); - - { - fixed_t oldheight = player->mo->height; - - // Less height while spinning. Good for spinning under things...? - if ((player->mo->state == &states[player->mo->info->painstate] || player->mo->state == &states[S_PLAY_SUPERHIT]) - || (player->charability2 == CA2_SPINDASH && (player->pflags & (PF_SPINNING|PF_JUMPED))) - || player->powers[pw_tailsfly] || player->pflags & PF_GLIDING - || (player->charability == CA_FLY && (player->mo->state >= &states[S_PLAY_SPC1] && player->mo->state <= &states[S_PLAY_SPC4]))) - player->mo->height = P_GetPlayerSpinHeight(player); - else - player->mo->height = P_GetPlayerHeight(player); - - if (player->mo->eflags & MFE_VERTICALFLIP && player->mo->height != oldheight) // adjust z height for reverse gravity, similar to how it's done for scaling - player->mo->z -= player->mo->height - oldheight; - } - */ // Crush test... if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) && !(player->mo->flags & MF_NOCLIP)) { - /* // SRB2kart - no, we're not making the playerspin - if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SPINNING)) - { - player->pflags |= PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - else */if (player->mo->ceilingz - player->mo->floorz < player->mo->height) + if (player->mo->ceilingz - player->mo->floorz < player->mo->height) { if ((netgame || multiplayer) && player->spectator) P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators else { K_SquishPlayer(player, NULL, NULL); // SRB2kart - we don't kill when squished, we squish when squished. - /* - mobj_t *killer = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_NULL); - killer->threshold = 44; // Special flag that it was crushing which killed you. - P_DamageMobj(player->mo, killer, killer, 10000); - */ } if (player->playerstate == PST_DEAD) @@ -6626,200 +3229,6 @@ static void P_DoZoomTube(player_t *player) #endif } -// -// P_DoRopeHang -// -// Kinda like P_DoZoomTube -// but a little different. -// -/* -static void P_DoRopeHang(player_t *player) // SRB2kart - unused. -{ - INT32 sequence; - fixed_t speed; - thinker_t *th; - mobj_t *mo2; - mobj_t *waypoint = NULL; - fixed_t dist; - fixed_t playerz; - - player->mo->height = P_GetPlayerHeight(player); - - // Play the 'clink' sound only if the player is moving. - if (!(leveltime & 7) && player->speed) - S_StartSound(player->mo, sfx_s3k55); - - playerz = player->mo->z + player->mo->height; - - speed = abs(player->speed); - - sequence = player->mo->tracer->threshold; - - // change slope - dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); - - if (dist < 1) - dist = 1; - - player->mo->momx = FixedMul(FixedDiv(player->mo->tracer->x - player->mo->x, dist), (speed)); - player->mo->momy = FixedMul(FixedDiv(player->mo->tracer->y - player->mo->y, dist), (speed)); - player->mo->momz = FixedMul(FixedDiv(player->mo->tracer->z - playerz, dist), (speed)); - - if (player->cmd.buttons & BT_USE && !(player->pflags & PF_STASIS)) // Drop off of the rope - { - P_SetTarget(&player->mo->tracer, NULL); - - player->pflags |= PF_JUMPED; - player->pflags &= ~PF_ROPEHANG; - - if (!(player->pflags & PF_SLIDING) && (player->pflags & PF_JUMPED) - && !(player->panim == PA_ROLL) && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - return; - } - - // If not allowed to move, we're done here. - if (!speed) - return; - - // Calculate the distance between the player and the waypoint - // 'dist' already equals this. - - // Will the player go past the waypoint? - if (speed > dist) - { - speed -= dist; - // If further away, set XYZ of player to waypoint location - P_UnsetThingPosition(player->mo); - player->mo->x = player->mo->tracer->x; - player->mo->y = player->mo->tracer->y; - player->mo->z = player->mo->tracer->z - player->mo->height; - playerz = player->mo->tracer->z; - P_SetThingPosition(player->mo); - - CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n"); - - // Find next waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == sequence) - { - if (mo2->health == player->mo->tracer->health + 1) - { - waypoint = mo2; - break; - } - } - } - - if (!(player->mo->tracer->flags & MF_SLIDEME) && !waypoint) - { - CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found, wrapping to start...\n"); - - // Wrap around back to first waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == sequence) - { - if (mo2->health == 0) - { - waypoint = mo2; - break; - } - } - } - } - - if (waypoint) - { - CONS_Debug(DBG_GAMELOGIC, "Found waypoint (sequence %d, number %d).\n", waypoint->threshold, waypoint->health); - - P_SetTarget(&player->mo->tracer, waypoint); - - // calculate MOMX/MOMY/MOMZ for next waypoint - // change slope - dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz); - - if (dist < 1) - dist = 1; - - player->mo->momx = FixedMul(FixedDiv(player->mo->tracer->x - player->mo->x, dist), (speed)); - player->mo->momy = FixedMul(FixedDiv(player->mo->tracer->y - player->mo->y, dist), (speed)); - player->mo->momz = FixedMul(FixedDiv(player->mo->tracer->z - playerz, dist), (speed)); - } - else - { - if (player->mo->tracer->flags & MF_SLIDEME) - { - player->pflags |= PF_JUMPED; - player->pflags &= ~PF_ROPEHANG; - - if (!(player->pflags & PF_SLIDING) && (player->pflags & PF_JUMPED) - && !(player->panim == PA_ROLL) && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - - P_SetTarget(&player->mo->tracer, NULL); - - CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found!\n"); - } - } -} -*/ - -#if 0 -// -// P_NukeAllPlayers -// -// Hurts all players -// source = guy who gets the credit -// -static void P_NukeAllPlayers(player_t *player) -{ - mobj_t *mo; - thinker_t *think; - - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (!mo->player) - continue; - - if (mo->health <= 0) // dead - continue; - - if (mo == player->mo) - continue; - - P_DamageMobj(mo, player->mo, player->mo, 1); - } - - CONS_Printf(M_GetText("%s caused a world of pain.\n"), player_names[player-players]); - - return; -} -#endif - // // P_NukeEnemies // Looks for something you can hit - Used for bomb shield @@ -7964,13 +4373,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (myceilingz != myfloorz && myceilingz - thiscam->height < z) { -/* // no fit - if (!resetcalled && !cameranoclip) - { - P_ResetCamera(player, thiscam); - return true; - } -*/ z = myceilingz - thiscam->height-FixedMul(11*FRACUNIT, mo->scale); // is the camera fit is there own sector } @@ -8297,25 +4699,6 @@ static void P_CalcPostImg(player_t *player) *type = postimg_mirror; } -/*void P_DoPityCheck(player_t *player) -{ - // No pity outside of match or CTF. - if (player->spectator - || !(gametype == GT_MATCH || gametype == GT_TEAMMATCH || gametype == GT_CTF)) - return; - - // Apply pity shield if available. - if ((player->pity >= 3 || player->pity < 0) && player->powers[pw_shield] == SH_NONE) - { - if (player->pity > 0) - S_StartSound(player->mo, mobjinfo[MT_PITYSHIELDICO].seesound); - - player->pity = 0; - player->powers[pw_shield] = SH_PITY; - P_SpawnShieldOrb(player); - } -}*/ - void P_DoTimeOver(player_t *player) { if (netgame && player->health > 0) @@ -8521,16 +4904,6 @@ void P_PlayerThink(player_t *player) player->awayviewtics = 0; // reset to zero } - /* - if (player->pflags & PF_GLIDING) - { - if (player->panim != PA_ABILITY) - P_SetPlayerMobjState(player->mo, S_PLAY_ABL1); - } - else if ((player->pflags & PF_JUMPED) && !player->powers[pw_super] && player->panim != PA_ROLL && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - */ - if (player->flashcount) player->flashcount--; @@ -8592,16 +4965,6 @@ void P_PlayerThink(player_t *player) if (i == MAXPLAYERS && player->exiting == raceexittime+2) // finished player->exiting = raceexittime+1; - // If 10 seconds are left on the timer, - // begin the drown music for countdown! - - // SRB2Kart: despite how perfect this is, it's disabled FOR A REASON - /*if (racecountdown == 11*TICRATE - 1) - { - if (P_IsLocalPlayer(player)) - S_ChangeMusicInternal("drown", false); - }*/ - // If you've hit the countdown and you haven't made // it to the exit, you're a goner! else if (racecountdown == 1 && !player->exiting && !player->spectator && player->lives > 0) @@ -8692,28 +5055,11 @@ void P_PlayerThink(player_t *player) player->health = 1; } -#if 0 - if ((netgame || multiplayer) && player->lives <= 0) - { - // In Co-Op, replenish a user's lives if they are depleted. - // of course, this is just a cheap hack, meh... - player->lives = cv_startinglives.value; - } -#else player->lives = 1; // SRB2Kart -#endif // SRB2kart 010217 if (leveltime < starttime) player->powers[pw_nocontrol] = 2; - /* - if ((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE) - { - cmd->buttons &= BT_BRAKE; // Remove all buttons except BT_BRAKE - cmd->forwardmove = 0; - cmd->sidemove = 0; - } - */ // Synchronizes the "real" amount of time spent in the level. if (!player->exiting) @@ -8851,25 +5197,8 @@ void P_PlayerThink(player_t *player) player->mo->reactiontime--; else if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) { - // SRB2kart - don't need no rope hangin' - //if (player->pflags & PF_ROPEHANG) - //{ - // if (!P_AnalogMove(player)) - // player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); - - // ticruned++; - // if ((cmd->angleturn & TICCMD_RECEIVED) == 0) - // ticmiss++; - - // P_DoRopeHang(player); - // P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); - // P_DoJumpStuff(player, &player->cmd); - //} - //else { P_DoZoomTube(player); - //if (!(player->panim == PA_ROLL) && player->charability2 == CA2_SPINDASH) // SRB2kart - // P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); } player->rmomx = player->rmomy = 0; // no actual momentum from your controls P_ResetScore(player); @@ -8969,23 +5298,6 @@ void P_PlayerThink(player_t *player) if (player->powers[pw_tailsfly] && player->powers[pw_tailsfly] < UINT16_MAX /*&& player->charability != CA_SWIM*/ && !(player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) // tails fly counter player->powers[pw_tailsfly]--; - /* // SRB2kart - Can't drown. - if (player->powers[pw_underwater] && (player->pflags & PF_GODMODE || (player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL)) - { - if (player->powers[pw_underwater] <= 12*TICRATE+1) - P_RestoreMusic(player); //incase they were about to drown - - player->powers[pw_underwater] = 0; - } - else if (player->powers[pw_underwater] && !(maptol & TOL_NIGHTS) && !((netgame || multiplayer) && player->spectator)) // underwater timer - player->powers[pw_underwater]--; - - if (player->powers[pw_spacetime] && (player->pflags & PF_GODMODE || (player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL)) - player->powers[pw_spacetime] = 0; - else if (player->powers[pw_spacetime] && !(maptol & TOL_NIGHTS) && !((netgame || multiplayer) && player->spectator)) // underwater timer - player->powers[pw_spacetime]--; - */ - if (player->powers[pw_gravityboots] && player->powers[pw_gravityboots] < UINT16_MAX) player->powers[pw_gravityboots]--; @@ -9086,42 +5398,6 @@ void P_PlayerThink(player_t *player) LUAh_PlayerThink(player); #endif -/* -// Colormap verification - { - INT32 i,j; - sector_t *controlsec; - for (j=0; jtag) - break; - } - - if (i == numlines) - CONS_Debug(DBG_GAMELOGIC, "%d, %d\n", j, sectors[j].tag); - } - } - - I_Error("I'm done!\n"); - }*/ -} // // P_PlayerAfterThink @@ -9174,229 +5450,10 @@ void P_PlayerAfterThink(player_t *player) //player->mo->eflags &= ~MFE_VERTICALFLIP; } - /* SRB2kart - don't need no weapon rings - if (!(player->pflags & PF_WPNDOWN)) - { - if (cmd->buttons & BT_WEAPONNEXT) - { - player->currentweapon++; - player->currentweapon %= NUM_WEAPONS; - player->pflags |= PF_WPNDOWN; - } - - if (cmd->buttons & BT_WEAPONPREV) - { - player->currentweapon--; - if (player->currentweapon < 0) - player->currentweapon = NUM_WEAPONS - 1; - player->pflags |= PF_WPNDOWN; - - if (player->currentweapon == WEP_RAIL && (!(player->ringweapons & RW_RAIL) || !player->powers[pw_railring])) - player->currentweapon--; - if (player->currentweapon == WEP_EXPLODE && (!(player->ringweapons & RW_EXPLODE) || !player->powers[pw_explosionring])) - player->currentweapon--; - if (player->currentweapon == WEP_GRENADE && (!(player->ringweapons & RW_GRENADE) || !player->powers[pw_grenadering])) - player->currentweapon--; - if (player->currentweapon == WEP_SCATTER && (!(player->ringweapons & RW_SCATTER) || !player->powers[pw_scatterring])) - player->currentweapon--; - if (player->currentweapon == WEP_BOUNCE && (!(player->ringweapons & RW_BOUNCE) || !player->powers[pw_bouncering])) - player->currentweapon--; - if (player->currentweapon == WEP_AUTO && (!(player->ringweapons & RW_AUTO) || !player->powers[pw_automaticring])) - player->currentweapon = 0; - } - - if (cmd->buttons & BT_WEAPONMASK) - { - //Read the bits to determine individual weapon ring selection. - INT32 weapon = (cmd->buttons & BT_WEAPONMASK); - - switch (weapon) - { - case 1: //normal / infinity - player->currentweapon = 0; - player->pflags |= PF_WPNDOWN; - break; - case 2: //automatic - if ((player->ringweapons & RW_AUTO) && player->powers[pw_automaticring]) - { - player->currentweapon = WEP_AUTO; - player->pflags |= PF_WPNDOWN; - } - break; - case 3: //bounce - if ((player->ringweapons & RW_BOUNCE) && player->powers[pw_bouncering]) - { - player->currentweapon = WEP_BOUNCE; - player->pflags |= PF_WPNDOWN; - } - break; - case 4: //scatter - if ((player->ringweapons & RW_SCATTER) && player->powers[pw_scatterring]) - { - player->currentweapon = WEP_SCATTER; - player->pflags |= PF_WPNDOWN; - } - break; - case 5: //grenade - if ((player->ringweapons & RW_GRENADE) && player->powers[pw_grenadering]) - { - player->currentweapon = WEP_GRENADE; - player->pflags |= PF_WPNDOWN; - } - break; - case 6: //explosion - if ((player->ringweapons & RW_EXPLODE) && player->powers[pw_explosionring]) - { - player->currentweapon = WEP_EXPLODE; - player->pflags |= PF_WPNDOWN; - } - break; - case 7: //rail - if ((player->ringweapons & RW_RAIL) && player->powers[pw_railring]) - { - player->currentweapon = WEP_RAIL; - player->pflags |= PF_WPNDOWN; - } - break; - } - } - } - - if (!(cmd->buttons & (BT_WEAPONNEXT|BT_WEAPONPREV|BT_WEAPONMASK))) - player->pflags &= ~PF_WPNDOWN; - - // Weapon cycling if out of ammo for a certain weapon - if (player->currentweapon == WEP_AUTO && (!(player->ringweapons & RW_AUTO) || !player->powers[pw_automaticring])) - player->currentweapon++; - if (player->currentweapon == WEP_BOUNCE && (!(player->ringweapons & RW_BOUNCE) || !player->powers[pw_bouncering])) - player->currentweapon++; - if (player->currentweapon == WEP_SCATTER && (!(player->ringweapons & RW_SCATTER) || !player->powers[pw_scatterring])) - player->currentweapon++; - if (player->currentweapon == WEP_GRENADE && (!(player->ringweapons & RW_GRENADE) || !player->powers[pw_grenadering])) - player->currentweapon++; - if (player->currentweapon == WEP_EXPLODE && (!(player->ringweapons & RW_EXPLODE) || !player->powers[pw_explosionring])) - player->currentweapon++; - if (player->currentweapon == WEP_RAIL && (!(player->ringweapons & RW_RAIL) || !player->powers[pw_railring])) - player->currentweapon = 0; - - // If you're out of rings, but have Infinity Rings left, switch to that. - if (player->currentweapon != 0 && player->health <= 1 && player->powers[pw_infinityring]) - player->currentweapon = 0; - - if (P_IsLocalPlayer(player) && (player->pflags & PF_WPNDOWN) && player->currentweapon != oldweapon) - S_StartSound(NULL, sfx_wepchg); - */ - - /* // SRB2kart - if (player->pflags & PF_GLIDING) - { - if (player->panim != PA_ABILITY) - P_SetPlayerMobjState(player->mo, S_PLAY_ABL1); - } - else */ if (player->pflags & PF_SLIDING) P_SetPlayerMobjState(player->mo, player->mo->info->painstate); - /*else if (player->pflags & PF_JUMPED - && ((!player->powers[pw_super] && player->panim != PA_ROLL) - || player->mo->state == &states[player->mo->info->painstate]) - && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1);*/ - /* // SRB2kart - fight! fight! fight! - if (player->pflags & PF_CARRIED && player->mo->tracer) - { - player->mo->height = FixedDiv(P_GetPlayerHeight(player), FixedDiv(14*FRACUNIT,10*FRACUNIT)); - - // State check for the carrier - Flame - // You are an IDIOT, those aren't even the right frames! >_> - JTE - if (player->mo->tracer->player - && !(player->mo->tracer->state >= &states[S_PLAY_ABL1] - && player->mo->tracer->state <= &states[S_PLAY_SPC4])) - player->pflags &= ~PF_CARRIED; - - if (player->mo->eflags & MFE_VERTICALFLIP) - { - if ((player->mo->tracer->z + player->mo->tracer->height + player->mo->height + FixedMul(FRACUNIT, player->mo->scale)) <= player->mo->tracer->ceilingz - && (player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Reverse gravity check for the carrier - Flame - player->mo->z = player->mo->tracer->z + player->mo->tracer->height + FixedMul(FRACUNIT, player->mo->scale); - else - player->pflags &= ~PF_CARRIED; - } - else - { - if ((player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale)) >= player->mo->tracer->floorz - && !(player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Correct gravity check for the carrier - Flame - player->mo->z = player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale); - else - player->pflags &= ~PF_CARRIED; - } - - if (player->mo->tracer->health <= 0) - player->pflags &= ~PF_CARRIED; - else - { - P_TryMove(player->mo, player->mo->tracer->x, player->mo->tracer->y, true); - player->mo->momx = player->mo->tracer->momx; - player->mo->momy = player->mo->tracer->momy; - player->mo->momz = player->mo->tracer->momz; - } - - if (gametype == GT_COOP) - { - player->mo->angle = player->mo->tracer->angle; - - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; - } - - if (P_AproxDistance(player->mo->x - player->mo->tracer->x, player->mo->y - player->mo->tracer->y) > player->mo->radius) - player->pflags &= ~PF_CARRIED; - - P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); - - //if (player-players == consoleplayer && botingame) - //CV_SetValue(&cv_analog2, !(player->pflags & PF_CARRIED)); - } - else if (player->pflags & PF_ITEMHANG && player->mo->tracer) - { - // tracer is what you're hanging onto - P_UnsetThingPosition(player->mo); - player->mo->x = player->mo->tracer->x; - player->mo->y = player->mo->tracer->y; - if (player->mo->eflags & MFE_VERTICALFLIP) - player->mo->z = player->mo->tracer->z + player->mo->tracer->height - FixedDiv(player->mo->height, 3*FRACUNIT); - else - player->mo->z = player->mo->tracer->z - FixedDiv(player->mo->height, 3*FRACUNIT/2); - player->mo->momx = player->mo->momy = player->mo->momz = 0; - P_SetThingPosition(player->mo); - P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); - - // Controllable missile - if (player->mo->tracer->type == MT_BLACKEGGMAN_MISSILE) - { - if (cmd->forwardmove > 0) - player->mo->tracer->momz += FixedMul(FRACUNIT/4, player->mo->tracer->scale); - else if (cmd->forwardmove < 0) - player->mo->tracer->momz -= FixedMul(FRACUNIT/4, player->mo->tracer->scale); - - player->mo->tracer->angle = player->mo->angle; - P_InstaThrust(player->mo->tracer, player->mo->tracer->angle, FixedMul(player->mo->tracer->info->speed, player->mo->tracer->scale)); - - if (player->mo->z <= player->mo->floorz - || player->mo->tracer->health <= 0) - { - player->pflags &= ~PF_ITEMHANG; - P_SetTarget(&player->mo->tracer, NULL); - } - } - } - else */if (player->pflags & PF_MACESPIN && player->mo->tracer && player->mo->tracer->target) + if (player->pflags & PF_MACESPIN && player->mo->tracer && player->mo->tracer->target) { player->mo->height = P_GetPlayerSpinHeight(player); // tracer is what you're hanging onto.... -- 2.54.0 From 804b0c2d67b24d75d9a081066badfd04fd2544ed Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Feb 2024 22:11:32 +0100 Subject: [PATCH 40/70] oopsie --- src/p_user.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 5be9f9a7d..99640c30a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2260,9 +2260,7 @@ static void P_CheckInvincibilityTimer(player_t *player) if (!player->powers[pw_invulnerability] && !player->kartstuff[k_invincibilitytimer]) return; - { - player->mo->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); - } + player->mo->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); // Resume normal music stuff. if (player->powers[pw_invulnerability] == 1 || player->kartstuff[k_invincibilitytimer] == 1) @@ -2278,11 +2276,11 @@ static void P_CheckInvincibilityTimer(player_t *player) P_SpawnShieldOrb(player); } - if (!player->powers[pw_super] || (mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC))*/ - P_RestoreMusic(player); + P_RestoreMusic(player); } } + // // P_DoBubbleBreath // @@ -5397,7 +5395,7 @@ void P_PlayerThink(player_t *player) #ifdef HAVE_BLUA LUAh_PlayerThink(player); #endif - +} // // P_PlayerAfterThink -- 2.54.0 From b49a46646c9af6fb0e6c694688138fc010315d81 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Feb 2024 22:16:52 +0100 Subject: [PATCH 41/70] missed those --- src/p_user.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 99640c30a..e92efcfe4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1843,15 +1843,6 @@ void P_DoPlayerExit(player_t *player) else player->exiting = raceexittime+2; // Accidental death safeguard??? - //player->pflags &= ~PF_GLIDING; - /* // SRB2kart - don't need - if (player->climbing) - { - player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } - */ player->powers[pw_underwater] = 0; player->powers[pw_spacetime] = 0; player->kartstuff[k_cardanimation] = 0; // srb2kart: reset battle animation @@ -1977,14 +1968,10 @@ static void P_CheckBustableBlocks(player_t *player) // ...or are drilling in NiGHTS (or Metal Sonic) if (!(rover->flags & FF_SHATTER) && !(rover->flags & FF_SPINBUST) && !((player->pflags & PF_SPINNING) && !(player->pflags & PF_JUMPED)) - && (/*player->charability != CA_GLIDEANDCLIMB &&*/ !player->powers[pw_super]) + && (!player->powers[pw_super]) && !(player->pflags & PF_DRILLING) && !metalrecording) continue; - // Only Knuckles can break this rock... - /*if (!(rover->flags & FF_SHATTER) && (rover->flags & FF_ONLYKNUX) && !(player->charability == CA_GLIDEANDCLIMB)) - continue;*/ - topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); -- 2.54.0 From ec80a4ccda59585f8f7befc3efde22a2e17fc1ee Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 03:50:43 +0100 Subject: [PATCH 42/70] OpenGL: Fix linedef type 10 not culling FOFs --- src/hardware/hw_main.c | 132 +++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2ca8f2a79..56b2b7220 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3372,6 +3372,47 @@ void HWR_AddPolyObjectPlanes(void) #endif #endif + +// +// HWR_DoCulling +// Hardware version of R_DoCulling +// (see r_main.c) +static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float vz, float bottomh, float toph) +{ + float cullplane; + + if (!cullheight) + return false; + + cullplane = FIXED_TO_FLOAT(cullheight->frontsector->floorheight); + if (cullheight->flags & ML_NOCLIMB) // Group culling + { + if (!viewcullheight) + return false; + + // Make sure this is part of the same group + if (viewcullheight->frontsector == cullheight->frontsector) + { + // OK, we can cull + if (vz > cullplane && toph < cullplane) // Cull if below plane + return true; + + if (bottomh > cullplane && vz <= cullplane) // Cull if above plane + return true; + } + } + else // Quick culling + { + if (vz > cullplane && toph < cullplane) // Cull if below plane + return true; + + if (bottomh > cullplane && vz <= cullplane) // Cull if above plane + return true; + } + + return false; +} + // -----------------+ // HWR_Subsector : Determine floor/ceiling planes. // : Add sprites of things in sector. @@ -3553,34 +3594,35 @@ void HWR_Subsector(size_t num) for (rover = gr_frontsector->ffloors; rover; rover = rover->next) { - fixed_t cullHeight, centerHeight; - - // bottom plane -#ifdef ESLOPE - if (*rover->b_slope) - { - cullHeight = P_GetZAt(*rover->b_slope, viewx, viewy); - centerHeight = P_GetZAt(*rover->b_slope, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - } - else -#endif - cullHeight = centerHeight = *rover->bottomheight; + fixed_t bottomCullHeight, topCullHeight, centerHeight; if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) continue; if (sub->validcount == validcount) continue; + + // rendering heights for bottom and top planes + bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); + topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); + + if (gr_frontsector->cullheight) + { + if (HWR_DoCulling(gr_frontsector->cullheight, viewsector->cullheight, gr_viewz, FIXED_TO_FLOAT(bottomCullHeight), FIXED_TO_FLOAT(topCullHeight))) + continue; + } - if (centerHeight <= locCeilingHeight && - centerHeight >= locFloorHeight && - ((viewz < cullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > cullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + // bottom plane + centerHeight = P_GetFFloorBottomZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); + + if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight && + ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { UINT8 alpha; - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); @@ -3594,7 +3636,7 @@ void HWR_Subsector(size_t num) } else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) // SoM: Flags are more efficient { - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum, &extrasubsectors[num], false, @@ -3606,7 +3648,7 @@ void HWR_Subsector(size_t num) else { HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gr_frontsector, false)); - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->bottompic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } @@ -3616,23 +3658,22 @@ void HWR_Subsector(size_t num) #ifdef ESLOPE if (*rover->t_slope) { - cullHeight = P_GetZAt(*rover->t_slope, viewx, viewy); centerHeight = P_GetZAt(*rover->t_slope, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); } else #endif - cullHeight = centerHeight = *rover->topheight; + centerHeight = *rover->topheight; if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight && - ((viewz > cullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < cullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { UINT8 alpha; - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false); alpha = HWR_FogBlockAlpha(SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), rover->master->frontsector->extra_colormap); @@ -3646,7 +3687,7 @@ void HWR_Subsector(size_t num) } else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false); HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, &extrasubsectors[num], true, @@ -3658,7 +3699,7 @@ void HWR_Subsector(size_t num) else { HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gr_frontsector, true)); - light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < cullHeight ? true : false); + light = R_GetPlaneLight(gr_frontsector, centerHeight, viewz < topCullHeight ? true : false); HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, SOFTLIGHT(*gr_frontsector->lightlist[light].lightlevel), levelflats[*rover->toppic].lumpnum, rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); } @@ -3912,45 +3953,6 @@ static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t hei return floorz; } -// -// HWR_DoCulling -// Hardware version of R_DoCulling -// (see r_main.c) -static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float vz, float bottomh, float toph) -{ - float cullplane; - - if (!cullheight) - return false; - - cullplane = FIXED_TO_FLOAT(cullheight->frontsector->floorheight); - if (cullheight->flags & ML_NOCLIMB) // Group culling - { - if (!viewcullheight) - return false; - - // Make sure this is part of the same group - if (viewcullheight->frontsector == cullheight->frontsector) - { - // OK, we can cull - if (vz > cullplane && toph < cullplane) // Cull if below plane - return true; - - if (bottomh > cullplane && vz <= cullplane) // Cull if above plane - return true; - } - } - else // Quick culling - { - if (vz > cullplane && toph < cullplane) // Cull if below plane - return true; - - if (bottomh > cullplane && vz <= cullplane) // Cull if above plane - return true; - } - - return false; -} static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float this_scale) { -- 2.54.0 From 622e0c12fe940b5afb88c03cadc820092eb99846 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 04:11:39 +0100 Subject: [PATCH 43/70] forgor this --- src/hardware/hw_main.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 56b2b7220..9202216a4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3602,9 +3602,10 @@ void HWR_Subsector(size_t num) continue; // rendering heights for bottom and top planes + // yes there were functions for this stuff, no idea why it wasnt used but bleh bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - + if (gr_frontsector->cullheight) { if (HWR_DoCulling(gr_frontsector->cullheight, viewsector->cullheight, gr_viewz, FIXED_TO_FLOAT(bottomCullHeight), FIXED_TO_FLOAT(topCullHeight))) @@ -3655,14 +3656,7 @@ void HWR_Subsector(size_t num) } // top plane -#ifdef ESLOPE - if (*rover->t_slope) - { - centerHeight = P_GetZAt(*rover->t_slope, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - } - else -#endif - centerHeight = *rover->topheight; + centerHeight = P_GetFFloorTopZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight && -- 2.54.0 From 05accd5acaff2cdfcd88288ca05e4babf2bacc03 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 17:41:52 +0100 Subject: [PATCH 44/70] kill eslope --- src/doomdef.h | 3 - src/hardware/hw_main.c | 431 ++++++---------------------------------- src/hardware/hw_trick.c | 4 - src/p_map.c | 7 - src/r_segs.c | 5 - 5 files changed, 64 insertions(+), 386 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 8e77e87ae..bb7a63412 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -561,9 +561,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -/// Kalaron/Eternity Engine slope code (SRB2CB ported) -#define ESLOPE - /// Backwards compatibility with SRB2CB's slope linedef types. /// \note A simple shim that prints a warning. #define ESLOPE_TYPESHIM diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9202216a4..8a1f42934 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -44,10 +44,7 @@ #include "../i_system.h" #include "../m_cheat.h" #include "../m_argv.h" // parm functions for msaa - -#ifdef ESLOPE #include "../p_slopes.h" -#endif #include // qsort @@ -655,9 +652,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc angle_t angle = 0; FSurfaceInfo Surf; fixed_t tempxsow, tempytow; -#ifdef ESLOPE pslope_t *slope = NULL; -#endif static FOutVector *planeVerts = NULL; static UINT16 numAllocedPlaneVerts = 0; @@ -668,7 +663,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc if (!xsub->planepoly) return; -#ifdef ESLOPE + // Get the slope pointer to simplify future code if (FOFsector) { @@ -688,7 +683,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc // Set fixedheight to the slope's height from our viewpoint, if we have a slope if (slope) fixedheight = P_GetZAt(slope, viewx, viewy); -#endif height = FIXED_TO_FLOAT(fixedheight); @@ -822,10 +816,8 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc for (i = 0, v3d = planeVerts; i < nrPlaneVerts; i++,v3d++,pv++) SETUP3DVERT(v3d, pv->x, pv->y); -#ifdef ESLOPE if (slope) lightlevel = HWR_CalcSlopeLight(lightlevel, R_PointToAngle2(0, 0, slope->normal.x, slope->normal.y), abs(slope->zdelta)); -#endif HWR_Lighting(&Surf, lightlevel, planecolormap); @@ -1073,7 +1065,6 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, float pegt, pegb, pegmul; float height = 0.0f, bheight = 0.0f; -#ifdef ESLOPE float endrealtop, endrealbot, endtop, endbot; float endpegt, endpegb, endpegmul; float endheight = 0.0f, endbheight = 0.0f; @@ -1084,7 +1075,6 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, fixed_t v1y = FloatToFixed(wallVerts[0].z); fixed_t v2x = FloatToFixed(wallVerts[1].x); fixed_t v2y = FloatToFixed(wallVerts[1].z); -#endif const UINT8 alpha = Surf->PolyColor.s.alpha; FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y); @@ -1106,20 +1096,15 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else pegmul = (pegb - pegt) / diff; -#ifdef ESLOPE endrealtop = endtop = wallVerts[2].y; endrealbot = endbot = wallVerts[1].y; endpegt = wallVerts[2].t; endpegb = wallVerts[1].t; endpegmul = (endpegb - endpegt) / (endtop - endbot); -#endif for (INT32 i = 0; i < sector->numlights; i++) { -#ifdef ESLOPE - if (endtop < endrealbot) -#endif - if (top < realbot) + if (endtop < endrealbot && top < realbot) return; lightlist_t *list = sector->lightlist; @@ -1169,7 +1154,6 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else solid = false; -#ifdef ESLOPE if (list[i].slope) { height = FixedToFloat(P_GetZAt(list[i].slope, v1x, v1y)); @@ -1188,26 +1172,16 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else bheight = endbheight = FIXED_TO_FLOAT(*list[i].caster->bottomheight); } -#else - height = FIXED_TO_FLOAT(list[i].height); - if (solid) - bheight = FIXED_TO_FLOAT(*list[i].caster->bottomheight); -#endif -#ifdef ESLOPE - if (endheight >= endtop) -#endif - if (height >= top) + if (endheight >= endtop && height >= top) { if (solid && top > bheight) top = bheight; -#ifdef ESLOPE + if (solid && endtop > endbheight) endtop = endbheight; -#endif } -#ifdef ESLOPE if (i + 1 < sector->numlights) { if (list[i+1].slope) @@ -1223,60 +1197,42 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, bheight = realbot; endbheight = endrealbot; } -#else - if (i + 1 < sector->numlights) + + if (cv_splitwallfix.value) { - bheight = FIXED_TO_FLOAT(list[i+1].height); + if (endbheight > endtop) + endbot = endtop; + + if (bheight >= top) + continue; + + //Found a break; + bot = bheight; + + if (bot < realbot) + bot = realbot; + + endbot = min(max(endbheight, endrealbot), endtop); } else { - bheight = realbot; + if (endbheight >= endtop && bheight >= top) + continue; + + //Found a break; + bot = bheight; + + if (bot < realbot) + bot = realbot; + + endbot = endbheight; + + if (endbot < endrealbot) + endbot = endrealbot; } -#endif - - if (cv_splitwallfix.value) - { -#ifdef ESLOPE - if (endbheight > endtop) - endbot = endtop; -#endif - if (bheight >= top) - continue; - - //Found a break; - bot = bheight; - - if (bot < realbot) - bot = realbot; - -#ifdef ESLOPE - endbot = min(max(endbheight, endrealbot), endtop); -#endif - }else{ -#ifdef ESLOPE - if (endbheight >= endtop) -#endif - if (bheight >= top) - continue; - - //Found a break; - bot = bheight; - - if (bot < realbot) - bot = realbot; - -#ifdef ESLOPE - endbot = endbheight; - - if (endbot < endrealbot) - endbot = endrealbot; -#endif - } - Surf->PolyColor.s.alpha = alpha; -#ifdef ESLOPE wallVerts[3].t = pegt + ((realtop - top) * pegmul); wallVerts[2].t = endpegt + ((endrealtop - endtop) * endpegmul); wallVerts[0].t = pegt + ((realtop - bot) * pegmul); @@ -1287,14 +1243,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, wallVerts[2].y = endtop; wallVerts[0].y = bot; wallVerts[1].y = endbot; -#else - wallVerts[3].t = wallVerts[2].t = pegt + ((realtop - top) * pegmul); - wallVerts[0].t = wallVerts[1].t = pegt + ((realtop - bot) * pegmul); - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = top; - wallVerts[0].y = wallVerts[1].y = bot; -#endif if (cv_fofzfightfix.value) { if (cutflag & FF_FOG) @@ -1303,7 +1252,9 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); - }else{ + } + else + { if (cutflag & FF_FOG) HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) @@ -1314,22 +1265,16 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, top = bot; -#ifdef ESLOPE endtop = endbot; -#endif } bot = realbot; -#ifdef ESLOPE endbot = endrealbot; - if (endtop <= endrealbot) -#endif - if (top <= realbot) + if (endtop <= endrealbot && top <= realbot) return; Surf->PolyColor.s.alpha = alpha; -#ifdef ESLOPE wallVerts[3].t = pegt + ((realtop - top) * pegmul); wallVerts[2].t = endpegt + ((endrealtop - endtop) * endpegmul); wallVerts[0].t = pegt + ((realtop - bot) * pegmul); @@ -1340,14 +1285,6 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, wallVerts[2].y = endtop; wallVerts[0].y = bot; wallVerts[1].y = endbot; -#else - wallVerts[3].t = wallVerts[2].t = pegt + ((realtop - top) * pegmul); - wallVerts[0].t = wallVerts[1].t = pegt + ((realtop - bot) * pegmul); - - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = top; - wallVerts[0].y = wallVerts[1].y = bot; -#endif if (cv_fofzfightfix.value) { @@ -1357,7 +1294,9 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); - }else{ + } + else + { if (cutflag & FF_FOG) HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture, true, lightnum, colormap); else if (cutflag & FF_TRANSLUCENT) @@ -1457,19 +1396,15 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t worldtop, worldbottom; fixed_t worldhigh = 0, worldlow = 0; -#ifdef ESLOPE fixed_t worldtopslope, worldbottomslope; fixed_t worldhighslope = 0, worldlowslope = 0; fixed_t v1x, v1y, v2x, v2y; -#endif GLMapTexture_t *grTex = NULL; float cliplow = 0.0f, cliphigh = 0.0f; INT32 gr_midtexture; fixed_t h, l; // 3D sides and 2s middle textures -#ifdef ESLOPE fixed_t hS, lS; -#endif FUINT lightnum = 0; // shut up compiler extracolormap_t *colormap; @@ -1501,13 +1436,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom ve.y = FIXED_TO_FLOAT(gr_curline->v2->y); } -#ifdef ESLOPE v1x = FLOAT_TO_FIXED(vs.x); v1y = FLOAT_TO_FIXED(vs.y); v2x = FLOAT_TO_FIXED(ve.x); v2y = FLOAT_TO_FIXED(ve.y); -#endif -#ifdef ESLOPE #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ @@ -1518,10 +1450,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom SLOPEPARAMS(gr_frontsector->c_slope, worldtop, worldtopslope, gr_frontsector->ceilingheight) SLOPEPARAMS(gr_frontsector->f_slope, worldbottom, worldbottomslope, gr_frontsector->floorheight) -#else - worldtop = gr_frontsector->ceilingheight; - worldbottom = gr_frontsector->floorheight; -#endif // remember vertices ordering // 3--2 @@ -1563,13 +1491,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom INT32 gr_toptexture, gr_bottomtexture; // two sided line -#ifdef ESLOPE SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight) -#else - worldhigh = gr_backsector->ceilingheight; - worldlow = gr_backsector->floorheight; -#endif // Sky culling if (!gr_curline->polyseg) // Don't do it for polyobjects @@ -1587,36 +1510,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom && (worldhigh != worldtop || worldhighslope != worldtopslope)) // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race { -#ifdef ESLOPE wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); -#else - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldhigh); -#endif HWR_DrawSkyWall(wallVerts, &Surf); } } else { // Only the frontsector is sky, just draw a skywall from the front ceiling -#ifdef ESLOPE wallVerts[0].y = FIXED_TO_FLOAT(worldtop); wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); -#else - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop); -#endif HWR_DrawSkyWall(wallVerts, &Surf); } } else if (gr_backsector->ceilingpic == skyflatnum) { // Only the backsector is sky, just draw a skywall from the front ceiling -#ifdef ESLOPE wallVerts[0].y = FIXED_TO_FLOAT(worldtop); wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); -#else - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop); -#endif HWR_DrawSkyWall(wallVerts, &Surf); } @@ -1636,39 +1547,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race && !(gr_sidedef->bottomtexture)) { -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldlow); wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); -#else - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(worldlow); -#endif - HWR_DrawSkyWall(wallVerts, &Surf); } } else { // Only the backsector has sky, just draw a skywall from the back floor -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); -#else - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(worldbottom); -#endif - HWR_DrawSkyWall(wallVerts, &Surf); } } else if ((gr_backsector->floorpic == skyflatnum) && !(gr_sidedef->bottomtexture)) { // Only the backsector has sky, just draw a skywall from the back floor if there's no bottomtexture -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldlow); wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); -#else - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(worldlow); -#endif - HWR_DrawSkyWall(wallVerts, &Surf); } @@ -1680,21 +1576,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom && gr_backsector->ceilingpic == skyflatnum) { worldtop = worldhigh; -#ifdef ESLOPE worldtopslope = worldhighslope; -#endif } gr_toptexture = R_GetTextureNum(gr_sidedef->toptexture); gr_bottomtexture = R_GetTextureNum(gr_sidedef->bottomtexture); // check TOP TEXTURE - if (( -#ifdef ESLOPE - worldhighslope < worldtopslope || -#endif - worldhigh < worldtop - ) && gr_toptexture) + if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gr_toptexture) { { fixed_t texturevpegtop; // top @@ -1704,15 +1593,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // PEGGING if (gr_linedef->flags & ML_DONTPEGTOP) texturevpegtop = 0; -#ifdef ESLOPE else if (gr_linedef->flags & ML_EFFECT1) texturevpegtop = worldhigh + textureheight[gr_sidedef->toptexture] - worldtop; else texturevpegtop = gr_backsector->ceilingheight + textureheight[gr_sidedef->toptexture] - gr_frontsector->ceilingheight; -#else - else - texturevpegtop = worldhigh + textureheight[gr_sidedef->toptexture] - worldtop; -#endif texturevpegtop += gr_sidedef->rowoffset; @@ -1724,7 +1608,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; -#ifdef ESLOPE // Adjust t value for sloped walls if (!(gr_linedef->flags & ML_EFFECT1)) { @@ -1747,19 +1630,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * grTex->scaleY; } -#endif } // set top/bottom coords -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); -#else - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldhigh); -#endif if (!gl_drawing_stencil && gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); @@ -1770,11 +1647,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // check BOTTOM TEXTURE - if (( -#ifdef ESLOPE - worldlowslope > worldbottomslope || -#endif - worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! + if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! { { fixed_t texturevpegbottom = 0; // bottom @@ -1782,19 +1655,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); // PEGGING -#ifdef ESLOPE 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; -#else - if (gr_linedef->flags & ML_DONTPEGBOTTOM) - texturevpegbottom = worldbottom - worldlow; - else - texturevpegbottom = 0; -#endif texturevpegbottom += gr_sidedef->rowoffset; @@ -1806,7 +1672,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; -#ifdef ESLOPE // Adjust t value for sloped walls if (!(gr_linedef->flags & ML_EFFECT1)) { @@ -1829,19 +1694,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; } -#endif } // set top/bottom coords -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldlow); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); -#else - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldlow); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldbottom); -#endif if (!gl_drawing_stencil && gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); @@ -1912,19 +1771,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else #endif { -#ifdef ESLOPE popentop = min(worldtop, worldhigh); popenbottom = max(worldbottom, worldlow); popentopslope = min(worldtopslope, worldhighslope); popenbottomslope = max(worldbottomslope, worldlowslope); -#else - popentop = min(front->ceilingheight, back->ceilingheight); - popenbottom = max(front->floorheight, back->floorheight); -#endif } -#ifdef ESLOPE if (gr_linedef->flags & ML_EFFECT2) { if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) @@ -1943,9 +1796,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) -#else - if (gr_linedef->flags & ML_DONTPEGBOTTOM) -#endif { polybottom = popenbottom + gr_sidedef->rowoffset; polytop = polybottom + midtexheight; @@ -2023,11 +1873,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // PEGGING -#ifdef ESLOPE if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) -#else - if (gr_linedef->flags & ML_DONTPEGBOTTOM) -#endif texturevpeg = textureheight[gr_sidedef->midtexture]*repeats - h + polybottom; else texturevpeg = polytop - h; @@ -2043,7 +1889,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(h); wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(l); -#ifdef ESLOPE // Correct to account for slopes { fixed_t midtextureslant; @@ -2086,7 +1931,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(h); wallVerts[1].y = FIXED_TO_FLOAT(l); } -#endif } // set alpha for transparent walls (new boom and legacy linedef types) @@ -2197,12 +2041,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { fixed_t texturevpeg; // PEGGING -#ifdef ESLOPE 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 -#endif - if (gr_linedef->flags & ML_DONTPEGBOTTOM) + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; else // top of texture at top @@ -2215,7 +2056,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; -#ifdef ESLOPE // Texture correction for slopes if (gr_linedef->flags & ML_EFFECT2) { wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; @@ -2229,19 +2069,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; } -#endif } -#ifdef ESLOPE //Set textures properly on single sided walls that are sloped wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); -#else - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldbottom); -#endif if (gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); @@ -2256,17 +2089,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } else { -#ifdef ESLOPE //Set textures properly on single sided walls that are sloped wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); -#else - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldbottom); -#endif // When there's no midtexture, draw a skywall to prevent rendering behind it HWR_DrawSkyWall(wallVerts, &Surf); @@ -2280,22 +2107,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gr_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector { wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(INT32_MAX); -#ifdef ESLOPE wallVerts[0].y = FIXED_TO_FLOAT(worldtop); wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); -#else - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop); -#endif HWR_DrawSkyWall(wallVerts, &Surf); } if (gr_frontsector->floorpic == skyflatnum) { -#ifdef ESLOPE wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); -#else - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(worldbottom); -#endif wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); HWR_DrawSkyWall(wallVerts, &Surf); @@ -2364,13 +2183,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } -#ifdef ESLOPE - h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight; - hS = *rover->t_slope ? P_GetZAt(*rover->t_slope, v2x, v2y) : *rover->topheight; - l = *rover->b_slope ? P_GetZAt(*rover->b_slope, v1x, v1y) : *rover->bottomheight; - lS = *rover->b_slope ? P_GetZAt(*rover->b_slope, v2x, v2y) : *rover->bottomheight; - - + h = P_GetFFloorTopZAt (rover, v1x, v1y); + hS = P_GetFFloorTopZAt (rover, v2x, v2y); + l = P_GetFFloorBottomZAt(rover, v1x, v1y); + lS = P_GetFFloorBottomZAt(rover, v2x, v2y); + if (!cv_grfofcut.value) { if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) @@ -2402,19 +2219,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(hS); wallVerts[0].y = FIXED_TO_FLOAT(l); wallVerts[1].y = FIXED_TO_FLOAT(lS); -#else - h = *rover->topheight; - l = *rover->bottomheight; - if (h > highcut) - h = highcut; - if (l < lowcut) - l = lowcut; - //Hurdler: HW code starts here - //FIXME: check if peging is correct - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(l); -#endif + if (rover->flags & FF_FOG) { wallVerts[3].t = wallVerts[2].t = 0; @@ -2426,9 +2231,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { fixed_t texturevpeg; boolean attachtobottom = false; -#ifdef ESLOPE boolean slopeskew = false; // skew FOF walls with slopes? -#endif // Wow, how was this missing from OpenGL for so long? // ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software @@ -2437,22 +2240,17 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { texturevpeg = sides[newline->sidenum[0]].rowoffset; attachtobottom = !!(newline->flags & ML_DONTPEGBOTTOM); -#ifdef ESLOPE slopeskew = !!(newline->flags & ML_DONTPEGTOP); -#endif } else { texturevpeg = sides[rover->master->sidenum[0]].rowoffset; attachtobottom = !!(gr_linedef->flags & ML_DONTPEGBOTTOM); -#ifdef ESLOPE slopeskew = !!(rover->master->flags & ML_DONTPEGTOP); -#endif } grTex = HWR_GetTexture(texnum, noencore); -#ifdef ESLOPE if (!slopeskew) // no skewing { if (attachtobottom) @@ -2477,12 +2275,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].t = wallVerts[1].t - (hS - lS) * grTex->scaleY; } } -#else - if (attachtobottom) - texturevpeg -= *rover->topheight - *rover->bottomheight; - wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + texturevpeg) * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (*rover->topheight - l + texturevpeg) * grTex->scaleY; -#endif wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; @@ -2563,12 +2355,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom newline = rover->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); } -#ifdef ESLOPE //backsides - h = *rover->t_slope ? P_GetZAt(*rover->t_slope, v1x, v1y) : *rover->topheight; - hS = *rover->t_slope ? P_GetZAt(*rover->t_slope, v2x, v2y) : *rover->topheight; - l = *rover->b_slope ? P_GetZAt(*rover->b_slope, v1x, v1y) : *rover->bottomheight; - lS = *rover->b_slope ? P_GetZAt(*rover->b_slope, v2x, v2y) : *rover->bottomheight; - + + h = P_GetFFloorTopZAt (rover, v1x, v1y); + hS = P_GetFFloorTopZAt (rover, v2x, v2y); + l = P_GetFFloorBottomZAt(rover, v1x, v1y); + lS = P_GetFFloorBottomZAt(rover, v2x, v2y); + if (!cv_grfofcut.value) { if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut) @@ -2599,19 +2391,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(hS); wallVerts[0].y = FIXED_TO_FLOAT(l); wallVerts[1].y = FIXED_TO_FLOAT(lS); -#else - h = *rover->topheight; - l = *rover->bottomheight; - if (h > highcut) - h = highcut; - if (l < lowcut) - l = lowcut; - //Hurdler: HW code starts here - //FIXME: check if peging is correct - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(l); -#endif + if (rover->flags & FF_FOG) { wallVerts[3].t = wallVerts[2].t = 0; @@ -2704,7 +2484,6 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) // GZDoom method of sloped line clipping -#ifdef ESLOPE if (afrontsector->f_slope || afrontsector->c_slope || abacksector->f_slope || abacksector->c_slope) { fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t @@ -2744,7 +2523,6 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) #undef SLOPEPARAMS } else -#endif { frontf1 = frontf2 = afrontsector->floorheight; frontc1 = frontc2 = afrontsector->ceilingheight; @@ -3495,22 +3273,10 @@ void HWR_Subsector(size_t num) } else { - cullFloorHeight = locFloorHeight = gr_frontsector->floorheight; - cullCeilingHeight = locCeilingHeight = gr_frontsector->ceilingheight; - -#ifdef ESLOPE - if (gr_frontsector->f_slope) - { - cullFloorHeight = P_GetZAt(gr_frontsector->f_slope, viewx, viewy); - locFloorHeight = P_GetZAt(gr_frontsector->f_slope, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - } - - if (gr_frontsector->c_slope) - { - cullCeilingHeight = P_GetZAt(gr_frontsector->c_slope, viewx, viewy); - locCeilingHeight = P_GetZAt(gr_frontsector->c_slope, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - } -#endif + cullFloorHeight = P_GetSectorFloorZAt (gr_frontsector, viewx, viewy); + cullCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, viewx, viewy); + locFloorHeight = P_GetSectorFloorZAt (gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); + locCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); } // ----- end special tricks ----- @@ -4202,13 +3968,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) float realheight, heightmult; const sector_t *sector = spr->mobj->subsector->sector; const lightlist_t *list = sector->lightlist; -#ifdef ESLOPE float endrealtop, endrealbot, endtop, endbot; float endbheight; float endrealheight; fixed_t temp; fixed_t v1x, v1y, v2x, v2y; -#endif INT32 shader = SHADER_NONE; @@ -4293,10 +4057,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) towbot = baseWallVerts[0].t; towmult = (towbot - towtop) / (top - bot); -#ifdef ESLOPE endrealtop = endtop = baseWallVerts[2].y; endrealbot = endbot = baseWallVerts[1].y; -#endif // copy the contents of baseWallVerts into the drawn wallVerts array // baseWallVerts is used to know the final shape to easily get the vertex @@ -4338,11 +4100,9 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (spr->mobj->frame & FF_FULLBRIGHT) lightlevel = 255; -#ifdef ESLOPE for (i = 1; i < sector->numlights; i++) { - fixed_t h = sector->lightlist[i].slope ? P_GetZAt(sector->lightlist[i].slope, spr->mobj->x, spr->mobj->y) - : sector->lightlist[i].height; + fixed_t h = P_GetLightZAt(§or->lightlist[i], spr->mobj->x, spr->mobj->y); if (h <= temp) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) @@ -4351,19 +4111,10 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) break; } } -#else - i = R_GetPlaneLight(sector, temp, false); - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel > 255 ? 255 : SOFTLIGHT(*list[i].lightlevel); - colormap = list[i].extra_colormap; -#endif for (i = 0; i < sector->numlights; i++) { -#ifdef ESLOPE - if (endtop < endrealbot) -#endif - if (top < realbot) + if (endtop < endrealbot && top < realbot) return; // even if we aren't changing colormap or lightlevel, we still need to continue drawing down the sprite @@ -4374,7 +4125,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) colormap = list[i].extra_colormap; } -#ifdef ESLOPE if (i + 1 < sector->numlights) { if (list[i+1].slope) @@ -4392,21 +4142,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) bheight = realbot; endbheight = endrealbot; } -#else - if (i + 1 < sector->numlights) - { - bheight = FIXED_TO_FLOAT(list[i+1].height); - } - else - { - bheight = realbot; - } -#endif -#ifdef ESLOPE - if (endbheight >= endtop) -#endif - if (bheight >= top) + if (endbheight >= endtop && bheight >= top) continue; bot = bheight; @@ -4414,14 +4151,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (bot < realbot) bot = realbot; -#ifdef ESLOPE endbot = endbheight; if (endbot < endrealbot) endbot = endrealbot; -#endif -#ifdef ESLOPE wallVerts[3].t = towtop + ((realtop - top) * towmult); wallVerts[2].t = towtop + ((endrealtop - endtop) * towmult); wallVerts[0].t = towtop + ((realtop - bot) * towmult); @@ -4454,31 +4188,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; } -#else - wallVerts[3].t = wallVerts[2].t = towtop + ((realtop - top) * towmult); - wallVerts[0].t = wallVerts[1].t = towtop + ((realtop - bot) * towmult); - - wallVerts[2].y = wallVerts[3].y = top; - wallVerts[0].y = wallVerts[1].y = bot; - - // The x and y only need to be adjusted in the case that it's not a papersprite - if (cv_grspritebillboarding.value && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE)) - { - // Get the x and z of the vertices so billboarding draws correctly - realheight = realbot - realtop; - heightmult = (realtop - top) / realheight; - wallVerts[3].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; - wallVerts[3].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; - wallVerts[2].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; - wallVerts[2].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; - - heightmult = (realtop - bot) / realheight; - wallVerts[0].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; - wallVerts[0].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; - wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; - wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; - } -#endif HWR_Lighting(&Surf, lightlevel, colormap); @@ -4493,21 +4202,16 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); // sprite shader top = bot; -#ifdef ESLOPE endtop = endbot; -#endif } bot = realbot; -#ifdef ESLOPE endbot = endrealbot; - if (endtop <= endrealbot) -#endif - if (top <= realbot) + + if (endtop <= endrealbot && top <= realbot) return; // If we're ever down here, somehow the above loop hasn't draw all the light levels of sprite -#ifdef ESLOPE wallVerts[3].t = towtop + ((realtop - top) * towmult); wallVerts[2].t = towtop + ((endrealtop - endtop) * towmult); wallVerts[0].t = towtop + ((realtop - bot) * towmult); @@ -4517,13 +4221,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[2].y = endtop; wallVerts[0].y = bot; wallVerts[1].y = endbot; -#else - wallVerts[3].t = wallVerts[2].t = towtop + ((realtop - top) * towmult); - wallVerts[0].t = wallVerts[1].t = towtop + ((realtop - bot) * towmult); - - wallVerts[2].y = wallVerts[3].y = top; - wallVerts[0].y = wallVerts[1].y = bot; -#endif HWR_Lighting(&Surf, lightlevel, colormap); diff --git a/src/hardware/hw_trick.c b/src/hardware/hw_trick.c index de4a76c59..342a2051c 100644 --- a/src/hardware/hw_trick.c +++ b/src/hardware/hw_trick.c @@ -611,10 +611,8 @@ static boolean isCeilingFloating(sector_t *thisSector) if (!adjSector) // assume floating sectors have surrounding sectors return false; -#ifdef ESLOPE if (adjSector->c_slope) // Don't bother with slopes return false; -#endif if (!refSector) { @@ -664,10 +662,8 @@ static boolean isFloorFloating(sector_t *thisSector) if (!adjSector) // assume floating sectors have surrounding sectors return false; -#ifdef ESLOPE if (adjSector->f_slope) // Don't bother with slopes return false; -#endif if (!refSector) { diff --git a/src/p_map.c b/src/p_map.c index abca82eb0..3942122cc 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3931,13 +3931,6 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) topheight = *rover->topheight; bottomheight = *rover->bottomheight; -/*#ifdef ESLOPE - if (rover->t_slope) - topheight = P_GetZAt(rover->t_slope, thing->x, thing->y); - if (rover->b_slope) - bottomheight = P_GetZAt(rover->b_slope, thing->x, thing->y); -#endif*/ - delta1 = thing->z - (bottomheight + topheight)/2; delta2 = thingtop - (bottomheight + topheight)/2; if (bottomheight <= thing->ceilingz && abs(delta1) >= abs(delta2)) diff --git a/src/r_segs.c b/src/r_segs.c index 8eb3c9b41..6ee61e8ea 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2634,13 +2634,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) } else { -#ifdef ESLOPE ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); ffloor[i].f_step = ((centeryfrac>>4) - FixedMul(ffloor[i].f_pos_slope, ds_p->scale2) - ffloor[i].f_frac)/(range); -#else - ffloor[i].f_step = FixedMul(-rw_scalestep, ffloor[i].f_pos); - ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); -#endif } } } -- 2.54.0 From 47e045db065bcb622d462e7763392790e8eab9a1 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 04:47:55 +0100 Subject: [PATCH 45/70] kill hw_trick --- src/CMakeLists.txt | 1 - src/Makefile | 2 +- src/hardware/hw_main.c | 34 +- src/hardware/hw_main.h | 3 - src/hardware/hw_trick.c | 915 ---------------------------------------- src/p_setup.c | 11 - src/r_defs.h | 24 -- src/sdl/Srb2SDL.dsp | 4 - 8 files changed, 5 insertions(+), 989 deletions(-) delete mode 100644 src/hardware/hw_trick.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3743118c8..7811f9032 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -466,7 +466,6 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_trick.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.c ) diff --git a/src/Makefile b/src/Makefile index a9b706f44..4096f1104 100644 --- a/src/Makefile +++ b/src/Makefile @@ -272,7 +272,7 @@ ifdef NOHW else OPTS+=-DHWRENDER OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o $(OBJDIR)/hw_light.o \ - $(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o $(OBJDIR)/hw_trick.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_main.c b/src/hardware/hw_main.c index 8a1f42934..06b9ab23b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -90,7 +90,6 @@ consvar_t cv_grfiltermode = {"gr_filtermode", "Nearest", CV_CALL|CV_SAVE, grfilt consvar_t cv_granisotropicmode = {"gr_anisotropicmode", "1", CV_CALL|CV_SAVE, granisotropicmode_cons_t, CV_anisotropic_ONChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grcorrecttricks = {"gr_correcttricks", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3251,34 +3250,10 @@ void HWR_Subsector(size_t num) floorcolormap = ceilingcolormap = gr_frontsector->extra_colormap; -// ----- for special tricks with HW renderer ----- - if (gr_frontsector->pseudoSector) - { - cullFloorHeight = locFloorHeight = gr_frontsector->virtualFloorheight; - cullCeilingHeight = locCeilingHeight = gr_frontsector->virtualCeilingheight; - } - else if (gr_frontsector->virtualFloor) - { - ///@TODO Is this whole virtualFloor mess even useful? I don't think it even triggers ever. - cullFloorHeight = locFloorHeight = gr_frontsector->virtualFloorheight; - if (gr_frontsector->virtualCeiling) - cullCeilingHeight = locCeilingHeight = gr_frontsector->virtualCeilingheight; - else - cullCeilingHeight = locCeilingHeight = gr_frontsector->ceilingheight; - } - else if (gr_frontsector->virtualCeiling) - { - cullCeilingHeight = locCeilingHeight = gr_frontsector->virtualCeilingheight; - cullFloorHeight = locFloorHeight = gr_frontsector->floorheight; - } - else - { - cullFloorHeight = P_GetSectorFloorZAt (gr_frontsector, viewx, viewy); - cullCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, viewx, viewy); - locFloorHeight = P_GetSectorFloorZAt (gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - locCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); - } -// ----- end special tricks ----- + cullFloorHeight = P_GetSectorFloorZAt (gr_frontsector, viewx, viewy); + cullCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, viewx, viewy); + locFloorHeight = P_GetSectorFloorZAt (gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); + locCeilingHeight = P_GetSectorCeilingZAt(gr_frontsector, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); if (gr_frontsector->ffloors) { @@ -6116,7 +6091,6 @@ void HWR_AddCommands(void) { CV_RegisterVar(&cv_grfiltermode); CV_RegisterVar(&cv_granisotropicmode); - CV_RegisterVar(&cv_grcorrecttricks); CV_RegisterVar(&cv_grsolvetjoin); CV_RegisterVar(&cv_grbatching); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 018f1bfbd..0f57e04ea 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -163,9 +163,6 @@ extern boolean gr_maphasportals; void HWR_LoadTextures(size_t pnumtextures); RGBA_t *HWR_GetTexturePalette(void); -// hw_trick.c -void HWR_CorrectSWTricks(void); - void HWR_SetShaderState(void); // Console variables diff --git a/src/hardware/hw_trick.c b/src/hardware/hw_trick.c deleted file mode 100644 index 342a2051c..000000000 --- a/src/hardware/hw_trick.c +++ /dev/null @@ -1,915 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2001 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief special trick routines to make some SW tricks look OK with -/// HW rendering. This includes: -/// - deepwatereffect (e.g. tnt/map02) -/// - invisible staircase (e.g. eternal/map02) -/// - floating ceilings (e.g. eternal/map03) -/// -/// It is not guaranteed that it looks identical to the SW mode, -/// but it looks in most of the cases far better than having -/// holes in the architecture, HOM, etc. -/// -/// It fixes as well missing textures, which are replaced by either -/// a default texture or the midtexture. -/// -/// words of notice: -/// pseudosectors, as mentioned in this file, are sectors where both -/// sidedefs point to the same sector. This expression is also used -/// for sectors which are enclosed by another sector but have no -/// correct sidedefs at all -/// -/// if a vertex is inside a poly is determined by the angles between -/// this vertex and all angles on the linedefs (imagine walking along -/// a circle always facing a certain point inside/outside the circle; -/// if inside, angle have taken all values [0..pi), otherwise the -/// range was < pi/2 - -#include -#include "../doomdef.h" -#include "../doomstat.h" - -#ifdef HWRENDER -#include "hw_main.h" -#include "hw_glob.h" -#include "hw_dll.h" -#include "../r_local.h" -#include "../i_system.h" - -// -// add a line to a sectors list of lines -// -static void addLineToChain(sector_t *sector, line_t *line) -{ - linechain_t *thisElem = NULL, *nextElem; - - if (!sector) - return; - - nextElem = sector->sectorLines; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - } - - // add a new element into the chain - if (thisElem) - { - thisElem->next = malloc(sizeof (linechain_t)); - if (thisElem->next) - { - thisElem->next->line = line; - thisElem->next->next = NULL; - } - else - { - I_Error("Out of memory in addLineToChain(.)\n"); - } - } - else // first element in chain - { - sector->sectorLines = malloc(sizeof (linechain_t)); - if (sector->sectorLines) - { - sector->sectorLines->line = line; - sector->sectorLines->next = NULL; - } - else - { - I_Error("Out of memory in addLineToChain(.)\n"); - } - } -} - -// -// We dont want a memory hole, do we?;-) -// -static void releaseLineChains(void) -{ - linechain_t *thisElem, *nextElem; - sector_t *sector; - size_t i; - - for (i = 0; i < numsectors; i++) - { - sector = §ors[i]; - nextElem = sector->sectorLines; - - while (nextElem) - { - thisElem = nextElem; - nextElem = thisElem->next; - free(thisElem); - } - - sector->sectorLines = NULL; - } -} - -// -// check if a pseudo sector is valid by checking all its linedefs -// -static boolean isPSectorValid(sector_t *sector) -{ - linechain_t *thisElem, *nextElem; - - if (!sector->pseudoSector) // check only pseudosectors, others dont care - { -#ifdef PARANOIA - CONS_Debug(DBG_RENDER, "Alert! non-pseudosector fed to isPSectorClosed()\n"); -#endif - return false; - } - - nextElem = sector->sectorLines; - - while (nextElem) - { - thisElem = nextElem; - nextElem = thisElem->next; - if (thisElem->line->frontsector != thisElem->line->backsector) - return false; - } - return true; -} - -// -// angles are always phiMax-phiMin [0...2\pi) -// -FUNCMATH static double phiDiff(double phiMin, double phiMax) -{ - double result; - - result = phiMax-phiMin; - - if (result < 0.0l) - result += 2.0l*M_PIl; - - return result; -} - -// -// sort phi's so that enclosed angle < \pi -// -static void sortPhi(double phi1, double phi2, double *phiMin, double *phiMax) -{ - if (phiDiff(phi1, phi2) < M_PIl) - { - *phiMin = phi1; - *phiMax = phi2; - } - else - { - *phiMin = phi2; - *phiMax = phi1; - } -} - -// -// return if angle(phi1, phi2) is bigger than \pi -// if so, the vertex lies inside the poly -// -FUNCMATH static boolean biggerThanPi(double phi1, double phi2) -{ - if (phiDiff(phi1, phi2) > M_PIl) - return true; - - return false; -} - -#define DELTAPHI (M_PIl/100.0l) // some small phi << \pi - -// -// calculate bounds for minimum angle -// -static void phiBounds(double phi1, double phi2, double *phiMin, double *phiMax) -{ - double phi1Tmp, phi2Tmp; - double psi1, psi2, psi3, psi4, psi5, psi6, psi7; // for optimization - - sortPhi(phi1, phi2, &phi1Tmp, &phi2Tmp); - phi1 = phi1Tmp; - phi2 = phi2Tmp; - - // check start condition - if (*phiMin > M_PIl || *phiMax > M_PIl) - { - *phiMin = phi1; - *phiMax = phi2; - return; - } - - // 6 cases: - // new angles inbetween phiMin, phiMax -> forget it - // new angles enclose phiMin -> set phiMin - // new angles enclose phiMax -> set phiMax - // new angles completely outside phiMin, phiMax -> leave largest area free - // new angles close the range completely! - // new angles enlarges range on both sides - - psi1 = phiDiff(*phiMin, phi1); - psi2 = phiDiff(*phiMin, phi2); - psi3 = phiDiff(*phiMax, phi1); - psi4 = phiDiff(*phiMax, phi2); - psi5 = phiDiff(*phiMin, *phiMax); - psi6 = (double)(2.0l*M_PIl - psi5); // phiDiff(*phiMax, *phiMin); - psi7 = (double)(2.0l*M_PIl - psi2); // phiDiff(phi2, *phiMin); - - // case 1 & 5! - if ((psi1 <= psi5) && (psi2 <= psi5)) - { - if (psi1 <= psi2) // case 1 - { - return; - } - else // case 5 - { - // create some artificial interval here not to get into numerical trouble - // in fact we know now the sector is completely enclosed -> base for computational optimization - *phiMax = 0.0l; - *phiMin = DELTAPHI; - return; - } - } - - // case 2 - if ((psi1 >= psi5) && (psi2 <= psi5)) - { - *phiMin = phi1; - return; - } - - // case 3 - if ((psi3 >= psi6) && (psi4 <= psi6)) - { - *phiMax = phi2; - return; - } - - // case 4 & 6 -#ifdef PARANOIA - if ((psi3 <= psi6) && (psi4 <= psi6)) // FIXME: isn't this case implicitly true anyway?? -#endif - { - if (psi3 <= psi4) //case 4 - { - if (psi3 >= psi7) - { - *phiMin = phi1; - return; - } - else - { - *phiMax = phi2; - return; - } - } - else // case 6 - { - *phiMin = phi1; - *phiMax = phi2; - return; - } - } - -#ifdef PARANOIA - CONS_Debug(DBG_RENDER, "phiMin = %f, phiMax = %f, phi1 = %f, phi2 = %f\n", *phiMin, *phiMax, phi1, phi2); - I_Error("phiBounds() out of range!\n"); -#endif -} - -// -// Check if a vertex lies inside a sector -// This works for "well-behaved" convex polygons -// If we need it mathematically correct, we need to sort the -// linedefs first so we have them in a row, then walk along the linedefs, -// but this is a bit overdone -// -static inline boolean isVertexInside(vertex_t *vertex, sector_t *sector) -{ - double xa, ya, xe, ye; - linechain_t *chain; - double phiMin, phiMax; - double phi1, phi2; - - chain = sector->sectorLines; - phiMin = phiMax = 10.0l*M_PIl; // some value > \pi - - while (chain) - { - // start and end vertex - xa = (double)chain->line->v1->x - (double)vertex->x; - ya = (double)chain->line->v1->y - (double)vertex->y; - xe = (double)chain->line->v2->x - (double)vertex->x; - ye = (double)chain->line->v2->y - (double)vertex->y; - - // angle phi of connection between the vertices and the x-axis - phi1 = atan2(ya, xa); - phi2 = atan2(ye, xe); - - // if we have just started, we can have to create start bounds for phi - - phiBounds(phi1, phi2, &phiMin, &phiMax); - chain = chain->next; - } - - return biggerThanPi(phiMin, phiMax); -} - - -#define MAXSTACK 256 // Not more than 256 polys in each other? -// -// generate a list of sectors which enclose the given sector -// -static void generateStacklist(sector_t *thisSector) -{ - size_t i, stackCnt = 0; - sector_t *locStacklist[MAXSTACK]; - sector_t *checkSector; - - for (i = 0; i < numsectors; i++) - { - checkSector = §ors[i]; - - if (checkSector == thisSector) // dont check self - continue; - - // buggy sector? - if (!thisSector->sectorLines) - continue; - - // check if an arbitrary vertex of thisSector lies inside the checkSector - if (isVertexInside(thisSector->sectorLines->line->v1, checkSector)) - { - // if so, the thisSector lies inside the checkSector - locStacklist[stackCnt] = checkSector; - stackCnt++; - - if (MAXSTACK-1 == stackCnt) // beware of the SIGSEGV! and consider terminating NULL! - break; - } - } - - thisSector->stackList = malloc(sizeof (sector_t *) * (stackCnt+1)); - if (NULL == thisSector->stackList) - { - I_Error("Out of memory error in generateStacklist()"); - } - - locStacklist[stackCnt] = NULL; // terminating NULL - - memcpy(thisSector->stackList, locStacklist, sizeof (sector_t *) * (stackCnt+1)); -} - -// -// Bubble sort the stacklist with rising lineoutlengths -// -static void sortStacklist(sector_t *sector) -{ - sector_t **list; - sector_t *sec1, *sec2; - boolean finished; - size_t i; - - list = sector->stackList; - finished = false; - - if (!*list) - return; // nothing to sort - - while (!finished) - { - i = 0; - finished = true; - - while (*(list+i+1)) - { - sec1 = *(list+i); - sec2 = *(list+i+1); - - if (sec1->lineoutLength > sec2->lineoutLength) - { - *(list+i) = sec2; - *(list+i+1) = sec1; - finished = false; - } - i++; - } - } -} - -// -// length of a line in euclidian sense -// -static double lineLength(line_t *line) -{ - double dx, dy, length; - - dx = (double) line->v1->x - (double) line->v2->x; - dy = (double) line->v1->y - (double) line->v2->y; - - length = hypot(dx, dy); - - return length; -} - - -// -// length of the sector lineout -// -static double calcLineoutLength(sector_t *sector) -{ - linechain_t *chain; - double length = 0.0L; - chain = sector->sectorLines; - - while (chain) // sum up lengths of all lines - { - length += lineLength(chain->line); - chain = chain->next; - } - return length; -} - -// -// Calculate length of the sectors lineout -// -static void calcLineouts(sector_t *sector) -{ - size_t secCount = 0; - sector_t *encSector = *(sector->stackList); - - while (encSector) - { - if (encSector->lineoutLength < 0.0L) // if length has not yet been calculated - { - encSector->lineoutLength = calcLineoutLength(encSector); - } - - secCount++; - encSector = *((sector->stackList) + secCount); - } -} - -// -// Free Stacklists of all sectors -// -static void freeStacklists(void) -{ - size_t i; - - for (i = 0; i < numsectors; i++) - { - if (sectors[i].stackList) - { - free(sectors[i].stackList); - sectors[i].stackList = NULL; - } - } -} - -// -// if more than half of the toptextures are missing -// -static boolean areToptexturesMissing(sector_t *thisSector) -{ - linechain_t *thisElem, *nextElem = thisSector->sectorLines; - sector_t *frontSector, *backSector; - size_t nomiss = 0; - side_t *sidel, *sider; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - - frontSector = thisElem->line->frontsector; - backSector = thisElem->line->backsector; - - if (frontSector == backSector) // skip damn renderer tricks here - continue; - - if (!frontSector || !backSector) - continue; - - sider = &sides[thisElem->line->sidenum[0]]; - sidel = &sides[thisElem->line->sidenum[1]]; - - if (backSector->ceilingheight < frontSector->ceilingheight) - { - if (sider->toptexture != 0) - { - nomiss++; - break; // we can stop here if decision criterium is ==0 - } - } - else if (backSector->ceilingheight > frontSector->ceilingheight) - { - if (sidel->toptexture != 0) - { - nomiss++; - break; // we can stop here if decision criterium is ==0 - } - } - } - - return nomiss == 0; -} - -// -// are more textures missing than present? -// -static boolean areBottomtexturesMissing(sector_t *thisSector) -{ - linechain_t *thisElem, *nextElem = thisSector->sectorLines; - sector_t *frontSector, *backSector; - size_t nomiss = 0; - side_t *sidel, *sider; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - - frontSector = thisElem->line->frontsector; - backSector = thisElem->line->backsector; - - if (frontSector == backSector) // skip damn renderer tricks here - continue; - - if (!frontSector || !backSector) - continue; - - sider = &sides[thisElem->line->sidenum[0]]; - sidel = &sides[thisElem->line->sidenum[1]]; - - if (backSector->floorheight > frontSector->floorheight) - { - if (sider->bottomtexture != 0) - { - nomiss++; - break; // we can stop here if decision criterium is ==0 - } - } - - else if (backSector->floorheight < frontSector->floorheight) - { - if (sidel->bottomtexture != 0) - { - nomiss++; - break; // we can stop here if decision criterium is ==0 - } - } - } - - // return missing >= nomiss; - return nomiss == 0; -} - -// -// check if no adjacent sector has same ceiling height -// -static boolean isCeilingFloating(sector_t *thisSector) -{ - sector_t *adjSector, *refSector = NULL, *frontSector, *backSector; - linechain_t *thisElem, *nextElem; - - if (!thisSector) - return false; - - nextElem = thisSector->sectorLines; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - - frontSector = thisElem->line->frontsector; - backSector = thisElem->line->backsector; - - if (frontSector == thisSector) - adjSector = backSector; - else - adjSector = frontSector; - - if (!adjSector) // assume floating sectors have surrounding sectors - return false; - - if (adjSector->c_slope) // Don't bother with slopes - return false; - - if (!refSector) - { - refSector = adjSector; - continue; - } - - // if adjacent sector has same height or more than one adjacent sector exists -> stop - if (thisSector->ceilingheight == adjSector->ceilingheight || refSector != adjSector) - return false; - } - - // now check for walltextures - if (!areToptexturesMissing(thisSector)) - return false; - - return true; -} - -// -// check if no adjacent sector has same ceiling height -// FIXME: throw that together with isCeilingFloating?? -// -static boolean isFloorFloating(sector_t *thisSector) -{ - sector_t *adjSector, *refSector = NULL, *frontSector, *backSector; - linechain_t *thisElem, *nextElem; - - if (!thisSector) - return false; - - nextElem = thisSector->sectorLines; - - while (nextElem) // walk through chain - { - thisElem = nextElem; - nextElem = thisElem->next; - - frontSector = thisElem->line->frontsector; - backSector = thisElem->line->backsector; - - if (frontSector == thisSector) - adjSector = backSector; - else - adjSector = frontSector; - - if (!adjSector) // assume floating sectors have surrounding sectors - return false; - - if (adjSector->f_slope) // Don't bother with slopes - return false; - - if (!refSector) - { - refSector = adjSector; - continue; - } - - // if adjacent sector has same height or more than one adjacent sector exists -> stop - if (thisSector->floorheight == adjSector->floorheight || refSector != adjSector) - return false; - } - - // now check for walltextures - if (!areBottomtexturesMissing(thisSector)) - return false; - - return true; -} - -// -// estimate ceilingheight according to height of adjacent sector -// -static fixed_t estimateCeilHeight(sector_t *thisSector) -{ - sector_t *adjSector; - - if (!thisSector || !thisSector->sectorLines || !thisSector->sectorLines->line) - return 0; - - adjSector = thisSector->sectorLines->line->frontsector; - if (adjSector == thisSector) - adjSector = thisSector->sectorLines->line->backsector; - - if (!adjSector) - return 0; - - return adjSector->ceilingheight; -} - -// -// estimate ceilingheight according to height of adjacent sector -// -static fixed_t estimateFloorHeight(sector_t *thisSector) -{ - sector_t *adjSector; - - if (!thisSector || !thisSector->sectorLines || !thisSector->sectorLines->line) - return 0; - - adjSector = thisSector->sectorLines->line->frontsector; - if (adjSector == thisSector) - adjSector = thisSector->sectorLines->line->backsector; - - if (!adjSector) - return 0; - - return adjSector->floorheight; -} - -#define CORRECT_FLOAT_EXPERIMENTAL - -// -------------------------------------------------------------------------- -// Some levels have missing sidedefs, which produces HOM, so lets try to compensate for that -// and some levels have deep water trick, invisible staircases etc. -// -------------------------------------------------------------------------- -// FIXME: put some nice default texture in legacy.dat and use it -void HWR_CorrectSWTricks(void) -{ - size_t i; - size_t k; - line_t *ld; - side_t *sidel = NULL, *sider; - sector_t *secl, *secr; - sector_t **sectorList; - sector_t *outSector; - - if ((0 == cv_grcorrecttricks.value)) - return; - - // determine lines for sectors - for (i = 0; i < numlines; i++) - { - ld = &lines[i]; - secr = ld->frontsector; - secl = ld->backsector; - - if (secr == secl) - { - secr->pseudoSector = true; // special renderer trick? - addLineToChain(secr, ld); - } - else - { - addLineToChain(secr, ld); - addLineToChain(secl, ld); - } - } - - // preprocessing - for (i = 0; i < numsectors; i++) - { - sector_t *checkSector; - - checkSector = §ors[i]; - - // identify real pseudosectors first - if (checkSector->pseudoSector) - { - if (!isPSectorValid(checkSector)) // drop invalid pseudo sectors - { - checkSector->pseudoSector = false; - } - } - - // determine enclosing sectors for pseudosectors ... used later - if (checkSector->pseudoSector) - { - generateStacklist(checkSector); - calcLineouts(checkSector); - sortStacklist(checkSector); - } - } - - // set virtual floor heights for pseudo sectors - // required for deep water effect e.g. - for (i = 0; i < numsectors; i++) - { - if (sectors[i].pseudoSector) - { - sectorList = sectors[i].stackList; - k = 0; - while (*(sectorList+k)) - { - outSector = *(sectorList+k); - if (!outSector->pseudoSector) - { - sectors[i].virtualFloorheight = outSector->floorheight; - sectors[i].virtualCeilingheight = outSector->ceilingheight; - break; - } - k++; - } - if (*(sectorList+k) == NULL) // sorry, did not work :( - { - sectors[i].virtualFloorheight = sectors[i].floorheight; - sectors[i].virtualCeilingheight = sectors[i].ceilingheight; - } - } - } -#ifdef CORRECT_FLOAT_EXPERIMENTAL - // correct ceiling/floor heights of totally floating sectors - for (i = 0; i < numsectors; i++) - { - sector_t *floatSector; - - floatSector = §ors[i]; - - // correct height of floating sectors - if (isCeilingFloating(floatSector)) - { - floatSector->virtualCeilingheight = estimateCeilHeight(floatSector); - floatSector->virtualCeiling = true; - } - if (isFloorFloating(floatSector)) - { - floatSector->virtualFloorheight = estimateFloorHeight(floatSector); - floatSector->virtualFloor = true; - } - } -#endif - - // now for the missing textures - for (i = 0; i < numlines; i++) - { - ld = &lines[i]; - sider = &sides[ld->sidenum[0]]; - if (ld->sidenum[1] != 0xffff) - sidel = &sides[ld->sidenum[1]]; - - secr = ld->frontsector; - secl = ld->backsector; - - if (secr == secl) // special renderer trick - continue; // we cant correct missing textures here - - if (secl) // only if there is a backsector - { - if (secr->pseudoSector || secl->pseudoSector) - continue; - if (!secr->virtualFloor && !secl->virtualFloor) - { - if (secl->floorheight > secr->floorheight) - { - // now check if r-sidedef is correct - if (sider->bottomtexture == 0) - { - if (sider->midtexture == 0) - sider->bottomtexture = 0; // Tails // More redwall sky shenanigans - else - sider->bottomtexture = sider->midtexture; - } - } - else if (secl->floorheight < secr->floorheight) - { - // now check if l-sidedef is correct - if (sidel->bottomtexture == 0) - { - if (sidel->midtexture == 0) - sidel->bottomtexture = 0; // Tails // More redwall sky shenanigans - else - sidel->bottomtexture = sidel->midtexture; - } - } - } - - if (!secr->virtualCeiling && !secl->virtualCeiling) - { - if (secl->ceilingheight < secr->ceilingheight) - { - // now check if r-sidedef is correct - if (sider->toptexture == 0) - { - if (sider->midtexture == 0) - sider->toptexture = 0; // Tails // When this was REDWALL it was causing issues in the sky sometimes - else - sider->toptexture = sider->midtexture; - } - } - else if (secl->ceilingheight > secr->ceilingheight) - { - // now check if l-sidedef is correct - if (sidel->toptexture == 0) - { - if (sidel->midtexture == 0) - sidel->toptexture = 0; // Tails // When this was REDWALL it was causing issues in the sky sometimes - else - sidel->toptexture = sidel->midtexture; - } - } - } - } // if (NULL != secl) - } // for (i = 0; i < numlines; i++) - - // release all linechains - releaseLineChains(); - freeStacklists(); -} - -#endif // HWRENDER diff --git a/src/p_setup.c b/src/p_setup.c index a81ae3226..893097556 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -752,15 +752,6 @@ static void P_LoadRawSectors(UINT8 *data, size_t i) ss->floorspeed = 0; ss->ceilspeed = 0; - -#ifdef HWRENDER // ----- for special tricks with HW renderer ----- - ss->pseudoSector = false; - ss->virtualFloor = false; - ss->virtualCeiling = false; - ss->sectorLines = NULL; - ss->stackList = NULL; - ss->lineoutLength = -1.0l; -#endif // ----- end special tricks ----- } // set the sky flat num @@ -3414,8 +3405,6 @@ boolean P_SetupLevel(boolean skipprecip) void HWR_LoadLevel(void) { HWR_FreeMipmapCache(); - // Correct missing sidedefs & deep water trick - HWR_CorrectSWTricks(); HWR_CreatePlanePolygons((INT32)numnodes - 1); if (HWR_ShouldUsePaletteRendering()) diff --git a/src/r_defs.h b/src/r_defs.h index 085d25e0b..74fa71085 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -211,19 +211,6 @@ typedef struct r_lightlist_s INT32 lightnum; } r_lightlist_t; -// ----- for special tricks with HW renderer ----- - -// -// For creating a chain with the lines around a sector -// -typedef struct linechain_s -{ - struct line_s *line; - struct linechain_s *next; -} linechain_t; -// ----- end special tricks ----- - - // Slopes typedef enum { @@ -352,17 +339,6 @@ typedef struct sector_s // per-sector colormaps! extracolormap_t *extra_colormap; -#ifdef HWRENDER // ----- for special tricks with HW renderer ----- - boolean pseudoSector; - boolean virtualFloor; - fixed_t virtualFloorheight; - boolean virtualCeiling; - fixed_t virtualCeilingheight; - linechain_t *sectorLines; - struct sector_s **stackList; - double lineoutLength; -#endif // ----- end special tricks ----- - // This points to the master's floorheight, so it can be changed in realtime! fixed_t *gravity; // per-sector gravity boolean verticalflip; // If gravity < 0, then allow flipped physics diff --git a/src/sdl/Srb2SDL.dsp b/src/sdl/Srb2SDL.dsp index c6e96a453..92821295d 100644 --- a/src/sdl/Srb2SDL.dsp +++ b/src/sdl/Srb2SDL.dsp @@ -604,10 +604,6 @@ SOURCE=..\hardware\hw_md2.h # End Source File # Begin Source File -SOURCE=..\hardware\hw_trick.c -# End Source File -# Begin Source File - SOURCE=..\hardware\hws_data.h # End Source File # End Group -- 2.54.0 From cc4d44f80665ddde6bc5d1d6e2c9972c1ae5f922 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 04:51:13 +0100 Subject: [PATCH 46/70] e --- src/p_setup.c | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 893097556..36da98814 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2356,15 +2356,7 @@ static void P_LevelInitStuff(void) for (i = 0; i < MAXPLAYERS; i++) { -#if 0 - if ((netgame || multiplayer) && (gametype == GT_COMPETITION || players[i].lives <= 0)) - { - // In Co-Op, replenish a user's lives if they are depleted. - players[i].lives = cv_startinglives.value; - } -#else players[i].lives = 1; // SRB2Kart -#endif players[i].realtime = racecountdown = exitcountdown = 0; curlap = bestlap = 0; // SRB2Kart @@ -2688,47 +2680,6 @@ static void P_LoadRecordGhosts(void) free(gpath); } -/*static void P_LoadNightsGhosts(void) -{ - const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; - char *gpath = malloc(glen); - - if (!gpath) - return; - - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); - - // Best Score ghost - if (cv_ghost_bestscore.value && FIL_FileExists(va("%s-score-best.lmp", gpath))) - G_AddGhost(va("%s-score-best.lmp", gpath)); - - // Best Time ghost - if (cv_ghost_besttime.value && FIL_FileExists(va("%s-time-best.lmp", gpath))) - G_AddGhost(va("%s-time-best.lmp", gpath)); - - // Last ghost - if (cv_ghost_last.value && FIL_FileExists(va("%s-last.lmp", gpath))) - G_AddGhost(va("%s-last.lmp", gpath)); - - // Guest ghost - if (cv_ghost_guest.value && FIL_FileExists(va("%s-guest.lmp", gpath))) - G_AddGhost(va("%s-guest.lmp", gpath)); - - // Staff Attack ghosts - if (cv_ghost_staff.value) - { - lumpnum_t l; - UINT8 i = 1; - while (i <= 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(gamemap),i))) != LUMPERROR) - { - G_AddGhost(va("%sS%02u",G_BuildMapName(gamemap),i)); - i++; - } - } - - free(gpath); -}*/ - static void P_SetupCamera(UINT8 pnum, camera_t *cam) { if (players[pnum].mo && (server || addedtogame)) -- 2.54.0 From 1be1e7fcbd7279e0543dd5bb7676abca28d12653 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 04:53:42 +0100 Subject: [PATCH 47/70] u --- src/p_setup.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 36da98814..5d5c56ac3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2237,42 +2237,6 @@ static void P_LoadRawReject(UINT8 *data, size_t count, const char *lumpname) } } -#if 0 -static char *levellumps[] = -{ - "label", // ML_LABEL, A separator, name, MAPxx - "THINGS", // ML_THINGS, Enemies, items.. - "LINEDEFS", // ML_LINEDEFS, Linedefs, from editing - "SIDEDEFS", // ML_SIDEDEFS, Sidedefs, from editing - "VERTEXES", // ML_VERTEXES, Vertices, edited and BSP splits generated - "SEGS", // ML_SEGS, Linesegs, from linedefs split by BSP - "SSECTORS", // ML_SSECTORS, Subsectors, list of linesegs - "NODES", // ML_NODES, BSP nodes - "SECTORS", // ML_SECTORS, Sectors, from editing - "REJECT", // ML_REJECT, LUT, sector-sector visibility -}; - -/** Checks a lump and returns whether it is a valid start-of-level marker. - * - * \param lumpnum Lump number to check. - * \return True if the lump is a valid level marker, false if not. - */ -static inline boolean P_CheckLevel(lumpnum_t lumpnum) -{ - UINT16 file, lump; - size_t i; - - for (i = ML_THINGS; i <= ML_REJECT; i++) - { - file = WADFILENUM(lumpnum); - lump = LUMPNUM(lumpnum+1); - if (file > numwadfiles || lump < LUMPNUM(lumpnum) || lump > wadfiles[file]->numlumps || - memcmp(wadfiles[file]->lumpinfo[lump].name, levellumps[i], 8) != 0) - return false; - } - return true; // all right -} -#endif /** Sets up a sky texture to use for the level. * The sky texture is used instead of F_SKY1. -- 2.54.0 From 5d2b213f761b4d1b74c24331690f3749a1d94215 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 17:46:46 +0100 Subject: [PATCH 48/70] those can return earlier --- src/hardware/hw_main.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 06b9ab23b..233d15531 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -661,7 +661,12 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc // no convex poly were generated for this subsector if (!xsub->planepoly) return; + + pv = xsub->planepoly->pts; + nrPlaneVerts = xsub->planepoly->numpts; + if (nrPlaneVerts < 3) //not even a triangle ? + return; // Get the slope pointer to simplify future code if (FOFsector) @@ -685,12 +690,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc height = FIXED_TO_FLOAT(fixedheight); - pv = xsub->planepoly->pts; - nrPlaneVerts = xsub->planepoly->numpts; - - if (nrPlaneVerts < 3) //not even a triangle ? - return; - // Allocate plane-vertex buffer if we need to if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts) { @@ -771,7 +770,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc if (angle) // Only needs to be done if there's an altered angle { - angle = InvAngle(angle)>>ANGLETOFINESHIFT; // This needs to be done so that it scrolls in a different direction after rotation like software @@ -2667,6 +2665,18 @@ void HWR_AddLine(seg_t *line) angle2 = R_PointToAngleEx(viewx, viewy, v2x, v2y); } + // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! + if (angle2 - angle1 < ANGLE_180) + return; + + // PrBoom: use REAL clipping math YAYYYYYYY!!! + if (!gld_clipper_SafeCheckRange(angle2, angle1)) + return; + + checkforemptylines = true; + + gr_backsector = line->backsector; + // do an extra culling check when rendering portals // check if any line vertex is on the viewable side of the portal target line // if not, the line can be culled. @@ -2699,18 +2709,6 @@ void HWR_AddLine(seg_t *line) goto doaddline; } - // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! - if (angle2 - angle1 < ANGLE_180) - return; - - // PrBoom: use REAL clipping math YAYYYYYYY!!! - if (!gld_clipper_SafeCheckRange(angle2, angle1)) - return; - - checkforemptylines = true; - - gr_backsector = line->backsector; - if (line->linedef->special == 40) { if (line->side == 0) -- 2.54.0 From 0a62fd11a0bb4f20f2e07d877e021fed1facd51c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 17:58:39 +0100 Subject: [PATCH 49/70] kill polyobjects ifdef --- src/doomdef.h | 3 -- src/hardware/hw_bsp.c | 2 -- src/hardware/hw_main.c | 19 +---------- src/hardware/hw_main.h | 6 ---- src/p_maputl.c | 16 --------- src/r_defs.h | 1 - src/r_segs.c | 58 ++------------------------------- src/r_things.c | 73 ------------------------------------------ 8 files changed, 3 insertions(+), 175 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index bb7a63412..0176258f0 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -578,9 +578,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Dumps the contents of a network save game upon consistency failure for debugging. //#define DUMPCONSISTENCY -/// Polyobject fake flat code -#define POLYOBJECTS_PLANES - /// See name of player in your crosshair #define SEENAMES diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index ff7e035f8..ebf18ed14 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -809,12 +809,10 @@ static void AdjustSegs(void) float distv1,distv2,tmp; nearv1 = nearv2 = MYMAX; -#ifdef POLYOBJECTS // Don't touch polyobject segs. We'll compensate // for this when we go about drawing them. if (lseg->polyseg) continue; -#endif if (p) { for (j = 0; j < p->numpts; j++) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 233d15531..cb67d7e25 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1756,7 +1756,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // heights of the polygon, and h & l, are the final (clipped) // poly coords. -#ifdef POLYOBJECTS // NOTE: With polyobjects, whenever you need to check the properties of the polyobject sector it belongs to, // you must use the linedef's backsector to be correct // From CB @@ -1766,7 +1765,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom popenbottom = popenbottomslope = back->floorheight; } else -#endif { popentop = min(worldtop, worldhigh); popenbottom = max(worldbottom, worldlow); @@ -1809,7 +1807,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // CB -#ifdef POLYOBJECTS // NOTE: With polyobjects, whenever you need to check the properties of the polyobject sector it belongs to, // you must use the linedef's backsector to be correct if (gr_curline->polyseg) @@ -1819,7 +1816,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lowcutslope = polybottomslope; highcutslope = polytopslope; } -#endif else { // The cut-off values of a linedef can always be constant, since every line has an absoulute front and or back sector @@ -1986,7 +1982,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom break; } -#ifdef POLYOBJECTS if (gr_curline->polyseg && gr_curline->polyseg->translucency > 0) { if (gr_curline->polyseg->translucency >= NUMTRANSMAPS) // wall not drawn @@ -1997,7 +1992,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else blendmode = HWR_TranstableToAlpha(gr_curline->polyseg->translucency, &Surf); } -#endif // Render midtextures on two-sided lines with a z-buffer offset. // This will cause the midtexture appear on top, if a FOF overlaps with it. @@ -2625,10 +2619,9 @@ void HWR_AddLine(seg_t *line) fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t boolean dont_draw = false; -#ifdef POLYOBJECTS + if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) return; -#endif gr_curline = line; @@ -2872,7 +2865,6 @@ boolean HWR_CheckBBox(fixed_t *bspcoord) return gld_clipper_SafeCheckRange(angle2, angle1); } -#ifdef POLYOBJECTS // // HWR_AddPolyObjectSegs @@ -2911,7 +2903,6 @@ void HWR_AddPolyObjectSegs(void) } } -#ifdef POLYOBJECTS_PLANES void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap) { float height; //constant y for all points on the convex flat polygon @@ -3144,8 +3135,6 @@ void HWR_AddPolyObjectPlanes(void) } } } -#endif -#endif // @@ -3440,7 +3429,6 @@ void HWR_Subsector(size_t num) } } -#ifdef POLYOBJECTS // Draw all the polyobjects in this subsector if (sub->polyList) { @@ -3464,15 +3452,12 @@ void HWR_Subsector(size_t num) // Draw polyobject lines. HWR_AddPolyObjectSegs(); -#ifdef POLYOBJECTS_PLANES if (sub->validcount != validcount) // This validcount situation seems to let us know that the floors have already been drawn. { // Draw polyobject planes HWR_AddPolyObjectPlanes(); } -#endif } -#endif skip_stuff_for_portals: @@ -3497,9 +3482,7 @@ skip_stuff_for_portals: while (count--) { -#ifdef POLYOBJECTS if (!line->polyseg) // ignore segs that belong to polyobjects -#endif HWR_AddLine(line); line++; } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 0f57e04ea..ab5d57159 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -121,13 +121,9 @@ void HWR_DrawScreenFinalTexture(INT32 width, INT32 height); void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap); -#ifdef POLYOBJECTS -#ifdef POLYOBJECTS_PLANES void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); void HWR_AddPolyObjectPlanes(void); void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); -#endif -#endif // hw_main.c: Segs void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom @@ -138,9 +134,7 @@ void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 t void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf); void HWR_DrawSkyBackground(float fpov); -#ifdef POLYOBJECTS void HWR_AddPolyObjectSegs(void); -#endif // hw_main.c: BSP void HWR_RenderBSPNode(INT32 bspnum); diff --git a/src/p_maputl.c b/src/p_maputl.c index 17df33a91..8fcd8f271 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -546,22 +546,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) texheight = textures[texnum]->height << FRACBITS; // Set texbottom and textop to the Z coordinates of the texture's boundaries -#if 0 // #ifdef POLYOBJECTS - // don't remove this code unless solid midtextures - // on non-solid polyobjects should NEVER happen in the future - if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = back->floorheight + side->rowoffset; - textop = back->ceilingheight + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = back->floorheight + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = back->ceilingheight + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } - } else -#endif { if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat texbottom = openbottom + side->rowoffset; diff --git a/src/r_defs.h b/src/r_defs.h index 74fa71085..f5a4195bc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -25,7 +25,6 @@ #include "screen.h" // MAXVIDWIDTH, MAXVIDHEIGHT -#define POLYOBJECTS // // ClipWallSegment diff --git a/src/r_segs.c b/src/r_segs.c index 6ee61e8ea..401c87c8b 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -622,62 +622,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // draw the texture col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3); - -//#ifdef POLYOBJECTS_PLANES -#if 0 // Disabling this allows inside edges to render below the planes, for until the clipping is fixed to work right when POs are near the camera. -Red - if (curline->dontrenderme && curline->polyseg && (curline->polyseg->flags & POF_RENDERPLANES)) - { - fixed_t my_topscreen; - fixed_t my_bottomscreen; - fixed_t my_yl, my_yh; - - my_topscreen = sprtopscreen + spryscale*col->topdelta; - my_bottomscreen = sprbotscreen == INT32_MAX ? my_topscreen + spryscale*col->length - : sprbotscreen + spryscale*col->length; - - my_yl = (my_topscreen+FRACUNIT-1)>>FRACBITS; - my_yh = (my_bottomscreen-1)>>FRACBITS; - // CONS_Debug(DBG_RENDER, "my_topscreen: %d\nmy_bottomscreen: %d\nmy_yl: %d\nmy_yh: %d\n", my_topscreen, my_bottomscreen, my_yl, my_yh); - - if (numffloors) - { - INT32 top = my_yl; - INT32 bottom = my_yh; - - for (i = 0; i < numffloors; i++) - { - if (!ffloor[i].polyobj || ffloor[i].polyobj != curline->polyseg) - continue; - - if (ffloor[i].height < viewz) - { - INT32 top_w = ffloor[i].plane->top[dc_x]; - - // CONS_Debug(DBG_RENDER, "Leveltime : %d\n", leveltime); - // CONS_Debug(DBG_RENDER, "Top is %d, top_w is %d\n", top, top_w); - if (top_w < top) - { - ffloor[i].plane->top[dc_x] = (INT16)top; - ffloor[i].plane->picnum = 0; - } - // CONS_Debug(DBG_RENDER, "top_w is now %d\n", ffloor[i].plane->top[dc_x]); - } - else if (ffloor[i].height > viewz) - { - INT32 bottom_w = ffloor[i].plane->bottom[dc_x]; - - if (bottom_w > bottom) - { - ffloor[i].plane->bottom[dc_x] = (INT16)bottom; - ffloor[i].plane->picnum = 0; - } - } - } - } - } - else -#endif - colfunc_2s(col); + + colfunc_2s(col); } spryscale += rw_scalestep; } diff --git a/src/r_things.c b/src/r_things.c index 1e9a116cc..2905830fd 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1225,65 +1225,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) groundslope = NULL; } -#if 0 // Unfortunately, this drops CEZ2 down to sub-17 FPS on my i7. - // NOTE: this section was not updated to reflect reverse gravity support - // Check polyobjects and see if groundz needs to be altered, for rings only because they don't update floorz - if (thing->type == MT_RING) - { - INT32 xl, xh, yl, yh, bx, by; - - xl = (unsigned)(thing->x - thing->radius - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(thing->x + thing->radius - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(thing->y - thing->radius - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(thing->y + thing->radius - bmaporgy)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - validcount++; - - for (by = yl; by <= yh; by++) - for (bx = xl; bx <= xh; bx++) - { - INT32 offset; - polymaplink_t *plink; // haleyjd 02/22/06 - - if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) - continue; - - offset = by*bmapwidth + bx; - - // haleyjd 02/22/06: consider polyobject lines - plink = polyblocklinks[offset]; - - while (plink) - { - polyobj_t *po = plink->po; - - if (po->validcount != validcount) // if polyobj hasn't been checked - { - po->validcount = validcount; - - if (!P_MobjInsidePolyobj(po, thing) || !(po->flags & POF_RENDERPLANES)) - { - plink = (polymaplink_t *)(plink->link.next); - continue; - } - - // We're inside it! Yess... - z = po->lines[0]->backsector->ceilingheight; - - if (z < thing->z+thing->height/2 && z > groundz) - { - groundz = z; - groundslope = NULL; - } - } - plink = (polymaplink_t *)(plink->link.next); - } - } - } -#endif - if (shadowslope != NULL) *shadowslope = groundslope; @@ -2495,20 +2436,6 @@ static void R_CreateDrawNodes(void) } else if (r2->seg) { -#if 0 //#ifdef POLYOBJECTS_PLANES - if (r2->seg->curline->polyseg && rover->mobj && P_MobjInsidePolyobj(r2->seg->curline->polyseg, rover->mobj)) { - // Determine if we need to sort in front of the polyobj, based on the planes. This fixes the issue where - // polyobject planes render above the object standing on them. (A bit hacky... but it works.) -Red - mobj_t *mo = rover->mobj; - sector_t *po = r2->seg->curline->backsector; - - if (po->ceilingheight < viewz && mo->z+mo->height > po->ceilingheight) - continue; - - if (po->floorheight > viewz && mo->z < po->floorheight) - continue; - } -#endif if (rover->x1 > r2->seg->x2 || rover->x2 < r2->seg->x1) continue; -- 2.54.0 From 3e48bfc8f536f2eaf2abba6e76e69b8418cd3f56 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 17:58:06 +0100 Subject: [PATCH 50/70] dont need SEENAMES esp when we get nametags its obsolete --- src/doomdef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doomdef.h b/src/doomdef.h index 0176258f0..529538a9a 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -579,7 +579,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; //#define DUMPCONSISTENCY /// See name of player in your crosshair -#define SEENAMES +//#define SEENAMES /// Who put weights on my recycler? ... Inuyasha did. /// \note XMOD port. -- 2.54.0 From 10fd8629928781a27b0138e006dd0e79f8167acc Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 18:05:24 +0100 Subject: [PATCH 51/70] Zzz... --- src/hardware/hw_main.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index cb67d7e25..4d379fe85 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1406,12 +1406,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom FUINT lightnum = 0; // shut up compiler extracolormap_t *colormap; FSurfaceInfo Surf; - + boolean noencore = false; gr_sidedef = gr_curline->sidedef; gr_linedef = gr_curline->linedef; - + if (gr_curline->pv1) { vs.x = ((polyvertex_t *)gr_curline->pv1)->x; @@ -1472,11 +1472,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = SOFTLIGHT(gr_frontsector->lightlevel); colormap = gr_frontsector->extra_colormap; lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y); - }else{ + } + else + { lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = gr_frontsector->extra_colormap; } - + if (gr_linedef->flags & ML_TFERLINE) noencore = true; @@ -1564,7 +1566,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); HWR_DrawSkyWall(wallVerts, &Surf); } - } // hack to allow height changes in outdoor areas @@ -2005,16 +2006,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom 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); - } - }else{ + } + else + { if (!(blendmode & PF_Masked)) HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, 0); else - { HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); - } } } else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) @@ -2090,7 +2089,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_DrawSkyWall(wallVerts, &Surf); } - // Single sided lines are simple for skywalls, just need to draw from the top or bottom of the sector if there's // a sky flat if (!gr_curline->polyseg) @@ -2113,7 +2111,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } - //Hurdler: 3d-floors test if (!gl_drawing_stencil && gr_frontsector && gr_backsector && gr_frontsector->tag != gr_backsector->tag && (gr_backsector->ffloors || gr_frontsector->ffloors)) { @@ -2142,7 +2139,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom highcutslope = min(worldtopslope, worldhighslope); } - if (gr_backsector->ffloors) { for (rover = gr_backsector->ffloors; rover; rover = rover->next) @@ -2164,7 +2160,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom continue; } - texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); if (rover->master->flags & ML_TFERLINE) @@ -2201,7 +2196,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } - //Hurdler: HW code starts here //FIXME: check if peging is correct // set top/bottom coords -- 2.54.0 From 3d46dcc277239e392e5e3307f07bb9713aa39d58 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 18:19:11 +0100 Subject: [PATCH 52/70] kill GL_SHADERS --- src/doomdef.h | 3 --- src/hardware/hw_defs.h | 2 -- src/hardware/r_opengl/r_opengl.c | 37 -------------------------------- 3 files changed, 42 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 529538a9a..5d0542392 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -624,9 +624,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #define ROTANGLES 72 // Needs to be a divisor of 360 (45, 60, 90, 120...) #define ROTANGDIFF (360 / ROTANGLES) -/// Hardware renderer: OpenGL -#define GL_SHADERS - #if defined (HAVE_CURL) && ! defined (NONET) #define MASTERSERVER #define HOLEPUNCH diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index f5d0c9a18..b7c46b2e1 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -165,7 +165,6 @@ typedef struct FLOAT s,t; } FOutVector; -#ifdef GL_SHADERS // Shader targets used to render specific types of geometry. // A shader target is resolved to an actual shader with HWR_GetShaderFromTarget. // The shader returned may be a base shader or a custom shader. @@ -203,7 +202,6 @@ enum hwdshaderstage typedef enum hwdshaderstage hwdshaderstage_t; -#endif // ========================================================================== // RENDER MODES diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index f137a7cc8..8f91d5ed9 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -567,7 +567,6 @@ static PFNglStencilFuncSeparate pglStencilFuncSeparate; typedef void (APIENTRY *PFNglStencilOpSeparate) (GLenum, GLenum, GLenum, GLenum); static PFNglStencilOpSeparate pglStencilOpSeparate; -#ifdef GL_SHADERS typedef GLuint (APIENTRY *PFNglCreateShader) (GLenum); typedef void (APIENTRY *PFNglShaderSource) (GLuint, GLsizei, const GLchar**, GLint*); typedef void (APIENTRY *PFNglCompileShader) (GLuint); @@ -698,7 +697,6 @@ static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; "gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \ "}\0" -#endif // GL_SHADERS void SetupGLFunc4(void) { @@ -720,7 +718,6 @@ void SetupGLFunc4(void) pglStencilFuncSeparate = GetGLFunc("glStencilFuncSeparate"); pglStencilOpSeparate = GetGLFunc("glStencilOpSeparate"); -#ifdef GL_SHADERS pglCreateShader = GetGLFunc("glCreateShader"); pglShaderSource = GetGLFunc("glShaderSource"); pglCompileShader = GetGLFunc("glCompileShader"); @@ -742,7 +739,6 @@ void SetupGLFunc4(void) pglUniform2fv = GetGLFunc("glUniform2fv"); pglUniform3fv = GetGLFunc("glUniform3fv"); pglGetUniformLocation = GetGLFunc("glGetUniformLocation"); -#endif #ifdef GL_VERSION_3_0 pglGenerateMipmap = GetGLFunc("glGenerateMipmap"); @@ -751,7 +747,6 @@ void SetupGLFunc4(void) EXPORT boolean HWRAPI(InitShaders) (void) { -#ifdef GL_SHADERS if (!pglUseProgram) return false; @@ -765,14 +760,10 @@ EXPORT boolean HWRAPI(InitShaders) (void) } return true; -#else - return false; -#endif } EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage) { -#ifdef GL_SHADERS gl_shader_t *shader; if (slot < 0 || slot >= HWR_MAXSHADERS) @@ -794,16 +785,10 @@ EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage) I_Error("LoadShader: invalid shader stage"); #undef LOADSHADER -#else - (void)slot; - (void)code; - (void)stage; -#endif } EXPORT boolean HWRAPI(CompileShader) (int slot) { -#ifdef GL_SHADERS if (slot < 0 || slot >= HWR_MAXSHADERS) I_Error("CompileShader: Invalid slot %d", slot); @@ -816,10 +801,6 @@ EXPORT boolean HWRAPI(CompileShader) (int slot) gl_shaders[slot].program = 0; return false; } -#else - (void)slot; - return false; -#endif } // @@ -829,7 +810,6 @@ EXPORT boolean HWRAPI(CompileShader) (int slot) EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) { -#ifdef GL_SHADERS switch (info) { case HWD_SHADERINFO_LEVELTIME: @@ -838,15 +818,10 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) default: break; } -#else - (void)info; - (void)value; -#endif } EXPORT void HWRAPI(SetShader) (int slot) { -#ifdef GL_SHADERS if (gl_allowshaders) { gl_shader_t *next_shader = &gl_shaders[slot]; // the gl_shader_t we are going to switch to @@ -867,22 +842,17 @@ EXPORT void HWRAPI(SetShader) (int slot) return; } -#else - (void)slot; -#endif gl_shadersenabled = false; } EXPORT void HWRAPI(UnSetShader) (void) { -#ifdef GL_SHADERS gl_shaderstate.current = NULL; gl_shaderstate.type = 0; gl_shaderstate.program = 0; if (pglUseProgram) pglUseProgram(0); -#endif gl_shadersenabled = false; } @@ -1639,7 +1609,6 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAFloat *tint, GLRGBAFloat *fade) { -#ifdef GL_SHADERS gl_shader_t *shader = gl_shaderstate.current; if (gl_shadersenabled && (shader != NULL) && pglUseProgram) @@ -1699,12 +1668,6 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF #undef UNIFORM_3 #undef UNIFORM_4 } -#else - (void)Surface; - (void)poly; - (void)tint; - (void)fade; -#endif } static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) -- 2.54.0 From dd7252d9c184f856a9575022d65b0ace9c7fae4b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 18:26:54 +0100 Subject: [PATCH 53/70] kill eslope_typeshim --- src/doomdef.h | 4 ---- src/p_slopes.c | 13 +------------ 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 5d0542392..24bce55f4 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -561,10 +561,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -/// Backwards compatibility with SRB2CB's slope linedef types. -/// \note A simple shim that prints a warning. -#define ESLOPE_TYPESHIM - /// Delete file while the game is running. /// \note EXTREMELY buggy, tends to crash game. //#define DELFILE diff --git a/src/p_slopes.c b/src/p_slopes.c index 4e8918536..112ba008b 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -636,8 +636,6 @@ pslope_t *P_SlopeById(UINT16 id) // Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes void P_ResetDynamicSlopes(void) { size_t i; -#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning - boolean warned = false; slopelist = NULL; slopecount = 0; @@ -648,13 +646,10 @@ void P_ResetDynamicSlopes(void) { { switch (lines[i].special) { -#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning -#define WARNME if (!warned) {warned = true; CONS_Alert(CONS_WARNING, "This level uses old slope specials.\nA conversion will be needed before 2.2's release.\n");} case 386: case 387: case 388: lines[i].special += 700-386; - WARNME P_SpawnSlope_Line(i); break; @@ -663,13 +658,11 @@ void P_ResetDynamicSlopes(void) { case 391: case 392: lines[i].special += 710-389; - WARNME P_SpawnSlope_Line(i); break; case 393: lines[i].special = 703; - WARNME P_SpawnSlope_Line(i); break; @@ -677,11 +670,8 @@ void P_ResetDynamicSlopes(void) { case 395: case 396: lines[i].special += 720-394; - WARNME break; -#endif - case 700: case 701: case 702: @@ -944,5 +934,4 @@ void P_ButteredSlope(mobj_t *mo) P_Thrust(mo, mo->standingslope->xydirection, thrust); } -// EOF -#endif // #ifdef ESLOPE +// EOF \ No newline at end of file -- 2.54.0 From fe22c7aba00acc55911828676e00292986772e84 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 18:33:12 +0100 Subject: [PATCH 54/70] this doesent even exist anymore lmao --- src/doomdef.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 24bce55f4..c8f5f6982 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -598,9 +598,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #define CLIENT_LOADINGSCREEN #endif -/// Experimental tweaks to analog mode. (Needs a lot of work before it's ready for primetime.) -//#define REDSANALOG - /// Backwards compatibility with musicslots. /// \note You should leave this enabled unless you're working with a future SRB2 version. #define MUSICSLOT_COMPATIBILITY -- 2.54.0 From 06045a0751ca81b4af2852ec152db7f1c5a26f05 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 18:38:54 +0100 Subject: [PATCH 55/70] kill weighted recycling --- src/doomdef.h | 4 -- src/p_enemy.c | 104 +------------------------------------------------- 2 files changed, 1 insertion(+), 107 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index c8f5f6982..38dc83f9b 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -577,10 +577,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// See name of player in your crosshair //#define SEENAMES -/// Who put weights on my recycler? ... Inuyasha did. -/// \note XMOD port. -//#define WEIGHTEDRECYCLER - /// Allow loading of savegames between different versions of the game. /// \note XMOD port. /// Most modifications should probably enable this. diff --git a/src/p_enemy.c b/src/p_enemy.c index e617cfbce..cb1a1df4e 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -766,78 +766,6 @@ static boolean P_LookForShield(mobj_t *actor) //return false; } -#ifdef WEIGHTEDRECYCLER -// Compares players to see who currently has the "best" items, etc. -static int P_RecycleCompare(const void *p1, const void *p2) -{ - player_t *player1 = &players[*(const UINT8 *)p1]; - player_t *player2 = &players[*(const UINT8 *)p2]; - - // Non-shooting gametypes - if (!G_RaceGametype()) - { - // Invincibility. - if (player1->powers[pw_invulnerability] > player2->powers[pw_invulnerability]) return -1; - else if (player2->powers[pw_invulnerability] > player1->powers[pw_invulnerability]) return 1; - - // One has a shield, the other doesn't. - if (player1->powers[pw_shield] && !player2->powers[pw_shield]) return -1; - else if (player2->powers[pw_shield] && !player1->powers[pw_shield]) return 1; - - // Sneakers. - if (player1->powers[pw_sneakers] > player2->powers[pw_sneakers]) return -1; - else if (player2->powers[pw_sneakers] > player1->powers[pw_sneakers]) return 1; - } - else // Match, Team Match, CTF, Tag, Etc. - { - UINT8 player1_em = M_CountBits((UINT32)player1->powers[pw_emeralds], 7); - UINT8 player2_em = M_CountBits((UINT32)player2->powers[pw_emeralds], 7); - - UINT8 player1_rw = M_CountBits((UINT32)player1->ringweapons, NUM_WEAPONS-1); - UINT8 player2_rw = M_CountBits((UINT32)player2->ringweapons, NUM_WEAPONS-1); - - UINT16 player1_am = player1->powers[pw_infinityring] // max 800 - + player1->powers[pw_automaticring] // max 300 - + (player1->powers[pw_bouncering] * 3) // max 100 - + (player1->powers[pw_explosionring] * 6) // max 50 - + (player1->powers[pw_scatterring] * 3) // max 100 - + (player1->powers[pw_grenadering] * 6) // max 50 - + (player1->powers[pw_railring] * 6); // max 50 - UINT16 player2_am = player2->powers[pw_infinityring] // max 800 - + player2->powers[pw_automaticring] // max 300 - + (player2->powers[pw_bouncering] * 3) // max 100 - + (player2->powers[pw_explosionring] * 6) // max 50 - + (player2->powers[pw_scatterring] * 3) // max 100 - + (player2->powers[pw_grenadering] * 6) // max 50 - + (player2->powers[pw_railring] * 6); // max 50 - - // Super trumps everything. - if (player1->powers[pw_super] && !player2->powers[pw_super]) return -1; - else if (player2->powers[pw_super] && !player1->powers[pw_super]) return 1; - - // Emerald count if neither player is Super. - if (player1_em > player2_em) return -1; - else if (player1_em < player2_em) return 1; - - // One has a shield, the other doesn't. - // (the likelihood of a shielded player being worse off than one without one is low.) - if (player1->powers[pw_shield] && !player2->powers[pw_shield]) return -1; - else if (player2->powers[pw_shield] && !player1->powers[pw_shield]) return 1; - - // Ring weapons count - if (player1_rw > player2_rw) return -1; - else if (player1_rw < player2_rw) return 1; - - // Ring ammo if they have the same number of weapons - if (player1_am > player2_am) return -1; - else if (player1_am < player2_am) return 1; - } - - // Identical for our purposes - return 0; -} -#endif - // // ACTION ROUTINES // @@ -5834,9 +5762,6 @@ void A_RecyclePowers(mobj_t *actor) { INT32 i, j, k, numplayers = 0; -#ifdef WEIGHTEDRECYCLER - UINT8 beneficiary = 255; -#endif UINT8 playerslist[MAXPLAYERS]; UINT8 postscramble[MAXPLAYERS]; @@ -5849,7 +5774,7 @@ void A_RecyclePowers(mobj_t *actor) return; #endif -#if !defined(WEIGHTEDRECYCLER) && !defined(HAVE_BLUA) +#if !defined(HAVE_BLUA) // actor is used in all scenarios but this one, funny enough (void)actor; #endif @@ -5865,20 +5790,12 @@ void A_RecyclePowers(mobj_t *actor) if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE && !players[i].exiting && !((netgame || multiplayer) && players[i].spectator)) { -#ifndef WEIGHTEDRECYCLER if (players[i].powers[pw_super]) continue; // Ignore super players -#endif numplayers++; postscramble[j] = playerslist[j] = (UINT8)i; -#ifdef WEIGHTEDRECYCLER - // The guy who started the recycle gets the best result - if (actor && actor->target && actor->target->player && &players[i] == actor->target->player) - beneficiary = (UINT8)i; -#endif - // Save powers for (k = 0; k < NUMPOWERS; k++) powers[i][k] = players[i].powers[k]; @@ -5911,25 +5828,6 @@ void A_RecyclePowers(mobj_t *actor) postscramble[i] = tempint; } -#ifdef WEIGHTEDRECYCLER - //the joys of qsort... - if (beneficiary != 255) { - qsort(playerslist, numplayers, sizeof(UINT8), P_RecycleCompare); - - // now, make sure the benificiary is in the best slot - // swap out whatever poor sap was going to get the best items - for (i = 0; i < numplayers; i++) - { - if (postscramble[i] == beneficiary) - { - postscramble[i] = postscramble[0]; - postscramble[0] = beneficiary; - break; - } - } - } -#endif - // now assign! for (i = 0; i < numplayers; i++) { -- 2.54.0 From 694a397ba4bacce079c14d8fab7a16acb5160e75 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 19:01:44 +0100 Subject: [PATCH 56/70] kill delfile --- src/d_netcmd.c | 90 +---------- src/dehacked.c | 404 +------------------------------------------------ src/dehacked.h | 5 - src/doomdef.h | 4 - src/p_setup.c | 28 ---- src/p_setup.h | 3 - src/r_things.c | 156 ------------------- src/r_things.h | 8 - src/st_stuff.h | 3 - src/w_wad.c | 31 ---- src/w_wad.h | 3 - 11 files changed, 3 insertions(+), 732 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 21f60b7cd..e185f3286 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -73,9 +73,6 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum); static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum); static void Got_PickVotecmd(UINT8 **cp, INT32 playernum); static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum); -#ifdef DELFILE -static void Got_Delfilecmd(UINT8 **cp, INT32 playernum); -#endif static void Got_Addfilecmd(UINT8 **cp, INT32 playernum); static void Got_Pause(UINT8 **cp, INT32 playernum); static void Got_Respawn(UINT8 **cp, INT32 playernum); @@ -144,9 +141,6 @@ static void Command_Addfile(void); static void Command_Addskins(void); static void Command_GLocalSkin(void); static void Command_ListWADS_f(void); -#ifdef DELFILE -static void Command_Delfile(void); -#endif static void Command_RunSOC(void); static void Command_Pause(void); static void Command_Respawn(void); @@ -573,7 +567,7 @@ const char *netxcmdnames[MAXNETXCMD - 1] = "RANDOMSEED", "RUNSOC", "REQADDFILE", - "DELFILE", + "DELFILE", // sigh well this prob needs to be still here to not screw up maxnetxcmd "SETMOTD", "RESPAWN", "DEMOTED", @@ -622,9 +616,6 @@ void D_RegisterServerCommands(void) RegisterNetXCmd(XD_EXITLEVEL, Got_ExitLevelcmd); RegisterNetXCmd(XD_ADDFILE, Got_Addfilecmd); RegisterNetXCmd(XD_REQADDFILE, Got_RequestAddfilecmd); -#ifdef DELFILE - RegisterNetXCmd(XD_DELFILE, Got_Delfilecmd); -#endif RegisterNetXCmd(XD_PAUSE, Got_Pause); RegisterNetXCmd(XD_RESPAWN, Got_Respawn); RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd); @@ -667,9 +658,6 @@ void D_RegisterServerCommands(void) COM_AddCommand("localskin", Command_GLocalSkin); COM_AddCommand("listwad", Command_ListWADS_f); -#ifdef DELFILE - COM_AddCommand("delfile", Command_Delfile); -#endif COM_AddCommand("runsoc", Command_RunSOC); COM_AddCommand("pause", Command_Pause); COM_AddCommand("respawn", Command_Respawn); @@ -732,19 +720,6 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_competitionboxes); CV_RegisterVar(&cv_matchboxes); - /*CV_RegisterVar(&cv_recycler); - CV_RegisterVar(&cv_teleporters); - CV_RegisterVar(&cv_superring); - CV_RegisterVar(&cv_supersneakers); - CV_RegisterVar(&cv_invincibility); - CV_RegisterVar(&cv_jumpshield); - CV_RegisterVar(&cv_watershield); - CV_RegisterVar(&cv_ringshield); - CV_RegisterVar(&cv_forceshield); - CV_RegisterVar(&cv_bombshield); - CV_RegisterVar(&cv_1up); - CV_RegisterVar(&cv_eggmanbox);*/ - K_RegisterKartStuff(); // SRB2kart CV_RegisterVar(&cv_ringslinger); @@ -4745,42 +4720,6 @@ static void Command_GLocalSkin (void) } } -#ifdef DELFILE -/** removes the last added pwad at runtime. - * Searches for sounds, maps, music and images to remove - */ -static void Command_Delfile(void) -{ - if (gamestate == GS_LEVEL) - { - CONS_Printf(M_GetText("You must NOT be in a level to use this.\n")); - return; - } - - if (netgame && !(server || adminplayer == consoleplayer)) - { - CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); - return; - } - - if (numwadfiles <= mainwads) - { - CONS_Printf(M_GetText("No additional WADs are loaded.\n")); - return; - } - - if (!(netgame || multiplayer)) - { - P_DelWadFile(); - if (mainwads == numwadfiles && modifiedgame) - modifiedgame = false; - return; - } - - SendNetXCmd(XD_DELFILE, NULL, 0); -} -#endif - static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; @@ -4849,33 +4788,6 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) COM_BufAddText(va("addfile %s\n", filename)); } -#ifdef DELFILE -static void Got_Delfilecmd(UINT8 **cp, INT32 playernum) -{ - if (playernum != serverplayer && playernum != adminplayer) - { - CONS_Alert(CONS_WARNING, M_GetText("Illegal delfile command received from %s\n"), player_names[playernum]); - if (server) - { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); - } - return; - } - (void)cp; - - if (numwadfiles <= mainwads) //sanity - return; - - P_DelWadFile(); - if (mainwads == numwadfiles && modifiedgame) - modifiedgame = false; -} -#endif - static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) { char filename[241]; diff --git a/src/dehacked.c b/src/dehacked.c index c443e839c..6260f4f65 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -74,97 +74,6 @@ static powertype_t get_power(const char *word); boolean deh_loaded = false; static int dbg_line; -#ifdef DELFILE -typedef struct undehacked_s -{ - char *undata; - struct undehacked_s *next; -} undehacked_t; - -static UINT16 unsocwad; -static undehacked_t *unsocdata[MAX_WADFILES]; -static boolean disableundo = false; - -void DEH_WriteUndoline(const char *value, const char *data, undotype_f flags) -{ - const char *eqstr = " = "; - const char *space = " "; - const char *pader = eqstr; - undehacked_t *newdata; - - if (disableundo || !unsocwad) - return; - - if ((newdata = malloc(sizeof(*newdata))) == NULL) - I_Error("Out of memory for unsoc line"); - - if (flags & UNDO_SPACE) - pader = space; - - if (flags & UNDO_ENDTEXT && !data) - data = space; - - if (value) - { - const size_t plen = strlen(pader); - const char *pound = "#"; - char *undata = NULL; - const size_t elen = strlen(pound); - size_t vlen = strlen(value), dlen = 0, len = 1; - - if (*(value+vlen-1) == '\n') - vlen--; // lnet not copy the ending \n - - if (flags & UNDO_ENDTEXT) - len += elen; // let malloc more space - - if (flags & UNDO_NEWLINE) - len++; // more space for the beginning \n - - if (data) - { - dlen = strlen(data); - if (flags & UNDO_CUTLINE && *(data+dlen-1) == '\n') - dlen--; // let not copy the ending \n - newdata->undata = malloc(vlen+plen+dlen+len); - newdata->undata[vlen+plen+dlen+len-1] = '\0'; - } - else - { - newdata->undata = malloc(vlen+len); - newdata->undata[vlen+len-1] = '\0'; - } - - if (newdata->undata) - { - undata = newdata->undata; - *undata = '\0'; - } - else - { - free(newdata); - I_Error("Out of memory for unsoc data"); - } - - if (flags & UNDO_NEWLINE) // let start with \n - strcat(undata, "\n"); - - strncat(undata, value, vlen); - - if (data) // value+pader+data - strncat(strncat(undata, pader, plen), data, dlen); - - if (flags & UNDO_ENDTEXT) // let end the text - strncat(undata, pound, elen); - } - else - newdata->undata = NULL; - - newdata->next = unsocdata[unsocwad]; - unsocdata[unsocwad] = newdata; -} -#endif - ATTRINLINE static FUNCINLINE char myfget_color(MYFILE *f) { char c = *f->curpos++; @@ -361,56 +270,6 @@ static void clear_levels(void) P_AllocMapHeader(gamemap-1); } -/* -// Edits an animated texture slot on the array -// Tails 12-27-2003 -static void readAnimTex(MYFILE *f, INT32 num) -{ - char s[MAXLINELEN]; - char *word; - char *word2; - INT32 i; - - do { - if (myfgets(s, sizeof s, f) != NULL) - { - if (s[0] == '\n') break; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - // set the value in the appropriate field - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - word2 = strtok(NULL, " = "); - if (word2) - strupr(word2); - else - break; - - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - - i = atoi(word2); - - if (fastcmp(word, "START")) - strncpy(harddefs[num].startname, word2, 8); - if (fastcmp(word, "END")) - strncpy(harddefs[num].endname, word2, 8); - else if (fastcmp(word, "SPEED")) harddefs[num].speed = i; - else if (fastcmp(word, "ISTEXTURE")) harddefs[num].istexture = i; - - else deh_warning("readAnimTex %d: unknown word '%s'", num, word); - } - } while (s[0] != '\n' && !myfeof(f)); //finish when the line is empty -} -*/ - static boolean findFreeSlot(INT32 *num) { // Send the character select entry to a free slot. @@ -502,29 +361,7 @@ static void readPlayer(MYFILE *f, INT32 num) word2[strlen(word2)-1] = '\0'; i = atoi(word2); - /*if (fastcmp(word, "PLAYERNAME")) - { - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - DEH_WriteUndoline(word, description[num].text, UNDO_NONE); - strlcpy(description[num].text, word2, sizeof (description[num].text)); - for (word2 = description[num].text; *word2; word2++) - if (*word2 == '_') - *word2 = ' '; - PlayerMenu[num].text = description[num].text; - }*/ -/* else if (fastcmp(word, "MENUPOSITION")) - { // Make sure you make MENUPOSITION the first thing under CHARACTER if you're using it! - // This is to manually choose a slot and overwrite existing characters! It is NOT necessary for most individual character wads!! -#ifdef DELFILE - if (disableundo) -#endif - { - slotfound = true; - num = i; - } - } */ - /*else*/ if (fastcmp(word, "PICNAME")) + if (fastcmp(word, "PICNAME")) { if (!slotfound && (slotfound = findFreeSlot(&num)) == false) goto done; @@ -571,11 +408,6 @@ static void readPlayer(MYFILE *f, INT32 num) } } while (!myfeof(f)); // finish when the line is empty -#ifdef DELFILE - if (slotfound) - DEH_WriteUndoline("MENUPOSITION", va("%d", num), UNDO_NONE); -#endif - done: Z_Free(s); } @@ -1479,9 +1311,6 @@ static void readcutscene(MYFILE *f, INT32 num) char *word2; char *tmp; INT32 value; -#ifdef DELFILE - const INT32 oldnumscenes = cutscenes[num]->numscenes; -#endif // Allocate memory for this cutscene if we don't yet have any if (!cutscenes[num]) @@ -1973,21 +1802,7 @@ static void readsound(MYFILE *f, INT32 num, const char *savesfxnames[]) else break; -/* if (fastcmp(word, "OFFSET")) - { - value -= 150360; - if (value <= 64) - value /= 8; - else if (value <= 260) - value = (value+4)/8; - else - value = (value+8)/8; - if (value >= -1 && value < sfx_freeslot0 - 1) - S_sfx[num].name = savesfxnames[value+1]; - else - deh_warning("Sound %d: offset out of bounds", num); - } - else */if (fastcmp(word, "SINGULAR")) + if (fastcmp(word, "SINGULAR")) { DEH_WriteUndoline(word, va("%d", S_sfx[num].singularity), UNDO_NONE); S_sfx[num].singularity = value; @@ -2171,10 +1986,6 @@ static void reademblemdata(MYFILE *f, INT32 num) // Default sprite and color definitions for lazy people like me if (!emblemlocations[num-1].sprite) switch (emblemlocations[num-1].type) { - /*case ET_RINGS: - emblemlocations[num-1].sprite = 'R'; break; - case ET_SCORE: case ET_NGRADE: - emblemlocations[num-1].sprite = 'S'; break;*/ case ET_TIME: //case ET_NTIME: emblemlocations[num-1].sprite = 'B'; break; default: @@ -2182,12 +1993,6 @@ static void reademblemdata(MYFILE *f, INT32 num) } if (!emblemlocations[num-1].color) switch (emblemlocations[num-1].type) { - /*case ET_RINGS: - emblemlocations[num-1].color = SKINCOLOR_GOLD; break; - case ET_SCORE: - emblemlocations[num-1].color = SKINCOLOR_BROWN; break; - case ET_NGRADE: - emblemlocations[num-1].color = SKINCOLOR_TEAL; break;*/ case ET_TIME: //case ET_NTIME: emblemlocations[num-1].color = SKINCOLOR_GREY; break; default: @@ -2494,34 +2299,6 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) return; } } - /*else if ((offset=0) || fastcmp(params[0], "NIGHTSSCORE") - || (++offset && fastcmp(params[0], "NIGHTSTIME")) - || (++offset && fastcmp(params[0], "NIGHTSGRADE"))) - { - PARAMCHECK(2); // one optional one - - ty = UC_NIGHTSSCORE + offset; - re = atoi(params[2 + !!(params[3])]); - - // Convert to map number if it appears to be one - if (params[1][0] >= 'A' && params[1][0] <= 'Z') - x1 = (INT16)M_MapNumber(params[1][0], params[1][1]); - else - x1 = (INT16)atoi(params[1]); - - if (x1 < 0 || x1 >= NUMMAPS) - { - deh_warning("Level number %d out of range (1 - %d)", re, NUMMAPS); - return; - } - - // Mare number (0 for overall) - if (params[3]) // Only if we actually got 3 params (so the second one == mare and not requirement) - x2 = (INT16)atoi(params[2]); - else - x2 = 0; - - }*/ else if (fastcmp(params[0], "TRIGGER")) { PARAMCHECK(1); @@ -2719,15 +2496,6 @@ static void readpatch(MYFILE *f, const char *name, UINT16 wad) } } while (!myfeof(f)); - // Error checking. - /* // Irrelevant. Origins cannot be unsigned. - if (patch.originx == UINT16_MAX) - I_Error("Patch %s on texture %s has no X position!\n", name, textures[i]->name); - - if (patch.originy == UINT16_MAX) - I_Error("Patch %s on texture %s has no Y position!\n", name, textures[i]->name); -*/ - // Set the patch as that patch number. textures[i]->patches[j] = patch; @@ -3338,29 +3106,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) } DEH_WriteUndoline(word, word2, UNDO_HEADER); } - // Added translations to this just in case its re-enabled -/* else if (fastcmp(word, "POINTER")) - { - word = strtok(NULL, " "); // get frame - word = strtok(NULL, ")"); - if (word) - { - i = atoi(word); - if (i < NUMSTATES && i >= 0) - { - if (myfgets(s, MAXLINELEN, f)) - states[i].action = saveactions[searchvalue(s)]; - } - else - { - deh_warning("Pointer: Frame %d doesn't exist", i); - ignorelines(f); - } - } - else - deh_warning("pointer (Frame %d) : missing ')'", i); - G_SetGameModified(multiplayer, true); - }*/ else if (fastcmp(word, "SOUND")) { if (i == 0 && word2[0] != '0') // If word2 isn't a number @@ -3375,27 +3120,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) DEH_WriteUndoline(word, word2, UNDO_HEADER); // This is not a major mod. } -/* else if (fastcmp(word, "SPRITE")) - { - if (i < NUMSPRITES && i >= 0) - { - if (myfgets(s, MAXLINELEN, f)) - { - INT32 k; - k = (searchvalue(s) - 151328)/8; - if (k >= 0 && k < NUMSPRITES) - sprnames[i] = savesprnames[k]; - else - { - deh_warning("Sprite %d: offset out of bounds", i); - ignorelines(f); - } - } - } - else - deh_warning("Sprite %d doesn't exist",i); - // This is not a major mod. - }*/ else if (fastcmp(word, "HUDITEM")) { if (i == 0 && word2[0] != '0') // If word2 isn't a number @@ -3540,9 +3264,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_warning("No word in this line: %s", s); } // end while - /*if (gamedataadded) -- REFRESHDIR_GAMEDATA murdered this - G_LoadGameData();*/ - dbg_line = -1; if (deh_num_warning) { @@ -3563,9 +3284,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump) { MYFILE f; -#ifdef DELFILE - unsocwad = wad; -#endif f.wad = wad; f.size = W_LumpLengthPwad(wad, lump); f.data = Z_Malloc(f.size + 1, PU_STATIC, NULL); @@ -3582,67 +3300,6 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum) DEH_LoadDehackedLumpPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum)); } -#ifdef DELFILE -#define DUMPUNDONE - -// read (un)dehacked lump in wad's memory -void DEH_UnloadDehackedWad(UINT16 wad) -{ - undehacked_t *tmp, *curundo = unsocdata[wad]; - MYFILE f; - size_t len = 0; - char *data; -#ifdef DUMPUNDONE - FILE *UNDO = fopen("undo.soc", "wt"); -#endif - CONS_Printf(M_GetText("Unloading WAD SOC edits\n")); - while (curundo) - { - data = curundo->undata; - curundo = curundo->next; - if (data) - len += strlen(data); - len += 1; -#ifdef DUMPUNDONE - if (UNDO) - { - if (data) - fprintf(UNDO, "%s\n", data); - else - fprintf(UNDO, "\n"); - } -#endif - } -#ifndef DUMPUNDONE - if (UNDO) fclose(UNDO); -#endif - if (!len) return; - f.size = len; - data = f.data = Z_Malloc(f.size + 1, PU_STATIC, NULL); - curundo = unsocdata[wad]; - unsocdata[wad] = NULL; - while (curundo) - { - tmp = curundo; - curundo = curundo->next; - if (tmp->undata) - data += sprintf(data, "%s\n", tmp->undata); - else - data += sprintf(data, "\n"); - if (tmp->undata) free(tmp->undata); - free(tmp); - } - f.wad = wad; - f.curpos = f.data; - f.data[f.size] = 0; - disableundo = true; - DEH_LoadDehackedFile(&f); - disableundo = false; - Z_Free(f.data); -} -#endif //DELFILE - - //////////////////////////////////////////////////////////////////////////////// // CRAZY LIST OF STATE NAMES AND ALL FROM HERE DOWN // TODO: Make this all a seperate file or something, like part of info.c?? @@ -3696,63 +3353,6 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_KART_SPIN", "S_KART_PAIN", "S_KART_SQUISH", - /* - "S_PLAY_STND", - "S_PLAY_TAP1", - "S_PLAY_TAP2", - "S_PLAY_RUN1", - "S_PLAY_RUN2", - "S_PLAY_RUN3", - "S_PLAY_RUN4", - "S_PLAY_RUN5", - "S_PLAY_RUN6", - "S_PLAY_RUN7", - "S_PLAY_RUN8", - "S_PLAY_SPD1", - "S_PLAY_SPD2", - "S_PLAY_SPD3", - "S_PLAY_SPD4", - "S_PLAY_ATK1", - "S_PLAY_ATK2", - "S_PLAY_ATK3", - "S_PLAY_ATK4", - "S_PLAY_SPRING", - "S_PLAY_FALL1", - "S_PLAY_FALL2", - "S_PLAY_ABL1", - "S_PLAY_ABL2", - "S_PLAY_SPC1", - "S_PLAY_SPC2", - "S_PLAY_SPC3", - "S_PLAY_SPC4", - "S_PLAY_CLIMB1", - "S_PLAY_CLIMB2", - "S_PLAY_CLIMB3", - "S_PLAY_CLIMB4", - "S_PLAY_CLIMB5", - "S_PLAY_GASP", - "S_PLAY_PAIN", - "S_PLAY_DIE", - "S_PLAY_TEETER1", - "S_PLAY_TEETER2", - "S_PLAY_CARRY", - "S_PLAY_SUPERSTAND", - "S_PLAY_SUPERWALK1", - "S_PLAY_SUPERWALK2", - "S_PLAY_SUPERFLY1", - "S_PLAY_SUPERFLY2", - "S_PLAY_SUPERTEETER", - "S_PLAY_SUPERHIT", - "S_PLAY_SUPERTRANS1", - "S_PLAY_SUPERTRANS2", - "S_PLAY_SUPERTRANS3", - "S_PLAY_SUPERTRANS4", - "S_PLAY_SUPERTRANS5", - "S_PLAY_SUPERTRANS6", - "S_PLAY_SUPERTRANS7", - "S_PLAY_SUPERTRANS8", - "S_PLAY_SUPERTRANS9", // This has special significance in the code. If you add more frames, search for it and make the appropriate changes. - */ // technically the player goes here but it's an infinite tic state "S_OBJPLACE_DUMMY", diff --git a/src/dehacked.h b/src/dehacked.h index 0d6cc9022..d3e4b0e7b 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -27,12 +27,7 @@ typedef enum UNDO_DONE = 0, } undotype_f; -#ifdef DELFILE -void DEH_WriteUndoline(const char *value, const char *data, undotype_f flags); -void DEH_UnloadDehackedWad(UINT16 wad); -#else // null the undo lines #define DEH_WriteUndoline(a,b,c) -#endif void DEH_LoadDehackedLump(lumpnum_t lumpnum); void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump); diff --git a/src/doomdef.h b/src/doomdef.h index 38dc83f9b..620440d49 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -561,10 +561,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -/// Delete file while the game is running. -/// \note EXTREMELY buggy, tends to crash game. -//#define DELFILE - /// Allows the use of devmode in multiplayer. AKA "fishcake" //#define NETGAME_DEVMODE diff --git a/src/p_setup.c b/src/p_setup.c index 5d5c56ac3..ad2de63c2 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3584,31 +3584,3 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) return false; } } - -#ifdef DELFILE -boolean P_DelWadFile(void) -{ - sfxenum_t i; - const UINT16 wadnum = (UINT16)(numwadfiles - 1); - const lumpnum_t lumpnum = numwadfiles<<16; - //lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo; - R_DelSkins(wadnum); // only used by DELFILE - R_DelSpriteDefs(wadnum); // only used by DELFILE - for (i = 0; i < NUMSFX; i++) - { - if (S_sfx[i].lumpnum != LUMPERROR && S_sfx[i].lumpnum >= lumpnum) - { - S_StopSoundByNum(i); - S_RemoveSoundFx(i); - if (S_sfx[i].lumpnum != LUMPERROR) - { - I_FreeSfx(&S_sfx[i]); - S_sfx[i].lumpnum = LUMPERROR; - } - } - } - W_UnloadWadFile(wadnum); // only used by DELFILE - R_LoadTextures(); - return false; -} -#endif diff --git a/src/p_setup.h b/src/p_setup.h index 42c8cb773..9e66fff81 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -65,9 +65,6 @@ void HWR_LoadLevel(void); #endif boolean P_AddWadFile(const char *wadfilename, boolean local); boolean P_AddWadFileLocal(const char *wadfilename); -#ifdef DELFILE -boolean P_DelWadFile(void); -#endif // WARNING: The following functions should be grouped as follows: // any amount of PartialAdds followed by MultiSetups until returned true, diff --git a/src/r_things.c b/src/r_things.c index 2905830fd..2d9b880e0 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -475,116 +475,6 @@ void R_AddSpriteDefs(UINT16 wadnum) CONS_Printf(M_GetText("%s added %d frames in %s sprites\n"), wadname, end-start, sizeu1(addsprites)); } -#ifdef DELFILE -static void R_RemoveSpriteLump(UINT16 wad, // graphics patch - UINT16 lump, - size_t lumpid, // identifier - UINT8 frame, - UINT8 rotation, - UINT8 flipped) -{ - (void)wad; /// \todo: how do I remove sprites? - (void)lump; - (void)lumpid; - (void)frame; - (void)rotation; - (void)flipped; -} - -static boolean R_DelSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump) -{ - UINT16 l; - UINT8 frame; - UINT8 rotation; - lumpinfo_t *lumpinfo; - - maxframe = (size_t)-1; - - // scan the lumps, - // filling in the frames for whatever is found - lumpinfo = wadfiles[wadnum]->lumpinfo; - if (endlump > wadfiles[wadnum]->numlumps) - endlump = wadfiles[wadnum]->numlumps; - - for (l = startlump; l < endlump; l++) - { - if (memcmp(lumpinfo[l].name,sprname,4)==0) - { - frame = (UINT8)(lumpinfo[l].name[4] - 'A'); - rotation = (UINT8)(lumpinfo[l].name[5] - '0'); - - // skip NULL sprites from very old dmadds pwads - if (W_LumpLengthPwad(wadnum,l)<=8) - continue; - - //---------------------------------------------------- - - R_RemoveSpriteLump(wadnum, l, numspritelumps, frame, rotation, 0); - - if (lumpinfo[l].name[6]) - { - frame = (UINT8)(lumpinfo[l].name[6] - 'A'); - rotation = (UINT8)(lumpinfo[l].name[7] - '0'); - R_RemoveSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1); - } - } - } - - if (maxframe == (size_t)-1) - return false; - - spritedef->numframes = 0; - Z_Free(spritedef->spriteframes); - spritedef->spriteframes = NULL; - return true; -} - -void R_DelSpriteDefs(UINT16 wadnum) -{ - size_t i, delsprites = 0; - UINT16 start, end; - - // find the sprites section in this pwad - // we need at least the S_END - // (not really, but for speedup) - - start = W_CheckNumForNamePwad("S_START", wadnum, 0); - if (start == INT16_MAX) - start = W_CheckNumForNamePwad("SS_START", wadnum, 0); //deutex compatib. - if (start == INT16_MAX) - start = 0; //let say S_START is lump 0 - else - start++; // just after S_START - - end = W_CheckNumForNamePwad("S_END",wadnum,start); - if (end == INT16_MAX) - end = W_CheckNumForNamePwad("SS_END",wadnum,start); //deutex compatib. - if (end == INT16_MAX) - { - CONS_Debug(DBG_SETUP, "no sprites in pwad %d\n", wadnum); - return; - //I_Error("R_DelSpriteDefs: S_END, or SS_END missing for sprites " - // "in pwad %d\n",wadnum); - } - - // - // scan through lumps, for each sprite, find all the sprite frames - // - for (i = 0; i < numsprites; i++) - { - spritename = sprnames[i]; - - if (R_DelSingleSpriteDef(spritename, &sprites[i], wadnum, start, end)) - { - // if a new sprite was removed (not just replaced) - delsprites++; - CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", spritename, wadnum); - } - } - - CONS_Printf(M_GetText("%s sprites removed from file %s\n"), sizeu1(delsprites), wadfiles[wadnum]->filename); -} -#endif // // GAME FUNCTIONS @@ -3703,49 +3593,3 @@ next_token: return; } - -#ifdef DELFILE -void R_DelSkins(UINT16 wadnum) -{ - UINT16 lump, lastlump = 0; - while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) - { - if (skins[numskins].wadnum != wadnum) - break; - numskins--; - ST_UnLoadFaceGraphics(numskins); // only used by DELFILE - if (skins[numskins].sprite[0] != '\0') - { - const char *csprname = W_CheckNameForNumPwad(wadnum, lump); - - // skip to end of this skin's frames - lastlump = lump; - while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),csprname,4)==0) - lastlump++; - // allocate (or replace) sprite frames, and set spritedef - R_DelSingleSpriteDef(csprname, &skins[numskins].spritedef, wadnum, lump, lastlump); - } - else - { - // search in the normal sprite tables - size_t name; - boolean found = false; - const char *sprname = skins[numskins].sprite; - for (name = 0;sprnames[name][0] != '\0';name++) - if (strcmp(sprnames[name], sprname) == 0) - { - found = true; - skins[numskins].spritedef = sprites[name]; - } - - // not found so make a new one - if (!found) - R_DelSingleSpriteDef(sprname, &skins[numskins].spritedef, wadnum, 0, INT16_MAX); - - while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),sprname,4)==0) - lastlump++; - } - CONS_Printf(M_GetText("Removed skin '%s'\n"), skins[numskins].name); - } -} -#endif diff --git a/src/r_things.h b/src/r_things.h index e6470a952..7a22b0ef1 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -61,10 +61,6 @@ void R_SortVisSprites(void); // (only sprites from namelist are added or replaced) void R_AddSpriteDefs(UINT16 wadnum); -#ifdef DELFILE -void R_DelSpriteDefs(UINT16 wadnum); -#endif - //SoM: 6/5/2000: Light sprites correctly! void R_AddSprites(sector_t *sec, INT32 lightlevel); void R_InitSprites(void); @@ -229,10 +225,6 @@ INT32 R_AnySkinAvailable(const char *name); INT32 R_LocalSkinAvailable(const char *name, boolean local); void R_AddSkins(UINT16 wadnum, boolean local); -#ifdef DELFILE -void R_DelSkins(UINT16 wadnum); -#endif - void R_InitDrawNodes(void); char *GetPlayerFacePic(INT32 skinnum); diff --git a/src/st_stuff.h b/src/st_stuff.h index 0dffa46c3..994bec9d2 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -53,9 +53,6 @@ void ST_LoadGraphics(void); void ST_LoadFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum); void ST_LoadLocalFaceGraphics(char *rankstr, char *wantstr, char *mmapstr, INT32 playernum); void ST_ReloadSkinFaceGraphics(void); -#ifdef DELFILE -void ST_UnLoadFaceGraphics(INT32 skinnum); -#endif void ST_doPaletteStuff(void); diff --git a/src/w_wad.c b/src/w_wad.c index 44bb71ee9..1d1b18ccb 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -859,37 +859,6 @@ UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, b return wadfile->numlumps; } -#ifdef DELFILE -void W_UnloadWadFile(UINT16 num) -{ - INT32 i; - wadfile_t *delwad = wadfiles[num]; - lumpcache_t *lumpcache; - if (num == 0) - return; - CONS_Printf(M_GetText("Removing WAD %s...\n"), wadfiles[num]->filename); - - DEH_UnloadDehackedWad(num); - wadfiles[num] = NULL; - lumpcache = delwad->lumpcache; - numwadfiles--; -#ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - HWR_FreeTextureCache(); - M_AATreeFree(delwad->hwrcache); -#endif - if (*lumpcache) - { - for (i = 0;i < delwad->numlumps;i++) - Z_ChangeTag(lumpcache[i], PU_PURGELEVEL); - } - Z_Free(lumpcache); - fclose(delwad->handle); - Z_Free(delwad->filename); - Z_Free(delwad); - CONS_Printf(M_GetText("Done unloading WAD.\n")); -} -#endif /** Tries to load a series of files. * All files are wads unless they have an extension of ".soc" or ".lua". diff --git a/src/w_wad.h b/src/w_wad.h index 4b083ece6..71d50c718 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -137,9 +137,6 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors); // if local is true, it wouldn't check if file adds complex things, therefore // allowing to still join server without the "you have wrong addons loaded" error UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, boolean local); -#ifdef DELFILE -void W_UnloadWadFile(UINT16 num); -#endif // W_InitMultipleFiles returns 1 if all is okay, 0 otherwise, // so that it stops with a message if a file was not found, but not if all is okay. -- 2.54.0 From c5461dca4b35c6527095bc73a7f967d2948a436a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 22:05:49 +0100 Subject: [PATCH 57/70] Revert "dont need SEENAMES" This reverts commit 3e48bfc8f536f2eaf2abba6e76e69b8418cd3f56. --- src/doomdef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doomdef.h b/src/doomdef.h index 620440d49..3ad545f78 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -571,7 +571,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; //#define DUMPCONSISTENCY /// See name of player in your crosshair -//#define SEENAMES +#define SEENAMES /// Allow loading of savegames between different versions of the game. /// \note XMOD port. -- 2.54.0 From 0df5f4530e24169cacf997351f94fa267175806f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 22:08:14 +0100 Subject: [PATCH 58/70] kill have_blua --- src/Makefile | 6 +- src/b_bot.c | 4 - src/blua/Makefile.cfg | 2 - src/command.c | 19 +- src/d_clisrv.c | 14 +- src/d_main.c | 8 +- src/d_netcmd.c | 22 +- src/d_netcmd.h | 2 - src/dehacked.c | 278 +--------- src/dehacked.h | 2 - src/filesrch.h | 2 +- src/g_game.c | 24 +- src/hu_stuff.c | 35 +- src/k_kart.c | 94 +--- src/lua_baselib.c | 5 +- src/lua_blockmaplib.c | 5 +- src/lua_consolelib.c | 5 +- src/lua_hook.h | 6 +- src/lua_hooklib.c | 5 +- src/lua_hudlib.c | 5 +- src/lua_infolib.c | 5 +- src/lua_libs.h | 6 +- src/lua_maplib.c | 5 +- src/lua_mathlib.c | 5 +- src/lua_mobjlib.c | 5 +- src/lua_playerlib.c | 5 +- src/lua_script.c | 5 +- src/lua_script.h | 4 - src/lua_skinlib.c | 5 +- src/lua_thinkerlib.c | 5 +- src/lua_udatalib.h | 6 +- src/m_cheat.c | 4 +- src/m_cheat.h | 2 +- src/m_menu.c | 7 +- src/p_enemy.c | 633 +++++++-------------- src/p_inter.c | 119 +--- src/p_map.c | 2 - src/p_mobj.c | 46 +- src/p_saveg.c | 7 +- src/p_setup.c | 4 - src/p_spec.c | 4 - src/p_tick.c | 26 - src/p_user.c | 10 - src/s_sound.c | 6 +- src/st_stuff.c | 1211 +---------------------------------------- src/w_wad.c | 9 +- src/y_inter.c | 30 - 47 files changed, 276 insertions(+), 2443 deletions(-) diff --git a/src/Makefile b/src/Makefile index 4096f1104..bed91c98c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -389,9 +389,7 @@ CFLAGS+=-DHAVE_DISCORDRPC -DUSE_STUN OBJS+=$(OBJDIR)/discord.o $(OBJDIR)/stun.o endif -ifndef NO_LUA include blua/Makefile.cfg -endif ifdef NOMD5 OPTS+=-DNOMD5 @@ -721,9 +719,9 @@ $(OBJDIR)/depend.dep: ifndef NOHW $(CC) $(CFLAGS) -MM hardware/*.c >> $(OBJDIR)/depend.ped endif -ifndef NO_LUA + $(CC) $(CFLAGS) -MM blua/*.c >> $(OBJDIR)/depend.ped -endif + @sed -e 's,\(.*\)\.o: ,$(subst /,\/,$(OBJDIR))\/&,g' < $(OBJDIR)/depend.ped > $(OBJDIR)/depend.dep $(REMOVE) $(OBJDIR)/depend.ped @echo "Created dependency file, depend.dep" diff --git a/src/b_bot.c b/src/b_bot.c index 7c14c44a3..edaf477ad 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -35,11 +35,9 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm if (!sonic || sonic->health <= 0) return; -#ifdef HAVE_BLUA // Lua can handle it! if (LUAh_BotAI(sonic, tails, cmd)) return; -#endif if (tails->player->pflags & (PF_MACESPIN|PF_ITEMHANG)) { @@ -123,11 +121,9 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) // Bot AI isn't programmed in analog. //CV_SetValue(&cv_analog2, false); -#ifdef HAVE_BLUA // Let Lua scripts build ticcmds if (LUAh_BotTiccmd(player, cmd)) return; -#endif // We don't have any main character AI, sorry. D: if (player-players == consoleplayer) diff --git a/src/blua/Makefile.cfg b/src/blua/Makefile.cfg index a7146c79e..19b34383c 100644 --- a/src/blua/Makefile.cfg +++ b/src/blua/Makefile.cfg @@ -10,8 +10,6 @@ WFLAGS+=-Wno-logical-op endif endif -OPTS+=-DHAVE_BLUA - OBJS:=$(OBJS) \ $(OBJDIR)/lapi.o \ $(OBJDIR)/lbaselib.o \ diff --git a/src/command.c b/src/command.c index 165cbb584..af5d936ca 100644 --- a/src/command.c +++ b/src/command.c @@ -459,13 +459,11 @@ void COM_AddCommand(const char *name, com_func_t func) { if (!stricmp(name, cmd->name)) //case insensitive now that we have lower and uppercase! { -#ifdef HAVE_BLUA // don't I_Error for Lua commands // Lua commands can replace game commands, and they have priority. // BUT, if for some reason we screwed up and made two console commands with the same name, // it's good to have this here so we find out. if (cmd->function != COM_Lua_f) -#endif I_Error("Command %s already exists\n", name); return; @@ -479,7 +477,6 @@ void COM_AddCommand(const char *name, com_func_t func) com_commands = cmd; } -#ifdef HAVE_BLUA /** Adds a console command for Lua. * No I_Errors allowed; return a negative code instead. * @@ -512,7 +509,6 @@ int COM_AddLuaCommand(const char *name) com_commands = cmd; return 0; } -#endif /** Tests if a command exists. * @@ -1445,17 +1441,6 @@ found: var->value = atoi(var->string); finish: - // See the note above. -/* if (var->flags & CV_CHEAT) - { - boolean newcheats = CV_CheatsEnabled(); - - if (!prevcheats && newcheats) - CONS_Printf(M_GetText("Cheats have been enabled.\n")); - else if (prevcheats && !newcheats) - CONS_Printf(M_GetText("Cheats have been disabled.\n")); - } */ - if (var->flags & CV_SHOWMODIFONETIME || var->flags & CV_SHOWMODIF) { CONS_Printf(M_GetText("%s set to %s\n"), var->name, var->string); @@ -1466,10 +1451,10 @@ finish: DEBFILE(va("%s set to %s\n", var->name, var->string)); } var->flags |= CV_MODIFIED; + // raise 'on change' code -#ifdef HAVE_BLUA LUA_CVarChanged(var->name); // let consolelib know what cvar this is. -#endif + if (var->flags & CV_CALL && !stealth) var->func(); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1749d9aea..f31d4d8d6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3186,11 +3186,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) } } -#ifdef HAVE_BLUA LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting -#else - (void)reason; -#endif // Reset player data CL_ClearPlayer(playernum); @@ -3214,13 +3210,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) if (playernum == displayplayers[0] && !demo.playback) displayplayers[0] = consoleplayer; // don't look through someone's view who isn't there -#ifdef HAVE_BLUA LUA_InvalidatePlayer(&players[playernum]); -#endif - /*if (G_TagGametype()) //Check if you still have a game. Location flexible. =P - P_CheckSurvivors(); - else*/ if (G_BattleGametype()) // SRB2Kart + if (G_BattleGametype()) // SRB2Kart K_CheckBumpers(); else if (G_RaceGametype()) P_CheckRacers(); @@ -4097,9 +4089,7 @@ void SV_ResetServer(void) for (i = 0; i < MAXPLAYERS; i++) { -#ifdef HAVE_BLUA LUA_InvalidatePlayer(&players[i]); -#endif playeringame[i] = false; playernode[i] = UINT8_MAX; sprintf(player_names[i], "Player %d", i + 1); @@ -4285,9 +4275,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) if (server && multiplayer && motd[0] != '\0') COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); -#ifdef HAVE_BLUA LUAh_PlayerJoin(newplayernum); -#endif #ifdef HAVE_DISCORDRPC DRPC_UpdatePresence(); diff --git a/src/d_main.c b/src/d_main.c index 885a0be26..3353651ad 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -70,6 +70,8 @@ #include "d_protocol.h" #include "m_perfstats.h" +#include "lua_script.h" + #ifdef CMAKECONFIG #include "config.h" #else @@ -84,10 +86,6 @@ #include "hardware/hw3sound.h" #endif -#ifdef HAVE_BLUA -#include "lua_script.h" -#endif - #ifdef HAVE_DISCORDRPC #include "discord.h" #endif @@ -771,9 +769,7 @@ void D_SRB2Loop(void) HW3S_EndFrameUpdate(); #endif -#ifdef HAVE_BLUA LUA_Step(); -#endif #ifdef HAVE_DISCORDRPC if (! dedicated) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e185f3286..9eec0ce9b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -193,10 +193,8 @@ static void Command_SkinSearch(void); #ifdef _DEBUG static void Command_Togglemodified_f(void); -#ifdef HAVE_BLUA static void Command_Archivetest_f(void); #endif -#endif // ========================================================================= // CLIENT VARIABLES @@ -575,10 +573,8 @@ const char *netxcmdnames[MAXNETXCMD - 1] = "MODIFYVOTE", "PICKVOTE", "REMOVEPLAYER", -#ifdef HAVE_BLUA "LUACMD", "LUAVAR" -#endif }; // ========================================================================= @@ -619,9 +615,7 @@ void D_RegisterServerCommands(void) RegisterNetXCmd(XD_PAUSE, Got_Pause); RegisterNetXCmd(XD_RESPAWN, Got_Respawn); RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd); -#ifdef HAVE_BLUA RegisterNetXCmd(XD_LUACMD, Got_Luacmd); -#endif RegisterNetXCmd(XD_SETUPVOTE, Got_SetupVotecmd); RegisterNetXCmd(XD_MODIFYVOTE, Got_ModifyVotecmd); @@ -678,9 +672,7 @@ void D_RegisterServerCommands(void) COM_AddCommand("cheats", Command_Cheats_f); // test #ifdef _DEBUG COM_AddCommand("togglemodified", Command_Togglemodified_f); -#ifdef HAVE_BLUA COM_AddCommand("archivetest", Command_Archivetest_f); -#endif #endif COM_AddCommand("replaymarker", Command_ReplayMarker); @@ -1122,7 +1114,7 @@ void D_RegisterClientCommands(void) #ifdef _DEBUG COM_AddCommand("causecfail", Command_CauseCfail_f); #endif -#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) +#if defined(LUA_ALLOW_BYTECODE) COM_AddCommand("dumplua", Command_Dumplua_f); #endif @@ -2890,9 +2882,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) INT32 resetplayer = 1, lastgametype; UINT8 skipprecutscene, FLS; boolean pencoremode; -/*#ifdef HAVE_BLUA - INT16 mapnumber; -#endif*/ + //INT16 mapnumber; forceresetplayers = deferencoremode = false; @@ -2958,10 +2948,8 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) if (modeattacking) // i remember moving this here in internal fixed a heisenbug so SetPlayerSkinByNum(0, cv_chooseskin.value-1); -/*#ifdef HAVE_BLUA - mapnumber = M_MapNumber(mapname[3], mapname[4]); - LUAh_MapChange(mapnumber); -#endif*/ + //mapnumber = M_MapNumber(mapname[3], mapname[4]); + //LUAh_MapChange(mapnumber); demo.savemode = (cv_recordmultiplayerdemos.value == 2) ? DSM_WILLAUTOSAVE : DSM_NOTSAVING; demo.savebutton = 0; @@ -5702,7 +5690,6 @@ static void Command_Togglemodified_f(void) modifiedgame = !modifiedgame; } -#ifdef HAVE_BLUA extern UINT8 *save_p; static void Command_Archivetest_f(void) { @@ -5747,7 +5734,6 @@ static void Command_Archivetest_f(void) CONS_Printf("Done. No crash.\n"); } #endif -#endif /** Makes a change to ::cv_forceskin take effect immediately. * diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 8fbdf1d5f..ab79e5901 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -233,10 +233,8 @@ typedef enum XD_PICKVOTE, // 24 XD_REMOVEPLAYER,// 25 XD_DISCORD, // 26 -#ifdef HAVE_BLUA XD_LUACMD, // 27 XD_LUAVAR, // 28 -#endif MAXNETXCMD } netxcmd_t; diff --git a/src/dehacked.c b/src/dehacked.c index 6260f4f65..b7c2e605d 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -31,19 +31,19 @@ #include "r_data.h" #include "r_patch.h" #include "r_sky.h" +#include "r_draw.h" // translation colormap consts (for lua) #include "fastcmp.h" #include "lua_script.h" #include "lua_glib.h" #include "lua_hook.h" #include "d_clisrv.h" +#include "v_video.h" // video flags (for lua) + +#include "lua_script.h" +#include "lua_libs.h" #include "m_cond.h" -#ifdef HAVE_BLUA -#include "v_video.h" // video flags (for lua) -#include "r_draw.h" // translation colormap consts (for lua) -#endif - #define REQUIRE_MATHLIB_GUID "{748fcbc8-6480-4013-ac4e-7afce6cab766}" // Free slot names @@ -67,9 +67,6 @@ static sfxenum_t get_sfx(const char *word); static UINT16 get_mus(const char *word, UINT8 dehacked_mode); #endif static hudnum_t get_huditem(const char *word); -#ifndef HAVE_BLUA -static powertype_t get_power(const char *word); -#endif boolean deh_loaded = false; static int dbg_line; @@ -795,7 +792,6 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) // Lua custom options also go above, contents may be case sensitive. if (fastncmp(word, "LUA.", 4)) { -#ifdef HAVE_BLUA UINT8 j; customoption_t *modoption; @@ -829,9 +825,6 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) modoption->option[31] = '\0'; strncpy(modoption->value, word2, 255); modoption->value[255] = '\0'; -#else - // Silently ignore. -#endif continue; } @@ -1748,10 +1741,8 @@ static void readframe(MYFILE *f, INT32 num) } z = 0; -#ifdef HAVE_BLUA found = LUA_SetLuaAction(&states[num], actiontocompare); if (!found) -#endif while (actionpointers[z].name) { if (fastcmp(actiontocompare, actionpointers[z].name)) @@ -7403,14 +7394,12 @@ static const char *const MOBJEFLAG_LIST[] = { NULL }; -#ifdef HAVE_BLUA static const char *const MAPTHINGFLAG_LIST[4] = { NULL, "OBJECTFLIP", // Reverse gravity flag for objects. "OBJECTSPECIAL", // Special flag used with certain objects. "AMBUSH" // Deaf monsters/do not react to sound. }; -#endif static const char *const PLAYERFLAG_LIST[] = { // Flip camera angle with gravity flip prefrence. @@ -7483,7 +7472,6 @@ static const char *const PLAYERFLAG_LIST[] = { NULL // stop loop here. }; -#ifdef HAVE_BLUA // Linedef flags static const char *const ML_LIST[16] = { "IMPASSIBLE", @@ -7503,7 +7491,6 @@ static const char *const ML_LIST[16] = { "BOUNCY", "TFERLINE" }; -#endif // This DOES differ from r_draw's Color_Names, unfortunately. // Also includes Super colors @@ -7710,7 +7697,6 @@ static const char *const POWERS_LIST[] = { "INGOOP" // In goop }; -#ifdef HAVE_BLUA static const char *const KARTSTUFF_LIST[] = { "POSITION", "OLDPOSITION", @@ -7797,7 +7783,6 @@ static const char *const KARTSTUFF_LIST[] = { "SPECTATEWAIT", "GROWCANCEL" }; -#endif static const char *const HUDITEMS_LIST[] = { "LIVESNAME", @@ -7840,11 +7825,7 @@ static const char *const HUDITEMS_LIST[] = { struct { const char *n; // has to be able to hold both fixed_t and angle_t, so drastic measure!! -#ifdef HAVE_BLUA lua_Integer v; -#else - INT64 v; -#endif } const INT_CONST[] = { // If a mod removes some variables here, // please leave the names in-tact and just set @@ -8033,7 +8014,6 @@ struct { {"SF_NOINTERRUPT",SF_NOINTERRUPT}, {"SF_X2AWAYSOUND",SF_X2AWAYSOUND}, -#ifdef HAVE_BLUA // p_local.h constants {"FLOATSPEED",FLOATSPEED}, {"MAXSTEPMOVE",MAXSTEPMOVE}, @@ -8341,7 +8321,6 @@ struct { // Custom client features exposed to lua {"FEATURE_INTERMISSIONHUD",1}, {"FEATURE_VOTEHUD",1}, -#endif {NULL,0} }; @@ -8470,249 +8449,10 @@ static hudnum_t get_huditem(const char *word) return HUD_LIVESNAME; } -#ifndef HAVE_BLUA -static powertype_t get_power(const char *word) -{ // Returns the vlaue of pw_ enumerations - powertype_t i; - if (*word >= '0' && *word <= '9') - return atoi(word); - if (fastncmp("PW_",word,3)) - word += 3; // take off the pw_ - for (i = 0; i < NUMPOWERS; i++) - if (fastcmp(word, POWERS_LIST[i])) - return i; - deh_warning("Couldn't find power named 'pw_%s'",word); - return pw_invulnerability; -} - -/// \todo Make ANY of this completely over-the-top math craziness obey the order of operations. -static fixed_t op_mul(fixed_t a, fixed_t b) { return a*b; } -static fixed_t op_div(fixed_t a, fixed_t b) { return a/b; } -static fixed_t op_add(fixed_t a, fixed_t b) { return a+b; } -static fixed_t op_sub(fixed_t a, fixed_t b) { return a-b; } -static fixed_t op_or(fixed_t a, fixed_t b) { return a|b; } -static fixed_t op_and(fixed_t a, fixed_t b) { return a&b; } -static fixed_t op_lshift(fixed_t a, fixed_t b) { return a<>b; } - -struct { - const char c; - fixed_t (*v)(fixed_t,fixed_t); -} OPERATIONS[] = { - {'*',op_mul}, - {'/',op_div}, - {'+',op_add}, - {'-',op_sub}, - {'|',op_or}, - {'&',op_and}, - {'<',op_lshift}, - {'>',op_rshift}, - {0,NULL} -}; - -// Returns the full word, cut at the first symbol or whitespace -static char *read_word(const char *line) -{ - // Part 1: You got the start of the word, now find the end. - const char *p; - INT32 i; - for (p = line+1; *p; p++) { - if (*p == ' ' || *p == '\t') - break; - for (i = 0; OPERATIONS[i].c; i++) - if (*p == OPERATIONS[i].c) { - i = -1; - break; - } - if (i == -1) - break; - } - - // Part 2: Make a copy of the word and return it. - { - size_t len = (p-line); - char *word = malloc(len+1); - M_Memcpy(word,line,len); - word[len] = '\0'; - return word; - } -} - -static INT32 operation_pad(const char **word) -{ // Brings word the next operation and returns the operation number. - INT32 i; - for (; **word; (*word)++) { - if (**word == ' ' || **word == '\t') - continue; - for (i = 0; OPERATIONS[i].c; i++) - if (**word == OPERATIONS[i].c) - { - if ((**word == '<' && *(*word+1) == '<') || (**word == '>' && *(*word+1) == '>')) (*word)++; // These operations are two characters long. - else if (**word == '<' || **word == '>') continue; // ... do not accept one character long. - (*word)++; - return i; - } - deh_warning("Unknown operation '%c'",**word); - return -1; - } - return -1; -} - -static void const_warning(const char *type, const char *word) -{ - deh_warning("Couldn't find %s named '%s'",type,word); -} - -static fixed_t find_const(const char **rword) -{ // Finds the value of constants and returns it, bringing word to the next operation. - INT32 i; - fixed_t r; - char *word = read_word(*rword); - *rword += strlen(word); - if ((*word >= '0' && *word <= '9') || *word == '-') { // Parse a number - r = atoi(word); - free(word); - return r; - } - if (!*(word+1) && // Turn a single A-z symbol into numbers, like sprite frames. - ((*word >= 'A' && *word <= 'Z') || (*word >= 'a' && *word <= 'z'))) { - r = R_Char2Frame(*word); - free(word); - return r; - } - if (fastncmp("MF_", word, 3)) { - char *p = word+3; - for (i = 0; MOBJFLAG_LIST[i]; i++) - if (fastcmp(p, MOBJFLAG_LIST[i])) { - free(word); - return (1<forwardmove || cmd->sidemove || cmd->buttons) @@ -2954,9 +2952,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) if (starpost) //Don't even bother with looking for a place to spawn. { P_MovePlayerToStarpost(playernum); -#ifdef HAVE_BLUA LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) -#endif return; } @@ -3012,10 +3008,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) } P_MovePlayerToSpawn(playernum, spawnpoint); -#ifdef HAVE_BLUA LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) -#endif - } mapthing_t *G_FindCTFStart(INT32 playernum) @@ -3310,9 +3303,7 @@ void G_DoReborn(INT32 playernum) } else { -#ifdef HAVE_BLUA LUAh_MapChange(gamemap); -#endif G_DoLoadLevel(true); } }*/ @@ -4784,9 +4775,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool F_StartCustomCutscene(mapheaderinfo[gamemap-1]->precutscenenum-1, true, resetplayer); else { -#ifdef HAVE_BLUA LUAh_MapChange(gamemap); -#endif G_DoLoadLevel(resetplayer); } @@ -5109,9 +5098,7 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) #define DF_NIGHTSATTACK 0x04 // This demo is from NiGHTS attack and contains its time left, score, and mares! #define DF_ATTACKMASK 0x06 // This demo is from ??? attack and contains ??? -#ifdef HAVE_BLUA #define DF_LUAVARS 0x20 // this demo contains extra lua vars; this is mostly used for backwards compability -#endif #define DF_ATTACKSHIFT 1 #define DF_ENCORE 0x40 @@ -6780,11 +6767,9 @@ void G_BeginRecording(void) if (encoremode) demoflags |= DF_ENCORE; -#ifdef HAVE_BLUA if (!modeattacking && gL) // Ghosts don't read luavars, and you shouldn't ever need to save Lua in replays, you doof! // SERIOUSLY THOUGH WHY WOULD YOU LOAD HOSTMOD AND RECORD A GHOST WITH IT !???? demoflags |= DF_LUAVARS; -#endif // Setup header. M_Memcpy(demo_p, DEMOHEADER, 12); demo_p += 12; @@ -6892,11 +6877,9 @@ void G_BeginRecording(void) WRITEUINT8(demo_p, 0xFF); // Denote the end of the player listing -#ifdef HAVE_BLUA // player lua vars, always saved even if empty... Unless it's record attack. if (demoflags & DF_LUAVARS) LUA_ArchiveDemo(); -#endif memset(&oldcmd,0,sizeof(oldcmd)); memset(&oldghost,0,sizeof(oldghost)); @@ -7882,9 +7865,8 @@ void G_DoPlayDemo(char *defdemoname) // didn't start recording right away. demo.deferstart = false; -/*#ifdef HAVE_BLUA - LUAh_MapChange(gamemap); -#endif*/ + //LUAh_MapChange(gamemap); + displayplayers[0] = consoleplayer = 0; memset(playeringame,0,sizeof(playeringame)); @@ -7971,7 +7953,6 @@ void G_DoPlayDemo(char *defdemoname) // end of player read (the 0xFF marker) // so this is where we are to read our lua variables (if possible!) -#ifdef HAVE_BLUA if (demoflags & DF_LUAVARS) // again, used for compability, lua shit will be saved to replays regardless of if it's even been loaded { if (!gL) // No Lua state! ...I guess we'll just start one... @@ -7980,7 +7961,6 @@ void G_DoPlayDemo(char *defdemoname) // No modeattacking check, DF_LUAVARS won't be present here. LUA_UnArchiveDemo(); } -#endif splitscreen = 0; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 08c2d7c33..dd0a1c9c9 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -42,19 +42,17 @@ #include "p_local.h" // camera[] #include "p_tick.h" -#ifdef HWRENDER -#include "hardware/hw_main.h" -#endif - -#ifdef HAVE_BLUA #include "lua_hud.h" #include "lua_hudlib_drawlist.h" #include "lua_hook.h" -#endif #include "s_sound.h" // song credits #include "k_kart.h" +#ifdef HWRENDER +#include "hardware/hw_main.h" +#endif + // coords are scaled #define HU_INPUTX 0 #define HU_INPUTY 0 @@ -94,9 +92,7 @@ static boolean headsupactive = false; boolean hu_showscores; // draw rankings static char hu_tick; -#ifdef HAVE_BLUA static huddrawlist_h luahuddrawlist_scores; -#endif patch_t *rflagico; patch_t *bflagico; @@ -349,9 +345,7 @@ void HU_Init(void) // set shift translation table shiftxform = english_shiftxform; -#ifdef HAVE_BLUA luahuddrawlist_scores = LUA_HUD_CreateDrawList(); -#endif HU_LoadGraphics(); } @@ -887,10 +881,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) // run the lua hook even if we were supposed to eat the msg, netgame consistency goes first. -#ifdef HAVE_BLUA if (LUAh_PlayerMsg(playernum, target, flags, msg, spam_eatmsg)) return; -#endif if (spam_eatmsg) return; // don't proceed if we were supposed to eat the message. @@ -2425,19 +2417,18 @@ void HU_Drawer(void) { if (netgame || multiplayer) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_rankings)) -#endif HU_DrawRankings(); -#ifdef HAVE_BLUA - if (renderisnewtic) - { - LUA_HUD_ClearDrawList(luahuddrawlist_scores); - LUAh_ScoresHUD(luahuddrawlist_scores); - } - LUA_HUD_DrawList(luahuddrawlist_scores); -#endif + + if (renderisnewtic) + { + LUA_HUD_ClearDrawList(luahuddrawlist_scores); + LUAh_ScoresHUD(luahuddrawlist_scores); + } + + LUA_HUD_DrawList(luahuddrawlist_scores); } + if (demo.playback) { HU_DrawDemoInfo(); diff --git a/src/k_kart.c b/src/k_kart.c index 920a607fb..6befed280 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2210,7 +2210,6 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto { UINT8 scoremultiply = 1; // PS: Inflictor is unused for all purposes here and is actually only ever relevant to Lua. It may be nil too. -#ifdef HAVE_BLUA boolean force = false; // Used to check if Lua ShouldSpin should get us damaged reguardless of flashtics or heck knows what. UINT8 shouldForce = LUAh_ShouldSpin(player, inflictor, source); if (P_MobjWasRemoved(player->mo)) @@ -2219,11 +2218,6 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto force = true; else if (shouldForce == 2) return; -#else - static const boolean force = false; - (void)inflictor; // in case some weirdo doesn't want Lua. -#endif - if (!trapitem && G_BattleGametype()) { @@ -2247,10 +2241,8 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto } } -#ifdef HAVE_BLUA if (LUAh_PlayerSpin(player, inflictor, source)) // Let Lua do its thing or overwrite if it wants to. Make sure to let any possible instashield happen because we didn't get "damaged" in this case. return; -#endif if (source && source != player->mo && source->player) K_PlayHitEmSound(source); @@ -2356,7 +2348,6 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor) { UINT8 scoremultiply = 1; // PS: Inflictor is unused for all purposes here and is actually only ever relevant to Lua. It may be nil too. -#ifdef HAVE_BLUA boolean force = false; // Used to check if Lua ShouldSquish should get us damaged reguardless of flashtics or heck knows what. UINT8 shouldForce = LUAh_ShouldSquish(player, inflictor, source); if (P_MobjWasRemoved(player->mo)) @@ -2365,10 +2356,6 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor) force = true; else if (shouldForce == 2) return; -#else - static const boolean force = false; - (void)inflictor; // Please stop forgetting to put inflictor in yer functions thank -Lat' -#endif if (G_BattleGametype()) { @@ -2392,10 +2379,8 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor) } } -#ifdef HAVE_BLUA if (LUAh_PlayerSquish(player, inflictor, source)) // Let Lua do its thing or overwrite if it wants to. Make sure to let any possible instashield happen because we didn't get "damaged" in this case. return; -#endif player->kartstuff[k_sneakertimer] = 0; player->kartstuff[k_driftboost] = 0; @@ -2474,7 +2459,6 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b { fixed_t upgoer; UINT8 scoremultiply = 1; -#ifdef HAVE_BLUA boolean force = false; // Used to check if Lua ShouldExplode should get us damaged reguardless of flashtics or heck knows what. UINT8 shouldForce = LUAh_ShouldExplode(player, inflictor, source); @@ -2485,10 +2469,6 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b else if (shouldForce == 2) return; -#else - static const boolean force = false; -#endif - if (G_BattleGametype()) { if (K_IsPlayerWanted(player)) @@ -2511,10 +2491,8 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b } } -#ifdef HAVE_BLUA if (LUAh_PlayerExplode(player, inflictor, source)) // Same thing. Also make sure to let Instashield happen blah blah return; -#endif if (source && source != player->mo && source->player) K_PlayHitEmSound(source); @@ -7584,13 +7562,10 @@ static void K_drawKartStats(void) if (stplyr == &players[displayplayers[splitnum]]) break; } - -#ifdef HAVE_BLUA + if (!LUA_HudEnabled(hud_statdisplay)) return; -#endif - - + // I tried my best, but this is still mess :/ if (splitscreen) { @@ -8332,10 +8307,8 @@ static boolean K_drawKartPositionFaces(void) if (numplayersingame <= 1) return true; -#ifdef HAVE_BLUA if (!LUA_HudEnabled(hud_minirankings)) return false; // Don't proceed but still return true for free play above if HUD is disabled. -#endif for (j = 0; j < numplayersingame; j++) { @@ -8359,9 +8332,6 @@ static boolean K_drawKartPositionFaces(void) if (players+i == stplyr) strank = ranklines; - //if (ranklines == 5) - //break; // Only draw the top 5 players -- we do this a different way now... - ranklines++; } @@ -8413,10 +8383,8 @@ static boolean K_drawKartPositionFaces(void) V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceRank(p), colormap); } -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_battlebumpers)) { -#endif if (G_BattleGametype() && players[rankplayer[i]].kartstuff[k_bumper] > 0) { V_DrawMappedPatch(bumperx-2, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[0], colormap); @@ -8426,9 +8394,7 @@ static boolean K_drawKartPositionFaces(void) V_DrawMappedPatch(bumperx, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[1], colormap); } } -#ifdef HAVE_BLUA } // A new level of stupidity: checking if lua is enabled to close a bracket. :Fascinating: -#endif } if (i == strank) @@ -9304,10 +9270,9 @@ static void K_drawBattleFullscreen(void) INT32 splitflags = V_SNAPTOTOP; // I don't feel like properly supporting non-green resolutions, so you can have a misuse of SNAPTO instead fixed_t scale = FRACUNIT; boolean drawcomebacktimer = true; // lazy hack because it's cleaner in the long run. -#ifdef HAVE_BLUA + if (!LUA_HudEnabled(hud_battlecomebacktimer)) drawcomebacktimer = false; -#endif if (splitscreen) { @@ -9419,9 +9384,7 @@ static void K_drawBattleFullscreen(void) return; } -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_freeplay)) -#endif K_drawKartFreePlay(leveltime); } } @@ -9908,60 +9871,49 @@ void K_drawKartHUD(void) if (!demo.title && (!battlefullscreen || splitscreen)) { // Draw the CHECK indicator before the other items, so it's overlapped by everything else -#ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_check)) // delete lua when? -#endif + { if (cv_kartcheck.value && !splitscreen && !players[displayplayers[0]].exiting && !freecam) K_drawKartPlayerCheck(); + } // Draw WANTED status if (G_BattleGametype()) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_wanted)) -#endif K_drawKartWanted(); } if (cv_kartminimap.value) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_minimap)) -#endif K_drawKartMinimap(); } } if (battlefullscreen && !freecam) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_battlefullscreen)) -#endif K_drawBattleFullscreen(); return; } // Draw the item window -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_item) && !freecam) -#endif - K_drawKartItem(); + K_drawKartItem(); // If not splitscreen, draw... if (!splitscreen && !demo.title) { // Draw the timestamp -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_time)) -#endif K_drawKartTimestamp(stplyr->realtime, TIME_X, TIME_Y, gamemap, 0); if (!modeattacking) { // The top-four faces on the left - /*#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_minirankings)) - #endif*/ + //if (LUA_HudEnabled(hud_minirankings)) isfreeplay = K_drawKartPositionFaces(); } } @@ -9969,16 +9921,16 @@ void K_drawKartHUD(void) if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode { if (!(splitscreen || demo.title)) -#ifdef HAVE_BLUA + { if (LUA_HudEnabled(hud_position)) -#endif K_drawInput(); + } if (!demo.title && cv_showstats.value) -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_statdisplay)) -#endif - K_drawKartStats(); + { + if (LUA_HudEnabled(hud_statdisplay)) + K_drawKartStats(); + } if (demo.title) // Draw title logo instead in demo.titles { @@ -10005,19 +9957,15 @@ void K_drawKartHUD(void) else if (G_RaceGametype()) // Race-only elements { // Draw the lap counter -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_gametypeinfo)) -#endif K_drawKartLaps(); if (!splitscreen) { // Draw the speedometer - // TODO: Make a better speedometer. -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_speedometer)) -#endif - K_drawKartSpeedometer(); + // TODO: Make a better speedometer. << done :p + if (LUA_HudEnabled(hud_speedometer)) + K_drawKartSpeedometer(); } if (isfreeplay) @@ -10025,26 +9973,20 @@ void K_drawKartHUD(void) else if (!modeattacking) { // Draw the numerical position -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_position)) -#endif K_DrawKartPositionNum(stplyr->kartstuff[k_position]); } else //if (!(demo.playback && hu_showscores)) { // Draw the input UI -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_position)) -#endif K_drawInput(); } } else if (G_BattleGametype()) // Battle-only { // Draw the hits left! -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_gametypeinfo)) -#endif K_drawKartBumpersOrKarma(); } } @@ -10088,9 +10030,7 @@ void K_drawKartHUD(void) // Draw FREE PLAY. if (isfreeplay && !stplyr->spectator && timeinmap > 113) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_freeplay)) -#endif K_drawKartFreePlay(leveltime); } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9e42e7e9f..be561e7ba 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -11,7 +11,6 @@ /// \brief basic functions for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "p_local.h" #include "p_setup.h" // So we can have P_SetupLevelSky #include "p_slopes.h" // P_GetZAt @@ -3267,6 +3266,4 @@ int LUA_BaseLib(lua_State *L) lua_pushvalue(L, LUA_GLOBALSINDEX); luaL_register(L, NULL, lib); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 0e705e2ea..0b93766b8 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -11,7 +11,6 @@ /// \brief blockmap library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "p_local.h" #include "r_main.h" // validcount #include "lua_script.h" @@ -257,6 +256,4 @@ int LUA_BlockmapLib(lua_State *L) { lua_register(L, "searchBlockmap", lib_searchBlockmap); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index f0fe3ac49..b6ad0e17e 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -11,7 +11,6 @@ /// \brief console modifying/etc library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "p_local.h" #include "g_game.h" @@ -600,6 +599,4 @@ int LUA_ConsoleLib(lua_State *L) lua_pushvalue(L, LUA_GLOBALSINDEX); luaL_register(L, NULL, lib); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_hook.h b/src/lua_hook.h index a17a7ac78..14270dea5 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -10,8 +10,6 @@ /// \file lua_hook.h /// \brief hooks for Lua scripting -#ifdef HAVE_BLUA - #include "r_defs.h" #include "d_player.h" @@ -112,6 +110,4 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Allows to write to p void LUAh_IntermissionThinker(void); // Hook for Y_Ticker void LUAh_VoteThinker(void); // Hook for Y_VoteTicker -#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink - -#endif +#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink \ No newline at end of file diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 1e6a5cb29..6876e94d3 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -11,7 +11,6 @@ /// \brief hooks for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "doomstat.h" #include "p_mobj.h" #include "g_game.h" @@ -1740,6 +1739,4 @@ boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source) } lua_settop(gL, 0); return hooked; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index c7b1ec38e..5b2f64b54 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -12,7 +12,6 @@ #include "doomdef.h" #include "fastcmp.h" -#ifdef HAVE_BLUA #include "r_defs.h" #include "r_local.h" #include "st_stuff.h" // hudinfo[] @@ -1411,6 +1410,4 @@ void LUAh_VoteHUD(huddrawlist_h list) lua_pushlightuserdata(gL, NULL); lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); -} - -#endif +} \ No newline at end of file diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 64a8b63d7..c94b42b5b 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -11,7 +11,6 @@ /// \brief infotable editing library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "info.h" #include "dehacked.h" @@ -984,6 +983,4 @@ int LUA_InfoLib(lua_State *L) lua_setglobal(L, "S_sfx"); lua_setglobal(L, "sfxinfo"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_libs.h b/src/lua_libs.h index 00dd9c858..c226c4714 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -10,8 +10,6 @@ /// \file lua_libs.h /// \brief libraries for Lua scripting -#ifdef HAVE_BLUA - extern lua_State *gL; #define LREG_VALID "VALID_USERDATA" @@ -70,6 +68,4 @@ int LUA_SkinLib(lua_State *L); int LUA_ThinkerLib(lua_State *L); int LUA_MapLib(lua_State *L); int LUA_BlockmapLib(lua_State *L); -int LUA_HudLib(lua_State *L); - -#endif +int LUA_HudLib(lua_State *L); \ No newline at end of file diff --git a/src/lua_maplib.c b/src/lua_maplib.c index ba2ad97a1..6369e9a36 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -11,7 +11,6 @@ /// \brief game map library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "r_state.h" #include "p_local.h" #include "p_setup.h" @@ -1689,6 +1688,4 @@ int LUA_MapLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "mapheaderinfo"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 8c9d10062..c392ac6eb 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -11,7 +11,6 @@ /// \brief basic math library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA //#include "fastcmp.h" #include "tables.h" #include "p_local.h" @@ -228,6 +227,4 @@ int LUA_MathLib(lua_State *L) lua_pushvalue(L, LUA_GLOBALSINDEX); luaL_register(L, NULL, lib); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 9a7ea9828..7b1db5327 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -13,7 +13,6 @@ #include #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "r_things.h" #include "r_main.h" @@ -926,6 +925,4 @@ int LUA_MobjLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "mapthings"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index eb537d51f..70324fa02 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -11,7 +11,6 @@ /// \brief player object library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "r_main.h" #include "r_things.h" @@ -820,6 +819,4 @@ int LUA_PlayerLib(lua_State *L) lua_setglobal(L, "displayplayers"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_script.c b/src/lua_script.c index 29901bc3d..3af655efe 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -11,7 +11,6 @@ /// \brief Lua scripting basics #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "dehacked.h" #include "z_zone.h" @@ -1688,6 +1687,4 @@ int Lua_optoption(lua_State *L, int narg, if (fastcmp(lst[i], name)) return i; return -1; -} - -#endif // HAVE_BLUA +} \ No newline at end of file diff --git a/src/lua_script.h b/src/lua_script.h index 8ea5f3a89..a22e47c12 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -10,8 +10,6 @@ /// \file lua_script.h /// \brief Lua scripting basics -#ifdef HAVE_BLUA - #include "m_fixed.h" #include "doomtype.h" #include "d_player.h" @@ -95,5 +93,3 @@ void COM_Lua_f(void); CONS_Alert(CONS_WARNING,"%s\n", warningmsg);\ }\ } - -#endif diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index e86cd55af..286e983c1 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -11,7 +11,6 @@ /// \brief player skin structure library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "r_things.h" #include "sounds.h" @@ -273,6 +272,4 @@ int LUA_SkinLib(lua_State *L) lua_setglobal(L, "skins"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_thinkerlib.c b/src/lua_thinkerlib.c index ae859d46e..8315e7c3d 100644 --- a/src/lua_thinkerlib.c +++ b/src/lua_thinkerlib.c @@ -11,7 +11,6 @@ /// \brief thinker library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "p_local.h" #include "lua_script.h" #include "lua_libs.h" @@ -131,6 +130,4 @@ int LUA_ThinkerLib(lua_State *L) lua_setfield(L, -2, "iterate"); lua_setglobal(L, "thinkers"); return 0; -} - -#endif +} \ No newline at end of file diff --git a/src/lua_udatalib.h b/src/lua_udatalib.h index 36d1ef5ff..acff4cf3b 100644 --- a/src/lua_udatalib.h +++ b/src/lua_udatalib.h @@ -1,8 +1,6 @@ #ifndef __LUA_UDATALIB_H__ #define __LUA_UDATALIB_H__ -#ifdef HAVE_BLUA - #include "doomdef.h" #include "lua_script.h" #include "lua_libs.h" @@ -102,6 +100,4 @@ void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[]); return 0; \ } -#endif - -#endif +#endif \ No newline at end of file diff --git a/src/m_cheat.c b/src/m_cheat.c index a4aae676e..91ca536c8 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -647,7 +647,7 @@ void Command_CauseCfail_f(void) } #endif -#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) +#if defined(LUA_ALLOW_BYTECODE) void Command_Dumplua_f(void) { if (modifiedgame) @@ -891,9 +891,7 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mapthing_t *mt = mapthings; sector_t *sec = player->mo->subsector->sector; -#ifdef HAVE_BLUA LUA_InvalidateMapthings(); -#endif mapthings = Z_Realloc(mapthings, ++nummapthings * sizeof (*mapthings), PU_LEVEL, NULL); diff --git a/src/m_cheat.h b/src/m_cheat.h index 95c0060dd..f2944c27c 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -67,7 +67,7 @@ void Command_Weather_f(void); #ifdef _DEBUG void Command_CauseCfail_f(void); #endif -#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) +#if defined(LUA_ALLOW_BYTECODE) void Command_Dumplua_f(void); #endif diff --git a/src/m_menu.c b/src/m_menu.c index 4886f788d..922841404 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6457,13 +6457,8 @@ static void M_HandleAddons(INT32 choice) case EXT_CFG: M_AddonExec(KEY_ENTER); break; - case EXT_LUA: -#ifndef HAVE_BLUA - S_StartSound(NULL, sfx_s26d); - M_StartMessage(va("%c%s\x80\nThis version of SRB2Kart does not\nhave support for .lua files.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); - break; -#endif // else intentional fallthrough + case EXT_LUA: case EXT_SOC: case EXT_WAD: #ifdef USE_KART diff --git a/src/p_enemy.c b/src/p_enemy.c index cb1a1df4e..707819fd6 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -29,9 +29,7 @@ #include "hardware/hw3sound.h" #endif -#ifdef HAVE_BLUA boolean LUA_CallAction(const char *action, mobj_t *actor); -#endif player_t *stplyr; INT32 var1; @@ -784,10 +782,8 @@ void A_Look(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Look", actor)) return; -#endif if (!P_LookForPlayers(actor, locvar1 & 65535, false , FixedMul((locvar1 >> 16)*FRACUNIT, actor->scale))) return; @@ -822,10 +818,8 @@ void A_Chase(mobj_t *actor) INT32 delta; INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Chase", actor)) return; -#endif I_Assert(actor != NULL); I_Assert(!P_MobjWasRemoved(actor)); @@ -915,10 +909,8 @@ void A_FaceStabChase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA if (LUA_CallAction("A_FaceStabChase", actor)) return; -#endif if (actor->reactiontime) actor->reactiontime--; @@ -1003,10 +995,9 @@ nomissile: // void A_JetJawRoam(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_JetJawRoam", actor)) return; -#endif + if (actor->reactiontime) { actor->reactiontime--; @@ -1032,10 +1023,9 @@ void A_JetJawRoam(mobj_t *actor) void A_JetJawChomp(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetJawChomp", actor)) return; -#endif // turn towards movement direction if not there yet if (actor->movedir < NUMDIRS) @@ -1081,10 +1071,9 @@ void A_PointyThink(mobj_t *actor) boolean firsttime = true; INT32 sign; -#ifdef HAVE_BLUA if (LUA_CallAction("A_PointyThink", actor)) return; -#endif + actor->momx = actor->momy = actor->momz = 0; // Find nearest player @@ -1180,10 +1169,9 @@ void A_CheckBuddy(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_CheckBuddy", actor)) return; -#endif + if (locvar1 && (!actor->tracer || actor->tracer->health <= 0)) P_RemoveMobj(actor); else if (!locvar1 && (!actor->target || actor->target->health <= 0)) @@ -1199,10 +1187,9 @@ void A_CheckBuddy(mobj_t *actor) // void A_HoodThink(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_HoodThink", actor)) return; -#endif + // Currently in the air... if (!(actor->eflags & MFE_VERTICALFLIP) && actor->z > actor->floorz) { @@ -1261,10 +1248,8 @@ void A_ArrowCheck(mobj_t *actor) angle_t angle; fixed_t dist; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ArrowCheck", actor)) return; -#endif // Movement vector x = actor->momx; @@ -1301,10 +1286,8 @@ void A_ArrowCheck(mobj_t *actor) // void A_SnailerThink(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SnailerThink", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -1376,10 +1359,8 @@ void A_SnailerThink(mobj_t *actor) // void A_SharpChase(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SharpChase", actor)) return; -#endif if (!actor->health) { @@ -1436,10 +1417,8 @@ void A_SharpChase(mobj_t *actor) // void A_SharpSpin(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SharpSpin", actor)) return; -#endif if (!actor->health) { @@ -1474,10 +1453,8 @@ void A_SharpSpin(mobj_t *actor) // void A_VultureVtol(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_VultureVtol", actor)) return; -#endif if (!actor->target) return; @@ -1511,10 +1488,8 @@ void A_VultureVtol(mobj_t *actor) // void A_VultureCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_VultureCheck", actor)) return; -#endif if (actor->momx || actor->momy) return; @@ -1539,10 +1514,9 @@ void A_SkimChase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SkimChase", actor)) return; -#endif + if (actor->reactiontime) actor->reactiontime--; @@ -1626,10 +1600,9 @@ nomissile: // void A_FaceTarget(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_FaceTarget", actor)) return; -#endif + if (!actor->target) return; @@ -1645,10 +1618,9 @@ void A_FaceTarget(mobj_t *actor) // void A_FaceTracer(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_FaceTracer", actor)) return; -#endif + if (!actor->tracer) return; @@ -1675,10 +1647,9 @@ void A_LobShot(mobj_t *actor) fixed_t vertical, horizontal; fixed_t airtime = var2 & 65535; -#ifdef HAVE_BLUA if (LUA_CallAction("A_LobShot", actor)) return; -#endif + if (!actor->target) return; @@ -1776,10 +1747,9 @@ void A_FireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_FireShot", actor)) return; -#endif + if (!actor->target) return; @@ -1815,10 +1785,9 @@ void A_SuperFireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SuperFireShot", actor)) return; -#endif + if (!actor->target) return; @@ -1862,10 +1831,9 @@ void A_BossFireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BossFireShot", actor)) return; -#endif + if (!actor->target) return; @@ -1944,10 +1912,8 @@ void A_Boss7FireMissiles(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss7FireMissiles", actor)) return; -#endif if (!actor->target) { @@ -2003,10 +1969,9 @@ void A_Boss1Laser(mobj_t *actor) angle_t angle; mobj_t *point; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss1Laser", actor)) return; -#endif + if (!actor->target) return; @@ -2104,10 +2069,9 @@ void A_Boss1Laser(mobj_t *actor) void A_FocusTarget(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FocusTarget", actor)) return; -#endif if (actor->target) { @@ -2155,10 +2119,10 @@ void A_FocusTarget(mobj_t *actor) void A_Boss4Reverse(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss4Reverse", actor)) return; -#endif + S_StartSound(NULL, locvar1); actor->reactiontime = 0; if (actor->movedir == 1) @@ -2177,10 +2141,10 @@ void A_Boss4Reverse(mobj_t *actor) void A_Boss4SpeedUp(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss4SpeedUp", actor)) return; -#endif + S_StartSound(NULL, locvar1); actor->reactiontime = 2; } @@ -2195,10 +2159,10 @@ void A_Boss4SpeedUp(mobj_t *actor) void A_Boss4Raise(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss4Raise", actor)) return; -#endif + S_StartSound(NULL, locvar1); actor->reactiontime = 1; } @@ -2226,10 +2190,9 @@ void A_SkullAttack(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SkullAttack", actor)) return; -#endif + if (!actor->target) return; @@ -2277,10 +2240,9 @@ void A_BossZoom(mobj_t *actor) angle_t an; INT32 dist; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BossZoom", actor)) return; -#endif + if (!actor->target) return; @@ -2318,10 +2280,9 @@ void A_BossScream(mobj_t *actor) INT32 locvar2 = var2; mobjtype_t explodetype; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BossScream", actor)) return; -#endif + switch (locvar1) { default: @@ -2366,10 +2327,9 @@ void A_BossScream(mobj_t *actor) // void A_Scream(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Scream", actor)) return; -#endif + if (actor->tracer && (actor->tracer->type == MT_SHELL || actor->tracer->type == MT_FIREBALL)) S_StartScreamSound(actor, sfx_mario2); else if (actor->info->deathsound) @@ -2385,10 +2345,9 @@ void A_Scream(mobj_t *actor) // void A_Pain(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Pain", actor)) return; -#endif + if (actor->info->painsound) S_StartSound(actor, actor->info->painsound); @@ -2405,10 +2364,9 @@ void A_Pain(mobj_t *actor) // void A_Fall(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Fall", actor)) return; -#endif + // actor is on ground, it can be walked over actor->flags &= ~MF_SOLID; @@ -2435,10 +2393,9 @@ void A_1upThinker(mobj_t *actor) fixed_t temp; INT32 closestplayer = -1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_1upThinker", actor)) return; -#endif + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].bot || players[i].spectator) @@ -2494,10 +2451,8 @@ void A_MonitorPop(mobj_t *actor) mobjtype_t item = 0; //mobjtype_t newbox; -#ifdef HAVE_BLUA if (LUA_CallAction("A_MonitorPop", actor)) return; -#endif // de-solidify actor->health = 0; @@ -2634,10 +2589,9 @@ for (i = cvar.value; i; --i) spawnchance[numchoices++] = type // void A_Explode(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Explode", actor)) return; -#endif + P_RadiusAttack(actor, actor->target, actor->info->damage); } @@ -2654,10 +2608,9 @@ void A_BossDeath(mobj_t *mo) mobj_t *mo2; line_t junk; INT32 i; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BossDeath", mo)) return; -#endif P_LinedefExecute(LE_BOSSDEAD, mo, NULL); mo->health = 0; @@ -2706,12 +2659,11 @@ void A_BossDeath(mobj_t *mo) } bossjustdie: -#ifdef HAVE_BLUA if (LUAh_BossDeath(mo)) return; else if (P_MobjWasRemoved(mo)) return; -#endif + if (mo->type == MT_BLACKEGGMAN || mo->type == MT_CYBRAKDEMON) { mo->flags |= MF_NOCLIP; @@ -2826,10 +2778,9 @@ void A_CustomPower(mobj_t *actor) INT32 locvar2 = var2; boolean spawnshield = false; -#ifdef HAVE_BLUA if (LUA_CallAction("A_CustomPower", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -2867,10 +2818,9 @@ void A_GiveWeapon(mobj_t *actor) player_t *player; INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_GiveWeapon", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -2901,10 +2851,9 @@ void A_JumpShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_JumpShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -2933,10 +2882,9 @@ void A_RingShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RingShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -2966,10 +2914,9 @@ void A_RingBox(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RingBox", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -2994,10 +2941,9 @@ void A_Invincibility(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Invincibility", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3027,10 +2973,9 @@ void A_SuperSneakers(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SuperSneakers", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3064,10 +3009,9 @@ void A_AwardScore(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_AwardScore", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3092,10 +3036,9 @@ void A_ExtraLife(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ExtraLife", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3132,10 +3075,9 @@ void A_BombShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BombShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3164,10 +3106,9 @@ void A_WaterShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_WaterShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3182,11 +3123,6 @@ void A_WaterShield(mobj_t *actor) P_SpawnShieldOrb(player); } - /* // SRB2kart - Can't drown. - if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) - P_RestoreMusic(player); - */ - player->powers[pw_underwater] = 0; if (player->powers[pw_spacetime] > 1) @@ -3208,10 +3144,9 @@ void A_ForceShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ForceShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3246,10 +3181,9 @@ void A_PityShield(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_PityShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3279,10 +3213,9 @@ void A_GravityBox(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_GravityBox", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3304,10 +3237,9 @@ void A_GravityBox(mobj_t *actor) // void A_ScoreRise(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_ScoreRise", actor)) return; -#endif + // make logo rise! P_SetObjectMomZ(actor, actor->info->speed, false); } @@ -3326,10 +3258,9 @@ void A_ParticleSpawn(mobj_t *actor) mobjtype_t type; mobj_t *spawn; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ParticleSpawn", actor)) return; -#endif + if (!actor->spawnpoint) { P_RemoveMobj(actor); @@ -3363,10 +3294,9 @@ void A_BunnyHop(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BunnyHop", actor)) return; -#endif + if (((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz) || (!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz)) { @@ -3387,10 +3317,10 @@ void A_BubbleSpawn(mobj_t *actor) INT32 i, locvar1 = var1; UINT8 prandom; mobj_t *bubble = NULL; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BubbleSpawn", actor)) return; -#endif + if (!(actor->eflags & MFE_UNDERWATER)) { // Don't draw or spawn bubbles above water @@ -3440,10 +3370,10 @@ void A_FanBubbleSpawn(mobj_t *actor) UINT8 prandom; mobj_t *bubble = NULL; fixed_t hz = actor->z + (4*actor->height)/5; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FanBubbleSpawn", actor)) return; -#endif + if (!(actor->eflags & MFE_UNDERWATER)) return; @@ -3487,10 +3417,9 @@ void A_BubbleRise(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BubbleRise", actor)) return; -#endif + if (actor->type == MT_EXTRALARGEBUBBLE) P_SetObjectMomZ(actor, FixedDiv(6*FRACUNIT,5*FRACUNIT), false); // make bubbles rise! else @@ -3524,10 +3453,9 @@ void A_BubbleRise(mobj_t *actor) // void A_BubbleCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_BubbleCheck", actor)) return; -#endif + if (actor->eflags & MFE_UNDERWATER) actor->flags2 &= ~MF2_DONTDRAW; // underwater so draw else @@ -3543,10 +3471,9 @@ void A_BubbleCheck(mobj_t *actor) // void A_AttractChase(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_AttractChase", actor)) return; -#endif + if (actor->flags2 & MF2_NIGHTSPULL || !actor->health) return; @@ -3615,10 +3542,9 @@ void A_DropMine(mobj_t *actor) INT32 locvar2 = var2; fixed_t z; mobj_t *mine; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_DropMine", actor)) return; -#endif if (locvar2 & 65535) { @@ -3663,10 +3589,9 @@ void A_DropMine(mobj_t *actor) void A_FishJump(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FishJump", actor)) return; -#endif if ((actor->z <= actor->floorz) || (actor->z <= actor->watertop - FixedMul((64 << FRACBITS), actor->scale))) { @@ -3700,10 +3625,9 @@ void A_ThrownRing(mobj_t *actor) INT32 stop; player_t *player; fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ThrownRing", actor)) return; -#endif if (leveltime % (TICRATE/7) == 0) { @@ -3907,10 +3831,9 @@ void A_GrenadeRing(mobj_t *actor) { INT32 bx, by, xl, xh, yl, yh; explodedist = FixedMul(actor->info->painchance, mapobjectscale); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_GrenadeRing", actor)) return; -#endif if (actor->flags2 & MF2_DEBRIS) return; @@ -3979,10 +3902,9 @@ void A_MineExplode(mobj_t *actor) INT32 locvar1 = var1; mobjtype_t type; explodedist = FixedMul((3*actor->info->painchance)/2, mapobjectscale); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MineExplode", actor)) return; -#endif if (actor->flags2 & MF2_DEBRIS) return; @@ -4026,10 +3948,9 @@ void A_MineExplode(mobj_t *actor) // void A_SetSolidSteam(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SetSolidSteam", actor)) return; -#endif + actor->flags &= ~MF_NOCLIP; actor->flags |= MF_SOLID; @@ -4059,10 +3980,10 @@ void A_SetSolidSteam(mobj_t *actor) // void A_UnsetSolidSteam(mobj_t *actor) { -#ifdef HAVE_BLUA + if (LUA_CallAction("A_UnsetSolidSteam", actor)) return; -#endif + actor->flags &= ~MF_SOLID; actor->flags |= MF_NOCLIP; } @@ -4077,10 +3998,10 @@ void A_UnsetSolidSteam(mobj_t *actor) void A_SignPlayer(mobj_t *actor) { mobj_t *ov; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SignPlayer", actor)) return; -#endif + if (!actor->target) return; @@ -4121,10 +4042,10 @@ void A_SignPlayer(mobj_t *actor) void A_OverlayThink(mobj_t *actor) { fixed_t destx, desty; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_OverlayThink", actor)) return; -#endif + if (!actor->target) return; @@ -4173,10 +4094,9 @@ void A_OverlayThink(mobj_t *actor) void A_JetChase(mobj_t *actor) { fixed_t thefloor; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetChase", actor)) return; -#endif if (actor->flags2 & MF2_AMBUSH) return; @@ -4270,10 +4190,9 @@ void A_JetbThink(mobj_t *actor) { sector_t *nextsector; fixed_t thefloor; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetbThink", actor)) return; -#endif if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz && actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale)) @@ -4335,10 +4254,9 @@ void A_JetbThink(mobj_t *actor) void A_JetgShoot(mobj_t *actor) { fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetgShoot", actor)) return; -#endif if (!actor->target) return; @@ -4376,10 +4294,9 @@ void A_JetgShoot(mobj_t *actor) void A_ShootBullet(mobj_t *actor) { fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ShootBullet", actor)) return; -#endif if (!actor->target) return; @@ -4405,10 +4322,9 @@ void A_ShootBullet(mobj_t *actor) // void A_MinusDigging(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_MinusDigging", actor)) return; -#endif + actor->flags &= ~MF_SPECIAL; actor->flags &= ~MF_SHOOTABLE; @@ -4457,10 +4373,10 @@ void A_MinusDigging(mobj_t *actor) // void A_MinusPopup(mobj_t *actor) { -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MinusPopup", actor)) return; -#endif + P_SetObjectMomZ(actor, 10*FRACUNIT, false); actor->flags |= MF_SPECIAL; @@ -4479,10 +4395,9 @@ void A_MinusPopup(mobj_t *actor) // void A_MinusCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_MinusCheck", actor)) return; -#endif + if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) || ((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz)) { @@ -4507,10 +4422,9 @@ void A_MinusCheck(mobj_t *actor) // void A_ChickenCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_ChickenCheck", actor)) return; -#endif + if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) || (actor->eflags & MFE_VERTICALFLIP && actor->z + actor->height >= actor->ceilingz)) { @@ -4538,10 +4452,9 @@ void A_JetgThink(mobj_t *actor) sector_t *nextsector; fixed_t thefloor; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetgThink", actor)) return; -#endif if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz && actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale)) @@ -4590,10 +4503,8 @@ void A_JetgThink(mobj_t *actor) // void A_MouseThink(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_MouseThink", actor)) return; -#endif if (actor->reactiontime) actor->reactiontime--; @@ -4628,10 +4539,9 @@ void A_DetonChase(mobj_t *actor) { angle_t exact; fixed_t xydist, dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_DetonChase", actor)) return; -#endif // modify tracer threshold if (!actor->tracer || actor->tracer->health <= 0) @@ -4775,10 +4685,9 @@ void A_CapeChase(mobj_t *actor) fixed_t foffsetx, foffsety, boffsetx, boffsety; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CapeChase", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_CapeChase called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -4834,10 +4743,9 @@ void A_RotateSpikeBall(mobj_t *actor) { INT32 locvar1 = var1; const fixed_t radius = FixedMul(12*actor->info->speed, actor->scale); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RotateSpikeBall", actor)) return; -#endif if (actor->type == MT_SPECIALSPIKEBALL) // don't remove this, these spikeballs share the same states as the rotating spikeballs return; @@ -4890,10 +4798,8 @@ void A_UnidusBall(mobj_t *actor) INT32 locvar1 = var1; boolean canthrow = false; -#ifdef HAVE_BLUA if (LUA_CallAction("A_UnidusBall", actor)) return; -#endif actor->angle += ANGLE_11hh; @@ -4988,10 +4894,9 @@ void A_RockSpawn(mobj_t *actor) line_t *line; fixed_t dist; fixed_t randomoomph; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RockSpawn", actor)) return; -#endif if (i == -1) { @@ -5043,10 +4948,9 @@ void A_SlingAppear(mobj_t *actor) boolean firsttime = true; UINT8 mlength = 4; mobj_t *spawnee; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SlingAppear", actor)) return; -#endif P_UnsetThingPosition(actor); actor->flags &= ~(MF_NOBLOCKMAP|MF_NOCLIP|MF_NOGRAVITY|MF_NOCLIPHEIGHT); @@ -5104,10 +5008,9 @@ void A_MaceRotate(mobj_t *actor) TVector v; TVector *res; fixed_t radius; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MaceRotate", actor)) return; -#endif // Target was removed. if (!actor->target) @@ -5217,10 +5120,9 @@ void A_SetFuse(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetFuse", actor)) return; -#endif if ((!actor->fuse || (locvar2 >> 16)) && (locvar2 >> 16) != 2) // set the actor's fuse value actor->fuse = locvar1; @@ -5246,10 +5148,9 @@ void A_CrawlaCommanderThink(mobj_t *actor) fixed_t thefloor; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CrawlaCommanderThink", actor)) return; -#endif if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz && actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale)) @@ -5385,10 +5286,9 @@ void A_RingExplode(mobj_t *actor) mobj_t *mo2; thinker_t *th; angle_t d; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RingExplode", actor)) return; -#endif for (d = 0; d < 16; d++) P_SpawnParaloop(actor->x, actor->y, actor->z + actor->height, FixedMul(actor->info->painchance, actor->scale), 16, MT_NIGHTSPARKLE, S_NULL, d*(ANGLE_22h), true); @@ -5432,10 +5332,9 @@ void A_OldRingExplode(mobj_t *actor) { INT32 locvar1 = var1; //INT32 locvar2 = var2; boolean changecolor = (actor->target && actor->target->player); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_OldRingExplode", actor)) return; -#endif for (i = 0; i < 32; i++) { @@ -5509,12 +5408,9 @@ void A_MixUp(mobj_t *actor) { boolean teleported[MAXPLAYERS]; INT32 i, numplayers = 0, prandom = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MixUp", actor)) return; -#else - (void)actor; -#endif if (!multiplayer) return; @@ -5769,15 +5665,8 @@ void A_RecyclePowers(mobj_t *actor) INT32 weapons[MAXPLAYERS]; INT32 weaponheld[MAXPLAYERS]; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RecyclePowers", actor)) return; -#endif - -#if !defined(HAVE_BLUA) - // actor is used in all scenarios but this one, funny enough - (void)actor; -#endif if (!multiplayer) return; @@ -5868,10 +5757,9 @@ void A_RecyclePowers(mobj_t *actor) void A_Boss1Chase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss1Chase", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -5989,10 +5877,9 @@ void A_Boss2Chase(mobj_t *actor) fixed_t radius; boolean reverse = false; INT32 speedvar; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss2Chase", actor)) return; -#endif if (actor->health <= 0) return; @@ -6117,10 +6004,9 @@ void A_Boss2Chase(mobj_t *actor) // void A_Boss2Pogo(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss2Pogo", actor)) return; -#endif + if (actor->z <= actor->floorz + FixedMul(8*FRACUNIT, actor->scale) && actor->momz <= 0) { if (actor->state != &states[actor->info->raisestate]) @@ -6165,10 +6051,10 @@ void A_Boss2Pogo(mobj_t *actor) void A_Boss2TakeDamage(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss2TakeDamage", actor)) return; -#endif + A_Pain(actor); actor->reactiontime = 1; // turn around if (locvar1 == 0) // old A_Invincibilerize behavior @@ -6188,10 +6074,9 @@ void A_Boss7Chase(mobj_t *actor) { INT32 delta; INT32 i; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss7Chase", actor)) return; -#endif if (actor->z != actor->floorz) return; @@ -6320,10 +6205,9 @@ void A_Boss7Chase(mobj_t *actor) // void A_GoopSplat(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_GoopSplat", actor)) return; -#endif + P_UnsetThingPosition(actor); if (sector_list) { @@ -6345,10 +6229,9 @@ void A_Boss2PogoSFX(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss2PogoSFX", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -6389,10 +6272,8 @@ void A_Boss2PogoTarget(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss2PogoTarget", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE) || (actor->target->player && actor->target->player->powers[pw_flashing]) || P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) >= FixedMul(512*FRACUNIT, actor->scale)) @@ -6476,10 +6357,9 @@ void A_Boss2PogoTarget(mobj_t *actor) // void A_EggmanBox(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_EggmanBox", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -6502,10 +6382,9 @@ void A_TurretFire(mobj_t *actor) fixed_t dist; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_TurretFire", actor)) return; -#endif if (locvar2) dist = FixedMul(locvar2*FRACUNIT, actor->scale); @@ -6541,10 +6420,9 @@ void A_SuperTurretFire(mobj_t *actor) fixed_t dist; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SuperTurretFire", actor)) return; -#endif if (locvar2) dist = FixedMul(locvar2*FRACUNIT, actor->scale); @@ -6578,10 +6456,9 @@ void A_SuperTurretFire(mobj_t *actor) void A_TurretStop(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_TurretStop", actor)) return; -#endif actor->flags2 &= ~MF2_FIRING; actor->flags2 &= ~MF2_SUPERFIRE; @@ -6599,10 +6476,8 @@ void A_TurretStop(mobj_t *actor) // void A_SparkFollow(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SparkFollow", actor)) return; -#endif if ((!actor->target || (actor->target->health <= 0)) || (actor->target->player && !actor->target->player->powers[pw_super])) @@ -6636,10 +6511,10 @@ void A_BuzzFly(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BuzzFly", actor)) return; -#endif + if (actor->flags2 & MF2_AMBUSH) return; @@ -6735,10 +6610,9 @@ void A_BuzzFly(mobj_t *actor) void A_GuardChase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_GuardChase", actor)) return; -#endif if (actor->reactiontime) actor->reactiontime--; @@ -6811,10 +6685,9 @@ void A_EggShield(mobj_t *actor) fixed_t newx, newy; fixed_t movex, movey; angle_t angle; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_EggShield", actor)) return; -#endif if (!actor->target || !actor->target->health) { @@ -6895,10 +6768,9 @@ void A_EggShield(mobj_t *actor) // void A_SetReactionTime(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SetReactionTime", actor)) return; -#endif + if (var1) actor->reactiontime = var2; else @@ -6918,10 +6790,8 @@ void A_Boss1Spikeballs(mobj_t *actor) INT32 locvar2 = var2; mobj_t *ball; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss1Spikeballs", actor)) return; -#endif ball = P_SpawnMobj(actor->x, actor->y, actor->z, MT_EGGMOBILE_BALL); P_SetTarget(&ball->target, actor); @@ -6942,10 +6812,9 @@ void A_Boss1Spikeballs(mobj_t *actor) // void A_Boss3TakeDamage(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss3TakeDamage", actor)) return; -#endif + actor->movecount = var1; if (actor->target && actor->target->spawnpoint) @@ -6961,10 +6830,8 @@ void A_Boss3TakeDamage(mobj_t *actor) // void A_Boss3Path(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss3Path", actor)) return; -#endif if (actor->tracer && actor->tracer->health && actor->tracer->movecount) actor->movecount |= 1; @@ -7088,10 +6955,9 @@ void A_LinedefExecute(mobj_t *actor) INT32 tagnum; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_LinedefExecute", actor)) return; -#endif tagnum = locvar1; // state numbers option is no more, custom states cannot be guaranteed to stay the same number anymore, now that they can be defined by names instead @@ -7114,10 +6980,9 @@ void A_LinedefExecute(mobj_t *actor) // void A_PlaySeeSound(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_PlaySeeSound", actor)) return; -#endif + if (actor->info->seesound) S_StartScreamSound(actor, actor->info->seesound); } @@ -7131,10 +6996,9 @@ void A_PlaySeeSound(mobj_t *actor) // void A_PlayAttackSound(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_PlayAttackSound", actor)) return; -#endif + if (actor->info->attacksound) S_StartAttackSound(actor, actor->info->attacksound); } @@ -7148,10 +7012,9 @@ void A_PlayAttackSound(mobj_t *actor) // void A_PlayActiveSound(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_PlayActiveSound", actor)) return; -#endif + if (actor->info->activesound) S_StartSound(actor, actor->info->activesound); } @@ -7167,10 +7030,9 @@ void A_SmokeTrailer(mobj_t *actor) { mobj_t *th; INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SmokeTrailer", actor)) return; -#endif if (leveltime % 4) return; @@ -7209,10 +7071,9 @@ void A_SpawnObjectAbsolute(mobj_t *actor) mobj_t *mo; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SpawnObjectAbsolute", actor)) return; -#endif x = (INT16)(locvar1>>16); y = (INT16)(locvar1&65535); @@ -7246,10 +7107,9 @@ void A_SpawnObjectRelative(mobj_t *actor) mobj_t *mo; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SpawnObjectRelative", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_SpawnObjectRelative called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7285,25 +7145,16 @@ void A_ChangeAngleRelative(mobj_t *actor) // rather than the ranges, so <0 and >360 work as possible values. -Red INT32 locvar1 = var1; INT32 locvar2 = var2; - //angle_t angle = (P_RandomByte()+1)<<24; const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - //const angle_t amin = FixedAngle(locvar1*FRACUNIT); - //const angle_t amax = FixedAngle(locvar2*FRACUNIT); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeAngleRelative", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) I_Error("A_ChangeAngleRelative: var1 is greater then var2"); #endif -/* - if (angle < amin) - angle = amin; - if (angle > amax) - angle = amax;*/ actor->angle += FixedAngle(P_RandomRange(amin, amax)); } @@ -7319,25 +7170,16 @@ void A_ChangeAngleAbsolute(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; - //angle_t angle = (P_RandomByte()+1)<<24; const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; - //const angle_t amin = FixedAngle(locvar1*FRACUNIT); - //const angle_t amax = FixedAngle(locvar2*FRACUNIT); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeAngleAbsolute", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) I_Error("A_ChangeAngleAbsolute: var1 is greater then var2"); #endif -/* - if (angle < amin) - angle = amin; - if (angle > amax) - angle = amax;*/ actor->angle = FixedAngle(P_RandomRange(amin, amax)); } @@ -7355,10 +7197,8 @@ void A_RollAngle(mobj_t *actor) INT32 locvar2 = var2; const angle_t angle = FixedAngle(locvar1*FRACUNIT); -#ifdef HAVE_BLUA if (LUA_CallAction("A_RollAngle", actor)) return; -#endif // relative (default) if (!locvar2) @@ -7381,10 +7221,9 @@ void A_ChangeRollAngleRelative(mobj_t *actor) INT32 locvar2 = var2; const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeRollAngleRelative", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) @@ -7407,10 +7246,9 @@ void A_ChangeRollAngleAbsolute(mobj_t *actor) INT32 locvar2 = var2; const fixed_t amin = locvar1*FRACUNIT; const fixed_t amax = locvar2*FRACUNIT; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeRollAngleAbsolute", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) @@ -7433,10 +7271,9 @@ void A_PlaySound(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_PlaySound", actor)) return; -#endif S_StartSound(locvar2 ? actor : NULL, locvar1); } @@ -7456,10 +7293,9 @@ void A_FindTarget(mobj_t *actor) thinker_t *th; mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FindTarget", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_FindTarget called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7521,10 +7357,9 @@ void A_FindTracer(mobj_t *actor) thinker_t *th; mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FindTracer", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_FindTracer called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7582,10 +7417,9 @@ void A_SetTics(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetTics", actor)) return; -#endif if (locvar1) actor->tics = locvar1; @@ -7604,10 +7438,9 @@ void A_SetRandomTics(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetRandomTics", actor)) return; -#endif actor->tics = P_RandomRange(locvar1, locvar2); } @@ -7623,10 +7456,9 @@ void A_ChangeColorRelative(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeColorRelative", actor)) return; -#endif if (locvar1) { @@ -7649,10 +7481,9 @@ void A_ChangeColorAbsolute(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeColorAbsolute", actor)) return; -#endif if (locvar1) { @@ -7674,10 +7505,9 @@ void A_MoveRelative(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MoveRelative", actor)) return; -#endif P_Thrust(actor, actor->angle+FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); } @@ -7693,10 +7523,9 @@ void A_MoveAbsolute(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MoveAbsolute", actor)) return; -#endif P_InstaThrust(actor, FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); } @@ -7712,10 +7541,9 @@ void A_Thrust(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Thrust", actor)) return; -#endif if (!locvar1) CONS_Debug(DBG_GAMELOGIC, "A_Thrust: Var1 not specified!\n"); @@ -7739,10 +7567,9 @@ void A_ZThrust(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ZThrust", actor)) return; -#endif if (!locvar1) CONS_Debug(DBG_GAMELOGIC, "A_ZThrust: Var1 not specified!\n"); @@ -7774,10 +7601,9 @@ void A_SetTargetsTarget(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *oldtarg = NULL, *newtarg = NULL; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetTargetsTarget", actor)) return; -#endif // actor's target if (locvar1) // or tracer @@ -7819,10 +7645,9 @@ void A_SetObjectFlags(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; boolean unlinkthings = false; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetObjectFlags", actor)) return; -#endif if (locvar2 == 2) locvar1 = actor->flags | locvar1; @@ -7861,10 +7686,9 @@ void A_SetObjectFlags2(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetObjectFlags2", actor)) return; -#endif if (locvar2 == 2) actor->flags2 |= locvar1; @@ -7889,10 +7713,9 @@ void A_BossJetFume(mobj_t *actor) { mobj_t *filler; INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BossJetFume", actor)) return; -#endif if (locvar1 == 0) // Boss1 jet fumes { @@ -8000,10 +7823,9 @@ void A_RandomState(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RandomState", actor)) return; -#endif P_SetMobjState(actor, P_RandomChance(FRACUNIT/2) ? locvar1 : locvar2); } @@ -8020,10 +7842,8 @@ void A_RandomStateRange(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RandomStateRange", actor)) return; -#endif P_SetMobjState(actor, P_RandomRange(locvar1, locvar2)); } @@ -8039,27 +7859,22 @@ void A_DualAction(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_DualAction", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_DualAction called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); var1 = states[locvar1].var1; var2 = states[locvar1].var2; -#ifdef HAVE_BLUA astate = &states[locvar1]; -#endif CONS_Debug(DBG_GAMELOGIC, "A_DualAction: Calling First Action (state %d)...\n", locvar1); states[locvar1].action.acp1(actor); var1 = states[locvar2].var1; var2 = states[locvar2].var2; -#ifdef HAVE_BLUA astate = &states[locvar2]; -#endif CONS_Debug(DBG_GAMELOGIC, "A_DualAction: Calling Second Action (state %d)...\n", locvar2); states[locvar2].action.acp1(actor); @@ -8077,10 +7892,9 @@ void A_RemoteAction(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *originaltarget = actor->target; // Hold on to the target for later. -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RemoteAction", actor)) return; -#endif // If >=0, find the closest target. if (locvar1 >= 0) @@ -8142,9 +7956,7 @@ void A_RemoteAction(mobj_t *actor) // Steal the var1 and var2 from "locvar2" var1 = states[locvar2].var1; var2 = states[locvar2].var2; -#ifdef HAVE_BLUA astate = &states[locvar2]; -#endif CONS_Debug(DBG_GAMELOGIC, "A_RemoteAction: Calling action on %p\n" "var1 is %d\nvar2 is %d\n", actor->target, var1, var2); @@ -8163,10 +7975,9 @@ void A_RemoteAction(mobj_t *actor) // void A_ToggleFlameJet(mobj_t* actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_ToggleFlameJet", actor)) return; -#endif + // threshold - off delay // movecount - on timer @@ -8191,10 +8002,9 @@ void A_ItemPop(mobj_t *actor) { mobj_t *remains; mobjtype_t explode; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ItemPop", actor)) return; -#endif if (!(actor->target && actor->target->player)) { @@ -8258,10 +8068,9 @@ void A_ItemPop(mobj_t *actor) void A_JawzChase(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JawzChase", actor)) return; -#endif if (actor->tracer) { @@ -8305,10 +8114,8 @@ void A_JawzExplode(mobj_t *actor) INT32 shrapnel = 2; mobj_t *truc; -#ifdef HAVE_BLUA if (LUA_CallAction("A_JawzExplode", actor)) return; -#endif truc = P_SpawnMobj(actor->x, actor->y, actor->z, MT_BOOMEXPLODE); truc->scale = actor->scale*2; @@ -8346,10 +8153,9 @@ void A_SPBChase(mobj_t *actor) fixed_t dist; angle_t hang, vang; fixed_t wspeed, xyspeed, zspeed; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SPBChase", actor)) return; -#endif // Default speed wspeed = actor->movefactor; @@ -8626,10 +8432,9 @@ void A_SPBChase(mobj_t *actor) void A_BallhogExplode(mobj_t *actor) { mobj_t *mo2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BallhogExplode", actor)) return; -#endif mo2 = P_SpawnMobj(actor->x, actor->y, actor->z, MT_BALLHOGBOOM); P_SetScale(mo2, actor->scale*2); @@ -8643,10 +8448,10 @@ void A_BallhogExplode(mobj_t *actor) void A_LightningFollowPlayer(mobj_t *actor) { fixed_t sx, sy; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_LightningFollowPlayer", actor)) return; -#endif + if (!actor->target) return; @@ -8672,10 +8477,10 @@ void A_LightningFollowPlayer(mobj_t *actor) void A_FZBoomFlash(mobj_t *actor) { UINT8 i; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FZBoomFlash", actor)) return; -#endif + for (i = 0; i < MAXPLAYERS; i++) { fixed_t dist; @@ -8695,10 +8500,10 @@ void A_FZBoomSmoke(mobj_t *actor) { INT32 i; INT32 rad = 47+(23*var1); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FZBoomSmoke", actor)) return; -#endif + for (i = 0; i < 8+(4*var1); i++) { mobj_t *smoke = P_SpawnMobj(actor->x + (P_RandomRange(-rad, rad)*actor->scale), actor->y + (P_RandomRange(-rad, rad)*actor->scale), @@ -8717,10 +8522,9 @@ void A_RandomShadowFrame(mobj_t *actor) { mobj_t *fire; mobj_t *fake; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RandomShadowFrame", (actor))) return; -#endif if (!actor->extravalue1) // Hack that spawns thoks that look like random shadows. Otherwise the state would overwrite our frame and that's a pain. { @@ -8766,10 +8570,9 @@ void A_RoamingShadowThinker(mobj_t *actor) { mobj_t *wind; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RoamingShadowThinker", (actor))) return; -#endif + // extravalue1 replaces "movetimer" // extravalue2 replaces "stoptimer" @@ -8824,10 +8627,9 @@ void A_MayonakaArrow(mobj_t *actor) { INT32 flip = 0; INT32 iswarning; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MayonakaArrow", (actor))) return; -#endif iswarning = actor->spawnpoint->options & MTF_OBJECTSPECIAL; // is our object a warning sign? // "animtimer" is replaced by "extravalue1" here. @@ -8866,10 +8668,8 @@ void A_MementosTPParticles(mobj_t *actor) int i = 0; thinker_t *th; -#ifdef HAVE_BLUA if (LUA_CallAction("A_MementosTPParticles", (actor))) return; -#endif for (; i<4; i++) { @@ -8917,11 +8717,8 @@ void A_ReaperThinker(mobj_t *actor) player_t *player; // used as a shortcut in a loop. mobj_t *targetplayermo = NULL; // the player mo we can eventually target, or whatever. - -#ifdef HAVE_BLUA if (LUA_CallAction("A_ReaperThinker", (actor))) return; -#endif // We don't have custom variables or whatever so we'll do with whatever the fuck we have left. @@ -9090,10 +8887,9 @@ void A_FlameParticle(mobj_t *actor) { fixed_t rad = actor->radius>>FRACBITS, hei = actor->radius>>FRACBITS; mobj_t *par; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FlameParticle", actor)) return; -#endif par = P_SpawnMobj( actor->x + (P_RandomRange(-rad, rad)<target || !actor->target->player || !actor->target->tracer || !actor->target->player->nightstime @@ -9161,10 +8956,9 @@ void A_OrbitNights(mobj_t* actor) // void A_GhostMe(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_GhostMe", actor)) return; -#endif + P_SpawnGhostMobj(actor); } @@ -9182,10 +8976,9 @@ void A_SetObjectState(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *target; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetObjectState", actor)) return; -#endif if ((!locvar2 && !actor->target) || (locvar2 && !actor->tracer)) { @@ -9228,10 +9021,8 @@ void A_SetObjectTypeState(mobj_t *actor) mobj_t *mo2; fixed_t dist = 0; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SetObjectTypeState", actor)) return; -#endif for (th = thinkercap.next; th != &thinkercap; th = th->next) { @@ -9271,10 +9062,9 @@ void A_KnockBack(mobj_t *actor) { INT32 locvar1 = var1; mobj_t *target; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_KnockBack", actor)) return; -#endif if (!locvar1) target = actor->target; @@ -9307,10 +9097,9 @@ void A_PushAway(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; // target angle_t an; // actor to target angle -#ifdef HAVE_BLUA + if (LUA_CallAction("A_PushAway", actor)) return; -#endif if ((!(locvar2 >> 16) && !actor->target) || ((locvar2 >> 16) && !actor->tracer)) return; @@ -9342,10 +9131,9 @@ void A_RingDrain(mobj_t *actor) { INT32 locvar1 = var1; player_t *player; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RingDrain", actor)) return; -#endif if (!actor->target || !actor->target->player) { @@ -9375,10 +9163,9 @@ void A_SplitShot(mobj_t *actor) const UINT16 loc2up = (UINT16)(locvar2 >> 16); const fixed_t offs = (fixed_t)(locvar1*FRACUNIT); const fixed_t hoffs = (fixed_t)(loc2up*FRACUNIT); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SplitShot", actor)) return; -#endif A_FaceTarget(actor); { @@ -9410,10 +9197,10 @@ void A_MissileSplit(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MissileSplit", actor)) return; -#endif + if (actor->eflags & MFE_VERTICALFLIP) P_SpawnAlteredDirectionMissile(actor, locvar1, actor->x, actor->y, actor->z+actor->height, locvar2); else @@ -9438,10 +9225,9 @@ void A_MultiShot(mobj_t *actor) const UINT16 loc1up = (UINT16)(locvar1 >> 16); INT32 count = 0; fixed_t ad; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MultiShot", actor)) return; -#endif if (actor->target) A_FaceTarget(actor); @@ -9500,10 +9286,9 @@ void A_InstaLoop(mobj_t *actor) const angle_t fa = FixedAngleC(loc1lw*FRACUNIT*360, loc1up*FRACUNIT)>>ANGLETOFINESHIFT; const fixed_t ac = FINECOSINE(fa); const fixed_t as = FINESINE(fa); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_InstaLoop", actor)) return; -#endif P_InstaThrust(actor, actor->angle, FixedMul(ac, FixedMul(force, actor->scale))); P_SetObjectMomZ(actor, FixedMul(as, force), false); @@ -9534,10 +9319,9 @@ void A_Custom3DRotate(mobj_t *actor) const fixed_t hOff = FixedMul(loc1up*FRACUNIT, actor->scale); const fixed_t hspeed = FixedMul(loc2up*FRACUNIT/10, actor->scale); const fixed_t vspeed = FixedMul(loc2lw*FRACUNIT/10, actor->scale); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Custom3DRotate", actor)) return; -#endif if (!actor->target) // Ensure we actually have a target first. { @@ -9595,10 +9379,9 @@ void A_SearchForPlayers(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SearchForPlayers", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -9629,10 +9412,9 @@ void A_CheckRandom(mobj_t *actor) INT32 locvar2 = var2; fixed_t chance = FRACUNIT; -#ifdef HAVE_BLUA if (LUA_CallAction("A_CheckRandom", actor)) return; -#endif + if ((locvar1 & 0xFFFF) == 0) return; @@ -9656,10 +9438,9 @@ void A_CheckTargetRings(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckTargetRings", actor)) return; -#endif if (!(actor->target) || !(actor->target->player)) return; @@ -9680,10 +9461,9 @@ void A_CheckRings(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; INT32 i, cntr = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckRings", actor)) return; -#endif for (i = 0; i < MAXPLAYERS; i++) cntr += players[i].health-1; @@ -9705,10 +9485,9 @@ void A_CheckTotalRings(mobj_t *actor) INT32 locvar2 = var2; INT32 i, cntr = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckTotalRings", actor)) return; -#endif for (i = 0; i < MAXPLAYERS; i++) cntr += players[i].totalring; @@ -9728,10 +9507,9 @@ void A_CheckHealth(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckHealth", actor)) return; -#endif if (actor->health <= locvar1) P_SetMobjState(actor, locvar2); @@ -9751,10 +9529,9 @@ void A_CheckRange(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckRange", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -9782,10 +9559,9 @@ void A_CheckHeight(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; fixed_t height; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckHeight", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -9815,10 +9591,9 @@ void A_CheckTrueRange(mobj_t *actor) fixed_t height; // vertical range fixed_t dist; // horizontal range fixed_t l; // true range -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckTrueRange", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -9867,10 +9642,9 @@ void A_CheckThingCount(mobj_t *actor) thinker_t *th; mobj_t *mo2; fixed_t dist = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckThingCount", actor)) return; -#endif for (th = thinkercap.next; th != &thinkercap; th = th->next) { @@ -9914,10 +9688,8 @@ void A_CheckAmbush(mobj_t *actor) angle_t atp; // actor to target angle angle_t an; // angle between at and atp -#ifdef HAVE_BLUA if (LUA_CallAction("A_CheckAmbush", actor)) return; -#endif if ((!locvar1 && !actor->target) || (locvar1 && !actor->tracer)) return; @@ -9953,10 +9725,9 @@ void A_CheckCustomValue(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckCustomValue", actor)) return; -#endif if (actor->cusval >= locvar1) P_SetMobjState(actor, locvar2); @@ -9973,10 +9744,9 @@ void A_CheckCusValMemo(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckCusValMemo", actor)) return; -#endif if (actor->cvmem >= locvar1) P_SetMobjState(actor, locvar2); @@ -9999,10 +9769,9 @@ void A_SetCustomValue(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetCustomValue", actor)) return; -#endif if (cv_debug) CONS_Printf("Init custom value is %d\n", actor->cusval); @@ -10050,10 +9819,9 @@ void A_UseCusValMemo(mobj_t *actor) INT32 temp = actor->cusval; // value being manipulated INT32 tempM = actor->cvmem; // value used to manipulate temp with -#ifdef HAVE_BLUA + if (LUA_CallAction("A_UseCusValMemo", actor)) return; -#endif if (locvar1 == 1) // cvmem being changed using cusval { @@ -10114,10 +9882,9 @@ void A_RelayCustomValue(mobj_t *actor) INT32 temp; // reference value - var1 lower 16 bits changes this INT32 tempT; // target's value - changed to tracer if var1 upper 16 bits set, then modified to become final value -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RelayCustomValue", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -10174,10 +9941,9 @@ void A_CusValAction(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CusValAction", actor)) return; -#endif if (locvar2 == 5) { @@ -10210,9 +9976,7 @@ void A_CusValAction(mobj_t *actor) var2 = states[locvar1].var2; } -#ifdef HAVE_BLUA astate = &states[locvar1]; -#endif states[locvar1].action.acp1(actor); } @@ -10228,10 +9992,9 @@ void A_CusValAction(mobj_t *actor) void A_ForceStop(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ForceStop", actor)) return; -#endif actor->momx = actor->momy = 0; if (locvar1 == 0) @@ -10249,12 +10012,8 @@ void A_ForceWin(mobj_t *actor) { INT32 i; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ForceWin", actor)) return; -#else - (void)actor; -#endif for (i = 0; i < MAXPLAYERS; i++) { @@ -10282,10 +10041,9 @@ void A_ForceWin(mobj_t *actor) void A_SpikeRetract(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SpikeRetract", actor)) return; -#endif if (actor->flags & MF_NOBLOCKMAP) return; @@ -10367,10 +10125,9 @@ void A_Repeat(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Repeat", actor)) return; -#endif if ((!(actor->extravalue2)) || actor->extravalue2 > locvar1) actor->extravalue2 = locvar1; @@ -10393,10 +10150,9 @@ void A_SetScale(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *target; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetScale", actor)) return; -#endif if (locvar1 <= 0) { @@ -10439,10 +10195,10 @@ void A_RemoteDamage(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; // we MUST have a target mobj_t *source = NULL; // on the other hand we don't necessarily need a source -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RemoteDamage", actor)) return; -#endif + if (locvar1 == 1) target = actor->target; else if (locvar1 == 2) @@ -10492,10 +10248,9 @@ void A_HomingChase(mobj_t *actor) mobj_t *dest; fixed_t dist; fixed_t speedmul; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_HomingChase", actor)) return; -#endif if (locvar2 == 1) dest = actor->tracer; @@ -10541,10 +10296,9 @@ void A_TrapShot(mobj_t *actor) INT16 vertoff = (INT16)(locvar2 >> 16); fixed_t x, y, z; fixed_t speed; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_TrapShot", actor)) return; -#endif x = actor->x + P_ReturnThrustX(actor, actor->angle, FixedMul(frontoff*FRACUNIT, actor->scale)); y = actor->y + P_ReturnThrustY(actor, actor->angle, FixedMul(frontoff*FRACUNIT, actor->scale)); @@ -10596,10 +10350,8 @@ void A_VileTarget(mobj_t *actor) mobjtype_t fogtype; INT32 i; -#ifdef HAVE_BLUA if (LUA_CallAction("A_VileTarget", actor)) return; -#endif if (!actor->target) return; @@ -10685,10 +10437,8 @@ void A_VileAttack(mobj_t *actor) mobj_t *fire; INT32 i; -#ifdef HAVE_BLUA if (LUA_CallAction("A_VileAttack", actor)) return; -#endif if (!actor->target) return; @@ -10799,10 +10549,8 @@ void A_VileFire(mobj_t *actor) INT32 locvar2 = var2; mobj_t *dest; -#ifdef HAVE_BLUA if (LUA_CallAction("A_VileFire", actor)) return; -#endif dest = actor->tracer; if (!dest) @@ -10887,10 +10635,8 @@ void A_BrakChase(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BrakChase", actor)) return; -#endif // Set new tics NOW, in case the state changes while we're doing this and we try applying this to the painstate or something silly if (actor->tics > 1 && locvar1 < actor->tics) // Not much point, otherwise @@ -11009,10 +10755,9 @@ void A_BrakFireShot(mobj_t *actor) fixed_t x, y, z; INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BrakFireShot", actor)) return; -#endif + if (!actor->target) return; @@ -11073,10 +10818,8 @@ void A_BrakLobShot(mobj_t *actor) INT32 locvar2 = var2 & 0x0000FFFF; INT32 aimDirect = var2 & 0xFFFF0000; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BrakLobShot", actor)) return; -#endif if (!actor->target) return; // Don't even bother if we've got nothing to aim at. @@ -11181,10 +10924,8 @@ void A_NapalmScatter(mobj_t *actor) INT32 i; // for-loop cursor mobj_t *mo; // each and every spawned napalm burst -#ifdef HAVE_BLUA if (LUA_CallAction("A_NapalmScatter", actor)) return; -#endif // Some quick sanity-checking if (typeOfShot >= NUMMOBJTYPES) // I'd add a <0 check, too, but 0x0000FFFF isn't negative in this case @@ -11235,10 +10976,8 @@ void A_SpawnFreshCopy(mobj_t *actor) { mobj_t *newObject; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SpawnFreshCopy", actor)) return; -#endif newObject = P_SpawnMobj(actor->x, actor->y, actor->z, actor->type); newObject->angle = actor->angle; diff --git a/src/p_inter.c b/src/p_inter.c index 9e333ebe2..07b70587b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -288,43 +288,12 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (special->flags & MF_BOSS && special->flags2 & MF2_FRET) return; -#ifdef HAVE_BLUA if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special)) return; -#endif if (special->flags & MF_BOSS) { - /*if (special->type == MT_BLACKEGGMAN) - { - P_DamageMobj(toucher, special, special, 1); // ouch - return; - } - - if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) - || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) - || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? - { - if (P_MobjFlip(toucher)*toucher->momz < 0) - toucher->momz = -toucher->momz; - toucher->momx = -toucher->momx; - toucher->momy = -toucher->momy; - P_DamageMobj(special, toucher, toucher, 1); - } - else if (((toucher->z < special->z && !(toucher->eflags & MFE_VERTICALFLIP)) - || (toucher->z + toucher->height > special->z + special->height && (toucher->eflags & MFE_VERTICALFLIP))) - && player->charability == CA_FLY - && (player->powers[pw_tailsfly] - || (toucher->state >= &states[S_PLAY_SPC1] && toucher->state <= &states[S_PLAY_SPC4]))) // Tails can shred stuff with his propeller. - { - toucher->momz = -toucher->momz/2; - - P_DamageMobj(special, toucher, toucher, 1); - } - // SRB2kart - Removed: No more fly states - else*/ - P_DamageMobj(toucher, special, special, 1); - + P_DamageMobj(toucher, special, special, 1); return; } else if ((special->flags & MF_ENEMY) && !(special->flags & MF_MISSILE) @@ -2163,10 +2132,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); target->health = 0; // This makes it easy to check if something's dead elsewhere. -#ifdef HAVE_BLUA if (LUAh_MobjDeath(target, inflictor, source) || P_MobjWasRemoved(target)) return; -#endif // SRB2kart // I wish I knew a better way to do this @@ -3129,11 +3096,7 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) { player_t *player; -#ifdef HAVE_BLUA boolean force = false; -#else - static const boolean force = false; -#endif if (objectplacing) return false; @@ -3153,7 +3116,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; } -#ifdef HAVE_BLUA // Everything above here can't be forced. if (!metalrecording) { @@ -3165,7 +3127,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da else if (shouldForce == 2) return false; } -#endif if (!force) { @@ -3199,10 +3160,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (!force && target->fuse) // Invincible return false; -#ifdef HAVE_BLUA if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target)) return true; -#endif if (target->health > 1) { @@ -3227,21 +3186,17 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (!force && target->flags2 & MF2_FRET) // Currently flashing from being hit return false; -#ifdef HAVE_BLUA if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target)) return true; -#endif if (target->health > 1) target->flags2 |= MF2_FRET; } -#ifdef HAVE_BLUA else if (target->flags & MF_ENEMY) { if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target)) return true; } -#endif player = target->player; @@ -3267,18 +3222,16 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da || (G_GametypeHasTeams() && target->player->ctfteam == source->player->ctfteam))) return false; // Don't run eachother over in special stages and team games and such } -#ifdef HAVE_BLUA + if (LUAh_MobjDamage(target, inflictor, source, damage)) return true; -#endif + P_NiGHTSDamage(target, source); // -5s :( return true; } -#ifdef HAVE_BLUA // Add this back here for ACTUAL NORMAL DAMAGE. The funny shit is that the player is barely ever "actually" damaged. if (LUAh_MobjDamage(target, inflictor, source, damage)) return true; -#endif if (!force && inflictor && (inflictor->flags & MF_FIRE)) { @@ -3341,72 +3294,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da } return true; } - /* // SRB2kart - don't need these - else if (metalrecording) - { - if (!inflictor) - inflictor = source; - if (inflictor && inflictor->flags & MF_ENEMY) - { // Metal Sonic destroy enemy !! - P_KillMobj(inflictor, NULL, target); - return false; - } - else if (inflictor && inflictor->flags & MF_MISSILE) - return false; // Metal Sonic walk through flame !! - else - { // Oh no! Metal Sonic is hit !! - P_ShieldDamage(player, inflictor, source, damage); - return true; - } - } - else if (player->powers[pw_invulnerability] || player->powers[pw_flashing] // ignore bouncing & such in invulnerability - || (player->powers[pw_super] && !(ALL7EMERALDS(player->powers[pw_emeralds]) && inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player)))) - { - if (force || (inflictor && (inflictor->flags & MF_MISSILE) - && (inflictor->flags2 & MF2_SUPERFIRE) - && player->powers[pw_super])) - { -#ifdef HAVE_BLUA - if (!LUAh_MobjDamage(target, inflictor, source, damage)) -#endif - P_SuperDamage(player, inflictor, source, damage); - return true; - } - else - return false; - } -#ifdef HAVE_BLUA - else if (LUAh_MobjDamage(target, inflictor, source, damage)) - return true; -#endif - else if (!player->powers[pw_super] && (player->powers[pw_shield] || player->bot)) //If One-Hit Shield - { - P_ShieldDamage(player, inflictor, source, damage); - damage = 0; - } - else if (player->mo->health > 1) // No shield but have rings. - { - damage = player->mo->health - 1; - P_RingDamage(player, inflictor, source, damage); - } - else // No shield, no rings, no invincibility. - { - // To reduce griefing potential, don't allow players to be killed - // by friendly fire. Spilling their rings and other items is enough. - if (force || !(G_GametypeHasTeams() - && source && source->player && (source->player->ctfteam == player->ctfteam) - && cv_friendlyfire.value)) - { - damage = 1; - P_KillPlayer(player, source, damage); - } - else - { - damage = 0; - P_ShieldDamage(player, inflictor, source, damage); - } - } - */ if (inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player) && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) { diff --git a/src/p_map.c b/src/p_map.c index 3942122cc..3372fe088 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -596,7 +596,6 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; // the line doesn't cross between either pair of opposite corners } -#ifdef HAVE_BLUA { UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) @@ -615,7 +614,6 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (shouldCollide == 2) return true; // force no collide } -#endif // When solid spikes move, assume they just popped up and teleport things on top of them to hurt. if (tmthing->type == MT_SPIKE && tmthing->flags & MF_SOLID) diff --git a/src/p_mobj.c b/src/p_mobj.c index 5ad802f92..1bb709970 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -63,9 +63,8 @@ void P_RunCachedActions(void) { var1 = states[ac->statenum].var1; var2 = states[ac->statenum].var2; -#ifdef HAVE_BLUA astate = &states[ac->statenum]; -#endif + if (ac->mobj && !P_MobjWasRemoved(ac->mobj)) // just in case... states[ac->statenum].action.acp1(ac->mobj); next = ac->next; @@ -220,9 +219,8 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif + st->action.acp1(mobj); // woah. a player was removed by an action. @@ -288,9 +286,8 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif + st->action.acp1(mobj); if (P_MobjWasRemoved(mobj)) return false; @@ -6414,12 +6411,12 @@ void P_MobjThinker(mobj_t *mobj) // Special thinker for scenery objects if (mobj->flags & MF_SCENERY) { -#ifdef HAVE_BLUA if (LUAh_MobjThinker(mobj)) return; + if (P_MobjWasRemoved(mobj)) return; -#endif + switch (mobj->type) { case MT_HOOP: @@ -7120,10 +7117,8 @@ void P_MobjThinker(mobj_t *mobj) mobj->fuse--; if (!mobj->fuse) { -#ifdef HAVE_BLUA if (!LUAh_MobjFuse(mobj)) -#endif - P_RemoveMobj(mobj); + P_RemoveMobj(mobj); return; } } @@ -7134,7 +7129,6 @@ void P_MobjThinker(mobj_t *mobj) return; } -#ifdef HAVE_BLUA // Check for a Lua thinker first if (!mobj->player) { @@ -7148,7 +7142,7 @@ void P_MobjThinker(mobj_t *mobj) if (P_MobjWasRemoved(mobj)) return; } -#endif + // if it's pushable, or if it would be pushable other than temporary disablement, use the // separate thinker if (mobj->flags & MF_PUSHABLE || (mobj->info->flags & MF_PUSHABLE && mobj->fuse)) @@ -7166,7 +7160,6 @@ void P_MobjThinker(mobj_t *mobj) } else if (mobj->flags & MF_BOSS) { -#ifdef HAVE_BLUA if (LUAh_BossThinker(mobj)) { if (P_MobjWasRemoved(mobj)) @@ -7175,23 +7168,13 @@ void P_MobjThinker(mobj_t *mobj) else if (P_MobjWasRemoved(mobj)) return; else -#endif switch (mobj->type) { case MT_EGGMOBILE: if (mobj->health < mobj->info->damage+1 && leveltime & 1 && mobj->health > 0) P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMOKE); if (mobj->flags2 & MF2_SKULLFLY) -#if 1 P_SpawnGhostMobj(mobj); -#else - { - mobj_t *spawnmobj; - spawnmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->info->painchance); - P_SetTarget(&spawnmobj->target, mobj); - spawnmobj->color = SKINCOLOR_GREY; - } -#endif P_Boss1Thinker(mobj); break; case MT_EGGMOBILE2: @@ -9141,9 +9124,7 @@ void P_MobjThinker(mobj_t *mobj) fixed_t x, y, z; mobj_t *flagmo, *newmobj; -#ifdef HAVE_BLUA if (!LUAh_MobjFuse(mobj) && !P_MobjWasRemoved(mobj)) -#endif switch (mobj->type) { // gargoyle and snowman handled in P_PushableThinker, not here @@ -9730,7 +9711,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->colorized = false; -#ifdef HAVE_BLUA // DANGER! This can cause P_SpawnMobj to return NULL! // Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks! if (LUAh_MobjSpawn(mobj)) @@ -9741,7 +9721,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) else if (P_MobjWasRemoved(mobj)) return NULL; else -#endif switch (mobj->type) { case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: @@ -10063,9 +10042,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif + st->action.acp1(mobj); // DANGER! This can cause P_SpawnMobj to return NULL! // Avoid using MF_RUNSPAWNFUNC on mobjs whose spawn state expects target or tracer to already be set! @@ -10178,9 +10156,8 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif + st->action.acp1(mobj); // DANGER! This is the ONLY way for P_SpawnMobj to return NULL! // Avoid using MF_RUNSPAWNFUNC on mobjs whose spawn state expects target or tracer to already be set! @@ -10277,16 +10254,13 @@ size_t iquehead, iquetail; void P_RemoveMobj(mobj_t *mobj) { I_Assert(mobj != NULL); -#ifdef HAVE_BLUA + if (P_MobjWasRemoved(mobj)) return; // something already removing this mobj. mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing. LUAh_MobjRemoved(mobj); mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work. -#else - I_Assert(!P_MobjWasRemoved(mobj)); -#endif // Rings only, please! if (mobj->spawnpoint && diff --git a/src/p_saveg.c b/src/p_saveg.c index dcfcbe765..3658734ba 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3487,10 +3487,8 @@ void P_SaveNetGame(void) P_NetArchiveThinkers(); P_NetArchiveSpecials(); } -#ifdef HAVE_BLUA - LUA_Archive(); -#endif + LUA_Archive(); WRITEUINT8(save_p, 0x1d); // consistency marker } @@ -3531,9 +3529,8 @@ boolean P_LoadNetGame(void) P_RelinkPointers(); P_FinishMobjs(); } -#ifdef HAVE_BLUA + LUA_UnArchive(); -#endif // This is stupid and hacky, but maybe it'll work! P_SetRandSeed(P_GetInitSeed()); diff --git a/src/p_setup.c b/src/p_setup.c index ad2de63c2..749f30c1a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2889,9 +2889,7 @@ boolean P_SetupLevel(boolean skipprecip) I_UpdateNoVsync(); }*/ -#ifdef HAVE_BLUA LUA_InvalidateLevel(); -#endif for (ss = sectors; sectors+numsectors != ss; ss++) { @@ -3306,9 +3304,7 @@ boolean P_SetupLevel(boolean skipprecip) G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); } P_PreTicker(2); -#ifdef HAVE_BLUA LUAh_MapLoad(); -#endif } G_AddMapToBuffer(gamemap-1); diff --git a/src/p_spec.c b/src/p_spec.c index dc2ea796d..3056dcbe5 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3110,14 +3110,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } case 443: // Calls a named Lua function -#ifdef HAVE_BLUA if (line->text) LUAh_LinedefExecute(line, mo, callsec); else CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(line-lines)); -#else - CONS_Alert(CONS_ERROR, "The map is trying to run a Lua script, but this exe was not compiled with Lua support!\n"); -#endif break; case 444: // Earthquake camera diff --git a/src/p_tick.c b/src/p_tick.c index 6bad0f856..183c42a4b 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -254,9 +254,7 @@ void P_RemoveThinkerDelayed(void *pthinker) // void P_RemoveThinker(thinker_t *thinker) { -#ifdef HAVE_BLUA LUA_InvalidateUserdata(thinker); -#endif thinker->function.acp1 = P_RemoveThinkerDelayed; } @@ -661,13 +659,10 @@ void P_Ticker(boolean run) ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; -#ifdef HAVE_BLUA PS_START_TIMING(ps_lua_prethinkframe_time); LUAh_PreThinkFrame(); PS_STOP_TIMING(ps_lua_prethinkframe_time); -#endif - PS_START_TIMING(ps_playerthink_time); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) @@ -679,12 +674,6 @@ void P_Ticker(boolean run) if (!demo.playback) // Don't increment if a demo is playing. totalplaytime++; - /*if (!useNightsSS && G_IsSpecialStage(gamemap)) - P_DoSpecialStageStuff(); - - if (runemeraldmanager) - P_EmeraldManager(); // Power stone mode*/ - if (run) { PS_START_TIMING(ps_thinkertime); @@ -696,11 +685,9 @@ void P_Ticker(boolean run) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); -#ifdef HAVE_BLUA PS_START_TIMING(ps_lua_thinkframe_time); LUAh_ThinkFrame(); PS_STOP_TIMING(ps_lua_thinkframe_time); -#endif } // Run shield positioning @@ -825,13 +812,9 @@ void P_Ticker(boolean run) && server) // Remember: server uses it for mapchange, but EVERYONE ticks down for the animation D_MapChange(gamemap, gametype, encoremode, true, 0, false, false); -#ifdef HAVE_BLUA - PS_START_TIMING(ps_lua_postthinkframe_time); LUAh_PostThinkFrame(); PS_STOP_TIMING(ps_lua_postthinkframe_time); - -#endif } // Always move the camera. @@ -891,9 +874,7 @@ void P_PreTicker(INT32 frames) R_UpdateMobjInterpolators(); -#ifdef HAVE_BLUA LUAh_PreThinkFrame(); -#endif for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) @@ -918,22 +899,15 @@ void P_PreTicker(INT32 frames) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); -#ifdef HAVE_BLUA LUAh_ThinkFrame(); -#endif - // Run shield positioning - //P_RunShields(); P_RunOverlays(); - P_RunShadows(); P_UpdateSpecials(); P_RespawnSpecials(); -#ifdef HAVE_BLUA LUAh_PostThinkFrame(); -#endif R_UpdateLevelInterpolators(); R_UpdateViewInterpolation(); diff --git a/src/p_user.c b/src/p_user.c index e92efcfe4..013a0c8d2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4849,9 +4849,7 @@ void P_PlayerThink(player_t *player) } if (player->playerstate == PST_REBORN) { -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif return; } } @@ -4958,9 +4956,7 @@ void P_PlayerThink(player_t *player) if (player->playerstate == PST_DEAD) { -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif return; } } @@ -5026,9 +5022,7 @@ void P_PlayerThink(player_t *player) else player->mo->flags2 &= ~MF2_SHADOW; P_DeathThink(player); -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif return; } @@ -5193,9 +5187,7 @@ void P_PlayerThink(player_t *player) if (!player->mo) { -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif return; // P_MovePlayer removed player->mo. } @@ -5379,9 +5371,7 @@ void P_PlayerThink(player_t *player) if (rendermode != render_none) DoABarrelRoll(player); -#ifdef HAVE_BLUA LUAh_PlayerThink(player); -#endif } // diff --git a/src/s_sound.c b/src/s_sound.c index a2f81f210..95d939335 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -30,9 +30,7 @@ #include "m_cond.h" // for conditionsets #include "m_menu.h" // bird music stuff -#ifdef HAVE_BLUA #include "lua_hook.h" // MusicChange hook -#endif #ifdef HW3SOUND // 3D Sound Interface @@ -1995,10 +1993,10 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; strncpy(newmusic, mmusic, 7); -#ifdef HAVE_BLUA + if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) return; -#endif + newmusic[6] = 0; // No Music (empty string) diff --git a/src/st_stuff.c b/src/st_stuff.c index b4b4a3d49..6c10d8de0 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -40,11 +40,9 @@ #include "hardware/hw_main.h" #endif -#ifdef HAVE_BLUA #include "lua_hud.h" #include "lua_hudlib_drawlist.h" #include "lua_hook.h" -#endif #include "r_fps.h" @@ -191,9 +189,7 @@ hudinfo_t hudinfo[NUMHUDITEMS] = { 240, 160}, // HUD_LAP }; -#ifdef HAVE_BLUA static huddrawlist_h luahuddrawlist_game; -#endif // variable to stop mayonaka static from flickering consvar_t cv_lessflicker = {"lessflicker", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -471,9 +467,7 @@ void ST_Init(void) ST_LoadGraphics(); -#ifdef HAVE_BLUA luahuddrawlist_game = LUA_HUD_CreateDrawList(); -#endif } // change the status bar too, when pressing F12 while viewing a demo. @@ -490,86 +484,6 @@ void ST_changeDemoView(void) boolean st_overlay; -/* -static INT32 SCZ(INT32 z) -{ - return FixedInt(FixedMul(z<>= 1; - if (stplyr != &players[displayplayers[0]]) - y += vid.height / 2; - } - return y; -} -*/ - -/* -static INT32 STRINGY(INT32 y) -{ - //31/10/99: fixed by Hurdler so it _works_ also in hardware mode - // do not scale to resolution for hardware accelerated - // because these modes always scale by default - if (splitscreen) - { - y >>= 1; - if (stplyr != &players[displayplayers[0]]) - y += BASEVIDHEIGHT / 2; - } - return y; -} -*/ - -/* -static INT32 SPLITFLAGS(INT32 f) -{ - // Pass this V_SNAPTO(TOP|BOTTOM) and it'll trim them to account for splitscreen! -Red - if (splitscreen) - { - if (stplyr != &players[displayplayers[0]]) - f &= ~V_SNAPTOTOP; - else - f &= ~V_SNAPTOBOTTOM; - } - return f; -} -*/ - -/* -static INT32 SCX(INT32 x) -{ - return FixedInt(FixedMul(x<>= 1; - if (stplyr != &players[displayplayers[0]]) - y += vid.height / 2; - } - return FixedInt(FixedDiv(y, vid.fdupy)); -} -#endif - // ========================================================================= // INTERNAL DRAWING // ========================================================================= @@ -584,39 +498,6 @@ static INT32 SCR(INT32 r) #define ST_DrawPadNumFromHudWS(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n, q) #define ST_DrawPatchFromHudWS(h,p) V_DrawScaledPatch(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, p) -/* -// Draw a number, scaled, over the view, maybe with set translucency -// Always draw the number completely since it's overlay -// -// Supports different colors! woo! -static void ST_DrawNightsOverlayNum(INT32 x, INT32 y, INT32 a, - INT32 num, patch_t **numpat, skincolors_t colornum) -{ - INT32 w = SHORT(numpat[0]->width); - const UINT8 *colormap; - - // I want my V_SNAPTOx flags. :< -Red - //a &= V_ALPHAMASK; - - if (colornum == 0) - colormap = colormaps; - else // Uses the player colors. - colormap = R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE); - - I_Assert(num >= 0); // this function does not draw negative numbers - - // draw the number - do - { - x -= w; - V_DrawTranslucentMappedPatch(x, y, a, numpat[num % 10], colormap); - num /= 10; - } while (num); - - // Sorry chum, this function only draws UNSIGNED values! -} -*/ - // Devmode information static void ST_drawDebugInfo(void) { @@ -887,979 +768,6 @@ static void ST_drawLevelTitle(void) V_DrawLevelTitle(ttlnumxpos+12, bary+6, 0, actnum); } -/* -static void ST_drawFirstPersonHUD(void) -{ - player_t *player = stplyr; - patch_t *p = NULL; - UINT16 invulntime = 0; - - if (player->playerstate != PST_LIVE) - return; - - // Graue 06-18-2004: no V_NOSCALESTART, no SCX, no SCY, snap to right - if (player->powers[pw_shield] & SH_FORCE) - { - if ((player->powers[pw_shield] & 0xFF) > 0 || leveltime & 1) - p = forceshield; - } - else switch (player->powers[pw_shield] & SH_NOSTACK) - { - case SH_JUMP: p = jumpshield; break; - case SH_ELEMENTAL: p = watershield; break; - case SH_BOMB: p = bombshield; break; - case SH_ATTRACT: p = ringshield; break; - case SH_PITY: p = pityshield; break; - default: break; - } - - if (p) - { - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24), V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - else - V_DrawScaledPatch(304, 24, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - } - - // pw_flashing just sets the icon to flash no matter what. - invulntime = player->powers[pw_flashing] ? 1 : player->powers[pw_invulnerability]; - if (invulntime > 3*TICRATE || (invulntime && leveltime & 1)) - { - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24) + 14, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, invincibility); - else - V_DrawScaledPatch(304, 24 + 28, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, invincibility); - } - - if (player->powers[pw_sneakers] > 3*TICRATE || (player->powers[pw_sneakers] && leveltime & 1)) - { - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24) + 28, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, sneakers); - else - V_DrawScaledPatch(304, 24 + 56, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, sneakers); - } - - p = NULL; - - // Display the countdown drown numbers! - if ((player->powers[pw_underwater] <= 11*TICRATE + 1 - && player->powers[pw_underwater] >= 10*TICRATE + 1) - || (player->powers[pw_spacetime] <= 11*TICRATE + 1 - && player->powers[pw_spacetime] >= 10*TICRATE + 1)) - { - p = count5; - } - else if ((player->powers[pw_underwater] <= 9*TICRATE + 1 - && player->powers[pw_underwater] >= 8*TICRATE + 1) - || (player->powers[pw_spacetime] <= 9*TICRATE + 1 - && player->powers[pw_spacetime] >= 8*TICRATE + 1)) - { - p = count4; - } - else if ((player->powers[pw_underwater] <= 7*TICRATE + 1 - && player->powers[pw_underwater] >= 6*TICRATE + 1) - || (player->powers[pw_spacetime] <= 7*TICRATE + 1 - && player->powers[pw_spacetime] >= 6*TICRATE + 1)) - { - p = count3; - } - else if ((player->powers[pw_underwater] <= 5*TICRATE + 1 - && player->powers[pw_underwater] >= 4*TICRATE + 1) - || (player->powers[pw_spacetime] <= 5*TICRATE + 1 - && player->powers[pw_spacetime] >= 4*TICRATE + 1)) - { - p = count2; - } - else if ((player->powers[pw_underwater] <= 3*TICRATE + 1 - && player->powers[pw_underwater] >= 2*TICRATE + 1) - || (player->powers[pw_spacetime] <= 3*TICRATE + 1 - && player->powers[pw_spacetime] >= 2*TICRATE + 1)) - { - p = count1; - } - else if ((player->powers[pw_underwater] <= 1*TICRATE + 1 - && player->powers[pw_underwater] > 1) - || (player->powers[pw_spacetime] <= 1*TICRATE + 1 - && player->powers[pw_spacetime] > 1)) - { - p = count0; - } - - if (p) - V_DrawScaledPatch(SCX((BASEVIDWIDTH/2) - (SHORT(p->width)/2) + SHORT(p->leftoffset)), SCY(60 - SHORT(p->topoffset)), - V_NOSCALESTART|V_OFFSET|V_TRANSLUCENT, p); -} -*/ - -/* -// [21:42] <+Rob> Beige - Lavender - Steel Blue - Peach - Orange - Purple - Silver - Yellow - Pink - Red - Blue - Green - Cyan - Gold -static skincolors_t linkColor[14] = -{SKINCOLOR_BEIGE, SKINCOLOR_LAVENDER, SKINCOLOR_STEEL, SKINCOLOR_PEACH, SKINCOLOR_ORANGE, - SKINCOLOR_PURPLE, SKINCOLOR_SILVER, SKINCOLOR_SUPER4, SKINCOLOR_PINK, SKINCOLOR_RED, - SKINCOLOR_BLUE, SKINCOLOR_GREEN, SKINCOLOR_CYAN, SKINCOLOR_GOLD}; - -static void ST_drawNightsRecords(void) -{ - INT32 aflag = 0; - - if (!stplyr->texttimer) - return; - - if (stplyr->texttimer < TICRATE/2) - aflag = (9 - 9*stplyr->texttimer/(TICRATE/2)) << V_ALPHASHIFT; - - // A "Bonus Time Start" by any other name... - if (stplyr->textvar == 1) - { - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(52), V_GREENMAP|aflag, M_GetText("GET TO THE GOAL!")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60), aflag, M_GetText("SCORE MULTIPLIER START!")); - - if (stplyr->finishedtime) - { - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(140), aflag, "TIME:"); - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(148), aflag, "BONUS:"); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(140), V_ORANGEMAP|aflag, va("%d", (stplyr->startedtime - stplyr->finishedtime)/TICRATE)); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(148), V_ORANGEMAP|aflag, va("%d", (stplyr->finishedtime/TICRATE) * 100)); - } - } - - // Get n [more] Spheres - else if (stplyr->textvar <= 3 && stplyr->textvar >= 2) - { - if (!stplyr->capsule) - return; - - // Yes, this string is an abomination. - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60), aflag, - va(M_GetText("\x80GET\x82 %d\x80 %s%s%s!"), stplyr->capsule->health, - (stplyr->textvar == 3) ? M_GetText("MORE ") : "", - (G_IsSpecialStage(gamemap)) ? "SPHERE" : "RING", - (stplyr->capsule->health > 1) ? "S" : "")); - } - - // End Bonus - else if (stplyr->textvar == 4) - { - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(140), aflag, (G_IsSpecialStage(gamemap)) ? "ORBS:" : "RINGS:"); - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(148), aflag, "BONUS:"); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(140), V_ORANGEMAP|aflag, va("%d", stplyr->finishedrings)); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(148), V_ORANGEMAP|aflag, va("%d", stplyr->finishedrings * 50)); - ST_DrawNightsOverlayNum(BASEVIDWIDTH/2 + 48, STRINGY(160), aflag, stplyr->lastmarescore, nightsnum, SKINCOLOR_STEEL); - - // If new record, say so! - if (!(netgame || multiplayer) && G_GetBestNightsScore(gamemap, stplyr->lastmare + 1) <= stplyr->lastmarescore) - { - if (stplyr->texttimer & 16) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), V_YELLOWMAP|aflag, "* NEW RECORD *"); - } - - if (P_HasGrades(gamemap, stplyr->lastmare + 1)) - { - if (aflag) - V_DrawTranslucentPatch(BASEVIDWIDTH/2 + 60, STRINGY(160), aflag, - ngradeletters[P_GetGrade(stplyr->lastmarescore, gamemap, stplyr->lastmare)]); - else - V_DrawScaledPatch(BASEVIDWIDTH/2 + 60, STRINGY(160), 0, - ngradeletters[P_GetGrade(stplyr->lastmarescore, gamemap, stplyr->lastmare)]); - } - } -} -*/ - -/* -static void ST_drawNiGHTSHUD(void) // SRB2kart - unused. -{ - INT32 origamount; - INT32 minlink = 1; - INT32 total_ringcount; - UINT8 nosshack = 0; - - // When debugging, show "0 Link". - if (cv_debug & DBG_NIGHTSBASIC) - minlink = 0; - - // Cheap hack: don't display when the score is showing (it popping up for a split second when exiting a map is intentional) - if (stplyr->texttimer && stplyr->textvar == 4) - minlink = INT32_MAX; - - if (G_IsSpecialStage(gamemap)) - { // Since special stages share score, time, rings, etc. - // disable splitscreen mode for its HUD. - if (stplyr != &players[displayplayers[0]]) - return; - nosshack = splitscreen; - splitscreen = 0; - } - - // Link drawing - if ( -#ifdef HAVE_BLUA - LUA_HudEnabled(hud_nightslink) && -#endif - stplyr->linkcount > minlink) - { - skincolors_t colornum = linkColor[((stplyr->linkcount-1) / 5) % (sizeof(linkColor) / sizeof(skincolors_t))]; - if (stplyr->powers[pw_nights_linkfreeze]) - colornum = SKINCOLOR_WHITE; - - if (stplyr->linktimer < 2*TICRATE/3) - { - INT32 linktrans = (9 - 9*stplyr->linktimer/(2*TICRATE/3)) << V_ALPHASHIFT; - - if (splitscreen) - { - ST_DrawNightsOverlayNum(256, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT|linktrans, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawTranslucentMappedPatch(264, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT|linktrans, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - else - { - ST_DrawNightsOverlayNum(160, 160, V_SNAPTOBOTTOM|linktrans, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawTranslucentMappedPatch(168, 160, V_SNAPTOBOTTOM|linktrans, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - } - else // normal, fullbright - { -#if 0 // Cool but silly number effect where the previous link number fades away - if (stplyr->linkcount > 2 && stplyr->linktimer > (2*TICRATE) - 9) - { - INT32 offs = 10 - (stplyr->linktimer - (2*TICRATE - 9)); - INT32 ghosttrans = offs << V_ALPHASHIFT; - ST_DrawNightsOverlayNum(160, STRINGY(160+offs), SPLITFLAGS(V_SNAPTOBOTTOM)|ghosttrans, (stplyr->linkcount-2), - nightsnum, colornum); - } -#endif - - if (splitscreen) - { - ST_DrawNightsOverlayNum(256, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawMappedPatch(264, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - else - { - ST_DrawNightsOverlayNum(160, 160, V_SNAPTOBOTTOM, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawMappedPatch(168, 160, V_SNAPTOBOTTOM, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - } - - // Show remaining link time left in debug - if (cv_debug & DBG_NIGHTSBASIC) - V_DrawCenteredString(BASEVIDWIDTH/2, 180, V_SNAPTOBOTTOM, va("End in %d.%02d", stplyr->linktimer/TICRATE, G_TicsToCentiseconds(stplyr->linktimer))); - } - - // Drill meter - if ( -#ifdef HAVE_BLUA - LUA_HudEnabled(hud_nightsdrill) && -#endif - stplyr->pflags & PF_NIGHTSMODE) - { - INT32 locx, locy; - INT32 dfill; - UINT8 fillpatch; - - if (splitscreen || nosshack) - { - locx = 110; - locy = 188; - } - else - { - locx = 16; - locy = 180; - } - - // Use which patch? - if (stplyr->pflags & PF_DRILLING) - fillpatch = (stplyr->drillmeter & 1) + 1; - else - fillpatch = 0; - - if (splitscreen) - { // 11-5-14 Replaced the old hack with a slightly better hack. -Red - V_DrawScaledPatch(locx, STRINGY(locy)-3, SPLITFLAGS(V_SNAPTOBOTTOM)|V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), SPLITFLAGS(V_SNAPTOBOTTOM)|V_HUDTRANS, drillfill[fillpatch]); - } - else if (nosshack) - { // Even dirtier hack-of-a-hack to draw seperate drill meters in splitscreen special stages but nothing else. - splitscreen = nosshack; - V_DrawScaledPatch(locx, STRINGY(locy)-3, V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_HUDTRANS, drillfill[fillpatch]); - stplyr = &players[displayplayers[1]]; - if (stplyr->pflags & PF_DRILLING) - fillpatch = (stplyr->drillmeter & 1) + 1; - else - fillpatch = 0; - V_DrawScaledPatch(locx, STRINGY(locy-3), V_SNAPTOBOTTOM|V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_SNAPTOBOTTOM|V_HUDTRANS, drillfill[fillpatch]); - stplyr = &players[displayplayers[0]]; - splitscreen = 0; - } - else - { // Draw normally. <:3 - V_DrawScaledPatch(locx, locy, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, locy + 3, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS, drillfill[fillpatch]); - } - - // Display actual drill amount and bumper time - if (cv_debug & DBG_NIGHTSBASIC) - { - if (stplyr->bumpertime) - V_DrawString(SCX(locx), SCY(locy - 8), V_NOSCALESTART|V_REDMAP|V_MONOSPACE, va("BUMPER: 0.%02d", G_TicsToCentiseconds(stplyr->bumpertime))); - else - V_DrawString(SCX(locx), SCY(locy - 8), V_NOSCALESTART|V_MONOSPACE, va("Drill: %3d%%", (stplyr->drillmeter*100)/(96*20))); - } - } - - if (gametype == GT_RACE || gametype == GT_COMPETITION) - { - ST_drawScore(); - ST_drawTime(); - return; - } - - // Begin drawing brackets/chip display -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_nightsrings)) - { -#endif - ST_DrawOverlayPatch(SCX(16), SCY(8), nbracket); - if (G_IsSpecialStage(gamemap)) - ST_DrawOverlayPatch(SCX(24), SCY(8) + SCZ(8), nsshud); - else - ST_DrawOverlayPatch(SCX(24), SCY(8) + SCZ(8), nhud[(leveltime/2)%12]); - - if (G_IsSpecialStage(gamemap)) - { - INT32 i; - total_ringcount = 0; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE && players[i].health) - total_ringcount += players[i].health - 1; - } - else - total_ringcount = stplyr->health-1; - - if (stplyr->capsule) - { - INT32 amount; - const INT32 length = 88; - - origamount = stplyr->capsule->spawnpoint->angle; - I_Assert(origamount > 0); // should not happen now - - ST_DrawOverlayPatch(SCX(72), SCY(8), nbracket); - ST_DrawOverlayPatch(SCX(74), SCY(8) + SCZ(4), minicaps); - - if (stplyr->capsule->reactiontime != 0) - { - INT32 r; - const INT32 orblength = 20; - - for (r = 0; r < 5; r++) - { - ST_DrawOverlayPatch(SCX(230 - (7*r)), SCY(144), redstat); - ST_DrawOverlayPatch(SCX(188 - (7*r)), SCY(144), orngstat); - ST_DrawOverlayPatch(SCX(146 - (7*r)), SCY(144), yelstat); - ST_DrawOverlayPatch(SCX(104 - (7*r)), SCY(144), byelstat); - } - - amount = (origamount - stplyr->capsule->health); - amount = (amount * orblength)/origamount; - - if (amount > 0) - { - INT32 t; - - // Fill up the bar with blue orbs... in reverse! (yuck) - for (r = amount; r > 0; r--) - { - t = r; - - if (r > 15) ++t; - if (r > 10) ++t; - if (r > 5) ++t; - - ST_DrawOverlayPatch(SCX(69 + (7*t)), SCY(144), bluestat); - } - } - } - else - { - INT32 cfill; - - // Lil' white box! - V_DrawScaledPatch(15, STRINGY(8) + 34, V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulebar); - - amount = (origamount - stplyr->capsule->health); - amount = (amount * length)/origamount; - - for (cfill = 0; cfill < amount && cfill < 88; ++cfill) - V_DrawScaledPatch(15 + cfill + 1, STRINGY(8) + 35, V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulefill); - } - - if (total_ringcount >= stplyr->capsule->health) - ST_DrawOverlayPatch(SCX(40), SCY(8) + SCZ(5), nredar[leveltime%8]); - else - ST_DrawOverlayPatch(SCX(40), SCY(8) + SCZ(5), narrow[(leveltime/2)%8]); - } - else - ST_DrawOverlayPatch(SCX(40), SCY(8) + SCZ(5), narrow[8]); - - if (total_ringcount >= 100) - ST_DrawOverlayNum((total_ringcount >= 1000) ? SCX(76) : SCX(72), SCY(8) + SCZ(11), total_ringcount); - else - ST_DrawOverlayNum(SCX(68), SCY(8) + SCZ(11), total_ringcount); -#ifdef HAVE_BLUA - } -#endif - - // Score - if (!stplyr->exiting -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_nightsscore) -#endif - ) - { - ST_DrawNightsOverlayNum(304, STRINGY(16), SPLITFLAGS(V_SNAPTOTOP)|V_SNAPTORIGHT, stplyr->marescore, nightsnum, SKINCOLOR_STEEL); - } - - if (!stplyr->exiting -#ifdef HAVE_BLUA - // TODO give this its own section for Lua - && LUA_HudEnabled(hud_nightsscore) -#endif - ) - { - if (modeattacking == ATTACKING_NIGHTS) - { - INT32 maretime = max(stplyr->realtime - stplyr->marebegunat, 0); - fixed_t cornerx = vid.width, cornery = vid.height-SCZ(20); - -#define ASSISHHUDFIX(n) (n*vid.dupx) - ST_DrawOverlayPatch(cornerx-ASSISHHUDFIX(22), cornery, W_CachePatchName("NGRTIMER", PU_HUDGFX)); - ST_DrawPaddedOverlayNum(cornerx-ASSISHHUDFIX(22), cornery, G_TicsToCentiseconds(maretime), 2); - ST_DrawOverlayPatch(cornerx-ASSISHHUDFIX(46), cornery, sboperiod); - if (maretime < 60*TICRATE) - ST_DrawOverlayNum(cornerx-ASSISHHUDFIX(46), cornery, G_TicsToSeconds(maretime)); - else - { - ST_DrawPaddedOverlayNum(cornerx-ASSISHHUDFIX(46), cornery, G_TicsToSeconds(maretime), 2); - ST_DrawOverlayPatch(cornerx-ASSISHHUDFIX(70), cornery, sbocolon); - ST_DrawOverlayNum(cornerx-ASSISHHUDFIX(70), cornery, G_TicsToMinutes(maretime, true)); - } - } -#undef ASSISHHUDFIX - } - - // Ideya time remaining - if (!stplyr->exiting && stplyr->nightstime > 0 -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_nightstime) -#endif - ) - { - INT32 realnightstime = stplyr->nightstime/TICRATE; - INT32 numbersize; - - if (G_IsSpecialStage(gamemap)) - { - tic_t lowest_time = stplyr->nightstime; - INT32 i; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE && players[i].nightstime < lowest_time) - lowest_time = players[i].nightstime; - realnightstime = lowest_time/TICRATE; - } - - if (stplyr->powers[pw_flashing] > TICRATE ) // was hit - { - UINT16 flashingLeft = stplyr->powers[pw_flashing]-(TICRATE); - if (flashingLeft < TICRATE/2) // Start fading out - { - UINT32 fadingFlag = (9 - 9*flashingLeft/(TICRATE/2)) << V_ALPHASHIFT; - V_DrawTranslucentPatch(SCX(160 - (minus5sec->width/2)), SCY(28), V_NOSCALESTART|fadingFlag, minus5sec); - } - else - V_DrawScaledPatch(SCX(160 - (minus5sec->width/2)), SCY(28), V_NOSCALESTART, minus5sec); - } - - if (realnightstime < 10) - numbersize = 16/2; - else if (realnightstime < 100) - numbersize = 32/2; - else - numbersize = 48/2; - - if (realnightstime < 10) - ST_DrawNightsOverlayNum(160 + numbersize, STRINGY(12), SPLITFLAGS(V_SNAPTOTOP), realnightstime, - nightsnum, SKINCOLOR_RED); - else - ST_DrawNightsOverlayNum(160 + numbersize, STRINGY(12), SPLITFLAGS(V_SNAPTOTOP), realnightstime, - nightsnum, SKINCOLOR_SUPER4); - - // Show exact time in debug - if (cv_debug & DBG_NIGHTSBASIC) - V_DrawString(160 + numbersize + 8, 24, V_SNAPTOTOP|((realnightstime < 10) ? V_REDMAP : V_YELLOWMAP), va("%02d", G_TicsToCentiseconds(stplyr->nightstime))); - } - - // Show pickup durations - if (cv_debug & DBG_NIGHTSBASIC) - { - UINT16 pwr; - - if (stplyr->powers[pw_nights_superloop]) - { - pwr = stplyr->powers[pw_nights_superloop]; - V_DrawSmallScaledPatch(SCX(110), SCY(44), V_NOSCALESTART, W_CachePatchName("NPRUA0",PU_CACHE)); - V_DrawThinString(SCX(106), SCY(52), V_NOSCALESTART|V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); - } - - if (stplyr->powers[pw_nights_helper]) - { - pwr = stplyr->powers[pw_nights_helper]; - V_DrawSmallScaledPatch(SCX(150), SCY(44), V_NOSCALESTART, W_CachePatchName("NPRUC0",PU_CACHE)); - V_DrawThinString(SCX(146), SCY(52), V_NOSCALESTART|V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); - } - - if (stplyr->powers[pw_nights_linkfreeze]) - { - pwr = stplyr->powers[pw_nights_linkfreeze]; - V_DrawSmallScaledPatch(SCX(190), SCY(44), V_NOSCALESTART, W_CachePatchName("NPRUE0",PU_CACHE)); - V_DrawThinString(SCX(186), SCY(52), V_NOSCALESTART|V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); - } - } - - // Records/extra text -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_nightsrecords)) -#endif - ST_drawNightsRecords(); - - splitscreen = nosshack; -} -*/ - -/* -static void ST_drawWeaponRing(powertype_t weapon, INT32 rwflag, INT32 wepflag, INT32 xoffs, patch_t *pat) -{ - INT32 txtflags = 0, patflags = 0; - - if (stplyr->powers[weapon]) - { - if (stplyr->powers[weapon] >= rw_maximums[wepflag]) - txtflags |= V_YELLOWMAP; - - if (weapon == pw_infinityring - || (stplyr->ringweapons & rwflag && stplyr->health > 1)) - txtflags |= V_20TRANS; - else - { - txtflags |= V_TRANSLUCENT; - patflags = V_80TRANS; - } - - V_DrawScaledPatch(8 + xoffs, STRINGY(162), V_SNAPTOLEFT|patflags, pat); - - if (stplyr->powers[weapon] > 99) - V_DrawThinString(8 + xoffs + 1, STRINGY(162), V_SNAPTOLEFT|txtflags, va("%d", stplyr->powers[weapon])); - else - V_DrawString(8 + xoffs, STRINGY(162), V_SNAPTOLEFT|txtflags, va("%d", stplyr->powers[weapon])); - - if (stplyr->currentweapon == wepflag) - V_DrawScaledPatch(6 + xoffs, STRINGY(162 - (splitscreen ? 4 : 2)), V_SNAPTOLEFT, curweapon); - } - else if (stplyr->ringweapons & rwflag) - V_DrawScaledPatch(8 + xoffs, STRINGY(162), V_SNAPTOLEFT|V_TRANSLUCENT, pat); -} -*/ - -/* -static void ST_drawMatchHUD(void) // SRB2kart - unused. -{ - INT32 offset = (BASEVIDWIDTH / 2) - (NUM_WEAPONS * 10); - - if (!G_BattleGametype()) - return; - - if (G_TagGametype() && !(stplyr->pflags & PF_TAGIT)) - return; - -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_weaponrings)) { -#endif - - if (stplyr->powers[pw_infinityring]) - ST_drawWeaponRing(pw_infinityring, 0, 0, offset, infinityring); - else if (stplyr->health > 1) - V_DrawScaledPatch(8 + offset, STRINGY(162), V_SNAPTOLEFT, normring); - else - V_DrawTranslucentPatch(8 + offset, STRINGY(162), V_SNAPTOLEFT|V_80TRANS, normring); - - if (!stplyr->currentweapon) - V_DrawScaledPatch(6 + offset, STRINGY(162 - (splitscreen ? 4 : 2)), V_SNAPTOLEFT, curweapon); - - offset += 20; - ST_drawWeaponRing(pw_automaticring, RW_AUTO, WEP_AUTO, offset, autoring); - offset += 20; - ST_drawWeaponRing(pw_bouncering, RW_BOUNCE, WEP_BOUNCE, offset, bouncering); - offset += 20; - ST_drawWeaponRing(pw_scatterring, RW_SCATTER, WEP_SCATTER, offset, scatterring); - offset += 20; - ST_drawWeaponRing(pw_grenadering, RW_GRENADE, WEP_GRENADE, offset, grenadering); - offset += 20; - ST_drawWeaponRing(pw_explosionring, RW_EXPLODE, WEP_EXPLODE, offset, explosionring); - offset += 20; - ST_drawWeaponRing(pw_railring, RW_RAIL, WEP_RAIL, offset, railring); - -#ifdef HAVE_BLUA - } - - if (LUA_HudEnabled(hud_powerstones)) { -#endif - - // Power Stones collected - offset = 136; // Used for Y now - - if (stplyr->powers[pw_emeralds] & EMERALD1) - V_DrawScaledPatch(28, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[0]); - - offset += 8; - - if (stplyr->powers[pw_emeralds] & EMERALD2) - V_DrawScaledPatch(40, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[1]); - - if (stplyr->powers[pw_emeralds] & EMERALD6) - V_DrawScaledPatch(16, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[5]); - - offset += 16; - - if (stplyr->powers[pw_emeralds] & EMERALD3) - V_DrawScaledPatch(40, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[2]); - - if (stplyr->powers[pw_emeralds] & EMERALD5) - V_DrawScaledPatch(16, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[4]); - - offset += 8; - - if (stplyr->powers[pw_emeralds] & EMERALD4) - V_DrawScaledPatch(28, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[3]); - - offset -= 16; - - if (stplyr->powers[pw_emeralds] & EMERALD7) - V_DrawScaledPatch(28, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[6]); - -#ifdef HAVE_BLUA - } -#endif -} -*/ - -/* -static inline void ST_drawRaceHUD(void) // SRB2kart - unused. -{ - if (leveltime > starttime-(3*TICRATE) && leveltime <= starttime-(2*TICRATE)) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(race3->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, race3); - else if (leveltime > starttime-(2*TICRATE) && leveltime <= starttime-TICRATE) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(race2->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, race2); - else if (leveltime > starttime-TICRATE && leveltime <= starttime) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(race1->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, race1); - else if (leveltime > starttime && leveltime <= starttime+TICRATE) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(racego->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, racego); - - if (circuitmap) - { - if (stplyr->exiting) - V_DrawString(hudinfo[HUD_LAP].x, STRINGY(hudinfo[HUD_LAP].y), V_YELLOWMAP, "FINISHED!"); - else - V_DrawString(hudinfo[HUD_LAP].x, STRINGY(hudinfo[HUD_LAP].y), 0, va("Lap: %u/%d", stplyr->laps+1, cv_numlaps.value)); - } -} -*/ - -/* -static void ST_drawTagHUD(void) // SRB2kart - unused. -{ - char pstime[33] = ""; - char pstext[33] = ""; - - // Figure out what we're going to print. - if (leveltime < hidetime * TICRATE) //during the hide time, the seeker and hiders have different messages on their HUD. - { - if (hidetime) - sprintf(pstime, "%d", (hidetime - leveltime/TICRATE)); //hide time is in seconds, not tics. - - if (stplyr->pflags & PF_TAGIT && !stplyr->spectator) - sprintf(pstext, "%s", M_GetText("WAITING FOR PLAYERS TO HIDE...")); - else - { - if (!stplyr->spectator) //spectators get a generic HUD message rather than a gametype specific one. - { - if (gametype == GT_HIDEANDSEEK) //hide and seek. - sprintf(pstext, "%s", M_GetText("HIDE BEFORE TIME RUNS OUT!")); - else //default - sprintf(pstext, "%s", M_GetText("FLEE BEFORE YOU ARE HUNTED!")); - } - else - sprintf(pstext, "%s", M_GetText("HIDE TIME REMAINING:")); - } - } - else - { - if (cv_timelimit.value && timelimitintics >= leveltime) - sprintf(pstime, "%d", (timelimitintics-leveltime)/TICRATE); - - if (stplyr->pflags & PF_TAGIT) - sprintf(pstext, "%s", M_GetText("YOU'RE IT!")); - else - { - if (cv_timelimit.value) - sprintf(pstext, "%s", M_GetText("TIME REMAINING:")); - else //Since having no hud message in tag is not characteristic: - sprintf(pstext, "%s", M_GetText("NO TIME LIMIT")); - } - } - - // Print the stuff. - if (pstext[0]) - { - if (splitscreen) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(168), 0, pstext); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), 0, pstext); - } - if (pstime[0]) - { - if (splitscreen) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), 0, pstime); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(192), 0, pstime); - } -} - -static void ST_drawCTFHUD(void) // SRB2kart - unused. -{ - INT32 i; - UINT16 whichflag = 0; - - // Draw the flags - V_DrawSmallScaledPatch(256, (splitscreen) ? STRINGY(160) : STRINGY(176), V_HUDTRANS, rflagico); - V_DrawSmallScaledPatch(288, (splitscreen) ? STRINGY(160) : STRINGY(176), V_HUDTRANS, bflagico); - - for (i = 0; i < MAXPLAYERS; i++) - { - if (players[i].gotflag & GF_REDFLAG) // Red flag isn't at base - V_DrawScaledPatch(256, (splitscreen) ? STRINGY(156) : STRINGY(174), V_HUDTRANS, nonicon); - else if (players[i].gotflag & GF_BLUEFLAG) // Blue flag isn't at base - V_DrawScaledPatch(288, (splitscreen) ? STRINGY(156) : STRINGY(174), V_HUDTRANS, nonicon); - - whichflag |= players[i].gotflag; - if ((whichflag & (GF_REDFLAG|GF_BLUEFLAG)) == (GF_REDFLAG|GF_BLUEFLAG)) - break; // both flags were found, let's stop early - } - - // YOU have a flag. Display a monitor-like icon for it. - if (stplyr->gotflag) - { - patch_t *p = (stplyr->gotflag & GF_REDFLAG) ? gotrflag : gotbflag; - - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24) + 42, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - else - V_DrawScaledPatch(304, 24 + 84, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - } - - // Display a countdown timer showing how much time left until the flag your team dropped returns to base. - { - char timeleft[33]; - if (redflag && redflag->fuse > 1) - { - sprintf(timeleft, "%u", (redflag->fuse / TICRATE)); - V_DrawCenteredString(268, STRINGY(184), V_YELLOWMAP|V_HUDTRANS, timeleft); - } - - if (blueflag && blueflag->fuse > 1) - { - sprintf(timeleft, "%u", (blueflag->fuse / TICRATE)); - V_DrawCenteredString(300, STRINGY(184), V_YELLOWMAP|V_HUDTRANS, timeleft); - } - } -} -*/ - -// Draws "Red Team", "Blue Team", or "Spectator" for team gametypes. -/* -static inline void ST_drawTeamName(void) // SRB2kart - unused. -{ - if (stplyr->ctfteam == 1) - V_DrawString(256, splitscreen ? STRINGY(184) : STRINGY(192), V_HUDTRANSHALF, "RED TEAM"); - else if (stplyr->ctfteam == 2) - V_DrawString(248, splitscreen ? STRINGY(184) : STRINGY(192), V_HUDTRANSHALF, "BLUE TEAM"); - else - V_DrawString(244, splitscreen ? STRINGY(184) : STRINGY(192), V_HUDTRANSHALF, "SPECTATOR"); -} -*/ - -/* -static void ST_drawSpecialStageHUD(void) // SRB2kart - unused. -{ - if (totalrings > 0) - ST_DrawNumFromHudWS(HUD_SS_TOTALRINGS, totalrings); - - if (leveltime < 5*TICRATE && totalrings > 0) - { - ST_DrawPatchFromHud(HUD_GETRINGS, getall); - ST_DrawNumFromHud(HUD_GETRINGSNUM, totalrings); - } - - if (sstimer) - { - V_DrawString(hudinfo[HUD_TIMELEFT].x, STRINGY(hudinfo[HUD_TIMELEFT].y), V_HUDTRANS, M_GetText("TIME LEFT")); - ST_DrawNumFromHud(HUD_TIMELEFTNUM, sstimer/TICRATE); - } - else - ST_DrawPatchFromHud(HUD_TIMEUP, timeup); -} -*/ - -/* -static INT32 ST_drawEmeraldHuntIcon(mobj_t *hunt, patch_t **patches, INT32 offset) -{ - INT32 interval, i; - UINT32 dist = ((UINT32)P_AproxDistance(P_AproxDistance(stplyr->mo->x - hunt->x, stplyr->mo->y - hunt->y), stplyr->mo->z - hunt->z))>>FRACBITS; - - if (dist < 128) - { - i = 5; - interval = 5; - } - else if (dist < 512) - { - i = 4; - interval = 10; - } - else if (dist < 1024) - { - i = 3; - interval = 20; - } - else if (dist < 2048) - { - i = 2; - interval = 30; - } - else if (dist < 3072) - { - i = 1; - interval = 35; - } - else - { - i = 0; - interval = 0; - } - - V_DrawScaledPatch(hudinfo[HUD_HUNTPICS].x+offset, STRINGY(hudinfo[HUD_HUNTPICS].y), V_HUDTRANS, patches[i]); - return interval; -} -*/ - -/* -// Separated a few things to stop the SOUND EFFECTS BLARING UGH SHUT UP AAAA -static void ST_doHuntIconsAndSound(void) // SRB2kart - unused. -{ - INT32 interval = 0, newinterval = 0; - - if (hunt1 && hunt1->health) - interval = ST_drawEmeraldHuntIcon(hunt1, hunthoming, -20); - - if (hunt2 && hunt2->health) - { - newinterval = ST_drawEmeraldHuntIcon(hunt2, hunthoming, 0); - if (newinterval && (!interval || newinterval < interval)) - interval = newinterval; - } - - if (hunt3 && hunt3->health) - { - newinterval = ST_drawEmeraldHuntIcon(hunt3, hunthoming, 20); - if (newinterval && (!interval || newinterval < interval)) - interval = newinterval; - } - - if (!(P_AutoPause() || paused) && interval > 0 && leveltime && leveltime % interval == 0) - S_StartSound(NULL, sfx_emfind); -} - -static void ST_doItemFinderIconsAndSound(void) // SRB2kart - unused. -{ - INT32 emblems[16]; - thinker_t *th; - mobj_t *mo2; - - UINT8 stemblems = 0, stunfound = 0; - INT32 i; - INT32 interval = 0, newinterval = 0; - INT32 soffset; - - for (i = 0; i < numemblems; ++i) - { - if (emblemlocations[i].type > ET_SKIN || emblemlocations[i].level != gamemap) - continue; - - emblems[stemblems++] = i; - - if (!emblemlocations[i].collected) - ++stunfound; - - if (stemblems >= 16) - break; - } - // Found all/none exist? Don't waste our time - if (!stunfound) - return; - - // Scan thinkers to find emblem mobj with these ids - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - mo2 = (mobj_t *)th; - - if (mo2->type == MT_EMBLEM) - { - if (!(mo2->flags & MF_SPECIAL)) - continue; - - for (i = 0; i < stemblems; ++i) - { - if (mo2->health == emblems[i]+1) - { - soffset = (i * 20) - ((stemblems-1) * 10); - - newinterval = ST_drawEmeraldHuntIcon(mo2, itemhoming, soffset); - if (newinterval && (!interval || newinterval < interval)) - interval = newinterval; - - break; - } - } - } - } - - if (!(P_AutoPause() || paused) && interval > 0 && leveltime && leveltime % interval == 0) - S_StartSound(NULL, sfx_emfind); -} -*/ - // Draw the status bar overlay, customisable: the user chooses which // kind of information to overlay // @@ -1869,97 +777,13 @@ static void ST_overlayDrawer(void) if (!(hu_showscores && (netgame || multiplayer))) { K_drawKartHUD(); - - /* SRB2kart doesn't need this stuff - if (maptol & TOL_NIGHTS) - ST_drawNiGHTSHUD(); - else - { -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_score)) -#endif - ST_drawScore(); -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_time)) -#endif - ST_drawTime(); -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_rings)) -#endif - ST_drawRings(); - if (G_GametypeUsesLives() -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_lives) -#endif - ) - ST_drawLives(); - } - */ } - // GAME OVER pic - /*if (G_GametypeUsesLives() && stplyr->lives <= 0 && !(hu_showscores && (netgame || multiplayer))) - { - patch_t *p; - - if (racecountdown == 1) - p = timeover; - else - p = sboover; - - V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, STRINGY(BASEVIDHEIGHT/2 - (SHORT(p->height)/2)), 0, p); - }*/ - if (!hu_showscores) // hide the following if TAB is held { // Countdown timer for Race Mode // ...moved to k_kart.c so we can take advantage of the LAPS_Y value - /* SRB2kart doesn't need this stuff, I think - // If you are in overtime, put a big honkin' flashin' message on the screen. - if (G_BattleGametype() && cv_overtime.value - && (leveltime > (timelimitintics + TICRATE/2)) && cv_timelimit.value && (leveltime/TICRATE % 2 == 0)) - { - if (splitscreen) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(168), 0, M_GetText("OVERTIME!")); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), 0, M_GetText("OVERTIME!")); - } - - // Draw Match-related stuff - //\note Match HUD is drawn no matter what gametype. - // ... just not if you're a spectator. - if (!stplyr->spectator) - ST_drawMatchHUD(); - - // Race HUD Stuff - if (gametype == GT_RACE || gametype == GT_COMPETITION) - ST_drawRaceHUD(); - // Tag HUD Stuff - else if (gametype == GT_TAG || gametype == GT_HIDEANDSEEK) - ST_drawTagHUD(); - // CTF HUD Stuff - else if (gametype == GT_CTF) - ST_drawCTFHUD(); - - // Team names for team gametypes - if (G_GametypeHasTeams()) - ST_drawTeamName(); - - // Special Stage HUD - if (!useNightsSS && G_IsSpecialStage(gamemap) && stplyr == &players[displayplayers[0]]) - ST_drawSpecialStageHUD(); - - // Emerald Hunt Indicators - if (cv_itemfinder.value && M_SecretUnlocked(SECRET_ITEMFINDER)) - ST_doItemFinderIconsAndSound(); - else - ST_doHuntIconsAndSound(); - - if (stplyr->powers[pw_gravityboots] > 3*TICRATE || (stplyr->powers[pw_gravityboots] && leveltime & 1)) - V_DrawScaledPatch(hudinfo[HUD_GRAVBOOTSICO].x, STRINGY(hudinfo[HUD_GRAVBOOTSICO].y), V_SNAPTORIGHT, gravboots); - */ - if (cv_showviewpointtext.value) { if (!(multiplayer && demo.playback)) @@ -2007,7 +831,6 @@ static void ST_overlayDrawer(void) }*/ } -#ifdef HAVE_BLUA if (!(netgame || multiplayer) || !hu_showscores) { if (renderisnewtic) @@ -2015,39 +838,14 @@ static void ST_overlayDrawer(void) LUAh_GameHUD(stplyr, luahuddrawlist_game); } } -#endif // HAVE_BLUA // draw level title Tails - if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_stagetitle) -#endif - ) + if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) && LUA_HudEnabled(hud_stagetitle)) ST_drawLevelTitle(); if (!hu_showscores && netgame && !mapreset) { - /*if (G_GametypeUsesLives() && stplyr->lives <= 0 && racecountdown != 1) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), 0, M_GetText("Press Viewpoint Key to watch a player.")); - else if (gametype == GT_HIDEANDSEEK && - (!stplyr->spectator && !(stplyr->pflags & PF_TAGIT)) && (leveltime > hidetime * TICRATE)) - { - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(116), 0, M_GetText("You cannot move while hiding.")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), 0, M_GetText("Press Viewpoint Key to watch a player.")); - } - else if (!G_RaceGametype() && stplyr->playerstate == PST_DEAD && stplyr->lives) //Death overrides spectator text. - { - INT32 respawntime = cv_respawntime.value - stplyr->deadtimer/TICRATE; - if (respawntime > 0 && !stplyr->spectator) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, va(M_GetText("Respawn in: %d second%s."), respawntime, respawntime == 1 ? "" : "s")); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Jump to respawn.")); - } - else*/ if (stplyr->spectator -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_textspectator) -#endif - ) + if (stplyr->spectator && LUA_HudEnabled(hud_textspectator)) { const char *itemtxt = M_GetText("Item - Join Game"); @@ -2213,12 +1011,11 @@ void ST_Drawer(void) if (st_overlay) { -#ifdef HAVE_BLUA if (renderisnewtic) { LUA_HUD_ClearDrawList(luahuddrawlist_game); } -#endif // HAVE_BLUA + // No deadview! for (i = 0; i <= splitscreen; i++) { @@ -2226,9 +1023,7 @@ void ST_Drawer(void) ST_overlayDrawer(); } -#ifdef HAVE_BLUA LUA_HUD_DrawList(luahuddrawlist_game); -#endif // HAVE_BLUA // draw Midnight Channel's overlay ontop if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff. diff --git a/src/w_wad.c b/src/w_wad.c index 1d1b18ccb..bf8537672 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -222,7 +222,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors) static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) { UINT16 posStart, posEnd; -#ifdef HAVE_BLUA + posStart = W_CheckNumForFolderStartPK3("Lua/", wadnum, 0); if (posStart != INT16_MAX) { @@ -230,7 +230,6 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) for (; posStart < posEnd; posStart++) LUA_LoadLump(wadnum, posStart); } -#endif posStart = W_CheckNumForFolderStartPK3("SOC/", wadnum, 0); if (posStart != INT16_MAX) @@ -255,7 +254,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) { UINT16 lump; -#ifdef HAVE_BLUA // Find Lua scripts before SOCs to allow new A_Actions in SOC editing. { lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; @@ -263,7 +261,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) if (memcmp(lump_p->name,"LUA_",4)==0) LUA_LoadLump(wadnum, lump); } -#endif { lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; @@ -770,11 +767,9 @@ UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, b case RET_SOC: lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "OBJCTCFG"); break; -#ifdef HAVE_BLUA case RET_LUA: lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "LUA_INIT"); break; -#endif case RET_PK3: lumpinfo = ResGetLumpsZip(handle, &numlumps); break; @@ -842,11 +837,9 @@ UINT16 W_InitFile(const char *filename, const char *lumpname, UINT16 *wadnump, b CONS_Printf(M_GetText("Loading SOC from %s\n"), wadfile->filename); DEH_LoadDehackedLumpPwad(numwadfiles - 1, 0); break; -#ifdef HAVE_BLUA case RET_LUA: LUA_LoadLump(numwadfiles - 1, 0); break; -#endif default: break; } diff --git a/src/y_inter.c b/src/y_inter.c index ba5f89785..62f585492 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -125,11 +125,8 @@ static INT32 foundAnimVoteWideFrames = 0; intertype_t intertype = int_none; - -#ifdef HAVE_BLUA static huddrawlist_h luahuddrawlist_intermission = NULL; static huddrawlist_h luahuddrawlist_vote = NULL; -#endif static void Y_FollowIntermission(void); static void Y_UnloadData(void); @@ -675,14 +672,12 @@ dotimer: if (cv_scrambleonchange.value && cv_teamscramble.value && (intertic/TICRATE % 2 == 0)) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, hilicol, M_GetText("Teams will be scrambled next round!")); -#ifdef HAVE_BLUA if (renderisnewtic) { LUA_HUD_ClearDrawList(luahuddrawlist_intermission); LUAh_IntermissionHUD(luahuddrawlist_intermission); } LUA_HUD_DrawList(luahuddrawlist_intermission); -#endif } // @@ -710,22 +705,10 @@ void Y_Ticker(void) if (paused || P_AutoPause()) return; -#ifdef HAVE_BLUA LUAh_IntermissionThinker(); -#endif intertic++; - // Team scramble code for team match and CTF. - // Don't do this if we're going to automatically scramble teams next round. - /*if (G_GametypeHasTeams() && cv_teamscramble.value && !cv_scrambleonchange.value && server) - { - // If we run out of time in intermission, the beauty is that - // the P_Ticker() team scramble code will pick it up. - if ((intertic % (TICRATE/7)) == 0) - P_DoTeamscrambling(); - }*/ - // multiplayer uses timer (based on cv_inttime) if (timer) { @@ -944,11 +927,6 @@ void Y_StartIntermission(void) mapvisited[gamemap-1] |= MV_BEATEN; if (ALL7EMERALDS(emeralds)) mapvisited[gamemap-1] |= MV_ALLEMERALDS; - /*if (ultimatemode) - mapvisited[gamemap-1] |= MV_ULTIMATE; - if (data.coop.gotperfbonus) - mapvisited[gamemap-1] |= MV_PERFECT;*/ - if (modeattacking == ATTACKING_RECORD) Y_UpdateRecordReplays(); } @@ -970,10 +948,8 @@ void Y_StartIntermission(void) usebuffer = true; } -#ifdef HAVE_BLUA LUA_HUD_DestroyDrawList(luahuddrawlist_intermission); luahuddrawlist_intermission = LUA_HUD_CreateDrawList(); -#endif } // ====== @@ -1366,14 +1342,12 @@ void Y_VoteDrawer(void) lastvotetic = votetic; -#ifdef HAVE_BLUA if (renderisnewtic) { LUA_HUD_ClearDrawList(luahuddrawlist_vote); LUAh_VoteHUD(luahuddrawlist_vote); } LUA_HUD_DrawList(luahuddrawlist_vote); -#endif } // @@ -1418,9 +1392,7 @@ void Y_VoteTicker(void) if (paused || P_AutoPause() || !voteclient.loaded) return; -#ifdef HAVE_BLUA LUAh_VoteThinker(); -#endif votetic++; @@ -1706,10 +1678,8 @@ void Y_StartVote(void) voteclient.loaded = true; -#ifdef HAVE_BLUA LUA_HUD_DestroyDrawList(luahuddrawlist_vote); luahuddrawlist_vote = LUA_HUD_CreateDrawList(); -#endif } // -- 2.54.0 From 015cf95f4eb0531d13aa85f6702583b558eb6487 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 Feb 2024 22:31:06 +0100 Subject: [PATCH 59/70] stimky ugly --- src/m_menu.c | 67 ++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 922841404..5cf720be7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1516,13 +1516,13 @@ static const char* OP_OpenGLTooltips[] = static menuitem_t OP_SoundOptionsMenu[] = { - {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "SFX", &cv_gamesounds, 10}, + {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "SFX", &cv_gamesounds, 10}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, - NULL, "SFX Volume", &cv_soundvolume, 18}, + NULL, "SFX Volume", &cv_soundvolume, 18}, - {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music", &cv_gamedigimusic, 30}, + {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music", &cv_gamedigimusic, 30}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, - NULL, "Music Volume", &cv_digmusicvolume, 38}, + NULL, "Music Volume", &cv_digmusicvolume, 38}, /* -- :nonnathisshit: {IT_STRING|IT_CVAR, NULL, "MIDI", &cv_gamemidimusic, 50}, @@ -1532,19 +1532,19 @@ static menuitem_t OP_SoundOptionsMenu[] = //{IT_STRING|IT_CALL, NULL, "Restart Audio System", M_RestartAudio, 50}, - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50}, - {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 60}, + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50}, + {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 60}, - {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, - {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, - {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, + {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, + {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, + {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, - {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, - {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, + {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, + {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} }; static const char* OP_SoundTooltips[] = @@ -1571,17 +1571,17 @@ static menuitem_t OP_SoundAdvancedMenu[] = #ifdef HAVE_OPENMPT {IT_HEADER, NULL, "Tracker Module Options", NULL, 10}, - {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 22}, - {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42}, + {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 22}, + {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42}, #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 - {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 62}, + {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 62}, #endif - {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 82}, + {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 82}, #endif - {IT_HEADER, NULL, "Misc", NULL, 105}, + {IT_HEADER, NULL, "Misc", NULL, 105}, - {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 117}, - {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 137}, + {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 117}, + {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 137}, }; static const char* OP_SoundAdvancedTooltips[] = @@ -1604,11 +1604,10 @@ static const char* OP_SoundAdvancedTooltips[] = static menuitem_t OP_DataOptionsMenu[] = { - {IT_STRING | IT_CALL, NULL, "Screenshot Options...", M_ScreenshotOptions, 10}, {IT_STRING | IT_CALL, NULL, "Addon Options...", M_AddonsOptions, 20}, {IT_STRING | IT_SUBMENU, NULL, "Replay Options...", &MISC_ReplayOptionsDef, 30}, - {IT_STRING | IT_SUBMENU, NULL, "Protocol options...", &OP_ProtocolDef, 40}, + {IT_STRING | IT_SUBMENU, NULL, "Protocol options...", &OP_ProtocolDef, 40}, #ifdef HAVE_DISCORDRPC {IT_STRING | IT_SUBMENU, NULL, "Discord Options...", &OP_DiscordOptionsDef, 50}, @@ -1624,21 +1623,21 @@ static menuitem_t OP_ScreenshotOptionsMenu[] = {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 20}, {IT_HEADER, NULL, "Screenshots (F8)", NULL, 50}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 60}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 70}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 80}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 90}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 60}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 70}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 80}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 90}, {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 105}, - {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 115}, + {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 115}, - {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 125}, - {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 135}, + {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 125}, + {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 135}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 125}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 135}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 145}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 155}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 125}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 135}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 145}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 155}, }; enum -- 2.54.0 From 8223ab07e40469753b7f3664c81fefcb6471e93e Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 01:50:35 +0100 Subject: [PATCH 60/70] shader stuffs --- src/hardware/r_opengl/r_opengl.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 8f91d5ed9..55689d976 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -822,6 +822,11 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) EXPORT void HWRAPI(SetShader) (int slot) { + if (slot == SHADER_NONE) + { + UnSetShader(); + return; + } if (gl_allowshaders) { gl_shader_t *next_shader = &gl_shaders[slot]; // the gl_shader_t we are going to switch to @@ -842,21 +847,26 @@ EXPORT void HWRAPI(SetShader) (int slot) return; } + gl_shadersenabled = false; } EXPORT void HWRAPI(UnSetShader) (void) { - gl_shaderstate.current = NULL; - gl_shaderstate.type = 0; - gl_shaderstate.program = 0; + if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed + { + gl_shaderstate.current = NULL; + gl_shaderstate.type = 0; + gl_shaderstate.program = 0; - if (pglUseProgram) - pglUseProgram(0); + if (pglUseProgram) + pglUseProgram(0); + } gl_shadersenabled = false; } + // -----------------+ // SetNoTexture : Disable texture // -----------------+ -- 2.54.0 From 4a1eab5ccd2fb6c689154f455f4d9c9ee66b142a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 01:53:11 +0100 Subject: [PATCH 61/70] more shader stuff --- src/hardware/hw_shaders.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index f9c755b0d..427bd1540 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -439,7 +439,7 @@ void HWR_LoadAllCustomShaders(void) // read every custom shader for (i = 0; i < numwadfiles; i++) - HWR_LoadCustomShadersFromFile(i, (wadfiles[i]->type == RET_PK3)); + HWR_LoadCustomShadersFromFile(i, W_FileHasFolders(wadfiles[i])); } void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) @@ -454,7 +454,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) int i; boolean modified_shaders[NUMSHADERTARGETS] = {0}; - if (!HWR_UseShader()) + if (!gr_shadersavailable) return; lump = HWR_FindShaderDefs(wadnum); -- 2.54.0 From a0ae10018657222441b1ca57a6d2ec9eb69e89a0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:02:03 +0100 Subject: [PATCH 62/70] more stuffs --- src/hardware/r_opengl/r_opengl.c | 72 +++++++++++--------------------- 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 55689d976..3a07860ed 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -8,7 +8,7 @@ // terms of the GNU General Public License, version 2. // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- -/// \file +/// \file r_opengl.c /// \brief OpenGL API for Sonic Robo Blast 2 #if defined (_WIN32) @@ -26,7 +26,7 @@ #include "../../r_local.h" // For rendertimefrac, used for the leveltime shader uniform #include "r_opengl.h" #include "r_vbo.h" - +#include "../hw_shaders.h" #include "../hw_main.h" // Eeeeh not sure is this right way, but it works < sry :c < sry again it had to go :c @@ -674,29 +674,6 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; // -// Generic vertex shader -// - -#define GLSL_FALLBACK_VERTEX_SHADER \ - "void main()\n" \ - "{\n" \ - "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ - "gl_FrontColor = gl_Color;\n" \ - "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ - "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ - "}\0" - -// -// Generic fragment shader -// - -#define GLSL_FALLBACK_FRAGMENT_SHADER \ - "uniform sampler2D tex;\n" \ - "uniform vec4 poly_color;\n" \ - "void main(void) {\n" \ - "gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \ - "}\0" - void SetupGLFunc4(void) { @@ -894,7 +871,7 @@ static void GLPerspective(GLfloat fovy, GLfloat aspect) const GLfloat zNear = NEAR_CLIPPING_PLANE; const GLfloat zFar = FAR_CLIPPING_PLANE; const GLfloat radians = (GLfloat)(fovy / 2.0f * M_PIl / 180.0f); - const GLfloat sine = sin(radians); + const GLfloat sine = (GLfloat)sin(radians); const GLfloat deltaZ = zFar - zNear; GLfloat cotangent; @@ -1666,9 +1643,9 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF if (Surface != NULL) { - UNIFORM_1(shader->uniforms[gluniform_lighting], Surface->LightInfo.light_level, pglUniform1f); - UNIFORM_1(shader->uniforms[gluniform_fade_start], Surface->LightInfo.fade_start, pglUniform1f); - UNIFORM_1(shader->uniforms[gluniform_fade_end], Surface->LightInfo.fade_end, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_lighting], (GLfloat)Surface->LightInfo.light_level, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_fade_start], (GLfloat)Surface->LightInfo.fade_start, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_fade_end], (GLfloat)Surface->LightInfo.fade_end, pglUniform1f); } UNIFORM_1(shader->uniforms[gluniform_leveltime], ((float)shader_leveltime) / TICRATE, pglUniform1f); @@ -1824,31 +1801,32 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD SetBlend(PolyFlags); //TODO: inline (#pragma..) - // PolyColor if (pSurf) { - // If Modulated, mix the surface colour to the texture + // If modulated, mix the surface colour to the texture if (CurrentPolyFlags & PF_Modulated) - { - // Poly color - poly.red = byte2float[pSurf->PolyColor.s.red]; - poly.green = byte2float[pSurf->PolyColor.s.green]; - poly.blue = byte2float[pSurf->PolyColor.s.blue]; - poly.alpha = byte2float[pSurf->PolyColor.s.alpha]; - pglColor4ubv((GLubyte*)&pSurf->PolyColor.s); + + // If the surface is either modulated or colormapped, or both + if (CurrentPolyFlags & (PF_Modulated | PF_ColorMapped)) + { + poly.red = byte2float[pSurf->PolyColor.s.red]; + poly.green = byte2float[pSurf->PolyColor.s.green]; + poly.blue = byte2float[pSurf->PolyColor.s.blue]; + poly.alpha = byte2float[pSurf->PolyColor.s.alpha]; } - // Tint color - tint.red = byte2float[pSurf->TintColor.s.red]; - tint.green = byte2float[pSurf->TintColor.s.green]; - tint.blue = byte2float[pSurf->TintColor.s.blue]; - tint.alpha = byte2float[pSurf->TintColor.s.alpha]; + // Only if the surface is colormapped + if (CurrentPolyFlags & PF_ColorMapped) + { + tint.red = byte2float[pSurf->TintColor.s.red]; + tint.green = byte2float[pSurf->TintColor.s.green]; + tint.blue = byte2float[pSurf->TintColor.s.blue]; + tint.alpha = byte2float[pSurf->TintColor.s.alpha]; - // Fade color - fade.red = byte2float[pSurf->FadeColor.s.red]; - fade.green = byte2float[pSurf->FadeColor.s.green]; - fade.blue = byte2float[pSurf->FadeColor.s.blue]; + fade.red = byte2float[pSurf->FadeColor.s.red]; + fade.green = byte2float[pSurf->FadeColor.s.green]; + fade.blue = byte2float[pSurf->FadeColor.s.blue]; fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded) -- 2.54.0 From f6f5b5caec8022a3ad6b9bd37e7a6ef2d6e04160 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:03:22 +0100 Subject: [PATCH 63/70] a --- src/hardware/r_opengl/r_opengl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 3a07860ed..77a17cb80 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -673,7 +673,6 @@ static void Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRGBAF static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; -// void SetupGLFunc4(void) { @@ -1827,14 +1826,15 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD fade.red = byte2float[pSurf->FadeColor.s.red]; fade.green = byte2float[pSurf->FadeColor.s.green]; fade.blue = byte2float[pSurf->FadeColor.s.blue]; - fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; - - if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded) - { - pglActiveTexture(GL_TEXTURE2); - pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId); - pglActiveTexture(GL_TEXTURE0); - lt_downloaded = pSurf->LightTableId; + fade.alpha = byte2float[pSurf->FadeColor.s.alpha]; + + if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded) + { + pglActiveTexture(GL_TEXTURE2); + pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId); + pglActiveTexture(GL_TEXTURE0); + lt_downloaded = pSurf->LightTableId; + } } } -- 2.54.0 From 8cc71fb13ab66d659cdf5bb7beb8aa9f7b6aca71 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:07:54 +0100 Subject: [PATCH 64/70] e --- src/hardware/r_opengl/r_opengl.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 77a17cb80..1cb3153a4 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -829,15 +829,12 @@ EXPORT void HWRAPI(SetShader) (int slot) EXPORT void HWRAPI(UnSetShader) (void) { - if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed - { - gl_shaderstate.current = NULL; - gl_shaderstate.type = 0; - gl_shaderstate.program = 0; + gl_shaderstate.current = NULL; + gl_shaderstate.type = 0; + gl_shaderstate.program = 0; - if (pglUseProgram) - pglUseProgram(0); - } + if (pglUseProgram) + pglUseProgram(0); gl_shadersenabled = false; } -- 2.54.0 From ef076b457691c012aae07818ea2e692fbc0bb622 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:15:28 +0100 Subject: [PATCH 65/70] unhack palrendering screentex stuff --- src/hardware/r_opengl/r_opengl.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 1cb3153a4..d1e04f331 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -829,12 +829,15 @@ EXPORT void HWRAPI(SetShader) (int slot) EXPORT void HWRAPI(UnSetShader) (void) { - gl_shaderstate.current = NULL; - gl_shaderstate.type = 0; - gl_shaderstate.program = 0; + if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed + { + gl_shaderstate.current = NULL; + gl_shaderstate.type = 0; + gl_shaderstate.program = 0; - if (pglUseProgram) - pglUseProgram(0); + if (pglUseProgram) + pglUseProgram(0); + } gl_shadersenabled = false; } @@ -3253,7 +3256,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int tex, int width, int height) pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); if (HWR_ShouldUsePaletteRendering()) - UnSetShader(); + pglUseProgram(0); tex_downloaded = screenTextures[tex]; } -- 2.54.0 From bfddbcde6dd20973f2246e343153f6f2cd5ae30f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 02:43:53 +0100 Subject: [PATCH 66/70] fix compiler complains those were for coronas code which we dont even have --- src/hardware/r_opengl/r_opengl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index d1e04f331..bb5c1fe3d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1792,7 +1792,7 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) // code that is common between DrawPolygon and DrawIndexedTriangles // DrawScreenTexture also can use this function for fancier screen texture drawing // the corona thing is there too, i have no idea if that stuff works with DrawIndexedTriangles and batching -static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD PolyFlags) +static void PreparePolygon(FSurfaceInfo *pSurf, FBITFIELD PolyFlags) { static GLRGBAFloat poly = {0,0,0,0}; static GLRGBAFloat tint = {0,0,0,0}; @@ -1846,7 +1846,7 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD // -----------------+ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags) { - PreparePolygon(pSurf, pOutVerts, PolyFlags); + PreparePolygon(pSurf, PolyFlags); pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x); pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].s); @@ -1864,7 +1864,7 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray) { - PreparePolygon(pSurf, pOutVerts, PolyFlags); + PreparePolygon(pSurf, PolyFlags); pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x); pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].s); @@ -2946,7 +2946,7 @@ EXPORT void HWRAPI(DrawScreenTexture)(int tex, FSurfaceInfo *surf, FBITFIELD pol pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]); - PreparePolygon(surf, NULL, surf ? polyflags : (PF_NoDepthTest)); + PreparePolygon(surf, surf ? polyflags : (PF_NoDepthTest)); if (!surf) pglColor4ubv(white); -- 2.54.0 From a4f52ebd101d4e4e44e84b3062687ec995680a01 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 21:56:39 +0100 Subject: [PATCH 67/70] move sprite mobj checks first --- src/hardware/hw_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4d379fe85..1fe0c8990 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4198,12 +4198,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) FSurfaceInfo Surf; INT32 shader = SHADER_NONE; - - const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); - if (spr->mobj) - this_scale = FIXED_TO_FLOAT(spr->mobj->scale); - if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); if (!spr->mobj) return; @@ -4217,6 +4211,12 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) return; } + const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); + if (spr->mobj) + this_scale = FIXED_TO_FLOAT(spr->mobj->scale); + if (hires) + this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); + // cache sprite graphics //12/12/99: Hurdler: // OK, I don't change anything for MD2 support because I want to be @@ -4342,7 +4342,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) shader = SHADER_SPRITE; // sprite shader blend |= PF_ColorMapped; } - + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); } } -- 2.54.0 From 46da9bf98bba9a459a40e9bad1e5dc38dc8af5b7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 22:30:25 +0100 Subject: [PATCH 68/70] we have functions for that dont check for slopes everywhere the functions already do it for us anyways --- src/hardware/hw_main.c | 49 ++++++++++-------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1fe0c8990..fdf0bb729 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -236,7 +236,6 @@ static float gr_windowcentery; static float gr_pspritexscale, gr_pspriteyscale; - static seg_t *gr_curline; static side_t *gr_sidedef; static line_t *gr_linedef; @@ -684,10 +683,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc slope = gr_frontsector->c_slope; } - // Set fixedheight to the slope's height from our viewpoint, if we have a slope - if (slope) - fixedheight = P_GetZAt(slope, viewx, viewy); - height = FIXED_TO_FLOAT(fixedheight); // Allocate plane-vertex buffer if we need to @@ -767,7 +762,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc } } - if (angle) // Only needs to be done if there's an altered angle { angle = InvAngle(angle)>>ANGLETOFINESHIFT; @@ -1151,23 +1145,13 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else solid = false; - if (list[i].slope) - { - height = FixedToFloat(P_GetZAt(list[i].slope, v1x, v1y)); - endheight = FixedToFloat(P_GetZAt(list[i].slope, v2x, v2y)); - } - else - height = endheight = FIXED_TO_FLOAT(list[i].height); - + height = FixedToFloat(P_GetLightZAt(&list[i], v1x, v1y)); + endheight = FixedToFloat(P_GetLightZAt(&list[i], v2x, v2y)); + if (solid) { - if (*list[i].caster->b_slope) - { - bheight = FixedToFloat(P_GetZAt(*list[i].caster->b_slope, v1x, v1y)); - endbheight = FixedToFloat(P_GetZAt(*list[i].caster->b_slope, v2x, v2y)); - } - else - bheight = endbheight = FIXED_TO_FLOAT(*list[i].caster->bottomheight); + height = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v1x, v1y)); + endbheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v2x, v2y)); } if (endheight >= endtop && height >= top) @@ -1181,13 +1165,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (i + 1 < sector->numlights) { - if (list[i+1].slope) - { - bheight = FixedToFloat(P_GetZAt(list[i+1].slope, v1x, v1y)); - endbheight = FixedToFloat(P_GetZAt(list[i+1].slope, v2x, v2y)); - } - else - bheight = endbheight = FIXED_TO_FLOAT(list[i+1].height); + bheight = FixedToFloat(P_GetLightZAt(&list[i+1], v1x, v1y)); + endbheight = FixedToFloat(P_GetLightZAt(&list[i+1], v2x, v2y)); } else { @@ -4077,15 +4056,10 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (i + 1 < sector->numlights) { - if (list[i+1].slope) - { - temp = P_GetZAt(list[i+1].slope, v1x, v1y); - bheight = FIXED_TO_FLOAT(temp); - temp = P_GetZAt(list[i+1].slope, v2x, v2y); - endbheight = FIXED_TO_FLOAT(temp); - } - else - bheight = endbheight = FIXED_TO_FLOAT(list[i+1].height); + temp = P_GetLightZAt(&list[i+1], v1x, v1y); + bheight = FIXED_TO_FLOAT(temp); + temp = P_GetLightZAt(&list[i+1], v2x, v2y); + endbheight = FIXED_TO_FLOAT(temp); } else { @@ -4238,7 +4212,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) wallVerts[2].y = wallVerts[3].y = spr->gzt; wallVerts[0].y = wallVerts[1].y = spr->gz; - // make a wall polygon (with 2 triangles), using the floor/ceiling heights, // and the 2d map coords of start/end vertices wallVerts[0].z = wallVerts[3].z = spr->z1; -- 2.54.0 From e211afa9dd89fa13d6e288f0c91a570426660de7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 22:56:26 +0100 Subject: [PATCH 69/70] dont need to check if we dont use it --- src/hardware/hw_main.c | 14 ++++++++++---- src/r_things.c | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fdf0bb729..f3872c488 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3819,8 +3819,10 @@ static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts // uncapped/interpolation interpmobjstate_t interp = {0}; float basey, lowy; + INT32 dist = -1; - INT32 dist = R_QuickCamDist(spr->mobj->x, spr->mobj->y); + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(spr->mobj->x, spr->mobj->y); // do interpolation if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) @@ -4944,10 +4946,11 @@ void HWR_ProjectSprite(mobj_t *thing) UINT8 flip; boolean mirrored = thing->mirrored; boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - + angle_t ang, camang; const boolean papersprite = (thing->frame & FF_PAPERSPRITE); INT32 heightsec, phs; + INT32 dist = -1; fixed_t spr_width, spr_height; fixed_t spr_offset, spr_topoffset; @@ -4964,7 +4967,8 @@ void HWR_ProjectSprite(mobj_t *thing) if (!thing) return; - INT32 dist = R_QuickCamDist(thing->x, thing->y); + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { @@ -5303,11 +5307,13 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) size_t lumpoff; unsigned rot = 0; UINT8 flip; + INT32 dist = -1; if (!thing) return; - INT32 dist = R_QuickCamDist(thing->x, thing->y); + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); // uncapped/interpolation interpmobjstate_t interp = {0}; diff --git a/src/r_things.c b/src/r_things.c index 2d9b880e0..98d2dc53a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1183,12 +1183,17 @@ static void R_ProjectSprite(mobj_t *thing) #endif fixed_t ang_scale = FRACUNIT; + + INT32 dist = -1; + + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); // uncapped/interpolation interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || R_QuickCamDist(thing->x, thing->y) < cv_grmaxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolateMobjState(oldthing, rendertimefrac, &interp); } @@ -1708,11 +1713,16 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) //SoM: 3/17/2000 fixed_t gz ,gzt; + INT32 dist = 1; + + if (cv_grmaxinterpdist.value) + dist = R_QuickCamDist(thing->x, thing->y); + // uncapped/interpolation interpmobjstate_t interp = {0}; // do interpolation - if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || R_QuickCamDist(thing->x, thing->y) < cv_grmaxinterpdist.value)) + if (R_UsingFrameInterpolation() && !paused && (!cv_grmaxinterpdist.value || dist < cv_grmaxinterpdist.value)) { R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp); } -- 2.54.0 From 9f2624021163715b5cff16082c365b0bcd6f6bb2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 Mar 2024 23:36:48 +0100 Subject: [PATCH 70/70] fix this --- src/hardware/hw_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f3872c488..45ad96d12 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3317,8 +3317,8 @@ void HWR_Subsector(size_t num) centerHeight = P_GetFFloorBottomZAt(rover, gr_frontsector->soundorg.x, gr_frontsector->soundorg.y); if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight && - ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + ((viewz < bottomCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { @@ -3361,8 +3361,8 @@ void HWR_Subsector(size_t num) if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight && - ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + ((viewz > topCullHeight && (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES))) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { -- 2.54.0