? diff ? all.diff Index: ai/aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.176 diff -u -r1.176 aiunit.c --- ai/aiunit.c 2002/02/22 13:14:38 1.176 +++ ai/aiunit.c 2002/02/22 15:30:29 @@ -317,7 +317,7 @@ if (map_get_continent(x1, y1) != continent) continue; - if (!can_unit_move_to_tile_with_notify(punit, x1, y1, FALSE)) + if (!can_unit_move_to_tile(punit, x1, y1, FALSE)) continue; /* We won't travel into cities, unless we are able to do so - diplomats @@ -2388,7 +2388,7 @@ square_iterate(leader->x, leader->y, 1, x, y) { if (warmap.cost[x][y] > safest - && can_unit_move_to_tile_with_notify(leader, x, y, FALSE)) { + && can_unit_move_to_tile(leader, x, y, FALSE)) { safest = warmap.cost[x][y]; freelog(LOG_DEBUG, "Barbarian leader: safest is %d, %d, safeness %d", x, y, Index: common/unit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v retrieving revision 1.151 diff -u -r1.151 unit.c --- common/unit.c 2002/02/22 13:14:44 1.151 +++ common/unit.c 2002/02/22 15:30:35 @@ -1211,15 +1211,16 @@ return zoc_ok_move_gen(punit, punit->x, punit->y, x, y); } -bool can_unit_move_to_tile(Unit_Type_id type, - struct player *unit_owner, - enum unit_activity activity, - bool connecting, int src_x, - int src_y, int dest_x, int dest_y, bool igzoc) +/************************************************************************** + Convenience wrapper for test_unit_move_to_tile. +**************************************************************************/ +bool can_unit_move_to_tile(struct unit *punit, int dest_x, int dest_y, + bool igzoc) { - return MR_OK == test_unit_move_to_tile(type, unit_owner, activity, - connecting, src_x, - src_y, dest_x, dest_y, igzoc); + return MR_OK == test_unit_move_to_tile(punit->type, unit_owner(punit), + punit->activity, punit->connecting, + punit->x, punit->y, dest_x, dest_y, + igzoc); } /************************************************************************** Index: common/unit.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v retrieving revision 1.83 diff -u -r1.83 unit.h --- common/unit.h 2002/02/14 15:17:22 1.83 +++ common/unit.h 2002/02/22 15:30:35 @@ -248,11 +248,8 @@ bool can_step_taken_wrt_to_zoc(Unit_Type_id type, struct player *unit_owner, int src_x, int src_y, int dest_x, int dest_y); -bool can_unit_move_to_tile(Unit_Type_id type, - struct player *unit_owner, - enum unit_activity activity, - bool connecting, int src_x, - int src_y, int dest_x, int dest_y, bool igzoc); +bool can_unit_move_to_tile(struct unit *punit, int dest_x, int dest_y, + bool igzoc); enum unit_move_result test_unit_move_to_tile(Unit_Type_id type, struct player *unit_owner, enum unit_activity activity, Index: server/barbarian.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/barbarian.c,v retrieving revision 1.50 diff -u -r1.50 barbarian.c --- server/barbarian.c 2002/02/21 09:44:52 1.50 +++ server/barbarian.c 2002/02/22 15:30:36 @@ -226,9 +226,9 @@ send_unit_info(NULL, punit2); while(TRUE) { rand_neighbour(x, y, &xu, &yu); - if (can_unit_move_to_tile_with_notify(punit2, xu, yu, TRUE)) + if (can_unit_move_to_tile(punit2, xu, yu, TRUE)) break; - if (can_unit_move_to_tile_with_notify(punit2, xb, yb, TRUE)) { + if (can_unit_move_to_tile(punit2, xb, yb, TRUE)) { xu = xb; yu = yb; break; } Index: server/unithand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v retrieving revision 1.217 diff -u -r1.217 unithand.c --- server/unithand.c 2002/02/22 13:14:45 1.217 +++ server/unithand.c 2002/02/22 15:30:40 @@ -839,6 +839,45 @@ } /************************************************************************** +... +**************************************************************************/ +static bool can_unit_move_to_tile_with_notify(struct unit *punit, int dest_x, + int dest_y, bool igzoc) +{ + enum unit_move_result reason; + int src_x = punit->x, src_y = punit->y; + + reason = + test_unit_move_to_tile(punit->type, unit_owner(punit), + punit->activity, punit->connecting, + punit->x, punit->y, dest_x, dest_y, igzoc); + if (reason == MR_OK) + return TRUE; + + if (reason == MR_BAD_TYPE_FOR_CITY_TAKE_OVER) { + char *units_str = get_units_with_flag_string(F_MARINES); + if (units_str) { + notify_player_ex(unit_owner(punit), src_x, src_y, + E_NOEVENT, _("Game: Only %s can attack from sea."), + units_str); + free(units_str); + } else { + notify_player_ex(unit_owner(punit), src_x, src_y, + E_NOEVENT, _("Game: Cannot attack from sea.")); + } + } else if (reason == MR_NO_WAR) { + notify_player_ex(unit_owner(punit), src_x, src_y, + E_NOEVENT, + _("Game: Cannot attack unless you declare war first.")); + } else if (reason == MR_ZOC) { + notify_player_ex(unit_owner(punit), src_x, src_y, E_NOEVENT, + _("Game: %s can only move into your own zone of control."), + unit_type(punit)->name); + } + return FALSE; +} + +/************************************************************************** Will try to move to/attack the tile dest_x,dest_y. Returns true if this could be done, false if it couldn't for some reason. @@ -926,7 +965,7 @@ packet.action_type = DIPLOMAT_CLIENT_POPUP_DIALOG; lsend_packet_diplomat_action(player_reply_dest(pplayer), &packet); return FALSE; - } else if (!can_unit_move_to_tile_with_notify(punit, dest_x, dest_y, igzoc)) { + } else if (!can_unit_move_to_tile(punit, dest_x, dest_y, igzoc)) { notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT, map_get_terrain(punit->x, punit->y) == T_OCEAN ? _("Game: Unit must be on land to " Index: server/unittools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v retrieving revision 1.160 diff -u -r1.160 unittools.c --- server/unittools.c 2002/02/22 13:14:46 1.160 +++ server/unittools.c 2002/02/22 15:30:42 @@ -3147,45 +3147,6 @@ /************************************************************************** ... **************************************************************************/ -bool can_unit_move_to_tile_with_notify(struct unit *punit, int dest_x, - int dest_y, bool igzoc) -{ - enum unit_move_result reason; - int src_x = punit->x, src_y = punit->y; - - reason = - test_unit_move_to_tile(punit->type, unit_owner(punit), - punit->activity, punit->connecting, - punit->x, punit->y, dest_x, dest_y, igzoc); - if (reason == MR_OK) - return TRUE; - - if (reason == MR_BAD_TYPE_FOR_CITY_TAKE_OVER) { - char *units_str = get_units_with_flag_string(F_MARINES); - if (units_str) { - notify_player_ex(unit_owner(punit), src_x, src_y, - E_NOEVENT, _("Game: Only %s can attack from sea."), - units_str); - free(units_str); - } else { - notify_player_ex(unit_owner(punit), src_x, src_y, - E_NOEVENT, _("Game: Cannot attack from sea.")); - } - } else if (reason == MR_NO_WAR) { - notify_player_ex(unit_owner(punit), src_x, src_y, - E_NOEVENT, - _("Game: Cannot attack unless you declare war first.")); - } else if (reason == MR_ZOC) { - notify_player_ex(unit_owner(punit), src_x, src_y, E_NOEVENT, - _("Game: %s can only move into your own zone of control."), - unit_type(punit)->name); - } - return FALSE; -} - -/************************************************************************** -... -**************************************************************************/ int get_watchtower_vision(struct unit *punit) { int base_vision = unit_type(punit)->vision_range; Index: server/unittools.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.h,v retrieving revision 1.41 diff -u -r1.41 unittools.h --- server/unittools.h 2002/02/14 15:17:41 1.41 +++ server/unittools.h 2002/02/22 15:30:42 @@ -27,11 +27,6 @@ void maybe_make_veteran(struct unit *punit); void unit_versus_unit(struct unit *attacker, struct unit *defender); - -/* move check related */ -bool can_unit_move_to_tile_with_notify(struct unit *punit, int dest_x, - int dest_y, bool igzoc); - /* turn update related */ void player_restore_units(struct player *pplayer); void update_unit_activities(struct player *pplayer);