? civscore.log ? rand_pos.diff ? title.diff ? diff ? tinydent-1.11.4.tar.gz ? null_flags1.diff ? map_iterate.diff ? map_iterate2.diff ? mapgen1.diff ? log ? base_real_map_distance.diff ? map_distance_vector1.diff ? air_goto.diff ? air_goto2.diff ? unit_move_turns1.diff ? data/tinydent ? data/tinydent.tilespec ? data/tinydent.mod ? data/tinydent1.diff Index: ai/aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.158 diff -u -r1.158 aiunit.c --- ai/aiunit.c 2001/11/05 01:59:59 1.158 +++ ai/aiunit.c 2001/11/22 17:03:01 @@ -133,28 +133,51 @@ } /********************************************************************** - ... + Returns the minimal amount of turns required to reach the given + destination position. It will only be accurate for air units. For + all other units it can only produce an estimation. Things like + railroad, roads will make the actual move cost lower than the given + estimation. Mountains, swamps will increase actual move cost. ***********************************************************************/ static int unit_move_turns(struct unit *punit, int x, int y) { - int m, d; - m = unit_type(punit)->move_rate; - if (unit_flag(punit, F_IGTER)) m *= SINGLE_MOVE; - if(is_sailing_unit(punit)) { - struct player *pplayer = unit_owner(punit); - if (player_owns_active_wonder(pplayer, B_LIGHTHOUSE)) - m += SINGLE_MOVE; - if (player_owns_active_wonder(pplayer, B_MAGELLAN)) - m += (improvement_variant(B_MAGELLAN)==1) ? SINGLE_MOVE : 2 * SINGLE_MOVE; - m += player_knows_techs_with_flag(pplayer,TF_BOAT_FAST) * SINGLE_MOVE; - } + int result, move_rate = unit_type(punit)->move_rate; + + switch (unit_type(punit)->move_type) { + case LAND_MOVING: + if (unit_flag(punit, F_IGTER)) { + move_rate *= SINGLE_MOVE; + } + result = warmap.cost[x][y] / move_rate; + break; + + case SEA_MOVING: + if (player_owns_active_wonder(unit_owner(punit), B_LIGHTHOUSE)) { + move_rate += SINGLE_MOVE; + } + if (player_owns_active_wonder(unit_owner(punit), B_MAGELLAN)) { + move_rate += (improvement_variant(B_MAGELLAN) == 1) ? + SINGLE_MOVE : 2 * SINGLE_MOVE; + } + if (player_knows_techs_with_flag(unit_owner(punit), TF_BOAT_FAST)) { + move_rate += SINGLE_MOVE; + } + result = warmap.seacost[x][y] / move_rate; + break; - if (unit_type(punit)->move_type == LAND_MOVING) - d = warmap.cost[x][y] / m; - else if (unit_type(punit)->move_type == SEA_MOVING) - d = warmap.seacost[x][y] / m; - else d = real_map_distance(punit->x, punit->y, x, y) * SINGLE_MOVE / m; - return(d); + case HELI_MOVING: + case AIR_MOVING: + result = + real_map_distance(punit->x, punit->y, x, + y) * SINGLE_MOVE / move_rate; + break; + + default: + assert(0); + exit(1); + result = -1; + } + return result; } /**************************************************************************