OpenTTD Source 20260421-master-gc2fbc6fdeb
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef NETWORK_CORE_TCP_CONTENT_TYPE_H
11#define NETWORK_CORE_TCP_CONTENT_TYPE_H
12
13#include "../../3rdparty/md5/md5.h"
14
15#include "../../string_type.h"
16#include "../../textfile_type.h"
17
19enum class ContentType : uint8_t {
20 Begin = 1,
21
23 NewGRF = 2,
24 Ai = 3,
30 Gs = 9,
31 GsLibrary = 10,
32
34
35 Invalid = 0xFF,
36};
38
40
41
42using ContentID = uint32_t;
43
44static constexpr ContentID INVALID_CONTENT_ID = UINT32_MAX;
45
49 enum class State : uint8_t {
50 Unselected,
51 Selected,
52 Autoselected,
53 AlreadyHere,
54 DoesNotExist,
56 };
57
60 uint32_t filesize = 0;
61 std::string filename;
62 std::string name;
63 std::string version;
64 std::string url;
65 std::string description;
66 uint32_t unique_id = 0;
67 MD5Hash md5sum;
68 std::vector<ContentID> dependencies;
71 bool upgrade = false;
72
73 bool IsSelected() const;
74 bool IsValid() const;
75 std::optional<std::string> GetTextfile(TextfileType type) const;
76};
77
78#endif /* NETWORK_CORE_TCP_CONTENT_TYPE_H */
All data/functions related with replacing the base graphics.
All data/functions related with replacing the base music.
All data/functions related with replacing the base sounds.
Enum-as-bit-set wrapper.
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
Definition enum_type.hpp:86
Types for strings.
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?
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::string version
Version of the content.
std::string filename
Filename (for the .tar.gz; only valid on download).
bool IsSelected() const
Is the state either selected or autoselected?
ContentType type
Type of content.
std::vector< ContentID > dependencies
The dependencies (unique server side ids).
State
The state the content can be in.
@ Unselected
The content has not been selected.
StringList tags
Tags associated with the content.
bool upgrade
This item is an upgrade.
uint32_t ContentID
Unique identifier for the content.
ContentType
The values in the enum are important; they are received over the network from the content servers.
@ Begin
Helper to mark the begin of the types.
@ Invalid
Invalid/uninitialized content.
@ GsLibrary
The content consists of a GS library.
@ Scenario
The content consists of a scenario.
@ Heightmap
The content consists of a heightmap.
@ Ai
The content consists of an AI.
@ End
Helper to mark the end of the types.
@ Gs
The content consists of a game script.
@ NewGRF
The content consists of a NewGRF.
@ AiLibrary
The content consists of an AI library.
static constexpr ContentID INVALID_CONTENT_ID
Sentinel for invalid content.
EnumBitSet< ContentType, uint16_t, ContentType::End > ContentTypes
Bitset of chosen content types.
std::optional< std::string > GetTextfile(TextfileType type, Subdirectory dir, std::string_view filename)
Search a textfile file next to the given content.
Types related to textfiles.
TextfileType
Additional text files accompanying Tar archives.