Exemple #1
0
int LuaPlayerExecute(Lua_State* L)
{
    int         nRetCode    = false;
    const char* pszRoleName = NULL;
    KRole*      pRole       = NULL;
    const char* pszScript   = NULL;

    nRetCode = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nRetCode == 2);

    pszRoleName = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszRoleName);

    pszScript = Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pszScript);

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

    nRetCode = pRole->IsOnline();
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = g_pSO3GameCenter->m_GameServer.DoGmCommand(
        pRole->m_nConnIndex, pRole->m_dwPlayerID, 
        pszRoleName, pszScript
    );
    KGLOG_PROCESS_ERROR(nRetCode);

Exit0:
    return 0;
}
Exemple #2
0
int KSchemeScriptTable::LuaInteraction_AddParam(Lua_State *L)
{
    const char * pcszName = NULL;
    const char * pcszValue = NULL;
    BOOL bFile = FALSE;
    int nParamCount = Lua_GetTopIndex(L);
    int nRetCode = false;
    KGLOG_PROCESS_ERROR(nParamCount == 2 || nParamCount == 3);

    pcszName = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pcszName);

    pcszValue = Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pcszValue);

    if (nParamCount == 3)
    {
        if (lua_isboolean(L, 3))
            bFile = lua_toboolean(L, 3);
        else
            bFile = (BOOL)(int)lua_tonumber(L, 3);
    }

    nRetCode = g_pSO3UI->m_pInteraction->AddParam(pcszName, pcszValue, bFile);
    KGLOG_PROCESS_ERROR(nRetCode);

    lua_pushboolean(L, TRUE);
    return 1;
Exit0:
    lua_pushboolean(L, FALSE);
    return 1;
}
Exemple #3
0
int KSchemeScriptTable::LuaInteraction_Request(Lua_State *L)
{
    int nRetCode = false;
    const char * pcszName = NULL;
    const char * pcszAddress = NULL;
    const char * pcszObjectName = NULL;
    const char * pcszVerb = NULL;
    int nPort = 0;
    int nParamCount = Lua_GetTopIndex(L);

    KGLOG_PROCESS_ERROR(nParamCount == 5);

    pcszName = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pcszName);

    pcszAddress = Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pcszAddress);

    pcszObjectName = Lua_ValueToString(L, 3);
    KGLOG_PROCESS_ERROR(pcszObjectName);

    pcszVerb = Lua_ValueToString(L, 4);
    KGLOG_PROCESS_ERROR(pcszVerb);

    nPort = (int)Lua_ValueToNumber(L, 5);

    nRetCode = g_pSO3UI->m_pInteraction->Request(pcszName, pcszAddress, pcszObjectName, pcszVerb, nPort, &Interaction_RequestResult);
    KGLOG_PROCESS_ERROR(nRetCode);

    lua_pushboolean(L, TRUE);
    return 1;
Exit0:
    lua_pushboolean(L, FALSE);
    return 1;
}
Exemple #4
0
int LuaRenameConflictTong(Lua_State* L)
{
    BOOL        bRetCode        = false;
    int         nTopIndex       = 0;
    int         nConnIndex      = 0;
    DWORD       dwPlayerID      = ERROR_ID;
    DWORD       dwTongID        = ERROR_ID;
    const char* pszNewName      = NULL;
    size_t      uNewNameLen     = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 4);

    nConnIndex = (int)Lua_ValueToNumber(L, 1);
    KGLOG_PROCESS_ERROR(nConnIndex);

    dwPlayerID = (DWORD)Lua_ValueToNumber(L, 2);
    KGLOG_PROCESS_ERROR(dwPlayerID != ERROR_ID);

    dwTongID = (DWORD)Lua_ValueToNumber(L, 3);
    KGLOG_PROCESS_ERROR(dwTongID != ERROR_ID);

    pszNewName = (const char*)Lua_ValueToString(L, 4);
    KGLOG_PROCESS_ERROR(pszNewName);

    uNewNameLen = strlen(pszNewName);
    KGLOG_PROCESS_ERROR(uNewNameLen < _NAME_LEN);

    g_pSO3GameCenter->m_TongManager.ProcessRenameConflictTong(nConnIndex, dwPlayerID, dwTongID, pszNewName);

Exit0:
    return 0;
}
Exemple #5
0
int LuaSendPrizeInfo(Lua_State* L)
{
    int         nRetCode        = 0;
    int         nTopIndex       = 0;
    DWORD       dwPlayerID      = ERROR_ID;
    KRole*      pRole           = NULL;
    const char* pszType         = NULL;
    int         nValue          = 0;

    nTopIndex =  Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    dwPlayerID = (DWORD)Lua_ValueToNumber(L, 1);
    KGLOG_PROCESS_ERROR(dwPlayerID);

    pszType = (const char*)Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pszType);

    nValue = (int)Lua_ValueToNumber(L, 3);

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

    g_pSO3GameCenter->m_Eyes.DoSendPrizeInfo(pRole->m_pszAccount, pRole->m_szName, dwPlayerID, pszType, nValue);   
Exit0:
    return 0;
}
Exemple #6
0
int LuaFreezeRole(Lua_State* L)
{
    int         nRetCode        = false;
    const char* pszRoleName     = NULL;
    int         nFreezeSecond   = 0;
    time_t      nFreezeEndTime  = 0;
    KRole*      pRole           = NULL;

    nRetCode = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nRetCode == 2);

    pszRoleName = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszRoleName);

    nFreezeSecond = (int)Lua_ValueToNumber(L, 2);

    nFreezeEndTime = g_pSO3GameCenter->m_nTimeNow + nFreezeSecond;

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

    nRetCode = g_pSO3GameCenter->m_RoleManager.FreezeRole(pRole->m_dwPlayerID, nFreezeEndTime);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = g_pSO3GameCenter->m_MiscDB.DoUpdateRoleBlackList(pRole->m_dwPlayerID, nFreezeEndTime);
    KGLOG_PROCESS_ERROR(nRetCode);

Exit0:
    return 0;
}
int KScene::LuaSetTimer(Lua_State* L)
{
    int         nParamCount     = 0;
    DWORD       dwID            = 0;
    int         nTime           = 0;
    const char* pszScriptName   = NULL;
    int         nParam1         = 0;
    int         nParam2         = 0;

    nParamCount = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nParamCount == 4);

    nTime           =   (int)Lua_ValueToNumber(L, 1);
    pszScriptName   =   Lua_ValueToString(L, 2);
    nParam1         =   (int)Lua_ValueToNumber(L, 3);
    nParam2         =   (int)Lua_ValueToNumber(L, 4);

    KGLOG_PROCESS_ERROR(pszScriptName);

    dwID = m_ScriptTimerList.SetTimer(nTime, pszScriptName, nParam1, nParam2);
    KGLOG_PROCESS_ERROR(dwID);

Exit0:
    lua_pushinteger(L, dwID);
    return 1;
}
Exemple #8
0
int KScriptClient::Call(Lua_State* L)
{
    int         nParamCount     = 0;
    const char* pszFunction     = NULL;
    BYTE*       pbyOffset       = m_byParamData;
    BYTE*       pbyTail         = m_byParamData + sizeof(m_byParamData);

	nParamCount = Lua_GetTopIndex(L);
	KGLOG_PROCESS_ERROR(nParamCount >= 1);

	pszFunction = Lua_ValueToString(L, 1);
	KGLOG_PROCESS_ERROR(pszFunction);

    for (int i = 2; i <= nParamCount; i++)
    {
        pbyOffset = LuaPackup(L, i, pbyOffset, (size_t)(pbyTail - pbyOffset));
        KGLOG_PROCESS_ERROR(pbyOffset);
    }

    g_PlayerClient.DoRemoteLuaCall(
        pszFunction, m_byParamData, (size_t)(pbyOffset - m_byParamData)
    );

Exit0:
    return 0;
}
int KHero::LuaSetAISelfDefData(Lua_State* L)
{
    BOOL bResult 	    = false;
    BOOL bRetCode	    = false;
    int	 nTopIndex	    = 0;
    const char* pszKey  = NULL;
    int nNewValue       = 0;
    BOOL bDirectlySet   = false;
    int nDefaultValue   = 0;
    int nCurValue 		= 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 4);

    pszKey        = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszKey);

    nNewValue     = (int)Lua_ValueToNumber(L, 2);
    bDirectlySet  = (BOOL)Lua_ValueToBoolean(L, 3);
    nDefaultValue = (int)Lua_ValueToNumber(L, 4);

    if (bDirectlySet)
        m_dictAISelfDefData[pszKey] = nNewValue;
    else if (m_dictAISelfDefData.find(pszKey) == m_dictAISelfDefData.end())
        m_dictAISelfDefData[pszKey] = nDefaultValue + nNewValue;
    else
        m_dictAISelfDefData[pszKey] += nNewValue;
    
Exit0:
    return 0;
}
Exemple #10
0
int KSystemScriptTable::LuaGetUnpakFileSize(Lua_State* L)
{
    int nRetCode = false;
    int nSize = 0;
    const char * pcszFile = NULL;
    FILE * pFile = NULL;

    KGLOG_PROCESS_ERROR(Lua_GetTopIndex(L) == 1);

    pcszFile = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pcszFile);

    pFile = fopen(pcszFile, "rb");
    KG_PROCESS_ERROR(pFile);

    fseek(pFile, 0, SEEK_END);
    nSize = (int)ftell(pFile);

Exit0:
    if (pFile)
    {
        fclose(pFile);
        pFile = NULL;
    }
    Lua_PushNumber(L, nSize);
    return 1;
}
int KHero::LuaCheckAISelfDefData(Lua_State* L)
{
    int nRetCode = KAI_BRANCH_ERROR;
    BOOL bRetCode	= false;
    int	 nTopIndex	= 0;
    const char* pszKey = NULL;
    int nMinValue = 0;
    int nMaxValue = 0;
    int nCurValue = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    pszKey = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszKey);

    nMinValue = (int)Lua_ValueToNumber(L, 1);
    nMaxValue = (int)Lua_ValueToNumber(L, 2);

    if (m_dictAISelfDefData.find(pszKey) == m_dictAISelfDefData.end())
        goto Exit0;

    nCurValue = m_dictAISelfDefData[pszKey];
    if (nCurValue < nMinValue || nCurValue > nMaxValue)
    {
        nRetCode = KAI_BRANCH_FAILED;
        goto Exit0;
    }

    nRetCode = KAI_BRANCH_SUCCESS;
Exit0:
    Lua_PushNumber(L, nRetCode);
    return 1;
}
Exemple #12
0
int KSystemScriptTable::LuaGetOpenFileName(Lua_State* L)
{
    int nRetCode = false;
    OPENFILENAME OpenFileName;
    char szFile[MAX_PATH];
    szFile[0] = '\0';
    const char * pcszTitle = "Please select a file!";
    int nParamCount = lua_gettop(L);

    if (nParamCount > 0)
        pcszTitle = Lua_ValueToString(L, 1);

    memset(&OpenFileName, 0, sizeof(OPENFILENAME));
    OpenFileName.lStructSize = sizeof(OPENFILENAME);
    OpenFileName.hwndOwner = g_pUI->m_hWnd;
    OpenFileName.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR |
                         OFN_HIDEREADONLY | OFN_EXPLORER | OFN_EXTENSIONDIFFERENT;
    OpenFileName.lpstrTitle = pcszTitle;
    OpenFileName.nMaxFile = sizeof(szFile);
    OpenFileName.lpstrFile = szFile;
    nRetCode = ::GetOpenFileNameA(&OpenFileName);
    KG_PROCESS_ERROR(nRetCode);

Exit0:
    Lua_PushString(L, szFile);
    return 1;
}
Exemple #13
0
int LuaSetStatData(Lua_State* L)
{
    int         nTopIndex    = 0;
    int         nValue       = 0;
    size_t      uNameLen     = 0;
    const char* pszName      = NULL;
    const char* pszLuaPrefix = "lua_";
    char        szName[STAT_DATA_NAME_LEN];

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2);

    pszName = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszName);

    uNameLen = strlen(pszName) + strlen(pszLuaPrefix) + 1;
    KGLOG_PROCESS_ERROR(uNameLen <= sizeof(szName));

    nValue = (int)Lua_ValueToNumber(L, 2);

    snprintf(szName, sizeof(szName), "%s%s", pszLuaPrefix, pszName);
    szName[sizeof(szName) - 1] = '\0';

    g_pSO3GameCenter->m_StatDataManager.SetDataValue(szName, nValue);

Exit0:
    return 0;
}
Exemple #14
0
int LuaCreateTong(Lua_State* L)
{
    int         nResult     = 0;
    BOOL        bRetCode    = false;
    int         nTopIndex   = 0;
    DWORD       dwPlayerID  = 0;
    const char* pszTongName = 0;
    int         nTemplateID = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    dwPlayerID  = (DWORD)Lua_ValueToNumber(L, 1);

    pszTongName = Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pszTongName);

    nTemplateID = (int)Lua_ValueToNumber(L, 3);

    bRetCode = g_pSO3GameCenter->m_TongManager.CreateTong(dwPlayerID, pszTongName, nTemplateID);
    
    Lua_PushBoolean(L, bRetCode);
    nResult = 1;
Exit0:
    return nResult;
}
Exemple #15
0
int KScriptClient::Call(Lua_State* L)
{
    int         nRetCode        = 0;
    int         nParamCount     = 0;
    const char* pszFunction     = NULL;
    BYTE*       pbyOffset       = m_byOriginalBuffer;
    BYTE*       pbyTail         = m_byOriginalBuffer + sizeof(m_byOriginalBuffer);
    size_t      uSrcLen         = 0;
    size_t      uDstLen         = 0;

	nParamCount = Lua_GetTopIndex(L);
	KGLOG_PROCESS_ERROR(nParamCount >= 1);

	pszFunction = Lua_ValueToString(L, 1);
	KGLOG_PROCESS_ERROR(pszFunction);

    for (int i = 2; i <= nParamCount; i++)
    {
        pbyOffset = LuaPackup(L, i, pbyOffset, (size_t)(pbyTail - pbyOffset));
        KGLOG_PROCESS_ERROR(pbyOffset);
    }

    uSrcLen = (size_t)(pbyOffset - m_byOriginalBuffer);

    nRetCode = lzo1x_1_compress(m_byOriginalBuffer, (lzo_uint)uSrcLen, m_byCompressBuffer, (lzo_uint*)&uDstLen, m_LzoWorkBuffer);
    KGLOG_PROCESS_ERROR(nRetCode == LZO_E_OK);

    g_PlayerClient.DoRemoteLuaCall(pszFunction, m_byCompressBuffer, uDstLen);

Exit0:
    return 0;
}
Exemple #16
0
    int LuaSetSndaIDToken(Lua_State* L)
    {
        const char* pszSndaID       = NULL;
        const char* pszSndaToken    = NULL;
        int         nTopIndex       = Lua_GetTopIndex(L);

        KGLOG_PROCESS_ERROR(nTopIndex == 2);

        pszSndaID = Lua_ValueToString(L, 1);
        KGLOG_PROCESS_ERROR(pszSndaID);

        pszSndaToken = Lua_ValueToString(L, 2);
        KGLOG_PROCESS_ERROR(pszSndaToken);

        g_GatewayClient.SetSndaIDToken(pszSndaID, pszSndaToken);
Exit0:
        return 0;
    }
Exemple #17
0
int LuaSendGmMessageMail(Lua_State* L)
{
    BOOL            bRetCode        = false;
    int             nTopIndex       = 0;
    char*           pszSender       = NULL;
    char*           pszReciever     = NULL;
    char*           pszMailTitle    = NULL;
    char*           pszText         = NULL;
    unsigned int    uTextLen        = 0;
    KRole*          pDstRole        = NULL;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 4);

    pszSender    = (char*)Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszSender);

    pszReciever  = (char*)Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pszReciever);

    pszMailTitle = (char*)Lua_ValueToString(L, 3);
    KGLOG_PROCESS_ERROR(pszMailTitle);

    pszText      = (char*)Lua_ValueToString(L, 4);
    KGLOG_PROCESS_ERROR(pszText);
    KGLOG_PROCESS_ERROR(strlen(pszText) > 0);

    pDstRole = g_pSO3GameCenter->m_RoleManager.GetRole(pszReciever);
    KGLOG_PROCESS_ERROR(pDstRole);

    uTextLen = (unsigned)(strlen(pszText) + 1);

    bRetCode = g_pSO3GameCenter->m_MailManager.PostRequestSendMail(
        0, pDstRole->m_dwPlayerID, 0, eMailType_GmMessage,
        pszSender, pszMailTitle, 
        0,
        (BYTE*)pszText, uTextLen,
        NULL, 0, 0
    );
    KGLOG_PROCESS_ERROR(bRetCode);

Exit0:
    return 0;
}
Exemple #18
0
    int LuaRename(Lua_State* L)
    {
        int     nTopIndex   = 0;
        char*   pszOldName  = NULL;
        char*   pszNewName  = NULL;

        nTopIndex = Lua_GetTopIndex(L);
        KGLOG_PROCESS_ERROR(nTopIndex == 2);

        pszOldName  = (char*)Lua_ValueToString(L, 1);
        pszNewName  = (char*)Lua_ValueToString(L, 2);

        KGLOG_PROCESS_ERROR(pszOldName);
        KGLOG_PROCESS_ERROR(pszNewName);

        g_GatewayClient.DoRenameRequest(pszOldName, pszNewName);

Exit0:
        return 0;
    }
Exemple #19
0
int LuaSendGmMessage(Lua_State* L)
{
    int         nTopIndex   = 0;
    const char* pszGmName  = NULL;
    const char* pszMessage = NULL;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2);

    pszGmName = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszGmName);

    pszMessage = Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pszMessage);

    g_pSO3GameCenter->m_Eyes.DoSendGmMessage(pszGmName, pszMessage);

Exit0:
    return 0;
}
int KHero::LuaAISay(Lua_State* L)
{
	BOOL bResult 	    = false;
	BOOL bRetCode	    = false;
	int	 nTopIndex	    = 0;
    int  nTalkChannel   = 0;
    int  nMsgType       = trRoom;
    const char* szMessage = NULL;
    DWORD dwTalkID      = ERROR_ID;
    char* szTalkerName  = m_szName;
	
	nTopIndex = Lua_GetTopIndex(L);
	KGLOG_PROCESS_ERROR(nTopIndex == 2);

    nTalkChannel = (int)Lua_ValueToNumber(L, 1);
    KGLOG_PROCESS_ERROR(nTalkChannel == KAI_TALK_CHANNEL_MAP || nTalkChannel == KAI_TALK_CHANNEL_TEAM);

    szMessage = Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(szMessage);

    if (nTalkChannel == KAI_TALK_CHANNEL_TEAM)
        nMsgType = trTeam;

    if (m_pOwner)
    {
        dwTalkID = m_pOwner->m_dwID;
        szTalkerName = m_pOwner->m_szName;
    }

    for (KObjEnumerator it = m_pScene->GetObjEnumerator(); it.HasElement(); it.MoveToNext())
    {
        KSceneObject* pObj = it.GetValue();
        if (!pObj->Is(sotHero))
            continue;

        KHero* pHero = (KHero*)pObj;
        KPlayer* pOwner = pHero->GetOwner();
        if (!pOwner)
            continue;
        if (pOwner->m_pFightingHero != pHero)
            continue;

        if (nTalkChannel == KAI_TALK_CHANNEL_TEAM && pHero->m_nSide != m_nSide)
            continue;

        g_PlayerServer.DoTalkMessage(nMsgType, dwTalkID, szTalkerName, m_dwID,  ERROR_ID, pOwner->m_dwID, pOwner->m_szName, strlen(szMessage), szMessage);
    }

	bResult = true;
Exit0:
	Lua_PushBoolean(L, bResult);
	return 1;
}
Exemple #21
0
	int LuaDeleteRole(Lua_State* L)
	{
        const char* cszRoleName          = NULL;
        const char* cszSecondlyPassword  = NULL;
  		char        szSecondlyPasswordMD5[KSG_PASSWORD_MAX_SIZE];

		KGLOG_PROCESS_ERROR(Lua_GetTopIndex(L) == 2);

		cszRoleName = (const char*)Lua_ValueToString(L, 1);
        KGLOG_PROCESS_ERROR(cszRoleName);

		cszSecondlyPassword = (const char*)Lua_ValueToString(L, 2);
        KGLOG_PROCESS_ERROR(cszSecondlyPassword);

		KG_EDStringToMD5String(szSecondlyPasswordMD5, cszSecondlyPassword);
        szSecondlyPasswordMD5[sizeof(szSecondlyPasswordMD5) - 1] = '\0';

		g_GatewayClient.DeleteRole(cszRoleName, szSecondlyPasswordMD5);
Exit0:
		return 0;
	}
Exemple #22
0
	int LuaRoleLogin(Lua_State* L)
	{
        const char* cszRoleName = NULL;

        KGLOG_PROCESS_ERROR(Lua_GetTopIndex(L) == 1);

		cszRoleName = (const char*)Lua_ValueToString(L, 1);
		KGLOG_PROCESS_ERROR(cszRoleName);

		g_GatewayClient.RoleLogin(cszRoleName);
Exit0:
		return 0;
	}
Exemple #23
0
int LuaSendGlobalMail(Lua_State* L)
{
    BOOL            bRetCode        = false;
    int             nTopIndex       = 0;
    char*           pszSender       = NULL;
    char*           pszMailTitle    = NULL;
    char*           pszText         = NULL;
    int             nLifeTime       = 60 * 60 * 24 * 7;
    unsigned int    uTextLen        = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex >= 3);
    KGLOG_PROCESS_ERROR(nTopIndex <= 4);

    pszSender       = (char*)Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pszSender);

    pszMailTitle    = (char*)Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pszMailTitle);

    pszText         = (char*)Lua_ValueToString(L, 3);
    KGLOG_PROCESS_ERROR(pszText);

    if (nTopIndex == 4)
    {
        nLifeTime = (int)Lua_ValueToNumber(L, 4);
    }
    KGLOG_PROCESS_ERROR(nLifeTime > 0);

    uTextLen = (unsigned)(strlen(pszText) + 1);

    bRetCode = g_pSO3GameCenter->m_MailManager.SendGlobalMail(
        nLifeTime, eMailType_System, pszSender, pszMailTitle, 0, (BYTE*)pszText, uTextLen, NULL, 0, 0
    );
    KGLOG_PROCESS_ERROR(bRetCode);

Exit0:
    return 0;
}
Exemple #24
0
    int LuaSetAccountPassword(Lua_State* L)
    {
        BOOL        bRetCode         = false;
        const char* pszAccountName   = NULL;
        const char* pszPassword      = NULL;
        const char* pszActiveCode    = NULL;
        BOOL        bMD5             = false;
        int         nTopIndex        = Lua_GetTopIndex(L);
        char        szDestMD5String[64] = { 0 };

        KGLOG_PROCESS_ERROR(nTopIndex == 3 || nTopIndex == 4);

        pszAccountName = Lua_ValueToString(L, 1);
        KGLOG_PROCESS_ERROR(pszAccountName);

        pszPassword = Lua_ValueToString(L, 2);
        KGLOG_PROCESS_ERROR(pszPassword);

        bMD5 = Lua_ValueToBoolean(L, 3);

        if (bMD5)
        {
            KGLOG_PROCESS_ERROR(g_pGameWorldUIHandler);

            bRetCode = g_pGameWorldUIHandler->GetPassword(pszPassword, szDestMD5String);
            KGLOG_PROCESS_ERROR(bRetCode);
        }

        if (nTopIndex == 4)
        {
            pszActiveCode = Lua_ValueToString(L, 4);
            KGLOG_PROCESS_ERROR(pszActiveCode);
        }

        g_GatewayClient.SetAccountPassword(pszAccountName, szDestMD5String, pszActiveCode);
Exit0:
        return 0;
    }
Exemple #25
0
int LuaSendCheatReport(Lua_State* L)
{
    int         nTopIndex       = 0;
    const char* pcszAccount     = NULL;
    const char* pcszRoleName    = NULL;
    const char* pcszText        = NULL;

    nTopIndex =  Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    pcszAccount = (const char*)Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pcszAccount);

    pcszRoleName = (const char*)Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pcszRoleName);

    pcszText = (const char*)Lua_ValueToString(L, 3);
    KGLOG_PROCESS_ERROR(pcszText);

    g_pSO3GameCenter->m_Eyes.DoSendGmChn(l2e_report_cheat_def, pcszAccount, pcszRoleName, pcszText);   
Exit0:
    return 0;
}
Exemple #26
0
	int LuaCreateRole(Lua_State* L)
	{
		BOOL                    bRetCode    = false;
		int                     nParamCount = 0;
		char const*             pszRoleName = NULL;
		UI_ROLE_CREATE_PARAM    RoleCreateParam;

		nParamCount = Lua_GetTopIndex(L);
		KGLOG_PROCESS_ERROR(nParamCount == 4 + perRepresentCount);

		pszRoleName = (char const*)Lua_ValueToString(L, 1);
		KGLOG_PROCESS_ERROR(pszRoleName && pszRoleName[0] != _T('\0'));
        
        ZeroMemory(&RoleCreateParam, sizeof(UI_ROLE_CREATE_PARAM));

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

		RoleCreateParam.nRoleType = (int)Lua_ValueToNumber(L, 2);
		KGLOG_PROCESS_ERROR(RoleCreateParam.nRoleType >= rtInvalid && RoleCreateParam.nRoleType < rtTotal);

		RoleCreateParam.dwMapID        = (DWORD)Lua_ValueToNumber(L, 3);
   		RoleCreateParam.nMapCopyIndex  = (DWORD)Lua_ValueToNumber(L, 4);

        RoleCreateParam.wRepresentId[perFaceStyle]         = (WORD)Lua_ValueToNumber(L, 5);    
        RoleCreateParam.wRepresentId[perHairStyle]         = (WORD)Lua_ValueToNumber(L, 6);
        RoleCreateParam.wRepresentId[perHelmStyle]         = (WORD)Lua_ValueToNumber(L, 7);
        RoleCreateParam.wRepresentId[perHelmColor]         = (WORD)Lua_ValueToNumber(L, 8);
        RoleCreateParam.wRepresentId[perHelmEnchant]       = (WORD)Lua_ValueToNumber(L, 9);   
        RoleCreateParam.wRepresentId[perChestStyle]        = (WORD)Lua_ValueToNumber(L, 10);
        RoleCreateParam.wRepresentId[perChestColor]        = (WORD)Lua_ValueToNumber(L, 11);
        RoleCreateParam.wRepresentId[perChestEnchant]      = (WORD)Lua_ValueToNumber(L, 12);
        RoleCreateParam.wRepresentId[perWaistStyle]        = (WORD)Lua_ValueToNumber(L, 13);
        RoleCreateParam.wRepresentId[perWaistColor]        = (WORD)Lua_ValueToNumber(L, 14);
        RoleCreateParam.wRepresentId[perWaistEnchant]      = (WORD)Lua_ValueToNumber(L, 15);
        RoleCreateParam.wRepresentId[perBangleStyle]       = (WORD)Lua_ValueToNumber(L, 16);
        RoleCreateParam.wRepresentId[perBangleColor]       = (WORD)Lua_ValueToNumber(L, 17);
        RoleCreateParam.wRepresentId[perBangleEnchant]     = (WORD)Lua_ValueToNumber(L, 18);
        RoleCreateParam.wRepresentId[perBootsStyle]        = (WORD)Lua_ValueToNumber(L, 19);
        RoleCreateParam.wRepresentId[perBootsColor]        = (WORD)Lua_ValueToNumber(L, 20);
        RoleCreateParam.wRepresentId[perWeaponStyle]       = (WORD)Lua_ValueToNumber(L, 21);
        RoleCreateParam.wRepresentId[perWeaponEnchant1]    = (WORD)Lua_ValueToNumber(L, 22);
        RoleCreateParam.wRepresentId[perWeaponEnchant2]    = (WORD)Lua_ValueToNumber(L, 23);
        RoleCreateParam.wRepresentId[perBackExtend]        = (WORD)Lua_ValueToNumber(L, 24);
        RoleCreateParam.wRepresentId[perWaistExtend]       = (WORD)Lua_ValueToNumber(L, 25);

		g_GatewayClient.CreateRole(RoleCreateParam);
Exit0:
		return 0;
	}
Exemple #27
0
int LuaSendKingeyesReport(Lua_State* L)
{
    int         nTopIndex       = 0;
    int         nType           = 0;
    const char* pszKey          = NULL;
    const char* pszValue        = NULL;

    nTopIndex =  Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    nType = (int)Lua_ValueToNumber(L, 1);

    pszKey = (const char*)Lua_ValueToString(L, 2);
    KGLOG_PROCESS_ERROR(pszKey);

    pszValue = (const char*)Lua_ValueToString(L, 3);
    KGLOG_PROCESS_ERROR(pszValue);

    g_pSO3GameCenter->m_Eyes.DoSendReport(nType, pszKey, pszValue);

Exit0:
    return 0;
}
Exemple #28
0
int KSystemScriptTable::LuaIsUnpakFileExist(Lua_State* L)
{
    int nRetCode = false;
    const char * pcszFile = NULL;

    KGLOG_PROCESS_ERROR(Lua_GetTopIndex(L) == 1);

    pcszFile = Lua_ValueToString(L, 1);
    KGLOG_PROCESS_ERROR(pcszFile);

    nRetCode = ::PathFileExistsA(pcszFile);
Exit0:
    Lua_PushBoolean(L, nRetCode);
    return 1;
}
Exemple #29
0
    int LuaMibaoVerify(Lua_State* L)
    {
        int         nTopIndex   = 0;
        const char* pszPassword = NULL;

        nTopIndex = Lua_GetTopIndex(L);
        KGLOG_PROCESS_ERROR(nTopIndex == 1);

        pszPassword = Lua_ValueToString(L, 1);
        KGLOG_PROCESS_ERROR(pszPassword);

        g_GatewayClient.MibaoVerify(pszPassword);

Exit0:
        return 0;
    }
Exemple #30
0
	int LuaSetGatewayAddress(Lua_State* L)
	{
        const char* cszLoginIP   = NULL;
        WORD        wLoginPort  = 0;

        KGLOG_PROCESS_ERROR(Lua_GetTopIndex(L) == 2);
        
        cszLoginIP = (const char*)Lua_ValueToString(L, 1);
		KGLOG_PROCESS_ERROR(cszLoginIP);

		wLoginPort = (WORD)Lua_ValueToNumber(L, 2);

        g_GatewayClient.SetGatewayAddress(cszLoginIP, wLoginPort);
Exit0:
        return 0;
	}