diff --git a/amxmodx/CLang.cpp b/amxmodx/CLang.cpp index 2a7263fb..0c0cba49 100755 --- a/amxmodx/CLang.cpp +++ b/amxmodx/CLang.cpp @@ -33,6 +33,7 @@ #include "amxmodx.h" #include "CLang.h" #include "format.h" +#include "amxmod_compat.h" #ifdef __linux__ #define _snprintf snprintf @@ -287,7 +288,23 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len) static char outbuf[4096]; cell *addr = get_amxaddr(amx, params[parm++]); - len = atcprintf(outbuf, sizeof(outbuf)-1, addr, amx, params, &parm); + if (amx->flags & AMX_FLAG_OLDFILE) + { + if (*addr & BCOMPAT_TRANSLATE_BITS) + { + const char *key, *def; + if (!translate_bcompat(amx, addr, &key, &def)) + { + goto normal_string; + } + len = atcprintf(outbuf, sizeof(outbuf)-1, def, amx, params, &parm); + } else { + goto normal_string; + } + } else { +normal_string: + len = atcprintf(outbuf, sizeof(outbuf)-1, addr, amx, params, &parm); + } return outbuf; } diff --git a/amxmodx/format.cpp b/amxmodx/format.cpp index b2e788db..441ab2c8 100644 --- a/amxmodx/format.cpp +++ b/amxmodx/format.cpp @@ -1,5 +1,6 @@ #include "amxmodx.h" #include "format.h" +#include "amxmod_compat.h" //Adapted from Quake3's vsprintf // thanks to cybermind for linking me to this :) @@ -422,6 +423,24 @@ reswitch: break; case 's': CHECK_ARGS(0); + if (amx->flags & AMX_FLAG_OLDFILE) + { + cell *addr = get_amxaddr(amx, params[arg]); + if (*addr & BCOMPAT_TRANSLATE_BITS) + { + const char *key, *def; + if (!translate_bcompat(amx, addr, &key, &def)) + { + goto break_to_normal_string; + } + arg++; + size_t written = atcprintf(buf_p, llen, def, amx, params, &arg); + buf_p += written; + llen -= written; + break; + } + } +break_to_normal_string: AddString(&buf_p, llen, get_amxaddr(amx, params[arg]), width, prec); arg++; break; diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index eb554a3d..9f859503 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -628,6 +628,7 @@ void C_ServerDeactivate_Post() g_xvars.clear(); g_plugins.clear(); ClearPluginLibraries(); + ClearTransCache(); modules_callPluginsUnloaded(); ClearMessages(); diff --git a/amxmodx/modules.cpp b/amxmodx/modules.cpp index 54d5c3e0..a0b638ac 100755 --- a/amxmodx/modules.cpp +++ b/amxmodx/modules.cpp @@ -578,6 +578,11 @@ int set_amxnatives(AMX* amx, char error[128]) amx_Register(amx, msg_Natives, -1); amx_Register(amx, vector_Natives, -1); amx_Register(amx, g_SortNatives, -1); + + if (amx->flags & AMX_FLAG_OLDFILE) + { + amx_Register(amx, g_BcompatNatives, -1); + } //we're not actually gonna check these here anymore amx->flags |= AMX_FLAG_PRENIT; diff --git a/amxmodx/sdk/amxxmodule.cpp b/amxmodx/sdk/amxxmodule.cpp index b83c9903..ab2cbdb6 100755 --- a/amxmodx/sdk/amxxmodule.cpp +++ b/amxmodx/sdk/amxxmodule.cpp @@ -2437,6 +2437,7 @@ static amxx_module_info_s g_ModuleInfo = // Storage for the requested functions PFN_ADD_NATIVES g_fn_AddNatives; +PFN_ADD_NEW_NATIVES g_fn_AddNewNatives; PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR; PFN_GET_AMXADDR g_fn_GetAmxAddr; @@ -2515,6 +2516,7 @@ PFN_OVERRIDENATIVES g_fn_OverrideNatives; PFN_GETLOCALINFO g_fn_GetLocalInfo; PFN_AMX_REREGISTER g_fn_AmxReRegister; PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx; +PFN_MESSAGE_BLOCK g_fn_MessageBlock; // *** Exports *** C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) @@ -2591,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc) // Natives / Forwards REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES); + REQFUNC("AddNewNatives", g_fn_AddNewNatives, PFN_ADD_NEW_NATIVES); REQFUNC("RaiseAmxError", g_fn_RaiseAmxError, PFN_RAISE_AMXERROR); REQFUNC("RegisterForward", g_fn_RegisterForward, PFN_REGISTER_FORWARD); REQFUNC("RegisterSPForward", g_fn_RegisterSPForward, PFN_REGISTER_SPFORWARD); @@ -2638,6 +2641,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc) REQFUNC("GetLocalInfo", g_fn_GetLocalInfo, PFN_GETLOCALINFO); REQFUNC("AmxReregister", g_fn_AmxReRegister, PFN_AMX_REREGISTER); + REQFUNC("MessageBlock", g_fn_MessageBlock, PFN_MESSAGE_BLOCK); + #ifdef MEMORY_TEST // Memory REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR); @@ -2780,6 +2785,7 @@ void ValidateMacros_DontCallThis_Smiley() MF_AddLibraries(NULL, LibType_Class, NULL); MF_RemoveLibraries(NULL); MF_OverrideNatives(NULL, NULL); + MF_MessageBlock(0, 0, NULL); } #endif diff --git a/amxmodx/sdk/amxxmodule.h b/amxmodx/sdk/amxxmodule.h index 1136e594..964ad53b 100755 --- a/amxmodx/sdk/amxxmodule.h +++ b/amxmodx/sdk/amxxmodule.h @@ -2095,9 +2095,16 @@ enum LibType LibType_Class }; +#define MSGBLOCK_SET 0 +#define MSGBLOCK_GET 1 +#define BLOCK_NOT 0 +#define BLOCK_ONCE 1 +#define BLOCK_SET 2 + typedef void (*AUTHORIZEFUNC)(int player, const char *authstring); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); +typedef int (*PFN_ADD_NEW_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); @@ -2183,8 +2190,10 @@ typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/, const ch typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/); typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/); typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/); +typedef void (*PFN_MESSAGE_BLOCK) (int /* mode */, int /* message */, int * /* opt */); extern PFN_ADD_NATIVES g_fn_AddNatives; +extern PFN_ADD_NEW_NATIVES g_fn_AddNewNatives; extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR; extern PFN_GET_AMXADDR g_fn_GetAmxAddr; @@ -2257,11 +2266,13 @@ extern PFN_OVERRIDENATIVES g_fn_OverrideNatives; 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; #ifdef MAY_NEVER_BE_DEFINED // Function prototypes for intellisense and similar systems // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED int MF_AddNatives (const AMX_NATIVE_INFO *list) { } +int MF_AddNewNatives (const AMX_NATIVE_INFO *list) { } char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { } @@ -2328,9 +2339,11 @@ void MF_OverrideNatives (AMX_NATIVE_INFO *natives, const char *myname) { } const char * MF_GetLocalInfo (const char *name, const char *def) { } int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; } void * MF_RegisterFunctionEx (void *pfn, const char *description) { } +void * MF_MessageBlock (int mode, int msg, int *opt) { } #endif // MAY_NEVER_BE_DEFINED #define MF_AddNatives g_fn_AddNatives +#define MF_AddNewNatives g_fn_AddNewNatives #define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathnameR g_fn_BuildPathnameR #define MF_FormatAmxString g_fn_FormatAmxString @@ -2404,6 +2417,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...); #define MF_GetLocalInfo g_fn_GetLocalInfo #define MF_AmxReRegister g_fn_AmxReRegister #define MF_RegisterFunctionEx g_fn_RegisterFunctionEx +#define MF_MessageBlock g_fn_MessageBlock #ifdef MEMORY_TEST /*** Memory ***/ diff --git a/amxmodx/string.cpp b/amxmodx/string.cpp index 267f6aee..5fbaad38 100755 --- a/amxmodx/string.cpp +++ b/amxmodx/string.cpp @@ -33,6 +33,7 @@ #include "amxmodx.h" #include "format.h" #include "binlog.h" +#include "amxmod_compat.h" const char* stristr(const char* str, const char* substr) { @@ -115,8 +116,21 @@ extern "C" size_t get_amxstring_r(AMX *amx, cell amx_addr, char *destination, in register char *dest = destination; char *start = dest; - while (maxlen-- && *source) - *dest++=(char)(*source++); + if ( (amx->flags & AMX_FLAG_OLDFILE) && + (*source & BCOMPAT_TRANSLATE_BITS) ) + { + const char *def, *key; + if (!translate_bcompat(amx, source, &key, &def)) + { + goto normal_string; + } + while (maxlen-- && *def) + *dest++=(*source++); + } else { +normal_string: + while (maxlen-- && *source) + *dest++=(char)(*source++); + } *dest = '\0'; @@ -139,9 +153,22 @@ char *get_amxstring(AMX *amx, cell amx_addr, int id, int& len) register char* dest = buffor[id]; char* start = dest; - while ((*dest++=(char)(*source++))); + if ( (amx->flags & AMX_FLAG_OLDFILE) && + (*source & BCOMPAT_TRANSLATE_BITS) ) + { + const char *def, *key; + if (!translate_bcompat(amx, source, &key, &def)) + { + goto normal_string; + } + while ( (*dest++ = (*def++)) ); + len = --dest - start; + } else { +normal_string: + while ((*dest++=(char)(*source++))); - len = --dest - start; + len = --dest - start; + } #if defined BINLOG_ENABLED if (g_binlog_level & 2) diff --git a/plugins/amxxpc32.dll b/plugins/amxxpc32.dll index eb9dbc9f..d83992e5 100755 Binary files a/plugins/amxxpc32.dll and b/plugins/amxxpc32.dll differ diff --git a/plugins/amxxpc64.dll b/plugins/amxxpc64.dll index 483a6675..5b6d28bd 100755 Binary files a/plugins/amxxpc64.dll and b/plugins/amxxpc64.dll differ