--- a/hedgewars/hwengine.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/hwengine.pas Sun Jan 31 16:07:14 2016 +0300
@@ -140,7 +140,7 @@
ScreenFade:= sfFromWhite;
ScreenFadeValue:= sfMax;
ScreenFadeSpeed:= 5;
-
+
if (not flagDumpLand and MakeScreenshot(s, 1, 0)) or
(flagDumpLand and MakeScreenshot(s, 1, 1) and ((cReducedQuality and rqBlurryLand <> 0) or MakeScreenshot(s, 1, 2))) then
WriteLnToConsole('Screenshot saved: ' + s)
@@ -162,7 +162,7 @@
begin
isTerminated:= false;
PrevTime:= SDL_GetTicks;
- while isTerminated = false do
+ while (not isTerminated) and allOK do
begin
wheelEvent:= false;
SDL_PumpEvents();
@@ -327,12 +327,11 @@
{$ENDIF}
///////////////////////////////////////////////////////////////////////////////
-procedure Game;
+procedure GameRoutine;
//var p: TPathType;
var s: shortstring;
i: LongInt;
begin
- initEverything(true);
WriteLnToConsole('Hedgewars engine ' + cVersionString + '-r' + cRevisionString +
' (' + cHashString + ') with protocol #' + inttostr(cNetProtoVersion));
AddFileLog('Prefix: "' + shortstring(PathPrefix) +'"');
@@ -351,11 +350,7 @@
WriteLnToConsole(msgOK);
end;
- if not allOK then
- begin
- freeEverything(true);
- exit
- end;
+ if not allOK then exit;
//SDL_StartTextInput();
SDL_ShowCursor(0);
@@ -376,6 +371,7 @@
ControllerInit(); // has to happen before InitKbdKeyTable to map keys
InitKbdKeyTable();
AddProgress();
+ if not allOK then exit;
LoadLocale(cPathz[ptLocale] + '/en.txt'); // Do an initial load with english
if cLocaleFName <> 'en.txt' then
@@ -389,6 +385,7 @@
end
else cLocale := 'en';
+ if not allOK then exit;
WriteLnToConsole(msgGettingConfig);
if cTestLua then
@@ -406,39 +403,43 @@
LoadRecordFromFile(recordFileName);
end;
- if allOK then
- begin
- ScriptOnGameInit;
- s:= 'eproto ' + inttostr(cNetProtoVersion);
- SendIPCRaw(@s[0], Length(s) + 1); // send proto version
+ if not allOK then exit;
+ ScriptOnGameInit;
+ s:= 'eproto ' + inttostr(cNetProtoVersion);
+ SendIPCRaw(@s[0], Length(s) + 1); // send proto version
- InitTeams();
- AssignStores();
+ InitTeams();
+ AssignStores();
- if GameType = gmtRecord then
- SetSound(false);
+ if GameType = gmtRecord then
+ SetSound(false);
- InitSound();
+ InitSound();
- isDeveloperMode:= false;
- TryDo(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
- //ParseCommand('rotmask', true);
+ isDeveloperMode:= false;
+ if checkFails(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true) then exit;
+ //ParseCommand('rotmask', true);
+ if not allOK then exit;
- {$IFDEF USE_VIDEO_RECORDING}
- if GameType = gmtRecord then
- begin
- RecorderMainLoop();
- freeEverything(true);
- exit;
- end;
- {$ENDIF}
+{$IFDEF USE_VIDEO_RECORDING}
+ if GameType = gmtRecord then
+ begin
+ RecorderMainLoop();
+ freeEverything(true);
+ exit;
+ end;
+{$ENDIF}
- MainLoop;
- end;
+ MainLoop;
+end;
+
+procedure Game;
+begin
+ initEverything(true);
+ GameRoutine;
// clean up all the memory allocated
freeEverything(true);
end;
-
///////////////////////////////////////////////////////////////////////////////
// preInitEverything - init variables that are going to be ovewritten by arguments
// initEverything - init variables only. Should be coupled by below
@@ -549,7 +550,7 @@
if allOK then
begin
IPCWaitPongEvent;
- TryDo(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
+ if checkFails(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true) then exit;
ScriptOnPreviewInit;
{$IFDEF MOBILE}
--- a/hedgewars/uAI.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uAI.pas Sun Jan 31 16:07:14 2016 +0300
@@ -552,7 +552,7 @@
if Gear^.Message <> 0 then
begin
StopMessages(Gear^.Message);
- TryDo((Gear^.Message and gmAllStoppable) = 0, 'Engine bug: AI may break demos playing', true);
+ if checkFails((Gear^.Message and gmAllStoppable) = 0, 'Engine bug: AI may break demos playing', true) then exit;
end;
if Gear^.Message <> 0 then
--- a/hedgewars/uAmmos.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uAmmos.pas Sun Jan 31 16:07:14 2016 +0300
@@ -70,7 +70,7 @@
begin
if newAmmo[a].Count > 0 then
begin
- TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true);
+ if checkFails(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true) then exit;
Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= newAmmo[a];
inc(mi[Ammoz[a].Slot])
end
@@ -85,10 +85,13 @@
ammos: TAmmoCounts;
newAmmos: TAmmoArray;
begin
-TryDo((byte(ammoLoadout[0]) = byte(ord(High(TAmmoType)))) and (byte(ammoProbability[0]) = byte(ord(High(TAmmoType)))) and (byte(ammoDelay[0]) = byte(ord(High(TAmmoType)))) and (byte(ammoReinforcement[0]) = byte(ord(High(TAmmoType)))), 'Incomplete or missing ammo scheme set (incompatible frontend or demo/save?)', true);
+ if checkFails((byte(ammoLoadout[0]) = byte(ord(High(TAmmoType)))) and (byte(ammoProbability[0]) = byte(ord(High(TAmmoType)))) and (byte(ammoDelay[0]) = byte(ord(High(TAmmoType)))) and (byte(ammoReinforcement[0]) = byte(ord(High(TAmmoType))))
+ , 'Incomplete or missing ammo scheme set (incompatible frontend or demo/save?)'
+ , true)
+ then exit;
inc(StoreCnt);
-TryDo(StoreCnt <= cMaxHHs, 'Ammo stores overflow', true);
+if checkFails(StoreCnt <= cMaxHHs, 'Ammo stores overflow', true) then exit;
new(StoresList[Pred(StoreCnt)]);
@@ -153,8 +156,10 @@
function GetAmmoByNum(num: LongInt): PHHAmmo;
begin
- TryDo(num < StoreCnt, 'Invalid store number', true);
- GetAmmoByNum:= StoresList[num]
+ if checkFails(num < StoreCnt, 'Invalid store number', true) then
+ GetAmmoByNum:= nil
+ else
+ GetAmmoByNum:= StoresList[num]
end;
function GetCurAmmoEntry(var Hedgehog: THedgehog): PAmmo;
@@ -364,7 +369,7 @@
inc(slot)
end
end;
- TryDo(slot <= cMaxSlotIndex, 'Ammo slot index overflow', true);
+ if checkFails(slot <= cMaxSlotIndex, 'Ammo slot index overflow', true) then exit;
CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
end
end;
--- a/hedgewars/uCollisions.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uCollisions.pas Sun Jan 31 16:07:14 2016 +0300
@@ -62,7 +62,7 @@
function CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean;
implementation
-uses uConsts, uLandGraphics, uVariables, uDebug;
+uses uConsts, uLandGraphics, uVariables;
type TCollisionEntry = record
X, Y, Radius: LongInt;
@@ -76,10 +76,10 @@
procedure AddCI(Gear: PGear);
begin
-if (Gear^.CollisionIndex >= 0) or
+if (Gear^.CollisionIndex >= 0) or (Count > MAXRECTSINDEX) or
((Count > MAXRECTSINDEX-200) and ((Gear^.Kind = gtMine) or (Gear^.Kind = gtSMine) or (Gear^.Kind = gtKnife))) then
exit;
-TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true);
+
with cinfos[Count] do
begin
X:= hwRound(Gear^.X);
--- a/hedgewars/uCommandHandlers.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uCommandHandlers.pas Sun Jan 31 16:07:14 2016 +0300
@@ -93,8 +93,8 @@
if isDeveloperMode then
begin
i:= StrToInt(s);
- TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
- TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
+ checkFails(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
+ checkFails(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
end
end;
@@ -379,7 +379,7 @@
begin
s:= s; // avoid compiler hint
- TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
+ if checkFails(AllInactive, '/nextturn called when not all gears are inactive', true) then exit;
CheckSum:= CheckSum xor GameTicks;
gi := GearsList;
@@ -398,7 +398,7 @@
SendIPC(s)
end
else
- TryDo(CurrentTeam^.hasGone or (CheckSum = lastTurnChecksum), 'Desync detected', true);
+ checkFails(CurrentTeam^.hasGone or (CheckSum = lastTurnChecksum), 'Desync detected', true);
AddFileLog('Next turn: time '+inttostr(GameTicks));
end;
@@ -408,7 +408,7 @@
if CheckNoTeamOrHH then
exit;
-TryDo((s[0] = #1) and (s[1] >= '1') and (s[1] <= '5'), 'Malformed /timer', true);
+if checkFails((s[0] = #1) and (s[1] >= '1') and (s[1] <= '5'), 'Malformed /timer', true) then exit;
if not isExternalSource then
SendIPC(s);
@@ -450,7 +450,7 @@
if CheckNoTeamOrHH then
exit;
- TryDo((s[0] = #1) and (s[1] <= char(High(TAmmoType))), 'Malformed /setweap', true);
+ if checkFails((s[0] = #1) and (s[1] <= char(High(TAmmoType))), 'Malformed /setweap', true) then exit;
if not isExternalSource then
SendIPC('w' + s);
--- a/hedgewars/uDebug.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uDebug.pas Sun Jan 31 16:07:14 2016 +0300
@@ -23,7 +23,8 @@
interface
procedure OutError(Msg: shortstring; isFatalError: boolean);
-procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline;
+//procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline;
+function checkFails(Assert: boolean; Msg: shortstring; isFatal: boolean): boolean;
function SDLCheck(Assert: boolean; Msg: shortstring; isFatal: boolean): boolean;
var
@@ -50,6 +51,15 @@
OutError(Msg, isFatal)
end;
+function checkFails(Assert: boolean; Msg: shortstring; isFatal: boolean): boolean;
+begin
+ if not Assert then
+ OutError(Msg, false);
+
+ allOK:= allOK and (Assert or (not isFatal));
+ checkFails:= (not Assert) and isFatal
+end;
+
function SDLCheck(Assert: boolean; Msg: shortstring; isFatal: boolean): boolean;
var s: shortstring;
begin
--- a/hedgewars/uGame.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uGame.pas Sun Jan 31 16:07:14 2016 +0300
@@ -28,7 +28,7 @@
////////////////////
uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, uLocale, uCaptions,
uTypes, uVariables, uCommands, uConsts, uVisualGearsList, uUtils
- {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
+ {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF}, uDebug;
procedure DoGameTick(Lag: LongInt);
var i,j : LongInt;
@@ -40,6 +40,7 @@
if (not CurrentTeam^.ExtDriven) then
begin
NetGetNextCmd; // its for the case of receiving "/say" message
+ if not allOK then exit;
isInLag:= false;
FlushMessages(Lag)
end;
@@ -99,6 +100,8 @@
else
begin
NetGetNextCmd;
+ if not allOK then exit;
+
if isInLag then
case GameType of
gmtNet: begin
--- a/hedgewars/uGears.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uGears.pas Sun Jan 31 16:07:14 2016 +0300
@@ -748,7 +748,7 @@
if (ClansCount = 2) and ((GameFlags and gfDivideTeams) <> 0) then
begin
t:= 0;
- TryDo(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true);
+ if checkFails(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true) then exit;
for p:= 0 to 1 do
begin
with ClansArray[p]^ do
--- a/hedgewars/uGearsHandlersRope.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uGearsHandlersRope.pas Sun Jan 31 16:07:14 2016 +0300
@@ -270,7 +270,7 @@
Gear^.X := Gear^.X + nx * len;
Gear^.Y := Gear^.Y + ny * len;
inc(RopePoints.Count);
- TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true);
+ if checkFails(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true) then exit;
Gear^.Elasticity := Gear^.Elasticity - len;
Gear^.Friction := Gear^.Friction - len;
haveDivided := true;
--- a/hedgewars/uGearsList.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uGearsList.pas Sun Jan 31 16:07:14 2016 +0300
@@ -150,7 +150,7 @@
AddFileLog('Attempted to remove Gear #'+inttostr(Gear^.uid)+' from the list twice.');
exit
end;
-TryDo((Gear = nil) or (curHandledGear = nil) or (Gear = curHandledGear), 'You''re doing it wrong', true);
+if checkFails((Gear = nil) or (curHandledGear = nil) or (Gear = curHandledGear), 'You''re doing it wrong', true) then exit;
if Gear^.NextGear <> nil then
Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
--- a/hedgewars/uIO.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uIO.pas Sun Jan 31 16:07:14 2016 +0300
@@ -102,7 +102,6 @@
procedure RemoveCmd;
var tmp: PCmd;
begin
-TryDo(headcmd <> nil, 'Engine bug: headcmd = nil', true);
tmp:= headcmd;
headcmd:= headcmd^.Next;
if headcmd = nil then
@@ -224,7 +223,8 @@
{$I-}
assign(f, fileName);
reset(f, 1);
-tryDo(IOResult = 0, 'Error opening file ' + fileName, true);
+if checkFails(IOResult = 0, 'Error opening file ' + fileName, true) then
+ exit;
i:= 0; // avoid compiler hints
s[0]:= #0;
@@ -435,7 +435,7 @@
end;
if (headcmd <> nil) and tmpflag and (not CurrentTeam^.hasGone) then
- TryDo(GameTicks < LongWord(hiTicks shl 16) + headcmd^.loTime,
+ checkFails(GameTicks < LongWord(hiTicks shl 16) + headcmd^.loTime,
'oops, queue error. in buffer: ' + headcmd^.cmd +
' (' + IntToStr(GameTicks) + ' > ' +
IntToStr(hiTicks shl 16 + headcmd^.loTime) + ')',
--- a/hedgewars/uLand.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uLand.pas Sun Jan 31 16:07:14 2016 +0300
@@ -260,7 +260,7 @@
var x, y: LongInt;
p: PLongwordArray;
begin
-TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true);
+if checkFails(Surface <> nil, 'Assert (LandSurface <> nil) failed', true) then exit;
if SDL_MustLock(Surface) then
if SDLCheck(SDL_LockSurface(Surface) >= 0, 'SDL_LockSurface', true) then exit;
@@ -291,7 +291,7 @@
tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, AMask);
- TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true);
+ if checkFails(tmpsurf <> nil, 'Error creating pre-land surface', true) then exit;
ColorizeLand(tmpsurf);
if gameFlags and gfShoppaBorder = 0 then DrawBorderFromImage(tmpsurf);
AddOnLandObjects(tmpsurf);
@@ -490,9 +490,11 @@
begin
mapName:= ExtractFileName(cPathz[ptMapCurrent]);
tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
+ if not allOK then exit;
end;
// (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take
-TryDo((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (QWord(tmpsurf^.w) * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true);
+if checkFails((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (QWord(tmpsurf^.w) * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true)
+ then exit;
ResizeLand(tmpsurf^.w, tmpsurf^.h);
LoadMapConfig;
@@ -503,16 +505,16 @@
rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
topY:= LAND_HEIGHT - playHeight;
-TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true);
+if not checkFails(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true) then
+ BlitImageAndGenerateCollisionInfo(
+ (LAND_WIDTH - tmpsurf^.w) div 2,
+ LAND_HEIGHT - tmpsurf^.h,
+ tmpsurf^.w,
+ tmpsurf);
-BlitImageAndGenerateCollisionInfo(
- (LAND_WIDTH - tmpsurf^.w) div 2,
- LAND_HEIGHT - tmpsurf^.h,
- tmpsurf^.w,
- tmpsurf);
SDL_FreeSurface(tmpsurf);
-LoadMask;
+if allOK then LoadMask;
end;
procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD
@@ -797,7 +799,7 @@
if digest = '' then
digest:= s
else
- TryDo(s = digest, 'Different maps generated, sorry', true);
+ checkFails(s = digest, 'Different maps generated, sorry', true);
end;
procedure chSendLandDigest(var s: shortstring);
@@ -811,7 +813,7 @@
ScriptSetString('LandDigest', s);
chLandCheck(s);
- SendIPCRaw(@s[0], Length(s) + 1)
+ if allOK then SendIPCRaw(@s[0], Length(s) + 1)
end;
procedure initModule;
--- a/hedgewars/uLandGenTemplateBased.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uLandGenTemplateBased.pas Sun Jan 31 16:07:14 2016 +0300
@@ -9,7 +9,7 @@
var minDistance, dabDiv: LongInt; // different details size
implementation
-uses uVariables, uTypes, uConsts, uFloat, uLandUtils, uRandom, SDLh, math;
+uses uVariables, uConsts, uFloat, uLandUtils, uRandom, SDLh, math;
procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr; fps: PPointArray);
--- a/hedgewars/uLandGraphics.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uLandGraphics.pas Sun Jan 31 16:07:14 2016 +0300
@@ -705,7 +705,7 @@
if outOfMap then doPlace:= false; // just using for a check
-TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true);
+if checkFails(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true) then exit;
Image:= SpritesData[Obj].Surface;
w:= SpritesData[Obj].Width;
@@ -719,7 +719,12 @@
if SDLCheck(SDL_LockSurface(Image) >= 0, 'TryPlaceOnLand', true) then exit;
bpp:= Image^.format^.BytesPerPixel;
-TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
+if checkFails(bpp = 4, 'It should be 32 bpp sprite', true) then
+begin
+ if SDL_MustLock(Image) then
+ SDL_UnlockSurface(Image);
+ exit
+end;
// Check that sprite fits free space
p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
case bpp of
@@ -824,7 +829,7 @@
begin
numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
-TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true);
+if checkFails(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true) then exit;
Image:= SpritesData[Obj].Surface;
w:= SpritesData[Obj].Width;
@@ -838,11 +843,16 @@
if SDLCheck(SDL_LockSurface(Image) >= 0, 'EraseLand', true) then exit;
bpp:= Image^.format^.BytesPerPixel;
-TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
+if checkFails(bpp = 4, 'It should be 32 bpp sprite', true) then
+begin
+ if SDL_MustLock(Image) then
+ SDL_UnlockSurface(Image);
+ exit
+end;
// Check that sprite fits free space
p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
-case bpp of
- 4: for y:= 0 to Pred(h) do
+
+ for y:= 0 to Pred(h) do
begin
for x:= 0 to Pred(w) do
if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then
@@ -854,13 +864,11 @@
exit
end;
p:= PByteArray(@(p^[Image^.pitch]))
- end
- end;
+ end;
// Checked, now place
p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
-case bpp of
- 4: for y:= 0 to Pred(h) do
+ for y:= 0 to Pred(h) do
begin
for x:= 0 to Pred(w) do
if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then
@@ -875,7 +883,7 @@
gX:= (cpX + x) div 2;
gY:= (cpY + y) div 2;
end;
- if (not eraseOnLFMatch or (Land[cpY + y, cpX + x] and LandFlags <> 0)) and
+ if (not eraseOnLFMatch or (Land[cpY + y, cpX + x] and LandFlags <> 0)) and
((PLongword(@(p^[x * 4]))^) and AMask <> 0) then
begin
if not onlyEraseLF then
@@ -888,7 +896,6 @@
end;
p:= PByteArray(@(p^[Image^.pitch]));
end;
- end;
if SDL_MustLock(Image) then
SDL_UnlockSurface(Image);
@@ -910,7 +917,7 @@
GetPlaceCollisionTex:= nil;
numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
-TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true);
+checkFails(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true);
Image:= SpritesData[Obj].Surface;
w:= SpritesData[Obj].Width;
h:= SpritesData[Obj].Height;
@@ -922,17 +929,28 @@
exit;
bpp:= Image^.format^.BytesPerPixel;
-TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
+checkFails(bpp = 4, 'It should be 32 bpp sprite', true);
finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
-TryDo(finalSurface <> nil, 'GetPlaceCollisionTex: fail to create surface', true);
+checkFails(finalSurface <> nil, 'GetPlaceCollisionTex: fail to create surface', true);
if SDL_MustLock(finalSurface) then
- if SDLCheck(SDL_LockSurface(finalSurface) >= 0, 'GetPlaceCollisionTex', true) then
- exit;
+ SDLCheck(SDL_LockSurface(finalSurface) >= 0, 'GetPlaceCollisionTex', true);
+
+if not allOK then
+ begin
+ if SDL_MustLock(Image) then
+ SDL_UnlockSurface(Image);
+
+ if SDL_MustLock(finalSurface) then
+ SDL_UnlockSurface(finalSurface);
+
+ if finalSurface <> nil then
+ SDL_FreeSurface(finalSurface);
+ end;
p:= PLongWordArray(@(PLongWordArray(Image^.pixels)^[ (Image^.pitch div 4) * row * h + col * w ]));
pt:= PLongWordArray(finalSurface^.pixels);
--- a/hedgewars/uLandObjects.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uLandObjects.pas Sun Jan 31 16:07:14 2016 +0300
@@ -112,7 +112,11 @@
if SDLCheck(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true) then exit;
bpp:= Image^.format^.BytesPerPixel;
-TryDo(bpp = 4, 'Land object should be 32bit', true);
+if checkFails(bpp = 4, 'Land object should be 32bit', true) then
+begin
+if SDL_MustLock(Image) then
+ SDL_UnlockSurface(Image);
+end;
if Width = 0 then
Width:= Image^.w;
@@ -163,7 +167,11 @@
if SDLCheck(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true) then exit;
bpp:= Image^.format^.BytesPerPixel;
-TryDo(bpp = 4, 'Land object should be 32bit', true);
+if checkFails(bpp = 4, 'Land object should be 32bit', true) then
+begin
+if SDL_MustLock(Image) then
+ SDL_UnlockSurface(Image);
+end;
p:= Image^.pixels;
mp:= Mask^.pixels;
@@ -203,7 +211,7 @@
h:= h1
end;
inc(RectCount);
-TryDo(RectCount < MaxRects, 'AddRect: overflow', true)
+checkFails(RectCount < MaxRects, 'AddRect: overflow', true)
end;
procedure InitRects;
@@ -512,7 +520,7 @@
s:= cPathz[ptCurrTheme] + '/' + cThemeCFGFilename;
WriteLnToConsole('Reading objects info...');
f:= pfsOpenRead(s);
-TryDo(f <> nil, 'Bad data or cannot access file ' + s, true);
+if checkFails(f <> nil, 'Bad data or cannot access file ' + s, true) then exit;
ThemeObjects.Count:= 0;
SprayObjects.Count:= 0;
--- a/hedgewars/uLandOutline.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uLandOutline.pas Sun Jan 31 16:07:14 2016 +0300
@@ -30,7 +30,7 @@
procedure Push(_xl, _xr, _y, _dir: LongInt);
begin
- TryDo(Stack.Count <= 8192, 'FillLand: stack overflow', true);
+ if checkFails(Stack.Count <= 8192, 'FillLand: stack overflow', true) then exit;
_y:= _y + _dir;
if (_y < 0) or (_y >= LAND_HEIGHT) then
exit;
--- a/hedgewars/uLandTexture.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uLandTexture.pas Sun Jan 31 16:07:14 2016 +0300
@@ -72,10 +72,11 @@
if cOnlyStats then exit;
if (Width <= 0) or (Height <= 0) then
exit;
- TryDo((X >= 0) and (X < LAND_WIDTH), 'UpdateLandTexture: wrong X parameter', true);
- TryDo(X + Width <= LAND_WIDTH, 'UpdateLandTexture: wrong Width parameter', true);
- TryDo((Y >= 0) and (Y < LAND_HEIGHT), 'UpdateLandTexture: wrong Y parameter', true);
- TryDo(Y + Height <= LAND_HEIGHT, 'UpdateLandTexture: wrong Height parameter', true);
+ checkFails((X >= 0) and (X < LAND_WIDTH), 'UpdateLandTexture: wrong X parameter', true);
+ checkFails(X + Width <= LAND_WIDTH, 'UpdateLandTexture: wrong Width parameter', true);
+ checkFails((Y >= 0) and (Y < LAND_HEIGHT), 'UpdateLandTexture: wrong Y parameter', true);
+ checkFails(Y + Height <= LAND_HEIGHT, 'UpdateLandTexture: wrong Height parameter', true);
+ if not allOK then exit;
tSize:= TEXSIZE;
--- a/hedgewars/uLocale.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uLocale.pas Sun Jan 31 16:07:14 2016 +0300
@@ -50,7 +50,7 @@
first[e]:= true;
f:= pfsOpenRead(FileName);
-TryDo(f <> nil, 'Cannot load locale "' + FileName + '"', false);
+checkFails(f <> nil, 'Cannot load locale "' + FileName + '"', false);
s:= '';
@@ -63,18 +63,19 @@
continue;
if (s[1] < '0') or (s[1] > '9') then
continue;
- TryDo(Length(s) > 6, 'Load locale: empty string', true);
+ checkFails(Length(s) > 6, 'Load locale: empty string', true);
{$IFNDEF PAS2C}
val(s[1]+s[2], a, c);
- TryDo(c = 0, ansistring('Load locale: numbers should be two-digit: ') + s, true);
+ checkFails(c = 0, ansistring('Load locale: numbers should be two-digit: ') + s, true);
val(s[4]+s[5], b, c);
- TryDo(c = 0, ansistring('Load locale: numbers should be two-digit: ') + s, true);
+ checkFails(c = 0, ansistring('Load locale: numbers should be two-digit: ') + s, true);
{$ELSE}
val(s[1]+s[2], a);
val(s[4]+s[5], b);
{$ENDIF}
- TryDo(s[3] = ':', 'Load locale: ":" expected', true);
- TryDo(s[6] = '=', 'Load locale: "=" expected', true);
+ checkFails(s[3] = ':', 'Load locale: ":" expected', true);
+ checkFails(s[6] = '=', 'Load locale: "=" expected', true);
+ if not allOK then exit;
Delete(s, 1, 6);
case a of
0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then
@@ -83,7 +84,7 @@
trmsg[TMsgStrId(b)]:= s;
2: if (b >=0) and (b <= ord(High(TEventId))) then
begin
- TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + IntToStr(a) + ':' + IntToStr(b), false);
+ checkFails(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + IntToStr(a) + ':' + IntToStr(b), false);
if first[TEventId(b)] then
begin
trevt_n[TEventId(b)]:= 0;
--- a/hedgewars/uRenderUtils.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uRenderUtils.pas Sun Jan 31 16:07:14 2016 +0300
@@ -115,7 +115,8 @@
tmpPixel: Longword;
pixels: PLongWordArray;
begin
- TryDo(Surface^.format^.BytesPerPixel = 4, 'flipSurface failed, expecting 32 bit surface', true);
+ if checkFails(Surface^.format^.BytesPerPixel = 4, 'flipSurface failed, expecting 32 bit surface', true) then
+ exit;
SDL_LockSurface(Surface);
pixels:= Surface^.pixels;
if Vertical then
@@ -130,7 +131,7 @@
end
else
for x := 0 to (Surface^.w div 2) - 1 do
- for y := 0 to Surface^.h -1 do
+ for y := 0 to Surface^.h - 1 do
begin
i:= y*Surface^.w + x;
j:= y*Surface^.w + (Surface^.w - x - 1);
@@ -246,8 +247,9 @@
var y, x, i, j: LongInt;
srcPixels, destPixels: PLongWordArray;
begin
- TryDo(src^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
- TryDo(dest^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
+ checkFails(src^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
+ checkFails(dest^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
+ if not allOK then exit;
SDL_LockSurface(src);
SDL_LockSurface(dest);
@@ -293,11 +295,12 @@
finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
32, RMask, GMask, BMask, AMask);
- TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);
+ if checkFails(finalSurface <> nil, 'RenderString: fail to create surface', true) then
+ exit(nil);
WriteInRoundRect(finalSurface, 0, 0, Color, font, s, maxLength);
- TryDo(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+ checkFails(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, false);
RenderStringTexLim:= Surface2Tex(finalSurface, false);
@@ -444,7 +447,8 @@
finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, rect.h, 32, RMask, GMask, BMask, AMask);
- TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);
+ if checkFails(finalSurface <> nil, 'RenderString: fail to create surface', true) then
+ exit(nil);
//////////////////////////////// CORNERS ///////////////////////////////
copyToXY(SpritesData[corner].Surface, finalSurface, 0, 0); /////////////////// NW
--- a/hedgewars/uScript.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uScript.pas Sun Jan 31 16:07:14 2016 +0300
@@ -442,7 +442,6 @@
// enable/disable cinematic effects
function lc_setcinematicmode(L : Plua_State) : LongInt; Cdecl;
-var at: LongInt;
const
call = 'SetCinematicMode';
params = 'enable';
@@ -3111,7 +3110,7 @@
begin
// initialize lua
luaState:= lua_open;
-TryDo(luaState <> nil, 'lua_open failed', true);
+if checkFails(luaState <> nil, 'lua_open failed', true) then exit;
// open internal libraries
luaopen_base(luaState);
--- a/hedgewars/uSound.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uSound.pas Sun Jan 31 16:07:14 2016 +0300
@@ -290,10 +290,10 @@
exit(AskForVoicepack('Default'));
end;
- while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do
+ while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') and (i < cMaxTeams) do
begin
inc(i);
- TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true)
+ //TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true)
end;
voicepacks[i].name:= name;
--- a/hedgewars/uStats.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uStats.pas Sun Jan 31 16:07:14 2016 +0300
@@ -38,7 +38,7 @@
procedure declareAchievement(id, teamname, location: shortstring; value: LongInt);
implementation
-uses uSound, uLocale, uVariables, uUtils, uIO, uCaptions, uDebug, uMisc, uConsole, uScript;
+uses uSound, uLocale, uVariables, uUtils, uIO, uCaptions, uMisc, uConsole, uScript;
var DamageClan : Longword = 0;
DamageTotal : Longword = 0;
@@ -99,7 +99,7 @@
var i, t: LongInt;
s: ansistring;
begin
-TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true);
+//TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true);
inc(FinishedTurnsTotal);
if FinishedTurnsTotal <> 0 then
--- a/hedgewars/uStore.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uStore.pas Sun Jan 31 16:07:14 2016 +0300
@@ -149,8 +149,10 @@
rr.h:= h;
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
- TryDo(texsurf <> nil, errmsgCreateSurface, true);
- TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+ if not checkFails(texsurf <> nil, errmsgCreateSurface, true) then
+ checkFails(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+
+ if not allOK then exit(nil);
DrawRoundRect(@rr, cWhiteColor, cNearBlackColor, texsurf, true);
@@ -196,8 +198,9 @@
r.w:= 32;
r.h:= 32;
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask);
- TryDo(texsurf <> nil, errmsgCreateSurface, true);
- TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+ if not checkFails(texsurf <> nil, errmsgCreateSurface, true) then
+ checkFails(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+ if not allOK then exit;
r.w:= 26;
r.h:= 19;
@@ -229,20 +232,20 @@
Flag:= 'hedgewars';
flagsurf:= LoadDataImageAltFile(ptFlags, Flag, 'hedgewars', ifNone);
- TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true);
+ if not checkFails(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true) then
+ begin
+ case maxLevel of
+ 1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0);
+ 2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2);
+ 3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5);
+ 4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9);
+ 5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11)
+ end;
- case maxLevel of
- 1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0);
- 2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2);
- 3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5);
- 4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9);
- 5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11)
- end;
-
- copyToXY(flagsurf, texsurf, 2, 2);
- SDL_FreeSurface(flagsurf);
- flagsurf:= nil;
-
+ copyToXY(flagsurf, texsurf, 2, 2);
+ SDL_FreeSurface(flagsurf);
+ flagsurf:= nil;
+ end;
// restore black border pixels inside the flag
PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor;
@@ -255,6 +258,8 @@
SDL_FreeSurface(texsurf);
texsurf:= nil;
+ if not allOK then exit;
+
AIKillsTex := RenderStringTex(ansistring(inttostr(stats.AIKills)), Clan^.Color, fnt16);
dec(drY, r.h + 2);
@@ -475,9 +480,9 @@
for ai:= Low(TAmmoType) to High(TAmmoType) do
with Ammoz[ai] do
begin
- TryDo(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
+ if checkFails(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true) then exit;
tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, PChar(trAmmo[NameId]), cWhiteColorChannels);
- TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
+ if checkFails(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true) then exit;
tmpsurf:= doSurfaceConversion(tmpsurf);
FreeAndNilTexture(NameTex);
NameTex:= Surface2Tex(tmpsurf, false);
@@ -629,7 +634,7 @@
tmpsurf:= doSurfaceConversion(tmpsurf);
if (imageFlags and ifTransparent) <> 0 then
- TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+ if checkFails(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true) then exit;
WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')');
@@ -778,7 +783,7 @@
{$ENDIF}
end;
- TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true);
+ if checkFails(ProgrTex <> nil, 'Error - Progress Texure is nil!', true) then exit;
RenderClear();
if Step < numsquares then
@@ -879,7 +884,7 @@
inc(h, ha + 8);
tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
-TryDo(tmpsurf <> nil, 'RenderHelpWindow: fail to create surface', true);
+if checkFails(tmpsurf <> nil, 'RenderHelpWindow: fail to create surface', true) then exit(nil);
// render border and background
r.x:= 0;
--- a/hedgewars/uTeams.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uTeams.pas Sun Jan 31 16:07:14 2016 +0300
@@ -119,7 +119,7 @@
PrevHH, PrevTeam : LongWord;
begin
TargetPoint.X:= NoPointX;
-TryDo(CurrentTeam <> nil, 'nil Team', true);
+if checkFails(CurrentTeam <> nil, 'nil Team', true) then exit;
with CurrentHedgehog^ do
if (PreviousTeam <> nil) and PlacingHogs and Unplaced then
begin
@@ -355,9 +355,9 @@
var team: PTeam;
c, t: LongInt;
begin
-TryDo(TeamsCount < cMaxTeams, 'Too many teams', true);
+if checkFails(TeamsCount < cMaxTeams, 'Too many teams', true) then exit(nil);
New(team);
-TryDo(team <> nil, 'AddTeam: team = nil', true);
+if checkFails(team <> nil, 'AddTeam: team = nil', true) then exit(nil);
FillChar(team^, sizeof(TTeam), 0);
team^.AttackBar:= 2;
team^.CurrHedgehog:= 0;
@@ -551,10 +551,10 @@
s:= '';
if (not isDeveloperMode) then
exit;
-TryDo((CurrentTeam <> nil), 'Can''t add hedgehogs yet, add a team first!', true);
+if checkFails((CurrentTeam <> nil), 'Can''t add hedgehogs yet, add a team first!', true) then exit;
with CurrentTeam^ do
begin
- TryDo(HedgehogsNumber<=cMaxHHIndex, 'Can''t add hedgehog to "' + TeamName + '"! (already ' + intToStr(HedgehogsNumber) + ' hogs)', true);
+ if checkFails(HedgehogsNumber<=cMaxHHIndex, 'Can''t add hedgehog to "' + TeamName + '"! (already ' + intToStr(HedgehogsNumber) + ' hogs)', true) then exit;
SplitBySpace(id, s);
SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]);
CurrentHedgehog^.BotLevel:= StrToInt(id);
@@ -562,7 +562,7 @@
Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
SplitBySpace(s, id);
Gear^.Health:= StrToInt(s);
- TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
+ if checkFails(Gear^.Health > 0, 'Invalid hedgehog health', true) then exit;
if (GameFlags and gfSharedAmmo) <> 0 then
CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex
else if (GameFlags and gfPerHogAmmo) <> 0 then
--- a/hedgewars/uTextures.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uTextures.pas Sun Jan 31 16:07:14 2016 +0300
@@ -229,7 +229,7 @@
if (surf^.format^.BytesPerPixel <> 4) then
begin
- TryDo(false, 'Surface2Tex failed, expecting 32 bit surface', true);
+ checkFails(false, 'Surface2Tex failed, expecting 32 bit surface', true);
Surface2Tex^.id:= 0;
exit
end;
--- a/hedgewars/uVideoRec.pas Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uVideoRec.pas Sun Jan 31 16:07:14 2016 +0300
@@ -109,7 +109,7 @@
filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix;
soundFilePath:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw';
- TryDo(AVWrapper_Init(@AddFileLogRaw
+ if checkFails(AVWrapper_Init(@AddFileLogRaw
, PChar(ansistring(filename))
, PChar(ansistring(desc))
, PChar(ansistring(soundFilePath))
@@ -118,7 +118,7 @@
, PChar(ansistring(cAudioCodec))
, cScreenWidth, cScreenHeight, cVideoFramerateNum, cVideoFramerateDen, cVideoQuality) >= 0,
'AVWrapper_Init failed',
- true);
+ true) then exit(false);
numPixels:= cScreenWidth*cScreenHeight;
YCbCr_Planes[0]:= GetMem(numPixels);