[Freeciv-Dev] (PR#13357) notify_team
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<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()
--
mateusz
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 07:51:04 -0000
@@ -781,6 +781,51 @@
}
/**************************************************************************
+ Sends a message to all players on pplayer's team
+**************************************************************************/
+void notify_team(struct player* pplayer, const char *format, ...)
+{
+ struct packet_chat_msg genmsg;
+ va_list args;
+
+ va_start(args, format);
+ my_vsnprintf(genmsg.message, sizeof(genmsg.message), format, args);
+ va_end(args);
+
+ genmsg.x = -1;
+ genmsg.y = -1;
+ genmsg.event = E_NOEVENT;
+ genmsg.conn_id = -1;
+
+ players_iterate(other_player) {
+ if (!players_on_same_team(pplayer, other_player)) {
+ continue;
+ }
+ lsend_packet_chat_msg(other_player->connections, &genmsg);
+ } players_iterate_end;
+}
+
+/**************************************************************************
+ 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 07:51:04 -0000
@@ -60,6 +60,11 @@
void notify_embassies(struct player *pplayer, struct player *exclude,
const char *format, ...)
fc__attribute((format (printf, 3, 4)));
+void notify_team(struct player* pplayer, const char *format, ...)
+ fc__attribute((format (printf, 2, 3)));
+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.6
diff -u -r1.6 techtools.c
--- server/techtools.c 27 Jun 2005 08:30:34 -0000 1.6
+++ server/techtools.c 28 Jun 2005 07:51:04 -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,7 +405,7 @@
notify_player(plr, _("%s"),
_(advances[tech_found].bonus_message));
} else {
- notify_player(plr, _("Great scientists from all the "
+ notify_team(plr, _("Great scientists from all the "
"world join your civilization: you get "
"an immediate advance."));
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13357) notify_team,
Mateusz Stefek <=
|
|