Skip to content

Commit

Permalink
1.3.3 update for Pi/-Pi Bearing Rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDraco committed Jul 16, 2021
1 parent d1a7052 commit bb94e1f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v1.3.3
- Correct 'Bearing' sign flipping due to floating point math when Bearing == 180 degrees (Pi/-Pi Radians)

# v1.3.2
- Bugfix in the 1.3.2 EOL whitespace handling

Expand Down
2 changes: 1 addition & 1 deletion nwnt.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "1.3.2"
version = "1.3.3"
author = "WilliamDraco"
description = "GFF <-> NWNT Converter (NeverWinter Nights Text)"
license = "MIT"
Expand Down
6 changes: 5 additions & 1 deletion src/nwnt/gffnwnt.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ proc nwntFromGffStruct*(s: GffStruct, floatPrecision: int, namePrefix: string =
if s of GffRoot:
result.add(["data_type", "", ($s.GffRoot.fileType).strip()])

let piCheck = formatFloat(-3.141592653589793, ffDecimal, floatPrecision)

for lable, gffValue in s.sortedPairs:
let
name = namePrefix & lable
Expand All @@ -38,7 +40,9 @@ proc nwntFromGffStruct*(s: GffStruct, floatPrecision: int, namePrefix: string =
of GffFieldKind.Short: value = $gffValue.getValue(GffShort).int
of GffFieldKind.Dword: value = $gffValue.getValue(GffDword).int
of GffFieldKind.Int: value = $gffValue.getValue(GffInt).int
of GffFieldKind.Float: value = $gffValue.getValue(GffFloat).float.formatFloat(ffDecimal, floatPrecision)
of GffFieldKind.Float:
value = gffValue.getValue(GffFloat).float.formatFloat(ffDecimal, floatPrecision)
if lable == "Bearing" and value == piCheck: value = value[1..^1]
of GffFieldKind.Dword64: value = $gffValue.getValue(GffDword64).int64
of GffFieldKind.Int64: value = $gffValue.getValue(GffInt64).int64
of GffFieldKind.Double: value = $gffValue.getValue(GffDouble).float64.formatFloat(ffDecimal, floatPrecision)
Expand Down

0 comments on commit bb94e1f

Please sign in to comment.