Update: Translations from eints
[openttd-github.git] / src / script / script_storage.hpp
blob6f856908d5b6985666c67c79b302808b686ab648
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_storage.hpp Defines ScriptStorage and includes all files required for it. */
10 #ifndef SCRIPT_STORAGE_HPP
11 #define SCRIPT_STORAGE_HPP
13 #include "../signs_func.h"
14 #include "../vehicle_func.h"
15 #include "../road_type.h"
16 #include "../group.h"
17 #include "../goal_type.h"
18 #include "../story_type.h"
20 #include "script_log_types.hpp"
22 #include "table/strings.h"
24 /**
25 * The callback function for Mode-classes.
27 typedef bool (ScriptModeProc)();
29 /**
30 * The callback function for Async Mode-classes.
32 typedef bool (ScriptAsyncModeProc)();
34 /**
35 * The storage for each script. It keeps track of important information.
37 class ScriptStorage {
38 friend class ScriptObject;
39 private:
40 ScriptModeProc *mode; ///< The current build mode we are int.
41 class ScriptObject *mode_instance; ///< The instance belonging to the current build mode.
42 ScriptAsyncModeProc *async_mode; ///< The current command async mode we are in.
43 class ScriptObject *async_mode_instance; ///< The instance belonging to the current command async mode.
44 CompanyID root_company; ///< The root company, the company that the script really belongs to.
45 CompanyID company; ///< The current company.
47 uint delay; ///< The ticks of delay each DoCommand has.
48 bool allow_do_command; ///< Is the usage of DoCommands restricted?
50 CommandCost costs; ///< The costs the script is tracking.
51 Money last_cost; ///< The last cost of the command.
52 uint last_error; ///< The last error of the command.
53 bool last_command_res; ///< The last result of the command.
55 CommandDataBuffer last_data; ///< The last data passed to a command.
56 Commands last_cmd; ///< The last cmd passed to a command.
57 CommandDataBuffer last_cmd_ret; ///< The extra data returned by the last command.
59 std::vector<int> callback_value; ///< The values which need to survive a callback.
61 RoadType road_type; ///< The current roadtype we build.
62 RailType rail_type; ///< The current railtype we build.
64 void *event_data; ///< Pointer to the event data storage.
65 ScriptLogTypes::LogData log_data;///< Log data storage.
67 public:
68 ScriptStorage() :
69 mode (nullptr),
70 mode_instance (nullptr),
71 async_mode (nullptr),
72 async_mode_instance (nullptr),
73 root_company (INVALID_OWNER),
74 company (INVALID_OWNER),
75 delay (1),
76 allow_do_command (true),
77 /* costs (can't be set) */
78 last_cost (0),
79 last_error (STR_NULL),
80 last_command_res (true),
81 last_cmd (CMD_END),
82 /* calback_value (can't be set) */
83 road_type (INVALID_ROADTYPE),
84 rail_type (INVALID_RAILTYPE),
85 event_data (nullptr)
86 { }
88 ~ScriptStorage();
91 #endif /* SCRIPT_STORAGE_HPP */