mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-02-03 09:10:41 +03:00
Allow & ignore errors when parsing exchange string
This commit is contained in:
parent
5cef85adb4
commit
74ef4d49ad
@ -238,15 +238,28 @@ namespace Facepunch.Steamworks
|
|||||||
var i = new Ingredient();
|
var i = new Ingredient();
|
||||||
i.Count = 1;
|
i.Count = 1;
|
||||||
|
|
||||||
if ( part.Contains( 'x' ) )
|
try
|
||||||
{
|
{
|
||||||
var idx = part.IndexOf( 'x' );
|
|
||||||
i.Count = int.Parse( part.Substring( idx + 1 ) );
|
|
||||||
part = part.Substring( 0, idx );
|
|
||||||
}
|
|
||||||
|
|
||||||
i.DefinitionId = int.Parse( part );
|
if ( part.Contains( 'x' ) )
|
||||||
i.Definition = definitions.FirstOrDefault( x => x.Id == i.DefinitionId );
|
{
|
||||||
|
var idx = part.IndexOf( 'x' );
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
if ( int.TryParse( part.Substring( idx + 1 ), out count ) )
|
||||||
|
i.Count = count;
|
||||||
|
|
||||||
|
part = part.Substring( 0, idx );
|
||||||
|
}
|
||||||
|
|
||||||
|
i.DefinitionId = int.Parse( part );
|
||||||
|
i.Definition = definitions.FirstOrDefault( x => x.Id == i.DefinitionId );
|
||||||
|
|
||||||
|
}
|
||||||
|
catch ( System.Exception )
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -268,7 +281,7 @@ namespace Facepunch.Steamworks
|
|||||||
r.Result = Result;
|
r.Result = Result;
|
||||||
var parts = part.Split( new[] { ',' }, StringSplitOptions.RemoveEmptyEntries );
|
var parts = part.Split( new[] { ',' }, StringSplitOptions.RemoveEmptyEntries );
|
||||||
|
|
||||||
r.Ingredients = parts.Select( x => Ingredient.FromString( x, definitions ) ).ToArray();
|
r.Ingredients = parts.Select( x => Ingredient.FromString( x, definitions ) ).Where( x => x.DefinitionId != 0 ).ToArray();
|
||||||
|
|
||||||
foreach ( var i in r.Ingredients )
|
foreach ( var i in r.Ingredients )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user