Author: cazfi
Date: Sat Aug  1 00:45:10 2015
New Revision: 29284

URL: http://svn.gna.org/viewcvs/freeciv?rev=29284&view=rev
Log:
Made advance_by_number(A_FUTURE) to return valid advance structure.
This fixes receiving Future Tech from Darwin's Voyage in multiplayer ruleset.

See bug #23231

Modified:
    trunk/common/tech.c
    trunk/common/tech.h

Modified: trunk/common/tech.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/tech.c?rev=29284&r1=29283&r2=29284&view=diff
==============================================================================
--- trunk/common/tech.c (original)
+++ trunk/common/tech.c Sat Aug  1 00:45:10 2015
@@ -47,7 +47,7 @@
  * server/ruleset.c (for the server)
  * client/packhand.c (for the client)
  */
-struct advance advances[A_LAST];
+struct advance advances[A_LAST_EXISTING];
 
 static struct user_flag user_tech_flags[MAX_NUM_USER_TECH_FLAGS];
 
@@ -96,10 +96,12 @@
 **************************************************************************/
 struct advance *advance_by_number(const Tech_type_id atype)
 {
-  if (atype < 0 || atype >= game.control.num_tech_types) {
+  if (atype != A_FUTURE
+      && (atype < 0 || atype >= game.control.num_tech_types)) {
     /* This isn't an error; some callers depend on it. */
     return NULL;
   }
+
   return &advances[atype];
 }
 
@@ -368,6 +370,7 @@
 void techs_init(void)
 {
   struct advance *a_none = &advances[A_NONE];
+  struct advance *a_future = &advances[A_FUTURE];
   int i;
 
   memset(advances, 0, sizeof(advances));
@@ -384,6 +387,11 @@
   a_none->require[AR_ONE] = a_none;
   a_none->require[AR_TWO] = a_none;
   a_none->require[AR_ROOT] = A_NEVER;
+
+  name_set(&a_future->name, NULL, "Future");
+  a_future->require[AR_ONE] = A_NEVER;
+  a_future->require[AR_TWO] = A_NEVER;
+  a_future->require[AR_ROOT] = A_NEVER;
 }
 
 /***************************************************************

Modified: trunk/common/tech.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/tech.h?rev=29284&r1=29283&r2=29284&view=diff
==============================================================================
--- trunk/common/tech.h (original)
+++ trunk/common/tech.h Sat Aug  1 00:45:10 2015
@@ -43,8 +43,9 @@
 #define A_NONE 0
 #define A_FIRST 1
 #define A_LAST MAX_NUM_ITEMS /* Used in the network protocol. */
-#define A_UNSET (A_LAST + 1)
-#define A_FUTURE (A_LAST + 2)
+#define A_FUTURE (A_LAST + 1)
+#define A_LAST_EXISTING A_FUTURE
+#define A_UNSET (A_LAST + 2)
 #define A_UNKNOWN (A_LAST + 3)
 
 #define A_NEVER (NULL)


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to