2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/** @file script_company.cpp Implementation of ScriptCompany. */
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-01-22 10:33:16 +00:00
|
|
|
#include "../../stdafx.h"
|
2011-11-29 23:07:38 +00:00
|
|
|
#include "script_company.hpp"
|
|
|
|
#include "script_error.hpp"
|
2013-09-21 13:07:42 +00:00
|
|
|
#include "script_companymode.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
#include "../../company_func.h"
|
|
|
|
#include "../../company_base.h"
|
2009-08-01 00:28:21 +00:00
|
|
|
#include "../../company_manager_face.h"
|
2009-01-12 17:11:45 +00:00
|
|
|
#include "../../economy_func.h"
|
2010-08-08 10:59:30 +00:00
|
|
|
#include "../../object_type.h"
|
2009-01-12 17:11:45 +00:00
|
|
|
#include "../../strings_func.h"
|
|
|
|
#include "../../tile_map.h"
|
|
|
|
#include "../../string_func.h"
|
2009-05-26 13:29:01 +00:00
|
|
|
#include "../../settings_func.h"
|
2009-01-12 17:11:45 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "../../safeguards.h"
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ ScriptCompany::CompanyID ScriptCompany::ResolveCompanyID(ScriptCompany::CompanyID company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-12-19 21:05:25 +00:00
|
|
|
if (company == COMPANY_SELF) {
|
2020-02-18 18:50:38 +00:00
|
|
|
if (!::Company::IsValidID(_current_company)) return COMPANY_INVALID;
|
2011-12-19 21:05:25 +00:00
|
|
|
return (CompanyID)((byte)_current_company);
|
|
|
|
}
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::IsValidID(company) ? company : COMPANY_INVALID;
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ bool ScriptCompany::IsMine(ScriptCompany::CompanyID company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2009-01-16 00:05:26 +00:00
|
|
|
return ResolveCompanyID(company) == ResolveCompanyID(COMPANY_SELF);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-12-19 21:06:06 +00:00
|
|
|
/* static */ bool ScriptCompany::SetName(Text *name)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-12-19 21:06:06 +00:00
|
|
|
CCountedPtr<Text> counter(name);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2019-04-10 21:07:06 +00:00
|
|
|
EnforcePrecondition(false, name != nullptr);
|
2013-06-27 19:57:41 +00:00
|
|
|
const char *text = name->GetDecodedText();
|
2013-02-08 20:34:27 +00:00
|
|
|
EnforcePreconditionEncodedText(false, text);
|
2011-12-19 21:06:06 +00:00
|
|
|
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_COMPANY_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
|
|
|
|
|
|
|
return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_COMPANY, text);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ char *ScriptCompany::GetName(ScriptCompany::CompanyID company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
2019-04-10 21:07:06 +00:00
|
|
|
if (company == COMPANY_INVALID) return nullptr;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
::SetDParam(0, company);
|
2012-01-08 21:48:05 +00:00
|
|
|
return GetString(STR_COMPANY_NAME);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-12-19 21:06:06 +00:00
|
|
|
/* static */ bool ScriptCompany::SetPresidentName(Text *name)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-12-19 21:06:06 +00:00
|
|
|
CCountedPtr<Text> counter(name);
|
|
|
|
|
2019-04-10 21:07:06 +00:00
|
|
|
EnforcePrecondition(false, name != nullptr);
|
2013-06-27 19:57:41 +00:00
|
|
|
const char *text = name->GetDecodedText();
|
2013-02-08 20:34:27 +00:00
|
|
|
EnforcePreconditionEncodedText(false, text);
|
2013-06-27 19:23:23 +00:00
|
|
|
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_PRESIDENT_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-12-19 21:06:06 +00:00
|
|
|
return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, text);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ char *ScriptCompany::GetPresidentName(ScriptCompany::CompanyID company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
|
|
|
|
|
|
|
static const int len = 64;
|
|
|
|
char *president_name = MallocT<char>(len);
|
2009-01-16 00:05:26 +00:00
|
|
|
if (company != COMPANY_INVALID) {
|
2009-01-12 17:11:45 +00:00
|
|
|
::SetDParam(0, company);
|
|
|
|
::GetString(president_name, STR_PRESIDENT_NAME, &president_name[len - 1]);
|
|
|
|
} else {
|
|
|
|
*president_name = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
return president_name;
|
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ bool ScriptCompany::SetPresidentGender(Gender gender)
|
2009-08-01 00:28:21 +00:00
|
|
|
{
|
|
|
|
EnforcePrecondition(false, gender == GENDER_MALE || gender == GENDER_FEMALE);
|
2011-11-29 23:15:35 +00:00
|
|
|
EnforcePrecondition(false, GetPresidentGender(ScriptCompany::COMPANY_SELF) != gender);
|
2009-08-01 00:28:21 +00:00
|
|
|
|
|
|
|
CompanyManagerFace cmf;
|
|
|
|
GenderEthnicity ge = (GenderEthnicity)((gender == GENDER_FEMALE ? (1 << ::GENDER_FEMALE) : 0) | (::InteractiveRandom() & (1 << ETHNICITY_BLACK)));
|
|
|
|
RandomCompanyManagerFaceBits(cmf, ge, false);
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
return ScriptObject::DoCommand(0, 0, cmf, CMD_SET_COMPANY_MANAGER_FACE);
|
2009-08-01 00:28:21 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ ScriptCompany::Gender ScriptCompany::GetPresidentGender(CompanyID company)
|
2009-08-01 00:28:21 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
|
|
|
if (company == COMPANY_INVALID) return GENDER_INVALID;
|
|
|
|
|
|
|
|
GenderEthnicity ge = (GenderEthnicity)GetCompanyManagerFaceBits(Company::Get(company)->face, CMFV_GEN_ETHN, GE_WM);
|
|
|
|
return HasBit(ge, ::GENDER_FEMALE) ? GENDER_FEMALE : GENDER_MALE;
|
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ Money ScriptCompany::GetQuarterlyIncome(ScriptCompany::CompanyID company, uint32 quarter)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
2009-01-16 00:05:26 +00:00
|
|
|
if (company == COMPANY_INVALID) return -1;
|
2011-06-13 15:23:20 +00:00
|
|
|
if (quarter > EARLIEST_QUARTER) return -1;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-06-13 15:23:20 +00:00
|
|
|
if (quarter == CURRENT_QUARTER) {
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->cur_economy.income;
|
2011-06-13 15:23:20 +00:00
|
|
|
}
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->old_economy[quarter - 1].income;
|
2011-06-13 15:23:20 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ Money ScriptCompany::GetQuarterlyExpenses(ScriptCompany::CompanyID company, uint32 quarter)
|
2011-06-13 15:23:20 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
|
|
|
if (company == COMPANY_INVALID) return -1;
|
|
|
|
if (quarter > EARLIEST_QUARTER) return -1;
|
|
|
|
|
|
|
|
if (quarter == CURRENT_QUARTER) {
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->cur_economy.expenses;
|
2011-06-13 15:23:20 +00:00
|
|
|
}
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->old_economy[quarter - 1].expenses;
|
2011-06-13 15:23:20 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ int32 ScriptCompany::GetQuarterlyCargoDelivered(ScriptCompany::CompanyID company, uint32 quarter)
|
2011-06-13 15:23:20 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
|
|
|
if (company == COMPANY_INVALID) return -1;
|
|
|
|
if (quarter > EARLIEST_QUARTER) return -1;
|
|
|
|
|
|
|
|
if (quarter == CURRENT_QUARTER) {
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->cur_economy.delivered_cargo.GetSum<OverflowSafeInt<int32, INT32_MAX, INT32_MIN> >();
|
2011-06-13 15:23:20 +00:00
|
|
|
}
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->old_economy[quarter - 1].delivered_cargo.GetSum<OverflowSafeInt<int32, INT32_MAX, INT32_MIN> >();
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ int32 ScriptCompany::GetQuarterlyPerformanceRating(ScriptCompany::CompanyID company, uint32 quarter)
|
2011-06-13 15:23:20 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
|
|
|
if (company == COMPANY_INVALID) return -1;
|
|
|
|
if (quarter > EARLIEST_QUARTER) return -1;
|
|
|
|
if (quarter == CURRENT_QUARTER) return -1;
|
|
|
|
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->old_economy[quarter - 1].performance_history;
|
2011-06-13 15:23:20 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ Money ScriptCompany::GetQuarterlyCompanyValue(ScriptCompany::CompanyID company, uint32 quarter)
|
2011-06-13 15:23:20 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
|
|
|
if (company == COMPANY_INVALID) return -1;
|
|
|
|
if (quarter > EARLIEST_QUARTER) return -1;
|
|
|
|
|
|
|
|
if (quarter == CURRENT_QUARTER) {
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::CalculateCompanyValue(::Company::Get(company));
|
2011-06-13 15:23:20 +00:00
|
|
|
}
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->old_economy[quarter - 1].company_value;
|
2011-06-13 15:23:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ Money ScriptCompany::GetBankBalance(ScriptCompany::CompanyID company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
2009-01-16 00:05:26 +00:00
|
|
|
if (company == COMPANY_INVALID) return -1;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->money;
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ Money ScriptCompany::GetLoanAmount()
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-12-19 21:05:25 +00:00
|
|
|
ScriptCompany::CompanyID company = ResolveCompanyID(COMPANY_SELF);
|
|
|
|
if (company == COMPANY_INVALID) return -1;
|
|
|
|
|
|
|
|
return ::Company::Get(company)->current_loan;
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ Money ScriptCompany::GetMaxLoanAmount()
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
return _economy.max_loan;
|
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ Money ScriptCompany::GetLoanInterval()
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
return LOAN_INTERVAL;
|
|
|
|
}
|
|
|
|
|
2014-05-11 20:25:26 +00:00
|
|
|
/* static */ bool ScriptCompany::SetLoanAmount(Money loan)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-12-19 21:05:36 +00:00
|
|
|
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
2009-01-12 17:11:45 +00:00
|
|
|
EnforcePrecondition(false, loan >= 0);
|
2014-05-11 20:25:26 +00:00
|
|
|
EnforcePrecondition(false, ((int64)loan % GetLoanInterval()) == 0);
|
2009-01-12 17:11:45 +00:00
|
|
|
EnforcePrecondition(false, loan <= GetMaxLoanAmount());
|
2009-01-16 00:05:26 +00:00
|
|
|
EnforcePrecondition(false, (loan - GetLoanAmount() + GetBankBalance(COMPANY_SELF)) >= 0);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
if (loan == GetLoanAmount()) return true;
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
return ScriptObject::DoCommand(0,
|
2009-01-12 17:11:45 +00:00
|
|
|
abs(loan - GetLoanAmount()), 2,
|
|
|
|
(loan > GetLoanAmount()) ? CMD_INCREASE_LOAN : CMD_DECREASE_LOAN);
|
|
|
|
}
|
|
|
|
|
2014-05-11 20:25:26 +00:00
|
|
|
/* static */ bool ScriptCompany::SetMinimumLoanAmount(Money loan)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-12-19 21:05:36 +00:00
|
|
|
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
2009-01-12 17:11:45 +00:00
|
|
|
EnforcePrecondition(false, loan >= 0);
|
|
|
|
|
2014-05-11 20:25:26 +00:00
|
|
|
Money over_interval = (int64)loan % GetLoanInterval();
|
2009-01-12 17:11:45 +00:00
|
|
|
if (over_interval != 0) loan += GetLoanInterval() - over_interval;
|
|
|
|
|
|
|
|
EnforcePrecondition(false, loan <= GetMaxLoanAmount());
|
|
|
|
|
|
|
|
SetLoanAmount(loan);
|
|
|
|
|
|
|
|
return GetLoanAmount() == loan;
|
|
|
|
}
|
|
|
|
|
2014-05-11 20:25:26 +00:00
|
|
|
/* static */ bool ScriptCompany::ChangeBankBalance(CompanyID company, Money delta, ExpensesType expenses_type)
|
2013-09-21 13:07:42 +00:00
|
|
|
{
|
|
|
|
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
2013-09-21 19:35:49 +00:00
|
|
|
EnforcePrecondition(false, expenses_type < (ExpensesType)::EXPENSES_END);
|
2014-10-21 16:58:15 +00:00
|
|
|
EnforcePrecondition(false, (int64)delta >= INT32_MIN);
|
|
|
|
EnforcePrecondition(false, (int64)delta <= INT32_MAX);
|
2013-09-21 13:07:42 +00:00
|
|
|
|
|
|
|
company = ResolveCompanyID(company);
|
2013-11-26 12:46:21 +00:00
|
|
|
EnforcePrecondition(false, company != COMPANY_INVALID);
|
2013-09-21 13:07:42 +00:00
|
|
|
|
|
|
|
return ScriptObject::DoCommand(0, (uint32)(delta), company | expenses_type << 8 , CMD_CHANGE_BANK_BALANCE);
|
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ bool ScriptCompany::BuildCompanyHQ(TileIndex tile)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-12-19 21:05:36 +00:00
|
|
|
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
|
2009-01-12 17:11:45 +00:00
|
|
|
EnforcePrecondition(false, ::IsValidTile(tile));
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
return ScriptObject::DoCommand(tile, OBJECT_HQ, 0, CMD_BUILD_OBJECT);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ TileIndex ScriptCompany::GetCompanyHQ(CompanyID company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
2013-12-08 18:20:14 +00:00
|
|
|
if (company == COMPANY_INVALID) return INVALID_TILE;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2020-02-18 18:50:38 +00:00
|
|
|
TileIndex loc = ::Company::Get(company)->location_of_HQ;
|
2009-01-12 17:11:45 +00:00
|
|
|
return (loc == 0) ? INVALID_TILE : loc;
|
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ bool ScriptCompany::SetAutoRenewStatus(bool autorenew)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-11-29 23:15:35 +00:00
|
|
|
return ScriptObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew"), autorenew ? 1 : 0, CMD_CHANGE_COMPANY_SETTING);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ bool ScriptCompany::GetAutoRenewStatus(CompanyID company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
2009-01-16 00:05:26 +00:00
|
|
|
if (company == COMPANY_INVALID) return false;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->settings.engine_renew;
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ bool ScriptCompany::SetAutoRenewMonths(int16 months)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-11-29 23:15:35 +00:00
|
|
|
return ScriptObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew_months"), months, CMD_CHANGE_COMPANY_SETTING);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ int16 ScriptCompany::GetAutoRenewMonths(CompanyID company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
2009-01-16 00:05:26 +00:00
|
|
|
if (company == COMPANY_INVALID) return 0;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->settings.engine_renew_months;
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2014-05-11 20:25:26 +00:00
|
|
|
/* static */ bool ScriptCompany::SetAutoRenewMoney(Money money)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2014-05-11 20:25:26 +00:00
|
|
|
EnforcePrecondition(false, money >= 0);
|
|
|
|
EnforcePrecondition(false, (int64)money <= UINT32_MAX);
|
2011-11-29 23:15:35 +00:00
|
|
|
return ScriptObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew_money"), money, CMD_CHANGE_COMPANY_SETTING);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2014-05-11 20:25:26 +00:00
|
|
|
/* static */ Money ScriptCompany::GetAutoRenewMoney(CompanyID company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
company = ResolveCompanyID(company);
|
2009-01-16 00:05:26 +00:00
|
|
|
if (company == COMPANY_INVALID) return 0;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2020-02-18 18:50:38 +00:00
|
|
|
return ::Company::Get(company)->settings.engine_renew_money;
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
2019-02-13 22:05:08 +00:00
|
|
|
|
|
|
|
/* static */ bool ScriptCompany::SetPrimaryLiveryColour(LiveryScheme scheme, Colours colour)
|
|
|
|
{
|
|
|
|
return ScriptObject::DoCommand(0, scheme, colour, CMD_SET_COMPANY_COLOUR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ bool ScriptCompany::SetSecondaryLiveryColour(LiveryScheme scheme, Colours colour)
|
|
|
|
{
|
|
|
|
return ScriptObject::DoCommand(0, scheme | 1 << 8, colour, CMD_SET_COMPANY_COLOUR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ ScriptCompany::Colours ScriptCompany::GetPrimaryLiveryColour(ScriptCompany::LiveryScheme scheme)
|
|
|
|
{
|
|
|
|
if ((::LiveryScheme)scheme < LS_BEGIN || (::LiveryScheme)scheme >= LS_END) return COLOUR_INVALID;
|
|
|
|
|
|
|
|
const Company *c = ::Company::GetIfValid(_current_company);
|
2019-04-10 21:07:06 +00:00
|
|
|
if (c == nullptr) return COLOUR_INVALID;
|
2019-02-13 22:05:08 +00:00
|
|
|
|
|
|
|
return (ScriptCompany::Colours)c->livery[scheme].colour1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ ScriptCompany::Colours ScriptCompany::GetSecondaryLiveryColour(ScriptCompany::LiveryScheme scheme)
|
|
|
|
{
|
|
|
|
if ((::LiveryScheme)scheme < LS_BEGIN || (::LiveryScheme)scheme >= LS_END) return COLOUR_INVALID;
|
|
|
|
|
|
|
|
const Company *c = ::Company::GetIfValid(_current_company);
|
2019-04-10 21:07:06 +00:00
|
|
|
if (c == nullptr) return COLOUR_INVALID;
|
2019-02-13 22:05:08 +00:00
|
|
|
|
|
|
|
return (ScriptCompany::Colours)c->livery[scheme].colour2;
|
|
|
|
}
|