(svn r6780) -Codechange: Remove GPMI leftovers (-b impersonisation of AI in MP).

This commit is contained in:
Darkvater
2006-10-15 17:01:19 +00:00
parent 5a1ee9e02b
commit b2110cbaed
7 changed files with 7 additions and 67 deletions

22
ai/ai.c
View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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