diff options
author | Peter Nelson <peter1138@openttd.org> | 2019-02-13 22:05:08 +0000 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-03-03 09:15:39 +0100 |
commit | e0c2ad1b6591859a1a30216e396cdab6e6bb028f (patch) | |
tree | b8d65be4898bbb1e783be8f589a48b465c7745a9 /src/script/api/script_company.cpp | |
parent | 3c047b124e28db45621de06d5556c96598352fc7 (diff) | |
download | openttd-e0c2ad1b6591859a1a30216e396cdab6e6bb028f.tar.xz |
Add: AI functions to get/set company colours.
Diffstat (limited to 'src/script/api/script_company.cpp')
-rw-r--r-- | src/script/api/script_company.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp index a1f40c5e1..54888c33c 100644 --- a/src/script/api/script_company.cpp +++ b/src/script/api/script_company.cpp @@ -296,3 +296,33 @@ return ::Company::Get((CompanyID)company)->settings.engine_renew_money; } + +/* 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); + if (c == NULL) 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 == NULL) return COLOUR_INVALID; + + return (ScriptCompany::Colours)c->livery[scheme].colour2; +} |