#include "prototypes.h"
#include "optlist.h"
-void satdisp(struct sctstr *sp, int acc, int showstuff);
+void satdisp(struct sctstr *sp, int acc, int showstuff);
-static s_char **rad;
-static s_char *radbuf;
+static s_char **rad;
+static s_char *radbuf;
void
satmap(int x, int y, int eff, int range, int flags, int type)
{
- int acc;
- struct sctstr sect;
- struct shpstr ship;
- struct lndstr land;
- int count;
- struct nstr_item ni;
- struct nstr_sect ns;
- int rx, ry;
- int row;
- int n;
- int changed = 0;
- long crackle;
- s_char noise[100];
- s_char selection[1024];
+ int acc;
+ struct sctstr sect;
+ struct shpstr ship;
+ struct lndstr land;
+ int count;
+ struct nstr_item ni;
+ struct nstr_sect ns;
+ int rx, ry;
+ int row;
+ int n;
+ int changed = 0;
+ long crackle;
+ s_char noise[100];
+ s_char selection[1024];
- if (!eff)
- return;
+ if (!eff)
+ return;
- if (!radbuf)
- radbuf = (s_char *)malloc((WORLD_Y * (WORLD_X + 1)) *
- sizeof(s_char));
- if (!rad) {
- rad = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
- if (rad && radbuf) {
- for (rx = 0; rx < WORLD_Y; rx++)
- rad[rx] = &radbuf[(WORLD_X + 1) * rx];
- }
+ if (!radbuf)
+ radbuf = (s_char *)malloc((WORLD_Y * (WORLD_X + 1)) *
+ sizeof(s_char));
+ if (!rad) {
+ rad = (s_char **)malloc(WORLD_Y * sizeof(s_char *));
+ if (rad && radbuf) {
+ for (rx = 0; rx < WORLD_Y; rx++)
+ rad[rx] = &radbuf[(WORLD_X + 1) * rx];
}
+ }
- if (!radbuf || !rad) {
- pr("Memory error in satmap, tell the deity.\n");
- return;
- }
+ if (!radbuf || !rad) {
+ pr("Memory error in satmap, tell the deity.\n");
+ return;
+ }
- range = range * (eff / 100.0);
- pr("%s efficiency %d%%, max range %d\n", xyas(x, y, player->cnum),
- eff, range);
- bzero(noise, sizeof(noise));
- if (eff < 100) {
- pr("Some noise on the transmission...\n");
- for (n = 0; n < (100 - eff); ++n)
- noise[100 * n / (100 - eff)] = 1;
- }
+ range = range * (eff / 100.0);
+ pr("%s efficiency %d%%, max range %d\n", xyas(x, y, player->cnum),
+ eff, range);
+ bzero(noise, sizeof(noise));
+ if (eff < 100) {
+ pr("Some noise on the transmission...\n");
+ for (n = 0; n < (100 - eff); ++n)
+ noise[100 * n / (100 - eff)] = 1;
+ }
- /* Have to convert to player coords, since it gets converted
- back from there */
- sprintf(selection, "@%s:%d", xyas(x, y, player->cnum), range);
+ /* Have to convert to player coords, since it gets converted
+ back from there */
+ sprintf(selection, "@%s:%d", xyas(x, y, player->cnum), range);
- if (type == EF_BAD || type == EF_SECTOR) {
- if (type == EF_SECTOR) /* Use ?conditionals */
- snxtsct(&ns, selection);
- else
- snxtsct_dist(&ns, x, y, range);
-
- blankfill((s_char *)radbuf, &ns.range, 1);
- if (flags & P_S) {
- pr("Satellite sector report\n");
- prdate();
- sathead();
- acc = (flags & P_I) ? 5 : 50;
+ if (type == EF_BAD || type == EF_SECTOR) {
+ if (type == EF_SECTOR) /* Use ?conditionals */
+ snxtsct(&ns, selection);
+ else
+ snxtsct_dist(&ns, x, y, range);
+
+ blankfill((s_char *)radbuf, &ns.range, 1);
+ if (flags & P_S) {
+ pr("Satellite sector report\n");
+ prdate();
+ sathead();
+ acc = (flags & P_I) ? 5 : 50;
+ }
+ crackle = count = 0;
+ while (nxtsct(&ns, §)) {
+ if (++crackle == 100)
+ crackle = 0;
+ if (noise[crackle])
+ continue;
+ if (flags & P_S) {
+ if (sect.sct_type > SCT_RURAL) {
+ satdisp(§, acc, 0);
+ ++count;
}
- crackle = count = 0;
- while (nxtsct(&ns, §)) {
- if (++crackle == 100)
- crackle = 0;
- if (noise[crackle])
- continue;
- if (flags & P_S) {
- if (sect.sct_type > SCT_RURAL) {
- satdisp(§, acc,0);
- ++count;
- }
- if (opt_HIDDEN) {
- setcont(player->cnum, sect.sct_own, FOUND_FLY);
- }
- }
- if ((flags & P_I) ||
- sect.sct_type == SCT_WATER ||
- sect.sct_type == SCT_MOUNT) {
- rad[ns.dy][ns.dx] = dchr[sect.sct_type].d_mnem;
- } else
- rad[ns.dy][ns.dx] = '?';
- changed += map_set(player->cnum, ns.x, ns.y, rad[ns.dy][ns.dx],0);
+ if (opt_HIDDEN) {
+ setcont(player->cnum, sect.sct_own, FOUND_FLY);
}
- if (changed)
- writemap(player->cnum);
- if (flags & P_S)
- pr(" %d sectors\n\n", count);
+ }
+ if ((flags & P_I) ||
+ sect.sct_type == SCT_WATER || sect.sct_type == SCT_MOUNT) {
+ rad[ns.dy][ns.dx] = dchr[sect.sct_type].d_mnem;
+ } else
+ rad[ns.dy][ns.dx] = '?';
+ changed +=
+ map_set(player->cnum, ns.x, ns.y, rad[ns.dy][ns.dx], 0);
}
+ if (changed)
+ writemap(player->cnum);
+ if (flags & P_S)
+ pr(" %d sectors\n\n", count);
+ }
- if ((type == EF_BAD || type == EF_SHIP) &&
- (flags & P_S || flags & P_I)) {
- if (type == EF_SHIP)
- snxtitem(&ni, EF_SHIP, selection);
- else
- snxtitem_dist(&ni, EF_SHIP, x, y, range);
+ if ((type == EF_BAD || type == EF_SHIP) &&
+ (flags & P_S || flags & P_I)) {
+ if (type == EF_SHIP)
+ snxtitem(&ni, EF_SHIP, selection);
+ else
+ snxtitem_dist(&ni, EF_SHIP, x, y, range);
- crackle = count = 0;
- if (flags & P_S) {
- pr("Satellite ship report\n");
- prdate();
- if (opt_SHIPNAMES) {
- pr(" own shp# ship type sector eff\n");
- } else {
- pr(" own shp# ship type sector eff\n");
- }
- }
- while (nxtitem(&ni, (caddr_t)&ship)) {
- if (ship.shp_own == 0)
- continue;
- if ((mchr[(int)ship.shp_type].m_flags & M_SUB) &&
- ((flags & (P_S|P_I)) != (P_S|P_I)))
- continue;
- if (++crackle == 100)
- crackle = 0;
- if (noise[crackle])
- continue;
- if (flags & P_S) {
- pr("%4d %4d %-16.16s ",
- ship.shp_own, ship.shp_uid,
- mchr[(int)ship.shp_type].m_name);
- if (opt_SHIPNAMES)
- pr("%-25.25s ", ship.shp_name);
- prxy("%4d,%-4d ", ship.shp_x, ship.shp_y,
- player->cnum);
- pr("%3d%%\n", ship.shp_effic);
- ++count;
- if (opt_HIDDEN) {
- setcont(player->cnum, ship.shp_own, FOUND_FLY);
- }
- }
- /* If we are imaging *and* drawing the map */
- if ((flags & P_I) && (type == EF_BAD)) {
- /* Figure out where to put the ship */
- /* First, figure out the distance from the two */
- rx = diffx((int)ship.shp_x, x);
- ry = diffy((int)ship.shp_y, y);
- /* Next, determine which direction to add it to the center */
- /* We can only do this if imaging and we have gotten the center
- up above by imaging the sectors. */
- rx = deltax(x, ns.range.lx) + rx;
- ry = deltay(y, ns.range.ly) + ry;
- /* &~0x20 makes it a cap letter */
- rad[ry][rx] = (*mchr[(int)ship.shp_type].m_name) & ~0x20;
- }
+ crackle = count = 0;
+ if (flags & P_S) {
+ pr("Satellite ship report\n");
+ prdate();
+ if (opt_SHIPNAMES) {
+ pr(" own shp# ship type sector eff\n");
+ } else {
+ pr(" own shp# ship type sector eff\n");
+ }
+ }
+ while (nxtitem(&ni, (caddr_t)&ship)) {
+ if (ship.shp_own == 0)
+ continue;
+ if ((mchr[(int)ship.shp_type].m_flags & M_SUB) &&
+ ((flags & (P_S | P_I)) != (P_S | P_I)))
+ continue;
+ if (++crackle == 100)
+ crackle = 0;
+ if (noise[crackle])
+ continue;
+ if (flags & P_S) {
+ pr("%4d %4d %-16.16s ",
+ ship.shp_own, ship.shp_uid,
+ mchr[(int)ship.shp_type].m_name);
+ if (opt_SHIPNAMES)
+ pr("%-25.25s ", ship.shp_name);
+ prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
+ pr("%3d%%\n", ship.shp_effic);
+ ++count;
+ if (opt_HIDDEN) {
+ setcont(player->cnum, ship.shp_own, FOUND_FLY);
}
- if (flags & P_S)
- pr(" %d ships\n\n", count);
+ }
+ /* If we are imaging *and* drawing the map */
+ if ((flags & P_I) && (type == EF_BAD)) {
+ /* Figure out where to put the ship */
+ /* First, figure out the distance from the two */
+ rx = diffx((int)ship.shp_x, x);
+ ry = diffy((int)ship.shp_y, y);
+ /* Next, determine which direction to add it to the center */
+ /* We can only do this if imaging and we have gotten the center
+ up above by imaging the sectors. */
+ rx = deltax(x, ns.range.lx) + rx;
+ ry = deltay(y, ns.range.ly) + ry;
+ /* &~0x20 makes it a cap letter */
+ rad[ry][rx] = (*mchr[(int)ship.shp_type].m_name) & ~0x20;
+ }
}
+ if (flags & P_S)
+ pr(" %d ships\n\n", count);
+ }
- if ((type == EF_BAD || type == EF_LAND) &&
- (flags & P_S || flags & P_I)) {
- if (type == EF_LAND)
- snxtitem(&ni, EF_LAND, selection);
- else
- snxtitem_dist(&ni, EF_LAND, x, y, range);
+ if ((type == EF_BAD || type == EF_LAND) &&
+ (flags & P_S || flags & P_I)) {
+ if (type == EF_LAND)
+ snxtitem(&ni, EF_LAND, selection);
+ else
+ snxtitem_dist(&ni, EF_LAND, x, y, range);
- crackle = count = 0;
- if (flags & P_S) {
- pr("Satellite unit report\n");
- prdate();
- pr(" own lnd# unit type sector eff\n");
- }
- while (nxtitem(&ni, (caddr_t)&land)) {
- if (land.lnd_own == 0)
- continue;
- if (!chance((double)land.lnd_effic/20.0))
- continue;
- if (++crackle == 100)
- crackle = 0;
- if (noise[crackle])
- continue;
- if (flags & P_S) {
- pr("%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);
- ++count;
- }
- /* If we are imaging *and* drawing the map */
- if ((flags & P_I) && (type == EF_BAD)) {
- /* Figure out where to put the unit */
- /* First, figure out the distance from the two */
- rx = diffx((int)land.lnd_x, x);
- ry = diffy((int)land.lnd_y, y);
- /* Next, determine which direction to add it to the center */
- /* We can only do this if imaging and we have gotten the center
- up above by imaging the sectors. */
- rx = deltax(x, ns.range.lx) + rx;
- ry = deltay(y, ns.range.ly) + ry;
- /* &~0x20 makes it a cap letter */
- rad[ry][rx] = (*lchr[(int)land.lnd_type].l_name) & ~0x20;
- }
- }
- if (flags & P_S)
- pr(" %d units\n\n", count);
+ crackle = count = 0;
+ if (flags & P_S) {
+ pr("Satellite unit report\n");
+ prdate();
+ pr(" own lnd# unit type sector eff\n");
}
+ while (nxtitem(&ni, (caddr_t)&land)) {
+ if (land.lnd_own == 0)
+ continue;
+ if (!chance((double)land.lnd_effic / 20.0))
+ continue;
+ if (++crackle == 100)
+ crackle = 0;
+ if (noise[crackle])
+ continue;
+ if (flags & P_S) {
+ pr("%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);
+ ++count;
+ }
+ /* If we are imaging *and* drawing the map */
+ if ((flags & P_I) && (type == EF_BAD)) {
+ /* Figure out where to put the unit */
+ /* First, figure out the distance from the two */
+ rx = diffx((int)land.lnd_x, x);
+ ry = diffy((int)land.lnd_y, y);
+ /* Next, determine which direction to add it to the center */
+ /* We can only do this if imaging and we have gotten the center
+ up above by imaging the sectors. */
+ rx = deltax(x, ns.range.lx) + rx;
+ ry = deltay(y, ns.range.ly) + ry;
+ /* &~0x20 makes it a cap letter */
+ rad[ry][rx] = (*lchr[(int)land.lnd_type].l_name) & ~0x20;
+ }
+ }
+ if (flags & P_S)
+ pr(" %d units\n\n", count);
+ }
- /* Ok, have we made the map? If so, display it */
- if (type == EF_BAD) {
- /*
- * print out the map
- * We have to make the center a '0' for ve
- * ve needs a garbage line to terminate the map
- */
- rad[deltay(y, ns.range.ly)][deltax(x, ns.range.lx)] = '0';
+ /* Ok, have we made the map? If so, display it */
+ if (type == EF_BAD) {
+ /*
+ * print out the map
+ * We have to make the center a '0' for ve
+ * ve needs a garbage line to terminate the map
+ */
+ rad[deltay(y, ns.range.ly)][deltax(x, ns.range.lx)] = '0';
- pr("Satellite radar report\n");
+ pr("Satellite radar report\n");
#ifdef HAY
- /* This is wrong for small, hitech worlds. */
- n = deltay(ns.range.hy, ns.range.ly);
+ /* This is wrong for small, hitech worlds. */
+ n = deltay(ns.range.hy, ns.range.ly);
#else
- /* This is already available, so why not use it. */
- n = ns.range.height;
+ /* This is already available, so why not use it. */
+ n = ns.range.height;
#endif
- for (row=0; row < n; row++)
- pr("%s\n", rad[row]);
- pr("\n(c) 1989 Imaginative Images Inc.\n");
- }
+ for (row = 0; row < n; row++)
+ pr("%s\n", rad[row]);
+ pr("\n(c) 1989 Imaginative Images Inc.\n");
+ }
}
void
sathead(void)
{
-pr(" sct rd rl def\n");
-pr(" sect type own eff eff eff eff civ mil shl gun iron pet food\n");
+ pr(" sct rd rl def\n");
+ pr(" sect type own eff eff eff eff civ mil shl gun iron pet food\n");
}
void
satdisp(struct sctstr *sp, int acc, int showstuff)
{
- int vec[I_MAX+1], first;
- struct nstr_item ni;
- struct shpstr ship;
- struct lndstr land;
+ int vec[I_MAX + 1], first;
+ struct nstr_item ni;
+ struct shpstr ship;
+ struct lndstr land;
- if (getvec(VT_ITEM, vec, (caddr_t)sp, EF_SECTOR) < 0)
- return;
- prxy("%4d,%-4d ", sp->sct_x, sp->sct_y, player->cnum),
+ if (getvec(VT_ITEM, vec, (caddr_t)sp, EF_SECTOR) < 0)
+ return;
+ 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,
- sp->sct_own, roundintby((int)sp->sct_effic, acc / 2),
- roundintby((int)sp->sct_road, acc / 2),
- roundintby((int)sp->sct_rail, acc / 2),
- roundintby((int)sp->sct_defense, acc / 2),
- roundintby(vec[I_CIVIL], acc), roundintby(vec[I_MILIT], acc),
- roundintby(vec[I_SHELL], acc), roundintby(vec[I_GUN], acc),
- roundintby(vec[I_IRON], acc), roundintby(vec[I_PETROL], acc),
- roundintby(vec[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);
- first=1;
- while (nxtitem(&ni, (caddr_t)&ship)) {
- if (ship.shp_own == 0)
- continue;
- if (mchr[(int)ship.shp_type].m_flags & M_SUB)
- continue;
- if (first){
- if (opt_SHIPNAMES) {
-pr("\t own shp# ship type sector eff\n");
- } else {
-pr("\t own shp# ship type sector eff\n");
- }
- first=0;
- }
- pr("\t%4d %4d %-16.16s ", ship.shp_own, ship.shp_uid,
- mchr[(int)ship.shp_type].m_name);
- if (opt_SHIPNAMES)
- pr("%-25.25s ", ship.shp_name);
- prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
- pr("%3d%%\n", ship.shp_effic);
+ dchr[sp->sct_type].d_mnem,
+ sp->sct_own, roundintby((int)sp->sct_effic, acc / 2),
+ roundintby((int)sp->sct_road, acc / 2),
+ roundintby((int)sp->sct_rail, acc / 2),
+ roundintby((int)sp->sct_defense, acc / 2),
+ roundintby(vec[I_CIVIL], acc), roundintby(vec[I_MILIT], acc),
+ roundintby(vec[I_SHELL], acc), roundintby(vec[I_GUN], acc),
+ roundintby(vec[I_IRON], acc), roundintby(vec[I_PETROL], acc),
+ roundintby(vec[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);
+ first = 1;
+ while (nxtitem(&ni, (caddr_t)&ship)) {
+ if (ship.shp_own == 0)
+ continue;
+ if (mchr[(int)ship.shp_type].m_flags & M_SUB)
+ continue;
+ if (first) {
+ if (opt_SHIPNAMES) {
+ pr("\t own shp# ship type sector eff\n");
+ } else {
+ pr("\t own shp# ship type sector eff\n");
+ }
+ first = 0;
}
+ pr("\t%4d %4d %-16.16s ", ship.shp_own, ship.shp_uid,
+ mchr[(int)ship.shp_type].m_name);
+ if (opt_SHIPNAMES)
+ pr("%-25.25s ", ship.shp_name);
+ prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
+ pr("%3d%%\n", ship.shp_effic);
+ }
- if (!first)
- pr("\n");
+ if (!first)
+ pr("\n");
- snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
- first=1;
+ snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
+ first = 1;
- while (nxtitem(&ni, (caddr_t)&land)) {
- if (land.lnd_own == 0)
- continue;
- if (!chance((double)land.lnd_effic/20.0))
- continue;
+ while (nxtitem(&ni, (caddr_t)&land)) {
+ if (land.lnd_own == 0)
+ continue;
+ if (!chance((double)land.lnd_effic / 20.0))
+ continue;
- if (first){
- 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);
- prxy("%4d,%-4d ",land.lnd_x, land.lnd_y, player->cnum);
- pr("%3d%%\n", land.lnd_effic);
+ if (first) {
+ pr("\t own lnd# unit type sector eff\n");
+ first = 0;
}
- if (!first)
- pr("\n");
-}
+ 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);
+ }
+ if (!first)
+ pr("\n");
+}