void CLandscapeUser::flushTiles (NLMISC::IProgressCallback &progress) { // After loading the TileBank, and before initTileBanks(), must load the vegetables descritpor _Landscape->Landscape.TileBank.loadTileVegetableDescs(); // init the TileBanks descriptors if ( ! _Landscape->Landscape.initTileBanks() ) { nlwarning( "You need to recompute bank.farbank for the far textures" ); } // Count tiles uint tileCount = 0; sint ts; for (ts=0; ts<_Landscape->Landscape.TileBank.getTileSetCount (); ts++) { CTileSet *tileSet=_Landscape->Landscape.TileBank.getTileSet (ts); tileCount += tileSet->getNumTile128(); tileCount += tileSet->getNumTile256(); tileCount += CTileSet::count; } // Second, temporary, flushTiles. //=============================== uint tile = 0; for (ts=0; ts<_Landscape->Landscape.TileBank.getTileSetCount (); ts++) { CTileSet *tileSet=_Landscape->Landscape.TileBank.getTileSet (ts); sint tl; for (tl=0; tl<tileSet->getNumTile128(); tl++) { // Progress bar progress.progress ((float)tile/(float)tileCount); tile++; _Landscape->Landscape.flushTiles (_Scene->getDriver(), (uint16)tileSet->getTile128(tl), 1); } for (tl=0; tl<tileSet->getNumTile256(); tl++) { // Progress bar progress.progress ((float)tile/(float)tileCount); tile++; _Landscape->Landscape.flushTiles (_Scene->getDriver(), (uint16)tileSet->getTile256(tl), 1); } for (tl=0; tl<CTileSet::count; tl++) { // Progress bar progress.progress ((float)tile/(float)tileCount); tile++; _Landscape->Landscape.flushTiles (_Scene->getDriver(), (uint16)tileSet->getTransition(tl)->getTile (), 1); } } }
// *************************************************************************** void CSheetManager::loadAllSheetNoPackedSheet(NLMISC::IProgressCallback &callBack, const std::vector<std::string> &extensions, const std::string &wildcardFilter) { callBack.progress (0); callBack.pushCropedValues (0, 0.5f); // load all forms ::loadFormNoPackedSheet(extensions, _EntitySheetContainer, wildcardFilter); // callBack.popCropedValues(); }
//========================================================================= void CHairSet::init (NLMISC::IProgressCallback &progress) { H_AUTO_USE(RZ_HairSet) clear(); uint numHairItem = SheetMngr.getNumItem(SLOTTYPE::HEAD_SLOT); for(uint k = 0; k < numHairItem; ++k) { // Progress bar progress.progress ((float)k/(float)numHairItem); const CItemSheet *item = SheetMngr.getItem(SLOTTYPE::HEAD_SLOT, k); if( (item) && (!item->getShape().empty()) ) { std::string itemName = item->getShape(); itemName = NLMISC::strlwr(itemName); if (item->getShape().find("cheveux", 0) != std::string::npos) { // get race uint16 race = (uint16) itemName[1] | ((uint16) itemName[0] << 8); switch(race) { case 'ma': _Hairs[Matis].push_back(k); break; case 'tr': _Hairs[Tryker].push_back(k); break; case 'zo': _Hairs[Zorai].push_back(k); break; case 'fy': _Hairs[Fyros].push_back(k); break; } } } } }
// **************************************************************************** void CLandscapeUser::refreshAllZonesAround(const CVector &pos, float radius, std::vector<std::string> &zonesAdded, std::vector<std::string> &zonesRemoved, NLMISC::IProgressCallback &progress, const std::vector<uint16> *validZoneIds) { NL3D_HAUTO_LOAD_LANDSCAPE; zonesAdded.clear(); zonesRemoved.clear(); std::string za, zr; _ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius, validZoneIds); refreshZonesAround (pos, radius, za, zr); // Zone to load uint zoneToLoad = _ZoneManager.getNumZoneLeftToLoad (); while (_ZoneManager.isLoading() || _ZoneManager.isRemoving()) { // Progress bar if (zoneToLoad != 0) progress.progress ((float)(zoneToLoad-_ZoneManager.getNumZoneLeftToLoad ())/(float)zoneToLoad); refreshZonesAround (pos, radius, za, zr); // some zone added or removed?? if(za != "") zonesAdded.push_back(za); if(zr != "") zonesRemoved.push_back(zr); _ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius); if (_ZoneManager.isLoading()) nlSleep (0); } }
//----------------------------------------------- // loadAllSheet : // Load all sheets. //----------------------------------------------- void CSheetManager::loadAllSheet(NLMISC::IProgressCallback &callBack, bool updatePackedSheet, bool needComputeVS, bool dumpVSIndex, bool forceRecompute /*= false*/, const std::vector<std::string> *userExtensions /*= NULL*/) { callBack.progress (0); callBack.pushCropedValues (0, 0.5f); // Get some informations from typ files. loadTyp(); // prepare a list of sheets extension to load. vector<string> extensions; uint sizeTypeVersion = sizeof(TypeVersion); uint sizeCTypeVersion = sizeof(CTypeVersion); uint nb = sizeTypeVersion/sizeCTypeVersion; { if (!userExtensions) { _EntitySheetContainer.clear(); } TEntitySheetMap entitySheetContainer; for(uint i=0; i<nb; ++i) { // see if extension is wanted bool found = false; if (userExtensions) { for(uint l = 0; l < userExtensions->size(); ++l) { if (stricmp((*userExtensions)[l].c_str(), TypeVersion[i].Type.c_str()) == 0) { found = true; } } } else { found = true; } if (found) { entitySheetContainer.clear(); extensions.clear(); extensions.push_back(TypeVersion[i].Type); CSheetManagerEntry::setVersion(TypeVersion[i].Version); string path = CPath::lookup(TypeVersion[i].Type + ".packed_sheets", false); if (forceRecompute && !path.empty()) { // delete previous packed sheets NLMISC::CFile::deleteFile(path); path.clear(); } if(path.empty()) path = "../../client/data/" + TypeVersion[i].Type + ".packed_sheets"; ::loadForm(extensions, path, entitySheetContainer, updatePackedSheet); TEntitySheetMap::iterator it = entitySheetContainer.begin(); while(it != entitySheetContainer.end()) { _EntitySheetContainer[(*it).first] = (*it).second; (*it).second.EntitySheet = 0; // Next ++it; } } } } // Re-compute Visual Slot if(needComputeVS) computeVS(); // Compute Visual Slots { for(uint i=0; i<SLOTTYPE::NB_SLOT; ++i) _VisualSlots[i].resize(CVisualSlotManager::getInstance()->getNbIndex((SLOTTYPE::EVisualSlot)i)+1, 0); // Nb Index +1 because index 0 is reserve for empty. // TEntitySheetMap::iterator it = _EntitySheetContainer.begin(); while(it != _EntitySheetContainer.end()) { std::vector<CVisualSlotManager::TIdxbyVS> result; CVisualSlotManager::getInstance()->sheet2Index((*it).first, result); for(uint i=0; i<result.size(); ++i) { if(dynamic_cast<CItemSheet *>((*it).second.EntitySheet)) { _SheetToVS[dynamic_cast<CItemSheet *>((*it).second.EntitySheet)].push_back(std::make_pair(result[i].VisualSlot, result[i].Index)); _VisualSlots[result[i].VisualSlot][result[i].Index] = dynamic_cast<CItemSheet *>((*it).second.EntitySheet); } } ++it; } } // Dump visual slots // nb : if a new visual_slot.tab has just been generated don't forget // to move it in data_common before dump. if(dumpVSIndex) dumpVisualSlotsIndex(); // callBack.popCropedValues(); }// loadAllSheet //
void CCDBStructNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack ) { xmlNodePtr child; // look for other branches within this branch uint countNode = CIXml::countChildren (node, "branch") + CIXml::countChildren (node, "leaf"); uint nodeId = 0; for (child = CIXml::getFirstChildNode (node, "branch"); child; child = CIXml::getNextChildNode (child, "branch")) { // Progress bar progressCallBack.progress ((float)nodeId/(float)countNode); progressCallBack.pushCropedValues ((float)nodeId/(float)countNode, (float)(nodeId+1)/(float)countNode); CXMLAutoPtr name((const char*)xmlGetProp (child, (xmlChar*)"name")); CXMLAutoPtr count((const char*)xmlGetProp (child, (xmlChar*)"count")); CXMLAutoPtr bank((const char*)xmlGetProp (child, (xmlChar*)"bank")); CXMLAutoPtr atom((const char*)xmlGetProp (child, (xmlChar*)"atom")); CXMLAutoPtr clientonly((const char*)xmlGetProp (child, (xmlChar*)"clientonly")); string sBank, sAtom, sClientonly; if ( bank ) sBank = bank.getDatas(); if ( atom ) sAtom = atom.getDatas(); if ( clientonly ) sClientonly = clientonly.getDatas(); nlassert((const char *) name != NULL); if ((const char *) count != NULL) { // dealing with an array of entries uint countAsInt; NLMISC::fromString(count, countAsInt); nlassert((const char *) count != NULL); for (uint i=0; i<countAsInt; i++) { // Progress bar progressCallBack.progress ((float)i/(float)countAsInt); progressCallBack.pushCropedValues ((float)i/(float)countAsInt, (float)(i+1)/(float)countAsInt); // nlinfo("+ %s%d",name,i); addNode( new CCDBStructNodeBranch, string(name.getDatas())+toString(i), this, _Names, _Nodes, _Index, child, sBank.c_str(), sAtom=="1", sClientonly=="1", progressCallBack ); /* _Names.push_back(string(name)+toString(i)); _Index.insert(make_pair(string(name)+toString(i),_Nodes.size())); _Nodes.push_back(new CCDBStructNodeBranch); _Nodes.back()->setParent(this); _Nodes.back()->init(child); */ // nlinfo("-"); // Progress bar progressCallBack.popCropedValues (); } } else { // dealing with a single entry // nlinfo("+ %s",name); addNode( new CCDBStructNodeBranch, string(name.getDatas()), this, _Names, _Nodes, _Index, child, sBank.c_str(), sAtom=="1", sClientonly=="1", progressCallBack ); /* _Names.push_back(name); _Index.insert(make_pair(name,_Nodes.size())); _Nodes.push_back(new CCDBStructNodeBranch); _Nodes.back()->setParent(this); _Nodes.back()->init(child); */ // nlinfo("-"); } // Progress bar progressCallBack.popCropedValues (); nodeId++; } // look for leaves of this branch for (child = CIXml::getFirstChildNode (node, "leaf"); child; child = CIXml::getNextChildNode (child, "leaf")) { // Progress bar progressCallBack.progress ((float)nodeId/(float)countNode); progressCallBack.pushCropedValues ((float)nodeId/(float)countNode, (float)(nodeId+1)/(float)countNode); CXMLAutoPtr name((const char*)xmlGetProp (child, (xmlChar*)"name")); CXMLAutoPtr count((const char*)xmlGetProp (child, (xmlChar*)"count")); CXMLAutoPtr bank((const char*)xmlGetProp (child, (xmlChar*)"bank")); string sBank; if ( bank ) sBank = bank.getDatas(); nlassert((const char *) name != NULL); if ((const char *) count != NULL) { // dealing with an array of entries uint countAsInt; NLMISC::fromString(count, countAsInt); nlassert((const char *) count != NULL); for (uint i=0; i<countAsInt; i++) { // Progress bar progressCallBack.progress ((float)i/(float)countAsInt); progressCallBack.pushCropedValues ((float)i/(float)countAsInt, (float)(i+1)/(float)countAsInt); // nlinfo(" %s%d",name,i); addNode( new CCDBStructNodeLeaf, string(name.getDatas())+toString(i), this, _Names, _Nodes, _Index, child, sBank.c_str(), false, false, progressCallBack ); /* _Names.push_back(string(name)+toString(i)); _Index.insert(make_pair(string(name)+toString(i),_Nodes.size())); _Nodes.push_back(new CCDBStructNodeLeaf); _Nodes.back()->setParent(this); _Nodes.back()->init(child); */ // Progress bar progressCallBack.popCropedValues (); } } else { // nlinfo(" %s",name); addNode( new CCDBStructNodeLeaf, string(name.getDatas()), this, _Names, _Nodes, _Index, child, sBank.c_str(), false, false, progressCallBack ); /* _Names.push_back(name); _Index.insert(make_pair(name,_Nodes.size())); _Nodes.push_back(new CCDBStructNodeLeaf); _Nodes.back()->setParent(this); _Nodes.back()->init(child); */ } // Progress bar progressCallBack.popCropedValues (); nodeId++; } calcIdBits(); }