From b449bd826a014bdc07f43c544f522a628ed128c0 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 13 Aug 2015 19:42:00 +0100 Subject: [PATCH 1/4] Rewrote A_SetTargetsTarget to be more sensible and efficient --- src/p_enemy.c | 55 ++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 4719a9d06..93ffbff7d 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -7592,48 +7592,35 @@ void A_SetTargetsTarget(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; - mobj_t *targetedmobj = NULL; - thinker_t *th; - mobj_t *mo2; + mobj_t *oldtarg = NULL, *newtarg = NULL; #ifdef HAVE_BLUA if (LUA_CallAction("A_SetTargetsTarget", actor)) return; #endif - if ((!locvar1 && (!actor->target)) || (locvar1 && (!actor->tracer))) + // actor's target + if (locvar1) // or tracer + oldtarg = actor->tracer; + else + oldtarg = actor->target; + + if (P_MobjWasRemoved(oldtarg)) return; - if ((!locvar1 && !locvar2 && (!actor->target->target)) - || (!locvar1 && locvar2 && (!actor->target->tracer)) - || (locvar1 && !locvar2 && (!actor->tracer->target)) - || (locvar1 && locvar2 && (!actor->tracer->tracer))) - return; // Don't search for nothing. - - // scan the thinkers - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if ((!locvar1 && !locvar2 && (mo2 == actor->target->target)) - || (!locvar1 && locvar2 && (mo2 == actor->target->tracer)) - || (locvar1 && !locvar2 && (mo2 == actor->tracer->target)) - || (locvar1 && locvar2 && (mo2 == actor->tracer->tracer))) - { - targetedmobj = mo2; - break; - } - } - - if (!targetedmobj) - return; // Oops, nothing found.. - - if (!locvar1) - P_SetTarget(&actor->target, targetedmobj); + // actor's target's target! + if (locvar2) // or tracer + newtarg = oldtarg->tracer; else - P_SetTarget(&actor->tracer, targetedmobj); + newtarg = oldtarg->target; + + if (P_MobjWasRemoved(newtarg)) + return; + + // set actor's new target + if (locvar1) // or tracer + P_SetTarget(&actor->tracer, newtarg); + else + P_SetTarget(&actor->target, newtarg); } // Function: A_SetObjectFlags From b043520411016d482b5f8b6275478f6250fe2404 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 8 Nov 2015 17:50:05 +0000 Subject: [PATCH 2/4] NextLevel for level headers can now take the special strings "Title" "Evaluation" or "Credits" in place of their usual numbers (optionally, that is) --- src/dehacked.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 6b7900f76..44ef998ac 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1132,6 +1132,10 @@ static void readlevelheader(MYFILE *f, INT32 num) } else if (fastcmp(word, "NEXTLEVEL")) { + if (fastcmp(word2, "TITLE")) i = 1100; + else if (fastcmp(word2, "EVALUATION")) i = 1101; + else if (fastcmp(word2, "CREDITS")) i = 1102; + else // Support using the actual map name, // i.e., Nextlevel = AB, Nextlevel = FZ, etc. From 8cad9a6dc87931df736b3e527a862021005ba0c2 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 10 Oct 2015 17:57:35 +0100 Subject: [PATCH 3/4] We can compile the slopes code now, yay! My brain hurts. Compiling errors fixed in this commit: * Various cases of mixed declaration and statement code * Implicit declaration of slope functions (read: you forgot to put "include "p_slopes.h" in MORE than a few places) * an odd case of a bad fixed_t to float typecase, cause by using P_GetZAt directly inside FIXED_TO_FLOAT * a few minor cases of bad unsigned-signed comparisons * no prototypes for some of the new slope functions. For goodness sake Red, this is basic stuff! --- src/p_map.c | 16 +++++--- src/p_maputl.c | 21 ++++++---- src/p_mobj.c | 10 +++-- src/p_slopes.c | 34 +++++++++-------- src/p_slopes.h | 5 +++ src/p_spec.c | 5 ++- src/p_user.c | 3 +- src/r_bsp.c | 1 + src/r_draw.h | 7 ++-- src/r_draw8.c | 101 +++++++++++++++++++++++++++---------------------- src/r_plane.c | 17 +++++++-- src/r_segs.c | 9 ++++- src/r_things.c | 1 + 13 files changed, 140 insertions(+), 90 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index c4dafe81d..224ed31bf 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1245,11 +1245,13 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) { + fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) continue; - fixed_t topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); - fixed_t bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); + topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); + bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); if (rover->flags & FF_GOOWATER && !(thing->flags & MF_NOGRAVITY)) { @@ -1549,11 +1551,12 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) { + fixed_t topheight, bottomheight; if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) continue; - fixed_t topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, x, y, NULL); - fixed_t bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, x, y, NULL); + topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, x, y, NULL); + bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, x, y, NULL); delta1 = thiscam->z - (bottomheight + ((topheight - bottomheight)/2)); @@ -3943,14 +3946,15 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) for (rover = sec->ffloors; rover; rover = rover->next) { + fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) continue; if ((!(rover->flags & FF_SOLID || rover->flags & FF_QUICKSAND) || (rover->flags & FF_SWIMMABLE))) continue; - fixed_t topheight = *rover->topheight; - fixed_t bottomheight = *rover->bottomheight; + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; #ifdef ESLOPE if (*rover->t_slope) diff --git a/src/p_maputl.c b/src/p_maputl.c index c9a42bd43..8f349a2a9 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -20,6 +20,7 @@ #include "r_data.h" #include "p_maputl.h" #include "p_polyobj.h" +#include "p_slopes.h" #include "z_zone.h" // @@ -442,11 +443,12 @@ void P_CameraLineOpening(line_t *linedef) if (front->ffloors) for (rover = front->ffloors; rover; rover = rover->next) { + fixed_t topheight, bottomheight; if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) continue; - fixed_t topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); - fixed_t bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); + topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); @@ -465,11 +467,12 @@ void P_CameraLineOpening(line_t *linedef) if (back->ffloors) for (rover = back->ffloors; rover; rover = rover->next) { + fixed_t topheight, bottomheight; if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) continue; - fixed_t topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); - fixed_t bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); + topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); @@ -636,6 +639,7 @@ void P_LineOpening(line_t *linedef) // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) { + fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) continue; @@ -645,8 +649,8 @@ void P_LineOpening(line_t *linedef) || (rover->flags & FF_BLOCKOTHERS && !tmthing->player))) continue; - fixed_t topheight = P_GetFOFTopZ(tmthing, front, rover, tmx, tmy, linedef); - fixed_t bottomheight = P_GetFOFBottomZ(tmthing, front, rover, tmx, tmy, linedef); + topheight = P_GetFOFTopZ(tmthing, front, rover, tmx, tmy, linedef); + bottomheight = P_GetFOFBottomZ(tmthing, front, rover, tmx, tmy, linedef); delta1 = abs(tmthing->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); @@ -679,6 +683,7 @@ void P_LineOpening(line_t *linedef) // Check for backsectors fake floors for (rover = back->ffloors; rover; rover = rover->next) { + fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) continue; @@ -688,8 +693,8 @@ void P_LineOpening(line_t *linedef) || (rover->flags & FF_BLOCKOTHERS && !tmthing->player))) continue; - fixed_t topheight = P_GetFOFTopZ(tmthing, back, rover, tmx, tmy, linedef); - fixed_t bottomheight = P_GetFOFBottomZ(tmthing, back, rover, tmx, tmy, linedef); + topheight = P_GetFOFTopZ(tmthing, back, rover, tmx, tmy, linedef); + bottomheight = P_GetFOFBottomZ(tmthing, back, rover, tmx, tmy, linedef); delta1 = abs(tmthing->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); diff --git a/src/p_mobj.c b/src/p_mobj.c index 324989067..fd5b2d455 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -696,6 +696,7 @@ void P_ExplodeMissile(mobj_t *mo) // Returns TRUE if mobj is inside a non-solid 3d floor. boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover) { + fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS)) return false; @@ -703,8 +704,8 @@ boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover) || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) return false; - fixed_t topheight = *rover->topheight; - fixed_t bottomheight = *rover->bottomheight; + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; #ifdef ESLOPE if (*rover->t_slope) @@ -3006,13 +3007,14 @@ void P_MobjCheckWater(mobj_t *mobj) for (rover = sector->ffloors; rover; rover = rover->next) { + fixed_t topheight, bottomheight; if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || (((rover->flags & FF_BLOCKPLAYER) && mobj->player) || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) continue; - fixed_t topheight = *rover->topheight; - fixed_t bottomheight = *rover->bottomheight; + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; #ifdef ESLOPE if (*rover->t_slope) diff --git a/src/p_slopes.c b/src/p_slopes.c index bb150944e..755939039 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -32,6 +32,7 @@ #include "r_state.h" #include "m_bbox.h" #include "z_zone.h" +#include "p_local.h" #include "p_spec.h" #include "p_slopes.h" #include "p_setup.h" @@ -140,7 +141,8 @@ void P_RunDynamicSlopes(void) { case 5: // vertices { mapthing_t *mt; - size_t i, l; + size_t i; + INT32 l; line_t *line; for (i = 0; i < 3; i++) { @@ -322,7 +324,8 @@ void P_SpawnSlope_Line(int linenum) if(frontfloor) { - + fixed_t highest, lowest; + size_t l; point.z = line->frontsector->floorheight; // Startz dz = FixedDiv(origin.z - point.z, extent); // Destinationz @@ -351,12 +354,11 @@ void P_SpawnSlope_Line(int linenum) // *You can use sourceline as a reference to see if two slopes really are the same // Default points for high and low - fixed_t highest = point.z > origin.z ? point.z : origin.z; - fixed_t lowest = point.z < origin.z ? point.z : origin.z; + highest = point.z > origin.z ? point.z : origin.z; + lowest = point.z < origin.z ? point.z : origin.z; // Now check to see what the REAL high and low points of the slope inside the sector // TODO: Is this really needed outside of FOFs? -Red - size_t l; for (l = 0; l < line->frontsector->linecount; l++) { @@ -380,6 +382,8 @@ void P_SpawnSlope_Line(int linenum) } if(frontceil) { + fixed_t highest, lowest; + size_t l; origin.z = line->backsector->ceilingheight; point.z = line->frontsector->ceilingheight; dz = FixedDiv(origin.z - point.z, extent); @@ -396,9 +400,8 @@ void P_SpawnSlope_Line(int linenum) cslope->sourceline = line; // Remember the way the slope is formed - fixed_t highest = point.z > origin.z ? point.z : origin.z; - fixed_t lowest = point.z < origin.z ? point.z : origin.z; - size_t l; + highest = point.z > origin.z ? point.z : origin.z; + lowest = point.z < origin.z ? point.z : origin.z; for (l = 0; l < line->frontsector->linecount; l++) { @@ -446,6 +449,8 @@ void P_SpawnSlope_Line(int linenum) if(backfloor) { + fixed_t highest, lowest; + size_t l; point.z = line->backsector->floorheight; dz = FixedDiv(origin.z - point.z, extent); @@ -461,9 +466,8 @@ void P_SpawnSlope_Line(int linenum) fslope->sourceline = line; // Remember the way the slope is formed - fixed_t highest = point.z > origin.z ? point.z : origin.z; - fixed_t lowest = point.z < origin.z ? point.z : origin.z; - size_t l; + highest = point.z > origin.z ? point.z : origin.z; + lowest = point.z < origin.z ? point.z : origin.z; for (l = 0; l < line->backsector->linecount; l++) { @@ -487,6 +491,8 @@ void P_SpawnSlope_Line(int linenum) } if(backceil) { + fixed_t highest, lowest; + size_t l; origin.z = line->frontsector->ceilingheight; point.z = line->backsector->ceilingheight; dz = FixedDiv(origin.z - point.z, extent); @@ -503,10 +509,8 @@ void P_SpawnSlope_Line(int linenum) cslope->sourceline = line; // Remember the way the slope is formed - fixed_t highest = point.z > origin.z ? point.z : origin.z; - fixed_t lowest = point.z < origin.z ? point.z : origin.z; - - size_t l; + highest = point.z > origin.z ? point.z : origin.z; + lowest = point.z < origin.z ? point.z : origin.z; for (l = 0; l < line->backsector->linecount; l++) { diff --git a/src/p_slopes.h b/src/p_slopes.h index 8d82632ff..f2d1cd81e 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -29,6 +29,9 @@ #define P_SLOPES_H__ #ifdef ESLOPE +void P_CalculateSlopeNormal(pslope_t *slope); +void P_ReconfigureVertexSlope(pslope_t *slope); + void P_ResetDynamicSlopes(void); void P_RunDynamicSlopes(void); // P_SpawnSlope_Line @@ -36,6 +39,8 @@ void P_RunDynamicSlopes(void); // sectors. void P_SpawnSlope_Line(int linenum); +pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flags); + #ifdef SPRINGCLEAN // Loads just map objects that make slopes, // terrain affecting objects have to be spawned first diff --git a/src/p_spec.c b/src/p_spec.c index 694893502..3f39bd08e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -29,6 +29,7 @@ #include "r_main.h" //Two extra includes. #include "r_sky.h" #include "p_polyobj.h" +#include "p_slopes.h" #include "hu_stuff.h" #include "m_misc.h" #include "m_cond.h" //unlock triggers @@ -7043,7 +7044,7 @@ static void Add_Friction(INT32 friction, INT32 movefactor, INT32 affectee, INT32 */ void T_Friction(friction_t *f) { - sector_t *sec, *referrer; + sector_t *sec, *referrer = NULL; mobj_t *thing; msecnode_t *node; @@ -7371,7 +7372,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) */ void T_Pusher(pusher_t *p) { - sector_t *sec, *referrer; + sector_t *sec, *referrer = NULL; mobj_t *thing; msecnode_t *node; INT32 xspeed = 0,yspeed = 0; diff --git a/src/p_user.c b/src/p_user.c index b0eb2a224..d693cb277 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -29,6 +29,7 @@ #include "m_random.h" #include "m_misc.h" #include "i_video.h" +#include "p_slopes.h" #include "p_spec.h" #include "r_splats.h" #include "z_zone.h" @@ -2317,11 +2318,11 @@ static void P_DoClimbing(player_t *player) boolean thrust; boolean boostup; boolean skyclimber; + fixed_t floorheight, ceilingheight; // ESLOPE thrust = false; floorclimb = false; boostup = false; skyclimber = false; - fixed_t floorheight, ceilingheight; // ESLOPE #ifdef ESLOPE floorheight = glidesector->sector->f_slope ? P_GetZAt(glidesector->sector->f_slope, player->mo->x, player->mo->y) diff --git a/src/r_bsp.c b/src/r_bsp.c index 503b2e1f0..badf8bdac 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -18,6 +18,7 @@ #include "r_splats.h" #include "p_local.h" // camera +#include "p_slopes.h" #include "z_zone.h" // Check R_Prep3DFloors seg_t *curline; diff --git a/src/r_draw.h b/src/r_draw.h index 63fecc046..0ece26487 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -65,9 +65,9 @@ typedef struct { float x, y, z; } floatv3_t; -pslope_t *ds_slope; // Current slope being used -floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff? -float focallengthf, zeroheight; +extern pslope_t *ds_slope; // Current slope being used +extern floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff? +extern float focallengthf, zeroheight; #endif // Variable flat sizes @@ -152,6 +152,7 @@ void R_DrawTranslatedColumn_8(void); void R_DrawTranslatedTranslucentColumn_8(void); void R_DrawSpan_8(void); #ifdef ESLOPE +void R_CalcTiltedLighting(fixed_t start, fixed_t end); void R_DrawTiltedSpan_8(void); void R_DrawTiltedTranslucentSpan_8(void); void R_DrawTiltedSplat_8(void); diff --git a/src/r_draw8.c b/src/r_draw8.c index f78f1494b..2a4c89be7 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -529,14 +529,14 @@ void R_DrawSpan_8 (void) #ifdef ESLOPE // R_CalcTiltedLighting // Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly. -static size_t tiltlighting[MAXVIDWIDTH]; +static INT32 tiltlighting[MAXVIDWIDTH]; void R_CalcTiltedLighting(fixed_t start, fixed_t end) { // ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version // of this function. Here's my own. INT32 left = ds_x1, right = ds_x2; fixed_t step = (end-start)/(ds_x2-ds_x1+1); - size_t i; + INT32 i; // I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once, // but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now... @@ -566,6 +566,11 @@ void R_DrawTiltedSpan_8(void) UINT8 *colormap; UINT8 *dest; + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end @@ -608,10 +613,9 @@ void R_DrawTiltedSpan_8(void) #define SPANSIZE 16 #define INVSPAN 0.0625f - double startz = 1.f/iz; - double startu = uz*startz; - double startv = vz*startz; - double izstep, uzstep, vzstep; + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; izstep = ds_sz.x * SPANSIZE; uzstep = ds_su.x * SPANSIZE; @@ -625,11 +629,11 @@ void R_DrawTiltedSpan_8(void) uz += uzstep; vz += vzstep; - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; - UINT32 stepu = (INT64)((endu - startu) * INVSPAN); - UINT32 stepv = (INT64)((endv - startv) * INVSPAN); + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); u = (INT64)(startu) + viewx; v = (INT64)(startv) + viewy; @@ -661,12 +665,12 @@ void R_DrawTiltedSpan_8(void) uz += ds_su.x * left; vz += ds_sv.x * left; - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; left = 1.f/left; - UINT32 stepu = (INT64)((endu - startu) * left); - UINT32 stepv = (INT64)((endv - startv) * left); + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); u = (INT64)(startu) + viewx; v = (INT64)(startv) + viewy; @@ -683,7 +687,6 @@ void R_DrawTiltedSpan_8(void) #endif } - /** \brief The R_DrawTiltedTranslucentSpan_8 function Like DrawTiltedSpan, but translucent */ @@ -699,6 +702,11 @@ void R_DrawTiltedTranslucentSpan_8(void) UINT8 *colormap; UINT8 *dest; + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end @@ -741,10 +749,9 @@ void R_DrawTiltedTranslucentSpan_8(void) #define SPANSIZE 16 #define INVSPAN 0.0625f - double startz = 1.f/iz; - double startu = uz*startz; - double startv = vz*startz; - double izstep, uzstep, vzstep; + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; izstep = ds_sz.x * SPANSIZE; uzstep = ds_su.x * SPANSIZE; @@ -758,11 +765,11 @@ void R_DrawTiltedTranslucentSpan_8(void) uz += uzstep; vz += vzstep; - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; - UINT32 stepu = (INT64)((endu - startu) * INVSPAN); - UINT32 stepv = (INT64)((endv - startv) * INVSPAN); + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); u = (INT64)(startu) + viewx; v = (INT64)(startv) + viewy; @@ -794,12 +801,12 @@ void R_DrawTiltedTranslucentSpan_8(void) uz += ds_su.x * left; vz += ds_sv.x * left; - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; left = 1.f/left; - UINT32 stepu = (INT64)((endu - startu) * left); - UINT32 stepv = (INT64)((endv - startv) * left); + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); u = (INT64)(startu) + viewx; v = (INT64)(startv) + viewy; @@ -830,6 +837,11 @@ void R_DrawTiltedSplat_8(void) UINT8 val; + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end @@ -874,10 +886,9 @@ void R_DrawTiltedSplat_8(void) #define SPANSIZE 16 #define INVSPAN 0.0625f - double startz = 1.f/iz; - double startu = uz*startz; - double startv = vz*startz; - double izstep, uzstep, vzstep; + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; izstep = ds_sz.x * SPANSIZE; uzstep = ds_su.x * SPANSIZE; @@ -891,11 +902,11 @@ void R_DrawTiltedSplat_8(void) uz += uzstep; vz += vzstep; - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; - UINT32 stepu = (INT64)((endu - startu) * INVSPAN); - UINT32 stepv = (INT64)((endv - startv) * INVSPAN); + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); u = (INT64)(startu) + viewx; v = (INT64)(startv) + viewy; @@ -931,12 +942,12 @@ void R_DrawTiltedSplat_8(void) uz += ds_su.x * left; vz += ds_sv.x * left; - double endz = 1.f/iz; - double endu = uz*endz; - double endv = vz*endz; + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; left = 1.f/left; - UINT32 stepu = (INT64)((endu - startu) * left); - UINT32 stepv = (INT64)((endv - startv) * left); + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); u = (INT64)(startu) + viewx; v = (INT64)(startv) + viewy; diff --git a/src/r_plane.c b/src/r_plane.c index 406a38d7b..fa0e0eac3 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -28,6 +28,8 @@ #include "p_setup.h" // levelflats +#include "p_slopes.h" + // // opening // @@ -952,6 +954,9 @@ void R_DrawSinglePlane(visplane_t *pl) float ang; float vx, vy, vz; float fudge; + // compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly + // use this as a temp var to store P_GetZAt's return value each time + fixed_t temp; xoffs &= ((1 << (32-nflatshiftup))-1); yoffs &= ((1 << (32-nflatshiftup))-1); @@ -969,7 +974,8 @@ void R_DrawSinglePlane(visplane_t *pl) vy = FIXED_TO_FLOAT(viewy-yoffs); vz = FIXED_TO_FLOAT(viewz); - zeroheight = FIXED_TO_FLOAT(P_GetZAt(pl->slope, viewx, viewy)); + temp = P_GetZAt(pl->slope, viewx, viewy); + zeroheight = FIXED_TO_FLOAT(temp); #define ANG2RAD(angle) ((float)((angle)*M_PI)/ANGLE_180) @@ -979,7 +985,8 @@ void R_DrawSinglePlane(visplane_t *pl) ang = ANG2RAD(ANGLE_270 - viewangle); p.x = vx * cos(ang) - vy * sin(ang); p.z = vx * sin(ang) + vy * cos(ang); - p.y = FIXED_TO_FLOAT(P_GetZAt(pl->slope, -xoffs, yoffs)) - vz; + temp = P_GetZAt(pl->slope, -xoffs, yoffs); + p.y = FIXED_TO_FLOAT(temp) - vz; // m is the v direction vector in view space ang = ANG2RAD(ANGLE_180 - viewangle - pl->plangle); @@ -991,8 +998,10 @@ void R_DrawSinglePlane(visplane_t *pl) n.z = -cos(ang); ang = ANG2RAD(pl->plangle); - m.y = FIXED_TO_FLOAT(P_GetZAt(pl->slope, viewx + FLOAT_TO_FIXED(sin(ang)), viewy + FLOAT_TO_FIXED(cos(ang)))) - zeroheight; - n.y = FIXED_TO_FLOAT(P_GetZAt(pl->slope, viewx + FLOAT_TO_FIXED(cos(ang)), viewy - FLOAT_TO_FIXED(sin(ang)))) - zeroheight; + temp = P_GetZAt(pl->slope, viewx + FLOAT_TO_FIXED(sin(ang)), viewy + FLOAT_TO_FIXED(cos(ang))); + m.y = FIXED_TO_FLOAT(temp) - zeroheight; + temp = P_GetZAt(pl->slope, viewx + FLOAT_TO_FIXED(cos(ang)), viewy - FLOAT_TO_FIXED(sin(ang))); + n.y = FIXED_TO_FLOAT(temp) - zeroheight; m.x /= fudge; m.y /= fudge; diff --git a/src/r_segs.c b/src/r_segs.c index 2d41d702c..75e7b8b98 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -22,6 +22,7 @@ #include "d_netcmd.h" #include "m_misc.h" #include "p_local.h" // Camera... +#include "p_slopes.h" #include "console.h" // con_clipviewtop // OPTIMIZE: closed two sided lines as single sided @@ -1489,7 +1490,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) fixed_t hyp; fixed_t sineval; angle_t distangle, offsetangle; - fixed_t vtop; + //fixed_t vtop; INT32 lightnum; INT32 i, p; lightlist_t *light; @@ -1502,6 +1503,10 @@ void R_StoreWallRange(INT32 start, INT32 stop) maskedtextureheight = NULL; + //initialize segleft and segright + memset(&segleft, 0x00, sizeof(segleft)); + memset(&segright, 0x00, sizeof(segright)); + if (ds_p == drawsegs+maxdrawsegs) { size_t pos = ds_p - drawsegs; @@ -2630,11 +2635,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) { ffloor_t * rover; - i = 0; #ifdef ESLOPE fixed_t rovertest; fixed_t planevistest; #endif + i = 0; if (backsector->ffloors) { diff --git a/src/r_things.c b/src/r_things.c index 3a38eb482..85221dce2 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -24,6 +24,7 @@ #include "r_plane.h" #include "p_tick.h" #include "p_local.h" +#include "p_slopes.h" #include "dehacked.h" // get_number (for thok) #include "d_netfil.h" // blargh. for nameonly(). #include "m_cheat.h" // objectplace From 6929b6fe4bb13451fd3ecb89cc63cddaf22af9a2 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sun, 3 Jan 2016 10:33:45 -0600 Subject: [PATCH 4/4] Make internal slope functions static and remove from header --- src/p_slopes.c | 6 +++--- src/p_slopes.h | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 755939039..2d55cf194 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -46,14 +46,14 @@ static pslope_t *slopelist = NULL; static UINT16 slopecount = 0; // Calculate line normal -void P_CalculateSlopeNormal(pslope_t *slope) { +static void P_CalculateSlopeNormal(pslope_t *slope) { slope->normal.z = FINECOSINE(slope->zangle>>ANGLETOFINESHIFT); slope->normal.x = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.x); slope->normal.y = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.y); } // With a vertex slope that has its vertices set, configure relevant slope info -void P_ReconfigureVertexSlope(pslope_t *slope) +static void P_ReconfigureVertexSlope(pslope_t *slope) { vector3_t vec1, vec2; @@ -543,7 +543,7 @@ void P_SpawnSlope_Line(int linenum) // // Creates a new slope from three vertices with the specified IDs // -pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flags) +static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flags) { size_t i; mapthing_t *mt = mapthings; diff --git a/src/p_slopes.h b/src/p_slopes.h index f2d1cd81e..8d82632ff 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -29,9 +29,6 @@ #define P_SLOPES_H__ #ifdef ESLOPE -void P_CalculateSlopeNormal(pslope_t *slope); -void P_ReconfigureVertexSlope(pslope_t *slope); - void P_ResetDynamicSlopes(void); void P_RunDynamicSlopes(void); // P_SpawnSlope_Line @@ -39,8 +36,6 @@ void P_RunDynamicSlopes(void); // sectors. void P_SpawnSlope_Line(int linenum); -pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flags); - #ifdef SPRINGCLEAN // Loads just map objects that make slopes, // terrain affecting objects have to be spawned first