Fix some daylength issues, possible division by zero in main menu.
[openttd-joker.git] / src / script / api / script_execmode.cpp
blob91dd658a3411886035f7c9c0d67b4345b51f1c0d
1 /* $Id: script_execmode.cpp 24008 2012-03-04 16:54:12Z rubidium $ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file script_execmode.cpp Implementation of ScriptExecMode. */
12 #include "../../stdafx.h"
13 #include "script_execmode.hpp"
14 #include "../script_instance.hpp"
15 #include "../script_fatalerror.hpp"
17 #include "../../safeguards.h"
19 bool ScriptExecMode::ModeProc()
21 /* In execution mode we only return 'true', telling the DoCommand it
22 * should continue with the real execution of the command. */
23 return true;
26 ScriptExecMode::ScriptExecMode()
28 this->last_mode = this->GetDoCommandMode();
29 this->last_instance = this->GetDoCommandModeInstance();
30 this->SetDoCommandMode(&ScriptExecMode::ModeProc, this);
33 void ScriptExecMode::FinalRelease()
35 if (this->GetDoCommandModeInstance() != this) {
36 /* Ignore this error if the script already died. */
37 if (!ScriptObject::GetActiveInstance()->IsDead()) {
38 throw Script_FatalError("ScriptExecMode object was removed while it was not the latest *Mode object created.");
43 ScriptExecMode::~ScriptExecMode()
45 this->SetDoCommandMode(this->last_mode, this->last_instance);