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

On Thu, 9 Oct 2008 Egor Vyscrebentsov wrote:
> On Thu, 9 Oct 2008 Egor Vyscrebentsov wrote:
>
> > Quickest (not the best) fix is 
> > 
> > -          } else if (base_buf) {
> > +          } else if (base_buf && base_buf[j] != '?') {
> > 
> > at server/savegame.c:1862
> 
> After some thoughts I've decided that this fix is proper.

And after some more thoughts I've decided opposite...
Patch with more or less accurate workaround is attached.

There should be some action after each of two added LOG_ERRORs.
One variant is to abort civserver. Opinions?

-- 
Thanks, evyscr

Index: server/savegame.c
===================================================================
--- server/savegame.c	(revision 15253)
+++ server/savegame.c	(working copy)
@@ -1859,20 +1859,30 @@
             /* Either ACTIVITY_FORTRESS or ACTIVITY_AIRBASE */
             order->activity = ACTIVITY_BASE;
             order->base = base_number(pbase);
-          } else if (base_buf) {
-            base = char2num(base_buf[j]);
+	  } else if (order->activity == ACTIVITY_BASE) {
+	    if (base_buf) {
+	      if (base_buf[j] != '?') {
+		base = char2num(base_buf[j]);
 
-            if (base >= 0
-                && base < sizeof(base_order) / sizeof (struct base_type *)) {
-              pbase = base_order[base];
-            } else {
-              freelog(LOG_ERROR, "Cannot find base %d for %s to build",
-                      base, unit_rule_name(punit));
-              base = base_number(get_base_by_gui_type(BASE_GUI_FORTRESS, NULL, NULL));
-            }
+		if (base >= 0
+		    && base < sizeof(base_order) / sizeof (struct base_type *)) {
+		  pbase = base_order[base];
+		} else {
+		  freelog(LOG_ERROR, "Cannot find base %d for %s [%d] to build",
+			  base, unit_rule_name(punit), punit->id);
+		  base = base_number(get_base_by_gui_type(BASE_GUI_FORTRESS, NULL, NULL));
+		}
 
-            order->base = base;
-          }
+		order->base = base;
+	      } else {
+		freelog(LOG_ERROR, "%s [%d] has ACTIVITY_BASE but no base in base_list",
+			unit_rule_name(punit), punit->id);
+	      }
+	    } else {
+	      freelog(LOG_ERROR, "%s [%d] has ACTIVITY_BASE but no base_list",
+		      unit_rule_name(punit), punit->id);
+	    }
+	  }
 	}
       } else {
 	punit->has_orders = FALSE;
@@ -3470,7 +3480,7 @@
 	  break;
 	}
       }
-      orders_buf[len] = dir_buf[len] = act_buf[len] = '\0';
+      orders_buf[len] = dir_buf[len] = act_buf[len] = base_buf[len] = '\0';
 
       secfile_insert_str(file, orders_buf,
 			 "player%d.u%d.orders_list", plrno, i);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to