rifter1818
Well-known member
K here is my problem, I have a type (SQUARE)
[CS]
unsafe struct SQUARE
{
public byte Owner,Units;
public SQUARE*[] Neighbors;
public void AddUnit(byte owner)
{
byte i;
this.Units++;
this.Owner = owner;
if(Neighbors.GetUpperBound(0) < Units)
{
Units = 0;
Owner = 0;
for(i=0;i<=Neighbors.GetUpperBound(0);i++)
{
Neighbors->AddUnit(owner);
}
}
}
};
[/CS]
Now each square has some neighbors which i want to use pointers to Keep track of the problem is when i try and fill these pointers.
[CS]
IntPtr T;
Marshal.StructureToPtr(S[x,y],T,false);
S[x,y].Neighbors[0] = &(SQUARE)T.ToPointer();
[/CS]
This Cannot convert void* to SQUARE... Anyways how to i fill those pointers in C#? Thanks in advance.
[CS]
unsafe struct SQUARE
{
public byte Owner,Units;
public SQUARE*[] Neighbors;
public void AddUnit(byte owner)
{
byte i;
this.Units++;
this.Owner = owner;
if(Neighbors.GetUpperBound(0) < Units)
{
Units = 0;
Owner = 0;
for(i=0;i<=Neighbors.GetUpperBound(0);i++)
{
Neighbors->AddUnit(owner);
}
}
}
};
[/CS]
Now each square has some neighbors which i want to use pointers to Keep track of the problem is when i try and fill these pointers.
[CS]
IntPtr T;
Marshal.StructureToPtr(S[x,y],T,false);
S[x,y].Neighbors[0] = &(SQUARE)T.ToPointer();
[/CS]
This Cannot convert void* to SQUARE... Anyways how to i fill those pointers in C#? Thanks in advance.