Skip to content

Commit

Permalink
Update 24.02.11_b2144
Browse files Browse the repository at this point in the history
* fix error messages for incorrect reading of saved data
  • Loading branch information
BlackyBPG committed Feb 11, 2024
1 parent a91154c commit d291121
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions load.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
except ImportError:
config = dict()

APP_VERSION = "21.01.02_b1344"
APP_VERSION = "24.02.11_b2144"

CFG_DISTANCE = "JumpSpeed_distance"
CFG_JUMPS = "JumpSpeed_jumps"
Expand Down Expand Up @@ -73,24 +73,24 @@ def load(self):
"""
Load saved distance from config
"""
if config.getint(CFG_DESIGN):
self.appdesign = config.getint(CFG_DESIGN)
if config.get_int(CFG_DESIGN):
self.appdesign = config.get_int(CFG_DESIGN)
else:
self.appdesign = 0

saved = config.get(CFG_DISTANCE)
saved = config.get_str(CFG_DISTANCE)
if not saved:
self.saved_distance = 0.0
else:
self.saved_distance = float(saved)

savedJ = config.get(CFG_JUMPS)
savedJ = config.get_str(CFG_JUMPS)
if not savedJ:
self.saved_jumps = 0.0
else:
self.saved_jumps = float(savedJ)

savedT = config.get(CFG_TIME)
savedT = config.get_str(CFG_TIME)
if not savedT:
self.saved_time = 0.0
else:
Expand Down Expand Up @@ -189,7 +189,7 @@ def speed(self):
Get the jump speed in ly/hr
:return overall jump speed rate per hour:
"""
if self.trip_distance() > 0 and self.alljumps() > 0:
if self.trip_distance() > 0 and self.alljumps() > 0 and self.sincetime() > 0:
return (self.saved_distance + self.trip_distance()) / (self.saved_time + self.sincetime())
elif self.saved_distance > 0 and self.saved_time > 0:
return self.saved_distance / self.saved_time
Expand All @@ -201,7 +201,7 @@ def speednow(self):
Get the jump speed in ly/hr
:return jump speed rate for trip per hour:
"""
if self.trip_distance() > 0 and self.alljumps() > 0:
if self.trip_distance() > 0 and self.alljumps() > 0 and self.sincetime() > 0:
return self.trip_distance() / self.sincetime()
else:
return 0
Expand Down Expand Up @@ -250,7 +250,7 @@ def update_jumpspeed_dist(self):

def prefs_changed(cmdr, is_beta):
jumpspeed = this.jumpspeed
jumpspeed.appdesign = config.getint(CFG_DESIGN)
jumpspeed.appdesign = config.get_int(CFG_DESIGN)
jumpspeed.update_window()

def plugin_start():
Expand Down

0 comments on commit d291121

Please sign in to comment.