Skip to content

Commit

Permalink
Merge pull request #356 from stefanx111/fix-invariant
Browse files Browse the repository at this point in the history
fix float parsing to use invariant culture
  • Loading branch information
daffyyyy authored Nov 19, 2024
2 parents c418de1 + a89593f commit eae091b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions WeaponSynchronization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using MySqlConnector;
using System.Collections.Concurrent;
using CounterStrikeSharp.API.Modules.Utils;
using System.Globalization;

namespace WeaponPaints;

Expand Down Expand Up @@ -197,9 +198,9 @@ private void GetWeaponPaintsFromDatabase(PlayerInfo? player, MySqlConnection con

if (keyChainParts!.Length == 5 &&
uint.TryParse(keyChainParts[0], out uint keyChainId) &&
float.TryParse(keyChainParts[1], out float keyChainOffsetX) &&
float.TryParse(keyChainParts[2], out float keyChainOffsetY) &&
float.TryParse(keyChainParts[3], out float keyChainOffsetZ) &&
float.TryParse(keyChainParts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out float keyChainOffsetX) &&
float.TryParse(keyChainParts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out float keyChainOffsetY) &&
float.TryParse(keyChainParts[3], NumberStyles.Float, CultureInfo.InvariantCulture, out float keyChainOffsetZ) &&
uint.TryParse(keyChainParts[4], out uint keyChainSeed))
{
// Successfully parsed the values
Expand Down Expand Up @@ -246,11 +247,11 @@ private void GetWeaponPaintsFromDatabase(PlayerInfo? player, MySqlConnection con
if (parts.Length != 7 ||
!uint.TryParse(parts[0], out uint stickerId) ||
!uint.TryParse(parts[1], out uint stickerSchema) ||
!float.TryParse(parts[2], out float stickerOffsetX) ||
!float.TryParse(parts[3], out float stickerOffsetY) ||
!float.TryParse(parts[4], out float stickerWear) ||
!float.TryParse(parts[5], out float stickerScale) ||
!float.TryParse(parts[6], out float stickerRotation)) continue;
!float.TryParse(parts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerOffsetX) ||
!float.TryParse(parts[3], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerOffsetY) ||
!float.TryParse(parts[4], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerWear) ||
!float.TryParse(parts[5], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerScale) ||
!float.TryParse(parts[6], NumberStyles.Float, CultureInfo.InvariantCulture, out float stickerRotation)) continue;

StickerInfo stickerInfo = new StickerInfo
{
Expand Down

0 comments on commit eae091b

Please sign in to comment.