def on_packet(self, packet): packet_id = packet.packet_id if packet_id == ClientVersion.packet_id: if packet.version != constants.CLIENT_VERSION: self.disconnect() return self.entity_id = self.factory.entity_ids.pop() self.entity_data = create_entity_data() self.factory.entities[self.entity_id] = self.entity_data self.factory.connections[(self.entity_id,)] = self server_data.entity_id = self.entity_id self.send_packet(server_data) seed_data.seed = self.factory.config.seed self.send_packet(seed_data) elif packet_id == EntityUpdate.packet_id: if packet.entity_id != self.entity_id: raise NotImplementedError() packet.update_entity(self.entity_data) if not self.has_joined and self.entity_data.name: self.on_join() self.has_joined = True self.factory.broadcast_packet(packet) elif packet_id == ClientChatMessage.packet_id: message = packet.value if self.on_chat(message) is False: return chat_message.entity_id = self.entity_id chat_message.value = message self.factory.broadcast_packet(chat_message) else: print 'Got client packet:', packet.packet_id
def on_entity_update(self, packet): if packet.entity_id not in self.entities: entity = create_entity_data() self.entities[packet.entity_id] = entity else: entity = self.entities[packet.entity_id] packet.update_entity(entity)
def on_entity_packet(self, packet): if self.entity_data is None: self.entity_data = create_entity_data() self.server.entities[self.entity_id] = self.entity_data self.entity_data.mask |= packet.update_entity(self.entity_data) if not self.has_joined and getattr(self.entity_data, 'name', None): self.on_join()
def on_entity_packet(self, packet): if self.entity_data is None: self.entity_data = create_entity_data() mask = packet.update_entity(self.entity_data) self.entity_data.mask |= mask if self.connection_state==2 and getattr(self.entity_data, 'name', None): self.on_join() return self.scripts.call('on_entity_update', mask=mask) # XXX clean this up if entity.is_pos_set(mask): self.on_pos_update() if entity.is_mode_set(mask): self.scripts.call('on_mode_update') if entity.is_class_set(mask): self.scripts.call('on_class_update') if entity.is_name_set(mask): self.scripts.call('on_name_update') if entity.is_multiplier_set(mask): self.scripts.call('on_multiplier_update') if entity.is_level_set(mask): self.scripts.call('on_level_update') if entity.is_equipment_set(mask): self.scripts.call('on_equipment_update') if entity.is_skill_set(mask): self.scripts.call('on_skill_update') if entity.is_appearance_set(mask): self.scripts.call('on_appearance_update') if entity.is_charged_mp_set(mask): self.scripts.call('on_charged_mp_update') if entity.is_flags_set(mask): self.scripts.call('on_flags_update') if entity.is_consumable_set(mask): self.scripts.call('on_consumable_update')
def on_entity_packet(self, packet): if self.entity_data is None: self.entity_data = create_entity_data() self.server.entities[self.entity_id] = self.entity_data mask = packet.update_entity(self.entity_data) self.entity_data.mask |= mask if not self.has_joined and getattr(self.entity_data, 'name', None): self.on_join() return self.scripts.call('on_entity_update', mask=mask) # XXX clean this up if entity.is_pos_set(mask): self.scripts.call('on_pos_update') if entity.is_mode_set(mask): self.scripts.call('on_mode_update') if entity.is_class_set(mask): self.scripts.call('on_class_update') if entity.is_name_set(mask): self.scripts.call('on_name_update') if entity.is_multiplier_set(mask): self.scripts.call('on_multiplier_update') if entity.is_level_set(mask): self.scripts.call('on_level_update') if entity.is_equipment_set(mask): self.scripts.call('on_equipment_update') if entity.is_skill_set(mask): self.scripts.call('on_skill_update') if entity.is_appearance_set(mask): self.scripts.call('on_appearance_update') if entity.is_charged_mp_set(mask): self.scripts.call('on_charged_mp_update')
def on_entity_packet(self, packet): if self.entity_data is None: self.entity_data = create_entity_data() self.factory.entities[self.entity_id] = self.entity_data packet.update_entity(self.entity_data) if not self.has_joined and self.entity_data.name: self.on_join() self.has_joined = True
def on_entity_packet(self, packet): if self.entity_data is None: self.entity_data = create_entity_data() self.server.entities[self.entity_id] = self.entity_data mask = packet.update_entity(self.entity_data) self.entity_data.mask |= mask if not self.has_joined and getattr(self.entity_data, 'name', None): self.on_join() return self.scripts.call('on_entity_update', mask=mask) # XXX clean this up if entity.is_pos_set(mask): self.scripts.call('on_pos_update') if entity.is_mode_set(mask): self.scripts.call('on_mode_update') if entity.is_class_set(mask): self.scripts.call('on_class_update') if entity.is_name_set(mask): self.scripts.call('on_name_update') if entity.is_multiplier_set(mask): self.scripts.call('on_multiplier_update') if entity.is_level_set(mask): self.scripts.call('on_level_update') if entity.is_equipment_set(mask): self.scripts.call('on_equipment_update') if entity.is_skill_set(mask): self.scripts.call('on_skill_update') if entity.is_appearance_set(mask): self.scripts.call('on_appearance_update') if entity.is_charged_mp_set(mask): self.scripts.call('on_charged_mp_update') if entity.is_flags_set(mask): self.scripts.call('on_flags_update') if entity.is_consumable_set(mask): self.scripts.call('on_consumable_update')