summaryrefslogtreecommitdiff
path: root/network_client.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-11-22 15:55:38 +0000
committertruelight <truelight@openttd.org>2005-11-22 15:55:38 +0000
commite4cb8ed4570f53fc26367371e8d680882f0e70e6 (patch)
tree6702beccddba7217fe3ad311ffda9285b6719e5d /network_client.c
parent28df667ceb7fa74a1146a2bede0a908bc9dd3eb4 (diff)
downloadopenttd-e4cb8ed4570f53fc26367371e8d680882f0e70e6.tar.xz
(svn r3226) -Fix: GPMI implementation had minor glitches
-Fix: the AI speed control is done by the AI-core, individual AIs don't have to do it (so, AIs were delayed twice ;) -Add: Support for AI-network-clients (an AI, connecting to a remote server) -Fix: minor AI-core problems
Diffstat (limited to 'network_client.c')
-rw-r--r--network_client.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/network_client.c b/network_client.c
index 6da4b0618..0f552f4a3 100644
--- a/network_client.c
+++ b/network_client.c
@@ -19,6 +19,7 @@
#include "settings.h"
#include "console.h"
#include "variables.h"
+#include "ai/ai.h"
// This file handles all the client-commands
@@ -342,9 +343,18 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
return NETWORK_RECV_STATUS_CONN_LOST;
/* Do we receive a change of data? Most likely we changed playas */
- if (index == _network_own_client_index)
+ if (index == _network_own_client_index) {
_network_playas = playas;
+ /* Are we a ai-network-client? */
+ if (_ai.network_client) {
+ if (_ai.network_playas == OWNER_SPECTATOR)
+ AI_StartNewAI(playas - 1);
+
+ _ai.network_playas = playas - 1;
+ }
+ }
+
ci = NetworkFindClientInfoFromIndex(index);
if (ci != NULL) {
if (playas == ci->client_playas && strcmp(name, ci->client_name) != 0) {
@@ -532,6 +542,17 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
_patches.autorenew_money = GetPlayer(_local_player)->engine_renew_money;
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
}
+
+ /* Check if we are an ai-network-client, and if so, disable GUI */
+ if (_ai.network_client) {
+ _ai.network_playas = _local_player;
+ _local_player = OWNER_SPECTATOR;
+
+ if (_ai.network_playas != OWNER_SPECTATOR) {
+ /* If we didn't join the game as a spectator, activate the AI */
+ AI_StartNewAI(_ai.network_playas);
+ }
+ }
}
return NETWORK_RECV_STATUS_OKAY;