<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40513 >

If a user tries to set a player's nation to one already assigned
to a different player via the property editor, then an assertion
fails in the server. Attached patch fixes this by disallowing
setting of already assigned nations on the server side.

diff --git a/server/edithand.c b/server/edithand.c
index f87772e..cc72622 100644
--- a/server/edithand.c
+++ b/server/edithand.c
@@ -795,6 +795,15 @@ void handle_edit_player(struct connection *pc,
                     "because the given nation ID %d is invalid."),
                   player_number(pplayer), player_name(pplayer),
+    } else if (pnation->player != NULL) {
+      notify_conn(pc->self, NULL, E_BAD_COMMAND,
+                  _("Cannot change nation for player %d (%s) "
+                    "to nation %d (%s) because that nation is "
+                    "already assigned to player %d (%s)."),
+                  player_number(pplayer), player_name(pplayer),
+                  packet->nation, nation_plural_translation(pnation),
+                  player_number(pnation->player),
+                  player_name(pnation->player));
     } else {
       changed = player_set_nation(pplayer, pnation);
Freeciv-dev mailing list

Reply via email to