Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13814) add extended info to notify_embassies
Home

[Freeciv-Dev] (PR#13814) add extended info to notify_embassies

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13814) add extended info to notify_embassies
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Aug 2005 10:07:16 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch adds a tile and event type info to the notify_embassies function.

I used E_TECH_GAIN for all the messages which were basically "<nation> 
has acquired <tech> from <source>".  This may be wrong since we may want 
to split your acquisitions from other-players acquisitions.  But this 
can come in a later step.

-jason

Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.333
diff -p -u -r1.333 cityturn.c
--- server/cityturn.c   29 Aug 2005 12:59:57 -0000      1.333
+++ server/cityturn.c   29 Aug 2005 17:05:30 -0000
@@ -1133,7 +1133,7 @@ static bool city_build_building(struct p
       for (i = 0; i < mod; i++) {
        Tech_type_id tech = give_immediate_free_tech(pplayer);
 
-       notify_embassies(pplayer, NULL,
+       notify_embassies(pplayer, NULL, NULL, E_TECH_GAIN,
            _("The %s have acquired %s from %s."),
            get_nation_name_plural(pplayer->nation),
            get_tech_name(pplayer, tech),
Index: server/diplhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplhand.c,v
retrieving revision 1.103
diff -p -u -r1.103 diplhand.c
--- server/diplhand.c   29 Aug 2005 12:59:58 -0000      1.103
+++ server/diplhand.c   29 Aug 2005 17:05:30 -0000
@@ -357,7 +357,7 @@ void handle_diplomacy_accept_treaty_req(
                         _("You are taught the knowledge of %s."),
                         get_tech_name(pdest, pclause->value));
 
-       notify_embassies(pdest, pgiver,
+       notify_embassies(pdest, pgiver, NULL, E_TECH_GAIN,
                         _("The %s have acquired %s from the %s."),
                         get_nation_name_plural(pdest->nation),
                         get_tech_name(pdest, pclause->value),
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.417
diff -p -u -r1.417 plrhand.c
--- server/plrhand.c    29 Aug 2005 12:59:58 -0000      1.417
+++ server/plrhand.c    29 Aug 2005 17:05:31 -0000
@@ -768,6 +768,7 @@ void notify_player(const struct player *
   but excluding pplayer and specified player.
 **************************************************************************/
 void notify_embassies(struct player *pplayer, struct player *exclude,
+                     struct tile *ptile, enum event_type event,
                      const char *format, ...) 
 {
   struct packet_chat_msg genmsg;
@@ -777,9 +778,14 @@ void notify_embassies(struct player *ppl
   my_vsnprintf(genmsg.message, sizeof(genmsg.message), format, args);
   va_end(args);
 
-  genmsg.x = -1;
-  genmsg.y = -1;
-  genmsg.event = E_NOEVENT;
+  if (ptile) {
+    genmsg.x = ptile->x;
+    genmsg.y = ptile->y;
+  } else {
+    genmsg.x = -1;
+    genmsg.y = -1;
+  }
+  genmsg.event = event;
   genmsg.conn_id = -1;
 
   players_iterate(other_player) {
Index: server/plrhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.h,v
retrieving revision 1.82
diff -p -u -r1.82 plrhand.h
--- server/plrhand.h    29 Aug 2005 12:59:58 -0000      1.82
+++ server/plrhand.h    29 Aug 2005 17:05:31 -0000
@@ -58,8 +58,9 @@ void notify_player(const struct player *
                   enum event_type event, const char *format, ...)
                    fc__attribute((format (printf, 4, 5)));
 void notify_embassies(struct player *pplayer, struct player *exclude,
+                     struct tile *ptile, enum event_type event,
                      const char *format, ...)
-                     fc__attribute((format (printf, 3, 4)));
+                     fc__attribute((format (printf, 5, 6)));
 void notify_team_ex(struct player* pplayer, struct tile *ptile,
                  enum event_type event, const char *format, ...)
                  fc__attribute((format (printf, 4, 5)));
Index: server/techtools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/techtools.c,v
retrieving revision 1.21
diff -p -u -r1.21 techtools.c
--- server/techtools.c  29 Aug 2005 12:59:58 -0000      1.21
+++ server/techtools.c  29 Aug 2005 17:05:31 -0000
@@ -108,13 +108,13 @@ static void tech_researched(struct playe
   struct advance *tech = &advances[tech_id];
 
   if (!is_future_tech(research->researching)) {
-    notify_embassies(plr, NULL,
+    notify_embassies(plr, NULL, NULL, E_TECH_GAIN,
                     _("The %s have researched %s."), 
                     get_nation_name_plural(plr->nation),
                     get_tech_name(plr, research->researching));
 
   } else {
-    notify_embassies(plr, NULL,
+    notify_embassies(plr, NULL, NULL, E_TECH_GAIN,
                     _("The %s have researched Future Tech. %d."), 
                     get_nation_name_plural(plr->nation),
                     research->future_tech);
@@ -175,7 +175,7 @@ void do_tech_parasite_effect(struct play
                             API_TYPE_PLAYER, pplayer,
                             API_TYPE_STRING, "stolen");
           gamelog(GAMELOG_TECH, pplayer, NULL, i, "steal");
-         notify_embassies(pplayer, NULL,
+         notify_embassies(pplayer, NULL, NULL, E_TECH_GAIN,
                           _("The %s have acquired %s from %s."),
                           get_nation_name_plural(pplayer->nation),
                           get_tech_name(pplayer, i), buf);
@@ -704,7 +704,7 @@ Tech_type_id steal_a_tech(struct player 
                   get_nation_name_plural(pplayer->nation),
                   get_tech_name(pplayer, stolen_tech));
 
-  notify_embassies(pplayer, victim,
+  notify_embassies(pplayer, victim, NULL, E_TECH_GAIN,
                   _("The %s have stolen %s from the %s."),
                   get_nation_name_plural(pplayer->nation),
                   get_tech_name(pplayer, stolen_tech),
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.380
diff -p -u -r1.380 unittools.c
--- server/unittools.c  29 Aug 2005 12:59:58 -0000      1.380
+++ server/unittools.c  29 Aug 2005 17:05:33 -0000
@@ -2159,8 +2159,9 @@ static void hut_get_tech(struct unit *pu
                     API_TYPE_PLAYER, pplayer,
                     API_TYPE_STRING, "hut");
   gamelog(GAMELOG_TECH, pplayer, NULL, new_tech);
-  notify_embassies(pplayer, NULL, _("The %s have acquired %s"
-                                   " from ancient scrolls of wisdom."),
+  notify_embassies(pplayer, NULL, NULL, E_TECH_GAIN,
+                  _("The %s have acquired %s"
+                    " from ancient scrolls of wisdom."),
                   get_nation_name_plural(pplayer->nation), tech_name);
 }
 
Index: server/scripting/api.pkg
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api.pkg,v
retrieving revision 1.16
diff -p -u -r1.16 api.pkg
--- server/scripting/api.pkg    26 Aug 2005 19:14:26 -0000      1.16
+++ server/scripting/api.pkg    29 Aug 2005 17:05:33 -0000
@@ -260,6 +260,8 @@ const char *api_intl_PL_ @ PL_ (const ch
 /* Notify module. */
 module notify {
   void api_notify_embassies_msg @ embassies_msg (Player *pplayer,
+                                                Tile *ptile,
+                                                int event,
                                                 const char *message);
   void api_notify_event_msg @ event_msg (Player *pplayer, Tile *ptile,
                                         int event, const char *message);
@@ -390,8 +392,8 @@ function notify.event(player, tile, even
   notify.event_msg(player, tile, event, string.format(unpack(arg)))
 end
 
-function notify.embassies(player, ...)
-  notify.embassies_msg(player, string.format(unpack(arg)))
+function notify.embassies(player, ptile, event, ...)
+  notify.embassies_msg(player, ptile, event, string.format(unpack(arg)))
 end
 $]
 
Index: server/scripting/api_notify.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api_notify.c,v
retrieving revision 1.3
diff -p -u -r1.3 api_notify.c
--- server/scripting/api_notify.c       29 Aug 2005 12:59:58 -0000      1.3
+++ server/scripting/api_notify.c       29 Aug 2005 17:05:33 -0000
@@ -23,9 +23,10 @@
 /**************************************************************************
   Notify players which have embassies with pplayer with the given message.
 **************************************************************************/
-void api_notify_embassies_msg(Player *pplayer, const char *message)
+void api_notify_embassies_msg(Player *pplayer, Tile *ptile, int event,
+                             const char *message)
 {
-  notify_embassies(pplayer, NULL, "%s", message);
+  notify_embassies(pplayer, NULL, ptile, event, "%s", message);
 }
 
 /**************************************************************************
Index: server/scripting/api_notify.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api_notify.h,v
retrieving revision 1.2
diff -p -u -r1.2 api_notify.h
--- server/scripting/api_notify.h       3 May 2005 15:09:05 -0000       1.2
+++ server/scripting/api_notify.h       29 Aug 2005 17:05:33 -0000
@@ -16,7 +16,8 @@
 
 #include "api_types.h"
 
-void api_notify_embassies_msg(Player *pplayer, const char *message);
+void api_notify_embassies_msg(Player *pplayer, Tile *ptile,
+                             int event, const char *message);
 void api_notify_event_msg(Player *pplayer, Tile *ptile, int event,
                          const char *message);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13814) add extended info to notify_embassies, Jason Short <=