mirror of https://github.com/OpenTTD/OpenTTD
(svn r22600) [1.1] -Backport from trunk:
- Fix: PBS order forecasting modified the current order index in case of a goto-nearest-depot order and no depot could be found [FS#4641] (r22589) - Fix: Remove BaseStorageArrays from _changed_storage_arrays on destruction (r22583, r22551) - Fix: Do not increment STL iterators after they've been invalidated (r22582) - Fix: Do not lower the arrow buttons in the NewGRF/AI parameter windows if they are clicked when disabled (r22553, r22499)release/1.1
parent
5cb560d4bd
commit
0b02b285a8
|
@ -374,6 +374,7 @@ struct AISettingsWindow : public Window {
|
|||
/* One of the arrows is clicked (or green/red rect in case of bool value) */
|
||||
if (IsInsideMM(x, 0, 21)) {
|
||||
int new_val = this->ai_config->GetSetting(config_item.name);
|
||||
int old_val = new_val;
|
||||
if (bool_item) {
|
||||
new_val = !new_val;
|
||||
} else if (x >= 10) {
|
||||
|
@ -388,18 +389,19 @@ struct AISettingsWindow : public Window {
|
|||
this->clicked_increase = false;
|
||||
}
|
||||
|
||||
this->ai_config->SetSetting(config_item.name, new_val);
|
||||
this->clicked_button = num;
|
||||
this->timeout = 5;
|
||||
if (new_val != old_val) {
|
||||
this->ai_config->SetSetting(config_item.name, new_val);
|
||||
this->clicked_button = num;
|
||||
this->timeout = 5;
|
||||
|
||||
this->CheckDifficultyLevel();
|
||||
this->CheckDifficultyLevel();
|
||||
}
|
||||
} else if (!bool_item) {
|
||||
/* Display a query box so users can enter a custom value. */
|
||||
this->clicked_row = num;
|
||||
SetDParam(0, this->ai_config->GetSetting(config_item.name));
|
||||
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, 100, this, CS_NUMERAL, QSF_NONE);
|
||||
}
|
||||
|
||||
this->SetDirty();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ void CargoList<Tinst>::Truncate(uint max_remaining)
|
|||
CargoPacket *cp = *it;
|
||||
if (max_remaining == 0) {
|
||||
/* Nothing should remain, just remove the packets. */
|
||||
this->packets.erase(it++);
|
||||
it = this->packets.erase(it);
|
||||
static_cast<Tinst *>(this)->RemoveFromCache(cp);
|
||||
delete cp;
|
||||
continue;
|
||||
|
@ -276,7 +276,7 @@ bool CargoList<Tinst>::MoveTo(Tother_inst *dest, uint max_move, MoveToAction mta
|
|||
if (cp->count <= max_move) {
|
||||
/* Can move the complete packet */
|
||||
max_move -= cp->count;
|
||||
this->packets.erase(it++);
|
||||
it = this->packets.erase(it);
|
||||
static_cast<Tinst *>(this)->RemoveFromCache(cp);
|
||||
switch (mta) {
|
||||
case MTA_FINAL_DELIVERY:
|
||||
|
|
|
@ -325,6 +325,7 @@ struct NewGRFParametersWindow : public Window {
|
|||
/* One of the arrows is clicked */
|
||||
if (IsInsideMM(x, 0, 21)) {
|
||||
uint32 val = par_info->GetValue(this->grf_config);
|
||||
uint32 old_val = val;
|
||||
if (par_info->type == PTYPE_BOOL) {
|
||||
val = !val;
|
||||
} else {
|
||||
|
@ -338,16 +339,17 @@ struct NewGRFParametersWindow : public Window {
|
|||
this->clicked_increase = false;
|
||||
}
|
||||
}
|
||||
par_info->SetValue(this->grf_config, val);
|
||||
if (val != old_val) {
|
||||
par_info->SetValue(this->grf_config, val);
|
||||
|
||||
this->clicked_button = num;
|
||||
this->timeout = 5;
|
||||
this->clicked_button = num;
|
||||
this->timeout = 5;
|
||||
}
|
||||
} else if (par_info->type == PTYPE_UINT_ENUM && click_count >= 2) {
|
||||
/* Display a query box so users can enter a custom value. */
|
||||
SetDParam(0, this->grf_config->param[num]);
|
||||
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, 100, this, CS_NUMERAL, QSF_NONE);
|
||||
}
|
||||
|
||||
this->SetDirty();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,15 @@
|
|||
#include <set>
|
||||
|
||||
/** The changed storage arrays */
|
||||
static std::set<BaseStorageArray*> _changed_storage_arrays;
|
||||
static std::set<BaseStorageArray*> *_changed_storage_arrays = new std::set<BaseStorageArray*>;
|
||||
|
||||
/**
|
||||
* Remove references to use.
|
||||
*/
|
||||
BaseStorageArray::~BaseStorageArray()
|
||||
{
|
||||
_changed_storage_arrays->erase(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the changed storage array to the list of changed arrays.
|
||||
|
@ -24,7 +32,7 @@ static std::set<BaseStorageArray*> _changed_storage_arrays;
|
|||
*/
|
||||
void AddChangedStorage(BaseStorageArray *storage)
|
||||
{
|
||||
_changed_storage_arrays.insert(storage);
|
||||
_changed_storage_arrays->insert(storage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,10 +48,10 @@ void AddChangedStorage(BaseStorageArray *storage)
|
|||
void ClearStorageChanges(bool keep_changes)
|
||||
{
|
||||
/* Loop over all changes arrays */
|
||||
for (std::set<BaseStorageArray*>::iterator it = _changed_storage_arrays.begin(); it != _changed_storage_arrays.end(); it++) {
|
||||
for (std::set<BaseStorageArray*>::iterator it = _changed_storage_arrays->begin(); it != _changed_storage_arrays->end(); it++) {
|
||||
(*it)->ClearChanges(keep_changes);
|
||||
}
|
||||
|
||||
/* And then clear that array */
|
||||
_changed_storage_arrays.clear();
|
||||
_changed_storage_arrays->clear();
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
*/
|
||||
struct BaseStorageArray
|
||||
{
|
||||
/** The needed destructor */
|
||||
virtual ~BaseStorageArray() {}
|
||||
virtual ~BaseStorageArray();
|
||||
|
||||
/**
|
||||
* Clear the changes made since the last ClearChanges.
|
||||
|
|
|
@ -1807,8 +1807,9 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v)
|
|||
* @param order the order the vehicle currently has
|
||||
* @param v the vehicle to update
|
||||
* @param conditional_depth the depth (amount of steps) to go with conditional orders. This to prevent infinite loops.
|
||||
* @param pbs_look_ahead Whether we are forecasting orders for pbs reservations in advance. If true, the order indices must not be modified.
|
||||
*/
|
||||
bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth)
|
||||
bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool pbs_look_ahead)
|
||||
{
|
||||
if (conditional_depth > v->GetNumOrders()) return false;
|
||||
|
||||
|
@ -1819,6 +1820,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth)
|
|||
|
||||
case OT_GOTO_DEPOT:
|
||||
if ((order->GetDepotOrderType() & ODTFB_SERVICE) && !v->NeedsServicing()) {
|
||||
assert(!pbs_look_ahead);
|
||||
UpdateVehicleTimetable(v, true);
|
||||
v->IncrementRealOrderIndex();
|
||||
break;
|
||||
|
@ -1831,6 +1833,9 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth)
|
|||
bool reverse;
|
||||
|
||||
if (v->FindClosestDepot(&location, &destination, &reverse)) {
|
||||
/* PBS reservations cannot reverse */
|
||||
if (pbs_look_ahead && reverse) return false;
|
||||
|
||||
v->dest_tile = location;
|
||||
v->current_order.MakeGoToDepot(destination, v->current_order.GetDepotOrderType(), v->current_order.GetNonStopType(), (OrderDepotActionFlags)(v->current_order.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT), v->current_order.GetRefitCargo(), v->current_order.GetRefitSubtype());
|
||||
|
||||
|
@ -1848,6 +1853,9 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth)
|
|||
return true;
|
||||
}
|
||||
|
||||
/* If there is no depot, we cannot help PBS either. */
|
||||
if (pbs_look_ahead) return false;
|
||||
|
||||
UpdateVehicleTimetable(v, true);
|
||||
v->IncrementRealOrderIndex();
|
||||
} else {
|
||||
|
@ -1863,6 +1871,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth)
|
|||
return true;
|
||||
|
||||
case OT_CONDITIONAL: {
|
||||
assert(!pbs_look_ahead);
|
||||
VehicleOrderID next_order = ProcessConditionalOrder(order, v);
|
||||
if (next_order != INVALID_VEH_ORDER_ID) {
|
||||
/* Jump to next_order. cur_implicit_order_index becomes exactly that order,
|
||||
|
@ -1907,7 +1916,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth)
|
|||
}
|
||||
|
||||
v->current_order = *order;
|
||||
return UpdateOrderDest(v, order, conditional_depth + 1);
|
||||
return UpdateOrderDest(v, order, conditional_depth + 1, pbs_look_ahead);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@ void InvalidateVehicleOrder(const Vehicle *v, int data);
|
|||
void CheckOrders(const Vehicle*);
|
||||
void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist = false, bool reset_order_indices = true);
|
||||
bool ProcessOrders(Vehicle *v);
|
||||
bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth = 0);
|
||||
bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth = 0, bool pbs_look_ahead = false);
|
||||
VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v);
|
||||
|
||||
void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int left, int middle, int right);
|
||||
|
|
|
@ -2340,8 +2340,7 @@ public:
|
|||
case OT_GOTO_STATION:
|
||||
case OT_GOTO_WAYPOINT:
|
||||
this->v->current_order = *order;
|
||||
UpdateOrderDest(this->v, order);
|
||||
return true;
|
||||
return UpdateOrderDest(this->v, order, 0, true);
|
||||
case OT_CONDITIONAL: {
|
||||
if (conditional_depth > this->v->GetNumOrders()) return false;
|
||||
VehicleOrderID next = ProcessConditionalOrder(order, this->v);
|
||||
|
|
Loading…
Reference in New Issue