Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Re: (PR#4351) Client crashes when diplomat/spy investigate
Home

[Freeciv-Dev] Re: (PR#4351) Client crashes when diplomat/spy investigate

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: cameron@xxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4351) Client crashes when diplomat/spy investigates city
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sun, 13 Jul 2003 13:10:06 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Fri, 11 Jul 2003, Jason Short wrote:
> unpackage_unit is grossly incomplete! Some fields in the packet are
> simply ignored.
>
> These were broken by this commit:
>
> revision 1.305
> date: 2003/05/05 12:41:39;author: per;  state: Exp;  lines: +6 -16
> Move virtual unit creation function from ai/aitools.c to common/game.c,
> and use it in both client and server for creation unit skeletons. This
> avoids duplication of code and allows client AI to use it to create
> virtual units.

The new function just isn't used everywhere it should be. Here is another
patch. Untested. Can be combined with above-mentioned patch for failsafe.

  - Per

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.311
diff -u -r1.311 packhand.c
--- client/packhand.c   11 Jul 2003 17:01:40 -0000      1.311
+++ client/packhand.c   13 Jul 2003 20:00:35 -0000
@@ -848,11 +848,13 @@
     }
     /* okay, append a unit struct to the proper list */
     if (packet->packet_use == UNIT_INFO_CITY_SUPPORTED) {
-      punit = fc_malloc(sizeof(struct unit));
+      punit = create_unit_virtual(get_player(packet->owner), NULL,
+                                  packet->type, packet->veteran);
       unpackage_unit(punit, packet);
       unit_list_insert(&(pcity->info_units_supported), punit);
     } else if (packet->packet_use == UNIT_INFO_CITY_PRESENT) {
-      punit = fc_malloc(sizeof(struct unit));
+      punit = create_unit_virtual(get_player(packet->owner), NULL,
+                                  packet->type, packet->veteran);
       unpackage_unit(punit, packet);
       unit_list_insert(&(pcity->info_units_present), punit);
     }

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