Convert anim step hashes from uint64 to int64, because blueprint has no uint64

This commit is contained in:
2025-10-10 19:03:04 -04:00
parent e7cb47db5b
commit 63dcbb7434
4 changed files with 45 additions and 28 deletions

View File

@@ -19,8 +19,10 @@ void AnimQueue::initialize_module() {
blankqueue_ = queue.get_encoded_queue();
}
static uint64_t hash_encstep(uint64_t prev, std::string_view s) {
return util::hash_string(util::HashValue(123, prev), s).first;
static int64_t hash_encstep(int64_t prev, std::string_view s) {
// We drop the most significant bit to ensure that the value
// can be represented as a nonnegative int64.
return int64_t(0x7FFFFFFF & util::hash_string(util::HashValue(123, prev), s).first);
}
// Parse a value. This is meant for unit testing only. The
@@ -368,7 +370,7 @@ int AnimQueue::get_actual_size() const {
return sb.read_uint8();
}
uint64_t AnimQueue::get_final_hash() const {
int64_t AnimQueue::get_final_hash() const {
if (encqueue_ == nullptr) return 0;
StreamBuffer sb(*encqueue_);
sb.read_bytes(2);
@@ -411,11 +413,11 @@ AnimQueue::QueueRange AnimQueue::get_range(int lo, int hi) {
return QueueRange(hi-lo, queueview.substr(pos1, pos2 - pos1));
}
uint64_t AnimQueue::hash_encstep(const QueueRange &prev, std::string_view s) {
uint64_t prev_hash = 0;
int64_t AnimQueue::hash_encstep(const QueueRange &prev, std::string_view s) {
int64_t prev_hash = 0;
if (prev.size > 0) {
StreamBuffer retsb(prev.entries);
prev_hash = retsb.read_uint64();
prev_hash = retsb.read_int64();
}
return ::hash_encstep(prev_hash, s);
}
@@ -429,7 +431,7 @@ void AnimQueue::update_encqueue(int limit, bool add, std::string_view add_enc, i
result.write_uint8(limit);
result.write_uint8(keeprange.size + (add ? 1:0));
if (add) {
uint64_t add_hash = hash_encstep(keeprange, add_enc);
int64_t add_hash = hash_encstep(keeprange, add_enc);
result.write_uint64(add_hash);
result.write_string(add_enc);
}