stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src/action action_board.c action_buil...


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src/action action_board.c action_buil...
Date: Fri, 03 Oct 2003 16:31:24 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/10/03 16:31:24

Modified files:
        src/action     : action_board.c action_build.c action_demolish.c 
                         action_die.c action_follow.c action_move.c 
                         action_patrol.c 

Log message:
        Cleanup

Patches:
Index: stratagus/src/action/action_board.c
diff -u stratagus/src/action/action_board.c:1.41 
stratagus/src/action/action_board.c:1.42
--- stratagus/src/action/action_board.c:1.41    Sun Sep 14 00:45:52 2003
+++ stratagus/src/action/action_board.c Fri Oct  3 16:31:24 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_board.c,v 1.41 2003/09/14 04:45:52 mr-russ Exp $
+//     $Id: action_board.c,v 1.42 2003/10/03 20:31:24 jsalmon3 Exp $
 
 //@{
 
@@ -59,19 +59,21 @@
 */
 local int MoveToTransporter(Unit* unit)
 {
-    int i,x,y;
+    int i;
+    int x;
+    int y;
 
-    x=unit->X;
-    y=unit->Y;
-    i=DoActionMove(unit);
+    x = unit->X;
+    y = unit->Y;
+    i = DoActionMove(unit);
     // We have to reset a lot, or else they will circle each other and stuff.
-    if (x!=unit->X||y!=unit->Y) {
-       unit->Orders[0].RangeX=1;
-       unit->Orders[0].RangeY=1;
+    if (x != unit->X || y != unit->Y) {
+       unit->Orders[0].RangeX = 1;
+       unit->Orders[0].RangeY = 1;
         NewResetPath(unit);
     }
     // New code has this as default.
-    DebugCheck( unit->Orders[0].Action!=UnitActionBoard );
+    DebugCheck(unit->Orders[0].Action != UnitActionBoard);
     return i;
 }
 
@@ -85,36 +87,36 @@
 {
     Unit* trans;
 
-    unit->Wait=6;
-    unit->Reset=1;
+    unit->Wait = 6;
+    unit->Reset = 1;
 
-    trans=unit->Orders[0].Goal;
+    trans = unit->Orders[0].Goal;
 
-    if( !trans || !trans->Type->Transporter ) {
+    if (!trans || !trans->Type->Transporter) {
        // FIXME: destination destroyed??
         DebugLevel2Fn("TRANSPORTER NOT REACHED %d,%d\n" _C_ unit->X _C_ 
unit->Y);
         return 0;
     }
 
-    if( trans->Destroyed ) {
+    if (trans->Destroyed) {
        DebugLevel0Fn("Destroyed transporter\n");
-       RefsDebugCheck( !trans->Refs );
-       if( !--trans->Refs ) {
+       RefsDebugCheck(!trans->Refs);
+       if (!--trans->Refs) {
            ReleaseUnit(trans);
        }
-       unit->Orders[0].Goal=NoUnitP;
+       unit->Orders[0].Goal = NoUnitP;
        return 0;
-    } else if( trans->Removed ||
-           !trans->HP || trans->Orders[0].Action==UnitActionDie ) {
+    } else if (trans->Removed ||
+           !trans->HP || trans->Orders[0].Action == UnitActionDie) {
        DebugLevel0Fn("Unusable transporter\n");
-       RefsDebugCheck( !trans->Refs );
+       RefsDebugCheck(!trans->Refs);
        --trans->Refs;
-       RefsDebugCheck( !trans->Refs );
-       unit->Orders[0].Goal=NoUnitP;
+       RefsDebugCheck(!trans->Refs);
+       unit->Orders[0].Goal = NoUnitP;
        return 0;
     }
 
-    if( MapDistanceBetweenUnits(unit,trans)==1 ) {
+    if (MapDistanceBetweenUnits(unit,trans) == 1) {
        DebugLevel3Fn("Enter transporter\n");
        return 1;
     }
@@ -129,11 +131,11 @@
     //  is not there. The unit searches with a big range, so it thinks
     //  it's there. This is why we reset the search. The transporter
     //  should be a lot closer now, so it's not as bad as it seems.
-    unit->SubAction=0;
-    unit->Orders[0].RangeX=1;
-    unit->Orders[0].RangeY=1;
+    unit->SubAction = 0;
+    unit->Orders[0].RangeX = 1;
+    unit->Orders[0].RangeY = 1;
     //Uhh wait a bit.
-    unit->Wait=10;
+    unit->Wait = 10;
 
     return 0;
 }
@@ -147,47 +149,47 @@
 {
     Unit* transporter;
 
-    unit->Wait=1;
-    unit->Orders[0].Action=UnitActionStill;
-    unit->SubAction=0;
+    unit->Wait = 1;
+    unit->Orders[0].Action = UnitActionStill;
+    unit->SubAction = 0;
 
-    transporter=unit->Orders[0].Goal;
-    if( transporter->Destroyed ) {
+    transporter = unit->Orders[0].Goal;
+    if (transporter->Destroyed) {
        DebugLevel0Fn("Destroyed transporter\n");
        RefsDebugCheck( !transporter->Refs );
-       if( !--transporter->Refs ) {
+       if (!--transporter->Refs) {
            ReleaseUnit(transporter);
        }
-       unit->Orders[0].Goal=NoUnitP;
+       unit->Orders[0].Goal = NoUnitP;
        return;
-    } else if( transporter->Removed ||
-           !transporter->HP || transporter->Orders[0].Action==UnitActionDie ) {
+    } else if (transporter->Removed ||
+           !transporter->HP || transporter->Orders[0].Action == UnitActionDie) 
{
        DebugLevel0Fn("Unuseable transporter\n");
-       RefsDebugCheck( !transporter->Refs );
+       RefsDebugCheck(!transporter->Refs);
        --transporter->Refs;
-       RefsDebugCheck( !transporter->Refs );
-       unit->Orders[0].Goal=NoUnitP;
+       RefsDebugCheck(!transporter->Refs);
+       unit->Orders[0].Goal = NoUnitP;
        return;
     }
 
-    RefsDebugCheck( !transporter->Refs );
+    RefsDebugCheck(!transporter->Refs);
     --transporter->Refs;
-    RefsDebugCheck( !transporter->Refs );
-    unit->Orders[0].Goal=NoUnitP;
+    RefsDebugCheck(!transporter->Refs);
+    unit->Orders[0].Goal = NoUnitP;
 
     //
     //         Place the unit inside the transporter.
     //
    
-    if (transporter->InsideCount<transporter->Type->MaxOnBoard) {
-       RemoveUnit(unit,transporter);
+    if (transporter->InsideCount < transporter->Type->MaxOnBoard) {
+       RemoveUnit(unit, transporter);
        //Don't make anything funny after going out of the transporter.
        // FIXME: This is probably wrong, but it works for me (n0b0dy)
-       unit->OrderCount=1;
-       unit->Orders[0].Action=UnitActionStill;
-       if( IsOnlySelected(transporter) ) {
+       unit->OrderCount = 1;
+       unit->Orders[0].Action = UnitActionStill;
+       if (IsOnlySelected(transporter)) {
            SelectedUnitChanged();
-           MustRedraw|=RedrawInfoPanel;
+           MustRedraw |= RedrawInfoPanel;
        }
        return;
     }
@@ -207,18 +209,18 @@
     int i;
     Unit* goal;
 
-    DebugLevel3Fn("%p(%d) SubAction %d\n"
-           _C_ unit _C_ UnitNumber(unit) _C_ unit->SubAction);
+    DebugLevel3Fn("%p(%d) SubAction %d\n" _C_
+       unit _C_ UnitNumber(unit) _C_ unit->SubAction);
 
-    switch( unit->SubAction ) {
+    switch (unit->SubAction) {
        //
        //      Wait for transporter
        //
        case 201:
            // FIXME: show still animations
            DebugLevel3Fn("Waiting\n");
-           if( WaitForTransporter(unit) ) {
-               unit->SubAction=202;
+           if (WaitForTransporter(unit)) {
+               unit->SubAction = 202;
            }
            break;
        //
@@ -231,40 +233,40 @@
        //      Move to transporter
        //
        case 0:
-               NewResetPath(unit);
-               unit->SubAction=1;
-               // FALL THROUGH
+           NewResetPath(unit);
+           unit->SubAction = 1;
+           // FALL THROUGH
         default:
-           if( unit->SubAction<=200 ) {
+           if (unit->SubAction <= 200) {
                // FIXME: if near transporter wait for enter
-               if( (i=MoveToTransporter(unit)) ) {
-                   if( i==PF_UNREACHABLE ) {
-                       if( ++unit->SubAction==200 ) {
-                           unit->Orders[0].Action=UnitActionStill;
-                           if( (goal=unit->Orders[0].Goal) ) {
+               if ((i = MoveToTransporter(unit))) {
+                   if (i == PF_UNREACHABLE) {
+                       if (++unit->SubAction == 200) {
+                           unit->Orders[0].Action = UnitActionStill;
+                           if ((goal = unit->Orders[0].Goal)) {
                                RefsDebugCheck(!goal->Refs);
-                               if( !--goal->Refs ) {
+                               if (!--goal->Refs) {
                                    RefsDebugCheck(!goal->Destroyed);
-                                   if( goal->Destroyed ) {
+                                   if (goal->Destroyed) {
                                        ReleaseUnit(goal);
                                    }
                                }
-                               unit->Orders[0].Goal=NoUnitP;
+                               unit->Orders[0].Goal = NoUnitP;
                            }
-                           unit->SubAction=0;
+                           unit->SubAction = 0;
                        } else {
                             //
                             // Try with a bigger range.
                             //
-                            if( unit->Orders[0].RangeX <= TheMap.Width
-                               || unit->Orders[0].RangeX <= TheMap.Height) {
+                            if (unit->Orders[0].RangeX <= TheMap.Width ||
+                                   unit->Orders[0].RangeX <= TheMap.Height) {
                                unit->Orders[0].RangeX++;
                                unit->Orders[0].RangeY++;
                                 unit->SubAction--;
                             }
                        }
-                   } else if( i==PF_REACHED ) {
-                       unit->SubAction=201;
+                   } else if (i == PF_REACHED) {
+                       unit->SubAction = 201;
                    }
                }
            }
Index: stratagus/src/action/action_build.c
diff -u stratagus/src/action/action_build.c:1.96 
stratagus/src/action/action_build.c:1.97
--- stratagus/src/action/action_build.c:1.96    Fri Sep 12 13:44:36 2003
+++ stratagus/src/action/action_build.c Fri Oct  3 16:31:24 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_build.c,v 1.96 2003/09/12 17:44:36 n0body Exp $
+//     $Id: action_build.c,v 1.97 2003/10/03 20:31:24 jsalmon3 Exp $
 
 //@{
 
@@ -63,19 +63,19 @@
     ConstructionFrame* tmp;
     int percent;
 
-//    
percent=unit->Data.Builded.Progress*100/(unit->Type->Stats->Costs[TimeCost]*600);
-    percent=unit->Data.Builded.Progress/(unit->Type->Stats->Costs[TimeCost]*6);
-    cframe=tmp=unit->Type->Construction->Frames;
-    while( tmp ) {
-       if( percent<tmp->Percent ) {
+//    percent = unit->Data.Builded.Progress * 100 / 
(unit->Type->Stats->Costs[TimeCost] * 600);
+    percent = unit->Data.Builded.Progress / 
(unit->Type->Stats->Costs[TimeCost] * 6);
+    cframe = tmp = unit->Type->Construction->Frames;
+    while (tmp) {
+       if (percent < tmp->Percent) {
            break;
        }
-       cframe=tmp;
-       tmp=tmp->Next;
+       cframe = tmp;
+       tmp = tmp->Next;
     }
-    if( cframe!=unit->Data.Builded.Frame ) {
-       unit->Data.Builded.Frame=cframe;
-       unit->Frame=cframe->Frame;
+    if (cframe != unit->Data.Builded.Frame) {
+       unit->Data.Builded.Frame = cframe;
+       unit->Frame = cframe->Frame;
        CheckUnitToBeDrawn(unit);
        UnitMarkSeen(unit);
     }
@@ -95,45 +95,45 @@
     const UnitStats* stats;
     Unit* build;
 
-    if( !unit->SubAction ) {           // first entry
-       unit->SubAction=1;
+    if (!unit->SubAction) {            // first entry
+       unit->SubAction = 1;
        NewResetPath(unit);
     }
 
-    type=unit->Orders[0].Type;
+    type = unit->Orders[0].Type;
 
     // Create the building to find a valid path to any part of it.
     // Only create if we didn't already.
-    if ( unit->Orders[0].Goal == NoUnitP ) {
-       unit->Orders[0].Goal=MakeUnit(type,NULL);
-       unit->Orders[0].Goal->X=unit->Orders[0].X;
-       unit->Orders[0].Goal->Y=unit->Orders[0].Y;
+    if (unit->Orders[0].Goal == NoUnitP) {
+       unit->Orders[0].Goal = MakeUnit(type, NULL);
+       unit->Orders[0].Goal->X = unit->Orders[0].X;
+       unit->Orders[0].Goal->Y = unit->Orders[0].Y;
     }
 
-    switch( DoActionMove(unit) ) {     // reached end-point?
+    switch (DoActionMove(unit)) {      // reached end-point?
        case PF_UNREACHABLE:
            //
            //  Some tries to reach the goal
            //
-           if( unit->SubAction++<10 ) {
+           if (unit->SubAction++ < 10) {
                //      To keep the load low, retry each 1/4 second.
                // NOTE: we can already inform the AI about this problem?
-               unit->Wait=CYCLES_PER_SECOND/4+unit->SubAction;
+               unit->Wait = CYCLES_PER_SECOND / 4 + unit->SubAction;
                return;
            }
 
-           NotifyPlayer(unit->Player,NotifyYellow,unit->X,unit->Y,
+           NotifyPlayer(unit->Player, NotifyYellow, unit->X, unit->Y,
                "You cannot reach building place");
-           if( unit->Player->Ai ) {
+           if (unit->Player->Ai) {
                AiCanNotReach(unit,type);
            }
 
-           unit->Orders[0].Action=UnitActionStill;
+           unit->Orders[0].Action = UnitActionStill;
            // Release Temporary Building
             UnitClearOrders(unit->Orders[0].Goal);
             ReleaseUnit(unit->Orders[0].Goal);
-           unit->SubAction=0;
-           if( unit->Selected ) {      // update display for new action
+           unit->SubAction = 0;
+           if (unit->Selected) {       // update display for new action
                SelectedUnitChanged();
            }
            return;
@@ -146,36 +146,36 @@
            return;
     }
 
-    x=unit->Orders[0].X;
-    y=unit->Orders[0].Y;
+    x = unit->Orders[0].X;
+    y = unit->Orders[0].Y;
 
     //
     // Check if the building could be build there.
     //
-    if( !CanBuildUnitType(unit,type,x,y) ) {
+    if (!CanBuildUnitType(unit, type, x, y)) {
        //
        //      Some tries to build the building.
        //
-       if( unit->SubAction++<10 ) {
+       if (unit->SubAction++ < 10) {
            //  To keep the load low, retry each 10 cycles
            // NOTE: we can already inform the AI about this problem?
-           unit->Wait=10;
+           unit->Wait = 10;
            return;
        }
 
-       NotifyPlayer(unit->Player,NotifyYellow,unit->X,unit->Y,
-               "You cannot build %s here",type->Name);
-       if( unit->Player->Ai ) {
-           AiCanNotBuild(unit,type);
+       NotifyPlayer(unit->Player, NotifyYellow, unit->X, unit->Y,
+           "You cannot build %s here",type->Name);
+       if (unit->Player->Ai) {
+           AiCanNotBuild(unit, type);
        }
 
-       unit->Orders[0].Action=UnitActionStill;
+       unit->Orders[0].Action = UnitActionStill;
        // Release Temporary Building
         UnitClearOrders(unit->Orders[0].Goal);
         ReleaseUnit(unit->Orders[0].Goal);
-       unit->Orders[0].Goal=0;
-       unit->SubAction=0;
-       if( unit->Selected ) {  // update display for new action
+       unit->Orders[0].Goal = 0;
+       unit->SubAction = 0;
+       if (unit->Selected) {   // update display for new action
            SelectedUnitChanged();
        }
 
@@ -185,29 +185,29 @@
     //
     // FIXME: got bug report about unit->Type==NULL in building
     //
-    DebugCheck( !unit->Type || !unit->HP );
+    DebugCheck(!unit->Type || !unit->HP);
 
-    if( !unit->Type || !unit->HP ) {
+    if (!unit->Type || !unit->HP) {
        return;
     }
 
     //
     // Check if enough resources for the building.
     //
-    if( PlayerCheckUnitType(unit->Player,type) ) {
+    if (PlayerCheckUnitType(unit->Player, type)) {
        // FIXME: Better tell what is missing?
-       NotifyPlayer(unit->Player,NotifyYellow,unit->X,unit->Y,
-               "Not enough resources to build %s",type->Name);
-       if( unit->Player->Ai ) {
-           AiCanNotBuild(unit,type);
+       NotifyPlayer(unit->Player, NotifyYellow, unit->X, unit->Y,
+           "Not enough resources to build %s", type->Name);
+       if (unit->Player->Ai) {
+           AiCanNotBuild(unit, type);
        }
 
-       unit->Orders[0].Action=UnitActionStill;
+       unit->Orders[0].Action = UnitActionStill;
        // Release Temporary Building
         UnitClearOrders(unit->Orders[0].Goal);
         ReleaseUnit(unit->Orders[0].Goal);
-       unit->SubAction=0;
-       if( unit->Selected ) {  // update display for new action
+       unit->SubAction = 0;
+       if (unit->Selected) {   // update display for new action
            SelectedUnitChanged();
        }
        return;
@@ -216,42 +216,42 @@
     //
     // Check if hiting any limits for the building.
     //
-    if( !PlayerCheckLimits(unit->Player,type) ) {
-       NotifyPlayer(unit->Player,NotifyYellow,unit->X,unit->Y,
-               "Can't build more units %s",type->Name);
-       if( unit->Player->Ai ) {
-           AiCanNotBuild(unit,type);
+    if (!PlayerCheckLimits(unit->Player, type)) {
+       NotifyPlayer(unit->Player, NotifyYellow, unit->X, unit->Y,
+           "Can't build more units %s", type->Name);
+       if (unit->Player->Ai) {
+           AiCanNotBuild(unit, type);
        }
 
-       unit->Orders[0].Action=UnitActionStill;
+       unit->Orders[0].Action = UnitActionStill;
        // Release Temporary Building
         UnitClearOrders(unit->Orders[0].Goal);
         ReleaseUnit(unit->Orders[0].Goal);
-       unit->SubAction=0;
-       if( unit->Selected ) {  // update display for new action
+       unit->SubAction = 0;
+       if (unit->Selected) {   // update display for new action
            SelectedUnitChanged();
        }
        return;
     }
-    PlayerSubUnitType(unit->Player,type);
+    PlayerSubUnitType(unit->Player, type);
 
     
-    build=unit->Orders[0].Goal;
+    build = unit->Orders[0].Goal;
     unit->Orders[0].Goal = NoUnitP;
-    AssignUnitToPlayer(build,unit->Player);
-    build->Constructed=1;
-    build->CurrentSightRange=0;
-    PlaceUnit(build,x,y);
-    if( !type->BuilderOutside ) {
-       build->CurrentSightRange=1;
+    AssignUnitToPlayer(build, unit->Player);
+    build->Constructed = 1;
+    build->CurrentSightRange = 0;
+    PlaceUnit(build, x, y);
+    if (!type->BuilderOutside) {
+       build->CurrentSightRange = 1;
     }
 
     // Building on top of something, must remove what is beneath it
-    if( type->MustBuildOnTop ) {
+    if (type->MustBuildOnTop) {
        Unit* temp;
-       if( (temp=UnitTypeOnMap(x,y,type->MustBuildOnTop)) ) {
-           build->Value=temp->Value;   // We capture the value of what is 
beneath.
-           RemoveUnit(temp,NULL);      // Destroy building beneath
+       if ((temp = UnitTypeOnMap(x, y, type->MustBuildOnTop))) {
+           build->Value = temp->Value;   // We capture the value of what is 
beneath.
+           RemoveUnit(temp, NULL);     // Destroy building beneath
            UnitLost(temp);
            UnitClearOrders(temp);
            ReleaseUnit(temp);
@@ -263,43 +263,43 @@
 /* Done by PlaceUnit now
 #ifdef HIERARCHIC_PATHFINDER
     PfHierMapChangedCallback (build->X, build->Y,
-                   build->X + build->Type->TileWidth - 1,
-                   build->Y + build->Type->TileHeight - 1);
+       build->X + build->Type->TileWidth - 1,
+       build->Y + build->Type->TileHeight - 1);
 #endif
 */
 
     // HACK: the building is not ready yet
     build->Player->UnitTypesCount[type->Type]--;
 
-    stats=build->Stats;
+    stats = build->Stats;
 
-    build->Wait=1;
+    build->Wait = 1;
     //  Make sure the bulding doesn't cancel itself out right away.
-    build->Data.Builded.Progress=100;
-    build->Orders[0].Action=UnitActionBuilded;
-    build->HP=1;
+    build->Data.Builded.Progress = 100;
+    build->Orders[0].Action = UnitActionBuilded;
+    build->HP = 1;
     UpdateConstructionFrame(build);
 
     // We need somebody to work on it.
-    build->HP=1;
+    build->HP = 1;
     if (!type->BuilderOutside) {
        //  Place the builder inside the building
-       build->Data.Builded.Worker=unit;
-       RemoveUnit(unit,build);
-       build->CurrentSightRange=0;
-       unit->X=x;
-       unit->Y=y;
-       unit->Orders[0].Action=UnitActionStill;
-       unit->SubAction=0;
+       build->Data.Builded.Worker = unit;
+       RemoveUnit(unit, build);
+       build->CurrentSightRange = 0;
+       unit->X = x;
+       unit->Y = y;
+       unit->Orders[0].Action = UnitActionStill;
+       unit->SubAction = 0;
     } else {
        //  Make the builder repair the newly spawned building.
-       unit->Orders[0].Action=UnitActionRepair;
-       unit->Orders[0].Goal=build;
-       unit->Orders[0].X=unit->Orders[0].Y=-1;
-       unit->Orders[0].RangeX=unit->Orders[0].RangeY=unit->Type->RepairRange;
-       unit->SubAction=0;
-       unit->Wait=1;
-       RefsDebugCheck( !build->Refs );
+       unit->Orders[0].Action = UnitActionRepair;
+       unit->Orders[0].Goal = build;
+       unit->Orders[0].X = unit->Orders[0].Y = -1;
+       unit->Orders[0].RangeX = unit->Orders[0].RangeY = 
unit->Type->RepairRange;
+       unit->SubAction = 0;
+       unit->Wait = 1;
+       RefsDebugCheck(!build->Refs);
        build->Refs++;
        UnitMarkSeen(unit);
        //  Mark the new building seen.
@@ -321,46 +321,46 @@
     int n;
     int progress;
 
-    type=unit->Type;
+    type = unit->Type;
     
     //  n is the current damage taken by the unit.
-    n=(unit->Data.Builded.Progress*unit->Stats->HitPoints)/
-           (type->Stats->Costs[TimeCost]*600)-unit->HP;
+    n = (unit->Data.Builded.Progress * unit->Stats->HitPoints) /
+       (type->Stats->Costs[TimeCost] * 600) - unit->HP;
     //  This below is most often 0
     if (type->BuilderOutside) {
-       progress=unit->Type->AutoBuildRate;
+       progress = unit->Type->AutoBuildRate;
     } else {
-       progress=100;
-           // FIXME: implement this below:
-           //unit->Data.Builded.Worker->Type->BuilderSpeedFactor;
+       progress = 100;
+       // FIXME: implement this below:
+       //unit->Data.Builded.Worker->Type->BuilderSpeedFactor;
     }
     //  Building speeds increase or decrease.
-    progress*=SpeedBuild;
-    unit->Data.Builded.Progress+=progress;
+    progress *= SpeedBuild;
+    unit->Data.Builded.Progress += progress;
     //  Keep the same level of damage while increasing HP.
-    unit->HP=(unit->Data.Builded.Progress*unit->Stats->HitPoints)/
-           (type->Stats->Costs[TimeCost]*600)-n;
-    if (unit->HP>unit->Stats->HitPoints) {
-       unit->HP=unit->Stats->HitPoints;
+    unit->HP = (unit->Data.Builded.Progress * unit->Stats->HitPoints) /
+       (type->Stats->Costs[TimeCost] * 600) - n;
+    if (unit->HP > unit->Stats->HitPoints) {
+       unit->HP = unit->Stats->HitPoints;
     }
 
     //
     // Check if construction should be canceled...
     //
-    if( unit->Data.Builded.Cancel || unit->Data.Builded.Progress<0 ) {
+    if (unit->Data.Builded.Cancel || unit->Data.Builded.Progress < 0) {
        DebugLevel0Fn("%s canceled.\n" _C_ unit->Type->Name);
        // Drop out unit
-       if ((worker=unit->Data.Builded.Worker)) {
-           worker->Orders[0].Action=UnitActionStill;
-           unit->Data.Builded.Worker=NoUnitP;
-           worker->Reset=worker->Wait=1;
-           worker->SubAction=0;
-           DropOutOnSide(worker,LookingW,type->TileWidth,type->TileHeight);
+       if ((worker = unit->Data.Builded.Worker)) {
+           worker->Orders[0].Action = UnitActionStill;
+           unit->Data.Builded.Worker = NoUnitP;
+           worker->Reset = worker->Wait = 1;
+           worker->SubAction = 0;
+           DropOutOnSide(worker, LookingW, type->TileWidth, type->TileHeight);
        }
 
        // Player gets back 75% of the original cost for a building.
-       PlayerAddCostsFactor(unit->Player,unit->Stats->Costs,
-               CancelBuildingCostsFactor);
+       PlayerAddCostsFactor(unit->Player, unit->Stats->Costs,
+           CancelBuildingCostsFactor);
        // Cancel building
        LetUnitDie(unit);
        return;
@@ -369,79 +369,79 @@
     //
     // Check if building ready. Note we can both build and repair.
     //
-    if( unit->Data.Builded.Progress>=unit->Stats->Costs[TimeCost]*600 ||
-           unit->HP>=unit->Stats->HitPoints) {
+    if (unit->Data.Builded.Progress >= unit->Stats->Costs[TimeCost] * 600 ||
+           unit->HP >= unit->Stats->HitPoints) {
        DebugLevel0Fn("Building ready.\n");
-       if( unit->HP>unit->Stats->HitPoints ) {
-           unit->HP=unit->Stats->HitPoints;
+       if (unit->HP > unit->Stats->HitPoints) {
+           unit->HP = unit->Stats->HitPoints;
        }
-       unit->Orders[0].Action=UnitActionStill;
+       unit->Orders[0].Action = UnitActionStill;
        // HACK: the building is ready now
        unit->Player->UnitTypesCount[type->Type]++;
-       unit->Constructed=0;
-       unit->Frame=0;
-       unit->Reset=unit->Wait=1;
+       unit->Constructed = 0;
+       unit->Frame = 0;
+       unit->Reset = unit->Wait = 1;
 
-       if ((worker=unit->Data.Builded.Worker)) {
+       if ((worker = unit->Data.Builded.Worker)) {
            // Bye bye worker.
            if (type->BuilderLost) {
                // FIXME: enough?
                LetUnitDie(worker);
            // Drop out the worker.
            } else {
-               worker->Orders[0].Action=UnitActionStill;
-               worker->SubAction=0;
-               worker->Reset=worker->Wait=1;
-               DropOutOnSide(worker,LookingW,type->TileWidth,type->TileHeight);
+               worker->Orders[0].Action = UnitActionStill;
+               worker->SubAction = 0;
+               worker->Reset = worker->Wait = 1;
+               DropOutOnSide(worker, LookingW, type->TileWidth, 
type->TileHeight);
                //
                //      If we can harvest from the new building, do it.
                //
                if (worker->Type->ResInfo[type->GivesResource]) {
-                   CommandResource(worker,unit,0);
+                   CommandResource(worker, unit, 0);
                }
            }
        }
        
-       if( type->GivesResource ) {
+       if (type->GivesResource) {
            // Set to Zero as it's part of a union
-           unit->Data.Resource.Active=0;
+           unit->Data.Resource.Active = 0;
        }
 
-       NotifyPlayer(unit->Player,NotifyGreen,unit->X,unit->Y,
+       NotifyPlayer(unit->Player, NotifyGreen, unit->X, unit->Y,
            "New %s done", type->Name);
-       if( unit->Player==ThisPlayer ) {
+       if (unit->Player == ThisPlayer) {
            if (worker) {
-               PlayUnitSound(worker,VoiceWorkCompleted);
+               PlayUnitSound(worker, VoiceWorkCompleted);
            } else {
-               PlayUnitSound(unit,VoiceBuilding);
+               PlayUnitSound(unit, VoiceBuilding);
            }
        }
-       if( unit->Player->Ai ) {
-           AiWorkComplete(worker,unit);
+       if (unit->Player->Ai) {
+           AiWorkComplete(worker, unit);
        }
 
        // FIXME: Vladi: this is just a hack to test wall fixing,
        // FIXME:       also not sure if the right place...
        // FIXME: Johns: hardcoded unit-type wall / more races!
-       if ( unit->Type == UnitTypeOrcWall
-                   || unit->Type == UnitTypeHumanWall ) {
+       if (unit->Type == UnitTypeOrcWall ||
+               unit->Type == UnitTypeHumanWall) {
            MapSetWall(unit->X, unit->Y, unit->Type == UnitTypeHumanWall);
-           RemoveUnit(unit,NULL);
+           RemoveUnit(unit, NULL);
            UnitLost(unit);
            UnitClearOrders(unit);
            ReleaseUnit(unit);
            return;
         }
 
-       UpdateForNewUnit(unit,0);
+       UpdateForNewUnit(unit, 0);
 
-       if( IsOnlySelected(unit) ) {
+       if (IsOnlySelected(unit)) {
            SelectedUnitChanged();
-           MustRedraw|=RedrawInfoPanel;
-       } else if( unit->Player==ThisPlayer ) {
+           MustRedraw |= RedrawInfoPanel;
+       } else if (unit->Player == ThisPlayer) {
            SelectedUnitChanged();
        }
-       unit->CurrentSightRange=unit->Stats->SightRange;
+       unit->CurrentSightRange = unit->Stats->SightRange;
        MapMarkUnitSight(unit);
         CheckUnitToBeDrawn(unit);
        return;
@@ -449,9 +449,9 @@
 
     UpdateConstructionFrame(unit);
 
-    unit->Wait=1;
-    if( IsOnlySelected(unit) ) {
-        MustRedraw|=RedrawInfoPanel;
+    unit->Wait = 1;
+    if (IsOnlySelected(unit)) {
+        MustRedraw |= RedrawInfoPanel;
     }
 }
 
Index: stratagus/src/action/action_demolish.c
diff -u stratagus/src/action/action_demolish.c:1.37 
stratagus/src/action/action_demolish.c:1.38
--- stratagus/src/action/action_demolish.c:1.37 Sun Sep 14 00:45:52 2003
+++ stratagus/src/action/action_demolish.c      Fri Oct  3 16:31:24 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_demolish.c,v 1.37 2003/09/14 04:45:52 mr-russ Exp $
+//     $Id: action_demolish.c,v 1.38 2003/10/03 20:31:24 jsalmon3 Exp $
 
 //@{
 
@@ -60,34 +60,38 @@
     Unit* table[UnitMax];
     int i;
     int n;
-    int xmin, ymin, xmax, ymax;
-    int ix, iy;
+    int xmin;
+    int ymin;
+    int xmax;
+    int ymax;
+    int ix;
+    int iy;
     Unit* goal;
     int err;
 
     DebugLevel3Fn("Demolish %d\n" _C_ UnitNumber(unit));
 
-    switch( unit->SubAction ) {
+    switch (unit->SubAction) {
        //
        //      Move near to target.
        //
        case 0:                         // first entry.
            NewResetPath(unit);
-           unit->SubAction=1;
+           unit->SubAction = 1;
            //
            //  Already at target? FIXME: duplicate code.
            //
-           if( (goal=unit->Orders[0].Goal) ) {
-               if( MapDistanceBetweenUnits(unit,goal)<=1 ) {
-                   unit->State=0;
-                   unit->SubAction=2;
+           if ((goal = unit->Orders[0].Goal)) {
+               if (MapDistanceBetweenUnits(unit,goal) <= 1) {
+                   unit->State = 0;
+                   unit->SubAction = 2;
                    HandleActionDemolish(unit);
                    return;
                }
-           } else if( MapDistanceToUnit(unit->Orders[0].X,
-                       unit->Orders[0].Y,unit)<=1 ) {
-               unit->State=0;
-               unit->SubAction=2;
+           } else if (MapDistanceToUnit(unit->Orders[0].X,
+                   unit->Orders[0].Y,unit) <= 1) {
+               unit->State = 0;
+               unit->SubAction = 2;
                HandleActionDemolish(unit);
                return;
            } 
@@ -95,33 +99,33 @@
        case 1:
            // FIXME: reset first!! why? (johns)
            err=DoActionMove(unit);
-           if( unit->Reset ) {
-               goal=unit->Orders[0].Goal;
+           if (unit->Reset) {
+               goal = unit->Orders[0].Goal;
                //
                //      Target is dead, stop demolish.
                //      FIXME: what should I do, go back or explode on place?
                //
-               if( goal ) {
-                   if( goal->Destroyed ) {
+               if (goal) {
+                   if (goal->Destroyed) {
                        DebugLevel0Fn("Destroyed unit\n");
-                       RefsDebugCheck( !goal->Refs );
-                       if( !--goal->Refs ) {
+                       RefsDebugCheck(!goal->Refs);
+                       if (!--goal->Refs) {
                            ReleaseUnit(goal);
                        }
                        // FIXME: perhaps I should choose an alternative
-                       unit->Orders[0].Goal=NoUnitP;
-                       unit->Orders[0].Action=UnitActionStill;
-                       unit->SubAction=0;
+                       unit->Orders[0].Goal = NoUnitP;
+                       unit->Orders[0].Action = UnitActionStill;
+                       unit->SubAction = 0;
                        return;
-                   } else if( goal->Removed || !goal->HP
-                               || goal->Orders[0].Action==UnitActionDie ) {
-                       RefsDebugCheck( !goal->Refs );
+                   } else if (goal->Removed || !goal->HP ||
+                           goal->Orders[0].Action == UnitActionDie) {
+                       RefsDebugCheck(!goal->Refs);
                        --goal->Refs;
-                       RefsDebugCheck( !goal->Refs );
-                       unit->Orders[0].Goal=NoUnitP;
+                       RefsDebugCheck(!goal->Refs);
+                       unit->Orders[0].Goal = NoUnitP;
                        // FIXME: perhaps I should choose an alternative
-                       unit->Orders[0].Action=UnitActionStill;
-                       unit->SubAction=0;
+                       unit->Orders[0].Action = UnitActionStill;
+                       unit->SubAction = 0;
                        return;
                    }
                }
@@ -129,20 +133,20 @@
                //
                //      Have reached target? FIXME: could use pathfinder result?
                //
-               if( goal ) {
-                   if( MapDistanceBetweenUnits(unit,goal)<=1 ) {
-                       unit->State=0;
-                       unit->SubAction=2;
+               if (goal) {
+                   if (MapDistanceBetweenUnits(unit, goal) <= 1) {
+                       unit->State = 0;
+                       unit->SubAction = 2;
                    }
-               } else if( MapDistanceToUnit(unit->Orders[0].X,unit->Orders[0].Y
-                       ,unit )<=1 ) {
-                   unit->State=0;
-                   unit->SubAction=2;
-               } else if( err==PF_UNREACHABLE ) {
-                   unit->Orders[0].Action=UnitActionStill;
+               } else if (MapDistanceToUnit(unit->Orders[0].X, 
unit->Orders[0].Y,
+                       unit) <= 1) {
+                   unit->State = 0;
+                   unit->SubAction = 2;
+               } else if (err == PF_UNREACHABLE) {
+                   unit->Orders[0].Action = UnitActionStill;
                    return;
                }
-               DebugCheck( unit->Orders[0].Action!=UnitActionDemolish );
+               DebugCheck(unit->Orders[0].Action != UnitActionDemolish);
            }
            break;
 
@@ -150,12 +154,12 @@
        //      Demolish the target.
        //
        case 2:
-           goal=unit->Orders[0].Goal;
-           if( goal ) {
-               RefsDebugCheck( !goal->Refs );
+           goal = unit->Orders[0].Goal;
+           if (goal) {
+               RefsDebugCheck(!goal->Refs);
                --goal->Refs;
-               RefsDebugCheck( !goal->Refs );
-               unit->Orders[0].Goal=NoUnitP;
+               RefsDebugCheck(!goal->Refs);
+               unit->Orders[0].Goal = NoUnitP;
            }
 
            if (unit->Type->DemolishRange) {
@@ -163,10 +167,18 @@
                ymin = unit->Y - unit->Type->DemolishRange;
                xmax = unit->X + unit->Type->DemolishRange;
                ymax = unit->Y + unit->Type->DemolishRange;
-               if (xmin<0) xmin=0;
-               if (xmax > TheMap.Width-1) xmax = TheMap.Width-1;
-               if (ymin<0) ymin=0;
-               if (ymax > TheMap.Height-1) ymax = TheMap.Height-1;
+               if (xmin < 0) {
+                   xmin = 0;
+               }
+               if (xmax > TheMap.Width - 1) {
+                   xmax = TheMap.Width - 1;
+               }
+               if (ymin < 0) {
+                   ymin = 0;
+               }
+               if (ymax > TheMap.Height - 1) {
+                   ymax = TheMap.Height - 1;
+               }
 
                // FIXME: Must play explosion sound
 
@@ -174,13 +186,14 @@
                //       Effect of the explosion on units. Don't bother if 
damage is 0
                //
                if (unit->Type->DemolishDamage) {
-                   n=SelectUnits(xmin,ymin, xmax, ymax,table);
-                   for( i=0; i<n; ++i ) {
-                       if( table[i]->Type->UnitType!=UnitTypeFly && 
table[i]->HP
-                           && table[i] != unit 
-                           && MapDistanceBetweenUnits(unit,table[i]) <= 
unit->Type->DemolishRange) {
+                   n = SelectUnits(xmin, ymin, xmax, ymax, table);
+                   for (i = 0; i < n; ++i) {
+                       if (table[i]->Type->UnitType != UnitTypeFly &&
+                               table[i]->HP && table[i] != unit &&
+                               MapDistanceBetweenUnits(unit, table[i]) <=
+                                   unit->Type->DemolishRange) {
                            // Don't hit flying units!
-                           HitUnit(unit,table[i],unit->Type->DemolishDamage);
+                           HitUnit(unit, table[i], unit->Type->DemolishDamage);
                        }
                    }
                }
@@ -188,18 +201,19 @@
                //
                //      Terrain effect of the explosion
                //
-               for( ix=xmin; ix<=xmax; ix++ ) {
-                   for( iy=ymin; iy<=ymax; iy++ ) {
-                       n=TheMap.Fields[ix+iy*TheMap.Width].Flags;
-                       if ( MapDistanceToUnit(ix,iy,unit) > 
unit->Type->DemolishRange ) {
+               for (ix = xmin; ix <= xmax; ++ix) {
+                   for (iy = ymin; iy <= ymax; ++iy) {
+                       n = TheMap.Fields[ix + iy * TheMap.Width].Flags;
+                       if (MapDistanceToUnit(ix, iy, unit) >
+                               unit->Type->DemolishRange) {
                            // Not in circle range
                            continue;
-                       } else if( n&MapFieldWall ) {
-                           MapRemoveWall(ix,iy);
-                       } else if( n&MapFieldRocks ) {
-                           MapRemoveRock(ix,iy);
-                       } else if( n&MapFieldForest ) {
-                           MapRemoveWood(ix,iy);
+                       } else if (n & MapFieldWall) {
+                           MapRemoveWall(ix, iy);
+                       } else if (n & MapFieldRocks) {
+                           MapRemoveRock(ix, iy);
+                       } else if (n & MapFieldForest) {
+                           MapRemoveWood(ix, iy);
                        }
                    }
                }
Index: stratagus/src/action/action_die.c
diff -u stratagus/src/action/action_die.c:1.51 
stratagus/src/action/action_die.c:1.52
--- stratagus/src/action/action_die.c:1.51      Mon Aug 25 07:21:15 2003
+++ stratagus/src/action/action_die.c   Fri Oct  3 16:31:24 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_die.c,v 1.51 2003/08/25 11:21:15 mr-russ Exp $
+//     $Id: action_die.c,v 1.52 2003/10/03 20:31:24 jsalmon3 Exp $
 
 //@{
 
@@ -58,20 +58,20 @@
     //
     // Show death animation
     //
-    if( unit->Type->Animations && unit->Type->Animations->Die ) {
-       UnitShowAnimation(unit,unit->Type->Animations->Die);
+    if (unit->Type->Animations && unit->Type->Animations->Die) {
+       UnitShowAnimation(unit, unit->Type->Animations->Die);
     } else {
        // some units has no death animation
-       unit->Reset=unit->Wait=1;
+       unit->Reset = unit->Wait = 1;
     }
 
     //
     // Die sequence terminated, generate corpse.
     //
-    if( unit->Reset ) {
+    if (unit->Reset) {
        DebugLevel3("Die complete %d\n" _C_ UnitNumber(unit));
 
-       if( !unit->Type->CorpseType ) {
+       if (!unit->Type->CorpseType) {
            UnitMarkSeen(unit);
            ReleaseUnit(unit);
            return;
@@ -81,24 +81,24 @@
        MapUnmarkUnitSight(unit);
        //unit->CurrentSightRange=unit->Type->Stats->SightRange;
 
-       unit->State=unit->Type->CorpseScript;
-       unit->Type=unit->Type->CorpseType;
+       unit->State = unit->Type->CorpseScript;
+       unit->Type = unit->Type->CorpseType;
         
        CommandStopUnit(unit);          // This clears all order queues
-       IfDebug(
-           if( unit->Orders[0].Action!=UnitActionDie ) {
-               DebugLevel0Fn("Reset to die is really needed\n");
-           }
-       );
-       unit->Orders[0].Action=UnitActionDie;
+#ifdef DEBUG
+       if (unit->Orders[0].Action != UnitActionDie) {
+           DebugLevel0Fn("Reset to die is really needed\n");
+       }
+#endif
+       unit->Orders[0].Action = UnitActionDie;
        --unit->OrderCount;             // remove the stop command
-       unit->SubAction=0;
-       unit->Frame=0;
+       unit->SubAction = 0;
+       unit->Frame = 0;
        UnitUpdateHeading(unit);
-       UnitShowAnimation(unit,unit->Type->Animations->Die);
+       UnitShowAnimation(unit, unit->Type->Animations->Die);
 
        // FIXME: perhaps later or never is better
-       //ChangeUnitOwner(unit,&Players[PlayerNumNeutral]);
+       //ChangeUnitOwner(unit, &Players[PlayerNumNeutral]);
     }
     UnitMarkSeen(unit);
 }
Index: stratagus/src/action/action_follow.c
diff -u stratagus/src/action/action_follow.c:1.30 
stratagus/src/action/action_follow.c:1.31
--- stratagus/src/action/action_follow.c:1.30   Sat Sep 20 05:03:40 2003
+++ stratagus/src/action/action_follow.c        Fri Oct  3 16:31:24 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_follow.c,v 1.30 2003/09/20 09:03:40 mr-russ Exp $
+//     $Id: action_follow.c,v 1.31 2003/10/03 20:31:24 jsalmon3 Exp $
 
 //@{
 
@@ -64,22 +64,22 @@
     //
     // Reached target
     //
-    if( unit->SubAction==128 ) {
-       goal=unit->Orders[0].Goal;
-       if( !goal || goal->Destroyed || !goal->HP
-               || goal->Orders[0].Action==UnitActionDie ) {
+    if (unit->SubAction == 128) {
+       goal = unit->Orders[0].Goal;
+       if (!goal || goal->Destroyed || !goal->HP ||
+               goal->Orders[0].Action == UnitActionDie) {
            DebugLevel0Fn("Goal dead\n");
-           if( goal ) {
-               RefsDebugCheck( !goal->Refs );
-               if( !--goal->Refs && goal->Destroyed ) {
+           if (goal) {
+               RefsDebugCheck(!goal->Refs);
+               if (!--goal->Refs && goal->Destroyed) {
                    ReleaseUnit(goal);
                }
            }
-           unit->Orders[0].Goal=NoUnitP;
-           unit->Wait=1;
-           unit->SubAction=0;
-           unit->Orders[0].Action=UnitActionStill;
-           if( IsOnlySelected(unit) ) { // update display for new action
+           unit->Orders[0].Goal = NoUnitP;
+           unit->Wait = 1;
+           unit->SubAction = 0;
+           unit->Orders[0].Action = UnitActionStill;
+           if (IsOnlySelected(unit)) { // update display for new action
                SelectedUnitChanged();
            }
            return;
@@ -88,44 +88,44 @@
        // Two posibilities, both broken. maybe we should change the animation 
system?
        // FIXME: Unit doesn't decrease range
 #if 0
-       if( (goal->X==unit->Orders[0].X && 
goal->Y==unit->Orders[0].Y)||unit->State ) {
-           UnitShowAnimation(unit,unit->Type->Animations->Still);
+       if ((goal->X == unit->Orders[0].X && goal->Y == unit->Orders[0].Y) || 
unit->State) {
+           UnitShowAnimation(unit, unit->Type->Animations->Still);
            //
            //  Sea and air units are floating up/down.
            //  
-           if( unit->Type->SeaUnit||unit->Type->AirUnit ) {
-               unit->IY=(MyRand()>>15)&1;
+           if (unit->Type->SeaUnit || unit->Type->AirUnit) {
+               unit->IY = (MyRand() >> 15) & 1;
            }
            return;
        }
 #else
        // FIXME:Unit doesn't animate.
-       if( (goal->X==unit->Orders[0].X && goal->Y==unit->Orders[0].Y) ) {
-           unit->Reset=1;
-           unit->Wait=10;
-           if ((unit->Orders[0].RangeX>1)||(unit->Orders[0].RangeY>1)) {
-               unit->Orders[0].RangeX=unit->Orders[0].RangeY=1;
-               unit->SubAction=0;
+       if ((goal->X == unit->Orders[0].X && goal->Y == unit->Orders[0].Y)) {
+           unit->Reset = 1;
+           unit->Wait = 10;
+           if ((unit->Orders[0].RangeX > 1) || (unit->Orders[0].RangeY > 1)) {
+               unit->Orders[0].RangeX = unit->Orders[0].RangeY = 1;
+               unit->SubAction = 0;
            }
            return;
        }
 #endif
-       unit->SubAction=0;
+       unit->SubAction = 0;
     }
 
-    if( !unit->SubAction ) {           // first entry
-       unit->SubAction=1;
+    if (!unit->SubAction) {            // first entry
+       unit->SubAction = 1;
        NewResetPath(unit);
-       DebugCheck( unit->State!=0 );
+       DebugCheck(unit->State != 0);
     }
 
-    switch( DoActionMove(unit) ) {     // reached end-point?
+    switch (DoActionMove(unit)) {      // reached end-point?
        case PF_UNREACHABLE:
            //
            //  Some tries to reach the goal
            //
-           if( unit->Orders[0].RangeX <= TheMap.Width
-               || unit->Orders[0].RangeX <= TheMap.Height) {
+           if (unit->Orders[0].RangeX <= TheMap.Width ||
+                   unit->Orders[0].RangeX <= TheMap.Height) {
                unit->Orders[0].RangeX++;
                unit->Orders[0].RangeY++;
                break;
@@ -134,72 +134,72 @@
        case PF_REACHED:
            // FIXME: dark portal teleportation: Goal is used for target circle 
of power
            // FIXME: teleporting of units should use dark portal's mana
-           if( (goal=unit->Orders[0].Goal) && 
+           if ((goal = unit->Orders[0].Goal) && 
                    goal->Type->Teleporter && goal->Goal &&
-                   MapDistanceBetweenUnits(unit,goal)<4 ) {
+                   MapDistanceBetweenUnits(unit, goal) < 4) {
                Unit* table[UnitMax];
                Unit* dest;
                int n;
                int i;
 
-               RemoveUnit(unit,NULL);
+               RemoveUnit(unit, NULL);
                unit->X = goal->Goal->X;
                unit->Y = goal->Goal->Y;
-               DropOutOnSide(unit,unit->Direction,1,1);
+               DropOutOnSide(unit, unit->Direction, 1, 1);
                //FIXME: SoundIdForName() should be called once
-               PlayGameSound(SoundIdForName("invisibility"),MaxSampleVolume);
+               PlayGameSound(SoundIdForName("invisibility"), MaxSampleVolume);
                //FIXME: MissileTypeByIdent() should be called once
                MakeMissile(MissileTypeByIdent("missile-normal-spell"),
-                       unit->X*TileSizeX+TileSizeX/2,
-                       unit->Y*TileSizeY+TileSizeY/2,
-                       unit->X*TileSizeX+TileSizeX/2,
-                       unit->Y*TileSizeY+TileSizeY/2 );
-
-               unit->Wait=1;
-               unit->SubAction=0;
-               unit->Orders[0].Action=UnitActionStill;
+                   unit->X * TileSizeX + TileSizeX / 2,
+                   unit->Y * TileSizeY + TileSizeY / 2,
+                   unit->X * TileSizeX + TileSizeX / 2,
+                   unit->Y * TileSizeY + TileSizeY / 2);
+
+               unit->Wait = 1;
+               unit->SubAction = 0;
+               unit->Orders[0].Action = UnitActionStill;
 
                //
                //      FIXME: we must check if the units supports the new 
order.
                //
-               dest=NoUnitP;
-               n=SelectUnitsOnTile(goal->Goal->X,goal->Goal->Y,table);
-               for( i=0; i<n; ++i ) {
-                   if( table[i]->Type==UnitTypeByIdent("unit-circle-of-power") 
) {
-                       dest=table[i];
+               dest = NoUnitP;
+               n = SelectUnitsOnTile(goal->Goal->X, goal->Goal->Y, table);
+               for (i = 0; i < n; ++i) {
+                   if (table[i]->Type == 
UnitTypeByIdent("unit-circle-of-power")) {
+                       dest = table[i];
                    }
                }
 
-               if( dest ) {
-                   if( (dest->NewOrder.Action==UnitActionResource
-                               && !unit->Type->Harvester  )
-                           || (dest->NewOrder.Action==UnitActionAttack
-                               && !unit->Type->CanAttack)
-                           || (dest->NewOrder.Action==UnitActionBoard
-                               && unit->Type->UnitType!=UnitTypeLand) ) {
+               if (dest) {
+                   if ((dest->NewOrder.Action == UnitActionResource &&
+                               !unit->Type->Harvester) ||
+                           (dest->NewOrder.Action == UnitActionAttack &&
+                               !unit->Type->CanAttack) ||
+                           (dest->NewOrder.Action == UnitActionBoard &&
+                               unit->Type->UnitType != UnitTypeLand)) {
                        DebugLevel0Fn("Wrong order for unit\n");
-                       unit->Orders[0].Action=UnitActionStill;
+                       unit->Orders[0].Action = UnitActionStill;
                    } else {
-                       if( dest->NewOrder.Goal ) {
-                           if( dest->NewOrder.Goal->Destroyed ) {
+                       if (dest->NewOrder.Goal) {
+                           if (dest->NewOrder.Goal->Destroyed) {
                                // FIXME: perhaps we should use another dest?
                                DebugLevel0Fn("Destroyed unit in teleport 
unit\n");
-                               RefsDebugCheck( !dest->NewOrder.Goal->Refs );
-                               if( !--dest->NewOrder.Goal->Refs ) {
+                               RefsDebugCheck(!dest->NewOrder.Goal->Refs);
+                               if (!--dest->NewOrder.Goal->Refs) {
                                    ReleaseUnit(dest->NewOrder.Goal);
                                }
-                               dest->NewOrder.Goal=NoUnitP;
-                               dest->NewOrder.Action=UnitActionStill;
+                               dest->NewOrder.Goal = NoUnitP;
+                               dest->NewOrder.Action = UnitActionStill;
                            }
                        }
 
-                       unit->Orders[0]=dest->NewOrder;
+                       unit->Orders[0] = dest->NewOrder;
 
                        //
                        // FIXME: Pending command uses any references?
                        //
-                       if( unit->Orders[0].Goal ) {
-                           RefsDebugCheck( !unit->Orders[0].Goal->Refs );
+                       if (unit->Orders[0].Goal) {
+                           RefsDebugCheck(!unit->Orders[0].Goal->Refs);
                            unit->Orders[0].Goal->Refs++;
                        }
                    }
@@ -207,18 +207,18 @@
                return;
            }
 
-           if( !(goal=unit->Orders[0].Goal) ) {// goal has died
-               unit->Wait=1;
-               unit->SubAction=0;
-               unit->Orders[0].Action=UnitActionStill;
-               if( IsOnlySelected(unit) ) { // update display for new action
+           if (!(goal = unit->Orders[0].Goal)) {// goal has died
+               unit->Wait = 1;
+               unit->SubAction = 0;
+               unit->Orders[0].Action = UnitActionStill;
+               if (IsOnlySelected(unit)) { // update display for new action
                    SelectedUnitChanged();
                }
                return;
            }
-           unit->Orders[0].X=goal->X;
-           unit->Orders[0].Y=goal->Y;
-           unit->SubAction=128;
+           unit->Orders[0].X = goal->X;
+           unit->Orders[0].Y = goal->Y;
+           unit->SubAction = 128;
 
            // FALL THROUGH
        default:
@@ -228,55 +228,55 @@
     //
     // Target destroyed?
     //
-    if( (goal=unit->Orders[0].Goal) && goal->Destroyed ) {
+    if ((goal = unit->Orders[0].Goal) && goal->Destroyed) {
        DebugLevel0Fn("Goal dead\n");
-       unit->Orders[0].X=goal->X+goal->Type->TileWidth/2;
-       unit->Orders[0].Y=goal->Y+goal->Type->TileHeight/2;
-       unit->Orders[0].Goal=NoUnitP;
-       RefsDebugCheck( !goal->Refs );
-       if( !--goal->Refs ) {
+       unit->Orders[0].X = goal->X + goal->Type->TileWidth / 2;
+       unit->Orders[0].Y = goal->Y + goal->Type->TileHeight / 2;
+       unit->Orders[0].Goal = NoUnitP;
+       RefsDebugCheck(!goal->Refs);
+       if (!--goal->Refs) {
            ReleaseUnit(goal);
        }
-       goal=NoUnitP;
+       goal = NoUnitP;
        NewResetPath(unit);
     }
     //
     // Target removed?
     //
-    if( unit->Type->Transporter && goal && goal->Removed ) {
+    if (unit->Type->Transporter && goal && goal->Removed) {
        DebugLevel0Fn("Goal removed\n");
-       unit->Orders[0].X=goal->X+goal->Type->TileWidth/2;
-       unit->Orders[0].Y=goal->Y+goal->Type->TileHeight/2;
-       unit->Orders[0].Goal=NoUnitP;
-       RefsDebugCheck( !goal->Refs );
-       if( !--goal->Refs ) {
+       unit->Orders[0].X = goal->X + goal->Type->TileWidth / 2;
+       unit->Orders[0].Y = goal->Y + goal->Type->TileHeight / 2;
+       unit->Orders[0].Goal = NoUnitP;
+       RefsDebugCheck(!goal->Refs);
+       if (!--goal->Refs) {
            ReleaseUnit(goal);
        }
-       goal=NoUnitP;
+       goal = NoUnitP;
        NewResetPath(unit);
     }
 
-    if( unit->Reset ) {
+    if (unit->Reset) {
        //
        //      If our leader is dead or stops or attacks:
        //      Attack any enemy in reaction range.
        //              If don't set the goal, the unit can than choose a
        //              better goal if moving nearer to enemy.
        //
-       if( unit->Type->CanAttack && unit->Stats->Speed
-               && (!goal || goal->Orders[0].Action==UnitActionAttack
-                   || goal->Orders[0].Action==UnitActionStill) ) {
-           goal=AttackUnitsInReactRange(unit);
-           if( goal ) {
+       if (unit->Type->CanAttack && unit->Stats->Speed &&
+               (!goal || goal->Orders[0].Action == UnitActionAttack ||
+                   goal->Orders[0].Action == UnitActionStill)) {
+           goal = AttackUnitsInReactRange(unit);
+           if (goal) {
                DebugLevel2Fn("Follow attack %d\n" _C_ UnitNumber(goal));
-               CommandAttack(unit,goal->X,goal->Y,NULL,FlushCommands);
+               CommandAttack(unit, goal->X, goal->Y, NULL, FlushCommands);
                // Save current command to come back.
-               unit->SavedOrder=unit->Orders[0];
+               unit->SavedOrder = unit->Orders[0];
                // This stops the follow command and the attack is executed
-               unit->Orders[0].Action=UnitActionStill;
-               unit->Orders[0].Goal=NoUnitP;
-               unit->SubAction=0;
-               unit->Wait=1;
+               unit->Orders[0].Action = UnitActionStill;
+               unit->Orders[0].Goal = NoUnitP;
+               unit->SubAction = 0;
+               unit->Wait = 1;
            }
        }
     }
Index: stratagus/src/action/action_move.c
diff -u stratagus/src/action/action_move.c:1.66 
stratagus/src/action/action_move.c:1.67
--- stratagus/src/action/action_move.c:1.66     Thu Sep 11 18:07:52 2003
+++ stratagus/src/action/action_move.c  Fri Oct  3 16:31:24 2003
@@ -10,7 +10,7 @@
 //
 /address@hidden action_move.c  -       The move action. */
 //
-//     (c) Copyright 1998,2001,2002,2003 by Lutz Sammer
+//     (c) Copyright 1998,2001-2003 by Lutz Sammer
 //
 //     Stratagus is free software; you can redistribute it and/or modify
 //     it under the terms of the GNU General Public License as published
@@ -21,7 +21,7 @@
 //     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //     GNU General Public License for more details.
 //
-//     $Id: action_move.c,v 1.66 2003/09/11 22:07:52 n0body Exp $
+//     $Id: action_move.c,v 1.67 2003/10/03 20:31:24 jsalmon3 Exp $
 
 //@{
 
@@ -65,7 +65,7 @@
 **     @return         >0 remaining path length, 0 wait for path, -1
 **                     reached goal, -2 can't reach the goal.
 */
-local int ActionMoveGeneric(Unit* unit,const Animation* anim)
+local int ActionMoveGeneric(Unit* unit, const Animation* anim)
 {
     int xd;
     int yd;
@@ -74,44 +74,45 @@
     int i;
     int x;
     int y;
-    Unit *uninside;
+    Unit* uninside;
 
     // FIXME: state 0?, should be wrong, should be Reset.
     // FIXME: Reset flag is cleared by HandleUnitAction.
-    if( !(state=unit->State) ) {
+    if (!(state = unit->State)) {
        //  FIXME: So units flying up and down are not affected.
-       unit->IX=unit->IY=0;
+       unit->IX = unit->IY = 0;
 
 #ifdef HIERARCHIC_PATHFINDER
-       d = PfHierComputePath (unit, &xd, &yd);
+       d = PfHierComputePath(unit, &xd, &yd);
 
 #if 0
        {
-       int ts0, ts1;
-       ts0 = rdtsc ();
-       NextPathElement(unit,&xd,&yd);
-       ts1 = rdtsc ();
-       printf ("old pathfinder: %d cycles\n", ts1-ts0);
+       int ts0;
+       int ts1;
+       ts0 = rdtsc();
+       NextPathElement(unit, &xd, &yd);
+       ts1 = rdtsc();
+       printf("old pathfinder: %d cycles\n", ts1 - ts0);
        }
 #endif
-       switch( d ) {
+       switch (d) {
 #else /* HIERARCHIC_PATHFINDER */
-       switch( d=NextPathElement(unit,&xd,&yd) ) {
+       switch (d = NextPathElement(unit, &xd, &yd)) {
 #endif /* HIERARCHIC_PATHFINDER */
            case PF_UNREACHABLE:        // Can't reach, stop
-               unit->Reset=unit->Wait=1;
-               unit->Moving=0;
+               unit->Reset = unit->Wait = 1;
+               unit->Moving = 0;
                return d;
            case PF_REACHED:            // Reached goal, stop
-               unit->Reset=unit->Wait=1;
-               unit->Moving=0;
+               unit->Reset = unit->Wait = 1;
+               unit->Moving = 0;
                return d;
            case PF_WAIT:               // No path, wait
-               unit->Reset=unit->Wait=1;
-               unit->Moving=0;
+               unit->Reset = unit->Wait = 1;
+               unit->Moving = 0;
                return d;
            default:                    // On the way moving
-               unit->Moving=1;
+               unit->Moving = 1;
                break;
        }
 
@@ -119,42 +120,42 @@
        //      Transporter (un)docking?
        //
        //      FIXME: This is an ugly hack
-       if( unit->Type->Transporter
-               && ( (WaterOnMap(unit->X,unit->Y)
-                   && CoastOnMap(unit->X+xd,unit->Y+yd))
-               || (CoastOnMap(unit->X,unit->Y)
-                   && WaterOnMap(unit->X+xd,unit->Y+yd)) ) ) {
-           PlayUnitSound(unit,VoiceDocking);
+       if (unit->Type->Transporter &&
+               ((WaterOnMap(unit->X, unit->Y) &&
+                   CoastOnMap(unit->X + xd, unit->Y + yd)) ||
+               (CoastOnMap(unit->X, unit->Y) &&
+                   WaterOnMap(unit->X + xd, unit->Y + yd)))) {
+           PlayUnitSound(unit, VoiceDocking);
        }
 
        //
        //      Update movement map.
        //
-       i=unit->Type->FieldFlags;
-       TheMap.Fields[unit->X+unit->Y*TheMap.Width].Flags&=~i;
+       i = unit->Type->FieldFlags;
+       TheMap.Fields[unit->X + unit->Y * TheMap.Width].Flags &= ~i;
 
        UnitCacheRemove(unit);
 
        MapUnmarkUnitSight(unit);
        //  ummark sight for units inside too.
-       uninside=unit->UnitInside;
-       for( i=unit->InsideCount; i; uninside=uninside->NextContained,i-- ) {
-           MapUnmarkUnitOnBoardSight(uninside,unit);
+       uninside = unit->UnitInside;
+       for (i = unit->InsideCount; i; uninside = uninside->NextContained, --i) 
{
+           MapUnmarkUnitOnBoardSight(uninside, unit);
        }
 
-       x=unit->X+=xd;
-       y=unit->Y+=yd;
+       x = unit->X += xd;
+       y = unit->Y += yd;
        UnitCacheInsert(unit);
 
-       TheMap.Fields[x+y*TheMap.Width].Flags|=unit->Type->FieldFlags;
+       TheMap.Fields[x + y * TheMap.Width].Flags |= unit->Type->FieldFlags;
 
-       MustRedraw|=RedrawMinimap;
+       MustRedraw |= RedrawMinimap;
 
        MapMarkUnitSight(unit);
        //  Remove unit from the current selection
-       if( unit->Selected && !IsMapFieldVisible(ThisPlayer,unit->X,unit->Y)) {
+       if (unit->Selected && !IsMapFieldVisible(ThisPlayer, unit->X, unit->Y)) 
{
 #ifndef NEW_UI
-           if( NumSelected==1 ) {          //  Remove building cursor
+           if (NumSelected == 1) {          //  Remove building cursor
                CancelBuildingMode();
            }
 #endif
@@ -163,78 +164,75 @@
        }
 
        //  Remark sight for units inside too.
-       uninside=unit->UnitInside;
-       for( i=unit->InsideCount; i; uninside=uninside->NextContained,i-- ) {
-           MapMarkUnitOnBoardSight(uninside,unit);
+       uninside = unit->UnitInside;
+       for (i = unit->InsideCount; i; uninside = uninside->NextContained, --i) 
{
+           MapMarkUnitOnBoardSight(uninside, unit);
        }
 
        //  Reveal cloaked units.
-       if( unit->Type->DetectCloak ) {
+       if (unit->Type->DetectCloak) {
            MapDetectCloakedUnits(unit);
        }
 
-       unit->IX=-xd*TileSizeX;
-       unit->IY=-yd*TileSizeY;
-       unit->Frame=0;
-       UnitHeadingFromDeltaXY(unit,xd,yd);
+       unit->IX = -xd * TileSizeX;
+       unit->IY = -yd * TileSizeY;
+       unit->Frame = 0;
+       UnitHeadingFromDeltaXY(unit, xd, yd);
     } else {
 #ifdef NEW_SHIPS
-       if( unit->Type->UnitType==UnitTypeLand ) {
-           xd=Heading2X[unit->Direction/NextDirection];
-           yd=Heading2Y[unit->Direction/NextDirection];
+       if (unit->Type->UnitType == UnitTypeLand) {
+           xd = Heading2X[unit->Direction / NextDirection];
+           yd = Heading2Y[unit->Direction / NextDirection];
        } else {
-           xd=Heading2X[unit->Direction/NextDirection]*2;
-           yd=Heading2Y[unit->Direction/NextDirection]*2;
+           xd = Heading2X[unit->Direction / NextDirection] * 2;
+           yd = Heading2Y[unit->Direction / NextDirection] * 2;
        }
-       d=0;
+       d = 0;
 #else
-       xd=Heading2X[unit->Direction/NextDirection];
-       yd=Heading2Y[unit->Direction/NextDirection];
-       d=0;
+       xd = Heading2X[unit->Direction / NextDirection];
+       yd = Heading2Y[unit->Direction / NextDirection];
+       d = 0;
 #endif
     }
 
     DebugLevel3Fn(": %d,%d State %2d " _C_ xd _C_ yd _C_ unit->State);
-    DebugLevel3("Walk %d Frame %2d Wait %3d Heading %d %d,%d\n"
-           _C_ anim[state].Pixel
-           _C_ anim[state].Frame
-           _C_ anim[state].Sleep
-           _C_ unit->Direction
-           _C_ unit->IX _C_ unit->IY);
+    DebugLevel3("Walk %d Frame %2d Wait %3d Heading %d %d,%d\n" _C_
+       anim[state].Pixel _C_ anim[state].Frame _C_ anim[state].Sleep _C_
+       unit->Direction _C_ unit->IX _C_ unit->IY);
 
     //
     // Next animation.
     //
-    unit->IX+=xd*anim[state].Pixel;
-    unit->IY+=yd*anim[state].Pixel;
-    if( unit->Frame<0 ) {
-       unit->Frame+=-anim[state].Frame;
+    unit->IX += xd * anim[state].Pixel;
+    unit->IY += yd * anim[state].Pixel;
+    if (unit->Frame < 0) {
+       unit->Frame += -anim[state].Frame;
     } else {
-       unit->Frame+=anim[state].Frame;
+       unit->Frame += anim[state].Frame;
     }
-    unit->Wait=anim[state].Sleep;
-    if( unit->Slow ) {                 // unit is slowed down
-       unit->Wait<<=1;
+    unit->Wait = anim[state].Sleep;
+    if (unit->Slow) {                  // unit is slowed down
+       unit->Wait <<= 1;
     }
-    if( unit->Haste && unit->Wait>1 ) {        // unit is accelerated
-       unit->Wait>>=1;
+    if (unit->Haste && unit->Wait > 1) {       // unit is accelerated
+       unit->Wait >>= 1;
     }
 
     //
     // Any graphic change?
     //
-    if( !state || anim[state].Pixel || anim[state].Frame ) {
+    if (!state || anim[state].Pixel || anim[state].Frame) {
         CheckUnitToBeDrawn(unit);
     }
 
     //
     // Handle the flags.
     //
-    if( anim[state].Flags&AnimationReset ) {
-       unit->Reset=1;
+    if (anim[state].Flags & AnimationReset) {
+       unit->Reset = 1;
     }
-    if( anim[state].Flags&AnimationRestart ) {
-       unit->State=0;
+    if (anim[state].Flags & AnimationRestart) {
+       unit->State = 0;
     } else {
        ++unit->State;
     }
@@ -252,9 +250,9 @@
 */
 global int DoActionMove(Unit* unit)
 {
-    if( unit->Type->Animations && unit->Type->Animations->Move ) {
-       DebugLevel3("%s: %p\n" _C_ unit->Type->Ident _C_ unit->Type->Animations 
);
-       return ActionMoveGeneric(unit,unit->Type->Animations->Move);
+    if (unit->Type->Animations && unit->Type->Animations->Move) {
+       DebugLevel3("%s: %p\n" _C_ unit->Type->Ident _C_ 
unit->Type->Animations);
+       return ActionMoveGeneric(unit, unit->Type->Animations->Move);
     }
 
     DebugLevel0Fn("Warning tried to move an object, which can't move\n");
@@ -277,43 +275,43 @@
     Unit* goal;
 
     DebugLevel3Fn("%d: %d %d,%d \n" _C_ UnitNumber(unit) _C_
-           unit->Orders[0].Goal ? UnitNumber(unit->Orders[0].Goal) : -1 _C_
-           unit->Orders[0].X _C_ unit->Orders[0].Y);
+       unit->Orders[0].Goal ? UnitNumber(unit->Orders[0].Goal) : -1 _C_
+       unit->Orders[0].X _C_ unit->Orders[0].Y);
 
-    if( !unit->SubAction ) {           // first entry
-       unit->SubAction=1;
+    if (!unit->SubAction) {            // first entry
+       unit->SubAction = 1;
        NewResetPath(unit);
        
-       DebugCheck( unit->State!=0 );
+       DebugCheck(unit->State != 0);
     }
 
     // FIXME: (mr-russ) Make a reachable goal here with GoalReachable ...
 
-    switch( DoActionMove(unit) ) {     // reached end-point?
+    switch (DoActionMove(unit)) {      // reached end-point?
        case PF_UNREACHABLE:
            //
            //  Some tries to reach the goal
            //
-           if( unit->Orders[0].RangeX <= TheMap.Width
-               || unit->Orders[0].RangeX <= TheMap.Height) {
+           if (unit->Orders[0].RangeX <= TheMap.Width ||
+                   unit->Orders[0].RangeX <= TheMap.Height) {
                unit->Orders[0].RangeX++;
                unit->Orders[0].RangeY++;
                break;
            }
            // FALL THROUGH
        case PF_REACHED:
-           unit->SubAction=0;
+           unit->SubAction = 0;
            // Release target, if any.
-           if( (goal=unit->Orders[0].Goal) ) {
-               RefsDebugCheck( !goal->Refs );
-               if( !--goal->Refs ) {
-                   DebugCheck( !goal->Destroyed );
+           if ((goal = unit->Orders[0].Goal)) {
+               RefsDebugCheck(!goal->Refs);
+               if (!--goal->Refs) {
+                   DebugCheck(!goal->Destroyed);
                    ReleaseUnit(goal);
                }
-               unit->Orders[0].Goal=NoUnitP;
+               unit->Orders[0].Goal = NoUnitP;
            }
-           unit->Orders[0].Action=UnitActionStill;
-           if( unit->Selected ) {      // update display for new action
+           unit->Orders[0].Action = UnitActionStill;
+           if (unit->Selected) {       // update display for new action
                SelectedUnitChanged();
            }
            return;
@@ -325,13 +323,13 @@
     //
     // Target destroyed?
     //
-    if( (goal=unit->Orders[0].Goal) && goal->Destroyed ) {
+    if ((goal = unit->Orders[0].Goal) && goal->Destroyed) {
        DebugLevel0Fn("Goal dead\n");
-       unit->Orders[0].X=goal->X+goal->Type->TileWidth/2;
-       unit->Orders[0].Y=goal->Y+goal->Type->TileHeight/2;
-       unit->Orders[0].Goal=NoUnitP;
-       RefsDebugCheck( !goal->Refs );
-       if( !--goal->Refs ) {
+       unit->Orders[0].X = goal->X + goal->Type->TileWidth / 2;
+       unit->Orders[0].Y = goal->Y + goal->Type->TileHeight / 2;
+       unit->Orders[0].Goal = NoUnitP;
+       RefsDebugCheck(!goal->Refs);
+       if (!--goal->Refs) {
            ReleaseUnit(goal);
        }
        NewResetPath(unit);
Index: stratagus/src/action/action_patrol.c
diff -u stratagus/src/action/action_patrol.c:1.33 
stratagus/src/action/action_patrol.c:1.34
--- stratagus/src/action/action_patrol.c:1.33   Sat Sep 20 05:03:40 2003
+++ stratagus/src/action/action_patrol.c        Fri Oct  3 16:31:24 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_patrol.c,v 1.33 2003/09/20 09:03:40 mr-russ Exp $
+//     $Id: action_patrol.c,v 1.34 2003/10/03 20:31:24 jsalmon3 Exp $
 
 //@{
 
@@ -61,43 +61,43 @@
 {
     const Unit* goal;
 
-    if( !unit->SubAction ) {           // first entry.
+    if (!unit->SubAction) {            // first entry.
        NewResetPath(unit);
-       unit->SubAction=1;
+       unit->SubAction = 1;
     }
 
-    if( DoActionMove(unit)<0 ) {       // reached end-point or stop
+    if (DoActionMove(unit) < 0) {      // reached end-point or stop
        int tmp;
 
-       DebugCheck( unit->Orders[0].Action!=UnitActionPatrol );
+       DebugCheck(unit->Orders[0].Action!=UnitActionPatrol);
 
        //
        //      Swap the points.
        //
-       tmp=(int)unit->Orders[0].Arg1;
-       unit->Orders[0].Arg1=(void*)((unit->Orders[0].X<<16)|unit->Orders[0].Y);
-       unit->Orders[0].X=tmp>>16;
-       unit->Orders[0].Y=tmp&0xFFFF;
+       tmp = (int)unit->Orders[0].Arg1;
+       unit->Orders[0].Arg1 = (void*)((unit->Orders[0].X << 16) | 
unit->Orders[0].Y);
+       unit->Orders[0].X = tmp >> 16;
+       unit->Orders[0].Y = tmp & 0xFFFF;
 
        NewResetPath(unit);
     }
 
-    if( unit->Reset ) {
+    if (unit->Reset) {
        //
        //      Attack any enemy in reaction range.
        //              If don't set the goal, the unit can than choose a
        //              better goal if moving nearer to enemy.
        //
-       if( unit->Type->CanAttack && unit->Stats->Speed ) {
-           goal=AttackUnitsInReactRange(unit);
-           if( goal ) {
+       if (unit->Type->CanAttack && unit->Stats->Speed) {
+           goal = AttackUnitsInReactRange(unit);
+           if (goal) {
                DebugLevel0Fn("Patrol attack %d\n" _C_ UnitNumber(goal));
-               CommandAttack(unit,goal->X,goal->Y,NULL,FlushCommands);
+               CommandAttack(unit, goal->X, goal->Y, NULL, FlushCommands);
                // Save current command to come back.
-               unit->SavedOrder=unit->Orders[0];
-               unit->Orders[0].Action=UnitActionStill;
-               unit->Orders[0].Goal=NoUnitP;
-               unit->SubAction=0;
+               unit->SavedOrder = unit->Orders[0];
+               unit->Orders[0].Action = UnitActionStill;
+               unit->Orders[0].Goal = NoUnitP;
+               unit->SubAction = 0;
                DebugLevel0Fn("Wait %d\n" _C_ unit->Wait);
            }
        }




reply via email to

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