/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* ---
*
* look.c: Lookout from a ship or land unit
- *
+ *
* Known contributors to this file:
- *
+ * Ron Koenderink, 2006-2007
*/
#include <config.h>
unsigned char *bitmap;
int changed = 0;
- if (!snxtitem(&ni, type, player->argp[1]))
+ if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
+ type = EF_SHIP;
+
+ if (!snxtitem(&ni, type, player->argp[1], NULL))
return RET_SYN;
- if ((bitmap = malloc((WORLD_X * WORLD_Y) / 8)) == 0) {
+ bitmap = calloc(WORLD_SZ() / 8, 1);
+ if (!bitmap) {
logerror("malloc failed in do_look\n");
pr("Memory error. Tell the deity.\n");
return RET_FAIL;
}
- memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8);
while (nxtitem(&ni, &unit)) {
if (!player->owner)
continue;
continue;
tmcp = &mchr[(int)sp->shp_type];
if (smcp->m_flags & M_SUB)
- vrange = (int)(sp->shp_visib * range / 30.0);
+ vrange = (int)(shp_visib(sp) * range / 30.0);
else
- vrange = (int)(sp->shp_visib * range / 20.0);
+ vrange = (int)(shp_visib(sp) * range / 20.0);
getsect(sp->shp_x, sp->shp_y, §);
if (sect.sct_type != SCT_WATER)
vrange = MAX(1, vrange);
int i;
int dist;
- drange = techfact(lookland->lnd_tech, lookland->lnd_spy);
+ drange = techfact(lookland->lnd_tech, lchr[lookland->lnd_type].l_spy);
drange *= lookland->lnd_effic / 100.0;
range = ldround(drange, 1);
if (!(chance(LND_SPY_DETECT_CHANCE(lp->lnd_effic))))
continue;
}
- vrange = ldround((lp->lnd_vis * range) / 20.0, 1);
+ vrange = ldround((lnd_vis(lp) * range) / 20.0, 1);
dist = mapdist(lp->lnd_x, lp->lnd_y,
lookland->lnd_x, lookland->lnd_y);
if (dist > vrange)