int main(void) { puts("RIOT network stack example application"); _init_interface(); _send_packet(); return 0; }
void world_session::HandlePlayerJoinOpcode(world_packet &recvPacket) { uint8 data[0x20]; if(!m_player) m_player = new player(*this); try { recvPacket.read<uint8>(); recvPacket.read<uint8>(); recvPacket.read((uint8*)(&m_player->m_player_info), 0x61); m_player->m_player_info.name[0x18] = 0; recvPacket.read(data, 0x1F); recvPacket.read((uint8*)m_player->m_player_info.username, 9); m_player->m_player_info.username[8] = 0; recvPacket.read(m_player->m_player_info.unk1, 0x0C); recvPacket.read(data, 0x03); } catch(ByteBuffer::error &) { //sLog.outDetail("Incomplete join packet"); return; } m_status = STATUS_LOGGEDIN; world::instance->add_player(m_player); object_mgr::instance->add_object(m_player); m_unk++; //m_player->SetName(name); world_packet packet(0xA9, 0x80, m_endpoint, 0x5); packet << (uint8)0x0C; packet << (uint32)1; send_packet(packet, false); _SendFullTimestampOpcode(); _SendJoinDataOpcode(); _SendGameSettingsOpcode(); _SendGameSettings2Opcode(); _SendNewPlayerOpcode(); m_unk++; _SendUseMapOpcode(); packet.set_opcode(0x04); packet.set_account_id(0x00); packet.set_unk(0x00); packet.clear(); send_packet(packet, false, false); _send_packet(m_send_packet); //clear the send buffer m_timestamp++; _SendPartialTimestampOpcode(); }
void world_session::send_packet(world_packet& packet, bool ifReady, bool changeUnk) { if (!ifReady || !is_player_loading()) { if(changeUnk) packet.set_unk(m_unk); if(m_send_packet.get_opcode() && (packet.get_unk() != m_send_packet.get_unk() || packet.get_account_id() != m_send_packet.get_account_id())) // || packet.GetAccountId() != sendPacket.GetAccountId() _send_packet(m_send_packet); if(!m_send_packet.get_opcode()) { m_send_packet.set_opcode(packet.get_opcode()); m_send_packet.set_account_id(packet.get_account_id()); m_send_packet.set_unk(packet.get_unk()); } else m_send_packet << (uint8)packet.get_opcode(); if(packet.size() > 0) m_send_packet.append(packet.contents(), packet.size()); } }
void Sender::Impl::_send_start() { lansink::Packet packet; _prepare_packet(packet, lansink::Packet_Kind_START, m_nPointer); _send_packet(packet); }
void Sender::Impl::_send_pause() { lansink::Packet packet; _prepare_packet(packet, lansink::Packet_Kind_PAUSE, m_nPointer); _send_packet(packet); }
bool world_session::update() { world_packet* packet = NULL; // Always send new timestamp if(m_status == STATUS_LOGGEDIN) { m_timestamp++; _SendPartialTimestampOpcode(); } if(m_receive_queue.empty()) { // this is strange, let's resend our packets as necessary world_packet sendpacket; switch(m_status) { case STATUS_AUTHED: sendpacket.initialize(0x14, 0, m_endpoint, 0); _send_packet(sendpacket); break; case STATUS_CONFIRMED: break; } } while(!m_receive_queue.empty() || packet) { if(!packet) { packet = m_receive_queue.front(); m_receive_queue.pop(); } // do some shit try { opcode_table_map::const_iterator iter = object_mgr::instance->get_opcode_table().find( packet->get_opcode() ); if (packet->get_opcode() == 0 && packet->get_account_id() == 0xFF) //let's assume that this will always be FF 00 00 { switch(m_status) { case STATUS_AUTHED: // client's port is not set in stone until now m_endpoint = packet->get_endpoint(); HandleJoinConfirmation(); break; case STATUS_CONFIRMED: break; } } else if (iter == object_mgr::instance->get_opcode_table().end()) { /*sLog.outError( "SESSION: received unhandled opcode %s (0x%.4X)", LookupName(packet->GetOpcode(), g_worldOpcodeNames), packet->GetOpcode());*/ } else { if (iter->second.status == STATUS_LOGGEDIN && m_player) { (this->*iter->second.handler)(*packet); } else if (iter->second.status == STATUS_AUTHED) { //m_playerRecentlyLogout = false; (this->*iter->second.handler)(*packet); } //if(!m_playerRecentlyLogout) //{ /*sLog.outError( "SESSION: received unexpected opcode %s (0x%.4X)", LookupName(packet->GetOpcode(), g_worldOpcodeNames), packet->GetOpcode());*/ //} } if(packet->rpos() == packet->size()) { delete packet; packet = NULL; } else packet->set_opcode(packet->read<uint8>()); } catch(ByteBuffer::error &) { delete packet; packet = NULL; } } // send our massive packet now if(m_send_packet.size() > 0) _send_packet(m_send_packet); // this will cause the socket to destroy this session if(m_player_logging_out) return false; return true; }