From e6e69d528921ab731c4c38ee708ff31b7055fd27 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sat, 20 Nov 2021 22:30:56 +0100 Subject: Codechange: Un-bitstuff goal and story page commands. --- src/script/api/script_goal.cpp | 16 ++++++++-------- src/script/api/script_story_page.cpp | 17 +++++++---------- 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'src/script') diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index dbc2c51e0..70f040dd4 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -38,7 +38,7 @@ EnforcePreconditionEncodedText(GOAL_INVALID, text); EnforcePrecondition(GOAL_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); - uint8 c = company; + CompanyID c = (::CompanyID)company; if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; StoryPage *story_page = nullptr; if (type == GT_STORY_PAGE && ScriptStoryPage::IsValidStoryPage((ScriptStoryPage::StoryPageID)destination)) story_page = ::StoryPage::Get((ScriptStoryPage::StoryPageID)destination); @@ -50,7 +50,7 @@ (type == GT_COMPANY && ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)destination) != ScriptCompany::COMPANY_INVALID) || (type == GT_STORY_PAGE && story_page != nullptr && (c == INVALID_COMPANY ? story_page->company == INVALID_COMPANY : story_page->company == INVALID_COMPANY || story_page->company == c))); - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnGoalID, 0, type | (c << 8), destination, text)) return GOAL_INVALID; + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnGoalID, c, (::GoalType)type, destination, text)) return GOAL_INVALID; /* In case of test-mode, we return GoalID 0 */ return (ScriptGoal::GoalID)0; @@ -61,7 +61,7 @@ EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, IsValidGoal(goal_id)); - return ScriptObject::Command::Do(0, goal_id, 0, {}); + return ScriptObject::Command::Do(goal_id); } /* static */ bool ScriptGoal::SetText(GoalID goal_id, Text *goal) @@ -73,7 +73,7 @@ EnforcePrecondition(false, goal != nullptr); EnforcePrecondition(false, !StrEmpty(goal->GetEncodedText())); - return ScriptObject::Command::Do(0, goal_id, 0, goal->GetEncodedText()); + return ScriptObject::Command::Do(goal_id, goal->GetEncodedText()); } /* static */ bool ScriptGoal::SetProgress(GoalID goal_id, Text *progress) @@ -88,7 +88,7 @@ progress = nullptr; } - return ScriptObject::Command::Do(0, goal_id, 0, progress != nullptr ? std::string{ progress->GetEncodedText() } : std::string{}); + return ScriptObject::Command::Do(goal_id, progress != nullptr ? std::string{ progress->GetEncodedText() } : std::string{}); } /* static */ bool ScriptGoal::SetCompleted(GoalID goal_id, bool completed) @@ -96,7 +96,7 @@ EnforcePrecondition(false, IsValidGoal(goal_id)); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); - return ScriptObject::Command::Do(0, goal_id, completed ? 1 : 0, {}); + return ScriptObject::Command::Do(goal_id, completed); } /* static */ bool ScriptGoal::IsCompleted(GoalID goal_id) @@ -121,7 +121,7 @@ EnforcePrecondition(false, buttons < (1 << ::GOAL_QUESTION_BUTTON_COUNT)); EnforcePrecondition(false, (int)type < ::GQT_END); - return ScriptObject::Command::Do(0, uniqueid | (target << 16), buttons | (type << 29) | (is_client ? (1 << 31) : 0), text); + return ScriptObject::Command::Do(uniqueid, target, is_client, buttons, (::GoalQuestionType)type, text); } /* static */ bool ScriptGoal::Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, int buttons) @@ -146,5 +146,5 @@ { EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); - return ScriptObject::Command::Do(0, uniqueid, 0, {}); + return ScriptObject::Command::Do(uniqueid, 0); } diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp index afa259041..f767472e0 100644 --- a/src/script/api/script_story_page.cpp +++ b/src/script/api/script_story_page.cpp @@ -49,10 +49,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnStoryPageID, - 0, - c, - 0, - title != nullptr ? std::string{ title->GetEncodedText() } : std::string{})) return STORY_PAGE_INVALID; + (::CompanyID)c, title != nullptr ? std::string{ title->GetEncodedText() } : std::string{})) return STORY_PAGE_INVALID; /* In case of test-mode, we return StoryPageID 0 */ return (ScriptStoryPage::StoryPageID)0; @@ -91,7 +88,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnStoryPageElementID, reftile, - story_page_id + (type << 16), + (::StoryPageID)story_page_id, (::StoryPageElementType)type, refid, StoryPageElementTypeRequiresText(btype) ? std::string{ text->GetEncodedText() } : std::string{})) return STORY_PAGE_ELEMENT_INVALID; @@ -160,7 +157,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); - return ScriptObject::Command::Do(0, story_page_id, 0, title != nullptr ? std::string{ title->GetEncodedText() } : std::string{}); + return ScriptObject::Command::Do(story_page_id, title != nullptr ? std::string{ title->GetEncodedText() } : std::string{}); } /* static */ ScriptCompany::CompanyID ScriptStoryPage::GetCompany(StoryPageID story_page_id) @@ -186,7 +183,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); - return ScriptObject::Command::Do(0, story_page_id, date, {}); + return ScriptObject::Command::Do(story_page_id, date); } @@ -195,7 +192,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); - return ScriptObject::Command::Do(0, story_page_id, 0, {}); + return ScriptObject::Command::Do(story_page_id); } /* static */ bool ScriptStoryPage::Remove(StoryPageID story_page_id) @@ -203,7 +200,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, IsValidStoryPage(story_page_id)); - return ScriptObject::Command::Do(0, story_page_id, 0, {}); + return ScriptObject::Command::Do(story_page_id); } /* static */ bool ScriptStoryPage::RemoveElement(StoryPageElementID story_page_element_id) @@ -211,7 +208,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, IsValidStoryPageElement(story_page_element_id)); - return ScriptObject::Command::Do(0, story_page_element_id, 0, {}); + return ScriptObject::Command::Do(story_page_element_id); } /* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakePushButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags) -- cgit v1.2.3-54-g00ecf