diff xmit of animation queues. Also, StreamBuffer::unwrite_to

This commit is contained in:
2021-07-13 15:18:37 -04:00
parent 3fc76afc09
commit 1904f03dad
4 changed files with 260 additions and 51 deletions

View File

@@ -95,6 +95,20 @@ public:
void clear();
// ExactlyEqual compares all fields.
bool exactly_equal(const AnimStep &other) const;
// LogicallyEqual only compares fields whose HAS_XXX bits are set.
bool logically_equal(const AnimStep &other) const;
// StateEqual is true if the plane, graphic, facing, and xyz match.
bool state_equal(const AnimStep &other) const;
// read/write the step using a stream buffer.
//
void write_into(StreamBuffer *sb) const;
void read_from(StreamBuffer *sb);
// Create an AnimStep from a lua table.
//
// Lua stack must contain a table, which may contain:
@@ -111,6 +125,9 @@ public:
//
void from_lua(lua_State *L, int idx, const AnimStep &qback);
// Make this step into a first-step of an anim queue.
void keep_state_only();
// For any values that are unchanged in this step,
// echo the values of the previous step.
void echo(const AnimStep &prev);
@@ -127,6 +144,8 @@ private:
public:
AnimQueue();
bool exactly_equal(const AnimQueue &aq) const;
const AnimStep &nth(int n) const { return steps_[n]; }
size_t size() const { return steps_.size(); }
int32_t size_limit() const { return size_limit_; }
@@ -147,6 +166,15 @@ public:
void serialize(StreamBuffer *sb);
void deserialize(StreamBuffer *sb);
// Difference transmission
//
// make_patch will emit zero bytes when there are no differences.
// make_patch does not put a 'length' field for the patch as a whole.
// apply_patch must receive a patch followed by eof.
//
void make_patch(const AnimQueue &auth, StreamBuffer *sb) const;
void apply_patch(StreamBuffer *sb);
// Get the final resting place after all animations are complete.
const AnimStep &back() const;
@@ -154,7 +182,7 @@ public:
void set_size_limit(int32_t n);
// (For testing): make sure the invariants are preserved.
bool valid();
bool valid() const;
};
#endif // ANIMQUEUE_HPP