Project

General

Profile

Bug #123 » 0029-Let-server-decide-if-the-other-party-meets-clause-re.patch

main, S3_2 - Marko Lindqvist, 01/04/2024 03:53 AM

View differences:

client/clitreaty.c
gui_prepare_clause_updt(ptreaty, they);
add_clause(ptreaty, player_by_number(giver), type, value);
add_clause(ptreaty, player_by_number(giver), type, value,
client_player());
gui_recv_create_clause(ptreaty, they);
}
common/diptreaty.c
Add clause to treaty.
**************************************************************************/
bool add_clause(struct Treaty *ptreaty, struct player *pfrom,
enum clause_type type, int val)
enum clause_type type, int val,
struct player *client_player)
{
struct player *pto = (pfrom == ptreaty->plr0
? ptreaty->plr1 : ptreaty->plr0);
......
}
if (type == CLAUSE_EMBASSY && player_has_real_embassy(pto, pfrom)) {
/* we already have embassy */
/* We already have embassy */
log_error("Illegal embassy clause: %s already have embassy with %s.",
nation_rule_name(nation_of_player(pto)),
nation_rule_name(nation_of_player(pfrom)));
......
return FALSE;
}
if (!are_reqs_active(&(const struct req_context) { .player = pfrom },
pto, &clause_infos[type].giver_reqs, RPT_POSSIBLE)
|| !are_reqs_active(&(const struct req_context) { .player = pto },
pfrom, &clause_infos[type].receiver_reqs,
RPT_POSSIBLE)) {
return FALSE;
/* Leave it to the server to decide if the other party can meet
* the requirements. */
if (client_player == NULL || client_player == pfrom) {
if (!are_reqs_active(&(const struct req_context) { .player = pfrom },
pto, &clause_infos[type].giver_reqs, RPT_POSSIBLE)) {
return FALSE;
}
}
if (client_player == NULL || client_player == pto) {
if (!are_reqs_active(&(const struct req_context) { .player = pto },
pfrom, &clause_infos[type].receiver_reqs,
RPT_POSSIBLE)) {
return FALSE;
}
}
clause_list_iterate(ptreaty->clauses, old_clause) {
common/diptreaty.h
void init_treaty(struct Treaty *ptreaty,
struct player *plr0, struct player *plr1);
bool add_clause(struct Treaty *ptreaty, struct player *pfrom,
enum clause_type type, int val);
enum clause_type type, int val,
struct player *client_player);
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom,
enum clause_type type, int val);
void clear_treaty(struct Treaty *ptreaty);
server/diplhand.c
ptreaty = find_treaty(pplayer, pother);
if (ptreaty && add_clause(ptreaty, pgiver, type, value)) {
/*
* If we are trading cities, then it is possible that the
* dest is unaware of it's existence. We have 2 choices,
* forbid it, or lighten that area. If we assume that
if (ptreaty != NULL
&& add_clause(ptreaty, pgiver, type, value, NULL)) {
/*
* If we are trading cities, then it is possible that
* the dest is unaware of it's existence. We have 2 choices,
* forbid it, or lighten that area. If we assume that
* the giver knows what they are doing, then 2. is the
* most powerful option - I'll choose that for now.
* - Kris Bubendorfer
server/savegame/savegame2.c
"treaty%d.clause%d.value",
tidx, cidx);
add_clause(ptreaty, pgiver, type, value);
add_clause(ptreaty, pgiver, type, value, NULL);
}
}
}
server/savegame/savegame3.c
"treaty%d.clause%d.value",
tidx, cidx);
add_clause(ptreaty, pgiver, type, value);
add_clause(ptreaty, pgiver, type, value, NULL);
}
}
}
(1-1/2)