bool WorldServer::loadIFOs(Map* curMap, STBFile& warpFile) { std::string folderPath = std::string(curMap->getMapPath()); if (folderPath.length() == 0) return true; #ifdef __ROSE_USE_VFS__ //dword_t fileAmount = this->vfs->getFileCountFromFolder(folderPath.c_str()); std::vector<std::string> files = this->vfs->getFileNamesFromFolder(folderPath.c_str() , ".ifo"); #else folderPath = workingPath + std::string("\\") + folderPath.substr(0, folderPath.find_last_of("\\") + 1); //Get all IFOs from the current map directory QuickInfo::getFilesFromDirectoryA(folderPath, std::string(".ifo"), files); if (files.size() == 0) { //In case there are none (for whatever reason), don't do anything return true; } #endif this->teleGates.reserve(warpFile.getRowCount()); for (unsigned int i = 0; i < this->teleGates.capacity(); i++) this->teleGates.addValue(Telegate()); /** ASSIGN SECTORS **/ curMap->setSectorWidthAndHeight(this->zoneFile->getZoneSize(curMap->getId())); //As precaution, as some Maps seem to have 0 as ZoneSize if (curMap->getSectorWidthAndHeight() == 0) { curMap->setSectorWidthAndHeight(IFO::CUSTOMIZED_SECTOR_SIZE); } curMap->createSectors(files); //Iterate through all *.ifo files GlobalLogger::debug("Loading IFOs from path %s...\n", folderPath.c_str()); for (unsigned int j = 0; j < files.size(); j++) { VFSData fileData; this->vfs->readFile(files.at(j).c_str(), fileData); IFO ifo(&fileData); //Add all spawns of the current *.ifo to the map for (unsigned int k = 0; k < ifo.getSpawnAmount(); k++) { curMap->addSpawn(new IFOSpawn(ifo.getSpawn(k))); } //Add all (IFO-)NPCs to the map for (unsigned int k = 0; k < ifo.getNPCAmount(); k++) { IFONPC& npcINFO = ifo.getNPC(k); NPCData& npcData = this->npcData.at(npcINFO.getObjectId()); NPC *newNpc = new NPC(&npcData, &this->aiData.getValue(npcData.getAIId()), curMap->getId(), npcINFO.getPosition()); newNpc->setDirection(npcINFO.getDirection()); newNpc->setSector(curMap->getSector(newNpc->getPositionCurrent())); this->globalNPCs.push_back(newNpc); } //Create telegates from the previously read IFO-info this->loadTelegates(curMap->getId(), warpFile, ifo); } return true; }