(svn r13532) [NoAI] -Fix: in MultiPlayer SignID wasn't set correctly, causing weird effects. Code is now more unified, which should avoid simular effects in the future (tnx to glx for initial patch) noai
authortruebrain
Mon, 16 Jun 2008 14:43:19 +0000
branchnoai
changeset 10978 13fd0364b2c6
parent 10977 6c1a6657c7db
child 10992 4dd4f4327c3a
(svn r13532) [NoAI] -Fix: in MultiPlayer SignID wasn't set correctly, causing weird effects. Code is now more unified, which should avoid simular effects in the future (tnx to glx for initial patch)
src/ai/ai_threads.cpp
src/ai/api/ai_object.cpp
--- a/src/ai/ai_threads.cpp	Mon Jun 16 00:07:49 2008 +0000
+++ b/src/ai/ai_threads.cpp	Mon Jun 16 14:43:19 2008 +0000
@@ -8,7 +8,6 @@
 #include "../debug.h"
 #include "../thread.h"
 #include "../fiber.hpp"
-#include "../vehicle_func.h"
 #include "../player_func.h"
 #include "ai.h"
 #include "ai_threads.h"
@@ -398,8 +397,6 @@
 	assert(thr != NULL);
 	/* Store if we were a success or not */
 	AIObject::SetLastCommandRes(success);
-	/* Store some values inside the AIObject static memory */
-	AIObject::SetNewVehicleID(_new_vehicle_id);
 
 	/* Resume the fiber now */
 	thr->Resume();
--- 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());