src/road_cmd.cpp
changeset 8398 1e181e2e4e15
parent 8390 f88f515e6557
child 8413 c7f3384330a3
equal deleted inserted replaced
8397:db3e5c72c257 8398:1e181e2e4e15
    31 #include "strings_func.h"
    31 #include "strings_func.h"
    32 #include "vehicle_func.h"
    32 #include "vehicle_func.h"
    33 #include "vehicle_base.h"
    33 #include "vehicle_base.h"
    34 #include "sound_func.h"
    34 #include "sound_func.h"
    35 #include "road_func.h"
    35 #include "road_func.h"
       
    36 #include "tunnelbridge.h"
    36 
    37 
    37 #include "table/sprites.h"
    38 #include "table/sprites.h"
    38 #include "table/strings.h"
    39 #include "table/strings.h"
    39 
    40 
    40 #define M(x) (1 << (x))
    41 #define M(x) (1 << (x))
   157 
   158 
   158 		CommandCost cost(EXPENSES_CONSTRUCTION);
   159 		CommandCost cost(EXPENSES_CONSTRUCTION);
   159 		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
   160 		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
   160 			TileIndex other_end = GetOtherTunnelBridgeEnd(tile);
   161 			TileIndex other_end = GetOtherTunnelBridgeEnd(tile);
   161 			/* Pay for *every* tile of the bridge or tunnel */
   162 			/* Pay for *every* tile of the bridge or tunnel */
   162 			cost.AddCost((DistanceManhattan(other_end, tile) + 1) * _price.remove_road);
   163 			cost.AddCost((GetTunnelBridgeLength(other_end, tile) + 2) * _price.remove_road);
   163 			if (flags & DC_EXEC) {
   164 			if (flags & DC_EXEC) {
   164 				SetRoadTypes(other_end, GetRoadTypes(other_end) & ~RoadTypeToRoadTypes(rt));
   165 				SetRoadTypes(other_end, GetRoadTypes(other_end) & ~RoadTypeToRoadTypes(rt));
   165 				SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt));
   166 				SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt));
   166 
   167 
   167 				/* Mark tiles diry that have been repaved */
   168 				/* Mark tiles diry that have been repaved */
   549 	}
   550 	}
   550 
   551 
   551 	cost.AddCost(CountBits(pieces) * _price.build_road);
   552 	cost.AddCost(CountBits(pieces) * _price.build_road);
   552 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
   553 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
   553 		/* Pay for *every* tile of the bridge or tunnel */
   554 		/* Pay for *every* tile of the bridge or tunnel */
   554 		cost.MultiplyCost(DistanceManhattan(GetOtherTunnelBridgeEnd(tile), tile) + 1);
   555 		cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2);
   555 	}
   556 	}
   556 
   557 
   557 	if (flags & DC_EXEC) {
   558 	if (flags & DC_EXEC) {
   558 		switch (GetTileType(tile)) {
   559 		switch (GetTileType(tile)) {
   559 			case MP_ROAD: {
   560 			case MP_ROAD: {