diff options
author | yexo <yexo@openttd.org> | 2009-08-01 00:28:21 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-08-01 00:28:21 +0000 |
commit | fc03fef4aee9b069bf4f1e8c2109d127246a973a (patch) | |
tree | a9b87cbe46c314a6b6d76193a9144b56d12694f8 /src/ai/api/ai_company.cpp | |
parent | ae71df349ebeeb1732525f34b88ab8d2782f57a4 (diff) | |
download | openttd-fc03fef4aee9b069bf4f1e8c2109d127246a973a.tar.xz |
(svn r17016) -Add [NoAI]: AICompany::Get/Set PresidentGender
Diffstat (limited to 'src/ai/api/ai_company.cpp')
-rw-r--r-- | src/ai/api/ai_company.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ai/api/ai_company.cpp b/src/ai/api/ai_company.cpp index ca11b7f73..73207fbbf 100644 --- a/src/ai/api/ai_company.cpp +++ b/src/ai/api/ai_company.cpp @@ -8,6 +8,7 @@ #include "../../command_func.h" #include "../../company_func.h" #include "../../company_base.h" +#include "../../company_manager_face.h" #include "../../economy_func.h" #include "../../strings_func.h" #include "../../tile_map.h" @@ -72,6 +73,27 @@ return president_name; } +/* static */ bool AICompany::SetPresidentGender(Gender gender) +{ + EnforcePrecondition(false, gender == GENDER_MALE || gender == GENDER_FEMALE); + EnforcePrecondition(false, GetPresidentGender(AICompany::COMPANY_SELF) != gender); + + CompanyManagerFace cmf; + GenderEthnicity ge = (GenderEthnicity)((gender == GENDER_FEMALE ? (1 << ::GENDER_FEMALE) : 0) | (::InteractiveRandom() & (1 << ETHNICITY_BLACK))); + RandomCompanyManagerFaceBits(cmf, ge, false); + + return AIObject::DoCommand(0, 0, cmf, CMD_SET_COMPANY_MANAGER_FACE); +} + +/* static */ AICompany::Gender AICompany::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 AICompany::GetCompanyValue(AICompany::CompanyID company) { company = ResolveCompanyID(company); |