diff --git a/src/samples/ghhb_game.h b/src/samples/ghhb_game.h index b488740..aa6422a 100644 --- a/src/samples/ghhb_game.h +++ b/src/samples/ghhb_game.h @@ -311,6 +311,7 @@ public: std::unordered_set missed_notes; std::vector pending_sounds; std::vector active_sustained; + bool instrument_has_hits[MAX_INSTRUMENT_TYPES] = {false}; float song_time = 0.0f; float chart_time_offset = 0.0f; int score = 0; @@ -351,6 +352,10 @@ public: missed_notes.clear(); pending_sounds.clear(); active_sustained.clear(); + for (int i = 0; i < MAX_INSTRUMENT_TYPES; i++) + { + instrument_has_hits[i] = false; + } for (int i = 0; i < LANE_COUNT; i++) { press_flash_timer[i] = 0.0f; @@ -536,7 +541,7 @@ public: return bottom_y >= upper_bar_y - HIT_ZONE_MARGIN && bottom_y <= hit_line_y + HIT_ZONE_MARGIN; } - void consume_note(Glyph* n) + void consume_note(Glyph* n, bool is_player_input = false) { auto it = std::find_if(spawned.begin(), spawned.end(), [n](Glyph* p) { return p == n; }); if (it != spawned.end()) @@ -568,6 +573,17 @@ public: } combo++; score += 100 + std::min(combo * 10, 50); + // Only mark as "has hits" if this was actual player input + if (is_player_input) + { + if (!instrument_has_hits[n->instrument_slot]) + { + TraceLog(LOG_INFO, "Marking instrument %d as actively played (PHYSICAL_GP=%d)", + n->instrument_slot, INSTRUMENT_PHYSICAL_GAMEPAD[n->instrument_slot]); + } + instrument_has_hits[n->instrument_slot] = true; + } + TraceLog(LOG_INFO, "COMBO++ -> %d (lane %d, inst %d, player_input=%d)", combo, n->lane, n->instrument_slot, is_player_input); } void update_layout() @@ -692,12 +708,19 @@ public: continue; if (missed_notes.count(n) != 0) continue; - if (is_instrument_auto_played(n->instrument_slot)) + bool is_auto = is_instrument_auto_played(n->instrument_slot); + if (is_auto) + continue; + // Only reset combo for instruments that the player is actively playing + bool has_hits = instrument_has_hits[n->instrument_slot]; + if (!has_hits) continue; float bottom_y = glyph_bottom_y(*n); if (bottom_y > hit_line_y + HIT_ZONE_MARGIN) { missed_notes.insert(n); + TraceLog(LOG_WARNING, "COMBO RESET -> 0 (missed note: lane %d, inst %d, is_auto=%d, has_hits=%d, PHYSICAL_GP[%d]=%d)", + n->lane, n->instrument_slot, is_auto, has_hits, n->instrument_slot, INSTRUMENT_PHYSICAL_GAMEPAD[n->instrument_slot]); combo = 0; } } @@ -779,10 +802,11 @@ public: } if (best != nullptr && pressed) { - consume_note(best); + consume_note(best, true); // Player input } else { + TraceLog(LOG_WARNING, "COMBO RESET -> 0 (lane %d pressed but no valid note found)", lane); combo = 0; score = std::max(0, score - 25); }