Initial Vectorail GC format library
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#ifndef OPENROLLER_GC_EVENTSTREAM_HPP
|
||||
#define OPENROLLER_GC_EVENTSTREAM_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace gc {
|
||||
|
||||
struct GameEvent {
|
||||
uint16_t id = 0;
|
||||
float timestamp = 0.0f;
|
||||
uint16_t a = 0; // unknown (often 0)
|
||||
uint32_t type = 0;
|
||||
float value = 0.0f;
|
||||
uint16_t b = 0; // unknown (often 0)
|
||||
};
|
||||
|
||||
struct EventStreamDecodeResult {
|
||||
size_t recordSize = 16; // 16 or 12 (for now)
|
||||
int alignment = 0; // best alignment within [0,recordSize-1]
|
||||
size_t eventCount = 0; // decoded event count at best alignment (bounded)
|
||||
double padZeroRatio = 0.0; // fraction of padding fields that are zero (0..1)
|
||||
int score = 0; // heuristic score for ranking
|
||||
};
|
||||
|
||||
EventStreamDecodeResult TryDecodeEventStream(const std::vector<uint8_t>& bytes, size_t start, size_t end);
|
||||
|
||||
// Like TryDecodeEventStream, but forces recordSize=12 or 16.
|
||||
EventStreamDecodeResult TryDecodeEventStreamFixed(const std::vector<uint8_t>& bytes, size_t start, size_t end, size_t recordSize);
|
||||
|
||||
// Decodes using a fixed record size (big endian).
|
||||
// recordSize=16: u16 id, f32 timestamp, u16 a, u16 type, f32 value, u16 b
|
||||
// recordSize=12: f32 timestamp, u32 type, f32 value
|
||||
bool DecodeEventStream(
|
||||
const std::vector<uint8_t>& bytes,
|
||||
size_t start,
|
||||
size_t end,
|
||||
size_t recordSize,
|
||||
std::vector<GameEvent>* out,
|
||||
std::string* err);
|
||||
|
||||
} // namespace gc
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user