Fixed-point arithmetics in engine.
Introduced many bugs.
Currently disabled:
- land morphing in land generator
- AI
- many minor features
Engine is nearly unusable and totally unplayable.
--- a/hedgewars/CCHandlers.inc Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/CCHandlers.inc Sun Jan 21 19:51:02 2007 +0000
@@ -17,13 +17,15 @@
*)
function CheckNoTeamOrHH: boolean;
+var Result: boolean;
begin
-Result:= (CurrentTeam = nil) or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = nil);
+Result:= (CurrentTeam = nil) or (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = nil);
{$IFDEF DEBUGFILE}
if Result then
if CurrentTeam = nil then AddFileLog('CONSOLE: CurTeam = nil')
- else AddFileLog('CONSOLE: CurTeam <> nil, Gear = nil')
+ else AddFileLog('CONSOLE: CurTeam <> nil, Gear = nil');
{$ENDIF}
+CheckNoTeamOrHH:= Result
end;
////////////////////////////////////////////////////////////////////////////////
procedure chQuit(var s: shortstring);
@@ -53,15 +55,15 @@
TryDo(TeamsCount <= 5, 'Too many teams', true);
AddTeam
end;
-
-if GameType in [gmtDemo, gmtSave] then CurrentTeam.ExtDriven:= true
+
+if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true
end;
procedure chTeamLocal(var s: shortstring);
begin
if not isDeveloperMode then exit;
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true);
-CurrentTeam.ExtDriven:= true
+CurrentTeam^.ExtDriven:= true
end;
procedure chName(var id: shortstring);
@@ -71,11 +73,11 @@
SplitBySpace(id, s);
if s[1]='"' then Delete(s, 1, 1);
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
-if id = 'team' then CurrentTeam.TeamName:= s
+if id = 'team' then CurrentTeam^.TeamName:= s
else if (id[1] = 'h') and (id[2] = 'h')
and (id[3] >= '0') and (id[3] <= chr(ord('0')+cMaxHHIndex)) then
- CurrentTeam.Hedgehogs[byte(id[3])-48].Name:= s
-else OutError(errmsgUnknownVariable + ' "' + id + '"')
+ CurrentTeam^.Hedgehogs[byte(id[3])-48].Name:= s
+else OutError(errmsgUnknownVariable + ' "' + id + '"', false)
end;
procedure chGrave(var s: shortstring);
@@ -83,7 +85,7 @@
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
if s[1]='"' then Delete(s, 1, 1);
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
-CurrentTeam.GraveName:= s
+CurrentTeam^.GraveName:= s
end;
procedure chFort(var s: shortstring);
@@ -91,16 +93,16 @@
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
if s[1]='"' then Delete(s, 1, 1);
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
-CurrentTeam.FortName:= s
+CurrentTeam^.FortName:= s
end;
procedure chColor(var id: shortstring);
var c: integer;
begin
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/color"', true);
-val(id, CurrentTeam.Color, c);
-CurrentTeam.AdjColor:= CurrentTeam.Color;
-AdjustColor(CurrentTeam.AdjColor)
+val(id, CurrentTeam^.Color, c);
+CurrentTeam^.AdjColor:= CurrentTeam^.Color;
+AdjustColor(CurrentTeam^.AdjColor)
end;
procedure chAddHH(var id: shortstring);
@@ -113,11 +115,11 @@
begin
SplitBySpace(id, s);
val(id, Hedgehogs[HedgehogsNumber].BotLevel, c);
- Gear:= AddGear(0, 0, gtHedgehog, 0);
- Gear.Hedgehog:= @Hedgehogs[HedgehogsNumber];
- val(s, Gear.Health, c);
- TryDo(Gear.Health > 0, 'Invalid hedgehog health', true);
- PHedgehog(Gear.Hedgehog).Team:= CurrentTeam;
+ Gear:= AddGear(0, 0, gtHedgehog, 0, 0, 0, 0);
+ Gear^.Hedgehog:= @Hedgehogs[HedgehogsNumber];
+ val(s, Gear^.Health, c);
+ TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
+ PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam;
Hedgehogs[HedgehogsNumber].AmmoStore:= 0;
Hedgehogs[HedgehogsNumber].Gear:= Gear;
inc(HedgehogsNumber)
@@ -138,24 +140,24 @@
if s[1]='"' then Delete(s, 1, 1);
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
b:= KeyNameToCode(id);
-if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"')
- else CurrentTeam.Binds[b]:= s
+if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false)
+ else CurrentTeam^.Binds[b]:= s
end;
procedure chLeft_p(var s: shortstring);
begin
if CheckNoTeamOrHH then exit;
bShowFinger:= false;
-if not CurrentTeam.ExtDriven then SendIPC('L');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('L');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message or gm_Left
end;
procedure chLeft_m(var s: shortstring);
begin
if CheckNoTeamOrHH then exit;
-if not CurrentTeam.ExtDriven then SendIPC('l');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('l');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message and not gm_Left
end;
@@ -163,16 +165,16 @@
begin
if CheckNoTeamOrHH then exit;
bShowFinger:= false;
-if not CurrentTeam.ExtDriven then SendIPC('R');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('R');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message or gm_Right
end;
procedure chRight_m(var s: shortstring);
begin
if CheckNoTeamOrHH then exit;
-if not CurrentTeam.ExtDriven then SendIPC('r');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('r');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message and not gm_Right
end;
@@ -180,16 +182,16 @@
begin
if CheckNoTeamOrHH then exit;
bShowFinger:= false;
-if not CurrentTeam.ExtDriven then SendIPC('U');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('U');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message or gm_Up
end;
procedure chUp_m(var s: shortstring);
begin
if CheckNoTeamOrHH then exit;
-if not CurrentTeam.ExtDriven then SendIPC('u');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('u');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message and not gm_Up
end;
@@ -197,16 +199,16 @@
begin
if CheckNoTeamOrHH then exit;
bShowFinger:= false;
-if not CurrentTeam.ExtDriven then SendIPC('D');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('D');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message or gm_Down
end;
procedure chDown_m(var s: shortstring);
begin
if CheckNoTeamOrHH then exit;
-if not CurrentTeam.ExtDriven then SendIPC('d');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('d');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message and not gm_Down
end;
@@ -214,8 +216,8 @@
begin
if CheckNoTeamOrHH then exit;
bShowFinger:= false;
-if not CurrentTeam.ExtDriven then SendIPC('j');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('j');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message or gm_LJump
end;
@@ -223,8 +225,8 @@
begin
if CheckNoTeamOrHH then exit;
bShowFinger:= false;
-if not CurrentTeam.ExtDriven then SendIPC('J');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('J');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message or gm_HJump
end;
@@ -232,13 +234,13 @@
begin
if CheckNoTeamOrHH then exit;
bShowFinger:= false;
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
begin
- {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear.State = '+inttostr(State));{$ENDIF}
+ {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF}
if ((State and gstHHDriven)<>0)and((State and (gstAttacked or gstHHChooseTarget or gstMoving)) = 0) then
begin
- FollowGear:= CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear;
- if not CurrentTeam.ExtDriven then SendIPC('A');
+ FollowGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear;
+ if not CurrentTeam^.ExtDriven then SendIPC('A');
Message:= Message or gm_Attack
end
end
@@ -247,9 +249,9 @@
procedure chAttack_m(var s: shortstring);
begin
if CheckNoTeamOrHH then exit;
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
begin
- if not CurrentTeam.ExtDriven and
+ if not CurrentTeam^.ExtDriven and
((Message and gm_Attack) <> 0) then SendIPC('a');
Message:= Message and not gm_Attack
end
@@ -258,8 +260,8 @@
procedure chSwitch(var s: shortstring);
begin
if CheckNoTeamOrHH then exit;
-if not CurrentTeam.ExtDriven then SendIPC('S');
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do
+if not CurrentTeam^.ExtDriven then SendIPC('S');
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do
Message:= Message or gm_Switch
end;
@@ -267,7 +269,7 @@
begin
if AllInactive then
begin
- if not CurrentTeam.ExtDriven then SendIPC('N');
+ if not CurrentTeam^.ExtDriven then SendIPC('N');
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF}
SwitchHedgehog;
end
@@ -283,13 +285,13 @@
begin
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit;
bShowFinger:= false;
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
- if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
+ if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then
begin
- Ammo[CurSlot, CurAmmo].Timer:= 1000 * (byte(s[1]) - 48);
+ Ammo^[CurSlot, CurAmmo].Timer:= 1000 * (byte(s[1]) - 48);
with CurrentTeam^ do
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]);
- if not CurrentTeam.ExtDriven then SendIPC(s);
+ if not CurrentTeam^.ExtDriven then SendIPC(s);
end
end;
@@ -301,21 +303,21 @@
bShowFinger:= false;
slot:= byte(s[1]) - 49;
if slot > cMaxSlotIndex then exit;
-if not CurrentTeam.ExtDriven then SendIPC(char(byte(s[1]) + 79));
+if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79));
with CurrentTeam^ do
begin
with Hedgehogs[CurrHedgehog] do
begin
- if ((Gear.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
- or ((Gear.State and gstHHDriven) = 0) then exit; // во время стрельбы исключает смену оружия
+ if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
+ or ((Gear^.State and gstHHDriven) = 0) then exit; // во время стрельбы исключает смену оружия
if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end
else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end;
if caSlot^ = slot then
begin
inc(caAmmo^);
- if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo[slot, caAmmo^].Count = 0) then caAmmo^:= 0
+ if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo^[slot, caAmmo^].Count = 0) then caAmmo^:= 0
end else
- if Ammo[slot, 0].Count > 0 then
+ if Ammo^[slot, 0].Count > 0 then
begin
caSlot^:= slot;
caAmmo^:= 0;
@@ -333,12 +335,12 @@
bSelected:= true;
exit
end;
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^,
- CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^,
+ CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
if (State and gstHHChooseTarget) <> 0 then
begin
isCursorVisible:= false;
- if not CurrentTeam.ExtDriven then
+ if not CurrentTeam^.ExtDriven then
begin
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y);
dec(TargetPoint.X, WorldDx);
@@ -346,9 +348,9 @@
SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
end;
State:= State and not gstHHChooseTarget;
- if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then
+ if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then
Message:= Message or gm_Attack;
- end else if CurrentTeam.ExtDriven then OutError('got /put while not being in choose target mode', false)
+ end else if CurrentTeam^.ExtDriven then OutError('got /put while not being in choose target mode', false)
end;
procedure chCapture(var s: shortstring);
@@ -358,7 +360,7 @@
procedure chSkip(var s: shortstring);
begin
-if not CurrentTeam.ExtDriven then SendIPC(',');
+if not CurrentTeam^.ExtDriven then SendIPC(',');
TurnTimeLeft:= 0
end;
@@ -398,8 +400,8 @@
begin
bSelected:= false;
if bShowAmmoMenu then bShowAmmoMenu:= false
- else if ((Gear.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
- or ((Gear.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true
+ else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
+ or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true
end
end;
@@ -412,7 +414,7 @@
if Length(s) = 0 then cFullScreen:= not cFullScreen
else cFullScreen:= s = '1';
-flags:= SDL_HWSURFACE or SDL_DOUBLEBUF or SDL_HWACCEL;
+flags:= SDL_HWSURFACE or SDL_hwFloatBUF or SDL_HWACCEL;
if cFullScreen then flags:= flags or SDL_FULLSCREEN
else SDL_WM_SetCaption('Hedgewars', nil);
SDL_FreeSurface(SDLPrimSurface);
@@ -422,7 +424,7 @@
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf))));
{$ENDIF}
TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true);
-PixelFormat:= SDLPrimSurface.format
+PixelFormat:= SDLPrimSurface^.format
end;
procedure chVol_p(var s: shortstring);
@@ -439,7 +441,7 @@
begin
if CheckNoTeamOrHH then exit;
bShowFinger:= true;
-FollowGear:= CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear
+FollowGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear
end;
procedure chPause(var s: shortstring);
@@ -447,4 +449,3 @@
isPaused:= not isPaused;
SDL_ShowCursor(ord(isPaused))
end;
-
--- a/hedgewars/CMakeLists.txt Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/CMakeLists.txt Sun Jan 21 19:51:02 2007 +0000
@@ -1,7 +1,7 @@
configure_file(${hedgewars_SOURCE_DIR}/hedgewars/proto.inc.in
${hedgewars_SOURCE_DIR}/hedgewars/proto.inc)
-set(dcc32_tryexe dcc32.exe)
+set(dcc32_tryexe "delphi!doesnt!work.exe")
set(fpc_tryexe fpc)
set(hwengine_project "hwengine.dpr")
@@ -66,7 +66,7 @@
message("Minimum required version of FreePascal is 1.9.4")
else (fpc_ver LESS "010904")
set(pascal_compiler ${fpc_executable})
- set(pascal_compiler_flags "-k-z" "-knoexecstack" "-B" "-Sd" "-Xs" "-OG" "-O2" "-FE../bin" "-Cs2000000" ${hwengine_project})
+ set(pascal_compiler_flags "-FE../bin" "-Cs2000000" "-O2" ${hwengine_project})
endif (fpc_ver LESS "010904")
endif (fpc_version)
endif (dcc32version)
--- a/hedgewars/GSHandlers.inc Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/GSHandlers.inc Sun Jan 21 19:51:02 2007 +0000
@@ -20,93 +20,94 @@
function CheckGearDrowning(Gear: PGear): boolean;
begin
-Result:= Gear.Y + Gear.Radius >= cWaterLine;
-if Result then
+if cWaterLine < Gear^.Y + Gear^.Radius then
begin
- Gear.State:= gstDrowning;
- Gear.doStep:= doStepDrowningGear;
- PlaySound(sndSplash)
- end
+ CheckGearDrowning:= true;
+ Gear^.State:= gstDrowning;
+ Gear^.doStep:= @doStepDrowningGear;
+ PlaySound(sndSplash, false)
+ end else
+ CheckGearDrowning:= false
end;
procedure CheckCollision(Gear: PGear);
begin
-if TestCollisionXwithGear(Gear, hwSign(Gear.X)) or TestCollisionYwithGear(Gear, hwSign(Gear.Y))
- then Gear.State:= Gear.State or gstCollision
- else Gear.State:= Gear.State and not gstCollision
+if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y))
+ then Gear^.State:= Gear^.State or gstCollision
+ else Gear^.State:= Gear^.State and not gstCollision
end;
procedure CheckHHDamage(Gear: PGear);
begin
-if Gear.dY > 0.40 then Gear.Damage:= Gear.Damage + 1 + round(70 * (abs(Gear.dY) - 0.40));
+if _0_4 < Gear^.dY then Gear^.Damage:= Gear^.Damage + 1 + hwRound(70 * (hwAbs(Gear^.dY) - _0_4));
end;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
procedure CalcRotationDirAngle(Gear: PGear);
-var dAngle: Double;
+var dAngle: hwFloat;
begin
-dAngle:= (abs(Gear.dX) + abs(Gear.dY))*0.1;
-if Gear.dX >= 0 then Gear.DirAngle:= Gear.DirAngle + dAngle
- else Gear.DirAngle:= Gear.DirAngle - dAngle;
-if Gear.DirAngle < 0 then Gear.DirAngle:= Gear.DirAngle + 16
-else if Gear.DirAngle >= 16 then Gear.DirAngle:= Gear.DirAngle - 16
+dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) * _0_1;
+if not Gear^.dX.isNegative then Gear^.DirAngle:= Gear^.DirAngle + dAngle
+ else Gear^.DirAngle:= Gear^.DirAngle - dAngle;
+if Gear^.DirAngle < 0 then Gear^.DirAngle:= Gear^.DirAngle + 16
+else if 16 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 16
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepDrowningGear(Gear: PGear);
begin
AllInactive:= false;
-Gear.Y:= Gear.Y + cDrownSpeed;
-if round(Gear.Y) > Gear.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear)
+Gear^.Y:= Gear^.Y + cDrownSpeed;
+if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepFallingGear(Gear: PGear);
var b: boolean;
begin
-if TestCollisionYwithGear(Gear, hwSign(Gear.dY)) then
+if TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) then
begin
- Gear.dX:= Gear.dX * Gear.Friction;
- Gear.dY:= - Gear.dY * Gear.Elasticity;
+ Gear^.dX:= Gear^.dX * Gear^.Friction;
+ Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
b:= false
end else b:= true;
-if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then
+if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
begin
- Gear.dX:= - Gear.dX * Gear.Elasticity;
-// Gear.dY:= Gear.dY;
+ Gear^.dX:= - Gear^.dX * Gear^.Elasticity;
+// Gear^.dY:= Gear^.dY;
b:= false
end;
if b then
begin
- Gear.dY:= Gear.dY + cGravity;
- Gear.State:= Gear.State and not gstCollision
+ Gear^.dY:= Gear^.dY + cGravity;
+ Gear^.State:= Gear^.State and not gstCollision
end else
begin
- if sqr(Gear.dX) + sqr(Gear.dY) < 0.00001 then
- if (Gear.Timer = 0) then Gear.Active:= false
+ if hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _1div100000 then
+ if (Gear^.Timer = 0) then Gear^.Active:= false
else begin
- Gear.dX:= 0;
- Gear.dY:= 0
+ Gear^.dX:= 0;
+ Gear^.dY:= 0
end;
- Gear.State:= Gear.State or gstCollision
+ Gear^.State:= Gear^.State or gstCollision
end;
-Gear.X:= Gear.X + Gear.dX;
-Gear.Y:= Gear.Y + Gear.dY;
+Gear^.X:= Gear^.X + Gear^.dX;
+Gear^.Y:= Gear^.Y + Gear^.dY;
CheckGearDrowning(Gear);
-if (sqr(Gear.dX) + sqr(Gear.dY) < 0.003) then Gear.State:= Gear.State and not gstMoving
- else Gear.State:= Gear.State or gstMoving
+if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_003) then Gear^.State:= Gear^.State and not gstMoving
+ else Gear^.State:= Gear^.State or gstMoving
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepCloud(Gear: PGear);
begin
-Gear.X:= Gear.X + cWindSpeed * 200 + Gear.dX;
-if Gear.Y > -160 then Gear.dY:= Gear.dY - 0.00002
- else Gear.dY:= Gear.dY + 0.00002;
-Gear.Y:= Gear.Y + Gear.dY;
-if Gear.X < -cScreenWidth - 256 then Gear.X:= cScreenWidth + 2048 else
-if Gear.X > cScreenWidth + 2048 then Gear.X:= -cScreenWidth - 256
+Gear^.X:= Gear^.X + cWindSpeed * 200 + Gear^.dX;
+if Gear^.Y > -160 then Gear^.dY:= Gear^.dY - _1div50000
+ else Gear^.dY:= Gear^.dY + _1div50000;
+Gear^.Y:= Gear^.Y + Gear^.dY;
+if Gear^.X < -cScreenWidth - 256 then Gear^.X:= cScreenWidth + 2048 else
+if Gear^.X > cScreenWidth + 2048 then Gear^.X:= -cScreenWidth - 256
end;
////////////////////////////////////////////////////////////////////////////////
@@ -115,63 +116,63 @@
begin
AllInactive:= false;
doStepFallingGear(Gear);
-dec(Gear.Timer);
-if Gear.Timer = 0 then
+dec(Gear^.Timer);
+if Gear^.Timer = 0 then
begin
- case Gear.Kind of
- gtAmmo_Bomb: doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
+ case Gear^.Kind of
+ gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
gtClusterBomb: begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound);
for i:= 0 to 4 do
- AddGear(round(Gear.X), round(Gear.Y), gtCluster, 0, (getrandom - 0.5)*0.2, (getrandom - 3) * 0.08);
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, (getrandom - _0_5) * _0_2, (getrandom - 3) * _0_08, 0);
end
end;
DeleteGear(Gear);
exit
end;
CalcRotationDirAngle(Gear);
-if (Gear.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact)
+if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact, false)
end;
procedure doStepCluster(Gear: PGear);
begin
AllInactive:= false;
doStepFallingGear(Gear);
-if (Gear.State and gstCollision) <> 0 then
+if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
if (GameTicks and $1F) = 0 then
- AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, 0, 0, 0)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepGrenade(Gear: PGear);
begin
AllInactive:= false;
-Gear.dX:= Gear.dX + cWindSpeed;
+Gear^.dX:= Gear^.dX + cWindSpeed;
doStepFallingGear(Gear);
-if (Gear.State and gstCollision) <> 0 then
+if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
if (GameTicks and $3F) = 0 then
- AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, 0, 0, 0)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepHealthTagWork(Gear: PGear);
begin
AllInactive:= false;
-dec(Gear.Timer);
-Gear.Y:= Gear.Y - 0.07;
-if Gear.Timer = 0 then
+dec(Gear^.Timer);
+Gear^.Y:= Gear^.Y - _0_08;
+if Gear^.Timer = 0 then
begin
- PHedgehog(Gear.Hedgehog).Gear.Active:= true; // to let current hh die
+ PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die
DeleteGear(Gear)
end
end;
@@ -179,8 +180,8 @@
procedure doStepHealthTagWorkUnderWater(Gear: PGear);
begin
AllInactive:= false;
-Gear.Y:= Gear.Y - 0.07;
-if Gear.Y <= cWaterLine + 10 then
+Gear^.Y:= Gear^.Y - _0_08;
+if Gear^.Y < cWaterLine + 10 then
DeleteGear(Gear)
end;
@@ -188,52 +189,52 @@
var s: shortstring;
begin
AllInactive:= false;
-str(Gear.State, s);
-Gear.Surf:= RenderString(s, PHedgehog(Gear.Hedgehog).Team.Color, fnt16);
-if Gear.Y < cWaterLine then Gear.doStep:= doStepHealthTagWork
- else Gear.doStep:= doStepHealthTagWorkUnderWater
+str(Gear^.State, s);
+Gear^.Surf:= RenderString(s, PHedgehog(Gear^.Hedgehog)^.Team^.Color, fnt16);
+if Gear^.Y < cWaterLine then Gear^.doStep:= @doStepHealthTagWork
+ else Gear^.doStep:= @doStepHealthTagWorkUnderWater
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepGrave(Gear: PGear);
begin
AllInactive:= false;
-if Gear.dY < 0 then
- if TestCollisionY(Gear, -1) then Gear.dY:= 0;
+if Gear^.dY < 0 then
+ if TestCollisionY(Gear, -1) then Gear^.dY:= 0;
-if Gear.dY >=0 then
+if not Gear^.dY.isNegative then
if TestCollisionY(Gear, 1) then
begin
- Gear.dY:= - Gear.dY * Gear.Elasticity;
- if Gear.dY > - 0.001 then
+ Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
+ if Gear^.dY > - _1div1024 then
begin
- Gear.Active:= false;
+ Gear^.Active:= false;
exit
- end else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact)
+ end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false)
end;
-Gear.Y:= Gear.Y + Gear.dY;
+Gear^.Y:= Gear^.Y + Gear^.dY;
CheckGearDrowning(Gear);
-Gear.dY:= Gear.dY + cGravity
+Gear^.dY:= Gear^.dY + cGravity
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepUFOWork(Gear: PGear);
-var t: Double;
+var t: hwFloat;
begin
AllInactive:= false;
-t:= sqrt(sqr(Gear.dX) + sqr(Gear.dY));
-Gear.dX:= Gear.Elasticity * (Gear.dX + 0.000004 * (TargetPoint.X - trunc(Gear.X)));
-Gear.dY:= Gear.Elasticity * (Gear.dY + 0.000004 * (TargetPoint.Y - trunc(Gear.Y)));
-t:= t / (sqrt(sqr(Gear.dX) + sqr(Gear.dY)));
-Gear.dX:= Gear.dX * t;
-Gear.dY:= Gear.dY * t;
-Gear.X:= Gear.X + Gear.dX;
-Gear.Y:= Gear.Y + Gear.dY;
+t:= Distance(Gear^.dX, Gear^.dY);
+Gear^.dX:= Gear^.Elasticity * (Gear^.dX + _0_000004 * (TargetPoint.X - hwRound(Gear^.X)));
+Gear^.dY:= Gear^.Elasticity * (Gear^.dY + _0_000004 * (TargetPoint.Y - hwRound(Gear^.Y)));
+t:= t / Distance(Gear^.dX, Gear^.dY);
+Gear^.dX:= Gear^.dX * t;
+Gear^.dY:= Gear^.dY * t;
+Gear^.X:= Gear^.X + Gear^.dX;
+Gear^.Y:= Gear^.Y + Gear^.dY;
CheckCollision(Gear);
-dec(Gear.Timer);
-if ((Gear.State and gstCollision) <> 0) or (Gear.Timer = 0) then
+dec(Gear^.Timer);
+if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then
begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
DeleteGear(Gear);
end;
end;
@@ -241,21 +242,21 @@
procedure doStepUFO(Gear: PGear);
begin
AllInactive:= false;
-Gear.X:= Gear.X + Gear.dX;
-Gear.Y:= Gear.Y + Gear.dY;
-Gear.dY:= Gear.dY + cGravity;
+Gear^.X:= Gear^.X + Gear^.dX;
+Gear^.Y:= Gear^.Y + Gear^.dY;
+Gear^.dY:= Gear^.dY + cGravity;
CheckCollision(Gear);
-if (Gear.State and gstCollision) <> 0 then
+if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
-dec(Gear.Timer);
-if Gear.Timer = 0 then
+dec(Gear^.Timer);
+if Gear^.Timer = 0 then
begin
- Gear.Timer:= 5000;
- Gear.doStep:= doStepUFOWork
+ Gear^.Timer:= 5000;
+ Gear^.doStep:= @doStepUFOWork
end;
end;
@@ -264,28 +265,28 @@
var i: LongWord;
begin
AllInactive:= false;
-if Gear.Timer > 0 then
+if Gear^.Timer > 0 then
begin
- dec(Gear.Timer);
- if Gear.Timer = 0 then PlaySound(sndShotgunFire);
+ dec(Gear^.Timer);
+ if Gear^.Timer = 0 then PlaySound(sndShotgunFire, false);
exit
end;
i:= 200;
repeat
-Gear.X:= Gear.X + Gear.dX;
-Gear.Y:= Gear.Y + Gear.dY;
+Gear^.X:= Gear^.X + Gear^.dX;
+Gear^.Y:= Gear^.Y + Gear^.dY;
CheckCollision(Gear);
-if (Gear.State and gstCollision) <> 0 then
+if (Gear^.State and gstCollision) <> 0 then
begin
AmmoShove(Gear, 25, 25);
- doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH);
DeleteGear(Gear);
AfterAttack;
exit
end;
dec(i)
until i = 0;
-if (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then
+if (Gear^.X < 0) or (Gear^.Y < 0) or (Gear^.X > 2048) or (Gear^.Y > 1024) then
begin
DeleteGear(Gear);
AfterAttack
@@ -295,53 +296,53 @@
////////////////////////////////////////////////////////////////////////////////
procedure doStepDEagleShot(Gear: PGear);
var i, x, y: LongWord;
- oX, oY: Double;
+ oX, oY: hwFloat;
begin
AllInactive:= false;
i:= 80;
-oX:= Gear.X;
-oY:= Gear.Y;
+oX:= Gear^.X;
+oY:= Gear^.Y;
repeat
- Gear.X:= Gear.X + Gear.dX;
- Gear.Y:= Gear.Y + Gear.dY;
- x:= round(Gear.X);
- y:= round(Gear.Y);
+ Gear^.X:= Gear^.X + Gear^.dX;
+ Gear^.Y:= Gear^.Y + Gear^.dY;
+ x:= hwRound(Gear^.X);
+ y:= hwRound(Gear^.Y);
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0)
- and (Land[y, x] <> 0) then inc(Gear.Damage);
+ and (Land[y, x] <> 0) then inc(Gear^.Damage);
AmmoShove(Gear, 7, 20);
dec(i)
-until (i = 0) or (Gear.Damage > Gear.Health);
-if Gear.Damage > 0 then
+until (i = 0) or (Gear^.Damage > Gear^.Health);
+if Gear^.Damage > 0 then
begin
- DrawTunnel(oX, oY, Gear.dX, Gear.dY, 82 - i, 1);
- dec(Gear.Health, Gear.Damage);
- Gear.Damage:= 0
+ DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1);
+ dec(Gear^.Health, Gear^.Damage);
+ Gear^.Damage:= 0
end;
-if (Gear.Health <= 0) or (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then
+if (Gear^.Health <= 0) or (Gear^.X < 0) or (Gear^.Y < 0) or (Gear^.X > 2048) or (Gear^.Y > 1024) then
DeleteGear(Gear)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepActionTimer(Gear: PGear);
begin
-dec(Gear.Timer);
-case Gear.Kind of
+dec(Gear^.Timer);
+case Gear^.Kind of
gtATStartGame: begin
AllInactive:= false;
- if Gear.Timer = 0 then
+ if Gear^.Timer = 0 then
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState);
end;
gtATSmoothWindCh: begin
- if Gear.Timer = 0 then
+ if Gear^.Timer = 0 then
begin
- if WindBarWidth < Gear.Tag then inc(WindBarWidth)
- else if WindBarWidth > Gear.Tag then dec(WindBarWidth);
- if WindBarWidth <> Gear.Tag then Gear.Timer:= 10;
+ if WindBarWidth < Gear^.Tag then inc(WindBarWidth)
+ else if WindBarWidth > Gear^.Tag then dec(WindBarWidth);
+ if WindBarWidth <> Gear^.Tag then Gear^.Timer:= 10;
end
end;
gtATFinishGame: begin
AllInactive:= false;
- if Gear.Timer = 0 then
+ if Gear^.Timer = 0 then
begin
SendIPC('N');
SendIPC('q');
@@ -349,7 +350,7 @@
end
end;
end;
-if Gear.Timer = 0 then DeleteGear(Gear)
+if Gear^.Timer = 0 then DeleteGear(Gear)
end;
////////////////////////////////////////////////////////////////////////////////
@@ -358,50 +359,50 @@
HHGear: PGear;
begin
AllInactive:= false;
-HHGear:= PHedgehog(Gear.Hedgehog).Gear;
-dec(Gear.Timer);
-if (Gear.Timer = 0)or((Gear.Message and gm_Destroy) <> 0)or((HHGear.State and gstHHDriven) = 0) then
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+dec(Gear^.Timer);
+if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then
begin
StopSound(sndPickhammer);
DeleteGear(Gear);
AfterAttack;
exit
end;
-if (Gear.Timer and $3F) = 0 then
+if (Gear^.Timer and $3F) = 0 then
begin
- i:= round(Gear.X) - Gear.Radius - GetRandom(2);
- ei:= round(Gear.X) + Gear.Radius + GetRandom(2);
+ i:= hwRound(Gear^.X) - Gear^.Radius - GetRandom(2);
+ ei:= hwRound(Gear^.X) + Gear^.Radius + GetRandom(2);
while i <= ei do
begin
- doMakeExplosion(i, round(Gear.Y) + 3, 3, 0);
+ doMakeExplosion(i, hwRound(Gear^.Y) + 3, 3, 0);
inc(i, 1)
end;
- Gear.X:= Gear.X + Gear.dX;
- Gear.Y:= Gear.Y + 1.9;
+ Gear^.X:= Gear^.X + Gear^.dX;
+ Gear^.Y:= Gear^.Y + _1_9;
SetAllHHToActive;
end;
if TestCollisionYwithGear(Gear, 1) then
begin
- Gear.dY:= 0;
- SetLittle(HHGear.dX);
- HHGear.dY:= 0;
+ Gear^.dY:= 0;
+ SetLittle(HHGear^.dX);
+ HHGear^.dY:= 0;
end else
begin
- Gear.dY:= Gear.dY + cGravity;
- Gear.Y:= Gear.Y + Gear.dY;
- if Gear.Y > 1024 then Gear.Timer:= 1
+ Gear^.dY:= Gear^.dY + cGravity;
+ Gear^.Y:= Gear^.Y + Gear^.dY;
+ if Gear^.Y > 1024 then Gear^.Timer:= 1
end;
-Gear.X:= Gear.X + HHGear.dX;
-HHGear.X:= Gear.X;
-HHGear.Y:= Gear.Y - cHHRadius;
+Gear^.X:= Gear^.X + HHGear^.dX;
+HHGear^.X:= Gear^.X;
+HHGear^.Y:= Gear^.Y - cHHRadius;
-if (Gear.Message and gm_Attack) <> 0 then
- if (Gear.State and gsttmpFlag) <> 0 then Gear.Timer:= 1 else else
- if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag;
-if ((Gear.Message and gm_Left) <> 0) then Gear.dX:= -0.3 else
- if ((Gear.Message and gm_Right) <> 0) then Gear.dX:= 0.3
- else Gear.dX:= 0;
+if (Gear^.Message and gm_Attack) <> 0 then
+ if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else
+ if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag;
+if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else
+ if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3
+ else Gear^.dX:= 0;
end;
procedure doStepPickHammer(Gear: PGear);
@@ -409,19 +410,19 @@
ar: TRangeArray;
begin
i:= 0;
-y:= round(Gear.Y) - cHHRadius*2;
-while y < round(Gear.Y) do
+y:= hwRound(Gear^.Y) - cHHRadius*2;
+while y < hwRound(Gear^.Y) do
begin
- ar[i].Left := round(Gear.X) - Gear.Radius - GetRandom(2);
- ar[i].Right:= round(Gear.X) + Gear.Radius + GetRandom(2);
+ ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - GetRandom(2);
+ ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + GetRandom(2);
inc(y, 2);
inc(i)
end;
-DrawHLinesExplosions(@ar, 3, round(Gear.Y) - cHHRadius*2, 2, Pred(i));
-Gear.dY:= PHedgehog(Gear.Hedgehog).Gear.dY;
+DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius*2, 2, Pred(i));
+Gear^.dY:= PHedgehog(Gear^.Hedgehog)^.Gear^.dY;
PlaySound(sndPickhammer, true);
doStepPickHammerWork(Gear);
-Gear.doStep:= doStepPickHammerWork
+Gear^.doStep:= @doStepPickHammerWork
end;
////////////////////////////////////////////////////////////////////////////////
@@ -432,50 +433,50 @@
b: boolean;
begin
AllInactive:= false;
-dec(Gear.Timer);
-HHGear:= PHedgehog(Gear.Hedgehog).Gear;
+dec(Gear^.Timer);
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
HedgehogChAngle(HHGear);
b:= false;
-if (HHGear.Angle <> BTPrevAngle) then
+if (HHGear^.Angle <> BTPrevAngle) then
begin
- Gear.dX:= hwSign(HHGear.dX) * Sin(HHGear.Angle * pi / cMaxAngle) * 0.5;
- Gear.dY:= Cos(HHGear.Angle * pi / cMaxAngle) * (-0.5);
- BTPrevAngle:= HHGear.Angle;
+ Gear^.dX:= hwSign(HHGear^.dX) * _0_5;//hwSign(HHGear^.dX) * Sin(HHGear^.Angle * pi / cMaxAngle) * _0_5;
+ Gear^.dY:= 0;//Cos(HHGear^.Angle * pi / cMaxAngle) * (-0.5);
+ BTPrevAngle:= HHGear^.Angle;
b:= true
end;
-if Gear.Timer mod cHHStepTicks = 0 then
+if Gear^.Timer mod cHHStepTicks = 0 then
begin
b:= true;
- if Gear.dX < 0 then HHGear.Message:= (HHGear.Message or gm_Left) and not gm_Right
- else HHGear.Message:= (HHGear.Message or gm_Right) and not gm_Left;
+ if Gear^.dX < 0 then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right
+ else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left;
HedgehogStep(HHGear);
inc(BTSteps);
if BTSteps = 11 then
begin
BTSteps:= 0;
- Gear.X:= HHGear.X + Gear.dX * cHHRadius * 2;
- Gear.Y:= HHGear.Y + Gear.dY * cHHRadius * 2;
- HHGear.State:= HHGear.State or gstNoDamage;
+ Gear^.X:= HHGear^.X + Gear^.dX * cHHRadius * 2;
+ Gear^.Y:= HHGear^.Y + Gear^.dY * cHHRadius * 2;
+ HHGear^.State:= HHGear^.State or gstNoDamage;
AmmoShove(Gear, 3, 14);
- HHGear.State:= HHGear.State and not gstNoDamage
+ HHGear^.State:= HHGear^.State and not gstNoDamage
end;
- if (HHGear.State and gstFalling) <> 0 then Gear.Timer:= 0
+ if (HHGear^.State and gstFalling) <> 0 then Gear^.Timer:= 0
end;
if b then
- DrawTunnel(HHGear.X - Gear.dX * cHHRadius, HHGear.Y - 4 - Gear.dY * cHHRadius + abs(Gear.dY) * 7,
- Gear.dX, Gear.dY,
+ DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - 4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7,
+ Gear^.dX, Gear^.dY,
cHHRadius * 5, cHHRadius * 2 + 6);
-if (Gear.Timer = 0) or ((HHGear.Message and gm_Attack) <> 0) then
+if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then
begin
- HHGear.Message:= 0;
+ HHGear^.Message:= 0;
DeleteGear(Gear);
AfterAttack
end
@@ -486,10 +487,10 @@
begin
BTPrevAngle:= High(Longword);
BTSteps:= 0;
-HHGear:= PHedgehog(Gear.Hedgehog).Gear;
-HHGear.State:= HHGear.State and not gstAttacking;
-HHGear.Message:= 0;
-Gear.doStep:= doStepBlowTorchWork
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+HHGear^.State:= HHGear^.State and not gstAttacking;
+HHGear^.Message:= 0;
+Gear^.doStep:= @doStepBlowTorchWork
end;
////////////////////////////////////////////////////////////////////////////////
@@ -497,7 +498,7 @@
procedure doStepRopeWork(Gear: PGear);
const flCheck: boolean = false;
var HHGear: PGear;
- len, cs, cc, tx, ty: Double;
+ len, cs, cc, tx, ty: hwFloat;
lx, ly: LongInt;
procedure DeleteMe;
@@ -508,58 +509,58 @@
State:= State or gstFalling;
end;
DeleteGear(Gear);
- OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo);
- ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^)
+ OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^.Ammo);
+ ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^)
end;
begin
-HHGear:= PHedgehog(Gear.Hedgehog).Gear;
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
-if ((HHGear.State and gstHHDriven) = 0)
+if ((HHGear^.State and gstHHDriven) = 0)
or (CheckGearDrowning(HHGear)) then
begin
DeleteMe;
exit
end;
-Gear.dX:= HHGear.X - Gear.X;
-Gear.dY:= HHGear.Y - Gear.Y;
+Gear^.dX:= HHGear^.X - Gear^.X;
+Gear^.dY:= HHGear^.Y - Gear^.Y;
-if (Gear.Message and gm_Left <> 0) then HHGear.dX:= HHGear.dX - 0.0002 else
-if (Gear.Message and gm_Right <> 0) then HHGear.dX:= HHGear.dX + 0.0002;
+if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else
+if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002;
-if not TestCollisionYwithGear(HHGear, 1) then HHGear.dY:= HHGear.dY + cGravity;
+if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity;
-cs:= Gear.dY + HHGear.dY;
-cc:= Gear.dX + HHGear.dX;
-len:= 1 / sqrt(sqr(cc)+sqr(cs));
+cs:= Gear^.dY + HHGear^.dY;
+cc:= Gear^.dX + HHGear^.dX;
+len:= 1 / Distance(cc, cs);
cc:= cc * len;
cs:= cs * len;
flCheck:= not flCheck;
if flCheck then // check whether rope needs dividing
begin
- len:= Gear.Elasticity - 20;
+ len:= Gear^.Elasticity - 20;
while len > 5 do
begin
tx:= cc*len;
ty:= cs*len;
- lx:= round(Gear.X + tx) + hwSign(HHGear.dX);
- ly:= round(Gear.Y + ty) + hwSign(HHGear.dY);
+ lx:= hwRound(Gear^.X + tx) + hwSign(HHGear^.dX);
+ ly:= hwRound(Gear^.Y + ty) + hwSign(HHGear^.dY);
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then
begin
with RopePoints.ar[RopePoints.Count] do
begin
- X:= Gear.X;
- Y:= Gear.Y;
- if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear.dY, Gear.dX);
- b:= (cc * HHGear.dY) > (cs * HHGear.dX);
+ X:= Gear^.X;
+ Y:= Gear^.Y;
+ if RopePoints.Count = 0 then RopePoints.HookAngle:= 0;//DxDy2Angle32(Gear^.dY, Gear^.dX);
+ b:= (cc * HHGear^.dY) > (cs * HHGear^.dX);
dLen:= len
end;
- Gear.X:= Gear.X + tx;
- Gear.Y:= Gear.Y + ty;
+ Gear^.X:= Gear^.X + tx;
+ Gear^.Y:= Gear^.Y + ty;
inc(RopePoints.Count);
- Gear.Elasticity:= Gear.Elasticity - len;
- Gear.Friction:= Gear.Friction - len;
+ Gear^.Elasticity:= Gear^.Elasticity - len;
+ Gear^.Friction:= Gear^.Friction - len;
break
end;
len:= len - 3
@@ -569,113 +570,107 @@
begin
tx:= RopePoints.ar[Pred(RopePoints.Count)].X;
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y;
- if GameTicks = 189245 then
- begin
- AddFileLog('tx = ' + floattostr(tx) + ' ty = ' + floattostr(ty));
- AddFileLog('Gear.X = ' + floattostr(Gear.X) + ' Gear.Y = ' + floattostr(Gear.Y));
- AddFileLog('HHGear.X = ' + floattostr(HHGear.X) + ' HHGear.Y = ' + floattostr(HHGear.Y));
- end;
- if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear.X) * (ty - HHGear.Y) > (tx - HHGear.X) * (ty - Gear.Y)) then
+ if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then
begin
dec(RopePoints.Count);
- Gear.X:=RopePoints.ar[RopePoints.Count].X;
- Gear.Y:=RopePoints.ar[RopePoints.Count].Y;
- Gear.Elasticity:= Gear.Elasticity + RopePoints.ar[RopePoints.Count].dLen;
- Gear.Friction:= Gear.Friction + RopePoints.ar[RopePoints.Count].dLen
+ Gear^.X:=RopePoints.ar[RopePoints.Count].X;
+ Gear^.Y:=RopePoints.ar[RopePoints.Count].Y;
+ Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen;
+ Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen
end
end;
-Gear.dX:= HHGear.X - Gear.X;
-Gear.dY:= HHGear.Y - Gear.Y;
+Gear^.dX:= HHGear^.X - Gear^.X;
+Gear^.dY:= HHGear^.Y - Gear^.Y;
-cs:= Gear.dY + HHGear.dY;
-cc:= Gear.dX + HHGear.dX;
-len:= 1 / sqrt(sqr(cc)+sqr(cs));
+cs:= Gear^.dY + HHGear^.dY;
+cc:= Gear^.dX + HHGear^.dX;
+len:= 1 / Distance(cc, cs);
cc:= cc * len;
cs:= cs * len;
-HHGear.dX:= HHGear.X;
-HHGear.dY:= HHGear.Y;
+HHGear^.dX:= HHGear^.X;
+HHGear^.dY:= HHGear^.Y;
-if ((Gear.Message and gm_Down) <> 0) and (Gear.Elasticity < Gear.Friction) then
- if not (TestCollisionXwithGear(HHGear, hwSign(Gear.dX))
- or TestCollisionYwithGear(HHGear, hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity + 0.3;
+if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then
+ if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3;
-if ((Gear.Message and gm_Up) <> 0) and (Gear.Elasticity > 30) then
- if not (TestCollisionXwithGear(HHGear, -hwSign(Gear.dX))
- or TestCollisionYwithGear(HHGear, -hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity - 0.3;
+if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > 30) then
+ if not (TestCollisionXwithGear(HHGear, -hwSign(Gear^.dX))
+ or TestCollisionYwithGear(HHGear, -hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity - _0_3;
-HHGear.X:= Gear.X + cc*Gear.Elasticity;
-HHGear.Y:= Gear.Y + cs*Gear.Elasticity;
+HHGear^.X:= Gear^.X + cc*Gear^.Elasticity;
+HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity;
-HHGear.dX:= HHGear.X - HHGear.dX;
-HHGear.dY:= HHGear.Y - HHGear.dY;
+HHGear^.dX:= HHGear^.X - HHGear^.dX;
+HHGear^.dY:= HHGear^.Y - HHGear^.dY;
-if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then
- HHGear.dX:= -0.6 * HHGear.dX;
-if TestCollisionYwithGear(HHGear, hwSign(HHGear.dY)) then
- HHGear.dY:= -0.6 * HHGear.dY;
+if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
+ HHGear^.dX:= -_0_6 * HHGear^.dX;
+if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then
+ HHGear^.dY:= -_0_6 * HHGear^.dY;
-if (Gear.Message and gm_Attack) <> 0 then
- if (Gear.State and gsttmpFlag) <> 0 then DeleteMe else
-else if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag;
+if (Gear^.Message and gm_Attack) <> 0 then
+ if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else
+else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag;
end;
procedure doStepRopeAttach(Gear: PGear);
var HHGear: PGear;
- tx, ty, tt: Double;
+ tx, ty, tt: hwFloat;
begin
-Gear.X:= Gear.X - Gear.dX;
-Gear.Y:= Gear.Y - Gear.dY;
-Gear.Elasticity:= Gear.Elasticity + 1.0;
-HHGear:= PHedgehog(Gear.Hedgehog)^.Gear;
-if (HHGear.State and gstFalling) <> 0 then
+Gear^.X:= Gear^.X - Gear^.dX;
+Gear^.Y:= Gear^.Y - Gear^.dY;
+Gear^.Elasticity:= Gear^.Elasticity + 1;
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+if (HHGear^.State and gstFalling) <> 0 then
if TestCollisionYwithGear(HHGear, 1) then
begin
- HHGear.dY:= 0;
+ HHGear^.dY:= 0;
CheckHHDamage(HHGear);
- HHGear.State:= HHGear.State and not (gstFalling or gstHHJumping);
+ HHGear^.State:= HHGear^.State and not (gstFalling or gstHHJumping);
end else
begin
- if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then HHGear.dX:= 0.0000001 * hwSign(HHGear.dX);
- HHGear.X:= HHGear.X + HHGear.dX;
- HHGear.Y:= HHGear.Y + HHGear.dY;
- Gear.X:= Gear.X + HHGear.dX;
- Gear.Y:= Gear.Y + HHGear.dY;
- HHGear.dY:= HHGear.dY + cGravity;
- tt:= Gear.Elasticity;
+ if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
+ HHGear^.X:= HHGear^.X + HHGear^.dX;
+ HHGear^.Y:= HHGear^.Y + HHGear^.dY;
+ Gear^.X:= Gear^.X + HHGear^.dX;
+ Gear^.Y:= Gear^.Y + HHGear^.dY;
+ HHGear^.dY:= HHGear^.dY + cGravity;
+ tt:= Gear^.Elasticity;
tx:= 0;
ty:= 0;
while tt > 20 do
begin
- if TestCollisionXwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dX))
- or TestCollisionYwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dY)) then
+ if TestCollisionXwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dX))
+ or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dY)) then
begin
- Gear.X:= Gear.X + tx;
- Gear.Y:= Gear.Y + ty;
- Gear.Elasticity:= tt;
- Gear.doStep:= doStepRopeWork;
+ Gear^.X:= Gear^.X + tx;
+ Gear^.Y:= Gear^.Y + ty;
+ Gear^.Elasticity:= tt;
+ Gear^.doStep:= @doStepRopeWork;
with HHGear^ do State:= State and not gstAttacking;
tt:= 0
end;
- tx:= tx + Gear.dX - Gear.dX;
- ty:= ty + Gear.dY - Gear.dY;
- tt:= tt - 2.0;
+ tx:= tx + Gear^.dX - Gear^.dX;
+ ty:= ty + Gear^.dY - Gear^.dY;
+ tt:= tt - 2;
end;
end;
CheckCollision(Gear);
-if (Gear.State and gstCollision) <> 0 then
+if (Gear^.State and gstCollision) <> 0 then
begin
- Gear.doStep:= doStepRopeWork;
+ Gear^.doStep:= @doStepRopeWork;
with HHGear^ do State:= State and not gstAttacking;
- if Gear.Elasticity < 10 then
- Gear.Elasticity:= 10000;
+ if Gear^.Elasticity < 10 then
+ Gear^.Elasticity:= 10000;
end;
-if (Gear.Elasticity >= Gear.Friction) or ((Gear.Message and gm_Attack) = 0) then
+if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then
begin
- with PHedgehog(Gear.Hedgehog).Gear^ do
+ with PHedgehog(Gear^.Hedgehog)^.Gear^ do
begin
State:= State and not gstAttacking;
Message:= Message and not gm_Attack
@@ -686,71 +681,71 @@
procedure doStepRope(Gear: PGear);
begin
-Gear.dX:= - Gear.dX;
-Gear.dY:= - Gear.dY;
-Gear.doStep:= doStepRopeAttach
+Gear^.dX:= - Gear^.dX;
+Gear^.dY:= - Gear^.dY;
+Gear^.doStep:= @doStepRopeAttach
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepSmokeTrace(Gear: PGear);
begin
-inc(Gear.Timer);
-if Gear.Timer > 64 then
+inc(Gear^.Timer);
+if Gear^.Timer > 64 then
begin
- Gear.Timer:= 0;
- dec(Gear.State)
+ Gear^.Timer:= 0;
+ dec(Gear^.State)
end;
-Gear.dX:= Gear.dX + cWindSpeed;
-Gear.X:= Gear.X + Gear.dX;
-if Gear.State = 0 then DeleteGear(Gear)
+Gear^.dX:= Gear^.dX + cWindSpeed;
+Gear^.X:= Gear^.X + Gear^.dX;
+if Gear^.State = 0 then DeleteGear(Gear)
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepExplosion(Gear: PGear);
begin
-inc(Gear.Timer);
-if Gear.Timer > 75 then
+inc(Gear^.Timer);
+if Gear^.Timer > 75 then
begin
- inc(Gear.State);
- Gear.Timer:= 0;
- if Gear.State > 5 then DeleteGear(Gear)
+ inc(Gear^.State);
+ Gear^.Timer:= 0;
+ if Gear^.State > 5 then DeleteGear(Gear)
end;
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepMine(Gear: PGear);
begin
-if (Gear.dX <> 0) or (Gear.dY <> 0) then
+if (Gear^.dX.QWordValue <> 0) or (Gear^.dY.QWordValue <> 0) then
begin
- if Gear.CollIndex < High(Longword) then DeleteCI(Gear);
+ if Gear^.CollIndex < High(Longword) then DeleteCI(Gear);
doStepFallingGear(Gear);
- if Gear.Active = false then
+ if Gear^.Active = false then
begin
- if Gear.CollIndex = High(Longword) then AddGearCI(Gear);
- Gear.dX:= 0;
- Gear.dY:= 0
+ if Gear^.CollIndex = High(Longword) then AddGearCI(Gear);
+ Gear^.dX:= 0;
+ Gear^.dY:= 0
end;
CalcRotationDirAngle(Gear);
AllInactive:= false
end;
-
-if ((Gear.State and gsttmpFlag) <> 0) then
- if ((Gear.State and gstAttacking) = 0) then
+
+if ((Gear^.State and gsttmpFlag) <> 0) then
+ if ((Gear^.State and gstAttacking) = 0) then
begin
if ((GameTicks and $F) = 0) then
- if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear.State:= Gear.State or gstAttacking
+ if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking
end else // gstAttacking <> 0
begin
AllInactive:= false;
- if (Gear.Timer and $FF) = 0 then PlaySound(sndMineTick);
- if Gear.Timer = 0 then
+ if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false);
+ if Gear^.Timer = 0 then
begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
DeleteGear(Gear)
end;
- dec(Gear.Timer);
+ dec(Gear^.Timer);
end else // gsttmpFlag = 0
- if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag;
+ if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag;
end;
////////////////////////////////////////////////////////////////////////////////
@@ -758,54 +753,54 @@
begin
doStepFallingGear(Gear);
AllInactive:= false;
-if Gear.Timer mod 166 = 0 then inc(Gear.Tag);
-if Gear.Timer = 0 then
+if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag);
+if Gear^.Timer = 0 then
begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 75, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
-dec(Gear.Timer);
+dec(Gear^.Timer);
end;
-////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
procedure doStepCase(Gear: PGear);
var i, x, y: integer;
begin
-if (Gear.Message and gm_Destroy) > 0 then
+if (Gear^.Message and gm_Destroy) > 0 then
begin
DeleteGear(Gear);
exit
end;
-if Gear.Damage > 0 then
+if Gear^.Damage > 0 then
begin
- x:= round(Gear.X);
- y:= round(Gear.Y);
+ x:= hwRound(Gear^.X);
+ y:= hwRound(Gear^.Y);
DeleteGear(Gear);
doMakeExplosion(x, y, 25, EXPLAutoSound);
for i:= 0 to 63 do
- AddGear(x, y, gtFlame, 0);
+ AddGear(x, y, gtFlame, 0, 0, 0, 0);
exit
end;
-if (Gear.dY <> 0) or (not TestCollisionYwithGear(Gear, 1)) then
+if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then
begin
AllInactive:= false;
- Gear.dY:= Gear.dY + cGravity;
- Gear.Y:= Gear.Y + Gear.dY;
- if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0 else
- if (Gear.dY >= 0) and TestCollisionYwithGear(Gear, 1) then
+ Gear^.dY:= Gear^.dY + cGravity;
+ Gear^.Y:= Gear^.Y + Gear^.dY;
+ if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0 else
+ if (Gear^.dY.QWordValue <> 0) and TestCollisionYwithGear(Gear, 1) then
begin
- Gear.dY:= - Gear.dY * Gear.Elasticity;
- if Gear.dY > - 0.001 then Gear.dY:= 0
- else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact);
+ Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
+ if Gear^.dY > - _0_001 then Gear^.dY:= 0
+ else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false);
end;
CheckGearDrowning(Gear);
end;
-if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCI(Gear)
- else if (Gear.CollIndex < High(Longword)) and (Gear.dY <> 0) then DeleteCI(Gear);
+if (Gear^.CollIndex = High(Longword)) and (Gear^.dY.QWordValue = 0) then AddGearCI(Gear)
+ else if (Gear^.CollIndex < High(Longword)) and (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear);
end;
////////////////////////////////////////////////////////////////////////////////
@@ -820,14 +815,14 @@
var i: integer;
begin
AllInactive:= false;
-dec(Gear.Timer);
-if (Gear.Timer and 15) = 0 then
+dec(Gear^.Timer);
+if (Gear^.Timer and 15) = 0 then
for i:= 0 to Pred(thexchcnt) do
with thexchar[i] do
{$WARNINGS OFF}
- team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640;
+ team^.DrawHealthY:= ny + (oy - ny) * Gear^.Timer div 640;
{$WARNINGS ON}
-if (Gear.Timer = 0) or (currsorter <> Gear) then
+if (Gear^.Timer = 0) or (currsorter <> Gear) then
begin
if currsorter = Gear then currsorter:= nil;
DeleteGear(Gear)
@@ -843,15 +838,15 @@
i:= 0;
while team <> nil do
begin
- thexchar[i].oy:= team.DrawHealthY;
+ thexchar[i].oy:= team^.DrawHealthY;
thexchar[i].team:= team;
inc(i);
- team:= team.Next
+ team:= team^.Next
end;
thexchcnt:= i;
for i:= 1 to thexchcnt do
for t:= 0 to thexchcnt - 2 do
- if thexchar[t].team.TeamHealthBarWidth > thexchar[Succ(t)].team.TeamHealthBarWidth then
+ if thexchar[t].team^.TeamHealthBarWidth > thexchar[Succ(t)].team^.TeamHealthBarWidth then
begin
thexchar[5]:= thexchar[t];
thexchar[t]:= thexchar[Succ(t)];
@@ -861,11 +856,11 @@
for i:= 0 to Pred(thexchcnt) do
with thexchar[i] do
begin
- dec(t, team.HealthRect.h + 2);
+ dec(t, team^.HealthRect.h + 2);
ny:= t
end;
-Gear.Timer:= 640;
-Gear.doStep:= doStepTeamHealthSorterWork;
+Gear^.Timer:= 640;
+Gear^.doStep:= @doStepTeamHealthSorterWork;
currsorter:= Gear
end;
@@ -873,10 +868,10 @@
procedure doStepShover(Gear: PGear);
var HHGear: PGear;
begin
-HHGear:= PHedgehog(Gear.Hedgehog)^.Gear;
-HHGear.State:= HHGear.State or gstNoDamage;
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+HHGear^.State:= HHGear^.State or gstNoDamage;
AmmoShove(Gear, 30, 115);
-HHGear.State:= HHGear.State and not gstNoDamage;
+HHGear^.State:= HHGear^.State and not gstNoDamage;
DeleteGear(Gear)
end;
@@ -886,30 +881,30 @@
AllInactive:= false;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear.dX:= Gear.dX + cWindSpeed;
- Gear.dY:= Gear.dY + cGravity;
- if abs(Gear.dX) > 0.12 then Gear.dX:= Gear.dX * 0.5;
- if Gear.dY > 0.12 then Gear.dY:= Gear.dY * 0.995;
- Gear.X:= Gear.X + Gear.dX;
- Gear.Y:= Gear.Y + Gear.dY;
- if Gear.Y > 1023 then
+ Gear^.dX:= Gear^.dX + cWindSpeed;
+ Gear^.dY:= Gear^.dY + cGravity;
+ if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5;
+ if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995;
+ Gear^.X:= Gear^.X + Gear^.dX;
+ Gear^.Y:= Gear^.Y + Gear^.dY;
+ if Gear^.Y > 1023 then
begin
DeleteGear(Gear);
exit
end
end else begin
- if Gear.Timer > 0 then dec(Gear.Timer)
+ if Gear^.Timer > 0 then dec(Gear^.Timer)
else begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 2, 0);
- dec(Gear.Health);
- Gear.Timer:= 1250 - Gear.Angle * 12
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0);
+ dec(Gear^.Health);
+ Gear^.Timer:= 1250 - Gear^.Angle * 12
end
end;
-if (((GameTicks div 8) mod 64) = Gear.Angle) then
+if (((GameTicks div 8) mod 64) = Gear^.Angle) then
AmmoFlameWork(Gear);
-if Gear.Health = 0 then
+if Gear^.Health = 0 then
DeleteGear(Gear)
end;
@@ -918,49 +913,49 @@
var HHGear: PGear;
begin
AllInactive:= false;
-if ((Gear.Message and gm_Destroy) <> 0) then
+if ((Gear^.Message and gm_Destroy) <> 0) then
begin
DeleteGear(Gear);
AfterAttack;
exit
end;
-HHGear:= PHedgehog(Gear.Hedgehog).Gear;
-if round(HHGear.Y) <= Gear.Tag - 2 then
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then
begin
- Gear.Tag:= round(HHGear.Y);
- DrawTunnel(HHGear.X - cHHRadius, HHGear.Y - 1, 0.5, 0.0, cHHRadius * 4, 2);
- HHGear.State:= HHGear.State or gstNoDamage;
- Gear.Y:= HHGear.Y;
+ Gear^.Tag:= hwRound(HHGear^.Y);
+ DrawTunnel(HHGear^.X - cHHRadius, HHGear^.Y - 1, _0_5, 0, cHHRadius * 4, 2);
+ HHGear^.State:= HHGear^.State or gstNoDamage;
+ Gear^.Y:= HHGear^.Y;
AmmoShove(Gear, 30, 40);
- HHGear.State:= HHGear.State and not gstNoDamage
+ HHGear^.State:= HHGear^.State and not gstNoDamage
end;
-
-HHGear.dY:= HHGear.dY + cGravity;
-if HHGear.dY >= 0 then
+
+HHGear^.dY:= HHGear^.dY + cGravity;
+if not (HHGear^.dY.isNegative) then
begin
- HHGear.State:= HHGear.State or gstFalling;
+ HHGear^.State:= HHGear^.State or gstFalling;
DeleteGear(Gear);
AfterAttack;
exit
end;
-HHGear.Y:= HHGear.Y + HHGear.dY
+HHGear^.Y:= HHGear^.Y + HHGear^.dY
end;
procedure doStepFirePunch(Gear: PGear);
var HHGear: PGear;
begin
AllInactive:= false;
-HHGear:= PHedgehog(Gear.Hedgehog).Gear;
-HHGear.X:= round(HHGear.X) - 0.5;
-HHGear.dX:= 0.0000001 * hwSign(HHGear.dX);
-HHGear.dY:= -0.30;
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+HHGear^.X:= hwRound(HHGear^.X) - _0_5;
+SetLittle(HHGear^.dX);
+HHGear^.dY:= - _0_3;
-Gear.X:= HHGear.X;
-Gear.dX:= hwSign(HHGear.dX)* 0.45;
-Gear.dY:= -0.9;
-Gear.doStep:= doStepFirePunchWork;
-DrawTunnel(HHGear.X - cHHRadius, HHGear.Y + 1, 0.5, 0.0, cHHRadius * 4, 5);
+Gear^.X:= HHGear^.X;
+Gear^.dX:= hwSign(HHGear^.dX) * _0_45;
+Gear^.dY:= - _0_9;
+Gear^.doStep:= @doStepFirePunchWork;
+DrawTunnel(HHGear^.X - cHHRadius, HHGear^.Y + 1, _0_5, 0, cHHRadius * 4, 5);
end;
////////////////////////////////////////////////////////////////////////////////
@@ -968,69 +963,69 @@
procedure doStepParachute(Gear: PGear);
var HHGear: PGear;
begin
-HHGear:= PHedgehog(Gear.Hedgehog).Gear;
-HHGear.State:= HHGear.State and not gstAttacking;
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+HHGear^.State:= HHGear^.State and not gstAttacking;
if TestCollisionYwithGear(HHGear, 1)
- or ((HHGear.State and gstHHDriven) = 0)
+ or ((HHGear^.State and gstHHDriven) = 0)
or CheckGearDrowning(HHGear) then
begin
with HHGear^ do
begin
Message:= 0;
- dx:= 0.0000001 * hwSign(dX);
+ SetLittle(dx);
dY:= 0;
State:= State and not (gstAttacking or gstAttacked);
State:= State or gstFalling;
end;
DeleteGear(Gear);
- OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo);
- ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^);
+ OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^.Ammo);
+ ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^);
exit
end;
-if not TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then
- HHGear.X:= HHGear.X + cWindSpeed * 200;
+if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
+ HHGear^.X:= HHGear^.X + cWindSpeed * 200;
-if (Gear.Message and gm_Left) <> 0 then HHGear.X:= HHGear.X - cMaxWindSpeed * 40
-else if (Gear.Message and gm_Right) <> 0 then HHGear.X:= HHGear.X + cMaxWindSpeed * 40;
-if (Gear.Message and gm_Up) <> 0 then HHGear.Y:= HHGear.Y - cGravity * 40
-else if (Gear.Message and gm_Down) <> 0 then HHGear.Y:= HHGear.Y + cGravity * 40;
+if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40
+else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40;
+if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40
+else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40;
-HHGear.Y:= HHGear.Y + cGravity * 100;
+HHGear^.Y:= HHGear^.Y + cGravity * 100;
end;
////////////////////////////////////////////////////////////////////////////////
-const cAirPlaneSpeed = 1.4;
- cBombsDistance = 30;
- cBombsSpeed = 0.1;
+const cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 6012954214); // 1.4
+ cBombsDistance: hwFloat = (isNegative: false; QWordValue: 128849018880); // 30
+ cBombsSpeed : hwFloat = (isNegative: false; QWordValue: 429496729);
procedure doStepAirAttackWork(Gear: PGear);
begin
AllInactive:= false;
-Gear.X:= Gear.X + cAirPlaneSpeed;
-if (Gear.Health > 0)and(Gear.X >= Gear.dX)and(Gear.X < Gear.dX + cAirPlaneSpeed) then
+Gear^.X:= Gear^.X + cAirPlaneSpeed;
+if (Gear^.Health > 0)and( not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then
begin
- dec(Gear.Health);
- case Gear.State of
- 0: AddGear(round(Gear.X), round(Gear.Y), gtAirBomb, 0, cBombsSpeed, 0.0);
- 1: AddGear(round(Gear.X), round(Gear.Y), gtMine, 0, cBombsSpeed, 0.0);
+ dec(Gear^.Health);
+ case Gear^.State of
+ 0: AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed, 0, 0);
+ 1: AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed, 0, 0);
end;
- Gear.dX:= Gear.dX + cBombsDistance
+ Gear^.dX:= Gear^.dX + cBombsDistance
end;
-if Gear.X > 3072 then DeleteGear(Gear)
+if Gear^.X > 3072 then DeleteGear(Gear)
end;
procedure doStepAirAttack(Gear: PGear);
begin
AllInactive:= false;
-Gear.X:= -1024;
-Gear.Y:= -128;
-Gear.dX:= TargetPoint.X -
- cBombsDistance * 5 / 2 -
- cBombsSpeed * sqrt(2 * (TargetPoint.Y - Gear.Y) / cGravity);
-Gear.Health:= 6;
-Gear.doStep:= doStepAirAttackWork
+Gear^.X:= -1024;
+Gear^.Y:= -128;
+Gear^.dX:= TargetPoint.X -
+ cBombsDistance * 5 / 2;{ -
+ cBombsSpeed * sqrt(2 * (TargetPoint.Y - Gear^.Y) / cGravity);}
+Gear^.Health:= 6;
+Gear^.doStep:= @doStepAirAttackWork
end;
////////////////////////////////////////////////////////////////////////////////
@@ -1039,14 +1034,12 @@
begin
AllInactive:= false;
doStepFallingGear(Gear);
-if (Gear.State and gstCollision) <> 0 then
+if (Gear^.State and gstCollision) <> 0 then
begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound);
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound);
DeleteGear(Gear);
exit
end;
if (GameTicks and $3F) = 0 then
- AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0)
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, 0, 0, 0)
end;
-
-
--- a/hedgewars/HHHandlers.inc Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/HHHandlers.inc Sun Jan 21 19:51:02 2007 +0000
@@ -18,68 +18,71 @@
////////////////////////////////////////////////////////////////////////////////
procedure Attack(Gear: PGear);
-var xx, yy: Double;
+var xx, yy: hwFloat;
begin
with Gear^,
- PHedgehog(Gear.Hedgehog)^ do
+ PHedgehog(Gear^.Hedgehog)^ do
begin
if ((State and gstHHDriven) <> 0)and
// (((State and gstAttacking) <> 0) or ((Message and gm_Attack) <> 0))and
((State and (gstAttacked or gstMoving or gstHHChooseTarget)) = 0)and
- (((State and gstFalling ) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInFall) <> 0))and
- (((State and gstHHJumping) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInJump) <> 0))and
- ((TargetPoint.X <> NoPointX) or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_NeedTarget) = 0)) then
+ (((State and gstFalling ) = 0)or((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInFall) <> 0))and
+ (((State and gstHHJumping) = 0)or((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInJump) <> 0))and
+ ((TargetPoint.X <> NoPointX) or((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NeedTarget) = 0)) then
begin
State:= State or gstAttacking;
if Power = cMaxPower then Message:= Message and not gm_Attack
- else if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack
+ else if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack
else begin
if Power = 0 then
begin
- AttackBar:= CurrentTeam.AttackBar;
- PlaySound(sndThrowPowerUp)
+ AttackBar:= CurrentTeam^.AttackBar;
+ PlaySound(sndThrowPowerUp, false)
end;
inc(Power)
end;
if ((Message and gm_Attack) <> 0) then exit;
-
- if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0 then
+
+ if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0 then
begin
StopSound(sndThrowPowerUp);
- PlaySound(sndThrowRelease);
+ PlaySound(sndThrowRelease, false);
end;
- xx:= hwSign(dX)*Sin(Angle*pi/cMaxAngle);
- yy:= -Cos(Angle*pi/cMaxAngle);
- case Ammo[CurSlot, CurAmmo].AmmoType of
- amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer);
- amClusterBomb: FollowGear:= AddGear(round(X), round(Y), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer);
- amBazooka: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
- amUFO: FollowGear:= AddGear(round(X), round(Y), gtUFO, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
+// xx:= hwSign(dX)*Sin(Angle*pi/cMaxAngle);
+// yy:= -Cos(Angle*pi/cMaxAngle);
+ xx:= AngleSin(Angle);
+ xx.isNegative:= dX.isNegative;
+ yy:= -AngleCos(Angle);
+ case Ammo^[CurSlot, CurAmmo].AmmoType of
+ amGrenade: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
+ amClusterBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer);
+ amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
+ amUFO: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtUFO, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
amShotgun: begin
- PlaySound(sndShotgunReload);
- CurAmmoGear:= AddGear(round(X), round(Y), gtShotgunShot, 0, xx * 0.5, yy * 0.5);
+ PlaySound(sndShotgunReload, false);
+ CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtShotgunShot, 0, xx * _0_5, yy * _0_5, 0);
end;
- amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHRadius, gtPickHammer, 0);
+ amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, 0, 0, 0);
amSkip: TurnTimeLeft:= 0;
- amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy);
- amMine: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtMine, 0, hwSign(dX) * 0.02, 0, 3000);
- amDEagle: AddGear(round(X), round(Y), gtDEagleShot, 0, xx * 0.5, yy * 0.5);
- amDynamite: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtDynamite, 0, hwSign(dX) * 0.035, 0, 5000);
- amBaseballBat: AddGear(round(X) + hwSign(dX) * 10, round(Y), gtShover, 0, xx * 0.5, yy * 0.5).Radius:= 20;
- amFirePunch: CurAmmoGear:= AddGear(round(X) + hwSign(dX) * 10, round(Y), gtFirePunch, 0);
- amParachute: CurAmmoGear:= AddGear(round(X), round(Y), gtParachute, 0);
- amAirAttack: AddGear(0, 0, gtAirAttack, 0);
- amMineStrike: AddGear(0, 0, gtAirAttack, 1);
- amBlowTorch: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtBlowTorch, 0, hwSign(Gear.dX) * 0.5);
+ amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0);
+ amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, hwSign(dX) * _0_02, 0, 3000);
+ amDEagle: AddGear(hwRound(X), hwRound(Y), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
+ amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, hwSign(dX) * _0_03, 0, 5000);
+ amBaseballBat: AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0)^.Radius:= 20;
+ amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, 0, 0, 0);
+ amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, 0, 0, 0);
+ amAirAttack: AddGear(0, 0, gtAirAttack, 0, 0, 0, 0);
+ amMineStrike: AddGear(0, 0, gtAirAttack, 1, 0, 0, 0);
+ amBlowTorch: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBlowTorch, 0, hwSign(Gear^.dX) * _0_5, 0, 0);
end;
Power:= 0;
if CurAmmoGear <> nil then
begin
Message:= Message or gm_Attack;
- CurAmmoGear.Message:= Message
+ CurAmmoGear^.Message:= Message
end else begin
- if not CurrentTeam.ExtDriven and
- ((Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a');
+ if not CurrentTeam^.ExtDriven and
+ ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a');
AfterAttack
end
end else Message:= Message and not gm_Attack
@@ -88,14 +91,14 @@
procedure AfterAttack;
begin
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^,
- CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^,
+ CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
begin
Inc(AttacksNum);
State:= State and not gstAttacking;
- if Ammo[CurSlot, CurAmmo].NumPerTurn >= AttacksNum then isInMultiShoot:= true
+ if Ammo^[CurSlot, CurAmmo].NumPerTurn >= AttacksNum then isInMultiShoot:= true
else begin
- TurnTimeLeft:= Ammoz[Ammo[CurSlot, CurAmmo].AmmoType].TimeAfterTurn;
+ TurnTimeLeft:= Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].TimeAfterTurn;
State:= State or gstAttacked;
OnUsedAmmo(Ammo)
end;
@@ -108,21 +111,21 @@
var s: shortstring;
a: TAmmoType;
begin
-Gear.Message:= gm_Destroy;
-case Gear.Pos of
+Gear^.Message:= gm_Destroy;
+case Gear^.Pos of
posCaseAmmo: begin
- a:= TAmmoType(Gear.State);
- AddAmmo(PHedgehog(HH.Hedgehog), a);
+ a:= TAmmoType(Gear^.State);
+ AddAmmo(PHedgehog(HH^.Hedgehog), a);
s:= trammo[Ammoz[a].NameId];
- AddCaption(s, PHedgehog(HH.Hedgehog).Team.Color, capgrpAmmoinfo);
+ AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Color, capgrpAmmoinfo);
end;
posCaseHealth: begin
- inc(HH.Health, Gear.Health);
- str(Gear.Health, s);
+ inc(HH^.Health, Gear^.Health);
+ str(Gear^.Health, s);
s:= '+' + s;
- AddCaption(s, PHedgehog(HH.Hedgehog).Team.Color, capgrpAmmoinfo);
- RenderHealth(PHedgehog(HH.Hedgehog)^);
- RecountTeamHealth(PHedgehog(HH.Hedgehog)^.Team)
+ AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Color, capgrpAmmoinfo);
+ RenderHealth(PHedgehog(HH^.Hedgehog)^);
+ RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team)
end;
end;
end;
@@ -132,83 +135,82 @@
procedure HedgehogStep(Gear: PGear);
var PrevdX: integer;
begin
-if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0) then
+if ((Gear^.State and (gstAttacking or gstMoving or gstFalling)) = 0) then
begin
- if ((Gear.Message and gm_LJump ) <> 0) then
+ if ((Gear^.Message and gm_LJump ) <> 0) then
begin
- Gear.Message:= 0;
+ Gear^.Message:= 0;
if not TestCollisionYwithGear(Gear, -1) then
- if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else
- if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 1;
- if not (TestCollisionXwithGear(Gear, hwSign(Gear.dX))
+ if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - 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)) then
begin
- Gear.dY:= -0.15;
- Gear.dX:= hwSign(Gear.dX) * 0.15;
- Gear.State:= Gear.State or gstFalling or gstHHJumping;
+ Gear^.dY:= -_0_15;
+ Gear^.dX:= hwSign(Gear^.dX) * _0_15;
+ Gear^.State:= Gear^.State or gstFalling or gstHHJumping;
exit
end;
end;
- if ((Gear.Message and gm_HJump ) <> 0) then
+ if ((Gear^.Message and gm_HJump ) <> 0) then
begin
- Gear.Message:= 0;
+ Gear^.Message:= 0;
if not TestCollisionYwithGear(Gear, -1) then
begin
- Gear.dY:= -0.20;
- Gear.dX:= 0.0000001 * hwSign(Gear.dX);
- Gear.X:= Gear.X - hwSign(Gear.dX)*0.00008; // shift compensation
- Gear.State:= Gear.State or gstFalling or gstHHJumping;
+ Gear^.dY:= -_0_2;
+ SetLittle(Gear^.dX);
+ Gear^.State:= Gear^.State or gstFalling or gstHHJumping;
exit
end;
end;
- PrevdX:= hwSign(Gear.dX);
- if (Gear.Message and gm_Left )<>0 then Gear.dX:= -cLittle else
- if (Gear.Message and gm_Right )<>0 then Gear.dX:= cLittle else exit;
+ PrevdX:= hwSign(Gear^.dX);
+ if (Gear^.Message and gm_Left )<>0 then Gear^.dX:= -cLittle else
+ if (Gear^.Message and gm_Right )<>0 then Gear^.dX:= cLittle else exit;
StepTicks:= cHHStepTicks;
- if PrevdX <> hwSign(Gear.dX) then exit;
- PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7;
- if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then
+ if PrevdX <> hwSign(Gear^.dX) then exit;
+ PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7;
+ if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
begin
- if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
+ if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
+ if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
+ if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
+ if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
+ if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
+ if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
end;
- if not TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.X:= Gear.X + hwSign(Gear.dX);
+ if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + hwSign(Gear^.dX);
SetAllHHToActive;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear.Y:= Gear.Y + 1;
+ Gear^.Y:= Gear^.Y + 1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear.Y:= Gear.Y + 1;
+ Gear^.Y:= Gear^.Y + 1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear.Y:= Gear.Y + 1;
+ Gear^.Y:= Gear^.Y + 1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear.Y:= Gear.Y + 1;
+ Gear^.Y:= Gear^.Y + 1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear.Y:= Gear.Y + 1;
+ Gear^.Y:= Gear^.Y + 1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear.Y:= Gear.Y + 1;
+ Gear^.Y:= Gear^.Y + 1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear.Y:= Gear.Y - 6;
- Gear.dY:= 0;
- Gear.State:= Gear.State or gstFalling
+ Gear^.Y:= Gear^.Y - 6;
+ Gear^.dY:= 0;
+ Gear^.State:= Gear^.State or gstFalling
end;
end
end
@@ -221,10 +223,10 @@
procedure HedgehogChAngle(Gear: PGear);
begin
-if ((Gear.State and (gstMoving or gstFalling)) = 0) then
- if (Gear.Message and gm_Up )<>0 then if Gear.Angle > CurMinAngle then dec(Gear.Angle)
+if ((Gear^.State and (gstMoving or gstFalling)) = 0) then
+ if (Gear^.Message and gm_Up )<>0 then if Gear^.Angle > CurMinAngle then dec(Gear^.Angle)
else else
- if (Gear.Message and gm_Down )<>0 then if Gear.Angle < CurMaxAngle then inc(Gear.Angle);
+ if (Gear^.Message and gm_Down )<>0 then if Gear^.Angle < CurMaxAngle then inc(Gear^.Angle);
end;
procedure doStepHedgehog(Gear: PGear); forward;
@@ -232,21 +234,21 @@
procedure doStepHedgehogDriven(Gear: PGear);
var t: PGear;
begin
-if isInMultiShoot and (Gear.Damage = 0) then
+if isInMultiShoot and (Gear^.Damage = 0) then
begin
exit
end;
AllInactive:= false;
DeleteCI(Gear);
-if (TurnTimeLeft = 0) or (Gear.Damage > 0) then
+if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then
begin
TurnTimeLeft:= 0;
- Gear.State:= Gear.State and not gstHHDriven;
- if Gear.Damage > 0 then
- Gear.State:= Gear.State and not gstHHJumping;
+ Gear^.State:= Gear^.State and not gstHHDriven;
+ if Gear^.Damage > 0 then
+ Gear^.State:= Gear^.State and not gstHHJumping;
exit
end;
-if ((Gear.State and gstFalling) <> 0) or (StepTicks = cHHStepTicks)
+if ((Gear^.State and gstFalling) <> 0) or (StepTicks = cHHStepTicks)
or (CurAmmoGear <> nil) then // we're moving
begin
// check for case with ammo
@@ -257,41 +259,41 @@
if CurAmmoGear <> nil then
begin
- CurAmmoGear.Message:= Gear.Message;
+ CurAmmoGear^.Message:= Gear^.Message;
exit
end;
-if ((Gear.Message and gm_Attack) <> 0) or
- ((Gear.State and gstAttacking) <> 0)then Attack(Gear);
+if ((Gear^.Message and gm_Attack) <> 0) or
+ ((Gear^.State and gstAttacking) <> 0)then Attack(Gear);
-if (Gear.State and gstFalling) <> 0 then
+if (Gear^.State and gstFalling) <> 0 then
begin
- // it could be the source to trick: double-backspace jump -> vertical wall
- // collision - > (abs(Gear.dX) < 0.0000002) -> backspace -> even more high jump
- if ((Gear.Message and gm_HJump) <> 0) and ((Gear.State and gstHHJumping) <> 0) then
- if (abs(Gear.dX) < 2 * cLittle) and (Gear.dY < -0.02) then
+ // it could be the source to trick: hwFloat-backspace jump -> vertical wall
+ // collision - > (abs(Gear^.dX) < 0.0000002) -> backspace -> even more high jump
+ if ((Gear^.Message and gm_HJump) <> 0) and ((Gear^.State and gstHHJumping) <> 0) then
+ if (hwAbs(Gear^.dX) < cLittle + cLittle) and (Gear^.dY < -_0_02) then
begin
- Gear.dY:= -0.25;
- Gear.dX:= hwSign(Gear.dX) * 0.02
+ Gear^.dY:= -_0_25;
+ Gear^.dX:= hwSign(Gear^.dX) * _0_02
end;
- Gear.Message:= Gear.Message and not (gm_LJump or gm_HJump);
- if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then SetLittle(Gear.dX);
- Gear.X:= Gear.X + Gear.dX;
- Gear.dY:= Gear.dY + cGravity;
- if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0;
- Gear.Y:= Gear.Y + Gear.dY;
- if (Gear.dY >= 0)and TestCollisionYwithGear(Gear, 1) then
+ Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
+ if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX);
+ Gear^.X:= Gear^.X + Gear^.dX;
+ Gear^.dY:= Gear^.dY + cGravity;
+ if (Gear^.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0;
+ Gear^.Y:= Gear^.Y + Gear^.dY;
+ if (not Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, 1) then
begin
CheckHHDamage(Gear);
- if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55)
- and ((Gear.State and gstHHJumping) <> 0) then SetLittle(Gear.dX);
- Gear.State:= Gear.State and not (gstFalling or gstHHJumping);
- StepTicks:= 300;
- Gear.dY:= 0
+ if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55)
+ and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX);
+ Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping);
+ StepTicks:= 300;
+ Gear^.dY:= 0
end;
CheckGearDrowning(Gear);
exit
- end ;//else if Gear.CollIndex = High(Longword) then AddIntersectorsCR(Gear);
+ end ;//else if Gear^.CollIndex = High(Longword) then AddIntersectorsCR(Gear);
HedgehogChAngle(Gear);
if StepTicks > 0 then dec(StepTicks);
@@ -304,79 +306,79 @@
//DeleteCI(Gear);
if not TestCollisionYwithGear(Gear, 1) then
begin
- if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0;
- Gear.State:= Gear.State or gstFalling or gstMoving;
- Gear.dY:= Gear.dY + cGravity
+ if (Gear^.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0;
+ Gear^.State:= Gear^.State or gstFalling or gstMoving;
+ Gear^.dY:= Gear^.dY + cGravity
end else begin
CheckHHDamage(Gear);
- if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55)
- and ((Gear.State and gstHHJumping) <> 0) then SetLittle(Gear.dX);
- Gear.State:= Gear.State and not (gstFalling or gstHHJumping);
- if Gear.dY > 0 then Gear.dY:= 0;
- if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction
+ if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55)
+ and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX);
+ Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping);
+ if Gear^.dY > 0 then Gear^.dY:= 0;
+ if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction
end;
-if (Gear.State <> 0) then DeleteCI(Gear);
+if (Gear^.State <> 0) then DeleteCI(Gear);
-if (Gear.State and gstMoving) <> 0 then
- if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then
- if ((Gear.State and gstFalling) = 0) then
- if abs(Gear.dX) > 0.01 then
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -1, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.96; Gear.Y:= Gear.Y - 1 end else
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -2, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.93; Gear.Y:= Gear.Y - 2 end else
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -3, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.90; Gear.Y:= Gear.Y - 3 end else
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -4, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.87; Gear.Y:= Gear.Y - 4 end else
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -5, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.84; Gear.Y:= Gear.Y - 5 end else
- if abs(Gear.dX) > 0.02 then Gear.dX:= -Gear.Elasticity * Gear.dX
+if (Gear^.State and gstMoving) <> 0 then
+ if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
+ if ((Gear^.State and gstFalling) = 0) then
+ if hwAbs(Gear^.dX) > _0_01 then
+ if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -1, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_96; Gear^.Y:= Gear^.Y - 1 end else
+ if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -2, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_93; Gear^.Y:= Gear^.Y - 2 end else
+ if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -3, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_9; Gear^.Y:= Gear^.Y - 3 end else
+ if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -4, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_87; Gear^.Y:= Gear^.Y - 4 end else
+ if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -5, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_84; Gear^.Y:= Gear^.Y - 5 end else
+ if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX
else begin
- Gear.State:= Gear.State and not gstMoving;
- SetLittle(Gear.dX)
+ Gear^.State:= Gear^.State and not gstMoving;
+ SetLittle(Gear^.dX)
end
else begin
- Gear.State:= Gear.State and not gstMoving;
- SetLittle(Gear.dX)
+ Gear^.State:= Gear^.State and not gstMoving;
+ SetLittle(Gear^.dX)
end
- else Gear.dX:= -Gear.Elasticity * Gear.dX;
+ else Gear^.dX:= -Gear^.Elasticity * Gear^.dX;
-if ((Gear.State and gstFalling) = 0)and
- (sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then
+if ((Gear^.State and gstFalling) = 0)and
+ (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then
begin
- Gear.State:= Gear.State and not gstMoving;
- SetLittle(Gear.dX);
- Gear.dY:= 0
- end else Gear.State:= Gear.State or gstMoving;
+ Gear^.State:= Gear^.State and not gstMoving;
+ SetLittle(Gear^.dX);
+ Gear^.dY:= 0
+ end else Gear^.State:= Gear^.State or gstMoving;
-if (Gear.State and gstMoving) <> 0 then
+if (Gear^.State and gstMoving) <> 0 then
begin
- Gear.X:= Gear.X + Gear.dX;
- Gear.Y:= Gear.Y + Gear.dY;
- if (Gear.dY > 0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then
+ Gear^.X:= Gear^.X + Gear^.dX;
+ Gear^.Y:= Gear^.Y + Gear^.dY;
+ if (Gear^.dY > 0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then
begin
CheckHHDamage(Gear);
- Gear.dY:= 0;
- Gear.Y:= Gear.Y + 1
+ Gear^.dY:= 0;
+ Gear^.Y:= Gear^.Y + 1
end;
end else
- if Gear.Health = 0 then
+ if Gear^.Health = 0 then
begin
if AllInactive then
begin
- doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound);
- AddGear(round(Gear.X), round(Gear.Y), gtGrave, 0).Hedgehog:= Gear.Hedgehog;
+ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound);
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog;
DeleteGear(Gear);
SetAllToActive
end;
- AllInactive:= false;
+ AllInactive:= false;
exit
end;
AllInactive:= false;
if (not CheckGearDrowning(Gear)) and
- ((Gear.State and gstMoving) = 0) then
+ ((Gear^.State and gstMoving) = 0) then
begin
- Gear.State:= 0;
- Gear.Active:= false;
+ Gear^.State:= 0;
+ Gear^.Active:= false;
AddGearCI(Gear);
exit
end
@@ -385,11 +387,11 @@
////////////////////////////////////////////////////////////////////////////////
procedure doStepHedgehog(Gear: PGear);
begin
-if (Gear.Message and gm_Destroy) <> 0 then
+if (Gear^.Message and gm_Destroy) <> 0 then
begin
DeleteGear(Gear);
exit
end;
-if (Gear.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear)
+if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear)
else doStepHedgehogDriven(Gear)
end;
--- a/hedgewars/SDLh.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/SDLh.pas Sun Jan 21 19:51:02 2007 +0000
@@ -47,7 +47,7 @@
SDL_ASYNCBLIT = $00000004;
SDL_ANYFORMAT = $10000000;
SDL_HWPALETTE = $20000000;
- SDL_DOUBLEBUF = $40000000;
+ SDL_hwFloatBUF = $40000000;
SDL_FULLSCREEN = $80000000;
SDL_NOFRAME = $00000020;
SDL_HWACCEL = $00000100;
--- a/hedgewars/hwengine.dpr Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/hwengine.dpr Sun Jan 21 19:51:02 2007 +0000
@@ -43,7 +43,8 @@
uLandGraphics in 'uLandGraphics.pas',
uLocale in 'uLocale.pas',
uAmmos in 'uAmmos.pas',
- uSHA in 'uSHA.pas';
+ uSHA in 'uSHA.pas',
+ uFloat in 'uFloat.pas';
{$INCLUDE options.inc}
@@ -102,7 +103,7 @@
flagMakeCapture:= false;
s:= 'hw_' + cSeed + '_' + inttostr(GameTicks) + '.bmp';
WriteLnToConsole('Saving ' + s);
- SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(PChar(s), 'wb'), 1)
+// SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(PChar(s), 'wb'), 1)
end;
end;
@@ -154,7 +155,7 @@
procedure GetParams;
var c: integer;
{$IFDEF DEBUGFILE}
- i: integer;
+ i: integer;
{$ENDIF}
p: TPathType;
begin
@@ -194,8 +195,8 @@
procedure ShowMainWindow;
begin
-if cFullScreen then ParseCommand('fullscr 1')
- else ParseCommand('fullscr 0');
+if cFullScreen then ParseCommand('fullscr 1', true)
+ else ParseCommand('fullscr 0', true);
SDL_ShowCursor(0)
end;
@@ -225,7 +226,7 @@
SendIPCRaw(@s[0], Length(s) + 1); // send proto version
InitTeams;
-ParseCommand('ammstore 91911111111111108');
+ParseCommand('ammstore 91911111111111108', true);
AssignStores;
if isSoundEnabled then InitSound;
--- a/hedgewars/options.inc Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/options.inc Sun Jan 21 19:51:02 2007 +0000
@@ -17,6 +17,7 @@
*)
{$J+}
+
{$DEFINE DEBUGFILE}
{ $DEFINE COUNTTICKS}
{ $DEFINE DUMP}
--- a/hedgewars/tunsetborder.inc Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/tunsetborder.inc Sun Jan 21 19:51:02 2007 +0000
@@ -1,8 +1,8 @@
begin
X:= X + dX;
Y:= Y + dY;
- tx:= round(X);
- ty:= round(Y);
+ tx:= hwRound(X);
+ ty:= hwRound(Y);
if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0)and (Land[ty, tx] = $FFFFFF) then
SetLandPixel(ty, tx)
- end;
\ No newline at end of file
+ end;
--- a/hedgewars/uAI.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uAI.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,12 +18,13 @@
unit uAI;
interface
+uses uFloat;
{$INCLUDE options.inc}
procedure ProcessBot(FrameNo: Longword);
procedure FreeActionsList;
implementation
-uses uTeams, uConsts, SDLh, uAIMisc, uGears, uAIAmmoTests, uAIActions, uMisc,
+{uses uTeams, uConsts, SDLh, uAIMisc, uGears, uAIAmmoTests, uAIActions, uMisc,
uAIThinkStack, uAmmos;
var BestActions: TActions;
@@ -31,13 +32,13 @@
AIThinkStart: Longword;
isThinking: boolean = false;
-procedure FreeActionsList;
+}procedure FreeActionsList;
begin
-isThinking:= false;
+{isThinking:= false;
BestActions.Count:= 0;
BestActions.Pos:= 0
-end;
-
+}end;
+{
procedure TestAmmos(var Actions: TActions; Me: PGear);
var Time, BotLevel: Longword;
Angle, Power, Score, ExplX, ExplY, ExplR: integer;
@@ -235,12 +236,12 @@
BestActions.Score:= Low(integer);
Think(Me)
-end;
+end; }
procedure ProcessBot(FrameNo: Longword);
-const LastFrameNo: Longword = 0;
+//const LastFrameNo: Longword = 0;
begin
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+{with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
if (Gear <> nil)
and ((Gear.State and gstHHDriven) <> 0)
and (TurnTimeLeft < cHedgehogTurnTime - 50) then
@@ -252,6 +253,6 @@
LastFrameNo:= FrameNo;
Think(Gear)
end;
-end;
+}end;
end.
--- a/hedgewars/uAIActions.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uAIActions.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,9 +18,9 @@
unit uAIActions;
interface
-uses uGears;
+uses uGears, uFloat;
{$INCLUDE options.inc}
-const MAXACTIONS = 96;
+(*const MAXACTIONS = 96;
aia_none = 0;
aia_Left = 1;
aia_Right = 2;
@@ -57,9 +57,9 @@
procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword; const X: integer = 0; Y: integer = 0);
procedure ProcessAction(var Actions: TActions; Me: PGear);
-
+*)
implementation
-uses uMisc, uTeams, uConsts, uConsole, uAIMisc;
+(*uses uMisc, uTeams, uConsts, uConsole, uAIMisc;
const ActionIdToStr: array[0..6] of string[16] = (
{aia_none} '',
@@ -191,5 +191,5 @@
inc(Actions.actions[Actions.Pos].Time, GameTicks);
until false
end;
-
+*)
end.
--- a/hedgewars/uAIAmmoTests.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uAIAmmoTests.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,9 +18,9 @@
unit uAIAmmoTests;
interface
-uses SDLh, uGears, uConsts;
+uses SDLh, uGears, uConsts, uFloat;
-function TestBazooka(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
+(*function TestBazooka(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
function TestGrenade(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
function TestShotgun(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
function TestDesertEagle(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
@@ -50,22 +50,23 @@
);
const BadTurn = Low(integer);
+*)
implementation
uses uMisc, uAIMisc, uLand;
-
+{
function Metric(x1, y1, x2, y2: integer): integer;
begin
Result:= abs(x1 - x2) + abs(y1 - y2)
end;
function TestBazooka(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
-var Vx, Vy, r: Double;
- rTime: Double;
+var Vx, Vy, r: hwFloat;
+ rTime: hwFloat;
Score, EX, EY: integer;
function CheckTrace: integer;
- var x, y, dX, dY: Double;
+ var x, y, dX, dY: hwFloat;
t: integer;
begin
x:= Me.X;
@@ -115,12 +116,12 @@
function TestGrenade(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
const tDelta = 24;
-var Vx, Vy, r: Double;
+var Vx, Vy, r: hwFloat;
Score, EX, EY: integer;
TestTime: Longword;
function CheckTrace: integer;
- var x, y, dY: Double;
+ var x, y, dY: hwFloat;
t: integer;
begin
x:= Me.X;
@@ -167,7 +168,7 @@
end;
function TestShotgun(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
-var Vx, Vy, x, y: Double;
+var Vx, Vy, x, y: hwFloat;
begin
ExplR:= 0;
if Metric(round(Me.X), round(Me.Y), Targ.X, Targ.Y) < 80 then
@@ -197,7 +198,7 @@
end;
function TestDesertEagle(Me: PGear; Targ: TPoint; Level: Integer; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
-var Vx, Vy, x, y, t: Double;
+var Vx, Vy, x, y, t: hwFloat;
d: Longword;
begin
ExplR:= 0;
@@ -257,5 +258,5 @@
Result:= Result + RateShove(Me, round(Me.X) + 10 * hwSign(Targ.X - Me.X), round(Me.Y) - 20 * i - 5, 10, 30);
if Result <= 0 then Result:= BadTurn
end;
-
+}
end.
--- a/hedgewars/uAIMisc.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uAIMisc.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,9 +18,9 @@
unit uAIMisc;
interface
-uses SDLh, uConsts, uGears;
+uses SDLh, uConsts, uGears, uFloat;
{$INCLUDE options.inc}
-
+ {
type TTarget = record
Point: TPoint;
Score: integer;
@@ -48,9 +48,9 @@
var ThinkingHH: PGear;
Targets: TTargets;
-
+ }
implementation
-uses uTeams, uMisc, uLand, uCollisions;
+{uses uTeams, uMisc, uLand, uCollisions;
const KillScore = 200;
MAXBONUS = 1024;
@@ -389,6 +389,6 @@
begin
if random(2) = 0 then Result:= num
else Result:= - num
-end;
+end; }
end.
--- a/hedgewars/uAmmos.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uAmmos.pas Sun Jan 21 19:51:02 2007 +0000
@@ -28,8 +28,8 @@
if cnts[a] > 0 then
begin
TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true);
- Ammo[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo;
- Ammo[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= cnts[a];
+ Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo;
+ Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= cnts[a];
inc(mi[Ammoz[a].Slot])
end
end;
@@ -59,7 +59,7 @@
function GetAmmoByNum(num: Longword): PHHAmmo;
begin
TryDo(num < StoreCnt, 'Invalid store number', true);
-Result:= StoresList[num]
+exit(StoresList[num])
end;
procedure AssignStores;
@@ -70,9 +70,9 @@
while tteam <> nil do
begin
for i:= 0 to cMaxHHIndex do
- if tteam.Hedgehogs[i].Gear <> nil then
- tteam.Hedgehogs[i].Ammo:= GetAmmoByNum(tteam.Hedgehogs[i].AmmoStore);
- tteam:= tteam.Next
+ if tteam^.Hedgehogs[i].Gear <> nil then
+ tteam^.Hedgehogs[i].Ammo:= GetAmmoByNum(tteam^.Hedgehogs[i].AmmoStore);
+ tteam:= tteam^.Next
end
end;
@@ -82,12 +82,12 @@
hhammo: PHHAmmo;
begin
FillChar(ammos, sizeof(ammos), 0);
-hhammo:= PHedgehog(Hedgehog).Ammo;
+hhammo:= PHedgehog(Hedgehog)^.Ammo;
for slot:= 0 to cMaxSlotIndex do
for ami:= 0 to cMaxSlotAmmoIndex do
- if hhammo[slot, ami].Count > 0 then
- ammos[hhammo[slot, ami].AmmoType]:= hhammo[slot, ami].Count;
+ if hhammo^[slot, ami].Count > 0 then
+ ammos[hhammo^[slot, ami].AmmoType]:= hhammo^[slot, ami].Count;
if ammos[ammo] <> AMMO_INFINITE then inc(ammos[ammo]);
FillAmmoStore(hhammo, ammos)
@@ -101,13 +101,13 @@
b:= false;
ami:= 0;
while (not b) and (ami < cMaxSlotAmmoIndex) do
- if (Ammo[Slot, ami].Count = 0)
- and (Ammo[Slot, ami + 1].Count > 0) then b:= true
+ if (Ammo^[Slot, ami].Count = 0)
+ and (Ammo^[Slot, ami + 1].Count > 0) then b:= true
else inc(ami);
if b then // there's a free item in ammo stack
begin
- Ammo[Slot, ami]:= Ammo[Slot, ami + 1];
- Ammo[Slot, ami + 1].Count:= 0
+ Ammo^[Slot, ami]:= Ammo^[Slot, ami + 1];
+ Ammo^[Slot, ami + 1].Count:= 0
end;
until not b;
end;
@@ -115,11 +115,11 @@
procedure OnUsedAmmo(Ammo: PHHAmmo);
var s, a: Longword;
begin
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
begin
if CurAmmoGear = nil then begin s:= CurSlot; a:= CurAmmo end
else begin s:= AltSlot; a:= AltAmmo end;
- with Ammo[s, a] do
+ with Ammo^[s, a] do
if Count <> AMMO_INFINITE then
begin
dec(Count);
@@ -133,13 +133,13 @@
begin
Slot:= Ammoz[Ammo].Slot;
ami:= 0;
-Result:= false;
-while (not Result) and (ami <= cMaxSlotAmmoIndex) do
+while (ami <= cMaxSlotAmmoIndex) do
begin
- with PHedgehog(Hedgehog).Ammo[Slot, ami] do
- if (AmmoType = Ammo) and (Count > 0) then Result:= true;
+ with PHedgehog(Hedgehog)^.Ammo^[Slot, ami] do
+ if (AmmoType = Ammo) and (Count > 0) then exit(true);
inc(ami)
- end
+ end;
+HHHasAmmo:= false
end;
end.
--- a/hedgewars/uCollisions.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uCollisions.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,7 +18,7 @@
unit uCollisions;
interface
-uses uGears;
+uses uGears, uFloat;
{$INCLUDE options.inc}
const cMaxGearArrayInd = 255;
@@ -34,7 +34,7 @@
function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean;
function TestCollisionYwithGear(Gear: PGear; Dir: integer): boolean;
function TestCollisionY(Gear: PGear; Dir: integer): boolean;
-function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: Double; Dir: integer): boolean;
+function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: hwFloat; Dir: integer): boolean;
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean;
implementation
@@ -44,7 +44,7 @@
X, Y, Radius: integer;
cGear: PGear;
end;
-
+
const MAXRECTSINDEX = 255;
var Count: Longword = 0;
cinfos: array[0..MAXRECTSINDEX] of TCollisionEntry;
@@ -52,28 +52,28 @@
procedure AddGearCI(Gear: PGear);
begin
-if Gear.CollIndex < High(Longword) then exit;
+if Gear^.CollIndex < High(Longword) then exit;
TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true);
with cinfos[Count] do
begin
- X:= round(Gear.X);
- Y:= round(Gear.Y);
- Radius:= Gear.Radius;
+ X:= hwRound(Gear^.X);
+ Y:= hwRound(Gear^.Y);
+ Radius:= Gear^.Radius;
FillRoundInLand(X, Y, Radius-1, $FF);
cGear:= Gear
end;
-Gear.CollIndex:= Count;
+Gear^.CollIndex:= Count;
inc(Count)
end;
procedure DeleteCI(Gear: PGear);
begin
-if Gear.CollIndex < Count then
+if Gear^.CollIndex < Count then
begin
- with cinfos[Gear.CollIndex] do FillRoundInLand(X, Y, Radius-1, 0);
- cinfos[Gear.CollIndex]:= cinfos[Pred(Count)];
- cinfos[Gear.CollIndex].cGear.CollIndex:= Gear.CollIndex;
- Gear.CollIndex:= High(Longword);
+ with cinfos[Gear^.CollIndex] do FillRoundInLand(X, Y, Radius-1, 0);
+ cinfos[Gear^.CollIndex]:= cinfos[Pred(Count)];
+ cinfos[Gear^.CollIndex].cGear^.CollIndex:= Gear^.CollIndex;
+ Gear^.CollIndex:= High(Longword);
dec(Count)
end;
end;
@@ -81,93 +81,98 @@
function CheckGearsCollision(Gear: PGear): PGearArray;
var mx, my: integer;
i: Longword;
+ Result: PGearArray;
begin
Result:= @ga;
ga.Count:= 0;
if Count = 0 then exit;
-mx:= round(Gear.X);
-my:= round(Gear.Y);
+mx:= hwRound(Gear^.X);
+my:= hwRound(Gear^.Y);
for i:= 0 to Pred(Count) do
with cinfos[i] do
if (Gear <> cGear) and
- (sqrt(sqr(mx - x) + sqr(my - y)) <= Radius + Gear.Radius) then
+ (sqrt(sqr(mx - x) + sqr(my - y)) <= Radius + Gear^.Radius) then
begin
ga.ar[ga.Count]:= cinfos[i].cGear;
inc(ga.Count)
end;
+CheckGearsCollision:= Result
end;
function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean;
var x, y, i: integer;
begin
-Result:= false;
-x:= round(Gear.X);
-if Dir < 0 then x:= x - Gear.Radius
- else x:= x + Gear.Radius;
+x:= hwRound(Gear^.X);
+if Dir < 0 then x:= x - Gear^.Radius
+ else x:= x + Gear^.Radius;
if (x and $FFFFF800) = 0 then
begin
- y:= round(Gear.Y) - Gear.Radius + 1;
- i:= y + Gear.Radius * 2 - 2;
+ y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
+ i:= y + Gear^.Radius * 2 - 2;
repeat
- if (y and $FFFFFC00) = 0 then Result:= Land[y, x]<>0;
+ if (y and $FFFFFC00) = 0 then
+ if Land[y, x] <> 0 then exit(true);
inc(y)
- until (y > i) or Result;
- end
+ until (y > i);
+ end;
+TestCollisionXwithGear:= false
end;
-function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: Double; Dir: integer): boolean;
+function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: hwFloat; Dir: integer): boolean;
begin
-Gear.X:= Gear.X + ShiftX;
-Gear.Y:= Gear.Y + ShiftY;
-Result:= TestCollisionXwithGear(Gear, Dir);
-Gear.X:= Gear.X - ShiftX;
-Gear.Y:= Gear.Y - ShiftY
+Gear^.X:= Gear^.X + ShiftX;
+Gear^.Y:= Gear^.Y + ShiftY;
+TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir);
+Gear^.X:= Gear^.X - ShiftX;
+Gear^.Y:= Gear^.Y - ShiftY
end;
function TestCollisionYwithGear(Gear: PGear; Dir: integer): boolean;
var x, y, i: integer;
begin
-Result:= false;
-y:= round(Gear.Y);
-if Dir < 0 then y:= y - Gear.Radius
- else y:= y + Gear.Radius;
+y:= hwRound(Gear^.Y);
+if Dir < 0 then y:= y - Gear^.Radius
+ else y:= y + Gear^.Radius;
if (y and $FFFFFC00) = 0 then
begin
- x:= round(Gear.X) - Gear.Radius + 1;
- i:= x + Gear.Radius * 2 - 2;
+ x:= hwRound(Gear^.X) - Gear^.Radius + 1;
+ i:= x + Gear^.Radius * 2 - 2;
repeat
- if (x and $FFFFF800) = 0 then Result:= Land[y, x]<>0;
+ if (x and $FFFFF800) = 0 then
+ if Land[y, x] <> 0 then exit(true);
inc(x)
- until (x > i) or Result;
- end
+ until (x > i);
+ end;
+TestCollisionYwithGear:= false
end;
function TestCollisionY(Gear: PGear; Dir: integer): boolean;
var x, y, i: integer;
begin
-Result:= false;
-y:= round(Gear.Y);
-if Dir < 0 then y:= y - Gear.Radius
- else y:= y + Gear.Radius;
+y:= hwRound(Gear^.Y);
+if Dir < 0 then y:= y - Gear^.Radius
+ else y:= y + Gear^.Radius;
if (y and $FFFFFC00) = 0 then
begin
- x:= round(Gear.X) - Gear.Radius + 1;
- i:= x + Gear.Radius * 2 - 2;
+ x:= hwRound(Gear^.X) - Gear^.Radius + 1;
+ i:= x + Gear^.Radius * 2 - 2;
repeat
- if (x and $FFFFF800) = 0 then Result:= Land[y, x] = COLOR_LAND;
+ if (x and $FFFFF800) = 0 then
+ if Land[y, x] = COLOR_LAND then exit(true);
inc(x)
- until (x > i) or Result;
- end
+ until (x > i);
+ end;
+TestCollisionY:= false
end;
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean;
begin
-Gear.X:= Gear.X + ShiftX;
-Gear.Y:= Gear.Y + ShiftY;
-Result:= TestCollisionYwithGear(Gear, Dir);
-Gear.X:= Gear.X - ShiftX;
-Gear.Y:= Gear.Y - ShiftY
+Gear^.X:= Gear^.X + ShiftX;
+Gear^.Y:= Gear^.Y + ShiftY;
+TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir);
+Gear^.X:= Gear^.X - ShiftX;
+Gear^.Y:= Gear^.Y - ShiftY
end;
end.
--- a/hedgewars/uConsole.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uConsole.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,17 +18,17 @@
unit uConsole;
interface
-uses SDLh;
+uses SDLh, uFloat;
{$INCLUDE options.inc}
const isDeveloperMode: boolean = true;
-type TVariableType = (vtCommand, vtInteger, vtDouble, vtBoolean);
+type TVariableType = (vtCommand, vtInteger, vthwFloat, vtBoolean);
TCommandHandler = procedure (var params: shortstring);
procedure DrawConsole(Surface: PSDL_Surface);
procedure WriteToConsole(s: shortstring);
procedure WriteLnToConsole(s: shortstring);
procedure KeyPressConsole(Key: Longword);
-procedure ParseCommand(CmdStr: shortstring; const TrustedSource: boolean = true);
+procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
function GetLastConsoleLine: shortstring;
implementation
@@ -37,7 +37,7 @@
uRandom, uAmmos;
const cLineWidth: integer = 0;
cLinesCount = 256;
-
+
type PVariable = ^TVariable;
TVariable = record
Next: PVariable;
@@ -53,20 +53,23 @@
Variables: PVariable = nil;
function RegisterVariable(Name: string; VType: TVariableType; p: pointer; Trusted: boolean): PVariable;
+var Result: PVariable;
begin
New(Result);
TryDo(Result <> nil, 'RegisterVariable: Result = nil', true);
FillChar(Result^, sizeof(TVariable), 0);
-Result.Name:= Name;
-Result.VType:= VType;
-Result.Handler:= p;
-Result.Trusted:= Trusted;
+Result^.Name:= Name;
+Result^.VType:= VType;
+Result^.Handler:= p;
+Result^.Trusted:= Trusted;
if Variables = nil then Variables:= Result
else begin
- Result.Next:= Variables;
+ Result^.Next:= Variables;
Variables:= Result
- end
+ end;
+
+RegisterVariable:= Result
end;
procedure FreeVariablesList;
@@ -74,10 +77,10 @@
begin
tt:= Variables;
Variables:= nil;
-while tt<>nil do
+while tt <> nil do
begin
t:= tt;
- tt:= tt.Next;
+ tt:= tt^.Next;
Dispose(t)
end;
end;
@@ -151,8 +154,8 @@
for i:= 0 to Pred(cLinesCount) do PLongWord(@ConsoleLines[i])^:= 0
end;
-procedure ParseCommand(CmdStr: shortstring; const TrustedSource: boolean = true);
-type PDouble = ^Double;
+procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
+type PhwFloat = ^hwFloat;
var i, ii: integer;
s: shortstring;
t: PVariable;
@@ -167,39 +170,39 @@
t:= Variables;
while t <> nil do
begin
- if t.Name = CmdStr then
+ if t^.Name = CmdStr then
begin
- if TrustedSource or t.Trusted then
- case t.VType of
+ if TrustedSource or t^.Trusted then
+ case t^.VType of
vtCommand: if c='/' then
begin
- TCommandHandler(t.Handler)(s);
+ TCommandHandler(t^.Handler)(s);
end;
vtInteger: if c='$' then
if s[0]=#0 then
begin
- str(PInteger(t.Handler)^, s);
+ str(PInteger(t^.Handler)^, s);
WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
- end else val(s, PInteger(t.Handler)^, i);
- vtDouble: if c='$' then
+ end else val(s, PInteger(t^.Handler)^, i);
+ vthwFloat: if c='$' then
if s[0]=#0 then
begin
- str(PDouble(t.Handler)^:4:6, s);
+ //str(PhwFloat(t^.Handler)^:4:6, s);
WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
- end else val(s, PDouble(t.Handler)^ , i);
+ end else; //val(s, PhwFloat(t^.Handler)^, i);
vtBoolean: if c='$' then
if s[0]=#0 then
begin
- str(ord(boolean(t.Handler^)), s);
+ str(ord(boolean(t^.Handler^)), s);
WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
end else
begin
val(s, ii, i);
- boolean(t.Handler^):= not (ii = 0)
+ boolean(t^.Handler^):= not (ii = 0)
end;
end;
exit
- end else t:= t.Next
+ end else t:= t^.Next
end;
case c of
'$': WriteLnToConsole(errmsgUnknownVariable + ': "$' + CmdStr + '"')
@@ -218,15 +221,15 @@
t:= Variables;
while t <> nil do
begin
- if (c=#0) or ((t.VType = vtCommand) and (c='/'))or
- ((t.VType <> vtCommand) and (c='$'))then
- if copy(t.Name, 1, Length(InputStr)) = InputStr then
+ if (c=#0) or ((t^.VType = vtCommand) and (c='/'))or
+ ((t^.VType <> vtCommand) and (c='$'))then
+ if copy(t^.Name, 1, Length(InputStr)) = InputStr then
begin
- if t.VType = vtCommand then InputStr:= '/' + t.Name + ' '
- else InputStr:= '$' + t.Name + ' ';
+ if t^.VType = vtCommand then InputStr:= '/' + t^.Name + ' '
+ else InputStr:= '$' + t^.Name + ' ';
exit
end;
- t:= t.Next
+ t:= t^.Next
end
end;
@@ -253,8 +256,8 @@
function GetLastConsoleLine: shortstring;
begin
-if CurrLine = 0 then Result:= ConsoleLines[Pred(cLinesCount)]
- else Result:= ConsoleLines[Pred(CurrLine)]
+if CurrLine = 0 then GetLastConsoleLine:= ConsoleLines[Pred(cLinesCount)]
+ else GetLastConsoleLine:= ConsoleLines[Pred(CurrLine)]
end;
{$INCLUDE CCHandlers.inc}
--- a/hedgewars/uConsts.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uConsts.pas Sun Jan 21 19:51:02 2007 +0000
@@ -121,8 +121,6 @@
cHHStepTicks = 38;
cHHZ = 1000;
cCurrHHZ = Succ(cHHZ);
- cHHKick = 0.03;
- cLittle = 0.0000001;
cKeyMaxIndex = 1023;
@@ -184,10 +182,12 @@
cThemeCFGFilename = 'theme.cfg';
Fontz: array[THWFont] of THHFont = (
- (Height: 12;
+ (Handle: nil;
+ Height: 12;
style: TTF_STYLE_NORMAL;
Name: 'DejaVuSans.ttf'),
- (Height: 24;
+ (Handle: nil;
+ Height: 24;
style: TTF_STYLE_NORMAL;
Name: 'DejaVuSans.ttf')
);
@@ -241,40 +241,72 @@
Width, Height: integer;
hasAlpha: boolean;
end = (
- (FileName: 'BlueWater'; Path: ptGraphics; Width: 256; Height: 48; hasAlpha: false),// sprWater
- (FileName: 'Clouds'; Path: ptCurrTheme;
- AltPath: ptGraphics; Width: 256; Height:128; hasAlpha: false),// sprCloud
- (FileName: 'Bomb'; Path: ptGraphics; Width: 16; Height: 16; hasAlpha: false),// sprBomb
- (FileName: 'BigDigits'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: true),// sprBigDigit
- (FileName: 'Frame'; Path: ptGraphics; Width: 4; Height: 32; hasAlpha: true),// sprFrame
- (FileName: 'Lag'; Path: ptGraphics; Width: 64; Height: 64; hasAlpha: false),// sprLag
- (FileName: 'Arrow'; Path: ptGraphics; Width: 16; Height: 16; hasAlpha: false),// sprCursor
- (FileName: 'Grenade'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: false),// sprGrenade
- (FileName: 'Targetp'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: false),// sprTargetP
- (FileName: 'UFO'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: false),// sprUFO
- (FileName:'SmokeTrace'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: true),// sprSmokeTrace
- (FileName: 'RopeHook'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: false),// sprRopeHook
- (FileName: 'Expl50'; Path: ptGraphics; Width: 64; Height: 64; hasAlpha: false),// sprExplosion50
- (FileName: 'MineOff'; Path: ptGraphics; Width: 16; Height: 16; hasAlpha: false),// sprMineOff
- (FileName: 'MineOn'; Path: ptGraphics; Width: 16; Height: 16; hasAlpha: false),// sprMineOn
- (FileName: 'Case'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: false),// sprCase
- (FileName: 'FirstAid'; Path: ptGraphics; Width: 48; Height: 48; hasAlpha: false),// sprFAid
- (FileName: 'dynamite'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: false),// sprDynamite
- (FileName: 'Power'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: true),// sprPower
- (FileName: 'ClBomb'; Path: ptGraphics; Width: 16; Height: 16; hasAlpha: false),// sprClusterBomb
- (FileName:'ClParticle'; Path: ptGraphics; Width: 16; Height: 16; hasAlpha: false),// sprClusterParticle
- (FileName: 'Flame'; Path: ptGraphics; Width: 16; Height: 16; hasAlpha: false),// sprFlame
- (FileName: 'horizont'; Path: ptCurrTheme;Width: 0; Height: 0; hasAlpha: false),// sprHorizont
- (FileName: 'Sky'; Path: ptCurrTheme;Width: 0; Height: 0; hasAlpha: false),// sprSky
- (FileName: 'BrdrLines'; Path: ptAmmoMenu; Width: 202; Height: 1; hasAlpha: false),// sprAMBorders
- (FileName: 'Slot'; Path: ptAmmoMenu; Width: 202; Height: 33; hasAlpha: false),// sprAMSlot
- (FileName: 'AmmoName'; Path: ptAmmoMenu; Width: 202; Height: 33; hasAlpha: false),// sprAMSlotName
- (FileName: 'Ammos'; Path: ptAmmoMenu; Width: 32; Height: 32; hasAlpha: false),// sprAMAmmos
- (FileName: 'SlotKeys'; Path: ptAmmoMenu; Width: 32; Height: 32; hasAlpha: false),// sprAMSlotKeys
- (FileName: 'Selection'; Path: ptAmmoMenu; Width: 32; Height: 32; hasAlpha: false),// sprAMSelection
- (FileName: 'Finger'; Path: ptGraphics; Width: 32; Height: 48; hasAlpha: false),// sprFinger
- (FileName: 'AirBomb'; Path: ptGraphics; Width: 32; Height: 32; hasAlpha: false),// sprAirBomb
- (FileName: 'Airplane'; Path: ptGraphics; Width: 125; Height: 42; hasAlpha: false) // sprAirplane
+ (FileName: 'BlueWater'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 256; Height: 48; hasAlpha: false),// sprWater
+ (FileName: 'Clouds'; Path: ptCurrTheme; AltPath: ptGraphics; Surface: nil;
+ Width: 256; Height:128; hasAlpha: false),// sprCloud
+ (FileName: 'Bomb'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 16; Height: 16; hasAlpha: false),// sprBomb
+ (FileName: 'BigDigits'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: true),// sprBigDigit
+ (FileName: 'Frame'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 4; Height: 32; hasAlpha: true),// sprFrame
+ (FileName: 'Lag'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 64; Height: 64; hasAlpha: false),// sprLag
+ (FileName: 'Arrow'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 16; Height: 16; hasAlpha: false),// sprCursor
+ (FileName: 'Grenade'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprGrenade
+ (FileName: 'Targetp'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprTargetP
+ (FileName: 'UFO'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprUFO
+ (FileName:'SmokeTrace'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: true),// sprSmokeTrace
+ (FileName: 'RopeHook'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprRopeHook
+ (FileName: 'Expl50'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 64; Height: 64; hasAlpha: false),// sprExplosion50
+ (FileName: 'MineOff'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 16; Height: 16; hasAlpha: false),// sprMineOff
+ (FileName: 'MineOn'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 16; Height: 16; hasAlpha: false),// sprMineOn
+ (FileName: 'Case'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprCase
+ (FileName: 'FirstAid'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 48; Height: 48; hasAlpha: false),// sprFAid
+ (FileName: 'dynamite'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprDynamite
+ (FileName: 'Power'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: true),// sprPower
+ (FileName: 'ClBomb'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 16; Height: 16; hasAlpha: false),// sprClusterBomb
+ (FileName:'ClParticle'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 16; Height: 16; hasAlpha: false),// sprClusterParticle
+ (FileName: 'Flame'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 16; Height: 16; hasAlpha: false),// sprFlame
+ (FileName: 'horizont'; Path: ptCurrTheme; AltPath: ptNone; Surface: nil;
+ Width: 0; Height: 0; hasAlpha: false),// sprHorizont
+ (FileName: 'Sky'; Path: ptCurrTheme; AltPath: ptNone; Surface: nil;
+ Width: 0; Height: 0; hasAlpha: false),// sprSky
+ (FileName: 'BrdrLines'; Path: ptAmmoMenu; AltPath: ptNone; Surface: nil;
+ Width: 202; Height: 1; hasAlpha: false),// sprAMBorders
+ (FileName: 'Slot'; Path: ptAmmoMenu; AltPath: ptNone; Surface: nil;
+ Width: 202; Height: 33; hasAlpha: false),// sprAMSlot
+ (FileName: 'AmmoName'; Path: ptAmmoMenu; AltPath: ptNone; Surface: nil;
+ Width: 202; Height: 33; hasAlpha: false),// sprAMSlotName
+ (FileName: 'Ammos'; Path: ptAmmoMenu; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprAMAmmos
+ (FileName: 'SlotKeys'; Path: ptAmmoMenu; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprAMSlotKeys
+ (FileName: 'Selection'; Path: ptAmmoMenu; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprAMSelection
+ (FileName: 'Finger'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 48; hasAlpha: false),// sprFinger
+ (FileName: 'AirBomb'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 32; Height: 32; hasAlpha: false),// sprAirBomb
+ (FileName: 'Airplane'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 125; Height: 42; hasAlpha: false) // sprAirplane
);
Soundz: array[TSound] of record
FileName: String[31];
@@ -309,7 +341,9 @@
Timer: 3000;
AmmoType: amGrenade);
Slot: 1;
- TimeAfterTurn: 3000),
+ TimeAfterTurn: 3000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidClusterBomb;
Ammo: (Propz: ammoprop_Timerable or
ammoprop_Power;
@@ -318,7 +352,9 @@
Timer: 3000;
AmmoType: amClusterBomb);
Slot: 1;
- TimeAfterTurn: 3000),
+ TimeAfterTurn: 3000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidBazooka;
Ammo: (Propz: ammoprop_Power;
Count: AMMO_INFINITE;
@@ -326,7 +362,9 @@
Timer: 0;
AmmoType: amBazooka);
Slot: 0;
- TimeAfterTurn: 3000),
+ TimeAfterTurn: 3000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidUFO;
Ammo: (Propz: ammoprop_Power or
ammoprop_NeedTarget;
@@ -335,7 +373,9 @@
Timer: 0;
AmmoType: amUFO);
Slot: 0;
- TimeAfterTurn: 3000),
+ TimeAfterTurn: 3000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidShotgun;
Ammo: (Propz: ammoprop_ForwMsgs;
Count: AMMO_INFINITE;
@@ -343,7 +383,9 @@
Timer: 0;
AmmoType: amShotgun);
Slot: 2;
- TimeAfterTurn: 3000),
+ TimeAfterTurn: 3000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidPickHammer;
Ammo: (Propz: ammoprop_ForwMsgs or
ammoprop_AttackInFall or
@@ -354,7 +396,9 @@
Timer: 0;
AmmoType: amPickHammer);
Slot: 6;
- TimeAfterTurn: 0),
+ TimeAfterTurn: 0;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidSkip;
Ammo: (Propz: 0;
Count: AMMO_INFINITE;
@@ -362,7 +406,9 @@
Timer: 0;
AmmoType: amSkip);
Slot: 8;
- TimeAfterTurn: 0),
+ TimeAfterTurn: 0;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidRope;
Ammo: (Propz: ammoprop_ForwMsgs or
ammoprop_AttackInFall or
@@ -373,6 +419,7 @@
AmmoType: amRope);
Slot: 7;
TimeAfterTurn: 0;
+ minAngle: 0;
maxAngle: cMaxAngle div 2),
(NameId: sidMine;
Ammo: (Propz: ammoprop_NoCrosshair;
@@ -381,7 +428,9 @@
Timer: 0;
AmmoType: amMine);
Slot: 4;
- TimeAfterTurn: 5000),
+ TimeAfterTurn: 5000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidDEagle;
Ammo: (Propz: 0;
Count: 3;
@@ -389,7 +438,9 @@
Timer: 0;
AmmoType: amDEagle);
Slot: 2;
- TimeAfterTurn: 3000),
+ TimeAfterTurn: 3000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidDynamite;
Ammo: (Propz: ammoprop_NoCrosshair or
ammoprop_AttackInJump or
@@ -399,7 +450,9 @@
Timer: 0;
AmmoType: amDynamite);
Slot: 4;
- TimeAfterTurn: 5000),
+ TimeAfterTurn: 5000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidFirePunch;
Ammo: (Propz: ammoprop_NoCrosshair or
ammoprop_ForwMsgs or
@@ -410,7 +463,9 @@
Timer: 0;
AmmoType: amFirePunch);
Slot: 3;
- TimeAfterTurn: 3000),
+ TimeAfterTurn: 3000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidBaseballBat;
Ammo: (Propz: 0;
Count: 1;
@@ -418,7 +473,9 @@
Timer: 0;
AmmoType: amBaseballBat);
Slot: 3;
- TimeAfterTurn: 5000),
+ TimeAfterTurn: 5000;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidParachute;
Ammo: (Propz: ammoprop_ForwMsgs or
ammoprop_AttackInJump or
@@ -428,7 +485,9 @@
Timer: 0;
AmmoType: amParachute);
Slot: 7;
- TimeAfterTurn: 0),
+ TimeAfterTurn: 0;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidAirAttack;
Ammo: (Propz: ammoprop_NoCrosshair or
ammoprop_NeedTarget or
@@ -438,7 +497,9 @@
Timer: 0;
AmmoType: amAirAttack);
Slot: 5;
- TimeAfterTurn: 0),
+ TimeAfterTurn: 0;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidMineStrike;
Ammo: (Propz: ammoprop_NoCrosshair or
ammoprop_NeedTarget or
@@ -448,7 +509,9 @@
Timer: 0;
AmmoType: amMineStrike);
Slot: 5;
- TimeAfterTurn: 0),
+ TimeAfterTurn: 0;
+ minAngle: 0;
+ maxAngle: 0),
(NameId: sidBlowTorch;
Ammo: (Propz: ammoprop_ForwMsgs;
Count: 1;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/uFloat.pas Sun Jan 21 19:51:02 2007 +0000
@@ -0,0 +1,276 @@
+(*
+ * Hedgewars, a Worms style game
+ * Copyright (c) 2007 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
+ *)
+
+unit uFloat;
+interface
+
+{$IFDEF FPC}
+{$ifdef FPC_LITTLE_ENDIAN}
+type hwFloat = record
+ isNegative: boolean;
+ case byte of
+ 0: (Frac, Round: Longword);
+ 1: (QWordValue : QWord);
+ end;
+{$else FPC_LITTLE_ENDIAN}
+type hwFloat = record
+ isNegative: boolean;
+ case byte of
+ 0: (Round, Frac: Longword);
+ 1: (QWordValue : QWord);
+ end;
+{$endif FPC_LITTLE_ENDIAN}
+
+operator := (i: LongInt) z : hwFloat;
+
+operator + (z1, z2: hwFloat) z : hwFloat;
+operator - (z1, z2: hwFloat) z : hwFloat;
+operator - (z1: hwFloat) z : hwFloat;
+
+operator * (z1, z2: hwFloat) z : hwFloat;
+operator * (z1: hwFloat; z2: LongInt) z : hwFloat;
+operator / (z1, z2: hwFloat) z : hwFloat;
+
+operator < (z1, z2: hwFloat) b : boolean;
+operator > (z1, z2: hwFloat) b : boolean;
+
+function cstr(z: hwFloat): string;
+function hwRound(t: hwFloat): integer;
+function hwAbs(t: hwFloat): hwFloat;
+function hwSqr(t: hwFloat): hwFloat;
+function Distance(dx, dy: hwFloat): hwFloat;
+function AngleSin(angle: Longword): hwFloat;
+function AngleCos(angle: Longword): hwFloat;
+
+const _1div1024: hwFloat = (isNegative: false; QWordValue: 4194304);
+ _1div10000: hwFloat = (isNegative: false; QWordValue: 429496);
+ _1div50000: hwFloat = (isNegative: false; QWordValue: 85899);
+ _1div100000: hwFloat = (isNegative: false; QWordValue: 42950);
+ _1div3: hwFloat = (isNegative: false; QWordValue: 1431655766);
+ hwPi: hwFloat = (isNegative: false; QWordValue: 13493037704);
+ _0_000004: hwFloat = (isNegative: false; QWordValue: 17179);
+ _0_0002: hwFloat = (isNegative: false; QWordValue: 858993);
+ _0_001: hwFloat = (isNegative: false; QWordValue: 4294967);
+ _0_003: hwFloat = (isNegative: false; QWordValue: 12884902);
+ _0_004: hwFloat = (isNegative: false; QWordValue: 17179869);
+ _0_005: hwFloat = (isNegative: false; QWordValue: 21474836);
+ _0_01: hwFloat = (isNegative: false; QWordValue: 42949673);
+ _0_02: hwFloat = (isNegative: false; QWordValue: 85899345);
+ _0_03: hwFloat = (isNegative: false; QWordValue: 128849018);
+ _0_08: hwFloat = (isNegative: false; QWordValue: 343597383);
+ _0_1: hwFloat = (isNegative: false; QWordValue: 429496729);
+ _0_15: hwFloat = (isNegative: false; QWordValue: 644245094);
+ _0_2: hwFloat = (isNegative: false; QWordValue: 858993459);
+ _0_25: hwFloat = (isNegative: false; QWordValue: 1073741824);
+ _0_3: hwFloat = (isNegative: false; QWordValue: 1288490189);
+ _0_35: hwFloat = (isNegative: false; QWordValue: 1503238553);
+ _0_4: hwFloat = (isNegative: false; QWordValue: 1717986918);
+ _0_45: hwFloat = (isNegative: false; QWordValue: 1932735283);
+ _0_5: hwFloat = (isNegative: false; QWordValue: 2147483648);
+ _0_55: hwFloat = (isNegative: false; QWordValue: 2362232012);
+ _0_6: hwFloat = (isNegative: false; QWordValue: 2576980377);
+ _0_8: hwFloat = (isNegative: false; QWordValue: 3435973837);
+ _0_84: hwFloat = (isNegative: false; QWordValue: 3607772528);
+ _0_87: hwFloat = (isNegative: false; QWordValue: 3736621547);
+ _0_9: hwFloat = (isNegative: false; QWordValue: 3865470566);
+ _0_93: hwFloat = (isNegative: false; QWordValue: 3994319585);
+ _0_96: hwFloat = (isNegative: false; QWordValue: 4123168604);
+ _0_995: hwFloat = (isNegative: false; QWordValue: 4273492459);
+ _0_999: hwFloat = (isNegative: false; QWordValue: 4290672328);
+ _1_9: hwFloat = (isNegative: false; QWordValue: 8160437862);
+
+ cLittle: hwFloat = (isNegative: false; QWordValue: 1);
+ cHHKick: hwFloat = (isNegative: false; QWordValue: 128849018);
+{$ENDIF}
+
+{$IFNDEF FPC}
+type hwFloat = Extended;
+{$ENDIF}
+
+implementation
+uses uConsts;
+
+{$IFDEF FPC}
+
+operator := (i: LongInt) z : hwFloat;
+begin
+z.isNegative:= i < 0;
+z.Round:= abs(i);
+z.Frac:= 0
+end;
+
+operator + (z1, z2: hwFloat) z : hwFloat;
+begin
+if z1.isNegative = z2.isNegative then
+ begin
+ z.isNegative:= z1.isNegative;
+ z.QWordValue:= z1.QWordValue + z2.QWordValue
+ end
+else
+ if z1.QWordValue > z2.QWordValue then
+ begin
+ z.isNegative:= z1.isNegative;
+ z.QWordValue:= z1.QWordValue - z2.QWordValue
+ end else
+ begin
+ z.isNegative:= z2.isNegative;
+ z.QWordValue:= z2.QWordValue - z1.QWordValue
+ end
+end;
+
+operator - (z1, z2: hwFloat) z : hwFloat;
+begin
+if z1.isNegative = z2.isNegative then
+ if z1.QWordValue > z2.QWordValue then
+ begin
+ z.isNegative:= z1.isNegative;
+ z.QWordValue:= z1.QWordValue - z2.QWordValue
+ end else
+ begin
+ z.isNegative:= not z2.isNegative;
+ z.QWordValue:= z2.QWordValue - z1.QWordValue
+ end
+else begin
+ z.isNegative:= z1.isNegative;
+ z.QWordValue:= z1.QWordValue + z2.QWordValue
+ end
+end;
+
+operator - (z1: hwFloat) z : hwFloat;
+begin
+z:= z1;
+z.isNegative:= not z.isNegative
+end;
+
+
+operator * (z1, z2: hwFloat) z : hwFloat;
+begin
+z.isNegative:= z1.isNegative xor z2.isNegative;
+z.QWordValue:= QWord(z1.Round) * z2.Frac +
+ QWord(z1.Frac) * z2.Round +
+ ((QWord(z1.Frac) * z2.Frac) shr 32);
+z.Round:= z.Round + QWord(z1.Round) * z2.Round;
+end;
+
+operator * (z1: hwFloat; z2: LongInt) z : hwFloat;
+begin
+z.isNegative:= z1.isNegative xor (z2 < 0);
+z2:= abs(z2);
+z.QWordValue:= z.QWordValue * z2
+end;
+
+operator / (z1, z2: hwFloat) z : hwFloat;
+var t: hwFloat;
+begin
+z.isNegative:= z1.isNegative xor z2.isNegative;
+z.Round:= z1.QWordValue div z2.QWordValue;
+t:= z1 - z2 * z.Round;
+if t.QWordValue = 0 then
+ z.Frac:= 0
+else
+ begin
+ while ((t.QWordValue and $8000000000000000) = 0) and
+ ((z2.QWordValue and $8000000000000000) = 0) do
+ begin
+ t.QWordValue:= t.QWordValue shl 1;
+ z2.QWordValue:= z2.QWordValue shl 1
+ end;
+ z.Frac:= (t.QWordValue) div (z2.Round)
+ end
+end;
+
+operator < (z1, z2: hwFloat) b : boolean;
+begin
+if z1.isNegative <> z2.isNegative then
+ b:= z1.isNegative
+else
+ if z1.QWordValue = z2.QWordValue then
+ b:= false
+ else
+ b:= (z1.QWordValue < z2.QWordValue) xor z1.isNegative
+end;
+
+operator > (z1, z2: hwFloat) b : boolean;
+begin
+if z1.isNegative <> z2.isNegative then
+ b:= z2.isNegative
+else
+ if z1.QWordValue = z2.QWordValue then
+ b:= false
+ else
+ b:= (z1.QWordValue > z2.QWordValue) xor z2.isNegative
+end;
+
+function cstr(z: hwFloat): string;
+var tmpstr: string;
+begin
+str(z.Round, cstr);
+if z.Frac <> 0 then
+ begin
+ str(z.Frac / $100000000:1:15, tmpstr);
+ delete(tmpstr, 1, 2);
+ cstr:= cstr + '.' + tmpstr
+ end;
+if z.isNegative then cstr:= '-' + cstr
+end;
+
+function hwRound(t: hwFloat): integer;
+begin
+if t.isNegative then hwRound:= -t.Round
+ else hwRound:= t.Round
+end;
+
+function hwAbs(t: hwFloat): hwFloat;
+begin
+hwAbs:= t;
+hwAbs.isNegative:= false
+end;
+
+function hwSqr(t: hwFloat): hwFloat;
+begin
+hwSqr:= t * t
+end;
+
+function Distance(dx, dy: hwFloat): hwFloat;
+var x, y: hwFloat;
+ Result: hwFloat;
+begin
+x:= dx * dx;
+y:= dy * dy;
+Result:= x + y;
+Result.QWordValue:= Round(sqrt(1.0 / 4294967296 * (Result.QWordValue)) * 4294967296);
+Distance:= Result
+end;
+
+function AngleSin(angle: Longword): hwFloat;
+begin
+AngleSin.isNegative:= false;
+AngleSin:= Round(Sin(Angle * pi / cMaxAngle) * 4294967296)
+end;
+
+function AngleCos(angle: Longword): hwFloat;
+var CosVal: Extended;
+begin
+CosVal:= Cos(Angle * pi / cMaxAngle);
+AngleCos.isNegative:= CosVal < 0;
+AngleCos:= Round(Cosval * 4294967296)
+end;
+
+{$ENDIF}
+
+end.
--- a/hedgewars/uGame.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uGame.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,6 +18,7 @@
unit uGame;
interface
+uses uFloat;
{$INCLUDE options.inc}
procedure DoGameTick(Lag: integer);
@@ -32,7 +33,7 @@
var i: integer;
begin
if isPaused then exit;
-if not CurrentTeam.ExtDriven then
+if not CurrentTeam^.ExtDriven then
begin
NetGetNextCmd; // its for the case when receiving "/say" message
isInLag:= false;
@@ -49,7 +50,7 @@
i:= 1;
while (GameState <> gsExit) and (i <= Lag) do
begin
- if not CurrentTeam.ExtDriven then
+ if not CurrentTeam^.ExtDriven then
begin
with CurrentTeam^ do
if Hedgehogs[CurrHedgehog].BotLevel <> 0 then ProcessBot(Frames);
--- a/hedgewars/uGears.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uGears.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,7 +18,7 @@
unit uGears;
interface
-uses SDLh, uConsts;
+uses SDLh, uConsts, uFloat;
{$INCLUDE options.inc}
const AllInactive: boolean = false;
@@ -28,19 +28,19 @@
NextGear, PrevGear: PGear;
Active: Boolean;
State : Longword;
- X : Double;
- Y : Double;
- dX: Double;
- dY: Double;
+ X : hwFloat;
+ Y : hwFloat;
+ dX: hwFloat;
+ dY: hwFloat;
Kind: TGearType;
Pos: Longword;
doStep: TGearStepProcedure;
Radius: integer;
Angle, Power : Longword;
- DirAngle: Double;
+ DirAngle: hwFloat;
Timer : LongWord;
- Elasticity: Double;
- Friction : Double;
+ Elasticity: hwFloat;
+ Friction : hwFloat;
Message : Longword;
Hedgehog: pointer;
Health, Damage: integer;
@@ -50,7 +50,7 @@
Z: Longword;
end;
-function AddGear(X, Y: integer; Kind: TGearType; State: Longword; const dX: Double=0.0; dY: Double=0.0; Timer: LongWord=0): PGear;
+function AddGear(X, Y: integer; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
procedure ProcessGears;
procedure SetAllToActive;
procedure SetAllHHToActive;
@@ -73,8 +73,8 @@
Count: Longword;
HookAngle: integer;
ar: array[0..300] of record
- X, Y: Double;
- dLen: Double;
+ X, Y: hwFloat;
+ dLen: hwFloat;
b: boolean;
end;
end;
@@ -95,35 +95,35 @@
{$INCLUDE HHHandlers.inc}
const doStepHandlers: array[TGearType] of TGearStepProcedure = (
- doStepCloud,
- doStepBomb,
- doStepHedgehog,
- doStepGrenade,
- doStepHealthTag,
- doStepGrave,
- doStepUFO,
- doStepShotgunShot,
- doStepPickHammer,
- doStepRope,
- doStepSmokeTrace,
- doStepExplosion,
- doStepMine,
- doStepCase,
- doStepDEagleShot,
- doStepDynamite,
- doStepTeamHealthSorter,
- doStepBomb,
- doStepCluster,
- doStepShover,
- doStepFlame,
- doStepFirePunch,
- doStepActionTimer,
- doStepActionTimer,
- doStepActionTimer,
- doStepParachute,
- doStepAirAttack,
- doStepAirBomb,
- doStepBlowTorch
+ @doStepCloud,
+ @doStepBomb,
+ @doStepHedgehog,
+ @doStepGrenade,
+ @doStepHealthTag,
+ @doStepGrave,
+ @doStepUFO,
+ @doStepShotgunShot,
+ @doStepPickHammer,
+ @doStepRope,
+ @doStepSmokeTrace,
+ @doStepExplosion,
+ @doStepMine,
+ @doStepCase,
+ @doStepDEagleShot,
+ @doStepDynamite,
+ @doStepTeamHealthSorter,
+ @doStepBomb,
+ @doStepCluster,
+ @doStepShover,
+ @doStepFlame,
+ @doStepFirePunch,
+ @doStepActionTimer,
+ @doStepActionTimer,
+ @doStepActionTimer,
+ @doStepParachute,
+ @doStepAirAttack,
+ @doStepAirBomb,
+ @doStepBlowTorch
);
procedure InsertGearToList(Gear: PGear);
@@ -134,172 +134,174 @@
else begin
// WARNING: this code assumes that the first gears added to the list are clouds (have maximal Z)
tmp:= GearsList;
- while (tmp <> nil) and (tmp.Z < Gear.Z) do
- tmp:= tmp.NextGear;
+ while (tmp <> nil) and (tmp^.Z < Gear^.Z) do
+ tmp:= tmp^.NextGear;
- if tmp.PrevGear <> nil then tmp.PrevGear.NextGear:= Gear;
- Gear.PrevGear:= tmp.PrevGear;
- tmp.PrevGear:= Gear;
- Gear.NextGear:= tmp;
+ if tmp^.PrevGear <> nil then tmp^.PrevGear^.NextGear:= Gear;
+ Gear^.PrevGear:= tmp^.PrevGear;
+ tmp^.PrevGear:= Gear;
+ Gear^.NextGear:= tmp;
if GearsList = tmp then GearsList:= Gear
end
end;
procedure RemoveGearFromList(Gear: PGear);
begin
-if Gear.NextGear <> nil then Gear.NextGear.PrevGear:= Gear.PrevGear;
-if Gear.PrevGear <> nil then Gear.PrevGear.NextGear:= Gear.NextGear
+if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
+if Gear^.PrevGear <> nil then Gear^.PrevGear^.NextGear:= Gear^.NextGear
else begin
- GearsList:= Gear.NextGear;
- if GearsList <> nil then GearsList.PrevGear:= nil
+ GearsList:= Gear^.NextGear;
+ if GearsList <> nil then GearsList^.PrevGear:= nil
end;
end;
-function AddGear(X, Y: integer; Kind: TGearType; State: Longword; const dX: Double=0.0; dY: Double=0.0; Timer: LongWord=0): PGear;
+function AddGear(X, Y: integer; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
const Counter: Longword = 0;
+var Result: PGear;
begin
inc(Counter);
{$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF}
New(Result);
{$IFDEF DEBUGFILE}AddFileLog('AddGear: type = '+inttostr(ord(Kind))+'; handle = '+inttostr(integer(Result)));{$ENDIF}
FillChar(Result^, sizeof(TGear), 0);
-Result.X:= X;
-Result.Y:= Y;
-Result.Kind := Kind;
-Result.State:= State;
-Result.Active:= true;
-Result.dX:= dX;
-Result.dY:= dY;
-Result.doStep:= doStepHandlers[Kind];
-Result.CollIndex:= High(Longword);
-Result.Timer:= Timer;
+Result^.X:= X;
+Result^.Y:= Y;
+Result^.Kind := Kind;
+Result^.State:= State;
+Result^.Active:= true;
+Result^.dX:= dX;
+Result^.dY:= dY;
+Result^.doStep:= doStepHandlers[Kind];
+Result^.CollIndex:= High(Longword);
+Result^.Timer:= Timer;
if CurrentTeam <> nil then
- Result.Hedgehog:= @CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog];
+ Result^.Hedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
case Kind of
- gtCloud: Result.Z:= High(Result.Z);
+ gtCloud: Result^.Z:= High(Result^.Z);
gtAmmo_Bomb: begin
- Result.Radius:= 4;
- Result.Elasticity:= 0.6;
- Result.Friction:= 0.995;
+ Result^.Radius:= 4;
+ Result^.Elasticity:= _0_6;
+ Result^.Friction:= _0_995;
end;
gtHedgehog: begin
- Result.Radius:= cHHRadius;
- Result.Elasticity:= 0.35;
- Result.Friction:= 0.999;
- Result.Angle:= cMaxAngle div 2;
- Result.Z:= cHHZ;
+ Result^.Radius:= cHHRadius;
+ Result^.Elasticity:= _0_35;
+ Result^.Friction:= _0_999;
+ Result^.Angle:= cMaxAngle div 2;
+ Result^.Z:= cHHZ;
end;
gtAmmo_Grenade: begin
- Result.Radius:= 4;
+ Result^.Radius:= 4;
end;
gtHealthTag: begin
- Result.Timer:= 1500;
- Result.Z:= 2000;
+ Result^.Timer:= 1500;
+ Result^.Z:= 2000;
end;
gtGrave: begin
- Result.Radius:= 10;
- Result.Elasticity:= 0.6;
+ Result^.Radius:= 10;
+ Result^.Elasticity:= _0_6;
end;
gtUFO: begin
- Result.Radius:= 5;
- Result.Timer:= 500;
- Result.Elasticity:= 0.9
+ Result^.Radius:= 5;
+ Result^.Timer:= 500;
+ Result^.Elasticity:= _0_9
end;
gtShotgunShot: begin
- Result.Timer:= 900;
- Result.Radius:= 2
+ Result^.Timer:= 900;
+ Result^.Radius:= 2
end;
gtPickHammer: begin
- Result.Radius:= 10;
- Result.Timer:= 4000
+ Result^.Radius:= 10;
+ Result^.Timer:= 4000
end;
gtSmokeTrace: begin
- Result.X:= Result.X - 16;
- Result.Y:= Result.Y - 16;
- Result.State:= 8
+ Result^.X:= Result^.X - 16;
+ Result^.Y:= Result^.Y - 16;
+ Result^.State:= 8
end;
gtRope: begin
- Result.Radius:= 3;
- Result.Friction:= 500;
+ Result^.Radius:= 3;
+ Result^.Friction:= 500;
RopePoints.Count:= 0;
end;
gtExplosion: begin
- Result.X:= Result.X - 25;
- Result.Y:= Result.Y - 25;
+ Result^.X:= Result^.X - 25;
+ Result^.Y:= Result^.Y - 25;
end;
gtMine: begin
- Result.Radius:= 3;
- Result.Elasticity:= 0.55;
- Result.Friction:= 0.995;
- Result.Timer:= 3000;
+ Result^.Radius:= 3;
+ Result^.Elasticity:= _0_55;
+ Result^.Friction:= _0_995;
+ Result^.Timer:= 3000;
end;
gtCase: begin
- Result.Radius:= 16;
- Result.Elasticity:= 0.4
+ Result^.Radius:= 16;
+ Result^.Elasticity:= _0_4
end;
gtDEagleShot: begin
- Result.Radius:= 1;
- Result.Radius:= 1;
- Result.Health:= 50
+ Result^.Radius:= 1;
+ Result^.Radius:= 1;
+ Result^.Health:= 50
end;
gtDynamite: begin
- Result.Radius:= 3;
- Result.Elasticity:= 0.55;
- Result.Friction:= 0.03;
- Result.Timer:= 5000;
+ Result^.Radius:= 3;
+ Result^.Elasticity:= _0_55;
+ Result^.Friction:= _0_03;
+ Result^.Timer:= 5000;
end;
gtClusterBomb: begin
- Result.Radius:= 4;
- Result.Elasticity:= 0.6;
- Result.Friction:= 0.995;
+ Result^.Radius:= 4;
+ Result^.Elasticity:= _0_6;
+ Result^.Friction:= _0_995;
end;
gtFlame: begin
- Result.Angle:= Counter mod 64;
- Result.Radius:= 1;
- Result.Health:= 2;
- Result.dY:= (getrandom - 0.8) * 0.03;
- Result.dX:= (getrandom - 0.5) * 0.4
+ Result^.Angle:= Counter mod 64;
+ Result^.Radius:= 1;
+ Result^.Health:= 2;
+ Result^.dY:= (getrandom - _0_8) * _0_03;
+ Result^.dX:= (getrandom - _0_5) * _0_4
end;
gtFirePunch: begin
- Result.Radius:= 15;
- Result.Tag:= Y
+ Result^.Radius:= 15;
+ Result^.Tag:= Y
end;
gtAirBomb: begin
- Result.Radius:= 10;
+ Result^.Radius:= 10;
end;
gtBlowTorch: begin
- Result.Radius:= cHHRadius;
- Result.Timer:= 7500;
+ Result^.Radius:= cHHRadius;
+ Result^.Timer:= 7500;
end;
end;
-InsertGearToList(Result)
+InsertGearToList(Result);
+AddGear:= Result
end;
procedure DeleteGear(Gear: PGear);
var team: PTeam;
t: Longword;
begin
-if Gear.CollIndex < High(Longword) then DeleteCI(Gear);
-if Gear.Surf <> nil then SDL_FreeSurface(Gear.Surf);
-if Gear.Kind = gtHedgehog then
+if Gear^.CollIndex < High(Longword) then DeleteCI(Gear);
+if Gear^.Surf <> nil then SDL_FreeSurface(Gear^.Surf);
+if Gear^.Kind = gtHedgehog then
if CurAmmoGear <> nil then
begin
{$IFDEF DEBUGFILE}AddFileLog('DeleteGear: Sending gm_Destroy, hh handle = '+inttostr(integer(Gear)));{$ENDIF}
- Gear.Message:= gm_Destroy;
- CurAmmoGear.Message:= gm_Destroy;
+ Gear^.Message:= gm_Destroy;
+ CurAmmoGear^.Message:= gm_Destroy;
exit
end else
begin
- if Gear.Y >= cWaterLine then
+ if not (Gear^.Y < cWaterLine) then
begin
- t:= max(Gear.Damage, Gear.Health);
- AddGear(Round(Gear.X), Round(Gear.Y), gtHealthTag, t).Hedgehog:= Gear.Hedgehog;
+ t:= max(Gear^.Damage, Gear^.Health);
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog;
inc(StepDamage, t)
end;
- team:= PHedgehog(Gear.Hedgehog).Team;
- if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = Gear then
+ team:= PHedgehog(Gear^.Hedgehog)^.Team;
+ if CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = Gear then
FreeActionsList; // to avoid ThinkThread on drawned gear
- PHedgehog(Gear.Hedgehog).Gear:= nil;
+ PHedgehog(Gear^.Hedgehog)^.Gear:= nil;
inc(KilledHHs);
RecountTeamHealth(team);
end;
@@ -313,25 +315,25 @@
function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs
var Gear: PGear;
begin
-Result:= true;
+CheckNoDamage:= true;
Gear:= GearsList;
while Gear <> nil do
begin
- if Gear.Kind = gtHedgehog then
- if Gear.Damage <> 0 then
+ if Gear^.Kind = gtHedgehog then
+ if Gear^.Damage <> 0 then
begin
- Result:= false;
- inc(StepDamage, Gear.Damage);
- if Gear.Health < Gear.Damage then Gear.Health:= 0
- else dec(Gear.Health, Gear.Damage);
- AddGear(Round(Gear.X), round(Gear.Y) - cHHRadius - 12 - PHedgehog(Gear.Hedgehog)^.HealthTag.h,
- gtHealthTag, Gear.Damage).Hedgehog:= Gear.Hedgehog;
- RenderHealth(PHedgehog(Gear.Hedgehog)^);
- RecountTeamHealth(PHedgehog(Gear.Hedgehog)^.Team);
-
- Gear.Damage:= 0
+ CheckNoDamage:= false;
+ inc(StepDamage, Gear^.Damage);
+ if Gear^.Health < Gear^.Damage then Gear^.Health:= 0
+ else dec(Gear^.Health, Gear^.Damage);
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12 - PHedgehog(Gear^.Hedgehog)^.HealthTag^.h,
+ gtHealthTag, Gear^.Damage, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog;
+ RenderHealth(PHedgehog(Gear^.Hedgehog)^);
+ RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
+
+ Gear^.Damage:= 0
end;
- Gear:= Gear.NextGear
+ Gear:= Gear^.NextGear
end;
end;
@@ -360,8 +362,8 @@
while t<>nil do
begin
Gear:= t;
- t:= Gear.NextGear;
- if Gear.Active then Gear.doStep(Gear);
+ t:= Gear^.NextGear;
+ if Gear^.Active then Gear^.doStep(Gear);
end;
if AllInactive then
@@ -375,19 +377,19 @@
end
end;
stChDmg: if CheckNoDamage then inc(step) else step:= stDelay;
- stChWin: if not CheckForWin then inc(step) else step:= stDelay;
+ stChWin: if not CheckForWin then inc(step) else step:= stDelay;
stSpawn: begin
if not isInMultiShoot then SpawnBoxOfSmth;
inc(step)
end;
stNTurn: begin
- AwareOfExplosion(0, 0, 0);
+ //AwareOfExplosion(0, 0, 0);
if isInMultiShoot then isInMultiShoot:= false
else begin
- with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+ with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
if MaxStepDamage < StepDamage then MaxStepDamage:= StepDamage;
StepDamage:= 0;
- ParseCommand('/nextturn');
+ ParseCommand('/nextturn', true);
end;
step:= Low(step)
end;
@@ -395,10 +397,10 @@
if TurnTimeLeft > 0 then
if CurrentTeam <> nil then
- if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear <> nil then
- if ((CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear.State and gstAttacking) = 0)
+ if CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil then
+ if ((CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^.State and gstAttacking) = 0)
and not isInMultiShoot then dec(TurnTimeLeft);
-
+
inc(GameTicks);
{$IFDEF COUNTTICKS}
asm
@@ -427,10 +429,10 @@
begin
AllInactive:= false;
t:= GearsList;
-while t<>nil do
+while t <> nil do
begin
- t.Active:= true;
- t:= t.NextGear
+ t^.Active:= true;
+ t:= t^.NextGear
end
end;
@@ -439,64 +441,64 @@
begin
AllInactive:= false;
t:= GearsList;
-while t<>nil do
+while t <> nil do
begin
- if t.Kind = gtHedgehog then t.Active:= true;
- t:= t.NextGear
+ if t^.Kind = gtHedgehog then t^.Active:= true;
+ t:= t^.NextGear
end
end;
procedure DrawHH(Gear: PGear; Surface: PSDL_Surface);
var t: integer;
begin
-DrawHedgehog(Round(Gear.X) - 14 + WorldDx, Round(Gear.Y) - 18 + WorldDy,
- hwSign(Gear.dX), 0,
- PHedgehog(Gear.Hedgehog).visStepPos div 2,
+DrawHedgehog(hwRound(Gear^.X) - 14 + WorldDx, hwRound(Gear^.Y) - 18 + WorldDy,
+ hwSign(Gear^.dX), 0,
+ PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
Surface);
-with PHedgehog(Gear.Hedgehog)^ do
- if Gear.State = 0 then
+with PHedgehog(Gear^.Hedgehog)^ do
+ if Gear^.State = 0 then
begin
- t:= round(Gear.Y) - cHHRadius - 10 + WorldDy;
- dec(t, HealthTag.h + 2);
- DrawCentered(round(Gear.X) + WorldDx, t, HealthTag, Surface);
- dec(t, NameTag.h + 2);
- DrawCentered(round(Gear.X) + WorldDx, t, NameTag, Surface);
- dec(t, Team.NameTag.h + 2);
- DrawCentered(round(Gear.X) + WorldDx, t, Team.NameTag, Surface)
+ t:= hwRound(Gear^.Y) - cHHRadius - 10 + WorldDy;
+ dec(t, HealthTag^.h + 2);
+ DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTag, Surface);
+ dec(t, NameTag^.h + 2);
+ DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTag, Surface);
+ dec(t, Team^.NameTag^.h + 2);
+ DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTag, Surface)
end else // Current hedgehog
begin
- if bShowFinger and ((Gear.State and gstHHDriven) <> 0) then
- DrawSprite(sprFinger, round(Gear.X) - 16 + WorldDx, round(Gear.Y) - 64 + WorldDy,
+ if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
+ DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy,
GameTicks div 32 mod 16, Surface);
- if (Gear.State and (gstMoving or gstDrowning or gstFalling)) = 0 then
- if (Gear.State and gstHHThinking) <> 0 then
- DrawGear(sQuestion, Round(Gear.X) - 10 + WorldDx, Round(Gear.Y) - cHHRadius - 34 + WorldDy, Surface)
+ if (Gear^.State and (gstMoving or gstDrowning or gstFalling)) = 0 then
+ if (Gear^.State and gstHHThinking) <> 0 then
+ DrawGear(sQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, Surface)
else
- if ShowCrosshair and ((Gear.State and gstAttacked) = 0) then
- DrawSurfSprite(Round(Gear.X + hwSign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle)*60) + WorldDx - 11,
- Round(Gear.Y - Cos(Gear.Angle*pi/cMaxAngle)*60) + WorldDy - 12,
- 24, (18 + hwSign(Gear.dX) * integer(((Gear.Angle * 72 div cMaxAngle) + 1) div 2) mod 18) mod 18,
- Team.CrosshairSurf, Surface);
+ if ShowCrosshair and ((Gear^.State and gstAttacked) = 0) then
+ DrawSurfSprite(Round(hwRound(Gear^.X) + hwSign(Gear^.dX) * Sin(Gear^.Angle*pi/cMaxAngle)*60) + WorldDx - 11,
+ Round(hwRound(Gear^.Y) - Cos(Gear^.Angle*pi/cMaxAngle)*60) + WorldDy - 12,
+ 24, (18 + hwSign(Gear^.dX) * integer(((Gear^.Angle * 72 div cMaxAngle) + 1) div 2) mod 18) mod 18,
+ Team^.CrosshairSurf, Surface);
end;
end;
procedure DrawGears(Surface: PSDL_Surface);
var Gear: PGear;
i: Longword;
- roplen: Double;
+ roplen: hwFloat;
procedure DrawRopeLine(X1, Y1, X2, Y2: integer);
const nodlen = 5;
var i, x, y: integer;
- t, k, ladd: Double;
+ t, k, ladd: hwFloat;
begin
if (X1 = X2) and (Y1 = Y2) then
begin
- OutError('WARNING: zero length rope line!');
+ OutError('WARNING: zero length rope line!', false);
exit
end;
- if abs(X1 - X2) > abs(Y1 - Y2) then
+{ if abs(X1 - X2) > abs(Y1 - Y2) then
begin
if X1 > X2 then
begin
@@ -555,21 +557,21 @@
t:= t + k;
end;
end
- end;
+} end;
begin
Gear:= GearsList;
while Gear<>nil do
begin
- case Gear.Kind of
- gtCloud: DrawSprite(sprCloud , Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy, Gear.State, Surface);
- gtAmmo_Bomb: DrawSprite(sprBomb , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
+ case Gear^.Kind of
+ gtCloud: DrawSprite(sprCloud , hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
+ gtAmmo_Bomb: DrawSprite(sprBomb , hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, hwRound(Gear^.DirAngle), Surface);
gtHedgehog: DrawHH(Gear, Surface);
- gtAmmo_Grenade: DrawSprite(sprGrenade , Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, DxDy2Angle32(Gear.dY, Gear.dX), Surface);
- gtHealthTag: if Gear.Surf <> nil then DrawCentered(Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy, Gear.Surf, Surface);
- gtGrave: DrawSpriteFromRect(PHedgehog(Gear.Hedgehog).Team.GraveRect, Round(Gear.X) + WorldDx - 16, Round(Gear.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, Surface);
- gtUFO: DrawSprite(sprUFO, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4, Surface);
- gtSmokeTrace: if Gear.State < 8 then DrawSprite(sprSmokeTrace, Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy, Gear.State, Surface);
+ gtAmmo_Grenade: DrawSprite(sprGrenade , hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, DxDy2Angle32(Gear^.dY.QWordValue, Gear^.dX.QWordValue), Surface);
+ gtHealthTag: if Gear^.Surf <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Surf, Surface);
+ gtGrave: DrawSpriteFromRect(PHedgehog(Gear^.Hedgehog)^.Team^.GraveRect, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, Surface);
+ gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4, Surface);
+ gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
gtRope: begin
roplen:= 0;
if RopePoints.Count > 0 then
@@ -577,38 +579,38 @@
i:= 0;
while i < Pred(RopePoints.Count) do
begin
- DrawRopeLine(Round(RopePoints.ar[i].X) + WorldDx, Round(RopePoints.ar[i].Y) + WorldDy,
- Round(RopePoints.ar[Succ(i)].X) + WorldDx, Round(RopePoints.ar[Succ(i)].Y) + WorldDy);
+ DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
+ hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy);
inc(i)
end;
- DrawRopeLine(Round(RopePoints.ar[i].X) + WorldDx, Round(RopePoints.ar[i].Y) + WorldDy,
- Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy);
- DrawRopeLine(Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy,
- Round(PHedgehog(Gear.Hedgehog).Gear.X) + WorldDx, Round(PHedgehog(Gear.Hedgehog).Gear.Y) + WorldDy);
- DrawSprite(sprRopeHook, Round(RopePoints.ar[0].X) + WorldDx - 16, Round(RopePoints.ar[0].Y) + WorldDy - 16, RopePoints.HookAngle, Surface);
+ DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
+ hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy);
+ DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
+ hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
+ DrawSprite(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx - 16, hwRound(RopePoints.ar[0].Y) + WorldDy - 16, RopePoints.HookAngle, Surface);
end else
begin
- DrawRopeLine(Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy,
- Round(PHedgehog(Gear.Hedgehog).Gear.X) + WorldDx, Round(PHedgehog(Gear.Hedgehog).Gear.Y) + WorldDy);
- DrawSprite(sprRopeHook, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, DxDy2Angle32(Gear.dY, Gear.dX), Surface);
+ DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
+ hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
+ DrawSprite(sprRopeHook, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, DxDy2Angle32(Gear^.dY.QWordValue, Gear^.dX.QWordValue), Surface);
end;
end;
- gtExplosion: DrawSprite(sprExplosion50, Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy, Gear.State, Surface);
- gtMine: if ((Gear.State and gstAttacking) = 0)or((Gear.Timer and $3FF) < 420)
- then DrawSprite(sprMineOff , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface)
- else DrawSprite(sprMineOn , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
- gtDynamite: DrawSprite2(sprDynamite, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 25 + WorldDy, Gear.Tag and 1, Gear.Tag shr 1, Surface);
- gtCase: case Gear.Pos of
- posCaseAmmo : DrawSprite(sprCase, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, 0, Surface);
- posCaseHealth: DrawSprite(sprFAid, Round(Gear.X) - 24 + WorldDx, Round(Gear.Y) - 24 + WorldDy, (GameTicks shr 6) mod 13, Surface);
+ gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
+ gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)
+ then DrawSprite(sprMineOff , hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, hwRound(Gear^.DirAngle), Surface)
+ else DrawSprite(sprMineOn , hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, hwRound(Gear^.DirAngle), Surface);
+ gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1, Surface);
+ gtCase: case Gear^.Pos of
+ posCaseAmmo : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0, Surface);
+ posCaseHealth: DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, (GameTicks shr 6) mod 13, Surface);
end;
- gtClusterBomb: DrawSprite(sprClusterBomb, Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
- gtCluster: DrawSprite(sprClusterParticle, Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, 0, Surface);
- gtFlame: DrawSprite(sprFlame, Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy,(GameTicks div 128 + Gear.Angle) mod 8, Surface);
- gtAirBomb: DrawSprite(sprAirBomb , Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, DxDy2Angle32(Gear.dY, Gear.dX), Surface);
- gtAirAttack: DrawSprite(sprAirplane, Round(Gear.X) - 60 + WorldDx, Round(Gear.Y) - 25 + WorldDy, 0, Surface);
+ gtClusterBomb: DrawSprite(sprClusterBomb, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, hwRound(Gear^.DirAngle), Surface);
+ gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0, Surface);
+ gtFlame: DrawSprite(sprFlame, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy,(GameTicks div 128 + Gear^.Angle) mod 8, Surface);
+ gtAirBomb: DrawSprite(sprAirBomb , hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, DxDy2Angle32(Gear^.dY.QWordValue, Gear^.dX.QWordValue), Surface);
+ gtAirAttack: DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 0, Surface);
end;
- Gear:= Gear.NextGear
+ Gear:= Gear^.NextGear
end;
end;
@@ -620,7 +622,7 @@
while tt<>nil do
begin
t:= tt;
- tt:= tt.NextGear;
+ tt:= tt^.NextGear;
Dispose(t)
end;
end;
@@ -631,7 +633,7 @@
AddGear(0, 0, gtATStartGame, 0, 0, 0, 2000);
if (GameFlags and gfForts) = 0 then
for i:= 0 to 3 do
- FindPlace(AddGear(0, 0, gtMine, 0), false, 0, 2048);
+ FindPlace(AddGear(0, 0, gtMine, 0, 0, 0, 0), false, 0, 2048);
end;
procedure AddClouds;
@@ -639,7 +641,8 @@
begin
for i:= 0 to cCloudsNumber do
AddGear( - cScreenWidth + i * ((cScreenWidth * 2 + 2304) div cCloudsNumber), -140, gtCloud, random(4),
- (0.5-random)*0.1, ((i mod 2) * 2 - 1) * (0.005 + 0.015*random))
+// (0.5-random)*0.1, ((i mod 2) * 2 - 1) * (0.005 + 0.015*random), 0)
+ 0, 0, 0)
end;
procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord);
@@ -649,39 +652,39 @@
TargetPoint.X:= NoPointX;
{$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
if (Mask and EXPLDontDraw) = 0 then DrawExplosion(X, Y, Radius);
-if Radius = 50 then AddGear(X, Y, gtExplosion, 0);
-if (Mask and EXPLAutoSound)<>0 then PlaySound(sndExplosion);
+if Radius = 50 then AddGear(X, Y, gtExplosion, 0, 0, 0, 0);
+if (Mask and EXPLAutoSound)<>0 then PlaySound(sndExplosion, false);
if (Mask and EXPLAllDamageInRadius)=0 then Radius:= Radius shl 1;
Gear:= GearsList;
while Gear <> nil do
begin
- dmg:= Radius - Round(sqrt(sqr(Gear.X - X) + sqr(Gear.Y - Y)));
+ dmg:= Radius - hwRound(Distance(Gear^.X - X, Gear^.Y - Y));
if dmg > 0 then
begin
dmg:= dmg shr 1;
- case Gear.Kind of
+ case Gear^.Kind of
gtHedgehog,
gtMine,
gtCase,
gtFlame: begin
- if (Mask and EXPLNoDamage) = 0 then inc(Gear.Damage, dmg);
- if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear.Kind <> gtHedgehog) then
+ if (Mask and EXPLNoDamage) = 0 then inc(Gear^.Damage, dmg);
+ if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
begin
- Gear.dX:= Gear.dX + (dmg / 200 + cHHKick)* hwSign(Gear.X - X);
- Gear.dY:= Gear.dY + (dmg / 200 + cHHKick)* hwSign(Gear.Y - Y);
- Gear.Active:= true;
+ Gear^.dX:= Gear^.dX + (_0_005 * dmg + cHHKick)* hwSign(Gear^.X - X);
+ Gear^.dY:= Gear^.dY + (_0_005 * dmg + cHHKick)* hwSign(Gear^.Y - Y);
+ Gear^.Active:= true;
FollowGear:= Gear
end;
end;
gtGrave: begin
- Gear.dY:= - dmg / 250;
- Gear.Active:= true;
+ Gear^.dY:= - _0_004 * dmg;
+ Gear^.Active:= true;
end;
end;
end;
- Gear:= Gear.NextGear
+ Gear:= Gear^.NextGear
end;
-uAIMisc.AwareOfExplosion(0, 0, 0)
+//uAIMisc.AwareOfExplosion(0, 0, 0)
end;
procedure AmmoShove(Ammo: PGear; Damage, Power: integer);
@@ -690,23 +693,23 @@
hh: PHedgehog;
begin
t:= CheckGearsCollision(Ammo);
-i:= t.Count;
-hh:= Ammo.Hedgehog;
+i:= t^.Count;
+hh:= Ammo^.Hedgehog;
while i > 0 do
begin
dec(i);
- if (t.ar[i].State and gstNoDamage) = 0 then
- case t.ar[i].Kind of
+ if (t^.ar[i]^.State and gstNoDamage) = 0 then
+ case t^.ar[i]^.Kind of
gtHedgehog,
gtMine,
gtCase: begin
- inc(t.ar[i].Damage, Damage);
- inc(hh.DamageGiven, Damage);
- t.ar[i].dX:= Ammo.dX * Power * 0.01;
- t.ar[i].dY:= Ammo.dY * Power * 0.01;
- t.ar[i].Active:= true;
- DeleteCI(t.ar[i]);
- FollowGear:= t.ar[i]
+ inc(t^.ar[i]^.Damage, Damage);
+ inc(hh^.DamageGiven, Damage);
+ t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01;
+ t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01;
+ t^.ar[i]^.Active:= true;
+ DeleteCI(t^.ar[i]);
+ FollowGear:= t^.ar[i]
end;
end
end;
@@ -722,12 +725,12 @@
while Team <> nil do
begin
for i:= 0 to cMaxHHIndex do
- with Team.Hedgehogs[i] do
+ with Team^.Hedgehogs[i] do
if Gear <> nil then
if (GameFlags and gfForts) = 0 then FindPlace(Gear, false, 0, 2048)
else FindPlace(Gear, false, t, t + 1024);
inc(t, 1024);
- Team:= Team.Next
+ Team:= Team^.Next
end
end;
@@ -739,15 +742,12 @@
rY:= sqr(rY);
while t <> nil do
begin
- if (t <> Gear) and (t.Kind = Kind) then
- if sqr(Gear.X - t.X) / rX + sqr(Gear.Y - t.Y) / rY <= 1 then
- begin
- Result:= t;
- exit
- end;
- t:= t.NextGear
+ 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);
+ t:= t^.NextGear
end;
-Result:= nil
+CheckGearNear:= nil
end;
procedure AmmoFlameWork(Ammo: PGear);
@@ -756,17 +756,17 @@
t:= GearsList;
while t <> nil do
begin
- if (t.Kind = gtHedgehog) and (t.Y < Ammo.Y) then
- if sqr(Ammo.X - t.X) + sqr(Ammo.Y - t.Y - cHHRadius) * 2 <= sqr(4) then
+ if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then
+ if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - cHHRadius) * 2 > 2) then
begin
- inc(t.Damage, 5);
- t.dX:= t.dX + (t.X - Ammo.X) * 0.02;
- t.dY:= - 0.25;
- t.Active:= true;
+ inc(t^.Damage, 5);
+ t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02;
+ t^.dY:= - _0_25;
+ t^.Active:= true;
DeleteCI(t);
FollowGear:= t
end;
- t:= t.NextGear
+ t:= t^.NextGear
end;
end;
@@ -778,41 +778,40 @@
rY:= sqr(rY);
while t <> nil do
begin
- if t.Kind in Kind then
- if sqr(mX - t.X) / rX + sqr(mY - t.Y) / rY <= 1 then
- begin
- Result:= t;
- exit
- end;
- t:= t.NextGear
+ if t^.Kind in Kind then
+ if not (hwSqr(mX - t^.X) / rX + hwSqr(mY - t^.Y) / rY > 1) then
+ exit(t);
+ t:= t^.NextGear
end;
-Result:= nil
+CheckGearsNear:= nil
end;
function CountGears(Kind: TGearType): Longword;
var t: PGear;
+ Result: Longword;
begin
Result:= 0;
t:= GearsList;
while t <> nil do
begin
- if t.Kind = Kind then inc(Result);
- t:= t.NextGear
+ if t^.Kind = Kind then inc(Result);
+ t:= t^.NextGear
end;
+CountGears:= Result
end;
procedure SpawnBoxOfSmth;
begin
if (CountGears(gtCase) >= 5) or (getrandom(cCaseFactor) <> 0) then exit;
-FollowGear:= AddGear(0, 0, gtCase, 0);
+FollowGear:= AddGear(0, 0, gtCase, 0, 0, 0, 0);
case getrandom(2) of
0: begin
- FollowGear.Health:= 25;
- FollowGear.Pos:= posCaseHealth
+ FollowGear^.Health:= 25;
+ FollowGear^.Pos:= posCaseHealth
end;
1: begin
- FollowGear.Pos:= posCaseAmmo;
- FollowGear.State:= Longword(amMineStrike)
+ FollowGear^.Pos:= posCaseAmmo;
+ FollowGear^.State:= Longword(amMineStrike)
end;
end;
FindPlace(FollowGear, true, 0, 2048)
@@ -822,11 +821,13 @@
function CountNonZeroz(x, y, r: integer): integer;
var i: integer;
+ Result: integer;
begin
Result:= 0;
if (y and $FFFFFC00) <> 0 then exit;
for i:= max(x - r, 0) to min(x + r, 2043) do
- if Land[y, i] <> 0 then inc(Result)
+ if Land[y, i] <> 0 then inc(Result);
+ CountNonZeroz:= Result
end;
var fx, x: integer;
@@ -839,26 +840,26 @@
delta:= 130;
repeat
repeat
- inc(x, Gear.Radius);
+ inc(x, Gear^.Radius);
if x > Right then x:= Left + (x mod (Right - left));
cnt:= 0;
- y:= -Gear.Radius * 2;
+ y:= -Gear^.Radius * 2;
while y < 1023 do
begin
repeat
inc(y, 2);
- until (y > 1023) or (CountNonZeroz(x, y, Gear.Radius - 1) = 0);
+ until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) = 0);
sy:= y;
repeat
inc(y);
- until (y > 1023) or (CountNonZeroz(x, y, Gear.Radius - 1) <> 0);
- if (y - sy > Gear.Radius * 2)
+ until (y > 1023) or (CountNonZeroz(x, y, Gear^.Radius - 1) <> 0);
+ if (y - sy > Gear^.Radius * 2)
and (y < 1023)
- and (CheckGearsNear(x, y - Gear.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then
+ and (CheckGearsNear(x, y - Gear^.Radius, [gtHedgehog, gtMine, gtCase], 110, 110) = nil) then
begin
ar[cnt].X:= x;
- if withFall then ar[cnt].Y:= sy + Gear.Radius
- else ar[cnt].Y:= y - Gear.Radius;
+ if withFall then ar[cnt].Y:= sy + Gear^.Radius
+ else ar[cnt].Y:= y - Gear^.Radius;
inc(cnt)
end;
inc(y, 80)
@@ -866,8 +867,8 @@
if cnt > 0 then
with ar[GetRandom(cnt)] do
begin
- Gear.X:= x;
- Gear.Y:= y;
+ Gear^.X:= x;
+ Gear^.Y:= y;
{$IFDEF DEBUGFILE}
AddFileLog('Assigned Gear ' + inttostr(integer(Gear)) +
' coordinates (' + inttostr(x) +
@@ -875,7 +876,7 @@
{$ENDIF}
exit
end
- until (x - Gear.Radius < fx) and (x + Gear.Radius > fx);
+ until (x - Gear^.Radius < fx) and (x + Gear^.Radius > fx);
dec(Delta, 20)
until (Delta < 70);
OutError('Couldn''t find place for Gear ' + inttostr(integer(Gear)), false);
--- a/hedgewars/uIO.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uIO.pas Sun Jan 21 19:51:02 2007 +0000
@@ -77,7 +77,7 @@
case s[1] of
'!': begin {$IFDEF DEBUGFILE}AddFileLog('Ping? Pong!');{$ENDIF}isPonged:= true; end;
'?': SendIPC('!');
- 'e': ParseCommand(copy(s, 2, Length(s) - 1));
+ 'e': ParseCommand(copy(s, 2, Length(s) - 1), true);
'E': OutError(copy(s, 2, Length(s) - 1), true);
'W': OutError(copy(s, 2, Length(s) - 1), false);
'T': case s[2] of
@@ -101,12 +101,12 @@
buf: array[0..255] of byte;
s: shortstring absolute buf;
begin
-fds.numsockets:= 0;
+fds^.numsockets:= 0;
SDLNet_AddSocket(fds, IPCSock);
while SDLNet_CheckSockets(fds, 0) > 0 do
begin
- i:= SDLNet_TCP_Recv(IPCSock, @buf[1], 255);
+ i:= SDLNet_TCP_Recv(IPCSock, @buf[1], 255 - Length(ss));
if i > 0 then
begin
buf[0]:= i;
@@ -175,7 +175,7 @@
AddCaption('> ' + copy(extcmd[cmdcurpos].str, 2, Pred(extcmd[cmdcurpos].len)), $FFFFFF, capgrpNetSay);
inc(cmdcurpos)
end;
-
+
if cmdcurpos <= cmdendpos then
TryDo(GameTicks <= extcmd[cmdcurpos].Time,
'oops, queue error. in buffer: ' + extcmd[cmdcurpos].cmd +
@@ -187,20 +187,20 @@
while (cmdcurpos <= cmdendpos)and(GameTicks = extcmd[cmdcurpos].Time) do
begin
case extcmd[cmdcurpos].cmd of
- 'L': ParseCommand('+left');
- 'l': ParseCommand('-left');
- 'R': ParseCommand('+right');
- 'r': ParseCommand('-right');
- 'U': ParseCommand('+up');
- 'u': ParseCommand('-up');
- 'D': ParseCommand('+down');
- 'd': ParseCommand('-down');
- 'A': ParseCommand('+attack');
- 'a': ParseCommand('-attack');
- 'S': ParseCommand('switch');
- 'j': ParseCommand('ljump');
- 'J': ParseCommand('hjump');
- ',': ParseCommand('skip');
+ 'L': ParseCommand('+left', true);
+ 'l': ParseCommand('-left', true);
+ 'R': ParseCommand('+right', true);
+ 'r': ParseCommand('-right', true);
+ 'U': ParseCommand('+up', true);
+ 'u': ParseCommand('-up', true);
+ 'D': ParseCommand('+down', true);
+ 'd': ParseCommand('-down', true);
+ 'A': ParseCommand('+attack', true);
+ 'a': ParseCommand('-attack', true);
+ 'S': ParseCommand('switch', true);
+ 'j': ParseCommand('ljump', true);
+ 'J': ParseCommand('hjump', true);
+ ',': ParseCommand('skip', true);
'N': begin
tmpflag:= false;
{$IFDEF DEBUGFILE}AddFileLog('got cmd "N": time '+inttostr(extcmd[cmdcurpos].Time)){$ENDIF}
@@ -208,14 +208,14 @@
'p': begin
TargetPoint.X:= SDLNet_Read16(@extcmd[cmdcurpos].X);
TargetPoint.Y:= SDLNet_Read16(@extcmd[cmdcurpos].Y);
- ParseCommand('put')
+ ParseCommand('put', true)
end;
'P': begin
CursorPoint.X:= SDLNet_Read16(@extcmd[cmdcurpos].X) + WorldDx;
CursorPoint.Y:= SDLNet_Read16(@extcmd[cmdcurpos].Y) + WorldDy;
end;
- '1'..'5': ParseCommand('timer ' + extcmd[cmdcurpos].cmd);
- #128..char(128 + cMaxSlotIndex): ParseCommand('slot ' + char(byte(extcmd[cmdcurpos].cmd) - 79))
+ '1'..'5': ParseCommand('timer ' + extcmd[cmdcurpos].cmd, true);
+ #128..char(128 + cMaxSlotIndex): ParseCommand('slot ' + char(byte(extcmd[cmdcurpos].cmd) - 79), true)
end;
inc(cmdcurpos)
end;
--- a/hedgewars/uKeys.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uKeys.pas Sun Jan 21 19:51:02 2007 +0000
@@ -43,9 +43,11 @@
DefaultBinds, CurrentBinds: TBinds;
function KeyNameToCode(name: string): word;
+var Result: Word;
begin
Result:= cKeyMaxIndex;
-while (Result > 0) and (KeyNames[Result] <> name) do dec(Result)
+while (Result > 0) and (KeyNames[Result] <> name) do dec(Result);
+KeyNameToCode:= Result
end;
procedure ProcessKbd;
@@ -56,8 +58,8 @@
begin
KbdKeyPressed:= false;
Trusted:= (CurrentTeam <> nil)
- and (not CurrentTeam.ExtDriven)
- and (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].BotLevel = 0);
+ and (not CurrentTeam^.ExtDriven)
+ and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].BotLevel = 0);
pkbd:= SDL_GetKeyState(nil);
i:= SDL_GetMouseState(nil, nil);
@@ -75,7 +77,7 @@
begin
s:= CurrentBinds[i];
s[1]:= '-';
- ParseCommand(s)
+ ParseCommand(s, true)
end;
end else
if (tkbd[i] = 0) and (pkbd^[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted);
--- a/hedgewars/uLand.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uLand.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,7 +18,7 @@
unit uLand;
interface
-uses SDLh, uLandTemplates;
+uses SDLh, uLandTemplates, uFloat;
{$include options.inc}
type TLandArray = packed array[0..1023, 0..2047] of LongWord;
TPreview = packed array[0..127, 0..31] of byte;
@@ -57,71 +57,72 @@
procedure DrawBezierEdge(var pa: TPixAr; Color: Longword);
var x, y, i: integer;
- tx, ty, vx, vy, vlen, t: Double;
- r1, r2, r3, r4: Double;
- x1, y1, x2, y2, cx1, cy1, cx2, cy2, tsq, tcb: Double;
+ tx, ty, vx, vy, vlen, t: hwFloat;
+ r1, r2, r3, r4: hwFloat;
+ x1, y1, x2, y2, cx1, cy1, cx2, cy2, tsq, tcb: hwFloat;
begin
vx:= 0;
vy:= 0;
with pa do
for i:= 0 to Count-2 do
begin
- vlen:= sqrt(sqr(ar[i + 1].x - ar[i ].X) + sqr(ar[i + 1].y - ar[i ].y));
- t:= sqrt(sqr(ar[i + 1].x - ar[i + 2].X) + sqr(ar[i + 1].y - ar[i + 2].y));
+ vlen:= Distance(ar[i + 1].x - ar[i].X, ar[i + 1].y - ar[i].y);
+ t:= Distance(ar[i + 1].x - ar[i + 2].X,ar[i + 1].y - ar[i + 2].y);
if t<vlen then vlen:= t;
- vlen:= vlen/3;
+ vlen:= vlen * _1div3;
tx:= ar[i+2].X - ar[i].X;
ty:= ar[i+2].y - ar[i].y;
- t:= sqrt(sqr(tx)+sqr(ty));
- if t = 0 then
+ t:= Distance(tx, ty);
+ if t.QWordValue = 0 then
begin
- tx:= -tx * 100000;
- ty:= -ty * 100000;
+ tx:= -tx * 10000;
+ ty:= -ty * 10000;
end else
begin
- tx:= -tx/t;
- ty:= -ty/t;
+ t:= 1/t;
+ tx:= -tx * t;
+ ty:= -ty * t;
end;
- t:= 1.0*vlen;
- tx:= tx*t;
- ty:= ty*t;
+ t:= vlen;
+ tx:= tx * t;
+ ty:= ty * t;
x1:= ar[i].x;
y1:= ar[i].y;
x2:= ar[i + 1].x;
y2:= ar[i + 1].y;
- cx1:= ar[i].X + trunc(vx);
- cy1:= ar[i].y + trunc(vy);
- cx2:= ar[i+1].X + trunc(tx);
- cy2:= ar[i+1].y + trunc(ty);
+ cx1:= ar[i].X + hwRound(vx);
+ cy1:= ar[i].y + hwRound(vy);
+ cx2:= ar[i+1].X + hwRound(tx);
+ cy2:= ar[i+1].y + hwRound(ty);
vx:= -tx;
vy:= -ty;
t:= 0;
- while t <= 1.0 do
+ while t.Round = 0 do
begin
- tsq:= sqr(t);
+ tsq:= t * t;
tcb:= tsq * t;
r1:= (1 - 3*t + 3*tsq - tcb) * x1;
r2:= ( 3*t - 6*tsq + 3*tcb) * cx1;
r3:= ( 3*tsq - 3*tcb) * cx2;
r4:= ( tcb) * x2;
- X:= round(r1 + r2 + r3 + r4);
+ X:= hwRound(r1 + r2 + r3 + r4);
r1:= (1 - 3*t + 3*tsq - tcb) * y1;
r2:= ( 3*t - 6*tsq + 3*tcb) * cy1;
r3:= ( 3*tsq - 3*tcb) * cy2;
r4:= ( tcb) * y2;
- Y:= round(r1 + r2 + r3 + r4);
- t:= t + 0.001;
+ Y:= hwRound(r1 + r2 + r3 + r4);
+ t:= t + _1div1024;
if ((x and $FFFFF800) = 0) and ((y and $FFFFFC00) = 0) then
Land[y, x]:= Color;
end;
end;
end;
-procedure BezierizeEdge(var pa: TPixAr; Delta: Double);
+procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat);
var x, y, i: integer;
- tx, ty, vx, vy, vlen, t: Double;
- r1, r2, r3, r4: Double;
- x1, y1, x2, y2, cx1, cy1, cx2, cy2, tsq, tcb: Double;
+ tx, ty, vx, vy, vlen, t: hwFloat;
+ r1, r2, r3, r4: hwFloat;
+ x1, y1, x2, y2, cx1, cy1, cx2, cy2, tsq, tcb: hwFloat;
opa: TPixAr;
begin
opa:= pa;
@@ -131,50 +132,53 @@
with opa do
for i:= 0 to Count-2 do
begin
- vlen:= sqrt(sqr(ar[i + 1].x - ar[i ].X) + sqr(ar[i + 1].y - ar[i ].y));
- t:= sqrt(sqr(ar[i + 1].x - ar[i + 2].X) + sqr(ar[i + 1].y - ar[i + 2].y));
+addfilelog('50');
+ vlen:= Distance(ar[i + 1].x - ar[i].X, ar[i + 1].y - ar[i].y);
+ t:= Distance(ar[i + 1].x - ar[i + 2].X,ar[i + 1].y - ar[i + 2].y);
+addfilelog('51');
if t<vlen then vlen:= t;
- vlen:= vlen/3;
+ vlen:= vlen * _1div3;
tx:= ar[i+2].X - ar[i].X;
ty:= ar[i+2].y - ar[i].y;
- t:= sqrt(sqr(tx)+sqr(ty));
- if t = 0 then
+ t:= Distance(tx, ty);
+ if t.QWordValue = 0 then
begin
tx:= -tx * 100000;
ty:= -ty * 100000;
end else
begin
- tx:= -tx/t;
- ty:= -ty/t;
+ t:= 1/t;
+ tx:= -tx * t;
+ ty:= -ty * t;
end;
- t:= 1.0*vlen;
+ t:= vlen;
tx:= tx*t;
ty:= ty*t;
x1:= ar[i].x;
y1:= ar[i].y;
x2:= ar[i + 1].x;
y2:= ar[i + 1].y;
- cx1:= ar[i].X + trunc(vx);
- cy1:= ar[i].y + trunc(vy);
- cx2:= ar[i+1].X + trunc(tx);
- cy2:= ar[i+1].y + trunc(ty);
+ cx1:= ar[i].X + hwRound(vx);
+ cy1:= ar[i].y + hwRound(vy);
+ cx2:= ar[i+1].X + hwRound(tx);
+ cy2:= ar[i+1].y + hwRound(ty);
vx:= -tx;
vy:= -ty;
t:= 0;
- while t <= 1.0 do
+ while t.Round = 0 do
begin
- tsq:= sqr(t);
+ tsq:= t * t;
tcb:= tsq * t;
r1:= (1 - 3*t + 3*tsq - tcb) * x1;
r2:= ( 3*t - 6*tsq + 3*tcb) * cx1;
r3:= ( 3*tsq - 3*tcb) * cx2;
r4:= ( tcb) * x2;
- X:= round(r1 + r2 + r3 + r4);
+ X:= hwRound(r1 + r2 + r3 + r4);
r1:= (1 - 3*t + 3*tsq - tcb) * y1;
r2:= ( 3*t - 6*tsq + 3*tcb) * cy1;
r3:= ( 3*tsq - 3*tcb) * cy2;
r4:= ( tcb) * y2;
- Y:= round(r1 + r2 + r3 + r4);
+ Y:= hwRound(r1 + r2 + r3 + r4);
t:= t + Delta;
pa.ar[pa.Count].x:= X;
pa.ar[pa.Count].y:= Y;
@@ -207,7 +211,7 @@
inc(Stack.Count)
end;
- procedure Pop(out _xl, _xr, _y, _dir: integer);
+ procedure Pop(var _xl, _xr, _y, _dir: integer);
begin
dec(Stack.Count);
with Stack.points[Stack.Count] do
@@ -220,7 +224,7 @@
end;
var xl, xr, dir: integer;
-begin
+begin
Stack.Count:= 0;
xl:= x - 1;
xr:= x;
@@ -253,7 +257,7 @@
var tmpsurf: PSDL_Surface;
r: TSDL_Rect;
begin
-tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', false);
+tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', false, true, true);
r.y:= 0;
while r.y < 1024 do
begin
@@ -261,15 +265,15 @@
while r.x < 2048 do
begin
SDL_UpperBlit(tmpsurf, nil, Surface, @r);
- inc(r.x, tmpsurf.w)
+ inc(r.x, tmpsurf^.w)
end;
- inc(r.y, tmpsurf.h)
+ inc(r.y, tmpsurf^.h)
end;
SDL_FreeSurface(tmpsurf);
tmpsurf:= SDL_CreateRGBSurfaceFrom(@Land, 2048, 1024, 32, 2048*4, $FF0000, $FF00, $FF, 0);
SDLTry(tmpsurf <> nil, true);
-SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, SDL_MapRGB(tmpsurf.format, $FF, $FF, $FF));
+SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, SDL_MapRGB(tmpsurf^.format, $FF, $FF, $FF));
SDL_UpperBlit(tmpsurf, nil, Surface, nil);
SDL_FreeSurface(tmpsurf)
end;
@@ -279,7 +283,7 @@
r, rr: TSDL_Rect;
x, yd, yu: integer;
begin
-tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', false);
+tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', false, true, true);
for x:= 0 to 2047 do
begin
yd:= 1023;
@@ -295,7 +299,7 @@
begin
rr.x:= x;
rr.y:= yd - 15;
- r.x:= x mod tmpsurf.w;
+ r.x:= x mod tmpsurf^.w;
r.y:= 16;
r.w:= 1;
r.h:= 16;
@@ -305,7 +309,7 @@
begin
rr.x:= x;
rr.y:= yu;
- r.x:= x mod tmpsurf.w;
+ r.x:= x mod tmpsurf^.w;
r.y:= 0;
r.w:= 1;
r.h:= min(16, yd - yu + 1);
@@ -316,38 +320,35 @@
end;
end;
-function rndSign(num: Double): Double;
-begin
-if getrandom(2) = 0 then Result:= num
- else Result:= - num
-end;
-
-
procedure PointWave(var Template: TEdgeTemplate; var pa: TPixAr);
const MAXPASSES = 32;
-var ar: array[0..MAXPASSES, 0..9] of Double;
+var ar: array[0..MAXPASSES, 0..9] of hwFloat;
i, k: integer;
- rx, ry, ox, oy: Double;
+ rx, ry, ox, oy: hwFloat;
PassesNum: Longword;
begin
with Template do
begin
PassesNum:= PassMin + getrandom(PassDelta);
TryDo(PassesNum < MAXPASSES, 'Passes number too big', true);
- ar[0, 1]:= WaveFreqMin;
- ar[0, 4]:= WaveFreqMin;
+ ar[0, 1]:= WaveFreqMin * _1div10000;
+ ar[0, 4]:= WaveFreqMin * _1div10000;
for i:= 1 to PassesNum do // initialize random parameters
begin
ar[i, 0]:= WaveAmplMin + getrandom * WaveAmplDelta;
- ar[i, 1]:= ar[i - 1, 1] + (getrandom * 0.7 + 0.3) * WaveFreqDelta;
- ar[i, 2]:= getrandom * pi * 2;
+// ar[i, 1]:= ar[i - 1, 1] + (getrandom * 0.7 + 0.3) * WaveFreqDelta;
+ ar[i, 1]:= ar[i - 1, 1] + (getrandom) * WaveFreqDelta;
+ ar[i, 2]:= getrandom * hwPi * 2;
ar[i, 3]:= WaveAmplMin + getrandom * WaveAmplDelta;
- ar[i, 4]:= ar[i - 1, 4] + (getrandom * 0.7 + 0.3) * WaveFreqDelta;
- ar[i, 5]:= getrandom * pi * 2;
+// ar[i, 4]:= ar[i - 1, 4] + (getrandom * 0.7 + 0.3) * WaveFreqDelta;
+ ar[i, 4]:= ar[i - 1, 4] + (getrandom) * WaveFreqDelta;
+ ar[i, 5]:= getrandom * hwPi * 2;
ar[i, 6]:= ar[i, 1] * (getrandom * 2 - 1);
- ar[i, 7]:= ar[i, 1] * rndSign(sqrt(1 - sqr(ar[i, 6])));
+// ar[i, 7]:= ar[i, 1] * rndSign(sqrt(1 - sqr(ar[i, 6])));
+ ar[i, 7]:= ar[i, 1] * rndSign((1 - (ar[i, 6])));
ar[i, 8]:= ar[i, 4] * (getrandom * 2 - 1);
- ar[i, 9]:= ar[i, 4] * rndSign(sqrt(1 - sqr(ar[i, 8])));
+// ar[i, 9]:= ar[i, 4] * rndSign(sqrt(1 - sqr(ar[i, 8])));
+ ar[i, 9]:= ar[i, 4] * rndSign((1 - (ar[i, 8])));
end;
end;
@@ -359,17 +360,17 @@
begin
ox:= rx;
oy:= ry;
- ry:= ry + ar[i, 0] * sin(ox * ar[i, 6] + oy * ar[i, 7] + ar[i, 2]);
- rx:= rx + ar[i, 3] * sin(ox * ar[i, 8] + oy * ar[i, 9] + ar[i, 5]);
+// ry:= ry; + ar[i, 0] * sin(ox * ar[i, 6] + oy * ar[i, 7] + ar[i, 2]);
+// rx:= rx + ar[i, 3] * sin(ox * ar[i, 8] + oy * ar[i, 9] + ar[i, 5]);
end;
- pa.ar[k].x:= round(rx);
- pa.ar[k].y:= round(ry);
+ pa.ar[k].x:= hwRound(rx);
+ pa.ar[k].y:= hwRound(ry);
end;
end;
procedure NormalizePoints(var pa: TPixAr);
const brd = 32;
-var isUP: boolean; // HACK: transform for Y should be exact as one for X
+var isUP: boolean; // HACK: transform for Y should be exact as one for X
Left, Right, Top, Bottom,
OWidth, Width, OHeight, Height,
OLeft: integer;
@@ -449,8 +450,8 @@
for i:= 0 to pred(pa.Count) do
pa.ar[i]:= BasePoints^[i];
- for i:= 1 to BezPassCnt do
- BezierizeEdge(pa, 0.33333334);
+// for i:= 1 to BezPassCnt do
+ BezierizeEdge(pa, _1div3);
PointWave(Template, pa);
NormalizePoints(pa);
@@ -466,7 +467,7 @@
function SelectTemplate: integer;
begin
-Result:= getrandom(Succ(High(EdgeTemplates)))
+SelectTemplate:= getrandom(Succ(High(EdgeTemplates)))
end;
procedure GenLandSurface;
@@ -506,15 +507,15 @@
with PixelFormat^ do
LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, AMask);
SDL_FillRect(LandSurface, nil, 0);
-tmpsurf:= LoadImage(Pathz[ptForts] + '/' + p.FortName + 'L', false);
+tmpsurf:= LoadImage(Pathz[ptForts] + '/' + p^.FortName + 'L', false, true, true);
BlitImageAndGenerateCollisionInfo(0, 0, tmpsurf, LandSurface);
SDL_FreeSurface(tmpsurf);
-p:= p.Next;
+p:= p^.Next;
TryDo(p <> nil, 'Only one team on map!', true);
-tmpsurf:= LoadImage(Pathz[ptForts] + '/' + p.FortName + 'R', false);
+tmpsurf:= LoadImage(Pathz[ptForts] + '/' + p^.FortName + 'R', false, true, true);
BlitImageAndGenerateCollisionInfo(1024, 0, tmpsurf, LandSurface);
SDL_FreeSurface(tmpsurf);
-p:= p.Next;
+p:= p^.Next;
TryDo(p = nil, 'More than 2 teams on map in forts mode!', true);
end;
@@ -524,36 +525,37 @@
begin
WriteLnToConsole('Loading land from file...');
AddProgress;
-LandSurface:= LoadImage(Pathz[ptMapCurrent] + '/map', false);
-TryDo((LandSurface.w = 2048) and (LandSurface.h = 1024), 'Map dimensions should be 2048x1024!', true);
+LandSurface:= LoadImage(Pathz[ptMapCurrent] + '/map', false, true, true);
+TryDo((LandSurface^.w = 2048) and (LandSurface^.h = 1024), 'Map dimensions should be 2048x1024!', true);
if SDL_MustLock(LandSurface) then
SDLTry(SDL_LockSurface(LandSurface) >= 0, true);
-p:= LandSurface.pixels;
-case LandSurface.format.BytesPerPixel of
+p:= LandSurface^.pixels;
+case LandSurface^.format^.BytesPerPixel of
1: OutError('We don''t work with 8 bit surfaces', true);
2: for y:= 0 to 1023 do
begin
for x:= 0 to 2047 do
- if PWord(@p[x * 2])^ <> 0 then Land[y, x]:= COLOR_LAND;
- p:= @p[LandSurface.pitch];
+ if PWord(@(p^[x * 2]))^ <> 0 then Land[y, x]:= COLOR_LAND;
+ p:= @(p^[LandSurface^.pitch]);
end;
3: for y:= 0 to 1023 do
begin
for x:= 0 to 2047 do
- if (p[x * 3 + 0] <> 0)
- or (p[x * 3 + 1] <> 0)
- or (p[x * 3 + 2] <> 0) then Land[y, x]:= COLOR_LAND;
- p:= @p[LandSurface.pitch];
+ if (p^[x * 3 + 0] <> 0)
+ or (p^[x * 3 + 1] <> 0)
+ or (p^[x * 3 + 2] <> 0) then Land[y, x]:= COLOR_LAND;
+ p:= @(p^[LandSurface^.pitch]);
end;
4: for y:= 0 to 1023 do
begin
for x:= 0 to 2047 do
- if PLongword(@p[x * 4])^ <> 0 then Land[y, x]:= COLOR_LAND;
- p:= @p[LandSurface.pitch];
+ if PLongword(@(p^[x * 4]))^ <> 0 then Land[y, x]:= COLOR_LAND;
+ p:= @(p^[LandSurface^.pitch]);
end;
end;
+
if SDL_MustLock(LandSurface) then
SDL_UnlockSurface(LandSurface);
end;
@@ -584,7 +586,7 @@
for yy:= y * 8 to y * 8 + 7 do
for xx:= x * 64 + bit * 8 to x * 64 + bit * 8 + 7 do
if Land[yy, xx] <> 0 then inc(t);
- if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit)
+ if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit)
end
end
end;
--- a/hedgewars/uLandGraphics.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uLandGraphics.pas Sun Jan 21 19:51:02 2007 +0000
@@ -1,5 +1,6 @@
unit uLandGraphics;
interface
+uses uFloat;
{$INCLUDE options.inc}
type PRangeArray = ^TRangeArray;
@@ -9,7 +10,7 @@
procedure DrawExplosion(X, Y, Radius: integer);
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: integer; y, dY: integer; Count: Byte);
-procedure DrawTunnel(X, Y, dX, dY: Double; ticks, HalfWidth: integer);
+procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: integer);
procedure FillRoundInLand(X, Y, Radius: integer; Value: Longword);
implementation
@@ -51,32 +52,32 @@
procedure ClearLandPixel(y, x: integer);
var p: PByteArray;
begin
-p:= @PByteArray(LandSurface.pixels)^[LandSurface.pitch*y];
-case LandSurface.format.BytesPerPixel of
+p:= @PByteArray(LandSurface^.pixels)^[LandSurface^.pitch * y];
+case LandSurface^.format^.BytesPerPixel of
1: ;// not supported
- 2: PWord(@p[x * 2])^:= 0;
+ 2: PWord(@(p^[x * 2]))^:= 0;
3: begin
- p[x * 3 + 0]:= 0;
- p[x * 3 + 1]:= 0;
- p[x * 3 + 2]:= 0;
+ p^[x * 3 + 0]:= 0;
+ p^[x * 3 + 1]:= 0;
+ p^[x * 3 + 2]:= 0;
end;
- 4: PLongword(@p[x * 4])^:= 0;
+ 4: PLongword(@(p^[x * 4]))^:= 0;
end
end;
procedure SetLandPixel(y, x: integer);
var p: PByteArray;
begin
-p:= @PByteArray(LandSurface.pixels)^[LandSurface.pitch*y];
-case LandSurface.format.BytesPerPixel of
+p:= @PByteArray(LandSurface^.pixels)^[LandSurface^.pitch * y];
+case LandSurface^.format^.BytesPerPixel of
1: ;// not supported
- 2: PWord(@p[x * 2])^:= cExplosionBorderColor;
+ 2: PWord(@(p^[x * 2]))^:= cExplosionBorderColor;
3: begin
- p[x * 3 + 0]:= cExplosionBorderColor and $FF;
- p[x * 3 + 1]:= (cExplosionBorderColor shr 8) and $FF;
- p[x * 3 + 2]:= cExplosionBorderColor shr 16;
+ p^[x * 3 + 0]:= cExplosionBorderColor and $FF;
+ p^[x * 3 + 1]:= (cExplosionBorderColor shr 8) and $FF;
+ p^[x * 3 + 2]:= cExplosionBorderColor shr 16;
end;
- 4: PLongword(@p[x * 4])^:= cExplosionBorderColor;
+ 4: PLongword(@(p^[x * 4]))^:= cExplosionBorderColor;
end
end;
@@ -148,8 +149,8 @@
end;
inc(dx)
end;
- if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);
-
+ if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy);
+
if SDL_MustLock(LandSurface) then
SDL_UnlockSurface(LandSurface);
end;
@@ -163,18 +164,18 @@
for i:= 0 to Pred(Count) do
begin
for ty:= max(y - Radius, 0) to min(y + Radius, 1023) do
- for tx:= max(0, ar[i].Left - Radius) to min(2047, ar[i].Right + Radius) do
+ for tx:= max(0, ar^[i].Left - Radius) to min(2047, ar^[i].Right + Radius) do
ClearLandPixel(ty, tx);
inc(y, dY)
end;
inc(Radius, 4);
-dec(y, Count*dY);
+dec(y, Count * dY);
for i:= 0 to Pred(Count) do
begin
for ty:= max(y - Radius, 0) to min(y + Radius, 1023) do
- for tx:= max(0, ar[i].Left - Radius) to min(2047, ar[i].Right + Radius) do
+ for tx:= max(0, ar^[i].Left - Radius) to min(2047, ar^[i].Right + Radius) do
if Land[ty, tx] = $FFFFFF then
SetLandPixel(ty, tx);
inc(y, dY)
@@ -187,8 +188,8 @@
//
// - (dX, dY) - direction, vector of length = 0.5
//
-procedure DrawTunnel(X, Y, dX, dY: Double; ticks, HalfWidth: integer);
-var nx, ny: Double;
+procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: integer);
+var nx, ny: hwFloat;
i, t, tx, ty: Longint;
begin // (-dY, dX) is (dX, dY) rotated by PI/2
if SDL_MustLock(LandSurface) then
@@ -219,8 +220,8 @@
begin
X:= X + dX;
Y:= Y + dY;
- tx:= round(X);
- ty:= round(Y);
+ tx:= hwRound(X);
+ ty:= hwRound(Y);
if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0) then
begin
Land[ty, tx]:= 0;
--- a/hedgewars/uLandObjects.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uLandObjects.pas Sun Jan 21 19:51:02 2007 +0000
@@ -71,30 +71,30 @@
if SDL_MustLock(Image) then
SDLTry(SDL_LockSurface(Image) >= 0, true);
-bpp:= Image.format.BytesPerPixel;
+bpp:= Image^.format^.BytesPerPixel;
WriteToConsole('('+inttostr(bpp)+') ');
-p:= Image.pixels;
+p:= Image^.pixels;
case bpp of
1: OutError('We don''t work with 8 bit surfaces', true);
- 2: for y:= 0 to Pred(Image.h) do
+ 2: for y:= 0 to Pred(Image^.h) do
begin
- for x:= 0 to Pred(Image.w) do
- if PWord(@p[x * 2])^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND;
- p:= @p[Image.pitch];
+ for x:= 0 to Pred(Image^.w) do
+ if PWord(@(p^[x * 2]))^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND;
+ p:= @(p^[Image^.pitch]);
end;
- 3: for y:= 0 to Pred(Image.h) do
+ 3: for y:= 0 to Pred(Image^.h) do
begin
- for x:= 0 to Pred(Image.w) do
- if (p[x * 3 + 0] <> 0)
- or (p[x * 3 + 1] <> 0)
- or (p[x * 3 + 2] <> 0) then Land[cpY + y, cpX + x]:= COLOR_LAND;
- p:= @p[Image.pitch];
+ for x:= 0 to Pred(Image^.w) do
+ if (p^[x * 3 + 0] <> 0)
+ or (p^[x * 3 + 1] <> 0)
+ or (p^[x * 3 + 2] <> 0) then Land[cpY + y, cpX + x]:= COLOR_LAND;
+ p:= @(p^[Image^.pitch]);
end;
- 4: for y:= 0 to Pred(Image.h) do
+ 4: for y:= 0 to Pred(Image^.h) do
begin
- for x:= 0 to Pred(Image.w) do
- if PLongword(@p[x * 4])^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND;
- p:= @p[Image.pitch];
+ for x:= 0 to Pred(Image^.w) do
+ if PLongword(@(p^[x * 4]))^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND;
+ p:= @(p^[Image^.pitch]);
end;
end;
if SDL_MustLock(Image) then
@@ -104,7 +104,7 @@
procedure AddRect(x1, y1, w1, h1: integer);
begin
-with Rects[RectCount] do
+with Rects^[RectCount] do
begin
x:= x1;
y:= y1;
@@ -128,29 +128,34 @@
function CheckIntersect(x1, y1, w1, h1: integer): boolean;
var i: Longword;
+ Result: boolean;
begin
Result:= false;
i:= 0;
if RectCount > 0 then
repeat
- with Rects[i] do
+ with Rects^[i] do
Result:= (x < x1 + w1) and (x1 < x + w) and
(y < y1 + h1) and (y1 < y + h);
inc(i)
- until (i = RectCount) or (Result)
+ until (i = RectCount) or (Result);
+CheckIntersect:= Result
end;
function AddGirder(gX: integer; Surface: PSDL_Surface): boolean;
var tmpsurf: PSDL_Surface;
x1, x2, y, k, i: integer;
r, rr: TSDL_Rect;
+ Result: boolean;
function CountNonZeroz(x, y: integer): Longword;
var i: integer;
+ Result: Longword;
begin
Result:= 0;
for i:= y to y + 15 do
- if Land[i, x] <> 0 then inc(Result)
+ if Land[i, x] <> 0 then inc(Result);
+ CountNonZeroz:= Result
end;
begin
@@ -182,7 +187,7 @@
if x1 > 0 then
begin
Result:= true;
- tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', false);
+ tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', false, true, true);
rr.x:= x1;
rr.y:= y;
while rr.x + 100 < x2 do
@@ -199,11 +204,13 @@
AddRect(x1 - 8, y - 32, x2 - x1 + 16, 80);
for k:= y to y + 15 do
for i:= x1 to x2 do Land[k, i]:= $FFFFFF
- end else Result:= false
+ end else Result:= false;
+AddGirder:= Result
end;
function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean;
var i: Longword;
+ Result: boolean;
begin
Result:= true;
inc(rect.x, dX);
@@ -222,10 +229,12 @@
inc(i)
end;
{$WARNINGS ON}
+CheckLand:= Result
end;
function CheckCanPlace(x, y: Longword; var Obj: TThemeObject): boolean;
var i: Longword;
+ Result: boolean;
begin
with Obj do
if CheckLand(inland, x, y, $FFFFFF) then
@@ -240,7 +249,8 @@
if Result then
Result:= not CheckIntersect(x, y, Width, Height)
end else
- Result:= false
+ Result:= false;
+CheckCanPlace:= Result
end;
function TryPut(var Obj: TThemeObject; Surface: PSDL_Surface): boolean; overload;
@@ -248,15 +258,13 @@
var x, y: Longword;
ar: array[0..MaxPointsIndex] of TPoint;
cnt, i: Longword;
+ Result: boolean;
begin
cnt:= 0;
with Obj do
begin
if Maxcnt = 0 then
- begin
- Result:= false;
- exit
- end;
+ exit(false);
x:= 0;
repeat
y:= 0;
@@ -284,7 +292,8 @@
AddRect(ar[i].x, ar[i].y, Width, Height);
dec(Maxcnt)
end else Maxcnt:= 0
- end
+ end;
+TryPut:= Result
end;
function TryPut(var Obj: TSprayObject; Surface: PSDL_Surface): boolean; overload;
@@ -293,15 +302,13 @@
ar: array[0..MaxPointsIndex] of TPoint;
cnt, i: Longword;
r: TSDL_Rect;
+ Result: boolean;
begin
cnt:= 0;
with Obj do
begin
if Maxcnt = 0 then
- begin
- Result:= false;
- exit
- end;
+ exit(false);
x:= 0;
r.x:= 0;
r.y:= 0;
@@ -338,7 +345,8 @@
AddRect(ar[i].x - 32, ar[i].y - 32, Width + 64, Height + 64);
dec(Maxcnt)
end else Maxcnt:= 0
- end
+ end;
+TryPut:= Result
end;
procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects);
@@ -348,7 +356,7 @@
begin
s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
WriteLnToConsole('Reading objects info...');
-AssignFile(f, s);
+Assign(f, s);
{$I-}
Reset(f);
Readln(f, s); // skip color
@@ -358,9 +366,9 @@
Readln(f, s); // filename
with ThemeObjects.objs[i] do
begin
- Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false);
- Width:= Surf.w;
- Height:= Surf.h;
+ Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false, true, true);
+ Width:= Surf^.w;
+ Height:= Surf^.h;
with inland do Read(f, x, y, w, h);
Read(f, rectcnt);
for ii:= 1 to rectcnt do
@@ -376,13 +384,13 @@
Readln(f, s); // filename
with SprayObjects.objs[i] do
begin
- Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false);
- Width:= Surf.w;
- Height:= Surf.h;
+ Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false, true, true);
+ Width:= Surf^.w;
+ Height:= Surf^.h;
ReadLn(f, Maxcnt)
end;
end;
-Closefile(f);
+Close(f);
{$I+}
TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true)
end;
--- a/hedgewars/uLandTemplates.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uLandTemplates.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,7 +18,7 @@
unit uLandTemplates;
interface
-uses SDLh;
+uses SDLh, uFloat;
{$INCLUDE options.inc}
type PPointArray = ^TPointArray;
@@ -28,8 +28,8 @@
BasePointsCount: Longword;
BezPassCnt: Longword;
PassMin, PassDelta: Longword;
- WaveAmplMin, WaveAmplDelta: Double;
- WaveFreqMin, WaveFreqDelta: Double;
+ WaveAmplMin, WaveAmplDelta: Longword;
+ WaveFreqMin, WaveFreqDelta: Longword;
FillPoints: PPointArray;
FillPointsCount: Longword;
canMirror, canFlip: boolean;
@@ -496,7 +496,7 @@
BezPassCnt: 4;
PassMin: 10; PassDelta: 5;
WaveAmplMin: 17; WaveAmplDelta: 20;
- WaveFreqMin: 0.010; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0100; WaveFreqDelta: 0020;
FillPoints: @Template0FPoints;
FillPointsCount: Succ(High(Template0FPoints));
canMirror: false; canFlip: false;
@@ -506,7 +506,7 @@
BezPassCnt: 3;
PassMin: 10; PassDelta: 2;
WaveAmplMin: 25; WaveAmplDelta: 15;
- WaveFreqMin: 0.008; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0080; WaveFreqDelta: 0020;
FillPoints: @Template1FPoints;
FillPointsCount: Succ(High(Template1FPoints));
canMirror: false; canFlip: false;
@@ -516,7 +516,7 @@
BezPassCnt: 3;
PassMin: 14; PassDelta: 3;
WaveAmplMin: 10; WaveAmplDelta: 10;
- WaveFreqMin: 0.010; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0100; WaveFreqDelta: 0020;
FillPoints: @Template2FPoints;
FillPointsCount: Succ(High(Template2FPoints));
canMirror: true; canFlip: false;
@@ -526,7 +526,7 @@
BezPassCnt: 4;
PassMin: 15; PassDelta: 2;
WaveAmplMin: 8; WaveAmplDelta: 12;
- WaveFreqMin: 0.015; WaveFreqDelta: 0.0015;
+ WaveFreqMin: 0150; WaveFreqDelta: 0015;
FillPoints: @Template3FPoints;
FillPointsCount: Succ(High(Template3FPoints));
canMirror: true; canFlip: false;
@@ -536,7 +536,7 @@
BezPassCnt: 3;
PassMin: 19; PassDelta: 5;
WaveAmplMin: 12; WaveAmplDelta: 14;
- WaveFreqMin: 0.008; WaveFreqDelta: 0.001;
+ WaveFreqMin: 0080; WaveFreqDelta: 0010;
FillPoints: @Template4FPoints;
FillPointsCount: Succ(High(Template4FPoints));
canMirror: true; canFlip: false;
@@ -546,7 +546,7 @@
BezPassCnt: 4;
PassMin: 15; PassDelta: 1;
WaveAmplMin: 15; WaveAmplDelta: 14;
- WaveFreqMin: 0.008; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0080; WaveFreqDelta: 0020;
FillPoints: @Template5FPoints;
FillPointsCount: Succ(High(Template5FPoints));
canMirror: true; canFlip: false;
@@ -556,7 +556,7 @@
BezPassCnt: 3;
PassMin: 15; PassDelta: 1;
WaveAmplMin: 15; WaveAmplDelta: 10;
- WaveFreqMin: 0.010; WaveFreqDelta: 0.0015;
+ WaveFreqMin: 0100; WaveFreqDelta: 0015;
FillPoints: @Template6FPoints;
FillPointsCount: Succ(High(Template6FPoints));
canMirror: true; canFlip: false;
@@ -566,7 +566,7 @@
BezPassCnt: 3;
PassMin: 12; PassDelta: 4;
WaveAmplMin: 5; WaveAmplDelta: 15;
- WaveFreqMin: 0.015; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0150; WaveFreqDelta: 0020;
FillPoints: @Template7FPoints;
FillPointsCount: Succ(High(Template7FPoints));
canMirror: true; canFlip: false;
@@ -576,7 +576,7 @@
BezPassCnt: 4;
PassMin: 9; PassDelta: 3;
WaveAmplMin: 18; WaveAmplDelta: 18;
- WaveFreqMin: 0.010; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0100; WaveFreqDelta: 0020;
FillPoints: @Template8FPoints;
FillPointsCount: Succ(High(Template8FPoints));
canMirror: true; canFlip: false;
@@ -586,7 +586,7 @@
BezPassCnt: 4;
PassMin: 17; PassDelta: 3;
WaveAmplMin: 10; WaveAmplDelta: 10;
- WaveFreqMin: 0.010; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0100; WaveFreqDelta: 0020;
FillPoints: @Template9FPoints;
FillPointsCount: Succ(High(Template9FPoints));
canMirror: true; canFlip: false;
@@ -596,7 +596,7 @@
BezPassCnt: 4;
PassMin: 15; PassDelta: 2;
WaveAmplMin: 15; WaveAmplDelta: 10;
- WaveFreqMin: 0.008; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0080; WaveFreqDelta: 0020;
FillPoints: @Template10FPoints;
FillPointsCount: Succ(High(Template10FPoints));
canMirror: false; canFlip: false;
@@ -606,7 +606,7 @@
BezPassCnt: 4;
PassMin: 15; PassDelta: 1;
WaveAmplMin: 10; WaveAmplDelta: 10;
- WaveFreqMin: 0.008; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0080; WaveFreqDelta: 0020;
FillPoints: @Template11FPoints;
FillPointsCount: Succ(High(Template11FPoints));
canMirror: true; canFlip: false;
@@ -616,7 +616,7 @@
BezPassCnt: 3;
PassMin: 10; PassDelta: 1;
WaveAmplMin: 15; WaveAmplDelta: 15;
- WaveFreqMin: 0.005; WaveFreqDelta: 0.003;
+ WaveFreqMin: 0050; WaveFreqDelta: 0030;
FillPoints: @Template12FPoints;
FillPointsCount: Succ(High(Template12FPoints));
canMirror: true; canFlip: false;
@@ -626,7 +626,7 @@
BezPassCnt: 5;
PassMin: 15; PassDelta: 3;
WaveAmplMin: 18; WaveAmplDelta: 15;
- WaveFreqMin: 0.0028; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0028; WaveFreqDelta: 0020;
FillPoints: @Template13FPoints;
FillPointsCount: Succ(High(Template13FPoints));
canMirror: true; canFlip: false;
@@ -636,7 +636,7 @@
BezPassCnt: 4;
PassMin: 14; PassDelta: 3;
WaveAmplMin: 20; WaveAmplDelta: 15;
- WaveFreqMin: 0.003; WaveFreqDelta: 0.002;
+ WaveFreqMin: 0030; WaveFreqDelta: 0020;
FillPoints: @Template14FPoints;
FillPointsCount: Succ(High(Template14FPoints));
canMirror: true; canFlip: false;
--- a/hedgewars/uLocale.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uLocale.pas Sun Jan 21 19:51:02 2007 +0000
@@ -40,7 +40,7 @@
a, b, c: integer;
begin
{$I-}
-AssignFile(f, FileName);
+Assign(f, FileName);
reset(f);
TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true);
while not eof(f) do
@@ -61,7 +61,7 @@
1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
end;
end;
-closefile(f)
+Close(f)
{$I+}
end;
@@ -69,8 +69,8 @@
var i: integer;
begin
i:= Pos('%1', fmt);
-if i = 0 then Result:= fmt
- else Result:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
+if i = 0 then Format:= fmt
+ else Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
end;
end.
--- a/hedgewars/uMisc.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uMisc.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,7 +18,7 @@
unit uMisc;
interface
-uses uConsts, SDLh;
+uses uConsts, SDLh, uFloat;
{$INCLUDE options.inc}
var isCursorVisible : boolean = false;
isTerminated : boolean = false;
@@ -37,7 +37,7 @@
cCloudsNumber : integer = 9;
cConsoleHeight : integer = 320;
- cConsoleYAdd : integer = 0;
+ cConsoleYAdd : integer = 0;
cScreenWidth : integer = 1024;
cScreenHeight : integer = 768;
cBits : integer = 16;
@@ -58,11 +58,6 @@
cColorNearBlack : Longword = 16;
cExplosionBorderColor : LongWord = $808080;
- cDrownSpeed : Double = 0.06;
- cMaxWindSpeed : Double = 0.0005;
- cWindSpeed : Double = 0.0001;
- cGravity : Double = 0.0005;
-
cShowFPS : boolean = true;
cCaseFactor : Longword = 3; {1..10}
cFullScreen : boolean = true;
@@ -71,12 +66,16 @@
cInitVolume : integer = 128;
cVolumeDelta : integer = 0;
cTimerInterval : Longword = 5;
- cHasFocus : boolean = true;
+ cHasFocus : boolean = true;
var
cSendEmptyPacketTime : LongWord = 2000;
cSendCursorPosTime : LongWord = 50;
ShowCrosshair : boolean;
+ cDrownSpeed,
+ cMaxWindSpeed,
+ cWindSpeed,
+ cGravity: hwFloat;
flagMakeCapture: boolean = false;
@@ -84,14 +83,15 @@
AttackBar: integer = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
-function hwSign(r: Double): integer;
+function hwSign(r: hwFloat): integer;
function Min(a, b: integer): integer;
function Max(a, b: integer): integer;
-procedure OutError(Msg: String; const isFatalError: boolean=false);
+function rndSign(num: hwFloat): hwFloat;
+procedure OutError(Msg: String; isFatalError: boolean);
procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean);
procedure SDLTry(Assert: boolean; isFatal: boolean);
function IntToStr(n: LongInt): shortstring;
-function FloatToStr(n: Double): shortstring;
+function FloatToStr(n: hwFloat): shortstring;
function DxDy2Angle32(const _dY, _dX: Extended): integer;
function DxDy2AttackAngle(const _dY, _dX: Extended): integer;
procedure AdjustColor(var Color: Longword);
@@ -101,35 +101,36 @@
{$ENDIF}
procedure SetKB(n: Longword);
procedure SendKB;
-procedure SetLittle(var r: Double);
+procedure SetLittle(var r: hwFloat);
procedure SendStat(sit: TStatInfoType; s: shortstring);
+function Str2PChar(var s: shortstring): PChar;
var CursorPoint: TPoint;
TargetPoint: TPoint = (X: NoPointX; Y: 0);
implementation
-uses uConsole, uStore, uIO{$IFDEF FPC}, Math{$ENDIF};
+uses uConsole, uStore, uIO, Math, uRandom;
var KBnum: Longword = 0;
{$IFDEF DEBUGFILE}
var f: textfile;
{$ENDIF}
-function hwSign(r: Double): integer;
+function hwSign(r: hwFloat): integer;
begin
-if r < 0 then Result:= -1 else Result:= 1
+if r.isNegative then hwSign:= -1 else hwSign:= 1
end;
function Min(a, b: integer): integer;
begin
-if a < b then Result:= a else Result:= b
+if a < b then Min:= a else Min:= b
end;
function Max(a, b: integer): integer;
begin
-if a > b then Result:= a else Result:= b
+if a > b then Max:= a else Max:= b
end;
-procedure OutError(Msg: String; const isFatalError: boolean=false);
+procedure OutError(Msg: String; isFatalError: boolean);
begin
{$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF}
WriteLnToConsole(Msg);
@@ -158,17 +159,16 @@
function IntToStr(n: LongInt): shortstring;
begin
-str(n, Result)
+str(n, IntToStr)
end;
-function FloatToStr(n: Double): shortstring;
+function FloatToStr(n: hwFloat): shortstring;
begin
-//str(n:5:5, Result)
-str(n, Result)
+FloatToStr:= cstr(n)
end;
{$IFNDEF FPC}
-function arctan2(const Y, X: Double): Double;
+function arctan2(const Y, X: hwFloat): hwFloat;
asm
fld Y
fld X
@@ -180,13 +180,13 @@
function DxDy2Angle32(const _dY, _dX: Extended): integer;
const _16divPI: Extended = 16/pi;
begin
-Result:= trunc(arctan2(_dY, _dX) * _16divPI) and $1f
+DxDy2Angle32:= trunc(arctan2(_dY, _dX) * _16divPI) and $1f
end;
function DxDy2AttackAngle(const _dY, _dX: Extended): integer;
const MaxAngleDivPI: Extended = cMaxAngle/pi;
begin
-Result:= trunc(arctan2(_dY, _dX) * MaxAngleDivPI) mod cMaxAngle
+DxDy2AttackAngle:= trunc(arctan2(_dY, _dX) * MaxAngleDivPI) mod cMaxAngle
end;
procedure SetKB(n: Longword);
@@ -204,9 +204,9 @@
end
end;
-procedure SetLittle(var r: Double);
+procedure SetLittle(var r: hwFloat);
begin
-if r >= 0 then r:= cLittle else r:= - cLittle
+if not r.isNegative then r:= cLittle else r:= - cLittle
end;
procedure SendStat(sit: TStatInfoType; s: shortstring);
@@ -215,6 +215,20 @@
SendIPC('i' + stc[sit] + s)
end;
+function rndSign(num: hwFloat): hwFloat;
+begin
+num.isNegative:= getrandom(2) = 0;
+rndSign:= num
+end;
+
+function Str2PChar(var s: shortstring): PChar;
+const CharArray: array[byte] of Char = '';
+begin
+CharArray:= s;
+CharArray[Length(s)]:= #0;
+Str2PChar:= @CharArray
+end;
+
{$IFDEF DEBUGFILE}
procedure AddFileLog(s: shortstring);
begin
@@ -224,17 +238,23 @@
function RectToStr(Rect: TSDL_Rect): shortstring;
begin
-Result:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')'
+RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')'
end;
var i: integer;
initialization
+cDrownSpeed.QWordValue:= 257698038;// 0.06
+cMaxWindSpeed.QWordValue:= 2147484;// 0.0005
+cWindSpeed.QWordValue:= 429496;// 0.0001
+cGravity:= cMaxWindSpeed;
+
+
{$I-}
for i:= 0 to 7 do
begin
- AssignFile(f, 'debug' + inttostr(i) + '.txt');
+ Assign(f, 'debug' + inttostr(i) + '.txt');
rewrite(f);
if IOResult = 0 then break
end;
@@ -243,7 +263,7 @@
finalization
writeln(f, '-= halt at ',GameTicks,' ticks =-');
Flush(f);
-closefile(f)
+close(f)
{$ENDIF}
end.
--- a/hedgewars/uRandom.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uRandom.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,10 +18,11 @@
unit uRandom;
interface
+uses uFloat;
{$INCLUDE options.inc}
procedure SetRandomSeed(Seed: shortstring);
-function GetRandom: Double; overload;
+function GetRandom: hwFloat; overload;
function GetRandom(m: LongWord): LongWord; overload;
implementation
@@ -36,7 +37,7 @@
cirbuf[(n + 9) and $3F]) {n - 55 mod 64}
and $7FFFFFFF; {mod 2^31}
-Result:= cirbuf[n]
+GetNext:= cirbuf[n]
end;
procedure SetRandomSeed(Seed: shortstring);
@@ -55,15 +56,19 @@
for i:= 0 to 1023 do GetNext
end;
-function GetRandom: Double;
+function GetRandom: hwFloat;
+var r: hwFloat;
begin
-Result:= frac( GetNext * 0.00073 + GetNext * 0.00301)
+GetNext;
+r.isNegative:= false;
+r.QWordValue:= GetNext;
+GetRandom:= r
end;
function GetRandom(m: LongWord): LongWord;
begin
GetNext;
-Result:= GetNext mod m
+GetRandom:= GetNext mod m
end;
end.
--- a/hedgewars/uSHA.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uSHA.pas Sun Jan 21 19:51:02 2007 +0000
@@ -35,27 +35,27 @@
function rol(x: LongWord; y: Byte): LongWord;
begin
- Result:= (X shl y) or (X shr (32 - y))
+ rol:= (X shl y) or (X shr (32 - y))
end;
function Ft(t, b, c, d: LongWord): LongWord;
begin
case t of
- 0..19: Result := (b and c) or ((not b) and d);
- 20..39: Result := b xor c xor d;
- 40..59: Result := (b and c) or (b and d) or (c and d);
- else Result := b xor c xor d;
+ 0..19: Ft := (b and c) or ((not b) and d);
+ 20..39: Ft := b xor c xor d;
+ 40..59: Ft := (b and c) or (b and d) or (c and d);
+ else Ft := b xor c xor d;
end;
end;
function Kt(t: Byte): LongWord;
begin
case t of
- 0..19: Result := $5A827999;
- 20..39: Result := $6ED9EBA1;
- 40..59: Result := $8F1BBCDC;
+ 0..19: Kt := $5A827999;
+ 20..39: Kt := $6ED9EBA1;
+ 40..59: Kt := $8F1BBCDC;
else
- Result := $CA62C1D6
+ Kt := $CA62C1D6
end;
end;
@@ -67,11 +67,11 @@
begin
move(Context.H, S, sizeof(S));
for i:= 0 to 15 do
- SDLNet_Write32(PLongWordArray(@Context.Buf)[i], @W[i]);
-
+ SDLNet_Write32(PLongWordArray(@Context.Buf)^[i], @W[i]);
+
for i := 16 to 79 do
W[i] := rol(W[i - 3] xor W[i - 8] xor W[i - 14] xor W[i - 16], 1);
-
+
for i := 0 to 79 do
begin
t:= rol(S[0], 5) + Ft(i, S[1], S[2], S[3]) + S[4] + W[i] + Kt(i);
@@ -81,7 +81,7 @@
S[1]:= S[0];
S[0]:= t
end;
-
+
for i := 0 to 4 do
Context.H[i]:= Context.H[i] + S[i]
end;
@@ -118,6 +118,7 @@
function SHA1Final(Context: TSHA1Context): TSHA1Digest;
var i: LongWord;
+ Result: TSHA1Digest;
begin
Context.Length:= Context.Length + Context.CurrLength shl 3;
Context.Buf[Context.CurrLength]:= $80;
@@ -137,7 +138,8 @@
Context.Buf[i] := (Context.Length shr ((63 - i) * 8)) and $FF;
SHA1Hash(Context);
move(Context.H, Result, sizeof(TSHA1Digest));
-FillChar(Context, sizeof(Context), 0)
+FillChar(Context, sizeof(Context), 0);
+SHA1Final:= Result
end;
end.
--- a/hedgewars/uSound.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uSound.pas Sun Jan 21 19:51:02 2007 +0000
@@ -24,7 +24,7 @@
procedure InitSound;
procedure ReleaseSound;
procedure SoundLoad;
-procedure PlaySound(snd: TSound; const infinite: boolean = false);
+procedure PlaySound(snd: TSound; infinite: boolean);
procedure PlayMusic;
procedure StopSound(snd: TSound);
function ChangeVolume(voldelta: integer): integer;
@@ -63,26 +63,26 @@
procedure SoundLoad;
var i: TSound;
- s: string;
+ s: array[byte] of char;
begin
if not isSoundEnabled then exit;
for i:= Low(TSound) to High(TSound) do
begin
s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName;
- WriteToConsole(msgLoading + s + ' ');
- Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(PChar(s), 'rb'), 1);
+ WriteToConsole(msgLoading + string(s) + ' ');
+ Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(@s, 'rb'), 1);
TryDo(Soundz[i].id <> nil, msgFailed, true);
WriteLnToConsole(msgOK);
end;
s:= PathPrefix + '/Music/kahvi140a_alexander_chereshnev-illusion.ogg';
-WriteToConsole(msgLoading + s + ' ');
-Mus:= Mix_LoadMUS(PChar(s));
+WriteToConsole(msgLoading + string(s) + ' ');
+Mus:= Mix_LoadMUS(@s);
TryDo(Mus <> nil, msgFailed, false);
WriteLnToConsole(msgOK)
end;
-procedure PlaySound(snd: TSound; const infinite: boolean = false);
+procedure PlaySound(snd: TSound; infinite: boolean);
var loops: integer;
begin
if not isSoundEnabled then exit;
@@ -107,16 +107,14 @@
function ChangeVolume(voldelta: integer): integer;
begin
if not isSoundEnabled then
- begin
- Result:= 0;
- exit
- end;
+ exit(0);
+
inc(Volume, voldelta);
if Volume < 0 then Volume:= 0;
Mix_Volume(-1, Volume);
Volume:= Mix_Volume(-1, -1);
Mix_VolumeMusic(Volume * 3 div 8);
-Result:= Volume * 100 div MIX_MAX_VOLUME
+ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME
end;
end.
--- a/hedgewars/uStore.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uStore.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,7 +18,7 @@
unit uStore;
interface
-uses uConsts, uTeams, SDLh;
+uses uConsts, uTeams, SDLh, uFloat;
{$INCLUDE options.inc}
procedure StoreInit;
@@ -35,10 +35,10 @@
procedure DrawCentered(X, Top: integer; Source, Surface: PSDL_Surface);
procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface);
procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface);
-function RenderString(s: string; Color: integer; font: THWFont): PSDL_Surface;
+function RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface;
procedure RenderHealth(var Hedgehog: THedgehog);
procedure AddProgress;
-function LoadImage(filename: string; hasAlpha: boolean; const critical: boolean = true; const setTransparent: boolean = true): PSDL_Surface;
+function LoadImage(filename: string; hasAlpha, critical, setTransparent: boolean): PSDL_Surface;
var PixelFormat: PSDL_PixelFormat;
SDLPrimSurface: PSDL_Surface;
@@ -52,7 +52,7 @@
procedure StoreInit;
begin
-StoreSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, PixelFormat.AMask);
+StoreSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat^.RMask, PixelFormat^.GMask, PixelFormat^.BMask, PixelFormat^.AMask);
TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true);
SDL_FillRect(StoreSurface, nil, 0);
@@ -63,53 +63,56 @@
var tmpsurf: PSDL_Surface;
rr: TSDL_Rect;
begin
- tmpsurf:= LoadImage(Filename, false);
+ tmpsurf:= LoadImage(Filename, false, true, false);
rr.x:= X;
rr.y:= Y;
SDL_UpperBlit(tmpsurf, nil, Surface, @rr);
SDL_FreeSurface(tmpsurf);
end;
-procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; const Clear: boolean = true);
+procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
var r: TSDL_Rect;
begin
r:= rect^;
if Clear then SDL_FillRect(Surface, @r, 0);
-r.y:= rect.y + 1;
-r.h:= rect.h - 2;
+r.y:= rect^.y + 1;
+r.h:= rect^.h - 2;
SDL_FillRect(Surface, @r, BorderColor);
-r.x:= rect.x + 1;
-r.w:= rect.w - 2;
-r.y:= rect.y;
-r.h:= rect.h;
+r.x:= rect^.x + 1;
+r.w:= rect^.w - 2;
+r.y:= rect^.y;
+r.h:= rect^.h;
SDL_FillRect(Surface, @r, BorderColor);
-r.x:= rect.x + 2;
-r.y:= rect.y + 1;
-r.w:= rect.w - 4;
-r.h:= rect.h - 2;
+r.x:= rect^.x + 2;
+r.y:= rect^.y + 1;
+r.w:= rect^.w - 4;
+r.h:= rect^.h - 2;
SDL_FillRect(Surface, @r, FillColor);
-r.x:= rect.x + 1;
-r.y:= rect.y + 2;
-r.w:= rect.w - 2;
-r.h:= rect.h - 4;
+r.x:= rect^.x + 1;
+r.y:= rect^.y + 2;
+r.w:= rect^.w - 2;
+r.h:= rect^.h - 4;
SDL_FillRect(Surface, @r, FillColor)
end;
function WriteInRoundRect(Surface: PSDL_Surface; X, Y: integer; Color: LongWord; Font: THWFont; s: string): TSDL_Rect;
-var w, h: integer;
+var w, h: LongInt;
tmpsurf: PSDL_Surface;
clr: TSDL_Color;
+ Result: TSDL_Rect;
+ ps: array[byte] of char;
begin
-TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), w, h);
+ps:= s;
+TTF_SizeUTF8(Fontz[Font].Handle, @ps, w, h);
Result.x:= X;
Result.y:= Y;
Result.w:= w + FontBorder * 2 + 4;
Result.h:= h + FontBorder * 2;
-DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface);
+DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface, true);
clr.r:= Color shr 16;
clr.g:= (Color shr 8) and $FF;
clr.b:= Color and $FF;
-tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr.value);
+tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, @ps, clr.value);
Result.x:= X + FontBorder + 2;
Result.y:= Y + FontBorder;
SDLTry(tmpsurf <> nil, true);
@@ -118,7 +121,8 @@
Result.x:= X;
Result.y:= Y;
Result.w:= w + FontBorder * 2 + 4;
-Result.h:= h + FontBorder * 2
+Result.h:= h + FontBorder * 2;
+WriteInRoundRect:= Result
end;
procedure StoreLoad;
@@ -141,22 +145,22 @@
while Team<>nil do
begin
r.w:= 104;
- Team.NameTag:= RenderString(Team.TeamName, Team.Color, Font);
+ Team^.NameTag:= RenderString(Team^.TeamName, Team^.Color, Font);
r.w:= cTeamHealthWidth + 5;
- r.h:= Team.NameTag.h;
- DrawRoundRect(@r, cWhiteColor, cColorNearBlack, StoreSurface);
- Team.HealthRect:= r;
+ r.h:= Team^.NameTag^.h;
+ DrawRoundRect(@r, cWhiteColor, cColorNearBlack, StoreSurface, true);
+ Team^.HealthRect:= r;
rr:= r;
inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
- DrawRoundRect(@rr, Team.AdjColor, Team.AdjColor, StoreSurface, false);
+ DrawRoundRect(@rr, Team^.AdjColor, Team^.AdjColor, StoreSurface, false);
inc(r.y, r.h);
dec(drY, r.h + 2);
- Team.DrawHealthY:= drY;
+ Team^.DrawHealthY:= drY;
for i:= 0 to 7 do
- with Team.Hedgehogs[i] do
+ with Team^.Hedgehogs[i] do
if Gear <> nil then
- NameTag:= RenderString(Name, Team.Color, fnt16);
- Team:= Team.Next
+ NameTag:= RenderString(Name, Team^.Color, fnt16);
+ Team:= Team^.Next
end;
end;
@@ -166,19 +170,19 @@
s: string;
begin
s:= Pathz[ptGraphics] + '/' + cCHFileName;
- tmpsurf:= LoadImage(PChar(s), true, true, false);
+ tmpsurf:= LoadImage(s, true, true, false);
Team:= TeamsList;
while Team<>nil do
begin
- Team.CrosshairSurf:= SDL_CreateRGBSurface(SDL_HWSURFACE, tmpsurf.w, tmpsurf.h, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, PixelFormat.AMask);
- TryDo(Team.CrosshairSurf <> nil, errmsgCreateSurface, true);
- SDL_FillRect(Team.CrosshairSurf, nil, Team.AdjColor);
- SDL_UpperBlit(tmpsurf, nil, Team.CrosshairSurf, nil);
- TryDo(SDL_SetColorKey(Team.CrosshairSurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
- Team:= Team.Next
+ Team^.CrosshairSurf:= SDL_CreateRGBSurface(SDL_HWSURFACE, tmpsurf^.w, tmpsurf^.h, cBits, PixelFormat^.RMask, PixelFormat^.GMask, PixelFormat^.BMask, PixelFormat^.AMask);
+ TryDo(Team^.CrosshairSurf <> nil, errmsgCreateSurface, true);
+ SDL_FillRect(Team^.CrosshairSurf, nil, Team^.AdjColor);
+ SDL_UpperBlit(tmpsurf, nil, Team^.CrosshairSurf, nil);
+ TryDo(SDL_SetColorKey(Team^.CrosshairSurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
+ Team:= Team^.Next
end;
-
+
SDL_FreeSurface(tmpsurf)
end;
@@ -190,9 +194,9 @@
while p <> nil do
begin
for i:= 0 to cMaxHHIndex do
- if p.Hedgehogs[i].Gear <> nil then
- RenderHealth(p.Hedgehogs[i]);
- p:= p.Next
+ if p^.Hedgehogs[i].Gear <> nil then
+ RenderHealth(p^.Hedgehogs[i]);
+ p:= p^.Next
end
end;
@@ -205,13 +209,13 @@
while p <> nil do
begin
dec(l, 32);
- if p.GraveName = '' then p.GraveName:= 'Simple';
- LoadToSurface(Pathz[ptGraves] + '/' + p.GraveName, StoreSurface, l, 512);
- p.GraveRect.x:= l;
- p.GraveRect.y:= 512;
- p.GraveRect.w:= 32;
- p.GraveRect.h:= 256;
- p:= p.Next
+ if p^.GraveName = '' then p^.GraveName:= 'Simple';
+ LoadToSurface(Pathz[ptGraves] + '/' + p^.GraveName, StoreSurface, l, 512);
+ p^.GraveRect.x:= l;
+ p^.GraveRect.y:= 512;
+ p^.GraveRect.w:= 32;
+ p^.GraveRect.h:= 256;
+ p:= p^.Next
end
end;
@@ -220,8 +224,8 @@
begin
if SDL_MustLock(SpritesData[sprSky].Surface) then
SDLTry(SDL_LockSurface(SpritesData[sprSky].Surface) >= 0, true);
- p:= SpritesData[sprSky].Surface.pixels;
- case SpritesData[sprSky].Surface.format.BytesPerPixel of
+ p:= SpritesData[sprSky].Surface^.pixels;
+ case SpritesData[sprSky].Surface^.format^.BytesPerPixel of
1: cSkyColor:= PByte(p)^;
2: cSkyColor:= PWord(p)^;
3: cSkyColor:= (p^[0]) or (p^[1] shl 8) or (p^[2] shl 16);
@@ -237,11 +241,11 @@
begin
s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
WriteToConsole(msgLoading + s + ' ');
- AssignFile(f, s);
+ Assign(f, s);
{$I-}
Reset(f);
Readln(f, s);
- Closefile(f);
+ Close(f);
{$I+}
TryDo(IOResult = 0, msgFailed, true);
WriteLnToConsole(msgOK);
@@ -249,13 +253,16 @@
AdjustColor(cExplosionBorderColor);
end;
+var ps: array[byte] of char;
+
begin
for fi:= Low(THWFont) to High(THWFont) do
with Fontz[fi] do
begin
s:= Pathz[ptFonts] + '/' + Name;
WriteToConsole(msgLoading + s + '... ');
- Handle:= TTF_OpenFont(PChar(s), Height);
+ ps:= s;
+ Handle:= TTF_OpenFont(@ps, Height);
SDLTry(Handle <> nil, true);
TTF_SetFontStyle(Handle, style);
WriteLnToConsole(msgOK)
@@ -289,20 +296,20 @@
with SpritesData[ii] do
begin
if AltPath = ptNone then
- Surface:= LoadImage(Pathz[Path] + '/' + FileName, hasAlpha)
+ Surface:= LoadImage(Pathz[Path] + '/' + FileName, hasAlpha, true, true)
else begin
- Surface:= LoadImage(Pathz[Path] + '/' + FileName, hasAlpha, false);
+ Surface:= LoadImage(Pathz[Path] + '/' + FileName, hasAlpha, false, true);
if Surface = nil then
- Surface:= LoadImage(Pathz[AltPath] + '/' + FileName, hasAlpha)
+ Surface:= LoadImage(Pathz[AltPath] + '/' + FileName, hasAlpha, true, true)
end;
- if Width = 0 then Width:= Surface.w;
- if Height = 0 then Height:= Surface.h
+ if Width = 0 then Width:= Surface^.w;
+ if Height = 0 then Height:= Surface^.h
end;
GetSkyColor;
AddProgress;
-tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, false);
+tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, false, true, true);
TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
HHSurface:= SDL_DisplayFormat(tmpsurf);
SDL_FreeSurface(tmpsurf);
@@ -322,8 +329,8 @@
begin
rr.x:= X;
rr.y:= Y;
-rr.w:= r.w;
-rr.h:= r.h;
+rr.w:= r^.w;
+rr.h:= r^.h;
if SDL_UpperBlit(SourceSurface, r, DestSurface, @rr) < 0 then
begin
OutError('Blit: ' + SDL_GetError, true);
@@ -362,7 +369,7 @@
var r: TSDL_Rect;
begin
r.x:= 0;
-r.w:= Source.w;
+r.w:= Source^.w;
r.y:= Frame * Height;
r.h:= Height;
DrawFromRect(X, Y, @r, Source, Surface)
@@ -372,13 +379,15 @@
var clr: TSDL_Color;
tmpsurf: PSDL_Surface;
r: TSDL_Rect;
+ ps: array[byte] of Char;
begin
r.x:= X;
r.y:= Y;
clr.r:= $FF;
clr.g:= $FF;
clr.b:= $FF;
-tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, PChar(s), clr.value);
+ps:= s;
+tmpsurf:= TTF_RenderUTF8_Solid(Fontz[Font].Handle, @ps, clr.value);
if tmpsurf = nil then
begin
SetKB(1);
@@ -407,10 +416,10 @@
procedure DrawCentered(X, Top: integer; Source, Surface: PSDL_Surface);
var r: TSDL_Rect;
begin
-r.x:= X - Source.w div 2;
+r.x:= X - Source^.w div 2;
r.y:= Top;
-r.w:= Source.w;
-r.h:= Source.h;
+r.w:= Source^.w;
+r.h:= Source^.h;
SDL_UpperBlit(Source, nil, Surface, @r)
end;
@@ -419,7 +428,7 @@
begin
r.x:= Step * 32;
r.y:= Pos * 32;
-if Dir = -1 then r.x:= HHSurface.w - 32 - r.x;
+if Dir = -1 then r.x:= HHSurface^.w - 32 - r.x;
r.w:= 32;
r.h:= 32;
DrawFromRect(X, Y, @r, HHSurface, Surface)
@@ -435,21 +444,25 @@
SDL_FreeSurface(StoreSurface )
end;
-function RenderString(s: string; Color: integer; font: THWFont): PSDL_Surface;
-var w, h: integer;
+function RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface;
+var w, h: Longint;
+ ps: array[byte] of Char;
+ Result: PSDL_Surface;
begin
-TTF_SizeUTF8(Fontz[font].Handle, PChar(s), w, h);
+ps:= s;
+TTF_SizeUTF8(Fontz[font].Handle, @ps, w, h);
Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + FontBorder * 2 + 4, h + FontBorder * 2,
- cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, PixelFormat.AMask);
+ cBits, PixelFormat^.RMask, PixelFormat^.GMask, PixelFormat^.BMask, PixelFormat^.AMask);
TryDo(Result <> nil, 'RenderString: fail to create surface', true);
WriteInRoundRect(Result, 0, 0, Color, font, s);
-TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true)
+TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
+RenderString:= Result
end;
procedure RenderHealth(var Hedgehog: THedgehog);
var s: shortstring;
begin
-str(Hedgehog.Gear.Health, s);
+str(Hedgehog.Gear^.Health, s);
if Hedgehog.HealthTag <> nil then SDL_FreeSurface(Hedgehog.HealthTag);
Hedgehog.HealthTag:= RenderString(s, Hedgehog.Team^.Color, fnt16)
end;
@@ -463,7 +476,7 @@
if Step = 0 then
begin
WriteToConsole(msgLoading + 'progress sprite: ');
- ProgrSurf:= LoadImage(Pathz[ptGraphics] + '/BigDigits', false);
+ ProgrSurf:= LoadImage(Pathz[ptGraphics] + '/BigDigits', false, true, true);
end;
SDL_FillRect(SDLPrimSurface, nil, 0);
r.x:= 0;
@@ -480,26 +493,33 @@
end;
end;
-function LoadImage(filename: string; hasAlpha: boolean; const critical: boolean = true; const setTransparent: boolean = true): PSDL_Surface;
+function LoadImage(filename: string; hasAlpha: boolean; critical, setTransparent: boolean): PSDL_Surface;
var tmpsurf: PSDL_Surface;
+ ps: array[byte] of char;
+ Result: PSDL_Surface;
begin
WriteToConsole(msgLoading + filename + '... ');
-tmpsurf:= IMG_Load(PChar(filename + '.' + cBitsStr + '.png'));
+ps:= filename + '.' + cBitsStr + '.png';
+tmpsurf:= IMG_Load(@ps);
+
if tmpsurf = nil then
- tmpsurf:= IMG_Load(PChar(filename + '.png'));
+ begin
+ ps:= filename + '.png';
+ tmpsurf:= IMG_Load(ps);
+ end;
if tmpsurf = nil then
if critical then OutError(msgFailed, true)
else begin
WriteLnToConsole(msgFailed);
- Result:= nil;
- exit
+ exit(nil)
end;
-
+
if setTransparent then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf)
else Result:= SDL_DisplayFormat(tmpsurf);
-WriteLnToConsole(msgOK)
+WriteLnToConsole(msgOK);
+LoadImage:= Result
end;
end.
--- a/hedgewars/uTeams.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uTeams.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,7 +18,7 @@
unit uTeams;
interface
-uses SDLh, uConsts, uKeys, uGears, uRandom, uAmmos;
+uses SDLh, uConsts, uKeys, uGears, uRandom, uAmmos, uFloat;
{$INCLUDE options.inc}
type PHedgehog = ^THedgehog;
PTeam = ^TTeam;
@@ -83,22 +83,21 @@
AliveCount: Longword;
s: shortstring;
begin
-Result:= false;
AliveCount:= 0;
AliveTeam:= nil;
team:= TeamsList;
while team <> nil do
begin
- if team.TeamHealth > 0 then
+ if team^.TeamHealth > 0 then
begin
inc(AliveCount);
AliveTeam:= team
end;
- team:= team.Next
+ team:= team^.Next
end;
-if AliveCount >= 2 then exit;
-Result:= true;
+if AliveCount >= 2 then exit(false);
+CheckForWin:= true;
TurnTimeLeft:= 0;
if AliveCount = 0 then
@@ -108,7 +107,7 @@
AddGear(0, 0, gtATFinishGame, 0, 0, 0, 2000)
end else // win
begin
- s:= Format(trmsg[sidWinner], AliveTeam.TeamName);
+ s:= Format(trmsg[sidWinner], AliveTeam^.TeamName);
AddCaption(s, $FFFFFF, capgrpGameState);
SendStat(siGameResult, s);
AddGear(0, 0, gtATFinishGame, 0, 0, 0, 2000)
@@ -119,30 +118,31 @@
procedure SwitchHedgehog;
var tteam: PTeam;
th: integer;
+ g: PGear;
begin
FreeActionsList;
TargetPoint.X:= NoPointX;
TryDo(CurrentTeam <> nil, 'nil Team', true);
tteam:= CurrentTeam;
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
if Gear <> nil then
begin
- Gear.Message:= 0;
- Gear.Z:= cHHZ
+ Gear^.Message:= 0;
+ Gear^.Z:= cHHZ
end;
repeat
- CurrentTeam:= CurrentTeam.Next;
+ CurrentTeam:= CurrentTeam^.Next;
if CurrentTeam = nil then CurrentTeam:= TeamsList;
- th:= CurrentTeam.CurrHedgehog;
+ th:= CurrentTeam^.CurrHedgehog;
repeat
- CurrentTeam.CurrHedgehog:= Succ(CurrentTeam.CurrHedgehog) mod (cMaxHHIndex + 1);
- until (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear <> nil) or (CurrentTeam.CurrHedgehog = th)
-until (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear <> nil) or (CurrentTeam = tteam);
+ CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (cMaxHHIndex + 1);
+ until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (CurrentTeam^.CurrHedgehog = th)
+until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (CurrentTeam = tteam);
TryDo(CurrentTeam <> tteam, 'Switch hedgehog: only one team?!', true);
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
begin
AttacksNum:= 0;
with Gear^ do
@@ -156,29 +156,35 @@
FollowGear:= Gear
end;
ResetKbd;
-cWindSpeed:= (GetRandom * 2 - 1) * cMaxWindSpeed;
-AddGear(0, 0, gtATSmoothWindCh, 0, 0, 0, 1).Tag:= round(72 * cWindSpeed / cMaxWindSpeed);
+
+cWindSpeed:= rndSign(GetRandom * cMaxWindSpeed);
+addfilelog('SwitchHedgehog 06');
+g:= AddGear(0, 0, gtATSmoothWindCh, 0, 0, 0, 1);
+g^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed);
+addfilelog('SwitchHedgehog 07');
{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF}
-ApplyAmmoChanges(CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog]);
-if CurrentTeam.ExtDriven then SetDefaultBinds
- else SetBinds(CurrentTeam.Binds);
+ApplyAmmoChanges(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
+if CurrentTeam^.ExtDriven then SetDefaultBinds
+ else SetBinds(CurrentTeam^.Binds);
bShowFinger:= true;
TurnTimeLeft:= cHedgehogTurnTime
end;
function AddTeam: PTeam;
+var Result: PTeam;
begin
New(Result);
TryDo(Result <> nil, 'AddTeam: Result = nil', true);
FillChar(Result^, sizeof(TTeam), 0);
-Result.AttackBar:= 2;
-Result.CurrHedgehog:= cMaxHHIndex;
+Result^.AttackBar:= 2;
+Result^.CurrHedgehog:= cMaxHHIndex;
if TeamsList = nil then TeamsList:= Result
else begin
- Result.Next:= TeamsList;
+ Result^.Next:= TeamsList;
TeamsList:= Result
end;
-CurrentTeam:= Result
+CurrentTeam:= Result;
+AddTeam:= Result
end;
procedure FreeTeamsList;
@@ -186,10 +192,10 @@
begin
tt:= TeamsList;
TeamsList:= nil;
-while tt<>nil do
+while tt <> nil do
begin
t:= tt;
- tt:= tt.Next;
+ tt:= tt^.Next;
Dispose(t)
end;
end;
@@ -201,7 +207,7 @@
while p <> nil do
begin
RecountTeamHealth(p);
- p:= p.Next
+ p:= p^.Next
end
end;
@@ -215,10 +221,10 @@
begin
th:= 0;
for i:= 0 to cMaxHHIndex do
- if p.Hedgehogs[i].Gear <> nil then
- inc(th, p.Hedgehogs[i].Gear.Health);
+ if p^.Hedgehogs[i].Gear <> nil then
+ inc(th, p^.Hedgehogs[i].Gear^.Health);
if th > MaxTeamHealth then MaxTeamHealth:= th;
- p:= p.Next
+ p:= p^.Next
end;
RecountAllTeamsHealth
end;
@@ -230,14 +236,14 @@
with Hedgehog do
begin
- if Ammo[CurSlot, CurAmmo].Count = 0 then
+ if Ammo^[CurSlot, CurAmmo].Count = 0 then
begin
CurAmmo:= 0;
CurSlot:= 0;
- while (CurSlot <= cMaxSlotIndex) and (Ammo[CurSlot, CurAmmo].Count = 0) do inc(CurSlot)
+ while (CurSlot <= cMaxSlotIndex) and (Ammo^[CurSlot, CurAmmo].Count = 0) do inc(CurSlot)
end;
-with Ammo[CurSlot, CurAmmo] do
+with Ammo^[CurSlot, CurAmmo] do
begin
CurMinAngle:= Ammoz[AmmoType].minAngle;
if Ammoz[AmmoType].maxAngle <> 0 then CurMaxAngle:= Ammoz[AmmoType].maxAngle
@@ -247,19 +253,19 @@
if Angle < CurMinAngle then Angle:= CurMinAngle;
if Angle > CurMaxAngle then Angle:= CurMaxAngle;
end;
-
+
s:= trammo[Ammoz[AmmoType].NameId];
if Count <> AMMO_INFINITE then
s:= s + ' (' + IntToStr(Count) + ')';
if (Propz and ammoprop_Timerable) <> 0 then
s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds];
- AddCaption(s, Team.Color, capgrpAmmoinfo);
+ AddCaption(s, Team^.Color, capgrpAmmoinfo);
if (Propz and ammoprop_NeedTarget) <> 0
then begin
- Gear.State:= Gear.State or gstHHChooseTarget;
+ Gear^.State:= Gear^.State or gstHHChooseTarget;
isCursorVisible:= true
end else begin
- Gear.State:= Gear.State and not gstHHChooseTarget;
+ Gear^.State:= Gear^.State and not gstHHChooseTarget;
isCursorVisible:= false
end;
ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0
@@ -268,11 +274,12 @@
end;
function TeamSize(p: PTeam): Longword;
-var i: Longword;
+var i, Result: Longword;
begin
Result:= 0;
for i:= 0 to cMaxHHIndex do
- if p.Hedgehogs[i].Gear <> nil then inc(Result)
+ if p^.Hedgehogs[i].Gear <> nil then inc(Result);
+TeamSize:= Result
end;
procedure RecountTeamHealth(team: PTeam);
@@ -283,7 +290,7 @@
TeamHealthBarWidth:= 0;
for i:= 0 to cMaxHHIndex do
if Hedgehogs[i].Gear <> nil then
- inc(TeamHealthBarWidth, Hedgehogs[i].Gear.Health);
+ inc(TeamHealthBarWidth, Hedgehogs[i].Gear^.Health);
TeamHealth:= TeamHealthBarWidth;
if TeamHealthBarWidth > MaxTeamHealth then
begin
@@ -292,7 +299,7 @@
end else TeamHealthBarWidth:= (TeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth
end;
// FIXME: at the game init, gtTeamHealthSorters are created for each team, and they work simultaneously
-AddGear(0, 0, gtTeamHealthSorter, 0)
+AddGear(0, 0, gtTeamHealthSorter, 0, 0, 0, 0)
end;
procedure RestoreTeamsFromSave;
@@ -301,8 +308,8 @@
p:= TeamsList;
while p <> nil do
begin
- p.ExtDriven:= false;
- p:= p.Next
+ p^.ExtDriven:= false;
+ p:= p^.Next
end;
end;
@@ -312,9 +319,9 @@
t:= cMaxSlotAmmoIndex;
with CurrentTeam^ do
with Hedgehogs[CurrHedgehog] do
- while (Ammo[CurSlot, CurAmmo].AmmoType <> weap) and (t >= 0) do
+ while (Ammo^[CurSlot, CurAmmo].AmmoType <> weap) and (t >= 0) do
begin
- ParseCommand('/slot ' + chr(49 + Ammoz[TAmmoType(weap)].Slot));
+ ParseCommand('/slot ' + chr(49 + Ammoz[TAmmoType(weap)].Slot), true);
dec(t)
end
end;
@@ -329,15 +336,15 @@
while p <> nil do
begin
for i:= 0 to cMaxHHIndex do
- if p.Hedgehogs[i].MaxStepDamage > msd then
+ if p^.Hedgehogs[i].MaxStepDamage > msd then
begin
- msdhh:= @p.Hedgehogs[i];
- msd:= p.Hedgehogs[i].MaxStepDamage
+ msdhh:= @(p^.Hedgehogs[i]);
+ msd:= p^.Hedgehogs[i].MaxStepDamage
end;
- p:= p.Next
+ p:= p^.Next
end;
-if msdhh <> nil then SendStat(siMaxStepDamage, inttostr(msdhh.MaxStepDamage) + ' ' +
- msdhh.Name + ' (' + msdhh.Team.TeamName + ')');
+if msdhh <> nil then SendStat(siMaxStepDamage, inttostr(msdhh^.MaxStepDamage) + ' ' +
+ msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')');
if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs));
end;
--- a/hedgewars/uWorld.pas Thu Jan 18 20:29:28 2007 +0000
+++ b/hedgewars/uWorld.pas Sun Jan 21 19:51:02 2007 +0000
@@ -18,7 +18,7 @@
unit uWorld;
interface
-uses SDLh, uGears, uConsts;
+uses SDLh, uGears, uConsts, uFloat;
{$INCLUDE options.inc}
const WorldDx: integer = -512;
WorldDy: integer = -256;
@@ -39,7 +39,7 @@
implementation
uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound;
-const RealTicks: Longword = 0;
+const hwFloatTicks: Longword = 0;
FPS: Longword = 0;
CountTicks: Longword = 0;
SoundTimerTicks: Longword = 0;
@@ -93,7 +93,7 @@
if CurrentTeam = nil then exit;
Slot:= 0;
Pos:= -1;
-with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
begin
if Ammo = nil then exit;
SlotsNum:= 0;
@@ -106,7 +106,7 @@
dec(y, 33);
DrawSprite(sprAMSlotName, x, y, 0, Surface);
for i:= cMaxSlotIndex downto 0 do
- if Ammo[i, 0].Count > 0 then
+ if Ammo^[i, 0].Count > 0 then
begin
if (CursorPoint.Y >= y - 33) and (CursorPoint.Y < y) then Slot:= i;
dec(y, 33);
@@ -114,9 +114,9 @@
DrawSprite(sprAMSlot, x, y, 0, Surface);
DrawSprite(sprAMSlotKeys, x + 2, y + 1, i, Surface);
t:= 0;
- while (t <= cMaxSlotAmmoIndex) and (Ammo[i, t].Count > 0) do
+ while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
begin
- DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, integer(Ammo[i, t].AmmoType), Surface);
+ DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, integer(Ammo^[i, t].AmmoType), Surface);
if (Slot = i) and (CursorPoint.X >= x + t * 33 + 35) and (CursorPoint.X < x + t * 33 + 68) then
begin
DrawSprite(sprAMSelection, x + t * 33 + 35, y + 1, 0, Surface);
@@ -129,15 +129,15 @@
DrawSprite(sprAMBorders, x, y, 0, Surface);
if (Pos >= 0) then
- if Ammo[Slot, Pos].Count > 0 then
+ if Ammo^[Slot, Pos].Count > 0 then
begin
- DXOutText(AMxCurr + 10, cScreenHeight - 68, fnt16, trAmmo[Ammoz[Ammo[Slot, Pos].AmmoType].NameId], Surface);
- if Ammo[Slot, Pos].Count < 10 then
- DXOutText(AMxCurr + 175, cScreenHeight - 68, fnt16, chr(Ammo[Slot, Pos].Count + 48) + 'x', Surface);
+ DXOutText(AMxCurr + 10, cScreenHeight - 68, fnt16, trAmmo[Ammoz[Ammo^[Slot, Pos].AmmoType].NameId], Surface);
+ if Ammo^[Slot, Pos].Count < 10 then
+ DXOutText(AMxCurr + 175, cScreenHeight - 68, fnt16, chr(Ammo^[Slot, Pos].Count + 48) + 'x', Surface);
if bSelected then
begin
bShowAmmoMenu:= false;
- SetWeapon(Ammo[Slot, Pos].AmmoType);
+ SetWeapon(Ammo^[Slot, Pos].AmmoType);
bSelected:= false;
exit
end;
@@ -145,7 +145,7 @@
end;
bSelected:= false;
-if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface)
+if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (hwFloatTicks shr 6) mod 8, Surface)
end;
procedure MoveCamera; forward;
@@ -174,7 +174,7 @@
if not isPaused then MoveCamera;
// Sky
-inc(RealTicks, Lag);
+inc(hwFloatTicks, Lag);
if WorldDy > 0 then
begin
if WorldDy > cScreenHeight then r.h:= cScreenHeight
@@ -190,8 +190,8 @@
// Waves
{$WARNINGS OFF}
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) ) and $FF), cWaterLine + WorldDy - 64, 0, Surface);
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx - (RealTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 48, 0, Surface);
+for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (hwFloatTicks shr 6) ) and $FF), cWaterLine + WorldDy - 64, 0, Surface);
+for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx - (hwFloatTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 48, 0, Surface);
{$WARNINGS ON}
DrawLand(WorldDx, WorldDy, Surface);
@@ -210,9 +210,9 @@
// Waves
{$WARNINGS OFF}
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) + 64) and $FF), cWaterLine + WorldDy - 32, 0, Surface);
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface);
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (RealTicks shr 6) ) and $FF), cWaterLine + WorldDy , 0, Surface);
+for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (hwFloatTicks shr 6) + 64) and $FF), cWaterLine + WorldDy - 32, 0, Surface);
+for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx - (hwFloatTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface);
+for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 256 + ((WorldDx + (hwFloatTicks shr 6) ) and $FF), cWaterLine + WorldDy , 0, Surface);
{$WARNINGS ON}
// Turn time
@@ -238,17 +238,17 @@
1: begin
r:= StuffPoz[sPowerBar];
{$WARNINGS OFF}
- r.w:= (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear.Power * 256) div cPowerDivisor;
+ r.w:= (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^.Power * 256) div cPowerDivisor;
{$WARNINGS ON}
DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
end;
- 2: with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+ 2: with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
begin
- tdx:= hwSign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle);
- tdy:= - Cos(Gear.Angle*pi/cMaxAngle);
- for i:= (Gear.Power * 24) div cPowerDivisor downto 0 do
- DrawSprite(sprPower, round(Gear.X + WorldDx + tdx * (24 + i * 2)) - 16,
- round(Gear.Y + WorldDy + tdy * (24 + i * 2)) - 12,
+ tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
+ tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
+ for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
+ DrawSprite(sprPower, Gear^.X.Round + system.round(WorldDx + tdx * (24 + i * 2)) - 16,
+ Gear^.Y.Round + system.round(WorldDy + tdy * (24 + i * 2)) - 12,
i, Surface)
end
end;
@@ -263,8 +263,8 @@
if Surf <> nil then
begin
DrawCentered(cScreenWidth div 2, i + cConsoleYAdd, Surf, Surface);
- inc(i, Surf.h + 2);
- if EndTime <= RealTicks then
+ inc(i, Surf^.h + 2);
+ if EndTime <= hwFloatTicks then
begin
SDL_FreeSurface(Surf);
Surf:= nil;
@@ -276,26 +276,26 @@
team:= TeamsList;
while team <> nil do
begin
- r.x:= cScreenWidth div 2 - team.NameTag.w - 3;
- r.y:= team.DrawHealthY;
- r.w:= team.NameTag.w;
- r.h:= team.NameTag.h;
- SDL_UpperBlit(team.NameTag, nil, Surface, @r);
- r:= team.HealthRect;
- r.w:= 2 + team.TeamHealthBarWidth;
+ r.x:= cScreenWidth div 2 - team^.NameTag^.w - 3;
+ r.y:= team^.DrawHealthY;
+ r.w:= team^.NameTag^.w;
+ r.h:= team^.NameTag^.h;
+ SDL_UpperBlit(team^.NameTag, nil, Surface, @r);
+ r:= team^.HealthRect;
+ r.w:= 2 + team^.TeamHealthBarWidth;
DrawFromStoreRect(cScreenWidth div 2,
- Team.DrawHealthY,
+ Team^.DrawHealthY,
@r, Surface);
inc(r.x, cTeamHealthWidth + 2);
r.w:= 3;
- DrawFromStoreRect(cScreenWidth div 2 + team.TeamHealthBarWidth + 2,
- Team.DrawHealthY,
+ DrawFromStoreRect(cScreenWidth div 2 + team^.TeamHealthBarWidth + 2,
+ Team^.DrawHealthY,
@r, Surface);
- team:= team.Next
+ team:= team^.Next
end;
// Lag alert
-if isInLag then DrawSprite(sprLag, 32, 32 + cConsoleYAdd, (RealTicks shr 7) mod 7, Surface);
+if isInLag then DrawSprite(sprLag, 32, 32 + cConsoleYAdd, (hwFloatTicks shr 7) mod 7, Surface);
// Wind bar
DrawGear(sWindBar, cScreenWidth - 180, cScreenHeight - 30, Surface);
@@ -304,7 +304,7 @@
with StuffPoz[sWindR] do
begin
{$WARNINGS OFF}
- r.x:= x + 8 - (RealTicks shr 6) mod 8;
+ r.x:= x + 8 - (hwFloatTicks shr 6) mod 8;
{$WARNINGS ON}
r.y:= y;
r.w:= WindBarWidth;
@@ -317,7 +317,7 @@
with StuffPoz[sWindL] do
begin
{$WARNINGS OFF}
- r.x:= x + (WindBarWidth + RealTicks shr 6) mod 8;
+ r.x:= x + (WindBarWidth + hwFloatTicks shr 6) mod 8;
{$WARNINGS ON}
r.y:= y;
r.w:= - WindBarWidth;
@@ -330,7 +330,7 @@
if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu(Surface);
// Cursor
-if isCursorVisible then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface);
+if isCursorVisible then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (hwFloatTicks shr 6) mod 8, Surface);
{$IFDEF COUNTTICKS}
DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);
@@ -349,7 +349,7 @@
CountTicks:= 0;
s:= inttostr(FPS) + ' fps';
if fpsSurface <> nil then SDL_FreeSurface(fpsSurface);
- fpsSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, PChar(String(s)), $FFFFFF);
+ fpsSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
end;
r.x:= cScreenWidth - 50;
r.y:= 10;
@@ -374,14 +374,14 @@
if Captions[Group].Surf <> nil then SDL_FreeSurface(Captions[Group].Surf);
Captions[Group].Surf:= RenderString(s, Color, fntBig);
-Captions[Group].EndTime:= RealTicks + 1500
+Captions[Group].EndTime:= hwFloatTicks + 1500
end;
procedure MoveCamera;
const PrevSentPointTime: LongWord = 0;
var EdgesDist: integer;
begin
-if not (CurrentTeam.ExtDriven and isCursorVisible) then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
+if not (CurrentTeam^.ExtDriven and isCursorVisible) then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
if (FollowGear <> nil) then
if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
begin
@@ -389,8 +389,8 @@
exit
end
else begin
- CursorPoint.x:= (CursorPoint.x * 7 + (round(FollowGear.X + hwSign(FollowGear.dX) * 100) + WorldDx)) div 8;
- CursorPoint.y:= (CursorPoint.y * 7 + (round(FollowGear.Y) + WorldDy)) div 8
+ CursorPoint.x:= (CursorPoint.x * 7 + (hwRound(FollowGear^.X + hwSign(FollowGear^.dX) * 100) + WorldDx)) div 8;
+ CursorPoint.y:= (CursorPoint.y * 7 + (hwRound(FollowGear^.Y) + WorldDy)) div 8
end;
if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit;
@@ -408,13 +408,13 @@
if isCursorVisible then
begin
- if (not CurrentTeam.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then
+ if (not CurrentTeam^.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then
begin
SendIPCXY('P', CursorPoint.X - WorldDx, CursorPoint.Y - WorldDy);
PrevSentPointTime:= GameTicks
end;
end;
-
+
if isCursorVisible or (FollowGear <> nil) then
begin
if isCursorVisible then EdgesDist:= cCursorEdgesDist
@@ -447,7 +447,7 @@
CursorPoint.X:= (cScreenWidth shr 1);
CursorPoint.Y:= (cScreenHeight shr 1);
end;
-
+
if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
prevPoint:= CursorPoint;
if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater;