[Freeciv-Dev] Active Diplomat dumps core (with fix) (PR#1410)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
The active diplomat code appears to assume old map_get_city() behaviour
that checks for unreal coordinates and returns NULL.
Needs a simple fix to do this explictly in caller code now (like many
other places, particularly those assuming sanity is stored in goto_dest
:-).
Cheers,
RossW
=====
static void ai_manage_diplomat(struct player *pplayer, struct unit
*pdiplomat)
{
struct packet_diplomat_action dact;
- struct city *ctarget, *pcity;
+ struct city *pcity, *ctarget = NULL;
Unit_Type_id sanity = pdiplomat->id;
bool broken_goto = FALSE;
assert((pplayer != NULL) && (pdiplomat != NULL));
/* Look for someone to bribe */
broken_goto = ai_diplomat_bribe_nearby(pplayer, pdiplomat);
/* Sanity check */
if (find_unit_by_id(sanity) == NULL) { return; }
/* If we are the only diplomat in a threatened city, stay to defend it. */
pcity = map_get_city(pdiplomat->x, pdiplomat->y);
if ((pcity != NULL)
&& (count_diplomats_on_tile(pdiplomat->x, pdiplomat->y) == 1)
&& ((pcity->ai.urgency > 0) || (pcity->ai.diplomat_threat))) {
return;
}
/* Check if we can do the nasty diplomat stuff right now. */
- ctarget = map_get_city(pdiplomat->goto_dest_x, pdiplomat->goto_dest_y);
+ if(normalize_map_pos(&pdiplomat->goto_dest_x, &pdiplomat->goto_dest_y)) {
+ ctarget = map_get_city(pdiplomat->goto_dest_x, pdiplomat->goto_dest_y);
#ifdef DEBUG
freelog(LOG_DEBUG, "%s's diplomat %d aims for (%d,%d), and is at "
"(%d,%d) with distance %d to %s (owned by %s)",
pplayer->name, pdiplomat->id,
pdiplomat->goto_dest_x, pdiplomat->goto_dest_y, pdiplomat->x,
pdiplomat->y, real_map_distance(pdiplomat->x, pdiplomat->y,
pdiplomat->goto_dest_x, pdiplomat->goto_dest_y), ctarget ?
ctarget->name : "(none)", ctarget ? city_owner(ctarget)->name : "n/a");
#endif
+ }
if (ctarget && (real_map_distance(pdiplomat->x, pdiplomat->y,
pdiplomat->goto_dest_x, pdiplomat->goto_dest_y) == 1)
&& (pplayers_at_war(pplayer, city_owner(ctarget))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Active Diplomat dumps core (with fix) (PR#1410),
Ross W. Wetmore <=
|
|