stratagus-cvs
[Top][All Lists]
Advanced

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

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


From: Crestez Leonard
Subject: [Stratagus-CVS] stratagus data/ccl/units.ccl data/ccl/human/uni...
Date: Tue, 22 Jul 2003 10:32:23 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Crestez Leonard <address@hidden>        03/07/22 10:32:22

Modified files:
        data/ccl       : units.ccl 
        data/ccl/human : units.ccl 
        data/ccl/orc   : units.ccl 
        src/action     : action_build.c action_still.c 
        src/ai         : ai_building.c new_ai.c 
        src/clone      : pud.c scm.c selection.c unit.c unit_draw.c 
                         unit_find.c 
        src/editor     : editloop.c 
        src/include    : stratagus.h unit.h unittype.h 
        src/map        : minimap.c 
        src/network    : commands.c 
        src/ui         : botpanel.c mainscr.c menus.c 
        src/unit       : ccl_unittype.c unittype.c upgrade.c 
        src/video      : cursor.c font.c 

Log message:
        More work on resource configuration. Better handling of Oil Platforms
        (generalized to resource platform). Changed UnitTypes to an array of
        pointers.

Patches:
Index: stratagus/data/ccl/human/units.ccl
diff -u stratagus/data/ccl/human/units.ccl:1.19 
stratagus/data/ccl/human/units.ccl:1.20
--- stratagus/data/ccl/human/units.ccl:1.19     Fri Jul 11 14:27:05 2003
+++ stratagus/data/ccl/human/units.ccl  Tue Jul 22 10:32:21 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.19 2003/07/11 18:27:05 grumbel Exp $
+;;     $Id: units.ccl,v 1.20 2003/07/22 14:32:21 n0body Exp $
 
 ;;=============================================================================
 ;;     Define unit-types.
@@ -1217,6 +1217,7 @@
   'corpse '(unit-destroyed-3x3-place 3)
   'type-naval
   'building
+  'must-build-on-top 'unit-oil-patch
   'gives-oil
   'sounds '(
     selected "human-oil-platform-selected"
Index: stratagus/data/ccl/orc/units.ccl
diff -u stratagus/data/ccl/orc/units.ccl:1.23 
stratagus/data/ccl/orc/units.ccl:1.24
--- stratagus/data/ccl/orc/units.ccl:1.23       Fri Jul 11 14:27:05 2003
+++ stratagus/data/ccl/orc/units.ccl    Tue Jul 22 10:32:21 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.23 2003/07/11 18:27:05 grumbel Exp $
+;;     $Id: units.ccl,v 1.24 2003/07/22 14:32:21 n0body Exp $
 
 ;;=============================================================================
 ;;     Define unit-types.
@@ -1309,6 +1309,7 @@
   'type-naval
   'building
   'gives-oil
+  'must-build-on-top 'unit-oil-patch
   'sounds '(
     selected "orc-oil-platform-selected"
     acknowledge "orc-oil-platform-acknowledge"
Index: stratagus/data/ccl/units.ccl
diff -u stratagus/data/ccl/units.ccl:1.36 stratagus/data/ccl/units.ccl:1.37
--- stratagus/data/ccl/units.ccl:1.36   Fri Jul 11 14:27:04 2003
+++ stratagus/data/ccl/units.ccl        Tue Jul 22 10:32:21 2003
@@ -26,15 +26,11 @@
 ;;      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.36 2003/07/11 18:27:04 grumbel Exp $
+;;     $Id: units.ccl,v 1.37 2003/07/22 14:32:21 n0body Exp $
 
 ;; Load the animations for the units.
 (load "ccl/anim.ccl" #f #t)
 
-;; Load the different races
-(load "ccl/human/units.ccl" #f #t)
-(load "ccl/orc/units.ccl" #f #t)
-
 ;;=============================================================================
 ;;     Define unit-types.
 ;;
@@ -433,3 +429,8 @@
   'building
   'critter
   'sounds '())
+
+;; Load the different races
+(load "ccl/human/units.ccl" #f #t)
+(load "ccl/orc/units.ccl" #f #t)
+
Index: stratagus/src/action/action_build.c
diff -u stratagus/src/action/action_build.c:1.83 
stratagus/src/action/action_build.c:1.84
--- stratagus/src/action/action_build.c:1.83    Sat Jul 12 10:09:17 2003
+++ stratagus/src/action/action_build.c Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_build.c,v 1.83 2003/07/12 14:09:17 n0body Exp $
+//     $Id: action_build.c,v 1.84 2003/07/22 14:32:21 n0body Exp $
 
 //@{
 
@@ -226,6 +226,19 @@
     build->CurrentSightRange=build->Type->TileWidth < build->Type->TileHeight
                                ? build->Type->TileHeight : 
build->Type->TileWidth;
 
+    // Building on top of something, must remove what is beneath it
+    if( type->MustBuildOnTop ) {
+       Unit* temp;
+       if( (temp=UnitTypeOnMap(x,y,type->MustBuildOnTop)) ) {
+           build->Value=temp->Value;
+           RemoveUnit(temp,NULL);      // Destroy building beneath
+           UnitLost(temp);
+           UnitClearOrders(temp);
+           ReleaseUnit(temp);
+       } else {
+           DebugCheck(1);
+       }
+    }
 
 /* Done by PlaceUnit now
 #ifdef HIERARCHIC_PATHFINDER
@@ -362,7 +375,7 @@
        //
        //      Building oil-platform, must update oil.
        //
-       if( type->GivesOil ) {
+       if( type->GivesResource==OilCost ) {
            CommandHaulOil(worker,unit,0);      // Let the unit haul oil
            DebugLevel0Fn("Update oil-platform\n");
            DebugLevel0Fn(" =%d\n" _C_ unit->Data.Resource.Active);
Index: stratagus/src/action/action_still.c
diff -u stratagus/src/action/action_still.c:1.64 
stratagus/src/action/action_still.c:1.65
--- stratagus/src/action/action_still.c:1.64    Fri Jul 11 10:35:29 2003
+++ stratagus/src/action/action_still.c Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: action_still.c,v 1.64 2003/07/11 14:35:29 n0body Exp $
+//     $Id: action_still.c,v 1.65 2003/07/22 14:32:21 n0body Exp $
 
 //@{
 
@@ -95,10 +95,10 @@
        //              UnitShowAnimation resets frame.
        //      FIXME: the frames are hardcoded they should be configurable
        //
-       if( unit->State==1 && type->GoldMine ) {
+       if( unit->State==1 && type->GivesResource==GoldCost ) {
            unit->Frame=!!unit->Data.Resource.Active;
        }
-       if( unit->State==1 && type->GivesOil ) {
+       if( unit->State==1 && type->GivesResource==OilCost ) {
            unit->Frame=unit->Data.Resource.Active ? 2 : 0;
        }
        UnitMarkSeen(unit);
Index: stratagus/src/ai/ai_building.c
diff -u stratagus/src/ai/ai_building.c:1.33 stratagus/src/ai/ai_building.c:1.34
--- stratagus/src/ai/ai_building.c:1.33 Sat Jul 12 10:09:17 2003
+++ stratagus/src/ai/ai_building.c      Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_building.c,v 1.33 2003/07/12 14:09:17 n0body Exp $
+//      $Id: ai_building.c,v 1.34 2003/07/22 14:32:21 n0body Exp $
 
 #ifdef NEW_AI  // {
 
@@ -448,7 +448,7 @@
                        }
                        // Town hall may not be near but we may be using it, 
check
                        // for 2 buildings near it and assume it's been used
-                       if( units[j]->Type->Building && 
!units[j]->Type->GoldMine ) {
+                       if( units[j]->Type->Building && 
!units[j]->Type->GivesResource==GoldCost ) {
                            ++buildings;
                            if( buildings==2 ) {
                                break;
@@ -640,7 +640,7 @@
     //
     // Platforms can only be build on oil patches
     //
-    if( !type->GivesOil && 
AiFindBuildingPlace2(worker,type,worker->X,worker->Y,dx,dy,1) ) {
+    if( !type->GivesResource==OilCost && 
AiFindBuildingPlace2(worker,type,worker->X,worker->Y,dx,dy,1) ) {
        return 1;
     }
 
Index: stratagus/src/ai/new_ai.c
diff -u stratagus/src/ai/new_ai.c:1.66 stratagus/src/ai/new_ai.c:1.67
--- stratagus/src/ai/new_ai.c:1.66      Fri Jul 11 10:35:29 2003
+++ stratagus/src/ai/new_ai.c   Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: new_ai.c,v 1.66 2003/07/11 14:35:29 n0body Exp $
+//      $Id: new_ai.c,v 1.67 2003/07/22 14:32:21 n0body Exp $
 
 #ifdef NEW_AI  // {
 
@@ -395,7 +395,7 @@
                    if( table[i]->Table[j]->Type==t ) {
                        if( !f ) {
                            fprintf(file,"\n  (list '%s '%s\n    ",name,
-                                   UnitTypes[t].Ident);
+                                   UnitTypes[t]->Ident);
                            f=4;
                        }
                        if( upgrade ) {
@@ -404,10 +404,10 @@
                            }
                            f+=fprintf(file,"'%s ",Upgrades[i].Ident);
                        } else {
-                           if( f+strlen(UnitTypes[i].Ident)>78 ) {
+                           if( f+strlen(UnitTypes[i]->Ident)>78 ) {
                                f=fprintf(file,"\n    ");
                            }
-                           f+=fprintf(file,"'%s ",UnitTypes[i].Ident);
+                           f+=fprintf(file,"'%s ",UnitTypes[i]->Ident);
                        }
                    }
                }
@@ -437,7 +437,7 @@
     for( i=0; i<n; ++i ) {
        if( table[i] ) {
            fprintf(file,"\n  (list '%s '%s\n    ",name,
-                   UnitTypes[i].Ident);
+                   UnitTypes[i]->Ident);
            f=4;
            for( j=0; j<table[i]->Count; ++j ) {
                if( f+strlen(table[i]->Table[j]->Ident)>78 ) {
@@ -474,7 +474,7 @@
                    if( table[i]->Table[j]->Type==t ) {
                        if( !f ) {
                            fprintf(file,"\n  (list '%s '%s\n    ",name,
-                                   UnitTypes[t].Ident);
+                                   UnitTypes[t]->Ident);
                            f=4;
                        }
                        if( f+strlen(DefaultResourceNames[i])>78 ) {
@@ -515,7 +515,7 @@
                    if( table[i]->Table[j]->Type==t ) {
                        if( !f ) {
                            fprintf(file,"\n  (list '%s '%s\n    ",name,
-                                   UnitTypes[t].Ident);
+                                   UnitTypes[t]->Ident);
                            f=4;
                        }
                        if( f+strlen("food")>78 ) {
@@ -814,7 +814,7 @@
 global void SaveAi(FILE* file)
 {
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: AI $Id: new_ai.c,v 1.66 2003/07/11 14:35:29 
n0body Exp $\n\n");
+    fprintf(file,";;; MODULE: AI $Id: new_ai.c,v 1.67 2003/07/22 14:32:21 
n0body Exp $\n\n");
 
     SaveAiTypesWcName(file);
     SaveAiHelper(file);
Index: stratagus/src/clone/pud.c
diff -u stratagus/src/clone/pud.c:1.106 stratagus/src/clone/pud.c:1.107
--- stratagus/src/clone/pud.c:1.106     Fri Jul 11 10:35:30 2003
+++ stratagus/src/clone/pud.c   Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: pud.c,v 1.106 2003/07/11 14:35:30 n0body Exp $
+//     $Id: pud.c,v 1.107 2003/07/22 14:32:21 n0body Exp $
 
 //@{
 
@@ -1291,8 +1291,7 @@
                        if (Players[o].Type != PlayerNobody) {
                            unit=MakeUnitAndPlace(MapOffsetX+x,MapOffsetY+y
                                    ,UnitTypeByWcNum(t),&Players[o]);
-                           if( unit->Type->GoldMine || unit->Type->GivesOil
-                                   || unit->Type->OilPatch ) {
+                           if( unit->Type->GivesResource ) {
                                DebugCheck( !v );
                                unit->Value=v*2500;
                            } else {    
@@ -1550,9 +1549,7 @@
        }
        buf[4]=j;
        buf[5]=Units[i]->Player->Player;
-       if( Units[i]->Type->GoldMine
-               || Units[i]->Type->OilPatch
-               || Units[i]->Type->GivesOil ) {
+       if( Units[i]->Type->GivesResource ) {
            buf[6]=(Units[i]->Value/2500) >> 0;
            buf[7]=(Units[i]->Value/2500) >> 8;
        } else {
Index: stratagus/src/clone/scm.c
diff -u stratagus/src/clone/scm.c:1.24 stratagus/src/clone/scm.c:1.25
--- stratagus/src/clone/scm.c:1.24      Fri Jul 11 10:35:30 2003
+++ stratagus/src/clone/scm.c   Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: scm.c,v 1.24 2003/07/11 14:35:30 n0body Exp $
+//     $Id: scm.c,v 1.25 2003/07/22 14:32:21 n0body Exp $
 
 //@{
 
@@ -1213,8 +1213,7 @@
                            if( Players[o].Type != PlayerNobody ) {
                                unit=MakeUnitAndPlace(MapOffsetX+x,MapOffsetY+y
                                        ,UnitTypeByWcNum(t),&Players[o]);
-                               if( unit->Type->GoldMine || unit->Type->GivesOil
-                                       || unit->Type->OilPatch ) {
+                               if( unit->Type->GivesResource ) {
 #if 0
                                    DebugCheck( !v );
                                    unit->Value=v;
Index: stratagus/src/clone/selection.c
diff -u stratagus/src/clone/selection.c:1.45 
stratagus/src/clone/selection.c:1.46
--- stratagus/src/clone/selection.c:1.45        Fri Jul 11 10:35:30 2003
+++ stratagus/src/clone/selection.c     Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: selection.c,v 1.45 2003/07/11 14:35:30 n0body Exp $
+//     $Id: selection.c,v 1.46 2003/07/22 14:32:21 n0body Exp $
 
 //@{
 
@@ -677,8 +677,8 @@
        if( type->Building && !UnitVisibleOnMap(unit) ) {
            continue;
        }
-       if( type->Critter || type->GoldMine
-             || (type->OilPatch && !unit->Removed) ) {  // no oil platform!
+       if( type->Critter || 
+               (type->GivesResource && !unit->Removed) ) { // no built 
resources.
            SelectSingleUnit(unit);
            return 1;
        }
@@ -975,7 +975,7 @@
     char *ref;
 
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: selection $Id: selection.c,v 1.45 2003/07/11 
14:35:30 n0body Exp $\n\n");
+    fprintf(file,";;; MODULE: selection $Id: selection.c,v 1.46 2003/07/22 
14:32:21 n0body Exp $\n\n");
 
     fprintf(file,"(set-group-id! %d)\n",GroupId);
     fprintf(file,"(selection %d '(",NumSelected);
Index: stratagus/src/clone/unit.c
diff -u stratagus/src/clone/unit.c:1.278 stratagus/src/clone/unit.c:1.279
--- stratagus/src/clone/unit.c:1.278    Sat Jul 12 10:09:17 2003
+++ stratagus/src/clone/unit.c  Tue Jul 22 10:32:21 2003
@@ -26,13 +26,13 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.c,v 1.278 2003/07/12 14:09:17 n0body Exp $
+//     $Id: unit.c,v 1.279 2003/07/22 14:32:21 n0body Exp $
 
 //@{
 
 /*----------------------------------------------------------------------------
---     Includes
-----------------------------------------------------------------------------*/
+  --   Includes
+  
----------------------------------------------------------------------------*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -62,8 +62,8 @@
 #include "editor.h"
 
 /*----------------------------------------------------------------------------
---     Variables
-----------------------------------------------------------------------------*/
+  --   Variables
+  
----------------------------------------------------------------------------*/
 
 #ifndef LimitSearch
 #define LimitSearch 1                  /// Limit the search
@@ -86,12 +86,12 @@
 global char RevealAttacker;            /// Config: reveal attacker enabled
 
 /*----------------------------------------------------------------------------
---     Functions
-----------------------------------------------------------------------------*/
+  --   Functions
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Initial memory allocation for units.
-*/
+ **    Initial memory allocation for units.
+ */
 global void InitUnitsMemory(void)
 {
     Unit** slot;
@@ -114,11 +114,11 @@
 
 #if 0
 /**
-**     Free the memory for an unit slot. Update the global slot table.
-**     The memory should only be freed, if all references are dropped.
-**
-**     @param unit     Pointer to unit.
-*/
+ **    Free the memory for an unit slot. Update the global slot table.
+ **    The memory should only be freed, if all references are dropped.
+ **
+ **    @param unit     Pointer to unit.
+ */
 global void FreeUnitMemory(Unit* unit)
 {
     Unit** slot;
@@ -135,12 +135,12 @@
 #endif
 
 /**
-**     Release an unit.
-**
-**     The unit is only released, if all references are dropped.
-**
-**     @param unit     Pointer to unit.
-*/
+ **    Release an unit.
+ **
+ **    The unit is only released, if all references are dropped.
+ **
+ **    @param unit     Pointer to unit.
+ */
 global void ReleaseUnit(Unit* unit)
 {
     DebugLevel2Fn("%lu:Unit %p %d `%s'\n" _C_ GameCycle _C_
@@ -170,7 +170,7 @@
        unit->Destroyed=1;              // mark as destroyed
 
        // Mark building as can't be destroyed, since it's still seen
-        if( unit->Type->Building ) {
+       if( unit->Type->Building ) {
            int i;
            int x;
            int y;
@@ -188,8 +188,8 @@
                for( ; h-->0; ) {
                    for( w=w0; w-->0; ) {
                        if( !IsMapFieldVisible(&Players[i],x+w,y+h)
-                           && IsMapFieldExplored(&Players[i],x+w,y+h)
-                           && Players[i].Type == PlayerPerson ) {
+                               && IsMapFieldExplored(&Players[i],x+w,y+h)
+                               && Players[i].Type == PlayerPerson ) {
                            unit->Visible |= (1 << i);
                        }
                    }
@@ -238,15 +238,15 @@
     ReleasedTail=&unit->Next;
     unit->Refs=GameCycle+NetworkMaxLag;        // could be reuse after this 
time
     IfDebug(
-       DebugLevel2Fn("%lu:No more references %d\n" _C_
+           DebugLevel2Fn("%lu:No more references %d\n" _C_
                GameCycle _C_ UnitNumber(unit));
-       // unit->Type=NULL;                     // for debugging.
-    );
+           // unit->Type=NULL;                 // for debugging.
+          );
 }
 
 /**
-**     FIXME: Docu
-*/
+ **    FIXME: Docu
+ */
 local Unit *AllocUnit(void)
 {
     Unit* unit;
@@ -289,11 +289,11 @@
 }
 
 /**
-**     Initialize the unit slot with default values.
-**
-**     @param unit     Unit pointer (allocated zero filled)
-**     @param type     Unit-type
-*/
+ **    Initialize the unit slot with default values.
+ **
+ **    @param unit     Unit pointer (allocated zero filled)
+ **    @param type     Unit-type
+ */
 global void InitUnit(Unit* unit, UnitType* type)
 {
     // Refs need to be *increased* by 1, not *set* to 1, because if InitUnit()
@@ -368,12 +368,12 @@
 }
 
 /**
-**     FIXME: Docu
-*/
+ **    FIXME: Docu
+ */
 global void AssignUnitToPlayer(Unit *unit, Player *player)
 {
     UnitType* type;
- 
+
     type=unit->Type;
 
     //
@@ -397,7 +397,7 @@
     }
 
     if( type->Demand ) {
-        player->NumFoodUnits+=type->Demand;    // food needed
+       player->NumFoodUnits+=type->Demand;     // food needed
        if( player==ThisPlayer ) {
            MustRedraw|=RedrawResources;        // update food
        }
@@ -415,13 +415,13 @@
 }
 
 /**
-**     Create a new unit.
-**
-**     @param type     Pointer to unit-type.
-**     @param player   Pointer to owning player.
-**
-**     @return         Pointer to created unit.
-*/
+ **    Create a new unit.
+ **
+ **    @param type     Pointer to unit-type.
+ **    @param player   Pointer to owning player.
+ **
+ **    @return         Pointer to created unit.
+ */
 global Unit* MakeUnit(UnitType* type, Player* player)
 {
     Unit* unit;
@@ -442,12 +442,12 @@
 }
 
 /**
-**     Place unit on map.
-**
-**     @param unit     Unit to be placed.
-**     @param x        X map tile position.
-**     @param y        Y map tile position.
-*/
+ **    Place unit on map.
+ **
+ **    @param unit     Unit to be placed.
+ **    @param x        X map tile position.
+ **    @param y        Y map tile position.
+ */
 global void PlaceUnit(Unit* unit,int x,int y)
 {
     const UnitType* type;
@@ -488,14 +488,14 @@
            for( h=type->TileHeight; h--; ) {
                for( w=type->TileWidth; w--; ) {
                    TheMap.Fields[x+w+(y+h)*TheMap.Width].Flags
-                           |=MapFieldBuilding;
+                       |=MapFieldBuilding;
                }
            }
        } else if( !type->OilPatch ) {
            for( h=type->TileHeight; h--; ) {
                for( w=type->TileWidth; w--; ) {
                    TheMap.Fields[x+w+(y+h)*TheMap.Width].Flags
-                           |=MapFieldNoBuilding;
+                       |=MapFieldNoBuilding;
                }
            }
        }
@@ -527,7 +527,7 @@
     //
     if( type->Building ) {
        PfHierMapChangedCallback(x, y,
-           x + type->TileWidth - 1, y + type->TileHeight - 1);
+               x + type->TileWidth - 1, y + type->TileHeight - 1);
     }
 #endif
 
@@ -545,8 +545,8 @@
        //
        if( unit->Container && unit->Removed ) {
            
MapUnmarkSight(unit->Player,unit->Container->X+unit->Container->Type->TileWidth/2
-                               
,unit->Container->Y+unit->Container->Type->TileHeight/2
-                               ,unit->CurrentSightRange);
+                   ,unit->Container->Y+unit->Container->Type->TileHeight/2
+                   ,unit->CurrentSightRange);
        }
        if (unit->Container) {
            RemoveUnitFromContainer(unit);
@@ -558,22 +558,6 @@
            MarkSubmarineSeen(unit->Player,x,y,unit->Stats->SightRange);
        }
     }
-    
-    //
-    // Building oil-platform, must remove oil-patch.
-    //
-    if( type->GivesOil ) {
-       Unit* temp;
-
-       if( (temp=OilPatchOnMap(x,y)) ) {
-           DebugCheck( !temp );
-           unit->Value=temp->Value;
-           // oil patch should NOT make sound, handled by let unit die
-           LetUnitDie(temp);           // Destroy oil patch
-       } else {
-           DebugLevel0Fn("No oil-patch to remove.\n");
-       }
-    }
 
     unit->Removed=0;
     UnitCacheInsert(unit);
@@ -584,15 +568,15 @@
 }
 
 /**
-**     Create new unit and place on map.
-**
-**     @param x        X map tile position.
-**     @param y        Y map tile position.
-**     @param type     Pointer to unit-type.
-**     @param player   Pointer to owning player.
-**
-**     @return         Pointer to created unit.
-*/
+ **    Create new unit and place on map.
+ **
+ **    @param x        X map tile position.
+ **    @param y        Y map tile position.
+ **    @param type     Pointer to unit-type.
+ **    @param player   Pointer to owning player.
+ **
+ **    @return         Pointer to created unit.
+ */
 global Unit* MakeUnitAndPlace(int x,int y,UnitType* type,Player* player)
 {
     Unit* unit;
@@ -614,11 +598,11 @@
 }
 
 /*
-**     Add unit to a container. It only updates linked list stuff
-**
-**     @param unit     Pointer to unit.
-**     @param host     Pointer to container.
-*/
+ **    Add unit to a container. It only updates linked list stuff
+ **
+ **    @param unit     Pointer to unit.
+ *     @param host     Pointer to container.
+ */
 global void AddUnitInContainer(Unit* unit, Unit* host)
 {
     if (unit->Container) {
@@ -627,7 +611,7 @@
     }
     unit->Container=host;
     if (host->InsideCount==0) {
-       unit->NextContained=unit->PrevContained=unit;
+       unit->NextContained=unit->PrevContained=unit;
     } else {
        unit->NextContained=host->UnitInside;
        unit->PrevContained=host->UnitInside->PrevContained;
@@ -639,10 +623,10 @@
 }
 
 /*
-**     Remove unit from a container. It only updates linked list stuff
-**
-**     @param unit     Pointer to unit.
-*/
+ **    Remove unit from a container. It only updates linked list stuff
+ **
+ **    @param unit     Pointer to unit.
+ */
 global void RemoveUnitFromContainer(Unit* unit)
 {
     Unit* host;
@@ -668,15 +652,15 @@
 }
 
 /*
-**     Remove unit from map.
-**
-**     Update selection.
-**     Update panels.
-**     Update map.
-**
-**     @param unit     Pointer to unit.
-**     @param host     Pointer to housing unit.
-*/
+ **    Remove unit from map.
+ **
+ **    Update selection.
+ **    Update panels.
+ **    Update map.
+ **
+ **    @param unit     Pointer to unit.
+ **    @param host     Pointer to housing unit.
+ */
 global void RemoveUnit(Unit* unit, Unit* host)
 {
     int h;
@@ -686,19 +670,19 @@
 
     if( unit->Removed && unit->Container ) {
        
MapUnmarkSight(unit->Player,unit->Container->X+unit->Container->Type->TileWidth/2
-                               
,unit->Container->Y+unit->Container->Type->TileHeight/2
-                               ,unit->CurrentSightRange);
+               ,unit->Container->Y+unit->Container->Type->TileHeight/2
+               ,unit->CurrentSightRange);
     } else {
        MapUnmarkSight(unit->Player,unit->X+unit->Type->TileWidth/2
-                               ,unit->Y+unit->Type->TileHeight/2
-                               ,unit->CurrentSightRange);
+               ,unit->Y+unit->Type->TileHeight/2
+               ,unit->CurrentSightRange);
     }
     if( host ) {
        unit->CurrentSightRange=host->CurrentSightRange;
        MapMarkSight(unit->Player,host->X+host->Type->TileWidth/2,
-                       host->Y+host->Type->TileWidth/2,
-                       unit->CurrentSightRange);
-       AddUnitInContainer(unit,host);
+               host->Y+host->Type->TileWidth/2,
+               unit->CurrentSightRange);
+       AddUnitInContainer(unit,host);
     }
 
     if( unit->Removed ) {              // could happen!
@@ -708,7 +692,7 @@
     unit->Removed=1;
     //  Remove unit from the current selection
     if( unit->Selected ) {
-        if( NumSelected==1 ) {         //  Remove building cursor
+       if( NumSelected==1 ) {          //  Remove building cursor
            CancelBuildingMode();
        }
        UnSelectUnit(unit);
@@ -740,14 +724,14 @@
            for( h=type->TileHeight; h--; ) {
                for( w=type->TileWidth; w--; ) {
                    TheMap.Fields[unit->X+w+(unit->Y+h)*TheMap.Width].Flags
-                           &=~MapFieldBuilding;
+                       &=~MapFieldBuilding;
                }
            }
        } else if( !type->OilPatch ) {
            for( h=type->TileHeight; h--; ) {
                for( w=type->TileWidth; w--; ) {
                    TheMap.Fields[unit->X+w+(unit->Y+h)*TheMap.Width].Flags
-                           &=~MapFieldNoBuilding;
+                       &=~MapFieldNoBuilding;
                }
            }
        }
@@ -756,8 +740,8 @@
        //      Update hierarchic pathfinder structures.
        //
        PfHierMapChangedCallback (unit->X, unit->Y,
-                   unit->X + unit->Type->TileWidth - 1,
-                   unit->Y + unit->Type->TileHeight - 1);
+               unit->X + unit->Type->TileWidth - 1,
+               unit->Y + unit->Type->TileHeight - 1);
 #endif
     } else {
        unsigned flags;
@@ -786,7 +770,7 @@
     //
     if( type->Building ) {
        PfHierMapChangedCallback(unit->X, unit->Y,
-           unit->X + type->TileWidth - 1, unit->Y + type->TileHeight - 1);
+               unit->X + type->TileWidth - 1, unit->Y + type->TileHeight - 1);
     }
 #endif
 
@@ -796,18 +780,18 @@
     UnitCacheRemove(unit);
     // UnitCache uses Next, need to set next again
     unit->Next=host;
-     
+
     MustRedraw|=RedrawMinimap;
     CheckUnitToBeDrawn(unit);
 }
 
 /**
-**     Update informations for lost units.
-**
-**     @param unit     Pointer to unit.
-**
-**     @note Also called by ChangeUnitOwner
-*/
+ **    Update informations for lost units.
+ **
+ **    @param unit     Pointer to unit.
+ **
+ **    @note Also called by ChangeUnitOwner
+ */
 global void UnitLost(Unit* unit)
 {
     Unit* temp;
@@ -831,7 +815,7 @@
     //  Remove unit from its groups
     //
     if( unit->GroupId ) {
-        RemoveUnitFromGroups(unit);
+       RemoveUnitFromGroups(unit);
     }
 
     //
@@ -910,18 +894,14 @@
     //
     if( unit->Orders[0].Action == UnitActionResearch ) {
        unit->Player->UpgradeTimers.Upgrades[unit->Data.Research.Upgrade
-               -Upgrades]=0;
+           -Upgrades]=0;
     }
 
     DebugLevel3Fn("Lost %s(%d)\n" _C_ unit->Type->Ident _C_ UnitNumber(unit));
 
-    //
-    // Destroy oil-platform, must re-make oil patch.
-    //
-    if( type->GivesOil && unit->Value>0 ) {
-       // NOTE: I wasn't sure the best UnitType/Player
-       // NOTE: This should really NOT be hardcoded?!
-       temp=MakeUnitAndPlace(unit->X,unit->Y,UnitTypeOilPatch,&Players[15]);
+    // Destroy resource-platform, must re-make resource patch.
+    if( type->MustBuildOnTop && unit->Value>0 ) {
+       
temp=MakeUnitAndPlace(unit->X,unit->Y,type->MustBuildOnTop,&Players[15]);
        temp->Value=unit->Value;
     }
     DebugCheck( player->NumFoodUnits > UnitMax);
@@ -931,8 +911,8 @@
 }
 
 /**
-**     FIXME: Docu
-*/
+ **    FIXME: Docu
+ */
 global void UnitClearOrders(Unit *unit)
 {
     int i;
@@ -971,11 +951,11 @@
 }
 
 /**
-**     Update for new unit. Food and income ...
-**
-**     @param unit     New unit pointer.
-**     @param upgrade  True unit was upgraded.
-*/
+ **    Update for new unit. Food and income ...
+ **
+ **    @param unit     New unit pointer.
+ **    @param upgrade  True unit was upgraded.
+ */
 global void UpdateForNewUnit(const Unit* unit,int upgrade)
 {
     const UnitType* type;
@@ -1010,14 +990,14 @@
 }
 
 /**
-**     Find nearest point of unit.
-**
-**     @param unit     Pointer to unit.
-**     @param tx       X tile map postion.
-**     @param ty       Y tile map postion.
-**     @param dx       Out: nearest point X tile map postion to (tx,ty).
-**     @param dy       Out: nearest point Y tile map postion to (tx,ty).
-*/
+ **    Find nearest point of unit.
+ **
+ **    @param unit     Pointer to unit.
+ **    @param tx       X tile map postion.
+ **    @param ty       Y tile map postion.
+ **    @param dx       Out: nearest point X tile map postion to (tx,ty).
+ **    @param dy       Out: nearest point Y tile map postion to (tx,ty).
+ */
 global void NearestOfUnit(const Unit* unit,int tx,int ty,int *dx,int *dy)
 {
     int x;
@@ -1046,16 +1026,16 @@
 }
 
 /**
-**     Mark submarine seen by a submarine detector.
-**
-**     @param player   Player pointer that can see the submarine
-**     @param x        X map tile center position
-**     @param y        Y map tile center position
-**     @param r        Range around center
-**
-**     @note
-**             All units are marked as visible, not only submarines.
-*/
+ **    Mark submarine seen by a submarine detector.
+ **
+ **    @param player   Player pointer that can see the submarine
+ **    @param x        X map tile center position
+ **    @param y        Y map tile center position
+ **    @param r        Range around center
+ **
+ **    @note
+ **            All units are marked as visible, not only submarines.
+ */
 global void MarkSubmarineSeen(const Player* player,int x,int y,int r)
 {
     Unit* table[UnitMax];
@@ -1071,14 +1051,14 @@
 }
 
 /**
-**     Returns true, if unit is visible for this player on the map.
-**     An unit is visible, if any field could be seen.
-**
-**     @warning        This is only true for ::ThisPlayer.
-**
-**     @param unit     Unit to be checked.
-**     @return         True if visible, false otherwise.
-*/
+ **    Returns true, if unit is visible for this player on the map.
+ **    An unit is visible, if any field could be seen.
+ **
+ **    @warning        This is only true for ::ThisPlayer.
+ **
+ **    @param unit     Unit to be checked.
+ **    @return         True if visible, false otherwise.
+ */
 global int UnitVisibleOnMap(const Unit* unit)
 {
     int x;
@@ -1118,14 +1098,14 @@
 }
 
 /**
-**     Returns true, if unit is visible for this player on the map.
-**     An unit is visible, if any field could be seen.
-**
-**     @warning        This is only true for ::ThisPlayer.
-**
-**     @param unit     Unit to be checked.
-**     @return         True if visible, false otherwise.
-*/
+ **    Returns true, if unit is visible for this player on the map.
+ **    An unit is visible, if any field could be seen.
+ **
+ **    @warning        This is only true for ::ThisPlayer.
+ **
+ **    @param unit     Unit to be checked.
+ **    @return         True if visible, false otherwise.
+ */
 global int BuildingVisibleOnMap(const Unit* unit)
 {
     int x;
@@ -1157,11 +1137,11 @@
 }
 
 /**
-**     FIXME: docu
-**
-**     @param x        x location to check if building is on, and mark as seen
-**     @param y        y location to check if building is on, and mark as seen
-*/
+ **    FIXME: docu
+ **
+ **    @param x        x location to check if building is on, and mark as seen
+ **    @param y        y location to check if building is on, and mark as seen
+ */
 global void UnitsMarkSeen(int x,int y)
 {
     int n;
@@ -1176,9 +1156,9 @@
            units[n-1]->SeenFrame = units[n-1]->Frame;
            units[n-1]->SeenType = units[n-1]->Type;
            units[n-1]->SeenState = 
(units[n-1]->Orders[0].Action==UnitActionBuilded) |
-                   ((units[n-1]->Orders[0].Action==UnitActionUpgradeTo) << 1);
+               ((units[n-1]->Orders[0].Action==UnitActionUpgradeTo) << 1);
            if( units[n-1]->Orders[0].Action==UnitActionDie ) {
-                   units[n-1]->SeenState = 3;
+               units[n-1]->SeenState = 3;
            }
            units[n-1]->SeenConstructed = units[n-1]->Constructed;
            units[n-1]->SeenDestroyed = units[n-1]->Destroyed;
@@ -1188,10 +1168,10 @@
 }
 
 /**
-**     FIXME: docu
-**
-**     @param unit     pointer to the unit to check if seen
-*/
+ **    FIXME: docu
+ **
+ **    @param unit     pointer to the unit to check if seen
+ */
 global void UnitMarkSeen(Unit* unit)
 {
     int x;
@@ -1210,7 +1190,7 @@
                unit->SeenFrame = unit->Frame;
                unit->SeenType = unit->Type;
                unit->SeenState = (unit->Orders[0].Action==UnitActionBuilded) |
-                       ((unit->Orders[0].Action==UnitActionUpgradeTo) << 1);
+                   ((unit->Orders[0].Action==UnitActionUpgradeTo) << 1);
                if( unit->Orders[0].Action==UnitActionDie ) {
                    unit->SeenState = 3;
                }
@@ -1224,11 +1204,11 @@
 }
 
 /**
-**     Returns true, if unit is known on the map. Special case for buildings.
-**
-**     @param unit     Unit to be checked.
-**     @return         True if known, false otherwise.
-*/
+ **    Returns true, if unit is known on the map. Special case for buildings.
+ **
+ **    @param unit     Unit to be checked.
+ **    @return         True if known, false otherwise.
+ */
 global int UnitKnownOnMap(const Unit* unit)
 {
     int x;
@@ -1279,12 +1259,12 @@
 }
 
 /**
-**     Returns true, if unit is visible in viewport.
-**
-**     @param vp       Viewport number.
-**     @param unit     Unit to be checked.
-**     @return         True if visible, false otherwise.
-*/
+ **    Returns true, if unit is visible in viewport.
+ **
+ **    @param vp       Viewport number.
+ **    @param unit     Unit to be checked.
+ **    @return         True if visible, false otherwise.
+ */
 global int UnitVisibleInViewport(const Viewport* vp, const Unit* unit)
 {
     int x;
@@ -1305,8 +1285,8 @@
     // FIXME: Need to be able to see enemy submarines seen by my shared vision
     //         partners
     if( ThisPlayer != unit->Player &&
-       !(unit->Player->SharedVision&(1<<ThisPlayer->Player) &&
-       ThisPlayer->SharedVision&(1<<unit->Player->Player)) ) {
+           !(unit->Player->SharedVision&(1<<ThisPlayer->Player) &&
+               ThisPlayer->SharedVision&(1<<unit->Player->Player)) ) {
        // Invisible by spell
        if ( unit->Invisible ) {
            return 0;
@@ -1350,11 +1330,11 @@
 }
 
 /**
-**     Returns true, if unit is visible on current map view (any viewport).
-**
-**     @param unit     Unit to be checked.
-**     @return         True if visible, false otherwise.
-*/
+ **    Returns true, if unit is visible on current map view (any viewport).
+ **
+ **    @param unit     Unit to be checked.
+ **    @return         True if visible, false otherwise.
+ */
 global int UnitVisibleOnScreen(const Unit* unit)
 {
     const Viewport* vp;
@@ -1369,16 +1349,16 @@
 }
 
 /**
-**      Get area of map tiles covered by unit, including its displacement.
-**
-**      @param unit     Unit to be checked and set.
-**     @param sx       Out: Top left X tile map postion.
-**     @param sy       Out: Top left Y tile map postion.
-**     @param ex       Out: Bottom right X tile map postion.
-**     @param ey       Out: Bottom right Y tile map postion.
-**
-**      @return                sx,sy,ex,ey defining area in Map
-*/
+ **      Get area of map tiles covered by unit, including its displacement.
+ **
+ **      @param unit     Unit to be checked and set.
+ **    @param sx       Out: Top left X tile map postion.
+ **    @param sy       Out: Top left Y tile map postion.
+ **    @param ex       Out: Bottom right X tile map postion.
+ **    @param ey       Out: Bottom right Y tile map postion.
+ **
+ **      @return               sx,sy,ex,ey defining area in Map
+ */
 global void GetUnitMapArea(const Unit* unit, int *sx, int *sy, int *ex, int 
*ey)
 {
     *sx = unit->X - (unit->IX < 0);
@@ -1389,11 +1369,11 @@
 
 #ifdef NEW_DECODRAW
 /**
-**     Decoration redraw function that will redraw an unit (no building) for
-**     set clip rectangle by decoration mechanism.
-**
-**     @param data     Unit pointer to be drawn
-*/
+ **    Decoration redraw function that will redraw an unit (no building) for
+ **    set clip rectangle by decoration mechanism.
+ **
+ **    @param data     Unit pointer to be drawn
+ */
 local void DecoUnitDraw(void* data)
 {
     Unit* unit;
@@ -1406,11 +1386,11 @@
 }
 
 /**
-**     Decoration redraw function that will redraw a building for
-**     set clip rectangle by decoration mechanism.
-**
-**     @param data     Unit pointer to be drawn
-*/
+ **    Decoration redraw function that will redraw a building for
+ **    set clip rectangle by decoration mechanism.
+ **
+ **    @param data     Unit pointer to be drawn
+ */
 local void DecoBuildingDraw(void* data)
 {
     Unit *unit;
@@ -1423,14 +1403,14 @@
 }
 
 /**
-**     Create decoration for any unit-type
-**
-**     @param u        an unit which is visible on screen
-**      @param x       x pixel position on screen of left-top
-**      @param y       y pixel position on screen of left-top
-**      @param w       width in pixels of area to be drawn from (x,y)
-**      @param h       height in pixels of area to be drawn from (x,y)
-*/
+ **    Create decoration for any unit-type
+ **
+ **    @param u        an unit which is visible on screen
+ **      @param x      x pixel position on screen of left-top
+ **      @param y      y pixel position on screen of left-top
+ **      @param w      width in pixels of area to be drawn from (x,y)
+ **      @param h      height in pixels of area to be drawn from (x,y)
+ */
 local void AddUnitDeco(Unit* u, int x, int y, int w, int h)
 {
     if (u->Type->Building) {
@@ -1444,11 +1424,11 @@
 #endif
 
 /**
-**      Check and sets if unit must be drawn on screen-map
-**
-**      @param unit     Unit to be checked.
-**      @return         True if map marked to be drawn, false otherwise.
-*/
+ **      Check and sets if unit must be drawn on screen-map
+ **
+ **      @param unit     Unit to be checked.
+ **      @return         True if map marked to be drawn, false otherwise.
+ */
 global int CheckUnitToBeDrawn(const Unit* unit)
 {
 #ifdef NEW_MAPDRAW
@@ -1505,7 +1485,7 @@
                DecorationMark(unit->deco);
            }
        }
-        else {
+       else {
            AddUnitDeco((Unit *)unit, x, y, w, h);
        }
 
@@ -1532,8 +1512,8 @@
 #include "../pathfinder/pf_lowlevel.h"
 
 /**
-**     FIXME: Docu
-*/
+ **    FIXME: Docu
+ */
 global int UnitGetNextPathSegment(const Unit* unit, int *dx, int *dy)
 {
     int segment;
@@ -1556,8 +1536,8 @@
 #endif // } HIERARCHIC_PATHFINDER
 
 /**
-**     Do the runestone work each second.
-*/
+ **    Do the runestone work each second.
+ */
 global void DoRunestones(void)
 {
     Unit* units[UnitMax];
@@ -1573,10 +1553,10 @@
     for (i = 0; i < nstones; ++i) {
        // Get all the units around the runestone
        nunits = SelectUnits(stones[i]->X - stones[i]->Stats->SightRange,
-                            stones[i]->Y - stones[i]->Stats->SightRange,
-                            stones[i]->X + stones[i]->Stats->SightRange+1,
-                            stones[i]->Y + stones[i]->Stats->SightRange+1,
-                            units);
+               stones[i]->Y - stones[i]->Stats->SightRange,
+               stones[i]->X + stones[i]->Stats->SightRange+1,
+               stones[i]->Y + stones[i]->Stats->SightRange+1,
+               units);
        // Runestone Mana and HP on units, 2 every time
        for (j = 0; j < nunits; ++j) {
            if (units[j] == stones[i]) {
@@ -1585,7 +1565,7 @@
 
            // Restore HP in everything but buildings (even in other player's 
units)
            if (!units[j]->Type->Building && units[j]->Type->Organic && 
-                       units[j]->HP != units[j]->Stats->HitPoints ) {
+                   units[j]->HP != units[j]->Stats->HitPoints ) {
                tmp = units[j]->Stats->HitPoints - units[j]->HP;
                if (tmp > 2) {
                    tmp = 2;
@@ -1608,14 +1588,14 @@
 // FIXME: perhaps I should write a function UnitSelectable?
 
 /**
-**     Increment mana of all magic units. Called each second.
-**     Also clears the blink flag and handles submarines.
-**
-**     @note   we could build a table of all magic units reducing cpu use.
-**
-**     @todo FIXME: Split this into more functions, to make the use clearer
-**             or rename the function.
-*/
+ **    Increment mana of all magic units. Called each second.
+ **    Also clears the blink flag and handles submarines.
+ **
+ **    @note   we could build a table of all magic units reducing cpu use.
+ **
+ **    @todo FIXME: Split this into more functions, to make the use clearer
+ **            or rename the function.
+ */
 //FIXME: vladi: the doc says incrementing mana is done by 1 per second
 //       the spells effect can be decremented at the same time and this
 //       will reduse calls to this function to one time per second only!
@@ -1638,7 +1618,7 @@
 
            // some frames delayed done my color cycling
            if( 0 ) {
-                CheckUnitToBeDrawn(unit);
+               CheckUnitToBeDrawn(unit);
            }
            if( unit->Selected ) {
                MustRedraw|=RedrawInfoPanel;
@@ -1652,7 +1632,7 @@
            DebugLevel0Fn("Unit must die %lu %lu!\n" _C_ unit->TTL
                    _C_ GameCycle);
            //if( !--unit->HP ) { FIXME: must reduce hp the last seconds of life
-               LetUnitDie(unit);
+           LetUnitDie(unit);
            //}
            // FIXME: this can modify my table, some units are than skipped!
            continue;
@@ -1666,31 +1646,31 @@
        if ( unit->Bloodlust ) {
            unit->Bloodlust--;
            if( !flag && !unit->Bloodlust ) {
-                flag=CheckUnitToBeDrawn(unit);
+               flag=CheckUnitToBeDrawn(unit);
            }
        }
        if ( unit->Haste ) {
            unit->Haste--;
            if( !flag && !unit->Haste ) {
-                flag=CheckUnitToBeDrawn(unit);
+               flag=CheckUnitToBeDrawn(unit);
            }
        }
        if ( unit->Slow ) {
            unit->Slow--;
            if( !flag && !unit->Slow ) {
-                flag=CheckUnitToBeDrawn(unit);
+               flag=CheckUnitToBeDrawn(unit);
            }
        }
        if ( unit->Invisible ) {
            unit->Invisible--;
            if( !flag && !unit->Invisible ) {
-                flag=CheckUnitToBeDrawn(unit);
+               flag=CheckUnitToBeDrawn(unit);
            }
        }
        if ( unit->UnholyArmor ) {
            unit->UnholyArmor--;
            if( !flag && !unit->UnholyArmor ) {
-                flag=CheckUnitToBeDrawn(unit);
+               flag=CheckUnitToBeDrawn(unit);
            }
        }
        DebugLevel3Fn("%d:%d,%d,%d,%d,%d\n" _C_ UnitNumber(unit) _C_
@@ -1699,7 +1679,7 @@
 
        if (  unit->Type->Submarine ) {
            if( !flag && (unit->Visible&(1<<ThisPlayer->Player)) ) {
-                flag=CheckUnitToBeDrawn(unit);
+               flag=CheckUnitToBeDrawn(unit);
            }
            unit->Visible=0;
        }
@@ -1715,19 +1695,19 @@
        if( unit->Type->CanSeeSubmarine && !unit->Removed &&
                unit->Orders[0].Action!=UnitActionBuilded ) {
            MarkSubmarineSeen(unit->Player,unit->X+unit->Type->TileWidth/2,
-               unit->Y+unit->Type->TileHeight/2,unit->Stats->SightRange);
+                   unit->Y+unit->Type->TileHeight/2,unit->Stats->SightRange);
        }
     }
 }
 
 /**
-**     Increment health of all regenerating units. Called each second.
-**
-**     @note:  We could build a table of all regenerating units reducing cpu
-**             use.
-**             Any idea how to handle this more general? It whould be nice
-**             to have more units that could regenerate.
-*/
+ **    Increment health of all regenerating units. Called each second.
+ **
+ **    @note:  We could build a table of all regenerating units reducing cpu
+ **            use.
+ **            Any idea how to handle this more general? It whould be nice
+ **            to have more units that could regenerate.
+ */
 global void UnitIncrementHealth(void)
 {
     Unit** table;
@@ -1756,7 +1736,7 @@
 
            // some frames delayed done my color cycling
            if( 0 ) {
-                CheckUnitToBeDrawn(unit);
+               CheckUnitToBeDrawn(unit);
            }
            if( unit->Selected ) {
                MustRedraw|=RedrawInfoPanel;
@@ -1766,15 +1746,15 @@
 }
 
 /**
-**     Change the unit's owner
-**
-**     @param unit             Unit which should be consigned.
-**     @param newplayer        New owning player.
-**
-**     @todo   FIXME: I think here are some failures, if building is build
-**             what is with the unit inside? or a main hall with workers
-**             inside?
-*/
+ **    Change the unit's owner
+ **
+ **    @param unit             Unit which should be consigned.
+ **    @param newplayer        New owning player.
+ **
+ **    @todo   FIXME: I think here are some failures, if building is build
+ **            what is with the unit inside? or a main hall with workers
+ **            inside?
+ */
 global void ChangeUnitOwner(Unit* unit,Player* newplayer)
 {
     int i;
@@ -1782,21 +1762,16 @@
     Player* oldplayer;
 
     oldplayer=unit->Player;
-   
+
     // This shouldn't happen
     if (oldplayer==newplayer) {
-        DebugLevel0Fn("Change the unit owner to the same player???\n");
-        return;
+       DebugLevel0Fn("Change the unit owner to the same player???\n");
+       return;
     }
-  
-    //
-    // Rescue all units in buildings/transporters.
-    //
-    printf("Rescue of a %s at 0x%X\n",unit->Type->Name,(unsigned)unit);
 
+    // Rescue all units in buildings/transporters.
     uins=unit->UnitInside;
     for( i=unit->InsideCount; i; --i,uins=uins->NextContained) {
-        printf("Chain rescue of a %s\n at 
0x%X",Units[i]->Type->Name,(unsigned)Units[i]);
        ChangeUnitOwner(uins,newplayer);
     }
 
@@ -1809,19 +1784,19 @@
     //  Mainly to protect peasants who are building.
     //  FIXME: What's the point in this code? It just causes a crash when
     //  FIXME: an unit is moving (the unit stops when between map cells.)
-    
+
     /*for( i=0; i < MAX_ORDERS; i++) {
-        if (unit->Orders[i].Action==UnitActionAttack ||
-            unit->Orders[i].Action==UnitActionAttackGround) {
-               //Now see if it's an enemy..
-               //FIXME:Just Stops attacking at the moment
-               printf("Stopped attack for a/an %s,\n",unit->Type->Name);
-               unit->Orders[i].Action=UnitActionStill;
-               unit->SubAction=unit->State=0;
-               break;
-        }
+      if (unit->Orders[i].Action==UnitActionAttack ||
+      unit->Orders[i].Action==UnitActionAttackGround) {
+    //Now see if it's an enemy..
+    //FIXME:Just Stops attacking at the moment
+    printf("Stopped attack for a/an %s,\n",unit->Type->Name);
+    unit->Orders[i].Action=UnitActionStill;
+    unit->SubAction=unit->State=0;
+    break;
+    }
     }*/
-    
+
     //
     // Now the new side!
     //
@@ -1840,29 +1815,29 @@
     *unit->PlayerSlot=unit;
 
     unit->Player=newplayer;
-    
+
     if ( unit->Removed && unit->Container ) {
-        
MapUnmarkSight(oldplayer,unit->Container->X+unit->Container->Type->TileWidth/2
-            ,unit->Container->Y+unit->Container->Type->TileHeight/2
-           ,unit->CurrentSightRange);
-        
MapMarkSight(unit->Player,unit->Container->X+unit->Container->Type->TileWidth/2
-           ,unit->Container->Y+unit->Container->Type->TileHeight/2
-            ,unit->CurrentSightRange);
+       
MapUnmarkSight(oldplayer,unit->Container->X+unit->Container->Type->TileWidth/2
+               ,unit->Container->Y+unit->Container->Type->TileHeight/2
+               ,unit->CurrentSightRange);
+       
MapMarkSight(unit->Player,unit->Container->X+unit->Container->Type->TileWidth/2
+               ,unit->Container->Y+unit->Container->Type->TileHeight/2
+               ,unit->CurrentSightRange);
     } else {
-        MapUnmarkSight(oldplayer,unit->X+unit->Type->TileWidth/2
-            ,unit->Y+unit->Type->TileHeight/2
-           ,unit->CurrentSightRange);
-        MapMarkSight(unit->Player,unit->X+unit->Type->TileWidth/2
-           ,unit->Y+unit->Type->TileHeight/2
-            ,unit->CurrentSightRange);
+       MapUnmarkSight(oldplayer,unit->X+unit->Type->TileWidth/2
+               ,unit->Y+unit->Type->TileHeight/2
+               ,unit->CurrentSightRange);
+       MapMarkSight(unit->Player,unit->X+unit->Type->TileWidth/2
+               ,unit->Y+unit->Type->TileHeight/2
+               ,unit->CurrentSightRange);
     }
 
     unit->Stats=&unit->Type->Stats[newplayer->Player];
     //
     // Must change food/gold and other.
     //
-    if( unit->Type->GivesOil ) {
-       DebugLevel0Fn("oil platform transfer unsupported\n");
+    if( unit->Type->GivesResource ) {
+       DebugLevel0Fn("Resource transfer not supported\n");
     }
     if( !unit->Type->Building ) {
        newplayer->NumFoodUnits+=unit->Type->Demand;
@@ -1878,11 +1853,11 @@
 }
 
 /**
-**     Change the owner of all units of a player.
-**
-**     @param oldplayer        Old owning player.
-**     @param newplayer        New owning player.
-*/
+ **    Change the owner of all units of a player.
+ **
+ **    @param oldplayer        Old owning player.
+ **    @param newplayer        New owning player.
+ */
 local void ChangePlayerOwner(Player* oldplayer,Player* newplayer)
 {
     Unit* table[UnitMax];
@@ -1895,10 +1870,10 @@
     memcpy(table,oldplayer->Units,n*sizeof(Unit*));
     for( i=0; i<n; i++ ) {
        unit=table[i];
-        // Don't save the unit again(can happen when inside a town hall)
-        if (unit->Player==newplayer) {
-            continue;
-        }
+       // Don't save the unit again(can happen when inside a town hall)
+       if (unit->Player==newplayer) {
+           continue;
+       }
        ChangeUnitOwner(unit,newplayer);
        unit->Blink=5;
        unit->RescuedFrom=oldplayer;
@@ -1906,10 +1881,10 @@
 }
 
 /**
-**     Rescue units.
-**
-**     Look through all rescueable players, if they could be rescued.
-*/
+ **    Rescue units.
+ **
+ **    Look through all rescueable players, if they could be rescued.
+ */
 global void RescueUnits(void)
 {
     Player* p;
@@ -1940,11 +1915,11 @@
            memcpy(table,p->Units,l*sizeof(Unit*));
            for( j=0; j<l; j++ ) {
                unit=table[j];
-                // Do not rescue removed units. Units inside something are
-                // rescued by ChangeUnitOwner
-                if (unit->Removed) {
-                    continue;
-                }
+               // Do not rescue removed units. Units inside something are
+               // rescued by ChangeUnitOwner
+               if (unit->Removed) {
+                   continue;
+               }
                DebugLevel3("Checking %d(%s)" _C_ UnitNumber(unit) _C_
                        unit->Type->Ident);
 #ifdef UNIT_ON_MAP
@@ -1955,35 +1930,31 @@
                // NOTE: +1 right,bottom isn't inclusive :(
                if( unit->Type->UnitType==UnitTypeLand ) {
                    n=SelectUnits(
-                       unit->X-1,unit->Y-1,
-                       unit->X+unit->Type->TileWidth+1,
-                       unit->Y+unit->Type->TileHeight+1,around);
+                           unit->X-1,unit->Y-1,
+                           unit->X+unit->Type->TileWidth+1,
+                           unit->Y+unit->Type->TileHeight+1,around);
                } else {
                    n=SelectUnits(
-                       unit->X-2,unit->Y-2,
-                       unit->X+unit->Type->TileWidth+2,
-                       unit->Y+unit->Type->TileHeight+2,around);
+                           unit->X-2,unit->Y-2,
+                           unit->X+unit->Type->TileWidth+2,
+                           unit->Y+unit->Type->TileHeight+2,around);
                }
                DebugLevel3(" = %d\n" _C_ n);
                //
                //      Look if ally near the unit.
                //
                for( i=0; i<n; ++i ) {
-#if 0
-                   if( around[i]->Type->CanAttack &&
-                           around[i]->Player->Type==PlayerPerson ) {
-#endif
                    if( around[i]->Type->CanAttack &&
                            IsAllied(unit->Player,around[i]) ) {
-                       //
+                       //
                        //      City center converts complete race
                        //      NOTE: I use a trick here, centers could
                        //              store gold. FIXME!!!
                        if( unit->Type->CanStore[GoldCost] ) {
                            ChangePlayerOwner(p,around[i]->Player);
-                            break;
+                           break;
                        }
-                        unit->RescuedFrom=unit->Player;
+                       unit->RescuedFrom=unit->Player;
                        ChangeUnitOwner(unit,around[i]->Player);
                        unit->Blink=5;
                        
PlayGameSound(GameSounds.Rescue[unit->Player->Race].Sound
@@ -1997,16 +1968,16 @@
 }
 
 /*----------------------------------------------------------------------------
---     Unit headings
-----------------------------------------------------------------------------*/
+  --   Unit headings
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Fast arc tangent function.
-**
-**     @param val      atan argument
-**
-**     @return         atan(val)
-*/
+ **    Fast arc tangent function.
+ **
+ **    @param val      atan argument
+ **
+ **    @return         atan(val)
+ */
 local int myatan(int val)
 {
     static int init;
@@ -2026,13 +1997,13 @@
 }
 
 /**
-**     Convert direction to heading.
-**
-**     @param delta_x  Delta X.
-**     @param delta_y  Delta Y.
-**
-**     @return         Angle (0..255)
-*/
+ **    Convert direction to heading.
+ **
+ **    @param delta_x  Delta X.
+ **    @param delta_y  Delta Y.
+ **
+ **    @return         Angle (0..255)
+ */
 global int DirectionToHeading(int delta_x,int delta_y)
 {
     //
@@ -2042,7 +2013,7 @@
        if( delta_y<0 ) {       // Quadrant 1?
            return myatan((delta_x*64)/-delta_y);
        }
-                               // Quadrant 2?
+       // Quadrant 2?
        return myatan((delta_y*64)/delta_x)+64;
     }
     if( delta_y>0 ) {          // Quadrant 3?
@@ -2055,8 +2026,8 @@
 }
 
 /**
-**     Update sprite frame for new heading.
-*/
+ **    Update sprite frame for new heading.
+ */
 global void UnitUpdateHeading(Unit* unit)
 {
     int dir;
@@ -2080,12 +2051,12 @@
 }
 
 /**
-**     Change unit heading/frame from delta direction x,y.
-*
-**     @param unit     Unit for new direction looking.
-**     @param dx       X map tile delta direction.
-**     @param dy       Y map tile delta direction.
-*/
+ **    Change unit heading/frame from delta direction x,y.
+ *
+ **    @param unit     Unit for new direction looking.
+ **    @param dx       X map tile delta direction.
+ **    @param dy       Y map tile delta direction.
+ */
 global void UnitHeadingFromDeltaXY(Unit* unit,int dx,int dy)
 {
     unit->Direction=DirectionToHeading(dx,dy);
@@ -2093,17 +2064,17 @@
 }
 
 /*----------------------------------------------------------------------------
---     Drop out units
-----------------------------------------------------------------------------*/
+  --   Drop out units
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Reappear unit on map.
-**
-**     @param unit     Unit to drop out.
-**     @param heading  Direction in which the unit should appear.
-**     @param addx     Tile size in x.
-**     @param addy     Tile size in y.
-*/
+ **    Reappear unit on map.
+ **
+ **    @param unit     Unit to drop out.
+ **    @param heading  Direction in which the unit should appear.
+ **    @param addx     Tile size in x.
+ **    @param addy     Tile size in y.
+ */
 global void DropOutOnSide(Unit* unit,int heading,int addx,int addy)
 {
     int x;
@@ -2203,14 +2174,14 @@
 }
 
 /**
-**     Reappear unit on map nearest to x,y.
-**
-**     @param unit     Unit to drop out.
-**     @param gx       Goal X map tile position.
-**     @param gy       Goal Y map tile position.
-**     @param addx     Tile size in x.
-**     @param addy     Tile size in y.
-*/
+ **    Reappear unit on map nearest to x,y.
+ **
+ **    @param unit     Unit to drop out.
+ **    @param gx       Goal X map tile position.
+ **    @param gy       Goal Y map tile position.
+ **    @param addx     Tile size in x.
+ **    @param addy     Tile size in y.
+ */
 global void DropOutNearest(Unit* unit,int gx,int gy,int addx,int addy)
 {
     int x;
@@ -2301,10 +2272,10 @@
 }
 
 /**
-**     Drop out all units inside unit.
-**
-**     @param source   All units inside source are dropped out.
-*/
+ **    Drop out all units inside unit.
+ **
+ **    @param source   All units inside source are dropped out.
+ */
 global void DropOutAll(const Unit* source)
 {
     Unit* unit;
@@ -2323,19 +2294,19 @@
 }
 
 /*----------------------------------------------------------------------------
---     Building units
-----------------------------------------------------------------------------*/
+  --   Building units
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Can build unit here.
-**             Hall to near to goldmine.
-**             Refinery or shipyard to near to oil patch.
-**
-**     @param type     unit-type to be checked.
-**     @param x        Map X position.
-**     @param y        Map Y position.
-**     @return         True if could build here, otherwise false.
-*/
+ **            Can build unit here.
+ **            Hall to near to goldmine.
+ **            Refinery or shipyard to near to oil patch.
+ **
+ **    @param type     unit-type to be checked.
+ **    @param x        Map X position.
+ **    @param y        Map Y position.
+ **    @return         True if could build here, otherwise false.
+ */
 global int CanBuildHere(const UnitType* type,int x,int y)
 {
     Unit* table[UnitMax];
@@ -2344,6 +2315,10 @@
     Unit* unit;
     int dx;
     int dy;
+    int w;
+    int h;
+    int resource;
+    int found;
 
     //
     // Can't build outside the map
@@ -2356,18 +2331,15 @@
     }
 
     if( EditorRunning ) {
-       if( type->OilPatch || type->GivesOil ) {
+       if( type->GivesResource==OilCost ) {
            // Oil patches and platforms can only be placed on even tiles
            if( !(x&1 && y&1) ) {
                return 0;
            }
-           // Don't allow oil patches on oil patches
-           if( type->OilPatch ) {
-               
n=UnitCacheSelect(x,y,x+type->TileWidth,y+type->TileHeight,table);
-               for( i=0; i<n; ++i ) {
-                   if( table[i]->Type->OilPatch ) {
-                       return 0;
-                   }
+           n=UnitCacheSelect(x,y,x+type->TileWidth,y+type->TileHeight,table);
+           for( i=0; i<n; ++i ) {
+               if( table[i]->Type->GivesResource==OilCost ) {
+                   return 0;
                }
            }
        } else if( type->UnitType==UnitTypeFly || type->UnitType==UnitTypeNaval 
) {
@@ -2378,17 +2350,33 @@
        }
     }
 
-    if( type->CanStore[GoldCost] ) {
-       //
-       //      Gold deposit can't be build too near to gold-mine.
-       //
-       // FIXME: use unit-cache here.
-        int i;
+    // Must be checked before oil!
+    if( type->ShoreBuilding ) {
+       found=0;
 
-       for( i=0; i<NumUnits; i++ ) {
-           unit=Units[i];
-           if( unit->Type->GoldMine ) {
-               DebugLevel3("Check goldmine %d,%d\n" _C_ unit->X _C_ unit->Y);
+       DebugLevel3("Shore building\n");
+       // Need atleast one coast tile
+       for( h=type->TileHeight; h--; ) {
+           for( w=type->TileWidth; w--; ) {
+               if( TheMap.Fields[x+w+(y+h)*TheMap.Width].Flags
+                       &MapFieldCoastAllowed ) {
+                   h=w=0;
+                   found=1;
+               }
+           }
+       }
+       if ( !found ) {
+           return 0;
+       }
+    }
+    
+    // resource deposit can't be build too near to resource
+    // FIXME: use unit-cache here.
+    for( i=0; i<NumUnits; i++ ) {
+       unit=Units[i];
+       for (resource=1;resource<MaxCosts;resource++) {
+           if (( type->CanStore[resource] && 
unit->Type->GivesResource==resource )||
+                   ( unit->Type->CanStore[resource] && 
type->GivesResource==resource )) {
                if( unit->X<x ) {
                    dx=x-unit->X-unit->Type->TileWidth;
                } else {
@@ -2400,71 +2388,21 @@
                    dy=unit->Y-y-type->TileHeight;
                }
                DebugLevel3("Distance %d,%d\n" _C_ dx _C_ dy);
-               if( dx<GOLDMINE_DISTANCE && dy<GOLDMINE_DISTANCE ) {
+               if( dx<RESOURCE_DISTANCE && dy<RESOURCE_DISTANCE ) {
                    return 0;
                }
            }
        }
-       return 1;
     }
 
-    // Must be checked before oil!
-    if( type->ShoreBuilding ) {
-       int h;
-       int w;
-
-       DebugLevel3("Shore building\n");
-       // Need atleast one coast tile
-       for( h=type->TileHeight; h--; ) {
-           for( w=type->TileWidth; w--; ) {
-               if( TheMap.Fields[x+w+(y+h)*TheMap.Width].Flags
-                           &MapFieldCoastAllowed ) {
-                   goto next;
-               }
-           }
-       }
-       return 0;
-    }
-
-next:
-    if( type->CanStore[OilCost] ) {
-       //
-       //      Oil deposit can't be build too near to oil-patch or platform.
-       //
-       // FIXME: use unit-cache here.
-       int i;
-
-       for( i=0; i<NumUnits; i++ ) {
-           unit=Units[i];
-           if( unit->Type->OilPatch || unit->Type->GivesOil ) {
-             DebugLevel3("Check oilpatch %d,%d\n"
-                         _C_ unit->X _C_ unit->Y);
-             if( unit->X<x ) {
-               dx=x-unit->X-unit->Type->TileWidth;
-             } else {
-               dx=unit->X-x-type->TileWidth;
-             }
-             if( unit->Y<y ) {
-               dy=y-unit->Y-unit->Type->TileHeight;
-             } else {
-               dy=unit->Y-y-type->TileHeight;
-             }
-             DebugLevel3("Distance %d,%d\n" _C_ dx _C_ dy);
-             if( dx<OILPATCH_DISTANCE && dy<OILPATCH_DISTANCE ) {
-               return 0;
-             }
-           }
-       }
-    }
-
-    if( type->GivesOil ) {
-       //
-       //      Oil platform could only be build on oil-patch.
-       //
-       // FIXME: Can I use here OilPatchOnMap?
+    if( type->MustBuildOnTop ) {
+       // Resource platform could only be build on resource patch.
        n=UnitCacheSelect(x,y,x+1,y+1,table);
        for( i=0; i<n; ++i ) {
-           if( !table[i]->Type->OilPatch ) {
+           if( table[i]->Type!=type->MustBuildOnTop ) {
+               continue;
+           }
+           if( table[i]->Orders[0].Action==UnitActionBuilded ) {
                continue;
            }
            if( table[i]->X==x && table[i]->Y==y ) {
@@ -2479,8 +2417,8 @@
 }
 
 /**
-**     Can build on this point.
-*/
+ **    Can build on this point.
+ */
 global int CanBuildOn(int x,int y,int mask)
 {
     if( x<0 || y<0 || x>=TheMap.Width || y>=TheMap.Height ) {
@@ -2490,16 +2428,16 @@
 }
 
 /**
-**     Can build unit-type on this point.
-**
-**     @param unit     Worker that want to build the building or NULL.
-**     @param type     Building unit-type.
-**     @param x        X tile map position.
-**     @param y        Y tile map position.
-**     @return         True if the building could be build..
-**
-**     @todo can't handle building units !1x1, needs a rewrite.
-*/
+ **    Can build unit-type on this point.
+ **
+ **    @param unit     Worker that want to build the building or NULL.
+ **    @param type     Building unit-type.
+ **    @param x        X tile map position.
+ **    @param y        Y tile map position.
+ **    @return         True if the building could be build..
+ **
+ **    @todo can't handle building units !1x1, needs a rewrite.
+ */
 global int CanBuildUnitType(const Unit* unit,const UnitType* type,int x,int y)
 {
     int w;
@@ -2507,6 +2445,11 @@
     int j;
     int mask;
 
+    // Terrain Flags don't matter.
+    if ( type->MustBuildOnTop ) {
+       return CanBuildHere(type,x,y);
+    }
+
     //
     // Remove unit that is building!
     //
@@ -2522,44 +2465,44 @@
     // FIXME: Should be moved into unittype structure, and allow more types.
     if( type->ShoreBuilding ) {
        mask=MapFieldLandUnit
-               | MapFieldSeaUnit
-               | MapFieldBuilding      // already occuppied
-               | MapFieldWall
-               | MapFieldRocks
-               | MapFieldForest        // wall,rock,forest not 100% clear?
-               | MapFieldLandAllowed   // can't build on this
-               //| MapFieldUnpassable  // FIXME: I think shouldn't be used
-               | MapFieldNoBuilding;
+           | MapFieldSeaUnit
+           | MapFieldBuilding  // already occuppied
+           | MapFieldWall
+           | MapFieldRocks
+           | MapFieldForest    // wall,rock,forest not 100% clear?
+           | MapFieldLandAllowed       // can't build on this
+           //| MapFieldUnpassable      // FIXME: I think shouldn't be used
+           | MapFieldNoBuilding;
     } else if( type->Building ) {
        switch( type->UnitType ) {
-       case UnitTypeLand:
-           mask=MapFieldLandUnit
-               | MapFieldBuilding      // already occuppied
-               | MapFieldWall
-               | MapFieldRocks
-               | MapFieldForest        // wall,rock,forest not 100% clear?
-               | MapFieldCoastAllowed
-               | MapFieldWaterAllowed  // can't build on this
-               | MapFieldUnpassable    // FIXME: I think shouldn't be used
-               | MapFieldNoBuilding;
-           break;
-       case UnitTypeNaval:
-           mask=MapFieldSeaUnit
-               | MapFieldBuilding      // already occuppied
-               | MapFieldCoastAllowed
-               | MapFieldLandAllowed   // can't build on this
-               | MapFieldUnpassable    // FIXME: I think shouldn't be used
-               | MapFieldNoBuilding;
-           break;
-       case UnitTypeFly:
-           mask=MapFieldAirUnit;       // already occuppied
-           break;
-       default:
-           DebugLevel1Fn("Were moves this unit?\n");
-           if( unit ) {
-               TheMap.Fields[unit->X+unit->Y*TheMap.Width].Flags|=j;
-           }
-           return 0;
+           case UnitTypeLand:
+               mask=MapFieldLandUnit
+                   | MapFieldBuilding  // already occuppied
+                   | MapFieldWall
+                   | MapFieldRocks
+                   | MapFieldForest    // wall,rock,forest not 100% clear?
+                   | MapFieldCoastAllowed
+                   | MapFieldWaterAllowed      // can't build on this
+                   | MapFieldUnpassable        // FIXME: I think shouldn't be 
used
+                   | MapFieldNoBuilding;
+               break;
+           case UnitTypeNaval:
+               mask=MapFieldSeaUnit
+                   | MapFieldBuilding  // already occuppied
+                   | MapFieldCoastAllowed
+                   | MapFieldLandAllowed       // can't build on this
+                   | MapFieldUnpassable        // FIXME: I think shouldn't be 
used
+                   | MapFieldNoBuilding;
+               break;
+           case UnitTypeFly:
+               mask=MapFieldAirUnit;   // already occuppied
+               break;
+           default:
+               DebugLevel1Fn("Were moves this unit?\n");
+               if( unit ) {
+                   TheMap.Fields[unit->X+unit->Y*TheMap.Width].Flags|=j;
+               }
+               return 0;
        }
     } else switch( type->UnitType ) {
        case UnitTypeLand:
@@ -2616,18 +2559,18 @@
 }
 
 /*----------------------------------------------------------------------------
---     Finding units
-----------------------------------------------------------------------------*/
+  --   Finding units
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Find the nearest gold mine for unit from x,y.
-**
-**     @param unit     Pointer for source unit.
-**     @param x        X tile position to start.
-**     @param y        Y tile position to start.
-**
-**     @return         Pointer to the nearest gold mine.
-*/
+ **    Find the nearest gold mine for unit from x,y.
+ **
+ **    @param unit     Pointer for source unit.
+ **    @param x        X tile position to start.
+ **    @param y        Y tile position to start.
+ **
+ **    @return         Pointer to the nearest gold mine.
+ */
 global Unit* FindGoldMine(const Unit* unit,int x,int y)
 {
     static const int xoffset[]={  0,-1,+1, 0, -1,+1,-1,+1 };
@@ -2802,14 +2745,14 @@
 
 #if 0
 /**
-**     Find wood in sight range.
-**
-**     @param unit     Unit that needs wood.
-**     @param px       OUT: Map X position of wood.
-**     @param py       OUT: Map Y position of wood.
-**
-**     @return         True if wood was found.
-*/
+ **    Find wood in sight range.
+ **
+ **    @param unit     Unit that needs wood.
+ **    @param px       OUT: Map X position of wood.
+ **    @param py       OUT: Map Y position of wood.
+ **
+ **    @return         True if wood was found.
+ */
 global int FindWoodInSight(Unit* unit,int* px,int* py)
 {
     int x;
@@ -2913,14 +2856,14 @@
 #else
 
 /**
-**     Find wood in sight range.
-**
-**     @param unit     Unit that needs wood.
-**     @param px       OUT: Map X position of wood.
-**     @param py       OUT: Map Y position of wood.
-**
-**     @return         True if wood was found.
-*/
+ **    Find wood in sight range.
+ **
+ **    @param unit     Unit that needs wood.
+ **    @param px       OUT: Map X position of wood.
+ **    @param py       OUT: Map Y position of wood.
+ **
+ **    @return         True if wood was found.
+ */
 global int FindWoodInSight(const Unit* unit,int* px,int* py)
 {
     static const int xoffset[]={  0,-1,+1, 0, -1,+1,-1,+1 };
@@ -2954,7 +2897,7 @@
     desty=y=unit->Y;
     size=TheMap.Width*TheMap.Height/4;
     points=malloc(size*sizeof(*points));
-       
+
     //
     // Find the nearest wood depot
     //
@@ -3098,14 +3041,14 @@
 #endif
 
 /**
-**     Find oil platform.
-**
-**     @param player   A deposit owning this player
-**     @param x        Nearest to X position.
-**     @param y        Nearest to Y position.
-**
-**     @return         NoUnitP or oil platform unit
-*/
+ **    Find oil platform.
+ **
+ **    @param player   A deposit owning this player
+ **    @param x        Nearest to X position.
+ **    @param y        Nearest to Y position.
+ **
+ **    @return         NoUnitP or oil platform unit
+ */
 global Unit* FindOilPlatform(const Player* player,int x,int y)
 {
     Unit* unit;
@@ -3131,7 +3074,7 @@
            continue;
        }
        // Want platform
-       if( unit->Type->GivesOil ) {
+       if( unit->Type->GivesResource==OilCost ) {
            d=MapDistanceToUnit(x,y,unit);
            if( d<best_d ) {
                best_d=d;
@@ -3141,25 +3084,25 @@
     }
 
     DebugLevel3Fn("%d %d,%d\n" _C_ best?UnitNumber(best):-1 _C_
-                               best?best->X:-1 _C_ best?best->Y:-1);
+           best?best->X:-1 _C_ best?best->Y:-1);
     /* Oil platforms are our own, they should be known
-    if( LimitSearch && (best_d>TheMap.Width/5 || best_d>TheMap.Height/5) ) {
+       if( LimitSearch && (best_d>TheMap.Width/5 || best_d>TheMap.Height/5) ) {
        return NoUnitP;
-    }
-    */
+       }
+       */
     return best;
 }
 
 /**
-**     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 oyu need the deposit to hold.
-**
-**     @return         NoUnitP or oil deposit unit
-*/
+ **    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 oyu 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;
@@ -3196,18 +3139,18 @@
     }
 
     DebugLevel3Fn("%d %d,%d\n" _C_ best?UnitNumber(best):-1 _C_
-                               best?best->X:-1 _C_ best?best->Y:-1);
+           best?best->X:-1 _C_ best?best->Y:-1);
     return best;
 }
 
 /**
-**     Find the next idle worker
-**
-**     @param player   Player's units to search through
-**     @param last     Previous idle worker selected
-**
-**     @return         NoUnitP or next idle worker
-*/
+ **    Find the next idle worker
+ **
+ **    @param player   Player's units to search through
+ **    @param last     Previous idle worker selected
+ **
+ **    @return         NoUnitP or next idle worker
+ */
 global Unit* FindIdleWorker(const Player* player,const Unit* last)
 {
     Unit* unit;
@@ -3249,26 +3192,26 @@
 }
 
 /*----------------------------------------------------------------------------
---     Select units
-----------------------------------------------------------------------------*/
+  --   Select units
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Unit on map screen.
-**
-**     Select units on screen. (x,y are in pixels relative to map 0,0).
-**
-**     More units on same position.
-**             Cycle through units. ounit is the old one.
-**             First take highest unit.
-**
-**     FIXME: If no unit, we could select near units?
-**
-**     @param ounit    Old selected unit.
-**     @param x        X pixel position.
-**     @param y        Y pixel position.
-**
-**     @return         An unit on X,Y position.
-*/
+ **    Unit on map screen.
+ **
+ **    Select units on screen. (x,y are in pixels relative to map 0,0).
+ **
+ **    More units on same position.
+ **            Cycle through units. ounit is the old one.
+ **            First take highest unit.
+ **
+ **    FIXME: If no unit, we could select near units?
+ **
+ **    @param ounit    Old selected unit.
+ **    @param x        X pixel position.
+ **    @param y        Y pixel position.
+ **
+ **    @return         An unit on X,Y position.
+ */
 global Unit* UnitOnScreen(Unit* ounit,int x,int y)
 {
     Unit** table;
@@ -3335,10 +3278,10 @@
 }
 
 /**
-**     Let an unit die.
-**
-**     @param unit     Unit to be destroyed.
-*/
+ **    Let an unit die.
+ **
+ **    @param unit     Unit to be destroyed.
+ */
 global void LetUnitDie(Unit* unit)
 {
     const UnitType* type;
@@ -3349,10 +3292,8 @@
 
     type=unit->Type;
 
-    //
-    // Oil patch or removed units,  just remove.
-    //
-    if( type->OilPatch || unit->Removed ) {
+    // removed units,  just remove.
+    if( unit->Removed ) {
        RemoveUnit(unit,NULL);
        UnitLost(unit);
        UnitClearOrders(unit);
@@ -3368,9 +3309,9 @@
     if( type->ExplodeWhenKilled ) {
        // FIXME: make it configurable?
        MakeMissile(MissileTypeExplosion
-           ,unit->X*TileSizeX+type->TileWidth*TileSizeX/2
-           ,unit->Y*TileSizeY+type->TileHeight*TileSizeY/2
-           ,0,0);
+               ,unit->X*TileSizeX+type->TileWidth*TileSizeX/2
+               ,unit->Y*TileSizeY+type->TileHeight*TileSizeY/2
+               ,0,0);
        RemoveUnit(unit,NULL);
        UnitLost(unit);
        UnitClearOrders(unit);
@@ -3383,20 +3324,20 @@
     //
     if( type->Building ) {
        MakeMissile(MissileTypeByIdent("missile-explosion")
-           ,unit->X*TileSizeX+type->TileWidth*TileSizeX/2
-           ,unit->Y*TileSizeY+type->TileHeight*TileSizeY/2
-           ,0,0);
+               ,unit->X*TileSizeX+type->TileWidth*TileSizeX/2
+               ,unit->Y*TileSizeY+type->TileHeight*TileSizeY/2
+               ,0,0);
 
        //
        //      Building with units inside?
        //
        //
-       //      During oil platform build, the worker holds the oil value,
+       //      During resource build, the worker holds the resource amount,
        //      but if canceling building the platform, the worker is already
        //      outside.
-       if( type->GivesOil
-                   && unit->Orders[0].Action==UnitActionBuilded
-                   && unit->Data.Builded.Worker ) {
+       if( type->GivesResource
+               && unit->Orders[0].Action==UnitActionBuilded
+               && unit->Data.Builded.Worker ) {
            // Restore value for oil-patch
            unit->Value=unit->Data.Builded.Worker->Value;
        }
@@ -3445,7 +3386,7 @@
 
     // FIXME: units in transporters should die without corpes...
     if( unit->Type->Transporter ) { // Transporters loose their units
-        //FIXME: vladi: it could be usefull if transport is near land
+       //FIXME: vladi: it could be usefull if transport is near land
        //       to unload instead of destroying all units in it... ?
        DestroyAllInside(unit);
     }
@@ -3485,36 +3426,36 @@
 }
 
 /**
-**     Destroy all units inside unit.
-*/
+ **    Destroy all units inside unit.
+ */
 global void DestroyAllInside(Unit* source)
 {
     Unit* unit;
     int i;
 
-    // FIXME: n0b0dy: No corpses, is that corrent behaviour?
+    // FIXME: n0b0dy: No corpses, is that correct behaviour?
     unit=source->UnitInside;
     for( i=source->InsideCount; i; --i,unit=unit->NextContained ) {
-       RemoveUnit(unit,NULL);
-       UnitLost(unit);
+       RemoveUnit(unit,NULL);
+       UnitLost(unit);
        UnitClearOrders(unit);
        ReleaseUnit(unit);
     }
-    
+
 }
 
 
 /*----------------------------------------------------------------------------
---     Unit AI
-----------------------------------------------------------------------------*/
+  --   Unit AI
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Unit is hit by missile or other damage.
-**
-**     @param attacker Unit that attacks.
-**     @param target   Unit that is hit.
-**     @param damage   How many damage to take.
-*/
+ **    Unit is hit by missile or other damage.
+ **
+ **    @param attacker Unit that attacks.
+ **    @param target   Unit that is hit.
+ **    @param damage   How many damage to take.
+ */
 global void HitUnit(Unit* attacker,Unit* target,int damage)
 {
     UnitType* type;
@@ -3562,7 +3503,7 @@
            if( LastCycle<GameCycle ) {
                if( LastCycle+CYCLES_PER_SECOND*120<GameCycle ||
                        target->X<LastX-14 || target->X>LastX+14
-                           || target->Y<LastY-14 || target->Y>LastY+14  ) {
+                       || target->Y<LastY-14 || target->Y>LastY+14  ) {
                    LastCycle=GameCycle+CYCLES_PER_SECOND*2;
                    LastX=target->X;
                    LastY=target->Y;
@@ -3617,11 +3558,11 @@
 
     if( UnitVisibleOnMap(target) || ReplayRevealMap ) {
        MakeLocalMissile(MissileTypeHit,
-           target->X*TileSizeX+target->Type->TileWidth*TileSizeX/2,
-           target->Y*TileSizeY+target->Type->TileHeight*TileSizeY/2,
-           target->X*TileSizeX+target->Type->TileWidth*TileSizeX/2+3,
-           target->Y*TileSizeY+target->Type->TileHeight*TileSizeY/2
-                   -MissileTypeHit->Range)->Damage=-damage;
+               target->X*TileSizeX+target->Type->TileWidth*TileSizeX/2,
+               target->Y*TileSizeY+target->Type->TileHeight*TileSizeY/2,
+               target->X*TileSizeX+target->Type->TileWidth*TileSizeX/2+3,
+               target->Y*TileSizeY+target->Type->TileHeight*TileSizeY/2
+               -MissileTypeHit->Range)->Damage=-damage;
     }
 
 #if 0
@@ -3650,7 +3591,7 @@
            missile=MakeMissile(MissileTypeSmallFire
                    ,target->X*TileSizeX+(type->TileWidth*TileSizeX)/2
                    ,target->Y*TileSizeY+(type->TileHeight*TileSizeY)/2
-                           -TileSizeY
+                   -TileSizeY
                    ,0,0);
            missile->SourceUnit=target;
            target->Burning=1;
@@ -3659,7 +3600,7 @@
            missile=MakeMissile(MissileTypeBigFire
                    ,target->X*TileSizeX+(type->TileWidth*TileSizeX)/2
                    ,target->Y*TileSizeY+(type->TileHeight*TileSizeY)/2
-                           -TileSizeY
+                   -TileSizeY
                    ,0,0);
            missile->SourceUnit=target;
            target->Burning=1;
@@ -3706,35 +3647,35 @@
 }
 
 /*----------------------------------------------------------------------------
---     Conflicts
-----------------------------------------------------------------------------*/
+  --   Conflicts
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Returns the map distance between two points.
-**
-**     @param x1       X map tile position.
-**     @param y1       Y map tile position.
-**     @param x2       X map tile position.
-**     @param y2       Y map tile position.
-**
-**     @return         The distance between in tiles.
-*/
+ **    Returns the map distance between two points.
+ **
+ **    @param x1       X map tile position.
+ **    @param y1       Y map tile position.
+ **    @param x2       X map tile position.
+ **    @param y2       Y map tile position.
+ **
+ **    @return         The distance between in tiles.
+ */
 global int MapDistance(int x1,int y1,int x2,int y2)
 {
     return max(abs(x1-x2),abs(y1-y2));
 }
 
 /**
-**     Returns the map distance between two points with unit type.
-**
-**     @param x1       X map tile position.
-**     @param y1       Y map tile position.
-**     @param type     Unit type to take into account.
-**     @param x2       X map tile position.
-**     @param y2       Y map tile position.
-**
-**     @return         The distance between in tiles.
-*/
+ **    Returns the map distance between two points with unit type.
+ **
+ **    @param x1       X map tile position.
+ **    @param y1       Y map tile position.
+ **    @param type     Unit type to take into account.
+ **    @param x2       X map tile position.
+ **    @param y2       Y map tile position.
+ **
+ **    @return         The distance between in tiles.
+ */
 global int MapDistanceToType(int x1,int y1,const UnitType* type,int x2,int y2)
 {
     int dx;
@@ -3765,27 +3706,27 @@
 }
 
 /**
-**     Returns the map distance to unit.
-**
-**     @param x        X map tile position.
-**     @param y        Y map tile position.
-**     @param dest     Distance to this unit.
-**
-**     @return         The distance between in tiles.
-*/
+ **    Returns the map distance to unit.
+ **
+ **    @param x        X map tile position.
+ **    @param y        Y map tile position.
+ **    @param dest     Distance to this unit.
+ **
+ **    @return         The distance between in tiles.
+ */
 global int MapDistanceToUnit(int x,int y,const Unit* dest)
 {
     return MapDistanceToType(x,y,dest->Type,dest->X,dest->Y);
 }
 
 /**
-**     Returns the map distance between two units.
-**
-**     @param src      Distance from this unit.
-**     @param dst      Distance  to  this unit.
-**
-**     @return         The distance between in tiles.
-*/
+ **    Returns the map distance between two units.
+ **
+ **    @param src      Distance from this unit.
+ **    @param dst      Distance  to  this unit.
+ **
+ **    @return         The distance between in tiles.
+ */
 global int MapDistanceBetweenUnits(const Unit* src,const Unit* dst)
 {
     int dx;
@@ -3825,14 +3766,14 @@
 }
 
 /**
-**     Compute the distance from the view point to a given point.
-**
-**     @param x        X map tile position.
-**     @param y        Y map tile position.
-**
-**     @todo
-**             FIXME: is it the correct place to put this function in?
-*/
+ **    Compute the distance from the view point to a given point.
+ **
+ **    @param x        X map tile position.
+ **    @param y        Y map tile position.
+ **
+ **    @todo
+ **            FIXME: is it the correct place to put this function in?
+ */
 global int ViewPointDistance(int x, int y)
 {
     const Viewport *vp;
@@ -3842,17 +3783,17 @@
 
     // then use MapDistance
     return MapDistance(vp->MapX + vp->MapWidth / 2,
-       vp->MapY + vp->MapHeight / 2, x, y);
+           vp->MapY + vp->MapHeight / 2, x, y);
 }
 
 /**
-**     Compute the distance from the view point to a given unit.
-**
-**     @param dest     Distance to this unit.
-**
-**     @todo
-**             FIXME: is it the correct place to put this function in?
-*/
+ **    Compute the distance from the view point to a given unit.
+ **
+ **    @param dest     Distance to this unit.
+ **
+ **    @todo
+ **            FIXME: is it the correct place to put this function in?
+ */
 global int ViewPointDistanceToUnit(const Unit* dest)
 {
     const Viewport* vp;
@@ -3865,52 +3806,52 @@
 }
 
 /**
-**     Check if unit is an enemy.
-**
-**     @param player   The source player.
-**     @param dest     The destination unit.
-**
-**     @return         Returns true, if the destination unit is an enemy.
-*/
+ **    Check if unit is an enemy.
+ **
+ **    @param player   The source player.
+ **    @param dest     The destination unit.
+ **
+ **    @return         Returns true, if the destination unit is an enemy.
+ */
 global int IsEnemy(const Player* player,const Unit* dest)
 {
     return player->Enemy&(1<<dest->Player->Player);
 }
 
 /**
-**     Check if unit is allied.
-**
-**     @param player   The source player.
-**     @param dest     The destination unit.
-**
-**     @return         Returns true, if the destination unit is allied.
-*/
+ **    Check if unit is allied.
+ **
+ **    @param player   The source player.
+ **    @param dest     The destination unit.
+ **
+ **    @return         Returns true, if the destination unit is allied.
+ */
 global int IsAllied(const Player* player,const Unit* dest)
 {
     return player->Allied&(1<<dest->Player->Player);
 }
 
 /**
-**     Check if unit is shared vision.
-**
-**     @param player   The source player.
-**     @param dest     The destination unit.
-**
-**     @return         Returns true, if the destination unit is shared
-**                     vision.
-*/
+ **    Check if unit is shared vision.
+ **
+ **    @param player   The source player.
+ **    @param dest     The destination unit.
+ **
+ **    @return         Returns true, if the destination unit is shared
+ **                    vision.
+ */
 global int IsSharedVision(const Player* player,const Unit* dest)
 {
     return (player->SharedVision&(1<<dest->Player->Player)) &&
-          (dest->Player->SharedVision&(1<<player->Player));
+       (dest->Player->SharedVision&(1<<player->Player));
 }
 
 /**
-**     Can the source unit attack the destination unit.
-**
-**     @param source   Unit type pointer of the attacker.
-**     @param dest     Unit type pointer of the target.
-*/
+ **    Can the source unit attack the destination unit.
+ **
+ **    @param source   Unit type pointer of the attacker.
+ **    @param dest     Unit type pointer of the target.
+ */
 global int CanTarget(const UnitType* source,const UnitType* dest)
 {
     if( dest->UnitType==UnitTypeLand ) {
@@ -3929,12 +3870,12 @@
 }
 
 /*----------------------------------------------------------------------------
---     SAVE/LOAD
-----------------------------------------------------------------------------*/
+  --   SAVE/LOAD
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Generate a unit reference, a printable unique string for unit.
-*/
+ **    Generate a unit reference, a printable unique string for unit.
+ */
 global char* UnitReference(const Unit* unit)
 {
     char* ref;
@@ -3945,11 +3886,11 @@
 }
 
 /**
-**     Save an order.
-**
-**     @param order    Order who should be saved.
-**     @param file     Output file.
-*/
+ **    Save an order.
+ **
+ **    @param order    Order who should be saved.
+ **    @param file     Output file.
+ */
 local void SaveOrder(const Order* order,FILE* file)
 {
     char* ref;
@@ -4085,11 +4026,11 @@
 }
 
 /**
-**     Save the state of an unit to file.
-**
-**     @param unit     Unit pointer to be saved.
-**     @param file     Output file.
-*/
+ **    Save the state of an unit to file.
+ **
+ **    @param unit     Unit pointer to be saved.
+ **    @param file     Output file.
+ */
 global void SaveUnit(const Unit* unit,FILE* file)
 {
     char* ref;
@@ -4103,7 +4044,7 @@
     if( unit->SeenType ) {
        fprintf(file,"'seen-type '%s ",unit->SeenType->Ident);
     }
-    
+
     fprintf(file,"'player %d\n  ",unit->Player->Player);
 
     if( unit->Name ) {
@@ -4243,34 +4184,34 @@
     switch( unit->Orders[0].Action ) {
        case UnitActionStill:
            // FIXME: support other resource types
-           if( unit->Type->GoldMine || unit->Type->GivesOil ) {
+           if( unit->Type->GivesResource ) {
                fprintf(file," 'resource-active %d",unit->Data.Resource.Active);
            }
            break;
        case UnitActionBuilded:
-       {
-           ConstructionFrame* cframe;
-           int frame;
-
-           cframe=unit->Type->Construction->Frames;
-           frame=0;
-           while( cframe!=unit->Data.Builded.Frame ) {
-               cframe=cframe->Next;
-               ++frame;
-           }
-           fprintf(file,"\n  'data-builded '(worker %s",
-                   ref=UnitReference(unit->Data.Builded.Worker));
-           free(ref);
-           fprintf(file," sum %d add %d val %d sub %d frame %d",
-                   unit->Data.Builded.Sum,unit->Data.Builded.Add,
-                   unit->Data.Builded.Val,unit->Data.Builded.Sub,
-                   frame);
-           if( unit->Data.Builded.Cancel ) {
-               fprintf(file," cancel");
+           {
+               ConstructionFrame* cframe;
+               int frame;
+
+               cframe=unit->Type->Construction->Frames;
+               frame=0;
+               while( cframe!=unit->Data.Builded.Frame ) {
+                   cframe=cframe->Next;
+                   ++frame;
+               }
+               fprintf(file,"\n  'data-builded '(worker %s",
+                       ref=UnitReference(unit->Data.Builded.Worker));
+               free(ref);
+               fprintf(file," sum %d add %d val %d sub %d frame %d",
+                       unit->Data.Builded.Sum,unit->Data.Builded.Add,
+                       unit->Data.Builded.Val,unit->Data.Builded.Sub,
+                       frame);
+               if( unit->Data.Builded.Cancel ) {
+                   fprintf(file," cancel");
+               }
+               fprintf(file,")");
+               break;
            }
-           fprintf(file,")");
-           break;
-       }
        case UnitActionResearch:
            fprintf(file,"\n  'data-research '(");
            fprintf(file,"ident %s", unit->Data.Research.Upgrade->Ident);
@@ -4323,10 +4264,10 @@
 }
 
 /**
-**     Save state of units to file.
-**
-**     @param file     Output file.
-*/
+ **    Save state of units to file.
+ **
+ **    @param file     Output file.
+ */
 global void SaveUnits(FILE* file)
 {
     Unit** table;
@@ -4335,7 +4276,7 @@
     int InRun, RunStart;
 
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: units $Id: unit.c,v 1.278 2003/07/12 14:09:17 
n0body Exp $\n\n");
+    fprintf(file,";;; MODULE: units $Id: unit.c,v 1.279 2003/07/22 14:32:21 
n0body Exp $\n\n");
 
     //
     // Local variables
@@ -4392,19 +4333,19 @@
 }
 
 /*----------------------------------------------------------------------------
---     Initialize/Cleanup
-----------------------------------------------------------------------------*/
+  --   Initialize/Cleanup
+  
----------------------------------------------------------------------------*/
 
 /**
-**     Initialize unit module.
-*/
+ **    Initialize unit module.
+ */
 global void InitUnits(void)
 {
 }
 
 /**
-**     Cleanup unit module.
-*/
+ **    Cleanup unit module.
+ */
 global void CleanUnits(void)
 {
     Unit** table;
Index: stratagus/src/clone/unit_draw.c
diff -u stratagus/src/clone/unit_draw.c:1.144 
stratagus/src/clone/unit_draw.c:1.145
--- stratagus/src/clone/unit_draw.c:1.144       Fri Jul 18 16:26:20 2003
+++ stratagus/src/clone/unit_draw.c     Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit_draw.c,v 1.144 2003/07/18 20:26:20 grumbel Exp $
+//     $Id: unit_draw.c,v 1.145 2003/07/22 14:32:21 n0body Exp $
 
 //@{
 
@@ -649,7 +649,7 @@
 global void SaveDecorations(FILE* file)
 {
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: decorations $Id: unit_draw.c,v 1.144 2003/07/18 
20:26:20 grumbel Exp $\n\n");
+    fprintf(file,";;; MODULE: decorations $Id: unit_draw.c,v 1.145 2003/07/22 
14:32:21 n0body Exp $\n\n");
 
     fprintf(file,"(mana-sprite \"%s\"  %d %d  %d %d)\n",
        ManaSprite.File,ManaSprite.HotX,ManaSprite.HotY,
@@ -992,7 +992,7 @@
            // s0m3body: mana bar should display mana proportionally
            //          to unit's max mana (unit->Type->_MaxMana)
            DrawManaBar(x,y,type,unit->Type->_MaxMana,unit->Mana);
-       } else if( type->GivesOil || type->GoldMine || type->OilPatch ) {
+       } else if( type->GivesResource ) {
            DrawManaBar(x,y,type,655350,unit->Value);
        }
        //
@@ -1060,7 +1060,7 @@
        if( type->CanCastSpell
                && !(ShowNoFull && unit->Mana==unit->Type->_MaxMana) ) {
            DrawManaSprite(x,y,type,unit->Type->_MaxMana,unit->Mana);
-       } else if( type->GivesOil || type->GoldMine || type->OilPatch ) {
+       } else if( type->GivesResource ) {
            DrawManaSprite(x,y,type,655350,unit->Value);
        }
        //
Index: stratagus/src/clone/unit_find.c
diff -u stratagus/src/clone/unit_find.c:1.49 
stratagus/src/clone/unit_find.c:1.50
--- stratagus/src/clone/unit_find.c:1.49        Sat Jul 12 10:09:17 2003
+++ stratagus/src/clone/unit_find.c     Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit_find.c,v 1.49 2003/07/12 14:09:17 n0body Exp $
+//     $Id: unit_find.c,v 1.50 2003/07/22 14:32:21 n0body Exp $
 
 //@{
 
@@ -498,7 +498,30 @@
        if( UnitUnusable(table[i]) ) {
            continue;
        }
-       if( table[i]->Type->GoldMine ) {
+       if( table[i]->Type->GivesResource==GoldCost ) {
+           return table[i];
+       }
+    }
+    return NoUnitP;
+}
+
+/**
+**     Find a unit on a map tile with a specific type
+**
+**     @param tx       X position on map, tile-based.
+**     @param ty       Y position on map, tile-based.
+**
+**     @return         Returns the unit if found, or NoUnitP.
+*/
+global Unit* UnitTypeOnMap(int tx,int ty,UnitType* type)
+{
+    Unit* table[UnitMax];
+    int i;
+    int n;
+    
+    n=SelectUnitsOnTile(tx,ty,table);
+    for( i=0; i<n; ++i ) {
+       if( table[i]->Type==type ) {
            return table[i];
        }
     }
@@ -521,7 +544,7 @@
 
     n=SelectUnitsOnTile(tx,ty,table);
     for( i=0; i<n; ++i ) {
-       if( table[i]->Type->OilPatch ) {
+       if( table[i]->Type->GivesResource==OilCost ) {
            return table[i];
        }
     }
@@ -547,7 +570,7 @@
        if( UnitUnusable(table[i]) ) {
            continue;
        }
-       if( table[i]->Type->GivesOil ) {
+       if( table[i]->Type->GivesResource==OilCost ) {
            return table[i];
        }
     }
Index: stratagus/src/editor/editloop.c
diff -u stratagus/src/editor/editloop.c:1.122 
stratagus/src/editor/editloop.c:1.123
--- stratagus/src/editor/editloop.c:1.122       Fri Jul 11 10:35:30 2003
+++ stratagus/src/editor/editloop.c     Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: editloop.c,v 1.122 2003/07/11 14:35:30 n0body Exp $
+//     $Id: editloop.c,v 1.123 2003/07/22 14:32:21 n0body Exp $
 
 //@{
 
@@ -288,10 +288,10 @@
 
     //FXIME: vladi: should check place when mirror editing is enabled...?
     unit = MakeUnitAndPlace(x, y, type, player);
-    if (type->OilPatch || type->GivesOil) {
+    if (type->GivesResource==OilCost) {
        unit->Value = 50000;
     }
-    if (unit->Type->GoldMine) {
+    if (type->GivesResource==GoldCost) {
        unit->Value = 100000;
     }
 }
@@ -879,8 +879,7 @@
     i = sprintf(buf, "#%d '%s' Player:#%d %s", UnitNumber(unit),
        unit->Type->Name, unit->Player->Player,
        unit->Active ? "active" : "passive");
-    if (unit->Type->OilPatch || unit->Type->GivesOil
-           || unit->Type->GoldMine) {
+    if (unit->Type->GivesResource) {
        sprintf(buf+i," Amount %d",unit->Value);
     }
     SetStatusLine(buf);
@@ -1208,9 +1207,7 @@
     //
     if (EditorState == EditorSelecting) {
        if ((MouseButtons&RightButton && UnitUnderCursor)) {
-           if (UnitUnderCursor->Type->GoldMine ||
-               UnitUnderCursor->Type->OilPatch ||
-               UnitUnderCursor->Type->GivesOil) {
+           if (UnitUnderCursor->Type->GivesResource) {
                EditorEditResource();
                return;
            }
Index: stratagus/src/include/stratagus.h
diff -u stratagus/src/include/stratagus.h:1.7 
stratagus/src/include/stratagus.h:1.8
--- stratagus/src/include/stratagus.h:1.7       Fri Jul 18 16:26:20 2003
+++ stratagus/src/include/stratagus.h   Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: stratagus.h,v 1.7 2003/07/18 20:26:20 grumbel Exp $
+//     $Id: stratagus.h,v 1.8 2003/07/22 14:32:21 n0body Exp $
 
 #ifndef __STRATAGUS_H__
 #define __STRATAGUS_H__
@@ -338,7 +338,7 @@
 
 #define TilesetMax     8               /// How many tilesets are supported
 #define PlayerMax      16              /// How many players are supported
-#define UnitTypeMax    0xFF            /// How many unit types supported
+#define UnitTypeMax    257             /// How many unit types supported
 #define UpgradeMax     256             /// How many upgrades supported
 #define UnitMax                2048            /// How many units supported
 
@@ -531,9 +531,9 @@
     // FIXME: more config stuff which needs a better place
 
     /// How long stay in a gold-mine
-#define MINE_FOR_GOLD  
(UnitTypeGoldMine->_Costs[TimeCost]/SpeedResourcesHarvest[GoldCost])
+#define MINE_FOR_GOLD  (150/SpeedResourcesHarvest[GoldCost])
     /// How long stay in a gold-deposit
-#define WAIT_FOR_GOLD  
(UnitTypeGoldMine->_Costs[TimeCost]/SpeedResourcesReturn[GoldCost])
+#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
@@ -552,10 +552,8 @@
     /// How many resource get the player back if canceling upgrade
 #define CancelUpgradeCostsFactor       100
 
-    /// How near could a hall or gold-depot be build to a goldmine
-#define GOLDMINE_DISTANCE      3
-    /// How near could a oil-depot be build to a oil-patch
-#define OILPATCH_DISTANCE      3
+    /// How near could a depot be build to a resource
+#define RESOURCE_DISTANCE      3
 
     /// How near we could repair an unit
 #define REPAIR_RANGE           1
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.197 stratagus/src/include/unit.h:1.198
--- stratagus/src/include/unit.h:1.197  Fri Jul 11 10:35:30 2003
+++ stratagus/src/include/unit.h        Tue Jul 22 10:32:21 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.h,v 1.197 2003/07/11 14:35:30 n0body Exp $
+//     $Id: unit.h,v 1.198 2003/07/22 14:32:21 n0body Exp $
 
 #ifndef __UNIT_H__
 #define __UNIT_H__
@@ -993,6 +993,8 @@
     /// Return transporter unit on that screen map position
 extern Unit* TransporterOnScreenMapPosition (int , int );
 
+    /// Return unit of a fixed type on a map tile.
+extern Unit* UnitTypeOnMap(int tx,int ty,UnitType* type);
     /// Return gold mine, if on map tile
 extern Unit* GoldMineOnMap(int tx,int ty);
     /// Return oil patch, if on map tile
Index: stratagus/src/include/unittype.h
diff -u stratagus/src/include/unittype.h:1.89 
stratagus/src/include/unittype.h:1.90
--- stratagus/src/include/unittype.h:1.89       Sat Jul 12 10:09:17 2003
+++ stratagus/src/include/unittype.h    Tue Jul 22 10:32:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unittype.h,v 1.89 2003/07/12 14:09:17 n0body Exp $
+//     $Id: unittype.h,v 1.90 2003/07/22 14:32:22 n0body Exp $
 
 #ifndef __UNITTYPE_H__
 #define __UNITTYPE_H__
@@ -496,8 +496,6 @@
 
     /// Base structure of unit-type
 struct _unit_type_ {
-    const void*        OType;                  /// Object type (future 
extensions)
-
     char*      Ident;                  /// Identifier
     char*      Name;                   /// Pretty name shown from the engine
     char*      SameSprite;             /// Unit-type shared sprites
@@ -582,8 +580,6 @@
     unsigned Tanker : 1;               /// FIXME: used? Can transport oil
     unsigned Transporter : 1;          /// Can transport units
     unsigned MaxOnBoard;               /// Number of Transporter slots.
-    unsigned GivesOil : 1;             /// We get here oil
-    unsigned CanStore[MaxCosts];               /// Resources that we can store 
here.
     unsigned Vanishes : 1;             /// Corpes & destroyed places
     unsigned GroundAttack : 1;         /// Can do command ground attack
     unsigned IsUndead : 1;             /// Unit is already dead
@@ -591,12 +587,14 @@
     unsigned CanCastSpell : 1;         /// Unit is able to use spells
     unsigned CanAttack : 1;            /// Unit can attack
     unsigned Tower : 1;                        /// Unit can attack, but not 
move
-    unsigned OilPatch : 1;             /// Platform can be build here
-    unsigned GoldMine : 1;             /// Gold can be collected here
     unsigned Hero : 1;                 /// Is hero only used for triggers 
     unsigned Volatile : 1;             /// Invisiblity/unholy armor kills unit
     unsigned CowerMage : 1;            /// FIXME: docu
     unsigned Organic : 1;              /// Organic can be healed
+    
+    unsigned CanStore[MaxCosts];       /// Resources that we can store here.
+    unsigned GivesResource;            /// The resource this unit gives.
+    UnitType* MustBuildOnTop;          /// Must be built on top of something
 
     unsigned SelectableByRectangle : 1;        /// Selectable with mouse 
rectangle
     unsigned Teleporter : 1;           /// Can teleport other units.
@@ -632,33 +630,30 @@
 
     // FIXME: ARI: should be dynamic (ccl..), JOHNS: Pud only supports 255.
     /// How many unit-types are currently supported
-#define UnitTypeMax    0xFF
+#define UnitTypeMax    257
 
 /*----------------------------------------------------------------------------
 --     Variables
 ----------------------------------------------------------------------------*/
 
-extern const char UnitTypeType[];      /// Unit-type type
-extern UnitType* UnitTypes;            /// All unit-types
-extern int NumUnitTypes;               /// Number of unit-types made
+extern UnitType* UnitTypes[UnitTypeMax];       /// All unit-types
+extern int NumUnitTypes;                       /// Number of unit-types made
 
 // FIXME: this hardcoded unit-types must be removed!!
-extern UnitType*UnitTypeOilPatch;      /// Oil patch unit-type pointer
-extern UnitType*UnitTypeGoldMine;      /// Gold-mine unit-type pointer
-extern UnitType*UnitTypeHumanTanker;   /// Orc tanker unit-type pointer
-extern UnitType*UnitTypeOrcTanker;     /// Human tanker unit-type pointer
-extern UnitType*UnitTypeHumanTankerFull;/// Orc tanker full unit-type pointer
-extern UnitType*UnitTypeOrcTankerFull; /// Human tanker full unit-type pointer
-extern UnitType*UnitTypeHumanWorker;   /// Human worker
-extern UnitType*UnitTypeOrcWorker;     /// Orc worker
+extern UnitType*UnitTypeHumanTanker;           /// Orc tanker unit-type pointer
+extern UnitType*UnitTypeOrcTanker;             /// Human tanker unit-type 
pointer
+extern UnitType*UnitTypeHumanTankerFull;       /// Orc tanker full unit-type 
pointer
+extern UnitType*UnitTypeOrcTankerFull;         /// Human tanker full unit-type 
pointer
+extern UnitType*UnitTypeHumanWorker;           /// Human worker
+extern UnitType*UnitTypeOrcWorker;             /// Orc worker
 extern UnitType*UnitTypeHumanWorkerWithGold;   /// Human worker with gold
 extern UnitType*UnitTypeOrcWorkerWithGold;     /// Orc worker with gold
 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
-extern UnitType*UnitTypeBerserker;     /// Berserker for berserker regeneration
+extern UnitType*UnitTypeHumanWall;             /// Human wall
+extern UnitType*UnitTypeOrcWall;               /// Orc wall
+extern UnitType*UnitTypeCritter;               /// Critter unit-type pointer
+extern UnitType*UnitTypeBerserker;             /// Berserker for berserker 
regeneration
 
 extern char** UnitTypeWcNames;         /// Mapping wc-number 2 symbol
 
Index: stratagus/src/map/minimap.c
diff -u stratagus/src/map/minimap.c:1.58 stratagus/src/map/minimap.c:1.59
--- stratagus/src/map/minimap.c:1.58    Fri Jul 11 10:35:32 2003
+++ stratagus/src/map/minimap.c Tue Jul 22 10:32:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: minimap.c,v 1.58 2003/07/11 14:35:32 n0body Exp $
+//     $Id: minimap.c,v 1.59 2003/07/22 14:32:22 n0body Exp $
 
 //@{
 
@@ -356,7 +356,7 @@
        if( unit->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.60 
stratagus/src/network/commands.c:1.61
--- stratagus/src/network/commands.c:1.60       Fri Jul 11 10:35:33 2003
+++ stratagus/src/network/commands.c    Tue Jul 22 10:32:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: commands.c,v 1.60 2003/07/11 14:35:33 n0body Exp $
+//     $Id: commands.c,v 1.61 2003/07/22 14:32:22 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.60 2003/07/11 
14:35:33 n0body Exp $\"\n");
+       fprintf(LogFile,"  'comment\t\"$Id: commands.c,v 1.61 2003/07/22 
14:32:22 n0body Exp $\"\n");
        if( NetworkFildes==-1 ) {
            fprintf(LogFile,"  'type\t\"%s\"\n","single-player");
            fprintf(LogFile,"  'race\t%d\n",GameSettings.Presets[0].Race);
@@ -1313,9 +1313,9 @@
            CommandUnload(unit,x,y,dest,status);
            break;
        case MessageCommandBuild:
-           CommandLog("build",unit,status,x,y,NoUnitP,UnitTypes[dstnr].Ident,
+           CommandLog("build",unit,status,x,y,NoUnitP,UnitTypes[dstnr]->Ident,
                    -1);
-           CommandBuildBuilding(unit,x,y,UnitTypes+dstnr,status);
+           CommandBuildBuilding(unit,x,y,UnitTypes[dstnr],status);
            break;
        case MessageCommandCancelBuild:
            // dest is the worker building the unit...
@@ -1360,15 +1360,15 @@
            break;
        case MessageCommandTrain:
            CommandLog("train",unit,status,-1,-1,NoUnitP
-                   ,UnitTypes[dstnr].Ident,-1);
-           CommandTrainUnit(unit,UnitTypes+dstnr,status);
+                   ,UnitTypes[dstnr]->Ident,-1);
+           CommandTrainUnit(unit,UnitTypes[dstnr],status);
            break;
        case MessageCommandCancelTrain:
            // We need (short)x for the last slot -1
            if( dstnr!=(unsigned short)0xFFFF ) {
                CommandLog("cancel-train",unit,FlushCommands,-1,-1,NoUnitP,
-                       UnitTypes[dstnr].Ident,(short)x);
-               CommandCancelTraining(unit,(short)x,UnitTypes+dstnr);
+                       UnitTypes[dstnr]->Ident,(short)x);
+               CommandCancelTraining(unit,(short)x,UnitTypes[dstnr]);
            } else {
                CommandLog("cancel-train",unit,FlushCommands,-1,-1,NoUnitP,
                        NULL,(short)x);
@@ -1377,8 +1377,8 @@
            break;
        case MessageCommandUpgrade:
            CommandLog("upgrade-to",unit,status,-1,-1,NoUnitP
-                   ,UnitTypes[dstnr].Ident,-1);
-           CommandUpgradeTo(unit,UnitTypes+dstnr,status);
+                   ,UnitTypes[dstnr]->Ident,-1);
+           CommandUpgradeTo(unit,UnitTypes[dstnr],status);
            break;
        case MessageCommandCancelUpgrade:
            CommandLog("cancel-upgrade-to",unit,FlushCommands,-1,-1,NoUnitP
Index: stratagus/src/ui/botpanel.c
diff -u stratagus/src/ui/botpanel.c:1.79 stratagus/src/ui/botpanel.c:1.80
--- stratagus/src/ui/botpanel.c:1.79    Fri Jul 11 10:35:33 2003
+++ stratagus/src/ui/botpanel.c Tue Jul 22 10:32:22 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: botpanel.c,v 1.79 2003/07/11 14:35:33 n0body Exp $
+//     $Id: botpanel.c,v 1.80 2003/07/22 14:32:22 n0body Exp $
 
 //@{
 
@@ -104,7 +104,7 @@
     char* cp;
 
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: buttons $Id: botpanel.c,v 1.79 2003/07/11 
14:35:33 n0body Exp $\n\n");
+    fprintf(file,";;; MODULE: buttons $Id: botpanel.c,v 1.80 2003/07/22 
14:32:22 n0body Exp $\n\n");
 
     for( i=0; i<NumUnitButtons; ++i ) {
        fprintf(file,"(define-button 'pos %d 'level %d 'icon '%s\n",
@@ -517,7 +517,7 @@
                    case ButtonTrain:
                    case ButtonUpgradeTo:
                        // FIXME: store pointer in button table!
-                       stats=&UnitTypes[v].Stats[ThisPlayer->Player];
+                       stats=&UnitTypes[v]->Stats[ThisPlayer->Player];
                        DebugLevel3("Upgrade to %s %d %d %d %d %d\n"
                                _C_ UnitTypes[v].Ident
                                _C_ UnitTypes[v].Demand
@@ -526,7 +526,7 @@
                                _C_ stats->Costs[GoldCost]
                                _C_ stats->Costs[WoodCost]);
 
-                       SetCosts(0,UnitTypes[v].Demand,stats->Costs);
+                       SetCosts(0,UnitTypes[v]->Demand,stats->Costs);
 
                        break;
                    //case ButtonUpgrade:
@@ -1000,7 +1000,7 @@
 
        case ButtonBuild:
            // FIXME: store pointer in button table!
-           type=&UnitTypes[CurrentButtons[button].Value];
+           type=UnitTypes[CurrentButtons[button].Value];
            if( !PlayerCheckUnitType(ThisPlayer,type) ) {
                SetStatusLine("Select Location");
                ClearCosts();
@@ -1014,7 +1014,7 @@
 
        case ButtonTrain:
            // FIXME: store pointer in button table!
-           type=&UnitTypes[CurrentButtons[button].Value];
+           type=UnitTypes[CurrentButtons[button].Value];
            // FIXME: Johns: I want to place commands in queue, even if not
            // FIXME:   enough resources are available.
            // FIXME: training queue full check is not correct for network.
@@ -1036,7 +1036,7 @@
 
        case ButtonUpgradeTo:
            // FIXME: store pointer in button table!
-           type=&UnitTypes[CurrentButtons[button].Value];
+           type=UnitTypes[CurrentButtons[button].Value];
            if( !PlayerCheckUnitType(ThisPlayer,type) ) {
                DebugLevel3("Upgrade to %s %d %d\n"
                        _C_ type->Ident
Index: stratagus/src/ui/mainscr.c
diff -u stratagus/src/ui/mainscr.c:1.112 stratagus/src/ui/mainscr.c:1.113
--- stratagus/src/ui/mainscr.c:1.112    Sat Jul 12 10:09:17 2003
+++ stratagus/src/ui/mainscr.c  Tue Jul 22 10:32:22 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mainscr.c,v 1.112 2003/07/12 14:09:17 n0body Exp $
+//     $Id: mainscr.c,v 1.113 2003/07/22 14:32:22 n0body Exp $
 
 //@{
 
@@ -244,10 +244,10 @@
     //
     // Show for all players.
     //
-    if( type->GoldMine ) {
+    if( type->GivesResource==GoldCost ) {
        VideoDrawText(x+37,y+8+78,GameFont,"Gold Left:");
        if ( !unit->Value ) {
-           VideoDrawText(x+108,y+8+78,GameFont,"(depleted)");
+           VideoDrawText(x+108,y+8+78,GameFont,"(none)");
        } else {
            VideoDrawNumber(x+108,y+8+78,GameFont,unit->Value);
        }
@@ -256,7 +256,7 @@
     // Not our building and not under construction
     if( unit->Player!=ThisPlayer
            || unit->Orders[0].Action!=UnitActionBuilded ) {
-       if( type->GivesOil || type->OilPatch ) {
+       if( type->GivesResource==OilCost ) {
            VideoDrawText(x+47,y+8+78,GameFont,"Oil Left:");
            if ( !unit->Value ) {
                VideoDrawText(x+108,y+8+78,GameFont,"(depleted)");
Index: stratagus/src/ui/menus.c
diff -u stratagus/src/ui/menus.c:1.552 stratagus/src/ui/menus.c:1.553
--- stratagus/src/ui/menus.c:1.552      Fri Jul 11 10:35:33 2003
+++ stratagus/src/ui/menus.c    Tue Jul 22 10:32:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: menus.c,v 1.552 2003/07/11 14:35:33 n0body Exp $
+//     $Id: menus.c,v 1.553 2003/07/22 14:32:22 n0body Exp $
 
 //@{
 
@@ -6012,14 +6012,12 @@
 {
     Menu *menu;
     char buf[13];
+    char buf2[32];
 
     menu = FindMenu("menu-editor-edit-resource");
 
-    if (UnitUnderCursor->Type->GoldMine) {
-       menu->Items[0].d.text.text = "Amount of gold:";
-    } else if (UnitUnderCursor->Type->OilPatch || 
UnitUnderCursor->Type->GivesOil) {
-       menu->Items[0].d.text.text = "Amount of oil:";
-    }
+    sprintf(buf2,"Amount of 
%s:",DefaultResourceNames[UnitUnderCursor->Type->GivesResource]);
+    menu->Items[0].d.text.text = buf2;
     sprintf(buf, "%d~!_", UnitUnderCursor->Value);
     menu->Items[1].d.input.buffer = buf;
     menu->Items[1].d.input.nch = strlen(buf) - 3;
Index: stratagus/src/unit/ccl_unittype.c
diff -u stratagus/src/unit/ccl_unittype.c:1.67 
stratagus/src/unit/ccl_unittype.c:1.68
--- stratagus/src/unit/ccl_unittype.c:1.67      Sat Jul 12 10:09:18 2003
+++ stratagus/src/unit/ccl_unittype.c   Tue Jul 22 10:32:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_unittype.c,v 1.67 2003/07/12 14:09:18 n0body Exp $
+//     $Id: ccl_unittype.c,v 1.68 2003/07/22 14:32:22 n0body Exp $
 
 //@{
 
@@ -77,6 +77,7 @@
     SCM value;
     SCM sublist;
     UnitType* type;
+    UnitType* auxtype;
     char* str;
     int i;
     int redefine;
@@ -90,10 +91,11 @@
     type=UnitTypeByIdent(str);
     IfDebug( NoWarningUnitType=i; );
     if( type ) {
-       DebugLevel0Fn("Redefining unit-type `%s'\n" _C_ str);
+       DebugLevel3Fn("Redefining unit-type `%s'\n" _C_ str);
        free(str);
        redefine = 1;
     } else {
+       DebugLevel3Fn("Defining unit-type `%s'\n" _C_ str);
        type=NewUnitTypeSlot(str);
        redefine = 0;
     }
@@ -243,6 +245,16 @@
            list=gh_cdr(list);
            type->TileWidth=gh_scm2int(gh_car(sublist));
            type->TileHeight=gh_scm2int(gh_cadr(sublist));
+       } else if( gh_eq_p(value,gh_symbol2scm("must-build-on-top")) ){
+           str=gh_scm2newstr(gh_car(list),NULL);
+           auxtype=UnitTypeByIdent(str);
+           if (!auxtype) {
+               DebugLevel0("Build on top of undefined unit \"%s\".\n" _C_ str);
+               exit(0);
+           }
+           type->MustBuildOnTop=auxtype;
+           free(str);
+           list=gh_cdr(list);
        } else if( gh_eq_p(value,gh_symbol2scm("box-size")) ) {
            sublist=gh_car(list);
            list=gh_cdr(list);
@@ -373,7 +385,7 @@
        } else if( gh_eq_p(value,gh_symbol2scm("tanker")) ) {
            type->Tanker=1;
        } else if( gh_eq_p(value,gh_symbol2scm("gives-oil")) ) {
-           type->GivesOil=1;
+           type->GivesResource=OilCost;
        } else if( gh_eq_p(value,gh_symbol2scm("can-store")) ) {
            sublist=gh_car(list);
            list=gh_cdr(list);
@@ -391,9 +403,9 @@
                }
            }
        } else if( gh_eq_p(value,gh_symbol2scm("oil-patch")) ) {
-           type->OilPatch=1;
+           type->GivesResource=OilCost;
        } else if( gh_eq_p(value,gh_symbol2scm("gives-gold")) ) {
-           type->GoldMine=1;
+           type->GivesResource=GoldCost;
        } else if( gh_eq_p(value,gh_symbol2scm("vanishes")) ) {
            type->Vanishes=1;
        } else if( gh_eq_p(value,gh_symbol2scm("tower")) ) {
@@ -501,10 +513,14 @@
     char* str;
 
     type=UnitTypeByIdent(str=gh_scm2newstr(gh_car(list),NULL));
+    DebugCheck(!type);
+    
     free(str);
     list=gh_cdr(list);
     i=gh_scm2int(gh_car(list));
+    DebugCheck(i>=PlayerMax);
     list=gh_cdr(list);
+
     stats=&type->Stats[i];
 
     //
Index: stratagus/src/unit/unittype.c
diff -u stratagus/src/unit/unittype.c:1.77 stratagus/src/unit/unittype.c:1.78
--- stratagus/src/unit/unittype.c:1.77  Sat Jul 12 10:09:18 2003
+++ stratagus/src/unit/unittype.c       Tue Jul 22 10:32:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unittype.c,v 1.77 2003/07/12 14:09:18 n0body Exp $
+//     $Id: unittype.c,v 1.78 2003/07/22 14:32:22 n0body Exp $
 
 //@{
 
@@ -65,33 +65,31 @@
 global const char UnitTypeType[] = "unit-type";
 
 IfDebug(
-global int NoWarningUnitType;          /// quiet ident lookup
+global int NoWarningUnitType;                  /// quiet ident lookup
 );
 
-global UnitType* UnitTypes;            /// unit-types definition
-global int NumUnitTypes;               /// number of unit-types made
+global UnitType* UnitTypes[UnitTypeMax];       /// unit-types definition
+global int NumUnitTypes;                       /// number of unit-types made
 
 /*
 **     Next unit type are used hardcoded in the source.
 **
 **     FIXME: find a way to make it configurable!
 */
-global UnitType*UnitTypeOilPatch;      /// Oil patch for oil patch removement
-global UnitType*UnitTypeGoldMine;      /// Gold mine unit type pointer
-global UnitType*UnitTypeOrcTanker;     /// Orc tanker unit type pointer
-global UnitType*UnitTypeHumanTanker;   /// Human tanker unit type pointer
-global UnitType*UnitTypeOrcTankerFull; /// Orc tanker full unit type pointer
-global UnitType*UnitTypeHumanTankerFull;/// Human tanker full unit type pointer
-global UnitType*UnitTypeHumanWorker;   /// Human worker
-global UnitType*UnitTypeOrcWorker;     /// Orc worker
+global UnitType*UnitTypeOrcTanker;             /// Orc tanker unit type pointer
+global UnitType*UnitTypeHumanTanker;           /// Human tanker unit type 
pointer
+global UnitType*UnitTypeOrcTankerFull;         /// Orc tanker full unit type 
pointer
+global UnitType*UnitTypeHumanTankerFull;       /// Human tanker full unit type 
pointer
+global UnitType*UnitTypeHumanWorker;           /// Human worker
+global UnitType*UnitTypeOrcWorker;             /// Orc worker
 global UnitType*UnitTypeHumanWorkerWithGold;   /// Human worker with gold
 global UnitType*UnitTypeOrcWorkerWithGold;     /// Orc worker with gold
 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
-global UnitType*UnitTypeBerserker;     /// Berserker for berserker regeneration
+global UnitType*UnitTypeHumanWall;             /// Human wall
+global UnitType*UnitTypeOrcWall;               /// Orc wall
+global UnitType*UnitTypeCritter;               /// Critter unit type pointer
+global UnitType*UnitTypeBerserker;             /// Berserker for berserker 
regeneration
 
 /**
 **     Mapping of W*rCr*ft number to our internal unit-type symbol.
@@ -104,14 +102,14 @@
 /**
 **     Lookup table for unit-type names
 */
-local UnitType* UnitTypeHash[61];
+local UnitType* UnitTypeHash[UnitTypeMax];
 
 #else
 
 /**
 **     Lookup table for unit-type names
 */
-local hashtable(UnitType*,61) UnitTypeHash;
+local hashtable(UnitType*,UnitTypeMax) UnitTypeHash;
 
 #endif
 
@@ -164,11 +162,13 @@
     UnitStats* stats;
     unsigned player;
     unsigned i;
+    unsigned j;
 
     //
     //  Update players stats
     //
-    for (type = UnitTypes; type->OType; ++type) {
+    for (j = 0; j<NumUnitTypes; ++j) {
+       type = UnitTypes[j];
         if (reset){
            // LUDO : FIXME : reset loading of player stats !
            for (player = 0; player < PlayerMax; ++player) {
@@ -247,8 +247,6 @@
            //
            if( type->_HitPoints ) {
                type->FieldFlags = MapFieldBuilding;
-           } else if( type->OilPatch ) {
-               type->FieldFlags = 0;
            } else {
                type->FieldFlags = MapFieldNoBuilding;
            }
@@ -461,7 +459,6 @@
        unittype->CowerWorker=BIT(8,v);
        unittype->Tanker=BIT(9,v);
        unittype->Transporter=BIT(10,v);
-       unittype->GivesOil=BIT(11,v);
        unittype->CanStore[GoldCost]=BIT(12,v);
        unittype->Vanishes=BIT(13,v);
        unittype->GroundAttack=BIT(14,v);
@@ -471,13 +468,18 @@
        unittype->CanStore[WoodCost]=BIT(18,v);
        unittype->CanAttack=BIT(19,v);
        unittype->Tower=BIT(20,v);
-       unittype->OilPatch=BIT(21,v);
-       unittype->GoldMine=BIT(22,v);
        unittype->Hero=BIT(23,v);
        unittype->CanStore[OilCost]=BIT(24,v);
        unittype->Volatile=BIT(25,v);
        unittype->CowerMage=BIT(26,v);
        unittype->Organic=BIT(27,v);
+       
+       if (BIT(11,v)||BIT(21,v)) {
+           unittype->GivesResource=OilCost;
+       }
+       if (BIT(22,v)) {
+           unittype->GivesResource=GoldCost;
+       }
 
 #ifdef DEBUG
        if( BIT(28,v) ) DebugLevel0("Unused bit 28 used in %d\n" _C_ i);
@@ -592,9 +594,9 @@
 */
 local void SaveAnimations(const UnitType* type,FILE* file)
 {
-    const UnitType* temp;
     const Animations* anims;
     int i;
+    int q;
 
     if( !(anims=type->Animations) ) {
        return;
@@ -603,8 +605,8 @@
     //
     // Look if this is the first use of it.
     //
-    for( temp=UnitTypes; temp->OType && temp!=type ; ++temp ) {
-       if( temp->Animations==anims ) {
+    for( i=0; i<NumUnitTypes && UnitTypes[i]!=type ; ++i ) {
+       if( UnitTypes[i]->Animations==anims ) {
            return;                     // allready handled.
        }
     }
@@ -613,14 +615,14 @@
     //
     // Print all units that use this animation.
     //
-    i=0;
-    for( temp=UnitTypes; temp->OType; ++temp ) {
-       if( temp->Animations==anims ) {
-           if( i ) {
+    q=0;
+    for( i=0 ; i<NumUnitTypes ; ++i ) {
+       if( UnitTypes[i]->Animations==anims ) {
+           if( q ) {
                fprintf(file,", ");
            }
-           fprintf(file,"%s",temp->Name);
-           i=1;
+           fprintf(file,"%s",UnitTypes[i]->Name);
+           q=1;
        }
     }
     fprintf(file,"\n(define-animations 'animations-%s",type->Ident+5);
@@ -646,7 +648,6 @@
 {
     int i;
     int flag;
-    const UnitType* temp;
 
     fprintf(file,"(define-unit-type '%s",type->Ident);
     fprintf(file," 'name \"%s\"\n  ",type->Name);
@@ -675,13 +676,13 @@
     //
     // Animations are shared, find first use of the unit-type animation.
     //
-    for( temp=UnitTypes; temp->OType && temp!=type ; ++temp ) {
-       if( temp->Animations==type->Animations ) {
+    for( i=0; i<NumUnitTypes && UnitTypes[i]!=type ; ++i ) {
+       if( UnitTypes[i]->Animations==type->Animations ) {
            break;
        }
     }
-    fprintf(file,"  'animations 'animations-%s",temp->Ident+5);
-    fprintf(file," 'icon '%s\n",IdentOfIcon(type->Icon.Icon));
+    fprintf(file,"  'animations 'animations-%s",UnitTypes[i]->Ident+5);
+    fprintf(file,"  'icon '%s\n",IdentOfIcon(type->Icon.Icon));
     for( i=flag=0; i<MaxCosts; ++i ) {
        if( all || type->_Costs[i] ) {
            if( !flag ) {
@@ -709,13 +710,13 @@
        fprintf(file,"  'magic %d\n",type->Magic);
     }
     fprintf(file,"  'tile-size '(%d %d)",type->TileWidth,type->TileHeight);
-    fprintf(file," 'box-size '(%d %d)\n",type->BoxWidth,type->BoxHeight);
+    fprintf(file,"  'box-size '(%d %d)\n",type->BoxWidth,type->BoxHeight);
     fprintf(file,"  'sight-range %d",type->_SightRange);
     if( all || type->ReactRangeComputer ) {
-       fprintf(file," 'computer-reaction-range %d",type->ReactRangeComputer);
+       fprintf(file,"  'computer-reaction-range %d",type->ReactRangeComputer);
     }
     if( all || type->ReactRangePerson ) {
-       fprintf(file," 'person-reaction-range %d",type->ReactRangePerson);
+       fprintf(file,"  'person-reaction-range %d",type->ReactRangePerson);
     }
     fputs("\n",file);
 
@@ -724,13 +725,13 @@
     } else {
        fputs(" ",file);
     }
-    fprintf(file," 'basic-damage %d",type->_BasicDamage);
-    fprintf(file," 'piercing-damage %d",type->_PiercingDamage);
-    fprintf(file," 'missile '%s\n",type->Missile.Name);
-    fprintf(file," 'draw-level %d",type->DrawLevel);
+    fprintf(file,"  'basic-damage %d",type->_BasicDamage);
+    fprintf(file,"  'piercing-damage %d",type->_PiercingDamage);
+    fprintf(file,"  'missile '%s\n",type->Missile.Name);
+    fprintf(file,"  'draw-level %d",type->DrawLevel);
     if( all || type->MinAttackRange ) {
        fprintf(file,"  'min-attack-range %d",type->MinAttackRange);
-       fprintf(file," 'max-attack-range %d\n",type->_AttackRange);
+       fprintf(file,"  'max-attack-range %d\n",type->_AttackRange);
     } else if( type->_AttackRange ) {
        fprintf(file,"  'max-attack-range %d\n",type->_AttackRange);
     }
@@ -746,7 +747,7 @@
     }
     fprintf(file,"  'priority %d",type->Priority);
     if( all || type->AnnoyComputerFactor ) {
-       fprintf(file," 'annoy-computer-factor %d",type->AnnoyComputerFactor);
+       fprintf(file,"  'annoy-computer-factor %d",type->AnnoyComputerFactor);
     }
     fputs("\n",file);
     if( all || type->DecayRate ) {
@@ -876,10 +877,9 @@
     if( type->Tanker ) {
        fprintf(file,"  'tanker\n");
     }
-    if( type->GivesOil ) {
+    if( type->GivesResource==OilCost ) {
        fprintf(file,"  'gives-oil\n");
     }
-
     // Save store info.
     for (flag=i=0;i<MaxCosts;i++)
        if (type->CanStore[i]) {
@@ -892,13 +892,12 @@
        }
     if (flag)
        fprintf(file,")");
-    
-    if( type->OilPatch ) {
-       fprintf(file,"  'oil-patch\n");
-    }
-    if( type->GoldMine ) {
+    if( type->GivesResource==GoldCost ) {
        fprintf(file,"  'gives-gold\n");
     }
+    if( type->MustBuildOnTop ) {
+       fprintf(file," 'must-build-on-top '%s\n",type->MustBuildOnTop->Ident);
+    }
 
     if( type->Vanishes ) {
        fprintf(file,"  'vanishes\n");
@@ -967,6 +966,7 @@
 local void SaveUnitStats(const UnitStats* stats,const char* ident,int plynr,
        FILE* file)
 {
+    DebugCheck(plynr>=PlayerMax);
     int j;
 
     fprintf(file,"(define-unit-stats '%s %d\n  ",ident,plynr);
@@ -1000,12 +1000,12 @@
 */
 global void SaveUnitTypes(FILE* file)
 {
-    const UnitType* type;
     char* const* sp;
     int i;
+    int j;
 
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: unittypes $Id: unittype.c,v 1.77 2003/07/12 
14:09:18 n0body Exp $\n\n");
+    fprintf(file,";;; MODULE: unittypes $Id: unittype.c,v 1.78 2003/07/22 
14:32:22 n0body Exp $\n\n");
 
     // Original number to internal unit-type name.
 
@@ -1020,23 +1020,23 @@
 
     // Save all animations.
 
-    for( type=UnitTypes; type->OType; ++type ) {
-       SaveAnimations(type,file);
+    for( i=0; i<NumUnitTypes; ++i ) {
+       SaveAnimations(UnitTypes[i],file);
     }
 
     // Save all types
 
-    for( type=UnitTypes; type->OType; ++type ) {
+    for( i=0; i<NumUnitTypes; ++i ) {
        fputc('\n',file);
-       SaveUnitType(file,type,0);
+       SaveUnitType(file,UnitTypes[i],0);
     }
 
     // Save all stats
 
-    for( type=UnitTypes; type->OType; ++type ) {
+    for( i=0; i<NumUnitTypes; ++i ) {
        fputc('\n',file);
-       for( i=0; i<PlayerMax; ++i ) {
-           SaveUnitStats(&type->Stats[i],type->Ident,i,file);
+       for( j=0; j<PlayerMax; ++j ) {
+           SaveUnitStats(&UnitTypes[i]->Stats[j],UnitTypes[i]->Ident,j,file);
        }
     }
 }
@@ -1086,30 +1086,20 @@
 global UnitType* NewUnitTypeSlot(char* ident)
 {
     UnitType* type;
-    int i;
 
-    // +2 for slot and an empty slot at end.
-    type=calloc(NumUnitTypes+2,sizeof(UnitType));
+    type=malloc(sizeof(UnitType));
     if( !type ) {
        fprintf(stderr,"Out of memory\n");
        ExitFatal(-1);
     }
-    memcpy(type,UnitTypes,sizeof(UnitType)*NumUnitTypes);
-    if( UnitTypes ) {
-       free(UnitTypes);
-    }
-    UnitTypes=type;
-    type=UnitTypes+NumUnitTypes;
-    type->OType=UnitTypeType;
-    type->Type=NumUnitTypes++;
+    memset(type,0,sizeof(UnitType));
+    type->Type=NumUnitTypes;
     type->Ident=ident;
+    UnitTypes[NumUnitTypes++]=type;
     //
     // Rehash.
     //
-    for( i=0; i<NumUnitTypes; ++i ) {
-       *(UnitType**)hash_add(UnitTypeHash,UnitTypes[i].Ident)=&UnitTypes[i];
-    }
-
+    *(UnitType**)hash_add(UnitTypeHash,type->Ident)=type;
     return type;
 }
 
@@ -1145,49 +1135,49 @@
 {
     int type;
 
-    for( type=0; UnitTypes[type].OType; ++type ) {
+    for( type=0; type<NumUnitTypes; ++type ) {
        //
        //      Initialize:
        //
-       DebugCheck( UnitTypes[type].Type!=type );
+       DebugCheck( UnitTypes[type]->Type!=type );
        //
        //      Add idents to hash.
        //
-       *(UnitType**)hash_add(UnitTypeHash,UnitTypes[type].Ident)
-               =&UnitTypes[type];
+       *(UnitType**)hash_add(UnitTypeHash,UnitTypes[type]->Ident)
+               =UnitTypes[type];
        //
        //      Hardcoded incomes, FIXME: should be moved to some configs.
        //
-       if( !strcmp(UnitTypes[type].Ident,"unit-elven-lumber-mill") ) {
-           UnitTypes[type].ImproveIncomes[WoodCost]=
+       if( !strcmp(UnitTypes[type]->Ident,"unit-elven-lumber-mill") ) {
+           UnitTypes[type]->ImproveIncomes[WoodCost]=
                    DefaultIncomes[WoodCost]+25;
        }
-       if( !strcmp(UnitTypes[type].Ident,"unit-troll-lumber-mill") ) {
-           UnitTypes[type].ImproveIncomes[WoodCost]=
+       if( !strcmp(UnitTypes[type]->Ident,"unit-troll-lumber-mill") ) {
+           UnitTypes[type]->ImproveIncomes[WoodCost]=
                    DefaultIncomes[WoodCost]+25;
        }
-       if( !strcmp(UnitTypes[type].Ident,"unit-human-refinery") ) {
-           UnitTypes[type].ImproveIncomes[OilCost]=
+       if( !strcmp(UnitTypes[type]->Ident,"unit-human-refinery") ) {
+           UnitTypes[type]->ImproveIncomes[OilCost]=
                    DefaultIncomes[OilCost]+25;
        }
-       if( !strcmp(UnitTypes[type].Ident,"unit-orc-refinery") ) {
-           UnitTypes[type].ImproveIncomes[OilCost]=
+       if( !strcmp(UnitTypes[type]->Ident,"unit-orc-refinery") ) {
+           UnitTypes[type]->ImproveIncomes[OilCost]=
                    DefaultIncomes[OilCost]+25;
        }
-       if( !strcmp(UnitTypes[type].Ident,"unit-keep") ) {
-           UnitTypes[type].ImproveIncomes[GoldCost]=
+       if( !strcmp(UnitTypes[type]->Ident,"unit-keep") ) {
+           UnitTypes[type]->ImproveIncomes[GoldCost]=
                    DefaultIncomes[GoldCost]+10;
        }
-       if( !strcmp(UnitTypes[type].Ident,"unit-stronghold") ) {
-           UnitTypes[type].ImproveIncomes[GoldCost]=
+       if( !strcmp(UnitTypes[type]->Ident,"unit-stronghold") ) {
+           UnitTypes[type]->ImproveIncomes[GoldCost]=
                    DefaultIncomes[GoldCost]+10;
        }
-       if( !strcmp(UnitTypes[type].Ident,"unit-castle") ) {
-           UnitTypes[type].ImproveIncomes[GoldCost]=
+       if( !strcmp(UnitTypes[type]->Ident,"unit-castle") ) {
+           UnitTypes[type]->ImproveIncomes[GoldCost]=
                    DefaultIncomes[GoldCost]+20;
        }
-       if( !strcmp(UnitTypes[type].Ident,"unit-fortress") ) {
-           UnitTypes[type].ImproveIncomes[GoldCost]=
+       if( !strcmp(UnitTypes[type]->Ident,"unit-fortress") ) {
+           UnitTypes[type]->ImproveIncomes[GoldCost]=
                    DefaultIncomes[GoldCost]+20;
        }
     }
@@ -1198,8 +1188,6 @@
     //
     // Setup hardcoded unit types. FIXME: should be moved to some configs.
     //
-    UnitTypeOilPatch=UnitTypeByIdent("unit-oil-patch");
-    UnitTypeGoldMine=UnitTypeByIdent("unit-gold-mine");
     UnitTypeHumanTanker=UnitTypeByIdent("unit-human-oil-tanker");
     UnitTypeOrcTanker=UnitTypeByIdent("unit-orc-oil-tanker");
     UnitTypeHumanTankerFull=UnitTypeByIdent("unit-human-oil-tanker-full");
@@ -1223,8 +1211,10 @@
 {
     UnitType* type;
     const char* file;
+    int i;
 
-    for( type=UnitTypes; type->OType; ++type ) {
+    for( i=0; i<NumUnitTypes; ++i ) {
+       type=UnitTypes[i];
        if( (file=type->ShadowFile) ) {
            char *buf;
            buf=alloca(strlen(file)+9+1);
@@ -1258,7 +1248,8 @@
        }
     }
 
-    for( type=UnitTypes; type->OType; ++type ) {
+    for( i=0; i<NumUnitTypes; ++i ) {
+       type=UnitTypes[i];
        //
        //      Unit-type uses the same sprite as an other.
        //
@@ -1303,9 +1294,8 @@
 {
     UnitType* type;
     void** ptr;
-#ifdef USE_OPENGL
     int i;
-#endif
+    int j;
 
     DebugLevel0Fn("FIXME: icon, sounds not freed.\n");
 
@@ -1324,16 +1314,17 @@
     // FIXME: scheme contains references on this structure.
     // Clean all animations.
 
-    for( type=UnitTypes; type->OType; ++type ) {
+    for( i=0; i<NumUnitTypes; ++i )
+    {
+       type=UnitTypes[i];
        Animations* anims;
-       UnitType* temp;
 
        if( !(anims=type->Animations) ) {       // Must be handled?
            continue;
        }
-       for( temp=type; temp->OType; ++temp ) { // remove all uses
-           if( anims==temp->Animations ) {
-               temp->Animations=NULL;
+       for( j=i; j<NumUnitTypes; ++j ) {       // Remove all uses.
+           if( anims==UnitTypes[j]->Animations ) {
+               UnitTypes[j]->Animations=NULL;
            }
        }
        type->Animations=NULL;
@@ -1354,80 +1345,78 @@
 
     // Clean all unit-types
 
-    if( UnitTypes ) {
-       for( type=UnitTypes; type->OType; ++type ) {
-           hash_del(UnitTypeHash,type->Ident);
-
-           DebugCheck( !type->Ident );
-           free(type->Ident);
-           DebugCheck( !type->Name );
-           free(type->Name);
+    for( i=0;i<NumUnitTypes;++i ) {
+       type=UnitTypes[i];
+       hash_del(UnitTypeHash,type->Ident);
 
-           if( type->SameSprite ) {
-               free(type->SameSprite);
-           }
-           if( type->File[0] ) {
-               free(type->File[0]);
-           }
-           if( type->File[1] ) {
-               free(type->File[1]);
-           }
-           if( type->File[2] ) {
-               free(type->File[2]);
-           }
-           if( type->File[3] ) {
-               free(type->File[3]);
-           }
-           if( type->Icon.Name ) {
-               free(type->Icon.Name);
-           }
-           if( type->Missile.Name ) {
-               free(type->Missile.Name);
-           }
-           if( type->CorpseName ) {
-               free(type->CorpseName);
-           }
+       DebugCheck( !type->Ident );
+       free(type->Ident);
+       DebugCheck( !type->Name );
+       free(type->Name);
 
-           //
-           //  FIXME: Sounds can't be freed, they still stuck in sound hash.
-           //
-           if( type->Sound.Selected.Name ) {
-               free(type->Sound.Selected.Name);
-           }
-           if( type->Sound.Acknowledgement.Name ) {
-               free(type->Sound.Acknowledgement.Name);
-           }
-           if( type->Sound.Ready.Name ) {
-               free(type->Sound.Ready.Name);
-           }
-           if( type->Sound.Help.Name ) {
-               free(type->Sound.Help.Name);
-           }
-           if( type->Sound.Dead.Name ) {
-               free(type->Sound.Dead.Name);
-           }
-           if( type->Weapon.Attack.Name ) {
-               free(type->Weapon.Attack.Name);
-           }
+       if( type->SameSprite ) {
+           free(type->SameSprite);
+       }
+       if( type->File[0] ) {
+           free(type->File[0]);
+       }
+       if( type->File[1] ) {
+           free(type->File[1]);
+       }
+       if( type->File[2] ) {
+           free(type->File[2]);
+       }
+       if( type->File[3] ) {
+           free(type->File[3]);
+       }
+       if( type->Icon.Name ) {
+           free(type->Icon.Name);
+       }
+       if( type->Missile.Name ) {
+           free(type->Missile.Name);
+       }
+       if( type->CorpseName ) {
+           free(type->CorpseName);
+       }
 
-           if( !type->SameSprite ) {   // our own graphics
-               VideoSaveFree(type->Sprite);
-           }
+       //
+       //      FIXME: Sounds can't be freed, they still stuck in sound hash.
+       //
+       if( type->Sound.Selected.Name ) {
+           free(type->Sound.Selected.Name);
+       }
+       if( type->Sound.Acknowledgement.Name ) {
+           free(type->Sound.Acknowledgement.Name);
+       }
+       if( type->Sound.Ready.Name ) {
+           free(type->Sound.Ready.Name);
+       }
+       if( type->Sound.Help.Name ) {
+           free(type->Sound.Help.Name);
+       }
+       if( type->Sound.Dead.Name ) {
+           free(type->Sound.Dead.Name);
+       }
+       if( type->Weapon.Attack.Name ) {
+           free(type->Weapon.Attack.Name);
+       }
+
+       if( !type->SameSprite ) {       // our own graphics
+           VideoSaveFree(type->Sprite);
+       }
 #ifdef USE_OPENGL
-           for( i=0; i<PlayerMax; ++i ) {
-               VideoSaveFree(type->PlayerColorSprite[i]);
-           }
-#endif
+       for( i=0; i<PlayerMax; ++i ) {
+           VideoSaveFree(type->PlayerColorSprite[i]);
        }
-       free(UnitTypes);
-       UnitTypes=NULL;
-       NumUnitTypes=0;
+#endif
+       free(UnitTypes[i]);
+       UnitTypes[i]=0;
     }
+    NumUnitTypes=0;
 
     //
     // Clean hardcoded unit types.
     //
-    UnitTypeGoldMine=NULL;
     UnitTypeHumanTanker=NULL;
     UnitTypeOrcTanker=NULL;
     UnitTypeHumanTankerFull=NULL;
Index: stratagus/src/unit/upgrade.c
diff -u stratagus/src/unit/upgrade.c:1.54 stratagus/src/unit/upgrade.c:1.55
--- stratagus/src/unit/upgrade.c:1.54   Fri Jul 18 16:26:20 2003
+++ stratagus/src/unit/upgrade.c        Tue Jul 22 10:32:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: upgrade.c,v 1.54 2003/07/18 20:26:20 grumbel Exp $
+//     $Id: upgrade.c,v 1.55 2003/07/22 14:32:22 n0body Exp $
 
 //@{
 
@@ -550,7 +550,7 @@
     int p;
 
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: upgrades $Id: upgrade.c,v 1.54 2003/07/18 
20:26:20 grumbel Exp $\n\n");
+    fprintf(file,";;; MODULE: upgrades $Id: upgrade.c,v 1.55 2003/07/22 
14:32:22 n0body Exp $\n\n");
 
     //
     // Save all upgrades
@@ -613,7 +613,7 @@
        for( j=0; j<UnitTypeMax; ++j ) {        // allow/forbid units
            if( UpgradeModifiers[i]->ChangeUnits[j]!='?' ) {
                fprintf(file,"\n  '(allow %s %d)",
-                       UnitTypes[j].Ident,
+                       UnitTypes[j]->Ident,
                        UpgradeModifiers[i]->ChangeUnits[j]);
            }
        }
@@ -627,7 +627,7 @@
 
        for( j=0; j<UnitTypeMax; ++j ) {        // apply to units
            if( UpgradeModifiers[i]->ApplyTo[j]!='?' ) {
-               fprintf(file,"\n  '(apply-to %s)",UnitTypes[j].Ident);
+               fprintf(file,"\n  '(apply-to %s)",UnitTypes[j]->Ident);
            }
        }
 
@@ -642,13 +642,13 @@
     //
     // Save the allow
     //
-    for( i=0; UnitTypes[i].OType; ++i ) {
-       fprintf(file,"(define-allow '%s\t",UnitTypes[i].Ident);
-       if( strlen(UnitTypes[i].Ident)<9 ) {
+    for( i=0; i<NumUnitTypes; ++i ) {
+       fprintf(file,"(define-allow '%s\t",UnitTypes[i]->Ident);
+       if( strlen(UnitTypes[i]->Ident)<9 ) {
            fprintf(file,"\t\t\t\"");
-       } else if( strlen(UnitTypes[i].Ident)<17 ) {
+       } else if( strlen(UnitTypes[i]->Ident)<17 ) {
            fprintf(file,"\t\t\"");
-       } else if( strlen(UnitTypes[i].Ident)<25 ) {
+       } else if( strlen(UnitTypes[i]->Ident)<25 ) {
            fprintf(file,"\t\"");
        } else {
            fprintf(file,"\"");
@@ -1388,50 +1388,50 @@
 
            DebugLevel3Fn(" applied to %d\n" _C_ z);
            // upgrade stats     
-           UnitTypes[z].Stats[pn].AttackRange += um->Modifier.AttackRange;
-           UnitTypes[z].Stats[pn].SightRange += um->Modifier.SightRange;
+           UnitTypes[z]->Stats[pn].AttackRange += um->Modifier.AttackRange;
+           UnitTypes[z]->Stats[pn].SightRange += um->Modifier.SightRange;
            //If Sight range is upgraded, we need to change EVERY unit
            //to the new range, otherwise the counters get confused.
            if (um->Modifier.SightRange) {
                int numunits;
                Unit* sightupgrade[UnitMax];
                
-               numunits = FindUnitsByType(&UnitTypes[z],sightupgrade);
+               numunits = FindUnitsByType(UnitTypes[z],sightupgrade);
                numunits--; // Change to 0 Start not 1 start
                while (numunits >= 0) {
                    if (sightupgrade[numunits]->Player->Player == 
player->Player &&
                        !sightupgrade[numunits]->Removed) {
                        /// Marking First is faster
                        MapMarkSight(player,
-                                       
sightupgrade[numunits]->X+UnitTypes[z].TileWidth/2,
-                                       
sightupgrade[numunits]->Y+UnitTypes[z].TileHeight/2,
-                                       UnitTypes[z].Stats[pn].SightRange);
+                                       
sightupgrade[numunits]->X+UnitTypes[z]->TileWidth/2,
+                                       
sightupgrade[numunits]->Y+UnitTypes[z]->TileHeight/2,
+                                       UnitTypes[z]->Stats[pn].SightRange);
                        MapUnmarkSight(player,
-                                       
sightupgrade[numunits]->X+UnitTypes[z].TileWidth/2,
-                                       
sightupgrade[numunits]->Y+UnitTypes[z].TileHeight/2,
+                                       
sightupgrade[numunits]->X+UnitTypes[z]->TileWidth/2,
+                                       
sightupgrade[numunits]->Y+UnitTypes[z]->TileHeight/2,
                                        
sightupgrade[numunits]->CurrentSightRange);
-                       
sightupgrade[numunits]->CurrentSightRange=UnitTypes[z].Stats[pn].SightRange;
+                       
sightupgrade[numunits]->CurrentSightRange=UnitTypes[z]->Stats[pn].SightRange;
                    }                                   
                    numunits--;
                }
            }
-           UnitTypes[z].Stats[pn].BasicDamage += um->Modifier.BasicDamage;
-           UnitTypes[z].Stats[pn].PiercingDamage
+           UnitTypes[z]->Stats[pn].BasicDamage += um->Modifier.BasicDamage;
+           UnitTypes[z]->Stats[pn].PiercingDamage
                    += um->Modifier.PiercingDamage;
-           UnitTypes[z].Stats[pn].Armor += um->Modifier.Armor;
-           UnitTypes[z].Stats[pn].Speed += um->Modifier.Speed;
-           UnitTypes[z].Stats[pn].HitPoints += um->Modifier.HitPoints;
+           UnitTypes[z]->Stats[pn].Armor += um->Modifier.Armor;
+           UnitTypes[z]->Stats[pn].Speed += um->Modifier.Speed;
+           UnitTypes[z]->Stats[pn].HitPoints += um->Modifier.HitPoints;
 
            // upgrade costs :)
            for (j = 0; j < MaxCosts; ++j) {
-               UnitTypes[z].Stats[pn].Costs[j] += um->Modifier.Costs[j];
+               UnitTypes[z]->Stats[pn].Costs[j] += um->Modifier.Costs[j];
            }
 
-           UnitTypes[z].Stats[pn].Level++;
+           UnitTypes[z]->Stats[pn].Level++;
 
            if( um->ConvertTo ) {
                ((UnitType*)um->ConvertTo)->Stats[pn].Level++;
-               ConvertUnitTypeTo(player,&UnitTypes[z],um->ConvertTo);
+               ConvertUnitTypeTo(player,UnitTypes[z],um->ConvertTo);
            }
        }
     }
Index: stratagus/src/video/cursor.c
diff -u stratagus/src/video/cursor.c:1.58 stratagus/src/video/cursor.c:1.59
--- stratagus/src/video/cursor.c:1.58   Fri Jul 11 10:35:34 2003
+++ stratagus/src/video/cursor.c        Tue Jul 22 10:32:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: cursor.c,v 1.58 2003/07/11 14:35:34 n0body Exp $
+//     $Id: cursor.c,v 1.59 2003/07/22 14:32:22 n0body Exp $
 
 //@{
 
@@ -737,11 +737,11 @@
        while( w-- ) {
            int basex, basey;
            // FIXME: The field is covered by fog of war!
-           if( f && CanBuildOn(mx+w,my+h,mask &
-                   ((Selected[0]
-                           && Selected[0]->X==mx+w && Selected[0]->Y==my+h)
-                       ? ~(MapFieldLandUnit|MapFieldSeaUnit) : -1))
-                 && IsMapFieldExplored(ThisPlayer,mx+w,my+h) ) {
+           if( f && ( CursorBuilding->MustBuildOnTop || 
+                   CanBuildOn(mx+w,my+h,mask & ((Selected[0] && 
+                       Selected[0]->X==mx+w && Selected[0]->Y==my+h)
+                       ? ~(MapFieldLandUnit|MapFieldSeaUnit) : -1)))
+                 && IsMapFieldExplored(ThisPlayer,mx+w,my+h) )  {
                color=ColorGreen;
            } else {
                color=ColorRed;
@@ -1108,7 +1108,7 @@
     int i;
 
     fprintf(file,"\n;;; -----------------------------------------\n");
-    fprintf(file,";;; MODULE: cursors $Id: cursor.c,v 1.58 2003/07/11 14:35:34 
n0body Exp $\n\n");
+    fprintf(file,";;; MODULE: cursors $Id: cursor.c,v 1.59 2003/07/22 14:32:22 
n0body Exp $\n\n");
 
     for( i=0; Cursors[i].OType; ++i ) {
        fprintf(file,"(define-cursor '%s '%s\n",
Index: stratagus/src/video/font.c
diff -u stratagus/src/video/font.c:1.52 stratagus/src/video/font.c:1.53
--- stratagus/src/video/font.c:1.52     Fri Jul 18 16:26:20 2003
+++ stratagus/src/video/font.c  Tue Jul 22 10:32:22 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: font.c,v 1.52 2003/07/18 20:26:20 grumbel Exp $
+//     $Id: font.c,v 1.53 2003/07/22 14:32:22 n0body Exp $
 
 //@{
 
@@ -365,7 +365,8 @@
     glDisable(GL_TEXTURE_2D);
 
     for( i=0; i<NumFontColors; ++i ) {
-       c=FontPixels[i];
+       //c=FontPixels[i];
+       memcpy(&c,FontPixels+i,sizeof(Palette));
        glColor3ub(c.r,c.g,c.b);
        glRasterPos2i(x,VideoHeight-y-h);
        glBitmap(FontBitmapWidths[CurrentFont]*8,h,




reply via email to

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