Freeciv-3.3: /fast/freeciv/nightly/main/client/agents/agents.h Source File

Freeciv-3.3

Loading...
Searching...
No Matches
agents.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2001 - R. Falke
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifndef FC__AGENTS_H
15#define FC__AGENTS_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21#include "support.h" /* bool type */
22
23#include "fc_types.h"
24
25/*
26 * Besides callback for convenience client/agents/agents also
27 * implements a "flattening" of the call stack i.e. to ensure that
28 * every agent is only called once at any time.
29 */
30
31/* Don't use the very last level unless you know what you're doing */
32#define LAST_AGENT_LEVEL 99
33
34#define MAX_AGENT_NAME_LEN 10
35
36 enum callback_type {
37 CB_NEW, CB_REMOVE, CB_CHANGE, CB_LAST
38};
39
40 struct agent {
41 char name[MAX_AGENT_NAME_LEN];
42 int level;
43
44 void (*turn_start_notify) (void);
45 void (*city_callbacks[CB_LAST]) (int);
46 void (*unit_callbacks[CB_LAST]) (int);
47 void (*tile_callbacks[CB_LAST]) (struct tile *ptile);
48};
49
50void agents_init(void);
51void agents_free(void);
52void register_agent(const struct agent *agent);
53bool agents_busy(void);
54
55/* Called from client/packhand.c */
56void agents_disconnect(void);
57void agents_processing_started(void);
58void agents_processing_finished(void);
59void agents_freeze_hint(void);
60void agents_thaw_hint(void);
61void agents_game_joined(void);
62void agents_game_start(void);
63void agents_before_new_turn(void);
64void agents_start_turn(void);
65void agents_new_turn(void);
66
67void agents_unit_changed(struct unit *punit);
68void agents_unit_new(struct unit *punit);
69void agents_unit_remove(struct unit *punit);
70
71void agents_city_changed(struct city *pcity);
72void agents_city_new(struct city *pcity);
73void agents_city_remove(struct city *pcity);
74
75void agents_tile_changed(struct tile *ptile);
76void agents_tile_new(struct tile *ptile);
77void agents_tile_remove(struct tile *ptile);
78
79/* Called from agents */
80void cause_a_city_changed_for_agent(const char *name_of_calling_agent,
81 struct city *pcity);
82void cause_a_unit_changed_for_agent(const char *name_of_calling_agent,
83 struct unit *punit);
84void wait_for_requests(const char *agent_name, int first_request_id,
85 int last_request_id);
86
87#ifdef __cplusplus
88}
89#endif /* __cplusplus */
90
91#endif /* FC__AGENTS_H */
agents_unit_changed
void agents_unit_changed(struct unit *punit)
Definition agents.c:512
callback_type
callback_type
Definition agents.h:36
CB_LAST
@ CB_LAST
Definition agents.h:37
CB_NEW
@ CB_NEW
Definition agents.h:37
CB_REMOVE
@ CB_REMOVE
Definition agents.h:37
CB_CHANGE
@ CB_CHANGE
Definition agents.h:37
agents_city_remove
void agents_city_remove(struct city *pcity)
Definition agents.c:641
agents_free
void agents_free(void)
Definition agents.c:349
agents_thaw_hint
void agents_thaw_hint(void)
Definition agents.c:441
agents_disconnect
void agents_disconnect(void)
Definition agents.c:405
agents_game_start
void agents_game_start(void)
Definition agents.c:458
wait_for_requests
void wait_for_requests(const char *agent_name, int first_request_id, int last_request_id)
Definition agents.c:740
agents_tile_remove
void agents_tile_remove(struct tile *ptile)
Definition agents.c:668
agents_city_new
void agents_city_new(struct city *pcity)
Definition agents.c:615
MAX_AGENT_NAME_LEN
#define MAX_AGENT_NAME_LEN
Definition agents.h:34
agents_start_turn
void agents_start_turn(void)
Definition agents.c:475
agents_tile_changed
void agents_tile_changed(struct tile *ptile)
Definition agents.c:692
agents_unit_new
void agents_unit_new(struct unit *punit)
Definition agents.c:537
agents_busy
bool agents_busy(void)
Definition agents.c:804
agents_unit_remove
void agents_unit_remove(struct unit *punit)
Definition agents.c:563
agents_processing_started
void agents_processing_started(void)
Definition agents.c:414
agents_tile_new
void agents_tile_new(struct tile *ptile)
Definition agents.c:716
agents_processing_finished
void agents_processing_finished(void)
Definition agents.c:423
agents_new_turn
void agents_new_turn(void)
Definition agents.c:484
agents_city_changed
void agents_city_changed(struct city *pcity)
Definition agents.c:589
cause_a_city_changed_for_agent
void cause_a_city_changed_for_agent(const char *name_of_calling_agent, struct city *pcity)
Definition agents.c:791
agents_game_joined
void agents_game_joined(void)
Definition agents.c:450
register_agent
void register_agent(const struct agent *agent)
Definition agents.c:382
agents_init
void agents_init(void)
Definition agents.c:335
cause_a_unit_changed_for_agent
void cause_a_unit_changed_for_agent(const char *name_of_calling_agent, struct unit *punit)
Definition agents.c:778
agents_freeze_hint
void agents_freeze_hint(void)
Definition agents.c:432
agents_before_new_turn
void agents_before_new_turn(void)
Definition agents.c:467
incite_cost
char * incite_cost
Definition comments.c:74
punit
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
Definition dialogs_g.h:74
fc_types.h
agent
Definition agents.h:40
agent::level
int level
Definition agents.h:42
agent::unit_callbacks
void(* unit_callbacks[CB_LAST])(int)
Definition agents.h:46
agent::tile_callbacks
void(* tile_callbacks[CB_LAST])(struct tile *ptile)
Definition agents.h:47
agent::name
char name[MAX_AGENT_NAME_LEN]
Definition agents.h:41
agent::city_callbacks
void(* city_callbacks[CB_LAST])(int)
Definition agents.h:45
agent::turn_start_notify
void(* turn_start_notify)(void)
Definition agents.h:44
city
Definition city.h:320
tile
Definition tile.h:50
unit
Definition unit.h:140
support.h