]> git.pond.sub.org Git - empserver/commitdiff
Merge dodistribute() parameters dist_i_cost, dist_e_cost
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 18 Feb 2011 18:07:31 +0000 (19:07 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 11 Apr 2011 20:29:12 +0000 (22:29 +0200)
Only one of them is used, depending on argument imex.  Replace them by
a single parameter path_cost.

include/prototypes.h
src/lib/update/distribute.c
src/lib/update/finish.c

index 3c0748b558f0bb8a2e917e65547bd8fa461ac10b..d7e62b80f81aaaf603b8b5d7bb8d0e81341dac2f 100644 (file)
@@ -694,7 +694,7 @@ extern void delete_old_announcements(void);
 /* deliver.c */
 extern void dodeliver(struct sctstr *);
 /* distribute.c */
 /* deliver.c */
 extern void dodeliver(struct sctstr *);
 /* distribute.c */
-extern int dodistribute(struct sctstr *, int, double, double);
+extern int dodistribute(struct sctstr *, int, double);
 /* finish.c */
 extern void finish_sects(int);
 /* human.c */
 /* finish.c */
 extern void finish_sects(int);
 /* human.c */
index 7f86179e71d319bce58e146e7c7563b1dbcccba9..ddc88bdd5a1b3efffb8145e84979e77d97936b05 100644 (file)
@@ -51,8 +51,7 @@
 #define IMPORT_BONUS 10.0
 
 int
 #define IMPORT_BONUS 10.0
 
 int
-dodistribute(struct sctstr *sp, int imex,
-            double dist_i_cost, double dist_e_cost)
+dodistribute(struct sctstr *sp, int imex, double path_cost)
 {
     struct ichrstr *ip;
     struct sctstr *dist;
 {
     struct ichrstr *ip;
     struct sctstr *dist;
@@ -72,7 +71,7 @@ dodistribute(struct sctstr *sp, int imex,
     if ((sp->sct_dist_x == sp->sct_x) && (sp->sct_dist_y == sp->sct_y))
        return 0;
 
     if ((sp->sct_dist_x == sp->sct_x) && (sp->sct_dist_y == sp->sct_y))
        return 0;
 
-    if (dist_e_cost < 0.0) {
+    if (path_cost < 0.0) {
        if (sp->sct_own != 0) {
            if (imex == EXPORT) /* only want this once */
                wu(0, sp->sct_own, "No path to dist sector for %s\n",
        if (sp->sct_own != 0) {
            if (imex == EXPORT) /* only want this once */
                wu(0, sp->sct_own, "No path to dist sector for %s\n",
@@ -87,7 +86,7 @@ dodistribute(struct sctstr *sp, int imex,
 
     DPRINTF("distribute: %d,%d to %d,%d pathcost %g\n",
            sp->sct_x, sp->sct_y, sp->sct_dist_x, sp->sct_dist_y,
 
     DPRINTF("distribute: %d,%d to %d,%d pathcost %g\n",
            sp->sct_x, sp->sct_y, sp->sct_dist_x, sp->sct_dist_y,
-           imex == IMPORT ? dist_i_cost : dist_e_cost);
+           path_cost);
 
     lplague = rplague = changed = 0;
     for (item = I_NONE + 1; item <= I_MAX; item++) {
 
     lplague = rplague = changed = 0;
     for (item = I_NONE + 1; item <= I_MAX; item++) {
@@ -138,7 +137,7 @@ dodistribute(struct sctstr *sp, int imex,
                    continue;
            }
            pack = ip->i_pkg[dist_packing];
                    continue;
            }
            pack = ip->i_pkg[dist_packing];
-           mcost = dist_i_cost / pack * ip->i_lbs / IMPORT_BONUS;
+           mcost = path_cost / pack * ip->i_lbs / IMPORT_BONUS;
            if (dist->sct_mobil < mcost * amt)
                amt = dist->sct_mobil / mcost;
 
            if (dist->sct_mobil < mcost * amt)
                amt = dist->sct_mobil / mcost;
 
@@ -169,7 +168,7 @@ dodistribute(struct sctstr *sp, int imex,
            if (amt > amt_sect)
                amt = amt_sect;
            pack = MAX(ip->i_pkg[sect_packing], ip->i_pkg[dist_packing]);
            if (amt > amt_sect)
                amt = amt_sect;
            pack = MAX(ip->i_pkg[sect_packing], ip->i_pkg[dist_packing]);
-           mcost = dist_e_cost / pack * ip->i_lbs / EXPORT_BONUS;
+           mcost = path_cost / pack * ip->i_lbs / EXPORT_BONUS;
            if (sp->sct_mobil < mcost * amt)
                amt = sp->sct_mobil / mcost;
            if (amt > ITEM_MAX - amt_dist)
            if (sp->sct_mobil < mcost * amt)
                amt = sp->sct_mobil / mcost;
            if (amt > ITEM_MAX - amt_dist)
index 43e035557f40008ec7eddf9bd2ec6d28675e5474..1544f45da24c4361f311bb49dca31e6b39370ed7 100644 (file)
@@ -122,7 +122,7 @@ finish_sects(int etu)
            continue;
        /* Get the pointer */
        infptr = &g_distptrs[sp->sct_uid];
            continue;
        /* Get the pointer */
        infptr = &g_distptrs[sp->sct_uid];
-       dodistribute(sp, EXPORT, infptr->imcost, infptr->excost);
+       dodistribute(sp, EXPORT, infptr->excost);
     }
     logerror("done exporting\n");
 
     }
     logerror("done exporting\n");
 
@@ -135,7 +135,7 @@ finish_sects(int etu)
        np = getnatp(sp->sct_own);
        if (np->nat_money < 0)
            continue;
        np = getnatp(sp->sct_own);
        if (np->nat_money < 0)
            continue;
-       dodistribute(sp, IMPORT, infptr->imcost, infptr->excost);
+       dodistribute(sp, IMPORT, infptr->imcost);
        sp->sct_off = 0;
     }
     logerror("done importing\n");
        sp->sct_off = 0;
     }
     logerror("done importing\n");