diff --git a/amxmodx/CMisc.h b/amxmodx/CMisc.h index a90a80a8..95e06983 100755 --- a/amxmodx/CMisc.h +++ b/amxmodx/CMisc.h @@ -58,6 +58,7 @@ public: inline const char* getPluginName() { return plugin.c_str(); } inline const char* getName() { return name.c_str(); } inline bool operator == (const char* string) { return (strcmp(name.c_str(), string) == 0); } + int plugin_id; }; // ***************************************************** diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index a545858e..567dc5e1 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -1112,6 +1112,16 @@ static cell AMX_NATIVE_CALL get_plugin(AMX *amx, cell *params) /* 11 param */ return a->getId(); } + + if (params[0] / sizeof(cell) >= 12) + { + cell *jit_info = get_amxaddr(amx, params[12]); +#if defined AMD64 || !defined JIT + *jit_info = 0; +#else + *jit_info = a->isDebug() ? 0 : 1; +#endif + } return -1; } @@ -1288,6 +1298,28 @@ static cell AMX_NATIVE_CALL get_concmd(AMX *amx, cell *params) /* 7 param */ return 1; } +static cell AMX_NATIVE_CALL get_concmd_plid(AMX *amx, cell *params) +{ + int who = params[3]; + if (who > 0) + { + who = CMD_ClientCommand; + } else if (who == 0) { + who = CMD_ServerCommand; + } else { + who = CMD_ConsoleCommand; + } + + CmdMngr::Command *cmd = g_commands.getCmd(params[1], who, params[2]); + + if (cmd == NULL) + { + return -1; + } + + return cmd->getPlugin()->getId(); +} + static cell AMX_NATIVE_CALL get_clcmd(AMX *amx, cell *params) /* 7 param */ { CmdMngr::Command* cmd = g_commands.getCmd(params[1], CMD_ClientCommand, params[7]); @@ -2189,8 +2221,7 @@ static cell AMX_NATIVE_CALL register_cvar(AMX *amx, cell *params) /* 3 param */ CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx); CCVar* cvar = new CCVar(temp, plugin->getName(), params[3], amx_ctof(params[4])); - if (cvar == 0) - return 0; + cvar->plugin_id = plugin->getId(); g_cvars.put(cvar); @@ -2582,6 +2613,43 @@ static cell AMX_NATIVE_CALL remove_quotes(AMX *amx, cell *params) /* 1 param */ return 0; } +//native get_plugins_cvar(id, name[], namelen, &flags=0, &plugin_id=0, &pcvar_handle=0); +static cell AMX_NATIVE_CALL get_plugins_cvar(AMX *amx, cell *params) +{ + int id = params[1]; + int iter_id = 0; + + for (CList::iterator iter=g_cvars.begin(); iter; ++iter) + { + if (id == iter_id) + { + CCVar *var = &(*iter); + set_amxstring(amx, params[2], var->getName(), params[3]); + cvar_t *ptr = CVAR_GET_POINTER(var->getName()); + if (!ptr) + { + return 0; + } + cell *addr = get_amxaddr(amx, params[4]); + *addr = ptr->flags; + addr = get_amxaddr(amx, params[5]); + *addr = var->plugin_id; + addr = get_amxaddr(amx, params[6]); + *addr = (cell)ptr; + return 1; + } + iter_id++; + } + + return 0; +} + +//native get_plugins_cvarsnum(); +static cell AMX_NATIVE_CALL get_plugins_cvarsnum(AMX *amx, cell *params) +{ + return g_cvars.size(); +} + static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param */ { int index = params[1]; @@ -4147,6 +4215,14 @@ static cell AMX_NATIVE_CALL AddTranslation(AMX *amx, cell *params) return 1; } +static cell AMX_NATIVE_CALL GetLangTransKey(AMX *amx, cell *params) +{ + int len; + const char *key = get_amxstring(amx, params[1], 0, len); + + return g_langMngr.GetKeyEntry(key); +} + AMX_NATIVE_INFO amxmodx_Natives[] = { {"abort", amx_abort}, @@ -4181,6 +4257,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] = {"get_clcmdsnum", get_clcmdsnum}, {"get_concmd", get_concmd}, {"get_concmdsnum", get_concmdsnum}, + {"get_concmd_plid", get_concmd_plid}, {"get_cvar_flags", get_cvar_flags}, {"get_cvar_float", get_cvar_float}, {"get_cvar_num", get_cvar_num}, @@ -4205,6 +4282,8 @@ AMX_NATIVE_INFO amxmodx_Natives[] = {"get_playersnum", get_playersnum}, {"get_plugin", get_plugin}, {"get_pluginsnum", get_pluginsnum}, + {"get_plugins_cvar", get_plugins_cvar}, + {"get_plugins_cvarsnum", get_plugins_cvarsnum}, {"get_srvcmd", get_srvcmd}, {"get_srvcmdsnum", get_srvcmdsnum}, {"get_systime", get_systime}, @@ -4334,6 +4413,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] = {"CreateOneForward", CreateOneForward}, {"DestroyForward", DestroyForward}, {"ExecuteForward", ExecuteForward}, + {"GetLangTransKey", GetLangTransKey}, {"LibraryExists", LibraryExists}, {"PrepareArray", PrepareArray}, {"ShowSyncHudMsg", ShowSyncHudMsg}, diff --git a/plugins/amxmod_compat/amxmod_compat.sma b/plugins/amxmod_compat/amxmod_compat.sma index 1f94a408..5eee7aeb 100644 --- a/plugins/amxmod_compat/amxmod_compat.sma +++ b/plugins/amxmod_compat/amxmod_compat.sma @@ -24,7 +24,7 @@ new g_MaxPlayers public plugin_init() { - register_plugin("AMX Mod Compat Engine", AMXX_VERSION_STR, "AMXX Dev Team") + register_plugin("AMX Mod Compat Engine", "1.76.rc4", "AMXX Dev Team") g_MaxPlayers = get_maxplayers() diff --git a/plugins/amxmod_compat/core.sma b/plugins/amxmod_compat/core.sma index 5ba8948d..0981167d 100644 --- a/plugins/amxmod_compat/core.sma +++ b/plugins/amxmod_compat/core.sma @@ -27,6 +27,11 @@ Core_Natives() register_native("fpower", "__fpower") register_native("flog", "__flog") register_native("get_cmdaccess", "__get_cmdaccess") + register_native("is_translated", "__is_translated") + register_native("get_plugincmdsnum", "__get_plugincmdsnum") + register_native("get_plugincmd", "__get_plugincmd") + register_native("get_plugincvarsnum", "__get_plugincvarsnum") + register_native("get_plugincvar", "__get_plugincvar") } public __VelocityByAim(plid, num) @@ -185,7 +190,7 @@ public Float:__flog(plid, num) //get_cmdaccess(cmd[], accessflags[], len) public __get_cmdaccess(plid, num) { - new command[32], accessflags[32] + static command[32], accessflags[32] new ret get_string(1, command, 31) @@ -197,3 +202,80 @@ public __get_cmdaccess(plid, num) return ret } + +public __is_translated(plid, num) +{ + static string[512] + + get_string(1, string, 511) + + return is_translated(string) +} + +public __get_plugincmdsnum(plid, num) +{ + static plugin[64] + + get_string(1, plugin, 63) + + return get_plugincmdsnum(plugin, get_param(2)) +} + +public __get_plugincmd(plid, num) +{ + static plugin[64] + static command[32] + static accessflags[32] + static info[512] + + get_string(1, plugin, 63) + + if (get_plugincmd(plugin, + get_param(2), + command, + 31, + accessflags, + 31, + info, + 511, + get_param(9), + get_param(10))) + { + set_string(3, command, get_param(4)) + set_string(5, accessflags, get_param(6)) + set_string(7, info, get_param(8)) + + return 1 + } + + return 0 +} + +public __get_plugincvarsnum(plid, num) +{ + static plugin[64] + + get_string(1, plugin, 63) + + return get_plugincvarsnum(plugin, get_param(2)) +} + +//stock get_plugincvar(plugin[], index, cvar[], len1, value[], len2, flags=0) +public __get_plugincvar(plid, num) +{ + static plugin[64] + static cvar[32] + static value[512] + + get_string(1, plugin, 63) + + if (get_plugincvar(plugin, get_param(2), cvar, 31, value, 511, get_param(7))) + { + set_string(3, cvar, get_param(4)) + set_string(5, value, get_param(6)) + + return 1 + } + + return 0 +} diff --git a/plugins/include/amxmod_compat/amxmod.inc b/plugins/include/amxmod_compat/amxmod.inc index fced07d5..a59562e8 100644 --- a/plugins/include/amxmod_compat/amxmod.inc +++ b/plugins/include/amxmod_compat/amxmod.inc @@ -54,7 +54,7 @@ stock strtonum(const string[]) stock build_path(path[], len, {Float,_}:... ) { - format_args(path, len, 2) + format_args(path, len, 2); new pathlen = strlen(path); new basedir[32]; if (containi(path, "$basedir") != -1) @@ -66,22 +66,22 @@ stock build_path(path[], len, {Float,_}:... ) } if ((pathlen+strlen(basedir)-strlen("$basedir")) < len) { - replace(path, len, "$basedir", basedir) + replace(path, len, "$basedir", basedir); } } new dir[64], subdir[63]; if (containi(path, "$configdir") != -1) { - get_localinfo("amxx_configsdir", dir, 63) + get_localinfo("amxx_configsdir", dir, 63); if (!dir[0]) { - format(dir, 63, "%s/configs", basedir) + format(dir, 63, "%s/configs", basedir); } if ((pathlen+strlen(basedir)-strlen("$configdir")) < len) { - replace(path, len, "$configdir", dir) + replace(path, len, "$configdir", dir); } - dir[0] = '^0' + dir[0] = '^0'; } if (containi(path, "$langdir") != -1) { @@ -95,7 +95,7 @@ stock build_path(path[], len, {Float,_}:... ) { replace(path, len, "$langdir", dir); } - dir[0] = '^0'' + dir[0] = '^0'; } if (containi(path, "$modulesdir") != -1) { @@ -128,14 +128,14 @@ stock build_path(path[], len, {Float,_}:... ) get_localinfo("amx_logs", dir, 63); if (!dir[0]) { - format(dir, 63, "%s/logs", basedir) + format(dir, 63, "%s/logs", basedir); } if ((pathlen+strlen(basedir)-strlen("$logdir")) < len) { replace(path, len, "$logdir", dir); } } - return 1 + return 1; } stock is_user_authorized(id) @@ -161,7 +161,7 @@ stock angle_to_vector(Float:vector[3], FRU, Float:ret[3]) return angle_vector(vector, FRU, ret); } -get_cmdaccess(cmd[], accessflags[], len) +stock get_cmdaccess(cmd[], accessflags[], len) { new num = get_concmdsnum(-1); new command[32], info[3]; @@ -179,3 +179,120 @@ get_cmdaccess(cmd[], accessflags[], len) return 0; } + +stock is_translated(const sentence[]) +{ + return (GetLangTransKey(sentence) != TransKey_Bad); +} + +stock get_plugincmdsnum(plugin[], type=7) +{ + new plid = find_plugin_byfile(plugin); + new our_type; + + /** + * Whoever wrote this was a bit confused about the type stuff... + */ + if (type == 1) { + our_type = 1; + } else if (type == 4) { + our_type = 0; + } else { + our_type = -1; + } + + new found = 0; + new total = get_concmdsnum(-1, our_type); + for (new i=0; i