|
@@ -818,15 +818,17 @@ int32 CmdPlayerCtrl(TileIndex tile, uint
|
|
|
{
|
|
|
if (flags & DC_EXEC) _current_player = OWNER_NONE;
|
|
|
|
|
|
switch (p1) {
|
|
|
case 0: { /* Create a new player */
|
|
|
Player *p;
|
|
|
PlayerID pid = p2;
|
|
|
uint16 cid = p2; // ClientID
|
|
|
|
|
|
if (!(flags & DC_EXEC) || !IsValidPlayer(pid)) return 0;
|
|
|
/* ClientID would be valid up to MAX_CLIENT_INFO, but as it has to be a
|
|
|
* new player, its valid range is restricted to that of players */
|
|
|
if (!(flags & DC_EXEC) || !IsValidPlayer((PlayerID)cid)) return 0;
|
|
|
|
|
|
p = DoStartupNewPlayer(false);
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
if (_networking && !_network_server && _local_player == PLAYER_SPECTATOR) {
|
|
|
/* In case we are a client joining a server... */
|
|
@@ -848,13 +850,13 @@ int32 CmdPlayerCtrl(TileIndex tile, uint
|
|
|
}
|
|
|
#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];
|
|
|
NetworkClientInfo *ci = &_network_client_info[cid];
|
|
|
ci->client_playas = p->index + 1;
|
|
|
NetworkUpdateClientInfo(ci->client_index);
|
|
|
|
|
|
if (ci->client_playas != 0 && ci->client_playas <= MAX_PLAYERS) {
|
|
|
PlayerID player_backup = _local_player;
|
|
|
_network_player_info[p->index].months_empty = 0;
|
|
@@ -878,13 +880,13 @@ int32 CmdPlayerCtrl(TileIndex tile, uint
|
|
|
}
|
|
|
} else if (_network_server) {
|
|
|
// Creating player failed, defer client to spectator
|
|
|
/* 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];
|
|
|
NetworkClientInfo *ci = &_network_client_info[cid];
|
|
|
ci->client_playas = PLAYER_SPECTATOR;
|
|
|
NetworkUpdateClientInfo(ci->client_index);
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
}
|
|
|
} break;
|
|
|
|