Codechange: use RAII to automatically restore _cur_dpi after use

This commit is contained in:
Rubidium
2023-01-26 19:21:36 +01:00
committed by rubidium42
parent b7a5d8e296
commit f001e84e5e
18 changed files with 122 additions and 136 deletions

View File

@@ -8,6 +8,7 @@
/** @file smallmap_gui.cpp GUI that shows a small map of the world with metadata like owner or height. */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "clear_map.h"
#include "industry.h"
#include "station_map.h"
@@ -973,10 +974,7 @@ void SmallMapWindow::DrawMapIndicators() const
void SmallMapWindow::DrawSmallMap(DrawPixelInfo *dpi) const
{
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
DrawPixelInfo *old_dpi;
old_dpi = _cur_dpi;
_cur_dpi = dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, dpi);
/* Clear it */
GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, PC_BLACK);
@@ -1027,8 +1025,6 @@ void SmallMapWindow::DrawSmallMap(DrawPixelInfo *dpi) const
/* Draw map indicators */
this->DrawMapIndicators();
_cur_dpi = old_dpi;
}
/**