diff --git a/bemani/backend/danevo/danevo.py b/bemani/backend/danevo/danevo.py index 41d4721..2731a5d 100644 --- a/bemani/backend/danevo/danevo.py +++ b/bemani/backend/danevo/danevo.py @@ -84,6 +84,8 @@ class DanceEvolution( DATA03_FIRST_HIGH_SCORE_OFFSET: Final[int] = 14 DATA03_SECOND_SONG_OFFSET: Final[int] = 15 DATA03_SECOND_HIGH_SCORE_OFFSET: Final[int] = 16 + DATA03_THIRD_SONG_OFFSET: Final[int] = 17 + DATA03_THIRD_HIGH_SCORE_OFFSET: Final[int] = 18 DATA04_TOTAL_SCORE_EARNED_OFFSET: Final[int] = 9 @@ -390,14 +392,22 @@ class DanceEvolution( if "DATA03" in usergamedata: strdatalist = usergamedata["DATA03"]["strdata"].split(b",") + # First two are represented in the hex section. first_song_played = int(strdatalist[self.DATA03_FIRST_SONG_OFFSET].decode("shift-jis"), 16) second_song_played = int(strdatalist[self.DATA03_SECOND_SONG_OFFSET].decode("shift-jis"), 16) first_song_scored = int(strdatalist[self.DATA03_FIRST_HIGH_SCORE_OFFSET].decode("shift-jis"), 16) second_song_scored = int(strdatalist[self.DATA03_SECOND_HIGH_SCORE_OFFSET].decode("shift-jis"), 16) + # They really just stuck this in as floats. I couldn't make this up. + third_song_played = int(strdatalist[self.DATA03_THIRD_SONG_OFFSET].decode("shift-jis").split(".")[0]) + third_song_scored = int( + strdatalist[self.DATA03_THIRD_HIGH_SCORE_OFFSET].decode("shift-jis").split(".")[0] + ) + for played, scored in [ (first_song_played, first_song_scored), (second_song_played, second_song_scored), + (third_song_played, third_song_scored), ]: if played not in valid_ids: # Game might be set to 1 song. diff --git a/bemani/client/danevo/danevo.py b/bemani/client/danevo/danevo.py index ca0602e..92c983a 100644 --- a/bemani/client/danevo/danevo.py +++ b/bemani/client/danevo/danevo.py @@ -442,7 +442,7 @@ class DanceEvolutionClient(BaseClient): } def verify_scores_send(self, ref_id: str, name: str, scores: List[Dict[str, int]]) -> None: - if len(scores) > 2: + if len(scores) > 3: raise Exception("DanEvo can only save two scores at once!") # This is identical to usergamedata_send, but the function was getting out of hand. @@ -486,8 +486,11 @@ class DanceEvolutionClient(BaseClient): elif offset == 1: profiledata["DATA03"][15] = _to_hex(sid) profiledata["DATA03"][16] = _to_hex(score["points"]) + elif offset == 2: + profiledata["DATA03"][17] = str(float(sid)).encode("shift-jis") + profiledata["DATA03"][18] = str(float(score["points"])).encode("shift-jis") else: - raise Exception("Logic error, can't save more than two scores!") + raise Exception("Logic error, can't save more than three scores!") # Make binary data blobs. blobs: Dict[int, bytes] = {} @@ -779,7 +782,7 @@ class DanceEvolutionClient(BaseClient): }, ] - scorechunks = [dummyscores[x : (x + 2)] for x in range(0, len(dummyscores), 2)] + scorechunks = [dummyscores[x : (x + 3)] for x in range(0, len(dummyscores), 3)] for chunk in scorechunks: self.verify_scores_send(ref_id, self.NAME1, chunk)