[Freeciv-Dev] (PR#10121) pplayers_in_the_same_team
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#10121) pplayers_in_the_same_team |
From: |
"Mateusz Stefek" <mstefek@xxxxxxxxx> |
Date: |
Wed, 15 Sep 2004 01:46:24 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10121 >
This patch adds a new function pplayers_in_the_same_team() and use it in
several places. None of these places are speed-critical. No behavior is
changed even though I can see a mistake in PR#10086
--
mateusz
? ai/test
? server/civgame-3700.sav.gz
? server/civgame-3950.sav.gz
Index: ai/advdiplomacy.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdiplomacy.c,v
retrieving revision 1.39
diff -u -r1.39 advdiplomacy.c
--- ai/advdiplomacy.c 14 Sep 2004 19:06:02 -0000 1.39
+++ ai/advdiplomacy.c 15 Sep 2004 08:43:00 -0000
@@ -212,7 +212,7 @@
if (pplayers_allied(pplayer, aplayer)) {
worth /= 2;
}
- if (pplayer->team != TEAM_NONE && pplayer->team == aplayer->team) {
+ if (pplayers_in_the_same_team(pplayer, aplayer)) {
worth = 0;
break;
}
@@ -800,7 +800,7 @@
if (aplayer == pplayer
|| !aplayer->is_alive
|| ds == DS_NO_CONTACT
- || (pplayer->team != TEAM_NONE && pplayer->team == aplayer->team)
+ || pplayers_in_the_same_team(pplayer, aplayer)
|| (pplayer != ai->diplomacy.alliance_leader &&
aplayer != ai->diplomacy.alliance_leader &&
adip->is_allied_with_ally)
@@ -866,7 +866,7 @@
int index;
/* Only share techs with team mates */
- if (pplayer->team != TEAM_NONE && pplayer->team == aplayer->team) {
+ if (pplayers_in_the_same_team(pplayer, aplayer)) {
for (index = A_FIRST; index < game.num_tech_types; index++) {
if ((get_invention(pplayer, index) != TECH_KNOWN)
&& (get_invention(aplayer, index) == TECH_KNOWN)) {
@@ -957,7 +957,7 @@
struct player_spaceship *ship = &aplayer->spaceship;
if (!aplayer->is_alive || aplayer == pplayer
- || (pplayer->team != TEAM_NONE && aplayer->team == pplayer->team)
+ || pplayers_in_the_same_team(pplayer, aplayer)
|| ship->state == SSHIP_NONE) {
continue;
}
@@ -1094,7 +1094,7 @@
ai_share(pplayer, aplayer);
break;
case DS_ALLIANCE:
- if ((pplayer->team != TEAM_NONE && aplayer->team == pplayer->team)
+ if (pplayers_in_the_same_team(pplayer, aplayer)
|| (target && (!pplayers_at_war(pplayer, target)
|| pplayers_at_war(aplayer, target)))) {
/* Share techs only with team mates and _reliable_ allies.
Index: common/diptreaty.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.c,v
retrieving revision 1.24
diff -u -r1.24 diptreaty.c
--- common/diptreaty.c 14 Jul 2004 19:12:27 -0000 1.24
+++ common/diptreaty.c 15 Sep 2004 08:43:02 -0000
@@ -36,8 +36,7 @@
&& pplayer->ai.control
&& aplayer->ai.control)
|| (game.diplomacy == 3 /* Team diplomacy only */
- && pplayer->team != TEAM_NONE
- && pplayer->team == aplayer->team));
+ && pplayers_in_the_same_team(pplayer, aplayer)));
}
/**************************************************************************
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.152
diff -u -r1.152 player.c
--- common/player.c 14 Sep 2004 09:09:22 -0000 1.152
+++ common/player.c 15 Sep 2004 08:43:03 -0000
@@ -715,8 +715,17 @@
}
/**************************************************************************
-...
+ Return TRUE if players are in the same team
**************************************************************************/
+bool pplayers_in_the_same_team(const struct player *pplayer1,
+ const struct player *pplayer2)
+{
+ if (pplayer1->team == TEAM_NONE) {
+ return FALSE;
+ }
+ return (pplayer1->team == pplayer2->team);
+}
+
bool is_barbarian(const struct player *pplayer)
{
return pplayer->ai.barbarian_type != NOT_A_BARBARIAN;
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.123
diff -u -r1.123 player.h
--- common/player.h 13 Sep 2004 15:54:53 -0000 1.123
+++ common/player.h 15 Sep 2004 08:43:04 -0000
@@ -284,6 +284,8 @@
const struct player *pplayer2);
bool pplayers_non_attack(const struct player *pplayer,
const struct player *pplayer2);
+bool pplayers_in_the_same_team(const struct player *pplayer1,
+ const struct player *pplayer2);
int player_in_territory(struct player *pplayer, struct player *pplayer2);
bool is_barbarian(const struct player *pplayer);
Index: server/diplhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplhand.c,v
retrieving revision 1.83
diff -u -r1.83 diplhand.c
--- server/diplhand.c 14 Jul 2004 19:12:27 -0000 1.83
+++ server/diplhand.c 15 Sep 2004 08:43:10 -0000
@@ -283,7 +283,7 @@
break;
case CLAUSE_TEAM:
/* Limitation: Only for teams */
- if (pother->team == TEAM_NONE || pother->team != pplayer->team) {
+ if (!pplayers_in_the_same_team(pother, pplayer)) {
freelog(LOG_ERROR, "Attempted to make team in-game!");
goto cleanup;
}
Index: server/gamelog.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamelog.c,v
retrieving revision 1.34
diff -u -r1.34 gamelog.c
--- server/gamelog.c 3 Sep 2004 01:21:03 -0000 1.34
+++ server/gamelog.c 15 Sep 2004 08:43:10 -0000
@@ -164,8 +164,7 @@
if (!is_barbarian(pplayer)) {
if ((BV_ISSET_ANY(srvarg.draw)
&& BV_ISSET(srvarg.draw, pplayer->player_no))
- || (pplayer->team != TEAM_NONE
- && pplayer->team == highest_plr->team)) {
+ || pplayers_in_the_same_team(pplayer, highest_plr)) {
/* We win a shared victory, so equal the score. */
rank[count].value = highest;
}
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.322
diff -u -r1.322 plrhand.c
--- server/plrhand.c 14 Sep 2004 21:20:54 -0000 1.322
+++ server/plrhand.c 15 Sep 2004 08:43:13 -0000
@@ -1012,8 +1012,7 @@
/* Can't break alliance with a team member, but can reduce a team
* research to an alliance for stand-alone research. */
- if (pplayer->team != TEAM_NONE && pplayer->team == pplayer2->team
- && old_type != DS_TEAM) {
+ if (pplayers_in_the_same_team(pplayer, pplayer2) && old_type != DS_TEAM) {
return;
}
@@ -1149,7 +1148,7 @@
/* Check fall-out of a war declaration. */
players_iterate(other) {
if (other->is_alive && other != pplayer && other != pplayer2
- && (pplayer->team == TEAM_NONE || pplayer->team != pplayer2->team)
+ && !pplayers_in_the_same_team(pplayer, pplayer2)
&& new_type == DS_WAR && pplayers_allied(pplayer2, other)
&& pplayers_allied(pplayer, other)) {
/* If an ally declares war on another ally, break off your alliance
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.192
diff -u -r1.192 srv_main.c
--- server/srv_main.c 14 Sep 2004 03:48:01 -0000 1.192
+++ server/srv_main.c 15 Sep 2004 08:43:17 -0000
@@ -1818,7 +1818,7 @@
if (game.is_new_game) {
players_iterate(pplayer) {
players_iterate(pdest) {
- if (pplayer->team == pdest->team && pplayer->team != TEAM_NONE
+ if (pplayers_in_the_same_team(pplayer, pdest)
&& pplayer->player_no != pdest->player_no) {
pplayer->diplstates[pdest->player_no].type = DS_TEAM;
give_shared_vision(pplayer, pdest);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#10121) pplayers_in_the_same_team,
Mateusz Stefek <=
|
|