Changeset - r10468:83faa36bfb14
[Not reviewed]
master
0 9 1
rubidium - 16 years ago 2008-12-23 11:06:52
rubidium@openttd.org
(svn r14723) -Codechange: shuffling some stuff around to reduce indirect #include dependencies.
10 files changed with 48 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -11,12 +11,13 @@
 
#include "town.h"
 
#include "news_func.h"
 
#include "saveload.h"
 
#include "command_func.h"
 
#include "network/network.h"
 
#include "network/network_func.h"
 
#include "network/network_base.h"
 
#include "variables.h"
 
#include "cheat_func.h"
 
#include "ai/ai.h"
 
#include "company_manager_face.h"
 
#include "group.h"
 
#include "window_func.h"
src/console_cmds.cpp
Show inline comments
 
@@ -9,12 +9,13 @@
 
#include "engine_func.h"
 
#include "landscape.h"
 
#include "saveload.h"
 
#include "variables.h"
 
#include "network/network.h"
 
#include "network/network_func.h"
 
#include "network/network_base.h"
 
#include "command_func.h"
 
#include "settings_func.h"
 
#include "fios.h"
 
#include "fileio_func.h"
 
#include "screenshot.h"
 
#include "genworld.h"
src/main_gui.cpp
Show inline comments
 
@@ -33,12 +33,13 @@
 
#include "variables.h"
 
#include "tilehighlight_func.h"
 

	
 
#include "network/network.h"
 
#include "network/network_func.h"
 
#include "network/network_gui.h"
 
#include "network/network_base.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
static int _rename_id = 1;
 
static int _rename_what = -1;
src/network/core/tcp.h
Show inline comments
 
@@ -110,15 +110,14 @@ public:
 
	bool IsPacketQueueEmpty();
 

	
 
	Packet *Recv_Packet(NetworkRecvStatus *status);
 

	
 
	inline NetworkClientInfo *GetInfo() const
 
	{
 
		extern NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
 
		extern NetworkClientSocket _clients[MAX_CLIENTS];
 
		return &_network_client_info[this - _clients];
 
		return GetNetworkClientInfo(this - _clients);
 
	}
 
};
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CORE_TCP_H */
src/network/network.cpp
Show inline comments
 
@@ -104,13 +104,13 @@ extern void StateGameLoop();
 
 * Return the CI given it's raw index
 
 * @param index the index to search for
 
 * @return return a pointer to the corresponding NetworkClientInfo struct
 
 */
 
NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index)
 
{
 
	return &_network_client_info[index];
 
	return IsValidNetworkClientInfoIndex(index) ? GetNetworkClientInfo(index) : NULL;
 
}
 

	
 
/**
 
 * Return the CI given it's client-identifier
 
 * @param client_id the ClientID to search for
 
 * @return return a pointer to the corresponding NetworkClientInfo struct or NULL when not found
src/network/network_base.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file network_base.h Base core network types and some helper functions to access them. */
 

	
 
#ifndef NETWORK_BASE_H
 
#define NETWORK_BASE_H
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "network_type.h"
 

	
 
struct NetworkClientInfo {
 
	ClientID client_id;                             ///< Client identifier (same as ClientState->client_id)
 
	char client_name[NETWORK_CLIENT_NAME_LENGTH];   ///< Name of the client
 
	byte client_lang;                               ///< The language of the client
 
	CompanyID client_playas;                        ///< As which company is this client playing (CompanyID)
 
	uint32 client_ip;                               ///< IP-address of the client (so he can be banned)
 
	Date join_date;                                 ///< Gamedate the client has joined
 
	char unique_id[NETWORK_UNIQUE_ID_LENGTH];       ///< Every play sends an unique id so we can indentify him
 

	
 
	inline bool IsValid() const { return client_id != INVALID_CLIENT_ID; }
 
};
 

	
 
static NetworkClientInfo *GetNetworkClientInfo(int ci)
 
{
 
	extern NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
 
	return &_network_client_info[ci];
 
}
 

	
 
static inline bool IsValidNetworkClientInfoIndex(ClientIndex index)
 
{
 
	return (uint)index < MAX_CLIENT_INFO && GetNetworkClientInfo(index)->IsValid();
 
}
 

	
 
#define FOR_ALL_CLIENT_INFOS_FROM(d, start) for (ci = GetNetworkClientInfo(start); ci != GetNetworkClientInfo(MAX_CLIENT_INFO); ci++) if (ci->IsValid())
 
#define FOR_ALL_CLIENT_INFOS(d) FOR_ALL_CLIENT_INFOS_FROM(d, 0)
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_BASE_H */
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -298,14 +298,14 @@ struct NetworkChatWindow : public QueryS
 
	{
 
		static char chat_tab_temp_buffer[64];
 

	
 
		/* First, try clients */
 
		if (*item < MAX_CLIENT_INFO) {
 
			/* Skip inactive clients */
 
			while (_network_client_info[*item].client_id == INVALID_CLIENT_ID && *item < MAX_CLIENT_INFO) (*item)++;
 
			if (*item < MAX_CLIENT_INFO) return _network_client_info[*item].client_name;
 
			while (GetNetworkClientInfo(*item)->client_id == INVALID_CLIENT_ID && *item < MAX_CLIENT_INFO) (*item)++;
 
			if (*item < MAX_CLIENT_INFO) return GetNetworkClientInfo(*item)->client_name;
 
		}
 

	
 
		/* Then, try townnames */
 
		/* Not that the following assumes all town indices are adjacent, ie no
 
		* towns have been deleted. */
 
		if (*item <= (uint)MAX_CLIENT_INFO + GetMaxTownIndex()) {
src/network/network_func.h
Show inline comments
 
@@ -61,10 +61,8 @@ void NetworkServerSendChat(NetworkAction
 

	
 
void NetworkInitChatMessage();
 
void CDECL NetworkAddChatMessage(uint16 color, uint8 duration, const char *message, ...);
 
void NetworkUndrawChatMessage();
 
void NetworkChatMessageDailyLoop();
 

	
 
#define FOR_ALL_CLIENT_INFOS(ci) for (ci = _network_client_info; ci != endof(_network_client_info); ci++) if (ci->client_id != INVALID_CLIENT_ID)
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_FUNC_H */
src/network/network_internal.h
Show inline comments
 
@@ -6,12 +6,13 @@
 
#define NETWORK_INTERNAL_H
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
#include "network.h"
 
#include "network_func.h"
 
#include "network_base.h"
 
#include "core/os_abstraction.h"
 
#include "core/core.h"
 
#include "core/config.h"
 
#include "core/packet.h"
 
#include "core/tcp.h"
 

	
 
@@ -88,14 +89,12 @@ enum NetworkLanguage {
 
	NETLANG_GALICIAN,
 
	NETLANG_GREEK,
 
	NETLANG_LATVIAN,
 
	NETLANG_COUNT
 
};
 

	
 
extern NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
 

	
 
extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
 
extern uint32 _frame_counter_max; // To where we may go with our clients
 

	
 
extern uint32 _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients.
 

	
 
// networking settings
src/network/network_type.h
Show inline comments
 
@@ -50,21 +50,13 @@ struct NetworkCompanyStats {
 
/** Some state information of a company, especially for servers */
 
struct NetworkCompanyState {
 
	char password[NETWORK_PASSWORD_LENGTH];         ///< The password for the company
 
	uint16 months_empty;                            ///< How many months the company is empty
 
};
 

	
 
struct NetworkClientInfo {
 
	ClientID client_id;                             ///< Client identifier (same as ClientState->client_id)
 
	char client_name[NETWORK_CLIENT_NAME_LENGTH];   ///< Name of the client
 
	byte client_lang;                               ///< The language of the client
 
	CompanyID client_playas;                        ///< As which company is this client playing (CompanyID)
 
	uint32 client_ip;                               ///< IP-address of the client (so he can be banned)
 
	Date join_date;                                 ///< Gamedate the client has joined
 
	char unique_id[NETWORK_UNIQUE_ID_LENGTH];       ///< Every play sends an unique id so we can indentify him
 
};
 
struct NetworkClientInfo;
 

	
 
enum NetworkPasswordType {
 
	NETWORK_GAME_PASSWORD,
 
	NETWORK_COMPANY_PASSWORD,
 
};
 

	
0 comments (0 inline, 0 general)