Example #1
0
	virtual bool Load() override
	{
		bool loadedSomething = m_archive.Open(GetZoneFile(m_zd));

		std::string base_filename = (boost::format("%s\\%s")
			% m_zd->GetEQPath()
			% m_zd->GetZoneName()).str();

		// next we need to try to read an _assets file and load more eqg based data.
		std::string assets_file = base_filename + "_assets.txt";
		std::error_code ec;
		if (sys::exists(assets_file, ec))
		{
			std::vector<std::string> filenames;
			std::ifstream assets(assets_file.c_str());

			if (assets.is_open())
			{
				std::copy(std::istream_iterator<std::string>(assets),
					std::istream_iterator<std::string>(),
					std::back_inserter(filenames));

				for (auto& name : filenames)
				{
					std::string asset_file = (boost::format("%s\\%s") % m_zd->GetEQPath() % name).str();
					EQEmu::PFS::Archive archive;

					if (!archive.Open(asset_file))
						continue;

					std::vector<std::string> models;

					if (archive.GetFilenames("mod", models))
					{
						for (auto& modelName : models)
						{
							EQEmu::EQGModelLoader model_loader;
							ModelPtr model;

							model_loader.Load(archive, modelName, model);
							if (model)
							{
								model->SetName(modelName);
								m_modelsByFile[modelName] = model;
								loadedSomething = true;
							}
						}
					}
				}
			}
		}

		return loadedSomething;
	}
Example #2
0
bool EQEmu::EQGLoader::Load(std::string file, std::vector<std::shared_ptr<EQG::Geometry>> &models, std::vector<std::shared_ptr<Placeable>> &placeables,
	std::vector<std::shared_ptr<EQG::Region>> &regions, std::vector<std::shared_ptr<Light>> &lights) {
	// find zon file
	EQEmu::PFS::Archive archive;
	if(!archive.Open(file + ".eqg")) {
		eqLogMessage(LogTrace, "Failed to open %s.eqg as a standard eqg file because the file does not exist.", file.c_str());
		return false;
	}

	std::vector<char> zon;
	bool zon_found = false;
	std::vector<std::string> files;
	archive.GetFilenames("zon", files);

	if(files.size() == 0) {
		if (GetZon(file + ".zon", zon)) {
			zon_found = true;
		}
	} else {
		for(auto &f : files) {
			if(archive.Get(f, zon)) {
				if(zon[0] == 'E' && zon[1] == 'Q' && zon[2] == 'T' && zon[3] == 'Z' && zon[4] == 'P') {
					eqLogMessage(LogWarn, "Unable to parse the zone file, is a eqgv4.");
					return false;
				}

				zon_found = true;
			}
		}
	}

	if (!zon_found) {
		eqLogMessage(LogError, "Failed to open %s.eqg because the %s.zon file could not be found.", file.c_str(), file.c_str());
		return false;
	}

	eqLogMessage(LogTrace, "Parsing zone file.");
	if (!ParseZon(archive, zon, models, placeables, regions, lights)) {
		//if we couldn't parse the zon file then it's probably eqg4
		eqLogMessage(LogWarn, "Unable to parse the zone file, probably eqgv4 style file.");
		return false;
	}

	return true;
}
Example #3
0
	virtual bool Load() override
	{
		std::vector<EQEmu::S3D::WLDFragment> zone_object_frags;

		std::string base_filename = (boost::format("%s\\%s")
			% m_zd->GetEQPath()
			% m_zd->GetZoneName()).str();
		bool loadedSomething = false;

		EQEmu::PFS::Archive archive;

		for (int i = 0; i < 3; i++)
		{
			std::string suffix;
			if (i > 0)
				suffix = "_obj";
			if (i > 1)
				suffix += std::to_string(i);

			std::string wld_name = m_zd->GetZoneName() + suffix + ".wld";
			std::string file_name = (boost::format("%s\\%s.s3d")
				% m_zd->GetEQPath() % (m_zd->GetZoneName() + suffix)).str();

			EQEmu::S3DLoader loader;
			std::vector<EQEmu::S3D::WLDFragment> frags;

			if (loader.ParseWLDFile(file_name, wld_name, frags))
			{
				for (auto& frag : frags)
				{
					if (frag.type == 0x36)
					{
						EQEmu::S3D::WLDFragment36 &frag36 = reinterpret_cast<EQEmu::S3D::WLDFragment36&>(frag);
						auto model = frag36.GetData();

						if (m_s3dModels.find(model->GetName()) == m_s3dModels.end())
						{
							m_s3dModels[model->GetName()] = model;
							loadedSomething = true;
						}
					}
				}
			}
		}

		// next we need to try to read an _assets file and load more eqg based data.
		std::string assets_file = base_filename + "_assets.txt";
		std::error_code ec;
		if (sys::exists(assets_file, ec))
		{
			std::vector<std::string> filenames;
			std::ifstream assets(assets_file.c_str());

			if (assets.is_open())
			{
				std::copy(std::istream_iterator<std::string>(assets),
					std::istream_iterator<std::string>(),
					std::back_inserter(filenames));

				if (m_zd->GetZoneName() == "poknowledge")
				{
					filenames.push_back("poknowledge_obj3.eqg");
				}

				for (auto& name : filenames)
				{
					std::string asset_file = (boost::format("%s\\%s") % m_zd->GetEQPath() % name).str();
					EQEmu::PFS::Archive archive;

					if (!archive.Open(asset_file))
						continue;

					std::vector<std::string> models;

					if (archive.GetFilenames("mod", models))
					{
						for (auto& modelName : models)
						{
							EQEmu::EQGModelLoader model_loader;
							ModelPtr model;

							model_loader.Load(archive, modelName, model);
							if (model)
							{
								model->SetName(modelName);
								m_eqgModels[modelName] = model;
								loadedSomething = true;
							}
						}
					}
				}
			}
		}

		return loadedSomething;
	}