Codechange: use std::string_view for scripts
This commit is contained in:
@@ -27,7 +27,7 @@ ScriptError::ScriptErrorMapString ScriptError::error_map_string = ScriptError::S
|
||||
{
|
||||
auto it = ScriptError::error_map_string.find(ScriptError::GetLastError());
|
||||
assert(it != ScriptError::error_map_string.end());
|
||||
return it->second;
|
||||
return std::string{it->second};
|
||||
}
|
||||
|
||||
/* static */ ScriptErrorType ScriptError::StringToError(StringID internal_string_id)
|
||||
@@ -62,7 +62,7 @@ ScriptError::ScriptErrorMapString ScriptError::error_map_string = ScriptError::S
|
||||
error_map[internal_string_id] = ai_error_msg;
|
||||
}
|
||||
|
||||
/* static */ void ScriptError::RegisterErrorMapString(ScriptErrorType ai_error_msg, const char *message)
|
||||
/* static */ void ScriptError::RegisterErrorMapString(ScriptErrorType ai_error_msg, std::string_view message)
|
||||
{
|
||||
error_map_string[ai_error_msg] = message;
|
||||
}
|
||||
|
||||
@@ -218,11 +218,11 @@ public:
|
||||
* @param ai_error_msg The script error message representation.
|
||||
* @param message The string representation of this error message, used for debug purposes.
|
||||
*/
|
||||
static void RegisterErrorMapString(ScriptErrorType ai_error_msg, const char *message);
|
||||
static void RegisterErrorMapString(ScriptErrorType ai_error_msg, std::string_view message);
|
||||
|
||||
private:
|
||||
typedef std::map<StringID, ScriptErrorType> ScriptErrorMap; ///< The type for mapping between error (internal OpenTTD) StringID to the script error type.
|
||||
typedef std::map<ScriptErrorType, const char *> ScriptErrorMapString; ///< The type for mapping between error type and textual representation.
|
||||
using ScriptErrorMap = std::map<StringID, ScriptErrorType>; ///< The type for mapping between error (internal OpenTTD) StringID to the script error type.
|
||||
using ScriptErrorMapString = std::map<ScriptErrorType, std::string_view>; ///< The type for mapping between error type and textual representation.
|
||||
|
||||
static ScriptErrorMap error_map; ///< The mapping between error (internal OpenTTD) StringID to the script error type.
|
||||
static ScriptErrorMapString error_map_string; ///< The mapping between error type and textual representation.
|
||||
|
||||
Reference in New Issue
Block a user