Merge branch 'custom_bridgeheads' into jgrpp

# Conflicts:
#	docs/landscape_grid.html
#	src/roadveh_cmd.cpp
#	src/saveload/afterload.cpp
#	src/saveload/extended_ver_sl.cpp
#	src/saveload/extended_ver_sl.h
#	src/settings_gui.cpp
#	src/settings_type.h
#	src/tunnelbridge_cmd.cpp
#	src/tunnelbridge_map.h
This commit is contained in:
Jonathan G Rennison
2017-02-05 20:43:56 +00:00
20 changed files with 475 additions and 106 deletions

View File

@@ -1151,6 +1151,8 @@ bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev)
* by the previous vehicle in the chain when it gets to the right place. */
if (v->IsInDepot()) return true;
bool no_advance_tile = false;
if (v->state == RVSB_WORMHOLE) {
/* Vehicle is entering a depot or is on a bridge or in a tunnel */
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
@@ -1164,19 +1166,24 @@ bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev)
}
if (IsTileType(gp.new_tile, MP_TUNNELBRIDGE) && HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
/* Vehicle has just entered a bridge or tunnel */
if (IsRoadCustomBridgeHeadTile(gp.new_tile)) {
v->frame = 15;
no_advance_tile = true;
} else {
/* Vehicle has just entered a bridge or tunnel */
v->x_pos = gp.x;
v->y_pos = gp.y;
v->UpdatePosition();
v->UpdateInclination(true, true);
return true;
}
} else {
v->x_pos = gp.x;
v->y_pos = gp.y;
v->UpdatePosition();
v->UpdateInclination(true, true);
if ((v->vehstatus & VS_HIDDEN) == 0) v->Vehicle::UpdateViewport(true);
return true;
}
v->x_pos = gp.x;
v->y_pos = gp.y;
v->UpdatePosition();
if (v->IsDrawn()) v->Vehicle::UpdateViewport(true);
return true;
}
/* Get move position data for next frame.
@@ -1187,12 +1194,16 @@ bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev)
(_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)) ^ v->overtaking][v->frame + 1];
if (rd.x & RDE_NEXT_TILE) {
TileIndex tile = v->tile + TileOffsByDiagDir((DiagDirection)(rd.x & 3));
TileIndex tile = v->tile;
if (!no_advance_tile) tile += TileOffsByDiagDir((DiagDirection)(rd.x & 3));
Trackdir dir;
if (v->IsFrontEngine()) {
/* If this is the front engine, look for the right path. */
dir = RoadFindPathToDest(v, tile, (DiagDirection)(rd.x & 3));
} else if (no_advance_tile) {
/* Follow previous vehicle out of custom bridge wormhole */
dir = (Trackdir) prev->state;
} else {
dir = FollowPreviousRoadVehicle(v, prev, tile, (DiagDirection)(rd.x & 3), false);
}
@@ -1209,6 +1220,10 @@ again:
/* When turning around we can't be overtaking. */
v->overtaking = 0;
if (no_advance_tile) {
DEBUG(misc, 0, "Road vehicle attempted to turn around on a single road piece bridge head");
}
/* Turning around */
if (v->roadtype == ROADTYPE_TRAM) {
/* Determine the road bits the tram needs to be able to turn around
@@ -1221,9 +1236,16 @@ again:
case TRACKDIR_RVREV_SW: needed = ROAD_NE; break;
case TRACKDIR_RVREV_NW: needed = ROAD_SE; break;
}
if ((v->Previous() != NULL && v->Previous()->tile == tile) ||
(v->IsFrontEngine() && IsNormalRoadTile(tile) && !HasRoadWorks(tile) &&
(needed & GetRoadBits(tile, ROADTYPE_TRAM)) != ROAD_NONE)) {
auto tile_turn_ok = [&]() -> bool {
if (IsNormalRoadTile(tile)) {
return !HasRoadWorks(tile) && (needed & GetRoadBits(tile, ROADTYPE_TRAM)) != ROAD_NONE;
} else if (IsRoadCustomBridgeHeadTile(tile)) {
return (needed & GetCustomBridgeHeadRoadBits(tile, ROADTYPE_TRAM)) != ROAD_NONE;
} else {
return false;
}
};
if ((v->Previous() != NULL && v->Previous()->tile == tile) || tile_turn_ok()) {
/*
* Taking the 'big' corner for trams only happens when:
* - The previous vehicle in this (articulated) tram chain is