microsoft/gdk-unity-package

XblSocialRelationshipResultGetRelationships returns array of same items.

MonsterArtur1 opened this issue · 2 comments

When you call XblSocialRelationshipResultGetRelationships from XBLSocial, you will get an array of elements, where every single element is the same as first one.
I belive there is an issue here:
Original code

if (HR.SUCCEEDED(result))
                    {
                        relationships = new XblSocialRelationship[count.ToInt32()];
                        var interopPtr = relationshipsPtr;

                        for (var i = 0; i < count.ToInt32(); i++)
                        {
                            relationships[i] = new XblSocialRelationship();
                            relationships[i].xboxUserId = interopPtr->xboxUserId;
                            relationships[i].isFavorite = interopPtr->isFavorite;
                            relationships[i].isFollowingCaller = interopPtr->isFollowingCaller;
                            relationships[i].socialNetworks = new string[interopPtr->socialNetworksCount.ToInt32()];

                            var socialNetworksPtr = interopPtr->socialNetworks;

                            for (var j = 0; j < interopPtr->socialNetworksCount.ToInt32(); j++)
                            {
                                relationships[i].socialNetworks[j] =
                                    Converters.NullTerminatedBytePointerToString((byte*)*socialNetworksPtr);
                                socialNetworksPtr++;
                            }
                        }
                    }

And should be:

 if (HR.SUCCEEDED(result))
                    {
                        relationships = new XblSocialRelationship[count.ToInt32()];
                        
                        for (var i = 0; i < count.ToInt32(); i++)
                        {
                            var interopPtr = relationshipsPtr[i];
                            relationships[i] = new XblSocialRelationship();
                            relationships[i].xboxUserId = interopPtr.xboxUserId;
                            relationships[i].isFavorite = interopPtr.isFavorite;
                            relationships[i].isFollowingCaller = interopPtr.isFollowingCaller;
                            relationships[i].socialNetworks = new string[interopPtr.socialNetworksCount.ToInt32()];

                            var socialNetworksPtr = interopPtr.socialNetworks;

                            for (var j = 0; j < interopPtr.socialNetworksCount.ToInt32(); j++)
                            {
                                relationships[i].socialNetworks[j] =
                                    Converters.NullTerminatedBytePointerToString((byte*)*socialNetworksPtr);
                                socialNetworksPtr++;
                            }
                        }
                    }

Thank you for pointing that out. I will open a bug on our side so one of our engineers can fix it.

This has been fixed here #82 and should be included in the next release.