viewport.c
changeset 926 a6d140a6a4de
parent 919 544f374ee392
child 979 11ea18598e16
equal deleted inserted replaced
925:47d7952c6c14 926:a6d140a6a4de
   117 		Vehicle *veh;
   117 		Vehicle *veh;
   118 		WP(w,vp_d).follow_vehicle = (VehicleID)(follow_flags & 0xFFFF);
   118 		WP(w,vp_d).follow_vehicle = (VehicleID)(follow_flags & 0xFFFF);
   119 		veh = GetVehicle(WP(w,vp_d).follow_vehicle);
   119 		veh = GetVehicle(WP(w,vp_d).follow_vehicle);
   120 		pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
   120 		pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
   121 	} else {
   121 	} else {
   122 		int x = GET_TILE_X(follow_flags) * 16;
   122 		int x = TileX(follow_flags) * 16;
   123 		int y = GET_TILE_Y(follow_flags) * 16;
   123 		int y = TileY(follow_flags) * 16;
   124 		WP(w,vp_d).follow_vehicle = 0xFFFF;
   124 		WP(w,vp_d).follow_vehicle = 0xFFFF;
   125 		z = GetSlopeZ(x,y);
   125 		z = GetSlopeZ(x,y);
   126 		pt = MapXYZToViewport(vp, x,y, z);
   126 		pt = MapXYZToViewport(vp, x,y, z);
   127 	}
   127 	}
   128 
   128 
  1361 		}
  1361 		}
  1362 	} while (vp++,act>>=1);
  1362 	} while (vp++,act>>=1);
  1363 }
  1363 }
  1364 
  1364 
  1365 void MarkTileDirtyByTile(TileIndex tile) {
  1365 void MarkTileDirtyByTile(TileIndex tile) {
  1366 	Point pt = RemapCoords(GET_TILE_X(tile) * 16, GET_TILE_Y(tile) * 16, GetTileZ(tile));
  1366 	Point pt = RemapCoords(TileX(tile) * 16, TileY(tile) * 16, GetTileZ(tile));
  1367 	MarkAllViewportsDirty(
  1367 	MarkAllViewportsDirty(
  1368 		pt.x - 31,
  1368 		pt.x - 31,
  1369 		pt.y - 122,
  1369 		pt.y - 122,
  1370 		pt.x - 31 + 67,
  1370 		pt.x - 31 + 67,
  1371 		pt.y - 122 + 154
  1371 		pt.y - 122 + 154
  1745 }
  1745 }
  1746 
  1746 
  1747 /* scrolls the viewport in a window to a given tile */
  1747 /* scrolls the viewport in a window to a given tile */
  1748 bool ScrollWindowToTile(TileIndex tile, Window * w)
  1748 bool ScrollWindowToTile(TileIndex tile, Window * w)
  1749 {
  1749 {
  1750 	return ScrollWindowTo(GET_TILE_X(tile)*16+8, GET_TILE_Y(tile)*16+8, w);
  1750 	return ScrollWindowTo(TileX(tile) * 16 + 8, TileY(tile) * 16 + 8, w);
  1751 }
  1751 }
  1752 
  1752 
  1753 
  1753 
  1754 
  1754 
  1755 bool ScrollMainWindowTo(int x, int y)
  1755 bool ScrollMainWindowTo(int x, int y)
  1770 }
  1770 }
  1771 
  1771 
  1772 
  1772 
  1773 bool ScrollMainWindowToTile(TileIndex tile)
  1773 bool ScrollMainWindowToTile(TileIndex tile)
  1774 {
  1774 {
  1775 	return ScrollMainWindowTo(GET_TILE_X(tile)*16+8, GET_TILE_Y(tile)*16+8);
  1775 	return ScrollMainWindowTo(TileX(tile) * 16 + 8, TileY(tile) * 16 + 8);
  1776 }
  1776 }
  1777 
  1777 
  1778 void SetRedErrorSquare(TileIndex tile)
  1778 void SetRedErrorSquare(TileIndex tile)
  1779 {
  1779 {
  1780 	TileIndex old;
  1780 	TileIndex old;
  1870 {
  1870 {
  1871 	TileHighlightData *thd;
  1871 	TileHighlightData *thd;
  1872 
  1872 
  1873 	thd = _thd_ptr;
  1873 	thd = _thd_ptr;
  1874 	thd->userdata = user;
  1874 	thd->userdata = user;
  1875 	thd->selend.x = GET_TILE_X(tile)*16;
  1875 	thd->selend.x = TileX(tile) * 16;
  1876 	thd->selstart.x = GET_TILE_X(tile)*16;
  1876 	thd->selstart.x = TileX(tile) * 16;
  1877 	thd->selend.y = GET_TILE_Y(tile)*16;
  1877 	thd->selend.y = TileY(tile) * 16;
  1878 	thd->selstart.y = GET_TILE_Y(tile)*16;
  1878 	thd->selstart.y = TileY(tile) * 16;
  1879 	if (thd->place_mode == 1) {
  1879 	if (thd->place_mode == 1) {
  1880 		thd->place_mode = 3;
  1880 		thd->place_mode = 3;
  1881 		thd->next_drawstyle = HT_RECT;
  1881 		thd->next_drawstyle = HT_RECT;
  1882 	} else {
  1882 	} else {
  1883 		thd->place_mode = 3;
  1883 		thd->place_mode = 3;
  1892 }
  1892 }
  1893 
  1893 
  1894 void VpSetPresizeRange(uint from, uint to)
  1894 void VpSetPresizeRange(uint from, uint to)
  1895 {
  1895 {
  1896 	TileHighlightData *thd = _thd_ptr;
  1896 	TileHighlightData *thd = _thd_ptr;
  1897 	thd->selend.x = GET_TILE_X(to)*16;
  1897 	thd->selend.x = TileX(to) * 16;
  1898 	thd->selend.y = GET_TILE_Y(to)*16;
  1898 	thd->selend.y = TileY(to) * 16;
  1899 	thd->selstart.x = GET_TILE_X(from)*16;
  1899 	thd->selstart.x = TileX(from) * 16;
  1900 	thd->selstart.y = GET_TILE_Y(from)*16;
  1900 	thd->selstart.y = TileY(from) * 16;
  1901 	thd->next_drawstyle = HT_RECT;
  1901 	thd->next_drawstyle = HT_RECT;
  1902 }
  1902 }
  1903 
  1903 
  1904 void VpStartPreSizing()
  1904 void VpStartPreSizing()
  1905 {
  1905 {