stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus data/ccl/ai.ccl data/ccl/editor.ccl d...


From: Crestez Leonard
Subject: [Stratagus-CVS] stratagus data/ccl/ai.ccl data/ccl/editor.ccl d...
Date: Fri, 05 Sep 2003 14:10:58 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Crestez Leonard <address@hidden>        03/09/05 14:10:56

Modified files:
        data/ccl       : ai.ccl editor.ccl sound.ccl stratagus.ccl 
                         wc2.ccl 
        data/ccl/human : buttons.ccl units.ccl upgrade.ccl 
        data/ccl/orc   : buttons.ccl units.ccl upgrade.ccl 
        doc            : ChangeLog.html 
        src/action     : Module.make action_build.c action_move.c 
                         action_resource.c action_returngoods.c 
                         action_train.c actions.c command.c 
        src/ai         : ai_resource.c 
        src/clone      : clone.c unit.c unit_draw.c unit_find.c 
        src/include    : actions.h commands.h iolib.h network.h 
                         stratagus.h unit.h unittype.h 
        src/map        : map.c minimap.c 
        src/network    : commands.c 
        src/siod       : sliba.c 
        src/sound      : sound.c 
        src/ui         : botpanel.c interface.c mainscr.c menu_proc.c 
                         mouse.c 
        src/unit       : ccl_unit.c ccl_unittype.c unittype.c 
Removed files:
        src/action     : action_harvest.c 

Log message:
        A lot of work on resource gathering, some still bugs may still remain.
        Removed hardcoded unit types forever.
        Applied a path from jim4 for win32 compilation.

Patches:
Index: stratagus/data/ccl/ai.ccl
diff -u stratagus/data/ccl/ai.ccl:1.53 stratagus/data/ccl/ai.ccl:1.54
--- stratagus/data/ccl/ai.ccl:1.53      Thu Jul  3 13:30:01 2003
+++ stratagus/data/ccl/ai.ccl   Fri Sep  5 14:10:54 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: ai.ccl,v 1.53 2003/07/03 17:30:01 ingo Exp $
+;;     $Id: ai.ccl,v 1.54 2003/09/05 18:10:54 n0body Exp $
 
 ;(define (ai:sleep) () #t)
 
@@ -59,20 +59,7 @@
        'unit-alliance-shipyard 'unit-alliance-foundry 'unit-human-refinery
        'unit-inventor 'unit-stables 'unit-mage-tower 'unit-church
        'unit-gryphon-aviary 'unit-dark-portal 'unit-runestone)
-    (list 'build 'unit-peasant-with-gold
-       'unit-farm 'unit-alliance-barracks 'unit-town-hall 
'unit-elven-lumber-mill
-       'unit-alliance-blacksmith 'unit-alliance-watch-tower 'unit-human-wall
-       'unit-alliance-shipyard 'unit-alliance-foundry 'unit-human-refinery
-       'unit-inventor 'unit-stables 'unit-mage-tower 'unit-church
-       'unit-gryphon-aviary 'unit-dark-portal 'unit-runestone)
-    (list 'build 'unit-peasant-with-wood
-       'unit-farm 'unit-alliance-barracks 'unit-town-hall 
'unit-elven-lumber-mill
-       'unit-alliance-blacksmith 'unit-alliance-watch-tower 'unit-human-wall
-       'unit-alliance-shipyard 'unit-alliance-foundry 'unit-human-refinery
-       'unit-inventor 'unit-stables 'unit-mage-tower 'unit-church
-       'unit-gryphon-aviary 'unit-dark-portal 'unit-runestone)
     (list 'build 'unit-human-oil-tanker 'unit-alliance-oil-platform)
-    (list 'build 'unit-human-oil-tanker-full 'unit-alliance-oil-platform)
     ;;
     ;; Building can train which units.
     ;;
@@ -126,34 +113,12 @@
        'unit-inventor 'unit-stables 'unit-mage-tower 'unit-church
        'unit-gryphon-aviary 'unit-dark-portal 'unit-runestone
        'unit-alliance-transport)
-    (list 'repair 'unit-peasant-with-gold
-       'unit-farm 'unit-alliance-barracks 'unit-town-hall 'unit-keep 
'unit-castle
-       'unit-elven-lumber-mill 'unit-alliance-blacksmith 
'unit-alliance-watch-tower
-       'unit-alliance-guard-tower 'unit-alliance-cannon-tower 'unit-human-wall
-       'unit-alliance-shipyard 'unit-alliance-foundry 'unit-human-refinery
-       'unit-inventor 'unit-stables 'unit-mage-tower 'unit-church
-       'unit-gryphon-aviary 'unit-dark-portal 'unit-runestone
-       'unit-alliance-transport)
-    (list 'repair 'unit-peasant-with-wood
-       'unit-farm 'unit-alliance-barracks 'unit-town-hall 'unit-keep 
'unit-castle
-       'unit-elven-lumber-mill 'unit-alliance-blacksmith 
'unit-alliance-watch-tower
-       'unit-alliance-guard-tower 'unit-alliance-cannon-tower 'unit-human-wall
-       'unit-alliance-shipyard 'unit-alliance-foundry 'unit-human-refinery
-       'unit-inventor 'unit-stables 'unit-mage-tower 'unit-church
-       'unit-gryphon-aviary 'unit-dark-portal 'unit-runestone
-       'unit-alliance-transport)
     ;;
     ;; Workers can collect which resource.
     ;;
     (list 'collect 'unit-peasant 'gold 'wood 'ore 'stone 'coal)
     (list 'collect 'unit-human-oil-tanker 'oil )
     ;;
-    ;; Workers with resource.
-    ;;
-    (list 'with-goods 'unit-peasant-with-gold 'gold)
-    (list 'with-goods 'unit-peasant-with-wood 'wood)
-    (list 'with-goods 'unit-human-oil-tanker-full 'oil )
-    ;;
     ;; Reduce unit limits.
     ;;
     (list 'unit-limit 'unit-farm 'food)
@@ -168,10 +133,8 @@
        'unit-ranger)
     (list 'unit-equiv 'unit-knight
        'unit-paladin)
-    (list 'unit-equiv 'unit-peasant
-       'unit-peasant-with-gold 'unit-peasant-with-wood)
-    (list 'unit-equiv 'unit-human-oil-tanker
-       'unit-human-oil-tanker-full)
+    (list 'unit-equiv 'unit-peasant)
+    (list 'unit-equiv 'unit-human-oil-tanker)
     (list 'unit-equiv 'unit-alliance-watch-tower
         'unit-alliance-guard-tower 'unit-alliance-cannon-tower) )
 
@@ -190,22 +153,7 @@
        'unit-alchemist 'unit-ogre-mound 'unit-temple-of-the-damned
        'unit-altar-of-storms
        'unit-dragon-roost 'unit-dark-portal 'unit-runestone)
-    (list 'build 'unit-peon-with-gold
-       'unit-pig-farm 'unit-mythical-barracks 'unit-great-hall
-       'unit-troll-lumber-mill 'unit-mythical-blacksmith 
'unit-mythical-watch-tower
-       'unit-orc-wall 'unit-mythical-shipyard 'unit-mythical-foundry 
'unit-orc-refinery
-       'unit-alchemist 'unit-ogre-mound 'unit-temple-of-the-damned
-       'unit-altar-of-storms
-       'unit-dragon-roost 'unit-dark-portal 'unit-runestone)
-    (list 'build 'unit-peon-with-wood
-       'unit-pig-farm 'unit-mythical-barracks 'unit-great-hall
-       'unit-troll-lumber-mill 'unit-mythical-blacksmith 
'unit-mythical-watch-tower
-       'unit-orc-wall 'unit-mythical-shipyard 'unit-mythical-foundry 
'unit-orc-refinery
-       'unit-alchemist 'unit-ogre-mound 'unit-temple-of-the-damned
-       'unit-altar-of-storms
-       'unit-dragon-roost 'unit-dark-portal 'unit-runestone)
     (list 'build 'unit-orc-oil-tanker 'unit-mythical-oil-platform)
-    (list 'build 'unit-orc-oil-tanker-full 'unit-mythical-oil-platform)
     ;;
     ;; Building can train which units.
     ;;
@@ -260,34 +208,12 @@
        'unit-alchemist 'unit-ogre-mound 'unit-temple-of-the-damned
        'unit-altar-of-storms 'unit-dragon-roost 'unit-dark-portal
        'unit-runestone 'unit-mythical-transport)
-    (list 'repair 'unit-peon-with-gold
-       'unit-pig-farm 'unit-mythical-barracks 'unit-great-hall 'unit-stronghold
-       'unit-fortress 'unit-troll-lumber-mill 'unit-mythical-blacksmith
-       'unit-mythical-watch-tower 'unit-mythical-guard-tower 
'unit-mythical-cannon-tower
-       'unit-orc-wall 'unit-mythical-shipyard 'unit-mythical-foundry 
'unit-orc-refinery
-       'unit-alchemist 'unit-ogre-mound 'unit-temple-of-the-damned
-       'unit-altar-of-storms 'unit-dragon-roost 'unit-dark-portal
-       'unit-runestone 'unit-mythical-transport)
-    (list 'repair 'unit-peon-with-wood
-       'unit-pig-farm 'unit-mythical-barracks 'unit-great-hall 'unit-stronghold
-       'unit-fortress 'unit-troll-lumber-mill 'unit-mythical-blacksmith
-       'unit-mythical-watch-tower 'unit-mythical-guard-tower 
'unit-mythical-cannon-tower
-       'unit-orc-wall 'unit-mythical-shipyard 'unit-mythical-foundry 
'unit-orc-refinery
-       'unit-alchemist 'unit-ogre-mound 'unit-temple-of-the-damned
-       'unit-altar-of-storms 'unit-dragon-roost 'unit-dark-portal
-       'unit-runestone 'unit-mythical-transport)
     ;;
     ;; Workers can collect which resource.
     ;;
     (list 'collect 'unit-peon 'gold 'wood 'ore 'stone 'coal)
     (list 'collect 'unit-orc-oil-tanker 'oil )
     ;;
-    ;; Workers with resource.
-    ;;
-    (list 'with-goods 'unit-peon-with-gold 'gold)
-    (list 'with-goods 'unit-peon-with-wood 'wood)
-    (list 'with-goods 'unit-orc-oil-tanker-full 'oil )
-    ;;
     ;; Reduce unit limits.
     ;;
     (list 'unit-limit 'unit-pig-farm 'food)
@@ -302,10 +228,8 @@
        'unit-berserker)
     (list 'unit-equiv 'unit-ogre
        'unit-ogre-mage)
-    (list 'unit-equiv 'unit-peon
-       'unit-peon-with-gold 'unit-peon-with-wood)
-    (list 'unit-equiv 'unit-orc-oil-tanker
-       'unit-orc-oil-tanker-full)
+    (list 'unit-equiv 'unit-peon)
+    (list 'unit-equiv 'unit-orc-oil-tanker)
     (list 'unit-equiv 'unit-mythical-watch-tower
         'unit-mythical-guard-tower 'unit-mythical-cannon-tower) )
 
Index: stratagus/data/ccl/editor.ccl
diff -u stratagus/data/ccl/editor.ccl:1.12 stratagus/data/ccl/editor.ccl:1.13
--- stratagus/data/ccl/editor.ccl:1.12  Sat Aug  9 16:32:51 2003
+++ stratagus/data/ccl/editor.ccl       Fri Sep  5 14:10:54 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: editor.ccl,v 1.12 2003/08/09 20:32:51 n0body Exp $
+;;     $Id: editor.ccl,v 1.13 2003/09/05 18:10:54 n0body Exp $
 
 
 ;;     Set which icons to display
@@ -89,10 +89,6 @@
    'unit-wise-man
    'unit-man-of-light
 
-   'unit-peasant-with-gold
-   'unit-peasant-with-wood
-   'unit-human-oil-tanker-full
-
 ;- - - - - - - - - - - - - - - - - - -
 
    'unit-mythical-start-location
@@ -146,10 +142,6 @@
    'unit-ice-bringer
    'unit-double-head
    'unit-sharp-axe
-
-   'unit-peon-with-gold
-   'unit-peon-with-wood
-   'unit-orc-oil-tanker-full
 
 ;- - - - - - - - - - - - - - - - - - -
 
Index: stratagus/data/ccl/human/buttons.ccl
diff -u stratagus/data/ccl/human/buttons.ccl:1.25 
stratagus/data/ccl/human/buttons.ccl:1.26
--- stratagus/data/ccl/human/buttons.ccl:1.25   Sat Aug  9 16:32:51 2003
+++ stratagus/data/ccl/human/buttons.ccl        Fri Sep  5 14:10:54 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: buttons.ccl,v 1.25 2003/08/09 20:32:51 n0body Exp $
+;;     $Id: buttons.ccl,v 1.26 2003/09/05 18:10:54 n0body Exp $
 
 ;;----------------------------------------------------------------------------
 ;;     Define unit-button.
@@ -42,7 +42,7 @@
   'key "m" 'hint "~!MOVE"
   'for-unit '(unit-footman unit-knight unit-archer unit-paladin
     unit-dwarves unit-ranger unit-ballista unit-peasant
-    unit-peasant-with-gold unit-peasant-with-wood unit-female-hero
+    unit-female-hero
     unit-flying-angle unit-arthor-literios unit-knight-rider unit-wise-man
     unit-man-of-light unit-white-mage unit-balloon
     unit-gryphon-rider unit-mage unit-critter
@@ -53,7 +53,7 @@
   'key "s" 'hint "~!STOP"
   'for-unit '(unit-footman unit-knight unit-archer unit-paladin
     unit-dwarves unit-ranger unit-ballista unit-peasant
-    unit-peasant-with-gold unit-peasant-with-wood unit-female-hero
+    unit-female-hero
     unit-flying-angle unit-arthor-literios unit-knight-rider unit-wise-man
     unit-man-of-light unit-white-mage unit-balloon
     unit-gryphon-rider unit-mage unit-critter
@@ -80,7 +80,7 @@
   'key "a" 'hint "~!ATTACK"
   'for-unit '(unit-footman unit-knight unit-archer unit-paladin
     unit-dwarves unit-ranger unit-ballista unit-peasant
-    unit-peasant-with-gold unit-peasant-with-wood unit-female-hero
+    unit-female-hero
     unit-flying-angle unit-arthor-literios unit-knight-rider unit-wise-man
     unit-man-of-light unit-white-mage unit-gryphon-rider human-group))
 
@@ -234,7 +234,7 @@
 (define-button 'pos 4 'level 0 'icon 'icon-repair
   'action 'repair
   'key "r" 'hint "~!REPAIR"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 5 'level 0 'icon 'icon-harvest
   'action 'harvest
@@ -244,117 +244,117 @@
 (define-button 'pos 6 'level 0 'icon 'icon-return-goods-peasant
   'action 'return-goods
   'key "g" 'hint "RETURN WITH ~!GOODS"
-  'for-unit '(unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 ;; build basic/advanced structs -----------------------------------------------
 
 (define-button 'pos 7 'level 0 'icon 'icon-build-basic
   'action 'button 'value 1
   'key "b" 'hint "~!BUILD BASIC STRUCTURE"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 8 'level 0 'icon 'icon-build-advanced
   'action 'button 'value 2
   'allowed 'check-units-or 'allow-arg '(unit-elven-lumber-mill unit-keep)
   'key "v" 'hint "BUILD AD~!VANCED STRUCTURE"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (if extensions
 (define-button 'pos 9 'level 0 'icon 'icon-build-advanced
   'action 'button 'value 3
   'allowed 'check-units-and 'allow-arg '(unit-castle unit-mage-tower 
unit-church)
   'key "e" 'hint "BUILD SP~!ECIAL STRUCTURE"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood)) )
+  'for-unit '(unit-peasant)) )
 
 ;; simple buildings human -----------------------------------------------------
 
 (define-button 'pos 1 'level 1 'icon 'icon-farm
   'action 'build 'value 'unit-farm
   'key "f" 'hint "BUILD ~!FARM"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 2 'level 1 'icon 'icon-alliance-barracks
   'action 'build 'value 'unit-alliance-barracks
   'key "b" 'hint "BUILD ~!BARRACKS"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 3 'level 1 'icon 'icon-town-hall
   'action 'build 'value 'unit-town-hall
   'key "h" 'hint "BUILD TOWN ~!HALL"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 4 'level 1 'icon 'icon-elven-lumber-mill
   'action 'build 'value 'unit-elven-lumber-mill
   'key "l" 'hint "BUILD ELVEN ~!LUMBER MILL"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 5 'level 1 'icon 'icon-alliance-blacksmith
   'action 'build 'value 'unit-alliance-blacksmith
   'key "s" 'hint "BUILD BLACK~!SMITH"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 7 'level 1 'icon 'icon-alliance-watch-tower
   'action 'build 'value 'unit-alliance-watch-tower
   'key "t" 'hint "BUILD ~!TOWER"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 8 'level 1 'icon 'icon-alliance-wall
   'action 'build 'value 'unit-human-wall
   'allowed 'check-network
   'key "w" 'hint "BUILD ~!WALL"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 9 'level 1 'icon 'icon-cancel
   'action 'button 'value 0
   'key "\033" 'hint "~<ESC~> CANCEL"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 ;; human advanced buildings ---------------------------------------------------
 
 (define-button 'pos 1 'level 2 'icon 'icon-alliance-shipyard
   'action 'build 'value 'unit-alliance-shipyard
   'key "s" 'hint "BUILD ~!SHIPYARD"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 2 'level 2 'icon 'icon-alliance-foundry
   'action 'build 'value 'unit-alliance-foundry
   'key "f" 'hint "BUILD ~!FOUNDRY"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 3 'level 2 'icon 'icon-alliance-refinery
   'action 'build 'value 'unit-human-refinery
   'key "r" 'hint "BUILD ~!REFINERY"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 4 'level 2 'icon 'icon-gnomish-inventor
   'action 'build 'value 'unit-inventor
   'key "i" 'hint "BUILD GNOMISH ~!INVENTOR"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 5 'level 2 'icon 'icon-stables
   'action 'build 'value 'unit-stables
   'key "a" 'hint "BUILD ST~!ABLES"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 6 'level 2 'icon 'icon-mage-tower
   'action 'build 'value 'unit-mage-tower
   'key "m" 'hint "BUILD ~!MAGE TOWER"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 7 'level 2 'icon 'icon-church
   'action 'build 'value 'unit-church
   'key "c" 'hint "BUILD ~!CHURCH"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 8 'level 2 'icon 'icon-gryphon-aviary
   'action 'build 'value 'unit-gryphon-aviary
   'key "g" 'hint "BUILD ~!GRYPHON AVIARY"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 9 'level 2 'icon 'icon-cancel
   'action 'button 'value 0
   'key "\033" 'hint "~<ESC~> CANCEL"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 ;; human special buildings ----------------------------------------------------
 
@@ -362,18 +362,18 @@
   'action 'build 'value 'unit-dark-portal
   'allowed 'check-no-network
   'key "p" 'hint "BUILD DARK ~!PORTAL"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 2 'level 3 'icon 'icon-runestone
   'action 'build 'value 'unit-runestone
   'allowed 'check-no-network
   'key "r" 'hint "BUILD ~!RUNESTONE"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 (define-button 'pos 9 'level 3 'icon 'icon-cancel
   'action 'button 'value 0
   'key "\033" 'hint "~<ESC~> CANCEL"
-  'for-unit '(unit-peasant unit-peasant-with-gold unit-peasant-with-wood))
+  'for-unit '(unit-peasant))
 
 ;; buildings commands ---------------------------------------------------------
 
@@ -526,14 +526,14 @@
 (define-button 'pos 1 'level 0 'icon 'icon-alliance-ship-move
   'action 'move
   'key "m" 'hint "~!MOVE"
-  'for-unit '(unit-human-oil-tanker unit-human-oil-tanker-full
+  'for-unit '(unit-human-oil-tanker
     unit-alliance-submarine unit-battleship unit-alliance-destroyer
     unit-alliance-transport))
 
 (define-button 'pos 2 'level 0 'icon 'icon-alliance-ship-armor1
   'action 'stop
   'key "s" 'hint "~!STOP"
-  'for-unit '(unit-human-oil-tanker unit-human-oil-tanker-full
+  'for-unit '(unit-human-oil-tanker
     unit-alliance-submarine unit-battleship unit-alliance-destroyer
     unit-alliance-transport))
 
@@ -555,7 +555,7 @@
 (define-button 'pos 6 'level 0 'icon 'icon-alliance-ship-return-oil
   'action 'return-goods
   'key "g" 'hint "RETURN WITH ~!GOODS"
-  'for-unit '(unit-human-oil-tanker-full))
+  'for-unit '(unit-human-oil))
 
 (define-button 'pos 3 'level 0 'icon 'icon-alliance-ship-cannon1
   'action 'attack
Index: stratagus/data/ccl/human/units.ccl
diff -u stratagus/data/ccl/human/units.ccl:1.31 
stratagus/data/ccl/human/units.ccl:1.32
--- stratagus/data/ccl/human/units.ccl:1.31     Wed Sep  3 05:27:50 2003
+++ stratagus/data/ccl/human/units.ccl  Fri Sep  5 14:10:54 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.31 2003/09/03 09:27:50 mr-russ Exp $
+;;     $Id: units.ccl,v 1.32 2003/09/05 18:10:54 n0body Exp $
 
 ;;=============================================================================
 ;;     Define unit-types.
@@ -66,8 +66,6 @@
     dead "basic human voices dead"
     attack "footman-attack"))
 
-(define-unit-type 'unit-peasant-with-gold)
-
 (define-unit-type 'unit-peasant 'name "Peasant"
   'files '(tileset-summer "human/units/peasant.png")
   'size '(72 72)
@@ -91,10 +89,22 @@
   'can-target-land
   'land-unit
   'coward
-  'harvester 'resource-harvested 'gold 'resource-capacity 100
-  'resource-step 10 'wait-at-resource 15 'wait-at-depot 150
-  'transform-when-loaded 'unit-peasant-with-gold
-;; 'harvest-from-outside
+  'harvester
+  'can-gather-resource '(
+       file-when-loaded "human/units/peasant_with_gold.png"  
+       resource-id gold
+       resource-capacity 100
+       wait-at-resource 150
+       wait-at-depot 150 )
+  'can-gather-resource '(
+       file-when-loaded "human/units/peasant_with_wood.png"  
+       resource-id wood
+       resource-capacity 100
+       resource-step 2
+       wait-at-resource 24
+       wait-at-depot 150
+       lose-resources
+       terrain-harvester )
   'organic
   'selectable-by-rectangle
   'sounds '(
@@ -105,74 +115,6 @@
     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 'repair-range 1
-  'can-target-land
-  'land-unit
-  'coward
-  'harvester 'resource-harvested 'gold 'resource-capacity 100
-  'resource-step 10 'wait-at-resource 15 'wait-at-depot 150
-  'transform-when-empty 'unit-peasant
-;;'harvest-from-outside
-  '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 'repair-range 1
-  'can-target-land
-  'land-unit
-  'coward
-  '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-ballista 'name "Ballista"
   'files '(tileset-summer "human/units/ballista.png")
   'size '(64 64)
@@ -498,8 +440,6 @@
     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)
@@ -519,40 +459,14 @@
   'type-naval
   'right-harvest
   'sea-unit 'coward
-  '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"
-    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-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-harvest
-  'sea-unit 'coward
-  'harvester 'resource-harvested 'oil 'resource-capacity 100
-  'wait-at-resource 100 'wait-at-depot 100
-  'transform-when-empty 'unit-human-oil-tanker
+  'harvester
+  'can-gather-resource '(
+      file-when-empty "human/units/oil_tanker_empty.png"
+      file-when-loaded "human/units/oil_tanker_full.png"
+      resource-id oil
+      resource-capacity 100
+      wait-at-resource 100
+      wait-at-depot 100)
   'selectable-by-rectangle
   'sounds '(
     selected "human-oil-tanker-selected"
Index: stratagus/data/ccl/human/upgrade.ccl
diff -u stratagus/data/ccl/human/upgrade.ccl:1.14 
stratagus/data/ccl/human/upgrade.ccl:1.15
--- stratagus/data/ccl/human/upgrade.ccl:1.14   Sat Aug  9 16:32:51 2003
+++ stratagus/data/ccl/human/upgrade.ccl        Fri Sep  5 14:10:54 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: upgrade.ccl,v 1.14 2003/08/09 20:32:51 n0body Exp $
+;;     $Id: upgrade.ccl,v 1.15 2003/09/05 18:10:54 n0body Exp $
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;=============================================================================
@@ -286,9 +286,6 @@
 (define-allow 'unit-alliance-guard-tower               "AAAAAAAAAAAAAAAA")
 (define-allow 'unit-alliance-cannon-tower              "AAAAAAAAAAAAAAAA")
 (define-allow 'unit-human-wall                 "AAAAAAAAAAAAAAAA")
-(define-allow 'unit-peasant-with-gold          "AAAAAAAAAAAAAAAA")
-(define-allow 'unit-peasant-with-wood          "AAAAAAAAAAAAAAAA")
-(define-allow 'unit-human-oil-tanker-full      "AAAAAAAAAAAAAAAA")
 
 ;;     - upgrades
 
Index: stratagus/data/ccl/orc/buttons.ccl
diff -u stratagus/data/ccl/orc/buttons.ccl:1.25 
stratagus/data/ccl/orc/buttons.ccl:1.26
--- stratagus/data/ccl/orc/buttons.ccl:1.25     Sat Aug  9 16:32:51 2003
+++ stratagus/data/ccl/orc/buttons.ccl  Fri Sep  5 14:10:55 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: buttons.ccl,v 1.25 2003/08/09 20:32:51 n0body Exp $
+;;     $Id: buttons.ccl,v 1.26 2003/09/05 18:10:55 n0body Exp $
 
 ;;----------------------------------------------------------------------------
 ;;     Define unit-button.
@@ -42,7 +42,7 @@
   'key "m" 'hint "~!MOVE"
   'for-unit '(unit-grunt unit-ogre unit-axethrower unit-ogre-mage
     unit-goblin-sappers unit-berserker unit-catapult unit-peon
-    unit-peon-with-gold unit-peon-with-wood unit-fad-man unit-double-head
+    unit-fad-man unit-double-head
     unit-sharp-axe unit-beast-cry unit-quick-blade unit-ice-bringer
     unit-evil-knight unit-skeleton unit-eye-of-vision unit-dragon
     unit-zeppelin unit-death-knight unit-fire-breeze
@@ -53,7 +53,7 @@
   'key "s" 'hint "~!STOP"
   'for-unit '(unit-grunt unit-ogre unit-axethrower unit-ogre-mage
     unit-goblin-sappers unit-berserker unit-catapult unit-peon
-    unit-peon-with-gold unit-peon-with-wood unit-fad-man unit-double-head
+    unit-fad-man unit-double-head
     unit-sharp-axe unit-beast-cry unit-quick-blade unit-ice-bringer
     unit-evil-knight unit-skeleton unit-eye-of-vision unit-dragon
     unit-zeppelin unit-death-knight unit-fire-breeze
@@ -80,7 +80,7 @@
   'key "a" 'hint "~!ATTACK"
   'for-unit '(unit-grunt unit-ogre unit-axethrower unit-ogre-mage
     unit-goblin-sappers unit-berserker unit-catapult unit-peon
-    unit-peon-with-gold unit-peon-with-wood unit-fad-man unit-double-head
+    unit-fad-man unit-double-head
     unit-sharp-axe unit-beast-cry unit-quick-blade unit-ice-bringer
     unit-evil-knight unit-skeleton unit-dragon unit-fire-breeze
     orc-group unit-daemon))
@@ -166,7 +166,7 @@
   'key "d" 'hint "~!DEMOLISH"
   'for-unit '(unit-grunt unit-ogre unit-axethrower unit-ogre-mage
     unit-goblin-sappers unit-berserker unit-catapult unit-peon
-    unit-peon-with-gold unit-peon-with-wood unit-fad-man unit-double-head
+    unit-fad-man unit-double-head
     unit-sharp-axe unit-beast-cry unit-quick-blade unit-ice-bringer
     unit-evil-knight unit-skeleton unit-eye-of-vision unit-dragon
     unit-zeppelin orc-group))
@@ -259,7 +259,7 @@
 (define-button 'pos 4 'level 0 'icon 'icon-repair
   'action 'repair
   'key "r" 'hint "~!REPAIR"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 5 'level 0 'icon 'icon-harvest
   'action 'harvest
@@ -269,117 +269,117 @@
 (define-button 'pos 6 'level 0 'icon 'icon-return-goods-peon
   'action 'return-goods
   'key "g" 'hint "RETURN WITH ~!GOODS"
-  'for-unit '(unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 ;; build basic/advanced structs -----------------------------------------------
 
 (define-button 'pos 7 'level 0 'icon 'icon-build-basic
   'action 'button 'value 1
   'key "b" 'hint "~!BUILD BASIC STRUCTURE"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 8 'level 0 'icon 'icon-build-advanced
   'action 'button 'value 2
   'allowed 'check-units-or 'allow-arg '(unit-troll-lumber-mill unit-stronghold)
   'key "v" 'hint "BUILD AD~!VANCED STRUCTURE"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 9 'level 0 'icon 'icon-build-advanced
   'action 'button 'value 3
   'allowed 'check-units-and 'allow-arg '(unit-fortress 
unit-temple-of-the-damned
     unit-altar-of-storms)
   'key "e" 'hint "BUILD SP~!ECIAL STRUCTURE"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 ;; simple buildings orc -------------------------------------------------------
 
 (define-button 'pos 1 'level 1 'icon 'icon-pig-farm
   'action 'build 'value 'unit-pig-farm
   'key "f" 'hint "BUILD PIG ~!FARM"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 2 'level 1 'icon 'icon-mythical-barracks
   'action 'build 'value 'unit-mythical-barracks
   'key "b" 'hint "BUILD ~!BARRACKS"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 3 'level 1 'icon 'icon-great-hall
   'action 'build 'value 'unit-great-hall
   'key "h" 'hint "BUILD GREAT ~!HALL"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 4 'level 1 'icon 'icon-troll-lumber-mill
   'action 'build 'value 'unit-troll-lumber-mill
   'key "l" 'hint "BUILD TROLL ~!LUMBER MILL"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 5 'level 1 'icon 'icon-mythical-blacksmith
   'action 'build 'value 'unit-mythical-blacksmith
   'key "s" 'hint "BUILD BLACK~!SMITH"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 7 'level 1 'icon 'icon-mythical-watch-tower
   'action 'build 'value 'unit-mythical-watch-tower
   'key "t" 'hint "BUILD ~!TOWER"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 8 'level 1 'icon 'icon-mythical-wall
   'action 'build 'value 'unit-orc-wall
   'allowed 'check-network
   'key "w" 'hint "BUILD ~!WALL"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 9 'level 1 'icon 'icon-cancel
   'action 'button 'value 0
   'key "\033" 'hint "~<ESC~> CANCEL"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 ;; orc advanced buildings -----------------------------------------------------
 
 (define-button 'pos 1 'level 2 'icon 'icon-mythical-shipyard
   'action 'build 'value 'unit-mythical-shipyard
   'key "s" 'hint "BUILD ~!SHIPYARD"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 2 'level 2 'icon 'icon-mythical-foundry
   'action 'build 'value 'unit-mythical-foundry
   'key "f" 'hint "BUILD ~!FOUNDRY"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 3 'level 2 'icon 'icon-mythical-refinery
   'action 'build 'value 'unit-orc-refinery
   'key "r" 'hint "BUILD ~!REFINERY"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 4 'level 2 'icon 'icon-alchemist
   'action 'build 'value 'unit-alchemist
   'key "a" 'hint "BUILD GOBLIN ~!ALCHEMIST"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 5 'level 2 'icon 'icon-ogre-mound
   'action 'build 'value 'unit-ogre-mound
   'key "o" 'hint "BUILD ~!OGRE MOUND"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 6 'level 2 'icon 'icon-temple-of-the-damned
   'action 'build 'value 'unit-temple-of-the-damned
   'key "t" 'hint "BUILD ~!TEMPLE OF THE DAMNED"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 7 'level 2 'icon 'icon-altar-of-storms
   'action 'build 'value 'unit-altar-of-storms
   'key "l" 'hint "BUILD A~!LTAR OF STORMS"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 8 'level 2 'icon 'icon-dragon-roost
   'action 'build 'value 'unit-dragon-roost
   'key "d" 'hint "BUILD ~!DRAGON ROOST"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 9 'level 2 'icon 'icon-cancel
   'action 'button 'value 0
   'key "\033" 'hint "~<ESC~> CANCEL"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 ;; orc special buildings ------------------------------------------------------
 
@@ -387,18 +387,18 @@
   'action 'build 'value 'unit-dark-portal
   'allowed 'check-no-network
   'key "p" 'hint "BUILD DARK ~!PORTAL"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 2 'level 3 'icon 'icon-runestone
   'action 'build 'value 'unit-runestone
   'allowed 'check-no-network
   'key "r" 'hint "BUILD ~!RUNESTONE"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 (define-button 'pos 9 'level 3 'icon 'icon-cancel
   'action 'button 'value 0
   'key "\033" 'hint "~<ESC~> CANCEL"
-  'for-unit '(unit-peon unit-peon-with-gold unit-peon-with-wood))
+  'for-unit '(unit-peon))
 
 ;; orc buildings commands -----------------------------------------------------
 
@@ -554,13 +554,13 @@
 (define-button 'pos 1 'level 0 'icon 'icon-mythical-ship-move
   'action 'move
   'key "m" 'hint "~!MOVE"
-  'for-unit '(unit-orc-oil-tanker unit-orc-oil-tanker-full 
unit-mythical-submarine
+  'for-unit '(unit-orc-oil-tanker unit-mythical-submarine
     unit-ogre-juggernaught unit-mythical-destroyer unit-mythical-transport))
 
 (define-button 'pos 2 'level 0 'icon 'icon-mythical-ship-armor1
   'action 'stop
   'key "s" 'hint "~!STOP"
-  'for-unit '(unit-orc-oil-tanker unit-orc-oil-tanker-full 
unit-mythical-submarine
+  'for-unit '(unit-orc-oil-tanker unit-mythical-submarine
     unit-ogre-juggernaught unit-mythical-destroyer unit-mythical-transport))
 
 (define-button 'pos 3 'level 0 'icon 'icon-mythical-unload
@@ -581,7 +581,7 @@
 (define-button 'pos 6 'level 0 'icon 'icon-mythical-ship-return-oil
   'action 'return-goods
   'key "g" 'hint "RETURN WITH ~!GOODS"
-  'for-unit '(unit-orc-oil-tanker-full))
+  'for-unit '(unit-orc-oil))
 
 (define-button 'pos 3 'level 0 'icon 'icon-mythical-ship-cannon1
   'action 'attack
Index: stratagus/data/ccl/orc/units.ccl
diff -u stratagus/data/ccl/orc/units.ccl:1.35 
stratagus/data/ccl/orc/units.ccl:1.36
--- stratagus/data/ccl/orc/units.ccl:1.35       Wed Sep  3 05:27:50 2003
+++ stratagus/data/ccl/orc/units.ccl    Fri Sep  5 14:10:55 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.35 2003/09/03 09:27:50 mr-russ Exp $
+;;     $Id: units.ccl,v 1.36 2003/09/05 18:10:55 n0body Exp $
 
 ;;=============================================================================
 ;;     Define unit-types.
@@ -63,8 +63,6 @@
     dead "basic orc voices dead"
     attack "grunt-attack"))
 
-(define-unit-type 'unit-peon-with-gold)
-
 (define-unit-type 'unit-peon 'name "Peon"
   'files '(tileset-summer "orc/units/peon.png")
   'size '(72 72)
@@ -87,9 +85,22 @@
   'can-target-land
   'land-unit
   'coward
-  'harvester 'resource-harvested 'gold 'resource-capacity 100
-  'wait-at-resource 150 'wait-at-depot 150
-  'transform-when-loaded 'unit-peon-with-gold
+  'harvester
+  'can-gather-resource '(
+       file-when-loaded "orc/units/peon_with_gold.png"
+       resource-id gold
+       resource-capacity 100
+       wait-at-resource 150
+       wait-at-depot 150)
+  'can-gather-resource '(
+       file-when-loaded "orc/units/peon_with_wood.png"
+       resource-id wood
+       resource-capacity 100
+       resource-step 2
+       wait-at-resource 24
+       wait-at-depot 150
+       lose-resources
+       terrain-harvester )
   'organic
   'selectable-by-rectangle
   'sounds '(
@@ -100,73 +111,6 @@
     dead "basic orc voices dead"
     attack "peon-attack"))
 
-(define-unit-type 'unit-peon-with-gold 'name "Peon"
-  'files '(tileset-summer "orc/units/peon_with_gold.png")
-  'size '(72 72)
-  'animations 'animations-peasant 'icon 'icon-peon
-  '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 0)
-  'type-land
-  'right-harvest
-  'can-attack 'repair-range 1
-  'can-target-land
-  'land-unit
-  'coward
-  'harvester 'resource-harvested 'gold 'resource-capacity 100
-  'wait-at-resource 150 'wait-at-depot 150
-  'transform-when-empty 'unit-peon
-  'organic
-  'selectable-by-rectangle
-  'sounds '(
-    selected "peon-with-gold-selected"
-    acknowledge "peon-with-gold-acknowledge"
-    ready "peon-with-gold-ready"
-    help "basic orc voices help 1"
-    dead "basic orc voices dead"
-    attack "peon-with-gold-attack"))
-
-(define-unit-type 'unit-peon-with-wood 'name "Peon"
-  'files '(tileset-summer "orc/units/peon_with_wood.png")
-  'size '(72 72)
-  'animations 'animations-peasant 'icon 'icon-peon
-  '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 0)
-  'type-land
-  'right-harvest
-  'can-attack 'repair-range 1
-  'can-target-land
-  'land-unit
-  'coward
-  'organic
-  'selectable-by-rectangle
-  'sounds '(
-    selected "peon-with-wood-selected"
-    acknowledge "peon-with-wood-acknowledge"
-    ready "peon-with-wood-ready"
-    help "basic orc voices help 1"
-    dead "basic orc voices dead"
-    attack "peon-with-wood-attack"))
-
 (define-unit-type 'unit-catapult 'name "Catapult"
   'files '(tileset-summer "orc/units/catapult.png")
   'size '(64 64)
@@ -498,8 +442,6 @@
     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)
@@ -519,9 +461,14 @@
   'type-naval
   'right-harvest
   'sea-unit 'coward
-  'harvester 'resource-harvested 'oil 'resource-capacity 100
-  'wait-at-resource 100 'wait-at-depot 100
-  'transform-when-loaded 'unit-orc-oil-tanker-full
+  'harvester
+  'can-gather-resource '(
+        file-when-empty "human/units/oil_tanker_empty.png"
+        file-when-loaded "human/units/oil_tanker_full.png"
+       resource-id oil
+        resource-capacity 100
+       wait-at-resource 100
+       wait-at-depot 100 )
   'selectable-by-rectangle
   'sounds '(
     selected "orc-oil-tanker-selected"
@@ -531,37 +478,6 @@
     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-harvest
-  'sea-unit 'coward
-  '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)
Index: stratagus/data/ccl/orc/upgrade.ccl
diff -u stratagus/data/ccl/orc/upgrade.ccl:1.14 
stratagus/data/ccl/orc/upgrade.ccl:1.15
--- stratagus/data/ccl/orc/upgrade.ccl:1.14     Sat Aug  9 16:32:51 2003
+++ stratagus/data/ccl/orc/upgrade.ccl  Fri Sep  5 14:10:55 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: upgrade.ccl,v 1.14 2003/08/09 20:32:51 n0body Exp $
+;;     $Id: upgrade.ccl,v 1.15 2003/09/05 18:10:55 n0body Exp $
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;=============================================================================
@@ -284,9 +284,6 @@
 (define-allow 'unit-mythical-guard-tower       "AAAAAAAAAAAAAAAA")
 (define-allow 'unit-mythical-cannon-tower      "AAAAAAAAAAAAAAAA")
 (define-allow 'unit-orc-wall                   "AAAAAAAAAAAAAAAA")
-(define-allow 'unit-peon-with-gold             "AAAAAAAAAAAAAAAA")
-(define-allow 'unit-peon-with-wood             "AAAAAAAAAAAAAAAA")
-(define-allow 'unit-orc-oil-tanker-full                "AAAAAAAAAAAAAAAA")
 
 ;;     - upgrades
 
Index: stratagus/data/ccl/sound.ccl
diff -u stratagus/data/ccl/sound.ccl:1.34 stratagus/data/ccl/sound.ccl:1.35
--- stratagus/data/ccl/sound.ccl:1.34   Sat Aug  2 09:37:06 2003
+++ stratagus/data/ccl/sound.ccl        Fri Sep  5 14:10:54 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: sound.ccl,v 1.34 2003/08/02 13:37:06 grumbel Exp $
+;;     $Id: sound.ccl,v 1.35 2003/09/05 18:10:54 n0body Exp $
 
 ;;     Uncomment this to enable threaded sound
 ;(sound-thread)
@@ -692,12 +692,6 @@
 (map-sound "gul-dan-acknowledge" "death-knight-acknowledge")
 (map-sound "uther-lightbringer-acknowledge" "paladin-acknowledge")
 (map-sound "zuljin-acknowledge" "troll axethrower-berserker acknowledge")
-(map-sound "peon-with-gold-acknowledge" "basic orc voices acknowledge")
-(map-sound "peasant-with-gold-acknowledge" "peasant-acknowledge")
-(map-sound "peon-with-wood-acknowledge" "basic orc voices acknowledge")
-(map-sound "peasant-with-wood-acknowledge" "peasant-acknowledge")
-(map-sound "human-oil-tanker-full-acknowledge" "tanker acknowledge")
-(map-sound "orc-oil-tanker-full-acknowledge" "tanker acknowledge")
     ;;  ready sounds
 (map-sound "footman-ready" "basic human voices ready")
 (map-sound "grunt-ready" "basic orc voices ready")
@@ -765,12 +759,6 @@
 (map-sound "orc-guard-tower-selected" "click")
 (map-sound "human-cannon-tower-selected" "click")
 (map-sound "orc-cannon-tower-selected" "click")
-(map-sound "peon-with-gold-selected" "peon-selected")
-(map-sound "peasant-with-gold-selected" "peasant-selected")
-(map-sound "peon-with-wood-selected" "peon-selected")
-(map-sound "peasant-with-wood-selected" "peasant-selected")
-(map-sound "human-oil-tanker-full-selected" "human-oil-tanker-selected")
-(map-sound "orc-oil-tanker-full-selected" "orc-oil-tanker-selected")
     ;; attack sounds
 (map-sound "footman-attack" "sword attack")
 (map-sound "grunt-attack" "sword attack")
@@ -822,10 +810,6 @@
 ;;     (map-sound "orc-guard-tower-attack")
 ;;     (map-sound "human-cannon-tower-attack")
 ;;     (map-sound "orc-cannon-tower-attack")
-(map-sound "peon-with-gold-attack" "peasant-attack")
-(map-sound "peasant-with-gold-attack" "peasant-attack")
-(map-sound "peon-with-wood-attack" "peasant-attack")
-(map-sound "peasant-with-wood-attack" "peasant-attack")
 
 (map-sound "critter-help" "basic orc voices help 1")
 (map-sound "critter-dead" "explosion")
Index: stratagus/data/ccl/stratagus.ccl
diff -u stratagus/data/ccl/stratagus.ccl:1.11 
stratagus/data/ccl/stratagus.ccl:1.12
--- stratagus/data/ccl/stratagus.ccl:1.11       Wed Sep  3 09:24:28 2003
+++ stratagus/data/ccl/stratagus.ccl    Fri Sep  5 14:10:54 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: stratagus.ccl,v 1.11 2003/09/03 13:24:28 martinxyz Exp $
+;;     $Id: stratagus.ccl,v 1.12 2003/09/05 18:10:54 n0body Exp $
 
 ;; For documentation see stratagus/doc/ccl/ccl.html
 
@@ -77,8 +77,10 @@
 (set-color-cycle-all! #t)
 ;(set-color-cycle-all! #f)
 
-;;     FIXME: documentation
+;;     Set the game name. It's used so we can mantain different savegames
+;;     and setting. Might also be used for multiplayer.
 (set-game-name! "wc2")
+;;     set the default map file.
 (set-default-map! "puds/default.pud")
 
 ;;-----------------------------------------------------------------------------
Index: stratagus/data/ccl/wc2.ccl
diff -u stratagus/data/ccl/wc2.ccl:1.33 stratagus/data/ccl/wc2.ccl:1.34
--- stratagus/data/ccl/wc2.ccl:1.33     Sat Aug  9 16:32:51 2003
+++ stratagus/data/ccl/wc2.ccl  Fri Sep  5 14:10:54 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: wc2.ccl,v 1.33 2003/08/09 20:32:51 n0body Exp $
+;;     $Id: wc2.ccl,v 1.34 2003/09/05 18:10:54 n0body Exp $
 
 ;;=============================================================================
 ;;     Define race names
@@ -116,9 +116,7 @@
     'unit-runestone 'unit-human-wall 'unit-orc-wall 'unit-dead-body
     'unit-destroyed-1x1-place 'unit-destroyed-2x2-place
     'unit-destroyed-3x3-place 'unit-destroyed-4x4-place
-    'unit-peasant-with-gold 'unit-peon-with-gold 'unit-peasant-with-wood
-    'unit-peon-with-wood 'unit-human-oil-tanker-full
-    'unit-orc-oil-tanker-full)
+    'unit-peasant 'unit-peon 'unit-peasant 'unit-peon 'unit-human-oil-tanker 
'unit-orc-oil-tanker)
 
 ;;=============================================================================
 ;;     Define missiletype mapping from original number to internal symbol
Index: stratagus/doc/ChangeLog.html
diff -u stratagus/doc/ChangeLog.html:1.521 stratagus/doc/ChangeLog.html:1.522
--- stratagus/doc/ChangeLog.html:1.521  Wed Sep  3 09:30:42 2003
+++ stratagus/doc/ChangeLog.html        Fri Sep  5 14:10:55 2003
@@ -2,7 +2,7 @@
 <html>
 <head>
 <!--
-----   $Id: ChangeLog.html,v 1.521 2003/09/03 13:30:42 martinxyz Exp $
+----   $Id: ChangeLog.html,v 1.522 2003/09/05 18:10:55 n0body Exp $
 
 ----   (c) Copyright 1998-2003 by Lutz Sammer
 
@@ -36,6 +36,7 @@
 <li>Future 1.19 Release<p>
     <ul>
     <li>++
+    <li>New resource harvesting, no hardcoded unit types (from Crestez 
Leonard). 
     <li>NEW_UI: Fixed save/load (from Martin Renold).
     <li>Pathfinder fixes for when the goal moves (EXPERIMENTAL) (from Russell 
Smith).
     <li>Added repair-costs and repair-hp for units that can be repaired (from 
Russell Smith).
Index: stratagus/src/action/Module.make
diff -u stratagus/src/action/Module.make:1.7 
stratagus/src/action/Module.make:1.8
--- stratagus/src/action/Module.make:1.7        Sun Aug 10 22:14:45 2003
+++ stratagus/src/action/Module.make    Fri Sep  5 14:10:55 2003
@@ -27,11 +27,11 @@
 
 MODULE = src/action
 MSRC =  action_attack.c action_board.c action_build.c action_demolish.c \
-        action_die.c action_follow.c action_harvest.c \
-        action_move.c action_patrol.c action_repair.c action_research.c \
-        action_resource.c action_returngoods.c action_spellcast.c \
-        action_stand.c action_still.c action_train.c action_unload.c \
-        action_upgradeto.c actions.c command.c 
+        action_die.c action_follow.c action_move.c action_patrol.c \
+        action_repair.c action_research.c action_resource.c \
+        action_returngoods.c action_spellcast.c action_stand.c \
+        action_still.c action_train.c action_unload.c action_upgradeto.c \
+        actions.c command.c 
 
 SRC+=  $(addprefix $(MODULE)/,$(MSRC))
 HDRS+=
Index: stratagus/src/action/action_build.c
diff -u stratagus/src/action/action_build.c:1.93 
stratagus/src/action/action_build.c:1.94
--- stratagus/src/action/action_build.c:1.93    Mon Sep  1 08:32:17 2003
+++ stratagus/src/action/action_build.c Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_build.c,v 1.93 2003/09/01 12:32:17 mr-russ Exp $
+//     $Id: action_build.c,v 1.94 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -392,7 +392,7 @@
                //
                //      If we can harvest from the new building, do it.
                //
-               if 
(worker->Type->Harvester&&worker->Type->ResourceHarvested==type->GivesResource) 
{
+               if (worker->Type->ResInfo[type->GivesResource]) {
                    CommandResource(worker,unit,0);
                }
            }
Index: stratagus/src/action/action_move.c
diff -u stratagus/src/action/action_move.c:1.63 
stratagus/src/action/action_move.c:1.64
--- stratagus/src/action/action_move.c:1.63     Mon Aug 25 07:21:15 2003
+++ stratagus/src/action/action_move.c  Fri Sep  5 14:10:55 2003
@@ -21,7 +21,7 @@
 //     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //     GNU General Public License for more details.
 //
-//     $Id: action_move.c,v 1.63 2003/08/25 11:21:15 mr-russ Exp $
+//     $Id: action_move.c,v 1.64 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -78,6 +78,8 @@
     // FIXME: state 0?, should be wrong, should be Reset.
     // FIXME: Reset flag is cleared by HandleUnitAction.
     if( !(state=unit->State) ) {
+       //  FIXME: So units flying up and down are not affected.
+       unit->IX=unit->IY=0;
 
 #ifdef HIERARCHIC_PATHFINDER
        d = PfHierComputePath (unit, &xd, &yd);
Index: stratagus/src/action/action_resource.c
diff -u stratagus/src/action/action_resource.c:1.50 
stratagus/src/action/action_resource.c:1.51
--- stratagus/src/action/action_resource.c:1.50 Thu Aug 28 18:51:41 2003
+++ stratagus/src/action/action_resource.c      Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_resource.c,v 1.50 2003/08/28 22:51:41 n0body Exp $
+//     $Id: action_resource.c,v 1.51 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -50,7 +50,7 @@
 ----------------------------------------------------------------------------*/
 
 #define SUB_START_RESOURCE 0
-#define SUB_MOVE_TO_RESOURCE 1
+#define SUB_MOVE_TO_RESOURCE 5
 #define SUB_UNREACHABLE_RESOURCE 31
 #define SUB_START_GATHERING 55
 #define SUB_GATHER_RESOURCE 60
@@ -73,24 +73,62 @@
 local int MoveToResource(Unit* unit)
 {
     Unit* goal;
+    ResourceInfo* resinfo;
+    int x;
+    int y;
 
-    goal=unit->Orders[0].Goal;
-    DebugCheck( !goal );
-
-    switch( DoActionMove(unit) ) {     // reached end-point?
-       case PF_UNREACHABLE:
-           return -1;
-       case PF_REACHED:
-           break;
-       default:
-           if( !unit->Reset || !(goal->Destroyed || goal->Removed
-                   || !goal->HP || goal->Orders[0].Action==UnitActionDie) ) {
-               return 0;
+    resinfo=unit->Type->ResInfo[unit->CurrentResource];
+    if (resinfo->TerrainHarvester) {
+       x=unit->Orders->X;
+       y=unit->Orders->Y;
+       // Wood gone, look somewhere else.
+       if ( (!ForestOnMap(x,y)) && (!unit->IX) && (!unit->IY)) {
+           if (!FindTerrainType(UnitMovementMask(unit),MapFieldForest,0,10,
+               unit->Player,unit->X,unit->Y,&x,&y)) {
+               DebugLevel3Fn("No wood in range\n");
+               return -1;
+           } else {
+               DebugLevel3Fn("%d,%d -> %d,%d\n" _C_ unit->X _C_ unit->Y _C_ x 
_C_ y);
+               unit->Orders->X=x;
+               unit->Orders->Y=y;
+               NewResetPath(unit);
            }
-           break;
+       }
+       switch( DoActionMove(unit)) {
+           case PF_UNREACHABLE:
+               if 
(FindTerrainType(UnitMovementMask(unit),MapFieldForest,0,9999,unit->Player,unit->X,unit->Y,&x,&y))
 {
+                   unit->Orders->X=x;
+                   unit->Orders->Y=y;
+                   NewResetPath(unit);
+                   DebugLevel3Fn("Found a better place to harvest %d,%d\n" _C_ 
x _C_ y);
+                   // FIXME: can't this overflow? It really shouldn't, since
+                   // x and y are really supossed to be reachable, checked 
thorugh a flood fill.
+                   return MoveToResource(unit);
+               }
+               return -1;
+           case PF_REACHED:
+               return 1;
+           default:
+               return 0;
+       }
+    } else {
+       goal=unit->Orders[0].Goal;
+       DebugCheck( !goal );
+       switch( DoActionMove(unit) ) {  // reached end-point?
+           case PF_UNREACHABLE:
+               return -1;
+           case PF_REACHED:
+               break;
+           default:
+               // Goal gone or something.
+               if( !unit->Reset || !(goal->Destroyed || goal->Removed
+                       || !goal->HP || goal->Orders[0].Action==UnitActionDie) 
) {
+                   return 0;
+               }
+               break;
+       }
+       return 1;
     }
-
-    return 1;
 }
 
 /*
@@ -103,13 +141,30 @@
 local int StartGathering(Unit* unit)
 {
     Unit * goal;
+    ResourceInfo* resinfo;
+
+    resinfo=unit->Type->ResInfo[unit->CurrentResource];
+    DebugCheck(unit->IX);
+    DebugCheck(unit->IY);
+    if (resinfo->TerrainHarvester) {
+       DebugCheck(!ForestOnMap(unit->Orders->X,unit->Orders->Y));
+       
UnitHeadingFromDeltaXY(unit,unit->Orders->X-unit->X,unit->Orders->Y-unit->Y);
+       if (resinfo->WaitAtResource) {
+           unit->Data.ResWorker.TimeToHarvest=resinfo->WaitAtResource;
+       } else {
+           unit->Data.ResWorker.TimeToHarvest=1;
+       }
+       unit->Data.ResWorker.DoneHarvesting=0;
+       return 1;
+    }
+
     goal=unit->Orders[0].Goal;
     //
     // Target is dead, stop getting resources.
     //
     if( goal->Destroyed || goal->Removed || !goal->HP ||
            goal->Orders[0].Action==UnitActionDie) {
-       DebugLevel0Fn("Destroyed resource goal, stop gathering.\n");
+       DebugLevel3Fn("Destroyed resource goal, stop gathering.\n");
        RefsDebugCheck( !goal->Refs );
        --goal->Refs;
        if( goal->Destroyed ) {
@@ -119,15 +174,23 @@
        } else {
            RefsDebugCheck( !goal->Refs );
        }
-       unit->Orders[0].Goal=NoUnitP;
+       //  Find an alternative, but don't look too far.
        unit->Orders[0].X=unit->Orders[0].Y=-1;
-       // FIXME: Choose an alternative
-       unit->Orders[0].Action=UnitActionStill;
-       unit->SubAction=0;
+       if ((goal=FindResource(unit,unit->X,unit->Y,10))) {
+           unit->SubAction=SUB_START_RESOURCE;
+           unit->Orders[0].Goal=goal;
+           RefsDebugCheck( !goal->Refs );
+           ++goal->Refs;
+       } else {
+           unit->Orders[0].Action=UnitActionStill;
+           unit->Orders[0].Goal=0;
+           unit->SubAction=0;
+       }
        return 0;
     }
 
     // FIXME: 0 can happen, if to near placed by map designer.
+    DebugLevel3Fn("%d\n" _C_ MapDistanceToUnit(unit->X,unit->Y,goal) );
     DebugCheck( MapDistanceToUnit(unit->X,unit->Y,goal)>1 );
 
     //
@@ -163,7 +226,7 @@
     //
     // Place unit inside the resource
     //
-    if (!unit->Type->HarvestFromOutside) {
+    if (!resinfo->HarvestFromOutside) {
 
        RefsDebugCheck( !goal->Refs );
        --goal->Refs;
@@ -175,13 +238,9 @@
        unit->Y=goal->Y;
     }
 
-    if (unit->Type->WaitAtResource) {
-       unit->Data.ResWorker.TimeToHarvest=unit->Type->WaitAtResource;
-    } else {
-       unit->Data.ResWorker.TimeToHarvest=1;
-    }
+    unit->Data.ResWorker.TimeToHarvest=resinfo->WaitAtResource;
 
-    unit->Reset=1;
+    unit->Data.ResWorker.DoneHarvesting=0;
 
     return 1;
 }
@@ -196,11 +255,7 @@
        flags=UnitShowAnimation(unit,unit->Type->Animations->Attack);
 #ifdef WITH_SOUND
        if( (flags&AnimationSound) ) {
-           if( GameSounds.Repair.Sound==(void*)-1 ) {
-               PlayUnitSound(unit,VoiceAttacking);
-           } else {
-               PlayUnitSound(unit,VoiceRepair);
-           }
+           PlayUnitSound(unit,VoiceTreeChopping);
        }
 #endif
     }
@@ -218,133 +273,171 @@
     Unit* source;
     Unit* depot;
     Unit* uins;
+    ResourceInfo* resinfo;
     int i;
     int addload;
-
-    if (unit->Type->HarvestFromOutside) {
+    
+    resinfo=unit->Type->ResInfo[unit->CurrentResource];
+    source=0;
+    
+    if (resinfo->HarvestFromOutside||resinfo->TerrainHarvester) {
        AnimateActionHarvest(unit);
+       unit->Data.ResWorker.TimeToHarvest-=unit->Wait;
     } else {
+       unit->Data.ResWorker.TimeToHarvest--;
        unit->Wait=1;
     }
 
-    //  This means we have to return.
-    if (unit->Data.ResWorker.TimeToHarvest==-1) {
-       DebugCheck(!unit->Type->HarvestFromOutside);
+    if (unit->Data.ResWorker.DoneHarvesting) {
+       DebugCheck(!(resinfo->HarvestFromOutside||resinfo->TerrainHarvester));
        return unit->Reset;
     }
     
-    if (--unit->Data.ResWorker.TimeToHarvest) {
-       DebugLevel3Fn("need to wait %d more cycles.\n" _C_ 
unit->Data.ResWorker.TimeToHarvest);
+    //  Target gone?
+    if 
(resinfo->TerrainHarvester&&!ForestOnMap(unit->Orders->X,unit->Orders->Y)) {
+       DebugLevel3Fn("Wood gone for unit %d.\n" _C_ unit->Slot);
+       if (unit->Reset) {
+           // Action now breakable, move to resource again.
+           unit->SubAction=SUB_MOVE_TO_RESOURCE;
+           // Give it some reasonable look while serching.
+           unit->Frame=unit->Type->Animations->Still->Frame;
+       }
        return 0;
+       // No wood? Freeze!!!
     }
-    
-    unit->Data.ResWorker.TimeToHarvest=unit->Type->WaitAtResource;
-    
-    if ( unit->Type->HarvestFromOutside ) {
-       source=unit->Orders[0].Goal;
-    } else {
-       source=unit->Container;
-    }
-
-    DebugCheck( !source );
-    DebugCheck( source->Value>655350 );
 
-    //
-    // Target is dead, stop getting resources.
-    //
-    if( !(source->Destroyed || source->Removed || !source->HP ||
-           source->Orders[0].Action==UnitActionDie)) {
+    if 
(!unit->Data.ResWorker.DoneHarvesting&&unit->Data.ResWorker.TimeToHarvest<0) {
+       unit->Data.ResWorker.TimeToHarvest+=resinfo->WaitAtResource;
+       
        //
        //  Calculate how much we can load.
-       //  
-       if (unit->Type->ResourceStep) {
-           addload = unit->Type->ResourceStep;
-       } else {
-           addload = unit->Type->ResourceCapacity;
-       }
-       //  Don't load more that there is.
-       if (addload > source->Value) {
-           addload = source->Value;
+       //
+       if (resinfo->ResourceStep) {
+           addload = resinfo->ResourceStep;
+       } else {
+           addload = resinfo->ResourceCapacity;
        }
        //  Make sure we don't bite more than we can chew.
-       if (unit->Value + addload > unit->Type->ResourceCapacity) {
-           addload = unit->Type->ResourceCapacity - unit->Value;
+       if (unit->Value + addload > resinfo->ResourceCapacity) {
+           addload = resinfo->ResourceCapacity - unit->Value;
        }
-
-       DebugLevel3Fn("Harvested another %d resources.\n" _C_ addload);
        
-       unit->Value += addload;
-       source->Value -= addload;
-       
-       UnitMarkSeen(source);
-       if( IsOnlySelected(source) ) {
-           MustRedraw|=RedrawInfoPanel;
-       }
-       //      Change unit to full state.
-       if( unit->Type->TransformWhenLoaded&&unit->Value ) {
-           unit->Player->UnitTypesCount[unit->Type->Type]--;
-           unit->Type=unit->Type->TransformWhenLoaded;
-           unit->Player->UnitTypesCount[unit->Type->Type]++;
-       }
-    }
-    
-    //
-    // End of resource: destroy the resource.
-    // FIXME: implement depleted resources.
-    //
-    if( source->Destroyed || source->Removed || !source->HP ||
-           source->Orders[0].Action==UnitActionDie || source->Value==0) {
-       DebugLevel0Fn("Resource is destroyed\n");
-       uins=source->UnitInside;
-       //
-       // Improved version of DropOutAll that makes workers go to the depot.
-       // FIXME: empty harvesters whould find another resource.
-       // 
-        for( i=source->InsideCount; i; --i,uins=uins->NextContained ) {
-           if (uins->Value && 
(depot=FindDeposit(uins->Player,uins->X,uins->Y,source->Type->GivesResource))) {
-               DropOutNearest(uins,depot->X+depot->Type->TileWidth/2
-                       ,depot->Y+depot->Type->TileHeight/2
-                       ,source->Type->TileWidth,source->Type->TileHeight);
-               uins->Orders[0].Action=UnitActionReturnGoods;
-               uins->SubAction=0;
-               uins->Wait=unit->Reset=1;
-               uins->Orders[0].Goal=depot;
-               
-               RefsDebugCheck( !depot->Refs );
-               ++depot->Refs;
-               DebugLevel0Fn("Sent unit %d to depot\n" _C_ uins->Slot);
-               continue;
+       if (resinfo->TerrainHarvester) {
+           DebugLevel3Fn("Harvested another %d resources.\n" _C_ addload);
+           unit->Value += addload;
+
+           if (addload&&unit->Value==resinfo->ResourceCapacity) {
+               DebugLevel3("Removed wood.\n");
+               MapRemoveWood(unit->Orders->X,unit->Orders->Y);
+           }
+       } else {
+           if ( resinfo->HarvestFromOutside ) {
+               source=unit->Orders[0].Goal;
+           } else {
+               source=unit->Container;
            }
-           DebugLevel0Fn("Unit %d just sits around confused.\n" _C_ 
uins->Slot);
-           DropOutOnSide(uins,LookingW
-                   ,source->Type->TileWidth,source->Type->TileHeight);
-           uins->Orders[0].Goal=0;
-           uins->Orders[0].X=uins->Orders[0].Y=-1;
-           uins->Orders[0].Action=UnitActionStill;
-           uins->Wait=unit->Reset=1;
-           uins->SubAction=0;
-       }
 
-       //  Don't destroy the resource twice.
-       if( !(source->Destroyed || source->Removed || !source->HP ||
-           source->Orders[0].Action==UnitActionDie)){
-           LetUnitDie(source);
-       }
-       // FIXME: make the workers inside look for a new resource.
-       source=NULL;
-    }
+           DebugCheck( !source );
+           DebugCheck( source->Value>655350 );
 
-    //  Only return home if we are full.
-    if (unit->Value < unit->Type->ResourceCapacity || !source) {
-       return 0;
-    } else {
-       if (unit->Type->HarvestFromOutside) {
-           unit->Data.ResWorker.TimeToHarvest=-1;
+           //
+           //  Target is dead, stop getting resources.
+           //
+           if( !(source->Destroyed || source->Removed || !source->HP ||
+                   source->Orders[0].Action==UnitActionDie)) {
+               //  Don't load more that there is.
+               if (addload > source->Value) {
+                   addload = source->Value;
+               }
+
+               DebugLevel3Fn("Harvested another %d resources.\n" _C_ addload);
+               unit->Value += addload;
+               source->Value -= addload;
+              
+               UnitMarkSeen(source);
+               if( IsOnlySelected(source) ) {
+                   MustRedraw|=RedrawInfoPanel;
+               }
+           }
+           
+           //
+           //  End of resource: destroy the resource.
+           //  FIXME: implement depleted resources.
+           //
+           if( source->Destroyed || source->Removed || !source->HP ||
+                   source->Orders[0].Action==UnitActionDie || 
source->Value==0) {
+               DebugLevel0Fn("Resource is destroyed\n");
+               uins=source->UnitInside;
+               //
+               // Improved version of DropOutAll that makes workers go to the 
depot.
+               // FIXME: empty harvesters should find another resource.
+               // 
+               for( i=source->InsideCount; i; --i,uins=uins->NextContained ) {
+                   if (uins->Value && 
(depot=FindDeposit(uins,uins->X,uins->Y,1000))) {
+                       DropOutNearest(uins,depot->X+depot->Type->TileWidth/2
+                               ,depot->Y+depot->Type->TileHeight/2
+                               
,source->Type->TileWidth,source->Type->TileHeight);
+                       //  Remember were it mined, so it can look around for 
another resource.
+                       uins->Orders[0].Arg1=(void*)((unit->X<<16)|unit->Y);
+                       uins->Orders[0].Goal=depot;
+                       RefsDebugCheck( !depot->Refs );
+                       ++depot->Refs;
+                       NewResetPath(uins);
+                       uins->SubAction=SUB_MOVE_TO_DEPOT;
+                       uins->Wait=1;
+                       DebugLevel0Fn("Sent unit %d to depot\n" _C_ uins->Slot);
+                       continue;
+                   }
+                   DropOutOnSide(uins,LookingW
+                           ,source->Type->TileWidth,source->Type->TileHeight);
+                   uins->Orders[0].X=uins->Orders[0].Y=-1;
+                   if 
((uins->Orders[0].Goal=FindResource(uins,uins->X,uins->Y,10))) {
+                       DebugLevel0Fn("Unit %d found another resource.\n" _C_ 
uins->Slot);
+                       uins->SubAction=SUB_START_RESOURCE;
+                       uins->Wait=1;
+                       RefsDebugCheck( !uins->Orders[0].Goal->Refs );
+                       ++uins->Orders[0].Goal->Refs;
+                   } else {
+                       DebugLevel0Fn("Unit %d just sits around confused.\n" 
_C_ uins->Slot);
+                       uins->Orders[0].Action=UnitActionStill;
+                       uins->SubAction=0;
+                       uins->Wait=unit->Reset=1;
+                   }
+               }
+
+               //  Don't destroy the resource twice.
+               if( !(source->Destroyed || source->Removed || !source->HP ||
+                   source->Orders[0].Action==UnitActionDie)){
+                   LetUnitDie(source);
+                   // FIXME: make the workers inside look for a new resource.
+               }
+               source=NULL;
+           }
+       }
+       if (resinfo->TerrainHarvester) {
+           if (unit->Value == resinfo->ResourceCapacity) {
+               // Mark as complete.
+               DebugLevel3Fn("Done Harvesting, waiting for reset.\n");
+               unit->Data.ResWorker.DoneHarvesting=1;
+           }
            return 0;
-       } else {
-           return 1;
+       }
+       
+       if (resinfo->HarvestFromOutside && !resinfo->TerrainHarvester) {
+           if ((unit->Value == resinfo->ResourceCapacity)||(source==NULL)) {
+               // Mark as complete.
+               DebugLevel3Fn("Done Harvesting, waiting for reset %X.\n" _C_ 
(unsigned)source);
+               unit->Data.ResWorker.DoneHarvesting=1;
+           }
+           return 0;
+       }
+       
+       if ((!resinfo->HarvestFromOutside)&& (!resinfo->TerrainHarvester)) {
+           return unit->Value==resinfo->ResourceCapacity&&source;
        }
     }
+
+    return 0;
 }
 
 /**
@@ -358,25 +451,31 @@
 {
     Unit* depot;
     Unit* source;
+    ResourceInfo* resinfo;
 
-    
-    if ( unit->Type->HarvestFromOutside ) {
-       source=unit->Orders[0].Goal;
-    } else {
-       source=unit->Container;
+    resinfo=unit->Type->ResInfo[unit->CurrentResource];
+
+   
+    source=0;
+    if (!resinfo->TerrainHarvester) {
+       if ( resinfo->HarvestFromOutside ) {
+           source=unit->Orders[0].Goal;
+       } else {
+           source=unit->Container;
+       }
+       source->Data.Resource.Active--;
+       DebugCheck(source->Data.Resource.Active<0);
     }
      
-    source->Data.Resource.Active--;
-    DebugCheck(source->Data.Resource.Active<0);
 
     // Store resource position.
     // FIXME: is this the best way?
     unit->Orders[0].Arg1=(void*)((unit->X<<16)|unit->Y);
    
     // Find and send to resource deposit.
-    if( 
(!(depot=FindDeposit(unit->Player,unit->X,unit->Y,unit->Type->ResourceHarvested)))
+    if( (!(depot=FindDeposit(unit,unit->X,unit->Y,1000)))
            || (!unit->Value)) {
-       if (!unit->Type->HarvestFromOutside) {
+       if (!(resinfo->HarvestFromOutside||resinfo->TerrainHarvester)) {
            DebugCheck(!unit->Container);
            
DropOutOnSide(unit,LookingW,source->Type->TileWidth,source->Type->TileHeight);
        }
@@ -385,7 +484,7 @@
        unit->SubAction=0;
        // should return 0, done below!
     } else {
-       if (!unit->Type->HarvestFromOutside) {
+       if (!(resinfo->HarvestFromOutside||resinfo->TerrainHarvester)) {
            DebugCheck(!unit->Container);
            DropOutNearest(unit,depot->X+depot->Type->TileWidth/2
                    ,depot->Y+depot->Type->TileHeight/2
@@ -421,6 +520,9 @@
 local int MoveToDepot(Unit* unit)
 {
     Unit* goal;
+    ResourceInfo* resinfo;
+
+    resinfo=unit->Type->ResInfo[unit->CurrentResource];
 
     goal=unit->Orders[0].Goal;
     DebugCheck( !goal );
@@ -489,29 +591,17 @@
     //
     // Update resource.
     //
-    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;
+    unit->Player->Resources[resinfo->FinalResource]+=
+       (unit->Value*unit->Player->Incomes[resinfo->FinalResource])/100;
+    unit->Player->TotalResources[resinfo->FinalResource]+=
+       (unit->Value*unit->Player->Incomes[resinfo->FinalResource])/100;
     unit->Value=0;
     if( unit->Player==ThisPlayer ) {
        MustRedraw|=RedrawResources;
     }
 
-    //
-    // Change unit to empty state.
-    //
-    if( unit->Type->TransformWhenEmpty ) {
-       unit->Player->UnitTypesCount[unit->Type->Type]--;
-       unit->Type=unit->Type->TransformWhenEmpty;
-       unit->Player->UnitTypesCount[unit->Type->Type]++;
-    }
+    unit->Wait=resinfo->WaitAtDepot;
 
-    if (unit->Type->WaitAtDepot) {
-       unit->Wait=unit->Type->WaitAtDepot;
-    } else {
-       unit->Wait=1;
-    }
     return 1;
 }
 
@@ -526,10 +616,13 @@
 {
     const Unit* depot;
     Unit* goal;
+    ResourceInfo* resinfo;
     int x;
     int y;
 
-    depot=ResourceDepositOnMap(unit->X,unit->Y,unit->Type->ResourceHarvested);
+    resinfo=unit->Type->ResInfo[unit->CurrentResource];
+
+    depot=ResourceDepositOnMap(unit->X,unit->Y,resinfo->ResourceId);
     DebugCheck( !depot );
     // Could be destroyed, but then we couldn't be in?
 
@@ -540,20 +633,33 @@
        x=(int)unit->Orders[0].Arg1>>16;
        y=(int)unit->Orders[0].Arg1&0xFFFF;
     }
-    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;
+    //  Range hardcoded. don't stray too far though
+    if( resinfo->TerrainHarvester ) {
+       if (FindTerrainType(UnitMovementMask(unit),MapFieldForest,0,10,
+               unit->Player,x,y,&x,&y)) {
+           
DropOutNearest(unit,x,y,depot->Type->TileWidth,depot->Type->TileHeight);
+           unit->Orders->X=x;
+           unit->Orders->Y=y;
+       } else {
+           
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;
+       if ((goal=FindResource(unit,x,y,10))) {
+           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;
+       } else {
+           
DropOutOnSide(unit,LookingW,depot->Type->TileWidth,depot->Type->TileHeight);
+           unit->Orders[0].Action=UnitActionStill;
+           unit->SubAction=0;
+       }
     }
 
     CheckUnitToBeDrawn(unit);
@@ -574,6 +680,10 @@
     unit->Reset=1;
     unit->Orders[0].X=unit->Orders[0].Y=-1;
     unit->SubAction=0;
+    if( unit->Type->ResInfo[unit->CurrentResource]->LoseResources ) {
+       unit->Value=0;
+       unit->CurrentResource=0;
+    }
     if( unit->Orders[0].Goal ) {
        RefsDebugCheck( !unit->Orders[0].Goal->Refs );
        --unit->Orders[0].Goal->Refs;
@@ -591,13 +701,23 @@
 */
 global void HandleActionResource(Unit* unit)
 {
-    int ret;
+    int ret,newres;
 
     DebugLevel3Fn("%s(%d) SubAction %d\n"
        _C_ unit->Type->Ident _C_ UnitNumber(unit) _C_ unit->SubAction);
-
+    
     // Let's start mining.
     if ( unit->SubAction==SUB_START_RESOURCE ) {
+       if (unit->Orders->Goal) {
+           newres=unit->Orders->Goal->Type->GivesResource;
+       } else {
+           newres=WoodCost;
+       }
+       if (newres!=unit->CurrentResource) {
+           // Drop other resources.
+           unit->Value=0;
+       }
+       unit->CurrentResource=newres;
        NewResetPath(unit);
        DebugLevel3Fn("Started mining. reset path.\n");
        unit->SubAction=SUB_MOVE_TO_RESOURCE;
@@ -632,8 +752,9 @@
     if (unit->SubAction==SUB_START_GATHERING) {
        if (StartGathering(unit)) {
            unit->SubAction=SUB_GATHER_RESOURCE;
-       }
+       } else {
        return;
+       }
     }
     
     //  Gather the resource.
Index: stratagus/src/action/action_returngoods.c
diff -u stratagus/src/action/action_returngoods.c:1.37 
stratagus/src/action/action_returngoods.c:1.38
--- stratagus/src/action/action_returngoods.c:1.37      Sun Aug 10 22:14:45 2003
+++ stratagus/src/action/action_returngoods.c   Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_returngoods.c,v 1.37 2003/08/11 02:14:45 n0body Exp $
+//     $Id: action_returngoods.c,v 1.38 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -54,9 +54,9 @@
 /**
 **     Return goods to gold/wood deposit.
 **
-**     FIXME: must support to move to a specified deposit.
-**
 **     @param unit     pointer to unit.
+**
+**     FIXME: move this into action_resource?
 */
 global void HandleActionReturnGoods(Unit* unit)
 {
@@ -65,56 +65,30 @@
 
     type=unit->Type;
     //
-    // Select target to return goods. FIXME: more races support
+    // Select target to return goods. 
     // 
-    if( type->Harvester ) {
-       if( !unit->Orders[0].Goal ) {
-           if( 
!(destu=FindDeposit(unit->Player,unit->X,unit->Y,type->ResourceHarvested)) ) {
-               DebugLevel3Fn("No deposit -> can't return\n");
-               unit->Orders[0].Action=UnitActionStill;
-               return;
-           }
-           unit->Orders[0].Goal=destu;
-           RefsDebugCheck( !destu->Refs );
-           ++destu->Refs;
-       }
-       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=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=70;
-       unit->Wait=1;
-       return;
-    }
-    
-    if( type==UnitTypeHumanWorkerWithWood || type==UnitTypeOrcWorkerWithWood ) 
{
-       if( !unit->Orders[0].Goal ) {
-           if( !(destu=FindDeposit(unit->Player,unit->X,unit->Y,WoodCost)) ) {
-               // No deposit -> can't return
-               unit->Orders[0].Action=UnitActionStill;
-               return;
-           }
-           unit->Orders[0].Goal=destu;
-           RefsDebugCheck( !destu->Refs );
-           ++destu->Refs;
+    DebugCheck(!type->Harvester );
+    if( !unit->Orders[0].Goal ) {
+       if( !(destu=FindDeposit(unit,unit->X,unit->Y,1000)) ) {
+           DebugLevel3Fn("No deposit -> can't return\n");
+           unit->Orders[0].Action=UnitActionStill;
+           return;
        }
-       unit->Orders[0].X=unit->X;
-       unit->Orders[0].Y=unit->Y;      // Return point to continue.
-       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=UnitActionHarvest;
-       unit->Orders[0].Arg1=(void*)-1;
-       NewResetPath(unit);
-       unit->SubAction=128;            // FIXME: Hardcoded
-       DebugLevel3("Wait: %d\n" _C_ unit->Wait);
-       unit->Wait=1;
-       return;
+       unit->Orders[0].Goal=destu;
+       RefsDebugCheck( !destu->Refs );
+       ++destu->Refs;
     }
+    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=UnitActionResource;
+    // Somewhere on the way the loaded worker could have change Arg1
+    // Bummer, go get the closest resource to the depot
+    unit->Orders[0].Arg1=(void*)-1;
+    NewResetPath(unit);
+    unit->SubAction=70;
+    unit->Wait=1;
+    return;
 }
 
 //@}
Index: stratagus/src/action/action_train.c
diff -u stratagus/src/action/action_train.c:1.55 
stratagus/src/action/action_train.c:1.56
--- stratagus/src/action/action_train.c:1.55    Sun Aug 10 22:14:45 2003
+++ stratagus/src/action/action_train.c Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_train.c,v 1.55 2003/08/11 02:14:45 n0body Exp $
+//     $Id: action_train.c,v 1.56 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -155,9 +155,6 @@
                && !nunit->Type->Harvester)
            || (unit->NewOrder.Action==UnitActionAttack
                && !nunit->Type->CanAttack)
-            || ((unit->NewOrder.Action==UnitActionHarvest)
-               && nunit->Type!=UnitTypeOrcWorker 
-               && nunit->Type!=UnitTypeHumanWorker )
            || (unit->NewOrder.Action==UnitActionBoard
                && nunit->Type->UnitType!=UnitTypeLand) ) {
            DebugLevel0Fn("Wrong order for unit\n");
Index: stratagus/src/action/actions.c
diff -u stratagus/src/action/actions.c:1.91 stratagus/src/action/actions.c:1.92
--- stratagus/src/action/actions.c:1.91 Tue Sep  2 04:09:19 2003
+++ stratagus/src/action/actions.c      Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: actions.c,v 1.91 2003/09/02 08:09:19 mr-russ Exp $
+//     $Id: actions.c,v 1.92 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -174,10 +174,10 @@
     HandleActionPatrol,
     HandleActionBuild,
     HandleActionRepair,
-    HandleActionHarvest,
     HandleActionResource,
     HandleActionReturnGoods,
     HandleActionDemolish,
+    HandleActionNotWritten,
 
     // Enough for the future ?
     HandleActionNotWritten, HandleActionNotWritten, HandleActionNotWritten,
@@ -268,7 +268,7 @@
 local void HandleUnitAction(Unit* unit)
 {
     int z;
-
+       
     //
     // If current action is breakable proceed with next one.
     //
@@ -304,6 +304,11 @@
                RefsDebugCheck( !unit->Orders[0].Goal->Refs );
                if( !--unit->Orders[0].Goal->Refs ) {
                    ReleaseUnit(unit->Orders[0].Goal);
+               }
+           }
+           if (unit->CurrentResource) {
+               if (unit->Type->ResInfo[unit->CurrentResource]->LoseResources) {
+                   unit->Value=0;
                }
            }
 
Index: stratagus/src/action/command.c
diff -u stratagus/src/action/command.c:1.102 
stratagus/src/action/command.c:1.103
--- stratagus/src/action/command.c:1.102        Mon Sep  1 08:32:17 2003
+++ stratagus/src/action/command.c      Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: command.c,v 1.102 2003/09/01 12:32:17 mr-russ Exp $
+//     $Id: command.c,v 1.103 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -702,29 +702,23 @@
 }
 
 /**
-**     Send unit harvest
+**     Send unit harvest a location
 **
 **     @param unit     pointer to unit.
 **     @param x        X map position for harvest.
 **     @param y        Y map position for harvest.
 **     @param flush    if true, flush command queue.
 */
-global void CommandHarvest(Unit* unit,int x,int y,int flush)
+global void CommandResourceLoc(Unit* unit,int x,int y,int flush)
 {
     Order* order;
+    int nx;
+    int ny;
 
     //
     // Check if unit is still valid? (NETWORK!)
     //
     if( !unit->Removed && unit->Orders[0].Action!=UnitActionDie ) {
-       // FIXME: more races, could happen with many orders in queue.
-       if( !unit->Type->Building
-               && unit->Type!=UnitTypeHumanWorker
-               && unit->Type!=UnitTypeOrcWorker ) {
-           DebugLevel0Fn("None worker gets order\n");
-           ClearSavedAction(unit);
-           return;
-       }
        if( unit->Type->Building ) {
            // FIXME: should find a better way for pending orders.
            order=&unit->NewOrder;
@@ -733,9 +727,27 @@
            return;
        }
 
-       order->Action=UnitActionHarvest;
-       order->X=x;
-       order->Y=y;
+       order->Action=UnitActionResource;
+       
+       //  Find the closest piece of wood next to a tile where the unit can 
move
+       DebugLevel3("Want to harvest from %d,%d.\n" _C_ x _C_ y);
+       if 
(!FindTerrainType(0,(unit->Type->MovementMask),1,20,unit->Player,x,y,&nx,&ny)) {
+           DebugLevel0Fn("FIXME: Give up???\n");
+       }
+       if (max(abs(nx-x),abs(ny-y))>1) {
+           DebugLevel3("Closest tile reachable is at %d,%d.\n" _C_ x _C_ y);
+           if 
(!FindTerrainType(0,MapFieldForest,0,20,unit->Player,nx,ny,&nx,&ny)) {
+               DebugLevel0Fn("FIXME: Give up???\n");
+           }
+       } else {
+           // The destination is next to a reacahble tile.
+           nx=x;
+           ny=y;
+       }
+       DebugLevel3("So the final destination is %d,%d.\n" _C_ nx _C_ ny);
+       order->X=nx;
+       order->Y=ny;
+
        order->RangeX=order->RangeY=1;
        order->Goal=NoUnitP;
        order->Type=NULL;
@@ -806,8 +818,7 @@
        // FIXME: more races, could happen with many orders in queue.
        if( !unit->Type->Building
                && !unit->Type->Harvester
-               && unit->Type!=UnitTypeHumanWorkerWithWood
-               && unit->Type!=UnitTypeOrcWorkerWithWood) {
+               && !unit->Value ) { 
            ClearSavedAction(unit);
            return;
        }
Index: stratagus/src/ai/ai_resource.c
diff -u stratagus/src/ai/ai_resource.c:1.65 stratagus/src/ai/ai_resource.c:1.66
--- stratagus/src/ai/ai_resource.c:1.65 Mon Sep  1 08:32:17 2003
+++ stratagus/src/ai/ai_resource.c      Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_resource.c,v 1.65 2003/09/01 12:32:17 mr-russ Exp $
+//      $Id: ai_resource.c,v 1.66 2003/09/05 18:10:55 n0body Exp $
 
 #ifdef NEW_AI  // {
 
@@ -744,180 +744,12 @@
 **
 **     @return         Pointer to the nearest reachable gold mine.
 **
-**     @see FindGoldMine but this version doesn't check for explored tiles.
+**     @see FindGoldMine
 */
 local Unit* AiFindGoldMine(const Unit* unit)
 {
-    static const int xoffset[]={  0,-1,+1, 0, -1,+1,-1,+1 };
-    static const int yoffset[]={ -1, 0, 0,+1, -1,-1,+1,+1 };
-    struct {
-       unsigned short X;
-       unsigned short Y;
-    } * points;
-    int size;
-    int x;
-    int y;
-    int rx;
-    int ry;
-    int mask;
-    int wp;
-    int rp;
-    int ep;
-    int i;
-    int w;
-    int n;
-    unsigned char* m;
-    unsigned char* matrix;
-    const Unit* destu;
-    Unit* mine;
-    Unit* bestmine;
-    int destx;
-    int desty;
-    int bestx;
-    int besty;
-    int bestd;
-
-    destx=x=unit->X;
-    desty=y=unit->Y;
-    size=TheMap.Width*TheMap.Height/4;
-    points=malloc(size*sizeof(*points));
-
-    //
-    // Find the nearest gold depot
-    //
-    if( (destu=FindDeposit(unit->Player,x,y,GoldCost)) ) {
-       NearestOfUnit(destu,x,y,&destx,&desty);
-    }
-    bestd=99999;
-    IfDebug( bestx=besty=0; );         // keep the compiler happy
-
-    //
-    // Make movement matrix. FIXME: can create smaller matrix.
-    //
-    matrix=CreateMatrix();
-    w=TheMap.Width+2;
-    matrix+=w+w+2;
-
-    //
-    // Mark sight range as border. FIXME: matrix didn't need to be bigger.
-    //
-    n=unit->Stats->SightRange;
-    rx=x-n;
-    if( rx<0 ) {
-       rx=0;
-    }
-    ep=x+n;
-    if( ep>TheMap.Width ) {
-       ep=TheMap.Width;
-    }
-    ry=y-n;
-    if( ry<0 ) {
-       ry=0;
-    }
-    wp=y+n;
-    if( wp>TheMap.Height ) {
-       wp=TheMap.Height;
-    }
-    for( i=rx; i<ep; ++i ) {           // top bottom line
-       matrix[i+ry*w]=matrix[i+wp*w]=66;
-    }
-    for( i=ry+1; i<wp-1; ++i ) {
-       matrix[rx+i*w]=matrix[ep+i*w]=66;
-    }
-
-#if 0
-    matrix[x+n+(y+n)*w]=matrix[x-n+(y+n)*w]=
-       matrix[x+n+(y-n)*w]=matrix[x-n+(y-n)*w]=66;
-    for( i=n; i--; ) {
-       // FIXME: marks out of map area
-       DebugCheck( x-i+(y-n)*w<0 || x+i+(y+n)*w>w*TheMap.Hight );
-       matrix[x+n+(y+i)*w]=matrix[x-n+(y+i)*w]=
-           matrix[x+n+(y-i)*w]=matrix[x-n+(y-i)*w]=
-           matrix[x-i+(y+n)*w]=matrix[x+i+(y+n)*w]=
-           matrix[x-i+(y-n)*w]=matrix[x+i+(y-n)*w]=66;
-    }
-#endif
-
-    mask=UnitMovementMask(unit);
-
-    points[0].X=x;
-    points[0].Y=y;
-    rp=0;
-    matrix[x+y*w]=1;                   // mark start point
-    ep=wp=1;                           // start with one point
-    bestmine=NoUnitP;
-
-    //
-    // Pop a point from stack, push all neighbors which could be entered.
-    //
-    for( ;; ) {
-       while( rp!=ep ) {
-           rx=points[rp].X;
-           ry=points[rp].Y;
-           for( i=0; i<8; ++i ) {              // mark all neighbors
-               x=rx+xoffset[i];
-               y=ry+yoffset[i];
-               m=matrix+x+y*w;
-               if( *m ) {                      // already checked
-                   continue;
-               }
-
-               //
-               //      Look if there is a mine
-               //
-               if ( (mine=ResourceOnMap(x,y,GoldCost)) ) {
-                   if( destu ) {
-                       n=max(abs(destx-x),abs(desty-y));
-                       if( n<bestd ) {
-                           bestd=n;
-                           bestx=x;
-                           besty=y;
-                           bestmine=mine;
-                       }
-                       *m=22;
-                   } else {                    // no goal take the first
-                       free(points);
-                       return mine;
-                   }
-               }
-
-               if( CanMoveToMask(x,y,mask) ) { // reachable
-                   *m=1;
-                   points[wp].X=x;             // push the point
-                   points[wp].Y=y;
-                   if( ++wp>=size ) {          // round about
-                       wp=0;
-                   }
-               } else {                        // unreachable
-                   *m=99;
-               }
-           }
-           if( ++rp>=size ) {                  // round about
-               rp=0;
-           }
-       }
-
-       //
-       //      Take best of this frame, if any.
-       //
-       if( bestd!=99999 ) {
-           free(points);
-           return bestmine;
-       }
-
-       //
-       //      Continue with next frame.
-       //
-       if( rp==wp ) {                  // unreachable, no more points available
-           break;
-       }
-       ep=wp;
-    }
-
-    DebugLevel3Fn("no mine in sight-range\n");
-
-    free(points);
-    return NoUnitP;
+    // FIXME: explored tiles?
+    return FindResource(unit,unit->X,unit->Y,100);
 }
 
 /**
@@ -939,113 +771,12 @@
                _C_ unit->Type->Ident _C_ unit->X _C_ unit->Y);
        return 0;
     }
-    DebugCheck(unit->Type != UnitTypeHumanWorker
-           && unit->Type != UnitTypeOrcWorker);
 
     CommandResource(unit, dest, FlushCommands);
 
     return 1;
 }
 
-#if 0
-
-/**
-**      Assign worker to harvest.
-**
-**     @param unit     Find wood for this worker.
-*/
-local int AiHarvest(Unit * unit)
-{
-    int x, y, addx, addy, i, n, r, wx, wy, bestx, besty, cost;
-    Unit *dest;
-
-    DebugLevel3Fn("%d\n" _C_ UnitNumber(unit));
-    x = unit->X;
-    y = unit->Y;
-    addx = unit->Type->TileWidth;
-    addy = unit->Type->TileHeight;
-    r = TheMap.Width;
-    if (r < TheMap.Height) {
-       r = TheMap.Height;
-    }
-
-    //  This is correct, but can this be written faster???
-    if ((dest = FindWoodDeposit(unit->Player, x, y))) {
-       NearestOfUnit(dest, x, y, &wx, &wy);
-       DebugLevel3("To %d,%d\n" _C_ wx _C_ wy);
-    } else {
-       wx = unit->X;
-       wy = unit->Y;
-    }
-    cost = 99999;
-    IfDebug(bestx = besty = 0; );      // keep the compiler happy
-
-    // FIXME: if we reach the map borders we can go fast up, left, ...
-    --x;
-    while (addx <= r && addy <= r) {
-       for (i = addy; i--; y++) {      // go down
-           if (CheckedForestOnMap(x, y)) {
-               n = max(abs(wx - x), abs(wy - y));
-               DebugLevel3("Distance %d,%d %d\n" _C_ x _C_ y _C_ n);
-               if (n < cost && PlaceReachable(unit, x-1, y-1, 3)) {
-                   cost = n;
-                   bestx = x;
-                   besty = y;
-               }
-           }
-       }
-       ++addx;
-       for (i = addx; i--; x++) {      // go right
-           if (CheckedForestOnMap(x, y)) {
-               n = max(abs(wx - x), abs(wy - y));
-               DebugLevel3("Distance %d,%d %d\n" _C_ x _C_ y _C_ n);
-               if (n < cost && PlaceReachable(unit, x-1, y-1, 3)) {
-                   cost = n;
-                   bestx = x;
-                   besty = y;
-               }
-           }
-       }
-       ++addy;
-       for (i = addy; i--; y--) {      // go up
-           if (CheckedForestOnMap(x, y)) {
-               n = max(abs(wx - x), abs(wy - y));
-               DebugLevel3("Distance %d,%d %d\n" _C_ x _C_ y _C_ n);
-               if (n < cost && PlaceReachable(unit, x-1, y-1, 3)) {
-                   cost = n;
-                   bestx = x;
-                   besty = y;
-               }
-           }
-       }
-       ++addx;
-       for (i = addx; i--; x--) {      // go left
-           if (CheckedForestOnMap(x, y)) {
-               n = max(abs(wx - x), abs(wy - y));
-               DebugLevel3("Distance %d,%d %d\n" _C_ x _C_ y _C_ n);
-               if (n < cost && PlaceReachable(unit, x-1, y-1, 3)) {
-                   cost = n;
-                   bestx = x;
-                   besty = y;
-               }
-           }
-       }
-       if (cost != 99999) {
-           DebugLevel3Fn("wood on %d,%d\n" _C_ x _C_ y);
-           DebugCheck(unit->Type!=UnitTypeHumanWorker && 
unit->Type!=UnitTypeOrcWorker);
-           CommandHarvest(unit, bestx, besty,FlushCommands);
-           return 1;
-       }
-       ++addy;
-    }
-
-    DebugLevel0Fn("no wood reachable by %s(%d,%d)\n");
-           _C_ unit->Type->Ident _C_ unit->X _C_ unit->Y);
-    return 0;
-}
-
-#else
-
 /**
 **      Assign worker to harvest.
 **
@@ -1090,7 +821,7 @@
     //
     // Find the nearest wood depot
     //
-    if( (destu=FindDeposit(unit->Player,x,y,WoodCost)) ) {
+    if( (destu=FindDeposit(unit,x,y,100)) ) {
        NearestOfUnit(destu,x,y,&destx,&desty);
     }
     bestd=99999;
@@ -1139,9 +870,7 @@
                        }
                        *m=22;
                    } else {                    // no goal take the first
-                       DebugCheck(unit->Type!=UnitTypeHumanWorker
-                               && unit->Type!=UnitTypeOrcWorker);
-                       CommandHarvest(unit,x,y,FlushCommands);
+                       CommandResourceLoc(unit,x,y,FlushCommands);
                        free(points);
                        return 1;
                    }
@@ -1167,9 +896,7 @@
        //      Take best of this frame, if any.
        //
        if( bestd!=99999 ) {
-           DebugCheck(unit->Type!=UnitTypeHumanWorker
-                   && unit->Type!=UnitTypeOrcWorker);
-           CommandHarvest(unit, bestx, besty,FlushCommands);
+           CommandResourceLoc(unit, bestx, besty,FlushCommands);
            free(points);
            return 1;
        }
@@ -1190,8 +917,6 @@
     return 0;
 }
 
-#endif
-
 /**
 **      Assign worker to haul oil.
 */
@@ -1200,7 +925,8 @@
     Unit *dest;
 
     DebugLevel3Fn("%d\n" _C_ UnitNumber(unit));
-    dest = FindResource(unit->Player, unit->X, unit->Y 
,unit->Type->ResourceHarvested);
+    //  Range hardcoded. search the whole map!!!
+    dest = FindResource(unit, unit->X, unit->Y,1000);
     if (!dest) {
        DebugLevel3Fn("oil platform not reachable by %s(%d,%d)\n"
                _C_ unit->Type->Ident _C_ unit->X _C_ unit->Y);
@@ -1261,27 +987,19 @@
        if( !unit->Type->Harvester ) {
            continue;
        }
-       c=unit->Type->ResourceHarvested;
 
        //
        //      See if it's assigned already
        //
-       switch( unit->Orders[0].Action ) {
-           case UnitActionHarvest:
-               units_assigned[num_units_assigned[WoodCost]++][WoodCost]=unit;
-               continue;
-           case UnitActionResource:
-               units_assigned[num_units_assigned[c]++][c]=unit;
-               continue;
-           default:
-               break;
+       if (unit->Orders[0].Action==UnitActionResource) {
+           c=unit->CurrentResource;
+           units_assigned[num_units_assigned[c]++][c]=unit;
        }
 
        //
        //  Send workers with resources back home.
        //
-       if (unit->Value||unit->Type==UnitTypeHumanWorkerWithWood
-               ||unit->Type==UnitTypeOrcWorkerWithWood) {
+       if (unit->Value) {
            units_with_resource[num_units_with_resource[c]++][c]=unit;
            if (unit->Orders[0].Action == UnitActionStill
                    && unit->OrderCount==1 ) {
@@ -1293,7 +1011,10 @@
        //      Look what the unit can do
        //
        for( c=0; c<MaxCosts; ++c ) {
-           int tn;
+           if (unit->Type->ResInfo[c]) {
+               units_unassigned[num_units_unassigned[c]++][c]=unit;
+           }
+#if 0
            UnitType** types;
 
            //
@@ -1329,6 +1050,7 @@
            if( j<tn ) {
                break;
            }
+#endif
        }
     }
 
@@ -1418,7 +1140,7 @@
                            int n1;
                            int n2;
                            case GoldCost:
-                               if( 
(unit->Orders[0].Action==UnitActionResource&&unit->Type->ResourceHarvested==GoldCost)
 || AiMineGold(unit) ) {
+                               if( 
(unit->Orders[0].Action==UnitActionResource&&unit->CurrentResource==GoldCost) 
|| AiMineGold(unit) ) {
                                    DebugLevel3Fn("Assigned to gold\n");
                                    
units_assigned[num_units_assigned[c]++][c]=unit;
                                    units_unassigned[i][c] = 
units_unassigned[--num_units_unassigned[c]][c];
@@ -1434,7 +1156,7 @@
                                }
                                break;
                            case WoodCost:
-                               if( unit->Orders[0].Action==UnitActionHarvest 
|| AiHarvest(unit) ) {
+                               if( 
(unit->Orders[0].Action==UnitActionResource&&unit->CurrentResource==WoodCost) 
|| AiHarvest(unit) ) {
                                    DebugLevel3Fn("Assigned to harvest\n");
                                    
units_assigned[num_units_assigned[c]++][c]=unit;
                                    units_unassigned[i][c] = 
units_unassigned[--num_units_unassigned[c]][c];
@@ -1450,7 +1172,7 @@
                                }
                                break;
                            case OilCost:
-                               if( 
(unit->Orders[0].Action==UnitActionResource&&unit->Type->ResourceHarvested==OilCost)
 || AiHaulOil(unit) ) {
+                               if( 
(unit->Orders[0].Action==UnitActionResource&&unit->CurrentResource==OilCost) || 
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/clone.c
diff -u stratagus/src/clone/clone.c:1.199 stratagus/src/clone/clone.c:1.200
--- stratagus/src/clone/clone.c:1.199   Fri Jul 11 10:35:30 2003
+++ stratagus/src/clone/clone.c Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: clone.c,v 1.199 2003/07/11 14:35:30 n0body Exp $
+//     $Id: clone.c,v 1.200 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -989,11 +989,7 @@
     char* s;
 
     va_start(va,fmt);
-#ifdef USE_WIN32
-    vsprintf(temp,fmt,va);
-#else
     vsnprintf(temp,sizeof(temp),fmt,va);
-#endif
     va_end(va);
 
     if( VideoDepth && IsFontLoaded(GameFont) ) {
Index: stratagus/src/clone/unit.c
diff -u stratagus/src/clone/unit.c:1.290 stratagus/src/clone/unit.c:1.291
--- stratagus/src/clone/unit.c:1.290    Mon Aug 25 07:21:17 2003
+++ stratagus/src/clone/unit.c  Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.c,v 1.290 2003/08/25 11:21:17 mr-russ Exp $
+//     $Id: unit.c,v 1.291 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -2462,15 +2462,152 @@
   
----------------------------------------------------------------------------*/
 
 /**
- **    Find wood in sight range.
+ **    Find the closest piece of wood for an unit.
  **
- **    @param unit     Unit that needs wood.
- **    @param px       OUT: Map X position of wood.
- **    @param py       OUT: Map Y position of wood.
+ **    @param unit     The unit.
+ **    @param x        OUT: Map X position of tile.
+ **    @param y        OUT: Map Y position of tile.
+ */
+global int FindWoodInSight(const Unit* unit,int* x,int* y)
+{
+    return FindTerrainType(UnitMovementMask(unit),0,MapFieldForest,9999,
+           unit->Player,unit->X,unit->Y,x,y);
+}
+
+/**
+ **    Find the closest piece of terrain with the given flags.
+ **
+ **    @param movemask The movement mask to reach that location. 
+ **    @param resmask  Result tile mask.
+ **    @param rvresult Return a tile that doesn't match. 
+ **    @param range    Maximum distance for the search.
+ **    @param player   Only search fields explored by player
+ **    @param x        Map X start position for the search.
+ **    @param y        Map Y start position for the search.
+ **
+ **    @param px       OUT: Map X position of tile.
+ **    @param py       OUT: Map Y position of tile.
+ **
+ **    @notes          Movement mask can be 0xFFFFFFFF to have no effect
+ **                    Range is not circular, but square.
+ **                    Player is ignored if nil(search the entire map)
+ **                    Use rvresult if you search for a til;e that doesn't
+ **                    match resmask. Like for a tile where an unit can go
+ **                    with it's movement mask.
  **
  **    @return         True if wood was found.
  */
-global int FindWoodInSight(const Unit* unit,int* px,int* py)
+global int FindTerrainType(int movemask,int resmask,int rvresult,int range,
+       const Player *player,int x,int y,int* px,int* py)
+{
+    static const int xoffset[]={  0,-1,+1, 0, -1,+1,-1,+1 };
+    static const int yoffset[]={ -1, 0, 0,+1, -1,-1,+1,+1 };
+    struct {
+       unsigned short X;
+       unsigned short Y;
+    } * points;
+    int size;
+    int rx;
+    int ry;
+    int wp;
+    int rp;
+    int ep;
+    int i;
+    int w;
+    unsigned char* m;
+    unsigned char* matrix;
+    int destx;
+    int desty;
+    int cdist;
+
+    destx=x;
+    desty=y;
+    size=min(TheMap.Width*TheMap.Height/4,range*range*5);
+    points=malloc(size*sizeof(*points));
+
+    // Make movement matrix. FIXME: can create smaller matrix.
+    matrix=CreateMatrix();
+    w=TheMap.Width+2;
+    matrix+=w+w+2;
+    points[0].X=x;
+    points[0].Y=y;
+    rp=0;
+    matrix[x+y*w]=1;                   // mark start point
+    ep=wp=1;                           // start with one point
+    cdist=0;                           // current distance is 0
+
+    //
+    // Pop a point from stack, push all neighbors which could be entered.
+    //
+    for( ;; ) {
+       while( rp!=ep ) {
+           rx=points[rp].X;
+           ry=points[rp].Y;
+           DebugLevel3("%d,%d\n" _C_ rx _C_ ry);
+           for( i=0; i<8; ++i ) {              // mark all neighbors
+               x=rx+xoffset[i];
+               y=ry+yoffset[i];
+               //  Make sure we don't leave the map.
+               if (x<0||y<0||x>=TheMap.Width||y>=TheMap.Height) {
+                   continue; 
+               }
+               m=matrix+x+y*w;
+               //  Check if visited or unexplored
+               if( *m || (player&&!IsMapFieldExplored(player,x,y))) {
+                   continue;
+               }
+               //      Look if found what was required.
+               if ( 
rvresult?CanMoveToMask(x,y,resmask):!CanMoveToMask(x,y,resmask) ) {
+                   *px=x;
+                   *py=y;
+                   DebugLevel3("Found it! %X %X\n" _C_ 
TheMap.Fields[x+y*TheMap.Width].Flags _C_ resmask);
+                   return 1;
+               }
+               if( CanMoveToMask(x,y,movemask) ) {     // reachable
+                   *m=1;
+                   points[wp].X=x;             // push the point
+                   points[wp].Y=y;
+                   if( ++wp>=size ) {          // round about
+                       wp=0;
+                   }
+                   if (wp==ep) {
+                       //  We are out of points, give up!
+                       DebugLevel0Fn("Ran out of points the hard way, 
beware.\n");
+                       break;
+                   }
+               } else {                        // unreachable
+                   *m=99;
+               }
+           }
+           if( ++rp>=size ) {                  // round about
+               rp=0;
+           }
+       }
+       cdist++;
+       if( rp==wp||cdist>=range ) {                    // unreachable, no more 
points available
+           break;
+       }
+       //      Continue with next set.
+       ep=wp;
+    }
+    free(points);
+    return 0;
+}
+
+/**
+ **    Find Resource.
+ **
+ **    @param unit     The unit that wants to find a resource.
+ **    @param x        Closest to x
+ **    @param x        Closest to y
+ **    @param range    Maximum distance to the resource.
+ **
+ **    @notes          This will return an usable resource building that
+ **                    belongs to "player" or is neutral.
+ **
+ **    @return         NoUnitP or resource unit
+ */
+global Unit* FindResource(const Unit * unit,int x,int y,int range)
 {
     static const int xoffset[]={  0,-1,+1, 0, -1,+1,-1,+1 };
     static const int yoffset[]={ -1, 0, 0,+1, -1,-1,+1,+1 };
@@ -2479,8 +2616,6 @@
        unsigned short Y;
     } * points;
     int size;
-    int x;
-    int y;
     int rx;
     int ry;
     int mask;
@@ -2493,80 +2628,42 @@
     unsigned char* m;
     unsigned char* matrix;
     const Unit* destu;
+    Unit* mine;
+    Unit* bestmine;
     int destx;
     int desty;
-    int bestx;
-    int besty;
     int bestd;
+    int cdist;
+    int resource;
 
-    destx=x=unit->X;
-    desty=y=unit->Y;
-    size=TheMap.Width*TheMap.Height/4;
+    resource=unit->CurrentResource;
+
+    destx=x;
+    desty=y;
+    size=min(TheMap.Width*TheMap.Height/4,range*range*5);
     points=malloc(size*sizeof(*points));
 
-    //
-    // Find the nearest wood depot
-    //
-    if( (destu=FindDeposit(unit->Player,x,y,WoodCost)) ) {
+    // Find the nearest gold depot
+    if( (destu=FindDeposit(unit,x,y,range)) ) {
        NearestOfUnit(destu,x,y,&destx,&desty);
     }
     bestd=99999;
-    IfDebug( bestx=besty=0; );         // keep the compiler happy
-
-    //
     // Make movement matrix. FIXME: can create smaller matrix.
-    //
     matrix=CreateMatrix();
     w=TheMap.Width+2;
     matrix+=w+w+2;
-
-    //
-    // Mark sight range as border. FIXME: matrix didn't need to be bigger.
-    //
-    n=unit->Stats->SightRange;
-    rx=x-n;
-    if( rx<0 ) {
-       rx=0;
-    }
-    ep=x+n;
-    if( ep>TheMap.Width ) {
-       ep=TheMap.Width;
-    }
-    ry=y-n;
-    if( ry<0 ) {
-       ry=0;
-    }
-    wp=y+n;
-    if( wp>TheMap.Height ) {
-       wp=TheMap.Height;
-    }
-    for( i=rx; i<ep; ++i ) {           // top bottom line
-       matrix[i+ry*w]=matrix[i+wp*w]=66;
-    }
-    for( i=ry+1; i<wp-1; ++i ) {
-       matrix[rx+i*w]=matrix[ep+i*w]=66;
-    }
-
-#if 0
-    matrix[x+n+(y+n)*w]=matrix[x-n+(y+n)*w]=
-       matrix[x+n+(y-n)*w]=matrix[x-n+(y-n)*w]=66;
-    for( i=n; i--; ) {
-       // FIXME: marks out of map area
-       DebugCheck( x-i+(y-n)*w<0 || x+i+(y+n)*w>w*TheMap.Hight );
-       matrix[x+n+(y+i)*w]=matrix[x-n+(y+i)*w]=
-           matrix[x+n+(y-i)*w]=matrix[x-n+(y-i)*w]=
-           matrix[x-i+(y+n)*w]=matrix[x+i+(y+n)*w]=
-           matrix[x-i+(y-n)*w]=matrix[x+i+(y-n)*w]=66;
-    }
-#endif
-
+    //  Unit movement mask
     mask=UnitMovementMask(unit);
-
+    //  Ignore all units along the way. Might seem wierd, but otherwise
+    //  peasants would lock at a mine with a lot of workers.
+    mask&=~(MapFieldLandUnit|MapFieldSeaUnit|MapFieldAirUnit);
     points[0].X=x;
     points[0].Y=y;
     rp=0;
     matrix[x+y*w]=1;                   // mark start point
     ep=wp=1;                           // start with one point
+    cdist=0;                           // current distance is 0
+    bestmine=NoUnitP;
 
     //
     // Pop a point from stack, push all neighbors which could be entered.
@@ -2583,23 +2680,28 @@
                    continue;
                }
 
+               if (!IsMapFieldExplored(unit->Player,x,y)) { // Unknown.
+                   continue;
+               }
+
                //
-               //      Look if there is wood
+               //      Look if there is a mine
                //
-               if ( ForestOnMap(x,y) && IsMapFieldExplored(unit->Player,x,y) ) 
{
+               if ((mine=ResourceOnMap(x,y,resource))&&
+                       (mine->Type->CanHarvest)&&
+                       ((mine->Player->Player==PlayerMax-1)||
+                       (mine->Player==unit->Player)||
+                       (IsAllied(unit->Player,mine)))) {
                    if( destu ) {
                        n=max(abs(destx-x),abs(desty-y));
                        if( n<bestd ) {
                            bestd=n;
-                           bestx=x;
-                           besty=y;
+                           bestmine=mine;
                        }
-                       *m=22;
+                       *m=99;
                    } else {                    // no goal take the first
-                       *px=x;
-                       *py=y;
                        free(points);
-                       return 1;
+                       return mine;
                    }
                }
 
@@ -2610,6 +2712,10 @@
                    if( ++wp>=size ) {          // round about
                        wp=0;
                    }
+                   if (wp==ep) {
+                       //  We are out of points, give up!
+                       break;
+                   }
                } else {                        // unreachable
                    *m=99;
                }
@@ -2618,138 +2724,141 @@
                rp=0;
            }
        }
-
-       //
        //      Take best of this frame, if any.
-       //
        if( bestd!=99999 ) {
-           *px=bestx;
-           *py=besty;
            free(points);
-           return 1;
+           return bestmine;
        }
-
-       //
-       //      Continue with next frame.
-       //
-       if( rp==wp ) {                  // unreachable, no more points available
+       cdist++;
+       if( rp==wp||cdist>=range ) {                    // unreachable, no more 
points available
            break;
        }
+       //      Continue with next set.
        ep=wp;
     }
-
-    DebugLevel3Fn("no wood in sight-range\n");
-
+    DebugLevel3Fn("no resource found\n");
     free(points);
-    return 0;
+    return NoUnitP;
 }
 
 /**
- **    Find Resource.
+ **    Find deposit. This will find a deposit for a resource 
  **
- **    @param player   The player that wants to find a resource.
- **    @param x        Nearest to X position.
- **    @param y        Nearest to Y position
- **    @param resource The ID of the resource.
+ **    @param unit     The unit that wants to find a resource.
+ **    @param x        Closest to x
+ **    @param x        Closest to y
+ **    @param range    Maximum distance to the deposit.
  **
- **    @notes          This will return an usable resource building that
- **                    belongs to "player" or is neutral.
+ **    @notes          This will return a reachable allied depot.
  **
- **    @return         NoUnitP or oil platform unit
+ **    @return         NoUnitP or oil deposit unit
  */
-global Unit* FindResource(const Player* player,int x,int y,int resource)
+global Unit* FindDeposit(const Unit* unit,int x,int y,int range)
 {
-    Unit* unit;
-    Unit* best;
-    Unit** units;
-    int nunits;
-    int best_d;
-    int d;
+    static const int xoffset[]={  0,-1,+1, 0, -1,+1,-1,+1 };
+    static const int yoffset[]={ -1, 0, 0,+1, -1,-1,+1,+1 };
+    struct {
+       unsigned short X;
+       unsigned short Y;
+    } * points;
+    int size;
+    int rx;
+    int ry;
+    int mask;
+    int wp;
+    int rp;
+    int ep;
     int i;
-    int pnum;
+    int w;
+    unsigned char* m;
+    unsigned char* matrix;
+    Unit* depot;
+    int destx;
+    int desty;
+    int cdist;
+    int resource;
 
-    // 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;
-    for (pnum=0;pnum<PlayerMax;++pnum) {
-       // FIXME: allow harvesting from ally
-       if ( (pnum!=PlayerMax-1) && (pnum!=player->Player) ) {
-           continue;
-       }
-       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;
-               }
-           }
-       }
-    }
+    resource=unit->CurrentResource;
 
-    DebugLevel3Fn("%d %d,%d\n" _C_ best?UnitNumber(best):-1 _C_
-           best?best->X:-1 _C_ best?best->Y:-1);
-    return best;
-}
+    destx=x;
+    desty=y;
+    size=min(TheMap.Width*TheMap.Height/4,range*range*5);
+    points=malloc(size*sizeof(*points));
 
-/**
- **    Find deposit. This will find a deposit for a resource 
- **
- **    @param player   The player the deposit must belong to.
- **    @param x        Nearest to X position.
- **    @param y        Nearest to Y position.
- **    @param resource The resource you need the deposit to hold.
- **
- **    @return         NoUnitP or oil deposit unit
- */
-global Unit* FindDeposit(const Player* player,int x,int y,int resource)
-{
-    Unit* unit;
-    Unit* best;
-    Unit** units;
-    int nunits;
-    int best_d;
-    int d,i;
+    // Make movement matrix. FIXME: can create smaller matrix.
+    matrix=CreateMatrix();
+    w=TheMap.Width+2;
+    matrix+=w+w+2;
+    //  Unit movement mask
+    mask=UnitMovementMask(unit);
+    //  Ignore all units along the way. Might seem wierd, but otherwise
+    //  peasants would lock at a mine with a lot of workers.
+    mask&=~(MapFieldLandUnit|MapFieldSeaUnit|MapFieldAirUnit);
+    points[0].X=x;
+    points[0].Y=y;
+    rp=0;
+    matrix[x+y*w]=1;                   // mark start point
+    ep=wp=1;                           // start with one point
+    cdist=0;                           // current distance is 0
 
-    // FIXME:  this is not the best one
-    //         We need the deposit with the shortest way!
-    //         At least it must be reachable!
-    // FIXME:  Could we use unit-cache to find it faster?
     //
-
-    best=NoUnitP;
-    best_d=INT_MAX;
-    nunits=player->TotalNumUnits;
-    units=player->Units;
-    for( i=0; i<nunits; i++ ) {
-       unit=units[i];
-       if( UnitUnusable(unit) ) {
-           continue;
-       }
-       if( unit->Type->CanStore[resource] ) {
-           d=MapDistanceToUnit(x,y,unit);
-           if( d<best_d
-                   // FIXME: UnitReachable didn't work with unit inside
-                   /*&& (d=UnitReachable(source,unit,1)) && d<best_d*/ ) {
-               best_d=d;
-               best=unit;
+    // Pop a point from stack, push all neighbors which could be entered.
+    //
+    for( ;; ) {
+       while( rp!=ep ) {
+           rx=points[rp].X;
+           ry=points[rp].Y;
+           for( i=0; i<8; ++i ) {              // mark all neighbors
+               x=rx+xoffset[i];
+               y=ry+yoffset[i];
+               //  Make sure we don't leave the map.
+               if (x<0||y<0||x>=TheMap.Width||y>=TheMap.Height) {
+                   continue; 
+               }
+               m=matrix+x+y*w;
+               //  Check if visited or unexplored
+               if( *m || !IsMapFieldExplored(unit->Player,x,y)) {
+                   continue;
+               }
+               //
+               //      Look if there is a mine
+               //
+               if ((depot=ResourceDepositOnMap(x,y,resource))&&
+                       ((IsAllied(unit->Player,depot)) ||
+                       (unit->Player==depot->Player))) {
+                   free(points);
+                   return depot;
+               }
+               if( CanMoveToMask(x,y,mask) ) { // reachable
+                   *m=1;
+                   points[wp].X=x;             // push the point
+                   points[wp].Y=y;
+                   if( ++wp>=size ) {          // round about
+                       wp=0;
+                   }
+                   if (wp==ep) {
+                       //  We are out of points, give up!
+                       DebugLevel0Fn("Ran out of points the hard way, 
beware.\n");
+                       break;
+                   }
+               } else {                        // unreachable
+                   *m=99;
+               }
            }
+           if( ++rp>=size ) {                  // round about
+               rp=0;
+           }
+       }
+       cdist++;
+       if( rp==wp||cdist>=range ) {                    // unreachable, no more 
points available
+           break;
        }
+       //      Continue with next set.
+       ep=wp;
     }
-
-    DebugLevel3Fn("%d %d,%d\n" _C_ best?UnitNumber(best):-1 _C_
-           best?best->X:-1 _C_ best?best->Y:-1);
-    return best;
+    DebugLevel3Fn("no resource deposit found\n");
+    free(points);
+    return NoUnitP;
 }
 
 /**
@@ -3146,14 +3255,14 @@
     }
 #endif
 
+    // FIXME: this is dumb. I made repairers capture. crap.
     // david: capture enemy buildings
     // Only worker types can capture.
     // Still possible to destroy building if not careful (too many attackers)
     if( EnableBuildingCapture && attacker
            && type->Building && target->HP<=damage*3
            && IsEnemy(attacker->Player,target)
-           && (attacker->Type==UnitTypeOrcWorker
-               || attacker->Type==UnitTypeHumanWorker) ) {
+           && attacker->Type->RepairRange ) {
        ChangeUnitOwner(target,attacker->Player);
        CommandStopUnit(attacker);      // Attacker shouldn't continue attack!
     }
@@ -3558,9 +3667,6 @@
        case UnitActionRepair:
            CLprintf(file,"action-repair");
            break;
-       case UnitActionHarvest:
-           CLprintf(file,"action-harvest");
-           break;
        case UnitActionResource:
            CLprintf(file,"action-resource");
            break;
@@ -3731,6 +3837,9 @@
     CLprintf(file,"'last-group %d\n  ",unit->LastGroup);
 
     CLprintf(file,"'value %d\n  ",unit->Value);
+    if (unit->CurrentResource) {
+       CLprintf(file,"'current-resource '%s\n  
",DefaultResourceNames[unit->CurrentResource]);
+    }
 
     CLprintf(file,"'sub-action %d ",unit->SubAction);
     CLprintf(file,"'wait %d ",unit->Wait);
@@ -3775,6 +3884,13 @@
                CLprintf(file," 'resource-active 
%d",unit->Data.Resource.Active);
            }
            break;
+       case UnitActionResource:
+           CLprintf(file," 'data-res-worker '(time-to-harvest 
%d",unit->Data.ResWorker.TimeToHarvest);
+           if (unit->Data.ResWorker.DoneHarvesting) {
+               CLprintf(file," done-harvesting");
+           }
+           CLprintf(file,")");
+           break;
        case UnitActionBuilded:
            {
                ConstructionFrame* cframe;
@@ -3861,7 +3977,7 @@
     int InRun, RunStart;
 
     CLprintf(file,"\n;;; -----------------------------------------\n");
-    CLprintf(file,";;; MODULE: units $Id: unit.c,v 1.290 2003/08/25 11:21:17 
mr-russ Exp $\n\n");
+    CLprintf(file,";;; MODULE: units $Id: unit.c,v 1.291 2003/09/05 18:10:55 
n0body Exp $\n\n");
 
     //
     // Local variables
Index: stratagus/src/clone/unit_draw.c
diff -u stratagus/src/clone/unit_draw.c:1.156 
stratagus/src/clone/unit_draw.c:1.157
--- stratagus/src/clone/unit_draw.c:1.156       Thu Aug 28 18:51:41 2003
+++ stratagus/src/clone/unit_draw.c     Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit_draw.c,v 1.156 2003/08/28 22:51:41 n0body Exp $
+//     $Id: unit_draw.c,v 1.157 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -577,7 +577,7 @@
 global void SaveDecorations(CLFile* file)
 {
     CLprintf(file,"\n;;; -----------------------------------------\n");
-    CLprintf(file,";;; MODULE: decorations $Id: unit_draw.c,v 1.156 2003/08/28 
22:51:41 n0body Exp $\n\n");
+    CLprintf(file,";;; MODULE: decorations $Id: unit_draw.c,v 1.157 2003/09/05 
18:10:55 n0body Exp $\n\n");
 
     CLprintf(file,"(mana-sprite \"%s\"  %d %d  %d %d)\n",
        ManaSprite.File,ManaSprite.HotX,ManaSprite.HotY,
@@ -965,13 +965,12 @@
                        ,unit->Data.UpgradeTo.Ticks);
 
            //
-           //  Chopping wood.
+           //  Carry resource.
+           //  Don't display if empty.
            //
-           } else if( unit->Orders[0].Action==UnitActionHarvest
-                   && unit->SubAction==64 ) {
-               DrawManaBar(x,y,type,CHOP_FOR_WOOD,
-                       unit->Value>CHOP_FOR_WOOD?
-                           0:CHOP_FOR_WOOD-unit->Value);
+           } else if( 
unit->Type->Harvester&&unit->CurrentResource&&unit->Value>0 ) {
+               
DrawManaBar(x,y,type,unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity,
+                       unit->Value);
 
            //
            //  Building research new technologie.
@@ -1031,15 +1030,13 @@
                DrawManaSprite(x,y,type,unit->Orders[0].Type
                            ->Stats[unit->Player->Player].Costs[TimeCost]
                        ,unit->Data.UpgradeTo.Ticks);
-
+               
            //
-           //  Chopping wood.
+           //  Carry resource.
            //
-           } else if( unit->Orders[0].Action==UnitActionHarvest
-                   && unit->SubAction==64 ) {
-               DrawManaSprite(x,y,type,CHOP_FOR_WOOD,
-                       unit->Value>CHOP_FOR_WOOD?
-                           0:CHOP_FOR_WOOD-unit->Value);
+           } else if( 
unit->Type->Harvester&&unit->CurrentResource&&unit->Value>0 ) {
+               
DrawManaSprite(x,y,type,unit->Type->ResInfo[unit->CurrentResource]->ResourceCapacity,
+                       unit->Value);
 
            //
            //  Building research new technologie.
@@ -1492,11 +1489,6 @@
            e_color = color = ColorGray;
            break;
 
-       case UnitActionHarvest:
-           e_color = color = ColorYellow;
-           dest = 1;
-           break;
-
        case UnitActionResource:
            e_color = color = ColorYellow;
            dest = 1;
@@ -1839,6 +1831,8 @@
 {
     int x;
     int y;
+    Graphic* Sprite;
+    ResourceInfo* resinfo;
     const UnitType* type;
 
     if ( unit->Type->Revealer ) {              // Revealers are not drawn
@@ -1859,13 +1853,35 @@
     DrawUnitSelection(unit);
 
     GraphicUnitPixels(unit,type->Sprite);
-    DrawUnitType(type,unit->Frame,x,y);
+
+    Sprite=type->Sprite;
+    if (type->Harvester && unit->CurrentResource) {
+       resinfo=type->ResInfo[unit->CurrentResource];
+       if (unit->Value) {
+           if (resinfo->SpriteWhenLoaded) {
+               Sprite=resinfo->SpriteWhenLoaded;
+           }
+       } else {
+           if (resinfo->SpriteWhenEmpty) {
+               Sprite=resinfo->SpriteWhenEmpty;
+           }
+       }
+    }
+    if( unit->Frame<0 ) {
+       VideoDrawClipX(Sprite,-unit->Frame,
+               x-(type->Width-type->TileWidth*TileSizeX)/2,
+               y-(type->Height-type->TileHeight*TileSizeY)/2);
+    } else {
+       VideoDrawClip(Sprite,unit->Frame,
+               x-(type->Width-type->TileWidth*TileSizeX)/2,
+               y-(type->Height-type->TileHeight*TileSizeY)/2);
+    }
 #ifdef USE_OPENGL
     DrawUnitPlayerColor(type,unit->Player->Player,unit->Frame,x,y);
 #endif
 
 #ifndef NEW_DECODRAW
-// Unit's extras not fully supported.. need to be deocrations themselves.
+// Unit's extras not fully supported.. need to be decorations themselves.
     DrawInformations(unit,type,x,y);
 #endif
 }
Index: stratagus/src/clone/unit_find.c
diff -u stratagus/src/clone/unit_find.c:1.55 
stratagus/src/clone/unit_find.c:1.56
--- stratagus/src/clone/unit_find.c:1.55        Mon Aug 25 07:21:17 2003
+++ stratagus/src/clone/unit_find.c     Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit_find.c,v 1.55 2003/08/25 11:21:17 mr-russ Exp $
+//     $Id: unit_find.c,v 1.56 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -417,7 +417,7 @@
 
     n=SelectUnitsOnTile(tx,ty,table);
     for( i=0; i<n; ++i ) {
-       if( UnitUnusable(table[i]) || !table[i]->Type->CanHarvest ){
+       if( UnitUnusable(table[i]) || !table[i]->Type->CanHarvest || 
table[i]->Value==0) {
            continue;
        }
        if( table[i]->Type->GivesResource==resource ) {
Index: stratagus/src/include/actions.h
diff -u stratagus/src/include/actions.h:1.53 
stratagus/src/include/actions.h:1.54
--- stratagus/src/include/actions.h:1.53        Sun Aug 10 22:14:46 2003
+++ stratagus/src/include/actions.h     Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: actions.h,v 1.53 2003/08/11 02:14:46 n0body Exp $
+//     $Id: actions.h,v 1.54 2003/09/05 18:10:55 n0body Exp $
 
 #ifndef __ACTIONS_H__
 #define __ACTIONS_H__
@@ -100,8 +100,8 @@
 extern void CommandBuildBuilding(Unit*,int,int,UnitType*,int);
     /// Prepare command cancel build
 extern void CommandCancelBuilding(Unit* unit,Unit* worker);
-    /// Prepare command harvest
-extern void CommandHarvest(Unit* unit,int x,int y,int flush);
+    /// Prepare command resource location
+extern void CommandResourceLoc(Unit* unit,int x,int y,int flush);
     /// Prepare command resource
 extern void CommandResource(Unit* unit,Unit* dest,int flush);
     /// Prepare command return
@@ -160,9 +160,7 @@
 extern void HandleActionBoard(Unit* unit);
     /// Handle command unload
 extern void HandleActionUnload(Unit* unit);
-    /// Handle command harvest
-extern void HandleActionHarvest(Unit* unit);
-    /// Handle command haul
+    /// Handle command resource
 extern void HandleActionResource(Unit* unit);
     /// Handle command return
 extern void HandleActionReturnGoods(Unit* unit);
Index: stratagus/src/include/commands.h
diff -u stratagus/src/include/commands.h:1.21 
stratagus/src/include/commands.h:1.22
--- stratagus/src/include/commands.h:1.21       Sun Aug 10 22:14:46 2003
+++ stratagus/src/include/commands.h    Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: commands.h,v 1.21 2003/08/11 02:14:46 n0body Exp $
+//     $Id: commands.h,v 1.22 2003/09/05 18:10:55 n0body Exp $
 
 #ifndef __COMMANDS_H__
 #define __COMMANDS_H__
@@ -98,9 +98,9 @@
 extern void SendCommandBuildBuilding(Unit*,int,int,UnitType*,int);
     /// Send cancel building command
 extern void SendCommandCancelBuilding(Unit* unit,Unit* peon);
+    /// Send harvest location command
+extern void SendCommandResourceLoc(Unit* unit,int x,int y,int flush);
     /// Send harvest command
-extern void SendCommandHarvest(Unit* unit,int x,int y,int flush);
-    /// Send haul oil command
 extern void SendCommandResource(Unit* unit,Unit* dest,int flush);
     /// Send return goods command
 extern void SendCommandReturnGoods(Unit* unit,Unit* dest,int flush);
Index: stratagus/src/include/iolib.h
diff -u stratagus/src/include/iolib.h:1.19 stratagus/src/include/iolib.h:1.20
--- stratagus/src/include/iolib.h:1.19  Thu Aug 21 03:12:03 2003
+++ stratagus/src/include/iolib.h       Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: iolib.h,v 1.19 2003/08/21 07:12:03 n0body Exp $
+//     $Id: iolib.h,v 1.20 2003/09/05 18:10:55 n0body Exp $
 
 #ifndef __IOLIB_H__
 #define __IOLIB_H__
@@ -47,6 +47,7 @@
 #include <bzlib.h>
 #undef DrawIcon
 #undef EndMenu
+#undef FindResource
 #endif
 
 #ifdef USE_ZZIPLIB
Index: stratagus/src/include/network.h
diff -u stratagus/src/include/network.h:1.39 
stratagus/src/include/network.h:1.40
--- stratagus/src/include/network.h:1.39        Fri Aug  8 15:31:36 2003
+++ stratagus/src/include/network.h     Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: network.h,v 1.39 2003/08/08 19:31:36 n0body Exp $
+//     $Id: network.h,v 1.40 2003/09/05 18:10:55 n0body Exp $
 
 #ifndef __NETWORK_H__
 #define __NETWORK_H__
@@ -83,9 +83,8 @@
     MessageCommandUnload,              /// Unit command unload
     MessageCommandBuild,               /// Unit command build building
     MessageCommandCancelBuild,         /// Unit command cancel building
-    MessageCommandHarvest,             /// Unit command harvest
-    MessageCommandMine,                        /// Unit command mine gold
-    MessageCommandResource,            /// Unit command haul oil
+    MessageCommandResourceLoc,         /// Unit command resource location
+    MessageCommandResource,            /// Unit command resource
     MessageCommandReturn,              /// Unit command return goods
     MessageCommandTrain,               /// Unit command train
     MessageCommandCancelTrain,         /// Unit command cancel training
Index: stratagus/src/include/stratagus.h
diff -u stratagus/src/include/stratagus.h:1.10 
stratagus/src/include/stratagus.h:1.11
--- stratagus/src/include/stratagus.h:1.10      Mon Sep  1 08:32:17 2003
+++ stratagus/src/include/stratagus.h   Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: stratagus.h,v 1.10 2003/09/01 12:32:17 mr-russ Exp $
+//     $Id: stratagus.h,v 1.11 2003/09/05 18:10:55 n0body Exp $
 
 #ifndef __STRATAGUS_H__
 #define __STRATAGUS_H__
@@ -139,6 +139,7 @@
 #pragma warning(disable:4244)          // Conversion from double to uchar
 #pragma warning(disable:4761)          // Integral size mismatch
 #define snprintf _snprintf             /// Unix -> dumm
+#define vsnprintf _vsnprintf
 #include <string.h>
 #define strdup _strdup
 #define strncasecmp strnicmp
@@ -531,21 +532,8 @@
     /// bits macro
 #define BitsOf(n)      (sizeof(n)*8)
 
-    // FIXME: more config stuff which needs a better place
-
-    /// How long stay in a gold-mine
-#define MINE_FOR_GOLD  (150/SpeedResourcesHarvest[GoldCost])
-    /// How long stay in a gold-deposit
-#define WAIT_FOR_GOLD  (150/SpeedResourcesReturn[GoldCost])
-    /// How much I must chop for 1 wood
-#define CHOP_FOR_WOOD  (52/SpeedResourcesHarvest[WoodCost])
-    /// How long stay in a wood-deposit
-#define WAIT_FOR_WOOD  (100/SpeedResourcesReturn[WoodCost])
-    /// How long stay in a oil-well
-#define HAUL_FOR_OIL   (100/SpeedResourcesHarvest[OilCost])
-    /// How long stay in a oil-deposit
-#define WAIT_FOR_OIL   (100/SpeedResourcesReturn[OilCost])
-
+//     FIXME: configurable. maybe we could move it into one big global
+//     FIXME: settings struct?
     /// How many resource get the player back if canceling building
 #define CancelBuildingCostsFactor      75
     /// How many resource get the player back if canceling training
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.210 stratagus/src/include/unit.h:1.211
--- stratagus/src/include/unit.h:1.210  Thu Aug 28 18:51:42 2003
+++ stratagus/src/include/unit.h        Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.h,v 1.210 2003/08/28 22:51:42 n0body Exp $
+//     $Id: unit.h,v 1.211 2003/09/05 18:10:55 n0body Exp $
 
 #ifndef __UNIT_H__
 #define __UNIT_H__
@@ -420,7 +420,6 @@
     UnitActionBuild,                   /// unit builds building
 
     UnitActionRepair,                  /// unit repairing
-    UnitActionHarvest,                 /// unit harvest lumber
     UnitActionResource,                        /// unit harvesting resources
     UnitActionReturnGoods,             /// unit returning any resource
 
@@ -568,6 +567,7 @@
                                        ** ,used for fancy buildings
                                        */
     unsigned   Rs : 8;
+    unsigned   CurrentResource;
 
 #define MAX_ORDERS 16                  /// How many outstanding orders?
     char       OrderCount;             /// how many orders in queue
@@ -595,6 +595,7 @@
     }          Resource;               /// Resource still
     struct _order_resource_worker_ {
        int     TimeToHarvest;          /// how much time until we harvest some 
more.
+       unsigned DoneHarvesting:1;      /// Harvesting done, wait for action to 
break.
     }          ResWorker;              /// Worker harvesting
     struct _order_research_ {
        Upgrade* Upgrade;               /// Upgrade researched
@@ -819,12 +820,15 @@
 extern int CanBuildUnitType(const Unit* unit,const UnitType* type,int x,int y);
 
     /// Find resource
-extern Unit* FindResource(const Player* player,int x,int y,int resource);
+extern Unit* FindResource(const Unit* unit,int x,int y,int range);
     /// Find nearest deposit
-extern Unit* FindDeposit(const Player*,int x,int y,int resource);
+extern Unit* FindDeposit(const Unit* unit,int x,int y,int range);
     /// Find the next idle worker
 extern Unit* FindIdleWorker(const Player* player,const Unit* last);
 
+    /// Find the neareast piece of terrain with specific flags.        
+extern int FindTerrainType(int movemask,int resmask,int rvresult,int range,
+       const Player *player,int x,int y,int* px,int* py);
     /// Find the nearest piece of wood in sight range
 extern int FindWoodInSight(const Unit* unit,int* x,int* y);
 
Index: stratagus/src/include/unittype.h
diff -u stratagus/src/include/unittype.h:1.102 
stratagus/src/include/unittype.h:1.103
--- stratagus/src/include/unittype.h:1.102      Wed Sep  3 05:27:51 2003
+++ stratagus/src/include/unittype.h    Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unittype.h,v 1.102 2003/09/03 09:27:51 mr-russ Exp $
+//     $Id: unittype.h,v 1.103 2003/09/05 18:10:55 n0body Exp $
 
 #ifndef __UNITTYPE_H__
 #define __UNITTYPE_H__
@@ -38,7 +38,7 @@
 ----------------------------------------------------------------------------*/
 
 /**
-**     @struct _unit_type_ unittype.h
+**     @struct _unit_type_ unittype.h
 **
 **     \#include "unittype.h"
 **
@@ -328,54 +328,17 @@
 **
 **             Resource can be harvested. It's false for things like
 **             oil patches.
+**             FIXME: crappy name.
 **
 **     UnitType::Harvester
 **
-**             Unit is a resource worker.
+**             Unit is a resource worker. Faster than examining ResInfo
 **
-**     UnitType::HarvestFromOutside
 **
-**             Unit will harvest from the outside. The unit will use it's
-**             Attack animation (seems it turned into a generic Action anim.)
-**
-**      UnitType::ResourceHarvested
-**
-**             The resource it can harvest. Needs Harvester flag. An unit
-**             can't harvest more than one type of resource.
-**             FIXME: implement something like TransformForOtherResource.
-**
-**     UnitType::WaitAtResource
-**
-**             Cycles the unit waits while inside a resource.
-**
-**     UnitType::ResourceStep
-**
-**             The unit makes so-caled mining cycles. Each mining cycle
-**             it does some sort of animation and gains ResourceStep
-**             resources. You can stop after any number of steps.
-**             when the quantity in the harvester reaches the maximum
-**             (ResourceCapacity) it will return home. I this is 0 then
-**             it's considered infinity, and ResourceCapacity will now
-**             be the limit.
+**     UnitType::ResInfo[::MaxCosts]
 **
-**     UnitType::ResourceCapacity
-**
-**             Maximum amount of resources a harvester can carry. The
-**             actual amount can be modified while unloading.
-**
-**     UnitType::WaitAtDepot
-**
-**             Cycles the unit waits while inside the depot to unload.
-**
-**     UnitType::TransformWhenEmpty;
-**     
-**             The harvester will transform into another unit when it is
-**             empty. FIXME: just change the animation.
-**
-**     UnitType::TransformWhenLoaded
-**
-**             The harvester will transform into another unit when it is
-**             loaded. FIXME: just change the animation.
+**             Information about resource harvesting. If NULL, it can't
+**             harvest it.
 **
 **     UnitType::MustBuildOnTop
 **
@@ -520,6 +483,73 @@
 **
 **             Sprite images of the player colors.  This image is drawn
 **             over UnitType::Sprite.  Used with OpenGL only.
+**
+**
+**
+**     @struct _resource_info_ unittype.h
+**
+**     \#include "unittype.h"
+**
+**     typedef struct _unit_type_ UnitType;
+**
+**     This struct contains information about how a unit will harvest a
+**     resource.
+**
+**     ResourceInfo::FileWhenLoaded
+**
+**             The harvester's animation file will change when it's loaded.
+**
+**     ResourceInfo::FileWhenEmpty;
+**     
+**             The harvester's animation file will change when it's empty.
+**             The standard animation is used only when building/repairing.
+**
+**
+**     ResourceInfo::HarvestFromOutside
+**
+**             Unit will harvest from the outside. The unit will use it's
+**             Attack animation (seems it turned into a generic Action anim.)
+**
+**      ResourceInfo::ResourceId
+**
+**             The resource this is for. Mostly redundant.
+**
+**     ResourceInfo::FinalResource
+**
+**             The resource is converted to this at the depot. Usefull for
+**             a fisherman who harvests fish, but it all turns to food at the
+**             depot.
+**
+**     ResourceInfo::WaitAtResource
+**
+**             Cycles the unit waits while inside a resource.
+**
+**     ResourceInfo::ResourceStep
+**
+**             The unit makes so-caled mining cycles. Each mining cycle
+**             it does some sort of animation and gains ResourceStep
+**             resources. You can stop after any number of steps.
+**             when the quantity in the harvester reaches the maximum
+**             (ResourceCapacity) it will return home. I this is 0 then
+**             it's considered infinity, and ResourceCapacity will now
+**             be the limit.
+**
+**     ResourceInfo::ResourceCapacity
+**
+**             Maximum amount of resources a harvester can carry. The
+**             actual amount can be modified while unloading.
+**
+**     ResourceInfo::WaitAtDepot
+**
+**             Cycles the unit waits while inside the depot to unload.
+**
+**     ResourceInfo::TerrainHarvester
+**
+**             The unit will harvest terrain. For now this only works
+**             for wood. maybe it could be made to work for rocks, but
+**             more than that requires a tileset rewrite.
+**             FIXME: more configurable.
+**
 */
 
 /*----------------------------------------------------------------------------
@@ -584,6 +614,23 @@
     MissileType*Missile;               /// Identifier to use to run time
 } MissileConfig;
 
+typedef struct _resource_info_ {
+    char *     FileWhenLoaded;                 /// Change the graphic when the 
unit is loaded.
+    char *     FileWhenEmpty;                  /// Change the graphic when the 
unit is empty.
+    unsigned   HarvestFromOutside;             /// Unit harvests without 
entering the building.
+    unsigned   WaitAtResource;                 /// Cycles the unit waits while 
mining.
+    unsigned   ResourceStep;                   /// Resources the unit gains 
per mining cycle.
+    unsigned   ResourceCapacity;               /// Max amount of resources to 
carry.
+    unsigned   WaitAtDepot;                    /// Cycles the unit waits while 
returning.
+    unsigned   ResourceId;                     /// Id of the resource 
harvested. Redundant.
+    unsigned   FinalResource;                  /// Convert resource when 
delivered. 
+    unsigned   TerrainHarvester;               /// Unit will harvest 
terrain(wood only for now).
+    unsigned   LoseResources;                  /// The unit will lose it's 
resource when distracted.
+    //  Runtime info:
+    Graphic *   SpriteWhenLoaded;              /// The graphic corresponding 
to FileWhenLoaded.
+    Graphic *   SpriteWhenEmpty;               /// The graphic corresponding 
to FileWhenEmpty
+} ResourceInfo;
+
 /**
 **     Typedef of base structure of unit-type
 */
@@ -664,6 +711,7 @@
 #define CanTargetSea   2                       /// Can attack sea units
 #define CanTargetAir   4                       /// Can attack air units
 
+    unsigned EquivType : 1;            /// 
     unsigned Revealer : 1;             /// reveal the fog of war
     unsigned LandUnit : 1;             /// Land animated
     unsigned AirUnit : 1;              /// Air animated
@@ -692,20 +740,13 @@
     unsigned Hero : 1;                 /// Is hero only used for triggers .
     unsigned Volatile : 1;             /// Invisiblity/unholy armor kills unit.
     unsigned Organic : 1;              /// Organic can be healed.
-    
+
     unsigned CanStore[MaxCosts];       /// Resources that we can store here.
     unsigned GivesResource;            /// The resource this unit gives.
     unsigned MaxWorkers;               /// Maximum number of workers.
     unsigned CanHarvest : 1;           /// Resource can be harvested.
-    unsigned Harvester : 1;            /// Unit is a resource worker.
-    unsigned HarvestFromOutside;       /// Unit harvests without entering the 
building.
-    unsigned ResourceHarvested;                /// The resource it can harvest.
-    unsigned WaitAtResource;           /// Cycles the unit waits while mining.
-    unsigned ResourceStep;             /// Resources the unit gains per mining 
cycle.
-    unsigned ResourceCapacity;         /// Max amount of resources to carry.
-    unsigned WaitAtDepot;              /// Cycles the unit waits while 
returning.
-    UnitType* TransformWhenEmpty;      /// UnitType to transform to when empty.
-    UnitType* TransformWhenLoaded;     /// UnitType to transform to when 
loaded.
+    unsigned Harvester : 1;            /// unit is a resource harvester.
+    ResourceInfo* ResInfo[MaxCosts];   /// Resource information.
     UnitType* MustBuildOnTop;          /// Must be built on top of something.
 
     unsigned SelectableByRectangle : 1;        /// Selectable with mouse 
rectangle.
@@ -756,10 +797,6 @@
 extern int NumUnitTypes;                       /// Number of unit-types made
 
 // FIXME: this hardcoded unit-types must be removed!!
-extern UnitType*UnitTypeHumanWorker;           /// Human worker
-extern UnitType*UnitTypeOrcWorker;             /// Orc worker
-extern UnitType*UnitTypeHumanWorkerWithWood;   /// Human worker with wood
-extern UnitType*UnitTypeOrcWorkerWithWood;     /// Orc worker with wood
 extern UnitType*UnitTypeHumanWall;             /// Human wall
 extern UnitType*UnitTypeOrcWall;               /// Orc wall
 extern UnitType*UnitTypeCritter;               /// Critter unit-type pointer
Index: stratagus/src/map/map.c
diff -u stratagus/src/map/map.c:1.57 stratagus/src/map/map.c:1.58
--- stratagus/src/map/map.c:1.57        Fri Jul 11 10:35:32 2003
+++ stratagus/src/map/map.c     Fri Sep  5 14:10:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: map.c,v 1.57 2003/07/11 14:35:32 n0body Exp $
+//     $Id: map.c,v 1.58 2003/09/05 18:10:55 n0body Exp $
 
 //@{
 
@@ -307,14 +307,14 @@
 */
 global int ForestOnMap(int tx,int ty)
 {
-    IfDebug(
-       if( tx<0 || ty<0 || tx>=TheMap.Width || ty>=TheMap.Height ) {
-           // FIXME: must cleanup calling function !
-           fprintf(stderr,"Used x %d, y %d\n",tx,ty);
-           abort();
-           return 0;
-       }
-    );
+#ifdef DEBUG
+    if( tx<0 || ty<0 || tx>=TheMap.Width || ty>=TheMap.Height ) {
+       // FIXME: must cleanup calling function !
+       fprintf(stderr,"Used x %d, y %d\n",tx,ty);
+       abort();
+       return 0;
+    }
+#endif
 
     return TheMap.Fields[tx+ty*TheMap.Width].Flags&MapFieldForest;
 }
Index: stratagus/src/map/minimap.c
diff -u stratagus/src/map/minimap.c:1.60 stratagus/src/map/minimap.c:1.61
--- stratagus/src/map/minimap.c:1.60    Fri Aug  8 06:16:44 2003
+++ stratagus/src/map/minimap.c Fri Sep  5 14:10:56 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: minimap.c,v 1.60 2003/08/08 10:16:44 martinxyz Exp $
+//     $Id: minimap.c,v 1.61 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -301,7 +301,7 @@
            if( (*table)->Player->Player==PlayerNumNeutral ) {
                if( type->Critter ) {
                    color=ColorNPC;
-               } else if( type->OilPatch ) {
+               } else if( type->GivesResource==OilCost ) {
                    color=ColorBlack;
                } else {
                    color=ColorYellow;
Index: stratagus/src/network/commands.c
diff -u stratagus/src/network/commands.c:1.64 
stratagus/src/network/commands.c:1.65
--- stratagus/src/network/commands.c:1.64       Sun Aug 10 22:14:46 2003
+++ stratagus/src/network/commands.c    Fri Sep  5 14:10:56 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: commands.c,v 1.64 2003/08/11 02:14:46 n0body Exp $
+//     $Id: commands.c,v 1.65 2003/09/05 18:10:56 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.64 2003/08/11 
02:14:46 n0body Exp $\"\n");
+       fprintf(LogFile,"  'comment\t\"$Id: commands.c,v 1.65 2003/09/05 
18:10:56 n0body Exp $\"\n");
        if( NetworkFildes==-1 ) {
            fprintf(LogFile,"  'type\t\"%s\"\n","single-player");
            fprintf(LogFile,"  'race\t%d\n",GameSettings.Presets[0].Race);
@@ -561,8 +561,8 @@
        
SendCommandBuildBuilding(UnitSlots[unit],posx,posy,UnitTypeByIdent(val),flags);
     } else if( !strcmp(name,"cancel-build") ) {
        SendCommandCancelBuilding(UnitSlots[unit],dunit);
-    } else if( !strcmp(name,"harvest") ) {
-       SendCommandHarvest(UnitSlots[unit],posx,posy,flags);
+    } else if( !strcmp(name,"resource-loc") ) {
+       SendCommandResourceLoc(UnitSlots[unit],posx,posy,flags);
     } else if( !strcmp(name,"resource") ) {
        SendCommandResource(UnitSlots[unit],dunit,flags);
     } else if( !strcmp(name,"return") ) {
@@ -902,20 +902,20 @@
 }
 
 /**
-**     Send command: Unit harvest wood.
+**     Send command: Unit harvests a location (wood for now).
 **
 **     @param unit     pointer to unit.
 **     @param x        X map tile position where to harvest.
 **     @param y        Y map tile position where to harvest.
 **     @param flush    Flag flush all pending commands.
 */
-global void SendCommandHarvest(Unit* unit,int x,int y,int flush)
+global void SendCommandResourceLoc(Unit* unit,int x,int y,int flush)
 {
     if( NetworkFildes==-1 ) {
-       CommandLog("harvest",unit,flush,x,y,NoUnitP,NULL,-1);
-       CommandHarvest(unit,x,y,flush);
+       CommandLog("resource-loc",unit,flush,x,y,NoUnitP,NULL,-1);
+       CommandResourceLoc(unit,x,y,flush);
     } else {
-       NetworkSendCommand(MessageCommandHarvest,unit,x,y,NoUnitP,0,flush);
+       NetworkSendCommand(MessageCommandResourceLoc,unit,x,y,NoUnitP,0,flush);
     }
 }
 
@@ -923,7 +923,7 @@
 **     Send command: Unit harvest resources
 **
 **     @param unit     pointer to unit.
-**     @param dest     pointer to destination (oil-platform).
+**     @param dest     pointer to destination (oil-platform,gold mine).
 **     @param flush    Flag flush all pending commands.
 */
 global void SendCommandResource(Unit* unit,Unit* dest,int flush)
@@ -1308,9 +1308,9 @@
            CommandLog("cancel-build",unit,FlushCommands,-1,-1,dest,NULL,-1);
            CommandCancelBuilding(unit,dest);
            break;
-       case MessageCommandHarvest:
-           CommandLog("harvest",unit,status,x,y,NoUnitP,NULL,-1);
-           CommandHarvest(unit,x,y,status);
+       case MessageCommandResourceLoc:
+           CommandLog("resource-loc",unit,status,x,y,NoUnitP,NULL,-1);
+           CommandResourceLoc(unit,x,y,status);
            break;
        case MessageCommandResource:
            dest=NoUnitP;
Index: stratagus/src/siod/sliba.c
diff -u stratagus/src/siod/sliba.c:1.8 stratagus/src/siod/sliba.c:1.9
--- stratagus/src/siod/sliba.c:1.8      Sat Sep  7 21:47:19 2002
+++ stratagus/src/siod/sliba.c  Fri Sep  5 14:10:56 2003
@@ -17,6 +17,9 @@
 
 #include "siod.h"
 #include "siodp.h"
+#undef lstrcmp
+#undef lstrcpy
+#undef lstrcat
 
 #ifndef __GNUC__
 #define __attribute__(a) /* a */
@@ -24,7 +27,7 @@
 
 static void init_sliba_version(void)
 {setvar(cintern("*sliba-version*"),
-       cintern("$Id: sliba.c,v 1.8 2002/09/08 01:47:19 johns Exp $"),
+       cintern("$Id: sliba.c,v 1.9 2003/09/05 18:10:56 n0body Exp $"),
        NIL);}
 
 static LISP sym_plists = NIL;
Index: stratagus/src/sound/sound.c
diff -u stratagus/src/sound/sound.c:1.40 stratagus/src/sound/sound.c:1.41
--- stratagus/src/sound/sound.c:1.40    Fri Jul 11 10:35:33 2003
+++ stratagus/src/sound/sound.c Fri Sep  5 14:10:56 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: sound.c,v 1.40 2003/07/11 14:35:33 n0body Exp $
+//     $Id: sound.c,v 1.41 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -181,9 +181,7 @@
        return GameSounds.TreeChopping.Sound;
     case VoiceWorkCompleted:
        // FIXME: make this more configurable
-       if (unit->Type==UnitTypeHumanWorker) {
-           return GameSounds.PeasantWorkComplete.Sound;
-       } else if( ThisPlayer->Race==PlayerRaceHuman ) {
+       if( ThisPlayer->Race==PlayerRaceHuman ) {
            return GameSounds.HumanWorkComplete.Sound;
        } else {
            return GameSounds.OrcWorkComplete.Sound;
Index: stratagus/src/ui/botpanel.c
diff -u stratagus/src/ui/botpanel.c:1.85 stratagus/src/ui/botpanel.c:1.86
--- stratagus/src/ui/botpanel.c:1.85    Wed Sep  3 09:30:43 2003
+++ stratagus/src/ui/botpanel.c Fri Sep  5 14:10:56 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: botpanel.c,v 1.85 2003/09/03 13:30:43 martinxyz Exp $
+//     $Id: botpanel.c,v 1.86 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -114,7 +114,7 @@
 #endif
 
     CLprintf(file,"\n;;; -----------------------------------------\n");
-    CLprintf(file,";;; MODULE: buttons $Id: botpanel.c,v 1.85 2003/09/03 
13:30:43 martinxyz Exp $\n\n");
+    CLprintf(file,";;; MODULE: buttons $Id: botpanel.c,v 1.86 2003/09/05 
18:10:56 n0body Exp $\n\n");
 
 #ifndef NEW_UI
     for( i=0; i<NumUnitButtons; ++i ) {
@@ -594,9 +594,7 @@
                    case ButtonHarvest:
                    case ButtonReturn:
                        for( j=0; j<NumSelected; ++j ) {
-                           if( 
Selected[j]->Orders[0].Action!=UnitActionResource
-                                   && Selected[j]->Orders[0].Action
-                                       !=UnitActionHarvest ) {
+                           if( 
Selected[j]->Orders[0].Action!=UnitActionResource ) {
                                break;
                            }
                        }
Index: stratagus/src/ui/interface.c
diff -u stratagus/src/ui/interface.c:1.135 stratagus/src/ui/interface.c:1.136
--- stratagus/src/ui/interface.c:1.135  Sun Aug 17 11:57:08 2003
+++ stratagus/src/ui/interface.c        Fri Sep  5 14:10:56 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: interface.c,v 1.135 2003/08/17 15:57:08 n0body Exp $
+//     $Id: interface.c,v 1.136 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -1082,7 +1082,7 @@
            if( !ThisPlayer->Ai ) {
                AiInit( ThisPlayer );
            }
-           SetMessage("I'm an AI Now :)");
+           SetMessage("I'm the BORG, resistance is futile!");
        }
 #endif
     } else {
Index: stratagus/src/ui/mainscr.c
diff -u stratagus/src/ui/mainscr.c:1.119 stratagus/src/ui/mainscr.c:1.120
--- stratagus/src/ui/mainscr.c:1.119    Thu Aug 28 18:51:42 2003
+++ stratagus/src/ui/mainscr.c  Fri Sep  5 14:10:56 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mainscr.c,v 1.119 2003/08/28 22:51:42 n0body Exp $
+//     $Id: mainscr.c,v 1.120 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -521,17 +521,22 @@
        VideoDrawText(x+63,y+8+125,GameFont,"Speed:");
        DrawStats(x+108,y+8+125,stats->Speed,type->_Speed);
 
-        // Show how much wood is harvested already in percents! :) //vladi
-       // FIXME: Make this optional
-        if( unit->Orders[0].Action==UnitActionHarvest && unit->SubAction==64 ) 
{
-           sprintf(buf,"Wood: %d%%"
-                   ,(100*(CHOP_FOR_WOOD-unit->Value))/CHOP_FOR_WOOD);
-           VideoDrawText(x+63,y+8+141,GameFont,buf);
-        }
        // FIXME: Ugly hack.
-       if( 
unit->Type->Harvester&&unit->Value&&unit->Orders[0].Action!=UnitActionHarvest ) 
{
+       if( unit->Type->Harvester&&unit->Value) {
            sprintf(buf,"Carry: %d %s",unit->Value,
-                   DefaultResourceNames[unit->Type->ResourceHarvested]);
+                   DefaultResourceNames[unit->CurrentResource]);
+           VideoDrawText(x+61,y+8+141,GameFont,buf);       
+       }
+       if ((unit->Type->Harvester)&&
+               (unit->Orders->Action==UnitActionResource)&&
+               (unit->CurrentResource)&&
+               (unit->Type->ResInfo[unit->CurrentResource]) &&
+               (unit->SubAction==60) &&
+               (!unit->Type->ResInfo[unit->CurrentResource]->ResourceStep)) {
+           sprintf(buf,"%s: %d%%",DefaultResourceNames[unit->CurrentResource],
+                   
100*(unit->Type->ResInfo[unit->CurrentResource]->WaitAtResource-
+                       unit->Data.ResWorker.TimeToHarvest)/
+                       
unit->Type->ResInfo[unit->CurrentResource]->WaitAtResource);
            VideoDrawText(x+61,y+8+141,GameFont,buf);       
        }
 
Index: stratagus/src/ui/menu_proc.c
diff -u stratagus/src/ui/menu_proc.c:1.100 stratagus/src/ui/menu_proc.c:1.101
--- stratagus/src/ui/menu_proc.c:1.100  Fri Aug  8 06:16:44 2003
+++ stratagus/src/ui/menu_proc.c        Fri Sep  5 14:10:56 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: menu_proc.c,v 1.100 2003/08/08 10:16:44 martinxyz Exp $
+//     $Id: menu_proc.c,v 1.101 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -40,12 +40,10 @@
 
 #include "stratagus.h"
 
-#if defined(USE_OPENGL) && defined(_MSC_VER)
+#if defined(_MSC_VER)
 #undef NOUSER
-#include "video.h"
-#else
-#include "video.h"
 #endif
+#include "video.h"
 #include "font.h"
 #include "interface.h"
 #include "menus.h"
Index: stratagus/src/ui/mouse.c
diff -u stratagus/src/ui/mouse.c:1.143 stratagus/src/ui/mouse.c:1.144
--- stratagus/src/ui/mouse.c:1.143      Wed Sep  3 05:27:51 2003
+++ stratagus/src/ui/mouse.c    Fri Sep  5 14:10:56 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mouse.c,v 1.143 2003/09/03 09:27:51 mr-russ Exp $
+//     $Id: mouse.c,v 1.144 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -111,6 +111,7 @@
     int action;
     int acknowledged;
     int flush;
+    int res;
 
     //
     // No unit selected
@@ -196,41 +197,45 @@
        //      Handle resource workers.
        //
        if( action==MouseActionHarvest ) {
-           //  Return wood cutter home
-           if( (type==UnitTypeOrcWorkerWithWood ||
-                   type==UnitTypeHumanWorkerWithWood) &&
-                   dest && dest->Type->CanStore[WoodCost] &&
-                   dest->Player==unit->Player) {
-               DebugLevel3("send to wood deposit.\n");
-               dest->Blink=4;
-               SendCommandReturnGoods(unit,dest,flush);
-               continue;
-           }
-           //  Send wood cutter to work
-           if((type==UnitTypeOrcWorker||type==UnitTypeHumanWorker) &&
-                   IsMapFieldExplored(unit->Player,x,y) &&
-                   ForestOnMap(x,y) ) {
-               SendCommandHarvest(unit,x,y,flush);
-               continue;
-           }
-           if (unit->Type->Harvester && dest) {
-               //  Return a loaded harvester to deposit
-               if( unit->Value>0 &&
-                       dest->Type->CanStore[unit->Type->ResourceHarvested] &&
-                       dest->Player==unit->Player) {
-                   dest->Blink=4;
-                   DebugLevel3Fn("Return to deposit.\n");
-                   SendCommandReturnGoods(unit,dest,flush);
-                   continue;
-               } 
-               //  Go and harvest
-               if( (unit->Value<unit->Type->ResourceCapacity) &&
-                       
dest->Type->GivesResource==unit->Type->ResourceHarvested &&
-                       (dest->Player==unit->Player ||
-                        dest->Player->Player==PlayerMax-1)) {
-                   dest->Blink=4;
-                   SendCommandResource(unit,dest,flush);
-                   continue;
+           if (unit->Type->Harvester) {
+               if ( dest ) {
+                   //  Return a loaded harvester to deposit
+                   if( (unit->Value>0) &&
+                           (dest->Type->CanStore[unit->CurrentResource])&&
+                           (dest->Player==unit->Player) ) {
+                       dest->Blink=4;
+                       DebugLevel3Fn("Return to deposit.\n");
+                       SendCommandReturnGoods(unit,dest,flush);
+                       continue;
+                   } 
+                   //  Go and harvest from an building
+                   if( (res=dest->Type->GivesResource) &&
+                           (unit->Type->ResInfo[res]) &&
+                           
(unit->Value<unit->Type->ResInfo[res]->ResourceCapacity) &&
+                           (dest->Type->CanHarvest) &&
+                           (dest->Player==unit->Player ||
+                               (dest->Player->Player==PlayerMax-1)) ) {
+                       dest->Blink=4;
+                       SendCommandResource(unit,dest,flush);
+                       continue;
+                   }
+               } else {
+                   // FIXME: support harvesting more types of terrain.
+                   for (res=0;res<MaxCosts;res++) {
+                       if ( (unit->Type->ResInfo[res]) &&
+                               (unit->Type->ResInfo[res]->TerrainHarvester) && 
+                               (IsMapFieldExplored(unit->Player,x,y)) &&
+                               (ForestOnMap(x,y)) &&
+                               ((unit->CurrentResource!=res)||
+                               
(unit->Value<unit->Type->ResInfo[res]->ResourceCapacity))) {
+                           DebugLevel3("Sent worker to cut wood.\n");
+                           SendCommandResourceLoc(unit,x,y,flush);
+                           break;
+                       }
+                   }
+                   if (res!=MaxCosts) {
+                       continue;
+                   }
                }
            }
            //  Go and repair
@@ -358,7 +363,7 @@
            }
            if( IsMapFieldExplored(unit->Player,x,y) && ForestOnMap(x,y) ) {
                 DebugLevel3("RALY POINT TO FOREST\n");                
-               
SendCommandHarvest(Selected[i],x,y,!(KeyModifiers&ModifierShift));
+               
SendCommandResourceLoc(Selected[i],x,y,!(KeyModifiers&ModifierShift));
                 continue;
             }
            SendCommandMove(unit,x,y,flush);
@@ -945,23 +950,31 @@
 **
 **     @see Selected
 */
-local void SendHarvest(int sx,int sy)
+local void SendResource(int sx,int sy)
 {
     int i;
+    int res;
     Unit* dest;
 
     for( i=0; i<NumSelected; ++i ) {
-       DebugCheck(!Selected[i]->Type->Harvester);
        if ((dest=UnitUnderCursor) &&
-               
(Selected[i]->Type->ResourceHarvested==dest->Type->GivesResource)) {
+               (Selected[i]->Type->Harvester) &&
+               (res=dest->Type->GivesResource) &&
+               (Selected[i]->Type->ResInfo[res])) {
            dest->Blink=4;
            DebugLevel3("RESOURCE\n");
            SendCommandResource(Selected[i],dest,!(KeyModifiers&ModifierShift));
            continue;
        }
-       if( IsMapFieldExplored(Selected[i]->Player,sx/TileSizeX,sy/TileSizeY) &&
-               ForestOnMap(sx/TileSizeX,sy/TileSizeY) ) {
-           
SendCommandHarvest(Selected[i],sx/TileSizeY,sy/TileSizeY,!(KeyModifiers&ModifierShift));
+       for (res=0;res<MaxCosts;res++) {
+           if( Selected[i]->Type->Harvester &&
+                   Selected[i]->Type->ResInfo[res] &&
+                   Selected[i]->Type->ResInfo[res]->TerrainHarvester &&
+                   
IsMapFieldExplored(Selected[i]->Player,sx/TileSizeX,sy/TileSizeY) &&
+                   ForestOnMap(sx/TileSizeX,sy/TileSizeY) ) {
+               DebugLevel3("RESOURCE\n");
+               
SendCommandResourceLoc(Selected[i],sx/TileSizeY,sy/TileSizeY,!(KeyModifiers&ModifierShift));
+           }
        }
     }
 }
@@ -1070,7 +1083,7 @@
            SendPatrol(sx,sy);
            break;
        case ButtonHarvest:
-           SendHarvest(sx,sy);
+           SendResource(sx,sy);
            break;
        case ButtonUnload:
            SendUnload(sx,sy);
Index: stratagus/src/unit/ccl_unit.c
diff -u stratagus/src/unit/ccl_unit.c:1.65 stratagus/src/unit/ccl_unit.c:1.66
--- stratagus/src/unit/ccl_unit.c:1.65  Mon Aug 25 07:21:18 2003
+++ stratagus/src/unit/ccl_unit.c       Fri Sep  5 14:10:56 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_unit.c,v 1.65 2003/08/25 11:21:18 mr-russ Exp $
+//     $Id: ccl_unit.c,v 1.66 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -58,6 +58,8 @@
 
     /// Get unit-type.
 extern UnitType* CclGetUnitType(SCM ptr);
+    /// Get resource by name
+extern unsigned CclGetResourceByName(SCM ptr);
 
 /**
 **     Set hit-point regeneration
@@ -209,8 +211,6 @@
            order->Action=UnitActionBuild;
        } else if( gh_eq_p(value,gh_symbol2scm("action-repair")) ) {
            order->Action=UnitActionRepair;
-       } else if( gh_eq_p(value,gh_symbol2scm("action-harvest")) ) {
-           order->Action=UnitActionHarvest;
        } else if( gh_eq_p(value,gh_symbol2scm("action-resource")) ) {
            order->Action=UnitActionResource;
        } else if( gh_eq_p(value,gh_symbol2scm("action-return-goods")) ) {
@@ -367,6 +367,29 @@
 }
 
 /**
+**     Parse res worker data
+**
+**     @param unit     Unit pointer which should be filled with the data.
+**     @param list     All options of the resource worker data.
+*/
+local void CclParseResWorker(Unit* unit, SCM list)
+{
+    SCM value;
+
+    while (!gh_null_p(list)) {
+       value = gh_car(list);
+       list = gh_cdr(list);
+       if (gh_eq_p(value, gh_symbol2scm("time-to-harvest"))) {
+           unit->Data.ResWorker.TimeToHarvest = gh_scm2int(gh_car(list));
+           list = gh_cdr(list);
+       } else if (gh_eq_p(value, gh_symbol2scm("done-harvesting"))) {
+           unit->Data.ResWorker.DoneHarvesting = 1;
+           list = gh_cdr(list);
+       }
+    }
+}
+
+/**
 **     Parse research
 **
 **     @param unit     Unit pointer which should be filled with the data.
@@ -681,6 +704,9 @@
        } else if( gh_eq_p(value,gh_symbol2scm("value")) ) {
            unit->Value=gh_scm2int(gh_car(list));
            list=gh_cdr(list);
+       } else if( gh_eq_p(value,gh_symbol2scm("current-resource")) ) {
+           unit->CurrentResource=CclGetResourceByName(gh_car(list));
+           list=gh_cdr(list);
        } else if( gh_eq_p(value,gh_symbol2scm("sub-action")) ) {
            unit->SubAction=gh_scm2int(gh_car(list));
            list=gh_cdr(list);
@@ -761,6 +787,10 @@
            sublist=gh_car(list);
            list=gh_cdr(list);
            CclParseBuilded(unit,sublist);
+       } else if( gh_eq_p(value,gh_symbol2scm("data-res-worker")) ) {
+           sublist=gh_car(list);
+           list=gh_cdr(list);
+           CclParseResWorker(unit,sublist);
        } else if( gh_eq_p(value,gh_symbol2scm("data-research")) ) {
            sublist=gh_car(list);
            list=gh_cdr(list);
Index: stratagus/src/unit/ccl_unittype.c
diff -u stratagus/src/unit/ccl_unittype.c:1.80 
stratagus/src/unit/ccl_unittype.c:1.81
--- stratagus/src/unit/ccl_unittype.c:1.80      Wed Sep  3 05:27:52 2003
+++ stratagus/src/unit/ccl_unittype.c   Fri Sep  5 14:10:56 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_unittype.c,v 1.80 2003/09/03 09:27:52 mr-russ Exp $
+//     $Id: ccl_unittype.c,v 1.81 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -71,7 +71,7 @@
 **     @param value    SCM thingie
 **     @return         the resource id
 */
-local unsigned CclGetResourceByName(SCM value)
+global unsigned CclGetResourceByName(SCM value)
 {
     int i;
     for( i=0; i<MaxCosts; ++i ) {
@@ -96,6 +96,7 @@
     SCM sublist;
     UnitType* type;
     UnitType* auxtype;
+    ResourceInfo* res;
     char* str;
     int i;
     int redefine;
@@ -271,7 +272,7 @@
            auxtype=UnitTypeByIdent(str);
            if (!auxtype) {
                DebugLevel0("Build on top of undefined unit \"%s\".\n" _C_ str);
-               exit(0);
+               DebugCheck(1);
            }
            type->MustBuildOnTop=auxtype;
            free(str);
@@ -428,43 +429,55 @@
            type->Coward=1;
        } else if( gh_eq_p(value,gh_symbol2scm("harvester")) ) {
            type->Harvester=1;
-       } else if( gh_eq_p(value,gh_symbol2scm("harvest-from-outside")) ) {
-           type->HarvestFromOutside=1;
-       } else if( gh_eq_p(value,gh_symbol2scm("resource-step")) ) {
-           type->ResourceStep=gh_scm2int(gh_car(list));
-           list=gh_cdr(list);
-       } 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));
+       } else if( gh_eq_p(value,gh_symbol2scm("can-gather-resource")) ) {
+           sublist=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);
+           res=(ResourceInfo*)malloc(sizeof(ResourceInfo));
+           memset(res,0,sizeof(ResourceInfo));
+           while( !gh_null_p(sublist) ) {
+               value=gh_car(sublist);
+               sublist=gh_cdr(sublist);
+               if (gh_eq_p(value,gh_symbol2scm("resource-id")) ) {
+                   res->ResourceId=CclGetResourceByName(gh_car(sublist));
+                   type->ResInfo[res->ResourceId]=res;
+                   sublist=gh_cdr(sublist);
+               } else if( gh_eq_p(value,gh_symbol2scm("resource-step")) ) {
+                   res->ResourceStep=gh_scm2int(gh_car(sublist));
+                   sublist=gh_cdr(sublist);
+               } else if( gh_eq_p(value,gh_symbol2scm("final-resource")) ) {
+                   res->FinalResource=CclGetResourceByName(gh_car(sublist));
+                   sublist=gh_cdr(sublist);
+               } else if( gh_eq_p(value,gh_symbol2scm("wait-at-resource")) ) {
+                   res->WaitAtResource=gh_scm2int(gh_car(sublist));
+                   sublist=gh_cdr(sublist);
+               } else if( gh_eq_p(value,gh_symbol2scm("wait-at-depot")) ) {
+                   res->WaitAtDepot=gh_scm2int(gh_car(sublist));
+                   sublist=gh_cdr(sublist);
+               } else if( gh_eq_p(value,gh_symbol2scm("resource-capacity")) ) {
+                   res->ResourceCapacity=gh_scm2int(gh_car(sublist));
+                   sublist=gh_cdr(sublist);
+               } else if( gh_eq_p(value,gh_symbol2scm("terrain-harvester")) ) {
+                   res->TerrainHarvester=1;
+               } else if( gh_eq_p(value,gh_symbol2scm("lose-resources")) ) {
+                   res->LoseResources=1;
+               } else if( gh_eq_p(value,gh_symbol2scm("harvest-from-outside")) 
) {
+                   res->HarvestFromOutside=1;
+               } else if( gh_eq_p(value,gh_symbol2scm("file-when-empty")) ) {
+                   res->FileWhenLoaded=gh_scm2newstr(gh_car(sublist),0);
+                   sublist=gh_cdr(sublist);
+               } else if( gh_eq_p(value,gh_symbol2scm("file-when-loaded")) ) {
+                   res->FileWhenLoaded=gh_scm2newstr(gh_car(sublist),0);
+                   sublist=gh_cdr(sublist);
+               } else {
+                  printf("\n%s\n",type->Name);
+                  errl("Unsupported tag",value);
+                  DebugCheck( 1 );
+               }
            }
-           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);
+           if (!res->FinalResource) {
+               res->FinalResource=res->ResourceId;
            }
-           type->TransformWhenLoaded=auxtype;
-           free(str);
-           list=gh_cdr(list);
+           DebugCheck(!res->ResourceId);
        } else if( gh_eq_p(value,gh_symbol2scm("gives-resource")) ) {
            type->GivesResource=CclGetResourceByName(gh_car(list));
            list=gh_cdr(list);
@@ -562,8 +575,8 @@
        } else {
           // FIXME: this leaves a half initialized unit-type
           printf("\n%s\n",type->Name);
-          DebugCheck( 1 );
           errl("Unsupported tag",value);
+          DebugCheck( 1 );
        }
     }
 
Index: stratagus/src/unit/unittype.c
diff -u stratagus/src/unit/unittype.c:1.93 stratagus/src/unit/unittype.c:1.94
--- stratagus/src/unit/unittype.c:1.93  Wed Sep  3 09:30:43 2003
+++ stratagus/src/unit/unittype.c       Fri Sep  5 14:10:56 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unittype.c,v 1.93 2003/09/03 13:30:43 martinxyz Exp $
+//     $Id: unittype.c,v 1.94 2003/09/05 18:10:56 n0body Exp $
 
 //@{
 
@@ -76,10 +76,6 @@
 **
 **     FIXME: find a way to make it configurable!
 */
-global UnitType*UnitTypeHumanWorker;           /// Human worker
-global UnitType*UnitTypeOrcWorker;             /// Orc worker
-global UnitType*UnitTypeHumanWorkerWithWood;   /// Human worker with wood
-global UnitType*UnitTypeOrcWorkerWithWood;     /// Orc worker with wood
 global UnitType*UnitTypeHumanWall;             /// Human wall
 global UnitType*UnitTypeOrcWall;               /// Orc wall
 global UnitType*UnitTypeCritter;               /// Critter unit type pointer
@@ -453,8 +449,13 @@
        // Cowards
        unittype->Coward=BIT(8,v)|BIT(26,v);
        if (BIT(9,v)) {
-           unittype->Harvester=1;
-           unittype->ResourceHarvested=OilCost;
+           
unittype->ResInfo[OilCost]=(ResourceInfo*)malloc(sizeof(ResourceInfo));
+           memset(unittype->ResInfo[OilCost],0,sizeof(ResourceInfo));
+           unittype->ResInfo[OilCost]->ResourceId=OilCost;
+           unittype->ResInfo[OilCost]->FinalResource=OilCost;
+           unittype->ResInfo[OilCost]->WaitAtResource=150;
+           unittype->ResInfo[OilCost]->WaitAtDepot=150;
+           unittype->ResInfo[OilCost]->ResourceCapacity=100;
        }
        unittype->Transporter=BIT(10,v);
        unittype->CanStore[GoldCost]=BIT(12,v);
@@ -645,6 +646,7 @@
 {
     int i;
     int flag;
+    ResourceInfo* res;
 
     CLprintf(file,"(define-unit-type '%s",type->Ident);
     CLprintf(file," 'name \"%s\"\n  ",type->Name);
@@ -905,36 +907,53 @@
     if( type->Coward ) {
        CLprintf(file,"  'coward\n");
     }
+    
     if( type->Harvester ) {
-       CLprintf(file,"  'harvester 'resource-harvested 
'%s\n",DefaultResourceNames[type->ResourceHarvested]);
-    }
-    if( type->HarvestFromOutside ) {
-       CLprintf(file,"  'harvest-from-outside\n");
-    }
-    if ( type->WaitAtResource ) {
-       CLprintf(file,"  'wait-at-resource %d\n",type->WaitAtResource);
-    }
-    if ( type->WaitAtDepot ) {
-       CLprintf(file,"  'wait-at-depot %d\n",type->WaitAtDepot);
-    }
-    if ( type->ResourceCapacity ) {
-        CLprintf(file,"  'resource-capacity %d\n",type->ResourceCapacity);
-    }
-    if ( type->TransformWhenEmpty ) {
-       CLprintf(file,"  'transform-when-empty 
'%s\n",type->TransformWhenEmpty->Ident);
-    }
-    if ( type->TransformWhenLoaded ) {
-       CLprintf(file,"  'transform-when-loaded 
'%s\n",type->TransformWhenLoaded->Ident);
+       CLprintf(file,"  'harvester\n");
+       for (i=0;i<MaxCosts;i++) {
+           if (type->ResInfo[i]) {
+               res=type->ResInfo[i];
+               CLprintf(file,"  'can-gather-resource '(\n");
+               CLprintf(file,"        resource-id 
%s\n",DefaultResourceNames[res->ResourceId]);
+               CLprintf(file,"        final-resource 
%s\n",DefaultResourceNames[res->FinalResource]);
+               if( res->HarvestFromOutside ) {
+                   CLprintf(file,"        harvest-from-outside\n");
+               }
+               if ( res->WaitAtResource ) {
+                   CLprintf(file,"        wait-at-resource 
%d\n",res->WaitAtResource);
+               }
+               if ( res->WaitAtDepot ) {
+                   CLprintf(file,"        wait-at-depot 
%d\n",res->WaitAtDepot);
+               }
+               if ( res->ResourceCapacity ) {
+                   CLprintf(file,"        resource-capacity 
%d\n",res->ResourceCapacity);
+               }
+               if( res->ResourceStep ) {
+                   CLprintf(file,"        resource-step 
%d\n",res->ResourceStep);
+               }
+               if( res->TerrainHarvester ) {
+                   CLprintf(file,"        terrain-harvester\n");
+               }
+               if( res->LoseResources ) {
+                   CLprintf(file,"        lose-resources\n");
+               }
+               if ( res->FileWhenEmpty ) {
+                   CLprintf(file,"        file-when-empty 
%s\n",res->FileWhenEmpty);
+               }
+               if ( res->FileWhenLoaded ) {
+                   CLprintf(file,"        file-when-loaded 
%s\n",res->FileWhenLoaded);
+               }
+               CLprintf(file,"        )\n");
+           }
+       }
     }
+
     if( type->GivesResource ) {
        CLprintf(file,"  'gives-resource 
'%s\n",DefaultResourceNames[type->GivesResource]);
     }
     if( type->MaxWorkers ) {
        CLprintf(file,"  'max-workers %d\n",type->MaxWorkers);
     }
-    if( type->ResourceStep ){
-       CLprintf(file,"  'resource-step %d\n",type->ResourceStep);
-    }
    
     // Save store info.
     for (flag=i=0;i<MaxCosts;i++)
@@ -1066,7 +1085,7 @@
     char **sp;
 
     CLprintf(file,"\n;;; -----------------------------------------\n");
-    CLprintf(file,";;; MODULE: unittypes $Id: unittype.c,v 1.93 2003/09/03 
13:30:43 martinxyz Exp $\n\n");
+    CLprintf(file,";;; MODULE: unittypes $Id: unittype.c,v 1.94 2003/09/05 
18:10:56 n0body Exp $\n\n");
 
     // Original number to internal unit-type name.
 
@@ -1222,10 +1241,6 @@
     //
     // Setup hardcoded unit types. FIXME: should be moved to some configs.
     //
-    UnitTypeHumanWorker=UnitTypeByIdent("unit-peasant");
-    UnitTypeOrcWorker=UnitTypeByIdent("unit-peon");
-    UnitTypeHumanWorkerWithWood=UnitTypeByIdent("unit-peasant-with-wood");
-    UnitTypeOrcWorkerWithWood=UnitTypeByIdent("unit-peon-with-wood");
     UnitTypeHumanWall=UnitTypeByIdent("unit-human-wall");
     UnitTypeOrcWall=UnitTypeByIdent("unit-orc-wall");
     UnitTypeCritter=UnitTypeByIdent("unit-critter");
@@ -1239,18 +1254,37 @@
 {
     UnitType* type;
     const char* file;
+    char buf[1000];
     int i;
+    int res;
+    ResourceInfo* resinfo;
 
     for( i=0; i<NumUnitTypes; ++i ) {
        type=UnitTypes[i];
        if( (file=type->ShadowFile) ) {
-           char *buf;
-           buf=alloca(strlen(file)+9+1);
            file=strcat(strcpy(buf,"graphics/"),file);
            ShowLoadProgress("\tUnit `%s'\n",file);
            
type->ShadowSprite=LoadSprite(file,type->ShadowWidth,type->ShadowHeight);
        }
 
+       //  Load empty/loaded graphics
+       if (type->Harvester) {
+           for (res=0;res<MaxCosts;res++) {
+               if ((resinfo=type->ResInfo[res])) {
+                   if ((file=resinfo->FileWhenLoaded)) {
+                       file=strcat(strcpy(buf,"graphics/"),file);
+                       ShowLoadProgress("\tUnit `%s'\n",file);
+                       
resinfo->SpriteWhenLoaded=LoadSprite(file,type->Width,type->Height);
+                   }
+                   if ((file=resinfo->FileWhenEmpty)) {
+                       file=strcat(strcpy(buf,"graphics/"),file);
+                       ShowLoadProgress("\tUnit `%s'\n",file);
+                       
resinfo->SpriteWhenEmpty=LoadSprite(file,type->Width,type->Height);
+                   }
+               }
+           }
+       }
+
        //
        //      Unit-type uses the same sprite as an other.
        //
@@ -1310,9 +1344,6 @@
 
        // FIXME: should i copy the animations of same graphics?
     }
-
-    // FIXME: must copy unit data from peon/peasant to with gold/wood
-    // FIXME: must copy unit data from tanker to tanker full
 }
 
 /**
@@ -1324,6 +1355,7 @@
     void** ptr;
     int i;
     int j;
+    int res;
     Animations* anims;
 
     DebugLevel0Fn("FIXME: icon, sounds not freed.\n");
@@ -1407,6 +1439,24 @@
            free(type->CorpseName);
        }
 
+       for (res=0;res<MaxCosts;res++) {
+           if (type->ResInfo[res]) {
+               if (type->ResInfo[res]->SpriteWhenLoaded) {
+                   free (type->ResInfo[res]->SpriteWhenLoaded);
+               }
+               if (type->ResInfo[res]->SpriteWhenEmpty) {
+                   free (type->ResInfo[res]->SpriteWhenEmpty);
+               }
+               if (type->ResInfo[res]->FileWhenEmpty) {
+                   free (type->ResInfo[res]->FileWhenEmpty);
+               }
+               if (type->ResInfo[res]->FileWhenLoaded) {
+                   free (type->ResInfo[res]->FileWhenLoaded);
+               }
+               free (type->ResInfo[res]);
+           }
+       }
+
        //
        //      FIXME: Sounds can't be freed, they still stuck in sound hash.
        //
@@ -1445,10 +1495,6 @@
     //
     // Clean hardcoded unit types.
     //
-    UnitTypeHumanWorker=NULL;
-    UnitTypeOrcWorker=NULL;
-    UnitTypeHumanWorkerWithWood=NULL;
-    UnitTypeOrcWorkerWithWood=NULL;
     UnitTypeHumanWall=NULL;
     UnitTypeOrcWall=NULL;
     UnitTypeCritter=NULL;




reply via email to

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