Make add require confirmation for unadvisable actions

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.
This commit is contained in:
Markus Armbruster 2011-11-06 19:40:21 +01:00
parent d2057af7a2
commit 6d98cd3134

View file

@ -108,6 +108,16 @@ add(void)
pr("Illegal status\n"); pr("Illegal status\n");
return RET_SYN; 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)) { if (getplayer(natp->nat_cnum)) {
pr("%s (#%d) is logged in!\n", pr("%s (#%d) is logged in!\n",
natp->nat_cnam, natp->nat_cnum); natp->nat_cnam, natp->nat_cnum);