diff --git a/amxmodx/amxmodx.h b/amxmodx/amxmodx.h index bf55dc7d..b42b7002 100755 --- a/amxmodx/amxmodx.h +++ b/amxmodx/amxmodx.h @@ -302,6 +302,8 @@ int load_amxscript(AMX* amx, void** program, const char* path, char error[64], i int set_amxnatives(AMX* amx, char error[64]); int set_amxstring(AMX *amx, cell amx_addr, const char *source, int max); template int set_amxstring_utf8(AMX *amx, cell amx_addr, const T *source, size_t sourcelen, size_t maxlen); +int set_amxstring_utf8_char(AMX *amx, cell amx_addr, const char *source, size_t sourcelen, size_t maxlen); +int set_amxstring_utf8_cell(AMX *amx, cell amx_addr, const cell *source, size_t sourcelen, size_t maxlen); int unload_amxscript(AMX* amx, void** program); void copy_amxmemory(cell* dest, cell* src, int len); diff --git a/amxmodx/modules.cpp b/amxmodx/modules.cpp index 627fafe8..3ded1532 100755 --- a/amxmodx/modules.cpp +++ b/amxmodx/modules.cpp @@ -1867,6 +1867,8 @@ void Module_CacheFunctions() // String / mem in amx scripts support REGISTER_FUNC("SetAmxString", set_amxstring) + REGISTER_FUNC("SetAmxStringUTF8Char", set_amxstring_utf8_char) + REGISTER_FUNC("SetAmxStringUTF8Cell", set_amxstring_utf8_cell) REGISTER_FUNC("GetAmxString", MNF_GetAmxString) REGISTER_FUNC("GetAmxStringLen", MNF_GetAmxStringLen) REGISTER_FUNC("FormatAmxString", MNF_FormatAmxString) diff --git a/amxmodx/sdk/amxxmodule.cpp b/amxmodx/sdk/amxxmodule.cpp index faf8f75c..efb933b3 100755 --- a/amxmodx/sdk/amxxmodule.cpp +++ b/amxmodx/sdk/amxxmodule.cpp @@ -2448,6 +2448,8 @@ PFN_GET_AMXSCRIPT g_fn_GetAmxScript; PFN_FIND_AMXSCRIPT_BYAMX g_fn_FindAmxScriptByAmx; PFN_FIND_AMXSCRIPT_BYNAME g_fn_FindAmxScriptByName; PFN_SET_AMXSTRING g_fn_SetAmxString; +PFN_SET_AMXSTRING_UTF8_CHAR g_fn_SetAmxStringUTF8Char; +PFN_SET_AMXSTRING_UTF8_CELL g_fn_SetAmxStringUTF8Cell; PFN_GET_AMXSTRING g_fn_GetAmxString; PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen; PFN_FORMAT_AMXSTRING g_fn_FormatAmxString; @@ -2587,6 +2589,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc) // String / mem in amx scripts support REQFUNC("SetAmxString", g_fn_SetAmxString, PFN_SET_AMXSTRING); + REQFUNC("SetAmxStringUTF8Char", g_fn_SetAmxStringUTF8Char, PFN_SET_AMXSTRING_UTF8_CHAR); + REQFUNC("SetAmxStringUTF8Cell", g_fn_SetAmxStringUTF8Cell, PFN_SET_AMXSTRING_UTF8_CELL); REQFUNC("GetAmxString", g_fn_GetAmxString, PFN_GET_AMXSTRING); REQFUNC("GetAmxStringLen", g_fn_GetAmxStringLen, PFN_GET_AMXSTRINGLEN); REQFUNC("FormatAmxString", g_fn_FormatAmxString, PFN_FORMAT_AMXSTRING); @@ -2739,6 +2743,8 @@ void ValidateMacros_DontCallThis_Smiley() MF_FindScriptByAmx(NULL); MF_FindScriptByName("str"); MF_SetAmxString(NULL, 0, "str", 0); + MF_SetAmxStringUTF8Char(NULL, 0, "str", 0, 0); + MF_SetAmxStringUTF8Cell(NULL, 0, "str", 0, 0); MF_GetAmxString(NULL, 0, 0, 0); MF_GetAmxStringLen(NULL); MF_CopyAmxMemory(NULL, NULL, 0); diff --git a/amxmodx/sdk/amxxmodule.h b/amxmodx/sdk/amxxmodule.h index bdf464cd..2a061fc2 100755 --- a/amxmodx/sdk/amxxmodule.h +++ b/amxmodx/sdk/amxxmodule.h @@ -2128,6 +2128,8 @@ typedef AMX * (*PFN_GET_AMXSCRIPT) (int /*id*/); typedef int (*PFN_FIND_AMXSCRIPT_BYAMX) (const AMX * /*amx*/); typedef int (*PFN_FIND_AMXSCRIPT_BYNAME) (const char * /*name*/); typedef int (*PFN_SET_AMXSTRING) (AMX * /*amx*/, cell /*amx_addr*/, const char * /* source */, int /* max */); +typedef int (*PFN_SET_AMXSTRING_UTF8_CHAR) (AMX *amx, cell amx_addr, const char *source, size_t sourcelen, size_t maxlen); +typedef int (*PFN_SET_AMXSTRING_UTF8_CELL) (AMX *amx, cell amx_addr, const cell *source, size_t sourcelen, size_t maxlen) { } typedef char * (*PFN_GET_AMXSTRING) (AMX * /*amx*/, cell /*amx_addr*/, int /*bufferId*/, int * /*pLen*/); typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr); typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/); @@ -2217,6 +2219,8 @@ extern PFN_GET_AMXSCRIPT g_fn_GetAmxScript; extern PFN_FIND_AMXSCRIPT_BYAMX g_fn_FindAmxScriptByAmx; extern PFN_FIND_AMXSCRIPT_BYNAME g_fn_FindAmxScriptByName; extern PFN_SET_AMXSTRING g_fn_SetAmxString; +extern PFN_SET_AMXSTRING_UTF8_CHAR g_fn_SetAmxStringUTF8Char; +extern PFN_SET_AMXSTRING_UTF8_CELL g_fn_SetAmxStringUTF8Cell; extern PFN_GET_AMXSTRING g_fn_GetAmxString; extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen; extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString; @@ -2280,7 +2284,7 @@ extern PFN_GETLOCALINFO g_fn_GetLocalInfo; extern PFN_AMX_REREGISTER g_fn_AmxReRegister; extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx; extern PFN_MESSAGE_BLOCK g_fn_MessageBlock; - +template int set_amxstring_utf8(AMX *amx, cell amx_addr, const T *source, size_t sourcelen, size_t maxlen); #ifdef MAY_NEVER_BE_DEFINED // Function prototypes for intellisense and similar systems // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED @@ -2296,6 +2300,8 @@ AMX * MF_GetScriptAmx (int id) { } int MF_FindScriptByAmx (const AMX * amx) { } int MF_FindScriptByAmx (const char * name) { } int MF_SetAmxString (AMX * amx, cell amx_addr, const char * source , int max ) { } +int MF_SetAmxStringUTF8Char (AMX *amx, cell amx_addr, const char *source, size_t sourcelen, size_t maxlen) { } +int MF_SetAmxStringUTF8Cell (AMX *amx, cell amx_addr, const cell *source, size_t sourcelen, size_t maxlen) { } char * MF_GetAmxString (AMX * amx, cell amx_addr, int bufferId, int * pLen) { } int MF_GetAmxStringLen (const cell *ptr) { } char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { } @@ -2368,6 +2374,8 @@ void * MF_MessageBlock (int mode, int msg, int *opt) { } #define MF_FindScriptByAmx g_fn_FindAmxScriptByAmx #define MF_FindScriptByName g_fn_FindAmxScriptByName #define MF_SetAmxString g_fn_SetAmxString +#define MF_SetAmxStringUTF8Char g_fn_SetAmxStringUTF8Char +#define MF_SetAmxStringUTF8Cell g_fn_SetAmxStringUTF8Cell #define MF_GetAmxString g_fn_GetAmxString #define MF_GetAmxStringLen g_fn_GetAmxStringLen #define MF_CopyAmxMemory g_fn_CopyAmxMemory diff --git a/amxmodx/string.cpp b/amxmodx/string.cpp index 3912a821..0a8a4622 100755 --- a/amxmodx/string.cpp +++ b/amxmodx/string.cpp @@ -144,6 +144,16 @@ int set_amxstring_utf8(AMX *amx, cell amx_addr, const T *source, size_t sourcele return len; } +int set_amxstring_utf8_char(AMX *amx, cell amx_addr, const char *source, size_t sourcelen, size_t maxlen) +{ + return set_amxstring_utf8(amx, amx_addr, source, sourcelen, maxlen); +} + +int set_amxstring_utf8_cell(AMX *amx, cell amx_addr, const cell *source, size_t sourcelen, size_t maxlen) +{ + return set_amxstring_utf8(amx, amx_addr, source, sourcelen, maxlen); +} + extern "C" size_t get_amxstring_r(AMX *amx, cell amx_addr, char *destination, int maxlen) { register cell *source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));