]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/load.c
Update copyright notice
[empserver] / src / lib / commands / load.c
index 0e8bea59816cc92f5b93d6191e5101c3189c5d8e..04abbbfaa68a00d64f8fb4c4b166d24071ce00a3 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-2016, 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/>.
  *
  *  ---
  *
  *     David Sharnoff, 1987
  *     Ken Stevens, 1995 (rewritten)
  *     Steve McClure, 1998-2000
- *     Markus Armbruster, 2004-2009
+ *     Markus Armbruster, 2004-2014
  */
 
 #include <config.h>
 
 #include <ctype.h>
 #include "commands.h"
-#include "empobj.h"
 #include "item.h"
 #include "land.h"
 #include "optlist.h"
@@ -132,7 +130,7 @@ load(void)
                continue;
            if (load_unload == LOAD) {
                if (noisy)
-                   pr("You don't own %s \n",
+                   pr("You don't own %s\n",
                       xyas(sect.sct_x, sect.sct_y, player->cnum));
                continue;
            }
@@ -328,18 +326,12 @@ move_amount(int sect_amt, int unit_amt, int unit_max,
        move_amt = -amount - unit_amt;
     else
        move_amt = load_unload == LOAD ? amount : -amount;
-    if (move_amt > unit_max - unit_amt)
-       move_amt = unit_max - unit_amt;
-    if (move_amt < -unit_amt)
-       move_amt = -unit_amt;
-    if (move_amt > sect_amt)
-       move_amt = sect_amt;
-    if (move_amt < sect_amt - ITEM_MAX)
-       move_amt = sect_amt - ITEM_MAX;
+    move_amt = LIMIT_TO(move_amt, -unit_amt, unit_max - unit_amt);
+    move_amt = LIMIT_TO(move_amt, sect_amt - ITEM_MAX, sect_amt);
     return move_amt;
 }
 
-static int
+int
 load_comm_ok(struct sctstr *sectp, natid unit_own,
             i_type item, int move_amt)
 {
@@ -364,7 +356,7 @@ void
 gift(natid givee, natid giver, void *ptr, char *mesg)
 {
     if (giver != givee)
-       wu(0, givee, "%s %s %s\n", cname(giver), obj_nameof(ptr), mesg);
+       wu(0, givee, "%s %s %s\n", cname(giver), unit_nameof(ptr), mesg);
     unit_give_away(ptr, givee, 0);
 }
 
@@ -463,7 +455,7 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
        } else if (sp->shp_x != pln.pln_x || sp->shp_y != pln.pln_y)
            continue;
 
-       if (!could_be_on_ship(&pln, sp, 0, 0, 0, 0)) {
+       if (!could_be_on_ship(&pln, sp)) {
            if (noisy) {
                if (plchr[(int)pln.pln_type].pl_flags & P_K)
                    p = "choppers";
@@ -520,16 +512,14 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
     int load_spy = 0;
 
     if (load_unload == LOAD) {
-       if (opt_LANDSPIES) {
-           if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
-               (mchr[(int)sp->shp_type].m_nland == 0)) {
-               if (shp_nland(sp) >= 2) {
-                   pr("Non-land unit carrying subs can only carry up to two spy units.\n");
-                   return 0;
-               }
-               /* Eh, let 'em load a spy only */
-               load_spy = 1;
+       if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
+           (mchr[(int)sp->shp_type].m_nland == 0)) {
+           if (shp_nland(sp) >= 2) {
+               pr("Non-land unit carrying subs can only carry up to two spy units.\n");
+               return 0;
            }
+           /* Eh, let 'em load a spy only */
+           load_spy = 1;
        }
        if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
            if (noisy) {
@@ -614,16 +604,14 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
        /* Fit unit on ship */
        if (load_unload == LOAD) {
            /* We have to check again, since it may have changed */
-           if (opt_LANDSPIES) {
-               if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
-                   (mchr[(int)sp->shp_type].m_nland == 0)) {
-                   if (shp_nland(sp) >= 2) {
-                       pr("Non-land unit carrying subs can only carry up to two spy units.\n");
-                       return 0;
-                   }
-                   /* Eh, let 'em load a spy only */
-                   load_spy = 1;
+           if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
+               (mchr[(int)sp->shp_type].m_nland == 0)) {
+               if (shp_nland(sp) >= 2) {
+                   pr("Non-land unit carrying subs can only carry up to two spy units.\n");
+                   return 0;
                }
+               /* Eh, let 'em load a spy only */
+               load_spy = 1;
            }
            if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
                if (noisy) {
@@ -704,7 +692,7 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
                           load_unload, atoi(p));
     if (!load_comm_ok(sectp, sp->shp_own, item, move_amt))
        return RET_OK;
-    if (!want_to_abandon(sectp, item, move_amt, NULL))
+    if (!abandon_askyn(sectp, item, move_amt, NULL))
        return RET_FAIL;
     if (!still_ok_ship(sectp, sp))
        return RET_SYN;