]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/distribute.c
Update copyright notice
[empserver] / src / lib / update / distribute.c
index f9b267747aed466e2fa255d902024489dc6a6e3c..56e955be1c9d27da3598975f4c0785dc696383a5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@
  *  ---
  *
  *  distribute.c: Do distribution to sectors
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1986
  *     Steve McClure, 1998
@@ -55,7 +55,7 @@ dodistribute(struct sctstr *sp, int imex, char *path, double dist_i_cost,
     int thresh;
     int amt_dist;
     int amt_sect;
-    i_packing sect_packing, dist_packing;
+    enum i_packing sect_packing, dist_packing;
     int pack;
     double mcost;
     int diff;
@@ -115,13 +115,13 @@ dodistribute(struct sctstr *sp, int imex, char *path, double dist_i_cost,
             * check to make sure have enough mobility in the
             * dist sector to import what we need.
             */
-           if (dist->sct_mobil <= 0) {
-               /*logerror("  dist mobil < 0"); */
+           if (dist->sct_mobil <= 0)
                continue;
-           }
            amt = diff;
-           if (item == I_CIVIL)
-               amt_dist--;     /* Don't send your last civ */
+           /* make sure not to abandon the sector */
+           if (item == I_CIVIL ||
+               (item == I_MILIT && dist->sct_item[I_CIVIL] == 0))
+               amt_dist--;
 
            if (amt_dist < amt) {
                amt = amt_dist;
@@ -154,10 +154,8 @@ dodistribute(struct sctstr *sp, int imex, char *path, double dist_i_cost,
             * also make sure that there's enough space in the
             * target sector to hold the required amt.
             */
-           if (sp->sct_mobil <= 0) {
-               /*logerror("  sp mob is zero"); */
+           if (sp->sct_mobil <= 0)
                continue;
-           }
            amt = diff;
            if (amt > amt_sect)
                amt = amt_sect;