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


C++ USER::SetAccount方法代码示例

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


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

示例1: Execute

UINT LWAskCharLoginHandler::Execute(LWAskCharLogin* pPacket, Player* pPlayer )
{
    __ENTER_FUNCTION
    
    Assert(pPacket);
    
    ASK_LOGINSTATUS    AskStatus  = pPacket->GetAskStatus();
    ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ;
    Assert(pServerPlayer);

    USER* pUser;

    GUID_t    CharGuid = pPacket->GetPlayerGUID();

    if(AskStatus == ALS_ASKSTATUS)
    {
        
        WLRetCharLogin Msg;
        pUser = g_pOnlineUser->FindUser( CharGuid ) ;
        if(pUser) //用户存在,直接返回成功消息
        {
            UINT uUserStatus = pUser->UserStatus();

            switch (uUserStatus)
            {
            case US_CRASH_DOWN:
            case US_WAIT_SHUTDOWN://服务器Crash
                {
                    Msg.SetResult(ASKCHARLOGIN_SERVER_STOP);
                    Msg.SetAccount(pPacket->GetAccount());
                    Msg.SetPlayerID(pPacket->GetPlayerID());
                    Msg.SetPlayerGUID(CharGuid);
                    Msg.SetHoldStatus(TRUE);
                    Msg.SetPlayerServerID(pUser->GetServerID());
                    pServerPlayer->SendPacket(&Msg);

                    Log::SaveLog( WORLD_LOGFILE, "LWAskCharLoginHandler...User Hold,CharGUID = %X",CharGuid) ;
                    return PACKET_EXE_CONTINUE;
                }
                break;
            case US_NONE:
            case US_NORMAL:
            case US_OFFLINE:
            case US_CHANGESCENE:
            case US_HOLDUSERDATA:
                {
                    pUser->SetKey( pPacket->GetUserKey() );
                    Msg.SetResult(ASKCHARLOGIN_SUCCESS);
                    Msg.SetAccount(pPacket->GetAccount());
                    Msg.SetPlayerID(pPacket->GetPlayerID());
                    Msg.SetPlayerGUID(CharGuid);
                    Msg.SetHoldStatus(TRUE);
                    Msg.SetPlayerServerID(pUser->GetServerID());
                    pServerPlayer->SendPacket(&Msg);
                    Log::SaveLog( WORLD_LOGFILE, "LWAskCharLoginHandler...User Hold,CharGUID = %X",CharGuid) ;
                    return PACKET_EXE_CONTINUE;
                }
                break;
            default:
                {
                    Log::SaveLog( WORLD_LOGFILE, "LWAskCharLoginHandler...UNKNOW ERROR,CharGUID = %X, Status=%d",CharGuid,uUserStatus) ;
                    return PACKET_EXE_ERROR;    
                }
                break;
            }
        }
        else //用户不存在
        {
            Msg.SetResult(ASKCHARLOGIN_LOADDB_ERROR);
            Msg.SetAccount(pPacket->GetAccount());
            Msg.SetPlayerID(pPacket->GetPlayerID());
            Msg.SetPlayerGUID(CharGuid);
            Msg.SetHoldStatus(FALSE);
            pServerPlayer->SendPacket(&Msg);
            Log::SaveLog( WORLD_LOGFILE, "LWAskCharLoginHandler...No User,CharGUID = %X",CharGuid) ;
            return PACKET_EXE_CONTINUE;    
            

        }
    }
    else if(AskStatus == ALS_SENDDATA)
    {
        pUser = g_pOnlineUser->FindUser( CharGuid ) ;
        if( pUser )
        {//如果此用户存在
            Log::SaveLog( WORLD_LOGFILE, "LWAskCharLoginHandler...Char Exist! CharGUID = %X",CharGuid) ;
            return PACKET_EXE_CONTINUE;
        }

        ID_t    ServerID = g_Config.SceneID2ServerID(pPacket->GetUserData()->m_Human.m_StartScene);

        ServerPlayer* pFindPlayer = g_pServerManager->GetServerPlayer( ServerID ) ;
        if( pFindPlayer==NULL ) //服务器维护
        {
            WLRetCharLogin Msg;
            Msg.SetResult(ASKCHARLOGIN_SERVER_STOP);
            Msg.SetAccount(pPacket->GetAccount());
            Msg.SetPlayerID(pPacket->GetPlayerID());
            Msg.SetPlayerGUID(CharGuid);
            Msg.SetHoldStatus(FALSE);
//.........这里部分代码省略.........
开发者ID:gangzi4494,项目名称:web-pap,代码行数:101,代码来源:LWAskCharLoginHandler.cpp


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