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.