Freeciv-3.3
Loading...
Searching...
No Matches
notify.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdarg.h>
19
20/* utility */
21#include "bitvector.h"
22#include "log.h"
23#include "registry.h"
24
25/* common */
26#include "connection.h"
27#include "events.h"
28#include "featured_text.h"
29#include "game.h"
30#include "research.h"
31#include "packets.h"
32#include "player.h"
33#include "tile.h"
34
35/* server */
36#include "maphand.h"
37#include "srv_main.h"
38
39#include "notify.h"
40
41
42/**********************************************************************/
55static void package_event_full(struct packet_chat_msg *packet,
56 const struct tile *ptile,
57 enum event_type event,
58 const struct connection *pconn,
59 const struct ft_color color,
60 const char *format, va_list vargs)
61{
62 char buf[MAX_LEN_MSG];
63 char *str;
64
65 fc_assert_ret(NULL != packet);
66
67 packet->tile = (NULL != ptile ? tile_index(ptile) : -1);
68 packet->event = event;
69 packet->conn_id = pconn ? pconn->id : -1;
70 packet->turn = game.info.turn;
71 packet->phase = game.info.phase;
72
73 fc_vsnprintf(buf, sizeof(buf), format, vargs);
76 } else {
77 str = buf;
78 }
79
81 featured_text_apply_tag(str, packet->message, sizeof(packet->message),
83 } else {
84 /* Simple case */
85 sz_strlcpy(packet->message, str);
86 }
87
90 }
91}
92
93/**********************************************************************/
105 const struct connection *sender,
106 const struct ft_color color,
107 const char *format, va_list vargs)
108{
109 package_event_full(packet, NULL, E_CHAT_MSG, sender, color, format, vargs);
110}
111
112/**********************************************************************/
124 const struct connection *sender,
125 const struct ft_color color,
126 const char *format, ...)
127{
128 va_list args;
129
130 va_start(args, format);
131 vpackage_chat_msg(packet, sender, color, format, args);
132 va_end(args);
133}
134
135/**********************************************************************/
147void vpackage_event(struct packet_chat_msg *packet,
148 const struct tile *ptile,
149 enum event_type event,
150 const struct ft_color color,
151 const char *format, va_list vargs)
152{
153 package_event_full(packet, ptile, event, NULL, color, format, vargs);
154}
155
156/**********************************************************************/
168void package_event(struct packet_chat_msg *packet,
169 const struct tile *ptile,
170 enum event_type event,
171 const struct ft_color color,
172 const char *format, ...)
173{
174 va_list args;
175
176 va_start(args, format);
177 vpackage_event(packet, ptile, event, color, format, args);
178 va_end(args);
179}
180
181/**********************************************************************/
192static void notify_conn_packet(struct conn_list *dest,
193 const struct packet_chat_msg *packet,
194 bool early)
195{
196 struct packet_chat_msg real_packet = *packet;
197 int tile = packet->tile;
198 struct tile *ptile = index_to_tile(&(wld.map), tile);
199
200 if (!dest) {
201 dest = game.est_connections;
202 }
203
204 conn_list_iterate(dest, pconn) {
205 /* Avoid sending messages that could potentially reveal
206 * internal information about the server machine to
207 * connections that do not already have hack access. */
208 if ((packet->event == E_LOG_ERROR || packet->event == E_LOG_FATAL)
209 && pconn->access_level != ALLOW_HACK) {
210 continue;
211 }
212
214 && ptile /* special case, see above */
215 && ((NULL == pconn->playing && pconn->observer)
216 || (NULL != pconn->playing
217 && map_is_known(ptile, pconn->playing)))) {
218 /* tile info is OK; see above. */
219 /* FIXME: in the case this is a city event, we should check if the
220 * city is really known. */
221 real_packet.tile = tile;
222 } else {
223 /* No tile info. */
224 real_packet.tile = -1;
225 }
226
227 if (early) {
229 } else {
231 }
233}
234
235/**********************************************************************/
238void notify_conn(struct conn_list *dest,
239 const struct tile *ptile,
240 enum event_type event,
241 const struct ft_color color,
242 const char *format, ...)
243{
244 struct packet_chat_msg genmsg;
245 va_list args;
246
247 va_start(args, format);
248 vpackage_event(&genmsg, ptile, event, color, format, args);
249 va_end(args);
250
252
253 if (!dest || dest == game.est_connections) {
254 /* Add to the cache */
256 }
257}
258
259/**********************************************************************/
263void notify_conn_early(struct conn_list *dest,
264 const struct tile *ptile,
265 enum event_type event,
266 const struct ft_color color,
267 const char *format, ...)
268{
269 struct packet_chat_msg genmsg;
270 va_list args;
271
272 va_start(args, format);
273 vpackage_event(&genmsg, ptile, event, color, format, args);
274 va_end(args);
275
277
278 if (!dest || dest == game.est_connections) {
279 /* Add to the cache */
281 }
282}
283
284/**********************************************************************/
291void notify_player(const struct player *pplayer,
292 const struct tile *ptile,
293 enum event_type event,
294 const struct ft_color color,
295 const char *format, ...)
296{
297 struct conn_list *dest = pplayer ? pplayer->connections : NULL;
298 struct packet_chat_msg genmsg;
299 va_list args;
300
301 va_start(args, format);
302 vpackage_event(&genmsg, ptile, event, color, format, args);
303 va_end(args);
304
306
307 /* Add to the cache */
309}
310
311/**********************************************************************/
315void notify_embassies(const struct player *pplayer,
316 const struct tile *ptile,
317 enum event_type event,
318 const struct ft_color color,
319 const char *format, ...)
320{
321 struct packet_chat_msg genmsg;
322 struct event_cache_players *players = NULL;
323 va_list args;
324
325 va_start(args, format);
326 vpackage_event(&genmsg, ptile, event, color, format, args);
327 va_end(args);
328
329 players_iterate(other_player) {
330 if (team_has_embassy(other_player->team, pplayer)
331 && pplayer != other_player) {
332 notify_conn_packet(other_player->connections, &genmsg, FALSE);
333 players = event_cache_player_add(players, other_player);
334 }
336
337 /* Add to the cache */
339}
340
341/**********************************************************************/
345void notify_team(const struct player *pplayer,
346 const struct tile *ptile,
347 enum event_type event,
348 const struct ft_color color,
349 const char *format, ...)
350{
351 struct conn_list *dest = game.est_connections;
352 struct packet_chat_msg genmsg;
353 struct event_cache_players *players = NULL;
354 va_list args;
355
356 va_start(args, format);
357 vpackage_event(&genmsg, ptile, event, color, format, args);
358 va_end(args);
359
360 if (pplayer) {
361 dest = conn_list_new();
362 players_iterate(other_player) {
363 if (!players_on_same_team(pplayer, other_player)) {
364 continue;
365 }
366 conn_list_iterate(other_player->connections, pconn) {
367 conn_list_append(dest, pconn);
369 players = event_cache_player_add(players, other_player);
371
372 /* Add to the cache */
374
375 } else {
376 /* Add to the cache for all players. */
378 }
379
381
382 if (pplayer) {
383 conn_list_destroy(dest);
384 }
385}
386
387/**********************************************************************/
394 const struct player *exclude,
395 enum event_type event,
396 const struct ft_color color,
397 const char *format, ...)
398{
399 struct packet_chat_msg genmsg;
400 struct event_cache_players *players = NULL;
401 va_list args;
402
403 va_start(args, format);
404 vpackage_event(&genmsg, NULL, event, color, format, args);
405 va_end(args);
406
408 if (exclude != aplayer) {
409 lsend_packet_chat_msg(aplayer->connections, &genmsg);
410 players = event_cache_player_add(players, aplayer);
411 }
413
414 /* Add to the cache */
416}
417
418/**********************************************************************/
434 const struct player *exclude,
435 enum event_type event,
436 const struct ft_color color,
437 const char *format, ...)
438{
439 struct packet_chat_msg genmsg;
440 struct event_cache_players *players = NULL;
441 va_list args;
442
443 va_start(args, format);
444 vpackage_event(&genmsg, NULL, event, color, format, args);
445 va_end(args);
446
448 if (exclude == aplayer || research_get(aplayer) == presearch) {
449 continue;
450 }
451
453 if (team_has_embassy(aplayer->team, rplayer)) {
454 lsend_packet_chat_msg(aplayer->connections, &genmsg);
455 players = event_cache_player_add(players, aplayer);
456 break;
457 }
460
461 /* Add to the cache */
463}
464
465
466/**************************************************************************
467 Event cache datas.
468**************************************************************************/
474
475/* Events are saved in that structure. */
483
484#define SPECLIST_TAG event_cache_data
485#define SPECLIST_TYPE struct event_cache_data
486#include "speclist.h"
487#define event_cache_iterate(pdata) \
488 TYPED_LIST_ITERATE(struct event_cache_data, event_cache, pdata)
489#define event_cache_iterate_end LIST_ITERATE_END
490
494
495/* The full list of the events. */
497
498/* Event cache status: ON(TRUE) / OFF(FALSE); used for saving the
499 * event cache */
501
502/**********************************************************************/
506{
507 free(data);
508}
509
510/**********************************************************************/
514static struct event_cache_data *
518 struct event_cache_players *players)
519{
520 struct event_cache_data *pdata;
521 int max_events;
522
523 if (NULL == event_cache) {
524 /* Don't do log for this, because this could make an infinite
525 * recursion. */
526 return NULL;
527 }
529
530 if (packet->event == E_MESSAGE_WALL) {
531 /* No popups at save game load. */
532 return NULL;
533 }
534
536 /* chat messages should _not_ be saved */
537 return NULL;
538 }
539
540 /* check if cache is active */
541 if (!event_cache_status) {
542 return NULL;
543 }
544
545 pdata = fc_malloc(sizeof(*pdata));
546 pdata->packet = *packet;
547 pdata->timestamp = timestamp;
548 pdata->server_state = server_status;
549 pdata->target_type = target_type;
550 if (players) {
551 pdata->target = players->vector;
552 } else {
553 BV_CLR_ALL(pdata->target);
554 }
556
562 }
563
564 return pdata;
565}
566
567/**********************************************************************/
578
579/**********************************************************************/
590
591/**********************************************************************/
598
599/**********************************************************************/
603{
604 struct event_cache_data *current;
605
606 /* This assumes that entries are in order, the ones to be removed first. */
608
609 while (current != NULL
610 && current->packet.turn + game.server.event_cache.turns <= game.info.turn) {
613 }
614}
615
616/**********************************************************************/
620{
621 if (0 < game.server.event_cache.turns) {
624 }
625}
626
627/**********************************************************************/
637
638/**********************************************************************/
646 const struct player *pplayer)
647{
648 if (NULL == pplayer) {
650 return;
651 }
652
655 struct event_cache_data *pdata;
656
660 BV_SET(pdata->target, player_index(pplayer));
661 }
662}
663
664/**********************************************************************/
672 struct event_cache_players *players)
673{
675 && NULL != players
676 && BV_ISSET_ANY(players->vector)
679 server_state(), ECT_PLAYERS, players);
680 }
681
682 if (NULL != players) {
683 free(players);
684 }
685}
686
687/**********************************************************************/
702struct event_cache_players *
704 const struct player *pplayer)
705{
706 if (NULL == players) {
707 players = fc_malloc(sizeof(*players));
708 BV_CLR_ALL(players->vector);
709 }
710
711 if (NULL != pplayer) {
712 BV_SET(players->vector, player_index(pplayer));
713 }
714
715 return players;
716}
717
718/**********************************************************************/
721static bool event_cache_match(const struct event_cache_data *pdata,
722 const struct player *pplayer,
724 bool include_public)
725{
726 if (server_state() != pdata->server_state) {
727 return FALSE;
728 }
729
731 && game.info.turn < pdata->packet.turn
732 && game.info.turn > pdata->packet.turn - game.server.event_cache.turns) {
733 return FALSE;
734 }
735
736 switch (pdata->target_type) {
737 case ECT_ALL:
738 return include_public;
739 case ECT_PLAYERS:
740 return (NULL != pplayer
741 && BV_ISSET(pdata->target, player_index(pplayer)));
743 return is_global_observer;
744 }
745
746 return FALSE;
747}
748
749/**********************************************************************/
754{
755 const struct player *pplayer = conn_get_player(pconn);
757 char timestr[64];
758 struct packet_chat_msg pcm;
759
761 if (event_cache_match(pdata, pplayer,
764 struct tm tr;
765
766 /* Add turn and time to the message */
767 strftime(timestr, sizeof(timestr), "%H:%M:%S",
768 fc_localtime(&pdata->timestamp, &tr));
769 pcm = pdata->packet;
770 fc_snprintf(pcm.message, sizeof(pcm.message), "(T%d - %s) %s",
771 pdata->packet.turn, timestr, pdata->packet.message);
773 } else {
774 notify_conn_packet(pconn->self, &pdata->packet, FALSE);
775 }
776 }
778}
779
780/**********************************************************************/
783void event_cache_load(struct section_file *file, const char *section)
784{
785 struct packet_chat_msg packet;
786 enum event_cache_target target_type;
788 struct event_cache_players *players = NULL;
789 int i, x, y, event_count;
790 time_t timestamp, now;
791 const char *p, *q;
792
793 event_count = secfile_lookup_int_default(file, 0, "%s.count", section);
794 log_verbose("Saved events: %d.", event_count);
795
796 if (0 >= event_count) {
797 return;
798 }
799
800 now = time(NULL);
801 for (i = 0; i < event_count; i++) {
802 int turn;
803 int phase;
804
805 /* restore packet */
806 x = secfile_lookup_int_default(file, -1, "%s.events%d.x", section, i);
807 y = secfile_lookup_int_default(file, -1, "%s.events%d.y", section, i);
808 packet.tile = (is_normal_map_pos(x, y)
809 ? map_pos_to_index(&(wld.map), x, y) : -1);
810 packet.conn_id = -1;
811
812 p = secfile_lookup_str(file, "%s.events%d.event", section, i);
813 if (NULL == p) {
814 log_verbose("[Event cache %4d] Missing event type.", i);
815 continue;
816 }
818 if (!event_type_is_valid(packet.event)) {
819 log_verbose("[Event cache %4d] Not supported event type: %s", i, p);
820 continue;
821 }
822
823 p = secfile_lookup_str(file, "%s.events%d.message", section, i);
824 if (NULL == p) {
825 log_verbose("[Event cache %4d] Missing message.", i);
826 continue;
827 }
828 sz_strlcpy(packet.message, p);
829
830 /* restore event cache data */
831 turn = secfile_lookup_int_default(file, 0, "%s.events%d.turn",
832 section, i);
833 packet.turn = turn;
834
835 phase = secfile_lookup_int_default(file, PHASE_UNKNOWN, "%s.events%d.phase",
836 section, i);
837 packet.phase = phase;
838
839 timestamp = secfile_lookup_int_default(file, now,
840 "%s.events%d.timestamp",
841 section, i);
842
843 p = secfile_lookup_str(file, "%s.events%d.server_state", section, i);
844 if (NULL == p) {
845 log_verbose("[Event cache %4d] Missing server state info.", i);
846 continue;
847 }
850 log_verbose("[Event cache %4d] Server state no supported: %s", i, p);
851 continue;
852 }
853
854 p = secfile_lookup_str(file, "%s.events%d.target", section, i);
855 if (NULL == p) {
856 log_verbose("[Event cache %4d] Missing target info.", i);
857 continue;
858 } else if (0 == fc_strcasecmp(p, "All")) {
859 target_type = ECT_ALL;
860 } else if (0 == fc_strcasecmp(p, "Global Observers")) {
861 target_type = ECT_GLOBAL_OBSERVERS;
862 } else {
863 bool valid = TRUE;
864
865 target_type = ECT_PLAYERS;
866 q = p;
867 players_iterate(pplayer) {
868 if ('1' == *q) {
869 players = event_cache_player_add(players, pplayer);
870 } else if ('0' != *q) {
871 /* a value not '0' or '1' means a corruption of the savegame */
872 valid = FALSE;
873 break;
874 }
875
876 q++;
878
879 if (!valid && NULL == players) {
880 log_verbose("[Event cache %4d] invalid target bitmap: %s", i, p);
881 if (NULL != players) {
882 FC_FREE(players);
883 }
884 }
885 }
886
887 /* insert event into the cache */
888 (void) event_cache_data_new(&packet, timestamp, server_status,
889 target_type, players);
890
891 if (NULL != players) {
892 /* free the event cache player selection */
893 FC_FREE(players);
894 }
895
896 log_verbose("Event %4d loaded.", i);
897 }
898}
899
900/**********************************************************************/
903void event_cache_save(struct section_file *file, const char *section)
904{
905 int event_count = 0;
906
907 /* stop event logging; this way events from log_*() will not be added
908 * to the event list while saving the event list */
910
912 struct tile *ptile = index_to_tile(&(wld.map), pdata->packet.tile);
913 char target[MAX_NUM_PLAYER_SLOTS + 1];
914 char *p;
915 int tile_x = -1, tile_y = -1;
916
917 if (ptile != NULL) {
919 }
920
921 secfile_insert_int(file, pdata->packet.turn, "%s.events%d.turn",
923 if (pdata->packet.phase != PHASE_UNKNOWN) {
924 /* Do not save current value of PHASE_UNKNOWN to savegame.
925 * It practically means that "savegame had no phase stored".
926 * Note that the only case where phase might be PHASE_UNKNOWN
927 * may be present is that the event was loaded from previous
928 * savegame created by a freeciv version that did not store event
929 * phases. */
930 secfile_insert_int(file, pdata->packet.phase, "%s.events%d.phase",
932 }
933 secfile_insert_int(file, pdata->timestamp, "%s.events%d.timestamp",
935 secfile_insert_int(file, tile_x, "%s.events%d.x", section, event_count);
936 secfile_insert_int(file, tile_y, "%s.events%d.y", section, event_count);
937 secfile_insert_str(file, server_states_name(pdata->server_state),
938 "%s.events%d.server_state", section, event_count);
939 secfile_insert_str(file, event_type_name(pdata->packet.event),
940 "%s.events%d.event", section, event_count);
941 switch (pdata->target_type) {
942 case ECT_ALL:
943 fc_snprintf(target, sizeof(target), "All");
944 break;
945 case ECT_PLAYERS:
946 p = target;
947 players_iterate(pplayer) {
948 *p++ = (BV_ISSET(pdata->target, player_index(pplayer)) ? '1' : '0');
950 *p = '\0';
951 break;
953 fc_snprintf(target, sizeof(target), "Global Observers");
954 break;
955 }
956 secfile_insert_str(file, target, "%s.events%d.target",
958 secfile_insert_str(file, pdata->packet.message, "%s.events%d.message",
960
961 log_verbose("Event %4d saved.", event_count);
962
963 event_count++;
965
966 /* save the number of events in the event cache */
967 secfile_insert_int(file, event_count, "%s.count", section);
968
969 log_verbose("Events saved: %d.", event_count);
970
972}
973
974/**********************************************************************/
978{
980 if (pdata->packet.phase >= 0) {
981 pdata->packet.phase = PHASE_INVALIDATED;
982 }
984}
#define str
Definition astring.c:76
#define BV_CLR_ALL(bv)
Definition bitvector.h:103
#define BV_SET(bv, bit)
Definition bitvector.h:89
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
#define BV_ISSET_ANY(vec)
Definition bitvector.h:117
char * incite_cost
Definition comments.c:76
#define MAX_LEN_MSG
Definition conn_types.h:37
struct player * conn_get_player(const struct connection *pconn)
Definition connection.c:763
bool conn_is_global_observer(const struct connection *pconn)
Definition connection.c:753
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
#define conn_list_iterate_end
Definition connection.h:110
enum event_type event
Definition events.c:81
#define PHASE_INVALIDATED
Definition fc_types.h:739
#define MAX_NUM_PLAYER_SLOTS
Definition fc_types.h:32
#define PHASE_UNKNOWN
Definition fc_types.h:741
char * capitalized_string(const char *str)
Definition fcintl.c:66
bool is_capitalization_enabled(void)
Definition fcintl.c:101
void free_capitalized(char *str)
Definition fcintl.c:85
size_t featured_text_apply_tag(const char *text_source, char *featured_text, size_t featured_text_len, enum text_tag_type tag_type, ft_offset_t start_offset, ft_offset_t stop_offset,...)
#define FT_OFFSET_UNSET
static bool ft_color_requested(const struct ft_color color)
@ TTT_COLOR
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
#define GAME_MAX_EVENT_CACHE_MAX_SIZE
Definition game.h:719
#define fc_assert_ret(condition)
Definition log.h:192
#define log_verbose(message,...)
Definition log.h:110
#define fc_assert_ret_val(condition, val)
Definition log.h:195
bool is_normal_map_pos(int x, int y)
Definition map.c:1099
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:471
static int map_pos_to_index(struct civ_map *nmap, int map_x, int map_y)
Definition map.h:733
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition map.h:229
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Definition maphand.c:899
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_malloc(sz)
Definition mem.h:34
void notify_research(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:393
#define event_cache_iterate(pdata)
Definition notify.c:487
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:291
void event_cache_remove_old(void)
Definition notify.c:602
void send_pending_events(struct connection *pconn, bool include_public)
Definition notify.c:753
void package_chat_msg(struct packet_chat_msg *packet, const struct connection *sender, const struct ft_color color, const char *format,...)
Definition notify.c:123
void event_cache_add_for_players(const struct packet_chat_msg *packet, struct event_cache_players *players)
Definition notify.c:671
struct event_cache_players * event_cache_player_add(struct event_cache_players *players, const struct player *pplayer)
Definition notify.c:703
void event_cache_load(struct section_file *file, const char *section)
Definition notify.c:783
void notify_research_embassies(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:433
static struct event_cache_data * event_cache_data_new(const struct packet_chat_msg *packet, time_t timestamp, enum server_states server_status, enum event_cache_target target_type, struct event_cache_players *players)
Definition notify.c:515
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:238
void vpackage_event(struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format, va_list vargs)
Definition notify.c:147
event_cache_target
Definition notify.c:469
@ ECT_ALL
Definition notify.c:470
@ ECT_PLAYERS
Definition notify.c:471
@ ECT_GLOBAL_OBSERVERS
Definition notify.c:472
void notify_team(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:345
void notify_embassies(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:315
static void notify_conn_packet(struct conn_list *dest, const struct packet_chat_msg *packet, bool early)
Definition notify.c:192
void package_event(struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:168
void event_cache_clear(void)
Definition notify.c:594
void event_cache_free(void)
Definition notify.c:582
void event_cache_phases_invalidate(void)
Definition notify.c:977
void notify_conn_early(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:263
void event_cache_add_for_global_observers(const struct packet_chat_msg *packet)
Definition notify.c:630
static void package_event_full(struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct connection *pconn, const struct ft_color color, const char *format, va_list vargs)
Definition notify.c:55
static bool event_cache_match(const struct event_cache_data *pdata, const struct player *pplayer, bool is_global_observer, bool include_public)
Definition notify.c:721
static void event_cache_data_free(struct event_cache_data *data)
Definition notify.c:505
void event_cache_add_for_player(const struct packet_chat_msg *packet, const struct player *pplayer)
Definition notify.c:645
void vpackage_chat_msg(struct packet_chat_msg *packet, const struct connection *sender, const struct ft_color color, const char *format, va_list vargs)
Definition notify.c:104
#define event_cache_iterate_end
Definition notify.c:489
static bool event_cache_status
Definition notify.c:500
void event_cache_add_for_all(const struct packet_chat_msg *packet)
Definition notify.c:619
void event_cache_save(struct section_file *file, const char *section)
Definition notify.c:903
static struct event_cache_data_list * event_cache
Definition notify.c:496
void event_cache_init(void)
Definition notify.c:570
void lsend_packet_chat_msg(struct conn_list *dest, const struct packet_chat_msg *packet)
int send_packet_chat_msg(struct connection *pc, const struct packet_chat_msg *packet)
int send_packet_early_chat_msg(struct connection *pc, const struct packet_early_chat_msg *packet)
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
Definition player.c:1480
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player)
Definition player.c:220
int player_index(const struct player *pplayer)
Definition player.c:829
#define players_iterate_end
Definition player.h:542
#define players_iterate(_pplayer)
Definition player.h:537
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
#define secfile_insert_int(secfile, value, path,...)
#define secfile_insert_str(secfile, string, path,...)
struct research * research_get(const struct player *pplayer)
Definition research.c:128
#define research_players_iterate(_presearch, _pplayer)
Definition research.h:166
#define research_players_iterate_end
Definition research.h:170
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
enum server_states server_state(void)
Definition srv_main.c:338
bool chat
Definition game.h:260
int max_size
Definition game.h:259
struct conn_list * est_connections
Definition game.h:97
struct packet_game_info info
Definition game.h:89
struct civ_game::@32::@36::@38 event_cache
struct civ_game::@32::@36 server
int turns
Definition game.h:258
Definition colors.h:21
enum server_states server_state
Definition notify.c:479
struct packet_chat_msg packet
Definition notify.c:477
bv_player target
Definition notify.c:481
time_t timestamp
Definition notify.c:478
enum event_cache_target target_type
Definition notify.c:480
bv_player vector
Definition notify.c:492
char message[MAX_LEN_MSG]
enum event_type event
struct conn_list * connections
Definition player.h:298
Definition tile.h:50
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
struct tm * fc_localtime(const time_t *timep, struct tm *result)
Definition support.c:1301
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition support.c:886
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define tile_index(_pt_)
Definition tile.h:89