diff --git a/src/3rdparty/squirrel/include/squirrel.h b/src/3rdparty/squirrel/include/squirrel.h index 9dd4d7a75d..7dfdaed9ad 100644 --- a/src/3rdparty/squirrel/include/squirrel.h +++ b/src/3rdparty/squirrel/include/squirrel.h @@ -238,6 +238,7 @@ void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars); SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask); SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx); void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len); +static inline void sq_pushstring(HSQUIRRELVM v, const std::string &str, SQInteger len = -1) { sq_pushstring(v, str.c_str(), len == -1 ? str.size() : len); } void sq_pushfloat(HSQUIRRELVM v,SQFloat f); void sq_pushinteger(HSQUIRRELVM v,SQInteger n); void sq_pushbool(HSQUIRRELVM v,SQBool b); diff --git a/src/game/game_text.cpp b/src/game/game_text.cpp index dc78e6a927..9db7e52ad6 100644 --- a/src/game/game_text.cpp +++ b/src/game/game_text.cpp @@ -369,7 +369,7 @@ void RegisterGameTranslation(Squirrel *engine) int idx = 0; for (const auto &p : _current_data->string_names) { - sq_pushstring(vm, p.c_str(), -1); + sq_pushstring(vm, p, -1); sq_pushinteger(vm, idx); sq_rawset(vm, -3); idx++; diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index b7a4497aae..1383a4540b 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -618,7 +618,7 @@ bool ScriptInstance::IsPaused() } if (std::holds_alternative(value)) { - sq_pushstring(vm, std::get(value).c_str(), -1); + sq_pushstring(vm, std::get(value), -1); return true; }