File diff r26116:c6706853a5ab → r26117:dec8ad7628ec
src/script/api/script_goal.cpp
Show inline comments
 
@@ -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<CMD_CREATE_GOAL>::Do(&ScriptInstance::DoCommandReturnGoalID, 0, type | (c << 8), destination, text)) return GOAL_INVALID;
 
	if (!ScriptObject::Command<CMD_CREATE_GOAL>::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<CMD_REMOVE_GOAL>::Do(0, goal_id, 0, {});
 
	return ScriptObject::Command<CMD_REMOVE_GOAL>::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<CMD_SET_GOAL_TEXT>::Do(0, goal_id, 0, goal->GetEncodedText());
 
	return ScriptObject::Command<CMD_SET_GOAL_TEXT>::Do(goal_id, goal->GetEncodedText());
 
}
 

	
 
/* static */ bool ScriptGoal::SetProgress(GoalID goal_id, Text *progress)
 
@@ -88,7 +88,7 @@
 
		progress = nullptr;
 
	}
 

	
 
	return ScriptObject::Command<CMD_SET_GOAL_PROGRESS>::Do(0, goal_id, 0, progress != nullptr ? std::string{ progress->GetEncodedText() } : std::string{});
 
	return ScriptObject::Command<CMD_SET_GOAL_PROGRESS>::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<CMD_SET_GOAL_COMPLETED>::Do(0, goal_id, completed ? 1 : 0, {});
 
	return ScriptObject::Command<CMD_SET_GOAL_COMPLETED>::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<CMD_GOAL_QUESTION>::Do(0, uniqueid | (target << 16), buttons | (type << 29) | (is_client ? (1 << 31) : 0), text);
 
	return ScriptObject::Command<CMD_GOAL_QUESTION>::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<CMD_GOAL_QUESTION_ANSWER>::Do(0, uniqueid, 0, {});
 
	return ScriptObject::Command<CMD_GOAL_QUESTION_ANSWER>::Do(uniqueid, 0);
 
}