Fix NaN display for FPS

This commit is contained in:
nsubiron 2019-01-31 17:23:45 +01:00
parent f1c41864ed
commit d43c73f780
2 changed files with 6 additions and 11 deletions

View File

@ -336,7 +336,7 @@ class HUD(object):
def on_world_tick(self, timestamp):
self._server_clock.tick()
self.server_fps = np.nan_to_num(self._server_clock.get_fps())
self.server_fps = self._server_clock.get_fps()
self.frame_number = timestamp.frame_count
self.simulation_time = timestamp.elapsed_seconds
@ -356,8 +356,8 @@ class HUD(object):
collision = [x / max_col for x in collision]
vehicles = world.world.get_actors().filter('vehicle.*')
self._info_text = [
'Server: % 16d FPS' % self.server_fps,
'Client: % 16d FPS' % clock.get_fps(),
'Server: % 16s FPS' % round(self.server_fps),
'Client: % 16s FPS' % round(clock.get_fps()),
'',
'Vehicle: % 20s' % get_actor_display_name(world.player, truncate=20),
'Map: % 20s' % world.world.map_name,

View File

@ -52,11 +52,6 @@ try:
except ImportError:
raise RuntimeError('cannot import pygame, make sure pygame package is installed')
try:
import numpy as np
except ImportError:
raise RuntimeError('cannot import numpy, make sure numpy package is installed')
# ==============================================================================
# -- Constants -----------------------------------------------------------------
# ==============================================================================
@ -824,10 +819,10 @@ class ModuleWorld(object):
else:
hero_mode_text = ['Hero Mode: OFF']
self.server_fps = np.nan_to_num(self.server_clock.get_fps())
self.server_fps = self.server_clock.get_fps()
module_info_text = [
'Server: % 16d FPS' % self.server_fps,
'Client: % 16d FPS' % clock.get_fps(),
'Server: % 16s FPS' % round(self.server_fps),
'Client: % 16s FPS' % round(clock.get_fps()),
'Map Name: %10s' % self.world.map_name,
]