CViewRadar::CViewRadar(const TCtorParam ¶m) : CViewBase(param) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CCDBNodeLeaf *pUIMI = pIM->getDbProp( "UI:SAVE:INSCENE:FRIEND:MISSION_ICON" ); if (pUIMI) { ICDBNode::CTextId textId; pUIMI->addObserver( &_MissionIconsObs, textId); } CCDBNodeLeaf *pUIMMI = pIM->getDbProp( "UI:SAVE:INSCENE:FRIEND:MINI_MISSION_ICON" ); if (pUIMMI) { ICDBNode::CTextId textId; pUIMMI->addObserver( &_MiniMissionSpotsObs, textId); } }
void execute (CCtrlBase * /* pCaller */, const std::string &sParams) { // retrieve the sheet of this outpost uint32 sheet= 0; uint8 outpostSel; fromString(sParams, outpostSel); CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GUILD:OUTPOST:O%d:SHEET", outpostSel),false); if (pNL == NULL) return; sheet = pNL->getValue32(); // send msg to server sendMsgToServer("OUTPOST:GIVEUP_OUTPOST", sheet); // reset confirm dialog flag CInterfaceManager *pIM= CInterfaceManager::getInstance(); NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(false); }
//----------------------------------------------- // updateVisualProperty0 : /// Update the item position. //----------------------------------------------- void CItemCL::updateVisualPropertyPos(const NLMISC::TGameCycle &/* gameCycle */, const sint64 &prop, const NLMISC::TGameCycle &/* pI */) { // Check the DB entry (the warning is already done in the build method). if(_DBEntry == 0) return; // Get The property 'Y'. CCDBNodeLeaf *nodeY = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_POSY)); if(nodeY == 0) { nlwarning("ITM:updtVPPos:%d: Cannot find the property 'PROPERTY_POSY(%d)'.", _Slot, CLFECOMMON::PROPERTY_POSY); return; } // Get The property 'Z'. CCDBNodeLeaf *nodeZ = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_POSZ)); if(nodeZ == 0) { nlwarning("ITM:updtVPPos:%d: Cannot find the property 'PROPERTY_POSZ(%d)'.", _Slot, CLFECOMMON::PROPERTY_POSZ); return; } // Insert the primitive into the world. if(_Primitive) _Primitive->insertInWorldImage(dynamicWI); float x = (float)(prop)/1000.0f; float y = (float)(nodeY->getValue64())/1000.0f; float z = (float)(nodeZ->getValue64())/1000.0f; // Set the primitive position. pacsPos(CVectorD(x, y, z)); // Snap the entity to the ground. snapToGround(); // Change the instance position. if(!_Instance.empty()) { _Instance.setPos(pos()); _Instance.getShapeAABBox(_SelectBox); _SelectBox.setCenter(pos() + _SelectBox.getCenter()); // Adjust the collision. if(_Primitive) { _Primitive->setRadius(std::min(std::max((_SelectBox.getHalfSize()).x, (_SelectBox.getHalfSize()).y), (float)(RYZOM_ENTITY_SIZE_MAX/2))); _Primitive->setHeight((_SelectBox.getHalfSize()).z); } } }// updateVisualProperty0 //
// ************************************************************************************* void CBotChatPagePlayerGift::begin() { CBotChatPage::begin(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); // clear intro text NLGUI::CDBManager::getInstance()->getDbProp(BOT_CHAT_BASE_DB_PATH ":PLAYER_GIFT")->setValue32(0); // clear money proposal value CCDBNodeLeaf *moneyProposal = NLGUI::CDBManager::getInstance()->getDbProp(CWidgetManager::getInstance()->getParser()->getDefine("money_proposal")); if (moneyProposal) moneyProposal->setValue64(0); // clear 'accept' button NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // Default is not validated PlayerGiftValidated= false; // open the window activateWindow(WIN_BOT_CHAT_PAGE_PLAYER_GIFT, true); // PlayerTrade is in "BotChatGift" mode PlayerTrade.BotChatGiftContext= true; }
void CDisplayerVisualEntity::updateRaceAndSex() { //H_AUTO(R2_CDisplayerVisualEntity_updateRaceAndSex) std::string sheetClient = (std::string) getString(&getProps(), "SheetClient"); _Entity = getEditor().createEntity(_Entity->slot(), CSheetId(sheetClient), getPos().asVector(), getAngle()); updateEntity(); // update sex SPropVisualA vA; const string propNameA = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPA); CCDBNodeLeaf *leafA = NLGUI::CDBManager::getInstance()->getDbProp(propNameA); if (!leafA) { nlwarning("Can't find DB leaf %s", propNameA.c_str()); return; } vA.PropertyA = leafA->getValue64(); string::size_type loc = sheetClient.find("female", 0); vA.PropertySubData.Sex = (uint)(loc != string::npos); EntitiesMngr.updateVisualProperty(0, _Entity->slot(), CLFECOMMON::PROPERTY_VPA); }
void CGroupSkills::CSkillsObs::update (ICDBNode *node) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CCDBNodeLeaf *leaf = NLMISC::safe_cast<CCDBNodeLeaf *>(node); // Rebuild all only if new skill (previously level 0) if (leaf->getOldValue32() == 0) Owner->_MustRebuild= true; // Popup a message if previous was not 0 if ((leaf->getOldValue32() != 0) && (leaf->getValue32() != 0)) // prevent displaying FX when resetData() is called during a Far TP { CGroupSkills::InhibitSkillUpFX = false; ICDBNode *skill = node->getParent(); if (skill) { ICDBNode *skillParent = skill->getParent(); if (skillParent) { uint skillId; if (skillParent->getNodeIndex (skill, skillId)) { CAHManager::getInstance()->runActionHandler("skill_popup", NULL, "skillId="+toString(skillId)+"|delta="+toString(leaf->getValue32()-leaf->getOldValue32())); // Context help contextHelp ("skill"); } } } } else { if( !CGroupSkills::InhibitSkillUpFX ) // TODO: couldn't this be replaced by IngameDbMngr.initInProgress()? { UserEntity->skillUp(); } } // Check if this skill canunblock title CSkillManager *pSM = CSkillManager::getInstance(); string sTmp = leaf->getFullName(); sTmp = sTmp.substr(0, sTmp.rfind(':')); sTmp = sTmp.substr(sTmp.rfind(':')+1,sTmp.size()); sint32 eSkills; fromString(sTmp, eSkills); pSM->tryToUnblockTitleFromSkill((SKILLS::ESkills)eSkills, leaf->getValue32()); }
// *************************************************************************************** void CBotChatPageMission::selectMission(CDBCtrlSheet *missionSheet) { if (!missionSheet) return; if (missionSheet->getGrayed()) return; // show the dialog with good infos CInterfaceManager *im = CInterfaceManager::getInstance(); CGroupContainer *gc = dynamic_cast<CGroupContainer *>(im->getElementFromId(WIN_BOT_CHAT_ACCEPT_MISSION)); // copy text id for title { CCDBNodeLeaf *titleTextLeaf = dynamic_cast<CCDBNodeLeaf *>(missionSheet->getRootBranch()->getNode(ICDBNode::CTextId("TEXT"))); // CViewTextID *viewTitleTextID = dynamic_cast<CViewTextID *>(gc->getView("text_title_id")); if (viewTitleTextID && titleTextLeaf) viewTitleTextID->setTextId(titleTextLeaf->getValue32()); } // copy text id for details CCDBNodeLeaf *detailTextLeaf = dynamic_cast<CCDBNodeLeaf *>(missionSheet->getRootBranch()->getNode(ICDBNode::CTextId("DETAIL_TEXT"))); // CViewTextID *viewTextID = dynamic_cast<CViewTextID *>(gc->getView("text_id")); if(viewTextID && detailTextLeaf) { viewTextID->setTextId(detailTextLeaf->getValue32()); } // copy icon CCDBNodeLeaf *iconLeaf = im->getDbProp("UI:TEMP:MISSION:ICON"); if (iconLeaf) { iconLeaf->setValue32(missionSheet->getSheetId()); } // if (!gc) return; im->setTopWindow(gc); gc->setActive(true); gc->updateCoords(); gc->center(); gc->setModalParentList(WIN_BOT_CHAT_PAGE_MISSION); _CurrSel = missionSheet; }
// ********************************************************************************************************* std::string CDisplayerVisualEntity::getVisualProperties() const { //H_AUTO(R2_std_getVisualProperties) if( !_Entity ) return ""; const std::string propNameA = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPA); const std::string propNameB = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPB); const std::string propNameC = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPC); CCDBNodeLeaf *leafA = NLGUI::CDBManager::getInstance()->getDbProp(propNameA); CCDBNodeLeaf *leafB = NLGUI::CDBManager::getInstance()->getDbProp(propNameB); CCDBNodeLeaf *leafC = NLGUI::CDBManager::getInstance()->getDbProp(propNameC); if (!leafA) { nlwarning("Can't find DB leaf %s", propNameA.c_str()); return ""; } if (!leafB) { nlwarning("Can't find DB leaf %s", propNameB.c_str()); return ""; } if (!leafC) { nlwarning("Can't find DB leaf %s", propNameC.c_str()); return ""; } uint64 uVPA = leafA->getValue64(); uint64 uVPB = leafB->getValue64(); uint64 uVPC = leafC->getValue64(); const std::string strVPABC = NLMISC::toString( "VPA:%016.16"NL_I64"x\nVPB:%016.16"NL_I64"x\nVPC:%016.16"NL_I64"x", uVPA, uVPB, uVPC ); return strVPABC; }
// **************************************************************************** void CHugeListObs::updateUIItemPage(uint index) { nlassert((uint) _Category < ListTypeCount); // must call setListType CInterfaceManager *im = CInterfaceManager::getInstance(); // std::string dbPath; // db path for the current item list TItemVect *items = &_ItemsPages; CDBCtrlSheet::TSheetCategory *itemCategory = &_ItemCategory; CDBGroupListSheetText *listSheet; CCDBNodeLeaf *itemListCategoryLeaf = NULL; switch (_Category) { case Trading: { if (BotChatPageAll->Trade->getBuyOnly()) { dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":"; listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MONEY_BUY_ONLY)); } else { dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":"; listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MONEY)); } if (!listSheet) return; itemListCategoryLeaf = im->getDbProp("UI:TEMP:TYPE_OF_ITEMS_TO_BUY", false); } break; case ItemForMissions: { dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":"; listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MISSION)); if (!listSheet) return; itemListCategoryLeaf = im->getDbProp("UI:TEMP:TYPE_OF_ITEMS_FOR_MISSION", false); if (!itemListCategoryLeaf) return; // display the group for mission items CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_ITEMS_FOR_MISSION); if (elm) elm->setActive(true); } break; case Ascensor: { dbPath = DB_LOCAL_BRANCH_FOR_ASCENSOR ":"; listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_ASCENSOR)); if (!listSheet) return; // display the group for mission items CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_ITEMS_FOR_ASCENSOR); if (elm) elm->setActive(true); } break; case Missions: { dbPath = DB_LOCAL_BRANCH_FOR_MISSIONS ":"; listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_MISSIONS)); if (!listSheet) return; // display the group for mission items CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_MISSIONS); if (elm) elm->setActive(true); } break; default: nlassert(0); // Provide code for initializing break; } // Copy item into the big local db for(uint k = 0; k < TRADE_PAGE_NUM_ITEMS; ++k) { CCDBNodeLeaf *leaf; const CItem &currItem = (*items)[index].Items[k]; // get branch for the item switch(_Category) { case Trading: leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUALITY", false); if (leaf) leaf->setValue32(currItem.Quality); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SLOT_TYPE", false); if (leaf) leaf->setValue32(currItem.SlotType); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SHEET", false); if (leaf) leaf->setValue32(currItem.SheetIDOrSkill); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE", false); if (leaf) leaf->setValue32(currItem.Price); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":WEIGHT", false); if (leaf) leaf->setValue32(currItem.Weight); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAMEID", false); if (leaf) leaf->setValue32(currItem.NameId); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":USER_COLOR", false); if (leaf) leaf->setValue32(currItem.UserColor); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ENCHANT", false); if (leaf) leaf->setValue32(currItem.Enchant); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_CLASS_TYPE", false); if (leaf) leaf->setValue32(currItem.RMClassType); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_FABER_STAT_TYPE", false); if (leaf) leaf->setValue32(currItem.RMFaberStatType); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PREREQUISIT_VALID", false); if (leaf) leaf->setValue32(currItem.PrerequisitValid); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":INFO_VERSION", false); if (leaf) leaf->setValue32(currItem.InfoVersion); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUANTITY", false); if (leaf) leaf->setValue32(currItem.Quantity); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE_RETIRE", false); if (leaf) leaf->setValue32(currItem.PriceRetire); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RESALE_TIME_LEFT", false); if (leaf) leaf->setValue32(currItem.ResaleTimeLeft); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SELLER_TYPE", false); if (leaf) leaf->setValue32(currItem.SellerType); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":VENDOR_NAMEID", false); if (leaf) leaf->setValue32(currItem.VendorNameId); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":FACTION_TYPE", false); if (leaf) leaf->setValue32(currItem.FactionType); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE", false); if (leaf) leaf->setValue32(currItem.FactionPointPrice); break; case ItemForMissions: leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUALITY", false); if (leaf) leaf->setValue32(currItem.Quality); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SLOT_TYPE", false); if (leaf) leaf->setValue32(currItem.SlotType); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SHEET", false); if (leaf) leaf->setValue32(currItem.SheetIDOrSkill); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":LOGIC_TEXT_ID", false); if (leaf) leaf->setValue32(currItem.LogicTextID); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":DESC_TEXT_ID", false); if (leaf) leaf->setValue32(currItem.DescTextID); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":WEIGHT", false); if (leaf) leaf->setValue32(currItem.Weight); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAMEID", false); if (leaf) leaf->setValue32(currItem.NameId); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":USER_COLOR", false); if (leaf) leaf->setValue32(currItem.UserColor); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ENCHANT", false); if (leaf) leaf->setValue32(currItem.Enchant); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_CLASS", false); if (leaf) leaf->setValue32(currItem.RMClassType); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_FABER_STAT_TYPE", false); if (leaf) leaf->setValue32(currItem.RMFaberStatType); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":INFO_VERSION", false); if (leaf) leaf->setValue32(currItem.InfoVersion); break; case Ascensor: leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ICON", false); if (leaf) leaf->setValue64(currItem.GuildIcon); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAME", false); if (leaf) leaf->setValue32(currItem.GuildName); break; case Missions: leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":TEXT", false); if (leaf) leaf->setValue64(currItem.MissionText); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":DETAIL_TEXT", false); if (leaf) leaf->setValue64(currItem.MissionDetailText); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ICON", false); if (leaf) leaf->setValue32(currItem.MissionIcon); leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PREREQ_STATE", false); if (leaf) leaf->setValue32(currItem.MissionPreReqState); break; default: nlassert(0); // Implement the temp -> local stuff break; } CDBCtrlSheet *sheet = listSheet->getSheet(k + index * TRADE_PAGE_NUM_ITEMS); if (sheet) { CDBCtrlSheet::TSheetCategory newItemCategory = sheet->getSheetCategory(); if (k == 0 && index == 0) { *itemCategory = newItemCategory; } else { if (*itemCategory != newItemCategory) { *itemCategory = CDBCtrlSheet::DontKnow; } } if (_Category == Trading) { // If price of current selected item has changed, repercute it if (sheet == CDBCtrlSheet::getCurrSelection()) { string ls = im->getDefine("item_price_1"); string ms = im->getDefine("item_price_2"); string bs = im->getDefine("item_price_3"); string vbs = im->getDefine("item_price_4"); setPriceInDB(currItem.Price, ls, ms, bs, vbs); } } } } // set db entry to give the type of the items if (itemListCategoryLeaf) itemListCategoryLeaf->setValue64((sint64) *itemCategory); // max page set _FirstPageNotUpdated= max(_FirstPageNotUpdated, uint32(index+1)); // For Phrase BotChat, update the DB prices if(_Category==Trading && _PhrasePriceUpdateAndMaybeClientFill) { CSPhraseManager *pPM= CSPhraseManager::getInstance(); pPM->updateBotChatPhrasePrice(index * TRADE_PAGE_NUM_ITEMS, (index+1) * TRADE_PAGE_NUM_ITEMS); } }
// **************************************************************************** void CHugeListObs::start() { nlassert((uint) _Category < ListTypeCount); // must call setListType // Clear temp structure _ItemsPages.clear(); _DownloadComplete = false; // clear the local database CInterfaceManager *im = CInterfaceManager::getInstance(); for (uint k = 0; k < TRADE_PAGE_NUM_ITEMS * TRADE_MAX_NUM_PAGES; ++k) { CCDBNodeLeaf *leaf; switch(_Category) { case Trading: leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":%d:SHEET", (int) k), false); if (leaf) leaf->setValue32(0); leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":%d:SLOT_TYPE", (int) k), false); if (leaf) leaf->setValue32(0); break; case ItemForMissions: leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":%d:SHEET", (int) k), false); if (leaf) leaf->setValue32(0); leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":%d:SLOT_TYPE", (int) k), false); if (leaf) leaf->setValue32(0); break; case Ascensor: leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ASCENSOR":%d:ICON", (int) k), false); if (leaf) leaf->setValue64(0); leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ASCENSOR":%d:NAME", (int) k), false); if (leaf) leaf->setValue32(0); break; case Missions: leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_MISSIONS":%d:ICON", (int) k), false); if (leaf) leaf->setValue64(0); leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_MISSIONS":%d:TEXT", (int) k), false); if (leaf) leaf->setValue32(0); leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_MISSIONS":%d:DETAIL_TEXT", (int) k), false); if (leaf) leaf->setValue32(0); break; default: nlassert(0); // You have to provide code for elements in local db to be cleared break; } } // Setup session ID switch(_Category) { case Trading: case ItemForMissions: case Missions: _CurrentSessionNb = CBotChatManager::getInstance()->getSessionID(); break; case Ascensor: break; default: nlassert(0); // You have to provide code for the choice of the session id break; } // reset _FirstPageNotUpdated= 0; _PhraseClientFillNumPhrase= 0; _PhraseClientFill= false; }
//*************************************************************** std::string CToolCreateEntity::cloneEntityIntoScenario(CEntityCL *clonee, const NLMISC::CVector &createPosition, float createAngle, bool newAction, bool createGhost ) { //H_AUTO(R2_CToolCreateEntity_cloneEntityIntoScenario) if (!clonee) return ""; std::string instanceId; bool isBotObject = isBotObjectSheet(clonee->sheetId()); if (!getEditor().verifyRoomLeft(isBotObject ? 0 : 1, isBotObject ? 1 : 0)) { return ""; } std::string className; // if class is given in the palette node, then use it. Default to 'Npc' else CObject *paletteNode = getDMC().getPaletteElement(_PaletteId); if (paletteNode && paletteNode->findIndex("Class") != -1) { className = getString(paletteNode, "Class"); } if (className.empty()) { className = "Npc"; } ucstring readableName; // retrieve name from the palette id CLuaState &ls = getEditor().getLua(); getEditor().getEnv()["PaletteIdToTranslation"][_PaletteId].push(); if (ls.isString(-1)) { readableName.fromUtf8(ls.toString(-1)); } if (readableName.empty()) { // if no name found then give a default one readableName = CI18N::get(isBotObject ? "uiR2EDNameBotObject" : "uiR2EDNameNPC"); } // except for creatures, posfix the name with a number std::string creaturePaletteRoot = "palette.entities.creatures"; if (_PaletteId.substr(0, creaturePaletteRoot.size()) != creaturePaletteRoot) { readableName = getEditor().genInstanceName(readableName); } else { className = "NpcCreature"; // is Plant std::string sheetClient = getString(paletteNode, "SheetClient"); getEditor().getLua().push(sheetClient); if (getEditor().getEnv().callMethodByNameNoThrow("isNPCPlant", 1, 1)) { CLuaObject result(getEditor().getLua()); bool isPlant = result.toBoolean(); if (isPlant) className = "NpcPlant"; } } if (newAction) { getDMC().newAction(NLMISC::CI18N::get("uiR2EDCreateAction") + readableName); } // send network commands to create entity on server std::auto_ptr<CObject> desc(getDMC().newComponent(className)); if (desc.get()) { // TMP FIX : if the created entity is a custom npc, then retrieve look from the clonee visual properties if (className == "NpcCustom") { SPropVisualA vA; SPropVisualB vB; SPropVisualC vC; const string propNameA = toString("SERVER:Entities:E%d:P%d", clonee->slot(), CLFECOMMON::PROPERTY_VPA); const string propNameB = toString("SERVER:Entities:E%d:P%d", clonee->slot(), CLFECOMMON::PROPERTY_VPB); const string propNameC = toString("SERVER:Entities:E%d:P%d", clonee->slot(), CLFECOMMON::PROPERTY_VPC); CCDBNodeLeaf *leafA = CInterfaceManager::getInstance()->getDbProp(propNameA); CCDBNodeLeaf *leafB = CInterfaceManager::getInstance()->getDbProp(propNameB); CCDBNodeLeaf *leafC = CInterfaceManager::getInstance()->getDbProp(propNameC); if (!leafA) { nlwarning("Can't find DB leaf %s", propNameA.c_str()); return ""; } if (!leafB) { nlwarning("Can't find DB leaf %s", propNameB.c_str()); return ""; } if (!leafC) { nlwarning("Can't find DB leaf %s", propNameC.c_str()); return ""; } vA.PropertyA = leafA->getValue64(); vB.PropertyB = leafB->getValue64(); vC.PropertyC = leafC->getValue64(); nlassert(desc->isTable()); CObjectTable *props = (CObjectTable *) desc.get(); props->set("GabaritHeight", (double)vC.PropertySubData.CharacterHeight); props->set("GabaritTorsoWidth", (double)vC.PropertySubData.TorsoWidth); props->set("GabaritArmsWidth", (double)vC.PropertySubData.ArmsWidth); props->set("GabaritLegsWidth", (double)vC.PropertySubData.LegsWidth); props->set("GabaritBreastSize", (double)vC.PropertySubData.BreastSize); props->set("HairColor", (double)vA.PropertySubData.HatColor); props->set("Tattoo", (double)vC.PropertySubData.Tattoo); props->set("EyesColor", (double)vC.PropertySubData.EyesColor); props->set("MorphTarget1", (double)vC.PropertySubData.MorphTarget1); props->set("MorphTarget2", (double)vC.PropertySubData.MorphTarget2); props->set("MorphTarget3", (double)vC.PropertySubData.MorphTarget3); props->set("MorphTarget4", (double)vC.PropertySubData.MorphTarget4); props->set("MorphTarget5", (double)vC.PropertySubData.MorphTarget5); props->set("MorphTarget6", (double)vC.PropertySubData.MorphTarget6); props->set("MorphTarget7", (double)vC.PropertySubData.MorphTarget7); props->set("MorphTarget8", (double)vC.PropertySubData.MorphTarget8); props->set("Sex", (double)vA.PropertySubData.Sex); CVisualSlotManager * vsManager = CVisualSlotManager::getInstance(); NLMISC::CSheetId * sheetId = NULL; if(vA.PropertySubData.HatModel == 0) { props->set("HatModel", 0); } else { sheetId = vsManager->index2Sheet((uint32)vA.PropertySubData.HatModel, SLOTTYPE::HEAD_SLOT); if (sheetId) { props->set("HairType", (double)sheetId->asInt()); } } if(vA.PropertySubData.JacketModel == 0) { props->set("JacketModel", 0); } else { sheetId = vsManager->index2Sheet((uint32)vA.PropertySubData.JacketModel, SLOTTYPE::CHEST_SLOT); if (sheetId) { props->set("JacketModel", (double)sheetId->asInt()); } } if(vA.PropertySubData.TrouserModel == 0) { props->set("TrouserModel", 0); } else { sheetId = vsManager->index2Sheet((uint32)vA.PropertySubData.TrouserModel, SLOTTYPE::LEGS_SLOT); if (sheetId) { props->set("TrouserModel", (double)sheetId->asInt()); } } if(vB.PropertySubData.FeetModel == 0) { props->set("FeetModel", 0); } else { sheetId = vsManager->index2Sheet((uint32)vB.PropertySubData.FeetModel, SLOTTYPE::FEET_SLOT); if (sheetId) { props->set("FeetModel", (double)sheetId->asInt()); } } if(vB.PropertySubData.HandsModel == 0) { props->set("HandsModel", 0); } else { sheetId = vsManager->index2Sheet((uint32)vB.PropertySubData.HandsModel, SLOTTYPE::HANDS_SLOT); if (sheetId) { props->set("HandsModel", (double)sheetId->asInt()); } } if(vA.PropertySubData.ArmModel == 0) { props->set("ArmModel", 0); } else { sheetId = vsManager->index2Sheet((uint32)vA.PropertySubData.ArmModel, SLOTTYPE::ARMS_SLOT); if (sheetId) { props->set("ArmModel", (double)sheetId->asInt()); } } double weaponRH=0, weaponLH=0; if(vA.PropertySubData.WeaponRightHand == 0) { props->set("WeaponRightHand", 0); } else { sheetId = vsManager->index2Sheet((uint32)vA.PropertySubData.WeaponRightHand, SLOTTYPE::RIGHT_HAND_SLOT); if (sheetId) { weaponRH = (double)sheetId->asInt(); } props->set("WeaponRightHand", weaponRH); } if(vA.PropertySubData.WeaponLeftHand == 0) { props->set("WeaponLeftHand", 0); } else { sheetId = vsManager->index2Sheet((uint32)vA.PropertySubData.WeaponLeftHand, SLOTTYPE::LEFT_HAND_SLOT); if (sheetId) { weaponLH = (double)sheetId->asInt(); } props->set("WeaponLeftHand", weaponLH); } props->set("JacketColor", (double)vA.PropertySubData.JacketColor); props->set("TrouserColor", (double)vA.PropertySubData.TrouserColor); props->set("FeetColor", (double)vB.PropertySubData.FeetColor); props->set("HandsColor", (double)vB.PropertySubData.HandsColor); props->set("ArmColor", (double)vA.PropertySubData.ArmColor); CPlayerR2CL * player = (CPlayerR2CL*)dynamic_cast<CPlayerR2CL*>(clonee); if(player != NULL) { std::string race, gender, sheetClient; switch(player->people()) { case EGSPD::CPeople::Fyros: sheetClient = "basic_fyros_"; race = "Fyros"; break; case EGSPD::CPeople::Matis: sheetClient = "basic_matis_"; race = "Matis"; break; case EGSPD::CPeople::Tryker: sheetClient = "basic_tryker_"; race = "Tryker"; break; case EGSPD::CPeople::Zorai: sheetClient = "basic_zorai_"; race = "Zorai"; break; default: nlwarning("CToolCreateEntity::commit unknown people"); } switch(player->getGender()) { case GSGENDER::female: sheetClient = sheetClient+"female.creature"; gender = "female"; break; case GSGENDER::male: sheetClient = sheetClient+"male.creature"; gender = "male"; break; default: nlwarning("CToolCreateEntity::commit unknown gender"); } props->set("SheetClient", sheetClient); // random name getEditor().getLua().push(race); getEditor().getLua().push(gender); if (getEditor().getEnv().callMethodByNameNoThrow("randomNPCName", 2, 1)) { CLuaObject result(getEditor().getLua()); std::string name = result.toString(); props->set("Name", name); } } getEditor().getLua().push(getString(paletteNode, "Equipment")); getEditor().getLua().push(weaponRH); getEditor().getLua().push(weaponLH); getEditor().getLua().push(getString(paletteNode, "Sheet")); getEditor().getLua().push(getString(paletteNode, "SheetModel")); if (getEditor().getEnv().callMethodByNameNoThrow("searchSheet", 5, 1)) { CLuaObject result(getEditor().getLua()); std::string sheet = result.toString(); props->set("Sheet", sheet); } else { nlwarning("SearchSheet failed : Palette Id = %s", _PaletteId.c_str()); return ""; } } else { desc->set("Name", readableName.toUtf8()); } desc->set("Base", _PaletteId); desc->setObject("Position", buildVector(CVectorD(createPosition))); desc->set("Angle", createAngle); //desc->set("Name", readableName.toUtf8()); instanceId = getString(desc.get(), "InstanceId"); if (!instanceId.empty()) { if (!createGhost) { // selection asked when instance is created getEditor().setCookie(instanceId, "Select", true); } else { getEditor().setCookie(instanceId, "GhostDuplicate", true); } } // send creation command // tmp : static npc counter // add in component list of default feature if (getEditor().getDefaultFeature()) { std::string targetInstanceId; // if object is a bot object, it is considered to be permanent content // and should be created in the base act CInstance *targetAct = isBotObject ? getEditor().getBaseAct() : getEditor().getCurrentAct(); if (!targetAct) { nlwarning("Can't find act when creating an entity"); } else { if (_AutoGroup.getGroupingCandidate()) { nlassert(!createGhost); // either autogroup or arraymode, both at the same time not supported _AutoGroup.group(desc.get(), createPosition); } else { // create standalone desc->setGhost(createGhost); getDMC().requestInsertNode(getEditor().getDefaultFeature(targetAct)->getId(), "Components", -1, "", desc.get()); } } } } return instanceId; }
void CDisplayerVisualEntity::updateEntity() { { //BENCH(updateName) //H_AUTO(R2_CDisplayerVisualEntity_updateEntity) updateName(); } CCDBNodeLeaf *leafA; CCDBNodeLeaf *leafB; CCDBNodeLeaf *leafC; SPropVisualA vA; SPropVisualB vB; SPropVisualC vC; { //BENCH(entitySetup) const string propNameA = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPA); const string propNameB = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPB); const string propNameC = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPC); leafA = NLGUI::CDBManager::getInstance()->getDbProp(propNameA); leafB = NLGUI::CDBManager::getInstance()->getDbProp(propNameB); leafC = NLGUI::CDBManager::getInstance()->getDbProp(propNameC); if (!leafA) { nlwarning("Can't find DB leaf %s", propNameA.c_str()); return; } if (!leafB) { nlwarning("Can't find DB leaf %s", propNameB.c_str()); return; } if (!leafC) { nlwarning("Can't find DB leaf %s", propNameC.c_str()); return; } vA.PropertyA = leafA->getValue64(); vB.PropertyB = leafB->getValue64(); vC.PropertyC = leafC->getValue64(); vC.PropertySubData.CharacterHeight = (uint) getNumber(&getProps(), "GabaritHeight"); vC.PropertySubData.ArmsWidth = (uint) getNumber(&getProps(), "GabaritArmsWidth"); vC.PropertySubData.TorsoWidth = (uint) getNumber(&getProps(), "GabaritTorsoWidth"); vC.PropertySubData.LegsWidth = (uint) getNumber(&getProps(), "GabaritLegsWidth"); vC.PropertySubData.BreastSize = (uint) getNumber(&getProps(), "GabaritBreastSize"); int itemNb = (int) getNumber(&getProps(), "HairType"); std::string itemFileName; if(itemNb>0) { itemFileName = CSheetId(itemNb).toString(); vA.PropertySubData.HatModel = (uint) SheetMngr.getVSIndex(itemFileName, SLOTTYPE::HEAD_SLOT); } else { vA.PropertySubData.HatModel = 0; } vA.PropertySubData.HatColor = (uint) getNumber(&getProps(), "HairColor"); vC.PropertySubData.Tattoo = (uint) getNumber(&getProps(), "Tattoo"); vC.PropertySubData.EyesColor = (uint) getNumber(&getProps(), "EyesColor"); vC.PropertySubData.MorphTarget1 = (uint) getNumber(&getProps(), "MorphTarget1"); vC.PropertySubData.MorphTarget2 = (uint) getNumber(&getProps(), "MorphTarget2"); vC.PropertySubData.MorphTarget3 = (uint) getNumber(&getProps(), "MorphTarget3"); vC.PropertySubData.MorphTarget4 = (uint) getNumber(&getProps(), "MorphTarget4"); vC.PropertySubData.MorphTarget5 = (uint) getNumber(&getProps(), "MorphTarget5"); vC.PropertySubData.MorphTarget6 = (uint) getNumber(&getProps(), "MorphTarget6"); vC.PropertySubData.MorphTarget7 = (uint) getNumber(&getProps(), "MorphTarget7"); vC.PropertySubData.MorphTarget8 = (uint) getNumber(&getProps(), "MorphTarget8"); itemNb = (int) getNumber(&getProps(), "JacketModel"); if(itemNb>0) { itemFileName = CSheetId(itemNb).toString(); vA.PropertySubData.JacketModel = (uint) SheetMngr.getVSIndex(itemFileName, SLOTTYPE::CHEST_SLOT); } else { vA.PropertySubData.JacketModel = 0; } itemNb = (int) getNumber(&getProps(), "TrouserModel"); if(itemNb>0) { itemFileName = CSheetId(itemNb).toString(); vA.PropertySubData.TrouserModel = (uint) SheetMngr.getVSIndex(itemFileName, SLOTTYPE::LEGS_SLOT); } else { vA.PropertySubData.TrouserModel = 0; } itemNb = (int) getNumber(&getProps(), "FeetModel"); if(itemNb>0) { itemFileName = CSheetId(itemNb).toString(); vB.PropertySubData.FeetModel = (uint) SheetMngr.getVSIndex(itemFileName, SLOTTYPE::FEET_SLOT); } else { vB.PropertySubData.FeetModel = 0; } itemNb = (int) getNumber(&getProps(), "HandsModel"); if(itemNb>0) { itemFileName = CSheetId(itemNb).toString(); vB.PropertySubData.HandsModel = (uint) SheetMngr.getVSIndex(itemFileName, SLOTTYPE::HANDS_SLOT); } else { vB.PropertySubData.HandsModel = 0; } itemNb = (int) getNumber(&getProps(), "ArmModel"); if(itemNb>0) { itemFileName = CSheetId(itemNb).toString(); vA.PropertySubData.ArmModel = (uint) SheetMngr.getVSIndex(itemFileName, SLOTTYPE::ARMS_SLOT); } else { vA.PropertySubData.ArmModel = 0; } itemNb = (int) getNumber(&getProps(), "WeaponRightHand"); if(itemNb>0) { itemFileName = CSheetId(itemNb).toString(); vA.PropertySubData.WeaponRightHand = (uint) SheetMngr.getVSIndex(itemFileName, SLOTTYPE::RIGHT_HAND_SLOT); } else { vA.PropertySubData.WeaponRightHand = 0; } itemNb = (int) getNumber(&getProps(), "WeaponLeftHand"); if(itemNb>0) { itemFileName = CSheetId(itemNb).toString(); vA.PropertySubData.WeaponLeftHand = (uint) SheetMngr.getVSIndex(itemFileName, SLOTTYPE::LEFT_HAND_SLOT); } else { vA.PropertySubData.WeaponLeftHand = 0; } vA.PropertySubData.JacketColor = (uint) getNumber(&getProps(), "JacketColor"); vA.PropertySubData.TrouserColor = (uint) getNumber(&getProps(), "TrouserColor"); vB.PropertySubData.FeetColor = (uint) getNumber(&getProps(), "FeetColor"); vB.PropertySubData.HandsColor = (uint) getNumber(&getProps(), "HandsColor"); vA.PropertySubData.ArmColor = (uint) getNumber(&getProps(), "ArmColor"); } { //BENCH(entityApply) // Set the database leafA->setValue64(vA.PropertyA); leafB->setValue64(vB.PropertyB); leafC->setValue64(vC.PropertyC); // Force to update properties EntitiesMngr.updateVisualProperty(0, _Entity->slot(), CLFECOMMON::PROPERTY_VPA); EntitiesMngr.updateVisualProperty(0, _Entity->slot(), CLFECOMMON::PROPERTY_VPB); EntitiesMngr.updateVisualProperty(0, _Entity->slot(), CLFECOMMON::PROPERTY_VPC); } }
virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string dbdst = getParam (Params, "dbdst"); string dbsrc = getParam (Params, "dbsrc"); CCDBNodeBranch *pNBdst = pIM->getDbBranch(dbdst); CCDBNodeBranch *pNBsrc = pIM->getDbBranch(dbsrc); // Branch copy if ((pNBdst != NULL) && (pNBsrc != NULL)) { //nlinfo("copying from %s to %s",pNBsrc->getName()->c_str(), pNBdst->getName()->c_str()); // Parse all children of the src branch uint nbLeaves = pNBsrc->countLeaves(); for (uint i = 0; i < nbLeaves; ++i) { uint count = i; CCDBNodeLeaf *pNLsrc = pNBsrc->findLeafAtCount(count); // Find its access name string sTmp = *pNLsrc->getName(); CCDBNodeBranch *pParent = pNLsrc->getParent(); while (pParent != pNBsrc) { sTmp = *pParent->getName() + ":" + sTmp; pParent = pParent->getParent(); } // Find the correspondant node in the dst branch CCDBNodeLeaf *pNLdst = dynamic_cast<CCDBNodeLeaf*>(pNBdst->getNode(ICDBNode::CTextId(sTmp))); if (pNLdst == NULL) { nlwarning ("cannot find destination leaf %s",sTmp.c_str()); } else { pNLdst->setValue64(pNLsrc->getValue64()); //sint32 nVal = pNLsrc->getValue64(); //nlinfo("set value %d for node %s", nVal, sTmp.c_str()); } } return; } // Not branch copy so leaf copy CInterfaceProperty ipsrc; CInterfaceProperty ipdst; if (!ipsrc.link (dbsrc.c_str())) { nlwarning("cannot find leaf %s",dbsrc.c_str()); return; } if (!ipdst.link (dbdst.c_str())) { nlwarning("cannot find leaf %s",dbdst.c_str()); return; } // copy ipdst.setSInt64 (ipsrc.getSInt64()); }
void addWebIGParams (string &url, bool trustedDomain) { if(!UserEntity || !NetMngr.getLoginCookie().isValid()) return; uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; url += ((url.find('?') != string::npos) ? "&" : "?") + string("shardid=") + toString(CharacterHomeSessionId) + string("&name=") + UserEntity->getLoginName().toUtf8() + string("&lang=") + CI18N::getCurrentLanguageCode() + string("&datasetid=") + toString(UserEntity->dataSetId()) + string("&ig=1"); if (trustedDomain) { url += string("&cid=") + toString(cid) + string("&authkey=") + getWebAuthKey(); if (url.find('$') != string::npos) { strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender())); strFindReplace(url, "$displayName$", UserEntity->getDisplayName().toString()); strFindReplace(url, "$posx$", toString(UserEntity->pos().x)); strFindReplace(url, "$posy$", toString(UserEntity->pos().y)); strFindReplace(url, "$posz$", toString(UserEntity->pos().z)); strFindReplace(url, "$post$", toString(atan2(UserEntity->front().y, UserEntity->front().x))); // Target fields const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; CInterfaceManager *im = CInterfaceManager::getInstance(); CCDBNodeLeaf *node = im->getDbProp(dbPath, false); if (node && (uint8)node->getValue32() != (uint8) CLFECOMMON::INVALID_SLOT) { CEntityCL *target = EntitiesMngr.entity((uint) node->getValue32()); if (target) { strFindReplace(url, "$tdatasetid$", toString(target->dataSetId())); strFindReplace(url, "$tdisplayName$", target->getDisplayName().toString()); strFindReplace(url, "$tposx$", toString(target->pos().x)); strFindReplace(url, "$tposy$", toString(target->pos().y)); strFindReplace(url, "$tposz$", toString(target->pos().z)); strFindReplace(url, "$tpost$", toString(atan2(target->front().y, target->front().x))); strFindReplace(url, "$tsheet$", target->sheetId().toString()); string type; if (target->isFauna()) type = "fauna"; else if (target->isNPC()) type = "npc"; else if (target->isPlayer()) type = "player"; else if (target->isUser()) type = "user"; strFindReplace(url, "$ttype$", target->sheetId().toString()); } else { strFindReplace(url, "$tdatasetid$", ""); strFindReplace(url, "$tdisplayName$", ""); strFindReplace(url, "$tposx$", ""); strFindReplace(url, "$tposy$", ""); strFindReplace(url, "$tposz$", ""); strFindReplace(url, "$tpost$", ""); strFindReplace(url, "$tsheet$", ""); strFindReplace(url, "$ttype$", ""); } } } } }