]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/mission.c
Update copyright notice
[empserver] / src / lib / subs / mission.c
index 6db7db0484dc63d0a6034b9e2aba856b779f837e..ee909b7c94c11efa089dceabc72b963bbe414ae9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2016, 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-2012
+ *     Markus Armbruster, 2003-2015
  */
 
 #include <config.h>
@@ -107,7 +107,7 @@ ground_interdict(coord x, coord y, natid victim, char *s)
     act[0] = 0;
     for (cn = 1; cn < MAXNOC; cn++) {
        act[cn] = relations_with(cn, victim) <= HOSTILE;
-       emp_initque((struct emp_qelem *)&mi[cn]);
+       emp_initque(&mi[cn].queue);
     }
 
     build_mission_list(mi, act, act, x, y, MI_INTERDICT);
@@ -192,7 +192,7 @@ unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
        other_act[cn] = rel <= HOSTILE;
        plane_act[cn] = mission == MI_SINTERDICT
            ? rel <= NEUTRAL : other_act[cn];
-       emp_initque((struct emp_qelem *)&mi[cn]);
+       emp_initque(&mi[cn].queue);
     }
 
     build_mission_list(mi, other_act, plane_act, x, y, mission);
@@ -233,8 +233,8 @@ def_support(coord x, coord y, natid victim, natid actee)
 }
 
 /*
- * Perform support missions in X,Y against VICTIM for ACTEE.
- * MISSION is either MI_OSUPPORT or MI_DSUPPORT.
+ * Perform support missions in @x,@y against @victim for @actee.
+ * @mission is either MI_OSUPPORT or MI_DSUPPORT.
  * Return total damage.
  */
 static int
@@ -250,7 +250,7 @@ dosupport(coord x, coord y, natid victim, natid actee, int mission)
     act[0] = 0;
     for (cn = 1; cn < MAXNOC; cn++) {
        act[cn] = feels_like_helping(cn, actee, victim);
-       emp_initque((struct emp_qelem *)&mi[cn]);
+       emp_initque(&mi[cn].queue);
     }
 
     build_mission_list(mi, act, act, x, y, MI_SUPPORT);
@@ -289,7 +289,7 @@ build_mission_list_type(struct genlist mi[], unsigned char act[],
 
     snxtitem_all(&ni, type);
     while (nxtitem(&ni, &item)) {
-       gp = (struct empobj *)&item;
+       gp = &item.gen;
 
        if (!act[gp->own])
            continue;
@@ -487,8 +487,7 @@ perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
        wu(0, sp->shp_own,
           "\tEffective torpedo range is %d.0\n", range);
        wu(0, sp->shp_own,
-          "\tWhooosh... Hitchance = %d%%\n",
-          (int)(hitchance * 100));
+          "\tWhooosh... Hitchance = %.0f%%\n", hitchance * 100);
 
        if (!chance(hitchance)) {
            wu(0, sp->shp_own, "\tMissed\n");
@@ -561,7 +560,7 @@ perform_mission_msl(int dam, struct emp_qelem *missiles, coord x, coord y,
            if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
                         N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
                CANT_REACH();
-           dam2 = pln_damage(&plp->plane, 'p', 1);
+           dam2 = pln_damage(&plp->plane, 'p', "");
            air_dam += dam2;
        use_up_msl:
            plp->plane.pln_effic = 0;
@@ -748,7 +747,7 @@ mission_name(int mission)
 }
 
 /*
- * Maximum distance GP can perform its mission.
+ * Maximum distance @gp can perform its mission.
  * Note: this has nothing to do with the radius of the op-area.
  * oprange() governs where the unit *can* strike, the op-area governs
  * where the player wants it to strike.
@@ -774,7 +773,7 @@ oprange(struct empobj *gp)
 }
 
 /*
- * Does GP's mission op area cover X,Y?
+ * Does @gp's mission op area cover @x,@y?
  */
 int
 in_oparea(struct empobj *gp, coord x, coord y)
@@ -992,7 +991,7 @@ add_airport(struct emp_qelem *airp, coord x, coord y)
     getsect(x, y, &sect);
     a->own = sect.sct_own;
 
-    emp_insque((struct emp_qelem *)a, airp);
+    emp_insque(&a->queue, airp);
 }
 
 /*
@@ -1027,6 +1026,7 @@ air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
     struct plist *plp;
     struct plnstr *pp;
     int newdam, dam = 0;
+    char buf[32];
     int hitchance;
 
     for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
@@ -1060,20 +1060,25 @@ air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
               "\t%s pinbombing %s %s in %s\n",
               prplane(pp), cname(victim), s, xyas(x, y, pp->pln_own));
        }
-       hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
+
+       buf[0] = 0;
        if (nuk_on_plane(&plp->plane) >= 0)
            hitchance = 100;
-       else if (hardtarget != SECT_HARDTARGET)
-           wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
+       else {
+           hitchance = pln_hitchance(pp, hardtarget, EF_SHIP);
+           if (hardtarget != SECT_HARDTARGET)
+               snprintf(buf, sizeof(buf), "\t\t%d%% hitchance...",
+                        hitchance);
+       }
        if (pct_chance(hitchance)) {
-           newdam = pln_damage(&plp->plane, 'p', 1);
+           newdam = pln_damage(&plp->plane, 'p', buf);
            wu(0, pp->pln_own,
               "\t\thit %s %s for %d damage\n",
               cname(victim), s, newdam);
            dam += newdam;
        } else {
-           newdam = pln_damage(&plp->plane, 'p', 0);
-           wu(0, pp->pln_own, "missed\n");
+           newdam = pln_damage(&plp->plane, 'p', NULL);
+           wu(0, pp->pln_own, "%smissed\n", buf);
            if (mission == MI_SINTERDICT) {
                mpr(victim,
                    "RUMBLE... your sub in %s hears a depth-charge explode nearby\n",