passant linters a vore si trobe variables sense inicialitzar

This commit is contained in:
2025-08-17 00:23:59 +02:00
parent ada5025c65
commit 327987447d
55 changed files with 516 additions and 474 deletions

View File

@@ -27,8 +27,8 @@ Fade::~Fade() {
// Inicializa las variables
void Fade::init() {
type_ = FadeType::CENTER;
mode_ = FadeMode::OUT;
type_ = Type::CENTER;
mode_ = Mode::OUT;
counter_ = 0;
r_ = 0;
g_ = 0;
@@ -46,13 +46,13 @@ void Fade::init() {
// Resetea algunas variables para volver a hacer el fade sin perder ciertos parametros
void Fade::reset() {
state_ = FadeState::NOT_ENABLED;
state_ = State::NOT_ENABLED;
counter_ = 0;
}
// Pinta una transición en pantalla
void Fade::render() {
if (state_ != FadeState::NOT_ENABLED) {
if (state_ != State::NOT_ENABLED) {
SDL_RenderTexture(renderer_, backbuffer_, nullptr, nullptr);
}
}
@@ -60,13 +60,13 @@ void Fade::render() {
// Actualiza las variables internas
void Fade::update() {
switch (state_) {
case FadeState::PRE:
case State::PRE:
updatePreState();
break;
case FadeState::FADING:
case State::FADING:
updateFadingState();
break;
case FadeState::POST:
case State::POST:
updatePostState();
break;
default:
@@ -76,7 +76,7 @@ void Fade::update() {
void Fade::updatePreState() {
if (pre_counter_ == pre_duration_) {
state_ = FadeState::FADING;
state_ = State::FADING;
} else {
pre_counter_++;
}
@@ -84,16 +84,16 @@ void Fade::updatePreState() {
void Fade::updateFadingState() {
switch (type_) {
case FadeType::FULLSCREEN:
case Type::FULLSCREEN:
updateFullscreenFade();
break;
case FadeType::CENTER:
case Type::CENTER:
updateCenterFade();
break;
case FadeType::RANDOM_SQUARE:
case Type::RANDOM_SQUARE:
updateRandomSquareFade();
break;
case FadeType::VENETIAN:
case Type::VENETIAN:
updateVenetianFade();
break;
default:
@@ -104,7 +104,7 @@ void Fade::updateFadingState() {
void Fade::updatePostState() {
if (post_counter_ == post_duration_) {
state_ = FadeState::FINISHED;
state_ = State::FINISHED;
} else {
post_counter_++;
}
@@ -113,12 +113,12 @@ void Fade::updatePostState() {
void Fade::updateFullscreenFade() {
// Modifica la transparencia
a_ = mode_ == FadeMode::OUT ? std::min(counter_ * 4, 255) : 255 - std::min(counter_ * 4, 255);
a_ = mode_ == Mode::OUT ? std::min(counter_ * 4, 255) : 255 - std::min(counter_ * 4, 255);
SDL_SetTextureAlphaMod(backbuffer_, a_);
// Comprueba si ha terminado
if (counter_ >= 255 / 4) {
state_ = FadeState::POST;
state_ = State::POST;
}
}
@@ -127,7 +127,7 @@ void Fade::updateCenterFade() {
// Comprueba si ha terminado
if ((counter_ * 4) > param.game.height) {
state_ = FadeState::POST;
state_ = State::POST;
a_ = 255;
}
}
@@ -160,7 +160,7 @@ void Fade::updateRandomSquareFade() {
// Comprueba si ha terminado
if (counter_ * fade_random_squares_mult_ / fade_random_squares_delay_ >=
num_squares_width_ * num_squares_height_) {
state_ = FadeState::POST;
state_ = State::POST;
}
}
@@ -192,7 +192,7 @@ void Fade::updateVenetianFade() {
updateVenetianRectangles();
calculateVenetianProgress();
} else {
state_ = FadeState::POST;
state_ = State::POST;
}
}
@@ -233,30 +233,30 @@ void Fade::calculateVenetianProgress() {
// Activa el fade
void Fade::activate() {
// Si ya está habilitado, no hay que volverlo a activar
if (state_ != FadeState::NOT_ENABLED) {
if (state_ != State::NOT_ENABLED) {
return;
}
state_ = FadeState::PRE;
state_ = State::PRE;
counter_ = 0;
post_counter_ = 0;
pre_counter_ = 0;
switch (type_) {
case FadeType::FULLSCREEN: {
case Type::FULLSCREEN: {
// Pinta el backbuffer_ de color sólido
cleanBackbuffer(r_, g_, b_, 255);
break;
}
case FadeType::CENTER: {
case Type::CENTER: {
rect1_ = {0, 0, param.game.width, 0};
rect2_ = {0, 0, param.game.width, 0};
a_ = 64;
break;
}
case FadeType::RANDOM_SQUARE: {
case Type::RANDOM_SQUARE: {
rect1_ = {0, 0, static_cast<float>(param.game.width / num_squares_width_), static_cast<float>(param.game.height / num_squares_height_)};
square_.clear();
@@ -278,22 +278,22 @@ void Fade::activate() {
}
// Limpia la textura
a_ = mode_ == FadeMode::OUT ? 0 : 255;
a_ = mode_ == Mode::OUT ? 0 : 255;
cleanBackbuffer(r_, g_, b_, a_);
// Deja el color listo para usar
a_ = mode_ == FadeMode::OUT ? 255 : 0;
a_ = mode_ == Mode::OUT ? 255 : 0;
break;
}
case FadeType::VENETIAN: {
case Type::VENETIAN: {
// Limpia la textura
a_ = mode_ == FadeMode::OUT ? 0 : 255;
a_ = mode_ == Mode::OUT ? 0 : 255;
cleanBackbuffer(r_, g_, b_, a_);
// Deja el color listo para usar
a_ = mode_ == FadeMode::OUT ? 255 : 0;
a_ = mode_ == Mode::OUT ? 255 : 0;
// Añade los cuadrados al vector
square_.clear();