From ee429fd1f4cae02c1fe7eabb4fedbb618429c7c6 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Fri, 15 Nov 2024 22:51:48 +0200 Subject: [PATCH] Convert SOLDIERTYPE->ubAttackerID to SoldierID --- Multiplayer/client.cpp | 8 ++++---- Strategic/Strategic Merc Handler.cpp | 4 ++-- Strategic/Strategic Town Loyalty.cpp | 8 ++++---- Tactical/Overhead.cpp | 22 +++++++++++----------- Tactical/Rotting Corpses.cpp | 4 ++-- Tactical/Soldier Ani.cpp | 16 ++++++++-------- Tactical/Soldier Control.cpp | 6 +++--- Tactical/Soldier Control.h | 2 +- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Multiplayer/client.cpp b/Multiplayer/client.cpp index 637f6df4..b8507358 100644 --- a/Multiplayer/client.cpp +++ b/Multiplayer/client.cpp @@ -3844,9 +3844,9 @@ void send_death( SOLDIERTYPE *pSoldier ) if(pSoldier->ubID<20)nDeath.soldier_id=nDeath.soldier_id+ubID_prefix; // if soldier died from bleeding - if(pSoldier->ubAttackerID==NULL || pSoldier->ubAttackerID == NOBODY) + if(pSoldier->ubAttackerID >= NOBODY) { - if (pSoldier->ubPreviousAttackerID != NOBODY && pSoldier->ubPreviousAttackerID != NULL) + if (pSoldier->ubPreviousAttackerID < NOBODY) nDeath.attacker_id = pSoldier->ubPreviousAttackerID; else if (pSoldier->ubNextToPreviousAttackerID != NOBODY && pSoldier->ubNextToPreviousAttackerID != NULL) nDeath.attacker_id = pSoldier->ubNextToPreviousAttackerID; @@ -3871,8 +3871,8 @@ void send_death( SOLDIERTYPE *pSoldier ) pAttacker=MercPtrs[ pSoldier->ubNextToPreviousAttackerID ]; // if its still a friendly, use the original attacker id...for posterity // guy must snore too loudly if all his mates wanna kill him :) - if (pAttacker->bTeam == pSoldier->bTeam && pSoldier->ubAttackerID != NULL && pSoldier->ubAttackerID != NOBODY) - pAttacker = MercPtrs[ pSoldier->ubAttackerID ]; + if (pAttacker->bTeam == pSoldier->bTeam && pSoldier->ubAttackerID != NOBODY) + pAttacker = pSoldier->ubAttackerID; nDeath.attacker_id = pAttacker->ubID; } diff --git a/Strategic/Strategic Merc Handler.cpp b/Strategic/Strategic Merc Handler.cpp index b3a21464..e6cae0b5 100644 --- a/Strategic/Strategic Merc Handler.cpp +++ b/Strategic/Strategic Merc Handler.cpp @@ -85,7 +85,7 @@ void StrategicHandlePlayerTeamMercDeath( SOLDIERTYPE *pSoldier ) //add to the history log the fact that the merc died and the circumstances if( pSoldier->ubAttackerID != NOBODY ) { - pKiller = MercPtrs[ pSoldier->ubAttackerID ]; + pKiller = pSoldier->ubAttackerID; } // CJC Nov 11, 2002 @@ -141,7 +141,7 @@ void StrategicHandlePlayerTeamMercDeath( SOLDIERTYPE *pSoldier ) gMercProfiles[ pSoldier->ubProfile ].ubSuspiciousDeath = VERY_SUSPICIOUS_DEATH; } // if killed by someone on our team, or while there weren't any opponents around - else if (Menptr[ pSoldier->ubAttackerID ].bTeam == OUR_TEAM || !gTacticalStatus.fEnemyInSector ) + else if (pSoldier->ubAttackerID->bTeam == OUR_TEAM || !gTacticalStatus.fEnemyInSector ) { // cause insurance company to suspect fraud and investigate this claim gMercProfiles[ pSoldier->ubProfile ].ubSuspiciousDeath = SUSPICIOUS_DEATH; diff --git a/Strategic/Strategic Town Loyalty.cpp b/Strategic/Strategic Town Loyalty.cpp index 579155ab..44fc5f1f 100644 --- a/Strategic/Strategic Town Loyalty.cpp +++ b/Strategic/Strategic Town Loyalty.cpp @@ -740,13 +740,13 @@ void HandleMurderOfCivilian( SOLDIERTYPE *pSoldier, BOOLEAN fIntentional ) } */ // set killer team - bKillerTeam = Menptr[ pSoldier->ubAttackerID ].bTeam; + bKillerTeam = pSoldier->ubAttackerID->bTeam; // if the player did the killing if( bKillerTeam == OUR_TEAM ) { - SOLDIERTYPE *pKiller = MercPtrs[ pSoldier->ubAttackerID ]; + SOLDIERTYPE *pKiller = pSoldier->ubAttackerID; // apply morale penalty for killing a civilian! HandleMoraleEvent( pKiller, MORALE_KILLED_CIVILIAN, pKiller->sSectorX, pKiller->sSectorY, pKiller->bSectorZ ); @@ -800,7 +800,7 @@ void HandleMurderOfCivilian( SOLDIERTYPE *pSoldier, BOOLEAN fIntentional ) } // killer seen by civ? - if ( SoldierToSoldierLineOfSightTest( pCivSoldier, MercPtrs[ pSoldier->ubAttackerID ], TRUE, gGameExternalOptions.ubStraightSightRange ) != 0 ) + if ( SoldierToSoldierLineOfSightTest( pCivSoldier, pSoldier->ubAttackerID, TRUE, gGameExternalOptions.ubStraightSightRange ) != 0 ) { bSeenState |= 1; } @@ -908,7 +908,7 @@ void HandleMurderOfCivilian( SOLDIERTYPE *pSoldier, BOOLEAN fIntentional ) case CREATURE_TEAM: // killed by a monster - make sure it was one - if( ( Menptr[ pSoldier->ubAttackerID ].ubBodyType >= ADULTFEMALEMONSTER ) && ( Menptr[ pSoldier->ubAttackerID ].ubBodyType <= QUEENMONSTER ) ) + if( ( pSoldier->ubAttackerID->ubBodyType >= ADULTFEMALEMONSTER ) && ( pSoldier->ubAttackerID->ubBodyType <= QUEENMONSTER ) ) { // increase for the extreme horror of being killed by a monster iLoyaltyChange *= MULTIPLIER_FOR_MURDER_BY_MONSTER; diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 3d10915f..f729d931 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -3796,7 +3796,7 @@ void HandleNPCTeamMemberDeath( SOLDIERTYPE *pSoldierOld ) { if ( pSoldierOld->ubAttackerID != NOBODY ) { - pKiller = MercPtrs[ pSoldierOld->ubAttackerID ]; + pKiller = pSoldierOld->ubAttackerID; } if( pKiller && pKiller->bTeam == OUR_TEAM ) { @@ -4016,7 +4016,7 @@ void HandleNPCTeamMemberDeath( SOLDIERTYPE *pSoldierOld ) { if ( pSoldierOld->ubAttackerID != NOBODY ) { - pKiller = MercPtrs[ pSoldierOld->ubAttackerID ]; + pKiller = pSoldierOld->ubAttackerID; } BeginHandleDeidrannaDeath( pKiller, pSoldierOld->sGridNo, pSoldierOld->pathing.bLevel ); @@ -4088,7 +4088,7 @@ void HandleNPCTeamMemberDeath( SOLDIERTYPE *pSoldierOld ) // If the militia's killer is known // silversurfer: did the player team kill the militia? If not, militia shouldn't become hostile towards the player. - if ( pSoldierOld->ubAttackerID != NOBODY && MercPtrs[ pSoldierOld->ubAttackerID ]->bTeam == OUR_TEAM ) + if ( pSoldierOld->ubAttackerID != NOBODY && pSoldierOld->ubAttackerID->bTeam == OUR_TEAM ) { // also treat this as murder - but player will never be blamed for militia death he didn't cause // HEADROCK HAM 3.6: Actually this function never runs for militia (see function for details) @@ -4118,7 +4118,7 @@ void HandleNPCTeamMemberDeath( SOLDIERTYPE *pSoldierOld ) if ( pSoldierOld->ubAttackerID != NOBODY ) { - pKiller = MercPtrs[ pSoldierOld->ubAttackerID ]; + pKiller = pSoldierOld->ubAttackerID; BeginHandleQueenBitchDeath( pKiller, pSoldierOld->sGridNo, pSoldierOld->pathing.bLevel ); } @@ -4130,9 +4130,9 @@ void HandleNPCTeamMemberDeath( SOLDIERTYPE *pSoldierOld ) TrackEnemiesKilled( ENEMY_KILLED_IN_TACTICAL, pSoldierOld->ubSoldierClass ); } // If enemy guy was killed by the player, give morale boost to player's team! - if (pSoldierOld->ubAttackerID != NOBODY && MercPtrs[ pSoldierOld->ubAttackerID ]->bTeam == gbPlayerNum ) + if (pSoldierOld->ubAttackerID != NOBODY && pSoldierOld->ubAttackerID->bTeam == gbPlayerNum ) { - HandleMoraleEvent( MercPtrs[pSoldierOld->ubAttackerID], MORALE_KILLED_ENEMY, gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); + HandleMoraleEvent( pSoldierOld->ubAttackerID, MORALE_KILLED_ENEMY, gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); } HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_ENEMY_KILLED, gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); @@ -4176,7 +4176,7 @@ void HandleNPCTeamMemberDeath( SOLDIERTYPE *pSoldierOld ) UINT16 ubAssister = NOBODY; // if it was a kill by a player's merc - if (pSoldierOld->ubAttackerID != NOBODY && MercPtrs[ pSoldierOld->ubAttackerID ]->bTeam == gbPlayerNum ) + if (pSoldierOld->ubAttackerID != NOBODY && pSoldierOld->ubAttackerID->bTeam == gbPlayerNum ) { // SANDRO - for special NPCs, you gain more experiences UINT16 usNumExpChances = ( 10 * pSoldierOld->stats.bExpLevel ); // basic value @@ -4207,7 +4207,7 @@ void HandleNPCTeamMemberDeath( SOLDIERTYPE *pSoldierOld ) break; } // EXPERIENCE CLASS GAIN: Earned a kill - StatChange( MercPtrs[ pSoldierOld->ubAttackerID ], EXPERAMT, usNumExpChances, FALSE ); + StatChange( pSoldierOld->ubAttackerID, EXPERAMT, usNumExpChances, FALSE ); } // JA2 Gold: if previous and current attackers are the same, the next-to-previous attacker gets the assist @@ -4229,9 +4229,9 @@ void HandleNPCTeamMemberDeath( SOLDIERTYPE *pSoldierOld ) } } - if (pSoldierOld->ubAttackerID != NOBODY && MercPtrs[ pSoldierOld->ubAttackerID ]->bTeam == MILITIA_TEAM ) + if (pSoldierOld->ubAttackerID != NOBODY && pSoldierOld->ubAttackerID->bTeam == MILITIA_TEAM ) { - MercPtrs[pSoldierOld->ubAttackerID]->ubMilitiaAssists++; + pSoldierOld->ubAttackerID->ubMilitiaAssists++; } //if the NPC is a dealer, add the dealers items to the ground @@ -4567,7 +4567,7 @@ UINT8 CivilianGroupMembersChangeSidesWithinProximity( SOLDIERTYPE * pAttacked ) // if in LOS of this guy's attacker if ( (pAttacked->ubAttackerID != NOBODY && pSoldier->aiData.bOppList[pAttacked->ubAttackerID] == SEEN_CURRENTLY) || ( PythSpacesAway( pSoldier->sGridNo, pAttacked->sGridNo ) < pAttacked->GetMaxDistanceVisible(pSoldier->sGridNo, pSoldier->pathing.bLevel) ) - || ( pAttacked->ubAttackerID != NOBODY && PythSpacesAway( pSoldier->sGridNo, MercPtrs[ pAttacked->ubAttackerID ]->sGridNo ) < pAttacked->GetMaxDistanceVisible(MercPtrs[ pAttacked->ubAttackerID ]->sGridNo, MercPtrs[ pAttacked->ubAttackerID ]->pathing.bLevel) ) ) + || ( pAttacked->ubAttackerID != NOBODY && PythSpacesAway( pSoldier->sGridNo, pAttacked->ubAttackerID->sGridNo ) < pAttacked->GetMaxDistanceVisible(pAttacked->ubAttackerID->sGridNo, pAttacked->ubAttackerID->pathing.bLevel) ) ) { MakeCivHostile(pSoldier); if ( pSoldier->aiData.bOppCnt > 0 ) diff --git a/Tactical/Rotting Corpses.cpp b/Tactical/Rotting Corpses.cpp index cee4fe75..b5346fb6 100644 --- a/Tactical/Rotting Corpses.cpp +++ b/Tactical/Rotting Corpses.cpp @@ -1022,7 +1022,7 @@ BOOLEAN TurnSoldierIntoCorpse( SOLDIERTYPE *pSoldier, BOOLEAN fRemoveMerc, BOOLE // HEADROCK HAM B2.8: Now also reveals equipment dropped by militia, if requirement is met. if( pSoldier->bTeam == ENEMY_TEAM || ( gGameExternalOptions.ubMilitiaDropEquipment == 2 && pSoldier->bTeam == MILITIA_TEAM ) || - ( gGameExternalOptions.ubMilitiaDropEquipment == 1 && pSoldier->bTeam == MILITIA_TEAM && Menptr[ pSoldier->ubAttackerID ].bTeam != OUR_TEAM )) + ( gGameExternalOptions.ubMilitiaDropEquipment == 1 && pSoldier->bTeam == MILITIA_TEAM && pSoldier->ubAttackerID->bTeam != OUR_TEAM )) { //add a flag to the item so when all enemies are killed, we can run through and reveal all the enemies items usItemFlags |= WORLD_ITEM_DROPPED_FROM_ENEMY; @@ -1054,7 +1054,7 @@ BOOLEAN TurnSoldierIntoCorpse( SOLDIERTYPE *pSoldier, BOOLEAN fRemoveMerc, BOOLE // HEADROCK HAM B2.8: Militia will drop items only if allowed. if (!(gGameExternalOptions.ubMilitiaDropEquipment == 0 && pSoldier->bTeam == MILITIA_TEAM ) && - !(gGameExternalOptions.ubMilitiaDropEquipment == 1 && pSoldier->bTeam == MILITIA_TEAM && Menptr[ pSoldier->ubAttackerID ].bTeam == OUR_TEAM )) + !(gGameExternalOptions.ubMilitiaDropEquipment == 1 && pSoldier->bTeam == MILITIA_TEAM && pSoldier->ubAttackerID->bTeam == OUR_TEAM )) { AddItemToPool( pSoldier->sGridNo, pObj, bVisible , pSoldier->pathing.bLevel, usItemFlags, -1 ); } diff --git a/Tactical/Soldier Ani.cpp b/Tactical/Soldier Ani.cpp index 1b86246b..92cf3377 100644 --- a/Tactical/Soldier Ani.cpp +++ b/Tactical/Soldier Ani.cpp @@ -3932,7 +3932,7 @@ BOOLEAN HandleSoldierDeath( SOLDIERTYPE *pSoldier , BOOLEAN *pfMadeCorpse ) SOLDIERTYPE *pKillerSoldier = NULL; if(pSoldier->ubAttackerID != NOBODY) { - pKillerSoldier = MercPtrs[pSoldier->ubAttackerID]; + pKillerSoldier = pSoldier->ubAttackerID; } else if(pSoldier->ubPreviousAttackerID != NOBODY) { @@ -3995,8 +3995,8 @@ BOOLEAN HandleSoldierDeath( SOLDIERTYPE *pSoldier , BOOLEAN *pfMadeCorpse ) { ////////////////////////////////////////////////////////////// // SANDRO - some changes here - UINT16 ubAttacker = pSoldier->ubAttackerID; - UINT16 ubAssister = pSoldier->ubPreviousAttackerID; + SoldierID ubAttacker = pSoldier->ubAttackerID; + SoldierID ubAssister = pSoldier->ubPreviousAttackerID; // If attacker is nobody, and we died, then set the last attacker(if exists) as our killer if ( ubAttacker == NOBODY ) { @@ -4024,9 +4024,9 @@ BOOLEAN HandleSoldierDeath( SOLDIERTYPE *pSoldier , BOOLEAN *pfMadeCorpse ) { // anv: note that ubAttacker can be already different from pSoldier->ubAttackerID // IF this guy has an attacker and he's a good guy, play sound - if ( pSoldier->ubAttackerID != NOBODY ) + if ( pSoldier->ubAttackerID < NOBODY ) { - if ( MercPtrs[ pSoldier->ubAttackerID ] != NULL && MercPtrs[ pSoldier->ubAttackerID ]->bTeam == gbPlayerNum && gTacticalStatus.ubAttackBusyCount > 0 ) + if ( pSoldier->ubAttackerID->bTeam == gbPlayerNum && gTacticalStatus.ubAttackBusyCount > 0 ) { gTacticalStatus.fKilledEnemyOnAttack = TRUE; gTacticalStatus.ubEnemyKilledOnAttack = pSoldier->ubID; @@ -4110,7 +4110,7 @@ BOOLEAN HandleSoldierDeath( SOLDIERTYPE *pSoldier , BOOLEAN *pfMadeCorpse ) } break; } - //gMercProfiles[ MercPtrs[ pSoldier->ubAttackerID ]->ubProfile ].usKills++; + //gMercProfiles[ pSoldier->ubAttackerID->ubProfile ].usKills++; ///////////////////////////////////////////////////////////////////////////////////// gStrategicStatus.usPlayerKills++; @@ -4456,7 +4456,7 @@ void CheckForAndHandleSoldierIncompacitated( SOLDIERTYPE *pSoldier ) // SANDRO - if Martial Artist took someone down, always fall back if possible (for the fun) if ( pSoldier->ubAttackerID != NOBODY && gGameOptions.fNewTraitSystem ) { - if ( HAS_SKILL_TRAIT( MercPtrs[ pSoldier->ubAttackerID ], MARTIAL_ARTS_NT ) && (!MercPtrs[ pSoldier->ubAttackerID ]->usAttackingWeapon || ItemIsBrassKnuckles(MercPtrs[ pSoldier->ubAttackerID ]->inv[HANDPOS].usItem)) ) + if ( HAS_SKILL_TRAIT( pSoldier->ubAttackerID, MARTIAL_ARTS_NT ) && (!pSoldier->ubAttackerID->usAttackingWeapon || ItemIsBrassKnuckles(pSoldier->ubAttackerID->inv[HANDPOS].usItem)) ) { fAlwaysFallBack = TRUE; } @@ -4468,7 +4468,7 @@ void CheckForAndHandleSoldierIncompacitated( SOLDIERTYPE *pSoldier ) if ( pSoldier->ubAttackerID != NOBODY ) { // Find direction! - bTestDirection = (INT8)GetDirectionFromGridNo( MercPtrs[ pSoldier->ubAttackerID ]->sGridNo, pSoldier ); + bTestDirection = (INT8)GetDirectionFromGridNo( pSoldier->ubAttackerID->sGridNo, pSoldier ); fForceDirection = TRUE; } diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 78ba39b6..bb011c63 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -5732,9 +5732,9 @@ void SOLDIERTYPE::EVENT_SoldierGotHit( UINT16 usWeaponIndex, INT16 sDamage, INT1 // handle morale for heavy damage attacks if ( sDamage > 25 ) { - if ( this->ubAttackerID != NOBODY && MercPtrs[this->ubAttackerID]->bTeam == gbPlayerNum ) + if ( this->ubAttackerID != NOBODY && this->ubAttackerID->bTeam == gbPlayerNum ) { - HandleMoraleEvent( MercPtrs[this->ubAttackerID], MORALE_DID_LOTS_OF_DAMAGE, MercPtrs[this->ubAttackerID]->sSectorX, MercPtrs[this->ubAttackerID]->sSectorY, MercPtrs[this->ubAttackerID]->bSectorZ ); + HandleMoraleEvent( this->ubAttackerID, MORALE_DID_LOTS_OF_DAMAGE, this->ubAttackerID->sSectorX, this->ubAttackerID->sSectorY, this->ubAttackerID->bSectorZ ); this->ubLastMoraleFromHit++; } if ( this->bTeam == gbPlayerNum ) @@ -10475,7 +10475,7 @@ UINT8 SOLDIERTYPE::SoldierTakeDamage( INT8 bHeight, INT16 sLifeDeduct, INT16 sBr sTestOne = EffectiveStrength( this, FALSE ); sTestTwo = 2 * max(sLifeDeduct, (sBreathLoss / 100)); - if (this->ubAttackerID != NOBODY && MercPtrs[this->ubAttackerID]->ubBodyType == BLOODCAT) + if (this->ubAttackerID != NOBODY && this->ubAttackerID->ubBodyType == BLOODCAT) { // bloodcat boost, let them make people drop items more sTestTwo += 20; diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index 70a032d7..c092c3c2 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -1187,8 +1187,8 @@ public: UINT32 uiAIDelay; INT16 sReloadDelay; - UINT16 ubAttackerID; UINT16 ubPreviousAttackerID; + SoldierID ubAttackerID; INT32 sInsertionGridNo;