Freeciv21
Develop your civilization from humble roots to a global empire
notify.h File Reference
#include <cstdarg>
#include "support.h"
#include "events.h"
#include "fc_types.h"
#include "featured_text.h"
#include "packets.h"
#include "srv_main.h"
+ Include dependency graph for notify.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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 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. More...
 
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 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. More...
 
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 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 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 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 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 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 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 event_cache_init ()
 Initializes the event cache. More...
 
void event_cache_free ()
 Frees the event cache. More...
 
void event_cache_clear ()
 Remove all events from the cache. More...
 
void event_cache_remove_old ()
 Remove the old events from the cache. More...
 
void event_cache_add_for_all (const struct packet_chat_msg *packet)
 Add an event to the cache for all connections. More...
 
void event_cache_add_for_global_observers (const struct packet_chat_msg *packet)
 Add an event to the cache for all global observers. More...
 
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. More...
 
struct event_cache_playersevent_cache_player_add (struct event_cache_players *players, const struct player *pplayer) fc__warn_unused_result
 Select players for event_cache_add_for_players(). More...
 
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. More...
 
void send_pending_events (struct connection *pconn, bool include_public)
 Send all available events. More...
 
void event_cache_phases_invalidate ()
 Mark all existing phase values in event cache invalid. More...
 
void event_cache_load (struct section_file *file, const char *section)
 Load the event cache from a savefile. More...
 
void event_cache_save (struct section_file *file, const char *section)
 Save the event cache into the savegame. More...
 

Function Documentation

◆ event_cache_add_for_all()

void event_cache_add_for_all ( const struct packet_chat_msg *  packet)

Add an event to the cache for all connections.

Definition at line 609 of file notify.cpp.

Referenced by chat_msg_to_all(), cmd_reply_line(), establish_new_connection(), event_cache_add_for_player(), notify_conn(), notify_conn_early(), and notify_team().

◆ event_cache_add_for_global_observers()

void event_cache_add_for_global_observers ( const struct packet_chat_msg *  packet)

Add an event to the cache for all global observers.

Definition at line 620 of file notify.cpp.

Referenced by chat_msg_to_global_observers().

◆ event_cache_add_for_player()

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.

N.B.: event_cache_add_for_player(&packet, nullptr) will have the same effect as event_cache_add_for_all(&packet). N.B.: in pregame, this will never success, because players are not fixed.

Definition at line 636 of file notify.cpp.

Referenced by city_turn_notify(), dai_diplo_notify(), and notify_player().

◆ event_cache_add_for_players()

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.

See event_cache_player_add() to see how to select players. This also free the players pointer argument.

N.B.: in pregame, this will never success, because players are not fixed.

Definition at line 662 of file notify.cpp.

Referenced by chat_msg_to_allies(), chat_msg_to_player(), notify_embassies(), notify_research(), notify_research_embassies(), and notify_team().

◆ event_cache_clear()

void event_cache_clear ( )

Remove all events from the cache.

Definition at line 586 of file notify.cpp.

Referenced by freeciv::server::prepare_game().

◆ event_cache_free()

void event_cache_free ( )

Frees the event cache.

Definition at line 574 of file notify.cpp.

Referenced by event_cache_init(), and server_game_free().

◆ event_cache_init()

void event_cache_init ( )

Initializes the event cache.

Definition at line 562 of file notify.cpp.

Referenced by server_game_init().

◆ event_cache_load()

void event_cache_load ( struct section_file file,
const char *  section 
)

Load the event cache from a savefile.

Definition at line 772 of file notify.cpp.

Referenced by sg_load_event_cache().

◆ event_cache_phases_invalidate()

void event_cache_phases_invalidate ( )

Mark all existing phase values in event cache invalid.

Definition at line 966 of file notify.cpp.

Referenced by begin_turn().

◆ event_cache_player_add()

struct event_cache_players* event_cache_player_add ( struct event_cache_players players,
const struct player pplayer 
)

Select players for event_cache_add_for_players().

Pass nullptr as players argument to create a new selection. Usually the usage of this function would look to:

struct event_cache_players *players = nullptr;

players_iterate(pplayer) { if (some_condition) { players = event_cache_player_add(players, pplayer); } } players_iterate_end; Now add to the cache. event_cache_add_for_players(&packet, players); // Free players.

Definition at line 693 of file notify.cpp.

Referenced by chat_msg_to_allies(), chat_msg_to_player(), event_cache_load(), notify_embassies(), notify_research(), notify_research_embassies(), and notify_team().

◆ event_cache_remove_old()

void event_cache_remove_old ( )

Remove the old events from the cache.

Definition at line 591 of file notify.cpp.

Referenced by begin_turn().

◆ event_cache_save()

void event_cache_save ( struct section_file file,
const char *  section 
)

Save the event cache into the savegame.

Definition at line 888 of file notify.cpp.

Referenced by sg_save_event_cache().

◆ notify_conn()

void notify_conn ( struct conn_list *  dest,
const struct tile ptile,
enum event_type  event,
const struct ft_color  color,
const char *  format,
  ... 
)

◆ notify_conn_early()

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,
  ... 
)

◆ notify_embassies()

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,
  ... 
)

◆ notify_player()

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,
  ... 
)

◆ notify_research()

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,
  ... 
)

◆ notify_research_embassies()

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,
  ... 
)

◆ notify_team()

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,
  ... 
)

◆ package_chat_msg()

void package_chat_msg ( struct packet_chat_msg *  packet,
const struct connection sender,
const struct ft_color  color,
const char *  format,
  ... 
)

◆ package_event()

void package_event ( struct packet_chat_msg *  packet,
const struct tile ptile,
enum event_type  event,
const struct ft_color  color,
const char *  format,
  ... 
)

◆ send_pending_events()

void send_pending_events ( struct connection pconn,
bool  include_public 
)

Send all available events.

If include_public is TRUE, also fully global message will be sent.

Definition at line 742 of file notify.cpp.

Referenced by freeciv::server::begin_phase(), connection_attach_real(), and establish_new_connection().

◆ vpackage_chat_msg()

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.

packet: A pointer to the packet. sender: The sender of the message. color: The requested color or ftc_any if not requested. Some colors are predefined in common/featured_text.h. You can pass a custom one using ft_color(). format: The format of the message. vargs: The extra arguments to build the message.

Definition at line 102 of file notify.cpp.

Referenced by package_chat_msg(), and send_chat_msg().

◆ vpackage_event()

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.

packet: A pointer to the packet. ptile: A pointer to a tile the event is occuring. event: The event type. color: The requested color or ftc_any if not requested. Some colors are predefined in common/featured_text.h. You can pass a custom one using ft_color(). format: The format of the message. vargs: The extra arguments to build the message.

Definition at line 145 of file notify.cpp.

Referenced by dai_diplo_notify(), notify_conn(), notify_conn_early(), notify_embassies(), notify_player(), notify_research(), notify_research_embassies(), notify_team(), and package_event().