(svn r16245) [0.7] -Backport from trunk:

- Fix: Hardcoded (old sized) MAX_COMPANIES constant (r16182)
- Fix: Do not try to reserve path for trains crashed in station [FS#2866] (r16178)
- Fix: Forbid joining AI companies via the 'move' and 'join' console commands/multiplayer lobby (r16176, r16175)
- Fix: The overflowsafe type did not like dividing by int64 larger than MAX_INT32 causing division by negative numbers and small anomolies when drawing graphs [FS#2855] (r16130)
This commit is contained in:
rubidium 2009-05-06 22:21:32 +00:00
parent 28e7981a5b
commit 07a16f9282
7 changed files with 19 additions and 4 deletions

View File

@ -640,6 +640,11 @@ DEF_CONSOLE_CMD(ConJoinCompany)
return true;
}
if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) {
IConsoleError("Cannot join AI company.");
return true;
}
/* Check if the company requires a password */
if (NetworkCompanyIsPassworded(company_id) && argc < 3) {
IConsolePrintF(CC_ERROR, "Company %d requires a password to join.", company_id + 1);
@ -678,6 +683,11 @@ DEF_CONSOLE_CMD(ConMoveClient)
return true;
}
if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) {
IConsoleError("You cannot move clients to AI companies.");
return true;
}
if (ci->client_id == CLIENT_ID_SERVER && _network_dedicated) {
IConsoleError("Silly boy, you cannot move the server!");
return true;

View File

@ -86,7 +86,7 @@ public:
FORCEINLINE OverflowSafeInt operator * (const byte factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
/* Operators for division */
FORCEINLINE OverflowSafeInt& operator /= (const int divisor) { this->m_value /= divisor; return *this; }
FORCEINLINE OverflowSafeInt& operator /= (const int64 divisor) { this->m_value /= divisor; return *this; }
FORCEINLINE OverflowSafeInt operator / (const OverflowSafeInt& divisor) const { OverflowSafeInt result = *this; result /= divisor.m_value; return result; }
FORCEINLINE OverflowSafeInt operator / (const int divisor) const { OverflowSafeInt result = *this; result /= divisor; return result; }
FORCEINLINE OverflowSafeInt operator / (const uint divisor) const { OverflowSafeInt result = *this; result /= (int)divisor; return result; }

View File

@ -520,7 +520,7 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
Point pt;
const ViewPort *vp;
if (msg_1 != STR_013B_OWNED_BY || GetDParam(2) >= 8) {
if (msg_1 != STR_013B_OWNED_BY || GetDParam(2) >= MAX_COMPANIES) {
if ((x | y) != 0) {
pt = RemapCoords2(x, y);
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;

View File

@ -23,7 +23,7 @@ enum {
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 = 5, ///< What version of company info is this?
NETWORK_COMPANY_INFO_VERSION = 6, ///< 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'

View File

@ -380,6 +380,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
company_info->num_vehicle[i] = p->Recv_uint16();
for (int i = 0; i < NETWORK_STATION_TYPES; i++)
company_info->num_station[i] = p->Recv_uint16();
company_info->ai = p->Recv_bool();
p->Recv_string(company_info->clients, sizeof(company_info->clients));

View File

@ -1235,6 +1235,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MOVE)
/* Check if the company is valid */
if (!IsValidCompanyID(company_id) && company_id != COMPANY_SPECTATOR) return;
/* We don't allow moving to AI companies */
if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) return;
/* Check if we require a password for this company */
if (company_id != COMPANY_SPECTATOR && !StrEmpty(_network_company_states[company_id].password)) {
@ -1344,6 +1346,8 @@ void NetworkSocketHandler::Send_CompanyInformation(Packet *p, const Company *c,
for (int i = 0; i < NETWORK_STATION_TYPES; i++) {
p->Send_uint16(stats->num_station[i]);
}
p->Send_bool(c->is_ai);
}
/**

View File

@ -1531,7 +1531,7 @@ void Vehicle::LeaveStation()
HideFillingPercent(&this->fill_percent_te_id);
if (this->type == VEH_TRAIN) {
if (this->type == VEH_TRAIN && !(this->vehstatus & VS_CRASHED)) {
/* Trigger station animation (trains only) */
if (IsTileType(this->tile, MP_STATION)) StationAnimationTrigger(st, this->tile, STAT_ANIM_TRAIN_DEPARTS);