From 8247f9fc02049b39b78e865a297a62ba5e504756 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 29 Jul 2023 13:30:42 +0300 Subject: [PATCH 1/4] Expose S_StopSoundByNum to lua --- src/lua_baselib.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e59bc2416..5fd813dc5 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1824,6 +1824,14 @@ static int lib_sStopSoundByID(lua_State *L) return 0; } +static int lib_sStopSoundByNum(lua_State *L) +{ + sfxenum_t sound_id = luaL_checkinteger(L, 1); + NOHUD + S_StopSoundByNum(sound_id); + return 0; +} + static int lib_sShowMusicCredit(lua_State *L) { player_t *player = NULL; @@ -3139,6 +3147,7 @@ static luaL_Reg lib[] = { {"S_StartSoundAtVolume",lib_sStartSoundAtVolume}, {"S_StopSound",lib_sStopSound}, {"S_StopSoundByID",lib_sStopSoundByID}, + {"S_StopSoundByNum",lib_sStopSoundByNum}, {"S_ShowMusicCredit",lib_sShowMusicCredit}, {"S_ChangeMusic",lib_sChangeMusic}, {"S_SpeedMusic",lib_sSpeedMusic}, -- 2.54.0 From 6bc1a6c5152df074ee737f1db42a990cd422fe86 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 31 Jul 2023 14:24:46 +0200 Subject: [PATCH 2/4] software ffloorclip cleanup code looks nicer, since i accidentally ported the old deprecated thing, works good now --- src/r_main.c | 2 +- src/r_segs.c | 78 ++++++++++++++++++++++++++-------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 9ed8c4107..cd4c99b69 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -196,7 +196,7 @@ consvar_t cv_flipcam4 = {"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_ffloorclip = {"ffloorclip", "On", CV_SAVE, CV_OnOff, NULL}; +consvar_t cv_ffloorclip = {"ffloorclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_soniccd = {"soniccd", "Off", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowmlook = {"allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showhud = {"showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/r_segs.c b/src/r_segs.c index a3d41a900..e93cbaecb 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -705,7 +705,7 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor) // Polyobjects have no ffloors, and they're handled in the conditional above. if (pfloor->ffloor != NULL) - return (pfloor->ffloor->flags & (FF_TRANSLUCENT|FF_FOG)); + return (pfloor->ffloor->flags & FF_TRANSLUCENT); return false; } @@ -1362,29 +1362,29 @@ static void R_RenderSegLoop (void) if (top_w <= bottom_w) { fftop = (INT16)top_w; - ffbottom = (INT16)bottom_w; + ffbottom = (INT16)bottom_w; - ffloor[i].plane->top[rw_x] = fftop; - ffloor[i].plane->bottom[rw_x] = ffbottom; + ffloor[i].plane->top[rw_x] = fftop; + ffloor[i].plane->bottom[rw_x] = ffbottom; - // Lactozilla: Cull part of the column by the 3D floor if it can't be seen - // "bottom" is the top pixel of the floor column - if (ffbottom >= bottom-1 && R_FFloorCanClip(&ffloor[i]) && !curline->polyseg) + // Lactozilla: Cull part of the column by the 3D floor if it can't be seen + // "bottom" is the top pixel of the floor column + if (ffbottom >= bottom-1 && R_FFloorCanClip(&ffloor[i])) + { + rw_floormarked = true; + floorclip[rw_x] = fftop; + if (yh > fftop) + yh = fftop; + + if (markfloor && floorplane) + floorplane->top[rw_x] = bottom; + + if (rw_silhouette) { - rw_floormarked = true; - floorclip[rw_x] = fftop; - if (yh > fftop) - yh = fftop; - - if (markfloor && floorplane) - floorplane->top[rw_x] = bottom; - - if (rw_silhouette) - { - (*rw_silhouette) |= SIL_BOTTOM; - (*rw_bsilheight) = INT32_MAX; - } + (*rw_silhouette) |= SIL_BOTTOM; + (*rw_bsilheight) = INT32_MAX; } + } } } else if (ffloor[i].height > viewz) @@ -1406,29 +1406,29 @@ static void R_RenderSegLoop (void) if (top_w <= bottom_w) { fftop = (INT16)top_w; - ffbottom = (INT16)bottom_w; + ffbottom = (INT16)bottom_w; - ffloor[i].plane->top[rw_x] = fftop; - ffloor[i].plane->bottom[rw_x] = ffbottom; + ffloor[i].plane->top[rw_x] = fftop; + ffloor[i].plane->bottom[rw_x] = ffbottom; - // Lactozilla: Cull part of the column by the 3D floor if it can't be seen - // "top" is the height of the ceiling column - if (fftop <= top+1 && R_FFloorCanClip(&ffloor[i]) && !curline->polyseg) + // Lactozilla: Cull part of the column by the 3D floor if it can't be seen + // "top" is the height of the ceiling column + if (fftop <= top+1 && R_FFloorCanClip(&ffloor[i])) + { + rw_ceilingmarked = true; + ceilingclip[rw_x] = ffbottom; + if (yl < ffbottom) + yl = ffbottom; + + if (markceiling && ceilingplane) + ceilingplane->bottom[rw_x] = top; + + if (rw_silhouette) { - rw_ceilingmarked = true; - ceilingclip[rw_x] = ffbottom; - if (yl < ffbottom) - yl = ffbottom; - - if (markceiling && ceilingplane) - ceilingplane->bottom[rw_x] = top; - - if (rw_silhouette) - { - (*rw_silhouette) |= SIL_TOP; - (*rw_tsilheight) = INT32_MIN; - } + (*rw_silhouette) |= SIL_TOP; + (*rw_tsilheight) = INT32_MIN; } + } } } } -- 2.54.0 From dbfa2a8852e5e77edce5574d290eef5bd0479404 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 31 Jul 2023 14:25:49 +0200 Subject: [PATCH 3/4] P_RandomFixed should return the same result maybe fixes desynchs between 64bit and 32bit clients see: https://git.do.srb2.org/bird/Kart-Public/-/commit/a7bbc76c7c94c37ea62fe338451f7f4b70487a19 --- src/m_random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_random.c b/src/m_random.c index 3d46f76b7..d9a8cb6b0 100644 --- a/src/m_random.c +++ b/src/m_random.c @@ -114,7 +114,7 @@ fixed_t P_RandomFixedD(const char *rfile, INT32 rline) { CONS_Printf("P_RandomFixed() at: %sp %d\n", rfile, rline); #endif - return __internal_prng__(); + return (INT32)((INT64)__internal_prng__()); } /** Provides a random byte. Distribution is uniform. -- 2.54.0 From 91b140903969d113e836c646761b33129d381b0c Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 31 Jul 2023 14:29:02 +0200 Subject: [PATCH 4/4] Some render bugfixes from HEP client see: https://git.do.srb2.org/haya_/Kart-Public/-/commit/7622b977769061d63b69bcdccb0065d0ca0895e7 --- src/hardware/hw_main.c | 82 ++++++++++++++++++++---------------------- src/hardware/hw_main.h | 2 +- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bdb6ebcb2..a4e257117 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -191,6 +191,8 @@ FTransform atransform; static float gr_viewx, gr_viewy, gr_viewz; static float gr_viewsin, gr_viewcos; +static fixed_t dup_viewx, dup_viewy, dup_viewz; + static angle_t gr_aimingangle; static float gr_viewludsin, gr_viewludcos; @@ -523,7 +525,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t // HWR_RenderPlane // Render a floor or ceiling convex polygon -void HWR_RenderPlane(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_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap, subsector_t *subsector) { polyvertex_t * pv; float height; //constant y for all points on the convex flat polygon @@ -625,9 +627,6 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatsize); flatyref = (float)(((fixed_t)pv->y & (~flatflag)) / fflatsize); - // transform - v3d = planeVerts; - if (FOFsector != NULL) { if (!isceiling) // it's a floor @@ -679,40 +678,32 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei flatyref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); } - - for (i = 0; i < nrPlaneVerts; i++,v3d++,pv++) - { - // Hurdler: add scrolling texture on floor/ceiling - v3d->s = (float)((pv->x / fflatsize) - flatxref + scrollx); - v3d->t = (float)(flatyref - (pv->y / fflatsize) + scrolly); - - //v3d->s = (float)(pv->x / fflatsize); - //v3d->t = (float)(pv->y / fflatsize); - - // Need to rotate before translate - if (angle) // Only needs to be done if there's an altered angle - { - tempxsow = FLOAT_TO_FIXED(v3d->s); - tempytow = FLOAT_TO_FIXED(v3d->t); - v3d->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - v3d->t = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); - } - - //v3d->s = (float)(v3d->s - flatxref + scrollx); - //v3d->t = (float)(flatyref - v3d->t + scrolly); - - v3d->x = pv->x; - v3d->y = height; - v3d->z = pv->y; - -#ifdef ESLOPE - if (slope) - { - fixedheight = P_GetZAt(slope, FLOAT_TO_FIXED(pv->x), FLOAT_TO_FIXED(pv->y)); - v3d->y = FIXED_TO_FLOAT(fixedheight); - } -#endif - } +#define SETUP3DVERT(vert, vx, vy) {\ + /* Hurdler: add scrolling texture on floor/ceiling */\ + vert->s = (float)(((vx) / fflatsize) - flatxref + scrollx);\ + vert->t = (float)(flatyref - ((vy) / fflatsize) + scrolly);\ +\ + /* Need to rotate before translate */\ + if (angle) /* Only needs to be done if there's an altered angle */\ + {\ + tempxsow = FLOAT_TO_FIXED(vert->s);\ + tempytow = FLOAT_TO_FIXED(vert->t);\ + vert->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));\ + vert->t = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));\ + }\ +\ + vert->x = (vx);\ + vert->y = height;\ + vert->z = (vy);\ +\ + if (slope)\ + {\ + fixedheight = P_GetZAt(slope, FLOAT_TO_FIXED((vx)), FLOAT_TO_FIXED((vy)));\ + vert->y = FIXED_TO_FLOAT(fixedheight);\ + }\ +} + for (i = 0, v3d = planeVerts; i < nrPlaneVerts; i++,v3d++,pv++) + SETUP3DVERT(v3d, pv->x, pv->y); HWR_Lighting(&Surf, lightlevel, planecolormap); @@ -3180,7 +3171,7 @@ void HWR_Subsector(size_t num) // Hack to make things continue to work around slopes. locFloorHeight == cullFloorHeight ? locFloorHeight : gr_frontsector->floorheight, // We now return you to your regularly scheduled rendering. - PF_Occlude, floorlightlevel, levelflats[gr_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap); + PF_Occlude, floorlightlevel, levelflats[gr_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap, sub); } } } @@ -3196,7 +3187,7 @@ void HWR_Subsector(size_t num) // Hack to make things continue to work around slopes. locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gr_frontsector->ceilingheight, // We now return you to your regularly scheduled rendering. - PF_Occlude, ceilinglightlevel, levelflats[gr_frontsector->ceilingpic].lumpnum,NULL, 255, ceilingcolormap); + PF_Occlude, ceilinglightlevel, levelflats[gr_frontsector->ceilingpic].lumpnum,NULL, 255, ceilingcolormap, sub); } } } @@ -3262,7 +3253,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(&extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, - rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap, sub); } } @@ -3314,7 +3305,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(&extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, - rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, gr_frontsector->lightlist[light].extra_colormap, sub); } } } @@ -4721,7 +4712,7 @@ void HWR_RenderDrawNodes(void) if (!(sortnode[sortindex[i]].plane->blend & PF_NoTexture)) HWR_GetFlat(sortnode[sortindex[i]].plane->lumpnum, R_NoEncore(sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->isceiling)); HWR_RenderPlane(sortnode[sortindex[i]].plane->xsub, sortnode[sortindex[i]].plane->isceiling, sortnode[sortindex[i]].plane->fixedheight, sortnode[sortindex[i]].plane->blend, sortnode[sortindex[i]].plane->lightlevel, - sortnode[sortindex[i]].plane->lumpnum, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, /*sortnode[sortindex[i]].plane->fogplane,*/ sortnode[sortindex[i]].plane->planecolormap); + sortnode[sortindex[i]].plane->lumpnum, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, /*sortnode[sortindex[i]].plane->fogplane,*/ sortnode[sortindex[i]].plane->planecolormap, NULL); } else if (sortnode[sortindex[i]].polyplane) { @@ -5492,6 +5483,11 @@ void HWR_SetTransform(float fpov, player_t *player) { postimg_t *postprocessor = &postimgtype[0]; INT32 i; + + // copy view cam position for local use + dup_viewx = viewx; + dup_viewy = viewy; + dup_viewz = viewz; gr_viewx = FIXED_TO_FLOAT(viewx); gr_viewy = FIXED_TO_FLOAT(viewy); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index efa61b2fd..c49e384b2 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -104,7 +104,7 @@ void HWR_MakeScreenFinalTexture(void); void HWR_DrawScreenFinalTexture(int width, int height); // hw_main.c: Planes -void HWR_RenderPlane(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_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap, subsector_t *subsector); 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 -- 2.54.0