stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src include/unit.h ui/mouse.c unit/un...


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src include/unit.h ui/mouse.c unit/un...
Date: 31 Jan 2004 17:56:41 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/01/31 17:56:41

Modified files:
        src/include    : unit.h 
        src/ui         : mouse.c 
        src/unit       : unit.c 
        src/video      : cursor.c 

Log message:
        Fixed Bug #7294: Building cursor over hidden building

Patches:
Index: stratagus/src/include/unit.h
diff -u stratagus/src/include/unit.h:1.253 stratagus/src/include/unit.h:1.254
--- stratagus/src/include/unit.h:1.253  Sat Jan 31 01:02:48 2004
+++ stratagus/src/include/unit.h        Sat Jan 31 17:56:37 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: unit.h,v 1.253 2004/01/30 14:02:48 nobody_ Exp $
+//      $Id: unit.h,v 1.254 2004/01/31 06:56:37 wizzard Exp $
 
 #ifndef __UNIT_H__
 #define __UNIT_H__
@@ -840,6 +840,8 @@
 extern int CanBuildOn(int x, int y, int mask);
        /// FIXME: more docu
 extern int CanBuildUnitType(const Unit* unit,const UnitType* type, int x, int 
y);
+       /// FIXME: more docu
+extern int CanBuildUnitTypeMask(const Unit* unit,const UnitType* type, int x, 
int y, int mask);
 
        /// Find resource
 extern Unit* FindResource(const Unit* unit, int x, int y, int range, int 
resource);
Index: stratagus/src/ui/mouse.c
diff -u stratagus/src/ui/mouse.c:1.176 stratagus/src/ui/mouse.c:1.177
--- stratagus/src/ui/mouse.c:1.176      Sat Jan 31 02:14:50 2004
+++ stratagus/src/ui/mouse.c    Sat Jan 31 17:56:38 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mouse.c,v 1.176 2004/01/30 15:14:50 nobody_ Exp $
+//     $Id: mouse.c,v 1.177 2004/01/31 06:56:38 wizzard Exp $
 
 //@{
 
@@ -1447,7 +1447,8 @@
                                                }
                                        }
                                }
-                               if (CanBuildUnitType(Selected[0], 
CursorBuilding, x, y) &&
+                               if (CanBuildUnitTypeMask(Selected[0], 
CursorBuilding, x, y,
+                                       Selected[0]->Type->MovementMask & 
~(MapFieldBuilding | MapFieldLandUnit | MapFieldSeaUnit)) &&
                                                (explored || ReplayRevealMap)) {
                                        
PlayGameSound(GameSounds.PlacementSuccess.Sound,
                                                MaxSampleVolume);
Index: stratagus/src/unit/unit.c
diff -u stratagus/src/unit/unit.c:1.384 stratagus/src/unit/unit.c:1.385
--- stratagus/src/unit/unit.c:1.384     Sat Jan 31 02:14:51 2004
+++ stratagus/src/unit/unit.c   Sat Jan 31 17:56:39 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: unit.c,v 1.384 2004/01/30 15:14:51 nobody_ Exp $
+//      $Id: unit.c,v 1.385 2004/01/31 06:56:39 wizzard Exp $
 
 //@{
 
@@ -2087,10 +2087,25 @@
 */
 global int CanBuildUnitType(const Unit* unit, const UnitType* type, int x, int 
y)
 {
+       return CanBuildUnitTypeMask(unit, type, x, y, type->MovementMask);
+}
+/**
+**             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.
+**  @param mask  movement mask to check
+**             @return                         True if the building could be 
build..
+**
+**             @todo can't handle building units !1x1, needs a rewrite.
+*/
+global int CanBuildUnitTypeMask(const Unit* unit, const UnitType* type, int x, 
int y, int mask)
+{
        int w;
        int h;
        int j;
-       int mask;
        Player* player;
 
        // Terrain Flags don't matter.
@@ -2184,8 +2199,6 @@
        }
 #else
 
-       mask = type->MovementMask;
-
 #endif
 
        player = NULL;
@@ -3772,7 +3785,7 @@
        int j;
 
        CLprintf(file, "\n--- -----------------------------------------\n");
-       CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.384 2004/01/30 
15:14:51 nobody_ Exp $\n\n");
+       CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.385 2004/01/31 
06:56:39 wizzard Exp $\n\n");
 
 #if 0
        //
Index: stratagus/src/video/cursor.c
diff -u stratagus/src/video/cursor.c:1.97 stratagus/src/video/cursor.c:1.98
--- stratagus/src/video/cursor.c:1.97   Sat Jan 17 06:22:18 2004
+++ stratagus/src/video/cursor.c        Sat Jan 31 17:56:40 2004
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: cursor.c,v 1.97 2004/01/16 19:22:18 wizzard Exp $
+//      $Id: cursor.c,v 1.98 2004/01/31 06:56:40 wizzard Exp $
 
 //@{
 
@@ -546,12 +546,13 @@
                w = w0;
                while (w--) {
 
-                       // FIXME: The field is covered by fog of war!
                        if (f && (CursorBuilding->MustBuildOnTop ||
                                        CanBuildOn(mx + w, my + h, mask & 
((NumSelected &&
                                                !CursorBuilding->BuilderOutside 
&&
                                                Selected[0]->X == mx + w && 
Selected[0]->Y == my + h) ?
-                                                       ~(MapFieldLandUnit | 
MapFieldSeaUnit) : -1)))
+                                                       ~(MapFieldLandUnit | 
MapFieldSeaUnit) : -1) &
+                                               (IsTileVisible(ThisPlayer, mx + 
w, my + h) == 1 ? 
+                                               ~(MapFieldLandUnit | 
MapFieldSeaUnit | MapFieldBuilding) : -1)))
                                  && IsMapFieldExplored(ThisPlayer, mx + w, my 
+ h))  {
                                color = ColorGreen;
                        } else {
@@ -835,7 +836,7 @@
        int i;
 
        CLprintf(file, "\n;;; -----------------------------------------\n");
-       CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.97 2004/01/16 
19:22:18 wizzard Exp $\n\n");
+       CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.98 2004/01/31 
06:56:40 wizzard Exp $\n\n");
 
        for (i = 0; Cursors[i].OType; ++i) {
                CLprintf(file, "(define-cursor '%s '%s\n",




reply via email to

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