]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/conv.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / commands / conv.c
index 0bedd50537f867f5b00e7ac4de63d12014640c7a..5d5e71afe7b9b404285383e196b60dc07ad91613 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-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -19,9 +19,9 @@
  *
  *  ---
  *
- *  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.
  *
  *  ---
  *
  * format: convert <SECTS> <NUMBER PER SECTOR>
  */
 
+#include <config.h>
+
 #include "misc.h"
 #include "player.h"
-#include "var.h"
 #include "sect.h"
 #include "nat.h"
 #include "xy.h"
@@ -73,9 +74,10 @@ conv(void)
 static long
 do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
 {
+    struct natstr *natp;
     struct sctstr sect;
     int newuw, totaluw, uw;
-    int civ, mil, adj_mob, mob;
+    int maxpop, civ, mil, adj_mob, mob;
     double security_extra = 1.0;
     struct lndstr land;
     struct nstr_item ni;
@@ -87,9 +89,9 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
            continue;
        if (sect.sct_oldown == player->cnum)
            continue;
+        natp = getnatp(sect.sct_own);
+       maxpop = max_pop(natp->nat_level[NAT_RLEV], &sect);
        civ = sect.sct_item[I_CIVIL];
-       if (civ == 0)
-           continue;
        mil = sect.sct_item[I_MILIT];
 
        /*
@@ -98,10 +100,8 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
         * count.
         */
        snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
-       while (nxtitem(&ni, (s_char *)&land)) {
+       while (nxtitem(&ni, &land)) {
            mil += lnd_getmil(&land);
-/*                     mil += (lnd_getmil(&land) *
-                               ((double)land.lnd_effic/100.0));*/
 
            /* Anti-terrorist units count double */
            if (lchr[(int)land.lnd_type].l_flags & L_SECURITY) {
@@ -116,8 +116,6 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
                if (for_real)
                    putland(land.lnd_uid, &land);
                mil += lnd_getmil(&land);
-/*                             mil += (lchr[land.lnd_type].l_mil *
-                                       ((double)land.lnd_effic/100.0));*/
            }
        }
        /*
@@ -129,11 +127,9 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
        if (newuw > uwtoconvert)
            newuw = uwtoconvert;
        uw = sect.sct_item[I_UW];
-       if (uw > 999)
-           continue;
-       if (newuw > 999 - uw)
-           newuw = 999 - uw;
-       if (newuw == 0)
+       if (newuw > maxpop - uw)
+           newuw = maxpop - uw;
+       if (newuw <= 0)
            continue;
        /*
         * So entire civilian populations don't disappear immediately