summaryrefslogtreecommitdiff
path: root/src/script/api/script_story_page.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-11-01 21:30:34 +0100
committerMichael Lutz <michi@icosahedron.de>2021-12-16 22:28:32 +0100
commit6691ee3b963ee3282490360bb3cc1ea09d0c58ea (patch)
tree398b1139844d2566831e249836b6923bd88b6124 /src/script/api/script_story_page.cpp
parenteab18f06a47e558fe313cb86c855e8949b01feed (diff)
downloadopenttd-6691ee3b963ee3282490360bb3cc1ea09d0c58ea.tar.xz
Codechange: Template script command calls.
Diffstat (limited to 'src/script/api/script_story_page.cpp')
-rw-r--r--src/script/api/script_story_page.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp
index 4ee90e218..afa259041 100644
--- a/src/script/api/script_story_page.cpp
+++ b/src/script/api/script_story_page.cpp
@@ -19,6 +19,7 @@
#include "../../goal_base.h"
#include "../../string_func.h"
#include "../../tile_map.h"
+#include "../../story_cmd.h"
#include "../../safeguards.h"
@@ -47,12 +48,11 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
uint8 c = company;
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
- if (!ScriptObject::DoCommand(0,
+ if (!ScriptObject::Command<CMD_CREATE_STORY_PAGE>::Do(&ScriptInstance::DoCommandReturnStoryPageID,
+ 0,
c,
0,
- CMD_CREATE_STORY_PAGE,
- title != nullptr? title->GetEncodedText() : nullptr,
- &ScriptInstance::DoCommandReturnStoryPageID)) return STORY_PAGE_INVALID;
+ 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;
@@ -89,12 +89,11 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
NOT_REACHED();
}
- if (!ScriptObject::DoCommand(reftile,
+ if (!ScriptObject::Command<CMD_CREATE_STORY_PAGE_ELEMENT>::Do(&ScriptInstance::DoCommandReturnStoryPageElementID,
+ reftile,
story_page_id + (type << 16),
refid,
- CMD_CREATE_STORY_PAGE_ELEMENT,
- StoryPageElementTypeRequiresText(btype) ? text->GetEncodedText() : nullptr,
- &ScriptInstance::DoCommandReturnStoryPageElementID)) return STORY_PAGE_ELEMENT_INVALID;
+ StoryPageElementTypeRequiresText(btype) ? std::string{ text->GetEncodedText() } : std::string{})) return STORY_PAGE_ELEMENT_INVALID;
/* In case of test-mode, we return StoryPageElementID 0 */
return (ScriptStoryPage::StoryPageElementID)0;
@@ -134,11 +133,10 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
NOT_REACHED();
}
- return ScriptObject::DoCommand(reftile,
+ return ScriptObject::Command<CMD_UPDATE_STORY_PAGE_ELEMENT>::Do(reftile,
story_page_element_id,
refid,
- CMD_UPDATE_STORY_PAGE_ELEMENT,
- StoryPageElementTypeRequiresText(type) ? text->GetEncodedText() : nullptr);
+ StoryPageElementTypeRequiresText(type) ? std::string{ text->GetEncodedText() } : std::string{});
}
/* static */ uint32 ScriptStoryPage::GetPageSortValue(StoryPageID story_page_id)
@@ -162,7 +160,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, IsValidStoryPage(story_page_id));
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
- return ScriptObject::DoCommand(0, story_page_id, 0, CMD_SET_STORY_PAGE_TITLE, title != nullptr? title->GetEncodedText() : nullptr);
+ return ScriptObject::Command<CMD_SET_STORY_PAGE_TITLE>::Do(0, story_page_id, 0, title != nullptr ? std::string{ title->GetEncodedText() } : std::string{});
}
/* static */ ScriptCompany::CompanyID ScriptStoryPage::GetCompany(StoryPageID story_page_id)
@@ -188,7 +186,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, IsValidStoryPage(story_page_id));
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
- return ScriptObject::DoCommand(0, story_page_id, date, CMD_SET_STORY_PAGE_DATE, nullptr);
+ return ScriptObject::Command<CMD_SET_STORY_PAGE_DATE>::Do(0, story_page_id, date, {});
}
@@ -197,7 +195,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, IsValidStoryPage(story_page_id));
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
- return ScriptObject::DoCommand(0, story_page_id, 0, CMD_SHOW_STORY_PAGE);
+ return ScriptObject::Command<CMD_SHOW_STORY_PAGE>::Do(0, story_page_id, 0, {});
}
/* static */ bool ScriptStoryPage::Remove(StoryPageID story_page_id)
@@ -205,7 +203,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
EnforcePrecondition(false, IsValidStoryPage(story_page_id));
- return ScriptObject::DoCommand(0, story_page_id, 0, CMD_REMOVE_STORY_PAGE);
+ return ScriptObject::Command<CMD_REMOVE_STORY_PAGE>::Do(0, story_page_id, 0, {});
}
/* static */ bool ScriptStoryPage::RemoveElement(StoryPageElementID story_page_element_id)
@@ -213,7 +211,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type)
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
EnforcePrecondition(false, IsValidStoryPageElement(story_page_element_id));
- return ScriptObject::DoCommand(0, story_page_element_id, 0, CMD_REMOVE_STORY_PAGE_ELEMENT);
+ return ScriptObject::Command<CMD_REMOVE_STORY_PAGE_ELEMENT>::Do(0, story_page_element_id, 0, {});
}
/* static */ ScriptStoryPage::StoryPageButtonFormatting ScriptStoryPage::MakePushButtonReference(StoryPageButtonColour colour, StoryPageButtonFlags flags)