当前位置: 首页>>代码示例>>C++>>正文


C++ CUser::Get_Name方法代码示例

本文整理汇总了C++中CUser::Get_Name方法的典型用法代码示例。如果您正苦于以下问题:C++ CUser::Get_Name方法的具体用法?C++ CUser::Get_Name怎么用?C++ CUser::Get_Name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUser的用法示例。


在下文中一共展示了CUser::Get_Name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Handle_User_Update_Packet

	void CAuthModule::Handle_User_Update_Packet( CUserUpdatePacket* pPacket, CConnection* pConnection ) {
		
		// Get user object
		CUser* pUser = Get_User_By_Name( pPacket->m_Username );
		
		if( !pUser ) {
			pUser = Create_New_User( pPacket->m_UserType );
				
			return;
		}
		
		pUser->Serialize_From(*pPacket->Get_ByteStream() );
		
		DLog(LOG_AUTH, "Updated User object for: %s\n", pUser->Get_Name().c_str());
		
	}
开发者ID:Gilgalal,项目名称:divercities,代码行数:16,代码来源:CAuthModule.cpp

示例2: Handle_User_Update_Request_Packet

	void CAuthModule::Handle_User_Update_Request_Packet( CUserUpdateRequestPacket* pPacket, CConnection* pConnection ) {
		// Get the user object
		CUser* pUser = Get_User_By_Name( pPacket->m_Username );
		if( !pUser ) {
			// We don't have this user's info
			// TODO pass request upstream
			return;
		}

		// Create packet
		CUserUpdatePacket* pUpdatePacket = (CUserUpdatePacket*)m_pNetworkModule->Create_Packet( PACKET_USERUPDATE );
		if( !pUpdatePacket ) {
			Log(LOG_AUTH, "Could not create CUserUpdatePacket to service CUserUpdateRequestPacket\n");
			return;
		}
		
		pUpdatePacket->m_pUser = pUser;
		pUpdatePacket->m_Username = pUser->Get_Name();
		
		pConnection->Send_Packet( pUpdatePacket );
		
		m_pNetworkModule->Destroy_Packet( pUpdatePacket );
		
	}
开发者ID:Gilgalal,项目名称:divercities,代码行数:24,代码来源:CAuthModule.cpp

示例3: Handle_Login_Packet

	void CAuthModule::Handle_Login_Packet( CLoginPacket* pPacket, CConnection* pConnection ) {
		// Make sure username is in all lowercase
		std::string Name = pPacket->Get_Username();
		std::transform(Name.begin(), Name.end(), Name.begin(), ::tolower);
	
		// This will try loading from disk if it isn't already in mem
		CUser* pUser = Get_User_By_Name( Name );
		
		if( !pUser ) {
			// Not loaded in mem, can't loaded from disk
	
			// Check if we are allowing new users
			CStateModule* pStateModule = (CStateModule*)GETMODULE(MODULE_STATE);
			CState* pState = pStateModule->Get_Current_State();
			
			// Only Master server can create new users
			if( (CDCEngine::GetInstance()->Get_Driver_Mode() == MODE_MASTER) && (pState->Allow_New_User()) ) {
			
				DLog(LOG_AUTH, "Creating new user: %s\n", Name.c_str());
				
				CPlayer* pPlayer = NULL;

				// Create the new User obj
				pPlayer = (CPlayer*)Create_New_User( pPacket->Get_UserType() );
				pPlayer->m_Name = Name;
				pPlayer->m_Password = pPacket->Get_Password();
				
				// Establish link between connection and user
				pPlayer->m_pConnection = pConnection;
				pConnection->m_pUser = pPlayer;

				// Add to loaded users map
				m_UsersByName.insert( USER_MAP_NAME_PAIR(pPlayer->Get_Name(),pPlayer) );
				m_UsersByID.insert( USER_MAP_ID_PAIR(pPlayer->Get_UserID(), pPlayer) );
				
				// Send Ident
				Send_Ident( pConnection );
				
				// Notify engine of new login
				CDCEngine::GetInstance()->On_New_Login( pPlayer );
				
				return;
			}
			// Disconnect this connection
			Log(LOG_DRIVER, "Not allowing new users, disconnecting: %s:%d\n", pConnection->Get_Address().c_str(), pConnection->Get_Port());
			m_pNetworkModule->Disconnect_Connection( pConnection->Get_ID(), DR_NO_NEW_USERS );
			
			return;
		}
		
		// User is loaded
		DLog(LOG_AUTH, "User logged in new: %s\n", pUser->Get_Name().c_str());

		// Link connection and user
		pUser->m_pConnection = pConnection;
		pConnection->m_pUser = pUser;
		
		// Send Ident
		Send_Ident( pConnection );
		
		// Notify Engine
		CDCEngine::GetInstance()->On_New_Login( pUser );
		
		return;
	}
开发者ID:Gilgalal,项目名称:divercities,代码行数:65,代码来源:CAuthModule.cpp


注:本文中的CUser::Get_Name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。