Exemplo n.º 1
0
    def try_add_member(self, player_mgr, invite):
        # Check if new player is not in a group already and if we have space.
        if len(self.members) == MAX_GROUP_SIZE:
            return False

        if invite:
            self.invites[player_mgr.guid] = player_mgr
            player_mgr.group_manager = self
            return True
        else:
            self.members[player_mgr.guid] = player_mgr
            player_mgr.group_manager = self
            player_mgr.group_status = WhoPartyStatus.WHO_PARTY_STATUS_IN_PARTY

            query_details_packet = NameQueryHandler.get_query_details(
                player_mgr.player)
            self.send_packet_to_members(query_details_packet)

            if player_mgr != self.party_leader:
                player_mgr.set_group_leader(False)

            if len(self.members) > 1:
                self.party_leader.group_status = WhoPartyStatus.WHO_PARTY_STATUS_IN_PARTY
                self.send_update()
                self.send_party_members_stats()

            return True
Exemplo n.º 2
0
    def send_friends(self):
        friends_list = [f for f in self.friends.values() if not f.ignore]
        data = pack('<B', len(friends_list))

        for entry in friends_list:
            player_mgr = WorldSessionStateHandler.find_player_by_guid(entry.friend)
            if player_mgr and player_mgr.online:
                self.owner.session.enqueue_packet(NameQueryHandler.get_query_details(player_mgr.player))
                data += pack('<QB3I', player_mgr.guid, 1, player_mgr.zone, player_mgr.level, player_mgr.player.class_)
            else:
                data += pack('QB', entry.friend, 0)  # 0 = Offline

        packet = PacketWriter.get_packet(OpCode.SMSG_FRIEND_LIST, data)
        self.owner.session.enqueue_packet(packet)
Exemplo n.º 3
0
    def try_add_member(self, player_mgr, invite):
        # Check if we have space.
        if self.is_full():
            GroupManager.send_group_operation_result(
                player_mgr, PartyOperations.PARTY_OP_INVITE, '',
                PartyResults.ERR_GROUP_FULL)
            return False

        if invite:
            self.invites[player_mgr.guid] = player_mgr
            player_mgr.group_manager = self
            player_mgr.has_pending_group_invite = True
            return True
        else:
            if len(self.members
                   ) == 0:  # Party just formed, store the group and params.
                leader_player = WorldSessionStateHandler.find_player_by_guid(
                    self.group.leader_guid)
                if leader_player:  # If online, we set leader group status.
                    RealmDatabaseManager.group_create(self.group)
                    GroupManager.GROUPS[self.group.group_id] = self
                    leader = GroupManager._create_new_member(
                        self.group, leader_player)
                    RealmDatabaseManager.group_add_member(leader)
                    self.members[self.group.leader_guid] = leader
                    leader_player.group_status = WhoPartyStatus.WHO_PARTY_STATUS_IN_PARTY
                    GroupManager._set_leader_flag(leader)
                else:  # Leader went offline after sending the invite.
                    return False

            new_member = GroupManager._create_new_member(
                self.group, player_mgr)
            new_member = RealmDatabaseManager.group_add_member(new_member)
            self.members[player_mgr.guid] = new_member

            # Update newly added member group_manager ref, party status and pending invite flag.
            player_mgr.group_manager = self
            player_mgr.group_status = WhoPartyStatus.WHO_PARTY_STATUS_IN_PARTY
            player_mgr.has_pending_group_invite = False

            query_details_packet = NameQueryHandler.get_query_details(
                player_mgr.player)
            self.send_packet_to_members(query_details_packet)

            if len(self.members) > 1:
                self.send_update()
                self.send_party_members_stats()

            return True
Exemplo n.º 4
0
    def update_surrounding_on_me(self):
        players, creatures, gobjects = GridManager.get_surrounding_objects(
            self, [
                ObjectTypes.TYPE_PLAYER, ObjectTypes.TYPE_UNIT,
                ObjectTypes.TYPE_GAMEOBJECT
            ])

        # At this point, all objects aren't synced unless proven otherwise
        for guid, object_info in list(self.objects_in_range.items()):
            self.objects_in_range[guid]['synced'] = False

        for guid, player in players.items():
            if self.guid != guid:
                if guid not in self.objects_in_range:
                    update_packet = player.generate_proper_update_packet(
                        create=True)
                    self.session.request.sendall(update_packet)
                    self.session.request.sendall(
                        NameQueryHandler.get_query_details(player.player))
                self.objects_in_range[guid] = {
                    'object': player,
                    'synced': True
                }

        for guid, creature in creatures.items():
            if creature.is_spawned:
                if guid not in self.objects_in_range:
                    update_packet = UpdatePacketFactory.compress_if_needed(
                        PacketWriter.get_packet(
                            OpCode.SMSG_UPDATE_OBJECT,
                            creature.get_full_update_packet(is_self=False)))
                    self.session.request.sendall(update_packet)
                    self.session.request.sendall(creature.query_details())
            self.objects_in_range[guid] = {'object': creature, 'synced': True}

        for guid, gobject in gobjects.items():
            if guid not in self.objects_in_range:
                update_packet = UpdatePacketFactory.compress_if_needed(
                    PacketWriter.get_packet(
                        OpCode.SMSG_UPDATE_OBJECT,
                        gobject.get_full_update_packet(is_self=False)))
                self.session.request.sendall(update_packet)
                self.session.request.sendall(gobject.query_details())
            self.objects_in_range[guid] = {'object': gobject, 'synced': True}

        for guid, object_info in list(self.objects_in_range.items()):
            if not object_info['synced']:
                self.destroy_near_object(guid, skip_check=True)
Exemplo n.º 5
0
    def send_update_surrounding(self,
                                update_packet,
                                include_self=False,
                                create=False,
                                force_inventory_update=False):
        if not create and (self.dirty_inventory or force_inventory_update):
            self.inventory.send_inventory_update(self.session, is_self=False)
            self.inventory.build_update()

        GridManager.send_surrounding(update_packet,
                                     self,
                                     include_self=include_self)
        if create:
            GridManager.send_surrounding(NameQueryHandler.get_query_details(
                self.player),
                                         self,
                                         include_self=True)