mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-04-16 22:32:28 +03:00
Overloaded function vtable order
This commit is contained in:
parent
6c1dd241ba
commit
9af8935f47
@ -18,10 +18,10 @@ namespace Steamworks
|
|||||||
public override void InitInternals()
|
public override void InitInternals()
|
||||||
{
|
{
|
||||||
_RequestCurrentStats = Marshal.GetDelegateForFunctionPointer<FRequestCurrentStats>( Marshal.ReadIntPtr( VTable, 0) );
|
_RequestCurrentStats = Marshal.GetDelegateForFunctionPointer<FRequestCurrentStats>( Marshal.ReadIntPtr( VTable, 0) );
|
||||||
_GetStat1 = Marshal.GetDelegateForFunctionPointer<FGetStat1>( Marshal.ReadIntPtr( VTable, 8) );
|
_GetStat1 = Marshal.GetDelegateForFunctionPointer<FGetStat1>( Marshal.ReadIntPtr( VTable, 16) );
|
||||||
_GetStat2 = Marshal.GetDelegateForFunctionPointer<FGetStat2>( Marshal.ReadIntPtr( VTable, 16) );
|
_GetStat2 = Marshal.GetDelegateForFunctionPointer<FGetStat2>( Marshal.ReadIntPtr( VTable, 8) );
|
||||||
_SetStat1 = Marshal.GetDelegateForFunctionPointer<FSetStat1>( Marshal.ReadIntPtr( VTable, 24) );
|
_SetStat1 = Marshal.GetDelegateForFunctionPointer<FSetStat1>( Marshal.ReadIntPtr( VTable, 32) );
|
||||||
_SetStat2 = Marshal.GetDelegateForFunctionPointer<FSetStat2>( Marshal.ReadIntPtr( VTable, 32) );
|
_SetStat2 = Marshal.GetDelegateForFunctionPointer<FSetStat2>( Marshal.ReadIntPtr( VTable, 24) );
|
||||||
_UpdateAvgRateStat = Marshal.GetDelegateForFunctionPointer<FUpdateAvgRateStat>( Marshal.ReadIntPtr( VTable, 40) );
|
_UpdateAvgRateStat = Marshal.GetDelegateForFunctionPointer<FUpdateAvgRateStat>( Marshal.ReadIntPtr( VTable, 40) );
|
||||||
_GetAchievement = Marshal.GetDelegateForFunctionPointer<FGetAchievement>( Marshal.ReadIntPtr( VTable, 48) );
|
_GetAchievement = Marshal.GetDelegateForFunctionPointer<FGetAchievement>( Marshal.ReadIntPtr( VTable, 48) );
|
||||||
_SetAchievement = Marshal.GetDelegateForFunctionPointer<FSetAchievement>( Marshal.ReadIntPtr( VTable, 56) );
|
_SetAchievement = Marshal.GetDelegateForFunctionPointer<FSetAchievement>( Marshal.ReadIntPtr( VTable, 56) );
|
||||||
@ -34,8 +34,8 @@ namespace Steamworks
|
|||||||
_GetNumAchievements = Marshal.GetDelegateForFunctionPointer<FGetNumAchievements>( Marshal.ReadIntPtr( VTable, 112) );
|
_GetNumAchievements = Marshal.GetDelegateForFunctionPointer<FGetNumAchievements>( Marshal.ReadIntPtr( VTable, 112) );
|
||||||
_GetAchievementName = Marshal.GetDelegateForFunctionPointer<FGetAchievementName>( Marshal.ReadIntPtr( VTable, 120) );
|
_GetAchievementName = Marshal.GetDelegateForFunctionPointer<FGetAchievementName>( Marshal.ReadIntPtr( VTable, 120) );
|
||||||
_RequestUserStats = Marshal.GetDelegateForFunctionPointer<FRequestUserStats>( Marshal.ReadIntPtr( VTable, 128) );
|
_RequestUserStats = Marshal.GetDelegateForFunctionPointer<FRequestUserStats>( Marshal.ReadIntPtr( VTable, 128) );
|
||||||
_GetUserStat1 = Marshal.GetDelegateForFunctionPointer<FGetUserStat1>( Marshal.ReadIntPtr( VTable, 136) );
|
_GetUserStat1 = Marshal.GetDelegateForFunctionPointer<FGetUserStat1>( Marshal.ReadIntPtr( VTable, 144) );
|
||||||
_GetUserStat2 = Marshal.GetDelegateForFunctionPointer<FGetUserStat2>( Marshal.ReadIntPtr( VTable, 144) );
|
_GetUserStat2 = Marshal.GetDelegateForFunctionPointer<FGetUserStat2>( Marshal.ReadIntPtr( VTable, 136) );
|
||||||
_GetUserAchievement = Marshal.GetDelegateForFunctionPointer<FGetUserAchievement>( Marshal.ReadIntPtr( VTable, 152) );
|
_GetUserAchievement = Marshal.GetDelegateForFunctionPointer<FGetUserAchievement>( Marshal.ReadIntPtr( VTable, 152) );
|
||||||
_GetUserAchievementAndUnlockTime = Marshal.GetDelegateForFunctionPointer<FGetUserAchievementAndUnlockTime>( Marshal.ReadIntPtr( VTable, 160) );
|
_GetUserAchievementAndUnlockTime = Marshal.GetDelegateForFunctionPointer<FGetUserAchievementAndUnlockTime>( Marshal.ReadIntPtr( VTable, 160) );
|
||||||
_ResetAllStats = Marshal.GetDelegateForFunctionPointer<FResetAllStats>( Marshal.ReadIntPtr( VTable, 168) );
|
_ResetAllStats = Marshal.GetDelegateForFunctionPointer<FResetAllStats>( Marshal.ReadIntPtr( VTable, 168) );
|
||||||
@ -56,10 +56,10 @@ namespace Steamworks
|
|||||||
_GetNextMostAchievedAchievementInfo = Marshal.GetDelegateForFunctionPointer<FGetNextMostAchievedAchievementInfo>( Marshal.ReadIntPtr( VTable, 288) );
|
_GetNextMostAchievedAchievementInfo = Marshal.GetDelegateForFunctionPointer<FGetNextMostAchievedAchievementInfo>( Marshal.ReadIntPtr( VTable, 288) );
|
||||||
_GetAchievementAchievedPercent = Marshal.GetDelegateForFunctionPointer<FGetAchievementAchievedPercent>( Marshal.ReadIntPtr( VTable, 296) );
|
_GetAchievementAchievedPercent = Marshal.GetDelegateForFunctionPointer<FGetAchievementAchievedPercent>( Marshal.ReadIntPtr( VTable, 296) );
|
||||||
_RequestGlobalStats = Marshal.GetDelegateForFunctionPointer<FRequestGlobalStats>( Marshal.ReadIntPtr( VTable, 304) );
|
_RequestGlobalStats = Marshal.GetDelegateForFunctionPointer<FRequestGlobalStats>( Marshal.ReadIntPtr( VTable, 304) );
|
||||||
_GetGlobalStat1 = Marshal.GetDelegateForFunctionPointer<FGetGlobalStat1>( Marshal.ReadIntPtr( VTable, 312) );
|
_GetGlobalStat1 = Marshal.GetDelegateForFunctionPointer<FGetGlobalStat1>( Marshal.ReadIntPtr( VTable, 320) );
|
||||||
_GetGlobalStat2 = Marshal.GetDelegateForFunctionPointer<FGetGlobalStat2>( Marshal.ReadIntPtr( VTable, 320) );
|
_GetGlobalStat2 = Marshal.GetDelegateForFunctionPointer<FGetGlobalStat2>( Marshal.ReadIntPtr( VTable, 312) );
|
||||||
_GetGlobalStatHistory1 = Marshal.GetDelegateForFunctionPointer<FGetGlobalStatHistory1>( Marshal.ReadIntPtr( VTable, 328) );
|
_GetGlobalStatHistory1 = Marshal.GetDelegateForFunctionPointer<FGetGlobalStatHistory1>( Marshal.ReadIntPtr( VTable, 336) );
|
||||||
_GetGlobalStatHistory2 = Marshal.GetDelegateForFunctionPointer<FGetGlobalStatHistory2>( Marshal.ReadIntPtr( VTable, 336) );
|
_GetGlobalStatHistory2 = Marshal.GetDelegateForFunctionPointer<FGetGlobalStatHistory2>( Marshal.ReadIntPtr( VTable, 328) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#region FunctionMeta
|
#region FunctionMeta
|
||||||
|
@ -57,17 +57,50 @@ namespace Generator
|
|||||||
|
|
||||||
void WriteFunctionPointerReader( CodeParser.Class clss )
|
void WriteFunctionPointerReader( CodeParser.Class clss )
|
||||||
{
|
{
|
||||||
|
// TODO - we'll probably have to do this PER platform
|
||||||
|
|
||||||
|
int[] locations = new int[clss.Functions.Count];
|
||||||
|
|
||||||
|
for ( int i = 0; i < clss.Functions.Count; i++ )
|
||||||
|
{
|
||||||
|
locations[i] = i * 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// MSVC switches the order in the vtable of overloaded functions
|
||||||
|
// I'm not going to try to try to work out how to order shit
|
||||||
|
// so lets just manually fix shit here
|
||||||
|
//
|
||||||
|
if ( clss.Name == "ISteamUserStats" )
|
||||||
|
{
|
||||||
|
Swap( clss, "GetStat1", "GetStat2", locations );
|
||||||
|
Swap( clss, "SetStat1", "SetStat2", locations );
|
||||||
|
Swap( clss, "GetUserStat1", "GetUserStat2", locations );
|
||||||
|
Swap( clss, "GetGlobalStat1", "GetGlobalStat2", locations );
|
||||||
|
Swap( clss, "GetGlobalStatHistory1", "GetGlobalStatHistory2", locations );
|
||||||
|
}
|
||||||
|
|
||||||
StartBlock( $"public override void InitInternals()" );
|
StartBlock( $"public override void InitInternals()" );
|
||||||
{
|
{
|
||||||
for (int i=0; i< clss.Functions.Count; i++ )
|
for (int i=0; i< clss.Functions.Count; i++ )
|
||||||
{
|
{
|
||||||
var func = clss.Functions[i];
|
var func = clss.Functions[i];
|
||||||
WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer<F{func.Name}>( Marshal.ReadIntPtr( VTable, {i*8}) );" );
|
WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer<F{func.Name}>( Marshal.ReadIntPtr( VTable, {locations[i]}) );" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndBlock();
|
EndBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Swap( CodeParser.Class clss, string v1, string v2, int[] locations )
|
||||||
|
{
|
||||||
|
var a = clss.Functions.IndexOf( clss.Functions.Single( x => x.Name == v1 ) );
|
||||||
|
var b = clss.Functions.IndexOf( clss.Functions.Single( x => x.Name == v2 ) );
|
||||||
|
|
||||||
|
var s = locations[a];
|
||||||
|
locations[a] = locations[b];
|
||||||
|
locations[b] = s;
|
||||||
|
}
|
||||||
|
|
||||||
private void WriteFunction( CodeParser.Class clss, CodeParser.Class.Function func )
|
private void WriteFunction( CodeParser.Class clss, CodeParser.Class.Function func )
|
||||||
{
|
{
|
||||||
var returnType = BaseType.Parse( func.ReturnType );
|
var returnType = BaseType.Parse( func.ReturnType );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user