Fix various formatting and spelling issues
This commit is contained in:
@@ -192,7 +192,7 @@ static bool VehicleSetNextDepartureTime(Ticks *previous_departure, Ticks *waitin
|
|||||||
|
|
||||||
static void ScheduledDispatchDepartureLocalFix(DepartureList *departure_list)
|
static void ScheduledDispatchDepartureLocalFix(DepartureList *departure_list)
|
||||||
{
|
{
|
||||||
/* Seperate departure by each shared order group */
|
/* Separate departure by each shared order group */
|
||||||
btree::btree_map<uint32_t, std::vector<Departure*>> separated_departure;
|
btree::btree_map<uint32_t, std::vector<Departure*>> separated_departure;
|
||||||
for (Departure* departure : *departure_list) {
|
for (Departure* departure : *departure_list) {
|
||||||
separated_departure[departure->vehicle->orders->index].push_back(departure);
|
separated_departure[departure->vehicle->orders->index].push_back(departure);
|
||||||
|
@@ -252,7 +252,7 @@ GroundVehicleAcceleration GroundVehicle<T, Type>::GetAcceleration()
|
|||||||
* This yields a number x on a 0-1 scale, but shifted 16 bits to the left.
|
* This yields a number x on a 0-1 scale, but shifted 16 bits to the left.
|
||||||
* We then calculate 64 + 128x, clamped to 0-255, but still shifted 16 bits to the left.
|
* We then calculate 64 + 128x, clamped to 0-255, but still shifted 16 bits to the left.
|
||||||
* Then we apply a correction for multiengine trains, and in the end we shift it 16 bits to the right to get a 0-255 number.
|
* Then we apply a correction for multiengine trains, and in the end we shift it 16 bits to the right to get a 0-255 number.
|
||||||
* @note A seperate correction for multiheaded engines is done in CheckVehicleBreakdown. We can't do that here because it would affect the whole consist.
|
* @note A separate correction for multiheaded engines is done in CheckVehicleBreakdown. We can't do that here because it would affect the whole consist.
|
||||||
*/
|
*/
|
||||||
uint64_t breakdown_factor = (uint64_t)abs(resistance) * (uint64_t)(this->cur_speed << 16);
|
uint64_t breakdown_factor = (uint64_t)abs(resistance) * (uint64_t)(this->cur_speed << 16);
|
||||||
breakdown_factor /= (std::max(force, (int64_t)100) * this->gcache.cached_max_track_speed);
|
breakdown_factor /= (std::max(force, (int64_t)100) * this->gcache.cached_max_track_speed);
|
||||||
|
@@ -1017,7 +1017,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
|||||||
|
|
||||||
SetDParam(1, order->GetConditionSkipToOrder() + 1);
|
SetDParam(1, order->GetConditionSkipToOrder() + 1);
|
||||||
const OrderConditionVariable ocv = order->GetConditionVariable();
|
const OrderConditionVariable ocv = order->GetConditionVariable();
|
||||||
/* handle some non-ordinary cases seperately */
|
/* handle some non-ordinary cases separately */
|
||||||
if (ocv == OCV_UNCONDITIONALLY) {
|
if (ocv == OCV_UNCONDITIONALLY) {
|
||||||
SetDParam(0, STR_ORDER_CONDITIONAL_UNCONDITIONAL);
|
SetDParam(0, STR_ORDER_CONDITIONAL_UNCONDITIONAL);
|
||||||
} else if (ocv == OCV_PERCENT) {
|
} else if (ocv == OCV_PERCENT) {
|
||||||
|
@@ -1123,7 +1123,7 @@ static void ShipController(Ship *v)
|
|||||||
|
|
||||||
/* Ship is back on the bridge head, we need to consume its path
|
/* Ship is back on the bridge head, we need to consume its path
|
||||||
* cache entry here as we didn't have to choose a ship track. */
|
* cache entry here as we didn't have to choose a ship track. */
|
||||||
if (!v->cached_path.empty()) v->cached_path.pop_front();
|
if (!v->cached_path.empty()) v->cached_path.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update image of ship, as well as delta XY */
|
/* update image of ship, as well as delta XY */
|
||||||
|
@@ -280,7 +280,7 @@ struct SlxiSubChunkInfo {
|
|||||||
const char *name; ///< feature name, this *IS* saved, so must be globally unique
|
const char *name; ///< feature name, this *IS* saved, so must be globally unique
|
||||||
SlxiSubChunkSaveProc *save_proc; ///< save procedure of the sub chunk, this may be nullptr in which case no extra chunk data is saved
|
SlxiSubChunkSaveProc *save_proc; ///< save procedure of the sub chunk, this may be nullptr in which case no extra chunk data is saved
|
||||||
SlxiSubChunkLoadProc *load_proc; ///< load procedure of the sub chunk, this may be nullptr in which case the extra chunk data must be missing or of 0 length
|
SlxiSubChunkLoadProc *load_proc; ///< load procedure of the sub chunk, this may be nullptr in which case the extra chunk data must be missing or of 0 length
|
||||||
const char *chunk_list; ///< this is a list of chunks that this feature uses, which should be written to the savegame, this must be a comma-seperated list of 4-character IDs, with no spaces, or nullptr
|
const char *chunk_list; ///< this is a list of chunks that this feature uses, which should be written to the savegame, this must be a comma-separated list of 4-character IDs, with no spaces, or nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
void SlXvResetState();
|
void SlXvResetState();
|
||||||
|
@@ -109,10 +109,10 @@ void ClearTraceRestrictMapping() {
|
|||||||
* Elif/orif/else may modify the stack top
|
* Elif/orif/else may modify the stack top
|
||||||
*/
|
*/
|
||||||
enum TraceRestrictCondStackFlags {
|
enum TraceRestrictCondStackFlags {
|
||||||
TRCSF_DONE_IF = 1<<0, ///< The if/elif/else is "done", future elif/else branches will not be executed
|
TRCSF_DONE_IF = 1 << 0, ///< The if/elif/else is "done", future elif/else branches will not be executed
|
||||||
TRCSF_SEEN_ELSE = 1<<1, ///< An else branch has been seen already, error if another is seen afterwards
|
TRCSF_SEEN_ELSE = 1 << 1, ///< An else branch has been seen already, error if another is seen afterwards
|
||||||
TRCSF_ACTIVE = 1<<2, ///< The condition is currently active
|
TRCSF_ACTIVE = 1 << 2, ///< The condition is currently active
|
||||||
TRCSF_PARENT_INACTIVE = 1<<3, ///< The parent condition is not active, thus this condition is also not active
|
TRCSF_PARENT_INACTIVE = 1 << 3, ///< The parent condition is not active, thus this condition is also not active
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(TraceRestrictCondStackFlags)
|
DECLARE_ENUM_AS_BIT_SET(TraceRestrictCondStackFlags)
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ static void HandleCondition(std::vector<TraceRestrictCondStackFlags> &condstack,
|
|||||||
if (condflags & TRCF_OR) {
|
if (condflags & TRCF_OR) {
|
||||||
assert(!condstack.empty());
|
assert(!condstack.empty());
|
||||||
if (condstack.back() & TRCSF_ACTIVE) {
|
if (condstack.back() & TRCSF_ACTIVE) {
|
||||||
// leave TRCSF_ACTIVE set
|
/* Leave TRCSF_ACTIVE set */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ static void HandleCondition(std::vector<TraceRestrictCondStackFlags> &condstack,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!condstack.empty() && !(condstack.back() & TRCSF_ACTIVE)) {
|
if (!condstack.empty() && !(condstack.back() & TRCSF_ACTIVE)) {
|
||||||
//this is a 'nested if', the 'parent if' is not active
|
/* This is a 'nested if', the 'parent if' is not active */
|
||||||
condstack.push_back(TRCSF_PARENT_INACTIVE);
|
condstack.push_back(TRCSF_PARENT_INACTIVE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ static bool TestOrderCondition(const Order *order, TraceRestrictItem item)
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (order) {
|
if (order != nullptr) {
|
||||||
DestinationID condvalue = GetTraceRestrictValue(item);
|
DestinationID condvalue = GetTraceRestrictValue(item);
|
||||||
switch (static_cast<TraceRestrictOrderCondAuxField>(GetTraceRestrictAuxField(item))) {
|
switch (static_cast<TraceRestrictOrderCondAuxField>(GetTraceRestrictAuxField(item))) {
|
||||||
case TROCAF_STATION:
|
case TROCAF_STATION:
|
||||||
@@ -242,7 +242,7 @@ static bool TestStationCondition(StationID station, TraceRestrictItem item)
|
|||||||
*/
|
*/
|
||||||
void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInput &input, TraceRestrictProgramResult& out) const
|
void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInput &input, TraceRestrictProgramResult& out) const
|
||||||
{
|
{
|
||||||
/* static to avoid needing to re-alloc/resize on each execution */
|
/* Static to avoid needing to re-alloc/resize on each execution */
|
||||||
static std::vector<TraceRestrictCondStackFlags> condstack;
|
static std::vector<TraceRestrictCondStackFlags> condstack;
|
||||||
condstack.clear();
|
condstack.clear();
|
||||||
|
|
||||||
@@ -264,12 +264,12 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
|||||||
if (type == TRIT_COND_ENDIF) {
|
if (type == TRIT_COND_ENDIF) {
|
||||||
assert(!condstack.empty());
|
assert(!condstack.empty());
|
||||||
if (condflags & TRCF_ELSE) {
|
if (condflags & TRCF_ELSE) {
|
||||||
// else
|
/* Else */
|
||||||
assert(!(condstack.back() & TRCSF_SEEN_ELSE));
|
assert(!(condstack.back() & TRCSF_SEEN_ELSE));
|
||||||
HandleCondition(condstack, condflags, true);
|
HandleCondition(condstack, condflags, true);
|
||||||
condstack.back() |= TRCSF_SEEN_ELSE;
|
condstack.back() |= TRCSF_SEEN_ELSE;
|
||||||
} else {
|
} else {
|
||||||
// end if
|
/* End if */
|
||||||
condstack.pop_back();
|
condstack.pop_back();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -357,7 +357,7 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
|||||||
}
|
}
|
||||||
|
|
||||||
case TRIT_COND_PBS_ENTRY_SIGNAL: {
|
case TRIT_COND_PBS_ENTRY_SIGNAL: {
|
||||||
// TRIT_COND_PBS_ENTRY_SIGNAL value type uses the next slot
|
/* TRIT_COND_PBS_ENTRY_SIGNAL value type uses the next slot */
|
||||||
i++;
|
i++;
|
||||||
TraceRestrictPBSEntrySignalAuxField mode = static_cast<TraceRestrictPBSEntrySignalAuxField>(GetTraceRestrictAuxField(item));
|
TraceRestrictPBSEntrySignalAuxField mode = static_cast<TraceRestrictPBSEntrySignalAuxField>(GetTraceRestrictAuxField(item));
|
||||||
assert(mode == TRPESAF_VEH_POS || mode == TRPESAF_RES_END || mode == TRPESAF_RES_END_TILE);
|
assert(mode == TRPESAF_VEH_POS || mode == TRPESAF_RES_END || mode == TRPESAF_RES_END_TILE);
|
||||||
@@ -388,17 +388,17 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
|||||||
}
|
}
|
||||||
|
|
||||||
case TRIT_COND_SLOT_OCCUPANCY: {
|
case TRIT_COND_SLOT_OCCUPANCY: {
|
||||||
// TRIT_COND_SLOT_OCCUPANCY value type uses the next slot
|
/* TRIT_COND_SLOT_OCCUPANCY value type uses the next slot */
|
||||||
i++;
|
i++;
|
||||||
uint32_t value = this->items[i];
|
uint32_t value = this->items[i];
|
||||||
const TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(GetTraceRestrictValue(item));
|
const TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(GetTraceRestrictValue(item));
|
||||||
switch (static_cast<TraceRestrictSlotOccupancyCondAuxField>(GetTraceRestrictAuxField(item))) {
|
switch (static_cast<TraceRestrictSlotOccupancyCondAuxField>(GetTraceRestrictAuxField(item))) {
|
||||||
case TRSOCAF_OCCUPANTS:
|
case TRSOCAF_OCCUPANTS:
|
||||||
result = TestCondition(slot != nullptr ? (uint)slot->occupants.size() : 0, condop, value);
|
result = TestCondition(slot != nullptr ? static_cast<uint>(slot->occupants.size()) : 0, condop, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRSOCAF_REMAINING:
|
case TRSOCAF_REMAINING:
|
||||||
result = TestCondition(slot != nullptr ? slot->max_occupancy - (uint)slot->occupants.size() : 0, condop, value);
|
result = TestCondition(slot != nullptr ? slot->max_occupancy - static_cast<uint>(slot->occupants.size()) : 0, condop, value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -537,7 +537,7 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
|||||||
}
|
}
|
||||||
|
|
||||||
case TRIT_COND_COUNTER_VALUE: {
|
case TRIT_COND_COUNTER_VALUE: {
|
||||||
// TRVT_COUNTER_INDEX_INT value type uses the next slot
|
/* TRVT_COUNTER_INDEX_INT value type uses the next slot */
|
||||||
i++;
|
i++;
|
||||||
uint32_t value = this->items[i];
|
uint32_t value = this->items[i];
|
||||||
const TraceRestrictCounter *ctr = TraceRestrictCounter::GetIfValid(GetTraceRestrictValue(item));
|
const TraceRestrictCounter *ctr = TraceRestrictCounter::GetIfValid(GetTraceRestrictValue(item));
|
||||||
@@ -546,7 +546,7 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
|||||||
}
|
}
|
||||||
|
|
||||||
case TRIT_COND_TIME_DATE_VALUE: {
|
case TRIT_COND_TIME_DATE_VALUE: {
|
||||||
// TRVT_TIME_DATE_INT value type uses the next slot
|
/* TRVT_TIME_DATE_INT value type uses the next slot */
|
||||||
i++;
|
i++;
|
||||||
uint32_t value = this->items[i];
|
uint32_t value = this->items[i];
|
||||||
result = TestCondition(GetTraceRestrictTimeDateValue(static_cast<TraceRestrictTimeDateValueField>(GetTraceRestrictValue(item))), condop, value);
|
result = TestCondition(GetTraceRestrictTimeDateValue(static_cast<TraceRestrictTimeDateValueField>(GetTraceRestrictValue(item))), condop, value);
|
||||||
@@ -628,7 +628,7 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
|||||||
}
|
}
|
||||||
|
|
||||||
case TRIT_COND_RESERVATION_THROUGH: {
|
case TRIT_COND_RESERVATION_THROUGH: {
|
||||||
// TRIT_COND_RESERVATION_THROUGH value type uses the next slot
|
/* TRIT_COND_RESERVATION_THROUGH value type uses the next slot */
|
||||||
i++;
|
i++;
|
||||||
uint32_t test_tile = this->items[i];
|
uint32_t test_tile = this->items[i];
|
||||||
result = TestBinaryConditionCommon(item, TrainReservationPassesThroughTile(v, test_tile));
|
result = TestBinaryConditionCommon(item, TrainReservationPassesThroughTile(v, test_tile));
|
||||||
@@ -834,7 +834,7 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TRIT_COUNTER: {
|
case TRIT_COUNTER: {
|
||||||
// TRVT_COUNTER_INDEX_INT value type uses the next slot
|
/* TRVT_COUNTER_INDEX_INT value type uses the next slot */
|
||||||
i++;
|
i++;
|
||||||
uint32_t value = this->items[i];
|
uint32_t value = this->items[i];
|
||||||
if (!(input.permitted_slot_operations & TRPISP_CHANGE_COUNTER)) break;
|
if (!(input.permitted_slot_operations & TRPISP_CHANGE_COUNTER)) break;
|
||||||
@@ -929,7 +929,7 @@ void TraceRestrictProgram::IncrementRefCount(TraceRestrictRefId ref_id)
|
|||||||
this->ref_ids.ptr_ref_ids.buffer = ptr;
|
this->ref_ids.ptr_ref_ids.buffer = ptr;
|
||||||
this->ref_ids.ptr_ref_ids.elem_capacity = 8;
|
this->ref_ids.ptr_ref_ids.elem_capacity = 8;
|
||||||
} else if (this->refcount == this->ref_ids.ptr_ref_ids.elem_capacity) {
|
} else if (this->refcount == this->ref_ids.ptr_ref_ids.elem_capacity) {
|
||||||
// grow buffer
|
/* Grow buffer */
|
||||||
this->ref_ids.ptr_ref_ids.elem_capacity *= 2;
|
this->ref_ids.ptr_ref_ids.elem_capacity *= 2;
|
||||||
this->ref_ids.ptr_ref_ids.buffer = ReallocT<TraceRestrictRefId>(this->ref_ids.ptr_ref_ids.buffer, this->ref_ids.ptr_ref_ids.elem_capacity);
|
this->ref_ids.ptr_ref_ids.buffer = ReallocT<TraceRestrictRefId>(this->ref_ids.ptr_ref_ids.buffer, this->ref_ids.ptr_ref_ids.elem_capacity);
|
||||||
}
|
}
|
||||||
@@ -979,7 +979,7 @@ void TraceRestrictProgram::DecrementRefCount(TraceRestrictRefId ref_id) {
|
|||||||
* and that all instructions have a known type, at present
|
* and that all instructions have a known type, at present
|
||||||
*/
|
*/
|
||||||
CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem> &items, TraceRestrictProgramActionsUsedFlags &actions_used_flags) {
|
CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem> &items, TraceRestrictProgramActionsUsedFlags &actions_used_flags) {
|
||||||
// static to avoid needing to re-alloc/resize on each execution
|
/* Static to avoid needing to re-alloc/resize on each execution */
|
||||||
static std::vector<TraceRestrictCondStackFlags> condstack;
|
static std::vector<TraceRestrictCondStackFlags> condstack;
|
||||||
condstack.clear();
|
condstack.clear();
|
||||||
actions_used_flags = TRPAUF_NONE;
|
actions_used_flags = TRPAUF_NONE;
|
||||||
@@ -996,7 +996,7 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
|||||||
|
|
||||||
auto validation_error = [i](StringID str) -> CommandCost {
|
auto validation_error = [i](StringID str) -> CommandCost {
|
||||||
CommandCost result(str);
|
CommandCost result(str);
|
||||||
result.SetResultData((uint)i);
|
result.SetResultData(static_cast<uint>(i));
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1004,11 +1004,11 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
|||||||
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_UNKNOWN_INSTRUCTION);
|
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_UNKNOWN_INSTRUCTION);
|
||||||
};
|
};
|
||||||
|
|
||||||
// check multi-word instructions
|
/* Check multi-word instructions */
|
||||||
if (IsTraceRestrictDoubleItem(item)) {
|
if (IsTraceRestrictDoubleItem(item)) {
|
||||||
i++;
|
i++;
|
||||||
if (i >= size) {
|
if (i >= size) {
|
||||||
return validation_error(STR_TRACE_RESTRICT_ERROR_OFFSET_TOO_LARGE); // instruction ran off end
|
return validation_error(STR_TRACE_RESTRICT_ERROR_OFFSET_TOO_LARGE); // Instruction ran off end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1017,17 +1017,17 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
|||||||
|
|
||||||
if (type == TRIT_COND_ENDIF) {
|
if (type == TRIT_COND_ENDIF) {
|
||||||
if (condstack.empty()) {
|
if (condstack.empty()) {
|
||||||
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_NO_IF); // else/endif with no starting if
|
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_NO_IF); // Else/endif with no starting if
|
||||||
}
|
}
|
||||||
if (condflags & TRCF_ELSE) {
|
if (condflags & TRCF_ELSE) {
|
||||||
// else
|
/* Else */
|
||||||
if (condstack.back() & TRCSF_SEEN_ELSE) {
|
if (condstack.back() & TRCSF_SEEN_ELSE) {
|
||||||
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_DUP_ELSE); // Two else clauses
|
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_DUP_ELSE); // Two else clauses
|
||||||
}
|
}
|
||||||
HandleCondition(condstack, condflags, true);
|
HandleCondition(condstack, condflags, true);
|
||||||
condstack.back() |= TRCSF_SEEN_ELSE;
|
condstack.back() |= TRCSF_SEEN_ELSE;
|
||||||
} else {
|
} else {
|
||||||
// end if
|
/* End if */
|
||||||
condstack.pop_back();
|
condstack.pop_back();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1036,7 +1036,7 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
|||||||
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_ELIF_NO_IF); // Pre-empt assertions in HandleCondition
|
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_ELIF_NO_IF); // Pre-empt assertions in HandleCondition
|
||||||
}
|
}
|
||||||
if (condstack.back() & TRCSF_SEEN_ELSE) {
|
if (condstack.back() & TRCSF_SEEN_ELSE) {
|
||||||
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_DUP_ELSE); // else clause followed by elif/orif
|
return validation_error(STR_TRACE_RESTRICT_ERROR_VALIDATE_DUP_ELSE); // Else clause followed by elif/orif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HandleCondition(condstack, condflags, true);
|
HandleCondition(condstack, condflags, true);
|
||||||
@@ -1077,7 +1077,7 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Validation action instruction */
|
/* Validate condition type */
|
||||||
switch (GetTraceRestrictType(item)) {
|
switch (GetTraceRestrictType(item)) {
|
||||||
case TRIT_COND_ENDIF:
|
case TRIT_COND_ENDIF:
|
||||||
case TRIT_COND_UNDEFINED:
|
case TRIT_COND_UNDEFINED:
|
||||||
@@ -1642,7 +1642,7 @@ void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GetTraceRestrictType(item) == TRIT_COND_LAST_STATION && GetTraceRestrictAuxField(item) != TROCAF_STATION) {
|
if (GetTraceRestrictType(item) == TRIT_COND_LAST_STATION && GetTraceRestrictAuxField(item) != TROCAF_STATION) {
|
||||||
// if changing type from another order type to last visited station, reset value if not currently a station
|
/* If changing type from another order type to last visited station, reset value if not currently a station */
|
||||||
SetTraceRestrictValueDefault(item, TRVT_ORDER);
|
SetTraceRestrictValueDefault(item, TRVT_ORDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1653,12 +1653,12 @@ void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItem
|
|||||||
*/
|
*/
|
||||||
void TraceRestrictSetIsSignalRestrictedBit(TileIndex t)
|
void TraceRestrictSetIsSignalRestrictedBit(TileIndex t)
|
||||||
{
|
{
|
||||||
// First mapping for this tile, or later
|
/* First mapping for this tile, or later */
|
||||||
TraceRestrictMapping::iterator lower_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t, static_cast<Track>(0)));
|
TraceRestrictMapping::iterator lower_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t, static_cast<Track>(0)));
|
||||||
|
|
||||||
bool found = (lower_bound != _tracerestrictprogram_mapping.end()) && (GetTraceRestrictRefIdTileIndex(lower_bound->first) == t);
|
bool found = (lower_bound != _tracerestrictprogram_mapping.end()) && (GetTraceRestrictRefIdTileIndex(lower_bound->first) == t);
|
||||||
|
|
||||||
// If iterators are the same, there are no mappings for this tile
|
/* If iterators are the same, there are no mappings for this tile */
|
||||||
switch (GetTileType(t)) {
|
switch (GetTileType(t)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
SetRestrictedSignal(t, found);
|
SetRestrictedSignal(t, found);
|
||||||
@@ -1683,8 +1683,8 @@ void TraceRestrictCreateProgramMapping(TraceRestrictRefId ref, TraceRestrictProg
|
|||||||
_tracerestrictprogram_mapping.insert(std::make_pair(ref, TraceRestrictMappingItem(prog->index)));
|
_tracerestrictprogram_mapping.insert(std::make_pair(ref, TraceRestrictMappingItem(prog->index)));
|
||||||
|
|
||||||
if (!insert_result.second) {
|
if (!insert_result.second) {
|
||||||
// value was not inserted, there is an existing mapping
|
/* Value was not inserted, there is an existing mapping.
|
||||||
// unref the existing mapping before updating it
|
* Unref the existing mapping before updating it. */
|
||||||
_tracerestrictprogram_pool.Get(insert_result.first->second.program_id)->DecrementRefCount(ref);
|
_tracerestrictprogram_pool.Get(insert_result.first->second.program_id)->DecrementRefCount(ref);
|
||||||
insert_result.first->second = prog->index;
|
insert_result.first->second = prog->index;
|
||||||
}
|
}
|
||||||
@@ -1705,13 +1705,13 @@ bool TraceRestrictRemoveProgramMapping(TraceRestrictRefId ref)
|
|||||||
{
|
{
|
||||||
TraceRestrictMapping::iterator iter = _tracerestrictprogram_mapping.find(ref);
|
TraceRestrictMapping::iterator iter = _tracerestrictprogram_mapping.find(ref);
|
||||||
if (iter != _tracerestrictprogram_mapping.end()) {
|
if (iter != _tracerestrictprogram_mapping.end()) {
|
||||||
// Found
|
/* Found */
|
||||||
TraceRestrictProgram *prog = _tracerestrictprogram_pool.Get(iter->second.program_id);
|
TraceRestrictProgram *prog = _tracerestrictprogram_pool.Get(iter->second.program_id);
|
||||||
|
|
||||||
bool update_reserve_through = (prog->actions_used_flags & TRPAUF_RESERVE_THROUGH_ALWAYS);
|
bool update_reserve_through = (prog->actions_used_flags & TRPAUF_RESERVE_THROUGH_ALWAYS);
|
||||||
|
|
||||||
// check to see if another mapping needs to be removed as well
|
/* Check to see if another mapping needs to be removed as well,
|
||||||
// do this before decrementing the refcount
|
* do this before decrementing the refcount */
|
||||||
bool remove_other_mapping = prog->refcount == 2 && prog->items.empty();
|
bool remove_other_mapping = prog->refcount == 2 && prog->items.empty();
|
||||||
|
|
||||||
prog->DecrementRefCount(ref);
|
prog->DecrementRefCount(ref);
|
||||||
@@ -1774,22 +1774,22 @@ void TraceRestrictCheckRefreshSingleSignal(const TraceRestrictProgram *prog, Tra
|
|||||||
*/
|
*/
|
||||||
TraceRestrictProgram *GetTraceRestrictProgram(TraceRestrictRefId ref, bool create_new)
|
TraceRestrictProgram *GetTraceRestrictProgram(TraceRestrictRefId ref, bool create_new)
|
||||||
{
|
{
|
||||||
// Optimise for lookup, creating doesn't have to be that fast
|
/* Optimise for lookup, creating doesn't have to be that fast */
|
||||||
|
|
||||||
TraceRestrictMapping::iterator iter = _tracerestrictprogram_mapping.find(ref);
|
TraceRestrictMapping::iterator iter = _tracerestrictprogram_mapping.find(ref);
|
||||||
if (iter != _tracerestrictprogram_mapping.end()) {
|
if (iter != _tracerestrictprogram_mapping.end()) {
|
||||||
// Found
|
/* Found */
|
||||||
return _tracerestrictprogram_pool.Get(iter->second.program_id);
|
return _tracerestrictprogram_pool.Get(iter->second.program_id);
|
||||||
} else if (create_new) {
|
} else if (create_new) {
|
||||||
// Not found
|
/* Not found */
|
||||||
|
|
||||||
// Create new pool item
|
/* Create new pool item */
|
||||||
if (!TraceRestrictProgram::CanAllocateItem()) {
|
if (!TraceRestrictProgram::CanAllocateItem()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
TraceRestrictProgram *prog = new TraceRestrictProgram();
|
TraceRestrictProgram *prog = new TraceRestrictProgram();
|
||||||
|
|
||||||
// Create new mapping to pool item
|
/* Create new mapping to pool item */
|
||||||
TraceRestrictCreateProgramMapping(ref, prog);
|
TraceRestrictCreateProgramMapping(ref, prog);
|
||||||
return prog;
|
return prog;
|
||||||
} else {
|
} else {
|
||||||
@@ -1803,7 +1803,7 @@ TraceRestrictProgram *GetTraceRestrictProgram(TraceRestrictRefId ref, bool creat
|
|||||||
*/
|
*/
|
||||||
TraceRestrictProgram *GetFirstTraceRestrictProgramOnTile(TileIndex t)
|
TraceRestrictProgram *GetFirstTraceRestrictProgramOnTile(TileIndex t)
|
||||||
{
|
{
|
||||||
// First mapping for this tile, or later
|
/* First mapping for this tile, or later */
|
||||||
TraceRestrictMapping::iterator lower_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t, static_cast<Track>(0)));
|
TraceRestrictMapping::iterator lower_bound = _tracerestrictprogram_mapping.lower_bound(MakeTraceRestrictRefId(t, static_cast<Track>(0)));
|
||||||
|
|
||||||
if ((lower_bound != _tracerestrictprogram_mapping.end()) && (GetTraceRestrictRefIdTileIndex(lower_bound->first) == t)) {
|
if ((lower_bound != _tracerestrictprogram_mapping.end()) && (GetTraceRestrictRefIdTileIndex(lower_bound->first) == t)) {
|
||||||
@@ -1842,7 +1842,7 @@ void TraceRestrictDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommand
|
|||||||
*/
|
*/
|
||||||
static CommandCost TraceRestrictCheckTileIsUsable(TileIndex tile, Track track)
|
static CommandCost TraceRestrictCheckTileIsUsable(TileIndex tile, Track track)
|
||||||
{
|
{
|
||||||
// Check that there actually is a signal here
|
/* Check that there actually is a signal here */
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (!IsPlainRailTile(tile) || !HasTrack(tile, track)) {
|
if (!IsPlainRailTile(tile) || !HasTrack(tile, track)) {
|
||||||
@@ -1866,7 +1866,7 @@ static CommandCost TraceRestrictCheckTileIsUsable(TileIndex tile, Track track)
|
|||||||
return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
|
return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check tile ownership, do this afterwards to avoid tripping up on house/industry tiles
|
/* Check tile ownership, do this afterwards to avoid tripping up on house/industry tiles */
|
||||||
CommandCost ret = CheckTileOwnership(tile);
|
CommandCost ret = CheckTileOwnership(tile);
|
||||||
if (ret.Failed()) {
|
if (ret.Failed()) {
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1916,10 +1916,10 @@ CommandCost TraceRestrictProgramRemoveItemAt(std::vector<TraceRestrictItem> &ite
|
|||||||
bool remove_whole_block = false;
|
bool remove_whole_block = false;
|
||||||
if (GetTraceRestrictCondFlags(old_item) == 0) {
|
if (GetTraceRestrictCondFlags(old_item) == 0) {
|
||||||
if (GetTraceRestrictType(old_item) == TRIT_COND_ENDIF) {
|
if (GetTraceRestrictType(old_item) == TRIT_COND_ENDIF) {
|
||||||
// this is an end if, can't remove these
|
/* This is an end if, can't remove these */
|
||||||
return_cmd_error(STR_TRACE_RESTRICT_ERROR_CAN_T_REMOVE_ENDIF);
|
return_cmd_error(STR_TRACE_RESTRICT_ERROR_CAN_T_REMOVE_ENDIF);
|
||||||
} else {
|
} else {
|
||||||
// this is an opening if
|
/* This is an opening if */
|
||||||
remove_whole_block = true;
|
remove_whole_block = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1928,42 +1928,42 @@ CommandCost TraceRestrictProgramRemoveItemAt(std::vector<TraceRestrictItem> &ite
|
|||||||
std::vector<TraceRestrictItem>::iterator remove_start = TraceRestrictProgram::InstructionAt(items, offset);
|
std::vector<TraceRestrictItem>::iterator remove_start = TraceRestrictProgram::InstructionAt(items, offset);
|
||||||
std::vector<TraceRestrictItem>::iterator remove_end = InstructionIteratorNext(remove_start);
|
std::vector<TraceRestrictItem>::iterator remove_end = InstructionIteratorNext(remove_start);
|
||||||
|
|
||||||
// iterate until matching end block found
|
/* Iterate until matching end block found */
|
||||||
for (; remove_end != items.end(); InstructionIteratorAdvance(remove_end)) {
|
for (; remove_end != items.end(); InstructionIteratorAdvance(remove_end)) {
|
||||||
TraceRestrictItem current_item = *remove_end;
|
TraceRestrictItem current_item = *remove_end;
|
||||||
if (IsTraceRestrictConditional(current_item)) {
|
if (IsTraceRestrictConditional(current_item)) {
|
||||||
if (GetTraceRestrictCondFlags(current_item) == 0) {
|
if (GetTraceRestrictCondFlags(current_item) == 0) {
|
||||||
if (GetTraceRestrictType(current_item) == TRIT_COND_ENDIF) {
|
if (GetTraceRestrictType(current_item) == TRIT_COND_ENDIF) {
|
||||||
// this is an end if
|
/* This is an end if */
|
||||||
recursion_depth--;
|
recursion_depth--;
|
||||||
if (recursion_depth == 0) {
|
if (recursion_depth == 0) {
|
||||||
if (remove_whole_block) {
|
if (remove_whole_block) {
|
||||||
if (shallow_mode) {
|
if (shallow_mode) {
|
||||||
// must erase endif first, as it is later in the vector
|
/* Must erase endif first, as it is later in the vector */
|
||||||
items.erase(remove_end, InstructionIteratorNext(remove_end));
|
items.erase(remove_end, InstructionIteratorNext(remove_end));
|
||||||
} else {
|
} else {
|
||||||
// inclusively remove up to here
|
/* Inclusively remove up to here */
|
||||||
InstructionIteratorAdvance(remove_end);
|
InstructionIteratorAdvance(remove_end);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// exclusively remove up to here
|
/* Exclusively remove up to here */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this is an opening if
|
/* This is an opening if */
|
||||||
recursion_depth++;
|
recursion_depth++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this is an else/or type block
|
/* This is an else/or type block */
|
||||||
if (recursion_depth == 1 && !remove_whole_block) {
|
if (recursion_depth == 1 && !remove_whole_block) {
|
||||||
// exclusively remove up to here
|
/* Exclusively remove up to here */
|
||||||
recursion_depth = 0;
|
recursion_depth = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (recursion_depth == 1 && remove_whole_block && shallow_mode) {
|
if (recursion_depth == 1 && remove_whole_block && shallow_mode) {
|
||||||
// shallow-removing whole if block, and it contains an else/or if, bail out
|
/* Shallow-removing whole if block, and it contains an else/or if, bail out */
|
||||||
return_cmd_error(STR_TRACE_RESTRICT_ERROR_CAN_T_SHALLOW_REMOVE_IF_ELIF);
|
return_cmd_error(STR_TRACE_RESTRICT_ERROR_CAN_T_SHALLOW_REMOVE_IF_ELIF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1990,7 +1990,7 @@ static CommandCost AdvanceItemEndIteratorForBlock(const std::vector<TraceRestric
|
|||||||
TraceRestrictItem old_item = *move_start;
|
TraceRestrictItem old_item = *move_start;
|
||||||
if (IsTraceRestrictConditional(old_item)) {
|
if (IsTraceRestrictConditional(old_item)) {
|
||||||
if (GetTraceRestrictType(old_item) == TRIT_COND_ENDIF) {
|
if (GetTraceRestrictType(old_item) == TRIT_COND_ENDIF) {
|
||||||
// this is an else or end if, can't move these
|
/* This is an else or end if, can't move these */
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
if (GetTraceRestrictCondFlags(old_item) != 0) {
|
if (GetTraceRestrictCondFlags(old_item) != 0) {
|
||||||
@@ -2001,41 +2001,41 @@ static CommandCost AdvanceItemEndIteratorForBlock(const std::vector<TraceRestric
|
|||||||
if (IsTraceRestrictConditional(current_item)) {
|
if (IsTraceRestrictConditional(current_item)) {
|
||||||
if (GetTraceRestrictCondFlags(current_item) == 0) {
|
if (GetTraceRestrictCondFlags(current_item) == 0) {
|
||||||
if (GetTraceRestrictType(current_item) == TRIT_COND_ENDIF) {
|
if (GetTraceRestrictType(current_item) == TRIT_COND_ENDIF) {
|
||||||
// this is an end if
|
/* This is an end if */
|
||||||
if (recursion_depth == 0) break;
|
if (recursion_depth == 0) break;
|
||||||
recursion_depth--;
|
recursion_depth--;
|
||||||
} else {
|
} else {
|
||||||
// this is an opening if
|
/* This is an opening if */
|
||||||
recursion_depth++;
|
recursion_depth++;
|
||||||
}
|
}
|
||||||
} else if (recursion_depth == 0) {
|
} else if (recursion_depth == 0) {
|
||||||
// next elif/orif
|
/* Next elif/orif */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
}
|
}
|
||||||
// can't move or/else blocks
|
/* Can't move or/else blocks */
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t recursion_depth = 1;
|
uint32_t recursion_depth = 1;
|
||||||
// iterate until matching end block found
|
/* Iterate until matching end block found */
|
||||||
for (; move_end != items.end(); InstructionIteratorAdvance(move_end)) {
|
for (; move_end != items.end(); InstructionIteratorAdvance(move_end)) {
|
||||||
TraceRestrictItem current_item = *move_end;
|
TraceRestrictItem current_item = *move_end;
|
||||||
if (IsTraceRestrictConditional(current_item)) {
|
if (IsTraceRestrictConditional(current_item)) {
|
||||||
if (GetTraceRestrictCondFlags(current_item) == 0) {
|
if (GetTraceRestrictCondFlags(current_item) == 0) {
|
||||||
if (GetTraceRestrictType(current_item) == TRIT_COND_ENDIF) {
|
if (GetTraceRestrictType(current_item) == TRIT_COND_ENDIF) {
|
||||||
// this is an end if
|
/* This is an end if */
|
||||||
recursion_depth--;
|
recursion_depth--;
|
||||||
if (recursion_depth == 0) {
|
if (recursion_depth == 0) {
|
||||||
// inclusively remove up to here
|
/* Inclusively remove up to here */
|
||||||
InstructionIteratorAdvance(move_end);
|
InstructionIteratorAdvance(move_end);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this is an opening if
|
/* This is an opening if */
|
||||||
recursion_depth++;
|
recursion_depth++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2123,20 +2123,20 @@ CommandCost CmdProgramSignalTraceRestrict(TileIndex tile, DoCommandFlag flags, u
|
|||||||
bool can_make_new = (type == TRDCT_INSERT_ITEM) && (flags & DC_EXEC);
|
bool can_make_new = (type == TRDCT_INSERT_ITEM) && (flags & DC_EXEC);
|
||||||
bool need_existing = (type != TRDCT_INSERT_ITEM);
|
bool need_existing = (type != TRDCT_INSERT_ITEM);
|
||||||
TraceRestrictProgram *prog = GetTraceRestrictProgram(MakeTraceRestrictRefId(tile, track), can_make_new);
|
TraceRestrictProgram *prog = GetTraceRestrictProgram(MakeTraceRestrictRefId(tile, track), can_make_new);
|
||||||
if (need_existing && !prog) {
|
if (need_existing && prog == nullptr) {
|
||||||
return_cmd_error(STR_TRACE_RESTRICT_ERROR_NO_PROGRAM);
|
return_cmd_error(STR_TRACE_RESTRICT_ERROR_NO_PROGRAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t offset_limit_exclusive = ((type == TRDCT_INSERT_ITEM) ? 1 : 0);
|
uint32_t offset_limit_exclusive = ((type == TRDCT_INSERT_ITEM) ? 1 : 0);
|
||||||
if (prog) offset_limit_exclusive += (uint)prog->items.size();
|
if (prog != nullptr) offset_limit_exclusive += static_cast<uint>(prog->items.size());
|
||||||
|
|
||||||
if (offset >= offset_limit_exclusive) {
|
if (offset >= offset_limit_exclusive) {
|
||||||
return_cmd_error(STR_TRACE_RESTRICT_ERROR_OFFSET_TOO_LARGE);
|
return_cmd_error(STR_TRACE_RESTRICT_ERROR_OFFSET_TOO_LARGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy program
|
/* Copy program */
|
||||||
std::vector<TraceRestrictItem> items;
|
std::vector<TraceRestrictItem> items;
|
||||||
if (prog) items = prog->items;
|
if (prog != nullptr) items = prog->items;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TRDCT_INSERT_ITEM:
|
case TRDCT_INSERT_ITEM:
|
||||||
@@ -2144,7 +2144,7 @@ CommandCost CmdProgramSignalTraceRestrict(TileIndex tile, DoCommandFlag flags, u
|
|||||||
if (IsTraceRestrictConditional(item) &&
|
if (IsTraceRestrictConditional(item) &&
|
||||||
GetTraceRestrictCondFlags(item) == 0 &&
|
GetTraceRestrictCondFlags(item) == 0 &&
|
||||||
GetTraceRestrictType(item) != TRIT_COND_ENDIF) {
|
GetTraceRestrictType(item) != TRIT_COND_ENDIF) {
|
||||||
// this is an opening if block, insert a corresponding end if
|
/* This is an opening if block, insert a corresponding end if */
|
||||||
TraceRestrictItem endif_item = 0;
|
TraceRestrictItem endif_item = 0;
|
||||||
SetTraceRestrictType(endif_item, TRIT_COND_ENDIF);
|
SetTraceRestrictType(endif_item, TRIT_COND_ENDIF);
|
||||||
items.insert(TraceRestrictProgram::InstructionAt(items, offset) + 1, endif_item);
|
items.insert(TraceRestrictProgram::InstructionAt(items, offset) + 1, endif_item);
|
||||||
@@ -2211,25 +2211,25 @@ CommandCost CmdProgramSignalTraceRestrict(TileIndex tile, DoCommandFlag flags, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
assert(prog);
|
assert(prog != nullptr);
|
||||||
|
|
||||||
size_t old_size = prog->items.size();
|
size_t old_size = prog->items.size();
|
||||||
TraceRestrictProgramActionsUsedFlags old_actions_used_flags = prog->actions_used_flags;
|
TraceRestrictProgramActionsUsedFlags old_actions_used_flags = prog->actions_used_flags;
|
||||||
|
|
||||||
// move in modified program
|
/* Move in modified program */
|
||||||
prog->items.swap(items);
|
prog->items.swap(items);
|
||||||
prog->actions_used_flags = actions_used_flags;
|
prog->actions_used_flags = actions_used_flags;
|
||||||
|
|
||||||
if (prog->items.size() == 0 && prog->refcount == 1) {
|
if (prog->items.size() == 0 && prog->refcount == 1) {
|
||||||
// program is empty, and this tile is the only reference to it
|
/* Program is empty, and this tile is the only reference to it,
|
||||||
// so delete it, as it's redundant
|
* so delete it, as it's redundant */
|
||||||
TraceRestrictCheckRefreshSingleSignal(prog, MakeTraceRestrictRefId(tile, track), old_actions_used_flags);
|
TraceRestrictCheckRefreshSingleSignal(prog, MakeTraceRestrictRefId(tile, track), old_actions_used_flags);
|
||||||
TraceRestrictRemoveProgramMapping(MakeTraceRestrictRefId(tile, track));
|
TraceRestrictRemoveProgramMapping(MakeTraceRestrictRefId(tile, track));
|
||||||
} else {
|
} else {
|
||||||
TraceRestrictCheckRefreshSignals(prog, old_size, old_actions_used_flags);
|
TraceRestrictCheckRefreshSignals(prog, old_size, old_actions_used_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2303,10 +2303,10 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag
|
|||||||
TraceRestrictRemoveProgramMapping(self);
|
TraceRestrictRemoveProgramMapping(self);
|
||||||
|
|
||||||
TraceRestrictProgram *source_prog = GetTraceRestrictProgram(source, false);
|
TraceRestrictProgram *source_prog = GetTraceRestrictProgram(source, false);
|
||||||
if (source_prog && !source_prog->items.empty()) {
|
if (source_prog != nullptr && !source_prog->items.empty()) {
|
||||||
TraceRestrictProgram *prog = GetTraceRestrictProgram(self, true);
|
TraceRestrictProgram *prog = GetTraceRestrictProgram(self, true);
|
||||||
if (!prog) {
|
if (prog == nullptr) {
|
||||||
// allocation failed
|
/* Allocation failed */
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
prog->items = source_prog->items; // copy
|
prog->items = source_prog->items; // copy
|
||||||
@@ -2319,10 +2319,10 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag
|
|||||||
|
|
||||||
case TRDCT_PROG_COPY_APPEND: {
|
case TRDCT_PROG_COPY_APPEND: {
|
||||||
TraceRestrictProgram *source_prog = GetTraceRestrictProgram(source, false);
|
TraceRestrictProgram *source_prog = GetTraceRestrictProgram(source, false);
|
||||||
if (source_prog && !source_prog->items.empty()) {
|
if (source_prog != nullptr && !source_prog->items.empty()) {
|
||||||
TraceRestrictProgram *prog = GetTraceRestrictProgram(self, true);
|
TraceRestrictProgram *prog = GetTraceRestrictProgram(self, true);
|
||||||
if (!prog) {
|
if (prog == nullptr) {
|
||||||
// allocation failed
|
/* Allocation failed */
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2342,8 +2342,8 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag
|
|||||||
case TRDCT_PROG_SHARE_IF_UNMAPPED: {
|
case TRDCT_PROG_SHARE_IF_UNMAPPED: {
|
||||||
TraceRestrictRemoveProgramMapping(self);
|
TraceRestrictRemoveProgramMapping(self);
|
||||||
TraceRestrictProgram *source_prog = GetTraceRestrictProgram(source, true);
|
TraceRestrictProgram *source_prog = GetTraceRestrictProgram(source, true);
|
||||||
if (!source_prog) {
|
if (source_prog == nullptr) {
|
||||||
// allocation failed
|
/* Allocation failed */
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2355,18 +2355,18 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag
|
|||||||
case TRDCT_PROG_UNSHARE: {
|
case TRDCT_PROG_UNSHARE: {
|
||||||
std::vector<TraceRestrictItem> items;
|
std::vector<TraceRestrictItem> items;
|
||||||
TraceRestrictProgram *prog = GetTraceRestrictProgram(self, false);
|
TraceRestrictProgram *prog = GetTraceRestrictProgram(self, false);
|
||||||
if (prog) {
|
if (prog != nullptr) {
|
||||||
// copy program into temporary
|
/* Copy program into temporary */
|
||||||
items = prog->items;
|
items = prog->items;
|
||||||
}
|
}
|
||||||
// remove old program
|
/* Remove old program */
|
||||||
TraceRestrictRemoveProgramMapping(self);
|
TraceRestrictRemoveProgramMapping(self);
|
||||||
|
|
||||||
if (items.size()) {
|
if (items.size() > 0) {
|
||||||
// if prog is non-empty, create new program and move temporary in
|
/* If prog is non-empty, create new program and move temporary in */
|
||||||
TraceRestrictProgram *new_prog = GetTraceRestrictProgram(self, true);
|
TraceRestrictProgram *new_prog = GetTraceRestrictProgram(self, true);
|
||||||
if (!new_prog) {
|
if (new_prog == nullptr) {
|
||||||
// allocation failed
|
/* Allocation failed */
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2386,7 +2386,7 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag
|
|||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
|
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
@@ -2466,7 +2466,7 @@ void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2486,7 +2486,7 @@ void TraceRestrictRemoveGroupID(GroupID index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2529,7 +2529,7 @@ void TraceRestrictUpdateCompanyID(CompanyID old_company, CompanyID new_company)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS);
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_COUNTERS);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT_COUNTERS);
|
||||||
@@ -2870,7 +2870,7 @@ void TraceRestrictRemoveSlotID(TraceRestrictSlotID index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
if (changed_order) {
|
if (changed_order) {
|
||||||
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
||||||
@@ -2920,7 +2920,7 @@ CommandCost CmdCreateTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint
|
|||||||
TraceRestrictSlot *slot = new TraceRestrictSlot(_current_company, vehtype);
|
TraceRestrictSlot *slot = new TraceRestrictSlot(_current_company, vehtype);
|
||||||
slot->name = text;
|
slot->name = text;
|
||||||
|
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS);
|
||||||
}
|
}
|
||||||
@@ -2945,7 +2945,7 @@ CommandCost CmdDeleteTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint
|
|||||||
if (slot == nullptr || slot->owner != _current_company) return CMD_ERROR;
|
if (slot == nullptr || slot->owner != _current_company) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
/* notify tracerestrict that group is about to be deleted */
|
/* Notify tracerestrict that group is about to be deleted */
|
||||||
TraceRestrictRemoveSlotID(slot->index);
|
TraceRestrictRemoveSlotID(slot->index);
|
||||||
|
|
||||||
delete slot;
|
delete slot;
|
||||||
@@ -2997,7 +2997,7 @@ CommandCost CmdAlterTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint3
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT_SLOTS);
|
||||||
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
||||||
@@ -3127,7 +3127,7 @@ void TraceRestrictRemoveCounterID(TraceRestrictCounterID index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
if (changed_order) {
|
if (changed_order) {
|
||||||
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
||||||
@@ -3165,7 +3165,7 @@ CommandCost CmdCreateTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, u
|
|||||||
TraceRestrictCounter *ctr = new TraceRestrictCounter(_current_company);
|
TraceRestrictCounter *ctr = new TraceRestrictCounter(_current_company);
|
||||||
ctr->name = text;
|
ctr->name = text;
|
||||||
|
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_COUNTERS);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT_COUNTERS);
|
||||||
}
|
}
|
||||||
@@ -3190,7 +3190,7 @@ CommandCost CmdDeleteTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, u
|
|||||||
if (ctr == nullptr || ctr->owner != _current_company) return CMD_ERROR;
|
if (ctr == nullptr || ctr->owner != _current_company) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
/* notify tracerestrict that counter is about to be deleted */
|
/* Notify tracerestrict that counter is about to be deleted */
|
||||||
TraceRestrictRemoveCounterID(ctr->index);
|
TraceRestrictRemoveCounterID(ctr->index);
|
||||||
|
|
||||||
delete ctr;
|
delete ctr;
|
||||||
@@ -3241,7 +3241,7 @@ CommandCost CmdAlterTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
// update windows
|
/* Update windows */
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT_COUNTERS);
|
InvalidateWindowClassesData(WC_TRACE_RESTRICT_COUNTERS);
|
||||||
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
InvalidateWindowClassesData(WC_VEHICLE_ORDERS);
|
||||||
|
@@ -601,7 +601,7 @@ private:
|
|||||||
TraceRestrictRefId inline_ref_ids[4];
|
TraceRestrictRefId inline_ref_ids[4];
|
||||||
ptr_buffer ptr_ref_ids;
|
ptr_buffer ptr_ref_ids;
|
||||||
|
|
||||||
// Actual construction/destruction done by struct TraceRestrictProgram
|
/* Actual construction/destruction done by struct TraceRestrictProgram */
|
||||||
refid_list_union() {}
|
refid_list_union() {}
|
||||||
~refid_list_union() {}
|
~refid_list_union() {}
|
||||||
};
|
};
|
||||||
|
@@ -103,25 +103,25 @@ enum TraceRestrictWindowWidgets {
|
|||||||
|
|
||||||
/** Selection mappings for NWID_SELECTION selectors */
|
/** Selection mappings for NWID_SELECTION selectors */
|
||||||
enum PanelWidgets {
|
enum PanelWidgets {
|
||||||
// Left 2
|
/* Left 2 */
|
||||||
DPL2_TYPE = 0,
|
DPL2_TYPE = 0,
|
||||||
DPL2_CONDFLAGS,
|
DPL2_CONDFLAGS,
|
||||||
DPL2_BLANK,
|
DPL2_BLANK,
|
||||||
|
|
||||||
// Left
|
/* Left */
|
||||||
DPL_TYPE = 0,
|
DPL_TYPE = 0,
|
||||||
DPL_COUNTER_OP,
|
DPL_COUNTER_OP,
|
||||||
DPL_BLANK,
|
DPL_BLANK,
|
||||||
|
|
||||||
// Left aux
|
/* Left aux */
|
||||||
DPLA_DROPDOWN = 0,
|
DPLA_DROPDOWN = 0,
|
||||||
|
|
||||||
// Middle
|
/* Middle */
|
||||||
DPM_COMPARATOR = 0,
|
DPM_COMPARATOR = 0,
|
||||||
DPM_SLOT_OP,
|
DPM_SLOT_OP,
|
||||||
DPM_BLANK,
|
DPM_BLANK,
|
||||||
|
|
||||||
// Right
|
/* Right */
|
||||||
DPR_VALUE_INT = 0,
|
DPR_VALUE_INT = 0,
|
||||||
DPR_VALUE_DECIMAL,
|
DPR_VALUE_DECIMAL,
|
||||||
DPR_VALUE_DROPDOWN,
|
DPR_VALUE_DROPDOWN,
|
||||||
@@ -130,12 +130,12 @@ enum PanelWidgets {
|
|||||||
DPR_VALUE_TILE,
|
DPR_VALUE_TILE,
|
||||||
DPR_BLANK,
|
DPR_BLANK,
|
||||||
|
|
||||||
// Share
|
/* Share */
|
||||||
DPS_SHARE = 0,
|
DPS_SHARE = 0,
|
||||||
DPS_UNSHARE,
|
DPS_UNSHARE,
|
||||||
DPS_SHARE_ONTO,
|
DPS_SHARE_ONTO,
|
||||||
|
|
||||||
// Copy
|
/* Copy */
|
||||||
DPC_COPY = 0,
|
DPC_COPY = 0,
|
||||||
DPC_APPEND,
|
DPC_APPEND,
|
||||||
DPC_DUPLICATE,
|
DPC_DUPLICATE,
|
||||||
@@ -660,8 +660,7 @@ static DropDownList GetGroupDropDownList(Owner owner, GroupID group_id, int &sel
|
|||||||
if (group_id == DEFAULT_GROUP) selected = DEFAULT_GROUP;
|
if (group_id == DEFAULT_GROUP) selected = DEFAULT_GROUP;
|
||||||
dlist.push_back(MakeDropDownListStringItem(STR_GROUP_DEFAULT_TRAINS, DEFAULT_GROUP, false));
|
dlist.push_back(MakeDropDownListStringItem(STR_GROUP_DEFAULT_TRAINS, DEFAULT_GROUP, false));
|
||||||
|
|
||||||
for (size_t i = 0; i < list.size(); ++i) {
|
for (const Group *g : list) {
|
||||||
const Group *g = list[i];
|
|
||||||
if (group_id == g->index) selected = group_id;
|
if (group_id == g->index) selected = group_id;
|
||||||
SetDParam(0, g->index | GROUP_NAME_HIERARCHY);
|
SetDParam(0, g->index | GROUP_NAME_HIERARCHY);
|
||||||
dlist.push_back(MakeDropDownListStringItem(STR_GROUP_NAME, g->index, false));
|
dlist.push_back(MakeDropDownListStringItem(STR_GROUP_NAME, g->index, false));
|
||||||
@@ -757,8 +756,7 @@ DropDownList GetCounterDropDownList(Owner owner, TraceRestrictCounterID ctr_id,
|
|||||||
|
|
||||||
selected = -1;
|
selected = -1;
|
||||||
|
|
||||||
for (size_t i = 0; i < list.size(); ++i) {
|
for (const TraceRestrictCounter *s : list) {
|
||||||
const TraceRestrictCounter *s = list[i];
|
|
||||||
if (ctr_id == s->index) selected = ctr_id;
|
if (ctr_id == s->index) selected = ctr_id;
|
||||||
SetDParam(0, s->index);
|
SetDParam(0, s->index);
|
||||||
dlist.push_back(MakeDropDownListStringItem(STR_TRACE_RESTRICT_COUNTER_NAME, s->index, false));
|
dlist.push_back(MakeDropDownListStringItem(STR_TRACE_RESTRICT_COUNTER_NAME, s->index, false));
|
||||||
@@ -1231,7 +1229,7 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
|
|||||||
instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_ORDER_STATION;
|
instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_ORDER_STATION;
|
||||||
DrawInstructionStringConditionalIntegerCommon(item, properties);
|
DrawInstructionStringConditionalIntegerCommon(item, properties);
|
||||||
} else {
|
} else {
|
||||||
// this is an invalid station, use a seperate string
|
/* This is an invalid station, use a separate string */
|
||||||
DrawInstructionStringConditionalInvalidValue(item, properties, instruction_string, selected);
|
DrawInstructionStringConditionalInvalidValue(item, properties, instruction_string, selected);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1539,7 +1537,7 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TRIT_RESERVE_THROUGH:
|
case TRIT_RESERVE_THROUGH:
|
||||||
instruction_string = GetTraceRestrictValue(item) ? STR_TRACE_RESTRICT_RESERVE_THROUGH_CANCEL : STR_TRACE_RESTRICT_RESERVE_THROUGH;
|
instruction_string = GetTraceRestrictValue(item) != 0 ? STR_TRACE_RESTRICT_RESERVE_THROUGH_CANCEL : STR_TRACE_RESTRICT_RESERVE_THROUGH;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRIT_LONG_RESERVE:
|
case TRIT_LONG_RESERVE:
|
||||||
@@ -1813,7 +1811,7 @@ public:
|
|||||||
int sel = this->GetItemIndexFromPt(pt.y);
|
int sel = this->GetItemIndexFromPt(pt.y);
|
||||||
|
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
// scroll to target (for stations, waypoints, depots)
|
/* Scroll to target (for stations, waypoints, depots) */
|
||||||
|
|
||||||
if (sel == -1) return;
|
if (sel == -1) return;
|
||||||
|
|
||||||
@@ -1823,16 +1821,16 @@ public:
|
|||||||
switch (static_cast<TraceRestrictOrderCondAuxField>(GetTraceRestrictAuxField(item))) {
|
switch (static_cast<TraceRestrictOrderCondAuxField>(GetTraceRestrictAuxField(item))) {
|
||||||
case TROCAF_STATION:
|
case TROCAF_STATION:
|
||||||
case TROCAF_WAYPOINT: {
|
case TROCAF_WAYPOINT: {
|
||||||
BaseStation *st = BaseStation::GetIfValid(GetTraceRestrictValue(item));
|
const BaseStation *st = BaseStation::GetIfValid(GetTraceRestrictValue(item));
|
||||||
if (st) {
|
if (st != nullptr) {
|
||||||
ScrollMainWindowToTile(st->xy);
|
ScrollMainWindowToTile(st->xy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TROCAF_DEPOT: {
|
case TROCAF_DEPOT: {
|
||||||
Depot *depot = Depot::GetIfValid(GetTraceRestrictValue(item));
|
const Depot *depot = Depot::GetIfValid(GetTraceRestrictValue(item));
|
||||||
if (depot) {
|
if (depot != nullptr) {
|
||||||
ScrollMainWindowToTile(depot->xy);
|
ScrollMainWindowToTile(depot->xy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1851,7 +1849,7 @@ public:
|
|||||||
HideDropDownMenu(this);
|
HideDropDownMenu(this);
|
||||||
|
|
||||||
if (sel == -1 || this->GetOwner() != _local_company) {
|
if (sel == -1 || this->GetOwner() != _local_company) {
|
||||||
// Deselect
|
/* Deselect */
|
||||||
this->selected_instruction = -1;
|
this->selected_instruction = -1;
|
||||||
} else {
|
} else {
|
||||||
this->selected_instruction = sel;
|
this->selected_instruction = sel;
|
||||||
@@ -1873,20 +1871,20 @@ public:
|
|||||||
TraceRestrictItem item = this->GetSelected();
|
TraceRestrictItem item = this->GetSelected();
|
||||||
if (GetTraceRestrictType(item) == TRIT_COND_ENDIF ||
|
if (GetTraceRestrictType(item) == TRIT_COND_ENDIF ||
|
||||||
(IsTraceRestrictConditional(item) && GetTraceRestrictCondFlags(item) != 0)) {
|
(IsTraceRestrictConditional(item) && GetTraceRestrictCondFlags(item) != 0)) {
|
||||||
// this is either: an else/or if, an else, or an end if
|
/* This is either: an else/or if, an else, or an end if
|
||||||
// try to include else if, else in insertion list
|
* try to include else if, else in insertion list */
|
||||||
if (!ElseInsertionDryRun(false)) disabled |= _program_insert_else_hide_mask;
|
if (!ElseInsertionDryRun(false)) disabled |= _program_insert_else_hide_mask;
|
||||||
if (!ElseIfInsertionDryRun(false)) disabled |= _program_insert_else_if_hide_mask;
|
if (!ElseIfInsertionDryRun(false)) disabled |= _program_insert_else_if_hide_mask;
|
||||||
} else {
|
} else {
|
||||||
// can't insert else/end if here
|
/* Can't insert else/end if here */
|
||||||
disabled |= _program_insert_else_hide_mask | _program_insert_else_if_hide_mask;
|
disabled |= _program_insert_else_hide_mask | _program_insert_else_if_hide_mask;
|
||||||
}
|
}
|
||||||
if (this->selected_instruction > 1) {
|
if (this->selected_instruction > 1) {
|
||||||
TraceRestrictItem prev_item = this->GetItem(this->GetProgram(), this->selected_instruction - 1);
|
TraceRestrictItem prev_item = this->GetItem(this->GetProgram(), this->selected_instruction - 1);
|
||||||
if (IsTraceRestrictConditional(prev_item) && GetTraceRestrictType(prev_item) != TRIT_COND_ENDIF) {
|
if (IsTraceRestrictConditional(prev_item) && GetTraceRestrictType(prev_item) != TRIT_COND_ENDIF) {
|
||||||
// previous item is either: an if, or an else/or if
|
/* Previous item is either: an if, or an else/or if */
|
||||||
|
|
||||||
// else if has same validation rules as or if, use it instead of creating another test function
|
/* Else if has same validation rules as or if, use it instead of creating another test function */
|
||||||
if (ElseIfInsertionDryRun(false)) disabled &= ~_program_insert_or_if_hide_mask;
|
if (ElseIfInsertionDryRun(false)) disabled &= ~_program_insert_or_if_hide_mask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1993,7 +1991,7 @@ public:
|
|||||||
case TR_WIDGET_COMPARATOR: {
|
case TR_WIDGET_COMPARATOR: {
|
||||||
TraceRestrictItem item = this->GetSelected();
|
TraceRestrictItem item = this->GetSelected();
|
||||||
const TraceRestrictDropDownListSet *list_set = GetCondOpDropDownListSet(GetTraceRestrictTypeProperties(item));
|
const TraceRestrictDropDownListSet *list_set = GetCondOpDropDownListSet(GetTraceRestrictTypeProperties(item));
|
||||||
if (list_set) {
|
if (list_set != nullptr) {
|
||||||
this->ShowDropDownListWithValue(list_set, GetTraceRestrictCondOp(item), false, TR_WIDGET_COMPARATOR, 0, 0);
|
this->ShowDropDownListWithValue(list_set, GetTraceRestrictCondOp(item), false, TR_WIDGET_COMPARATOR, 0, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2289,7 +2287,7 @@ public:
|
|||||||
if (widget == TR_WIDGET_VALUE_DROPDOWN || widget == TR_WIDGET_LEFT_AUX_DROPDOWN) {
|
if (widget == TR_WIDGET_VALUE_DROPDOWN || widget == TR_WIDGET_LEFT_AUX_DROPDOWN) {
|
||||||
TraceRestrictTypePropertySet type = GetTraceRestrictTypeProperties(item);
|
TraceRestrictTypePropertySet type = GetTraceRestrictTypeProperties(item);
|
||||||
if (this->value_drop_down_is_company || type.value_type == TRVT_GROUP_INDEX || type.value_type == TRVT_SLOT_INDEX || type.value_type == TRVT_SLOT_INDEX_INT || type.value_type == TRVT_COUNTER_INDEX_INT || type.value_type == TRVT_TIME_DATE_INT) {
|
if (this->value_drop_down_is_company || type.value_type == TRVT_GROUP_INDEX || type.value_type == TRVT_SLOT_INDEX || type.value_type == TRVT_SLOT_INDEX_INT || type.value_type == TRVT_COUNTER_INDEX_INT || type.value_type == TRVT_TIME_DATE_INT) {
|
||||||
// this is a special company drop-down or group/slot-index drop-down
|
/* This is a special company drop-down or group/slot-index drop-down */
|
||||||
SetTraceRestrictValue(item, index);
|
SetTraceRestrictValue(item, index);
|
||||||
TraceRestrictDoCommandP(this->tile, this->track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM);
|
TraceRestrictDoCommandP(this->tile, this->track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM);
|
||||||
return;
|
return;
|
||||||
@@ -2335,7 +2333,7 @@ public:
|
|||||||
SetTraceRestrictCondFlags(item, TRCF_ELSE);
|
SetTraceRestrictCondFlags(item, TRCF_ELSE);
|
||||||
} else {
|
} else {
|
||||||
if (GetTraceRestrictType(item) == TRIT_COND_ENDIF) {
|
if (GetTraceRestrictType(item) == TRIT_COND_ENDIF) {
|
||||||
// item is currently an else, convert to else/or if
|
/* Item is currently an else, convert to else/or if */
|
||||||
SetTraceRestrictTypeAndNormalise(item, TRIT_COND_UNDEFINED);
|
SetTraceRestrictTypeAndNormalise(item, TRIT_COND_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2449,7 +2447,7 @@ public:
|
|||||||
trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
|
trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
|
||||||
}
|
}
|
||||||
Track source_track = FindFirstTrack(trackbits);
|
Track source_track = FindFirstTrack(trackbits);
|
||||||
if(source_track == INVALID_TRACK) {
|
if (source_track == INVALID_TRACK) {
|
||||||
ShowErrorMessage(error_message, STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, WL_INFO);
|
ShowErrorMessage(error_message, STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, WL_INFO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2557,9 +2555,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsRailDepotTile(tile)) {
|
if (IsRailDepotTile(tile)) {
|
||||||
// OK
|
/* OK */
|
||||||
} else if (IsTileType(tile, MP_TUNNELBRIDGE) && IsTunnelBridgeWithSignalSimulation(tile)) {
|
} else if (IsTileType(tile, MP_TUNNELBRIDGE) && IsTunnelBridgeWithSignalSimulation(tile)) {
|
||||||
// OK
|
/* OK */
|
||||||
} else {
|
} else {
|
||||||
if (!IsPlainRailTile(tile)) {
|
if (!IsPlainRailTile(tile)) {
|
||||||
ShowErrorMessage(error_message, STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, WL_INFO);
|
ShowErrorMessage(error_message, STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, WL_INFO);
|
||||||
@@ -2626,7 +2624,7 @@ public:
|
|||||||
int line_height = this->GetWidget<NWidgetBase>(TR_WIDGET_INSTRUCTION_LIST)->resize_y;
|
int line_height = this->GetWidget<NWidgetBase>(TR_WIDGET_INSTRUCTION_LIST)->resize_y;
|
||||||
int scroll_position = this->vscroll->GetPosition();
|
int scroll_position = this->vscroll->GetPosition();
|
||||||
|
|
||||||
// prog may be nullptr
|
/* prog may be nullptr */
|
||||||
const TraceRestrictProgram *prog = this->GetProgram();
|
const TraceRestrictProgram *prog = this->GetProgram();
|
||||||
|
|
||||||
int count = this->GetItemCount(prog);
|
int count = this->GetItemCount(prog);
|
||||||
@@ -2696,7 +2694,7 @@ public:
|
|||||||
|
|
||||||
case TR_WIDGET_CAPTION: {
|
case TR_WIDGET_CAPTION: {
|
||||||
const TraceRestrictProgram *prog = this->GetProgram();
|
const TraceRestrictProgram *prog = this->GetProgram();
|
||||||
if (prog) {
|
if (prog != nullptr) {
|
||||||
SetDParam(0, prog->refcount);
|
SetDParam(0, prog->refcount);
|
||||||
} else {
|
} else {
|
||||||
SetDParam(0, 1);
|
SetDParam(0, 1);
|
||||||
@@ -2786,8 +2784,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
int GetItemCount(const TraceRestrictProgram *prog) const
|
int GetItemCount(const TraceRestrictProgram *prog) const
|
||||||
{
|
{
|
||||||
if (prog) {
|
if (prog != nullptr) {
|
||||||
return 2 + (int)prog->GetInstructionCount();
|
return 2 + static_cast<int>(prog->GetInstructionCount());
|
||||||
} else {
|
} else {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@@ -2818,7 +2816,7 @@ private:
|
|||||||
return MakeSpecialItem(TRNTSV_START);
|
return MakeSpecialItem(TRNTSV_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prog) {
|
if (prog != nullptr) {
|
||||||
size_t instruction_count = prog->GetInstructionCount();
|
size_t instruction_count = prog->GetInstructionCount();
|
||||||
|
|
||||||
if (static_cast<size_t>(index) == instruction_count + 1) {
|
if (static_cast<size_t>(index) == instruction_count + 1) {
|
||||||
@@ -2831,7 +2829,7 @@ private:
|
|||||||
|
|
||||||
return prog->items[prog->InstructionOffsetToArrayOffset(index - 1)];
|
return prog->items[prog->InstructionOffsetToArrayOffset(index - 1)];
|
||||||
} else {
|
} else {
|
||||||
// No program defined, this is equivalent to an empty program
|
/* No program defined, this is equivalent to an empty program */
|
||||||
if (index == 1) {
|
if (index == 1) {
|
||||||
return MakeSpecialItem(TRNTSV_END);
|
return MakeSpecialItem(TRNTSV_END);
|
||||||
} else {
|
} else {
|
||||||
@@ -2879,16 +2877,16 @@ private:
|
|||||||
const TraceRestrictProgram *prog = this->GetProgram();
|
const TraceRestrictProgram *prog = this->GetProgram();
|
||||||
|
|
||||||
if (this->vscroll->GetCount() != this->GetItemCount(prog)) {
|
if (this->vscroll->GetCount() != this->GetItemCount(prog)) {
|
||||||
// program length has changed
|
/* Program length has changed */
|
||||||
|
|
||||||
if (this->GetItemCount(prog) < this->vscroll->GetCount() ||
|
if (this->GetItemCount(prog) < this->vscroll->GetCount() ||
|
||||||
this->GetItem(prog, this->selected_instruction) != this->expecting_inserted_item) {
|
this->GetItem(prog, this->selected_instruction) != this->expecting_inserted_item) {
|
||||||
// length has shrunk or if we weren't expecting an insertion, deselect
|
/* Length has shrunk or if we weren't expecting an insertion, deselect */
|
||||||
this->selected_instruction = -1;
|
this->selected_instruction = -1;
|
||||||
}
|
}
|
||||||
this->expecting_inserted_item = static_cast<TraceRestrictItem>(0);
|
this->expecting_inserted_item = static_cast<TraceRestrictItem>(0);
|
||||||
|
|
||||||
// update scrollbar size
|
/* Update scrollbar size */
|
||||||
this->vscroll->SetCount(this->GetItemCount(prog));
|
this->vscroll->SetCount(this->GetItemCount(prog));
|
||||||
}
|
}
|
||||||
this->UpdateButtonState();
|
this->UpdateButtonState();
|
||||||
@@ -2896,7 +2894,7 @@ private:
|
|||||||
|
|
||||||
bool IsUpDownBtnUsable(bool up, bool update_selection = false) {
|
bool IsUpDownBtnUsable(bool up, bool update_selection = false) {
|
||||||
const TraceRestrictProgram *prog = this->GetProgram();
|
const TraceRestrictProgram *prog = this->GetProgram();
|
||||||
if (!prog) return false;
|
if (prog == nullptr) return false;
|
||||||
|
|
||||||
TraceRestrictItem item = this->GetSelected();
|
TraceRestrictItem item = this->GetSelected();
|
||||||
if (GetTraceRestrictType(item) == TRIT_NULL) return false;
|
if (GetTraceRestrictType(item) == TRIT_NULL) return false;
|
||||||
@@ -2916,7 +2914,7 @@ private:
|
|||||||
|
|
||||||
bool IsDuplicateBtnUsable() const {
|
bool IsDuplicateBtnUsable() const {
|
||||||
const TraceRestrictProgram *prog = this->GetProgram();
|
const TraceRestrictProgram *prog = this->GetProgram();
|
||||||
if (!prog) return false;
|
if (prog == nullptr) return false;
|
||||||
|
|
||||||
TraceRestrictItem item = this->GetSelected();
|
TraceRestrictItem item = this->GetSelected();
|
||||||
if (GetTraceRestrictType(item) == TRIT_NULL) return false;
|
if (GetTraceRestrictType(item) == TRIT_NULL) return false;
|
||||||
@@ -3013,7 +3011,7 @@ private:
|
|||||||
const TraceRestrictProgram *prog = this->GetProgram();
|
const TraceRestrictProgram *prog = this->GetProgram();
|
||||||
|
|
||||||
this->GetWidget<NWidgetCore>(TR_WIDGET_CAPTION)->widget_data =
|
this->GetWidget<NWidgetCore>(TR_WIDGET_CAPTION)->widget_data =
|
||||||
(prog && prog->refcount > 1) ? STR_TRACE_RESTRICT_CAPTION_SHARED : STR_TRACE_RESTRICT_CAPTION;
|
(prog != nullptr && prog->refcount > 1) ? STR_TRACE_RESTRICT_CAPTION_SHARED : STR_TRACE_RESTRICT_CAPTION;
|
||||||
|
|
||||||
this->SetWidgetDisabledState(TR_WIDGET_HIGHLIGHT, prog == nullptr);
|
this->SetWidgetDisabledState(TR_WIDGET_HIGHLIGHT, prog == nullptr);
|
||||||
extern const TraceRestrictProgram *_viewport_highlight_tracerestrict_program;
|
extern const TraceRestrictProgram *_viewport_highlight_tracerestrict_program;
|
||||||
@@ -3026,7 +3024,7 @@ private:
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Don't allow modifications if don't own
|
/* Don't allow modifications for non-owners */
|
||||||
if (this->GetOwner() != _local_company) {
|
if (this->GetOwner() != _local_company) {
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
return;
|
return;
|
||||||
@@ -3039,15 +3037,15 @@ private:
|
|||||||
this->base_share_plane = DPS_SHARE;
|
this->base_share_plane = DPS_SHARE;
|
||||||
|
|
||||||
if (prog != nullptr && prog->refcount > 1) {
|
if (prog != nullptr && prog->refcount > 1) {
|
||||||
// program is shared, show and enable unshare button, and reset button
|
/* Program is shared, show and enable unshare button, and reset button */
|
||||||
this->base_share_plane = DPS_UNSHARE;
|
this->base_share_plane = DPS_UNSHARE;
|
||||||
this->EnableWidget(TR_WIDGET_UNSHARE);
|
this->EnableWidget(TR_WIDGET_UNSHARE);
|
||||||
this->EnableWidget(TR_WIDGET_RESET);
|
this->EnableWidget(TR_WIDGET_RESET);
|
||||||
} else if (this->GetItemCount(prog) > 2) {
|
} else if (this->GetItemCount(prog) > 2) {
|
||||||
// program is non-empty and not shared, enable reset button
|
/* Program is non-empty and not shared, enable reset button */
|
||||||
this->EnableWidget(TR_WIDGET_RESET);
|
this->EnableWidget(TR_WIDGET_RESET);
|
||||||
} else {
|
} else {
|
||||||
// program is empty and not shared, show copy and share buttons
|
/* Program is empty and not shared, show copy and share buttons */
|
||||||
this->EnableWidget(TR_WIDGET_COPY);
|
this->EnableWidget(TR_WIDGET_COPY);
|
||||||
this->EnableWidget(TR_WIDGET_SHARE);
|
this->EnableWidget(TR_WIDGET_SHARE);
|
||||||
this->base_copy_plane = DPC_COPY;
|
this->base_copy_plane = DPC_COPY;
|
||||||
@@ -3056,7 +3054,7 @@ private:
|
|||||||
this->GetWidget<NWidgetCore>(TR_WIDGET_COPY_APPEND)->tool_tip = (this->base_copy_plane == DPC_DUPLICATE) ? STR_TRACE_RESTRICT_DUPLICATE_TOOLTIP : STR_TRACE_RESTRICT_COPY_TOOLTIP;
|
this->GetWidget<NWidgetCore>(TR_WIDGET_COPY_APPEND)->tool_tip = (this->base_copy_plane == DPC_DUPLICATE) ? STR_TRACE_RESTRICT_DUPLICATE_TOOLTIP : STR_TRACE_RESTRICT_COPY_TOOLTIP;
|
||||||
this->UpdatePlaceObjectPlanes();
|
this->UpdatePlaceObjectPlanes();
|
||||||
|
|
||||||
// haven't selected instruction
|
/* Haven't selected instruction */
|
||||||
if (this->selected_instruction < 1) {
|
if (this->selected_instruction < 1) {
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
return;
|
return;
|
||||||
@@ -3080,10 +3078,10 @@ private:
|
|||||||
} else if (GetTraceRestrictType(item) == TRIT_COND_ENDIF) {
|
} else if (GetTraceRestrictType(item) == TRIT_COND_ENDIF) {
|
||||||
this->EnableWidget(TR_WIDGET_INSERT);
|
this->EnableWidget(TR_WIDGET_INSERT);
|
||||||
if (GetTraceRestrictCondFlags(item) != 0) {
|
if (GetTraceRestrictCondFlags(item) != 0) {
|
||||||
// this is not an end if, it must be an else, enable removing
|
/* This is not an end if, it must be an else, enable removing */
|
||||||
this->EnableWidget(TR_WIDGET_REMOVE);
|
this->EnableWidget(TR_WIDGET_REMOVE);
|
||||||
|
|
||||||
// setup condflags dropdown to show else
|
/* Setup condflags dropdown to show else */
|
||||||
left_2_sel->SetDisplayedPlane(DPL2_CONDFLAGS);
|
left_2_sel->SetDisplayedPlane(DPL2_CONDFLAGS);
|
||||||
this->EnableWidget(TR_WIDGET_CONDFLAGS);
|
this->EnableWidget(TR_WIDGET_CONDFLAGS);
|
||||||
this->GetWidget<NWidgetCore>(TR_WIDGET_CONDFLAGS)->widget_data = STR_TRACE_RESTRICT_CONDITIONAL_ELSE;
|
this->GetWidget<NWidgetCore>(TR_WIDGET_CONDFLAGS)->widget_data = STR_TRACE_RESTRICT_CONDITIONAL_ELSE;
|
||||||
@@ -3093,13 +3091,13 @@ private:
|
|||||||
|
|
||||||
int type_widget;
|
int type_widget;
|
||||||
if (IsTraceRestrictConditional(item)) {
|
if (IsTraceRestrictConditional(item)) {
|
||||||
// note that else and end if items are not handled here, they are handled above
|
/* Note that else and end if items are not handled here, they are handled above */
|
||||||
|
|
||||||
left_2_sel->SetDisplayedPlane(DPL2_CONDFLAGS);
|
left_2_sel->SetDisplayedPlane(DPL2_CONDFLAGS);
|
||||||
left_sel->SetDisplayedPlane(DPL_TYPE);
|
left_sel->SetDisplayedPlane(DPL_TYPE);
|
||||||
type_widget = TR_WIDGET_TYPE_COND;
|
type_widget = TR_WIDGET_TYPE_COND;
|
||||||
|
|
||||||
// setup condflags dropdown box
|
/* Setup condflags dropdown box */
|
||||||
left_2_sel->SetDisplayedPlane(DPL2_CONDFLAGS);
|
left_2_sel->SetDisplayedPlane(DPL2_CONDFLAGS);
|
||||||
switch (GetTraceRestrictCondFlags(item)) {
|
switch (GetTraceRestrictCondFlags(item)) {
|
||||||
case TRCF_DEFAULT: // opening if, leave disabled
|
case TRCF_DEFAULT: // opening if, leave disabled
|
||||||
@@ -3144,7 +3142,7 @@ private:
|
|||||||
if (IsIntegerValueType(properties.value_type)) {
|
if (IsIntegerValueType(properties.value_type)) {
|
||||||
right_sel->SetDisplayedPlane(DPR_VALUE_INT);
|
right_sel->SetDisplayedPlane(DPR_VALUE_INT);
|
||||||
this->EnableWidget(TR_WIDGET_VALUE_INT);
|
this->EnableWidget(TR_WIDGET_VALUE_INT);
|
||||||
} else if(IsDecimalValueType(properties.value_type)) {
|
} else if (IsDecimalValueType(properties.value_type)) {
|
||||||
right_sel->SetDisplayedPlane(DPR_VALUE_DECIMAL);
|
right_sel->SetDisplayedPlane(DPR_VALUE_DECIMAL);
|
||||||
this->EnableWidget(TR_WIDGET_VALUE_DECIMAL);
|
this->EnableWidget(TR_WIDGET_VALUE_DECIMAL);
|
||||||
} else {
|
} else {
|
||||||
@@ -3436,7 +3434,7 @@ private:
|
|||||||
{
|
{
|
||||||
DropDownList list;
|
DropDownList list;
|
||||||
|
|
||||||
for (Company *c : Company::Iterate()) {
|
for (const Company *c : Company::Iterate()) {
|
||||||
list.emplace_back(MakeCompanyDropDownListItem(c->index));
|
list.emplace_back(MakeCompanyDropDownListItem(c->index));
|
||||||
if (c->index == value) missing_ok = true;
|
if (c->index == value) missing_ok = true;
|
||||||
}
|
}
|
||||||
@@ -3487,13 +3485,13 @@ private:
|
|||||||
uint offset = this->selected_instruction - 1;
|
uint offset = this->selected_instruction - 1;
|
||||||
|
|
||||||
const TraceRestrictProgram *prog = this->GetProgram();
|
const TraceRestrictProgram *prog = this->GetProgram();
|
||||||
if (!prog) return false;
|
if (prog == nullptr) return false;
|
||||||
|
|
||||||
std::vector<TraceRestrictItem> items = prog->items; // copy
|
std::vector<TraceRestrictItem> items = prog->items; // copy
|
||||||
|
|
||||||
if (offset >= (TraceRestrictProgram::GetInstructionCount(items) + (replace ? 0 : 1))) return false; // off the end of the program
|
if (offset >= (TraceRestrictProgram::GetInstructionCount(items) + (replace ? 0 : 1))) return false; // off the end of the program
|
||||||
|
|
||||||
uint array_offset = (uint)TraceRestrictProgram::InstructionOffsetToArrayOffset(items, offset);
|
uint array_offset = static_cast<uint>(TraceRestrictProgram::InstructionOffsetToArrayOffset(items, offset));
|
||||||
if (replace) {
|
if (replace) {
|
||||||
items[array_offset] = item;
|
items[array_offset] = item;
|
||||||
} else {
|
} else {
|
||||||
@@ -3528,7 +3526,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static constexpr NWidgetPart _nested_program_widgets[] = {
|
static constexpr NWidgetPart _nested_program_widgets[] = {
|
||||||
// Title bar
|
/* Title bar */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||||
NWidget(WWT_CAPTION, COLOUR_GREY, TR_WIDGET_CAPTION), SetDataTip(STR_TRACE_RESTRICT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
NWidget(WWT_CAPTION, COLOUR_GREY, TR_WIDGET_CAPTION), SetDataTip(STR_TRACE_RESTRICT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||||
@@ -3538,14 +3536,14 @@ static constexpr NWidgetPart _nested_program_widgets[] = {
|
|||||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
|
||||||
// Program display
|
/* Program display */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY, TR_WIDGET_INSTRUCTION_LIST), SetMinimalSize(372, 62), SetDataTip(0x0, STR_TRACE_RESTRICT_INSTRUCTION_LIST_TOOLTIP),
|
NWidget(WWT_PANEL, COLOUR_GREY, TR_WIDGET_INSTRUCTION_LIST), SetMinimalSize(372, 62), SetDataTip(0x0, STR_TRACE_RESTRICT_INSTRUCTION_LIST_TOOLTIP),
|
||||||
SetResize(1, 1), SetScrollbar(TR_WIDGET_SCROLLBAR), EndContainer(),
|
SetResize(1, 1), SetScrollbar(TR_WIDGET_SCROLLBAR), EndContainer(),
|
||||||
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, TR_WIDGET_SCROLLBAR),
|
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, TR_WIDGET_SCROLLBAR),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
|
||||||
// Button Bar
|
/* Button Bar */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, TR_WIDGET_UP_BTN), SetMinimalSize(12, 12), SetDataTip(SPR_ARROW_UP, STR_TRACE_RESTRICT_UP_BTN_TOOLTIP),
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, TR_WIDGET_UP_BTN), SetMinimalSize(12, 12), SetDataTip(SPR_ARROW_UP, STR_TRACE_RESTRICT_UP_BTN_TOOLTIP),
|
||||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, TR_WIDGET_DOWN_BTN), SetMinimalSize(12, 12), SetDataTip(SPR_ARROW_DOWN, STR_TRACE_RESTRICT_DOWN_BTN_TOOLTIP),
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, TR_WIDGET_DOWN_BTN), SetMinimalSize(12, 12), SetDataTip(SPR_ARROW_DOWN, STR_TRACE_RESTRICT_DOWN_BTN_TOOLTIP),
|
||||||
@@ -3734,8 +3732,8 @@ private:
|
|||||||
TraceRestrictSlotID slot_rename; ///< Slot being renamed or max occupancy changed, INVALID_TRACE_RESTRICT_SLOT_ID if none
|
TraceRestrictSlotID slot_rename; ///< Slot being renamed or max occupancy changed, INVALID_TRACE_RESTRICT_SLOT_ID if none
|
||||||
TraceRestrictSlotID slot_over; ///< Slot over which a vehicle is dragged, INVALID_TRACE_RESTRICT_SLOT_ID if none
|
TraceRestrictSlotID slot_over; ///< Slot over which a vehicle is dragged, INVALID_TRACE_RESTRICT_SLOT_ID if none
|
||||||
TraceRestrictSlotID slot_confirm; ///< Slot awaiting delete confirmation
|
TraceRestrictSlotID slot_confirm; ///< Slot awaiting delete confirmation
|
||||||
GUIList<const TraceRestrictSlot*> slots; ///< List of slots
|
GUIList<const TraceRestrictSlot*> slots; ///< List of slots
|
||||||
uint tiny_step_height; ///< Step height for the slot list
|
uint tiny_step_height; ///< Step height for the slot list
|
||||||
Scrollbar *slot_sb;
|
Scrollbar *slot_sb;
|
||||||
|
|
||||||
Dimension column_size[VGC_END]; ///< Size of the columns in the group list.
|
Dimension column_size[VGC_END]; ///< Size of the columns in the group list.
|
||||||
@@ -3781,8 +3779,8 @@ private:
|
|||||||
this->tiny_step_height += WidgetDimensions::scaled.matrix.top + ScaleGUITrad(1);
|
this->tiny_step_height += WidgetDimensions::scaled.matrix.top + ScaleGUITrad(1);
|
||||||
|
|
||||||
return WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.vsep_wide +
|
return WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.vsep_wide +
|
||||||
this->column_size[VGC_NAME].width + WidgetDimensions::scaled.vsep_wide +
|
this->column_size[VGC_NAME].width + WidgetDimensions::scaled.vsep_wide +
|
||||||
this->column_size[VGC_NUMBER].width + WidgetDimensions::scaled.vsep_normal;
|
this->column_size[VGC_NUMBER].width + WidgetDimensions::scaled.vsep_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3812,7 +3810,13 @@ private:
|
|||||||
SetDParam(0, slot_id);
|
SetDParam(0, slot_id);
|
||||||
str = STR_TRACE_RESTRICT_SLOT_NAME;
|
str = STR_TRACE_RESTRICT_SLOT_NAME;
|
||||||
}
|
}
|
||||||
int x = rtl ? right - WidgetDimensions::scaled.framerect.right - WidgetDimensions::scaled.vsep_wide - this->column_size[VGC_NAME].width + 1 : left + WidgetDimensions::scaled.framerect.left + WidgetDimensions::scaled.vsep_wide;
|
|
||||||
|
int x;
|
||||||
|
if (rtl) {
|
||||||
|
x = right - WidgetDimensions::scaled.framerect.right - WidgetDimensions::scaled.vsep_wide - this->column_size[VGC_NAME].width + 1;
|
||||||
|
} else {
|
||||||
|
x = left + WidgetDimensions::scaled.framerect.left + WidgetDimensions::scaled.vsep_wide;
|
||||||
|
}
|
||||||
DrawString(x, x + this->column_size[VGC_NAME].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NAME].height) / 2, str, colour);
|
DrawString(x, x + this->column_size[VGC_NAME].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NAME].height) / 2, str, colour);
|
||||||
|
|
||||||
if (slot_id == ALL_TRAINS_TRACE_RESTRICT_SLOT_ID) return;
|
if (slot_id == ALL_TRAINS_TRACE_RESTRICT_SLOT_ID) return;
|
||||||
@@ -3976,8 +3980,8 @@ public:
|
|||||||
|
|
||||||
this->BuildSlotList(this->owner);
|
this->BuildSlotList(this->owner);
|
||||||
|
|
||||||
this->slot_sb->SetCount((uint)this->slots.size());
|
this->slot_sb->SetCount(static_cast<uint>(this->slots.size()));
|
||||||
this->vscroll->SetCount((uint)this->vehgroups.size());
|
this->vscroll->SetCount(static_cast<uint>(this->vehgroups.size()));
|
||||||
|
|
||||||
/* Disable the slot specific function when we select all vehicles */
|
/* Disable the slot specific function when we select all vehicles */
|
||||||
this->SetWidgetsDisabledState(this->vli.index == ALL_TRAINS_TRACE_RESTRICT_SLOT_ID || _local_company != this->vli.company,
|
this->SetWidgetsDisabledState(this->vli.index == ALL_TRAINS_TRACE_RESTRICT_SLOT_ID || _local_company != this->vli.company,
|
||||||
@@ -4011,7 +4015,7 @@ public:
|
|||||||
|
|
||||||
case WID_TRSL_LIST_SLOTS: {
|
case WID_TRSL_LIST_SLOTS: {
|
||||||
int y1 = r.top + WidgetDimensions::scaled.framerect.top;
|
int y1 = r.top + WidgetDimensions::scaled.framerect.top;
|
||||||
int max = std::min<int>(this->slot_sb->GetPosition() + this->slot_sb->GetCapacity(), (int)this->slots.size());
|
int max = std::min<int>(this->slot_sb->GetPosition() + this->slot_sb->GetCapacity(), static_cast<int>(this->slots.size()));
|
||||||
for (int i = this->slot_sb->GetPosition(); i < max; ++i) {
|
for (int i = this->slot_sb->GetPosition(); i < max; ++i) {
|
||||||
const TraceRestrictSlot *slot = this->slots[i];
|
const TraceRestrictSlot *slot = this->slots[i];
|
||||||
|
|
||||||
@@ -4142,7 +4146,7 @@ public:
|
|||||||
if (id_s >= this->slots.size()) return; // click out of list bound
|
if (id_s >= this->slots.size()) return; // click out of list bound
|
||||||
|
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
// remove from old group
|
/* Remove from old group */
|
||||||
DoCommandP(0, this->slot_sel, vindex, CMD_REMOVE_VEHICLE_TRACERESTRICT_SLOT | CMD_MSG(STR_TRACE_RESTRICT_ERROR_SLOT_CAN_T_REMOVE_VEHICLE));
|
DoCommandP(0, this->slot_sel, vindex, CMD_REMOVE_VEHICLE_TRACERESTRICT_SLOT | CMD_MSG(STR_TRACE_RESTRICT_ERROR_SLOT_CAN_T_REMOVE_VEHICLE));
|
||||||
}
|
}
|
||||||
DoCommandP(0, this->slots[id_s]->index, vindex, CMD_ADD_VEHICLE_TRACERESTRICT_SLOT | CMD_MSG(STR_TRACE_RESTRICT_ERROR_SLOT_CAN_T_ADD_VEHICLE));
|
DoCommandP(0, this->slots[id_s]->index, vindex, CMD_ADD_VEHICLE_TRACERESTRICT_SLOT | CMD_MSG(STR_TRACE_RESTRICT_ERROR_SLOT_CAN_T_ADD_VEHICLE));
|
||||||
@@ -4221,7 +4225,7 @@ public:
|
|||||||
|
|
||||||
virtual void OnPlaceObjectAbort() override
|
virtual void OnPlaceObjectAbort() override
|
||||||
{
|
{
|
||||||
/* abort drag & drop */
|
/* Abort drag & drop */
|
||||||
this->vehicle_sel = INVALID_VEHICLE;
|
this->vehicle_sel = INVALID_VEHICLE;
|
||||||
this->DirtyHighlightedSlotWidget();
|
this->DirtyHighlightedSlotWidget();
|
||||||
this->slot_over = INVALID_GROUP;
|
this->slot_over = INVALID_GROUP;
|
||||||
@@ -4389,9 +4393,9 @@ private:
|
|||||||
TraceRestrictCounterID ctr_qt_op; ///< Counter being adjusted in query text operation, INVALID_TRACE_RESTRICT_COUNTER_ID if none
|
TraceRestrictCounterID ctr_qt_op; ///< Counter being adjusted in query text operation, INVALID_TRACE_RESTRICT_COUNTER_ID if none
|
||||||
TraceRestrictCounterID ctr_confirm; ///< Counter awaiting delete confirmation
|
TraceRestrictCounterID ctr_confirm; ///< Counter awaiting delete confirmation
|
||||||
TraceRestrictCounterID selected; ///< Selected counter
|
TraceRestrictCounterID selected; ///< Selected counter
|
||||||
GUIList<const TraceRestrictCounter*> ctrs; ///< List of slots
|
GUIList<const TraceRestrictCounter*> ctrs; ///< List of slots
|
||||||
uint tiny_step_height; ///< Step height for the counter list
|
uint tiny_step_height; ///< Step height for the counter list
|
||||||
uint value_col_width; ///< Value column width
|
uint value_col_width; ///< Value column width
|
||||||
Scrollbar *sb;
|
Scrollbar *sb;
|
||||||
|
|
||||||
void BuildCounterList()
|
void BuildCounterList()
|
||||||
@@ -4424,9 +4428,9 @@ private:
|
|||||||
this->value_col_width = dim.width;
|
this->value_col_width = dim.width;
|
||||||
|
|
||||||
return WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.vsep_wide +
|
return WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.vsep_wide +
|
||||||
170 + WidgetDimensions::scaled.vsep_wide +
|
170 + WidgetDimensions::scaled.vsep_wide +
|
||||||
dim.width + WidgetDimensions::scaled.vsep_wide +
|
dim.width + WidgetDimensions::scaled.vsep_wide +
|
||||||
WidgetDimensions::scaled.framerect.right;
|
WidgetDimensions::scaled.framerect.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4516,7 +4520,7 @@ public:
|
|||||||
{
|
{
|
||||||
this->BuildCounterList();
|
this->BuildCounterList();
|
||||||
|
|
||||||
this->sb->SetCount((uint)this->ctrs.size());
|
this->sb->SetCount(static_cast<uint>(this->ctrs.size()));
|
||||||
|
|
||||||
/* Disable the counter specific functions when no counter is selected */
|
/* Disable the counter specific functions when no counter is selected */
|
||||||
this->SetWidgetsDisabledState(this->selected == INVALID_TRACE_RESTRICT_COUNTER_ID || _local_company != this->ctr_company,
|
this->SetWidgetsDisabledState(this->selected == INVALID_TRACE_RESTRICT_COUNTER_ID || _local_company != this->ctr_company,
|
||||||
@@ -4542,7 +4546,7 @@ public:
|
|||||||
case WID_TRCL_LIST_COUNTERS: {
|
case WID_TRCL_LIST_COUNTERS: {
|
||||||
Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
|
Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||||
int y1 = ir.top;
|
int y1 = ir.top;
|
||||||
int max = std::min<int>(this->sb->GetPosition() + this->sb->GetCapacity(), (int)this->ctrs.size());
|
int max = std::min<int>(this->sb->GetPosition() + this->sb->GetCapacity(), static_cast<int>(this->ctrs.size()));
|
||||||
for (int i = this->sb->GetPosition(); i < max; ++i) {
|
for (int i = this->sb->GetPosition(); i < max; ++i) {
|
||||||
const TraceRestrictCounter *ctr = this->ctrs[i];
|
const TraceRestrictCounter *ctr = this->ctrs[i];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user