1
0
Fork 0

(svn r23052) [1.1] -Backport from trunk:

- Fix: Palette conversion windows to DOS for light house / stadium animated colour was mixed up (r23032)
- Fix: For the admin 'bots' there was no distinction between bankruptcy and manual removal of companies even though the API suggested that [FS#4804] (r23031)
- Fix: Always show a chat message and send an admin packet when a new company is made [FS#4796] (r23030)
- Fix: Pass bottom of dropdown item rather than bottom of dropdown window, so the dropdown gets drawn better with different font sizes (r23018)
release/1.1
rubidium 2011-10-22 20:54:23 +00:00
parent 83d41e122c
commit bf3c75c34c
10 changed files with 39 additions and 23 deletions

View File

@ -1002,7 +1002,7 @@ struct AIDebugWindow : public QueryStringBaseWindow {
switch (widget) {
case AID_WIDGET_RELOAD_TOGGLE:
/* First kill the company of the AI, then start a new one. This should start the current AI again */
DoCommandP(0, 2 | ai_debug_company << 16, 0, CMD_COMPANY_CTRL);
DoCommandP(0, 2 | ai_debug_company << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
DoCommandP(0, 1 | ai_debug_company << 16, 0, CMD_COMPANY_CTRL);
break;

View File

@ -773,13 +773,14 @@ void CompanyAdminUpdate(const Company *company)
}
/**
* Called whenever a company goes bankrupt in order to notify admins.
* @param company_id The company that went bankrupt.
* Called whenever a company is removed in order to notify admins.
* @param company_id The company that was removed.
* @param reason The reason the company was removed.
*/
void CompanyAdminBankrupt(CompanyID company_id)
void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
{
#ifdef ENABLE_NETWORK
if (_network_server) NetworkAdminCompanyRemove(company_id, ADMIN_CRR_BANKRUPT);
if (_network_server) NetworkAdminCompanyRemove(company_id, (AdminCompanyRemoveReason)reason);
#endif /* ENABLE_NETWORK */
}
@ -846,7 +847,6 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
if (_network_server) {
CompanyID old_playas = ci->client_playas;
ci->client_playas = c->index;
NetworkUpdateClientInfo(ci->client_id);
@ -869,11 +869,9 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
NetworkSendCommand(0, 0, 0, CMD_RENAME_PRESIDENT, NULL, ci->client_name, ci->client_playas);
}
/* Announce new company on network, if the client was a SPECTATOR before */
if (old_playas == COMPANY_SPECTATOR) {
NetworkAdminCompanyInfo(c, true);
NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, ci->client_playas + 1);
}
/* Announce new company on network. */
NetworkAdminCompanyInfo(c, true);
NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, ci->client_playas + 1);
}
#endif /* ENABLE_NETWORK */
break;
@ -887,6 +885,9 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
break;
case 2: { // Delete a company
CompanyRemoveReason reason = (CompanyRemoveReason)GB(p2, 0, 2);
if (reason >= CRR_END) return CMD_ERROR;
Company *c = Company::GetIfValid(company_id);
if (c == NULL) return CMD_ERROR;
@ -910,7 +911,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
CompanyID c_index = c->index;
delete c;
AI::BroadcastNewEvent(new AIEventCompanyBankrupt(c_index));
CompanyAdminBankrupt(c_index);
CompanyAdminRemove(c_index, (CompanyRemoveReason)reason);
break;
}

View File

@ -56,4 +56,13 @@ typedef uint16 CompanyMask;
struct Company;
typedef uint32 CompanyManagerFace; ///< Company manager face bits, info see in company_manager_face.h
/** The reason why the company was removed. */
enum CompanyRemoveReason {
CRR_MANUAL, ///< The company is manually removed.
CRR_AUTOCLEAN, ///< The company is removed due to autoclean.
CRR_BANKRUPT, ///< The company went belly-up.
CRR_END ///< Sentinel for end.
};
#endif /* COMPANY_TYPE_H */

View File

@ -836,7 +836,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
}
/* It is safe to remove this company */
DoCommandP(0, 2 | index << 16, 0, CMD_COMPANY_CTRL);
DoCommandP(0, 2 | index << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "Company deleted.");
return true;
@ -1196,7 +1196,7 @@ DEF_CONSOLE_CMD(ConReloadAI)
}
/* First kill the company of the AI, then start a new one. This should start the current AI again */
DoCommandP(0, 2 | company_id << 16, 0, CMD_COMPANY_CTRL);
DoCommandP(0, 2 | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
DoCommandP(0, 1 | company_id << 16, 0, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "AI reloaded.");
@ -1233,7 +1233,7 @@ DEF_CONSOLE_CMD(ConStopAI)
}
/* Now kill the company of the AI. */
DoCommandP(0, 2 | company_id << 16, 0, CMD_COMPANY_CTRL);
DoCommandP(0, 2 | company_id << 16, CRR_MANUAL, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "AI stopped, company deleted.");
return true;

View File

@ -546,7 +546,7 @@ static void CompanyCheckBankrupt(Company *c)
* that changing the current company is okay. In case of single
* player we are sure (the above check) that we are not the local
* company and thus we won't be moved. */
if (!_networking || _network_server) DoCommandP(0, 2 | (c->index << 16), 0, CMD_COMPANY_CTRL);
if (!_networking || _network_server) DoCommandP(0, 2 | (c->index << 16), CRR_BANKRUPT, CMD_COMPANY_CTRL);
break;
}
}

View File

@ -19,6 +19,12 @@
#include "tcp_admin.h"
#include "../../debug.h"
/* Make sure that these enums match. */
assert_compile((int)CRR_MANUAL == (int)ADMIN_CRR_MANUAL);
assert_compile((int)CRR_AUTOCLEAN == (int)ADMIN_CRR_AUTOCLEAN);
assert_compile((int)CRR_BANKRUPT == (int)ADMIN_CRR_BANKRUPT);
assert_compile((int)CRR_END == (int)ADMIN_CRR_END);
NetworkAdminSocketHandler::NetworkAdminSocketHandler(SOCKET s)
{
this->sock = s;

View File

@ -99,7 +99,9 @@ DECLARE_ENUM_AS_BIT_SET(AdminUpdateFrequency)
enum AdminCompanyRemoveReason {
ADMIN_CRR_MANUAL, ///< The company is manually removed.
ADMIN_CRR_AUTOCLEAN, ///< The company is removed due to autoclean.
ADMIN_CRR_BANKRUPT ///< The company went belly-up.
ADMIN_CRR_BANKRUPT, ///< The company went belly-up.
ADMIN_CRR_END ///< Sentinel for end.
};
#define DECLARE_ADMIN_RECEIVE_COMMAND(type) virtual NetworkRecvStatus NetworkPacketReceive_## type ##_command(Packet *p)

View File

@ -1574,8 +1574,7 @@ static void NetworkAutoCleanCompanies()
/* Is the company empty for autoclean_unprotected-months, and is there no protection? */
if (_settings_client.network.autoclean_unprotected != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_unprotected && StrEmpty(_network_company_states[c->index].password)) {
/* Shut the company down */
DoCommandP(0, 2 | c->index << 16, 0, CMD_COMPANY_CTRL);
NetworkAdminCompanyRemove(c->index, ADMIN_CRR_AUTOCLEAN);
DoCommandP(0, 2 | c->index << 16, CRR_AUTOCLEAN, CMD_COMPANY_CTRL);
IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d with no password", c->index + 1);
}
/* Is the company empty for autoclean_protected-months, and there is a protection? */
@ -1589,8 +1588,7 @@ static void NetworkAutoCleanCompanies()
/* Is the company empty for autoclean_novehicles-months, and has no vehicles? */
if (_settings_client.network.autoclean_novehicles != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_novehicles && vehicles_in_company[c->index] == 0) {
/* Shut the company down */
DoCommandP(0, 2 | c->index << 16, 0, CMD_COMPANY_CTRL);
NetworkAdminCompanyRemove(c->index, ADMIN_CRR_AUTOCLEAN);
DoCommandP(0, 2 | c->index << 16, CRR_AUTOCLEAN, CMD_COMPANY_CTRL);
IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d with no vehicles", c->index + 1);
}
} else {

View File

@ -41,7 +41,7 @@ static const byte _palmap_w2d[] = {
2, 245, 246, 247, 248, 249, 250, 251, // 216..223
252, 253, 254, 229, 230, 231, 227, 228, // 224..231
235, 236, 237, 238, 232, 233, 234, 239, // 232..239
240, 241, 242, 244, 243, 9, 218, 219, // 240..247
240, 241, 242, 243, 244, 9, 218, 219, // 240..247
220, 221, 222, 223, 224, 225, 226, 255, // 248..255
};

View File

@ -239,7 +239,7 @@ struct DropdownWindow : Window {
bool selected = (this->selected_index == item->result);
if (selected) GfxFillRect(r.left + 2, y, r.right - 1, y + item_height - 1, 0);
item->Draw(r.left, r.right, y, r.bottom, selected, colour);
item->Draw(r.left, r.right, y, y + item_height, selected, colour);
if (item->masked) {
GfxFillRect(r.left + 1, y, r.right - 1, y + item_height - 1, _colour_gradient[colour][5], FILLRECT_CHECKER);