mirror of
https://github.com/solero/houdini.git
synced 2024-11-24 22:47:22 +00:00
Remove coordinate check on furniture positioning
Also checks that db update succeeded before updating internal igloo cache.
This commit is contained in:
parent
b8130a12fd
commit
69446d5800
@ -99,18 +99,15 @@ async def save_igloo_furniture(p, furniture_list=None):
|
|||||||
furniture_id, x, y, rotation, frame = map(int, furniture_string.split('|'))
|
furniture_id, x, y, rotation, frame = map(int, furniture_string.split('|'))
|
||||||
|
|
||||||
if furniture_id not in p.furniture:
|
if furniture_id not in p.furniture:
|
||||||
return
|
return False
|
||||||
|
|
||||||
if furniture_id not in furniture_tracker:
|
furniture_tracker[furniture_id] = furniture_tracker.get(furniture_id, 0) + 1
|
||||||
furniture_tracker[furniture_id] = 0
|
|
||||||
else:
|
|
||||||
furniture_tracker[furniture_id] += 1
|
|
||||||
|
|
||||||
if furniture_tracker[furniture_id] > p.furniture[furniture_id].quantity:
|
if furniture_tracker[furniture_id] > p.furniture[furniture_id].quantity:
|
||||||
return
|
return False
|
||||||
|
|
||||||
if not (0 <= x <= 700 and 0 <= y <= 700 and 1 <= rotation <= 8 and 1 <= frame <= 10):
|
if not (1 <= rotation <= 8 and 1 <= frame <= 10):
|
||||||
return
|
return False
|
||||||
|
|
||||||
furniture.append({
|
furniture.append({
|
||||||
'igloo_id': p.igloo,
|
'igloo_id': p.igloo,
|
||||||
@ -121,6 +118,7 @@ async def save_igloo_furniture(p, furniture_list=None):
|
|||||||
})
|
})
|
||||||
|
|
||||||
await IglooFurniture.insert().values(furniture).gino.status()
|
await IglooFurniture.insert().values(furniture).gino.status()
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@handlers.boot
|
@handlers.boot
|
||||||
@ -280,38 +278,40 @@ async def handle_update_igloo_configuration(p, igloo_id: int, igloo_type_id: int
|
|||||||
p.server.igloos_by_penguin_id[p.id] = igloo
|
p.server.igloos_by_penguin_id[p.id] = igloo
|
||||||
|
|
||||||
furniture_list = furniture_data.split(',') if furniture_data else None
|
furniture_list = furniture_data.split(',') if furniture_data else None
|
||||||
await save_igloo_furniture(p, furniture_list)
|
save_res = await save_igloo_furniture(p, furniture_list)
|
||||||
|
|
||||||
if not igloo_type_id or igloo_type_id in p.igloos\
|
if save_res:
|
||||||
and not flooring_id or flooring_id in p.flooring\
|
if not igloo_type_id or igloo_type_id in p.igloos\
|
||||||
and not location_id or location_id in p.locations:
|
and not flooring_id or flooring_id in p.flooring\
|
||||||
await igloo.update(
|
and not location_id or location_id in p.locations:
|
||||||
type=igloo_type_id,
|
await igloo.update(
|
||||||
flooring=flooring_id,
|
type=igloo_type_id,
|
||||||
location=location_id,
|
flooring=flooring_id,
|
||||||
music=music_id
|
location=location_id,
|
||||||
).apply()
|
music=music_id
|
||||||
|
).apply()
|
||||||
|
|
||||||
like_count = p.server.cache.get(f'layout_like_count.{igloo.id}')
|
like_count = p.server.cache.get(f'layout_like_count.{igloo.id}')
|
||||||
like_count = await get_layout_like_count(igloo.id) if like_count is None else like_count
|
like_count = await get_layout_like_count(igloo.id) if like_count is None else like_count
|
||||||
p.server.cache.set(f'layout_like_count.{igloo.id}', like_count)
|
p.server.cache.set(f'layout_like_count.{igloo.id}', like_count)
|
||||||
active_igloo_string = f'{igloo.id}:1:0:{int(igloo.locked)}:{igloo.music}:{igloo.flooring}:' \
|
active_igloo_string = f'{igloo.id}:1:0:{int(igloo.locked)}:{igloo.music}:{igloo.flooring}:' \
|
||||||
f'{igloo.location}:{igloo.type}:{like_count}:{furniture_data}'
|
f'{igloo.location}:{igloo.type}:{like_count}:{furniture_data}'
|
||||||
await p.room.send_xt('uvi', p.id, active_igloo_string)
|
await p.room.send_xt('uvi', p.id, active_igloo_string)
|
||||||
|
|
||||||
p.server.cache.set(f'layout_furniture.{igloo.id}', furniture_data)
|
p.server.cache.set(f'layout_furniture.{igloo.id}', furniture_data)
|
||||||
p.server.cache.set(f'active_igloo.{p.id}', active_igloo_string)
|
p.server.cache.set(f'active_igloo.{p.id}', active_igloo_string)
|
||||||
p.server.cache.delete(f'legacy_igloo.{p.id}')
|
p.server.cache.delete(f'legacy_igloo.{p.id}')
|
||||||
p.server.cache.delete(f'igloo_layouts.{p.id}')
|
p.server.cache.delete(f'igloo_layouts.{p.id}')
|
||||||
|
|
||||||
|
|
||||||
@handlers.handler(XTPacket('g', 'ur'), client=ClientType.Legacy)
|
@handlers.handler(XTPacket('g', 'ur'), client=ClientType.Legacy)
|
||||||
@handlers.cooldown(1)
|
@handlers.cooldown(1)
|
||||||
async def handle_save_igloo_furniture(p, *furniture_data):
|
async def handle_save_igloo_furniture(p, *furniture_data):
|
||||||
await save_igloo_furniture(p, furniture_data)
|
save_res = await save_igloo_furniture(p, furniture_data)
|
||||||
|
|
||||||
p.server.cache.set(f'layout_furniture.{p.igloo}', ','.join(furniture_data))
|
if save_res:
|
||||||
p.server.cache.delete(f'legacy_igloo.{p.id}')
|
p.server.cache.set(f'layout_furniture.{p.igloo}', ','.join(furniture_data))
|
||||||
|
p.server.cache.delete(f'legacy_igloo.{p.id}')
|
||||||
|
|
||||||
|
|
||||||
_slot_converter = SeparatorConverter(separator=',', mapper=str)
|
_slot_converter = SeparatorConverter(separator=',', mapper=str)
|
||||||
|
Loading…
Reference in New Issue
Block a user