summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2011-02-08 18:39:29 +0000
committersmatz <smatz@openttd.org>2011-02-08 18:39:29 +0000
commit9cd5243d04f782d7dcf64b935018fe22e6e73dfd (patch)
treef88e9a1d3c769ef93e2cc8524572f0ca130e5197
parent887a7724dc3f68cdd3d0c566c66adf00696e4bc0 (diff)
downloadopenttd-9cd5243d04f782d7dcf64b935018fe22e6e73dfd.tar.xz
(svn r22026) -Fix: don't crash when we generate too many objects while generating map
-rw-r--r--src/object_cmd.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 29163cab3..f39700df2 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -636,7 +636,7 @@ void GenerateObjects()
/* add lighthouses */
uint maxx = MapMaxX();
uint maxy = MapMaxY();
- for (int loop_count = 0; loop_count < 1000 && lighthouses_to_build != 0; loop_count++) {
+ for (int loop_count = 0; loop_count < 1000 && lighthouses_to_build != 0 && Object::CanAllocateItem(); loop_count++) {
uint r = Random();
/* Scatter the lighthouses more evenly around the perimeter */