stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src/action action_resource.c


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src/action action_resource.c
Date: Fri, 31 Oct 2003 13:16:32 -0500

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

Modified files:
        src/action     : action_resource.c 

Log message:
        Fixed bug if unit->Wait is 0

Patches:
Index: stratagus/src/action/action_resource.c
diff -u stratagus/src/action/action_resource.c:1.62 
stratagus/src/action/action_resource.c:1.63
--- stratagus/src/action/action_resource.c:1.62 Fri Oct 31 12:36:12 2003
+++ stratagus/src/action/action_resource.c      Fri Oct 31 13:16:31 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_resource.c,v 1.62 2003/10/31 17:36:12 jsalmon3 Exp $
+//     $Id: action_resource.c,v 1.63 2003/10/31 18:16:31 jsalmon3 Exp $
 
 //@{
 
@@ -213,7 +213,7 @@
            2 * (goal->X - unit->X) + goal->Type->TileWidth,
            2 * (goal->Y - unit->Y) + goal->Type->TileHeight);
     }
-    
+
     //
     // If resource is still under construction, wait!
     //
@@ -296,7 +296,7 @@
 
     //
     //  If we are loaded first search for a depot.
-    // 
+    //
     if (unit->Value && (depot = FindDeposit(unit, unit->X, unit->Y,
            1000, unit->CurrentResource))) {
        if (unit->Container) {
@@ -306,7 +306,7 @@
        }
        //
        //  Remember were it mined, so it can look around for another resource.
-       //  
+       //
        unit->Orders[0].Arg1 = (void*)((unit->X << 16) | unit->Y);
        unit->Orders[0].Goal = depot;
        RefsDebugCheck(!depot->Refs);
@@ -359,10 +359,10 @@
     ResourceInfo* resinfo;
     int i;
     int addload;
-    
+
     resinfo = unit->Type->ResInfo[unit->CurrentResource];
     source = 0;
-    
+
     if (resinfo->HarvestFromOutside || resinfo->TerrainHarvester) {
        AnimateActionHarvest(unit);
        unit->Data.ResWorker.TimeToHarvest -= unit->Wait;
@@ -375,7 +375,7 @@
        DebugCheck(!(resinfo->HarvestFromOutside || resinfo->TerrainHarvester));
        return unit->Reset;
     }
-    
+
     //  Target gone?
     if (resinfo->TerrainHarvester && !ForestOnMap(unit->Orders->X, 
unit->Orders->Y)) {
        DebugLevel3Fn("Wood gone for unit %d.\n" _C_ unit->Slot);
@@ -438,13 +438,13 @@
                DebugLevel3Fn("Harvested another %d resources.\n" _C_ addload);
                unit->Value += addload;
                source->Value -= addload;
-              
+
                UnitMarkSeen(source);
                if (IsOnlySelected(source)) {
                    MustRedraw |= RedrawInfoPanel;
                }
            }
-           
+
            //
            //  End of resource: destroy the resource.
            //  FIXME: implement depleted resources.
@@ -455,7 +455,7 @@
                uins = source->UnitInside;
                //
                // Improved version of DropOutAll that makes workers go to the 
depot.
-               // 
+               //
                LoseResource(unit,source);
                for (i = source->InsideCount; i; --i, uins = 
uins->NextContained) {
                    LoseResource(uins,source);
@@ -479,7 +479,7 @@
            }
            return 0;
        }
-       
+
        if (resinfo->HarvestFromOutside && !resinfo->TerrainHarvester) {
            if ((unit->Value == resinfo->ResourceCapacity) || (source == NULL)) 
{
                // Mark as complete.
@@ -488,7 +488,7 @@
            }
            return 0;
        }
-       
+
        if ((!resinfo->HarvestFromOutside) && (!resinfo->TerrainHarvester)) {
            return unit->Value == resinfo->ResourceCapacity && source;
        }
@@ -522,12 +522,12 @@
        source->Data.Resource.Active--;
        DebugCheck(source->Data.Resource.Active < 0);
     }
-     
+
 
     // Store resource position.
     // FIXME: is this the best way?
     unit->Orders[0].Arg1 = (void*)((unit->X << 16) | unit->Y);
- 
+
     if (!unit->Value) {
        DebugLevel0Fn("Unit %d is empty???\n" _C_ unit->Slot);
     } else {
@@ -664,6 +664,9 @@
     }
 
     unit->Wait = resinfo->WaitAtDepot / 
SpeedResourcesReturn[resinfo->ResourceId];
+    if (!unit->Wait) {
+       unit->Wait = 1;
+    }
 
     return 1;
 }
@@ -773,7 +776,7 @@
        unit->Data.ResWorker.TimeToHarvest _C_
        DefaultResourceNames[unit->CurrentResource] _C_
        (unsigned int)unit->Orders->Goal);
-    
+
     // Let's start mining.
     if (unit->SubAction == SUB_START_RESOURCE) {
        if (unit->Orders->Goal) {
@@ -790,7 +793,7 @@
        DebugLevel3Fn("Started mining. reset path.\n");
        unit->SubAction = SUB_MOVE_TO_RESOURCE;
     }
-   
+
     //  Move to the resource location.
     if (unit->SubAction >= SUB_MOVE_TO_RESOURCE &&
            unit->SubAction < SUB_UNREACHABLE_RESOURCE) {
@@ -825,7 +828,7 @@
            return;
        }
     }
-    
+
     //  Gather the resource.
     if (unit->SubAction == SUB_GATHER_RESOURCE) {
        if (GatherResource(unit)) {
@@ -834,7 +837,7 @@
            return;
        }
     }
-    
+
     //  Stop gathering the resource.
     if (unit->SubAction == SUB_STOP_GATHERING) {
        if (StopGathering(unit)) {




reply via email to

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