[Freeciv-Dev] Re: (PR#4200) two bugfixes to intelligence
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sun, May 11, 2003 at 01:26:48PM -0700, Per I. Mathisen wrote:
>
> On Sun, 11 May 2003, Raimar Falke wrote:
> > from common/tech.h:
> >
> > A_NONE is the root tech. All players always know this tech. It is
> > used as a flag in various cases where there is no tech-requirement.
> >
> > This would mix things again. We seperated A_* usage some months ago.
>
> It does not mix anything. It fits the bill exactly. All you know that
> player X has, is A_NONE.
>
> > So I change my opinion to: I'm for A_LAST or a new A_NOINFO (or
> > similar).
>
> Then we have to change 1) all clients and 2) tech.c. Then you make this a
> very big issue. I don't want to do that.
>
> If we send A_LAST or A_NOINFO, or anything other than A_NONE since it
> alone is a valid tech in this case, then the clients and client AIs have
> to special case this to avoid assert failures if they try to use this
> info. If we send A_NONE then no special casing will be needed. It does no
> harm to think player X is researching A_NONE. This is defensive
> programming.
See attached patch.
About the patch per se: I think we should document which data is set
in which info level.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
One nuclear bomb can ruin your whole day.
Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.169
diff -u -u -r1.169 civclient.c
--- client/civclient.c 2003/05/03 20:20:15 1.169
+++ client/civclient.c 2003/05/15 12:58:17
@@ -850,9 +850,7 @@
**************************************************************************/
bool can_intel_with_player(struct player *pplayer)
{
- return (pplayer->is_alive
- && pplayer != game.player_ptr
- && player_has_embassy(game.player_ptr, pplayer));
+ return could_intel_with_player(game.player_ptr, pplayer);
}
/**************************************************************************
Index: common/diptreaty.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.c,v
retrieving revision 1.15
diff -u -u -r1.15 diptreaty.c
--- common/diptreaty.c 2003/04/17 20:06:36 1.15
+++ common/diptreaty.c 2003/05/15 12:58:17
@@ -44,6 +44,19 @@
&& pplayer->is_connected);
}
+/**************************************************************************
+ Returns TRUE iff pplayer could do diplomatic meetings with aplayer.
+**************************************************************************/
+bool could_intel_with_player(struct player *pplayer, struct player *aplayer)
+{
+ return (pplayer->is_alive
+ && aplayer->is_alive
+ && pplayer != aplayer
+ && (pplayer->diplstates[aplayer->player_no].contact_turns_left > 0
+ || aplayer->diplstates[pplayer->player_no].contact_turns_left > 0
+ || player_has_embassy(pplayer, aplayer)));
+}
+
/****************************************************************
...
*****************************************************************/
Index: common/diptreaty.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.h,v
retrieving revision 1.10
diff -u -u -r1.10 diptreaty.h
--- common/diptreaty.h 2003/04/17 20:06:36 1.10
+++ common/diptreaty.h 2003/05/15 12:58:17
@@ -46,6 +46,7 @@
};
bool could_meet_with_player(struct player *pplayer, struct player *aplayer);
+bool could_intel_with_player(struct player *pplayer, struct player *aplayer);
void init_treaty(struct Treaty *ptreaty,
struct player *plr0, struct player *plr1);
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.62
diff -u -u -r1.62 tech.c
--- common/tech.c 2003/05/15 12:26:53 1.62
+++ common/tech.c 2003/05/15 12:58:18
@@ -542,7 +542,9 @@
{
static char buffer[200];
- if (!is_future_tech(tech)) {
+ if (tech == A_NOINFO) {
+ my_snprintf(buffer, sizeof(buffer), _("(Unknown)"));
+ } else if (!is_future_tech(tech)) {
assert(tech_exists(tech));
my_snprintf(buffer, sizeof(buffer), "%s", advances[tech].name);
} else {
Index: common/tech.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.h,v
retrieving revision 1.38
diff -u -u -r1.38 tech.h
--- common/tech.h 2003/01/13 23:27:12 1.38
+++ common/tech.h 2003/05/15 12:58:18
@@ -29,6 +29,7 @@
#define A_LAST MAX_NUM_ITEMS
#define A_UNSET (A_LAST-1)
#define A_FUTURE (A_LAST-2)
+#define A_NOINFO (A_LAST-3)
/*
A_NONE is the root tech. All players always know this tech. It is
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.271
diff -u -u -r1.271 plrhand.c
--- server/plrhand.c 2003/05/10 19:20:16 1.271
+++ server/plrhand.c 2003/05/15 12:58:21
@@ -1145,27 +1145,21 @@
info_level = min_info_level;
}
- if (info_level >= INFO_MEETING) {
+ for (i = A_FIRST; i < game.num_tech_types; i++) {
+ packet->inventions[i] = '0';
+ }
+ /* We have to inform the client that the other players also know
+ * A_NONE. */
+ packet->inventions[A_NONE] = plr->research.inventions[A_NONE].state + '0';
+ packet->inventions[i] = '\0';
+
+ if (info_level >= INFO_MINIMUM) {
packet->gold = plr->economic.gold;
- for (i = A_NONE; i < game.num_tech_types; i++) {
- packet->inventions[i] = plr->research.inventions[i].state + '0';
- }
packet->inventions[i] = '\0';
packet->government = plr->government;
} else {
packet->gold = 0;
- for (i = A_NONE; i < game.num_tech_types; i++) {
- packet->inventions[i] = '0';
- }
- /*
- * We have to inform the client that the other players also know
- * A_NONE.
- */
- packet->inventions[A_NONE] =
- plr->research.inventions[A_NONE].state + '0';
- packet->inventions[i] = '\0';
-
/* Ideally, we should check whether receiver really sees any cities owned
* by player before this. */
if (server_state == RUN_GAME_STATE) {
@@ -1177,6 +1171,9 @@
}
if (info_level >= INFO_EMBASSY) {
+ for (i = A_FIRST; i < game.num_tech_types; i++) {
+ packet->inventions[i] = plr->research.inventions[i].state + '0';
+ }
packet->tax = plr->economic.tax;
packet->science = plr->economic.science;
packet->luxury = plr->economic.luxury;
@@ -1205,7 +1202,7 @@
packet->luxury = 0;
packet->bulbs_researched= 0;
packet->techs_researched= 0;
- packet->researching = A_UNSET;
+ packet->researching = A_NOINFO;
packet->future_tech = 0;
packet->revolution = 0;
@@ -1268,7 +1265,7 @@
if (receiver && player_has_embassy(receiver, plr)) {
return INFO_EMBASSY;
}
- if (receiver && find_treaty(plr, receiver)) {
+ if (receiver && could_intel_with_player(receiver, plr)) {
return INFO_MEETING;
}
return INFO_MINIMUM;
[Freeciv-Dev] Re: (PR#4200) two bugfixes to intelligence, Per I. Mathisen, 2003/05/15
|
|