]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/desi.c
Update copyright notice
[empserver] / src / lib / commands / desi.c
index 8a3c1bec4cb6eb35373ffa36529f9a63defe52f8..76df4139e40d0b343951d490c51ba7e9bc93a824 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
  *  ---
  *
  *  desi.c: Redesignate sectors
- * 
+ *
  *  Known contributors to this file:
  *     Steve McClure, 1998-2000
- *     Markus Armbruster, 2004-2008
+ *     Markus Armbruster, 2004-2009
  */
 
 #include <config.h>
 #include "commands.h"
 #include "map.h"
 #include "optlist.h"
-#include "path.h"
 
 int
 desi(void)
 {
     int n;
     char *p;
-    int cap_x;
-    int cap_y;
     int des;
     struct nstr_sect nstr;
     struct sctstr sect;
@@ -58,9 +54,7 @@ desi(void)
     if (!snxtsct(&nstr, player->argp[1]))
        return RET_SYN;
     natp = getnatp(player->cnum);
-    cap_x = natp->nat_xcap;
-    cap_y = natp->nat_ycap;
-    while (!player->aborted && nxtsct(&nstr, &sect)) {
+    while (nxtsct(&nstr, &sect)) {
        if (!player->owner)
            continue;
        if (!player->god && dchr[sect.sct_type].d_cost < 0)
@@ -68,8 +62,10 @@ desi(void)
        sprintf(prompt, "%s %d%% %s  desig? ",
                xyas(sect.sct_x, sect.sct_y, player->cnum),
                sect.sct_effic, dchr[sect.sct_type].d_name);
-       if ((p = getstarg(player->argp[2], prompt, buf)) == 0)
-           continue;
+       if (!(p = getstarg(player->argp[2], prompt, buf))) {
+           rc = RET_FAIL;
+           break;
+       }
 
        if (!check_sect_ok(&sect))
            continue;
@@ -78,7 +74,7 @@ desi(void)
        if (des < 0) {
            pr("No such designation\n"
               "See \"info Sector-types\" for possible designations\n");
-           rc = RET_SYN;
+           rc = RET_FAIL;
            break;
        }
        if (!player->god) {
@@ -94,6 +90,11 @@ desi(void)
                rc = RET_FAIL;
                break;
            }
+           if (dchr[des].d_terrain != dchr[sect.sct_type].d_terrain) {
+               pr("You can't change a %s into a %s\n",
+                  dchr[sect.sct_type].d_name, dchr[des].d_name);
+               continue;
+           }
        }
        if (sect.sct_type == des && sect.sct_newtype == des)
            continue;
@@ -127,7 +128,8 @@ desi(void)
        }
        sect.sct_newtype = des;
        putsect(&sect);
-       if (sect.sct_x == cap_x && sect.sct_y == cap_y
+       if (!player->god
+           && sect.sct_x == natp->nat_xcap && sect.sct_y == natp->nat_ycap
            && des != SCT_CAPIT && des != SCT_SANCT && des != SCT_MOUNT)
            pr("You have redesignated your capital!\n");
        if (opt_EASY_BRIDGES == 0) {    /* may cause a bridge fall */