ai_execmode.cpp

Go to the documentation of this file.
00001 /* $Id$ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #include "ai_execmode.hpp"
00013 #include "../../command_type.h"
00014 #include "../../company_base.h"
00015 #include "../../company_func.h"
00016 #include "../ai_instance.hpp"
00017 
00018 bool AIExecMode::ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCost costs)
00019 {
00020   /* In execution mode we only return 'true', telling the DoCommand it
00021    *  should continue with the real execution of the command. */
00022   return true;
00023 }
00024 
00025 AIExecMode::AIExecMode()
00026 {
00027   this->last_mode     = this->GetDoCommandMode();
00028   this->last_instance = this->GetDoCommandModeInstance();
00029   this->SetDoCommandMode(&AIExecMode::ModeProc, this);
00030 }
00031 
00032 AIExecMode::~AIExecMode()
00033 {
00034   if (this->GetDoCommandModeInstance() != this) {
00035     AIInstance *instance = Company::Get(_current_company)->ai_instance;
00036     /* Ignore this error if the AI already died. */
00037     if (!instance->IsDead()) {
00038       throw AI_FatalError("AIExecMode object was removed while it was not the latest AI*Mode object created.");
00039     }
00040   }
00041   this->SetDoCommandMode(this->last_mode, this->last_instance);
00042 }

Generated on Wed Dec 30 20:40:00 2009 for OpenTTD by  doxygen 1.5.6