]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/satmap.c
Move declarations for chance.c to new chance.h
[empserver] / src / lib / subs / satmap.c
index 0de3c21ef533157d06a4f13feed4380f872b5ae2..e016e54d3fa6531bc940c5d0548a4a16be26a6fc 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
  *
  *  Known contributors to this file:
  *     Steve McClure, 2000
+ *     Markus Armbruster, 2004-2011
  */
 
 #include <config.h>
 
 #include <stdlib.h>
+#include "chance.h"
 #include "file.h"
 #include "land.h"
 #include "map.h"
@@ -50,7 +52,7 @@
 static char **rad;
 static char *radbuf;
 
-void
+int
 satmap(int x, int y, int eff, int range, int flags, int type)
 {
     struct sctstr sect;
@@ -65,10 +67,9 @@ satmap(int x, int y, int eff, int range, int flags, int type)
     int changed = 0;
     long crackle;
     signed char noise[100];
-    char selection[1024];
 
     if (!eff)
-       return;
+       return RET_OK;
 
     if (!radbuf)
        radbuf = malloc(WORLD_Y * MAPWIDTH(1));
@@ -82,7 +83,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
 
     if (!radbuf || !rad) {
        pr("Memory error in satmap, tell the deity.\n");
-       return;
+       return RET_FAIL;
     }
 
     range = range * (eff / 100.0);
@@ -95,15 +96,11 @@ satmap(int x, int y, int eff, int range, int flags, int type)
            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);
-
     if (type == EF_BAD || type == EF_SECTOR) {
-       if (type == EF_SECTOR)  /* Use ?conditionals */
-           snxtsct(&ns, selection);
-       else
-           snxtsct_dist(&ns, x, y, range);
+       snxtsct_dist(&ns, x, y, range);
+       if (type == EF_SECTOR && !snxtsct_use_condarg(&ns))
+           return RET_SYN;
+           
 
        blankfill(radbuf, &ns.range, 1);
        if (flags & P_S) {
@@ -143,10 +140,9 @@ satmap(int x, int y, int eff, int range, int flags, int type)
 
     if ((type == EF_BAD || type == EF_SHIP) &&
        (flags & P_S || flags & P_I)) {
-       if (type == EF_SHIP)
-           snxtitem(&ni, EF_SHIP, selection, NULL);
-       else
-           snxtitem_dist(&ni, EF_SHIP, x, y, range);
+       snxtitem_dist(&ni, EF_SHIP, x, y, range);
+       if (type == EF_SHIP && !snxtitem_use_condarg(&ni))
+           return RET_SYN;
 
        crackle = count = 0;
        if (flags & P_S) {
@@ -188,10 +184,9 @@ satmap(int x, int y, int eff, int range, int flags, int type)
 
     if ((type == EF_BAD || type == EF_LAND) &&
        (flags & P_S || flags & P_I)) {
-       if (type == EF_LAND)
-           snxtitem(&ni, EF_LAND, selection, NULL);
-       else
-           snxtitem_dist(&ni, EF_LAND, x, y, range);
+       snxtitem_dist(&ni, EF_LAND, x, y, range);
+       if (type == EF_LAND && !snxtitem_use_condarg(&ni))
+           return RET_SYN;
 
        crackle = count = 0;
        if (flags & P_S) {
@@ -247,6 +242,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
            pr("%s\n", rad[row]);
        pr("\n(c) 1989 Imaginative Images Inc.\n");
     }
+    return RET_OK;
 }
 
 void