stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus data/ccl/units.ccl data/ccl/human/uni...


From: Crestez Leonard
Subject: [Stratagus-CVS] stratagus data/ccl/units.ccl data/ccl/human/uni...
Date: Fri, 08 Aug 2003 15:31:38 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Crestez Leonard <address@hidden>        03/08/08 15:31:37

Modified files:
        data/ccl       : units.ccl 
        data/ccl/human : units.ccl 
        data/ccl/orc   : units.ccl 
        doc            : ChangeLog.html 
        src/action     : action_build.c action_follow.c action_harvest.c 
                         action_minegold.c action_resource.c 
                         action_returngoods.c action_train.c actions.c 
                         command.c 
        src/ai         : ai_resource.c 
        src/clone      : unit.c unit_draw.c 
        src/include    : actions.h commands.h network.h unit.h 
                         unittype.h 
        src/network    : commands.c 
        src/ui         : mainscr.c mouse.c 
        src/unit       : ccl_unit.c ccl_unittype.c unittype.c 

Log message:
        Resources are more configurable, no visible changes.

Patches:
Index: stratagus/data/ccl/human/units.ccl
diff -u stratagus/data/ccl/human/units.ccl:1.20 
stratagus/data/ccl/human/units.ccl:1.21
--- stratagus/data/ccl/human/units.ccl:1.20     Tue Jul 22 10:32:21 2003
+++ stratagus/data/ccl/human/units.ccl  Fri Aug  8 15:31:35 2003
@@ -26,7 +26,7 @@
 ;;      along with this program; if not, write to the Free Software
 ;;      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA
 ;;
-;;     $Id: units.ccl,v 1.20 2003/07/22 14:32:21 n0body Exp $
+;;     $Id: units.ccl,v 1.21 2003/08/08 19:31:35 n0body Exp $
 
 ;;=============================================================================
 ;;     Define unit-types.
@@ -98,6 +98,101 @@
     dead "basic human voices dead"
     attack "peasant-attack"))
 
+(define-unit-type 'unit-peasant-with-gold 'name "Peasant"
+  'files '(tileset-summer "human/units/peasant_with_gold.png")
+  'size '(72 72)
+  'animations 'animations-peasant 'icon 'icon-peasant
+  'costs '(time 45 gold 400)
+  'speed 10
+  'hit-points 30
+  'draw-level 40
+  'tile-size '(1 1) 'box-size '(31 31)
+  'sight-range 4 'computer-reaction-range 6 'person-reaction-range 4
+  'basic-damage 3 'piercing-damage 2 'missile 'missile-none
+  'max-attack-range 1
+  'priority 50
+  'points 30
+  'demand 1
+  'corpse '(unit-dead-body 6)
+  'type-land
+  'right-harvest
+  'can-attack
+  'can-target-land
+  'land-unit
+  'cower-worker
+  'organic
+  'selectable-by-rectangle
+  'sounds '(
+    selected "peasant-with-gold-selected"
+    acknowledge "peasant-with-gold-acknowledge"
+    ready "peasant-with-gold-ready"
+    help "basic human voices help 1"
+    dead "basic human voices dead"
+    attack "peasant-with-gold-attack"))
+
+(define-unit-type 'unit-peasant-with-wood 'name "Peasant"
+  'files '(tileset-summer "human/units/peasant_with_wood.png")
+  'size '(72 72)
+  'animations 'animations-peasant 'icon 'icon-peasant
+  'costs '(time 45 gold 400)
+  'speed 10
+  'hit-points 30
+  'draw-level 40
+  'tile-size '(1 1) 'box-size '(31 31)
+  'sight-range 4 'computer-reaction-range 6 'person-reaction-range 4
+  'basic-damage 3 'piercing-damage 2 'missile 'missile-none
+  'max-attack-range 1
+  'priority 50
+  'points 30
+  'demand 1
+  'corpse '(unit-dead-body 6)
+  'type-land
+  'right-harvest
+  'can-attack
+  'can-target-land
+  'land-unit
+  'cower-worker
+  'organic
+  'selectable-by-rectangle
+  'sounds '(
+    selected "peasant-with-wood-selected"
+    acknowledge "peasant-with-wood-acknowledge"
+    ready "peasant-with-wood-ready"
+    help "basic human voices help 1"
+    dead "basic human voices dead"
+    attack "peasant-with-wood-attack"))
+
+(define-unit-type 'unit-attack-peasant 'name "Peasant"
+  'use 'unit-peasant
+  'size '(72 72)
+  'animations 'animations-peasant 'icon 'icon-peasant
+  'costs '(time 45 gold 400)
+  'speed 10
+  'hit-points 30
+  'draw-level 40
+  'tile-size '(1 1) 'box-size '(31 31)
+  'sight-range 4 'computer-reaction-range 6 'person-reaction-range 4
+  'basic-damage 3 'piercing-damage 2 'missile 'missile-none
+  'max-attack-range 1
+  'priority 50
+  'points 30
+  'demand 1
+  'corpse '(unit-dead-body 6)
+  'type-land
+  'right-attack
+  'can-attack
+  'can-target-land
+  'land-unit
+  'organic
+  'selectable-by-rectangle
+  'sounds '(
+    selected "peasant-selected"
+    acknowledge "peasant-acknowledge"
+    ready "peasant-ready"
+    help "basic human voices help 1"
+    dead "basic human voices dead"
+    attack "peasant-attack"))
+
 (define-unit-type 'unit-ballista 'name "Ballista"
   'files '(tileset-summer "human/units/ballista.png")
   'size '(64 64)
@@ -293,37 +388,6 @@
     dead "explosion"
     attack "dwarves-attack"))
 
-(define-unit-type 'unit-attack-peasant 'name "Peasant"
-  'use 'unit-peasant
-  'size '(72 72)
-  'animations 'animations-peasant 'icon 'icon-peasant
-  'costs '(time 45 gold 400)
-  'speed 10
-  'hit-points 30
-  'draw-level 40
-  'tile-size '(1 1) 'box-size '(31 31)
-  'sight-range 4 'computer-reaction-range 6 'person-reaction-range 4
-  'basic-damage 3 'piercing-damage 2 'missile 'missile-none
-  'max-attack-range 1
-  'priority 50
-  'points 30
-  'demand 1
-  'corpse '(unit-dead-body 6)
-  'type-land
-  'right-attack
-  'can-attack
-  'can-target-land
-  'land-unit
-  'organic
-  'selectable-by-rectangle
-  'sounds '(
-    selected "peasant-selected"
-    acknowledge "peasant-acknowledge"
-    ready "peasant-ready"
-    help "basic human voices help 1"
-    dead "basic human voices dead"
-    attack "peasant-attack"))
-
 (define-unit-type 'unit-ranger 'name "Ranger"
   'use 'unit-archer
   'size '(72 72)
@@ -454,6 +518,8 @@
     dead "basic human voices dead"
     attack "khadgar-attack"))
 
+(define-unit-type 'unit-human-oil-tanker-full)
+ 
 (define-unit-type 'unit-human-oil-tanker 'name "Oil tanker"
   'files '(tileset-summer "human/units/oil_tanker_empty.png")
   'size '(72 72)
@@ -473,7 +539,9 @@
   'type-naval
   'right-haul-oil
   'sea-unit
-  'tanker
+  'harvester 'resource-harvested 'oil 'resource-capacity 100
+  'wait-at-resource 100 'wait-at-depot 100
+  'transform-when-loaded 'unit-human-oil-tanker-full
   'selectable-by-rectangle
   'sounds '(
     selected "human-oil-tanker-selected"
@@ -482,7 +550,38 @@
     help "basic human voices help 1"
     dead "ship sinking"
     attack "human-oil-tanker-attack"))
-
+    
+(define-unit-type 'unit-human-oil-tanker-full 'name "Oil tanker"
+  'files '(tileset-summer "human/units/oil_tanker_full.png")
+  'size '(72 72)
+  'animations 'animations-human-oil-tanker 'icon 'icon-alliance-oil-tanker
+  'costs '(time 50 gold 400 wood 200)
+  'speed 10
+  'hit-points 90
+  'draw-level 40
+  'tile-size '(1 1) 'box-size '(63 63)
+  'sight-range 4
+  'armor 10 'basic-damage 0 'piercing-damage 0 'missile 'missile-none
+  'max-attack-range 1
+  'priority 50 'annoy-computer-factor 10
+  'points 40
+  'demand 1
+  'corpse '(unit-dead-body 12)
+  'type-naval
+  'right-haul-oil
+  'sea-unit
+  'harvester 'resource-harvested 'oil 'resource-capacity 100
+  'wait-at-resource 100 'wait-at-depot 100
+  'transform-when-empty 'unit-human-oil-tanker
+  'selectable-by-rectangle
+  'sounds '(
+    selected "human-oil-tanker-selected"
+    acknowledge "human-oil-tanker-acknowledge"
+    ready "human-oil-tanker-ready"
+    help "basic human voices help 1"
+    dead "ship sinking"
+    attack "human-oil-tanker-attack"))
+   
 (define-unit-type 'unit-alliance-transport 'name "Transport"
   'files '(tileset-summer "human/units/transport.png")
   'size '(72 72)
@@ -1218,7 +1317,7 @@
   'type-naval
   'building
   'must-build-on-top 'unit-oil-patch
-  'gives-oil
+  'gives-resource 'oil 'can-harvest
   'sounds '(
     selected "human-oil-platform-selected"
     acknowledge "human-oil-platform-acknowledge"
@@ -1397,95 +1496,4 @@
     dead "building destroyed"
     attack "human-wall-attack"))
 
-(define-unit-type 'unit-peasant-with-gold 'name "Peasant"
-  'files '(tileset-summer "human/units/peasant_with_gold.png")
-  'size '(72 72)
-  'animations 'animations-peasant 'icon 'icon-peasant
-  'costs '(time 45 gold 400)
-  'speed 10
-  'hit-points 30
-  'draw-level 40
-  'tile-size '(1 1) 'box-size '(31 31)
-  'sight-range 4 'computer-reaction-range 6 'person-reaction-range 4
-  'basic-damage 3 'piercing-damage 2 'missile 'missile-none
-  'max-attack-range 1
-  'priority 50
-  'points 30
-  'demand 1
-  'corpse '(unit-dead-body 6)
-  'type-land
-  'right-harvest
-  'can-attack
-  'can-target-land
-  'land-unit
-  'cower-worker
-  'organic
-  'selectable-by-rectangle
-  'sounds '(
-    selected "peasant-with-gold-selected"
-    acknowledge "peasant-with-gold-acknowledge"
-    ready "peasant-with-gold-ready"
-    help "basic human voices help 1"
-    dead "basic human voices dead"
-    attack "peasant-with-gold-attack"))
-
-(define-unit-type 'unit-peasant-with-wood 'name "Peasant"
-  'files '(tileset-summer "human/units/peasant_with_wood.png")
-  'size '(72 72)
-  'animations 'animations-peasant 'icon 'icon-peasant
-  'costs '(time 45 gold 400)
-  'speed 10
-  'hit-points 30
-  'draw-level 40
-  'tile-size '(1 1) 'box-size '(31 31)
-  'sight-range 4 'computer-reaction-range 6 'person-reaction-range 4
-  'basic-damage 3 'piercing-damage 2 'missile 'missile-none
-  'max-attack-range 1
-  'priority 50
-  'points 30
-  'demand 1
-  'corpse '(unit-dead-body 6)
-  'type-land
-  'right-harvest
-  'can-attack
-  'can-target-land
-  'land-unit
-  'cower-worker
-  'organic
-  'selectable-by-rectangle
-  'sounds '(
-    selected "peasant-with-wood-selected"
-    acknowledge "peasant-with-wood-acknowledge"
-    ready "peasant-with-wood-ready"
-    help "basic human voices help 1"
-    dead "basic human voices dead"
-    attack "peasant-with-wood-attack"))
 
-(define-unit-type 'unit-human-oil-tanker-full 'name "Oil tanker"
-  'files '(tileset-summer "human/units/oil_tanker_full.png")
-  'size '(72 72)
-  'animations 'animations-human-oil-tanker 'icon 'icon-alliance-oil-tanker
-  'costs '(time 50 gold 400 wood 200)
-  'speed 10
-  'hit-points 90
-  'draw-level 40
-  'tile-size '(1 1) 'box-size '(63 63)
-  'sight-range 4
-  'armor 10 'basic-damage 0 'piercing-damage 0 'missile 'missile-none
-  'max-attack-range 1
-  'priority 50 'annoy-computer-factor 10
-  'points 40
-  'demand 1
-  'corpse '(unit-dead-body 12)
-  'type-naval
-  'right-haul-oil
-  'sea-unit
-  'tanker
-  'selectable-by-rectangle
-  'sounds '(
-    selected "human-oil-tanker-full-selected"
-    acknowledge "human-oil-tanker-full-acknowledge"
-    ready "human-oil-tanker-full-ready"
-    help "basic human voices help 1"
-    dead "ship sinking"
-    attack "human-oil-tanker-full-attack"))
Index: stratagus/data/ccl/orc/units.ccl
diff -u stratagus/data/ccl/orc/units.ccl:1.24 
stratagus/data/ccl/orc/units.ccl:1.25
--- stratagus/data/ccl/orc/units.ccl:1.24       Tue Jul 22 10:32:21 2003
+++ stratagus/data/ccl/orc/units.ccl    Fri Aug  8 15:31:35 2003
@@ -26,7 +26,7 @@
 ;;      along with this program; if not, write to the Free Software
 ;;      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA
 ;;
-;;     $Id: units.ccl,v 1.24 2003/07/22 14:32:21 n0body Exp $
+;;     $Id: units.ccl,v 1.25 2003/08/08 19:31:35 n0body Exp $
 
 ;;=============================================================================
 ;;     Define unit-types.
@@ -457,6 +457,8 @@
     dead "basic orc voices dead"
     attack "grom-hellscream-attack"))
 
+(define-unit-type 'unit-orc-oil-tanker-full)
+ 
 (define-unit-type 'unit-orc-oil-tanker 'name "Oil tanker"
   'files '(tileset-summer "orc/units/oil_tanker_empty.png")
   'size '(72 72)
@@ -476,7 +478,9 @@
   'type-naval
   'right-haul-oil
   'sea-unit
-  'tanker
+  'harvester 'resource-harvested 'oil 'resource-capacity 100
+  'wait-at-resource 100 'wait-at-depot 100
+  'transform-when-loaded 'unit-orc-oil-tanker-full
   'selectable-by-rectangle
   'sounds '(
     selected "orc-oil-tanker-selected"
@@ -486,6 +490,37 @@
     dead "ship sinking"
     attack "orc-oil-tanker-attack"))
 
+(define-unit-type 'unit-orc-oil-tanker-full 'name "Oil tanker"
+  'files '(tileset-summer "orc/units/oil_tanker_full.png")
+  'size '(72 72)
+  'animations 'animations-human-oil-tanker 'icon 'icon-mythical-oil-tanker
+  'costs '(time 50 gold 400 wood 200)
+  'speed 10
+  'hit-points 90
+  'draw-level 40
+  'tile-size '(1 1) 'box-size '(63 63)
+  'sight-range 4
+  'armor 10 'basic-damage 0 'piercing-damage 0 'missile 'missile-none
+  'max-attack-range 1
+  'priority 50 'annoy-computer-factor 10
+  'points 40
+  'demand 1
+  'corpse '(unit-dead-body 12)
+  'type-naval
+  'right-haul-oil
+  'sea-unit
+  'harvester 'resource-harvested 'oil 'resource-capacity 100
+  'wait-at-resource 100 'wait-at-depot 100
+  'transform-when-empty 'unit-orc-oil-tanker
+  'selectable-by-rectangle
+  'sounds '(
+    selected "orc-oil-tanker-full-selected"
+    acknowledge "orc-oil-tanker-full-acknowledge"
+    ready "orc-oil-tanker-full-ready"
+    help "basic orc voices help 1"
+    dead "ship sinking"
+    attack "orc-oil-tanker-full-attack"))
+    
 (define-unit-type 'unit-mythical-transport 'name "Transport"
   'files '(tileset-summer "orc/units/transport.png")
   'size '(72 72)
@@ -1308,8 +1343,8 @@
   'corpse '(unit-destroyed-3x3-place 3)
   'type-naval
   'building
-  'gives-oil
   'must-build-on-top 'unit-oil-patch
+  'gives-resource 'oil 'can-harvest
   'sounds '(
     selected "orc-oil-platform-selected"
     acknowledge "orc-oil-platform-acknowledge"
@@ -1550,31 +1585,3 @@
     dead "basic orc voices dead"
     attack "peon-with-wood-attack"))
 
-(define-unit-type 'unit-orc-oil-tanker-full 'name "Oil tanker"
-  'files '(tileset-summer "orc/units/oil_tanker_full.png")
-  'size '(72 72)
-  'animations 'animations-human-oil-tanker 'icon 'icon-mythical-oil-tanker
-  'costs '(time 50 gold 400 wood 200)
-  'speed 10
-  'hit-points 90
-  'draw-level 40
-  'tile-size '(1 1) 'box-size '(63 63)
-  'sight-range 4
-  'armor 10 'basic-damage 0 'piercing-damage 0 'missile 'missile-none
-  'max-attack-range 1
-  'priority 50 'annoy-computer-factor 10
-  'points 40
-  'demand 1
-  'corpse '(unit-dead-body 12)
-  'type-naval
-  'right-haul-oil
-  'sea-unit
-  'tanker
-  'selectable-by-rectangle
-  'sounds '(
-    selected "orc-oil-tanker-full-selected"
-    acknowledge "orc-oil-tanker-full-acknowledge"
-    ready "orc-oil-tanker-full-ready"
-    help "basic orc voices help 1"
-    dead "ship sinking"
-    attack "orc-oil-tanker-full-attack"))
Index: stratagus/data/ccl/units.ccl
diff -u stratagus/data/ccl/units.ccl:1.39 stratagus/data/ccl/units.ccl:1.40
--- stratagus/data/ccl/units.ccl:1.39   Sat Aug  2 09:37:06 2003
+++ stratagus/data/ccl/units.ccl        Fri Aug  8 15:31:35 2003
@@ -26,7 +26,7 @@
 ;;      along with this program; if not, write to the Free Software
 ;;      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA
 ;;
-;;     $Id: units.ccl,v 1.39 2003/08/02 13:37:06 grumbel Exp $
+;;     $Id: units.ccl,v 1.40 2003/08/08 19:31:35 n0body Exp $
 
 ;; Load the animations for the units.
 (ccl:load "ccl/anim.ccl")
@@ -198,7 +198,7 @@
   'corpse '(unit-destroyed-3x3-place 0)
   'type-land
   'building
-  'gives-gold
+  'gives-resource 'gold 'can-harvest
   'sounds '(
     selected "gold-mine-selected"
     acknowledge "gold-mine-acknowledge"
@@ -222,7 +222,7 @@
   'priority 0
   'type-naval
   'building
-  'oil-patch
+  'gives-resource 'oil
   'sounds '(
     selected "oil-patch-selected"
     acknowledge "oil-patch-acknowledge"
Index: stratagus/doc/ChangeLog.html
diff -u stratagus/doc/ChangeLog.html:1.507 stratagus/doc/ChangeLog.html:1.508
--- stratagus/doc/ChangeLog.html:1.507  Fri Aug  8 06:16:43 2003
+++ stratagus/doc/ChangeLog.html        Fri Aug  8 15:31:36 2003
@@ -2,7 +2,7 @@
 <html>
 <head>
 <!--
-----   $Id: ChangeLog.html,v 1.507 2003/08/08 10:16:43 martinxyz Exp $
+----   $Id: ChangeLog.html,v 1.508 2003/08/08 19:31:36 n0body Exp $
 
 ----   (c) Copyright 1998-2003 by Lutz Sammer
 
@@ -35,13 +35,15 @@
 <ul>
 <li>Future 1.19 Release<p>
     <ul>
-    <li>+++
+    <li>++
+    <li>A lot of progress in resource configurability (from Crestez Dan 
Leonard).
     <li>Minimap panel can have its own palette now (from Martin Renold).
     <li>Simplified save/load, fewer things are now saved (from Martin Renold).
     <li>NEW_UI: Dropped of displaying the current unit action with the buttons 
(from Martin Renold).
     <li>NEW_UI: Dropped Alt-Buttons support (did anybody use this?) (from 
Martin Renold).
     <li>NEW_UI: Button actions are now custom scheme scripts (from Martin 
Renold).
     <li>NEW_UI: Added as compile time option (from Martin Renold).
+    <li>Added guile support as an alternative scheme interpretor (Fron Ingo 
Ruhnke).
     <li>Fixed loading games saved with different resolutions (from Martin 
Renold).
     <li>Removed spaces from data files (from Martin Renold).
     <li>Changed the handling of contained units to a circular linked list 
(from Crestez Dan Leonard).
Index: stratagus/src/action/action_build.c
diff -u stratagus/src/action/action_build.c:1.85 
stratagus/src/action/action_build.c:1.86
--- stratagus/src/action/action_build.c:1.85    Fri Aug  8 06:16:43 2003
+++ stratagus/src/action/action_build.c Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_build.c,v 1.85 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: action_build.c,v 1.86 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -230,7 +230,7 @@
     if( type->MustBuildOnTop ) {
        Unit* temp;
        if( (temp=UnitTypeOnMap(x,y,type->MustBuildOnTop)) ) {
-           build->Value=temp->Value;
+           build->Value=temp->Value;   // We capture the value of what is 
beneath.
            RemoveUnit(temp,NULL);      // Destroy building beneath
            UnitLost(temp);
            UnitClearOrders(temp);
@@ -274,21 +274,6 @@
     build->Wait=CYCLES_PER_SECOND/6;
     UpdateConstructionFrame(build);
 
-#if 0
-    //
-    // Building oil-platform, must remove oil-patch.
-    //
-    if( type->GivesOil ) {
-       Unit* temp;
-        DebugLevel0Fn("Remove oil-patch\n");
-       temp=OilPatchOnMap(x,y);
-       DebugCheck( !temp );
-       // FIXME: Johns: why the worker and not the construction?
-       unit->Value=temp->Value;        // Let worker hold value while building
-       // oil patch should NOT make sound, handled by let unit die
-       LetUnitDie(temp);               // Destroy oil patch
-    }
-#endif
     unit->Value=build->Value;          // worker holding value while building
 
     RemoveUnit(unit,build);            // automaticly: CheckUnitToBeDrawn(unit)
@@ -373,14 +358,18 @@
        worker->Reset=worker->Wait=1;
        DropOutOnSide(worker,LookingW,type->TileWidth,type->TileHeight);
        //
-       //      Building oil-platform, must update oil.
+       //      Whe
        //
-       if( type->GivesResource==OilCost ) {
-           CommandHaulOil(worker,unit,0);      // Let the unit haul oil
-           DebugLevel0Fn("Update oil-platform\n");
-           DebugLevel0Fn(" =%d\n" _C_ unit->Data.Resource.Active);
+       if( type->MustBuildOnTop ) {
+           // FIXME: nobody: shouldn't this be already 0?
+           // It holds the number of units inside a resource.
            unit->Data.Resource.Active=0;
-           unit->Value=worker->Value;  // worker holding value while building
+       }
+       //
+       //      If we can harvest from the new building, do it.
+       //
+       if 
(worker->Type->Harvester&&worker->Type->ResourceHarvested==type->GivesResource) 
{
+           CommandResource(worker,unit,0);
        }
        //
        //      Building lumber mill, let worker automatic chopping wood.
Index: stratagus/src/action/action_follow.c
diff -u stratagus/src/action/action_follow.c:1.27 
stratagus/src/action/action_follow.c:1.28
--- stratagus/src/action/action_follow.c:1.27   Fri Aug  8 06:16:43 2003
+++ stratagus/src/action/action_follow.c        Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_follow.c,v 1.27 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: action_follow.c,v 1.28 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -154,8 +154,8 @@
                }
 
                if( dest ) {
-                   if( (dest->NewOrder.Action==UnitActionHaulOil
-                               && !unit->Type->Tanker)
+                   if( (dest->NewOrder.Action==UnitActionResource
+                               && !unit->Type->Harvester  )
                            || (dest->NewOrder.Action==UnitActionAttack
                                && !unit->Type->CanAttack)
                            || (dest->NewOrder.Action==UnitActionBoard
Index: stratagus/src/action/action_harvest.c
diff -u stratagus/src/action/action_harvest.c:1.74 
stratagus/src/action/action_harvest.c:1.75
--- stratagus/src/action/action_harvest.c:1.74  Fri Aug  8 06:16:43 2003
+++ stratagus/src/action/action_harvest.c       Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_harvest.c,v 1.74 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: action_harvest.c,v 1.75 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -393,12 +393,7 @@
     }
     unit->Player->UnitTypesCount[unit->Type->Type]++;
 
-    if( WAIT_FOR_WOOD<MAX_UNIT_WAIT ) {
-       unit->Wait=WAIT_FOR_WOOD;
-    } else {
-       unit->Wait=MAX_UNIT_WAIT;
-    }
-    unit->Value=WAIT_FOR_WOOD-unit->Wait;
+    unit->Wait=WAIT_FOR_WOOD;
 
     return 1;
 }
@@ -414,41 +409,30 @@
 
     DebugLevel3Fn("Waiting\n");
 
-    if( !unit->Value ) {
-       //
-       //      Drop out unit at nearest point to target.
-       //
-       destu=ResourceDepositOnMap(unit->X,unit->Y,WoodCost);
-       DebugCheck( !destu );           // there must be a depot!
-
-       DropOutNearest(unit
-               ,unit->Orders[0].X,unit->Orders[0].Y
-               ,destu->Type->TileWidth,destu->Type->TileHeight);
+    //
+    // Drop out unit at nearest point to target.
+    //
+    destu=ResourceDepositOnMap(unit->X,unit->Y,WoodCost);
+    DebugCheck( !destu );              // there must be a depot!
 
-       //
-       //      Return to chop point.
-       //
-       DebugCheck( unit->Orders[0].Action!=UnitActionHarvest );
-       unit->Orders[0].Goal=NoUnitP;
-       unit->Orders[0].RangeX=unit->Orders[0].RangeY=0;
-       // NOTE: unit->Orders[0].X && unit->Orders[0].Y holds return place.
-       NewResetPath(unit);
-
-        CheckUnitToBeDrawn(unit);
-       unit->Wait=1;
-       //unit->Data.Harvest.WoodToHarvest=CHOP_FOR_WOOD;
-       unit->Value=CHOP_FOR_WOOD;
-       return 1;
-    }
+    DropOutNearest(unit
+           ,unit->Orders[0].X,unit->Orders[0].Y
+           ,destu->Type->TileWidth,destu->Type->TileHeight);
 
-    if( unit->Value<MAX_UNIT_WAIT ) {
-       unit->Wait=unit->Value;
-    } else {
-       unit->Wait=MAX_UNIT_WAIT;
-    }
-    unit->Value-=unit->Wait;
+    //
+    // Return to chop point.
+    //
+    DebugCheck( unit->Orders[0].Action!=UnitActionHarvest );
+    unit->Orders[0].Goal=NoUnitP;
+    unit->Orders[0].RangeX=unit->Orders[0].RangeY=0;
+    // NOTE: unit->Orders[0].X && unit->Orders[0].Y holds return place.
+    NewResetPath(unit);
 
-    return 0;
+    CheckUnitToBeDrawn(unit);
+    unit->Wait=1;
+    //unit->Data.Harvest.WoodToHarvest=CHOP_FOR_WOOD;
+    unit->Value=CHOP_FOR_WOOD;
+    return 1;
 }
 
 /**
Index: stratagus/src/action/action_minegold.c
diff -u stratagus/src/action/action_minegold.c:1.76 
stratagus/src/action/action_minegold.c:1.77
--- stratagus/src/action/action_minegold.c:1.76 Fri Aug  8 06:16:43 2003
+++ stratagus/src/action/action_minegold.c      Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_minegold.c,v 1.76 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: action_minegold.c,v 1.77 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -177,12 +177,7 @@
     unit->Y=destu->Y;
 #endif
 
-    if( MINE_FOR_GOLD<MAX_UNIT_WAIT ) {
-       unit->Wait=MINE_FOR_GOLD;
-    } else {
-       unit->Wait=MAX_UNIT_WAIT;
-    }
-    unit->Value=MINE_FOR_GOLD-unit->Wait;
+    unit->Wait=MINE_FOR_GOLD;
 
     return 1;
 }
@@ -201,145 +196,126 @@
 
     DebugLevel3Fn("Waiting\n");
 
-    if( !unit->Value ) {
-       //
-       //      Have gold
-       //
-       mine=GoldMineOnMap(unit->X,unit->Y);
-       IfDebug(
-           DebugLevel3Fn("Found %d,%d=%d\n" _C_ unit->X _C_ unit->Y _C_ 
UnitNumber(mine));
-           if( !mine ) {
-               DebugLevel0Fn("No unit? (%d,%d)\n" _C_ unit->X _C_ unit->Y);
-               abort();
-           } );
-
-       DebugCheck( mine->Value>655350 );
-
-       //
-       //      Update gold mine.
-       //
-       if( OptionUseDepletedMines
-               && mine->Value < DefaultIncomes[GoldCost] ) {
-           mine->Value = 0;
-           unit->Rs = OptionUseDepletedMines;
-           // vladi: income reduced to 5% (mine depleted)
-       } else {        // remove gold from store
-           mine->Value-=DefaultIncomes[GoldCost];
-           unit->Rs = 100;             // vladi: normal income 100%
-       }
-       if( !--mine->Data.Resource.Active ) {
-           mine->Frame=0;
-           CheckUnitToBeDrawn(mine);
-       }
-       UnitMarkSeen(mine);
-       if( IsOnlySelected(mine) ) {
-           MustRedraw|=RedrawInfoPanel;
-       }
+    //
+    // Have gold
+    //
+    mine=GoldMineOnMap(unit->X,unit->Y);
 
-       //
-       //      End of gold: destroy gold-mine.
-       //
-       if( !OptionUseDepletedMines && mine->Value<DefaultIncomes[GoldCost] ) {
-           Unit* table[UnitMax];
-           Unit* u;
-           Unit* destu;
-           int i;
-           int count;
-
-           DebugLevel0Fn("Mine destroyed %d,%d\n" _C_ mine->X _C_ mine->Y);
-
-           count=0;
-           for( i=0; i<NumUnits; ++i ) {
-               u=Units[i];
-               if( u!=unit && u->Removed && u->X==mine->X && u->Y==mine->Y ) {
-                   table[count++]=u;
-               }
-           }
+    DebugCheck( mine->Value>655350 );
 
-           DropOutAll(mine);
-           LetUnitDie(mine);
-           mine=NULL;
-
-           u=table[0];
-           if( count && (destu=FindGoldMine(u,u->X,u->Y)) ) {
-               for( i=0; i<count; ++i ) {
-                   u=table[i];
-                   u->Orders[0].Goal=destu;
-                   RefsDebugCheck( destu->Destroyed || !destu->Refs );
-                   ++destu->Refs;
-                   u->Orders[0].RangeX=unit->Orders[0].RangeY=1;
-                   u->Orders[0].X=-1;
-                   u->Orders[0].Y=-1;
-                   u->Orders[0].Action=UnitActionMineGold;
-                   CheckUnitToBeDrawn(u);
-               }
-           }
-       }
+    //
+    // Update gold mine.
+    //
+    if( OptionUseDepletedMines
+           && mine->Value < DefaultIncomes[GoldCost] ) {
+       mine->Value = 0;
+       unit->Rs = OptionUseDepletedMines;
+       // vladi: income reduced to 5% (mine depleted)
+    } else {   // remove gold from store
+       mine->Value-=DefaultIncomes[GoldCost];
+       unit->Rs = 100;         // vladi: normal income 100%
+    }
+    if( !--mine->Data.Resource.Active ) {
+       mine->Frame=0;
+       CheckUnitToBeDrawn(mine);
+    }
+    UnitMarkSeen(mine);
+    if( IsOnlySelected(mine) ) {
+       MustRedraw|=RedrawInfoPanel;
+    }
+
+    //
+    // End of gold: destroy gold-mine.
+    //
+    if( !OptionUseDepletedMines && mine->Value<DefaultIncomes[GoldCost] ) {
+       Unit* table[UnitMax];
+       Unit* u;
+       Unit* destu;
+       int i;
+       int count;
 
-       //      Store gold mine position
-       unit->Orders[0].Arg1=(void*)((unit->X<<16)|unit->Y);
+       DebugLevel0Fn("Mine destroyed %d,%d\n" _C_ mine->X _C_ mine->Y);
 
-       //
-       //      Find gold depot
-       //
-       if( !(destu=FindDeposit(unit->Player,unit->X,unit->Y,GoldCost)) ) {
-           if( mine ) {
-               DropOutOnSide(unit,LookingW
-                       ,mine->Type->TileWidth,mine->Type->TileHeight);
+       count=0;
+       for( i=0; i<NumUnits; ++i ) {
+           u=Units[i];
+           if( u!=unit && u->Removed && u->X==mine->X && u->Y==mine->Y ) {
+               table[count++]=u;
            }
-           unit->Orders[0].Action=UnitActionStill;
-           unit->SubAction=0;
-           DebugLevel2Fn("Mine without deposit\n");
-       } else {
-           if( mine ) {
-               DropOutNearest(unit,destu->X+destu->Type->TileWidth/2
-                       ,destu->Y+destu->Type->TileHeight/2
-                       ,mine->Type->TileWidth,mine->Type->TileHeight);
+       }
+
+       DropOutAll(mine);
+       LetUnitDie(mine);
+       mine=NULL;
+
+       u=table[0];
+       if( count && (destu=FindGoldMine(u,u->X,u->Y)) ) {
+           for( i=0; i<count; ++i ) {
+               u=table[i];
+               u->Orders[0].Goal=destu;
+               RefsDebugCheck( destu->Destroyed || !destu->Refs );
+               ++destu->Refs;
+               u->Orders[0].RangeX=unit->Orders[0].RangeY=1;
+               u->Orders[0].X=-1;
+               u->Orders[0].Y=-1;
+               u->Orders[0].Action=UnitActionMineGold;
+               CheckUnitToBeDrawn(u);
            }
-           unit->Orders[0].Goal=destu;
-           NewResetPath(unit);
-           RefsDebugCheck( destu->Destroyed || !destu->Refs );
-           ++destu->Refs;
-           unit->Orders[0].RangeX=unit->Orders[0].RangeY=1;
-           unit->Orders[0].X=unit->Orders[0].Y=-1;
-           unit->Orders[0].Action=UnitActionMineGold;
-           unit->SubAction=64;
-           DebugLevel3Fn("Mine with deposit %d,%d\n" _C_ destu->X _C_ 
destu->Y);
        }
+    }
 
-       //
-       //      Change unit outfit. (Unit type is used for this.)
-       //
-       unit->Player->UnitTypesCount[unit->Type->Type]--;
-       if( unit->Type==UnitTypeOrcWorker ) {
-           unit->Type=UnitTypeOrcWorkerWithGold;
-       } else if( unit->Type==UnitTypeHumanWorker ) {
-           unit->Type=UnitTypeHumanWorkerWithGold;
-       } else {
-           // FIXME: support workers for more races.
-           DebugLevel0Fn("Wrong unit (%d,%d) for mining gold %d (%s)\n"
-               _C_ unit->X _C_ unit->Y _C_ unit->Type->Type _C_ 
unit->Type->Name);
+    // Store gold mine position
+    unit->Orders[0].Arg1=(void*)((unit->X<<16)|unit->Y);
+
+    //
+    // Find gold depot
+    //
+    if( !(destu=FindDeposit(unit->Player,unit->X,unit->Y,GoldCost)) ) {
+       if( mine ) {
+           DropOutOnSide(unit,LookingW
+                   ,mine->Type->TileWidth,mine->Type->TileHeight);
        }
-       unit->Player->UnitTypesCount[unit->Type->Type]++;
-        CheckUnitToBeDrawn(unit);
-       if( unit->Selected ) {
-           SelectedUnitChanged();
+       unit->Orders[0].Action=UnitActionStill;
+       unit->SubAction=0;
+       DebugLevel2Fn("Mine without deposit\n");
+    } else {
+       if( mine ) {
+           DropOutNearest(unit,destu->X+destu->Type->TileWidth/2
+                   ,destu->Y+destu->Type->TileHeight/2
+                   ,mine->Type->TileWidth,mine->Type->TileHeight);
        }
-       unit->Wait=1;
-       return unit->SubAction;
+       unit->Orders[0].Goal=destu;
+       NewResetPath(unit);
+       RefsDebugCheck( destu->Destroyed || !destu->Refs );
+       ++destu->Refs;
+       unit->Orders[0].RangeX=unit->Orders[0].RangeY=1;
+       unit->Orders[0].X=unit->Orders[0].Y=-1;
+       unit->Orders[0].Action=UnitActionMineGold;
+       unit->SubAction=64;
+       DebugLevel3Fn("Mine with deposit %d,%d\n" _C_ destu->X _C_ destu->Y);
     }
 
     //
-    // Continue waiting
+    // Change unit outfit. (Unit type is used for this.)
     //
-    if( unit->Value<MAX_UNIT_WAIT ) {
-       unit->Wait=unit->Value;
+    unit->Player->UnitTypesCount[unit->Type->Type]--;
+    if( unit->Type==UnitTypeOrcWorker ) {
+       unit->Type=UnitTypeOrcWorkerWithGold;
+    } else if( unit->Type==UnitTypeHumanWorker ) {
+       unit->Type=UnitTypeHumanWorkerWithGold;
     } else {
-       unit->Wait=MAX_UNIT_WAIT;
+       // FIXME: support workers for more races.
+       DebugLevel0Fn("Wrong unit (%d,%d) for mining gold %d (%s)\n"
+               _C_ unit->X _C_ unit->Y _C_ unit->Type->Type _C_ 
unit->Type->Name);
     }
-    unit->Value-=unit->Wait;
-
-    return 0;
+    unit->Player->UnitTypesCount[unit->Type->Type]++;
+    CheckUnitToBeDrawn(unit);
+    if( unit->Selected ) {
+       SelectedUnitChanged();
+       UpdateButtonPanel();
+    }
+    unit->Wait=1;
+    return unit->SubAction;
 }
 
 /**
@@ -448,12 +424,7 @@
     }
     unit->Player->UnitTypesCount[unit->Type->Type]++;
 
-    if( WAIT_FOR_GOLD<MAX_UNIT_WAIT ) {
-       unit->Wait=WAIT_FOR_GOLD;
-    } else {
-       unit->Wait=MAX_UNIT_WAIT;
-    }
-    unit->Value=WAIT_FOR_GOLD-unit->Wait;
+    unit->Wait=WAIT_FOR_GOLD;
 
     return 1;
 }
@@ -472,51 +443,41 @@
     int x;
     int y;
 
-    DebugLevel3Fn("Waiting\n");
-    if( !unit->Value ) {
-       depot=ResourceDepositOnMap(unit->X,unit->Y,GoldCost);
-       DebugCheck( !depot );
-       // Could be destroyed, but than we couldn't be in?
-
-       // FIXME: Ari says, don't automatic search a new mine.
-       // Return to last position
-       if( unit->Orders[0].Arg1==(void*)-1 ) {
-           x=unit->X;
-           y=unit->Y;
-       } else {
-           x=(int)unit->Orders[0].Arg1>>16;
-           y=(int)unit->Orders[0].Arg1&0xFFFF;
-       }
-       if( !(destu=FindGoldMine(unit,x,y)) ) {
-           DropOutOnSide(unit,LookingW
-                   ,depot->Type->TileWidth,depot->Type->TileHeight);
-           unit->Orders[0].Action=UnitActionStill;
-           unit->SubAction=0;
-       } else {
-           DropOutNearest(unit,destu->X+destu->Type->TileWidth/2
-                   ,destu->Y+destu->Type->TileHeight/2
-                   ,depot->Type->TileWidth,depot->Type->TileHeight);
-           unit->Orders[0].Goal=destu;
-           RefsDebugCheck( destu->Destroyed || !destu->Refs );
-           ++destu->Refs;
-           unit->Orders[0].RangeX=unit->Orders[0].RangeY=1;
-           unit->Orders[0].X=-1;
-           unit->Orders[0].Y=-1;
-           unit->Orders[0].Action=UnitActionMineGold;
-       }
-
-        CheckUnitToBeDrawn(unit);
-       unit->Wait=1;
-       unit->SubAction=0;
-       return 1;
+    depot=ResourceDepositOnMap(unit->X,unit->Y,GoldCost);
+    DebugCheck( !depot );
+    // Could be destroyed, but than we couldn't be in?
+
+    // FIXME: Ari says, don't automatic search a new mine.
+    // Return to last position
+    if( unit->Orders[0].Arg1==(void*)-1 ) {
+       x=unit->X;
+       y=unit->Y;
+    } else {
+       x=(int)unit->Orders[0].Arg1>>16;
+       y=(int)unit->Orders[0].Arg1&0xFFFF;
     }
-    if( unit->Value<MAX_UNIT_WAIT ) {
-       unit->Wait=unit->Value;
+    if( !(destu=FindGoldMine(unit,x,y)) ) {
+       DropOutOnSide(unit,LookingW
+               ,depot->Type->TileWidth,depot->Type->TileHeight);
+       unit->Orders[0].Action=UnitActionStill;
+       unit->SubAction=0;
     } else {
-       unit->Wait=MAX_UNIT_WAIT;
+       DropOutNearest(unit,destu->X+destu->Type->TileWidth/2
+               ,destu->Y+destu->Type->TileHeight/2
+               ,depot->Type->TileWidth,depot->Type->TileHeight);
+       unit->Orders[0].Goal=destu;
+       RefsDebugCheck( destu->Destroyed || !destu->Refs );
+       ++destu->Refs;
+       unit->Orders[0].RangeX=unit->Orders[0].RangeY=1;
+       unit->Orders[0].X=-1;
+       unit->Orders[0].Y=-1;
+       unit->Orders[0].Action=UnitActionMineGold;
     }
-    unit->Value-=unit->Wait;
-    return 0;
+
+    CheckUnitToBeDrawn(unit);
+    unit->Wait=1;
+    unit->SubAction=0;
+    return 1;
 }
 
 /**
Index: stratagus/src/action/action_resource.c
diff -u stratagus/src/action/action_resource.c:1.42 
stratagus/src/action/action_resource.c:1.43
--- stratagus/src/action/action_resource.c:1.42 Fri Aug  8 06:16:43 2003
+++ stratagus/src/action/action_resource.c      Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_resource.c,v 1.42 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: action_resource.c,v 1.43 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -49,25 +49,13 @@
 --     Declarations
 ----------------------------------------------------------------------------*/
 
-/**
-**     Helper structure for getting resources.
-**     FIXME: later we should make this configurable, to allow game
-**     FIXME: designers to create own resources.
-*/
-typedef struct _resource_ {
-    unsigned char Action;              /// Unit action.
-    int        Frame;                          /// Frame for active resource
-    Unit* (*ResourceOnMap)(int,int);   /// Get the resource on map.
-    int Cost;                          /// Resource type
-    UnitType** Human;                  /// Human worker
-    UnitType** HumanWithResource;      /// Human worker with resource
-    UnitType** Orc;                    /// Orc worker
-    UnitType** OrcWithResource;                /// Orc worker with resource
-
-    int        GetTime;                        /// Time to get the resource
-    int        PutTime;                        /// Time to store the resource
-
-} Resource;
+#define SUB_START_RESOURCE 0
+#define SUB_MOVE_TO_RESOURCE 1
+#define SUB_UNREACHABLE_RESOURCE 31
+#define SUB_GATHER_RESOURCE 60
+#define SUB_MOVE_TO_DEPOT 70
+#define SUB_UNREACHABLE_DEPOT 100
+#define SUB_RETURN_RESOURCE 120
 
 /*----------------------------------------------------------------------------
 --     Functions
@@ -77,11 +65,10 @@
 **     Move unit to resource.
 **
 **     @param unit     Pointer to unit.
-**     @param resource How to handle the resource.
 **
 **     @return         TRUE if reached, otherwise FALSE.
 */
-local int MoveToResource(Unit* unit,const Resource* resource)
+local int MoveToResource(Unit* unit)
 {
     Unit* goal;
 
@@ -90,7 +77,6 @@
 
     switch( DoActionMove(unit) ) {     // reached end-point?
        case PF_UNREACHABLE:
-           DebugCheck( unit->Orders[0].Action!=resource->Action );
            return -1;
        case PF_REACHED:
            break;
@@ -106,7 +92,7 @@
     // Target is dead, stop getting resources.
     //
     if( goal->Destroyed ) {
-       DebugLevel0Fn("Destroyed unit\n");
+       DebugLevel0Fn("Destroyed resource goal, stop gathering.\n");
        RefsDebugCheck( !goal->Refs );
        if( !--goal->Refs ) {
            ReleaseUnit(goal);
@@ -132,7 +118,6 @@
     DebugCheck( MapDistanceToUnit(unit->X,unit->Y,goal)>1 );
 
     DebugCheck( unit->Wait!=1 );
-    DebugCheck( unit->Orders[0].Action!=resource->Action );
 
     //
     // If resource is still under construction, wait!
@@ -154,7 +139,7 @@
     DebugLevel3Fn("+%d\n" _C_ goal->Data.Resource.Active);
 
     if( !goal->Frame ) {               // show resource working
-       goal->Frame=resource->Frame;
+       goal->Frame=2;
        CheckUnitToBeDrawn(goal);
     }
     UnitMarkSeen(goal);
@@ -162,42 +147,14 @@
     // Place unit inside the resource
     //
     RemoveUnit(unit,goal);
-#if 0
-    // This breaks the drop out code complete
-    // FIXME: this is a hack, but solves the problem, a better solution is
-    // FIXME: still wanted.
-
-    // Place unit where pathfinder is more likely to work
-    if (unit->X < goal->X) {
-       PlaceUnit(unit,goal->X,unit->Y);
-       RemoveUnit(unit,NULL);  // Unit removal necessary to free map tiles
-    }
-    if (unit->X > goal->X+goal->Type->TileWidth-1) {
-       PlaceUnit(unit,goal->X+goal->Type->TileWidth-1,unit->Y);
-       RemoveUnit(unit,NULL);
-    }
-    if (unit->Y < goal->Y) {
-       PlaceUnit(unit,unit->X,goal->Y);
-       RemoveUnit(unit,NULL);
-    }
-    if (unit->Y > goal->Y+goal->Type->TileHeight-1) {
-       PlaceUnit(unit,unit->X,goal->Y+goal->Type->TileHeight-1);
-       RemoveUnit(unit,NULL);
-    }
-#else
     unit->X=goal->X;
     unit->Y=goal->Y;
-#endif
 
-    //
-    // Time to collect the resource.
-    //
-    if( resource->GetTime<MAX_UNIT_WAIT ) {
-       unit->Wait=resource->GetTime;
+    if (unit->Type->WaitAtResource) {
+       unit->Wait=unit->Type->WaitAtResource;
     } else {
-       unit->Wait=MAX_UNIT_WAIT;
+       unit->Wait=1;
     }
-    unit->Value=resource->GetTime-unit->Wait;
 
     return 1;
 }
@@ -206,134 +163,109 @@
 **     Wait in resource, for collecting the resource.
 **
 **     @param unit     Pointer to unit.
-**     @param resource How to handle the resource.
 **
 **     @return         TRUE if ready, otherwise FALSE.
 */
-local int WaitInResource(Unit* unit,const Resource* resource)
+local int WaitInResource(Unit* unit)
 {
     Unit* source;
     Unit* depot;
 
-    DebugLevel3Fn("Waiting\n");
+    //
+    // Have the resource
+    //
+    source=unit->Container;
 
-    if( !unit->Value ) {
-       //
-       //      Have the resource
-       //
-       source=resource->ResourceOnMap(unit->X,unit->Y);
-       IfDebug(
-           DebugLevel3Fn("Found %d,%d=%d\n" _C_ unit->X _C_ unit->Y
-               _C_ UnitNumber(source));
-           if( !source ) {
-               DebugLevel0Fn("No unit? (%d,%d)\n" _C_ unit->X _C_ unit->Y);
-               abort();
-           } );
-
-       DebugCheck( source->Value>655350 );
-
-       //
-       //      Update the resource.
-       //      Remove what we can carry, FIXME: always this?
-       //
-       source->Value-=DefaultIncomes[resource->Cost];
-
-       DebugLevel3Fn("-%d\n" _C_ source->Data.Resource.Active);
-       if( !--source->Data.Resource.Active ) {
-           source->Frame=0;
-           CheckUnitToBeDrawn(source);
-       }
-       UnitMarkSeen(source);
-       if( IsOnlySelected(source) ) {
-           MustRedraw|=RedrawInfoPanel;
-       }
+    DebugCheck( !source );
+    DebugCheck( source->Value>655350 );
 
-       //
-       //      End of resource: destroy the resource.
-       //
-       if( source->Value<DefaultIncomes[resource->Cost] ) {
-           DebugLevel0Fn("Resource is destroyed\n");
-           DropOutAll(source);
-           LetUnitDie(source);
-           source=NULL;
-       }
+    //
+    // Update the resource. FIXME: depleted resources.
+    //
+    if (source->Value<unit->Type->ResourceCapacity) {
+       // Uhh-oh, depleted.
+       unit->Value=source->Value;
+       source->Value=0;
+    } else {
+       unit->Value=unit->Type->ResourceCapacity;
+       source->Value-=unit->Type->ResourceCapacity;
+    }
+    
+    if( !--source->Data.Resource.Active ) {
+       source->Frame=0;
+       CheckUnitToBeDrawn(source);
+    }
+    
+    UnitMarkSeen(source);
+    if( IsOnlySelected(source) ) {
+       MustRedraw|=RedrawInfoPanel;
+    }
 
-       //
-       //      Change unit to full state. FIXME: more races
-       //
+    //
+    // Change unit to full state.
+    //
+    if( unit->Type->TransformWhenLoaded ) {
        unit->Player->UnitTypesCount[unit->Type->Type]--;
-       if( unit->Type==*resource->Human ) {
-           unit->Type=*resource->HumanWithResource;
-       } else if( unit->Type==*resource->Orc ) {
-           unit->Type=*resource->OrcWithResource;
-       } else {
-           // FIXME: should support more races
-           DebugLevel0Fn("Wrong unit-type `%s' for resource `%s'\n"
-               _C_ unit->Type->Ident _C_ DefaultResourceNames[resource->Cost]);
-       }
-       unit->Player->UnitTypesCount[unit->Type->Type]++;
-
-       //      Store gold mine position
-       unit->Orders[0].Arg1=(void*)((unit->X<<16)|unit->Y);
-
-       //
-       //      Find and send to resource deposit.
-       //
-       if( !(depot=FindDeposit(unit->Player,unit->X,unit->Y,resource->Cost)) ) 
{
-           if( source ) {
-               DropOutOnSide(unit,LookingW
-                   ,source->Type->TileWidth,source->Type->TileHeight);
-           }
-           unit->Orders[0].Action=UnitActionStill;
-           unit->SubAction=0;
-           // should return 0, done below!
-       } else {
-           if( source ) {
-               DropOutNearest(unit,depot->X+depot->Type->TileWidth/2
-                   ,depot->Y+depot->Type->TileHeight/2
-                   ,source->Type->TileWidth,source->Type->TileHeight);
-           }
-           unit->Orders[0].Goal=depot;
-           RefsDebugCheck( !depot->Refs );
-           ++depot->Refs;
-           unit->Orders[0].RangeX=unit->Orders[0].RangeY=1;
-           unit->Orders[0].X=unit->Orders[0].Y=-1;
-           unit->Orders[0].Action=resource->Action;
-           unit->SubAction=64;
-           NewResetPath(unit);
-       }
-
-        CheckUnitToBeDrawn(unit);
-       if( IsOnlySelected(unit) ) {
-           SelectedUnitChanged();
-           // FIXME: redundant?
-           MustRedraw|=RedrawButtonPanel;
-       }
-       unit->Wait=1;
-       return unit->Orders[0].Action==resource->Action;
+       unit->Type=unit->Type->TransformWhenLoaded;
+       unit->Player->UnitTypesCount[unit->Type->Type]++;
     }
 
+    // Store resource position.
+    unit->Orders[0].Arg1=(void*)((unit->X<<16)|unit->Y);
+    
     //
-    // Continue waiting
+    // Find and send to resource deposit.
     //
-    if( unit->Value<MAX_UNIT_WAIT ) {
-       unit->Wait=unit->Value;
+    if( 
!(depot=FindDeposit(unit->Player,unit->X,unit->Y,unit->Type->ResourceHarvested))
 ) {
+       DropOutOnSide(unit,LookingW
+               ,source->Type->TileWidth,source->Type->TileHeight);
+       DebugLevel0Fn("Can't find a resource deposit.\n");
+       unit->Orders[0].Action=UnitActionStill;
+       unit->SubAction=0;
+       // should return 0, done below!
     } else {
-       unit->Wait=MAX_UNIT_WAIT;
+       DropOutNearest(unit,depot->X+depot->Type->TileWidth/2
+               ,depot->Y+depot->Type->TileHeight/2
+               ,source->Type->TileWidth,source->Type->TileHeight);
+       unit->Orders[0].Goal=depot;
+       RefsDebugCheck( !depot->Refs );
+       ++depot->Refs;
+       unit->Orders[0].RangeX=unit->Orders[0].RangeY=1;
+       unit->Orders[0].X=unit->Orders[0].Y=-1;
+       unit->Orders[0].X=unit->Orders[0].Y=-1;
+       unit->SubAction=SUB_MOVE_TO_DEPOT;
+       NewResetPath(unit);
+    }
+    
+    //
+    // End of resource: destroy the resource.
+    //
+    if( source->Value==0 ) {
+       DebugLevel0Fn("Resource is destroyed\n");
+       DropOutAll(source);
+       LetUnitDie(source);
+       source=NULL;
+    }
+
+    CheckUnitToBeDrawn(unit);
+    if( IsOnlySelected(unit) ) {
+       UpdateButtonPanel();
+       SelectedUnitChanged();
+       // FIXME: redundant?
+       MustRedraw|=RedrawButtonPanel;
     }
-    unit->Value-=unit->Wait;
-    return 0;
+    unit->Wait=1;
+    return unit->Orders[0].Action!=UnitActionStill;
 }
 
 /**
 **     Move to resource depot
 **
 **     @param unit     Pointer to unit.
-**     @param resource How to handle the resource.
 **
 **     @return         TRUE if reached, otherwise FALSE.
 */
-local int MoveToDepot(Unit* unit,const Resource* resource)
+local int MoveToDepot(Unit* unit)
 {
     Unit* goal;
 
@@ -342,7 +274,6 @@
 
     switch( DoActionMove(unit) ) {     // reached end-point?
        case PF_UNREACHABLE:
-           DebugCheck( unit->Orders[0].Action!=resource->Action );
            return -1;
        case PF_REACHED:
            break;
@@ -383,13 +314,12 @@
     DebugCheck( MapDistanceToUnit(unit->X,unit->Y,goal)!=1 );
 
     DebugCheck( unit->Wait!=1 );
-    DebugCheck( unit->Orders[0].Action!=resource->Action );
 
     //
-    // If resource is still under construction, wait!
+    // If resource depot is still under construction, wait!
     //
     if( goal->Orders[0].Action==UnitActionBuilded ) {
-        DebugLevel2Fn("Invalid resource\n");
+        DebugLevel2Fn("Invalid resource depot. FIXME:WAIT!!! \n");
        return 0;
     }
 
@@ -408,37 +338,28 @@
     //
     // Update resource.
     //
-    unit->Player->Resources[resource->Cost]
-       +=unit->Player->Incomes[resource->Cost];
-    unit->Player->TotalResources[resource->Cost]
-       +=unit->Player->Incomes[resource->Cost];
+    unit->Player->Resources[unit->Type->ResourceHarvested]+=
+       (unit->Value*unit->Player->Incomes[unit->Type->ResourceHarvested])/100;
+    unit->Player->TotalResources[unit->Type->ResourceHarvested]+=
+       (unit->Value*unit->Player->Incomes[unit->Type->ResourceHarvested])/100;
     if( unit->Player==ThisPlayer ) {
        MustRedraw|=RedrawResources;
     }
 
     //
-    // Change unit to empty state. FIXME: more races
+    // Change unit to empty state.
     //
-    unit->Player->UnitTypesCount[unit->Type->Type]--;
-    if( unit->Type==*resource->HumanWithResource ) {
-       unit->Type=*resource->Human;
-    } else if( unit->Type==*resource->OrcWithResource ) {
-       unit->Type=*resource->Orc;
-    } else {
-       DebugLevel0Fn("Wrong unit-type `%s' for resource `%s'\n"
-           _C_ unit->Type->Ident _C_ DefaultResourceNames[resource->Cost]);
+    if( unit->Type->TransformWhenEmpty ) {
+       unit->Player->UnitTypesCount[unit->Type->Type]--;
+       unit->Type=unit->Type->TransformWhenEmpty;
+       unit->Player->UnitTypesCount[unit->Type->Type]++;
     }
-    unit->Player->UnitTypesCount[unit->Type->Type]++;
 
-    //
-    // Time to store the resource.
-    //
-    if( resource->PutTime<MAX_UNIT_WAIT ) {
-       unit->Wait=resource->PutTime;
+    if (unit->Type->WaitAtDepot) {
+       unit->Wait=unit->Type->WaitAtDepot;
     } else {
-       unit->Wait=MAX_UNIT_WAIT;
+       unit->Wait=1;
     }
-    unit->Value=resource->PutTime-unit->Wait;
     return 1;
 }
 
@@ -446,63 +367,65 @@
 **     Wait in depot, for the resources stored.
 **
 **     @param unit     Pointer to unit.
-**     @param resource How to handle the resource.
 **
 **     @return         TRUE if ready, otherwise FALSE.
 */
-local int WaitInDepot(Unit* unit,const Resource* resource)
+local int WaitInDepot(Unit* unit)
 {
     const Unit* depot;
     Unit* goal;
     int x;
     int y;
 
-    DebugLevel3Fn("Waiting\n");
-    if( !unit->Value ) {
-       depot=ResourceDepositOnMap(unit->X,unit->Y,resource->Cost);
-       DebugCheck( !depot );
-       // Could be destroyed, but than we couldn't be in?
-
-       if( unit->Orders[0].Arg1==(void*)-1 ) {
-           x=unit->X;
-           y=unit->Y;
-       } else {
-           x=(int)unit->Orders[0].Arg1>>16;
-           y=(int)unit->Orders[0].Arg1&0xFFFF;
-       }
-       if( !(goal=FindOilPlatform(unit->Player,x,y)) ) {
-           DropOutOnSide(unit,LookingW,
-                   depot->Type->TileWidth,depot->Type->TileHeight);
-           unit->Orders[0].Action=UnitActionStill;
-           unit->SubAction=0;
-       } else {
-           DropOutNearest(unit,goal->X+goal->Type->TileWidth/2
-                   ,goal->Y+goal->Type->TileHeight/2
-                   ,depot->Type->TileWidth,depot->Type->TileHeight);
-           unit->Orders[0].Goal=goal;
-           RefsDebugCheck( !goal->Refs );
-           ++goal->Refs;
-           unit->Orders[0].RangeX=unit->Orders[0].RangeY=1;
-           unit->Orders[0].X=unit->Orders[0].Y=-1;
-           unit->Orders[0].Action=resource->Action;
-           NewResetPath(unit);
-       }
-
-        CheckUnitToBeDrawn(unit);
-       unit->Wait=1;
-       return unit->Orders[0].Action==resource->Action;
+    depot=ResourceDepositOnMap(unit->X,unit->Y,unit->Type->ResourceHarvested);
+    DebugCheck( !depot );
+    // Could be destroyed, but then we couldn't be in?
+
+    if( unit->Orders[0].Arg1==(void*)-1 ) {
+       x=unit->X;
+       y=unit->Y;
+    } else {
+       x=(int)unit->Orders[0].Arg1>>16;
+       y=(int)unit->Orders[0].Arg1&0xFFFF;
     }
-
-    //
-    // Continue waiting
-    //
-    if( unit->Value<MAX_UNIT_WAIT ) {
-       unit->Wait=unit->Value;
+    if( !(goal=FindResource(unit->Player,x,y,unit->Type->ResourceHarvested)) ) 
{
+       DropOutOnSide(unit,LookingW,
+               depot->Type->TileWidth,depot->Type->TileHeight);
+       unit->Orders[0].Action=UnitActionStill;
+       unit->SubAction=0;
     } else {
-       unit->Wait=MAX_UNIT_WAIT;
+       DropOutNearest(unit,goal->X+goal->Type->TileWidth/2
+               ,goal->Y+goal->Type->TileHeight/2
+               ,depot->Type->TileWidth,depot->Type->TileHeight);
+       unit->Orders[0].Goal=goal;
+       RefsDebugCheck( !goal->Refs );
+       ++goal->Refs;
+       unit->Orders[0].RangeX=unit->Orders[0].RangeY=1;
+       unit->Orders[0].X=unit->Orders[0].Y=-1;
+       NewResetPath(unit);
+    }
+
+    CheckUnitToBeDrawn(unit);
+    unit->Wait=1;
+    return unit->Orders[0].Action!=UnitActionStill;
+}
+
+/**
+**     Give up on gathering.
+**
+**     @param unit     Pointer to unit.
+*/
+void ResourceGiveUp(Unit* unit)
+{
+    unit->Orders[0].Action=UnitActionStill;
+    unit->Wait=1;
+    unit->SubAction=0;
+    if( unit->Orders[0].Goal ) {
+       RefsDebugCheck( !unit->Orders[0].Goal->Refs );
+       --unit->Orders[0].Goal->Refs;
+       RefsDebugCheck( !unit->Orders[0].Goal->Refs );
+       unit->Orders[0].Goal=NoUnitP;
     }
-    unit->Value-=unit->Wait;
-    return 0;
 }
 
 /**
@@ -511,133 +434,69 @@
 **     This the generic function for oil, gold, ...
 **
 **     @param unit     Pointer to unit.
-**     @param resource How to handle the resource.
 */
-global void HandleActionResource(Unit* unit,const Resource* resource)
+global void HandleActionResource(Unit* unit)
 {
     int ret;
 
     DebugLevel3Fn("%s(%d) SubAction %d\n"
        _C_ unit->Type->Ident _C_ UnitNumber(unit) _C_ unit->SubAction);
 
-    switch( unit->SubAction ) {
-       //
-       //      Move to the resource
-       //
-       case 0:
-           NewResetPath(unit);
-           unit->SubAction=1;
-           // FALL THROUGH
-       case 1:
-       case 2:
-       case 3:
-       case 4:
-           if( (ret=MoveToResource(unit,resource)) ) {
-               if( ret==-1 ) {
-                   if( ++unit->SubAction==5 ) {
-                       unit->Orders[0].Action=UnitActionStill;
-                       unit->SubAction=0;
-                       if( unit->Orders[0].Goal ) {
-                           RefsDebugCheck( !unit->Orders[0].Goal->Refs );
-                           --unit->Orders[0].Goal->Refs;
-                           RefsDebugCheck( !unit->Orders[0].Goal->Refs );
-                           unit->Orders[0].Goal=NoUnitP;
-                       }
-                   } else {                    // Do a little delay
-                       unit->Wait*=unit->SubAction;
-                       DebugLevel0Fn("Retring\n");
-                   }
-               } else {
-                   unit->SubAction=64;
-               }
+    if ( unit->SubAction==SUB_START_RESOURCE ) {
+       NewResetPath(unit);
+       unit->SubAction=1;
+    }
+    
+    if ( unit->SubAction>=SUB_MOVE_TO_RESOURCE && 
unit->SubAction<SUB_UNREACHABLE_RESOURCE ) {
+       // -1 failure, 0 not yet reached, 1 reached
+       if( (ret=MoveToResource(unit)) ) {
+           if( ret==-1 ) {
+               // Can't Reach
+               unit->SubAction++;
+               unit->Wait=10;
+           } else {
+               unit->SubAction=SUB_GATHER_RESOURCE;
            }
-           break;
+       }
+       return;
+    }
 
-       //
-       //      Wait for collecting the resource
-       //
-       case 64:
-           if( WaitInResource(unit,resource) ) {
-               ++unit->SubAction;
-           }
-           break;
+    if (unit->SubAction==SUB_UNREACHABLE_RESOURCE) {
+       return;
+       ResourceGiveUp(unit);
+    }
 
-       //
-       //      Return to the resource depot
-       //
-       case 65:
-       case 66:
-       case 67:
-       case 68:
-       case 69:
-           if( (ret=MoveToDepot(unit,resource)) ) {
-               if( ret==-1 ) {
-                   if( ++unit->SubAction==70 ) {
-                       unit->Orders[0].Action=UnitActionStill;
-                       unit->SubAction=0;
-                       if( unit->Orders[0].Goal ) {
-                           RefsDebugCheck( !unit->Orders[0].Goal->Refs );
-                           --unit->Orders[0].Goal->Refs;
-                           RefsDebugCheck( !unit->Orders[0].Goal->Refs );
-                           unit->Orders[0].Goal=NoUnitP;
-                       }
-                   } else {                    // Do a little delay
-                       unit->Wait*=unit->SubAction-65;
-                       DebugLevel0Fn("Retring\n");
-                   }
-               } else {
-                   unit->SubAction=128;
-               }
-           }
-           break;
+    if (unit->SubAction==SUB_GATHER_RESOURCE) {
+       if( WaitInResource(unit) ) {
+           unit->SubAction=SUB_MOVE_TO_DEPOT;
+       }
+    }
 
-       //
-       //      Wait for resource stored
-       //
-       case 128:
-           if( WaitInDepot(unit,resource) ) {
-               unit->SubAction=0;
+    if 
(unit->SubAction>=SUB_MOVE_TO_DEPOT&&unit->SubAction<SUB_UNREACHABLE_DEPOT) {
+       // -1 failure, 0 not yet reached, 1 reached
+       if( (ret=MoveToDepot(unit)) ) {
+           if( ret==-1 ) {
+               // Can't Reach
+               unit->SubAction++;
+               unit->Wait=10;
+           } else {
+               unit->SubAction=SUB_RETURN_RESOURCE;
            }
-           break;
+       }
+       return;
     }
-}
-
-/*----------------------------------------------------------------------------
---     High level
-----------------------------------------------------------------------------*/
-
-/**
-**     The oil resource.
-*/
-local Resource ResourceOil[1] = {
-{
-    UnitActionHaulOil,
-    2,                                 // FIXME: hardcoded.
-    PlatformOnMap,
-    OilCost,
-    // FIXME: The & could be removed.
-    &UnitTypeHumanTanker,
-    &UnitTypeHumanTankerFull,
-    &UnitTypeOrcTanker,
-    &UnitTypeOrcTankerFull,
-
-    0,                                 // Must be initialized
-    0,                                 // Must be initialized
-}
-};
 
-/**
-**     Control the unit action haul oil
-**
-**     @param unit     Pointer to unit.
-*/
-global void HandleActionHaulOil(Unit* unit)
-{
-    // FIXME: move into init function, debug could change this values.
-    ResourceOil->GetTime=HAUL_FOR_OIL;
-    ResourceOil->PutTime=WAIT_FOR_OIL;
+    if (unit->SubAction==SUB_UNREACHABLE_DEPOT) {
+       ResourceGiveUp(unit);
+       return;
+    }
 
-    HandleActionResource(unit,ResourceOil);
+    if (unit->SubAction==SUB_RETURN_RESOURCE) {
+       if( WaitInDepot(unit) ) {
+           unit->SubAction=SUB_START_RESOURCE;
+       }
+       return;
+    }
 }
 
 //@}
Index: stratagus/src/action/action_returngoods.c
diff -u stratagus/src/action/action_returngoods.c:1.34 
stratagus/src/action/action_returngoods.c:1.35
--- stratagus/src/action/action_returngoods.c:1.34      Fri Jul 11 10:35:29 2003
+++ stratagus/src/action/action_returngoods.c   Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_returngoods.c,v 1.34 2003/07/11 14:35:29 n0body Exp $
+//     $Id: action_returngoods.c,v 1.35 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -112,9 +112,9 @@
        return;
     }
 
-    if( type==UnitTypeHumanTankerFull || type==UnitTypeOrcTankerFull ) {
+    if( type->Harvester ) {
        if( !unit->Orders[0].Goal ) {
-           if( !(destu=FindDeposit(unit->Player,unit->X,unit->Y,OilCost)) ) {
+           if( 
!(destu=FindDeposit(unit->Player,unit->X,unit->Y,type->ResourceHarvested)) ) {
                // No deposit -> can't return
                unit->Orders[0].Action=UnitActionStill;
                return;
@@ -126,17 +126,16 @@
        DebugLevel3("Return to %d=%d,%d\n"
                _C_ UnitNumber(unit->Orders[0].Goal)
                _C_ unit->Orders[0].X _C_ unit->Orders[0].Y);
-       unit->Orders[0].Action=UnitActionHaulOil;
+       unit->Orders[0].Action=UnitActionResource;
+       // Somewhere on the way the loaded worker changed Arg1.
+       // Bummer, go get the closest resource to the depot
        unit->Orders[0].Arg1=(void*)-1;
        NewResetPath(unit);
-       unit->SubAction=65;             // FIXME: Hardcoded
-       DebugLevel3("Wait: %d\n" _C_ unit->Wait);
+       unit->SubAction=70;
        unit->Wait=1;
        return;
     }
 
-    // FIXME: return of more resources.
-    // FIXME: some general method for this?
 }
 
 //@}
Index: stratagus/src/action/action_train.c
diff -u stratagus/src/action/action_train.c:1.53 
stratagus/src/action/action_train.c:1.54
--- stratagus/src/action/action_train.c:1.53    Fri Aug  8 06:16:43 2003
+++ stratagus/src/action/action_train.c Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_train.c,v 1.53 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: action_train.c,v 1.54 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -151,8 +151,8 @@
        //
        //      FIXME: we must check if the units supports the new order.
        //
-       if( (unit->NewOrder.Action==UnitActionHaulOil
-               && !nunit->Type->Tanker)
+       if( (unit->NewOrder.Action==UnitActionResource
+               && !nunit->Type->Harvester)
            || (unit->NewOrder.Action==UnitActionAttack
                && !nunit->Type->CanAttack)
             || ((unit->NewOrder.Action==UnitActionMineGold
Index: stratagus/src/action/actions.c
diff -u stratagus/src/action/actions.c:1.83 stratagus/src/action/actions.c:1.84
--- stratagus/src/action/actions.c:1.83 Fri Aug  8 06:16:43 2003
+++ stratagus/src/action/actions.c      Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: actions.c,v 1.83 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: actions.c,v 1.84 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -179,7 +179,7 @@
     HandleActionNotWritten,    // HandleActionMineOre,
     HandleActionNotWritten,    // HandleActionMineCoal,
     HandleActionNotWritten,    // HandleActionQuarryStone,
-    HandleActionHaulOil,
+    HandleActionResource,
     HandleActionReturnGoods,
     HandleActionDemolish,
 
Index: stratagus/src/action/command.c
diff -u stratagus/src/action/command.c:1.95 stratagus/src/action/command.c:1.96
--- stratagus/src/action/command.c:1.95 Fri Aug  8 06:16:43 2003
+++ stratagus/src/action/command.c      Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: command.c,v 1.95 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: command.c,v 1.96 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -798,7 +798,7 @@
 **     @param dest     destination unit.
 **     @param flush    if true, flush command queue.
 */
-global void CommandHaulOil(Unit* unit,Unit* dest,int flush)
+global void CommandResource(Unit* unit,Unit* dest,int flush)
 {
     Order* order;
 
@@ -825,7 +825,7 @@
            return;
        }
 
-       order->Action=UnitActionHaulOil;
+       order->Action=UnitActionResource;
        order->X=order->Y=-1;
        order->Goal=dest;
        RefsDebugCheck( !dest->Refs );
Index: stratagus/src/ai/ai_resource.c
diff -u stratagus/src/ai/ai_resource.c:1.59 stratagus/src/ai/ai_resource.c:1.60
--- stratagus/src/ai/ai_resource.c:1.59 Fri Aug  1 15:30:36 2003
+++ stratagus/src/ai/ai_resource.c      Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_resource.c,v 1.59 2003/08/01 19:30:36 grumbel Exp $
+//      $Id: ai_resource.c,v 1.60 2003/08/08 19:31:36 n0body Exp $
 
 #ifdef NEW_AI  // {
 
@@ -1190,7 +1190,7 @@
     Unit *dest;
 
     DebugLevel3Fn("%d\n" _C_ UnitNumber(unit));
-    dest = FindOilPlatform(unit->Player, unit->X, unit->Y);
+    dest = FindResource(unit->Player, unit->X, unit->Y 
,unit->Type->ResourceHarvested);
     if (!dest) {
        DebugLevel0Fn("oil platform not reachable by %s(%d,%d)\n"
                _C_ unit->Type->Ident _C_ unit->X _C_ unit->Y);
@@ -1199,7 +1199,7 @@
     DebugCheck(unit->Type!=UnitTypeHumanTanker
            && unit->Type!=UnitTypeOrcTanker);
 
-    CommandHaulOil(unit, dest,FlushCommands);
+    CommandResource(unit, dest,FlushCommands);
 
     return 1;
 }
@@ -1248,7 +1248,7 @@
     units=AiPlayer->Player->Units;
     for( i=0; i<n; i++ ) {
        unit=units[i];
-       if( !unit->Type->CowerWorker && !unit->Type->Tanker ) {
+       if( !unit->Type->CowerWorker && !unit->Type->Harvester ) {
            continue;
        }
 
@@ -1262,8 +1262,8 @@
            case UnitActionHarvest:
                units_assigned[num_units_assigned[WoodCost]++][WoodCost]=unit;
                continue;
-           case UnitActionHaulOil:
-               units_assigned[num_units_assigned[OilCost]++][OilCost]=unit;
+           case UnitActionResource:
+               
units_assigned[num_units_assigned[unit->Type->ResourceHarvested]++][unit->Type->ResourceHarvested]=unit;
                continue;
                // FIXME: the other resources
            default:
@@ -1450,7 +1450,7 @@
                                }
                                break;
                            case OilCost:
-                               if( unit->Orders[0].Action==UnitActionHaulOil 
|| AiHaulOil(unit) ) {
+                               if( unit->Orders[0].Action==UnitActionResource 
|| AiHaulOil(unit) ) {
                                    DebugLevel3Fn("Assigned to oil\n");
                                    
units_assigned[num_units_assigned[c]++][c]=unit;
                                    units_unassigned[i][c] = 
units_unassigned[--num_units_unassigned[c]][c];
Index: stratagus/src/clone/unit.c
diff -u stratagus/src/clone/unit.c:1.282 stratagus/src/clone/unit.c:1.283
--- stratagus/src/clone/unit.c:1.282    Fri Aug  8 06:16:43 2003
+++ stratagus/src/clone/unit.c  Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.c,v 1.282 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: unit.c,v 1.283 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -2397,7 +2397,7 @@
        }
     }
 
-    if( type->MustBuildOnTop ) {
+    if( type->MustBuildOnTop && !EditorRunning) {
        // Resource platform could only be build on resource patch.
        n=UnitCacheSelect(x,y,x+1,y+1,table);
        for( i=0; i<n; ++i ) {
@@ -3043,15 +3043,19 @@
 #endif
 
 /**
- **    Find oil platform.
+ **    Find Resource.
  **
- **    @param player   A deposit owning this player
+ **    @param player   The player that wants to find a resource.
  **    @param x        Nearest to X position.
- **    @param y        Nearest to Y position.
+ **    @param y        Nearest to Y position
+ **    @param resource The ID of the resource.
+ **
+ **    @notes          This will return an usable resource building that
+ **                    belongs to "player" or is neutral.
  **
  **    @return         NoUnitP or oil platform unit
  */
-global Unit* FindOilPlatform(const Player* player,int x,int y)
+global Unit* FindResource(const Player* player,int x,int y,int resource)
 {
     Unit* unit;
     Unit* best;
@@ -3060,38 +3064,39 @@
     int best_d;
     int d;
     int i;
+    int pnum;
 
     // FIXME:  this is not the best one
     //         We need the deposit with the shortest way!
     //         At least it must be reachable!
-    //
 
     best=NoUnitP;
     best_d=99999;
-    nunits=player->TotalNumUnits;
-    units=player->Units;
-    for( i=0; i<nunits; i++ ) {
-       unit=units[i];
-       if( UnitUnusable(unit) ) {
+    for (pnum=0;pnum<PlayerMax;++pnum) {
+       // FIXME: allow harvesting from ally
+       if ( (pnum!=PlayerMax-1) && (pnum!=ThisPlayer->Player) ) {
            continue;
        }
-       // Want platform
-       if( unit->Type->GivesResource==OilCost ) {
-           d=MapDistanceToUnit(x,y,unit);
-           if( d<best_d ) {
-               best_d=d;
-               best=unit;
+       nunits=Players[pnum].TotalNumUnits;
+       units=Players[pnum].Units;
+       for( i=0; i<nunits; i++ ) {
+           unit=units[i];
+           if( UnitUnusable(unit) || !unit->Type->CanHarvest ) {
+               continue;
+           }
+           // Want platform
+           if( unit->Type->GivesResource==resource ) {
+               d=MapDistanceToUnit(x,y,unit);
+               if( d<best_d ) {
+                   best_d=d;
+                   best=unit;
+               }
            }
        }
     }
 
     DebugLevel3Fn("%d %d,%d\n" _C_ best?UnitNumber(best):-1 _C_
            best?best->X:-1 _C_ best?best->Y:-1);
-    /* Oil platforms are our own, they should be known
-       if( LimitSearch && (best_d>TheMap.Width/5 || best_d>TheMap.Height/5) ) {
-       return NoUnitP;
-       }
-       */
     return best;
 }
 
@@ -3964,17 +3969,8 @@
        case UnitActionMineGold:
            fprintf(file,"action-mine-gold");
            break;
-       case UnitActionMineOre:
-           fprintf(file,"action-mine-ore");
-           break;
-       case UnitActionMineCoal:
-           fprintf(file,"action-mine-coal");
-           break;
-       case UnitActionQuarryStone:
-           fprintf(file,"action-quarry-stone");
-           break;
-       case UnitActionHaulOil:
-           fprintf(file,"action-haul-oil");
+       case UnitActionResource:
+           fprintf(file,"action-resource");
            break;
        case UnitActionReturnGoods:
            fprintf(file,"action-return-goods");
@@ -4275,7 +4271,7 @@
     int InRun, RunStart;
 
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: units $Id: unit.c,v 1.282 2003/08/08 10:16:43 
martinxyz Exp $\n\n");
+    fprintf(file,";;; MODULE: units $Id: unit.c,v 1.283 2003/08/08 19:31:36 
n0body Exp $\n\n");
 
     //
     // Local variables
Index: stratagus/src/clone/unit_draw.c
diff -u stratagus/src/clone/unit_draw.c:1.147 
stratagus/src/clone/unit_draw.c:1.148
--- stratagus/src/clone/unit_draw.c:1.147       Fri Aug  8 06:16:43 2003
+++ stratagus/src/clone/unit_draw.c     Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit_draw.c,v 1.147 2003/08/08 10:16:43 martinxyz Exp $
+//     $Id: unit_draw.c,v 1.148 2003/08/08 19:31:36 n0body Exp $
 
 //@{
 
@@ -1468,7 +1468,7 @@
            dest = 1;
            break;
 
-       case UnitActionHaulOil:
+       case UnitActionResource:
            e_color = color = ColorYellow;
            dest = 1;
            break;
Index: stratagus/src/include/actions.h
diff -u stratagus/src/include/actions.h:1.51 
stratagus/src/include/actions.h:1.52
--- stratagus/src/include/actions.h:1.51        Fri Jul 11 10:35:30 2003
+++ stratagus/src/include/actions.h     Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: actions.h,v 1.51 2003/07/11 14:35:30 n0body Exp $
+//     $Id: actions.h,v 1.52 2003/08/08 19:31:36 n0body Exp $
 
 #ifndef __ACTIONS_H__
 #define __ACTIONS_H__
@@ -105,7 +105,7 @@
     /// Prepare command mine
 extern void CommandMineGold(Unit* unit,Unit* dest,int flush);
     /// Prepare command haul
-extern void CommandHaulOil(Unit* unit,Unit* dest,int flush);
+extern void CommandResource(Unit* unit,Unit* dest,int flush);
     /// Prepare command return
 extern void CommandReturnGoods(Unit* unit,Unit* goal,int flush);
     /// Prepare command train
@@ -167,7 +167,7 @@
     /// Handle command mine
 extern void HandleActionMineGold(Unit* unit);
     /// Handle command haul
-extern void HandleActionHaulOil(Unit* unit);
+extern void HandleActionResource(Unit* unit);
     /// Handle command return
 extern void HandleActionReturnGoods(Unit* unit);
     /// Handle command die
Index: stratagus/src/include/commands.h
diff -u stratagus/src/include/commands.h:1.19 
stratagus/src/include/commands.h:1.20
--- stratagus/src/include/commands.h:1.19       Fri Jul 11 10:35:30 2003
+++ stratagus/src/include/commands.h    Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: commands.h,v 1.19 2003/07/11 14:35:30 n0body Exp $
+//     $Id: commands.h,v 1.20 2003/08/08 19:31:36 n0body Exp $
 
 #ifndef __COMMANDS_H__
 #define __COMMANDS_H__
@@ -103,7 +103,7 @@
     /// Send mine gold command
 extern void SendCommandMineGold(Unit* unit,Unit* dest,int flush);
     /// Send haul oil command
-extern void SendCommandHaulOil(Unit* unit,Unit* dest,int flush);
+extern void SendCommandResource(Unit* unit,Unit* dest,int flush);
     /// Send return goods command
 extern void SendCommandReturnGoods(Unit* unit,Unit* dest,int flush);
     /// Send train command
Index: stratagus/src/include/network.h
diff -u stratagus/src/include/network.h:1.38 
stratagus/src/include/network.h:1.39
--- stratagus/src/include/network.h:1.38        Fri Jul 11 10:35:30 2003
+++ stratagus/src/include/network.h     Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: network.h,v 1.38 2003/07/11 14:35:30 n0body Exp $
+//     $Id: network.h,v 1.39 2003/08/08 19:31:36 n0body Exp $
 
 #ifndef __NETWORK_H__
 #define __NETWORK_H__
@@ -85,7 +85,7 @@
     MessageCommandCancelBuild,         /// Unit command cancel building
     MessageCommandHarvest,             /// Unit command harvest
     MessageCommandMine,                        /// Unit command mine gold
-    MessageCommandHaul,                        /// Unit command haul oil
+    MessageCommandResource,            /// Unit command haul oil
     MessageCommandReturn,              /// Unit command return goods
     MessageCommandTrain,               /// Unit command train
     MessageCommandCancelTrain,         /// Unit command cancel training
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.200 stratagus/src/include/unit.h:1.201
--- stratagus/src/include/unit.h:1.200  Fri Aug  8 06:16:44 2003
+++ stratagus/src/include/unit.h        Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.h,v 1.200 2003/08/08 10:16:44 martinxyz Exp $
+//     $Id: unit.h,v 1.201 2003/08/08 19:31:36 n0body Exp $
 
 #ifndef __UNIT_H__
 #define __UNIT_H__
@@ -430,7 +430,7 @@
     UnitActionMineOre,                 /// unit mines ore FIXME: not written
     UnitActionMineCoal,                        /// unit mines coal FIXME: not 
written
     UnitActionQuarryStone,             /// unit quarrying stone FIXME: not 
written
-    UnitActionHaulOil,                 /// unit hauling oil
+    UnitActionResource,                        /// unit hauling oil
     UnitActionReturnGoods,             /// unit returning any resource
 
     UnitActionDemolish,                        /// unit demolish at 
position/unit
@@ -566,8 +566,7 @@
     int                Value;                  /// value used for much
 
     unsigned   SubAction : 8;          /// sub-action of unit
-    unsigned   Wait : 8;               /// action counter
-#define MAX_UNIT_WAIT  255             /// biggest number in action counter
+    unsigned   Wait;                   /// action counter
     unsigned   State : 8;              /// action state
 #define MAX_UNIT_STATE 255             /// biggest state for action
     unsigned   Reset : 1;              /// can process new command
@@ -577,11 +576,6 @@
                                        ** ,used for fancy buildings
                                        */
     unsigned   Rs : 8;
-#if 0
-#define MAX_UNITS_ONBOARD 6            /// max number of units in transporter
-    // FIXME: use the new next pointer
-    Unit*      OnBoard[MAX_UNITS_ONBOARD];     /// Units in transporter
-#endif
 
 #define MAX_ORDERS 16                  /// How many outstanding orders?
     char       OrderCount;             /// how many orders in queue
@@ -841,8 +835,8 @@
 extern int FindWoodInSight(const Unit* unit,int* x,int* y);
     /// Find gold mine
 extern Unit* FindGoldMine(const Unit* unit,int x,int y);
-    /// Find oil platform
-extern Unit* FindOilPlatform(const Player* player,int x,int y);
+    /// Find resource
+extern Unit* FindResource(const Player* player,int x,int y,int resource);
 
     /// FIXME: more docu
 extern Unit* UnitOnScreen(Unit* unit,int x,int y);
Index: stratagus/src/include/unittype.h
diff -u stratagus/src/include/unittype.h:1.92 
stratagus/src/include/unittype.h:1.93
--- stratagus/src/include/unittype.h:1.92       Fri Aug  8 06:16:44 2003
+++ stratagus/src/include/unittype.h    Fri Aug  8 15:31:36 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unittype.h,v 1.92 2003/08/08 10:16:44 martinxyz Exp $
+//     $Id: unittype.h,v 1.93 2003/08/08 19:31:36 n0body Exp $
 
 #ifndef __UNITTYPE_H__
 #define __UNITTYPE_H__
@@ -50,10 +50,6 @@
 **
 **     The unit-type structure members:
 **
-**     UnitType::OType
-**
-**             Object type (future extensions).
-**
 **     UnitType::Ident
 **
 **             Unique identifier of the unit-type, used to reference it in
@@ -294,10 +290,6 @@
 **
 **             Is a worker, runs away if attcked
 **
-**     UnitType::Tanker
-**
-**             FIXME: used? Can transport oil
-**
 **     UnitType::Transporter
 **
 **             Can transport units
@@ -583,26 +575,33 @@
     unsigned Submarine : 1;            /// Is only visible by CanSeeSubmarine
     unsigned CanSeeSubmarine : 1;      /// Only this units can see Submarine
     unsigned CowerWorker : 1;          /// Is a worker, runs away if attcked
-    unsigned Tanker : 1;               /// FIXME: used? Can transport oil
     unsigned Transporter : 1;          /// Can transport units
     unsigned MaxOnBoard;               /// Number of Transporter slots.
-    unsigned Vanishes : 1;             /// Corpes & destroyed places
-    unsigned GroundAttack : 1;         /// Can do command ground attack
-    unsigned IsUndead : 1;             /// Unit is already dead
-    unsigned ShoreBuilding : 1;                /// Building must be build on 
coast
-    unsigned CanCastSpell : 1;         /// Unit is able to use spells
-    unsigned CanAttack : 1;            /// Unit can attack
-    unsigned Tower : 1;                        /// Unit can attack, but not 
move
-    unsigned Hero : 1;                 /// Is hero only used for triggers 
-    unsigned Volatile : 1;             /// Invisiblity/unholy armor kills unit
+    unsigned Vanishes : 1;             /// Corpes & destroyed places.
+    unsigned GroundAttack : 1;         /// Can do command ground attack.
+    unsigned IsUndead : 1;             /// Unit is already dead.
+    unsigned ShoreBuilding : 1;                /// Building must be build on 
coast.
+    unsigned CanCastSpell : 1;         /// Unit is able to use spells.
+    unsigned CanAttack : 1;            /// Unit can attack.
+    unsigned Tower : 1;                        /// Unit can attack, but not 
move.
+    unsigned Hero : 1;                 /// Is hero only used for triggers .
+    unsigned Volatile : 1;             /// Invisiblity/unholy armor kills unit.
     unsigned CowerMage : 1;            /// FIXME: docu
-    unsigned Organic : 1;              /// Organic can be healed
+    unsigned Organic : 1;              /// Organic can be healed.
     
     unsigned CanStore[MaxCosts];       /// Resources that we can store here.
     unsigned GivesResource;            /// The resource this unit gives.
-    UnitType* MustBuildOnTop;          /// Must be built on top of something
+    unsigned CanHarvest : 1;           /// Resource can be harvested(false for 
oil patches).
+    unsigned Harvester : 1;            /// Unit is a resource worker.
+    unsigned ResourceHarvested;                /// The resource it can harvest.
+    unsigned WaitAtResource;           /// Cycles the unit waits while mining.
+    unsigned WaitAtDepot;              /// Cycles the unit waits while 
returning.
+    unsigned ResourceCapacity;         /// Maximum amount of resources it can 
carry.
+    UnitType* TransformWhenEmpty;      /// UnitType to transform to when empty.
+    UnitType* TransformWhenLoaded;     /// UnitType to transform to when 
loaded.
+    UnitType* MustBuildOnTop;          /// Must be built on top of something.
 
-    unsigned SelectableByRectangle : 1;        /// Selectable with mouse 
rectangle
+    unsigned SelectableByRectangle : 1;        /// Selectable with mouse 
rectangle.
     unsigned Teleporter : 1;           /// Can teleport other units.
 
     UnitSound Sound;                   /// Sounds for events
Index: stratagus/src/network/commands.c
diff -u stratagus/src/network/commands.c:1.62 
stratagus/src/network/commands.c:1.63
--- stratagus/src/network/commands.c:1.62       Sat Aug  2 09:34:25 2003
+++ stratagus/src/network/commands.c    Fri Aug  8 15:31:37 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: commands.c,v 1.62 2003/08/02 13:34:25 grumbel Exp $
+//     $Id: commands.c,v 1.63 2003/08/08 19:31:37 n0body Exp $
 
 //@{
 
@@ -145,7 +145,7 @@
        fprintf(LogFile,"(replay-log\n");
        fprintf(LogFile,"  'comment\t\"Generated by Stratagus Version " VERSION 
"\"\n");
        fprintf(LogFile,"  'comment\t\"Visit http://Stratagus.Org for more 
information\"\n");
-       fprintf(LogFile,"  'comment\t\"$Id: commands.c,v 1.62 2003/08/02 
13:34:25 grumbel Exp $\"\n");
+       fprintf(LogFile,"  'comment\t\"$Id: commands.c,v 1.63 2003/08/08 
19:31:37 n0body Exp $\"\n");
        if( NetworkFildes==-1 ) {
            fprintf(LogFile,"  'type\t\"%s\"\n","single-player");
            fprintf(LogFile,"  'race\t%d\n",GameSettings.Presets[0].Race);
@@ -565,8 +565,8 @@
        SendCommandHarvest(UnitSlots[unit],posx,posy,flags);
     } else if( !strcmp(name,"mine") ) {
        SendCommandMineGold(UnitSlots[unit],dunit,flags);
-    } else if( !strcmp(name,"haul") ) {
-       SendCommandHaulOil(UnitSlots[unit],dunit,flags);
+    } else if( !strcmp(name,"resource") ) {
+       SendCommandResource(UnitSlots[unit],dunit,flags);
     } else if( !strcmp(name,"return") ) {
        SendCommandReturnGoods(UnitSlots[unit],dunit,flags);
     } else if( !strcmp(name,"train") ) {
@@ -945,13 +945,13 @@
 **     @param dest     pointer to destination (oil-platform).
 **     @param flush    Flag flush all pending commands.
 */
-global void SendCommandHaulOil(Unit* unit,Unit* dest,int flush)
+global void SendCommandResource(Unit* unit,Unit* dest,int flush)
 {
     if( NetworkFildes==-1 ) {
-       CommandLog("haul",unit,flush,-1,-1,dest,NULL,-1);
-       CommandHaulOil(unit,dest,flush);
+       CommandLog("resource",unit,flush,-1,-1,dest,NULL,-1);
+       CommandResource(unit,dest,flush);
     } else {
-       NetworkSendCommand(MessageCommandHaul,unit,0,0,dest,0,flush);
+       NetworkSendCommand(MessageCommandResource,unit,0,0,dest,0,flush);
     }
 }
 
@@ -1340,14 +1340,14 @@
            CommandLog("mine",unit,status,-1,-1,dest,NULL,-1);
            CommandMineGold(unit,dest,status);
            break;
-       case MessageCommandHaul:
+       case MessageCommandResource:
            dest=NoUnitP;
            if( dstnr!=(unsigned short)0xFFFF ) {
                dest=UnitSlots[dstnr];
                DebugCheck( !dest || !dest->Type );
            }
-           CommandLog("haul",unit,status,-1,-1,dest,NULL,-1);
-           CommandHaulOil(unit,dest,status);
+           CommandLog("resource",unit,status,-1,-1,dest,NULL,-1);
+           CommandResource(unit,dest,status);
            break;
        case MessageCommandReturn:
            dest=NoUnitP;
Index: stratagus/src/ui/mainscr.c
diff -u stratagus/src/ui/mainscr.c:1.114 stratagus/src/ui/mainscr.c:1.115
--- stratagus/src/ui/mainscr.c:1.114    Fri Aug  8 06:16:44 2003
+++ stratagus/src/ui/mainscr.c  Fri Aug  8 15:31:37 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mainscr.c,v 1.114 2003/08/08 10:16:44 martinxyz Exp $
+//     $Id: mainscr.c,v 1.115 2003/08/08 19:31:37 n0body Exp $
 
 //@{
 
@@ -477,10 +477,8 @@
         //sprintf(buf,"Level ~<%d~>",stats->Level);
        //VideoDrawText(x+91,y+8+33,GameFont,buf);
 
-       if( !type->Tanker && !type->Submarine ) {
-           VideoDrawText(x+57,y+8+63,GameFont,"Armor:");
-           DrawStats(x+108,y+8+63,stats->Armor,type->_Armor);
-       }
+       VideoDrawText(x+57,y+8+63,GameFont,"Armor:");
+       DrawStats(x+108,y+8+63,stats->Armor,type->_Armor);
 
        VideoDrawText(x+47,y+8+78,GameFont,"Damage:");
        if( (i=type->_BasicDamage+type->_PiercingDamage) ) {
Index: stratagus/src/ui/mouse.c
diff -u stratagus/src/ui/mouse.c:1.134 stratagus/src/ui/mouse.c:1.135
--- stratagus/src/ui/mouse.c:1.134      Fri Aug  8 06:16:44 2003
+++ stratagus/src/ui/mouse.c    Fri Aug  8 15:31:37 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mouse.c,v 1.134 2003/08/08 10:16:44 martinxyz Exp $
+//     $Id: mouse.c,v 1.135 2003/08/08 19:31:37 n0body Exp $
 
 //@{
 
@@ -274,9 +274,7 @@
        //      Tanker
        //
        if( action==MouseActionHaulOil ) {
-           // FIXME: How can I remove here the unit type? More races!
            if( type==UnitTypeOrcTankerFull || type==UnitTypeHumanTankerFull ) {
-               DebugLevel2("Should return to oil deposit\n");
                if( UnitUnderCursor && (dest=UnitOnMapTile(x,y))
                        && dest->Player==unit->Player ) {
                    dest->Blink=4;
@@ -291,7 +289,7 @@
                        && dest->Player==unit->Player ) {
                    dest->Blink=4;
                    DebugLevel3("PLATFORM\n");
-                   SendCommandHaulOil(unit,dest,flush);
+                   SendCommandResource(unit,dest,flush);
                    continue;
                }
            }
@@ -418,7 +416,7 @@
            if( UnitUnderCursor && (dest=PlatformOnMap(x,y)) ) {
                 dest->Blink=4;
                DebugLevel3("RALY POINT TO PLATFORM\n");
-                
SendCommandHaulOil(Selected[i],dest,!(KeyModifiers&ModifierShift));
+                
SendCommandResource(Selected[i],dest,!(KeyModifiers&ModifierShift));
                continue;
             }
             if( UnitUnderCursor && (dest=GoldMineOnMap(x,y)) ) {
@@ -1049,7 +1047,7 @@
        if( UnitUnderCursor && (dest=PlatformOnMap(x,y)) ) {
            dest->Blink=4;
            DebugLevel3("PLATFORM\n");
-           SendCommandHaulOil(Selected[i],dest,!(KeyModifiers&ModifierShift));
+           SendCommandResource(Selected[i],dest,!(KeyModifiers&ModifierShift));
            continue;
        }
        if( UnitUnderCursor && (dest=GoldMineOnMap(x,y)) ) {
Index: stratagus/src/unit/ccl_unit.c
diff -u stratagus/src/unit/ccl_unit.c:1.61 stratagus/src/unit/ccl_unit.c:1.62
--- stratagus/src/unit/ccl_unit.c:1.61  Fri Aug  1 15:30:37 2003
+++ stratagus/src/unit/ccl_unit.c       Fri Aug  8 15:31:37 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_unit.c,v 1.61 2003/08/01 19:30:37 grumbel Exp $
+//     $Id: ccl_unit.c,v 1.62 2003/08/08 19:31:37 n0body Exp $
 
 //@{
 
@@ -212,14 +212,8 @@
            order->Action=UnitActionHarvest;
        } else if( gh_eq_p(value,gh_symbol2scm("action-mine-gold")) ) {
            order->Action=UnitActionMineGold;
-       } else if( gh_eq_p(value,gh_symbol2scm("action-mine-ore")) ) {
-           order->Action=UnitActionMineOre;
-       } else if( gh_eq_p(value,gh_symbol2scm("action-mine-coal")) ) {
-           order->Action=UnitActionMineCoal;
-       } else if( gh_eq_p(value,gh_symbol2scm("action-quarry-stone")) ) {
-           order->Action=UnitActionQuarryStone;
-       } else if( gh_eq_p(value,gh_symbol2scm("action-haul-oil")) ) {
-           order->Action=UnitActionHaulOil;
+       } else if( gh_eq_p(value,gh_symbol2scm("action-resource")) ) {
+           order->Action=UnitActionResource;
        } else if( gh_eq_p(value,gh_symbol2scm("action-return-goods")) ) {
            order->Action=UnitActionReturnGoods;
        } else if( gh_eq_p(value,gh_symbol2scm("action-demolish")) ) {
Index: stratagus/src/unit/ccl_unittype.c
diff -u stratagus/src/unit/ccl_unittype.c:1.71 
stratagus/src/unit/ccl_unittype.c:1.72
--- stratagus/src/unit/ccl_unittype.c:1.71      Fri Aug  8 06:16:44 2003
+++ stratagus/src/unit/ccl_unittype.c   Fri Aug  8 15:31:37 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_unittype.c,v 1.71 2003/08/08 10:16:44 martinxyz Exp $
+//     $Id: ccl_unittype.c,v 1.72 2003/08/08 19:31:37 n0body Exp $
 
 //@{
 
@@ -66,6 +66,24 @@
 ----------------------------------------------------------------------------*/
 
 /**
+**     Get the resource ID from a SCM object.
+**
+**     @param value    SCM thingie
+**     @return         the resource id
+*/
+local unsigned CclGetResourceByName(SCM value)
+{
+    int i;
+    for( i=0; i<MaxCosts; ++i ) {
+       if( gh_eq_p(value,gh_symbol2scm(DefaultResourceNames[i])) ) {
+           return i;
+       }
+    }
+    errl("Unsupported resource tag",value);
+    return 0xABCDEF;
+}
+
+/**
 **     Parse unit-type.
 **
 **     @note Should write a general parser for this.
@@ -200,20 +218,9 @@
            sublist=gh_car(list);
            list=gh_cdr(list);
            while( !gh_null_p(sublist) ) {
-
                value=gh_car(sublist);
                sublist=gh_cdr(sublist);
-
-               for( i=0; i<MaxCosts; ++i ) {
-                   if( gh_eq_p(value,gh_symbol2scm(DefaultResourceNames[i])) ) 
{
-                       type->_Costs[i]=gh_scm2int(gh_car(sublist));
-                       break;
-                   }
-               }
-               if( i==MaxCosts ) {
-                  // FIXME: this leaves half initialized unit-type
-                  errl("Unsupported resource tag",value);
-               }
+               
type->_Costs[CclGetResourceByName(value)]=gh_scm2int(gh_car(sublist));
                sublist=gh_cdr(sublist);
            }
        } else if( gh_eq_p(value,gh_symbol2scm("construction")) ) {
@@ -388,30 +395,52 @@
            type->Transporter=1;
        } else if( gh_eq_p(value,gh_symbol2scm("cower-worker")) ) {
            type->CowerWorker=1;
-       } else if( gh_eq_p(value,gh_symbol2scm("tanker")) ) {
-           type->Tanker=1;
-       } else if( gh_eq_p(value,gh_symbol2scm("gives-oil")) ) {
-           type->GivesResource=OilCost;
+       } else if( gh_eq_p(value,gh_symbol2scm("harvester")) ) {
+           type->Harvester=1;
+       } else if( gh_eq_p(value,gh_symbol2scm("resource-harvested")) ) {
+           type->ResourceHarvested=CclGetResourceByName(gh_car(list));
+           list=gh_cdr(list);
+       } else if( gh_eq_p(value,gh_symbol2scm("wait-at-resource")) ) {
+           type->WaitAtResource=gh_scm2int(gh_car(list));
+           list=gh_cdr(list);
+       } else if( gh_eq_p(value,gh_symbol2scm("wait-at-depot")) ) {
+           type->WaitAtDepot=gh_scm2int(gh_car(list));
+           list=gh_cdr(list);
+       } else if( gh_eq_p(value,gh_symbol2scm("resource-capacity")) ) {
+           type->ResourceCapacity=gh_scm2int(gh_car(list));
+           list=gh_cdr(list);
+       } else if( gh_eq_p(value,gh_symbol2scm("transform-when-empty")) ) {
+           str=gh_scm2newstr(gh_car(list),NULL);
+           auxtype=UnitTypeByIdent(str);
+           if (!auxtype) {
+               DebugLevel0("Undefined unit \"%s\".\n" _C_ str);
+               exit(0);
+           }
+           type->TransformWhenEmpty=auxtype;
+           free(str);
+           list=gh_cdr(list);
+       } else if( gh_eq_p(value,gh_symbol2scm("transform-when-loaded")) ) {
+           str=gh_scm2newstr(gh_car(list),NULL);
+           auxtype=UnitTypeByIdent(str);
+           if (!auxtype) {
+               DebugLevel0("Undefined unit \"%s\".\n" _C_ str);
+               exit(0);
+           }
+           type->TransformWhenLoaded=auxtype;
+           free(str);
+           list=gh_cdr(list);
+       } else if( gh_eq_p(value,gh_symbol2scm("gives-resource")) ) {
+           type->GivesResource=CclGetResourceByName(gh_car(list));
+           list=gh_cdr(list);
+       } else if( gh_eq_p(value,gh_symbol2scm("can-harvest")) ) {
+           type->CanHarvest=1;
        } else if( gh_eq_p(value,gh_symbol2scm("can-store")) ) {
            sublist=gh_car(list);
            list=gh_cdr(list);
            while( !gh_null_p(sublist) ) {
-               value=gh_car(sublist);
+               type->CanStore[CclGetResourceByName(gh_car(sublist))]=1;
                sublist=gh_cdr(sublist);
-               for( i=0; i<MaxCosts; ++i ) {
-                   if( gh_eq_p(value,gh_symbol2scm(DefaultResourceNames[i])) ) 
{
-                       type->CanStore[i]=1;
-                       break;
-                   }
-               }
-               if( i==MaxCosts ) {
-                  errl("Unsupported resource tag",value);
-               }
            }
-       } else if( gh_eq_p(value,gh_symbol2scm("oil-patch")) ) {
-           type->GivesResource=OilCost;
-       } else if( gh_eq_p(value,gh_symbol2scm("gives-gold")) ) {
-           type->GivesResource=GoldCost;
        } else if( gh_eq_p(value,gh_symbol2scm("vanishes")) ) {
            type->Vanishes=1;
        } else if( gh_eq_p(value,gh_symbol2scm("tower")) ) {
@@ -609,7 +638,7 @@
 
     // Be kind allow also strings or symbols
     if( (str = CclConvertToString(ptr)) != NULL )  {
-        printf("CclGetUnitType: %s\n", str);
+        DebugLevel3("CclGetUnitType: %s\n"_C_ str);
         UnitType* type = UnitTypeByIdent(str);
         free(str);
         return type;
Index: stratagus/src/unit/unittype.c
diff -u stratagus/src/unit/unittype.c:1.80 stratagus/src/unit/unittype.c:1.81
--- stratagus/src/unit/unittype.c:1.80  Fri Aug  8 06:16:44 2003
+++ stratagus/src/unit/unittype.c       Fri Aug  8 15:31:37 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unittype.c,v 1.80 2003/08/08 10:16:44 martinxyz Exp $
+//     $Id: unittype.c,v 1.81 2003/08/08 19:31:37 n0body Exp $
 
 //@{
 
@@ -457,7 +457,10 @@
        unittype->Submarine=BIT(6,v);
        unittype->CanSeeSubmarine=BIT(7,v);
        unittype->CowerWorker=BIT(8,v);
-       unittype->Tanker=BIT(9,v);
+       if (BIT(9,v)) {
+           unittype->Harvester=1;
+           unittype->ResourceHarvested=OilCost;
+       }
        unittype->Transporter=BIT(10,v);
        unittype->CanStore[GoldCost]=BIT(12,v);
        unittype->Vanishes=BIT(13,v);
@@ -585,6 +588,400 @@
 }
 
 /**
+<<<<<<< unittype.c
+**     Save state of the animitions set to file.
+**
+**     We save only the first occurance of an animation.
+**
+**     @param type     Save animations of this unit-type.
+**     @param file     Output file.
+*/
+local void SaveAnimations(const UnitType* type,FILE* file)
+{
+    const Animations* anims;
+    int i;
+    int q;
+
+    if( !(anims=type->Animations) ) {
+       return;
+    }
+
+    //
+    // Look if this is the first use of it.
+    //
+    for( i=0; i<NumUnitTypes && UnitTypes[i]!=type ; ++i ) {
+       if( UnitTypes[i]->Animations==anims ) {
+           return;                     // allready handled.
+       }
+    }
+
+    fprintf(file,"\n;;------\n;;\t");
+    //
+    // Print all units that use this animation.
+    //
+    q=0;
+    for( i=0 ; i<NumUnitTypes ; ++i ) {
+       if( UnitTypes[i]->Animations==anims ) {
+           if( q ) {
+               fprintf(file,", ");
+           }
+           fprintf(file,"%s",UnitTypes[i]->Name);
+           q=1;
+       }
+    }
+    fprintf(file,"\n(define-animations 'animations-%s",type->Ident+5);
+
+    SaveAnimation("still",anims->Still,file);
+    SaveAnimation("move",anims->Move,file);
+    SaveAnimation("attack",anims->Attack,file);
+    SaveAnimation("die",anims->Die,file);
+
+    fprintf(file,")\n");
+}
+
+/**
+**     Save state of an unit-type to file.
+**
+**     @param file     Output file.
+**     @param type     Unit-type to save.
+**     @param all      Flag save all values.
+**
+**     @todo   Arrange the variables more logical
+*/
+local void SaveUnitType(FILE* file,const UnitType* type,int all)
+{
+    int i;
+    int flag;
+
+    fprintf(file,"(define-unit-type '%s",type->Ident);
+    fprintf(file," 'name \"%s\"\n  ",type->Name);
+    // Graphic files
+    if( type->SameSprite ) {
+       fprintf(file,"'use '%s",type->SameSprite);
+    } else {
+       fputs("'files '(",file);
+       for( flag=i=0; i<TilesetMax; ++i ) {
+           if( type->File[i] ) {
+               if( flag ) {
+                   fputs("\n    ",file);
+               }
+               fprintf(file,"%s \"%s\"",Tilesets[i]->Ident,type->File[i]);
+               flag=1;
+           }
+       }
+       fputs(")",file);
+    }
+    fprintf(file,"\n  'size '(%d %d)\n",type->Width,type->Height);
+    if( type->ShadowFile ) {
+       fprintf(file,"  'shadow '(file \"%s\" width %d height %d)\n",
+               type->ShadowFile, type->ShadowWidth, type->ShadowHeight);
+    }
+
+    //
+    // Animations are shared, find first use of the unit-type animation.
+    //
+    for( i=0; i<NumUnitTypes && UnitTypes[i]!=type ; ++i ) {
+       if( UnitTypes[i]->Animations==type->Animations ) {
+           break;
+       }
+    }
+    fprintf(file,"  'animations 'animations-%s",UnitTypes[i]->Ident+5);
+    fprintf(file,"  'icon '%s\n",IdentOfIcon(type->Icon.Icon));
+    for( i=flag=0; i<MaxCosts; ++i ) {
+       if( all || type->_Costs[i] ) {
+           if( !flag ) {
+               fputs("  'costs '(",file);
+               flag=1;
+           } else {
+               fputs(" ",file);
+           }
+           fprintf(file,"%s %d",DefaultResourceNames[i],type->_Costs[i]);
+       }
+    }
+    if( flag ) {
+       fputs(")\n",file);
+    }
+
+    if( type->Construction ) {
+       fprintf(file,"  'construction '%s\n",type->Construction->Ident);
+    }
+    fprintf(file,"  'speed %d\n",type->_Speed);
+    fprintf(file,"  'hit-points %d\n",type->_HitPoints);
+    if( all || type->_MaxMana ) {
+       fprintf(file,"  'max-mana %d\n",type->_MaxMana);
+    }
+    if( all || type->Magic ) {
+       fprintf(file,"  'magic %d\n",type->Magic);
+    }
+    fprintf(file,"  'tile-size '(%d %d)",type->TileWidth,type->TileHeight);
+    fprintf(file,"  'box-size '(%d %d)\n",type->BoxWidth,type->BoxHeight);
+    fprintf(file,"  'sight-range %d",type->_SightRange);
+    if( all || type->ReactRangeComputer ) {
+       fprintf(file,"  'computer-reaction-range %d",type->ReactRangeComputer);
+    }
+    if( all || type->ReactRangePerson ) {
+       fprintf(file,"  'person-reaction-range %d",type->ReactRangePerson);
+    }
+    fputs("\n",file);
+
+    if( all || type->_Armor ) {
+       fprintf(file,"  'armor %d",type->_Armor);
+    } else {
+       fputs(" ",file);
+    }
+    fprintf(file,"  'basic-damage %d",type->_BasicDamage);
+    fprintf(file,"  'piercing-damage %d",type->_PiercingDamage);
+    fprintf(file,"  'missile '%s\n",type->Missile.Name);
+    fprintf(file,"  'draw-level %d",type->DrawLevel);
+    if( all || type->MinAttackRange ) {
+       fprintf(file,"  'min-attack-range %d",type->MinAttackRange);
+       fprintf(file,"  'max-attack-range %d\n",type->_AttackRange);
+    } else if( type->_AttackRange ) {
+       fprintf(file,"  'max-attack-range %d\n",type->_AttackRange);
+    }
+    if( all || type->WeaponsUpgradable ) {
+       fprintf(file,"  'weapons-upgradable %d",type->WeaponsUpgradable);
+       if( all || type->ArmorUpgradable ) {
+           fprintf(file," 'armor-upgradable %d\n",type->ArmorUpgradable);
+       } else {
+           fputs("\n",file);
+       }
+    } else if( type->ArmorUpgradable ) {
+       fprintf(file,"  'armor-upgradable %d\n",type->ArmorUpgradable);
+    }
+    fprintf(file,"  'priority %d",type->Priority);
+    if( all || type->AnnoyComputerFactor ) {
+       fprintf(file,"  'annoy-computer-factor %d",type->AnnoyComputerFactor);
+    }
+    fputs("\n",file);
+    if( all || type->DecayRate ) {
+       fprintf(file,"  'decay-rate %d\n",type->DecayRate);
+    }
+    if( all || type->Points ) {
+       fprintf(file,"  'points %d\n",type->Points);
+    }
+    if( all || type->Demand ) {
+       fprintf(file,"  'demand %d\n",type->Demand);
+    }
+    if( all || type->Supply ) {
+       fprintf(file,"  'supply %d\n",type->Supply);
+    }
+
+    if( type->CorpseName ) {
+       fprintf(file,"  'corpse '(%s %d)\n",
+               type->CorpseName,type->CorpseScript);
+    }
+    if( type->ExplodeWhenKilled ) {
+       fprintf(file,"  'explode-when-killed\n");
+    }
+
+    fprintf(file,"  ");
+    switch( type->UnitType ) {
+       case UnitTypeLand:
+           fputs("'type-land",file);
+           break;
+       case UnitTypeFly:
+           fputs("'type-fly",file);
+           break;
+       case UnitTypeNaval:
+           fputs("'type-naval",file);
+           break;
+       default:
+           fputs("'type-unknown",file);
+           break;
+    }
+    fprintf(file,"\n");
+
+    fprintf(file,"  ");
+    switch( type->MouseAction ) {
+       case MouseActionNone:
+           if( all ) {
+               fprintf(file,"'right-none");
+           }
+           break;
+       case MouseActionAttack:
+           fprintf(file,"'right-attack");
+           break;
+       case MouseActionMove:
+           fprintf(file,"'right-move");
+           break;
+       case MouseActionHarvest:
+           fprintf(file,"'right-harvest");
+           break;
+       case MouseActionHaulOil:
+           fprintf(file,"'right-haul-oil");
+           break;
+       case MouseActionDemolish:
+           fprintf(file,"'right-demolish");
+           break;
+       case MouseActionSail:
+           fprintf(file,"'right-sail");
+           break;
+       default:
+           fprintf(file,"'right-unknown");
+           break;
+    }
+    fprintf(file,"\n");
+
+    if( type->GroundAttack ) {
+       fprintf(file,"  'can-ground-attack\n");
+    }
+    if( type->CanAttack ) {
+       fprintf(file,"  'can-attack\n");
+    }
+    if( type->CanTarget ) {
+       fprintf(file,"  ");
+       if( type->CanTarget&CanTargetLand ) {
+           fprintf(file,"'can-target-land ");
+       }
+       if( type->CanTarget&CanTargetSea ) {
+           fprintf(file,"'can-target-sea ");
+       }
+       if( type->CanTarget&CanTargetAir ) {
+           fprintf(file,"'can-target-air ");
+       }
+       if( type->CanTarget&~7 ) {
+           fprintf(file,"'can-target-other ");
+       }
+       fprintf(file,"\n");
+    }
+
+    if( type->Building ) {
+       fprintf(file,"  'building\n");
+    }
+    if( type->ShoreBuilding ) {
+       fprintf(file,"  'shore-building\n");
+    }
+    if( type->LandUnit ) {
+       fprintf(file,"  'land-unit\n");
+    }
+    if( type->AirUnit ) {
+       fprintf(file,"  'air-unit\n");
+    }
+    if( type->SeaUnit ) {
+       fprintf(file,"  'sea-unit\n");
+    }
+
+    if( type->Critter ) {
+       fprintf(file,"  'critter\n");
+    }
+    if( type->Revealer ) {
+       fprintf(file,"  'revealer\n");
+    }
+    if( type->Submarine ) {
+       fprintf(file,"  'submarine\n");
+    }
+    if( type->CanSeeSubmarine ) {
+       fprintf(file,"  'can-see-submarine\n");
+    }
+    if( type->Transporter ) {
+       fprintf(file,"  'transporter\n");
+    }
+
+    if( type->CowerWorker ) {
+       fprintf(file,"  'cower-worker\n");
+    }
+    if( type->Harvester ) {
+       fprintf(file,"  'harvester 'resource-harvested 
'%s",DefaultResourceNames[type->ResourceHarvested]);
+    }
+    if ( type->WaitAtResource ) {
+       fprintf(file,"  'wait-at-resource %d\n",type->WaitAtResource);
+    }
+    if ( type->WaitAtDepot ) {
+       fprintf(file,"  'wait-at-depot %d\n",type->WaitAtDepot);
+    }
+    if ( type->ResourceCapacity ) {
+        fprintf(file,"  'resource-capacity %d\n",type->ResourceCapacity);
+    }
+    if ( type->TransformWhenEmpty ) {
+       fprintf(file,"  'transform-when-empty 
'%s\n",type->TransformWhenEmpty->Ident);
+    }
+    if ( type->TransformWhenLoaded ) {
+       fprintf(file,"  'transform-when-loaded 
'%s\n",type->TransformWhenLoaded->Ident);
+    }
+    if( type->GivesResource ) {
+       fprintf(file,"  'gives-resource 
'%s\n",DefaultResourceNames[type->GivesResource]);
+    }
+    
+    // Save store info.
+    for (flag=i=0;i<MaxCosts;i++)
+       if (type->CanStore[i]) {
+           if (!flag) {
+               flag=1;
+               fprintf(file,"  'can-store '(%s",DefaultResourceNames[i]);
+           } else {
+               fprintf(file," %s",DefaultResourceNames[i]);
+           }
+       }
+    if (flag)
+       fprintf(file,")");
+    
+    if( type->MustBuildOnTop ) {
+       fprintf(file,"  'must-build-on-top '%s\n",type->MustBuildOnTop->Ident);
+    }
+    if( type->CanHarvest ) {
+       fprintf(file,"  'can-harvest\n");
+    }
+
+    if( type->Vanishes ) {
+       fprintf(file,"  'vanishes\n");
+    }
+    if( type->Tower ) {
+       fprintf(file,"  'tower\n");
+    }
+    if( type->Hero ) {
+       fprintf(file,"  'hero\n");
+    }
+    if( type->Volatile ) {
+       fprintf(file,"  'volatile\n");
+    }
+    if( type->CowerMage ) {
+       fprintf(file,"  'cower-mage\n");
+    }
+    if( type->IsUndead ) {
+       fprintf(file,"  'isundead\n");
+    }
+    if( type->CanCastSpell ) {
+       fprintf(file,"  'can-cast-spell\n");
+    }
+    if( type->Organic ) {
+       fprintf(file,"  'organic\n");
+    }
+    if( type->SelectableByRectangle ) {
+       fprintf(file,"  'selectable-by-rectangle\n");
+    }
+    if( type->Teleporter ) {
+       fprintf(file,"  'teleporter\n");
+    }
+
+    fprintf(file,"  'sounds '(");
+    if( type->Sound.Selected.Name ) {
+       fprintf(file,"\n    selected \"%s\"",type->Sound.Selected.Name);
+    }
+    if( type->Sound.Acknowledgement.Name ) {
+       fprintf(file,"\n    acknowledge \"%s\"",
+               type->Sound.Acknowledgement.Name);
+    }
+    if( type->Sound.Ready.Name ) {
+       fprintf(file,"\n    ready \"%s\"",type->Sound.Ready.Name);
+    }
+    if( type->Sound.Help.Name ) {
+       fprintf(file,"\n    help \"%s\"",type->Sound.Help.Name);
+    }
+    if( type->Sound.Dead.Name ) {
+       fprintf(file,"\n    dead \"%s\"",type->Sound.Dead.Name);
+    }
+    // FIXME: Attack should be removed!
+    if( type->Weapon.Attack.Name ) {
+       fprintf(file,"\n    attack \"%s\"",type->Weapon.Attack.Name);
+    }
+    fprintf(file,")");
+    fprintf(file,")\n\n");
+}
+
+/**
+=======
+>>>>>>> 1.80
 **     Save state of an unit-stats to file.
 **
 **     @param stats    Unit-stats to save.
@@ -631,9 +1028,41 @@
 {
     int i;
     int j;
+    char **sp;
 
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: unittypes $Id: unittype.c,v 1.80 2003/08/08 
10:16:44 martinxyz Exp $\n\n");
+    fprintf(file,";;; MODULE: unittypes $Id: unittype.c,v 1.81 2003/08/08 
19:31:37 n0body Exp $\n\n");
+
+    // Original number to internal unit-type name.
+
+    i=fprintf(file,"(define-unittype-wc-names");
+    for( sp=UnitTypeWcNames; *sp; ++sp ) {
+       if( i+strlen(*sp)>79 ) {
+           i=fprintf(file,"\n ");
+       }
+       i+=fprintf(file," '%s",*sp);
+    }
+    fprintf(file,")\n");
+
+    // Save all animations.
+
+    for( i=0; i<NumUnitTypes; ++i ) {
+       SaveAnimations(UnitTypes[i],file);
+    }
+
+    fprintf(file,"\n;;; Declare all unit types in advance.\n");
+    //  Define all types in advance to avoid undefined unit problems.
+    for ( i=0; i<NumUnitTypes; ++i ) {
+       fprintf(file,"(define-unit-type '%s)\n",UnitTypes[i]->Ident);
+    }
+    fprintf(file,"\n");
+
+    // Save all types
+
+    for( i=0; i<NumUnitTypes; ++i ) {
+       fputc('\n',file);
+       SaveUnitType(file,UnitTypes[i],0);
+    }
 
     // Save all stats
 




reply via email to

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