From 38e7a0f20df10208c2cbd6b8f455a6f36532728c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 12 Jun 2022 10:44:43 +0300 Subject: [PATCH 45/45] Editor: Disallow creation of more than one unit of unique type Reported by Alexandro Ignatiev See osdn #44793 Signed-off-by: Marko Lindqvist --- server/edithand.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/edithand.c b/server/edithand.c index d662995f40..93b853c8dd 100644 --- a/server/edithand.c +++ b/server/edithand.c @@ -461,6 +461,22 @@ void handle_edit_unit_create(struct connection *pc, int owner, int tile, return; } + if (utype_has_flag(punittype, UTYF_UNIQUE)) { + if (utype_player_already_has_this_unique(pplayer, punittype)) { + notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor, + _("Cannot create another instance of unique unit type %s. " + "Player already has one such unit."), + utype_name_translation(punittype)); + return; + } + if (count > 1) { + notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor, + _("Cannot create multiple instances of unique unit type %s."), + utype_name_translation(punittype)); + return; + } + } + if (is_non_allied_unit_tile(ptile, pplayer) || (tile_city(ptile) && !pplayers_allied(pplayer, city_owner(tile_city(ptile))))) { -- 2.35.1