From 8ddccb6e5601f8df54f9cbc4c376ad76aee2fe78 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 25 Jan 2019 03:44:35 +0100 Subject: [PATCH] Fix FOV floating point bugs by using fractions.Fraction for fractions. --- server_/map_.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server_/map_.py b/server_/map_.py index 6e14c5a..291130c 100644 --- a/server_/map_.py +++ b/server_/map_.py @@ -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) -- 2.30.2