]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/plnsub.c
Update copyright notice
[empserver] / src / lib / subs / plnsub.c
index 7c6f49cb49b3b94a09104bffd40e0aab2afc56de..3eb4a3f42ec40b31ba4f949d1313107d4f90558b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -35,6 +35,7 @@
 
 #include <config.h>
 
+#include "chance.h"
 #include "empobj.h"
 #include "file.h"
 #include "item.h"
@@ -45,6 +46,7 @@
 #include "nsc.h"
 #include "nuke.h"
 #include "optlist.h"
+#include "plague.h"
 #include "plane.h"
 #include "player.h"
 #include "prototypes.h"
@@ -184,17 +186,16 @@ pln_where_to_land(coord x, coord y,
 }
 
 int
-pln_oneway_to_carrier_ok(struct emp_qelem *bomb_list,
-                        struct emp_qelem *esc_list, int cno)
+pln_can_land_on_carrier(struct emp_qelem *bomb_list,
+                       struct emp_qelem *esc_list,
+                       struct shpstr *sp)
+
 {
     int n, nch, nxl, nmsl;
     struct emp_qelem *list, *qp;
     struct plist *plp;
-    struct shpstr ship;
 
-    if (cno < 0 || !getship(cno, &ship))
-       return 0;
-    n = shp_nplane(&ship, &nch, &nxl, &nmsl);
+    n = shp_nplane(sp, &nch, &nxl, &nmsl);
 
     /* for both lists */
     for (list = bomb_list;
@@ -202,14 +203,14 @@ pln_oneway_to_carrier_ok(struct emp_qelem *bomb_list,
         list = list == bomb_list ? esc_list : NULL) {
        for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
            plp = (struct plist *)qp;
-           if (plp->plane.pln_ship == ship.shp_uid)
+           if (plp->plane.pln_ship == sp->shp_uid)
                continue;
            n++;
            if (!inc_shp_nplane(&plp->plane, &nch, &nxl, &nmsl))
                return 0;
        }
     }
-    return ship_can_carry(&ship, n, nch, nxl, nmsl);
+    return ship_can_carry(sp, n, nch, nxl, nmsl);
 }
 
 void
@@ -237,6 +238,9 @@ pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
                       cname(player->cnum), prplane(&plp->plane),
                       prship(&ship));
                }
+               if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
+                   && ship.shp_pstage == PLG_HEALTHY)
+                   ship.shp_pstage = PLG_EXPOSED;
            }
        } else {
            plp->plane.pln_x = tx;
@@ -248,6 +252,9 @@ pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
                   cname(player->cnum),
                   prplane(&plp->plane), xyas(tx, ty, sect.sct_own));
            }
+           if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
+               && sect.sct_pstage == PLG_HEALTHY)
+               sect.sct_pstage = PLG_EXPOSED;
            plp->plane.pln_ship = cno;
        }
     }
@@ -264,14 +271,10 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
     struct shpstr ship;
     int there;
     int max;
+    int pstage;
 
     if (!ip)
        return;
-    amt = 0;
-    for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
-       plp = (struct plist *)qp;
-       amt += plp->load;
-    }
     if (cno < 0) {
        getsect(tx, ty, &sect);
        if (!sect.sct_own) {
@@ -293,11 +296,23 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
        }
        there = sect.sct_item[ip->i_uid];
        max = ITEM_MAX;
+       pstage = sect.sct_pstage;
     } else {
        getship(cno, &ship);
        there = ship.shp_item[ip->i_uid];
        max = mchr[ship.shp_type].m_item[ip->i_uid];
+       pstage = ship.shp_pstage;
     }
+
+    amt = 0;
+    for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
+       plp = (struct plist *)qp;
+       amt += plp->load;
+       if (plp->load
+           && plp->pstage == PLG_INFECT && pstage == PLG_HEALTHY)
+           pstage = PLG_EXPOSED;
+    }
+
     there += amt;
     if (there > max) {
        pr("%d excess %s discarded\n", there - max, ip->i_name);
@@ -307,6 +322,7 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
     pr("%d %s landed safely", amt, ip->i_name);
     if (cno < 0) {
        sect.sct_item[ip->i_uid] = there;
+       sect.sct_pstage = pstage;
        if (sect.sct_own != player->cnum)
            wu(0, sect.sct_own, "%s planes drop %d %s in %s\n",
               cname(player->cnum), amt, ip->i_name,
@@ -315,6 +331,7 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
        putsect(&sect);
     } else {
        ship.shp_item[ip->i_uid] = there;
+       ship.shp_pstage = pstage;
        if (ship.shp_own != player->cnum)
            wu(0, ship.shp_own, "%s planes land %d %s on carrier %d\n",
               cname(player->cnum), amt, ip->i_name, ship.shp_uid);
@@ -577,6 +594,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap,
        putplane(plane.pln_uid, &plane);
        plp = malloc(sizeof(struct plist));
        plp->load = 0;
+       plp->pstage = PLG_HEALTHY;
        plp->pcp = pcp;
        plp->plane = plane;
        emp_insque(&plp->queue, list);
@@ -627,14 +645,17 @@ 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;
        own = ship.shp_own;
     } else if (pp->pln_land >= 0) {
        getland(pp->pln_land, &land);
+       plp->pstage = land.lnd_pstage;
        item = land.lnd_item;
        own = land.lnd_own;
     } else {
        getsect(pp->pln_x, pp->pln_y, &sect);
+       plp->pstage = sect.sct_pstage;
        item = sect.sct_item;
        own = sect.sct_oldown;
     }