update collision in set gear position
authornemo
Mon, 10 Jan 2011 19:15:12 -0500
changeset 4832 e55e2b6f59b0
parent 4831 57b46b5dbfff
child 4833 204d26924532
update collision in set gear position
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Mon Jan 10 18:20:58 2011 +0300
+++ b/hedgewars/uScript.pas	Mon Jan 10 19:15:12 2011 -0500
@@ -57,7 +57,8 @@
     uUtils,
     uKeys,
     uCaptions,
-    uDebug;
+    uDebug,
+    uCollisions;
 
 var luaState : Plua_State;
     ScriptAmmoLoadout : shortstring;
@@ -972,6 +973,7 @@
 
 function lc_setgearposition(L : Plua_State) : LongInt; Cdecl;
 var gear: PGear;
+    col: boolean;
     x, y: LongInt;
 begin
     if lua_gettop(L) <> 3 then
@@ -981,11 +983,14 @@
         gear:= GearByUID(lua_tointeger(L, 1));
         if gear <> nil then
             begin
+            col:= gear^.CollisionIndex >= 0;
             x:= lua_tointeger(L, 2);
             y:= lua_tointeger(L, 3);
+            if col then DeleteCI(gear);
             gear^.X:= int2hwfloat(x);
             gear^.Y:= int2hwfloat(y);
-            SetAllToActive;
+            if col then AddGearCI(gear);
+            SetAllToActive
             end
         end;
     lc_setgearposition:= 0