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 CLAUSE_LAST CLAUSE_COUNT
52
53#define is_pact_clause(x) \
54 ((x == CLAUSE_CEASEFIRE) || (x == CLAUSE_PEACE) || (x == CLAUSE_ALLIANCE))
55
64
65/* For when we need to iterate over treaties */
66struct Clause;
67#define SPECLIST_TAG clause
68#define SPECLIST_TYPE struct Clause
69#include "speclist.h"
70
71#define clause_list_iterate(clauselist, pclause) \
72 TYPED_LIST_ITERATE(struct Clause, clauselist, pclause)
73#define clause_list_iterate_end LIST_ITERATE_END
74
75struct Clause {
77 struct player *from;
78 int value;
79};
80
81struct treaty {
82 struct player *plr0, *plr1;
85};
86
87bool diplomacy_possible(const struct player *pplayer,
88 const struct player *aplayer);
89bool could_meet_with_player(const struct player *pplayer,
90 const struct player *aplayer);
91bool could_intel_with_player(const struct player *pplayer,
92 const struct player *aplayer);
93
94void init_treaty(struct treaty *ptreaty,
95 struct player *plr0, struct player *plr1);
96bool add_clause(struct treaty *ptreaty, struct player *pfrom,
97 enum clause_type type, int val,
98 struct player *client_player);
99bool remove_clause(struct treaty *ptreaty, struct player *pfrom,
100 enum clause_type type, int val);
101void clear_treaty(struct treaty *ptreaty);
102
103void clause_infos_init(void);
104void clause_infos_free(void);
106
108
109#define SPECLIST_TAG treaty
110#define SPECLIST_TYPE struct treaty
111#include "speclist.h"
112
113#define treaty_list_iterate(list, p) \
114 TYPED_LIST_ITERATE(struct treaty, list, p)
115#define treaty_list_iterate_end LIST_ITERATE_END
116
117void treaties_init(void);
118void treaties_free(void);
119void free_treaties(void);
120
121struct treaty *find_treaty(struct player *plr0, struct player *plr1);
122
123void treaty_add(struct treaty *ptreaty);
124void treaty_remove(struct treaty *ptreaty);
125
126typedef void (*treaty_cb)(struct treaty *, void *data);
127void treaties_iterate(treaty_cb cb, void *data);
128
129#ifdef __cplusplus
130}
131#endif /* __cplusplus */
132
133#endif /* FC__DIPTREATY_H */
#define client_player()
char * incite_cost
Definition comments.c:76
struct treaty * ptreaty
Definition diplodlg_g.h:28
void treaty_remove(struct treaty *ptreaty)
Definition diptreaty.c:385
void treaty_add(struct treaty *ptreaty)
Definition diptreaty.c:377
void clause_infos_init(void)
Definition diptreaty.c:262
struct treaty * find_treaty(struct player *plr0, struct player *plr1)
Definition diptreaty.c:362
void clause_infos_free(void)
Definition diptreaty.c:278
void free_treaties(void)
Definition diptreaty.c:348
void init_treaty(struct treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diptreaty.c:99
void treaties_init(void)
Definition diptreaty.c:329
bool add_clause(struct treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
Definition diptreaty.c:145
void treaties_iterate(treaty_cb cb, void *data)
Definition diptreaty.c:396
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:305
void clear_treaty(struct treaty *ptreaty)
Definition diptreaty.c:112
bool remove_clause(struct treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Definition diptreaty.c:123
bool could_intel_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:84
void treaties_free(void)
Definition diptreaty.c:337
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:292
bool diplomacy_possible(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:36
void(* treaty_cb)(struct treaty *, void *data)
Definition diptreaty.h:126
bool could_meet_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:64
GType type
Definition repodlgs.c:1313
enum clause_type type
Definition diptreaty.h:76
struct player * from
Definition diptreaty.h:77
int value
Definition diptreaty.h:78
struct requirement_vector receiver_reqs
Definition diptreaty.h:61
struct requirement_vector giver_reqs
Definition diptreaty.h:60
enum clause_type type
Definition diptreaty.h:58
struct requirement_vector either_reqs
Definition diptreaty.h:62
bool enabled
Definition diptreaty.h:59
struct player * plr1
Definition diptreaty.h:82
struct clause_list * clauses
Definition diptreaty.h:84
bool accept1
Definition diptreaty.h:83
struct player * plr0
Definition diptreaty.h:82
bool accept0
Definition diptreaty.h:83