# HG changeset patch # User nemo # Date 1314660525 14400 # Node ID 637fb1e6487bdf2ec1edce6811ddbaff013a42b3 # Parent 944849ec04bf6092d9557362bc10796661aeb769 Check for nil from SpawnCustomCrate diff -r 944849ec04bf -r 637fb1e6487b hedgewars/uScript.pas --- a/hedgewars/uScript.pas Mon Aug 29 23:56:38 2011 +0200 +++ b/hedgewars/uScript.pas Mon Aug 29 19:28:45 2011 -0400 @@ -279,9 +279,9 @@ else begin if lua_gettop(L) = 3 then health:= lua_tointeger(L, 3) else health:= cHealthCaseAmount; - gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), - HealthCrate, health); - lua_pushinteger(L, gear^.uid); + gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health); + if gear <> nil then lua_pushinteger(L, gear^.uid) + else lua_pushnil(L); end; lc_spawnhealthcrate := 1; end; @@ -294,9 +294,9 @@ lua_pushnil(L); end else begin - gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), - AmmoCrate, lua_tointeger(L, 3)); - lua_pushinteger(L, gear^.uid); + gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3)); + if gear <> nil then lua_pushinteger(L, gear^.uid) + else lua_pushnil(L); end; lc_spawnammocrate := 1; end; @@ -311,7 +311,8 @@ else begin gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3)); - lua_pushinteger(L, gear^.uid); + if gear <> nil then lua_pushinteger(L, gear^.uid) + else lua_pushnil(L); end; lc_spawnutilitycrate := 1; end;