change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
--- a/hedgewars/PascalExports.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/PascalExports.pas Wed May 02 10:53:13 2012 +0100
@@ -91,12 +91,12 @@
function HW_zoomFactor: GLfloat; cdecl; export;
begin
- exit( ZoomValue / cDefaultZoomLevel );
+ HW_zoomFactor:= ZoomValue / cDefaultZoomLevel;
end;
function HW_zoomLevel: LongInt; cdecl; export;
begin
- exit( trunc((ZoomValue - cDefaultZoomLevel) / cZoomDelta) );
+ HW_zoomLevel:= trunc((ZoomValue - cDefaultZoomLevel) / cZoomDelta);
end;
procedure HW_walkingKeysUp; cdecl; export;
@@ -189,7 +189,7 @@
function HW_isPaused: boolean; cdecl; export;
begin
- exit( isPaused );
+ HW_isPaused:= isPaused;
end;
// equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup
@@ -201,10 +201,9 @@
function HW_getSDLWindow: pointer; cdecl; export;
begin
+ HW_getSDLWindow:= nil;
{$IFDEF SDL13}
- exit( SDLwindow );
-{$ELSE}
- exit( nil );
+ HW_getSDLWindow:= SDLwindow;
{$ENDIF}
end;
@@ -224,45 +223,41 @@
// ammo menu related functions
function HW_isAmmoMenuOpen: boolean; cdecl; export;
begin
- exit( bShowAmmoMenu );
+ HW_isAmmoMenuOpen:= bShowAmmoMenu;
end;
function HW_isAmmoMenuNotAllowed: boolean; cdecl; export;
begin;
- exit( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil)
- or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) );
+ HW_isAmmoMenuNotAllowed:= ( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or
+ ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) );
end;
function HW_isWeaponRequiringClick: boolean; cdecl; export;
begin
+ HW_isWeaponRequiringClick:= false;
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
- exit( (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0 )
- else
- exit(false);
+ HW_isWeaponRequiringClick:= (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0;
end;
function HW_isWeaponTimerable: boolean; cdecl; export;
begin
+ HW_isWeaponTimerable:= false;
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
- exit( (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable) <> 0)
- else
- exit(false);
+ HW_isWeaponTimerable:= (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable) <> 0;
end;
function HW_isWeaponSwitch: boolean cdecl; export;
begin
+ HW_isWeaponSwitch:= false;
if (CurAmmoGear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
- exit(CurAmmoGear^.AmmoType = amSwitch)
- else
- exit(false)
+ HW_isWeaponSwitch:= (CurAmmoGear^.AmmoType = amSwitch);
end;
function HW_isWeaponRope: boolean cdecl; export;
begin
+ HW_isWeaponRope:= false
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
- exit(CurrentHedgehog^.CurAmmoType = amRope)
- else
- exit(false);
+ HW_isWeaponRope:= (CurrentHedgehog^.CurAmmoType = amRope);
end;
procedure HW_setGrenadeTime(time: LongInt); cdecl; export;
@@ -272,14 +267,13 @@
function HW_getGrenadeTime: LongInt; cdecl; export;
var CurWeapon: PAmmo;
- res: LongInt = 3;
begin
+ HW_getGrenadeTime:= 3;
if HW_isWeaponTimerable then
begin
CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^);
- res:= CurWeapon^.Timer div 1000;
+ HW_getGrenadeTime:= CurWeapon^.Timer div 1000;
end;
- exit(res);
end;
procedure HW_setPianoSound(snd: LongInt); cdecl; export;
@@ -302,22 +296,22 @@
function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export;
begin
- exit(str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId]));
+ HW_getWeaponNameByIndex:= (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId]));
end;
function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; export;
begin
- exit(str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId]));
+ HW_getWeaponCaptionByIndex:= (str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId]));
end;
function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl; export;
begin
- exit(str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId]));
+ HW_getWeaponDescriptionByIndex:= (str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId]));
end;
-function HW_getNumberOfWeapons:LongInt; cdecl; export;
+function HW_getNumberOfWeapons: LongInt; cdecl; export;
begin
- exit(ord(high(TAmmoType)));
+ HW_getNumberOfWeapons:= ord(high(TAmmoType));
end;
procedure HW_setWeapon(whichone: LongInt); cdecl; export;
@@ -329,26 +323,27 @@
function HW_isWeaponAnEffect(whichone: LongInt): boolean; cdecl; export;
begin
- exit(Ammoz[TAmmoType(whichone+1)].Ammo.Propz and ammoprop_Effect <> 0)
+ HW_isWeaponAnEffect:= Ammoz[TAmmoType(whichone+1)].Ammo.Propz and ammoprop_Effect <> 0;
end;
function HW_getAmmoCounts(counts: PLongInt): LongInt; cdecl; export;
var a : PHHAmmo;
- slot, index: LongInt;
+ slot, index, res: LongInt;
begin
+ HW_getAmmoCounts:= -1;
// nil check
if (CurrentHedgehog = nil) or (CurrentHedgehog^.Ammo = nil) or (CurrentTeam = nil) then
- exit(-1);
+ exit;
// hog controlled by opponent (net or ai)
if (CurrentTeam^.ExtDriven) or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then
- exit(1);
+ exit;
a:= CurrentHedgehog^.Ammo;
for slot:= 0 to cMaxSlotIndex do
for index:= 0 to cMaxSlotAmmoIndex do
if a^[slot,index].Count <> 0 then // yes, ammomenu is hell
counts[ord(a^[slot,index].AmmoType)-1]:= a^[slot,index].Count;
- exit(0);
+ HW_getAmmoCounts:= 0;
end;
procedure HW_getAmmoDelays (skipTurns: PByte); cdecl; export;
@@ -360,20 +355,19 @@
function HW_getTurnsForCurrentTeam: LongInt; cdecl; export;
begin
+ HW_getTurnsForCurrentTeam:= 0;
if (CurrentTeam <> nil) and (CurrentTeam^.Clan <> nil) then
- exit(CurrentTeam^.Clan^.TurnNumber)
- else
- exit(0);
+ HW_getTurnsForCurrentTeam:= CurrentTeam^.Clan^.TurnNumber;
end;
function HW_getMaxNumberOfHogs: LongInt; cdecl; export;
begin
- exit(cMaxHHIndex+1);
+ HW_getMaxNumberOfHogs:= cMaxHHIndex + 1;
end;
function HW_getMaxNumberOfTeams: LongInt; cdecl; export;
begin
- exit(cMaxTeams);
+ HW_getMaxNumberOfTeams:= cMaxTeams;
end;
procedure HW_memoryWarningCallback; cdecl; export;
--- a/hedgewars/SDLh.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/SDLh.pas Wed May 02 10:53:13 2012 +0100
@@ -1070,22 +1070,22 @@
if (name <> nil) and (namebuf <> nil) then
begin
strlcopy(namebuf, name, maxlen);
- exit(namebuf)
+ SDL_VideoDriverName:= namebuf
end;
- exit(name);
+ SDL_VideoDriverName:= name;
end;
function SDL_EnableUNICODE(enable: LongInt): LongInt;
begin
SDL_StartTextInput();
- exit(0);
+ SDL_EnableUNICODE:= 0;
end;
function SDL_EnableKeyRepeat(timedelay, interval: LongInt): LongInt;
begin
timedelay:= timedelay; // avoid hint
interval:= interval; // avoid hint
- exit(0);
+ SDL_EnableKeyRepeat:= 0;
end;
{$ELSE}
const conversionFormat: TSDL_PixelFormat = (
@@ -1098,7 +1098,7 @@
function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat;
begin
format:= format;
- exit(@conversionFormat);
+ SDL_AllocFormat:= @conversionFormat;
end;
procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat);
@@ -1120,7 +1120,7 @@
{$IFNDEF SDL_MIXER_NEWER}
function Mix_Init(flags: LongInt): LongInt;
begin
- exit(flags);
+ Mix_Init:= flags;
end;
procedure Mix_Quit;
@@ -1131,7 +1131,7 @@
{$IFNDEF SDL_IMAGE_NEWER}
function IMG_Init(flags: LongInt): LongInt;
begin
- exit(flags);
+ IMG_Init:= flags;
end;
procedure IMG_Quit;
--- a/hedgewars/uAIAmmoTests.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uAIAmmoTests.pas Wed May 02 10:53:13 2012 +0100
@@ -474,22 +474,22 @@
function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
//const tDelta = 24;
var Vx, Vy: real;
- Score, EX, EY, valueResult: LongInt;
+ Score, EX, EY: LongInt;
TestTime: Longword;
x, y, dY, meX, meY: real;
begin
-valueResult:= BadTurn;
+TestMortar:= BadTurn;
ap.ExplR:= 0;
meX:= hwFloat2Float(Me^.X);
meY:= hwFloat2Float(Me^.Y);
if (Level > 2) then
- exit(BadTurn);
+ exit;
TestTime:= Solve(Targ.X, Targ.Y, trunc(meX), trunc(meY));
if TestTime = 0 then
- exit(BadTurn);
+ exit;
Vx:= (Targ.X - meX) / TestTime;
Vy:= cGravityf * (TestTime div 2) - (Targ.Y - meY) / TestTime;
@@ -520,17 +520,15 @@
else
Score:= BadTurn;
- if valueResult < Score then
+ if BadTurn < Score then
begin
ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level));
ap.Power:= 1;
ap.ExplR:= 100;
ap.ExplX:= EX;
ap.ExplY:= EY;
- valueResult:= Score
+ TestMortar:= Score
end;
-
-TestMortar:= valueResult;
end;
function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
@@ -541,6 +539,7 @@
rx, ry, valueResult: LongInt;
range: integer;
begin
+TestShotgun:= BadTurn;
ap.ExplR:= 0;
ap.Time:= 0;
ap.Power:= 1;
@@ -548,7 +547,7 @@
y:= hwFloat2Float(Me^.Y);
range:= Metric(trunc(x), trunc(y), Targ.X, Targ.Y);
if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then
- exit(BadTurn);
+ exit;
Vx:= (Targ.X - x) * 1 / 1024;
Vy:= (Targ.Y - y) * 1 / 1024;
ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
@@ -558,16 +557,18 @@
rx:= trunc(x);
ry:= trunc(y);
if TestCollExcludingMe(Me, rx, ry, 2) then
- begin
+ begin
x:= x + vX * 8;
y:= y + vY * 8;
valueResult:= RateShotgun(Me, vX, vY, rx, ry);
- if valueResult = 0 then
- valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64
- else
- dec(valueResult, Level * 4000);
- exit(valueResult * 27 div 20) // 27/20 is reuse bonus
+ if valueResult = 0 then
+ valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64
+ else
+ dec(valueResult, Level * 4000);
+ // 27/20 is reuse bonus
+ TestShotgun:= valueResult * 27 div 20;
+ exit
end
until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 4)
or (x < 0)
@@ -591,7 +592,10 @@
x:= hwFloat2Float(Me^.X);
y:= hwFloat2Float(Me^.Y);
if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 40 then
- exit(BadTurn);
+begin
+ TestDesertEagle:= BadTurn;
+ exit;
+end;
t:= 0.5 / sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y));
Vx:= (Targ.X - x) * t;
Vy:= (Targ.Y - y) * t;
@@ -628,11 +632,12 @@
x, y: real;
begin
Level:= Level; // avoid compiler hint
+TestBaseballBat:= BadTurn;
ap.ExplR:= 0;
x:= hwFloat2Float(Me^.X);
y:= hwFloat2Float(Me^.Y);
if (Level > 2) or (Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) > 25) then
- exit(BadTurn);
+ exit;
ap.Time:= 0;
ap.Power:= 1;
@@ -670,7 +675,8 @@
val1:= Succ(BadTurn)
else
val1:= BadTurn;
- exit(val1)
+ TestFirePunch:= val1;
+ exit;
end;
(*
For some silly reason, having this enabled w/ the AI
@@ -718,7 +724,8 @@
valueResult:= Succ(BadTurn)
else
valueResult:= BadTurn;
- exit(valueResult)
+ TestWhip:= valueResult;
+ exit;
end;
valueResult:= 0;
@@ -762,7 +769,10 @@
ap.ExplR:= 0;
ap.Time:= 0;
if (Level > 3) then
- exit(BadTurn);
+begin
+ TestAirAttack:= BadTurn;
+ exit;
+end;
ap.AttackPutX:= Targ.X;
ap.AttackPutY:= Targ.Y;
@@ -826,7 +836,7 @@
maxTop: longword;
begin
TestTeleport := BadTurn;
- exit();
+ exit;
Level:= Level; // avoid compiler hint
//FillBonuses(true, [gtCase]);
if bonuses.Count = 0 then
--- a/hedgewars/uAIMisc.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uAIMisc.pas Wed May 02 10:53:13 2012 +0100
@@ -216,51 +216,64 @@
function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline;
var MeX, MeY: LongInt;
begin
+ TestCollExcludingMe:= false;
if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then
- begin
+ begin
MeX:= hwRound(Me^.X);
MeY:= hwRound(Me^.Y);
// We are still inside the hog. Skip radius test
if ((((x-MeX)*(x-MeX)) + ((y-MeY)*(y-MeY))) < 256) and ((Land[y, x] and $FF00) = 0) then
- exit(false);
- end;
- exit(TestColl(x, y, r))
+ exit;
+ end;
+ TestCollExcludingMe:= TestColl(x, y, r)
end;
function TestColl(x, y, r: LongInt): boolean; inline;
var b: boolean;
begin
-b:= (((x-r) and LAND_WIDTH_MASK) = 0)and(((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] <> 0);
-if b then
- exit(true);
+ TestColl:= true;
+
+ b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] <> 0);
+ if b then
+ exit;
+
+ b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] <> 0);
+ if b then
+ exit;
-b:=(((x-r) and LAND_WIDTH_MASK) = 0)and(((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] <> 0);
-if b then
- exit(true);
+ b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] <> 0);
+ if b then
+ exit;
-b:=(((x+r) and LAND_WIDTH_MASK) = 0)and(((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] <> 0);
-if b then
- exit(true);
+ b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] <> 0);
+ if b then
+ exit;
-TestColl:=(((x+r) and LAND_WIDTH_MASK) = 0)and(((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] <> 0)
+ TestColl:= false;
end;
function TestCollWithLand(x, y, r: LongInt): boolean; inline;
var b: boolean;
begin
-b:= (((x-r) and LAND_WIDTH_MASK) = 0)and(((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] > 255);
-if b then
- exit(true);
+ TestCollWithLand:= true;
-b:=(((x-r) and LAND_WIDTH_MASK) = 0)and(((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] > 255);
-if b then
- exit(true);
-
-b:=(((x+r) and LAND_WIDTH_MASK) = 0)and(((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] > 255);
-if b then
- exit(true);
-
-TestCollWithLand:=(((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] > 255)
+ b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] > 255);
+ if b then
+ exit;
+
+ b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] > 255);
+ if b then
+ exit;
+
+ b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] > 255);
+ if b then
+ exit;
+
+ b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] > 255);
+ if b then
+ exit;
+
+ TestCollWithLand:= false;
end;
function TraceFall(eX, eY: LongInt; x, y, dX, dY: Real; r: LongWord): LongInt;
@@ -274,44 +287,64 @@
// ok. attempt approximate search for an unbroken trajectory into water. if it continues far enough, assume out of map
rCorner:= r * 0.75;
while true do
- begin
+ begin
x:= x + dX;
y:= y + dY;
dY:= dY + cGravityf;
skipLandCheck:= skipLandCheck and (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner));
if not skipLandCheck and TestCollWithLand(trunc(x), trunc(y), cHHRadius) then
- begin
+ begin
if 0.4 < dY then
- begin
+ begin
dmg := 1 + trunc((abs(dY) - 0.4) * 70);
- if dmg >= 1 then exit(dmg)
+ if dmg >= 1 then
+ begin
+ TraceFall:= dmg;
+ exit
end;
- exit(0)
end;
- if (y > cWaterLine) or (x > 4096) or (x < 0) then exit(-1); // returning -1 for drowning so it can be considered in the Rate routine
+ TraceFall:= 0;
+ exit
end;
+ if (y > cWaterLine) or (x > 4096) or (x < 0) then
+ begin
+ // returning -1 for drowning so it can be considered in the Rate routine
+ TraceFall:= -1;
+ exit;
+ end;
+ end;
end;
function TraceShoveFall(Me: PGear; x, y, dX, dY: Real): LongInt;
var dmg: LongInt;
begin
while true do
- begin
+ begin
x:= x + dX;
y:= y + dY;
dY:= dY + cGravityf;
// consider adding dX/dY calc here for fall damage
if TestCollExcludingMe(Me, trunc(x), trunc(y), cHHRadius) then
- begin
+ begin
if 0.4 < dY then
- begin
+ begin
dmg := 1 + trunc((abs(dY) - 0.4) * 70);
- if dmg >= 1 then exit(dmg)
+ if dmg >= 1 then
+ begin
+ TraceShoveFall:= dmg;
+ exit
end;
- exit(0)
end;
- if (y > cWaterLine) or (x > 4096) or (x < 0) then exit(-1); // returning -1 for drowning so it can be considered in the Rate routine
+ TraceShoveFall:= 0;
+ exit
end;
+ if (y > cWaterLine) or (x > 4096) or (x < 0) then
+ begin
+ // returning -1 for drowning so it can be considered in the Rate routine
+ TraceShoveFall:= -1;
+ exit;
+ end;
+ end;
end;
// Flags are not defined yet but 1 for checking drowning and 2 for assuming land erasure.
@@ -495,95 +528,95 @@
function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;
var bX, bY: LongInt;
- bRes: boolean;
begin
-bRes:= false;
+HHJump:= false;
GoInfo.Ticks:= 0;
GoInfo.JumpType:= jmpNone;
bX:= hwRound(Gear^.X);
bY:= hwRound(Gear^.Y);
case JumpType of
- jmpNone:
- exit(bRes);
+ jmpNone: exit;
jmpHJump:
- if TestCollisionYwithGear(Gear, -1) = 0 then
+ if TestCollisionYwithGear(Gear, -1) = 0 then
begin
- Gear^.dY:= -_0_2;
- SetLittle(Gear^.dX);
- Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
+ Gear^.dY:= -_0_2;
+ SetLittle(Gear^.dX);
+ Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
end
else
- exit(bRes);
+ exit;
jmpLJump:
- begin
- if TestCollisionYwithGear(Gear, -1) <> 0 then
- if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then
- Gear^.Y:= Gear^.Y - int2hwFloat(2)
- else
- if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then
- Gear^.Y:= Gear^.Y - _1;
- if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
- or (TestCollisionYwithGear(Gear, -1) <> 0)) then
+ begin
+ if TestCollisionYwithGear(Gear, -1) <> 0 then
+ if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then
+ Gear^.Y:= Gear^.Y - int2hwFloat(2)
+ else
+ if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then
+ Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) or
+ (TestCollisionYwithGear(Gear, -1) <> 0)) then
begin
- Gear^.dY:= -_0_15;
- Gear^.dX:= SignAs(_0_15, Gear^.dX);
- Gear^.State:= Gear^.State or gstMoving or gstHHJumping
+ Gear^.dY:= -_0_15;
+ Gear^.dX:= SignAs(_0_15, Gear^.dX);
+ Gear^.State:= Gear^.State or gstMoving or gstHHJumping
end
else
- exit(bRes)
- end
- end;
+ exit
+ end
+end;
repeat
if not (hwRound(Gear^.Y) + cHHRadius < cWaterLine) then
- exit(bRes);
+ exit;
if (Gear^.State and gstMoving) <> 0 then
- begin
+ begin
if (GoInfo.Ticks = 350) then
if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then
- begin
+ begin
Gear^.dY:= -_0_25;
Gear^.dX:= SignAs(_0_02, Gear^.dX)
- end;
- if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX);
- Gear^.X:= Gear^.X + Gear^.dX;
- inc(GoInfo.Ticks);
- Gear^.dY:= Gear^.dY + cGravity;
- if Gear^.dY > _0_4 then
- exit(bRes);
- if (Gear^.dY.isNegative)and (TestCollisionYwithGear(Gear, -1) <> 0) then
- Gear^.dY:= _0;
- Gear^.Y:= Gear^.Y + Gear^.dY;
- if (not Gear^.dY.isNegative)and (TestCollisionYwithGear(Gear, 1) <> 0) then
+ end;
+ if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX);
+ Gear^.X:= Gear^.X + Gear^.dX;
+ inc(GoInfo.Ticks);
+ Gear^.dY:= Gear^.dY + cGravity;
+ if Gear^.dY > _0_4 then
+ exit;
+ if (Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, -1) <> 0) then
+ Gear^.dY:= _0;
+ Gear^.Y:= Gear^.Y + Gear^.dY;
+ if (not Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, 1) <> 0) then
begin
- Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping);
- Gear^.dY:= _0;
- case JumpType of
- jmpHJump:
- if bY - hwRound(Gear^.Y) > 5 then
- begin
- bRes:= true;
- GoInfo.JumpType:= jmpHJump;
- inc(GoInfo.Ticks, 300 + 300) // 300 before jump, 300 after
- end;
- jmpLJump: if abs(bX - hwRound(Gear^.X)) > 30 then
- begin
- bRes:= true;
- GoInfo.JumpType:= jmpLJump;
- inc(GoInfo.Ticks, 300 + 300) // 300 before jump, 300 after
- end
- end;
- exit(bRes)
+ Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping);
+ Gear^.dY:= _0;
+ case JumpType of
+ jmpHJump:
+ if bY - hwRound(Gear^.Y) > 5 then
+ begin
+ HHJump:= true;
+ GoInfo.JumpType:= jmpHJump;
+ inc(GoInfo.Ticks, 300 + 300) // 300 before jump, 300 after
+ end;
+ jmpLJump:
+ if abs(bX - hwRound(Gear^.X)) > 30 then
+ begin
+ HHJump:= true;
+ GoInfo.JumpType:= jmpLJump;
+ inc(GoInfo.Ticks, 300 + 300) // 300 before jump, 300 after
+ end
end;
+ exit
end;
+ end;
until false
end;
function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
var pX, pY: LongInt;
begin
+HHGo:= false;
AltGear^:= Gear^;
GoInfo.Ticks:= 0;
@@ -593,7 +626,7 @@
pX:= hwRound(Gear^.X);
pY:= hwRound(Gear^.Y);
if pY + cHHRadius >= cWaterLine then
- exit(false);
+ exit;
if (Gear^.State and gstMoving) <> 0 then
begin
inc(GoInfo.Ticks);
@@ -602,7 +635,7 @@
begin
Goinfo.FallPix:= 0;
HHJump(AltGear, jmpLJump, GoInfo); // try ljump instead of fall with damage
- exit(false)
+ exit
end;
Gear^.Y:= Gear^.Y + Gear^.dY;
if hwRound(Gear^.Y) > pY then
@@ -613,7 +646,8 @@
Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping);
Gear^.dY:= _0;
HHJump(AltGear, jmpLJump, GoInfo); // try ljump instead of fall
- exit(true)
+ HHGo:= true;
+ exit
end;
continue
end;
@@ -621,9 +655,9 @@
Gear^.dX:= -cLittle
else
if (Gear^.Message and gmRight )<>0 then
- Gear^.dX:= cLittle
+ Gear^.dX:= cLittle
else
- exit(false);
+ exit;
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
begin
if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))
@@ -651,17 +685,18 @@
end;
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
- begin
+ begin
Gear^.X:= Gear^.X + int2hwFloat(hwSign(Gear^.dX));
inc(GoInfo.Ticks, cHHStepTicks)
- end;
-
+ end;
+
+ // too scared to reformat this part
if TestCollisionYwithGear(Gear, 1) = 0 then
begin
Gear^.Y:= Gear^.Y + _1;
if TestCollisionYwithGear(Gear, 1) = 0 then
- begin
+ begin
Gear^.Y:= Gear^.Y + _1;
if TestCollisionYwithGear(Gear, 1) = 0 then
@@ -693,10 +728,12 @@
end
end;
if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then
- exit(true);
+begin
+ HHGo:= true;
+ exit;
+end;
until (pX = hwRound(Gear^.X)) and (pY = hwRound(Gear^.Y)) and ((Gear^.State and gstMoving) = 0);
HHJump(AltGear, jmpHJump, GoInfo);
-HHGo:= false;
end;
function AIrndSign(num: LongInt): LongInt;
--- a/hedgewars/uAmmos.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uAmmos.pas Wed May 02 10:53:13 2012 +0100
@@ -145,13 +145,13 @@
function GetAmmoByNum(num: Longword): PHHAmmo;
begin
-TryDo(num < StoreCnt, 'Invalid store number', true);
-exit(StoresList[num])
+ TryDo(num < StoreCnt, 'Invalid store number', true);
+ GetAmmoByNum:= StoresList[num]
end;
function GetCurAmmoEntry(var Hedgehog: THedgehog): PAmmo;
begin
-GetCurAmmoEntry:= GetAmmoEntry(Hedgehog, Hedgehog.CurAmmoType)
+ GetCurAmmoEntry:= GetAmmoEntry(Hedgehog, Hedgehog.CurAmmoType)
end;
function GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo;
@@ -280,18 +280,21 @@
function HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): LongWord;
var slot, ami: LongInt;
begin
-Slot:= Ammoz[Ammo].Slot;
-ami:= 0;
-while (ami <= cMaxSlotAmmoIndex) do
- begin
+ HHHasAmmo:= 0;
+ Slot:= Ammoz[Ammo].Slot;
+ ami:= 0;
+ while (ami <= cMaxSlotAmmoIndex) do
+ begin
with Hedgehog.Ammo^[Slot, ami] do
if (AmmoType = Ammo) then
if Hedgehog.Team^.Clan^.TurnNumber > Ammoz[AmmoType].SkipTurns then
- exit(Count)
- else exit(0);
- inc(ami)
- end;
-HHHasAmmo:= 0
+ begin
+ HHHasAmmo:= Count;
+ exit;
+ end
+ else exit;
+ inc(ami)
+ end;
end;
procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType);
--- a/hedgewars/uCollisions.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uCollisions.pas Wed May 02 10:53:13 2012 +0100
@@ -155,6 +155,8 @@
x:= x - Gear^.Radius
else
x:= x + Gear^.Radius;
+
+TestCollisionXwithGear:= true;
if (x and LAND_WIDTH_MASK) = 0 then
begin
y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
@@ -162,7 +164,7 @@
repeat
if (y and LAND_HEIGHT_MASK) = 0 then
if Land[y, x] > TestWord then
- exit(true);
+ exit;
inc(y)
until (y > i);
end;
@@ -198,7 +200,10 @@
repeat
if (x and LAND_WIDTH_MASK) = 0 then
if Land[y, x] > TestWord then
- exit(Land[y, x]);
+ begin
+ TestCollisionYwithGear:= Land[y, x];
+ exit;
+ end;
inc(x)
until (x > i);
end;
@@ -215,6 +220,8 @@
x:= x - Gear^.Radius
else
x:= x + Gear^.Radius;
+
+TestCollisionXKick:= true;
if (x and LAND_WIDTH_MASK) = 0 then
begin
y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
@@ -222,7 +229,7 @@
repeat
if (y and LAND_HEIGHT_MASK) = 0 then
if Land[y, x] > 255 then
- exit(true)
+ exit
else if Land[y, x] <> 0 then
flag:= true;
inc(y)
@@ -257,7 +264,8 @@
Active:= true
end;
DeleteCI(cGear);
- exit(false)
+ TestCollisionXKick:= false;
+ exit;
end
end
end;
@@ -272,6 +280,8 @@
y:= y - Gear^.Radius
else
y:= y + Gear^.Radius;
+
+TestCollisionYKick:= true;
if (y and LAND_HEIGHT_MASK) = 0 then
begin
x:= hwRound(Gear^.X) - Gear^.Radius + 1;
@@ -280,7 +290,7 @@
if (x and LAND_WIDTH_MASK) = 0 then
if Land[y, x] > 0 then
if Land[y, x] > 255 then
- exit(true)
+ exit
else if Land[y, x] <> 0 then
flag:= true;
inc(x)
@@ -291,10 +301,8 @@
if flag then
begin
if hwAbs(Gear^.dY) < cHHKick then
- exit(true);
- if (Gear^.State and gstHHJumping <> 0)
- and (not Gear^.dY.isNegative)
- and (Gear^.dY < _0_4) then
+ exit;
+ if (Gear^.State and gstHHJumping <> 0) and (not Gear^.dY.isNegative) and (Gear^.dY < _0_4) then
exit;
mx:= hwRound(Gear^.X);
@@ -315,7 +323,8 @@
Active:= true
end;
DeleteCI(cGear);
- exit(false)
+ TestCollisionYKick:= false;
+ exit
end
end
end;
@@ -335,6 +344,7 @@
Gear^.X:= Gear^.X - ShiftX;
Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
end;
+
function TestCollisionX(Gear: PGear; Dir: LongInt): boolean;
var x, y, i: LongInt;
begin
@@ -343,6 +353,8 @@
x:= x - Gear^.Radius
else
x:= x + Gear^.Radius;
+
+TestCollisionX:= true;
if (x and LAND_WIDTH_MASK) = 0 then
begin
y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
@@ -350,7 +362,7 @@
repeat
if (y and LAND_HEIGHT_MASK) = 0 then
if Land[y, x] > 255 then
- exit(true);
+ exit;
inc(y)
until (y > i);
end;
@@ -365,6 +377,8 @@
y:= y - Gear^.Radius
else
y:= y + Gear^.Radius;
+
+TestCollisionY:= true;
if (y and LAND_HEIGHT_MASK) = 0 then
begin
x:= hwRound(Gear^.X) - Gear^.Radius + 1;
@@ -372,7 +386,7 @@
repeat
if (x and LAND_WIDTH_MASK) = 0 then
if Land[y, x] > 255 then
- exit(true);
+ exit;
inc(x)
until (x > i);
end;
@@ -402,33 +416,34 @@
var x, y: LongInt;
TestWord: LongWord;
begin
+TestRectancleForObstacle:= true;
+
if landOnly then
TestWord:= 255
else
TestWord:= 0;
if x1 > x2 then
- begin
+begin
x := x1;
x1 := x2;
x2 := x;
- end;
+end;
if y1 > y2 then
- begin
+begin
y := y1;
y1 := y2;
y2 := y;
- end;
+end;
if (hasBorder and ((y1 < 0) or (x1 < 0) or (x2 > LAND_WIDTH))) then
- exit(true);
+ exit;
for y := y1 to y2 do
for x := x1 to x2 do
- if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0)
- and (Land[y, x] > TestWord) then
- exit(true);
+ if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] > TestWord) then
+ exit;
TestRectancleForObstacle:= false
end;
@@ -442,6 +457,8 @@
isColl: Boolean;
begin
+ CalcSlopeTangent:= false;
+
dx:= Gear^.dX;
dy:= Gear^.dY;
@@ -566,11 +583,11 @@
ldy:= rdy - ldy;
if ((ldx = 0) and (ldy = 0)) then
- EXIT(false);
+ exit;
outDeltaX:= ldx;
outDeltaY:= ldy;
-exit(true);
+CalcSlopeTangent:= true;
end;
function CalcSlopeBelowGear(Gear: PGear): hwFloat;
--- a/hedgewars/uConsole.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uConsole.pas Wed May 02 10:53:13 2012 +0100
@@ -97,7 +97,7 @@
if Length(s) = High(s) then
Dec(s[0]);
s[Ord(Length(s))+1] := #0;
- exit(@s[1]);
+ ShortStringAsPChar:= @s[1];
end;
function GetLastConsoleLine: shortstring;
--- a/hedgewars/uGearsUtils.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uGearsUtils.pas Wed May 02 10:53:13 2012 +0100
@@ -473,21 +473,25 @@
var i: LongInt;
count: LongInt = 0;
begin
-if (y and LAND_HEIGHT_MASK) = 0 then
- for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do
- if Land[y, i] <> 0 then
+ if (y and LAND_HEIGHT_MASK) = 0 then
+ for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do
+ if Land[y, i] <> 0 then
begin
- inc(count);
- if count = c then
- exit(count)
+ inc(count);
+ if count = c then
+ begin
+ CountNonZeroz:= count;
+ exit
+ end;
end;
-CountNonZeroz:= count;
+ CountNonZeroz:= count;
end;
function NoGearsToAvoid(mX, mY: LongInt; rX, rY: LongInt): boolean;
var t: PGear;
begin
+NoGearsToAvoid:= false;
t:= GearsList;
rX:= sqr(rX);
rY:= sqr(rY);
@@ -495,7 +499,7 @@
begin
if t^.Kind <= gtExplosives then
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then
- exit(false);
+ exit;
t:= t^.NextGear
end;
NoGearsToAvoid:= true
@@ -606,7 +610,10 @@
begin
if (t <> Gear) and (t^.Kind = Kind) then
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then
- exit(t);
+ begin
+ CheckGearNear:= t;
+ exit;
+ end;
t:= t^.NextGear
end;
--- a/hedgewars/uLandGraphics.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uLandGraphics.pas Wed May 02 10:53:13 2012 +0100
@@ -672,6 +672,7 @@
p: PByteArray;
Image: PSDL_Surface;
begin
+TryPlaceOnLand:= false;
numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height;
TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true);
@@ -693,12 +694,12 @@
begin
for x:= 0 to Pred(w) do
if (PLongword(@(p^[x * 4]))^) <> 0 then
- if ((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT)
- or ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or (Land[cpY + y, cpX + x] <> 0) then
+ if ((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
+ ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or (Land[cpY + y, cpX + x] <> 0) then
begin
- if SDL_MustLock(Image) then
- SDL_UnlockSurface(Image);
- exit(false)
+ if SDL_MustLock(Image) then
+ SDL_UnlockSurface(Image);
+ exit;
end;
p:= @(p^[Image^.pitch]);
end;
@@ -758,58 +759,61 @@
var nx, ny, i, j, c, xx, yy: LongInt;
pixelsweep: boolean;
begin
-if (cReducedQuality and rqBlurryLand) = 0 then
+ Despeckle:= true;
+
+ if (cReducedQuality and rqBlurryLand) = 0 then
begin
- xx:= X;
- yy:= Y;
+ xx:= X;
+ yy:= Y;
end
-else
+ else
begin
- xx:= X div 2;
- yy:= Y div 2;
+ xx:= X div 2;
+ yy:= Y div 2;
end;
-pixelsweep:= ((Land[Y, X] and $FF00) = 0) and (LandPixels[yy, xx] <> 0);
-if (((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0)) or pixelsweep then
+
+ pixelsweep:= ((Land[Y, X] and $FF00) = 0) and (LandPixels[yy, xx] <> 0);
+ if (((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0)) or pixelsweep then
begin
- c:= 0;
- for i:= -1 to 1 do
- for j:= -1 to 1 do
- if (i <> 0) or (j <> 0) then
+ c:= 0;
+ for i:= -1 to 1 do
+ for j:= -1 to 1 do
+ if (i <> 0) or (j <> 0) then
begin
- ny:= Y + i;
- nx:= X + j;
- if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then
+ ny:= Y + i;
+ nx:= X + j;
+ if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then
begin
- if pixelsweep then
+ if pixelsweep then
begin
- if ((cReducedQuality and rqBlurryLand) <> 0) then
+ if ((cReducedQuality and rqBlurryLand) <> 0) then
begin
- nx:= nx div 2;
- ny:= ny div 2
+ nx:= nx div 2;
+ ny:= ny div 2
end;
- if LandPixels[ny, nx] <> 0 then
- inc(c);
+ if LandPixels[ny, nx] <> 0 then
+ inc(c);
end
else if Land[ny, nx] > 255 then
inc(c);
end
end;
- if c < 4 then // 0-3 neighbours
+ if c < 4 then // 0-3 neighbours
begin
- if ((Land[Y, X] and lfBasic) <> 0) and (not disableLandBack) then
- LandPixels[yy, xx]:= LandBackPixel(X, Y)
- else
- LandPixels[yy, xx]:= 0;
+ if ((Land[Y, X] and lfBasic) <> 0) and (not disableLandBack) then
+ LandPixels[yy, xx]:= LandBackPixel(X, Y)
+ else
+ LandPixels[yy, xx]:= 0;
- if not pixelsweep then
+ if not pixelsweep then
begin
- Land[Y, X]:= 0;
- exit(true)
+ Land[Y, X]:= 0;
+ exit
end
end;
end;
-Despeckle:= false
+ Despeckle:= false
end;
procedure Smooth(X, Y: LongInt);
--- a/hedgewars/uLandObjects.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uLandObjects.pas Wed May 02 10:53:13 2012 +0100
@@ -301,11 +301,12 @@
cnt, i: Longword;
bRes: boolean;
begin
+TryPut:= false;
cnt:= 0;
with Obj do
begin
if Maxcnt = 0 then
- exit(false);
+ exit;
x:= 0;
repeat
y:= topY+32; // leave room for a hedgie to teleport in
@@ -346,11 +347,12 @@
r: TSDL_Rect;
bRes: boolean;
begin
+TryPut:= false;
cnt:= 0;
with Obj do
begin
if Maxcnt = 0 then
- exit(false);
+ exit;
x:= 0;
r.x:= 0;
r.y:= 0;
--- a/hedgewars/uLandOutline.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uLandOutline.pas Wed May 02 10:53:13 2012 +0100
@@ -220,47 +220,49 @@
function CheckIntersect(V1, V2, V3, V4: TPoint): boolean;
var c1, c2, dm: LongInt;
begin
+ CheckIntersect:= false;
dm:= (V4.y - V3.y) * (V2.x - V1.x) - (V4.x - V3.x) * (V2.y - V1.y);
c1:= (V4.x - V3.x) * (V1.y - V3.y) - (V4.y - V3.y) * (V1.x - V3.x);
if dm = 0 then
- exit(false);
+ exit;
+ CheckIntersect:= true;
c2:= (V2.x - V3.x) * (V1.y - V3.y) - (V2.y - V3.y) * (V1.x - V3.x);
if dm > 0 then
- begin
+ begin
if (c1 < 0) or (c1 > dm) then
- exit(false);
- if (c2 < 0) or (c2 > dm) then
- exit(false)
- end
+ CheckIntersect:= false
+ else if (c2 < 0) or (c2 > dm) then
+ CheckIntersect:= false;
+ end
else
- begin
+ begin
if (c1 > 0) or (c1 < dm) then
- exit(false);
- if (c2 > 0) or (c2 < dm) then
- exit(false)
- end;
+ CheckIntersect:= false
+ else if (c2 > 0) or (c2 < dm) then
+ CheckIntersect:= false;
+ end;
//AddFileLog('1 (' + inttostr(V1.x) + ',' + inttostr(V1.y) + ')x(' + inttostr(V2.x) + ',' + inttostr(V2.y) + ')');
//AddFileLog('2 (' + inttostr(V3.x) + ',' + inttostr(V3.y) + ')x(' + inttostr(V4.x) + ',' + inttostr(V4.y) + ')');
- CheckIntersect:= true
end;
function CheckSelfIntersect(var pa: TPixAr; ind: Longword): boolean;
var i: Longword;
begin
+ CheckSelfIntersect:= false;
if (ind <= 0) or (ind >= Pred(pa.Count)) then
- exit(false);
+ exit;
+
+ CheckSelfIntersect:= true;
for i:= 1 to pa.Count - 3 do
if (i <= ind - 1) or (i >= ind + 2) then
begin
- if (i <> ind - 1) and
- CheckIntersect(pa.ar[ind], pa.ar[ind - 1], pa.ar[i], pa.ar[i - 1]) then
- exit(true);
- if (i <> ind + 2) and
- CheckIntersect(pa.ar[ind], pa.ar[ind + 1], pa.ar[i], pa.ar[i - 1]) then
- exit(true);
+ if (i <> ind - 1) and CheckIntersect(pa.ar[ind], pa.ar[ind - 1], pa.ar[i], pa.ar[i - 1]) then
+ exit;
+ if (i <> ind + 2) and CheckIntersect(pa.ar[ind], pa.ar[ind + 1], pa.ar[i], pa.ar[i - 1]) then
+ exit;
end;
CheckSelfIntersect:= false
end;
--- a/hedgewars/uMisc.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uMisc.pas Wed May 02 10:53:13 2012 +0100
@@ -23,6 +23,9 @@
uses SDLh, uConsts, GLunit, uTypes;
+procedure initModule;
+procedure freeModule;
+
procedure movecursor(dx, dy: LongInt);
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
function MakeScreenshot(filename: shortstring): boolean;
@@ -32,8 +35,6 @@
{$ELSE}
function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect;
{$ENDIF}
-procedure initModule;
-procedure freeModule;
implementation
uses typinfo, sysutils, uVariables, uUtils
@@ -74,7 +75,8 @@
if png_ptr = nil then
begin
// AddFileLog('Error: Could not create png write struct.');
- exit(0);
+ SaveScreenshot:= 0;
+ exit;
end;
info_ptr := png_create_info_struct(png_ptr);
@@ -82,7 +84,8 @@
begin
png_destroy_write_struct(@png_ptr, nil);
// AddFileLog('Error: Could not create png info struct.');
- exit(0);
+ SaveScreenshot:= 0;
+ exit;
end;
{$IOCHECKS OFF}
@@ -209,7 +212,8 @@
if p = nil then
begin
AddFileLog('Error: Could not allocate memory for screenshot.');
- exit(false);
+ MakeScreenshot:= false;
+ exit;
end;
// read pixel from the front buffer
@@ -235,15 +239,14 @@
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
var convertedSurf: PSDL_Surface;
begin
+ doSurfaceConversion:= tmpsurf;
if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
(tmpsurf^.format^.bitsperpixel = 24) then
begin
convertedSurf:= SDL_ConvertSurface(tmpsurf, conversionFormat, SDL_SWSURFACE);
SDL_FreeSurface(tmpsurf);
- exit(convertedSurf);
+ doSurfaceConversion:= convertedSurf;
end;
-
- exit(tmpsurf);
end;
{$IFDEF SDL13}
--- a/hedgewars/uMobile.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uMobile.pas Wed May 02 10:53:13 2012 +0100
@@ -44,18 +44,15 @@
// this function is just to determine whether we are running on a limited screen device
function isPhone: Boolean; inline;
begin
+ isPhone:= false;
{$IFDEF IPHONEOS}
- exit(isApplePhone());
+ isPhone:= isApplePhone();
{$ENDIF}
{$IFDEF ANDROID}
//nasty nasty hack. TODO: implement callback to java to have a unified way of determining if it is a tablet
if (cScreenWidth < 1000) and (cScreenHeight < 500) then
- begin
- exit(true);
- end
- else exit(false);
+ isPhone:= true;
{$ENDIF}
- exit(false);
end;
// this function should make the device vibrate in some way
--- a/hedgewars/uSound.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uSound.pas Wed May 02 10:53:13 2012 +0100
@@ -468,8 +468,9 @@
function ChangeVolume(voldelta: LongInt): LongInt;
begin
+ ChangeVolume:= 0;
if not isSoundEnabled then
- exit(0);
+ exit;
inc(Volume, voldelta);
if Volume < 0 then
@@ -483,8 +484,8 @@
procedure DampenAudio;
begin
-previousVolume:= Volume;
-ChangeVolume(-Volume * 7 div 9);
+ previousVolume:= Volume;
+ ChangeVolume(-Volume * 7 div 9);
end;
procedure UndampenAudio;
--- a/hedgewars/uStore.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uStore.pas Wed May 02 10:53:13 2012 +0100
@@ -524,28 +524,30 @@
Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16)
end;
-function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
+function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
var tmpsurf: PSDL_Surface;
s: shortstring;
begin
-WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
+ LoadImage:= nil;
+ WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
-s:= filename + '.png';
-tmpsurf:= IMG_Load(Str2PChar(s));
+ s:= filename + '.png';
+ tmpsurf:= IMG_Load(Str2PChar(s));
if tmpsurf = nil then
- begin
+ begin
OutError(msgFailed, (imageFlags and ifCritical) <> 0);
- exit(nil)
- end;
+ exit;
+ end;
if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
- begin
+ begin
SDL_FreeSurface(tmpsurf);
OutError(msgFailedSize, (imageFlags and ifCritical) <> 0);
// dummy surface to replace non-critical textures that failed to load due to their size
- exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask));
- end;
+ LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask);
+ exit;
+ end;
tmpsurf:= doSurfaceConversion(tmpsurf);
--- a/hedgewars/uTeams.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uTeams.pas Wed May 02 10:53:13 2012 +0100
@@ -46,6 +46,7 @@
s: shortstring;
t, AliveCount, i, j: LongInt;
begin
+CheckForWin:= false;
AliveCount:= 0;
for t:= 0 to Pred(ClansCount) do
if ClansArray[t]^.ClanHealth > 0 then
@@ -54,9 +55,8 @@
AliveClan:= ClansArray[t]
end;
-if (AliveCount > 1)
-or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then
- exit(false);
+if (AliveCount > 1) or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then
+ exit;
CheckForWin:= true;
TurnTimeLeft:= 0;
--- a/hedgewars/uUtils.pas Wed May 02 11:28:38 2012 +0200
+++ b/hedgewars/uUtils.pas Wed May 02 10:53:13 2012 +0100
@@ -296,12 +296,13 @@
u: WideChar;
tmpstr: array[0..256] of WideChar;
begin
+CheckCJKFont:= font;
{$IFNDEF MOBILE}
// remove chinese fonts for now
if (font >= CJKfnt16) or (length(s) = 0) then
{$ENDIF}
- exit(font);
+ exit;
l:= Utf8ToUnicode(@tmpstr, Str2PChar(s), length(s))-1;
i:= 0;
@@ -320,10 +321,13 @@
((#$AC00 <= u) and (u <= #$D7AF)) or // Hangul Syllables
((#$F900 <= u) and (u <= #$FAFF)) or // CJK Compatibility Ideographs
((#$FE30 <= u) and (u <= #$FE4F))) // CJK Compatibility Forms
- then exit(THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) ));
+ then
+ begin
+ CheckCJKFont:= THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) );
+ exit;
+ end;
inc(i)
end;
-exit(font);
(* two more to check. pascal WideChar is only 16 bit though
((#$20000 <= u) and (u >= #$2A6DF)) or // CJK Unified Ideographs Extension B
((#$2F800 <= u) and (u >= #$2FA1F))) // CJK Compatibility Ideographs Supplement *)