]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/mine.c
commands: Rename the command functions
[empserver] / src / lib / commands / mine.c
index 3d97136a04de98dc8ec35fbdf64a08644df5ecf1..20966fbeb70b613f91d54015523f69bd0a3eb5fc 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2009, 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/>.
  *
  *  ---
  *
@@ -28,7 +27,7 @@
  *  mine.c: Lay mines from ships or units
  *
  *  Known contributors to this file:
- *
+ *     Markus Armbruster, 2004-2010
  */
 
 #include <config.h>
@@ -42,7 +41,7 @@
  * format: mine <SHIPS> <NUMBER MINES>
  */
 int
-mine(void)
+c_mine(void)
 {
     struct shpstr ship;
     struct sctstr sect;
@@ -68,7 +67,7 @@ mine(void)
            continue;
        mines_avail = MIN(shells, mines);
        if (getsect(ship.shp_x, ship.shp_y, &sect) == 0 ||
-           (sect.sct_type != SCT_WATER && sect.sct_type != SCT_BSPAN)) {
+           sect.sct_type != SCT_WATER) {
            pr("You can't lay mines there!!\n");
            continue;
        }
@@ -89,12 +88,12 @@ mine(void)
  * format: landmine <UNITS> <NUMBER MINES>
  */
 int
-landmine(void)
+c_lmine(void)
 {
     struct lndstr land;
     struct sctstr sect;
     struct nstr_item ni;
-    int shells, todo;
+    int todo;
     int mines_wanted;
     int mines_laid;
     int total_mines_laid;
@@ -109,7 +108,7 @@ landmine(void)
            continue;
        if (land.lnd_ship >= 0 || land.lnd_land >= 0) {
            pr("%s is on a %s\n", prland(&land),
-              land. lnd_ship >= 0 ? "ship" : "land unit");
+              land.lnd_ship >= 0 ? "ship" : "land unit");
            continue;
        }
        if (land.lnd_mobil < 1) {
@@ -117,7 +116,7 @@ landmine(void)
            continue;
        }
        if (!getsect(land.lnd_x, land.lnd_y, &sect)
-           || sect.sct_type == SCT_WATER || sect.sct_type == SCT_BSPAN
+           || SCT_MINES_ARE_SEAMINES(&sect)
            || sect.sct_own != land.lnd_own) {
            pr("You can't lay mines there!!\n");
            continue;
@@ -137,27 +136,22 @@ landmine(void)
        todo = MIN(mines_wanted, land.lnd_mobil);
        total_mines_laid = 0;
        do {
-           shells = land.lnd_item[I_SHELL];
-           if (shells < todo)
-               shells += supply_commod(land.lnd_own,
-                                       land.lnd_x, land.lnd_y, I_SHELL,
-                                       todo - shells);
-           mines_laid = MIN(todo, shells);
-           land.lnd_item[I_SHELL] = shells - mines_laid;
+           lnd_supply(&land, I_SHELL, todo);
+           mines_laid = MIN(todo, land.lnd_item[I_SHELL]);
+           land.lnd_item[I_SHELL] -= mines_laid;
            land.lnd_mobil -= mines_laid;
            putland(land.lnd_uid, &land);
            total_mines_laid += mines_laid;
            todo -= mines_laid;
        } while (todo && mines_laid);
-       resupply_commod(&land, I_SHELL);
-       putland(land.lnd_uid, &land);
+       lnd_supply_all(&land);
        getsect(sect.sct_x, sect.sct_y, &sect);
        sect.sct_mines = MIN(sect.sct_mines + total_mines_laid, MINES_MAX);
        putsect(&sect);
        if (total_mines_laid == mines_wanted) {
            pr("%s laid a total of %d mines in %s",
               prland(&land), total_mines_laid,
-              xyas(sect.sct_x, sect.sct_y, land.lnd_own));
+              xyas(sect.sct_x, sect.sct_y, player->cnum));
            if (!land.lnd_item[I_SHELL])
                pr(" but is now out of shells\n");
            else
@@ -168,7 +162,7 @@ landmine(void)
               prland(&land),
               land.lnd_mobil > 0 ? "shells" : "mobility",
               total_mines_laid,
-              xyas(sect.sct_x, sect.sct_y, land.lnd_own));
+              xyas(sect.sct_x, sect.sct_y, player->cnum));
     }
     return RET_OK;
 }