This commit is contained in:
shakthi124 2024-05-10 01:49:51 +00:00 committed by GitHub
commit 1d0f4550aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 32 deletions

View File

@ -43,6 +43,18 @@ uint16_t TrackRemoveAction::GetActionFlags() const
return GameAction::GetActionFlags();
}
int32_t TrackRemoveAction::NormaliseTrackType(int32_t trackType) const
{
switch (trackType)
{
case TrackElemType::BeginStation:
case TrackElemType::MiddleStation:
return TrackElemType::EndStation;
}
return trackType;
}
void TrackRemoveAction::Serialise(DataSerialiser& stream)
{
GameAction::Serialise(stream);
@ -59,14 +71,7 @@ GameActions::Result TrackRemoveAction::Query() const
res.Expenditure = ExpenditureType::RideConstruction;
// Stations require some massaging of the track type for comparing
auto comparableTrackType = _trackType;
switch (_trackType)
{
case TrackElemType::BeginStation:
case TrackElemType::MiddleStation:
comparableTrackType = TrackElemType::EndStation;
break;
}
auto comparableTrackType = NormaliseTrackType(_trackType);
bool found = false;
bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
@ -92,14 +97,7 @@ GameActions::Result TrackRemoveAction::Query() const
if (tileElement->IsGhost() != isGhost)
continue;
auto tileTrackType = tileElement->AsTrack()->GetTrackType();
switch (tileTrackType)
{
case TrackElemType::BeginStation:
case TrackElemType::MiddleStation:
tileTrackType = TrackElemType::EndStation;
break;
}
auto tileTrackType = NormaliseTrackType(tileElement->AsTrack()->GetTrackType());
if (tileTrackType != comparableTrackType)
continue;
@ -266,14 +264,7 @@ GameActions::Result TrackRemoveAction::Execute() const
res.Expenditure = ExpenditureType::RideConstruction;
// Stations require some massaging of the track type for comparing
auto comparableTrackType = _trackType;
switch (_trackType)
{
case TrackElemType::BeginStation:
case TrackElemType::MiddleStation:
comparableTrackType = TrackElemType::EndStation;
break;
}
auto comparableTrackType = NormaliseTrackType(_trackType);
bool found = false;
bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
@ -299,14 +290,7 @@ GameActions::Result TrackRemoveAction::Execute() const
if (tileElement->IsGhost() != isGhost)
continue;
auto tileTrackType = tileElement->AsTrack()->GetTrackType();
switch (tileTrackType)
{
case TrackElemType::BeginStation:
case TrackElemType::MiddleStation:
tileTrackType = TrackElemType::EndStation;
break;
}
auto tileTrackType = NormaliseTrackType(tileElement->AsTrack()->GetTrackType());
if (tileTrackType != comparableTrackType)
continue;

View File

@ -26,6 +26,8 @@ public:
uint16_t GetActionFlags() const override final;
int32_t NormaliseTrackType(int32_t trackType) const;
void Serialise(DataSerialiser& stream) override;
GameActions::Result Query() const override;
GameActions::Result Execute() const override;