mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-27 05:58:07 +03:00
Use pack8 structs for windows where appropriate
This commit is contained in:
parent
1dd679c391
commit
c6ac47c0c3
@ -279,6 +279,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetAppOwner( IntPtr self );
|
||||
private FGetAppOwner _GetAppOwner;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetAppOwner_Windows( IntPtr self, ref SteamId retVal );
|
||||
private FGetAppOwner_Windows _GetAppOwner_Windows;
|
||||
|
||||
|
@ -143,6 +143,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetFriendByIndex( IntPtr self, int iFriend, int iFriendFlags );
|
||||
private FGetFriendByIndex _GetFriendByIndex;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetFriendByIndex_Windows( IntPtr self, ref SteamId retVal, int iFriend, int iFriendFlags );
|
||||
private FGetFriendByIndex_Windows _GetFriendByIndex_Windows;
|
||||
|
||||
@ -319,6 +320,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetClanByIndex( IntPtr self, int iClan );
|
||||
private FGetClanByIndex _GetClanByIndex;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetClanByIndex_Windows( IntPtr self, ref SteamId retVal, int iClan );
|
||||
private FGetClanByIndex_Windows _GetClanByIndex_Windows;
|
||||
|
||||
@ -395,6 +397,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetFriendFromSourceByIndex( IntPtr self, SteamId steamIDSource, int iFriend );
|
||||
private FGetFriendFromSourceByIndex _GetFriendFromSourceByIndex;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetFriendFromSourceByIndex_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDSource, int iFriend );
|
||||
private FGetFriendFromSourceByIndex_Windows _GetFriendFromSourceByIndex_Windows;
|
||||
|
||||
@ -560,6 +563,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetClanOwner( IntPtr self, SteamId steamIDClan );
|
||||
private FGetClanOwner _GetClanOwner;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetClanOwner_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDClan );
|
||||
private FGetClanOwner_Windows _GetClanOwner_Windows;
|
||||
|
||||
@ -591,6 +595,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetClanOfficerByIndex( IntPtr self, SteamId steamIDClan, int iOfficer );
|
||||
private FGetClanOfficerByIndex _GetClanOfficerByIndex;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetClanOfficerByIndex_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDClan, int iOfficer );
|
||||
private FGetClanOfficerByIndex_Windows _GetClanOfficerByIndex_Windows;
|
||||
|
||||
@ -712,6 +717,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetCoplayFriend( IntPtr self, int iCoplayFriend );
|
||||
private FGetCoplayFriend _GetCoplayFriend;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetCoplayFriend_Windows( IntPtr self, ref SteamId retVal, int iCoplayFriend );
|
||||
private FGetCoplayFriend_Windows _GetCoplayFriend_Windows;
|
||||
|
||||
@ -788,6 +794,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetChatMemberByIndex( IntPtr self, SteamId steamIDClan, int iUser );
|
||||
private FGetChatMemberByIndex _GetChatMemberByIndex;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetChatMemberByIndex_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDClan, int iUser );
|
||||
private FGetChatMemberByIndex_Windows _GetChatMemberByIndex_Windows;
|
||||
|
||||
|
@ -178,6 +178,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetSteamID( IntPtr self );
|
||||
private FGetSteamID _GetSteamID;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetSteamID_Windows( IntPtr self, ref SteamId retVal );
|
||||
private FGetSteamID_Windows _GetSteamID_Windows;
|
||||
|
||||
@ -354,6 +355,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FCreateUnauthenticatedUserConnection( IntPtr self );
|
||||
private FCreateUnauthenticatedUserConnection _CreateUnauthenticatedUserConnection;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FCreateUnauthenticatedUserConnection_Windows( IntPtr self, ref SteamId retVal );
|
||||
private FCreateUnauthenticatedUserConnection_Windows _CreateUnauthenticatedUserConnection_Windows;
|
||||
|
||||
|
@ -194,6 +194,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetLobbyByIndex( IntPtr self, int iLobby );
|
||||
private FGetLobbyByIndex _GetLobbyByIndex;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetLobbyByIndex_Windows( IntPtr self, ref SteamId retVal, int iLobby );
|
||||
private FGetLobbyByIndex_Windows _GetLobbyByIndex_Windows;
|
||||
|
||||
@ -270,6 +271,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetLobbyMemberByIndex( IntPtr self, SteamId steamIDLobby, int iMember );
|
||||
private FGetLobbyMemberByIndex _GetLobbyMemberByIndex;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetLobbyMemberByIndex_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDLobby, int iMember );
|
||||
private FGetLobbyMemberByIndex_Windows _GetLobbyMemberByIndex_Windows;
|
||||
|
||||
@ -475,6 +477,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetLobbyOwner( IntPtr self, SteamId steamIDLobby );
|
||||
private FGetLobbyOwner _GetLobbyOwner;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetLobbyOwner_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDLobby );
|
||||
private FGetLobbyOwner_Windows _GetLobbyOwner_Windows;
|
||||
|
||||
|
@ -20,6 +20,7 @@ namespace Steamworks
|
||||
_CloseP2PSessionWithUser = Marshal.GetDelegateForFunctionPointer<FCloseP2PSessionWithUser>( Marshal.ReadIntPtr( VTable, 32) );
|
||||
_CloseP2PChannelWithUser = Marshal.GetDelegateForFunctionPointer<FCloseP2PChannelWithUser>( Marshal.ReadIntPtr( VTable, 40) );
|
||||
_GetP2PSessionState = Marshal.GetDelegateForFunctionPointer<FGetP2PSessionState>( Marshal.ReadIntPtr( VTable, 48) );
|
||||
_GetP2PSessionState_Windows = Marshal.GetDelegateForFunctionPointer<FGetP2PSessionState_Windows>( Marshal.ReadIntPtr( VTable, 48) );
|
||||
_AllowP2PPacketRelay = Marshal.GetDelegateForFunctionPointer<FAllowP2PPacketRelay>( Marshal.ReadIntPtr( VTable, 56) );
|
||||
_CreateListenSocket = Marshal.GetDelegateForFunctionPointer<FCreateListenSocket>( Marshal.ReadIntPtr( VTable, 64) );
|
||||
_CreateP2PConnectionSocket = Marshal.GetDelegateForFunctionPointer<FCreateP2PConnectionSocket>( Marshal.ReadIntPtr( VTable, 72) );
|
||||
@ -114,10 +115,22 @@ namespace Steamworks
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetP2PSessionState( IntPtr self, SteamId steamIDRemote, ref P2PSessionState_t pConnectionState );
|
||||
private FGetP2PSessionState _GetP2PSessionState;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetP2PSessionState_Windows( IntPtr self, SteamId steamIDRemote, ref P2PSessionState_t.Pack8 pConnectionState );
|
||||
private FGetP2PSessionState_Windows _GetP2PSessionState_Windows;
|
||||
|
||||
#endregion
|
||||
internal bool GetP2PSessionState( SteamId steamIDRemote, ref P2PSessionState_t pConnectionState )
|
||||
{
|
||||
if ( Config.Os == OsType.Windows )
|
||||
{
|
||||
P2PSessionState_t.Pack8 pConnectionState_windows = pConnectionState;
|
||||
var retVal = _GetP2PSessionState_Windows( Self, steamIDRemote, ref pConnectionState_windows );
|
||||
pConnectionState = pConnectionState_windows;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return _GetP2PSessionState( Self, steamIDRemote, ref pConnectionState );
|
||||
}
|
||||
|
||||
|
@ -16,15 +16,19 @@ namespace Steamworks
|
||||
_GetNumActiveBeacons = Marshal.GetDelegateForFunctionPointer<FGetNumActiveBeacons>( Marshal.ReadIntPtr( VTable, 0) );
|
||||
_GetBeaconByIndex = Marshal.GetDelegateForFunctionPointer<FGetBeaconByIndex>( Marshal.ReadIntPtr( VTable, 8) );
|
||||
_GetBeaconDetails = Marshal.GetDelegateForFunctionPointer<FGetBeaconDetails>( Marshal.ReadIntPtr( VTable, 16) );
|
||||
_GetBeaconDetails_Windows = Marshal.GetDelegateForFunctionPointer<FGetBeaconDetails_Windows>( Marshal.ReadIntPtr( VTable, 16) );
|
||||
_JoinParty = Marshal.GetDelegateForFunctionPointer<FJoinParty>( Marshal.ReadIntPtr( VTable, 24) );
|
||||
_GetNumAvailableBeaconLocations = Marshal.GetDelegateForFunctionPointer<FGetNumAvailableBeaconLocations>( Marshal.ReadIntPtr( VTable, 32) );
|
||||
_GetAvailableBeaconLocations = Marshal.GetDelegateForFunctionPointer<FGetAvailableBeaconLocations>( Marshal.ReadIntPtr( VTable, 40) );
|
||||
_GetAvailableBeaconLocations_Windows = Marshal.GetDelegateForFunctionPointer<FGetAvailableBeaconLocations_Windows>( Marshal.ReadIntPtr( VTable, 40) );
|
||||
_CreateBeacon = Marshal.GetDelegateForFunctionPointer<FCreateBeacon>( Marshal.ReadIntPtr( VTable, 48) );
|
||||
_CreateBeacon_Windows = Marshal.GetDelegateForFunctionPointer<FCreateBeacon_Windows>( Marshal.ReadIntPtr( VTable, 48) );
|
||||
_OnReservationCompleted = Marshal.GetDelegateForFunctionPointer<FOnReservationCompleted>( Marshal.ReadIntPtr( VTable, 56) );
|
||||
_CancelReservation = Marshal.GetDelegateForFunctionPointer<FCancelReservation>( Marshal.ReadIntPtr( VTable, 64) );
|
||||
_ChangeNumOpenSlots = Marshal.GetDelegateForFunctionPointer<FChangeNumOpenSlots>( Marshal.ReadIntPtr( VTable, 72) );
|
||||
_DestroyBeacon = Marshal.GetDelegateForFunctionPointer<FDestroyBeacon>( Marshal.ReadIntPtr( VTable, 80) );
|
||||
_GetBeaconLocationData = Marshal.GetDelegateForFunctionPointer<FGetBeaconLocationData>( Marshal.ReadIntPtr( VTable, 88) );
|
||||
_GetBeaconLocationData_Windows = Marshal.GetDelegateForFunctionPointer<FGetBeaconLocationData_Windows>( Marshal.ReadIntPtr( VTable, 88) );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
@ -54,10 +58,22 @@ namespace Steamworks
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetBeaconDetails( IntPtr self, PartyBeaconID_t ulBeaconID, ref SteamId pSteamIDBeaconOwner, ref SteamPartyBeaconLocation_t pLocation, StringBuilder pchMetadata, int cchMetadata );
|
||||
private FGetBeaconDetails _GetBeaconDetails;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetBeaconDetails_Windows( IntPtr self, PartyBeaconID_t ulBeaconID, ref SteamId pSteamIDBeaconOwner, ref SteamPartyBeaconLocation_t.Pack8 pLocation, StringBuilder pchMetadata, int cchMetadata );
|
||||
private FGetBeaconDetails_Windows _GetBeaconDetails_Windows;
|
||||
|
||||
#endregion
|
||||
internal bool GetBeaconDetails( PartyBeaconID_t ulBeaconID, ref SteamId pSteamIDBeaconOwner, ref SteamPartyBeaconLocation_t pLocation, StringBuilder pchMetadata, int cchMetadata )
|
||||
{
|
||||
if ( Config.Os == OsType.Windows )
|
||||
{
|
||||
SteamPartyBeaconLocation_t.Pack8 pLocation_windows = pLocation;
|
||||
var retVal = _GetBeaconDetails_Windows( Self, ulBeaconID, ref pSteamIDBeaconOwner, ref pLocation_windows, pchMetadata, cchMetadata );
|
||||
pLocation = pLocation_windows;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return _GetBeaconDetails( Self, ulBeaconID, ref pSteamIDBeaconOwner, ref pLocation, pchMetadata, cchMetadata );
|
||||
}
|
||||
|
||||
@ -89,10 +105,22 @@ namespace Steamworks
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetAvailableBeaconLocations( IntPtr self, ref SteamPartyBeaconLocation_t pLocationList, uint uMaxNumLocations );
|
||||
private FGetAvailableBeaconLocations _GetAvailableBeaconLocations;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetAvailableBeaconLocations_Windows( IntPtr self, ref SteamPartyBeaconLocation_t.Pack8 pLocationList, uint uMaxNumLocations );
|
||||
private FGetAvailableBeaconLocations_Windows _GetAvailableBeaconLocations_Windows;
|
||||
|
||||
#endregion
|
||||
internal bool GetAvailableBeaconLocations( ref SteamPartyBeaconLocation_t pLocationList, uint uMaxNumLocations )
|
||||
{
|
||||
if ( Config.Os == OsType.Windows )
|
||||
{
|
||||
SteamPartyBeaconLocation_t.Pack8 pLocationList_windows = pLocationList;
|
||||
var retVal = _GetAvailableBeaconLocations_Windows( Self, ref pLocationList_windows, uMaxNumLocations );
|
||||
pLocationList = pLocationList_windows;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return _GetAvailableBeaconLocations( Self, ref pLocationList, uMaxNumLocations );
|
||||
}
|
||||
|
||||
@ -100,10 +128,21 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamAPICall_t FCreateBeacon( IntPtr self, uint unOpenSlots, ref SteamPartyBeaconLocation_t pBeaconLocation, string pchConnectString, string pchMetadata );
|
||||
private FCreateBeacon _CreateBeacon;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamAPICall_t FCreateBeacon_Windows( IntPtr self, uint unOpenSlots, ref SteamPartyBeaconLocation_t.Pack8 pBeaconLocation, string pchConnectString, string pchMetadata );
|
||||
private FCreateBeacon_Windows _CreateBeacon_Windows;
|
||||
|
||||
#endregion
|
||||
internal async Task<CreateBeaconCallback_t?> CreateBeacon( uint unOpenSlots, /* ref */ SteamPartyBeaconLocation_t pBeaconLocation, string pchConnectString, string pchMetadata )
|
||||
{
|
||||
if ( Config.Os == OsType.Windows )
|
||||
{
|
||||
SteamPartyBeaconLocation_t.Pack8 pBeaconLocation_windows = pBeaconLocation;
|
||||
var retVal = _CreateBeacon_Windows( Self, unOpenSlots, ref pBeaconLocation_windows, pchConnectString, pchMetadata );
|
||||
pBeaconLocation = pBeaconLocation_windows;
|
||||
return await CreateBeaconCallback_t.GetResultAsync( retVal );
|
||||
}
|
||||
|
||||
return await CreateBeaconCallback_t.GetResultAsync( _CreateBeacon( Self, unOpenSlots, ref pBeaconLocation, pchConnectString, pchMetadata ) );
|
||||
}
|
||||
|
||||
@ -157,10 +196,22 @@ namespace Steamworks
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetBeaconLocationData( IntPtr self, SteamPartyBeaconLocation_t BeaconLocation, SteamPartyBeaconLocationData eData, StringBuilder pchDataStringOut, int cchDataStringOut );
|
||||
private FGetBeaconLocationData _GetBeaconLocationData;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetBeaconLocationData_Windows( IntPtr self, SteamPartyBeaconLocation_t.Pack8 BeaconLocation, SteamPartyBeaconLocationData eData, StringBuilder pchDataStringOut, int cchDataStringOut );
|
||||
private FGetBeaconLocationData_Windows _GetBeaconLocationData_Windows;
|
||||
|
||||
#endregion
|
||||
internal bool GetBeaconLocationData( SteamPartyBeaconLocation_t BeaconLocation, SteamPartyBeaconLocationData eData, StringBuilder pchDataStringOut, int cchDataStringOut )
|
||||
{
|
||||
if ( Config.Os == OsType.Windows )
|
||||
{
|
||||
SteamPartyBeaconLocation_t.Pack8 BeaconLocation_windows = BeaconLocation;
|
||||
var retVal = _GetBeaconLocationData_Windows( Self, BeaconLocation, eData, pchDataStringOut, cchDataStringOut );
|
||||
BeaconLocation = BeaconLocation_windows;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return _GetBeaconLocationData( Self, BeaconLocation, eData, pchDataStringOut, cchDataStringOut );
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ namespace Steamworks
|
||||
_CreateQueryUGCDetailsRequest = Marshal.GetDelegateForFunctionPointer<FCreateQueryUGCDetailsRequest>( Marshal.ReadIntPtr( VTable, 24) );
|
||||
_SendQueryUGCRequest = Marshal.GetDelegateForFunctionPointer<FSendQueryUGCRequest>( Marshal.ReadIntPtr( VTable, 32) );
|
||||
_GetQueryUGCResult = Marshal.GetDelegateForFunctionPointer<FGetQueryUGCResult>( Marshal.ReadIntPtr( VTable, 40) );
|
||||
_GetQueryUGCResult_Windows = Marshal.GetDelegateForFunctionPointer<FGetQueryUGCResult_Windows>( Marshal.ReadIntPtr( VTable, 40) );
|
||||
_GetQueryUGCPreviewURL = Marshal.GetDelegateForFunctionPointer<FGetQueryUGCPreviewURL>( Marshal.ReadIntPtr( VTable, 48) );
|
||||
_GetQueryUGCMetadata = Marshal.GetDelegateForFunctionPointer<FGetQueryUGCMetadata>( Marshal.ReadIntPtr( VTable, 56) );
|
||||
_GetQueryUGCChildren = Marshal.GetDelegateForFunctionPointer<FGetQueryUGCChildren>( Marshal.ReadIntPtr( VTable, 64) );
|
||||
@ -54,6 +55,7 @@ namespace Steamworks
|
||||
_SetItemMetadata = Marshal.GetDelegateForFunctionPointer<FSetItemMetadata>( Marshal.ReadIntPtr( VTable, 304) );
|
||||
_SetItemVisibility = Marshal.GetDelegateForFunctionPointer<FSetItemVisibility>( Marshal.ReadIntPtr( VTable, 312) );
|
||||
_SetItemTags = Marshal.GetDelegateForFunctionPointer<FSetItemTags>( Marshal.ReadIntPtr( VTable, 320) );
|
||||
_SetItemTags_Windows = Marshal.GetDelegateForFunctionPointer<FSetItemTags_Windows>( Marshal.ReadIntPtr( VTable, 320) );
|
||||
_SetItemContent = Marshal.GetDelegateForFunctionPointer<FSetItemContent>( Marshal.ReadIntPtr( VTable, 328) );
|
||||
_SetItemPreview = Marshal.GetDelegateForFunctionPointer<FSetItemPreview>( Marshal.ReadIntPtr( VTable, 336) );
|
||||
_SetAllowLegacyUpload = Marshal.GetDelegateForFunctionPointer<FSetAllowLegacyUpload>( Marshal.ReadIntPtr( VTable, 344) );
|
||||
@ -151,10 +153,22 @@ namespace Steamworks
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetQueryUGCResult( IntPtr self, UGCQueryHandle_t handle, uint index, ref SteamUGCDetails_t pDetails );
|
||||
private FGetQueryUGCResult _GetQueryUGCResult;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FGetQueryUGCResult_Windows( IntPtr self, UGCQueryHandle_t handle, uint index, ref SteamUGCDetails_t.Pack8 pDetails );
|
||||
private FGetQueryUGCResult_Windows _GetQueryUGCResult_Windows;
|
||||
|
||||
#endregion
|
||||
internal bool GetQueryUGCResult( UGCQueryHandle_t handle, uint index, ref SteamUGCDetails_t pDetails )
|
||||
{
|
||||
if ( Config.Os == OsType.Windows )
|
||||
{
|
||||
SteamUGCDetails_t.Pack8 pDetails_windows = pDetails;
|
||||
var retVal = _GetQueryUGCResult_Windows( Self, handle, index, ref pDetails_windows );
|
||||
pDetails = pDetails_windows;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return _GetQueryUGCResult( Self, handle, index, ref pDetails );
|
||||
}
|
||||
|
||||
@ -566,10 +580,22 @@ namespace Steamworks
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FSetItemTags( IntPtr self, UGCUpdateHandle_t updateHandle, ref SteamParamStringArray_t pTags );
|
||||
private FSetItemTags _SetItemTags;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
private delegate bool FSetItemTags_Windows( IntPtr self, UGCUpdateHandle_t updateHandle, ref SteamParamStringArray_t.Pack8 pTags );
|
||||
private FSetItemTags_Windows _SetItemTags_Windows;
|
||||
|
||||
#endregion
|
||||
internal bool SetItemTags( UGCUpdateHandle_t updateHandle, ref SteamParamStringArray_t pTags )
|
||||
{
|
||||
if ( Config.Os == OsType.Windows )
|
||||
{
|
||||
SteamParamStringArray_t.Pack8 pTags_windows = pTags;
|
||||
var retVal = _SetItemTags_Windows( Self, updateHandle, ref pTags_windows );
|
||||
pTags = pTags_windows;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return _SetItemTags( Self, updateHandle, ref pTags );
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,7 @@ namespace Steamworks
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamId FGetSteamID( IntPtr self );
|
||||
private FGetSteamID _GetSteamID;
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate void FGetSteamID_Windows( IntPtr self, ref SteamId retVal );
|
||||
private FGetSteamID_Windows _GetSteamID_Windows;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -89,7 +89,9 @@ namespace Generator
|
||||
{
|
||||
var func = clss.Functions[i];
|
||||
var returnType = BaseType.Parse( func.ReturnType );
|
||||
var args = func.Arguments.Select( x => BaseType.Parse( x.Value, x.Key ) ).ToArray();
|
||||
var regularpos = i * 8;
|
||||
var windowsSpecific = NeedsWindowsSpecificFunction( func, returnType, args );
|
||||
|
||||
if ( Cleanup.IsDeprecated( $"{clss.Name}.{func.Name}" ) )
|
||||
{
|
||||
@ -97,27 +99,34 @@ namespace Generator
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( regularpos != locations[i] )
|
||||
{
|
||||
WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer<F{func.Name}>( Marshal.ReadIntPtr( VTable, Config.Os == OsType.Windows ? {locations[i]} : {regularpos} ) );" );
|
||||
if ( returnType.IsReturnedWeird )
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer<F{func.Name}>( Marshal.ReadIntPtr( VTable, {locations[i]}) );" );
|
||||
var pos = $"Config.Os == OsType.Windows ? {locations[i]} : {regularpos} ";
|
||||
|
||||
if ( returnType.IsReturnedWeird )
|
||||
{
|
||||
WriteLine( $"_{func.Name}_Windows = Marshal.GetDelegateForFunctionPointer<F{func.Name}_Windows>( Marshal.ReadIntPtr( VTable, {locations[i]}) );" );
|
||||
}
|
||||
if ( regularpos == locations[i] )
|
||||
pos = regularpos.ToString();
|
||||
|
||||
WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer<F{func.Name}>( Marshal.ReadIntPtr( VTable, {pos}) );" );
|
||||
|
||||
if ( windowsSpecific )
|
||||
{
|
||||
WriteLine( $"_{func.Name}_Windows = Marshal.GetDelegateForFunctionPointer<F{func.Name}_Windows>( Marshal.ReadIntPtr( VTable, {pos}) );" );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
|
||||
private bool NeedsWindowsSpecificFunction( CodeParser.Class.Function func, BaseType returnType, BaseType[] args )
|
||||
{
|
||||
if ( returnType.IsReturnedWeird ) return true;
|
||||
if ( returnType.WindowsSpecific ) return true;
|
||||
if ( args.Any( x => x.WindowsSpecific ) ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void Swap( CodeParser.Class clss, string v1, string v2, int[] locations )
|
||||
{
|
||||
var a = clss.Functions.IndexOf( clss.Functions.Single( x => x.Name == v1 ) );
|
||||
@ -130,7 +139,6 @@ namespace Generator
|
||||
|
||||
private void WriteFunction( CodeParser.Class clss, CodeParser.Class.Function func )
|
||||
{
|
||||
|
||||
var returnType = BaseType.Parse( func.ReturnType );
|
||||
returnType.Func = func.Name;
|
||||
|
||||
@ -143,6 +151,8 @@ namespace Generator
|
||||
var argstr = string.Join( ", ", args.Select( x => x.AsArgument() ) );
|
||||
var delegateargstr = string.Join( ", ", args.Select( x => x.AsArgument() ) );
|
||||
|
||||
var windowsSpecific = NeedsWindowsSpecificFunction( func, returnType, args );
|
||||
|
||||
if ( returnType is SteamApiCallType sap )
|
||||
{
|
||||
sap.CallResult = func.CallResult;
|
||||
@ -160,11 +170,25 @@ namespace Generator
|
||||
WriteLine( $"private delegate {returnType.TypeNameFrom} F{func.Name}( IntPtr self, {delegateargstr} );".Replace( "( IntPtr self, )", "( IntPtr self )" ) );
|
||||
WriteLine( $"private F{func.Name} _{func.Name};" );
|
||||
|
||||
if ( returnType.IsReturnedWeird )
|
||||
if ( windowsSpecific )
|
||||
{
|
||||
var windelargs = $"ref {returnType.TypeName} retVal, {delegateargstr}".Trim( ',', ' ' );
|
||||
var delegateargstrw = string.Join( ", ", args.Select( x => x.AsWinArgument() ) );
|
||||
WriteLine( $"[UnmanagedFunctionPointer( CallingConvention.ThisCall )]" );
|
||||
|
||||
if ( returnType.IsReturnedWeird )
|
||||
{
|
||||
var windelargs = $"ref {returnType.TypeName} retVal, {delegateargstrw}".Trim( ',', ' ' );
|
||||
WriteLine( $"private delegate void F{func.Name}_Windows( IntPtr self, {windelargs} );".Replace( "( IntPtr self, )", "( IntPtr self )" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( returnType.ReturnAttribute != null )
|
||||
WriteLine( returnType.ReturnAttribute );
|
||||
|
||||
|
||||
WriteLine( $"private delegate {returnType.TypeNameFrom} F{func.Name}_Windows( IntPtr self, {delegateargstrw} );".Replace( "( IntPtr self, )", "( IntPtr self )" ) );
|
||||
}
|
||||
|
||||
WriteLine( $"private delegate void F{func.Name}_Windows( IntPtr self, {windelargs} );".Replace( "( IntPtr self, )", "( IntPtr self )" ) );
|
||||
WriteLine( $"private F{func.Name}_Windows _{func.Name}_Windows;" );
|
||||
}
|
||||
|
||||
@ -186,6 +210,48 @@ namespace Generator
|
||||
EndBlock();
|
||||
WriteLine();
|
||||
}
|
||||
else if ( windowsSpecific )
|
||||
{
|
||||
StartBlock( "if ( Config.Os == OsType.Windows )" );
|
||||
{
|
||||
var wincallargs = callargs;
|
||||
|
||||
foreach ( var arg in args )
|
||||
{
|
||||
if ( !arg.WindowsSpecific ) continue;
|
||||
|
||||
if ( arg.IsVector )
|
||||
{
|
||||
WriteLine( $"{arg.TypeName}.Pack8[] {arg.VarName}_windows = {arg.VarName};" );
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLine( $"{arg.TypeName}.Pack8 {arg.VarName}_windows = {arg.VarName};" );
|
||||
}
|
||||
|
||||
wincallargs = wincallargs.Replace( $" {arg.VarName}", $" {arg.VarName}_windows" );
|
||||
}
|
||||
|
||||
if ( !returnType.IsVoid )
|
||||
Write( "var retVal = " );
|
||||
|
||||
WriteLine( $"_{func.Name}_Windows( Self, {wincallargs} );".Replace( "( Self, )", "( Self )" ) );
|
||||
|
||||
foreach ( var arg in args )
|
||||
{
|
||||
if ( !arg.WindowsSpecific ) continue;
|
||||
|
||||
WriteLine( $"{arg.VarName} = {arg.VarName}_windows;" );
|
||||
}
|
||||
|
||||
if ( !returnType.IsVoid )
|
||||
{
|
||||
WriteLine( returnType.Return( "retVal" ) );
|
||||
}
|
||||
}
|
||||
EndBlock();
|
||||
WriteLine();
|
||||
}
|
||||
|
||||
if ( returnType.IsVoid )
|
||||
{
|
||||
|
@ -184,6 +184,17 @@ namespace Generator
|
||||
WriteLine( " };" );
|
||||
}
|
||||
|
||||
Write( $"public static implicit operator {name}.Pack8 ( {name} d ) => " );
|
||||
{
|
||||
Write( $"new {name}.Pack8{{ " );
|
||||
{
|
||||
foreach ( var f in c.Fields )
|
||||
{
|
||||
Write( $"{CleanMemberName( f.Name )} = d.{CleanMemberName( f.Name )}," );
|
||||
}
|
||||
}
|
||||
WriteLine( " };" );
|
||||
}
|
||||
}
|
||||
EndBlock();
|
||||
|
||||
|
@ -13,6 +13,8 @@ internal class BaseType
|
||||
|
||||
public string Func;
|
||||
|
||||
public virtual bool WindowsSpecific => false;
|
||||
|
||||
public static BaseType Parse( string type, string varname = null )
|
||||
{
|
||||
type = Cleanup.ConvertType( type );
|
||||
@ -59,6 +61,7 @@ internal class BaseType
|
||||
}
|
||||
|
||||
public virtual string AsArgument() => IsVector ? $"[In,Out] {Ref}{TypeName.Trim( '*', ' ' )}[] {VarName}" : $"{Ref}{TypeName.Trim( '*', ' ' )} {VarName}";
|
||||
public virtual string AsWinArgument() => AsArgument();
|
||||
public virtual string AsCallArgument() => $"{Ref}{VarName}";
|
||||
|
||||
public virtual string Return( string varname ) => $"return {varname};";
|
||||
@ -134,6 +137,25 @@ internal class StructType : BaseType
|
||||
|
||||
return base.Return( varname );
|
||||
}
|
||||
|
||||
public override bool WindowsSpecific
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = Generator.Program.Definitions.structs.FirstOrDefault( x => x.Name == StructName );
|
||||
if ( s == null ) return false;
|
||||
|
||||
return !s.IsPack4OnWindows;
|
||||
}
|
||||
}
|
||||
|
||||
public override string AsWinArgument()
|
||||
{
|
||||
if ( WindowsSpecific )
|
||||
return IsVector ? $"[In,Out] {Ref}{TypeName.Trim( '*', ' ' )}.Pack8[] {VarName}" : $"{Ref}{TypeName.Trim( '*', ' ' )}.Pack8 {VarName}";
|
||||
|
||||
return AsArgument();
|
||||
}
|
||||
}
|
||||
|
||||
internal class SteamApiCallType : BaseType
|
||||
|
@ -9,7 +9,9 @@ namespace Generator
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main( string[] args )
|
||||
public static SteamApiDefinition Definitions;
|
||||
|
||||
static void Main( string[] args )
|
||||
{
|
||||
var content = System.IO.File.ReadAllText( "steam_sdk/steam_api.json" );
|
||||
var def = Newtonsoft.Json.JsonConvert.DeserializeObject<SteamApiDefinition>( content );
|
||||
@ -21,7 +23,9 @@ namespace Generator
|
||||
parser.ParseClasses();
|
||||
parser.ExtendDefinition( def );
|
||||
|
||||
var generator = new CodeWriter( parser, def );
|
||||
Definitions = def;
|
||||
|
||||
var generator = new CodeWriter( parser, def );
|
||||
|
||||
generator.ToFolder( "../Facepunch.Steamworks/Generated/" );
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ namespace Generator
|
||||
{
|
||||
get
|
||||
{
|
||||
// if ( Name.Contains( "LeaderboardEntry_t" ) )
|
||||
// return false;
|
||||
if ( Name.Contains( "SteamItemDetails_t" ) ) return true;
|
||||
if ( Name.Contains( "MatchMakingKeyValuePair_t" ) ) return true;
|
||||
|
||||
if ( Fields.Any( x => x.Type.Contains( "CSteamID" ) ) )
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user