Fix some daylength issues, possible division by zero in main menu.
[openttd-joker.git] / src / script / api / script_companymode.hpp
blobb1f643363d823a81810c9d214546c167c4c337bc
1 /* $Id: script_companymode.hpp 23737 2012-01-03 20:37:56Z truebrain $ */
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_companymode.hpp Switch the company. */
12 #ifndef SCRIPT_COMPANYMODE_HPP
13 #define SCRIPT_COMPANYMODE_HPP
15 #include "script_object.hpp"
17 /**
18 * Class to switch the current company.
19 * If you create an instance of this class, the company will be switched.
20 * The original company is stored and recovered from when ever the
21 * instance is destroyed.
22 * All actions performed within the scope of this mode, will be executed
23 * on behalf of the company you switched to. This includes any costs
24 * attached to the action performed. If the company does not have the
25 * funds the action will be aborted. In other words, this is like the
26 * real player is executing the commands.
27 * If the company is not valid during an action, the error
28 * ERR_PRECONDITION_INVALID_COMPANY will be returned. You can switch to
29 * invalid companies, or a company can become invalid (bankrupt) while you
30 * are switched to it.
31 * @api game
33 class ScriptCompanyMode : public ScriptObject {
34 private:
35 CompanyID last_company; ///< The previous company we were in.
37 public:
38 /**
39 * Creating instance of this class switches the company used for queries
40 * and commands.
41 * @param company The new company to switch to.
42 * @note When the instance is destroyed, he restores the company that was
43 * current when the instance was created!
45 ScriptCompanyMode(int company);
47 /**
48 * Destroying this instance reset the company to that what it was
49 * in when the instance was created.
51 ~ScriptCompanyMode();
54 #endif /* SCRIPT_COMPANYMODE_HPP */