Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#11612) 0: tech "None": requires itself
Home

[Freeciv-Dev] (PR#11612) 0: tech "None": requires itself

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: marko.lindqvist@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#11612) 0: tech "None": requires itself
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 29 Mar 2005 21:20:37 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11612 >

The problem is A_NONE hasn't been set to TECH_KNOWN.  There was an
assertion on this at some point in update_research, but it was foolishly
removed without actually fixing the bug.  In fact trying to run
update_research if the root tech isn't known will give entirely wrong
results, so we must have either the assertion or set it manually (or both).

This patch just sets A_NONE to known when running update_research.


Now, as to why this happens:

#2  0x4070d26f in __assert_fail () from /lib/tls/libc.so.6
#3  0x080fd8e5 in build_required_techs_helper (pplayer=0x81879b0,
    tech=135661452, goal=1082244192) at tech.c:114
#4  0x080fd981 in build_required_techs (pplayer=0x81879b0, goal=0)
    at tech.c:138
#5  0x080fdb09 in update_research (pplayer=0x81879b0) at tech.c:212
#6  0x080725ad in set_client_state (newstate=CLIENT_GAME_RUNNING_STATE)
    at civclient.c:521
#7  0x0808a14d in handle_game_state (value=4) at packhand.c:350
#8  0x0808fadf in client_handle_packet (type=PACKET_PROCESSING_STARTED,
    packet=0x6) at packhand_gen.c:71

The problem is the player info for the controlled player (only) is sent
before the ruleset control packet.  So although the client is told what
techs are known by the player it isn't loaded properly.  This is
probably a serious bug in its own right (since it means tech data isn't
known by the client until the next player packet) and should be fixed. 
The second patch demonstrates the problem.

-jason

Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.85
diff -u -r1.85 tech.c
--- common/tech.c       27 Mar 2005 17:29:25 -0000      1.85
+++ common/tech.c       30 Mar 2005 05:07:25 -0000
@@ -191,12 +191,12 @@
 {
   enum tech_flag_id flag;
 
-  /* This assert does not work. Triggered by AI players in new
-   * games. */
-  /* assert(get_invention(pplayer, A_NONE) == TECH_KNOWN); */
-
   tech_type_iterate(i) {
-    if (!tech_is_available(pplayer, i)) {
+    if (i == A_NONE) {
+      /* This is set when the game starts, but not everybody finds out
+       * right away. */
+      set_invention(pplayer, i, TECH_KNOWN);
+    } else if (!tech_is_available(pplayer, i)) {
       set_invention(pplayer, i, TECH_UNKNOWN);
     } else {
       if (get_invention(pplayer, i) == TECH_REACHABLE) {
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.484
diff -u -r1.484 packhand.c
--- client/packhand.c   28 Mar 2005 17:14:57 -0000      1.484
+++ client/packhand.c   30 Mar 2005 05:19:13 -0000
@@ -1415,10 +1415,17 @@
 {
   bool need_effect_update = FALSE;
 
+  freelog(LOG_NORMAL, "Reading techs for %s | %s : %d techs",
+         pplayer->name, pplayer->username, game.num_tech_types);
   tech_type_iterate(i) {
     enum tech_state oldstate = pplayer->research->inventions[i].state;
     enum tech_state newstate = inventions[i] - '0';
 
+    if (i == A_NONE) {
+      freelog(LOG_NORMAL, "Player %s | %s state for A_NONE: %d",
+             pplayer->name, pplayer->username, newstate);
+    }
+
     pplayer->research->inventions[i].state = newstate;
     if (newstate != oldstate
        && (newstate == TECH_KNOWN || oldstate == TECH_KNOWN)) {
@@ -1466,6 +1473,9 @@
   char msg[MAX_LEN_MSG];
   struct player *pplayer = &game.players[pinfo->playerno];
 
+  freelog(LOG_NORMAL, "Handling player info for %s | %s ",
+         pinfo->name, pinfo->username);
+
   sz_strlcpy(pplayer->name, pinfo->name);
 
   pplayer->is_observer = pinfo->is_observer;
@@ -2095,6 +2105,8 @@
   game.government_when_anarchy = packet->government_when_anarchy;
   game.default_government = packet->default_government;
 
+  freelog(LOG_NORMAL, "packet ruleset control: setting tech types to %d",
+         packet->num_tech_types);
   game.num_unit_types = packet->num_unit_types;
   game.num_impr_types = packet->num_impr_types;
   game.num_tech_types = packet->num_tech_types;

[Prev in Thread] Current Thread [Next in Thread]