# HG changeset patch # User truebrain # Date 1214861483 0 # Node ID 1b984dab8cec08bf673471866fe9848fe5088898 # Parent 8e553098ad05c88e24a19ccb9949b76a6f0740d5 (svn r13669) [NoAI] -Fix: allow clients only to join non-AI controlled companies in multiplayer diff -r 8e553098ad05 -r 1b984dab8cec src/network/core/config.h --- a/src/network/core/config.h Mon Jun 30 21:27:53 2008 +0000 +++ b/src/network/core/config.h Mon Jun 30 21:31:23 2008 +0000 @@ -20,7 +20,7 @@ SEND_MTU = 1460, ///< Number of bytes we can pack in a single packet NETWORK_GAME_INFO_VERSION = 4, ///< What version of game-info do we use? - NETWORK_COMPANY_INFO_VERSION = 4, ///< What version of company info is this? + NETWORK_COMPANY_INFO_VERSION = 5, ///< What version of company info is this? NETWORK_MASTER_SERVER_VERSION = 1, ///< What version of master-server-protocol do we use? NETWORK_NAME_LENGTH = 80, ///< The maximum length of the server name and map name, in bytes including '\0' diff -r 8e553098ad05 -r 1b984dab8cec src/network/network_client.cpp --- a/src/network/network_client.cpp Mon Jun 30 21:27:53 2008 +0000 +++ b/src/network/network_client.cpp Mon Jun 30 21:31:23 2008 +0000 @@ -376,6 +376,7 @@ _network_player_info[current].income = p->Recv_uint64(); _network_player_info[current].performance = p->Recv_uint16(); _network_player_info[current].use_password = p->Recv_bool(); + _network_player_info[current].ai = p->Recv_bool(); for (i = 0; i < NETWORK_VEHICLE_TYPES; i++) _network_player_info[current].num_vehicle[i] = p->Recv_uint16(); for (i = 0; i < NETWORK_STATION_TYPES; i++) diff -r 8e553098ad05 -r 1b984dab8cec src/network/network_gui.cpp --- a/src/network/network_gui.cpp Mon Jun 30 21:27:53 2008 +0000 +++ b/src/network/network_gui.cpp Mon Jun 30 21:31:23 2008 +0000 @@ -988,7 +988,7 @@ int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos; /* Join button is disabled when no company is selected */ - this->SetWidgetDisabledState(NLWW_JOIN, this->company == INVALID_PLAYER); + this->SetWidgetDisabledState(NLWW_JOIN, this->company == INVALID_PLAYER || _network_player_info[company].ai); /* Cannot start new company if there are too many */ this->SetWidgetDisabledState(NLWW_NEW, gi->companies_on >= gi->companies_max); /* Cannot spectate if there are too many spectators */ diff -r 8e553098ad05 -r 1b984dab8cec src/network/network_server.cpp --- a/src/network/network_server.cpp Mon Jun 30 21:27:53 2008 +0000 +++ b/src/network/network_server.cpp Mon Jun 30 21:31:23 2008 +0000 @@ -108,6 +108,7 @@ /* Send 1 if there is a passord for the company else send 0 */ p->Send_bool(!StrEmpty(_network_player_info[player->index].password)); + p->Send_bool(_network_player_info[player->index].ai); for (i = 0; i < NETWORK_VEHICLE_TYPES; i++) { p->Send_uint16(_network_player_info[player->index].num_vehicle[i]); @@ -679,7 +680,7 @@ } break; default: /* Join another company (companies 1-8 (index 0-7)) */ - if (!IsValidPlayer(playas)) { + if (!IsValidPlayer(playas) || !IsHumanPlayer(playas)) { SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH); return; } @@ -1335,6 +1336,7 @@ _network_player_info[p->index].company_value = p->old_economy[0].company_value; _network_player_info[p->index].money = p->player_money; _network_player_info[p->index].performance = p->old_economy[0].performance_history; + _network_player_info[p->index].ai = p->is_ai; } // Go through all vehicles and count the type of vehicles diff -r 8e553098ad05 -r 1b984dab8cec src/network/network_type.h --- a/src/network/network_type.h Mon Jun 30 21:27:53 2008 +0000 +++ b/src/network/network_type.h Mon Jun 30 21:31:23 2008 +0000 @@ -47,6 +47,7 @@ uint16 num_station[NETWORK_STATION_TYPES]; ///< How many stations are there of this type? char players[NETWORK_PLAYERS_LENGTH]; ///< The players that control this company (Name1, name2, ..) uint16 months_empty; ///< How many months the company is empty + bool ai; ///< Is this company an AI }; struct NetworkClientInfo {