forbid hiding already hidden hogs 1.0.0
authornemo
Fri, 20 Jan 2023 21:39:53 -0500
branch1.0.0
changeset 15907 1becf4a0e907
parent 15885 ed84eb580643
child 15908 4c0f8dbf6c13
child 15992 524b0abb5b4c
forbid hiding already hidden hogs
hedgewars/uGearsHandlersMess.pas
hedgewars/uScript.pas
--- a/hedgewars/uGearsHandlersMess.pas	Mon Oct 24 10:06:52 2022 -0400
+++ b/hedgewars/uGearsHandlersMess.pas	Fri Jan 20 21:39:53 2023 -0500
@@ -262,6 +262,7 @@
 
 procedure HideHog(HH: PHedgehog);
 begin
+    if HH^.Gear = nil then exit;
     ScriptCall('onHogHide', HH^.Gear^.Uid);
     DeleteCI(HH^.Gear);
     if FollowGear = HH^.Gear then
--- a/hedgewars/uScript.pas	Mon Oct 24 10:06:52 2022 -0400
+++ b/hedgewars/uScript.pas	Fri Jan 20 21:39:53 2023 -0500
@@ -3225,7 +3225,7 @@
     if CheckLuaParamCount(L, 1, 'HideHog', 'gearUid') then
         begin
         gear:= GearByUID(Trunc(lua_tonumber(L, 1)));
-        if (gear <> nil) and (gear^.hedgehog <> nil) then
+        if (gear <> nil) and (gear^.hedgehog <> nil) and (gear^.hedgehog^.gear <> nil) then
             begin
             HideHog(gear^.hedgehog);
             lua_pushboolean(L, true);