1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Advance map header serialization

This commit is contained in:
AlexVinS
2016-02-21 20:58:09 +03:00
parent b6103167f7
commit 53b5587c2e
16 changed files with 230 additions and 75 deletions

View File

@ -187,7 +187,6 @@ void CIdentifierStorage::registerObject(std::string scope, std::string type, std
checkIdentifier(fullID);
registeredObjects.insert(std::make_pair(fullID, data));
logGlobal->traceStream() << scope << "::" << fullID;
}
std::vector<CIdentifierStorage::ObjectData> CIdentifierStorage::getPossibleIdentifiers(const ObjectCallback & request)
@ -206,10 +205,21 @@ std::vector<CIdentifierStorage::ObjectData> CIdentifierStorage::getPossibleIdent
else
{
//...unless destination mod was specified explicitly
auto myDeps = VLC->modh->getModData(request.localScope).dependencies;
if (request.remoteScope == "core" || // allow only available to all core mod
myDeps.count(request.remoteScope)) // or dependencies
//note: getModData does not work for "core" by design
//for map format support core mod has access to any mod
//TODO: better solution for access from map?
if(request.localScope == "core" || request.localScope == "")
{
allowedScopes.insert(request.remoteScope);
}
else
{
// allow only available to all core mod or dependencies
auto myDeps = VLC->modh->getModData(request.localScope).dependencies;
if (request.remoteScope == "core" || myDeps.count(request.remoteScope))
allowedScopes.insert(request.remoteScope);
}
}
std::string fullID = request.type + '.' + request.name;
@ -845,9 +855,16 @@ void CModHandler::loadModFilesystems()
CModInfo & CModHandler::getModData(TModID modId)
{
CModInfo & mod = allMods.at(modId);
assert(vstd::contains(activeMods, modId)); // not really necessary but won't hurt
return mod;
auto it = allMods.find(modId);
if(it == allMods.end())
{
throw std::runtime_error("Mod not found '" + modId+"'");
}
else
{
return it->second;
}
}
void CModHandler::initializeConfig()