From 4f64cc7e08063c07cbb84b0a356dd1a16a3b34af Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Fri, 3 Sep 2021 04:34:51 +0000 Subject: [PATCH] Fix core state machine for cards so Fantasia will present a profile migration. --- bemani/backend/core/cardmng.py | 30 ++++++++++++++++++++---------- bemani/client/base.py | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/bemani/backend/core/cardmng.py b/bemani/backend/core/cardmng.py index a8b1016..c3fd896 100644 --- a/bemani/backend/core/cardmng.py +++ b/bemani/backend/core/cardmng.py @@ -35,29 +35,39 @@ class CardManagerHandler(Base): root.set_attribute('status', str(Status.NOT_REGISTERED)) return root - # Special handling for looking up whether the previous game's profile existed + # Special handling for looking up whether the previous game's profile existed. If we + # don't do this then some games won't present the user with a migration. bound = self.has_profile(userid) - expired = False if bound is False: if modelstring is not None: model = Model.from_modelstring(modelstring) oldgame = Base.create(self.data, self.config, model, self.model) - if oldgame is None: - bound = False - else: + if oldgame is not None: bound = oldgame.has_profile(userid) - expired = True refid = self.data.local.user.get_refid(self.game, self.version, userid) paseli_enabled = self.supports_paseli() and self.config.paseli.enabled + newflag = self.data.remote.user.get_any_profile(self.game, self.version, userid) is None root = Node.void('cardmng') root.set_attribute('refid', refid) root.set_attribute('dataid', refid) - root.set_attribute('newflag', '1') # Always seems to be set to 1 - root.set_attribute('binded', '1' if bound else '0') # Whether we've bound to this version of the game or not - root.set_attribute('expired', '1' if expired else '0') # Whether we're expired - root.set_attribute('ecflag', '1' if paseli_enabled else '0') # Whether to allow paseli + + # Unsure what this does, but it appears not to matter so we set it to my best guess. + root.set_attribute('newflag', '1' if newflag else '0') + + # Whether we've bound a profile to this refid/dataid or not. This includes current profiles and any + # older game profiles that might exist that we should do a conversion from. + root.set_attribute('binded', '1' if bound else '0') + + # Whether this version of the profile is expired (was converted to newer version). We support forwards + # and backwards compatibility so we always set this to 0. + root.set_attribute('expired', '0') + + # Whether to allow paseli, as enabled by the operator and arcade owner. + root.set_attribute('ecflag', '1' if paseli_enabled else '0') + + # I have absolutely no idea what these do. root.set_attribute('useridflag', '1') root.set_attribute('extidflag', '1') return root diff --git a/bemani/client/base.py b/bemani/client/base.py index 219e064..7ad231f 100644 --- a/bemani/client/base.py +++ b/bemani/client/base.py @@ -294,7 +294,7 @@ class BaseClient: if binded != 1: raise Exception(f'Card \'{card_id}\' returned invalid binded value \'{binded}\'') - if newflag != 1: + if newflag != 0: raise Exception(f'Card \'{card_id}\' returned invalid newflag value \'{newflag}\'') if ecflag != (1 if paseli_enabled else 0): raise Exception(f'Card \'{card_id}\' returned invalid ecflag value \'{newflag}\'')