OpenTTD Source  20241108-master-g80f628063a
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 
32 };
33 
35 enum PacketContentType : uint8_t {
44 };
45 
47 enum ContentID {
48  INVALID_CONTENT_ID = UINT32_MAX,
49 };
50 
52 struct ContentInfo {
54  enum State {
61  };
62 
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;
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 */
std::vector< std::string > StringList
Type for a list of strings.
Definition: string_type.h:60
Container for all important information about a piece of content.
uint32_t unique_id
Unique ID; either GRF ID or shortname.
bool IsValid() const
Is the information from this content info valid?
Definition: tcp_content.cpp:44
uint32_t filesize
Size of the file.
MD5Hash md5sum
The MD5 checksum.
std::string url
URL related to the content.
State state
Whether the content info is selected (for download)
std::string name
Name of the content.
std::string description
Description of the content.
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
std::string version
Version of the content.
State
The state the content can be in.
@ DOES_NOT_EXIST
The content does not exist in the content system.
@ ALREADY_HERE
The content is already at the client side.
@ AUTOSELECTED
The content has been selected as dependency.
@ INVALID
The content's invalid.
@ UNSELECTED
The content has not been selected.
@ SELECTED
The content has been manually selected.
std::string filename
Filename (for the .tar.gz; only valid on download)
bool IsSelected() const
Is the state either selected or autoselected?
Definition: tcp_content.cpp:27
ContentType type
Type of content.
std::vector< ContentID > dependencies
The dependencies (unique server side ids)
StringList tags
Tags associated with the content.
bool upgrade
This item is an upgrade.
ContentType
The values in the enum are important; they are used as database 'keys'.
@ CONTENT_TYPE_AI_LIBRARY
The content consists of an AI library.
@ CONTENT_TYPE_BASE_SOUNDS
The content consists of base sounds.
@ CONTENT_TYPE_GAME_LIBRARY
The content consists of a GS library.
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
@ CONTENT_TYPE_AI
The content consists of an AI.
@ CONTENT_TYPE_SCENARIO
The content consists of a scenario.
@ CONTENT_TYPE_NEWGRF
The content consists of a NewGRF.
@ CONTENT_TYPE_BEGIN
Helper to mark the begin of the types.
@ CONTENT_TYPE_BASE_MUSIC
The content consists of base music.
@ CONTENT_TYPE_GAME
The content consists of a game script.
@ INVALID_CONTENT_TYPE
Invalid/uninitialized content.
@ CONTENT_TYPE_END
Helper to mark the end of the types.
@ CONTENT_TYPE_HEIGHTMAP
The content consists of a heightmap.
ContentID
Unique identifier for the content.
@ INVALID_CONTENT_ID
Sentinel for invalid content.
PacketContentType
Enum with all types of TCP content packets.
@ PACKET_CONTENT_CLIENT_CONTENT
Request a content file given an internal ID.
@ PACKET_CONTENT_END
Must ALWAYS be on the end of this list!! (period)
@ PACKET_CONTENT_CLIENT_INFO_LIST
Queries the content server for a list of info of a given content type.
@ PACKET_CONTENT_CLIENT_INFO_EXTID_MD5
Queries the content server for information about a list of external IDs and MD5.
@ PACKET_CONTENT_SERVER_INFO
Reply of content server with information about content.
@ PACKET_CONTENT_SERVER_CONTENT
Reply with the content of the given ID.
@ PACKET_CONTENT_CLIENT_INFO_ID
Queries the content server for information about a list of internal IDs.
@ PACKET_CONTENT_CLIENT_INFO_EXTID
Queries the content server for information about a list of external IDs.
TextfileType
Additional text files accompanying Tar archives.
Definition: textfile_type.h:14