Codechange: Pass encoded script strings as EncodedString.

This removes the ambiguity of having std::strings that may or may not be encoded.
This commit is contained in:
Peter Nelson
2025-03-04 01:00:40 +00:00
committed by Peter Nelson
parent 2a05a845df
commit b55af05626
34 changed files with 126 additions and 114 deletions

View File

@@ -56,7 +56,7 @@ StoryPage::~StoryPage()
* @param text The text parameter of the DoCommand proc
* @return true, if and only if the given parameters are valid for the given page element type and page id.
*/
static bool VerifyElementContentParameters(StoryPageID page_id, StoryPageElementType type, TileIndex tile, uint32_t reference, const std::string &text)
static bool VerifyElementContentParameters(StoryPageID page_id, StoryPageElementType type, TileIndex tile, uint32_t reference, const EncodedString &text)
{
StoryPageButtonData button_data{ reference };
@@ -103,7 +103,7 @@ static bool VerifyElementContentParameters(StoryPageID page_id, StoryPageElement
* @param reference The reference parameter of the DoCommand proc (p2)
* @param text The text parameter of the DoCommand proc
*/
static void UpdateElement(StoryPageElement &pe, TileIndex tile, uint32_t reference, const std::string &text)
static void UpdateElement(StoryPageElement &pe, TileIndex tile, uint32_t reference, const EncodedString &text)
{
switch (pe.type) {
case SPET_TEXT:
@@ -215,7 +215,7 @@ bool StoryPageButtonData::ValidateVehicleType() const
* @param text Title of the story page. Null is allowed in which case a generic page title is provided by OpenTTD.
* @return the cost of this operation or an error
*/
std::tuple<CommandCost, StoryPageID> CmdCreateStoryPage(DoCommandFlags flags, CompanyID company, const std::string &text)
std::tuple<CommandCost, StoryPageID> CmdCreateStoryPage(DoCommandFlags flags, CompanyID company, const EncodedString &text)
{
if (!StoryPage::CanAllocateItem()) return { CMD_ERROR, StoryPageID::Invalid() };
@@ -250,7 +250,7 @@ std::tuple<CommandCost, StoryPageID> CmdCreateStoryPage(DoCommandFlags flags, Co
* @param text Text content in case it is a text or location page element
* @return the cost of this operation or an error
*/
std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement(DoCommandFlags flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32_t reference, const std::string &text)
std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement(DoCommandFlags flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32_t reference, const EncodedString &text)
{
if (!StoryPageElement::CanAllocateItem()) return { CMD_ERROR, StoryPageElementID::Invalid() };
@@ -293,7 +293,7 @@ std::tuple<CommandCost, StoryPageElementID> CmdCreateStoryPageElement(DoCommandF
* @param text Text content in case it is a text or location page element
* @return the cost of this operation or an error
*/
CommandCost CmdUpdateStoryPageElement(DoCommandFlags flags, TileIndex tile, StoryPageElementID page_element_id, uint32_t reference, const std::string &text)
CommandCost CmdUpdateStoryPageElement(DoCommandFlags flags, TileIndex tile, StoryPageElementID page_element_id, uint32_t reference, const EncodedString &text)
{
if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
@@ -319,7 +319,7 @@ CommandCost CmdUpdateStoryPageElement(DoCommandFlags flags, TileIndex tile, Stor
* @param text title text of the story page.
* @return the cost of this operation or an error
*/
CommandCost CmdSetStoryPageTitle(DoCommandFlags flags, StoryPageID page_id, const std::string &text)
CommandCost CmdSetStoryPageTitle(DoCommandFlags flags, StoryPageID page_id, const EncodedString &text)
{
if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;