fix UNLOZE+ReservedSlots

fix dependency unload error in a few plugins with LibraryExists in OnAllPluginsLoaded
This commit is contained in:
BotoX 2019-10-03 13:45:17 +02:00
parent 21f9296bc2
commit 6ffdbde668
8 changed files with 52 additions and 55 deletions

View File

@ -105,6 +105,9 @@ public void OnAllPluginsLoaded()
(g_Extension_Voice ? "loaded" : "not loaded")); (g_Extension_Voice ? "loaded" : "not loaded"));
} }
public void OnLibraryAdded(const char[] name) { OnAllPluginsLoaded(); }
public void OnLibraryRemoved(const char[] name) { OnAllPluginsLoaded(); }
public Action Command_Admins(int client, int args) public Action Command_Admins(int client, int args)
{ {
char aBuf[1024]; char aBuf[1024];

View File

@ -372,9 +372,15 @@ public void OnRunThinkFunctionsPost(bool simulating)
g_aaLagRecords[i][iOldRecord].vecOrigin[2] == TmpRecord.vecOrigin[2]) g_aaLagRecords[i][iOldRecord].vecOrigin[2] == TmpRecord.vecOrigin[2])
{ {
g_aEntityLagData[i].iNotMoving++; g_aEntityLagData[i].iNotMoving++;
if(g_aEntityLagData[i].iNotMoving == MAX_RECORDS)
LogMessage("[%d] index %d, entity %d GOING TO SLEEP", GetGameTickCount(), i, g_aEntityLagData[i].iEntity);
} }
else else
{
if(g_aEntityLagData[i].iNotMoving >= MAX_RECORDS)
LogMessage("[%d] index %d, entity %d WAKING UP", GetGameTickCount(), i, g_aEntityLagData[i].iEntity);
g_aEntityLagData[i].iNotMoving = 0; g_aEntityLagData[i].iNotMoving = 0;
}
if(g_aEntityLagData[i].iNotMoving >= MAX_RECORDS) if(g_aEntityLagData[i].iNotMoving >= MAX_RECORDS)
continue; continue;

View File

@ -100,6 +100,18 @@ public void OnAllPluginsLoaded()
g_Plugin_zombiereloaded = LibraryExists("zombiereloaded"); g_Plugin_zombiereloaded = LibraryExists("zombiereloaded");
} }
public void OnLibraryAdded(const char[] sName)
{
if(strcmp(sName, "zombiereloaded", false) == 0)
g_Plugin_zombiereloaded = true;
}
public void OnLibraryRemoved(const char[] sName)
{
if(strcmp(sName, "zombiereloaded", false) == 0)
g_Plugin_zombiereloaded = false;
}
public void OnPluginEnd() public void OnPluginEnd()
{ {
KillTimer(g_hThinkTimer); KillTimer(g_hThinkTimer);

View File

@ -4,14 +4,14 @@
#undef REQUIRE_PLUGIN #undef REQUIRE_PLUGIN
#include <AFKManager> #include <AFKManager>
#include <GFLClanru> #include <unloze>
#define REQUIRE_PLUGIN #define REQUIRE_PLUGIN
#pragma semicolon 1 #pragma semicolon 1
#pragma newdecls required #pragma newdecls required
bool g_Plugin_AFKManager; bool g_Plugin_AFKManager;
bool g_Plugin_GFLClanru; bool g_Plugin_UNLOZE;
int g_Client_Reservation[MAXPLAYERS + 1] = {0, ...}; int g_Client_Reservation[MAXPLAYERS + 1] = {0, ...};
@ -37,13 +37,16 @@ public void OnPluginStart()
public void OnAllPluginsLoaded() public void OnAllPluginsLoaded()
{ {
g_Plugin_AFKManager = LibraryExists("AFKManager"); g_Plugin_AFKManager = LibraryExists("AFKManager");
g_Plugin_GFLClanru = LibraryExists("GFLClanru"); g_Plugin_UNLOZE = LibraryExists("UNLOZE_ForumIntegration");
LogMessage("ReservedSlots capabilities:\nAFKManager: %s\nGFLClanru: %s\nentWatch: %s", LogMessage("ReservedSlots capabilities:\nAFKManager: %s\nUNLOZE: %s\n",
(g_Plugin_AFKManager ? "loaded" : "not loaded"), (g_Plugin_AFKManager ? "loaded" : "not loaded"),
(g_Plugin_GFLClanru ? "loaded" : "not loaded")); (g_Plugin_UNLOZE ? "loaded" : "not loaded"));
} }
public void OnLibraryAdded(const char[] name) { OnAllPluginsLoaded(); }
public void OnLibraryRemoved(const char[] name) { OnAllPluginsLoaded(); }
public void OnClientPostAdminCheck(int client) public void OnClientPostAdminCheck(int client)
{ {
AdminId admin = GetUserAdmin(client); AdminId admin = GetUserAdmin(client);
@ -87,7 +90,7 @@ public EConnect OnClientPreConnectEx(const char[] sName, char sPassword[255], co
return k_OnClientPreConnectEx_Accept; return k_OnClientPreConnectEx_Accept;
} }
if(g_Plugin_GFLClanru) if(g_Plugin_UNLOZE)
{ {
DataPack pack = new DataPack(); DataPack pack = new DataPack();
pack.WriteCell(admin); pack.WriteCell(admin);

View File

@ -102,6 +102,9 @@ public void OnAllPluginsLoaded()
(g_Extension_Voice ? "loaded" : "not loaded")); (g_Extension_Voice ? "loaded" : "not loaded"));
} }
public void OnLibraryAdded(const char[] name) { OnAllPluginsLoaded(); }
public void OnLibraryRemoved(const char[] name) { OnAllPluginsLoaded(); }
public void OnClientPutInServer(int client) public void OnClientPutInServer(int client)
{ {
g_SpecialMutes[client] = MUTE_NONE; g_SpecialMutes[client] = MUTE_NONE;

View File

@ -57,7 +57,7 @@ public void OnPluginStart()
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{ {
CreateNative("HasSteamIDReservedSlot", Native_HasSteamIDReservedSlot); CreateNative("AsyncHasSteamIDReservedSlot", Native_AsyncHasSteamIDReservedSlot);
RegPluginLibrary("unloze"); RegPluginLibrary("unloze");
@ -242,12 +242,12 @@ stock void ApplyGroupFlags(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public int Native_HasSteamIDReservedSlot(Handle plugin, int numParams) public int Native_AsyncHasSteamIDReservedSlot(Handle plugin, int numParams)
{ {
char sSteamID32[32]; char sSteamID32[32];
GetNativeString(1, sSteamID32, sizeof(sSteamID32)); GetNativeString(1, sSteamID32, sizeof(sSteamID32));
HasSteamIDReservedSlotCallback callback; AsyncHasSteamIDReservedSlotCallbackFunc callback;
callback = GetNativeCell(2); callback = GetNativeCell(2);
any data; any data;
@ -267,7 +267,7 @@ public int Native_HasSteamIDReservedSlot(Handle plugin, int numParams)
Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET, sRequest); Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET, sRequest);
if (!hRequest || if (!hRequest ||
!SteamWorks_SetHTTPCallbacks(hRequest, Native_HasSteamIDReservedSlot_OnTransferComplete) || !SteamWorks_SetHTTPCallbacks(hRequest, Native_AsyncHasSteamIDReservedSlot_OnTransferComplete) ||
!SteamWorks_SetHTTPRequestContextValue(hRequest, hDataPack) || !SteamWorks_SetHTTPRequestContextValue(hRequest, hDataPack) ||
!SteamWorks_SendHTTPRequest(hRequest)) !SteamWorks_SendHTTPRequest(hRequest))
{ {
@ -278,32 +278,32 @@ public int Native_HasSteamIDReservedSlot(Handle plugin, int numParams)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public int Native_HasSteamIDReservedSlot_OnTransferComplete(Handle hRequest, bool bFailure, bool bSuccessful, EHTTPStatusCode eStatusCode, DataPack hDataPack) public int Native_AsyncHasSteamIDReservedSlot_OnTransferComplete(Handle hRequest, bool bFailure, bool bSuccessful, EHTTPStatusCode eStatusCode, DataPack hDataPack)
{ {
if (bFailure || !bSuccessful || eStatusCode != k_EHTTPStatusCode200OK) if (bFailure || !bSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
{ {
char sData[32] = "NOGROUP"; char sData[32] = "NOGROUP";
Native_HasSteamIDReservedSlot_OnTransferResponse(sData, hDataPack); Native_AsyncHasSteamIDReservedSlot_OnTransferResponse(sData, hDataPack);
delete hRequest; delete hRequest;
return; return;
} }
SteamWorks_GetHTTPResponseBodyCallback(hRequest, Native_HasSteamIDReservedSlot_OnTransferResponse, hDataPack); SteamWorks_GetHTTPResponseBodyCallback(hRequest, Native_AsyncHasSteamIDReservedSlot_OnTransferResponse, hDataPack);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public int Native_HasSteamIDReservedSlot_OnTransferResponse(char[] sData, DataPack hDataPack) public int Native_AsyncHasSteamIDReservedSlot_OnTransferResponse(char[] sData, DataPack hDataPack)
{ {
hDataPack.Reset(); hDataPack.Reset();
char sSteamID32[32]; char sSteamID32[32];
hDataPack.ReadString(sSteamID32, sizeof(sSteamID32)); hDataPack.ReadString(sSteamID32, sizeof(sSteamID32));
HasSteamIDReservedSlotCallback callback; AsyncHasSteamIDReservedSlotCallbackFunc callback;
callback = view_as<HasSteamIDReservedSlotCallback>(hDataPack.ReadFunction()); callback = view_as<AsyncHasSteamIDReservedSlotCallbackFunc>(hDataPack.ReadFunction());
Handle plugin; Handle plugin;
plugin = hDataPack.ReadCell(); plugin = hDataPack.ReadCell();

View File

@ -1,30 +0,0 @@
#if defined _GFLClanru_Included
#endinput
#endif
#define _GFLClanru_Included
typeset AsyncHasSteamIDReservedSlotCallbackFunc
{
function void (const char[] sSteam32ID, int Result);
function void (const char[] sSteam32ID, int Result, any Data);
};
native void AsyncHasSteamIDReservedSlot(const char[] sSteam32ID, AsyncHasSteamIDReservedSlotCallbackFunc Callback, any Data = 0);
public SharedPlugin __pl_GFLClanru =
{
name = "GFLClanru",
file = "GFLClanru.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public __pl_GFLClanru_SetNTVOptional()
{
MarkNativeAsOptional("AsyncHasSteamIDReservedSlot");
}
#endif

View File

@ -1,19 +1,19 @@
#if defined _unloze_ForumIntegration_Included #if defined _UNLOZE_ForumIntegration_Included
#endinput #endinput
#endif #endif
#define _unloze_ForumIntegration_Included #define _UNLOZE_ForumIntegration_Included
typeset HasSteamIDReservedSlotCallback typeset AsyncHasSteamIDReservedSlotCallbackFunc
{ {
function void (const char[] sSteam32ID, int Result); function void (const char[] sSteam32ID, int Result);
function void (const char[] sSteam32ID, int Result, any Data); function void (const char[] sSteam32ID, int Result, any Data);
}; };
native void HasSteamIDReservedSlot(const char[] sSteam32ID, HasSteamIDReservedSlotCallback Callback, any Data = 0); native void AsyncHasSteamIDReservedSlot(const char[] sSteam32ID, AsyncHasSteamIDReservedSlotCallbackFunc Callback, any Data = 0);
public SharedPlugin __pl_unloze_ForumIntegration = public SharedPlugin __pl_UNLOZE_ForumIntegration =
{ {
name = "UNLOZE Forum Integration", name = "UNLOZE_ForumIntegration",
file = "UNLOZE_ForumIntegration.smx", file = "UNLOZE_ForumIntegration.smx",
#if defined REQUIRE_PLUGIN #if defined REQUIRE_PLUGIN
required = 1, required = 1,
@ -23,8 +23,8 @@ public SharedPlugin __pl_unloze_ForumIntegration =
}; };
#if !defined REQUIRE_PLUGIN #if !defined REQUIRE_PLUGIN
public __pl_UNLOZE Forum Integration_SetNTVOptional() public __pl_UNLOZE_ForumIntegration_SetNTVOptional()
{ {
MarkNativeAsOptional("HasSteamIDReservedSlot"); MarkNativeAsOptional("AsyncHasSteamIDReservedSlot");
} }
#endif #endif