29 const struct player *pplayer2)
48 qCritical(
"%s(): Unsupported diplomacy variant %d.", __FUNCTION__,
57 const struct player *aplayer)
75 const struct player *aplayer)
94 ptreaty->
clauses = clause_list_new();
104 clause_list_destroy(ptreaty->
clauses);
111 enum clause_type
type,
int val)
115 if (pclause->type ==
type && pclause->from == pfrom
116 && pclause->value == val) {
117 clause_list_remove(ptreaty->
clauses, pclause);
135 enum clause_type
type,
int val)
138 (pfrom == ptreaty->
plr0 ? ptreaty->
plr1 : ptreaty->
plr0);
140 enum diplstate_type ds =
143 if (!clause_type_is_valid(
type)) {
144 qCritical(
"Illegal clause type encountered.");
149 qCritical(
"Illegal tech value %i in clause.", val);
154 && ((ds == DS_PEACE &&
type == CLAUSE_PEACE)
155 || (ds == DS_ARMISTICE &&
type == CLAUSE_PEACE)
156 || (ds == DS_ALLIANCE &&
type == CLAUSE_ALLIANCE)
157 || (ds == DS_CEASEFIRE &&
type == CLAUSE_CEASEFIRE))) {
159 qCritical(
"Illegal treaty suggested between %s and %s - they "
160 "already have this treaty level.",
168 qCritical(
"Illegal embassy clause: %s already have embassy with %s.",
179 nullptr,
nullptr,
nullptr,
nullptr,
182 nullptr,
nullptr,
nullptr,
nullptr,
189 if (old_clause->type ==
type && old_clause->from == pfrom
190 && old_clause->value == val) {
198 old_clause->type =
type;
201 if (
type == CLAUSE_GOLD && old_clause->type == CLAUSE_GOLD
202 && old_clause->from == pfrom) {
206 old_clause->value = val;
215 pclause->
from = pfrom;
216 pclause->
value = val;
218 clause_list_append(ptreaty->
clauses, pclause);
233 for (i = 0; i < CLAUSE_COUNT; i++) {
237 requirement_vector_init(&(
clause_infos[i].receiver_reqs));
248 for (i = 0; i < CLAUSE_COUNT; i++) {
250 requirement_vector_free(&(
clause_infos[i].receiver_reqs));
286 if (!
game.
info.trading_tech &&
type == CLAUSE_ADVANCE) {
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Add clause to treaty.
bool diplomacy_possible(const struct player *pplayer1, const struct player *pplayer2)
Returns TRUE iff pplayer could do diplomancy in the game at all.
struct clause_info * clause_info_get(enum clause_type type)
Free memory associated with clause infos.
bool clause_enabled(enum clause_type type, struct player *from, struct player *to)
Is clause enabled in this game? Currently this does not consider clause requirements that may change ...
void clear_treaty(struct Treaty *ptreaty)
Free the clauses of a treaty.
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Initialize treaty structure between two players.
static struct clause_info clause_infos[CLAUSE_COUNT]
void clause_infos_free()
Free memory associated with clause infos.
void clause_infos_init()
Initialize clause info structures.
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Remove clause from treaty.
bool could_intel_with_player(const struct player *pplayer, const struct player *aplayer)
Returns TRUE iff pplayer can get intelligence about aplayer.
bool could_meet_with_player(const struct player *pplayer, const struct player *aplayer)
Returns TRUE iff pplayer could do diplomatic meetings with aplayer.
#define clause_list_iterate_end
#define clause_list_iterate(clauselist, pclause)
#define is_pact_clause(x)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
#define fc_assert(condition)
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
Return TRUE if players are in the same team.
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
Returns whether pplayer has a real embassy with pplayer2, established from a diplomat,...
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
Check if pplayer has an embassy with pplayer2.
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
bool are_reqs_active(const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement_vector *reqs, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement(s) to see if they are active on the given target.
struct clause_list * clauses
struct packet_game_info info
struct advance * valid_advance_by_number(const Tech_type_id id)
Returns pointer when the advance "exists" in this game, returns nullptr otherwise.