Recovered/ holds the code linked only into the standalone exe (scripts/exe/build_exe.py), outside the Clank source dirs: - jsoncons/ and nProtect/ moved from scripts/exe/; GameGuard stand-in follows main's renamed entry points. - GPak/PakAuxiliary.cpp: Extract (virtualised in every build; 02-19 jumps out at 0x0065861E) rebuilt from the open GRF Editor decoder, after the visible 02-19 prologue; inline key and kRO keys 1-4. Apply traps (unreachable in 02-19). - GGHash/GGHash.cpp: CGGHash::Load/Check/VerifyHash trap (RagHash.dat check unreachable in 02-19). The whole client links: 984 units, 0 unresolved.
103 lines
3 KiB
C++
103 lines
3 KiB
C++
// Copyright 2013-2023 Daniel Parker
|
|
// Distributed under the Boost license, Version 1.0.
|
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
// See https://github.com/danielaparker/jsoncons for latest version
|
|
|
|
#ifndef JSONCONS_JSONMERGEPATCH_JSONMERGEPATCH_HPP
|
|
#define JSONCONS_JSONMERGEPATCH_JSONMERGEPATCH_HPP
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <algorithm> // std::min
|
|
#include <utility> // std::move
|
|
#include <jsoncons/json.hpp>
|
|
|
|
namespace jsoncons {
|
|
namespace mergepatch {
|
|
|
|
template <class Json>
|
|
Json from_diff(const Json& source, const Json& target)
|
|
{
|
|
if (!source.is_object() || !target.is_object())
|
|
{
|
|
return target;
|
|
}
|
|
Json result(json_object_arg);
|
|
|
|
for (const auto& member : source.object_range())
|
|
{
|
|
auto it = target.find(member.key());
|
|
if (it != target.object_range().end())
|
|
{
|
|
if (member.value() != it->value())
|
|
{
|
|
result.try_emplace(member.key(), from_diff(member.value(), it->value()));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result.try_emplace(member.key(), Json::null());
|
|
}
|
|
}
|
|
|
|
for (const auto& member : target.object_range())
|
|
{
|
|
auto it = source.find(member.key());
|
|
if (it == source.object_range().end())
|
|
{
|
|
result.try_emplace(member.key(), member.value());
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
namespace detail {
|
|
template <class Json>
|
|
Json apply_merge_patch_(Json& target, const Json& patch)
|
|
{
|
|
if (patch.is_object())
|
|
{
|
|
if (!target.is_object())
|
|
{
|
|
target = Json(json_object_arg);
|
|
}
|
|
for (auto& member : patch.object_range())
|
|
{
|
|
auto it = target.find(member.key());
|
|
if (it != target.object_range().end())
|
|
{
|
|
Json item = it->value();
|
|
target.erase(it);
|
|
if (!member.value().is_null())
|
|
{
|
|
target.try_emplace(member.key(), apply_merge_patch_(item, member.value()));
|
|
}
|
|
}
|
|
else if (!member.value().is_null())
|
|
{
|
|
Json item(json_object_arg);
|
|
target.try_emplace(member.key(), apply_merge_patch_(item, member.value()));
|
|
}
|
|
}
|
|
return target;
|
|
}
|
|
else
|
|
{
|
|
return patch;
|
|
}
|
|
}
|
|
} // namespace detail
|
|
|
|
template <class Json>
|
|
void apply_merge_patch(Json& target, const Json& patch)
|
|
{
|
|
target = detail::apply_merge_patch_(target, patch);
|
|
}
|
|
|
|
} // namespace mergepatch
|
|
} // namespace jsoncons
|
|
|
|
#endif
|