phantasia

Phantasia - 2D SDL3 RPG prototype.
git clone git://git.beep.wimdupont.com/phantasia.git
Log | Files | Refs | README | LICENSE

replay.h (903B)


      1 #ifndef PH_GAME_REPLAY_H
      2 #define PH_GAME_REPLAY_H
      3 
      4 #include "game/game.h"
      5 #include <stdio.h>
      6 
      7 /* Versioned, little-endian input stream. Actions are ordered before the next
      8  * tick; paused menus can have any number of actions without advancing time.
      9  * Fresh game only, with identical content/config/build required for replay. */
     10 enum { PH_REPLAY_END, PH_REPLAY_ACTION, PH_REPLAY_TICK };
     11 int ph_replay_header(FILE *file, unsigned int *seed, int writing);
     12 int ph_replay_write(FILE *file, int kind, PhAction action, PhInput input);
     13 /* Returns record kind, or -1 for malformed/truncated input (including no END). */
     14 int ph_replay_read(FILE *file, PhAction *action, PhInput *input);
     15 /* Context must be a fresh game with no open menu and the header's RNG seed.
     16  * Runs without saving; returns 0 at END or -1 on invalid input. */
     17 int ph_replay_run(FILE *file, PhGameContext *context, uint64_t *ticks);
     18 
     19 #endif