fix: arrancar amb el borde desactivat feia crash al activarlo
This commit is contained in:
@@ -295,16 +295,16 @@ void Screen::adjustWindowSize() {
|
||||
window_width_ = Options::game.width + (Options::video.border.enabled ? Options::video.border.width * 2 : 0);
|
||||
window_height_ = Options::game.height + (Options::video.border.enabled ? Options::video.border.height * 2 : 0);
|
||||
|
||||
// Reservamos memoria una sola vez.
|
||||
// Si el buffer es más pequeño que la superficie, crash asegurado.
|
||||
border_pixel_buffer_.resize(static_cast<size_t>(window_width_ * window_height_));
|
||||
// border_surface_ sempre té el tamany complet del borde (game + 2*border_w/h),
|
||||
// independentment de si el borde està visible o no. El buffer ARGB que l'ombra
|
||||
// ha de ser ALMENYS tan gran com la surface; si no, toARGBBuffer() escriu fora
|
||||
// de bounds i corromp el heap (bug latent a desktop fins a disparar-lo un toggleBorder).
|
||||
const size_t FULL_BORDER_BUFFER_SIZE =
|
||||
static_cast<size_t>(Options::game.width + (Options::video.border.width * 2)) *
|
||||
static_cast<size_t>(Options::game.height + (Options::video.border.height * 2));
|
||||
border_pixel_buffer_.resize(FULL_BORDER_BUFFER_SIZE);
|
||||
game_pixel_buffer_.resize(static_cast<size_t>(Options::game.width * Options::game.height));
|
||||
|
||||
// border_pixel_buffer_ es el buffer que se sube a la GPU (tamaño total ventana).
|
||||
if (Options::video.border.enabled) {
|
||||
border_pixel_buffer_.resize(static_cast<size_t>(window_width_ * window_height_));
|
||||
}
|
||||
|
||||
// Lógica de centrado y redimensionado de ventana SDL
|
||||
if (static_cast<int>(Options::video.fullscreen) == 0) {
|
||||
int old_w;
|
||||
|
||||
Reference in New Issue
Block a user