//------------------------------------------------------------------------------------- Base::~Base() { ENTITY_DECONSTRUCTION(Base); S_RELEASE(clientMailbox_); S_RELEASE(cellMailbox_); S_RELEASE(cellDataDict_); }
//------------------------------------------------------------------------------------- Base::~Base() { ENTITY_DECONSTRUCTION(Base); S_RELEASE(clientMailbox_); S_RELEASE(cellMailbox_); S_RELEASE(cellDataDict_); SAFE_RELEASE(pBufferedSendToCellappMessages_); }
D3DTextureShader::~D3DTextureShader() { S_RELEASE(m_pixelShader); S_RELEASE(m_vertexShader); S_RELEASE(m_Layout); S_RELEASE(m_matrixBuffer); S_RELEASE(m_sampleState); };
bool EntityApp<E>::uninstallPyModules() { S_RELEASE(pEntities_); unregisterPyObjectToScript("entities"); unregisterPyObjectToScript("globalData"); S_RELEASE(pGlobalData_); Entities<E>::uninstallScript(); //Entity::uninstallScript(); EntityDef::uninstallScript(); return true; }
//------------------------------------------------------------------------------------- Base::~Base() { ENTITY_DECONSTRUCTION(Base); S_RELEASE(clientMailbox_); S_RELEASE(cellMailbox_); S_RELEASE(cellDataDict_); SAFE_RELEASE(pBufferedSendToCellappMessages_); if(Baseapp::getSingleton().pEntities()) Baseapp::getSingleton().pEntities()->pGetbages()->erase(id()); script::PyGC::decTracing("Base"); }
//------------------------------------------------------------------------------------- Entity::~Entity() { ENTITY_DECONSTRUCTION(Entity); S_RELEASE(clientMailbox_); S_RELEASE(baseMailbox_); S_RELEASE(allClients_); S_RELEASE(otherClients_); if(pWitness_) { pWitness_->detach(this); Witness::ObjPool().reclaimObject(pWitness_); pWitness_ = NULL; } }
//------------------------------------------------------------------------------------- ClientObject::~ClientObject() { pChannel_->decRef(); pEntities_->finalise(); S_RELEASE(pEntities_); }
//------------------------------------------------------------------------------------- ScriptDefModule::~ScriptDefModule() { S_RELEASE(scriptType_); PROPERTYDESCRIPTION_MAP::iterator iter1 = cellPropertyDescr_.begin(); for(; iter1 != cellPropertyDescr_.end(); iter1++) iter1->second->decRef(); iter1 = basePropertyDescr_.begin(); for(; iter1 != basePropertyDescr_.end(); iter1++) iter1->second->decRef(); iter1 = clientPropertyDescr_.begin(); for(; iter1 != clientPropertyDescr_.end(); iter1++) iter1->second->decRef(); METHODDESCRIPTION_MAP::iterator iter2 = methodCellDescr_.begin(); for(; iter2 != methodCellDescr_.end(); iter2++) SAFE_RELEASE(iter2->second); METHODDESCRIPTION_MAP::iterator iter3 = methodBaseDescr_.begin(); for(; iter3 != methodBaseDescr_.end(); iter3++) SAFE_RELEASE(iter3->second); METHODDESCRIPTION_MAP::iterator iter4 = methodClientDescr_.begin(); for(; iter4 != methodClientDescr_.end(); iter4++) SAFE_RELEASE(iter4->second); }
//------------------------------------------------------------------------------------- bool Bots::installPyModules() { ClientObject::installScript(NULL); PyBots::installScript(NULL); pPyBots_ = new PyBots(); registerPyObjectToScript("bots", pPyBots_); APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), addBots, __py_addBots, METH_VARARGS, 0); // 注册设置脚本输出类型 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), scriptLogType, __py_setScriptLogType, METH_VARARGS, 0) if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_NORMAL", log4cxx::ScriptLevel::SCRIPT_INT)) { ERROR_MSG( "Bots::installPyModules: Unable to set KBEngine.LOG_TYPE_NORMAL.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_INFO", log4cxx::ScriptLevel::SCRIPT_INFO)) { ERROR_MSG( "Bots::installPyModules: Unable to set KBEngine.LOG_TYPE_INFO.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_ERR", log4cxx::ScriptLevel::SCRIPT_ERR)) { ERROR_MSG( "Bots::installPyModules: Unable to set KBEngine.LOG_TYPE_ERR.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_DBG", log4cxx::ScriptLevel::SCRIPT_DBG)) { ERROR_MSG( "Bots::installPyModules: Unable to set KBEngine.LOG_TYPE_DBG.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_WAR", log4cxx::ScriptLevel::SCRIPT_WAR)) { ERROR_MSG( "Bots::installPyModules: Unable to set KBEngine.LOG_TYPE_WAR.\n"); } registerScript(client::Entity::getScriptType()); // 安装入口模块 PyObject *entryScriptFileName = PyUnicode_FromString(g_kbeSrvConfig.getBots().entryScriptFile); if(entryScriptFileName != NULL) { entryScript_ = PyImport_Import(entryScriptFileName); SCRIPT_ERROR_CHECK(); S_RELEASE(entryScriptFileName); if(entryScript_.get() == NULL) { return false; } } onInstallPyModules(); return true; }
//------------------------------------------------------------------------------------- bool Baseapp::uninstallPyModules() { unregisterPyObjectToScript("globalBases"); S_RELEASE(pGlobalBases_); Base::uninstallScript(); Proxy::uninstallScript(); return EntityApp<Base>::uninstallPyModules(); }
//------------------------------------------------------------------------------------- void ScriptDefModule::finalise(void) { S_RELEASE(scriptType_); S_RELEASE(pVolatileinfo_); PROPERTYDESCRIPTION_MAP::iterator iter1 = cellPropertyDescr_.begin(); for(; iter1 != cellPropertyDescr_.end(); ++iter1) iter1->second->decRef(); cellPropertyDescr_.clear(); iter1 = basePropertyDescr_.begin(); for(; iter1 != basePropertyDescr_.end(); ++iter1) iter1->second->decRef(); basePropertyDescr_.clear(); iter1 = clientPropertyDescr_.begin(); for(; iter1 != clientPropertyDescr_.end(); ++iter1) iter1->second->decRef(); clientPropertyDescr_.clear(); METHODDESCRIPTION_MAP::iterator iter2 = methodCellDescr_.begin(); for(; iter2 != methodCellDescr_.end(); ++iter2) SAFE_RELEASE(iter2->second); methodCellDescr_.clear(); METHODDESCRIPTION_MAP::iterator iter3 = methodBaseDescr_.begin(); for(; iter3 != methodBaseDescr_.end(); ++iter3) SAFE_RELEASE(iter3->second); methodBaseDescr_.clear(); METHODDESCRIPTION_MAP::iterator iter4 = methodClientDescr_.begin(); for(; iter4 != methodClientDescr_.end(); ++iter4) SAFE_RELEASE(iter4->second); methodClientDescr_.clear(); }
//------------------------------------------------------------------------------------- void PyGC::set_debug(uint32 flsgs) { PyObject* pyRet = PyObject_CallFunction(set_debugMethod_, const_cast<char*>("i"), flsgs); SCRIPT_ERROR_CHECK(); if(pyRet) { S_RELEASE(pyRet); } }
//------------------------------------------------------------------------------------- void Base::onLoseCell(Mercury::Channel* pChannel, MemoryStream& s) { S_RELEASE(cellMailbox_); // 通知脚本 PyObject* pyResult = PyObject_CallMethod(this, const_cast<char*>("onLoseCell"), const_cast<char*>("")); if(pyResult != NULL) Py_DECREF(pyResult); else PyErr_PrintEx(0); }
//------------------------------------------------------------------------------------- void ClientObjectBase::finalise(void) { pyCallbackMgr_.finalise(); if(pEntities_) { pEntities_->finalise(); S_RELEASE(pEntities_); } if(pServerChannel_) { pServerChannel_->destroy(); pServerChannel_->decRef(); pServerChannel_ = NULL; } }
//------------------------------------------------------------------------------------- std::string Pickler::pickle(PyObject* pyobj, int8 protocol) { PyObject* pyRet = PyObject_CallFunction(picklerMethod_, const_cast<char*>("(Oi)"), pyobj, protocol); SCRIPT_ERROR_CHECK(); if(pyRet) { std::string str; str.assign(PyBytes_AsString(pyRet), PyBytes_Size(pyRet)); S_RELEASE(pyRet); return str; } return ""; }
D3DLightShader::~D3DLightShader() { // Release the light constant buffer. S_RELEASE(m_lightBuffer) S_RELEASE(m_cameraBuffer); // Release the matrix constant buffer. S_RELEASE(m_matrixBuffer); // Release the sampler state. S_RELEASE(m_sampleState); // Release the layout. S_RELEASE(m_layout); // Release the pixel shader. S_RELEASE(m_pixelShader); // Release the vertex shader. S_RELEASE(m_vertexShader); }
//------------------------------------------------------------------------------------- bool Cellapp::uninstallPyModules() { if(g_kbeSrvConfig.getBaseApp().profiles.open_pyprofile) { script::PyProfile::stop("kbengine"); char buf[MAX_BUF]; kbe_snprintf(buf, MAX_BUF, "baseapp%u.prof", startGroupOrder_); script::PyProfile::dump("kbengine", buf); script::PyProfile::remove("kbengine"); } unregisterPyObjectToScript("cellAppData"); S_RELEASE(pCellAppData_); Entity::uninstallScript(); return EntityApp<Entity>::uninstallPyModules(); }
//------------------------------------------------------------------------------------- std::string Pickler::pickle(PyObject* pyobj) { AUTO_SCOPED_PROFILE("pickle"); PyObject* pyRet = PyObject_CallFunction(picklerMethod_, const_cast<char*>("(O)"), pyobj); SCRIPT_ERROR_CHECK(); if(pyRet) { std::string str; str.assign(PyBytes_AsString(pyRet), PyBytes_Size(pyRet)); S_RELEASE(pyRet); return str; } return ""; }
bool EntityApp<E>::installPyModules() { Entities<E>::installScript(NULL); //Entity::installScript(g_script.getModule()); pEntities_ = new Entities<E>(); registerPyObjectToScript("entities", pEntities_); // 安装入口模块 PyObject *entryScriptFileName = NULL; if(componentType() == BASEAPP_TYPE) { ENGINE_COMPONENT_INFO& info = g_kbeSrvConfig.getBaseApp(); entryScriptFileName = PyUnicode_FromString(info.entryScriptFile); } else if(componentType() == CELLAPP_TYPE) { ENGINE_COMPONENT_INFO& info = g_kbeSrvConfig.getCellApp(); entryScriptFileName = PyUnicode_FromString(info.entryScriptFile); } if(entryScriptFileName != NULL) { entryScript_ = PyImport_Import(entryScriptFileName); SCRIPT_ERROR_CHECK(); S_RELEASE(entryScriptFileName); if(entryScript_.get() == NULL) { return false; } } // 添加pywatcher支持 if(!initializePyWatcher(&this->getScript())) return false; // 添加globalData, globalBases支持 pGlobalData_ = new GlobalDataClient(DBMGR_TYPE, GlobalDataServer::GLOBAL_DATA); registerPyObjectToScript("globalData", pGlobalData_); onInstallPyModules(); return true; }
//------------------------------------------------------------------------------------- void Base::onBackupCellData(Mercury::Channel* pChannel, MemoryStream& s) { isGetingCellData_ = false; std::string strCellData; uint32 cellDataLength; PyObject* cellData = NULL; s >> cellDataLength; if(cellDataLength > 0) { strCellData.assign((char*)(s.data() + s.rpos()), cellDataLength); s.read_skip(cellDataLength); cellData = script::Pickler::unpickle(strCellData); KBE_ASSERT(cellData != NULL); } installCellDataAttr(cellData); S_RELEASE(cellData); }
//------------------------------------------------------------------------------------- void PyGC::collect(int8 generations) { PyObject* pyRet = NULL; if(generations != -1) { pyRet = PyObject_CallFunction(collectMethod_, const_cast<char*>("(i)"), generations); } else { pyRet = PyObject_CallFunction(collectMethod_, const_cast<char*>("")); } SCRIPT_ERROR_CHECK(); if(pyRet) { S_RELEASE(pyRet); } }
bool EntityApp<E>::installPyModules() { Entities<E>::installScript(NULL); //Entity::installScript(g_script.getModule()); pEntities_ = new Entities<E>(); registerPyObjectToScript("entities", pEntities_); // 安装入口模块 PyObject *entryScriptFileName = NULL; if(componentType() == BASEAPP_TYPE) { ENGINE_COMPONENT_INFO& info = g_kbeSrvConfig.getBaseApp(); entryScriptFileName = PyUnicode_FromString(info.entryScriptFile); } else if(componentType() == CELLAPP_TYPE) { ENGINE_COMPONENT_INFO& info = g_kbeSrvConfig.getCellApp(); entryScriptFileName = PyUnicode_FromString(info.entryScriptFile); } // 添加pywatcher支持 if(!initializePyWatcher(&this->getScript())) return false; // 添加globalData, globalBases支持 pGlobalData_ = new GlobalDataClient(DBMGR_TYPE, GlobalDataServer::GLOBAL_DATA); registerPyObjectToScript("globalData", pGlobalData_); // 注册创建entity的方法到py // 向脚本注册app发布状态 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), publish, __py_getAppPublish, METH_VARARGS, 0); // 注册设置脚本输出类型 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), scriptLogType, __py_setScriptLogType, METH_VARARGS, 0); // 获得资源全路径 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), getResFullPath, __py_getResFullPath, METH_VARARGS, 0); // 是否存在某个资源 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), hasRes, __py_hasRes, METH_VARARGS, 0); // 打开一个文件 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), open, __py_kbeOpen, METH_VARARGS, 0); // 列出目录下所有文件 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), listPathRes, __py_listPathRes, METH_VARARGS, 0); // 匹配相对路径获得全路径 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), matchPath, __py_matchPath, METH_VARARGS, 0); // 获取watcher值 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), getWatcher, __py_getWatcher, METH_VARARGS, 0); // 获取watcher目录 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), getWatcherDir, __py_getWatcherDir, METH_VARARGS, 0); if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_NORMAL", log4cxx::ScriptLevel::SCRIPT_INT)) { ERROR_MSG( "EntityApp::installPyModules: Unable to set KBEngine.LOG_TYPE_NORMAL.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_INFO", log4cxx::ScriptLevel::SCRIPT_INFO)) { ERROR_MSG( "EntityApp::installPyModules: Unable to set KBEngine.LOG_TYPE_INFO.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_ERR", log4cxx::ScriptLevel::SCRIPT_ERR)) { ERROR_MSG( "EntityApp::installPyModules: Unable to set KBEngine.LOG_TYPE_ERR.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_DBG", log4cxx::ScriptLevel::SCRIPT_DBG)) { ERROR_MSG( "EntityApp::installPyModules: Unable to set KBEngine.LOG_TYPE_DBG.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_WAR", log4cxx::ScriptLevel::SCRIPT_WAR)) { ERROR_MSG( "EntityApp::installPyModules: Unable to set KBEngine.LOG_TYPE_WAR.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "NEXT_ONLY", KBE_NEXT_ONLY)) { ERROR_MSG( "EntityApp::installPyModules: Unable to set KBEngine.NEXT_ONLY.\n"); } if(entryScriptFileName != NULL) { entryScript_ = PyImport_Import(entryScriptFileName); SCRIPT_ERROR_CHECK(); S_RELEASE(entryScriptFileName); if(entryScript_.get() == NULL) { return false; } } onInstallPyModules(); return true; }
D3DRenderToTexture::~D3DRenderToTexture() { S_RELEASE( m_shaderResourceView ); S_RELEASE( m_renderTargetView ); S_RELEASE( m_renderTargetTexture ); }
//------------------------------------------------------------------------------------- bool PythonApp::installPyModules() { // 安装入口模块 PyObject *entryScriptFileName = NULL; if(componentType() == BASEAPP_TYPE) { ENGINE_COMPONENT_INFO& info = g_kbeSrvConfig.getBaseApp(); entryScriptFileName = PyUnicode_FromString(info.entryScriptFile); } else if(componentType() == CELLAPP_TYPE) { ENGINE_COMPONENT_INFO& info = g_kbeSrvConfig.getCellApp(); entryScriptFileName = PyUnicode_FromString(info.entryScriptFile); } else if(componentType() == INTERFACES_TYPE) { ENGINE_COMPONENT_INFO& info = g_kbeSrvConfig.getInterfaces(); entryScriptFileName = PyUnicode_FromString(info.entryScriptFile); } else if (componentType() == LOGINAPP_TYPE) { ENGINE_COMPONENT_INFO& info = g_kbeSrvConfig.getLoginApp(); entryScriptFileName = PyUnicode_FromString(info.entryScriptFile); } else if (componentType() == DBMGR_TYPE) { ENGINE_COMPONENT_INFO& info = g_kbeSrvConfig.getDBMgr(); entryScriptFileName = PyUnicode_FromString(info.entryScriptFile); } else { ERROR_MSG("PythonApp::installPyModules: entryScriptFileName is NULL!\n"); } // 注册创建entity的方法到py // 向脚本注册app发布状态 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), publish, __py_getAppPublish, METH_VARARGS, 0); // 注册设置脚本输出类型 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), scriptLogType, __py_setScriptLogType, METH_VARARGS, 0); // 获得资源全路径 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), getResFullPath, __py_getResFullPath, METH_VARARGS, 0); // 是否存在某个资源 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), hasRes, __py_hasRes, METH_VARARGS, 0); // 打开一个文件 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), open, __py_kbeOpen, METH_VARARGS, 0); // 列出目录下所有文件 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), listPathRes, __py_listPathRes, METH_VARARGS, 0); // 匹配相对路径获得全路径 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), matchPath, __py_matchPath, METH_VARARGS, 0); // debug追踪kbe封装的py对象计数 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), debugTracing, script::PyGC::__py_debugTracing, METH_VARARGS, 0); if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_NORMAL", log4cxx::ScriptLevel::SCRIPT_INT)) { ERROR_MSG( "PythonApp::installPyModules: Unable to set KBEngine.LOG_TYPE_NORMAL.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_INFO", log4cxx::ScriptLevel::SCRIPT_INFO)) { ERROR_MSG( "PythonApp::installPyModules: Unable to set KBEngine.LOG_TYPE_INFO.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_ERR", log4cxx::ScriptLevel::SCRIPT_ERR)) { ERROR_MSG( "PythonApp::installPyModules: Unable to set KBEngine.LOG_TYPE_ERR.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_DBG", log4cxx::ScriptLevel::SCRIPT_DBG)) { ERROR_MSG( "PythonApp::installPyModules: Unable to set KBEngine.LOG_TYPE_DBG.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_WAR", log4cxx::ScriptLevel::SCRIPT_WAR)) { ERROR_MSG( "PythonApp::installPyModules: Unable to set KBEngine.LOG_TYPE_WAR.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "NEXT_ONLY", KBE_NEXT_ONLY)) { ERROR_MSG( "PythonApp::installPyModules: Unable to set KBEngine.NEXT_ONLY.\n"); } onInstallPyModules(); if (entryScriptFileName != NULL) { entryScript_ = PyImport_Import(entryScriptFileName); SCRIPT_ERROR_CHECK(); S_RELEASE(entryScriptFileName); if(entryScript_.get() == NULL) { return false; } } return true; }
//------------------------------------------------------------------------------------- PropertyDescription::~PropertyDescription() { S_RELEASE(defaultVal_); dataType_->decRef(); }