void ProtocolGame::sendLoginPacket(uint timestamp, uint8 unknown) { OutputMessage oMsg; oMsg.addU8(Proto::ClientEnterGame); oMsg.addU16(Proto::OsLinux); oMsg.addU16(Proto::ClientVersion); oMsg.addU8(0); // first RSA byte must be 0 // xtea key generateXteaKey(); oMsg.addU32(m_xteaKey[0]); oMsg.addU32(m_xteaKey[1]); oMsg.addU32(m_xteaKey[2]); oMsg.addU32(m_xteaKey[3]); oMsg.addU8(0); // is gm set? oMsg.addString(m_accountName); oMsg.addString(m_characterName); oMsg.addString(m_accountPassword); oMsg.addU32(timestamp); oMsg.addU8(unknown); // complete the 128 bytes for rsa encryption with zeros oMsg.addPaddingBytes(128 - (29 + m_accountName.length() + m_characterName.length() + m_accountPassword.length())); // encrypt with RSA Rsa::encrypt((char*)oMsg.getBuffer() + 6 + oMsg.getMessageSize() - 128, 128, Proto::RSA); send(oMsg); enableXteaEncryption(); }
void ProtocolLogin::sendLoginPacket() { OutputMessage oMsg; oMsg.addU8(Proto::ClientEnterAccount); oMsg.addU16(Proto::OsLinux); oMsg.addU16(Proto::ClientVersion); oMsg.addU32(g_thingsType.getSignature()); // data signature oMsg.addU32(g_sprites.getSignature()); // sprite signature oMsg.addU32(Proto::PicSignature); // pic signature oMsg.addU8(0); // first RSA byte must be 0 // xtea key generateXteaKey(); oMsg.addU32(m_xteaKey[0]); oMsg.addU32(m_xteaKey[1]); oMsg.addU32(m_xteaKey[2]); oMsg.addU32(m_xteaKey[3]); oMsg.addString(m_accountName); oMsg.addString(m_accountPassword); // complete the 128 bytes for rsa encryption with zeros oMsg.addPaddingBytes(128 - (21 + m_accountName.length() + m_accountPassword.length())); Rsa::encrypt((char*)oMsg.getBuffer() + InputMessage::DATA_POS + oMsg.getMessageSize() - 128, 128, Proto::RSA); send(oMsg); enableXteaEncryption(); recv(); }
void ProtocolGame::sendUseItemEx(const Position& fromPos, int fromThingId, int fromStackpos, const Position& toPos, int toThingId, int toStackpos) { OutputMessage oMsg; oMsg.addU8(Proto::ClientUseTwoObjects); addPosition(oMsg, fromPos); oMsg.addU16(fromThingId); oMsg.addU8(fromStackpos); addPosition(oMsg, toPos); oMsg.addU16(toThingId); oMsg.addU8(toStackpos); send(oMsg); }
void ProtocolGame::sendUseItemWith(const Position& fromPos, int itemId, int fromStackpos, const Position& toPos, int toThingId, int toStackpos) { OutputMessage msg; msg.addU8(Proto::ClientUseItemWith); addPosition(msg, fromPos); msg.addU16(itemId); msg.addU8(fromStackpos); addPosition(msg, toPos); msg.addU16(toThingId); msg.addU8(toStackpos); send(msg); }
void ProtocolGame::sendTalk(Otc::SpeakType speakType, int channelId, const std::string& receiver, const std::string& message) { if(message.length() > 255 || message.length() <= 0) return; int serverSpeakType = Proto::translateSpeakTypeToServer(speakType); OutputMessage msg; msg.addU8(Proto::ClientTalk); msg.addU8(serverSpeakType); switch(serverSpeakType) { case Proto::ServerSpeakPrivate: case Proto::ServerSpeakPrivateRed: msg.addString(receiver); break; case Proto::ServerSpeakChannelYellow: case Proto::ServerSpeakChannelRed: msg.addU16(channelId); break; } msg.addString(message); send(msg); }
void ProtocolGame::sendOpenChannel(int channelId) { OutputMessage oMsg; oMsg.addU8(Proto::ClientOpenChannel); oMsg.addU16(channelId); send(oMsg); }
void ProtocolGame::sendTalk(const std::string& speakTypeDesc, int channelId, const std::string& receiver, const std::string& message) { if(message.length() > 255 || message.length() <= 0) return; int speakType = Proto::translateSpeakTypeDesc(speakTypeDesc); OutputMessage oMsg; oMsg.addU8(Proto::ClientTalk); oMsg.addU8(speakType); switch(speakType) { case Proto::SpeakPrivate: case Proto::SpeakPrivateRed: oMsg.addString(receiver); break; case Proto::SpeakChannelYellow: case Proto::SpeakChannelRed: oMsg.addU16(channelId); break; } oMsg.addString(message); send(oMsg); }
void ProtocolGame::sendRequestQuestLine(int questId) { OutputMessage msg; msg.addU8(Proto::ClientRequestQuestLine); msg.addU16(questId); send(msg); }
void ProtocolGame::sendLeaveChannel(int channelId) { OutputMessage msg; msg.addU8(Proto::ClientLeaveChannel); msg.addU16(channelId); send(msg); }
void ProtocolGame::sendGetQuestLine(int questId) { OutputMessage oMsg; oMsg.addU8(Proto::ClientGetQuestLine); oMsg.addU16(questId); send(oMsg); }
void ProtocolGame::sendInspectNpcTrade(int itemId, int count) { OutputMessage msg; msg.addU8(Proto::ClientInspectNpcTrade); msg.addU16(itemId); msg.addU8(count); send(msg); }
void ProtocolGame::sendLookInShop(int thingId, int count) { OutputMessage oMsg; oMsg.addU8(Proto::ClientInspectNpcTrade); oMsg.addU16(thingId); oMsg.addU8(count); send(oMsg); }
void ProtocolGame::sendLook(const Position& position, int thingId, int stackpos) { OutputMessage msg; msg.addU8(Proto::ClientLook); addPosition(msg, position); msg.addU16(thingId); msg.addU8(stackpos); send(msg); }
void ProtocolGame::sendRotateItem(const Position& pos, int thingId, int stackpos) { OutputMessage msg; msg.addU8(Proto::ClientRotateItem); addPosition(msg, pos); msg.addU16(thingId); msg.addU8(stackpos); send(msg); }
void ProtocolGame::sendRotateItem(const Position& pos, int thingId, int stackpos) { OutputMessage oMsg; oMsg.addU8(Proto::ClientTurnObject); addPosition(oMsg, pos); oMsg.addU16(thingId); oMsg.addU8(stackpos); send(oMsg); }
void ProtocolGame::sendRequestTrade(const Position& pos, int thingId, int stackpos, uint playerId) { OutputMessage oMsg; oMsg.addU8(Proto::ClientTradeObject); addPosition(oMsg, pos); oMsg.addU16(thingId); oMsg.addU8(stackpos); oMsg.addU32(playerId); send(oMsg); }
void ProtocolGame::sendUseOnCreature(const Position& pos, int thingId, int stackpos, uint creatureId) { OutputMessage msg; msg.addU8(Proto::ClientUseOnCreature); addPosition(msg, pos); msg.addU16(thingId); msg.addU8(stackpos); msg.addU32(creatureId); send(msg); }
void ProtocolGame::sendUseItem(const Position& position, int itemId, int stackpos, int index) { OutputMessage msg; msg.addU8(Proto::ClientUseItem); addPosition(msg, position); msg.addU16(itemId); msg.addU8(stackpos); msg.addU8(index); send(msg); }
void ProtocolGame::sendSellItem(int itemId, int subType, int amount, bool ignoreEquipped) { OutputMessage msg; msg.addU8(Proto::ClientSellItem); msg.addU16(itemId); msg.addU8(subType); msg.addU8(amount); msg.addU8(ignoreEquipped ? 0x01 : 0x00); send(msg); }
void ProtocolGame::sendPlayerSale(int thingId, int count, int amount, bool ignoreEquipped) { OutputMessage oMsg; oMsg.addU8(Proto::ClientSellObject); oMsg.addU16(thingId); oMsg.addU8(count); oMsg.addU8(amount); oMsg.addU8(ignoreEquipped ? 0x01 : 0x00); send(oMsg); }
void ProtocolGame::sendPlayerPurchase(int thingId, int count, int amount, bool ignoreCapacity, bool buyWithBackpack) { OutputMessage oMsg; oMsg.addU8(Proto::ClientBuyObject); oMsg.addU16(thingId); oMsg.addU8(count); oMsg.addU8(amount); oMsg.addU8(ignoreCapacity ? 0x01 : 0x00); oMsg.addU8(buyWithBackpack ? 0x01 : 0x00); send(oMsg); }
void ProtocolGame::sendMove(const Position& fromPos, int thingId, int stackpos, const Position& toPos, int count) { OutputMessage msg; msg.addU8(Proto::ClientMove); addPosition(msg, fromPos); msg.addU16(thingId); msg.addU8(stackpos); addPosition(msg, toPos); msg.addU8(count); send(msg); }
void ProtocolGame::sendBuyItem(int itemId, int subType, int amount, bool ignoreCapacity, bool buyWithBackpack) { OutputMessage msg; msg.addU8(Proto::ClientBuyItem); msg.addU16(itemId); msg.addU8(subType); msg.addU8(amount); msg.addU8(ignoreCapacity ? 0x01 : 0x00); msg.addU8(buyWithBackpack ? 0x01 : 0x00); send(msg); }
void ProtocolGame::sendThrow(const Position& fromPos, int thingId, int stackpos, const Position& toPos, int count) { OutputMessage oMsg; oMsg.addU8(Proto::ClientMoveObject); addPosition(oMsg, fromPos); oMsg.addU16(thingId); oMsg.addU8(stackpos); addPosition(oMsg, toPos); oMsg.addU8(count); send(oMsg); }
void ProtocolGame::sendRuleVilation(const std::string& target, int reason, int action, const std::string& comment, const std::string& statement, int statementId, bool ipBanishment) { OutputMessage msg; msg.addU8(Proto::ClientRuleViolation); msg.addString(target); msg.addU8(reason); msg.addU8(action); msg.addString(comment); msg.addString(statement); msg.addU16(statementId); msg.addU8(ipBanishment); send(msg); }
void ProtocolGame::sendSetOutfit(const Outfit& outfit) { OutputMessage oMsg; oMsg.addU8(Proto::ClientSetOutfit); oMsg.addU16(outfit.getId()); oMsg.addU8(outfit.getHead()); oMsg.addU8(outfit.getBody()); oMsg.addU8(outfit.getLegs()); oMsg.addU8(outfit.getFeet()); oMsg.addU8(outfit.getAddons()); send(oMsg); }
void ProtocolGame::sendChangeOutfit(const Outfit& outfit) { OutputMessage msg; msg.addU8(Proto::ClientChangeOutfit); msg.addU16(outfit.getId()); msg.addU8(outfit.getHead()); msg.addU8(outfit.getBody()); msg.addU8(outfit.getLegs()); msg.addU8(outfit.getFeet()); msg.addU8(outfit.getAddons()); send(msg); }
void ProtocolGame::addPosition(OutputMessage& msg, const Position& position) { msg.addU16(position.x); msg.addU16(position.y); msg.addU8(position.z); }