Add nil check in fake crate spawn for if crate fails to spawn
authornemo
Sat, 03 Oct 2015 17:02:57 -0400
changeset 11200 f4cf2cdea8e5
parent 11197 283b6e6cf7ea
child 11201 8e0e3b79efa3
Add nil check in fake crate spawn for if crate fails to spawn
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Fri Sep 25 23:31:16 2015 -0400
+++ b/hedgewars/uScript.pas	Sat Oct 03 17:02:57 2015 -0400
@@ -628,7 +628,9 @@
         begin
         gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
         HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4));
-        lua_pushinteger(L, gear^.uid);
+        if gear <> nil then
+             lua_pushinteger(L, gear^.uid)
+        else lua_pushnil(L)
         end
     else
         lua_pushnil(L);