marked a couple of functions as inline
resolved all warnings/hints/notes
added -Ooregvar optimisation (stores frequently used variables in registers, saving ~30k code size)
--- a/CMakeLists.txt Wed May 02 12:24:44 2012 +0200
+++ b/CMakeLists.txt Wed May 02 11:43:43 2012 +0100
@@ -159,7 +159,7 @@
if(Optz)
# set(pascal_compiler_flags_cmn "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_compiler_flags_cmn})
- set(pascal_compiler_flags_cmn "-Os" "-Xs" "-Si" ${pascal_compiler_flags_cmn})
+ set(pascal_compiler_flags_cmn "-Os" "-Ooregvar" "-Xs" "-Si" ${pascal_compiler_flags_cmn})
set(haskell_compiler_flags_cmn "-w" "-fno-warn-unused-do-bind" ${haskell_compiler_flags_cmn})
else(Optz)
set(pascal_compiler_flags_cmn "-O-" "-g" "-gl" "-gv" "-dDEBUGFILE" ${pascal_compiler_flags_cmn})
--- a/hedgewars/CMakeLists.txt Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/CMakeLists.txt Wed May 02 11:43:43 2012 +0100
@@ -64,7 +64,6 @@
uWorld.pas
GSHandlers.inc
VGSHandlers.inc
- HHHandlers.inc
ArgParsers.inc
options.inc
adler32.pas
--- a/hedgewars/GSHandlers.inc Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/GSHandlers.inc Wed May 02 11:43:43 2012 +0100
@@ -2715,7 +2715,7 @@
procedure doStepSwitcherWork(Gear: PGear);
var
HHGear: PGear;
- Msg, State: Longword;
+ State: Longword;
begin
AllInactive := false;
--- a/hedgewars/HHHandlers.inc Wed May 02 12:24:44 2012 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-(*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *)
-
-////////////////////////////////////////////////////////////////////////////////
--- a/hedgewars/uAI.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uAI.pas Wed May 02 11:43:43 2012 +0100
@@ -291,7 +291,8 @@
function Think(Me: Pointer): ptrint;
var BackMe, WalkMe: TGear;
- StartTicks, currHedgehogIndex, itHedgehog, switchesNum, i, switchCount: Longword;
+ switchCount: LongInt;
+ StartTicks, currHedgehogIndex, itHedgehog, switchesNum, i: Longword;
switchImmediatelyAvailable: boolean;
Actions: TActions;
begin
@@ -319,7 +320,7 @@
if not switchImmediatelyAvailable then
begin
// when AI has to use switcher, make it cost smth unless they have a lot of switches
- if (SwitchCount < 10) then Actions.Score:= (-27+SwitchCount*3)*4000;
+ if (switchCount < 10) then Actions.Score:= (-27+switchCount*3)*4000;
AddAction(Actions, aia_Weapon, Longword(amSwitch), 300 + random(200), 0, 0);
AddAction(Actions, aia_attack, aim_push, 300 + random(300), 0, 0);
AddAction(Actions, aia_attack, aim_release, 1, 0, 0);
--- a/hedgewars/uAIAmmoTests.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uAIAmmoTests.pas Wed May 02 11:43:43 2012 +0100
@@ -646,7 +646,7 @@
else
ap.Angle:= - cMaxAngle div 4;
-valueResult:= RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x), trunc(y), 15, 30, 115, hwSign(Me^.dX)*0.353, -0.353, 1);
+valueResult:= RateShove(Me, trunc(x) + LongWord(10*hwSignf(Targ.X - x)), trunc(y), 15, 30, 115, hwSign(Me^.dX)*0.353, -0.353, 1);
if valueResult <= 0 then
valueResult:= BadTurn
else
@@ -655,7 +655,7 @@
end;
function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
-var i, val1, val2, t: LongInt;
+var val1: LongInt;
x, y: real;
begin
Level:= Level; // avoid compiler hint
@@ -670,7 +670,7 @@
begin
// TODO - find out WTH this works.
if TestColl(trunc(x), trunc(y) - 16, 6) and
- (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX),
+ (RateShove(Me, trunc(x) + LongWord(10 * hwSign(Me^.dX)),
trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX)*0.45, -0.9, 1) = 0) then
val1:= Succ(BadTurn)
else
@@ -720,7 +720,7 @@
or (Abs(trunc(y) - 50 - Targ.Y) > 50) then
begin
if TestColl(trunc(x), trunc(y) - 16, 6)
- and (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX), trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX), -0.8, 1) = 0) then
+ and (RateShove(Me, trunc(x) + LongWord(10 * hwSign(Me^.dX)), trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX), -0.8, 1) = 0) then
valueResult:= Succ(BadTurn)
else
valueResult:= BadTurn;
@@ -730,8 +730,8 @@
valueResult:= 0;
for i:= 0 to 4 do
- valueResult:= valueResult + RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x),
- trunc(y) - 20 * i - 5, 10, 30, 40, hwSign(Me^.dX), -0.8, 1);
+ valueResult:= valueResult + RateShove(Me, trunc(x) + LongWord(10 * hwSignf(Targ.X - x)),
+ trunc(y) - LongWord(20 * i) - 5, 10, 30, 40, hwSign(Me^.dX), -0.8, 1);
if valueResult <= 0 then
valueResult:= BadTurn
else
@@ -800,10 +800,10 @@
if b[i] then
begin
fexit:= false;
- if TestColl(trunc(X) + i * 30, trunc(Y), 4) then
+ if TestColl(trunc(X) + LongWord(i * 30), trunc(Y), 4) then
begin
b[i]:= false;
- dmg[i]:= RateExplosion(Me, trunc(X) + i * 30, trunc(Y), 58)
+ dmg[i]:= RateExplosion(Me, trunc(X) + LongWord(i * 30), trunc(Y), 58)
// 58 (instead of 60) for better prediction (hh moves after explosion of one of the rockets)
end
end;
--- a/hedgewars/uCollisions.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uCollisions.pas Wed May 02 11:43:43 2012 +0100
@@ -59,7 +59,7 @@
function CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): Boolean;
implementation
-uses uConsts, uLandGraphics, uVariables, uDebug, uGears, uGearsList;
+uses uConsts, uLandGraphics, uVariables, uDebug, uGearsList;
type TCollisionEntry = record
X, Y, Radius: LongInt;
--- a/hedgewars/uCommands.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uCommands.pas Wed May 02 11:43:43 2012 +0100
@@ -68,8 +68,7 @@
procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
-var ii: LongInt;
- s: shortstring;
+var s: shortstring;
t: PVariable;
c: char;
begin
--- a/hedgewars/uGears.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uGears.pas Wed May 02 11:43:43 2012 +0100
@@ -999,6 +999,7 @@
var t, aTot: LongInt;
i: TAmmoType;
begin
+Hedgehog:= Hedgehog; // avoid hint
aTot:= 0;
for i:= Low(TAmmoType) to High(TAmmoType) do
--- a/hedgewars/uGearsHedgehog.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uGearsHedgehog.pas Wed May 02 11:43:43 2012 +0100
@@ -30,7 +30,7 @@
procedure PickUp(HH, Gear: PGear);
implementation
-uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, uMisc,
+uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions,
uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript,
uGearsList, uGears, uCollisions, uRandom, uStore, uTeams,
uGearsUtils;
--- a/hedgewars/uInputHandler.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uInputHandler.pas Wed May 02 11:43:43 2012 +0100
@@ -28,7 +28,9 @@
function KeyNameToCode(name: shortstring): word;
procedure ProcessKbd;
procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean);
-procedure ProcessKey(event: TSDL_KeyboardEvent);
+procedure ProcessKey(event: TSDL_KeyboardEvent); inline;
+procedure ProcessKey(code: LongInt; KeyDown: boolean);
+
procedure ResetKbd;
procedure FreezeEnterKey;
procedure InitKbdKeyTable;
@@ -60,10 +62,7 @@
end;
procedure ProcessKbd;
-var i, j, k: LongInt;
- s: shortstring;
- Trusted: boolean;
- pkbd: PByteArray;
+//var i, j, k: LongInt;
begin
// move cursor/camera
@@ -72,9 +71,8 @@
movecursor(5 * CursorMovementX, 5 * CursorMovementY);
-{$IFNDEF MOBILE}
-
//TODO reimplement
+{$IFDEF 0}
// Controller(s)
k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
for j:= 0 to Pred(ControllerNumControllers) do
@@ -155,7 +153,7 @@
end;
-procedure ProcessKey(event: TSDL_KeyboardEvent);
+procedure ProcessKey(event: TSDL_KeyboardEvent); inline;
begin
ProcessKey(event.keysym.sym, event.type_ = SDL_KEYDOWN);
end;
--- a/hedgewars/uMisc.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uMisc.pas Wed May 02 11:43:43 2012 +0100
@@ -31,9 +31,9 @@
function MakeScreenshot(filename: shortstring): boolean;
function GetTeamStatString(p: PTeam): shortstring;
{$IFDEF SDL13}
-function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect;
+function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
{$ELSE}
-function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect;
+function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline;
{$ENDIF}
implementation
@@ -250,9 +250,9 @@
end;
{$IFDEF SDL13}
-function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect;
+function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
{$ELSE}
-function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect;
+function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline;
{$ENDIF}
begin
SDL_RectMake.x:= x;
--- a/hedgewars/uRender.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uRender.pas Wed May 02 11:43:43 2012 +0100
@@ -459,9 +459,9 @@
end;
procedure DrawScreenWidget(widget: POnScreenWidget);
+{$IFDEF USE_TOUCH_INTERFACE}
var alpha: byte = $FF;
begin
-{$IFDEF USE_TOUCH_INTERFACE}
with widget^ do
begin
if (fadeAnimStart <> 0) then
@@ -499,6 +499,9 @@
Tint($FF, $FF, $FF, $FF);
end;
end;
+{$ELSE}
+begin
+widget:= widget; // avoid hint
{$ENDIF}
end;
--- a/hedgewars/uRenderUtils.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uRenderUtils.pas Wed May 02 11:43:43 2012 +0100
@@ -193,12 +193,11 @@
procedure DrawLine2Surf(dest: PSDL_Surface; x0, y0,x1,y1: LongInt; r,g,b: byte);
var
- max: LongInt;
dx,dy,err,e2,sx,sy: LongInt;
yMax: LongInt;
destPixels: PLongwordArray;
begin
- max:= (dest^.pitch div 4) * dest^.h;
+ //max:= (dest^.pitch div 4) * dest^.h;
yMax:= dest^.pitch div 4;
destPixels:= dest^.pixels;
--- a/hedgewars/uTeams.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uTeams.pas Wed May 02 11:43:43 2012 +0100
@@ -20,7 +20,7 @@
unit uTeams;
interface
-uses uConsts, uInputHandler, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions, GLunit, uSound, uTypes, uWorld;
+uses uConsts, uInputHandler, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions, GLunit, uSound, uTypes{$IFDEF USE_TOUCH_INTERFACE}, uWorld{$ENDIF};
procedure initModule;
procedure freeModule;
--- a/hedgewars/uWorld.pas Wed May 02 12:24:44 2012 +0200
+++ b/hedgewars/uWorld.pas Wed May 02 11:43:43 2012 +0100
@@ -1772,7 +1772,9 @@
animateWidget(@utilityWidget, true, true);
end
else if utilityWidget.show then
- animateWidget(@utilityWidget, true, false);
+ animateWidget(@utilityWidget, true, false);
+{$ELSE}
+ammoType:= ammoType; // avoid hint
{$ENDIF}
end;