- Fix camera area with different zoom levels
- Fix memory leak when loading lowres texture
- Implement alternative horizont/sky sprites layout
- Remove deprecated try to load .32.png or .16.png texture
--- a/hedgewars/uConsts.pas Mon Oct 12 13:47:56 2009 +0000
+++ b/hedgewars/uConsts.pas Mon Oct 12 13:49:22 2009 +0000
@@ -45,7 +45,8 @@
sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff,
sprMineOn, sprCase, sprFAid, sprDynamite, sprPower,
sprClusterBomb, sprClusterParticle, sprFlame, sprHorizont,
- sprSky, sprAMBorders, sprAMSlot, sprAMSlotName, sprAMAmmos,
+ sprHorizontL, sprHorizontR, sprSky, sprSkyL,
+ sprSkyR, sprAMBorders, sprAMSlot, sprAMSlotName, sprAMAmmos,
sprAMSlotKeys, sprAMSelection, sprFinger, sprAirBomb,
sprAirplane, sprAmAirplane, sprAmGirder, sprHHTelepMask,
sprSwitch, sprParachute, sprTarget, sprRopeNode,
@@ -100,8 +101,8 @@
amBaseballBat, amParachute, amAirAttack, amMineStrike, amBlowTorch,
amGirder, amTeleport, amSwitch, amMortar, amKamikaze, amCake,
amSeduction, amWatermelon, amHellishBomb, amNapalm, amDrill, amBallgun,
- amRCPlane, amLowGravity, amExtraDamage, amInvulnerable, amExtraTime,
- amLaserSight, amVampiric, amSniperRifle, amJetpack);
+ amRCPlane, amLowGravity, amExtraDamage, amInvulnerable, amExtraTime,
+ amLaserSight, amVampiric, amSniperRifle, amJetpack);
THWFont = (fnt16, fntBig, fntSmall);
@@ -434,8 +435,16 @@
Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFlame
(FileName: 'horizont'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil;
Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHorizont
+ (FileName: 'horizontL'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil;
+ Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHorizont
+ (FileName: 'horizontR'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil;
+ Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHorizont
(FileName: 'Sky'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil;
Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSky
+ (FileName: 'SkyL'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil;
+ Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSky
+ (FileName: 'SkyR'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil;
+ Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSky
(FileName: 'BrdrLines'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil;
Width: 202; Height: 1; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMBorders
(FileName: 'Slot'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil;
--- a/hedgewars/uStore.pas Mon Oct 12 13:47:56 2009 +0000
+++ b/hedgewars/uStore.pas Mon Oct 12 13:49:22 2009 +0000
@@ -279,24 +279,33 @@
for ii:= Low(TSprite) to High(TSprite) do
with SpritesData[ii] do
// FIXME - add a sprite attribute
- if (not cReducedQuality) or ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then
+ if (not cReducedQuality) or (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR, sprFlake])) then // FIXME: hack
begin
if AltPath = ptNone then
- tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes)
+ if ii in [sprHorizontL, sprHorizontR, sprSkyL, sprSkyR] then // FIXME: hack
+ tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifLowRes)
+ else
+ tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes)
else begin
tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
if tmpsurf = nil then
- tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent);
+ tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent);
end;
- if imageWidth = 0 then imageWidth := tmpsurf^.w;
- if imageHeight = 0 then imageHeight := tmpsurf^.h;
- if Width = 0 then Width:= tmpsurf^.w;
- if Height = 0 then Height:= tmpsurf^.h;
- if (ii = sprSky) then
- Texture:= Surface2Tex(tmpsurf, true)
- else
- Texture:= Surface2Tex(tmpsurf, false);
- if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf)
+
+ if tmpsurf <> nil then
+ begin
+ if imageWidth = 0 then imageWidth := tmpsurf^.w;
+ if imageHeight = 0 then imageHeight := tmpsurf^.h;
+ if Width = 0 then Width:= tmpsurf^.w;
+ if Height = 0 then Height:= tmpsurf^.h;
+ if (ii = sprSky) then
+ Texture:= Surface2Tex(tmpsurf, true)
+ else
+ Texture:= Surface2Tex(tmpsurf, false);
+ if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf)
+ end
+ else
+ Surface:= nil
end;
AddProgress;
@@ -907,15 +916,10 @@
{$ENDIF}
begin
WriteToConsole(msgLoading + filename + '... ');
-s:= filename + '.' + cBitsStr + '.png';
+
+s:= filename + '.png';
tmpsurf:= IMG_Load(Str2PChar(s));
-if tmpsurf = nil then
- begin
- s:= filename + '.png';
- tmpsurf:= IMG_Load(Str2PChar(s));
- end;
-
if ((imageFlags and ifLowRes) <> 0) then
begin
s:= filename + '-lowres.png';
@@ -923,6 +927,7 @@
begin
if ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
begin
+ SDL_FreeSurface(tmpsurf);
WriteLnToConsole('Image too big, trying to load lowres version: ' + s);
tmpsurf:= IMG_Load(Str2PChar(s))
end;
--- a/hedgewars/uWorld.pas Mon Oct 12 13:47:56 2009 +0000
+++ b/hedgewars/uWorld.pas Mon Oct 12 13:49:22 2009 +0000
@@ -274,27 +274,51 @@
0)}
end;
+procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift: LongInt);
+var i, w, sw: LongInt;
+begin
+sw:= round(cScreenWidth / cScaleFactor);
+if (SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil) then
+ begin
+ w:= SpritesData[spr].Width;
+ i:= Shift mod w;
+ if i > 0 then dec(i, w);
+ dec(i, w * (sw div w + 1));
+ repeat
+ DrawSprite(spr, i, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0);
+ inc(i, w)
+ until i > sw
+ end else
+ begin
+ w:= SpritesData[spr].Width;
+ dec(Shift, w div 2);
+ DrawSprite(spr, Shift, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0);
+
+ sw:= round(cScreenWidth / cScaleFactor);
+
+ i:= Shift - SpritesData[sprL].Width;
+ while i >= -sw - SpritesData[sprL].Width do
+ begin
+ DrawSprite(sprL, i, WorldDy + LAND_HEIGHT - SpritesData[sprL].Height, 0);
+ dec(i, SpritesData[sprL].Width);
+ end;
+
+ i:= Shift + w;
+ while i <= sw do
+ begin
+ DrawSprite(sprR, i, WorldDy + LAND_HEIGHT - SpritesData[sprR].Height, 0);
+ inc(i, SpritesData[sprR].Width)
+ end
+ end
+end;
+
+
procedure DrawWorld(Lag: LongInt);
var i, t: LongInt;
r: TSDL_Rect;
tdx, tdy: Double;
grp: TCapGroup;
s: string[15];
-
- procedure DrawRepeated(spr: TSprite; Shift: LongInt);
- var i, w, sw: LongInt;
- begin
- sw:= round(cScreenWidth / cScaleFactor);
- w:= SpritesData[spr].Width;
- i:= Shift mod w;
- if i > 0 then dec(i, w);
- dec(i, w * (sw div w + 1));
- repeat
- DrawSprite(spr, i, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0);
- inc(i, w)
- until i > sw
- end;
-
begin
if ZoomValue < zoom then
begin
@@ -319,8 +343,8 @@
if not cReducedQuality then
begin
// background
- DrawRepeated(sprSky, WorldDx * 3 div 8);
- DrawRepeated(sprHorizont, WorldDx * 3 div 5);
+ DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8);
+ DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5);
DrawVisualGears(0);
end;
@@ -627,8 +651,8 @@
if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
if WorldDy < wdy then WorldDy:= wdy;
-if WorldDx < -round(LAND_WIDTH * 2 / cScaleFactor) then WorldDx:= -round(LAND_WIDTH * 2 / cScaleFactor);
-if WorldDx > cw then WorldDx:= cw;
+if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024;
+if WorldDx > 1024 then WorldDx:= 1024;
end;
initialization