From 458124a237615a9a4807fad820e9e12f061a2b07 Mon Sep 17 00:00:00 2001 From: pogokeen Date: Tue, 25 Jun 2019 18:35:24 +0000 Subject: [PATCH] actors.cpp: Change demo camera path following behaviour to search for locators based on a hitag channel to avoid locator lotag contention. Now, destination and subject locators should be assigned one hitag channel. Destination locators will be visited starting from lotag 0 and counting upward. Subject locators can have any lotag within the same hitag channel, and may also be a destination if the lotag is not separated from the destination locator ids. Destination locators must now specify their subject locator in their owner field by lotag. git-svn-id: https://svn.eduke32.com/eduke32@7739 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/actors.cpp | 32 ++++++++++++++++++++------------ source/duke3d/src/game.cpp | 1 + 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/source/duke3d/src/actors.cpp b/source/duke3d/src/actors.cpp index 40a452758..68f47ce32 100644 --- a/source/duke3d/src/actors.cpp +++ b/source/duke3d/src/actors.cpp @@ -3763,6 +3763,17 @@ static int A_FindLocator(int const tag, int const sectNum) return -1; } +static int A_FindLocatorWithHiLoTags(int const hitag, int const tag, int const sectNum) +{ + for (bssize_t SPRITES_OF(STAT_LOCATOR, spriteNum)) + { + if ((sectNum == -1 || sectNum == SECT(spriteNum)) && tag == SLT(spriteNum) && hitag == SHT(spriteNum)) + return spriteNum; + } + + return -1; +} + ACTOR_STATIC void G_MoveActors(void) { int spriteNum = headspritestat[STAT_ACTOR]; @@ -7575,7 +7586,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 findCameraDestination: if (pSprite->owner == spriteNum) { - pSprite->owner = A_FindLocator(pSprite->hitag, -1); + pSprite->owner = A_FindLocatorWithHiLoTags(pSprite->hitag, pData[0], -1); //reset our elapsed time since reaching a locator pData[1] = 0; @@ -7588,14 +7599,11 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if (pSprite->owner != -1) { spritetype* const destLocator = &sprite[pSprite->owner]; - int32_t subjectLocatorIndex = A_FindLocator(destLocator->hitag, -1); - if (subjectLocatorIndex == -1) - { - pData[7] = pSprite->ang; - //level the camera out by default (pData[8] stores our destination up/down angle) - pData[8] = 100; - } - else + int32_t subjectLocatorIndex = A_FindLocatorWithHiLoTags(pSprite->hitag, destLocator->owner, -1); + pData[7] = G_GetAngleDelta(pData[5], destLocator->ang); + //level the camera out by default (pData[8] stores our destination up/down angle) + pData[8] = 100; + if (subjectLocatorIndex != -1) { spritetype* const subjectLocator = &sprite[subjectLocatorIndex]; const vec3_t cameraDirection = {subjectLocator->x - destLocator->x, @@ -7615,11 +7623,11 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 break; } - spritetype* const destLocator = &sprite[pSprite->owner]; + spritetype* const destLocator = &sprite[pSprite->owner]; if (pData[1] == destLocator->extra) { pSprite->owner = spriteNum; - ++pSprite->hitag; + ++pData[0]; goto findCameraDestination; } @@ -7634,7 +7642,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 pSprite->z = pData[4]+interpolation*heading.z; pSprite->ang = pData[5]+interpolation*pData[7]; pSprite->yvel = (pData[6]+((int32_t) interpolation*pData[8])+100)%400-100; - + //increment elapsed time ++pData[1]; } diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 3c4849a2e..fb75e7463 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -2942,6 +2942,7 @@ int A_Spawn(int spriteNum, int tileNum) sector[sectNum].ceilingz = pSprite->z; break; case SE_27_DEMO_CAM: + T1(newSprite) = 0; if (ud.recstat == 1) { pSprite->xrepeat=pSprite->yrepeat=64;