Beispiel #1
0
    def handle(world_session, socket, reader):
        guid = unpack('<Q', reader.data)[0]

        world_session.player_mgr = PlayerManager(
            RealmDatabaseManager.character_get_by_guid(guid))
        if not world_session.player_mgr.player:
            Logger.error('Character with wrong guid (%u) tried to login.' %
                         guid)
            return -1

        socket.sendall(
            PacketWriter.get_packet(OpCode.SMSG_LOGIN_SETTIMESPEED,
                                    PlayerLoginHandler._get_login_timespeed()))

        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_query_details())
        # MotD
        ChatManager.send_system_message(world_session,
                                        config.Server.General.motd)

        socket.sendall(
            PacketWriter.get_packet(
                OpCode.SMSG_UPDATE_OBJECT,
                world_session.player_mgr.create_update_packet(
                    UpdateTypes.UPDATE_IN_RANGE.value) +
                world_session.player_mgr.get_update_packet()))

        PlayerLoginHandler.send_cinematic(world_session.player_mgr.player,
                                          socket)

        world_session.player_mgr.complete_login()

        return 0
 def gobject_info(world_session, args):
     try:
         if args:
             max_distance = int(args)
         else:
             max_distance = 10
         found_count = 0
         for guid, gobject in list(
                 GridManager.get_surrounding_gameobjects(
                     world_session.player_mgr).items()):
             distance = world_session.player_mgr.location.distance(
                 gobject.location)
             if distance <= max_distance:
                 found_count += 1
                 ChatManager.send_system_message(
                     world_session,
                     '[%s] - Guid: %u, Entry: %u, Display ID: %u, X: %f, Y: %f, Z: %f, O: %f, Map: %u, Distance: %f'
                     % (gobject.gobject_template.name,
                        gobject.guid & ~HighGuid.HIGHGUID_GAMEOBJECT,
                        gobject.gobject_template.entry, gobject.display_id,
                        gobject.location.x, gobject.location.y,
                        gobject.location.z, gobject.location.o,
                        gobject.map_, distance))
         return 0, '%u game objects found within %u distance units.' % (
             found_count, max_distance)
     except ValueError:
         return -1, 'please specify a valid distance.'
    def ann(world_session, args):
        ann = str(args)

        for session in WorldSessionStateHandler.get_world_sessions():
            if session.player_mgr and session.player_mgr.is_online:
                ChatManager.send_system_message(session, '[SERVER] %s' % ann)

        return 0, ''
 def tickets(world_session, args):
     tickets = RealmDatabaseManager.ticket_get_all()
     for ticket in tickets:
         ticket_text = '%s[%s]|r %s: %s from %s.' % (
             '|cFFFF0000' if ticket.is_bug else '|cFF00FFFF', ticket.id,
             ticket.submit_time, 'Bug report'
             if ticket.is_bug else 'Suggestion', ticket.character_name)
         ChatManager.send_system_message(world_session, ticket_text)
     return 0, '%u tickets shown.' % len(tickets)
Beispiel #5
0
    def sspell(world_session, args):
        spell_name = args.strip()
        if not spell_name:
            return -1, 'please specify a spell name to start searching.'
        spells = DbcDatabaseManager.spell_get_by_name(spell_name)

        for spell in spells:
            spell_text = '%u - |cFF00FFFF[%s]|r' % (spell.ID, spell.Name_enUS.replace('\\', ''))
            spell_text += ' (%s)' % spell.NameSubtext_enUS if spell.NameSubtext_enUS else ''
            ChatManager.send_system_message(world_session, spell_text)
        return 0, '%u spells found.' % len(spells)
Beispiel #6
0
    def sitem(world_session, args):
        item_name = args.strip()
        if not item_name:
            return -1, 'please specify an item name to start searching.'
        items = WorldDatabaseManager.item_template_get_by_name(item_name, return_all=True)

        for item in items:
            item_link = GameTextFormatter.generate_item_link(item.entry, item.name, item.quality)
            item_text = '%u - %s' % (item.entry, item_link)
            ChatManager.send_system_message(world_session, item_text)
        return 0, '%u items found.' % len(items)
Beispiel #7
0
    def stel(world_session, args):
        try:
            tel_name = args.split()[0]
        except IndexError:
            return -1, 'please specify a location name to start searching.'
        locations = WorldDatabaseManager.worldport_get_by_name(tel_name, return_all=True)

        for location in locations:
            port_text = '|cFF00FFFF[Map %s]|r - %s' % (location.map, location.name)
            ChatManager.send_system_message(world_session, port_text)
        return 0, '%u worldports found.' % len(locations)
    def handle(world_session, socket, reader):
        chat_type, lang = unpack('<2I', reader.data[:8])
        message = ''
        guid = 0
        chat_flags = 0

        # Return if no player
        if not world_session.player_mgr:
            return 0

        # Override language to universal for GMs
        if world_session.player_mgr.is_gm:
            lang = Languages.LANG_UNIVERSAL

        # Say, Yell, Emote
        if chat_type == ChatMsgs.CHAT_MSG_SAY \
                or chat_type == ChatMsgs.CHAT_MSG_EMOTE \
                or chat_type == ChatMsgs.CHAT_MSG_YELL:
            message = PacketReader.read_string(reader.data, 8)
            guid = world_session.player_mgr.guid
            chat_flags = world_session.player_mgr.chat_flags

            # Only send message if it's not a command
            if not ChatHandler.check_if_command(world_session, message):
                ChatManager.send_chat_message(
                    world_session, guid, chat_flags, message, chat_type, lang,
                    ChatHandler.get_range_by_type(chat_type))
        # Whisper
        elif chat_type == ChatMsgs.CHAT_MSG_WHISPER:
            target_name = PacketReader.read_string(reader.data, 8).strip()
            target_player_mgr = WorldSessionStateHandler.find_player_by_name(
                target_name)
            if not target_player_mgr:
                ChatManager.send_system_message(
                    world_session,
                    'No player named \'%s\' is currently playing.' %
                    target_name.capitalize())
                return 0
            message = PacketReader.read_string(reader.data,
                                               8 + len(target_name) + 1)
            if not ChatHandler.check_if_command(world_session, message):
                # Always whisper in universal language when speaking with a GM
                if target_player_mgr.is_gm:
                    lang = Languages.LANG_UNIVERSAL

                ChatManager.send_whisper(world_session.player_mgr,
                                         target_player_mgr, message, lang)
            return 0
        # Party
        elif chat_type == ChatMsgs.CHAT_MSG_PARTY:
            message = PacketReader.read_string(reader.data, 8)
            ChatManager.send_party(world_session.player_mgr, message, lang)
            return 0
        # Guild
        elif chat_type == ChatMsgs.CHAT_MSG_GUILD:
            # TODO: Implement
            return 0

        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
Beispiel #10
0
    def handle(world_session, socket, reader):
        chat_type, lang = unpack('<2I', reader.data[:8])
        chat_type = ChatMsgs(chat_type)

        # Say, Yell, Emote
        if chat_type == ChatMsgs.CHAT_MSG_SAY \
                or chat_type == ChatMsgs.CHAT_MSG_EMOTE \
                or chat_type == ChatMsgs.CHAT_MSG_YELL:
            message = PacketReader.read_string(reader.data[8:], 0)

            if len(message) == 0:
                return 0

            ChatManager.send_chat_message(world_session, message, chat_type,
                                          lang)

        return 0
Beispiel #11
0
    def handle(world_session, socket, reader):
        if len(reader.data) >= 4:  # Avoid handling empty area trigger packet
            trigger_id = unpack('<I', reader.data[:4])[0]
            location = WorldDatabaseManager.area_trigger_teleport_get_by_id(
                trigger_id)
            if location:
                if world_session.player_mgr.level >= location.required_level:
                    world_session.player_mgr.teleport(
                        location.target_map,
                        Vector(location.target_position_x,
                               location.target_position_y,
                               location.target_position_z,
                               location.target_orientation))
                else:
                    # SMSG_AREA_TRIGGER_MESSAGE in 1.x, but this OpCode seems to be missing in 0.5.3
                    ChatManager.send_system_message(
                        world_session,
                        'You must be at least level %u to enter.' %
                        location.required_level)

        return 0
Beispiel #12
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
Beispiel #13
0
    def handle_command(world_session, command_msg):
        terminator_index = command_msg.find(' ') if ' ' in command_msg else len(command_msg)

        command = command_msg[1:terminator_index].strip()
        args = command_msg[terminator_index:].strip()

        if command in PLAYER_COMMAND_DEFINITIONS:
            command_func = PLAYER_COMMAND_DEFINITIONS.get(command)
        elif command in GM_COMMAND_DEFINITIONS and world_session.player_mgr.is_gm:
            command_func = GM_COMMAND_DEFINITIONS.get(command)
        else:
            ChatManager.send_system_message(world_session, 'Command not found, type .help for help.')
            return

        if command_func:
            code, res = command_func(world_session, args)
            if code != 0:
                ChatManager.send_system_message(world_session, 'Wrong arguments for <%s> command: %s' % (command, res))
            elif res:
                ChatManager.send_system_message(world_session, res)
Beispiel #14
0
    def handle(world_session, socket, reader):
        chat_type, lang = unpack('<2I', reader.data[:8])
        message = ''
        guid = 0
        chat_flags = 0

        # Say, Yell, Emote
        if chat_type == ChatMsgs.CHAT_MSG_SAY \
                or chat_type == ChatMsgs.CHAT_MSG_EMOTE \
                or chat_type == ChatMsgs.CHAT_MSG_YELL:
            message = PacketReader.read_string(reader.data, 8)
            guid = world_session.player_mgr.guid
            chat_flags = world_session.player_mgr.chat_flags
        # Whisper
        elif chat_type == ChatMsgs.CHAT_MSG_WHISPER:
            target_name = PacketReader.read_string(reader.data, 8).strip()
            target_player_mgr = WorldSessionStateHandler.find_player_by_name(
                target_name)
            if not target_player_mgr:
                ChatManager.send_system_message(
                    world_session,
                    'No player named \'%s\' is currently playing.' %
                    target_name.capitalize())
                return 0
            message = PacketReader.read_string(reader.data,
                                               8 + len(target_name) + 1)
            if not ChatHandler.check_if_command(world_session, message):
                ChatManager.send_whisper(world_session.player_mgr,
                                         target_player_mgr, message,
                                         0)  # TODO: handle lang
            return 0

        if not ChatHandler.check_if_command(world_session, message):
            ChatManager.send_chat_message(
                world_session, guid, chat_flags, message, chat_type, lang,
                ChatHandler.get_range_by_type(chat_type))

        return 0
Beispiel #15
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