changeset 191 | a03c2d037e24 |
parent 188 | a7c2a61524c2 |
child 211 | 558476056205 |
190:206aabea2229 | 191:a03c2d037e24 |
---|---|
58 procedure AddMiscGears; |
58 procedure AddMiscGears; |
59 procedure AssignHHCoords; |
59 procedure AssignHHCoords; |
60 |
60 |
61 var CurAmmoGear: PGear = nil; |
61 var CurAmmoGear: PGear = nil; |
62 GearsList: PGear = nil; |
62 GearsList: PGear = nil; |
63 GearsListMutex: PSDL_mutex; |
|
64 |
63 |
65 implementation |
64 implementation |
66 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, |
65 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, |
67 uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI; |
66 uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI; |
68 var RopePoints: record |
67 var RopePoints: record |
220 gtFirePunch: begin |
219 gtFirePunch: begin |
221 Result.Radius:= 15; |
220 Result.Radius:= 15; |
222 Result.Tag:= Y |
221 Result.Tag:= Y |
223 end; |
222 end; |
224 end; |
223 end; |
225 SDL_LockMutex(GearsListMutex); |
|
226 if GearsList = nil then GearsList:= Result |
224 if GearsList = nil then GearsList:= Result |
227 else begin |
225 else begin |
228 GearsList.PrevGear:= Result; |
226 GearsList.PrevGear:= Result; |
229 Result.NextGear:= GearsList; |
227 Result.NextGear:= GearsList; |
230 GearsList:= Result |
228 GearsList:= Result |
231 end; |
229 end |
232 SDL_UnlockMutex(GearsListMutex) |
|
233 end; |
230 end; |
234 |
231 |
235 procedure DeleteGear(Gear: PGear); |
232 procedure DeleteGear(Gear: PGear); |
236 var team: PTeam; |
233 var team: PTeam; |
237 begin |
234 begin |
251 if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = Gear then |
248 if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = Gear then |
252 FreeActionsList; // to avoid ThinkThread on drawned gear |
249 FreeActionsList; // to avoid ThinkThread on drawned gear |
253 RecountTeamHealth(team); |
250 RecountTeamHealth(team); |
254 end; |
251 end; |
255 {$IFDEF DEBUGFILE}AddFileLog('DeleteGear: handle = '+inttostr(integer(Gear)));{$ENDIF} |
252 {$IFDEF DEBUGFILE}AddFileLog('DeleteGear: handle = '+inttostr(integer(Gear)));{$ENDIF} |
256 SDL_LockMutex(GearsListMutex); |
|
257 if CurAmmoGear = Gear then CurAmmoGear:= nil; |
253 if CurAmmoGear = Gear then CurAmmoGear:= nil; |
258 if FollowGear = Gear then FollowGear:= nil; |
254 if FollowGear = Gear then FollowGear:= nil; |
259 if Gear.NextGear <> nil then Gear.NextGear.PrevGear:= Gear.PrevGear; |
255 if Gear.NextGear <> nil then Gear.NextGear.PrevGear:= Gear.PrevGear; |
260 if Gear.PrevGear <> nil then Gear.PrevGear.NextGear:= Gear.NextGear |
256 if Gear.PrevGear <> nil then Gear.PrevGear.NextGear:= Gear.NextGear |
261 else begin |
257 else begin |
262 GearsList:= Gear^.NextGear; |
258 GearsList:= Gear^.NextGear; |
263 if GearsList <> nil then GearsList.PrevGear:= nil |
259 if GearsList <> nil then GearsList.PrevGear:= nil |
264 end; |
260 end; |
265 SDL_UnlockMutex(GearsListMutex); |
|
266 Dispose(Gear) |
261 Dispose(Gear) |
267 end; |
262 end; |
268 |
263 |
269 function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs |
264 function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs |
270 var Gear: PGear; |
265 var Gear: PGear; |
779 OutError('Couldn''t find place for Gear ' + inttostr(integer(Gear)), false); |
774 OutError('Couldn''t find place for Gear ' + inttostr(integer(Gear)), false); |
780 DeleteGear(Gear) |
775 DeleteGear(Gear) |
781 end; |
776 end; |
782 |
777 |
783 initialization |
778 initialization |
784 GearsListMutex:= SDL_CreateMutex; |
|
785 |
779 |
786 finalization |
780 finalization |
787 FreeGearsList; |
781 FreeGearsList; |
788 SDL_DestroyMutex(GearsListMutex); |
|
789 |
782 |
790 end. |
783 end. |