Enable detours in ServerActivate to avoid sig conflict with third-party AMXX modules

This commit is contained in:
Arkshine 2015-12-19 19:00:39 +01:00
parent af0042b71d
commit 98fb03dd30
3 changed files with 34 additions and 12 deletions

View File

@ -619,6 +619,11 @@ void C_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
} }
} }
if (DropClientDetour)
{
DropClientDetour->EnableDetour();
}
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
@ -687,6 +692,11 @@ void C_ServerDeactivate()
} }
} }
if (DropClientDetour)
{
DropClientDetour->DisableDetour();
}
g_players_num = 0; g_players_num = 0;
executeForwards(FF_PluginEnd); executeForwards(FF_PluginEnd);
@ -1581,7 +1591,6 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
if (CommonConfig && CommonConfig->GetMemSig("SV_DropClient", &address) && address) if (CommonConfig && CommonConfig->GetMemSig("SV_DropClient", &address) && address)
{ {
DropClientDetour = DETOUR_CREATE_STATIC_FIXED(SV_DropClient, address); DropClientDetour = DETOUR_CREATE_STATIC_FIXED(SV_DropClient, address);
DropClientDetour->EnableDetour();
} }
else else
{ {

View File

@ -67,13 +67,19 @@ void OnPluginsLoaded()
ForwardInternalCommand = MF_RegisterForward("CS_InternalCommand", ET_STOP, FP_CELL, FP_STRING, FP_DONE); ForwardInternalCommand = MF_RegisterForward("CS_InternalCommand", ET_STOP, FP_CELL, FP_STRING, FP_DONE);
ForwardOnBuy = MF_RegisterForward("CS_OnBuy" , ET_STOP, FP_CELL, FP_CELL, FP_DONE); ForwardOnBuy = MF_RegisterForward("CS_OnBuy" , ET_STOP, FP_CELL, FP_CELL, FP_DONE);
ForwardOnBuyAttempt = MF_RegisterForward("CS_OnBuyAttempt" , ET_STOP, FP_CELL, FP_CELL, FP_DONE); ForwardOnBuyAttempt = MF_RegisterForward("CS_OnBuyAttempt" , ET_STOP, FP_CELL, FP_CELL, FP_DONE);
}
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
// Used to catch WeaponList message at map change.
EnableMessageHooks();
if (!ClientCommandDetour) // All CS_* forwards requires ClientCommand. Unlikely to fail. if (!ClientCommandDetour) // All CS_* forwards requires ClientCommand. Unlikely to fail.
{ {
ToggleDetour_ClientCommands(false); ToggleDetour_ClientCommands(false);
ToggleDetour_BuyCommands(false); ToggleDetour_BuyCommands(false);
return; RETURN_META(MRES_IGNORED);
} }
auto haveBotDetours = UseBotArgs && BotArgs; auto haveBotDetours = UseBotArgs && BotArgs;
@ -85,12 +91,6 @@ void OnPluginsLoaded()
ToggleDetour_ClientCommands(HasInternalCommandForward || HasOnBuyAttemptForward || HasOnBuyForward); ToggleDetour_ClientCommands(HasInternalCommandForward || HasOnBuyAttemptForward || HasOnBuyForward);
ToggleDetour_BuyCommands(HasOnBuyForward); ToggleDetour_BuyCommands(HasOnBuyForward);
}
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
// Used to catch WeaponList message at map change.
EnableMessageHooks();
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
@ -102,6 +102,19 @@ void OnServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void OnServerDeactivate()
{
if (!ClientCommandDetour)
{
RETURN_META(MRES_IGNORED);
}
ToggleDetour_ClientCommands(false);
ToggleDetour_BuyCommands(false);
RETURN_META(MRES_IGNORED);
}
void OnPluginsUnloaded() void OnPluginsUnloaded()
{ {
// Used with model natives, enabled on demand. // Used with model natives, enabled on demand.

View File

@ -124,7 +124,7 @@
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */ // #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */ // #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
#define FN_ServerActivate OnServerActivate /* pfnServerActivate() (wd) Server is starting a new map */ #define FN_ServerActivate OnServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
// #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */ #define FN_ServerDeactivate OnServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */ // #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */ // #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
// #define FN_StartFrame StartFrame /* pfnStartFrame() */ // #define FN_StartFrame StartFrame /* pfnStartFrame() */