Update: Translations from eints
[openttd-github.git] / src / script / api / script_types.hpp
blobf020427fa2732c5d8a7966fe7caeab22f4ec52be
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 /**
9 * @file script_types.hpp Defines all the types of the game, like IDs of various objects.
12 /**
13 * @page script_ids Identifying game object
14 * IDs are used to identify certain objects. They are only unique within the object type, so for example a vehicle may have VehicleID 2009,
15 * while a station has StationID 2009 at the same time. Also IDs are assigned arbitrary, you cannot assume them to be consecutive.
16 * Also note that some IDs are static and never change, while others are allocated dynamically and might be
17 * reused for other objects once they are released. So be careful, which IDs you store for which purpose and whether they stay valid all the time.
19 * <table>
20 * <tr><th>type </th><th> object </th>
21 * <th> acquired </th>
22 * <th> released </th>
23 * <th> reused </th></tr>
24 * <tr><td>#BridgeID </td><td> bridge type </td>
25 * <td> introduction \ref newgrf_changes "(1)" </td>
26 * <td> never \ref newgrf_changes "(1)" </td>
27 * <td> no \ref newgrf_changes "(1)" </td></tr>
28 * <tr><td>#CargoID </td><td> cargo type </td>
29 * <td> game start \ref newgrf_changes "(1)" </td>
30 * <td> never \ref newgrf_changes "(1)" </td>
31 * <td> no \ref newgrf_changes "(1)" </td></tr>
32 * <tr><td>#EngineID </td><td> engine type </td>
33 * <td> introduction, preview \ref dynamic_engines "(2)" </td>
34 * <td> engines retires \ref dynamic_engines "(2)" </td>
35 * <td> no \ref dynamic_engines "(2)" </td></tr>
36 * <tr><td>#GoalID </td><td> goal </td>
37 * <td> creation </td>
38 * <td> deletion </td>
39 * <td> yes </td></tr>
40 * <tr><td>#GroupID </td><td> vehicle group </td>
41 * <td> creation </td>
42 * <td> deletion </td>
43 * <td> yes </td></tr>
44 * <tr><td>#IndustryID </td><td> industry </td>
45 * <td> construction </td>
46 * <td> closure </td>
47 * <td> yes </td></tr>
48 * <tr><td>#IndustryType</td><td> industry type </td>
49 * <td> game start \ref newgrf_changes "(1)" </td>
50 * <td> never \ref newgrf_changes "(1)" </td>
51 * <td> no </td></tr>
52 * <tr><td>#ObjectType </td><td> NewGRF object type </td>
53 * <td> game start \ref newgrf_changes "(1)" </td>
54 * <td> never \ref newgrf_changes "(1)" </td>
55 * <td> no </td></tr>
56 * <tr><td>#ScriptErrorType</td><td> error message </td>
57 * <td> OpenTTD start \ref transient_id "(3)" </td>
58 * <td> OpenTTD exit </td>
59 * <td> no </td></tr>
60 * <tr><td>#SignID </td><td> sign </td>
61 * <td> construction </td>
62 * <td> deletion </td>
63 * <td> yes </td></tr>
64 * <tr><td>#StationID </td><td> station </td>
65 * <td> construction </td>
66 * <td> expiration of 'grey' station sign after deletion </td>
67 * <td> yes </td></tr>
68 * <tr><td>#StringID </td><td> translatable text </td>
69 * <td> OpenTTD start \ref transient_id "(3)" </td>
70 * <td> OpenTTD exit </td>
71 * <td> no </td></tr>
72 * <tr><td>#SubsidyID </td><td> subsidy </td>
73 * <td> offer announcement </td>
74 * <td> (offer) expiration </td>
75 * <td> yes </td></tr>
76 * <tr><td>#StoryPageID </td><td> story page </td>
77 * <td> creation </td>
78 * <td> deletion </td>
79 * <td> yes </td></tr>
80 * <tr><td>#StoryPageElementID</td><td> story page element </td>
81 * <td> creation </td>
82 * <td> deletion </td>
83 * <td> yes </td></tr>
84 * <tr><td>#TileIndex </td><td> tile on map </td>
85 * <td> game start </td>
86 * <td> never </td>
87 * <td> no </td></tr>
88 * <tr><td>#TownID </td><td> town </td>
89 * <td> game start </td>
90 * <td> never </td>
91 * <td> no </td></tr>
92 * <tr><td>#VehicleID </td><td> vehicle </td>
93 * <td> construction, autorenew, autoreplace </td>
94 * <td> destruction, autorenew, autoreplace </td>
95 * <td> yes </td></tr>
96 * </table>
98 * @remarks
99 * \li \anchor newgrf_changes (1) in-game changes of newgrfs may reassign/invalidate IDs (will also cause other trouble though).
100 * \li \anchor dynamic_engines (2) engine IDs are reassigned/invalidated on changing 'allow multiple newgrf engine sets' (only allowed as long as no vehicles are built).
101 * \li \anchor transient_id (3) string/error IDs are only valid during a session, and may be reassigned/invalidated when loading savegames (so you cannot store them).
104 #ifndef SCRIPT_TYPES_HPP
105 #define SCRIPT_TYPES_HPP
107 #include "../../core/overflowsafe_type.hpp"
108 #include "../../company_type.h"
109 #include "../../tile_type.h"
110 #include <squirrel.h>
112 /* Define all types here, so they are added to the API docs. */
113 typedef uint BridgeID; ///< The ID of a bridge type.
114 typedef uint8_t CargoID; ///< The ID of a cargo.
115 typedef uint16_t EngineID; ///< The ID of an engine.
116 typedef uint16_t GoalID; ///< The ID of a goal.
117 typedef uint16_t GroupID; ///< The ID of a group.
118 typedef uint16_t IndustryID; ///< The ID of an industry.
119 typedef uint8_t IndustryType; ///< The ID of an industry-type.
120 #ifdef DOXYGEN_API
121 typedef int64_t Money; ///< Money, stored in a 32bit/64bit safe way. For scripts money is always in pounds.
122 #else
123 typedef OverflowSafeInt64 Money;
124 #endif /* DOXYGEN_API */
125 typedef uint16_t ObjectType; ///< The ID of an object-type.
126 typedef uint16_t SignID; ///< The ID of a sign.
127 typedef uint16_t StationID; ///< The ID of a station.
128 typedef uint32_t StringID; ///< The ID of a string.
129 typedef uint16_t SubsidyID; ///< The ID of a subsidy.
130 typedef uint16_t StoryPageID; ///< The ID of a story page.
131 typedef uint16_t StoryPageElementID; ///< The ID of a story page element.
132 #ifdef DOXYGEN_API
133 typedef uint32_t TileIndex; ///< The ID of a map location.
134 #endif /* DOXYGEN_API */
135 typedef uint16_t TownID; ///< The ID of a town.
136 typedef uint32_t VehicleID; ///< The ID of a vehicle.
139 * The types of errors inside the script framework.
141 * Possible value are defined inside each API class in an ErrorMessages enum.
143 typedef uint ScriptErrorType;
145 #endif /* SCRIPT_TYPES_HPP */