make benchmark spell appear last; account for extra stage in the spellstage system

This commit is contained in:
Andrei Alexeyev 2018-01-21 12:35:48 +02:00
parent 7f6399ab2b
commit e11e229b72
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
6 changed files with 30 additions and 22 deletions

View file

@ -61,7 +61,7 @@ typedef struct AttackInfo {
Doing so is going to break replays, progress files, and anything that stores stage IDs permanently.
Stage IDs are an internal detail invisible to the player, so they don't need to have any kind of fancy ordering.
*/
signed char idmap[NUM_SELECTABLE_DIFFICULTIES];
signed char idmap[NUM_SELECTABLE_DIFFICULTIES + 1];
AttackType type;
char *name;

View file

@ -34,7 +34,7 @@ void create_spell_menu(MenuData *m) {
continue;
}
if(stg->difficulty < lastdiff) {
if(stg->difficulty < lastdiff || (stg->difficulty == D_Extra && lastdiff != D_Extra)) {
add_menu_separator(m);
}

View file

@ -32,7 +32,7 @@ void create_stage_menu(MenuData *m) {
m->transition = TransMenuDark;
for(int i = 0; stages[i].procs; ++i) {
if(stages[i].difficulty < lastdiff || (stages[i].difficulty && !lastdiff)) {
if(stages[i].difficulty < lastdiff || (stages[i].difficulty == D_Extra && lastdiff != D_Extra) || (stages[i].difficulty && !lastdiff)) {
add_menu_separator(m);
}

View file

@ -48,6 +48,18 @@ static void end_stages(void) {
add_stage(0, NULL, 0, NULL, NULL, NULL, 0);
}
static void add_spellpractice_stage(StageInfo *s, AttackInfo *a, int *spellnum, uint16_t spellbits, Difficulty diff) {
uint16_t id = spellbits | a->idmap[diff - D_Easy] | (s->id << 8);
char *title = strfmt("Spell %d", ++(*spellnum));
char *subtitle = strjoin(a->name, " ~ ", difficulty_name(diff), NULL);
add_stage(id, s->procs->spellpractice_procs, STAGE_SPELL, title, subtitle, a, diff);
free(title);
free(subtitle);
}
static void add_spellpractice_stages(int *spellnum, bool (*filter)(AttackInfo*), uint16_t spellbits) {
for(int i = 0 ;; ++i) {
StageInfo *s = stages + i;
@ -63,16 +75,8 @@ static void add_spellpractice_stages(int *spellnum, bool (*filter)(AttackInfo*),
for(Difficulty diff = D_Easy; diff < D_Easy + NUM_SELECTABLE_DIFFICULTIES; ++diff) {
if(a->idmap[diff - D_Easy] >= 0) {
uint16_t id = spellbits | a->idmap[diff - D_Easy] | (s->id << 8);
char *title = strfmt("Spell %d", ++(*spellnum));
char *subtitle = strjoin(a->name, " ~ ", difficulty_name(diff), NULL);
add_stage(id, s->procs->spellpractice_procs, STAGE_SPELL, title, subtitle, a, diff);
add_spellpractice_stage(s, a, spellnum, spellbits, diff);
s = stages + i; // stages just got realloc'd, so we must update the pointer
free(title);
free(subtitle);
}
}
}
@ -90,7 +94,7 @@ static bool spellfilter_extra(AttackInfo *spell) {
void stage_init_array(void) {
int spellnum = 0;
// id procs type title subtitle spells diff
// id procs type title subtitle spells diff
add_stage(1, &stage1_procs, STAGE_STORY, "Stage 1", "Misty Lake", (AttackInfo*)&stage1_spells, D_Any);
add_stage(2, &stage2_procs, STAGE_STORY, "Stage 2", "Walk Along the Border", (AttackInfo*)&stage2_spells, D_Any);
add_stage(3, &stage3_procs, STAGE_STORY, "Stage 3", "Through the Tunnel of Light", (AttackInfo*)&stage3_spells, D_Any);
@ -102,6 +106,10 @@ void stage_init_array(void) {
add_spellpractice_stages(&spellnum, spellfilter_normal, STAGE_SPELL_BIT);
add_spellpractice_stages(&spellnum, spellfilter_extra, STAGE_SPELL_BIT | STAGE_EXTRASPELL_BIT);
#ifdef SPELL_BENCHMARK
add_spellpractice_stage(stages, &stage1_spell_benchmark, &spellnum, STAGE_SPELL_BIT, D_Extra);
#endif
end_stages();
#ifdef DEBUG

View file

@ -48,14 +48,14 @@ struct stage1_spells_s stage1_spells = {
{ 0, 1, 2, 3}, AT_ExtraSpell, "Frost Sign ~ Crystal Blizzard", 60, 40000,
cirno_crystal_blizzard, cirno_pfreeze_bg, VIEWPORT_W/2.0+100.0*I
},
};
#ifdef SPELL_BENCHMARK
.benchmark = {
{-1, -1, -1, 127}, AT_SurvivalSpell, "Profiling ~ ベンチマーク", 40, 40000,
cirno_benchmark, cirno_pfreeze_bg, VIEWPORT_W/2.0+100.0*I
},
#endif
AttackInfo stage1_spell_benchmark = {
{-1, -1, -1, -1, 127}, AT_SurvivalSpell, "Profiling ~ ベンチマーク", 40, 40000,
cirno_benchmark, cirno_pfreeze_bg, VIEWPORT_W/2.0+100.0*I
};
#endif
static bool particle_filter(Projectile *part) {
return !(part->flags & PFLAG_NOREFLECT) && stage_should_draw_particle(part);

View file

@ -33,13 +33,13 @@ extern struct stage1_spells_s {
AttackInfo crystal_blizzard;
} extra;
#ifdef SPELL_BENCHMARK
AttackInfo benchmark;
#endif
// required for iteration
AttackInfo null;
} stage1_spells;
extern StageProcs stage1_procs;
extern StageProcs stage1_spell_procs;
#ifdef SPELL_BENCHMARK
AttackInfo stage1_spell_benchmark;
#endif