It was only used to see whether a path to the dist center exists. Use
negative cost for that.
/* deliver.c */
extern void dodeliver(struct sctstr *);
/* distribute.c */
/* deliver.c */
extern void dodeliver(struct sctstr *);
/* distribute.c */
-extern int dodistribute(struct sctstr *, int, char *, double, double);
+extern int dodistribute(struct sctstr *, int, double, double);
/* finish.c */
extern void finish_sects(int);
/* human.c */
/* finish.c */
extern void finish_sects(int);
/* human.c */
#define IMPORT_BONUS 10.0
int
#define IMPORT_BONUS 10.0
int
-dodistribute(struct sctstr *sp, int imex, char *path, double dist_i_cost,
- double dist_e_cost)
- /* import or export? */
+dodistribute(struct sctstr *sp, int imex,
+ double dist_i_cost, double dist_e_cost)
{
struct ichrstr *ip;
struct sctstr *dist;
{
struct ichrstr *ip;
struct sctstr *dist;
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 (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",
/* Used for building up distribution info */
struct distinfo {
/* Used for building up distribution info */
struct distinfo {
- char *path; /* path to take */
double imcost; /* import cost */
double excost; /* export cost */
};
double imcost; /* import cost */
double excost; /* export cost */
};
* of course :) ) We do clear it each and every time. */
static struct distinfo *g_distptrs;
* of course :) ) We do clear it each and every time. */
static struct distinfo *g_distptrs;
-static char *finish_path = "h"; /* Placeholder indicating path exists */
-
static void assemble_dist_paths(struct distinfo *distptrs);
static char *ReversePath(char *path);
static void assemble_dist_paths(struct distinfo *distptrs);
static char *ReversePath(char *path);
continue;
/* Get the pointer */
infptr = &g_distptrs[sp->sct_uid];
continue;
/* Get the pointer */
infptr = &g_distptrs[sp->sct_uid];
- dodistribute(sp, EXPORT,
- infptr->path, infptr->imcost, infptr->excost);
+ dodistribute(sp, EXPORT, infptr->imcost, infptr->excost);
}
logerror("done exporting\n");
}
logerror("done exporting\n");
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->path, infptr->imcost, infptr->excost);
+ dodistribute(sp, IMPORT, infptr->imcost, infptr->excost);
sp->sct_off = 0;
}
logerror("done importing\n");
sp->sct_off = 0;
}
logerror("done importing\n");
path = BestDistPath(buf, dist, sp, &d);
/* Now, we have a path */
path = BestDistPath(buf, dist, sp, &d);
/* Now, we have a path */
+ if (!path)
+ infptr->imcost = infptr->excost = -1.0;
+ else {
/* Save the import cost */
infptr->imcost = d;
/* Now, reverse the path */
/* Save the import cost */
infptr->imcost = d;
/* Now, reverse the path */
/* And walk the path back to the dist center to get the export
cost */
infptr->excost = pathcost(sp, p, MOB_MOVE);
/* And walk the path back to the dist center to get the export
cost */
infptr->excost = pathcost(sp, p, MOB_MOVE);
- infptr->path = finish_path;