stratagus-cvs
[Top][All Lists]
Advanced

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

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


From: Russell Smith
Subject: [Stratagus-CVS] stratagus data/ccl/stratagus.ccl data/ccl/human...
Date: Sun, 14 Sep 2003 02:53:09 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Russell Smith <address@hidden>  03/09/14 02:53:08

Modified files:
        data/ccl       : stratagus.ccl 
        data/ccl/human : units.ccl 
        data/ccl/orc   : units.ccl 
        doc            : ChangeLog.html 
        doc/ccl        : config.html 
        src/action     : command.c 
        src/game       : game.c loadgame.c 
        src/include    : pathfinder.h unit.h 
        src/map        : map_fog.c 
        src/pathfinder : astar.c ccl_pathfinder.c pathfinder.c 

Log message:
        Removed old pathfinder, A-Star is not an option now.
        Added MinRange to Orders, Pathfinder finds correct paths for a ranged 
attack now.
        Fixes most known pathfinder bugs.  for the moment :)

Patches:
Index: stratagus/data/ccl/human/units.ccl
diff -u stratagus/data/ccl/human/units.ccl:1.34 
stratagus/data/ccl/human/units.ccl:1.35
--- stratagus/data/ccl/human/units.ccl:1.34     Fri Sep 12 13:44:35 2003
+++ stratagus/data/ccl/human/units.ccl  Sun Sep 14 02:53:07 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.34 2003/09/12 17:44:35 n0body Exp $
+;;     $Id: units.ccl,v 1.35 2003/09/14 06:53:07 mr-russ Exp $
 
 ;;=============================================================================
 ;;     Define unit-types.
@@ -125,7 +125,7 @@
   'tile-size '(1 1) 'box-size '(63 63)
   'sight-range 9 'computer-reaction-range 11 'person-reaction-range 9
   'basic-damage 80 'piercing-damage 0 'missile 'missile-ballista-bolt
-  'min-attack-range 1 'max-attack-range 8
+  'min-attack-range 2 'max-attack-range 8
   'weapons-upgradable 1
   'priority 70
   'points 100
@@ -1387,7 +1387,7 @@
   'tile-size '(2 2) 'box-size '(63 63)
   'sight-range 9 'computer-reaction-range 7 'person-reaction-range 7
   'armor 20 'basic-damage 50 'piercing-damage 0 'missile 'missile-small-cannon
-  'min-attack-range 1 'max-attack-range 7
+  'min-attack-range 2 'max-attack-range 7
   'priority 40 'annoy-computer-factor 50
   'points 250
   'corpse '(unit-destroyed-2x2-place 0)
Index: stratagus/data/ccl/orc/units.ccl
diff -u stratagus/data/ccl/orc/units.ccl:1.38 
stratagus/data/ccl/orc/units.ccl:1.39
--- stratagus/data/ccl/orc/units.ccl:1.38       Fri Sep 12 13:44:36 2003
+++ stratagus/data/ccl/orc/units.ccl    Sun Sep 14 02:53:07 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.38 2003/09/12 17:44:36 n0body Exp $
+;;     $Id: units.ccl,v 1.39 2003/09/14 06:53:07 mr-russ Exp $
 
 ;;=============================================================================
 ;;     Define unit-types.
@@ -121,7 +121,7 @@
   'tile-size '(1 1) 'box-size '(63 63)
   'sight-range 9 'computer-reaction-range 11 'person-reaction-range 9
   'basic-damage 80 'piercing-damage 0 'missile 'missile-catapult-rock
-  'min-attack-range 1 'max-attack-range 8
+  'min-attack-range 2 'max-attack-range 8
   'weapons-upgradable 1
   'priority 70
   'points 100
@@ -1477,7 +1477,7 @@
   'tile-size '(2 2) 'box-size '(63 63)
   'sight-range 9 'computer-reaction-range 7 'person-reaction-range 7
   'armor 20 'basic-damage 50 'piercing-damage 0 'missile 'missile-small-cannon
-  'min-attack-range 1 'max-attack-range 7
+  'min-attack-range 2 'max-attack-range 7
   'priority 40 'annoy-computer-factor 50
   'points 250
   'corpse '(unit-destroyed-2x2-place 0)
Index: stratagus/data/ccl/stratagus.ccl
diff -u stratagus/data/ccl/stratagus.ccl:1.12 
stratagus/data/ccl/stratagus.ccl:1.13
--- stratagus/data/ccl/stratagus.ccl:1.12       Fri Sep  5 14:10:54 2003
+++ stratagus/data/ccl/stratagus.ccl    Sun Sep 14 02:53:06 2003
@@ -26,7 +26,7 @@
 ;;      along with this program; if not, write to the Free Software
 ;;      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA
 ;;
-;;     $Id: stratagus.ccl,v 1.12 2003/09/05 18:10:54 n0body Exp $
+;;     $Id: stratagus.ccl,v 1.13 2003/09/14 06:53:06 mr-russ Exp $
 
 ;; For documentation see stratagus/doc/ccl/ccl.html
 
@@ -387,7 +387,7 @@
 
 ;;-----------------------------------------------------------------------------
 
-(a-star 'on 'fixed-unit-cost 1000 'moving-unit-cost 20 
'dont-know-unseen-terrain 'unseen-terrain-cost 2)
+(a-star 'fixed-unit-cost 1000 'moving-unit-cost 20 'dont-know-unseen-terrain 
'unseen-terrain-cost 2)
 
 ;;-----------------------------------------------------------------------------
 
Index: stratagus/doc/ChangeLog.html
diff -u stratagus/doc/ChangeLog.html:1.525 stratagus/doc/ChangeLog.html:1.526
--- stratagus/doc/ChangeLog.html:1.525  Fri Sep 12 13:44:36 2003
+++ stratagus/doc/ChangeLog.html        Sun Sep 14 02:53:07 2003
@@ -2,7 +2,7 @@
 <html>
 <head>
 <!--
-----   $Id: ChangeLog.html,v 1.525 2003/09/12 17:44:36 n0body Exp $
+----   $Id: ChangeLog.html,v 1.526 2003/09/14 06:53:07 mr-russ Exp $
 
 ----   (c) Copyright 1998-2003 by Lutz Sammer
 
@@ -36,6 +36,10 @@
 <li>Future 1.19 Release<p>
     <ul>
     <li>++
+    <li>Removed old pathfinder, A-Star is not an option now (from Russell 
Smith).
+    <li>Added MinRange to Orders, Pathfinder finds correct paths for a ranged 
attack now (from Russell Smith).
+    <li>Corrected calculation of MapDistanceBetweenUnits (from Russell Smith).
+    <li>Demolishing is now a circle, uses the isqrt functions (from Russell 
Smith).
     <li>Demolishing units and critters are more configurable (from Crestez 
Leonard).
     <li>"make it so" cheat works again for resources and buildings (from 
Crestez Leonard).
     <li>Fixed attack-move bug (from Crestez Leonard).
Index: stratagus/doc/ccl/config.html
diff -u stratagus/doc/ccl/config.html:1.23 stratagus/doc/ccl/config.html:1.24
--- stratagus/doc/ccl/config.html:1.23  Fri Sep 12 13:44:36 2003
+++ stratagus/doc/ccl/config.html       Sun Sep 14 02:53:07 2003
@@ -128,9 +128,9 @@
 
 <h2>Functions</h2>
 <a name="a-star"></a>
-<h3>(a-star on fixed-unit-cost moving-unit-cost unseen-terrain 
unseen-terrain-cost)</h3>
+<h3>(a-star fixed-unit-cost moving-unit-cost unseen-terrain 
unseen-terrain-cost)</h3>
 
-Configures the A-star pathfinder to be on or off.  Also sets variables about 
the pathfinder.
+Sets variables about the pathfinder.
 What the movement cost for unseen terrian is and whether units are aware of 
what's under unseen terrain.
 Items can be turned on and off to give desired behaviour, however 
dont-know-unseen-terrain will increase
 the amount the pathfinder is used at the start of a game while the map is 
being discovered.  If you need
@@ -139,8 +139,6 @@
 The Cost of a move it 1 if moving straight, or 2 if moving diagonal.
 
 <dl>
-<dt>on</dt>
-<dd>Whether A-Star is on or off &lt;'on|'off&gt;</dd>
 <dt>fixed-unit-cost</dt>
 <dd>cost to move over a unit that is standing still.</dd>
 <dt>moving-unit-cost</dt>
@@ -1575,7 +1573,7 @@
 <a href="../../data/ccl/stratagus.ccl"> $LIBARYPATH/ccl/stratagus.ccl </a>
 
 <hr>
-Last changed: $Id: config.html,v 1.23 2003/09/12 17:44:36 n0body Exp $<br>
+Last changed: $Id: config.html,v 1.24 2003/09/14 06:53:07 mr-russ Exp $<br>
 All trademarks and copyrights on this page are owned by their respective 
owners.
 <address>(c) 2002-2003 by <a href="http://stratagus.org";>
 The Stratagus Project</a></address></body></html>
Index: stratagus/src/action/command.c
diff -u stratagus/src/action/command.c:1.104 
stratagus/src/action/command.c:1.105
--- stratagus/src/action/command.c:1.104        Fri Sep 12 13:44:36 2003
+++ stratagus/src/action/command.c      Sun Sep 14 02:53:07 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: command.c,v 1.104 2003/09/12 17:44:36 n0body Exp $
+//     $Id: command.c,v 1.105 2003/09/14 06:53:07 mr-russ Exp $
 
 //@{
 
@@ -438,12 +438,14 @@
                RefsDebugCheck( !attack->Refs );
                attack->Refs++;
                order->RangeX=order->RangeY=unit->Stats->AttackRange;
+               order->MinRange=unit->Type->MinAttackRange;
            }
        } else if( WallOnMap(x,y) ) {
            // FIXME: look into action_attack.c about this ugly problem
            order->X=x;
            order->Y=y;
            order->RangeX=order->RangeY=unit->Stats->AttackRange;
+           order->MinRange=unit->Type->MinAttackRange;
            order->Goal=NoUnitP;
        } else {
            order->X=x;
@@ -493,6 +495,7 @@
        order->X=x;
        order->Y=y;
        order->RangeX=order->RangeY=unit->Stats->AttackRange;
+       order->MinRange=unit->Type->MinAttackRange;
        order->Goal=NoUnitP;
        order->Type=NULL;
        order->Arg1=NULL;
Index: stratagus/src/game/game.c
diff -u stratagus/src/game/game.c:1.101 stratagus/src/game/game.c:1.102
--- stratagus/src/game/game.c:1.101     Thu Aug 28 08:20:04 2003
+++ stratagus/src/game/game.c   Sun Sep 14 02:53:08 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: game.c,v 1.101 2003/08/28 12:20:04 mr-russ Exp $
+//     $Id: game.c,v 1.102 2003/09/14 06:53:08 mr-russ Exp $
 
 //@{
 
@@ -517,9 +517,7 @@
     // Various hacks wich must be done after the map is loaded.
     //
     //FIXME: must be done after map is loaded
-    if(AStarOn) {
-       InitAStar();
-    }
+    InitAStar();
 #ifdef HIERARCHIC_PATHFINDER
     PfHierInitialize();
 #endif // HIERARCHIC_PATHFINDER
Index: stratagus/src/game/loadgame.c
diff -u stratagus/src/game/loadgame.c:1.60 stratagus/src/game/loadgame.c:1.61
--- stratagus/src/game/loadgame.c:1.60  Thu Aug 28 08:25:42 2003
+++ stratagus/src/game/loadgame.c       Sun Sep 14 02:53:08 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: loadgame.c,v 1.60 2003/08/28 12:25:42 mr-russ Exp $
+//     $Id: loadgame.c,v 1.61 2003/09/14 06:53:08 mr-russ Exp $
 
 //@{
 
@@ -108,9 +108,7 @@
 #ifdef HIERARCHIC_PATHFINDER
     PfHierClean ();
 #endif
-    if (AStarOn) {
-        FreeAStar();
-    }
+    FreeAStar();
 
     //
     // Free our protected objects, AI scripts, unit-type properties.
Index: stratagus/src/include/pathfinder.h
diff -u stratagus/src/include/pathfinder.h:1.32 
stratagus/src/include/pathfinder.h:1.33
--- stratagus/src/include/pathfinder.h:1.32     Mon Aug 25 07:21:17 2003
+++ stratagus/src/include/pathfinder.h  Sun Sep 14 02:53:08 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: pathfinder.h,v 1.32 2003/08/25 11:21:17 mr-russ Exp $
+//     $Id: pathfinder.h,v 1.33 2003/09/14 06:53:08 mr-russ Exp $
 
 #ifndef        __PATH_FINDER_H__
 #define        __PATH_FINDER_H__
@@ -71,8 +71,6 @@
 
     /// Path matrix
 extern unsigned char Matrix[(MaxMapWidth+2)*(MaxMapHeight+3)+2];
-    /// are we using A* or the old path finder
-extern int AStarOn;
     /// cost associated to move on a tile occupied by a fixed unit
 extern int AStarFixedUnitCrossingCost;
     /// cost associated to move on a tile occupied by a moving unit
@@ -117,7 +115,7 @@
 extern void FreeAStar(void);
 
     /// Find and a* path for a unit
-extern int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int 
range, char* path);
+extern int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int 
minrange, int maxrange, char* path);
 //
 //     in ccl_pathfinder.c
 //
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.213 stratagus/src/include/unit.h:1.214
--- stratagus/src/include/unit.h:1.213  Thu Sep 11 18:07:53 2003
+++ stratagus/src/include/unit.h        Sun Sep 14 02:53:08 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.h,v 1.213 2003/09/11 22:07:53 n0body Exp $
+//     $Id: unit.h,v 1.214 2003/09/14 06:53:08 mr-russ Exp $
 
 #ifndef __UNIT_H__
 #define __UNIT_H__
@@ -434,6 +434,7 @@
     unsigned char      Flags;          /// Order flags (unused)
     unsigned int       RangeX;         /// How near in X direction
     unsigned int       RangeY;         /// How near in Y direction
+    unsigned int       MinRange;       /// How far away minimum
     unsigned char      IsRect:1;       /// For goal as a square, not circle
 
     Unit*              Goal;           /// goal of the order (if any)
Index: stratagus/src/map/map_fog.c
diff -u stratagus/src/map/map_fog.c:1.102 stratagus/src/map/map_fog.c:1.103
--- stratagus/src/map/map_fog.c:1.102   Sun Sep 14 00:45:53 2003
+++ stratagus/src/map/map_fog.c Sun Sep 14 02:53:08 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: map_fog.c,v 1.102 2003/09/14 04:45:53 mr-russ Exp $
+//     $Id: map_fog.c,v 1.103 2003/09/14 06:53:08 mr-russ Exp $
 
 //@{
 
@@ -58,7 +58,7 @@
 #ifdef DEBUG
 
 // Use this to see FOW visibility for every tile
-#define noDEBUG_FOG_OF_WAR
+#define DEBUG_FOG_OF_WAR
 
 #define noTIMEIT                       /// defined time function
 #endif
Index: stratagus/src/pathfinder/astar.c
diff -u stratagus/src/pathfinder/astar.c:1.51 
stratagus/src/pathfinder/astar.c:1.52
--- stratagus/src/pathfinder/astar.c:1.51       Wed Sep  3 05:27:51 2003
+++ stratagus/src/pathfinder/astar.c    Sun Sep 14 02:53:08 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: astar.c,v 1.51 2003/09/03 09:27:51 mr-russ Exp $
+//     $Id: astar.c,v 1.52 2003/09/14 06:53:08 mr-russ Exp $
 
 //@{
 
@@ -89,7 +89,6 @@
 /// see pathfinder.h
 global int AStarFixedUnitCrossingCost=MaxMapWidth*MaxMapHeight;
 global int AStarMovingUnitCrossingCost=5;
-global int AStarOn=1;
 global int AStarKnowUnknown=0;
 global int AStarUnknownTerrainCost=2;
 
@@ -109,15 +108,13 @@
 */
 global void InitAStar(void)
 {
-    if( AStarOn ) {
-       if( !AStarMatrix ) {
-           AStarMatrixSize=sizeof(Node)*TheMap.Width*TheMap.Height;
-           AStarMatrix=(Node *)calloc(TheMap.Width*TheMap.Height,sizeof(Node));
-           Threshold=TheMap.Width*TheMap.Height/MAX_CLOSE_SET_RATIO;
-           CloseSet=(int *)malloc(sizeof(int)*Threshold);
-           OpenSetMaxSize=TheMap.Width*TheMap.Height/MAX_OPEN_SET_RATIO;
-           OpenSet=(Open *)malloc(sizeof(Open)*OpenSetMaxSize);
-       }
+    if( !AStarMatrix ) {
+       AStarMatrixSize=sizeof(Node)*TheMap.Width*TheMap.Height;
+       AStarMatrix=(Node *)calloc(TheMap.Width*TheMap.Height,sizeof(Node));
+       Threshold=TheMap.Width*TheMap.Height/MAX_CLOSE_SET_RATIO;
+       CloseSet=(int *)malloc(sizeof(int)*Threshold);
+       OpenSetMaxSize=TheMap.Width*TheMap.Height/MAX_OPEN_SET_RATIO;
+       OpenSet=(Open *)malloc(sizeof(Open)*OpenSetMaxSize);
     }
 }
 
@@ -126,13 +123,11 @@
 */
 global void FreeAStar(void)
 {
-    if( AStarOn ) {
-       if( AStarMatrix ) {
-           free(AStarMatrix);
-           AStarMatrix=NULL;
-           free(CloseSet);
-           free(OpenSet);
-       }
+    if( AStarMatrix ) {
+       free(AStarMatrix);
+       AStarMatrix=NULL;
+       free(CloseSet);
+       free(OpenSet);
     }
 }
 
@@ -339,7 +334,8 @@
 /**
 **     MarkAStarGoal
 */
-local int AStarMarkGoal(Unit* unit, int gx, int gy, int gw, int gh, int range, 
int mask, int* num_in_close)
+local int AStarMarkGoal(Unit* unit, int gx, int gy, int gw, int gh, int 
minrange, int maxrange, 
+               int mask, int* num_in_close)
 {
     int cx[4]; 
     int cy[4];
@@ -351,10 +347,11 @@
     int quad;
     int eo;
     int filler;
+    int range;
 
     goal_reachable=0;
 
-    if( range == 0 && gw == 0 && gh == 0 ) {
+    if( minrange == 0 && maxrange == 0 && gw == 0 && gh == 0 ) {
        if( CostMoveTo(unit,gx,gy,mask,AStarFixedUnitCrossingCost)>=0 ) {
            AStarMatrix[gx+gy*TheMap.Width].InGoal=1;
            return 1;
@@ -364,87 +361,115 @@
     }
 
     // Mark top, bottom, left, right
-
-    // Mark Top and Bottom of Goal
-    for(x=gx;x<=gx+gw;x++) {
-       if( x >= 0 && x < TheMap.Width) {
-           if( gy-range >= 0 && 
CostMoveTo(unit,x,gy-range,mask,AStarFixedUnitCrossingCost)>=0 ) {
-               AStarMatrix[(gy-range)*TheMap.Width+x].InGoal=1;
-               goal_reachable=1;
-               if( *num_in_close<Threshold ) {
-                   CloseSet[(*num_in_close)++]=(gy-range)*TheMap.Width+x;
-               }                                                   
-           }
-           if( gy+range+gh < TheMap.Height && 
CostMoveTo(unit,x,gy+gh+range,mask,AStarFixedUnitCrossingCost)>=0 ) {
-               AStarMatrix[(gy+range+gh)*TheMap.Width+x].InGoal=1;
-               if( *num_in_close<Threshold ) {
-                   CloseSet[(*num_in_close)++]=(gy+range+gh)*TheMap.Width+x;
+    for(range=minrange; range <= maxrange; range++) {
+       // Mark Top and Bottom of Goal
+       for(x=gx;x<=gx+gw;x++) {
+           if( x >= 0 && x < TheMap.Width) {
+               if( gy-range >= 0 && 
CostMoveTo(unit,x,gy-range,mask,AStarFixedUnitCrossingCost)>=0 ) {
+                   AStarMatrix[(gy-range)*TheMap.Width+x].InGoal=1;
+                   goal_reachable=1;
+                   if( *num_in_close<Threshold ) {
+                       CloseSet[(*num_in_close)++]=(gy-range)*TheMap.Width+x;
+                   }                                               
+               }
+               if( gy+range+gh < TheMap.Height && 
+                       
CostMoveTo(unit,x,gy+gh+range,mask,AStarFixedUnitCrossingCost)>=0 ) {
+                   AStarMatrix[(gy+range+gh)*TheMap.Width+x].InGoal=1;
+                   if( *num_in_close<Threshold ) {
+                       
CloseSet[(*num_in_close)++]=(gy+range+gh)*TheMap.Width+x;
+                   }
+                   goal_reachable=1;
                }
-               goal_reachable=1;
            }
        }
-    }
 
-    for(y=gy;y<=gy+gh;y++) {
-       if( y >= 0 && y < TheMap.Height) {
-           if( gx-range >=0 && 
CostMoveTo(unit,gx-range,y,mask,AStarFixedUnitCrossingCost)>=0 ) {
-               AStarMatrix[y*TheMap.Width+gx-range].InGoal=1;
-               if( *num_in_close<Threshold ) {
-                   CloseSet[(*num_in_close)++]=y*TheMap.Width+gx-range;
+       for(y=gy;y<=gy+gh;y++) {
+           if( y >= 0 && y < TheMap.Height) {
+               if( gx-range >=0 && 
CostMoveTo(unit,gx-range,y,mask,AStarFixedUnitCrossingCost)>=0 ) {
+                   AStarMatrix[y*TheMap.Width+gx-range].InGoal=1;
+                   if( *num_in_close<Threshold ) {
+                       CloseSet[(*num_in_close)++]=y*TheMap.Width+gx-range;
+                   }
+                   goal_reachable=1;
                }
-               goal_reachable=1;
-           }
-           if( gx+gw+range < TheMap.Width && 
CostMoveTo(unit,gx+gw+range,y,mask,AStarFixedUnitCrossingCost)>=0 ) {
-               AStarMatrix[y*TheMap.Width+gx+gw+range].InGoal=1;
-               if( *num_in_close<Threshold ) {
-                   CloseSet[(*num_in_close)++]=y*TheMap.Width+gx+gw+range;
+               if( gx+gw+range < TheMap.Width && 
+                       
CostMoveTo(unit,gx+gw+range,y,mask,AStarFixedUnitCrossingCost)>=0 ) {
+                   AStarMatrix[y*TheMap.Width+gx+gw+range].InGoal=1;
+                   if( *num_in_close<Threshold ) {
+                       CloseSet[(*num_in_close)++]=y*TheMap.Width+gx+gw+range;
+                   }
+                   goal_reachable=1;
                }
-               goal_reachable=1;
            }
        }
-    }
+
+    } // Go Through the Ranges
 
     // Mark Goal Border in Matrix
 
     // Mark Edges of goal
 
-    steps=0;
-    // Find place to start. (for marking curves)
-    while(VisionTable[0][steps] != range && VisionTable[1][steps] == 0 && 
VisionTable[2][steps] == 0) {
-       steps++;
-    }
-    // 0 - Top right Quadrant
-    cx[0] = gx+gw;
-    cy[0] = gy-VisionTable[0][steps];
-    // 1 - Top left Quadrant
-    cx[1] = gx;
-    cy[1] = gy-VisionTable[0][steps];
-    // 2 - Bottom Left Quadrant
-    cx[2] = gx;
-    cy[2] = gy+VisionTable[0][steps]+gh;
-    // 3 - Bottom Right Quadrant
-    cx[3] = gx+gw;
-    cy[3] = gy+VisionTable[0][steps]+gh;
-
-    steps++;  // Move past blank marker
-    while(VisionTable[1][steps] != 0 || VisionTable[2][steps] != 0 ) {
-       // Loop through for repeat cycle
-       cycle=0;
-       while( cycle++ < VisionTable[0][steps] ) {
-           // If we travelled on an angle, mark down as well.
-           if( VisionTable[1][steps] == VisionTable[2][steps] ) {
-               // do down
+    steps=VisionLookup[minrange];
+
+    while( VisionTable[0][steps] <= maxrange ) {
+       // 0 - Top right Quadrant
+       cx[0] = gx+gw;
+       cy[0] = gy-VisionTable[0][steps];
+       // 1 - Top left Quadrant
+       cx[1] = gx;
+       cy[1] = gy-VisionTable[0][steps];
+       // 2 - Bottom Left Quadrant
+       cx[2] = gx;
+       cy[2] = gy+VisionTable[0][steps]+gh;
+       // 3 - Bottom Right Quadrant
+       cx[3] = gx+gw;
+       cy[3] = gy+VisionTable[0][steps]+gh;
+
+       steps++;  // Move past blank marker
+       while( VisionTable[1][steps] != 0 || VisionTable[2][steps] != 0 ) {
+           // Loop through for repeat cycle
+           cycle=0;
+           while( cycle++ < VisionTable[0][steps] ) {
+               // If we travelled on an angle, mark down as well.
+               if( VisionTable[1][steps] == VisionTable[2][steps] ) {
+                   // do down
+                   quad = 0;
+                   while( quad < 4 ) {
+                       if( quad < 2 ) {
+                           filler=1;
+                       } else {
+                           filler=-1;
+                       }
+                       if( cx[quad] >= 0 && cx[quad] < TheMap.Width && 
cy[quad]+filler >= 0 && 
+                           cy[quad]+filler < TheMap.Height &&
+                           
CostMoveTo(unit,cx[quad],cy[quad]+filler,mask,AStarFixedUnitCrossingCost)>=0 ) {
+                           eo=(cy[quad]+filler)*TheMap.Width+cx[quad];
+                           AStarMatrix[eo].InGoal=1;
+                           if( *num_in_close<Threshold ) {
+                               CloseSet[(*num_in_close)++]=eo;
+                           }
+                           goal_reachable=1;
+                       }
+                       quad++;
+                   }
+               }
+               
+               cx[0]+=VisionTable[1][steps];
+               cy[0]+=VisionTable[2][steps];
+               cx[1]-=VisionTable[1][steps];
+               cy[1]+=VisionTable[2][steps];
+               cx[2]-=VisionTable[1][steps];
+               cy[2]-=VisionTable[2][steps];
+               cx[3]+=VisionTable[1][steps];
+               cy[3]-=VisionTable[2][steps];
+           
+               // Mark Actually Goal curve change
                quad = 0;
                while( quad < 4 ) {
-                   if( quad < 2 ) {
-                       filler=1;
-                   } else {
-                       filler=-1;
-                   }
-                   if( cx[quad] >= 0 && cx[quad] < TheMap.Width && 
cy[quad]+filler >= 0 && 
-                       cy[quad]+filler < TheMap.Height &&
-                       
CostMoveTo(unit,cx[quad],cy[quad]+filler,mask,AStarFixedUnitCrossingCost)>=0 ) {
-                       eo=(cy[quad]+filler)*TheMap.Width+cx[quad];
+                   if( cx[quad] >= 0 && cx[quad] < TheMap.Width && cy[quad] >= 
0 &&
+                       cy[quad] < TheMap.Height &&
+                       
CostMoveTo(unit,cx[quad],cy[quad],mask,AStarFixedUnitCrossingCost)>=0 ) {
+                       eo=cy[quad]*TheMap.Width+cx[quad];
                        AStarMatrix[eo].InGoal=1;
                        if( *num_in_close<Threshold ) {
                            CloseSet[(*num_in_close)++]=eo;
@@ -454,40 +479,15 @@
                    quad++;
                }
            }
-               
-           cx[0]+=VisionTable[1][steps];
-           cy[0]+=VisionTable[2][steps];
-           cx[1]-=VisionTable[1][steps];
-           cy[1]+=VisionTable[2][steps];
-           cx[2]-=VisionTable[1][steps];
-           cy[2]-=VisionTable[2][steps];
-           cx[3]+=VisionTable[1][steps];
-           cy[3]-=VisionTable[2][steps];
-           
-           // Mark Actually Goal curve change
-           quad = 0;
-           while( quad < 4 ) {
-               if( cx[quad] >= 0 && cx[quad] < TheMap.Width && cy[quad] >= 0 &&
-                   cy[quad] < TheMap.Height &&
-                   
CostMoveTo(unit,cx[quad],cy[quad],mask,AStarFixedUnitCrossingCost)>=0 ) {
-                   eo=cy[quad]*TheMap.Width+cx[quad];
-                   AStarMatrix[eo].InGoal=1;
-                   if( *num_in_close<Threshold ) {
-                       CloseSet[(*num_in_close)++]=eo;
-                   }
-                   goal_reachable=1;
-               }
-               quad++;
-           }
+           steps++;
        }
-       steps++;
     }
     return goal_reachable;
 }
 /**
 **     Find path.
 */
-global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int 
range, char* path)
+global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int 
minrange, int maxrange, char* path)
 {
     int i;
     int j;
@@ -518,7 +518,7 @@
     y=unit->Y;
 
     // if goal is not directory reachable, punch out
-    if( !AStarMarkGoal(unit, gx, gy, gw, gh, range, mask, &num_in_close) ) {
+    if( !AStarMarkGoal(unit, gx, gy, gw, gh, minrange, maxrange, mask, 
&num_in_close) ) {
        AStarCleanUp(num_in_close);
        return PF_UNREACHABLE;
     }
Index: stratagus/src/pathfinder/ccl_pathfinder.c
diff -u stratagus/src/pathfinder/ccl_pathfinder.c:1.21 
stratagus/src/pathfinder/ccl_pathfinder.c:1.22
--- stratagus/src/pathfinder/ccl_pathfinder.c:1.21      Sun Aug 31 04:01:21 2003
+++ stratagus/src/pathfinder/ccl_pathfinder.c   Sun Sep 14 02:53:08 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_pathfinder.c,v 1.21 2003/08/31 08:01:21 mr-russ Exp $
+//     $Id: ccl_pathfinder.c,v 1.22 2003/09/14 06:53:08 mr-russ Exp $
 
 //@{
 
@@ -65,21 +65,7 @@
     while( !gh_null_p(list) ) {
        value=gh_car(list);
        list=gh_cdr(list);
-
-       if( gh_eq_p(value,gh_symbol2scm("on")) ) {
-           AStarOn=1;
-           if(!CclInConfigFile) {
-               // allocation is done directly in this alternate case
-               InitAStar();
-           }
-           DebugLevel0("A* is ON :-)\n");
-       } else if( gh_eq_p(value,gh_symbol2scm("off")) ) {
-           AStarOn=0;
-           if(!CclInConfigFile) {
-               FreeAStar();
-           }
-           DebugLevel0("A* is OFF :-(\n");
-       } else if( gh_eq_p(value,gh_symbol2scm("fixed-unit-cost")) ) {
+       if( gh_eq_p(value,gh_symbol2scm("fixed-unit-cost")) ) {
            i=gh_scm2int(gh_car(list));
             list=gh_cdr(list);
            if( i <=3 ) {
Index: stratagus/src/pathfinder/pathfinder.c
diff -u stratagus/src/pathfinder/pathfinder.c:1.53 
stratagus/src/pathfinder/pathfinder.c:1.54
--- stratagus/src/pathfinder/pathfinder.c:1.53  Mon Aug 25 07:21:18 2003
+++ stratagus/src/pathfinder/pathfinder.c       Sun Sep 14 02:53:08 2003
@@ -28,7 +28,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: pathfinder.c,v 1.53 2003/08/25 11:21:18 mr-russ Exp $
+//     $Id: pathfinder.c,v 1.54 2003/09/14 06:53:08 mr-russ Exp $
 
 //@{
 
@@ -452,440 +452,6 @@
 ----------------------------------------------------------------------------*/
 
 /**
-**     Fast search new path.
-**
-**     @param unit     Path for this unit.
-**     @param x1
-**     @param y1
-**     @param x2
-**     @param y2
-**
-**      @return                >0 remaining path length, 0 wait for path, -1
-**                     reached goal, -2 can't reach the goal.
-*/
-local int FastNewPath(Unit* unit,int x1,int y1,int x2,int y2)
-{
-    int x;
-    int y;
-    int xd;
-    int yd;
-    const UnitType* type;
-    int mask;
-    int steps;
-       
-    //
-    // Fast check if the way is blocked in sight.
-    //
-    type=unit->Type;
-    mask=TypeMovementMask(type);
-    steps=unit->Stats->SightRange;     // only in sight range!
-
-    x=unit->X;
-    y=unit->Y;
-    xd=(x1+x2)/2;                              // Center of goal
-    yd=(y1+y2)/2;
-
-
-    // FIXME: johns: has anybody an idea how to write this faster?
-    xd-=x;
-    yd-=y;
-    if( xd<0 ) xd=-1; else if( xd>0 ) xd=1;
-    if( yd<0 ) yd=-1; else if( yd>0 ) yd=1;
-    unit->Data.Move.Path[0]=XY2Heading[xd+1][yd+1];
-    unit->Data.Move.Length=1;
-
-    while( (steps-=1)>0 ) {
-       x+=xd;
-       y+=yd;
-
-       DebugLevel3Fn("Unit %d,%d Goal %d,%d - %d,%d\n"
-               _C_ x _C_ y _C_ x1 _C_ y1 _C_ x2 _C_ y2);
-       DebugLevel3Fn("Check %d,%d=%x\n" _C_ x _C_ y _C_ mask);
-
-       //
-       //      Now check if we can move to this field
-       //      FIXME: moving units didn't block?
-       //
-       if( !CheckedCanMoveToMask(x,y,mask) ) { // blocked
-           DebugLevel3Fn("The way is blocked in sight range\n");
-           return PF_UNREACHABLE;
-       }
-
-       //
-       //      Check if goal is reached
-       //
-       if( x>=x1 && x<=x2 && y>=y1 && y<=y2 ) {
-           DebugLevel3Fn("Goal in sight\n");
-           return unit->Stats->SightRange-steps;
-       }
-
-       //
-       //      Try next field.
-       //      From now on ignore any units.
-       //
-       mask&=~(MapFieldLandUnit|MapFieldAirUnit|MapFieldSeaUnit);
-
-       xd=(x1+x2)/2;                   // Center of goal
-       yd=(y1+y2)/2;
-
-       xd-=x;
-       if( xd<0 ) xd=-1; else if( xd>0 ) xd=1;
-       yd-=y;
-       if( yd<0 ) yd=-1; else if( yd>0 ) yd=1;
-    }
-    DebugLevel3Fn("Nothing in sight range\n");
-
-    return INT_MAX;
-}
-
-/**
-**     Trace path in the matrix back to origin.
-**
-**     @param matrix   Matrix (not real start!)
-**     @param add      Step value.
-**     @param x        X start point of trace back.
-**     @param y        Y start point of trace back.
-**     @param depth    Depth of path and marks start value (1..8)
-**     @param path     OUT: here are the path directions stored.
-*/
-local void PathTraceBack(const unsigned char* matrix,int add,int x,int y
-       ,int depth,unsigned char* path)
-{
-    int w;
-    int w2;
-    const unsigned char* m;
-    int d;
-    int n;
-    int startdepth;
-
-    w=TheMap.Width+2;
-    m=matrix+x+y*w;                    // End of path in matrix.
-    w*=add;
-    w2=w+w;
-    startdepth=depth;
-    if( startdepth > MAX_PATH_LENGTH ) {
-       startdepth = MAX_PATH_LENGTH;
-    }
-
-    //
-    // Find the way back, nodes are numbered ascending.
-    //
-    for( ;; ) {
-       --depth;
-       n=(depth&0x7)+1;
-
-       //
-       //      Directions stored in path:
-       //              7 0 1
-       //              6 . 2
-       //              5 4 3
-       //
-       d=6;
-       m+=add;                         // +1, 0
-       if( *m!=n ) {                   // test all neighbors
-         d=2;
-         m-=add<<1;                    // -1, 0
-         if( *m!=n ) {
-           d=0;
-           m+=add+w;                   //  0,+1
-           if( *m!=n ) {
-             d=4;
-             m-=w2;                    //  0,-1
-             if( *m!=n ) {
-               d=5;
-               m+=add;                 // +1,-1
-               if( *m!=n ) {
-                 d=3;
-                 m-=add<<1;            // -1,-1
-                 if( *m!=n ) {
-                   d=1;
-                   m+=w2;              // -1,+1
-                   if( *m!=n ) {
-                     d=7;
-                     m+=add<<1;        // +1,+1
-                     if( *m!=n ) {
-                         return;
-                     }
-                   }
-                 }
-               }
-             }
-           }
-         }
-       }
-       // found: continue
-       // Mart path if it's needed
-       // 
-       if( depth<MAX_PATH_LENGTH && path != NULL) {
-           path[startdepth-depth-1]=d;
-       }
-    }
-}
-
-/**
-**     Complex search new path.
-**
-**     @param unit     Path for this unit.
-**     @param x1       
-**     @param y1       
-**     @param x2       
-**     @param y2       
-**
-**     @param path     OUT: part of the path.
-**
-**      @return                >0 remaining path length, 0 wait for path, -1
-**                     reached goal, -2 can't reach the goal.
-*/
-local int ComplexNewPath(Unit* unit,int x1,int y1,int x2,int y2,char* path)
-{
-    unsigned char* matrix;
-    unsigned char* m;
-    unsigned short* points;
-    const Unit* goal;
-#ifdef USE_BEST
-    int bestx;
-    int besty;
-    int bestd;
-    int bestn;
-#endif
-    int x;
-    int y;
-    int xd;
-    int yd;
-    int mask;
-    int wp;
-    int rp;
-    int ep;
-    int n;
-    int i;
-    int j;
-    int w;
-    int depth;
-    int add;
-    int unreachable;
-    int size;
-
-    DebugLevel3Fn("%s(%d) to %d=%d,%d+%d+%d\n"
-           _C_ unit->Type->Ident _C_ UnitNumber(unit)
-           _C_ unit->Orders[0].Goal ? UnitNumber(unit->Orders[0].Goal) : 0
-           _C_ x1 _C_ y1 _C_ x2 _C_ y2);
-
-    size=TheMap.Width*TheMap.Height;
-    points=malloc(size);
-    size/=sizeof(*points)*2;
-
-    w=TheMap.Width+2;
-    matrix=CreateMatrix();
-    matrix+=w+w+2;
-    mask=UnitMovementMask(unit);
-
-    points[0]=x=unit->X;
-    points[1]=y=unit->Y;
-    rp=0;
-    matrix[x+y*w]=depth=1;                     // mark start point
-    ep=wp=n=2;                                 // start with one point
-
-#ifdef USE_BEST
-    bestx=x;
-    besty=y;
-    xd=abs(x1+x2)/2;
-    yd=abs(y1+y2)/2;
-    bestd=xd>yd ? xd : yd;
-    bestn=0;                                   // needed if goal not reachable
-#endif
-
-    //
-    // Mark goal
-    //
-    unreachable=1;
-    // FIXME: we need only to mark the rectangle border!!
-    for( x=x1; x<=x2; ++x ) {
-        if( x > TheMap.Width ) {
-           continue;
-       }
-       for( y=y1; y<=y2; ++y ) {
-           if( y > TheMap.Height ) {
-               continue;
-           }
-           if( CanMoveToMask(x,y,mask) ) {     // reachable
-               matrix[x+y*w]=88;
-               unreachable=0;
-           } else {
-               matrix[x+y*w]=99;
-           }
-       }
-    }
-
-    // No point of the target area could be entered
-    IfDebug(
-       if( unreachable ) {
-           PfCounterNotReachable++;
-           MakeLocalMissile(MissileTypeGreenCross,
-               unit->X*TileSizeX+TileSizeX/2,unit->Y*TileSizeY+TileSizeY/2,
-               unit->X*TileSizeX+TileSizeX/2,unit->Y*TileSizeY+TileSizeY/2);
-       }
-    );
-
-#ifdef NEW_SHIPS
-    if( unit->Type->UnitType==UnitTypeLand ) {
-       add=0;
-    } else {
-       add=8;
-    }
-#else
-    add=0;
-#endif
-
-    //gx=(x1+x2)/2;
-    //gy=(y1+y2)/2;
-
-    //
-    // Push and pop points until reached.
-    //
-    for( ;; ) {
-       while( rp!=ep ) {
-           for( j=0; j<8; ++j ) {              // mark all neighbors
-               x=points[rp]  +Heading2X[j+add];
-               y=points[rp+1]+Heading2Y[j+add];
-               m=matrix+x+y*w;
-               if( *m ) {                      // already checked/goal
-                   if( *m==88 ) {              // Check if goal reached.
-                       PathTraceBack(matrix,(add>>3)+1,x,y,depth,path);
-                       IfDebug(
-                           PfCounterOk++;
-                           PfCounterDepth+=depth;
-                           PfCounterDepth/=2;
-                       );
-                       free(points);
-                       return depth;
-                   }
-                   continue;
-               }
-
-               //
-               //      Look if destination field is blocked.
-               //      Fields blocked by moving units, are considered free.
-               //
-               i=TheMap.Fields[x+y*TheMap.Width].Flags&mask;
-               if( i ) {               // unreachable
-                   // Blocked by non-moving in not first round
-                   DebugLevel3("%x - %x\n" _C_ mask _C_ i);
-                   if( depth==1 || (i&~(MapFieldLandUnit
-                               |MapFieldAirUnit|MapFieldSeaUnit)) ) {
-                       DebugLevel3("NO: %d,%d\n" _C_ x _C_ y);
-                       *m=99;
-                       continue;
-                   }
-                   goal=UnitCacheOnXY(x,y,unit->Type->UnitType);
-                   if( !goal ) {       // Should not happen.
-                       DebugLevel3Fn("%d %s: No goal for %d,%d on %d,%d?\n" _C_
-                               UnitNumber(unit) _C_ unit->Type->Ident _C_
-                               unit->X _C_ unit->Y _C_ x _C_ y);
-                       *m=99;
-                       DebugCheck( 1 );
-                       continue;
-                   }
-                   if( !goal->Moving ) {
-                       *m=99;
-                       continue;
-                   }
-               }
-
-               //
-               //      Reachable: push point on stack.
-               //
-               *m=n;
-               points[wp]=x;
-               points[wp+1]=y;
-               wp+=2;
-               if( wp>=size ) {        // round about
-                   wp=0;
-               }
-
-#if 0
-               //
-               //      Save nearest point to target.
-               //
-               //xd=abs(gx-x);
-               //yd=abs(gy-y);
-               DebugLevel3("Best: %d,%d-%d - %d,%d\n" _C_ bestx _C_ besty _C_ 
bestd _C_ xd _C_ yd);
-               if( xd>yd && xd<bestd ) {
-                   bestd=xd;
-                   bestx=x;
-                   besty=y;
-                   bestn=depth;
-               }
-               if( yd>=xd && yd<bestd ) {
-                   bestd=yd;
-                   bestx=x;
-                   besty=y;
-                   bestn=depth;
-               }
-#endif
-           }
-
-           rp+=2;
-           if( rp>=size ) {    // round about
-               rp=0;
-           }
-       }
-       DebugLevel3("%d,%d\n" _C_ rp _C_ wp);
-
-       //
-       //      Continue with next frame.
-       //
-       if( rp==wp ) {                  // unreachable, no points available
-           break;
-       }
-       ep=wp;
-
-#if 0
-       //      FIXME: if we ignore distant units we run left-right
-       //      Ignore any units more than 5 fields from start.
-       if( depth>6 ) {
-           mask&=~(MapFieldLandUnit|MapFieldAirUnit|MapFieldSeaUnit);
-       }
-#endif
-
-       ++depth;
-       n=(depth&0x07)+1;
-    }
-
-    //
-    // We now move to the best reachable point.
-    //
-    DebugLevel3Fn("Unreachable Best %d,%d -> %d=%d,%d\n" _C_
-         unit->X _C_ unit->Y _C_ bestn _C_ bestx _C_ besty);
-
-    IfDebug(
-       PfCounterFail++;
-       PfCounterDepth+=depth;
-       PfCounterDepth/=2;
-    );
-
-#ifdef USE_BEST
-    if( bestn ) {              // can move
-#if 0
-       //
-       //      This reduces the amount of unreachables.
-       //      FIXME: should this be handled by the caller????
-       //
-       if( unreachable && !unit->Orders[0].Goal ) {
-           unit->Orders[0].X=bestx;
-           unit->Orders[0].Y=besty;
-       }
-#endif
-       PathTraceBack(matrix,(add>>3)+1,bestx,besty,bestn,path);
-       free(points);
-       return INT_MAX;
-    }
-#endif
-       
-    free(points);
-    return PF_UNREACHABLE;
-}
-
-/**
 **     Find new path.
 **
 **     The destination could be an unit or a field.
@@ -900,132 +466,22 @@
 */
 global int NewPath(Unit* unit)
 {
-#if 0
-    int x;
-    int y;
-    const Unit* goal;
-    const UnitType* type;
-    int x1;
-    int y1;
-    int x2;
-    int y2;
-    int rx;
-    int ry;
-    int reachable;
-#endif
     int i;
     int gw;
     int gh;
     int gx;
     int gy;
-    int range;
+    int minrange;
+    int maxrange;
     char* path;
 
-#if 0
-    x=unit->X;
-    y=unit->Y;
-    goal=unit->Orders[0].Goal;
-    x1=unit->Orders[0].X;
-    y1=unit->Orders[0].Y;
-    rx=unit->Orders[0].RangeX;
-    ry=unit->Orders[0].RangeY;
-    unit->Data.Move.Length=0;
-
-    //
-    // Check if goal is already reached.
-    //
-    if( goal ) {                       // goal unit
-       // Increase range, so can move to edge of building
-       type=goal->Type;
-       DebugLevel3Fn("Goal: %s, Me: %s (range %d)\n" _C_ type->Ident _C_ 
unit->Type->Ident _C_ rx);
-       x1=goal->X-rx;
-       y1=goal->Y-ry;
-       x2=x1+rx+type->TileWidth;
-       y2=y1+ry+type->TileHeight;
-       DebugLevel3Fn("Unit %d,%d Goal %d,%d - %d,%d\n"
-               _C_ x _C_ y _C_ x1 _C_ y1 _C_ x2 _C_ y2);
-       if( x>=x1 && x<=x2 && y>=y1 && y<=y2 ) {
-           DebugLevel3Fn("Goal reached\n");
-           return PF_REACHED;
-       }
-    } else {                           // goal map field
-       x1=unit->Orders[0].X-rx;
-       x2=unit->Orders[0].X+rx;
-       y1=unit->Orders[0].Y-ry;
-       y2=unit->Orders[0].Y+ry;
-       DebugLevel3Fn("Location: Unit %d,%d (%d,%d,%d) Goal %d,%d - %d,%d\n"
-               _C_ x _C_ y _C_ unit->Orders[0].X _C_ unit->Orders[0].Y _C_ rx 
_C_ x1 _C_ y1 _C_ x2 _C_ y2);
-       if( x>=x1 && x<=x2 && y>=y1 && y<=y2 ) {
-           DebugLevel3Fn("Field reached\n");
-           return PF_REACHED;
-       }
-       // This reduces the processor use,
-       // If target isn't reachable and were are beside it
-       // FIXME: should be +2? for ships/flyers?
-#if 0
-       if( x>=x1-1 && x<=x2+1 && y>=y1-1 && y<=y2+1 ) {
-           if( !CheckedCanMoveToMask(x,y,UnitMovementMask(unit)) ) {
-               // target field blocked by something
-               DebugLevel1Fn("Unreachable\n");
-               return PF_UNREACHABLE;
-           }
-           unit->Data.Move.Fast=1;     // this could be handled fast
-       }
-#endif
-    }
-
-    // Ensure the pathfinder gets something that's on the map
-    if( x1 < 0 ) x1 = 0;
-    if( x2 >= TheMap.Width ) x2 = TheMap.Width-1;
-    if( y1 < 0 ) y1 = 0;
-    if( y2 >= TheMap.Height ) y2 = TheMap.Height-1;
-    // Find a reachable target
-    reachable=0;
-    for( x=x1;x<=x2;x++ ) {
-       if( CheckedCanMoveToMask(x,y1,UnitMovementMask(unit)) ||
-           CheckedCanMoveToMask(x,y2,UnitMovementMask(unit)) ) {
-           reachable=1;
-       }
-    }
-    for( y=y1;y<y2;y++ ) {
-       if( CheckedCanMoveToMask(x1,y,UnitMovementMask(unit)) ||
-           CheckedCanMoveToMask(x2,y,UnitMovementMask(unit)) ) {
-           reachable=1;
-       }
-    }
-    if( !reachable ) {
-       return PF_UNREACHABLE;
-    }
-    x=unit->X;
-    y=unit->Y;
-    if( x>=x1 && x<=x2 && y>=y1 && y<=y2 ) {
-       DebugLevel3Fn("Field reached\n");
-       return PF_REACHED;
-    }
-
-    //
-    // If possible, try fast.
-    //
-    if( unit->Data.Move.Fast ) {
-       if( (i=FastNewPath(unit,x1,y1,x2,y2))>=-1 ) {
-           // Fast works
-           // DebugCheck( *xdp==0 && *ydp==0 );
-           return i;
-       }
-       DebugLevel3Fn("Fallback to slow method\n");
-       unit->Data.Move.Fast=0;
-    }
-
-    //
-    // Fall back to slow complex method.
-    //
-#endif
     if( unit->Orders[0].Goal ) {
        gw=unit->Orders[0].Goal->Type->TileWidth-1;
        gh=unit->Orders[0].Goal->Type->TileHeight-1;
        gx=unit->Orders[0].Goal->X;
        gy=unit->Orders[0].Goal->Y;
-       range=unit->Orders[0].RangeX;
+       maxrange=unit->Orders[0].RangeX;
+       minrange=unit->Orders[0].MinRange;
        DebugCheck( unit->Orders[0].RangeX != unit->Orders[0].RangeY );
     } else {
        // Take care of non square goals :)
@@ -1034,26 +490,21 @@
        if( unit->Orders[0].IsRect ) {
            gw = unit->Orders[0].RangeX;
            gh = unit->Orders[0].RangeY;
-           range=0;
+           maxrange=0;
+           minrange=0;
        } else {
            gw=0;
            gh=0;
-           range=unit->Orders[0].RangeX;
+           maxrange=unit->Orders[0].RangeX;
+           minrange=unit->Orders[0].MinRange;
        }
        gx=unit->Orders[0].X;
        gy=unit->Orders[0].Y;
     }
     path = unit->Data.Move.Path;
-    i=0;
-    if( AStarOn ) {
-       i=AStarFindPath(unit,gx,gy,gw,gh,range,path);
-       if( i == PF_FAILED ) {
-           i = PF_UNREACHABLE;
-       }
-#if 0  
-    } else {
-       i=ComplexNewPath(unit,x1,y1,x2,y2,path);
-#endif
+    i=AStarFindPath(unit,gx,gy,gw,gh,minrange,maxrange,path);
+    if( i == PF_FAILED ) {
+       i = PF_UNREACHABLE;
     }
 
     // Update path if it was requested. Otherwise we may only want




reply via email to

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