Changeset - r10701:bcbdad2bd171
[Not reviewed]
master
0 1 0
truebrain - 15 years ago 2009-01-12 17:40:13
truebrain@openttd.org
(svn r15033) -Fix (r15027): silent a warning when compiling without network
1 file changed with 1 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_object.cpp
Show inline comments
 
@@ -193,25 +193,24 @@ void AIObject::SetCallbackVariable(int i
 
int AIObject::GetCallbackVariable(int index)
 
{
 
	return GetStorage()->callback_value[index];
 
}
 

	
 
bool AIObject::DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text, AISuspendCallbackProc *callback)
 
{
 
	if (AIObject::GetAllowDoCommand() == false) {
 
		AILog::Error("You are not allowed to execute any DoCommand (even indirect) in your constructor, Save(), and Load().\n");
 
		return false;
 
	}
 

	
 
	CompanyID old_company;
 
	CommandCost res;
 

	
 
	/* Set the default callback to return a true/false result of the DoCommand */
 
	if (callback == NULL) callback = &AIInstance::DoCommandReturn;
 

	
 
	/* Make sure the last error is reset, so we don't give faulty warnings */
 
	SetLastError(AIError::ERR_NONE);
 

	
 
	/* First, do a test-run to see if we can do this */
 
	res = ::DoCommand(tile, p1, p2, CommandFlagsToDCFlags(GetCommandFlags(cmd)), cmd, text);
 
	/* The command failed, so return */
 
	if (::CmdFailed(res)) {
 
@@ -221,25 +220,25 @@ bool AIObject::DoCommand(TileIndex tile,
 

	
 
	/* Check what the callback wants us to do */
 
	if (GetDoCommandMode() != NULL && !GetDoCommandMode()(tile, p1, p2, cmd, res)) {
 
		IncreaseDoCommandCosts(res.GetCost());
 
		return true;
 
	}
 

	
 
#ifdef ENABLE_NETWORK
 
	/* Send the command */
 
	if (_networking) {
 
		/* NetworkSend_Command needs _local_company to be set correctly, so
 
		 * adjust it, and put it back right after the function */
 
		old_company = _local_company;
 
		CompanyID old_company = _local_company;
 
		_local_company = _current_company;
 
		::NetworkSend_Command(tile, p1, p2, cmd, CcAI, text);
 
		_local_company = old_company;
 
		SetLastCost(res.GetCost());
 

	
 
		/* Suspend the AI till the command is really executed */
 
		throw AI_VMSuspend(-(int)GetDoCommandDelay(), callback);
 
	} else {
 
#else
 
	{
 
#endif
 
		/* For SinglePlayer we execute the command immediatly */
0 comments (0 inline, 0 general)