]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/thre.c
Update copyright notice.
[empserver] / src / lib / commands / thre.c
index d821291cb05a7e54640928268595c64166bd8e21..38119389af648bc8780873f5d0fe200995268336 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
 int
 thre(void)
 {
-    extern     struct ichrstr *whatitem();
-    struct     sctstr sect;
-    struct     nstr_sect nstr;
-    int        val;
-    struct     ichrstr *ip;
-    s_char     *p;
-    int        thresh;
-    int        type;
-    s_char     prompt[128];
-    s_char     buf[128];
-    
+    struct sctstr sect;
+    struct nstr_sect nstr;
+    int val;
+    struct ichrstr *ip;
+    s_char *p;
+    int thresh;
+    int type;
+    s_char prompt[128];
+    s_char buf[128];
+
     if ((ip = whatitem(player->argp[1], "What commodity? ")) == 0)
        return RET_SYN;
     if (!snxtsct(&nstr, player->argp[2]))
        return RET_SYN;
-    type = V_DIST(ip->i_vtype & (~VT_TYPE));
+    type = ip->i_vtype;
     if (player->argp[3] && *player->argp[3] &&
        (*player->argp[3] < '0' || *player->argp[3] > '9')) {
-       pr ("Threshold must be a number\n");
+       pr("Threshold must be a number\n");
        return RET_SYN;
     }
     while (!player->aborted && nxtsct(&nstr, &sect)) {
        if (!player->owner)
            continue;
-       val = getvar(type, (s_char *)&sect, EF_SECTOR);
+       val = sect.sct_dist[type];
        if (val > 0)
            sprintf(prompt, "%s %s  old threshold %d new? ",
                    xyas(nstr.x, nstr.y, player->cnum),
@@ -89,8 +88,8 @@ thre(void)
        if (*p == '\0' || *p == '-')
            continue;
        thresh = atoi(p);
-       if (thresh > 10000)
-           thresh = 10000;
+       if (thresh > ITEM_MAX)
+           thresh = ITEM_MAX;
        if ((val > 0) && (val == thresh)) {
            pr("%s threshold unchanged (left at %d)\n",
               xyas(nstr.x, nstr.y, player->cnum), val);
@@ -98,11 +97,8 @@ thre(void)
        }
        if (val > 0 && (player->argp[3] != 0 && *player->argp[3] != 0))
            pr("%s old threshold %d\n",
-              xyas(nstr.x, nstr.y, player->cnum),
-              val);
-       if (putvar(type, thresh, (s_char *)&sect, EF_SECTOR) < 0)
-           pr("No room for threshold in %s\n",
-              xyas(nstr.x, nstr.y, player->cnum));
+              xyas(nstr.x, nstr.y, player->cnum), val);
+       sect.sct_dist[type] = thresh;
        putsect(&sect);
     }
     return RET_OK;