Fix parsing floats (#7)
This commit is contained in:
@@ -26,6 +26,7 @@ using Game.Maps;
|
|||||||
using Game.Network.Packets;
|
using Game.Network.Packets;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Game.Chat
|
namespace Game.Chat
|
||||||
@@ -892,7 +893,7 @@ namespace Game.Chat
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!float.TryParse(valueStr, out float value))
|
if (!float.TryParse(valueStr, NumberStyles.Float, CultureInfo.InvariantCulture, out float value))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
target.SetFloatValue(field, value);
|
target.SetFloatValue(field, value);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ using Game.Entities;
|
|||||||
using Game.Maps;
|
using Game.Maps;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Game.Chat
|
namespace Game.Chat
|
||||||
@@ -129,13 +130,13 @@ namespace Game.Chat
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!float.TryParse(toX, out x))
|
if (!float.TryParse(toX, NumberStyles.Float, CultureInfo.InvariantCulture, out x))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!float.TryParse(toY, out y))
|
if (!float.TryParse(toY, NumberStyles.Float, CultureInfo.InvariantCulture, out y))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!float.TryParse(toZ, out z))
|
if (!float.TryParse(toZ, NumberStyles.Float, CultureInfo.InvariantCulture, out z))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!GridDefines.IsValidMapCoord(obj.GetMapId(), x, y, z))
|
if (!GridDefines.IsValidMapCoord(obj.GetMapId(), x, y, z))
|
||||||
@@ -337,19 +338,19 @@ namespace Game.Chat
|
|||||||
float oz = 0.0f, oy = 0.0f, ox = 0.0f;
|
float oz = 0.0f, oy = 0.0f, ox = 0.0f;
|
||||||
if (!orientation.IsEmpty())
|
if (!orientation.IsEmpty())
|
||||||
{
|
{
|
||||||
if (!float.TryParse(orientation, out oz))
|
if (!float.TryParse(orientation, NumberStyles.Float, CultureInfo.InvariantCulture, out oz))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
orientation = args.NextString();
|
orientation = args.NextString();
|
||||||
if (!orientation.IsEmpty())
|
if (!orientation.IsEmpty())
|
||||||
{
|
{
|
||||||
if (!float.TryParse(orientation, out oy))
|
if (!float.TryParse(orientation, NumberStyles.Float, CultureInfo.InvariantCulture, out oy))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
orientation = args.NextString();
|
orientation = args.NextString();
|
||||||
if (!orientation.IsEmpty())
|
if (!orientation.IsEmpty())
|
||||||
{
|
{
|
||||||
if (!float.TryParse(orientation, out ox))
|
if (!float.TryParse(orientation, NumberStyles.Float, CultureInfo.InvariantCulture, out ox))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ using Game.SupportSystem;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Game.Chat.Commands
|
namespace Game.Chat.Commands
|
||||||
{
|
{
|
||||||
@@ -156,10 +157,10 @@ namespace Game.Chat.Commands
|
|||||||
|
|
||||||
Player player = handler.GetSession().GetPlayer();
|
Player player = handler.GetSession().GetPlayer();
|
||||||
|
|
||||||
if (!float.TryParse(args.NextString(), out float gridX))
|
if (!float.TryParse(args.NextString(), NumberStyles.Float, CultureInfo.InvariantCulture, out float gridX))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!float.TryParse(args.NextString(), out float gridY))
|
if (!float.TryParse(args.NextString(), NumberStyles.Float, CultureInfo.InvariantCulture, out float gridY))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!uint.TryParse(args.NextString(), out uint mapId))
|
if (!uint.TryParse(args.NextString(), out uint mapId))
|
||||||
@@ -402,10 +403,10 @@ namespace Game.Chat.Commands
|
|||||||
|
|
||||||
Player player = handler.GetSession().GetPlayer();
|
Player player = handler.GetSession().GetPlayer();
|
||||||
|
|
||||||
if (!float.TryParse(args.NextString(), out float x))
|
if (!float.TryParse(args.NextString(), NumberStyles.Float, CultureInfo.InvariantCulture, out float x))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!float.TryParse(args.NextString(),out float y))
|
if (!float.TryParse(args.NextString(), NumberStyles.Float, CultureInfo.InvariantCulture, out float y))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// prevent accept wrong numeric args
|
// prevent accept wrong numeric args
|
||||||
@@ -468,10 +469,10 @@ namespace Game.Chat.Commands
|
|||||||
|
|
||||||
Player player = handler.GetSession().GetPlayer();
|
Player player = handler.GetSession().GetPlayer();
|
||||||
|
|
||||||
if (!float.TryParse(args.NextString(), out float x))
|
if (!float.TryParse( args.NextString(), NumberStyles.Float, CultureInfo.InvariantCulture, out float x))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!float.TryParse(args.NextString(), out float y))
|
if (!float.TryParse(args.NextString(), NumberStyles.Float, CultureInfo.InvariantCulture, out float y))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
string goZ = args.NextString();
|
string goZ = args.NextString();
|
||||||
@@ -479,13 +480,13 @@ namespace Game.Chat.Commands
|
|||||||
if (!uint.TryParse(args.NextString(), out uint mapId))
|
if (!uint.TryParse(args.NextString(), out uint mapId))
|
||||||
mapId = player.GetMapId();
|
mapId = player.GetMapId();
|
||||||
|
|
||||||
if (!float.TryParse(args.NextString(), out float ort))
|
if (!float.TryParse(args.NextString(), NumberStyles.Float, CultureInfo.InvariantCulture, out float ort))
|
||||||
ort = player.GetOrientation();
|
ort = player.GetOrientation();
|
||||||
|
|
||||||
float z;
|
float z;
|
||||||
if (!goZ.IsEmpty())
|
if (!goZ.IsEmpty())
|
||||||
{
|
{
|
||||||
if (!float.TryParse(goZ, out z))
|
if (!float.TryParse(goZ, NumberStyles.Float, CultureInfo.InvariantCulture, out z))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!GridDefines.IsValidMapCoord(mapId, x, y, z))
|
if (!GridDefines.IsValidMapCoord(mapId, x, y, z))
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ using Game.Network.Packets;
|
|||||||
using Game.Spells;
|
using Game.Spells;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Game.Chat
|
namespace Game.Chat
|
||||||
@@ -1274,7 +1275,7 @@ namespace Game.Chat
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
//0 to 1, sending -1 is instand good weather
|
//0 to 1, sending -1 is instand good weather
|
||||||
if (!float.TryParse(args.NextString(), out float grade))
|
if (!float.TryParse(args.NextString(), NumberStyles.Float, CultureInfo.InvariantCulture, out float grade))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player player = handler.GetSession().GetPlayer();
|
Player player = handler.GetSession().GetPlayer();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using Framework.IO;
|
|||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Maps;
|
using Game.Maps;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Game.Chat.Commands
|
namespace Game.Chat.Commands
|
||||||
{
|
{
|
||||||
@@ -284,7 +285,7 @@ namespace Game.Chat.Commands
|
|||||||
|
|
||||||
if (arg_string == "posx")
|
if (arg_string == "posx")
|
||||||
{
|
{
|
||||||
if (!float.TryParse(arg_3, out float arg3))
|
if (!float.TryParse(arg_3, NumberStyles.Float, CultureInfo.InvariantCulture, out float arg3))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_X);
|
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_X);
|
||||||
@@ -297,7 +298,7 @@ namespace Game.Chat.Commands
|
|||||||
}
|
}
|
||||||
else if (arg_string == "posy")
|
else if (arg_string == "posy")
|
||||||
{
|
{
|
||||||
if (!float.TryParse(arg_3, out float arg3))
|
if (!float.TryParse(arg_3, NumberStyles.Float, CultureInfo.InvariantCulture, out float arg3))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_Y);
|
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_Y);
|
||||||
@@ -310,7 +311,7 @@ namespace Game.Chat.Commands
|
|||||||
}
|
}
|
||||||
else if (arg_string == "posz")
|
else if (arg_string == "posz")
|
||||||
{
|
{
|
||||||
if (!float.TryParse(arg_3, out float arg3))
|
if (!float.TryParse(arg_3, NumberStyles.Float, CultureInfo.InvariantCulture, out float arg3))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_Z);
|
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_Z);
|
||||||
@@ -323,7 +324,7 @@ namespace Game.Chat.Commands
|
|||||||
}
|
}
|
||||||
else if (arg_string == "orientation")
|
else if (arg_string == "orientation")
|
||||||
{
|
{
|
||||||
if (!float.TryParse(arg_3, out float arg3))
|
if (!float.TryParse(arg_3, NumberStyles.Float, CultureInfo.InvariantCulture, out float arg3))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_O);
|
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_O);
|
||||||
|
|||||||
Reference in New Issue
Block a user