summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-10-15 17:01:19 +0000
committerDarkvater <darkvater@openttd.org>2006-10-15 17:01:19 +0000
commitb2110cbaedbbbbb18769e4594f416dfef1c733fd (patch)
tree2918811729d57202b30a05affd69972a8168873b
parent5a1ee9e02b21b6be130beda5d2c6a51c8b00239f (diff)
downloadopenttd-b2110cbaedbbbbb18769e4594f416dfef1c733fd.tar.xz
(svn r6780) -Codechange: Remove GPMI leftovers (-b impersonisation of AI in MP).
-rw-r--r--ai/ai.c22
-rw-r--r--ai/ai.h4
-rw-r--r--ai/trolly/trolly.c4
-rw-r--r--economy.c2
-rw-r--r--network_client.c18
-rw-r--r--openttd.c8
-rw-r--r--players.c16
7 files changed, 7 insertions, 67 deletions
diff --git a/ai/ai.c b/ai/ai.c
index 9072d8fe6..8068227d0 100644
--- a/ai/ai.c
+++ b/ai/ai.c
@@ -170,12 +170,8 @@ void AI_RunGameLoop(void)
/* 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 @@ void AI_RunGameLoop(void)
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_StartNewAI(PlayerID player)
*/
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_PlayerDied(PlayerID player)
*/
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;
}
diff --git a/ai/ai.h b/ai/ai.h
index 440d3347a..aedb5b5cd 100644
--- a/ai/ai.h
+++ b/ai/ai.h
@@ -32,10 +32,6 @@ typedef struct AIStruct {
/* 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;
diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c
index e15356379..d952975b9 100644
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -48,9 +48,7 @@ static void AiNew_State_FirstTime(Player *p)
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
diff --git a/economy.c b/economy.c
index e61556ed4..36bab82ab 100644
--- a/economy.c
+++ b/economy.c
@@ -449,8 +449,6 @@ static void PlayersCheckBankrupt(Player *p)
if (!IsHumanPlayer(owner) && (!_networking || _network_server) && _ai.enabled)
AI_PlayerDied(owner);
- if (IsHumanPlayer(owner) && owner == _local_player && _ai.network_client)
- AI_PlayerDied(owner);
}
}
}
diff --git a/network_client.c b/network_client.c
index 95e66a4d2..8f6379a67 100644
--- a/network_client.c
+++ b/network_client.c
@@ -340,13 +340,6 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
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 @@ 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 = 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;
diff --git a/openttd.c b/openttd.c
index a99cdc32c..7bbd25023 100644
--- a/openttd.c
+++ b/openttd.c
@@ -338,7 +338,7 @@ int ttd_main(int argc, char *argv[])
// 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 @@ int ttd_main(int argc, char *argv[])
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 @@ int ttd_main(int argc, char *argv[])
}
}
- 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();
diff --git a/players.c b/players.c
index e95a451a8..11d3957b8 100644
--- a/players.c
+++ b/players.c
@@ -835,24 +835,12 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
#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) {