![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <cstdarg>#include "bitvector.h"#include "fcintl.h"#include "log.h"#include "registry.h"#include "registry_ini.h"#include "connection.h"#include "events.h"#include "featured_text.h"#include "game.h"#include "packets.h"#include "player.h"#include "research.h"#include "tile.h"#include "maphand.h"#include "srv_main.h"#include "notify.h"#include "speclist.h"
Include dependency graph for notify.cpp:Go to the source code of this file.
Classes | |
| struct | event_cache_data |
| struct | event_cache_players |
Macros | |
| #define | SPECLIST_TAG event_cache_data |
| #define | SPECLIST_TYPE struct event_cache_data |
| #define | event_cache_iterate(pdata) TYPED_LIST_ITERATE(struct event_cache_data, event_cache, pdata) |
| #define | event_cache_iterate_end LIST_ITERATE_END |
Enumerations | |
| enum | event_cache_target { ECT_ALL , ECT_PLAYERS , ECT_GLOBAL_OBSERVERS } |
| Event cache datas. More... | |
Functions | |
| 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) |
| Fill a packet_chat_msg structure. More... | |
| 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_chat_msg (struct packet_chat_msg *packet, const struct connection *sender, const struct ft_color color, const char *format,...) |
| Fill a packet_chat_msg structure for a chat message. More... | |
| 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 | package_event (struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) |
| Fill a packet_chat_msg structure for common server event. More... | |
| static void | notify_conn_packet (struct conn_list *dest, const struct packet_chat_msg *packet, bool early) |
| This is the basis for following notify_* functions. More... | |
| void | notify_conn (struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) |
| See notify_conn_packet - this is just the "non-v" version, with varargs. More... | |
| void | notify_conn_early (struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) |
| See notify_conn_packet - this is just the "non-v" version, with varargs. More... | |
| void | notify_player (const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) |
| Similar to notify_conn_packet (see also), but takes player as "destination". More... | |
| void | notify_embassies (const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) |
| Send message to all players who have an embassy with pplayer, but excluding pplayer and specified player. More... | |
| void | notify_team (const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) |
| Sends a message to all players on pplayer's team. More... | |
| void | notify_research (const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...) |
| Sends a message to all players that share research. More... | |
| void | notify_research_embassies (const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...) |
| Sends a message to all players that have embassies with someone who shares research. More... | |
| static void | event_cache_data_free (struct event_cache_data *data) |
| Callback for freeing event cache data. More... | |
| 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) |
| Creates a new event_cache_data, appened to the list. More... | |
| 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... | |
| 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... | |
| 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(). More... | |
| static bool | event_cache_match (const struct event_cache_data *pdata, const struct player *pplayer, bool is_global_observer, bool include_public) |
| Returns whether the event may be displayed for the connection. More... | |
| void | send_pending_events (struct connection *pconn, bool include_public) |
| Send all available events. 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... | |
| void | event_cache_phases_invalidate () |
| Mark all existing phase values in event cache invalid. More... | |
Variables | |
| static struct event_cache_data_list * | event_cache = nullptr |
| static bool | event_cache_status = false |
| #define event_cache_iterate | ( | pdata | ) | TYPED_LIST_ITERATE(struct event_cache_data, event_cache, pdata) |
Definition at line 479 of file notify.cpp.
| #define event_cache_iterate_end LIST_ITERATE_END |
Definition at line 481 of file notify.cpp.
| #define SPECLIST_TAG event_cache_data |
Definition at line 476 of file notify.cpp.
| #define SPECLIST_TYPE struct event_cache_data |
Definition at line 477 of file notify.cpp.
| enum event_cache_target |
Event cache datas.
| Enumerator | |
|---|---|
| ECT_ALL | |
| ECT_PLAYERS | |
| ECT_GLOBAL_OBSERVERS | |
Definition at line 465 of file notify.cpp.
| 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().
| 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().
| 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().
| 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().
| void event_cache_clear | ( | ) |
Remove all events from the cache.
Definition at line 586 of file notify.cpp.
Referenced by freeciv::server::prepare_game().
|
static |
Callback for freeing event cache data.
Definition at line 497 of file notify.cpp.
Referenced by event_cache_init().
|
static |
Creates a new event_cache_data, appened to the list.
It mays remove an old entry if needed.
Definition at line 507 of file notify.cpp.
Referenced by event_cache_add_for_all(), event_cache_add_for_global_observers(), event_cache_add_for_player(), event_cache_add_for_players(), and event_cache_load().
| 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().
| void event_cache_init | ( | ) |
Initializes the event cache.
Definition at line 562 of file notify.cpp.
Referenced by server_game_init().
| 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().
|
static |
Returns whether the event may be displayed for the connection.
Definition at line 711 of file notify.cpp.
Referenced by send_pending_events().
| 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().
| 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().
| void event_cache_remove_old | ( | ) |
Remove the old events from the cache.
Definition at line 591 of file notify.cpp.
Referenced by begin_turn().
| 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().
| void notify_conn | ( | struct conn_list * | dest, |
| const struct tile * | ptile, | ||
| enum event_type | event, | ||
| const struct ft_color | color, | ||
| const char * | format, | ||
| ... | |||
| ) |
See notify_conn_packet - this is just the "non-v" version, with varargs.
Definition at line 235 of file notify.cpp.
Referenced by aifill(), aifill_action(), announce_player(), auth_handle_reply(), cancelvote_command(), check_for_game_over(), city_global_turn_notify(), cmd_reply_line(), complain_ambiguous(), connection_detach(), debug_command(), delegate_command(), do_nuclear_explosion(), end_command(), establish_new_connection(), handle_chat_msg_req(), handle_edit_city(), handle_edit_city_create(), handle_edit_city_remove(), handle_edit_mode(), handle_edit_player(), handle_edit_player_create(), handle_edit_player_remove(), handle_edit_player_vision(), handle_edit_startpos(), handle_edit_startpos_full(), handle_edit_tile(), handle_edit_tile_extra(), handle_edit_tile_terrain(), handle_edit_toggle_fogofwar(), handle_edit_unit(), handle_edit_unit_create(), handle_edit_unit_remove(), handle_edit_unit_remove_by_id(), handle_nation_select_req(), handle_player_ready(), handle_report_req(), handle_save_scenario(), handle_stdin_input_real(), lost_connection_to_client(), nationset_action(), notify_if_first_access_level_is_available(), notify_ruleset_fallback(), player_limit_to_max_rates(), save_game(), save_thread_run(), send_delegation_info(), send_year_to_clients(), server_packet_input(), server_remove_unit_full(), set_running_game_access_level(), srv_ready(), start_cmd_reply(), start_command(), start_game(), surrender_command(), take_command(), timing_results_real(), update_timeout(), and wall().
| void notify_conn_early | ( | struct conn_list * | dest, |
| const struct tile * | ptile, | ||
| enum event_type | event, | ||
| const struct ft_color | color, | ||
| const char * | format, | ||
| ... | |||
| ) |
See notify_conn_packet - this is just the "non-v" version, with varargs.
Use for early connecting protocol messages.
Definition at line 258 of file notify.cpp.
Referenced by auth_user().
|
static |
This is the basis for following notify_* functions.
It uses the struct packet_chat_msg as defined by vpackage_event().
Notify specified connections of an event of specified type (from events.h) and specified (x,y) coords associated with the event. Coords will only apply if game has started and the conn's player knows that tile (or nullptr == pconn->playing && pconn->observer). If coords are not required, caller should specify (x,y) = (-1,-1); otherwise make sure that the coordinates have been normalized.
Definition at line 186 of file notify.cpp.
Referenced by notify_conn(), notify_conn_early(), notify_embassies(), notify_player(), notify_team(), and send_pending_events().
| void notify_embassies | ( | const struct player * | pplayer, |
| const struct tile * | ptile, | ||
| enum event_type | event, | ||
| const struct ft_color | color, | ||
| const char * | format, | ||
| ... | |||
| ) |
Send message to all players who have an embassy with pplayer, but excluding pplayer and specified player.
Definition at line 306 of file notify.cpp.
Referenced by api_notify_embassies_msg().
| void notify_player | ( | const struct player * | pplayer, |
| const struct tile * | ptile, | ||
| enum event_type | event, | ||
| const struct ft_color | color, | ||
| const char * | format, | ||
| ... | |||
| ) |
Similar to notify_conn_packet (see also), but takes player as "destination".
If player != nullptr, sends to all connections for that player. If player == nullptr, sends to all game connections, to support old code, but this feature may go away - should use notify_conn(nullptr) instead.
Definition at line 284 of file notify.cpp.
Referenced by announce_trade_route_removal(), api_edit_give_technology(), api_notify_event_msg(), apply_disaster(), auto_arrange_workers(), begin_turn(), bounce_unit(), build_free_small_wonders(), can_unit_move_to_tile_with_notify(), change_build_target(), check_city_migrations_player(), check_for_game_over(), check_player_max_rates(), check_pollution(), city_add_unit(), city_build(), city_build_building(), city_build_unit(), city_distribute_surplus_shields(), city_empty_food_stock(), city_handle_disorder(), city_illness_strike(), city_increase_size(), city_landlocked_sell_coastal_improvements(), city_map_update_radius_sq(), city_populate(), civil_war(), create_barbarian_player(), create_city(), dai_city_sell_noncritical(), diplomat_bribe(), diplomat_embassy(), diplomat_escape_full(), diplomat_get_tech(), diplomat_incite(), diplomat_infiltrate_tile(), diplomat_may_lose_gold(), diplomat_sabotage(), disband_city(), do_airline(), do_attack(), do_capture_units(), do_city_migration(), do_expel_unit(), do_heal_unit(), do_nuke_tile(), do_paradrop(), do_spaceship_place(), do_tech_parasite_effect(), do_unit_change_homecity(), do_unit_establish_trade(), do_unit_strike_city_building(), do_unit_strike_city_production(), do_unit_upgrade(), do_upgrade_effects(), end_phase(), end_turn(), execute_orders(), explain_why_no_action_enabled(), forget_tech_transfered(), found_new_tech(), global_warming(), government_change(), handle_city_change(), handle_city_rename(), handle_diplomacy_accept_treaty_req(), handle_diplomacy_cancel_pact_explicit(), handle_diplomacy_init_meeting_req(), handle_nation_select_req(), handle_player_change_government(), handle_player_rates(), handle_spaceship_launch(), handle_unit_get_actions(), handle_unit_type_upgrade(), hut_get_limited(), illegal_action(), illegal_action_msg(), illegal_action_pay_price(), kill_player(), kill_unit(), make_contact(), notify_actor_caught(), notify_actor_success(), notify_global_caught(), notify_global_success(), notify_illegal_armistice_units(), notify_unit_experience(), notify_victim_caught(), notify_victim_success(), nuclear_winter(), player_restore_units(), really_diplomacy_cancel_meeting(), really_handle_city_buy(), really_handle_city_sell(), remove_city(), remove_illegal_armistice_units(), remove_obsolete_buildings_city(), research_tech_lost(), revolution_length(), sell_random_building(), sell_random_unit(), server_remove_unit_full(), spaceship_arrived(), spaceship_lost(), spy_nuke_city(), spy_poison(), spy_sabotage_unit(), spy_spread_plague(), spy_steal_gold(), spy_steal_some_maps(), srv_scores(), steal_a_tech(), teleport_unit_to_city(), transfer_city(), transfer_city_units(), transfer_unit(), try_summon_barbarians(), try_to_save_unit(), unit_activities_cancel_all_illegal(), unit_bombard(), unit_can_do_action_now(), unit_conquer_city(), unit_convert(), unit_do_destroy_city(), unit_do_help_build(), unit_lost_with_transport(), unit_move_handling(), unit_nuke(), update_city_activities(), update_city_activity(), update_diplomatics(), update_revolution(), upgrade_all_city_extras(), upgrade_building_prod(), upgrade_unit_prod(), wakeup_neighbor_sentries(), worklist_change_build_target(), and worklist_item_postpone_req_vec().
| void notify_research | ( | const struct research * | presearch, |
| const struct player * | exclude, | ||
| enum event_type | event, | ||
| const struct ft_color | color, | ||
| const char * | format, | ||
| ... | |||
| ) |
Sends a message to all players that share research.
Unlike other notify functions this one does not take a tile argument. We assume no research message will have a tile associated.
Definition at line 386 of file notify.cpp.
Referenced by api_edit_give_technology(), api_notify_research_msg(), choose_tech_goal(), city_build_building(), do_tech_parasite_effect(), forget_tech_transfered(), found_new_tech(), handle_diplomacy_accept_treaty_req(), steal_a_tech(), and update_bulbs().
| void notify_research_embassies | ( | const struct research * | presearch, |
| const struct player * | exclude, | ||
| enum event_type | event, | ||
| const struct ft_color | color, | ||
| const char * | format, | ||
| ... | |||
| ) |
Sends a message to all players that have embassies with someone who shares research.
Unlike other notify functions this one does not take a tile argument. We assume no research message will have a tile associated.
Exclude parameter excludes everyone who has embassy (only) with that player.
FIXME: Should not send multiple messages if one has embassy with multiple members of the research group, should really exclude ones having embassy with the exclude -one as the use-case for exclusion is that different message is being sent to those excluded here.
Definition at line 426 of file notify.cpp.
Referenced by api_edit_give_technology(), api_notify_research_embassies_msg(), city_build_building(), do_tech_parasite_effect(), found_new_tech(), handle_diplomacy_accept_treaty_req(), research_tech_lost(), steal_a_tech(), and tech_researched().
| void notify_team | ( | const struct player * | pplayer, |
| const struct tile * | ptile, | ||
| enum event_type | event, | ||
| const struct ft_color | color, | ||
| const char * | format, | ||
| ... | |||
| ) |
Sends a message to all players on pplayer's team.
If 'pplayer' is nullptr, sends to all players.
Definition at line 336 of file notify.cpp.
Referenced by cancelvote_command(), check_vote(), and handle_stdin_input_real().
| void package_chat_msg | ( | struct packet_chat_msg * | packet, |
| const struct connection * | sender, | ||
| const struct ft_color | color, | ||
| const char * | format, | ||
| ... | |||
| ) |
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. ...: The extra arguments to build the message.
Definition at line 122 of file notify.cpp.
Referenced by chat_msg_to_all(), chat_msg_to_allies(), chat_msg_to_global_observers(), and chat_msg_to_player().
| void package_event | ( | struct packet_chat_msg * | packet, |
| const struct tile * | ptile, | ||
| enum event_type | event, | ||
| const struct ft_color | color, | ||
| const char * | format, | ||
| ... | |||
| ) |
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. ...: The extra arguments to build the message.
Definition at line 164 of file notify.cpp.
Referenced by city_turn_notify(), cmd_reply_line(), establish_new_connection(), and set_command().
|
static |
Fill a packet_chat_msg structure.
packet: A pointer to the packet. ptile: A pointer to a tile the event is occuring. event: The event type. pconn: The sender of the event (e.g. when event is E_CHAT_MSG). 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 52 of file notify.cpp.
Referenced by vpackage_chat_msg(), and vpackage_event().
| 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().
| 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().
| 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().
|
static |
Definition at line 488 of file notify.cpp.
Referenced by event_cache_clear(), event_cache_data_new(), event_cache_free(), event_cache_init(), and event_cache_remove_old().
|
static |
Definition at line 492 of file notify.cpp.
Referenced by event_cache_data_new(), event_cache_free(), event_cache_init(), and event_cache_save().