diff options
Diffstat (limited to 'src/script/api/script_goal.cpp')
-rw-r--r-- | src/script/api/script_goal.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index f1b75b032..dbc2c51e0 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -19,6 +19,7 @@ #include "../../goal_base.h" #include "../../string_func.h" #include "../../network/network_base.h" +#include "../../goal_cmd.h" #include "../../safeguards.h" @@ -49,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::DoCommand(0, type | (c << 8), destination, CMD_CREATE_GOAL, text, &ScriptInstance::DoCommandReturnGoalID)) return GOAL_INVALID; + if (!ScriptObject::Command<CMD_CREATE_GOAL>::Do(&ScriptInstance::DoCommandReturnGoalID, 0, type | (c << 8), destination, text)) return GOAL_INVALID; /* In case of test-mode, we return GoalID 0 */ return (ScriptGoal::GoalID)0; @@ -60,7 +61,7 @@ EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); EnforcePrecondition(false, IsValidGoal(goal_id)); - return ScriptObject::DoCommand(0, goal_id, 0, CMD_REMOVE_GOAL); + return ScriptObject::Command<CMD_REMOVE_GOAL>::Do(0, goal_id, 0, {}); } /* static */ bool ScriptGoal::SetText(GoalID goal_id, Text *goal) @@ -72,7 +73,7 @@ EnforcePrecondition(false, goal != nullptr); EnforcePrecondition(false, !StrEmpty(goal->GetEncodedText())); - return ScriptObject::DoCommand(0, goal_id, 0, CMD_SET_GOAL_TEXT, goal->GetEncodedText()); + return ScriptObject::Command<CMD_SET_GOAL_TEXT>::Do(0, goal_id, 0, goal->GetEncodedText()); } /* static */ bool ScriptGoal::SetProgress(GoalID goal_id, Text *progress) @@ -87,7 +88,7 @@ progress = nullptr; } - return ScriptObject::DoCommand(0, goal_id, 0, CMD_SET_GOAL_PROGRESS, progress != nullptr ? progress->GetEncodedText() : nullptr); + return ScriptObject::Command<CMD_SET_GOAL_PROGRESS>::Do(0, goal_id, 0, progress != nullptr ? std::string{ progress->GetEncodedText() } : std::string{}); } /* static */ bool ScriptGoal::SetCompleted(GoalID goal_id, bool completed) @@ -95,7 +96,7 @@ EnforcePrecondition(false, IsValidGoal(goal_id)); EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); - return ScriptObject::DoCommand(0, goal_id, completed ? 1 : 0, CMD_SET_GOAL_COMPLETED); + return ScriptObject::Command<CMD_SET_GOAL_COMPLETED>::Do(0, goal_id, completed ? 1 : 0, {}); } /* static */ bool ScriptGoal::IsCompleted(GoalID goal_id) @@ -120,7 +121,7 @@ EnforcePrecondition(false, buttons < (1 << ::GOAL_QUESTION_BUTTON_COUNT)); EnforcePrecondition(false, (int)type < ::GQT_END); - return ScriptObject::DoCommand(0, uniqueid | (target << 16), buttons | (type << 29) | (is_client ? (1 << 31) : 0), CMD_GOAL_QUESTION, text); + return ScriptObject::Command<CMD_GOAL_QUESTION>::Do(0, uniqueid | (target << 16), buttons | (type << 29) | (is_client ? (1 << 31) : 0), text); } /* static */ bool ScriptGoal::Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, int buttons) @@ -145,5 +146,5 @@ { EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY); - return ScriptObject::DoCommand(0, uniqueid, 0, CMD_GOAL_QUESTION_ANSWER); + return ScriptObject::Command<CMD_GOAL_QUESTION_ANSWER>::Do(0, uniqueid, 0, {}); } |