From 99b2fab410b5aa0b477414f34a3e8313b0d00f42 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Apr 2008 10:04:41 +0000 Subject: [PATCH] - Added submission for ACS CheckPlayerCamera ACS function. - Removed FRadiusThingsIterator after discovering that VC++ misoptimized it in P_CheckPosition. Now FBlockThingsIterator is used with the distance check being done manually. SVN r914 (trunk) --- docs/rh-log.txt | 6 ++++++ src/actor.h | 6 ++++++ src/g_doom/doom_sbar.cpp | 4 ++-- src/g_hexen/a_spike.cpp | 8 +++++++- src/p_acs.cpp | 19 ++++++++++++++++++- src/p_acs.h | 1 + src/p_local.h | 8 -------- src/p_map.cpp | 39 +++++++++++++++++++++++++++++++-------- src/p_maputl.cpp | 33 --------------------------------- 9 files changed, 71 insertions(+), 53 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 0e5eee406e..c123fe4ef5 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,9 @@ +April 15, 2008 (Changes by Graf Zahl) +- Added submission for ACS CheckPlayerCamera ACS function. +- Removed FRadiusThingsIterator after discovering that VC++ misoptimized + it in P_CheckPosition. Now FBlockThingsIterator is used with the distance + check being done manually. + April 14, 2008 (Changes by Graf Zahl) - Added rotation 90° angles only) and mirroring to the Multipatch texture composition code. diff --git a/src/actor.h b/src/actor.h index 0cff564756..606e2be8f9 100644 --- a/src/actor.h +++ b/src/actor.h @@ -603,6 +603,12 @@ public: return (flags & MF_COUNTKILL) && !(flags & MF_FRIENDLY); } + bool intersects(AActor *other) const + { + fixed_t blockdist = radius + other->radius; + return ( abs(x - other->x) < blockdist && abs(y - other->y) < blockdist); + } + // Calculate amount of missile damage virtual int GetMissileDamage(int mask, int add); diff --git a/src/g_doom/doom_sbar.cpp b/src/g_doom/doom_sbar.cpp index 94ed7787eb..70f8f6c200 100644 --- a/src/g_doom/doom_sbar.cpp +++ b/src/g_doom/doom_sbar.cpp @@ -145,9 +145,9 @@ public: player_t *oldplayer = CPlayer; DBaseStatusBar::AttachToPlayer (player); - if (oldplayer != CPlayer) + if (oldplayer != CPlayer || savegamerestore/*added for morphing*/) { - SetFace (&skins[CPlayer->userinfo.skin]); + SetFace (&skins[CPlayer->morphTics ? CPlayer->MorphedPlayerClass : CPlayer->userinfo.skin]); } if (multiplayer) { diff --git a/src/g_hexen/a_spike.cpp b/src/g_hexen/a_spike.cpp index a165af79f7..86dfe3b53f 100644 --- a/src/g_hexen/a_spike.cpp +++ b/src/g_hexen/a_spike.cpp @@ -5,6 +5,7 @@ #include "p_local.h" #include "a_sharedglobal.h" #include "s_sound.h" +#include "m_bbox.h" static FRandom pr_thrustraise ("ThrustRaise"); @@ -262,9 +263,14 @@ void A_ThrustBlock (AActor *actor) void A_ThrustImpale (AActor *actor) { AActor *thing; - FRadiusThingsIterator it(actor->x, actor->y, actor->radius); + FBlockThingsIterator it(FBoundingBox(actor->x, actor->y, actor->radius)); while ((thing = it.Next())) { + if (!thing->intersects(actor)) + { + continue; + } + if (!(thing->flags & MF_SHOOTABLE) ) continue; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 825a2a6af9..36e43e5305 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -5339,7 +5339,24 @@ int DLevelScript::RunScript () static_cast(StatusBar)->SetMugShotState(FBehavior::StaticLookupString(STACK(1))); } break; - + + case PCD_CHECKPLAYERCAMERA: + { + AActor *actor = SingleActorFromTID(STACK(1), activator); + + if(actor != NULL && actor->player != NULL) + { + if(actor->player->camera != actor->player->mo) + { + STACK(1) = actor->player->camera->tid; + } + else + { + STACK(1) = 0; + } + } + else STACK(1) = 0; + } } } diff --git a/src/p_acs.h b/src/p_acs.h index c97fa1790a..072d2ffbde 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -550,6 +550,7 @@ public: PCD_SETMUGSHOTSTATE, PCD_THINGCOUNTSECTOR, PCD_THINGCOUNTNAMESECTOR, + PCD_CHECKPLAYERCAMERA, // [TN] PCODE_COMMAND_COUNT }; diff --git a/src/p_local.h b/src/p_local.h index 4578d8c769..2e6dd3a4b9 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -283,14 +283,6 @@ public: void Reset() { StartBlock(minx, miny); } }; -class FRadiusThingsIterator : public FBlockThingsIterator -{ - fixed_t X, Y, Radius; -public: - FRadiusThingsIterator(fixed_t x, fixed_t y, fixed_t radius); - AActor *Next(); -}; - class FPathTraverse { static TArray intercepts; diff --git a/src/p_map.cpp b/src/p_map.cpp index b00f3e1439..cbba7a5dc9 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -253,7 +253,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; - FRadiusThingsIterator it2(x, y, thing->radius); + FBlockThingsIterator it2(FBoundingBox(x, y, thing->radius)); AActor *th; while ((th = it2.Next())) @@ -265,6 +265,10 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr if (th == thing) continue; + fixed_t blockdist = th->radius + tmf.thing->radius; + if ( abs(th->x - tmf.x) >= blockdist || abs(th->y - tmf.y) >= blockdist) + continue; + // [RH] Z-Check // But not if not MF2_PASSMOBJ or MF3_DONTOVERLAP are set! // Otherwise those things would get stuck inside each other. @@ -325,7 +329,7 @@ bool P_TeleportMove (AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefr void P_PlayerStartStomp (AActor *actor) { AActor *th; - FRadiusThingsIterator it(actor->x, actor->y, actor->radius); + FBlockThingsIterator it(FBoundingBox(actor->x, actor->y, actor->radius)); while ((th = it.Next())) { @@ -336,6 +340,9 @@ void P_PlayerStartStomp (AActor *actor) if (th == actor || (th->player == actor->player && th->player != NULL)) continue; + if (!th->intersects(actor)) + continue; + // only kill monsters and other players if (th->player == NULL && !(th->flags3 & MF3_ISMONSTER)) continue; @@ -643,7 +650,7 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) fixed_t topz; bool solid; int damage; - + // don't clip against self if (thing == tm.thing) return true; @@ -651,6 +658,10 @@ bool PIT_CheckThing (AActor *thing, FCheckPosition &tm) if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_SHOOTABLE)) ) 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) + return true; + 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)) && @@ -1037,7 +1048,7 @@ bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm) tm.stepthing = NULL; - FRadiusThingsIterator it2(x, y, thing->radius); + FBlockThingsIterator it2(FBoundingBox(x, y, thing->radius)); AActor *th; while ((th = it2.Next())) { @@ -1168,11 +1179,15 @@ bool P_TestMobjZ (AActor *actor, bool quick, AActor **pOnmobj) return true; } - FRadiusThingsIterator it(actor->x, actor->y, actor->radius); + FBlockThingsIterator it(FBoundingBox(actor->x, actor->y, actor->radius)); AActor *thing; while ((thing = it.Next())) { + if (!thing->intersects(actor)) + { + continue; + } if (!(thing->flags & MF_SOLID)) { // Can't hit thing continue; @@ -3392,7 +3407,7 @@ void P_RadiusAttack (AActor *bombspot, AActor *bombsource, int bombdamage, int b float bombdamagefloat = (float)bombdamage; FVector3 bombvec(FIXED2FLOAT(bombspot->x), FIXED2FLOAT(bombspot->y), FIXED2FLOAT(bombspot->z)); - FRadiusThingsIterator it(bombspot->x, bombspot->y, bombdistance<x, bombspot->y, bombdistance<x, actor->y, actor->radius); + FBlockThingsIterator it(FBoundingBox(actor->x, actor->y, actor->radius)); while ((thing = it.Next())) { + if (!thing->intersects(actor)) + { + continue; + } if (!(thing->flags & MF_SOLID)) { // Can't hit thing continue; @@ -3665,9 +3684,13 @@ void P_FindBelowIntersectors (AActor *actor) return; AActor *thing; - FRadiusThingsIterator it(actor->x, actor->y, actor->radius); + FBlockThingsIterator it(FBoundingBox(actor->x, actor->y, actor->radius)); while ((thing = it.Next())) { + if (!thing->intersects(actor)) + { + continue; + } if (!(thing->flags & MF_SOLID)) { // Can't hit thing continue; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 0f12f382f2..87a151a949 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -858,39 +858,6 @@ AActor *FBlockThingsIterator::Next() } -//=========================================================================== -// -// FRadiusThingsIterator :: Next -// -//=========================================================================== - -FRadiusThingsIterator::FRadiusThingsIterator(fixed_t x, fixed_t y, fixed_t radius) -: FBlockThingsIterator(FBoundingBox(x, y, radius)) -{ - X = x; - Y = y; - Radius = radius; -} - -//=========================================================================== -// -// FRadiusThingsIterator :: Next -// -//=========================================================================== - -AActor *FRadiusThingsIterator::Next() -{ - AActor *actor; - while ((actor = FBlockThingsIterator::Next())) - { - fixed_t blockdist = actor->radius + Radius; - if ( abs(actor->x - X) < blockdist && abs(actor->y - Y) < blockdist) - return actor; - } - return NULL; -} - - //=========================================================================== // // FPathTraverse :: Intercepts