Skip to content

Commit 7d42296

Browse files
committed
Forbid reference from writing into rdata
1 parent 49a4d22 commit 7d42296

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Helpers/CompileTime.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct reference {
3838
using value_type = T[Count];
3939

4040
static const auto Size = Count;
41-
41+
static_assert(!std::is_reference_v<T> && (std::is_const_v<T> || (Address > 0x812000)));
4242
constexpr reference() noexcept = default;
4343
reference(reference&) = delete;
4444

@@ -93,7 +93,7 @@ struct reference<T, Address, 0> {
9393

9494
constexpr reference() noexcept = default;
9595
reference(reference&) = delete;
96-
96+
static_assert(!std::is_reference_v<T> && (std::is_const_v<T> || (Address > 0x812000)));
9797
private:
9898
value_type& get() const noexcept {
9999
return *reinterpret_cast<value_type*>(Address);

Powerups.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Powerups {
1010
*/
1111

1212
// the name of the effect, for INI reading purposes
13-
static constexpr reference<const char*, 0x7E523Cu, 19u> const Effects{};
13+
static constexpr reference<const char* const, 0x7E523Cu, 19u> const Effects{};
1414

1515
// the weight of the effect
1616
static constexpr reference<int, 0x81DA8Cu, 19u> const Weights{};

Theater.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
struct Theater //US English spelling to keep it consistent with the game
99
{
1010
public:
11-
static constexpr reference<Theater, 0x7E1B78u, 6u> const Array {};
11+
static constexpr reference<Theater const, 0x7E1B78u, 6u> const Array {};
1212

1313
static void __fastcall Init(TheaterType theater)
1414
{
1515
JMP_STD(0x5349C0);
1616
}
1717

18-
static Theater* Get(TheaterType theater)
18+
static Theater const* Get(TheaterType theater)
1919
{
2020
return &Array[static_cast<int>(theater)];
2121
}
2222

23-
static Theater& GetTheater(TheaterType theater)
23+
static Theater const& GetTheater(TheaterType theater)
2424
{
2525
return Array[static_cast<int>(theater)];
2626
}

TunnelLocomotionClass.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class __declspec(align(4)) NOVTABLE TunnelLocomotionClass : public LocomotionCla
88
{
99
public:
1010
static constexpr uintptr_t ILocoVTable = 0x7F5A24;
11-
static constexpr reference<double, 0x7F5B20u> const TunnelMovementSpeed {};
11+
static constexpr reference<double const, 0x7F5B20u> const TunnelMovementSpeed {};
1212

1313
enum State
1414
{

0 commit comments

Comments
 (0)