1
0
mirror of synced 2025-02-17 19:19:19 +01:00

Rename whole-service route handler, get rid of legacy eacoin handler that's broken due to evaluation order, fix eacoin disable bug that I just discovered.

This commit is contained in:
Jennifer Taylor 2022-10-04 03:31:52 +00:00
parent 15c07b49a9
commit 8c1d272c72
9 changed files with 52 additions and 19 deletions

View File

@ -26,8 +26,9 @@ class Factory(ABC):
""" """
The base class every game factory inherits from. Defines a create method The base class every game factory inherits from. Defines a create method
which should return some game class which can handle packets. Game classes which should return some game class which can handle packets. Game classes
inherit from Base, and have handle_<call>_request methods on them that inherit from Base, and have handle_<call>_requests service methods or
Dispatch will look up in order to handle calls. handle_<call>_<method>_request methods on them that Dispatch will look up
in order to handle calls.
""" """
MANAGED_CLASSES: List[Type["Base"]] MANAGED_CLASSES: List[Type["Base"]]

View File

@ -1,4 +1,3 @@
from typing import Optional
from typing_extensions import Final from typing_extensions import Final
from bemani.backend.base import Base, Status from bemani.backend.base import Base, Status
@ -24,11 +23,7 @@ class PASELIHandler(Base):
""" """
paseli_padding: int = 1 paseli_padding: int = 1
def handle_eacoin_request(self, request: Node) -> Optional[Node]: def handle_eacoin_checkin_request(self, request: Node) -> Node:
"""
First, a generic handler to catch if paseli is not enabled, so that each
individual method below doesn't need to handle it.
"""
if not self.config.paseli.enabled: if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled # Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request") print("PASELI not enabled, ignoring eacoin request")
@ -36,10 +31,6 @@ class PASELIHandler(Base):
root.set_attribute('status', str(Status.NOT_ALLOWED)) root.set_attribute('status', str(Status.NOT_ALLOWED))
return root return root
# This is fine, let the individual request handlers handle this packet.
return None
def handle_eacoin_checkin_request(self, request: Node) -> Node:
root = Node.void('eacoin') root = Node.void('eacoin')
cardid = request.child_value('cardid') cardid = request.child_value('cardid')
pin = request.child_value('passwd') pin = request.child_value('passwd')
@ -85,6 +76,13 @@ class PASELIHandler(Base):
return root return root
def handle_eacoin_opcheckin_request(self, request: Node) -> Node: def handle_eacoin_opcheckin_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
root = Node.void('eacoin') root = Node.void('eacoin')
passwd = request.child_value('passwd') passwd = request.child_value('passwd')
@ -118,6 +116,12 @@ class PASELIHandler(Base):
return root return root
def handle_eacoin_consume_request(self, request: Node) -> Node: def handle_eacoin_consume_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
def make_resp(status: int, balance: int) -> Node: def make_resp(status: int, balance: int) -> Node:
root = Node.void('eacoin') root = Node.void('eacoin')
@ -174,6 +178,13 @@ class PASELIHandler(Base):
return make_resp(0, balance) return make_resp(0, balance)
def handle_eacoin_getlog_request(self, request: Node) -> Node: def handle_eacoin_getlog_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
root = Node.void('eacoin') root = Node.void('eacoin')
sessid = request.child_value('sessid') sessid = request.child_value('sessid')
logtype = request.child_value('logtype') logtype = request.child_value('logtype')
@ -389,6 +400,13 @@ class PASELIHandler(Base):
return root return root
def handle_eacoin_opchpass_request(self, request: Node) -> Node: def handle_eacoin_opchpass_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
root = Node.void('eacoin') root = Node.void('eacoin')
oldpass = request.child_value('passwd') oldpass = request.child_value('passwd')
newpass = request.child_value('newpasswd') newpass = request.child_value('newpasswd')
@ -423,6 +441,13 @@ class PASELIHandler(Base):
return root return root
def handle_eacoin_checkout_request(self, request: Node) -> Node: def handle_eacoin_checkout_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
session = request.child_value('sessid') session = request.child_value('sessid')
if session is not None: if session is not None:
# Destroy the session so it can't be used for any other purchases # Destroy the session so it can't be used for any other purchases
@ -432,6 +457,13 @@ class PASELIHandler(Base):
return root return root
def handle_eacoin_opcheckout_request(self, request: Node) -> Node: def handle_eacoin_opcheckout_request(self, request: Node) -> Node:
if not self.config.paseli.enabled:
# Refuse to respond, we don't have PASELI enabled
print("PASELI not enabled, ignoring eacoin request")
root = Node.void('eacoin')
root.set_attribute('status', str(Status.NOT_ALLOWED))
return root
session = request.child_value('sessid') session = request.child_value('sessid')
if session is not None: if session is not None:
# Destroy the session so it can't be used for any other purchases # Destroy the session so it can't be used for any other purchases

View File

@ -147,7 +147,7 @@ class Dispatch:
if response is None: if response is None:
# Now, try to pass it off to a generic service handler # Now, try to pass it off to a generic service handler
try: try:
handler = getattr(game, f'handle_{request.name}_request') handler = getattr(game, f'handle_{request.name}_requests')
except AttributeError: except AttributeError:
handler = None handler = None
if handler is not None: if handler is not None:

View File

@ -106,7 +106,7 @@ class PopnMusicModernBase(PopnMusicBase, ABC):
return self.GAME_PLAY_RANK_AAA return self.GAME_PLAY_RANK_AAA
return self.GAME_PLAY_RANK_S return self.GAME_PLAY_RANK_S
def handle_lobby24_request(self, request: Node) -> Node: def handle_lobby24_requests(self, request: Node) -> Node:
# Stub out the entire lobby24 service # Stub out the entire lobby24 service
return Node.void('lobby24') return Node.void('lobby24')

View File

@ -254,7 +254,7 @@ class PopnMusicEclale(PopnMusicBase):
self.__construct_common_info(info) self.__construct_common_info(info)
return info return info
def handle_lobby22_request(self, request: Node) -> Node: def handle_lobby22_requests(self, request: Node) -> Node:
# Stub out the entire lobby22 service (yes, its lobby22 in Pop'n 23) # Stub out the entire lobby22 service (yes, its lobby22 in Pop'n 23)
return Node.void('lobby22') return Node.void('lobby22')

View File

@ -636,6 +636,6 @@ class PopnMusicFantasia(PopnMusicBase):
self.update_machine(machine) self.update_machine(machine)
return Node.void('game') return Node.void('game')
def handle_lobby_request(self, request: Node) -> Node: def handle_lobby_requests(self, request: Node) -> Node:
# Stub out the entire lobby service # Stub out the entire lobby service
return Node.void('lobby') return Node.void('lobby')

View File

@ -249,7 +249,7 @@ class PopnMusicLapistoria(PopnMusicBase):
self.update_machine_name(request.child_value('pcb_setting/name')) self.update_machine_name(request.child_value('pcb_setting/name'))
return Node.void('pcb22') return Node.void('pcb22')
def handle_lobby22_request(self, request: Node) -> Node: def handle_lobby22_requests(self, request: Node) -> Node:
# Stub out the entire lobby22 service # Stub out the entire lobby22 service
return Node.void('lobby22') return Node.void('lobby22')

View File

@ -699,6 +699,6 @@ class PopnMusicSunnyPark(PopnMusicBase):
return root return root
def handle_lobby_request(self, request: Node) -> Node: def handle_lobby_requests(self, request: Node) -> Node:
# Stub out the entire lobby service # Stub out the entire lobby service
return Node.void('lobby') return Node.void('lobby')

View File

@ -616,6 +616,6 @@ class PopnMusicTuneStreet(PopnMusicBase):
return root return root
def handle_lobby_request(self, request: Node) -> Node: def handle_lobby_requests(self, request: Node) -> Node:
# Stub out the entire lobby service # Stub out the entire lobby service
return Node.void('lobby') return Node.void('lobby')