OpenTTD Source: src/network/core/tcp_content_type.h Source File

OpenTTD Source 14.1

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