Changeset - r17313:722abf9129a8
[Not reviewed]
master
0 3 0
rubidium - 14 years ago 2011-02-11 22:10:10
rubidium@openttd.org
(svn r22063) -Change: make the "has network" check also check whether the client is actually fully connected
3 files changed with 13 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/console_cmds.cpp
Show inline comments
 
@@ -16,12 +16,13 @@
 
#include "landscape.h"
 
#include "saveload/saveload.h"
 
#include "network/network.h"
 
#include "network/network_func.h"
 
#include "network/network_base.h"
 
#include "network/network_admin.h"
 
#include "network/network_client.h"
 
#include "command_func.h"
 
#include "settings_func.h"
 
#include "fios.h"
 
#include "fileio_func.h"
 
#include "screenshot.h"
 
#include "genworld.h"
 
@@ -87,13 +88,13 @@ DEF_CONSOLE_HOOK(ConHookClientOnly)
 
}
 

	
 
DEF_CONSOLE_HOOK(ConHookNeedNetwork)
 
{
 
	if (!NetworkAvailable(echo)) return CHR_DISALLOW;
 

	
 
	if (!_networking) {
 
	if (!_networking || (!_network_server && !MyClient::IsConnected())) {
 
		if (echo) IConsoleError("Not connected. This command is only available in multiplayer.");
 
		return CHR_DISALLOW;
 
	}
 
	return CHR_ALLOW;
 
}
 

	
src/network/network_client.cpp
Show inline comments
 
@@ -460,12 +460,21 @@ NetworkRecvStatus ClientNetworkGameSocke
 
	p->Send_uint8(company);
 
	p->Send_string(GenerateCompanyPasswordHash(password, _password_server_id, _password_game_seed));
 
	my_client->SendPacket(p);
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 

	
 
/**
 
 * Check whether the client is actually connected (and in the game).
 
 * @return True when the client is connected.
 
 */
 
bool ClientNetworkGameSocketHandler::IsConnected()
 
{
 
	return my_client != NULL && my_client->status == STATUS_ACTIVE;
 
}
 

	
 

	
 
/***********
 
 * Receiving functions
 
 *   DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
 
 ************/
 

	
src/network/network_client.h
Show inline comments
 
@@ -97,12 +97,14 @@ public:
 
	static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data);
 
	static NetworkRecvStatus SendSetPassword(const char *password);
 
	static NetworkRecvStatus SendSetName(const char *name);
 
	static NetworkRecvStatus SendRCon(const char *password, const char *command);
 
	static NetworkRecvStatus SendMove(CompanyID company, const char *password);
 

	
 
	static bool IsConnected();
 

	
 
	static void Send();
 
	static bool Receive();
 
	static bool GameLoop();
 
};
 

	
 
typedef ClientNetworkGameSocketHandler MyClient;
0 comments (0 inline, 0 general)