Fix order flags collision in OT_GOTO_DEPOT

Move depot wait is timetabled flag to xflags
This commit is contained in:
Jonathan G Rennison
2024-02-19 00:24:50 +00:00
parent 821c5970db
commit c6893388ab
3 changed files with 22 additions and 6 deletions

View File

@@ -53,7 +53,7 @@ void ClearOrderDestinationRefcountMap();
/*
* xflags bits:
* Bit 0: OT_CONDITIONAL: IsWaitTimetabled(): For branch travel time
* Bit 0: OT_CONDITIONAL and OT_GOTO_DEPOT: IsWaitTimetabled(): Depot: wait is timetabled, conditional: branch travel time
* Bit 1: IsWaitFixed(): Wait time fixed
* Bits 2-3: GetLeaveType(): Order leave type
* Bit 4: IsTravelFixed(): Travel time fixed
@@ -170,6 +170,11 @@ public:
return this->extra->xdata2;
}
inline uint16_t GetRawFlags() const
{
return this->flags;
}
Order *next; ///< Pointer to next order. If nullptr, end of list
Order() : flags(0), refit_cargo(CARGO_NO_REFIT), max_speed(UINT16_MAX) {}
@@ -475,7 +480,7 @@ public:
inline bool IsWaitTimetabled() const
{
if (this->HasNoTimetableTimes()) return true;
return this->IsType(OT_CONDITIONAL) ? HasBit(this->GetXFlags(), 0) : HasBit(this->flags, 3);
return (this->IsType(OT_CONDITIONAL) || this->IsType(OT_GOTO_DEPOT)) ? HasBit(this->GetXFlags(), 0) : HasBit(this->flags, 3);
}
/** Does this order have an explicit travel time set? */
inline bool IsTravelTimetabled() const
@@ -504,7 +509,8 @@ public:
inline void SetWaitTimetabled(bool timetabled)
{
if (this->HasNoTimetableTimes()) return;
if (this->IsType(OT_CONDITIONAL)) {
if (this->IsType(OT_CONDITIONAL) || this->IsType(OT_GOTO_DEPOT)) {
if (this->extra == nullptr && !timetabled) return;
SB(this->GetXFlagsRef(), 0, 1, timetabled ? 1 : 0);
} else {
SB(this->flags, 3, 1, timetabled ? 1 : 0);