25 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
25 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
26 procedure DeleteGear(Gear: PGear); |
26 procedure DeleteGear(Gear: PGear); |
27 procedure InsertGearToList(Gear: PGear); |
27 procedure InsertGearToList(Gear: PGear); |
28 procedure RemoveGearFromList(Gear: PGear); |
28 procedure RemoveGearFromList(Gear: PGear); |
29 |
29 |
|
30 var curHandledGear: PGear; |
|
31 |
30 implementation |
32 implementation |
31 |
33 |
32 uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats, |
34 uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats, |
33 uTextures, uScript, uRenderUtils, uAI, uCollisions, |
35 uTextures, uScript, uRenderUtils, uAI, uCollisions, |
34 uGearsRender, uGearsUtils; |
36 uGearsRender, uGearsUtils, uDebug; |
35 |
37 |
36 var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless |
38 var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless |
37 |
39 |
38 procedure InsertGearToList(Gear: PGear); |
40 procedure InsertGearToList(Gear: PGear); |
39 var tmp, ptmp: PGear; |
41 var tmp, ptmp: PGear; |
61 Gear^.NextGear^.PrevGear:= Gear; |
63 Gear^.NextGear^.PrevGear:= Gear; |
62 GearsList:= Gear; |
64 GearsList:= Gear; |
63 end; |
65 end; |
64 end; |
66 end; |
65 |
67 |
|
68 |
66 procedure RemoveGearFromList(Gear: PGear); |
69 procedure RemoveGearFromList(Gear: PGear); |
67 begin |
70 begin |
|
71 TryDo((curHandledGear = nil) or (Gear = curHandledGear), 'You''re doing it wrong', true); |
|
72 |
68 if Gear^.NextGear <> nil then |
73 if Gear^.NextGear <> nil then |
69 Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
74 Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
70 if Gear^.PrevGear <> nil then |
75 if Gear^.PrevGear <> nil then |
71 Gear^.PrevGear^.NextGear:= Gear^.NextGear |
76 Gear^.PrevGear^.NextGear:= Gear^.NextGear |
72 else |
77 else |
73 GearsList:= Gear^.NextGear |
78 GearsList:= Gear^.NextGear |
74 end; |
79 end; |
75 |
80 |
|
81 |
76 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
82 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
77 var gear: PGear; |
83 var gear: PGear; |
78 begin |
84 begin |
79 inc(GCounter); |
85 inc(GCounter); |
80 AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); |
86 AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); |