1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 20:13:07 +01:00

Move fixed point types to FixedPoint.hpp

This commit is contained in:
Aaron van Geffen
2024-05-14 16:25:52 +02:00
parent 6c66bff4b6
commit 9a4aa4bb94
8 changed files with 33 additions and 15 deletions

View File

@@ -38,26 +38,11 @@ using datetime64 = uint64_t;
constexpr datetime64 DATETIME64_MIN = 0;
// Represent fixed point numbers. dp = decimal point
using fixed8_1dp = uint8_t;
using fixed8_2dp = uint8_t;
using fixed16_1dp = int16_t;
using fixed16_2dp = int16_t;
using fixed32_1dp = int32_t;
using fixed32_2dp = int32_t;
using fixed64_1dp = int64_t;
// Money is stored as a multiple of 0.10.
using money16 = fixed16_1dp;
using money32 = fixed32_1dp;
using money64 = fixed64_1dp;
// Construct a fixed point number. For example, to create the value 3.65 you
// would write FIXED_2DP(3,65)
#define FIXED_XDP(x, whole, fraction) ((whole) * (10 * (x)) + (fraction))
#define FIXED_1DP(whole, fraction) FIXED_XDP(1, whole, fraction)
#define FIXED_2DP(whole, fraction) FIXED_XDP(10, whole, fraction)
// For a user defined floating point literal, the parameter type must be a
// `long double` which is problematic on ppc64el, as the architecture uses a
// pair of `doubles` to represent that type. This cannot be converted to a

View File

@@ -0,0 +1,27 @@
/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include <cstdint>
// Represent fixed point numbers. dp = decimal point
using fixed8_1dp = uint8_t;
using fixed8_2dp = uint8_t;
using fixed16_1dp = int16_t;
using fixed16_2dp = int16_t;
using fixed32_1dp = int32_t;
using fixed32_2dp = int32_t;
using fixed64_1dp = int64_t;
// Construct a fixed point number. For example, to create the value 3.65 you
// would write FIXED_2DP(3,65)
#define FIXED_XDP(x, whole, fraction) ((whole) * (10 * (x)) + (fraction))
#define FIXED_1DP(whole, fraction) FIXED_XDP(1, whole, fraction)
#define FIXED_2DP(whole, fraction) FIXED_XDP(10, whole, fraction)

View File

@@ -199,6 +199,7 @@
<ClInclude Include="core\FileStream.h" />
<ClInclude Include="core\FileSystem.hpp" />
<ClInclude Include="core\FileWatcher.h" />
<ClInclude Include="core\FixedPoint.hpp" />
<ClInclude Include="core\GroupVector.hpp" />
<ClInclude Include="core\Guard.hpp" />
<ClInclude Include="core\Http.h" />

View File

@@ -9,6 +9,7 @@
#pragma once
#include "../core/FixedPoint.hpp"
#include "../rct12/RCT12.h"
#include "../ride/RideRatings.h"
#include "../world/Park.h"

View File

@@ -11,6 +11,7 @@
#include "../common.h"
#include "../core/FileSystem.hpp"
#include "../core/FixedPoint.hpp"
#include "../rct12/RCT12.h"
#include "../ride/RideRatings.h"
#include "../world/Park.h"

View File

@@ -13,6 +13,7 @@
#include "../actions/ResultWithMessage.h"
#include "../common.h"
#include "../core/BitSet.hpp"
#include "../core/FixedPoint.hpp"
#include "../object/MusicObject.h"
#include "../rct2/DATLimits.h"
#include "../rct2/Limits.h"

View File

@@ -10,6 +10,7 @@
#pragma once
#include "../common.h"
#include "../core/FixedPoint.hpp"
#include "../world/Location.hpp"
#include "RideTypes.h"

View File

@@ -19,6 +19,7 @@
#include "../audio/AudioMixer.h"
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/FixedPoint.hpp"
#include "../core/Memory.hpp"
#include "../core/Speed.hpp"
#include "../entity/EntityRegistry.h"