Index: client/agents/agents.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/agents/agents.c,v retrieving revision 1.17 diff -u -r1.17 agents.c --- client/agents/agents.c 2002/09/10 14:01:07 1.17 +++ client/agents/agents.c 2002/09/12 12:35:55 @@ -41,7 +41,7 @@ struct my_agent *agent; enum oct { OCT_NEW_TURN, OCT_UNIT, OCT_CITY } type; enum callback_type cb_type; - void *arg; + int arg; }; #define SPECLIST_TAG call @@ -118,7 +118,7 @@ ***********************************************************************/ static void enqueue_call(struct my_agent *agent, enum oct type, - enum callback_type cb_type, void *arg) + enum callback_type cb_type, int arg) { struct call *pcall2; @@ -192,11 +192,9 @@ if (call->type == OCT_NEW_TURN) { call->agent->agent.turn_start_notify(); } else if (call->type == OCT_UNIT) { - call->agent->agent.unit_callbacks[call-> - cb_type] ((struct unit *) call->arg); + call->agent->agent.unit_callbacks[call->cb_type] (call->arg); } else if (call->type == OCT_CITY) { - call->agent->agent.city_callbacks[call-> - cb_type] ((struct city *) call->arg); + call->agent->agent.city_callbacks[call->cb_type] (call->arg); } else { assert(0); } @@ -414,7 +412,7 @@ continue; } if (agent->agent.turn_start_notify) { - enqueue_call(agent, OCT_NEW_TURN, CB_LAST, NULL); + enqueue_call(agent, OCT_NEW_TURN, CB_LAST, 0); } } /* @@ -447,7 +445,7 @@ continue; } if (agent->agent.unit_callbacks[CB_CHANGE]) { - enqueue_call(agent, OCT_UNIT, CB_CHANGE, punit); + enqueue_call(agent, OCT_UNIT, CB_CHANGE, punit->id); } } call_handle_methods(); @@ -473,7 +471,7 @@ continue; } if (agent->agent.unit_callbacks[CB_NEW]) { - enqueue_call(agent, OCT_UNIT, CB_NEW, punit); + enqueue_call(agent, OCT_UNIT, CB_NEW, punit->id); } } @@ -500,7 +498,7 @@ continue; } if (agent->agent.unit_callbacks[CB_REMOVE]) { - enqueue_call(agent, OCT_UNIT, CB_REMOVE, punit); + enqueue_call(agent, OCT_UNIT, CB_REMOVE, punit->id); } } @@ -525,7 +523,7 @@ continue; } if (agent->agent.city_callbacks[CB_CHANGE]) { - enqueue_call(agent, OCT_CITY, CB_CHANGE, pcity); + enqueue_call(agent, OCT_CITY, CB_CHANGE, pcity->id); } } call_handle_methods(); @@ -551,7 +549,7 @@ continue; } if (agent->agent.city_callbacks[CB_NEW]) { - enqueue_call(agent, OCT_CITY, CB_NEW, pcity); + enqueue_call(agent, OCT_CITY, CB_NEW, pcity->id); } } @@ -578,7 +576,7 @@ continue; } if (agent->agent.city_callbacks[CB_REMOVE]) { - enqueue_call(agent, OCT_CITY, CB_REMOVE, pcity); + enqueue_call(agent, OCT_CITY, CB_REMOVE, pcity->id); } } @@ -632,7 +630,7 @@ struct my_agent *agent = find_agent_by_name(name_of_calling_agent); assert(agent->agent.unit_callbacks[CB_CHANGE] != NULL); - enqueue_call(agent, OCT_UNIT, CB_CHANGE, punit); + enqueue_call(agent, OCT_UNIT, CB_CHANGE, punit->id); call_handle_methods(); } @@ -645,7 +643,7 @@ struct my_agent *agent = find_agent_by_name(name_of_calling_agent); assert(agent->agent.city_callbacks[CB_CHANGE] != NULL); - enqueue_call(agent, OCT_CITY, CB_CHANGE, pcity); + enqueue_call(agent, OCT_CITY, CB_CHANGE, pcity->id); call_handle_methods(); } Index: client/agents/agents.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/agents/agents.h,v retrieving revision 1.5 diff -u -r1.5 agents.h --- client/agents/agents.h 2002/09/10 14:01:07 1.5 +++ client/agents/agents.h 2002/09/12 12:35:55 @@ -36,8 +36,8 @@ int level; void (*turn_start_notify) (void); - void (*city_callbacks[CB_LAST]) (struct city *); - void (*unit_callbacks[CB_LAST]) (struct unit *); + void (*city_callbacks[CB_LAST]) (int); + void (*unit_callbacks[CB_LAST]) (int); }; void agents_init(void); Index: client/agents/cma_core.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v retrieving revision 1.29 diff -u -r1.29 cma_core.c --- client/agents/cma_core.c 2002/09/06 19:07:34 1.29 +++ client/agents/cma_core.c 2002/09/12 12:35:56 @@ -1041,6 +1041,13 @@ #endif } +/**************************************************************************** +... +*****************************************************************************/ +static void release_city(int city_id) +{ + attr_city_set(ATTR_CITY_CMA_PARAMETER, city_id, 0, NULL); +} /**************************************************************************** algorithmic functions @@ -1802,18 +1809,22 @@ /**************************************************************************** Callback for the agent interface. *****************************************************************************/ -static void city_changed(struct city *pcity) +static void city_changed(int city_id) { - clear_caches(pcity); - handle_city(pcity); + struct city *pcity = find_city_by_id(city_id); + + if (pcity) { + clear_caches(pcity); + handle_city(pcity); + } } /**************************************************************************** Callback for the agent interface. *****************************************************************************/ -static void city_remove(struct city *pcity) +static void city_remove(int city_id) { - cma_release_city(pcity); + release_city(city_id); } /**************************************************************************** @@ -1920,7 +1931,7 @@ *****************************************************************************/ void cma_release_city(struct city *pcity) { - attr_city_set(ATTR_CITY_CMA_PARAMETER, pcity->id, 0, NULL); + release_city(pcity->id); } /**************************************************************************** Index: client/agents/cma_fec.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_fec.c,v retrieving revision 1.9 diff -u -r1.9 cma_fec.c --- client/agents/cma_fec.c 2002/06/13 22:43:21 1.9 +++ client/agents/cma_fec.c 2002/09/12 12:35:56 @@ -61,9 +61,9 @@ Is called if the game removes a city. It will clear the "fe parameter" attribute to reduce the size of the savegame. *****************************************************************************/ -static void city_remove(struct city *pcity) +static void city_remove(int city_id) { - attr_city_set(ATTR_CITY_CMAFE_PARAMETER, pcity->id, 0, NULL); + attr_city_set(ATTR_CITY_CMAFE_PARAMETER, city_id, 0, NULL); } /**************************************************************************