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 tcp_content_type.h Basic types related to the content on the content server. 10 */ 11 12 #ifndef NETWORK_CORE_TCP_CONTENT_TYPE_H 13 #define NETWORK_CORE_TCP_CONTENT_TYPE_H 14 15 /** The values in the enum are important; they are used as database 'keys' */ 16 enum ContentType { 17 CONTENT_TYPE_BEGIN = 1, ///< Helper to mark the begin of the types 18 CONTENT_TYPE_BASE_GRAPHICS = 1, ///< The content consists of base graphics 19 CONTENT_TYPE_NEWGRF = 2, ///< The content consists of a NewGRF 20 CONTENT_TYPE_AI = 3, ///< The content consists of an AI 21 CONTENT_TYPE_AI_LIBRARY = 4, ///< The content consists of an AI library 22 CONTENT_TYPE_SCENARIO = 5, ///< The content consists of a scenario 23 CONTENT_TYPE_HEIGHTMAP = 6, ///< The content consists of a heightmap 24 CONTENT_TYPE_BASE_SOUNDS = 7, ///< The content consists of base sounds 25 CONTENT_TYPE_BASE_MUSIC = 8, ///< The content consists of base music 26 CONTENT_TYPE_GAME = 9, ///< The content consists of a game script 27 CONTENT_TYPE_GAME_LIBRARY = 10, ///< The content consists of a GS library 28 CONTENT_TYPE_END, ///< Helper to mark the end of the types 29 INVALID_CONTENT_TYPE = 0xFF, ///< Invalid/uninitialized content 30 }; 31 32 /** Enum with all types of TCP content packets. The order MUST not be changed **/ 33 enum PacketContentType { 34 PACKET_CONTENT_CLIENT_INFO_LIST, ///< Queries the content server for a list of info of a given content type 35 PACKET_CONTENT_CLIENT_INFO_ID, ///< Queries the content server for information about a list of internal IDs 36 PACKET_CONTENT_CLIENT_INFO_EXTID, ///< Queries the content server for information about a list of external IDs 37 PACKET_CONTENT_CLIENT_INFO_EXTID_MD5, ///< Queries the content server for information about a list of external IDs and MD5 38 PACKET_CONTENT_SERVER_INFO, ///< Reply of content server with information about content 39 PACKET_CONTENT_CLIENT_CONTENT, ///< Request a content file given an internal ID 40 PACKET_CONTENT_SERVER_CONTENT, ///< Reply with the content of the given ID 41 PACKET_CONTENT_END, ///< Must ALWAYS be on the end of this list!! (period) 42 }; 43 44 /** Unique identifier for the content. */ 45 enum ContentID { 46 INVALID_CONTENT_ID = UINT32_MAX, ///< Sentinel for invalid content. 47 }; 48 49 /** Container for all important information about a piece of content. */ 50 struct ContentInfo { 51 /** The state the content can be in. */ 52 enum State { 53 UNSELECTED, ///< The content has not been selected 54 SELECTED, ///< The content has been manually selected 55 AUTOSELECTED, ///< The content has been selected as dependency 56 ALREADY_HERE, ///< The content is already at the client side 57 DOES_NOT_EXIST, ///< The content does not exist in the content system 58 INVALID, ///< The content's invalid 59 }; 60 61 ContentType type = INVALID_CONTENT_TYPE; ///< Type of content 62 ContentID id = INVALID_CONTENT_ID; ///< Unique (server side) ID for the content 63 uint32 filesize = 0; ///< Size of the file 64 std::string filename; ///< Filename (for the .tar.gz; only valid on download) 65 std::string name; ///< Name of the content 66 std::string version; ///< Version of the content 67 std::string url; ///< URL related to the content 68 std::string description; ///< Description of the content 69 uint32 unique_id = 0; ///< Unique ID; either GRF ID or shortname 70 byte md5sum[16] = {0}; ///< The MD5 checksum 71 std::vector<ContentID> dependencies; ///< The dependencies (unique server side ids) 72 StringList tags; ///< Tags associated with the content 73 State state = State::UNSELECTED; ///< Whether the content info is selected (for download) 74 bool upgrade = false; ///< This item is an upgrade 75 76 bool IsSelected() const; 77 bool IsValid() const; 78 const char *GetTextfile(TextfileType type) const; 79 }; 80 81 #endif /* NETWORK_CORE_TCP_CONTENT_TYPE_H */ 82