本文整理汇总了C++中OutputMessage::AddU16方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputMessage::AddU16方法的具体用法?C++ OutputMessage::AddU16怎么用?C++ OutputMessage::AddU16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputMessage
的用法示例。
在下文中一共展示了OutputMessage::AddU16方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseFirstPacket
bool ProtocolLogin::parseFirstPacket(NetworkMessage& msg)
{
if(g_game.getGameState() == GAME_STATE_SHUTDOWN){
getConnection()->closeConnection();
return false;
}
uint32_t clientip = getConnection()->getIP();
/*uint16_t clientos =*/ msg.GetU16();
uint16_t version = msg.GetU16();
msg.SkipBytes(12);
if(version <= 760){
disconnectClient(0x0A, STRING_CLIENT_VERSION);
}
if(!RSA_decrypt(g_otservRSA, msg)){
getConnection()->closeConnection();
return false;
}
uint32_t key[4];
key[0] = msg.GetU32();
key[1] = msg.GetU32();
key[2] = msg.GetU32();
key[3] = msg.GetU32();
enableXTEAEncryption();
setXTEAKey(key);
uint32_t accnumber = msg.GetU32();
std::string password = msg.GetString();
if(!accnumber){
disconnectClient(0x0A, "You must enter your account number.");
return false;
}
if(version < CLIENT_VERSION_MIN || version > CLIENT_VERSION_MAX){
disconnectClient(0x0A, STRING_CLIENT_VERSION);
return false;
}
if(g_game.getGameState() == GAME_STATE_STARTUP){
disconnectClient(0x0A, "Gameworld is starting up. Please wait.");
return false;
}
if(g_bans.isIpDisabled(clientip)){
disconnectClient(0x0A, "Too many connections attempts from this IP. Try again later.");
return false;
}
if(g_bans.isIpBanished(clientip)){
disconnectClient(0x0A, "Your IP is banished!");
return false;
}
uint32_t serverip = serverIPs[0].first;
for(uint32_t i = 0; i < serverIPs.size(); i++){
if((serverIPs[i].first & serverIPs[i].second) == (clientip & serverIPs[i].second)){
serverip = serverIPs[i].first;
break;
}
}
Account account = IOAccount::instance()->loadAccount(accnumber);
if(!(accnumber != 0 && account.accnumber == accnumber &&
passwordTest(password, account.password))){
g_bans.addLoginAttempt(clientip, false);
disconnectClient(0x0A, "Please enter a valid account number and password.");
return false;
}
g_bans.addLoginAttempt(clientip, true);
OutputMessage* output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
//Add MOTD
std::stringstream motd;
output->AddByte(0x14);
motd << g_config.getNumber(ConfigManager::MOTD_NUM) << "\n";
motd << g_config.getString(ConfigManager::MOTD);
output->AddString(motd.str());
//Add char list
output->AddByte(0x64);
output->AddByte((uint8_t)account.charList.size());
std::list<std::string>::iterator it;
for(it = account.charList.begin(); it != account.charList.end(); it++){
output->AddString((*it));
output->AddString(g_config.getString(ConfigManager::WORLD_NAME));
output->AddU32(serverip);
output->AddU16(g_config.getNumber(ConfigManager::PORT));
}
//Add premium days
output->AddU16(account.premiumDays);//output->AddU16(0);
OutputMessagePool::getInstance()->send(output);
getConnection()->closeConnection();
//.........这里部分代码省略.........