Merge branch 'master' into jgrpp

# Conflicts:
#	config.lib
pull/8/head
Jonathan G Rennison 8 years ago
commit 655b329142

@ -1428,6 +1428,12 @@ make_compiler_cflags() {
CFLAGS="$CFLAGS -DCUSTOM_ALLOCATOR"
fi
if [ $cc_version -ge 60 ]; then
# -flifetime-dse=2 (default since GCC 6) doesn't play
# well with our custom pool item allocator
cxxflags="$cxxflags -flifetime-dse=1"
fi
if [ "$enable_lto" != "0" ]; then
# GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
has_lto=`$1 -dumpspecs | grep '\%{flto'`

@ -665,7 +665,8 @@ struct DepotWindow : Window {
DepotSortList(&this->vehicle_list);
uint new_unitnumber_digits = GetUnitNumberDigits(this->vehicle_list);
if (this->unitnumber_digits != new_unitnumber_digits) {
/* Only increase the size; do not decrease to prevent constant changes */
if (this->unitnumber_digits < new_unitnumber_digits) {
this->unitnumber_digits = new_unitnumber_digits;
this->ReInit();
}

@ -1328,7 +1328,8 @@ static uint GetLoadAmount(Vehicle *v)
/* Scale load amount the same as capacity */
if (HasBit(e->info.misc_flags, EF_NO_DEFAULT_CARGO_MULTIPLIER) && !air_mail) load_amount = CeilDiv(load_amount * CargoSpec::Get(v->cargo_type)->multiplier, 0x100);
return load_amount;
/* Zero load amount breaks a lot of things. */
return max(1u, load_amount);
}
/**
@ -1662,6 +1663,7 @@ static void LoadUnloadVehicle(Vehicle *front)
uint amount_unloaded = _settings_game.order.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here?
assert(payment != NULL);
payment->SetCargo(v->cargo_type);
if (!HasBit(ge->status, GoodsEntry::GES_ACCEPTANCE) && v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER) > 0) {

@ -438,29 +438,34 @@ public:
return true;
}
static bool stFindNearestDepot(const RoadVehicle *v, TileIndex tile, Trackdir td, int max_distance, TileIndex *depot_tile)
static FindDepotData stFindNearestDepot(const RoadVehicle *v, TileIndex tile, Trackdir td, int max_distance)
{
Tpf pf;
return pf.FindNearestDepot(v, tile, td, max_distance, depot_tile);
return pf.FindNearestDepot(v, tile, td, max_distance);
}
inline bool FindNearestDepot(const RoadVehicle *v, TileIndex tile, Trackdir td, int max_distance, TileIndex *depot_tile)
/**
* Find the best depot for a road vehicle.
* @param v Vehicle
* @param tile Tile of the vehicle.
* @param td Trackdir of the vehicle.
* @param max_distance max length (penalty) for paths.
* @todo max_distance not used by YAPF for road vehicles.
* It can be removed or copy the SetMaxCost() strategy
* applied in YAPF for rail. The best depot can be at
* a distance greater than max_distance.
*/
inline FindDepotData FindNearestDepot(const RoadVehicle *v, TileIndex tile, Trackdir td, int max_distance)
{
/* set origin and destination nodes */
/* Set origin. */
Yapf().SetOrigin(tile, TrackdirToTrackdirBits(td));
/* find the best path */
bool bFound = Yapf().FindPath(v);
if (!bFound) return false;
/* Find the best path and return if no depot is found. */
if (!Yapf().FindPath(v)) return FindDepotData();
/* some path found
* get found depot tile */
/* Return the cost of the best path and its depot. */
Node *n = Yapf().GetBestNode();
if (max_distance > 0 && n->m_cost > max_distance * YAPF_TILE_LENGTH) return false;
*depot_tile = n->m_segment_last_tile;
return true;
return FindDepotData(n->m_segment_last_tile, n->m_cost);
}
};
@ -512,7 +517,7 @@ FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_dist
}
/* default is YAPF type 2 */
typedef bool (*PfnFindNearestDepot)(const RoadVehicle*, TileIndex, Trackdir, int, TileIndex*);
typedef FindDepotData (*PfnFindNearestDepot)(const RoadVehicle*, TileIndex, Trackdir, int);
PfnFindNearestDepot pfnFindNearestDepot = &CYapfRoadAnyDepot2::stFindNearestDepot;
/* check if non-default YAPF type should be used */
@ -520,8 +525,5 @@ FindDepotData YapfRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_dist
pfnFindNearestDepot = &CYapfRoadAnyDepot1::stFindNearestDepot; // Trackdir, allow 90-deg
}
FindDepotData fdd;
bool ret = pfnFindNearestDepot(v, tile, trackdir, max_distance, &fdd.tile);
fdd.best_length = ret ? max_distance / 2 : UINT_MAX; // some fake distance or NOT_FOUND
return fdd;
return pfnFindNearestDepot(v, tile, trackdir, max_distance);
}

@ -11,6 +11,7 @@
#include "../../stdafx.h"
#include "script_list.hpp"
#include "script_controller.hpp"
#include "../../debug.h"
#include "../../script/squirrel.hpp"
@ -905,6 +906,16 @@ SQInteger ScriptList::Valuate(HSQUIRRELVM vm)
}
}
/* Kill the script when the valuator call takes way too long.
* Triggered by nesting valuators, which then take billions of iterations. */
if (ScriptController::GetOpsTillSuspend() < -1000000) {
/* See below for explanation. The extra pop is the return value. */
sq_pop(vm, nparam + 4);
ScriptObject::SetAllowDoCommand(backup_allow);
return sq_throwerror(vm, "excessive CPU usage in valuator function");
}
/* Was something changed? */
if (previous_modification_count != this->modifications) {
/* See below for explanation. The extra pop is the return value. */

@ -283,7 +283,7 @@ uint Vehicle::Crash(bool flooded)
SetWindowDirty(WC_VEHICLE_DEPOT, this->tile);
delete this->cargo_payment;
this->cargo_payment = NULL;
assert(this->cargo_payment == NULL); // cleared by ~CargoPayment
return RandomRange(pass + 1); // Randomise deceased passengers.
}
@ -834,6 +834,7 @@ void Vehicle::PreDestructor()
HideFillingPercent(&this->fill_percent_te_id);
this->CancelReservation(INVALID_STATION, st);
delete this->cargo_payment;
assert(this->cargo_payment == NULL); // cleared by ~CargoPayment
}
if (this->IsEngineCountable()) {
@ -2493,6 +2494,7 @@ void Vehicle::LeaveStation()
assert(this->current_order.IsType(OT_LOADING));
delete this->cargo_payment;
assert(this->cargo_payment == NULL); // cleared by ~CargoPayment
/* Only update the timetable if the vehicle was supposed to stop here. */
if (this->current_order.GetNonStopType() != ONSF_STOP_EVERYWHERE) UpdateVehicleTimetable(this, false);

Loading…
Cancel
Save