avoid overflow on templates
authornemo
Tue, 21 Aug 2012 21:02:52 -0400
changeset 7569 c7d4e035cf9d
parent 7567 da2aa8355d91
child 7571 22a7bfa3e6bb
avoid overflow on templates
hedgewars/uLand.pas
--- a/hedgewars/uLand.pas	Tue Aug 21 19:40:02 2012 -0400
+++ b/hedgewars/uLand.pas	Tue Aug 21 21:02:52 2012 -0400
@@ -285,7 +285,7 @@
         4: SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))];
         5: SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))];
 // For lua only!
-        6: SelectTemplate:= LuaTemplateNumber;
+        6: SelectTemplate:= min(max(LuaTemplateNumber,0),Succ(High(EdgeTemplates)));
     end;
 
     WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));