def _send_auth_challenge(self): auth_seed = int.from_bytes(os.urandom(4), "little") self.shared_data["auth_seed"] = auth_seed packet_data = self.AUTH_CHALLENGE_BIN.pack(auth_seed) packet = WorldPacket(OpCode.SMSG_AUTH_CHALLENGE, packet_data) self.send_packet(packet)
def _get_verify_login_packet(self): """ Send the unique (?) SMSG_LOGIN_VERIFY_WORLD packet. """ with self.conn.player.lock: response_data = self.VERIFY_WORLD_BIN.pack( self.conn.player.map_id, self.conn.player.position.x, self.conn.player.position.y, self.conn.player.position.z, self.conn.player.position.o) return WorldPacket(OpCode.SMSG_LOGIN_VERIFY_WORLD, response_data)
def _get_success_packet(self): data = self.RESPONSE_SUCC_BIN.pack( AuthSessionResponseCode.AUTH_OK.value, 0, # BillingTimeRemaining 0, # BillingPlanFlags 0 # BillingTimeRested ) return WorldPacket(OpCode.SMSG_AUTH_RESPONSE, data)
def _get_response_packet(self, unit): name_bytes = unit.name.encode("utf8") + b"\x00" name_len = len(name_bytes) response_struct = Struct(self.RESPONSE_FMT.format(name_len=name_len)) response_data = response_struct.pack(self.guid, name_bytes, unit.get_race(), unit.get_gender(), unit.get_class()) return WorldPacket(OpCode.SMSG_NAME_QUERY_RESPONSE, response_data)
def _get_response_packet(self, manager_code): response_code = { 0: CharDeleteResponseCode.SUCCESS, 1: CharDeleteResponseCode.FAILED }.get(manager_code, 1) LOG.debug("Character deletion status: " + str(response_code.name)) response_data = self.RESPONSE_BIN.pack(response_code.value) return WorldPacket(OpCode.SMSG_CHAR_DELETE, response_data)
def _get_response_packet(self, manager_code): response_code = { 0: CharCreateResponseCode.SUCCESS, 1: CharCreateResponseCode.FAILED, 2: CharCreateResponseCode.NAME_IN_USE, 3: CharCreateResponseCode.ERROR }.get(manager_code, 1) LOG.debug("Character creation status: " + str(response_code.name)) response_data = self.RESPONSE_BIN.pack(response_code.value) return WorldPacket(OpCode.SMSG_CHAR_CREATE, response_data)
def _get_tutorial_flags_packet(self): """ I agree with myself that I do not want to support tutorials. """ tutorial_data = b"\xFF" * 32 return WorldPacket(OpCode.SMSG_TUTORIAL_FLAGS, tutorial_data)
def _get_account_data_md5_packet(self): """ Send this dummy packet to trigger account data sync. """ md5s = AccountDataManager.get_account_data_md5(self.conn.account) md5s_data = b"".join(md5s) return WorldPacket(OpCode.SMSG_ACCOUNT_DATA_MD5, md5s_data)
def to_packet(self): return WorldPacket(OpCode.SMSG_CHANNEL_NOTIFY, self.to_bytes())
def _get_packet(self, num_chars, data): response_data = self.RESPONSE_HEADER_BIN.pack(num_chars) + data return WorldPacket(OpCode.SMSG_CHAR_ENUM, response_data)
def to_packet(self): return WorldPacket(OpCode.SMSG_MESSAGECHAT, self.to_bytes())
def _get_logout_complete_packet(self): return WorldPacket(OpCode.SMSG_LOGOUT_COMPLETE)
def _get_logout_response_packet(self, can_logout): response_value = 0 if can_logout else 1 response_data = self.LOGOUT_RESPONSE_BIN.pack(response_value, 0) return WorldPacket(OpCode.SMSG_LOGOUT_RESPONSE, response_data)
def _get_failure_packet(self, error_code): data = self.RESPONSE_FAIL_BIN.pack(error_code.value) return WorldPacket(OpCode.SMSG_AUTH_RESPONSE, data)
def process(self): seconds = int(time.time()) response_data = self.RESPONSE_BIN.pack(seconds) response = WorldPacket(OpCode.SMSG_QUERY_TIME_RESPONSE, response_data) return None, response
def process(self): pong_packet = WorldPacket(OpCode.SMSG_PONG, self.packet) return None, pong_packet