ai_execmode.cpp

Go to the documentation of this file.
00001 /* $Id: ai_execmode.cpp 17236 2009-08-20 13:25:21Z rubidium $ */
00002 
00005 #include "ai_execmode.hpp"
00006 #include "../../command_type.h"
00007 #include "../../company_base.h"
00008 #include "../../company_func.h"
00009 #include "../ai_instance.hpp"
00010 
00011 bool AIExecMode::ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCost costs)
00012 {
00013   /* In execution mode we only return 'true', telling the DoCommand it
00014    *  should continue with the real execution of the command. */
00015   return true;
00016 }
00017 
00018 AIExecMode::AIExecMode()
00019 {
00020   this->last_mode     = this->GetDoCommandMode();
00021   this->last_instance = this->GetDoCommandModeInstance();
00022   this->SetDoCommandMode(&AIExecMode::ModeProc, this);
00023 }
00024 
00025 AIExecMode::~AIExecMode()
00026 {
00027   if (this->GetDoCommandModeInstance() != this) {
00028     AIInstance *instance = GetCompany(_current_company)->ai_instance;
00029     /* Ignore this error if the AI already died. */
00030     if (!instance->IsDead()) {
00031       throw AI_FatalError("AIExecMode object was removed while it was not the latest AI*Mode object created.");
00032     }
00033   }
00034   this->SetDoCommandMode(this->last_mode, this->last_instance);
00035 }

Generated on Wed Dec 23 20:12:46 2009 for OpenTTD by  doxygen 1.5.6