|
@@ -797,28 +797,38 @@ int32 CmdPlayerCtrl(int x, int y, uint32
|
|
|
|
|
|
if (!(flags & DC_EXEC) || pid >= MAX_PLAYERS) return 0;
|
|
|
|
|
|
p = DoStartupNewPlayer(false);
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
if (_networking && !_network_server && _local_player == OWNER_SPECTATOR)
|
|
|
/* In case we are a client joining a server... */
|
|
|
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
|
|
if (p != NULL) {
|
|
|
if (_local_player == OWNER_SPECTATOR) {
|
|
|
if (_local_player == OWNER_SPECTATOR && (!_ai.network_client || _ai.network_playas == OWNER_SPECTATOR)) {
|
|
|
/* Check if we do not want to be a spectator in network */
|
|
|
if (!_networking || (_network_server && !_network_dedicated) || _network_playas != OWNER_SPECTATOR) {
|
|
|
_local_player = p->index;
|
|
|
if (!_networking || (_network_server && !_network_dedicated) || _network_playas != OWNER_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 = OWNER_SPECTATOR;
|
|
|
if (_ai.network_playas != OWNER_SPECTATOR) {
|
|
|
/* If we didn't join the game as a spectator, activate the AI */
|
|
|
AI_StartNewAI(_ai.network_playas);
|
|
|
}
|
|
|
} else {
|
|
|
_local_player = p->index;
|
|
|
}
|
|
|
MarkWholeScreenDirty();
|
|
|
}
|
|
|
} else if (p->index == _local_player) {
|
|
|
DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_REPLACE_VEHICLE);
|
|
|
}
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
if (_network_server) {
|
|
|
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at server-side
|
|
|
* in network_server.c:838, function DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
|
|
|
NetworkClientInfo *ci = &_network_client_info[pid];
|
|
|
ci->client_playas = p->index + 1;
|
|
|
NetworkUpdateClientInfo(ci->client_index);
|