Skip to content

Commit

Permalink
fix field alignment by doing max
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Oct 15, 2023
1 parent f8c5e97 commit cac2cbc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions loader/include/Geode/modify/Field.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "../utils/MiniFunction.hpp"
#include "Traits.hpp"

#include <Geode/loader/Loader.hpp>
#include "../utils/MiniFunction.hpp"
#include <cocos2d.h>
#include <vector>

Expand Down Expand Up @@ -49,16 +49,15 @@ namespace geode::modifier {
}
};

[[deprecated("Will be removed in 1.0.0")]]
GEODE_DLL size_t getFieldIndexForClass(size_t hash);
[[deprecated("Will be removed in 1.0.0")]] GEODE_DLL size_t getFieldIndexForClass(size_t hash);
GEODE_DLL size_t getFieldIndexForClass(char const* name);

template <class Parent, class Base>
class FieldIntermediate {
using Intermediate = Modify<Parent, Base>;
// Padding used for guaranteeing any member of parents
// will be in between sizeof(Intermediate) and sizeof(Parent)
alignas(Base) uintptr_t m_padding;
alignas(std::max(alignof(Base), alignof(uintptr_t))) uintptr_t m_padding;

public:
// the constructor that constructs the fields.
Expand Down Expand Up @@ -120,7 +119,7 @@ namespace geode::modifier {
reinterpret_cast<std::byte*>(offsetField) - sizeof(Intermediate)
);
}

Parent* self() {
return this->operator Parent*();
}
Expand Down

0 comments on commit cac2cbc

Please sign in to comment.