Skip to content

Commit

Permalink
Fix #11752: Track pieces with fractional cost are too cheap to build (#…
Browse files Browse the repository at this point in the history
…16477)

Fixes an inconsistency wuth RCT2 where track prices with a fractional part
did not have their price rounded up when building, but did when refunding.
This created an exploit where refunding such a track piece granted the player
0.50€ more than they spent on the piece.
  • Loading branch information
CookiePLMonster committed Feb 19, 2022
1 parent 8dce36b commit 7951446
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions distribution/changelog.txt
Expand Up @@ -26,6 +26,7 @@
- Change: [#16077] When importing SV6 files, the RCT1 land types are only added when they were actually used.
- Change: [#16424] Following an entity in the title sequence no longer toggles underground view when it's underground.
- Change: [#16493] Boat Hire and Submarine Ride support costs now match their visual appearance.
- Fix: [#11752] Track pieces with fractional cost are too cheap to build.
- Fix: [#13336] Can no longer place Bumble Bee track design (reverts #12707).
- Fix: [#14155] Map Generator sometimes places non-tree objects as trees.
- Fix: [#14674] Recent Messages only shows first few notifications.
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/actions/MazePlaceTrackAction.cpp
Expand Up @@ -119,7 +119,7 @@ GameActions::Result MazePlaceTrackAction::Query() const

const auto& ted = GetTrackElementDescriptor(TrackElemType::Maze);
money32 price = (((ride->GetRideTypeDescriptor().BuildCosts.TrackPrice * ted.Price) >> 16));
res.Cost = canBuild.Cost + price / 2 * 10;
res.Cost = ((canBuild.Cost + price) / 2) * 10;

return res;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ GameActions::Result MazePlaceTrackAction::Execute() const

const auto& ted = GetTrackElementDescriptor(TrackElemType::Maze);
money32 price = (((ride->GetRideTypeDescriptor().BuildCosts.TrackPrice * ted.Price) >> 16));
res.Cost = canBuild.Cost + price / 2 * 10;
res.Cost = ((canBuild.Cost + price) / 2) * 10;

auto startLoc = _loc.ToTileStart();

Expand Down
8 changes: 4 additions & 4 deletions src/openrct2/actions/TrackPlaceAction.cpp
Expand Up @@ -393,14 +393,14 @@ GameActions::Result TrackPlaceAction::Query() const
supportHeight = (10 * COORDS_Z_STEP);
}

cost += ((supportHeight / (2 * COORDS_Z_STEP)) * ride->GetRideTypeDescriptor().BuildCosts.SupportPrice) * 5;
cost += ((supportHeight / (2 * COORDS_Z_STEP)) * ride->GetRideTypeDescriptor().BuildCosts.SupportPrice);
}

money32 price = ride->GetRideTypeDescriptor().BuildCosts.TrackPrice;
price *= ted.Price;

price >>= 16;
res.Cost = cost + ((price / 2) * 10);
res.Cost = ((cost + price) / 2) * 10;
res.SetData(std::move(resultData));

return res;
Expand Down Expand Up @@ -522,7 +522,7 @@ GameActions::Result TrackPlaceAction::Execute() const
supportHeight = (10 * COORDS_Z_STEP);
}

cost += ((supportHeight / (2 * COORDS_Z_STEP)) * ride->GetRideTypeDescriptor().BuildCosts.SupportPrice) * 5;
cost += (supportHeight / (2 * COORDS_Z_STEP)) * ride->GetRideTypeDescriptor().BuildCosts.SupportPrice;

if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
{
Expand Down Expand Up @@ -697,7 +697,7 @@ GameActions::Result TrackPlaceAction::Execute() const
price *= ted.Price;

price >>= 16;
res.Cost = cost + ((price / 2) * 10);
res.Cost = ((cost + price) / 2) * 10;
res.SetData(std::move(resultData));

return res;
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/network/NetworkBase.cpp
Expand Up @@ -42,7 +42,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "17"
#define NETWORK_STREAM_VERSION "18"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION

static Peep* _pickup_peep = nullptr;
Expand Down

0 comments on commit 7951446

Please sign in to comment.