Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2005:
[Freeciv-Dev] (PR#13885) "Technology goal is Magnetism"
Home

[Freeciv-Dev] (PR#13885) "Technology goal is Magnetism"

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13885) "Technology goal is Magnetism"
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Sep 2005 13:46:30 -0700
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Thu Sep 08 19:57:20 2005]:
> 
> Jason Short wrote:
> > <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13885 >
> > 
> > Clicking on the tech tree will repeatedly bring up the same message 
> > ("Technology goal is Magnetism") in the messages dialog.  Obviously the 
> > text should not be sent by the server if the goal isn't changed.
> 
> These patches fix it for 2.0 and the development version.

Hmm, here's a better patch for the development version.  It sends the
message to all players sharing research.  It also adds a new function
notify_research to accomplish this.

-jason

Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.422
diff -p -u -r1.422 plrhand.c
--- server/plrhand.c    5 Sep 2005 15:55:47 -0000       1.422
+++ server/plrhand.c    8 Sep 2005 20:23:47 -0000
@@ -805,6 +805,28 @@ void notify_team(struct player *pplayer,
   va_end(args);
 }
 
+/****************************************************************************
+  Sends a message to all players that share research with pplayer.  Currently
+  this is all players on the same team but it may not always be that way.
+
+  Unlike other notify functions this one does not take a tile argument.  We
+  assume no research message will have a tile associated.
+****************************************************************************/
+void notify_research(struct player *pplayer,
+                    enum event_type event, const char *format, ...)
+{
+  va_list args;
+  struct player_research *research = get_player_research(pplayer);
+
+  /* This function is structured just like notify_team. */
+  va_start(args, format);
+  players_iterate(other_player) {
+    if (get_player_research(other_player) == research) {
+      vnotify_conn(other_player->connections, NULL, event, format, args);
+    }
+  } players_iterate_end;
+  va_end(args);
+}
 
 /**************************************************************************
   Send information about player src, or all players if src is NULL,
Index: server/plrhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.h,v
retrieving revision 1.85
diff -p -u -r1.85 plrhand.h
--- server/plrhand.h    5 Sep 2005 04:21:55 -0000       1.85
+++ server/plrhand.h    8 Sep 2005 20:23:47 -0000
@@ -62,6 +62,9 @@ void notify_embassies(struct player *ppl
 void notify_team(struct player* pplayer, struct tile *ptile,
                  enum event_type event, const char *format, ...)
                  fc__attribute((format (printf, 4, 5)));
+void notify_research(struct player *pplayer,
+                    enum event_type event, const char *format, ...)
+                     fc__attribute((format (printf, 3, 4)));
 
 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.24
diff -p -u -r1.24 techtools.c
--- server/techtools.c  8 Sep 2005 19:51:23 -0000       1.24
+++ server/techtools.c  8 Sep 2005 20:23:47 -0000
@@ -574,12 +574,16 @@ void choose_tech(struct player *plr, Tec
 ****************************************************************************/
 void choose_tech_goal(struct player *plr, Tech_type_id tech)
 {
-  /* It's been suggested that if the research target is empty then
-   * choose_random_tech should be called here. */
-  notify_player(plr, NULL, E_TECH_GAIN /* ? */,
-               _("Technology goal is %s."),
-               get_tech_name(plr, tech));
-  get_player_research(plr)->tech_goal = tech;
+  struct player_research *research = get_player_research(plr);
+
+  if (research && tech != research->tech_goal) {
+    /* It's been suggested that if the research target is empty then
+     * choose_random_tech should be called here. */
+    research->tech_goal = tech;
+    notify_research(plr, E_TECH_GAIN /* ? */,
+                   _("Technology goal is %s."),
+                   get_tech_name(plr, tech));
+  }
 }
 
 /****************************************************************************

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