Changeset - r17420:961c6d8bb357
[Not reviewed]
master
0 1 0
yexo - 13 years ago 2011-03-04 12:12:48
yexo@openttd.org
(svn r22181) -Fix (r20574): following a vehicle with a very high VehicleID was impossible
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/viewport.cpp
Show inline comments
 
@@ -162,25 +162,25 @@ void DeleteWindowViewport(Window *w)
 
	free(w->viewport);
 
	w->viewport = NULL;
 
}
 

	
 
/**
 
 * Initialize viewport of the window for use.
 
 * @param w Window to use/display the viewport in
 
 * @param x Offset of left edge of viewport with respect to left edge window \a w
 
 * @param y Offset of top edge of viewport with respect to top edge window \a w
 
 * @param width Width of the viewport
 
 * @param height Height of the viewport
 
 * @param follow_flags Flags controlling the viewport.
 
 *        - If bit 31 is set, the lower 16 bits are the vehicle that the viewport should follow.
 
 *        - If bit 31 is set, the lower 20 bits are the vehicle that the viewport should follow.
 
 *        - If bit 31 is clear, it is a #TileIndex.
 
 * @param zoom Zoomlevel to display
 
 */
 
void InitializeWindowViewport(Window *w, int x, int y,
 
	int width, int height, uint32 follow_flags, ZoomLevel zoom)
 
{
 
	assert(w->viewport == NULL);
 

	
 
	ViewportData *vp = CallocT<ViewportData>(1);
 

	
 
	vp->left = x + w->left;
 
	vp->top = y + w->top;
 
@@ -188,25 +188,25 @@ void InitializeWindowViewport(Window *w,
 
	vp->height = height;
 

	
 
	vp->zoom = zoom;
 

	
 
	vp->virtual_width = ScaleByZoom(width, zoom);
 
	vp->virtual_height = ScaleByZoom(height, zoom);
 

	
 
	Point pt;
 

	
 
	if (follow_flags & 0x80000000) {
 
		const Vehicle *veh;
 

	
 
		vp->follow_vehicle = (VehicleID)(follow_flags & 0xFFFF);
 
		vp->follow_vehicle = (VehicleID)(follow_flags & 0xFFFFF);
 
		veh = Vehicle::Get(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;
 

	
 
		vp->follow_vehicle = INVALID_VEHICLE;
 
		pt = MapXYZToViewport(vp, x, y, GetSlopeZ(x, y));
 
	}
 

	
 
	vp->scrollpos_x = pt.x;
 
	vp->scrollpos_y = pt.y;
0 comments (0 inline, 0 general)