<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39973 >

Here's the patch for 2.2.  This also fixes some of PR#39971 as needed.

Index: server/srv_main.c
===================================================================
--- server/srv_main.c   (revision 14198)
+++ server/srv_main.c   (working copy)
@@ -447,11 +447,10 @@
   unit_list_iterate_safe(plr1->units, punit) {
     if (tile_owner(punit->tile) == plr2
         && is_military_unit(punit)) {
-      notify_player(plr1, NULL, E_DIPLOMACY, _("Your %s unit %s was "
+      notify_player(plr1, punit->tile, E_DIPLOMACY, _("Your %s was "
                     "disbanded in accordance with your peace treaty with "
                     "the %s."),
                     unit_name_translation(punit),
-                    get_location_str_at(plr1, punit->tile),
                     nation_plural_for_player(plr2));
       wipe_unit(punit);
     }
@@ -459,11 +458,10 @@
   unit_list_iterate_safe(plr2->units, punit) {
     if (tile_owner(punit->tile) == plr1
         && is_military_unit(punit)) {
-      notify_player(plr2, NULL, E_DIPLOMACY, _("Your %s unit %s was "
+      notify_player(plr2, punit->tile, E_DIPLOMACY, _("Your %s was "
                     "disbanded in accordance with your peace treaty with "
                     "the %s."),
                     unit_name_translation(punit),
-                    get_location_str_at(plr2, punit->tile),
                     nation_plural_for_player(plr1));
       wipe_unit(punit);
     }
Index: server/diplomats.c
===================================================================
--- server/diplomats.c  (revision 14198)
+++ server/diplomats.c  (working copy)
@@ -391,7 +391,6 @@
   struct tile *victim_tile;
   int bribe_cost;
   int diplomat_id;
-  bool vet = FALSE;
   struct unit *gained_unit = NULL;
   
   /* Fetch target unit's player.  Sanity checks. */
@@ -450,28 +449,18 @@
   /* Inform owner about less than full fuel */
   send_unit_info(pplayer, gained_unit);
 
-  /* Check if the unit gained veteran level */
-  vet = maybe_make_veteran(pdiplomat);
-  
   /* Notify everybody involved. */
-  if (vet) {
-    notify_player(pplayer, pvictim->tile, E_MY_DIPLOMAT_BRIBE,
-                    _("Your %s succeeded in bribing %s's %s"
-                       " and became more experienced."),
-                    unit_name_translation(pdiplomat),
-                    unit_owner(pvictim)->name,
-                    unit_name_translation(pvictim));
-  } else {
-    notify_player(pplayer, pvictim->tile, E_MY_DIPLOMAT_BRIBE,
-                    _("Your %s succeeded in bribing %s's %s."),
-                    unit_name_translation(pdiplomat),
-                    unit_owner(pvictim)->name,
-                    unit_name_translation(pvictim));
+  notify_player(pplayer, pvictim->tile, E_MY_DIPLOMAT_BRIBE,
+               _("Your %s succeeded in bribing the %s."),
+               unit_name_translation(pdiplomat),
+               unit_name_translation(pvictim));
+  if (maybe_make_veteran(pdiplomat)) {
+    notify_unit_experience(pdiplomat, TRUE);
   }
   notify_player(uplayer, pvictim->tile, E_ENEMY_DIPLOMAT_BRIBE,
-                  _("Your %s was bribed by %s."),
-                  unit_name_translation(pvictim),
-                  pplayer->name);
+               _("Your %s was bribed by the %s."),
+               unit_name_translation(pvictim),
+               nation_plural_for_player(pplayer));
 
   /* This costs! */
   pplayer->economic.gold -= bribe_cost;
@@ -1093,18 +1082,26 @@
       if (diplomat_success_vs_defender(pdiplomat, punit, ptile) 
           && !unit_has_type_flag(punit, F_SUPERSPY)) {
        /* Defending Spy/Diplomat dies. */
-
-       notify_player(cplayer, ptile, E_MY_DIPLOMAT_FAILED,
-                        _("Your %s has been eliminated defending %s"
-                          " against a %s."),
-                        unit_name_translation(punit),
-                        (pcity ? pcity->name : ""),
-                        unit_name_translation(pdiplomat));
        notify_player(pplayer, ptile, E_ENEMY_DIPLOMAT_FAILED,
-                _("An enemy %s has been eliminated defending %s."),
-               unit_name_translation(punit),
-               (pcity ? pcity->name : ""));
+                     _("An enemy %s has been eliminated by your %s."),
+                     unit_name_translation(punit),
+                     unit_name_translation(pdiplomat));
 
+       if (pcity) {
+         notify_player(cplayer, ptile, E_MY_DIPLOMAT_FAILED,
+                       _("Your %s has been eliminated defending %s"
+                         " against a %s."),
+                       unit_name_translation(punit),
+                       pcity->name,
+                       unit_name_translation(pdiplomat));
+       } else {
+         notify_player(cplayer, ptile, E_MY_DIPLOMAT_FAILED,
+                       _("Your %s has been eliminated defending"
+                         " against a %s."),
+                       unit_name_translation(punit),
+                       unit_name_translation(pdiplomat));
+       }
+
        wipe_unit(punit);
         pdiplomat->moves_left = MAX(0, pdiplomat->moves_left - SINGLE_MOVE);
         send_unit_info(pplayer, pdiplomat);
@@ -1134,7 +1131,7 @@
 
        /* Defending unit became more experienced? */
        if (maybe_make_veteran(punit)) {
-         notify_unit_experience(punit);
+         notify_unit_experience(punit, FALSE);
        }
        wipe_unit(pdiplomat);
        return FALSE;
@@ -1160,7 +1157,6 @@
 {
   struct tile *ptile;
   int escapechance;
-  bool vet;
   struct city *spyhome;
 
   escapechance = game.info.diplchance + pdiplomat->veteran * 5;
@@ -1178,22 +1174,13 @@
       && unit_has_type_flag(pdiplomat, F_SPY)
       && (myrand (100) < escapechance || unit_has_type_flag(pdiplomat, 
F_SUPERSPY))) {
     /* Attacking Spy/Diplomat survives. */
-
-    /* may become a veteran */
-    vet = maybe_make_veteran(pdiplomat);
-    if (vet) {
-      notify_player(pplayer, ptile, E_MY_DIPLOMAT_ESCAPE,
-                      _("Your %s has successfully completed"
-                        " her mission and returned unharmed to %s"
-                        " and has become more experienced."),
-                      unit_name_translation(pdiplomat),
-                      spyhome->name);
-    } else {
-      notify_player(pplayer, ptile, E_MY_DIPLOMAT_ESCAPE,
-                      _("Your %s has successfully completed"
-                        " her mission and returned unharmed to %s."),
-                      unit_name_translation(pdiplomat),
-                      spyhome->name);
+    notify_player(pplayer, ptile, E_MY_DIPLOMAT_ESCAPE,
+                 _("Your %s has successfully completed"
+                   " her mission and returned unharmed to %s."),
+                 unit_name_translation(pdiplomat),
+                 spyhome->name);
+    if (maybe_make_veteran(pdiplomat)) {
+      notify_unit_experience(pdiplomat, TRUE);
     }
 
     /* being teleported costs all movement */
Index: server/unittools.c
===================================================================
--- server/unittools.c  (revision 14198)
+++ server/unittools.c  (working copy)
@@ -255,10 +255,9 @@
       = can_upgrade_unittype(pplayer, unit_type(punit));
 
     notify_player(pplayer, punit->tile, E_UNIT_UPGRADED,
-                 _("%s was upgraded for free to %s%s."),
+                 _("%s was upgraded for free to %s."),
                  unit_name_translation(punit),
-                 utype_name_translation(upgrade_type),
-                 get_location_str_in(pplayer, punit->tile));
+                 utype_name_translation(upgrade_type));
     upgrade_unit(punit, upgrade_type, TRUE);
     unit_list_unlink(candidates, punit);
     upgrades--;
@@ -617,12 +616,20 @@
 
 /**************************************************************************
   common notification for all experience levels.
+  When used immediately after another unit message, set also to TRUE.
 **************************************************************************/
-void notify_unit_experience(struct unit *punit)
+void notify_unit_experience(struct unit *punit, bool also)
 {
-  notify_player(unit_owner(punit), punit->tile, E_UNIT_BECAME_VET,
-               _("Your %s became more experienced!"),
-               unit_name_translation(punit));
+  if (also) {
+    notify_player(unit_owner(punit), punit->tile, E_UNIT_BECAME_VET,
+                 /* TRANS: And, <the unit> became ... */
+                 _("And, became more experienced!"));
+  } else {
+    notify_player(unit_owner(punit), punit->tile, E_UNIT_BECAME_VET,
+                 /* TRANS: Your <unit> became ... */
+                 _("Your %s became more experienced!"),
+                 unit_name_translation(punit));
+  }
 }
 
 /**************************************************************************
@@ -648,7 +655,7 @@
     /* settler may become veteran when doing something useful */
     if (activity != ACTIVITY_FORTIFYING && activity != ACTIVITY_SENTRY
        && maybe_settler_become_veteran(punit)) {
-      notify_unit_experience(punit);
+      notify_unit_experience(punit, FALSE);
     }
   }
 
@@ -857,65 +864,6 @@
 }
 
 /**************************************************************************
-  Returns a pointer to a (static) string which gives an informational
-  message about location (x,y), in terms of cities known by pplayer.
-  One of:
-    "in Foo City"  or  "at Foo City" (see below)
-    "outside Foo City"
-    "near Foo City"
-    "" (if no cities known)
-  There are two variants for the first case, one when something happens
-  inside the city, otherwise when it happens "at" but "outside" the city.
-  Eg, when an attacker fails, the attacker dies "at" the city, but
-  not "in" the city (since the attacker never made it in).
-  Don't call this function directly; use the wrappers below.
-**************************************************************************/
-static char *get_location_str(struct player *pplayer, struct tile *ptile, bool 
use_at)
-{
-  static char buffer[MAX_LEN_NAME+64];
-  struct city *incity, *nearcity;
-
-  incity = tile_city(ptile);
-  if (incity) {
-    if (use_at) {
-      my_snprintf(buffer, sizeof(buffer), _(" at %s"), incity->name);
-    } else {
-      my_snprintf(buffer, sizeof(buffer), _(" in %s"), incity->name);
-    }
-  } else {
-    nearcity = dist_nearest_city(pplayer, ptile, FALSE, FALSE);
-    if (nearcity) {
-      if (is_tiles_adjacent(ptile, nearcity->tile)) {
-       my_snprintf(buffer, sizeof(buffer),
-                  _(" outside %s"), nearcity->name);
-      } else {
-       my_snprintf(buffer, sizeof(buffer),
-                   _(" near %s"), nearcity->name);
-      }
-    } else {
-      buffer[0] = '\0';
-    }
-  }
-  return buffer;
-}
-
-/**************************************************************************
-  See get_location_str() above.
-**************************************************************************/
-char *get_location_str_in(struct player *pplayer, struct tile *ptile)
-{
-  return get_location_str(pplayer, ptile, FALSE);
-}
-
-/**************************************************************************
-  See get_location_str() above.
-**************************************************************************/
-char *get_location_str_at(struct player *pplayer, struct tile *ptile)
-{
-  return get_location_str(pplayer, ptile, TRUE);
-}
-
-/**************************************************************************
 ...
 **************************************************************************/
 enum goto_move_restriction get_activity_move_restriction(enum unit_activity 
activity)
@@ -1623,7 +1571,6 @@
 {
   struct player *pvictim = unit_owner(punit);
   struct player *pvictor = unit_owner(pkiller);
-  const char *loc_str = get_location_str_in(pvictim, punit->tile);
   int ransom, unitcount = 0;
   
   /* barbarian leader ransom hack */
@@ -1650,30 +1597,19 @@
   }
 
   if (!is_stack_vulnerable(punit->tile) || unitcount == 1) {
+    notify_player(pvictor, pkiller->tile, E_UNIT_WIN_ATT,
+                 _("Your attacking %s succeeded against the %s %s!"),
+                 unit_name_translation(pkiller),
+                 nation_adjective_for_player(pvictim),
+                 unit_name_translation(punit));
     if (vet) {
-      notify_player(pvictor, pkiller->tile, E_UNIT_WIN_ATT,
-                   _("Your attacking %s succeeded"
-                     " against %s's %s%s and became more experienced!"),
-                   unit_name_translation(pkiller),
-                   pvictim->name,
-                   unit_name_translation(punit),
-                   get_location_str_at(pvictor,
-                                       punit->tile));
-    } else {
-      notify_player(pvictor, pkiller->tile, E_UNIT_WIN_ATT,
-                   _("Your attacking %s succeeded against %s's %s%s!"),
-                   unit_name_translation(pkiller),
-                   pvictim->name,
-                   unit_name_translation(punit),
-                   get_location_str_at(pvictor,
-                                       punit->tile));
+      notify_unit_experience(pkiller, TRUE);
     }
     notify_player(pvictim, punit->tile, E_UNIT_LOST,
-                 _("%s lost to an attack by %s's %s%s."),
+                 _("%s lost to an attack by the %s %s."),
                  unit_name_translation(punit),
-                 pvictor->name,
-                 unit_name_translation(pkiller),
-                 loc_str);
+                 nation_adjective_for_player(pvictor),
+                 unit_name_translation(pkiller));
 
     wipe_unit(punit);
   } else { /* unitcount > 1 */
@@ -1702,31 +1638,17 @@
     } unit_list_iterate_end;
 
     /* Inform the destroyer: lots of different cases here! */
+    notify_player(pvictor, pkiller->tile, E_UNIT_WIN_ATT,
+                 PL_("Your attacking %s succeeded against the %s %s "
+                     "(and %d other unit)!",
+                     "Your attacking %s succeeded against the %s %s "
+                     "(and %d other units)!", unitcount - 1),
+                 unit_name_translation(pkiller),
+                 nation_adjective_for_player(pvictim),
+                 unit_name_translation(punit),
+                 unitcount - 1);
     if (vet) {
-      notify_player(pvictor, pkiller->tile, E_UNIT_WIN_ATT,
-                   PL_("Your attacking %s succeeded against %s's %s "
-                       "(and %d other unit)%s and became more experienced!",
-                       "Your attacking %s succeeded against %s's %s "
-                       "(and %d other units)%s and became more experienced!",
-                       unitcount - 1),
-                   unit_name_translation(pkiller),
-                   pvictim->name,
-                   unit_name_translation(punit),
-                   unitcount - 1,
-                   get_location_str_at(pvictor,
-                                       punit->tile));
-    } else {
-      notify_player(pvictor, pkiller->tile, E_UNIT_WIN_ATT,
-                   PL_("Your attacking %s succeeded against %s's %s "
-                       "(and %d other unit)%s!",
-                       "Your attacking %s succeeded against %s's %s "
-                       "(and %d other units)%s!", unitcount - 1),
-                   unit_name_translation(pkiller),
-                   pvictim->name,
-                   unit_name_translation(punit),
-                   unitcount - 1,
-                   get_location_str_at(pvictor,
-                                       punit->tile));
+      notify_unit_experience(pkiller, TRUE);
     }
 
     /* inform the owners: this only tells about owned units that were killed.
Index: server/unittools.h
===================================================================
--- server/unittools.h  (revision 14198)
+++ server/unittools.h  (working copy)
@@ -23,7 +23,7 @@
 struct unit_type *find_a_unit_type(enum unit_role_id role,
                                   enum unit_role_id role_tech);
 bool maybe_make_veteran(struct unit *punit);
-void notify_unit_experience(struct unit *punit);
+void notify_unit_experience(struct unit *punit, bool also);
 void unit_versus_unit(struct unit *attacker, struct unit *defender,
                      bool bombard);
 
@@ -38,8 +38,6 @@
 void update_unit_activities(struct player *pplayer);
 
 /* various */
-char *get_location_str_in(struct player *pplayer, struct tile *ptile);
-char *get_location_str_at(struct player *pplayer, struct tile *ptile);
 enum goto_move_restriction get_activity_move_restriction(enum unit_activity 
activity);
 void make_partisans(struct city *pcity);
 bool enemies_at(struct unit *punit, struct tile *ptile);
Index: server/unithand.c
===================================================================
--- server/unithand.c   (revision 14198)
+++ server/unithand.c   (working copy)
@@ -755,7 +755,6 @@
 {
   struct player *pplayer = unit_owner(punit);
   struct city *pcity = tile_city(ptile);
-  int old_unit_vet;
 
   freelog(LOG_DEBUG, "Start bombard: %s's %s to %d, %d.",
          pplayer->name,
@@ -799,15 +798,8 @@
     send_city_info(NULL, pcity);
   }
 
-  old_unit_vet = punit->veteran;
-  maybe_make_veteran(punit);
-  if (punit->veteran != old_unit_vet) {
-    notify_player(unit_owner(punit), punit->tile,
-                    E_UNIT_WIN_ATT,
-                    _("Your bombarding %s%s became more experienced!"),
-                    unit_name_translation(punit),
-                    get_location_str_at(unit_owner(punit),
-                    punit->tile));
+  if (maybe_make_veteran(punit)) {
+    notify_unit_experience(punit, FALSE);
   }
 
   send_unit_info(NULL, punit);
@@ -913,50 +905,32 @@
   
   if (punit == plooser) {
     /* The attacker lost */
-    freelog(LOG_DEBUG, "Attacker lost: %s's %s against %s's %s.",
-           pplayer->name,
+    freelog(LOG_DEBUG, "Attacker lost: %s %s against %s %s.",
+           nation_rule_name(nation_of_player(pplayer)),
            unit_rule_name(punit),
-           unit_owner(pdefender)->name,
+           nation_rule_name(nation_of_unit(pdefender)),
            unit_rule_name(pdefender));
 
+    notify_player(unit_owner(pwinner), pwinner->tile, E_UNIT_WIN,
+                 _("Your %s survived the pathetic attack from the %s %s."),
+                 unit_name_translation(pwinner),
+                 nation_adjective_for_player(unit_owner(plooser)),
+                 unit_name_translation(plooser));
     if (vet) {
-      notify_player(unit_owner(pwinner),
-                      pwinner->tile, E_UNIT_WIN,
-                      _("Your %s%s survived the pathetic attack"
-                        " from %s's %s and became more experienced!"),
-                      unit_name_translation(pwinner),
-                      get_location_str_in(unit_owner(pwinner),
-                                          pwinner->tile),
-                      unit_owner(plooser)->name,
-                      unit_name_translation(plooser));
-    } else {
-      notify_player(unit_owner(pwinner),
-                      pwinner->tile, E_UNIT_WIN,
-                      _("Your %s%s survived the pathetic attack"
-                        " from %s's %s."),
-                      unit_name_translation(pwinner),
-                      get_location_str_in(unit_owner(pwinner),
-                                          pwinner->tile),
-                      unit_owner(plooser)->name,
-                      unit_name_translation(plooser));
+      notify_unit_experience(pwinner, TRUE);
     }
-    
-    notify_player(unit_owner(plooser),
-                    def_tile, E_UNIT_LOST_ATT,
-                    _("Your attacking %s failed "
-                      "against %s's %s%s!"),
-                    unit_name_translation(plooser),
-                    unit_owner(pwinner)->name,
-                    unit_name_translation(pwinner),
-                    get_location_str_at(unit_owner(plooser),
-                                        pwinner->tile));
+    notify_player(unit_owner(plooser), def_tile, E_UNIT_LOST_ATT,
+                 _("Your attacking %s failed against the %s %s!"),
+                 unit_name_translation(plooser),
+                 nation_adjective_for_player(unit_owner(pwinner)),
+                 unit_name_translation(pwinner));
     wipe_unit(plooser);
   } else {
     /* The defender lost, the attacker punit lives! */
-    freelog(LOG_DEBUG, "Defender lost: %s's %s against %s's %s.",
-           pplayer->name,
+    freelog(LOG_DEBUG, "Defender lost: %s %s against %s %s.",
+           nation_rule_name(nation_of_player(pplayer)),
            unit_rule_name(punit),
-           unit_owner(pdefender)->name,
+           nation_rule_name(nation_of_unit(pdefender)),
            unit_rule_name(pdefender));
 
     punit->moved = TRUE;       /* We moved */
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to