diff -Nurd -X.diff_ignore freeciv/common/dataio.c freeciv/common/dataio.c
--- freeciv/common/dataio.c	2009-11-03 13:24:46.000000000 +0200
+++ freeciv/common/dataio.c	2012-08-01 04:30:49.000000000 +0300
@@ -406,7 +406,7 @@
  Receive uint8 value to dest. In case of failure, value stored to dest
  will be zero. Note that zero is legal value even when there is no failure.
 **************************************************************************/
-void dio_get_uint8(struct data_in *din, int *dest)
+bool dio_get_uint8(struct data_in *din, int *dest)
 {
   if (enough_data(din, 1)) {
     if (dest) {
@@ -419,14 +419,18 @@
     din->current++;
   } else if (dest) {
     *dest = 0;
+
+    return FALSE;
   }
+
+  return TRUE;
 }
 
 /**************************************************************************
  Receive uint16 value to dest. In case of failure, value stored to dest
  will be zero. Note that zero is legal value even when there is no failure.
 **************************************************************************/
-void dio_get_uint16(struct data_in *din, int *dest)
+bool dio_get_uint16(struct data_in *din, int *dest)
 {
   if (enough_data(din, 2)) {
     if (dest) {
@@ -439,14 +443,18 @@
     din->current += 2;
   } else if (dest) {
     *dest = 0;
+
+    return FALSE;
   }
+
+  return TRUE;
 }
 
 /**************************************************************************
  Receive uint32 value to dest. In case of failure, value stored to dest
  will be zero. Note that zero is legal value even when there is no failure.
 **************************************************************************/
-void dio_get_uint32(struct data_in *din, int *dest)
+bool dio_get_uint32(struct data_in *din, int *dest)
 {
   if (enough_data(din, 4)) {
     if (dest) {
@@ -459,17 +467,22 @@
     din->current += 4;
   } else if (dest) {
     *dest = 0;
+
+    return FALSE;
   }
+
+  return TRUE;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_bool8(struct data_in *din, bool * dest)
+bool dio_get_bool8(struct data_in *din, bool * dest)
 {
   int ival;
+  bool retval;
 
-  dio_get_uint8(din, &ival);
+  retval = dio_get_uint8(din, &ival);
 
   if (ival != 0 && ival != 1) {
     freelog(LOG_ERROR, "Received value isn't boolean: %d", ival);
@@ -477,16 +490,19 @@
   }
 
   *dest = (ival != 0);
+
+  return retval;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_bool32(struct data_in *din, bool * dest)
+bool dio_get_bool32(struct data_in *din, bool * dest)
 {
   int ival = 0;
+  bool retval;
 
-  dio_get_uint32(din, &ival);
+  retval = dio_get_uint32(din, &ival);
 
   if (ival != 0 && ival != 1) {
     freelog(LOG_ERROR, "Received value isn't boolean: %d", ival);
@@ -494,57 +510,69 @@
   }
 
   *dest = (ival != 0);
+
+  return retval;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_sint8(struct data_in *din, int *dest)
+bool dio_get_sint8(struct data_in *din, int *dest)
 {
   int tmp;
+  bool retval;
 
-  dio_get_uint8(din, &tmp);
+  retval = dio_get_uint8(din, &tmp);
   if (dest) {
     if (tmp > 0x7f) {
       tmp -= 0x100;
     }
     *dest = tmp;
   }
+
+  return retval;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_sint16(struct data_in *din, int *dest)
+bool dio_get_sint16(struct data_in *din, int *dest)
 {
   int tmp = 0;
+  bool retval;
 
-  dio_get_uint16(din, &tmp);
+  retval = dio_get_uint16(din, &tmp);
   if (dest) {
     if (tmp > 0x7fff) {
       tmp -= 0x10000;
     }
     *dest = tmp;
   }
+
+  return retval;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_memory(struct data_in *din, void *dest, size_t dest_size)
+bool dio_get_memory(struct data_in *din, void *dest, size_t dest_size)
 {
   if (enough_data(din, dest_size)) {
     if (dest) {
       memcpy(dest, ADD_TO_POINTER(din->src, din->current), dest_size);
     }
     din->current += dest_size;
+  } else {
+    return FALSE;
   }
+
+  return TRUE;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_string(struct data_in *din, char *dest, size_t max_dest_size)
+bool dio_get_string(struct data_in *din, char *dest, size_t max_dest_size)
 {
   char *c;
   size_t ps_len;		/* length in packet, not including null */
@@ -554,7 +582,7 @@
 
   if (!enough_data(din, 1)) {
     dest[0] = '\0';
-    return;
+    return FALSE;
   }
 
   remaining = dio_input_remaining(din);
@@ -580,37 +608,40 @@
   if (!din->too_short) {
     din->current += (ps_len + 1);	/* past terminator */
   }
+
+  return TRUE;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_bit_string(struct data_in *din, char *dest,
+bool dio_get_bit_string(struct data_in *din, char *dest,
 			size_t max_dest_size)
 {
   int npack = 0;		/* number claimed in packet */
   int i;			/* iterate the bytes */
+  bool retval;
 
   assert(dest != NULL && max_dest_size > 0);
 
   if (!enough_data(din, 1)) {
     dest[0] = '\0';
-    return;
+    return FALSE;
   }
 
-  dio_get_uint16(din, &npack);
+  retval = dio_get_uint16(din, &npack);
   if (npack >= max_dest_size) {
       freelog(LOG_ERROR, "Have size for %lu, got %d",
               (unsigned long)max_dest_size, npack);
     din->bad_bit_string = TRUE;
     dest[0] = '\0';
-    return;
+    return FALSE;
   }
 
   for (i = 0; i < npack;) {
     int bit, byte_value;
 
-    dio_get_uint8(din, &byte_value);
+    retval = dio_get_uint8(din, &byte_value);
     for (bit = 0; bit < 8 && i < npack; bit++, i++) {
       if (TEST_BIT(byte_value, bit)) {
 	dest[i] = '1';
@@ -625,17 +656,20 @@
   if (din->too_short) {
     din->bad_bit_string = TRUE;
   }
+
+  return retval;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_tech_list(struct data_in *din, int *dest)
+bool dio_get_tech_list(struct data_in *din, int *dest)
 {
   int i;
+  bool retval;
 
   for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
-    dio_get_uint8(din, &dest[i]);
+    retval = dio_get_uint8(din, &dest[i]);
     if (dest[i] == A_LAST) {
       break;
     }
@@ -644,56 +678,66 @@
   for (; i < MAX_NUM_TECH_LIST; i++) {
     dest[i] = A_LAST;
   }
+
+  return retval;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_worklist(struct data_in *din, struct worklist *pwl)
+bool dio_get_worklist(struct data_in *din, struct worklist *pwl)
 {
   int i, length;
+  bool retval;
 
   worklist_init(pwl);
 
-  dio_get_uint8(din, &length);
+  retval = dio_get_uint8(din, &length);
   for (i = 0; i < length; i++) {
     int identifier;
     int kind;
 
     dio_get_uint8(din, &kind);
-    dio_get_uint8(din, &identifier);
+    retval = dio_get_uint8(din, &identifier);
 
     worklist_append(pwl, universal_by_number(kind, identifier));
   }
+
+  return retval;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void dio_get_uint8_vec8(struct data_in *din, int **values, int stop_value)
+bool dio_get_uint8_vec8(struct data_in *din, int **values, int stop_value)
 {
   int count, inx;
+  bool retval;
 
-  dio_get_uint8(din, &count);
+  retval = dio_get_uint8(din, &count);
   if (values) {
     *values = fc_calloc((count + 1), sizeof(**values));
   }
   for (inx = 0; inx < count; inx++) {
-    dio_get_uint8(din, values ? &((*values)[inx]) : NULL);
+    retval = dio_get_uint8(din, values ? &((*values)[inx]) : NULL);
   }
   if (values) {
     (*values)[inx] = stop_value;
   }
+
+  return retval;
 }
 
 /**************************************************************************
  Receive vector of uint6 values.
 **************************************************************************/
-void dio_get_uint16_vec8(struct data_in *din, int **values, int stop_value)
+bool dio_get_uint16_vec8(struct data_in *din, int **values, int stop_value)
 {
   int count, inx;
+  bool retval;
+
+  retval = dio_get_uint8(din, &count);
 
-  dio_get_uint8(din, &count);
   if (values) {
     *values = fc_calloc((count + 1), sizeof(**values));
   }
@@ -703,14 +747,17 @@
   if (values) {
     (*values)[inx] = stop_value;
   }
+
+  return retval;
 }
 
 /**************************************************************************
   De-serialize a player diplomatic state.
 **************************************************************************/
-void dio_get_diplstate(struct data_in *din, struct player_diplstate *pds)
+bool dio_get_diplstate(struct data_in *din, struct player_diplstate *pds)
 {
   int value = 0;
+  bool retval;
 
   /* backward compatible order defined for this transaction */
   dio_get_uint8(din, &value);
@@ -720,8 +767,10 @@
   dio_get_uint8(din, &pds->has_reason_to_cancel);
   dio_get_uint16(din, &pds->first_contact_turn);
   value = 0;
-  dio_get_uint8(din, &value);
+  retval = dio_get_uint8(din, &value);
   pds->max_state = value;
+
+  return retval;
 }
 
 /**************************************************************************
@@ -742,18 +791,21 @@
 /**************************************************************************
   De-serialize a requirement.
 **************************************************************************/
-void dio_get_requirement(struct data_in *din, struct requirement *preq)
+bool dio_get_requirement(struct data_in *din, struct requirement *preq)
 {
   int type, range, value;
   bool survives, negated;
+  bool retval;
 
   dio_get_uint8(din, &type);
   dio_get_sint32(din, &value);
   dio_get_uint8(din, &range);
   dio_get_bool8(din, &survives);
-  dio_get_bool8(din, &negated);
+  retval = dio_get_bool8(din, &negated);
 
   *preq = req_from_values(type, range, survives, negated, value);
+
+  return retval;
 }
 
 /**************************************************************************
diff -Nurd -X.diff_ignore freeciv/common/dataio.h freeciv/common/dataio.h
--- freeciv/common/dataio.h	2008-03-09 20:25:43.000000000 +0200
+++ freeciv/common/dataio.h	2012-08-01 04:32:06.000000000 +0300
@@ -53,28 +53,28 @@
 
 /* gets */
 
-void dio_get_uint8(struct data_in *din, int *dest);
-void dio_get_uint16(struct data_in *din, int *dest);
-void dio_get_uint32(struct data_in *din, int *dest);
+bool dio_get_uint8(struct data_in *din, int *dest);
+bool dio_get_uint16(struct data_in *din, int *dest);
+bool dio_get_uint32(struct data_in *din, int *dest);
 
-void dio_get_sint8(struct data_in *din, int *dest);
-void dio_get_sint16(struct data_in *din, int *dest);
+bool dio_get_sint8(struct data_in *din, int *dest);
+bool dio_get_sint16(struct data_in *din, int *dest);
 #define dio_get_sint32(d,v) dio_get_uint32(d,v)
 
 
-void dio_get_bool8(struct data_in *din, bool *dest);
-void dio_get_bool32(struct data_in *din, bool *dest);
-void dio_get_memory(struct data_in *din, void *dest, size_t dest_size);
-void dio_get_string(struct data_in *din, char *dest, size_t max_dest_size);
-void dio_get_bit_string(struct data_in *din, char *dest,
+bool dio_get_bool8(struct data_in *din, bool *dest);
+bool dio_get_bool32(struct data_in *din, bool *dest);
+bool dio_get_memory(struct data_in *din, void *dest, size_t dest_size);
+bool dio_get_string(struct data_in *din, char *dest, size_t max_dest_size);
+bool dio_get_bit_string(struct data_in *din, char *dest,
 			size_t max_dest_size);
-void dio_get_tech_list(struct data_in *din, int *dest);
-void dio_get_worklist(struct data_in *din, struct worklist *pwl);
-void dio_get_diplstate(struct data_in *din, struct player_diplstate *pds);
-void dio_get_requirement(struct data_in *din, struct requirement *preq);
+bool dio_get_tech_list(struct data_in *din, int *dest);
+bool dio_get_worklist(struct data_in *din, struct worklist *pwl);
+bool dio_get_diplstate(struct data_in *din, struct player_diplstate *pds);
+bool dio_get_requirement(struct data_in *din, struct requirement *preq);
 
-void dio_get_uint8_vec8(struct data_in *din, int **values, int stop_value);
-void dio_get_uint16_vec8(struct data_in *din, int **values, int stop_value);
+bool dio_get_uint8_vec8(struct data_in *din, int **values, int stop_value);
+bool dio_get_uint16_vec8(struct data_in *din, int **values, int stop_value);
 
 /* Should be a function but we need some macro magic. */
 #define DIO_BV_GET(pdin, bv) \
diff -Nurd -X.diff_ignore freeciv/common/generate_packets.py freeciv/common/generate_packets.py
--- freeciv/common/generate_packets.py	2010-02-02 12:50:51.000000000 +0200
+++ freeciv/common/generate_packets.py	2012-08-01 04:33:28.000000000 +0300
@@ -486,11 +486,13 @@
 for (;;) {
   int i;
 
-  dio_get_uint8(&din, &i);
-  if(i == 255) {
+  if (!dio_get_uint8(&din, &i)) {
     break;
   }
-  if(i > %(array_size_u)s) {
+  if (i == 255) {
+    break;
+  }
+  if (i > %(array_size_u)s) {
     freelog(LOG_ERROR, "packets_gen.c: WARNING: ignoring intra array diff");
   } else {
     %(c)s
