int LuaInterface::luaScriptRunner(lua_State* L) { std::string fileName = g_lua.popString(); if(!boost::ends_with(fileName, ".lua")) fileName += ".lua"; try { g_lua.loadScript(fileName); g_lua.call(0, LUA_MULTRET); return g_lua.stackSize(); } catch(LuaException& e) { logError("failed to load script file '", fileName, "' :'", e.what()); return 0; } }
int LuaInterface::luaCollectCppFunction(lua_State* L) { auto funcPtr = static_cast<LuaCppFunctionPtr*>(g_lua.popUserdata()); assert(funcPtr); funcPtr->reset(); return 0; }
int LuaInterface::luaScriptsRunner(lua_State* L) { std::string directory = g_lua.popString(); for(const std::string& fileName : g_resources.listDirectoryFiles(directory)) { if(!boost::ends_with(fileName, ".lua")) continue; try { g_lua.loadScript(directory + "/" + fileName); g_lua.call(0, 0); } catch(LuaException& e) { logError("failed to load script file '", fileName, "' :'", e.what()); } } return 0; }
int LuaInterface::luaCppFunctionCallback(lua_State* L) { // retrieves function pointer from userdata auto funcPtr = static_cast<LuaCppFunctionPtr*>(g_lua.popUpvalueUserdata()); assert(funcPtr); int numRets = 0; // do the call try { g_lua.m_cppCallbackDepth++; numRets = (*(funcPtr->get()))(&g_lua); g_lua.m_cppCallbackDepth--; assert(numRets == g_lua.stackSize()); } catch(stdext::exception& e) { // cleanup stack while(g_lua.stackSize() > 0) g_lua.pop(); numRets = 0; g_lua.pushString(stdext::format("C++ call failed: %s", g_lua.traceback(e.what()))); g_lua.error(); } return numRets; }
void TTreeWidget::dropEvent(QDropEvent *event) { QTreeWidgetItem * pItem = itemAt( event->pos() ); if( ! pItem ) { event->setDropAction( Qt::IgnoreAction ); event->ignore(); } if( pItem == topLevelItem(0) ) { if( (dropIndicatorPosition() == QAbstractItemView::AboveItem ) || (dropIndicatorPosition() == QAbstractItemView::BelowItem ) ) { event->setDropAction( Qt::IgnoreAction ); event->ignore(); } } if ( mIsVarTree ) { LuaInterface * lI = mpHost->getLuaInterface(); if ( ! lI->validMove( pItem ) ) { event->setDropAction( Qt::IgnoreAction ); event->ignore(); } QTreeWidgetItem * newpItem = pItem; QTreeWidgetItem * cItem = selectedItems().first(); QTreeWidgetItem * oldpItem = cItem->parent(); if ( ! lI->reparentVariable( newpItem, cItem, oldpItem ) ) { qDebug()<<"reparent failed"; event->setDropAction( Qt::IgnoreAction ); event->ignore(); } } mIsDropAction = true; QTreeWidget::dropEvent( event ); return; }
BOOL AbilityMachining::IsGemConflict(Obj_Human* pHuman, BYTE GemIndex, BYTE EquipIndex) { __ENTER_FUNCTION Assert( pHuman ); //const _ITEM* pGem = pHuman->GetItem(GemIndex); //const _ITEM* pEquip = pHuman->GetItem(EquipIndex); Item* pGemItem = HumanItemLogic::GetBagItem(pHuman,GemIndex); Item* pEquipItem = HumanItemLogic::GetBagItem(pHuman,EquipIndex); UINT uGemSerialNumber = pGemItem->GetItemTableIndex(); LuaInterface* pLuaInterface; pLuaInterface = pHuman->getScene()->GetLuaInterface(); _ITEM tmpGem; for( INT i=0; i<pEquipItem->GetGemSlotMax(); ++i ) { UINT idx; idx = pEquipItem->GetEquipGemInfo(i).m_GemIndex; if( idx < 1 ) continue; if( pLuaInterface->ExeScript_DDD( ABILITY_LOGIC_SCRIPT, "IsGemConflict", (INT)pHuman->getScene()->SceneID(), (INT)uGemSerialNumber, (INT)idx ) ) { return FALSE; } } return TRUE; __LEAVE_FUNCTION return FALSE; }
int LuaInterface::luaCppFunctionCallback(lua_State* L) { // retrieves function pointer from userdata auto funcPtr = static_cast<LuaCppFunctionPtr*>(g_lua.popUpvalueUserdata()); assert(funcPtr); int numRets = 0; // do the call try { g_lua.m_cppCallbackDepth++; numRets = (*(funcPtr->get()))(&g_lua); g_lua.m_cppCallbackDepth--; assert(numRets == g_lua.stackSize()); } catch(LuaException &e) { logError("lua cpp callback failed: ", e.what()); } return numRets; }
void TTreeWidget::mouseReleaseEvent( QMouseEvent *event ) { QModelIndex indexClicked = indexAt(event->pos()); if( mIsVarTree && indexClicked.isValid() && mClickedItem == indexClicked ) { QRect vrect = visualRect(indexClicked); int itemIndentation = vrect.x() - visualRect(rootIndex()).x(); QRect rect = QRect(header()->sectionViewportPosition(0) + itemIndentation, vrect.y(), style()->pixelMetric(QStyle::PM_IndicatorWidth), vrect.height()); if(rect.contains(event->pos())) { QTreeWidgetItem * clicked = itemFromIndex( indexClicked ); if ( ! ( clicked->flags()&Qt::ItemIsUserCheckable ) ) return; if ( clicked->checkState( 0 ) == Qt::Unchecked ) { clicked->setCheckState( 0, Qt::Checked ); //get all children and see what ones we can save QList< QTreeWidgetItem * > list; getAllChildren( clicked, list ); QListIterator< QTreeWidgetItem * > it(list); LuaInterface * lI = mpHost->getLuaInterface(); VarUnit * vu = lI->getVarUnit(); while( it.hasNext() ) { QTreeWidgetItem * item = it.next(); if ( ! vu->shouldSave( item ) ) item->setCheckState( 0, Qt::Unchecked ); } } else { clicked->setCheckState( 0, Qt::Unchecked ); } return; } } QTreeWidget::mouseReleaseEvent(event); }
void LuaInterface::init() { createLuaState(); // check if demangle_type is working as expected assert(Fw::demangleType<LuaObject>() == "LuaObject"); // register LuaObject, the base of all other objects registerClass<LuaObject>(); bindClassMemberFunction<LuaObject>("getUseCount", &LuaObject::getUseCount); bindClassMemberFunction<LuaObject>("getClassName", &LuaObject::getClassName); registerClassMemberFunction<LuaObject>("getFieldsTable", (LuaCppFunction) ([](LuaInterface* lua) { LuaObjectPtr obj = g_lua.popObject(); obj->luaGetFieldsTable(); return 1; })); }
int LuaInterface::lua_dofile(lua_State* L) { std::string file = g_lua.popString(); try { g_lua.loadScript(file); g_lua.call(0, LUA_MULTRET); return g_lua.stackSize(); } catch(stdext::exception& e) { g_lua.pushString(e.what()); g_lua.error(); return 0; } }
int LuaInterface::lua_dofiles(lua_State* L) { std::string contains = ""; if(g_lua.getTop() > 2) { contains = g_lua.popString(); } bool recursive = false; if(g_lua.getTop() > 1) { recursive = g_lua.popBoolean(); } std::string directory = g_lua.popString(); g_lua.loadFiles(directory, recursive, contains); return 0; }
void LuaInterface::init() { createLuaState(); // store global environment reference pushThread(); getEnv(); m_globalEnv = ref(); pop(); // check if demangle_class is working as expected assert(stdext::demangle_class<LuaObject>() == "LuaObject"); // register LuaObject, the base of all other objects registerClass<LuaObject>(); bindClassMemberFunction<LuaObject>("getUseCount", &LuaObject::getUseCount); bindClassMemberFunction<LuaObject>("getClassName", &LuaObject::getClassName); registerClassMemberFunction<LuaObject>("getFieldsTable", (LuaCppFunction) ([](LuaInterface* lua) -> int { LuaObjectPtr obj = g_lua.popObject(); obj->luaGetFieldsTable(); return 1; })); }
bool XMLexport::writeHost( Host * pT ) { writeStartElement( "Host" ); writeAttribute( "autoClearCommandLineAfterSend", pT->mAutoClearCommandLineAfterSend ? "yes" : "no" ); writeAttribute( "disableAutoCompletion", pT->mDisableAutoCompletion ? "yes" : "no" ); writeAttribute( "printCommand", pT->mPrintCommand ? "yes" : "no" ); writeAttribute( "USE_IRE_DRIVER_BUGFIX", pT->mUSE_IRE_DRIVER_BUGFIX ? "yes" : "no" ); writeAttribute( "mUSE_FORCE_LF_AFTER_PROMPT", pT->mUSE_FORCE_LF_AFTER_PROMPT ? "yes" : "no" ); writeAttribute( "mUSE_UNIX_EOL", pT->mUSE_UNIX_EOL ? "yes" : "no" ); writeAttribute( "mNoAntiAlias", pT->mNoAntiAlias ? "yes" : "no" ); writeAttribute( "mRawStreamDump", pT->mRawStreamDump ? "yes" : "no" ); writeAttribute( "mAlertOnNewData", pT->mAlertOnNewData ? "yes" : "no" ); writeAttribute( "mFORCE_NO_COMPRESSION", pT->mFORCE_NO_COMPRESSION ? "yes" : "no" ); writeAttribute( "mFORCE_GA_OFF", pT->mFORCE_GA_OFF ? "yes" : "no" ); writeAttribute( "mFORCE_SAVE_ON_EXIT", pT->mFORCE_SAVE_ON_EXIT ? "yes" : "no" ); writeAttribute( "mEnableGMCP", pT->mEnableGMCP ? "yes" : "no" ); writeAttribute( "mMapStrongHighlight", pT->mMapStrongHighlight ? "yes" : "no" ); writeAttribute( "mLogStatus", pT->mLogStatus ? "yes" : "no" ); writeAttribute( "mEnableSpellCheck", pT->mEnableSpellCheck ? "yes" : "no" ); writeAttribute( "mShowInfo", pT->mShowInfo ? "yes" : "no" ); writeAttribute( "mAcceptServerGUI", pT->mAcceptServerGUI ? "yes" : "no" ); writeAttribute( "mMapperUseAntiAlias", pT->mMapperUseAntiAlias ? "yes" : "no" ); writeAttribute( "mFORCE_MXP_NEGOTIATION_OFF", pT->mFORCE_MXP_NEGOTIATION_OFF ? "yes" : "no" ); writeAttribute( "mRoomSize", QString::number(pT->mRoomSize)); writeAttribute( "mLineSize", QString::number(pT->mLineSize)); writeAttribute( "mBubbleMode", pT->mBubbleMode ? "yes" : "no"); writeAttribute( "mShowRoomIDs", pT->mShowRoomID ? "yes" : "no"); writeAttribute( "mShowPanel", pT->mShowPanel ? "yes" : "no"); writeAttribute( "mHaveMapperScript", pT->mHaveMapperScript ? "yes" : "no"); QString ignore; QSetIterator<QChar> it(pT->mDoubleClickIgnore); while( it.hasNext() ) { ignore = ignore.append(it.next()); } writeAttribute( "mDoubleClickIgnore", ignore); writeTextElement( "name", pT->mHostName ); //writeTextElement( "login", pT->mLogin ); //writeTextElement( "pass", pT->mPass ); writeStartElement( "mInstalledPackages" ); for( int i=0; i<pT->mInstalledPackages.size(); i++ ) { writeTextElement( "string", pT->mInstalledPackages[i] ); } writeEndElement(); if (pT->mInstalledModules.size()){ qDebug()<<"installed module being done"; writeStartElement( "mInstalledModules" ); QMapIterator<QString, QStringList> it(pT->mInstalledModules); pT->modulesToWrite.clear(); while( it.hasNext() ) { it.next(); writeTextElement("key", it.key()); QStringList entry = it.value(); qDebug()<<"XMLexport"<<entry[0]<<","<<entry[1]; writeTextElement("filepath", entry[0]); writeTextElement("globalSave", entry[1]); if (entry[1].toInt()){ qDebug()<<"adding module to write list:"<<it.key(); pT->modulesToWrite[it.key()] = entry; } writeTextElement("priority", QString::number(pT->mModulePriorities[it.key()])); } writeEndElement(); } writeTextElement( "url", pT->mUrl ); writeTextElement( "serverPackageName", pT->mServerGUI_Package_name ); writeTextElement( "serverPackageVersion", QString::number(pT->mServerGUI_Package_version ) ); writeTextElement( "port", QString::number(pT->mPort) ); writeTextElement( "borderTopHeight", QString::number(pT->mBorderTopHeight) ); writeTextElement( "borderBottomHeight", QString::number(pT->mBorderBottomHeight) ); writeTextElement( "borderLeftWidth", QString::number(pT->mBorderLeftWidth) ); writeTextElement( "borderRightWidth", QString::number(pT->mBorderRightWidth) ); writeTextElement( "wrapAt", QString::number(pT->mWrapAt) ); writeTextElement( "wrapIndentCount", QString::number(pT->mWrapIndentCount) ); writeTextElement( "commandSeperator", pT->mCommandSeperator ); writeTextElement( "mFgColor", pT->mFgColor.name() ); writeTextElement( "mBgColor", pT->mBgColor.name() ); writeTextElement( "mCommandFgColor", pT->mCommandFgColor.name() ); writeTextElement( "mCommandBgColor", pT->mCommandBgColor.name() ); writeTextElement( "mCommandLineFgColor", pT->mCommandLineFgColor.name() ); writeTextElement( "mCommandLineBgColor", pT->mCommandLineBgColor.name() ); writeTextElement( "mBlack", pT->mBlack.name() ); writeTextElement( "mLightBlack", pT->mLightBlack.name() ); writeTextElement( "mRed", pT->mRed.name() ); writeTextElement( "mLightRed", pT->mLightRed.name() ); writeTextElement( "mBlue", pT->mBlue.name() ); writeTextElement( "mLightBlue", pT->mLightBlue.name() ); writeTextElement( "mGreen", pT->mGreen.name() ); writeTextElement( "mLightGreen", pT->mLightGreen.name() ); writeTextElement( "mYellow", pT->mYellow.name() ); writeTextElement( "mLightYellow", pT->mLightYellow.name() ); writeTextElement( "mCyan", pT->mCyan.name() ); writeTextElement( "mLightCyan", pT->mLightCyan.name() ); writeTextElement( "mMagenta", pT->mMagenta.name() ); writeTextElement( "mLightMagenta", pT->mLightMagenta.name() ); writeTextElement( "mWhite", pT->mWhite.name() ); writeTextElement( "mLightWhite", pT->mLightWhite.name() ); writeTextElement( "mDisplayFont", pT->mDisplayFont.toString() ); writeTextElement( "mCommandLineFont", pT->mCommandLineFont.toString() ); writeTextElement( "mCommandSeparator", pT->mCommandSeparator ); writeTextElement( "commandLineMinimumHeight", QString::number(pT->commandLineMinimumHeight) ); writeTextElement( "mFgColor2", pT->mFgColor_2.name() ); writeTextElement( "mBgColor2", pT->mBgColor_2.name() ); writeTextElement( "mBlack2", pT->mBlack_2.name() ); writeTextElement( "mLightBlack2", pT->mLightBlack_2.name() ); writeTextElement( "mRed2", pT->mRed_2.name() ); writeTextElement( "mLightRed2", pT->mLightRed_2.name() ); writeTextElement( "mBlue2", pT->mBlue_2.name() ); writeTextElement( "mLightBlue2", pT->mLightBlue_2.name() ); writeTextElement( "mGreen2", pT->mGreen_2.name() ); writeTextElement( "mLightGreen2", pT->mLightGreen_2.name() ); writeTextElement( "mYellow2", pT->mYellow_2.name() ); writeTextElement( "mLightYellow2", pT->mLightYellow_2.name() ); writeTextElement( "mCyan2", pT->mCyan_2.name() ); writeTextElement( "mLightCyan2", pT->mLightCyan_2.name() ); writeTextElement( "mMagenta2", pT->mMagenta_2.name() ); writeTextElement( "mLightMagenta2", pT->mLightMagenta_2.name() ); writeTextElement( "mWhite2", pT->mWhite_2.name() ); writeTextElement( "mLightWhite2", pT->mLightWhite_2.name() ); writeTextElement( "mSpellDic", pT->mSpellDic ); writeTextElement( "mLineSize", QString::number(pT->mLineSize) ); writeTextElement( "mRoomSize", QString::number(pT->mRoomSize) ); writeEndElement(); // end Host tag writeEndElement(); // end HostPackage tag writeStartElement( "TriggerPackage" ); bool ret = true; typedef list<TTrigger *>::const_iterator ItTriggerUnit; for( ItTriggerUnit it1 = pT->mTriggerUnit.mTriggerRootNodeList.begin(); it1 != pT->mTriggerUnit.mTriggerRootNodeList.end(); it1++) { TTrigger * pChildTrigger = *it1; if( ! pChildTrigger || pChildTrigger->mModuleMember) continue; if( ! pChildTrigger->isTempTrigger()) { ret = writeTrigger( pChildTrigger ); } } writeEndElement(); //end trigger package tag writeStartElement("TimerPackage"); typedef list<TTimer *>::const_iterator ItTimerUnit; for( ItTimerUnit it2 = pT->mTimerUnit.mTimerRootNodeList.begin(); it2 != pT->mTimerUnit.mTimerRootNodeList.end(); it2++) { TTimer * pChildTimer = *it2; if (pChildTimer->mModuleMember) continue; if( ! pChildTimer->isTempTimer()) { ret = writeTimer( pChildTimer ); } } writeEndElement(); writeStartElement("AliasPackage"); typedef list<TAlias *>::const_iterator ItAliasUnit; for( ItAliasUnit it3 = pT->mAliasUnit.mAliasRootNodeList.begin(); it3 != pT->mAliasUnit.mAliasRootNodeList.end(); it3++) { TAlias * pChildAlias = *it3; if (pChildAlias->mModuleMember) continue; if( ! pChildAlias->isTempAlias()) { ret = writeAlias( pChildAlias ); } } writeEndElement(); writeStartElement("ActionPackage"); typedef list<TAction *>::const_iterator ItActionUnit; for( ItActionUnit it4 = pT->mActionUnit.mActionRootNodeList.begin(); it4 != pT->mActionUnit.mActionRootNodeList.end(); it4++) { TAction * pChildAction = *it4; if (pChildAction->mModuleMember) continue; ret = writeAction( pChildAction ); } writeEndElement(); writeStartElement("ScriptPackage"); typedef list<TScript *>::const_iterator ItScriptUnit; for( ItScriptUnit it5 = pT->mScriptUnit.mScriptRootNodeList.begin(); it5 != pT->mScriptUnit.mScriptRootNodeList.end(); it5++) { TScript * pChildScript = *it5; if (pChildScript->mModuleMember) continue; ret = writeScript( pChildScript ); } writeEndElement(); writeStartElement("KeyPackage"); typedef list<TKey *>::const_iterator ItKeyUnit; for( ItKeyUnit it6 = pT->mKeyUnit.mKeyRootNodeList.begin(); it6 != pT->mKeyUnit.mKeyRootNodeList.end(); it6++) { TKey * pChildKey = *it6; if (pChildKey->mModuleMember) continue; ret = writeKey( pChildKey ); } writeEndElement(); writeStartElement("VariablePackage"); LuaInterface * lI = pT->getLuaInterface(); VarUnit * vu = lI->getVarUnit(); //do hidden variables first writeStartElement("HiddenVariables"); QSetIterator<QString> it8( vu->hiddenByUser ); while( it8.hasNext() ) { writeTextElement( "name", it8.next() ); } writeEndElement(); TVar * base = vu->getBase(); QListIterator<TVar *> it7( base->getChildren() ); while( it7.hasNext() ) { TVar * var = it7.next(); writeVariable( var, lI, vu ); } writeEndElement(); return ret; }
ORESULT AbilityMachining::OnProcSuccess(Obj_Human* pHuman) { __ENTER_FUNCTION Assert( pHuman ); AbilityOpera* pAbilityOpera; pAbilityOpera = pHuman->GetAbilityOpera(); Assert( pAbilityOpera ); LuaInterface* pLuaInterface; pLuaInterface = pHuman->getScene()->GetLuaInterface(); GamePlayer* pGamePlayer; pGamePlayer = (GamePlayer*)pHuman->GetPlayer(); Assert( pGamePlayer != NULL ); switch( pAbilityOpera->m_SubType ) { case NORMAL_TYPE: break; case GEM_COMPOUND: { _ITEM_TYPE GemType; UINT bi; ITEM_LOG_PARAM ItemLogParam; ItemLogParam.OpType = ITEM_CREATE_ABILITY_COMPOUD; ItemLogParam.CharGUID = pHuman->GetGUID(); ItemLogParam.SceneID = pHuman->getScene()->SceneID(); ItemLogParam.XPos = pHuman->getWorldPos()->m_fX; ItemLogParam.ZPos = pHuman->getWorldPos()->m_fZ; GemType = ConvertSerial2ItemType( pAbilityOpera->m_uItemIndex ); //GemType.m_Quality++; HumanItemLogic::CreateItemToBag(&ItemLogParam,pHuman,GemType.ToSerial(),bi); if(bi==INVALID_INDEX) //创建失败 { return OR_ERROR; } SaveItemLog(&ItemLogParam); GCNotifyEquip Msg; Msg.SetBagIndex( bi ); Item* pItem = HumanItemLogic::GetBagItem(pHuman,bi); Assert(pItem); pItem->SaveValueTo(Msg.GetItem()); pGamePlayer->SendPacket(&Msg); // 发送成功消息以及物品和状态变化 GCAbilitySucc SuccMsg; SuccMsg.SetAbilityID( EAN_GEM_COMPOUNDED ); SuccMsg.SetPrescriptionID( INVALID_ID ); SuccMsg.SetItemSerial( GemType.ToSerial() ); //SuccMsg.SetSuccFlag( TRUE ); pGamePlayer->SendPacket( &SuccMsg ); } break; case GEM_EMBED: // 不需要额外的处理了 { // 发送成功消息以及物品和状态变化 Item* pItem = HumanItemLogic::GetBagItem(pHuman, pAbilityOpera->m_BagPos[1]); Assert( pItem ); GCAbilitySucc SuccMsg; SuccMsg.SetAbilityID( EAN_GEM_EMBEDDED ); SuccMsg.SetPrescriptionID( INVALID_ID ); SuccMsg.SetItemSerial( pItem->GetItemTableIndex() ); //SuccMsg.SetSuccFlag( TRUE ); pGamePlayer->SendPacket( &SuccMsg ); } break; default: Assert(FALSE); return OR_ERROR; } // 判断一下熟练度是否足够升级了 pLuaInterface->ExeScript_DDD( ABILITY_LOGIC_SCRIPT, "CheckAbilityLevel", (INT)pHuman->getScene()->SceneID(), (INT)pHuman->GetID(), (INT)pAbilityOpera->m_AbilityID ) ; return OR_OK; __LEAVE_FUNCTION return OR_ERROR; }
ORESULT AbilityMachining::CanUseAbility(Obj_Human* pHuman) { __ENTER_FUNCTION Assert( pHuman ); AbilityOpera* pAbilityOpera; pAbilityOpera = pHuman->GetAbilityOpera(); Assert( pAbilityOpera ); switch( pAbilityOpera->m_SubType ) { case NORMAL_TYPE: return AbilityCompound::CanUseAbility(pHuman); case GEM_COMPOUND: { ORESULT res; res = Ability::CanUseAbility(pHuman); if( res != OR_OK ) { return res; } if( (pAbilityOpera->m_BagPos[0] < 0) || (pAbilityOpera->m_BagPos[0] >= MAX_BAG_SIZE) || (pAbilityOpera->m_BagPos[1] < 0) || (pAbilityOpera->m_BagPos[1] >= MAX_BAG_SIZE) ) { Assert(FALSE); return OR_ERROR; } //const _ITEM* pGem1 = pHuman->GetItem(pAbilityOpera->m_BagPos[0]); //const _ITEM* pGem2 = pHuman->GetItem(pAbilityOpera->m_BagPos[1]); Item* pGem1Item = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[0]); Item* pGem2Item = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[1]); Assert( (pGem1Item != NULL) && (pGem2Item != NULL) ); if( (pGem1Item->GetItemClass() != ICLASS_GEM) || (pGem2Item->GetItemClass() != ICLASS_GEM) ) { return OR_STUFF_LACK; } if((pGem1Item->GetItemIndex() != pGem2Item->GetItemIndex())// (pGem1Item->GetItemQual() != pGem2Item->GetItemQual()) ) { return OR_STUFF_LACK; } //if( >= MAX_GEM_QUALITY ) // pGem1Item->GetItemQual()没法再升了 //{ // return OR_CANNOT_UPGRADE; //} return OR_OK; } break; case GEM_EMBED: { ORESULT res; res = Ability::CanUseAbility(pHuman); if( res != OR_OK ) { return res; } if( (pAbilityOpera->m_BagPos[0] < 0) || (pAbilityOpera->m_BagPos[0] >= MAX_BAG_SIZE) || (pAbilityOpera->m_BagPos[1] < 0) || (pAbilityOpera->m_BagPos[1] >= MAX_BAG_SIZE) ) { Assert(FALSE); return OR_ERROR; } //const _ITEM* pGem = pHuman->GetItem(pAbilityOpera->m_BagPos[0]); //const _ITEM* pEquip = pHuman->GetItem(pAbilityOpera->m_BagPos[1]); Item* pGemItem = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[0]); Item* pEquipItem = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[1]); Assert( (pGemItem != NULL) && (pEquipItem != NULL) ); if( (pGemItem->GetItemClass() != ICLASS_GEM) || (pEquipItem->GetItemClass() != ICLASS_EQUIP) ) { return OR_STUFF_LACK; } if( IsGemConflict(pHuman, pAbilityOpera->m_BagPos[0], pAbilityOpera->m_BagPos[1]) == FALSE ) { return OR_GEM_CONFLICT; } LuaInterface* pLuaInterface; pLuaInterface = pHuman->getScene()->GetLuaInterface(); if( pEquipItem->GetGemSlotMax() <= pEquipItem->GetEquipGemCount() || pLuaInterface->ExeScript_DDD( ABILITY_LOGIC_SCRIPT, "TooManyGems", (INT)pHuman->getScene()->SceneID(), (INT)pHuman->GetID(), (INT)pAbilityOpera->m_BagPos[1] ) ) { return OR_GEM_SLOT_LACK; } return OR_OK; } break; default: Assert(FALSE); return OR_ERROR; } return OR_WARNING; __LEAVE_FUNCTION return OR_ERROR; }
ORESULT AbilityMachining::OnProcOver(Obj_Human* pHuman) { __ENTER_FUNCTION Assert( pHuman ); AbilityOpera* pAbilityOpera; pAbilityOpera = pHuman->GetAbilityOpera(); Assert( pAbilityOpera ); switch( pAbilityOpera->m_SubType ) { case NORMAL_TYPE: return AbilityCompound::OnProcOver(pHuman); case GEM_COMPOUND: { ORESULT res; BOOL flag = FALSE; LuaInterface* pLuaInterface; UINT itemIndex; res = CanUseAbility(pHuman); // 以免过程中某些状态发生变化 if( res != OR_OK ) { return res; } pLuaInterface = pHuman->getScene()->GetLuaInterface(); itemIndex = HumanItemLogic::GetBagItem(pHuman, pAbilityOpera->m_BagPos[0])->GetItemTableIndex(); // 不管成功失败,宝石是没有了 GCDiscardItemResult Msg; GamePlayer* pGamePlayer; pGamePlayer = (GamePlayer*)pHuman->GetPlayer(); Assert( pGamePlayer != NULL ); ITEM_LOG_PARAM ItemLogParam; ItemLogParam.OpType = ITEM_GEM_COMPOUND_LOST; BOOL bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,pAbilityOpera->m_BagPos[0]); if(bRet) { SaveItemLog(&ItemLogParam); } Msg.setItemTableIndex( itemIndex ); Msg.setResult( DISCARDITEM_SUCCESS ); Msg.setBagIndex( pAbilityOpera->m_BagPos[0] ); pGamePlayer->SendPacket( &Msg ); bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,pAbilityOpera->m_BagPos[1]); if(bRet) { SaveItemLog(&ItemLogParam); } Msg.setBagIndex( pAbilityOpera->m_BagPos[1] ); pGamePlayer->SendPacket( &Msg ); if( pLuaInterface->ExeScript_DDD( ABILITY_LOGIC_SCRIPT, "CompoundProc", (INT)pHuman->getScene()->SceneID(), (INT)pHuman->GetID(), (INT)itemIndex ) != FALSE ) // 这里显然需要调用 lua script { // 脚本判断是否合成成功,成功了自动增加熟练度 flag = TRUE; pAbilityOpera->m_uItemIndex = itemIndex; res = OnProcSuccess( pHuman ); } if( flag == TRUE ) { return res; } else { return OR_FAILURE; } } break; case GEM_EMBED: { ORESULT res; enum EmbedResult { EMBED_SUCCESS = 0, GEM_GONE, EQUIP_GONE, BOTH_GONE, }; EmbedResult flag; LuaInterface* pLuaInterface; BYTE GemBagIndex = pAbilityOpera->m_BagPos[0]; BYTE EquipBagIndex = pAbilityOpera->m_BagPos[1]; UINT GemIndex = HumanItemLogic::GetBagItem(pHuman,GemBagIndex)->GetItemTableIndex(); UINT EquipIndex = HumanItemLogic::GetBagItem(pHuman,EquipBagIndex)->GetItemTableIndex(); res = CanUseAbility(pHuman); // 以免过程中某些状态发生变化 if( res != OR_OK ) { return res; } pLuaInterface = pHuman->getScene()->GetLuaInterface(); // 脚本判断是否镶嵌成功,如果成功则主动加上熟练度 // 否则返回失败情况 flag = (EmbedResult)pLuaInterface->ExeScript_DDD( ABILITY_LOGIC_SCRIPT, "EmbedProc", (INT)pHuman->getScene()->SceneID(), (INT)pHuman->GetID(), (INT)GemIndex ) ; GCDiscardItemResult Msg; Msg.setResult( DISCARDITEM_SUCCESS ); GamePlayer* pGamePlayer = (GamePlayer*)(pHuman->GetPlayer()); ITEM_LOG_PARAM ItemLogParam; ItemLogParam.OpType = ITEM_MACHINE_LOST; BOOL bRet = FALSE; switch(flag) { case EMBED_SUCCESS: { INT nRet;// = pHuman->UseGem(GemBagIndex, EquipBagIndex); if(USEGEM_SUCCESS == nRet) { g_ImpactCore.SendImpactToUnit(*pHuman, 49, pHuman->GetID()); } } return OnProcSuccess(pHuman); case GEM_GONE: bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,GemBagIndex); if(bRet) SaveItemLog(&ItemLogParam); //pHuman->EraseItem(GemBagIndex); Msg.setItemTableIndex( GemIndex ); Msg.setBagIndex( GemBagIndex ); pGamePlayer->SendPacket( &Msg ); return OR_FAILURE; case EQUIP_GONE: bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,EquipBagIndex); if(bRet) SaveItemLog(&ItemLogParam); //pHuman->EraseItem(EquipBagIndex); Msg.setItemTableIndex( EquipIndex ); Msg.setBagIndex( EquipBagIndex ); pGamePlayer->SendPacket( &Msg ); return OR_FAILURE; case BOTH_GONE: bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,EquipBagIndex); if(bRet) SaveItemLog(&ItemLogParam); bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,GemBagIndex); if(bRet) SaveItemLog(&ItemLogParam); Msg.setItemTableIndex( GemIndex ); Msg.setBagIndex( GemBagIndex ); pGamePlayer->SendPacket( &Msg ); Msg.setItemTableIndex( EquipIndex ); Msg.setBagIndex( EquipBagIndex ); pGamePlayer->SendPacket( &Msg ); return OR_FAILURE; default: Assert(FALSE); return OR_ERROR; } } break; default: Assert(FALSE); return OR_ERROR; } return OR_WARNING; __LEAVE_FUNCTION return OR_ERROR; }
// initialises the irc bot. bool IrcBot::init(string channel, string password, string saveFile) { // make directories that might not exist systemUtils.runProcessWithReturn("mkdir -p history/"); const char* touchCommand = ("touch "+saveFile).c_str(); systemUtils.runProcessWithReturn(touchCommand); dataFile = saveFile; channelSendString = "PRIVMSG "+channel+" :"; channelName = channel; this->channel = channel; // initialise connections to the IRC server struct addrinfo hints, *serverInfo; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; luaInterface = LuaInterface(dataFile); luaInterface.initState(this); pythonInterface = PythonInterface(dataFile); pythonInterface.initState(this); systemUtils = SystemUtils(); cout << "connecting to server..." << endl; if ((getaddrinfo("irc.freenode.net","6667",&hints,&serverInfo)) != 0) { cout << "Error getting address information. Exiting."; return false; } // set up the socket if ((connectionSocket = socket(serverInfo->ai_family,serverInfo->ai_socktype,serverInfo->ai_protocol)) < 0) { cout << "Error with initialising the socket. Exiting."; return false; } // connect to the server if (connect(connectionSocket,serverInfo->ai_addr, serverInfo->ai_addrlen) < 0) { cout << "Error with connecting to the server. Exiting."; close (connectionSocket); return false; } freeaddrinfo(serverInfo); // send nick information sendMessage("NICK "+nick); checkAndParseMessages(); // send user information sendMessage(user); checkAndParseMessages(); // send authentication to NickServ if bot has been set with password if (password != "") { string authMessage = "PRIVMSG NickServ : identify " + nick + " " + password; sendMessage(authMessage); } checkAndParseMessages(); // join the channel string joinMessage = "JOIN "; joinMessage += channel; sendMessage(joinMessage); checkAndParseMessages(); /* we're now on the channel, start the pingTimer */ pingTimer.start(); uptimeTimer.start(); return true; }
int main() { //WSADATA wsData; //IOCP_ASSERT(WSAStartup(MAKEWORD(2, 2), &wsData) == 0, "WSAStartup Failed.\n"); //HANDLE hIOCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, NULL, 2); //IOCP_ASSERT(hIOCP != NULL, "CreateIoCompletionPort Failed.\n"); //SOCKET sLinstenConn = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_IP, 0, 0, WSA_FLAG_OVERLAPPED); //IOCP_ASSERT(sLinstenConn != INVALID_SOCKET, "WSASocket Failed.\n"); //MustPrint("Socket Create Ok.\n"); ////int nReuseAddr = 1; ////setsockopt(Conn, SOL_SOCKET, SO_REUSEADDR, (const char*)&nReuseAddr, sizeof(int)); //SOCKADDR_IN addr; //addr.sin_family = AF_INET; //addr.sin_port = htons(6666); //addr.sin_addr.s_addr = inet_addr(TestIPAddr); // inet_addr("127.0.0.1"); // htonl(INADDR_ANY); //if (bind(sLinstenConn, (PSOCKADDR)&addr, sizeof(addr)) == SOCKET_ERROR) // IOCP_ASSERT(false, "bind Failed.\n"); // //// 参数2: The maximum length of the queue of pending connections. //// If set to SOMAXCONN, the underlying service provider responsible for socket s will set the backlog to a maximum reasonable value. //// There is no standard provision to obtain the actual backlog value //// 等待队列的最大长度。 //if (listen(sLinstenConn, SOMAXCONN) == SOCKET_ERROR) // IOCP_ASSERT(false, "listen Failed.\n"); //MustPrint("Listen OK.\n"); //// 关联监听连接和完成端口 //if (!CreateIoCompletionPort((HANDLE)sLinstenConn, hIOCP, (DWORD_PTR)&sLinstenConn, 0)) // IOCP_ASSERT(false, "CreateIoCompletionPort Associate IOCP with Conn Failed.\n"); //MustPrint("Create IOCP OK.\n"); //// Load the AcceptEx function into memory using WSAIoctl. The WSAIoctl function is an extension of the ioctlsocket() //// function that can use overlapped I/O. The function's 3rd through 6th parameters are input and output buffers where //// we pass the pointer to our AcceptEx function. This is used so that we can call the AcceptEx function directly, rather //// than refer to the Mswsock.lib library. //GUID GuidAcceptEx = WSAID_ACCEPTEX; // WSAID_GETACCEPTEXSOCKADDRS //LPFN_ACCEPTEX lpfnAcceptEx = NULL; //DWORD dwBytes; //int iResult = WSAIoctl(sLinstenConn, SIO_GET_EXTENSION_FUNCTION_POINTER, // &GuidAcceptEx, sizeof (GuidAcceptEx), // &lpfnAcceptEx, sizeof (lpfnAcceptEx), // &dwBytes, NULL, NULL); NetMsg* ReadMsg = new NetMsg; NetMsg* WriteMsg = new NetMsg; //// 创建工作线程, 线程关联数据 //ThreadInfo tThreadInfo; //tThreadInfo.hIOCP = hIOCP; //tThreadInfo.Conn = sLinstenConn; //tThreadInfo.ReadMsg = ReadMsg; //tThreadInfo.WriteMsg = WriteMsg; ////tThreadInfo.lpfAccepEx = lpfnAcceptEx; //HANDLE hWorkThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)ThreadProcess, &tThreadInfo, 0, 0); //IOCP_ASSERT(hWorkThread, "CreateThread Failed.\n"); //MustPrint("CreateThread OK.\n"); //// 创建事件,在AcceptEx中的预分配的连接使用完时,再次创建 //HANDLE hAcceptExEvent = CreateEvent(0, false, false, 0); //IOCP_ASSERT(hAcceptExEvent, "CreateEvent Failed.\n"); //iResult = WSAEventSelect(sLinstenConn, hAcceptExEvent, FD_ACCEPT); //IOCP_ASSERT(iResult != SOCKET_ERROR, "WSAEventSelect Failed.\n"); //MustPrint("Event Select OK.\n"); //// 添加第一批的预创建连接 //AddWaitingAcceptConn(sLinstenConn, lpfnAcceptEx); // 创建luainterface LuaInterface luaInterface; luaInterface.Init(); luaInterface.SetMsgBuffer(ReadMsg, WriteMsg); while (true) { // Flush(sLinstenConn, hAcceptExEvent, lpfnAcceptEx); // TODO: 相关代码ID:201508042055 // LogPrint("ReadMsg[0x%08x] Size = [%d].", &ReadMsg, ReadMsg.GetSize()); luaInterface.Run(); // 等待200ms Sleep(1000); } return 1; }
// we close the connection when deconstructing the bot IrcBot::~IrcBot() { luaInterface.closeState(); pythonInterface.closeState(); close (connectionSocket); // close the socket }
TEST(LuaUIOperationsTest, Copy) { QApplication app(argc, argv); LuaInterface luaInterface; auto L = luaInterface.luaState(); luaInterface.hideUI(true); luaInterface.initLua(); auto mdiArea = LuaIntf::Lua::getGlobal<QMdiArea*>(L, "mdiArea"); if(mdiArea->subWindowList().count() == 0) { LuaIntf::LuaRef(L, "new_file")(); } mdiArea->setActiveSubWindow(mdiArea->subWindowList().at(0)); auto mdiChild = dynamic_cast<CadMdiChild*>(mdiArea->activeSubWindow()->widget()); auto storageManager = mdiChild->storageManager(); auto documentCanvas = mdiChild->viewer()->documentCanvas(); lc::entity::Line_CSPtr createdEntity; std::vector<lc::entity::CADEntity_CSPtr> entities; entities = storageManager->entityContainer().asVector(); for(auto entity : entities) { storageManager->removeEntity(entity); } EXPECT_EQ(0, storageManager->entityContainer().asVector().size()); LuaIntf::LuaRef(L, "create_line")(); LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(0, 0)); LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(100, 100)); EXPECT_EQ(1, storageManager->entityContainer().asVector().size()) << "Line was not created"; documentCanvas->makeSelection(0, 0, 100, 100, false, false); documentCanvas->closeSelection(); EXPECT_EQ(1, mdiChild->selection().size()) << "Entity not selected"; LuaIntf::LuaRef(L, "copy_selected_entities")(); LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(0, 0)); LuaIntf::LuaRef(L, "event.trigger")("point", lc::geo::Coordinate(100, 100)); entities = storageManager->entityContainer().asVector(); ASSERT_EQ(2, entities.size()); createdEntity = std::dynamic_pointer_cast<const lc::entity::Line>(entities.at(0)); EXPECT_EQ(lc::geo::Coordinate(0, 0), createdEntity->start()); EXPECT_EQ(lc::geo::Coordinate(100, 100), createdEntity->end()); createdEntity = std::dynamic_pointer_cast<const lc::entity::Line>(entities.at(1)); EXPECT_EQ(lc::geo::Coordinate(100, 100), createdEntity->start()); EXPECT_EQ(lc::geo::Coordinate(200, 200), createdEntity->end()); }
/* the function which parses the messages that the user sends * this should really be in its own file */ int IrcBot::parseMessage(string str) { string username = getUsername(str); string serverInfo = getServerInfo(str); string userMessage = getUserMessage(str); bool isPrivateMessage = false; // if the message starts with an exclamation mark, let the bot respond to it if (userMessage.substr(0, 1) == "!") userMessage = this->nick + ": " + userMessage.substr(1,userMessage.length()); adminCommand thisCommand; thisCommand.userMessage = userMessage; thisCommand.isPrivateMessage = isPrivateMessage; if (serverInfo.find("PRIVMSG "+ircbotName) != string::npos && connected) { // this is a private message to the irc bot parsePrivateMessage(str); isPrivateMessage = true; } /* the returned str is just what the user text is without the IRC prefix information * note: this should not be done this way, a function should be called which has the * sole purpose of getting the user text from the full message */ if (!isPrivateMessage) writeHistory(username, serverInfo, userMessage); if (stringSearch(str, "End of /NAMES list")) { connected = true; // intro messages to the server have finished string beginningTrimmed = str.substr(str.find(channelName)+channelName.size()+2); string namesString = beginningTrimmed.substr(0, beginningTrimmed.find(":")-2); vector<string> namesOfUsersConnected; istringstream ss( namesString ); while (!ss.eof()) { string x; getline( ss, x, ' ' ); namesOfUsersConnected.push_back(x); } } if (serverInfo.find("JOIN") != string::npos) { string checkAccess = "PRIVMSG NickServ : ACC " + username; sendMessage(checkAccess); } else if (serverInfo.find("PART") != string::npos || serverInfo.find("QUIT") != string::npos) { // for detecting them leaving the channel // wipe the username from the map responsible for relaying text directUserText.erase(username); // wipe any admin commansd the user have stored in the map so they aren't run on next login adminCommandsUsed.erase(username); std::vector<string>::iterator position = std::find(authenticatedUsernames.begin(), authenticatedUsernames.end(), username); if (position != authenticatedUsernames.end()) authenticatedUsernames.erase(position); } if (stringSearch(userMessage, ircbotName+": help")) { // these are a list of c++ commands only, not including the lua plugin commands. outputToUser(username, "I have all kinds of fun features! Here's the list:\n" "\"!uptime\". Displays uptime.\n" "\"!history <start|stop>\". Starts/stops logging channel conversation.\n" "\"!shutdown\". Shuts me down. I won't come back though, please don't do that to me. :(\n" "Lua: !admins, !topic, !op, !deop, !<save|load> data, !history <date>, !seen <username>, !seenall, !reactions, !reaction enable <reaction>, !reaction disable <reaction>, !relay, !stop relay, !acknowledge, !stop acknowledge, !time, !update repo"); } else if (stringSearch(userMessage, ircbotName+": uptime")) { int uptime = uptimeTimer.elapsedTime(); int days = uptime / 60 / 60 / 24; int hours = (uptime / 60 / 60) % 24; int minutes = (uptime / 60) % 60; int seconds = uptime % 60; std::stringstream ss; ss << "I have been alive for "; ss << days; if (days == 1) ss << " day, "; else ss << " days, "; ss << hours; if (hours == 1) ss << " hour, "; else ss << " hours, "; ss << minutes; if (minutes == 1) ss << " minute, and "; else ss << " minutes, and "; ss << seconds; if (seconds == 1) ss << " second."; else ss << " seconds."; outputToSource(ss.str(), username, isPrivateMessage); } else if (stringSearch(userMessage, ircbotName+": history start")) { if (isPrivateMessage) outputToUser(username, "This command cannot be used in private chat."); else { if (loggingHistory) { loggingHistory = false; outputToChannel("I'm already keeping my ears peeled for tasty parsable information!"); loggingHistory = true; } else { outputToChannel("My ears are now open, I shall store future conversations for tasty parsing later."); loggingHistory = true; } } } else if (stringSearch(userMessage, ircbotName+": history stop")) { if (isPrivateMessage) outputToUser(username, "This command cannot be used in private chat."); else { if (loggingHistory) { loggingHistory = false; outputToChannel("Ah I see, cunning secret conversations. I know not of what you speak, your sneakrets are safe with me."); } else outputToChannel("My ears are already shut to your sneakiness. I'll keep it secret. I'll keep it safe."); } } else if (stringSearch(userMessage, ircbotName+": shutdown")) { if (isPrivateMessage) outputToUser(username, "This command cannot be used in private chat."); else { outputToChannel("Oh I get it. It's fine, I'm a pain sometimes I guess. Croo."); sendMessage("QUIT"); close (connectionSocket); //close the open socket cout << "Shutting down..."; return SHUTDOWN; } } /* once the connection has been established, we can run the lua and python plugins */ if (connected) { luaInterface.runPlugins(username, serverInfo, userMessage, isPrivateMessage); pythonInterface.runPlugins(username, serverInfo, userMessage, isPrivateMessage); } return SUCCESS; }
ORESULT AbilityInlay::CanUseAbility(Obj_Human* pHuman) { __ENTER_FUNCTION Assert( pHuman ); AbilityOpera* pAbilityOpera; pAbilityOpera = pHuman->GetAbilityOpera(); Assert( pAbilityOpera ); ORESULT res; res = Ability::CanUseAbility(pHuman); if( res != OR_OK ) { return res; } CHAR MaterialBagIndex1 = (CHAR)pAbilityOpera->m_BagPos[2]; CHAR MaterialBagIndex2 = (CHAR)pAbilityOpera->m_BagPos[3]; if( (pAbilityOpera->m_BagPos[0] < 0) || (pAbilityOpera->m_BagPos[0] >= MAX_BAG_SIZE) || (pAbilityOpera->m_BagPos[1] < 0) || (pAbilityOpera->m_BagPos[1] >= MAX_BAG_SIZE) || (MaterialBagIndex1>= MAX_BAG_SIZE)|| (MaterialBagIndex2>= MAX_BAG_SIZE) ) { Assert(FALSE); return OR_ERROR; } Item* pGemItem = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[0] ); Item* pEquipItem = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[1] ); Item* pMaterialItem1 = NULL; Item* pMaterialItem2 = NULL; if( MaterialBagIndex1 != -1 ) { pMaterialItem1 = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[2] ); Assert( pMaterialItem1 != NULL ); } if( MaterialBagIndex2 != -1 ) { pMaterialItem2 = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[3] ); Assert( pMaterialItem2 != NULL ); } Assert( (pGemItem != NULL) && (pEquipItem != NULL) ); if( (pGemItem->IsLock()) || (pEquipItem->IsLock()) || (pGemItem->IsPWLock()) || (pEquipItem->IsPWLock()) || (pGemItem->GetItemClass() != ICLASS_GEM) || (pEquipItem->GetItemClass() != ICLASS_EQUIP) ) { return OR_STUFF_LACK; } //if( pHuman->__GetAbilityLevel(pAbilityOpera->m_AbilityID) < pGemItem->GetItemQual() ) //{ // return OR_NO_LEVEL; //} if( IsGemConflict(pHuman, pAbilityOpera->m_BagPos[0], pAbilityOpera->m_BagPos[1]) == FALSE ) { return OR_GEM_CONFLICT; } LuaInterface* pLuaInterface; pLuaInterface = pHuman->getScene()->GetLuaInterface(); if( pEquipItem->GetGemSlotMax() <= pEquipItem->GetEquipGemCount() || pLuaInterface->ExeScript_DDD( ABILITY_LOGIC_SCRIPT, DEF_GEM_COUNT_CHECK, (INT)pHuman->getScene()->SceneID(), (INT)pHuman->GetID(), (INT)pAbilityOpera->m_BagPos[1] ) ) { return OR_GEM_SLOT_LACK; } if( pLuaInterface->ExeScript_DDDD( ABILITY_LOGIC_SCRIPT, DEF_IS_GEM_FIT_EQUIP, (INT)pHuman->getScene()->SceneID(), (INT)pHuman->GetID(), pGemItem->GetItemTableIndex(), pAbilityOpera->m_BagPos[1] ) == 0 ) { // 判断宝石和装备是否匹配 return OR_GEM_NOT_FIT_EQUIP; } return OR_OK; __LEAVE_FUNCTION return OR_ERROR; }
ORESULT AbilityInlay::OnProcOver(Obj_Human* pHuman) { __ENTER_FUNCTION Assert( pHuman ); ORESULT res; res = CanUseAbility(pHuman); // 以免过程中某些状态发生变化 if( res != OR_OK ) { return res; } AbilityOpera* pAbilityOpera; pAbilityOpera = pHuman->GetAbilityOpera(); Assert( pAbilityOpera ); BYTE GemBagIndex = pAbilityOpera->m_BagPos[0]; BYTE EquipBagIndex = pAbilityOpera->m_BagPos[1]; CHAR MaterialBagIndex1 = (CHAR)pAbilityOpera->m_BagPos[2]; CHAR MaterialBagIndex2 = (CHAR)pAbilityOpera->m_BagPos[3]; Item* pGemItem = HumanItemLogic::GetBagItem( pHuman, GemBagIndex ); Item* pEquipItem = HumanItemLogic::GetBagItem( pHuman, EquipBagIndex ); Item* pMaterialItem1 = NULL; Item* pMaterialItem2 = NULL; if( MaterialBagIndex1 != -1 ) { pMaterialItem1 = HumanItemLogic::GetBagItem( pHuman, MaterialBagIndex1 ); Assert(pMaterialItem1 != NULL); } if( MaterialBagIndex2 != -1 ) { pMaterialItem2 = HumanItemLogic::GetBagItem( pHuman, MaterialBagIndex2 ); Assert(pMaterialItem1 != NULL); } Assert( (pGemItem != NULL) && (pEquipItem != NULL) ); UINT GemIndex = pGemItem->GetItemTableIndex(); UINT EquipIndex = pEquipItem->GetItemTableIndex(); INT MaterialIndex1 = -1; INT MaterialIndex2 = -1; if( pMaterialItem1 ) { MaterialIndex1 = pMaterialItem1->GetItemTableIndex(); //if(pMaterialItem1) // pMaterialItem1->SetItemParam( 0, IPV_INT, INT( EquipBagIndex ) );//modi:lby20071114记录当前装备的id } if( pMaterialItem2 ) { MaterialIndex2 = pMaterialItem2->GetItemTableIndex(); //if(pMaterialItem2) //pMaterialItem2->SetItemParam( 0, IPV_INT, INT( EquipBagIndex ) );//modi:lby20071114记录当前装备的id } if( (pGemItem->IsLock()) || (pEquipItem->IsLock()) || (pGemItem->IsPWLock()) || (pEquipItem->IsPWLock()) ) { // 这里判断是否锁定,下面消耗时就不再判断了 return OR_STUFF_LACK; } if( pMaterialItem1 ) { if( pMaterialItem1->IsLock() || pMaterialItem1->IsPWLock() ) return OR_STUFF_LACK; } if( pMaterialItem2 ) { if( pMaterialItem2->IsLock() || pMaterialItem2->IsPWLock() ) return OR_STUFF_LACK; } EmbedResult flag; LuaInterface* pLuaInterface; pLuaInterface = pHuman->getScene()->GetLuaInterface(); // 脚本判断是否镶嵌成功,如果成功则主动加上熟练度 // 否则返回失败情况 flag = (EmbedResult)pLuaInterface->ExeScript_DDDDDD(ABILITY_LOGIC_SCRIPT, DEF_GEM_EMBED_PROCESS, (INT)pHuman->getScene()->SceneID(), (INT)pHuman->GetID(), (INT)EquipBagIndex, (INT)GemIndex, (INT)MaterialIndex1, (INT)MaterialIndex2 ) ; GCDiscardItemResult Msg; Msg.setResult( DISCARDITEM_SUCCESS ); GamePlayer* pGamePlayer = (GamePlayer*)(pHuman->GetPlayer()); ITEM_LOG_PARAM ItemLogParam; ItemLogParam.OpType = ITEM_INLAY_LOST; BOOL bRet = FALSE; switch(flag) { case EMBED_SUCCESS: { if( MaterialIndex1 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex1); if(bRet) SaveItemLog(&ItemLogParam); } if( MaterialIndex2 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex2); if(bRet) SaveItemLog(&ItemLogParam); } INT nRet ;//= pHuman->UseGem(GemBagIndex, EquipBagIndex); if(USEGEM_SUCCESS == nRet) { g_ImpactCore.SendImpactToUnit(*pHuman, 49, pHuman->GetID()); } return OnProcSuccess(pHuman); } case GEM_GONE: if( MaterialIndex1 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,GemBagIndex); if(bRet) SaveItemLog(&ItemLogParam); } if( MaterialIndex2 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex2); if(bRet) SaveItemLog(&ItemLogParam); } bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,GemBagIndex); if(bRet) SaveItemLog(&ItemLogParam); Msg.setItemTableIndex( GemIndex ); Msg.setBagIndex( GemBagIndex ); pGamePlayer->SendPacket( &Msg ); return OR_FAILURE; case EQUIP_GONE: if( MaterialIndex1 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,EquipBagIndex); if(bRet) SaveItemLog(&ItemLogParam); } if( MaterialIndex2 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex2); if(bRet) SaveItemLog(&ItemLogParam); } bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,EquipBagIndex); if(bRet) SaveItemLog(&ItemLogParam); Msg.setItemTableIndex( EquipIndex ); Msg.setBagIndex( EquipBagIndex ); pGamePlayer->SendPacket( &Msg ); return OR_FAILURE; case BOTH_GONE: if( MaterialIndex1 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,EquipBagIndex); if(bRet) SaveItemLog(&ItemLogParam); } if( MaterialIndex2 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,GemBagIndex); if(bRet) SaveItemLog(&ItemLogParam); } bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,EquipBagIndex); if(bRet) SaveItemLog(&ItemLogParam); bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,GemBagIndex); if(bRet) SaveItemLog(&ItemLogParam); Msg.setItemTableIndex( GemIndex ); Msg.setBagIndex( GemBagIndex ); pGamePlayer->SendPacket( &Msg ); Msg.setItemTableIndex( EquipIndex ); Msg.setBagIndex( EquipBagIndex ); pGamePlayer->SendPacket( &Msg ); return OR_FAILURE; case ENERGY_NOT_ENOUGH: return OR_NOT_ENOUGH_ENERGY; case GEM_DEGRADE_1: { if( MaterialIndex1 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex1); if(bRet) SaveItemLog(&ItemLogParam); } if( MaterialIndex2 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex2); if(bRet) SaveItemLog(&ItemLogParam); } bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,GemBagIndex); if(bRet) SaveItemLog(&ItemLogParam); _ITEM_TYPE type = ConvertSerial2ItemType(GemIndex); /* if(type.m_Quality>1) { type.m_Quality--; ITEM_LOG_PARAM ItemLogParam; ItemLogParam.OpType = ITEM_CREATE_REMOVE_GEM; ItemLogParam.CharGUID = pHuman->GetGUID(); ItemLogParam.SceneID = pHuman->getScene()->SceneID(); ItemLogParam.XPos = pHuman->getWorldPos()->m_fX; ItemLogParam.ZPos = pHuman->getWorldPos()->m_fZ; UINT GemBagIndex_Temp = GemBagIndex; HumanItemLogic::CreateItemToBag(&ItemLogParam,pHuman,type.ToSerial(),GemBagIndex_Temp,ITEM_DROP_MONSTER); }*/ Msg.setItemTableIndex( GemIndex ); Msg.setBagIndex( GemBagIndex ); pGamePlayer->SendPacket( &Msg ); } return OR_FAILURE; case GEM_DEGRADE_2: { if( MaterialIndex1 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex1); if(bRet) SaveItemLog(&ItemLogParam); } if( MaterialIndex2 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex2); if(bRet) SaveItemLog(&ItemLogParam); } bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,GemBagIndex); if(bRet) SaveItemLog(&ItemLogParam); _ITEM_TYPE type = ConvertSerial2ItemType(GemIndex); /*if(type.m_Quality>2) { type.m_Quality -= 2; ITEM_LOG_PARAM ItemLogParam; ItemLogParam.OpType = ITEM_CREATE_REMOVE_GEM; ItemLogParam.CharGUID = pHuman->GetGUID(); ItemLogParam.SceneID = pHuman->getScene()->SceneID(); ItemLogParam.XPos = pHuman->getWorldPos()->m_fX; ItemLogParam.ZPos = pHuman->getWorldPos()->m_fZ; UINT GemBagIndex_Temp = GemBagIndex; HumanItemLogic::CreateItemToBag(&ItemLogParam,pHuman,type.ToSerial(),GemBagIndex_Temp,ITEM_DROP_MONSTER); }*/ Msg.setItemTableIndex( GemIndex ); Msg.setBagIndex( GemBagIndex ); pGamePlayer->SendPacket( &Msg ); } return OR_FAILURE; case GEM_DEGRADE_3: { if( MaterialIndex1 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex1); if(bRet) SaveItemLog(&ItemLogParam); } if( MaterialIndex2 != -1 ) { bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,MaterialBagIndex2); if(bRet) SaveItemLog(&ItemLogParam); } bRet = HumanItemLogic::EraseBagItem(&ItemLogParam,pHuman,GemBagIndex); if(bRet) SaveItemLog(&ItemLogParam); _ITEM_TYPE type = ConvertSerial2ItemType(GemIndex); /*if(type.m_Quality>3) { type.m_Quality -= 3; ITEM_LOG_PARAM ItemLogParam; ItemLogParam.OpType = ITEM_CREATE_REMOVE_GEM; ItemLogParam.CharGUID = pHuman->GetGUID(); ItemLogParam.SceneID = pHuman->getScene()->SceneID(); ItemLogParam.XPos = pHuman->getWorldPos()->m_fX; ItemLogParam.ZPos = pHuman->getWorldPos()->m_fZ; UINT GemBagIndex_Temp = GemBagIndex; HumanItemLogic::CreateItemToBag(&ItemLogParam,pHuman,type.ToSerial(),GemBagIndex_Temp,ITEM_DROP_MONSTER); }*/ Msg.setItemTableIndex( GemIndex ); Msg.setBagIndex( GemBagIndex ); pGamePlayer->SendPacket( &Msg ); } return OR_FAILURE; default: Assert(FALSE); return OR_ERROR; } __LEAVE_FUNCTION return OR_ERROR; }
bool XMLexport::writeHost(Host* pHost) { bool isOk = true; writeStartElement("Host"); writeAttribute("autoClearCommandLineAfterSend", pHost->mAutoClearCommandLineAfterSend ? "yes" : "no"); writeAttribute("disableAutoCompletion", pHost->mDisableAutoCompletion ? "yes" : "no"); writeAttribute("printCommand", pHost->mPrintCommand ? "yes" : "no"); writeAttribute("USE_IRE_DRIVER_BUGFIX", pHost->mUSE_IRE_DRIVER_BUGFIX ? "yes" : "no"); writeAttribute("mUSE_FORCE_LF_AFTER_PROMPT", pHost->mUSE_FORCE_LF_AFTER_PROMPT ? "yes" : "no"); writeAttribute("mUSE_UNIX_EOL", pHost->mUSE_UNIX_EOL ? "yes" : "no"); writeAttribute("mNoAntiAlias", pHost->mNoAntiAlias ? "yes" : "no"); writeAttribute("mEchoLuaErrors", pHost->mEchoLuaErrors ? "yes" : "no"); // FIXME: Change to a string or integer property when possible to support more // than false (perhaps 0 or "PlainText") or true (perhaps 1 or "HTML") in the // future - phpBB code might be useful if it can be done. writeAttribute("mRawStreamDump", pHost->mIsNextLogFileInHtmlFormat ? "yes" : "no"); writeAttribute("mIsLoggingTimestamps", pHost->mIsLoggingTimestamps ? "yes" : "no"); writeAttribute("mAlertOnNewData", pHost->mAlertOnNewData ? "yes" : "no"); writeAttribute("mFORCE_NO_COMPRESSION", pHost->mFORCE_NO_COMPRESSION ? "yes" : "no"); writeAttribute("mFORCE_GA_OFF", pHost->mFORCE_GA_OFF ? "yes" : "no"); writeAttribute("mFORCE_SAVE_ON_EXIT", pHost->mFORCE_SAVE_ON_EXIT ? "yes" : "no"); writeAttribute("mEnableGMCP", pHost->mEnableGMCP ? "yes" : "no"); writeAttribute("mEnableMSDP", pHost->mEnableMSDP ? "yes" : "no"); writeAttribute("mMapStrongHighlight", pHost->mMapStrongHighlight ? "yes" : "no"); writeAttribute("mLogStatus", pHost->mLogStatus ? "yes" : "no"); writeAttribute("mEnableSpellCheck", pHost->mEnableSpellCheck ? "yes" : "no"); writeAttribute("mShowInfo", pHost->mShowInfo ? "yes" : "no"); writeAttribute("mAcceptServerGUI", pHost->mAcceptServerGUI ? "yes" : "no"); writeAttribute("mMapperUseAntiAlias", pHost->mMapperUseAntiAlias ? "yes" : "no"); writeAttribute("mFORCE_MXP_NEGOTIATION_OFF", pHost->mFORCE_MXP_NEGOTIATION_OFF ? "yes" : "no"); writeAttribute("mRoomSize", QString::number(pHost->mRoomSize, 'f', 1)); writeAttribute("mLineSize", QString::number(pHost->mLineSize, 'f', 1)); writeAttribute("mBubbleMode", pHost->mBubbleMode ? "yes" : "no"); writeAttribute("mShowRoomIDs", pHost->mShowRoomID ? "yes" : "no"); writeAttribute("mShowPanel", pHost->mShowPanel ? "yes" : "no"); writeAttribute("mHaveMapperScript", pHost->mHaveMapperScript ? "yes" : "no"); QString ignore; QSetIterator<QChar> it(pHost->mDoubleClickIgnore); while (it.hasNext()) { ignore = ignore.append(it.next()); } writeAttribute("mDoubleClickIgnore", ignore); { // Blocked so that indentation reflects that of the XML file writeTextElement("name", pHost->mHostName); writeStartElement("mInstalledPackages"); for (int i = 0; i < pHost->mInstalledPackages.size(); ++i) { writeTextElement("string", pHost->mInstalledPackages.at(i)); } writeEndElement(); // </mInstalledPackages> if (pHost->mInstalledModules.size()) { writeStartElement("mInstalledModules"); QMapIterator<QString, QStringList> it(pHost->mInstalledModules); pHost->modulesToWrite.clear(); while (it.hasNext()) { it.next(); writeTextElement("key", it.key()); QStringList entry = it.value(); writeTextElement("filepath", entry.at(0)); writeTextElement("globalSave", entry.at(1)); if (entry.at(1).toInt()) { pHost->modulesToWrite.insert(it.key(), entry); } writeTextElement("priority", QString::number(pHost->mModulePriorities.value(it.key()))); } writeEndElement(); // </mInstalledModules> } // CHECK: Do we need: // else { // writeEmptyElement( "mInstalledModules" ); // i.e. <mInstalledModules /> // } writeTextElement("url", pHost->mUrl); writeTextElement("serverPackageName", pHost->mServerGUI_Package_name); writeTextElement("serverPackageVersion", QString::number(pHost->mServerGUI_Package_version)); writeTextElement("port", QString::number(pHost->mPort)); writeTextElement("borderTopHeight", QString::number(pHost->mBorderTopHeight)); writeTextElement("borderBottomHeight", QString::number(pHost->mBorderBottomHeight)); writeTextElement("borderLeftWidth", QString::number(pHost->mBorderLeftWidth)); writeTextElement("borderRightWidth", QString::number(pHost->mBorderRightWidth)); writeTextElement("wrapAt", QString::number(pHost->mWrapAt)); writeTextElement("wrapIndentCount", QString::number(pHost->mWrapIndentCount)); writeTextElement("mFgColor", pHost->mFgColor.name()); writeTextElement("mBgColor", pHost->mBgColor.name()); writeTextElement("mCommandFgColor", pHost->mCommandFgColor.name()); writeTextElement("mCommandBgColor", pHost->mCommandBgColor.name()); writeTextElement("mCommandLineFgColor", pHost->mCommandLineFgColor.name()); writeTextElement("mCommandLineBgColor", pHost->mCommandLineBgColor.name()); writeTextElement("mBlack", pHost->mBlack.name()); writeTextElement("mLightBlack", pHost->mLightBlack.name()); writeTextElement("mRed", pHost->mRed.name()); writeTextElement("mLightRed", pHost->mLightRed.name()); writeTextElement("mBlue", pHost->mBlue.name()); writeTextElement("mLightBlue", pHost->mLightBlue.name()); writeTextElement("mGreen", pHost->mGreen.name()); writeTextElement("mLightGreen", pHost->mLightGreen.name()); writeTextElement("mYellow", pHost->mYellow.name()); writeTextElement("mLightYellow", pHost->mLightYellow.name()); writeTextElement("mCyan", pHost->mCyan.name()); writeTextElement("mLightCyan", pHost->mLightCyan.name()); writeTextElement("mMagenta", pHost->mMagenta.name()); writeTextElement("mLightMagenta", pHost->mLightMagenta.name()); writeTextElement("mWhite", pHost->mWhite.name()); writeTextElement("mLightWhite", pHost->mLightWhite.name()); writeTextElement("mDisplayFont", pHost->mDisplayFont.toString()); writeTextElement("mCommandLineFont", pHost->mCommandLineFont.toString()); // There was a mis-spelt duplicate commandSeperator above but it is now gone writeTextElement("mCommandSeparator", pHost->mCommandSeparator); writeTextElement("commandLineMinimumHeight", QString::number(pHost->commandLineMinimumHeight)); writeTextElement("mFgColor2", pHost->mFgColor_2.name()); writeTextElement("mBgColor2", pHost->mBgColor_2.name()); writeTextElement("mBlack2", pHost->mBlack_2.name()); writeTextElement("mLightBlack2", pHost->mLightBlack_2.name()); writeTextElement("mRed2", pHost->mRed_2.name()); writeTextElement("mLightRed2", pHost->mLightRed_2.name()); writeTextElement("mBlue2", pHost->mBlue_2.name()); writeTextElement("mLightBlue2", pHost->mLightBlue_2.name()); writeTextElement("mGreen2", pHost->mGreen_2.name()); writeTextElement("mLightGreen2", pHost->mLightGreen_2.name()); writeTextElement("mYellow2", pHost->mYellow_2.name()); writeTextElement("mLightYellow2", pHost->mLightYellow_2.name()); writeTextElement("mCyan2", pHost->mCyan_2.name()); writeTextElement("mLightCyan2", pHost->mLightCyan_2.name()); writeTextElement("mMagenta2", pHost->mMagenta_2.name()); writeTextElement("mLightMagenta2", pHost->mLightMagenta_2.name()); writeTextElement("mWhite2", pHost->mWhite_2.name()); writeTextElement("mLightWhite2", pHost->mLightWhite_2.name()); writeTextElement("mSpellDic", pHost->mSpellDic); // TODO: Consider removing these sub-elements that duplicate the same // attributes - which WERE bugged - when we update the XML format, must leave // them in place for now even though we no longer use them for compatibility // with older version of Mudlet writeTextElement("mLineSize", QString::number(pHost->mLineSize, 'f', 1)); writeTextElement("mRoomSize", QString::number(pHost->mRoomSize, 'f', 1)); writeEndElement(); // </Host> } writeEndElement(); // </HostPackage> if (hasError()) { isOk = false; } // Use if() to block each XXXXPackage element to limit scope of iterator so // we can use more of the same code in each block - and to escape quicker on // error... if (isOk) { writeStartElement("TriggerPackage"); for (auto it = pHost->mTriggerUnit.mTriggerRootNodeList.begin(); isOk && it != pHost->mTriggerUnit.mTriggerRootNodeList.end(); ++it) { if (!(*it) || (*it)->mModuleMember) { continue; } if (!(*it)->isTempTrigger()) { if (!writeTrigger(*it)) { isOk = false; } } } writeEndElement(); // </TriggerPackage> } if (isOk) { writeStartElement("TimerPackage"); for (auto it = pHost->mTimerUnit.mTimerRootNodeList.begin(); isOk && it != pHost->mTimerUnit.mTimerRootNodeList.end(); ++it) { if (!(*it) || (*it)->mModuleMember) { continue; } if (!(*it)->isTempTimer()) { if (!writeTimer(*it)) { isOk = false; } } } writeEndElement(); // </TimerPackage> } if (isOk) { writeStartElement("AliasPackage"); for (auto it = pHost->mAliasUnit.mAliasRootNodeList.begin(); isOk && it != pHost->mAliasUnit.mAliasRootNodeList.end(); ++it) { if (!(*it) || (*it)->mModuleMember) { continue; } if (!(*it)->isTempAlias()) { if (!writeAlias(*it)) { isOk = false; } } } writeEndElement(); // </AliasPackage> } if (isOk) { writeStartElement("ActionPackage"); for (auto it = pHost->mActionUnit.mActionRootNodeList.begin(); isOk && it != pHost->mActionUnit.mActionRootNodeList.end(); ++it) { if (!(*it) || (*it)->mModuleMember) { continue; } if (!writeAction(*it)) { isOk = false; } } writeEndElement(); // </ActionPackage> } if (isOk) { writeStartElement("ScriptPackage"); for (auto it = pHost->mScriptUnit.mScriptRootNodeList.begin(); isOk && it != pHost->mScriptUnit.mScriptRootNodeList.end(); ++it) { if (!(*it) || (*it)->mModuleMember) { continue; } if (!writeScript(*it)) { isOk = false; } } writeEndElement(); // </ScriptPackage> } if (isOk) { writeStartElement("KeyPackage"); for (auto it = pHost->mKeyUnit.mKeyRootNodeList.begin(); isOk && it != pHost->mKeyUnit.mKeyRootNodeList.end(); ++it) { if (!(*it) || (*it)->mModuleMember) { continue; } if (!writeKey(*it)) { isOk = false; } } writeEndElement(); // </KeyPackage> } if (isOk) { writeStartElement("VariablePackage"); LuaInterface* lI = pHost->getLuaInterface(); VarUnit* vu = lI->getVarUnit(); //do hidden variables first { // Blocked so that indentation reflects that of the XML file writeStartElement("HiddenVariables"); QSetIterator<QString> itHiddenVariableName(vu->hiddenByUser); while (itHiddenVariableName.hasNext()) { writeTextElement("name", itHiddenVariableName.next()); } writeEndElement(); // </HiddenVariables> } TVar* base = vu->getBase(); if (!base) { lI->getVars(false); base = vu->getBase(); } if (base) { QListIterator<TVar*> itVariable(base->getChildren(false)); while (isOk && itVariable.hasNext()) { if (!writeVariable(itVariable.next(), lI, vu)) { isOk = false; } } } writeEndElement(); // </VariablePackage> } return (isOk && (!hasError())); }