src/ai/api/ai_object.cpp
branchnoai
changeset 10978 13fd0364b2c6
parent 10977 6c1a6657c7db
child 11057 188a9ca6d8de
equal deleted inserted replaced
10977:6c1a6657c7db 10978:13fd0364b2c6
    95 }
    95 }
    96 
    96 
    97 void AIObject::SetLastCommandRes(bool res)
    97 void AIObject::SetLastCommandRes(bool res)
    98 {
    98 {
    99 	GetDoCommandStruct(_current_player)->last_command_res = res;
    99 	GetDoCommandStruct(_current_player)->last_command_res = res;
       
   100 	/* Also store the results of various global variables */
       
   101 	SetNewVehicleID(_new_vehicle_id);
       
   102 	SetNewSignID(_new_sign_id);
       
   103 	SetNewTunnelEndtile(_build_tunnel_endtile);
   100 }
   104 }
   101 
   105 
   102 bool AIObject::GetLastCommandRes()
   106 bool AIObject::GetLastCommandRes()
   103 {
   107 {
   104 	return GetDoCommandStruct(_current_player)->last_command_res;
   108 	return GetDoCommandStruct(_current_player)->last_command_res;
   225 	} else {
   229 	} else {
   226 #else
   230 #else
   227 	{
   231 	{
   228 #endif
   232 #endif
   229 		/* For SinglePlayer we execute the command immediatly */
   233 		/* For SinglePlayer we execute the command immediatly */
   230 		::DoCommandP(tile, p1, p2, NULL, procc);
   234 		if (!::DoCommandP(tile, p1, p2, NULL, procc)) res = CMD_ERROR;
   231 		/* Store some values inside the AIObject static memory */
   235 		SetLastCommandRes(!CmdFailed(res));
   232 		SetNewVehicleID(_new_vehicle_id);
       
   233 		SetNewSignID(_new_sign_id);
       
   234 		SetNewTunnelEndtile(_build_tunnel_endtile);
       
   235 
   236 
   236 		/* Suspend the AI player for 1 tick, so it simulates MultiPlayer */
   237 		/* Suspend the AI player for 1 tick, so it simulates MultiPlayer */
   237 		::AI_SuspendPlayer(_current_player, GetDoCommandDelay());
   238 		::AI_SuspendPlayer(_current_player, GetDoCommandDelay());
   238 	}
   239 	}
   239 
   240