home · contact · privacy
Fix FOV floating point bugs by using fractions.Fraction for fractions.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 25 Jan 2019 02:44:35 +0000 (03:44 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 25 Jan 2019 02:44:35 +0000 (03:44 +0100)
server_/map_.py

index 6e14c5a2508736df66a487a9d551838d25727d5d..291130c4e8dc7999950cce539f90908ae6c0f5a7 100644 (file)
@@ -2,6 +2,7 @@ import sys
 sys.path.append('../')
 import game_common
 import server_.game
+import fractions
 
 
 class Map(game_common.Map):
@@ -170,7 +171,7 @@ class MapFovHex(MapHex):
                     self.shadow_cones += [cone]
 
         #print('DEBUG', yx)
-        step_size = (CIRCLE/6)/distance_to_center
+        step_size = fractions.Fraction(CIRCLE, 6) / distance_to_center
         number_steps = dir_i * distance_to_center + dir_progress
         left_arm = correct_arm(-(step_size/2) - step_size*number_steps)
         right_arm = correct_arm(left_arm - step_size)
@@ -288,7 +289,7 @@ class MapFovSquare(MapSquare):
                     self.shadow_cones += [cone]
 
         #print('DEBUG', yx)
-        step_size = (CIRCLE/4)/distance_to_center
+        step_size = fractions.Fraction(CIRCLE, 4) / distance_to_center
         number_steps = dir_i * distance_to_center + dir_progress
         left_arm = correct_arm(-(step_size/2) - step_size*number_steps)
         right_arm = correct_arm(left_arm - step_size)