]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/drop.c
Use relations_with() for US==THEM || getrel(getnatp(US), THEM)
[empserver] / src / lib / commands / drop.c
index c1ea70ebc68a684ea6ace8e4074814866b5bf055..1ed7facd74f3916f61c95ed49537991df6cabe96 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -57,7 +57,6 @@ drop(void)
     struct sctstr ap_sect;
     char buf[1024];
 
-    wantflags = 0;
     if (get_planes(&ni_bomb, &ni_esc, player->argp[1], player->argp[2]) < 0)
        return RET_SYN;
     if (!get_assembly_point(player->argp[3], &ap_sect, buf))
@@ -75,18 +74,20 @@ drop(void)
        return RET_SYN;
     getsect(tx, ty, &target);
 
-    if (target.sct_own == player->cnum
-       || getrel(getnatp(target.sct_own), player->cnum) == ALLIED) {
+    if (relations_with(target.sct_own, player->cnum) == ALLIED) {
+       /* own or allied sector: cargo drop */
        if (ip->i_uid == I_CIVIL && target.sct_own != target.sct_oldown) {
            pr("Can't drop civilians into occupied sectors.\n");
            return RET_FAIL;
        }
+       wantflags = P_C;
     } else {
        /* into the unknown... */
        if (ip->i_uid != I_SHELL) {
            pr("You don't own %s!\n", xyas(tx, ty, player->cnum));
            return RET_FAIL;
        }
+       /* mine drop */
        wantflags = P_MINE;
     }
 
@@ -97,25 +98,21 @@ drop(void)
     /*
      * select planes within range
      */
-    pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target,
-           2, wantflags, P_M | P_O);
-    if (QEMPTY(&bomb_list)) {
-       pr("No planes could be equipped for the mission.\n");
-       return RET_FAIL;
-    }
-    pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target,
-           2, P_ESC | P_F, P_M | P_O);
+    pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, 2,
+           wantflags, P_M | P_O);
+    pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 2,
+           P_ESC | P_F, P_M | P_O);
     /*
      * now arm and equip the bombers, transports, whatever.
      */
     pln_arm(&bomb_list, 2 * ap_to_target,
            wantflags & P_MINE ? 'm' : 'd',
-           ip, 0);
+           ip);
     if (QEMPTY(&bomb_list)) {
        pr("No planes could be equipped for the mission.\n");
        return RET_FAIL;
     }
-    pln_arm(&esc_list, 2 * ap_to_target, 'd', ip, P_ESC | P_F);
+    pln_arm(&esc_list, 2 * ap_to_target, 'e', NULL);
     ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, 0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes got through fighter defenses\n");