28 procedure ProcessBot; |
28 procedure ProcessBot; |
29 procedure FreeActionsList; |
29 procedure FreeActionsList; |
30 |
30 |
31 implementation |
31 implementation |
32 uses uConsts, SDLh, uAIMisc, uAIAmmoTests, uAIActions, |
32 uses uConsts, SDLh, uAIMisc, uAIAmmoTests, uAIActions, |
33 uAmmos, SysUtils{$IFDEF UNIX}, cthreads{$ENDIF}, uTypes, |
33 uAmmos, SysUtils{$IFDEF UNIX}{$IFNDEF ANDROID}, cthreads{$ENDIF}{$ENDIF}, uTypes, |
34 uVariables, uCommands, uUtils, uDebug; |
34 uVariables, uCommands, uUtils, uDebug; |
35 |
35 |
36 var BestActions: TActions; |
36 var BestActions: TActions; |
37 CanUseAmmo: array [TAmmoType] of boolean; |
37 CanUseAmmo: array [TAmmoType] of boolean; |
38 StopThinking: boolean; |
38 StopThinking: boolean; |
39 ThinkThread: TThreadID; |
39 ThinkThread: PSDL_Thread = nil; |
40 hasThread: LongInt; |
40 hasThread: LongInt; |
41 |
41 |
42 procedure FreeActionsList; |
42 procedure FreeActionsList; |
43 begin |
43 begin |
44 AddFileLog('FreeActionsList called'); |
44 AddFileLog('FreeActionsList called'); |
364 exit |
363 exit |
365 end; |
364 end; |
366 |
365 |
367 FillBonuses((Me^.State and gstAttacked) <> 0); |
366 FillBonuses((Me^.State and gstAttacked) <> 0); |
368 AddFileLog('Enter Think Thread'); |
367 AddFileLog('Enter Think Thread'); |
369 BeginThread(@Think, Me, ThinkThread) |
368 {$IFDEF IPHONEOS} |
|
369 //TODO: sdl_thread works on device but crashes in simulator, most likely because of outdated toolchain |
|
370 BeginThread(@Think, Me, ThinkThread); |
|
371 {$ELSE} |
|
372 ThinkThread := SDL_CreateThread(@Think{$IFDEF SDL13}, nil{$ENDIF}, Me); |
|
373 {$ENDIF} |
|
374 {$ENDIF} |
|
375 AddFileLog('Thread started'); |
370 end; |
376 end; |
371 |
377 |
372 procedure ProcessBot; |
378 procedure ProcessBot; |
373 const StartTicks: Longword = 0; |
379 const StartTicks: Longword = 0; |
374 cStopThinkTime = 40; |
380 cStopThinkTime = 40; |