Skip to content

Commit

Permalink
- use GetIndex for error messages and deleted several unused index va…
Browse files Browse the repository at this point in the history
…riables.
  • Loading branch information
coelckers committed Sep 6, 2021
1 parent d432a67 commit 0e9ef64
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 22 deletions.
6 changes: 2 additions & 4 deletions source/games/blood/src/actor.cpp
Expand Up @@ -2454,7 +2454,7 @@ static void actInitDudes()
{
spritetype* pSprite = &act->s();
if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax)
I_Error("Non-enemy sprite (%d) in the enemy sprite list.\n", pSprite->index);
I_Error("Non-enemy sprite (%d) in the enemy sprite list.\n", act->GetIndex());
unk[pSprite->type - kDudeBase] = 1;
}

Expand Down Expand Up @@ -2581,15 +2581,14 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, int x, int y,
}
else
{
Printf(PRINT_HIGH, "Unexpected type in ConcussSprite(): Sprite: %d Type: %d Stat: %d", (int)pSprite->index, (int)pSprite->type, (int)pSprite->statnum);
Printf(PRINT_HIGH, "Unexpected type in ConcussSprite(): Sprite: %d Type: %d Stat: %d", actor->GetIndex(), (int)pSprite->type, (int)pSprite->statnum);
return;
}

if (mass > 0)
{
int size = (tileWidth(pSprite->picnum) * pSprite->xrepeat * tileHeight(pSprite->picnum) * pSprite->yrepeat) >> 1;
int t = scale(damage, size, mass);
int nSprite = pSprite->index;
actor->xvel += MulScale(t, dx, 16);
actor->yvel += MulScale(t, dy, 16);
actor->zvel += MulScale(t, dz, 16);
Expand Down Expand Up @@ -6718,7 +6717,6 @@ DBloodActor* actFireMissile(DBloodActor* actor, int a2, int a3, int a4, int a5,
assert(nType >= kMissileBase && nType < kMissileMax);
char v4 = 0;
auto pSprite = &actor->s();
int nSprite = pSprite->index;
const MissileType* pMissileInfo = &missileInfo[nType - kMissileBase];
int x = pSprite->x + MulScale(a2, Cos(pSprite->ang + 512), 30);
int y = pSprite->y + MulScale(a2, Sin(pSprite->ang + 512), 30);
Expand Down
3 changes: 1 addition & 2 deletions source/games/blood/src/ai.cpp
Expand Up @@ -998,7 +998,6 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
if (source)
{
spritetype *pSource = &source->s();
int nSource = pSource->index;
if (pSprite == pSource) return 0;
else if (actor->GetTarget() == nullptr) // if no target, give the dude a target
{
Expand Down Expand Up @@ -1043,7 +1042,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
}
}

DPrintf(DMSG_SPAMMY, "Player #%d does the critical damage to patrol dude #%d!", pPlayer->nPlayer + 1, pSprite->index);
DPrintf(DMSG_SPAMMY, "Player #%d does the critical damage to patrol dude #%d!", pPlayer->nPlayer + 1, actor->GetIndex());
}

return nDamage;
Expand Down
1 change: 0 additions & 1 deletion source/games/blood/src/aibeast.cpp
Expand Up @@ -618,7 +618,6 @@ static void sub_62D7C(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
int nSprite = pSprite->index;
assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
if (!actor->ValidateTarget(__FUNCTION__)) return;
Expand Down
2 changes: 0 additions & 2 deletions source/games/blood/src/aighost.cpp
Expand Up @@ -314,7 +314,6 @@ static void ghostMoveDodgeUp(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
int nSprite = pSprite->index;
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
Expand Down Expand Up @@ -350,7 +349,6 @@ static void ghostMoveDodgeDown(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
int nSprite = pSprite->index;
///assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) {
Printf(PRINT_HIGH, "pSprite->type >= kDudeBase && pSprite->type < kDudeMax");
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/aigilbst.cpp
Expand Up @@ -352,7 +352,7 @@ static void sub_6CB00(DBloodActor* actor)
{
auto pXSprite = &actor->x();
auto pSprite = &actor->s();
int nSprite = pSprite->index;

assert(pSprite->type >= kDudeBase && pSprite->type < kDudeMax);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int nAng = ((pXSprite->goalAng + 1024 - pSprite->ang) & 2047) - 1024;
Expand Down
4 changes: 2 additions & 2 deletions source/games/blood/src/aiunicult.cpp
Expand Up @@ -2356,7 +2356,7 @@ bool genDudePrepare(DBloodActor* actor, int propId)
Printf(PRINT_HIGH, "pSprite->type != kDudeModernCustom");
return false;
} else if (propId < kGenDudePropertyAll || propId >= kGenDudePropertyMax) {
viewSetSystemMessage("Unknown custom dude #%d property (%d)", pSprite->index, propId);
viewSetSystemMessage("Unknown custom dude #%d property (%d)", actor->GetIndex(), propId);
return false;
}

Expand Down Expand Up @@ -2446,7 +2446,7 @@ bool genDudePrepare(DBloodActor* actor, int propId)
if (!pSeq)
{
pXSprite->data2 = getDudeInfo(pSprite->type)->seqStartID;
viewSetSystemMessage("No SEQ animation id %d found for custom dude #%d!", i, pSprite->index);
viewSetSystemMessage("No SEQ animation id %d found for custom dude #%d!", i, actor->GetIndex());
viewSetSystemMessage("SEQ base id: %d", seqStartId);
}
else if ((i - seqStartId) == kGenDudeSeqAttackPunch)
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/asound.cpp
Expand Up @@ -131,7 +131,7 @@ void ambInit(void)
auto snd = soundEngine->FindSoundByResID(nSFX);
if (!snd) {
//I_Error("Missing sound #%d used in ambient sound generator %d\n", nSFX);
viewSetSystemMessage("Missing sound #%d used in ambient sound generator #%d\n", nSFX, actor->s().index);
viewSetSystemMessage("Missing sound #%d used in ambient sound generator #%d\n", nSFX, actor->GetIndex());
actPostSprite(actor, kStatDecoration);
continue;
}
Expand Down
1 change: 0 additions & 1 deletion source/games/blood/src/db.cpp
Expand Up @@ -819,7 +819,6 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
pSprite->statnum = LittleShort(load.statnum);
pSprite->ang = LittleShort(load.ang);
pSprite->owner = LittleShort(load.owner);
pSprite->index = LittleShort(load.index);
pSprite->yvel = LittleShort(load.yvel);
pSprite->inittype = LittleShort(load.inittype);
pSprite->type = LittleShort(load.type);
Expand Down
14 changes: 7 additions & 7 deletions source/games/blood/src/nnexts.cpp
Expand Up @@ -566,7 +566,7 @@ void nnExtInitModernStuff()
if (!pXSprite->rxID && pXSprite->data1 > kCondGameMax) condError(actor,"\nThe condition must have RX ID!\nSPRITE #%d", actor->GetIndex());
else if (!pXSprite->txID && !pSprite->flags)
{
Printf(PRINT_HIGH, "The condition must have TX ID or hitag to be set: RX ID %d, SPRITE #%d", pXSprite->rxID, pSprite->index);
Printf(PRINT_HIGH, "The condition must have TX ID or hitag to be set: RX ID %d, SPRITE #%d", pXSprite->rxID, actor->GetIndex());
}
break;
}
Expand Down Expand Up @@ -681,7 +681,7 @@ void nnExtInitModernStuff()
I_Error("\nPlayer Control (SPRITE #%d):\nPlayer out of a range (data1 = %d)", actor->GetIndex(), pXSprite->data1);

//if (numplayers < pXSprite->data1)
//I_Error("\nPlayer Control (SPRITE #%d):\n There is no player #%d", pSprite->index, pXSprite->data1);
//I_Error("\nPlayer Control (SPRITE #%d):\n There is no player #%d", actor->GetIndex(), pXSprite->data1);

if (pXSprite->rxID && pXSprite->rxID != kChannelLevelStart)
I_Error("\nPlayer Control (SPRITE #%d) with Link command should have no RX ID!", actor->GetIndex());
Expand Down Expand Up @@ -715,7 +715,7 @@ void nnExtInitModernStuff()
if (pXSprite->waitTime > 0)
{
pXSprite->busyTime += ClipHigh(((pXSprite->waitTime * 120) / 10), 4095); pXSprite->waitTime = 0;
Printf(PRINT_HIGH, "Summing busyTime and waitTime for tracking condition #%d, RX ID %d. Result = %d ticks", pSprite->index, pXSprite->rxID, pXSprite->busyTime);
Printf(PRINT_HIGH, "Summing busyTime and waitTime for tracking condition #%d, RX ID %d. Result = %d ticks", actor->GetIndex(), pXSprite->rxID, pXSprite->busyTime);
}
pXSprite->busy = pXSprite->busyTime;
}
Expand Down Expand Up @@ -888,7 +888,7 @@ void nnExtInitModernStuff()
}

if (pXSprite->data1 > kCondGameMax && count == 0)
Printf(PRINT_HIGH, "No objects to track found for condition #%d, RXID: %d!", pSprite->index, pXSprite->rxID);
Printf(PRINT_HIGH, "No objects to track found for condition #%d, RXID: %d!", iactor->GetIndex(), pXSprite->rxID);

pCond->length = count;
pCond->actor = iactor;
Expand Down Expand Up @@ -7920,7 +7920,7 @@ void aiPatrolSetMarker(DBloodActor* actor)

if (firstFinePath == nullptr)
{
viewSetSystemMessage("No markers with id #%d found for dude #%d! (back = %d)", next, pSprite->index, back);
viewSetSystemMessage("No markers with id #%d found for dude #%d! (back = %d)", next, actor->GetIndex(), back);
return;
}

Expand Down Expand Up @@ -8213,7 +8213,7 @@ void aiPatrolAlarmFull(DBloodActor* actor, DBloodActor* targetactor, bool chain)

if (chain)
aiPatrolAlarmFull(dudeactor, targetactor, Chance(0x0010));
//Printf("Dude #%d alarms dude #%d", pSprite->index, pDude->index);
//Printf("Dude #%d alarms dude #%d", actor->GetIndex(), pDude->index);
}
}
}
Expand Down Expand Up @@ -8578,7 +8578,7 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor)

if (itCanSee && seeChance > 0)
{
//DPrintf(DMSG_SPAMMY, "Patrol dude #%d seeing the Player #%d.", pSprite->index, pPlayer->nPlayer + 1);
//DPrintf(DMSG_SPAMMY, "Patrol dude #%d seeing the Player #%d.", actor->GetIndex(), pPlayer->nPlayer + 1);
//pXSprite->data3 += seeChance;
pXSprite->data3 = ClipRange(pXSprite->data3 + seeChance, -kMaxPatrolSpotValue, kMaxPatrolSpotValue);
if (!stealth)
Expand Down
1 change: 0 additions & 1 deletion source/games/blood/src/player.cpp
Expand Up @@ -1582,7 +1582,6 @@ void ProcessInput(PLAYER *pPlayer)
{
spritetype* pSprite2 = &spawned->s();
pSprite2->ang = (pPlayer->pSprite->ang + 1024) & 2047;
int nSprite = pPlayer->pSprite->index;
int x = CosScale16(pPlayer->pSprite->ang);
int y = SinScale16(pPlayer->pSprite->ang);
spawned->xvel = pPlayer->actor->xvel + MulScale(0x155555, x, 14);
Expand Down

0 comments on commit 0e9ef64

Please sign in to comment.