--- 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());