Files
@ r28025:9116d6e411b0
Branch filter:
Location: cpp/openttd-patchpack/source/src/script/api/script_company.cpp - annotation
r28025:9116d6e411b0
11.7 KiB
text/x-c
Codechange: replace x.size() == 0 with x.empty()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r20745:b1ebcc10c74a r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r26105:23588534dec9 r26105:23588534dec9 r26105:23588534dec9 r26105:23588534dec9 r18500:14a481bc4437 r18500:14a481bc4437 r21383:942c32fb8b0e r21383:942c32fb8b0e r18501:8e3d905ea4bc r18500:14a481bc4437 r18774:2977cce7e239 r24117:4a7343dfb19b r18774:2977cce7e239 r18774:2977cce7e239 r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r27114:3a7b4e6d95b2 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18778:4848b0595531 r18500:14a481bc4437 r18778:4848b0595531 r18500:14a481bc4437 r27006:2f140db085e8 r23607:36c15679007d r26891:5a795b8188a7 r20025:983c2ed8d329 r18778:4848b0595531 r18778:4848b0595531 r26120:15c912177c88 r18500:14a481bc4437 r18500:14a481bc4437 r27364:db69a5f5c496 r18500:14a481bc4437 r18500:14a481bc4437 r27364:db69a5f5c496 r18500:14a481bc4437 r18500:14a481bc4437 r18917:144687613228 r18500:14a481bc4437 r18500:14a481bc4437 r18778:4848b0595531 r18500:14a481bc4437 r18778:4848b0595531 r18500:14a481bc4437 r27006:2f140db085e8 r23607:36c15679007d r26891:5a795b8188a7 r20025:983c2ed8d329 r20471:6814a0b87b95 r18778:4848b0595531 r26120:15c912177c88 r18500:14a481bc4437 r18500:14a481bc4437 r27364:db69a5f5c496 r18500:14a481bc4437 r18500:14a481bc4437 r27364:db69a5f5c496 r18500:14a481bc4437 r27364:db69a5f5c496 r27364:db69a5f5c496 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r27006:2f140db085e8 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r26760:75c92d021229 r18500:14a481bc4437 r26760:75c92d021229 r26760:75c92d021229 r18500:14a481bc4437 r26120:15c912177c88 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r25846:3dc91304dafe r18500:14a481bc4437 r25846:3dc91304dafe r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18774:2977cce7e239 r18774:2977cce7e239 r18774:2977cce7e239 r18774:2977cce7e239 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r21476:20e40060edc2 r18500:14a481bc4437 r26996:7064173a70ca r18500:14a481bc4437 r27737:728d55b97775 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r24536:c6eb2a05f37b r24536:c6eb2a05f37b r26105:23588534dec9 r26120:15c912177c88 r26105:23588534dec9 r26120:15c912177c88 r26105:23588534dec9 r18500:14a481bc4437 r18500:14a481bc4437 r21476:20e40060edc2 r18500:14a481bc4437 r26996:7064173a70ca r18500:14a481bc4437 r18500:14a481bc4437 r27737:728d55b97775 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r24687:4a2fa1e7f559 r20745:b1ebcc10c74a r26996:7064173a70ca r20748:08a16bce87ff r24687:4a2fa1e7f559 r20745:b1ebcc10c74a r20745:b1ebcc10c74a r21039:849fffd298e6 r20745:b1ebcc10c74a r24687:4a2fa1e7f559 r26120:15c912177c88 r20745:b1ebcc10c74a r20745:b1ebcc10c74a r18501:8e3d905ea4bc r18500:14a481bc4437 r26996:7064173a70ca r18500:14a481bc4437 r18500:14a481bc4437 r26119:a6e64747fa5d r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r21068:1ff014815343 r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r27006:2f140db085e8 r26120:15c912177c88 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r27006:2f140db085e8 r26966:dfd8ee0544ac r27006:2f140db085e8 r26120:15c912177c88 r18500:14a481bc4437 r18500:14a481bc4437 r26966:dfd8ee0544ac r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r18500:14a481bc4437 r21476:20e40060edc2 r18500:14a481bc4437 r27006:2f140db085e8 r21476:20e40060edc2 r27737:728d55b97775 r26120:15c912177c88 r18500:14a481bc4437 r18500:14a481bc4437 r21476:20e40060edc2 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r24117:4a7343dfb19b r18500:14a481bc4437 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r27006:2f140db085e8 r26120:15c912177c88 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r27006:2f140db085e8 r26120:15c912177c88 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23607:36c15679007d r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 r23607:36c15679007d r23385:8b5c5d818774 r23385:8b5c5d818774 r23385:8b5c5d818774 | /*
* 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/>.
*/
/** @file script_company.cpp Implementation of ScriptCompany. */
#include "../../stdafx.h"
#include "script_company.hpp"
#include "script_error.hpp"
#include "script_companymode.hpp"
#include "../../company_func.h"
#include "../../company_base.h"
#include "../../company_manager_face.h"
#include "../../economy_func.h"
#include "../../object_type.h"
#include "../../strings_func.h"
#include "../../tile_map.h"
#include "../../string_func.h"
#include "../../settings_func.h"
#include "../../company_cmd.h"
#include "../../misc_cmd.h"
#include "../../object_cmd.h"
#include "../../settings_cmd.h"
#include "table/strings.h"
#include "../../safeguards.h"
/* static */ ScriptCompany::CompanyID ScriptCompany::ResolveCompanyID(ScriptCompany::CompanyID company)
{
if (company == COMPANY_SELF) {
if (!::Company::IsValidID(_current_company)) return COMPANY_INVALID;
return (CompanyID)((byte)_current_company);
}
return ::Company::IsValidID(company) ? company : COMPANY_INVALID;
}
/* static */ bool ScriptCompany::IsMine(ScriptCompany::CompanyID company)
{
EnforceCompanyModeValid(false);
return ResolveCompanyID(company) == ResolveCompanyID(COMPANY_SELF);
}
/* static */ bool ScriptCompany::SetName(Text *name)
{
CCountedPtr<Text> counter(name);
EnforceCompanyModeValid(false);
EnforcePrecondition(false, name != nullptr);
const std::string &text = name->GetDecodedText();
EnforcePreconditionEncodedText(false, text);
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_COMPANY_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
return ScriptObject::Command<CMD_RENAME_COMPANY>::Do(text);
}
/* static */ std::optional<std::string> ScriptCompany::GetName(ScriptCompany::CompanyID company)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return std::nullopt;
::SetDParam(0, company);
return GetString(STR_COMPANY_NAME);
}
/* static */ bool ScriptCompany::SetPresidentName(Text *name)
{
CCountedPtr<Text> counter(name);
EnforceCompanyModeValid(false);
EnforcePrecondition(false, name != nullptr);
const std::string &text = name->GetDecodedText();
EnforcePreconditionEncodedText(false, text);
EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_PRESIDENT_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
return ScriptObject::Command<CMD_RENAME_PRESIDENT>::Do(text);
}
/* static */ std::optional<std::string> ScriptCompany::GetPresidentName(ScriptCompany::CompanyID company)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return std::nullopt;
::SetDParam(0, company);
return GetString(STR_PRESIDENT_NAME);
}
/* static */ bool ScriptCompany::SetPresidentGender(Gender gender)
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, gender == GENDER_MALE || gender == GENDER_FEMALE);
EnforcePrecondition(false, GetPresidentGender(ScriptCompany::COMPANY_SELF) != gender);
Randomizer &randomizer = ScriptObject::GetRandomizer();
CompanyManagerFace cmf;
GenderEthnicity ge = (GenderEthnicity)((gender == GENDER_FEMALE ? (1 << ::GENDER_FEMALE) : 0) | (randomizer.Next() & (1 << ETHNICITY_BLACK)));
RandomCompanyManagerFaceBits(cmf, ge, false, randomizer);
return ScriptObject::Command<CMD_SET_COMPANY_MANAGER_FACE>::Do(cmf);
}
/* static */ ScriptCompany::Gender ScriptCompany::GetPresidentGender(CompanyID company)
{
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;
}
/* static */ Money ScriptCompany::GetQuarterlyIncome(ScriptCompany::CompanyID company, SQInteger quarter)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return -1;
if (quarter > EARLIEST_QUARTER) return -1;
if (quarter < CURRENT_QUARTER) return -1;
if (quarter == CURRENT_QUARTER) {
return ::Company::Get(company)->cur_economy.income;
}
return ::Company::Get(company)->old_economy[quarter - 1].income;
}
/* static */ Money ScriptCompany::GetQuarterlyExpenses(ScriptCompany::CompanyID company, SQInteger quarter)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return -1;
if (quarter > EARLIEST_QUARTER) return -1;
if (quarter < CURRENT_QUARTER) return -1;
if (quarter == CURRENT_QUARTER) {
return ::Company::Get(company)->cur_economy.expenses;
}
return ::Company::Get(company)->old_economy[quarter - 1].expenses;
}
/* static */ SQInteger ScriptCompany::GetQuarterlyCargoDelivered(ScriptCompany::CompanyID company, SQInteger quarter)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return -1;
if (quarter > EARLIEST_QUARTER) return -1;
if (quarter < CURRENT_QUARTER) return -1;
if (quarter == CURRENT_QUARTER) {
return ::Company::Get(company)->cur_economy.delivered_cargo.GetSum<OverflowSafeInt32>();
}
return ::Company::Get(company)->old_economy[quarter - 1].delivered_cargo.GetSum<OverflowSafeInt32>();
}
/* static */ SQInteger ScriptCompany::GetQuarterlyPerformanceRating(ScriptCompany::CompanyID company, SQInteger quarter)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return -1;
if (quarter > EARLIEST_QUARTER) return -1;
if (quarter <= CURRENT_QUARTER) return -1;
return ::Company::Get(company)->old_economy[quarter - 1].performance_history;
}
/* static */ Money ScriptCompany::GetQuarterlyCompanyValue(ScriptCompany::CompanyID company, SQInteger quarter)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return -1;
if (quarter > EARLIEST_QUARTER) return -1;
if (quarter < CURRENT_QUARTER) return -1;
if (quarter == CURRENT_QUARTER) {
return ::CalculateCompanyValue(::Company::Get(company));
}
return ::Company::Get(company)->old_economy[quarter - 1].company_value;
}
/* static */ Money ScriptCompany::GetBankBalance(ScriptCompany::CompanyID company)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return -1;
return ::Company::Get(company)->money;
}
/* static */ Money ScriptCompany::GetLoanAmount()
{
ScriptCompany::CompanyID company = ResolveCompanyID(COMPANY_SELF);
if (company == COMPANY_INVALID) return -1;
return ::Company::Get(company)->current_loan;
}
/* static */ Money ScriptCompany::GetMaxLoanAmount()
{
return _economy.max_loan;
}
/* static */ Money ScriptCompany::GetLoanInterval()
{
return LOAN_INTERVAL;
}
/* static */ bool ScriptCompany::SetLoanAmount(Money loan)
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, loan >= 0);
EnforcePrecondition(false, ((int64_t)loan % GetLoanInterval()) == 0);
EnforcePrecondition(false, loan <= GetMaxLoanAmount());
EnforcePrecondition(false, (loan - GetLoanAmount() + GetBankBalance(COMPANY_SELF)) >= 0);
if (loan == GetLoanAmount()) return true;
Money amount = abs(loan - GetLoanAmount());
if (loan > GetLoanAmount()) {
return ScriptObject::Command<CMD_INCREASE_LOAN>::Do(LoanCommand::Amount, amount);
} else {
return ScriptObject::Command<CMD_DECREASE_LOAN>::Do(LoanCommand::Amount, amount);
}
}
/* static */ bool ScriptCompany::SetMinimumLoanAmount(Money loan)
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, loan >= 0);
Money over_interval = (int64_t)loan % GetLoanInterval();
if (over_interval != 0) loan += GetLoanInterval() - over_interval;
EnforcePrecondition(false, loan <= GetMaxLoanAmount());
SetLoanAmount(loan);
return GetLoanAmount() == loan;
}
/* static */ bool ScriptCompany::ChangeBankBalance(CompanyID company, Money delta, ExpensesType expenses_type, TileIndex tile)
{
EnforceDeityMode(false);
EnforcePrecondition(false, expenses_type < (ExpensesType)::EXPENSES_END);
EnforcePrecondition(false, tile == INVALID_TILE || ::IsValidTile(tile));
company = ResolveCompanyID(company);
EnforcePrecondition(false, company != COMPANY_INVALID);
/* Network commands only allow 0 to indicate invalid tiles, not INVALID_TILE */
return ScriptObject::Command<CMD_CHANGE_BANK_BALANCE>::Do(tile == INVALID_TILE ? (TileIndex)0U : tile, delta, (::CompanyID)company, (::ExpensesType)expenses_type);
}
/* static */ bool ScriptCompany::BuildCompanyHQ(TileIndex tile)
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, ::IsValidTile(tile));
return ScriptObject::Command<CMD_BUILD_OBJECT>::Do(tile, OBJECT_HQ, 0);
}
/* static */ TileIndex ScriptCompany::GetCompanyHQ(CompanyID company)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return INVALID_TILE;
TileIndex loc = ::Company::Get(company)->location_of_HQ;
return (loc == 0) ? INVALID_TILE : loc;
}
/* static */ bool ScriptCompany::SetAutoRenewStatus(bool autorenew)
{
EnforceCompanyModeValid(false);
return ScriptObject::Command<CMD_CHANGE_COMPANY_SETTING>::Do("company.engine_renew", autorenew ? 1 : 0);
}
/* static */ bool ScriptCompany::GetAutoRenewStatus(CompanyID company)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return false;
return ::Company::Get(company)->settings.engine_renew;
}
/* static */ bool ScriptCompany::SetAutoRenewMonths(SQInteger months)
{
EnforceCompanyModeValid(false);
months = Clamp<SQInteger>(months, INT16_MIN, INT16_MAX);
return ScriptObject::Command<CMD_CHANGE_COMPANY_SETTING>::Do("company.engine_renew_months", months);
}
/* static */ SQInteger ScriptCompany::GetAutoRenewMonths(CompanyID company)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return 0;
return ::Company::Get(company)->settings.engine_renew_months;
}
/* static */ bool ScriptCompany::SetAutoRenewMoney(Money money)
{
EnforceCompanyModeValid(false);
EnforcePrecondition(false, money >= 0);
EnforcePrecondition(false, (int64_t)money <= UINT32_MAX);
return ScriptObject::Command<CMD_CHANGE_COMPANY_SETTING>::Do("company.engine_renew_money", money);
}
/* static */ Money ScriptCompany::GetAutoRenewMoney(CompanyID company)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return 0;
return ::Company::Get(company)->settings.engine_renew_money;
}
/* static */ bool ScriptCompany::SetPrimaryLiveryColour(LiveryScheme scheme, Colours colour)
{
EnforceCompanyModeValid(false);
return ScriptObject::Command<CMD_SET_COMPANY_COLOUR>::Do((::LiveryScheme)scheme, true, (::Colours)colour);
}
/* static */ bool ScriptCompany::SetSecondaryLiveryColour(LiveryScheme scheme, Colours colour)
{
EnforceCompanyModeValid(false);
return ScriptObject::Command<CMD_SET_COMPANY_COLOUR>::Do((::LiveryScheme)scheme, false, (::Colours)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);
if (c == nullptr) return COLOUR_INVALID;
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);
if (c == nullptr) return COLOUR_INVALID;
return (ScriptCompany::Colours)c->livery[scheme].colour2;
}
|