Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13753) RFC: death to E_NOEVENT
Home

[Freeciv-Dev] (PR#13753) RFC: death to E_NOEVENT

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13753) RFC: death to E_NOEVENT
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 23 Aug 2005 12:41:47 -0700
Reply-to: bugs@xxxxxxxxxxx

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

E_NOEVENT has no purpose.  It is just a garbage bin of unwanted messages 
that get dropped in the chatline, plus the chat messages themselves. 
The end result is that the chatline isn't useful for actual chatting 
since there's no way to separate it from these garbage messages.

Solution: remove E_NOEVENT entirely.  All messages should get an event, 
chat messages included.

This will take lots of work so I plan to do it in several steps.  This 
first step changes callers of notify_player_ex and other obvious ones to 
use an event type instead.  This fixes the biggest offenders since these 
are game messages that shouldn't be on the chatline.  To make it work I 
had to add a few new event types.

-jason

Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.139
diff -p -u -r1.139 options.c
--- client/options.c    19 Aug 2005 20:52:58 -0000      1.139
+++ client/options.c    23 Aug 2005 19:40:49 -0000
@@ -314,20 +314,26 @@ unsigned int messages_where[E_LAST];
 *****************************************************************/
 void message_options_init(void)
 {
-  int out_only[] = { E_IMP_BUY, E_IMP_SOLD, E_UNIT_BUY,
-                    E_UNIT_LOST_ATT, E_UNIT_WIN_ATT, E_GAME_START,
-                    E_NATION_SELECTED, E_CITY_BUILD, E_NEXT_YEAR,
-                    E_CITY_PRODUCTION_CHANGED,
-                    E_CITY_MAY_SOON_GROW, E_WORKLIST};
-  int all[] = { E_MESSAGE_WALL, E_TUTORIAL };
+  int none[] = {
+    E_IMP_BUY, E_IMP_SOLD, E_UNIT_BUY,
+    E_UNIT_LOST_ATT, E_UNIT_WIN_ATT, E_GAME_START,
+    E_NATION_SELECTED, E_CITY_BUILD, E_NEXT_YEAR,
+    E_CITY_PRODUCTION_CHANGED,
+    E_CITY_MAY_SOON_GROW, E_WORKLIST
+  };
+  int out_only[] = {E_CHAT_MSG, E_CHAT_ERROR, E_SETTING};
+  int all[] = {E_MESSAGE_WALL, E_TUTORIAL};
   int i;
 
-  for(i=0; i<E_LAST; i++) {
+  for (i = 0; i < E_LAST; i++) {
     messages_where[i] = MW_MESSAGES;
   }
-  for (i = 0; i < ARRAY_SIZE(out_only); i++) {
+  for (i = 0; i < ARRAY_SIZE(none); i++) {
     messages_where[out_only[i]] = 0;
   }
+  for (i = 0; i < ARRAY_SIZE(out_only); i++) {
+    messages_where[out_only[i]] = MW_OUTPUT;
+  }
   for (i = 0; i < ARRAY_SIZE(all); i++) {
     messages_where[all[i]] = MW_MESSAGES | MW_POPUP;
   }
Index: client/agents/cma_core.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v
retrieving revision 1.75
diff -p -u -r1.75 cma_core.c
--- client/agents/cma_core.c    13 Apr 2005 18:22:49 -0000      1.75
+++ client/agents/cma_core.c    23 Aug 2005 19:40:50 -0000
@@ -403,7 +403,7 @@ static void handle_city(struct city *pci
       if (!apply_result_on_server(pcity, &result)) {
        freelog(HANDLE_CITY_LOG_LEVEL2, "  doesn't cleanly apply");
        if (check_city(city_id, NULL) && i == 0) {
-         create_event(pcity->tile, E_NOEVENT,
+         create_event(pcity->tile, E_CITY_CMA_RELEASE,
                       _("The citizen governor has gotten confused dealing "
                         "with %s.  You may want to have a look."),
                       pcity->name);
@@ -423,7 +423,7 @@ static void handle_city(struct city *pci
     assert(pcity != NULL);
     freelog(HANDLE_CITY_LOG_LEVEL2, "  not handled");
 
-    create_event(pcity->tile, E_NOEVENT,
+    create_event(pcity->tile, E_CITY_CMA_RELEASE,
                 _("The citizen governor has gotten confused dealing "
                   "with %s.  You may want to have a look."),
                 pcity->name);
Index: common/events.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/events.c,v
retrieving revision 1.2
diff -p -u -r1.2 events.c
--- common/events.c     11 May 2005 19:47:27 -0000      1.2
+++ common/events.c     23 Aug 2005 19:40:50 -0000
@@ -26,7 +26,7 @@
 #include "events.h"
 
 #define GEN_EV(descr, event) { #event, NULL, descr, NULL, event }
-#define GEN_EV_TERMINATOR { NULL, NULL, NULL, NULL, E_NOEVENT }
+#define GEN_EV_TERMINATOR { NULL, NULL, NULL, NULL, -1 }
 
 /*
  * Holds information about all event types. The entries don't have
@@ -56,6 +56,7 @@ static struct {
   GEN_EV(N_("City: Transfer"),                        E_CITY_TRANSFER),
   GEN_EV(N_("City: Was Built"),                       E_CITY_BUILD),
   GEN_EV(N_("City: Worklist Events"),                 E_WORKLIST),
+  GEN_EV(N_("City: Production changed"),              
E_CITY_PRODUCTION_CHANGED),
   GEN_EV(N_("Civ: Barbarian Uprising"),               E_UPRISING ),
   GEN_EV(N_("Civ: Civil War"),                        E_CIVIL_WAR),
   GEN_EV(N_("Civ: Collapse to Anarchy"),              E_ANARCHY),
@@ -82,6 +83,7 @@ static struct {
   GEN_EV(N_("Enemy Diplomat: Poison"),              E_ENEMY_DIPLOMAT_POISON),
   GEN_EV(N_("Enemy Diplomat: Sabotage"),            E_ENEMY_DIPLOMAT_SABOTAGE),
   GEN_EV(N_("Enemy Diplomat: Theft"),               E_ENEMY_DIPLOMAT_THEFT),
+  GEN_EV(N_("Caravan actions"), E_CARAVAN_ACTION),
   GEN_EV(N_("Tutorial message"),                E_TUTORIAL),
   GEN_EV(N_("Broadcast Report"),                E_BROADCAST_REPORT),
   GEN_EV(N_("Game Ended"),                      E_GAME_END),
@@ -130,8 +132,11 @@ static struct {
   GEN_EV(N_("Wonder: Stopped"),                       E_WONDER_STOPPED),
   GEN_EV(N_("Wonder: Will Finish Next Turn"),         E_WONDER_WILL_BE_BUILT),
   GEN_EV(N_("Diplomatic Message"),                    E_DIPLOMACY),
-  GEN_EV(N_("City: Production changed"),              
E_CITY_PRODUCTION_CHANGED),
   GEN_EV(N_("Treaty: Embassy"),                       E_TREATY_EMBASSY),
+  GEN_EV(N_("Error message from bad command"), E_BAD_COMMAND),
+  GEN_EV(N_("Server settings changed"), E_SETTING),
+  GEN_EV(N_("Chat messages"), E_CHAT_MSG),
+  GEN_EV(N_("Chat error messages"), E_CHAT_ERROR),
   GEN_EV_TERMINATOR
 };
 
@@ -177,7 +182,7 @@ static int compar_event_message_texts(co
 ****************************************************************************/
 const char *get_event_sound_tag(enum event_type event)
 {
-  if (event == E_NOEVENT) {
+  if (event < 0 || event >= E_LAST) {
     return NULL;
   }
 
@@ -242,7 +247,7 @@ void events_init(void)
   for (i = 0;; i++) {
     int j;
 
-    if (events[i].event == E_NOEVENT) {
+    if (events[i].event < 0) {
       break;
     }
     events[i].descr = _(events[i].descr_orig);
Index: common/events.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/events.h,v
retrieving revision 1.29
diff -p -u -r1.29 events.h
--- common/events.h     11 May 2005 19:31:38 -0000      1.29
+++ common/events.h     23 Aug 2005 19:40:50 -0000
@@ -33,6 +33,7 @@ enum event_type {
   E_CITY_GRAN_THROTTLE,
   E_CITY_TRANSFER,
   E_CITY_BUILD,
+  E_CITY_PRODUCTION_CHANGED,
   E_WORKLIST,
   E_UPRISING,
   E_CIVIL_WAR,
@@ -60,6 +61,7 @@ enum event_type {
   E_ENEMY_DIPLOMAT_POISON,
   E_ENEMY_DIPLOMAT_SABOTAGE,
   E_ENEMY_DIPLOMAT_THEFT,
+  E_CARAVAN_ACTION,
   E_TUTORIAL,
   E_BROADCAST_REPORT,
   E_GAME_END,
@@ -108,8 +110,11 @@ enum event_type {
   E_WONDER_STOPPED,
   E_WONDER_WILL_BE_BUILT,
   E_DIPLOMACY,
-  E_CITY_PRODUCTION_CHANGED,
   E_TREATY_EMBASSY,
+  E_BAD_COMMAND,  /* Illegal command sent from client. */
+  E_SETTING, /* Messages for changed server settings */
+  E_CHAT_MSG, /* Chatline messages */
+  E_CHAT_ERROR, /* Chatline errors (bad syntax, etc.) */
   /* 
    * Note: If you add a new event, make sure you make a similar change
    * to the events array in client/options.c using GEN_EV and to
Index: server/cityhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityhand.c,v
retrieving revision 1.153
diff -p -u -r1.153 cityhand.c
--- server/cityhand.c   1 Aug 2005 23:09:36 -0000       1.153
+++ server/cityhand.c   23 Aug 2005 19:40:50 -0000
@@ -113,7 +113,7 @@ void handle_city_make_specialist(struct 
     city_refresh(pcity);
     sync_cities();
   } else {
-    notify_player_ex(pplayer, pcity->tile, E_NOEVENT,
+    notify_player_ex(pplayer, pcity->tile, E_BAD_COMMAND,
                     _("You don't have a worker here.")); 
   }
   sanity_check_city(pcity);
@@ -170,7 +170,7 @@ void really_handle_city_sell(struct play
                             Impr_type_id id)
 {  
   if (pcity->did_sell) {
-    notify_player_ex(pplayer, pcity->tile, E_NOEVENT, 
+    notify_player_ex(pplayer, pcity->tile, E_BAD_COMMAND, 
                  _("You have already sold something here this turn."));
     return;
   }
@@ -218,27 +218,27 @@ void really_handle_city_buy(struct playe
   assert(pcity && player_owns_city(pplayer, pcity));
  
   if (pcity->turn_founded == game.info.turn) {
-    notify_player_ex(pplayer, pcity->tile, E_NOEVENT,
+    notify_player_ex(pplayer, pcity->tile, E_BAD_COMMAND,
                  _("Cannot buy in city created this turn."));
     return;
   }
 
   if (pcity->did_buy) {
-    notify_player_ex(pplayer, pcity->tile, E_NOEVENT,
+    notify_player_ex(pplayer, pcity->tile, E_BAD_COMMAND,
                  _("You have already bought this turn."));
     return;
   }
 
   if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
     assert(!pcity->production.is_unit);
-    notify_player_ex(pplayer, pcity->tile, E_NOEVENT,
+    notify_player_ex(pplayer, pcity->tile, E_BAD_COMMAND,
                      _("You don't buy %s!"),
                     get_improvement_name(pcity->production.value));
     return;
   }
 
   if (pcity->production.is_unit && pcity->anarchy != 0) {
-    notify_player_ex(pplayer, pcity->tile, E_NOEVENT, 
+    notify_player_ex(pplayer, pcity->tile, E_BAD_COMMAND, 
                     _("Can't buy units when city is in disorder."));
     return;
   }
@@ -257,7 +257,7 @@ void really_handle_city_buy(struct playe
   if (cost > pplayer->economic.gold) {
     /* In case something changed while player tried to buy, or player 
      * tried to cheat! */
-    notify_player_ex(pplayer, pcity->tile, E_NOEVENT,
+    notify_player_ex(pplayer, pcity->tile, E_BAD_COMMAND,
                     _("%d gold required.  You only have %d gold."), cost,
                      pplayer->economic.gold);
     return;
@@ -358,12 +358,12 @@ void handle_city_change(struct player *p
    if (!is_build_id_unit_id && !can_build_improvement(pcity, build_id))
      return;
   if (pcity->did_buy && pcity->shield_stock > 0) {
-    notify_player_ex(pplayer, pcity->tile, E_NOEVENT,
+    notify_player_ex(pplayer, pcity->tile, E_BAD_COMMAND,
                     _("You have bought this turn, can't change."));
     return;
   }
 
-  change_build_target(pplayer, pcity, prod, E_NOEVENT);
+  change_build_target(pplayer, pcity, prod, E_CITY_PRODUCTION_CHANGED);
 
   sanity_check_city(pcity);
   city_refresh(pcity);
@@ -383,7 +383,7 @@ void handle_city_rename(struct player *p
   }
 
   if (!is_allowed_city_name(pplayer, name, message, sizeof(message))) {
-    notify_player_ex(pplayer, pcity->tile, E_NOEVENT,
+    notify_player_ex(pplayer, pcity->tile, E_BAD_COMMAND,
                     _("%s"),  message);
     return;
   }
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.342
diff -p -u -r1.342 citytools.c
--- server/citytools.c  1 Aug 2005 23:09:36 -0000       1.342
+++ server/citytools.c  23 Aug 2005 19:40:50 -0000
@@ -797,7 +797,7 @@ void transfer_city(struct player *ptaker
       && city_list_find_name(ptaker->cities, pcity->name)) {
     sz_strlcpy(pcity->name,
               city_name_suggestion(ptaker, pcity->tile));
-    notify_player_ex(ptaker, pcity->tile, E_NOEVENT,
+    notify_player_ex(ptaker, pcity->tile, E_BAD_COMMAND,
                     _("You already had a city called %s."
                       " The city was renamed to %s."), old_city_name,
                     pcity->name);
@@ -1085,7 +1085,7 @@ void remove_city(struct city *pcity)
        if (could_unit_move_to_tile(punit, tile1) == 1) {
          moved = handle_unit_move_request(punit, tile1, FALSE, TRUE);
          if (moved) {
-           notify_player_ex(unit_owner(punit), NULL, E_NOEVENT,
+           notify_player_ex(unit_owner(punit), NULL, E_UNIT_RELOCATED,
                             _("Moved %s out of disbanded city %s "
                               "to avoid being landlocked."),
                             unit_type(punit)->name, pcity->name);
@@ -1094,9 +1094,9 @@ void remove_city(struct city *pcity)
       }
     } adjc_iterate_end;
     if (!moved) {
-      notify_player_ex(unit_owner(punit), NULL, E_NOEVENT,
+      notify_player_ex(unit_owner(punit), NULL, E_UNIT_LOST,
                       _("When %s was disbanded your %s could not "
-                        "get out, and it was therefore stranded."),
+                        "get out, and it was therefore lost."),
                       pcity->name, unit_type(punit)->name);
       wipe_unit(punit);
     }
@@ -1105,9 +1105,9 @@ void remove_city(struct city *pcity)
   /* Destroy final ineligible units (land units in ocean city) */
   unit_list_iterate_safe(ptile->units, punit) {
     if (is_ocean(tile_get_terrain(ptile)) && is_ground_unit(punit)) {
-      notify_player_ex(unit_owner(punit), NULL, E_NOEVENT,
+      notify_player_ex(unit_owner(punit), NULL, E_UNIT_LOST,
                       _("When %s was disbanded your %s could not "
-                        "get out, and it was therefore stranded."),
+                        "get out, and it was therefore lost."),
                       pcity->name, unit_type(punit)->name);
       wipe_unit(punit);
     }
@@ -1832,17 +1832,10 @@ void change_build_target(struct player *
   /* Tell the player what's up. */
   /* FIXME: this may give bad grammar when translated if the 'source'
    * string can have multiple values. */
-  if (event != E_NOEVENT) {
-    notify_player_ex(pplayer, pcity->tile, event,
-                    /* TRANS: "<city> is building <production><source>." */
-                    _("%s is building %s%s."),
-                    pcity->name, name, source);
-  } else {
-    notify_player_ex(pplayer, pcity->tile, E_CITY_PRODUCTION_CHANGED,
-                    /* TRANS: "<city> is building <production>." */
-                    _("%s is building %s."), 
-                    pcity->name, name);
-  }
+  notify_player_ex(pplayer, pcity->tile, event,
+                  /* TRANS: "<city> is building <production><source>." */
+                  _("%s is building %s%s."),
+                  pcity->name, name, source);
 
   /* If the city is building a wonder, tell the rest of the world
      about it. */
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.165
diff -p -u -r1.165 gamehand.c
--- server/gamehand.c   22 Jul 2005 16:18:06 -0000      1.165
+++ server/gamehand.c   23 Aug 2005 19:40:51 -0000
@@ -383,7 +383,7 @@ int update_timeout(void)
     game.timeoutint += game.timeoutintinc;
 
     if (game.info.timeout > GAME_MAX_TIMEOUT) {
-      notify_conn_ex(game.game_connections, NULL, E_NOEVENT,
+      notify_conn_ex(game.game_connections, NULL, E_SETTING,
                     _("The turn timeout has exceeded its maximum value, "
                       "fixing at its maximum"));
       freelog(LOG_DEBUG, "game.info.timeout exceeded maximum value");
@@ -391,7 +391,7 @@ int update_timeout(void)
       game.timeoutint = 0;
       game.timeoutinc = 0;
     } else if (game.info.timeout < 0) {
-      notify_conn_ex(game.game_connections, NULL, E_NOEVENT,
+      notify_conn_ex(game.game_connections, NULL, E_SETTING,
                     _("The turn timeout is smaller than zero, "
                       "fixing at zero."));
       freelog(LOG_DEBUG, "game.info.timeout less than zero");
Index: server/handchat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/handchat.c,v
retrieving revision 1.37
diff -p -u -r1.37 handchat.c
--- server/handchat.c   14 Feb 2005 22:52:41 -0000      1.37
+++ server/handchat.c   23 Aug 2005 19:40:51 -0000
@@ -76,7 +76,7 @@ static void complain_ambiguous(struct co
   default:
     assert(0);
   }
-  dsend_packet_chat_msg(pconn, message, -1, -1, E_NOEVENT, -1);
+  dsend_packet_chat_msg(pconn, message, -1, -1, E_CHAT_ERROR, -1);
 }
 
 /**************************************************************************
@@ -94,11 +94,11 @@ static void chat_msg_to_conn(struct conn
   form_chat_name(dest, dest_name, sizeof(dest_name));
 
   my_snprintf(message, sizeof(message), "->*%s* %s", dest_name, msg);
-  dsend_packet_chat_msg(sender, message, -1, -1, E_NOEVENT, sender->id);
+  dsend_packet_chat_msg(sender, message, -1, -1, E_CHAT_MSG, sender->id);
 
   if (sender != dest) {
     my_snprintf(message, sizeof(message), "*%s* %s", sender_name, msg);
-    dsend_packet_chat_msg(dest, message, -1, -1, E_NOEVENT, sender->id);
+    dsend_packet_chat_msg(dest, message, -1, -1, E_CHAT_MSG, sender->id);
   }
 }
 
@@ -115,13 +115,13 @@ static void chat_msg_to_player_multi(str
   form_chat_name(sender, sender_name, sizeof(sender_name));
 
   my_snprintf(message, sizeof(message), "->[%s] %s", pdest->name, msg);
-  dsend_packet_chat_msg(sender, message, -1, -1, E_NOEVENT, sender->id);
+  dsend_packet_chat_msg(sender, message, -1, -1, E_CHAT_MSG, sender->id);
 
   my_snprintf(message, sizeof(message), "[%s] %s", sender_name, msg);
   conn_list_iterate(pdest->connections, dest_conn) {
     if (dest_conn != sender) {
       dsend_packet_chat_msg(dest_conn, message,
-                           -1, -1, E_NOEVENT, sender->id);
+                           -1, -1, E_CHAT_MSG, sender->id);
     }
   } conn_list_iterate_end;
 }
@@ -184,7 +184,7 @@ void handle_chat_msg_req(struct connecti
     if (!pconn->player) {
       my_snprintf(chat, sizeof(chat),
                   _("You are not attached to a player."));
-      dsend_packet_chat_msg(pconn, chat, -1, -1, E_NOEVENT, -1);
+      dsend_packet_chat_msg(pconn, chat, -1, -1, E_CHAT_ERROR, -1);
       return;
     }
 
@@ -200,7 +200,7 @@ void handle_chat_msg_req(struct connecti
         continue;
       }
       dlsend_packet_chat_msg(aplayer->connections, chat, -1, -1,
-                            E_NOEVENT, pconn->id);
+                            E_CHAT_MSG, pconn->id);
     } players_iterate_end;
     return;
   }
@@ -286,7 +286,7 @@ void handle_chat_msg_req(struct connecti
        /* Would have done something above if connected */
        my_snprintf(chat, sizeof(chat),
                    _("%s is not connected."), pdest->name);
-       dsend_packet_chat_msg(pconn, chat, -1, -1, E_NOEVENT, -1);
+       dsend_packet_chat_msg(pconn, chat, -1, -1, E_CHAT_ERROR, -1);
        return;
       }
     }
@@ -303,7 +303,7 @@ void handle_chat_msg_req(struct connecti
                    _("There is no player nor connection by the name %s."),
                    name);
       }
-      dsend_packet_chat_msg(pconn, chat, -1, -1, E_NOEVENT, -1);
+      dsend_packet_chat_msg(pconn, chat, -1, -1, E_CHAT_ERROR, -1);
       return;
     }
   }
@@ -312,5 +312,5 @@ void handle_chat_msg_req(struct connecti
   my_snprintf(chat, sizeof(chat),
              "<%s> %s", sender_name, message);
   dlsend_packet_chat_msg(game.est_connections, chat,
-                        -1, -1, E_NOEVENT, pconn->id);
+                        -1, -1, E_CHAT_MSG, pconn->id);
 }
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.412
diff -p -u -r1.412 plrhand.c
--- server/plrhand.c    22 Aug 2005 21:15:49 -0000      1.412
+++ server/plrhand.c    23 Aug 2005 19:40:51 -0000
@@ -688,8 +688,7 @@ repeat_break_treaty:
   apply if game has started and the conn's player knows that tile (or
   pconn->player==NULL && pconn->observer).  If coords are not required,
   caller should specify (x,y) = (-1,-1); otherwise make sure that the
-  coordinates have been normalized.  For generic event use E_NOEVENT.
-  (But current clients do not use (x,y) data for E_NOEVENT events.)
+  coordinates have been normalized.
 **************************************************************************/
 void vnotify_conn_ex(struct conn_list *dest, struct tile *ptile,
                     enum event_type event, const char *format,
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.347
diff -p -u -r1.347 unithand.c
--- server/unithand.c   20 Aug 2005 19:53:41 -0000      1.347
+++ server/unithand.c   23 Aug 2005 19:40:52 -0000
@@ -356,7 +356,7 @@ void handle_unit_disband(struct player *
 
   if (unit_flag(punit, F_UNDISBANDABLE)) {
     /* refuse to kill ourselves */
-    notify_player_ex(unit_owner(punit), punit->tile, E_NOEVENT,
+    notify_player_ex(unit_owner(punit), punit->tile, E_BAD_COMMAND,
               _("%s refuses to disband!"), unit_name(punit->type));
     return;
   }
@@ -409,19 +409,19 @@ static void city_add_or_build_error(stru
 
   switch (res) {
   case AB_NOT_BUILD_LOC:
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                     _("Can't place city here."));
     break;
   case AB_NOT_BUILD_UNIT:
     {
       const char *us = get_units_with_flag_string(F_CITIES);
       if (us) {
-       notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+       notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                         _("Only %s can build a city."),
                         us);
        free((void *) us);
       } else {
-       notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+       notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                         _("Can't build a city."));
       }
     }
@@ -430,33 +430,33 @@ static void city_add_or_build_error(stru
     {
       const char *us = get_units_with_flag_string(F_ADD_TO_CITY);
       if (us) {
-       notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+       notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                         _("Only %s can add to a city."),
                         us);
        free((void *) us);
       } else {
-       notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+       notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                         _("Can't add to a city."));
       }
     }
     break;
   case AB_NO_MOVES_ADD:
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                     _("%s unit has no moves left to add to %s."),
                     unit_name, pcity->name);
     break;
   case AB_NO_MOVES_BUILD:
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                     _("%s unit has no moves left to build city."),
                     unit_name);
     break;
   case AB_TOO_BIG:
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                     _("%s is too big to add %s."),
                     pcity->name, unit_name);
     break;
   case AB_NO_SPACE:
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                     _("%s needs an improvement to grow, so "
                       "you cannot add %s."),
                     pcity->name, unit_name);
@@ -465,7 +465,7 @@ static void city_add_or_build_error(stru
     /* Shouldn't happen */
     freelog(LOG_ERROR, "Cannot add %s to %s for unknown reason",
            unit_name, pcity->name);
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                     _("Can't add %s to %s."),
                     unit_name, pcity->name);
     break;
@@ -489,7 +489,7 @@ static void city_add_unit(struct player 
   auto_arrange_workers(pcity);
   wipe_unit(punit);
   send_city_info(NULL, pcity);
-  notify_player_ex(pplayer, pcity->tile, E_NOEVENT,
+  notify_player_ex(pplayer, pcity->tile, E_CITY_BUILD,
                   _("%s added to aid %s in growing."),
                   unit_name, pcity->name);
 }
@@ -506,8 +506,8 @@ static void city_build(struct player *pp
   char message[1024];
 
   if (!is_allowed_city_name(pplayer, name, message, sizeof(message))) {
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
-                    _("%s"), message);
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
+                    "%s", message);
     return;
   }
 
@@ -957,19 +957,19 @@ static bool can_unit_move_to_tile_with_n
     const char *units_str = get_units_with_flag_string(F_MARINES);
     if (units_str) {
       notify_player_ex(unit_owner(punit), src_tile,
-                      E_NOEVENT, _("Only %s can attack from sea."),
+                      E_BAD_COMMAND, _("Only %s can attack from sea."),
                       units_str);
       free((void *) units_str);
     } else {
       notify_player_ex(unit_owner(punit), src_tile,
-                      E_NOEVENT, _("Cannot attack from sea."));
+                      E_BAD_COMMAND, _("Cannot attack from sea."));
     }
   } else if (reason == MR_NO_WAR) {
     notify_player_ex(unit_owner(punit), src_tile,
-                    E_NOEVENT,
+                    E_BAD_COMMAND,
                     _("Cannot attack unless you declare war first."));
   } else if (reason == MR_ZOC) {
-    notify_player_ex(unit_owner(punit), src_tile, E_NOEVENT,
+    notify_player_ex(unit_owner(punit), src_tile, E_BAD_COMMAND,
                     _("%s can only move into your own zone of control."),
                     unit_type(punit)->name);
   }
@@ -1006,7 +1006,7 @@ bool handle_unit_move_request(struct uni
 
 
   if (punit->moves_left<=0)  {
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                      _("This unit has no moves left."));
     return FALSE;
   }
@@ -1059,7 +1059,7 @@ bool handle_unit_move_request(struct uni
                                                 punit->id, target_id);
         return FALSE;
       } else if (!can_unit_move_to_tile(punit, pdesttile, igzoc)) {
-        notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+        notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                          is_ocean(tile_get_terrain(punit->tile))
                          ? _("Unit must be on land to "
                              "perform diplomatic action.")
@@ -1078,7 +1078,7 @@ bool handle_unit_move_request(struct uni
     /* We can attack ONLY in enemy cities */
     if ((pcity && !pplayers_at_war(city_owner(pcity), pplayer))
         || (victim = is_non_attack_unit_tile(pdesttile, pplayer))) {
-      notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+      notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                        _("You must declare war on %s first.  Try using "
                          "players dialog (F3)."), victim == NULL ?
                        city_owner(pcity)->name : unit_owner(victim)->name);
@@ -1094,7 +1094,7 @@ bool handle_unit_move_request(struct uni
          unit_bombard(punit, pdesttile);
          return TRUE;
        } else {
-         notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+         notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                           _("This unit is being transported, and"
                             " so cannot bombard."));
          return FALSE;
@@ -1109,7 +1109,7 @@ bool handle_unit_move_request(struct uni
     if (victim) {
       /* Must be physically able to attack EVERY unit there */
       if (!can_unit_attack_all_at_tile(punit, pdesttile)) {
-        notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+        notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                          _("You can't attack there."));
         return FALSE;
       }
@@ -1129,7 +1129,7 @@ bool handle_unit_move_request(struct uni
        * If not it would have been caught in the attack case. 
        * FIXME: Move this check into test_unit_move_tile */
       if (!COULD_OCCUPY(punit)) {
-        notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+        notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                          _("This type of troops cannot "
                            "take over a city."));
         return FALSE;
@@ -1147,7 +1147,7 @@ bool handle_unit_move_request(struct uni
       if (pcargo->transported_by == punit->id
           && (is_non_allied_unit_tile(pdesttile, unit_owner(pcargo))
               || is_non_allied_city_tile(pdesttile, unit_owner(pcargo)))) {
-         notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+         notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                           _("A transported unit is not allied to all "
                             "units or city on target tile."));
          return FALSE;
@@ -1194,7 +1194,7 @@ void handle_unit_help_build_wonder(struc
   } else {
     text = _("Your %s helps build the %s in %s (%d surplus).");
   }
-  notify_player_ex(pplayer, pcity_dest->tile, E_NOEVENT,
+  notify_player_ex(pplayer, pcity_dest->tile, E_CARAVAN_ACTION,
                   text, /* Must match arguments below. */
                   unit_name(punit->type),
                   get_improvement_type(pcity_dest->production.value)->name,
@@ -1235,7 +1235,7 @@ static bool base_handle_unit_establish_t
   pcity_homecity = player_find_city_by_id(pplayer, punit->homecity);
 
   if (!pcity_homecity) {
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                     _("Sorry, your %s cannot establish"
                       " a trade route because it has no home city"),
                     unit_name(punit->type));
@@ -1245,7 +1245,7 @@ static bool base_handle_unit_establish_t
 
     
   if (!can_cities_trade(pcity_homecity, pcity_dest)) {
-    notify_player_ex(pplayer, pcity_dest->tile, E_NOEVENT,
+    notify_player_ex(pplayer, pcity_dest->tile, E_BAD_COMMAND,
                     _("Sorry, your %s cannot establish"
                       " a trade route between %s and %s"),
                     unit_name(punit->type),pcity_homecity->name,
@@ -1273,10 +1273,10 @@ static bool base_handle_unit_establish_t
        pcity_out_of_home = find_city_by_id(pcity_homecity->trade[slot]);
        assert(pcity_out_of_home != NULL);
       } else {
-       notify_player_ex(pplayer, pcity_dest->tile, E_NOEVENT,
+       notify_player_ex(pplayer, pcity_dest->tile, E_BAD_COMMAND,
                     _("Sorry, your %s cannot establish"
                       " a trade route here!"), unit_name(punit->type));
-        notify_player_ex(pplayer, pcity_dest->tile, E_NOEVENT,
+        notify_player_ex(pplayer, pcity_dest->tile, E_BAD_COMMAND,
                       _("      The city of %s already has %d "
                         "better trade routes!"), pcity_homecity->name,
                       NUM_TRADEROUTES);
@@ -1290,10 +1290,10 @@ static bool base_handle_unit_establish_t
        pcity_out_of_dest = find_city_by_id(pcity_dest->trade[slot]);
        assert(pcity_out_of_dest != NULL);
       } else {
-       notify_player_ex(pplayer, pcity_dest->tile, E_NOEVENT,
+       notify_player_ex(pplayer, pcity_dest->tile, E_BAD_COMMAND,
                     _("Sorry, your %s cannot establish"
                       " a trade route here!"), unit_name(punit->type));
-        notify_player_ex(pplayer, pcity_dest->tile, E_NOEVENT,
+        notify_player_ex(pplayer, pcity_dest->tile, E_BAD_COMMAND,
                       _("      The city of %s already has %d "
                         "better trade routes!"), pcity_dest->name,
                       NUM_TRADEROUTES);
@@ -1305,7 +1305,7 @@ static bool base_handle_unit_establish_t
     if (can_establish && pcity_out_of_home) {
       remove_trade_route(pcity_homecity, pcity_out_of_home);
       notify_player_ex(city_owner(pcity_out_of_home),
-                      pcity_out_of_home->tile, E_NOEVENT,
+                      pcity_out_of_home->tile, E_CARAVAN_ACTION,
                       _("Sorry, %s has canceled the trade route "
                         "from %s to your city %s."),
                       city_owner(pcity_homecity)->name,
@@ -1316,7 +1316,7 @@ static bool base_handle_unit_establish_t
     if (can_establish && pcity_out_of_dest) {
       remove_trade_route(pcity_dest, pcity_out_of_dest);
       notify_player_ex(city_owner(pcity_out_of_dest),
-                      pcity_out_of_dest->tile, E_NOEVENT,
+                      pcity_out_of_dest->tile, E_CARAVAN_ACTION,
                       _("Sorry, %s has canceled the trade route "
                         "from %s to your city %s."),
                       city_owner(pcity_dest)->name,
@@ -1348,7 +1348,7 @@ static bool base_handle_unit_establish_t
   }
   
   conn_list_do_buffer(pplayer->connections);
-  notify_player_ex(pplayer, pcity_dest->tile, E_NOEVENT,
+  notify_player_ex(pplayer, pcity_dest->tile, E_CARAVAN_ACTION,
                   _("Your %s from %s has arrived in %s,"
                     " and revenues amount to %d in gold and research."), 
                   unit_name(punit->type), pcity_homecity->name,
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.376
diff -p -u -r1.376 unittools.c
--- server/unittools.c  20 Aug 2005 19:58:55 -0000      1.376
+++ server/unittools.c  23 Aug 2005 19:40:52 -0000
@@ -420,7 +420,7 @@ void player_restore_units(struct player 
            punit->goto_tile = itr_tile;
            set_unit_activity(punit, ACTIVITY_GOTO);
            (void) do_unit_goto(punit, GOTO_MOVE_ANY, FALSE);
-           notify_player_ex(pplayer, punit->tile, E_NOEVENT, 
+           notify_player_ex(pplayer, punit->tile, E_UNIT_ORDERS, 
                             _("Your %s has returned to refuel."),
                             unit_name(punit->type));
            goto OUT;
@@ -1111,7 +1111,7 @@ bool teleport_unit_to_city(struct unit *
            unit_owner(punit)->name, unit_name(punit->type),
            src_tile->x, src_tile->y, pcity->name);
     if (verbose) {
-      notify_player_ex(unit_owner(punit), pcity->tile, E_NOEVENT,
+      notify_player_ex(unit_owner(punit), pcity->tile, E_UNIT_RELOCATED,
                       _("Teleported your %s to %s."),
                       unit_name(punit->type), pcity->name);
     }
@@ -1140,7 +1140,7 @@ void bounce_unit(struct unit *punit, boo
   } else {
     /* remove it */
     if (verbose) {
-      notify_player_ex(unit_owner(punit), punit->tile, E_NOEVENT,
+      notify_player_ex(unit_owner(punit), punit->tile, E_UNIT_LOST,
                       _("Disbanded your %s."),
                       unit_name(punit->type));
     }
@@ -1565,7 +1565,7 @@ void wipe_unit_spec_safe(struct unit *pu
            pcity = find_closest_owned_city(unit_owner(pcargo),
                                            pcargo->tile, TRUE, NULL);
            if (pcity && teleport_unit_to_city(pcargo, pcity, 0, FALSE)) {
-             notify_player_ex(pplayer, ptile, E_NOEVENT,
+             notify_player_ex(pplayer, ptile, E_UNIT_RELOCATED,
                               _("%s escaped the destruction of %s, and "
                                 "fled to %s."), unit_type(pcargo)->name,
                               ptype->name, pcity->name);
@@ -2019,7 +2019,7 @@ bool do_airline(struct unit *punit, stru
   city1->airlift = FALSE;
   city2->airlift = FALSE;
 
-  notify_player_ex(unit_owner(punit), city2->tile, E_NOEVENT,
+  notify_player_ex(unit_owner(punit), city2->tile, E_UNIT_RELOCATED,
                   _("%s transported succesfully."),
                   unit_name(punit->type));
 
@@ -2042,7 +2042,7 @@ bool do_paradrop(struct unit *punit, str
   struct player *pplayer = unit_owner(punit);
 
   if (!unit_flag(punit, F_PARATROOPERS)) {
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                      _("This unit type can not be paradropped."));
     return FALSE;
   }
@@ -2052,19 +2052,19 @@ bool do_paradrop(struct unit *punit, str
   }
 
   if (get_transporter_occupancy(punit) > 0) {
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_BAD_COMMAND,
                     _("You cannot paradrop a transporter unit."));
   }
 
   if (!map_is_known(ptile, pplayer)) {
-    notify_player_ex(pplayer, ptile, E_NOEVENT,
+    notify_player_ex(pplayer, ptile, E_BAD_COMMAND,
                      _("The destination location is not known."));
     return FALSE;
   }
 
   /* Safe terrain according to player map? */
   if (!is_native_terrain(punit, map_get_player_tile(ptile, pplayer)->terrain)) 
{
-    notify_player_ex(pplayer, ptile, E_NOEVENT,
+    notify_player_ex(pplayer, ptile, E_BAD_COMMAND,
                      _("This unit cannot paradrop into %s."),
                        get_name(map_get_player_tile(ptile, pplayer)->terrain));
     return FALSE;
@@ -2074,7 +2074,7 @@ bool do_paradrop(struct unit *punit, str
       && ((ptile->city
          && pplayers_non_attack(pplayer, city_owner(ptile->city)))
       || is_non_attack_unit_tile(ptile, pplayer))) {
-    notify_player_ex(pplayer, ptile, E_NOEVENT,
+    notify_player_ex(pplayer, ptile, E_BAD_COMMAND,
                      _("Cannot attack unless you declare war first."));
     return FALSE;    
   }
@@ -2083,7 +2083,7 @@ bool do_paradrop(struct unit *punit, str
     int range = unit_type(punit)->paratroopers_range;
     int distance = real_map_distance(punit->tile, ptile);
     if (distance > range) {
-      notify_player_ex(pplayer, ptile, E_NOEVENT,
+      notify_player_ex(pplayer, ptile, E_BAD_COMMAND,
                        _("The distance to the target (%i) "
                          "is greater than the unit's range (%i)."),
                        distance, range);
@@ -2246,7 +2246,7 @@ static bool unit_enter_hut(struct unit *
   update_tile_knowledge(punit->tile);
 
   if (game.info.hut_overflight == OVERFLIGHT_FRIGHTEN && is_air_unit(punit)) {
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_HUT_BARB,
                     _("Your overflight frightens the tribe;"
                       " they scatter in terror."));
     return ok;
@@ -2847,7 +2847,7 @@ static bool maybe_cancel_goto_due_to_ene
   
   if (is_non_allied_unit_tile(ptile, pplayer) 
       || is_non_allied_city_tile(ptile, pplayer)) {
-    notify_player_ex(pplayer, punit->tile, E_NOEVENT,
+    notify_player_ex(pplayer, punit->tile, E_UNIT_ORDERS,
                      _("%s aborted GOTO "
                        "as there are units in the way."),
                      unit_type(punit)->name);
@@ -2890,7 +2890,7 @@ static bool maybe_cancel_patrol_due_to_e
 
   if (cancel) {
     handle_unit_activity_request(punit, ACTIVITY_IDLE);
-    notify_player_ex(unit_owner(punit), punit->tile, E_NOEVENT, 
+    notify_player_ex(unit_owner(punit), punit->tile, E_UNIT_ORDERS, 
                     _("Your %s cancelled patrol order because it "
                       "encountered a foreign unit."), unit_name(punit->type));
   }
Index: server/scripting/api.pkg
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api.pkg,v
retrieving revision 1.14
diff -p -u -r1.14 api.pkg
--- server/scripting/api.pkg    1 Aug 2005 22:38:27 -0000       1.14
+++ server/scripting/api.pkg    23 Aug 2005 19:40:52 -0000
@@ -286,7 +286,6 @@ module notify {
 /* Notify events module. */
 module E {
   enum event_type {
-    E_NOEVENT @ NOEVENT = -1,
     E_CITY_CANTBUILD @ CITY_CANTBUILD,
     E_CITY_LOST @ CITY_LOST,
     E_CITY_LOVE @ CITY_LOVE,

[Prev in Thread] Current Thread [Next in Thread]