]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/setsect.c
Fix trailing whitespace
[empserver] / src / lib / commands / setsect.c
index d8aa8aaa2e09b0ae8be0347f0c859a54b6ea9e26..838e10d1b38fc55cd5bd2759143463767e34daf2 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-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
  *  setsect.c: Give resources to a country
- * 
+ *
  *  Known contributors to this file:
  *     David Muir Sharnoff
  *     Steve McClure, 1998
  */
 
-#include <stdio.h>
-#include <ctype.h>
-#include "misc.h"
-#include "player.h"
-#include "var.h"
-#include "xy.h"
-#include "sect.h"
-#include "nat.h"
-#include "news.h"
-#include "nsc.h"
-#include "item.h"
-#include "file.h"
+#include <config.h>
+
 #include "commands.h"
+#include "lost.h"
+#include "news.h"
 #include "optlist.h"
 
 
@@ -55,15 +47,15 @@ int
 setsector(void)
 {
     struct sctstr sect;
-    s_char *what;
+    char *what;
     int amt, current;
-    s_char *p;
+    char *p;
     struct nstr_sect nstr;
-    s_char buf[1024];
-    s_char char0, char1;
+    char buf[1024];
+    char char0, char1;
 
     if ((what = getstarg(player->argp[1],
-                        "Give What (iron, gold, oil, uranium, fertility, owner, eff., Mob., Work, Avail., oldown, mines)? ",
+                        "Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
                         buf)) == 0)
        return RET_SYN;
     char0 = what[0];
@@ -87,7 +79,7 @@ setsector(void)
            if (sect.sct_own != 0)
                resnoise(&sect, 1, "Iron ore content",
                         (int)sect.sct_min, current);
-           sect.sct_min = (u_char)current;
+           sect.sct_min = (unsigned char)current;
            putsect(&sect);
        }
        break;
@@ -108,7 +100,7 @@ setsector(void)
            if (sect.sct_own != 0)
                resnoise(&sect, 1, "Gold content",
                         (int)sect.sct_gmin, current);
-           sect.sct_gmin = (u_char)current;
+           sect.sct_gmin = (unsigned char)current;
            putsect(&sect);
        }
        break;
@@ -131,7 +123,7 @@ setsector(void)
                if (sect.sct_own != 0)
                    resnoise(&sect, 1, "Oil content",
                             (int)sect.sct_oil, current);
-               sect.sct_oil = (u_char)current;
+               sect.sct_oil = (unsigned char)current;
                putsect(&sect);
            }
            break;
@@ -157,10 +149,6 @@ setsector(void)
                    wu(player->cnum, amt,
                       "Sector %s gained from deity intervention\n",
                       xyas(sect.sct_x, sect.sct_y, amt));
-               makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x,
-                        sect.sct_y);
-               makenotlost(EF_SECTOR, amt, 0, sect.sct_x, sect.sct_y);
-
                sect.sct_own = (natid)amt;
                putsect(&sect);
            }
@@ -204,7 +192,7 @@ setsector(void)
                current = 100;
            pr("Efficiency in %s changed to %d.\n",
               xyas(sect.sct_x, sect.sct_y, player->cnum), current);
-           sect.sct_effic = (u_char)current;
+           sect.sct_effic = (unsigned char)current;
            putsect(&sect);
        }
        break;
@@ -214,20 +202,19 @@ setsector(void)
            if (!snxtsct(&nstr, player->argp[2]))
                return RET_SYN;
            while (nxtsct(&nstr, &sect) > 0) {
-               int mines;
-
                if (!(p = getstarg(player->argp[3], "What value : ", buf))
                    || (*p == '\0'))
                    return RET_SYN;
                amt = atoi(p);
-               mines = getvar(V_MINE, (s_char *)&sect, EF_SECTOR);
-               current = mines;
+               current = sect.sct_mines;
                current += amt;
                if (current < 0)
                    current = 0;
+               if (current > MINES_MAX)
+                   current = MINES_MAX;
                if (sect.sct_own != 0)
-                   resnoise(&sect, 1, "Mines", (int)mines, current);
-               putvar(V_MINE, current, (s_char *)&sect, EF_SECTOR);
+                   resnoise(&sect, 1, "Mines", sect.sct_mines, current);
+               sect.sct_mines = current;
                putsect(&sect);
            }
            break;
@@ -292,7 +279,7 @@ setsector(void)
                current = 100;
            pr("Work in %s changed to %d.\n",
               xyas(sect.sct_x, sect.sct_y, player->cnum), current);
-           sect.sct_work = (u_char)current;
+           sect.sct_work = (unsigned char)current;
            putsect(&sect);
        }
        break;
@@ -308,12 +295,12 @@ setsector(void)
            current += amt;
            if (current < 0)
                current = 0;
-           if (current > 120)
-               current = 120;
+           if (current > 100)
+               current = 100;
            if (sect.sct_own != 0)
                resnoise(&sect, 1, "Fertility content",
                         (int)sect.sct_fertil, current);
-           sect.sct_fertil = (u_char)current;
+           sect.sct_fertil = (unsigned char)current;
            putsect(&sect);
        }
        break;
@@ -334,7 +321,7 @@ setsector(void)
            if (sect.sct_own != 0)
                resnoise(&sect, 1, "Uranium content",
                         (int)sect.sct_uran, current);
-           sect.sct_uran = (u_char)current;
+           sect.sct_uran = (unsigned char)current;
            putsect(&sect);
        }
        break;
@@ -360,13 +347,13 @@ resbenefit(natid who, int good)
     }
 }
 
-extern void
-resnoise(struct sctstr *sptr, int public_amt, s_char *name, int old,
+void
+resnoise(struct sctstr *sptr, int public_amt, char *name, int old,
         int new)
 {
-    s_char p[100];
+    char p[100];
 
-    pr("%s of %s changed from %d to %d%%\n",
+    pr("%s of %s changed from %d to %d\n",
        name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
     if (public_amt)
        (void)sprintf(p, "changed from %d to %d", old, new);