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 8 /** 9 * @file script_types.hpp Defines all the types of the game, like IDs of various objects. 10 * 11 * IDs are used to identify certain objects. They are only unique within the object type, so for example a vehicle may have VehicleID 2009, 12 * while a station has StationID 2009 at the same time. Also IDs are assigned arbitrary, you cannot assume them to be consecutive. 13 * Also note that some IDs are static and never change, while others are allocated dynamically and might be 14 * 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. 15 * 16 * <table> 17 * <tr><th>type </th><th> object </th> 18 * <th> acquired </th> 19 * <th> released </th> 20 * <th> reused </th></tr> 21 * <tr><td>#BridgeID </td><td> bridge type </td> 22 * <td> introduction \ref newgrf_changes "(1)" </td> 23 * <td> never \ref newgrf_changes "(1)" </td> 24 * <td> no \ref newgrf_changes "(1)" </td></tr> 25 * <tr><td>#CargoID </td><td> cargo type </td> 26 * <td> game start \ref newgrf_changes "(1)" </td> 27 * <td> never \ref newgrf_changes "(1)" </td> 28 * <td> no \ref newgrf_changes "(1)" </td></tr> 29 * <tr><td>#EngineID </td><td> engine type </td> 30 * <td> introduction, preview \ref dynamic_engines "(2)" </td> 31 * <td> engines retires \ref dynamic_engines "(2)" </td> 32 * <td> no \ref dynamic_engines "(2)" </td></tr> 33 * <tr><td>#GoalID </td><td> goal </td> 34 * <td> creation </td> 35 * <td> deletion </td> 36 * <td> yes </td></tr> 37 * <tr><td>#GroupID </td><td> vehicle group </td> 38 * <td> creation </td> 39 * <td> deletion </td> 40 * <td> yes </td></tr> 41 * <tr><td>#IndustryID </td><td> industry </td> 42 * <td> construction </td> 43 * <td> closure </td> 44 * <td> yes </td></tr> 45 * <tr><td>#IndustryType</td><td> industry type </td> 46 * <td> game start \ref newgrf_changes "(1)" </td> 47 * <td> never \ref newgrf_changes "(1)" </td> 48 * <td> no </td></tr> 49 * <tr><td>#SignID </td><td> sign </td> 50 * <td> construction </td> 51 * <td> deletion </td> 52 * <td> yes </td></tr> 53 * <tr><td>#StationID </td><td> station </td> 54 * <td> construction </td> 55 * <td> expiration of 'grey' station sign after deletion </td> 56 * <td> yes </td></tr> 57 * <tr><td>#SubsidyID </td><td> subsidy </td> 58 * <td> offer announcement </td> 59 * <td> (offer) expiration </td> 60 * <td> yes </td></tr> 61 * <tr><td>#TileIndex </td><td> tile on map </td> 62 * <td> game start </td> 63 * <td> never </td> 64 * <td> no </td></tr> 65 * <tr><td>#TownID </td><td> town </td> 66 * <td> game start </td> 67 * <td> never </td> 68 * <td> no </td></tr> 69 * <tr><td>#VehicleID </td><td> vehicle </td> 70 * <td> construction, autorenew, autoreplace </td> 71 * <td> destruction, autorenew, autoreplace </td> 72 * <td> yes </td></tr> 73 * </table> 74 * 75 * @remarks 76 * \li \anchor newgrf_changes (1) in-game changes of newgrfs may reassign/invalidate IDs (will also cause other trouble though). 77 * \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). 78 */ 79 80 #ifndef SCRIPT_TYPES_HPP 81 #define SCRIPT_TYPES_HPP 82 83 #include "../../core/overflowsafe_type.hpp" 84 #include "../../company_type.h" 85 #include <squirrel.h> 86 87 /* Define all types here, so we don't have to include the whole _type.h maze */ 88 typedef uint BridgeType; ///< Internal name, not of any use for you. 89 typedef byte CargoID; ///< The ID of a cargo. 90 class CommandCost; ///< The cost of a command. 91 typedef uint16 EngineID; ///< The ID of an engine. 92 typedef uint16 GoalID; ///< The ID of a goal. 93 typedef uint16 GroupID; ///< The ID of a group. 94 typedef uint16 IndustryID; ///< The ID of an industry. 95 typedef uint8 IndustryType; ///< The ID of an industry-type. 96 typedef OverflowSafeInt64 Money; ///< Money, stored in a 32bit/64bit safe way. For scripts money is always in pounds. 97 typedef uint16 SignID; ///< The ID of a sign. 98 typedef uint16 StationID; ///< The ID of a station. 99 typedef uint32 StringID; ///< The ID of a string. 100 typedef uint16 SubsidyID; ///< The ID of a subsidy. 101 typedef uint16 StoryPageID; ///< The ID of a story page. 102 typedef uint16 StoryPageElementID; ///< The ID of a story page element. 103 typedef uint32 TileIndex; ///< The ID of a tile (just named differently). 104 typedef uint16 TownID; ///< The ID of a town. 105 typedef uint32 VehicleID; ///< The ID of a vehicle. 106 107 /* Types we defined ourself, as the OpenTTD core doesn't have them (yet) */ 108 typedef uint ScriptErrorType;///< The types of errors inside the script framework. 109 typedef BridgeType BridgeID; ///< The ID of a bridge. 110 111 #endif /* SCRIPT_TYPES_HPP */ 112