]> git.pond.sub.org Git - empserver/commitdiff
Make add require confirmation for unadvisable actions
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Nov 2011 18:40:21 +0000 (19:40 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 29 Dec 2011 10:47:06 +0000 (11:47 +0100)
Deleting a country in state STAT_SANCT, STAT_ACTIVE or STAT_GOD is
risky, because any references to this country become dangling, which
makes ef_verify() unhappy.  For a reason: we may well have code that
isn't prepared for dangling references, and breaks.

Replacing a country that is being used is risky, because it can get us
into weird states.  For instance, replacing a player by a visitor can
result in a visitor that owns stuff.

src/lib/commands/add.c

index 5580a903246386ab6c4709d5d995527040687888..6d8f649ccf3770e59dd2623e460c2d41a0589c4d 100644 (file)
@@ -108,6 +108,16 @@ add(void)
        pr("Illegal status\n");
        return RET_SYN;
     }
        pr("Illegal status\n");
        return RET_SYN;
     }
+    if (stat == STAT_UNUSED
+       ? natp->nat_stat >= STAT_SANCT : natp->nat_stat != STAT_UNUSED) {
+       pr("Country %s (#%d) status is %s.\n"
+          "%s it in this state is normally a bad idea.",
+          natp->nat_cnam, natp->nat_cnum,
+          symbol_by_value(natp->nat_stat, nation_status),
+          stat == STAT_UNUSED ? "Deleting" : "Replacing");
+       if (!askyn("Are you sure? "))
+           return RET_FAIL;
+    }
     if (getplayer(natp->nat_cnum)) {
        pr("%s (#%d) is logged in!\n",
           natp->nat_cnam, natp->nat_cnum);
     if (getplayer(natp->nat_cnum)) {
        pr("%s (#%d) is logged in!\n",
           natp->nat_cnam, natp->nat_cnum);