use Invariant culture for float parsing (workaround a mono bug)
This commit is contained in:
@@ -17,6 +17,7 @@ using OpenRA;
|
|||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace OpenRA.Editor
|
namespace OpenRA.Editor
|
||||||
{
|
{
|
||||||
@@ -401,7 +402,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
new LocationInit(new int2(loc % MapSize, loc / MapSize)),
|
new LocationInit(new int2(loc % MapSize, loc / MapSize)),
|
||||||
new OwnerInit(parts[0]),
|
new OwnerInit(parts[0]),
|
||||||
new HealthInit(float.Parse(parts[2])/256),
|
new HealthInit(float.Parse(parts[2], NumberFormatInfo.InvariantInfo)/256),
|
||||||
new FacingInit((section == "INFANTRY") ? int.Parse(parts[6]) : int.Parse(parts[4])),
|
new FacingInit((section == "INFANTRY") ? int.Parse(parts[6]) : int.Parse(parts[4])),
|
||||||
new ActorStanceInit(stance),
|
new ActorStanceInit(stance),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace OpenRA.FileFormats
|
namespace OpenRA.FileFormats
|
||||||
{
|
{
|
||||||
@@ -99,7 +100,7 @@ namespace OpenRA.FileFormats
|
|||||||
else if (fieldType == typeof(float))
|
else if (fieldType == typeof(float))
|
||||||
{
|
{
|
||||||
float res;
|
float res;
|
||||||
if (float.TryParse(x.Replace("%",""), out res))
|
if (float.TryParse(x.Replace("%",""), System.Globalization.NumberStyles.Any, NumberFormatInfo.InvariantInfo, out res))
|
||||||
return res * (x.Contains( '%' ) ? 0.01f : 1f);
|
return res * (x.Contains( '%' ) ? 0.01f : 1f);
|
||||||
return InvalidValueAction(x,fieldType, field);
|
return InvalidValueAction(x,fieldType, field);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA
|
|
||||||
{
|
|
||||||
class TraitCreator
|
|
||||||
{
|
|
||||||
public static object Create( string traitName, World world, Actor actor, ITraitInfo info, TypeDictionary init )
|
|
||||||
{
|
|
||||||
var argsDict = new Dictionary<string, object>
|
|
||||||
{
|
|
||||||
{ "world", world },
|
|
||||||
{ "self", actor },
|
|
||||||
{ "initDict", init },
|
|
||||||
{ "init", new ActorInitializer( actor, init ) },
|
|
||||||
{ "info", info },
|
|
||||||
};
|
|
||||||
return Game.modData.ObjectCreator.CreateObject<object>( traitName, argsDict );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user