Steamworks.NET
Steamworks.NET copied to clipboard
Unmanaged version of uint[] m_reserved in SteamNetworkingIdentity
I've implemented this in a way that does a stack allocation of SteamNetworkingMessage_t, looks like this: var messageBuffer = stackalloc SteamNetworkingMessage_t*[bufferSize];
The SteamNetworkingMessage_t struct contains a SteamNetworkingIdentity field, which have the uint[] m_reserved field. A stack allocation cannot contain a managed array. For me, it works by just commenting out the m_reserved field and it's MarshalAs attribute. But maybe there is an edge case where that solution will break.
I'm unfamiliar with the [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] attribute that is on the m_reserved field, so I don't know how to replace it with an unmanaged/non array version. But maybe it can be added easily by someone more familiar with it.
uint m_reserved0; uint m_reserved1; uint m_reserved2; uint m_reserved..; uint m_reserved31;
should do it 😅
Looks like I did this way back here: https://github.com/rlabrecque/Steamworks.NET/commit/6879a840221f7d1771a1f8e4fa37c63cbd8d8efd
I seen a few other places doing this, very dumb but alas