Skip to content

Commit 3aa808a

Browse files
committed
Merge branch 'debloated' into anniversary
2 parents 12f29c6 + 992c1bf commit 3aa808a

11 files changed

Lines changed: 35 additions & 21 deletions

File tree

th01/main/bonus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ void totle_animate(int stage_num)
461461
int bonus_div_10000;
462462

463463
Shots.unput_and_reset();
464-
Pellets.unput_and_reset();
464+
Pellets.unput_and_reset_nonclouds();
465465
frame_delay(50);
466466

467467
long val = 0;

th01/main/boss/b05.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ void singyoku_main(void)
782782
ent_sphere.put_8();
783783

784784
mdrv2_bgm_fade_out_nonblock();
785-
Pellets.unput_and_reset();
785+
Pellets.unput_and_reset_nonclouds();
786786
singyoku_defeat_animate_and_select_route();
787787
}
788788
}

th01/main/boss/b10j.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ void mima_main(void)
13391339
graph_accesspage_func(0);
13401340

13411341
mdrv2_bgm_fade_out_nonblock();
1342-
Pellets.unput_and_reset();
1342+
Pellets.unput_and_reset_nonclouds();
13431343
Missiles.reset();
13441344
shootout_lasers_reset();
13451345
boss_defeat_animate();

th01/main/boss/b10m.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ inline void conditionally_reset_missiles(bool cond) {
12041204
#define yuugenmagan_defeat_if(cond, reset_missiles, tmp_i) { \
12051205
if(cond) { \
12061206
mdrv2_bgm_fade_out_nonblock(); \
1207-
Pellets.unput_and_reset(); \
1207+
Pellets.unput_and_reset_nonclouds(); \
12081208
conditionally_reset_missiles(reset_missiles); \
12091209
boss_defeat_animate(); \
12101210
} \

th01/main/boss/b15j.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ void kikuri_main(void)
11371137
hit.update_and_render(flash_colors);
11381138
if(boss_hp <= 0) {
11391139
mdrv2_bgm_fade_out_nonblock();
1140-
Pellets.unput_and_reset();
1140+
Pellets.unput_and_reset_nonclouds();
11411141
shootout_lasers_reset();
11421142
boss_defeat_animate();
11431143
}

th01/main/boss/b15m.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2108,7 +2108,7 @@ void elis_main(void)
21082108
int i;
21092109

21102110
mdrv2_bgm_fade_out_nonblock();
2111-
Pellets.unput_and_reset();
2111+
Pellets.unput_and_reset_nonclouds();
21122112
girl_bg_put(1);
21132113
Missiles.reset();
21142114
shootout_lasers_reset();

th01/main/boss/b20m.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2706,7 +2706,7 @@ void sariel_main(void)
27062706
invincibility_frame = 399;
27072707

27082708
Shots.unput_and_reset();
2709-
Pellets.unput_and_reset();
2709+
Pellets.unput_and_reset_nonclouds();
27102710
shootout_lasers_reset();
27112711

27122712
// MODDERS: Move this to a common player reset function.

th01/main/bullet/pellet.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ void CPellets::add_group(
215215
Subpixel vel_x;
216216
Subpixel vel_y;
217217

218-
// Should be >=, but yeah, it's just an inconsequential oversight.
219-
if(alive_count > PELLET_COUNT) {
218+
if(alive_count >= PELLET_COUNT) {
220219
return;
221220
}
222221
if(
@@ -263,8 +262,7 @@ void CPellets::add_single(
263262
Subpixel vel_x;
264263
Subpixel vel_y;
265264

266-
// Should be >=, but yeah, it's just an inconsequential oversight.
267-
if(alive_count > PELLET_COUNT) {
265+
if(alive_count >= PELLET_COUNT) {
268266
return;
269267
}
270268
speed_set(speed_base);
@@ -591,19 +589,31 @@ void CPellets::unput_update_render(void)
591589
}
592590
}
593591

594-
void CPellets::unput_and_reset(void)
592+
void CPellets::unput_and_reset_nonclouds(void)
595593
{
596594
p = iteration_start();
597595
for(int i = 0; i < PELLET_COUNT; i++, p++) {
596+
// ZUN quirk: This condition skips the reset for active delay clouds,
597+
// i.e., pellets where (([moving] == false) && ([cloud_frame] > 0)).
598+
// These continue their delay animation after this function and
599+
// eventually turn into regular pellets. In most cases, that doesn't
600+
// matter because this is the final pellet-related method to be called
601+
// before the process restarts, but it does make a difference in
602+
// exactly two places:
603+
//
604+
// • The "TAMA DEL" command on the debug screen
605+
// • Sariel's second form, where this is the exact reason why some
606+
// pellets are carried over from the first to the second form
598607
if(!p->moving) {
599608
continue;
600609
}
610+
601611
p_sloppy_wide_unput_at_cur_pos();
602612
p->decay_frame = 0;
603613
p->moving = false;
604614
p->cloud_frame = 0;
615+
alive_count--;
605616
}
606-
alive_count = 0;
607617
}
608618

609619
void CPellets::decay(void)
@@ -620,18 +630,20 @@ void CPellets::decay(void)
620630
}
621631
}
622632

623-
void CPellets::reset(void)
633+
void CPellets::reset_nonclouds(void)
624634
{
625635
p = iteration_start();
626636
for(int i = 0; i < PELLET_COUNT; i++, p++) {
637+
// ZUN quirk: Same as in unput_and_reset_nonclouds().
627638
if(!p->moving) {
628639
continue;
629640
}
641+
630642
p->moving = false;
631643
p->decay_frame = 0;
632644
p->cloud_frame = 0;
645+
alive_count--;
633646
}
634-
alive_count = 0;
635647
}
636648

637649
bool CPellets::hittest_player_for_cur(void)

th01/main/bullet/pellet.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ struct Pellet {
143143

144144
class CPellets {
145145
Pellet near pellets[PELLET_COUNT];
146-
int alive_count; // only used for one single optimization
146+
147+
// Actually a reliable counter on this branch, unlike on `master`.
148+
int alive_count;
147149

148150
public:
149151
// Rendering pellets at odd or even indices this frame?
@@ -215,8 +217,8 @@ class CPellets {
215217
// Also calls Shots.unput_update_render()!
216218
void unput_update_render(void);
217219

218-
void unput_and_reset(void);
219-
void reset(void);
220+
void unput_and_reset_nonclouds(void);
221+
void reset_nonclouds(void);
220222
};
221223

222224
/// Globals

th01/main/debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void debug_mem(void)
100100
}
101101
recurse();
102102
} else if(input_up) {
103-
Pellets.unput_and_reset();
103+
Pellets.unput_and_reset_nonclouds();
104104
recurse();
105105
} else if(input_down) {
106106
recurse();

0 commit comments

Comments
 (0)