Merge remote-tracking branch 'upstream/master' into 13.0
This commit is contained in:
+25
-19
@@ -34,6 +34,8 @@
|
||||
#include "newgrf.h"
|
||||
#include "zoom_func.h"
|
||||
#include "framerate_type.h"
|
||||
#include "roadveh_cmd.h"
|
||||
#include "road_cmd.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
@@ -249,14 +251,13 @@ void RoadVehUpdateCache(RoadVehicle *v, bool same_length)
|
||||
|
||||
/**
|
||||
* Build a road vehicle.
|
||||
* @param tile tile of the depot where road vehicle is built.
|
||||
* @param flags type of operation.
|
||||
* @param tile tile of the depot where road vehicle is built.
|
||||
* @param e the engine to build.
|
||||
* @param data unused.
|
||||
* @param[out] ret the vehicle that has been built.
|
||||
* @return the cost of this operation or an error.
|
||||
*/
|
||||
CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **ret)
|
||||
CommandCost CmdBuildRoadVehicle(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
{
|
||||
/* Check that the vehicle can drive on the road in question */
|
||||
RoadType rt = e->u.road.roadtype;
|
||||
@@ -294,7 +295,6 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin
|
||||
v->reliability = e->reliability;
|
||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||
v->max_age = e->GetLifeLengthInDays();
|
||||
_new_vehicle_id = v->index;
|
||||
|
||||
v->SetServiceInterval(Company::Get(v->owner)->settings.vehicle.servint_roadveh);
|
||||
|
||||
@@ -359,16 +359,13 @@ bool RoadVehicle::FindClosestDepot(TileIndex *location, DestinationID *destinati
|
||||
|
||||
/**
|
||||
* Turn a roadvehicle around.
|
||||
* @param tile unused
|
||||
* @param flags operation to perform
|
||||
* @param p1 vehicle ID to turn
|
||||
* @param p2 unused
|
||||
* @param text unused
|
||||
* @param veh_id vehicle ID to turn
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
||||
CommandCost CmdTurnRoadVeh(DoCommandFlag flags, VehicleID veh_id)
|
||||
{
|
||||
RoadVehicle *v = RoadVehicle::GetIfValid(p1);
|
||||
RoadVehicle *v = RoadVehicle::GetIfValid(veh_id);
|
||||
if (v == nullptr) return CMD_ERROR;
|
||||
|
||||
if (!v->IsPrimaryVehicle()) return CMD_ERROR;
|
||||
@@ -553,7 +550,13 @@ static void RoadVehCrash(RoadVehicle *v)
|
||||
|
||||
SetDParam(0, pass);
|
||||
StringID newsitem = (pass == 1) ? STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER : STR_NEWS_ROAD_VEHICLE_CRASH;
|
||||
AddTileNewsItem(newsitem, NT_ACCIDENT, v->tile);
|
||||
NewsType newstype = NT_ACCIDENT;
|
||||
|
||||
if (v->owner != _local_company) {
|
||||
newstype = NT_ACCIDENT_OTHER;
|
||||
}
|
||||
|
||||
AddTileNewsItem(newsitem, newstype, v->tile);
|
||||
|
||||
ModifyStationRatingAround(v->tile, v->owner, -160, 22);
|
||||
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
||||
@@ -1127,7 +1130,7 @@ static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadType rt, RoadB
|
||||
/* The 'current' company is not necessarily the owner of the vehicle. */
|
||||
Backup<CompanyID> cur_company(_current_company, c, FILE_LINE);
|
||||
|
||||
CommandCost ret = DoCommand(t, rt << 4 | r, 0, DC_NO_WATER, CMD_BUILD_ROAD);
|
||||
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(DC_NO_WATER, t, r, rt, DRD_NONE, 0);
|
||||
|
||||
cur_company.Restore();
|
||||
return ret.Succeeded();
|
||||
@@ -1277,9 +1280,12 @@ again:
|
||||
|
||||
Direction new_dir = RoadVehGetSlidingDirection(v, x, y);
|
||||
if (v->IsFrontEngine()) {
|
||||
Vehicle *u = RoadVehFindCloseTo(v, x, y, new_dir);
|
||||
const Vehicle *u = RoadVehFindCloseTo(v, x, y, new_dir);
|
||||
if (u != nullptr) {
|
||||
v->cur_speed = u->First()->cur_speed;
|
||||
/* We might be blocked, prevent pathfinding rerun as we already know where we are heading to. */
|
||||
v->path.tile.push_front(tile);
|
||||
v->path.td.push_front(dir);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1389,15 +1395,15 @@ again:
|
||||
int y = TileY(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].y;
|
||||
|
||||
Direction new_dir = RoadVehGetSlidingDirection(v, x, y);
|
||||
if (v->IsFrontEngine() && RoadVehFindCloseTo(v, x, y, new_dir) != nullptr) {
|
||||
/* We are blocked. */
|
||||
v->cur_speed = 0;
|
||||
if (!v->path.empty()) {
|
||||
/* Prevent pathfinding rerun as we already know where we are heading to. */
|
||||
if (v->IsFrontEngine()) {
|
||||
const Vehicle *u = RoadVehFindCloseTo(v, x, y, new_dir);
|
||||
if (u != nullptr) {
|
||||
v->cur_speed = u->First()->cur_speed;
|
||||
/* We might be blocked, prevent pathfinding rerun as we already know where we are heading to. */
|
||||
v->path.tile.push_front(v->tile);
|
||||
v->path.td.push_front(dir);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 r = VehicleEnterTile(v, v->tile, x, y);
|
||||
|
||||
Reference in New Issue
Block a user