From b09bf4c532e586fc67ef880393ef30c512fa80e1 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Fri, 3 Aug 2007 06:48:08 +0000 Subject: [PATCH] Work around for amb228 - amxmod_compat caused set_user_hitzones to stop functioning. Any plugins being emulated by amxmod_compat that still use the traceline forward will still cause the issue, but if no plugins use that forward it won't interfere. (also, plugin_flags() can now specify a plid) --- amxmodx/amxmodx.cpp | 33 ++++++++++++++++++++++++++------ plugins/amxmod_compat/vexdum.sma | 15 ++++++++++++++- plugins/include/amxconst.inc | 1 + plugins/include/amxmodx.inc | 14 ++++++++------ 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 30778c1a..726a0f0a 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -3793,14 +3793,35 @@ static cell AMX_NATIVE_CALL register_dictionary(AMX *amx, cell *params) static cell AMX_NATIVE_CALL plugin_flags(AMX *amx, cell *params) { - if (params[1]) + if ((params[0] / sizeof(cell)) == 1 || // compiled with old include file + params[2] < 0) // specifically want calling plugin's flags { - AMX_HEADER *hdr; - hdr = (AMX_HEADER *)amx->base; - return hdr->flags; - } + if (params[1]) + { + AMX_HEADER *hdr; + hdr = (AMX_HEADER *)amx->base; + return hdr->flags; + } - return amx->flags; + return amx->flags; + } + else + { + CPluginMngr::CPlugin* a = g_plugins.findPlugin((int)params[2]); + + if (a == NULL) + { + return 0; + } + if (params[1]) + { + AMX_HEADER *hdr; + hdr = (AMX_HEADER *)a->getAMX()->base; + return hdr->flags; + } + + return a->getAMX()->flags; + } } // lang_exists(const name[]); diff --git a/plugins/amxmod_compat/vexdum.sma b/plugins/amxmod_compat/vexdum.sma index 420c2737..037967ff 100644 --- a/plugins/amxmod_compat/vexdum.sma +++ b/plugins/amxmod_compat/vexdum.sma @@ -34,7 +34,6 @@ VexdUM_Register() register_forward(FM_EmitSound, "Hook_FM_EmitSound") register_forward(FM_EmitAmbientSound, "Hook_FM_EmitAmbientSound") register_forward(FM_SetModel, "Hook_FM_SetModel") - register_forward(FM_TraceLine, "Hook_FM_TraceLine") register_forward(FM_SetClientKeyValue, "Hook_FM_SetClientKeyValue") register_forward(FM_KeyValue, "Hook_FM_KeyValue") register_forward(FM_Touch, "Hook_FM_Touch") @@ -43,7 +42,21 @@ VexdUM_Register() register_forward(FM_PlayerPreThink, "Hook_FM_PlayerPreThink") register_forward(FM_PlayerPostThink, "Hook_FM_PlayerPostThink") register_forward(FM_ClientUserInfoChanged, "Hook_ClientUserInfoChanged") + + // Only register the traceline forward if there actually is a plugin + // that needs it. Otherwise this will mess with set_user_hitzones + new pluginnum = get_pluginsnum(); + for (new i = 0; i < pluginnum; i++) + { + if (plugin_flags(0, i) & AMX_FLAG_OLDFILE && // plugin is an AMX plugin being emulated + get_func_id("traceline", i) != -1) // plugin needs traceline + { + register_forward(FM_TraceLine, "Hook_FM_TraceLine") + break; + } + + } /* Global Forwards */ g_FwdTouch = CreateMultiForwardEx("entity_touch", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_CELL) g_FwdThink = CreateMultiForwardEx("entity_think", ET_STOP, FORWARD_ONLY_OLD, FP_CELL) diff --git a/plugins/include/amxconst.inc b/plugins/include/amxconst.inc index 461b2eff..40b1174e 100755 --- a/plugins/include/amxconst.inc +++ b/plugins/include/amxconst.inc @@ -238,6 +238,7 @@ enum { #define AMX_FLAG_COMPACT 0x04 /* compact encoding */ #define AMX_FLAG_BYTEOPC 0x08 /* opcode is a byte (not a cell) */ #define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no STMT opcode */ +#define AMX_FLAG_OLDFILE 0x20 /* Old AMX Mod plugin */ #define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */ #define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */ #define AMX_FLAG_BROWSE 0x4000 /* busy browsing */ diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index fb9d8e08..5ec2f897 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -716,15 +716,17 @@ native md5(const szString[], md5buffer[34]); /* Calculates the md5 keysum of a file */ native md5_file(const file[], md5buffer[34]); -/* Returns the internal flags set on the called plugin's state +/* Returns the internal flags set on the plugin's state * If hdr is 1, it will return the pcode flags rather than state flags. + * + * Use a plid of -1 to get the flags for the calling plugin. */ -native plugin_flags(hdr=0); +native plugin_flags(hdr=0, plid=-1); -/* When using modules that aren't part of AMX Mod X base package, do -* a require_module("modulename") for each of them within the plugin_modules() -* forward. Module name is the one listed when doing "amxx modules" in server -* console. */ +/** + * @deprecated + * Do not use! + */ forward plugin_modules(); native require_module(const module[]);