本文整理汇总了C++中raknet::BitStream::GetNumberOfUnreadBits方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::GetNumberOfUnreadBits方法的具体用法?C++ BitStream::GetNumberOfUnreadBits怎么用?C++ BitStream::GetNumberOfUnreadBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::BitStream
的用法示例。
在下文中一共展示了BitStream::GetNumberOfUnreadBits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleUserLogin
/*
Update 24.08.2015 Xiphoseer
This function now contains all logic to
- Read the 53-01-00-00 LOGIN_REQUEST packet
- Verify the login credentials using the database
- Sending the response to the client
- Register the client in SessionsTable and UsersPool
*/
void HandleUserLogin(RakPeerInterface* rakServer, Packet* packet, CONNECT_INFO* cfg) {
//Make the packet data accessible via a bit stream
RakNet::BitStream *data = new RakNet::BitStream(packet->data, packet->length, false);
unsigned char packetID;
data->Read(packetID);
unsigned short networkType;
data->Read(networkType);
unsigned long packetType;
data->Read(packetType);
unsigned char pad;
data->Read(pad);
//Check if the correct packet is passed to this function
if (networkType == RemoteConnection::AUTH && packetType == AuthPacketID::LOGIN_REQUEST) {
// Read all available data from the login packet
// and log it, TODO: transform that into debug log messages
std::wstring username = PacketTools::ReadFromPacket(data, 33);
std::wstring password = PacketTools::ReadFromPacket(data, 41);
Logger::log("AUTH", "LOGIN", "Username: " + UtfConverter::ToUtf8(username), LOG_DEBUG);
std::vector<char> pwcv(password.size(), '*');
std::string pwcs(pwcv.begin(), pwcv.end());
Logger::log("AUTH", "LOGIN", "Password: " + pwcs, LOG_DEBUG);
unsigned short language_id;
data->Read(language_id);
Logger::log("AUTH", "LOGIN", "Language: " + std::to_string(language_id), LOG_ALL);
unsigned char uk1;
data->Read(uk1);
Logger::log("AUTH", "LOGIN", "Unknown?: " + std::to_string(uk1), LOG_ALL);
std::wstring process_info = PacketTools::ReadFromPacket(data, 256);
std::wstring graphics_info = PacketTools::ReadFromPacket(data, 128);
Logger::log("AUTH", "LOGIN", UtfConverter::ToUtf8(process_info), LOG_ALL);
Logger::log("AUTH", "LOGIN", UtfConverter::ToUtf8(graphics_info), LOG_ALL);
unsigned long num_processors, type_processor;
data->Read(num_processors);
data->Read(type_processor);
unsigned short level_processor, revision_processor;
data->Read(level_processor);
data->Read(revision_processor);
Logger::log("AUTH", "LOGIN", "Processor: " +
std::to_string(num_processors) + ", " +
std::to_string(type_processor) + ", " +
std::to_string(level_processor) + ", " +
std::to_string(revision_processor),
LOG_ALL
);
unsigned long uk2;
data->Read(uk2);
Logger::log("AUTH", "LOGIN", "Unknown?: " + std::to_string(uk2), LOG_ALL);
if (data->GetNumberOfUnreadBits() > 0){
unsigned long os_major_version, os_minor_version, os_build_number, os_platform_id;
data->Read(os_major_version);
data->Read(os_minor_version);
data->Read(os_build_number);
data->Read(os_platform_id);
Logger::log("AUTH", "LOGIN", "OS: " +
std::to_string(os_major_version) + '.' +
std::to_string(os_minor_version) + '.' +
std::to_string(os_build_number), LOG_ALL);
Logger::log("AUTH", "LOGIN", "OSP: " + std::to_string(os_platform_id), LOG_ALL);
}
std::string usernameA, passwordA;
usernameA = UtfConverter::ToUtf8(username);
passwordA = UtfConverter::ToUtf8(password);
//Validating the input
//Set default values
UserSuccess currentLoginStatus = UserSuccess::SUCCESS;
//Ref<User> user = NULL;
//query the account id of the associated with the username from the database
unsigned int accountid = AccountsTable::getAccountID(usernameA);
if (accountid == 0){
//If the query return 0, no user was found
currentLoginStatus = UserSuccess::INVALID_USER;
}else{
//check if the password is correct
bool passwordCorrect = AccountsTable::checkPassword(passwordA, accountid);
AccountAccessInfo info = AccountsTable::getAccessInfo(accountid);
if (info.locked || info.banned){
if (info.banned){
Logger::log("USER", "LOGIN", "User is BANNED");
currentLoginStatus = UserSuccess::BANNED;
}
else{
Logger::log("USER", "LOGIN", "User is LOCKED");
currentLoginStatus = UserSuccess::LOCKED;
}
}
else{
if (passwordCorrect){
//.........这里部分代码省略.........