diff options
author | truebrain <truebrain@openttd.org> | 2012-01-03 16:36:24 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2012-01-03 16:36:24 +0000 |
commit | 34d90da509a27c4abe35c11d7f034b1e386cd968 (patch) | |
tree | 552a11c264ee5b26ad849818f50f45bf9927735c /src/script/api/script_goal.cpp | |
parent | 18ac3f2bd89aa11fefa64bdada287a72937ab8d5 (diff) | |
download | openttd-34d90da509a27c4abe35c11d7f034b1e386cd968.tar.xz |
(svn r23731) -Add: add GSGoal::Question(), to ask a question to a(ll) company(ies). It can contain random text, and at most 3 buttons from a collection of 17
Diffstat (limited to 'src/script/api/script_goal.cpp')
-rw-r--r-- | src/script/api/script_goal.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index e005ceda0..ba5e19e37 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -32,6 +32,7 @@ { CCountedPtr<Text> counter(goal); + EnforcePrecondition(GOAL_INVALID, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(GOAL_INVALID, goal != NULL); EnforcePrecondition(GOAL_INVALID, !StrEmpty(goal->GetEncodedText())); EnforcePrecondition(GOAL_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); @@ -48,7 +49,31 @@ /* static */ bool ScriptGoal::Remove(GoalID goal_id) { + EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, IsValidGoal(goal_id)); return ScriptObject::DoCommand(0, goal_id, 0, CMD_REMOVE_GOAL); } + +/* static */ bool ScriptGoal::Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, int buttons) +{ + CCountedPtr<Text> counter(question); + + EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); + EnforcePrecondition(false, question != NULL); + EnforcePrecondition(false, !StrEmpty(question->GetEncodedText())); + EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); + EnforcePrecondition(false, CountBits(buttons) >= 1 && CountBits(buttons) <= 3); + + uint8 c = company; + if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; + + return ScriptObject::DoCommand(0, uniqueid | (c << 16), buttons, CMD_GOAL_QUESTION, question->GetEncodedText()); +} + +/* static */ bool ScriptGoal::CloseQuestion(uint16 uniqueid) +{ + EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); + + return ScriptObject::DoCommand(0, uniqueid, 0, CMD_GOAL_QUESTION_ANSWER); +} |