Quote:
Originally Posted by Neuro Toxin
|
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
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
//this stuff is happening from this, for some reason its using position 0.
public MyClass()
{
// First we make a new dymanic object
Dynamic myclass = Dynamic(64, 0);
// Next we will define all the members
// -> We do this to force the offsets to always be in the same location
// over multiple instances of the same class.
myclass.SetInt("int1", 2);
myclass.SetInt("int2", 0);
myclass.SetFloat("float1", 0.0);
myclass.SetBool("bool1", false);
return view_as<MyClass>(myclass);
}
//
Int Position: 0, offset 0
Int Position: 0, offset 2
Float Position: 0, offset 4 <----- Why is it position 0 here
Bool Position: 0, offset 6
//this stuff happens from
mc.int1 = 3;
mc.int2 = 4;
mc.bool1 = false;
mc.float1 = 2.1;
//
Int Position: 0, offset 0
Int Position: 0, offset 2
Bool Position: 0, offset 6
Float Position: 65, offset 4 <---- Now its position 65. This right here is causing issues.
L 03/05/2017 - 11:42:47: [SM] Exception reported: Invalid index 65 (count: 1)
L 03/05/2017 - 11:42:47: [SM] Blaming: dynamic.smx
L 03/05/2017 - 11:42:47: [SM] Call stack trace:
L 03/05/2017 - 11:42:47: [SM] [0] ArrayList.Get
L 03/05/2017 - 11:42:47: [SM] [1] Line 486, C:\Users\Josh\Desktop\New folder\dynamic.sp::_Dynamic_GetMemberDataType
L 03/05/2017 - 11:42:47: [SM] [2] Line 49, dynamic/system/datatypes/float.sp::_SetFloat
L 03/05/2017 - 11:42:47: [SM] [3] Line 119, dynamic/system/datatypes/float.sp::_Dynamic_SetFloatByOffset
L 03/05/2017 - 11:42:47: [SM] [4] Line 313, dynamic/system/natives.sp::Native_Dynamic_SetFloatByOffset
L 03/05/2017 - 11:42:47: [SM] [6] Dynamic_SetFloatByOffset
L 03/05/2017 - 11:42:47: [SM] [7] Line 210, C:\Users\Josh\Documents\spedit1.2.0.1\sourcep awn\configs\sm_1_8_5914\include\dynamic/methodmaps/dynamic.inc:
ynamic.SetFloatByOffset
L 03/05/2017 - 11:42:47: [SM] [8] Line 111, C:\Users\Josh\Documents\timersurf\addons\sour cemod\scripting\include\testdyn.inc::MyClass. float1.set
L 03/05/2017 - 11:42:47: [SM] [9] Line 26, C:\Users\Josh\Desktop\testdyn.sp::OnPluginSta rt
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