(move, explore): Return early when interdiction destroys everything

moved.  Without that, loyalty computation divided by zero and crashed
when moving civilians to a sector without civilians.  Found and
debugged by Jeff Cotter.  Closes #1005005.
This commit is contained in:
Markus Armbruster 2004-08-13 10:05:32 +00:00
parent 9549adefdc
commit 73308d9c57
2 changed files with 13 additions and 0 deletions

View file

@ -192,6 +192,12 @@ explore(void)
* Check for a multitude of problems
*/
getsect(endsect.sct_x, endsect.sct_y, &chksect);
if (amount <= 0) {
getsect(start.sct_x, start.sct_y, &start);
sect.sct_flags &= ~MOVE_IN_PROGRESS;
putsect(&sect);
return RET_FAIL;
}
if (chksect.sct_type == '.') {
pr("Bridge disappeared!\n");
getsect(start.sct_x, start.sct_y, &start);

View file

@ -269,6 +269,13 @@ move(void)
pr("%d mob left in %s\n", left,
xyas(start.sct_x, start.sct_y, player->cnum));
if (amount <= 0) {
getsect(x, y, &start);
start.sct_flags &= ~MOVE_IN_PROGRESS;
putsect(&start);
return RET_OK;
}
/* If the sector that things are going to is no longer
owned by the player, and was the starting sector,
try to find somewhere to dump the stuff. If nowhere