diff options
30 files changed, 194 insertions, 104 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index 42918b2be..695a01d8a 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -69,6 +69,7 @@ #include "../script/api/ai/ai_subsidy.hpp.sq" #include "../script/api/ai/ai_subsidylist.hpp.sq" #include "../script/api/ai/ai_testmode.hpp.sq" +#include "../script/api/ai/ai_text.hpp.sq" #include "../script/api/ai/ai_tile.hpp.sq" #include "../script/api/ai/ai_tilelist.hpp.sq" #include "../script/api/ai/ai_town.hpp.sq" @@ -171,6 +172,7 @@ void AIInstance::RegisterAPI() SQAISubsidy_Register(this->engine); SQAISubsidyList_Register(this->engine); SQAITestMode_Register(this->engine); + SQAIText_Register(this->engine); SQAITile_Register(this->engine); SQAITileList_Register(this->engine); SQAITileList_IndustryAccepting_Register(this->engine); diff --git a/src/command.cpp b/src/command.cpp index 47d305021..43d1f901b 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -207,7 +207,7 @@ static const Command _command_proc_table[] = { DEF_CMD(CmdRemoveFromRailStation, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_FROM_RAIL_STATION DEF_CMD(CmdConvertRail, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_CONVERT_RAILD DEF_CMD(CmdBuildRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAIL_WAYPOINT - DEF_CMD(CmdRenameWaypoint, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_WAYPOINT + DEF_CMD(CmdRenameWaypoint, CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_WAYPOINT DEF_CMD(CmdRemoveFromRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_FROM_RAIL_WAYPOINT DEF_CMD(CmdBuildRoadStop, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_ROAD_STOP @@ -249,17 +249,17 @@ static const Command _command_proc_table[] = { DEF_CMD(CmdWantEnginePreview, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_WANT_ENGINE_PREVIEW - DEF_CMD(CmdRenameVehicle, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_VEHICLE - DEF_CMD(CmdRenameEngine, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_ENGINE + DEF_CMD(CmdRenameVehicle, CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_VEHICLE + DEF_CMD(CmdRenameEngine, CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_ENGINE - DEF_CMD(CmdRenameCompany, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_COMPANY - DEF_CMD(CmdRenamePresident, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_PRESIDENT + DEF_CMD(CmdRenameCompany, CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_COMPANY + DEF_CMD(CmdRenamePresident, CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_PRESIDENT - DEF_CMD(CmdRenameStation, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_STATION - DEF_CMD(CmdRenameDepot, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_DEPOT + DEF_CMD(CmdRenameStation, CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_STATION + DEF_CMD(CmdRenameDepot, CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_DEPOT - DEF_CMD(CmdPlaceSign, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_PLACE_SIGN - DEF_CMD(CmdRenameSign, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_SIGN + DEF_CMD(CmdPlaceSign, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_PLACE_SIGN + DEF_CMD(CmdRenameSign, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_SIGN DEF_CMD(CmdTurnRoadVeh, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_TURN_ROADVEH @@ -270,11 +270,11 @@ static const Command _command_proc_table[] = { DEF_CMD(CmdBuyCompany, 0, CMDT_MONEY_MANAGEMENT ), // CMD_BUY_COMANY DEF_CMD(CmdFoundTown, CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_FOUND_TOWN; founding random town can fail only in exec run - DEF_CMD(CmdRenameTown, CMD_SERVER, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_TOWN + DEF_CMD(CmdRenameTown, CMD_STR_CTRL | CMD_SERVER, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_TOWN DEF_CMD(CmdDoTownAction, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_DO_TOWN_ACTION DEF_CMD(CmdTownCargoGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_CARGO_GOAL DEF_CMD(CmdTownGrowthRate, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_GROWTH_RATE - DEF_CMD(CmdTownSetText, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_SET_TEXT + DEF_CMD(CmdTownSetText, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_SET_TEXT DEF_CMD(CmdExpandTown, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_EXPAND_TOWN DEF_CMD(CmdDeleteTown, CMD_OFFLINE, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_DELETE_TOWN @@ -287,8 +287,8 @@ static const Command _command_proc_table[] = { DEF_CMD(CmdBuildCanal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_CANAL DEF_CMD(CmdCreateSubsidy, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_SUBSIDY DEF_CMD(CmdCompanyCtrl, CMD_SPECTATOR | CMD_CLIENT_ID, CMDT_SERVER_SETTING ), // CMD_COMPANY_CTRL - DEF_CMD(CmdCustomNewsItem, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CUSTOM_NEWS_ITEM - DEF_CMD(CmdCreateGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_GOAL + DEF_CMD(CmdCustomNewsItem, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CUSTOM_NEWS_ITEM + DEF_CMD(CmdCreateGoal, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_GOAL DEF_CMD(CmdRemoveGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_GOAL DEF_CMD(CmdLevelLand, CMD_ALL_TILES | CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_LEVEL_LAND; test run might clear tiles multiple times, in execution that only happens once @@ -310,7 +310,7 @@ static const Command _command_proc_table[] = { DEF_CMD(CmdDepotMassAutoReplace, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_DEPOT_MASS_AUTOREPLACE DEF_CMD(CmdCreateGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CREATE_GROUP DEF_CMD(CmdDeleteGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DELETE_GROUP - DEF_CMD(CmdRenameGroup, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_GROUP + DEF_CMD(CmdRenameGroup, CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_GROUP DEF_CMD(CmdAddVehicleGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ADD_VEHICLE_GROUP DEF_CMD(CmdAddSharedVehicleGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ADD_SHARE_VEHICLE_GROUP DEF_CMD(CmdRemoveAllVehiclesGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_REMOVE_ALL_VEHICLES_GROUP diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 5b0e62377..27c9054f6 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -235,11 +235,11 @@ void AfterLoadCompanyStats() static const SaveLoad _company_desc[] = { SLE_VAR(CompanyProperties, name_2, SLE_UINT32), SLE_VAR(CompanyProperties, name_1, SLE_STRINGID), - SLE_CONDSTR(CompanyProperties, name, SLE_STR, 0, 84, SL_MAX_VERSION), + SLE_CONDSTR(CompanyProperties, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION), SLE_VAR(CompanyProperties, president_name_1, SLE_UINT16), SLE_VAR(CompanyProperties, president_name_2, SLE_UINT32), - SLE_CONDSTR(CompanyProperties, president_name, SLE_STR, 0, 84, SL_MAX_VERSION), + SLE_CONDSTR(CompanyProperties, president_name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION), SLE_VAR(CompanyProperties, face, SLE_UINT32), diff --git a/src/saveload/goal_sl.cpp b/src/saveload/goal_sl.cpp index 721909a77..b8df122b3 100644 --- a/src/saveload/goal_sl.cpp +++ b/src/saveload/goal_sl.cpp @@ -18,7 +18,7 @@ static const SaveLoad _goals_desc[] = { SLE_VAR(Goal, company, SLE_UINT16), SLE_VAR(Goal, type, SLE_UINT16), SLE_VAR(Goal, dst, SLE_UINT32), - SLE_STR(Goal, text, SLE_STR, 0), + SLE_STR(Goal, text, SLE_STR | SLF_ALLOW_CONTROL, 0), SLE_END() }; diff --git a/src/saveload/group_sl.cpp b/src/saveload/group_sl.cpp index ec05d7280..6b833137b 100644 --- a/src/saveload/group_sl.cpp +++ b/src/saveload/group_sl.cpp @@ -16,7 +16,7 @@ static const SaveLoad _group_desc[] = { SLE_CONDVAR(Group, name, SLE_NAME, 0, 83), - SLE_CONDSTR(Group, name, SLE_STR, 0, 84, SL_MAX_VERSION), + SLE_CONDSTR(Group, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION), SLE_CONDNULL(2, 0, 163), // num_vehicle SLE_VAR(Group, owner, SLE_UINT8), SLE_VAR(Group, vehicle_type, SLE_UINT8), diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp index fcdf859d4..918f9e213 100644 --- a/src/saveload/signs_sl.cpp +++ b/src/saveload/signs_sl.cpp @@ -17,7 +17,7 @@ /** Description of a sign within the savegame. */ static const SaveLoad _sign_desc[] = { SLE_CONDVAR(Sign, name, SLE_NAME, 0, 83), - SLE_CONDSTR(Sign, name, SLE_STR, 0, 84, SL_MAX_VERSION), + SLE_CONDSTR(Sign, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION), SLE_CONDVAR(Sign, x, SLE_FILE_I16 | SLE_VAR_I32, 0, 4), SLE_CONDVAR(Sign, y, SLE_FILE_I16 | SLE_VAR_I32, 0, 4), SLE_CONDVAR(Sign, x, SLE_INT32, 5, SL_MAX_VERSION), diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index c8864d6df..c26f35454 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -182,7 +182,7 @@ static const SaveLoad _old_station_desc[] = { SLE_CONDNULL(1, 0, 3), ///< alpha_order SLE_VAR(Station, string_id, SLE_STRINGID), - SLE_CONDSTR(Station, name, SLE_STR, 0, 84, SL_MAX_VERSION), + SLE_CONDSTR(Station, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION), SLE_CONDVAR(Station, indtype, SLE_UINT8, 103, SL_MAX_VERSION), SLE_CONDVAR(Station, had_vehicle_of_type, SLE_FILE_U16 | SLE_VAR_U8, 0, 121), SLE_CONDVAR(Station, had_vehicle_of_type, SLE_UINT8, 122, SL_MAX_VERSION), @@ -331,7 +331,7 @@ static const SaveLoad _base_station_desc[] = { SLE_VAR(BaseStation, xy, SLE_UINT32), SLE_REF(BaseStation, town, REF_TOWN), SLE_VAR(BaseStation, string_id, SLE_STRINGID), - SLE_STR(BaseStation, name, SLE_STR, 0), + SLE_STR(BaseStation, name, SLE_STR | SLF_ALLOW_CONTROL, 0), SLE_VAR(BaseStation, delete_ctr, SLE_UINT8), SLE_VAR(BaseStation, owner, SLE_UINT8), SLE_VAR(BaseStation, facilities, SLE_UINT8), diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp index 1a424308c..3af31c57c 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -114,7 +114,7 @@ static const SaveLoad _town_desc[] = { SLE_CONDVAR(Town, townnamegrfid, SLE_UINT32, 66, SL_MAX_VERSION), SLE_VAR(Town, townnametype, SLE_UINT16), SLE_VAR(Town, townnameparts, SLE_UINT32), - SLE_CONDSTR(Town, name, SLE_STR, 0, 84, SL_MAX_VERSION), + SLE_CONDSTR(Town, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION), SLE_VAR(Town, flags, SLE_UINT8), SLE_CONDVAR(Town, statues, SLE_FILE_U8 | SLE_VAR_U16, 0, 103), @@ -157,7 +157,7 @@ static const SaveLoad _town_desc[] = { SLE_CONDARR(Town, goal, SLE_UINT32, NUM_TE, 165, SL_MAX_VERSION), - SLE_CONDSTR(Town, text, SLE_STR, 0, 168, SL_MAX_VERSION), + SLE_CONDSTR(Town, text, SLE_STR | SLF_ALLOW_CONTROL, 0, 168, SL_MAX_VERSION), SLE_CONDVAR(Town, time_until_rebuild, SLE_FILE_U8 | SLE_VAR_U16, 0, 53), SLE_CONDVAR(Town, grow_counter, SLE_FILE_U8 | SLE_VAR_U16, 0, 53), diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 9c8f25800..19c615ab1 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -554,7 +554,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_REF(Vehicle, next, REF_VEHICLE_OLD), SLE_CONDVAR(Vehicle, name, SLE_NAME, 0, 83), - SLE_CONDSTR(Vehicle, name, SLE_STR, 0, 84, SL_MAX_VERSION), + SLE_CONDSTR(Vehicle, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION), SLE_CONDVAR(Vehicle, unitnumber, SLE_FILE_U8 | SLE_VAR_U16, 0, 7), SLE_CONDVAR(Vehicle, unitnumber, SLE_UINT16, 8, SL_MAX_VERSION), SLE_VAR(Vehicle, owner, SLE_UINT8), diff --git a/src/script/api/ai/ai_text.hpp.sq b/src/script/api/ai/ai_text.hpp.sq new file mode 100644 index 000000000..e1d8e96c6 --- /dev/null +++ b/src/script/api/ai/ai_text.hpp.sq @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */ + +#include "../script_text.hpp" +#include "../template/template_text.hpp.sq" + + +template <> const char *GetClassName<ScriptText, ST_AI>() { return "AIText"; } + +void SQAIText_Register(Squirrel *engine) +{ + DefSQClass<ScriptText, ST_AI> SQAIText("AIText"); + SQAIText.PreRegister(engine); + SQAIText.AddConstructor<void (ScriptText::*)(StringID string), 2>(engine, "xi"); + + SQAIText.DefSQConst(engine, ScriptText::SCRIPT_TEXT_MAX_PARAMETERS, "SCRIPT_TEXT_MAX_PARAMETERS"); + + SQAIText.DefSQAdvancedMethod(engine, &ScriptText::_set, "_set"); + SQAIText.DefSQAdvancedMethod(engine, &ScriptText::SetParam, "SetParam"); + SQAIText.DefSQAdvancedMethod(engine, &ScriptText::AddParam, "AddParam"); + + SQAIText.PostRegister(engine); +} diff --git a/src/script/api/game/game_company.hpp.sq b/src/script/api/game/game_company.hpp.sq index e90b1a8a4..98c6d4476 100644 --- a/src/script/api/game/game_company.hpp.sq +++ b/src/script/api/game/game_company.hpp.sq @@ -32,7 +32,9 @@ void SQGSCompany_Register(Squirrel *engine) SQGSCompany.DefSQConst(engine, ScriptCompany::GENDER_INVALID, "GENDER_INVALID"); SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::ResolveCompanyID, "ResolveCompanyID", 2, ".i"); + SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::SetName, "SetName", 2, ".."); SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::GetName, "GetName", 2, ".i"); + SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::SetPresidentName, "SetPresidentName", 2, ".."); SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::GetPresidentName, "GetPresidentName", 2, ".i"); SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::GetPresidentGender, "GetPresidentGender", 2, ".i"); SQGSCompany.DefSQStaticMethod(engine, &ScriptCompany::SetLoanAmount, "SetLoanAmount", 2, ".i"); diff --git a/src/script/api/script_basestation.cpp b/src/script/api/script_basestation.cpp index 84c41abce..ff4de1cff 100644 --- a/src/script/api/script_basestation.cpp +++ b/src/script/api/script_basestation.cpp @@ -34,14 +34,18 @@ return name; } -/* static */ bool ScriptBaseStation::SetName(StationID station_id, const char *name) +/* static */ bool ScriptBaseStation::SetName(StationID station_id, Text *name) { + CCountedPtr<Text> counter(name); + EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY); EnforcePrecondition(false, IsValidBaseStation(station_id)); - EnforcePrecondition(false, !::StrEmpty(name)); - EnforcePreconditionCustomError(false, ::Utf8StringLength(name) < MAX_LENGTH_STATION_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); + EnforcePrecondition(false, name != NULL); + const char *text = name->GetEncodedText(); + EnforcePrecondition(false, !::StrEmpty(text)); + EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_STATION_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::DoCommand(0, station_id, 0, ::Station::IsValidID(station_id) ? CMD_RENAME_STATION : CMD_RENAME_WAYPOINT, name); + return ScriptObject::DoCommand(0, station_id, 0, ::Station::IsValidID(station_id) ? CMD_RENAME_STATION : CMD_RENAME_WAYPOINT, text); } /* static */ TileIndex ScriptBaseStation::GetLocation(StationID station_id) diff --git a/src/script/api/script_basestation.hpp b/src/script/api/script_basestation.hpp index 7007985ae..02ad4b716 100644 --- a/src/script/api/script_basestation.hpp +++ b/src/script/api/script_basestation.hpp @@ -13,6 +13,7 @@ #define SCRIPT_BASESTATION_HPP #include "script_error.hpp" +#include "script_text.hpp" /** * Base class for stations and waypoints. @@ -49,15 +50,14 @@ public: /** * Set the name this basestation. * @param station_id The basestation to set the name of. - * @param name The new name of the station. + * @param name The new name of the station (can be either a raw string, or a ScriptText object). * @pre IsValidBaseStation(station_id). - * @pre 'name' must have at least one character. - * @pre 'name' must have at most 30 characters. + * @pre name != NULL && len(name) != 0. * @game @pre Valid ScriptCompanyMode active in scope. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if the name was changed. */ - static bool SetName(StationID station_id, const char *name); + static bool SetName(StationID station_id, Text *name); /** * Get the current location of a basestation. diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp index efc2848a5..d4bc5d3e7 100644 --- a/src/script/api/script_company.cpp +++ b/src/script/api/script_company.cpp @@ -39,12 +39,16 @@ return ResolveCompanyID(company) == ResolveCompanyID(COMPANY_SELF); } -/* static */ bool ScriptCompany::SetName(const char *name) +/* static */ bool ScriptCompany::SetName(Text *name) { - EnforcePrecondition(false, !::StrEmpty(name)); - EnforcePreconditionCustomError(false, ::Utf8StringLength(name) < MAX_LENGTH_COMPANY_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); + CCountedPtr<Text> counter(name); - return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_COMPANY, name); + EnforcePrecondition(false, name != NULL); + const char *text = name->GetEncodedText(); + EnforcePrecondition(false, !::StrEmpty(text)); + EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_COMPANY_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); + + return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_COMPANY, text); } /* static */ char *ScriptCompany::GetName(ScriptCompany::CompanyID company) @@ -60,11 +64,15 @@ return company_name; } -/* static */ bool ScriptCompany::SetPresidentName(const char *name) +/* static */ bool ScriptCompany::SetPresidentName(Text *name) { - EnforcePrecondition(false, !::StrEmpty(name)); + CCountedPtr<Text> counter(name); + + EnforcePrecondition(false, name != NULL); + const char *text = name->GetEncodedText(); + EnforcePrecondition(false, !::StrEmpty(text)); - return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, name); + return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, text); } /* static */ char *ScriptCompany::GetPresidentName(ScriptCompany::CompanyID company) diff --git a/src/script/api/script_company.hpp b/src/script/api/script_company.hpp index de15b7ab2..04c3a5abc 100644 --- a/src/script/api/script_company.hpp +++ b/src/script/api/script_company.hpp @@ -13,6 +13,7 @@ #define SCRIPT_COMPANY_HPP #include "script_object.hpp" +#include "script_text.hpp" /** * Class that handles all company related functions. @@ -64,14 +65,12 @@ public: /** * Set the name of your company. - * @param name The new name of the company. - * @pre 'name' must have at least one character. - * @pre 'name' must have at most 30 characters. + * @param name The new name of the company (can be either a raw string, or a ScriptText object). + * @pre name != NULL && len(name) != 0. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if the name was changed. - * @api -game */ - static bool SetName(const char *name); + static bool SetName(Text *name); /** * Get the name of the given company. @@ -83,13 +82,12 @@ public: /** * Set the name of your president. - * @param name The new name of the president. - * @pre 'name' must have at least one character. + * @param name The new name of the president (can be either a raw string, or a ScriptText object). + * @pre name != NULL && len(name) != 0. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if the name was changed. - * @api -game */ - static bool SetPresidentName(const char *name); + static bool SetPresidentName(Text *name); /** * Get the name of the president of the given company. 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; diff --git a/src/script/api/script_goal.hpp b/src/script/api/script_goal.hpp index ac7d8f449..2fad1e843 100644 --- a/src/script/api/script_goal.hpp +++ b/src/script/api/script_goal.hpp @@ -52,14 +52,14 @@ public: /** * Create a new goal. * @param company The company to create the goal for, or ScriptCompany::COMPANY_INVALID for all. - * @param goal The goal to add to the GUI. + * @param goal The goal to add to the GUI (can be either a raw string, or a ScriptText object). * @param type The type of the goal. * @param destination The destination of the #type type. * @return The new GoalID, or GOAL_INVALID if it failed. - * @pre goal != NULL. + * @pre goal != NULL && len(goal) != 0. * @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID. */ - static GoalID New(ScriptCompany::CompanyID company, const char *goal, GoalType type, uint32 destination); + static GoalID New(ScriptCompany::CompanyID company, Text *goal, GoalType type, uint32 destination); /** * Remove a goal from the list. diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp index 4f9ce8a2a..63c022e90 100644 --- a/src/script/api/script_group.cpp +++ b/src/script/api/script_group.cpp @@ -49,13 +49,17 @@ return (ScriptVehicle::VehicleType)((::VehicleType)::Group::Get(group_id)->vehicle_type); } -/* static */ bool ScriptGroup::SetName(GroupID group_id, const char *name) +/* static */ bool ScriptGroup::SetName(GroupID group_id, Text *name) { + CCountedPtr<Text> counter(name); + EnforcePrecondition(false, IsValidGroup(group_id)); - EnforcePrecondition(false, !::StrEmpty(name)); - EnforcePreconditionCustomError(false, ::Utf8StringLength(name) < MAX_LENGTH_GROUP_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); + EnforcePrecondition(false, name != NULL); + const char *text = name->GetEncodedText(); + EnforcePrecondition(false, !::StrEmpty(text)); + EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_GROUP_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::DoCommand(0, group_id, 0, CMD_RENAME_GROUP, name); + return ScriptObject::DoCommand(0, group_id, 0, CMD_RENAME_GROUP, text); } /* static */ char *ScriptGroup::GetName(GroupID group_id) diff --git a/src/script/api/script_group.hpp b/src/script/api/script_group.hpp index 1a549bf53..e1cd7cf4e 100644 --- a/src/script/api/script_group.hpp +++ b/src/script/api/script_group.hpp @@ -68,14 +68,13 @@ public: /** * Set the name of a group. * @param group_id The group to set the name for. - * @param name The name for the group. + * @param name The name for the group (can be either a raw string, or a ScriptText object). * @pre IsValidGroup(group_id). - * @pre 'name' must have at least one character. - * @pre 'name' must have at most 30 characters. + * @pre name != NULL && len(name) != 0 * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if and only if the name was changed. */ - static bool SetName(GroupID group_id, const char *name); + static bool SetName(GroupID group_id, Text *name); /** * Get the name of a group. diff --git a/src/script/api/script_news.cpp b/src/script/api/script_news.cpp index 36ebf9204..d2c5e9343 100644 --- a/src/script/api/script_news.cpp +++ b/src/script/api/script_news.cpp @@ -18,14 +18,17 @@ #include "../../string_func.h" #include "table/strings.h" -/* static */ bool ScriptNews::Create(NewsType type, const char *text, ScriptCompany::CompanyID company) +/* static */ bool ScriptNews::Create(NewsType type, Text *text, ScriptCompany::CompanyID company) { - EnforcePrecondition(false, !StrEmpty(text)); + CCountedPtr<Text> counter(text); + + EnforcePrecondition(false, text != NULL); + EnforcePrecondition(false, !StrEmpty(text->GetEncodedText())); EnforcePrecondition(false, type >= NT_ARRIVAL_COMPANY && type <= NT_GENERAL); EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); uint8 c = company; if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; - return ScriptObject::DoCommand(0, type | (NR_NONE << 8) | (c << 16), 0, CMD_CUSTOM_NEWS_ITEM, text); + return ScriptObject::DoCommand(0, type | (NR_NONE << 8) | (c << 16), 0, CMD_CUSTOM_NEWS_ITEM, text->GetEncodedText()); } diff --git a/src/script/api/script_news.hpp b/src/script/api/script_news.hpp index 51780befc..8edd80df6 100644 --- a/src/script/api/script_news.hpp +++ b/src/script/api/script_news.hpp @@ -13,6 +13,7 @@ #define SCRIPT_NEWS_HPP #include "script_company.hpp" +#include "script_text.hpp" #include "../../news_type.h" /** @@ -49,13 +50,13 @@ public: /** * Create a news messages for a company. * @param type The type of the news. - * @param text The text message to show. + * @param text The text message to show (can be either a raw string, or a ScriptText object). * @param company The company, or COMPANY_INVALID for all companies. * @return True if the action succeeded. * @pre text != NULL. * @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID. */ - static bool Create(NewsType type, const char *text, ScriptCompany::CompanyID company); + static bool Create(NewsType type, Text *text, ScriptCompany::CompanyID company); }; #endif /* SCRIPT_NEWS_HPP */ diff --git a/src/script/api/script_sign.cpp b/src/script/api/script_sign.cpp index b5b8dacbc..352bb185e 100644 --- a/src/script/api/script_sign.cpp +++ b/src/script/api/script_sign.cpp @@ -33,13 +33,17 @@ return static_cast<ScriptCompany::CompanyID>((int)::Sign::Get(sign_id)->owner); } -/* static */ bool ScriptSign::SetName(SignID sign_id, const char *name) +/* static */ bool ScriptSign::SetName(SignID sign_id, Text *name) { + CCountedPtr<Text> counter(name); + EnforcePrecondition(false, IsValidSign(sign_id)); - EnforcePrecondition(false, !::StrEmpty(name)); - EnforcePreconditionCustomError(false, ::Utf8StringLength(name) < MAX_LENGTH_SIGN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); + EnforcePrecondition(false, name != NULL); + const char *text = name->GetEncodedText(); + EnforcePrecondition(false, !::StrEmpty(text)); + EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_SIGN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::DoCommand(0, sign_id, 0, CMD_RENAME_SIGN, name); + return ScriptObject::DoCommand(0, sign_id, 0, CMD_RENAME_SIGN, text); } /* static */ char *ScriptSign::GetName(SignID sign_id) @@ -69,9 +73,13 @@ return ScriptObject::DoCommand(0, sign_id, 0, CMD_RENAME_SIGN, ""); } -/* static */ SignID ScriptSign::BuildSign(TileIndex location, const char *text) +/* static */ SignID ScriptSign::BuildSign(TileIndex location, Text *name) { + CCountedPtr<Text> counter(name); + EnforcePrecondition(INVALID_SIGN, ::IsValidTile(location)); + EnforcePrecondition(INVALID_SIGN, name != NULL); + const char *text = name->GetEncodedText(); EnforcePrecondition(INVALID_SIGN, !::StrEmpty(text)); EnforcePreconditionCustomError(INVALID_SIGN, ::Utf8StringLength(text) < MAX_LENGTH_SIGN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); diff --git a/src/script/api/script_sign.hpp b/src/script/api/script_sign.hpp index 9aacc409c..e5c2164da 100644 --- a/src/script/api/script_sign.hpp +++ b/src/script/api/script_sign.hpp @@ -43,14 +43,13 @@ public: /** * Set the name of a sign. * @param sign_id The sign to set the name for. - * @param name The name for the sign. + * @param name The name for the sign (can be either a raw string, or a ScriptText object). * @pre IsValidSign(sign_id). - * @pre 'name' must have at least one character. - * @pre 'name' must have at most 30 characters. + * @pre name != NULL && len(name) != 0. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if and only if the name was changed. */ - static bool SetName(SignID sign_id, const char *name); + static bool SetName(SignID sign_id, Text *name); /** * Get the name of the sign. @@ -80,16 +79,15 @@ public: /** * Builds a sign on the map. * @param location The place to build the sign. - * @param text The text to place on the sign. + * @param name The text to place on the sign (can be either a raw string, or a ScriptText object). * @pre ScriptMap::IsValidTile(location). - * @pre 'text' must have at least one character. - * @pre 'text' must have at most 30 characters. + * @pre name != NULL && len(name) != 0. * @exception ScriptSign::ERR_SIGN_TOO_MANY_SIGNS * @return The SignID of the build sign (use IsValidSign() to check for validity). * In test-mode it returns 0 if successful, or any other value to indicate * failure. */ - static SignID BuildSign(TileIndex location, const char *text); + static SignID BuildSign(TileIndex location, Text *name); /** * Removes a sign from the map. diff --git a/src/script/api/script_text.hpp b/src/script/api/script_text.hpp index 9f994e1f3..27bcca485 100644 --- a/src/script/api/script_text.hpp +++ b/src/script/api/script_text.hpp @@ -62,7 +62,7 @@ private: * local text = ScriptText(ScriptText.STR_NEWS); text.AddParam(1); * This will set the {COMPANY} to the name of Company 1. * - * @api game + * @api ai game */ class ScriptText : public Text , public ZeroedMemoryAllocator { public: diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index e1c0c0a85..c04115c8f 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -43,10 +43,14 @@ return town_name; } -/* static */ bool ScriptTown::SetText(TownID town_id, const char *text) +/* static */ bool ScriptTown::SetText(TownID town_id, Text *text) { + CCountedPtr<Text> counter(text); + + EnforcePrecondition(false, text != NULL); EnforcePrecondition(false, IsValidTown(town_id)); - return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, text); + + return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, text->GetEncodedText()); } /* static */ int32 ScriptTown::GetPopulation(TownID town_id) diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp index 1138d3336..749bf807e 100644 --- a/src/script/api/script_town.hpp +++ b/src/script/api/script_town.hpp @@ -14,6 +14,7 @@ #include "script_cargo.hpp" #include "script_company.hpp" +#include "script_text.hpp" #include "../../town_type.h" /** @@ -129,12 +130,12 @@ public: /** * Set the custom text of a town, shown in the GUI. * @param town_id The town to set the custom text of. - * @param text The text to set it to. + * @param text The text to set it to (can be either a raw string, or a ScriptText object). * @pre IsValidTown(town_id). * @return True if the action succeeded. * @api -ai */ - static bool SetText(TownID town_id, const char *text); + static bool SetText(TownID town_id, Text *text); /** * Gets the number of inhabitants in the town. diff --git a/src/script/api/script_vehicle.cpp b/src/script/api/script_vehicle.cpp index 9a73e564e..13ccce518 100644 --- a/src/script/api/script_vehicle.cpp +++ b/src/script/api/script_vehicle.cpp @@ -212,14 +212,18 @@ } } -/* static */ bool ScriptVehicle::SetName(VehicleID vehicle_id, const char *name) +/* static */ bool ScriptVehicle::SetName(VehicleID vehicle_id, Text *name) { + CCountedPtr<Text> counter(name); + EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY); EnforcePrecondition(false, IsValidVehicle(vehicle_id)); - EnforcePrecondition(false, !::StrEmpty(name)); - EnforcePreconditionCustomError(false, ::Utf8StringLength(name) < MAX_LENGTH_VEHICLE_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); + EnforcePrecondition(false, name != NULL); + const char *text = name->GetEncodedText(); + EnforcePrecondition(false, !::StrEmpty(text)); + EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_VEHICLE_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::DoCommand(0, vehicle_id, 0, CMD_RENAME_VEHICLE, name); + return ScriptObject::DoCommand(0, vehicle_id, 0, CMD_RENAME_VEHICLE, text); } /* static */ TileIndex ScriptVehicle::GetLocation(VehicleID vehicle_id) diff --git a/src/script/api/script_vehicle.hpp b/src/script/api/script_vehicle.hpp index 9a6723cb9..da36a542c 100644 --- a/src/script/api/script_vehicle.hpp +++ b/src/script/api/script_vehicle.hpp @@ -113,15 +113,14 @@ public: /** * Set the name of a vehicle. * @param vehicle_id The vehicle to set the name for. - * @param name The name for the vehicle. + * @param name The name for the vehicle (can be either a raw string, or a ScriptText object). * @pre IsValidVehicle(vehicle_id). - * @pre 'name' must have at least one character. - * @pre 'name' must have at most 30 characters. + * @pre name != NULL && len(name) != 0. * @game @pre Valid ScriptCompanyMode active in scope. * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE * @return True if and only if the name was changed. */ - static bool SetName(VehicleID vehicle_id, const char *name); + static bool SetName(VehicleID vehicle_id, Text *name); /** * Get the name of a vehicle. diff --git a/src/strings.cpp b/src/strings.cpp index 9e16bb17f..0f6c2bc4a 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1205,7 +1205,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg if (c == NULL) break; if (c->name != NULL) { - buff = strecpy(buff, c->name, last); + int64 args_array[] = {(uint64)(size_t)c->name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { int64 args_array[] = {c->name_2}; StringParameters tmp_params(args_array); @@ -1237,7 +1239,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg const Depot *d = Depot::Get(args->GetInt32()); if (d->name != NULL) { - buff = strecpy(buff, d->name, last); + int64 args_array[] = {(uint64)(size_t)d->name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { int64 args_array[] = {d->town->index, d->town_cn + 1}; StringParameters tmp_params(args_array); @@ -1251,7 +1255,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg if (e == NULL) break; if (e->name != NULL && e->IsEnabled()) { - buff = strecpy(buff, e->name, last); + int64 args_array[] = {(uint64)(size_t)e->name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { StringParameters tmp_params(NULL, 0, NULL); buff = GetStringWithArgs(buff, e->info.string_id, &tmp_params, last); @@ -1264,7 +1270,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg if (g == NULL) break; if (g->name != NULL) { - buff = strecpy(buff, g->name, last); + int64 args_array[] = {(uint64)(size_t)g->name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { int64 args_array[] = {g->index}; StringParameters tmp_params(args_array); @@ -1292,7 +1300,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg if (c == NULL) break; if (c->president_name != NULL) { - buff = strecpy(buff, c->president_name, last); + int64 args_array[] = {(uint64)(size_t)c->president_name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { int64 args_array[] = {c->president_name_2}; StringParameters tmp_params(args_array); @@ -1315,7 +1325,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg } if (st->name != NULL) { - buff = strecpy(buff, st->name, last); + int64 args_array[] = {(uint64)(size_t)st->name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { StringID str = st->string_id; if (st->indtype != IT_INVALID) { @@ -1342,7 +1354,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg if (t == NULL) break; if (t->name != NULL) { - buff = strecpy(buff, t->name, last); + int64 args_array[] = {(uint64)(size_t)t->name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { buff = GetTownName(buff, t, last); } @@ -1354,7 +1368,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg if (wp == NULL) break; if (wp->name != NULL) { - buff = strecpy(buff, wp->name, last); + int64 args_array[] = {(uint64)(size_t)wp->name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { int64 args_array[] = {wp->town->index, wp->town_cn + 1}; StringParameters tmp_params(args_array); @@ -1370,7 +1386,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg if (v == NULL) break; if (v->name != NULL) { - buff = strecpy(buff, v->name, last); + int64 args_array[] = {(uint64)(size_t)v->name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { int64 args_array[] = {v->unitnumber}; StringParameters tmp_params(args_array); @@ -1394,7 +1412,9 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg if (si == NULL) break; if (si->name != NULL) { - buff = strecpy(buff, si->name, last); + int64 args_array[] = {(uint64)(size_t)si->name}; + StringParameters tmp_params(args_array); + buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last); } else { StringParameters tmp_params(NULL, 0, NULL); buff = GetStringWithArgs(buff, STR_DEFAULT_SIGN_NAME, &tmp_params, last); diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 038b3cf05..0838e94a0 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -405,7 +405,8 @@ public: } if (this->town->text != NULL) { - DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, UINT16_MAX, this->town->text, TC_BLACK); + SetDParamStr(0, this->town->text); + DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK); } } |