1
0
Fork 0

(svn r13717) -Codechange: place the whole 'create new company' command in #ifdef ENABLE_NETWORK as it may only be executed when we are playing in a network game.

release/0.7
rubidium 2008-07-17 15:16:11 +00:00
parent 39beec190b
commit 227085622a
1 changed files with 6 additions and 14 deletions

View File

@ -823,6 +823,11 @@ CommandCost CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
switch (p1) { switch (p1) {
case 0: { /* Create a new player */ case 0: { /* Create a new player */
/* This command is only executed in a multiplayer game */
if (!_networking) return CMD_ERROR;
#ifdef ENABLE_NETWORK
/* Joining Client: /* Joining Client:
* _local_player: PLAYER_SPECTATOR * _local_player: PLAYER_SPECTATOR
* _network_playas/cid = requested company/player * _network_playas/cid = requested company/player
@ -830,28 +835,19 @@ CommandCost CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* Other client(s)/server: * Other client(s)/server:
* _local_player/_network_playas: what they play as * _local_player/_network_playas: what they play as
* cid = requested company/player of joining client */ * cid = requested company/player of joining client */
Player *p;
#ifdef ENABLE_NETWORK
uint16 cid = p2; // ClientID uint16 cid = p2; // ClientID
#endif /* ENABLE_NETWORK */
/* This command is only executed in a multiplayer game */
if (!_networking) return CMD_ERROR;
/* Has the network client a correct ClientID? */ /* Has the network client a correct ClientID? */
if (!(flags & DC_EXEC)) return CommandCost(); if (!(flags & DC_EXEC)) return CommandCost();
#ifdef ENABLE_NETWORK
if (cid >= MAX_CLIENT_INFO) return CommandCost(); if (cid >= MAX_CLIENT_INFO) return CommandCost();
#endif /* ENABLE_NETWORK */
/* Delete multiplayer progress bar */ /* Delete multiplayer progress bar */
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
p = DoStartupNewPlayer(false); Player *p = DoStartupNewPlayer(false);
/* A new player could not be created, revert to being a spectator */ /* A new player could not be created, revert to being a spectator */
if (p == NULL) { if (p == NULL) {
#ifdef ENABLE_NETWORK
if (_network_server) { if (_network_server) {
NetworkClientInfo *ci = &_network_client_info[cid]; NetworkClientInfo *ci = &_network_client_info[cid];
ci->client_playas = PLAYER_SPECTATOR; ci->client_playas = PLAYER_SPECTATOR;
@ -859,7 +855,6 @@ CommandCost CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} else if (_local_player == PLAYER_SPECTATOR) { } else if (_local_player == PLAYER_SPECTATOR) {
_network_playas = PLAYER_SPECTATOR; _network_playas = PLAYER_SPECTATOR;
} }
#endif /* ENABLE_NETWORK */
break; break;
} }
@ -867,12 +862,10 @@ CommandCost CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (_local_player != _network_playas && _network_playas == p->index) { if (_local_player != _network_playas && _network_playas == p->index) {
assert(_local_player == PLAYER_SPECTATOR); assert(_local_player == PLAYER_SPECTATOR);
SetLocalPlayer(p->index); SetLocalPlayer(p->index);
#ifdef ENABLE_NETWORK
if (!StrEmpty(_settings_client.network.default_company_pass)) { if (!StrEmpty(_settings_client.network.default_company_pass)) {
char *password = _settings_client.network.default_company_pass; char *password = _settings_client.network.default_company_pass;
NetworkChangeCompanyPassword(1, &password); NetworkChangeCompanyPassword(1, &password);
} }
#endif /* ENABLE_NETWORK */
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
@ -885,7 +878,6 @@ CommandCost CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
CMD_SET_AUTOREPLACE CMD_SET_AUTOREPLACE
); );
#ifdef ENABLE_NETWORK
if (_network_server) { if (_network_server) {
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at /* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
* server-side in network_server.c:838, function * server-side in network_server.c:838, function