diff options
author | bjarni <bjarni@openttd.org> | 2006-06-29 09:05:30 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2006-06-29 09:05:30 +0000 |
commit | 979bdc55f153b4d02c641669e35c895ca106a0ce (patch) | |
tree | 791a52c058ca7197f0a27c4297ca1b2d522106b8 | |
parent | 34e18cbdfe191289e79cad4f253b90a110db7057 (diff) | |
download | openttd-979bdc55f153b4d02c641669e35c895ca106a0ce.tar.xz |
(svn r5428) -Fix: [vehicles] sovled crash when trying to build a vehicle type, that is set to max 0 (spotted by roboman)
somebody might add a better string than "too many vehicles in game" since none are allowed, but at least it will not crash anymore
-rw-r--r-- | vehicle.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -2054,6 +2054,14 @@ UnitID GetFreeUnitNumber(byte type) default: NOT_REACHED(); } + if (max == 0) { + /* we can't build any of this kind of vehicle, so we just return 1 instead of looking for a free number + * a max of 0 will cause the following code to write to a NULL pointer + * We know that 1 is bigger than the max allowed vehicle number, so it's the same as returning something, that is too big + */ + return 1; + } + if (max > gmax) { gmax = max; free(cache); |