Update: Translations from eints
[openttd-github.git] / src / script / api / script_execmode.cpp
blob007dd1ef58df3ff9f6bfd58986cd4a34c604e757
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file script_execmode.cpp Implementation of ScriptExecMode. */
10 #include "../../stdafx.h"
11 #include "script_execmode.hpp"
12 #include "../script_instance.hpp"
13 #include "../script_fatalerror.hpp"
15 #include "../../safeguards.h"
17 bool ScriptExecMode::ModeProc()
19 /* In execution mode we only return 'true', telling the DoCommand it
20 * should continue with the real execution of the command. */
21 return true;
24 ScriptExecMode::ScriptExecMode()
26 this->last_mode = this->GetDoCommandMode();
27 this->last_instance = this->GetDoCommandModeInstance();
28 this->SetDoCommandMode(&ScriptExecMode::ModeProc, this);
31 void ScriptExecMode::FinalRelease()
33 if (this->GetDoCommandModeInstance() != this) {
34 /* Ignore this error if the script is not alive. */
35 if (ScriptObject::GetActiveInstance()->IsAlive()) {
36 throw Script_FatalError("ScriptExecMode object was removed while it was not the latest *Mode object created.");
41 ScriptExecMode::~ScriptExecMode()
43 this->SetDoCommandMode(this->last_mode, this->last_instance);