diff --git a/Generator/CodeWriter/Constants.cs b/Generator/CodeWriter/Constants.cs index 253809c..8c4a271 100644 --- a/Generator/CodeWriter/Constants.cs +++ b/Generator/CodeWriter/Constants.cs @@ -10,21 +10,33 @@ namespace Generator { private void Constants() { - /* - StartBlock( "internal static class CallbackIdentifiers" ); - foreach ( var o in def.CallbackIds ) - { - WriteLine( $"public const int {o.Key} = {o.Value};" ); - } - EndBlock(); - StartBlock( "internal static class Defines" ); - foreach ( var o in def.Defines ) + foreach ( var o in def.Consts ) { - WriteLine( $"internal const string {o.Key} = \"{o.Value}\";" ); + var type = o.Type.Substring( "const ".Length ); + type = Cleanup.ConvertType( type ); + + var val = o.Val; + + // Don't need to ull in c# + if ( val.EndsWith( "ull" ) ) + val = val.Replace( "ull", "" ); + + val = val.Replace( "uint32", "uint" ); + val = val.Replace( "16U", "16" ); + val = val.Replace( "8U", "8" ); + + // we're not an actual typedef so can't cast like this + val = val.Replace( "( SteamItemInstanceID_t ) ~ 0", "~default(ulong)" ); + + // This is defined as 0xffffffff - which is too big for an int + // It seems like the loop around is required, so we just hard code it + if ( o.Name == "HSERVERQUERY_INVALID" && val == "0xffffffff" ) + val = "-1"; + + WriteLine( $"internal static readonly {type} {o.Name} = {val};" ); } EndBlock(); - */ } } } \ No newline at end of file