summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-02-08 20:34:27 +0000
committerrubidium <rubidium@openttd.org>2013-02-08 20:34:27 +0000
commit4e61c1770dc584229afdca7a37ce82dbf121b9d4 (patch)
treea37ac382e65ac4a0db3440365b8a461387edd65e /src
parentbb225ae39e93dabda532ee449c18b49de98b00af (diff)
downloadopenttd-4e61c1770dc584229afdca7a37ce82dbf121b9d4.tar.xz
(svn r24982) -Fix [FS#5465]: [Script] Crash when passing too many parameters
Diffstat (limited to 'src')
-rw-r--r--src/script/api/ai/ai_error.hpp.sq104
-rw-r--r--src/script/api/game/game_error.hpp.sq104
-rw-r--r--src/script/api/script_basestation.cpp2
-rw-r--r--src/script/api/script_company.cpp4
-rw-r--r--src/script/api/script_error.hpp17
-rw-r--r--src/script/api/script_goal.cpp10
-rw-r--r--src/script/api/script_group.cpp2
-rw-r--r--src/script/api/script_news.cpp5
-rw-r--r--src/script/api/script_sign.cpp4
-rw-r--r--src/script/api/script_text.cpp11
-rw-r--r--src/script/api/script_text.hpp3
-rw-r--r--src/script/api/script_town.cpp4
-rw-r--r--src/script/api/script_vehicle.cpp2
13 files changed, 151 insertions, 121 deletions
diff --git a/src/script/api/ai/ai_error.hpp.sq b/src/script/api/ai/ai_error.hpp.sq
index c588f7b40..54636d3a1 100644
--- a/src/script/api/ai/ai_error.hpp.sq
+++ b/src/script/api/ai/ai_error.hpp.sq
@@ -21,39 +21,40 @@ void SQAIError_Register(Squirrel *engine)
SQAIError.PreRegister(engine);
SQAIError.AddConstructor<void (ScriptError::*)(), 1>(engine, "x");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_NONE, "ERR_CAT_NONE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_GENERAL, "ERR_CAT_GENERAL");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_VEHICLE, "ERR_CAT_VEHICLE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_STATION, "ERR_CAT_STATION");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_BRIDGE, "ERR_CAT_BRIDGE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_TUNNEL, "ERR_CAT_TUNNEL");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_TILE, "ERR_CAT_TILE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_SIGN, "ERR_CAT_SIGN");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_RAIL, "ERR_CAT_RAIL");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_ROAD, "ERR_CAT_ROAD");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_ORDER, "ERR_CAT_ORDER");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_MARINE, "ERR_CAT_MARINE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_WAYPOINT, "ERR_CAT_WAYPOINT");
- SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_BIT_SIZE, "ERR_CAT_BIT_SIZE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_NONE, "ERR_NONE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN");
- SQAIError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED");
- SQAIError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG");
- SQAIError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_INVALID_COMPANY, "ERR_PRECONDITION_INVALID_COMPANY");
- SQAIError.DefSQConst(engine, ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR");
- SQAIError.DefSQConst(engine, ScriptError::ERR_GENERAL_BASE, "ERR_GENERAL_BASE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH");
- SQAIError.DefSQConst(engine, ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES");
- SQAIError.DefSQConst(engine, ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT");
- SQAIError.DefSQConst(engine, ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR");
- SQAIError.DefSQConst(engine, ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY");
- SQAIError.DefSQConst(engine, ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED");
- SQAIError.DefSQConst(engine, ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG");
- SQAIError.DefSQConst(engine, ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY");
- SQAIError.DefSQConst(engine, ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE");
- SQAIError.DefSQConst(engine, ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_NONE, "ERR_CAT_NONE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_GENERAL, "ERR_CAT_GENERAL");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_VEHICLE, "ERR_CAT_VEHICLE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_STATION, "ERR_CAT_STATION");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_BRIDGE, "ERR_CAT_BRIDGE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_TUNNEL, "ERR_CAT_TUNNEL");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_TILE, "ERR_CAT_TILE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_SIGN, "ERR_CAT_SIGN");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_RAIL, "ERR_CAT_RAIL");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_ROAD, "ERR_CAT_ROAD");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_ORDER, "ERR_CAT_ORDER");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_MARINE, "ERR_CAT_MARINE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_WAYPOINT, "ERR_CAT_WAYPOINT");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_CAT_BIT_SIZE, "ERR_CAT_BIT_SIZE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_NONE, "ERR_NONE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, "ERR_PRECONDITION_TOO_MANY_PARAMETERS");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_INVALID_COMPANY, "ERR_PRECONDITION_INVALID_COMPANY");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_GENERAL_BASE, "ERR_GENERAL_BASE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE");
+ SQAIError.DefSQConst(engine, ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT");
ScriptError::RegisterErrorMap(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY, ScriptError::ERR_NOT_ENOUGH_CASH);
ScriptError::RegisterErrorMap(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS, ScriptError::ERR_LOCAL_AUTHORITY_REFUSES);
@@ -90,24 +91,25 @@ void SQAIError_Register(Squirrel *engine)
ScriptError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_EDGE_OF_MAP, ScriptError::ERR_TOO_CLOSE_TO_EDGE);
ScriptError::RegisterErrorMap(STR_ERROR_STATION_TOO_SPREAD_OUT, ScriptError::ERR_STATION_TOO_SPREAD_OUT);
- ScriptError::RegisterErrorMapString(ScriptError::ERR_NONE, "ERR_NONE");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_INVALID_COMPANY, "ERR_PRECONDITION_INVALID_COMPANY");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_NONE, "ERR_NONE");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, "ERR_PRECONDITION_TOO_MANY_PARAMETERS");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_INVALID_COMPANY, "ERR_PRECONDITION_INVALID_COMPANY");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT");
SQAIError.DefSQStaticMethod(engine, &ScriptError::GetErrorCategory, "GetErrorCategory", 1, ".");
SQAIError.DefSQStaticMethod(engine, &ScriptError::GetLastError, "GetLastError", 1, ".");
diff --git a/src/script/api/game/game_error.hpp.sq b/src/script/api/game/game_error.hpp.sq
index b47f5d4a9..7718f1434 100644
--- a/src/script/api/game/game_error.hpp.sq
+++ b/src/script/api/game/game_error.hpp.sq
@@ -21,39 +21,40 @@ void SQGSError_Register(Squirrel *engine)
SQGSError.PreRegister(engine);
SQGSError.AddConstructor<void (ScriptError::*)(), 1>(engine, "x");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_NONE, "ERR_CAT_NONE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_GENERAL, "ERR_CAT_GENERAL");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_VEHICLE, "ERR_CAT_VEHICLE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_STATION, "ERR_CAT_STATION");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_BRIDGE, "ERR_CAT_BRIDGE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_TUNNEL, "ERR_CAT_TUNNEL");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_TILE, "ERR_CAT_TILE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_SIGN, "ERR_CAT_SIGN");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_RAIL, "ERR_CAT_RAIL");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_ROAD, "ERR_CAT_ROAD");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_ORDER, "ERR_CAT_ORDER");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_MARINE, "ERR_CAT_MARINE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_WAYPOINT, "ERR_CAT_WAYPOINT");
- SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_BIT_SIZE, "ERR_CAT_BIT_SIZE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_NONE, "ERR_NONE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN");
- SQGSError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED");
- SQGSError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG");
- SQGSError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_INVALID_COMPANY, "ERR_PRECONDITION_INVALID_COMPANY");
- SQGSError.DefSQConst(engine, ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR");
- SQGSError.DefSQConst(engine, ScriptError::ERR_GENERAL_BASE, "ERR_GENERAL_BASE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH");
- SQGSError.DefSQConst(engine, ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES");
- SQGSError.DefSQConst(engine, ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT");
- SQGSError.DefSQConst(engine, ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR");
- SQGSError.DefSQConst(engine, ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY");
- SQGSError.DefSQConst(engine, ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED");
- SQGSError.DefSQConst(engine, ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG");
- SQGSError.DefSQConst(engine, ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY");
- SQGSError.DefSQConst(engine, ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE");
- SQGSError.DefSQConst(engine, ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_NONE, "ERR_CAT_NONE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_GENERAL, "ERR_CAT_GENERAL");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_VEHICLE, "ERR_CAT_VEHICLE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_STATION, "ERR_CAT_STATION");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_BRIDGE, "ERR_CAT_BRIDGE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_TUNNEL, "ERR_CAT_TUNNEL");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_TILE, "ERR_CAT_TILE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_SIGN, "ERR_CAT_SIGN");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_RAIL, "ERR_CAT_RAIL");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_ROAD, "ERR_CAT_ROAD");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_ORDER, "ERR_CAT_ORDER");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_MARINE, "ERR_CAT_MARINE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_WAYPOINT, "ERR_CAT_WAYPOINT");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_CAT_BIT_SIZE, "ERR_CAT_BIT_SIZE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_NONE, "ERR_NONE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, "ERR_PRECONDITION_TOO_MANY_PARAMETERS");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_PRECONDITION_INVALID_COMPANY, "ERR_PRECONDITION_INVALID_COMPANY");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_GENERAL_BASE, "ERR_GENERAL_BASE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE");
+ SQGSError.DefSQConst(engine, ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT");
ScriptError::RegisterErrorMap(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY, ScriptError::ERR_NOT_ENOUGH_CASH);
ScriptError::RegisterErrorMap(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS, ScriptError::ERR_LOCAL_AUTHORITY_REFUSES);
@@ -90,24 +91,25 @@ void SQGSError_Register(Squirrel *engine)
ScriptError::RegisterErrorMap(STR_ERROR_TOO_CLOSE_TO_EDGE_OF_MAP, ScriptError::ERR_TOO_CLOSE_TO_EDGE);
ScriptError::RegisterErrorMap(STR_ERROR_STATION_TOO_SPREAD_OUT, ScriptError::ERR_STATION_TOO_SPREAD_OUT);
- ScriptError::RegisterErrorMapString(ScriptError::ERR_NONE, "ERR_NONE");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_INVALID_COMPANY, "ERR_PRECONDITION_INVALID_COMPANY");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE");
- ScriptError::RegisterErrorMapString(ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_NONE, "ERR_NONE");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_UNKNOWN, "ERR_UNKNOWN");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_FAILED, "ERR_PRECONDITION_FAILED");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, "ERR_PRECONDITION_STRING_TOO_LONG");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, "ERR_PRECONDITION_TOO_MANY_PARAMETERS");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_PRECONDITION_INVALID_COMPANY, "ERR_PRECONDITION_INVALID_COMPANY");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_NEWGRF_SUPPLIED_ERROR, "ERR_NEWGRF_SUPPLIED_ERROR");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_NOT_ENOUGH_CASH, "ERR_NOT_ENOUGH_CASH");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_LOCAL_AUTHORITY_REFUSES, "ERR_LOCAL_AUTHORITY_REFUSES");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_ALREADY_BUILT, "ERR_ALREADY_BUILT");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_AREA_NOT_CLEAR, "ERR_AREA_NOT_CLEAR");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY, "ERR_OWNED_BY_ANOTHER_COMPANY");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_NAME_IS_NOT_UNIQUE, "ERR_NAME_IS_NOT_UNIQUE");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_FLAT_LAND_REQUIRED, "ERR_FLAT_LAND_REQUIRED");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_LAND_SLOPED_WRONG, "ERR_LAND_SLOPED_WRONG");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_VEHICLE_IN_THE_WAY, "ERR_VEHICLE_IN_THE_WAY");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_SITE_UNSUITABLE, "ERR_SITE_UNSUITABLE");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE");
+ ScriptError::RegisterErrorMapString(ScriptError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT");
SQGSError.DefSQStaticMethod(engine, &ScriptError::GetErrorCategory, "GetErrorCategory", 1, ".");
SQGSError.DefSQStaticMethod(engine, &ScriptError::GetLastError, "GetLastError", 1, ".");
diff --git a/src/script/api/script_basestation.cpp b/src/script/api/script_basestation.cpp
index d1bcf6f6d..981ec2c31 100644
--- a/src/script/api/script_basestation.cpp
+++ b/src/script/api/script_basestation.cpp
@@ -39,7 +39,7 @@
EnforcePrecondition(false, IsValidBaseStation(station_id));
EnforcePrecondition(false, name != NULL);
const char *text = name->GetEncodedText();
- EnforcePrecondition(false, !::StrEmpty(text));
+ EnforcePreconditionEncodedText(false, 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, text);
diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp
index 8e19904f9..8dea4c22e 100644
--- a/src/script/api/script_company.cpp
+++ b/src/script/api/script_company.cpp
@@ -44,7 +44,7 @@
EnforcePrecondition(false, name != NULL);
const char *text = name->GetEncodedText();
- EnforcePrecondition(false, !::StrEmpty(text));
+ EnforcePreconditionEncodedText(false, 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);
@@ -65,7 +65,7 @@
EnforcePrecondition(false, name != NULL);
const char *text = name->GetEncodedText();
- EnforcePrecondition(false, !::StrEmpty(text));
+ EnforcePreconditionEncodedText(false, text);
return ScriptObject::DoCommand(0, 0, 0, CMD_RENAME_PRESIDENT, text);
}
diff --git a/src/script/api/script_error.hpp b/src/script/api/script_error.hpp
index 33a69e544..1817cdb7d 100644
--- a/src/script/api/script_error.hpp
+++ b/src/script/api/script_error.hpp
@@ -39,6 +39,21 @@
}
/**
+ * Helper to write precondition enforcers for the script API in an abbreviated manner for encoded texts.
+ * @param returnval The value to return on failure.
+ * @param string The string that is checked.
+ */
+#define EnforcePreconditionEncodedText(returnval, string) \
+ if ((string) == NULL) { \
+ ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_TOO_MANY_PARAMETERS); \
+ return returnval; \
+ } \
+ if (StrEmpty(string)) { \
+ ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_FAILED); \
+ return returnval; \
+ }
+
+/**
* Class that handles all error related functions.
* @api ai game
*/
@@ -81,6 +96,8 @@ public:
ERR_PRECONDITION_FAILED, // []
/** A string supplied was too long */
ERR_PRECONDITION_STRING_TOO_LONG, // []
+ /** A string had too many parameters */
+ ERR_PRECONDITION_TOO_MANY_PARAMETERS, // []
/** The company you use is invalid */
ERR_PRECONDITION_INVALID_COMPANY, // []
/** An error returned by a NewGRF. No possibility to get the exact error in an script readable format */
diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp
index 8e9dcbff8..2b9afc5ee 100644
--- a/src/script/api/script_goal.cpp
+++ b/src/script/api/script_goal.cpp
@@ -30,14 +30,15 @@
EnforcePrecondition(GOAL_INVALID, ScriptObject::GetCompany() == OWNER_DEITY);
EnforcePrecondition(GOAL_INVALID, goal != NULL);
- EnforcePrecondition(GOAL_INVALID, !StrEmpty(goal->GetEncodedText()));
+ const char *text = goal->GetEncodedText();
+ EnforcePreconditionEncodedText(GOAL_INVALID, text);
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->GetEncodedText(), &ScriptInstance::DoCommandReturnGoalID)) return GOAL_INVALID;
+ if (!ScriptObject::DoCommand(0, type | (c << 8), destination, CMD_CREATE_GOAL, text, &ScriptInstance::DoCommandReturnGoalID)) return GOAL_INVALID;
/* In case of test-mode, we return GoalID 0 */
return (ScriptGoal::GoalID)0;
@@ -57,7 +58,8 @@
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
EnforcePrecondition(false, question != NULL);
- EnforcePrecondition(false, !StrEmpty(question->GetEncodedText()));
+ const char *text = question->GetEncodedText();
+ EnforcePreconditionEncodedText(false, text);
EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
EnforcePrecondition(false, CountBits(buttons) >= 1 && CountBits(buttons) <= 3);
EnforcePrecondition(false, buttons < (1 << ::GOAL_QUESTION_BUTTON_COUNT));
@@ -66,7 +68,7 @@
uint8 c = company;
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
- return ScriptObject::DoCommand(0, uniqueid | (c << 16) | (type << 24), buttons, CMD_GOAL_QUESTION, question->GetEncodedText());
+ return ScriptObject::DoCommand(0, uniqueid | (c << 16) | (type << 24), buttons, CMD_GOAL_QUESTION, text);
}
/* static */ bool ScriptGoal::CloseQuestion(uint16 uniqueid)
diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp
index b04ece2fa..bd2ea3010 100644
--- a/src/script/api/script_group.cpp
+++ b/src/script/api/script_group.cpp
@@ -54,7 +54,7 @@
EnforcePrecondition(false, IsValidGroup(group_id));
EnforcePrecondition(false, name != NULL);
const char *text = name->GetEncodedText();
- EnforcePrecondition(false, !::StrEmpty(text));
+ EnforcePreconditionEncodedText(false, 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, text);
diff --git a/src/script/api/script_news.cpp b/src/script/api/script_news.cpp
index aaa8a6895..e80b88491 100644
--- a/src/script/api/script_news.cpp
+++ b/src/script/api/script_news.cpp
@@ -20,12 +20,13 @@
CCountedPtr<Text> counter(text);
EnforcePrecondition(false, text != NULL);
- EnforcePrecondition(false, !StrEmpty(text->GetEncodedText()));
+ const char *encoded = text->GetEncodedText();
+ EnforcePreconditionEncodedText(false, encoded);
EnforcePrecondition(false, type == NT_ECONOMY || type == NT_SUBSIDIES || 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->GetEncodedText());
+ return ScriptObject::DoCommand(0, type | (NR_NONE << 8) | (c << 16), 0, CMD_CUSTOM_NEWS_ITEM, encoded);
}
diff --git a/src/script/api/script_sign.cpp b/src/script/api/script_sign.cpp
index ecf0b4c28..514dd4a21 100644
--- a/src/script/api/script_sign.cpp
+++ b/src/script/api/script_sign.cpp
@@ -38,7 +38,7 @@
EnforcePrecondition(false, IsValidSign(sign_id));
EnforcePrecondition(false, name != NULL);
const char *text = name->GetEncodedText();
- EnforcePrecondition(false, !::StrEmpty(text));
+ EnforcePreconditionEncodedText(false, 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, text);
@@ -73,7 +73,7 @@
EnforcePrecondition(INVALID_SIGN, ::IsValidTile(location));
EnforcePrecondition(INVALID_SIGN, name != NULL);
const char *text = name->GetEncodedText();
- EnforcePrecondition(INVALID_SIGN, !::StrEmpty(text));
+ EnforcePreconditionEncodedText(INVALID_SIGN, text);
EnforcePreconditionCustomError(INVALID_SIGN, ::Utf8StringLength(text) < MAX_LENGTH_SIGN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG);
if (!ScriptObject::DoCommand(location, 0, 0, CMD_PLACE_SIGN, text, &ScriptInstance::DoCommandReturnSignID)) return INVALID_SIGN;
diff --git a/src/script/api/script_text.cpp b/src/script/api/script_text.cpp
index e5a93168e..8507a176d 100644
--- a/src/script/api/script_text.cpp
+++ b/src/script/api/script_text.cpp
@@ -165,25 +165,28 @@ SQInteger ScriptText::_set(HSQUIRRELVM vm)
const char *ScriptText::GetEncodedText()
{
static char buf[1024];
- this->_GetEncodedText(buf, lastof(buf));
- return buf;
+ int param_count = 0;
+ this->_GetEncodedText(buf, lastof(buf), param_count);
+ return (param_count > SCRIPT_TEXT_MAX_PARAMETERS) ? NULL : buf;
}
-char *ScriptText::_GetEncodedText(char *p, char *lastofp)
+char *ScriptText::_GetEncodedText(char *p, char *lastofp, int &param_count)
{
p += Utf8Encode(p, SCC_ENCODED);
p += seprintf(p, lastofp, "%X", this->string);
for (int i = 0; i < this->paramc; i++) {
if (this->params[i] != NULL) {
p += seprintf(p, lastofp, ":\"%s\"", this->params[i]);
+ param_count++;
continue;
}
if (this->paramt[i] != NULL) {
p += seprintf(p, lastofp, ":");
- p = this->paramt[i]->_GetEncodedText(p, lastofp);
+ p = this->paramt[i]->_GetEncodedText(p, lastofp, param_count);
continue;
}
p += seprintf(p, lastofp,":%X", (uint32)this->parami[i]);
+ param_count++;
}
return p;
diff --git a/src/script/api/script_text.hpp b/src/script/api/script_text.hpp
index 43a6037ef..6dd022bb7 100644
--- a/src/script/api/script_text.hpp
+++ b/src/script/api/script_text.hpp
@@ -132,9 +132,10 @@ private:
* instances, while writing in the same buffer.
* @param p The current position in the buffer.
* @param lastofp The last position valid in the buffer.
+ * @param param_count The number of parameters that are in the string.
* @return The new current position in the buffer.
*/
- char *_GetEncodedText(char *p, char *lastofp);
+ char *_GetEncodedText(char *p, char *lastofp, int &param_count);
/**
* Set a parameter, where the value is the first item on the stack.
diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp
index 31b9ed0b1..fa4b9c0c7 100644
--- a/src/script/api/script_town.cpp
+++ b/src/script/api/script_town.cpp
@@ -43,9 +43,11 @@
CCountedPtr<Text> counter(text);
EnforcePrecondition(false, text != NULL);
+ const char *encoded_text = text->GetEncodedText();
+ EnforcePreconditionEncodedText(false, encoded_text);
EnforcePrecondition(false, IsValidTown(town_id));
- return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, text->GetEncodedText());
+ return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, encoded_text);
}
/* static */ int32 ScriptTown::GetPopulation(TownID town_id)
diff --git a/src/script/api/script_vehicle.cpp b/src/script/api/script_vehicle.cpp
index 639b42f4b..5bbcd543a 100644
--- a/src/script/api/script_vehicle.cpp
+++ b/src/script/api/script_vehicle.cpp
@@ -220,7 +220,7 @@
EnforcePrecondition(false, IsValidVehicle(vehicle_id));
EnforcePrecondition(false, name != NULL);
const char *text = name->GetEncodedText();
- EnforcePrecondition(false, !::StrEmpty(text));
+ EnforcePreconditionEncodedText(false, 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, text);