From 220255e6a420b223550b929fd2295a43d53da7e5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 May 2016 11:56:03 +0200 Subject: [PATCH 01/14] - fixed P_CheckMove's dropoff check and removed some unneeded code. --- src/p_map.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index e0ee1eaec..923799668 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2535,11 +2535,7 @@ bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags) } else if ((flags & PCM_DROPOFF) && !(thing->flags & (MF_FLOAT|MF_DROPOFF))) { - const DVector3 oldpos = thing->Pos(); - thing->SetOrigin(pos.X, pos.Y, newz, true); - bool hcheck = (newz - thing->dropoffz > thing->MaxDropOffHeight); - thing->SetOrigin(oldpos, true); - if (hcheck) + if (newz - tm.dropoffz > thing->MaxDropOffHeight) { return false; } From 0726a88ab979f0097059a56562e1c53845046e2c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 May 2016 12:04:41 +0200 Subject: [PATCH 02/14] - only return DWORD aligned addresses in openings because the 3D floor code stores floating point values in there which cannot be accessed on platforms with strict alignment rules. --- src/r_segs.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 69d517b17..4eb3cb440 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -2352,6 +2352,7 @@ void R_CheckDrawSegs () ptrdiff_t R_NewOpening (ptrdiff_t len) { ptrdiff_t res = lastopening; + len = (len + 1) & ~1; // only return DWORD aligned addresses because some code stores fixed_t's and floats in openings... lastopening += len; if ((size_t)lastopening > maxopenings) { @@ -2512,6 +2513,7 @@ void R_StoreWallRange (int start, int stop) if(sidedef->GetTexture(side_t::mid).isValid()) ds_p->bFakeBoundary |= 4; // it is also mid texture + // note: This should never have used the openings array to store its data! ds_p->maskedtexturecol = R_NewOpening ((stop - start) * 2); ds_p->swall = R_NewOpening ((stop - start) * 2); From 9ab620814df9b04b4dc784dcdd6796742a6c0050 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Mon, 14 Mar 2016 16:57:26 -0500 Subject: [PATCH 03/14] - Fixed: Armor absorption did not take ALLOW/CAUSEPAIN flags into account. --- src/p_interaction.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index c2d5afd81..8890d3592 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -942,7 +942,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, bool forcedPain = false; int fakeDamage = 0; int holdDamage = 0; - int rawdamage = damage; + const int rawdamage = damage; if (damage < 0) damage = 0; @@ -1267,7 +1267,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, else return -1; } - + // Armor for players. if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL) { int newdam = damage; @@ -1280,15 +1280,21 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, // if we are telefragging don't let the damage value go below that magic value. Some further checks would fail otherwise. damage = newdam; } - + if (damage <= 0) { + // [MC] Godmode doesn't need checking here, it's already being handled above. + if ((target->flags5 & MF5_NOPAIN) || (inflictor && (inflictor->flags5 & MF5_PAINLESS))) + return damage; + // If MF6_FORCEPAIN is set, make the player enter the pain state. - if (!(target->flags5 & MF5_NOPAIN) && inflictor != NULL && - (inflictor->flags6 & MF6_FORCEPAIN) && !(inflictor->flags5 & MF5_PAINLESS) - && (!(player->mo->flags2 & MF2_INVULNERABLE)) && (!(player->cheats & CF_GODMODE)) && (!(player->cheats & CF_GODMODE2))) - { + if ((inflictor && (inflictor->flags6 & MF6_FORCEPAIN))) goto dopain; + else if (((player->mo->flags7 & MF7_ALLOWPAIN) && (rawdamage > 0)) || + (inflictor && (inflictor->flags7 & MF7_CAUSEPAIN))) + { + invulpain = true; + goto fakepain; } return damage; } From d4b258f15bc7f8d09a5d798ef728c5a38f3bc31e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 May 2016 13:57:49 +0200 Subject: [PATCH 04/14] - don't place the chasecam right at the hit position of the trace. This will be the intersection with a wall or sector plane and may cause clipping issues. Instead place it very slightly in front of the actual hit position. --- src/p_map.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 923799668..d1fc77268 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2535,7 +2535,11 @@ bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags) } else if ((flags & PCM_DROPOFF) && !(thing->flags & (MF_FLOAT|MF_DROPOFF))) { - if (newz - tm.dropoffz > thing->MaxDropOffHeight) + const DVector3 oldpos = thing->Pos(); + thing->SetOrigin(pos.X, pos.Y, newz, true); + bool hcheck = (newz - thing->dropoffz > thing->MaxDropOffHeight); + thing->SetOrigin(oldpos, true); + if (hcheck) { return false; } @@ -4840,7 +4844,7 @@ void P_AimCamera(AActor *t1, DVector3 &campos, DAngle &camangle, sector_t *&Came } else { - campos = trace.HitPos; + campos = trace.HitPos - trace.HitVector * 1/256.; } CameraSector = trace.Sector; unlinked = trace.unlinked; From 078e27e61f4acf9149db8852d64afdfd5f6429f4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 May 2016 14:04:21 +0200 Subject: [PATCH 05/14] - fixed: The mugshot's angle was inverted. --- src/g_shared/sbar_mugshot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_shared/sbar_mugshot.cpp b/src/g_shared/sbar_mugshot.cpp index 148b7cb32..d88ad40f2 100644 --- a/src/g_shared/sbar_mugshot.cpp +++ b/src/g_shared/sbar_mugshot.cpp @@ -367,11 +367,11 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags) DAngle diffang = deltaangle(player->mo->Angles.Yaw, badguyangle); if (diffang > 45.) { // turn face right - damage_angle = 0; + damage_angle = 2; } else if (diffang < -45.) { // turn face left - damage_angle = 2; + damage_angle = 0; } } } From 769521b2e19114b635d33d5a49c362ba8997e78b Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Wed, 11 May 2016 13:58:54 +0200 Subject: [PATCH 06/14] - Fixed second player lock after error in netgame. --- src/d_net.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_net.cpp b/src/d_net.cpp index 0758ebe38..eadd47d96 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -322,6 +322,8 @@ void Net_ClearBuffers () memset (netcmds, 0, sizeof(netcmds)); memset (nettics, 0, sizeof(nettics)); memset (nodeingame, 0, sizeof(nodeingame)); + memset (nodeforplayer, 0, sizeof(nodeforplayer)); + memset (playerfornode, 0, sizeof(playerfornode)); memset (remoteresend, 0, sizeof(remoteresend)); memset (resendto, 0, sizeof(resendto)); memset (resendcount, 0, sizeof(resendcount)); From 852ed6cd04eb50c53b45fc71c1764ce13112e5d6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 May 2016 19:39:08 +0200 Subject: [PATCH 07/14] - un-revert P_CheckMove fix. --- src/p_map.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index d1fc77268..88366baac 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2535,11 +2535,7 @@ bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags) } else if ((flags & PCM_DROPOFF) && !(thing->flags & (MF_FLOAT|MF_DROPOFF))) { - const DVector3 oldpos = thing->Pos(); - thing->SetOrigin(pos.X, pos.Y, newz, true); - bool hcheck = (newz - thing->dropoffz > thing->MaxDropOffHeight); - thing->SetOrigin(oldpos, true); - if (hcheck) + if (newz - tm.dropoffz > thing->MaxDropOffHeight) { return false; } From 952219a0184abf8c9f4776acc0873a5bc1ae07d4 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 11 May 2016 06:59:11 -0500 Subject: [PATCH 08/14] Added RTF_THRUSTZ for A_RadiusThrust. - Allows thrusting with Z velocity. --- src/p_local.h | 1 + src/p_map.cpp | 2 +- src/thingdef/thingdef_codeptr.cpp | 8 +++++--- wadsrc/static/actors/constants.txt | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 48014f993..8e64c3414 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -343,6 +343,7 @@ enum RADF_NOIMPACTDAMAGE = 2, RADF_SOURCEISSPOT = 4, RADF_NODAMAGE = 8, + RADF_THRUSTZ = 16, }; void P_RadiusAttack (AActor *spot, AActor *source, int damage, int distance, FName damageType, int flags, int fulldamagedistance=0); diff --git a/src/p_map.cpp b/src/p_map.cpp index 88366baac..22004b897 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -5321,7 +5321,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo vz *= 0.8; } thing->Thrust(bombspot->AngleTo(thing), thrust); - if (!(flags & RADF_NODAMAGE)) + if (!(flags & RADF_NODAMAGE) || (flags & RADF_THRUSTZ)) thing->Vel.Z += vz; // this really doesn't work well } } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index e5d080095..b2373a7a0 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1143,9 +1143,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode) enum { - RTF_AFFECTSOURCE = 1, - RTF_NOIMPACTDAMAGE = 2, - RTF_NOTMISSILE = 4, + RTF_AFFECTSOURCE = 1, + RTF_NOIMPACTDAMAGE = 2, + RTF_NOTMISSILE = 4, + RTF_THRUSTZ = 8, }; DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust) @@ -1167,6 +1168,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust) sourcenothrust = true; self->target->flags2 &= ~MF2_NODMGTHRUST; } + if (flags & RTF_THRUSTZ) flags |= RADF_THRUSTZ; P_RadiusAttack (self, self->target, force, distance, self->DamageType, flags | RADF_NODAMAGE, fullthrustdistance); P_CheckSplash(self, distance); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 9ccb1fd6e..7b8e25a9f 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -178,6 +178,7 @@ const int XF_NOTMISSILE = 4; const int RTF_AFFECTSOURCE = 1; const int RTF_NOIMPACTDAMAGE = 2; const int RTF_NOTMISSILE = 4; +const int RTF_THRUSTZ = 8; // Flags for A_Blast const int BF_USEAMMO = 1; From 39f64383cb90ec611dadba05bc003374fc0217c1 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 11 May 2016 07:28:05 -0500 Subject: [PATCH 09/14] Changed RTF_THRUSTZ to match RADF_THRUSTZ's bitmap. --- src/thingdef/thingdef_codeptr.cpp | 2 -- wadsrc/static/actors/constants.txt | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index b2373a7a0..677687f3e 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1146,7 +1146,6 @@ enum RTF_AFFECTSOURCE = 1, RTF_NOIMPACTDAMAGE = 2, RTF_NOTMISSILE = 4, - RTF_THRUSTZ = 8, }; DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust) @@ -1168,7 +1167,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust) sourcenothrust = true; self->target->flags2 &= ~MF2_NODMGTHRUST; } - if (flags & RTF_THRUSTZ) flags |= RADF_THRUSTZ; P_RadiusAttack (self, self->target, force, distance, self->DamageType, flags | RADF_NODAMAGE, fullthrustdistance); P_CheckSplash(self, distance); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 7b8e25a9f..1922194ed 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -178,7 +178,7 @@ const int XF_NOTMISSILE = 4; const int RTF_AFFECTSOURCE = 1; const int RTF_NOIMPACTDAMAGE = 2; const int RTF_NOTMISSILE = 4; -const int RTF_THRUSTZ = 8; +const int RTF_THRUSTZ = 16; // Flags for A_Blast const int BF_USEAMMO = 1; From b91ed5dc5da371cf51722ea6d5f2229712285d59 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 5 May 2016 18:33:36 -0500 Subject: [PATCH 10/14] Added GetZAt DECORATE function. - float GetZAt(x, y, angle, flags, pick_pointer); - Gets the floor z at x distance ahead and y distance to the side in relative form from the calling actor pointer. Flags are as follows (GZF_ prefix): - CEILING: Returns the ceiling z instead of floor. - ABSOLUTEPOS: x and y are absolute positions. - ABSOLUTEANG: angle parameter does not add the pointer's angle to the angle parameter. --- src/thingdef/thingdef_codeptr.cpp | 71 ++++++++++++++++++++++++++++++ wadsrc/static/actors/actor.txt | 1 + wadsrc/static/actors/constants.txt | 8 ++++ 3 files changed, 80 insertions(+) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 677687f3e..4ceb2b6f4 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -386,6 +386,77 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetGibHealth) return 0; } +//========================================================================== +// +// GetZAt +// +// NON-ACTION function to get the floor or ceiling z at (x, y) with +// relativity being an option. +//========================================================================== +enum GZFlags +{ + GZF_ABSOLUTEPOS = 1, + GZF_ABSOLUTEANG = 1 << 1, + GZF_CEILING = 1 << 2, +}; + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetZAt) +{ + if (numret > 0) + { + assert(ret != NULL); + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT_OPT(px) { px = 0.; } + PARAM_FLOAT_OPT(py) { py = 0.; } + PARAM_ANGLE_OPT(angle) { angle = 0.; } + PARAM_INT_OPT(flags) { flags = 0; } + PARAM_INT_OPT(pick_pointer) { pick_pointer = AAPTR_DEFAULT; } + + AActor *mobj = COPY_AAPTR(self, pick_pointer); + if (mobj == nullptr) + { + ret->SetFloat(0); + } + else + { + DVector2 pos = { px, py }; + int secnum; + double z = 0.; + + if (!(flags & GZF_ABSOLUTEPOS)) + { + if (!(flags & GZF_ABSOLUTEANG)) + { + angle += mobj->Angles.Yaw; + } + + double s = angle.Sin(); + double c = angle.Cos(); + pos = mobj->Vec2Offset(pos.X * c + pos.Y * s, pos.X * s - pos.Y * c); + } + + secnum = int(P_PointInSector(pos.X, pos.Y) - sectors); + + if (secnum >= 0) + { + if (flags & GZF_CEILING) + { + //z = mobj->Sector->ceilingplane.ZatPoint(pos.X, pos.Y); + z = sectors[secnum].ceilingplane.ZatPoint(pos); + } + else + { + //z = mobj->Sector->floorplane.ZatPoint(pos.X, pos.Y); + z = sectors[secnum].floorplane.ZatPoint(pos); + } + } + ret->SetFloat(z); + return 1; + } + } + return 0; +} + //=========================================================================== // // __decorate_internal_state__ diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 8b35be30d..44ebb1dc3 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -43,6 +43,7 @@ ACTOR Actor native //: Thinker native int CountInv(class itemtype, int ptr_select = AAPTR_DEFAULT); native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT); native float GetAngle(bool relative, int ptr = AAPTR_DEFAULT); + native float GetZAt(float px = 0, float py = 0, float angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT); native int GetSpawnHealth(); native int GetGibHealth(); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 1922194ed..a639799af 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -550,3 +550,11 @@ enum FMDF_INTERPOLATE = 1 << 1, FMDF_NOANGLE = 1 << 2, }; + +// Flags for GetZAt +enum +{ + GZF_ABSOLUTEPOS = 1, + GZF_ABSOLUTEANG = 1 << 1, + GZF_CEILING = 1 << 2, +}; From 2ba26693d1123af8f20d80f470f267b8b51e16f1 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 12 May 2016 13:23:10 -0500 Subject: [PATCH 11/14] - Added 3D Floor + Portal awareness, along with flags to turn off detection of both features. --- src/thingdef/thingdef_codeptr.cpp | 45 ++++++++++++++++++++++++------ wadsrc/static/actors/constants.txt | 9 ++++-- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 4ceb2b6f4..ffb441908 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -395,9 +395,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetGibHealth) //========================================================================== enum GZFlags { - GZF_ABSOLUTEPOS = 1, - GZF_ABSOLUTEANG = 1 << 1, - GZF_CEILING = 1 << 2, + GZF_ABSOLUTEPOS = 1, // Use the absolute position instead of an offsetted one. + GZF_ABSOLUTEANG = 1 << 1, // Don't add the actor's angle to the parameter. + GZF_CEILING = 1 << 2, // Check the ceiling instead of the floor. + GZF_3DRESTRICT = 1 << 3, // Ignore midtextures and 3D floors above the pointer's z. + GZF_NOPORTALS = 1 << 4, // Don't pass through any portals. + GZF_NO3DFLOOR = 1 << 5, // Pass all 3D floors. }; DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetZAt) @@ -419,9 +422,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetZAt) } else { + // [MC] At any time, the NextLowest/Highest functions could be changed to include + // more FFC flags to check. Don't risk it by just passing flags straight to it. + DVector2 pos = { px, py }; - int secnum; double z = 0.; + int pflags = (flags & GZF_3DRESTRICT) ? FFCF_3DRESTRICT : 0; + if (flags & GZF_NOPORTALS) pflags |= FFCF_NOPORTALS; if (!(flags & GZF_ABSOLUTEPOS)) { @@ -435,19 +442,39 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetZAt) pos = mobj->Vec2Offset(pos.X * c + pos.Y * s, pos.X * s - pos.Y * c); } - secnum = int(P_PointInSector(pos.X, pos.Y) - sectors); + int secnum = int(P_PointInSector(pos) - sectors); if (secnum >= 0) { if (flags & GZF_CEILING) { - //z = mobj->Sector->ceilingplane.ZatPoint(pos.X, pos.Y); - z = sectors[secnum].ceilingplane.ZatPoint(pos); + if ((flags & GZF_NO3DFLOOR) && (flags & GZF_NOPORTALS)) + { + z = sectors[secnum].ceilingplane.ZatPoint(pos); + } + else if (flags & GZF_NO3DFLOOR) + { + z = sectors[secnum].HighestCeilingAt(pos); + } + else + { // [MC] Handle strict 3D floors and portal toggling via the flags passed to it. + z = sectors[secnum].NextHighestCeilingAt(pos.X, pos.Y, mobj->Z(), mobj->Top(), pflags); + } } else { - //z = mobj->Sector->floorplane.ZatPoint(pos.X, pos.Y); - z = sectors[secnum].floorplane.ZatPoint(pos); + if ((flags & GZF_NO3DFLOOR) && (flags & GZF_NOPORTALS)) + { + z = sectors[secnum].floorplane.ZatPoint(pos); + } + else if (flags & GZF_NO3DFLOOR) + { + z = sectors[secnum].LowestFloorAt(pos); + } + else + { + z = sectors[secnum].NextLowestFloorAt(pos.X, pos.Y, mobj->Z(), pflags, mobj->MaxStepHeight); + } } } ret->SetFloat(z); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index a639799af..2468174b7 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -554,7 +554,10 @@ enum // Flags for GetZAt enum { - GZF_ABSOLUTEPOS = 1, - GZF_ABSOLUTEANG = 1 << 1, - GZF_CEILING = 1 << 2, + GZF_ABSOLUTEPOS = 1, // Use the absolute position instead of an offsetted one. + GZF_ABSOLUTEANG = 1 << 1, // Don't add the actor's angle to the parameter. + GZF_CEILING = 1 << 2, // Check the ceiling instead of the floor. + GZF_3DRESTRICT = 1 << 3, // Ignore midtextures and 3D floors above the pointer's z. + GZF_NOPORTALS = 1 << 4, // Don't pass through any portals. + GZF_NO3DFLOOR = 1 << 5, // Pass all 3D floors. }; From 4998d4a84d2693b2555ae4e055064b47b192a5cf Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 12 May 2016 14:47:00 -0500 Subject: [PATCH 12/14] Use the direct pointer of P_PointInSector instead. --- src/thingdef/thingdef_codeptr.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index ffb441908..afbc036a6 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -441,39 +441,38 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetZAt) double c = angle.Cos(); pos = mobj->Vec2Offset(pos.X * c + pos.Y * s, pos.X * s - pos.Y * c); } + sector_t *sec = P_PointInSector(pos); - int secnum = int(P_PointInSector(pos) - sectors); - - if (secnum >= 0) + if (sec) { if (flags & GZF_CEILING) { if ((flags & GZF_NO3DFLOOR) && (flags & GZF_NOPORTALS)) { - z = sectors[secnum].ceilingplane.ZatPoint(pos); + z = sec->ceilingplane.ZatPoint(pos); } else if (flags & GZF_NO3DFLOOR) { - z = sectors[secnum].HighestCeilingAt(pos); + z = sec->HighestCeilingAt(pos); } else { // [MC] Handle strict 3D floors and portal toggling via the flags passed to it. - z = sectors[secnum].NextHighestCeilingAt(pos.X, pos.Y, mobj->Z(), mobj->Top(), pflags); + z = sec->NextHighestCeilingAt(pos.X, pos.Y, mobj->Z(), mobj->Top(), pflags); } } else { if ((flags & GZF_NO3DFLOOR) && (flags & GZF_NOPORTALS)) { - z = sectors[secnum].floorplane.ZatPoint(pos); + z = sec->floorplane.ZatPoint(pos); } else if (flags & GZF_NO3DFLOOR) { - z = sectors[secnum].LowestFloorAt(pos); + z = sec->LowestFloorAt(pos); } else { - z = sectors[secnum].NextLowestFloorAt(pos.X, pos.Y, mobj->Z(), pflags, mobj->MaxStepHeight); + z = sec->NextLowestFloorAt(pos.X, pos.Y, mobj->Z(), pflags, mobj->MaxStepHeight); } } } From cd8213f067a9564af377791903eab17c2cc41036 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 13 May 2016 10:07:01 +0200 Subject: [PATCH 13/14] - fixed: The skybox pointer in FSectorPortal must at least be initialized to nullptr when the struct is deserialized, to avoid an access violation if the partially initialized data is used. This can happen when P_SerializeThinkers destroys the original thinkers that were created on map load. - removed the sector loop for deleting skybox references in ASkyViewpoint::Destroy. Since this only refers to the sectorPortals array it is completely redundant as the following code will clear them just as well. --- src/g_shared/a_skies.cpp | 7 ------- src/portal.cpp | 4 ++++ src/portal.h | 2 -- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/g_shared/a_skies.cpp b/src/g_shared/a_skies.cpp index 57fce23fd..6e85bd886 100644 --- a/src/g_shared/a_skies.cpp +++ b/src/g_shared/a_skies.cpp @@ -59,13 +59,6 @@ void ASkyViewpoint::BeginPlay () void ASkyViewpoint::Destroy () { // remove all sector references to ourselves. - for (int i = 0; i < numsectors; i++) - { - if (sectors[i].GetPortal(sector_t::floor)->mSkybox == this) - sectors[i].ClearPortal(sector_t::floor); - if (sectors[i].GetPortal(sector_t::ceiling)->mSkybox == this) - sectors[i].ClearPortal(sector_t::ceiling); - } for (auto &s : sectorPortals) { if (s.mSkybox == this) s.mSkybox = 0; diff --git a/src/portal.cpp b/src/portal.cpp index af98718bf..64a4dd97d 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -231,6 +231,10 @@ FArchive &operator<< (FArchive &arc, FSectorPortal &port) << port.mDestination << port.mDisplacement << port.mPlaneZ; + if (arc.IsLoading()) + { + port.mSkybox = nullptr; + } return arc; } diff --git a/src/portal.h b/src/portal.h index bba674def..a87ae207f 100644 --- a/src/portal.h +++ b/src/portal.h @@ -191,7 +191,6 @@ struct FLinePortal double mSinRot; double mCosRot; portnode_t *render_thinglist; - void *mRenderData; }; extern TArray linePortals; @@ -229,7 +228,6 @@ struct FSectorPortal DVector2 mDisplacement; double mPlaneZ; TObjPtr mSkybox; - void *mRenderData; bool MergeAllowed() const { From ebca170e73d95583a5a669c4820d56f3d5e1c645 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 13 May 2016 10:07:18 +0200 Subject: [PATCH 14/14] - fixed a few warnings in OpenAL code. --- src/sound/oalsound.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 95fa4d39a..bf7bede82 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -1188,7 +1188,7 @@ std::pair OpenALSoundRenderer::LoadSound(BYTE *sfxdata, int le int sum = 0; for(size_t c = 0;c < chancount;c++) sum += sfxdata[i*chancount + c]; - sfxdata[i] = sum / chancount; + sfxdata[i] = short(sum / chancount); } } else if(type == SampleType_UInt8) @@ -1199,10 +1199,10 @@ std::pair OpenALSoundRenderer::LoadSound(BYTE *sfxdata, int le int sum = 0; for(size_t c = 0;c < chancount;c++) sum += sfxdata[i*chancount + c] - 128; - sfxdata[i] = (sum / chancount) + 128; + sfxdata[i] = BYTE((sum / chancount) + 128); } } - data.Resize(data.Size()/chancount); + data.Resize(unsigned(data.Size()/chancount)); } ALenum err;