]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/unitsub.c
commands: Rename the command functions
[empserver] / src / lib / subs / unitsub.c
index 5441624150dd51abd7bd177b4c11f7bbbbf95db2..21222eef295b9c6bd3823ea03d5efcedab3fc39a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -34,7 +34,6 @@
 #include <config.h>
 
 #include <math.h>
-#include "file.h"
 #include "map.h"
 #include "optlist.h"
 #include "path.h"
@@ -255,7 +254,7 @@ unit_move_non_dir(struct emp_qelem *list, char *cp, int *map_shown)
        if (leader->ef_type != EF_SHIP)
            return NULL;
        cp = unit_move_parse(cp, leader_str);
-       sona();
+       c_sonar();
        player->btused++;       /* FIXME likewise */
        *map_shown = 1;
        break;
@@ -269,9 +268,9 @@ unit_move_non_dir(struct emp_qelem *list, char *cp, int *map_shown)
            player->argp[1] = leader_str;
        }
        if (leader->ef_type == EF_SHIP)
-           mine();
+           c_mine();
        else
-           landmine();
+           c_lmine();
        player->btused++;       /* FIXME likewise */
        *map_shown = 1;
        break;
@@ -406,8 +405,16 @@ unit_move(struct emp_qelem *list)
         */
        if (!*cp) {
            cp = unit_move_getpath(list, suppress_map, path);
-           if (!cp)
+           if (!cp) {
+               if (type == EF_SHIP) {
+                   shp_nav_stay_behind(list, player->cnum);
+                   shp_nav_put(list, player->cnum);
+               } else {
+                   lnd_mar_stay_behind(list, player->cnum);
+                   lnd_mar_put(list, player->cnum);
+               }
                return RET_FAIL;
+           }
            cp = unit_move_route(leader, path, sizeof(path));
            if (!cp || !*cp)
                cp = "h";
@@ -415,14 +422,20 @@ unit_move(struct emp_qelem *list)
        } else if ((dir = chkdir(*cp, DIR_STOP, DIR_LAST)) >= 0) {
            cp++;
            if (type == EF_SHIP)
-               stopping = shp_nav_one_sector(list, dir, player->cnum);
+               stopping = shp_nav_dir(list, dir, player->cnum)
+                   || shp_nav_gauntlet(list, 1, player->cnum);
            else {
-               if (!moved && !lnd_abandon_askyn(list))
+               if (!moved && !lnd_abandon_askyn(list)) {
+                   lnd_mar_put(list, player->cnum);
                    return RET_FAIL;
-               stopping = lnd_mar_one_sector(list, dir, player->cnum);
+               }
+               stopping = lnd_mar_dir(list, dir, player->cnum)
+                   || lnd_mar_gauntlet(list, 1, player->cnum);
            }
-           if (dir == DIR_STOP)
+           if (dir == DIR_STOP) {
+               CANT_HAPPEN(!QEMPTY(list));
                return RET_OK;
+           }
            moved = 1;
            if (stopping)
                cp = "";
@@ -435,7 +448,7 @@ unit_move(struct emp_qelem *list)
                   type == EF_SHIP ? "flagship" : "leader");
                pr("`r' to radar, %s`l' to look, `M' to map, `B' to bmap,\n",
                   type == EF_SHIP ? "`s' to sonar, " : "");
-               pr("`d' to drop mines, and `m' to minesweep\n");
+               pr("`d' to drop mines, and `m' to sweep mines\n");
                cp = "";
            }
        }
@@ -462,8 +475,8 @@ unit_move(struct emp_qelem *list)
 }
 
 /*
- * Teleport UNIT to X,Y.
- * If UNIT's mission op-area is centered on it, keep it centered.
+ * Teleport @unit to @x,@y.
+ * If @unit's mission op-area is centered on it, keep it centered.
  */
 void
 unit_teleport(struct empobj *unit, coord x, coord y)
@@ -477,7 +490,7 @@ unit_teleport(struct empobj *unit, coord x, coord y)
 }
 
 /*
- * Update cargo of CARRIER for movement or destruction.
+ * Update cargo of @carrier for movement or destruction.
  * If the carrier is destroyed, destroy its cargo (planes, land units,
  * nukes).
  * Else update their location to the carrier's.  Any op sectors equal
@@ -509,8 +522,8 @@ unit_update_cargo(struct empobj *carrier)
 }
 
 /*
- * Drop cargo of UNIT.
- * Give it to NEWOWN, unless it's zero.
+ * Drop cargo of @unit.
+ * Give it to @newown, unless it's zero.
  */
 void
 unit_drop_cargo(struct empobj *unit, natid newown)
@@ -545,9 +558,9 @@ unit_drop_cargo(struct empobj *unit, natid newown)
 }
 
 /*
- * Give UNIT and its cargo to RECIPIENT.
- * No action if RECIPIENT already owns UNIT.
- * If GIVER is non-zero, inform RECIPIENT and GIVER of the transaction.
+ * Give @unit and its cargo to @recipient.
+ * No action if @recipient already owns @unit.
+ * If @giver is non-zero, inform @recipient and @giver of the transaction.
  * Clears mission and group on the units given away.
  */
 void
@@ -579,7 +592,7 @@ unit_give_away(struct empobj *unit, natid recipient, natid giver)
 }
 
 /*
- * Wipe orders and such from UNIT.
+ * Wipe orders and such from @unit.
  */
 void
 unit_wipe_orders(struct empobj *unit)