Author: cazfi Date: Tue May 10 17:48:49 2016 New Revision: 32652 URL: http://svn.gna.org/viewcvs/freeciv?rev=32652&view=rev Log: Dropped special casing of barbarians from diplstate checks. Their diplstates should always be correctly set.
See patch #7200 Modified: branches/S2_6/common/player.c Modified: branches/S2_6/common/player.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/player.c?rev=32652&r1=32651&r2=32652&view=diff ============================================================================== --- branches/S2_6/common/player.c (original) +++ branches/S2_6/common/player.c Tue May 10 17:48:49 2016 @@ -1230,13 +1230,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; } @@ -1256,10 +1257,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); @@ -1276,9 +1273,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); @@ -1288,31 +1282,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); } @@ -1337,11 +1330,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