2014-06-25 17:11:07 +03:00
|
|
|
/*
|
|
|
|
|
* IHandlerBase.cpp, part of VCMI engine
|
|
|
|
|
*
|
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
|
*
|
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
#include "IHandlerBase.h"
|
2026-01-29 17:20:19 +00:00
|
|
|
#include "json/JsonNode.h"
|
2023-07-30 20:12:25 +03:00
|
|
|
#include "modding/IdentifierStorage.h"
|
|
|
|
|
#include "modding/ModScope.h"
|
|
|
|
|
#include "modding/CModHandler.h"
|
2025-02-14 16:23:37 +00:00
|
|
|
#include "GameLibrary.h"
|
2014-06-25 17:11:07 +03:00
|
|
|
|
2022-07-26 16:07:42 +03:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
2023-03-14 00:26:44 +03:00
|
|
|
std::string IHandlerBase::getScopeBuiltin()
|
2022-12-07 15:18:19 +02:00
|
|
|
{
|
2023-07-30 20:12:25 +03:00
|
|
|
return ModScope::scopeBuiltin();
|
2022-12-07 15:18:19 +02:00
|
|
|
}
|
2014-06-25 17:11:07 +03:00
|
|
|
|
2026-01-29 17:20:19 +00:00
|
|
|
void IHandlerBase::registerObject(const std::string & scope, const std::vector<std::string> & typeNames, const std::string & name, const JsonNode & data, si32 index)
|
2014-06-25 17:11:07 +03:00
|
|
|
{
|
2026-01-29 17:20:19 +00:00
|
|
|
for(const auto & typeName : typeNames)
|
|
|
|
|
registerObject(scope, typeName, name, data, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IHandlerBase::registerObject(const std::string & scope, const std::string & typeName, const std::string & name, const JsonNode & data, si32 index)
|
|
|
|
|
{
|
|
|
|
|
LIBRARY->identifiersHandler->registerObject(scope, typeName, name, index);
|
|
|
|
|
for(const auto & compatID : data["compatibilityIdentifiers"].Vector())
|
|
|
|
|
{
|
|
|
|
|
if (name != compatID.String())
|
|
|
|
|
LIBRARY->identifiersHandler->registerObject(scope, typeName, compatID.String(), index);
|
|
|
|
|
else
|
|
|
|
|
logMod->warn("Mod '%s' %s '%s': compatibility identifier has same name as object itself!", scope, typeName, name);
|
|
|
|
|
}
|
2014-06-25 17:11:07 +03:00
|
|
|
}
|
2016-02-21 20:58:09 +03:00
|
|
|
|
2026-03-10 20:28:54 +02:00
|
|
|
std::optional<int32_t> IHandlerBase::resolveIdentifier(const std::string & scope, const std::string & typeName, const std::string & name) const
|
|
|
|
|
{
|
|
|
|
|
return LIBRARY->identifiersHandler->getIdentifier(scope, typeName, name);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-26 16:07:42 +03:00
|
|
|
VCMI_LIB_NAMESPACE_END
|