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:
parent
2fa5f65257
commit
da48ba6d13
1 changed files with 6 additions and 4 deletions
|
@ -134,8 +134,9 @@ tran_nuke(void)
|
|||
else
|
||||
pr("No mobility used\n");
|
||||
getsect(srcx, srcy, §);
|
||||
sect.sct_mobil -= mcost;
|
||||
if (sect.sct_mobil < 0)
|
||||
if (sect.sct_mobil >= mcost)
|
||||
sect.sct_mobil -= mcost;
|
||||
else
|
||||
sect.sct_mobil = 0;
|
||||
putsect(§);
|
||||
return RET_OK;
|
||||
|
@ -229,8 +230,9 @@ tran_plane(void)
|
|||
else
|
||||
pr("No mobility used\n");
|
||||
getsect(srcx, srcy, §);
|
||||
sect.sct_mobil -= mcost;
|
||||
if (sect.sct_mobil < 0)
|
||||
if (sect.sct_mobil >= mcost)
|
||||
sect.sct_mobil -= mcost;
|
||||
else
|
||||
sect.sct_mobil = 0;
|
||||
putsect(§);
|
||||
return RET_OK;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue