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;
|
|
|
|
char key;
|
|
|
|
} ReplayEvent;
|
|
|
|
|
|
|
|
typedef struct Replay {
|
2012-07-29 22:39:52 +02:00
|
|
|
// metadata
|
|
|
|
char *playername;
|
|
|
|
|
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;
|
|
|
|
float plr_power;
|
|
|
|
int plr_lifes;
|
|
|
|
int plr_bombs;
|
|
|
|
|
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-14 19:46:03 +02:00
|
|
|
int active;
|
2012-07-29 15:54:49 +02:00
|
|
|
int playpos;
|
2012-07-14 19:46:03 +02:00
|
|
|
} Replay;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
REPLAY_RECORD,
|
|
|
|
REPLAY_PLAY
|
|
|
|
};
|
|
|
|
|
|
|
|
void replay_init(Replay *rpy, StageInfo *stage, int seed, Player *plr);
|
|
|
|
void replay_destroy(Replay *rpy);
|
|
|
|
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-07-14 19:46:03 +02:00
|
|
|
#define REPLAY_ALLOC_INITIAL 100
|
|
|
|
#define REPLAY_ALLOC_ADDITIONAL 100
|
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
|