Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复空指针异常 #1424

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions kbe/src/server/baseapp/baseapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ void Baseapp::finalise()
//-------------------------------------------------------------------------------------
void Baseapp::onCellAppDeath(Network::Channel * pChannel)
{
if(pChannel && pChannel->isExternal())
if(!pChannel || pChannel->isExternal())
return;

if(shuttingdown_ != SHUTDOWN_STATE_STOP)
Expand Down Expand Up @@ -2423,7 +2423,13 @@ void Baseapp::onCreateEntityRemotelyFromDBIDOtherBaseappCallback(Network::Channe
void Baseapp::createCellEntityInNewSpace(Entity* pEntity, PyObject* pyCellappIndex)
{
ScriptDefModule* pScriptModule = pEntity->pScriptModule();
if (!pScriptModule || !pScriptModule->hasCell())
if (!pScriptModule)
{
ERROR_MSG(fmt::format("{}::createCellEntityInNewSpace: cannot find pScriptModule!\n"));
return;
}

if (!pScriptModule->hasCell())
{
ERROR_MSG(fmt::format("{}::createCellEntityInNewSpace: cannot find the cellapp script({})!\n",
pScriptModule->getName(), pScriptModule->getName()));
Expand Down Expand Up @@ -4360,7 +4366,7 @@ void Baseapp::forwardMessageToClientFromCellapp(Network::Channel* pChannel,
void Baseapp::forwardMessageToCellappFromCellapp(Network::Channel* pChannel,
KBEngine::MemoryStream& s)
{
if(pChannel->isExternal())
if(!pChannel || pChannel->isExternal())
return;

ENTITY_ID eid;
Expand Down
21 changes: 11 additions & 10 deletions kbe/src/server/baseappmgr/baseappmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,15 @@ void Baseappmgr::reqCreateEntityAnywhereFromDBIDQueryBestBaseappID(Network::Chan
}

Network::Bundle* pBundle = Network::Bundle::createPoolObject(OBJECTPOOL_POINT);
(*pBundle).newMessage(BaseappInterface::onGetCreateEntityAnywhereFromDBIDBestBaseappID);
if (pBundle && cinfos)
{
(*pBundle).newMessage(BaseappInterface::onGetCreateEntityAnywhereFromDBIDBestBaseappID);

(*pBundle) << bestBaseappID_;
(*pBundle).append((char*)s.data() + s.rpos(), (int)s.length());
cinfos->pChannel->send(pBundle);
s.done();
(*pBundle) << bestBaseappID_;
(*pBundle).append((char*)s.data() + s.rpos(), (int)s.length());
cinfos->pChannel->send(pBundle);
s.done();
}
}

//-------------------------------------------------------------------------------------
Expand Down Expand Up @@ -638,21 +641,19 @@ void Baseappmgr::registerPendingAccountToBaseapp(Network::Channel* pChannel, Mem
return;
}

std::map< COMPONENT_ID, Baseapp >::iterator baseapps_iter = baseapps_.find(bestBaseappID_);

DEBUG_MSG(fmt::format("Baseappmgr::registerPendingAccountToBaseapp:{}. allocBaseapp={}, numEntities={}.\n",
accountName, bestBaseappID_, (bestBaseappID_ > 0 ? baseapps_iter->second.numEntities() : 0)));

Network::Bundle* pBundle = Network::Bundle::createPoolObject(OBJECTPOOL_POINT);
(*pBundle).newMessage(BaseappInterface::registerPendingLogin);
(*pBundle) << loginName << accountName << password << needCheckPassword << eid << entityDBID << flags << deadline << clientType << forceInternalLogin;
pBundle->appendBlob(datas);
cinfos->pChannel->send(pBundle);

// Ԥ�Ƚ�ʵ����������
std::map< COMPONENT_ID, Baseapp >::iterator baseapps_iter = baseapps_.find(bestBaseappID_);
if (baseapps_iter != baseapps_.end())
{
baseapps_iter->second.incNumProxices();
DEBUG_MSG(fmt::format("Baseappmgr::registerPendingAccountToBaseapp:{}. allocBaseapp={}, numEntities={}.\n",
accountName, bestBaseappID_, (bestBaseappID_ > 0 ? baseapps_iter->second.numEntities() : 0)));
}
}

Expand Down
24 changes: 14 additions & 10 deletions kbe/src/server/cellapp/cellapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ ShutdownHandler::CAN_SHUTDOWN_STATE Cellapp::canShutdown()
//Entity* pEntity = static_cast<Entity*>(iter->second.get());
//if(pEntity->baseEntityCall() != NULL &&
// pEntity->pScriptModule()->isPersistent())
do
{
INFO_MSG(fmt::format("Cellapp::canShutdown(): Wait for the entity's into the database! The remaining {}.\n",
entities.size()));

lastShutdownFailReason_ = "destroyHasBaseEntitys";
return ShutdownHandler::CAN_SHUTDOWN_STATE_FALSE;
}
} while (0);
}

return ShutdownHandler::CAN_SHUTDOWN_STATE_TRUE;
Expand Down Expand Up @@ -1314,16 +1315,19 @@ void Cellapp::onEntityCall(Network::Channel* pChannel, KBEngine::MemoryStream& s
if(calltype == ENTITYCALL_TYPE_CELL)
{
GhostManager* gm = Cellapp::getSingleton().pGhostManager();
COMPONENT_ID cellID = gm->getRoute(eid);
if(gm && cellID > 0)
if (gm)
{
Network::Bundle* pBundle = gm->createSendBundle(cellID);
(*pBundle).newMessage(CellappInterface::onEntityCall);
(*pBundle) << eid << calltype;
(*pBundle).append(s);
gm->pushMessage(cellID, pBundle);
s.done();
return;
COMPONENT_ID cellID = gm->getRoute(eid);
if (cellID > 0)
{
Network::Bundle* pBundle = gm->createSendBundle(cellID);
(*pBundle).newMessage(CellappInterface::onEntityCall);
(*pBundle) << eid << calltype;
(*pBundle).append(s);
gm->pushMessage(cellID, pBundle);
s.done();
return;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion kbe/src/server/cellapp/witness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void Witness::setViewRadius(float radius, float hyst)
// ����λ��ͬ��ʹ�������λ��ѹ�����䣬���÷�ΧΪ-512~512֮�䣬��˳�����Χ������ͬ������
// ������һ�����ƣ������Ҫ�������ֵ�ͻ���Ӧ�õ������굥λ����������Ŵ�ʹ�á�
// �ο�: MemoryStream::appendPackXZ
if(viewRadius_ + viewHysteresisArea_ > 512)
if(viewRadius_ + viewHysteresisArea_ > 512 && pEntity_)
{
if (g_kbeSrvConfig.getCellApp().entity_posdir_updates_type > 0)
{
Expand Down
5 changes: 2 additions & 3 deletions kbe/src/server/cellappmgr/cellappmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,12 @@ void Cellappmgr::reqCreateCellEntityInNewSpace(Network::Channel* pChannel, Memor
}

std::map< COMPONENT_ID, Cellapp >::iterator cellapp_iter = cellapps_.find(bestCellappID_);
DEBUG_MSG(fmt::format("Cellappmgr::reqCreateCellEntityInNewSpace: entityType={}, entityID={}, componentID={}, cellapp(cid={}, load={}, numEntities={}).\n",
entityType, id, componentID, bestCellappID_, cellapp_iter->second.load(), cellapp_iter->second.numEntities()));

// Ԥ�Ƚ�ʵ����������
if (cellapp_iter != cellapps_.end())
{
cellapp_iter->second.incNumEntities();
DEBUG_MSG(fmt::format("Cellappmgr::reqCreateCellEntityInNewSpace: entityType={}, entityID={}, componentID={}, cellapp(cid={}, load={}, numEntities={}).\n",
entityType, id, componentID, bestCellappID_, cellapp_iter->second.load(), cellapp_iter->second.numEntities()));
}
}

Expand Down
1 change: 1 addition & 0 deletions kbe/src/server/tools/guiconsole/LineChartCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class CAxis
m_color = RGB(0,0,0);
m_iStyle = PS_SOLID;
m_iThick = 1;
m_dValuePerPixel = 0;
}
};
// CLineChartCtrl
Expand Down
2 changes: 1 addition & 1 deletion kbe/src/server/tools/guiconsole/guiconsoleDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ void CguiconsoleDlg::OnNMClickTree1(NMHDR *pNMHDR, LRESULT *pResult)

COMPONENT_TYPE debugComponentType = getTreeItemComponent(hItem);
BOOL isread_only = debugComponentType != CELLAPP_TYPE && debugComponentType != BASEAPP_TYPE && debugComponentType != BOTS_TYPE;
m_debugWnd.sendbufferWnd()->SetReadOnly(isread_only || !changeToChecked && !m_tree.GetCheck(hItem));
m_debugWnd.sendbufferWnd()->SetReadOnly(isread_only || (!changeToChecked && !m_tree.GetCheck(hItem)));

if(!isread_only && changeToChecked)
{
Expand Down
4 changes: 2 additions & 2 deletions kbe/src/server/tools/kbcmd/client_sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ bool ClientSDK::saveFile()
{
ERROR_MSG(fmt::format("ClientSDK::saveFile(): fwrite error! {}\n",
path));

fclose(fp);
return false;
}

Expand Down Expand Up @@ -150,7 +150,7 @@ bool ClientSDK::saveFile()
{
ERROR_MSG(fmt::format("ClientSDK::saveFile(): fwrite error! {}\n",
path));

fclose(fp);
return false;
}

Expand Down
10 changes: 7 additions & 3 deletions kbe/src/server/tools/kbcmd/client_sdk_ue4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1626,10 +1626,14 @@ bool ClientSDKUE4::writeEntityDefsModuleInitScript_ScriptModule(ScriptDefModule*
bool ClientSDKUE4::writeEntityDefsModuleInitScript_MethodDescr(ScriptDefModule* pScriptDefModule, MethodDescription* pDescr, COMPONENT_TYPE componentType)
{
// ���pDescrΪNone�������ǿͻ��˷�������ô��Ҫǿ���趨useMethodDescrAliasΪtrue������Ĭ��Ϊfalse�����������
if (!pDescr && componentType == CLIENT_TYPE)
if (!pDescr)
{
fileBody() += fmt::format("\tp{}Module->useMethodDescrAlias = true;\n", pScriptDefModule->getName());
return true;
if (componentType == CLIENT_TYPE)
{
fileBody() += fmt::format("\tp{}Module->useMethodDescrAlias = true;\n", pScriptDefModule->getName());
return true;
}
return false;
}

fileBody() += fmt::format("\tTArray<DATATYPE_BASE*> {}_{}_args;\n", pScriptDefModule->getName(), pDescr->getName());
Expand Down
10 changes: 7 additions & 3 deletions kbe/src/server/tools/kbcmd/client_sdk_unity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,10 +1248,14 @@ bool ClientSDKUnity::writeEntityDefsModuleInitScript_ScriptModule(ScriptDefModul
bool ClientSDKUnity::writeEntityDefsModuleInitScript_MethodDescr(ScriptDefModule* pScriptDefModule, MethodDescription* pDescr, COMPONENT_TYPE componentType)
{
// ���pDescrΪNone�������ǿͻ��˷�������ô��Ҫǿ���趨useMethodDescrAliasΪtrue������Ĭ��Ϊfalse�����������
if (!pDescr && componentType == CLIENT_TYPE)
if (!pDescr)
{
sourcefileBody_ += fmt::format("\t\t\tp{}Module.useMethodDescrAlias = true;\n", pScriptDefModule->getName());
return true;
if (componentType == CLIENT_TYPE)
{
sourcefileBody_ += fmt::format("\t\t\tp{}Module.useMethodDescrAlias = true;\n", pScriptDefModule->getName());
return true;
}
return false;
}

sourcefileBody_ += fmt::format("\t\t\tList<DATATYPE_BASE> p{}_{}_args = new List<DATATYPE_BASE>();\n", pScriptDefModule->getName(), pDescr->getName());
Expand Down
2 changes: 2 additions & 0 deletions kbe/src/server/tools/kbcmd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ int process_make_client_sdk(int argc, char* argv[], const std::string clientType
{
ERROR_MSG(fmt::format("app::initialize(): create clientsdk error! nonsupport type={}\n", clientType));
ret = -1;
return ret;
}

// ��ʼ���
Expand Down Expand Up @@ -409,6 +410,7 @@ int process_newassets(int argc, char* argv[], const std::string assetsType)
{
ERROR_MSG(fmt::format("app::initialize(): create serverassets error! nonsupport type={}\n", assetsType));
ret = -1;
return ret;
}

script::entitydef::uninstallModule();
Expand Down
3 changes: 3 additions & 0 deletions kbe/src/server/tools/logger/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ struct LOG_ITEM
LOG_ITEM()
{
persistent = true;
uid = 0;
logtype = 0;
t = 0;
}

int32 uid;
Expand Down