]> git.pond.sub.org Git - empserver/commitdiff
subs: Move sector abandonment functions to control.c
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 28 Dec 2014 20:42:02 +0000 (21:42 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 28 Feb 2015 15:13:14 +0000 (16:13 +0100)
Move them out of commands/move.c, because they're the only thing
involving land units there.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/prototypes.h
src/lib/commands/move.c
src/lib/subs/control.c

index a72d3b6f26d858bffd516f10ca15a133dfeb0778..0a08db85e9241c6e94df51c2741477192ae4678a 100644 (file)
@@ -59,8 +59,6 @@ extern int edit_sect_i(struct sctstr *, char *, int);
 extern int load_comm_ok(struct sctstr *, natid, i_type, int);
 extern void gift(natid, natid, void *, char *);
 extern int display_mark(i_type, int);
 extern int load_comm_ok(struct sctstr *, natid, i_type, int);
 extern void gift(natid, natid, void *, char *);
 extern int display_mark(i_type, int);
-extern int want_to_abandon(struct sctstr *, i_type, int, struct lndstr *);
-extern int would_abandon(struct sctstr *, i_type, int, struct lndstr *);
 extern int nav_map(int, int, int);
 extern int do_unit_move(struct emp_qelem *, int *, double *, double *);
 extern int count_pop(int);
 extern int nav_map(int, int, int);
 extern int do_unit_move(struct emp_qelem *, int *, double *, double *);
 extern int count_pop(int);
@@ -406,6 +404,8 @@ extern int check_trade_ok(struct trdstr *);
 extern void set_coastal(struct sctstr *, int, int);
 /* control.c */
 extern int military_control(struct sctstr *);
 extern void set_coastal(struct sctstr *, int, int);
 /* control.c */
 extern int military_control(struct sctstr *);
+extern int want_to_abandon(struct sctstr *, i_type, int, struct lndstr *);
+extern int would_abandon(struct sctstr *, i_type, int, struct lndstr *);
 /* damage.c */
 extern void landdamage(struct lndstr *, int);
 extern void ship_damage(struct shpstr *, int);
 /* damage.c */
 extern void landdamage(struct lndstr *, int);
 extern void ship_damage(struct shpstr *, int);
index 2ff28fa64747bd809fadd0a86b78b484be4f4b0e..c9f012fb0719062de84a13752d9214238577aa39 100644 (file)
@@ -345,41 +345,3 @@ cmd_move_map(coord curx, coord cury, char *arg1, char *arg2)
 {
     return display_region_map(0, EF_SHIP, curx, cury, arg1, arg2);
 }
 {
     return display_region_map(0, EF_SHIP, curx, cury, arg1, arg2);
 }
-
-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);
-}
index a724570433b5e2b5a30f94d001cf55b7eb5f9ea1..cec33a7cab43521b81f8a94a96e407f7e73626d4 100644 (file)
@@ -35,6 +35,7 @@
 #include "file.h"
 #include "land.h"
 #include "nsc.h"
 #include "file.h"
 #include "land.h"
 #include "nsc.h"
+#include "player.h"
 #include "prototypes.h"
 #include "sect.h"
 
 #include "prototypes.h"
 #include "sect.h"
 
@@ -60,3 +61,41 @@ military_control(struct sctstr *sp)
 
     return 1;
 }
 
     return 1;
 }
+
+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);
+}