stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src/ai ai_force.c


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src/ai ai_force.c
Date: 23 Dec 2003 11:17:23 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       03/12/23 11:17:23

Modified files:
        src/ai         : ai_force.c 

Log message:
        Clean up

Patches:
Index: stratagus/src/ai/ai_force.c
diff -u stratagus/src/ai/ai_force.c:1.45 stratagus/src/ai/ai_force.c:1.46
--- stratagus/src/ai/ai_force.c:1.45    Sat Dec 20 16:02:00 2003
+++ stratagus/src/ai/ai_force.c Tue Dec 23 11:17:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_force.c,v 1.45 2003/12/20 05:02:00 jsalmon3 Exp $
+//      $Id: ai_force.c,v 1.46 2003/12/23 00:17:22 jsalmon3 Exp $
 
 //@{
 
@@ -65,7 +65,7 @@
 {
        int i;
 
-       for (i = 0; i <= UnitTypeMax; i++) {
+       for (i = 0; i <= UnitTypeMax; ++i) {
                UnitTypeEquivs[i] = i;
        }
 }
@@ -136,7 +136,7 @@
 **  @param unittype     The unittype to find equivalence for
 **  @param usabelTypes  int array which will hold the result. (Size 
UnitTypeMax+1)
 **
-**  @return          the number of unittype found
+**  @return             the number of unittype found
 */
 global int AiFindAvailableUnitTypeEquiv(const UnitType* unittype, int* 
usableTypes)
 {
@@ -156,9 +156,9 @@
                if (!CheckDependByIdent(AiPlayer->Player, 
UnitTypes[usableTypes[i]]->Ident)) {
                        // Not available, remove it
                        usableTypes[i] = usableTypes[usableTypesCount - 1];
-                       usableTypesCount--;
+                       --usableTypesCount;
                } else {
-                       i++;
+                       ++i;
                }
        }
 
@@ -166,9 +166,9 @@
        playerid = AiPlayer->Player->Player;
 
        // We won't have usableTypesCount>4, so simple sort should do it
-       for (i = 0; i < usableTypesCount-1; i++) {
+       for (i = 0; i < usableTypesCount - 1; ++i) {
                bestlevel = UnitTypes[usableTypes[i]]->Priority;
-               for (j = i + 1; j < usableTypesCount; j++) {
+               for (j = i + 1; j < usableTypesCount; ++j) {
                        curlevel = UnitTypes[usableTypes[j]]->Priority;
 
                        if (curlevel > bestlevel) {
@@ -182,7 +182,7 @@
                }
        }
        DebugLevel3Fn("prefered order for %s is " _C_ unittype->Ident);
-       for (i = 0; i < usableTypesCount; i++) {
+       for (i = 0; i < usableTypesCount; ++i) {
                DebugLevel3(" %s" _C_ UnitTypes[usableTypes[i]]->Ident);
        }
        DebugLevel3("\n");
@@ -203,15 +203,15 @@
        int type;
        AiUnit* aiunit;
 
-       memset(countByType, 0, sizeof (int) * (UnitTypeMax + 1));
+       memset(countByType, 0, sizeof(int) * (UnitTypeMax + 1));
 
        aiunit = AiPlayer->Force[force].Units;
        while (aiunit) {
-               if ((!aiunit->Unit->Destroyed) &&
-                       (aiunit->Unit->HP) && (aiunit->Unit->Orders[0].Action 
!= UnitActionDie)) {
+               if (!aiunit->Unit->Destroyed && aiunit->Unit->HP &&
+                               aiunit->Unit->Orders[0].Action != 
UnitActionDie) {
                        type = UnitTypeEquivs[aiunit->Unit->Type->Type];
 
-                       DebugCheck((type < 0) || (type > UnitTypeMax));
+                       DebugCheck(type < 0 || type > UnitTypeMax);
                        countByType[type]++;
                }
                aiunit = aiunit->Next;
@@ -235,7 +235,7 @@
        missing = 0;
        aitype = AiPlayer->Force[force].UnitTypes;
        while (aitype) {
-               type=UnitTypeEquivs[aitype->Type->Type];
+               type = UnitTypeEquivs[aitype->Type->Type];
                countByType[type] -= aitype->Want;
                if (countByType[type] < 0) {
                        missing -= countByType[type];
@@ -249,7 +249,7 @@
 /**
 **  Complete dst force with units from src force.
 **
-**  @todo FIXME : should check that unit can reach dst force's hotspot.
+**  @todo FIXME: should check that unit can reach dst force's hotspot.
 **
 **  @param src  the force from which units are taken
 **  @param dst  the force into which units go
@@ -289,7 +289,7 @@
                        AiPlayer->Force[dst].Units = aiunit;
 
                        counter[type]++;
-                       missing--;
+                       --missing;
 
                        if (!missing) {
                                AiPlayer->Force[dst].Completed = 1;
@@ -305,7 +305,7 @@
 /**
 **  Complete dst force with overflow units in src force.
 **
-**  @todo FIXME : should check that unit can reach dst force's hotspot.
+**  @todo FIXME: should check that unit can reach dst force's hotspot.
 **
 **  @param src  the force from which units are taken
 **  @param dst  the force into which units go
@@ -387,7 +387,8 @@
                        *prev = aiunit->Next;
                        free(aiunit);
                        continue;
-               } else if (!aiunit->Unit->HP || aiunit->Unit->Orders[0].Action 
== UnitActionDie) {
+               } else if (!aiunit->Unit->HP ||
+                               aiunit->Unit->Orders[0].Action == 
UnitActionDie) {
                        RefsDecrease(aiunit->Unit);
                        *prev = aiunit->Next;
                        free(aiunit);
@@ -490,7 +491,7 @@
 **  @param force  Force to be checked.
 **  @param type   Type to check.
 **
-**  @return       Returns true if it fits & update completed flag, false 
otherwise.
+**  @return       True if it fits & update completed flag, false otherwise.
 */
 local int AiCheckBelongsToForce(int force, const UnitType* type)
 {
@@ -514,7 +515,7 @@
        if (counter[realtype] < 0) {
                // Ok we will put this unit in this force !
                // Just one missing ?
-               if ((counter[realtype] == -1) && (missing == 1)) {
+               if (counter[realtype] == -1 && missing == 1) {
                        AiPlayer->Force[force].Completed = 1;
                }
                return 1;
@@ -568,7 +569,7 @@
 global void AiForceComplete(int force)
 {
        int j;
-       int overflowonly;;
+       int overflowonly;
 
        for (j = 0; j < AI_MAX_FORCES; ++j) {
                // Don't complete with self ...
@@ -583,13 +584,12 @@
 
                // Honor "populate from attack"
                if ((AiPlayer->Force[force].PopulateMode == 
AiForcePopulateFromAttack) &&
-                       (!AiPlayer->Force[j].Role == AiForceRoleAttack)) {
-
+                               (!AiPlayer->Force[j].Role == 
AiForceRoleAttack)) {
                        // Use overflow from force 0...
                        if (j == 0) {
                                overflowonly = 1;
                        } else {
-                                       continue;
+                               continue;
                        }
                } else {
                        overflowonly = 0;
@@ -612,9 +612,9 @@
 **  Enrole a unit in the specific force.
 **  Does not take equivalence into account
 **
-**  @todo FIXME : currently iterate all units (slow)
-**        FIXME : should take units which are closer to the hotspot.
-**        FIXME : should ensure that units can move to the hotspot.
+**  @todo FIXME: currently iterate all units (slow)
+**        FIXME: should take units which are closer to the hotspot.
+**        FIXME: should ensure that units can move to the hotspot.
 **
 **  @param force  the force to put units on
 **  @param ut     the searched unittype
@@ -640,7 +640,7 @@
                }
                // Don't populate attack force with defend reserve.
                if ((AiPlayer->Force[src_force].Role == AiForceRoleDefend) &&
-                       (AiPlayer->Force[force].PopulateMode == 
AiForcePopulateFromAttack)) {
+                               (AiPlayer->Force[force].PopulateMode == 
AiForcePopulateFromAttack)) {
                        continue;
                }
 
@@ -668,8 +668,10 @@
 }
 
 /**
-**  Make sure that current force requirement are superior to actual assigned 
unit count
+**  Make sure that current force requirement are superior to actual assigned
+**  unit count
 **
+**  @param force  FIXME: docu
 */
 local void AiFinalizeForce(int force)
 {
@@ -738,7 +740,7 @@
                for (id = 0; id < unittypescount; id++) {
                        // Search in equivalents
                        equivalentscount = 
AiFindAvailableUnitTypeEquiv(UnitTypes[unittypes[id]], equivalents);
-                       for (equivalentid = 0; equivalentid < equivalentscount; 
equivalentid++) {
+                       for (equivalentid = 0; equivalentid < equivalentscount; 
++equivalentid) {
                                ut = UnitTypes[equivalents[equivalentid]];
                                if (!(ut->CanTarget & (1 << maxPower))) {
                                        continue;
@@ -757,7 +759,7 @@
                                        continue;
                                }
 
-                               // FIXME : don't always use the right unittype 
here...
+                               // FIXME: don't always use the right unittype 
here...
                                curpower[maxPower] -= (maxadd - lefttoadd) * 
unittypeforce;
 
                                forceUpdated = 1;
@@ -853,7 +855,8 @@
 }
 
 /**
-**  Try to group units in a force. Units are grouped arround the closest units 
of the hotspot.
+**  Try to group units in a force. Units are grouped around the closest
+**  units of the hotspot.
 **
 **  @param force  the force to send home.
 */
@@ -1011,7 +1014,7 @@
 /**
 **  Entry point of force manager, perodic called.
 **
-** @todo FIXME : is this really needed anymore
+** @todo FIXME: is this really needed anymore
 */
 global void AiForceManager(void)
 {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]