OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
12 #include "../../stdafx.h"
14 #include "../../textfile_gui.h"
15 #include "../../newgrf_config.h"
16 #include "../../base_media_base.h"
17 #include "../../ai/ai.hpp"
18 #include "../../game/game.hpp"
19 #include "../../fios.h"
23 #include "../../safeguards.h"
28 memset(
this, 0,
sizeof(*
this));
49 other->
tags =
nullptr;
60 for (uint i = 0; i < this->
tag_count; i++) len += strlen(this->
tags[i]) + 1;
64 return sizeof(*this) +
75 switch (this->
state) {
105 switch (this->type) {
106 default: NOT_REACHED();
121 tmp = gc !=
nullptr ? gc->
filename :
nullptr;
139 if (tmp ==
nullptr)
return nullptr;
147 if (this->
sock == INVALID_SOCKET)
return;
149 closesocket(this->
sock);
150 this->
sock = INVALID_SOCKET;
208 static const int MAX_PACKETS_TO_RECEIVE = 42;
209 int i = MAX_PACKETS_TO_RECEIVE;
213 if (!cont)
return true;
216 return i != MAX_PACKETS_TO_RECEIVE - 1;
bool IsSelected() const
Is the state either selected or autoselected?
uint8 tag_count
Number of tags.
~ContentInfo()
Free everything allocated.
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this file in the content list.
ContentType type
Type of content.
virtual bool Receive_SERVER_CONTENT(Packet *p)
Server sending list of content info: uint32 unique id uint32 file size (0 == does not exist) string f...
static AIScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find AIs.
const GRFConfig * FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum, uint32 desired_version)
Find a NewGRF in the scanned list.
ContentType
The values in the enum are important; they are used as database 'keys'.
PacketContentType
Enum with all types of TCP content packets.
@ CONTENT_TYPE_BASE_SOUNDS
The content consists of base sounds.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
@ CONTENT_TYPE_AI
The content consists of an AI.
char(* tags)[32]
Malloced array of tags (strings)
@ GAME_LIBRARY_DIR
Subdirectory for all GS libraries.
@ PACKET_CONTENT_END
Must ALWAYS be on the end of this list!! (period)
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
@ PACKET_CONTENT_CLIENT_CONTENT
Request a content file given an internal ID.
@ HEIGHTMAP_DIR
Subdirectory of scenario for heightmaps.
SOCKET sock
The socket currently connected to.
bool ReceivePackets()
Receive a packet at TCP level.
@ PACKET_CONTENT_SERVER_CONTENT
Reply with the content of the given ID.
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 ...
bool IsValid() const
Is the information from this content info valid?
@ CONTENT_TYPE_BASE_MUSIC
The content consists of base music.
Subdirectory GetContentInfoSubDir(ContentType type)
Helper to get the subdirectory a ContentInfo is located in.
virtual Packet * ReceivePacket()
Receives a packet for the given client.
void TransferFrom(ContentInfo *other)
Copy data from other ContentInfo and take ownership of allocated stuff.
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,...
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
NetworkAddress client_addr
The address we're connected to.
@ CONTENT_TYPE_HEIGHTMAP
The content consists of a heightmap.
Information about GRF, used in the game and (part of it) in savegames.
@ AI_DIR
Subdirectory for all AI files.
#define DEBUG(name, level,...)
Output a line of debugging information.
Container for all important information about a piece of content.
NetworkRecvStatus CloseConnection(bool error=true) override
Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just ...
byte md5sum[16]
The MD5 checksum.
static AIScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find AI Libraries.
@ CONTENT_TYPE_GAME
The content consists of a game script.
@ CONTENT_TYPE_SCENARIO
The content consists of a scenario.
@ GAME_DIR
Subdirectory for all game scripts.
@ SCENARIO_DIR
Base directory for all scenarios.
@ SELECTED
The content has been manually selected.
@ CONTENT_TYPE_AI_LIBRARY
The content consists of an AI library.
@ PACKET_CONTENT_CLIENT_INFO_ID
Queries the content server for information about a list of internal IDs.
Internal entity of a packet.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
@ NEWGRF_DIR
Subdirectory for all NewGRFs.
@ CONTENT_TYPE_GAME_LIBRARY
The content consists of a GS library.
@ CONTENT_TYPE_NEWGRF
The content consists of a NewGRF.
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 HasClientQuit() const
Whether the current client connected to the socket has quit.
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
@ ALREADY_HERE
The content is already at the client side.
virtual bool Receive_CLIENT_CONTENT(Packet *p)
Client requesting the actual content: uint16 count of unique ids uint32 unique id (count times)
@ AUTOSELECTED
The content has been selected as dependency.
@ NO_DIRECTORY
A path without any base directory.
size_t Size() const
Get the size of the data as send over the network.
virtual bool Receive_CLIENT_INFO_LIST(Packet *p)
Client requesting a list of content info: byte type uint32 openttd version.
virtual bool Receive_CLIENT_INFO_ID(Packet *p)
Client requesting a list of content info: uint16 count of ids uint32 id (count times)
@ PACKET_CONTENT_CLIENT_INFO_EXTID
Queries the content server for information about a list of external IDs.
ContentInfo()
Clear everything in the struct.
uint8 dependency_count
Number of dependencies.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
uint8 Recv_uint8()
Read a 8 bits integer from the packet.
State state
Whether the content info is selected (for download)
uint32 unique_id
Unique ID; either GRF ID or shortname.
@ AI_LIBRARY_DIR
Subdirectory for all AI libraries.
@ CONTENT_TYPE_BEGIN
Helper to mark the begin of the types.
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
TextfileType
Additional text files accompanying Tar archives.
bool HandlePacket(Packet *p)
Handle the given packet, i.e.
void Close() override
Really close the socket.
@ FGCM_EXACT
Only find Grfs matching md5sum.
const char * FindMainScript(const ContentInfo *ci, bool md5sum)
Find a script of a ContentInfo.
char * filename
Filename - either with or without full path.
@ INVALID
The content's invalid.
ContentID * dependencies
Malloced array of dependencies (unique server side ids)
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
virtual bool Receive_SERVER_INFO(Packet *p)
Server sending list of content info: byte type (invalid ID == does not exist) uint32 id uint32 file_s...
const char * FindScenario(const ContentInfo *ci, bool md5sum)
Find a given scenario based on its unique ID.
@ PACKET_CONTENT_SERVER_INFO
Reply of content server with information about content.
void GetAddressAsString(char *buffer, const char *last, bool with_family=true)
Get the address as a string, e.g.
@ CONTENT_TYPE_END
Helper to mark the end of the types.
@ PACKET_CONTENT_CLIENT_INFO_EXTID_MD5
Queries the content server for information about a list of external IDs and MD5.