From 4bad77cdf01b6be499b17fb27d78fa27f31d53f3 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 18 Jan 2018 18:44:35 +0000 Subject: [PATCH] Use new/delete for Viewport info struct --- src/viewport.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/viewport.cpp b/src/viewport.cpp index bd8cf399b7..f8b64ac85d 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -300,7 +300,7 @@ void DeleteWindowViewport(Window *w) container_unordered_remove(_viewport_window_cache, w->viewport); delete w->viewport->overlay; - free(w->viewport); + delete w->viewport; w->viewport = NULL; } @@ -321,8 +321,9 @@ void InitializeWindowViewport(Window *w, int x, int y, { assert(w->viewport == NULL); - ViewportData *vp = CallocT(1); + ViewportData *vp = new ViewportData(); + vp->overlay = NULL; vp->left = x + w->left; vp->top = y + w->top; vp->width = width; @@ -330,9 +331,13 @@ void InitializeWindowViewport(Window *w, int x, int y, vp->zoom = static_cast(Clamp(zoom, _settings_client.gui.zoom_min, _settings_client.gui.zoom_max)); + vp->virtual_left = 0; + vp->virtual_top = 0; vp->virtual_width = ScaleByZoom(width, zoom); vp->virtual_height = ScaleByZoom(height, zoom); + vp->map_type = VPMT_BEGIN; + Point pt; if (follow_flags & 0x80000000) { @@ -356,11 +361,7 @@ void InitializeWindowViewport(Window *w, int x, int y, vp->dest_scrollpos_x = pt.x; vp->dest_scrollpos_y = pt.y; - vp->overlay = NULL; - w->viewport = vp; - vp->virtual_left = 0; // pt.x; - vp->virtual_top = 0; // pt.y; _viewport_window_cache.push_back(vp); }