fork/slippc
git clone https://git.julia.blue/fork/slippc
30c55ad
0.6.0
1#ifndef REPLAY_H_ 2#define REPLAY_H_ 3 4#include <iostream> 5#include <fstream> 6 7#include "enums.h" 8#include "util.h" 9 10// Replay File (.slp) Spec: https://github.com/project-slippi/project-slippi/wiki/Replay-File-Spec 11 12const unsigned MAX_ITEMS = 1024 ;//Max number of items to output 13 14namespace slip { 15 16struct SlippiFrame { 17//Parser stuff 18bool alive = false;//For checking if this frame was actually set 19 20//Pre-frame stuff 21int32_t frame = 0 ; 22uint8_t player = 0 ; 23bool follower = false; 24uint32_t seed = 0 ; 25uint16_t action_pre = 0 ; 26float pos_x_pre = 0.0f ; 27float pos_y_pre = 0.0f ; 28float face_dir_pre = 0.0f ; 29float joy_x = 0.0f ; 30float joy_y = 0.0f ; 31float c_x = 0.0f ; 32float c_y = 0.0f ; 33float trigger = 0.0f ; 34uint16_t buttons = 0 ; 35float phys_l = 0.0f ; 36float phys_r = 0.0f ; 37uint8_t ucf_x = 0 ; 38float percent_pre = 0.0f ; 39 40//Post-frame stuff 41uint8_t char_id = 0 ; 42uint16_t action_post = 0 ; 43float pos_x_post = 0.0f ; 44float pos_y_post = 0.0f ; 45float face_dir_post = 0.0f ; 46float percent_post = 0.0f ; 47float shield = 0.0f ; 48uint8_t hit_with = 0 ; 49uint8_t combo = 0 ; 50uint8_t hurt_by = 0 ; 51uint8_t stocks = 0 ; 52float action_fc = 0.0f ; 53uint8_t flags_1 = 0 ; 54uint8_t flags_2 = 0 ; 55uint8_t flags_3 = 0 ; 56uint8_t flags_4 = 0 ; 57uint8_t flags_5 = 0 ; 58float hitstun = 0.0f ; 59bool airborne = false; 60uint16_t ground_id = 0 ; 61uint8_t jumps = 0 ; 62uint8_t l_cancel = 0 ; 63uint8_t hurtbox = 0 ; 64float self_air_x = 0 ; 65float self_air_y = 0 ; 66float attack_x = 0 ; 67float attack_y = 0 ; 68float self_grd_x = 0 ; 69float hitlag = 0 ; 70}; 71 72struct SlippiItemFrame { 73int32_t frame = 0 ; 74uint8_t state = 0 ; 75float face_dir = 0 ; 76float xvel = 0 ; 77float yvel = 0 ; 78float xpos = 0 ; 79float ypos = 0 ; 80uint16_t damage = 0 ; 81float expire = 0 ; 82uint8_t flags_1 = 0 ; 83uint8_t flags_2 = 0 ; 84uint8_t flags_3 = 0 ; 85uint8_t flags_4 = 0 ; 86uint8_t owner = 0 ; 87}; 88 89struct SlippiItem { 90uint16_t type = 0 ; 91uint32_t spawn_id = MAX_ITEMS +1 ; 92uint32_t num_frames = 0 ; 93SlippiItemFrame * frame = nullptr; 94}; 95 96struct SlippiPlayer { 97uint8_t ext_char_id = 0 ; 98uint8_t player_type = 3 ;//empty 99uint8_t start_stocks = 0 ; 100uint8_t end_stocks = 0 ; 101uint8_t color = 0 ; 102uint8_t team_id = 0 ; 103uint8_t cpu_level = 0 ; 104uint32_t dash_back = 0 ; 105uint32_t shield_drop = 0 ; 106std ::string tag = ""; 107std ::string tag_code = ""; 108std ::string tag_css = ""; 109SlippiFrame * frame = nullptr; 110}; 111 112struct SlippiReplay { 113uint32_t slippi_version_raw = 0 ; 114std ::string slippi_version = ""; 115std ::string parser_version = ""; 116std ::string game_start_raw = ""; 117std ::string metadata = ""; 118std ::string played_on = ""; 119std ::string start_time = ""; 120int8_t winner_id = -1 ; 121bool teams = false; 122uint16_t stage = 0 ; 123uint32_t seed = 0 ; 124bool pal = false; 125bool frozen = false; 126uint8_t end_type = 0 ; 127int8_t lras = -1 ; 128int32_t first_frame = LOAD_FRAME ; 129int32_t last_frame = 0 ; 130uint32_t frame_count = 0 ; 131uint8_t timer = 0 ; 132int8_t items_on = 0 ; 133bool sudden_death = false; 134SlippiPlayer player [8 ]= {0 }; 135SlippiItem item [MAX_ITEMS ]= {0 }; 136 137void setFrames (int32_t max_frames ); 138void cleanup (); 139std ::string replayAsJson (bool delta ); 140}; 141 142 143} 144 145#endif /* REPLAY_H_ */