]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/move.c
commands: Rename the command functions
[empserver] / src / lib / commands / move.c
index ac872f1202f79e97bad45e30f00d2ea8c6ecc3c6..91b55edf895df91441a7f83e768461ee628accad 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2011, 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
 
 #include <config.h>
 
+#include "chance.h"
 #include "commands.h"
 #include "item.h"
-#include "land.h"
+#include "map.h"
 #include "optlist.h"
 #include "path.h"
 #include "plague.h"
 
 
-static int cmd_move_map(coord curx, coord cury, char *arg);
+static int cmd_move_map(coord, coord, char *, char *);
 
 int
-move(void)
+c_move(void)
 {
     int amount;
     struct sctstr sect;
@@ -139,7 +140,7 @@ move(void)
        }
     }
 
-    if (!istest && !want_to_abandon(&sect, vtype, amount, NULL)) {
+    if (!istest && !abandon_askyn(&sect, vtype, amount, NULL)) {
        pr("Move cancelled.\n");
        return RET_FAIL;
     }
@@ -249,7 +250,7 @@ move(void)
     if (amount > ITEM_MAX - amt_dst) {
        pr("Only enough room for %d in %s.  The goods will be returned.\n",
           ITEM_MAX - amt_dst, xyas(sect.sct_x, sect.sct_y, player->cnum));
-       /* FIXME Not nice.  Move what we can and return the rest.  */
+       /* FIXME Not nice.  Move what we can and return the rest. */
        getsect(x, y, &sect);
     }
 
@@ -340,45 +341,7 @@ move(void)
  */
 /*ARGSUSED*/
 static int
-cmd_move_map(coord curx, coord cury, char *arg)
+cmd_move_map(coord curx, coord cury, char *arg1, char *arg2)
 {
-    return display_region_map(0, EF_SHIP, curx, cury, arg);
-}
-
-int
-want_to_abandon(struct sctstr *sp, i_type vtype, int amnt, struct lndstr *lp)
-{
-    char prompt[80];
-
-    /*
-     * First, would we be abandoning it?  If not, just return that
-     * it's ok to move out.
-     */
-    if (!would_abandon(sp, vtype, amnt, lp))
-       return 1;
-
-    sprintf(prompt, "Do you really want to abandon %s [yn]? ",
-           xyas(sp->sct_x, sp->sct_y, player->cnum));
-
-    return askyn(prompt);
-}
-
-int
-would_abandon(struct sctstr *sp, i_type vtype, int amnt, struct lndstr *lp)
-{
-    int mil, civs;
-
-    if (vtype != I_CIVIL && vtype != I_MILIT)
-       return 0;
-
-    mil = sp->sct_item[I_MILIT];
-    civs = sp->sct_item[I_CIVIL];
-
-    if (vtype == I_MILIT)
-       mil -= amnt;
-    if (vtype == I_CIVIL)
-       civs -= amnt;
-
-    return sp->sct_own != 0 && civs <= 0 && mil <= 0
-       && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, lp);
+    return display_region_map(0, EF_SHIP, curx, cury, arg1, arg2);
 }