- made voodooTarget a pointer and removed most direct references to target_i.

This commit is contained in:
Christoph Oelckers 2021-08-29 18:13:15 +02:00
parent bf424b6439
commit a67da5003a
7 changed files with 28 additions and 28 deletions

View file

@ -523,6 +523,7 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int
for (int nTSprite = spritesortcnt-1; nTSprite >= 0; nTSprite--)
{
tspritetype *pTSprite = &tsprite[nTSprite];
auto owneractor = &bloodActors[pTSprite->owner];
//int nXSprite = pTSprite->extra;
int nXSprite = sprite[pTSprite->owner].extra;
XSPRITE *pTXSprite = NULL;
@ -805,8 +806,8 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int
case kMissileFlareRegular:
case kMissileFlareAlt:
if (pTSprite->statnum == kStatFlare) {
assert(pTXSprite != NULL);
if (pTXSprite->target_i == gView->nSprite) {
if (owneractor->GetTarget() == gView->actor())
{
pTSprite->xrepeat = 0;
break;
}
@ -833,9 +834,8 @@ void viewProcessSprites(spritetype* tsprite, int& spritesortcnt, int32_t cX, int
{
if (pTSprite->type == kDudeHand && pTXSprite->aiState == &hand13A3B4)
{
spritetype *pTTarget = &sprite[pTXSprite->target_i];
assert(pTXSprite != NULL && pTTarget != NULL);
if (IsPlayerSprite(pTTarget))
auto target = owneractor->GetTarget();
if (target && target->IsPlayerActor())
{
pTSprite->xrepeat = 0;
break;

View file

@ -8545,8 +8545,8 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor)
//
//---------------------------------------------------------------------------
void aiPatrolFlagsMgr(spritetype* pSource, XSPRITE* pXSource, spritetype* pDest, XSPRITE* pXDest, bool copy, bool init) {
void aiPatrolFlagsMgr(spritetype* pSource, XSPRITE* pXSource, spritetype* pDest, XSPRITE* pXDest, bool copy, bool init)
{
auto destactor = &bloodActors[pDest->index];
// copy flags
if (copy) {

View file

@ -698,7 +698,7 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->laughCount = 0;
pPlayer->angle.spin = 0;
pPlayer->posture = 0;
pPlayer->voodooTarget = -1;
pPlayer->voodooTarget = nullptr;
pPlayer->voodooTargets = 0;
pPlayer->voodooVar1 = 0;
pPlayer->vodooVar2 = 0;
@ -707,7 +707,7 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->relAim.dx = 0x4000;
pPlayer->relAim.dy = 0;
pPlayer->relAim.dz = 0;
pPlayer->aimTarget = -1;
pPlayer->aimTarget = nullptr;
pPlayer->zViewVel = pPlayer->zWeaponVel;
if (!(gGameOptions.nGameType == 1 && gGameOptions.bKeepKeysOnRespawn && !bNewLevel))
for (int i = 0; i < 8; i++)
@ -1943,7 +1943,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage
spritetype *pSprite = pPlayer->pSprite;
XSPRITE *pXSprite = pPlayer->pXSprite;
auto pActor = &bloodActors[pSprite->index];
auto pActor = pPlayer->actor();
int nXSprite = pSprite->extra;
int nXSector = sector[pSprite->sectnum].extra;
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
@ -2042,7 +2042,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage
nDeathSeqID = 16;
nKneelingPlayer = nPlayerKneelClient;
powerupActivate(pPlayer, kPwUpDeliriumShroom);
pXSprite->target_i = nSource;
pActor->SetTarget(source);
evPostActor(&bloodActors[pSprite->index], 15, kCallbackFinishHim);
}
else
@ -2448,7 +2448,6 @@ DEFINE_FIELD_X(BloodPlayer, PLAYER, fuseTime)
DEFINE_FIELD_X(BloodPlayer, PLAYER, throwTime)
DEFINE_FIELD_X(BloodPlayer, PLAYER, throwPower)
DEFINE_FIELD_X(BloodPlayer, PLAYER, aim) // world
DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTarget) // aim target sprite
DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTargetsCount)
DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTargets)
DEFINE_FIELD_X(BloodPlayer, PLAYER, deathTime)
@ -2468,7 +2467,7 @@ DEFINE_FIELD_X(BloodPlayer, PLAYER, packItemTime) // pack timer
DEFINE_FIELD_X(BloodPlayer, PLAYER, packItemId) // pack id 1: diving suit, 2: crystal ball, 3:
DEFINE_FIELD_X(BloodPlayer, PLAYER, packSlots) // at325 1]: diving suit, [2]: crystal ball,
DEFINE_FIELD_X(BloodPlayer, PLAYER, armor) // armor
DEFINE_FIELD_X(BloodPlayer, PLAYER, voodooTarget)
//DEFINE_FIELD_X(BloodPlayer, PLAYER, voodooTarget)
DEFINE_FIELD_X(BloodPlayer, PLAYER, flickerEffect)
DEFINE_FIELD_X(BloodPlayer, PLAYER, tiltEffect)
DEFINE_FIELD_X(BloodPlayer, PLAYER, visibility)

View file

@ -139,7 +139,7 @@ struct PLAYER
//int relAim;
//int at1ce;
//int at1d2;
int aimTarget; // aim target sprite
DBloodActor* aimTarget; // aim target sprite
int aimTargetsCount;
short aimTargets[16];
int deathTime;
@ -164,7 +164,7 @@ struct PLAYER
int armor[3]; // armor
//int at342;
//int at346;
int voodooTarget;
DBloodActor* voodooTarget;
int voodooTargets; // --> useless
int voodooVar1; // --> useless
int vodooVar2; // --> useless

View file

@ -222,12 +222,12 @@ void LifeLeechOperate(spritetype *pSprite, XSPRITE *pXSprite, EVENT event)
}
case kCmdSpriteProximity:
{
int nTarget = pXSprite->target_i;
if (nTarget >= 0 && nTarget < kMaxSprites)
auto target = actor->GetTarget();
if (target)
{
if (!pXSprite->stateTimer)
{
spritetype *pTarget = &sprite[nTarget];
spritetype *pTarget = &target->s();
if (pTarget->statnum == kStatDude && !(pTarget->flags&32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites)
{
int top, bottom;
@ -242,8 +242,8 @@ void LifeLeechOperate(spritetype *pSprite, XSPRITE *pXSprite, EVENT event)
if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sectnum, x, y, z, pTarget->sectnum))
{
int t = DivScale(nDist, 0x1aaaaa, 12);
x += (xvel[nTarget]*t)>>12;
y += (yvel[nTarget]*t)>>12;
x += (target->xvel()*t)>>12;
y += (target->yvel()*t)>>12;
int angBak = pSprite->ang;
pSprite->ang = getangle(x-pSprite->x, y-pSprite->y);
int dx = bcos(pSprite->ang);
@ -471,7 +471,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
case kDudeBurningBeast: {
pXSpawn->health = getDudeInfo(pXSprite->data1)->startHealth << 4;
pXSpawn->burnTime = 10;
pXSpawn->target_i = -1;
spawned->SetTarget(nullptr);
aiActivateDude(spawned);
break;
default:

View file

@ -482,7 +482,7 @@ void UpdateAimVector(PLAYER * pPlayer)
pPlayer->aim = pPlayer->relAim;
RotateVector((int*)&pPlayer->aim.dx, (int*)&pPlayer->aim.dy, pPSprite->ang);
pPlayer->aim.dz += pPlayer->slope;
pPlayer->aimTarget = nTarget;
pPlayer->aimTarget = &bloodActors[nTarget];
}
struct t_WeaponModes
@ -1443,8 +1443,8 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer)
actDamageSprite(actor, actor, kDamageBullet, 1<<4);
return;
}
assert(pPlayer->voodooTarget >= 0);
auto targetactor = &bloodActors[pPlayer->voodooTarget];
assert(pPlayer->voodooTarget != nullptr);
auto targetactor = pPlayer->voodooTarget;
spritetype *pTarget = &targetactor->s();
if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, pTarget))
return;
@ -1703,8 +1703,9 @@ void FireLifeLeech(int nTrigger, PLAYER *pPlayer)
spritetype *pMissile = playerFireMissile(pPlayer, 0, pPlayer->aim.dx+r1, pPlayer->aim.dy+r2, pPlayer->aim.dz+r3, 315);
if (pMissile)
{
auto missileActor = &bloodActors[pMissile->index];
XSPRITE *pXSprite = &xsprite[pMissile->extra];
pXSprite->target_i = pPlayer->aimTarget;
missileActor->SetTarget(pPlayer->aimTarget);
pMissile->ang = (nTrigger==2) ? 1024 : 0;
}
if (checkAmmo2(pPlayer, 8, 1))
@ -2452,7 +2453,7 @@ void WeaponProcess(PLAYER *pPlayer) {
{
}
pPlayer->voodooTarget = pPlayer->aimTarget;
if (pPlayer->voodooTarget == -1 || sprite[pPlayer->voodooTarget].statnum != kStatDude)
if (pPlayer->voodooTarget == nullptr || pPlayer->voodooTarget->s().statnum != kStatDude)
i = 4;
StartQAV(pPlayer,kQAVVDFIRE1 + i, nClientFireVoodoo);
return;

View file

@ -98,7 +98,7 @@ struct BloodPlayer native
native int throwTime;
native int throwPower;
//native Aim aim; // world
native int aimTarget; // aim target sprite
//native int aimTarget; // aim target sprite
native int aimTargetsCount;
native short aimTargets[16];
native int deathTime;
@ -118,7 +118,7 @@ struct BloodPlayer native
native int packItemId; // pack id 1: diving suit, 2: crystal ball, 3: beast vision 4: jump boots
native PACKINFO packSlots[5]; // at325 [1]: diving suit, [2]: crystal ball, [3]: beast vision [4]: jump boots
native int armor[3]; // armor
native int voodooTarget;
//native int voodooTarget;
native int flickerEffect;
native int tiltEffect;
native int visibility;