Freeciv-3.1
|
#include <stdarg.h>
#include <string.h>
#include "capability.h"
#include "log.h"
#include "mem.h"
#include "timing.h"
#include "client_main.h"
#include "mapctrl_g.h"
#include "cma_core.h"
#include "cma_fec.h"
#include "sha.h"
#include "agents.h"
#include "speclist.h"
Go to the source code of this file.
Data Structures | |
struct | call |
Macros | |
#define | log_request_ids(...) /* log_test(__VA_ARGS__) */ |
#define | log_todo_lists(...) /* log_test(__VA_ARGS__) */ |
#define | log_meta_callback(...) log_debug(__VA_ARGS__) |
#define | log_debug_freeze(...) /* log_test(__VA_ARGS__) */ |
#define | MAX_AGENTS 10 |
#define | SPECLIST_TAG call |
#define | SPECLIST_TYPE struct call |
#define | call_list_iterate(calllist, pcall) TYPED_LIST_ITERATE(struct call, calllist, pcall) |
#define | call_list_iterate_end LIST_ITERATE_END |
#define | call_list_both_iterate(calllist, plink, pcall) |
#define | call_list_both_iterate_end LIST_BOTH_ITERATE_END |
Functions | |
static bool | calls_are_equal (const struct call *pcall1, const struct call *pcall2) |
static void | enqueue_call (enum oct type, enum callback_type cb_type, struct my_agent *agent,...) |
static struct call * | remove_and_return_a_call (void) |
static void | execute_call (const struct call *call) |
static void | call_handle_methods (void) |
static void | freeze (void) |
static void | thaw (void) |
static struct my_agent * | agent_by_name (const char *agent_name) |
static bool | is_outstanding_request (struct my_agent *agent) |
void | agents_init (void) |
void | agents_free (void) |
void | register_agent (const struct agent *agent) |
void | agents_disconnect (void) |
void | agents_processing_started (void) |
void | agents_processing_finished (void) |
void | agents_freeze_hint (void) |
void | agents_thaw_hint (void) |
void | agents_game_joined (void) |
void | agents_game_start (void) |
void | agents_before_new_turn (void) |
void | agents_start_turn (void) |
void | agents_new_turn (void) |
void | agents_unit_changed (struct unit *punit) |
void | agents_unit_new (struct unit *punit) |
void | agents_unit_remove (struct unit *punit) |
void | agents_city_changed (struct city *pcity) |
void | agents_city_new (struct city *pcity) |
void | agents_city_remove (struct city *pcity) |
void | agents_tile_remove (struct tile *ptile) |
void | agents_tile_changed (struct tile *ptile) |
void | agents_tile_new (struct tile *ptile) |
void | wait_for_requests (const char *agent_name, int first_request_id, int last_request_id) |
void | cause_a_unit_changed_for_agent (const char *name_of_calling_agent, struct unit *punit) |
void | cause_a_city_changed_for_agent (const char *name_of_calling_agent, struct city *pcity) |
bool | agents_busy (void) |
Variables | ||
struct { | ||
int entries_used | ||
struct my_agent { | ||
struct agent agent | ||
int first_outstanding_request_id | ||
int last_outstanding_request_id | ||
struct { | ||
struct timer * network_wall_timer | ||
int wait_at_network | ||
int wait_at_network_requests | ||
} stats | ||
} entries [MAX_AGENTS] | ||
struct call_list * calls | ||
} | agents | |
static bool | initialized = FALSE | |
static int | frozen_level | |
static bool | currently_running = FALSE | |
#define call_list_both_iterate | ( | calllist, | |
plink, | |||
pcall | |||
) |
#define call_list_both_iterate_end LIST_BOTH_ITERATE_END |
#define call_list_iterate | ( | calllist, | |
pcall | |||
) | TYPED_LIST_ITERATE(struct call, calllist, pcall) |
#define call_list_iterate_end LIST_ITERATE_END |
|
static |
Helper.
Definition at line 296 of file agents.c.
Referenced by cause_a_city_changed_for_agent(), cause_a_unit_changed_for_agent(), and wait_for_requests().
void agents_before_new_turn | ( | void | ) |
Called from client/packhand.c.
Definition at line 462 of file agents.c.
Referenced by handle_end_turn().
bool agents_busy | ( | void | ) |
Returns TRUE iff some agent is currently busy.
Definition at line 799 of file agents.c.
Referenced by can_end_turn(), and send_turn_done().
void agents_city_changed | ( | struct city * | pcity | ) |
Called from client/packhand.c. See agents_unit_changed() for a generic documentation.
Definition at line 584 of file agents.c.
Referenced by handle_city_info(), and handle_city_short_info().
void agents_city_new | ( | struct city * | pcity | ) |
Called from client/packhand.c. See agents_unit_changed() for a generic documentation.
Definition at line 610 of file agents.c.
Referenced by handle_city_info(), and handle_city_short_info().
void agents_city_remove | ( | struct city * | pcity | ) |
Called from client/packhand.c. See agents_unit_changed() for a generic documentation.
Definition at line 636 of file agents.c.
Referenced by handle_city_remove().
void agents_disconnect | ( | void | ) |
Called from client/packhand.c.
Definition at line 400 of file agents.c.
Referenced by set_client_state().
void agents_free | ( | void | ) |
Free resources allocated for agents framework
Definition at line 346 of file agents.c.
Referenced by client_game_free(), and client_game_reset().
void agents_freeze_hint | ( | void | ) |
Called from client/packhand.c.
Definition at line 427 of file agents.c.
Referenced by handle_freeze_client(), and input_from_server().
void agents_game_joined | ( | void | ) |
Called from client/packhand.c.
Definition at line 445 of file agents.c.
Referenced by handle_server_join_reply().
void agents_game_start | ( | void | ) |
Called from client/packhand.c.
Definition at line 453 of file agents.c.
Referenced by set_client_state().
void agents_init | ( | void | ) |
Called once per client startup.
Definition at line 332 of file agents.c.
Referenced by client_game_init(), and client_game_reset().
void agents_new_turn | ( | void | ) |
Called from client/packhand.c. See agents_unit_changed() for a generic documentation.
Definition at line 479 of file agents.c.
Referenced by handle_new_year().
void agents_processing_finished | ( | void | ) |
Called from client/packhand.c.
Definition at line 418 of file agents.c.
Referenced by handle_processing_finished().
void agents_processing_started | ( | void | ) |
Called from client/packhand.c.
Definition at line 409 of file agents.c.
Referenced by handle_processing_started().
void agents_start_turn | ( | void | ) |
Called from client/packhand.c.
Definition at line 470 of file agents.c.
Referenced by handle_start_phase().
void agents_thaw_hint | ( | void | ) |
Called from client/packhand.c.
Definition at line 436 of file agents.c.
Referenced by handle_thaw_client(), and input_from_server().
void agents_tile_changed | ( | struct tile * | ptile | ) |
Called from client/packhand.c. See agents_unit_changed() for a generic documentation.
Definition at line 687 of file agents.c.
Referenced by handle_tile_info().
void agents_tile_new | ( | struct tile * | ptile | ) |
Called from client/packhand.c. See agents_unit_changed() for a generic documentation.
Definition at line 711 of file agents.c.
Referenced by handle_tile_info().
void agents_tile_remove | ( | struct tile * | ptile | ) |
Called from client/packhand.c. See agents_unit_changed() for a generic documentation. Tiles got removed because of FOW.
Definition at line 663 of file agents.c.
Referenced by handle_tile_info().
void agents_unit_changed | ( | struct unit * | punit | ) |
Called from client/packhand.c. A call is created and added to the list of outstanding calls if an agent wants to be informed about this event and the change wasn't caused by the agent. We then try (this may not be successful in every case since we can be frozen or another call_handle_methods may be running higher up on the stack) to execute all outstanding calls.
Definition at line 507 of file agents.c.
Referenced by handle_unit_packet_common().
void agents_unit_new | ( | struct unit * | punit | ) |
Called from client/packhand.c. See agents_unit_changed() for a generic documentation.
Definition at line 532 of file agents.c.
Referenced by handle_unit_packet_common().
void agents_unit_remove | ( | struct unit * | punit | ) |
Called from client/packhand.c. See agents_unit_changed() for a generic documentation.
Definition at line 558 of file agents.c.
Referenced by handle_unit_remove().
|
static |
Execute all outstanding calls. This method will do nothing if the dispatching is frozen (frozen_level > 0). Also call_handle_methods will ensure that only one instance is running at any given time.
Definition at line 235 of file agents.c.
Referenced by agents_city_changed(), agents_city_new(), agents_city_remove(), agents_game_start(), agents_tile_changed(), agents_tile_new(), agents_tile_remove(), agents_unit_changed(), agents_unit_new(), agents_unit_remove(), cause_a_city_changed_for_agent(), cause_a_unit_changed_for_agent(), and thaw().
Return TRUE iff the two agent calls are equal.
Definition at line 93 of file agents.c.
Referenced by enqueue_call().
void cause_a_city_changed_for_agent | ( | const char * | name_of_calling_agent, |
struct city * | pcity | ||
) |
Adds a specific call for the given agent.
Definition at line 786 of file agents.c.
Referenced by cma_put_city_under_agent().
void cause_a_unit_changed_for_agent | ( | const char * | name_of_calling_agent, |
struct unit * | punit | ||
) |
|
static |
If the call described by the given arguments isn't contained in agents.calls list, add the call to this list. Maintains the list in a sorted order.
Definition at line 122 of file agents.c.
Referenced by agents_city_changed(), agents_city_new(), agents_city_remove(), agents_new_turn(), agents_tile_changed(), agents_tile_new(), agents_tile_remove(), agents_unit_changed(), agents_unit_new(), agents_unit_remove(), cause_a_city_changed_for_agent(), and cause_a_unit_changed_for_agent().
|
static |
Calls an callback of an agent as described in the given call.
Definition at line 211 of file agents.c.
Referenced by call_handle_methods().
|
static |
Increase the frozen_level by one.
Definition at line 269 of file agents.c.
Referenced by agents_freeze_hint(), and agents_processing_started().
|
static |
Returns TRUE iff currently handled packet was caused by the given agent.
Definition at line 312 of file agents.c.
Referenced by agents_city_changed(), agents_city_new(), agents_city_remove(), agents_new_turn(), agents_tile_changed(), agents_tile_new(), agents_tile_remove(), agents_unit_changed(), agents_unit_new(), and agents_unit_remove().
void register_agent | ( | const struct agent * | agent | ) |
Registers an agent.
Definition at line 378 of file agents.c.
Referenced by cma_init(), cmafec_init(), and simple_historian_init().
|
static |
Return an outstanding call. The call is removed from the agents.calls list. Returns NULL if there no more outstanding calls.
Definition at line 193 of file agents.c.
Referenced by agents_free(), and call_handle_methods().
|
static |
Decrease the frozen_level by one. If the dispatching is not frozen anymore (frozen_level == 0) all outstanding calls are executed.
Definition at line 283 of file agents.c.
Referenced by agents_processing_finished(), and agents_thaw_hint().
void wait_for_requests | ( | const char * | agent_name, |
int | first_request_id, | ||
int | last_request_id | ||
) |
Called from an agent. This function will return until the last request has been processed by the server.
Definition at line 735 of file agents.c.
Referenced by apply_result_on_server().
Definition at line 76 of file agents.c.
Referenced by enqueue_call().
struct { ... } agents |
Referenced by agent_by_name(), agents_busy(), agents_city_changed(), agents_city_new(), agents_city_remove(), agents_free(), agents_init(), agents_new_turn(), agents_tile_changed(), agents_tile_new(), agents_tile_remove(), agents_unit_changed(), agents_unit_new(), agents_unit_remove(), enqueue_call(), register_agent(), and remove_and_return_a_call().
Definition at line 88 of file agents.c.
Referenced by agents_busy(), and call_handle_methods().
struct { ... } ::my_agent entries[MAX_AGENTS] |
int entries_used |
Definition at line 74 of file agents.c.
Referenced by economy_report_dialog_popup(), economy_report_update(), real_economy_report_dialog_update(), eco_report::update_report(), and fc_client::update_sidebar_tooltips().
|
static |
Definition at line 87 of file agents.c.
Referenced by agents_busy(), call_handle_methods(), freeze(), and thaw().
Definition at line 86 of file agents.c.
Referenced by agents_busy(), agents_disconnect(), and freeze().
struct { ... } stats |
Referenced by script_server_load_file().