OpenTTD Source  13.0-beta2
script_storage.hpp
Go to the documentation of this file.
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  */
7 
10 #ifndef SCRIPT_STORAGE_HPP
11 #define SCRIPT_STORAGE_HPP
12 
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"
19 
20 #include "table/strings.h"
21 #include <vector>
22 
26 typedef bool (ScriptModeProc)();
27 
32 friend class ScriptObject;
33 private:
35  class ScriptObject *mode_instance;
38 
39  uint delay;
41 
44  uint last_error;
46 
51 
52  std::vector<int> callback_value;
53 
56 
57  void *event_data;
58  void *log_data;
59 
60 public:
61  ScriptStorage() :
62  mode (nullptr),
63  mode_instance (nullptr),
66  delay (1),
67  allow_do_command (true),
68  /* costs (can't be set) */
69  last_cost (0),
70  last_error (STR_NULL),
71  last_command_res (true),
73  last_cmd (CMD_END),
74  /* calback_value (can't be set) */
77  event_data (nullptr),
78  log_data (nullptr)
79  { }
80 
81  ~ScriptStorage();
82 };
83 
84 #endif /* SCRIPT_STORAGE_HPP */
ScriptStorage::log_data
void * log_data
Pointer to the log data storage.
Definition: script_storage.hpp:58
ScriptStorage::last_cmd_ret
CommandDataBuffer last_cmd_ret
The extra data returned by the last command.
Definition: script_storage.hpp:50
ScriptStorage
The storage for each script.
Definition: script_storage.hpp:31
ScriptStorage::delay
uint delay
The ticks of delay each DoCommand has.
Definition: script_storage.hpp:39
ScriptStorage::last_cmd
Commands last_cmd
The last cmd passed to a command.
Definition: script_storage.hpp:49
Commands
Commands
List of commands.
Definition: command_type.h:176
CommandDataBuffer
std::vector< byte > CommandDataBuffer
Storage buffer for serialized command data.
Definition: command_type.h:449
ScriptStorage::last_tile
TileIndex last_tile
The last tile passed to a command.
Definition: script_storage.hpp:47
ScriptStorage::company
CompanyID company
The current company.
Definition: script_storage.hpp:37
INVALID_TILE
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:108
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
CMD_END
@ CMD_END
Must ALWAYS be on the end of this list!! (period)
Definition: command_type.h:346
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
CommandCost
Common return value for all commands.
Definition: command_type.h:24
ScriptModeProc
bool() ScriptModeProc()
The callback function for Mode-classes.
Definition: script_storage.hpp:26
ScriptStorage::last_error
uint last_error
The last error of the command.
Definition: script_storage.hpp:44
INVALID_OWNER
@ INVALID_OWNER
An invalid owner.
Definition: company_type.h:29
ScriptStorage::event_data
void * event_data
Pointer to the event data storage.
Definition: script_storage.hpp:57
ScriptStorage::mode_instance
class ScriptObject * mode_instance
The instance belonging to the current build mode.
Definition: script_storage.hpp:35
ScriptStorage::last_data
CommandDataBuffer last_data
The last data passed to a command.
Definition: script_storage.hpp:48
ScriptStorage::last_cost
Money last_cost
The last cost of the command.
Definition: script_storage.hpp:43
ScriptStorage::callback_value
std::vector< int > callback_value
The values which need to survive a callback.
Definition: script_storage.hpp:52
ScriptStorage::allow_do_command
bool allow_do_command
Is the usage of DoCommands restricted?
Definition: script_storage.hpp:40
ScriptStorage::costs
CommandCost costs
The costs the script is tracking.
Definition: script_storage.hpp:42
ScriptStorage::root_company
CompanyID root_company
The root company, the company that the script really belongs to.
Definition: script_storage.hpp:36
ScriptStorage::mode
ScriptModeProc * mode
The current build mode we are int.
Definition: script_storage.hpp:34
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
OverflowSafeInt< int64 >
ScriptStorage::road_type
RoadType road_type
The current roadtype we build.
Definition: script_storage.hpp:54
ScriptStorage::rail_type
RailType rail_type
The current railtype we build.
Definition: script_storage.hpp:55
ScriptStorage::last_command_res
bool last_command_res
The last result of the command.
Definition: script_storage.hpp:45
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34