Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] (PR#7433) remove can_player_see_unit_at
Home

[Freeciv-Dev] (PR#7433) remove can_player_see_unit_at

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7433) remove can_player_see_unit_at
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 17 Feb 2004 12:47:12 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7433 >

We have can_player_see_unit_at and can_player_see_unit_at2.  This 
bothered me, so I looked at their users.  cpsua is only used by cpsua2. 
  So I removed cpsua, merged it in to cpsua2, and renamed cpsua2.

jason

Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.134
diff -u -r1.134 player.c
--- common/player.c     2004/02/14 02:36:48     1.134
+++ common/player.c     2004/02/17 20:45:52
@@ -257,36 +257,24 @@
   return player_can_see_unit_at_location(pplayer, punit, punit->x, punit->y);
 }
 
-/**************************************************************************
-  A helper function for send_info_to_onlookers below.  
+/****************************************************************************
   Checks if a unit can be seen by pplayer at (x,y).
   A player can see a unit if he:
   (a) can see the tile AND
   (b) can see the unit at the tile (i.e. unit not invisible at this tile) AND
-  (c) the unit is outside a city OR in an allied city
+  (c) the unit is outside a city OR in an allied city AND
+  (d) the unit isn't in a transporter, or we are allied AND
+  (e) the unit isn't in a transporter, or we can see the transporter
   
   TODO: the name is confusingly similar to player_can_see_unit_at_location
   But we need to rename p_c_s_u_a_t because it is really 
   is_unit_visible_to_player_at or player_ignores_unit_invisibility_at.
-**************************************************************************/
+****************************************************************************/
 bool can_player_see_unit_at(struct player *pplayer, struct unit *punit,
                            int x, int y)
 {
-  struct city *pcity = map_get_city(x, y);
+  struct city *pcity;
 
-  return ((map_get_known(x, y, pplayer) == TILE_KNOWN)
-         && player_can_see_unit_at_location(pplayer, punit, x, y)
-         && (!pcity || can_player_see_units_in_city(pplayer, pcity)));
-}
-
-/***************************************************************
-  Like can_player_see_unit_at but disallow looking into transporters
-  except you are the owner or were allowed by the owner with shared
-  vision.
-***************************************************************/
-bool can_player_see_unit_at2(struct player *pplayer, struct unit *punit,
-                            int x, int y)
-{
   /* Don't show non-allied units that are in transports.  This is logical
    * because allied transports can also contain our units.  Shared vision
    * isn't taken into account. */
@@ -295,7 +283,10 @@
     return FALSE;
   }
 
-  return can_player_see_unit_at(pplayer, punit, x, y);
+  pcity = map_get_city(x, y);
+  return ((map_get_known(x, y, pplayer) == TILE_KNOWN)
+         && player_can_see_unit_at_location(pplayer, punit, x, y)
+         && (!pcity || can_player_see_units_in_city(pplayer, pcity)));
 }
 
 /****************************************************************************
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.112
diff -u -r1.112 player.h
--- common/player.h     2004/02/05 08:23:09     1.112
+++ common/player.h     2004/02/17 20:45:52
@@ -230,9 +230,7 @@
                                      struct unit *punit, 
                                      int x, int y);
 bool can_player_see_unit_at(struct player *pplayer, struct unit *punit,
-                            int x, int y);
-bool can_player_see_unit_at2(struct player *pplayer, struct unit *punit,
-                            int x, int y);
+                           int x, int y);
 
 bool can_player_see_units_in_city(struct player *pplayer,
                                  struct city *pcity);
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.287
diff -u -r1.287 unithand.c
--- server/unithand.c   2004/01/28 06:02:44     1.287
+++ server/unithand.c   2004/02/17 20:45:53
@@ -735,10 +735,10 @@
       /* 
        * Remove the client knowledge of the units. 
        */
-      if (!can_player_see_unit_at2(other_player, punit, punit->x, punit->y)) {
+      if (!can_player_see_unit_at(other_player, punit, punit->x, punit->y)) {
        unit_goes_out_of_sight(other_player, punit);
       }
-      if (!can_player_see_unit_at2
+      if (!can_player_see_unit_at
          (other_player, pdefender, pdefender->x, pdefender->y)) {
        unit_goes_out_of_sight(other_player, pdefender);
       }
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.278
diff -u -r1.278 unittools.c
--- server/unittools.c  2004/02/07 11:16:50     1.278
+++ server/unittools.c  2004/02/17 20:45:54
@@ -1995,8 +1995,8 @@
        || pplayer->player_no == punit->owner) {
       send_packet_unit_info(pconn, &info);
     } else {
-      if (can_player_see_unit_at2(pplayer, punit, punit->x, punit->y)
-         || can_player_see_unit_at2(pplayer, punit, x, y)) {
+      if (can_player_see_unit_at(pplayer, punit, punit->x, punit->y)
+         || can_player_see_unit_at(pplayer, punit, x, y)) {
        send_packet_unit_short_info(pconn, &sinfo);
       } else {
        if (remove_unseen) {
@@ -3073,8 +3073,8 @@
    * the unit anymore.
    */
   players_iterate(pplayer) {
-    if (can_player_see_unit_at2(pplayer, punit, src_x, src_y)
-       && !can_player_see_unit_at2(pplayer, punit, dest_x, dest_y)) {
+    if (can_player_see_unit_at(pplayer, punit, src_x, src_y)
+       && !can_player_see_unit_at(pplayer, punit, dest_x, dest_y)) {
       unit_goes_out_of_sight(pplayer, punit);
     }
   } players_iterate_end;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7433) remove can_player_see_unit_at, Jason Short <=