From 645c27180f907389d3acd3b3a15e17aac4c10929 Mon Sep 17 00:00:00 2001 From: Shinrin Ouja Moriking Date: Thu, 2 Mar 2023 03:10:49 -0600 Subject: [PATCH] Better support for Pop'n music Omnimix v2 omnimix songs are now saved in a different version --- README.md | 4 ++-- bemani/api/objects/catalog.py | 1 + bemani/api/objects/records.py | 1 + bemani/api/objects/statistics.py | 1 + bemani/backend/popn/base.py | 24 +++++++++++++++++++----- bemani/frontend/popn/endpoints.py | 30 +++++++++++++++--------------- bemani/utils/read.py | 9 ++++++--- 7 files changed, 45 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 50a05ad..153a2e2 100644 --- a/README.md +++ b/README.md @@ -440,13 +440,13 @@ command once for every version, giving the correct DLL file: For add songs of a XML from omnimix v2, run a command like this: ``` -./read --config config/server.yaml --series pnm --version 22 --bin popn22.dll --xml your_songs_db.xml +./read --config config/server.yaml --series pnm --version omni-24 --bin popn24.dll --xml your_songs_db.xml ``` If you have more than one XML you want to add, you can run this command with a folder with all your XML files: ``` -./read --config config/server.yaml --series pnm --version 22 --bin popn22.dll --folder my_path_with_xmls +./read --config config/server.yaml --series pnm --version omni-24 --bin popn24.dll --folder my_path_with_xmls ``` ### Jubeat diff --git a/bemani/api/objects/catalog.py b/bemani/api/objects/catalog.py index dcd82eb..e32f90d 100644 --- a/bemani/api/objects/catalog.py +++ b/bemani/api/objects/catalog.py @@ -219,6 +219,7 @@ class CatalogObject(BaseObject): GameConstants.IIDX, GameConstants.MUSECA, GameConstants.JUBEAT, + GameConstants.POPN_MUSIC, }: if self.omnimix: return self.version + DBConstants.OMNIMIX_VERSION_BUMP diff --git a/bemani/api/objects/records.py b/bemani/api/objects/records.py index 33372dd..57369f8 100644 --- a/bemani/api/objects/records.py +++ b/bemani/api/objects/records.py @@ -226,6 +226,7 @@ class RecordsObject(BaseObject): GameConstants.IIDX, GameConstants.MUSECA, GameConstants.JUBEAT, + GameConstants.POPN_MUSIC, }: if self.omnimix: return self.version + DBConstants.OMNIMIX_VERSION_BUMP diff --git a/bemani/api/objects/statistics.py b/bemani/api/objects/statistics.py index e389cfa..417ce95 100644 --- a/bemani/api/objects/statistics.py +++ b/bemani/api/objects/statistics.py @@ -30,6 +30,7 @@ class StatisticsObject(BaseObject): GameConstants.IIDX, GameConstants.MUSECA, GameConstants.JUBEAT, + GameConstants.POPN_MUSIC, }: if self.omnimix: return self.version + DBConstants.OMNIMIX_VERSION_BUMP diff --git a/bemani/backend/popn/base.py b/bemani/backend/popn/base.py index 9c01fe8..9fd0f87 100644 --- a/bemani/backend/popn/base.py +++ b/bemani/backend/popn/base.py @@ -11,8 +11,9 @@ from bemani.common import ( GameConstants, DBConstants, BroadcastConstants, + Model, ) -from bemani.data import UserID, Achievement, ScoreSaveException +from bemani.data import UserID, Achievement, ScoreSaveException, Config, Data from bemani.protocol import Node @@ -68,6 +69,19 @@ class PopnMusicBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): # properly. supports_expired_profiles: bool = False + def __init__(self, data: Data, config: Config, model: Model) -> None: + super().__init__(data, config, model) + if model.rev == "X": + self.omnimix = True + else: + self.omnimix = False + + @property + def music_version(self) -> int: + if self.omnimix: + return DBConstants.OMNIMIX_VERSION_BUMP + self.version + return self.version + def previous_version(self) -> Optional["PopnMusicBase"]: """ Returns the previous version of the game, based on this game. Should @@ -229,7 +243,7 @@ class PopnMusicBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): oldscore = self.data.local.music.get_score( self.game, - self.version, + self.music_version, userid, songid, chart, @@ -283,7 +297,7 @@ class PopnMusicBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): # Write the new score back self.data.local.music.put_score( self.game, - self.version, + self.music_version, userid, songid, chart, @@ -298,7 +312,7 @@ class PopnMusicBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): # Save the history of this score too self.data.local.music.put_attempt( self.game, - self.version, + self.music_version, userid, songid, chart, @@ -327,7 +341,7 @@ class PopnMusicBase(CoreHandler, CardManagerHandler, PASELIHandler, Base): ) -> None: # Generate scorecard profile = self.get_profile(userid) - song = self.data.local.music.get_song(self.game, self.version, songid, chart) + song = self.data.local.music.get_song(self.game, self.music_version, songid, chart) card_medal = { self.PLAY_MEDAL_CIRCLE_FAILED: "Failed", diff --git a/bemani/frontend/popn/endpoints.py b/bemani/frontend/popn/endpoints.py index e9e1bd1..745ad7f 100644 --- a/bemani/frontend/popn/endpoints.py +++ b/bemani/frontend/popn/endpoints.py @@ -2,8 +2,7 @@ import re from typing import Any, Dict from flask import Blueprint, request, Response, url_for, abort - -from bemani.common import ID, GameConstants, VersionConstants +from bemani.common import ID, GameConstants, VersionConstants, DBConstants from bemani.data import UserID from bemani.frontend.app import loginrequired, jsonify, render_react from bemani.frontend.popn.popn import PopnMusicFrontend @@ -187,19 +186,20 @@ def viewtopscores(musicid: int) -> Response: difficulties = [0, 0, 0, 0] for version in versions: - for chart in [0, 1, 2, 3]: - details = g.data.local.music.get_song( - GameConstants.POPN_MUSIC, version, musicid, chart - ) - if details is not None: - if name is None: - name = details.name - if artist is None: - artist = details.artist - if genre is None: - genre = details.genre - if difficulties[chart] == 0: - difficulties[chart] = details.data.get_int("difficulty") + for omniadd in [0, DBConstants.OMNIMIX_VERSION_BUMP]: + for chart in [0, 1, 2, 3]: + details = g.data.local.music.get_song( + GameConstants.POPN_MUSIC, version + omniadd, musicid, chart + ) + if details is not None: + if name is None: + name = details.name + if artist is None: + artist = details.artist + if genre is None: + genre = details.genre + if difficulties[chart] == 0: + difficulties[chart] = details.data.get_int("difficulty") if name is None: # Not a real song! diff --git a/bemani/utils/read.py b/bemani/utils/read.py index 381eef9..df77550 100644 --- a/bemani/utils/read.py +++ b/bemani/utils/read.py @@ -398,6 +398,9 @@ class ImportPopn(ImportBase): "24": VersionConstants.POPN_MUSIC_USANEKO, "25": VersionConstants.POPN_MUSIC_PEACE, "26": VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES, + "omni-24": VersionConstants.POPN_MUSIC_USANEKO + DBConstants.OMNIMIX_VERSION_BUMP, #Omnimix v2 only works for 24 - 26 + "omni-25": VersionConstants.POPN_MUSIC_PEACE + DBConstants.OMNIMIX_VERSION_BUMP , + "omni-26": VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES + DBConstants.OMNIMIX_VERSION_BUMP, }.get(version, -1) if actual_version == VersionConstants.POPN_MUSIC_TUNE_STREET: @@ -990,7 +993,7 @@ class ImportPopn(ImportBase): mask & 0x4000000 > 0, # Battle hyper chart bit ) - elif self.version == VersionConstants.POPN_MUSIC_USANEKO: + elif self.version == VersionConstants.POPN_MUSIC_USANEKO or self.version == (VersionConstants.POPN_MUSIC_USANEKO + DBConstants.OMNIMIX_VERSION_BUMP): # Based on M39:J:A:A:2018101500 # Normal offset for music DB, size @@ -1080,7 +1083,7 @@ class ImportPopn(ImportBase): mask & 0x4000000 > 0, # Battle hyper chart bit ) - elif self.version == VersionConstants.POPN_MUSIC_PEACE: + elif self.version == VersionConstants.POPN_MUSIC_PEACE or self.version == (VersionConstants.POPN_MUSIC_PEACE + DBConstants.OMNIMIX_VERSION_BUMP): # Based on M39:J:A:A:2020092800 # Normal offset for music DB, size @@ -1170,7 +1173,7 @@ class ImportPopn(ImportBase): mask & 0x4000000 > 0, # Battle hyper chart bit ) - elif self.version == VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES: + elif self.version == VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES or self.version == (VersionConstants.POPN_MUSIC_KAIMEI_RIDDLES + DBConstants.OMNIMIX_VERSION_BUMP): # Based on M39:J:A:A:2022061300 # Normal offset for music DB, size