56 const struct tile *ptile,
57 enum event_type
event,
60 const char *format, va_list vargs)
107 const char *format, va_list vargs)
126 const char *format, ...)
130 va_start(args, format);
148 const struct tile *ptile,
149 enum event_type
event,
151 const char *format, va_list vargs)
169 const struct tile *ptile,
170 enum event_type
event,
172 const char *format, ...)
176 va_start(args, format);
208 if ((packet->
event == E_LOG_ERROR || packet->
event == E_LOG_FATAL)
209 && pconn->access_level != ALLOW_HACK) {
215 && ((NULL == pconn->playing && pconn->observer)
216 || (NULL != pconn->playing
224 real_packet.
tile = -1;
239 const struct tile *ptile,
240 enum event_type
event,
242 const char *format, ...)
247 va_start(args, format);
264 const struct tile *ptile,
265 enum event_type
event,
267 const char *format, ...)
272 va_start(args, format);
292 const struct tile *ptile,
293 enum event_type
event,
295 const char *format, ...)
297 struct conn_list *dest = pplayer ? pplayer->
connections : NULL;
301 va_start(args, format);
316 const struct tile *ptile,
317 enum event_type
event,
319 const char *format, ...)
325 va_start(args, format);
331 && pplayer != other_player) {
346 const struct tile *ptile,
347 enum event_type
event,
349 const char *format, ...)
356 va_start(args, format);
361 dest = conn_list_new();
367 conn_list_append(dest, pconn);
383 conn_list_destroy(dest);
394 const struct player *exclude,
395 enum event_type
event,
397 const char *format, ...)
403 va_start(args, format);
408 if (exclude != aplayer) {
434 const struct player *exclude,
435 enum event_type
event,
437 const char *format, ...)
443 va_start(args, format);
448 if (exclude == aplayer ||
research_get(aplayer) == presearch) {
484#define SPECLIST_TAG event_cache_data
485#define SPECLIST_TYPE struct event_cache_data
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
516 time_t
timestamp,
enum server_states server_status,
560 while (event_cache_data_list_size(
event_cache) > max_events) {
607 current = event_cache_data_list_get(
event_cache, 0);
609 while (current != NULL
612 current = event_cache_data_list_get(
event_cache, 0);
646 const struct player *pplayer)
648 if (NULL == pplayer) {
682 if (NULL != players) {
704 const struct player *pplayer)
706 if (NULL == players) {
711 if (NULL != pplayer) {
722 const struct player *pplayer,
723 bool is_global_observer,
738 return include_public;
740 return (NULL != pplayer
743 return is_global_observer;
762 is_global_observer, include_public)) {
767 strftime(timestr,
sizeof(timestr),
"%H:%M:%S",
771 pdata->packet.turn, timestr, pdata->packet.message);
787 enum server_states server_status;
789 int i, x, y, event_count;
790 time_t timestamp, now;
796 if (0 >= event_count) {
801 for (i = 0; i < event_count; i++) {
814 log_verbose(
"[Event cache %4d] Missing event type.", i);
818 if (!event_type_is_valid(packet.
event)) {
819 log_verbose(
"[Event cache %4d] Not supported event type: %s", i, p);
825 log_verbose(
"[Event cache %4d] Missing message.", i);
837 packet.
phase = phase;
840 "%s.events%d.timestamp",
845 log_verbose(
"[Event cache %4d] Missing server state info.", i);
849 if (!server_states_is_valid(server_status)) {
850 log_verbose(
"[Event cache %4d] Server state no supported: %s", i, p);
856 log_verbose(
"[Event cache %4d] Missing target info.", i);
870 }
else if (
'0' != *q) {
879 if (!valid && NULL == players) {
880 log_verbose(
"[Event cache %4d] invalid target bitmap: %s", i, p);
881 if (NULL != players) {
889 target_type, players);
891 if (NULL != players) {
915 int tile_x = -1, tile_y = -1;
938 "%s.events%d.server_state",
section, event_count);
940 "%s.events%d.event",
section, event_count);
941 switch (pdata->target_type) {
953 fc_snprintf(target,
sizeof(target),
"Global Observers");
980 if (pdata->packet.phase >= 0) {
#define BV_ISSET(bv, bit)
#define BV_ISSET_ANY(vec)
struct player * conn_get_player(const struct connection *pconn)
bool conn_is_global_observer(const struct connection *pconn)
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
#define PHASE_INVALIDATED
#define MAX_NUM_PLAYER_SLOTS
char * capitalized_string(const char *str)
bool is_capitalization_enabled(void)
void free_capitalized(char *str)
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,...)
static bool ft_color_requested(const struct ft_color color)
#define GAME_MAX_EVENT_CACHE_MAX_SIZE
#define fc_assert_ret(condition)
#define log_verbose(message,...)
#define fc_assert_ret_val(condition, val)
bool is_normal_map_pos(int x, int y)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
static int map_pos_to_index(struct civ_map *nmap, int map_x, int map_y)
#define index_to_map_pos(pmap_x, pmap_y, mindex)
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
void notify_research(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
#define event_cache_iterate(pdata)
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
void event_cache_remove_old(void)
void send_pending_events(struct connection *pconn, bool include_public)
void package_chat_msg(struct packet_chat_msg *packet, const struct connection *sender, const struct ft_color color, const char *format,...)
void event_cache_add_for_players(const struct packet_chat_msg *packet, struct event_cache_players *players)
struct event_cache_players * event_cache_player_add(struct event_cache_players *players, const struct player *pplayer)
void event_cache_load(struct section_file *file, const char *section)
void notify_research_embassies(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
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)
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
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)
void notify_team(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
void notify_embassies(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
static void notify_conn_packet(struct conn_list *dest, const struct packet_chat_msg *packet, bool early)
void package_event(struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
void event_cache_clear(void)
void event_cache_free(void)
void event_cache_phases_invalidate(void)
void notify_conn_early(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
void event_cache_add_for_global_observers(const struct packet_chat_msg *packet)
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)
static bool event_cache_match(const struct event_cache_data *pdata, const struct player *pplayer, bool is_global_observer, bool include_public)
static void event_cache_data_free(struct event_cache_data *data)
void event_cache_add_for_player(const struct packet_chat_msg *packet, const struct player *pplayer)
void vpackage_chat_msg(struct packet_chat_msg *packet, const struct connection *sender, const struct ft_color color, const char *format, va_list vargs)
#define event_cache_iterate_end
static bool event_cache_status
void event_cache_add_for_all(const struct packet_chat_msg *packet)
void event_cache_save(struct section_file *file, const char *section)
static struct event_cache_data_list * event_cache
void event_cache_init(void)
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)
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player)
int player_index(const struct player *pplayer)
#define players_iterate_end
#define players_iterate(_pplayer)
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)
#define research_players_iterate(_presearch, _pplayer)
#define research_players_iterate_end
enum server_states server_state(void)
struct civ_game::@30::@34 server
struct civ_game::@30::@34::@35 event_cache
struct conn_list * est_connections
struct packet_game_info info
enum server_states server_state
struct packet_chat_msg packet
enum event_cache_target target_type
char message[MAX_LEN_MSG]
struct conn_list * connections
int fc_snprintf(char *str, size_t n, const char *format,...)
int fc_strcasecmp(const char *str0, const char *str1)
struct tm * fc_localtime(const time_t *timep, struct tm *result)
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
#define sz_strlcpy(dest, src)