diff options
-rw-r--r-- | ai/ai.c | 22 | ||||
-rw-r--r-- | ai/ai.h | 4 | ||||
-rw-r--r-- | ai/trolly/trolly.c | 4 | ||||
-rw-r--r-- | economy.c | 2 | ||||
-rw-r--r-- | network_client.c | 18 | ||||
-rw-r--r-- | openttd.c | 8 | ||||
-rw-r--r-- | players.c | 16 |
7 files changed, 7 insertions, 67 deletions
@@ -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; } @@ -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 @@ -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; @@ -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(); @@ -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) { |