diff options
author | zuu <zuu@openttd.org> | 2013-11-16 17:41:57 +0000 |
---|---|---|
committer | zuu <zuu@openttd.org> | 2013-11-16 17:41:57 +0000 |
commit | 6fc653d2d729d8a5c0efeba9f588e6523c3ea13d (patch) | |
tree | 76a9ebd0678eee9121a811696a8de6e1f6cb5681 /src/script/api/script_goal.cpp | |
parent | f10d2417d8922f7243bcd7e4582bb1a329f6b86c (diff) | |
download | openttd-6fc653d2d729d8a5c0efeba9f588e6523c3ea13d.tar.xz |
(svn r26012) -Add: new goal type that show a story page when clicked
Diffstat (limited to 'src/script/api/script_goal.cpp')
-rw-r--r-- | src/script/api/script_goal.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index 56f3628d0..535450973 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -15,6 +15,7 @@ #include "script_industry.hpp" #include "script_map.hpp" #include "script_town.hpp" +#include "script_story_page.hpp" #include "../script_instance.hpp" #include "../../goal_base.h" #include "../../string_func.h" @@ -33,10 +34,18 @@ const char *text = goal->GetEncodedText(); EnforcePreconditionEncodedText(GOAL_INVALID, text); EnforcePrecondition(GOAL_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); - EnforcePrecondition(GOAL_INVALID, (type == GT_NONE && destination == 0) || (type == GT_TILE && ScriptMap::IsValidTile(destination)) || (type == GT_INDUSTRY && ScriptIndustry::IsValidIndustry(destination)) || (type == GT_TOWN && ScriptTown::IsValidTown(destination)) || (type == GT_COMPANY && ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)destination) != ScriptCompany::COMPANY_INVALID)); uint8 c = company; if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; + StoryPage *story_page = NULL; + if (type == GT_STORY_PAGE && ScriptStoryPage::IsValidStoryPage((ScriptStoryPage::StoryPageID)destination)) story_page = ::StoryPage::Get((ScriptStoryPage::StoryPageID)destination); + + EnforcePrecondition(GOAL_INVALID, (type == GT_NONE && destination == 0) || + (type == GT_TILE && ScriptMap::IsValidTile(destination)) || + (type == GT_INDUSTRY && ScriptIndustry::IsValidIndustry(destination)) || + (type == GT_TOWN && ScriptTown::IsValidTown(destination)) || + (type == GT_COMPANY && ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)destination) != ScriptCompany::COMPANY_INVALID) || + (type == GT_STORY_PAGE && story_page != NULL && (c == INVALID_COMPANY ? story_page->company == INVALID_COMPANY : story_page->company == INVALID_COMPANY || story_page->company == c))); if (!ScriptObject::DoCommand(0, type | (c << 8), destination, CMD_CREATE_GOAL, text, &ScriptInstance::DoCommandReturnGoalID)) return GOAL_INVALID; |