From a4f0a34c3950a51f805eaa776c66f068f119b7bd Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 26 Mar 2022 16:10:24 +0200 Subject: [PATCH 38/38] Lua: Distinguish diplrel reasons in *_cant_be_built signals All the different diplrel related requirement types were emitting signals with identical reasons. Give them separate reasons, so that the script can tell them apart. See osdn #44192 Signed-off-by: Marko Lindqvist --- server/cityturn.c | 52 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/server/cityturn.c b/server/cityturn.c index a17e0f7fa8..bf3a668596 100644 --- a/server/cityturn.c +++ b/server/cityturn.c @@ -1464,6 +1464,8 @@ static bool worklist_item_postpone_req_vec(struct universal *target, case VUT_DIPLREL_TILE: /* The tile owner is the city owner */ case VUT_DIPLREL_TILE_O: /* The tile owner is the city owner */ if (preq->present) { + const char *reason; + notify_player(pplayer, city_tile(pcity), E_CITY_CANTBUILD, ftc_server, /* TRANS: '%s' is a wide range of relationships; @@ -1476,9 +1478,21 @@ static bool worklist_item_postpone_req_vec(struct universal *target, tgt_name, diplrel_name_translation( preq->source.value.diplrel)); + + if (preq->source.kind == VUT_DIPLREL_TILE) { + reason = "need_diplrel_tile"; + } else if (preq->source.kind == VUT_DIPLREL_TILE_O) { + reason = "need_diplrel_tile_o"; + } else { + fc_assert(preq->source.kind == VUT_DIPLREL); + reason = "need_diplrel"; + } + script_server_signal_emit(signal_name, ptarget, - pcity, "need_diplrel"); + pcity, reason); } else { + const char *reason; + notify_player(pplayer, city_tile(pcity), E_CITY_CANTBUILD, ftc_server, _("%s can't build %s from the worklist; " @@ -1488,13 +1502,25 @@ static bool worklist_item_postpone_req_vec(struct universal *target, tgt_name, diplrel_name_translation( preq->source.value.diplrel)); + + if (preq->source.kind == VUT_DIPLREL_TILE) { + reason = "have_diplrel_tile"; + } else if (preq->source.kind == VUT_DIPLREL_TILE_O) { + reason = "have_diplrel_tile_o"; + } else { + fc_assert(preq->source.kind == VUT_DIPLREL); + reason = "have_diplrel"; + } + script_server_signal_emit(signal_name, ptarget, - pcity, "have_diplrel"); + pcity, reason); } break; case VUT_DIPLREL_UNITANY: case VUT_DIPLREL_UNITANY_O: if (preq->present) { + const char *reason; + notify_player(pplayer, city_tile(pcity), E_CITY_CANTBUILD, ftc_server, /* TRANS: '%s' is a wide range of relationships; @@ -1507,9 +1533,19 @@ static bool worklist_item_postpone_req_vec(struct universal *target, tgt_name, diplrel_name_translation( preq->source.value.diplrel)); + + if (preq->source.kind == VUT_DIPLREL_UNITANY) { + reason = "need_diplrel_unitany"; + } else { + fc_assert(preq->source.kind == VUT_DIPLREL_UNITANY_O); + reason = "need_diplrel_unitany_o"; + } + script_server_signal_emit(signal_name, ptarget, - pcity, "need_diplrel"); + pcity, reason); } else { + const char *reason; + notify_player(pplayer, city_tile(pcity), E_CITY_CANTBUILD, ftc_server, _("%s can't build %s from the worklist; " @@ -1519,8 +1555,16 @@ static bool worklist_item_postpone_req_vec(struct universal *target, tgt_name, diplrel_name_translation( preq->source.value.diplrel)); + + if (preq->source.kind == VUT_DIPLREL_UNITANY) { + reason = "have_diplrel_unitany"; + } else { + fc_assert(preq->source.kind == VUT_DIPLREL_UNITANY_O); + reason = "have_diplrel_unitany_o"; + } + script_server_signal_emit(signal_name, ptarget, - pcity, "have_diplrel"); + pcity, reason); } break; case VUT_MINSIZE: -- 2.35.1