2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-29 15:08:07 +03:00

Added Q_StripUnprintableAndSpace for API

Mini-refactoring
This commit is contained in:
s1lentq 2016-11-05 01:05:39 +07:00
parent 1bf56b26dd
commit be450ea340
4 changed files with 15 additions and 12 deletions

View File

@ -543,8 +543,6 @@ char *Q_UnicodeAdvance(char *pUTF8, int nChars)
return pUTF8;
}
/* <f4a0d> ../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<char, uchar16, true, Q_UTF8ToUChar32, Q_UChar32ToUTF16Len, Q_UChar32ToUTF16>(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<uchar16, char, true, Q_UTF16ToUChar32, Q_UChar32ToUTF8Len, Q_UChar32ToUTF8>(pUTF16, pUTF8, cubDestSizeInBytes, ePolicy);
}
/* <f4a63> ../engine/unicode_strtools.cpp:724 */
int Q_UnicodeRepair(char *pUTF8)
{

View File

@ -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);

View File

@ -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 {

View File

@ -36,11 +36,9 @@ struct plugin_api_t
std::vector<plugin_api_t *> 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)