Ejemplo n.º 1
0
int NFCLoginLogicModule::OnLoginEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var)
{
    if (3 != var.GetCount()
        || !var.TypeEx(TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN))
    {
        return -1;
    }

    //////////////////////////////////////////////////////////////////////////
    const NFIDENTID xIdent = var.Object(0);
    const std::string& strAccount = var.String(1);
    const std::string& strPassword = var.String(2);
	int64_t nState = -1;

	std::vector<std::string> xFieldVec;
	std::vector<std::string> xValueVec;
	xFieldVec.push_back("Password");

	if (m_pClusterSqlModule->Query("AccountInfo", strAccount, xFieldVec, xValueVec)
		&& xFieldVec.size() == xValueVec.size()
		&& strPassword == xValueVec[0])
	{
		//µÇ¼³É¹¦
		nState = 0;
	}

    NFCDataList valEventInfo;
    valEventInfo << nState << xIdent << strAccount;
    m_pEventProcessModule->DoEvent(NFIDENTID(), NFED_ON_CLIENT_LOGIN_RESULTS, valEventInfo);

    return 0;
}
Ejemplo n.º 2
0
const int NFCGridModule::GetAroundObject(NFCSceneGridInfo* pGridInfo, NFIDataList& objectList, EGRID_AROUND eAround /*= EGRID_AROUND_9 */)
{
    if (!pGridInfo)
    {
        return 0;
    }

    NFCDataList gridList;
    if (GetAroundGrid(pGridInfo, gridList, eAround) > 0)
    {
        for (int i = 0; i < gridList.GetCount(); i++)
        {
            NFCSceneGridInfo* pGridInfo = (NFCSceneGridInfo*)(gridList.Pointer(i));
            if (pGridInfo)
            {
                NFIDENTID ident;
                bool bRet = pGridInfo->First(ident);
                while (bRet)
                {
                    objectList.Add(ident);
                    bRet = pGridInfo->Next(ident);
                }
            }
        }
    }

    return objectList.GetCount();
}
Ejemplo n.º 3
0
int HelloWorld3Module::OnEvent(const NFIDENTID& self, const int event, const NFIDataList& arg)
{
	//事件回调函数
	std::cout << "OnEvent EventID: " << event << " self: " << self.nData64 << " argList: " << arg.Int(0) << " " << " " << arg.String(1) << std::endl;

	m_pKernelModule->SetPropertyInt(self, "Hello", arg.Int(0));
	m_pKernelModule->SetPropertyString(self, "Hello", arg.String(1));

	return 0;
}
int NFCWorldToMasterModule::OnSelectServerResultsEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var)
{
    if (var.GetCount() != 7
        || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_OBJECT,
		TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING,
		TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN))
    {
		return 0;
    }

    const int nWorldID = var.Int(0);
    const NFIDENTID xClientIdent = var.Object(1);
    const int nLoginID = var.Int(2);
    const std::string& strAccount = var.String(3);
    const std::string& strWorldAddress = var.String(4);
    const int nPort = var.Int(5);
    const std::string& strKey = var.String(6);

    NFMsg::AckConnectWorldResult xMsg;

    xMsg.set_world_id(nWorldID);
    xMsg.set_login_id(nLoginID);
    xMsg.set_world_port(nPort);
    xMsg.mutable_sender()->CopyFrom(NFINetModule::NFToPB(xClientIdent));
    xMsg.set_account(strAccount);
    xMsg.set_world_ip(strWorldAddress);
    xMsg.set_world_key(strKey);

	SendSuitByPB(NFMsg::EGMI_ACK_CONNECT_WORLD, xMsg);

    return 0;
}
int NFCLoginNet_ServerModule::OnSelectWorldResultsEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var)
{
	if (7 != var.GetCount()
		|| !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING,
		TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN))
	{
		return -1;
	}

	const int nWorldID = var.Int(0);
	const NFIDENTID xClientIdent = var.Object(1);
	const int nLoginID = var.Int(2);
	const std::string& strAccount = var.String(3);
	const std::string& strWorldAddress = var.String(4);
	int nPort = var.Int(5);
	const std::string& strWorldKey = var.String(6);

	NF_SHARE_PTR<int> xFD = mxClientIdent.GetElement(xClientIdent);
	if (xFD)
	{
		NFMsg::AckConnectWorldResult xMsg;
		xMsg.set_world_id(nWorldID);
		xMsg.mutable_sender()->CopyFrom(NFToPB(xClientIdent));
		xMsg.set_login_id(nLoginID);
		xMsg.set_account(strAccount);
		xMsg.set_world_ip(strWorldAddress);
		xMsg.set_world_port(nPort);
		xMsg.set_world_key(strWorldKey);

		SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_CONNECT_WORLD, xMsg, *xFD);
	}

	return 0;
}
Ejemplo n.º 6
0
int NFCGameScene::OnPlayerMoveEvent(const int nEventID, const NFIDataList& varDataList)
{
	const NFGUID &self = varDataList.Object(0);
	Sprite *pPlayer = m_Players.GetElement(self);
	const NFVector3 &toPos = varDataList.Vector3(2);
	
	pPlayer->stopAllActions();
	pPlayer->runAction(CCMoveTo::create(1.0f, Vec2(toPos.X(), toPos.Y())));

	return 0;
}
Ejemplo n.º 7
0
int NFCLoginLogicModule::OnDisconnectEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var)
{
    if (2 != var.GetCount()
        || !var.TypeEx(TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN))
    {
        return -1;
    }

    //std::string strAccount = var.String(0);

    return 0;
}
Ejemplo n.º 8
0
bool NFCHeroPropertyModule::CalHeroTalentProperty(const NFGUID& self, const NFGUID& xHeroGUID, NFIDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_PlayerHero());
	if (nullptr == pHeroRecord)
	{
		return false;
	}

	NFCDataList varFind;
	if (pHeroRecord->FindObject(NFrame::Player::PlayerHero_GUID, xHeroGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int(0);

	NF_SHARE_PTR<NFIRecord> pHeroPropertyRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_HeroPropertyValue());
	if (nullptr == pHeroPropertyRecord)
	{
		return false;
	}

	////////////////////Talent//////////////////////////////////////////////////////
	xDataList.Clear();

	for (int i = 0; i < pHeroPropertyRecord->GetCols(); ++i)
	{
		xDataList.AddInt(0);
	}

	for (int i = NFrame::Player::PlayerHero_Talent1; i <= NFrame::Player::PlayerHero_Talent5; ++i)
	{
		const std::string& strTalentID = pHeroRecord->GetString(nRow, i);
		const std::string& strTalentEffectData = m_pElementModule->GetPropertyString(strTalentID, NFrame::Talent::EffectData());
		if (!strTalentEffectData.empty())
		{
			//one talent
			for (int j = 0; j < pHeroPropertyRecord->GetCols(); ++j)
			{
				const std::string& strColTag = pHeroPropertyRecord->GetColTag(j);
				int nValue = m_pElementModule->GetPropertyInt(strTalentEffectData, strColTag);
				int nOldValue = xDataList.Int(j);

				xDataList.SetInt(j, nOldValue + nValue);
			}
		}
	}

	return true;
}
int NFCLoginNet_ServerModule::OnLoginResultsEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var)
{
	if (3 != var.GetCount()
		|| !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN))
	{
		return -1;
	}

	const int nState = var.Int(0);
	const NFIDENTID xIdent = var.Object(1);
	const std::string& strAccount = var.String(2);

	NF_SHARE_PTR<int> xFD = mxClientIdent.GetElement(xIdent);
	if (xFD)
	{
		if (0 != nState)
		{
			//此帐号密码错误或者被封号
			//登录失败
			NFMsg::AckEventResult xMsg;
			xMsg.set_event_code(NFMsg::EGEC_ACCOUNTPWD_INVALID);

			SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_LOGIN, xMsg, *xFD);

			return 0;
		}

		NetObject* pNetObject = GetNet()->GetNetObject(*xFD);
		if (pNetObject)
		{
			//记录他登录过
			pNetObject->SetConnectKeyState(1);
			pNetObject->SetAccount(strAccount);
		}

		//把服务器列表广播下去

		NFMsg::AckEventResult xData;
		xData.set_event_code(NFMsg::EGEC_ACCOUNT_SUCCESS);

		SendMsgPB(NFMsg::EGameMsgID::EGMI_ACK_LOGIN, xData, *xFD);

		//SynWorldToClient(unAddress);

		m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, NFIDENTID(0, *xFD), "Login successed :", strAccount.c_str());

	}
	
	return 0;
}
Ejemplo n.º 10
0
int NFCGameScene::OnPlayerChatEvent(const int nEventID, const NFIDataList& varDataList)
{
	const NFGUID &self = varDataList.Object(0);
	Sprite *pPlayer = m_Players.GetElement(self);

	auto pChat = ui::Text::create(varDataList.String(3), "", 16);
	pChat->setAnchorPoint(Vec2(0.5, 0));
	pChat->setPosition(Vec2(pPlayer->getAnchorPointInPoints().x, pPlayer->getContentSize().height+ pChat->getContentSize().height));
	pPlayer->addChild(pChat);
	pChat->runAction(Sequence::create(FadeIn::create(0.5), DelayTime::create(5.0f), FadeIn::create(0.5), RemoveSelf::create(), NULL));
	pChat->runAction(MoveBy::create(0.5, Vec2(0, pChat->getContentSize().height)));

	return 0;
}
Ejemplo n.º 11
0
bool NFCHeroPropertyModule::CalHeroEquipProperty(const NFGUID& self, const NFGUID& xHeroGUID, NFIDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_PlayerHero());
	if (nullptr == pHeroRecord)
	{
		return false;
	}

	NFCDataList varFind;
	if (pHeroRecord->FindObject(NFrame::Player::PlayerHero_GUID, xHeroGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int(0);

	NF_SHARE_PTR<NFIRecord> pHeroPropertyRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_HeroPropertyValue());
	if (nullptr == pHeroPropertyRecord)
	{
		return false;
	}

	////////////////////Equip//////////////////////////////////////////////////////
	xDataList.Clear();

	for (int i = 0; i < pHeroPropertyRecord->GetCols(); ++i)
	{
		xDataList.AddInt(0);
	}

	for (int i = NFrame::Player::PlayerHero_Equip1; i <= NFrame::Player::PlayerHero_Equip6; ++i)
	{
		NFCDataList EquipDataList;
		const NFGUID xEquipID = pHeroRecord->GetObject(nRow, i);
		if (!xEquipID.IsNull() && m_pEquipPropertyModule->CalEquipProperty(self, xEquipID, EquipDataList))
		{
			//one equip
			for (int j = 0; j < pHeroPropertyRecord->GetCols(); ++j)
			{
				int nOldValue = xDataList.Int(j);
				int nEquipValue = EquipDataList.Int(j);

				xDataList.SetInt(j, nOldValue + nEquipValue);
			}
		}
	}

	return true;
}
Ejemplo n.º 12
0
int NFCRecord::FindString(const int nCol, const std::string& value, NFIDataList& varResult)
{
    if (!ValidCol(nCol))
    {
        return -1;
    }

    if (TDATA_STRING != mVarRecordType->Type(nCol))
    {
        return -1;
    }


    {
        for (int64_t i = 0; i < mnMaxRow; ++i)
        {
            if (!IsUsed(i))
            {
                continue;
            }

            const std::string& strData = GetString(i, nCol);
            if (0 == strcmp(strData.c_str(), value.c_str()))
            {
                varResult << i;
            }
        }

        return varResult.GetCount();
    }

    return -1;
}
Ejemplo n.º 13
0
int NFCRecord::FindObject(const int nCol, const NFGUID& value, NFIDataList& varResult)
{
    if (!ValidCol(nCol))
    {
        return -1;
    }

    if (TDATA_OBJECT != mVarRecordType->Type(nCol))
    {
        return -1;
    }

    {
        for (int64_t i = 0; i < mnMaxRow; ++i)
        {
            if (!IsUsed(i))
            {
                continue;
            }

            if (GetObject(i, nCol) == value)
            {
                varResult << i;
            }
        }

        return varResult.GetCount();
    }

    return -1;
}
int NFCGameServerToWorldModule::OnSwapGSEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var)
{
    //如果是单服,则不允许切换gs
    if (5 != var.GetCount())
    {
        return 0;
    }

    //     int nGameServerID = var.Int(0);
    //     const std::string& strAccount = var.String(1);
    //     const std::string& strRoleName = var.String(2);
    //     int nSceneIndex = var.Int(3);
    //     int nPlayerConfigIndex = var.Int(4);
    //
    //     _tagGTG_SWAP_GAMESERVER swapGS;
    //
    //     swapGS._nGameServerID = nGameServerID;
    //     strcpy(swapGS._szAccount, strAccount.c_str());
    //     strcpy(swapGS._szRoleName, strRoleName.c_str());
    //     swapGS._nSceneIndex = nSceneIndex;
    //     swapGS._nPlayerConfigIndex = nPlayerConfigIndex;
    //
    //     RakNet::BitStream oBitStream;
    //     swapGS.EnCode(oBitStream);
    //
    //     SendBitStream(&oBitStream);

    return 0;
}
Ejemplo n.º 15
0
int NFCRecord::FindFloat(const int nCol, const double value, NFIDataList& varResult)
{
    if (!ValidCol(nCol))
    {
        return -1;
    }

    if (TDATA_FLOAT != mVarRecordType->Type(nCol))
    {
        return -1;
    }

    for (int i = 0; i < mnMaxRow; ++i)
    {
        if (!IsUsed(i))
        {
            continue;
        }

        if (GetFloat(i, nCol) == value)
        {
            varResult << i;
        }
    }

    return varResult.GetCount();
}
Ejemplo n.º 16
0
bool NFCHeroPropertyModule::CalHeroAllProperty(const NFGUID& self, const NFGUID& xHeroGUID, NFIDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_PlayerHero());
	if (nullptr == pHeroRecord)
	{
		return false;
	}

	NFCDataList varFind;
	if (pHeroRecord->FindObject(NFrame::Player::PlayerHero_GUID, xHeroGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int(0);

	NF_SHARE_PTR<NFIRecord> pHeroPropertyRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_HeroPropertyValue());
	if (nullptr == pHeroPropertyRecord)
	{
		return false;
	}

	NFCDataList xHeroPropertyValue;
	CalHeroBaseProperty(self, xHeroGUID, xHeroPropertyValue);

	NFCDataList xHeroTalentValue;
	CalHeroTalentProperty(self, xHeroGUID, xHeroTalentValue);

	NFCDataList xHeroEquipValue;
	CalHeroEquipProperty(self, xHeroGUID, xHeroEquipValue);

	for (int i = 0; i < pHeroPropertyRecord->GetCols(); ++i)
	{
		int nPropertyValue = 0;
		int nTalentValue = 0;
		int nEquipValue = 0;

		if (xHeroPropertyValue.GetCount() == pHeroPropertyRecord->GetCols())
		{
			nPropertyValue = xHeroPropertyValue.Int(i);
		}
		if (xHeroTalentValue.GetCount() == pHeroPropertyRecord->GetCols())
		{
			nTalentValue = xHeroTalentValue.Int(i);
		}
		if (xHeroEquipValue.GetCount() == pHeroPropertyRecord->GetCols())
		{
			nEquipValue = xHeroEquipValue.Int(i);
		}

		int nAllValue = nPropertyValue + nTalentValue + nEquipValue;

		xDataList.AddInt(nAllValue);
	}

	return true;
}
Ejemplo n.º 17
0
const int NFCGridModule::GetAroundGrid(NFCSceneGridInfo* pGridInfo, NFIDataList& gridList, EGRID_AROUND eAround /*= EGRID_AROUND_9 */)
{
    int nObjectCount = 0;

    if (!pGridInfo)
    {
        return nObjectCount;
    }

    gridList.Add(pGridInfo);

    nObjectCount += pGridInfo->Count();

    switch (eAround)
    {
        case EGRID_AROUND_9:
        {
            for (int i = 0; i < EGRID_DIRECTION_MAXCOUNT; i++)
            {
                NFCSceneGridInfo* pInfo = pGridInfo->GetConnectGrid((EGRID_DIRECTION)i);
                if (pInfo)
                {
                    gridList.Add(pInfo);
                    //gridList.push_back( pInfo );
                    nObjectCount += pInfo->Count();
                }
            }
        }
        break;
        case EGRID_AROUND_16:
            break;
        case EGRID_AROUND_25:
            break;
        case EGRID_AROUND_ALL:
            break;
        default:
            break;
    }

    return nObjectCount;
}
int NFCSceneProcessModule::OnLeaveSceneEvent( const NFGUID& object, const int nEventID, const NFIDataList& var )
{
    if (1 != var.GetCount()
        || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_UNKNOWN))
    {
        return -1;
    }

    NFINT32 nOldGroupID = var.Int(0);
    if (nOldGroupID > 0)
    {
        int nSceneID = m_pKernelModule->GetPropertyInt(object, NFrame::Player::SceneID());
        if (GetCloneSceneType(nSceneID) == SCENE_TYPE_CLONE_SCENE)
        {
			m_pKernelModule->ReleaseGroupScene(nSceneID, nOldGroupID);

			m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, object, "DestroyCloneSceneGroup", nOldGroupID);
        }
    }

    return 0;
}
Ejemplo n.º 19
0
int NFCItemModule::OnRequireUseItemEvent( const NFGUID& self, const int nEventID, const NFIDataList& var )
{
	if (var.GetCount() != 2
		|| !var.TypeEx(TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN))
	{
		return 0;
	}
    //EGameErrorCode errorCode = EGameErrorCode::EGEC_INVALID_ITEM;
	const std::string& strItemID = var.String(0);
	const NFGUID xTargetID = var.Object(0);

	if(!m_pElementInfoModule->ExistElement(strItemID)
		|| !m_pKernelModule->GetObject(xTargetID))
	{
		return 0;
	}

    NF_SHARE_PTR<NFIRecord> pRecordPack = m_pKernelModule->FindRecord(self, NFrame::Player::R_BagItemList());
    if (nullptr != pRecordPack)
    {
// 		const bool bRet = m_pPackModule->DeleteItem(self, strItemID, 1);
// 		if (bRet)
// 		{
// 			int nItemType = m_pElementInfoModule->GetPropertyInt(strItemID, "ItemType");
// 			NFIItemConsumeProcessModule* pConsumeProcessModule = m_pItemConsumeManagerModule->GetConsumeModule(nItemType);
// 			if (pConsumeProcessModule)
// 			{
// 				if (pConsumeProcessModule->ConsumeLegal(self, strItemID, xTargetID) > 0)
// 				{
// 					pConsumeProcessModule->ConsumeProcess(self, strItemID, xTargetID);
// 
// 					return 0;
// 				}
// 			}
// 		}
	}

    return 0;
}
Ejemplo n.º 20
0
bool NFCHeroPropertyModule::CalHeroBaseProperty(const NFGUID& self, const NFGUID& xHeroGUID, NFIDataList& xDataList)
{
	NF_SHARE_PTR<NFIRecord> pHeroRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_PlayerHero());
	if (nullptr == pHeroRecord)
	{
		return false;
	}

	NFCDataList varFind;
	if (pHeroRecord->FindObject(NFrame::Player::PlayerHero_GUID, xHeroGUID, varFind) != 1)
	{
		return false;
	}

	const int nRow = varFind.Int(0);

	NF_SHARE_PTR<NFIRecord> pHeroPropertyRecord = m_pKernelModule->FindRecord(self, NFrame::Player::R_HeroPropertyValue());
	if (nullptr == pHeroPropertyRecord)
	{
		return false;
	}

	/////////////PropertyBase/////////////////////////////////////////
	xDataList.Clear();

	const std::string& strConfigID = pHeroRecord->GetString(nRow, NFrame::Player::PlayerHero::PlayerHero_ConfigID);
	const std::string& strPropertyEffectData = m_pElementModule->GetPropertyString(strConfigID, NFrame::NPC::EffectData());
	if (!strPropertyEffectData.empty())
	{
		for (int i = 0; i < pHeroPropertyRecord->GetCols(); ++i)
		{
			const std::string& strColTag = pHeroPropertyRecord->GetColTag(i);
			int nValue = m_pElementModule->GetPropertyInt(strPropertyEffectData, strColTag);
			xDataList.AddInt(nValue);
		}
	}

	return true;
}
Ejemplo n.º 21
0
// 获得数据
bool NFCRecord::QueryRow(const int nRow, NFIDataList& varList)
{
    if (!ValidRow(nRow))
    {
        return false;
    }

    if (!IsUsed(nRow))
    {
        return false;
    }

    varList.Clear();
    for (int i = 0; i < GetCols(); ++i)
    {
        NF_SHARE_PTR<NFIDataList::TData> pVar = mtRecordVec.at(GetPos(nRow, i));
        if (pVar.get())
        {
            varList.Append(*pVar);
        }
        else
        {
            switch (GetColType(i))
            {
                case TDATA_INT:
                    varList.Add(NFINT64(0));
                    break;

                case TDATA_FLOAT:
                    varList.Add(0.0f);
                    break;

                case TDATA_STRING:
                    varList.Add(NULL_STR.c_str());
                    break;

                case TDATA_OBJECT:
                    varList.Add(NFGUID());
                    break;
                default:
                    return false;
                    break;
            }
        }
    }

    if (varList.GetCount() != GetCols())
    {
        return false;
    }

    return true;
}
Ejemplo n.º 22
0
int NFCRecord::FindRowByColValue(const int nCol, const NFIDataList& var, NFIDataList& varResult)
{
    if (!ValidCol(nCol))
    {
        return -1;
    }

    TDATA_TYPE eType = var.Type(0);
    if (eType != mVarRecordType->Type(nCol))
    {
        return -1;
    }

    switch (eType)
    {
        case TDATA_INT:
            return FindInt(nCol, var.Int(nCol), varResult);
            break;

        case TDATA_FLOAT:
            return FindFloat(nCol, var.Float(nCol), varResult);
            break;

        case TDATA_STRING:
            return FindString(nCol, var.String(nCol).c_str(), varResult);
            break;

        case TDATA_OBJECT:
            return FindObject(nCol, var.Object(nCol), varResult);
            break;

        default:
            break;
    }

    return -1;
}
Ejemplo n.º 23
0
int NFCSkillModule::OnRequireUseSkillPosEvent( const NFGUID& self, const int nEventID, const NFIDataList& var )
{
    if ( var.GetCount() < 4 ||
        !var.TypeEx(TDATA_OBJECT, TDATA_FLOAT, TDATA_FLOAT, TDATA_FLOAT, TDATA_OBJECT))
    {
        return 1;
    }

    int nSkillID = var.Int( 0 );
    double fX = var.Float( 1 );
    double fY = var.Float( 2 );
    double fZ = var.Float( 3 );
    //群伤,就只计算第一个人的闪避

    //结果事件
    //  NFCDataList valueResult;
    //  valueResult.AddInt(nSkillID);
    //  valueResult.AddInt(nResult);
    //  valueResult.Append(var, 4, var.GetCount());
    //
    //  m_pEventProcessModule->DoEvent(self, NFED_ON_CLIENT_USE_SKILL_POS_RESULT, valueResult);

    return 0;
}
Ejemplo n.º 24
0
int NFCNPCRefreshModule::OnObjectHPEvent( const NFIDENTID& self, const std::string& strPropertyName, const NFIDataList& oldVar, const NFIDataList& newVar)
{
    if ( newVar.Int( 0 ) <= 0 )
    {
        NFIDENTID identAttacker = m_pKernelModule->GetPropertyObject( self, "LastAttacker" );
        if (!identAttacker.IsNull())
        {
            m_pEventProcessModule->DoEvent( self, NFED_ON_OBJECT_BE_KILLED, NFCDataList() << identAttacker );

            m_pKernelModule->AddHeartBeat( self, "OnDeadDestroyHeart", this, &NFCNPCRefreshModule::OnDeadDestroyHeart, 5.0f, 1 );
        }
    }

    return 0;
}
int NFCWorldNet_ServerModule::OnSelectServerEvent(const NFIDENTID& object, const int nEventID, const NFIDataList& var)
{
    if (4 != var.GetCount()
        || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_STRING, TDATA_TYPE::TDATA_UNKNOWN))
    {
        return 0;
    }

    const int nWorldID = var.Int(0);
    const int nSenderAddress = var.Int(1);
    const int nLoginID = var.Int(2);
    const std::string& strAccount = var.String(3);

    //////////////////////////////////////////////////////////////////////////
    if (InThisWorld(strAccount))
    {
        return 0;
    }

    NF_SHARE_PTR<ServerData> pServerData = mProxyMap.First();
    if (pServerData.get())
    {
        NFMsg::AckConnectWorldResult xData;

        xData.set_world_id(nWorldID);
        xData.set_sender_ip(nSenderAddress);
        xData.set_login_id(nLoginID);
        xData.set_account(strAccount);

        xData.set_world_ip(pServerData->pData->server_ip());
        xData.set_world_port(pServerData->pData->server_port());
        xData.set_world_key(strAccount);

        SendMsgPB(NFMsg::EGMI_ACK_CONNECT_WORLD, xData, pServerData->nFD);

        //结果
        NFCDataList varResult;
        varResult << nWorldID << nSenderAddress << nLoginID << strAccount << pServerData->pData->server_ip() << pServerData->pData->server_port() << strAccount;
        m_pEventProcessModule->DoEvent(NFIDENTID(), NFED_ON_CLIENT_SELECT_SERVER_RESULTS, varResult);
    }
    
    return 0;
}
Ejemplo n.º 26
0
int NFCSceneProcessModule::OnEnterSceneEvent( const NFIDENTID& self, const int nEventID, const NFIDataList& var )
{
    if ( var.GetCount() != 4 
        || !var.TypeEx(TDATA_TYPE::TDATA_OBJECT, TDATA_TYPE::TDATA_INT, 
        TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_UNKNOWN))
    {
        return 0;
    }

    NFIDENTID ident = var.Object( 0 );
    int nType = var.Int( 1 );
    int nTargetScene = var.Int( 2 );
    int nTargetGroupID = var.Int( 3 );
    int nOldSceneID = m_pKernelModule->GetPropertyInt( self, "SceneID" );

    char szSceneID[MAX_PATH] = {0};
    sprintf(szSceneID, "%d", nTargetScene);
#ifdef NF_USE_ACTOR
	int nActorID = m_pElementInfoModule->GetPropertyInt(szSceneID, "ActorID");
	int nSelfActorID = pPluginManager->GetActorID();
	if (nSelfActorID != nActorID)
	{
		m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, ident, "target scene not runing in this server", nTargetScene);
		return 1;
#endif

    if ( self != ident )
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, ident, "you are not you self, but you want to entry this scene", nTargetScene);
        return 1;
    }

    const int nNowContainerID = m_pKernelModule->GetPropertyInt(self, "SceneID");
    const int nNowGroupID = m_pKernelModule->GetPropertyInt(self, "GroupID");
    if (nNowContainerID == nTargetScene
        && nNowGroupID == nTargetGroupID)
    {
        //本来就是这个层这个场景就别切换了
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "in same scene and group but it not a clone scene", nTargetScene);

        return 1;
    }

    nTargetGroupID = CreateCloneScene( nTargetScene, nTargetGroupID, "File.xml", NFCDataList() );
    if ( nTargetGroupID <= 0 )
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "CreateCloneScene failed", nTargetScene);
        return 0;
    }

    //得到坐标
    float fX = 0.0f;
    float fY = 0.0f;
    float fZ = 0.0f;

    const std::string& strRelivePosList = m_pElementInfoModule->GetPropertyString(szSceneID, "RelivePos");
    NFCDataList valueRelivePosList( strRelivePosList.c_str(), ";" );
    if ( valueRelivePosList.GetCount() >= 1 )
    {
        NFCDataList valueRelivePos( valueRelivePosList.String( 0 ).c_str(), "," );
        if ( valueRelivePos.GetCount() == 3 )
        {
            fX = boost::lexical_cast<float>( valueRelivePos.String( 0 ) );
            fY = boost::lexical_cast<float>( valueRelivePos.String( 1 ) );
            fZ = boost::lexical_cast<float>( valueRelivePos.String( 2 ) );
        }
    }

    NFCDataList xSceneResult( var );
    xSceneResult.Add( fX );
    xSceneResult.Add( fY );
    xSceneResult.Add( fZ );

    m_pEventProcessModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_BEFORE, xSceneResult );

    if(!m_pKernelModule->SwitchScene( self, nTargetScene, nTargetGroupID, fX, fY, fZ, 0.0f, var ))
    {
        m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, ident, "SwitchScene failed", nTargetScene);

        return 0;
    }

    xSceneResult.Set(3, NFINT64(nTargetGroupID));//spicial
    m_pEventProcessModule->DoEvent( self, NFED_ON_OBJECT_ENTER_SCENE_RESULT, xSceneResult );

    return 0;
}

int NFCSceneProcessModule::OnLeaveSceneEvent( const NFIDENTID& object, const int nEventID, const NFIDataList& var )
{
    if (1 != var.GetCount()
        || !var.TypeEx(TDATA_TYPE::TDATA_INT, TDATA_TYPE::TDATA_UNKNOWN))
    {
        return -1;
    }

    NFINT32 nOldGroupID = var.Int(0);

    NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject(object);
    if (pObject.get() && nOldGroupID > 0)
    {
        int nContainerID = pObject->GetPropertyInt("SceneID");
        if (GetCloneSceneType(nContainerID) == SCENE_TYPE_MAINLINE_CLONE)
        {
            m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, object, "DestroyCloneSceneGroup", nOldGroupID);
            DestroyCloneScene(nContainerID, nOldGroupID, var);
        }
    }

    return 0;
}

int NFCSceneProcessModule::OnObjectClassEvent( const NFIDENTID& self, const std::string& strClassName, const CLASS_OBJECT_EVENT eClassEvent, const NFIDataList& var )
{
    if ( strClassName == "Player" )
    {
        if ( CLASS_OBJECT_EVENT::COE_DESTROY == eClassEvent )
        {
            //如果在副本中,则删除他的那个副本
            int nContainerID = m_pKernelModule->GetPropertyInt(self, "SceneID");
            if (GetCloneSceneType(nContainerID) == SCENE_TYPE_MAINLINE_CLONE)
            {
                int nGroupID = m_pKernelModule->GetPropertyInt(self, "GroupID");

                m_pLogModule->LogNormal(NFILogModule::NLL_INFO_NORMAL, self, "DestroyCloneSceneGroup", nGroupID);
                DestroyCloneScene(nContainerID, nGroupID, NFCDataList());
            }
        }
        else if ( CLASS_OBJECT_EVENT::COE_CREATE_HASDATA == eClassEvent )
        {
            m_pEventProcessModule->AddEventCallBack( self, NFED_ON_CLIENT_ENTER_SCENE, this, &NFCSceneProcessModule::OnEnterSceneEvent );
            m_pEventProcessModule->AddEventCallBack( self, NFED_ON_CLIENT_LEAVE_SCENE, this, &NFCSceneProcessModule::OnLeaveSceneEvent );
        }
    }

    return 0;
}

E_SCENE_TYPE NFCSceneProcessModule::GetCloneSceneType( const int nContainerID )
{
    char szSceneIDName[MAX_PATH] = { 0 };
    sprintf( szSceneIDName, "%d", nContainerID );
    if (m_pElementInfoModule->ExistElement(szSceneIDName))
    {
        return (E_SCENE_TYPE)m_pElementInfoModule->GetPropertyInt(szSceneIDName, "SceneType");
    }

    return SCENE_TYPE_ERROR;
}
Ejemplo n.º 27
0
bool NFCPVPMatchModule::TeamApplyPVP(const NFGUID& xTeam, const NFIDataList& varMemberList, int nPVPMode, const int nScore)
{
    int nMemberCount = varMemberList.GetCount();
    std::vector<NFGUID> xPlayerList;
    for (int i = 0; i < varMemberList.GetCount(); i++)
    {
        const NFGUID& xPlayerID = varMemberList.Object(i);
        if (xPlayerID.IsNull())
        {
            return false;
        }

        xPlayerList.push_back(xPlayerID);
    }

    int nGrade = GetGradeByScore(nScore);

    int nPVPModeMaxMember = GetMemberCount(nPVPMode);
    if (nPVPModeMaxMember < 0)
    {
        return false;
    }

    if (nMemberCount > nPVPModeMaxMember)
    {
        return false;
    }

    NFGUID xFindRoomID;
    int bRed = EPVPREDORBLUE_RED;
    std::vector<NFGUID> xRoomIDList;
    if (m_pPVPMatchRedisModule->GetStatusRoomID(nPVPMode, nGrade, EPVPROOMSTATUS_WAIT, xRoomIDList))
    {
        for (int i = 0; i < xRoomIDList.size(); i++)
        {
            const NFGUID& xRoomID = xRoomIDList[i];
            NFMsg::PVPRoomInfo xRoomInfo;
            if (m_pPVPMatchRedisModule->GetRoomInfo(xRoomID, xRoomInfo))
            {
                if ((xRoomInfo.xredplayer_size() + nMemberCount) < xRoomInfo.maxpalyer())
                {
                    xFindRoomID = xRoomID;
                    bRed = EPVPREDORBLUE_RED;
                    break;
                }
                else if ((xRoomInfo.xblueplayer_size() + nMemberCount) < xRoomInfo.maxpalyer())
                {
                    xFindRoomID = xRoomID;
                    bRed = EPVPREDORBLUE_BULE;
                    break;
                }
            }
        }
    }

    if (xFindRoomID.IsNull())
    {
        xFindRoomID = CreateRoom(NFGUID(), nPVPMode, nGrade);
        if (xFindRoomID.IsNull())
        {
            return false;
        }

        m_pPVPMatchRedisModule->SetStatusRoomID(nPVPMode, nGrade, EPVPROOMSTATUS_WAIT, xFindRoomID);
    }

    return PlayerListEnterRoom(xPlayerList, bRed, xFindRoomID);
}
int NFCBriefSkillConsumeProcessModule::ConsumeProcess( const NFGUID& self, const std::string& strSkillName, const NFIDataList& other, NFIDataList& damageListValue, NFIDataList& damageResultList )
{
    NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = m_pElementModule->GetPropertyManager( strSkillName );
    if ( pPropertyManager == NULL )
    {
        return 1;
    }

//     NFIProperty* pSkillDamageProperty = pPropertyManager->GetElement( "DamageProperty" );
//     NFIProperty* pSkillDamageValue = pPropertyManager->GetElement( "DamageValue" );
//     NFIProperty* pSkillDamageType = pPropertyManager->GetElement( "DamageType" );
//     NFIProperty* pSkillDamageSubType = pPropertyManager->GetElement( "DamageSubType" );
//     if ( pSkillDamageProperty == NULL || pSkillDamageValue == NULL || pSkillDamageType == NULL || pSkillDamageSubType == NULL )
//     {
//         return 1;
//     }
// 
//     int nDamageType = pSkillDamageType->QueryInt();
//     int nDamageSubType = pSkillDamageSubType->QueryInt();
//     NFCDataList valueEffectProperty( pSkillDamageProperty->QueryString().c_str(), "," );
//     NFCDataList valueEffectValue( pSkillDamageValue->QueryString().c_str(), "," );
// 
//     if ( valueEffectProperty.GetCount() != valueEffectValue.GetCount() )
//     {
//         return 1;
//     }

    //for ( int i = 0; i < valueEffectProperty.GetCount(); i++ )
    {
        //先测定目标是否有此属性(其实是担心配错了)
        for ( int j = 0; j < other.GetCount(); j++ )
        {
            NFGUID identOther = other.Object( j );
            if ( identOther.IsNull() )
            {
                continue;
            }

            NF_SHARE_PTR<NFIObject> pObject = m_pKernelModule->GetObject( identOther );
            if ( pObject == NULL )
            {
                continue;
            }

            //短刀伤害,只能是HP,MP之类的有最大上限值的属性
//             std::string strCurProperty = valueEffectProperty.StringVal( i );
//             std::string strMaxProperty = "MAX" + strCurProperty;
//             NFIProperty* pOtherCurProperty = pObject->GetPropertyManager()->GetElement( strCurProperty );
//             NFIProperty* pOtherMaxProperty = pObject->GetPropertyManager()->GetElement( strMaxProperty );
//             if ( pOtherCurProperty == NULL || pOtherMaxProperty == NULL )
//             {
//                 continue;
//             }

            NF_SHARE_PTR<NFIProperty> pLastProperty = pObject->GetPropertyManager()->GetElement( "LastAttacker" );
            if ( pLastProperty )
            {
                pLastProperty->SetObject( self );
            }
        }
    }
    //m_pKernelModule->LogErrorItem(strSkillName.c_str(), "");

    return 0;
}
Ejemplo n.º 29
0
int HelloWorld3Module::OnPropertyStrCallBackEvent( const NFIDENTID& self, const std::string& strProperty, const NFIDataList& oldVarList, const NFIDataList& newVarList)
{
	//属性回调事件,只要属性值内容有变化,就会被回调
	std::cout << "OnPropertyCallBackEvent Property: " << strProperty << " OldValue: " << oldVarList.String(0) << " NewValue: " << newVarList.String(0) << std::endl;

	return 0;
}
Ejemplo n.º 30
0
int NFCRecord::AddRow(const int nRow, const NFIDataList& var)
{
	bool bCover = false;
    int nFindRow = nRow;
    if (nFindRow >= mnMaxRow)
    {
        return -1;
    }

    if (var.GetCount() != GetCols())
    {
        return -1;
    }

    if (nFindRow < 0)
    {
        for (int i = 0; i < mnMaxRow; i++)
        {
            if (!IsUsed(i))
            {
                nFindRow = i;
                break;
            }
        }
    }
	else
	{
		if (IsUsed(nFindRow))
	    {
	        bCover = true;
	    }		
	}

    if (nFindRow < 0)
    {
        return -1;
    }

    for (int i = 0; i < GetCols(); ++i)
    {
        if (var.Type(i) != GetColType(i))
        {
            return -1;
        }
    }

    SetUsed(nFindRow, 1);

    for (int i = 0; i < GetCols(); ++i)
    {
        NF_SHARE_PTR<NFIDataList::TData> pVar = mtRecordVec.at(GetPos(nFindRow, i));
		if (nullptr == pVar)
		{
			pVar = NF_SHARE_PTR<NFIDataList::TData>(NF_NEW NFIDataList::TData(var.Type(i)));
		}

		pVar->variantData = var.GetStack(i)->variantData;
    }

	RECORD_EVENT_DATA xEventData;
	xEventData.nOpType = bCover? Cover : Add;
	xEventData.nRow = nFindRow;
	xEventData.nCol = 0;
	xEventData.strRecordName = mstrRecordName;

    NFIDataList::TData tData;
    OnEventHandler(mSelf, xEventData, tData, tData); //FIXME:RECORD

    return nFindRow;
}