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