src/road_cmd.cpp
branchnoai
changeset 10645 8cbdb511a674
parent 10513 33cb70ff2f5d
child 10713 c5c9dc32c052
equal deleted inserted replaced
10644:6c4314786d68 10645:8cbdb511a674
    41 #include "oldpool_func.h"
    41 #include "oldpool_func.h"
    42 
    42 
    43 #include "table/sprites.h"
    43 #include "table/sprites.h"
    44 #include "table/strings.h"
    44 #include "table/strings.h"
    45 
    45 
       
    46 
       
    47 bool RoadVehiclesAreBuilt()
       
    48 {
       
    49 	const Vehicle* v;
       
    50 
       
    51 	FOR_ALL_VEHICLES(v) {
       
    52 		if (v->type == VEH_ROAD) return true;
       
    53 	}
       
    54 	return false;
       
    55 }
       
    56 
       
    57 /**
       
    58  * Change the side of the road vehicles drive on (server only).
       
    59  * @param tile unused
       
    60  * @param flags operation to perform
       
    61  * @param p1 the side of the road; 0 = left side and 1 = right side
       
    62  * @param p2 unused
       
    63  */
       
    64 CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
       
    65 {
       
    66 	/* Check boundaries and you can only change this if NO vehicles have been built yet,
       
    67 	 * except in the intro-menu where of course it's always possible to do so. */
       
    68 	if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR;
       
    69 
       
    70 	if (flags & DC_EXEC) {
       
    71 		_opt_ptr->road_side = p1;
       
    72 		InvalidateWindow(WC_GAME_OPTIONS, 0);
       
    73 	}
       
    74 	return CommandCost();
       
    75 }
       
    76 
    46 #define M(x) (1 << (x))
    77 #define M(x) (1 << (x))
    47 /* Level crossings may only be built on these slopes */
    78 /* Level crossings may only be built on these slopes */
    48 static const uint32 VALID_LEVEL_CROSSING_SLOPES = (M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT));
    79 static const uint32 VALID_LEVEL_CROSSING_SLOPES = (M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT));
    49 #undef M
    80 #undef M
    50 
    81 
  1388 				case ROAD_TILE_DEPOT: {
  1419 				case ROAD_TILE_DEPOT: {
  1389 					DiagDirection dir = GetRoadDepotDirection(tile);
  1420 					DiagDirection dir = GetRoadDepotDirection(tile);
  1390 
  1421 
  1391 					if (side != INVALID_DIAGDIR && side != dir) break;
  1422 					if (side != INVALID_DIAGDIR && side != dir) break;
  1392 
  1423 
  1393 					trackdirbits = TrackBitsToTrackdirBits(AxisToTrackBits(DiagDirToAxis(dir)));
  1424 					trackdirbits = TrackBitsToTrackdirBits(DiagDirToDiagTrackBits(dir));
  1394 					break;
  1425 					break;
  1395 				}
  1426 				}
  1396 			}
  1427 			}
  1397 			break;
  1428 			break;
  1398 
  1429