]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/sell.c
commands: Rename the command functions
[empserver] / src / lib / commands / sell.c
index 1e88bc0a85d045a5c96b819bc75a9a6e0b574f7e..e53ce8462d5f83372b4a277c9df1471c200b3aad 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2021, 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/>.
  *
  *  ---
  *
 #include "commands.h"
 #include "commodity.h"
 #include "item.h"
-#include "land.h"
 #include "optlist.h"
-#include "plane.h"
-#include "ship.h"
 
 /*
  * format: sell <COMMODITY> <SECTS> <NUMBER> <PRICE>
@@ -51,7 +47,7 @@
  *   each sector.
  */
 int
-sell(void)
+c_sell(void)
 {
     struct sctstr sect;
     struct ichrstr *ip;
@@ -98,6 +94,10 @@ sell(void)
        pr("Sectors need at least 1 mobility to sell goods.\n");
        return RET_FAIL;
     }
+    if (ip->i_uid == I_CIVIL && sect.sct_oldown != sect.sct_own) {
+       pr("You can't sell conquered populace!\n");
+       return RET_FAIL;
+    }
     p = getstarg(player->argp[3], "Quantity: ", buf);
     if (!p || !*p)
        return RET_SYN;
@@ -137,29 +137,25 @@ sell(void)
        xyas(sect.sct_x, sect.sct_y, player->cnum), amt);
     sect.sct_item[ip->i_uid] = amt;
     putsect(&sect);
-    if (totalcom > 0) {
-       for (ii = 0; getcomm(ii, &comm); ii++) {
-           if (comm.com_owner == 0)
-               break;
-       }
-       (void)time(&now);
-       ef_blank(EF_COMM, ii, &comm);
-       comm.com_type = ip->i_uid;
-       comm.com_owner = player->cnum;
-       comm.com_price = price;
-       comm.com_maxbidder = player->cnum;
-       comm.com_markettime = now;
-       comm.com_amount = totalcom;
-       comm.com_x = 0;
-       comm.com_y = 0;
-       comm.sell_x = sect.sct_x;
-       comm.sell_y = sect.sct_y;
-       if (!putcomm(ii, &comm)) {
-           pr("Problems with the commodities file, call the Deity\n");
-           return RET_FAIL;
-       }
-    } else {
-       pr("No eligible %s for sale\n", ip->i_name);
+
+    for (ii = 0; getcomm(ii, &comm); ii++) {
+       if (comm.com_owner == 0)
+           break;
+    }
+    (void)time(&now);
+    ef_blank(EF_COMM, ii, &comm);
+    comm.com_type = ip->i_uid;
+    comm.com_owner = player->cnum;
+    comm.com_price = price;
+    comm.com_maxbidder = player->cnum;
+    comm.com_markettime = now;
+    comm.com_amount = totalcom;
+    comm.com_x = 0;
+    comm.com_y = 0;
+    comm.sell_x = sect.sct_x;
+    comm.sell_y = sect.sct_y;
+    if (!putcomm(ii, &comm)) {
+       pr("Problems with the commodities file, call the Deity\n");
        return RET_FAIL;
     }
     return RET_OK;