--- a/hedgewars/uGearsRender.pas Tue Oct 29 23:08:10 2013 +0400
+++ b/hedgewars/uGearsRender.pas Tue Oct 29 23:47:57 2013 +0400
@@ -362,10 +362,11 @@
CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
-
- DrawTextureRotated(HH^.Team^.CrosshairTex,
+ Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
+ DrawTextureRotated(CrosshairTexture,
12, 12, CrosshairX + WorldDx, CrosshairY + WorldDy, 0,
sign * (Gear^.Angle * 180.0) / cMaxAngle);
+ Tint($FFFFFFFF);
end;
hx:= ox + 8 * sign;
hy:= oy - 2;
--- a/hedgewars/uStore.pas Tue Oct 29 23:08:10 2013 +0400
+++ b/hedgewars/uStore.pas Tue Oct 29 23:47:57 2013 +0400
@@ -110,43 +110,13 @@
end;
procedure MakeCrossHairs;
-var t: LongInt;
- tmpsurf, texsurf: PSDL_Surface;
- Color, i: Longword;
+var tmpsurf: PSDL_Surface;
begin
-tmpsurf:= LoadDataImage(ptGraphics, cCHFileName, ifAlpha or ifCritical);
-
-for t:= 0 to Pred(TeamsCount) do
- with TeamsArray[t]^ do
- begin
- texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, tmpsurf^.w, tmpsurf^.h, 32, RMask, GMask, BMask, AMask);
- TryDo(texsurf <> nil, errmsgCreateSurface, true);
-
- Color:= Clan^.Color;
- Color:= SDL_MapRGB(texsurf^.format, Color shr 16, Color shr 8, Color and $FF);
- SDL_FillRect(texsurf, nil, Color);
-
- SDL_UpperBlit(tmpsurf, nil, texsurf, nil);
+ tmpsurf:= LoadDataImage(ptGraphics, cCHFileName, ifAlpha or ifCritical);
- TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Ooops', true);
-
- if SDL_MustLock(texsurf) then
- SDLTry(SDL_LockSurface(texsurf) >= 0, true);
-
- // make black pixel be alpha-transparent
- for i:= 0 to texsurf^.w * texsurf^.h - 1 do
- if PLongwordArray(texsurf^.pixels)^[i] = AMask then
- PLongwordArray(texsurf^.pixels)^[i]:= (RMask or GMask or BMask) and Color;
+ CrosshairTexture:= Surface2Tex(tmpsurf, false);
- if SDL_MustLock(texsurf) then
- SDL_UnlockSurface(texsurf);
-
- FreeTexture(CrosshairTex);
- CrosshairTex:= Surface2Tex(texsurf, false);
- SDL_FreeSurface(texsurf)
- end;
-
-SDL_FreeSurface(tmpsurf)
+ SDL_FreeSurface(tmpsurf)
end;
@@ -479,8 +449,8 @@
begin
for ii:= Low(TSprite) to High(TSprite) do
begin
- FreeTexture(SpritesData[ii].Texture);
- SpritesData[ii].Texture:= nil;
+ FreeAndNilTexture(SpritesData[ii].Texture);
+
if (SpritesData[ii].Surface <> nil) and (not reload) then
begin
SDL_FreeSurface(SpritesData[ii].Surface);
@@ -490,30 +460,22 @@
SDL_FreeSurface(MissionIcons);
// free the textures declared in uVariables
-FreeTexture(WeaponTooltipTex);
-WeaponTooltipTex:= nil;
-FreeTexture(PauseTexture);
-PauseTexture:= nil;
-FreeTexture(SyncTexture);
-SyncTexture:= nil;
-FreeTexture(ConfirmTexture);
-ConfirmTexture:= nil;
-FreeTexture(ropeIconTex);
-ropeIconTex:= nil;
-FreeTexture(HHTexture);
-HHTexture:= nil;
+FreeAndNilTexture(CrosshairTexture);
+FreeAndNilTexture(WeaponTooltipTex);
+FreeAndNilTexture(PauseTexture);
+FreeAndNilTexture(SyncTexture);
+FreeAndNilTexture(ConfirmTexture);
+FreeAndNilTexture(ropeIconTex);
+FreeAndNilTexture(HHTexture);
// free all ammo name textures
for ai:= Low(TAmmoType) to High(TAmmoType) do
- begin
- FreeTexture(Ammoz[ai].NameTex);
- Ammoz[ai].NameTex:= nil
- end;
+ FreeAndNilTexture(Ammoz[ai].NameTex);
// free all count textures
for i:= Low(CountTexz) to High(CountTexz) do
begin
- FreeTexture(CountTexz[i]);
+ FreeAndNilTexture(CountTexz[i]);
CountTexz[i]:= nil
end;
@@ -522,26 +484,17 @@
begin
if TeamsArray[t] <> nil then
begin
- FreeTexture(TeamsArray[t]^.NameTagTex);
- TeamsArray[t]^.NameTagTex:= nil;
- FreeTexture(TeamsArray[t]^.CrosshairTex);
- TeamsArray[t]^.CrosshairTex:= nil;
- FreeTexture(TeamsArray[t]^.GraveTex);
- TeamsArray[t]^.GraveTex:= nil;
- FreeTexture(TeamsArray[t]^.HealthTex);
- TeamsArray[t]^.HealthTex:= nil;
- FreeTexture(TeamsArray[t]^.AIKillsTex);
- TeamsArray[t]^.AIKillsTex:= nil;
- FreeTexture(TeamsArray[t]^.FlagTex);
- TeamsArray[t]^.FlagTex:= nil;
+ FreeAndNilTexture(TeamsArray[t]^.NameTagTex);
+ FreeAndNilTexture(TeamsArray[t]^.GraveTex);
+ FreeAndNilTexture(TeamsArray[t]^.HealthTex);
+ FreeAndNilTexture(TeamsArray[t]^.AIKillsTex);
+ FreeAndNilTexture(TeamsArray[t]^.FlagTex);
+
for i:= 0 to cMaxHHIndex do
begin
- FreeTexture(TeamsArray[t]^.Hedgehogs[i].NameTagTex);
- TeamsArray[t]^.Hedgehogs[i].NameTagTex:= nil;
- FreeTexture(TeamsArray[t]^.Hedgehogs[i].HealthTagTex);
- TeamsArray[t]^.Hedgehogs[i].HealthTagTex:= nil;
- FreeTexture(TeamsArray[t]^.Hedgehogs[i].HatTex);
- TeamsArray[t]^.Hedgehogs[i].HatTex:= nil;
+ FreeAndNilTexture(TeamsArray[t]^.Hedgehogs[i].NameTagTex);
+ FreeAndNilTexture(TeamsArray[t]^.Hedgehogs[i].HealthTagTex);
+ FreeAndNilTexture(TeamsArray[t]^.Hedgehogs[i].HatTex);
end;
end;
end;
--- a/hedgewars/uTeams.pas Tue Oct 29 23:08:10 2013 +0400
+++ b/hedgewars/uTeams.pas Tue Oct 29 23:47:57 2013 +0400
@@ -718,22 +718,21 @@
begin
if GearHidden <> nil then
Dispose(GearHidden);
-
+
FreeTexture(NameTagTex);
FreeTexture(HealthTagTex);
FreeTexture(HatTex);
end;
-
+
with TeamsArray[i]^ do
begin
FreeTexture(NameTagTex);
- FreeTexture(CrosshairTex);
FreeTexture(GraveTex);
FreeTexture(HealthTex);
FreeTexture(AIKillsTex);
FreeTexture(FlagTex);
end;
-
+
Dispose(TeamsArray[i]);
end;
for i:= 0 to Pred(ClansCount) do
--- a/hedgewars/uTextures.pas Tue Oct 29 23:08:10 2013 +0400
+++ b/hedgewars/uTextures.pas Tue Oct 29 23:47:57 2013 +0400
@@ -26,6 +26,7 @@
procedure Surface2GrayScale(surf: PSDL_Surface);
function Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture;
procedure FreeTexture(tex: PTexture);
+procedure FreeAndNilTexture(var tex: PTexture);
procedure initModule;
procedure freeModule;
@@ -226,6 +227,12 @@
end
end;
+procedure FreeAndNilTexture(var tex: PTexture);
+begin
+ FreeTexture(tex);
+ tex:= nil
+end;
+
procedure initModule;
begin
TextureList:= nil;
--- a/hedgewars/uTypes.pas Tue Oct 29 23:08:10 2013 +0400
+++ b/hedgewars/uTypes.pas Tue Oct 29 23:47:57 2013 +0400
@@ -381,7 +381,6 @@
Hedgehogs: array[0..cMaxHHIndex] of THedgehog;
CurrHedgehog: LongWord;
NameTagTex: PTexture;
- CrosshairTex,
GraveTex,
HealthTex,
AIKillsTex,
--- a/hedgewars/uVariables.pas Tue Oct 29 23:08:10 2013 +0400
+++ b/hedgewars/uVariables.pas Tue Oct 29 23:47:57 2013 +0400
@@ -129,6 +129,8 @@
LAND_HEIGHT : LongInt;
LAND_WIDTH_MASK : LongWord;
LAND_HEIGHT_MASK : LongWord;
+
+ CrosshairTexture : PTexture;
cLeftScreenBorder : LongInt;
cRightScreenBorder : LongInt;
Binary file share/hedgewars/Data/Graphics/Crosshair.png has changed