--- a/hedgewars/hwengine.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/hwengine.pas Thu Nov 07 21:06:30 2013 +0400
@@ -336,7 +336,7 @@
AddFileLog(inttostr(i) + ': ' + ParamStr(i));
WriteToConsole('Init SDL... ');
- if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true);
+ if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, 'SDL_Init', true);
WriteLnToConsole(msgOK);
{$IFDEF SDL2}
@@ -347,7 +347,7 @@
SDL_ShowCursor(0);
WriteToConsole('Init SDL_ttf... ');
- SDLTry(TTF_Init() <> -1, true);
+ SDLTry(TTF_Init() <> -1, 'TTF_Init', true);
WriteLnToConsole(msgOK);
{$IFDEF USE_VIDEO_RECORDING}
--- a/hedgewars/uDebug.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uDebug.pas Thu Nov 07 21:06:30 2013 +0400
@@ -24,7 +24,7 @@
procedure OutError(Msg: shortstring; isFatalError: boolean);
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline;
-procedure SDLTry(Assert: boolean; isFatal: boolean);
+procedure SDLTry(Assert: boolean; Msg: shortstring; isFatal: boolean);
implementation
uses SDLh, uConsole, uCommands;
@@ -42,13 +42,13 @@
OutError(Msg, isFatal)
end;
-procedure SDLTry(Assert: boolean; isFatal: boolean);
+procedure SDLTry(Assert: boolean; Msg: shortstring; isFatal: boolean);
var s: shortstring;
begin
if not Assert then
begin
s:= SDL_GetError();
- OutError(s, isFatal)
+ OutError(Msg + ': ' + s, isFatal)
end
end;
--- a/hedgewars/uIO.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uIO.pas Thu Nov 07 21:06:30 2013 +0400
@@ -106,16 +106,16 @@
var ipaddr: TIPAddress;
begin
WriteToConsole('Init SDL_Net... ');
- SDLTry(SDLNet_Init = 0, true);
+ SDLTry(SDLNet_Init = 0, 'SDLNet_Init', true);
fds:= SDLNet_AllocSocketSet(1);
- SDLTry(fds <> nil, true);
+ SDLTry(fds <> nil, 'SDLNet_AllocSocketSet', true);
WriteLnToConsole(msgOK);
WriteToConsole('Establishing IPC connection to tcp 127.0.0.1:' + IntToStr(ipcPort) + ' ');
{$HINTS OFF}
- SDLTry(SDLNet_ResolveHost(ipaddr, PChar('127.0.0.1'), ipcPort) = 0, true);
+ SDLTry(SDLNet_ResolveHost(ipaddr, PChar('127.0.0.1'), ipcPort) = 0, 'SDLNet_ResolveHost', true);
{$HINTS ON}
IPCSock:= SDLNet_TCP_Open(ipaddr);
- SDLTry(IPCSock <> nil, true);
+ SDLTry(IPCSock <> nil, 'SDLNet_TCP_Open', true);
WriteLnToConsole(msgOK)
end;
--- a/hedgewars/uInputHandler.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uInputHandler.pas Thu Nov 07 21:06:30 2013 +0400
@@ -231,7 +231,7 @@
for i:= 6 to cKeyMaxIndex do
begin
s:= shortstring(sdl_getkeyname(i));
- //WriteLnToConsole('uInputHandler - ' + IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex));
+ //AddFileLog('uInputHandler - ' + IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex));
if s = 'unknown key' then KeyNames[i]:= ''
else
begin
--- a/hedgewars/uLand.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uLand.pas Thu Nov 07 21:06:30 2013 +0400
@@ -398,7 +398,7 @@
TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true);
if SDL_MustLock(Surface) then
- SDLTry(SDL_LockSurface(Surface) >= 0, true);
+ SDLTry(SDL_LockSurface(Surface) >= 0, 'SDL_LockSurface', true);
p:= Surface^.pixels;
for y:= 0 to LAND_HEIGHT - 1 do
@@ -578,7 +578,7 @@
cpX:= (LAND_WIDTH - tmpsurf^.w) div 2;
cpY:= LAND_HEIGHT - tmpsurf^.h;
if SDL_MustLock(tmpsurf) then
- SDLTry(SDL_LockSurface(tmpsurf) >= 0, true);
+ SDLTry(SDL_LockSurface(tmpsurf) >= 0, 'SDL_LockSurface', true);
p:= tmpsurf^.pixels;
for y:= 0 to Pred(tmpsurf^.h) do
--- a/hedgewars/uLandGraphics.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uLandGraphics.pas Thu Nov 07 21:06:30 2013 +0400
@@ -601,7 +601,7 @@
col:= Frame div numFramesFirstCol;
if SDL_MustLock(Image) then
- SDLTry(SDL_LockSurface(Image) >= 0, true);
+ SDLTry(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true);
bpp:= Image^.format^.BytesPerPixel;
TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
--- a/hedgewars/uLandObjects.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uLandObjects.pas Thu Nov 07 21:06:30 2013 +0400
@@ -103,7 +103,7 @@
WriteToConsole('Generating collision info... ');
if SDL_MustLock(Image) then
- SDLTry(SDL_LockSurface(Image) >= 0, true);
+ SDLTry(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true);
bpp:= Image^.format^.BytesPerPixel;
TryDo(bpp = 4, 'Land object should be 32bit', true);
@@ -149,7 +149,7 @@
WriteToConsole('Generating collision info... ');
if SDL_MustLock(Image) then
- SDLTry(SDL_LockSurface(Image) >= 0, true);
+ SDLTry(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true);
bpp:= Image^.format^.BytesPerPixel;
TryDo(bpp = 4, 'Land object should be 32bit', true);
--- a/hedgewars/uRenderUtils.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uRenderUtils.pas Thu Nov 07 21:06:30 2013 +0400
@@ -99,7 +99,7 @@
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr);
finalRect.x:= X + cFontBorder + 2;
finalRect.y:= Y + cFontBorder;
- SDLTry(tmpsurf <> nil, true);
+ SDLTry(tmpsurf <> nil, 'TTF_RenderUTF8_Blended', true);
SDL_UpperBlit(tmpsurf, @textRect, Surface, @finalRect);
SDL_FreeSurface(tmpsurf);
finalRect.x:= X;
@@ -449,7 +449,7 @@
rect.x:= edgeHeight + 1 + ((i - w) div 2);
// trying to more evenly position the text, vertically
rect.y:= edgeHeight + ((j-(numLines*h)) div 2) + line * h;
- SDLTry(tmpsurf <> nil, true);
+ SDLTry(tmpsurf <> nil, 'TTF_RenderUTF8_Blended', true);
SDL_UpperBlit(tmpsurf, nil, finalSurface, @rect);
SDL_FreeSurface(tmpsurf);
inc(line);
--- a/hedgewars/uSound.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uSound.pas Thu Nov 07 21:06:30 2013 +0400
@@ -311,7 +311,7 @@
end;
WriteToConsole('Init SDL_mixer... ');
- SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true);
+ SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, 'Mix_Init', true);
WriteLnToConsole(msgOK);
Mix_AllocateChannels(Succ(chanTPU));
@@ -413,7 +413,7 @@
s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
WriteToConsole(msgLoading + s + ' ');
defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
- SDLTry(defVoicepack^.chunks[snd] <> nil, true);
+ SDLTry(defVoicepack^.chunks[snd] <> nil, 'Mix_LoadWAV_RW', true);
WriteLnToConsole(msgOK);
end;
lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1)
@@ -509,7 +509,7 @@
s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
WriteToConsole(msgLoading + s + ' ');
defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
- SDLTry(defVoicepack^.chunks[snd] <> nil, true);
+ SDLTry(defVoicepack^.chunks[snd] <> nil, 'Mix_LoadWAV_RW', true);
WriteLnToConsole(msgOK);
end;
if fadems > 0 then
@@ -559,10 +559,10 @@
WriteToConsole(msgLoading + s + ' ');
Mus:= Mix_LoadMUS_RW(rwopsOpenRead(s));
- SDLTry(Mus <> nil, false);
+ SDLTry(Mus <> nil, 'Mix_LoadMUS_RW', false);
WriteLnToConsole(msgOK);
- SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false)
+ SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, 'Mix_FadeInMusic', false)
end;
procedure SetVolume(vol: LongInt);
--- a/hedgewars/uStore.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uStore.pas Thu Nov 07 21:06:30 2013 +0400
@@ -100,7 +100,7 @@
clr.b:= Color and $FF;
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr);
tmpsurf:= doSurfaceConversion(tmpsurf);
-SDLTry(tmpsurf <> nil, true);
+SDLTry(tmpsurf <> nil, 'TTF_RenderUTF8_Blended, doSurfaceConversion', true);
SDL_UpperBlit(tmpsurf, nil, Surface, @finalRect);
SDL_FreeSurface(tmpsurf);
finalRect.x:= X;
@@ -314,7 +314,7 @@
s:= cPathz[ptFonts] + '/' + Name;
WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... ');
Handle:= TTF_OpenFontRW(rwopsOpenRead(s), true, Height);
- SDLTry(Handle <> nil, true);
+ SDLTry(Handle <> nil, 'TTF_OpenFontRW', true);
TTF_SetFontStyle(Handle, style);
WriteLnToConsole(msgOK)
end;
@@ -699,15 +699,15 @@
AuxBufNum:= AuxBufNum;
-{$IFDEF MOBILE}
+{$IFDEF SDL2}
// TODO: this function creates an opengles1.1 context
// un-comment below and add proper logic to support opengles2.0
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
if SDLGLcontext = nil then
SDLGLcontext:= SDL_GL_CreateContext(SDLwindow);
- SDLTry(SDLGLcontext <> nil, true);
- SDL_GL_SetSwapInterval(1);
+ SDLTry(SDLGLcontext <> nil, 'SDLGLcontext', true);
+ SDLTry(SDL_GL_SetSwapInterval(1) = 0, 'SDL_GL_SetSwapInterval', true);
{$ENDIF}
// get the max (h and v) size for textures that the gpu can support
@@ -1074,7 +1074,7 @@
SDL_WINDOWPOS_CENTERED_MASK, SDL_WINDOWPOS_CENTERED_MASK,
cScreenWidth, cScreenHeight,
SDL_WINDOW_HIDDEN or SDL_WINDOW_OPENGL);
- SDLTry(SDLwindow <> nil, true);
+ SDLTry(SDLwindow <> nil, 'SDL_CreateWindow', true);
SetupOpenGL();
end;
{$ELSE}
@@ -1134,7 +1134,7 @@
SDL_WM_SetCaption(_P'Hedgewars', nil);
{$ENDIF}
WriteToConsole('Init SDL_image... ');
- SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true);
+ SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, 'IMG_Init', true);
WriteLnToConsole(msgOK);
// load engine icon
{$IFNDEF DARWIN}
@@ -1208,7 +1208,7 @@
if SDLwindow = nil then
SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
- SDLTry(SDLwindow <> nil, true);
+ SDLTry(SDLwindow <> nil, 'SDL_CreateWindow', true);
{$ELSE}
flags:= SDL_OPENGL or SDL_RESIZABLE;
if cFullScreen then
@@ -1264,7 +1264,7 @@
if GameType = gmtRecord then
exit;
{$IFDEF SDL2}
- SDL_GL_SwapWindow(SDLwindow);
+ SDLTry(SDL_GL_SwapWindow(SDLwindow) <> 0, 'SDL_GL_SwapWindow', true);
{$ELSE}
SDL_GL_SwapBuffers();
{$ENDIF}
--- a/hedgewars/uTextures.pas Tue Nov 05 23:33:23 2013 +0100
+++ b/hedgewars/uTextures.pas Thu Nov 07 21:06:30 2013 +0400
@@ -154,7 +154,7 @@
glBindTexture(GL_TEXTURE_2D, Surface2Tex^.id);
if SDL_MustLock(surf) then
- SDLTry(SDL_LockSurface(surf) >= 0, true);
+ SDLTry(SDL_LockSurface(surf) >= 0, 'Lock surface', true);
fromP4:= Surf^.pixels;