[mai2/chuni/ongeki] Properly ignore guest plays (#132)

For all three games, guest plays are created using:
```python
0x1000000000001 | ((allnet_place_id & 65535) << 32)
```

Reviewed-on: Hay1tsme/artemis#132
Co-authored-by: beerpsi <beerpsi@duck.com>
Co-committed-by: beerpsi <beerpsi@duck.com>
This commit is contained in:
beerpsi 2024-04-24 17:00:01 +00:00 committed by Hay1tsme
parent a8daa0344a
commit d5c80cfb0f
4 changed files with 23 additions and 5 deletions

View File

@ -811,6 +811,12 @@ class ChuniBase:
upsert = data["upsertUserAll"] upsert = data["upsertUserAll"]
user_id = data["userId"] user_id = data["userId"]
if int(user_id) & 0x1000000000001 == 0x1000000000001:
place_id = int(user_id) & 0xFFFC00000000
self.logger.info("Guest play from place ID %d, ignoring.", place_id)
return {"returnCode": "1"}
if "userData" in upsert: if "userData" in upsert:
try: try:
upsert["userData"][0]["userName"] = self.read_wtf8( upsert["userData"][0]["userName"] = self.read_wtf8(

View File

@ -238,8 +238,10 @@ class Mai2Base:
user_id = data["userId"] user_id = data["userId"]
upsert = data["upsertUserAll"] upsert = data["upsertUserAll"]
if int(user_id) & 1000000000001 == 1000000000001: if int(user_id) & 0x1000000000001 == 0x1000000000001:
self.logger.info("Guest play, ignoring.") place_id = int(user_id) & 0xFFFC00000000
self.logger.info("Guest play from place ID %d, ignoring.", place_id)
return {"returnCode": 1, "apiName": "UpsertUserAllApi"} return {"returnCode": 1, "apiName": "UpsertUserAllApi"}
if "userData" in upsert and len(upsert["userData"]) > 0: if "userData" in upsert and len(upsert["userData"]) > 0:

View File

@ -121,8 +121,10 @@ class Mai2DX(Mai2Base):
user_id = data["userId"] user_id = data["userId"]
upsert = data["upsertUserAll"] upsert = data["upsertUserAll"]
if int(user_id) & 1000000000001 == 1000000000001: if int(user_id) & 0x1000000000001 == 0x1000000000001:
self.logger.info("Guest play, ignoring.") place_id = int(user_id) & 0xFFFC00000000
self.logger.info("Guest play from place ID %d, ignoring.", place_id)
return {"returnCode": 1, "apiName": "UpsertUserAllApi"} return {"returnCode": 1, "apiName": "UpsertUserAllApi"}
if "userData" in upsert and len(upsert["userData"]) > 0: if "userData" in upsert and len(upsert["userData"]) > 0:

View File

@ -293,7 +293,9 @@ class OngekiBase:
async def handle_upsert_user_gplog_api_request(self, data: Dict) -> Dict: async def handle_upsert_user_gplog_api_request(self, data: Dict) -> Dict:
user = data["userId"] user = data["userId"]
if user >= 200000000000000: # Account for guest play
# If playing as guest, the user ID is or(0x1000000000001, (placeId & 65535) << 32)
if user & 0x1000000000001 == 0x1000000000001:
user = None user = None
await self.data.log.put_gp_log( await self.data.log.put_gp_log(
@ -945,6 +947,12 @@ class OngekiBase:
upsert = data["upsertUserAll"] upsert = data["upsertUserAll"]
user_id = data["userId"] user_id = data["userId"]
if user_id & 0x1000000000001 == 0x1000000000001:
place_id = int(user_id) & 0xFFFC00000000
self.logger.info("Guest play from place ID %d, ignoring.", place_id)
return {"returnCode": 1, "apiName": "UpsertUserAllApi"}
# The isNew fields are new as of Red and up. We just won't use them for now. # The isNew fields are new as of Red and up. We just won't use them for now.
if "userData" in upsert and len(upsert["userData"]) > 0: if "userData" in upsert and len(upsert["userData"]) > 0: