22#include "table/strings.h"
32 switch (this->
state) {
60 std::optional<std::string_view> tmp;
62 default: NOT_REACHED();
77 if (gc !=
nullptr) tmp = gc->
filename;
94 if (!tmp.has_value())
return std::nullopt;
118 Debug(net, 0,
"[tcp/content] Received invalid packet type {}", type);
148 std::unique_ptr<Packet> p;
149 static const int MAX_PACKETS_TO_RECEIVE = 42;
150 int i = MAX_PACKETS_TO_RECEIVE;
153 if (!cont)
return true;
156 return i != MAX_PACKETS_TO_RECEIVE - 1;
167 Debug(net, 0,
"[tcp/content] Received illegal packet type {}", type);
Base functions for all AIs.
constexpr enable_if_t< is_integral_v< T >, T > byteswap(T x) noexcept
Custom implementation of std::byteswap; remove once we build with C++23.
static AIScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find AI Libraries.
static AIScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find AIs.
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
virtual bool ReceiveClientContent(Packet &p)
Client requesting the actual content: uint16_t count of unique ids uint32_t unique id (count times).
virtual bool ReceiveClientInfoID(Packet &p)
Client requesting a list of content info: uint16_t count of ids uint32_t id (count times).
bool ReceivePackets()
Receive a packet at TCP level.
virtual bool ReceiveServerInfo(Packet &p)
Server sending list of content info: uint8_t type (invalid ID == does not exist) uint32_t id uint32_t...
virtual bool ReceiveClientInfoList(Packet &p)
Client requesting a list of content info: uint8_t type uint32_t openttd version (or 0xFFFFFFFF if usi...
virtual bool ReceiveServerContent(Packet &p)
Server sending list of content info: uint32_t unique id uint32_t file size (0 == does not exist) stri...
virtual bool ReceiveClientInfoExternalIDMD5(Packet &p)
Client requesting a list of content info based on an external 'unique' id; GRF ID + MD5 checksum for ...
virtual bool ReceiveClientInfoExternalID(Packet &p)
Client requesting a list of content info based on an external 'unique' id; GRF ID for NewGRFS,...
bool ReceiveInvalidPacket(PacketContentType type)
Helper for logging receiving invalid packets.
bool HandlePacket(Packet &p)
Handle the given packet, i.e.
virtual std::unique_ptr< Packet > ReceivePacket()
Receives a packet for the given client.
std::optional< std::string_view > FindMainScript(const ContentInfo &ci, bool md5sum)
Find a script of a ContentInfo.
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
@ NewGrf
Subdirectory for all NewGRFs.
@ GsLibrary
Subdirectory for all GS libraries.
@ Scenario
Base directory for all scenarios.
@ Heightmap
Subdirectory of scenario for heightmaps.
@ None
A path without any base directory.
@ Ai
Subdirectory for all AI files.
@ Gs
Subdirectory for all game scripts.
@ Baseset
Subdirectory for all base data (base sets, intro game).
@ AiLibrary
Subdirectory for all AI libraries.
std::optional< std::string_view > FindScenario(const ContentInfo &ci, bool md5sum)
Find a given scenario based on its unique ID.
Declarations for savegames operations.
Base functions for all Games.
const GRFConfig * FindGRFConfig(uint32_t grfid, FindGRFConfigMode mode, const MD5Hash *md5sum, uint32_t desired_version)
Find a NewGRF in the scanned list.
Functions to find and configure NewGRFs.
@ Exact
Only find Grfs matching md5sum.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
uint32_t unique_id
Unique ID; either GRF ID or shortname.
bool IsValid() const
Is the information from this content info valid?
MD5Hash md5sum
The MD5 checksum.
State state
Whether the content info is selected (for download).
std::optional< std::string > GetTextfile(TextfileType type) const
Search a textfile file next to this file in the content list.
bool IsSelected() const
Is the state either selected or autoselected?
ContentType type
Type of content.
@ Invalid
The content's invalid.
@ AlreadyHere
The content is already at the client side.
@ Selected
The content has been manually selected.
@ Autoselected
The content has been selected as dependency.
Information about GRF, used in the game and (part of it) in savegames.
std::string filename
Filename - either with or without full path.
uint8_t Recv_uint8()
Read a 8 bits integer from the packet.
Subdirectory GetContentInfoSubDir(ContentType type)
Helper to get the subdirectory a ContentInfo is located in.
Basic functions to receive and send TCP packets to/from the content server.
PacketContentType
Enum with all types of TCP content packets.
@ ClientContent
Request a content file given an internal ID.
@ ClientInfoExternalID
Queries the content server for information about a list of external IDs.
@ ClientInfoID
Queries the content server for information about a list of internal IDs.
@ ClientInfoExternalIDMD5
Queries the content server for information about a list of external IDs and MD5.
@ ServerInfo
Reply of content server with information about content.
@ ServerContent
Reply with the content of the given ID.
@ ClientInfoList
Queries the content server for a list of info of a given content type.
ContentType
The values in the enum are important; they are received over the network from the content servers.
@ BaseSounds
The content consists of base sounds.
@ Begin
Helper to mark the begin of the types.
@ GsLibrary
The content consists of a GS library.
@ Scenario
The content consists of a scenario.
@ Heightmap
The content consists of a heightmap.
@ BaseGraphics
The content consists of base graphics.
@ Ai
The content consists of an AI.
@ End
Helper to mark the end of the types.
@ BaseMusic
The content consists of base music.
@ Gs
The content consists of a game script.
@ NewGRF
The content consists of a NewGRF.
@ AiLibrary
The content consists of an AI library.
GUI functions related to textfiles.
TextfileType
Additional text files accompanying Tar archives.