stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src action/command.c clone/unit.c pat...


From: Russell Smith
Subject: [Stratagus-CVS] stratagus/src action/command.c clone/unit.c pat...
Date: Tue, 11 Nov 2003 04:57:34 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Russell Smith <address@hidden>  03/11/11 04:57:33

Modified files:
        src/action     : command.c 
        src/clone      : unit.c 
        src/pathfinder : astar.c pathfinder.c 

Log message:
        Ensure you can't build if any red square appear. (Except for building 
unit)
        Ensure building inside units don't move away from building site to build

Patches:
Index: stratagus/src/action/command.c
diff -u stratagus/src/action/command.c:1.117 
stratagus/src/action/command.c:1.118
--- stratagus/src/action/command.c:1.117        Mon Nov 10 22:06:53 2003
+++ stratagus/src/action/command.c      Tue Nov 11 04:57:31 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: command.c,v 1.117 2003/11/11 03:06:53 n0body Exp $
+//     $Id: command.c,v 1.118 2003/11/11 09:57:31 mr-russ Exp $
 
 //@{
 
@@ -667,7 +667,7 @@
            order->Range = unit->Type->RepairRange;
        } else {
            // If building inside, but be next to stop
-           order->Range = 1;
+           order->Range = 0;
        }
        order->Type = what;
        if (what->BuilderOutside) {
Index: stratagus/src/clone/unit.c
diff -u stratagus/src/clone/unit.c:1.333 stratagus/src/clone/unit.c:1.334
--- stratagus/src/clone/unit.c:1.333    Tue Nov 11 04:24:01 2003
+++ stratagus/src/clone/unit.c  Tue Nov 11 04:57:32 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unit.c,v 1.333 2003/11/11 09:24:01 n0body Exp $
+//     $Id: unit.c,v 1.334 2003/11/11 09:57:32 mr-russ Exp $
 
 //@{
 
@@ -2168,6 +2168,7 @@
     int h;
     int j;
     int mask;
+    Player* player;
 
     // Terrain Flags don't matter.
     if (type->MustBuildOnTop) {
@@ -2264,6 +2265,12 @@
 
 #endif
 
+    player = NULL;
+
+    if (unit && unit->Player->Type == PlayerPerson) {
+       player = unit->Player;
+    }
+       
     for (h = type->TileHeight; h--;) {
        for (w = type->TileWidth; w--;) {
            if (!CanBuildOn(x + w, y + h, mask)) {
@@ -2272,6 +2279,9 @@
                }
                return 0;
            }
+           if (player && !IsMapFieldExplored(player, x + w, y + h)) {
+               return 0;
+           }
        }
     }
     if (unit) {
@@ -3838,7 +3848,7 @@
     int RunStart;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.333 2003/11/11 09:24:01 
n0body Exp $\n\n");
+    CLprintf(file, ";;; MODULE: units $Id: unit.c,v 1.334 2003/11/11 09:57:32 
mr-russ Exp $\n\n");
 
     //
     // Local variables
Index: stratagus/src/pathfinder/astar.c
diff -u stratagus/src/pathfinder/astar.c:1.52 
stratagus/src/pathfinder/astar.c:1.53
--- stratagus/src/pathfinder/astar.c:1.52       Sun Sep 14 02:53:08 2003
+++ stratagus/src/pathfinder/astar.c    Tue Nov 11 04:57:33 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: astar.c,v 1.52 2003/09/14 06:53:08 mr-russ Exp $
+//     $Id: astar.c,v 1.53 2003/11/11 09:57:33 mr-russ Exp $
 
 //@{
 
@@ -360,6 +360,27 @@
        }
     }
 
+    for (x = gx; x < gx + gy && !minrange; ++x) {
+       for (y = gy; y < gy + gh; ++y) {
+           if (x < 0 || x >= TheMap.Width || y < 0 || y >= TheMap.Height) {
+               continue;
+           }
+           if (CostMoveTo(unit, x, y, mask, AStarFixedUnitCrossingCost) >= 0) {
+               AStarMatrix[y * TheMap.Width + x].InGoal = 1;
+               goal_reachable = 1;
+           }
+           if (*num_in_close < Threshold) {
+               CloseSet[(*num_in_close)++] = y * TheMap.Width + x;
+           }
+       }
+    }
+
+    if (gw) {
+       gw--;
+    }
+    if (gh) {
+       gh--;
+    }
     // Mark top, bottom, left, right
     for(range=minrange; range <= maxrange; range++) {
        // Mark Top and Bottom of Goal
Index: stratagus/src/pathfinder/pathfinder.c
diff -u stratagus/src/pathfinder/pathfinder.c:1.58 
stratagus/src/pathfinder/pathfinder.c:1.59
--- stratagus/src/pathfinder/pathfinder.c:1.58  Thu Oct 23 14:38:36 2003
+++ stratagus/src/pathfinder/pathfinder.c       Tue Nov 11 04:57:33 2003
@@ -28,7 +28,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: pathfinder.c,v 1.58 2003/10/23 18:38:36 n0body Exp $
+//     $Id: pathfinder.c,v 1.59 2003/11/11 09:57:33 mr-russ Exp $
 
 //@{
 
@@ -470,8 +470,8 @@
     char* path;
 
     if( unit->Orders[0].Goal ) {
-       gw=unit->Orders[0].Goal->Type->TileWidth-1;
-       gh=unit->Orders[0].Goal->Type->TileHeight-1;
+       gw=unit->Orders[0].Goal->Type->TileWidth;
+       gh=unit->Orders[0].Goal->Type->TileHeight;
        gx=unit->Orders[0].Goal->X;
        gy=unit->Orders[0].Goal->Y;
        maxrange=unit->Orders[0].Range;




reply via email to

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