src/road_cmd.cpp
changeset 8232 a4883a0598db
parent 8230 64f28fe2d5c8
child 8254 1496654ca5e7
equal deleted inserted replaced
8231:d98af7a3fecb 8232:a4883a0598db
   197 
   197 
   198 			/* limit the bits to delete to the existing bits. */
   198 			/* limit the bits to delete to the existing bits. */
   199 			c &= present;
   199 			c &= present;
   200 			if (c == ROAD_NONE) return CMD_ERROR;
   200 			if (c == ROAD_NONE) return CMD_ERROR;
   201 
   201 
       
   202 			ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
   202 			if (flags & DC_EXEC) {
   203 			if (flags & DC_EXEC) {
   203 				ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
       
   204 
       
   205 				present ^= c;
   204 				present ^= c;
   206 				if (present == ROAD_NONE) {
   205 				if (present == ROAD_NONE) {
   207 					RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
   206 					RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
   208 					if (rts == ROADTYPES_NONE) {
   207 					if (rts == ROADTYPES_NONE) {
   209 						/* Includes MarkTileDirtyByTile() */
   208 						/* Includes MarkTileDirtyByTile() */
   232 
   231 
   233 			/* Don't allow road to be removed from the crossing when there is tram;
   232 			/* Don't allow road to be removed from the crossing when there is tram;
   234 			 * we can't draw the crossing without trambits ;) */
   233 			 * we can't draw the crossing without trambits ;) */
   235 			if (rt == ROADTYPE_ROAD && HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) && ((flags & DC_EXEC) || !HasBit(p1, 6))) return CMD_ERROR;
   234 			if (rt == ROADTYPE_ROAD && HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) && ((flags & DC_EXEC) || !HasBit(p1, 6))) return CMD_ERROR;
   236 
   235 
       
   236 			if (rt == ROADTYPE_ROAD) {
       
   237 				ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
       
   238 			}
       
   239 
   237 			if (flags & DC_EXEC) {
   240 			if (flags & DC_EXEC) {
   238 				if (rt == ROADTYPE_ROAD) {
       
   239 					ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
       
   240 				}
       
   241 
       
   242 				RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
   241 				RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
   243 				if (rts == ROADTYPES_NONE) {
   242 				if (rts == ROADTYPES_NONE) {
   244 					MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile));
   243 					MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile));
   245 				} else {
   244 				} else {
   246 					SetRoadTypes(tile, rts);
   245 					SetRoadTypes(tile, rts);