16 #include "../../stdafx.h" 18 #include "../../textfile_gui.h" 19 #include "../../newgrf_config.h" 20 #include "../../base_media_base.h" 21 #include "../../ai/ai.hpp" 22 #include "../../game/game.hpp" 23 #include "../../fios.h" 27 #include "../../safeguards.h" 32 memset(
this, 0,
sizeof(*
this));
64 for (uint i = 0; i < this->
tag_count; i++) len += strlen(this->
tags[i]) + 1;
68 return sizeof(*this) +
79 switch (this->
state) {
109 switch (this->type) {
110 default: NOT_REACHED();
125 tmp = gc != NULL ? gc->
filename : NULL;
143 if (tmp == NULL)
return NULL;
151 if (this->sock == INVALID_SOCKET)
return;
153 closesocket(this->sock);
154 this->sock = INVALID_SOCKET;
177 if (this->HasClientQuit()) {
178 DEBUG(net, 0,
"[tcp/content] received invalid packet type %d from %s", type, this->client_addr.GetAddressAsString());
180 DEBUG(net, 0,
"[tcp/content] received illegal packet from %s", this->client_addr.GetAddressAsString());
212 static const int MAX_PACKETS_TO_RECEIVE = 42;
213 int i = MAX_PACKETS_TO_RECEIVE;
214 while (--i != 0 && (p = this->ReceivePacket()) != NULL) {
215 bool cont = this->HandlePacket(p);
217 if (!cont)
return true;
220 return i != MAX_PACKETS_TO_RECEIVE - 1;
231 DEBUG(net, 0,
"[tcp/content] received illegal packet type %d from %s", type, this->client_addr.GetAddressAsString());
Helper to mark the end of the types.
The content consists of base graphics.
bool IsSelected() const
Is the state either selected or autoselected?
uint32 unique_id
Unique ID; either GRF ID or shortname.
Internal entity of a packet.
Queries the content server for information about a list of external IDs.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
The content consists of a scenario.
Subdirectory of scenario for heightmaps.
uint8 dependency_count
Number of dependencies.
char(* tags)[32]
Malloced array of tags (strings)
static GameScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find Game scripts.
static AIScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find AI Libraries.
ContentID * dependencies
Malloced array of dependencies (unique server side ids)
Subdirectory for all game scripts.
The content has been selected as dependency.
const GRFConfig * FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum, uint32 desired_version)
Find a NewGRF in the scanned list.
Subdirectory for all base data (base sets, intro game)
Queries the content server for information about a list of internal IDs.
bool ReceivePackets()
Receive a packet at TCP level.
The content consists of a game script.
virtual bool Receive_CLIENT_CONTENT(Packet *p)
Client requesting the actual content: uint16 count of unique ids uint32 unique id (count times) ...
Base directory for all scenarios.
const char * FindScenario(const ContentInfo *ci, bool md5sum)
Find a given scenario based on its unique ID.
The content's invalid.
uint8 tag_count
Number of tags.
Information about GRF, used in the game and (part of it) in savegames.
Reply of content server with information about content.
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...
A path without any base directory.
size_t Size() const
Get the size of the data as send over the network.
The content is already at the client side.
bool ReceiveInvalidPacket(PacketContentType type)
Helper for logging receiving invalid packets.
ContentInfo()
Clear everything in the struct.
State state
Whether the content info is selected (for download)
Subdirectory for all GS libraries.
Basic functions to receive and send TCP packets to/from the content server.
void TransferFrom(ContentInfo *other)
Copy data from other ContentInfo and take ownership of allocated stuff.
TextfileType
Additional text files accompanying Tar archives.
Queries the content server for a list of info of a given content type.
virtual bool Receive_CLIENT_INFO_LIST(Packet *p)
Client requesting a list of content info: byte type uint32 openttd version.
byte md5sum[16]
The MD5 checksum.
The content consists of a GS library.
Subdirectory for all NewGRFs.
The content consists of a NewGRF.
#define DEBUG(name, level,...)
Output a line of debugging information.
ContentType
The values in the enum are important; they are used as database 'keys'.
Subdirectory for all AI libraries.
PacketContentType
Enum with all types of TCP content packets.
Queries the content server for information about a list of external IDs and MD5.
The content consists of an AI library.
uint8 Recv_uint8()
Read a 8 bits integer from the packet.
Request a content file given an internal ID.
~ContentInfo()
Free everything allocated.
The content consists of a heightmap.
The content consists of an AI.
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this file in the content list.
ContentType type
Type of content.
Subdirectory for all AI files.
const char * FindMainScript(const ContentInfo *ci, bool md5sum)
Find a script of a ContentInfo.
char * filename
Filename - either with or without full path.
Helper to mark the begin of the types.
The content consists of base music.
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...
static GameScannerLibrary * GetScannerLibrary()
Gets the ScriptScanner instance that is used to find Game Libraries.
virtual void Close()
Really close the socket.
virtual bool Receive_CLIENT_INFO_ID(Packet *p)
Client requesting a list of content info: uint16 count of ids uint32 id (count times) ...
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
The content has been manually selected.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
Only find Grfs matching md5sum.
Subdirectory GetContentInfoSubDir(ContentType type)
Helper to get the subdirectory a ContentInfo is located in.
static AIScannerInfo * GetScannerInfo()
Gets the ScriptScanner instance that is used to find AIs.
Must ALWAYS be on the end of this list!! (period)
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...
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 ...
Container for all important information about a piece of content.
bool IsValid() const
Is the information from this content info valid?
Reply with the content of the given ID.
The content consists of base sounds.
bool HandlePacket(Packet *p)
Handle the given packet, i.e.