vehicle.c
changeset 926 a6d140a6a4de
parent 924 6fbd4419db2a
child 931 79bd23c03adb
equal deleted inserted replaced
925:47d7952c6c14 926:a6d140a6a4de
   103 	return VehicleFromPos(tile, &ti, EnsureNoVehicleProcZ) == NULL;
   103 	return VehicleFromPos(tile, &ti, EnsureNoVehicleProcZ) == NULL;
   104 }
   104 }
   105 
   105 
   106 Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z)
   106 Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z)
   107 {
   107 {
   108 	int x1 = GET_TILE_X(from);
   108 	int x1 = TileX(from);
   109 	int y1 = GET_TILE_Y(from);
   109 	int y1 = TileY(from);
   110 	int x2 = GET_TILE_X(to);
   110 	int x2 = TileX(to);
   111 	int y2 = GET_TILE_Y(to);
   111 	int y2 = TileY(to);
   112 	Vehicle *veh;
   112 	Vehicle *veh;
   113 
   113 
   114 	/* Make sure x1 < x2 or y1 < y2 */
   114 	/* Make sure x1 < x2 or y1 < y2 */
   115 	if (x1 > x2 || y1 > y2) {
   115 	if (x1 > x2 || y1 > y2) {
   116 		intswap(x1,x2);
   116 		intswap(x1,x2);
   146 	v->bottom_coord = pt.y + sd->ysize + 2;
   146 	v->bottom_coord = pt.y + sd->ysize + 2;
   147 }
   147 }
   148 
   148 
   149 void UpdateWaypointSign(Waypoint *cp)
   149 void UpdateWaypointSign(Waypoint *cp)
   150 {
   150 {
   151 	Point pt = RemapCoords2(GET_TILE_X(cp->xy)*16, GET_TILE_Y(cp->xy)*16);
   151 	Point pt = RemapCoords2(TileX(cp->xy) * 16, TileY(cp->xy) * 16);
   152 	SetDParam(0, cp - _waypoints);
   152 	SetDParam(0, cp - _waypoints);
   153 	UpdateViewportSignPos(&cp->sign, pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
   153 	UpdateViewportSignPos(&cp->sign, pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
   154 }
   154 }
   155 
   155 
   156 void RedrawWaypointSign(Waypoint *cp)
   156 void RedrawWaypointSign(Waypoint *cp)
   261 
   261 
   262 void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
   262 void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
   263 {
   263 {
   264 	int x,y,x2,y2;
   264 	int x,y,x2,y2;
   265 	VehicleID veh;
   265 	VehicleID veh;
   266 	Point pt = RemapCoords(GET_TILE_X(tile) * 16, GET_TILE_Y(tile) * 16, 0);
   266 	Point pt = RemapCoords(TileX(tile) * 16, TileY(tile) * 16, 0);
   267 
   267 
   268 	x2 = ((pt.x + 104) & 0x1F80) >> 7;
   268 	x2 = ((pt.x + 104) & 0x1F80) >> 7;
   269 	x  = ((pt.x - 174) & 0x1F80) >> 7;
   269 	x  = ((pt.x - 174) & 0x1F80) >> 7;
   270 
   270 
   271 	y2 = ((pt.y + 56) & 0xFC0);
   271 	y2 = ((pt.y + 56) & 0xFC0);