Example #1
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)
Example #2
0
 def generate_proper_update_packet(self, is_self=False, create=False):
     update_packet = UpdatePacketFactory.compress_if_needed(
         PacketWriter.get_packet(
             OpCode.SMSG_UPDATE_OBJECT,
             self.get_full_update_packet(is_self=is_self)
             if create else self.get_partial_update_packet()))
     return update_packet
Example #3
0
    def generate_partial_packet(self, requester):
        if not self.initialized:
            self.initialize_field_values()

        return UpdatePacketFactory.compress_if_needed(
            PacketWriter.get_packet(OpCode.SMSG_UPDATE_OBJECT,
                                    self.get_partial_update_packet(requester)))
Example #4
0
 def send_single_item_update(self, item, is_self):
     update_packet = UpdatePacketFactory.compress_if_needed(PacketWriter.get_packet(
         OpCode.SMSG_UPDATE_OBJECT, item.get_full_update_packet(is_self=False)))
     if is_self:
         self.owner.enqueue_packet(update_packet)
         self.owner.enqueue_packet(item.query_details())
     else:
         MapManager.send_surrounding(update_packet, self.owner, include_self=False)
         MapManager.send_surrounding(item.query_details(), self.owner, include_self=False)
Example #5
0
 def send_single_item_update(self, world_session, item, is_self):
     update_packet = UpdatePacketFactory.compress_if_needed(PacketWriter.get_packet(
         OpCode.SMSG_UPDATE_OBJECT, item.get_full_update_packet(is_self=False)))
     if is_self:
         world_session.request.sendall(update_packet)
         world_session.request.sendall(item.query_details())
     else:
         GridManager.send_surrounding(update_packet, world_session.player_mgr, include_self=False)
         GridManager.send_surrounding(item.query_details(), world_session.player_mgr,
                                      include_self=False)
Example #6
0
 def send_update_surrounding(self):
     update_packet = UpdatePacketFactory.compress_if_needed(
         PacketWriter.get_packet(
             OpCode.SMSG_UPDATE_OBJECT,
             self.get_full_update_packet(is_self=False)))
     MapManager.send_surrounding(update_packet, self, include_self=False)
Example #7
0
 def generate_create_packet(self, requester):
     return UpdatePacketFactory.compress_if_needed(
         PacketWriter.get_packet(OpCode.SMSG_UPDATE_OBJECT,
                                 self.get_object_create_packet(requester)))
Example #8
0
 def get_single_item_update_packet(self, item, requester):
     update_packet = UpdatePacketFactory.compress_if_needed(
         PacketWriter.get_packet(OpCode.SMSG_UPDATE_OBJECT,
                                 item.get_full_update_packet(requester)))
     return update_packet