Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] (PR#13357) notify_team
Home

[Freeciv-Dev] (PR#13357) notify_team

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13357) notify_team
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Tue, 28 Jun 2005 11:08:36 -0700
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Tue Jun 28 17:20:56 2005]:
> 
> Mateusz Stefek wrote:
> > <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13357 >
> > 
> > This patch introduces new functions: notify_team() and notify_team_ex().
> > They are used in found_new_tech()
> 
> There shouldn't be a notify_team function.  All team notificiations
> (like all player notifications, for that matter) should have an event
> type.  Only out-of-game conn notifications should have no event type.
> 
> -jason
> 
OK.
I choosed E_GAIN_TECH for "You are the first who researched philosophy"
message.
--
mateusz 

? server/civgame-1000.sav.gz
? server/civgame-1500.sav.gz
? server/civgame-2000.sav.gz
? server/civgame-2500.sav.gz
? server/civgame-3000.sav.gz
? server/civgame-3500.sav.gz
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.393
diff -u -r1.393 plrhand.c
--- server/plrhand.c    24 Jun 2005 10:12:47 -0000      1.393
+++ server/plrhand.c    28 Jun 2005 18:06:32 -0000
@@ -781,6 +781,26 @@
 }
 
 /**************************************************************************
+  Sends a message to all players on pplayer's team
+**************************************************************************/
+void notify_team_ex(struct player* pplayer,
+                    struct tile *ptile, enum event_type event,
+                   const char* format, ...)
+{
+  va_list args;
+
+  va_start(args, format);
+  players_iterate(other_player) {
+    if (!players_on_same_team(pplayer, other_player)) {
+      continue;
+    }
+    vnotify_conn_ex(other_player->connections, ptile, event, format, args);
+  } players_iterate_end;
+  va_end(args);
+}
+
+
+/**************************************************************************
   Send information about player src, or all players if src is NULL,
   to specified clients dest (dest may not be NULL).
 
Index: server/plrhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.h,v
retrieving revision 1.76
diff -u -r1.76 plrhand.h
--- server/plrhand.h    24 Jun 2005 10:12:47 -0000      1.76
+++ server/plrhand.h    28 Jun 2005 18:06:32 -0000
@@ -60,6 +60,9 @@
 void notify_embassies(struct player *pplayer, struct player *exclude,
                      const char *format, ...)
                      fc__attribute((format (printf, 3, 4)));
+void notify_team_ex(struct player* pplayer, struct tile *ptile,
+                 enum event_type event, const char *format, ...)
+                 fc__attribute((format (printf, 4, 5)));
 
 struct conn_list *player_reply_dest(struct player *pplayer);
 
Index: server/techtools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/techtools.c,v
retrieving revision 1.8
diff -u -r1.8 techtools.c
--- server/techtools.c  28 Jun 2005 17:32:53 -0000      1.8
+++ server/techtools.c  28 Jun 2005 18:06:35 -0000
@@ -351,7 +351,7 @@
     /* try to pick new tech to research */
 
     if (choose_goal_tech(plr)) {
-      notify_player_ex(plr, NULL, E_TECH_LEARNED,
+      notify_team_ex(plr, NULL, E_TECH_LEARNED,
                       _("Learned %s.  "
                         "Our scientists focus on %s, goal is %s."),
                       get_tech_name(plr, tech_found),
@@ -369,7 +369,7 @@
       if (research->researching != A_UNSET 
           && (!is_future_tech(research->researching)
              || !is_future_tech(tech_found))) {
-       notify_player_ex(plr, NULL, E_TECH_LEARNED,
+       notify_team_ex(plr, NULL, E_TECH_LEARNED,
                         _("Learned %s.  Scientists "
                           "choose to research %s."),
                         get_tech_name(plr, tech_found),
@@ -382,10 +382,10 @@
        research->future_tech++;
        my_snprintf(buffer2, sizeof(buffer2), _("Researching %s."),
                    get_tech_name(plr, research->researching));
-       notify_player_ex(plr, NULL, E_TECH_LEARNED, "%s%s", buffer1,
+       notify_team_ex(plr, NULL, E_TECH_LEARNED, "%s%s", buffer1,
                         buffer2);
       } else {
-       notify_player_ex(plr, NULL, E_TECH_LEARNED,
+       notify_team_ex(plr, NULL, E_TECH_LEARNED,
                         _("Learned %s.  Scientists "
                           "do not know what to research next."),
                         get_tech_name(plr, tech_found));
@@ -405,10 +405,12 @@
       notify_player(plr, _("%s"),
                    _(advances[tech_found].bonus_message));
     } else {
-      notify_player(plr, _("Great scientists from all the "
-                          "world join your civilization: you get "
-                          "an immediate advance."));
+      notify_team_ex(plr, NULL, E_TECH_GAIN,
+                     _("Great scientists from all the "
+                      "world join your civilization: you get "
+                      "an immediate advance."));
     }
+    
     if (research->researching == A_UNSET) {
       choose_random_tech(plr);
     }

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