fix TryPlaceOnLand's ambiguity/messup wrt to making terrain indestructible (had boolean parameter for indestructible AND landflags parameters that could contain lfIndestructibly)
authorsheepluva
Thu, 12 Jun 2014 15:17:53 +0200
changeset 10286 1940e937fc08
parent 10285 03b615d3c6e1
child 10287 e17fe8572478
fix TryPlaceOnLand's ambiguity/messup wrt to making terrain indestructible (had boolean parameter for indestructible AND landflags parameters that could contain lfIndestructibly)
hedgewars/uGearsHandlersMess.pas
hedgewars/uLandGraphics.pas
hedgewars/uScript.pas
--- a/hedgewars/uGearsHandlersMess.pas	Thu Jun 12 14:42:48 2014 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Jun 12 15:17:53 2014 +0200
@@ -2524,7 +2524,7 @@
             (Distance(tx - int2hwFloat(leftX-(rightX-rx)), ty - y) > _256)
             )));
     if distFail
-    or (not TryPlaceOnLand(Gear^.Target.X - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Width div 2, Gear^.Target.Y - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Height div 2, Ammoz[Gear^.AmmoType].PosSprite, Gear^.State, true, false, LandFlags)) then
+    or (not TryPlaceOnLand(Gear^.Target.X - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Width div 2, Gear^.Target.Y - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Height div 2, Ammoz[Gear^.AmmoType].PosSprite, Gear^.State, true, LandFlags)) then
         begin
         PlaySound(sndDenied);
         if not distFail then
@@ -2594,7 +2594,7 @@
     HHGear := Gear^.Hedgehog^.Gear;
     if not TryPlaceOnLand(Gear^.Target.X - SpritesData[sprHHTelepMask].Width div 2,
         Gear^.Target.Y - SpritesData[sprHHTelepMask].Height div 2,
-        sprHHTelepMask, 0, false, false, not hasBorder, 0) then
+        sprHHTelepMask, 0, false, not hasBorder, 0) then
         begin
         HHGear^.Message := HHGear^.Message and (not gmAttack);
         HHGear^.State := HHGear^.State and (not gstAttacking);
--- a/hedgewars/uLandGraphics.pas	Thu Jun 12 14:42:48 2014 +0200
+++ b/hedgewars/uLandGraphics.pas	Thu Jun 12 15:17:53 2014 +0200
@@ -48,8 +48,8 @@
 procedure DumpLandToLog(x, y, r: LongInt);
 procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint);
 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline;
-function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean; LandFlags: Word): boolean;
-function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible, outOfMap: boolean; LandFlags: Word): boolean;
+function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean;
+function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap: boolean; LandFlags: Word): boolean;
 function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture;
 
 implementation
@@ -607,23 +607,32 @@
 end;
 
 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline;
+var lf: LongWord;
 begin
-TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, indestructible, false, 0);
+if indestructible then
+    lf:= lfIndestructible
+else
+    lf:= 0;
+TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, lf);
 end;
 
-function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean; LandFlags: Word): boolean;
+function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean;
 begin
-TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, indestructible, false, LandFlags);
+TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, LandFlags);
 end;
 
-function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible, outOfMap: boolean; LandFlags: Word): boolean;
+function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap: boolean; LandFlags: Word): boolean;
 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt;
     p: PByteArray;
     Image: PSDL_Surface;
+    indestructible: boolean;
 begin
 TryPlaceOnLand:= false;
 numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
 
+// make land indestructible if lfIndestructible is passed
+indestructible:= (LandFlags and lfIndestructible <> 0);
+
 if outOfMap then doPlace:= false; // just using for a check
 
 TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true);
--- a/hedgewars/uScript.pas	Thu Jun 12 14:42:48 2014 +0200
+++ b/hedgewars/uScript.pas	Thu Jun 12 15:17:53 2014 +0200
@@ -2046,7 +2046,7 @@
                 placed:= TryPlaceOnLand(
                     lua_tointeger(L, 1) - SpritesData[spr].Width div 2,
                     lua_tointeger(L, 2) - SpritesData[spr].Height div 2,
-                    spr, lua_tointeger(L, 4), true, false, lf);
+                    spr, lua_tointeger(L, 4), true, lf);
             end;
         end;