Raised This Month: $32 Target: $400
 8% 

Dynamic Objects and Properties - v.0.0.32 - [2018.05.08]


Post New Thread Reply   
 
Thread Tools Display Modes
headline
SourceMod Moderator
Join Date: Mar 2015
Old 03-05-2017 , 19:06   Re: Dynamic Objects and Properties - v.0.0.24 - [2017.02.11]
Reply With Quote #231

Code:
L 03/05/2017 - 18:02:27: [SM] Exception reported: Could not read Handle 2d002d (error 1)
L 03/05/2017 - 18:02:27: [SM] Blaming: dynamic.smx
L 03/05/2017 - 18:02:27: [SM] Call stack trace:
L 03/05/2017 - 18:02:27: [SM]   [0] GetPluginStatus
L 03/05/2017 - 18:02:27: [SM]   [1] Line 246, ..\dynamic.sp::_Dynamic_CollectGarbage
L 03/05/2017 - 18:02:27: [SM]   [2] Line 73, ..\dynamic.sp::OnLibraryRemoved

I'm getting this error. I've tried doing it with and without disposing everything in OnPluginEnd, the result is the same. It happens every time the plugins unloads.

PHP Code:
#include <sourcemod>
#include <dynamic>

#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.0"

Database myDatabase null;

/* Chars */
char ga_sSteamID[MAXPLAYERS 1][128];

/* Booleans */
bool ga_bLoaded[MAXPLAYERS 1] = {false, ...};

/* ArrayList */
ArrayList donorArray null;

#include "donor.sp"

public Plugin myinfo =
{
    
name "[ANY] Donor Ranks",
    
author "Headline",
    
description "A custom donation system",
    
version PLUGIN_VERSION,
    
url="http://www.michaelwflaherty.com"
};

public 
APLRes AskPluginLoad2(Handle hMyselfbool bLatechar[] sErrorint err_max)
{
    
MarkNativeAsOptional("Store_GetClientCredits");

    
CreateNative("GetDonorArray"Native_GetDonorArray);
    
    
RegPluginLibrary("hl_donationmanager");
    
    return 
APLRes_Success;
}

public 
int Native_GetDonorArray(Handle pluginint iNumParams)
{
    return 
view_as<int>(donorArray);
}

public 
void OnPluginStart()
{
    
Database.Connect(SQLCallback_OnConnect"donations");
    
    
RegAdminCmd("sm_printdonors"Command_PrintDonorsADMFLAG_ROOT"A TEST COMMAND");
}

public 
Action Command_PrintDonors(int clientint args)
{
    
char buffer[300];
    for (
int i 0donorArray.Lengthi++)
    {
        
view_as<Donor>(donorArray.Get(i)).GetToString(buffersizeof(buffer));
        
PrintToConsole(clientbuffer);
    }
}
public 
void OnMapStart()
{
    
donorArray = new ArrayList();
}

public 
void OnClientPostAdminCheck(int client)
{
    
GetClientAuthId(clientAuthId_Steam2ga_sSteamID[client], sizeof(ga_sSteamID[]));
    
ReplaceString(ga_sSteamID[client], sizeof(ga_sSteamID[]), "STEAM_1""STEAM_0");
    
    
Log("hl_donationmanager.log""Player %N loaded under %s"clientga_sSteamID[client]);
    
char sQuery[300];
    
Format(sQuerysizeof(sQuery), "SELECT * FROM aaa_gfldonations_transactions WHERE t_steamid=\"%s\""ga_sSteamID[client]);
    
myDatabase.Query(SQLCallback_LoadClientsQueryGetClientUserId(client));
}

public 
void OnClientDisconnect(int client)
{
    
CleanADTArray(client);
}

public 
void OnPluginEnd()
{
    for (
int i 0donorArray.Lengthi++)
    {
        
view_as<Donor>(donorArray.Get(i)).Dispose();
    }
}

public 
void SQLCallback_OnConnect(Database db, const char[] errorany data)
{
    if (
db == null)
    {
        
SetFailState("[Donation System] Error: %s"error);
        return;
    }
    
    
myDatabase db;
    
    
AddServerIPColumn(myDatabase);
}

void AddServerIPColumn(Database db)
{
    
char sQuery[300];
    
Format(sQuerysizeof(sQuery), "ALTER TABLE `aaa_gfldonations_transactions` ADD `%s` int(8) NOT NULL default 0"GetServerIP());
    
db.Query(SQLCallback_VoidsQuery);
    
LogMessage("[CG - Donations] Column \"%s\" added!"GetServerIP());
}

public 
void SQLCallback_Void(Database dbDBResultSet results, const char[] errorany data)
{
    if (
db == null)
    {
        
SetFailState("Error (%i): %s"dataerror);
    }
}


public 
void SQLCallback_LoadClient(Database dbDBResultSet results, const char[] errorint userid)
{
    if (
db == null)
    {
        
SetFailState("Error: %s"error);
    }
    
    
int client GetClientOfUserId(userid);
    if (!
IsValidClient(client))
    {
        return;
    }
    
    if (
results.RowCount == 0)
    {
        return;
    }

    
int startTimeendTimeperk;
    
char status[128];
        
    
results.FetchRow();
    
    
/* Grab information */
    
startTime results.FetchInt(3);
    
endTime results.FetchInt(4);
    
perk results.FetchInt(7);
    
    
results.FetchString(6statussizeof(status));
        
    if (!
StrEqual(status"Completed"))
    {
        return;
    }
    if (
endTime GetTime())
    {
        return;
    }
    
    
Donor donor Donor();
    
donor.PerkID perk;
    
donor.StartTime startTime;
    
donor.EndTime endTime;
    
donor.SetSteamID(ga_sSteamID[client]);
    
//donorArray.Push(donor);
    
    
DataPack pack = new DataPack();
    
pack.WriteCell(GetClientUserId(client));
    
pack.WriteCell(donor);
    
pack.Reset();
    
    
char query[300];
    
Format(querysizeof(query), "SELECT * from aaa_gfldonations_perks WHERE p_id = %i"perk);
    
myDatabase.Query(SQLCallback_GetPerkStringquerypack);
    
    
Format(querysizeof(query), "SELECT `%s` FROM aaa_gfldonations_transactions WHERE t_steamid = \"%s\""GetServerIP(), ga_sSteamID[client]);
    
myDatabase.Query(SQLCallback_AnnouncequeryGetClientUserId(client));
    
    
ga_bLoaded[client] = true;
}

public 
void SQLCallback_Announce(Database dbDBResultSet results, const char[] errorint userid)
{
    if (
db == null)
    {
        
SetFailState("Error: %s"error);
    }
    
    
int client GetClientOfUserId(userid);
    if (!
IsValidClient(client))
    {
        return;
    }
    if (
results.RowCount == 0)
    {
        return;
    }
    
    
results.FetchRow();
    
bool result view_as<bool>(results.FetchInt(0));
    
    if (
result)
    {
        
CreateTimer(10.0Timer_PrintAnnouncementGetClientUserId(client));
    }
}

public 
Action Timer_PrintAnnouncement(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    
PrintToChatAll("\x04[Donations] %N has just donated!"client);
    
PrintToChatAll("\x04[Donations] %N has just donated!"client);
    
PrintToChatAll("\x04[Donations] %N has just donated!"client);
    
    
char query[300];
    
    
Format(querysizeof(query), "UPDATE aaa_gfldonations_transactions SET %s = 1 WHERE t_steamid = \"%s\""GetServerIP(), ga_sSteamID[client]);
    
myDatabase.Query(SQLCallback_Voidquery);
}

public 
void SQLCallback_GetPerkString(Database dbDBResultSet results, const char[] errorDataPack pack)
{
    
int client GetClientOfUserId(pack.ReadCell());
    
Donor donor pack.ReadCell();
    
delete pack;
    
    if (
db == null)
    {
        
SetFailState("Error: %s"error);
    }
    if (!
IsValidClient(client))
    {
        return;
    }
    if (
results.RowCount == 0)
    {
        return;
    }
    
    
results.FetchRow();

    
char perkString[256];
    
results.FetchString(5perkStringsizeof(perkString));
    
donor.SetPerkString(perkString);
    
    
donorArray.Push(donor);
}

void CleanADTArray(int client)
{
    
char SteamID[128];
    
GetClientAuthId(clientAuthId_SteamID64SteamIDsizeof(SteamID));
    
ReplaceString(SteamIDsizeof(SteamID), "STEAM_1""STEAM_0");

    
Donor donor;
    
char donorSteamID[128];
    for (
int i 0donorArray.Lengthi++)
    {
        
donor donorArray.Get(i);
        
donor.GetSteamID(donorSteamIDsizeof(donorSteamID));

        if (
StrEqual(donorSteamIDSteamID))
        {
            
donor.Dispose();
            
donorArray.Erase(i);
        }
    }
}

// Returns char array of the server IP
char[] GetServerIP()
{
    
char sServerIP[32];
    
int aArray[4];
    
int iLongIP GetConVarInt(FindConVar("hostip"));
    
    
aArray[0] = (iLongIP >> 24) & 0x000000FF;
    
aArray[1] = (iLongIP >> 16) & 0x000000FF;
    
aArray[2] = (iLongIP >> 8) & 0x000000FF;
    
aArray[3] = iLongIP 0x000000FF;
    
Format(sServerIPsizeof(sServerIP), "%d.%d.%d.%d"aArray[0], aArray[1], aArray[2], aArray[3]);
    return 
sServerIP;
}

bool IsValidClient(int clientbool bAllowBots falsebool bAllowDead true)
{
    if(!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;
}

void Log(char[] sPath, const char[] sMsgany ...)
{
    
char sLogFilePath[PLATFORM_MAX_PATH];
    
char sFormattedMsg[256];
    
BuildPath(Path_SMsLogFilePathsizeof(sLogFilePath), "logs/%s"sPath);
    
VFormat(sFormattedMsgsizeof(sFormattedMsg), sMsg3);
    
LogToFileEx(sLogFilePath"%s"sFormattedMsg);


Last edited by headline; 03-05-2017 at 19:09.
headline is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-05-2017 , 19:47   Re: Dynamic Objects and Properties - v.0.0.24 - [2017.02.11]
Reply With Quote #232

The error is harmless atm if you dispose everything.

I will still look into it tonight after work.

Thanks for source to replicate.
__________________
Neuro Toxin is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 03-05-2017 , 19:59   Re: Dynamic Objects and Properties - v.0.0.24 - [2017.02.11]
Reply With Quote #233

Quote:
Originally Posted by Neuro Toxin View Post
The error is harmless atm if you dispose everything.

I will still look into it tonight after work.

Thanks for source to replicate.
No problem.

You're gonna need this to compile it, aswell.

donor.sp
headline is offline
jdlovins
Junior Member
Join Date: Sep 2015
Old 03-05-2017 , 20:01   Re: Dynamic Objects and Properties - v.0.0.24 - [2017.02.11]
Reply With Quote #234

Quote:
Originally Posted by Neuro Toxin View Post
@ jdlovins

I'll look into what you've said.

I will iterate you MUST dispose your dynamic objects.

Quote:
Originally Posted by Neuro Toxin View Post
The error is harmless atm if you dispose everything.

I will still look into it tonight after work.

Thanks for source to replicate.
I looked more into the source and sort of understand why but not entirely. The GetPluginStatus seems to fail. I didn't dive too deep into that but yeah shouldnt be an issue if you dispose all your stuff properly. However that might want to be fixed somehow

I made a pull request on github to "fix" the issue. I don't know if using dynamic.Index is actually whats supposed to be used or offset.Index, everything else used offset.Index so i can only assume you just mixed up the two. If it was meant to be dynamic.Index then everything is wrong lol.
jdlovins is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-06-2017 , 16:58   Re: Dynamic Objects and Properties - v.0.0.24 - [2017.02.11]
Reply With Quote #235

Quote:
Originally Posted by jdlovins View Post
I looked more into the source and sort of understand why but not entirely. The GetPluginStatus seems to fail. I didn't dive too deep into that but yeah shouldnt be an issue if you dispose all your stuff properly. However that might want to be fixed somehow

I made a pull request on github to "fix" the issue. I don't know if using dynamic.Index is actually whats supposed to be used or offset.Index, everything else used offset.Index so i can only assume you just mixed up the two. If it was meant to be dynamic.Index then everything is wrong lol.
GetPluginStatus fails if a plugin has been unloaded that hasn't disposed it's dynamic objects.
__________________
Neuro Toxin is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 03-06-2017 , 23:19   Re: Dynamic Objects and Properties - v.0.0.24 - [2017.02.11]
Reply With Quote #236

Quote:
Originally Posted by Neuro Toxin View Post
GetPluginStatus fails if a plugin has been unloaded that hasn't disposed it's dynamic objects.
Why isn't this a template library?
KyleS is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-07-2017 , 00:00   Re: Dynamic Objects and Properties - v.0.0.24 - [2017.02.11]
Reply With Quote #237

Quote:
Originally Posted by KyleS View Post
Why isn't this a template library?
Sorry?

Those are big words that make no sense to a simple sourcepawn scripter.
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-07-2017 , 02:20   Re: Dynamic Objects and Properties - v.0.0.24 - [2017.02.11]
Reply With Quote #238

@ jdlovins

I merged your pull request to patch the error in SetFloatByOffset.

Would you be kind enough to download and compile the current master branch and then run the below command?

sm_dynamic_selftest

Edit: I've added new testing to sm_dynamic_selftest for offset get/set, fixed another bug in SetVectorByOffset and pushed the next major release in the repo (still waiting to make zip/update post, dinner first)
__________________

Last edited by Neuro Toxin; 03-07-2017 at 03:54.
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-07-2017 , 05:14   Re: Dynamic Objects and Properties - v.0.0.25 - [2017.03.07]
Reply With Quote #239

Dynamic 0.0.25

- Garbage collector plugin handle patch (thx KyleS)
- changed dynamic.Index to offset.Index (thx jdlovins)
- Add Get/Set by offset to sm_dynamic_selftest
- Fix Native_Dynamic_SetVectorByOffset
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-21-2017 , 09:51   Re: Dynamic Objects and Properties - v.0.0.26 - [2017.03.22]
Reply With Quote #240

Dynamic 0.0.26

- Add CloseHandle and CloseHandleByOffset
- Add Dynamic.IsLoaded()
- Intitalise all data along with natives in AskPluginLoad2
__________________
Neuro Toxin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode