mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Merge pull request #10428 from ZehMatt/refactor/guest-happiness-calc
Use integer math for guest initial happiness calculation
This commit is contained in:
@@ -31,7 +31,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 "6"
|
||||
#define NETWORK_STREAM_VERSION "7"
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
|
||||
static Peep* _pickup_peep = nullptr;
|
||||
|
||||
@@ -657,7 +657,10 @@ uint8_t Park::CalculateGuestInitialHappiness(uint8_t percentage)
|
||||
// This sequence can be defined as PI*(9+n)/2 (the value is floored)
|
||||
for (uint8_t n = 1; n < 55; n++)
|
||||
{
|
||||
if ((3.14159 * (9 + n)) / 2 >= percentage)
|
||||
// Avoid floating point math by rescaling PI up.
|
||||
constexpr int32_t SCALE = 100000;
|
||||
constexpr int32_t PI_SCALED = 314159; // PI * SCALE;
|
||||
if (((PI_SCALED * (9 + n)) / SCALE) / 2 >= percentage)
|
||||
{
|
||||
return (9 + n) * 4;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user