Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2005:
[Freeciv-Dev] (PR#11771) Uninitialised packet data with gen-specialists
Home

[Freeciv-Dev] (PR#11771) Uninitialised packet data with gen-specialists

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11771) Uninitialised packet data with gen-specialists
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Sun, 9 Jan 2005 14:37:24 -0800
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Thu Jan 06 00:38:20 2005]:
> 
> I think both your fixes are needed because there are two places where
> this data is sent.
> 
> - When specialist ruleset data is sent.
> - When city specialists are sent.
> 
> The former should eventually use separate packets per specialist.  The
> latter can just use an additional field (even though your patch zeroed
> it out); this actually saves a lot of space.  

Attached is a better fix, using an additional field.

Glip
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.86
diff -u -r1.86 packets.def
--- common/packets.def  6 Jan 2005 00:35:50 -0000       1.86
+++ common/packets.def  9 Jan 2005 22:36:23 -0000
@@ -397,8 +397,8 @@
 
   UINT8 ppl_happy[5], ppl_content[5], ppl_unhappy[5], ppl_angry[5];
 
-  # Make sure to set all fields here (even the unused ones)
-  UINT8 specialists[SP_MAX];
+  UINT8 specialists_size;
+  UINT8 specialists[SP_MAX:specialists_size];
 
   SINT16 surplus[O_MAX];
   UINT16 waste[O_MAX];
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.299
diff -u -r1.299 citytools.c
--- server/citytools.c  7 Jan 2005 14:28:38 -0000       1.299
+++ server/citytools.c  9 Jan 2005 22:36:24 -0000
@@ -1524,7 +1524,8 @@
     packet->ppl_unhappy[i]=pcity->ppl_unhappy[i];
     packet->ppl_angry[i]=pcity->ppl_angry[i];
   }
-  memset(packet->specialists, 0, sizeof(*(packet->specialists)) * SP_MAX);
+  /* The number of data in specilists[] array */
+  packet->specialists_size = SP_COUNT;
   specialist_type_iterate(sp) {
     packet->specialists[sp] = pcity->specialists[sp];
   } specialist_type_iterate_end;

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