OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
12 #include "../../stdafx.h"
13 #include "../../textfile_gui.h"
14 #include "../../newgrf_config.h"
15 #include "../../base_media_base.h"
16 #include "../../ai/ai.hpp"
17 #include "../../game/game.hpp"
18 #include "../../fios.h"
21 #include "../../safeguards.h"
29 switch (this->
state) {
59 default: NOT_REACHED();
74 tmp = gc !=
nullptr ? gc->
filename.c_str() :
nullptr;
91 if (tmp ==
nullptr)
return std::nullopt;
116 Debug(net, 0,
"[tcp/content] Received invalid packet type {}", type);
118 Debug(net, 0,
"[tcp/content] Received illegal packet");
149 std::unique_ptr<Packet> p;
150 static const int MAX_PACKETS_TO_RECEIVE = 42;
151 int i = MAX_PACKETS_TO_RECEIVE;
154 if (!cont)
return true;
157 return i != MAX_PACKETS_TO_RECEIVE - 1;
168 Debug(net, 0,
"[tcp/content] Received illegal packet type {}", type);
bool IsSelected() const
Is the state either selected or autoselected?
std::optional< std::string > GetTextfile(TextfileType type) const
Search a textfile file next to this file in the content list.
ContentType type
Type of content.
static AIScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find AIs.
virtual bool Receive_CLIENT_CONTENT(Packet &p)
Client requesting the actual content: uint16_t count of unique ids uint32_t unique id (count times)
@ PACKET_CONTENT_CLIENT_INFO_EXTID
Queries the content server for information about a list of external IDs.
@ CONTENT_TYPE_GAME_LIBRARY
The content consists of a GS library.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
@ GAME_LIBRARY_DIR
Subdirectory for all GS libraries.
virtual bool Receive_CLIENT_INFO_ID(Packet &p)
Client requesting a list of content info: uint16_t count of ids uint32_t id (count times)
@ CONTENT_TYPE_NEWGRF
The content consists of a NewGRF.
std::string filename
Filename - either with or without full path.
virtual bool Receive_CLIENT_INFO_EXTID(Packet &p)
Client requesting a list of content info based on an external 'unique' id; GRF ID for NewGRFS,...
@ HEIGHTMAP_DIR
Subdirectory of scenario for heightmaps.
bool ReceivePackets()
Receive a packet at TCP level.
@ CONTENT_TYPE_END
Helper to mark the end of the types.
MD5Hash md5sum
The MD5 checksum.
bool IsValid() const
Is the information from this content info valid?
ContentType
The values in the enum are important; they are used as database 'keys'.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Subdirectory GetContentInfoSubDir(ContentType type)
Helper to get the subdirectory a ContentInfo is located in.
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
@ CONTENT_TYPE_GAME
The content consists of a game script.
static uint32_t BSWAP32(uint32_t x)
Perform a 32 bits endianness bitswap on x.
PacketContentType
Enum with all types of TCP content packets.
Information about GRF, used in the game and (part of it) in savegames.
@ AI_DIR
Subdirectory for all AI files.
std::optional< std::string > GetTextfile(TextfileType type, Subdirectory dir, const std::string &filename)
Search a textfile file next to the given content.
static AIScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find AI Libraries.
@ GAME_DIR
Subdirectory for all game scripts.
@ PACKET_CONTENT_SERVER_INFO
Reply of content server with information about content.
@ SCENARIO_DIR
Base directory for all scenarios.
@ SELECTED
The content has been manually selected.
Internal entity of a packet.
virtual bool Receive_CLIENT_INFO_EXTID_MD5(Packet &p)
Client requesting a list of content info based on an external 'unique' id; GRF ID + MD5 checksum for ...
@ PACKET_CONTENT_CLIENT_CONTENT
Request a content file given an internal ID.
@ NEWGRF_DIR
Subdirectory for all NewGRFs.
virtual bool Receive_CLIENT_INFO_LIST(Packet &p)
Client requesting a list of content info: uint8_t type uint32_t openttd version (or 0xFFFFFFFF if usi...
bool ReceiveInvalidPacket(PacketContentType type)
Helper for logging receiving invalid packets.
@ PACKET_CONTENT_CLIENT_INFO_LIST
Queries the content server for a list of info of a given content type.
bool HandlePacket(Packet &p)
Handle the given packet, i.e.
@ CONTENT_TYPE_AI
The content consists of an AI.
@ PACKET_CONTENT_CLIENT_INFO_ID
Queries the content server for information about a list of internal IDs.
bool HasClientQuit() const
Whether the current client connected to the socket has quit.
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
@ ALREADY_HERE
The content is already at the client side.
virtual bool Receive_SERVER_INFO(Packet &p)
Server sending list of content info: uint8_t type (invalid ID == does not exist) uint32_t id uint32_t...
@ AUTOSELECTED
The content has been selected as dependency.
@ CONTENT_TYPE_AI_LIBRARY
The content consists of an AI library.
@ NO_DIRECTORY
A path without any base directory.
@ CONTENT_TYPE_BEGIN
Helper to mark the begin of the types.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
virtual std::unique_ptr< Packet > ReceivePacket()
Receives a packet for the given client.
State state
Whether the content info is selected (for download)
@ CONTENT_TYPE_BASE_SOUNDS
The content consists of base sounds.
@ AI_LIBRARY_DIR
Subdirectory for all AI libraries.
virtual bool Receive_SERVER_CONTENT(Packet &p)
Server sending list of content info: uint32_t unique id uint32_t file size (0 == does not exist) stri...
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
@ PACKET_CONTENT_CLIENT_INFO_EXTID_MD5
Queries the content server for information about a list of external IDs and MD5.
@ CONTENT_TYPE_SCENARIO
The content consists of a scenario.
@ PACKET_CONTENT_END
Must ALWAYS be on the end of this list!! (period)
TextfileType
Additional text files accompanying Tar archives.
@ FGCM_EXACT
Only find Grfs matching md5sum.
const char * FindMainScript(const ContentInfo *ci, bool md5sum)
Find a script of a ContentInfo.
@ INVALID
The content's invalid.
const char * FindScenario(const ContentInfo *ci, bool md5sum)
Find a given scenario based on its unique ID.
const GRFConfig * FindGRFConfig(uint32_t grfid, FindGRFConfigMode mode, const MD5Hash *md5sum, uint32_t desired_version)
Find a NewGRF in the scanned list.
@ CONTENT_TYPE_HEIGHTMAP
The content consists of a heightmap.
@ PACKET_CONTENT_SERVER_CONTENT
Reply with the content of the given ID.
uint32_t unique_id
Unique ID; either GRF ID or shortname.
uint8_t Recv_uint8()
Read a 8 bits integer from the packet.
@ CONTENT_TYPE_BASE_MUSIC
The content consists of base music.