Skip to content

Commit c6bd7f8

Browse files
authored
Don't treat two different consecutive flashes as repeating (#84)
Caused by not comparing the previous frame's flash parameters during the repeating flash check. The issue can be reproduced in maps with parallel flash+wait by using a flashing effect action like the rat form toggle in Collective Unconscious or rainbow/fairy in Yume 2kki. The effect action triggers the repeating flash condition, even though the two flashes have different parameters. Examples of affected maps: - Yume 2kki: MAP0160 (Monochrome Street) - Yume 2kki: MAP0703 (Florist) - Yume 2kki: MAP3594 (Firefly Lake) - Collective Unconscious: MAP1407 (Forest) Regression introduced in a545830.
1 parent 0df1701 commit c6bd7f8

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/multiplayer/game_multiplayer.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ static bool MovePlayerToPos(Game_PlayerOther& player, int x, int y) {
112112
}
113113

114114
void Game_Multiplayer::ResetRepeatingFlash() {
115+
repeating_flash_active = false;
115116
frame_index = 0;
116117
last_flash_frame_index = -1;
117-
last_frame_flash.reset();
118+
last_flash_frame_flash.fill(0);
118119
repeating_flashes.clear();
119120
}
120121

@@ -572,16 +573,16 @@ void Game_Multiplayer::MainPlayerFlashed(int r, int g, int b, int p, int f) {
572573
std::array<int, 5> flash_array = std::array<int, 5>{ r, g, b, p, f };
573574
if (last_flash_frame_index > -1
574575
&& frame_index - last_flash_frame_index <= 1
575-
&& (last_frame_flash.get() == nullptr || *last_frame_flash == flash_array)) {
576-
if (last_frame_flash.get() == nullptr) {
577-
last_frame_flash = std::make_unique<std::array<int, 5>>(flash_array);
576+
&& last_flash_frame_flash == flash_array) {
577+
if (!repeating_flash_active) {
578+
repeating_flash_active = true;
578579
connection.SendPacketAsync<RepeatingFlashPacket>(r, g, b, p, f);
579580
}
580581
} else {
581582
connection.SendPacketAsync<FlashPacket>(r, g, b, p, f);
582-
last_frame_flash.reset();
583583
}
584584
last_flash_frame_index = frame_index;
585+
last_flash_frame_flash = flash_array;
585586
}
586587

587588
void Game_Multiplayer::MainPlayerChangedTransparency(int transparency) {
@@ -780,12 +781,11 @@ void Game_Multiplayer::ApplyScreenTone() {
780781

781782
void Game_Multiplayer::Update() {
782783
if (session_active) {
783-
if (last_flash_frame_index > -1
784-
&& last_frame_flash.get() != nullptr
785-
&& frame_index > last_flash_frame_index) {
784+
if (repeating_flash_active && frame_index > last_flash_frame_index) {
786785
connection.SendPacketAsync<RemoveRepeatingFlashPacket>();
786+
repeating_flash_active = false;
787787
last_flash_frame_index = -1;
788-
last_frame_flash.reset();
788+
last_flash_frame_flash.fill(0);
789789
}
790790

791791
++frame_index;

src/multiplayer/game_multiplayer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ class Game_Multiplayer {
8989
std::vector<std::string> global_sync_picture_prefixes;
9090
std::map<int, bool> sync_picture_cache;
9191
std::vector<int> sync_battle_anim_ids;
92+
bool repeating_flash_active;
9293
int last_flash_frame_index{-1};
93-
std::unique_ptr<std::array<int, 5>> last_frame_flash;
94+
std::array<int, 5> last_flash_frame_flash;
9495
std::map<int, std::array<int, 5>> repeating_flashes;
9596

9697
int cu_randint;

0 commit comments

Comments
 (0)