]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/mission.c
Update copyright notice
[empserver] / src / lib / subs / mission.c
index 4f50f352bac80e791a017f13229133249f14aff4..04685dd0421b20d8b67793669e6b342e5387a58a 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-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -29,7 +29,7 @@
  *  Known contributors to this file:
  *     Ken Stevens, 1995
  *     Steve McClure, 1996-2000
- *     Markus Armbruster, 2003-2009
+ *     Markus Armbruster, 2003-2012
  */
 
 #include <config.h>
 #include "item.h"
 #include "misc.h"
 #include "mission.h"
+#include "news.h"
 #include "nsc.h"
 #include "optlist.h"
 #include "path.h"
-#include "player.h"
+#include "plague.h"
 #include "prototypes.h"
 #include "queue.h"
 #include "xy.h"
@@ -329,7 +330,8 @@ find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
        if (!in_oparea((struct empobj *)&plane, x, y))
            continue;
        plp = malloc(sizeof(struct plist));
-       memset(plp, 0, sizeof(struct plist));
+       plp->load = 0;
+       plp->pstage = PLG_HEALTHY;
        plp->pcp = &plchr[(int)plane.pln_type];
        plp->plane = plane;
        emp_insque(&plp->queue, escorts);
@@ -371,8 +373,8 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
            else {
                /* save planes for later */
                plp = malloc(sizeof(struct plist));
-
-               memset(plp, 0, sizeof(struct plist));
+               plp->load = 0;
+               plp->pstage = PLG_HEALTHY;
                plp->pcp = pcp;
                memcpy(&plp->plane, glp->thing, sizeof(struct plnstr));
                if (plp->pcp->pl_flags & P_M)
@@ -578,7 +580,8 @@ perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
 {
     struct emp_qelem *qp, *newqp, escorts, airp, b, e;
     struct plist *plp;
-    int plane_owner, performed, air_dam, md;
+    int plane_owner, performed, air_dam;
+    size_t md;
 
     emp_initque(&escorts);
     emp_initque(&airp);
@@ -613,11 +616,9 @@ perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
     performed = air_dam = 0;
     for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
        struct airport *air;
-       char buf[512];
-       char *pp;
+       char buf[1024];
 
        air = (struct airport *)qp;
-       md = mapdist(x, y, air->x, air->y);
 
        emp_initque(&b);
        emp_initque(&e);
@@ -628,16 +629,17 @@ perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
        /* Split off the escorts at this base into e */
        divide(&escorts, &e, air->x, air->y);
 
-       mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
+       if (path_find(air->x, air->y, x, y, plane_owner, MOB_FLY) < 0)
+           continue;
+       md = path_find_route(buf, sizeof(buf), air->x, air->y, x, y);
+       if (md >= sizeof(buf))
+           continue;
 
+       mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
        if (QEMPTY(&b))
            continue;
-
        mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
 
-       pp = BestAirPath(buf, air->x, air->y, x, y);
-       if (CANT_HAPPEN(!pp))
-           continue;
        performed = 1;
        wu(0, plane_owner, "Flying %s mission from %s to %s\n",
           mission_name(mission),
@@ -650,7 +652,7 @@ perform_mission_bomb(int dam, struct emp_qelem *bombers, coord x, coord y,
               xyas(x, y, air->own));
        }
 
-       ac_encounter(&b, &e, air->x, air->y, pp, 0);
+       ac_encounter(&b, &e, air->x, air->y, buf, 0);
 
        if (!QEMPTY(&b))
            air_dam +=
@@ -894,12 +896,15 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
     pcp = plp->pcp;
     if (pp->pln_ship >= 0) {
        getship(pp->pln_ship, &ship);
+       plp->pstage = ship.shp_pstage;
        item = ship.shp_item;
     } else if (pp->pln_land >= 0) {
        getland(pp->pln_land, &land);
+       plp->pstage = land.lnd_pstage;
        item = land.lnd_item;
     } else {
        getsect(pp->pln_x, pp->pln_y, &sect);
+       plp->pstage = sect.sct_pstage;
        item = sect.sct_item;
     }
     if (pcp->pl_fuel > item[I_PETROL]) {