mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-21 00:19:29 +02:00
vcmi: modernize rest of lib
This commit is contained in:
@ -35,12 +35,10 @@ static const std::vector<std::string> IMPLEMENTS_MAP =
|
||||
namespace scripting
|
||||
{
|
||||
|
||||
ScriptImpl::ScriptImpl(const ScriptHandler * owner_)
|
||||
:owner(owner_),
|
||||
host(),
|
||||
ScriptImpl::ScriptImpl(const ScriptHandler * owner_):
|
||||
owner(owner_),
|
||||
implements(Implements::ANYTHING)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ScriptImpl::~ScriptImpl() = default;
|
||||
@ -97,7 +95,7 @@ void ScriptImpl::serializeJson(vstd::CLoggerBase * logger, JsonSerializeFormat &
|
||||
|
||||
auto rawData = CResourceHandler::get()->load(sourcePathId)->readAll();
|
||||
|
||||
sourceText = std::string((char *)rawData.first.get(), rawData.second);
|
||||
sourceText = std::string(reinterpret_cast<char *>(rawData.first.get()), rawData.second);
|
||||
|
||||
compile(logger);
|
||||
}
|
||||
@ -149,7 +147,7 @@ std::shared_ptr<Context> PoolImpl::getContext(const Script * script)
|
||||
auto context = script->createContext(env);
|
||||
cache[script] = context;
|
||||
|
||||
auto & key = script->getName();
|
||||
const auto & key = script->getName();
|
||||
const JsonNode & scriptState = state[key];
|
||||
|
||||
if(srv)
|
||||
@ -171,7 +169,7 @@ void PoolImpl::serializeState(const bool saving, JsonNode & data)
|
||||
{
|
||||
for(auto & scriptAndContext : cache)
|
||||
{
|
||||
auto script = scriptAndContext.first;
|
||||
const auto * script = scriptAndContext.first;
|
||||
auto context = scriptAndContext.second;
|
||||
|
||||
state[script->getName()] = context->saveState();
|
||||
@ -254,7 +252,7 @@ void ScriptHandler::loadObject(std::string scope, std::string name, const JsonNo
|
||||
|
||||
void ScriptHandler::performRegistration(Services * services) const
|
||||
{
|
||||
for(auto & keyValue : objects)
|
||||
for(const auto & keyValue : objects)
|
||||
{
|
||||
auto script = keyValue.second;
|
||||
script->performRegistration(services);
|
||||
@ -263,7 +261,7 @@ void ScriptHandler::performRegistration(Services * services) const
|
||||
|
||||
void ScriptHandler::run(std::shared_ptr<Pool> pool) const
|
||||
{
|
||||
for(auto & keyValue : objects)
|
||||
for(const auto & keyValue : objects)
|
||||
{
|
||||
auto script = keyValue.second;
|
||||
|
||||
@ -281,7 +279,7 @@ void ScriptHandler::loadState(const JsonNode & state)
|
||||
|
||||
const JsonNode & scriptsData = state["scripts"];
|
||||
|
||||
for(auto & keyValue : scriptsData.Struct())
|
||||
for(const auto & keyValue : scriptsData.Struct())
|
||||
{
|
||||
std::string name = keyValue.first;
|
||||
|
||||
@ -308,7 +306,7 @@ void ScriptHandler::saveState(JsonNode & state)
|
||||
JsonSerializer handler(nullptr, scriptData);
|
||||
script->serializeJsonState(handler);
|
||||
|
||||
scriptsData[name] = std::move(scriptData);
|
||||
scriptsData[name] = scriptData;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user