Bunch of neat stuff by Smaxx. ATI check, translucent name tags to reduce terrain fail, disabling health crates on invulnerable hogs. Also tweaks to prior stuff.
--- a/hedgewars/CCHandlers.inc Tue Oct 20 17:55:11 2009 +0000
+++ b/hedgewars/CCHandlers.inc Tue Oct 20 21:20:47 2009 +0000
@@ -670,7 +670,11 @@
procedure chRotateMask(var s: shortstring);
const map: array[0..7] of byte = (7,4,0,1,2,3,0,5);
begin
-cTagsMask:= map[cTagsMask]
+inc(cTagsMaskIndex);
+if cTagsMaskIndex > High(cTagsMasks) then cTagsMaskIndex:= Low(cTagsMasks);
+
+// HACK: skip "health only" if all hogs are invulnerable
+if ((GameFlags and gfInvulnerable) <> 0) and ((cTagsMasks[cTagsMaskIndex] and not htTransparent) = htHealth) then chRotateMask(s);
end;
procedure chAddTrigger(var s: shortstring);
--- a/hedgewars/hwengine.pas Tue Oct 20 17:55:11 2009 +0000
+++ b/hedgewars/hwengine.pas Tue Oct 20 21:20:47 2009 +0000
@@ -17,7 +17,7 @@
*)
{$IFNDEF FPC}
-WriteLn('Only Freepascal supported');
+{$ERROR Only Free Pascal supported!}
{$ENDIF}
program hwengine;
--- a/hedgewars/uConsts.pas Tue Oct 20 17:55:11 2009 +0000
+++ b/hedgewars/uConsts.pas Tue Oct 20 21:20:47 2009 +0000
@@ -332,6 +332,24 @@
NoPointX = Low(LongInt);
+ // hog tag mask
+ htNone = $00;
+ htTeamName = $01;
+ htName = $02;
+ htHealth = $04;
+ htTransparent = $80;
+
+ cTagsMasks : array[0..7] of byte = (
+ htTeamName or htName or htHealth,
+ htName or htHealth,
+ htHealth,
+ htNone,
+ htTeamName or htName or htHealth or htTransparent,
+ htName or htHealth or htTransparent,
+ htHealth or htTransparent,
+ htNone
+ );
+
cHHFileName = 'Hedgehog';
cCHFileName = 'Crosshair';
cThemeCFGFilename = 'theme.cfg';
--- a/hedgewars/uGears.pas Tue Oct 20 17:55:11 2009 +0000
+++ b/hedgewars/uGears.pas Tue Oct 20 21:20:47 2009 +0000
@@ -1239,21 +1239,25 @@
or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
begin
t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy;
- if (cTagsMask and 1) <> 0 then
+ if (cTagsMasks[cTagsMaskIndex] and htTransparent) <> 0 then
+ glColor4f(1, 1, 1, 0.5);
+ if ((cTagsMasks[cTagsMaskIndex] and htHealth) <> 0) and ((GameFlags and gfInvulnerable) = 0) then
begin
dec(t, HealthTagTex^.h + 2);
DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex)
end;
- if (cTagsMask and 2) <> 0 then
+ if (cTagsMasks[cTagsMaskIndex] and htName) <> 0 then
begin
dec(t, NameTagTex^.h + 2);
DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex)
end;
- if (cTagsMask and 4) <> 0 then
+ if (cTagsMasks[cTagsMaskIndex] and htTeamName) <> 0 then
begin
dec(t, Team^.NameTagTex^.h + 2);
DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex)
- end
+ end;
+ if (cTagsMasks[cTagsMaskIndex] and htTransparent) <> 0 then
+ glColor4f(1, 1, 1, 1)
end;
if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
begin
@@ -1864,6 +1868,9 @@
else
t:= getrandom(20);
+// avoid health crates if all hogs are invulnerable
+if (t < 13) and ((GameFlags and gfInvulnerable) <> 0) then t:= t * 13 div 20 + 7;
+
//case getrandom(20) of
case t of
0..6: begin
--- a/hedgewars/uMisc.pas Tue Oct 20 17:55:11 2009 +0000
+++ b/hedgewars/uMisc.pas Tue Oct 20 21:20:47 2009 +0000
@@ -60,7 +60,7 @@
cInitHeight : LongInt = 768;
cBits : LongInt = 32;
cBitsStr : string[2] = '32';
- cTagsMask : byte = 7;
+ cTagsMaskIndex : byte = Low(cTagsMasks);
zoom : GLfloat = 2.0;
ZoomValue : GLfloat = 2.0;
--- a/hedgewars/uStore.pas Tue Oct 20 17:55:11 2009 +0000
+++ b/hedgewars/uStore.pas Tue Oct 20 21:20:47 2009 +0000
@@ -69,13 +69,16 @@
implementation
uses uMisc, uConsole, uLand, uLocale, uWorld;
+type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel);
+
var
HHTexture: PTexture;
MaxTextureSize: Integer;
+ cGPUVendor: TGPUVendor;
procedure StoreInit;
begin
-
+ cGPUVendor:= gvUnknown;
end;
procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
@@ -977,27 +980,56 @@
{$IFNDEF IPHONEOS}
glLoadExtension:= glext_LoadExtension(extension);
{$ELSE}
- glLoadExtension:= false;
+ glLoadExtension:= false;
{$ENDIF}
+{$IFDEF DEBUGFILE}
if not glLoadExtension then
- WriteLnToConsole('OpenGL: "' + extension + '" failed to load')
+ AddFileLog('OpenGL: "' + extension + '" failed to load')
else
- WriteLnToConsole('OpenGL: "' + extension + '" loaded');
+ AddFileLog('OpenGL: "' + extension + '" loaded');
+{$ENDIF}
end;
procedure SetupOpenGL;
+var vendor: shortstring;
begin
glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
-//workaround for wan the previous call fails
-if MaxTextureSize = 0 then MaxTextureSize:= 1024;
-
{$IFDEF DEBUGFILE}
-AddFileLog('GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
+AddFileLog('OpenGL: Renderer: ' + glGetString(GL_RENDERER));
+AddFileLog('OpenGL: Vendor: ' + glGetString(GL_VENDOR));
+AddFileLog('OpenGL: Version: ' + glGetString(GL_VERSION));
+AddFileLog('OpenGL: GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
{$ENDIF}
+if MaxTextureSize = 0 then
+ begin
+ MaxTextureSize:= 1024;
+{$IFDEF DEBUGFILE}
+ AddFileLog('OpenGL: Warning - driver didn''t provide any valid max texture size; assuming 1024');
+{$ENDIF}
+ end;
+
+vendor:= LowerCase(glGetString(GL_VENDOR));
+if StrPos(Str2PChar(vendor), Str2PChar('nvidia')) <> nil then
+ cGPUVendor:= gvNVIDIA
+else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then
+ cGPUVendor:= gvATI
+else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then
+ cGPUVendor:= gvIntel;
+
+
+
{$IFNDEF IPHONEOS}
-SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two');
+// since ATI seems to be unable to provide proper texture filtering/quality,
+// don't even try to load the extension on ATI cards
+if cGPUVendor <> gvATI then
+ SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two')
+{$IFDEF DEBUGFILE}
+else
+ AddFileLog('OpenGL: Skipped extension GL_ARB_texture_non_power_of_two due to ATI card')
+{$ENDIF}
+; // don't touch this line! :)
{$ENDIF}
// set view port to whole window