Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2005:
[Freeciv-Dev] Re: (PR#13833) SEGV in movement.c
Home

[Freeciv-Dev] Re: (PR#13833) SEGV in movement.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#13833) SEGV in movement.c
From: "White Raven" <whraven@xxxxxxxxxxxxxxxx>
Date: Thu, 1 Sep 2005 14:06:34 -0700
Reply-to: bugs@xxxxxxxxxxx

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

On Thu, 2005-09-01 at 13:38 -0700, Jason Short wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13833 >
> 
> White Raven wrote:
> > <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13833 >
> > 
> > CVS version of 1 September 2005:
> > 
> > Start a game; immediate SEGV.
> > 
> > It appears that unit class is not properly initialized.  If understand
> > correctly, it should be initialized in packhand.c, but it looks like
> > there is no corresponding field in the packet_ruleset_unit structure.
> 
> Indeed.  This is apparently a long-standing (post-2.0) bug.  The unit 
> class isn't sent to the client.  Thus all unit classes were 0 (NULL) 
> causing all units to behave (in some ways...not much since the unit 
> class doesn't do much yet) like a Missile (crash).
> 
> This patch fixes it.  I will commit immediately.

Interesting.  Your patch adds a unit-id to the packet, plus a function
to recreate the class struct from it.  I had worked out a patch I was
about to send that added a string class field to the packet, and used
existing functions to get the string from the class on the server side,
and recreate the class from the string on the client side.  However, I
did forget about modifying capstr.c (I'm still new to freeciv coding).
Just for fun, here's my version:

--- client/packhand.c   30 Aug 2005 20:06:27 -0000      1.545
+++ client/packhand.c   1 Sep 2005 20:41:37 -0000
@@ -2104,6 +2104,7 @@
     u->veteran[i].move_bonus = p->move_bonus[i];
   }
  
+  u->class = unit_class_from_str(p->class);
   u->helptext = mystrdup(p->helptext);
  
   tileset_setup_unit_type(tileset, u);
--- common/packets.def  20 Aug 2005 19:53:40 -0000      1.153
+++ common/packets.def  1 Sep 2005 20:41:39 -0000
@@ -1070,6 +1070,7 @@
  
   UINT8 bombard_rate;
  
+  STRING class[MAX_LEN_NAME];
   STRING helptext[MAX_LEN_PACKET];
  
   BV_FLAGS flags;
--- server/ruleset.c    1 Sep 2005 02:47:52 -0000       1.281
+++ server/ruleset.c    1 Sep 2005 20:41:50 -0000
@@ -2682,6 +2682,7 @@
       packet.power_fact[i] = u->veteran[i].power_fact;
       packet.move_bonus[i] = u->veteran[i].move_bonus;
     }
+    sz_strlcpy(packet.class, unit_class_name(u->class));
     if (u->helptext) {
       sz_strlcpy(packet.helptext, u->helptext);
     } else {





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