Example #1
0
int KSimulateRelay::DoDeleteRoleRespond(DWORD dwPacketIdentity, int nRespondCode)
{
    int                         nResult             = false;
    int                         nRetCode            = false;
    IKG_Buffer*                 piSendBuffer        = false;
    size_t                      uSendBufferSize     = 0;
    R2G_DELETE_ROLE_RESPOND*    pRespond            = NULL;

    KGLOG_PROCESS_ERROR(m_piSocket);

    uSendBufferSize = sizeof(R2G_DELETE_ROLE_RESPOND);

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)uSendBufferSize);
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pRespond = (R2G_DELETE_ROLE_RESPOND*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRespond);

    pRespond->byProtocol    = r2g_delete_role_respond;
    pRespond->nPlayerIndex  = dwPacketIdentity;
    pRespond->byCode      = nRespondCode;
    pRespond->dwRoleID      = 0;

    nRetCode = m_piSocket->Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return nResult;
}
Example #2
0
int KSimulateRelay::DoAccountExchangeRequest()
{
    BOOL                            bResult  = false;
    BOOL                            bRetCode = false;
    IKG_Buffer*                     piBuffer = NULL;
    R2G_ACCOUNT_EXCHANGE_REQUEST*   pRequest = NULL;
    const char* pszAccountName      = "0000"; 

//    DWORD dwRoleID = 3333; 
    assert(pszAccountName);

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(R2G_ACCOUNT_EXCHANGE_REQUEST));
    KGLOG_PROCESS_ERROR(piBuffer);

    pRequest = (R2G_ACCOUNT_EXCHANGE_REQUEST*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRequest);

    pRequest->byProtocol = r2g_account_exchange_request;

    bRetCode = m_piSocket->Send(piBuffer);
    KGLOG_PROCESS_ERROR(bRetCode);

    KGLogPrintf(KGLOG_INFO, "Relay, DoAccountExchangeRequest\n");

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #3
0
int KSimulateRelay::DoFreezeCoinRequest()
{
    BOOL                            bResult  = false;
    BOOL                            bRetCode = false;
    IKG_Buffer*                     piBuffer = NULL;
    R2G_FREEZE_COIN_REQUEST*        pRequest = NULL;
    const char* pszAccountName      = "0000"; 

    DWORD   dwRoleID = 3333; 

    assert(pszAccountName);

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(R2G_FREEZE_COIN_REQUEST));
    KGLOG_PROCESS_ERROR(piBuffer);

    pRequest = (R2G_FREEZE_COIN_REQUEST*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRequest);

    pRequest->byProtocol = r2g_freeze_coin_request;

    strncpy(pRequest->szAccount, pszAccountName, sizeof(pRequest->szAccount));
    pRequest->szAccount[sizeof(pRequest->szAccount) - 1] = '\0';

    pRequest->dwRequestID = dwRoleID;

    bRetCode = m_piSocket->Send(piBuffer);
    KGLOG_PROCESS_ERROR(bRetCode);

    KGLogPrintf(KGLOG_INFO, "Relay, DoFreezeCoinRequest\n");

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #4
0
int KSimulateRelay::DoPingRespond()
{
    int                         nResult                         = false;
    int                         nRetCode                        = false;
    IKG_Buffer*                 piSendBuffer                    = NULL;
    BYTE*                       pbySendBuffer                   = NULL;
    tagProtocolHeader*          ptagProtocolHeader              = NULL;

    KGLOG_PROCESS_ERROR(m_piSocket);

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)(sizeof(R2G_PING_SIGNAL)));
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pbySendBuffer = (BYTE*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pbySendBuffer);

    ptagProtocolHeader = (tagProtocolHeader*)pbySendBuffer;
    ptagProtocolHeader->cProtocol = r2g_ping_signal;

    nRetCode = m_piSocket->Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(nRetCode);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return nResult;
}
Example #5
0
BOOL KLogClient::DoPingSignal()
{
    BOOL				bResult			= false;
    BOOL				bRetCode		= false;
    DWORD               dwNowTime       = 0;
    IKG_Buffer*         piSendBuffer    = NULL;
    G2L_PING_SIGNAL*    pPingSingal		= NULL;

    dwNowTime = KG_GetTickCount();

    KG_PROCESS_ERROR(dwNowTime >= m_dwNextPingTime);

    m_dwNextPingTime = dwNowTime + 1000 * m_nPingCycle;

    piSendBuffer = KG_MemoryCreateBuffer(sizeof(G2L_PING_SIGNAL));
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pPingSingal = (G2L_PING_SIGNAL*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pPingSingal);

    pPingSingal->wProtocolID = g2l_ping_signal;

    bRetCode = Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(bRetCode);   

    bResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return bResult;
}
Example #6
0
BOOL KApexProxy::DoRoleLogout(DWORD dwRoleID)
{
    BOOL                bResult     = false;
    APEX_ROLE_LOGOUT*   pRoleLogout = NULL;
    IKG_Buffer*         piBuffer    = NULL;
    KRole*              pRole       = NULL;
    size_t              nNameLen    = 0;

    pRole = g_pSO3GameCenter->m_RoleManager.GetRole(dwRoleID);
    KGLOG_PROCESS_ERROR(pRole);

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(APEX_ROLE_LOGOUT));
    KGLOG_PROCESS_ERROR(piBuffer);

    pRoleLogout = (APEX_ROLE_LOGOUT*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRoleLogout);

    pRoleLogout->cMsgId  = 'G';
    pRoleLogout->nSendId = (int)dwRoleID;

    strncpy(pRoleLogout->szName, pRole->m_szName, sizeof(pRoleLogout->szName));
    pRoleLogout->szName[sizeof(pRoleLogout->szName) - 1] = '\0';

    Send(piBuffer);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #7
0
BOOL KLogServerAgency::Ping()
{
    BOOL                bResult      = false;
    BOOL                bRetCode     = false;
    IKG_Buffer*         piSendBuffer = NULL;
    tagProtocolHeader2* pPing        = NULL;

    KG_PROCESS_ERROR(g_pSO3GameCenter->m_nTimeNow >= m_nNextPingTime);

    m_nNextPingTime = g_pSO3GameCenter->m_nTimeNow + m_nPingCycle;

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(tagProtocolHeader2));
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pPing = (tagProtocolHeader2*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pPing);

    pPing->ProtocolType = LOGC2S_PING;
    pPing->ulIdentity   = 0;

    bRetCode = Send(piSendBuffer);
    KG_PROCESS_ERROR(bRetCode);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return bResult;
}
Example #8
0
int KSimulateRelay::DoSetProtocolVersion(int nLowerVersion, int nUpperVersion)
{
    int                             nResult             = false;
    int                             nRetCode            = false;
    IKG_Buffer*                     piSendBuffer        = false;
    size_t                          uSendBufferSize     = 0;
    R2G_SET_GAME_WORLD_VERSION*     pRespond            = NULL;

    KG_PROCESS_ERROR(m_piSocket);

    uSendBufferSize = sizeof(R2G_SET_GAME_WORLD_VERSION);

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)uSendBufferSize);
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pRespond = (R2G_SET_GAME_WORLD_VERSION*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRespond);

    pRespond->byProtocol    = r2g_set_game_world_version;
    pRespond->nLowerVersion = nLowerVersion;
    pRespond->nUpperVersion = nUpperVersion;

    nRetCode = m_piSocket->Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return nResult;
}
Example #9
0
int KSimulateRelay::OnQueryAccountState(BYTE* pbyData, size_t uDataLen)
{
    int                          nResult             = false;
    int                          nRetCode            = false;
    IKG_Buffer*                  piSendBuffer        = NULL;
    G2R_QUERY_ACCOUNT_STATE*     pQueryAccountState  = (G2R_QUERY_ACCOUNT_STATE*)pbyData;
    R2G_SYNC_ACCOUNT_STATE*      pSyncAccountState   = NULL;

    pQueryAccountState->szAccount[sizeof(pQueryAccountState->szAccount) - 1] = '\0';

    piSendBuffer = KG_MemoryCreateBuffer(sizeof(R2G_SYNC_ACCOUNT_STATE));
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pSyncAccountState = (R2G_SYNC_ACCOUNT_STATE*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pSyncAccountState);

    pSyncAccountState->byProtocol   = r2g_sync_account_state;
    pSyncAccountState->nPlayerIndex = pQueryAccountState->nPlayerIndex;    
    pSyncAccountState->bOnline      = m_RelayConfig.nUserOnlineResult;

    nRetCode = m_piSocket->Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return nResult;
}
Example #10
0
BOOL KMapCopy::Load(BYTE* pbyData, size_t uDataLen)
{
    BOOL        bResult         = false;
    BOOL        bRetCode        = false;
    BYTE*       pbyOffset       = pbyData;
    size_t      uLeftSize       = uDataLen;
    DWORD       dwPlayerCount   = 0;
    DWORD       dwSceneDataLen  = 0;
    IKG_Buffer* piSceneData     = NULL;
    BYTE*       pbySceneData    = NULL;
    
    KGLOG_PROCESS_ERROR(uLeftSize >= sizeof(DWORD));
    dwPlayerCount = *(DWORD*)pbyOffset;

    pbyOffset += sizeof(DWORD);
    uLeftSize -= sizeof(DWORD);
    
    for (DWORD i = 0; i < dwPlayerCount; i++)
    {
        KGLOG_PROCESS_ERROR(uLeftSize >= sizeof(DWORD));
        m_PlayerList.insert(*(DWORD*)pbyOffset);

        pbyOffset += sizeof(DWORD);
        uLeftSize -= sizeof(DWORD);
    }

    KGLOG_PROCESS_ERROR(uLeftSize >= sizeof(DWORD));
    dwSceneDataLen = *(DWORD*)pbyOffset;

    pbyOffset += sizeof(DWORD);
    uLeftSize -= sizeof(DWORD);
    
    KGLOG_PROCESS_ERROR(uLeftSize >= dwSceneDataLen);
    if (dwSceneDataLen > 0)
    {
        piSceneData = KG_MemoryCreateBuffer((unsigned)dwSceneDataLen);
        KGLOG_PROCESS_ERROR(piSceneData);

        pbySceneData = (BYTE*)piSceneData->GetData();
        KGLOG_PROCESS_ERROR(pbySceneData);
        
        memcpy(pbySceneData, pbyOffset, dwSceneDataLen);

        assert(m_piSceneData == NULL);    

        m_piSceneData = piSceneData;
        m_piSceneData->AddRef();
    }

    pbyOffset += dwSceneDataLen;
    uLeftSize -= dwSceneDataLen;

    KGLOG_PROCESS_ERROR(uLeftSize == 0);
    
    bResult = true;
Exit0:
    KG_COM_RELEASE(piSceneData);
    return bResult;
}
Example #11
0
BOOL KLogServerAgency::LogPlayerAction(
    PLAYER_ACTION_TYPE eActionType, unsigned uActionLevel, const char* pszActionTarget,
    const char* pszAccountName, const char* pszRoleName, size_t uCommentSize,
    BYTE* pbyComment
)
{
    BOOL                bResult      = false;
    BOOL                bRetCode     = false;
    size_t              uExtendSize  = 0;
    IKG_Buffer*         piSendBuffer = NULL;
    KGPlayerActionLog*  pLog         = NULL;

    assert(pszActionTarget);
    assert(pszAccountName);
    assert(pszRoleName);

    uExtendSize = uCommentSize ? uCommentSize - 1 : 0;

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)(sizeof(KGPlayerActionLog) + uExtendSize));
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pLog = (KGPlayerActionLog*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pLog);

    pLog->ProtocolType = LOGC2S_LOG_PLAYER_ACTION;
    pLog->ulIdentity   = 0;
    pLog->uActionLevel = uActionLevel;
    pLog->eActionType  = eActionType;

    strncpy(pLog->szActionTarget, pszActionTarget, sizeof(pLog->szActionTarget));
    pLog->szActionTarget[sizeof(pLog->szActionTarget) - 1] = '\0';

    strncpy(pLog->szAccountName, pszAccountName, sizeof(pLog->szAccountName));
    pLog->szAccountName[sizeof(pLog->szAccountName) - 1] = '\0';

    strncpy(pLog->szRoleName, pszRoleName, sizeof(pLog->szRoleName));
    pLog->szRoleName[sizeof(pLog->szRoleName) - 1] = '\0';

    pLog->uCommentSize = (unsigned)uCommentSize;
    if (pbyComment)
    {
        memcpy(pLog->pbyData, pbyComment, uCommentSize);
    }

    bRetCode = Send(piSendBuffer);
    KG_PROCESS_ERROR(bRetCode);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return bResult;
}
Example #12
0
BOOL KLogClient::Connect()
{
    BOOL bResult    = false;
    BOOL bRetCode   = false;
    KG_SocketConnector Connector;
    struct timeval     TimeVal;
    IKG_SocketStream*	    piSocketStream = NULL;
    IKG_Buffer*             piPackage       = NULL;
    G2L_HANDSHAKE_REQUEST*  pHandshake      = NULL;

    piSocketStream = Connector.Connect(m_szLogServerAddr, m_nRelayPort);
    KG_PROCESS_ERROR(piSocketStream);

    TimeVal.tv_sec  = 0;
    TimeVal.tv_usec = 10000;

    bRetCode = piSocketStream->SetTimeout(&TimeVal);
    KGLOG_PROCESS_ERROR(bRetCode);

    m_bSocketError        = false;
    //m_nWorldIndex         = 0;

    m_nLastSendPacketTime = g_pSO3World->m_nCurrentTime;

    // 初始化的一些操作,注意多线程
    piPackage = KG_MemoryCreateBuffer((unsigned)sizeof(G2L_HANDSHAKE_REQUEST));
    KGLOG_PROCESS_ERROR(piPackage);

    pHandshake = (G2L_HANDSHAKE_REQUEST*)piPackage->GetData();
    KGLOG_PROCESS_ERROR(pHandshake);

    pHandshake->wProtocolID         = g2l_handshake_request;
    pHandshake->nServerTime         = (int)time(NULL);
    pHandshake->nServerIndexInGC    = g_pSO3World->m_nServerIndexInGC;

    bRetCode = piSocketStream->Send(piPackage);
    KGLOG_PROCESS_ERROR(bRetCode == 1);

    // 小心: 这里不能写成 "m_piSocket = piSocket; m_piSocket->AddRef(); ", 那样会导致线程安全隐患
    piSocketStream->AddRef();
    m_piSocketStream = piSocketStream;

    KGLogPrintf( KGLOG_INFO, "Connect to log server %s:%d ... ... [OK]", m_szLogServerAddr, m_nRelayPort );

    bResult = true;
Exit0:
    KG_COM_RELEASE(piPackage);
    KG_COM_RELEASE(piSocketStream);
    return bResult;
}
Example #13
0
BOOL KLogServerAgency::LoginServer(const char cszIP[], int nPort, const char cszIdentity[])
{
    BOOL                bResult      = false;
    BOOL                bRetCode     = false;
    IKG_Buffer*         piSendBuffer = NULL;
    KGCSLogServerLogin* pLogin       = NULL;
    KG_SocketConnector  Connector;
    struct timeval      TimeVal;

    assert(m_piSocket == NULL);

    m_piSocket = Connector.Connect(cszIP, nPort);
    KG_PROCESS_ERROR(m_piSocket);

    TimeVal.tv_sec  = 2;
    TimeVal.tv_usec = 0;

    bRetCode = m_piSocket->SetTimeout(&TimeVal);
    KGLOG_PROCESS_ERROR(bRetCode);

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(KGCSLogServerLogin));
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pLogin = (KGCSLogServerLogin*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pLogin);

    pLogin->ProtocolType = LOGC2S_LOG_LOGIN;
    pLogin->ulIdentity   = 0;

    strncpy(pLogin->szGatewayName, cszIdentity, sizeof(pLogin->szGatewayName));
    pLogin->szGatewayName[sizeof(pLogin->szGatewayName) - 1] = '\0';

    bRetCode = Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(bRetCode);

    bResult = true;
Exit0:
    KGLogPrintf(
        KGLOG_INFO, "Connect to log server %s:%d ... ... [%s]",
        cszIP, nPort, bResult ? "OK" : "Failed"
    );
    if (!bResult)
    {
        KG_COM_RELEASE(m_piSocket);
    }
    KG_COM_RELEASE(piSendBuffer);
    return bResult;
}
Example #14
0
int KSimulateRelay::OnQueryRoleList(BYTE* pbyData, size_t uDataLen)
{
    int                     nResult             = false;
    BYTE*                   pbyPos              = NULL;
    IKG_Buffer*             piSendBuffer        = NULL;
    KROLE_LIST_INFO*        pBaseData           = NULL;
    int                     nRoleCount          = 0;
    G2R_QUERY_ROLE_LIST*    pQueryRoleList      = (G2R_QUERY_ROLE_LIST*)pbyData;

    pQueryRoleList->szAccount[sizeof(pQueryRoleList->szAccount) - 1] = '\0';

    nRoleCount = m_RelayConfig.nGetRoleListCount;
    if (nRoleCount > 0)
    {
        piSendBuffer = KG_MemoryCreateBuffer(sizeof(KROLE_LIST_INFO) * nRoleCount);
        KGLOG_PROCESS_ERROR(piSendBuffer);

        pbyPos = (BYTE*)piSendBuffer->GetData();
        KGLOG_PROCESS_ERROR(pbyPos);
    }
    
    if (nRoleCount == 0)
    {
        DoSyncRoleList(pQueryRoleList->nPlayerIndex, 0, 0, NULL);
    }
    else
    {
        for (int nRoleIndex = 0; nRoleIndex < nRoleCount; nRoleIndex++)
        {
            pBaseData = (KROLE_LIST_INFO*)pbyPos;
            pBaseData->BaseInfo.byLevel = 0x3;
            pBaseData->BaseInfo.cRoleType = '6';
            pBaseData->BaseInfo.CurrentPos.byFaceDirection = '6';
            pBaseData->dwPlayerID = nRoleIndex;
            strncpy(pBaseData->szAccount, "AccountYeah", sizeof(pBaseData->szAccount));
            strncpy(pBaseData->szRoleName, "RoleNameyaah", sizeof(pBaseData->szRoleName));

            DoSyncRoleList(pQueryRoleList->nPlayerIndex, nRoleIndex + 1, nRoleCount, (KROLE_LIST_INFO*)pbyPos);
            pbyPos += sizeof(KROLE_LIST_INFO);
        }
    }

    nResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return nResult;
}
Example #15
0
int KSimulateRelay::DoSyncRoleList(int nPlayerIndex, int nRoleIndex, int nRoleCount, KROLE_LIST_INFO* pBaseData)
{
    int                         nResult             = false;
    int                         nRetCode            = false;
    IKG_Buffer*                 piSendBuffer        = false;
    size_t                      uSendBufferSize     = 0;
    R2G_SYNC_ROLE_LIST*         pRespond            = NULL;

    KGLOG_PROCESS_ERROR(m_piSocket);

    uSendBufferSize = sizeof(R2G_SYNC_ROLE_LIST);
    if (nRoleCount > 0)
    {
        ASSERT(pBaseData);
        ASSERT(nRoleIndex > 0 && nRoleIndex <= nRoleCount);
        uSendBufferSize += sizeof(KROLE_LIST_INFO);
    }

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)uSendBufferSize);
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pRespond = (R2G_SYNC_ROLE_LIST*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRespond);

    pRespond->byProtocol    = r2g_sync_role_list;
    pRespond->nPlayerIndex  = nPlayerIndex;
    pRespond->nRoleIndex    = nRoleIndex;
    pRespond->nRoleCount    = nRoleCount;
    //pRespond->nFreezeTime   = 0;
    pRespond->dwRoleID      = ERROR_ID;

    if (pBaseData != NULL)
    {
        pRespond->dwRoleID = pBaseData->dwPlayerID;
        memcpy(pRespond->byData, pBaseData, sizeof(KROLE_LIST_INFO));
    }

    nRetCode = m_piSocket->Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return nResult;
}
Example #16
0
void KGatewayEyes::SendCustomInfo()
{
    l2e_update_custom_info* pInfo               = NULL;
    size_t                  uStrLen             = 0;
    IKG_Buffer*             piBuffer            = NULL;
    int                     nConnectiontotal    = 0;
    DWORD                   dwAccountVerifyTime = 0;
    int                     nWaitingQueuePlayer = 0;

    nConnectiontotal    = m_pPlayerManager->GetConnectionCount();
    dwAccountVerifyTime = m_pPaysysAgency->GetAccountVerifyTimeCost();
    nWaitingQueuePlayer = m_pQueueManager->GetWaitingQueuePlayerCount();

    piBuffer = KG_MemoryCreateBuffer(MAX_CUSTOM_INFO_PAK);
    KGLOG_PROCESS_ERROR(piBuffer);

    pInfo = (l2e_update_custom_info*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(piBuffer);

    pInfo->wProtocol	= l2e_header_def;
    pInfo->wServer		= 0;
    pInfo->wSubProtocol = l2e_update_custom_info_def;

    uStrLen = snprintf(
        (char*)pInfo->byData, MAX_CUSTOM_INFO_PAK - sizeof(l2e_update_custom_info),
        "-------------------------------------\n"
        "Connection total ... .... %d\n"
        "Waiting queue ... ... ... %d\n"
        "Account verify respond .. %lu ms\n"
        "-------------------------------------\n",
        nConnectiontotal,
        nWaitingQueuePlayer,
        dwAccountVerifyTime
    );
    KGLOG_PROCESS_ERROR(uStrLen > 0);
    KGLOG_PROCESS_ERROR(uStrLen < MAX_CUSTOM_INFO_PAK - sizeof(l2e_update_custom_info));

    pInfo->uDataLen = uStrLen;

    m_Stream.PutPack(pInfo, sizeof(l2e_update_custom_info) + uStrLen);

Exit0:
    KG_COM_RELEASE(piBuffer);
    return;
}
Example #17
0
BOOL KLogClient::DoFlowRecord(int nFlowRecordMainType, int nFlowRecordAssistType, const char cszRecordInfomation[], ...)
{
    BOOL    bResult	        = false;
    BOOL    bRetCode        = false;
    int     nBufferLen      = 0;
    char    szBuffer[1024]  = {'\0'};
    IKG_Buffer* piBuffer    = NULL;
    G2L_FLOW_RECORD* pPak   = NULL;

    va_list marker;
    va_start(marker, cszRecordInfomation);
    bRetCode = vsnprintf(szBuffer + nBufferLen, sizeof(szBuffer) - 1 - nBufferLen, cszRecordInfomation, marker);
    va_end(marker);
    KGLOG_PROCESS_ERROR(bRetCode != -1);
    szBuffer[sizeof(szBuffer) - 1] = '\0';
    nBufferLen += bRetCode;
	
	KGLOG_PROCESS_ERROR(nBufferLen < sizeof(szBuffer));
	szBuffer[nBufferLen] = '\0';
    ++nBufferLen;

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(G2L_FLOW_RECORD) + nBufferLen);
    KGLOG_PROCESS_ERROR(piBuffer);
 
    pPak = (G2L_FLOW_RECORD*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pPak);
 
    pPak->wProtocolID           = g2l_flow_record;
    pPak->wFlowRecordMainType   = (WORD)nFlowRecordMainType;
    pPak->wFlowRecordAssistType = (WORD)nFlowRecordAssistType;
    pPak->wInfomationLength     = (WORD)nBufferLen;
 
    memcpy(pPak->byInfomation, szBuffer, nBufferLen);
 
    bRetCode = Send(piBuffer);
    KGLOG_PROCESS_ERROR(bRetCode);

    bResult	= true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #18
0
int KSimulateRelay::DoCreateRoleRespond(int nSucceed, int nPlayerIndex)
{
    int                         nResult             = false;
    int                         nRetCode            = false;
    IKG_Buffer*                 piSendBuffer        = false;
    size_t                      uSendBufferSize     = 0;
    R2G_CREATE_ROLE_RESPOND*    pRespond            = NULL;

    KGLOG_PROCESS_ERROR(m_piSocket);

    uSendBufferSize = sizeof(R2G_CREATE_ROLE_RESPOND);

    if (nSucceed == eCreateRoleSucceed)
    {
        uSendBufferSize += sizeof(KROLE_LIST_INFO); 
    }

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)uSendBufferSize);
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pRespond = (R2G_CREATE_ROLE_RESPOND*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRespond);

    pRespond->byProtocol    = r2g_create_role_respond;
    pRespond->nPlayerIndex  = nPlayerIndex;
    //pRespond->byCode        = (BYTE)(nSucceed ? eCreateRoleSucceed : eCreateRoleInvalidRoleName);
    pRespond->byCode        = (BYTE)nSucceed;
    pRespond->dwRoleID      = m_RelayConfig.nGetRoleListCount;
    if (nSucceed == eCreateRoleSucceed)
    {
        memset(pRespond->byData, 0, sizeof(KROLE_LIST_INFO));
    }

    nRetCode = m_piSocket->Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return nResult;
}
Example #19
0
int KSimulateRelay::DoReplyLoginData(DWORD dwPacketIdentity, DWORD dwRoleID, int nRespondCode)
{
    int                         nResult             = false;
    int                         nRetCode            = false;
    IKG_Buffer*                 piSendBuffer        = false;
    size_t                      uSendBufferSize     = 0;
    R2G_GAME_LOGIN_RESPOND*     pRespond            = NULL;
    GUID                        SimulateGuid;

    KGLOG_PROCESS_ERROR(m_piSocket);

    uSendBufferSize = sizeof(R2G_GAME_LOGIN_RESPOND);

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)uSendBufferSize);
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pRespond = (R2G_GAME_LOGIN_RESPOND*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRespond);

    //虚拟数据
    SimulateGuid.Data1 = 1;
    SimulateGuid.Data2 = 1;
    SimulateGuid.Data3 = 1;

    pRespond->byProtocol    = r2g_game_login_respond;
    pRespond->byCode        = (BYTE)nRespondCode;
    pRespond->dwIP          = 1;
    pRespond->dwRoleID      = dwRoleID;
    pRespond->dwQueueID     = m_nQueueID;
    pRespond->guid          = SimulateGuid;
    pRespond->nPlayerIndex  = dwPacketIdentity;
    pRespond->nPort         = 1;

    nRetCode = m_piSocket->Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return nResult;
}
Example #20
0
int KSimulateRelay::DoSyncNewbieMaps(int nPlayerIndex)
{
    int                         nResult                 = false;
    int                         nRetCode                = 0;
    IKG_Buffer*                 piSendBuffer            = NULL;
    R2G_SYNC_NEWBIE_MAPS*       pRespond                = NULL;
    KNEWBIE_MAP_COPY_INFO*      pMapCopyInfo            = NULL;
    int                         nSimulateMapCopyCount   = m_RelayConfig.nMapCount;

    KG_PROCESS_ERROR(m_piSocket);

    KG_COM_RELEASE(piSendBuffer);

    piSendBuffer = KG_MemoryCreateBuffer((unsigned)(sizeof(R2G_SYNC_NEWBIE_MAPS) + sizeof(KNEWBIE_MAP_COPY_INFO) * nSimulateMapCopyCount));
    KGLOG_PROCESS_ERROR(piSendBuffer);

    pRespond = (R2G_SYNC_NEWBIE_MAPS*)piSendBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRespond);

    pRespond->byProtocol    = r2g_sync_newbie_maps;
    pRespond->nPlayerIndex  = nPlayerIndex;
    pRespond->dwMapID       = 1;//默认ID为1
    pRespond->nCopyCount    = nSimulateMapCopyCount;

    if (nSimulateMapCopyCount > 0)
    {
        pMapCopyInfo = (KNEWBIE_MAP_COPY_INFO*)((BYTE*)pRespond + sizeof(R2G_SYNC_NEWBIE_MAPS));
        KGLOG_PROCESS_ERROR(pMapCopyInfo);

        memset(pMapCopyInfo, 0, sizeof(KNEWBIE_MAP_COPY_INFO) * nSimulateMapCopyCount);
    }

    nRetCode = m_piSocket->Send(piSendBuffer);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    nResult = true;
Exit0:
    KG_COM_RELEASE(piSendBuffer);
    return nResult;
}
Example #21
0
BOOL KLogClient::DoPlayerLog(const char cszPlayerLogInfo[], ...)
{
    BOOL    bResult	        = false;
    BOOL    bRetCode        = false;
    int     nBufferLen      = 0;
    char    szBuffer[1024]  = {'\0'};
    IKG_Buffer* piBuffer    = NULL;
    G2L_OLD_PLAYER_LOG* pPak   = NULL;

    va_list marker;
    va_start(marker, cszPlayerLogInfo);
    bRetCode = vsnprintf(szBuffer + nBufferLen, sizeof(szBuffer) - 1 - nBufferLen, cszPlayerLogInfo, marker);
    va_end(marker);
    KGLOG_PROCESS_ERROR(bRetCode != -1);
    szBuffer[sizeof(szBuffer) - 1] = '\0';
    nBufferLen += bRetCode;

    KGLOG_PROCESS_ERROR(nBufferLen < sizeof(szBuffer));
    szBuffer[nBufferLen] = '\0';
    ++nBufferLen;

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(G2L_OLD_PLAYER_LOG) + nBufferLen);
    KGLOG_PROCESS_ERROR(piBuffer);

    pPak = (G2L_OLD_PLAYER_LOG*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pPak);

    pPak->wProtocolID           = g2l_player_log;
    pPak->wInfomationLength     = (WORD)nBufferLen;

    memcpy(pPak->byInfomation, szBuffer, nBufferLen);

    bRetCode = Send(piBuffer);
    KGLOG_PROCESS_ERROR(bRetCode);

    bResult	= true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #22
0
BOOL KApexProxy::DoPingSignal()
{
    BOOL                bResult     = false;
    APEX_PING_SIGNAL*   pPingSignal = NULL;
    IKG_Buffer*         piBuffer    = NULL;

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(APEX_PING_SIGNAL));
    KGLOG_PROCESS_ERROR(piBuffer);

    pPingSignal = (APEX_PING_SIGNAL*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pPingSignal);

    pPingSignal->cMsgId  = 'C';
    pPingSignal->nSendId = 0;

    Send(piBuffer);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #23
0
BOOL KApexProxy::DoSyncUserData(DWORD dwRoleID, BYTE* pbyData, size_t uDataSize)
{
    BOOL                    bResult         = false;
    APEX_SYNC_USER_DATA*    pSyncUserData   = NULL;
    IKG_Buffer*             piBuffer        = NULL;

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(APEX_SYNC_USER_DATA) + uDataSize);
    KGLOG_PROCESS_ERROR(piBuffer);

    pSyncUserData = (APEX_SYNC_USER_DATA*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pSyncUserData);

    pSyncUserData->cMsgId   = 'T';
    pSyncUserData->nSendId  = dwRoleID;
    memcpy(pSyncUserData->byData, pbyData, uDataSize);

    Send(piBuffer);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #24
0
BOOL KApexProxy::DoReturnClientRet(DWORD dwRoleID, int nRetCode)
{
    BOOL                    bResult         = false;
    APEX_CLIENT_RETCODE*    pClientRetCode  = NULL;
    IKG_Buffer*             piBuffer        = NULL;

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(APEX_CLIENT_RETCODE));
    KGLOG_PROCESS_ERROR(piBuffer);

    pClientRetCode = (APEX_CLIENT_RETCODE*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pClientRetCode);

    pClientRetCode->cMsgId      = 'R';
    pClientRetCode->nSendId     = (int)dwRoleID;
    pClientRetCode->nRetCode    = nRetCode;

    Send(piBuffer);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #25
0
int KClient::SendPackToServer(unsigned int uLinkId, const void *pData, unsigned int uLen)
{
	ASSERT(pData && uLen);
	int nRet = guard_err;
	do 
	{
		if (uLinkId >= (unsigned int)m_nMaxConnCount)
		{
			ASSERT(FALSE);
			break;
		}
		IKG_SocketStream* pConnection = m_ppConnections[uLinkId];
		if (!pConnection)
		{
		//	ASSERT(FALSE);
			break;
		}
		IKG_Buffer *pBuffer = KG_MemoryCreateBuffer(uLen);
		if (!pBuffer)
		{
			ASSERT(FALSE);
			break;
		}
		memcpy(pBuffer->GetData(), pData, uLen);
		INT nResult = pConnection->Send(pBuffer);
		pBuffer->Release();
		if (nResult != 1)
		{
			OnConnectionClose(uLinkId);
			pConnection->Release();
			break;
		}
		nRet = fseye_success;
	}
	while(0);
	return nRet;
}
Example #26
0
BOOL KSimulateRelay::DoSetChargeFlagRequest()
{
    BOOL                            bResult  = false;
    BOOL                            bRetCode = false;
    IKG_Buffer*                     piBuffer = NULL;
    R2G_SET_CHARGE_FLAG_REQUEST*    pRequest = NULL;
    const char* pszAccountName      = "0000"; 
    DWORD dwRoleID = 3333; 
    DWORD dwLastLoginIP = 123456; 
    int nChargeFlag = 2;
    assert(pszAccountName);

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(R2G_SET_CHARGE_FLAG_REQUEST));
    KGLOG_PROCESS_ERROR(piBuffer);

    pRequest = (R2G_SET_CHARGE_FLAG_REQUEST*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRequest);

    pRequest->byProtocol = r2g_set_charge_flag_request;

    strncpy(pRequest->szAccount, pszAccountName, sizeof(pRequest->szAccount));
    pRequest->szAccount[sizeof(pRequest->szAccount) - 1] = '\0';

    pRequest->dwRoleID      = dwRoleID;
    pRequest->dwLastLoginIP = dwLastLoginIP;
    pRequest->nChargeFlag   = nChargeFlag;

    bRetCode = m_piSocket->Send(piBuffer);
    KGLOG_PROCESS_ERROR(bRetCode);

    KGLogPrintf(KGLOG_INFO, "Relay, DoSetChargeFlagRequest\n");

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #27
0
BOOL KSimulateRelay::DoChangeExtPointRequest()
{
    BOOL                            bResult  = false;
    BOOL                            bRetCode = false;
    IKG_Buffer*                     piBuffer = NULL;
    R2G_CHANGE_EXT_POINT_REQUEST*   pRequest = NULL;
    const char*                     pszAccountName  = "aaaaa"; 
    DWORD                           dwRoleID        = 2233;
    WORD                            wExtPointIndex  = 5; 
    WORD                            wChangeValue    = 4;
    assert(pszAccountName);

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(R2G_CHANGE_EXT_POINT_REQUEST));
    KGLOG_PROCESS_ERROR(piBuffer);

    pRequest = (R2G_CHANGE_EXT_POINT_REQUEST*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRequest);

    pRequest->byProtocol = r2g_change_ext_point_request;

    strncpy(pRequest->szAccount, pszAccountName, sizeof(pRequest->szAccount));
    pRequest->szAccount[sizeof(pRequest->szAccount) - 1] = '\0';

    pRequest->dwRoleID          = dwRoleID;
    pRequest->wExtPointIndex    = wExtPointIndex;
    pRequest->wChangeValue      = wChangeValue;

    bRetCode = m_piSocket->Send(piBuffer);
    KGLOG_PROCESS_ERROR(bRetCode);

    KGLogPrintf(KGLOG_INFO, "Relay, DoChangeExtPointRequest\n");

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #28
0
int KSimulateRelay::DoActivePresentCoodeRequest()
{
    BOOL                                bResult         = false;
    BOOL                                bRetCode        = false;
    IKG_Buffer*                         piBuffer        = NULL;
    R2G_ACTIVE_PRESENT_CODE_REQUEST*    pRequest        = NULL;
    const char*                         pszAccountName  = "0000"; 

    DWORD                               dwRoleID        = 3333; 
    assert(pszAccountName);

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(R2G_ACTIVE_PRESENT_CODE_REQUEST));
    KGLOG_PROCESS_ERROR(piBuffer);

    pRequest = (R2G_ACTIVE_PRESENT_CODE_REQUEST*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pRequest);

    pRequest->byProtocol = r2g_active_present_code_request;

    strncpy(pRequest->szAccount, pszAccountName, sizeof(pRequest->szAccount));
    pRequest->szAccount[sizeof(pRequest->szAccount) - 1] = '\0';
    strncpy(pRequest->szPresentCode, "1234567890", sizeof(pRequest->szPresentCode));
    pRequest->szPresentCode[sizeof(pRequest->szPresentCode) - 1] = '\0';
    pRequest->dwActiveIP    = 999;
    pRequest->dwRoleID      = dwRoleID;

    bRetCode = m_piSocket->Send(piBuffer);
    KGLOG_PROCESS_ERROR(bRetCode);

    KGLogPrintf(KGLOG_INFO, "Relay, DoActivePresentCoodeRequest\n");

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #29
0
BOOL KApexProxy::DoLeaveServer(DWORD dwRoleID, int nGSIndex)
{
    BOOL                bResult         = false;
    APEX_SWITCH_SERVER* pSwitchServer   = NULL;
    IKG_Buffer*         piBuffer        = NULL;

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(APEX_SWITCH_SERVER));
    KGLOG_PROCESS_ERROR(piBuffer);

    pSwitchServer = (APEX_SWITCH_SERVER*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pSwitchServer);

    pSwitchServer->cMsgId       = 'H';
    pSwitchServer->nSendId      = dwRoleID;
    pSwitchServer->nGS_Index    = nGSIndex;
    pSwitchServer->nGS_State    = 1;

    Send(piBuffer);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}
Example #30
0
BOOL KApexProxy::DoSyncRoleIP(DWORD dwRoleID, int nIPAddr)
{
    BOOL                    bResult         = false;
    APEX_SYNC_ROLE_IPADDR*  pSyncRoleIPAddr = NULL;
    IKG_Buffer*             piBuffer        = NULL;

    piBuffer = KG_MemoryCreateBuffer((unsigned)sizeof(APEX_SYNC_ROLE_IPADDR));
    KGLOG_PROCESS_ERROR(piBuffer);

    pSyncRoleIPAddr = (APEX_SYNC_ROLE_IPADDR*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pSyncRoleIPAddr);

    pSyncRoleIPAddr->cMsgId         = 'S';
    pSyncRoleIPAddr->nSendId        = (int)dwRoleID;
    pSyncRoleIPAddr->byUserIPFlag   = 0x01;
    pSyncRoleIPAddr->nIPAddr        = nIPAddr;

    Send(piBuffer);

    bResult = true;
Exit0:
    KG_COM_RELEASE(piBuffer);
    return bResult;
}