Bug #872 » 0008-Check-get_discounted_reward-return-value.patch
common/aicore/caravan.c | ||
---|---|---|
/************************************************************************//**
|
||
Initialize the result to go from src to dest with the given amount
|
||
of time. This is useful for calling get_discounted_reward and the such.
|
||
of time. This is useful for calling get_discounted_reward() and the such.
|
||
****************************************************************************/
|
||
static void caravan_result_init(struct caravan_result *result,
|
||
const struct city *src,
|
||
... | ... | |
} else if (a->value < b->value) {
|
||
return -1;
|
||
} else {
|
||
/* faster time is better, so reverse-sort on time. */
|
||
/* Faster time is better, so reverse-sort on time. */
|
||
return b->arrival_time - a->arrival_time ;
|
||
}
|
||
}
|
||
... | ... | |
}
|
||
pcity = tile_city(pos.tile);
|
||
if (pcity && callback(nmap, callback_data, pcity, turns_before + pos.turn,
|
||
pos.moves_left)) {
|
||
if (pcity != NULL
|
||
&& callback(nmap, callback_data, pcity, turns_before + pos.turn,
|
||
pos.moves_left)) {
|
||
break;
|
||
}
|
||
} pf_map_positions_iterate_end;
|
||
... | ... | |
struct goods_type *pgood;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* if no foreign trade is allowed, just quit. */
|
||
/* If no foreign trade is allowed, just quit. */
|
||
if (!does_foreign_trade_param_allow(parameter, pplayer_src, pplayer_dest)) {
|
||
caravan_result_init_zero(result);
|
||
return FALSE;
|
||
... | ... | |
if ((consider_trade
|
||
|| (consider_windfall
|
||
&& (!parameter->consider_trade /* can only enter marketplaces */
|
||
&& (!parameter->consider_trade /* Can only enter marketplaces */
|
||
/* (FIXME: test any extra restrictions for trade routes) */
|
||
/* or the result is so big that we are still in plus */
|
||
/* (consider having produced IF_GOLD instead) */
|
||
... | ... | |
if (does_foreign_trade_param_allow(param, src_owner, dest_owner)) {
|
||
city_list_iterate(dest_owner->cities, dest) {
|
||
caravan_result_init(¤t, pcity, dest, 0);
|
||
get_discounted_reward(caravan, param, ¤t);
|
||
if (caravan_result_compare(¤t, best) > 0) {
|
||
if (get_discounted_reward(caravan, param, ¤t)
|
||
&& caravan_result_compare(¤t, best) > 0) {
|
||
*best = current;
|
||
}
|
||
} city_list_iterate_end;
|
||
... | ... | |
caravan_result_init(¤t, data->best->src, dest, arrival_time);
|
||
get_discounted_reward(data->caravan, data->param, ¤t);
|
||
if (caravan_result_compare(¤t, data->best) > 0) {
|
||
if (get_discounted_reward(data->caravan, data->param, ¤t)
|
||
&& caravan_result_compare(¤t, data->best) > 0) {
|
||
*data->best = current;
|
||
}
|
||
return FALSE; /* don't stop. */
|
||
return FALSE; /* Don't stop. */
|
||
}
|
||
/************************************************************************//**
|
- « Previous
- 1
- 2
- Next »