diff --git a/d2common/math.go b/d2common/math.go index eff88a44..d6b10b54 100644 --- a/d2common/math.go +++ b/d2common/math.go @@ -108,19 +108,14 @@ func AdjustWithRemainder(sourceValue, adjustment, targetvalue float64) (newValue finalValue := sourceValue + adjustment if !adjustNegative { if finalValue > targetvalue { - diff := finalValue - targetvalue // RoundToDecial(finalValue-targetvalue, 6) + diff := finalValue - targetvalue return targetvalue, diff } return finalValue, 0 } if finalValue < targetvalue { - return targetvalue, RoundToDecial(finalValue-targetvalue, 6) + return targetvalue, finalValue - targetvalue } return finalValue, 0 } - -func RoundToDecial(f float64, d int) float64 { - digits := float64(math.Pow10(d)) - return math.Trunc(f*digits) / digits -} diff --git a/d2common/math_test.go b/d2common/math_test.go deleted file mode 100644 index 1abe1a42..00000000 --- a/d2common/math_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package d2common - -import ( - "testing" -) - -type TestRecord struct { - source, adjust, max, expectedResult, expectedRemain float64 -} - -func TestSomething(t *testing.T) { - var testValues = []TestRecord{ - {100, 10, 100.2, 100.2, 9.8}, - } - for _, test := range testValues { - res, remain := AdjustWithRemainder(test.source, test.adjust, test.max) - if res != test.expectedResult { - t.Errorf("Expected result of %f but got %f", test.expectedResult, res) - } - if remain != test.expectedRemain { - t.Errorf("Expected result of %f but got %f", test.expectedRemain, remain) - } - } - -} diff --git a/d2core/d2map/map_entity.go b/d2core/d2map/map_entity.go index e6d77da7..4a518756 100644 --- a/d2core/d2map/map_entity.go +++ b/d2core/d2map/map_entity.go @@ -75,9 +75,7 @@ func (m *mapEntity) Step(tickTime float64) { } stepX, stepY := m.getStepLength(tickTime) - looped := false for { - looped = looped if d2common.AlmostEqual(m.LocationX-m.TargetX, 0, 0.0001) { stepX = 0 } @@ -114,7 +112,6 @@ func (m *mapEntity) Step(tickTime float64) { if stepX == 0 && stepY == 0 { break } - looped = true } }