Codechange: use RAII to automatically restore _cur_dpi after use
This commit is contained in:
@@ -61,6 +61,7 @@
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "core/backup_type.hpp"
|
||||
#include "landscape.h"
|
||||
#include "viewport_func.h"
|
||||
#include "station_base.h"
|
||||
@@ -1726,9 +1727,6 @@ static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector *
|
||||
|
||||
void ViewportDoDraw(const Viewport *vp, int left, int top, int right, int bottom)
|
||||
{
|
||||
DrawPixelInfo *old_dpi = _cur_dpi;
|
||||
_cur_dpi = &_vd.dpi;
|
||||
|
||||
_vd.dpi.zoom = vp->zoom;
|
||||
int mask = ScaleByZoom(-1, vp->zoom);
|
||||
|
||||
@@ -1738,13 +1736,14 @@ void ViewportDoDraw(const Viewport *vp, int left, int top, int right, int bottom
|
||||
_vd.dpi.height = (bottom - top) & mask;
|
||||
_vd.dpi.left = left & mask;
|
||||
_vd.dpi.top = top & mask;
|
||||
_vd.dpi.pitch = old_dpi->pitch;
|
||||
_vd.dpi.pitch = _cur_dpi->pitch;
|
||||
_vd.last_child = nullptr;
|
||||
|
||||
int x = UnScaleByZoom(_vd.dpi.left - (vp->virtual_left & mask), vp->zoom) + vp->left;
|
||||
int y = UnScaleByZoom(_vd.dpi.top - (vp->virtual_top & mask), vp->zoom) + vp->top;
|
||||
|
||||
_vd.dpi.dst_ptr = BlitterFactory::GetCurrentBlitter()->MoveTo(old_dpi->dst_ptr, x - old_dpi->left, y - old_dpi->top);
|
||||
_vd.dpi.dst_ptr = BlitterFactory::GetCurrentBlitter()->MoveTo(_cur_dpi->dst_ptr, x - _cur_dpi->left, y - _cur_dpi->top);
|
||||
AutoRestoreBackup dpi_backup(_cur_dpi, &_vd.dpi);
|
||||
|
||||
ViewportAddLandscape();
|
||||
ViewportAddVehicles(&_vd.dpi);
|
||||
@@ -1786,8 +1785,6 @@ void ViewportDoDraw(const Viewport *vp, int left, int top, int right, int bottom
|
||||
ViewportDrawStrings(zoom, &_vd.string_sprites_to_draw);
|
||||
}
|
||||
|
||||
_cur_dpi = old_dpi;
|
||||
|
||||
_vd.string_sprites_to_draw.clear();
|
||||
_vd.tile_sprites_to_draw.clear();
|
||||
_vd.parent_sprites_to_draw.clear();
|
||||
|
Reference in New Issue
Block a user