From 80e6a46536f8cb8b0f6655e7ecbb27c29738600b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 4 Jul 2022 20:46:25 +0300 Subject: [PATCH 46/46] Editor: Disallow creating more than maxplayers players See osdn #44811 Signed-off-by: Marko Lindqvist --- server/edithand.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/edithand.c b/server/edithand.c index 93b853c8dd..22040e80ff 100644 --- a/server/edithand.c +++ b/server/edithand.c @@ -894,8 +894,9 @@ void handle_edit_player_create(struct connection *pc, int tag) struct player *pplayer; struct nation_type *pnation; struct research *presearch; + int existing = player_count(); - if (player_count() >= player_slot_count()) { + if (existing >= player_slot_count()) { notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor, _("No more players can be added because the maximum " "number of players (%d) has been reached."), @@ -903,7 +904,15 @@ void handle_edit_player_create(struct connection *pc, int tag) return; } - if (player_count() >= nation_count() ) { + if (existing >= game.server.max_players) { + notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor, + _("No more players can be added because there's " + "already maximum number of players allowed by maxplayers setting (value %d)"), + game.server.max_players); + return; + } + + if (existing >= nation_count() ) { notify_conn(pc->self, NULL, E_BAD_COMMAND, ftc_editor, _("No more players can be added because there are " "no available nations (%d used)."), -- 2.35.1