From 41c3d9309cd1c1e3c15a16e5e329653dbdff14aa Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Thu, 2 Oct 2014 10:49:00 +0300 Subject: [PATCH] WIP --- builtin/entitysync/entitysync.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/builtin/entitysync/entitysync.cpp b/builtin/entitysync/entitysync.cpp index 6ed7d79..5e6f36c 100644 --- a/builtin/entitysync/entitysync.cpp +++ b/builtin/entitysync/entitysync.cpp @@ -35,12 +35,10 @@ ss_ dump(const magic::VectorBuffer &buf) { std::ostringstream os(std::ios::binary); os<<"["; - bool first = true; - for(auto it = buf.GetBuffer().Begin(); it != buf.GetBuffer().End(); ++it){ - if(!first) + for(size_t i = 0; i < buf.GetBuffer().Size(); i++){ + if(i != 0) os<<", "; - first = false; - os<<(*it); + os<WriteInitialDeltaUpdate(buf); // TODO: User variables (see Network/Connection.cpp) + buf.WriteVLE(0); // Components buf.WriteVLE(node->GetNumNetworkComponents()); @@ -274,6 +273,18 @@ struct Module: public interface::Module, public entitysync::Interface send_to_all("entitysync:latest_node_data", buf); } + + if(node_state.dirtyAttributes_.Count() || node_state.dirtyVars_.Size()){ + magic::VectorBuffer buf; + + buf.WriteNetID(node->GetID()); + node->WriteDeltaUpdate(buf, node_state.dirtyAttributes_); + + // TODO: User variables + buf.WriteVLE(0); + + send_to_all("entitysync:latest_node_data", buf); + } } }