hedgewars/uAI.pas
branchhedgeroid
changeset 6027 302408e45052
parent 6025 cac1d5601d7c
child 6328 d14adf1c7721
equal deleted inserted replaced
6025:cac1d5601d7c 6027:302408e45052
    72     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
    72     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
    73        begin
    73        begin
    74        with CurrentHedgehog^ do
    74        with CurrentHedgehog^ do
    75             a:= CurAmmoType;
    75             a:= CurAmmoType;
    76        aa:= a;
    76        aa:= a;
    77 SDL_delay(0);
    77        SDL_delay(0);    //ThreadSwitch was only a hint
    78 //       ThreadSwitch();
       
    79        
    78        
    80        repeat
    79        repeat
    81         if (CanUseAmmo[a]) and
    80         if (CanUseAmmo[a]) and
    82            ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0)) then
    81            ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0)) then
    83            begin
    82            begin
   318 
   317 
   319 FillBonuses((Me^.State and gstAttacked) <> 0);
   318 FillBonuses((Me^.State and gstAttacked) <> 0);
   320 for a:= Low(TAmmoType) to High(TAmmoType) do
   319 for a:= Low(TAmmoType) to High(TAmmoType) do
   321     CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and HHHasAmmo(Me^.Hedgehog^, a);
   320     CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and HHHasAmmo(Me^.Hedgehog^, a);
   322 AddFileLog('Enter Think Thread');
   321 AddFileLog('Enter Think Thread');
   323 //BeginThread(@Think, Me, ThinkThread)
   322 {$IFDEF IPHONEOS}
       
   323 //TODO: sdl_thread works on device but crashes in simulator, most likely because of outdated toolchain
       
   324 BeginThread(@Think, Me, ThinkThread);
       
   325 {$ELSE}
   324 ThinkThread := SDL_CreateThread(@Think, Me);
   326 ThinkThread := SDL_CreateThread(@Think, Me);
       
   327 {$ENDIF}
   325 AddFileLog('Thread started');
   328 AddFileLog('Thread started');
   326 end;
   329 end;
   327 
   330 
   328 procedure ProcessBot;
   331 procedure ProcessBot;
   329 const StartTicks: Longword = 0;
   332 const StartTicks: Longword = 0;