File diff r11916:e3a8d08bf479 → r11917:612c11f7ab47
src/misc_cmd.cpp
Show inline comments
 
@@ -32,13 +32,13 @@ CommandCost CmdSetCompanyManagerFace(Til
 
{
 
	CompanyManagerFace cmf = (CompanyManagerFace)p2;
 

	
 
	if (!IsValidCompanyManagerFace(cmf)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		GetCompany(_current_company)->face = cmf;
 
		Company::Get(_current_company)->face = cmf;
 
		MarkWholeScreenDirty();
 
	}
 
	return CommandCost();
 
}
 

	
 
/** Change the company's company-colour
 
@@ -57,13 +57,13 @@ CommandCost CmdSetCompanyColour(TileInde
 

	
 
	LiveryScheme scheme = (LiveryScheme)GB(p1, 0, 8);
 
	byte state = GB(p1, 8, 2);
 

	
 
	if (scheme >= LS_END || state >= 3) return CMD_ERROR;
 

	
 
	Company *c = GetCompany(_current_company);
 
	Company *c = Company::Get(_current_company);
 

	
 
	/* Ensure no two companies have the same primary colour */
 
	if (scheme == LS_DEFAULT && state == 0) {
 
		const Company *cc;
 
		FOR_ALL_COMPANIES(cc) {
 
			if (cc != c && cc->colour == colour) return CMD_ERROR;
 
@@ -135,13 +135,13 @@ CommandCost CmdSetCompanyColour(TileInde
 
 * @param p2 when 0: loans LOAN_INTERVAL
 
 *           when 1: loans the maximum loan permitting money (press CTRL),
 
 *           when 2: loans the amount specified in p1
 
 */
 
CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	Company *c = GetCompany(_current_company);
 
	Company *c = Company::Get(_current_company);
 

	
 
	if (c->current_loan >= _economy.max_loan) {
 
		SetDParam(0, _economy.max_loan);
 
		return_cmd_error(STR_ERROR_MAXIMUM_PERMITTED_LOAN);
 
	}
 

	
 
@@ -179,13 +179,13 @@ CommandCost CmdIncreaseLoan(TileIndex ti
 
 * @param p2 when 0: pays back LOAN_INTERVAL
 
 *           when 1: pays back the maximum loan permitting money (press CTRL),
 
 *           when 2: pays back the amount specified in p1
 
 */
 
CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	Company *c = GetCompany(_current_company);
 
	Company *c = Company::Get(_current_company);
 

	
 
	if (c->current_loan == 0) return_cmd_error(STR_ERROR_LOAN_ALREADY_REPAYED);
 

	
 
	Money loan;
 
	switch (p2) {
 
		default: return CMD_ERROR; // Invalid method
 
@@ -239,13 +239,13 @@ CommandCost CmdRenameCompany(TileIndex t
 
	if (!reset) {
 
		if (strlen(text) >= MAX_LENGTH_COMPANY_NAME_BYTES) return CMD_ERROR;
 
		if (!IsUniqueCompanyName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		Company *c = GetCompany(_current_company);
 
		Company *c = Company::Get(_current_company);
 
		free(c->name);
 
		c->name = reset ? NULL : strdup(text);
 
		MarkWholeScreenDirty();
 
	}
 

	
 
	return CommandCost();
 
@@ -275,13 +275,13 @@ CommandCost CmdRenamePresident(TileIndex
 
	if (!reset) {
 
		if (strlen(text) >= MAX_LENGTH_PRESIDENT_NAME_BYTES) return CMD_ERROR;
 
		if (!IsUniquePresidentName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		Company *c = GetCompany(_current_company);
 
		Company *c = Company::Get(_current_company);
 
		free(c->president_name);
 

	
 
		if (reset) {
 
			c->president_name = NULL;
 
		} else {
 
			c->president_name = strdup(text);
 
@@ -379,13 +379,13 @@ CommandCost CmdMoneyCheat(TileIndex tile
 
 * @param p2 the company to transfer the money to
 
 */
 
CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	if (!_settings_game.economy.give_money) return CMD_ERROR;
 

	
 
	const Company *c = GetCompany(_current_company);
 
	const Company *c = Company::Get(_current_company);
 
	CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
 

	
 
	/* You can only transfer funds that is in excess of your loan */
 
	if (c->money - c->current_loan < amount.GetCost() || amount.GetCost() <= 0) return CMD_ERROR;
 
	if (!_networking || !IsValidCompanyID((CompanyID)p2)) return CMD_ERROR;