def handle(world_session, socket, reader): if len(reader.data) >= 8: # Avoid handling empty initiate trade packet guid = unpack('<Q', reader.data[:8])[0] if guid > 0: trade_player = GridManager.get_surrounding_player_by_guid( world_session.player_mgr, guid) trade_status = None if not trade_player or not trade_player.is_alive: trade_status = TradeStatus.TRADE_STATUS_PLAYER_NOT_FOUND if not world_session.player_mgr.is_alive: trade_status = TradeStatus.TRADE_STATUS_DEAD if world_session.player_mgr.trade_data: trade_status = TradeStatus.TRADE_STATUS_ALREADY_TRADING if world_session.player_mgr.team != trade_player.team: trade_status = TradeStatus.TRADE_STATUS_WRONG_FACTION if trade_status: TradeManager.send_trade_status(world_session.player_mgr, trade_status) return 0 world_session.player_mgr.trade_data = TradeManager.TradeData( world_session.player_mgr, trade_player) trade_player.trade_data = TradeManager.TradeData( trade_player, world_session.player_mgr) TradeManager.send_trade_request(world_session.player_mgr, trade_player) TradeManager.send_trade_request(trade_player, world_session.player_mgr) return 0
def handle(world_session, socket, reader): if len(reader.data) >= 8: # Avoid handling empty name query packet guid = unpack('<Q', reader.data[:8])[0] player_mgr = GridManager.get_surrounding_player_by_guid(world_session.player_mgr, guid) if player_mgr: player = player_mgr.player else: player = RealmDatabaseManager.character_get_by_guid(guid) if player: world_session.enqueue_packet(NameQueryHandler.get_query_details(player)) return 0
def _target_or_self(world_session, only_players=False): if world_session.player_mgr.current_selection \ and world_session.player_mgr.current_selection != world_session.player_mgr.guid: if only_players: unit = GridManager.get_surrounding_player_by_guid(world_session.player_mgr, world_session.player_mgr.current_selection) else: unit = GridManager.get_surrounding_unit_by_guid(world_session.player_mgr, world_session.player_mgr.current_selection, include_players=True) if unit: return unit return world_session.player_mgr
def handle(world_session, socket, reader): if len(reader.data) >= 8: # Avoid handling empty inspect packet guid = unpack('<Q', reader.data[:8])[0] if guid > 0: inspected_player = GridManager.get_surrounding_player_by_guid( world_session.player_mgr, guid) if not inspected_player or not inspected_player.is_alive: return 0 world_session.player_mgr.set_current_selection(guid) world_session.player_mgr.set_current_target(guid) data = pack('<Q', world_session.player_mgr.guid) inspected_player.session.request.sendall( PacketWriter.get_packet(OpCode.SMSG_INSPECT, data)) return 0