Steamworks.NET icon indicating copy to clipboard operation
Steamworks.NET copied to clipboard

Unmanaged version of uint[] m_reserved in SteamNetworkingIdentity

Open Mockarutan opened this issue 2 years ago • 1 comments

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.

Mockarutan avatar Feb 01 '23 10:02 Mockarutan

uint m_reserved0; uint m_reserved1; uint m_reserved2; uint m_reserved..; uint m_reserved31;

should do it 😅

rlabrecque avatar Feb 03 '23 05:02 rlabrecque

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

rlabrecque avatar Jul 06 '24 04:07 rlabrecque