Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#10477) problems with changing rulesets
Home

[Freeciv-Dev] (PR#10477) problems with changing rulesets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10477) problems with changing rulesets
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Mon, 7 Feb 2005 15:13:48 -0800
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Fri Oct 08 05:30:56 2004]:
> 
> I accidentally loaded a game in which I had a city building a 
> blacksmith, in a server using the current default ruleset (which has no 
> blacksmith).
> 
> Of course there will be an error.  But the error is a server crash.

Here is a patch.

Index: common/effects.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.c,v
retrieving revision 1.22
diff -u -r1.22 effects.c
--- common/effects.c    2 Feb 2005 02:44:31 -0000       1.22
+++ common/effects.c    7 Feb 2005 23:13:03 -0000
@@ -246,9 +246,17 @@
 **************************************************************************/
 struct effect_list *get_req_source_effects(struct req_source *psource)
 {
-  switch (psource->type) {
+  int type, value;
+
+  req_source_get_values(psource, &type, &value);
+
+  switch (type) {
   case REQ_BUILDING:
-    return ruleset_cache.reqs.buildings[psource->value.building];
+    if (value >= 0 && value < game.num_impr_types) {
+      return ruleset_cache.reqs.buildings[value];
+    } else {
+      return NULL;
+    }
   default:
     return NULL;
   }
@@ -798,17 +806,19 @@
     };
     struct effect_list *plist = get_req_source_effects(&source);
 
-    effect_list_iterate(plist, peffect) {
-      if (peffect->type != effect_type) {
-       continue;
-      }
-      if (is_effect_useful(TARGET_BUILDING, city_owner(pcity),
-                          pcity, id, NULL, id, peffect)) {
-       power += peffect->value;
-      }
-    } effect_list_iterate_end;
+    if (plist) {
+      effect_list_iterate(plist, peffect) {
+       if (peffect->type != effect_type) {
+         continue;
+       }
+       if (is_effect_useful(TARGET_BUILDING, city_owner(pcity),
+                            pcity, id, NULL, id, peffect)) {
+         power += peffect->value;
+       }
+      } effect_list_iterate_end;
 
-    return power;
+      return power;
+    }
   }
   return 0;
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#10477) problems with changing rulesets, Vasco Alexandre da Silva Costa <=