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