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

2008/4/15 Marko Lindqvist:
> For
> S2_2 and TRUNK we should probably add new event category for unit
> deaths other than normal battle.

 Patch


 - ML

diff -Nurd -X.diff_ignore freeciv/common/events.c freeciv/common/events.c
--- freeciv/common/events.c     2008-04-06 15:19:10.000000000 +0300
+++ freeciv/common/events.c     2008-06-22 06:02:49.000000000 +0300
@@ -146,9 +146,10 @@
   GEN_EV(E_UNIT_WIN_ATT,       E_S_UNIT,       N_("Attack Succeeded")),
   GEN_EV(E_UNIT_BUY,           E_S_UNIT,       N_("Bought")),
   GEN_EV(E_UNIT_BUILT,         E_S_UNIT,       N_("Built")),
-  GEN_EV(E_UNIT_LOST,          E_S_UNIT,       N_("Defender Destroyed")),
+  GEN_EV(E_UNIT_LOST_DEF,      E_S_UNIT,       N_("Defender Destroyed")),
   GEN_EV(E_UNIT_WIN,           E_S_UNIT,       N_("Defender Survived")),
   GEN_EV(E_UNIT_BECAME_VET,    E_S_UNIT,       N_("Promoted to Veteran")),
+  GEN_EV(E_UNIT_LOST_MISC,      E_S_UNIT,       N_("Lost outside battle")),
   GEN_EV(E_UNIT_UPGRADED,      E_S_UNIT,       N_("Production Upgraded")),
   GEN_EV(E_UNIT_RELOCATED,     E_S_UNIT,       N_("Relocated")),
   GEN_EV(E_UNIT_ORDERS,                E_S_UNIT,       N_("Orders / goto 
events")),
@@ -246,7 +247,9 @@
   switch (event) {
   case E_GLOBAL_ECO:
   case E_CITY_LOST:
-  case E_UNIT_LOST:
+  case E_UNIT_LOST_DEF:  /* FIXME: Is this correct.
+                          * I'd like to find now defendeseless city quickly! */
+  case E_UNIT_LOST_MISC:
   case E_UNIT_WIN:
   case E_ENEMY_DIPLOMAT_FAILED:
   case E_ENEMY_DIPLOMAT_POISON:
diff -Nurd -X.diff_ignore freeciv/common/events.h freeciv/common/events.h
--- freeciv/common/events.h     2008-04-06 15:19:10.000000000 +0300
+++ freeciv/common/events.h     2008-06-22 05:48:10.000000000 +0300
@@ -102,7 +102,7 @@
   E_UNIT_WIN_ATT,
   E_UNIT_BUY,
   E_UNIT_BUILT,
-  E_UNIT_LOST,
+  E_UNIT_LOST_DEF,
   E_UNIT_WIN,
   E_UNIT_BECAME_VET,
   E_UNIT_UPGRADED,
@@ -125,10 +125,11 @@
   E_LOG_ERROR,                 /* Warning messages */
   E_LOG_FATAL,
   E_TECH_GOAL,                 /* Changed tech goal */
+  E_UNIT_LOST_MISC,             /* Non-battle unit deaths */
   /* 
    * Note: If you add a new event, make sure you make a similar change
-   * to the events array in common/events.c using GEN_EV and to
-   * data/stdsounds.soundspec.
+   * to the events array in common/events.c using GEN_EV,
+   * data/stdsoundes and to server/scripting/api.pkg
    */
   E_LAST
 };
diff -Nurd -X.diff_ignore freeciv/data/stdsounds.soundspec 
freeciv/data/stdsounds.soundspec
--- freeciv/data/stdsounds.soundspec    2008-02-10 11:05:27.000000000 +0200
+++ freeciv/data/stdsounds.soundspec    2008-06-22 05:46:52.000000000 +0300
@@ -286,8 +286,9 @@
 ;e_unit_became_vet = ""
 ;e_unit_built = ""
 ;e_unit_buy = ""
-;e_unit_lost = ""
+;e_unit_lost_def = ""
 ;e_unit_lost_att = ""
+;e_unit_lost_misc = ""
 ;e_unit_orders = ""
 ;e_unit_relocated = ""
 ;e_unit_upgraded = ""
diff -Nurd -X.diff_ignore freeciv/server/citytools.c freeciv/server/citytools.c
--- freeciv/server/citytools.c  2008-06-18 17:45:27.000000000 +0300
+++ freeciv/server/citytools.c  2008-06-22 05:57:51.000000000 +0300
@@ -586,7 +586,7 @@
              nation_rule_name(nation_of_player(from_player)),
              nation_rule_name(nation_of_player(to_player)));
       if (verbose) {
-       notify_player(from_player, punit->tile, E_UNIT_LOST,
+       notify_player(from_player, punit->tile, E_UNIT_LOST_MISC,
                      /* TRANS: Polish Destroyer ... German <city> */
                      _("%s %s lost in transfer to %s %s"),
                      nation_adjective_for_player(from_player),
@@ -670,7 +670,7 @@
              city_name(pcity));
       if (verbose) {
        notify_player(unit_owner(vunit), vunit->tile,
-                        E_UNIT_LOST,
+                        E_UNIT_LOST_MISC,
                         _("%s lost along with control of %s."),
                         unit_name_translation(vunit),
                         city_name(pcity));
@@ -1191,7 +1191,7 @@
       }
     } adjc_iterate_end;
     if (!moved) {
-      notify_player(unit_owner(punit), NULL, E_UNIT_LOST,
+      notify_player(unit_owner(punit), NULL, E_UNIT_LOST_MISC,
                       _("When %s was disbanded your %s could not "
                         "get out, and it was therefore lost."),
                       city_name(pcity),
diff -Nurd -X.diff_ignore freeciv/server/cityturn.c freeciv/server/cityturn.c
--- freeciv/server/cityturn.c   2008-05-13 13:26:10.000000000 +0300
+++ freeciv/server/cityturn.c   2008-06-22 05:58:25.000000000 +0300
@@ -716,7 +716,7 @@
       if (unit_type(punit)->upkeep[O_FOOD] > 0 
           && !unit_has_type_flag(punit, F_UNDISBANDABLE)) {
 
-       notify_player(city_owner(pcity), pcity->tile, E_UNIT_LOST,
+       notify_player(city_owner(pcity), pcity->tile, E_UNIT_LOST_MISC,
                         _("Famine feared in %s, %s lost!"), 
                         city_name(pcity),
                         unit_name_translation(punit));
@@ -1244,7 +1244,7 @@
       if (utype_upkeep_cost(unit_type(punit), pplayer, O_SHIELD) > 0
          && pcity->surplus[O_SHIELD] < 0
           && !unit_has_type_flag(punit, F_UNDISBANDABLE)) {
-       notify_player(pplayer, pcity->tile, E_UNIT_LOST,
+       notify_player(pplayer, pcity->tile, E_UNIT_LOST_MISC,
                         _("%s can't upkeep %s, unit disbanded."),
                         city_name(pcity),
                         unit_name_translation(punit));
@@ -1264,7 +1264,7 @@
 
       if (upkeep > 0 && pcity->surplus[O_SHIELD] < 0) {
        assert(unit_has_type_flag(punit, F_UNDISBANDABLE));
-       notify_player(pplayer, pcity->tile, E_UNIT_LOST,
+       notify_player(pplayer, pcity->tile, E_UNIT_LOST_MISC,
                         _("Citizens in %s perish for their failure to "
                         "upkeep %s!"),
                         city_name(pcity),
diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c
--- freeciv/server/maphand.c    2008-06-18 17:45:27.000000000 +0300
+++ freeciv/server/maphand.c    2008-06-22 05:58:48.000000000 +0300
@@ -1725,7 +1725,7 @@
                unit_rule_name(punit),
                TILE_XY(punit->tile));
        notify_player(unit_owner(punit),
-                        punit->tile, E_UNIT_LOST,
+                        punit->tile, E_UNIT_LOST_MISC,
                         _("Disbanded your %s due to changing terrain."),
                         unit_name_translation(punit));
        wipe_unit(punit);
diff -Nurd -X.diff_ignore freeciv/server/scripting/api.pkg 
freeciv/server/scripting/api.pkg
--- freeciv/server/scripting/api.pkg    2008-06-21 18:47:00.000000000 +0300
+++ freeciv/server/scripting/api.pkg    2008-06-22 05:49:55.000000000 +0300
@@ -452,8 +452,9 @@
     E_UNIT_WIN_ATT @ UNIT_WIN_ATT,
     E_UNIT_BUY @ UNIT_BUY,
     E_UNIT_BUILT @ UNIT_BUILT,
-    E_UNIT_LOST @ UNIT_LOST,
+    E_UNIT_LOST_DEF @ UNIT_LOST_DEF,
     E_UNIT_WIN @ UNIT_WIN,
+    E_UNIT_LOST_MISC @ UNIT_LOST_MISC,
     E_UNIT_BECAME_VET @ UNIT_BECAME_VET,
     E_UNIT_UPGRADED @ UNIT_UPGRADED,
     E_UNIT_RELOCATED @ UNIT_RELOCATED,
@@ -468,11 +469,7 @@
     E_SETTING @ SETTING,
     E_CHAT_MSG @ CHAT_MSG,
     E_CHAT_ERROR @ CHAT_ERROR,
-    /* 
-     * Note: If you add a new event, make sure you make a similar change
-     * to the events array in common/events.c using GEN_EV and to
-     * data/stdsounds.soundspec.
-     */
+
     E_LAST @ LAST
   };
 }
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c  2008-06-18 17:45:27.000000000 +0300
+++ freeciv/server/unittools.c  2008-06-22 05:39:44.000000000 +0300
@@ -294,8 +294,8 @@
       /* We cannot upkeep this unit any longer and selling off city
        * improvements will not help so we will have to disband */
       assert(pplayer->economic.gold + potential_gold >= 0);
-      
-      notify_player(pplayer, NULL, E_UNIT_LOST,
+
+      notify_player(pplayer, NULL, E_UNIT_LOST_MISC,
                       _("Not enough gold. %s disbanded"),
                       unit_name_translation(punit));
       wipe_unit(punit);
@@ -338,7 +338,7 @@
       /* This should usually only happen for heli units,
         but if any other units get 0 hp somehow, catch
         them too.  --dwp  */
-      notify_player(pplayer, punit->tile, E_UNIT_LOST, 
+      notify_player(pplayer, punit->tile, E_UNIT_LOST_MISC, 
           _("Your %s has run out of hit points."), 
           unit_name_translation(punit));
       wipe_unit(punit);
@@ -442,7 +442,7 @@
   /* 7) Check if there are air units without fuel */
   unit_list_iterate_safe(pplayer->units, punit) {
     if (punit->fuel <= 0 && unit_type(punit)->fuel) {
-      notify_player(pplayer, punit->tile, E_UNIT_LOST, 
+      notify_player(pplayer, punit->tile, E_UNIT_LOST_MISC, 
                       _("Your %s has run out of fuel."),
                       unit_name_translation(punit));
       wipe_unit(punit);
@@ -1099,7 +1099,7 @@
   } else {
     /* remove it */
     if (verbose) {
-      notify_player(unit_owner(punit), punit->tile, E_UNIT_LOST,
+      notify_player(unit_owner(punit), punit->tile, E_UNIT_LOST_MISC,
                       _("Disbanded your %s."),
                       unit_name_translation(punit));
     }
@@ -1428,7 +1428,7 @@
 
   /* check if this unit had F_GAMELOSS flag */
   if (unit_has_type_flag(punit, F_GAMELOSS) && unit_owner(punit)->is_alive) {
-    notify_conn(game.est_connections, ptile, E_UNIT_LOST,
+    notify_conn(game.est_connections, ptile, E_UNIT_LOST_MISC,
                    _("Unable to defend %s, %s has lost the game."),
                    unit_name_translation(punit),
                    player_name(unit_owner(punit)));
@@ -1469,7 +1469,7 @@
                                      struct unit *pcargo,
                                      struct unit_type *ptransport)
 {
-  notify_player(pplayer, pcargo->tile, E_UNIT_LOST,
+  notify_player(pplayer, pcargo->tile, E_UNIT_LOST_MISC,
                 _("%s lost when %s was lost."),
                 unit_name_translation(pcargo),
                 utype_name_translation(ptransport));
@@ -1625,7 +1625,7 @@
     if (vet) {
       notify_unit_experience(pkiller, TRUE);
     }
-    notify_player(pvictim, punit->tile, E_UNIT_LOST,
+    notify_player(pvictim, punit->tile, E_UNIT_LOST_DEF,
                  /* TRANS: "Cannon ... the Polish Destroyer." */
                  _("%s lost to an attack by the %s %s."),
                  unit_name_translation(punit),
@@ -1683,7 +1683,7 @@
       if (num_killed[i] == 1) {
        if (i == player_index(pvictim)) {
          assert(other_killed[i] == NULL);
-         notify_player(player_by_number(i), punit->tile, E_UNIT_LOST,
+         notify_player(player_by_number(i), punit->tile, E_UNIT_LOST_DEF,
                        /* TRANS: "Cannon ... the Polish Destroyer." */
                        _("%s lost to an attack by the %s %s."),
                        unit_name_translation(punit),
@@ -1691,7 +1691,7 @@
                        unit_name_translation(pkiller));
        } else {
          assert(other_killed[i] != punit);
-         notify_player(player_by_number(i), punit->tile, E_UNIT_LOST,
+         notify_player(player_by_number(i), punit->tile, E_UNIT_LOST_DEF,
                        /* TRANS: "Cannon lost when the Polish Destroyer
                         * attacked the German Musketeers." */
                        _("%s lost when the %s %s attacked the %s %s."),
@@ -1706,7 +1706,7 @@
          int others = num_killed[i] - 1;
 
          if (others == 1) {
-           notify_player(player_by_number(i), punit->tile, E_UNIT_LOST,
+           notify_player(player_by_number(i), punit->tile, E_UNIT_LOST_DEF,
                          /* TRANS: "Musketeers (and Cannon) lost to an
                           * attack from the Polish Destroyer." */
                          _("%s (and %s) lost to an attack from the %s %s."),
@@ -1715,7 +1715,7 @@
                          nation_adjective_for_player(pvictor),
                          unit_name_translation(pkiller));
          } else {
-           notify_player(player_by_number(i), punit->tile, E_UNIT_LOST,
+           notify_player(player_by_number(i), punit->tile, E_UNIT_LOST_DEF,
                          /* TRANS: "Musketeers and 3 other units lost to
                           * an attack from the Polish Destroyer."
                           * (only happens with at least 2 other units) */
@@ -1729,7 +1729,7 @@
                          unit_name_translation(pkiller));
          }
        } else {
-         notify_player(player_by_number(i), punit->tile, E_UNIT_LOST,
+         notify_player(player_by_number(i), punit->tile, E_UNIT_LOST_DEF,
                        /* TRANS: "2 units lost when the Polish Destroyer
                         * attacked the German Musketeers."
                         * (only happens with at least 2 other units) */
@@ -1999,7 +1999,7 @@
   struct city *pcity = tile_city(ptile);
 
   unit_list_iterate_safe(ptile->units, punit) {
-    notify_player(unit_owner(punit), ptile, E_UNIT_LOST,
+    notify_player(unit_owner(punit), ptile, E_UNIT_LOST_MISC,
                  _("Your %s was nuked by %s."),
                  unit_name_translation(punit),
                  pplayer == unit_owner(punit)
@@ -2194,7 +2194,7 @@
   /* Safe terrain, really? Not transformed since player last saw it. */
   if (!can_unit_exist_at_tile(punit, ptile)) {
     map_show_circle(pplayer, ptile, unit_type(punit)->vision_radius_sq);
-    notify_player(pplayer, ptile, E_UNIT_LOST,
+    notify_player(pplayer, ptile, E_UNIT_LOST_MISC,
                      _("Your %s paradropped into the %s "
                        "and was lost."),
                      unit_name_translation(punit),
@@ -2207,7 +2207,7 @@
       || is_non_allied_unit_tile(ptile, pplayer)) {
     map_show_circle(pplayer, ptile, unit_type(punit)->vision_radius_sq);
     maybe_make_contact(ptile, pplayer);
-    notify_player(pplayer, ptile, E_UNIT_LOST_ATT,
+    notify_player(pplayer, ptile, E_UNIT_LOST_MISC,
                      _("Your %s was killed by enemy units at the "
                        "paradrop destination."),
                      unit_name_translation(punit));
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to