Fixed playback of gamepad events from replays (with hacks)

This commit is contained in:
Andrei "Akari" Alexeyev 2017-02-05 04:04:31 +02:00
parent ff3986c6cb
commit 3662daaff0
3 changed files with 9 additions and 9 deletions

View file

@ -91,7 +91,7 @@ ReplayStage* replay_select(Replay *rpy, int stage) {
return rpy->current;
}
void replay_event(Replay *rpy, uint8_t type, uint16_t key) {
void replay_event(Replay *rpy, uint8_t type, int16_t value) {
if(!rpy->active)
return;
@ -99,7 +99,7 @@ void replay_event(Replay *rpy, uint8_t type, uint16_t key) {
ReplayEvent *e = &(s->events[s->ecount]);
e->frame = global.frames;
e->type = type;
e->key = key;
e->value = (uint16_t)value;
s->ecount++;
if(s->ecount >= s->capacity) {
@ -121,7 +121,7 @@ void replay_write_string(SDL_RWops *file, char *str) {
int replay_write_stage_event(ReplayEvent *evt, SDL_RWops *file) {
SDL_WriteLE32(file, evt->frame);
SDL_WriteU8(file, evt->type);
SDL_WriteLE16(file, evt->key);
SDL_WriteLE16(file, evt->value);
return True;
}
@ -247,7 +247,7 @@ int replay_read(Replay *rpy, SDL_RWops *file) {
evt->frame = SDL_ReadLE32(file);
evt->type = SDL_ReadU8(file);
evt->key = SDL_ReadLE16(file);
evt->value = SDL_ReadLE16(file);
}
}

View file

@ -28,7 +28,7 @@ typedef union float64_u {
typedef struct ReplayEvent {
uint32_t frame;
uint8_t type;
uint16_t key;
uint16_t value;
} ReplayEvent;
typedef struct ReplayStage {
@ -84,7 +84,7 @@ ReplayStage* replay_init_stage(Replay *rpy, StageInfo *stage, uint64_t seed, Pla
void replay_destroy(Replay *rpy);
void replay_destroy_stage(ReplayStage *stage);
ReplayStage* replay_select(Replay *rpy, int stage);
void replay_event(Replay *rpy, uint8_t type, uint16_t key);
void replay_event(Replay *rpy, uint8_t type, int16_t value);
int replay_write(Replay *rpy, SDL_RWops *file);
int replay_read(Replay *rpy, SDL_RWops *file);

View file

@ -136,12 +136,12 @@ void replay_input(void) {
break;
default:
if(global.dialog && e->type == EV_PRESS && (e->key == KEY_SHOT || e->key == KEY_BOMB))
if(global.dialog && e->type == EV_PRESS && (e->value == KEY_SHOT || e->value == KEY_BOMB))
page_dialog(&global.dialog);
else if(global.dialog && e->key == KEY_SKIP)
else if(global.dialog && e->value == KEY_SKIP)
global.dialog->skip = (e->type == EV_PRESS);
else
player_event(&global.plr, e->type, e->key);
player_event(&global.plr, e->type, (int16_t)e->value);
break;
}
}