fix: en alguns casos no podies tornar a unirte a la partida
This commit is contained in:
@@ -226,18 +226,39 @@ void EscenaJoc::actualitzar(float delta_time) {
|
||||
}
|
||||
}
|
||||
|
||||
// [NEW] Allow mid-game join: inactive player presses START
|
||||
// P2 can join if only P1 is active
|
||||
if (config_partida_.jugador1_actiu && !config_partida_.jugador2_actiu) {
|
||||
if (input->checkActionPlayer2(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
unir_jugador(1);
|
||||
// [FIXED] Allow mid-game join: inactive or dead player presses START
|
||||
// Only during PLAYING state (not INIT_HUD, CONTINUE, GAME_OVER)
|
||||
if (stage_manager_->get_estat() == StageSystem::EstatStage::PLAYING) {
|
||||
// Check if at least one player is alive and playing (game in progress)
|
||||
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
|
||||
if (!config_partida_.jugador1_actiu && config_partida_.jugador2_actiu) {
|
||||
if (input->checkActionPlayer1(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
unir_jugador(0);
|
||||
// Only allow join if there's an active game
|
||||
if (algun_jugador_viu) {
|
||||
// P2 can join if not currently playing (never joined OR dead without lives)
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user