Пример #1
0
bool Node::hasMatchingNodeID(ResourceID ID)
{
  switch (type) {
    case Node::XS1_G:
      return ((ID.node() >> 8) & 0xff) == nodeID;
    case Node::XS1_L:
      return ID.node() == nodeID;
  }
}
Пример #2
0
std::unique_ptr<CInputStream> CFilesystemList::load(const ResourceID & resourceName) const
{
	// load resource from last loader that have it (last overridden version)
	for (auto & loader : boost::adaptors::reverse(loaders))
	{
		if (loader->existsResource(resourceName))
			return loader->load(resourceName);
	}

	throw std::runtime_error("Resource with name " + resourceName.getName() + " and type "
		+ EResTypeHelper::getEResTypeAsString(resourceName.getType()) + " wasn't found.");
}
Пример #3
0
std::unique_ptr<CInputStream> CResourceLoader::load(const ResourceID & resourceIdent) const
{
	auto resource = resources.find(resourceIdent);

	if(resource == resources.end())
	{
		throw std::runtime_error("Resource with name " + resourceIdent.getName() + " and type "
			+ EResTypeHelper::getEResTypeAsString(resourceIdent.getType()) + " wasn't found.");
	}

	// get the last added resource(most overriden)
	const ResourceLocator & locator = resource->second.back();

	// load the resource and return it
	return locator.getLoader()->load(locator.getResourceName());
}
Пример #4
0
void CMapInfo::saveInit(ResourceID file)
{
	CLoadFile lf(*CResourceHandler::get()->getResourceName(file), MINIMAL_SERIALIZATION_VERSION);
	lf.checkMagicBytes(SAVEGAME_MAGIC);

	mapHeader = make_unique<CMapHeader>();
	lf >> *(mapHeader.get()) >> scenarioOptionsOfSave;
	fileURI = file.getName();
	countPlayers();
	std::time_t time = boost::filesystem::last_write_time(*CResourceHandler::get()->getResourceName(file));
	date = std::asctime(std::localtime(&time));
	// We absolutely not need this data for lobby and server will read it from save
	// FIXME: actually we don't want them in CMapHeader!
	mapHeader->triggeredEvents.clear();
}