]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/look.c
Fix trailing whitespace
[empserver] / src / lib / commands / look.c
index 6850a9a5f873975eebad786973c896ed3dfbed79..45e316fc8900d71fa22ad5f72aedf582b3cbb7b5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,9 +26,9 @@
  *  ---
  *
  *  look.c: Lookout from a ship or land unit
- * 
+ *
  *  Known contributors to this file:
- *     
+ *     Ron Koenderink, 2006-2007
  */
 
 #include <config.h>
@@ -39,7 +39,6 @@
 #include "optlist.h"
 #include "path.h"
 
-static int do_look(short type);
 static void look_ship(struct shpstr *lookship);
 static void look_land(struct lndstr *lookland);
 
@@ -55,7 +54,7 @@ llook(void)
     return do_look(EF_LAND);
 }
 
-static int
+int
 do_look(short type)
 {
     int i;
@@ -68,14 +67,17 @@ do_look(short type)
     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;
@@ -159,9 +161,9 @@ look_ship(struct shpstr *lookship)
            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, &sect);
        if (sect.sct_type != SCT_WATER)
            vrange = MAX(1, vrange);
@@ -205,7 +207,7 @@ look_land(struct lndstr *lookland)
     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);
 
@@ -226,7 +228,7 @@ look_land(struct lndstr *lookland)
            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)