codex-5.2: синхронизация ресурсов модов, частичная перезагрузка модов

This commit is contained in:
2026-01-01 15:12:27 +06:00
parent 4aa7c6f41a
commit f56b46f669
16 changed files with 692 additions and 84 deletions

View File

@@ -997,6 +997,9 @@ PreparedNodeState::PreparedNodeState(const std::u8string_view data) {
std::u8string PreparedNodeState::dump() const {
Net::Packet result;
const char magic[] = "bn";
result.write(reinterpret_cast<const std::byte*>(magic), 2);
// ResourceToLocalId
assert(LocalToModelKD.size() < (1 << 16));
assert(LocalToModelKD.size() == LocalToModel.size());
@@ -1357,6 +1360,7 @@ uint16_t PreparedNodeState::parseCondition(const std::string_view expression) {
bin.rhs = *nodeId;
}
node.v = bin;
Nodes.emplace_back(std::move(node));
assert(Nodes.size() < std::pow(2, 16)-64);
leftToken = uint16_t(Nodes.size()-1);
@@ -1756,6 +1760,29 @@ PreparedModel::PreparedModel(const std::string_view modid, const js::object& pro
}
}
if(boost::system::result<const js::value&> submodels_val = profile.try_at("sub_models")) {
const js::array& submodels = submodels_val->as_array();
SubModels.reserve(submodels.size());
for(const js::value& value : submodels) {
if(const auto model_key = value.try_as_string()) {
auto [domain, key] = parseDomainKey((std::string) *model_key, modid);
SubModels.push_back({std::move(domain), std::move(key), std::nullopt});
} else {
const js::object& obj = value.as_object();
const std::string model_key_str = (std::string) obj.at("model").as_string();
auto [domain, key] = parseDomainKey(model_key_str, modid);
std::optional<uint16_t> scene;
if(const auto scene_val = obj.try_at("scene")) {
scene = static_cast<uint16_t>(scene_val->to_number<int>());
}
SubModels.push_back({std::move(domain), std::move(key), scene});
}
}
}
if(boost::system::result<const js::value&> subModels_val = profile.try_at("sub_models")) {
const js::array& subModels = subModels_val->as_array();

View File

@@ -713,13 +713,15 @@ struct PreparedNodeState {
}
};
for(const auto& route : Routes)
lambda(route.first);
std::sort(variables.begin(), variables.end());
auto eraseIter = std::unique(variables.begin(), variables.end());
variables.erase(eraseIter, variables.end());
bool ok = false;
for(const std::string_view key : variables) {
bool ok = false;
if(size_t pos = key.find(':'); pos != std::string::npos) {
std::string_view state, value;
state = key.substr(0, pos);

View File

@@ -77,7 +77,8 @@ enum struct L2System : uint8_t {
Disconnect,
Test_CAM_PYR_POS,
BlockChange,
ResourceRequest
ResourceRequest,
ReloadMods
};
}
@@ -184,4 +185,4 @@ enum struct L2Content : uint8_t {
}
}
}