Skip to content

Commit

Permalink
proxy/ai->world with same area
Browse files Browse the repository at this point in the history
  • Loading branch information
zhxilin committed Jul 31, 2017
1 parent ece359e commit e3ddcd8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
22 changes: 21 additions & 1 deletion NFServer/NFAIServerNet_ClientPlugin/NFCAIServerToWorldModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,33 @@ bool NFCAIServerToWorldModule::AfterInit()
if (xLogicClass)
{
const std::vector<std::string>& strIdList = xLogicClass->GetIDList();

const int nCurAppID = pPluginManager->GetAppID();
std::vector<std::string>::const_iterator itr =
std::find_if(strIdList.begin(), strIdList.end(), [&](const std::string& strConfigId)
{
return nCurAppID == m_pElementModule->GetPropertyInt(strConfigId, NFrame::Server::ServerID());
});

if (strIdList.end() == itr)
{
std::ostringstream strLog;
strLog << "Cannot find current server, AppID = " << nCurAppID;
m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, NULL_OBJECT, strLog, __FUNCTION__, __LINE__);
NFASSERT(-1, "Cannot find current server", __FILE__, __FUNCTION__);
exit(0);
}

const int nCurArea = m_pElementModule->GetPropertyInt(*itr, NFrame::Server::Area());

for (int i = 0; i < strIdList.size(); ++i)
{
const std::string& strId = strIdList[i];

const int nServerType = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Type());
const int nServerID = m_pElementModule->GetPropertyInt(strId, NFrame::Server::ServerID());
if (nServerType == NF_SERVER_TYPES::NF_ST_WORLD)
const int nServerArea = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Area());
if (nServerType == NF_SERVER_TYPES::NF_ST_WORLD && nCurArea == nServerArea)
{
const int nPort = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Port());
const int nMaxConnect = m_pElementModule->GetPropertyInt(strId, NFrame::Server::MaxOnline());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ bool NFCGameServerToWorldModule::AfterInit()
std::ostringstream strLog;
strLog << "Cannot find current server, AppID = " << nCurAppID;
m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, NULL_OBJECT, strLog, __FUNCTION__, __LINE__);
NFASSERT(0, "Cannot find current server", __FILE__, __FUNCTION__);
NFASSERT(-1, "Cannot find current server", __FILE__, __FUNCTION__);
exit(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,34 @@ bool NFCProxyServerToWorldModule::AfterInit()
NF_SHARE_PTR<NFIClass> xLogicClass = m_pClassModule->GetElement(NFrame::Server::ThisName());
if (xLogicClass)
{
const std::vector<std::string>& strIdList = xLogicClass->GetIDList();
const std::vector<std::string>& strIdList = xLogicClass->GetIDList();

const int nCurAppID = pPluginManager->GetAppID();
std::vector<std::string>::const_iterator itr =
std::find_if(strIdList.begin(), strIdList.end(), [&](const std::string& strConfigId)
{
return nCurAppID == m_pElementModule->GetPropertyInt(strConfigId, NFrame::Server::ServerID());
});

if (strIdList.end() == itr)
{
std::ostringstream strLog;
strLog << "Cannot find current server, AppID = " << nCurAppID;
m_pLogModule->LogNormal(NFILogModule::NLL_ERROR_NORMAL, NULL_OBJECT, strLog, __FUNCTION__, __LINE__);
NFASSERT(-1, "Cannot find current server", __FILE__, __FUNCTION__);
exit(0);
}

const int nCurArea = m_pElementModule->GetPropertyInt(*itr, NFrame::Server::Area());

for (int i = 0; i < strIdList.size(); ++i)
{
const std::string& strId = strIdList[i];

const int nServerType = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Type());
const int nServerID = m_pElementModule->GetPropertyInt(strId, NFrame::Server::ServerID());
if (nServerType == NF_SERVER_TYPES::NF_ST_WORLD)
const int nServerArea = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Area());
if (nServerType == NF_SERVER_TYPES::NF_ST_WORLD && nCurArea == nServerArea)
{
const int nPort = m_pElementModule->GetPropertyInt(strId, NFrame::Server::Port());
const int nMaxConnect = m_pElementModule->GetPropertyInt(strId, NFrame::Server::MaxOnline());
Expand Down

0 comments on commit e3ddcd8

Please sign in to comment.