--- a/hedgewars/uConsts.pas Sat Dec 09 19:47:31 2006 +0000
+++ b/hedgewars/uConsts.pas Sun Dec 10 12:09:32 2006 +0000
@@ -108,13 +108,13 @@
cMaxHHIndex = 7;
cMaxHHs = 20;
cMaxSpawnPoints = 1024;
- cHHSurfaceWidth = 512;
- // cHHSurfaceHeigth = 256;
cMaxEdgePoints = 16384;
cHHRadius = 9;
cHHStepTicks = 38;
+ cHHZ = 1000;
+ cCurrHHZ = Succ(cHHZ);
cKeyMaxIndex = 1023;
--- a/hedgewars/uGears.pas Sat Dec 09 19:47:31 2006 +0000
+++ b/hedgewars/uGears.pas Sun Dec 10 12:09:32 2006 +0000
@@ -59,6 +59,8 @@
procedure AddMiscGears;
procedure AddClouds;
procedure AssignHHCoords;
+procedure InsertGearToList(Gear: PGear);
+procedure RemoveGearFromList(Gear: PGear);
var CurAmmoGear: PGear = nil;
GearsList: PGear = nil;
@@ -119,9 +121,37 @@
doStepAirBomb
);
+procedure InsertGearToList(Gear: PGear);
+var tmp: PGear;
+begin
+if GearsList = nil then
+ GearsList:= Gear
+ 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;
+
+ 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
+ else begin
+ 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;
const Counter: Longword = 0;
-var tmp: PGear;
begin
inc(Counter);
{$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF}
@@ -152,7 +182,7 @@
Result.Elasticity:= 0.35;
Result.Friction:= 0.999;
Result.Angle:= cMaxAngle div 2;
- Result.Z:= 1000;
+ Result.Z:= cHHZ;
end;
gtAmmo_Grenade: begin
Result.Radius:= 4;
@@ -233,20 +263,7 @@
Result.Radius:= 10;
end;
end;
-
-if GearsList = nil then GearsList:= Result
- 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 < Result.Z) do
- tmp:= tmp.NextGear;
-
- if tmp.PrevGear <> nil then tmp.PrevGear.NextGear:= Result;
- Result.PrevGear:= tmp.PrevGear;
- tmp.PrevGear:= Result;
- Result.NextGear:= tmp;
- if GearsList = tmp then GearsList:= Result
- end
+InsertGearToList(Result)
end;
procedure DeleteGear(Gear: PGear);
@@ -274,12 +291,7 @@
{$IFDEF DEBUGFILE}AddFileLog('DeleteGear: handle = '+inttostr(integer(Gear)));{$ENDIF}
if CurAmmoGear = Gear then CurAmmoGear:= nil;
if FollowGear = Gear then FollowGear:= nil;
-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
- end;
+RemoveGearFromList(Gear);
Dispose(Gear)
end;
--- a/hedgewars/uStore.pas Sat Dec 09 19:47:31 2006 +0000
+++ b/hedgewars/uStore.pas Sun Dec 10 12:09:32 2006 +0000
@@ -419,7 +419,7 @@
begin
r.x:= Step * 32;
r.y:= Pos * 32;
-if Dir = -1 then r.x:= cHHSurfaceWidth - 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)
--- a/hedgewars/uTeams.pas Sat Dec 09 19:47:31 2006 +0000
+++ b/hedgewars/uTeams.pas Sun Dec 10 12:09:32 2006 +0000
@@ -118,7 +118,11 @@
TryDo(CurrentTeam <> nil, 'nil Team', true);
tteam:= CurrentTeam;
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
- if Gear <> nil then Gear.Message:= 0;
+ if Gear <> nil then
+ begin
+ Gear.Message:= 0;
+ Gear.Z:= cHHZ
+ end;
repeat
CurrentTeam:= CurrentTeam.Next;
@@ -136,9 +140,12 @@
AttacksNum:= 0;
with Gear^ do
begin
+ Z:= cCurrHHZ;
State:= gstHHDriven;
Active:= true
end;
+ RemoveGearFromList(Gear);
+ InsertGearToList(Gear);
FollowGear:= Gear
end;
ResetKbd;