# HG changeset patch # User unc0rr # Date 1406306512 -14400 # Node ID 7ebb71a36e9563294192dec9ccf4d07cfeef5c83 # Parent 6e1bfa70ccb3a9460b198789fa7eeb7d9edd97c0 Forced sprites placing mode, exposed to scripts (not tested at all) diff -r 6e1bfa70ccb3 -r 7ebb71a36e95 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Fri Jul 25 14:16:33 2014 +0400 +++ b/hedgewars/uGearsHandlersMess.pas Fri Jul 25 20:41:52 2014 +0400 @@ -2618,7 +2618,7 @@ for y:= ty downto ty - ytol do begin - if TryPlaceOnLand(lx, y, sprHHTelepMask, 0, false, not hasBorder, 0) then + if TryPlaceOnLand(lx, y, sprHHTelepMask, 0, false, not hasBorder, false, 0) then begin valid:= true; break; diff -r 6e1bfa70ccb3 -r 7ebb71a36e95 hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Fri Jul 25 14:16:33 2014 +0400 +++ b/hedgewars/uLandGraphics.pas Fri Jul 25 20:41:52 2014 +0400 @@ -49,7 +49,8 @@ procedure DrawIceBreak(x, y, iceRadius, iceHeight: Longint); function TryPlaceOnLandSimple(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, indestructible: boolean): boolean; inline; function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline; -function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap: boolean; LandFlags: Word): boolean; +function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word): boolean; inline; +function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force: boolean; LandFlags: Word): boolean; function GetPlaceCollisionTex(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): PTexture; implementation @@ -613,15 +614,20 @@ lf:= lfIndestructible else lf:= 0; -TryPlaceOnLandSimple:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, lf); +TryPlaceOnLandSimple:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, false, lf); end; function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; LandFlags: Word): boolean; inline; begin -TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, LandFlags); +TryPlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, doPlace, false, false, LandFlags); end; -function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap: boolean; LandFlags: Word): boolean; +function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word): boolean; inline; +begin + ForcePlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, true, true, true, LandFlags) +end; + +function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force: boolean; LandFlags: Word): boolean; var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt; p: PByteArray; Image: PSDL_Surface; @@ -655,14 +661,14 @@ for x:= 0 to Pred(w) do if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then if (outOfMap and - ((cpY + y) < LAND_HEIGHT) and ((cpY + y) >= 0) and - ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and - (Land[cpY + y, cpX + x] <> 0)) or + ((cpY + y) < LAND_HEIGHT) and ((cpY + y) >= 0) and + ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and + ((not force) or (Land[cpY + y, cpX + x] <> 0))) or (not outOfMap and (((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or - (Land[cpY + y, cpX + x] <> 0))) then + ((not force) or (Land[cpY + y, cpX + x] <> 0)))) then begin if SDL_MustLock(Image) then SDL_UnlockSurface(Image); diff -r 6e1bfa70ccb3 -r 7ebb71a36e95 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Fri Jul 25 14:16:33 2014 +0400 +++ b/hedgewars/uScript.pas Fri Jul 25 20:41:52 2014 +0400 @@ -2001,10 +2001,10 @@ if SpritesData[spr].Surface = nil then LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) else - placed:= TryPlaceOnLand( + placed:= ForcePlaceOnLand( lua_tointeger(L, 1) - SpritesData[spr].Width div 2, lua_tointeger(L, 2) - SpritesData[spr].Height div 2, - spr, lua_tointeger(L, 4), true, lf); + spr, lua_tointeger(L, 4), lf); end; end;