From 5400ce1a218d3391b20953b9837ae356ac7c163a Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Thu, 7 Aug 2014 15:50:21 +0200 Subject: [PATCH 01/16] +MTHRUSPECIES on puffs --- src/p_map.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 96b2b6195..8aeab1a84 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3466,7 +3466,29 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p // //========================================================================== -static ETraceStatus CheckForGhost (FTraceResults &res, void *userdata) +struct Origin +{ + AActor *Caller; +}; + +static ETraceStatus CheckForSameSpecie(FTraceResults &res, void *userdata) +{ + if (res.HitType != TRACE_HitActor) + { + return TRACE_Stop; + } + + Origin *data = (Origin *)userdata; + + // check for physical attacks on the same specie + if (res.Actor->GetSpecies() == data->Caller->GetSpecies() || res.Actor->flags4 & MF4_SPECTRAL) + { + return TRACE_Skip; + } + + return TRACE_Stop; +} +static ETraceStatus CheckForGhost(FTraceResults &res, void *userdata) { if (res.HitType != TRACE_HitActor) { @@ -3481,8 +3503,24 @@ static ETraceStatus CheckForGhost (FTraceResults &res, void *userdata) return TRACE_Stop; } +static ETraceStatus CheckForSpecieAndGhost(FTraceResults &res, void *userdata) +{ + if (res.HitType != TRACE_HitActor) + { + return TRACE_Stop; + } -static ETraceStatus CheckForSpectral (FTraceResults &res, void *userdata) + Origin *data = (Origin *)userdata; + + // check for physical attacks + if (res.Actor->GetSpecies() == data->Caller->GetSpecies() || res.Actor->flags3 & MF3_GHOST || res.Actor->flags4 & MF4_SPECTRAL) + { + return TRACE_Skip; + } + + return TRACE_Stop; +} +static ETraceStatus CheckForSpectral(FTraceResults &res, void *userdata) { if (res.HitType != TRACE_HitActor) { @@ -3511,9 +3549,12 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, { fixed_t vx, vy, vz, shootz; FTraceResults trace; + Origin TData; + TData.Caller = t1; angle_t srcangle = angle; int srcpitch = pitch; bool hitGhosts; + bool hitSameSpecie; bool killPuff = false; AActor *puff = NULL; int pflag = 0; @@ -3561,6 +3602,8 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, (t1->player->ReadyWeapon->flags2 & MF2_THRUGHOST)) || (puffDefaults && (puffDefaults->flags2 & MF2_THRUGHOST)); + hitSameSpecie = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); + // if the puff uses a non-standard damage type, this will override default, hitscan and melee damage type. // All other explicitly passed damage types (currenty only MDK) will be preserved. if ((damageType == NAME_None || damageType == NAME_Melee || damageType == NAME_Hitscan) && @@ -3575,7 +3618,7 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, if (!Trace (t1->x, t1->y, shootz, t1->Sector, vx, vy, vz, distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING|ML_BLOCKHITSCAN, t1, trace, - tflags, hitGhosts ? CheckForGhost : CheckForSpectral)) + tflags, hitGhosts ? (hitSameSpecie ? CheckForSpecieAndGhost : CheckForGhost) : hitSameSpecie ? CheckForSameSpecie : CheckForSpectral, &TData)) { // hit nothing if (puffDefaults == NULL) { From 8c4c011ca217210a2806ef9f9847215644845a75 Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Thu, 7 Aug 2014 18:05:39 +0200 Subject: [PATCH 02/16] MTHRUSPECIES on puffs You were right it's cleaner that way --- src/p_map.cpp | 1735 ++++++++++++++++++++++++------------------------- 1 file changed, 849 insertions(+), 886 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 8aeab1a84..68c2c1530 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -53,19 +53,19 @@ #include "r_data/r_translate.h" #include "g_level.h" -CVAR (Bool, cl_bloodsplats, true, CVAR_ARCHIVE) -CVAR (Int, sv_smartaim, 0, CVAR_ARCHIVE|CVAR_SERVERINFO) -CVAR (Bool, cl_doautoaim, false, CVAR_ARCHIVE) +CVAR(Bool, cl_bloodsplats, true, CVAR_ARCHIVE) +CVAR(Int, sv_smartaim, 0, CVAR_ARCHIVE | CVAR_SERVERINFO) +CVAR(Bool, cl_doautoaim, false, CVAR_ARCHIVE) -static void CheckForPushSpecial (line_t *line, int side, AActor *mobj, bool windowcheck); -static void SpawnShootDecal (AActor *t1, const FTraceResults &trace); -static void SpawnDeepSplash (AActor *t1, const FTraceResults &trace, AActor *puff, - fixed_t vx, fixed_t vy, fixed_t vz, fixed_t shootz, bool ffloor = false); +static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, bool windowcheck); +static void SpawnShootDecal(AActor *t1, const FTraceResults &trace); +static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff, + fixed_t vx, fixed_t vy, fixed_t vz, fixed_t shootz, bool ffloor = false); -static FRandom pr_tracebleed ("TraceBleed"); -static FRandom pr_checkthing ("CheckThing"); -static FRandom pr_lineattack ("LineAttack"); -static FRandom pr_crunch ("DoCrunch"); +static FRandom pr_tracebleed("TraceBleed"); +static FRandom pr_checkthing("CheckThing"); +static FRandom pr_lineattack("LineAttack"); +static FRandom pr_crunch("DoCrunch"); // keep track of special lines as they are hit, // but don't process them until the move is proven valid @@ -82,19 +82,19 @@ msecnode_t* sector_list = NULL; // phares 3/16/98 // //========================================================================== -static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPosition &tmf, int flags) +static bool PIT_FindFloorCeiling(line_t *ld, const FBoundingBox &box, FCheckPosition &tmf, int flags) { if (box.Right() <= ld->bbox[BOXLEFT] || box.Left() >= ld->bbox[BOXRIGHT] || box.Top() <= ld->bbox[BOXBOTTOM] - || box.Bottom() >= ld->bbox[BOXTOP] ) + || box.Bottom() >= ld->bbox[BOXTOP]) return true; - if (box.BoxOnLineSide (ld) != -1) + if (box.BoxOnLineSide(ld) != -1) return true; // A line has been hit - + if (!ld->backsector) { // One sided line return true; @@ -105,33 +105,33 @@ static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPos // set openrange, opentop, openbottom if ((((ld->frontsector->floorplane.a | ld->frontsector->floorplane.b) | - (ld->backsector->floorplane.a | ld->backsector->floorplane.b) | - (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | - (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) - && ld->backsector->e->XFloor.ffloors.Size()==0 && ld->frontsector->e->XFloor.ffloors.Size()==0) + (ld->backsector->floorplane.a | ld->backsector->floorplane.b) | + (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | + (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) + && ld->backsector->e->XFloor.ffloors.Size() == 0 && ld->frontsector->e->XFloor.ffloors.Size() == 0) { - P_LineOpening (open, tmf.thing, ld, sx=tmf.x, sy=tmf.y, tmf.x, tmf.y, flags); + P_LineOpening(open, tmf.thing, ld, sx = tmf.x, sy = tmf.y, tmf.x, tmf.y, flags); } else { // Find the point on the line closest to the actor's center, and use - // that to calculate openings + // that to calculate openings double dx = ld->dx; double dy = ld->dy; fixed_t r = xs_CRoundToInt(((double)(tmf.x - ld->v1->x) * dx + - (double)(tmf.y - ld->v1->y) * dy) / - (dx*dx + dy*dy) * 16777216.f); + (double)(tmf.y - ld->v1->y) * dy) / + (dx*dx + dy*dy) * 16777216.f); if (r <= 0) { - P_LineOpening (open, tmf.thing, ld, sx=ld->v1->x, sy=ld->v1->y, tmf.x, tmf.y, flags); + P_LineOpening(open, tmf.thing, ld, sx = ld->v1->x, sy = ld->v1->y, tmf.x, tmf.y, flags); } - else if (r >= (1<<24)) + else if (r >= (1 << 24)) { - P_LineOpening (open, tmf.thing, ld, sx=ld->v2->x, sy=ld->v2->y, tmf.thing->x, tmf.thing->y, flags); + P_LineOpening(open, tmf.thing, ld, sx = ld->v2->x, sy = ld->v2->y, tmf.thing->x, tmf.thing->y, flags); } else { - P_LineOpening (open, tmf.thing, ld, sx=ld->v1->x + MulScale24 (r, ld->dx), - sy=ld->v1->y + MulScale24 (r, ld->dy), tmf.x, tmf.y, flags); + P_LineOpening(open, tmf.thing, ld, sx = ld->v1->x + MulScale24(r, ld->dx), + sy = ld->v1->y + MulScale24(r, ld->dy), tmf.x, tmf.y, flags); } } @@ -156,7 +156,7 @@ static bool PIT_FindFloorCeiling (line_t *ld, const FBoundingBox &box, FCheckPos if (open.lowfloor < tmf.dropoffz) tmf.dropoffz = open.lowfloor; - + return true; } @@ -172,12 +172,12 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) sector_t *sec; if (!(flags & FFCF_ONLYSPAWNPOS)) { - sec = !(flags & FFCF_SAMESECTOR) ? P_PointInSector (tmf.x, tmf.y) : tmf.thing->Sector; + sec = !(flags & FFCF_SAMESECTOR) ? P_PointInSector(tmf.x, tmf.y) : tmf.thing->Sector; tmf.floorsector = sec; tmf.ceilingsector = sec; - tmf.floorz = tmf.dropoffz = sec->floorplane.ZatPoint (tmf.x, tmf.y); - tmf.ceilingz = sec->ceilingplane.ZatPoint (tmf.x, tmf.y); + tmf.floorz = tmf.dropoffz = sec->floorplane.ZatPoint(tmf.x, tmf.y); + tmf.ceilingz = sec->ceilingplane.ZatPoint(tmf.x, tmf.y); tmf.floorpic = sec->GetTexture(sector_t::floor); tmf.ceilingpic = sec->GetTexture(sector_t::ceiling); } @@ -187,7 +187,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) } #ifdef _3DFLOORS - for(unsigned int i=0;ie->XFloor.ffloors.Size();i++) + for (unsigned int i = 0; ie->XFloor.ffloors.Size(); i++) { F3DFloor* rover = sec->e->XFloor.ffloors[i]; @@ -204,7 +204,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) tmf.floorpic = *rover->top.texture; } } - if (ff_bottom <= tmf.ceilingz && ff_bottom > tmf.z + tmf.thing->height) + if (ff_bottom <= tmf.ceilingz && ff_bottom > tmf.z + tmf.thing->height) { tmf.ceilingz = ff_bottom; tmf.ceilingpic = *rover->bottom.texture; @@ -219,7 +219,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) // //========================================================================== -void P_FindFloorCeiling (AActor *actor, int flags) +void P_FindFloorCeiling(AActor *actor, int flags) { FCheckPosition tmf; @@ -309,14 +309,14 @@ void P_FindFloorCeiling (AActor *actor, int flags) // //========================================================================== -bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag) +bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag) { FCheckPosition tmf; sector_t *oldsec = thing->Sector; - + // kill anything occupying the position - - + + // The base floor/ceiling is from the subsector that contains the point. // Any contacted lines the step closer together will adjust them. tmf.thing = thing; @@ -326,8 +326,8 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr tmf.touchmidtex = false; tmf.abovemidtex = false; P_GetFloorCeilingZ(tmf, 0); - - spechit.Clear (); + + spechit.Clear(); bool StompAlwaysFrags = ((thing->flags2 & MF2_TELESTOMP) || (level.flags & LEVEL_MONSTERSTELEFRAG) || telefrag) && !(thing->flags7 & MF7_NOTELESTOMP); @@ -359,7 +359,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr continue; fixed_t blockdist = th->radius + tmf.thing->radius; - if ( abs(th->x - tmf.x) >= blockdist || abs(th->y - tmf.y) >= blockdist) + if (abs(th->x - tmf.x) >= blockdist || abs(th->y - tmf.y) >= blockdist) continue; // [RH] Z-Check @@ -370,7 +370,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr if (!(th->flags3 & thing->flags3 & MF3_DONTOVERLAP)) { if (z > th->z + th->height || // overhead - z+thing->height < th->z) // underneath + z + thing->height < th->z) // underneath continue; } } @@ -380,14 +380,14 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr // ... and some items can never be telefragged while others will be telefragged by everything that teleports upon them. if ((StompAlwaysFrags && !(th->flags6 & MF6_NOTELEFRAG)) || (th->flags7 & MF7_ALWAYSTELEFRAG)) { - P_DamageMobj (th, thing, thing, TELEFRAG_DAMAGE, NAME_Telefrag, DMG_THRUSTLESS); + P_DamageMobj(th, thing, thing, TELEFRAG_DAMAGE, NAME_Telefrag, DMG_THRUSTLESS); continue; } return false; } - + // the move is ok, so link the thing into its new position - thing->SetOrigin (x, y, z); + thing->SetOrigin(x, y, z); thing->floorz = tmf.floorz; thing->ceilingz = tmf.ceilingz; thing->floorsector = tmf.floorsector; @@ -399,12 +399,12 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr if (thing->flags2 & MF2_FLOORCLIP) { - thing->AdjustFloorClip (); + thing->AdjustFloorClip(); } if (thing == players[consoleplayer].camera) { - R_ResetViewInterpolation (); + R_ResetViewInterpolation(); } thing->PrevX = x; @@ -430,7 +430,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr // //========================================================================== -void P_PlayerStartStomp (AActor *actor) +void P_PlayerStartStomp(AActor *actor) { AActor *th; FBlockThingsIterator it(FBoundingBox(actor->x, actor->y, actor->radius)); @@ -456,7 +456,7 @@ void P_PlayerStartStomp (AActor *actor) if (actor->z + actor->height < th->z) continue; // underneath - P_DamageMobj (th, actor, actor, TELEFRAG_DAMAGE, NAME_Telefrag); + P_DamageMobj(th, actor, actor, TELEFRAG_DAMAGE, NAME_Telefrag); } } @@ -466,13 +466,13 @@ void P_PlayerStartStomp (AActor *actor) // //========================================================================== -inline fixed_t secfriction (const sector_t *sec) +inline fixed_t secfriction(const sector_t *sec) { fixed_t friction = Terrains[TerrainTypes[sec->GetTexture(sector_t::floor)]].Friction; return friction != 0 ? friction : sec->friction; } -inline fixed_t secmovefac (const sector_t *sec) +inline fixed_t secmovefac(const sector_t *sec) { fixed_t movefactor = Terrains[TerrainTypes[sec->GetTexture(sector_t::floor)]].MoveFactor; return movefactor != 0 ? movefactor : sec->movefactor; @@ -488,7 +488,7 @@ inline fixed_t secmovefac (const sector_t *sec) // //========================================================================== -int P_GetFriction (const AActor *mo, int *frictionfactor) +int P_GetFriction(const AActor *mo, int *frictionfactor) { int friction = ORIG_FRICTION; int movefactor = ORIG_FRICTION_FACTOR; @@ -505,12 +505,12 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) friction = FRICTION_FLY; } else if ((!(mo->flags & MF_NOGRAVITY) && mo->waterlevel > 1) || - (mo->waterlevel == 1 && mo->z > mo->floorz + 6*FRACUNIT)) + (mo->waterlevel == 1 && mo->z > mo->floorz + 6 * FRACUNIT)) { friction = secfriction(mo->Sector); movefactor = secmovefac(mo->Sector) >> 1; } - else if (var_friction && !(mo->flags & (MF_NOCLIP|MF_NOGRAVITY))) + else if (var_friction && !(mo->flags & (MF_NOCLIP | MF_NOGRAVITY))) { // When the object is straddling sectors with the same // floor height that have different frictions, use the lowest // friction value (muddy has precedence over icy). @@ -528,7 +528,7 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) if (!(rover->flags & FF_SOLID)) continue; // Player must be on top of the floor to be affected... - if (mo->z != rover->top.plane->ZatPoint(mo->x,mo->y)) continue; + if (mo->z != rover->top.plane->ZatPoint(mo->x, mo->y)) continue; newfriction = secfriction(rover->model); if (newfriction < friction || friction == ORIG_FRICTION) { @@ -547,14 +547,14 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) if ((newfriction < friction || friction == ORIG_FRICTION) && (mo->z <= sec->floorplane.ZatPoint(mo->x, mo->y) || (sec->GetHeightSec() != NULL && - mo->z <= sec->heightsec->floorplane.ZatPoint(mo->x, mo->y)))) + mo->z <= sec->heightsec->floorplane.ZatPoint(mo->x, mo->y)))) { friction = newfriction; movefactor = secmovefac(sec); } } } - + if (mo->Friction != FRACUNIT) { friction = clamp(FixedMul(friction, mo->Friction), 0, FRACUNIT); @@ -577,7 +577,7 @@ int P_GetFriction (const AActor *mo, int *frictionfactor) // //========================================================================== -int P_GetMoveFactor (const AActor *mo, int *frictionp) +int P_GetMoveFactor(const AActor *mo, int *frictionp) { int movefactor, friction; @@ -592,9 +592,9 @@ int P_GetMoveFactor (const AActor *mo, int *frictionp) int velocity = P_AproxDistance(mo->velx, mo->vely); - if (velocity > MORE_FRICTION_VELOCITY<<2) + if (velocity > MORE_FRICTION_VELOCITY << 2) movefactor <<= 3; - else if (velocity > MORE_FRICTION_VELOCITY<<1) + else if (velocity > MORE_FRICTION_VELOCITY << 1) movefactor <<= 2; else if (velocity > MORE_FRICTION_VELOCITY) movefactor <<= 1; @@ -620,37 +620,37 @@ int P_GetMoveFactor (const AActor *mo, int *frictionp) //========================================================================== static // killough 3/26/98: make static -bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) +bool PIT_CheckLine(line_t *ld, const FBoundingBox &box, FCheckPosition &tm) { bool rail = false; if (box.Right() <= ld->bbox[BOXLEFT] || box.Left() >= ld->bbox[BOXRIGHT] || box.Top() <= ld->bbox[BOXBOTTOM] - || box.Bottom() >= ld->bbox[BOXTOP] ) + || box.Bottom() >= ld->bbox[BOXTOP]) return true; - if (box.BoxOnLineSide (ld) != -1) + if (box.BoxOnLineSide(ld) != -1) return true; // A line has been hit -/* -= -= The moving thing's destination position will cross the given line. -= If this should not be allowed, return false. -= If the line is special, keep track of it to process later if the move -= is proven ok. NOTE: specials are NOT sorted by order, so two special lines -= that are only 8 pixels apart could be crossed in either order. -*/ - + /* + = + = The moving thing's destination position will cross the given line. + = If this should not be allowed, return false. + = If the line is special, keep track of it to process later if the move + = is proven ok. NOTE: specials are NOT sorted by order, so two special lines + = that are only 8 pixels apart could be crossed in either order. + */ + if (!ld->backsector) { // One sided line if (tm.thing->flags2 & MF2_BLASTED) { - P_DamageMobj (tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); + P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); } tm.thing->BlockingLine = ld; - CheckForPushSpecial (ld, 0, tm.thing, false); + CheckForPushSpecial(ld, 0, tm.thing, false); return false; } @@ -663,13 +663,13 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) bool NotBlocked = ((tm.thing->flags3 & MF3_NOBLOCKMONST) || ((i_compatflags & COMPATF_NOBLOCKFRIENDS) && (tm.thing->flags & MF_FRIENDLY))); - if (!(Projectile) || (ld->flags & (ML_BLOCKEVERYTHING|ML_BLOCKPROJECTILE))) + if (!(Projectile) || (ld->flags & (ML_BLOCKEVERYTHING | ML_BLOCKPROJECTILE))) { if (ld->flags & ML_RAILING) { rail = true; } - else if ((ld->flags & (ML_BLOCKING|ML_BLOCKEVERYTHING)) || // explicitly blocking everything + else if ((ld->flags & (ML_BLOCKING | ML_BLOCKEVERYTHING)) || // explicitly blocking everything (!(NotBlocked) && (ld->flags & ML_BLOCKMONSTERS)) || // block monsters only (tm.thing->player != NULL && (ld->flags & ML_BLOCK_PLAYERS)) || // block players ((Projectile) && (ld->flags & ML_BLOCKPROJECTILE)) || // block projectiles @@ -677,21 +677,21 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) { if (tm.thing->flags2 & MF2_BLASTED) { - P_DamageMobj (tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); + P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); } tm.thing->BlockingLine = ld; // Calculate line side based on the actor's original position, not the new one. - CheckForPushSpecial (ld, P_PointOnLineSide(tm.thing->x, tm.thing->y, ld), tm.thing, false); + CheckForPushSpecial(ld, P_PointOnLineSide(tm.thing->x, tm.thing->y, ld), tm.thing, false); return false; } } // [RH] Steep sectors count as dropoffs (unless already in one) if (!(tm.thing->flags & MF_DROPOFF) && - !(tm.thing->flags & (MF_NOGRAVITY|MF_NOCLIP))) + !(tm.thing->flags & (MF_NOGRAVITY | MF_NOCLIP))) { secplane_t frontplane = ld->frontsector->floorplane; - secplane_t backplane = ld->backsector->floorplane; + secplane_t backplane = ld->backsector->floorplane; #ifdef _3DFLOORS // Check 3D floors as well frontplane = P_FindFloorPlane(ld->frontsector, tm.thing->x, tm.thing->y, tm.thing->floorz); @@ -719,57 +719,57 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) } } - fixed_t sx=0, sy=0; + fixed_t sx = 0, sy = 0; FLineOpening open; // set openrange, opentop, openbottom if ((((ld->frontsector->floorplane.a | ld->frontsector->floorplane.b) | - (ld->backsector->floorplane.a | ld->backsector->floorplane.b) | - (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | - (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) - && ld->backsector->e->XFloor.ffloors.Size()==0 && ld->frontsector->e->XFloor.ffloors.Size()==0) + (ld->backsector->floorplane.a | ld->backsector->floorplane.b) | + (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | + (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) == 0) + && ld->backsector->e->XFloor.ffloors.Size() == 0 && ld->frontsector->e->XFloor.ffloors.Size() == 0) { - P_LineOpening (open, tm.thing, ld, sx=tm.x, sy=tm.y, tm.x, tm.y); + P_LineOpening(open, tm.thing, ld, sx = tm.x, sy = tm.y, tm.x, tm.y); } else { // Find the point on the line closest to the actor's center, and use - // that to calculate openings + // that to calculate openings float dx = (float)ld->dx; float dy = (float)ld->dy; fixed_t r = (fixed_t)(((float)(tm.x - ld->v1->x) * dx + - (float)(tm.y - ld->v1->y) * dy) / - (dx*dx + dy*dy) * 16777216.f); -/* Printf ("%d:%d: %d (%d %d %d %d) (%d %d %d %d)\n", level.time, ld-lines, r, - ld->frontsector->floorplane.a, - ld->frontsector->floorplane.b, - ld->frontsector->floorplane.c, - ld->frontsector->floorplane.ic, - ld->backsector->floorplane.a, - ld->backsector->floorplane.b, - ld->backsector->floorplane.c, - ld->backsector->floorplane.ic);*/ + (float)(tm.y - ld->v1->y) * dy) / + (dx*dx + dy*dy) * 16777216.f); + /* Printf ("%d:%d: %d (%d %d %d %d) (%d %d %d %d)\n", level.time, ld-lines, r, + ld->frontsector->floorplane.a, + ld->frontsector->floorplane.b, + ld->frontsector->floorplane.c, + ld->frontsector->floorplane.ic, + ld->backsector->floorplane.a, + ld->backsector->floorplane.b, + ld->backsector->floorplane.c, + ld->backsector->floorplane.ic);*/ if (r <= 0) { - P_LineOpening (open, tm.thing, ld, sx=ld->v1->x, sy=ld->v1->y, tm.x, tm.y); + P_LineOpening(open, tm.thing, ld, sx = ld->v1->x, sy = ld->v1->y, tm.x, tm.y); } - else if (r >= (1<<24)) + else if (r >= (1 << 24)) { - P_LineOpening (open, tm.thing, ld, sx=ld->v2->x, sy=ld->v2->y, tm.thing->x, tm.thing->y); + P_LineOpening(open, tm.thing, ld, sx = ld->v2->x, sy = ld->v2->y, tm.thing->x, tm.thing->y); } else { - P_LineOpening (open, tm.thing, ld, sx=ld->v1->x + MulScale24 (r, ld->dx), - sy=ld->v1->y + MulScale24 (r, ld->dy), tm.x, tm.y); + P_LineOpening(open, tm.thing, ld, sx = ld->v1->x + MulScale24(r, ld->dx), + sy = ld->v1->y + MulScale24(r, ld->dy), tm.x, tm.y); } // the floorplane on both sides is identical with the current one // so don't mess around with the z-position - if (ld->frontsector->floorplane==ld->backsector->floorplane && - ld->frontsector->floorplane==tm.thing->Sector->floorplane && + if (ld->frontsector->floorplane == ld->backsector->floorplane && + ld->frontsector->floorplane == tm.thing->Sector->floorplane && !ld->frontsector->e->XFloor.ffloors.Size() && !ld->backsector->e->XFloor.ffloors.Size() && !open.abovemidtex) { - open.bottom=INT_MIN; + open.bottom = INT_MIN; } /* Printf (" %d %d %d\n", sx, sy, openbottom);*/ } @@ -783,9 +783,9 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) // from either side. How long until somebody reports this as a bug and I'm // forced to say, "It's not a bug. It's a feature?" Ugh. (!(level.flags2 & LEVEL2_RAILINGHACK) || - open.bottom == tm.thing->Sector->floorplane.ZatPoint (sx, sy))) + open.bottom == tm.thing->Sector->floorplane.ZatPoint(sx, sy))) { - open.bottom += 32*FRACUNIT; + open.bottom += 32 * FRACUNIT; } // adjust floor / ceiling heights @@ -815,11 +815,11 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) if (open.lowfloor < tm.dropoffz) tm.dropoffz = open.lowfloor; - + // if contacted a special line, add it to the list if (ld->special) { - spechit.Push (ld); + spechit.Push(ld); } return true; @@ -831,24 +831,24 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) // //========================================================================== -bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) +bool PIT_CheckThing(AActor *thing, FCheckPosition &tm) { fixed_t topz; bool solid; int damage; - if (!((thing->flags & (MF_SOLID|MF_SPECIAL|MF_SHOOTABLE)) || thing->flags6 & MF6_TOUCHY)) + if (!((thing->flags & (MF_SOLID | MF_SPECIAL | MF_SHOOTABLE)) || thing->flags6 & MF6_TOUCHY)) return true; // can't hit thing fixed_t blockdist = thing->radius + tm.thing->radius; - if ( abs(thing->x - tm.x) >= blockdist || abs(thing->y - tm.y) >= blockdist) + if (abs(thing->x - tm.x) >= blockdist || abs(thing->y - tm.y) >= blockdist) return true; // don't clip against self if (thing == tm.thing) return true; - if ((thing->flags2 | tm.thing->flags2) & MF2_THRUACTORS) + if ((thing->flags2 | tm.thing->flags2) & MF2_THRUACTORS) return true; if ((tm.thing->flags6 & MF6_THRUSPECIES) && (tm.thing->GetSpecies() == thing->GetSpecies())) @@ -856,7 +856,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) tm.thing->BlockingMobj = thing; topz = thing->z + thing->height; - if (!(i_compatflags & COMPATF_NO_PASSMOBJ) && !(tm.thing->flags & (MF_FLOAT|MF_MISSILE|MF_SKULLFLY|MF_NOGRAVITY)) && + if (!(i_compatflags & COMPATF_NO_PASSMOBJ) && !(tm.thing->flags & (MF_FLOAT | MF_MISSILE | MF_SKULLFLY | MF_NOGRAVITY)) && (thing->flags & MF_SOLID) && (thing->flags4 & MF4_ACTLIKEBRIDGE)) { // [RH] Let monsters walk on actors as well as floors @@ -868,8 +868,8 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // way to do this, so I restrict them to only walking on bridges instead. // Uncommenting the if here makes it almost impossible for them to walk on // anything, bridge or otherwise. -// if (abs(thing->x - tmx) <= thing->radius && -// abs(thing->y - tmy) <= thing->radius) + // if (abs(thing->x - tmx) <= thing->radius && + // abs(thing->y - tmy) <= thing->radius) { tm.stepthing = thing; tm.floorz = topz; @@ -897,7 +897,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { // ... but not if they did not overlap in z-direction before but would after the move. unblocking = !((tm.thing->z >= thing->z + thing->height && tm.z < thing->z + thing->height) || - (tm.thing->z + tm.thing->height <= thing->z && tm.z + tm.thing->height > thing->z)); + (tm.thing->z + tm.thing->height <= thing->z && tm.z + tm.thing->height > thing->z)); } } } @@ -957,7 +957,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // Check for skulls slamming into things if (tm.thing->flags & MF_SKULLFLY) { - bool res = tm.thing->Slam (tm.thing->BlockingMobj); + bool res = tm.thing->Slam(tm.thing->BlockingMobj); tm.thing->BlockingMobj = NULL; return res; } @@ -980,15 +980,15 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // ideally this should take the mass factor into account thing->velx += tm.thing->velx; thing->vely += tm.thing->vely; - if ((thing->velx + thing->vely) > 3*FRACUNIT) + if ((thing->velx + thing->vely) > 3 * FRACUNIT) { int newdam; damage = (tm.thing->Mass / 100) + 1; - newdam = P_DamageMobj (thing, tm.thing, tm.thing, damage, tm.thing->DamageType); - P_TraceBleed (newdam > 0 ? newdam : damage, thing, tm.thing); + newdam = P_DamageMobj(thing, tm.thing, tm.thing, damage, tm.thing->DamageType); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, tm.thing); damage = (thing->Mass / 100) + 1; - newdam = P_DamageMobj (tm.thing, thing, thing, damage >> 2, tm.thing->DamageType); - P_TraceBleed (newdam > 0 ? newdam : damage, tm.thing, thing); + newdam = P_DamageMobj(tm.thing, thing, thing, damage >> 2, tm.thing->DamageType); + P_TraceBleed(newdam > 0 ? newdam : damage, tm.thing, thing); } return false; } @@ -1007,7 +1007,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) return true; } - if ((tm.thing->flags6 & MF6_MTHRUSPECIES) + if ((tm.thing->flags6 & MF6_MTHRUSPECIES) && tm.thing->target // NULL pointer check && (tm.thing->target->GetSpecies() == thing->GetSpecies())) return true; @@ -1019,8 +1019,8 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) } int clipheight; - - if (thing->projectilepassheight > 0) + + if (thing->projectilepassheight > 0) { clipheight = thing->projectilepassheight; } @@ -1038,7 +1038,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { // Over thing return true; } - if (tm.thing->z+tm.thing->height < thing->z) + if (tm.thing->z + tm.thing->height < thing->z) { // Under thing return true; } @@ -1051,7 +1051,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) return (tm.thing->target == thing || !(thing->flags & MF_SOLID)); } - switch (tm.thing->SpecialMissileHit (thing)) + switch (tm.thing->SpecialMissileHit(thing)) { case 0: return false; case 1: return true; @@ -1063,7 +1063,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // [Graf Zahl] Why do I have the feeling that this didn't really work anymore now // that ZDoom supports friendly monsters? - + if (tm.thing->target != NULL) { @@ -1077,10 +1077,10 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) if (!thing->player && !tm.thing->target->player) { int infight; - if (level.flags2 & LEVEL2_TOTALINFIGHTING) infight=1; - else if (level.flags2 & LEVEL2_NOINFIGHTING) infight=-1; + if (level.flags2 & LEVEL2_TOTALINFIGHTING) infight = 1; + else if (level.flags2 & LEVEL2_NOINFIGHTING) infight = -1; else infight = infighting; - + if (infight < 0) { // -1: Monsters cannot hurt each other, but make exceptions for @@ -1092,7 +1092,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) if (thing->flags3 & MF3_ISMONSTER) { // Monsters that are clearly hostile can always hurt each other - if (!thing->IsHostile (tm.thing->target)) + if (!thing->IsHostile(tm.thing->target)) { // The same if the shooter hates the target if (thing->tid == 0 || tm.thing->target->TIDtoHate != thing->tid) @@ -1107,7 +1107,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { // 0: Monsters cannot hurt same species except // cases where they are clearly supposed to do that - if (thing->IsFriend (tm.thing->target)) + if (thing->IsFriend(tm.thing->target)) { // Friends never harm each other return false; @@ -1121,7 +1121,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) { // Don't hurt same species or any relative - // but only if the target isn't one's hostile. - if (!thing->IsHostile (tm.thing->target)) + if (!thing->IsHostile(tm.thing->target)) { // Allow hurting monsters the shooter hates. if (thing->tid == 0 || tm.thing->target->TIDtoHate != thing->tid) @@ -1152,11 +1152,11 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) if (!(thing->flags & MF_NOBLOOD) && !(thing->flags2 & MF2_REFLECTIVE) && !(tm.thing->flags3 & MF3_BLOODLESSIMPACT) && - !(thing->flags2 & (MF2_INVULNERABLE|MF2_DORMANT))) + !(thing->flags2 & (MF2_INVULNERABLE | MF2_DORMANT))) { // Ok to spawn blood - P_RipperBlood (tm.thing, thing); + P_RipperBlood(tm.thing, thing); } - S_Sound (tm.thing, CHAN_BODY, "misc/ripslop", 1, ATTN_IDLE); + S_Sound(tm.thing, CHAN_BODY, "misc/ripslop", 1, ATTN_IDLE); // Do poisoning (if using new style poison) if (tm.thing->PoisonDamage > 0 && tm.thing->PoisonDuration != INT_MIN) @@ -1164,11 +1164,11 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) P_PoisonMobj(thing, tm.thing, tm.thing->target, tm.thing->PoisonDamage, tm.thing->PoisonDuration, tm.thing->PoisonPeriod, tm.thing->PoisonDamageType); } - damage = tm.thing->GetMissileDamage (3, 2); - int newdam = P_DamageMobj (thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); + damage = tm.thing->GetMissileDamage(3, 2); + int newdam = P_DamageMobj(thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT)) { - P_TraceBleed (newdam > 0 ? newdam : damage, thing, tm.thing); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, tm.thing); } if (thing->flags2 & MF2_PUSHABLE && !(tm.thing->flags2 & MF2_CANNOTPUSH)) @@ -1181,7 +1181,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) } } } - spechit.Clear (); + spechit.Clear(); return true; } } @@ -1193,30 +1193,30 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) } // Do damage - damage = tm.thing->GetMissileDamage ((tm.thing->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1); - if ((damage > 0) || (tm.thing->flags6 & MF6_FORCEPAIN)) + damage = tm.thing->GetMissileDamage((tm.thing->flags4 & MF4_STRIFEDAMAGE) ? 3 : 7, 1); + if ((damage > 0) || (tm.thing->flags6 & MF6_FORCEPAIN)) { - int newdam = P_DamageMobj (thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); + int newdam = P_DamageMobj(thing, tm.thing, tm.thing->target, damage, tm.thing->DamageType); if (damage > 0) { if ((tm.thing->flags5 & MF5_BLOODSPLATTER) && !(thing->flags & MF_NOBLOOD) && !(thing->flags2 & MF2_REFLECTIVE) && - !(thing->flags2 & (MF2_INVULNERABLE|MF2_DORMANT)) && + !(thing->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)) && !(tm.thing->flags3 & MF3_BLOODLESSIMPACT) && (pr_checkthing() < 192)) { - P_BloodSplatter (tm.thing->x, tm.thing->y, tm.thing->z, thing); + P_BloodSplatter(tm.thing->x, tm.thing->y, tm.thing->z, thing); } if (!(tm.thing->flags3 & MF3_BLOODLESSIMPACT)) { - P_TraceBleed (newdam > 0 ? newdam : damage, thing, tm.thing); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, tm.thing); } } } else { - P_GiveBody (thing, -damage); + P_GiveBody(thing, -damage); } return false; // don't traverse any more } @@ -1230,8 +1230,8 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) } } solid = (thing->flags & MF_SOLID) && - !(thing->flags & MF_NOCLIP) && - ((tm.thing->flags & MF_SOLID) || (tm.thing->flags6 & MF6_BLOCKEDBYSOLIDACTORS)); + !(thing->flags & MF_NOCLIP) && + ((tm.thing->flags & MF_SOLID) || (tm.thing->flags6 & MF6_BLOCKEDBYSOLIDACTORS)); // Check for special pickup if ((thing->flags & MF_SPECIAL) && (tm.thing->flags & MF_PICKUP) @@ -1240,7 +1240,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // up things that are above your true height. && thing->z < tm.thing->z + tm.thing->height - tm.thing->MaxStepHeight) { // Can be picked up by tmthing - P_TouchSpecialThing (thing, tm.thing); // can remove thing + P_TouchSpecialThing(thing, tm.thing); // can remove thing } // killough 3/16/98: Allow non-solid moving objects to move through solid @@ -1258,7 +1258,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) /* =============================================================================== - MOVEMENT CLIPPING +MOVEMENT CLIPPING =============================================================================== */ @@ -1290,7 +1290,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) // //========================================================================== -bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bool actorsonly) +bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bool actorsonly) { sector_t *newsec; AActor *thingblocker; @@ -1301,13 +1301,13 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b tm.x = x; tm.y = y; - newsec = P_PointInSector (x,y); + newsec = P_PointInSector(x, y); tm.ceilingline = thing->BlockingLine = NULL; - -// The base floor / ceiling is from the subsector that contains the point. -// Any contacted lines the step closer together will adjust them. - tm.floorz = tm.dropoffz = newsec->floorplane.ZatPoint (x, y); - tm.ceilingz = newsec->ceilingplane.ZatPoint (x, y); + + // The base floor / ceiling is from the subsector that contains the point. + // Any contacted lines the step closer together will adjust them. + tm.floorz = tm.dropoffz = newsec->floorplane.ZatPoint(x, y); + tm.ceilingz = newsec->ceilingplane.ZatPoint(x, y); tm.floorpic = newsec->GetTexture(sector_t::floor); tm.floorsector = newsec; tm.ceilingpic = newsec->GetTexture(sector_t::ceiling); @@ -1317,7 +1317,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b //Added by MC: Fill the tmsector. tm.sector = newsec; - + #ifdef _3DFLOORS //Check 3D floors if (!thing->IsNoClip2() && newsec->e->XFloor.ffloors.Size()) @@ -1325,25 +1325,25 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b F3DFloor* rover; fixed_t delta1; fixed_t delta2; - int thingtop = thing->z + (thing->height==0? 1:thing->height); - - for(unsigned i=0;ie->XFloor.ffloors.Size();i++) + int thingtop = thing->z + (thing->height == 0 ? 1 : thing->height); + + for (unsigned i = 0; ie->XFloor.ffloors.Size(); i++) { rover = newsec->e->XFloor.ffloors[i]; - if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(x, y); - fixed_t ff_top=rover->top.plane->ZatPoint(x, y); - - delta1 = thing->z - (ff_bottom + ((ff_top-ff_bottom)/2)); - delta2 = thingtop - (ff_bottom + ((ff_top-ff_bottom)/2)); + fixed_t ff_bottom = rover->bottom.plane->ZatPoint(x, y); + fixed_t ff_top = rover->top.plane->ZatPoint(x, y); - if(ff_top > tm.floorz && abs(delta1) < abs(delta2)) + delta1 = thing->z - (ff_bottom + ((ff_top - ff_bottom) / 2)); + delta2 = thingtop - (ff_bottom + ((ff_top - ff_bottom) / 2)); + + if (ff_top > tm.floorz && abs(delta1) < abs(delta2)) { tm.floorz = tm.dropoffz = ff_top; tm.floorpic = *rover->top.texture; } - if(ff_bottom < tm.ceilingz && abs(delta1) >= abs(delta2)) + if (ff_bottom < tm.ceilingz && abs(delta1) >= abs(delta2)) { tm.ceilingz = ff_bottom; tm.ceilingpic = *rover->bottom.texture; @@ -1351,13 +1351,13 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b } } #endif - + validcount++; - spechit.Clear (); + spechit.Clear(); if ((thing->flags & MF_NOCLIP) && !(thing->flags & MF_SKULLFLY)) return true; - + // Check things first, possibly picking things up. thing->BlockingMobj = NULL; thingblocker = NULL; @@ -1376,9 +1376,9 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b { if (!PIT_CheckThing(th, tm)) { // [RH] If a thing can be stepped up on, we need to continue checking - // other things in the blocks and see if we hit something that is - // definitely blocking. Otherwise, we need to check the lines, or we - // could end up stuck inside a wall. + // other things in the blocks and see if we hit something that is + // definitely blocking. Otherwise, we need to check the lines, or we + // could end up stuck inside a wall. AActor *BlockingMobj = thing->BlockingMobj; if (BlockingMobj == NULL || (i_compatflags & COMPATF_NO_PASSMOBJ)) @@ -1386,8 +1386,8 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b thing->height = realheight; return false; } - else if (!BlockingMobj->player && !(thing->flags & (MF_FLOAT|MF_MISSILE|MF_SKULLFLY)) && - BlockingMobj->z+BlockingMobj->height-thing->z <= thing->MaxStepHeight) + else if (!BlockingMobj->player && !(thing->flags & (MF_FLOAT | MF_MISSILE | MF_SKULLFLY)) && + BlockingMobj->z + BlockingMobj->height - thing->z <= thing->MaxStepHeight) { if (thingblocker == NULL || BlockingMobj->z > thingblocker->z) @@ -1401,7 +1401,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b { if (thingblocker) { // There is something to step up on. Return this thing as - // the blocker so that we don't step up. + // the blocker so that we don't step up. thing->height = realheight; return false; } @@ -1469,7 +1469,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, b return (thing->BlockingMobj = thingblocker) == NULL; } -bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, bool actorsonly) +bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, bool actorsonly) { FCheckPosition tm; return P_CheckPosition(thing, x, y, tm, actorsonly); @@ -1484,7 +1484,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, bool actorsonly) // //---------------------------------------------------------------------------- -bool P_TestMobjLocation (AActor *mobj) +bool P_TestMobjLocation(AActor *mobj) { int flags; @@ -1511,15 +1511,15 @@ bool P_TestMobjLocation (AActor *mobj) // Checks if the new Z position is legal //============================================================================= -AActor *P_CheckOnmobj (AActor *thing) +AActor *P_CheckOnmobj(AActor *thing) { fixed_t oldz; bool good; AActor *onmobj; oldz = thing->z; - P_FakeZMovement (thing); - good = P_TestMobjZ (thing, false, &onmobj); + P_FakeZMovement(thing); + good = P_TestMobjZ(thing, false, &onmobj); thing->z = oldz; return good ? NULL : onmobj; @@ -1531,7 +1531,7 @@ AActor *P_CheckOnmobj (AActor *thing) // //============================================================================= -bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) +bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) { AActor *onmobj = NULL; if (actor->flags & MF_NOCLIP) @@ -1561,7 +1561,7 @@ bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) { // Can't hit thing continue; } - if (thing->flags & (MF_SPECIAL|MF_NOCLIP)) + if (thing->flags & (MF_SPECIAL | MF_NOCLIP)) { // [RH] Specials and noclippers don't block moves continue; } @@ -1582,11 +1582,11 @@ bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) { // Don't clip against whoever shot the missile. continue; } - if (actor->z > thing->z+thing->height) + if (actor->z > thing->z + thing->height) { // over thing continue; } - else if (actor->z+actor->height <= thing->z) + else if (actor->z + actor->height <= thing->z) { // under thing continue; } @@ -1609,32 +1609,32 @@ bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) // Fake the zmovement so that we can check if a move is legal //============================================================================= -void P_FakeZMovement (AActor *mo) +void P_FakeZMovement(AActor *mo) { -// -// adjust height -// + // + // adjust height + // mo->z += mo->velz; if ((mo->flags&MF_FLOAT) && mo->target) { // float down towards target if too close if (!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT)) { - fixed_t dist = P_AproxDistance (mo->x - mo->target->x, mo->y - mo->target->y); - fixed_t delta = (mo->target->z + (mo->height>>1)) - mo->z; - if (delta < 0 && dist < -(delta*3)) + fixed_t dist = P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y); + fixed_t delta = (mo->target->z + (mo->height >> 1)) - mo->z; + if (delta < 0 && dist < -(delta * 3)) mo->z -= mo->FloatSpeed; - else if (delta > 0 && dist < (delta*3)) + else if (delta > 0 && dist < (delta * 3)) mo->z += mo->FloatSpeed; } } if (mo->player && mo->flags&MF_NOGRAVITY && (mo->z > mo->floorz) && !mo->IsNoClip2()) { - mo->z += finesine[(FINEANGLES/80*level.maptime)&FINEMASK]/8; + mo->z += finesine[(FINEANGLES / 80 * level.maptime)&FINEMASK] / 8; } -// -// clip movement -// + // + // clip movement + // if (mo->z <= mo->floorz) { // hit the floor mo->z = mo->floorz; @@ -1652,13 +1652,13 @@ void P_FakeZMovement (AActor *mo) // //=========================================================================== -static void CheckForPushSpecial (line_t *line, int side, AActor *mobj, bool windowcheck) +static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, bool windowcheck) { if (line->special && !(mobj->flags6 & MF6_NOTRIGGER)) { if (windowcheck && !(ib_compatflags & BCOMPATF_NOWINDOWCHECK) && line->backsector != NULL) { // Make sure this line actually blocks us and is not a window - // or similar construct we are standing inside of. + // or similar construct we are standing inside of. fixed_t fzt = line->frontsector->ceilingplane.ZatPoint(mobj->x, mobj->y); fixed_t fzb = line->frontsector->floorplane.ZatPoint(mobj->x, mobj->y); fixed_t bzt = line->backsector->ceilingplane.ZatPoint(mobj->x, mobj->y); @@ -1667,29 +1667,29 @@ static void CheckForPushSpecial (line_t *line, int side, AActor *mobj, bool wind fzb <= mobj->z && bzb <= mobj->z) { // we must also check if some 3D floor in the backsector may be blocking - #ifdef _3DFLOORS - for(unsigned int i=0;ibacksector->e->XFloor.ffloors.Size();i++) +#ifdef _3DFLOORS + for (unsigned int i = 0; ibacksector->e->XFloor.ffloors.Size(); i++) + { + F3DFloor* rover = line->backsector->e->XFloor.ffloors[i]; + + if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + + fixed_t ff_bottom = rover->bottom.plane->ZatPoint(mobj->x, mobj->y); + fixed_t ff_top = rover->top.plane->ZatPoint(mobj->x, mobj->y); + + if (ff_bottom < mobj->z + mobj->height && ff_top > mobj->z) { - F3DFloor* rover = line->backsector->e->XFloor.ffloors[i]; - - if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - - fixed_t ff_bottom = rover->bottom.plane->ZatPoint(mobj->x, mobj->y); - fixed_t ff_top = rover->top.plane->ZatPoint(mobj->x, mobj->y); - - if (ff_bottom < mobj->z + mobj->height && ff_top > mobj->z) - { - goto isblocking; - } + goto isblocking; } - #endif + } +#endif return; } } -isblocking: + isblocking: if (mobj->flags2 & MF2_PUSHWALL) { - P_ActivateLine (line, mobj, side, SPAC_Push); + P_ActivateLine(line, mobj, side, SPAC_Push); } else if (mobj->flags2 & MF2_IMPACT) { @@ -1697,13 +1697,13 @@ isblocking: !(mobj->flags & MF_MISSILE) || (mobj->target == NULL)) { - P_ActivateLine (line, mobj, side, SPAC_Impact); + P_ActivateLine(line, mobj, side, SPAC_Impact); } else { - P_ActivateLine (line, mobj->target, side, SPAC_Impact); + P_ActivateLine(line, mobj->target, side, SPAC_Impact); } - } + } } } @@ -1715,11 +1715,11 @@ isblocking: // //========================================================================== -bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, - int dropoff, // killough 3/15/98: allow dropoff as option - const secplane_t *onfloor, // [RH] Let P_TryMove keep the thing on the floor - FCheckPosition &tm, - bool missileCheck) // [GZ] Fired missiles ignore the drop-off test +bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, + int dropoff, // killough 3/15/98: allow dropoff as option + const secplane_t *onfloor, // [RH] Let P_TryMove keep the thing on the floor + FCheckPosition &tm, + bool missileCheck) // [GZ] Fired missiles ignore the drop-off test { fixed_t oldx; fixed_t oldy; @@ -1734,10 +1734,10 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, oldz = thing->z; if (onfloor) { - thing->z = onfloor->ZatPoint (x, y); + thing->z = onfloor->ZatPoint(x, y); } thing->flags6 |= MF6_INTRYMOVE; - if (!P_CheckPosition (thing, x, y, tm)) + if (!P_CheckPosition(thing, x, y, tm)) { AActor *BlockingMobj = thing->BlockingMobj; // Solid wall or thing @@ -1751,11 +1751,11 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { goto pushline; } - else if (BlockingMobj->z+BlockingMobj->height-thing->z + else if (BlockingMobj->z + BlockingMobj->height - thing->z > thing->MaxStepHeight - || (BlockingMobj->Sector->ceilingplane.ZatPoint (x, y) - - (BlockingMobj->z+BlockingMobj->height) < thing->height) - || (tm.ceilingz-(BlockingMobj->z+BlockingMobj->height) + || (BlockingMobj->Sector->ceilingplane.ZatPoint(x, y) + - (BlockingMobj->z + BlockingMobj->height) < thing->height) + || (tm.ceilingz - (BlockingMobj->z + BlockingMobj->height) < thing->height)) { goto pushline; @@ -1790,7 +1790,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, } tm.floatok = true; - + if (!(thing->flags & MF_TELEPORT) && tm.ceilingz - thing->z < thing->height && !(thing->flags3 & MF3_CEILINGHUGGER) @@ -1801,19 +1801,19 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, if (thing->flags2 & MF2_FLY && thing->flags & MF_NOGRAVITY) { #if 1 - if (thing->z+thing->height > tm.ceilingz) + if (thing->z + thing->height > tm.ceilingz) goto pushline; #else // When flying, slide up or down blocking lines until the actor // is not blocked. - if (thing->z+thing->height > tm.ceilingz) + if (thing->z + thing->height > tm.ceilingz) { - thing->velz = -8*FRACUNIT; + thing->velz = -8 * FRACUNIT; goto pushline; } - else if (thing->z < tm.floorz && tm.floorz-tm.dropoffz > thing->MaxDropOffHeight) + else if (thing->z < tm.floorz && tm.floorz - tm.dropoffz > thing->MaxDropOffHeight) { - thing->velz = 8*FRACUNIT; + thing->velz = 8 * FRACUNIT; goto pushline; } #endif @@ -1824,7 +1824,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { // [RH] Don't let normal missiles climb steps goto pushline; } - if (tm.floorz-thing->z > thing->MaxStepHeight) + if (tm.floorz - thing->z > thing->MaxStepHeight) { // too big a step up goto pushline; } @@ -1833,7 +1833,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, fixed_t savedz = thing->z; bool good; thing->z = tm.floorz; - good = P_TestMobjZ (thing); + good = P_TestMobjZ(thing); thing->z = savedz; if (!good) { @@ -1848,7 +1848,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, // If it's a bouncer, let it bounce off its new floor, too. if (thing->BounceFlags & BOUNCE_Floors) { - thing->FloorBounceMissile (tm.floorsector->floorplane); + thing->FloorBounceMissile(tm.floorsector->floorplane); } else { @@ -1866,15 +1866,15 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, dropoff = false; } - if (dropoff==2 && // large jump down (e.g. dogs) - (tm.floorz-tm.dropoffz > 128*FRACUNIT || thing->target == NULL || thing->target->z >tm.dropoffz)) + if (dropoff == 2 && // large jump down (e.g. dogs) + (tm.floorz - tm.dropoffz > 128 * FRACUNIT || thing->target == NULL || thing->target->z >tm.dropoffz)) { dropoff = false; } // killough 3/15/98: Allow certain objects to drop off - if ((!dropoff && !(thing->flags & (MF_DROPOFF|MF_FLOAT|MF_MISSILE))) || (thing->flags5&MF5_NODROPOFF)) + if ((!dropoff && !(thing->flags & (MF_DROPOFF | MF_FLOAT | MF_MISSILE))) || (thing->flags5&MF5_NODROPOFF)) { if (!(thing->flags5&MF5_AVOIDINGDROPOFF)) { @@ -1885,11 +1885,11 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { floorz = MAX(thing->z, tm.floorz); } - + if (floorz - tm.dropoffz > thing->MaxDropOffHeight && - !(thing->flags2 & MF2_BLASTED) && !missileCheck) + !(thing->flags2 & MF2_BLASTED) && !missileCheck) { // Can't move over a dropoff unless it's been blasted - // [GZ] Or missile-spawned + // [GZ] Or missile-spawned thing->z = oldz; thing->flags6 &= ~MF6_INTRYMOVE; return false; @@ -1909,18 +1909,18 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, } if (thing->flags2 & MF2_CANTLEAVEFLOORPIC && (tm.floorpic != thing->floorpic - || tm.floorz - thing->z != 0)) + || tm.floorz - thing->z != 0)) { // must stay within a sector of a certain floor type thing->z = oldz; thing->flags6 &= ~MF6_INTRYMOVE; return false; } - + //Added by MC: To prevent bot from getting into dangerous sectors. if (thing->player && thing->player->isbot && thing->flags & MF_SHOOTABLE) { if (tm.sector != thing->Sector - && bglobal.IsDangerous (tm.sector)) + && bglobal.IsDangerous(tm.sector)) { thing->player->prev = thing->player->dest; thing->player->dest = NULL; @@ -1930,7 +1930,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, thing->flags6 &= ~MF6_INTRYMOVE; return false; } - } + } } // [RH] Check status of eyes against fake floor/ceiling in case @@ -1938,7 +1938,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, bool oldAboveFakeFloor, oldAboveFakeCeiling; fixed_t viewheight; - + viewheight = thing->player ? thing->player->viewheight : thing->height / 2; oldAboveFakeFloor = oldAboveFakeCeiling = false; // pacify GCC @@ -1946,21 +1946,21 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { fixed_t eyez = oldz + viewheight; - oldAboveFakeFloor = eyez > oldsec->heightsec->floorplane.ZatPoint (thing->x, thing->y); - oldAboveFakeCeiling = eyez > oldsec->heightsec->ceilingplane.ZatPoint (thing->x, thing->y); + oldAboveFakeFloor = eyez > oldsec->heightsec->floorplane.ZatPoint(thing->x, thing->y); + oldAboveFakeCeiling = eyez > oldsec->heightsec->ceilingplane.ZatPoint(thing->x, thing->y); } // Borrowed from MBF: if (thing->BounceFlags & BOUNCE_MBF && // killough 8/13/98 - !(thing->flags & (MF_MISSILE|MF_NOGRAVITY)) && - !thing->IsSentient() && tm.floorz - thing->z > 16*FRACUNIT) + !(thing->flags & (MF_MISSILE | MF_NOGRAVITY)) && + !thing->IsSentient() && tm.floorz - thing->z > 16 * FRACUNIT) { // too big a step up for MBF bouncers under gravity thing->flags6 &= ~MF6_INTRYMOVE; return false; } // the move is ok, so link the thing into its new position - thing->UnlinkFromWorld (); + thing->UnlinkFromWorld(); oldx = thing->x; oldy = thing->y; @@ -1974,11 +1974,11 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, thing->x = x; thing->y = y; - thing->LinkToWorld (); + thing->LinkToWorld(); if (thing->flags2 & MF2_FLOORCLIP) { - thing->AdjustFloorClip (); + thing->AdjustFloorClip(); } // [RH] Don't activate anything if just predicting @@ -1989,36 +1989,36 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, } // if any special lines were hit, do the effect - if (!(thing->flags & (MF_TELEPORT|MF_NOCLIP))) + if (!(thing->flags & (MF_TELEPORT | MF_NOCLIP))) { - while (spechit.Pop (ld)) + while (spechit.Pop(ld)) { // see if the line was crossed - side = P_PointOnLineSide (thing->x, thing->y, ld); - oldside = P_PointOnLineSide (oldx, oldy, ld); + side = P_PointOnLineSide(thing->x, thing->y, ld); + oldside = P_PointOnLineSide(oldx, oldy, ld); if (side != oldside && ld->special && !(thing->flags6 & MF6_NOTRIGGER)) { if (thing->player) { - P_ActivateLine (ld, thing, oldside, SPAC_Cross); + P_ActivateLine(ld, thing, oldside, SPAC_Cross); } else if (thing->flags2 & MF2_MCROSS) { - P_ActivateLine (ld, thing, oldside, SPAC_MCross); + P_ActivateLine(ld, thing, oldside, SPAC_MCross); } else if (thing->flags2 & MF2_PCROSS) { - P_ActivateLine (ld, thing, oldside, SPAC_PCross); + P_ActivateLine(ld, thing, oldside, SPAC_PCross); } else if ((ld->special == Teleport || - ld->special == Teleport_NoFog || - ld->special == Teleport_Line)) + ld->special == Teleport_NoFog || + ld->special == Teleport_Line)) { // [RH] Just a little hack for BOOM compatibility - P_ActivateLine (ld, thing, oldside, SPAC_MCross); + P_ActivateLine(ld, thing, oldside, SPAC_MCross); } else { - P_ActivateLine (ld, thing, oldside, SPAC_AnyCross); + P_ActivateLine(ld, thing, oldside, SPAC_AnyCross); } } } @@ -2030,27 +2030,27 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, { const sector_t *hs = newsec->heightsec; fixed_t eyez = thing->z + viewheight; - fixed_t fakez = hs->floorplane.ZatPoint (x, y); + fixed_t fakez = hs->floorplane.ZatPoint(x, y); if (!oldAboveFakeFloor && eyez > fakez) { // View went above fake floor - newsec->SecActTarget->TriggerAction (thing, SECSPAC_EyesSurface); + newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesSurface); } else if (oldAboveFakeFloor && eyez <= fakez) { // View went below fake floor - newsec->SecActTarget->TriggerAction (thing, SECSPAC_EyesDive); + newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesDive); } if (!(hs->MoreFlags & SECF_FAKEFLOORONLY)) { - fakez = hs->ceilingplane.ZatPoint (x, y); + fakez = hs->ceilingplane.ZatPoint(x, y); if (!oldAboveFakeCeiling && eyez > fakez) { // View went above fake ceiling - newsec->SecActTarget->TriggerAction (thing, SECSPAC_EyesAboveC); + newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesAboveC); } else if (oldAboveFakeCeiling && eyez <= fakez) { // View went below fake ceiling - newsec->SecActTarget->TriggerAction (thing, SECSPAC_EyesBelowC); + newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesBelowC); } } } @@ -2070,29 +2070,29 @@ pushline: } thing->z = oldz; - if (!(thing->flags&(MF_TELEPORT|MF_NOCLIP))) + if (!(thing->flags&(MF_TELEPORT | MF_NOCLIP))) { int numSpecHitTemp; if (tm.thing->flags2 & MF2_BLASTED) { - P_DamageMobj (tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); + P_DamageMobj(tm.thing, NULL, NULL, tm.thing->Mass >> 5, NAME_Melee); } - numSpecHitTemp = (int)spechit.Size (); + numSpecHitTemp = (int)spechit.Size(); while (numSpecHitTemp > 0) { // see which lines were pushed ld = spechit[--numSpecHitTemp]; - side = P_PointOnLineSide (thing->x, thing->y, ld); - CheckForPushSpecial (ld, side, thing, true); + side = P_PointOnLineSide(thing->x, thing->y, ld); + CheckForPushSpecial(ld, side, thing, true); } } return false; } -bool P_TryMove (AActor *thing, fixed_t x, fixed_t y, - int dropoff, // killough 3/15/98: allow dropoff as option - const secplane_t *onfloor) // [RH] Let P_TryMove keep the thing on the floor +bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, + int dropoff, // killough 3/15/98: allow dropoff as option + const secplane_t *onfloor) // [RH] Let P_TryMove keep the thing on the floor { FCheckPosition tm; return P_TryMove(thing, x, y, dropoff, onfloor, tm); @@ -2112,7 +2112,7 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) FCheckPosition tm; fixed_t newz = thing->z; - if (!P_CheckPosition (thing, x, y, tm)) + if (!P_CheckPosition(thing, x, y, tm)) { return false; } @@ -2142,12 +2142,12 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) } if (thing->flags2 & MF2_FLY && thing->flags & MF_NOGRAVITY) { - if (thing->z+thing->height > tm.ceilingz) + if (thing->z + thing->height > tm.ceilingz) return false; } if (!(thing->flags & MF_TELEPORT) && !(thing->flags3 & MF3_FLOORHUGGER)) { - if (tm.floorz-newz > thing->MaxStepHeight) + if (tm.floorz - newz > thing->MaxStepHeight) { // too big a step up return false; } @@ -2159,7 +2159,7 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) { // [RH] Check to make sure there's nothing in the way for the step up fixed_t savedz = thing->z; thing->z = newz = tm.floorz; - bool good = P_TestMobjZ (thing); + bool good = P_TestMobjZ(thing); thing->z = savedz; if (!good) { @@ -2170,7 +2170,7 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) if (thing->flags2 & MF2_CANTLEAVEFLOORPIC && (tm.floorpic != thing->floorpic - || tm.floorz - newz != 0)) + || tm.floorz - newz != 0)) { // must stay within a sector of a certain floor type return false; } @@ -2202,12 +2202,12 @@ struct FSlide fixed_t tmymove; void HitSlideLine(line_t *ld); - void SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); - void SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps); + void SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); + void SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps); // The bouncing code uses the same data structure - bool BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); - bool BounceWall (AActor *mo); + bool BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); + bool BounceWall(AActor *mo); }; //========================================================================== @@ -2219,17 +2219,17 @@ struct FSlide // //========================================================================== -void FSlide::HitSlideLine (line_t* ld) +void FSlide::HitSlideLine(line_t* ld) { int side; angle_t lineangle; angle_t moveangle; angle_t deltaangle; - + fixed_t movelen; bool icyfloor; // is floor icy? // phares - // | + // | // Under icy conditions, if the angle of approach to the wall // V // is more than 45 degrees, then you'll bounce and lose half // your velocity. If less than 45 degrees, you'll slide along @@ -2238,21 +2238,21 @@ void FSlide::HitSlideLine (line_t* ld) // Check for the special cases of horz or vert walls. // killough 10/98: only bounce if hit hard (prevents wobbling) - icyfloor = - (P_AproxDistance(tmxmove, tmymove) > 4*FRACUNIT) && + icyfloor = + (P_AproxDistance(tmxmove, tmymove) > 4 * FRACUNIT) && var_friction && // killough 8/28/98: calc friction on demand slidemo->z <= slidemo->floorz && - P_GetFriction (slidemo, NULL) > ORIG_FRICTION; + P_GetFriction(slidemo, NULL) > ORIG_FRICTION; if (ld->dx == 0) { // ST_VERTICAL if (icyfloor && (abs(tmxmove) > abs(tmymove))) { - tmxmove = -tmxmove/2; // absorb half the velocity + tmxmove = -tmxmove / 2; // absorb half the velocity tmymove /= 2; if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { - S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff!// ^ + S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff!// ^ } } // | else // phares @@ -2265,10 +2265,10 @@ void FSlide::HitSlideLine (line_t* ld) if (icyfloor && (abs(tmymove) > abs(tmxmove))) { tmxmove /= 2; // absorb half the velocity - tmymove = -tmymove/2; + tmymove = -tmymove / 2; if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { - S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! + S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! } } else @@ -2279,30 +2279,30 @@ void FSlide::HitSlideLine (line_t* ld) // The wall is angled. Bounce if the angle of approach is // phares // less than 45 degrees. // phares - side = P_PointOnLineSide (slidemo->x, slidemo->y, ld); + side = P_PointOnLineSide(slidemo->x, slidemo->y, ld); - lineangle = R_PointToAngle2 (0,0, ld->dx, ld->dy); + lineangle = R_PointToAngle2(0, 0, ld->dx, ld->dy); if (side == 1) lineangle += ANG180; - moveangle = R_PointToAngle2 (0,0, tmxmove, tmymove); + moveangle = R_PointToAngle2(0, 0, tmxmove, tmymove); moveangle += 10; // prevents sudden path reversal due to // phares - // rounding error // | - deltaangle = moveangle-lineangle; // V - movelen = P_AproxDistance (tmxmove, tmymove); - if (icyfloor && (deltaangle > ANG45) && (deltaangle < ANG90+ANG45)) + // rounding error // | + deltaangle = moveangle - lineangle; // V + movelen = P_AproxDistance(tmxmove, tmymove); + if (icyfloor && (deltaangle > ANG45) && (deltaangle < ANG90 + ANG45)) { moveangle = lineangle - deltaangle; movelen /= 2; // absorb if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { - S_Sound (slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! + S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! } moveangle >>= ANGLETOFINESHIFT; - tmxmove = FixedMul (movelen, finecosine[moveangle]); - tmymove = FixedMul (movelen, finesine[moveangle]); + tmxmove = FixedMul(movelen, finecosine[moveangle]); + tmymove = FixedMul(movelen, finesine[moveangle]); } // ^ else // | { // phares @@ -2311,7 +2311,7 @@ void FSlide::HitSlideLine (line_t* ld) if (i_compatflags & COMPATF_WALLRUN) { fixed_t newlen; - + if (deltaangle > ANG180) deltaangle += ANG180; // I_Error ("SlideLine: ang>ANG180"); @@ -2319,17 +2319,17 @@ void FSlide::HitSlideLine (line_t* ld) lineangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT; - newlen = FixedMul (movelen, finecosine[deltaangle]); + newlen = FixedMul(movelen, finecosine[deltaangle]); - tmxmove = FixedMul (newlen, finecosine[lineangle]); - tmymove = FixedMul (newlen, finesine[lineangle]); + tmxmove = FixedMul(newlen, finecosine[lineangle]); + tmymove = FixedMul(newlen, finesine[lineangle]); } else { divline_t dll, dlv; fixed_t inter1, inter2, inter3; - P_MakeDivline (ld, &dll); + P_MakeDivline(ld, &dll); dlv.x = slidemo->x; dlv.y = slidemo->y; @@ -2340,13 +2340,13 @@ void FSlide::HitSlideLine (line_t* ld) dlv.dx = tmxmove; dlv.dy = tmymove; - inter2 = P_InterceptVector (&dll, &dlv); - inter3 = P_InterceptVector (&dlv, &dll); + inter2 = P_InterceptVector(&dll, &dlv); + inter3 = P_InterceptVector(&dlv, &dll); if (inter3 != 0) { - tmxmove = Scale (inter2-inter1, dll.dx, inter3); - tmymove = Scale (inter2-inter1, dll.dy, inter3); + tmxmove = Scale(inter2 - inter1, dll.dx, inter3); + tmymove = Scale(inter2 - inter1, dll.dy, inter3); } else { @@ -2363,7 +2363,7 @@ void FSlide::HitSlideLine (line_t* ld) // //========================================================================== -void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) +void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) { FLineOpening open; FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES); @@ -2372,26 +2372,26 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ while ((in = it.Next())) { line_t* li; - + if (!in->isaline) { // should never happen - Printf ("PTR_SlideTraverse: not a line?"); + Printf("PTR_SlideTraverse: not a line?"); continue; } - + li = in->d.line; - - if ( !(li->flags & ML_TWOSIDED) || !li->backsector ) + + if (!(li->flags & ML_TWOSIDED) || !li->backsector) { - if (P_PointOnLineSide (slidemo->x, slidemo->y, li)) + if (P_PointOnLineSide(slidemo->x, slidemo->y, li)) { // don't hit the back side - continue; + continue; } goto isblocking; } - if (li->flags & (ML_BLOCKING|ML_BLOCKEVERYTHING)) + if (li->flags & (ML_BLOCKING | ML_BLOCKEVERYTHING)) { goto isblocking; } @@ -2406,12 +2406,12 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ } // set openrange, opentop, openbottom - P_LineOpening (open, slidemo, li, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); - + P_LineOpening(open, slidemo, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); + if (open.range < slidemo->height) goto isblocking; // doesn't fit - + if (open.top - slidemo->z < slidemo->height) goto isblocking; // mobj is too high @@ -2423,7 +2423,7 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ { // [RH] Check to make sure there's nothing in the way for the step up fixed_t savedz = slidemo->z; slidemo->z = open.bottom; - bool good = P_TestMobjZ (slidemo); + bool good = P_TestMobjZ(slidemo); slidemo->z = savedz; if (!good) { @@ -2432,11 +2432,11 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ } // this line doesn't block movement - continue; - + continue; + // the line does block movement, // see if it is closer than best so far - isblocking: + isblocking: if (in->frac < bestslidefrac) { secondslidefrac = bestslidefrac; @@ -2444,7 +2444,7 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ bestslidefrac = in->frac; bestslideline = li; } - + return; // stop } } @@ -2463,7 +2463,7 @@ void FSlide::SlideTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_ // //========================================================================== -void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) +void FSlide::SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) { fixed_t leadx, leady; fixed_t trailx, traily; @@ -2477,11 +2477,11 @@ void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) if (mo->player && mo->player->mo == mo && mo->reactiontime > 0) return; // player coming right out of a teleporter. - - retry: + +retry: if (!--hitcount) goto stairstep; // don't loop forever - + // trace along the three leading corners if (tryx > 0) { @@ -2505,42 +2505,42 @@ void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) traily = mo->y + mo->radius; } - bestslidefrac = FRACUNIT+1; - - SlideTraverse (leadx, leady, leadx+tryx, leady+tryy); - SlideTraverse (trailx, leady, trailx+tryx, leady+tryy); - SlideTraverse (leadx, traily, leadx+tryx, traily+tryy); + bestslidefrac = FRACUNIT + 1; + + SlideTraverse(leadx, leady, leadx + tryx, leady + tryy); + SlideTraverse(trailx, leady, trailx + tryx, leady + tryy); + SlideTraverse(leadx, traily, leadx + tryx, traily + tryy); // move up to the wall - if (bestslidefrac == FRACUNIT+1) + if (bestslidefrac == FRACUNIT + 1) { // the move must have hit the middle, so stairstep - stairstep: + stairstep: // killough 3/15/98: Allow objects to drop off ledges xmove = 0, ymove = tryy; - walkplane = P_CheckSlopeWalk (mo, xmove, ymove); - if (!P_TryMove (mo, mo->x + xmove, mo->y + ymove, true, walkplane)) + walkplane = P_CheckSlopeWalk(mo, xmove, ymove); + if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true, walkplane)) { xmove = tryx, ymove = 0; - walkplane = P_CheckSlopeWalk (mo, xmove, ymove); - P_TryMove (mo, mo->x + xmove, mo->y + ymove, true, walkplane); + walkplane = P_CheckSlopeWalk(mo, xmove, ymove); + P_TryMove(mo, mo->x + xmove, mo->y + ymove, true, walkplane); } return; } // fudge a bit to make sure it doesn't hit - bestslidefrac -= FRACUNIT/32; + bestslidefrac -= FRACUNIT / 32; if (bestslidefrac > 0) { - newx = FixedMul (tryx, bestslidefrac); - newy = FixedMul (tryy, bestslidefrac); + newx = FixedMul(tryx, bestslidefrac); + newy = FixedMul(tryy, bestslidefrac); // [BL] We need to abandon this function if we end up going through a teleporter const fixed_t startvelx = mo->velx; const fixed_t startvely = mo->vely; // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove (mo, mo->x+newx, mo->y+newy, true)) + if (!P_TryMove(mo, mo->x + newx, mo->y + newy, true)) goto stairstep; if (mo->velx != startvelx || mo->vely != startvely) @@ -2548,16 +2548,16 @@ void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) } // Now continue along the wall. - bestslidefrac = FRACUNIT - (bestslidefrac + FRACUNIT/32); // remainder + bestslidefrac = FRACUNIT - (bestslidefrac + FRACUNIT / 32); // remainder if (bestslidefrac > FRACUNIT) bestslidefrac = FRACUNIT; else if (bestslidefrac <= 0) return; - tryx = tmxmove = FixedMul (tryx, bestslidefrac); - tryy = tmymove = FixedMul (tryy, bestslidefrac); + tryx = tmxmove = FixedMul(tryx, bestslidefrac); + tryy = tmymove = FixedMul(tryy, bestslidefrac); - HitSlideLine (bestslideline); // clip the moves + HitSlideLine(bestslideline); // clip the moves mo->velx = tmxmove * numsteps; mo->vely = tmymove * numsteps; @@ -2571,16 +2571,16 @@ void FSlide::SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) mo->player->vely = mo->vely; } - walkplane = P_CheckSlopeWalk (mo, tmxmove, tmymove); + walkplane = P_CheckSlopeWalk(mo, tmxmove, tmymove); // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove (mo, mo->x+tmxmove, mo->y+tmymove, true, walkplane)) + if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true, walkplane)) { goto retry; } } -void P_SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) +void P_SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) { FSlide slide; slide.SlideMove(mo, tryx, tryy, numsteps); @@ -2592,7 +2592,7 @@ void P_SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) // //============================================================================ -const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymove) +const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymove) { static secplane_t copyplane; if (actor->flags & MF_NOGRAVITY) @@ -2601,40 +2601,40 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo } const secplane_t *plane = &actor->floorsector->floorplane; - fixed_t planezhere = plane->ZatPoint (actor->x, actor->y); + fixed_t planezhere = plane->ZatPoint(actor->x, actor->y); #ifdef _3DFLOORS - for(unsigned int i=0;ifloorsector->e->XFloor.ffloors.Size();i++) + for (unsigned int i = 0; ifloorsector->e->XFloor.ffloors.Size(); i++) { - F3DFloor * rover= actor->floorsector->e->XFloor.ffloors[i]; - if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + F3DFloor * rover = actor->floorsector->e->XFloor.ffloors[i]; + if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; fixed_t thisplanez = rover->top.plane->ZatPoint(actor->x, actor->y); - if (thisplanez>planezhere && thisplanez<=actor->z + actor->MaxStepHeight) + if (thisplanez>planezhere && thisplanez <= actor->z + actor->MaxStepHeight) { copyplane = *rover->top.plane; if (copyplane.c<0) copyplane.FlipVert(); plane = ©plane; - planezhere=thisplanez; + planezhere = thisplanez; } } if (actor->floorsector != actor->Sector) { - for(unsigned int i=0;iSector->e->XFloor.ffloors.Size();i++) + for (unsigned int i = 0; iSector->e->XFloor.ffloors.Size(); i++) { - F3DFloor * rover= actor->Sector->e->XFloor.ffloors[i]; - if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + F3DFloor * rover = actor->Sector->e->XFloor.ffloors[i]; + if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; fixed_t thisplanez = rover->top.plane->ZatPoint(actor->x, actor->y); - if (thisplanez>planezhere && thisplanez<=actor->z + actor->MaxStepHeight) + if (thisplanez>planezhere && thisplanez <= actor->z + actor->MaxStepHeight) { copyplane = *rover->top.plane; if (copyplane.c<0) copyplane.FlipVert(); plane = ©plane; - planezhere=thisplanez; + planezhere = thisplanez; } } } @@ -2643,7 +2643,7 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo if (actor->floorsector != actor->Sector) { // this additional check prevents sliding on sloped dropoffs - if (planezhere>actor->floorz+4*FRACUNIT) + if (planezhere>actor->floorz + 4 * FRACUNIT) return NULL; } @@ -2659,10 +2659,10 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo destx = actor->x + xmove; desty = actor->y + ymove; - t = TMulScale16 (plane->a, destx, plane->b, desty, plane->c, actor->z) + plane->d; + t = TMulScale16(plane->a, destx, plane->b, desty, plane->c, actor->z) + plane->d; if (t < 0) { // Desired location is behind (below) the plane - // (i.e. Walking up the plane) + // (i.e. Walking up the plane) if (plane->c < STEEPSLOPE) { // Can't climb up slopes of ~45 degrees or more if (actor->flags & MF_NOCLIP) @@ -2674,14 +2674,14 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo const msecnode_t *node; bool dopush = true; - if (plane->c > STEEPSLOPE*2/3) + if (plane->c > STEEPSLOPE * 2 / 3) { for (node = actor->touching_sectorlist; node; node = node->m_tnext) { const sector_t *sec = node->m_sector; if (sec->floorplane.c >= STEEPSLOPE) { - if (sec->floorplane.ZatPoint (destx, desty) >= actor->z - actor->MaxStepHeight) + if (sec->floorplane.ZatPoint(destx, desty) >= actor->z - actor->MaxStepHeight) { dopush = false; break; @@ -2699,8 +2699,8 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo } // Slide the desired location along the plane's normal // so that it lies on the plane's surface - destx -= FixedMul (plane->a, t); - desty -= FixedMul (plane->b, t); + destx -= FixedMul(plane->a, t); + desty -= FixedMul(plane->b, t); xmove = destx - actor->x; ymove = desty - actor->y; return (actor->floorsector == actor->Sector) ? plane : NULL; @@ -2709,9 +2709,9 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo { // Desired location is in front of (above) the plane if (planezhere == actor->z) { // Actor's current spot is on/in the plane, so walk down it - // Same principle as walking up, except reversed - destx += FixedMul (plane->a, t); - desty += FixedMul (plane->b, t); + // Same principle as walking up, except reversed + destx += FixedMul(plane->a, t); + desty += FixedMul(plane->b, t); xmove = destx - actor->x; ymove = desty - actor->y; return (actor->floorsector == actor->Sector) ? plane : NULL; @@ -2727,7 +2727,7 @@ const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymo // //============================================================================ -bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) +bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) { FLineOpening open; FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES); @@ -2740,7 +2740,7 @@ bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed if (!in->isaline) { - Printf ("PTR_BounceTraverse: not a line?"); + Printf("PTR_BounceTraverse: not a line?"); continue; } @@ -2752,14 +2752,14 @@ bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed } if (!(li->flags&ML_TWOSIDED) || !li->backsector) { - if (P_PointOnLineSide (slidemo->x, slidemo->y, li)) + if (P_PointOnLineSide(slidemo->x, slidemo->y, li)) continue; // don't hit the back side goto bounceblocking; } - P_LineOpening (open, slidemo, li, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); // set openrange, opentop, openbottom + P_LineOpening(open, slidemo, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); // set openrange, opentop, openbottom if (open.range < slidemo->height) goto bounceblocking; // doesn't fit @@ -2771,7 +2771,7 @@ bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed continue; // this line doesn't block movement - // the line does block movement, see if it is closer than best so far + // the line does block movement, see if it is closer than best so far bounceblocking: if (in->frac < bestslidefrac) { @@ -2791,7 +2791,7 @@ bool FSlide::BounceTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed // //============================================================================ -bool FSlide::BounceWall (AActor *mo) +bool FSlide::BounceWall(AActor *mo) { fixed_t leadx, leady; int side; @@ -2805,39 +2805,39 @@ bool FSlide::BounceWall (AActor *mo) } slidemo = mo; -// -// trace along the three leading corners -// + // + // trace along the three leading corners + // if (mo->velx > 0) { - leadx = mo->x+mo->radius; + leadx = mo->x + mo->radius; } else { - leadx = mo->x-mo->radius; + leadx = mo->x - mo->radius; } if (mo->vely > 0) { - leady = mo->y+mo->radius; + leady = mo->y + mo->radius; } else { - leady = mo->y-mo->radius; + leady = mo->y - mo->radius; } - bestslidefrac = FRACUNIT+1; + bestslidefrac = FRACUNIT + 1; bestslideline = mo->BlockingLine; - if (BounceTraverse(leadx, leady, leadx+mo->velx, leady+mo->vely) && mo->BlockingLine == NULL) + if (BounceTraverse(leadx, leady, leadx + mo->velx, leady + mo->vely) && mo->BlockingLine == NULL) { // Could not find a wall, so bounce off the floor/ceiling instead. fixed_t floordist = mo->z - mo->floorz; fixed_t ceildist = mo->ceilingz - mo->z; if (floordist <= ceildist) { - mo->FloorBounceMissile (mo->Sector->floorplane); + mo->FloorBounceMissile(mo->Sector->floorplane); return true; } else { - mo->FloorBounceMissile (mo->Sector->ceilingplane); + mo->FloorBounceMissile(mo->Sector->ceilingplane); return true; } } @@ -2851,7 +2851,7 @@ bool FSlide::BounceWall (AActor *mo) } // The amount of bounces is limited - if (mo->bouncecount>0 && --mo->bouncecount==0) + if (mo->bouncecount>0 && --mo->bouncecount == 0) { if (mo->flags & MF_MISSILE) P_ExplodeMissile(mo, line, NULL); @@ -2860,14 +2860,14 @@ bool FSlide::BounceWall (AActor *mo) return true; } - side = P_PointOnLineSide (mo->x, mo->y, line); - lineangle = R_PointToAngle2 (0, 0, line->dx, line->dy); + side = P_PointOnLineSide(mo->x, mo->y, line); + lineangle = R_PointToAngle2(0, 0, line->dx, line->dy); if (side == 1) { lineangle += ANG180; } - moveangle = R_PointToAngle2 (0, 0, mo->velx, mo->vely); - deltaangle = (2*lineangle)-moveangle; + moveangle = R_PointToAngle2(0, 0, mo->velx, mo->vely); + deltaangle = (2 * lineangle) - moveangle; mo->angle = deltaangle; lineangle >>= ANGLETOFINESHIFT; @@ -2877,14 +2877,14 @@ bool FSlide::BounceWall (AActor *mo) movelen = FixedMul(movelen, mo->wallbouncefactor); FBoundingBox box(mo->x, mo->y, mo->radius); - if (box.BoxOnLineSide (line) == -1) + if (box.BoxOnLineSide(line) == -1) { - mo->SetOrigin (mo->x + FixedMul(mo->radius, + mo->SetOrigin(mo->x + FixedMul(mo->radius, finecosine[deltaangle]), mo->y + FixedMul(mo->radius, finesine[deltaangle]), mo->z); } if (movelen < FRACUNIT) { - movelen = 2*FRACUNIT; + movelen = 2 * FRACUNIT; } mo->velx = FixedMul(movelen, finecosine[deltaangle]); mo->vely = FixedMul(movelen, finesine[deltaangle]); @@ -2899,7 +2899,7 @@ bool FSlide::BounceWall (AActor *mo) return true; } -bool P_BounceWall (AActor *mo) +bool P_BounceWall(AActor *mo) { FSlide slide; return slide.BounceWall(mo); @@ -2912,7 +2912,7 @@ bool P_BounceWall (AActor *mo) //========================================================================== extern FRandom pr_bounce; -bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop) +bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) { if (mo && BlockingMobj && ((mo->BounceFlags & BOUNCE_AllActors) || ((mo->flags & MF_MISSILE) && (!(mo->flags2 & MF2_RIP) || (BlockingMobj->flags5 & MF5_DONTRIP) || ((mo->flags6 & MF6_NOBOSSRIP) && (BlockingMobj->flags2 & MF2_BOSS))) && (BlockingMobj->flags2 & MF2_REFLECTIVE)) @@ -2924,21 +2924,21 @@ bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop) if (!ontop) { fixed_t speed; - angle_t angle = R_PointToAngle2 (BlockingMobj->x, - BlockingMobj->y, mo->x, mo->y) + ANGLE_1*((pr_bounce()%16)-8); - speed = P_AproxDistance (mo->velx, mo->vely); - speed = FixedMul (speed, mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent + angle_t angle = R_PointToAngle2(BlockingMobj->x, + BlockingMobj->y, mo->x, mo->y) + ANGLE_1*((pr_bounce() % 16) - 8); + speed = P_AproxDistance(mo->velx, mo->vely); + speed = FixedMul(speed, mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent mo->angle = angle; angle >>= ANGLETOFINESHIFT; - mo->velx = FixedMul (speed, finecosine[angle]); - mo->vely = FixedMul (speed, finesine[angle]); + mo->velx = FixedMul(speed, finecosine[angle]); + mo->vely = FixedMul(speed, finesine[angle]); mo->PlayBounceSound(true); if (mo->BounceFlags & BOUNCE_UseBounceState) { FName names[] = { NAME_Bounce, NAME_Actor, NAME_Creature }; FState *bouncestate; int count = 2; - + if ((BlockingMobj->flags & MF_SHOOTABLE) && !(BlockingMobj->flags & MF_NOBLOOD)) { count = 3; @@ -2956,7 +2956,7 @@ bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop) if (mo->BounceFlags & (BOUNCE_HereticType | BOUNCE_MBF)) { - mo->velz -= MulScale15 (FRACUNIT, dot); + mo->velz -= MulScale15(FRACUNIT, dot); if (!(mo->BounceFlags & BOUNCE_MBF)) // Heretic projectiles die, MBF projectiles don't. { mo->flags |= MF_INBOUNCE; @@ -2981,9 +2981,9 @@ bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop) if (abs(mo->velz) < (fixed_t)(mo->Mass * mo->GetGravity() / 64)) mo->velz = 0; } - else if (mo->BounceFlags & (BOUNCE_AutoOff|BOUNCE_AutoOffFloorOnly)) + else if (mo->BounceFlags & (BOUNCE_AutoOff | BOUNCE_AutoOffFloorOnly)) { - if (!(mo->flags & MF_NOGRAVITY) && (mo->velz < 3*FRACUNIT)) + if (!(mo->flags & MF_NOGRAVITY) && (mo->velz < 3 * FRACUNIT)) mo->BounceFlags &= ~BOUNCE_TypeMask; } } @@ -3008,7 +3008,7 @@ struct aim_t fixed_t toppitch, bottompitch; AActor * linetarget; - AActor * thing_friend, * thing_other; + AActor * thing_friend, *thing_other; angle_t pitch_friend, pitch_other; int flags; #ifdef _3DFLOORS @@ -3021,7 +3021,7 @@ struct aim_t bool AimTraverse3DFloors(const divline_t &trace, intercept_t * in); #endif - void AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target=NULL); + void AimTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target = NULL); }; @@ -3034,100 +3034,100 @@ struct aim_t bool aim_t::AimTraverse3DFloors(const divline_t &trace, intercept_t * in) { sector_t * nextsector; - secplane_t * nexttopplane, * nextbottomplane; - line_t * li=in->d.line; + secplane_t * nexttopplane, *nextbottomplane; + line_t * li = in->d.line; - nextsector=NULL; - nexttopplane=nextbottomplane=NULL; + nextsector = NULL; + nexttopplane = nextbottomplane = NULL; if (li->backsector == NULL) return true; // shouldn't really happen but crashed once for me... - if (li->frontsector->e->XFloor.ffloors.Size() || li->backsector->e->XFloor.ffloors.Size()) - { + if (li->frontsector->e->XFloor.ffloors.Size() || li->backsector->e->XFloor.ffloors.Size()) + { int frontflag; F3DFloor* rover; int highpitch, lowpitch; - fixed_t trX = trace.x + FixedMul (trace.dx, in->frac); - fixed_t trY = trace.y + FixedMul (trace.dy, in->frac); - fixed_t dist = FixedMul (attackrange, in->frac); + fixed_t trX = trace.x + FixedMul(trace.dx, in->frac); + fixed_t trY = trace.y + FixedMul(trace.dy, in->frac); + fixed_t dist = FixedMul(attackrange, in->frac); + - int dir = aimpitch < 0 ? 1 : aimpitch > 0 ? -1 : 0; - + frontflag = P_PointOnLineSide(shootthing->x, shootthing->y, li); - + // 3D floor check. This is not 100% accurate but normally sufficient when // combined with a final sight check - for(int i=1;i<=2;i++) + for (int i = 1; i <= 2; i++) { - sector_t * s=i==1? li->frontsector:li->backsector; + sector_t * s = i == 1 ? li->frontsector : li->backsector; - for(unsigned k=0;ke->XFloor.ffloors.Size();k++) + for (unsigned k = 0; ke->XFloor.ffloors.Size(); k++) { - crossedffloors=true; - rover=s->e->XFloor.ffloors[k]; - - if((rover->flags & FF_SHOOTTHROUGH) || !(rover->flags & FF_EXISTS)) continue; - - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(trX, trY); - fixed_t ff_top=rover->top.plane->ZatPoint(trX, trY); - + crossedffloors = true; + rover = s->e->XFloor.ffloors[k]; - highpitch = -(int)R_PointToAngle2 (0, shootz, dist, ff_top); - lowpitch = -(int)R_PointToAngle2 (0, shootz, dist, ff_bottom); + if ((rover->flags & FF_SHOOTTHROUGH) || !(rover->flags & FF_EXISTS)) continue; - if (highpitch<=toppitch) + fixed_t ff_bottom = rover->bottom.plane->ZatPoint(trX, trY); + fixed_t ff_top = rover->top.plane->ZatPoint(trX, trY); + + + highpitch = -(int)R_PointToAngle2(0, shootz, dist, ff_top); + lowpitch = -(int)R_PointToAngle2(0, shootz, dist, ff_bottom); + + if (highpitch <= toppitch) { // blocks completely - if (lowpitch>=bottompitch) return false; + if (lowpitch >= bottompitch) return false; // blocks upper edge of view - if (lowpitch>toppitch) + if (lowpitch>toppitch) { - toppitch=lowpitch; - if (frontflag!=i-1) + toppitch = lowpitch; + if (frontflag != i - 1) { - nexttopplane=rover->bottom.plane; + nexttopplane = rover->bottom.plane; } } } - else if (lowpitch>=bottompitch) + else if (lowpitch >= bottompitch) { // blocks lower edge of view - if (highpitchtop.plane; + nextbottomplane = rover->top.plane; } } } // trace is leaving a sector with a 3d-floor - if (frontflag==i-1) + if (frontflag == i - 1) { - if (s==lastsector) + if (s == lastsector) { // upper slope intersects with this 3d-floor - if (rover->bottom.plane==lastceilingplane && lowpitch > toppitch) + if (rover->bottom.plane == lastceilingplane && lowpitch > toppitch) { - toppitch=lowpitch; + toppitch = lowpitch; } // lower slope intersects with this 3d-floor - if (rover->top.plane==lastfloorplane && highpitch < bottompitch) + if (rover->top.plane == lastfloorplane && highpitch < bottompitch) { - bottompitch=highpitch; + bottompitch = highpitch; } } } if (toppitch >= bottompitch) return false; // stop } } - } + } - lastsector=nextsector; - lastceilingplane=nexttopplane; - lastfloorplane=nextbottomplane; + lastsector = nextsector; + lastceilingplane = nexttopplane; + lastfloorplane = nextbottomplane; return true; } #endif @@ -3139,9 +3139,9 @@ bool aim_t::AimTraverse3DFloors(const divline_t &trace, intercept_t * in) // //============================================================================ -void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target) +void aim_t::AimTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, AActor *target) { - FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES|PT_ADDTHINGS|PT_COMPATIBLE); + FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE); intercept_t *in; while ((in = it.Next())) @@ -3154,35 +3154,35 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e fixed_t dist; int thingpitch; - if (in->isaline) + if (in->isaline) { li = in->d.line; - if ( !(li->flags & ML_TWOSIDED) || (li->flags & ML_BLOCKEVERYTHING) ) + if (!(li->flags & ML_TWOSIDED) || (li->flags & ML_BLOCKEVERYTHING)) return; // stop // Crosses a two sided line. // A two sided line will restrict the possible target ranges. FLineOpening open; - P_LineOpening (open, NULL, li, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); + P_LineOpening(open, NULL, li, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); if (open.bottom >= open.top) return; // stop - dist = FixedMul (attackrange, in->frac); + dist = FixedMul(attackrange, in->frac); - pitch = -(int)R_PointToAngle2 (0, shootz, dist, open.bottom); + pitch = -(int)R_PointToAngle2(0, shootz, dist, open.bottom); if (pitch < bottompitch) bottompitch = pitch; - pitch = -(int)R_PointToAngle2 (0, shootz, dist, open.top); + pitch = -(int)R_PointToAngle2(0, shootz, dist, open.top); if (pitch > toppitch) toppitch = pitch; if (toppitch >= bottompitch) return; // stop - + #ifdef _3DFLOORS if (!AimTraverse3DFloors(it.Trace(), in)) return; #endif @@ -3203,11 +3203,11 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e { if (!(flags & ALF_CHECKNONSHOOTABLE)) // For info CCMD, ignore stuff about GHOST and SHOOTABLE flags { - if (!(th->flags&MF_SHOOTABLE)) + if (!(th->flags&MF_SHOOTABLE)) continue; // corpse or something // check for physical attacks on a ghost - if ((th->flags3 & MF3_GHOST) && + if ((th->flags3 & MF3_GHOST) && shootthing->player && // [RH] Be sure shootthing is a player shootthing->player->ReadyWeapon && (shootthing->player->ReadyWeapon->flags2 & MF2_THRUGHOST)) @@ -3216,7 +3216,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e } } } - dist = FixedMul (attackrange, in->frac); + dist = FixedMul(attackrange, in->frac); // Don't autoaim certain special actors if (!cl_doautoaim && th->flags6 & MF6_NOTAUTOAIMED) @@ -3226,26 +3226,26 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e #ifdef _3DFLOORS // we must do one last check whether the trace has crossed a 3D floor - if (lastsector==th->Sector && th->Sector->e->XFloor.ffloors.Size()) + if (lastsector == th->Sector && th->Sector->e->XFloor.ffloors.Size()) { if (lastceilingplane) { - fixed_t ff_top=lastceilingplane->ZatPoint(th->x, th->y); - fixed_t pitch = -(int)R_PointToAngle2 (0, shootz, dist, ff_top); + fixed_t ff_top = lastceilingplane->ZatPoint(th->x, th->y); + fixed_t pitch = -(int)R_PointToAngle2(0, shootz, dist, ff_top); // upper slope intersects with this 3d-floor if (pitch > toppitch) { - toppitch=pitch; + toppitch = pitch; } } if (lastfloorplane) { - fixed_t ff_bottom=lastfloorplane->ZatPoint(th->x, th->y); - fixed_t pitch = -(int)R_PointToAngle2 (0, shootz, dist, ff_bottom); + fixed_t ff_bottom = lastfloorplane->ZatPoint(th->x, th->y); + fixed_t pitch = -(int)R_PointToAngle2(0, shootz, dist, ff_bottom); // lower slope intersects with this 3d-floor if (pitch < bottompitch) { - bottompitch=pitch; + bottompitch = pitch; } } } @@ -3253,30 +3253,30 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e // check angles to see if the thing can be aimed at - thingtoppitch = -(int)R_PointToAngle2 (0, shootz, dist, th->z + th->height); + thingtoppitch = -(int)R_PointToAngle2(0, shootz, dist, th->z + th->height); if (thingtoppitch > bottompitch) continue; // shot over the thing - thingbottompitch = -(int)R_PointToAngle2 (0, shootz, dist, th->z); + thingbottompitch = -(int)R_PointToAngle2(0, shootz, dist, th->z); if (thingbottompitch < toppitch) continue; // shot under the thing - + #ifdef _3DFLOORS if (crossedffloors) { // if 3D floors were in the way do an extra visibility check for safety - if (!P_CheckSight(shootthing, th, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY)) + if (!P_CheckSight(shootthing, th, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) { // the thing can't be seen so we can safely exclude its range from our aiming field - if (thingtoppitchtoppitch) toppitch=thingbottompitch; + if (thingbottompitch>toppitch) toppitch = thingbottompitch; } else if (thingbottompitch>bottompitch) { - if (thingtoppitch bottompitch) thingbottompitch = bottompitch; - - thingpitch = thingtoppitch/2 + thingbottompitch/2; - + + thingpitch = thingtoppitch / 2 + thingbottompitch / 2; + if (flags & ALF_CHECK3D) { // We need to do a 3D distance check here because this is nearly always used in @@ -3302,7 +3302,7 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e fixed_t cosine = finecosine[thingpitch >> ANGLETOFINESHIFT]; if (cosine != 0) { - fixed_t d3 = FixedDiv( FixedMul( P_AproxDistance(it.Trace().dx, it.Trace().dy), in->frac), cosine); + fixed_t d3 = FixedDiv(FixedMul(P_AproxDistance(it.Trace().dx, it.Trace().dy), in->frac), cosine); if (d3 > attackrange) { return; @@ -3358,8 +3358,8 @@ void aim_t::AimTraverse (fixed_t startx, fixed_t starty, fixed_t endx, fixed_t e // //============================================================================ -fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, - int flags, AActor *target, AActor *friender) +fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, AActor **pLineTarget, fixed_t vrange, + int flags, AActor *target, AActor *friender) { fixed_t x2; fixed_t y2; @@ -3370,16 +3370,16 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p aim.shootthing = t1; aim.friender = (friender == NULL) ? t1 : friender; - x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; - y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; - aim.shootz = t1->z + (t1->height>>1) - t1->floorclip; + x2 = t1->x + (distance >> FRACBITS)*finecosine[angle]; + y2 = t1->y + (distance >> FRACBITS)*finesine[angle]; + aim.shootz = t1->z + (t1->height >> 1) - t1->floorclip; if (t1->player != NULL) { - aim.shootz += FixedMul (t1->player->mo->AttackZOffset, t1->player->crouchfactor); + aim.shootz += FixedMul(t1->player->mo->AttackZOffset, t1->player->crouchfactor); } else { - aim.shootz += 8*FRACUNIT; + aim.shootz += 8 * FRACUNIT; } // can't shoot outside view angles @@ -3387,15 +3387,15 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p { if (t1->player == NULL || !level.IsFreelookAllowed()) { - vrange = ANGLE_1*35; + vrange = ANGLE_1 * 35; } else { // [BB] Disable autoaim on weapons with WIF_NOAUTOAIM. AWeapon *weapon = t1->player->ReadyWeapon; - if ( weapon && (weapon->WeaponFlags & WIF_NOAUTOAIM) ) + if (weapon && (weapon->WeaponFlags & WIF_NOAUTOAIM)) { - vrange = ANGLE_1/2; + vrange = ANGLE_1 / 2; } else { @@ -3403,7 +3403,7 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p // vrange of 0 degrees, because then toppitch and bottompitch will // be equal, and PTR_AimTraverse will never find anything to shoot at // if it crosses a line. - vrange = clamp (t1->player->userinfo.GetAimDist(), ANGLE_1/2, ANGLE_1*35); + vrange = clamp(t1->player->userinfo.GetAimDist(), ANGLE_1 / 2, ANGLE_1 * 35); } } } @@ -3414,32 +3414,32 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p aim.linetarget = NULL; // for smart aiming - aim.thing_friend=aim.thing_other=NULL; + aim.thing_friend = aim.thing_other = NULL; // Information for tracking crossed 3D floors - aim.aimpitch=t1->pitch; + aim.aimpitch = t1->pitch; #ifdef _3DFLOORS - aim.crossedffloors=t1->Sector->e->XFloor.ffloors.Size()!=0; - aim.lastsector=t1->Sector; - aim.lastfloorplane=aim.lastceilingplane=NULL; + aim.crossedffloors = t1->Sector->e->XFloor.ffloors.Size() != 0; + aim.lastsector = t1->Sector; + aim.lastfloorplane = aim.lastceilingplane = NULL; // set initial 3d-floor info - for(unsigned i=0;iSector->e->XFloor.ffloors.Size();i++) + for (unsigned i = 0; iSector->e->XFloor.ffloors.Size(); i++) { - F3DFloor * rover=t1->Sector->e->XFloor.ffloors[i]; - fixed_t bottomz=rover->bottom.plane->ZatPoint(t1->x, t1->y); + F3DFloor * rover = t1->Sector->e->XFloor.ffloors[i]; + fixed_t bottomz = rover->bottom.plane->ZatPoint(t1->x, t1->y); - if (bottomz>=t1->z+t1->height) aim.lastceilingplane=rover->bottom.plane; + if (bottomz >= t1->z + t1->height) aim.lastceilingplane = rover->bottom.plane; - bottomz=rover->top.plane->ZatPoint(t1->x, t1->y); - if (bottomz<=t1->z) aim.lastfloorplane=rover->top.plane; + bottomz = rover->top.plane->ZatPoint(t1->x, t1->y); + if (bottomz <= t1->z) aim.lastfloorplane = rover->top.plane; } #endif - aim.AimTraverse (t1->x, t1->y, x2, y2, target); + aim.AimTraverse(t1->x, t1->y, x2, y2, target); - if (!aim.linetarget) + if (!aim.linetarget) { if (aim.thing_other) { @@ -3469,9 +3469,11 @@ fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, AActor **p struct Origin { AActor *Caller; + bool hitGhosts; + bool hitSameSpecie; }; -static ETraceStatus CheckForSameSpecie(FTraceResults &res, void *userdata) +static ETraceStatus CheckForActor(FTraceResults &res, void *userdata) { if (res.HitType != TRACE_HitActor) { @@ -3480,59 +3482,21 @@ static ETraceStatus CheckForSameSpecie(FTraceResults &res, void *userdata) Origin *data = (Origin *)userdata; - // check for physical attacks on the same specie - if (res.Actor->GetSpecies() == data->Caller->GetSpecies() || res.Actor->flags4 & MF4_SPECTRAL) - { - return TRACE_Skip; - } - - return TRACE_Stop; -} -static ETraceStatus CheckForGhost(FTraceResults &res, void *userdata) -{ - if (res.HitType != TRACE_HitActor) - { - return TRACE_Stop; - } - - // check for physical attacks on a ghost - if (res.Actor->flags3 & MF3_GHOST || res.Actor->flags4 & MF4_SPECTRAL) - { - return TRACE_Skip; - } - - return TRACE_Stop; -} -static ETraceStatus CheckForSpecieAndGhost(FTraceResults &res, void *userdata) -{ - if (res.HitType != TRACE_HitActor) - { - return TRACE_Stop; - } - - Origin *data = (Origin *)userdata; - - // check for physical attacks - if (res.Actor->GetSpecies() == data->Caller->GetSpecies() || res.Actor->flags3 & MF3_GHOST || res.Actor->flags4 & MF4_SPECTRAL) - { - return TRACE_Skip; - } - - return TRACE_Stop; -} -static ETraceStatus CheckForSpectral(FTraceResults &res, void *userdata) -{ - if (res.HitType != TRACE_HitActor) - { - return TRACE_Stop; - } - // check for physical attacks on spectrals if (res.Actor->flags4 & MF4_SPECTRAL) { return TRACE_Skip; } + if (data->hitSameSpecie && res.Actor->GetSpecies() == data->Caller->GetSpecies()) + { + return TRACE_Skip; + } + if (data->hitGhosts && res.Actor->flags3 & MF3_GHOST) + { + return TRACE_Skip; + } + return TRACE_Stop; } @@ -3544,8 +3508,8 @@ static ETraceStatus CheckForSpectral(FTraceResults &res, void *userdata) // //========================================================================== -AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, - int pitch, int damage, FName damageType, const PClass *pufftype, int flags, AActor **victim, int *actualdamage) +AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, + int pitch, int damage, FName damageType, const PClass *pufftype, int flags, AActor **victim, int *actualdamage) { fixed_t vx, vy, vz, shootz; FTraceResults trace; @@ -3558,7 +3522,7 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, bool killPuff = false; AActor *puff = NULL; int pflag = 0; - int puffFlags = (flags & LAF_ISMELEEATTACK)? PF_MELEERANGE : 0; + int puffFlags = (flags & LAF_ISMELEEATTACK) ? PF_MELEERANGE : 0; if (flags & LAF_NORANDOMPUFFZ) puffFlags |= PF_NORANDOMZ; @@ -3574,14 +3538,14 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, angle >>= ANGLETOFINESHIFT; pitch = (angle_t)(pitch) >> ANGLETOFINESHIFT; - vx = FixedMul (finecosine[pitch], finecosine[angle]); - vy = FixedMul (finecosine[pitch], finesine[angle]); + vx = FixedMul(finecosine[pitch], finecosine[angle]); + vy = FixedMul(finecosine[pitch], finesine[angle]); vz = -finesine[pitch]; - shootz = t1->z - t1->floorclip + (t1->height>>1); + shootz = t1->z - t1->floorclip + (t1->height >> 1); if (t1->player != NULL) { - shootz += FixedMul (t1->player->mo->AttackZOffset, t1->player->crouchfactor); + shootz += FixedMul(t1->player->mo->AttackZOffset, t1->player->crouchfactor); if (damageType == NAME_Melee || damageType == NAME_Hitscan) { // this is coming from a weapon attack function which needs to transfer information to the obituary code, @@ -3591,18 +3555,18 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, } else { - shootz += 8*FRACUNIT; + shootz += 8 * FRACUNIT; } // We need to check the defaults of the replacement here AActor *puffDefaults = GetDefaultByType(pufftype->GetReplacement()); - hitGhosts = (t1->player != NULL && + TData.hitGhosts = (t1->player != NULL && t1->player->ReadyWeapon != NULL && (t1->player->ReadyWeapon->flags2 & MF2_THRUGHOST)) || (puffDefaults && (puffDefaults->flags2 & MF2_THRUGHOST)); - hitSameSpecie = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); + TData.hitSameSpecie = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); // if the puff uses a non-standard damage type, this will override default, hitscan and melee damage type. // All other explicitly passed damage types (currenty only MDK) will be preserved. @@ -3614,22 +3578,22 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int tflags; if (puffDefaults != NULL && puffDefaults->flags6 & MF6_NOTRIGGER) tflags = TRACE_NoSky; - else tflags = TRACE_NoSky|TRACE_Impact; + else tflags = TRACE_NoSky | TRACE_Impact; - if (!Trace (t1->x, t1->y, shootz, t1->Sector, vx, vy, vz, distance, - MF_SHOOTABLE, ML_BLOCKEVERYTHING|ML_BLOCKHITSCAN, t1, trace, - tflags, hitGhosts ? (hitSameSpecie ? CheckForSpecieAndGhost : CheckForGhost) : hitSameSpecie ? CheckForSameSpecie : CheckForSpectral, &TData)) + if (!Trace(t1->x, t1->y, shootz, t1->Sector, vx, vy, vz, distance, + MF_SHOOTABLE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace, + tflags, CheckForActor, &TData)) { // hit nothing if (puffDefaults == NULL) { } else if (puffDefaults->ActiveSound) { // Play miss sound - S_Sound (t1, CHAN_WEAPON, puffDefaults->ActiveSound, 1, ATTN_NORM); + S_Sound(t1, CHAN_WEAPON, puffDefaults->ActiveSound, 1, ATTN_NORM); } if (puffDefaults != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF) { // Spawn the puff anyway - puff = P_SpawnPuff (t1, pufftype, trace.X, trace.Y, trace.Z, angle - ANG180, 2, puffFlags); + puff = P_SpawnPuff(t1, pufftype, trace.X, trace.Y, trace.Z, angle - ANG180, 2, puffFlags); } else { @@ -3645,32 +3609,32 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, // position a bit closer for puffs if (trace.HitType != TRACE_HitWall || trace.Line->special != Line_Horizon) { - fixed_t closer = trace.Distance - 4*FRACUNIT; - puff = P_SpawnPuff (t1, pufftype, t1->x + FixedMul (vx, closer), - t1->y + FixedMul (vy, closer), - shootz + FixedMul (vz, closer), angle - ANG90, 0, puffFlags); + fixed_t closer = trace.Distance - 4 * FRACUNIT; + puff = P_SpawnPuff(t1, pufftype, t1->x + FixedMul(vx, closer), + t1->y + FixedMul(vy, closer), + shootz + FixedMul(vz, closer), angle - ANG90, 0, puffFlags); } // [RH] Spawn a decal if (trace.HitType == TRACE_HitWall && trace.Line->special != Line_Horizon) - { + { // [TN] If the actor or weapon has a decal defined, use that one. - if(t1->DecalGenerator != NULL || + if (t1->DecalGenerator != NULL || (t1->player != NULL && t1->player->ReadyWeapon != NULL && t1->player->ReadyWeapon->DecalGenerator != NULL)) { - SpawnShootDecal (t1, trace); + SpawnShootDecal(t1, trace); } // Else, look if the bulletpuff has a decal defined. - else if(puff != NULL && puff->DecalGenerator) + else if (puff != NULL && puff->DecalGenerator) { - SpawnShootDecal (puff, trace); - } - + SpawnShootDecal(puff, trace); + } + else { - SpawnShootDecal (t1, trace); - } + SpawnShootDecal(t1, trace); + } } else if (puff != NULL && trace.CrossedWater == NULL && @@ -3679,17 +3643,17 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, { // Using the puff's position is not accurate enough. // Instead make it splash at the actual hit position - hitx = t1->x + FixedMul (vx, trace.Distance); - hity = t1->y + FixedMul (vy, trace.Distance); - hitz = shootz + FixedMul (vz, trace.Distance); - P_HitWater (puff, P_PointInSector(hitx, hity), hitx, hity, hitz); + hitx = t1->x + FixedMul(vx, trace.Distance); + hity = t1->y + FixedMul(vy, trace.Distance); + hitz = shootz + FixedMul(vz, trace.Distance); + P_HitWater(puff, P_PointInSector(hitx, hity), hitx, hity, hitz); } } else { bool bloodsplatter = (t1->flags5 & MF5_BLOODSPLATTER) || - (t1->player != NULL && t1->player->ReadyWeapon != NULL && - (t1->player->ReadyWeapon->WeaponFlags & WIF_AXEBLOOD)); + (t1->player != NULL && t1->player->ReadyWeapon != NULL && + (t1->player->ReadyWeapon->WeaponFlags & WIF_AXEBLOOD)); bool axeBlood = (t1->player != NULL && t1->player->ReadyWeapon != NULL && @@ -3698,21 +3662,21 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, // Hit a thing, so it could be either a puff or blood fixed_t dist = trace.Distance; // position a bit closer for puffs/blood if using compatibility mode. - if (i_compatflags & COMPATF_HITSCAN) dist -= 10*FRACUNIT; - hitx = t1->x + FixedMul (vx, dist); - hity = t1->y + FixedMul (vy, dist); - hitz = shootz + FixedMul (vz, dist); + if (i_compatflags & COMPATF_HITSCAN) dist -= 10 * FRACUNIT; + hitx = t1->x + FixedMul(vx, dist); + hity = t1->y + FixedMul(vy, dist); + hitz = shootz + FixedMul(vz, dist); // Spawn bullet puffs or blood spots, depending on target type. if ((puffDefaults != NULL && puffDefaults->flags3 & MF3_PUFFONACTORS) || (trace.Actor->flags & MF_NOBLOOD) || - (trace.Actor->flags2 & (MF2_INVULNERABLE|MF2_DORMANT))) + (trace.Actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT))) { if (!(trace.Actor->flags & MF_NOBLOOD)) puffFlags |= PF_HITTHINGBLEED; // We must pass the unreplaced puff type here - puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags|PF_HITTHING); + puff = P_SpawnPuff(t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags | PF_HITTHING); } // Allow puffs to inflict poison damage, so that hitscans can poison, too. @@ -3733,15 +3697,15 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, { dmgflags |= DMG_NO_ARMOR; } - + if (puff == NULL) - { + { // Since the puff is the damage inflictor we need it here // regardless of whether it is displayed or not. - puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags|PF_HITTHING|PF_TEMPORARY); + puff = P_SpawnPuff(t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags | PF_HITTHING | PF_TEMPORARY); killPuff = true; } - newdam = P_DamageMobj (trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags); + newdam = P_DamageMobj(trace.Actor, puff ? puff : t1, t1, damage, damageType, dmgflags); if (actualdamage != NULL) { *actualdamage = newdam; @@ -3751,30 +3715,30 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, { if (!bloodsplatter && !axeBlood && !(trace.Actor->flags & MF_NOBLOOD) && - !(trace.Actor->flags2 & (MF2_INVULNERABLE|MF2_DORMANT))) + !(trace.Actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT))) { - P_SpawnBlood (hitx, hity, hitz, angle - ANG180, newdam > 0 ? newdam : damage, trace.Actor); + P_SpawnBlood(hitx, hity, hitz, angle - ANG180, newdam > 0 ? newdam : damage, trace.Actor); } - + if (damage) { if (bloodsplatter || axeBlood) { if (!(trace.Actor->flags&MF_NOBLOOD) && - !(trace.Actor->flags2&(MF2_INVULNERABLE|MF2_DORMANT))) + !(trace.Actor->flags2&(MF2_INVULNERABLE | MF2_DORMANT))) { if (axeBlood) { - P_BloodSplatter2 (hitx, hity, hitz, trace.Actor); + P_BloodSplatter2(hitx, hity, hitz, trace.Actor); } if (pr_lineattack() < 192) { - P_BloodSplatter (hitx, hity, hitz, trace.Actor); + P_BloodSplatter(hitx, hity, hitz, trace.Actor); } } } // [RH] Stick blood to walls - P_TraceBleed (newdam > 0 ? newdam : damage, trace.X, trace.Y, trace.Z, + P_TraceBleed(newdam > 0 ? newdam : damage, trace.X, trace.Y, trace.Z, trace.Actor, srcangle, srcpitch); } } @@ -3788,10 +3752,10 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, if (puff == NULL) { // Spawn puff just to get a mass for the splash - puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags|PF_HITTHING|PF_TEMPORARY); + puff = P_SpawnPuff(t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, puffFlags | PF_HITTHING | PF_TEMPORARY); killPuff = true; } - SpawnDeepSplash (t1, trace, puff, vx, vy, vz, shootz, trace.Crossed3DWater != NULL); + SpawnDeepSplash(t1, trace, puff, vx, vy, vz, shootz, trace.Crossed3DWater != NULL); } } if (killPuff && puff != NULL) @@ -3802,8 +3766,8 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, return puff; } -AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, - int pitch, int damage, FName damageType, FName pufftype, int flags, AActor **victim, int *actualdamage) +AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, + int pitch, int damage, FName damageType, FName pufftype, int flags, AActor **victim, int *actualdamage) { const PClass * type = PClass::FindClass(pufftype); if (victim != NULL) @@ -3827,7 +3791,7 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, // //========================================================================== -void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, angle_t angle, int pitch) +void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, angle_t angle, int pitch) { if (!cl_bloodsplats) return; @@ -3839,7 +3803,7 @@ void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, a if ((actor->flags & MF_NOBLOOD) || (actor->flags5 & MF5_NOBLOODDECALS) || - (actor->flags2 & (MF2_INVULNERABLE|MF2_DORMANT)) || + (actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT)) || (actor->player && actor->player->cheats & CF_GODMODE)) { return; @@ -3880,28 +3844,28 @@ void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, a { FTraceResults bleedtrace; - angle_t bleedang = (angle + ((pr_tracebleed()-128) << noise)) >> ANGLETOFINESHIFT; - angle_t bleedpitch = (angle_t)(pitch + ((pr_tracebleed()-128) << noise)) >> ANGLETOFINESHIFT; - fixed_t vx = FixedMul (finecosine[bleedpitch], finecosine[bleedang]); - fixed_t vy = FixedMul (finecosine[bleedpitch], finesine[bleedang]); + angle_t bleedang = (angle + ((pr_tracebleed() - 128) << noise)) >> ANGLETOFINESHIFT; + angle_t bleedpitch = (angle_t)(pitch + ((pr_tracebleed() - 128) << noise)) >> ANGLETOFINESHIFT; + fixed_t vx = FixedMul(finecosine[bleedpitch], finecosine[bleedang]); + fixed_t vy = FixedMul(finecosine[bleedpitch], finesine[bleedang]); fixed_t vz = -finesine[bleedpitch]; - if (Trace (x, y, z, actor->Sector, - vx, vy, vz, 172*FRACUNIT, 0, ML_BLOCKEVERYTHING, actor, - bleedtrace, TRACE_NoSky)) + if (Trace(x, y, z, actor->Sector, + vx, vy, vz, 172 * FRACUNIT, 0, ML_BLOCKEVERYTHING, actor, + bleedtrace, TRACE_NoSky)) { if (bleedtrace.HitType == TRACE_HitWall) { PalEntry bloodcolor = actor->GetBloodColor(); if (bloodcolor != 0) { - bloodcolor.r>>=1; // the full color is too bright for blood decals - bloodcolor.g>>=1; - bloodcolor.b>>=1; - bloodcolor.a=1; + bloodcolor.r >>= 1; // the full color is too bright for blood decals + bloodcolor.g >>= 1; + bloodcolor.b >>= 1; + bloodcolor.a = 1; } - DImpactDecal::StaticCreate (bloodType, + DImpactDecal::StaticCreate(bloodType, bleedtrace.X, bleedtrace.Y, bleedtrace.Z, bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, @@ -3911,9 +3875,9 @@ void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, a } } -void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch) +void P_TraceBleed(int damage, AActor *target, angle_t angle, int pitch) { - P_TraceBleed (damage, target->x, target->y, target->z + target->height/2, + P_TraceBleed(damage, target->x, target->y, target->z + target->height / 2, target, angle, pitch); } @@ -3923,7 +3887,7 @@ void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch) // //========================================================================== -void P_TraceBleed (int damage, AActor *target, AActor *missile) +void P_TraceBleed(int damage, AActor *target, AActor *missile) { int pitch; @@ -3936,15 +3900,15 @@ void P_TraceBleed (int damage, AActor *target, AActor *missile) { double aim; - aim = atan ((double)missile->velz / (double)P_AproxDistance (missile->x - target->x, missile->y - target->y)); - pitch = -(int)(aim * ANGLE_180/PI); + aim = atan((double)missile->velz / (double)P_AproxDistance(missile->x - target->x, missile->y - target->y)); + pitch = -(int)(aim * ANGLE_180 / PI); } else { pitch = 0; } - P_TraceBleed (damage, target->x, target->y, target->z + target->height/2, - target, R_PointToAngle2 (missile->x, missile->y, target->x, target->y), + P_TraceBleed(damage, target->x, target->y, target->z + target->height / 2, + target, R_PointToAngle2(missile->x, missile->y, target->x, target->y), pitch); } @@ -3954,14 +3918,14 @@ void P_TraceBleed (int damage, AActor *target, AActor *missile) // //========================================================================== -void P_TraceBleed (int damage, AActor *target) +void P_TraceBleed(int damage, AActor *target) { if (target != NULL) { fixed_t one = pr_tracebleed() << 24; - fixed_t two = (pr_tracebleed()-128) << 16; + fixed_t two = (pr_tracebleed() - 128) << 16; - P_TraceBleed (damage, target->x, target->y, target->z + target->height/2, + P_TraceBleed(damage, target->x, target->y, target->z + target->height / 2, target, one, two); } } @@ -3984,7 +3948,7 @@ struct RailData bool StopAtInvul; }; -static ETraceStatus ProcessRailHit (FTraceResults &res, void *userdata) +static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) { RailData *data = (RailData *)userdata; if (res.HitType != TRACE_HitActor) @@ -4001,8 +3965,8 @@ static ETraceStatus ProcessRailHit (FTraceResults &res, void *userdata) // Save this thing for damaging later, and continue the trace SRailHit newhit; newhit.HitActor = res.Actor; - newhit.Distance = res.Distance - 10*FRACUNIT; // put blood in front - data->RailHits.Push (newhit); + newhit.Distance = res.Distance - 10 * FRACUNIT; // put blood in front + data->RailHits.Push(newhit); return data->StopAtOne ? TRACE_Stop : TRACE_Continue; } @@ -4012,7 +3976,7 @@ static ETraceStatus ProcessRailHit (FTraceResults &res, void *userdata) // // //========================================================================== -void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, int color1, int color2, float maxdiff, int railflags, const PClass *puffclass, angle_t angleoffset, angle_t pitchoffset, fixed_t distance, int duration, float sparsity, float drift, const PClass *spawnclass) +void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, int color1, int color2, float maxdiff, int railflags, const PClass *puffclass, angle_t angleoffset, angle_t pitchoffset, fixed_t distance, int duration, float sparsity, float drift, const PClass *spawnclass) { fixed_t vx, vy, vz; angle_t angle, pitch; @@ -4026,8 +3990,8 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, pitch = ((angle_t)(-source->pitch) + pitchoffset) >> ANGLETOFINESHIFT; angle = (source->angle + angleoffset) >> ANGLETOFINESHIFT; - vx = FixedMul (finecosine[pitch], finecosine[angle]); - vy = FixedMul (finecosine[pitch], finesine[angle]); + vx = FixedMul(finecosine[pitch], finecosine[angle]); + vy = FixedMul(finecosine[pitch], finesine[angle]); vz = finesine[pitch]; x1 = source->x; @@ -4039,11 +4003,11 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, { if (source->player != NULL) { - shootz += FixedMul (source->player->mo->AttackZOffset, source->player->crouchfactor); + shootz += FixedMul(source->player->mo->AttackZOffset, source->player->crouchfactor); } else { - shootz += 8*FRACUNIT; + shootz += 8 * FRACUNIT; } } @@ -4061,12 +4025,12 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, int flags; assert(puffclass != NULL); // Because we set it to a default above - AActor *puffDefaults = GetDefaultByType (puffclass->GetReplacement()); + AActor *puffDefaults = GetDefaultByType(puffclass->GetReplacement()); - flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? 0 : TRACE_PCross|TRACE_Impact; + flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? 0 : TRACE_PCross | TRACE_Impact; rail_data.StopAtInvul = (puffDefaults->flags3 & MF3_FOILINVUL) ? false : true; - Trace (x1, y1, shootz, source->Sector, vx, vy, vz, + Trace(x1, y1, shootz, source->Sector, vx, vy, vz, distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, flags, ProcessRailHit, &rail_data); @@ -4076,10 +4040,10 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, // used as damage inflictor AActor *thepuff = NULL; - - if (puffclass != NULL) thepuff = Spawn (puffclass, source->x, source->y, source->z, ALLOW_REPLACE); - for (i = 0; i < rail_data.RailHits.Size (); i++) + if (puffclass != NULL) thepuff = Spawn(puffclass, source->x, source->y, source->z, ALLOW_REPLACE); + + for (i = 0; i < rail_data.RailHits.Size(); i++) { fixed_t x, y, z; bool spawnpuff; @@ -4094,7 +4058,7 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, z = shootz + FixedMul(hitdist, vz); if ((hitactor->flags & MF_NOBLOOD) || - (hitactor->flags2 & (MF2_DORMANT|MF2_INVULNERABLE))) + (hitactor->flags2 & (MF2_DORMANT | MF2_INVULNERABLE))) { spawnpuff = (puffclass != NULL); } @@ -4102,7 +4066,7 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, { spawnpuff = (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF); puffflags |= PF_HITTHINGBLEED; // [XA] Allow for puffs to jump to XDeath state. - if (!(puffDefaults->flags3 & MF3_BLOODLESSIMPACT)) + if (!(puffDefaults->flags3 & MF3_BLOODLESSIMPACT)) { bleed = true; } @@ -4115,7 +4079,7 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, { P_PoisonMobj(hitactor, thepuff ? thepuff : source, source, puffDefaults->PoisonDamage, puffDefaults->PoisonDuration, puffDefaults->PoisonPeriod, puffDefaults->PoisonDamageType); } - int newdam = P_DamageMobj(hitactor, thepuff? thepuff:source, source, damage, damagetype, DMG_INFLICTOR_IS_PUFF); + int newdam = P_DamageMobj(hitactor, thepuff ? thepuff : source, source, damage, damagetype, DMG_INFLICTOR_IS_PUFF); if (bleed) { P_SpawnBlood(x, y, z, (source->angle + angleoffset) - ANG180, newdam > 0 ? newdam : damage, hitactor); @@ -4126,34 +4090,34 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, // Spawn a decal or puff at the point where the trace ended. if (trace.HitType == TRACE_HitWall) { - SpawnShootDecal (source, trace); - if (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF) + SpawnShootDecal(source, trace); + if (puffclass != NULL && puffDefaults->flags3 & MF3_ALWAYSPUFF) { - P_SpawnPuff (source, puffclass, trace.X, trace.Y, trace.Z, (source->angle + angleoffset) - ANG90, 1, 0); + P_SpawnPuff(source, puffclass, trace.X, trace.Y, trace.Z, (source->angle + angleoffset) - ANG90, 1, 0); } } - if(thepuff != NULL) + if (thepuff != NULL) { if (trace.HitType == TRACE_HitFloor && trace.CrossedWater == NULL && trace.Sector->heightsec == NULL) { thepuff->SetOrigin(trace.X, trace.Y, trace.Z); - P_HitWater (thepuff, trace.Sector); + P_HitWater(thepuff, trace.Sector); } if (trace.Crossed3DWater || trace.CrossedWater) { - SpawnDeepSplash (source, trace, thepuff, vx, vy, vz, shootz, trace.Crossed3DWater != NULL); + SpawnDeepSplash(source, trace, thepuff, vx, vy, vz, shootz, trace.Crossed3DWater != NULL); } - thepuff->Destroy (); + thepuff->Destroy(); } // Draw the slug's trail. end.X = FIXED2FLOAT(trace.X); end.Y = FIXED2FLOAT(trace.Y); end.Z = FIXED2FLOAT(trace.Z); - P_DrawRailTrail (source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->angle + angleoffset, duration, sparsity, drift); + P_DrawRailTrail(source, start, end, color1, color2, maxdiff, railflags, spawnclass, source->angle + angleoffset, duration, sparsity, drift); } //========================================================================== @@ -4162,10 +4126,10 @@ void P_RailAttack (AActor *source, int damage, int offset_xy, fixed_t offset_z, // //========================================================================== -CVAR (Float, chase_height, -8.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR (Float, chase_dist, 90.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Float, chase_height, -8.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Float, chase_dist, 90.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -void P_AimCamera (AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector) +void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector) { fixed_t distance = (fixed_t)(chase_dist * FRACUNIT); angle_t angle = (t1->angle - ANG180) >> ANGLETOFINESHIFT; @@ -4173,21 +4137,21 @@ void P_AimCamera (AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camer FTraceResults trace; fixed_t vx, vy, vz, sz; - vx = FixedMul (finecosine[pitch], finecosine[angle]); - vy = FixedMul (finecosine[pitch], finesine[angle]); + vx = FixedMul(finecosine[pitch], finecosine[angle]); + vy = FixedMul(finecosine[pitch], finesine[angle]); vz = finesine[pitch]; sz = t1->z - t1->floorclip + t1->height + (fixed_t)(chase_height * FRACUNIT); - if (Trace (t1->x, t1->y, sz, t1->Sector, + if (Trace(t1->x, t1->y, sz, t1->Sector, vx, vy, vz, distance, 0, 0, NULL, trace) && - trace.Distance > 10*FRACUNIT) + trace.Distance > 10 * FRACUNIT) { // Position camera slightly in front of hit thing - fixed_t dist = trace.Distance - 5*FRACUNIT; - CameraX = t1->x + FixedMul (vx, dist); - CameraY = t1->y + FixedMul (vy, dist); - CameraZ = sz + FixedMul (vz, dist); + fixed_t dist = trace.Distance - 5 * FRACUNIT; + CameraX = t1->x + FixedMul(vx, dist); + CameraY = t1->y + FixedMul(vy, dist); + CameraZ = sz + FixedMul(vz, dist); } else { @@ -4212,13 +4176,13 @@ bool P_TalkFacing(AActor *player) { AActor *linetarget; - P_AimLineAttack(player, player->angle, TALKRANGE, &linetarget, ANGLE_1*35, ALF_FORCENOSMART|ALF_CHECKCONVERSATION); + P_AimLineAttack(player, player->angle, TALKRANGE, &linetarget, ANGLE_1 * 35, ALF_FORCENOSMART | ALF_CHECKCONVERSATION); if (linetarget == NULL) { - P_AimLineAttack(player, player->angle + (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, ALF_FORCENOSMART|ALF_CHECKCONVERSATION); + P_AimLineAttack(player, player->angle + (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1 * 35, ALF_FORCENOSMART | ALF_CHECKCONVERSATION); if (linetarget == NULL) { - P_AimLineAttack(player, player->angle - (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1*35, ALF_FORCENOSMART|ALF_CHECKCONVERSATION); + P_AimLineAttack(player, player->angle - (ANGLE_90 >> 4), TALKRANGE, &linetarget, ANGLE_1 * 35, ALF_FORCENOSMART | ALF_CHECKCONVERSATION); if (linetarget == NULL) { return false; @@ -4238,8 +4202,8 @@ bool P_TalkFacing(AActor *player) if (linetarget->Conversation != NULL) { // Give the NPC a chance to play a brief animation - linetarget->ConversationAnimation (0); - P_StartConversation (linetarget, player, true, true); + linetarget->ConversationAnimation(0); + P_StartConversation(linetarget, player, true, true); return true; } return false; @@ -4253,7 +4217,7 @@ bool P_TalkFacing(AActor *player) bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline) { - FPathTraverse it(usething->x, usething->y, endx, endy, PT_ADDLINES|PT_ADDTHINGS); + FPathTraverse it(usething->x, usething->y, endx, endy, PT_ADDLINES | PT_ADDTHINGS); intercept_t *in; while ((in = it.Next())) @@ -4276,17 +4240,17 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline } FLineOpening open; - if (in->d.line->special == 0 || !(in->d.line->activation & (SPAC_Use|SPAC_UseThrough|SPAC_UseBack))) + if (in->d.line->special == 0 || !(in->d.line->activation & (SPAC_Use | SPAC_UseThrough | SPAC_UseBack))) { - blocked: - if (in->d.line->flags & (ML_BLOCKEVERYTHING|ML_BLOCKUSE)) + blocked: + if (in->d.line->flags & (ML_BLOCKEVERYTHING | ML_BLOCKUSE)) { open.range = 0; } else { - P_LineOpening (open, NULL, in->d.line, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); + P_LineOpening(open, NULL, in->d.line, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); } if (open.range <= 0 || (in->d.line->special != 0 && (i_compatflags & COMPATF_USEBLOCKING))) @@ -4297,31 +4261,31 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline sec = usething->Sector; - if (sec->SecActTarget && sec->SecActTarget->TriggerAction (usething, SECSPAC_Use)) + if (sec->SecActTarget && sec->SecActTarget->TriggerAction(usething, SECSPAC_Use)) { return true; } - sec = P_PointOnLineSide(usething->x, usething->y, in->d.line) == 0? + sec = P_PointOnLineSide(usething->x, usething->y, in->d.line) == 0 ? in->d.line->frontsector : in->d.line->backsector; if (sec != NULL && sec->SecActTarget && - sec->SecActTarget->TriggerAction (usething, SECSPAC_UseWall)) + sec->SecActTarget->TriggerAction(usething, SECSPAC_UseWall)) { return true; } if (usething->player) { - S_Sound (usething, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); + S_Sound(usething, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); } return true; // can't use through a wall } foundline = true; continue; // not a special line, but keep checking } - - if (P_PointOnLineSide (usething->x, usething->y, in->d.line) == 1) + + if (P_PointOnLineSide(usething->x, usething->y, in->d.line) == 1) { if (!(in->d.line->activation & SPAC_UseBack)) { @@ -4331,18 +4295,18 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline } else { - P_ActivateLine (in->d.line, usething, 1, SPAC_UseBack); + P_ActivateLine(in->d.line, usething, 1, SPAC_UseBack); return true; } } - else + else { - if ((in->d.line->activation & (SPAC_Use|SPAC_UseThrough|SPAC_UseBack)) == SPAC_UseBack) + if ((in->d.line->activation & (SPAC_Use | SPAC_UseThrough | SPAC_UseBack)) == SPAC_UseBack) { goto blocked; // Line cannot be used from front side so treat it as a non-trigger line } - P_ActivateLine (in->d.line, usething, 0, SPAC_Use); + P_ActivateLine(in->d.line, usething, 0, SPAC_Use); //WAS can't use more than one special line in a row //jff 3/21/98 NOW multiple use allowed with enabling line flag @@ -4379,7 +4343,7 @@ bool P_UseTraverse(AActor *usething, fixed_t endx, fixed_t endy, bool &foundline // //========================================================================== -bool P_NoWayTraverse (AActor *usething, fixed_t endx, fixed_t endy) +bool P_NoWayTraverse(AActor *usething, fixed_t endx, fixed_t endy) { FPathTraverse it(usething->x, usething->y, endx, endy, PT_ADDLINES); intercept_t *in; @@ -4392,9 +4356,9 @@ bool P_NoWayTraverse (AActor *usething, fixed_t endx, fixed_t endy) // [GrafZahl] de-obfuscated. Was I the only one who was unable to make sense out of // this convoluted mess? if (ld->special) continue; - if (ld->flags&(ML_BLOCKING|ML_BLOCKEVERYTHING|ML_BLOCK_PLAYERS)) return true; - P_LineOpening(open, NULL, ld, it.Trace().x+FixedMul(it.Trace().dx, in->frac), - it.Trace().y+FixedMul(it.Trace().dy, in->frac)); + if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true; + P_LineOpening(open, NULL, ld, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); if (open.range <= 0 || open.bottom > usething->z + usething->MaxStepHeight || open.top < usething->z + usething->height) return true; @@ -4410,7 +4374,7 @@ bool P_NoWayTraverse (AActor *usething, fixed_t endx, fixed_t endy) // //========================================================================== -void P_UseLines (player_t *player) +void P_UseLines(player_t *player) { angle_t angle; fixed_t x1, y1, usedist; @@ -4431,15 +4395,15 @@ void P_UseLines (player_t *player) // // This added test makes the "oof" sound work on 2s lines -- killough: - if (!P_UseTraverse (player->mo, x1, y1, foundline)) + if (!P_UseTraverse(player->mo, x1, y1, foundline)) { // [RH] Give sector a chance to eat the use sector_t *sec = player->mo->Sector; int spac = SECSPAC_Use; if (foundline) spac |= SECSPAC_UseWall; - if ((!sec->SecActTarget || !sec->SecActTarget->TriggerAction (player->mo, spac)) && - P_NoWayTraverse (player->mo, x1, y1)) + if ((!sec->SecActTarget || !sec->SecActTarget->TriggerAction(player->mo, spac)) && + P_NoWayTraverse(player->mo, x1, y1)) { - S_Sound (player->mo, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); + S_Sound(player->mo, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); } } } @@ -4452,12 +4416,12 @@ void P_UseLines (player_t *player) // //========================================================================== -bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) +bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) { int angle; fixed_t x1, y1, x2, y2, usedist; - angle = PuzzleItemUser->angle>>ANGLETOFINESHIFT; + angle = PuzzleItemUser->angle >> ANGLETOFINESHIFT; x1 = PuzzleItemUser->x; y1 = PuzzleItemUser->y; @@ -4470,7 +4434,7 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) x2 = x1 + FixedMul(usedist, finecosine[angle]); y2 = y1 + FixedMul(usedist, finesine[angle]); - FPathTraverse it(x1, y1, x2, y2, PT_ADDLINES|PT_ADDTHINGS); + FPathTraverse it(x1, y1, x2, y2, PT_ADDLINES | PT_ADDTHINGS); intercept_t *in; while ((in = it.Next())) @@ -4482,15 +4446,15 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) { // Check line if (in->d.line->special != UsePuzzleItem) { - P_LineOpening (open, NULL, in->d.line, it.Trace().x + FixedMul (it.Trace().dx, in->frac), - it.Trace().y + FixedMul (it.Trace().dy, in->frac)); + P_LineOpening(open, NULL, in->d.line, it.Trace().x + FixedMul(it.Trace().dx, in->frac), + it.Trace().y + FixedMul(it.Trace().dy, in->frac)); if (open.range <= 0) { return false; // can't use through a wall } continue; } - if (P_PointOnLineSide (PuzzleItemUser->x, PuzzleItemUser->y, in->d.line) == 1) + if (P_PointOnLineSide(PuzzleItemUser->x, PuzzleItemUser->y, in->d.line) == 1) { // Don't use back sides return false; } @@ -4499,7 +4463,7 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) return false; } int args[3] = { in->d.line->args[2], in->d.line->args[3], in->d.line->args[4] }; - P_StartScript (PuzzleItemUser, in->d.line, in->d.line->args[1], NULL, args, 3, ACS_ALWAYS); + P_StartScript(PuzzleItemUser, in->d.line, in->d.line->args[1], NULL, args, 3, ACS_ALWAYS); in->d.line->special = 0; return true; } @@ -4514,7 +4478,7 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) continue; } int args[3] = { mobj->args[2], mobj->args[3], mobj->args[4] }; - P_StartScript (PuzzleItemUser, NULL, mobj->args[1], NULL, args, 3, ACS_ALWAYS); + P_StartScript(PuzzleItemUser, NULL, mobj->args[1], NULL, args, 3, ACS_ALWAYS); mobj->special = 0; return true; } @@ -4532,7 +4496,7 @@ bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) // [RH] Damage scale to apply to thing that shot the missile. static float selfthrustscale; -CUSTOM_CVAR (Float, splashfactor, 1.f, CVAR_SERVERINFO) +CUSTOM_CVAR(Float, splashfactor, 1.f, CVAR_SERVERINFO) { if (self <= 0.f) self = 1.f; @@ -4547,19 +4511,19 @@ CUSTOM_CVAR (Float, splashfactor, 1.f, CVAR_SERVERINFO) // //========================================================================== -void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int bombdistance, FName bombmod, +void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bombdistance, FName bombmod, int flags, int fulldamagedistance) { if (bombdistance <= 0) return; - fulldamagedistance = clamp(fulldamagedistance, 0, bombdistance-1); + fulldamagedistance = clamp(fulldamagedistance, 0, bombdistance - 1); double bombdistancefloat = 1.f / (double)(bombdistance - fulldamagedistance); double bombdamagefloat = (double)bombdamage; FVector3 bombvec(FIXED2FLOAT(bombspot->x), FIXED2FLOAT(bombspot->y), FIXED2FLOAT(bombspot->z)); - FBlockThingsIterator it(FBoundingBox(bombspot->x, bombspot->y, bombdistance<x, bombspot->y, bombdistance << FRACBITS)); AActor *thing; if (flags & RADF_SOURCEISSPOT) @@ -4588,12 +4552,12 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b // be hurt by projectiles fired by a monster of the same type. // Controlled by the DONTHARMCLASS and DONTHARMSPECIES flags. if ((bombsource && !thing->player) // code common to both checks - && ( // Class check first + && ( // Class check first ((bombsource->flags4 & MF4_DONTHARMCLASS) && (thing->GetClass() == bombsource->GetClass())) || // Nigh-identical species check second ((bombsource->flags6 & MF6_DONTHARMSPECIES) && (thing->GetSpecies() == bombsource->GetSpecies())) ) - ) continue; + ) continue; // Barrels always use the original code, since this makes // them far too "active." BossBrains also use the old code @@ -4608,12 +4572,12 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b fixed_t dx, dy; double boxradius; - dx = abs (thing->x - bombspot->x); - dy = abs (thing->y - bombspot->y); - boxradius = double (thing->radius); + dx = abs(thing->x - bombspot->x); + dy = abs(thing->y - bombspot->y); + boxradius = double(thing->radius); // The damage pattern is square, not circular. - len = double (dx > dy ? dx : dy); + len = double(dx > dy ? dx : dy); if (bombspot->z < thing->z || bombspot->z >= thing->z + thing->height) { @@ -4621,11 +4585,11 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b if (bombspot->z > thing->z) { - dz = double (bombspot->z - thing->z - thing->height); + dz = double(bombspot->z - thing->z - thing->height); } else { - dz = double (thing->z - bombspot->z); + dz = double(thing->z - bombspot->z); } if (len <= boxradius) { @@ -4634,7 +4598,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b else { len -= boxradius; - len = sqrt (len*len + dz*dz); + len = sqrt(len*len + dz*dz); } } else @@ -4650,10 +4614,10 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b { points = points * splashfactor; } - points *= thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT)/(double)FRACUNIT; + points *= thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT) / (double)FRACUNIT; // points and bombdamage should be the same sign - if ((points * bombdamage) > 0 && P_CheckSight (thing, bombspot, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY)) + if ((points * bombdamage) > 0 && P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) { // OK to damage; target is in direct path double velz; double thrust; @@ -4661,14 +4625,14 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b int newdam = damage; if (!(flags & RADF_NODAMAGE)) - newdam = P_DamageMobj (thing, bombspot, bombsource, damage, bombmod); + newdam = P_DamageMobj(thing, bombspot, bombsource, damage, bombmod); else if (thing->player == NULL && !(flags & RADF_NOIMPACTDAMAGE)) thing->flags2 |= MF2_BLASTED; if (!(thing->flags & MF_ICECORPSE)) { if (!(flags & RADF_NODAMAGE) && !(bombspot->flags3 & MF3_BLOODLESSIMPACT)) - P_TraceBleed (newdam > 0 ? newdam : damage, thing, bombspot); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, bombspot); if ((flags & RADF_NODAMAGE) || !(bombspot->flags2 & MF2_NODMGTHRUST)) { @@ -4679,7 +4643,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b { thrust *= selfthrustscale; } - velz = (double)(thing->z + (thing->height>>1) - bombspot->z) * thrust; + velz = (double)(thing->z + (thing->height >> 1) - bombspot->z) * thrust; if (bombsource != thing) { velz *= 0.5f; @@ -4688,9 +4652,9 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b { velz *= 0.8f; } - angle_t ang = R_PointToAngle2 (bombspot->x, bombspot->y, thing->x, thing->y) >> ANGLETOFINESHIFT; - thing->velx += fixed_t (finecosine[ang] * thrust); - thing->vely += fixed_t (finesine[ang] * thrust); + angle_t ang = R_PointToAngle2(bombspot->x, bombspot->y, thing->x, thing->y) >> ANGLETOFINESHIFT; + thing->velx += fixed_t(finecosine[ang] * thrust); + thing->vely += fixed_t(finesine[ang] * thrust); if (!(flags & RADF_NODAMAGE)) thing->velz += (fixed_t)velz; // this really doesn't work well } @@ -4703,8 +4667,8 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b // [RH] Old code just for barrels fixed_t dx, dy, dist; - dx = abs (thing->x - bombspot->x); - dy = abs (thing->y - bombspot->y); + dx = abs(thing->x - bombspot->x); + dy = abs(thing->y - bombspot->y); dist = dx>dy ? dx : dy; dist = (dist - thing->radius) >> FRACBITS; @@ -4715,17 +4679,17 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b if (dist >= bombdistance) continue; // out of range - if (P_CheckSight (thing, bombspot, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY)) + if (P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) { // OK to damage; target is in direct path dist = clamp(dist - fulldamagedistance, 0, dist); - int damage = Scale (bombdamage, bombdistance-dist, bombdistance); + int damage = Scale(bombdamage, bombdistance - dist, bombdistance); damage = (int)((double)damage * splashfactor); damage = Scale(damage, thing->GetClass()->Meta.GetMetaFixed(AMETA_RDFactor, FRACUNIT), FRACUNIT); if (damage > 0) { - int newdam = P_DamageMobj (thing, bombspot, bombsource, damage, bombmod); - P_TraceBleed (newdam > 0 ? newdam : damage, thing, bombspot); + int newdam = P_DamageMobj(thing, bombspot, bombsource, damage, bombmod); + P_TraceBleed(newdam > 0 ? newdam : damage, thing, bombspot); } } } @@ -4765,7 +4729,7 @@ struct FChangePosition TArray intersectors; -EXTERN_CVAR (Int, cl_bloodtype) +EXTERN_CVAR(Int, cl_bloodtype) //============================================================================= // @@ -4773,7 +4737,7 @@ EXTERN_CVAR (Int, cl_bloodtype) // //============================================================================= -bool P_AdjustFloorCeil (AActor *thing, FChangePosition *cpos) +bool P_AdjustFloorCeil(AActor *thing, FChangePosition *cpos) { int flags2 = thing->flags2 & MF2_PASSMOBJ; FCheckPosition tm; @@ -4791,7 +4755,7 @@ bool P_AdjustFloorCeil (AActor *thing, FChangePosition *cpos) thing->flags2 |= MF2_PASSMOBJ; } - bool isgood = P_CheckPosition (thing, thing->x, thing->y, tm); + bool isgood = P_CheckPosition(thing, thing->x, thing->y, tm); thing->floorz = tm.floorz; thing->ceilingz = tm.ceilingz; thing->dropoffz = tm.dropoffz; // killough 11/98: remember dropoffs @@ -4812,7 +4776,7 @@ bool P_AdjustFloorCeil (AActor *thing, FChangePosition *cpos) // //============================================================================= -void P_FindAboveIntersectors (AActor *actor) +void P_FindAboveIntersectors(AActor *actor) { if (actor->flags & MF_NOCLIP) return; @@ -4855,7 +4819,7 @@ void P_FindAboveIntersectors (AActor *actor) if (thing->z >= actor->z && thing->z <= actor->z + actor->height) { // Thing intersects above the base - intersectors.Push (thing); + intersectors.Push(thing); } } } @@ -4866,7 +4830,7 @@ void P_FindAboveIntersectors (AActor *actor) // //============================================================================= -void P_FindBelowIntersectors (AActor *actor) +void P_FindBelowIntersectors(AActor *actor) { if (actor->flags & MF_NOCLIP) return; @@ -4909,7 +4873,7 @@ void P_FindBelowIntersectors (AActor *actor) if (thing->z + thing->height <= actor->z + actor->height && thing->z + thing->height > actor->z) { // Thing intersects below the base - intersectors.Push (thing); + intersectors.Push(thing); } } } @@ -4920,34 +4884,34 @@ void P_FindBelowIntersectors (AActor *actor) // //============================================================================= -void P_DoCrunch (AActor *thing, FChangePosition *cpos) +void P_DoCrunch(AActor *thing, FChangePosition *cpos) { if (!(thing && thing->Grind(true) && cpos)) return; cpos->nofit = true; if ((cpos->crushchange > 0) && !(level.maptime & 3)) { - int newdam = P_DamageMobj (thing, NULL, NULL, cpos->crushchange, NAME_Crush); + int newdam = P_DamageMobj(thing, NULL, NULL, cpos->crushchange, NAME_Crush); // spray blood in a random direction - if (!(thing->flags2&(MF2_INVULNERABLE|MF2_DORMANT))) + if (!(thing->flags2&(MF2_INVULNERABLE | MF2_DORMANT))) { if (!(thing->flags&MF_NOBLOOD)) { PalEntry bloodcolor = thing->GetBloodColor(); const PClass *bloodcls = thing->GetBloodType(); - - P_TraceBleed (newdam > 0 ? newdam : cpos->crushchange, thing); + + P_TraceBleed(newdam > 0 ? newdam : cpos->crushchange, thing); if (bloodcls != NULL) { AActor *mo; - mo = Spawn (bloodcls, thing->x, thing->y, - thing->z + thing->height/2, ALLOW_REPLACE); + mo = Spawn(bloodcls, thing->x, thing->y, + thing->z + thing->height / 2, ALLOW_REPLACE); - mo->velx = pr_crunch.Random2 () << 12; - mo->vely = pr_crunch.Random2 () << 12; + mo->velx = pr_crunch.Random2() << 12; + mo->vely = pr_crunch.Random2() << 12; if (bloodcolor != 0 && !(mo->flags2 & MF2_DONTTRANSLATE)) { mo->Translation = TRANSLATION(TRANSLATION_Blood, bloodcolor.a); @@ -4957,7 +4921,7 @@ void P_DoCrunch (AActor *thing, FChangePosition *cpos) } angle_t an; - an = (M_Random () - 128) << 24; + an = (M_Random() - 128) << 24; if (cl_bloodtype >= 1) { P_DrawSplash2(32, thing->x, thing->y, thing->z + thing->height / 2, an, 2, bloodcolor); @@ -4982,9 +4946,9 @@ void P_DoCrunch (AActor *thing, FChangePosition *cpos) // above it didn't fit. //============================================================================= -int P_PushUp (AActor *thing, FChangePosition *cpos) +int P_PushUp(AActor *thing, FChangePosition *cpos) { - unsigned int firstintersect = intersectors.Size (); + unsigned int firstintersect = intersectors.Size(); unsigned int lastintersect; int mymass = thing->Mass; @@ -4995,8 +4959,8 @@ int P_PushUp (AActor *thing, FChangePosition *cpos) // [GZ] Skip thing intersect test for THRUACTORS things. if (thing->flags2 & MF2_THRUACTORS) return 0; - P_FindAboveIntersectors (thing); - lastintersect = intersectors.Size (); + P_FindAboveIntersectors(thing); + lastintersect = intersectors.Size(); for (; firstintersect < lastintersect; firstintersect++) { AActor *intersect = intersectors[firstintersect]; @@ -5009,17 +4973,17 @@ int P_PushUp (AActor *thing, FChangePosition *cpos) if (!(intersect->flags2 & MF2_PASSMOBJ) || (!(intersect->flags3 & MF3_ISMONSTER) && intersect->Mass > mymass) || (intersect->flags4 & MF4_ACTLIKEBRIDGE) - ) - { + ) + { // Can't push bridges or things more massive than ourself return 2; } fixed_t oldz = intersect->z; - P_AdjustFloorCeil (intersect, cpos); + P_AdjustFloorCeil(intersect, cpos); intersect->z = thing->z + thing->height + 1; - if (P_PushUp (intersect, cpos)) + if (P_PushUp(intersect, cpos)) { // Move blocked - P_DoCrunch (intersect, cpos); + P_DoCrunch(intersect, cpos); intersect->z = oldz; return 2; } @@ -5035,9 +4999,9 @@ int P_PushUp (AActor *thing, FChangePosition *cpos) // below it didn't fit. //============================================================================= -int P_PushDown (AActor *thing, FChangePosition *cpos) +int P_PushDown(AActor *thing, FChangePosition *cpos) { - unsigned int firstintersect = intersectors.Size (); + unsigned int firstintersect = intersectors.Size(); unsigned int lastintersect; int mymass = thing->Mass; @@ -5045,27 +5009,27 @@ int P_PushDown (AActor *thing, FChangePosition *cpos) { return 1; } - P_FindBelowIntersectors (thing); - lastintersect = intersectors.Size (); + P_FindBelowIntersectors(thing); + lastintersect = intersectors.Size(); for (; firstintersect < lastintersect; firstintersect++) { AActor *intersect = intersectors[firstintersect]; if (!(intersect->flags2 & MF2_PASSMOBJ) || (!(intersect->flags3 & MF3_ISMONSTER) && intersect->Mass > mymass) || (intersect->flags4 & MF4_ACTLIKEBRIDGE) - ) - { + ) + { // Can't push bridges or things more massive than ourself return 2; } fixed_t oldz = intersect->z; - P_AdjustFloorCeil (intersect, cpos); + P_AdjustFloorCeil(intersect, cpos); if (oldz > thing->z - intersect->height) { // Only push things down, not up. intersect->z = thing->z - intersect->height; - if (P_PushDown (intersect, cpos)) + if (P_PushDown(intersect, cpos)) { // Move blocked - P_DoCrunch (intersect, cpos); + P_DoCrunch(intersect, cpos); intersect->z = oldz; return 2; } @@ -5080,27 +5044,27 @@ int P_PushDown (AActor *thing, FChangePosition *cpos) // //============================================================================= -void PIT_FloorDrop (AActor *thing, FChangePosition *cpos) +void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) { fixed_t oldfloorz = thing->floorz; - P_AdjustFloorCeil (thing, cpos); + P_AdjustFloorCeil(thing, cpos); if (oldfloorz == thing->floorz) return; if (thing->flags4 & MF4_ACTLIKEBRIDGE) return; // do not move bridge things if (thing->velz == 0 && (!(thing->flags & MF_NOGRAVITY) || - (thing->z == oldfloorz && !(thing->flags & MF_NOLIFTDROP)))) + (thing->z == oldfloorz && !(thing->flags & MF_NOLIFTDROP)))) { fixed_t oldz = thing->z; if ((thing->flags & MF_NOGRAVITY) || (thing->flags5 & MF5_MOVEWITHSECTOR) || - (((cpos->sector->Flags & SECF_FLOORDROP) || cpos->moveamt < 9*FRACUNIT) - && thing->z - thing->floorz <= cpos->moveamt)) + (((cpos->sector->Flags & SECF_FLOORDROP) || cpos->moveamt < 9 * FRACUNIT) + && thing->z - thing->floorz <= cpos->moveamt)) { thing->z = thing->floorz; - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); } } else if ((thing->z != oldfloorz && !(thing->flags & MF_NOLIFTDROP))) @@ -5109,7 +5073,7 @@ void PIT_FloorDrop (AActor *thing, FChangePosition *cpos) if ((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) { thing->z = thing->z - oldfloorz + thing->floorz; - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); } } } @@ -5120,46 +5084,46 @@ void PIT_FloorDrop (AActor *thing, FChangePosition *cpos) // //============================================================================= -void PIT_FloorRaise (AActor *thing, FChangePosition *cpos) +void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) { fixed_t oldfloorz = thing->floorz; fixed_t oldz = thing->z; - P_AdjustFloorCeil (thing, cpos); + P_AdjustFloorCeil(thing, cpos); if (oldfloorz == thing->floorz) return; // Move things intersecting the floor up if (thing->z <= thing->floorz) { - if (thing->flags4 & MF4_ACTLIKEBRIDGE) + if (thing->flags4 & MF4_ACTLIKEBRIDGE) { cpos->nofit = true; return; // do not move bridge things } - intersectors.Clear (); + intersectors.Clear(); thing->z = thing->floorz; } else { - if((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) + if ((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) { - intersectors.Clear (); + intersectors.Clear(); thing->z = thing->z - oldfloorz + thing->floorz; } else return; } - switch (P_PushUp (thing, cpos)) + switch (P_PushUp(thing, cpos)) { default: - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); break; case 1: - P_DoCrunch (thing, cpos); - P_CheckFakeFloorTriggers (thing, oldz); + P_DoCrunch(thing, cpos); + P_CheckFakeFloorTriggers(thing, oldz); break; case 2: - P_DoCrunch (thing, cpos); + P_DoCrunch(thing, cpos); thing->z = oldz; break; } @@ -5171,21 +5135,21 @@ void PIT_FloorRaise (AActor *thing, FChangePosition *cpos) // //============================================================================= -void PIT_CeilingLower (AActor *thing, FChangePosition *cpos) +void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) { bool onfloor; onfloor = thing->z <= thing->floorz; - P_AdjustFloorCeil (thing, cpos); + P_AdjustFloorCeil(thing, cpos); if (thing->z + thing->height > thing->ceilingz) { - if (thing->flags4 & MF4_ACTLIKEBRIDGE) + if (thing->flags4 & MF4_ACTLIKEBRIDGE) { cpos->nofit = true; return; // do not move bridge things } - intersectors.Clear (); + intersectors.Clear(); fixed_t oldz = thing->z; if (thing->ceilingz - thing->height >= thing->floorz) { @@ -5195,18 +5159,18 @@ void PIT_CeilingLower (AActor *thing, FChangePosition *cpos) { thing->z = thing->floorz; } - switch (P_PushDown (thing, cpos)) + switch (P_PushDown(thing, cpos)) { case 2: // intentional fall-through case 1: if (onfloor) thing->z = thing->floorz; - P_DoCrunch (thing, cpos); - P_CheckFakeFloorTriggers (thing, oldz); + P_DoCrunch(thing, cpos); + P_CheckFakeFloorTriggers(thing, oldz); break; default: - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); break; } } @@ -5218,9 +5182,9 @@ void PIT_CeilingLower (AActor *thing, FChangePosition *cpos) // //============================================================================= -void PIT_CeilingRaise (AActor *thing, FChangePosition *cpos) +void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) { - bool isgood = P_AdjustFloorCeil (thing, cpos); + bool isgood = P_AdjustFloorCeil(thing, cpos); if (thing->flags4 & MF4_ACTLIKEBRIDGE) return; // do not move bridge things @@ -5237,15 +5201,15 @@ void PIT_CeilingRaise (AActor *thing, FChangePosition *cpos) { thing->z = thing->ceilingz - thing->height; } - P_CheckFakeFloorTriggers (thing, oldz); + P_CheckFakeFloorTriggers(thing, oldz); } else if ((thing->flags2 & MF2_PASSMOBJ) && !isgood && thing->z + thing->height < thing->ceilingz) { AActor *onmobj; - if (!P_TestMobjZ (thing, true, &onmobj) && onmobj->z <= thing->z) + if (!P_TestMobjZ(thing, true, &onmobj) && onmobj->z <= thing->z) { - thing->z = MIN (thing->ceilingz - thing->height, - onmobj->z + onmobj->height); + thing->z = MIN(thing->ceilingz - thing->height, + onmobj->z + onmobj->height); } } } @@ -5260,23 +5224,23 @@ void PIT_CeilingRaise (AActor *thing, FChangePosition *cpos) // //============================================================================= -bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, bool isreset) +bool P_ChangeSector(sector_t *sector, int crunch, int amt, int floorOrCeil, bool isreset) { FChangePosition cpos; - void (*iterator)(AActor *, FChangePosition *); - void (*iterator2)(AActor *, FChangePosition *) = NULL; + void(*iterator)(AActor *, FChangePosition *); + void(*iterator2)(AActor *, FChangePosition *) = NULL; msecnode_t *n; cpos.nofit = false; cpos.crushchange = crunch; - cpos.moveamt = abs (amt); + cpos.moveamt = abs(amt); cpos.movemidtex = false; cpos.sector = sector; #ifdef _3DFLOORS // Also process all sectors that have 3D floors transferred from the // changed sector. - if(sector->e->XFloor.attached.Size()) + if (sector->e->XFloor.attached.Size()) { unsigned i; sector_t* sec; @@ -5285,30 +5249,30 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, boo // Use different functions for the four different types of sector movement. // for 3D-floors the meaning of floor and ceiling is inverted!!! if (floorOrCeil == 1) - { + { iterator = (amt >= 0) ? PIT_FloorRaise : PIT_FloorDrop; } else - { - iterator = (amt >=0) ? PIT_CeilingRaise : PIT_CeilingLower; + { + iterator = (amt >= 0) ? PIT_CeilingRaise : PIT_CeilingLower; } - for(i = 0; i < sector->e->XFloor.attached.Size(); i ++) + for (i = 0; i < sector->e->XFloor.attached.Size(); i++) { sec = sector->e->XFloor.attached[i]; P_Recalculate3DFloors(sec); // Must recalculate the 3d floor and light lists // no thing checks for attached sectors because of heightsec - if (sec->heightsec==sector) continue; + if (sec->heightsec == sector) continue; - for (n=sec->touching_thinglist; n; n=n->m_snext) n->visited = false; - do + for (n = sec->touching_thinglist; n; n = n->m_snext) n->visited = false; + do { - for (n=sec->touching_thinglist; n; n=n->m_snext) + for (n = sec->touching_thinglist; n; n = n->m_snext) { if (!n->visited) { - n->visited = true; + n->visited = true; if (!(n->m_thing->flags & MF_NOBLOCKMAP) || //jff 4/7/98 don't do these (n->m_thing->flags5 & MF5_MOVEWITHSECTOR)) { @@ -5317,8 +5281,7 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, boo break; } } - } - while (n); + } while (n); } } P_Recalculate3DFloors(sector); // Must recalculate the 3d floor and light lists @@ -5376,8 +5339,8 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, boo if (!(n->m_thing->flags & MF_NOBLOCKMAP) || //jff 4/7/98 don't do these (n->m_thing->flags5 & MF5_MOVEWITHSECTOR)) { - iterator (n->m_thing, &cpos); // process it - if (iterator2 != NULL) iterator2 (n->m_thing, &cpos); + iterator(n->m_thing, &cpos); // process it + if (iterator2 != NULL) iterator2(n->m_thing, &cpos); } break; // exit and start over } @@ -5391,7 +5354,7 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, boo // execute appropriate sector actions. // Only check if the sector move was successful. TArray & secs = sector->e->FakeFloor.Sectors; - for(unsigned i = 0; i < secs.Size(); i++) + for (unsigned i = 0; i < secs.Size(); i++) { sector_t * s = secs[i]; @@ -5446,7 +5409,7 @@ msecnode_t *P_GetSecnode() } else { - node = (msecnode_t *)M_Malloc (sizeof(*node)); + node = (msecnode_t *)M_Malloc(sizeof(*node)); } return node; } @@ -5459,7 +5422,7 @@ msecnode_t *P_GetSecnode() // //============================================================================= -void P_PutSecnode (msecnode_t *node) +void P_PutSecnode(msecnode_t *node) { node->m_snext = headsecnode; headsecnode = node; @@ -5477,13 +5440,13 @@ void P_PutSecnode (msecnode_t *node) // //============================================================================= -msecnode_t *P_AddSecnode (sector_t *s, AActor *thing, msecnode_t *nextnode) +msecnode_t *P_AddSecnode(sector_t *s, AActor *thing, msecnode_t *nextnode) { msecnode_t *node; if (s == 0) { - I_FatalError ("AddSecnode of 0 for %s\n", thing->_StaticType.TypeName.GetChars()); + I_FatalError("AddSecnode of 0 for %s\n", thing->_StaticType.TypeName.GetChars()); } node = nextnode; @@ -5506,16 +5469,16 @@ msecnode_t *P_AddSecnode (sector_t *s, AActor *thing, msecnode_t *nextnode) node->visited = 0; node->m_sector = s; // sector - node->m_thing = thing; // mobj - node->m_tprev = NULL; // prev node on Thing thread - node->m_tnext = nextnode; // next node on Thing thread + node->m_thing = thing; // mobj + node->m_tprev = NULL; // prev node on Thing thread + node->m_tnext = nextnode; // next node on Thing thread if (nextnode) nextnode->m_tprev = node; // set back link on Thing // Add new node at head of sector thread starting at s->touching_thinglist - node->m_sprev = NULL; // prev node on sector thread - node->m_snext = s->touching_thinglist; // next node on sector thread + node->m_sprev = NULL; // prev node on sector thread + node->m_snext = s->touching_thinglist; // next node on sector thread if (s->touching_thinglist) node->m_snext->m_sprev = node; s->touching_thinglist = node; @@ -5532,7 +5495,7 @@ msecnode_t *P_AddSecnode (sector_t *s, AActor *thing, msecnode_t *nextnode) // //============================================================================= -msecnode_t *P_DelSecnode (msecnode_t *node) +msecnode_t *P_DelSecnode(msecnode_t *node) { msecnode_t* tp; // prev node on thing thread msecnode_t* tn; // next node on thing thread @@ -5579,11 +5542,11 @@ msecnode_t *P_DelSecnode (msecnode_t *node) // //============================================================================= -void P_DelSector_List () +void P_DelSector_List() { if (sector_list != NULL) { - P_DelSeclist (sector_list); + P_DelSeclist(sector_list); sector_list = NULL; } } @@ -5596,10 +5559,10 @@ void P_DelSector_List () // //============================================================================= -void P_DelSeclist (msecnode_t *node) +void P_DelSeclist(msecnode_t *node) { while (node) - node = P_DelSecnode (node); + node = P_DelSecnode(node); } //============================================================================= @@ -5611,7 +5574,7 @@ void P_DelSeclist (msecnode_t *node) // //============================================================================= -void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) +void P_CreateSecNodeList(AActor *thing, fixed_t x, fixed_t y) { msecnode_t *node; @@ -5633,13 +5596,13 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) while ((ld = it.Next())) { - if (box.Right() <= ld->bbox[BOXLEFT] || - box.Left() >= ld->bbox[BOXRIGHT] || - box.Top() <= ld->bbox[BOXBOTTOM] || + if (box.Right() <= ld->bbox[BOXLEFT] || + box.Left() >= ld->bbox[BOXRIGHT] || + box.Top() <= ld->bbox[BOXBOTTOM] || box.Bottom() >= ld->bbox[BOXTOP]) continue; - if (box.BoxOnLineSide (ld) != -1) + if (box.BoxOnLineSide(ld) != -1) continue; // This line crosses through the object. @@ -5649,7 +5612,7 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) // allowed to move to this position, then the sector_list // will be attached to the Thing's AActor at touching_sectorlist. - sector_list = P_AddSecnode (ld->frontsector,thing,sector_list); + sector_list = P_AddSecnode(ld->frontsector, thing, sector_list); // Don't assume all lines are 2-sided, since some Things // like MT_TFOG are allowed regardless of whether their radius takes @@ -5664,7 +5627,7 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) // Add the sector of the (x,y) point to sector_list. - sector_list = P_AddSecnode (thing->Sector, thing, sector_list); + sector_list = P_AddSecnode(thing->Sector, thing, sector_list); // Now delete any nodes that won't be used. These are the ones where // m_thing is still NULL. @@ -5676,7 +5639,7 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) { if (node == sector_list) sector_list = node->m_tnext; - node = P_DelSecnode (node); + node = P_DelSecnode(node); } else { @@ -5691,7 +5654,7 @@ void P_CreateSecNodeList (AActor *thing, fixed_t x, fixed_t y) // //========================================================================== -void SpawnShootDecal (AActor *t1, const FTraceResults &trace) +void SpawnShootDecal(AActor *t1, const FTraceResults &trace) { FDecalBase *decalbase = NULL; @@ -5705,7 +5668,7 @@ void SpawnShootDecal (AActor *t1, const FTraceResults &trace) } if (decalbase != NULL) { - DImpactDecal::StaticCreate (decalbase->GetDecal (), + DImpactDecal::StaticCreate(decalbase->GetDecal(), trace.X, trace.Y, trace.Z, trace.Line->sidedef[trace.Side], trace.ffloor); } } @@ -5716,10 +5679,10 @@ void SpawnShootDecal (AActor *t1, const FTraceResults &trace) // //========================================================================== -static void SpawnDeepSplash (AActor *t1, const FTraceResults &trace, AActor *puff, +static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff, fixed_t vx, fixed_t vy, fixed_t vz, fixed_t shootz, bool ffloor) { - const secplane_t *plane; + const secplane_t *plane; if (ffloor && trace.Crossed3DWater) plane = trace.Crossed3DWater->top.plane; else if (trace.CrossedWater && trace.CrossedWater->heightsec) @@ -5727,19 +5690,19 @@ static void SpawnDeepSplash (AActor *t1, const FTraceResults &trace, AActor *puf else return; fixed_t num, den, hitdist; - den = TMulScale16 (plane->a, vx, plane->b, vy, plane->c, vz); + den = TMulScale16(plane->a, vx, plane->b, vy, plane->c, vz); if (den != 0) { - num = TMulScale16 (plane->a, t1->x, plane->b, t1->y, plane->c, shootz) + plane->d; - hitdist = FixedDiv (-num, den); + num = TMulScale16(plane->a, t1->x, plane->b, t1->y, plane->c, shootz) + plane->d; + hitdist = FixedDiv(-num, den); if (hitdist >= 0 && hitdist <= trace.Distance) { - fixed_t hitx = t1->x+FixedMul (vx, hitdist); - fixed_t hity = t1->y+FixedMul (vy, hitdist); - fixed_t hitz = shootz+FixedMul (vz, hitdist); + fixed_t hitx = t1->x + FixedMul(vx, hitdist); + fixed_t hity = t1->y + FixedMul(vy, hitdist); + fixed_t hitz = shootz + FixedMul(vz, hitdist); - P_HitWater (puff != NULL? puff:t1, P_PointInSector(hitx, hity), hitx, hity, hitz); + P_HitWater(puff != NULL ? puff : t1, P_PointInSector(hitx, hity), hitx, hity, hitz); } } } @@ -5761,12 +5724,12 @@ bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death) if (thing->activationtype & THINGSPEC_TriggerTargets) trigger->target = thing; // State change mechanism. The thing needs to be not dead and to have at least one of the relevant flags - if (!death && (thing->activationtype & (THINGSPEC_Activate|THINGSPEC_Deactivate|THINGSPEC_Switch))) + if (!death && (thing->activationtype & (THINGSPEC_Activate | THINGSPEC_Deactivate | THINGSPEC_Switch))) { // If a switchable thing does not know whether it should be activated // or deactivated, the default is to activate it. - if ((thing->activationtype & THINGSPEC_Switch) - && !(thing->activationtype & (THINGSPEC_Activate|THINGSPEC_Deactivate))) + if ((thing->activationtype & THINGSPEC_Switch) + && !(thing->activationtype & (THINGSPEC_Activate | THINGSPEC_Deactivate))) { thing->activationtype |= THINGSPEC_Activate; } @@ -5793,11 +5756,11 @@ bool P_ActivateThingSpecial(AActor * thing, AActor * trigger, bool death) // Run the special, if any if (thing->special) { - res = !! P_ExecuteSpecial(thing->special, NULL, + res = !!P_ExecuteSpecial(thing->special, NULL, // TriggerActs overrides the level flag, which only concerns thing activated by death (((death && level.flags & LEVEL_ACTOWNSPECIAL && !(thing->activationtype & THINGSPEC_TriggerActs)) || (thing->activationtype & THINGSPEC_ThingActs)) // Who triggers? - ? thing : trigger), + ? thing : trigger), false, thing->args[0], thing->args[1], thing->args[2], thing->args[3], thing->args[4]); // Clears the special if it was run on thing's death or if flag is set. From e1ee80661e285f2be6d3ef58e5ec0e1fe8d554fe Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 17:12:04 -0500 Subject: [PATCH 03/16] Make FWallCoords' members lowercase because they're kind of a pain to type when all uppercase. - Also, make its sx1 and sx2 members shorts, so it takes less space, since it's getting crammed into a vissprite now. --- src/r_bsp.cpp | 90 ++++++++++++------------ src/r_bsp.h | 12 ++-- src/r_segs.cpp | 180 +++++++++++++++++++++++------------------------ src/r_things.cpp | 12 ++-- 4 files changed, 147 insertions(+), 147 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 02a89f371..c56255888 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -408,7 +408,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->x, curline->v2->y)) { // Check that the window is actually visible - for (int z = WallC.SX1; z < WallC.SX2; ++z) + for (int z = WallC.sx1; z < WallC.sx2; ++z) { if (floorclip[z] > ceilingclip[z]) { @@ -541,12 +541,12 @@ void R_AddLine (seg_t *line) if (WallC.Init(tx1, ty1, tx2, ty2, 32)) return; - if (WallC.SX1 > WindowRight || WallC.SX2 < WindowLeft) + if (WallC.sx1 > WindowRight || WallC.sx2 < WindowLeft) return; if (line->linedef == NULL) { - if (R_CheckClipWallSegment (WallC.SX1, WallC.SX2)) + if (R_CheckClipWallSegment (WallC.sx1, WallC.sx2)) { InSubsector->flags |= SSECF_DRAWN; } @@ -695,7 +695,7 @@ void R_AddLine (seg_t *line) // mark their subsectors as visible for automap texturing. if (hasglnodes && !(InSubsector->flags & SSECF_DRAWN)) { - if (R_CheckClipWallSegment(WallC.SX1, WallC.SX2)) + if (R_CheckClipWallSegment(WallC.sx1, WallC.sx2)) { InSubsector->flags |= SSECF_DRAWN; } @@ -709,8 +709,8 @@ void R_AddLine (seg_t *line) if (line->linedef->special == Line_Horizon) { // Be aware: Line_Horizon does not work properly with sloped planes - clearbufshort (walltop+WallC.SX1, WallC.SX2 - WallC.SX1, centery); - clearbufshort (wallbottom+WallC.SX1, WallC.SX2 - WallC.SX1, centery); + clearbufshort (walltop+WallC.sx1, WallC.sx2 - WallC.sx1, centery); + clearbufshort (wallbottom+WallC.sx1, WallC.sx2 - WallC.sx1, centery); } else { @@ -735,7 +735,7 @@ void R_AddLine (seg_t *line) #endif } - if (R_ClipWallSegment (WallC.SX1, WallC.SX2, solid)) + if (R_ClipWallSegment (WallC.sx1, WallC.sx2, solid)) { InSubsector->flags |= SSECF_DRAWN; } @@ -748,58 +748,58 @@ void R_AddLine (seg_t *line) // bool FWallCoords::Init(int x1, int y1, int x2, int y2, int too_close) { - TX1 = DMulScale20(x1, viewsin, -y1, viewcos); - TX2 = DMulScale20(x2, viewsin, -y2, viewcos); + tx1 = DMulScale20(x1, viewsin, -y1, viewcos); + tx2 = DMulScale20(x2, viewsin, -y2, viewcos); - TY1 = DMulScale20(x1, viewtancos, y1, viewtansin); - TY2 = DMulScale20(x2, viewtancos, y2, viewtansin); + ty1 = DMulScale20(x1, viewtancos, y1, viewtansin); + ty2 = DMulScale20(x2, viewtancos, y2, viewtansin); if (MirrorFlags & RF_XFLIP) { - int t = 256 - TX1; - TX1 = 256 - TX2; - TX2 = t; - swapvalues(TY1, TY2); + int t = 256 - tx1; + tx1 = 256 - tx2; + tx2 = t; + swapvalues(ty1, ty2); } - if (TX1 >= -TY1) + if (tx1 >= -ty1) { - if (TX1 > TY1) return true; // left edge is off the right side - if (TY1 == 0) return true; - SX1 = (centerxfrac + Scale(TX1, centerxfrac, TY1)) >> FRACBITS; - if (TX1 >= 0) SX1 = MIN(viewwidth, SX1+1); // fix for signed divide - SZ1 = TY1; + if (tx1 > ty1) return true; // left edge is off the right side + if (ty1 == 0) return true; + sx1 = (centerxfrac + Scale(tx1, centerxfrac, ty1)) >> FRACBITS; + if (tx1 >= 0) sx1 = MIN(viewwidth, sx1+1); // fix for signed divide + sz1 = ty1; } else { - if (TX2 < -TY2) return true; // wall is off the left side - fixed_t den = TX1 - TX2 - TY2 + TY1; + if (tx2 < -ty2) return true; // wall is off the left side + fixed_t den = tx1 - tx2 - ty2 + ty1; if (den == 0) return true; - SX1 = 0; - SZ1 = TY1 + Scale(TY2 - TY1, TX1 + TY1, den); + sx1 = 0; + sz1 = ty1 + Scale(ty2 - ty1, tx1 + ty1, den); } - if (SZ1 < too_close) + if (sz1 < too_close) return true; - if (TX2 <= TY2) + if (tx2 <= ty2) { - if (TX2 < -TY2) return true; // right edge is off the left side - if (TY2 == 0) return true; - SX2 = (centerxfrac + Scale(TX2, centerxfrac, TY2)) >> FRACBITS; - if (TX2 >= 0) SX2 = MIN(viewwidth, SX2+1); // fix for signed divide - SZ2 = TY2; + if (tx2 < -ty2) return true; // right edge is off the left side + if (ty2 == 0) return true; + sx2 = (centerxfrac + Scale(tx2, centerxfrac, ty2)) >> FRACBITS; + if (tx2 >= 0) sx2 = MIN(viewwidth, sx2+1); // fix for signed divide + sz2 = ty2; } else { - if (TX1 > TY1) return true; // wall is off the right side - fixed_t den = TY2 - TY1 - TX2 + TX1; + if (tx1 > ty1) return true; // wall is off the right side + fixed_t den = ty2 - ty1 - tx2 + tx1; if (den == 0) return true; - SX2 = viewwidth; - SZ2 = TY1 + Scale(TY2 - TY1, TX1 - TY1, den); + sx2 = viewwidth; + sz2 = ty1 + Scale(ty2 - ty1, tx1 - ty1, den); } - if (SZ2 < too_close || SX2 <= SX1) + if (sz2 < too_close || sx2 <= sx1) return true; return false; @@ -809,17 +809,17 @@ void FWallTmapVals::InitFromWallCoords(const FWallCoords *wallc) { if (MirrorFlags & RF_XFLIP) { - UoverZorg = (float)wallc->TX2 * WallTMapScale; - UoverZstep = (float)(-wallc->TY2) * 32.f; - InvZorg = (float)(wallc->TX2 - wallc->TX1) * WallTMapScale; - InvZstep = (float)(wallc->TY1 - wallc->TY2) * 32.f; + UoverZorg = (float)wallc->tx2 * WallTMapScale; + UoverZstep = (float)(-wallc->ty2) * 32.f; + InvZorg = (float)(wallc->tx2 - wallc->tx1) * WallTMapScale; + InvZstep = (float)(wallc->ty1 - wallc->ty2) * 32.f; } else { - UoverZorg = (float)wallc->TX1 * WallTMapScale; - UoverZstep = (float)(-wallc->TY1) * 32.f; - InvZorg = (float)(wallc->TX1 - wallc->TX2) * WallTMapScale; - InvZstep = (float)(wallc->TY2 - wallc->TY1) * 32.f; + UoverZorg = (float)wallc->tx1 * WallTMapScale; + UoverZstep = (float)(-wallc->ty1) * 32.f; + InvZorg = (float)(wallc->tx1 - wallc->tx2) * WallTMapScale; + InvZstep = (float)(wallc->ty2 - wallc->ty1) * 32.f; } InitDepth(); } diff --git a/src/r_bsp.h b/src/r_bsp.h index d15beca0c..79dac6c88 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -33,14 +33,14 @@ struct FWallCoords { - fixed_t TX1, TX2; // x coords at left, right of wall in view space - fixed_t TY1, TY2; // y coords at left, right of wall in view space + fixed_t tx1, tx2; // x coords at left, right of wall in view space + fixed_t ty1, ty2; // y coords at left, right of wall in view space - fixed_t CX1, CX2; // x coords at left, right of wall in camera space - fixed_t CY1, CY2; // y coords at left, right of wall in camera space + fixed_t cx1, cx2; // x coords at left, right of wall in camera space + fixed_t cy1, cy2; // y coords at left, right of wall in camera space - int SX1, SX2; // x coords at left, right of wall in screen space - fixed_t SZ1, SZ2; // depth at left, right of wall in screen space + short sx1, sx2; // x coords at left, right of wall in screen space + fixed_t sz1, sz2; // depth at left, right of wall in screen space bool Init(int x1, int y1, int x2, int y2, int too_close); }; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 25395a596..15f736c93 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -376,10 +376,10 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) goto clearfog; } - WallC.SZ1 = ds->sz1; - WallC.SZ2 = ds->sz2; - WallC.SX1 = ds->sx1; - WallC.SX2 = ds->sx2; + WallC.sz1 = ds->sz1; + WallC.sz2 = ds->sz2; + WallC.sx1 = ds->sx1; + WallC.sx2 = ds->sx2; if (fake3D & FAKE3D_CLIPTOP) { @@ -467,10 +467,10 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } else { // Texture does wrap vertically. - WallC.SZ1 = ds->sz1; - WallC.SZ2 = ds->sz2; - WallC.SX1 = ds->sx1; - WallC.SX2 = ds->sx2; + WallC.sz1 = ds->sz1; + WallC.sz2 = ds->sz2; + WallC.sx1 = ds->sx1; + WallC.sx2 = ds->sx2; if (CurrentSkybox) { // Midtex clipping doesn't work properly with skyboxes, since you're normally below the floor @@ -587,14 +587,14 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) else if (fixedcolormap != NULL) dc_colormap = fixedcolormap; - WallC.SZ1 = ds->sz1; - WallC.SZ2 = ds->sz2; - WallC.SX1 = ds->sx1; - WallC.SX2 = ds->sx2; - WallC.TX1 = ds->cx; - WallC.TY1 = ds->cy; - WallC.TX2 = ds->cx + ds->cdx; - WallC.TY2 = ds->cy + ds->cdy; + WallC.sz1 = ds->sz1; + WallC.sz2 = ds->sz2; + WallC.sx1 = ds->sx1; + WallC.sx2 = ds->sx2; + WallC.tx1 = ds->cx; + WallC.ty1 = ds->cy; + WallC.tx2 = ds->cx + ds->cdx; + WallC.ty2 = ds->cy + ds->cdy; WallT = ds->tmapvals; OWallMost(wallupper, sclipTop - viewz, &WallC); @@ -1209,8 +1209,8 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, up = uwal; down = most1; - assert(WallC.SX1 <= x1); - assert(WallC.SX2 > x2); + assert(WallC.sx1 <= x1); + assert(WallC.sx2 > x2); // kg3D - fake floors instead of zdoom light list for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++) @@ -1821,7 +1821,7 @@ void R_RenderSegLoop () yscale = FixedMul(rw_pic->yScale, rw_midtexturescaley); if (xscale != lwallscale) { - PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); lwallscale = xscale; } if (midtexture->bWorldPanning) @@ -1864,7 +1864,7 @@ void R_RenderSegLoop () yscale = FixedMul(rw_pic->yScale, rw_toptexturescaley); if (xscale != lwallscale) { - PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); lwallscale = xscale; } if (toptexture->bWorldPanning) @@ -1910,7 +1910,7 @@ void R_RenderSegLoop () yscale = FixedMul(rw_pic->yScale, rw_bottomtexturescaley); if (xscale != lwallscale) { - PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.SX1, WallC.SX2); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); lwallscale = xscale; } if (bottomtexture->bWorldPanning) @@ -2030,7 +2030,7 @@ void R_NewWall (bool needlights) { if (rw_havehigh) { // front ceiling is above back ceiling - memcpy (&walltop[WallC.SX1], &wallupper[WallC.SX1], (WallC.SX2 - WallC.SX1)*sizeof(walltop[0])); + memcpy (&walltop[WallC.sx1], &wallupper[WallC.sx1], (WallC.sx2 - WallC.sx1)*sizeof(walltop[0])); rw_havehigh = false; } else if (rw_havelow && frontsector->ceilingplane != backsector->ceilingplane) @@ -2255,15 +2255,15 @@ void R_NewWall (bool needlights) bottomtexture ? FixedMul(bottomtexture->xScale, sidedef->GetTextureXScale(side_t::bottom)) : FRACUNIT; - PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.SX1, WallC.SX2); + PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.sx1, WallC.sx2); if (fixedcolormap == NULL && fixedlightlev < 0) { wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel) + r_actualextralight); GlobVis = r_WallVisibility; - rw_lightleft = SafeDivScale12 (GlobVis, WallC.SZ1); - rw_lightstep = (SafeDivScale12 (GlobVis, WallC.SZ2) - rw_lightleft) / (WallC.SX2 - WallC.SX1); + rw_lightleft = SafeDivScale12 (GlobVis, WallC.sz1); + rw_lightstep = (SafeDivScale12 (GlobVis, WallC.sz2) - rw_lightleft) / (WallC.sx2 - WallC.sx1); } else { @@ -2337,19 +2337,19 @@ void R_StoreWallRange (int start, int stop) } rw_offset = sidedef->GetTextureXOffset(side_t::mid); - rw_light = rw_lightleft + rw_lightstep * (start - WallC.SX1); + rw_light = rw_lightleft + rw_lightstep * (start - WallC.sx1); - ds_p->sx1 = WallC.SX1; - ds_p->sx2 = WallC.SX2; - ds_p->sz1 = WallC.SZ1; - ds_p->sz2 = WallC.SZ2; - ds_p->cx = WallC.TX1; - ds_p->cy = WallC.TY1; - ds_p->cdx = WallC.TX2 - WallC.TX1; - ds_p->cdy = WallC.TY2 - WallC.TY1; + ds_p->sx1 = WallC.sx1; + ds_p->sx2 = WallC.sx2; + ds_p->sz1 = WallC.sz1; + ds_p->sz2 = WallC.sz2; + ds_p->cx = WallC.tx1; + ds_p->cy = WallC.ty1; + ds_p->cdx = WallC.tx2 - WallC.tx1; + ds_p->cdy = WallC.ty2 - WallC.ty1; ds_p->tmapvals = WallT; - ds_p->siz1 = (DWORD)DivScale32 (1, WallC.SZ1) >> 1; - ds_p->siz2 = (DWORD)DivScale32 (1, WallC.SZ2) >> 1; + ds_p->siz1 = (DWORD)DivScale32 (1, WallC.sz1) >> 1; + ds_p->siz2 = (DWORD)DivScale32 (1, WallC.sz2) >> 1; ds_p->x1 = rw_x = start; ds_p->x2 = stop-1; ds_p->curline = curline; @@ -2442,7 +2442,7 @@ void R_StoreWallRange (int start, int stop) if ((TexMan(sidedef->GetTexture(side_t::mid), true)->UseType != FTexture::TEX_Null || ds_p->bFakeBoundary || IsFogBoundary (frontsector, backsector)) && (rw_ceilstat != 12 || !sidedef->GetTexture(side_t::top).isValid()) && (rw_floorstat != 3 || !sidedef->GetTexture(side_t::bottom).isValid()) && - (WallC.SZ1 >= TOO_CLOSE_Z && WallC.SZ2 >= TOO_CLOSE_Z)) + (WallC.sz1 >= TOO_CLOSE_Z && WallC.sz2 >= TOO_CLOSE_Z)) { fixed_t *swal; fixed_t *lwal; @@ -2590,59 +2590,59 @@ int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc) fixed_t s1, s2, s3, s4; z = -(z >> 4); - s1 = MulScale16 (globaluclip, wallc->SZ1); s2 = MulScale16 (globaluclip, wallc->SZ2); - s3 = MulScale16 (globaldclip, wallc->SZ1); s4 = MulScale16 (globaldclip, wallc->SZ2); + s1 = MulScale16 (globaluclip, wallc->sz1); s2 = MulScale16 (globaluclip, wallc->sz2); + s3 = MulScale16 (globaldclip, wallc->sz1); s4 = MulScale16 (globaldclip, wallc->sz2); bad = (zs3)<<2)+((z>s4)<<3); #if 1 if ((bad&3) == 3) { - memset (&mostbuf[wallc->SX1], 0, (wallc->SX2 - wallc->SX1)*sizeof(mostbuf[0])); + memset (&mostbuf[wallc->sx1], 0, (wallc->sx2 - wallc->sx1)*sizeof(mostbuf[0])); return bad; } if ((bad&12) == 12) { - clearbufshort (&mostbuf[wallc->SX1], wallc->SX2 - wallc->SX1, viewheight); + clearbufshort (&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight); return bad; } #endif - ix1 = wallc->SX1; iy1 = wallc->SZ1; - ix2 = wallc->SX2; iy2 = wallc->SZ2; + ix1 = wallc->sx1; iy1 = wallc->sz1; + ix2 = wallc->sx2; iy2 = wallc->sz2; #if 1 if (bad & 3) { int t = DivScale30 (z-s1, s2-s1); - int inty = wallc->SZ1 + MulScale30 (wallc->SZ2 - wallc->SZ1, t); - int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2 - wallc->SX1, inty); + int inty = wallc->sz1 + MulScale30 (wallc->sz2 - wallc->sz1, t); + int xcross = wallc->sx1 + Scale (MulScale30 (wallc->sz2, t), wallc->sx2 - wallc->sx1, inty); if ((bad & 3) == 2) { - if (wallc->SX1 <= xcross) { iy2 = inty; ix2 = xcross; } - if (wallc->SX2 > xcross) memset (&mostbuf[xcross], 0, (wallc->SX2-xcross)*sizeof(mostbuf[0])); + if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; } + if (wallc->sx2 > xcross) memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0])); } else { - if (xcross <= wallc->SX2) { iy1 = inty; ix1 = xcross; } - if (xcross > wallc->SX1) memset (&mostbuf[wallc->SX1], 0, (xcross-wallc->SX1)*sizeof(mostbuf[0])); + if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; } + if (xcross > wallc->sx1) memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0])); } } if (bad & 12) { int t = DivScale30 (z-s3, s4-s3); - int inty = wallc->SZ1 + MulScale30 (wallc->SZ2 - wallc->SZ1, t); - int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2 - wallc->SX1, inty); + int inty = wallc->sz1 + MulScale30 (wallc->sz2 - wallc->sz1, t); + int xcross = wallc->sx1 + Scale (MulScale30 (wallc->sz2, t), wallc->sx2 - wallc->sx1, inty); if ((bad & 12) == 8) { - if (wallc->SX1 <= xcross) { iy2 = inty; ix2 = xcross; } - if (wallc->SX2 > xcross) clearbufshort (&mostbuf[xcross], wallc->SX2 - xcross, viewheight); + if (wallc->sx1 <= xcross) { iy2 = inty; ix2 = xcross; } + if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2 - xcross, viewheight); } else { - if (xcross <= wallc->SX2) { iy1 = inty; ix1 = xcross; } - if (xcross > wallc->SX1) clearbufshort (&mostbuf[wallc->SX1], xcross - wallc->SX1, viewheight); + if (xcross <= wallc->sx2) { iy1 = inty; ix1 = xcross; } + if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross - wallc->sx1, viewheight); } } @@ -2660,12 +2660,12 @@ int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc) double max = viewheight; double zz = z / 65536.0; #if 0 - double z1 = zz * InvZtoScale / wallc->SZ1; - double z2 = zz * InvZtoScale / wallc->SZ2 - z1; - z2 /= (wallc->SX2 - wallc->SX1); + double z1 = zz * InvZtoScale / wallc->sz1; + double z2 = zz * InvZtoScale / wallc->sz2 - z1; + z2 /= (wallc->sx2 - wallc->sx1); z1 += centeryfrac / 65536.0; - for (int x = wallc->SX1; x < wallc->SX2; ++x) + for (int x = wallc->sx1; x < wallc->sx2; ++x) { mostbuf[x] = xs_RoundToInt(clamp(z1, 0.0, max)); z1 += z2; @@ -2673,12 +2673,12 @@ int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc) #else double top, bot, i; - i = wallc->SX1 - centerx; + i = wallc->sx1 - centerx; top = WallT.UoverZorg + WallT.UoverZstep * i; bot = WallT.InvZorg + WallT.InvZstep * i; double cy = centeryfrac / 65536.0; - for (int x = wallc->SX1; x < wallc->SX2; x++) + for (int x = wallc->sx1; x < wallc->sx2; x++) { double frac = top / bot; double scale = frac * WallT.DepthScale + WallT.DepthOrg; @@ -2711,21 +2711,21 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) { x = curline->v2->x; y = curline->v2->y; - if (wallc->SX1 == 0 && 0 != (den = wallc->TX1 - wallc->TX2 + wallc->TY1 - wallc->TY2)) + if (wallc->sx1 == 0 && 0 != (den = wallc->tx1 - wallc->tx2 + wallc->ty1 - wallc->ty2)) { - int frac = SafeDivScale30 (wallc->TY1 + wallc->TX1, den); + int frac = SafeDivScale30 (wallc->ty1 + wallc->tx1, den); x -= MulScale30 (frac, x - curline->v1->x); y -= MulScale30 (frac, y - curline->v1->y); } z1 = viewz - plane.ZatPoint (x, y); - if (wallc->SX2 > wallc->SX1 + 1) + if (wallc->sx2 > wallc->sx1 + 1) { x = curline->v1->x; y = curline->v1->y; - if (wallc->SX2 == viewwidth && 0 != (den = wallc->TX1 - wallc->TX2 - wallc->TY1 + wallc->TY2)) + if (wallc->sx2 == viewwidth && 0 != (den = wallc->tx1 - wallc->tx2 - wallc->ty1 + wallc->ty2)) { - int frac = SafeDivScale30 (wallc->TY2 - wallc->TX2, den); + int frac = SafeDivScale30 (wallc->ty2 - wallc->tx2, den); x += MulScale30 (frac, curline->v2->x - x); y += MulScale30 (frac, curline->v2->y - y); } @@ -2740,21 +2740,21 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) { x = curline->v1->x; y = curline->v1->y; - if (wallc->SX1 == 0 && 0 != (den = wallc->TX1 - wallc->TX2 + wallc->TY1 - wallc->TY2)) + if (wallc->sx1 == 0 && 0 != (den = wallc->tx1 - wallc->tx2 + wallc->ty1 - wallc->ty2)) { - int frac = SafeDivScale30 (wallc->TY1 + wallc->TX1, den); + int frac = SafeDivScale30 (wallc->ty1 + wallc->tx1, den); x += MulScale30 (frac, curline->v2->x - x); y += MulScale30 (frac, curline->v2->y - y); } z1 = viewz - plane.ZatPoint (x, y); - if (wallc->SX2 > wallc->SX1 + 1) + if (wallc->sx2 > wallc->sx1 + 1) { x = curline->v2->x; y = curline->v2->y; - if (wallc->SX2 == viewwidth && 0 != (den = wallc->TX1 - wallc->TX2 - wallc->TY1 + wallc->TY2)) + if (wallc->sx2 == viewwidth && 0 != (den = wallc->tx1 - wallc->tx2 - wallc->ty1 + wallc->ty2)) { - int frac = SafeDivScale30 (wallc->TY2 - wallc->TX2, den); + int frac = SafeDivScale30 (wallc->ty2 - wallc->tx2, den); x -= MulScale30 (frac, x - curline->v1->x); y -= MulScale30 (frac, y - curline->v1->y); } @@ -2766,12 +2766,12 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) } } - s1 = MulScale12 (globaluclip, wallc->SZ1); s2 = MulScale12 (globaluclip, wallc->SZ2); - s3 = MulScale12 (globaldclip, wallc->SZ1); s4 = MulScale12 (globaldclip, wallc->SZ2); + s1 = MulScale12 (globaluclip, wallc->sz1); s2 = MulScale12 (globaluclip, wallc->sz2); + s3 = MulScale12 (globaldclip, wallc->sz1); s4 = MulScale12 (globaldclip, wallc->sz2); bad = (z1s3)<<2)+((z2>s4)<<3); - ix1 = wallc->SX1; ix2 = wallc->SX2; - iy1 = wallc->SZ1; iy2 = wallc->SZ2; + ix1 = wallc->sx1; ix2 = wallc->sx2; + iy1 = wallc->sz1; iy2 = wallc->sz2; oz1 = z1; oz2 = z2; if ((bad&3) == 3) @@ -2791,9 +2791,9 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) { //inty = intz / (globaluclip>>16) int t = SafeDivScale30 (oz1-s1, s2-s1+oz1-oz2); - int inty = wallc->SZ1 + MulScale30 (wallc->SZ2-wallc->SZ1,t); + int inty = wallc->sz1 + MulScale30 (wallc->sz2-wallc->sz1,t); int intz = oz1 + MulScale30 (oz2-oz1,t); - int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2-wallc->SX1, inty); + int xcross = wallc->sx1 + Scale (MulScale30 (wallc->sz2, t), wallc->sx2-wallc->sx1, inty); //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); @@ -2801,13 +2801,13 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) if ((bad&3) == 2) { - if (wallc->SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } - memset (&mostbuf[xcross], 0, (wallc->SX2-xcross)*sizeof(mostbuf[0])); + if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + memset (&mostbuf[xcross], 0, (wallc->sx2-xcross)*sizeof(mostbuf[0])); } else { - if (xcross <= wallc->SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } - memset (&mostbuf[wallc->SX1], 0, (xcross-wallc->SX1)*sizeof(mostbuf[0])); + if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; } + memset (&mostbuf[wallc->sx1], 0, (xcross-wallc->sx1)*sizeof(mostbuf[0])); } } @@ -2815,9 +2815,9 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) { //inty = intz / (globaldclip>>16) int t = SafeDivScale30 (oz1-s3, s4-s3+oz1-oz2); - int inty = wallc->SZ1 + MulScale30 (wallc->SZ2-wallc->SZ1,t); + int inty = wallc->sz1 + MulScale30 (wallc->sz2-wallc->sz1,t); int intz = oz1 + MulScale30 (oz2-oz1,t); - int xcross = wallc->SX1 + Scale (MulScale30 (wallc->SZ2, t), wallc->SX2-wallc->SX1,inty); + int xcross = wallc->sx1 + Scale (MulScale30 (wallc->sz2, t), wallc->sx2-wallc->sx1,inty); //t = divscale30((x1<<4)-xcross*yb1[w],xcross*(yb2[w]-yb1[w])-((x2-x1)<<4)); //inty = yb1[w] + mulscale30(yb2[w]-yb1[w],t); @@ -2825,13 +2825,13 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) if ((bad&12) == 8) { - if (wallc->SX1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } - if (wallc->SX2 > xcross) clearbufshort (&mostbuf[xcross], wallc->SX2-xcross, viewheight); + if (wallc->sx1 <= xcross) { z2 = intz; iy2 = inty; ix2 = xcross; } + if (wallc->sx2 > xcross) clearbufshort (&mostbuf[xcross], wallc->sx2-xcross, viewheight); } else { - if (xcross <= wallc->SX2) { z1 = intz; iy1 = inty; ix1 = xcross; } - if (xcross > wallc->SX1) clearbufshort (&mostbuf[wallc->SX1], xcross-wallc->SX1, viewheight); + if (xcross <= wallc->sx2) { z1 = intz; iy1 = inty; ix1 = xcross; } + if (xcross > wallc->sx1) clearbufshort (&mostbuf[wallc->sx1], xcross-wallc->sx1, viewheight); } } @@ -3041,8 +3041,8 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, if (WallC.Init(lx, ly, lx2, ly2, TOO_CLOSE_Z)) goto done; - x1 = WallC.SX1; - x2 = WallC.SX2; + x1 = WallC.sx1; + x2 = WallC.sx2; if (x1 > clipper->x2 || x2 <= clipper->x1) goto done; @@ -3145,7 +3145,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, rereadcolormap = false; } - rw_light = rw_lightleft + (x1 - WallC.SX1) * rw_lightstep; + rw_light = rw_lightleft + (x1 - WallC.sx1) * rw_lightstep; if (fixedlightlev >= 0) dc_colormap = usecolormap->Maps + fixedlightlev; else if (fixedcolormap != NULL) diff --git a/src/r_things.cpp b/src/r_things.cpp index 1d2c07a2a..72ebcf8c4 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -411,8 +411,8 @@ void R_DrawWallSprite(vissprite_t *spr) fixed_t yscale; int shade = LIGHT2SHADE(140); - x1 = MAX(spr->x1, spr->wallc.SX1); - x2 = MIN(spr->x2, spr->wallc.SX2 + 1); + x1 = MAX(spr->x1, spr->wallc.sx1); + x2 = MIN(spr->x2, spr->wallc.sx2 + 1); if (x1 >= x2) return; WallT.InitFromWallCoords(&spr->wallc); @@ -440,7 +440,7 @@ void R_DrawWallSprite(vissprite_t *spr) rereadcolormap = false; } - rw_light = rw_lightleft + (x1 - spr->wallc.SX1) * rw_lightstep; + rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; if (fixedlightlev >= 0) dc_colormap = usecolormap->Maps + fixedlightlev; else if (fixedcolormap != NULL) @@ -1057,7 +1057,7 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f if (wallc.Init(lx1, ly1, lx2, ly2, TOO_CLOSE_Z)) return; - if (wallc.SX1 > WindowRight || wallc.SX2 <= WindowLeft) + if (wallc.sx1 > WindowRight || wallc.sx2 <= WindowLeft) return; // Sprite sorting should probably treat these as walls, not sprites, @@ -1070,8 +1070,8 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f gzb = fz + yscale * scaled_bo; vis = R_NewVisSprite(); - vis->x1 = wallc.SX1 < WindowLeft ? WindowLeft : wallc.SX1; - vis->x2 = wallc.SX2 >= WindowRight ? WindowRight-1 : wallc.SX2-1; + vis->x1 = wallc.sx1 < WindowLeft ? WindowLeft : wallc.sx1; + vis->x2 = wallc.sx2 >= WindowRight ? WindowRight-1 : wallc.sx2-1; vis->idepth = (unsigned)DivScale32(1, tz) >> 1; vis->depth = tz; vis->sector = thing->Sector; From 0aa67c68ab44ee79dbbad27765ae41e18d41256d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 17:23:06 -0500 Subject: [PATCH 04/16] Redo lighting for each wall sprite - Because previously it just reused whatever the most recently drawn wall used. --- src/r_things.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 72ebcf8c4..84ce18b64 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -409,7 +409,6 @@ void R_DrawWallSprite(vissprite_t *spr) { int x1, x2; fixed_t yscale; - int shade = LIGHT2SHADE(140); x1 = MAX(spr->x1, spr->wallc.sx1); x2 = MIN(spr->x2, spr->wallc.sx2 + 1); @@ -440,6 +439,10 @@ void R_DrawWallSprite(vissprite_t *spr) rereadcolormap = false; } + int shade = LIGHT2SHADE(spr->sector->lightlevel + r_actualextralight); + GlobVis = r_WallVisibility; + rw_lightleft = SafeDivScale12(GlobVis, spr->wallc.sz1); + rw_lightstep = (SafeDivScale12(GlobVis, spr->wallc.sz2) - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1); rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; if (fixedlightlev >= 0) dc_colormap = usecolormap->Maps + fixedlightlev; From 6303935ad61bc360dae646ac052a784b1d68e782 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 19:57:55 -0500 Subject: [PATCH 05/16] Use wall sprite Y scale --- src/r_things.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 84ce18b64..9a6bfee6f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -416,8 +416,8 @@ void R_DrawWallSprite(vissprite_t *spr) return; WallT.InitFromWallCoords(&spr->wallc); PrepWall(swall, lwall, spr->pic->GetWidth() << FRACBITS, x1, x2); - dc_texturemid = spr->gzt - viewz; - yscale = FRACUNIT; + yscale = spr->yscale; + dc_texturemid = FixedDiv(spr->gzt - viewz, yscale); if (spr->renderflags & RF_XFLIP) { int right = (spr->pic->GetWidth() << FRACBITS) - 1; @@ -1075,6 +1075,7 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f vis = R_NewVisSprite(); vis->x1 = wallc.sx1 < WindowLeft ? WindowLeft : wallc.sx1; vis->x2 = wallc.sx2 >= WindowRight ? WindowRight-1 : wallc.sx2-1; + vis->yscale = yscale; vis->idepth = (unsigned)DivScale32(1, tz) >> 1; vis->depth = tz; vis->sector = thing->Sector; From 7b02027ba72879a95261d353f1155c0e8d33a823 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 20:00:49 -0500 Subject: [PATCH 06/16] Fixed: Wall sprites cut off one pixel short of the window's right border --- src/r_things.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 9a6bfee6f..801d25bfb 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -411,7 +411,7 @@ void R_DrawWallSprite(vissprite_t *spr) fixed_t yscale; x1 = MAX(spr->x1, spr->wallc.sx1); - x2 = MIN(spr->x2, spr->wallc.sx2 + 1); + x2 = MIN(spr->x2 + 1, spr->wallc.sx2 + 1); if (x1 >= x2) return; WallT.InitFromWallCoords(&spr->wallc); @@ -1074,7 +1074,7 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f vis = R_NewVisSprite(); vis->x1 = wallc.sx1 < WindowLeft ? WindowLeft : wallc.sx1; - vis->x2 = wallc.sx2 >= WindowRight ? WindowRight-1 : wallc.sx2-1; + vis->x2 = wallc.sx2 >= WindowRight ? WindowRight : wallc.sx2-1; vis->yscale = yscale; vis->idepth = (unsigned)DivScale32(1, tz) >> 1; vis->depth = tz; From 9659b894a3663aceb640d61e6950e1ac7ef256b5 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 20:43:09 -0500 Subject: [PATCH 07/16] Skip neardepth/fardepth checking in R_DrawSprite - Wall sprites now clip much, much better than before. --- src/r_things.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 801d25bfb..092e799dc 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2076,19 +2076,9 @@ void R_DrawSprite (vissprite_t *spr) r1 = MAX (ds->x1, x1); r2 = MIN (ds->x2, x2); - fixed_t neardepth, fardepth; - if (ds->sz1 < ds->sz2) - { - neardepth = ds->sz1, fardepth = ds->sz2; - } - else - { - neardepth = ds->sz2, fardepth = ds->sz1; - } - if (neardepth > spr->depth || (fardepth > spr->depth && - // Check if sprite is in front of draw seg: - DMulScale32(spr->gy - ds->curline->v1->y, ds->curline->v2->x - ds->curline->v1->x, - ds->curline->v1->x - spr->gx, ds->curline->v2->y - ds->curline->v1->y) <= 0)) + // Check if sprite is in front of draw seg: + if (DMulScale32(spr->gy - ds->curline->v1->y, ds->curline->v2->x - ds->curline->v1->x, + ds->curline->v1->x - spr->gx, ds->curline->v2->y - ds->curline->v1->y) <= 0) { // seg is behind sprite, so draw the mid texture if it has one if (ds->maskedtexturecol != -1 || ds->bFogBoundary) From e6a1d6b516eb45206e8a688de26dd70c357799ef Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 22:00:02 -0500 Subject: [PATCH 08/16] Parse more info from Blood's map header --- src/p_buildmap.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 32651b5bb..7e2f0b472 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -249,7 +249,7 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * BYTE infoBlock[37]; int mapver = data[5]; DWORD matt; - int numRevisions, numWalls, numsprites, skyLen; + int numRevisions, numWalls, numsprites, skyLen, visibility, parallaxType; int i; int k; @@ -269,11 +269,14 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * { memcpy (infoBlock, data + 6, 37); } + skyLen = 2 << LittleShort(*(WORD *)(infoBlock + 16)); + visibility = LittleLong(*(DWORD *)(infoBlock + 18)); + parallaxType = infoBlock[26]; numRevisions = LittleLong(*(DWORD *)(infoBlock + 27)); numsectors = LittleShort(*(WORD *)(infoBlock + 31)); numWalls = LittleShort(*(WORD *)(infoBlock + 33)); numsprites = LittleShort(*(WORD *)(infoBlock + 35)); - skyLen = 2 << LittleShort(*(WORD *)(infoBlock + 16)); + Printf("Visibility: %d\n", visibility); if (mapver == 7) { From fbb5689f298348003c5fbf90956656e1f946e30f Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 22:26:24 -0500 Subject: [PATCH 09/16] Eliminate extra vars from FWallCoords - cx1, cx2, cy1, and cy2 are not used anywhere, so get rid of them. - Also annotated the comments to indicate the corresponding arrays in the Build engine. --- src/r_bsp.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/r_bsp.h b/src/r_bsp.h index 79dac6c88..1b5af9805 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -33,14 +33,11 @@ struct FWallCoords { - fixed_t tx1, tx2; // x coords at left, right of wall in view space - fixed_t ty1, ty2; // y coords at left, right of wall in view space + fixed_t tx1, tx2; // x coords at left, right of wall in view space rx1,rx2 + fixed_t ty1, ty2; // y coords at left, right of wall in view space ry1,ry2 - fixed_t cx1, cx2; // x coords at left, right of wall in camera space - fixed_t cy1, cy2; // y coords at left, right of wall in camera space - - short sx1, sx2; // x coords at left, right of wall in screen space - fixed_t sz1, sz2; // depth at left, right of wall in screen space + short sx1, sx2; // x coords at left, right of wall in screen space xb1,xb2 + fixed_t sz1, sz2; // depth at left, right of wall in screen space yb1,yb2 bool Init(int x1, int y1, int x2, int y2, int too_close); }; From 46592f5f6d3c72938911df920a9afb4391964a33 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 22:27:48 -0500 Subject: [PATCH 10/16] Don't clamp SHADE2LIGHT - Light levels aren't stored in bytes anymore, so there's no reason to clamp it anymore when loading Build maps. --- src/p_buildmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 7e2f0b472..2ee2ae83a 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -20,8 +20,8 @@ // MACROS ------------------------------------------------------------------ -//#define SHADE2LIGHT(s) (clamp (160-2*(s), 0, 255)) -#define SHADE2LIGHT(s) (clamp (255-2*s, 0, 255)) +//#define SHADE2LIGHT(s) (160-2*(s)) +#define SHADE2LIGHT(s) (255-2*s) // TYPES ------------------------------------------------------------------- From fefe6aa2c105e38056cf35668bd51f5f5b4073be Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Aug 2014 22:40:12 -0500 Subject: [PATCH 11/16] Specie -> Species - specie: money in the form of coins rather than notes - species: a group of living organisms consisting of similar individuals capable of exchanging genes or interbreeding --- src/p_map.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 68c2c1530..4ea8762ec 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3470,7 +3470,7 @@ struct Origin { AActor *Caller; bool hitGhosts; - bool hitSameSpecie; + bool hitSameSpecies; }; static ETraceStatus CheckForActor(FTraceResults &res, void *userdata) @@ -3488,7 +3488,7 @@ static ETraceStatus CheckForActor(FTraceResults &res, void *userdata) return TRACE_Skip; } - if (data->hitSameSpecie && res.Actor->GetSpecies() == data->Caller->GetSpecies()) + if (data->hitSameSpecies && res.Actor->GetSpecies() == data->Caller->GetSpecies()) { return TRACE_Skip; } @@ -3517,8 +3517,6 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, TData.Caller = t1; angle_t srcangle = angle; int srcpitch = pitch; - bool hitGhosts; - bool hitSameSpecie; bool killPuff = false; AActor *puff = NULL; int pflag = 0; @@ -3566,7 +3564,7 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, (t1->player->ReadyWeapon->flags2 & MF2_THRUGHOST)) || (puffDefaults && (puffDefaults->flags2 & MF2_THRUGHOST)); - TData.hitSameSpecie = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); + TData.hitSameSpecies = (puffDefaults && (puffDefaults->flags6 & MF6_MTHRUSPECIES)); // if the puff uses a non-standard damage type, this will override default, hitscan and melee damage type. // All other explicitly passed damage types (currenty only MDK) will be preserved. From 1fcde912984c9a5628ca01737b24c9787153c1de Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Aug 2014 09:25:35 +0200 Subject: [PATCH 12/16] - BlueShadow's GetArmorInfo submission. --- src/p_acs.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 2ca6fe909..1646ab7b7 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -120,6 +120,16 @@ FRandom pr_acs ("ACS"); #define SDF_ABSANGLE 1 #define SDF_PERMANENT 2 +// GetArmorInfo +enum +{ + ARMORINFO_CLASSNAME, + ARMORINFO_SAVEAMOUNT, + ARMORINFO_SAVEPERCENT, + ARMORINFO_MAXABSORB, + ARMORINFO_MAXFULLABSORB, +}; + struct CallReturn { CallReturn(int pc, ScriptFunction *func, FBehavior *module, SDWORD *locals, ACSLocalArrays *arrays, bool discard, unsigned int runaway) @@ -4349,6 +4359,7 @@ enum EACSFunctions ACSF_GetActorPowerupTics, ACSF_ChangeActorAngle, ACSF_ChangeActorPitch, // 80 + ACSF_GetArmorInfo, /* Zandronum's - these must be skipped when we reach 99! -100:ResetMap(0), @@ -4822,6 +4833,38 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const return 0; } + case ACSF_GetArmorInfo: + { + if (activator == NULL || activator->player == NULL) return 0; + + ABasicArmor * equippedarmor = (ABasicArmor *) activator->FindInventory(NAME_BasicArmor); + + if (equippedarmor && equippedarmor->Amount != 0) + { + switch(args[0]) + { + case ARMORINFO_CLASSNAME: + return GlobalACSStrings.AddString(equippedarmor->ArmorType.GetChars(), stack, stackdepth); + + case ARMORINFO_SAVEAMOUNT: + return equippedarmor->MaxAmount; + + case ARMORINFO_SAVEPERCENT: + return equippedarmor->SavePercent; + + case ARMORINFO_MAXABSORB: + return equippedarmor->MaxAbsorb; + + case ARMORINFO_MAXFULLABSORB: + return equippedarmor->MaxFullAbsorb; + + default: + return 0; + } + } + return args[0] == ARMORINFO_CLASSNAME ? GlobalACSStrings.AddString("None", stack, stackdepth) : 0; + } + case ACSF_SpawnSpotForced: return DoSpawnSpot(args[0], args[1], args[2], args[3], true); From 259466c3d462f55a7f8b07abfe850c619d0076ab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Aug 2014 09:39:38 +0200 Subject: [PATCH 13/16] fixed time printing. - In ZDoom the timer runs a bit too fast because roundoff errors make 35 tics only last 0.98 seconds. None of the internal timing has been changed, only the places where a time value is printed it will get adjusted for this discrepancy. --- src/cmdlib.h | 21 +++++++++++++++++++++ src/g_shared/sbarinfo_commands.cpp | 5 ++++- src/g_shared/shared_hud.cpp | 8 ++++---- src/g_shared/shared_sbar.cpp | 4 ++-- src/g_strife/strife_sbar.cpp | 20 ++++++++++++-------- src/statistics.cpp | 4 ++-- src/wi_stuff.cpp | 20 +++++++++++--------- 7 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/cmdlib.h b/src/cmdlib.h index e3a9d3d08..66747415a 100644 --- a/src/cmdlib.h +++ b/src/cmdlib.h @@ -62,4 +62,25 @@ struct FFileList void ScanDirectory(TArray &list, const char *dirpath); + +//========================================================================== +// +// Functions to compensate for a tic being a bit short. +// Since ZDoom uses a milliseconds timer for game timing +// 35 tics are actually only 0.98 seconds. +// For real time display this needs to be adjusted +// +//========================================================================== + +inline int AdjustTics(int tics) +{ + return (tics * 98) / 100; +} + +inline int Tics2Seconds(int tics) +{ + return (tics * 98) / (100 * TICRATE); +} + + #endif diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 629c31cb4..c9011e851 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -886,8 +886,11 @@ class CommandDrawString : public SBarInfoCommand } break; case TIME: - str.Format("%02d:%02d:%02d", (level.time/TICRATE)/3600, ((level.time/TICRATE)%3600)/60, (level.time/TICRATE)%60); + { + int sec = Tics2Seconds(level.time); + str.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60); break; + } case LOGTEXT: str = statusBar->CPlayer->LogText; break; diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 3806e5f9d..2daeff7a8 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -867,7 +867,7 @@ static void DrawTime() : (hud_showtime < 6 ? level.time : level.totaltime); - const int timeSeconds = timeTicks / TICRATE; + const int timeSeconds = Tics2Seconds(timeTicks); hours = timeSeconds / 3600; minutes = (timeSeconds % 3600) / 60; @@ -994,7 +994,7 @@ void DrawHUD() if (am_showtotaltime) { - seconds = level.totaltime / TICRATE; + seconds = Tics2Seconds(level.totaltime); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, FRACUNIT); bottom -= fonth; @@ -1004,14 +1004,14 @@ void DrawHUD() { if (level.clusterflags&CLUSTER_HUB) { - seconds = level.time /TICRATE; + seconds = Tics2Seconds(level.time); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, FRACUNIT); bottom -= fonth; } // Single level time for hubs - seconds= level.maptime /TICRATE; + seconds= Tics2Seconds(level.maptime); mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60); DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, FRACUNIT); } diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 6b2f609b7..89921e3a2 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1306,8 +1306,8 @@ void DBaseStatusBar::Draw (EHudState state) } else if (automapactive) { - int y, time = level.time / TICRATE, height; - int totaltime = level.totaltime / TICRATE; + int y, time = Tics2Seconds(level.time), height; + int totaltime = Tics2Seconds(level.totaltime); EColorRange highlight = (gameinfo.gametype & GAME_DoomChex) ? CR_UNTRANSLATED : CR_YELLOW; diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index 1a355b90a..89659e61d 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -586,29 +586,33 @@ private: screen->DrawTexture (Images[back], left, top, DTA_CleanNoMove, true, DTA_Alpha, FRACUNIT*3/4, TAG_DONE); screen->DrawTexture (Images[bars], left, top, DTA_CleanNoMove, true, TAG_DONE); + switch (CurrentPop) { case POP_Log: + { + int seconds = Tics2Seconds(level.time); // Draw the latest log message. - mysnprintf (buff, countof(buff), "%02d:%02d:%02d", - (level.time/TICRATE)/3600, - ((level.time/TICRATE)%3600)/60, - (level.time/TICRATE)%60); + mysnprintf(buff, countof(buff), "%02d:%02d:%02d", + seconds / 3600, + (seconds % 3600) / 60, + (seconds) % 60); - screen->DrawText (SmallFont2, CR_UNTRANSLATED, left+210*xscale, top+8*yscale, buff, + screen->DrawText(SmallFont2, CR_UNTRANSLATED, left + 210 * xscale, top + 8 * yscale, buff, DTA_CleanNoMove, true, TAG_DONE); if (CPlayer->LogText != NULL) { - FBrokenLines *lines = V_BreakLines (SmallFont2, 272, CPlayer->LogText); + FBrokenLines *lines = V_BreakLines(SmallFont2, 272, CPlayer->LogText); for (i = 0; lines[i].Width >= 0; ++i) { - screen->DrawText (SmallFont2, CR_UNTRANSLATED, left+24*xscale, top+(18+i*12)*yscale, + screen->DrawText(SmallFont2, CR_UNTRANSLATED, left + 24 * xscale, top + (18 + i * 12)*yscale, lines[i].Text, DTA_CleanNoMove, true, TAG_DONE); } - V_FreeBrokenLines (lines); + V_FreeBrokenLines(lines); } break; + } case POP_Keys: // List the keys the player has. diff --git a/src/statistics.cpp b/src/statistics.cpp index acd8440e8..7ed6e7f8e 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -420,7 +420,7 @@ static void StoreLevelStats() LevelData[i].killcount = level.killed_monsters; LevelData[i].totalsecrets = level.total_secrets; LevelData[i].secretcount = level.found_secrets; - LevelData[i].leveltime = level.maptime; + LevelData[i].leveltime = AdjustTics(level.maptime); // Check for living monsters. On some maps it can happen // that the counter misses some. @@ -490,7 +490,7 @@ void STAT_ChangeLevel(const char *newl) } infostring.Format("%4d/%4d, %3d/%3d, %2d", statvals[0], statvals[1], statvals[2], statvals[3], validlevels); - FSessionStatistics *es = StatisticsEntry(sl, infostring, level.totaltime); + FSessionStatistics *es = StatisticsEntry(sl, infostring, AdjustTics(level.totaltime)); for(unsigned i = 0; i < LevelData.Size(); i++) { diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index e60fee303..2ab93f090 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -1460,7 +1460,7 @@ void WI_drawDeathmatchStats () // Draw game time y += height + CleanYfac; - int seconds = plrs[me].stime / TICRATE; + int seconds = Tics2Seconds(plrs[me].stime); int hours = seconds / 3600; int minutes = (seconds % 3600) / 60; seconds = seconds % 60; @@ -1817,9 +1817,9 @@ void WI_updateStats () cnt_kills[0] = plrs[me].skills; cnt_items[0] = plrs[me].sitems; cnt_secret[0] = plrs[me].ssecret; - cnt_time = plrs[me].stime / TICRATE; + cnt_time = Tics2Seconds(plrs[me].stime); cnt_par = wbs->partime / TICRATE; - cnt_total_time = wbs->totaltime / TICRATE; + cnt_total_time = Tics2Seconds(wbs->totaltime); } if (sp_state == 2) @@ -1882,19 +1882,21 @@ void WI_updateStats () cnt_total_time += 3; } - if (!gameinfo.intermissioncounter || cnt_time >= plrs[me].stime / TICRATE) - cnt_time = plrs[me].stime / TICRATE; + int sec = Tics2Seconds(plrs[me].stime); + if (!gameinfo.intermissioncounter || cnt_time >= sec) + cnt_time = sec; - if (!gameinfo.intermissioncounter || cnt_total_time >= wbs->totaltime / TICRATE) - cnt_total_time = wbs->totaltime / TICRATE; + int tsec = Tics2Seconds(wbs->totaltime); + if (!gameinfo.intermissioncounter || cnt_total_time >= tsec) + cnt_total_time = tsec; if (!gameinfo.intermissioncounter || cnt_par >= wbs->partime / TICRATE) { cnt_par = wbs->partime / TICRATE; - if (cnt_time >= plrs[me].stime / TICRATE) + if (cnt_time >= sec) { - cnt_total_time = wbs->totaltime / TICRATE; + cnt_total_time = tsec; S_Sound (CHAN_VOICE | CHAN_UI, "intermission/nextstage", 1, ATTN_NONE); sp_state++; } From f0eccb9d1541ea1fefcc82cdd02a0b7b2dc73fbe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Aug 2014 10:08:49 +0200 Subject: [PATCH 14/16] - BlueShadow's submission for keeping the max save amount of BasicArmorPickups around when picking up armor bonuses. --- src/g_shared/a_armor.cpp | 8 ++++++++ src/g_shared/a_pickups.h | 1 + src/p_acs.cpp | 4 ++++ src/version.h | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/g_shared/a_armor.cpp b/src/g_shared/a_armor.cpp index 6b90a6a78..a745197c2 100644 --- a/src/g_shared/a_armor.cpp +++ b/src/g_shared/a_armor.cpp @@ -25,6 +25,11 @@ void ABasicArmor::Serialize (FArchive &arc) { Super::Serialize (arc); arc << SavePercent << BonusCount << MaxAbsorb << MaxFullAbsorb << AbsorbCount << ArmorType; + + if (SaveVersion >= 4511) + { + arc << ActualSaveAmount; + } } //=========================================================================== @@ -69,6 +74,7 @@ AInventory *ABasicArmor::CreateCopy (AActor *other) copy->Icon = Icon; copy->BonusCount = BonusCount; copy->ArmorType = ArmorType; + copy->ActualSaveAmount = ActualSaveAmount; GoAwayAndDie (); return copy; } @@ -268,6 +274,7 @@ bool ABasicArmorPickup::Use (bool pickup) armor->MaxAbsorb = MaxAbsorb; armor->MaxFullAbsorb = MaxFullAbsorb; armor->ArmorType = this->GetClass()->TypeName; + armor->ActualSaveAmount = SaveAmount; return true; } @@ -360,6 +367,7 @@ bool ABasicArmorBonus::Use (bool pickup) armor->MaxAbsorb = MaxAbsorb; armor->ArmorType = this->GetClass()->TypeName; armor->MaxFullAbsorb = MaxFullAbsorb; + armor->ActualSaveAmount = MaxSaveAmount; } armor->Amount = MIN(armor->Amount + saveAmount, MaxSaveAmount + armor->BonusCount); diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 22d1e009f..72548776a 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -423,6 +423,7 @@ public: int MaxFullAbsorb; int BonusCount; FNameNoInit ArmorType; + int ActualSaveAmount; }; // BasicArmorPickup replaces the armor you have. diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 1646ab7b7..e0967d400 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -128,6 +128,7 @@ enum ARMORINFO_SAVEPERCENT, ARMORINFO_MAXABSORB, ARMORINFO_MAXFULLABSORB, + ARMORINFO_ACTUALSAVEAMOUNT, }; struct CallReturn @@ -4858,6 +4859,9 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const case ARMORINFO_MAXFULLABSORB: return equippedarmor->MaxFullAbsorb; + case ARMORINFO_ACTUALSAVEAMOUNT: + return equippedarmor->ActualSaveAmount; + default: return 0; } diff --git a/src/version.h b/src/version.h index 6d24c3fe8..af376938c 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4510 +#define SAVEVER 4511 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) From 48163de8e2485116e3007cdb0245bc975e8eed80 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Aug 2014 11:47:14 +0200 Subject: [PATCH 15/16] must include doomdef.h in cmdlib.h to get TICRATE. --- src/cmdlib.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmdlib.h b/src/cmdlib.h index 66747415a..f6f0e6ad8 100644 --- a/src/cmdlib.h +++ b/src/cmdlib.h @@ -5,6 +5,7 @@ #include "doomtype.h" +#include "doomdef.h" #include #include From f482dc094df50a6bf4ae5608dbb564a18bc864fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Aug 2014 12:27:04 +0200 Subject: [PATCH 16/16] fixed: R_PointOnSideSlow had precision issues with very short lines. When this function was originally written there was no possibility of fractional vertex coordinates so it threw away the fractional parts of the node's directional vector (which in the original nodes was always 0.) Now, with UDMF and high precision vertices this no longer works and the loss of significant parts of their value caused this code to produce erroneous results if the linedefs were only a few map units long and using fractional positions. --- src/p_maputl.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 17fc97d2f..3a4a4c6a0 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -434,8 +434,8 @@ static int R_PointOnSideSlow (fixed_t x, fixed_t y, node_t *node) // add on a 386/486, but it certainly isn't on anything newer than that. fixed_t dx; fixed_t dy; - fixed_t left; - fixed_t right; + double left; + double right; if (!node->dx) { @@ -466,8 +466,9 @@ static int R_PointOnSideSlow (fixed_t x, fixed_t y, node_t *node) return 0; } - left = FixedMul ( node->dy>>FRACBITS , dx ); - right = FixedMul ( dy , node->dx>>FRACBITS ); + // we must use doubles here because the fixed point code will produce errors due to loss of precision for extremely short linedefs. + left = (double)node->dy * (double)dx; + right = (double)dy * (double)node->dx; if (right < left) {