stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src include/map.h map/map_fog.c ui/mo...


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src include/map.h map/map_fog.c ui/mo...
Date: 1 Feb 2004 13:15:01 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/02/01 13:15:00

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

Log message:
        Fix building placement, and filter flags for building placement

Patches:
Index: stratagus/src/include/map.h
diff -u stratagus/src/include/map.h:1.121 stratagus/src/include/map.h:1.122
--- stratagus/src/include/map.h:1.121   Fri Jan 30 20:49:38 2004
+++ stratagus/src/include/map.h Sun Feb  1 13:14:56 2004
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: map.h,v 1.121 2004/01/30 09:49:38 nobody_ Exp $
+//      $Id: map.h,v 1.122 2004/02/01 02:14:56 wizzard Exp $
 
 #ifndef __MAP_H__
 #define __MAP_H__
@@ -364,6 +364,8 @@
 //
 // in map_fog.c
 //
+       /// Filter map flags through fog
+extern int MapFogFilterFlags(Player* player, int x, int y, int mask);
        /// Mark a tile for normal sight
 extern void MapMarkTileSight(const Player* player, int x, int y);
        /// Unmark a tile for normal sight
Index: stratagus/src/map/map_fog.c
diff -u stratagus/src/map/map_fog.c:1.147 stratagus/src/map/map_fog.c:1.148
--- stratagus/src/map/map_fog.c:1.147   Tue Jan 27 09:00:59 2004
+++ stratagus/src/map/map_fog.c Sun Feb  1 13:14:57 2004
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: map_fog.c,v 1.147 2004/01/26 22:00:59 wizzard Exp $
+//      $Id: map_fog.c,v 1.148 2004/02/01 02:14:57 wizzard Exp $
 
 //@{
 
@@ -223,6 +223,36 @@
                return visiontype + TheMap.NoFogOfWar;
        }
        return 0;
+}
+
+/**
+**  Find out what the tile flags are a tile is covered by fog
+**
+**  @param player  player who is doing operation
+**  @param x       X map location
+**  @param y       Y map location
+**  @param mask    input mask to filter
+**
+**  @return        Filtered mask after taking fog into account
+*/
+global int MapFogFilterFlags(Player* player, int x, int y, int mask)
+{
+       int nunits;
+       int unitcount;
+       int fogmask;
+       Unit* table[UnitMax];
+       
+                       // Calculate Mask for tile with fog
+                       nunits = UnitCacheOnTile(x, y, table);
+                       fogmask = -1;
+                       unitcount = 0;
+                       while (unitcount < nunits) {
+                               if (!UnitVisibleAsGoal(table[unitcount], 
player)) {
+                                       fogmask &= 
~table[unitcount]->Type->FieldFlags;
+                               }
+                               ++unitcount;
+                       }
+       return mask & fogmask;
 }
 
 /**
Index: stratagus/src/ui/mouse.c
diff -u stratagus/src/ui/mouse.c:1.177 stratagus/src/ui/mouse.c:1.178
--- stratagus/src/ui/mouse.c:1.177      Sat Jan 31 17:56:38 2004
+++ stratagus/src/ui/mouse.c    Sun Feb  1 13:14:58 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: mouse.c,v 1.177 2004/01/31 06:56:38 wizzard Exp $
+//     $Id: mouse.c,v 1.178 2004/02/01 02:14:58 wizzard Exp $
 
 //@{
 
@@ -124,7 +124,7 @@
        // Unit selected isn't owned by the player.
        // You can't select your own units + foreign unit(s).
        //
-       if (!CanSelectMultipleUnits(Selected[0]->Player)) {
+       if (!CanSelectMultipleUnits(Selected[0]->Player) && 0) {
                return;
        }
 
@@ -1448,7 +1448,7 @@
                                        }
                                }
                                if (CanBuildUnitTypeMask(Selected[0], 
CursorBuilding, x, y,
-                                       Selected[0]->Type->MovementMask & 
~(MapFieldBuilding | MapFieldLandUnit | MapFieldSeaUnit)) &&
+                                       Selected[0]->Type->MovementMask) &&
                                                (explored || ReplayRevealMap)) {
                                        
PlayGameSound(GameSounds.PlacementSuccess.Sound,
                                                MaxSampleVolume);
Index: stratagus/src/unit/unit.c
diff -u stratagus/src/unit/unit.c:1.386 stratagus/src/unit/unit.c:1.387
--- stratagus/src/unit/unit.c:1.386     Sun Feb  1 05:35:57 2004
+++ stratagus/src/unit/unit.c   Sun Feb  1 13:14:59 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: unit.c,v 1.386 2004/01/31 18:35:57 jsalmon3 Exp $
+//      $Id: unit.c,v 1.387 2004/02/01 02:14:59 wizzard Exp $
 
 //@{
 
@@ -2106,6 +2106,7 @@
        int w;
        int h;
        int j;
+       int testmask;
        Player* player;
 
        // Terrain Flags don't matter.
@@ -2209,7 +2210,12 @@
 
        for (h = type->TileHeight; h--;) {
                for (w = type->TileWidth; w--;) {
-                       if (!CanBuildOn(x + w, y + h, mask)) {
+                       if (player) {
+                               testmask = MapFogFilterFlags(player, x + w, y + 
h, mask);
+                       } else {
+                               testmask = mask;
+                       }
+                       if (!CanBuildOn(x + w, y + h, testmask)) {
                                if (unit) {
                                        TheMap.Fields[unit->X + unit->Y * 
TheMap.Width].Flags |= j;
                                }
@@ -3787,7 +3793,7 @@
        int j;
 
        CLprintf(file, "\n--- -----------------------------------------\n");
-       CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.386 2004/01/31 
18:35:57 jsalmon3 Exp $\n\n");
+       CLprintf(file, "--- MODULE: units $Id: unit.c,v 1.387 2004/02/01 
02:14:59 wizzard Exp $\n\n");
 
 #if 0
        //
Index: stratagus/src/video/cursor.c
diff -u stratagus/src/video/cursor.c:1.98 stratagus/src/video/cursor.c:1.99
--- stratagus/src/video/cursor.c:1.98   Sat Jan 31 17:56:40 2004
+++ stratagus/src/video/cursor.c        Sun Feb  1 13:15:00 2004
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: cursor.c,v 1.98 2004/01/31 06:56:40 wizzard Exp $
+//      $Id: cursor.c,v 1.99 2004/02/01 02:15:00 wizzard Exp $
 
 //@{
 
@@ -545,14 +545,11 @@
        while (h--) {
                w = w0;
                while (w--) {
-
                        if (f && (CursorBuilding->MustBuildOnTop ||
-                                       CanBuildOn(mx + w, my + h, mask & 
((NumSelected &&
-                                               !CursorBuilding->BuilderOutside 
&&
+                                       CanBuildOn(mx + w, my + h, 
MapFogFilterFlags(ThisPlayer, mx + w, my + h, 
+                                               mask & ((NumSelected && 
!CursorBuilding->BuilderOutside &&
                                                Selected[0]->X == mx + w && 
Selected[0]->Y == my + h) ?
-                                                       ~(MapFieldLandUnit | 
MapFieldSeaUnit) : -1) &
-                                               (IsTileVisible(ThisPlayer, mx + 
w, my + h) == 1 ? 
-                                               ~(MapFieldLandUnit | 
MapFieldSeaUnit | MapFieldBuilding) : -1)))
+                                                       ~(MapFieldLandUnit | 
MapFieldSeaUnit) : -1))))
                                  && IsMapFieldExplored(ThisPlayer, mx + w, my 
+ h))  {
                                color = ColorGreen;
                        } else {
@@ -836,7 +833,7 @@
        int i;
 
        CLprintf(file, "\n;;; -----------------------------------------\n");
-       CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.98 2004/01/31 
06:56:40 wizzard Exp $\n\n");
+       CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.99 2004/02/01 
02:15:00 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]