Improved player input handling. Smooth focus transitions at all times.
Note that the focus change may desync some old replays (particularly, the MarisaA ones)
This commit is contained in:
parent
f1f639611d
commit
591b5258fc
8 changed files with 117 additions and 117 deletions
|
@ -55,7 +55,7 @@ void print_state_checksum(void) {
|
|||
Enemy *s;
|
||||
Projectile *pr;
|
||||
|
||||
plr = creal(p->pos)+cimag(p->pos)+p->focus+p->fire+p->power+p->lifes+p->bombs+p->recovery+p->deathtime+p->continues+p->moveflags;
|
||||
plr = creal(p->pos)+cimag(p->pos)+p->focus+p->power+p->lifes+p->bombs+p->recovery+p->deathtime+p->continues+p->inputflags;
|
||||
|
||||
for(s = global.plr.slaves; s; s = s->next) {
|
||||
spos += creal(s->pos + s->pos0) + cimag(s->pos + s->pos0);
|
||||
|
|
|
@ -72,7 +72,7 @@ void process_items(void) {
|
|||
int v;
|
||||
|
||||
float r = 30;
|
||||
if(global.plr.focus > 0)
|
||||
if(global.plr.inputflags & INFLAG_FOCUS)
|
||||
r *= 2;
|
||||
|
||||
while(item != NULL) {
|
||||
|
|
|
@ -22,8 +22,6 @@ void continue_game(MenuData *m, void *arg)
|
|||
|
||||
global.plr.lifes = PLR_START_LIVES;
|
||||
global.plr.continues += 1;
|
||||
global.plr.focus = 0;
|
||||
global.plr.fire = 0;
|
||||
|
||||
delete_projectiles(&global.projs);
|
||||
delete_projectiles(&global.particles);
|
||||
|
|
149
src/player.c
149
src/player.c
|
@ -72,7 +72,10 @@ void player_set_power(Player *plr, short npow) {
|
|||
}
|
||||
|
||||
void player_move(Player *plr, complex delta) {
|
||||
float speed = 0.01*VIEWPORT_W/((plr->focus > 0)+1);
|
||||
float speed = 0.01*VIEWPORT_W;
|
||||
|
||||
if(plr->inputflags & INFLAG_FOCUS)
|
||||
speed /= 2.0;
|
||||
|
||||
if(plr->cha == Marisa && plr->shot == MarisaLaser && global.frames - plr->recovery < 0)
|
||||
speed /= 5.0;
|
||||
|
@ -94,11 +97,11 @@ void player_draw(Player* plr) {
|
|||
glPushMatrix();
|
||||
glTranslatef(creal(plr->pos), cimag(plr->pos), 0);
|
||||
|
||||
if(plr->focus != 0) {
|
||||
if(plr->focus) {
|
||||
glPushMatrix();
|
||||
glRotatef(global.frames*10, 0, 0, 1);
|
||||
glScalef(1, 1, 1);
|
||||
glColor4f(1,1,1,0.2);
|
||||
glColor4f(1, 1, 1, 0.2 * (clamp(plr->focus, 0, 15) / 15.0));
|
||||
draw_texture(0, 0, "fairy_circle");
|
||||
glColor4f(1,1,1,1);
|
||||
glPopMatrix();
|
||||
|
@ -127,12 +130,12 @@ void player_draw(Player* plr) {
|
|||
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
if(plr->focus != 0) {
|
||||
if(plr->focus) {
|
||||
glPushMatrix();
|
||||
glColor4f(1,1,1,fabs((float)plr->focus/30.0f));
|
||||
glColor4f(1, 1, 1, plr->focus / 30.0);
|
||||
glRotatef(global.frames, 0, 0, -1);
|
||||
draw_texture(0, 0, "focus");
|
||||
glColor4f(1,1,1,1);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -147,20 +150,17 @@ void player_logic(Player* plr) {
|
|||
return;
|
||||
}
|
||||
|
||||
if(plr->focus < 0 || (plr->focus > 0 && plr->focus < 30))
|
||||
plr->focus++;
|
||||
|
||||
plr->focus = approach(plr->focus, (plr->inputflags & INFLAG_FOCUS) ? 30 : 0, 1);
|
||||
|
||||
switch(plr->cha) {
|
||||
case Youmu:
|
||||
youmu_shot(plr);
|
||||
break;
|
||||
case Marisa:
|
||||
marisa_shot(plr);
|
||||
break;
|
||||
case Youmu:
|
||||
youmu_shot(plr);
|
||||
break;
|
||||
case Marisa:
|
||||
marisa_shot(plr);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(global.frames == plr->deathtime)
|
||||
player_realdeath(plr);
|
||||
|
||||
|
@ -214,7 +214,7 @@ void player_bomb(Player *plr) {
|
|||
void player_realdeath(Player *plr) {
|
||||
plr->deathtime = -DEATH_DELAY-1;
|
||||
plr->respawntime = global.frames;
|
||||
plr->moveflags = 0;
|
||||
plr->inputflags &= ~INFLAGS_MOVE;
|
||||
|
||||
const double arc = 0.3 * M_PI;
|
||||
int drop = max(2, (plr->power * 0.15) / POWER_VALUE);
|
||||
|
@ -252,27 +252,36 @@ void player_death(Player *plr) {
|
|||
}
|
||||
}
|
||||
|
||||
void player_setmoveflag(Player* plr, int key, bool mode) {
|
||||
int flag = 0;
|
||||
|
||||
static PlrInputFlag key_to_inflag(KeyIndex key) {
|
||||
switch(key) {
|
||||
case KEY_UP: flag = MOVEFLAG_UP; break;
|
||||
case KEY_DOWN: flag = MOVEFLAG_DOWN; break;
|
||||
case KEY_LEFT: flag = MOVEFLAG_LEFT; break;
|
||||
case KEY_RIGHT: flag = MOVEFLAG_RIGHT; break;
|
||||
case KEY_UP: return INFLAG_UP; break;
|
||||
case KEY_DOWN: return INFLAG_DOWN; break;
|
||||
case KEY_LEFT: return INFLAG_LEFT; break;
|
||||
case KEY_RIGHT: return INFLAG_RIGHT; break;
|
||||
case KEY_FOCUS: return INFLAG_FOCUS; break;
|
||||
case KEY_SHOT: return INFLAG_SHOT; break;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void player_setinputflag(Player *plr, KeyIndex key, bool mode) {
|
||||
PlrInputFlag flag = key_to_inflag(key);
|
||||
|
||||
if(!flag) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!flag)
|
||||
return;
|
||||
|
||||
if(mode) {
|
||||
plr->prevmove = plr->curmove;
|
||||
plr->prevmovetime = plr->movetime;
|
||||
plr->curmove = flag;
|
||||
plr->moveflags |= flag;
|
||||
plr->movetime = global.frames;
|
||||
if(flag & INFLAGS_MOVE) {
|
||||
plr->prevmove = plr->curmove;
|
||||
plr->prevmovetime = plr->movetime;
|
||||
plr->curmove = flag;
|
||||
plr->movetime = global.frames;
|
||||
}
|
||||
|
||||
plr->inputflags |= flag;
|
||||
} else {
|
||||
plr->moveflags &= ~flag;
|
||||
plr->inputflags &= ~flag;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,14 +289,6 @@ void player_event(Player* plr, int type, int key) {
|
|||
switch(type) {
|
||||
case EV_PRESS:
|
||||
switch(key) {
|
||||
case KEY_FOCUS:
|
||||
plr->focus = 1;
|
||||
break;
|
||||
|
||||
case KEY_SHOT:
|
||||
plr->fire = true;
|
||||
break;
|
||||
|
||||
case KEY_BOMB:
|
||||
player_bomb(plr);
|
||||
break;
|
||||
|
@ -297,26 +298,13 @@ void player_event(Player* plr, int type, int key) {
|
|||
break;
|
||||
|
||||
default:
|
||||
player_setmoveflag(plr, key, true);
|
||||
player_setinputflag(plr, key, true);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case EV_RELEASE:
|
||||
switch(key) {
|
||||
case KEY_FOCUS:
|
||||
plr->focus = -30; // that's for the transparency timer
|
||||
break;
|
||||
|
||||
case KEY_SHOT:
|
||||
plr->fire = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
player_setmoveflag(plr, key, false);
|
||||
break;
|
||||
}
|
||||
|
||||
player_setinputflag(plr, key, false);
|
||||
break;
|
||||
|
||||
case EV_AXIS_LR:
|
||||
|
@ -334,7 +322,7 @@ bool player_applymovement_gamepad(Player *plr) {
|
|||
if(!plr->axis_lr && !plr->axis_ud) {
|
||||
if(plr->gamepadmove) {
|
||||
plr->gamepadmove = false;
|
||||
plr->moveflags = 0;
|
||||
plr->inputflags &= ~INFLAGS_MOVE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -348,10 +336,10 @@ bool player_applymovement_gamepad(Player *plr) {
|
|||
int sr = SIGN(real);
|
||||
int si = SIGN(imag);
|
||||
|
||||
player_setmoveflag(plr, KEY_UP, si == -1);
|
||||
player_setmoveflag(plr, KEY_DOWN, si == 1);
|
||||
player_setmoveflag(plr, KEY_LEFT, sr == -1);
|
||||
player_setmoveflag(plr, KEY_RIGHT, sr == 1);
|
||||
player_setinputflag(plr, KEY_UP, si == -1);
|
||||
player_setinputflag(plr, KEY_DOWN, si == 1);
|
||||
player_setinputflag(plr, KEY_LEFT, sr == -1);
|
||||
player_setinputflag(plr, KEY_RIGHT, sr == 1);
|
||||
|
||||
if(direction) {
|
||||
plr->gamepadmove = true;
|
||||
|
@ -368,10 +356,10 @@ void player_applymovement(Player *plr) {
|
|||
bool gamepad = player_applymovement_gamepad(plr);
|
||||
plr->moving = false;
|
||||
|
||||
int up = plr->moveflags & MOVEFLAG_UP,
|
||||
down = plr->moveflags & MOVEFLAG_DOWN,
|
||||
left = plr->moveflags & MOVEFLAG_LEFT,
|
||||
right = plr->moveflags & MOVEFLAG_RIGHT;
|
||||
int up = plr->inputflags & INFLAG_UP,
|
||||
down = plr->inputflags & INFLAG_DOWN,
|
||||
left = plr->inputflags & INFLAG_LEFT,
|
||||
right = plr->inputflags & INFLAG_RIGHT;
|
||||
|
||||
if(left && !right) {
|
||||
plr->moving = true;
|
||||
|
@ -399,21 +387,26 @@ void player_applymovement(Player *plr) {
|
|||
}
|
||||
|
||||
void player_input_workaround(Player *plr) {
|
||||
if(!global.dialog) {
|
||||
int shot = gamekeypressed(KEY_SHOT);
|
||||
int focus = gamekeypressed(KEY_FOCUS);
|
||||
for(KeyIndex key = KEYIDX_FIRST; key <= KEYIDX_LAST; ++key) {
|
||||
int flag = key_to_inflag(key);
|
||||
|
||||
if(!shot && plr->fire) {
|
||||
player_event(plr, EV_RELEASE, KEY_SHOT);
|
||||
replay_stage_event(global.replay_stage, global.frames, EV_RELEASE, KEY_SHOT);
|
||||
} else if(shot && !plr->fire) {
|
||||
player_event(plr, EV_PRESS, KEY_SHOT);
|
||||
replay_stage_event(global.replay_stage, global.frames, EV_PRESS, KEY_SHOT);
|
||||
}
|
||||
if(flag) {
|
||||
int event = -1;
|
||||
bool flagset = plr->inputflags & flag;
|
||||
bool keyheld = gamekeypressed(key);
|
||||
|
||||
if(!focus && plr->focus > 0) {
|
||||
player_event(plr, EV_RELEASE, KEY_FOCUS);
|
||||
replay_stage_event(global.replay_stage, global.frames, EV_RELEASE, KEY_FOCUS);
|
||||
if(flagset && !keyheld) {
|
||||
// something ate the release event (most likely the ingame menu)
|
||||
event = EV_RELEASE;
|
||||
} else if(!flagset && keyheld) {
|
||||
// something ate the press event (most likely the ingame menu)
|
||||
event = EV_PRESS;
|
||||
}
|
||||
|
||||
if(event != -1) {
|
||||
player_event(plr, event, key);
|
||||
replay_stage_event(global.replay_stage, global.frames, event, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
21
src/player.h
21
src/player.h
|
@ -15,11 +15,19 @@
|
|||
#include "gamepad.h"
|
||||
#include "resource/animation.h"
|
||||
|
||||
typedef enum {
|
||||
// do not reorder these or you'll break replays
|
||||
|
||||
INFLAG_UP = 1,
|
||||
INFLAG_DOWN = 2,
|
||||
INFLAG_LEFT = 4,
|
||||
INFLAG_RIGHT = 8,
|
||||
INFLAG_FOCUS = 16,
|
||||
INFLAG_SHOT = 32,
|
||||
} PlrInputFlag;
|
||||
|
||||
enum {
|
||||
MOVEFLAG_UP = 1,
|
||||
MOVEFLAG_DOWN = 2,
|
||||
MOVEFLAG_LEFT = 4,
|
||||
MOVEFLAG_RIGHT = 8
|
||||
INFLAGS_MOVE = INFLAG_UP | INFLAG_DOWN | INFLAG_LEFT | INFLAG_RIGHT
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
@ -38,7 +46,6 @@ typedef enum {
|
|||
typedef struct {
|
||||
complex pos;
|
||||
short focus;
|
||||
bool fire;
|
||||
bool moving;
|
||||
|
||||
short dir;
|
||||
|
@ -61,7 +68,7 @@ typedef struct {
|
|||
ShotMode shot;
|
||||
Enemy *slaves;
|
||||
|
||||
int moveflags;
|
||||
int inputflags;
|
||||
int curmove;
|
||||
int movetime;
|
||||
int prevmove;
|
||||
|
@ -90,7 +97,7 @@ void player_realdeath(Player*);
|
|||
void player_death(Player*);
|
||||
void player_graze(Player*, complex, int);
|
||||
|
||||
void player_setmoveflag(Player* plr, int key, bool mode);
|
||||
void player_setinputflag(Player *plr, KeyIndex key, bool mode);
|
||||
void player_event(Player* plr, int type, int key);
|
||||
void player_applymovement(Player* plr);
|
||||
void player_input_workaround(Player *plr);
|
||||
|
|
|
@ -137,8 +137,8 @@ int youmu_opposite_myon(Enemy *e, int t) {
|
|||
float arg = carg(e->pos0);
|
||||
float rad = cabs(e->pos0);
|
||||
|
||||
if(plr->focus < 1) {
|
||||
if(plr->moveflags && !creal(e->args[0]))
|
||||
if(!(plr->inputflags & INFLAG_FOCUS)) {
|
||||
if(plr->inputflags && !creal(e->args[0]))
|
||||
arg -= (carg(e->pos0)-carg(e->pos-plr->pos))*2;
|
||||
|
||||
//if(global.frames - plr->prevmovetime <= 10 && global.frames == plr->movetime) {
|
||||
|
@ -146,16 +146,16 @@ int youmu_opposite_myon(Enemy *e, int t) {
|
|||
int new = plr->curmove;
|
||||
int old = plr->prevmove;
|
||||
|
||||
if(new == MOVEFLAG_UP && old == MOVEFLAG_DOWN) {
|
||||
if(new == INFLAG_UP && old == INFLAG_DOWN) {
|
||||
arg = M_PI/2;
|
||||
e->args[0] = plr->movetime;
|
||||
} else if(new == MOVEFLAG_DOWN && old == MOVEFLAG_UP) {
|
||||
} else if(new == INFLAG_DOWN && old == INFLAG_UP) {
|
||||
arg = 3*M_PI/2;
|
||||
e->args[0] = plr->movetime;
|
||||
} else if(new == MOVEFLAG_LEFT && old == MOVEFLAG_RIGHT) {
|
||||
} else if(new == INFLAG_LEFT && old == INFLAG_RIGHT) {
|
||||
arg = 0;
|
||||
e->args[0] = plr->movetime;
|
||||
} else if(new == MOVEFLAG_RIGHT && old == MOVEFLAG_LEFT) {
|
||||
} else if(new == INFLAG_RIGHT && old == INFLAG_LEFT) {
|
||||
arg = M_PI;
|
||||
e->args[0] = plr->movetime;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ int youmu_opposite_myon(Enemy *e, int t) {
|
|||
complex target = plr->pos + e->pos0;
|
||||
e->pos += cexp(I*carg(target - e->pos)) * min(10, 0.07 * cabs(target - e->pos));
|
||||
|
||||
if(plr->fire && !(global.frames % 6) && global.plr.deathtime >= -1) {
|
||||
if(plr->inputflags & INFLAG_SHOT && !(global.frames % 6) && global.plr.deathtime >= -1) {
|
||||
int a = 20;
|
||||
|
||||
if(plr->power >= 300) {
|
||||
|
@ -217,8 +217,7 @@ int youmu_split(Enemy *e, int t) {
|
|||
// Youmu Generic
|
||||
|
||||
void youmu_shot(Player *plr) {
|
||||
if(plr->fire) {
|
||||
|
||||
if(plr->inputflags & INFLAG_SHOT) {
|
||||
if(!(global.frames % 4))
|
||||
play_sound("generic_shot");
|
||||
|
||||
|
@ -228,7 +227,7 @@ void youmu_shot(Player *plr) {
|
|||
}
|
||||
|
||||
if(plr->shot == YoumuHoming) {
|
||||
if(plr->focus && !(global.frames % 45)) {
|
||||
if(plr->inputflags & INFLAG_FOCUS && !(global.frames % 45)) {
|
||||
int ref = -1;
|
||||
if(global.boss != NULL)
|
||||
ref = add_ref(global.boss);
|
||||
|
@ -240,7 +239,7 @@ void youmu_shot(Player *plr) {
|
|||
create_projectile2c("youhoming", plr->pos, 0, youmu_homing, -3.0*I, ref)->type = PlrProj+(450+225*(plr->power/100));
|
||||
}
|
||||
|
||||
if(!plr->focus && !(global.frames % (int)round(8 - (plr->power / 100.0) * 1.3))) {
|
||||
if(!(plr->inputflags & INFLAG_FOCUS) && !(global.frames % (int)round(8 - (plr->power / 100.0) * 1.3))) {
|
||||
create_projectile2c("hghost", plr->pos, 0, accelerated, 2-10.0*I, -0.4*I)->type = PlrProj+27;
|
||||
create_projectile2c("hghost", plr->pos, 0, accelerated, -10.0*I, -0.4*I)->type = PlrProj+27;
|
||||
create_projectile2c("hghost", plr->pos, 0, accelerated, -2-10.0*I, -0.4*I)->type = PlrProj+27;
|
||||
|
@ -296,7 +295,7 @@ int mari_laser(Projectile *p, int t) {
|
|||
return ACTION_DESTROY;
|
||||
|
||||
float angle = creal(p->args[2]);
|
||||
float factor = (1-abs(global.plr.focus)/30.0) * !!angle;
|
||||
float factor = (1-global.plr.focus/30.0) * !!angle;
|
||||
complex dir = -cexp(I*((angle+0.025*sin(global.frames/50.0)*(angle > 0? 1 : -1))*factor + M_PI/2));
|
||||
p->args[0] = 20*dir;
|
||||
linear(p, t);
|
||||
|
@ -307,7 +306,7 @@ int mari_laser(Projectile *p, int t) {
|
|||
}
|
||||
|
||||
int marisa_laser_slave(Enemy *e, int t) {
|
||||
if(global.plr.fire && global.frames - global.plr.recovery >= 0 && global.plr.deathtime >= -1) {
|
||||
if(global.plr.inputflags & INFLAG_SHOT && global.frames - global.plr.recovery >= 0 && global.plr.deathtime >= -1) {
|
||||
if(!(global.frames % 4))
|
||||
create_projectile_p(&global.projs, get_tex("proj/marilaser"), 0, 0, MariLaser, mari_laser, 0, add_ref(e),e->args[2],0)->type = PlrProj+e->args[1]*4;
|
||||
|
||||
|
@ -318,7 +317,7 @@ int marisa_laser_slave(Enemy *e, int t) {
|
|||
create_particle1c("lasercurve", e->pos, 0, Fade, timeout, 4)->type = PlrProj;
|
||||
}
|
||||
|
||||
e->pos = global.plr.pos + (1 - abs(global.plr.focus)/30.0)*e->pos0 + (abs(global.plr.focus)/30.0)*e->args[0];
|
||||
e->pos = global.plr.pos + (1 - global.plr.focus/30.0)*e->pos0 + (global.plr.focus/30.0)*e->args[0];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -433,9 +432,9 @@ int marisa_star_projectile(Projectile *p, int t) {
|
|||
}
|
||||
|
||||
int marisa_star_slave(Enemy *e, int t) {
|
||||
double focus = abs(global.plr.focus)/30.0;
|
||||
double focus = global.plr.focus/30.0;
|
||||
|
||||
if(global.plr.fire && global.frames - global.plr.recovery >= 0 && global.plr.deathtime >= -1) {
|
||||
if(global.plr.inputflags & INFLAG_SHOT && global.frames - global.plr.recovery >= 0 && global.plr.deathtime >= -1) {
|
||||
if(!(global.frames % 20))
|
||||
create_projectile_p(&global.projs, get_tex("proj/maristar"), e->pos, 0, MariStar, marisa_star_projectile, e->args[1] * 2 * (1 - 1.5 * focus), e->args[2], 0, 0)->type = PlrProj+e->args[3]*20;
|
||||
}
|
||||
|
@ -467,7 +466,7 @@ int marisa_star_orbit(Projectile *p, int t) { // a[0]: x' a[1]: x''
|
|||
// Generic Marisa
|
||||
|
||||
void marisa_shot(Player *plr) {
|
||||
if(plr->fire) {
|
||||
if(plr->inputflags & INFLAG_SHOT) {
|
||||
if(!(global.frames % 4))
|
||||
play_sound("generic_shot");
|
||||
|
||||
|
|
21
src/replay.c
21
src/replay.c
|
@ -45,13 +45,13 @@ ReplayStage* replay_create_stage(Replay *rpy, StageInfo *stage, uint64_t seed, D
|
|||
s->plr_pos_y = floor(cimag(plr->pos));
|
||||
|
||||
s->plr_focus = plr->focus;
|
||||
s->plr_fire = plr->fire;
|
||||
s->plr_fire = !!(plr->inputflags & INFLAG_SHOT); // legacy, please remove in next struct version
|
||||
s->plr_char = plr->cha;
|
||||
s->plr_shot = plr->shot;
|
||||
s->plr_lifes = plr->lifes;
|
||||
s->plr_bombs = plr->bombs;
|
||||
s->plr_power = plr->power;
|
||||
s->plr_moveflags = plr->moveflags;
|
||||
s->plr_inputflags = plr->inputflags;
|
||||
|
||||
printf("replay_init_stage(): created a new stage for writting\n");
|
||||
return s;
|
||||
|
@ -63,11 +63,14 @@ void replay_stage_sync_player_state(ReplayStage *stg, Player *plr) {
|
|||
plr->cha = stg->plr_char;
|
||||
plr->pos = stg->plr_pos_x + I * stg->plr_pos_y;
|
||||
plr->focus = stg->plr_focus;
|
||||
plr->fire = stg->plr_fire;
|
||||
plr->lifes = stg->plr_lifes;
|
||||
plr->bombs = stg->plr_bombs;
|
||||
plr->power = stg->plr_power;
|
||||
plr->moveflags = stg->plr_moveflags;
|
||||
plr->inputflags = stg->plr_inputflags;
|
||||
|
||||
// legacy, please remove in next struct version
|
||||
if(stg->plr_fire)
|
||||
plr->inputflags |= INFLAG_SHOT;
|
||||
}
|
||||
|
||||
static void replay_destroy_stage(ReplayStage *stage) {
|
||||
|
@ -156,11 +159,11 @@ static uint32_t replay_calc_stageinfo_checksum(ReplayStage *stg) {
|
|||
cs += stg->plr_pos_x;
|
||||
cs += stg->plr_pos_y;
|
||||
cs += stg->plr_focus;
|
||||
cs += stg->plr_fire;
|
||||
cs += stg->plr_fire; // legacy, please remove in next struct version
|
||||
cs += stg->plr_power;
|
||||
cs += stg->plr_lifes;
|
||||
cs += stg->plr_bombs;
|
||||
cs += stg->plr_moveflags;
|
||||
cs += stg->plr_inputflags;
|
||||
cs += stg->numevents;
|
||||
return cs;
|
||||
}
|
||||
|
@ -175,11 +178,11 @@ static int replay_write_stage(ReplayStage *stg, SDL_RWops *file) {
|
|||
SDL_WriteLE16(file, stg->plr_pos_x);
|
||||
SDL_WriteLE16(file, stg->plr_pos_y);
|
||||
SDL_WriteU8(file, stg->plr_focus);
|
||||
SDL_WriteU8(file, stg->plr_fire);
|
||||
SDL_WriteU8(file, stg->plr_fire); // legacy, please remove in next struct version
|
||||
SDL_WriteLE16(file, stg->plr_power);
|
||||
SDL_WriteU8(file, stg->plr_lifes);
|
||||
SDL_WriteU8(file, stg->plr_bombs);
|
||||
SDL_WriteU8(file, stg->plr_moveflags);
|
||||
SDL_WriteU8(file, stg->plr_inputflags);
|
||||
SDL_WriteLE16(file, stg->numevents);
|
||||
SDL_WriteLE32(file, 1 + ~replay_calc_stageinfo_checksum(stg));
|
||||
|
||||
|
@ -328,7 +331,7 @@ static int replay_read_meta(Replay *rpy, SDL_RWops *file, int64_t filesize) {
|
|||
CHECKPROP(stg->plr_power = SDL_ReadLE16(file), u);
|
||||
CHECKPROP(stg->plr_lifes = SDL_ReadU8(file), u);
|
||||
CHECKPROP(stg->plr_bombs = SDL_ReadU8(file), u);
|
||||
CHECKPROP(stg->plr_moveflags = SDL_ReadU8(file), u);
|
||||
CHECKPROP(stg->plr_inputflags = SDL_ReadU8(file), u);
|
||||
CHECKPROP(stg->numevents = SDL_ReadLE16(file), u);
|
||||
|
||||
if(replay_calc_stageinfo_checksum(stg) + SDL_ReadLE32(file)) {
|
||||
|
|
|
@ -67,11 +67,11 @@ typedef struct ReplayStage {
|
|||
uint16_t plr_pos_x;
|
||||
uint16_t plr_pos_y;
|
||||
uint8_t plr_focus;
|
||||
uint8_t plr_fire;
|
||||
uint8_t plr_fire; // legacy, please remove in next struct version
|
||||
uint16_t plr_power;
|
||||
uint8_t plr_lifes;
|
||||
uint8_t plr_bombs;
|
||||
uint8_t plr_moveflags;
|
||||
uint8_t plr_inputflags;
|
||||
|
||||
// player input
|
||||
uint16_t numevents;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue