diff --git a/rehlds/engine/unicode_strtools.cpp b/rehlds/engine/unicode_strtools.cpp index 2e323fc..91caa47 100644 --- a/rehlds/engine/unicode_strtools.cpp +++ b/rehlds/engine/unicode_strtools.cpp @@ -543,8 +543,6 @@ char *Q_UnicodeAdvance(char *pUTF8, int nChars) return pUTF8; } - - /* ../engine/unicode_strtools.cpp:717 */ qboolean V_UTF8ToUChar32(const char *pUTF8_, uchar32 *uValueOut) { @@ -724,12 +722,11 @@ int Q_UTF8ToUTF16(const char *pUTF8, uchar16 *pUTF16, int cubDestSizeInBytes, en return Q_UnicodeConvertT(pUTF8, pUTF16, cubDestSizeInBytes, ePolicy); } -int Q_UTF16ToUTF8(const uchar16 *pUTF16, char *pUTF8, int cubDestSizeInBytes, enum EStringConvertErrorPolicy ePolicy) /* linkage=_Z13Q_UTF16ToUTF8PKtPci25EStringConvertErrorPolicy */ +int Q_UTF16ToUTF8(const uchar16 *pUTF16, char *pUTF8, int cubDestSizeInBytes, enum EStringConvertErrorPolicy ePolicy) { return Q_UnicodeConvertT(pUTF16, pUTF8, cubDestSizeInBytes, ePolicy); } - /* ../engine/unicode_strtools.cpp:724 */ int Q_UnicodeRepair(char *pUTF8) { diff --git a/rehlds/engine/unicode_strtools.h b/rehlds/engine/unicode_strtools.h index c1dff16..cc51577 100644 --- a/rehlds/engine/unicode_strtools.h +++ b/rehlds/engine/unicode_strtools.h @@ -53,7 +53,7 @@ enum EStringConvertErrorPolicy { STRINGCONVERT_ASSERT_REPLACE = 4, STRINGCONVERT_ASSERT_SKIP = 5, STRINGCONVERT_ASSERT_FAIL = 6, -}; /* size: 4 */ +}; qboolean Q_IsValidUChar32(uchar32 uVal); int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 79e75d0..548e915 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -281,6 +281,7 @@ struct RehldsFuncs_t { void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch); bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin); void(*SV_UpdateUserInfo)(IGameClient *pGameClient); + bool(*StripUnprintableAndSpace)(char *pch); }; class IRehldsApi { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 312484f..9d5676a 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -36,11 +36,9 @@ struct plugin_api_t std::vector g_PluginApis; plugin_api_t* FindPluginApiByName(const char *name) { - for (auto it = g_PluginApis.begin(), end = g_PluginApis.end(); it != end; ++it) { - auto api = *it; - - if (!strcmp(api->name, name)) { - return api; + for (auto pl : g_PluginApis) { + if (!strcmp(pl->name, name)) { + return pl; } } @@ -142,12 +140,18 @@ void* EXT_FUNC Rehlds_GetPluginApi(const char *name) { return api ? api->impl : NULL; } +bool EXT_FUNC StripUnprintableAndSpace_api(char *pch) { + return Q_StripUnprintableAndSpace(pch) != FALSE; +} + void EXT_FUNC Rehlds_RegisterPluginApi(const char *name, void *impl) { auto api = FindPluginApiByName(name); if (!api) { api = new plugin_api_t; - strncpy(api->name, name, sizeof api->name - 1); + Q_strncpy(api->name, name, sizeof api->name - 1); + api->name[sizeof api->name - 1] = '\0'; + g_PluginApis.push_back(api); } @@ -205,7 +209,8 @@ RehldsFuncs_t g_RehldsApiFuncs = &Steam_NotifyClientDisconnect_api, &SV_StartSound_api, &SV_EmitSound2_api, - &SV_UpdateUserInfo_api + &SV_UpdateUserInfo_api, + &StripUnprintableAndSpace_api }; bool EXT_FUNC SV_EmitSound2_internal(edict_t *entity, IGameClient *pReceiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin)