Remove coordinate check on furniture positioning

Also checks that db update succeeded before updating internal igloo cache.
This commit is contained in:
Ben 2020-06-05 22:47:19 +01:00
parent b8130a12fd
commit 69446d5800

View File

@ -99,18 +99,15 @@ async def save_igloo_furniture(p, furniture_list=None):
furniture_id, x, y, rotation, frame = map(int, furniture_string.split('|'))
if furniture_id not in p.furniture:
return
return False
if furniture_id not in furniture_tracker:
furniture_tracker[furniture_id] = 0
else:
furniture_tracker[furniture_id] += 1
furniture_tracker[furniture_id] = furniture_tracker.get(furniture_id, 0) + 1
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):
return
if not (1 <= rotation <= 8 and 1 <= frame <= 10):
return False
furniture.append({
'igloo_id': p.igloo,
@ -121,6 +118,7 @@ async def save_igloo_furniture(p, furniture_list=None):
})
await IglooFurniture.insert().values(furniture).gino.status()
return True
@handlers.boot
@ -280,8 +278,9 @@ async def handle_update_igloo_configuration(p, igloo_id: int, igloo_type_id: int
p.server.igloos_by_penguin_id[p.id] = igloo
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 save_res:
if not igloo_type_id or igloo_type_id in p.igloos\
and not flooring_id or flooring_id in p.flooring\
and not location_id or location_id in p.locations:
@ -308,8 +307,9 @@ async def handle_update_igloo_configuration(p, igloo_id: int, igloo_type_id: int
@handlers.handler(XTPacket('g', 'ur'), client=ClientType.Legacy)
@handlers.cooldown(1)
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)
if save_res:
p.server.cache.set(f'layout_furniture.{p.igloo}', ','.join(furniture_data))
p.server.cache.delete(f'legacy_igloo.{p.id}')