1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Fixes identifiers resolving for json serialization

This commit is contained in:
Ivan Savenko 2022-12-06 16:26:32 +02:00
parent 34cd856f53
commit 65f9a1ffd2
2 changed files with 10 additions and 7 deletions

View File

@ -209,8 +209,7 @@ std::vector<CIdentifierStorage::ObjectData> CIdentifierStorage::getPossibleIdent
// called have not specified destination mod explicitly
if (request.remoteScope.empty())
{
// FIXME: temporary, for queries from map loader allow access to any identifer
// should be changed to list of mods that are marked as required by current map
// "map" is special scope that should have access to all in-game objects
if (request.localScope == "map")
{
for (auto const & modName : VLC->modh->getActiveMods())
@ -234,12 +233,16 @@ std::vector<CIdentifierStorage::ObjectData> CIdentifierStorage::getPossibleIdent
else
{
//if destination mod was specified explicitly, restrict lookup to this mod
if(request.remoteScope == "core" )
{
//"core" mod is an implicit dependency for all mods, allow access into it
allowedScopes.insert(request.remoteScope);
}
else if ( request.localScope == "map" )
{
// allow access, "map" is special scope that should have access to all in-game objects
allowedScopes.insert(request.remoteScope);
}
else if(request.remoteScope == request.localScope )
{
// allow self-access

View File

@ -86,7 +86,7 @@ const Artifact * ArtifactID::toArtifact(const ArtifactService * service) const
si32 ArtifactID::decode(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier("core", "artifact", identifier);
auto rawId = VLC->modh->identifiers.getIdentifier("map", "artifact", identifier);
if(rawId)
return rawId.get();
else
@ -110,7 +110,7 @@ const Creature * CreatureID::toCreature(const CreatureService * creatures) const
si32 CreatureID::decode(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier("core", "creature", identifier);
auto rawId = VLC->modh->identifiers.getIdentifier("map", "creature", identifier);
if(rawId)
return rawId.get();
else
@ -139,7 +139,7 @@ const spells::Spell * SpellID::toSpell(const spells::Service * service) const
si32 SpellID::decode(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier("core", "spell", identifier);
auto rawId = VLC->modh->identifiers.getIdentifier("map", "spell", identifier);
if(rawId)
return rawId.get();
else
@ -201,7 +201,7 @@ const FactionID FactionID::NEUTRAL = FactionID(9);
si32 FactionID::decode(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier("core", "faction", identifier);
auto rawId = VLC->modh->identifiers.getIdentifier("map", "faction", identifier);
if(rawId)
return rawId.get();
else