OpenTTD Source: src/script/script_storage.hpp Source File

OpenTTD Source 12.2

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
31 class ScriptStorage {
32 friend class ScriptObject;
33 private:
34 ScriptModeProc *mode;
35 class ScriptObject *mode_instance;
36 CompanyID root_company;
37 CompanyID company;
38
39 uint delay;
40 bool allow_do_command;
41
42 CommandCost costs;
43 Money last_cost;
44 uint last_error;
45 bool last_command_res;
46
47 TileIndex last_tile;
48 uint32 last_p1;
49 uint32 last_p2;
50 uint32 last_cmd;
51
52 VehicleID new_vehicle_id;
53 SignID new_sign_id;
54 GroupID new_group_id;
55 GoalID new_goal_id;
56 StoryPageID new_story_page_id;
57 StoryPageID new_story_page_element_id;
58
59 std::vector<int> callback_value;
60
61 RoadType road_type;
62 RailType rail_type;
63
64 void *event_data;
65 void *log_data;
66
67 public:
68 ScriptStorage() :
69 mode (nullptr),
70 mode_instance (nullptr),
71 root_company (INVALID_OWNER),
72 company (INVALID_OWNER),
73 delay (1),
74 allow_do_command (true),
75 /* costs (can't be set) */
76 last_cost (0),
77 last_error (STR_NULL),
78 last_command_res (true),
79 last_tile (INVALID_TILE),
80 last_p1 (0),
81 last_p2 (0),
82 last_cmd (CMD_END),
83 new_vehicle_id (0),
84 new_sign_id (0),
85 new_group_id (0),
86 new_goal_id (0),
87 new_story_page_id (0),
88 new_story_page_element_id(0),
89 /* calback_value (can't be set) */
90 road_type (INVALID_ROADTYPE),
91 rail_type (INVALID_RAILTYPE),
92 event_data (nullptr),
93 log_data (nullptr)
94 { }
95
96 ~ScriptStorage();
97 };
98
99 #endif /* SCRIPT_STORAGE_HPP */
ScriptStorage::log_data
void * log_data
Pointer to the log data storage.
Definition: script_storage.hpp:65
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
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_tile
TileIndex last_tile
The last tile passed to a command.
Definition: script_storage.hpp:47
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
ScriptStorage::company
CompanyID company
The current company.
Definition: script_storage.hpp:37
ScriptStorage::last_p2
uint32 last_p2
The last p2 passed to a command.
Definition: script_storage.hpp:49
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
CommandCost
Common return value for all commands.
Definition: command_type.h:23
ScriptModeProc
bool() ScriptModeProc()
The callback function for Mode-classes.
Definition: script_storage.hpp:26
StoryPageID
uint16 StoryPageID
ID of a story page.
Definition: story_type.h:16
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:64
ScriptStorage::mode_instance
class ScriptObject * mode_instance
The instance belonging to the current build mode.
Definition: script_storage.hpp:35
ScriptStorage::last_p1
uint32 last_p1
The last p1 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
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
ScriptStorage::new_vehicle_id
VehicleID new_vehicle_id
The ID of the new Vehicle.
Definition: script_storage.hpp:52
ScriptStorage::callback_value
std::vector< int > callback_value
The values which need to survive a callback.
Definition: script_storage.hpp:59
ScriptStorage::allow_do_command
bool allow_do_command
Is the usage of DoCommands restricted?
Definition: script_storage.hpp:40
GroupID
uint16 GroupID
Type for all group identifiers.
Definition: group_type.h:13
ScriptStorage::new_story_page_element_id
StoryPageID new_story_page_element_id
The ID of the new StoryPageElement.
Definition: script_storage.hpp:57
ScriptStorage::costs
CommandCost costs
The costs the script is tracking.
Definition: script_storage.hpp:42
ScriptStorage::new_sign_id
SignID new_sign_id
The ID of the new Sign.
Definition: script_storage.hpp:53
ScriptStorage::new_group_id
GroupID new_group_id
The ID of the new Group.
Definition: script_storage.hpp:54
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
ScriptStorage::new_story_page_id
StoryPageID new_story_page_id
The ID of the new StoryPage.
Definition: script_storage.hpp:56
VehicleID
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
ScriptStorage::new_goal_id
GoalID new_goal_id
The ID of the new Goal.
Definition: script_storage.hpp:55
OverflowSafeInt< int64 >
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
ScriptStorage::road_type
RoadType road_type
The current roadtype we build.
Definition: script_storage.hpp:61
CMD_END
@ CMD_END
Must ALWAYS be on the end of this list!! (period)
Definition: command_type.h:338
ScriptStorage::last_cmd
uint32 last_cmd
The last cmd passed to a command.
Definition: script_storage.hpp:50
GoalID
uint16 GoalID
ID of a goal.
Definition: goal_type.h:38
ScriptStorage::rail_type
RailType rail_type
The current railtype we build.
Definition: script_storage.hpp:62
ScriptStorage::last_command_res
bool last_command_res
The last result of the command.
Definition: script_storage.hpp:45
SignID
uint16 SignID
The type of the IDs of signs.
Definition: signs_type.h:14
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34