Merge remote-tracking branch 'origin/master'

This commit is contained in:
rsakeys 2020-04-06 18:47:03 +01:00
commit ce51983a9b
7 changed files with 6699 additions and 6694 deletions

13374
houdini.sql

File diff suppressed because it is too large Load Diff

View File

@ -271,9 +271,6 @@ class RoomWaddle(db.Model):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
async def add_penguin(self, p): async def add_penguin(self, p):
if not self.penguins:
self.penguins = [None] * self.seats
seat_id = self.penguins.index(None) seat_id = self.penguins.index(None)
self.penguins[seat_id] = p self.penguins[seat_id] = p
await p.send_xt('jw', seat_id) await p.send_xt('jw', seat_id)

View File

@ -128,7 +128,7 @@ async def handle_buddy_request(p, buddy_id: int):
buddy = p.server.penguins_by_id[buddy_id] buddy = p.server.penguins_by_id[buddy_id]
if buddy.client_type == ClientType.Vanilla and p.id not in buddy.buddy_requests: if buddy.client_type == ClientType.Vanilla and p.id not in buddy.buddy_requests:
await buddy.buddy_requests.insert(buddy_id=p.id) await buddy.buddy_requests.insert(requester_id=p.id)
elif p.id not in buddy.legacy_buddy_requests: elif p.id not in buddy.legacy_buddy_requests:
buddy.legacy_buddy_requests.add(p.id) buddy.legacy_buddy_requests.add(p.id)
else: else:

View File

@ -41,7 +41,7 @@ async def handle_send_job_mail(p):
while last_paycheck < first_day_of_month: while last_paycheck < first_day_of_month:
last_paycheck = last_paycheck + datetime.timedelta(days=32) last_paycheck = last_paycheck + datetime.timedelta(days=32)
last_paycheck = last_paycheck.replace(day=1) last_paycheck = last_paycheck.replace(day=1)
send_date = last_paycheck + datetime.timedelta(days=1) send_date = last_paycheck
if 428 in p.inventory: if 428 in p.inventory:
postcards.append({ postcards.append({
'penguin_id': p.id, 'penguin_id': p.id,

View File

@ -1,4 +1,5 @@
import time import time
import pytz
from houdini import handlers from houdini import handlers
from houdini.data import db from houdini.data import db
@ -33,13 +34,17 @@ async def handle_get_mail(p):
PenguinPostcard.send_date.desc()) PenguinPostcard.send_date.desc())
postcards = [] postcards = []
pst = pytz.timezone(p.server.config.timezone)
async with p.server.db.transaction(): async with p.server.db.transaction():
async for postcard in mail_query.gino.iterate(): async for postcard in mail_query.gino.iterate():
sender_name, sender_id = ('sys', 0) if postcard.sender_id is None else ( sender_name, sender_id = ('sys', 0) if postcard.sender_id is None else (
postcard.parent.safe_nickname(p.server.config.lang), postcard.sender_id) postcard.parent.safe_nickname(p.server.config.lang), postcard.sender_id)
sent_pst = postcard.send_date.astimezone(pst)
sent_timestamp = int(time.mktime(postcard.send_date.timetuple())) sent_timestamp = int(time.mktime(postcard.send_date.timetuple()))
sent_pst_timestamp = int(time.mktime(sent_pst.timetuple()))
sent_timestamp += sent_timestamp - sent_pst_timestamp
postcards.append(f'{sender_name}|{sender_id}|{postcard.postcard_id}|' postcards.append(f'{sender_name}|{sender_id}|{postcard.postcard_id}|'
f'{postcard.details}|{sent_timestamp}|{postcard.id}|{int(postcard.has_read)}') f'{postcard.details}|{sent_timestamp+1}|{postcard.id}|{int(postcard.has_read)}')
await p.send_xt('mg', *postcards) await p.send_xt('mg', *postcards)

View File

@ -150,6 +150,8 @@ def encode_music_track(track_pattern):
def determine_song_length(track_pattern): def determine_song_length(track_pattern):
if track_pattern == '0':
return 0
track_length = track_pattern.split(',')[-1] track_length = track_pattern.split(',')[-1]
track_length = track_length.split('|')[1] track_length = track_length.split('|')[1]
return int(track_length, 16) // 1000 return int(track_length, 16) // 1000
@ -200,7 +202,7 @@ async def handle_save_my_music_track(p, track_name, track_pattern, track_hash):
if encoded_track_pattern != track_hash or song_length > 180: if encoded_track_pattern != track_hash or song_length > 180:
return return
pattern_regex = r'^([0-9a-fA-F]+,\d+\|){0,1000}[0-9a-fA-F]+,FFFF\|[0-9a-fA-F]+$' pattern_regex = r'^([0-9a-fA-F]+,[0-9a-fA-F]+\|){0,1000}[0-9a-fA-F]+,FFFF\|[0-9a-fA-F]+$'
if not re.match(pattern_regex, track_pattern): if not re.match(pattern_regex, track_pattern):
return return

View File

@ -55,6 +55,7 @@ async def setup_waddles(room_collection):
room_collection[waddle.room_id].waddles[waddle.id] = waddle room_collection[waddle.room_id].waddles[waddle.id] = waddle
waddle.room = room_collection[waddle.room_id] waddle.room = room_collection[waddle.room_id]
waddle.logic = WaddleLogicMapping[waddle.game] waddle.logic = WaddleLogicMapping[waddle.game]
waddle.penguins = [None] * waddle.seats
@handlers.boot @handlers.boot