# HG changeset patch # User nemo # Date 1428676577 14400 # Node ID c9a0cdee42679f9317ad2e1ea41bdf6bc7ab0521 # Parent fbf6fbe66092274db36ace08483379a132ff5300 tweak erase diff -r fbf6fbe66092 -r c9a0cdee4267 hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Wed Apr 08 23:59:35 2015 -0400 +++ b/hedgewars/uLandGraphics.pas Fri Apr 10 10:36:17 2015 -0400 @@ -51,7 +51,7 @@ function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline; function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; Tint: LongWord; Behind, flipHoriz, flipVert: boolean): boolean; inline; function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force, behind, flipHoriz, flipVert: boolean; LandFlags: Word; Tint: LongWord): boolean; -procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, flipHoriz, flipVert: boolean); +procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert: boolean); function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture; implementation @@ -816,11 +816,10 @@ end; -procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, flipHoriz, flipVert: boolean); +procedure EraseLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert: boolean); var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt; p: PByteArray; Image: PSDL_Surface; - pixel: LongWord; begin numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height; @@ -878,8 +877,12 @@ if (not eraseOnLFMatch or (Land[cpY + y, cpX + x] and LandFlags <> 0)) and (PLongword(@(p^[x * 4]))^ and AMask <> 0) then begin - LandPixels[gY, gX]:= 0; - Land[cpY + y, cpX + x]:= 0 + if not onlyEraseLF then + begin + LandPixels[gY, gX]:= 0; + Land[cpY + y, cpX + x]:= 0 + end + else Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] and not LandFlags end end; p:= PByteArray(@(p^[Image^.pitch])); diff -r fbf6fbe66092 -r c9a0cdee4267 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Wed Apr 08 23:59:35 2015 -0400 +++ b/hedgewars/uScript.pas Fri Apr 10 10:36:17 2015 -0400 @@ -2252,7 +2252,7 @@ var spr : TSprite; lf : Word; i, n : LongInt; - eraseOnLFMatch, flipHoriz, flipVert : boolean; + eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert : boolean; const call = 'EraseSprite'; params = 'x, y, sprite, frameIdx, eraseOnLFMatch, flipHoriz, flipVert, [, landFlag, ... ]'; @@ -2263,15 +2263,18 @@ eraseOnLFMatch := lua_toboolean(L, 5) else eraseOnLFMatch := false; if not lua_isnoneornil(L, 6) then - flipHoriz := lua_toboolean(L, 6) + onlyEraseLF := lua_toboolean(L, 6) + else onlyEraseLF := false; + if not lua_isnoneornil(L, 7) then + flipHoriz := lua_toboolean(L, 7) else flipHoriz := false; - if not lua_isnoneornil(L, 7) then - flipVert := lua_toboolean(L, 7) + if not lua_isnoneornil(L, 8) then + flipVert := lua_toboolean(L, 8) else flipVert := false; lf:= 0; // accept any amount of landflags, loop is never executed if n>6 - for i:= 8 to n do + for i:= 9 to n do lf:= lf or lua_tointeger(L, i); n:= LuaToSpriteOrd(L, 3, call, params); @@ -2284,7 +2287,7 @@ EraseLand( lua_tointeger(L, 1) - SpritesData[spr].Width div 2, lua_tointeger(L, 2) - SpritesData[spr].Height div 2, - spr, lua_tointeger(L, 4), lf, eraseOnLFMatch, flipHoriz, flipVert); + spr, lua_tointeger(L, 4), lf, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert); end; end; lc_erasesprite:= 0