Fix assemble_dist_paths()'s recovery from invalid dist center
The recovery avoided crashing here, but left the path costs undefined. If they happend to be non-negative, dodistribute() still crashed. Set the costs to -1 to avoid that. While there, oops on invalid distribution center.
This commit is contained in:
parent
08cb463878
commit
f4db4e37b1
1 changed files with 2 additions and 10 deletions
|
@ -62,8 +62,6 @@ finish_sects(int etu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(import_cost, 0, WORLD_SZ() * sizeof(*import_cost));
|
|
||||||
|
|
||||||
logerror("delivering...\n");
|
logerror("delivering...\n");
|
||||||
/* Do deliveries */
|
/* Do deliveries */
|
||||||
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
||||||
|
@ -136,23 +134,17 @@ assemble_dist_paths(double *import_cost)
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
||||||
|
import_cost[n] = -1;
|
||||||
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))
|
||||||
continue;
|
continue;
|
||||||
/* now, get the dist sector */
|
|
||||||
dist = getsectp(sp->sct_dist_x, sp->sct_dist_y);
|
dist = getsectp(sp->sct_dist_x, sp->sct_dist_y);
|
||||||
if (dist == NULL) {
|
if (CANT_HAPPEN(!dist))
|
||||||
logerror("Bad dist sect %d,%d for %d,%d !\n",
|
|
||||||
sp->sct_dist_x, sp->sct_dist_y,
|
|
||||||
sp->sct_x, sp->sct_y);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
/* Now, get the best distribution path over roads */
|
/* Now, get the best distribution path over roads */
|
||||||
/* Note we go from the dist center to the sector. This gives
|
/* Note we go from the dist center to the sector. This gives
|
||||||
us the import path for that sector. */
|
us the import path for that sector. */
|
||||||
path = BestDistPath(buf, dist, sp, &d);
|
path = BestDistPath(buf, dist, sp, &d);
|
||||||
if (path)
|
if (path)
|
||||||
import_cost[n] = d;
|
import_cost[n] = d;
|
||||||
else
|
|
||||||
import_cost[n] = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue