View Single Post
jdlovins
Junior Member
Join Date: Sep 2015
Old 03-05-2017 , 11:24   Re: Dynamic Objects and Properties - v.0.0.24 - [2017.02.11]
Reply With Quote #228

Quote:
Originally Posted by Neuro Toxin View Post
You are responsible to .Dispose each Dynamic instance you create.

Edit: The Dynamic Lifecycle
I understand that. If i make a regular dynamic and call the garbage collection command it will clean it up, however if I use a methodmap dynamic class it wont. Is that intended?

Still floats are still broken. I can use any other type but as soon as i use floats it breaks dynamic. Can you reproduce that issue while using a methodmap dynamic class?

edit:

I changed _SetFloat and _SetInt to print out the position its trying to access like so
Code:
stock Dynamic_MemberType _SetFloat(ArrayList data, int position, int offset, int blocksize, float value)
{
	PrintToServer("Position: %i, offset %i", position, offset);
When trying to modify an int its position 0 and offset 0
When trying to modify a float its position 65 and offset 0.

Is that supposed to happen? The array length is 1 and its trying to access index 65.

edit2:

so i see you reserve up to MAXPLAYERS for client stuff which is 64, so it trying to access the 65th index makes sense. The only weird thing is when you do it with an int it will use position 0 (should be client reserved), however when you use a float it uses 65 (which should have just been created) and that index is invalid.

I modified
public void Initialise(Handle plugin, int blocksize=64, int startsize=0, bool persistent=false)
to display the index it is with "PrintToServer("From Initialise: index: %i ", me);"

this results in
Spoiler


Okay. everything looks normal.

I have a plugin that does
Code:
public void OnPluginStart()
{
	MyClass mc = MyClass();
	mc.int1 = 3;
	mc.int2 = 4;
	mc.bool1 = false;
	mc.float1 = 2.1;
	mc.Dispose();
}
when loaded it prints out "From Initialise: index: 65"
okay cool, thats right. It should be MAXPLAYERS + 1 now.

When the rest of the code runs with my debug messages i get
Spoiler


It's trying to access position 0 for the ints and bools. Then it gets to the float and uses position 65 ( the right position i believe. )

Am i misunderstanding something or is there actually a big bug?

edit 3:

sorry for the long post. Just kinda going as i look through stuff. I believe i found the issue.

Code:
stock bool _Dynamic_SetFloatByOffset(DynamicObject dynamic, DynamicOffset offset, float value)
{
	if (!dynamic.IsValid(true))
		return false;
	
	Dynamic_MemberType type = _SetFloat(dynamic.Data, dynamic.Index, offset.Cell, dynamic.BlockSize, value);
	_Dynamic_CallOnChangedForwardByOffset(dynamic, offset, type);
	return true;
}
This uses dynamic.Index

Now look at

Code:
stock bool _Dynamic_SetIntByOffset(DynamicObject dynamic, DynamicOffset offset, int value)
{
	if (!dynamic.IsValid(true))
		return false;
	
	Dynamic_MemberType type = _SetInt(dynamic.Data, offset.Index, offset.Cell, dynamic.BlockSize, value);
	_Dynamic_CallOnChangedForwardByOffset(dynamic, offset, type);
	return true;
}
this uses offset.Index

The same goes for bool, it uses offset.Index.

I dont know which one is the right one and which one is the wrong one. offset.Index or dynamic.Index. I want to say its dynamic but I'm not too sure.

Changing float to use offset.Index fixes the float problem.

I guess it happened here; https://github.com/ntoxin66/Dynamic/...1cfe7d5c2cR118

Last edited by jdlovins; 03-05-2017 at 13:10.
jdlovins is offline