def handle(world_session, socket, reader): target_name = PacketReader.read_string(reader.data, 0).strip() online_player = WorldSessionStateHandler.find_player_by_name( target_name) offline_player = None friend_result_error = None # Try to pull the character from DB. if not online_player: offline_player = RealmDatabaseManager.character_get_by_name( target_name) target_guid = online_player.guid if online_player else offline_player.guid if offline_player else None target_team = online_player.team if online_player else PlayerManager.get_team_for_race( offline_player.race) if offline_player else None if not online_player and not offline_player: friend_result_error = FriendResults.FRIEND_NOT_FOUND elif world_session.player_mgr.team != target_team: friend_result_error = FriendResults.FRIEND_ENEMY elif world_session.player_mgr.guid == target_guid: friend_result_error = FriendResults.FRIEND_SELF elif world_session.player_mgr.friends_manager.has_friend(target_guid): friend_result_error = FriendResults.FRIEND_ALREADY if not friend_result_error: world_session.player_mgr.friends_manager.add_friend(target_guid) else: data = pack('<B', friend_result_error) world_session.enqueue_packet( PacketWriter.get_packet(OpCode.SMSG_FRIEND_STATUS, data)) return 0
def handle(world_session, socket, reader): if len(reader.data) < 8: # Avoid handling wrong player login packet return -1 guid = unpack('<Q', reader.data[:8])[0] world_session.player_mgr = PlayerManager( RealmDatabaseManager.character_get_by_guid(guid), world_session) world_session.player_mgr.session = world_session if not world_session.player_mgr.player: Logger.anticheat('Character with wrong guid (%u) tried to login.' % guid) return -1 socket.sendall( PacketWriter.get_packet(OpCode.SMSG_LOGIN_SETTIMESPEED, PlayerLoginHandler._get_login_timespeed())) world_session.player_mgr.load_skills() world_session.player_mgr.load_spells() world_session.player_mgr.deathbind = RealmDatabaseManager.character_get_deathbind( world_session.player_mgr.guid) socket.sendall(world_session.player_mgr.get_deathbind_packet()) # Tutorials aren't implemented in 0.5.3 # socket.sendall(world_session.player_mgr.get_tutorial_packet()) socket.sendall(world_session.player_mgr.get_initial_spells()) socket.sendall(world_session.player_mgr.get_action_buttons()) # MotD ChatManager.send_system_message(world_session, config.Server.General.motd) world_session.player_mgr.inventory.load_items() world_session.player_mgr.stat_manager.init_stats() world_session.player_mgr.stat_manager.apply_bonuses() world_session.player_mgr.send_update_self(create=True) world_session.player_mgr.reset_fields() PlayerLoginHandler._send_cinematic(world_session, world_session.player_mgr.player, socket) world_session.player_mgr.complete_login() return 0
def handle(world_session, socket, reader): if len(reader.data) < 8: # Avoid handling wrong player login packet return -1 guid = unpack('<Q', reader.data[:8])[0] world_session.player_mgr = PlayerManager( RealmDatabaseManager.character_get_by_guid(guid), world_session) world_session.player_mgr.session = world_session if not world_session.player_mgr.player: Logger.anticheat('Character with wrong guid (%u) tried to login.' % guid) return -1 socket.sendall(PacketWriter.get_packet(OpCode.SMSG_LOGIN_SETTIMESPEED, PlayerLoginHandler._get_login_timespeed())) world_session.player_mgr.load_skills() world_session.player_mgr.load_spells() socket.sendall(world_session.player_mgr.get_tutorial_packet()) socket.sendall(world_session.player_mgr.get_initial_spells()) socket.sendall(world_session.player_mgr.get_action_buttons()) # MotD ChatManager.send_system_message(world_session, config.Server.General.motd) # Clear Who list on login, otherwise the last search will appear PlayerLoginHandler._clear_who_list(socket) world_session.player_mgr.inventory.load_items() update_packet = UpdatePacketFactory.compress_if_needed(PacketWriter.get_packet( OpCode.SMSG_UPDATE_OBJECT, world_session.player_mgr.get_update_packet(update_type=UpdateTypes.UPDATE_FULL))) socket.sendall(update_packet) PlayerLoginHandler._send_cinematic(world_session, world_session.player_mgr.player, socket) world_session.player_mgr.complete_login() return 0
def handle(world_session, socket, reader): if len(reader.data) < 8: # Avoid handling wrong player login packet return -1 guid = unpack('<Q', reader.data[:8])[0] world_session.player_mgr = PlayerManager( RealmDatabaseManager.character_get_by_guid(guid), world_session) world_session.player_mgr.session = world_session if not world_session.player_mgr.player: Logger.anticheat('Character with wrong guid (%u) tried to login.' % guid) return -1 # Disabled race & class checks (only if not a GM) if not world_session.player_mgr.is_gm: disabled_race_mask = config.Server.General.disabled_race_mask disabled = disabled_race_mask & world_session.player_mgr.race_mask == world_session.player_mgr.race_mask if not disabled: disabled_class_mask = config.Server.General.disabled_class_mask disabled = disabled_class_mask & world_session.player_mgr.class_mask == world_session.player_mgr.class_mask if disabled: # Not 100% sure if CHAR_LOGIN_DISABLED matters here, but I don't know where else to send it data = pack('<B', CharLogin.CHAR_LOGIN_DISABLED) socket.sendall( PacketWriter.get_packet(OpCode.SMSG_CHARACTER_LOGIN_FAILED, data)) return 0 # Class & race allowed, continue with the login process socket.sendall( PacketWriter.get_packet(OpCode.SMSG_LOGIN_SETTIMESPEED, PlayerLoginHandler._get_login_timespeed())) world_session.player_mgr.load_skills() world_session.player_mgr.load_spells() world_session.player_mgr.deathbind = RealmDatabaseManager.character_get_deathbind( world_session.player_mgr.guid) socket.sendall(world_session.player_mgr.get_deathbind_packet()) # Tutorials aren't implemented in 0.5.3 # socket.sendall(world_session.player_mgr.get_tutorial_packet()) socket.sendall(world_session.player_mgr.get_initial_spells()) socket.sendall(world_session.player_mgr.get_action_buttons()) # MotD ChatManager.send_system_message(world_session, config.Server.General.motd) world_session.player_mgr.inventory.load_items() world_session.player_mgr.stat_manager.init_stats() world_session.player_mgr.stat_manager.apply_bonuses() world_session.player_mgr.send_update_self(create=True) world_session.player_mgr.reset_fields() PlayerLoginHandler._send_cinematic(world_session, world_session.player_mgr.player, socket) world_session.player_mgr.complete_login() return 0
def handle(world_session, socket, reader): if len(reader.data) < 8: # Avoid handling wrong player login packet. return -1 guid = unpack('<Q', reader.data[:8])[0] world_session.player_mgr = PlayerManager( RealmDatabaseManager.character_get_by_guid(guid), world_session) world_session.player_mgr.session = world_session if not world_session.player_mgr.player: Logger.anticheat( f'Character with wrong guid ({guid}) tried to login.') return -1 else: WorldSessionStateHandler.push_active_player_session(world_session) # Disabled race & class checks (only if not a GM) if not world_session.player_mgr.is_gm: disabled_race_mask = config.Server.General.disabled_race_mask disabled = disabled_race_mask & world_session.player_mgr.race_mask == world_session.player_mgr.race_mask if not disabled: disabled_class_mask = config.Server.General.disabled_class_mask disabled = disabled_class_mask & world_session.player_mgr.class_mask == world_session.player_mgr.class_mask if disabled: # Not 100% sure if CHAR_LOGIN_DISABLED matters here, but I don't know where else to send it data = pack('<B', CharLogin.CHAR_LOGIN_DISABLED) world_session.enqueue_packet( PacketWriter.get_packet(OpCode.SMSG_CHARACTER_LOGIN_FAILED, data)) return 0 # Class & race allowed, continue with the login process world_session.enqueue_packet( PacketWriter.get_packet(OpCode.SMSG_LOGIN_SETTIMESPEED, PlayerLoginHandler._get_login_timespeed())) world_session.player_mgr.skill_manager.load_proficiencies() world_session.player_mgr.spell_manager.load_spells() world_session.player_mgr.deathbind = RealmDatabaseManager.character_get_deathbind( world_session.player_mgr.guid) world_session.player_mgr.friends_manager.load_from_db( RealmDatabaseManager.character_get_social( world_session.player_mgr.guid)) world_session.enqueue_packet( world_session.player_mgr.get_deathbind_packet()) # Tutorials aren't implemented in 0.5.3 # world_session.enqueue_packet(world_session.player_mgr.get_tutorial_packet()) world_session.player_mgr.skill_manager.init_proficiencies() world_session.enqueue_packet( world_session.player_mgr.spell_manager.get_initial_spells()) world_session.enqueue_packet( world_session.player_mgr.get_action_buttons()) # MotD ChatManager.send_system_message(world_session, config.Server.General.motd) world_session.player_mgr.inventory.load_items() world_session.player_mgr.stat_manager.init_stats() world_session.player_mgr.stat_manager.apply_bonuses() world_session.player_mgr.skill_manager.load_skills() world_session.player_mgr.quest_manager.load_quests() world_session.player_mgr.reputation_manager.load_reputations() GuildManager.set_character_guild(world_session.player_mgr) GroupManager.set_character_group(world_session.player_mgr) PetitionManager.load_petition(world_session.player_mgr) # First login if world_session.player_mgr.player.totaltime == 0: # Replenish health, and mana if needed. world_session.player_mgr.set_health( world_session.player_mgr.max_health) if world_session.player_mgr.power_type == PowerTypes.TYPE_MANA: world_session.player_mgr.set_mana( world_session.player_mgr.max_power_1) # Load self before sending cinematic PlayerLoginHandler._load_self(world_session.player_mgr) # Send cinematic PlayerLoginHandler._send_cinematic(world_session, world_session.player_mgr.player, socket) else: PlayerLoginHandler._load_self(world_session.player_mgr) world_session.player_mgr.complete_login() return 0