Spooky hash, smarter animqueue diffs
This commit is contained in:
@@ -19,6 +19,27 @@
|
||||
// set_plane, or an other setter. These setters are meant to only be used
|
||||
// immediately after calling 'add' to populate the new step.
|
||||
//
|
||||
// VERSION NUMBERS
|
||||
//
|
||||
// The version number field: if the version number in the synchronous model is
|
||||
// equal to the version number in the master model, then the two animqueues are
|
||||
// guaranteed to be equal. Here's how we achieve that invariant:
|
||||
//
|
||||
// * In the master model, the version number starts at 1 and is incremented
|
||||
// every time the animation queue is mutated.
|
||||
//
|
||||
// * In the synchronous model, the version number is set to zero every time the
|
||||
// animation queue is mutated. Note that master version numbers are never
|
||||
// zero. Applying a patch also sets the version number to zero.
|
||||
//
|
||||
// * Serializing and deserializing causes the version number to be saved and
|
||||
// restored in both master and synchronous models.
|
||||
//
|
||||
// * The routine 'update_version' should be called after difference
|
||||
// transmission. This copies the version number from the master to the
|
||||
// synchronous model. This is guaranteed to be safe because we just finished
|
||||
// difference transmission, therefore, the animatio queues should match.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ANIMQUEUE_HPP
|
||||
@@ -138,25 +159,28 @@ public:
|
||||
|
||||
class AnimQueue {
|
||||
private:
|
||||
util::WorldType world_type_;
|
||||
int32_t size_limit_;
|
||||
std::deque<AnimStep> steps_;
|
||||
int64_t version_number_;
|
||||
|
||||
// Called whenever the animation queue is mutated.
|
||||
// serialization and deserialization
|
||||
void mutated();
|
||||
public:
|
||||
AnimQueue();
|
||||
AnimQueue(util::WorldType wt);
|
||||
|
||||
bool exactly_equal(const AnimQueue &aq) const;
|
||||
|
||||
// Simple getters.
|
||||
const AnimStep &nth(int n) const { return steps_[n]; }
|
||||
size_t size() const { return steps_.size(); }
|
||||
int32_t size_limit() const { return size_limit_; }
|
||||
|
||||
// Discard all but the most recent N steps.
|
||||
void keep_only(int n);
|
||||
// Return true if the size limit and steps are identical.
|
||||
bool size_and_steps_equal(const AnimQueue &aq) const;
|
||||
|
||||
// Clear the steps.
|
||||
// Clear the steps. Doesn't affect size_limit.
|
||||
// The resulting steps aren't empty. There will be one
|
||||
// step in the queue, which will be on the plane "", at (0,0,0).
|
||||
// Doesn't affect size_limit.
|
||||
void clear_steps();
|
||||
|
||||
// Mutator to create a new step.
|
||||
@@ -167,13 +191,10 @@ public:
|
||||
void deserialize(StreamBuffer *sb);
|
||||
|
||||
// Difference transmission
|
||||
//
|
||||
// When there are no differences, make_patch returns false but
|
||||
// still writes out a valid patch.
|
||||
//
|
||||
bool make_patch(const AnimQueue &auth, StreamBuffer *sb) const;
|
||||
void apply_patch(StreamBuffer *sb);
|
||||
|
||||
void update_version(const AnimQueue &auth);
|
||||
|
||||
// Get the final resting place after all animations are complete.
|
||||
const AnimStep &back() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user