From 1dc5ba22105bc12ab13e79f3a8a22952d82f7c8e Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 11 Feb 2011 22:10:10 +0000 Subject: (svn r22063) -Change: make the "has network" check also check whether the client is actually fully connected --- src/console_cmds.cpp | 3 ++- src/network/network_client.cpp | 9 +++++++++ src/network/network_client.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index a8e4c3eb8..7cd18bd6e 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -19,6 +19,7 @@ #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" @@ -90,7 +91,7 @@ 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; } diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 2d75353df..9bf8ec0b4 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -463,6 +463,15 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendMove(CompanyID company, co 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 diff --git a/src/network/network_client.h b/src/network/network_client.h index 096544156..c1ded6035 100644 --- a/src/network/network_client.h +++ b/src/network/network_client.h @@ -100,6 +100,8 @@ public: 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(); -- cgit v1.2.3-54-g00ecf