Nice name deduplucate

This commit is contained in:
Garry Newman 2019-04-17 13:33:38 +01:00
parent 99e85e9a98
commit eb16bebae9
4 changed files with 42 additions and 45 deletions

View File

@ -182,6 +182,7 @@ public async Task GetStatGlobalHistoryInt()
var startups = new Stat( "GMA_X_STARTUPS_STAT" );
var history = await startups.GetGlobalIntDays( 60 );
Assert.AreNotEqual( 0, history.Length );
for ( int i=0; i< history.Length; i++ )
{

View File

@ -18,9 +18,9 @@ public ISteamUserStats( bool server = false ) : base( server )
public override void InitInternals()
{
RequestCurrentStatsDelegatePointer = Marshal.GetDelegateForFunctionPointer<RequestCurrentStatsDelegate>( Marshal.ReadIntPtr( VTable, 0) );
GetStatDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetStatDelegate>( Marshal.ReadIntPtr( VTable, 8) );
GetStat1DelegatePointer = Marshal.GetDelegateForFunctionPointer<GetStat1Delegate>( Marshal.ReadIntPtr( VTable, 8) );
GetStat2DelegatePointer = Marshal.GetDelegateForFunctionPointer<GetStat2Delegate>( Marshal.ReadIntPtr( VTable, 16) );
SetStatDelegatePointer = Marshal.GetDelegateForFunctionPointer<SetStatDelegate>( Marshal.ReadIntPtr( VTable, 24) );
SetStat1DelegatePointer = Marshal.GetDelegateForFunctionPointer<SetStat1Delegate>( Marshal.ReadIntPtr( VTable, 24) );
SetStat2DelegatePointer = Marshal.GetDelegateForFunctionPointer<SetStat2Delegate>( Marshal.ReadIntPtr( VTable, 32) );
UpdateAvgRateStatDelegatePointer = Marshal.GetDelegateForFunctionPointer<UpdateAvgRateStatDelegate>( Marshal.ReadIntPtr( VTable, 40) );
GetAchievementDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetAchievementDelegate>( Marshal.ReadIntPtr( VTable, 48) );
@ -34,7 +34,7 @@ public override void InitInternals()
GetNumAchievementsDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetNumAchievementsDelegate>( Marshal.ReadIntPtr( VTable, 112) );
GetAchievementNameDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetAchievementNameDelegate>( Marshal.ReadIntPtr( VTable, 120) );
RequestUserStatsDelegatePointer = Marshal.GetDelegateForFunctionPointer<RequestUserStatsDelegate>( Marshal.ReadIntPtr( VTable, 128) );
GetUserStatDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetUserStatDelegate>( Marshal.ReadIntPtr( VTable, 136) );
GetUserStat1DelegatePointer = Marshal.GetDelegateForFunctionPointer<GetUserStat1Delegate>( Marshal.ReadIntPtr( VTable, 136) );
GetUserStat2DelegatePointer = Marshal.GetDelegateForFunctionPointer<GetUserStat2Delegate>( Marshal.ReadIntPtr( VTable, 144) );
GetUserAchievementDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetUserAchievementDelegate>( Marshal.ReadIntPtr( VTable, 152) );
GetUserAchievementAndUnlockTimeDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetUserAchievementAndUnlockTimeDelegate>( Marshal.ReadIntPtr( VTable, 160) );
@ -56,9 +56,9 @@ public override void InitInternals()
GetNextMostAchievedAchievementInfoDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetNextMostAchievedAchievementInfoDelegate>( Marshal.ReadIntPtr( VTable, 288) );
GetAchievementAchievedPercentDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetAchievementAchievedPercentDelegate>( Marshal.ReadIntPtr( VTable, 296) );
RequestGlobalStatsDelegatePointer = Marshal.GetDelegateForFunctionPointer<RequestGlobalStatsDelegate>( Marshal.ReadIntPtr( VTable, 304) );
GetGlobalStatDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetGlobalStatDelegate>( Marshal.ReadIntPtr( VTable, 312) );
GetGlobalStat1DelegatePointer = Marshal.GetDelegateForFunctionPointer<GetGlobalStat1Delegate>( Marshal.ReadIntPtr( VTable, 312) );
GetGlobalStat2DelegatePointer = Marshal.GetDelegateForFunctionPointer<GetGlobalStat2Delegate>( Marshal.ReadIntPtr( VTable, 320) );
GetGlobalStatHistoryDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetGlobalStatHistoryDelegate>( Marshal.ReadIntPtr( VTable, 328) );
GetGlobalStatHistory1DelegatePointer = Marshal.GetDelegateForFunctionPointer<GetGlobalStatHistory1Delegate>( Marshal.ReadIntPtr( VTable, 328) );
GetGlobalStatHistory2DelegatePointer = Marshal.GetDelegateForFunctionPointer<GetGlobalStatHistory2Delegate>( Marshal.ReadIntPtr( VTable, 336) );
}
@ -77,13 +77,13 @@ internal bool RequestCurrentStats()
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool GetStatDelegate( IntPtr self, string pchName, ref int pData );
private GetStatDelegate GetStatDelegatePointer;
private delegate bool GetStat1Delegate( IntPtr self, string pchName, ref int pData );
private GetStat1Delegate GetStat1DelegatePointer;
#endregion
internal bool GetStat( string pchName, ref int pData )
internal bool GetStat1( string pchName, ref int pData )
{
return GetStatDelegatePointer( Self, pchName, ref pData );
return GetStat1DelegatePointer( Self, pchName, ref pData );
}
#region FunctionMeta
@ -101,13 +101,13 @@ internal bool GetStat2( string pchName, ref float pData )
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool SetStatDelegate( IntPtr self, string pchName, int nData );
private SetStatDelegate SetStatDelegatePointer;
private delegate bool SetStat1Delegate( IntPtr self, string pchName, int nData );
private SetStat1Delegate SetStat1DelegatePointer;
#endregion
internal bool SetStat( string pchName, int nData )
internal bool SetStat1( string pchName, int nData )
{
return SetStatDelegatePointer( Self, pchName, nData );
return SetStat1DelegatePointer( Self, pchName, nData );
}
#region FunctionMeta
@ -264,13 +264,13 @@ internal string GetAchievementName( uint iAchievement )
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool GetUserStatDelegate( IntPtr self, SteamId steamIDUser, string pchName, ref int pData );
private GetUserStatDelegate GetUserStatDelegatePointer;
private delegate bool GetUserStat1Delegate( IntPtr self, SteamId steamIDUser, string pchName, ref int pData );
private GetUserStat1Delegate GetUserStat1DelegatePointer;
#endregion
internal bool GetUserStat( SteamId steamIDUser, string pchName, ref int pData )
internal bool GetUserStat1( SteamId steamIDUser, string pchName, ref int pData )
{
return GetUserStatDelegatePointer( Self, steamIDUser, pchName, ref pData );
return GetUserStat1DelegatePointer( Self, steamIDUser, pchName, ref pData );
}
#region FunctionMeta
@ -513,13 +513,13 @@ internal bool GetAchievementAchievedPercent( string pchName, ref float pflPercen
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
[return: MarshalAs( UnmanagedType.I1 )]
private delegate bool GetGlobalStatDelegate( IntPtr self, string pchStatName, ref long pData );
private GetGlobalStatDelegate GetGlobalStatDelegatePointer;
private delegate bool GetGlobalStat1Delegate( IntPtr self, string pchStatName, ref long pData );
private GetGlobalStat1Delegate GetGlobalStat1DelegatePointer;
#endregion
internal bool GetGlobalStat( string pchStatName, ref long pData )
internal bool GetGlobalStat1( string pchStatName, ref long pData )
{
return GetGlobalStatDelegatePointer( Self, pchStatName, ref pData );
return GetGlobalStat1DelegatePointer( Self, pchStatName, ref pData );
}
#region FunctionMeta
@ -536,13 +536,13 @@ internal bool GetGlobalStat2( string pchStatName, ref double pData )
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate int GetGlobalStatHistoryDelegate( IntPtr self, string pchStatName, [In,Out] long[] pData, uint cubData );
private GetGlobalStatHistoryDelegate GetGlobalStatHistoryDelegatePointer;
private delegate int GetGlobalStatHistory1Delegate( IntPtr self, string pchStatName, [In,Out] long[] pData, uint cubData );
private GetGlobalStatHistory1Delegate GetGlobalStatHistory1DelegatePointer;
#endregion
internal int GetGlobalStatHistory( string pchStatName, [In,Out] long[] pData, uint cubData )
internal int GetGlobalStatHistory1( string pchStatName, [In,Out] long[] pData, uint cubData )
{
return GetGlobalStatHistoryDelegatePointer( Self, pchStatName, pData, cubData );
return GetGlobalStatHistory1DelegatePointer( Self, pchStatName, pData, cubData );
}
#region FunctionMeta

View File

@ -45,7 +45,7 @@ public double GetGlobalFloat()
public long GetGlobalInt()
{
long val = 0;
SteamUserStats.Internal.GetGlobalStat( Name, ref val );
SteamUserStats.Internal.GetGlobalStat1( Name, ref val );
return val;
}
@ -56,7 +56,7 @@ public async Task<long[]> GetGlobalIntDays( int days )
var r = new long[days];
var rows = SteamUserStats.Internal.GetGlobalStatHistory( Name, r, (uint) r.Length );
var rows = SteamUserStats.Internal.GetGlobalStatHistory1( Name, r, (uint) r.Length );
if ( days != rows )
r = r.Take( rows ).ToArray();
@ -101,11 +101,11 @@ public int GetInt()
if ( UserId > 0 )
{
SteamUserStats.Internal.GetUserStat( UserId, Name, ref val );
SteamUserStats.Internal.GetUserStat1( UserId, Name, ref val );
}
else
{
SteamUserStats.Internal.GetStat( Name, ref val );
SteamUserStats.Internal.GetStat1( Name, ref val );
}
return val;
@ -114,7 +114,7 @@ public int GetInt()
public bool Set( int val )
{
LocalUserOnly();
return SteamUserStats.Internal.SetStat( Name, val );
return SteamUserStats.Internal.SetStat1( Name, val );
}
public bool Set( float val )

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Generator
@ -14,6 +15,7 @@ public class Class
public class Function
{
public string Name;
public string DuplicateName;
public Dictionary<string, string> Arguments = new Dictionary<string, string>();
public string ReturnType;
@ -51,24 +53,18 @@ internal Function AddFunction( string funcName, string returnType, string args )
public void PostProcess()
{
var LastName = "";
var DuplicateCount = 0;
var duplicateFunctions = Functions
.GroupBy( x => x.Name )
.Where( x => x.Count() > 1 );
for (int i=0; i< Functions.Count; i++ )
foreach ( var group in duplicateFunctions )
{
var ThisName = Functions[i].Name;
if ( Functions[i].Name == LastName)
var g = group.ToArray();
for ( int i=0; i< g.Count(); i++ )
{
DuplicateCount++;
Functions[i].Name += $"{DuplicateCount + 1}";
g[i].DuplicateName = g[i].Name;
g[i].Name = $"{g[i].Name}{i+1}";
}
else
{
DuplicateCount = 0;
}
LastName = ThisName;
}
}
}