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
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
73struct Clause {
75 struct player *from;
76 int value;
77};
78
79struct Treaty {
80 struct player *plr0, *plr1;
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);
104
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
124typedef 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 */
#define client_player()
char * incite_cost
Definition comments.c:74
struct Treaty * ptreaty
Definition diplodlg_g.h:28
void(* treaty_cb)(struct Treaty *, void *data)
Definition diptreaty.h:124
void clause_infos_init(void)
Definition diptreaty.c:262
void clause_infos_free(void)
Definition diptreaty.c:278
void free_treaties(void)
Definition diptreaty.c:348
void treaties_init(void)
Definition diptreaty.c:329
void clear_treaty(struct Treaty *ptreaty)
Definition diptreaty.c:112
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diptreaty.c:99
void treaties_iterate(treaty_cb cb, void *data)
Definition diptreaty.c:396
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
Definition diptreaty.c:145
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:305
void treaty_add(struct Treaty *ptreaty)
Definition diptreaty.c:377
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Definition diptreaty.c:123
void treaty_remove(struct Treaty *ptreaty)
Definition diptreaty.c:385
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 Treaty * find_treaty(struct player *plr0, struct player *plr1)
Definition diptreaty.c:362
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
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:74
struct player * from
Definition diptreaty.h:75
int value
Definition diptreaty.h:76
struct player * plr0
Definition diptreaty.h:80
bool accept0
Definition diptreaty.h:81
bool accept1
Definition diptreaty.h:81
struct clause_list * clauses
Definition diptreaty.h:82
struct player * plr1
Definition diptreaty.h:80
struct requirement_vector receiver_reqs
Definition diptreaty.h:59
struct requirement_vector giver_reqs
Definition diptreaty.h:58
enum clause_type type
Definition diptreaty.h:56
struct requirement_vector either_reqs
Definition diptreaty.h:60
bool enabled
Definition diptreaty.h:57