road_cmd.c
changeset 2639 eeaefdabfdfd
parent 2549 5587f9a38563
child 2690 5a4ed6db4493
equal deleted inserted replaced
2638:0811adaec525 2639:eeaefdabfdfd
   375 	// allow building road under bridge
   375 	// allow building road under bridge
   376 	if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) return CMD_ERROR;
   376 	if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) return CMD_ERROR;
   377 
   377 
   378 	if (ti.type == MP_STREET) {
   378 	if (ti.type == MP_STREET) {
   379 		if (!(ti.map5 & 0xF0)) {
   379 		if (!(ti.map5 & 0xF0)) {
   380 			if ( (pieces & (byte)(ti.map5)) == (pieces))
   380 			if ((pieces & (byte)ti.map5) == pieces)
   381 				return_cmd_error(STR_1007_ALREADY_BUILT);
   381 				return_cmd_error(STR_1007_ALREADY_BUILT);
   382 			existing = ti.map5;
   382 			existing = ti.map5;
   383 		} else {
   383 		} else {
   384 			if (!(ti.map5 & 0xE0) && pieces != ((ti.map5 & 8) ? 5 : 10))
   384 			if (!(ti.map5 & 0xE0) && pieces != ((ti.map5 & 8) ? 5 : 10))
   385 				return_cmd_error(STR_1007_ALREADY_BUILT);
   385 				return_cmd_error(STR_1007_ALREADY_BUILT);
   678 static int32 RemoveRoadDepot(TileIndex tile, uint32 flags)
   678 static int32 RemoveRoadDepot(TileIndex tile, uint32 flags)
   679 {
   679 {
   680 	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
   680 	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
   681 		return CMD_ERROR;
   681 		return CMD_ERROR;
   682 
   682 
   683 	if (!EnsureNoVehicle(tile))
   683 	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
   684 		return CMD_ERROR;
   684 
   685 
   685 	if (flags & DC_EXEC) DoDeleteDepot(tile);
   686 	if (flags & DC_EXEC) {
       
   687 		DoDeleteDepot(tile);
       
   688 	}
       
   689 
   686 
   690 	return _price.remove_road_depot;
   687 	return _price.remove_road_depot;
   691 }
   688 }
   692 
   689 
   693 #define M(x) (1<<(x))
   690 #define M(x) (1<<(x))
   788 			foundation = ti->tileh;
   785 			foundation = ti->tileh;
   789 		} else {
   786 		} else {
   790 			foundation = GetRoadFoundation(ti->tileh, road);
   787 			foundation = GetRoadFoundation(ti->tileh, road);
   791 		}
   788 		}
   792 
   789 
   793 		if (foundation != 0)
   790 		if (foundation != 0) DrawFoundation(ti, foundation);
   794 			DrawFoundation(ti, foundation);
       
   795 
   791 
   796 		// DrawFoundation() modifies ti.
   792 		// DrawFoundation() modifies ti.
   797 		// Default sloped sprites..
   793 		// Default sloped sprites..
   798 		if (ti->tileh != 0) {
   794 		if (ti->tileh != 0) image = _road_sloped_sprites[ti->tileh - 1] + 0x53F;
   799 			image = _road_sloped_sprites[ti->tileh - 1] + 0x53F;
   795 	}
   800 		}
   796 
   801 	}
   797 	if (image == 0) image = _road_tile_sprites_1[road];
   802 
   798 
   803 	if (image == 0)
   799 	if (ground_type == 0) image |= PALETTE_TO_BARE_LAND;
   804 		image = _road_tile_sprites_1[road];
       
   805 
       
   806 	if (ground_type == 0)
       
   807 		image |= PALETTE_TO_BARE_LAND;
       
   808 
   800 
   809 	if (snow) {
   801 	if (snow) {
   810 		image += 19;
   802 		image += 19;
   811 	} else if (ground_type > 1 && ground_type != 6) {
   803 	} else if (ground_type > 1 && ground_type != 6) {
   812 		// Pavement tiles.
   804 		// Pavement tiles.
   814 	}
   806 	}
   815 
   807 
   816 	DrawGroundSprite(image);
   808 	DrawGroundSprite(image);
   817 
   809 
   818 	// Return if full detail is disabled, or we are zoomed fully out.
   810 	// Return if full detail is disabled, or we are zoomed fully out.
   819 	if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2)
   811 	if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2) return;
   820 		return;
       
   821 
   812 
   822 	if (ground_type >= 6) {
   813 	if (ground_type >= 6) {
   823 		// Road works
   814 		// Road works
   824 		DrawGroundSprite(HASBIT(road, 4) ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y);
   815 		DrawGroundSprite(HASBIT(road, 4) ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y);
   825 		return;
   816 		return;
   829 	drts = _road_display_table[ground_type][road];
   820 	drts = _road_display_table[ground_type][road];
   830 	while ((image = drts->image) != 0) {
   821 	while ((image = drts->image) != 0) {
   831 		int x = ti->x | drts->subcoord_x;
   822 		int x = ti->x | drts->subcoord_x;
   832 		int y = ti->y | drts->subcoord_y;
   823 		int y = ti->y | drts->subcoord_y;
   833 		byte z = ti->z;
   824 		byte z = ti->z;
   834 		if (ti->tileh != 0)
   825 		if (ti->tileh != 0) z = GetSlopeZ(x, y);
   835 			z = GetSlopeZ(x, y);
       
   836 		AddSortableSpriteToDraw(image, x, y, 2, 2, 0x10, z);
   826 		AddSortableSpriteToDraw(image, x, y, 2, 2, 0x10, z);
   837 		drts++;
   827 		drts++;
   838 	}
   828 	}
   839 }
   829 }
   840 
   830 
   913 
   903 
   914 	ormod = PLAYER_SPRITE_COLOR(_local_player);
   904 	ormod = PLAYER_SPRITE_COLOR(_local_player);
   915 
   905 
   916 	dtss = _road_display_datas[image];
   906 	dtss = _road_display_datas[image];
   917 
   907 
   918 	x+=33;
   908 	x += 33;
   919 	y+=17;
   909 	y += 17;
   920 
   910 
   921 	DrawSprite(dtss++->image, x, y);
   911 	DrawSprite(dtss++->image, x, y);
   922 
   912 
   923 	for(; dtss->image != 0; dtss++) {
   913 	for(; dtss->image != 0; dtss++) {
   924 		Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0);
   914 		Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0);
   925 
   915 
   926 		image = dtss->image;
   916 		image = dtss->image;
   927 		if (image & PALETTE_MODIFIER_COLOR)
   917 		if (image & PALETTE_MODIFIER_COLOR) image |= ormod;
   928 			image |= ormod;
       
   929 
   918 
   930 		DrawSprite(image, x + pt.x, y + pt.y);
   919 		DrawSprite(image, x + pt.x, y + pt.y);
   931 	}
   920 	}
   932 }
   921 }
   933 
   922 
   984 	/* not used */
   973 	/* not used */
   985 }
   974 }
   986 
   975 
   987 static void AnimateTile_Road(TileIndex tile)
   976 static void AnimateTile_Road(TileIndex tile)
   988 {
   977 {
   989 	if (IsLevelCrossing(tile)) {
   978 	if (IsLevelCrossing(tile)) MarkTileDirtyByTile(tile);
   990 		MarkTileDirtyByTile(tile);
       
   991 	}
       
   992 }
   979 }
   993 
   980 
   994 static const byte _town_road_types[5][2] = {
   981 static const byte _town_road_types[5][2] = {
   995 	{1,1},
   982 	{1,1},
   996 	{2,2},
   983 	{2,2},