From 24f854e61d6e17ec92cc21713d8e17ee6ffca56b Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Thu, 9 Jul 2026 17:35:26 +0200 Subject: [PATCH] allnet: improve billing playlimit to include history --- core/allnet.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/core/allnet.py b/core/allnet.py index 821c5de..276f440 100644 --- a/core/allnet.py +++ b/core/allnet.py @@ -711,6 +711,7 @@ class BillingServlet: "messages": [] } playhist = "000000/0:000000/0:000000/0" + total_playcount = req.playcnt if machine is not None: if self.config.allnet.save_billing: @@ -722,16 +723,21 @@ class BillingServlet: # Technically if a cab resets it's playcount and then does more plays then the previous # playcount before a billing checkin occours, we will lose plays equal to the current playcount. - if req.playcnt < last_playct: await self.data.arcade.billing_add_playcount(machine['id'], req.gameid, req.playcnt) - elif req.playcnt == last_playct: pass # No plays since last checkin, skip update - else: await self.data.arcade.billing_add_playcount(machine['id'], req.gameid, req.playcnt - last_playct) + if req.playcnt < last_playct: + await self.data.arcade.billing_add_playcount(machine['id'], req.gameid, req.playcnt) + elif req.playcnt == last_playct: + pass # No plays since last checkin, skip update + else: + await self.data.arcade.billing_add_playcount(machine['id'], req.gameid, req.playcnt - last_playct) plays = await self.data.arcade.billing_get_playcount_3mo(machine['id'], req.gameid) - if plays is not None and len(plays) > 0: - playhist = "" - - for x in range(len(plays) - 1, -1, -1): playhist += f"{plays[x]['year']:04d}{plays[x]['month']:02d}/{plays[x]['playct']}:" - playhist = playhist[:-1] + if plays: + total_playcount = sum(p['playct'] for p in plays) + + playhist = ":".join( + f"{p['year']:04d}{p['month']:02d}/{p['playct']}" + for p in reversed(plays) + ) for x in range(1, len(req_dict)): if not req_dict[x]: @@ -814,10 +820,10 @@ class BillingServlet: return PlainTextResponse("result=6&waittime=0&linelimit=20\r\n") playlimit = req.playlimit - while req.playcnt > playlimit: + while total_playcount > playlimit: playlimit += 1024 - nearfull = req.nearfull + (req.billingtype.value * 0x00010000) + nearfull = req.nearfull | (req.billingtype.value << 16) digest.update(playlimit.to_bytes(4, "little") + kc_serial_bytes) playlimit_sig = signer.sign(digest).hex()