Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/diptreaty.h Source File

Freeciv-3.1

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_COUNT CLAUSE_COUNT
47#include "specenum_gen.h"
48
49#define is_pact_clause(x) \
50 ((x == CLAUSE_CEASEFIRE) || (x == CLAUSE_PEACE) || (x == CLAUSE_ALLIANCE))
51
52 struct clause_info
53{
54 enum clause_type type;
55 bool enabled;
56 struct requirement_vector giver_reqs;
57 struct requirement_vector receiver_reqs;
58};
59
60/* For when we need to iterate over treaties */
61struct Clause;
62#define SPECLIST_TAG clause
63#define SPECLIST_TYPE struct Clause
64#include "speclist.h"
65
66#define clause_list_iterate(clauselist, pclause) \
67 TYPED_LIST_ITERATE(struct Clause, clauselist, pclause)
68#define clause_list_iterate_end LIST_ITERATE_END
69
70 struct Clause {
71 enum clause_type type;
72 struct player *from;
73 int value;
74};
75
76 struct Treaty {
77 struct player *plr0, *plr1;
78 bool accept0, accept1;
79 struct clause_list *clauses;
80};
81
82bool diplomacy_possible(const struct player *pplayer,
83 const struct player *aplayer);
84bool could_meet_with_player(const struct player *pplayer,
85 const struct player *aplayer);
86bool could_intel_with_player(const struct player *pplayer,
87 const struct player *aplayer);
88
89void init_treaty(struct Treaty *ptreaty,
90 struct player *plr0, struct player *plr1);
91bool add_clause(struct Treaty *ptreaty, struct player *pfrom,
92 enum clause_type type, int val,
93 struct player *client_player);
94bool remove_clause(struct Treaty *ptreaty, struct player *pfrom,
95 enum clause_type type, int val);
96void clear_treaty(struct Treaty *ptreaty);
97
98void clause_infos_init(void);
99void clause_infos_free(void);
100struct clause_info *clause_info_get(enum clause_type type);
101
102bool clause_enabled(enum clause_type type);
103
104#ifdef __cplusplus
105}
106#endif /* __cplusplus */
107
108#endif /* FC__DIPTREATY_H */
client_player
#define client_player()
Definition client_main.h:106
clause_infos_init
void clause_infos_init(void)
Definition diptreaty.c:245
clause_infos_free
void clause_infos_free(void)
Definition diptreaty.c:260
clear_treaty
void clear_treaty(struct Treaty *ptreaty)
Definition diptreaty.c:109
init_treaty
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diptreaty.c:96
add_clause
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
Definition diptreaty.c:142
clause_enabled
bool clause_enabled(enum clause_type type)
Definition diptreaty.c:286
remove_clause
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Definition diptreaty.c:120
could_intel_with_player
bool could_intel_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:81
clause_info_get
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:273
diplomacy_possible
bool diplomacy_possible(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:33
could_meet_with_player
bool could_meet_with_player(const struct player *pplayer, const struct player *aplayer)
Definition diptreaty.c:61
type
GType type
Definition repodlgs.c:1312
requirements.h
specenum_gen.h
speclist.h
Clause
Definition diptreaty.h:70
Clause::type
enum clause_type type
Definition diptreaty.h:71
Clause::from
struct player * from
Definition diptreaty.h:72
Clause::value
int value
Definition diptreaty.h:73
Treaty
Definition diptreaty.h:76
Treaty::plr0
struct player * plr0
Definition diptreaty.h:77
Treaty::accept0
bool accept0
Definition diptreaty.h:78
Treaty::accept1
bool accept1
Definition diptreaty.h:78
Treaty::clauses
struct clause_list * clauses
Definition diptreaty.h:79
Treaty::plr1
struct player * plr1
Definition diptreaty.h:77
clause_info
Definition diptreaty.h:53
clause_info::receiver_reqs
struct requirement_vector receiver_reqs
Definition diptreaty.h:57
clause_info::giver_reqs
struct requirement_vector giver_reqs
Definition diptreaty.h:56
clause_info::type
enum clause_type type
Definition diptreaty.h:54
clause_info::enabled
bool enabled
Definition diptreaty.h:55
player
Definition player.h:249
support.h