merge
authornemo
Thu, 08 Nov 2012 15:57:01 -0500
changeset 8014 851f65004c33
parent 8012 2a61631a4505 (diff)
parent 8013 5cbf6e4361f4 (current diff)
child 8015 e7869e70db35
merge
--- a/hedgewars/uScript.pas	Thu Nov 08 17:18:49 2012 +0400
+++ b/hedgewars/uScript.pas	Thu Nov 08 15:57:01 2012 -0500
@@ -1727,36 +1727,29 @@
     else
         begin
         gear:= GearByUID(lua_tointeger(L, 1));
-        hiddenHedgehogs[hiddenHedgehogsNumber]:=gear^.hedgehog;
-        inc(hiddenHedgehogsNumber);
-        HideHog(gear^.hedgehog);
+        HideHog(gear^.hedgehog)
         end;
     lc_hidehog := 0;
 end;
 
 function lc_restorehog(L: Plua_State): LongInt; Cdecl;
 var hog: PHedgehog;
-    i, j: LongInt;
+    i, h: LongInt;
+    uid: LongWord;
 begin
     if lua_gettop(L) <> 1 then
         LuaError('Lua: Wrong number of parameters passed to RestoreHog!')
     else
         begin
-          i := 0;
-          while (i < hiddenHedgehogsNumber) do
-            begin
-            if hiddenHedgehogs[i]^.gearHidden^.uid = LongWord(lua_tointeger(L, 1)) then
-              begin
-                hog := hiddenHedgehogs[i];
-                RestoreHog(hog);
-                dec(hiddenHedgehogsNumber);
-                for j := i to hiddenHedgehogsNumber - 1 do
-                  hiddenHedgehogs[j] := hiddenHedgehogs[j + 1];
-                lc_restorehog := 0;
-                exit;
-              end;
-            inc(i);
-            end;
+        uid:= LongWord(lua_tointeger(L, 1));
+        if TeamsCount > 0 then
+            for i:= 0 to Pred(TeamsCount) do
+                for h:= 0 to cMaxHHIndex do
+                    if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then
+                        begin
+                        RestoreHog(@TeamsArray[i]^.Hedgehogs[h]);
+                        exit(0)
+                        end
         end;
     lc_restorehog := 0;
 end;
--- a/hedgewars/uVariables.pas	Thu Nov 08 17:18:49 2012 +0400
+++ b/hedgewars/uVariables.pas	Thu Nov 08 15:57:01 2012 -0500
@@ -196,8 +196,6 @@
     hiTicks: Word;
 
     LuaGoals        : shortstring;
-    hiddenHedgehogs : array [0..cMaxHHs] of PHedgehog;
-    hiddenHedgehogsNumber : longint;
 
     LuaTemplateNumber : LongWord;
 
@@ -2743,7 +2741,6 @@
     cMapName:= '';
 
     LuaTemplateNumber:= 0;
-    hiddenHedgehogsNumber:=0;
 end;
 
 procedure freeModule;