diff options
author | truebrain <truebrain@openttd.org> | 2011-12-19 21:06:06 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-12-19 21:06:06 +0000 |
commit | 102f811d0277afefe5c90762c0c4cc11ab69713c (patch) | |
tree | 1c7343e8031eab2c764cff974bd9df9a814c3dd9 /src/script/api/script_goal.cpp | |
parent | b0ac529a6ff4e087520a14d2a0169f445952e7e0 (diff) | |
download | openttd-102f811d0277afefe5c90762c0c4cc11ab69713c.tar.xz |
(svn r23636) -Add: introduce ScriptText in parameters where it can be used
Diffstat (limited to 'src/script/api/script_goal.cpp')
-rw-r--r-- | src/script/api/script_goal.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index 85aaeedb6..e005ceda0 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -28,16 +28,19 @@ return ::Goal::IsValidID(goal_id); } -/* static */ ScriptGoal::GoalID ScriptGoal::New(ScriptCompany::CompanyID company, const char *goal, GoalType type, uint32 destination) +/* static */ ScriptGoal::GoalID ScriptGoal::New(ScriptCompany::CompanyID company, Text *goal, GoalType type, uint32 destination) { - EnforcePrecondition(GOAL_INVALID, !StrEmpty(goal)); + CCountedPtr<Text> counter(goal); + + EnforcePrecondition(GOAL_INVALID, goal != NULL); + EnforcePrecondition(GOAL_INVALID, !StrEmpty(goal->GetEncodedText())); 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; - if (!ScriptObject::DoCommand(0, type | (c << 8), destination, CMD_CREATE_GOAL, goal, &ScriptInstance::DoCommandReturnGoalID)) return GOAL_INVALID; + if (!ScriptObject::DoCommand(0, type | (c << 8), destination, CMD_CREATE_GOAL, goal->GetEncodedText(), &ScriptInstance::DoCommandReturnGoalID)) return GOAL_INVALID; /* In case of test-mode, we return GoalID 0 */ return (ScriptGoal::GoalID)0; |