Changeset - r25287:53db62f40fa0
[Not reviewed]
master
0 3 0
rubidium42 - 3 years ago 2021-04-27 17:32:51
rubidium@openttd.org
Cleanup: remove #ifdefs for compiling the old content server
3 files changed with 0 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/network/core/tcp_content.cpp
Show inline comments
 
/*
 
 * This file is part of OpenTTD.
 
 * 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.
 
 * 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.
 
 * 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 <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/**
 
 * @file tcp_content.cpp Basic functions to receive and send Content packets.
 
 */
 

	
 
#include "../../stdafx.h"
 
#ifndef OPENTTD_MSU
 
#include "../../textfile_gui.h"
 
#include "../../newgrf_config.h"
 
#include "../../base_media_base.h"
 
#include "../../ai/ai.hpp"
 
#include "../../game/game.hpp"
 
#include "../../fios.h"
 
#endif /* OPENTTD_MSU */
 
#include "tcp_content.h"
 

	
 
#include "../../safeguards.h"
 

	
 
/** Clear everything in the struct */
 
ContentInfo::ContentInfo()
 
{
 
	memset(this, 0, sizeof(*this));
 
}
 

	
 
/** Free everything allocated */
 
ContentInfo::~ContentInfo()
 
@@ -83,25 +81,24 @@ bool ContentInfo::IsSelected() const
 
	}
 
}
 

	
 
/**
 
 * Is the information from this content info valid?
 
 * @return true iff it's valid
 
 */
 
bool ContentInfo::IsValid() const
 
{
 
	return this->state < ContentInfo::INVALID && this->type >= CONTENT_TYPE_BEGIN && this->type < CONTENT_TYPE_END;
 
}
 

	
 
#ifndef OPENTTD_MSU
 
/**
 
 * Search a textfile file next to this file in the content list.
 
 * @param type The type of the textfile to search for.
 
 * @return The filename for the textfile, \c nullptr otherwise.
 
 */
 
const char *ContentInfo::GetTextfile(TextfileType type) const
 
{
 
	if (this->state == INVALID) return nullptr;
 
	const char *tmp;
 
	switch (this->type) {
 
		default: NOT_REACHED();
 
		case CONTENT_TYPE_AI:
 
@@ -130,25 +127,24 @@ const char *ContentInfo::GetTextfile(Tex
 
		case CONTENT_TYPE_BASE_MUSIC:
 
			tmp = TryGetBaseSetFile(this, true, BaseMusic::GetAvailableSets());
 
			break;
 
		case CONTENT_TYPE_SCENARIO:
 
		case CONTENT_TYPE_HEIGHTMAP:
 
			extern const char *FindScenario(const ContentInfo *ci, bool md5sum);
 
			tmp = FindScenario(this, true);
 
			break;
 
	}
 
	if (tmp == nullptr) return nullptr;
 
	return ::GetTextfile(type, GetContentInfoSubDir(this->type), tmp);
 
}
 
#endif /* OPENTTD_MSU */
 

	
 
void NetworkContentSocketHandler::Close()
 
{
 
	CloseConnection();
 
	if (this->sock == INVALID_SOCKET) return;
 

	
 
	closesocket(this->sock);
 
	this->sock = INVALID_SOCKET;
 
}
 

	
 
/**
 
 * Handle the given packet, i.e. pass it to the right
 
@@ -227,38 +223,36 @@ bool NetworkContentSocketHandler::Receiv
 
	DEBUG(net, 0, "[tcp/content] received illegal packet type %d", type);
 
	return false;
 
}
 

	
 
bool NetworkContentSocketHandler::Receive_CLIENT_INFO_LIST(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CONTENT_CLIENT_INFO_LIST); }
 
bool NetworkContentSocketHandler::Receive_CLIENT_INFO_ID(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CONTENT_CLIENT_INFO_ID); }
 
bool NetworkContentSocketHandler::Receive_CLIENT_INFO_EXTID(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CONTENT_CLIENT_INFO_EXTID); }
 
bool NetworkContentSocketHandler::Receive_CLIENT_INFO_EXTID_MD5(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CONTENT_CLIENT_INFO_EXTID_MD5); }
 
bool NetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CONTENT_SERVER_INFO); }
 
bool NetworkContentSocketHandler::Receive_CLIENT_CONTENT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CONTENT_CLIENT_CONTENT); }
 
bool NetworkContentSocketHandler::Receive_SERVER_CONTENT(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CONTENT_SERVER_CONTENT); }
 

	
 
#ifndef OPENTTD_MSU
 
/**
 
 * Helper to get the subdirectory a #ContentInfo is located in.
 
 * @param type The type of content.
 
 * @return The subdirectory the content is located in.
 
 */
 
Subdirectory GetContentInfoSubDir(ContentType type)
 
{
 
	switch (type) {
 
		default: return NO_DIRECTORY;
 
		case CONTENT_TYPE_AI:           return AI_DIR;
 
		case CONTENT_TYPE_AI_LIBRARY:   return AI_LIBRARY_DIR;
 
		case CONTENT_TYPE_GAME:         return GAME_DIR;
 
		case CONTENT_TYPE_GAME_LIBRARY: return GAME_LIBRARY_DIR;
 
		case CONTENT_TYPE_NEWGRF:       return NEWGRF_DIR;
 

	
 
		case CONTENT_TYPE_BASE_GRAPHICS:
 
		case CONTENT_TYPE_BASE_SOUNDS:
 
		case CONTENT_TYPE_BASE_MUSIC:
 
			return BASESET_DIR;
 

	
 
		case CONTENT_TYPE_SCENARIO:     return SCENARIO_DIR;
 
		case CONTENT_TYPE_HEIGHTMAP:    return HEIGHTMAP_DIR;
 
	}
 
}
 
#endif /* OPENTTD_MSU */
src/network/core/tcp_content.h
Show inline comments
 
@@ -120,17 +120,15 @@ public:
 
	 */
 
	NetworkContentSocketHandler(SOCKET s = INVALID_SOCKET) :
 
		NetworkTCPSocketHandler(s)
 
	{
 
	}
 

	
 
	/** On destructing of this class, the socket needs to be closed */
 
	virtual ~NetworkContentSocketHandler() { this->Close(); }
 

	
 
	bool ReceivePackets();
 
};
 

	
 
#ifndef OPENTTD_MSU
 
Subdirectory GetContentInfoSubDir(ContentType type);
 
#endif /* OPENTTD_MSU */
 

	
 
#endif /* NETWORK_CORE_TCP_CONTENT_H */
src/network/core/tcp_content_type.h
Show inline comments
 
@@ -73,18 +73,16 @@ struct ContentInfo {
 
	char (*tags)[32];        ///< Malloced array of tags (strings)
 
	State state;             ///< Whether the content info is selected (for download)
 
	bool upgrade;            ///< This item is an upgrade
 

	
 
	ContentInfo();
 
	~ContentInfo();
 

	
 
	void TransferFrom(ContentInfo *other);
 

	
 
	size_t Size() const;
 
	bool IsSelected() const;
 
	bool IsValid() const;
 
#ifndef OPENTTD_MSU
 
	const char *GetTextfile(TextfileType type) const;
 
#endif /* OPENTTD_MSU */
 
};
 

	
 
#endif /* NETWORK_CORE_TCP_CONTENT_TYPE_H */
0 comments (0 inline, 0 general)