Freeciv-3.2
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
61
62/* For when we need to iterate over treaties */
63struct Clause;
64#define SPECLIST_TAG clause
65#define SPECLIST_TYPE struct Clause
66#include "speclist.h"
67
68#define clause_list_iterate(clauselist, pclause) \
69 TYPED_LIST_ITERATE(struct Clause, clauselist, pclause)
70#define clause_list_iterate_end LIST_ITERATE_END
71
72struct Clause {
74 struct player *from;
75 int value;
76};
77
78struct Treaty {
79 struct player *plr0, *plr1;
82};
83
84bool diplomacy_possible(const struct player *pplayer,
85 const struct player *aplayer);
86bool could_meet_with_player(const struct player *pplayer,
87 const struct player *aplayer);
88bool could_intel_with_player(const struct player *pplayer,
89 const struct player *aplayer);
90
91void init_treaty(struct Treaty *ptreaty,
92 struct player *plr0, struct player *plr1);
93bool add_clause(struct Treaty *ptreaty, struct player *pfrom,
94 enum clause_type type, int val,
95 struct player *client_player);
96bool remove_clause(struct Treaty *ptreaty, struct player *pfrom,
97 enum clause_type type, int val);
98void clear_treaty(struct Treaty *ptreaty);
99
100void clause_infos_init(void);
101void clause_infos_free(void);
103
105
106#define SPECLIST_TAG treaty
107#define SPECLIST_TYPE struct Treaty
108#include "speclist.h"
109
110#define treaty_list_iterate(list, p) \
111 TYPED_LIST_ITERATE(struct Treaty, list, p)
112#define treaty_list_iterate_end LIST_ITERATE_END
113
114void treaties_init(void);
115void treaties_free(void);
116void free_treaties(void);
117
118struct Treaty *find_treaty(struct player *plr0, struct player *plr1);
119
120void treaty_add(struct Treaty *ptreaty);
121void treaty_remove(struct Treaty *ptreaty);
122
123typedef void (*treaty_cb)(struct Treaty *, void *data);
124void treaties_iterate(treaty_cb cb, void *data);
125
126#ifdef __cplusplus
127}
128#endif /* __cplusplus */
129
130#endif /* FC__DIPTREATY_H */
#define client_player()
char * incite_cost
Definition comments.c:75
struct Treaty * ptreaty
Definition diplodlg_g.h:28
void(* treaty_cb)(struct Treaty *, void *data)
Definition diptreaty.h:123
void clause_infos_init(void)
Definition diptreaty.c:248
void clause_infos_free(void)
Definition diptreaty.c:263
void free_treaties(void)
Definition diptreaty.c:332
void treaties_init(void)
Definition diptreaty.c:313
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:380
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:289
void treaty_add(struct Treaty *ptreaty)
Definition diptreaty.c:361
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:369
bool could_intel_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:84
void treaties_free(void)
Definition diptreaty.c:321
struct Treaty * find_treaty(struct player *plr0, struct player *plr1)
Definition diptreaty.c:346
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:276
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:73
struct player * from
Definition diptreaty.h:74
int value
Definition diptreaty.h:75
struct player * plr0
Definition diptreaty.h:79
bool accept0
Definition diptreaty.h:80
bool accept1
Definition diptreaty.h:80
struct clause_list * clauses
Definition diptreaty.h:81
struct player * plr1
Definition diptreaty.h:79
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
bool enabled
Definition diptreaty.h:57