fix: en alguns casos no podies tornar a unirte a la partida

This commit is contained in:
2025-12-17 18:16:46 +01:00
parent 461eaedecf
commit 2555157bd7

View File

@@ -226,18 +226,39 @@ void EscenaJoc::actualitzar(float delta_time) {
} }
} }
// [NEW] Allow mid-game join: inactive player presses START // [FIXED] Allow mid-game join: inactive or dead player presses START
// P2 can join if only P1 is active // Only during PLAYING state (not INIT_HUD, CONTINUE, GAME_OVER)
if (config_partida_.jugador1_actiu && !config_partida_.jugador2_actiu) { if (stage_manager_->get_estat() == StageSystem::EstatStage::PLAYING) {
if (input->checkActionPlayer2(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) { // Check if at least one player is alive and playing (game in progress)
unir_jugador(1); bool algun_jugador_viu = false;
if (config_partida_.jugador1_actiu && itocado_per_jugador_[0] != 999.0f) {
algun_jugador_viu = true;
}
if (config_partida_.jugador2_actiu && itocado_per_jugador_[1] != 999.0f) {
algun_jugador_viu = true;
} }
}
// P1 can join if only P2 is active // Only allow join if there's an active game
if (!config_partida_.jugador1_actiu && config_partida_.jugador2_actiu) { if (algun_jugador_viu) {
if (input->checkActionPlayer1(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) { // P2 can join if not currently playing (never joined OR dead without lives)
unir_jugador(0); bool p2_no_juga = !config_partida_.jugador2_actiu || // Never joined
itocado_per_jugador_[1] == 999.0f; // Dead without lives
if (p2_no_juga) {
if (input->checkActionPlayer2(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) {
unir_jugador(1);
}
}
// P1 can join if not currently playing (never joined OR dead without lives)
bool p1_no_juga = !config_partida_.jugador1_actiu || // Never joined
itocado_per_jugador_[0] == 999.0f; // Dead without lives
if (p1_no_juga) {
if (input->checkActionPlayer1(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) {
unir_jugador(0);
}
}
} }
} }
} }