]> git.pond.sub.org Git - empserver/commitdiff
Remove unreachable code in sell()
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 26 Oct 2011 17:42:37 +0000 (19:42 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 29 Dec 2011 10:47:04 +0000 (11:47 +0100)
sell used to search multiple sectors for sellable commodities, keeping
tally in totalcom.  It failed with message "No eligible" when none
could be found.

sell's second argument got changed to a single sector in Empire 3.  If
the sector can't sell, we return early.  Else, totalcom is positive.
Thus, the "No eligible" code is unreachable.  Remove it.

src/lib/commands/sell.c

index 861762c8d991cc7ef882b8d4eab1d02fb10ede74..cf838335fec31b8ccd145f4d0fdddb7a2d9a2b74 100644 (file)
@@ -136,29 +136,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;