taisei/src/replay.h

73 lines
1.5 KiB
C
Raw Normal View History

/*
* 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/>
*/
#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 {
// metadata
char *playername;
// initial game settings
int stage;
int seed; // this also happens to be the game initiation time - and we use this property, don't break it please
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;
// events
ReplayEvent *events;
int ecount;
// The fields below should not be stored
2012-07-15 12:16:27 +02:00
int capacity;
int active;
2012-07-29 15:54:49 +02:00
int playpos;
} 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);
char* replay_getpath(char *name, int ext); // must be freed
int replay_save(Replay *rpy, char *name);
int replay_load(Replay *rpy, char *name);
void replay_copy(Replay *dst, Replay *src);
#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"
#define REPLAY_READ_MAXSTRLEN 128
#endif