Project

General

Profile

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

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

View differences:

client/gui-gtk-3.0/diplodlg.c
return;
}
add_clause(&pdialog->treaty, player_by_number(giver), type, value);
add_clause(&pdialog->treaty, player_by_number(giver), type, value,
client_player());
update_diplomacy_dialog(pdialog);
gui_dialog_alert(pdialog->dialog);
}
client/gui-gtk-3.22/diplodlg.c
return;
}
add_clause(&pdialog->treaty, player_by_number(giver), type, value);
add_clause(&pdialog->treaty, player_by_number(giver), type, value,
client_player());
update_diplomacy_dialog(pdialog);
gui_dialog_alert(pdialog->dialog);
}
client/gui-gtk-4.0/diplodlg.c
return;
}
add_clause(&pdialog->treaty, player_by_number(giver), type, value);
add_clause(&pdialog->treaty, player_by_number(giver), type, value,
client_player());
update_diplomacy_dialog(pdialog);
gui_dialog_alert(pdialog->dialog);
}
client/gui-qt/diplodlg.cpp
w = gui()->game_tab_widget->widget(i);
dd = qobject_cast<diplo_dlg *>(w);
dw = dd->find_widget(counterpart);
add_clause(&dw->treaty, player_by_number(giver), type, value);
add_clause(&dw->treaty, player_by_number(giver), type, value,
client_player());
dw->update_wdg();
}
client/gui-sdl2/diplodlg.c
pclause->value);
} clause_list_iterate_end;
add_clause(&pdialog->treaty, player_by_number(giver), type, value);
add_clause(&pdialog->treaty, player_by_number(giver), type, value,
client_player());
update_clauses_list(pdialog);
update_acceptance_icons(pdialog);
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);
}
}
}
(2-2/2)