Freeciv21
Develop your civilization from humble roots to a global empire
notify.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  __ __ part of Freeciv21. Freeciv21 is free software: you can
4 / \\..// \ redistribute it and/or modify it under the terms of the GNU
5  ( oo ) General Public License as published by the Free Software
6  \__/ Foundation, either version 3 of the License, or (at your
7  option) any later version. You should have received
8  a copy of the GNU General Public License along with Freeciv21. If not,
9  see https://www.gnu.org/licenses/.
10 **************************************************************************/
11 #pragma once
12 
13 #include <cstdarg>
14 
15 // utility
16 #include "support.h" // fc__attribute
17 
18 // common
19 #include "events.h"
20 #include "fc_types.h"
21 #include "featured_text.h" // ftc_*: color pre-definitions.
22 #include "packets.h"
23 
24 // server
25 #include "srv_main.h" // enum server_states
26 
27 struct research;
28 
29 void package_chat_msg(struct packet_chat_msg *packet,
30  const struct connection *sender,
31  const struct ft_color color, const char *format, ...)
32  fc__attribute((__format__(__printf__, 4, 5)));
33 void vpackage_chat_msg(struct packet_chat_msg *packet,
34  const struct connection *sender,
35  const struct ft_color color, const char *format,
36  va_list vargs);
37 void package_event(struct packet_chat_msg *packet, const struct tile *ptile,
38  enum event_type event, const struct ft_color color,
39  const char *format, ...)
40  fc__attribute((__format__(__printf__, 5, 6)));
41 void vpackage_event(struct packet_chat_msg *packet, const struct tile *ptile,
42  enum event_type event, const struct ft_color color,
43  const char *format, va_list vargs);
44 
45 void notify_conn(struct conn_list *dest, const struct tile *ptile,
46  enum event_type event, const struct ft_color color,
47  const char *format, ...)
48  fc__attribute((__format__(__printf__, 5, 6)));
49 void notify_conn_early(struct conn_list *dest, const struct tile *ptile,
50  enum event_type event, const struct ft_color color,
51  const char *format, ...)
52  fc__attribute((__format__(__printf__, 5, 6)));
53 void notify_player(const struct player *pplayer, const struct tile *ptile,
54  enum event_type event, const struct ft_color color,
55  const char *format, ...)
56  fc__attribute((__format__(__printf__, 5, 6)));
57 void notify_embassies(const struct player *pplayer, const struct tile *ptile,
58  enum event_type event, const struct ft_color color,
59  const char *format, ...)
60  fc__attribute((__format__(__printf__, 5, 6)));
61 void notify_team(const struct player *pplayer, const struct tile *ptile,
62  enum event_type event, const struct ft_color color,
63  const char *format, ...)
64  fc__attribute((__format__(__printf__, 5, 6)));
65 void notify_research(const struct research *presearch,
66  const struct player *exclude, enum event_type event,
67  const struct ft_color color, const char *format, ...)
68  fc__attribute((__format__(__printf__, 5, 6)));
69 void notify_research_embassies(const struct research *presearch,
70  const struct player *exclude,
71  enum event_type event,
72  const struct ft_color color,
73  const char *format, ...)
74  fc__attribute((__format__(__printf__, 5, 6)));
75 
76 // Event cache.
77 
78 // The type of event target.
79 struct event_cache_players;
80 
81 void event_cache_init();
82 void event_cache_free();
83 void event_cache_clear();
85 
86 void event_cache_add_for_all(const struct packet_chat_msg *packet);
88  const struct packet_chat_msg *packet);
89 void event_cache_add_for_player(const struct packet_chat_msg *packet,
90  const struct player *pplayer);
91 struct event_cache_players *
93  const struct player *pplayer) fc__warn_unused_result;
94 void event_cache_add_for_players(const struct packet_chat_msg *packet,
95  struct event_cache_players *players);
96 
97 void send_pending_events(struct connection *pconn, bool include_public);
98 
100 
101 struct section_file;
102 void event_cache_load(struct section_file *file, const char *section);
103 void event_cache_save(struct section_file *file, const char *section);
enum event_type event
Definition: events.cpp:68
void void void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) fc__attribute((__format__(__printf__
void event_cache_clear()
Remove all events from the cache.
Definition: notify.cpp:586
void event_cache_init()
Initializes the event cache.
Definition: notify.cpp:562
void void void void void void notify_research(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...) fc__attribute((__format__(__printf__
void send_pending_events(struct connection *pconn, bool include_public)
Send all available events.
Definition: notify.cpp:742
void event_cache_add_for_players(const struct packet_chat_msg *packet, struct event_cache_players *players)
Add an event to the cache for selected players.
Definition: notify.cpp:662
void void void void notify_embassies(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) fc__attribute((__format__(__printf__
void event_cache_load(struct section_file *file, const char *section)
Load the event cache from a savefile.
Definition: notify.cpp:772
void void vpackage_chat_msg(struct packet_chat_msg *packet, const struct connection *sender, const struct ft_color color, const char *format, va_list vargs)
Fill a packet_chat_msg structure for a chat message.
Definition: notify.cpp:102
void event_cache_remove_old()
Remove the old events from the cache.
Definition: notify.cpp:591
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,...) fc__attribute((__format__(__printf__
void package_chat_msg(struct packet_chat_msg *packet, const struct connection *sender, const struct ft_color color, const char *format,...) fc__attribute((__format__(__printf__
void event_cache_free()
Frees the event cache.
Definition: notify.cpp:574
void event_cache_phases_invalidate()
Mark all existing phase values in event cache invalid.
Definition: notify.cpp:966
void void void void void void void notify_research_embassies(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...) fc__attribute((__format__(__printf__
void void void void void notify_team(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) fc__attribute((__format__(__printf__
void 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)
Fill a packet_chat_msg structure for common server event.
Definition: notify.cpp:145
void event_cache_add_for_global_observers(const struct packet_chat_msg *packet)
Add an event to the cache for all global observers.
Definition: notify.cpp:620
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) fc__attribute((__format__(__printf__
void event_cache_add_for_player(const struct packet_chat_msg *packet, const struct player *pplayer)
Add an event to the cache for one player.
Definition: notify.cpp:636
struct event_cache_players * event_cache_player_add(struct event_cache_players *players, const struct player *pplayer) fc__warn_unused_result
Select players for event_cache_add_for_players().
Definition: notify.cpp:693
void event_cache_add_for_all(const struct packet_chat_msg *packet)
Add an event to the cache for all connections.
Definition: notify.cpp:609
void package_event(struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) fc__attribute((__format__(__printf__
void event_cache_save(struct section_file *file, const char *section)
Save the event cache into the savegame.
Definition: notify.cpp:888
Definition: player.h:231
Definition: tile.h:42
int fc__attribute((nonnull(1, 3)))
#define fc__warn_unused_result
Definition: support.h:41