# HG changeset patch # User Wuzzy # Date 1560559851 -7200 # Node ID af14c418c92f8c80a196df312da6299bf0a0eb99 # Parent 53342ce3f0a605da43879a6661b64db0906bb989 Drawn maps: Erase land outside of land bounds diff -r 53342ce3f0a6 -r af14c418c92f hedgewars/uLand.pas --- a/hedgewars/uLand.pas Sat Jun 15 01:18:40 2019 +0200 +++ b/hedgewars/uLand.pas Sat Jun 15 02:50:51 2019 +0200 @@ -298,15 +298,16 @@ if GameType = gmtLandPreview then cFeatureSize:= 3; - ResizeLand((4096 * max(min(cFeatureSize,24),3)) div 12, (2048 * max(min(cFeatureSize,24),3)) div 12); - uLandPainted.Draw; + playWidth:= (4096 * max(min(cFeatureSize,24),3)) div 12; + playHeight:= (2048 * max(min(cFeatureSize,24),3)) div 12; + ResizeLand(playWidth, playHeight); hasGirders:= true; - playHeight:= LAND_HEIGHT; - playWidth:= LAND_WIDTH; leftX:= ((LAND_WIDTH - playWidth) div 2); rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; topY:= LAND_HEIGHT - playHeight; + + uLandPainted.Draw; end; function SelectTemplate: LongInt; diff -r 53342ce3f0a6 -r af14c418c92f hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Sat Jun 15 01:18:40 2019 +0200 +++ b/hedgewars/uLandGraphics.pas Sat Jun 15 02:50:51 2019 +0200 @@ -51,6 +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 EraseLandRectRaw(X, Y, width, height: LongWord); 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; @@ -840,6 +841,17 @@ end; +procedure EraseLandRectRaw(X, Y, width, height: LongWord); +var tx, ty: LongWord; +begin +for ty:= 0 to height - 1 do + for tx:= 0 to width - 1 do + begin + LandPixels[ty, tx]:= 0; + Land[Y + ty, X + tx]:= 0; + end; +end; + 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; diff -r 53342ce3f0a6 -r af14c418c92f hedgewars/uLandPainted.pas --- a/hedgewars/uLandPainted.pas Sat Jun 15 01:18:40 2019 +0200 +++ b/hedgewars/uLandPainted.pas Sat Jun 15 02:50:51 2019 +0200 @@ -129,6 +129,13 @@ prevPoint:= pe^.point; pe:= pe^.next; end; + + if (topY > 0) then + EraseLandRectRaw(0, 0, LAND_WIDTH, topY - 1); + if (leftX > 0) then + EraseLandRectRaw(0, topY, leftX - 1, LAND_HEIGHT - topY); + if (rightX < (LAND_WIDTH - 1)) then + EraseLandRectRaw(rightX + 1, topY, LAND_WIDTH - (rightX + 1), LAND_HEIGHT - topY); end; procedure initModule;