2012-07-14 16:37:52 +02:00
/*
* This software is licensed under the terms of the MIT - License
* See COPYING for further information .
* - - -
* Copyright ( C ) 2011 , Lukas Weber < laochailan @ web . de >
* Copyright ( C ) 2012 , Alexeyew Andrew < http : //akari.thebadasschoobs.org/>
*/
2012-07-14 19:46:03 +02:00
# ifndef REPLAY_H
# define REPLAY_H
# include "stage.h"
# include "player.h"
typedef struct ReplayEvent {
int frame ;
char type ;
2012-08-15 16:36:39 +02:00
short key ;
2012-07-14 19:46:03 +02:00
} ReplayEvent ;
2012-08-07 05:28:41 +02:00
typedef struct ReplayStage {
2012-07-14 19:46:03 +02:00
// initial game settings
int stage ;
2012-07-29 22:39:52 +02:00
int seed ; // this also happens to be the game initiation time - and we use this property, don't break it please
2012-07-14 19:46:03 +02:00
int diff ;
int points ;
// initial player settings
Character plr_char ;
ShotMode plr_shot ;
complex plr_pos ;
2012-08-07 07:01:57 +02:00
short plr_focus ;
short plr_fire ;
2012-07-14 19:46:03 +02:00
float plr_power ;
int plr_lifes ;
int plr_bombs ;
2012-08-07 02:45:38 +02:00
int plr_mflags ;
2012-07-14 19:46:03 +02:00
2012-07-29 22:39:52 +02:00
// events
2012-07-14 19:46:03 +02:00
ReplayEvent * events ;
int ecount ;
// The fields below should not be stored
2012-07-15 12:16:27 +02:00
int capacity ;
2012-07-29 15:54:49 +02:00
int playpos ;
2012-08-07 05:28:41 +02:00
} ReplayStage ;
typedef struct Replay {
// metadata
char * playername ;
// stages (NOTE FOR FUTURE: stages do not represent stage runs in particular, they can and should be used to store stuff like spell practice runs, too)
ReplayStage * stages ;
int stgcount ;
// The fields below should not be stored
int active ;
ReplayStage * current ;
int currentidx ;
2012-07-14 19:46:03 +02:00
} Replay ;
enum {
REPLAY_RECORD ,
REPLAY_PLAY
} ;
2012-08-07 05:28:41 +02:00
void replay_init ( Replay * rpy ) ;
ReplayStage * replay_init_stage ( Replay * rpy , StageInfo * stage , int seed , Player * plr ) ;
2012-07-14 19:46:03 +02:00
void replay_destroy ( Replay * rpy ) ;
2012-08-07 05:28:41 +02:00
void replay_destroy_stage ( ReplayStage * stage ) ;
ReplayStage * replay_select ( Replay * rpy , int stage ) ;
2012-07-14 19:46:03 +02:00
void replay_event ( Replay * rpy , int type , int key ) ;
2012-07-15 12:16:27 +02:00
int replay_write ( Replay * rpy , FILE * file ) ;
int replay_read ( Replay * rpy , FILE * file ) ;
2012-07-29 22:39:52 +02:00
char * replay_getpath ( char * name , int ext ) ; // must be freed
2012-07-16 17:47:06 +02:00
int replay_save ( Replay * rpy , char * name ) ;
int replay_load ( Replay * rpy , char * name ) ;
2012-07-29 22:39:52 +02:00
void replay_copy ( Replay * dst , Replay * src ) ;
2012-07-16 17:47:06 +02:00
2012-08-15 17:03:53 +02:00
# define REPLAY_ALLOC_INITIAL 1000
# define REPLAY_ALLOC_ADDITIONAL 500
2012-07-15 12:16:27 +02:00
# define REPLAY_MAGICNUMBER 1337
# define REPLAY_EXTENSION "tsr"
2012-07-15 20:19:31 +02:00
# define REPLAY_READ_MAXSTRLEN 128
2012-07-14 19:46:03 +02:00
# endif