Raised This Month: $12 Target: $400
 3% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-21-2016 , 10:22   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #101

Refactor native logic
- Split internal logic code and native code to define an edge between them
- No internal code uses native calls anymore
- Fixed some bugs with Handles and Strings in the process

This update was to stop internal Dynamic calls from using it's own Natives. The benchmark has speed up again on add/read/update members.
__________________
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-24-2016 , 05:30   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #102

Massive refactor with lots of changes
- Refactored all type code (Lots of small bugs fixed in the process)
- Added property OwnerPlugin
- Added Reset(bool disposemembers=true, int blocksize=0, int startsize=0)
- Added sm_dynamic_selftest command to ensure all Dynamic methods work as expected
- Finished partially completed type conversion between types Vector and String
__________________
Neuro Toxin is offline
PUNKSNOTDEAF
Junior Member
Join Date: Oct 2015
Old 08-25-2016 , 05:01   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #103

New update works fine. I only get the following error each mapchange.

Code:
L 08/25/2016 - 10:24:03: Error log file session closed.
L 08/25/2016 - 10:24:04: SourceMod error session started
L 08/25/2016 - 10:24:04: Info (map "de_mirage") (file "errors_20160825.log")
L 08/25/2016 - 10:24:04: [SM] Exception reported: Could not read Handle b8490022 (error 1)
L 08/25/2016 - 10:24:04: [SM] Blaming: third/dynamic.smx()
L 08/25/2016 - 10:24:04: [SM] Call stack trace:
L 08/25/2016 - 10:24:04: [SM]   [0] GetPluginStatus
L 08/25/2016 - 10:24:04: [SM]   [1] Line 131, dynamic.sp::OnMapStart()
PUNKSNOTDEAF is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-25-2016 , 08:49   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #104

Steps towards FindByMemberValue(Dynamic params)
- Fixed .Push* methods not storing membernames correctly
- Fixed .CompareString/ByOffset
- Some more tests added to SelfTest
- First version of .FindByMemberValue
- Add garbage collection to OnLibraryRemoved forward
- Reset player settings on post disconnect
- Implement .Reset
- Implement .GetName properly
- Fix SelfTest reporting errors for Vector conversions

Quote:
Originally Posted by PUNKSNOTDEAF View Post
New update works fine. I only get the following error each mapchange.

Code:
L 08/25/2016 - 10:24:03: Error log file session closed.
L 08/25/2016 - 10:24:04: SourceMod error session started
L 08/25/2016 - 10:24:04: Info (map "de_mirage") (file "errors_20160825.log")
L 08/25/2016 - 10:24:04: [SM] Exception reported: Could not read Handle b8490022 (error 1)
L 08/25/2016 - 10:24:04: [SM] Blaming: third/dynamic.smx()
L 08/25/2016 - 10:24:04: [SM] Call stack trace:
L 08/25/2016 - 10:24:04: [SM]   [0] GetPluginStatus
L 08/25/2016 - 10:24:04: [SM]   [1] Line 131, dynamic.sp::OnMapStart()
Be careful storing Handles. This makes me think a piece of code is calling delete on your handle, and is NOT calling .SetHandle("member", null);

Also update to the latest Dynamic master branch download as I had recently fixed a similar bug around Handles.
__________________
Neuro Toxin is offline
Chief149
Member
Join Date: Sep 2010
Old 08-26-2016 , 17:22   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #105

So I've been having an issue with setting some properties. dynamic.smx throws an exception basically.

The relevant part of my object's constructor:
Code:
public BClient(char steamid[64], int Client, bool loadFromDB = true)
{
	if(g_iLaser == -1)
		g_iLaser = PrecacheModel("materials/sprites/laserbeam.vmt", true);
		
	//the backing data structure
	Dynamic bc = Dynamic(256, 0);

	//one of the fields that wont work
	bc.SetInt("usingvendor", 0);

	//these lines only occur after EVERY field has been setup in the constructor
	if(loadFromDB)
		CreateTimer(3.0, LoadClient, bc);
	return view_as<BClient>(bc);
}
Here is the property code:
Code:
property int UsingVendor
{
	public get()
	{
		static int offset = INVALID_DYNAMIC_OFFSET;
		if(offset == INVALID_DYNAMIC_OFFSET)
		{
			offset = this.GetMemberOffset("usingvendor");
			if(offset == INVALID_DYNAMIC_OFFSET)
				ThrowError("A serious error has occurred in Dynamic!");
		}
		return this.GetIntByOffset(offset);
	}
	public set(int i)
	{
		static int offset = INVALID_DYNAMIC_OFFSET;
		if(offset == INVALID_DYNAMIC_OFFSET)
		{
			offset = this.GetMemberOffset("usingvendor");
			if(offset == INVALID_DYNAMIC_OFFSET)
			{
				offset = this.SetInt("usingvendor", i);
				return;
			}
		}
		this.SetIntByOffset(offset, i);
	}
}
The code that triggers the error:
Code:
player.UsingVendor = 0;
//The error thrown to the console
Code:
L 08/26/2016 - 21:15:25: [SM] Exception reported: Invalid index 1 (count: 0)
L 08/26/2016 - 21:15:25: [SM] Blaming: dynamic.smx()
L 08/26/2016 - 21:15:25: [SM] Call stack trace:
L 08/26/2016 - 21:15:25: [SM]   [0] GetArrayCell
L 08/26/2016 - 21:15:25: [SM]   [1] Line 1199, C:\Users\Clayton\Dropbox\BluRP Dev\dynamic.sp::GetMemberType()
L 08/26/2016 - 21:15:25: [SM]   [2] Line 1527, C:\Users\Clayton\Dropbox\BluRP Dev\dynamic.sp::Native_Dynamic_SetIntByOffset()
L 08/26/2016 - 21:15:25: [SM]   [4] Dynamic_SetIntByOffset
L 08/26/2016 - 21:15:25: [SM]   [5] Line 201, C:\Users\Clayton\Dropbox\BluRP Dev\include\dynamic.inc::Dynamic.SetIntByOffset()
L 08/26/2016 - 21:15:25: [SM]   [6] Line 1166, C:\Users\Clayton\Dropbox\BluRP Dev\include\bluerp/classes/BClient.inc::BClient.UsingVendor.set()
L 08/26/2016 - 21:15:25: [SM]   [7] Line 1502, C:\Users\Clayton\Dropbox\BluRP Dev\include\bluerp/classes/BNpc.inc::JobHandle()
Is this an error on my end or with your plugin? I seem to be following everything correctly as far as I can tell. Judging by the error, I am pretty sure I am NOT trying to access a property of an invalid dynamic object.

Last edited by Chief149; 08-26-2016 at 17:23.
Chief149 is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 08-26-2016 , 18:22   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #106

It appears .Membercount does not decrement when a child is disposed. I believe this is the cause of my loops getting slower + possibly memory leaks with stack constantly increasing?
SM9 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-26-2016 , 20:49   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #107

Quote:
Originally Posted by Chief149 View Post
Is this an error on my end or with your plugin? I seem to be following everything correctly as far as I can tell. Judging by the error, I am pretty sure I am NOT trying to access a property of an invalid dynamic object.
The error is indicating that your dynamic object wasn't initialised before setting a member.

Please download / install / update your plugins to the current unreleased version.

Please also refer to this new methodmap structure. The offsets have been removed to avoid corruption with non uniform objects. It also cleans up your methodmaps and makes them easier to manage.
__________________

Last edited by Neuro Toxin; 08-26-2016 at 21:03.
Neuro Toxin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-26-2016 , 20:57   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #108

Quote:
Originally Posted by xCoderx View Post
It appears .Membercount does not decrement when a child is disposed. I believe this is the cause of my loops getting slower + possibly memory leaks with stack constantly increasing?
Dynamic cant remove members and have the member count decrease.

You need to reuse members or use .Reset(*) to clean its members.

You may be after a collection which allows you to remove objects.

Edit: You can also override a collections Items function to return your own methodmap.
__________________

Last edited by Neuro Toxin; 08-26-2016 at 20:59.
Neuro Toxin is offline
Chief149
Member
Join Date: Sep 2010
Old 08-26-2016 , 21:03   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #109

I suspected that there may have been updates to your plugin, so I downloaded the latest version. This didn't fix the problem.

The constructor initializes every single member. Even if it doesn't, I know for certain that I initialized the one class member that is shown in my post.

How long does it take for your plugin to initialize a dynamic object once the constructor is called? Because in this case that object was a client object. BClient is created when a player joins the game. This error occurred a couple minutes later.

How does the efficiency compare between the new methodmap structure and the old one? I have thousands of lines worth of classes coded with the older methodmap structure.

What I find really odd is that other members do work, but some also don't work. I have checked many times to make sure I didn't misspell the member name in the constructor or property.

Last edited by Chief149; 08-26-2016 at 21:05.
Chief149 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-26-2016 , 21:20   Re: Dynamic Objects and Properties - v.0.0.16 - [2016.07.14]
Reply With Quote #110

To confirm. The index out of bounds error is saying your dynamic object is invalid. It doesnt relate to the member your trying to access.

Maybe add a check like .IsValid just before your error line.

Dynamic objects are initialised instantly.

The "class" method your using is like .01 faster over 100K member iterations which is nothing really. The class code is safe if noone accesses the dynamic object from outside your class.

By removing the offsets and doing methodmaps based on the last post to you: you should remove those pesky and hard to debug issues when your checking the member names in the initialiser and properties. It also makes the code heaps easier to manage. Imo, this outweighs the ever so slight performance boost.

When i get weird issues with members. I dump the object using .WriteKeyValues. This is the best way to check your data is right.
__________________
Neuro Toxin is offline
Reply


Thread Tools
Display Modes

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 09:08.


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