]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/satmap.c
Update copyright notice.
[empserver] / src / lib / subs / satmap.c
index 12f8ebcc065c98ad83f5c8c06aeaec5e34116173..1ce0dc15b2bae30894ede1ccc4f4fe10af9f2ee9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  * 
  *  Known contributors to this file:
  *     Steve McClure, 2000
- *     
  */
 
 #include <config.h>
 
+#include <stdlib.h>
+#include "file.h"
+#include "land.h"
+#include "map.h"
 #include "misc.h"
+#include "nat.h"
+#include "nsc.h"
+#include "optlist.h"
+#include "plane.h"
 #include "player.h"
-#include "xy.h"
+#include "prototypes.h"
 #include "sect.h"
 #include "ship.h"
-#include "land.h"
-#include "plane.h"
-#include "nsc.h"
-#include "nat.h"
-#include "file.h"
-#include "prototypes.h"
-#include "optlist.h"
+#include "xy.h"
 
-static s_char **rad;
-static s_char *radbuf;
+static char **rad;
+static char *radbuf;
 
 void
 satmap(int x, int y, int eff, int range, int flags, int type)
@@ -65,17 +66,16 @@ satmap(int x, int y, int eff, int range, int flags, int type)
     int n;
     int changed = 0;
     long crackle;
-    s_char noise[100];
-    s_char selection[1024];
+    signed char noise[100];
+    char selection[1024];
 
     if (!eff)
        return;
 
     if (!radbuf)
-       radbuf = malloc((WORLD_Y * (WORLD_X + 1)) *
-                                 sizeof(s_char));
+       radbuf = malloc(WORLD_Y * (WORLD_X + 1));
     if (!rad) {
-       rad = malloc(WORLD_Y * sizeof(s_char *));
+       rad = malloc(WORLD_Y * sizeof(char *));
        if (rad && radbuf) {
            for (rx = 0; rx < WORLD_Y; rx++)
                rad[rx] = &radbuf[(WORLD_X + 1) * rx];
@@ -88,8 +88,8 @@ satmap(int x, int y, int eff, int range, int flags, int type)
     }
 
     range = range * (eff / 100.0);
-    pr("%s efficiency %d%%, max range %d\n", xyas(x, y, player->cnum),
-       eff, range);
+    pr("%s efficiency %d%%, max range %d\n",
+       xyas(x, y, player->cnum), eff, range);
     memset(noise, 0, sizeof(noise));
     if (eff < 100) {
        pr("Some noise on the transmission...\n");
@@ -107,7 +107,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
        else
            snxtsct_dist(&ns, x, y, range);
 
-       blankfill((s_char *)radbuf, &ns.range, 1);
+       blankfill(radbuf, &ns.range, 1);
        if (flags & P_S) {
            pr("Satellite sector report\n");
            prdate();
@@ -122,7 +122,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
                continue;
            if (flags & P_S) {
                if (sect.sct_own && sect.sct_own != player->cnum) {
-                   satdisp(&sect, acc, 0);
+                   satdisp_sect(&sect, acc);
                    ++count;
                    if (opt_HIDDEN)
                        setcont(player->cnum, sect.sct_own, FOUND_FLY);
@@ -210,7 +210,9 @@ satmap(int x, int y, int eff, int range, int flags, int type)
        while (nxtitem(&ni, &land)) {
            if (land.lnd_own == 0)
                continue;
-           if (!chance((double)land.lnd_effic / 20.0))
+           if (lchr[(int)land.lnd_type].l_flags & L_SPY)
+               continue;
+           if (!chance(land.lnd_effic / 20.0))
                continue;
            if (++crackle == 100)
                crackle = 0;
@@ -276,13 +278,8 @@ sathead(void)
 }
 
 void
-satdisp(struct sctstr *sp, int acc, int showstuff)
+satdisp_sect(struct sctstr *sp, int acc)
 {
-    int first;
-    struct nstr_item ni;
-    struct shpstr ship;
-    struct lndstr land;
-
     prxy("%4d,%-4d   ", sp->sct_x, sp->sct_y, player->cnum);
     pr("%c  %3d  %3d %3d %3d %3d %4d %4d %4d %4d %4d %4d %5d\n",
        dchr[sp->sct_type].d_mnem,
@@ -299,9 +296,17 @@ satdisp(struct sctstr *sp, int acc, int showstuff)
        roundintby(sp->sct_item[I_FOOD], acc));
     map_set(player->cnum, sp->sct_x, sp->sct_y, dchr[sp->sct_type].d_mnem,
            0);
-    if (!showstuff)
-       return;
-    snxtitem_xy(&ni, EF_SHIP, sp->sct_x, sp->sct_y);
+}
+
+void
+satdisp_units(coord x, coord y)
+{
+    int first;
+    struct nstr_item ni;
+    struct shpstr ship;
+    struct lndstr land;
+
+    snxtitem_xy(&ni, EF_SHIP, x, y);
     first = 1;
     while (nxtitem(&ni, &ship)) {
        if (ship.shp_own == 0)
@@ -322,22 +327,26 @@ satdisp(struct sctstr *sp, int acc, int showstuff)
     if (!first)
        pr("\n");
 
-    snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
+    snxtitem_xy(&ni, EF_LAND, x, y);
     first = 1;
 
     while (nxtitem(&ni, &land)) {
        if (land.lnd_own == 0)
            continue;
-       if (!chance((double)land.lnd_effic / 20.0))
+       if (land.lnd_ship >= 0 || land.lnd_land >= 0)
+           continue;
+       if (lchr[(int)land.lnd_type].l_flags & L_SPY)
+           continue;
+       if (!chance(land.lnd_effic / 20.0))
            continue;
 
        if (first) {
-           pr("\t own  lnd# unit type         sector   eff\n");
+           pr("\t own  lnd# unit type       sector   eff\n");
            first = 0;
        }
 
-       pr("\t%4d %4d %-16.16s ", land.lnd_own, land.lnd_uid,
-          lchr[(int)land.lnd_type].l_name);
+       pr("\t%4d %4d %-16.16s ",
+          land.lnd_own, land.lnd_uid, lchr[(int)land.lnd_type].l_name);
        prxy("%4d,%-4d ", land.lnd_x, land.lnd_y, player->cnum);
        pr("%3d%%\n", land.lnd_effic);
     }