Author: cazfi
Date: Tue May 10 17:48:44 2016
New Revision: 32651

URL: http://svn.gna.org/viewcvs/freeciv?rev=32651&view=rev
Log:
Dropped special casing of barbarians from diplstate checks.
Their diplstates should always be correctly set.

See patch #7200

Modified:
    trunk/common/player.c

Modified: trunk/common/player.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/player.c?rev=32651&r1=32650&r2=32651&view=diff
==============================================================================
--- trunk/common/player.c       (original)
+++ trunk/common/player.c       Tue May 10 17:48:44 2016
@@ -1233,13 +1233,14 @@
 bool pplayers_at_war(const struct player *pplayer,
                      const struct player *pplayer2)
 {
-  enum diplstate_type ds = player_diplstate_get(pplayer, pplayer2)->type;
+  enum diplstate_type ds;
+
   if (pplayer == pplayer2) {
     return FALSE;
   }
-  if (is_barbarian(pplayer) || is_barbarian(pplayer2)) {
-    return TRUE;
-  }
+
+  ds = player_diplstate_get(pplayer, pplayer2)->type;
+
   return ds == DS_WAR || ds == DS_NO_CONTACT;
 }
 
@@ -1259,10 +1260,6 @@
     return TRUE;
   }
 
-  if (is_barbarian(pplayer) || is_barbarian(pplayer2)) {
-    return FALSE;
-  }
-
   ds = player_diplstate_get(pplayer, pplayer2)->type;
 
   return (ds == DS_ALLIANCE || ds == DS_TEAM);
@@ -1279,9 +1276,6 @@
   if (pplayer == pplayer2) {
     return TRUE;
   }
-  if (is_barbarian(pplayer) || is_barbarian(pplayer2)) {
-    return FALSE;
-  }
 
   return (ds == DS_PEACE || ds == DS_ALLIANCE
           || ds == DS_ARMISTICE || ds == DS_TEAM);
@@ -1291,31 +1285,30 @@
   Returns TRUE if players can't enter each others' territory.
 ****************************************************************************/
 bool players_non_invade(const struct player *pplayer1,
-                       const struct player *pplayer2)
+                        const struct player *pplayer2)
 {
   if (pplayer1 == pplayer2 || !pplayer1 || !pplayer2) {
     return FALSE;
   }
-  if (is_barbarian(pplayer1) || is_barbarian(pplayer2)) {
-    /* Likely an unnecessary test. */
-    return FALSE;
-  }
+
   return player_diplstate_get(pplayer1, pplayer2)->type == DS_PEACE;
 }
 
 /***************************************************************
-  Returns true iff players have peace or cease-fire.
+  Returns true iff players have peace, cease-fire, or
+  armistice.
 ***************************************************************/
 bool pplayers_non_attack(const struct player *pplayer,
                          const struct player *pplayer2)
 {
-  enum diplstate_type ds = player_diplstate_get(pplayer, pplayer2)->type;
+  enum diplstate_type ds;
+
   if (pplayer == pplayer2) {
     return FALSE;
   }
-  if (is_barbarian(pplayer) || is_barbarian(pplayer2)) {
-    return FALSE;
-  }
+
+  ds = player_diplstate_get(pplayer, pplayer2)->type;
+
   return (ds == DS_PEACE || ds == DS_CEASEFIRE || ds == DS_ARMISTICE);
 }
 
@@ -1340,11 +1333,11 @@
   Return TRUE iff the two diplstates are equal.
 **************************************************************************/
 bool are_diplstates_equal(const struct player_diplstate *pds1,
-                         const struct player_diplstate *pds2)
+                          const struct player_diplstate *pds2)
 {
   return (pds1->type == pds2->type && pds1->turns_left == pds2->turns_left
-         && pds1->has_reason_to_cancel == pds2->has_reason_to_cancel
-         && pds1->contact_turns_left == pds2->contact_turns_left);
+          && pds1->has_reason_to_cancel == pds2->has_reason_to_cancel
+          && pds1->contact_turns_left == pds2->contact_turns_left);
 }
 
 /**************************************************************************


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to