Freeciv-3.3: /fast/freeciv/nightly/main/common/diptreaty.h Source File

Freeciv-3.3

Loading...
Searching...
No Matches
diptreaty.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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#ifndef FC__DIPTREATY_H
14#define FC__DIPTREATY_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "requirements.h"
22#include "support.h" /* bool type */
23
24/* Used in the network protocol */
25#define SPECENUM_NAME clause_type
26#define SPECENUM_VALUE0 CLAUSE_ADVANCE
27#define SPECENUM_VALUE0NAME "Advance"
28#define SPECENUM_VALUE1 CLAUSE_GOLD
29#define SPECENUM_VALUE1NAME "Gold"
30#define SPECENUM_VALUE2 CLAUSE_MAP
31#define SPECENUM_VALUE2NAME "Map"
32#define SPECENUM_VALUE3 CLAUSE_SEAMAP
33#define SPECENUM_VALUE3NAME "Seamap"
34#define SPECENUM_VALUE4 CLAUSE_CITY
35#define SPECENUM_VALUE4NAME "City"
36#define SPECENUM_VALUE5 CLAUSE_CEASEFIRE
37#define SPECENUM_VALUE5NAME "Ceasefire"
38#define SPECENUM_VALUE6 CLAUSE_PEACE
39#define SPECENUM_VALUE6NAME "Peace"
40#define SPECENUM_VALUE7 CLAUSE_ALLIANCE
41#define SPECENUM_VALUE7NAME "Alliance"
42#define SPECENUM_VALUE8 CLAUSE_VISION
43#define SPECENUM_VALUE8NAME "Vision"
44#define SPECENUM_VALUE9 CLAUSE_EMBASSY
45#define SPECENUM_VALUE9NAME "Embassy"
46#define SPECENUM_VALUE10 CLAUSE_SHARED_TILES
47#define SPECENUM_VALUE10NAME "SharedTiles"
48#define SPECENUM_COUNT CLAUSE_COUNT
49#include "specenum_gen.h"
50
51#define is_pact_clause(x) \
52 ((x == CLAUSE_CEASEFIRE) || (x == CLAUSE_PEACE) || (x == CLAUSE_ALLIANCE))
53
54 struct clause_info
55{
56 enum clause_type type;
57 bool enabled;
58 struct requirement_vector giver_reqs;
59 struct requirement_vector receiver_reqs;
60 struct requirement_vector either_reqs;
61};
62
63/* For when we need to iterate over treaties */
64struct Clause;
65#define SPECLIST_TAG clause
66#define SPECLIST_TYPE struct Clause
67#include "speclist.h"
68
69#define clause_list_iterate(clauselist, pclause) \
70 TYPED_LIST_ITERATE(struct Clause, clauselist, pclause)
71#define clause_list_iterate_end LIST_ITERATE_END
72
73 struct Clause {
74 enum clause_type type;
75 struct player *from;
76 int value;
77};
78
79 struct Treaty {
80 struct player *plr0, *plr1;
81 bool accept0, accept1;
82 struct clause_list *clauses;
83};
84
85bool diplomacy_possible(const struct player *pplayer,
86 const struct player *aplayer);
87bool could_meet_with_player(const struct player *pplayer,
88 const struct player *aplayer);
89bool could_intel_with_player(const struct player *pplayer,
90 const struct player *aplayer);
91
92void init_treaty(struct Treaty *ptreaty,
93 struct player *plr0, struct player *plr1);
94bool add_clause(struct Treaty *ptreaty, struct player *pfrom,
95 enum clause_type type, int val,
96 struct player *client_player);
97bool remove_clause(struct Treaty *ptreaty, struct player *pfrom,
98 enum clause_type type, int val);
99void clear_treaty(struct Treaty *ptreaty);
100
101void clause_infos_init(void);
102void clause_infos_free(void);
103struct clause_info *clause_info_get(enum clause_type type);
104
105bool clause_enabled(enum clause_type type);
106
107#define SPECLIST_TAG treaty
108#define SPECLIST_TYPE struct Treaty
109#include "speclist.h"
110
111#define treaty_list_iterate(list, p) \
112 TYPED_LIST_ITERATE(struct Treaty, list, p)
113#define treaty_list_iterate_end LIST_ITERATE_END
114
115void treaties_init(void);
116void treaties_free(void);
117void free_treaties(void);
118
119struct Treaty *find_treaty(struct player *plr0, struct player *plr1);
120
121void treaty_add(struct Treaty *ptreaty);
122void treaty_remove(struct Treaty *ptreaty);
123
124 typedef void (*treaty_cb)(struct Treaty *, void *data);
125void treaties_iterate(treaty_cb cb, void *data);
126
127#ifdef __cplusplus
128}
129#endif /* __cplusplus */
130
131#endif /* FC__DIPTREATY_H */
client_player
#define client_player()
Definition client_main.h:106
incite_cost
char * incite_cost
Definition comments.c:74
ptreaty
struct Treaty * ptreaty
Definition diplodlg_g.h:28
treaty_cb
void(* treaty_cb)(struct Treaty *, void *data)
Definition diptreaty.h:124
clause_infos_init
void clause_infos_init(void)
Definition diptreaty.c:262
clause_infos_free
void clause_infos_free(void)
Definition diptreaty.c:278
free_treaties
void free_treaties(void)
Definition diptreaty.c:348
treaties_init
void treaties_init(void)
Definition diptreaty.c:329
clear_treaty
void clear_treaty(struct Treaty *ptreaty)
Definition diptreaty.c:112
init_treaty
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diptreaty.c:99
treaties_iterate
void treaties_iterate(treaty_cb cb, void *data)
Definition diptreaty.c:396
add_clause
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
Definition diptreaty.c:145
clause_enabled
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:305
treaty_add
void treaty_add(struct Treaty *ptreaty)
Definition diptreaty.c:377
remove_clause
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Definition diptreaty.c:123
treaty_remove
void treaty_remove(struct Treaty *ptreaty)
Definition diptreaty.c:385
could_intel_with_player
bool could_intel_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:84
treaties_free
void treaties_free(void)
Definition diptreaty.c:337
find_treaty
struct Treaty * find_treaty(struct player *plr0, struct player *plr1)
Definition diptreaty.c:362
clause_info_get
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:292
diplomacy_possible
bool diplomacy_possible(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:36
could_meet_with_player
bool could_meet_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:64
type
GType type
Definition repodlgs.c:1313
requirements.h
specenum_gen.h
speclist.h
Clause
Definition diptreaty.h:73
Clause::type
enum clause_type type
Definition diptreaty.h:74
Clause::from
struct player * from
Definition diptreaty.h:75
Clause::value
int value
Definition diptreaty.h:76
Treaty
Definition diptreaty.h:79
Treaty::plr0
struct player * plr0
Definition diptreaty.h:80
Treaty::accept0
bool accept0
Definition diptreaty.h:81
Treaty::accept1
bool accept1
Definition diptreaty.h:81
Treaty::clauses
struct clause_list * clauses
Definition diptreaty.h:82
Treaty::plr1
struct player * plr1
Definition diptreaty.h:80
clause_info
Definition diptreaty.h:55
clause_info::receiver_reqs
struct requirement_vector receiver_reqs
Definition diptreaty.h:59
clause_info::giver_reqs
struct requirement_vector giver_reqs
Definition diptreaty.h:58
clause_info::type
enum clause_type type
Definition diptreaty.h:56
clause_info::either_reqs
struct requirement_vector either_reqs
Definition diptreaty.h:60
clause_info::enabled
bool enabled
Definition diptreaty.h:57
player
Definition player.h:249
support.h