40#define log_request_ids(...)
41#define log_todo_lists(...)
42#define log_meta_callback(...) log_debug(__VA_ARGS__)
43#define log_debug_freeze(...)
56#define SPECLIST_TAG call
57#define SPECLIST_TYPE struct call
60#define call_list_iterate(calllist, pcall) \
61 TYPED_LIST_ITERATE(struct call, calllist, pcall)
62#define call_list_iterate_end LIST_ITERATE_END
64#define call_list_both_iterate(calllist, plink, pcall) \
65 TYPED_LIST_BOTH_ITERATE(struct call_list_link, struct call, \
66 calllist, plink, pcall)
67#define call_list_both_iterate_end LIST_BOTH_ITERATE_END
94 const struct call *pcall2)
104 switch (pcall1->
type) {
108 return (pcall1->
arg == pcall2->
arg);
124 struct my_agent *
agent, ...)
129 const struct tile *ptile;
141 arg = va_arg(ap,
int);
144 ptile = va_arg(ap,
const struct tile *);
168 if (pcall->agent->agent.level - pcall2->
agent->agent.level > 0) {
173 call_list_insert_before(
agents.calls, pcall2, plink);
180 call_list_append(
agents.calls, pcall2);
197 if (call_list_size(
agents.calls) == 0) {
201 result = call_list_front(
agents.calls);
202 call_list_pop_front(
agents.calls);
300 for (i = 0; i <
agents.entries_used; i++) {
301 if (strcmp(agent_name,
agents.entries[i].agent.name) == 0)
302 return &
agents.entries[i];
314 if (
agent->first_outstanding_request_id != 0
316 &&
agent->first_outstanding_request_id <=
318 &&
agent->last_outstanding_request_id >=
320 log_debug(
"A:%s: ignoring packet; outstanding [%d..%d] got=%d",
322 agent->last_outstanding_request_id,
335 agents.calls = call_list_new();
367 for (i = 0; i <
agents.entries_used; i++) {
372 call_list_destroy(
agents.calls);
380 struct my_agent *priv_agent = &
agents.entries[
agents.entries_used];
385 memcpy(&priv_agent->agent,
agent,
sizeof(
struct agent));
387 priv_agent->first_outstanding_request_id = 0;
388 priv_agent->last_outstanding_request_id = 0;
391 priv_agent->stats.wait_at_network = 0;
392 priv_agent->stats.wait_at_network_requests = 0;
483 for (i = 0; i <
agents.entries_used; i++) {
511 log_debug(
"A: agents_unit_changed(unit=%d) type=%s pos=(%d,%d) owner=%s",
515 for (i = 0; i <
agents.entries_used; i++) {
536 log_debug(
"A: agents_new_unit(unit=%d) type=%s pos=(%d,%d) owner=%s",
540 for (i = 0; i <
agents.entries_used; i++) {
562 log_debug(
"A: agents_remove_unit(unit=%d) type=%s pos=(%d,%d) owner=%s",
566 for (i = 0; i <
agents.entries_used; i++) {
588 log_debug(
"A: agents_city_changed(city %d=\"%s\") owner=%s",
592 for (i = 0; i <
agents.entries_used; i++) {
614 log_debug(
"A: agents_city_new(city %d=\"%s\") pos=(%d,%d) owner=%s",
618 for (i = 0; i <
agents.entries_used; i++) {
640 log_debug(
"A: agents_city_remove(city %d=\"%s\") pos=(%d,%d) owner=%s",
644 for (i = 0; i <
agents.entries_used; i++) {
669 for (i = 0; i <
agents.entries_used; i++) {
693 for (i = 0; i <
agents.entries_used; i++) {
717 for (i = 0; i <
agents.entries_used; i++) {
741 agent->agent.
name, first_request_id, last_request_id);
744 && first_request_id <= last_request_id);
746 agent->first_outstanding_request_id = first_request_id;
747 agent->last_outstanding_request_id = last_request_id;
753 agent->stats.wait_at_network++;
754 agent->stats.wait_at_network_requests +=
755 (1 + (last_request_id - first_request_id));
758 agent->agent.
name, first_request_id, last_request_id);
760 agent->first_outstanding_request_id = 0;
762 log_debug(
"A:%s: waited %fs in total for network; "
763 "requests=%d; waited %d times",
766 agent->stats.wait_at_network_requests,
767 agent->stats.wait_at_network);
812 for (i = 0; i <
agents.entries_used; i++) {
815 if (
agent->first_outstanding_request_id != 0) {
#define log_todo_lists(...)
static struct my_agent * agent_by_name(const char *agent_name)
static void enqueue_call(enum oct type, enum callback_type cb_type, struct my_agent *agent,...)
static bool calls_are_equal(const struct call *pcall1, const struct call *pcall2)
void agents_unit_changed(struct unit *punit)
void agents_city_remove(struct city *pcity)
void agents_thaw_hint(void)
void agents_disconnect(void)
void agents_game_start(void)
void wait_for_requests(const char *agent_name, int first_request_id, int last_request_id)
void agents_tile_remove(struct tile *ptile)
void agents_city_new(struct city *pcity)
struct timer * network_wall_timer
struct @124::my_agent entries[MAX_AGENTS]
int wait_at_network_requests
#define call_list_both_iterate_end
int first_outstanding_request_id
void agents_start_turn(void)
void agents_tile_changed(struct tile *ptile)
static void call_handle_methods(void)
void agents_unit_new(struct unit *punit)
static struct call * remove_and_return_a_call(void)
void agents_unit_remove(struct unit *punit)
static bool currently_running
static bool is_outstanding_request(struct my_agent *agent)
void agents_processing_started(void)
static struct @124 agents
void agents_tile_new(struct tile *ptile)
void agents_processing_finished(void)
void agents_new_turn(void)
#define log_request_ids(...)
void agents_city_changed(struct city *pcity)
int last_outstanding_request_id
void cause_a_city_changed_for_agent(const char *name_of_calling_agent, struct city *pcity)
void agents_game_joined(void)
struct @124::my_agent::@125 stats
void register_agent(const struct agent *agent)
void cause_a_unit_changed_for_agent(const char *name_of_calling_agent, struct unit *punit)
static void execute_call(const struct call *call)
#define call_list_both_iterate(calllist, plink, pcall)
#define log_debug_freeze(...)
#define log_meta_callback(...)
void agents_freeze_hint(void)
void agents_before_new_turn(void)
const char * city_name_get(const struct city *pcity)
bool client_is_observer(void)
enum client_states client_state(void)
void wait_till_request_got_processed(int request_id)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define log_debug(message,...)
#define log_error(message,...)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
void update_turn_done_button_state(void)
const char * nation_rule_name(const struct nation_type *pnation)
struct nation_type * nation_of_city(const struct city *pcity)
const char * player_name(const struct player *pplayer)
void(* unit_callbacks[CB_LAST])(int)
void(* tile_callbacks[CB_LAST])(struct tile *ptile)
char name[MAX_AGENT_NAME_LEN]
void(* city_callbacks[CB_LAST])(int)
void(* turn_start_notify)(void)
enum callback_type cb_type
struct connection::@57::@62 client
int request_id_of_currently_handled_packet
struct timer * timer_new(enum timer_timetype type, enum timer_use use)
void timer_destroy(struct timer *t)
void timer_start(struct timer *t)
void timer_stop(struct timer *t)
double timer_read_seconds(struct timer *t)
const char * unit_rule_name(const struct unit *punit)