src/ai/api/ai_object.cpp
branchnoai
changeset 10978 13fd0364b2c6
parent 10977 6c1a6657c7db
child 11057 188a9ca6d8de
--- a/src/ai/api/ai_object.cpp	Mon Jun 16 00:07:49 2008 +0000
+++ b/src/ai/api/ai_object.cpp	Mon Jun 16 14:43:19 2008 +0000
@@ -97,6 +97,10 @@
 void AIObject::SetLastCommandRes(bool res)
 {
 	GetDoCommandStruct(_current_player)->last_command_res = res;
+	/* Also store the results of various global variables */
+	SetNewVehicleID(_new_vehicle_id);
+	SetNewSignID(_new_sign_id);
+	SetNewTunnelEndtile(_build_tunnel_endtile);
 }
 
 bool AIObject::GetLastCommandRes()
@@ -227,11 +231,8 @@
 	{
 #endif
 		/* For SinglePlayer we execute the command immediatly */
-		::DoCommandP(tile, p1, p2, NULL, procc);
-		/* Store some values inside the AIObject static memory */
-		SetNewVehicleID(_new_vehicle_id);
-		SetNewSignID(_new_sign_id);
-		SetNewTunnelEndtile(_build_tunnel_endtile);
+		if (!::DoCommandP(tile, p1, p2, NULL, procc)) res = CMD_ERROR;
+		SetLastCommandRes(!CmdFailed(res));
 
 		/* Suspend the AI player for 1 tick, so it simulates MultiPlayer */
 		::AI_SuspendPlayer(_current_player, GetDoCommandDelay());