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:
@@ -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
|
||||
|
||||
27
src/openrct2/core/FixedPoint.hpp
Normal file
27
src/openrct2/core/FixedPoint.hpp
Normal 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)
|
||||
@@ -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" />
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../core/FixedPoint.hpp"
|
||||
#include "../rct12/RCT12.h"
|
||||
#include "../ride/RideRatings.h"
|
||||
#include "../world/Park.h"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common.h"
|
||||
#include "../core/FixedPoint.hpp"
|
||||
#include "../world/Location.hpp"
|
||||
#include "RideTypes.h"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user