From ec9ab56ece8fe47ab0df9ce7e00e9ecc4aeb327c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Oct 2021 01:15:32 +0200 Subject: [PATCH] - use collision struct in ActorMoveHitReact --- source/build/include/build.h | 4 ---- source/games/sw/src/ai.cpp | 32 ++++++-------------------------- source/games/sw/src/swactor.h | 9 ++++++++- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 666f8f28f..c61b66484 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -699,10 +699,6 @@ enum EHitBits kHitSector = 0x4000, kHitWall = 0x8000, kHitSprite = 0xC000, - kHitSky = 0x10000, // SW only - kHitFloor = 0x18000, // Exhumed only - kHitCeiling = 0x1c000, // Exhumed only - }; void updateModelInterpolation(); diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index dd9050993..142826db5 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -118,42 +118,22 @@ bool ActorMoveHitReact(DSWActor* actor) // Should only return true if there is a reaction to what was hit that // would cause the calling function to abort - switch (TEST(u->ret, HIT_MASK)) + auto coll = u->hitCode(); + if (coll.type == kHitSprite) { - case HIT_SPRITE: - { - short HitSprite = NORM_SPRITE(u->ret); - USERp hu; - ANIMATORp action; - - hu = User[HitSprite].Data(); - - - // if you ran into a player - call close range functions - if (hu && hu->PlayerP) + auto hitActor = coll.actor; + if (hitActor->hasU() && hitActor->u()->PlayerP) { + // if you ran into a player - call close range functions DoActorPickClosePlayer(SpriteNum); - action = ChooseAction(u->Personality->TouchTarget); + auto action = ChooseAction(u->Personality->TouchTarget); if (action) { (*action)(actor); return true; } } - break; } - - case HIT_WALL: - { - break; - } - - case HIT_SECTOR: - { - break; - } - } - return false; } diff --git a/source/games/sw/src/swactor.h b/source/games/sw/src/swactor.h index f2ade5a42..ca073cc9b 100644 --- a/source/games/sw/src/swactor.h +++ b/source/games/sw/src/swactor.h @@ -137,6 +137,13 @@ public: }; +enum EHitBitsSW +{ + kHitTypeMaskSW = 0x1C000, + kHitSky = 0x10000, // SW only +}; + + // Wrapper around the insane collision info mess from Build. struct Collision { @@ -185,7 +192,7 @@ struct Collision int setFromEngine(int value) { legacyVal = value; - type = value & kHitTypeMask; + type = value & kHitTypeMaskSW; if (type == 0) { index = -1; actor = nullptr; } else if (type != kHitSprite) { index = value & kHitIndexMask; actor = nullptr; } else { index = -1; actor = &swActors[value & kHitIndexMask]; }