I found my agent crashing on tile-related callbacks.  Turns out
handle_tile_info() was passing a struct tile *, but enqueue_call() was
taking x and y coordinates.  This couldn't have helped the "core dumps
and memory corruption" referred to in
http://thread.gmane.org/gmane.games.freeciv.cvs/6285, but that's so
2004 I don't know if that's relevant here.

>From 91564bdd952b8c52af7d297de1d165f21fa4e913 Mon Sep 17 00:00:00 2001
From: berndj <ber...@localhost.localdomain>
Date: Thu, 11 Jun 2009 00:25:31 +0200
Subject: [PATCH] Fix type of argument extracted from varargs list.

(Was this killing the simple historian agent?)
---
 client/agents/agents.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/client/agents/agents.c b/client/agents/agents.c
index 60fd99d..fa8aad4 100644
--- a/client/agents/agents.c
+++ b/client/agents/agents.c
@@ -116,7 +116,8 @@ static void enqueue_call(struct my_agent *agent,
 {
   va_list ap;
   struct call *pcall2;
-  int x, y, arg = 0;
+  int arg = 0;
+  struct tile const *ptile;

   va_start(ap, cb_type);

@@ -130,9 +131,8 @@ static void enqueue_call(struct my_agent *agent,
     arg = va_arg(ap, int);
     break;
   case OCT_TILE:
-    x = va_arg(ap, int);
-    y = va_arg(ap, int);
-    arg = map_pos_to_index(x, y);
+    ptile = va_arg(ap, struct tile const *);
+    arg = ptile->index;
     break;
   case OCT_NEW_TURN:
     /* nothing */
-- 
1.5.6

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

Reply via email to