Skip to content

Commit

Permalink
Fix situation where incoming tick is older than current forced tick. C…
Browse files Browse the repository at this point in the history
…loses #133.
  • Loading branch information
aussig committed Sep 4, 2023
1 parent 2ee9b28 commit 88b891b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

### Bug Fixes:

* Some Orthrus kills were not being tallied because the bond value logged was 40m instead of the previous 25m. We can only detect the type of Thargoid via the bond value logged by the game, so BGS-Tally will now tally an Orthrus for both kill values.#
* Some Orthrus kills were not being tallied because the bond value logged was 40m instead of the previous 25m. We can only detect the type of Thargoid via the bond value logged by the game, so BGS-Tally will now tally an Orthrus for both kill values.
* Trade purchase, sale and profit was not being logged if you previously disembarked from your ship on foot, took a taxi or dropship somewhere, returned to your ship and then traded.
* If you did a Force Tick but then an automatic tick was detected that had an earlier tick time, this could cause BGS-Tally to get confused, post more than once to Discord and if you also restart EDMC you could lose activity. Now in this situation, your current activity inherits the older incoming tick time.

### API Changes ([v1.2](https://studio-ws.apicur.io/sharing/281a84ad-dca9-42da-a08b-84e4b9af1b7e)):

Expand Down
31 changes: 19 additions & 12 deletions bgstally/activitymanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,26 @@ def get_previous_activities(self):

def new_tick(self, tick: Tick):
"""
New tick detected, duplicate the current Activity object
New tick detected, duplicate the current Activity object or update the current tick time.
"""
# Note Activity uses a customised __deepcopy__ that only deep copies data, not class instances.
new_activity = deepcopy(self.current_activity)
new_activity.tick_id = tick.tick_id
new_activity.tick_time = tick.tick_time
new_activity.discord_bgs_messageid = None
new_activity.discord_tw_messageid = None
new_activity.discord_notes = ""
new_activity.clear_activity(self.bgstally.mission_log)
self.activity_data.append(new_activity)
self.activity_data.sort(reverse=True)
self.current_activity = new_activity

if tick.tick_time < self.current_activity.tick_time:
# An inbound tick is older than the current tick. The only valid situation for this is if the user previously
# did a Force Tick and an earlier tick was later detected. Just set the current tick time to the received tick time.
self.current_activity.tick_time = tick.tick_time
else:
# An inbound tick is newer than the current tick. Create a new Activity object.
# Note Activity uses a customised __deepcopy__ that only deep copies data, not class instances.
new_activity:Activity = deepcopy(self.current_activity)
new_activity.tick_id = tick.tick_id
new_activity.tick_time = tick.tick_time
new_activity.discord_bgs_messageid = None
new_activity.discord_tw_messageid = None
new_activity.discord_notes = ""
new_activity.clear_activity(self.bgstally.mission_log)
self.activity_data.append(new_activity)
self.activity_data.sort(reverse=True)
self.current_activity = new_activity


def _load(self):
Expand Down

0 comments on commit 88b891b

Please sign in to comment.