Fix sloppy sanity check for mobility going negative in transport

Assignment to sct_mobil was vulnerable to integer underflow.  Should
not happen, as move_ground() never returns a cost exceeding available
mobility.
This commit is contained in:
Markus Armbruster 2009-12-31 11:27:48 +01:00
parent 2fa5f65257
commit da48ba6d13

View file

@ -134,8 +134,9 @@ tran_nuke(void)
else
pr("No mobility used\n");
getsect(srcx, srcy, &sect);
if (sect.sct_mobil >= mcost)
sect.sct_mobil -= mcost;
if (sect.sct_mobil < 0)
else
sect.sct_mobil = 0;
putsect(&sect);
return RET_OK;
@ -229,8 +230,9 @@ tran_plane(void)
else
pr("No mobility used\n");
getsect(srcx, srcy, &sect);
if (sect.sct_mobil >= mcost)
sect.sct_mobil -= mcost;
if (sect.sct_mobil < 0)
else
sect.sct_mobil = 0;
putsect(&sect);
return RET_OK;