Mercurial > hg > openttd
changeset 9650:548d152a87d5 draft
(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.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 17 Jul 2008 15:16:11 +0000 |
parents | 4bd4c7e6daf2 |
children | f93fb4d96ea5 |
files | src/players.cpp |
diffstat | 1 files changed, 6 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/players.cpp +++ b/src/players.cpp @@ -823,6 +823,11 @@ switch (p1) { 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: * _local_player: PLAYER_SPECTATOR * _network_playas/cid = requested company/player @@ -830,28 +835,19 @@ * Other client(s)/server: * _local_player/_network_playas: what they play as * cid = requested company/player of joining client */ - Player *p; -#ifdef ENABLE_NETWORK 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? */ if (!(flags & DC_EXEC)) return CommandCost(); -#ifdef ENABLE_NETWORK if (cid >= MAX_CLIENT_INFO) return CommandCost(); -#endif /* ENABLE_NETWORK */ /* Delete multiplayer progress bar */ 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 */ if (p == NULL) { -#ifdef ENABLE_NETWORK if (_network_server) { NetworkClientInfo *ci = &_network_client_info[cid]; ci->client_playas = PLAYER_SPECTATOR; @@ -859,7 +855,6 @@ } else if (_local_player == PLAYER_SPECTATOR) { _network_playas = PLAYER_SPECTATOR; } -#endif /* ENABLE_NETWORK */ break; } @@ -867,12 +862,10 @@ if (_local_player != _network_playas && _network_playas == p->index) { assert(_local_player == PLAYER_SPECTATOR); SetLocalPlayer(p->index); -#ifdef ENABLE_NETWORK if (!StrEmpty(_settings_client.network.default_company_pass)) { char *password = _settings_client.network.default_company_pass; NetworkChangeCompanyPassword(1, &password); } -#endif /* ENABLE_NETWORK */ MarkWholeScreenDirty(); } @@ -885,7 +878,6 @@ CMD_SET_AUTOREPLACE ); -#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