Commit 1f11ee38 authored by Filip Hauzvic's avatar Filip Hauzvic
Browse files

Use ContextPath instead of raw string vector

parent 93859ac8
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -116,8 +116,6 @@ struct Reflection
        virtual ValuePtr copy() const = 0; 
        virtual ValuePtr deep_copy() const { return copy(); }
        virtual bool equals(const ValuePtr& other) const = 0;

    protected:
        bool is_same_type(const ValuePtr& other) const { return other && other->typeID() == typeID(); }
    };

+3 −3
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ namespace net {
            const std::string& setter_name,
            double update_interval = 0.0);
        void register_property(
            const std::vector<std::string>& object_path,
            const com::ContextPath& object_path,
            const std::string& getter_name,
            const std::string& setter_name,
            double update_interval = 0.0);
@@ -28,7 +28,7 @@ namespace net {
            const std::string& getter_name,
            const std::string& setter_name);
        void unregister_property(
            const std::vector<std::string>& object_path,
            const com::ContextPath& object_path,
            const std::string& getter_name,
            const std::string& setter_name);

@@ -37,7 +37,7 @@ namespace net {
    private:
        utils::Buffer create_packet(const ReplicatedProperty& property, const com::Reflection::ValuePtr& value,
                                    int& written_bytes) const;
        void call_setter(const std::vector<std::string>& context_item_path, const std::string& setter_name,
        void call_setter(const com::ContextPath& context_item_path, const std::string& setter_name,
                         const com::Reflection::ValuePtr& value);

        void initialize() override;
+2 −2
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ namespace net
            int& written_bytes);

        void call_function_local(
            std::vector<std::string> const& context_item_path,
            const com::ContextPath& context_item_path,
            std::string const& function_name,
            utils::Deserializer& deserializer,
            ConnectionId from_id);
@@ -93,7 +93,7 @@ namespace net
            } else if constexpr (std::is_same_v<T, vec2i>)
            {
                return com::make_value<com::Reflection::ValueVEC2I>(val);
            } else if constexpr (std::is_same_v<T, std::vector<std::string>>)
            } else if constexpr (std::is_same_v<T, com::ContextPath>)
            {
                return com::make_value<com::Reflection::ValuePATH>(val);
            } else
+4 −4
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ namespace net {
        m_replicated_properties[object].push_back(property);
    }

    void ReplicationSystem::register_property(const std::vector<std::string>& object_path,
    void ReplicationSystem::register_property(const com::ContextPath& object_path,
                                              const std::string& getter_name,
                                              const std::string& setter_name,
                                              double update_interval)
@@ -145,7 +145,7 @@ namespace net {
        }
    }

    void ReplicationSystem::unregister_property(const std::vector<std::string>& object_path, const std::string& getter_name, const std::string& setter_name)
    void ReplicationSystem::unregister_property(const com::ContextPath& object_path, const std::string& getter_name, const std::string& setter_name)
    {
        auto owner = com::Folder::root()->locate<com::ContextItem>(object_path);
        if (!owner)
@@ -165,7 +165,7 @@ namespace net {
            LOG(LSL_ERROR, "[ReplicationSystem] Invalid packet from " << from << ": Only the server can send replication updates");
            return;
        }
        std::vector<std::string> context_item_path;
        com::ContextPath context_item_path;
        utils::deserialize_path(deserializer, context_item_path);
        if (context_item_path.empty())
        {
@@ -181,7 +181,7 @@ namespace net {
        call_setter(context_item_path, setter_name, value);
    }

    void ReplicationSystem::call_setter(const std::vector<std::string>& context_item_path, const std::string& setter_name,
    void ReplicationSystem::call_setter(const com::ContextPath& context_item_path, const std::string& setter_name,
                                        const com::Reflection::ValuePtr& value)
    {
        const auto context_item = com::Folder::root()->locate<com::ContextItem>(context_item_path);
+2 −2
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ void RPCSystem::call_remote(

void RPCSystem::handle_packet(ConnectionId from, utils::Deserializer& deserializer)
{
    std::vector<std::string> context_item_path;
    com::ContextPath context_item_path;
    utils::deserialize_path(deserializer, context_item_path);
    if (context_item_path.empty())
    {
@@ -113,7 +113,7 @@ std::vector<uint8_t> RPCSystem::create_packet(
}

void RPCSystem::call_function_local(
    std::vector<std::string> const& context_item_path,
    const com::ContextPath& context_item_path,
    std::string const& function_name,
    utils::Deserializer& deserializer,
    ConnectionId from_id)
Loading