Serialization for idalloc and animqueue
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <deque>
|
||||
#include <cassert>
|
||||
#include <unordered_map>
|
||||
#include "streambuffer.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
|
||||
@@ -45,8 +46,8 @@ public:
|
||||
|
||||
private:
|
||||
int64_t id_;
|
||||
int16_t bits_;
|
||||
std::string action_;
|
||||
int bits_;
|
||||
|
||||
float facing_;
|
||||
util::XYZ xyz_;
|
||||
@@ -58,8 +59,8 @@ public:
|
||||
~AnimStep();
|
||||
|
||||
int64_t id() const { return id_; }
|
||||
const std::string &action() const { return action_; }
|
||||
int bits() const { return bits_; }
|
||||
const std::string &action() const { return action_; }
|
||||
|
||||
double facing() const { return facing_; }
|
||||
util::XYZ xyz() const { return xyz_; }
|
||||
@@ -75,15 +76,21 @@ public:
|
||||
class AnimQueue {
|
||||
private:
|
||||
int64_t id_;
|
||||
int size_limit_;
|
||||
int32_t size_limit_;
|
||||
std::deque<AnimStep> steps_;
|
||||
|
||||
public:
|
||||
AnimQueue();
|
||||
|
||||
int64_t get_id() const { return id_; }
|
||||
void set_id(int64_t id) { id_ = id; }
|
||||
const AnimStep &nth(int n) const { return steps_[n]; }
|
||||
int size() const { return steps_.size(); }
|
||||
size_t size() const { return steps_.size(); }
|
||||
int32_t size_limit() const { return size_limit_; }
|
||||
|
||||
// Clear the steps. Doesn't affect size_limit or id.
|
||||
void clear_steps();
|
||||
|
||||
// Mutators to create new steps from C++
|
||||
//
|
||||
void add(int64_t id, const std::string &action);
|
||||
@@ -92,6 +99,10 @@ public:
|
||||
void set_graphic(const std::string &g);
|
||||
void set_plane(const std::string &p);
|
||||
|
||||
// Serialize or deserialize to a StreamBuffer
|
||||
void serialize(StreamBuffer *sb);
|
||||
void deserialize(StreamBuffer *sb);
|
||||
|
||||
// Mutator to create new steps from lua.
|
||||
//
|
||||
// Lua stack must contain a table, which may contain:
|
||||
@@ -113,8 +124,11 @@ public:
|
||||
const std::string &get_plane() const;
|
||||
const util::XYZ &get_xyz() const;
|
||||
|
||||
// Functions for unit testing.
|
||||
void set_size_limit(int n);
|
||||
// (For testing): change the size limit.
|
||||
void set_size_limit(int32_t n);
|
||||
|
||||
// (For testing): make sure the invariants are preserved.
|
||||
bool valid();
|
||||
};
|
||||
|
||||
#endif // ANIMQUEUE_HPP
|
||||
|
||||
Reference in New Issue
Block a user