summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-05-11 15:08:44 +0000
committerglx <glx@openttd.org>2008-05-11 15:08:44 +0000
commitc708ab3b486a2ecf1f163c900ff71fd46764bdfa (patch)
treedfb592610399f3c49e4292af8aacfd992b50d368
parentc47926311b5f90086f0c7a44c30f3455748d524c (diff)
downloadopenttd-c708ab3b486a2ecf1f163c900ff71fd46764bdfa.tar.xz
(svn r13047) -Codechange: remove vp_d
-rw-r--r--src/industry_gui.cpp6
-rw-r--r--src/main_gui.cpp28
-rw-r--r--src/news_gui.cpp2
-rw-r--r--src/openttd.cpp16
-rw-r--r--src/smallmap_gui.cpp40
-rw-r--r--src/vehicle.cpp4
-rw-r--r--src/vehicle_gui.cpp4
-rw-r--r--src/viewport.cpp56
-rw-r--r--src/window.cpp12
-rw-r--r--src/window_gui.h23
10 files changed, 95 insertions, 96 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index db1a93e63..5104827e7 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -433,7 +433,7 @@ enum IndustryViewWidgets {
};
/** Information to store about the industry window */
-struct indview_d : public vp_d {
+struct indview_d {
byte editbox_line; ///< The line clicked to open the edit box
byte clicked_line; ///< The line of the button that has been clicked
byte clicked_button; ///< The button that has been clicked (to raise)
@@ -601,8 +601,8 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
w->viewport->height += e->we.sizing.diff.y;
w->viewport->virtual_width += e->we.sizing.diff.x;
w->viewport->virtual_height += e->we.sizing.diff.y;
- WP(w, vp_d).dest_scrollpos_x -= e->we.sizing.diff.x;
- WP(w, vp_d).dest_scrollpos_y -= e->we.sizing.diff.y;
+ w->viewport->dest_scrollpos_x -= e->we.sizing.diff.x;
+ w->viewport->dest_scrollpos_y -= e->we.sizing.diff.y;
UpdateViewportPosition(w);
break;
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 5ad0c277f..8b4b1328d 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -166,27 +166,27 @@ bool DoZoomInOutWindow(int how, Window *w)
vp->virtual_width >>= 1;
vp->virtual_height >>= 1;
- WP(w, vp_d).scrollpos_x += vp->virtual_width >> 1;
- WP(w, vp_d).scrollpos_y += vp->virtual_height >> 1;
- WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x;
- WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
+ w->viewport->scrollpos_x += vp->virtual_width >> 1;
+ w->viewport->scrollpos_y += vp->virtual_height >> 1;
+ w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
+ w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
break;
case ZOOM_OUT:
if (vp->zoom == ZOOM_LVL_MAX) return false;
vp->zoom = (ZoomLevel)((int)vp->zoom + 1);
- WP(w, vp_d).scrollpos_x -= vp->virtual_width >> 1;
- WP(w, vp_d).scrollpos_y -= vp->virtual_height >> 1;
- WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x;
- WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
+ w->viewport->scrollpos_x -= vp->virtual_width >> 1;
+ w->viewport->scrollpos_y -= vp->virtual_height >> 1;
+ w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
+ w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
vp->virtual_width <<= 1;
vp->virtual_height <<= 1;
break;
}
if (vp != NULL) { // the vp can be null when how == ZOOM_NONE
- vp->virtual_left = WP(w, vp_d).scrollpos_x;
- vp->virtual_top = WP(w, vp_d).scrollpos_y;
+ vp->virtual_left = w->viewport->scrollpos_x;
+ vp->virtual_top = w->viewport->scrollpos_y;
}
w->SetDirty();
/* Update the windows that have zoom-buttons to perhaps disable their buttons */
@@ -380,10 +380,10 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
_scrolling_viewport = false;
}
- WP(w, vp_d).scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom);
- WP(w, vp_d).scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom);
- WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x;
- WP(w, vp_d).dest_scrollpos_y = WP(w, vp_d).scrollpos_y;
+ w->viewport->scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom);
+ w->viewport->scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom);
+ w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
+ w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
} break;
case WE_MOUSEWHEEL:
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 33b1ff236..7a9ecb289 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -60,7 +60,7 @@ static NewsID _current_news = INVALID_NEWS; ///< points to news item that should
static NewsID _oldest_news = 0; ///< points to first item in fifo queue
static NewsID _latest_news = INVALID_NEWS; ///< points to last item in fifo queue
-struct news_d : vp_d {
+struct news_d {
uint16 chat_height;
NewsItem *ni;
};
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 1f2d7c3b5..ecba066fa 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1092,8 +1092,8 @@ static void ScrollMainViewport(int x, int y)
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
assert(w);
- WP(w, vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
- WP(w, vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
+ w->viewport->dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
+ w->viewport->dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
}
}
@@ -1203,8 +1203,8 @@ void BeforeSaveGame()
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
if (w != NULL) {
- _saved_scrollpos_x = WP(w, const vp_d).scrollpos_x;
- _saved_scrollpos_y = WP(w, const vp_d).scrollpos_y;
+ _saved_scrollpos_x = w->viewport->scrollpos_x;
+ _saved_scrollpos_y = w->viewport->scrollpos_y;
_saved_scrollpos_zoom = w->viewport->zoom;
}
}
@@ -1316,10 +1316,10 @@ static bool InitializeWindowsAndCaches()
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
- WP(w, vp_d).scrollpos_x = _saved_scrollpos_x;
- WP(w, vp_d).scrollpos_y = _saved_scrollpos_y;
- WP(w, vp_d).dest_scrollpos_x = _saved_scrollpos_x;
- WP(w, vp_d).dest_scrollpos_y = _saved_scrollpos_y;
+ w->viewport->scrollpos_x = _saved_scrollpos_x;
+ w->viewport->scrollpos_y = _saved_scrollpos_y;
+ w->viewport->dest_scrollpos_x = _saved_scrollpos_x;
+ w->viewport->dest_scrollpos_y = _saved_scrollpos_y;
ViewPort *vp = w->viewport;
vp->zoom = min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 966f85fe7..1752ecbd7 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -884,8 +884,8 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e)
_left_button_clicked = false;
pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0);
- WP(w2, vp_d).dest_scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1);
- WP(w2, vp_d).dest_scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);
+ w2->viewport->dest_scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1);
+ w2->viewport->dest_scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);
w->SetDirty();
} break;
@@ -1138,21 +1138,21 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
case 7: { // location button (move main view to same spot as this view) 'Paste Location'
Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
- int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
- int y = WP(w, vp_d).scrollpos_y;
+ int x = w->viewport->scrollpos_x; // Where is the main looking at
+ int y = w->viewport->scrollpos_y;
/* set this view to same location. Based on the center, adjusting for zoom */
- WP(w2, vp_d).dest_scrollpos_x = x - (w2->viewport->virtual_width - w->viewport->virtual_width) / 2;
- WP(w2, vp_d).dest_scrollpos_y = y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
+ w2->viewport->dest_scrollpos_x = x - (w2->viewport->virtual_width - w->viewport->virtual_width) / 2;
+ w2->viewport->dest_scrollpos_y = y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
} break;
case 8: { // inverse location button (move this view to same spot as main view) 'Copy Location'
const Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
- int x = WP(w2, const vp_d).scrollpos_x;
- int y = WP(w2, const vp_d).scrollpos_y;
+ int x = w2->viewport->scrollpos_x;
+ int y = w2->viewport->scrollpos_y;
- WP(w, vp_d).dest_scrollpos_x = x + (w2->viewport->virtual_width - w->viewport->virtual_width) / 2;
- WP(w, vp_d).dest_scrollpos_y = y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
+ w->viewport->dest_scrollpos_x = x + (w2->viewport->virtual_width - w->viewport->virtual_width) / 2;
+ w->viewport->dest_scrollpos_y = y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
} break;
}
break;
@@ -1172,10 +1172,10 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
_scrolling_viewport = false;
}
- WP(w, vp_d).scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom);
- WP(w, vp_d).scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom);
- WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x;
- WP(w, vp_d).dest_scrollpos_y = WP(w, vp_d).scrollpos_y;
+ w->viewport->scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom);
+ w->viewport->scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom);
+ w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
+ w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
} break;
case WE_MOUSEWHEEL:
@@ -1213,15 +1213,15 @@ void ShowExtraViewPortWindow(TileIndex tile)
const Window *v = FindWindowById(WC_MAIN_WINDOW, 0);
/* center on same place as main window (zoom is maximum, no adjustment needed) */
- pt.x = WP(v, vp_d).scrollpos_x + v->viewport->virtual_height / 2;
- pt.y = WP(v, vp_d).scrollpos_y + v->viewport->virtual_height / 2;
+ pt.x = v->viewport->scrollpos_x + v->viewport->virtual_height / 2;
+ pt.y = v->viewport->scrollpos_y + v->viewport->virtual_height / 2;
} else {
pt = RemapCoords(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, TileHeight(tile));
}
- WP(w, vp_d).scrollpos_x = pt.x - ((w->widget[4].right - w->widget[4].left) - 1) / 2;
- WP(w, vp_d).scrollpos_y = pt.y - ((w->widget[4].bottom - w->widget[4].top) - 1) / 2;
- WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x;
- WP(w, vp_d).dest_scrollpos_y = WP(w, vp_d).scrollpos_y;
+ w->viewport->scrollpos_x = pt.x - ((w->widget[4].right - w->widget[4].left) - 1) / 2;
+ w->viewport->scrollpos_y = pt.y - ((w->widget[4].bottom - w->widget[4].top) - 1) / 2;
+ w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
+ w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
}
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 9b8325832..85e0b9762 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -591,9 +591,9 @@ void Vehicle::PreDestructor()
}
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
- if (w != NULL && WP(w, vp_d).follow_vehicle == this->index) {
+ if (w != NULL && w->viewport->follow_vehicle == this->index) {
ScrollMainWindowTo(this->x_pos, this->y_pos, true); // lock the main view on the vehicle's last position
- WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
+ w->viewport->follow_vehicle = INVALID_VEHICLE;
}
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 804679f02..4c6c3f84e 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -738,7 +738,7 @@ void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index)
if (w != NULL) {
w->window_number = to_index;
- WP(w, vp_d).follow_vehicle = to_index;
+ w->viewport->follow_vehicle = to_index;
w->SetDirty();
w = FindWindowById(WC_VEHICLE_ORDERS, from_index);
@@ -2091,7 +2091,7 @@ static void VehicleViewWndProc(Window *w, WindowEvent *e)
const Window *mainwindow = FindWindowById(WC_MAIN_WINDOW, 0);
/* code to allow the main window to 'follow' the vehicle if the ctrl key is pressed */
if (_ctrl_pressed && mainwindow->viewport->zoom == ZOOM_LVL_NORMAL) {
- WP(mainwindow, vp_d).follow_vehicle = v->index;
+ mainwindow->viewport->follow_vehicle = v->index;
} else {
ScrollMainWindowTo(v->x_pos, v->y_pos);
}
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 499adf69f..7b3d3bfdb 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -156,7 +156,7 @@ static Point MapXYZToViewport(const ViewPort *vp, uint x, uint y, uint z)
void DeleteWindowViewport(Window *w)
{
- w->viewport->width = 0;
+ free(w->viewport);
w->viewport = NULL;
}
@@ -177,7 +177,7 @@ void InitializeWindowViewport(Window *w, int x, int y,
{
assert(w->viewport == NULL);
- ViewPort *vp = &(WP(w, vp_d).vp_data);
+ ViewportData *vp = CallocT<ViewportData>(1);
vp->left = x + w->left;
vp->top = y + w->top;
@@ -194,21 +194,21 @@ void InitializeWindowViewport(Window *w, int x, int y,
if (follow_flags & 0x80000000) {
const Vehicle *veh;
- WP(w, vp_d).follow_vehicle = (VehicleID)(follow_flags & 0xFFFF);
- veh = GetVehicle(WP(w, vp_d).follow_vehicle);
+ vp->follow_vehicle = (VehicleID)(follow_flags & 0xFFFF);
+ veh = GetVehicle(vp->follow_vehicle);
pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
} else {
uint x = TileX(follow_flags) * TILE_SIZE;
uint y = TileY(follow_flags) * TILE_SIZE;
- WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
+ vp->follow_vehicle = INVALID_VEHICLE;
pt = MapXYZToViewport(vp, x, y, GetSlopeZ(x, y));
}
- WP(w, vp_d).scrollpos_x = pt.x;
- WP(w, vp_d).scrollpos_y = pt.y;
- WP(w, vp_d).dest_scrollpos_x = pt.x;
- WP(w, vp_d).dest_scrollpos_y = pt.y;
+ vp->scrollpos_x = pt.x;
+ vp->scrollpos_y = pt.y;
+ vp->dest_scrollpos_x = pt.x;
+ vp->dest_scrollpos_y = pt.y;
w->viewport = vp;
vp->virtual_left = 0;//pt.x;
@@ -426,9 +426,7 @@ Point GetTileBelowCursor()
Point GetTileZoomCenterWindow(bool in, Window * w)
{
int x, y;
- ViewPort * vp;
-
- vp = w->viewport;
+ ViewPort *vp = w->viewport;
if (in) {
x = ((_cursor.pos.x - vp->left) >> 1) + (vp->width >> 2);
@@ -1581,33 +1579,33 @@ void UpdateViewportPosition(Window *w)
{
const ViewPort *vp = w->viewport;
- if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE) {
- const Vehicle* veh = GetVehicle(WP(w, vp_d).follow_vehicle);
+ if (w->viewport->follow_vehicle != INVALID_VEHICLE) {
+ const Vehicle* veh = GetVehicle(w->viewport->follow_vehicle);
Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
SetViewportPosition(w, pt.x, pt.y);
} else {
/* Ensure the destination location is within the map */
- ClampViewportToMap(vp, WP(w, vp_d).dest_scrollpos_x, WP(w, vp_d).dest_scrollpos_y);
+ ClampViewportToMap(vp, w->viewport->dest_scrollpos_x, w->viewport->dest_scrollpos_y);
- int delta_x = WP(w, vp_d).dest_scrollpos_x - WP(w, vp_d).scrollpos_x;
- int delta_y = WP(w, vp_d).dest_scrollpos_y - WP(w, vp_d).scrollpos_y;
+ int delta_x = w->viewport->dest_scrollpos_x - w->viewport->scrollpos_x;
+ int delta_y = w->viewport->dest_scrollpos_y - w->viewport->scrollpos_y;
if (delta_x != 0 || delta_y != 0) {
if (_patches.smooth_scroll) {
int max_scroll = ScaleByMapSize1D(512);
/* Not at our desired positon yet... */
- WP(w, vp_d).scrollpos_x += Clamp(delta_x / 4, -max_scroll, max_scroll);
- WP(w, vp_d).scrollpos_y += Clamp(delta_y / 4, -max_scroll, max_scroll);
+ w->viewport->scrollpos_x += Clamp(delta_x / 4, -max_scroll, max_scroll);
+ w->viewport->scrollpos_y += Clamp(delta_y / 4, -max_scroll, max_scroll);
} else {
- WP(w, vp_d).scrollpos_x = WP(w, vp_d).dest_scrollpos_x;
- WP(w, vp_d).scrollpos_y = WP(w, vp_d).dest_scrollpos_y;
+ w->viewport->scrollpos_x = w->viewport->dest_scrollpos_x;
+ w->viewport->scrollpos_y = w->viewport->dest_scrollpos_y;
}
}
- ClampViewportToMap(vp, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y);
+ ClampViewportToMap(vp, w->viewport->scrollpos_x, w->viewport->scrollpos_y);
- SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y);
+ SetViewportPosition(w, w->viewport->scrollpos_x, w->viewport->scrollpos_y);
}
}
@@ -2066,18 +2064,18 @@ bool ScrollWindowTo(int x , int y, Window *w, bool instant)
{
/* The slope cannot be acquired outside of the map, so make sure we are always within the map. */
Point pt = MapXYZToViewport(w->viewport, x, y, GetSlopeZ(Clamp(x, 0, MapSizeX()), Clamp(y, 0, MapSizeY())));
- WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
+ w->viewport->follow_vehicle = INVALID_VEHICLE;
- if (WP(w, vp_d).dest_scrollpos_x == pt.x && WP(w, vp_d).dest_scrollpos_y == pt.y)
+ if (w->viewport->dest_scrollpos_x == pt.x && w->viewport->dest_scrollpos_y == pt.y)
return false;
if (instant) {
- WP(w, vp_d).scrollpos_x = pt.x;
- WP(w, vp_d).scrollpos_y = pt.y;
+ w->viewport->scrollpos_x = pt.x;
+ w->viewport->scrollpos_y = pt.y;
}
- WP(w, vp_d).dest_scrollpos_x = pt.x;
- WP(w, vp_d).dest_scrollpos_y = pt.y;
+ w->viewport->dest_scrollpos_x = pt.x;
+ w->viewport->dest_scrollpos_y = pt.y;
return true;
}
diff --git a/src/window.cpp b/src/window.cpp
index 3efdb2df3..4c7f89454 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1713,9 +1713,9 @@ static bool HandleViewportScroll()
return true;
}
- if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE && w == FindWindowById(WC_MAIN_WINDOW, 0)) {
+ if (w == FindWindowById(WC_MAIN_WINDOW, 0) && w->viewport->follow_vehicle != INVALID_VEHICLE) {
/* If the main window is following a vehicle, then first let go of it! */
- const Vehicle *veh = GetVehicle(WP(w, vp_d).follow_vehicle);
+ const Vehicle *veh = GetVehicle(w->viewport->follow_vehicle);
ScrollMainWindowTo(veh->x_pos, veh->y_pos, true); /* This also resets follow_vehicle */
return true;
}
@@ -1915,14 +1915,14 @@ static void HandleAutoscroll()
/* here allows scrolling in both x and y axis */
#define scrollspeed 3
if (x - 15 < 0) {
- WP(w, vp_d).dest_scrollpos_x += ScaleByZoom((x - 15) * scrollspeed, vp->zoom);
+ w->viewport->dest_scrollpos_x += ScaleByZoom((x - 15) * scrollspeed, vp->zoom);
} else if (15 - (vp->width - x) > 0) {
- WP(w, vp_d).dest_scrollpos_x += ScaleByZoom((15 - (vp->width - x)) * scrollspeed, vp->zoom);
+ w->viewport->dest_scrollpos_x += ScaleByZoom((15 - (vp->width - x)) * scrollspeed, vp->zoom);
}
if (y - 15 < 0) {
- WP(w, vp_d).dest_scrollpos_y += ScaleByZoom((y - 15) * scrollspeed, vp->zoom);
+ w->viewport->dest_scrollpos_y += ScaleByZoom((y - 15) * scrollspeed, vp->zoom);
} else if (15 - (vp->height - y) > 0) {
- WP(w, vp_d).dest_scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * scrollspeed, vp->zoom);
+ w->viewport->dest_scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * scrollspeed, vp->zoom);
}
#undef scrollspeed
}
diff --git a/src/window_gui.h b/src/window_gui.h
index a647cb8c6..73f7065e7 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -271,6 +271,17 @@ struct ResizeInfo {
};
/**
+ * Data structure for a window viewport
+ */
+struct ViewportData : ViewPort {
+ VehicleID follow_vehicle;
+ int32 scrollpos_x;
+ int32 scrollpos_y;
+ int32 dest_scrollpos_x;
+ int32 dest_scrollpos_y;
+};
+
+ /**
* Data structure for an opened window
*/
struct Window : ZeroedMemoryAllocator {
@@ -306,7 +317,7 @@ public:
byte caption_color; ///< Background color of the window caption, contains PlayerID
- ViewPort *viewport; ///< Pointer to viewport, if present
+ ViewportData *viewport; ///< Pointer to viewport data, if present
const Widget *original_widget; ///< Original widget layout, copied from WindowDesc
Widget *widget; ///< Widgets of the window
uint widget_count; ///< Number of widgets of the window
@@ -540,16 +551,6 @@ struct depot_d {
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d));
-struct vp_d {
- VehicleID follow_vehicle;
- int32 scrollpos_x;
- int32 scrollpos_y;
- int32 dest_scrollpos_x;
- int32 dest_scrollpos_y;
- ViewPort vp_data; ///< Screen position and zoom of the viewport
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
-
enum SortListFlags {
VL_NONE = 0, ///< no sort
VL_DESC = 1 << 0, ///< sort descending or ascending