changeset 3793 | 33cdb5bf7b21 |
parent 3792 | 2eb8388731bf |
child 3794 | ac26a7b4615d |
3792:2eb8388731bf | 3793:33cdb5bf7b21 |
---|---|
147 |
147 |
148 // check if you're allowed to remove the street owned by a town |
148 // check if you're allowed to remove the street owned by a town |
149 // removal allowance depends on difficulty setting |
149 // removal allowance depends on difficulty setting |
150 if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR; |
150 if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR; |
151 |
151 |
152 switch (GetRoadType(tile)) { |
152 switch (GetRoadTileType(tile)) { |
153 case ROAD_NORMAL: { |
153 case ROAD_TILE_NORMAL: { |
154 RoadBits present = GetRoadBits(tile); |
154 RoadBits present = GetRoadBits(tile); |
155 RoadBits c = pieces; |
155 RoadBits c = pieces; |
156 |
156 |
157 if (GetTileSlope(tile, NULL) != SLOPE_FLAT && |
157 if (GetTileSlope(tile, NULL) != SLOPE_FLAT && |
158 (present == ROAD_Y || present == ROAD_X)) { |
158 (present == ROAD_Y || present == ROAD_X)) { |
176 } |
176 } |
177 } |
177 } |
178 return CountRoadBits(c) * _price.remove_road; |
178 return CountRoadBits(c) * _price.remove_road; |
179 } |
179 } |
180 |
180 |
181 case ROAD_CROSSING: { |
181 case ROAD_TILE_CROSSING: { |
182 if (pieces & ComplementRoadBits(GetCrossingRoadBits(tile))) { |
182 if (pieces & ComplementRoadBits(GetCrossingRoadBits(tile))) { |
183 return CMD_ERROR; |
183 return CMD_ERROR; |
184 } |
184 } |
185 |
185 |
186 if (flags & DC_EXEC) { |
186 if (flags & DC_EXEC) { |
191 } |
191 } |
192 return _price.remove_road * 2; |
192 return _price.remove_road * 2; |
193 } |
193 } |
194 |
194 |
195 default: |
195 default: |
196 case ROAD_DEPOT: |
196 case ROAD_TILE_DEPOT: |
197 return CMD_ERROR; |
197 return CMD_ERROR; |
198 } |
198 } |
199 |
199 |
200 default: return CMD_ERROR; |
200 default: return CMD_ERROR; |
201 } |
201 } |
286 |
286 |
287 tileh = GetTileSlope(tile, NULL); |
287 tileh = GetTileSlope(tile, NULL); |
288 |
288 |
289 switch (GetTileType(tile)) { |
289 switch (GetTileType(tile)) { |
290 case MP_STREET: |
290 case MP_STREET: |
291 switch (GetRoadType(tile)) { |
291 switch (GetRoadTileType(tile)) { |
292 case ROAD_NORMAL: |
292 case ROAD_TILE_NORMAL: |
293 existing = GetRoadBits(tile); |
293 existing = GetRoadBits(tile); |
294 if ((existing & pieces) == pieces) { |
294 if ((existing & pieces) == pieces) { |
295 return_cmd_error(STR_1007_ALREADY_BUILT); |
295 return_cmd_error(STR_1007_ALREADY_BUILT); |
296 } |
296 } |
297 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
297 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
298 break; |
298 break; |
299 |
299 |
300 case ROAD_CROSSING: |
300 case ROAD_TILE_CROSSING: |
301 if (pieces != GetCrossingRoadBits(tile)) { // XXX is this correct? |
301 if (pieces != GetCrossingRoadBits(tile)) { // XXX is this correct? |
302 return_cmd_error(STR_1007_ALREADY_BUILT); |
302 return_cmd_error(STR_1007_ALREADY_BUILT); |
303 } |
303 } |
304 goto do_clear; |
304 goto do_clear; |
305 |
305 |
306 default: |
306 default: |
307 case ROAD_DEPOT: |
307 case ROAD_TILE_DEPOT: |
308 goto do_clear; |
308 goto do_clear; |
309 } |
309 } |
310 break; |
310 break; |
311 |
311 |
312 case MP_RAILWAY: { |
312 case MP_RAILWAY: { |
602 |
602 |
603 #define M(x) (1<<(x)) |
603 #define M(x) (1<<(x)) |
604 |
604 |
605 static int32 ClearTile_Road(TileIndex tile, byte flags) |
605 static int32 ClearTile_Road(TileIndex tile, byte flags) |
606 { |
606 { |
607 switch (GetRoadType(tile)) { |
607 switch (GetRoadTileType(tile)) { |
608 case ROAD_NORMAL: { |
608 case ROAD_TILE_NORMAL: { |
609 RoadBits b = GetRoadBits(tile); |
609 RoadBits b = GetRoadBits(tile); |
610 |
610 |
611 if (!((1 << b) & (M(1)|M(2)|M(4)|M(8))) && |
611 if (!((1 << b) & (M(1)|M(2)|M(4)|M(8))) && |
612 (!(flags & DC_AI_BUILDING) || !IsTileOwner(tile, OWNER_TOWN)) && |
612 (!(flags & DC_AI_BUILDING) || !IsTileOwner(tile, OWNER_TOWN)) && |
613 flags & DC_AUTO) { |
613 flags & DC_AUTO) { |
614 return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
614 return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
615 } |
615 } |
616 return DoCommand(tile, b, 0, flags, CMD_REMOVE_ROAD); |
616 return DoCommand(tile, b, 0, flags, CMD_REMOVE_ROAD); |
617 } |
617 } |
618 |
618 |
619 case ROAD_CROSSING: { |
619 case ROAD_TILE_CROSSING: { |
620 int32 ret; |
620 int32 ret; |
621 |
621 |
622 if (flags & DC_AUTO) return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
622 if (flags & DC_AUTO) return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
623 |
623 |
624 ret = DoCommand(tile, GetCrossingRoadBits(tile), 0, flags, CMD_REMOVE_ROAD); |
624 ret = DoCommand(tile, GetCrossingRoadBits(tile), 0, flags, CMD_REMOVE_ROAD); |
629 } |
629 } |
630 return ret; |
630 return ret; |
631 } |
631 } |
632 |
632 |
633 default: |
633 default: |
634 case ROAD_DEPOT: |
634 case ROAD_TILE_DEPOT: |
635 if (flags & DC_AUTO) { |
635 if (flags & DC_AUTO) { |
636 return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
636 return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
637 } |
637 } |
638 return RemoveRoadDepot(tile, flags); |
638 return RemoveRoadDepot(tile, flags); |
639 } |
639 } |
740 |
740 |
741 static void DrawTile_Road(TileInfo *ti) |
741 static void DrawTile_Road(TileInfo *ti) |
742 { |
742 { |
743 PalSpriteID image; |
743 PalSpriteID image; |
744 |
744 |
745 switch (GetRoadType(ti->tile)) { |
745 switch (GetRoadTileType(ti->tile)) { |
746 case ROAD_NORMAL: |
746 case ROAD_TILE_NORMAL: |
747 DrawRoadBits(ti, GetRoadBits(ti->tile)); |
747 DrawRoadBits(ti, GetRoadBits(ti->tile)); |
748 break; |
748 break; |
749 |
749 |
750 case ROAD_CROSSING: { |
750 case ROAD_TILE_CROSSING: { |
751 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); |
751 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); |
752 |
752 |
753 image = GetRailTypeInfo(GetRailTypeCrossing(ti->tile))->base_sprites.crossing; |
753 image = GetRailTypeInfo(GetRailTypeCrossing(ti->tile))->base_sprites.crossing; |
754 |
754 |
755 if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++; |
755 if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++; |
767 if (GetRailTypeCrossing(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); |
767 if (GetRailTypeCrossing(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); |
768 break; |
768 break; |
769 } |
769 } |
770 |
770 |
771 default: |
771 default: |
772 case ROAD_DEPOT: { |
772 case ROAD_TILE_DEPOT: { |
773 uint32 ormod; |
773 uint32 ormod; |
774 PlayerID player; |
774 PlayerID player; |
775 const DrawRoadSeqStruct* drss; |
775 const DrawRoadSeqStruct* drss; |
776 |
776 |
777 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); |
777 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); |
827 { |
827 { |
828 Slope tileh = ti->tileh; |
828 Slope tileh = ti->tileh; |
829 uint z = ti->z; |
829 uint z = ti->z; |
830 |
830 |
831 if (tileh == SLOPE_FLAT) return z; |
831 if (tileh == SLOPE_FLAT) return z; |
832 if (GetRoadType(ti->tile) == ROAD_NORMAL) { |
832 if (GetRoadTileType(ti->tile) == ROAD_TILE_NORMAL) { |
833 uint f = GetRoadFoundation(tileh, GetRoadBits(ti->tile)); |
833 uint f = GetRoadFoundation(tileh, GetRoadBits(ti->tile)); |
834 |
834 |
835 if (f != 0) { |
835 if (f != 0) { |
836 if (f < 15) return z + TILE_HEIGHT; // leveled foundation |
836 if (f < 15) return z + TILE_HEIGHT; // leveled foundation |
837 tileh = _inclined_tileh[f - 15]; // inclined foundation |
837 tileh = _inclined_tileh[f - 15]; // inclined foundation |
843 } |
843 } |
844 |
844 |
845 static Slope GetSlopeTileh_Road(TileIndex tile, Slope tileh) |
845 static Slope GetSlopeTileh_Road(TileIndex tile, Slope tileh) |
846 { |
846 { |
847 if (tileh == SLOPE_FLAT) return SLOPE_FLAT; |
847 if (tileh == SLOPE_FLAT) return SLOPE_FLAT; |
848 if (GetRoadType(tile) == ROAD_NORMAL) { |
848 if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { |
849 uint f = GetRoadFoundation(tileh, GetRoadBits(tile)); |
849 uint f = GetRoadFoundation(tileh, GetRoadBits(tile)); |
850 |
850 |
851 if (f == 0) return tileh; |
851 if (f == 0) return tileh; |
852 if (f < 15) return SLOPE_FLAT; // leveled foundation |
852 if (f < 15) return SLOPE_FLAT; // leveled foundation |
853 return _inclined_tileh[f - 15]; // inclined foundation |
853 return _inclined_tileh[f - 15]; // inclined foundation |
902 MarkTileDirtyByTile(tile); |
902 MarkTileDirtyByTile(tile); |
903 } |
903 } |
904 break; |
904 break; |
905 } |
905 } |
906 |
906 |
907 if (GetRoadType(tile) == ROAD_DEPOT) return; |
907 if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) return; |
908 |
908 |
909 if (!HasRoadWorks(tile)) { |
909 if (!HasRoadWorks(tile)) { |
910 t = ClosestTownFromTile(tile, (uint)-1); |
910 t = ClosestTownFromTile(tile, (uint)-1); |
911 |
911 |
912 grp = 0; |
912 grp = 0; |
914 grp = GetTownRadiusGroup(t, tile); |
914 grp = GetTownRadiusGroup(t, tile); |
915 |
915 |
916 // Show an animation to indicate road work |
916 // Show an animation to indicate road work |
917 if (t->road_build_months != 0 && |
917 if (t->road_build_months != 0 && |
918 !(DistanceManhattan(t->xy, tile) >= 8 && grp == 0) && |
918 !(DistanceManhattan(t->xy, tile) >= 8 && grp == 0) && |
919 GetRoadType(tile) == ROAD_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) { |
919 GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) { |
920 if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicle(tile) && CHANCE16(1, 20)) { |
920 if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicle(tile) && CHANCE16(1, 20)) { |
921 StartRoadWorks(tile); |
921 StartRoadWorks(tile); |
922 |
922 |
923 SndPlayTileFx(SND_21_JACKHAMMER, tile); |
923 SndPlayTileFx(SND_21_JACKHAMMER, tile); |
924 CreateEffectVehicleAbove( |
924 CreateEffectVehicleAbove( |
961 |
961 |
962 void ShowRoadDepotWindow(TileIndex tile); |
962 void ShowRoadDepotWindow(TileIndex tile); |
963 |
963 |
964 static void ClickTile_Road(TileIndex tile) |
964 static void ClickTile_Road(TileIndex tile) |
965 { |
965 { |
966 if (GetRoadType(tile) == ROAD_DEPOT) ShowRoadDepotWindow(tile); |
966 if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) ShowRoadDepotWindow(tile); |
967 } |
967 } |
968 |
968 |
969 static const byte _road_trackbits[16] = { |
969 static const byte _road_trackbits[16] = { |
970 0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, |
970 0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, |
971 }; |
971 }; |
976 case TRANSPORT_RAIL: |
976 case TRANSPORT_RAIL: |
977 if (!IsLevelCrossing(tile)) return 0; |
977 if (!IsLevelCrossing(tile)) return 0; |
978 return GetCrossingRailBits(tile) * 0x101; |
978 return GetCrossingRailBits(tile) * 0x101; |
979 |
979 |
980 case TRANSPORT_ROAD: |
980 case TRANSPORT_ROAD: |
981 switch (GetRoadType(tile)) { |
981 switch (GetRoadTileType(tile)) { |
982 case ROAD_NORMAL: |
982 case ROAD_TILE_NORMAL: |
983 return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile)] * 0x101; |
983 return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile)] * 0x101; |
984 |
984 |
985 case ROAD_CROSSING: { |
985 case ROAD_TILE_CROSSING: { |
986 uint32 r = (GetCrossingRoadAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101; |
986 uint32 r = (GetCrossingRoadAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101; |
987 |
987 |
988 if (IsCrossingBarred(tile)) r *= 0x10001; |
988 if (IsCrossingBarred(tile)) r *= 0x10001; |
989 return r; |
989 return r; |
990 } |
990 } |
991 |
991 |
992 default: |
992 default: |
993 case ROAD_DEPOT: |
993 case ROAD_TILE_DEPOT: |
994 break; |
994 break; |
995 } |
995 } |
996 break; |
996 break; |
997 |
997 |
998 default: break; |
998 default: break; |
1012 }; |
1012 }; |
1013 |
1013 |
1014 static void GetTileDesc_Road(TileIndex tile, TileDesc *td) |
1014 static void GetTileDesc_Road(TileIndex tile, TileDesc *td) |
1015 { |
1015 { |
1016 td->owner = GetTileOwner(tile); |
1016 td->owner = GetTileOwner(tile); |
1017 switch (GetRoadType(tile)) { |
1017 switch (GetRoadTileType(tile)) { |
1018 case ROAD_CROSSING: td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING; break; |
1018 case ROAD_TILE_CROSSING: td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING; break; |
1019 case ROAD_DEPOT: td->str = STR_1817_ROAD_VEHICLE_DEPOT; break; |
1019 case ROAD_TILE_DEPOT: td->str = STR_1817_ROAD_VEHICLE_DEPOT; break; |
1020 default: td->str = _road_tile_strings[GetGroundType(tile)]; break; |
1020 default: td->str = _road_tile_strings[GetGroundType(tile)]; break; |
1021 } |
1021 } |
1022 } |
1022 } |
1023 |
1023 |
1024 static const byte _roadveh_enter_depot_unk0[4] = { |
1024 static const byte _roadveh_enter_depot_unk0[4] = { |
1025 8, 9, 0, 1 |
1025 8, 9, 0, 1 |
1026 }; |
1026 }; |
1027 |
1027 |
1028 static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y) |
1028 static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y) |
1029 { |
1029 { |
1030 switch (GetRoadType(tile)) { |
1030 switch (GetRoadTileType(tile)) { |
1031 case ROAD_CROSSING: |
1031 case ROAD_TILE_CROSSING: |
1032 if (v->type == VEH_Train && !IsCrossingBarred(tile)) { |
1032 if (v->type == VEH_Train && !IsCrossingBarred(tile)) { |
1033 /* train crossing a road */ |
1033 /* train crossing a road */ |
1034 SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v); |
1034 SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v); |
1035 BarCrossing(tile); |
1035 BarCrossing(tile); |
1036 MarkTileDirtyByTile(tile); |
1036 MarkTileDirtyByTile(tile); |
1037 } |
1037 } |
1038 break; |
1038 break; |
1039 |
1039 |
1040 case ROAD_DEPOT: |
1040 case ROAD_TILE_DEPOT: |
1041 if (v->type == VEH_Road && v->u.road.frame == 11) { |
1041 if (v->type == VEH_Road && v->u.road.frame == 11) { |
1042 if (_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) { |
1042 if (_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) { |
1043 RoadVehEnterDepot(v); |
1043 RoadVehEnterDepot(v); |
1044 return 4; |
1044 return 4; |
1045 } |
1045 } |
1061 if (!IsTileOwner(tile, old_player)) return; |
1061 if (!IsTileOwner(tile, old_player)) return; |
1062 |
1062 |
1063 if (new_player != OWNER_SPECTATOR) { |
1063 if (new_player != OWNER_SPECTATOR) { |
1064 SetTileOwner(tile, new_player); |
1064 SetTileOwner(tile, new_player); |
1065 } else { |
1065 } else { |
1066 switch (GetRoadType(tile)) { |
1066 switch (GetRoadTileType(tile)) { |
1067 case ROAD_NORMAL: |
1067 case ROAD_TILE_NORMAL: |
1068 SetTileOwner(tile, OWNER_NONE); |
1068 SetTileOwner(tile, OWNER_NONE); |
1069 break; |
1069 break; |
1070 |
1070 |
1071 case ROAD_CROSSING: |
1071 case ROAD_TILE_CROSSING: |
1072 MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), GetTownIndex(tile)); |
1072 MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), GetTownIndex(tile)); |
1073 break; |
1073 break; |
1074 |
1074 |
1075 default: |
1075 default: |
1076 case ROAD_DEPOT: |
1076 case ROAD_TILE_DEPOT: |
1077 DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
1077 DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
1078 break; |
1078 break; |
1079 } |
1079 } |
1080 } |
1080 } |
1081 } |
1081 } |