654 */ |
654 */ |
655 static void DrawRoadBits(TileInfo* ti) |
655 static void DrawRoadBits(TileInfo* ti) |
656 { |
656 { |
657 RoadBits road = GetRoadBits(ti->tile); |
657 RoadBits road = GetRoadBits(ti->tile); |
658 const DrawRoadTileStruct *drts; |
658 const DrawRoadTileStruct *drts; |
659 PalSpriteID image = 0; |
659 SpriteID image = 0; |
|
660 SpriteID pal = PAL_NONE; |
660 Roadside roadside; |
661 Roadside roadside; |
661 |
662 |
662 if (ti->tileh != SLOPE_FLAT) { |
663 if (ti->tileh != SLOPE_FLAT) { |
663 int foundation = GetRoadFoundation(ti->tileh, road); |
664 int foundation = GetRoadFoundation(ti->tileh, road); |
664 |
665 |
675 |
676 |
676 if (IsOnSnow(ti->tile)) { |
677 if (IsOnSnow(ti->tile)) { |
677 image += 19; |
678 image += 19; |
678 } else { |
679 } else { |
679 switch (roadside) { |
680 switch (roadside) { |
680 case ROADSIDE_BARREN: image |= PALETTE_TO_BARE_LAND; break; |
681 case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break; |
681 case ROADSIDE_GRASS: break; |
682 case ROADSIDE_GRASS: break; |
682 case ROADSIDE_GRASS_ROAD_WORKS: break; |
683 case ROADSIDE_GRASS_ROAD_WORKS: break; |
683 default: image -= 19; break; // Paved |
684 default: image -= 19; break; // Paved |
684 } |
685 } |
685 } |
686 } |
686 |
687 |
687 DrawGroundSprite(image); |
688 DrawGroundSprite(image, pal); |
688 |
689 |
689 if (HasRoadWorks(ti->tile)) { |
690 if (HasRoadWorks(ti->tile)) { |
690 // Road works |
691 // Road works |
691 DrawGroundSprite(road & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y); |
692 DrawGroundSprite(road & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, PAL_NONE); |
692 return; |
693 return; |
693 } |
694 } |
694 |
695 |
695 // Return if full detail is disabled, or we are zoomed fully out. |
696 // Return if full detail is disabled, or we are zoomed fully out. |
696 if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2) return; |
697 if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2) return; |
699 for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) { |
700 for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) { |
700 int x = ti->x | drts->subcoord_x; |
701 int x = ti->x | drts->subcoord_x; |
701 int y = ti->y | drts->subcoord_y; |
702 int y = ti->y | drts->subcoord_y; |
702 byte z = ti->z; |
703 byte z = ti->z; |
703 if (ti->tileh != SLOPE_FLAT) z = GetSlopeZ(x, y); |
704 if (ti->tileh != SLOPE_FLAT) z = GetSlopeZ(x, y); |
704 AddSortableSpriteToDraw(drts->image, x, y, 2, 2, 0x10, z); |
705 AddSortableSpriteToDraw(drts->image, PAL_NONE, x, y, 2, 2, 0x10, z); |
705 } |
706 } |
706 } |
707 } |
707 |
708 |
708 static void DrawTile_Road(TileInfo *ti) |
709 static void DrawTile_Road(TileInfo *ti) |
709 { |
710 { |
724 |
726 |
725 if (IsOnSnow(ti->tile)) { |
727 if (IsOnSnow(ti->tile)) { |
726 image += 8; |
728 image += 8; |
727 } else { |
729 } else { |
728 switch (GetRoadside(ti->tile)) { |
730 switch (GetRoadside(ti->tile)) { |
729 case ROADSIDE_BARREN: image |= PALETTE_TO_BARE_LAND; break; |
731 case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break; |
730 case ROADSIDE_GRASS: break; |
732 case ROADSIDE_GRASS: break; |
731 default: image += 4; break; // Paved |
733 default: image += 4; break; // Paved |
732 } |
734 } |
733 } |
735 } |
734 |
736 |
735 DrawGroundSprite(image); |
737 DrawGroundSprite(image, pal); |
736 if (GetRailTypeCrossing(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); |
738 if (GetRailTypeCrossing(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); |
737 break; |
739 break; |
738 } |
740 } |
739 |
741 |
740 default: |
742 default: |
741 case ROAD_TILE_DEPOT: { |
743 case ROAD_TILE_DEPOT: { |
742 const DrawTileSprites* dts; |
744 const DrawTileSprites* dts; |
743 const DrawTileSeqStruct* dtss; |
745 const DrawTileSeqStruct* dtss; |
744 uint32 palette; |
746 SpriteID palette; |
745 |
747 |
746 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); |
748 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); |
747 |
749 |
748 palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)); |
750 palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)); |
749 |
751 |
750 dts = &_road_depot[GetRoadDepotDirection(ti->tile)]; |
752 dts = &_road_depot[GetRoadDepotDirection(ti->tile)]; |
751 DrawGroundSprite(dts->ground_sprite); |
753 DrawGroundSprite(dts->ground_sprite, PAL_NONE); |
752 |
754 |
753 for (dtss = dts->seq; dtss->image != 0; dtss++) { |
755 for (dtss = dts->seq; dtss->image != 0; dtss++) { |
754 uint32 image = dtss->image; |
756 SpriteID image = dtss->image; |
|
757 SpriteID pal; |
755 |
758 |
756 if (_display_opt & DO_TRANS_BUILDINGS) { |
759 if (_display_opt & DO_TRANS_BUILDINGS) { |
757 MAKE_TRANSPARENT(image); |
760 SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
758 } else if (image & PALETTE_MODIFIER_COLOR) { |
761 pal = PALETTE_TO_TRANSPARENT; |
759 image |= palette; |
762 } else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) { |
|
763 pal = palette; |
|
764 } else { |
|
765 pal = PAL_NONE; |
760 } |
766 } |
761 |
767 |
762 AddSortableSpriteToDraw( |
768 AddSortableSpriteToDraw( |
763 image, |
769 image, pal, |
764 ti->x + dtss->delta_x, ti->y + dtss->delta_y, |
770 ti->x + dtss->delta_x, ti->y + dtss->delta_y, |
765 dtss->size_x, dtss->size_y, |
771 dtss->size_x, dtss->size_y, |
766 dtss->size_z, ti->z |
772 dtss->size_z, ti->z |
767 ); |
773 ); |
768 } |
774 } |
772 DrawBridgeMiddle(ti); |
778 DrawBridgeMiddle(ti); |
773 } |
779 } |
774 |
780 |
775 void DrawRoadDepotSprite(int x, int y, DiagDirection dir) |
781 void DrawRoadDepotSprite(int x, int y, DiagDirection dir) |
776 { |
782 { |
777 uint32 palette = PLAYER_SPRITE_COLOR(_local_player); |
783 SpriteID palette = PLAYER_SPRITE_COLOR(_local_player); |
778 const DrawTileSprites* dts = &_road_depot[dir]; |
784 const DrawTileSprites* dts = &_road_depot[dir]; |
779 const DrawTileSeqStruct* dtss; |
785 const DrawTileSeqStruct* dtss; |
780 |
786 |
781 x += 33; |
787 x += 33; |
782 y += 17; |
788 y += 17; |
783 |
789 |
784 DrawSprite(dts->ground_sprite, x, y); |
790 DrawSprite(dts->ground_sprite, PAL_NONE, x, y); |
785 |
791 |
786 for (dtss = dts->seq; dtss->image != 0; dtss++) { |
792 for (dtss = dts->seq; dtss->image != 0; dtss++) { |
787 Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z); |
793 Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z); |
788 uint32 image = dtss->image; |
794 SpriteID image = dtss->image; |
789 |
795 |
790 if (image & PALETTE_MODIFIER_COLOR) image |= palette; |
796 DrawSprite(image, HASBIT(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE, x + pt.x, y + pt.y); |
791 |
|
792 DrawSprite(image, x + pt.x, y + pt.y); |
|
793 } |
797 } |
794 } |
798 } |
795 |
799 |
796 static uint GetSlopeZ_Road(TileIndex tile, uint x, uint y) |
800 static uint GetSlopeZ_Road(TileIndex tile, uint x, uint y) |
797 { |
801 { |