changeset 4854:21fdf9f5e355 draft

(svn r6780) -Codechange: Remove GPMI leftovers (-b impersonisation of AI in MP).
author Darkvater <Darkvater@openttd.org>
date Sun, 15 Oct 2006 17:01:19 +0000
parents f20236ff8212
children f3c5eb1c7c1b
files ai/ai.c ai/ai.h ai/trolly/trolly.c economy.c network_client.c openttd.c players.c
diffstat 7 files changed, 7 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/ai/ai.c
+++ b/ai/ai.c
@@ -170,12 +170,8 @@
 	/* Don't do anything if ai is disabled */
 	if (!_ai.enabled) return;
 
-	/* Don't do anything if we are a network-client
-	 *  (too bad when a client joins, he thinks the AIs are real, so it wants to control
-	 *   them.. this avoids that, while loading a network game in singleplayer, does make
-	 *   the AIs to continue ;))
-	 */
-	if (_networking && !_network_server && !_ai.network_client) return;
+	/* Don't do anything if we are a network-client */
+	if (_networking && !_network_server) return;
 
 	/* New tick */
 	_ai.tick++;
@@ -185,11 +181,7 @@
 	if ((_ai.tick & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0) return;
 
 	/* Check for AI-client (so joining a network with an AI) */
-	if (_ai.network_client && _ai_player[_ai.network_playas].active) {
-		/* Run the script */
-		AI_DequeueCommands(_ai.network_playas);
-		AI_RunTick(_ai.network_playas);
-	} else if (!_networking || _network_server) {
+	if (!_networking || _network_server) {
 		/* Check if we want to run AIs (server or SP only) */
 		const Player* p;
 
@@ -224,10 +216,6 @@
  */
 void AI_PlayerDied(PlayerID player)
 {
-	if (_ai.network_client && _ai.network_playas == player) {
-		_ai.network_playas = PLAYER_SPECTATOR;
-	}
-
 	/* Called if this AI died */
 	_ai_player[player].active = false;
 }
@@ -237,16 +225,12 @@
  */
 void AI_Initialize(void)
 {
-	bool ai_network_client = _ai.network_client;
-
 	/* First, make sure all AIs are DEAD! */
 	AI_Uninitialize();
 
 	memset(&_ai, 0, sizeof(_ai));
 	memset(&_ai_player, 0, sizeof(_ai_player));
 
-	_ai.network_client = ai_network_client;
-	_ai.network_playas = PLAYER_SPECTATOR;
 	_ai.enabled = true;
 }
 
--- a/ai/ai.h
+++ b/ai/ai.h
@@ -32,10 +32,6 @@
 	/* General */
 	bool enabled;           ///< Is AI enabled?
 	uint tick;              ///< The current tick (something like _frame_counter, only for AIs)
-
-	/* For network-clients (a OpenTTD client who acts as an AI connected to a server) */
-	bool network_client;    ///< Are we a network_client?
-	uint8 network_playas;   ///< The current network player we are connected as
 } AIStruct;
 
 VARDEF AIStruct _ai;
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -48,9 +48,7 @@
 	assert(p->ainew.state == AI_STATE_FIRST_TIME);
 	// We first have to init some things
 
-	if (_current_player == 1 || _ai.network_client) {
-		ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_IN_PROGRESS, 0, 0);
-	}
+	if (_current_player == 1) ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_IN_PROGRESS, 0, 0);
 
 	// The PathFinder (AyStar)
 	// TODO: Maybe when an AI goes bankrupt, this is de-init
--- a/economy.c
+++ b/economy.c
@@ -449,8 +449,6 @@
 
 				if (!IsHumanPlayer(owner) && (!_networking || _network_server) && _ai.enabled)
 					AI_PlayerDied(owner);
-				if (IsHumanPlayer(owner) && owner == _local_player && _ai.network_client)
-					AI_PlayerDied(owner);
 			}
 		}
 	}
--- a/network_client.c
+++ b/network_client.c
@@ -340,13 +340,6 @@
 	if (index == _network_own_client_index) {
 		_network_playas = playas;
 
-		/* Are we a ai-network-client? Are we not joining as a SPECTATOR (playas == 0, means SPECTATOR) */
-		if (_ai.network_client && playas != 0) {
-			if (_ai.network_playas == PLAYER_SPECTATOR)
-				AI_StartNewAI(playas - 1);
-
-			_ai.network_playas = playas - 1;
-		}
 	}
 
 	ci = NetworkFindClientInfoFromIndex(index);
@@ -540,17 +533,6 @@
 			_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      = PLAYER_SPECTATOR;
-
-			if (_ai.network_playas != PLAYER_SPECTATOR) {
-				/* If we didn't join the game as a spectator, activate the AI */
-				AI_StartNewAI(_ai.network_playas);
-			}
-		}
 	}
 
 	return NETWORK_RECV_STATUS_OKAY;
--- a/openttd.c
+++ b/openttd.c
@@ -338,7 +338,7 @@
 	//   a letter means: it accepts that param (e.g.: -h)
 	//   a ':' behind it means: it need a param (e.g.: -m<driver>)
 	//   a '::' behind it means: it can optional have a param (e.g.: -d<debug>)
-	optformat = "bm:s:v:hDn::eit:d::r:g::G:c:"
+	optformat = "m:s:v:hDn::eit:d::r:g::G:c:"
 #if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
 		"f"
 #endif
@@ -361,7 +361,6 @@
 			network = true;
 			network_conn = mgo.opt; // optional IP parameter, NULL if unset
 			break;
-		case 'b': _ai.network_client = true; break;
 		case 'r': ParseResolution(resolution, mgo.opt); break;
 		case 't': startyear = atoi(mgo.opt); break;
 		case 'd': {
@@ -389,11 +388,6 @@
 		}
 	}
 
-	if (_ai.network_client && !network) {
-		_ai.network_client = false;
-		DEBUG(ai, 0) ("[AI] Can't enable network-AI, because '-n' is not used\n");
-	}
-
 	DeterminePaths();
 	CheckExternalFiles();
 
--- a/players.c
+++ b/players.c
@@ -835,24 +835,12 @@
 #endif /* ENABLE_NETWORK */
 
 		if (p != NULL) {
-			if (_local_player == PLAYER_SPECTATOR &&
-					(!_ai.network_client || _ai.network_playas == PLAYER_SPECTATOR)) {
+			if (_local_player == PLAYER_SPECTATOR) {
 				/* Check if we do not want to be a spectator in network */
 				if (!_networking ||
 						(_network_server && !_network_dedicated) ||
-						_network_playas != PLAYER_SPECTATOR ||
-						_ai.network_client) {
-					if (_ai.network_client) {
-						/* As ai-network-client, we have our own rulez (disable GUI and stuff) */
-						_ai.network_playas = p->index;
-						_local_player      = PLAYER_SPECTATOR;
-						if (_ai.network_playas != PLAYER_SPECTATOR) {
-							/* If we didn't join the game as a spectator, activate the AI */
-							AI_StartNewAI(_ai.network_playas);
-						}
-					} else {
+						_network_playas != PLAYER_SPECTATOR) {
 						_local_player = p->index;
-					}
 					MarkWholeScreenDirty();
 				}
 			} else if (p->index == _local_player) {