mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r6780) -Codechange: Remove GPMI leftovers (-b impersonisation of AI in MP).
This commit is contained in:
parent
5a1ee9e02b
commit
b2110cbaed
22
ai/ai.c
22
ai/ai.c
@ -170,12 +170,8 @@ void AI_RunGameLoop(void)
|
|||||||
/* Don't do anything if ai is disabled */
|
/* Don't do anything if ai is disabled */
|
||||||
if (!_ai.enabled) return;
|
if (!_ai.enabled) return;
|
||||||
|
|
||||||
/* Don't do anything if we are a network-client
|
/* 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
|
if (_networking && !_network_server) return;
|
||||||
* 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;
|
|
||||||
|
|
||||||
/* New tick */
|
/* New tick */
|
||||||
_ai.tick++;
|
_ai.tick++;
|
||||||
@ -185,11 +181,7 @@ void AI_RunGameLoop(void)
|
|||||||
if ((_ai.tick & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0) return;
|
if ((_ai.tick & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0) return;
|
||||||
|
|
||||||
/* Check for AI-client (so joining a network with an AI) */
|
/* Check for AI-client (so joining a network with an AI) */
|
||||||
if (_ai.network_client && _ai_player[_ai.network_playas].active) {
|
if (!_networking || _network_server) {
|
||||||
/* Run the script */
|
|
||||||
AI_DequeueCommands(_ai.network_playas);
|
|
||||||
AI_RunTick(_ai.network_playas);
|
|
||||||
} else if (!_networking || _network_server) {
|
|
||||||
/* Check if we want to run AIs (server or SP only) */
|
/* Check if we want to run AIs (server or SP only) */
|
||||||
const Player* p;
|
const Player* p;
|
||||||
|
|
||||||
@ -224,10 +216,6 @@ void AI_StartNewAI(PlayerID player)
|
|||||||
*/
|
*/
|
||||||
void AI_PlayerDied(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 */
|
/* Called if this AI died */
|
||||||
_ai_player[player].active = false;
|
_ai_player[player].active = false;
|
||||||
}
|
}
|
||||||
@ -237,16 +225,12 @@ void AI_PlayerDied(PlayerID player)
|
|||||||
*/
|
*/
|
||||||
void AI_Initialize(void)
|
void AI_Initialize(void)
|
||||||
{
|
{
|
||||||
bool ai_network_client = _ai.network_client;
|
|
||||||
|
|
||||||
/* First, make sure all AIs are DEAD! */
|
/* First, make sure all AIs are DEAD! */
|
||||||
AI_Uninitialize();
|
AI_Uninitialize();
|
||||||
|
|
||||||
memset(&_ai, 0, sizeof(_ai));
|
memset(&_ai, 0, sizeof(_ai));
|
||||||
memset(&_ai_player, 0, sizeof(_ai_player));
|
memset(&_ai_player, 0, sizeof(_ai_player));
|
||||||
|
|
||||||
_ai.network_client = ai_network_client;
|
|
||||||
_ai.network_playas = PLAYER_SPECTATOR;
|
|
||||||
_ai.enabled = true;
|
_ai.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
ai/ai.h
4
ai/ai.h
@ -32,10 +32,6 @@ typedef struct AIStruct {
|
|||||||
/* General */
|
/* General */
|
||||||
bool enabled; ///< Is AI enabled?
|
bool enabled; ///< Is AI enabled?
|
||||||
uint tick; ///< The current tick (something like _frame_counter, only for AIs)
|
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;
|
} AIStruct;
|
||||||
|
|
||||||
VARDEF AIStruct _ai;
|
VARDEF AIStruct _ai;
|
||||||
|
@ -48,9 +48,7 @@ static void AiNew_State_FirstTime(Player *p)
|
|||||||
assert(p->ainew.state == AI_STATE_FIRST_TIME);
|
assert(p->ainew.state == AI_STATE_FIRST_TIME);
|
||||||
// We first have to init some things
|
// We first have to init some things
|
||||||
|
|
||||||
if (_current_player == 1 || _ai.network_client) {
|
if (_current_player == 1) ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_IN_PROGRESS, 0, 0);
|
||||||
ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_IN_PROGRESS, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The PathFinder (AyStar)
|
// The PathFinder (AyStar)
|
||||||
// TODO: Maybe when an AI goes bankrupt, this is de-init
|
// 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)
|
if (!IsHumanPlayer(owner) && (!_networking || _network_server) && _ai.enabled)
|
||||||
AI_PlayerDied(owner);
|
AI_PlayerDied(owner);
|
||||||
if (IsHumanPlayer(owner) && owner == _local_player && _ai.network_client)
|
|
||||||
AI_PlayerDied(owner);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,13 +340,6 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
|
|||||||
if (index == _network_own_client_index) {
|
if (index == _network_own_client_index) {
|
||||||
_network_playas = playas;
|
_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);
|
ci = NetworkFindClientInfoFromIndex(index);
|
||||||
@ -540,17 +533,6 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
|
|||||||
_patches.autorenew_money = GetPlayer(_local_player)->engine_renew_money;
|
_patches.autorenew_money = GetPlayer(_local_player)->engine_renew_money;
|
||||||
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
|
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;
|
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 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 need a param (e.g.: -m<driver>)
|
||||||
// a '::' behind it means: it can optional have a param (e.g.: -d<debug>)
|
// 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)
|
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
|
||||||
"f"
|
"f"
|
||||||
#endif
|
#endif
|
||||||
@ -361,7 +361,6 @@ int ttd_main(int argc, char *argv[])
|
|||||||
network = true;
|
network = true;
|
||||||
network_conn = mgo.opt; // optional IP parameter, NULL if unset
|
network_conn = mgo.opt; // optional IP parameter, NULL if unset
|
||||||
break;
|
break;
|
||||||
case 'b': _ai.network_client = true; break;
|
|
||||||
case 'r': ParseResolution(resolution, mgo.opt); break;
|
case 'r': ParseResolution(resolution, mgo.opt); break;
|
||||||
case 't': startyear = atoi(mgo.opt); break;
|
case 't': startyear = atoi(mgo.opt); break;
|
||||||
case 'd': {
|
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();
|
DeterminePaths();
|
||||||
CheckExternalFiles();
|
CheckExternalFiles();
|
||||||
|
|
||||||
|
16
players.c
16
players.c
@ -835,24 +835,12 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
if (_local_player == PLAYER_SPECTATOR &&
|
if (_local_player == PLAYER_SPECTATOR) {
|
||||||
(!_ai.network_client || _ai.network_playas == PLAYER_SPECTATOR)) {
|
|
||||||
/* Check if we do not want to be a spectator in network */
|
/* Check if we do not want to be a spectator in network */
|
||||||
if (!_networking ||
|
if (!_networking ||
|
||||||
(_network_server && !_network_dedicated) ||
|
(_network_server && !_network_dedicated) ||
|
||||||
_network_playas != PLAYER_SPECTATOR ||
|
_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 {
|
|
||||||
_local_player = p->index;
|
_local_player = p->index;
|
||||||
}
|
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
} else if (p->index == _local_player) {
|
} else if (p->index == _local_player) {
|
||||||
|
Loading…
Reference in New Issue
Block a user