From 30af74e59dc83b150ac0b5e10888af4d22023042 Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Fri, 15 Aug 2008 21:48:58 +0000 Subject: [PATCH] Mostly cosmetic cleanup of action update code git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5823 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/action.c | 64 ++++++++++++---------------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/src/action.c b/src/action.c index 70e18cbce..c8e828e92 100644 --- a/src/action.c +++ b/src/action.c @@ -800,8 +800,7 @@ static void actionUpdateVtolAttack( DROID *psDroid ) if (psDroid->asWeaps[i].nStat != 0) { psWeapStats[i] = asWeaponStats + psDroid->asWeaps[i].nStat; - ASSERT( psWeapStats != NULL, - "actionUpdateVtolAttack: invalid weapon stats pointer" ); + ASSERT(psWeapStats != NULL, "invalid weapon stats pointer"); break; } } @@ -811,8 +810,7 @@ static void actionUpdateVtolAttack( DROID *psDroid ) if (psDroid->asWeaps[0].nStat > 0) { psWeapStats[0] = asWeaponStats + psDroid->asWeaps[0].nStat; - ASSERT( psWeapStats != NULL, - "actionUpdateVtolAttack: invalid weapon stats pointer" ); + ASSERT(psWeapStats != NULL, "invalid weapon stats pointer"); } } @@ -1019,13 +1017,10 @@ void actionUpdateDroid(DROID *psDroid) CHECK_DROID(psDroid); psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat; - ASSERT( psPropStats != NULL, - "actionUpdateUnit: invalid propulsion stats pointer" ); + ASSERT(psPropStats != NULL, "invalid propulsion stats pointer"); /* check whether turret inverted for actionTargetTurret */ - //if ( psDroid->droidType != DROID_CYBORG && - if ( !cyborgDroid(psDroid) && - psPropStats->propulsionType == PROPULSION_TYPE_LIFT ) + if (!cyborgDroid(psDroid) && psPropStats->propulsionType == PROPULSION_TYPE_LIFT) { bInvert = true; } @@ -1035,51 +1030,27 @@ void actionUpdateDroid(DROID *psDroid) } // clear the target if it has died - // weapon droid - if (psDroid->numWeaps > 0) + for (i = 0; i < DROID_MAXWEAPS; i++) { - // clear targets - for (i = 0;i < psDroid->numWeaps;i++) + if (psDroid->psActionTarget[i] && psDroid->psActionTarget[i]->died) { - if (psDroid->psActionTarget[i] && psDroid->psActionTarget[i]->died) + setDroidActionTarget(psDroid, NULL, i); + if (i == 0) { - setDroidActionTarget(psDroid, NULL, i); - if (i == 0) + if ( (psDroid->action != DACTION_MOVEFIRE) && + (psDroid->action != DACTION_TRANSPORTIN) && + (psDroid->action != DACTION_TRANSPORTOUT) ) { - if ( (psDroid->action != DACTION_MOVEFIRE) && - (psDroid->action != DACTION_TRANSPORTIN) && - (psDroid->action != DACTION_TRANSPORTOUT) ) + psDroid->action = DACTION_NONE; + //if Vtol - return to rearm pad + if (isVtolDroid(psDroid)) { - psDroid->action = DACTION_NONE; - //if Vtol - return to rearm pad - if (isVtolDroid(psDroid)) - { - moveToRearm(psDroid); - } + moveToRearm(psDroid); } } } } } - //utility droid - else - { - if (psDroid->psActionTarget[0] && psDroid->psActionTarget[0]->died) - { - setDroidActionTarget(psDroid, NULL, 0); - if ( (psDroid->action != DACTION_MOVEFIRE) && - (psDroid->action != DACTION_TRANSPORTIN) && - (psDroid->action != DACTION_TRANSPORTOUT) ) - { - psDroid->action = DACTION_NONE; - //if Vtol - return to rearm pad - if (isVtolDroid(psDroid)) - { - moveToRearm(psDroid); - } - } - } - } //if the droid has been attacked by an EMP weapon, it is temporarily disabled if (psDroid->lastHitWeapon == WSC_EMP) @@ -1099,8 +1070,6 @@ void actionUpdateDroid(DROID *psDroid) } } - //if (psDroid->numWeaps == 0) - /* Watermelon:if I am a multi-turret droid */ if (psDroid->numWeaps > 1) { for(i = 0;i < psDroid->numWeaps;i++) @@ -1118,8 +1087,6 @@ void actionUpdateDroid(DROID *psDroid) psTarget = psDroid->psTarget; - //Watermelon:safety check - //if (psDroid->numWeaps > 0) if (psDroid->asWeaps[0].nStat > 0) { psWeapStats = asWeaponStats + psDroid->asWeaps[0].nStat; @@ -1589,7 +1556,6 @@ void actionUpdateDroid(DROID *psDroid) } } // if the vtol is far enough away head for the target again -// else if (rangeSq > (VTOL_ATTACK_RETURNDIST*VTOL_ATTACK_RETURNDIST)) else if (rangeSq > (SDWORD)(psWeapStats->longRange*psWeapStats->longRange)) { // don't do another attack run if already heading for the target