Fix #11752: Track pieces with fractional cost are too cheap to build (#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.
This commit is contained in:
Silent 2022-02-19 18:47:13 +01:00 committed by GitHub
parent 8dce36b974
commit 795144662a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

@ -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.

View File

@ -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;
}
@ -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();

View File

@ -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;
@ -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))
{
@ -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;

View File

@ -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;