Remove dodistribute() parameter path
It was only used to see whether a path to the dist center exists. Use negative cost for that.
This commit is contained in:
parent
99c73f399a
commit
d1bdeb4353
3 changed files with 9 additions and 14 deletions
|
@ -694,7 +694,7 @@ extern void delete_old_announcements(void);
|
||||||
/* deliver.c */
|
/* deliver.c */
|
||||||
extern void dodeliver(struct sctstr *);
|
extern void dodeliver(struct sctstr *);
|
||||||
/* distribute.c */
|
/* distribute.c */
|
||||||
extern int dodistribute(struct sctstr *, int, char *, double, double);
|
extern int dodistribute(struct sctstr *, int, double, double);
|
||||||
/* finish.c */
|
/* finish.c */
|
||||||
extern void finish_sects(int);
|
extern void finish_sects(int);
|
||||||
/* human.c */
|
/* human.c */
|
||||||
|
|
|
@ -51,9 +51,8 @@
|
||||||
#define IMPORT_BONUS 10.0
|
#define IMPORT_BONUS 10.0
|
||||||
|
|
||||||
int
|
int
|
||||||
dodistribute(struct sctstr *sp, int imex, char *path, double dist_i_cost,
|
dodistribute(struct sctstr *sp, int imex,
|
||||||
double dist_e_cost)
|
double dist_i_cost, double dist_e_cost)
|
||||||
/* import or export? */
|
|
||||||
{
|
{
|
||||||
struct ichrstr *ip;
|
struct ichrstr *ip;
|
||||||
struct sctstr *dist;
|
struct sctstr *dist;
|
||||||
|
@ -73,7 +72,7 @@ dodistribute(struct sctstr *sp, int imex, char *path, double dist_i_cost,
|
||||||
if ((sp->sct_dist_x == sp->sct_x) && (sp->sct_dist_y == sp->sct_y))
|
if ((sp->sct_dist_x == sp->sct_x) && (sp->sct_dist_y == sp->sct_y))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!path) {
|
if (dist_e_cost < 0.0) {
|
||||||
if (sp->sct_own != 0) {
|
if (sp->sct_own != 0) {
|
||||||
if (imex == EXPORT) /* only want this once */
|
if (imex == EXPORT) /* only want this once */
|
||||||
wu(0, sp->sct_own, "No path to dist sector for %s\n",
|
wu(0, sp->sct_own, "No path to dist sector for %s\n",
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
|
|
||||||
/* Used for building up distribution info */
|
/* Used for building up distribution info */
|
||||||
struct distinfo {
|
struct distinfo {
|
||||||
char *path; /* path to take */
|
|
||||||
double imcost; /* import cost */
|
double imcost; /* import cost */
|
||||||
double excost; /* export cost */
|
double excost; /* export cost */
|
||||||
};
|
};
|
||||||
|
@ -53,8 +52,6 @@ struct distinfo {
|
||||||
* of course :) ) We do clear it each and every time. */
|
* of course :) ) We do clear it each and every time. */
|
||||||
static struct distinfo *g_distptrs;
|
static struct distinfo *g_distptrs;
|
||||||
|
|
||||||
static char *finish_path = "h"; /* Placeholder indicating path exists */
|
|
||||||
|
|
||||||
static void assemble_dist_paths(struct distinfo *distptrs);
|
static void assemble_dist_paths(struct distinfo *distptrs);
|
||||||
static char *ReversePath(char *path);
|
static char *ReversePath(char *path);
|
||||||
|
|
||||||
|
@ -125,8 +122,7 @@ finish_sects(int etu)
|
||||||
continue;
|
continue;
|
||||||
/* Get the pointer */
|
/* Get the pointer */
|
||||||
infptr = &g_distptrs[sp->sct_uid];
|
infptr = &g_distptrs[sp->sct_uid];
|
||||||
dodistribute(sp, EXPORT,
|
dodistribute(sp, EXPORT, infptr->imcost, infptr->excost);
|
||||||
infptr->path, infptr->imcost, infptr->excost);
|
|
||||||
}
|
}
|
||||||
logerror("done exporting\n");
|
logerror("done exporting\n");
|
||||||
|
|
||||||
|
@ -139,8 +135,7 @@ finish_sects(int etu)
|
||||||
np = getnatp(sp->sct_own);
|
np = getnatp(sp->sct_own);
|
||||||
if (np->nat_money < 0)
|
if (np->nat_money < 0)
|
||||||
continue;
|
continue;
|
||||||
dodistribute(sp, IMPORT,
|
dodistribute(sp, IMPORT, infptr->imcost, infptr->excost);
|
||||||
infptr->path, infptr->imcost, infptr->excost);
|
|
||||||
sp->sct_off = 0;
|
sp->sct_off = 0;
|
||||||
}
|
}
|
||||||
logerror("done importing\n");
|
logerror("done importing\n");
|
||||||
|
@ -177,7 +172,9 @@ assemble_dist_paths(struct distinfo *distptrs)
|
||||||
path = BestDistPath(buf, dist, sp, &d);
|
path = BestDistPath(buf, dist, sp, &d);
|
||||||
|
|
||||||
/* Now, we have a path */
|
/* Now, we have a path */
|
||||||
if (path != NULL) {
|
if (!path)
|
||||||
|
infptr->imcost = infptr->excost = -1.0;
|
||||||
|
else {
|
||||||
/* Save the import cost */
|
/* Save the import cost */
|
||||||
infptr->imcost = d;
|
infptr->imcost = d;
|
||||||
/* Now, reverse the path */
|
/* Now, reverse the path */
|
||||||
|
@ -185,7 +182,6 @@ assemble_dist_paths(struct distinfo *distptrs)
|
||||||
/* And walk the path back to the dist center to get the export
|
/* And walk the path back to the dist center to get the export
|
||||||
cost */
|
cost */
|
||||||
infptr->excost = pathcost(sp, p, MOB_MOVE);
|
infptr->excost = pathcost(sp, p, MOB_MOVE);
|
||||||
infptr->path = finish_path;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue