Complete.Org:
Mailing Lists:
Archives:
freeciv-dev:
September 2005: [Freeciv-Dev] (PR#13912) duplicate orders-cancelled messages |
![]() |
[Freeciv-Dev] (PR#13912) duplicate orders-cancelled messages[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13912 > Now that these have the same event type they always show up right together: two separate messages appear when orders are cancelled. This patch fixes it. -jason Index: server/unittools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v retrieving revision 1.383 diff -p -u -r1.383 unittools.c --- server/unittools.c 5 Sep 2005 15:55:47 -0000 1.383 +++ server/unittools.c 7 Sep 2005 16:49:32 -0000 @@ -2461,6 +2461,16 @@ static bool unit_survive_autoattack(stru } } +/**************************************************************************** + Cancel orders for the unit. +****************************************************************************/ +static void cancel_orders(struct unit *punit, char *dbg_msg) +{ + free_unit_orders(punit); + send_unit_info(NULL, punit); + freelog(LOG_DEBUG, "%s", dbg_msg); +} + /***************************************************************** Will wake up any neighboring enemy sentry units or patrolling units. @@ -2500,7 +2510,13 @@ static void wakeup_neighbor_sentries(str if (punit != ppatrol && unit_has_orders(ppatrol) && ppatrol->orders.vigilant) { - (void) maybe_cancel_patrol_due_to_enemy(ppatrol); + if (maybe_cancel_patrol_due_to_enemy(ppatrol)) { + cancel_orders(ppatrol, " stopping because of nearby enemy"); + notify_player(ppatrol->owner, ppatrol->tile, E_UNIT_ORDERS, + _("Orders for %s aborted after enemy movement was " + "spotted."), + unit_name(ppatrol->type)); + } } } unit_list_iterate_end; } square_iterate_end; @@ -2846,18 +2862,8 @@ bool move_unit(struct unit *punit, struc static bool maybe_cancel_goto_due_to_enemy(struct unit *punit, struct tile *ptile) { - struct player *pplayer = unit_owner(punit); - - if (is_non_allied_unit_tile(ptile, pplayer) - || is_non_allied_city_tile(ptile, pplayer)) { - notify_player(pplayer, punit->tile, E_UNIT_ORDERS, - _("%s aborted GOTO " - "as there are units in the way."), - unit_type(punit)->name); - return TRUE; - } - - return FALSE; + return (is_non_allied_unit_tile(ptile, punit->owner) + || is_non_allied_city_tile(ptile, punit->owner)); } /************************************************************************** @@ -2891,27 +2897,10 @@ static bool maybe_cancel_patrol_due_to_e } } square_iterate_end; - if (cancel) { - handle_unit_activity_request(punit, ACTIVITY_IDLE); - notify_player(unit_owner(punit), punit->tile, E_UNIT_ORDERS, - _("Your %s cancelled patrol order because it " - "encountered a foreign unit."), unit_name(punit->type)); - } - return cancel; } /**************************************************************************** - Cancel orders for the unit. -****************************************************************************/ -static void cancel_orders(struct unit *punit, char *dbg_msg) -{ - free_unit_orders(punit); - send_unit_info(NULL, punit); - freelog(LOG_DEBUG, "%s", dbg_msg); -} - -/**************************************************************************** Executes a unit's orders stored in punit->orders. The unit is put on idle if an action fails or if "patrol" is set and an enemy unit is encountered.
|