From eadb1b14bd2d8880464b710119b563db860783ed Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Sat, 3 Dec 2022 16:49:48 +0300 Subject: [PATCH 1/4] Move getFieldIndexForClass outside of header --- loader/include/Geode/modify/Field.hpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/loader/include/Geode/modify/Field.hpp b/loader/include/Geode/modify/Field.hpp index 32eb1ade..ee0ed13d 100644 --- a/loader/include/Geode/modify/Field.hpp +++ b/loader/include/Geode/modify/Field.hpp @@ -47,11 +47,8 @@ namespace geode::modifier { // Padding used for guaranteeing any member of parents // will be in between sizeof(Intermediate) and sizeof(Parent) uintptr_t m_padding; - static inline std::unordered_map nextIndex; - - static size_t getFieldIndexForClass(size_t hash) { - return nextIndex[hash]++; - } + + GEODE_DLL static size_t getFieldIndexForClass(size_t hash); public: static void fieldConstructor(void* offsetField) { From cf4f058945b79f5fa2ea9a97dcf04af6d33ab408 Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Sat, 3 Dec 2022 16:51:46 +0300 Subject: [PATCH 2/4] Move getFieldIndexForClass to source --- loader/src/hooks/GeodeNodeMetadata.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/loader/src/hooks/GeodeNodeMetadata.cpp b/loader/src/hooks/GeodeNodeMetadata.cpp index 70a0f1a8..935aa057 100644 --- a/loader/src/hooks/GeodeNodeMetadata.cpp +++ b/loader/src/hooks/GeodeNodeMetadata.cpp @@ -64,7 +64,6 @@ public: }; // proxy forwards -// clang-format off #include struct ProxyCCNode : Modify { virtual CCObject* getUserObject() { @@ -80,7 +79,10 @@ struct ProxyCCNode : Modify { } }; -// clang-format on +static inline std::unordered_map s_nextIndex; +size_t FieldIntermediate::getFieldIndexForClass(size_t hash) { + return s_nextIndex[hash]++; +} // not const because might modify contents FieldContainer* CCNode::getFieldContainer() { From 780aaf33f89bd8e90894724ffb0403236d4a7151 Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Sat, 3 Dec 2022 16:59:55 +0300 Subject: [PATCH 3/4] remove getFieldIndex from Intermediate --- loader/src/hooks/GeodeNodeMetadata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loader/src/hooks/GeodeNodeMetadata.cpp b/loader/src/hooks/GeodeNodeMetadata.cpp index 935aa057..777635ab 100644 --- a/loader/src/hooks/GeodeNodeMetadata.cpp +++ b/loader/src/hooks/GeodeNodeMetadata.cpp @@ -80,7 +80,7 @@ struct ProxyCCNode : Modify { }; static inline std::unordered_map s_nextIndex; -size_t FieldIntermediate::getFieldIndexForClass(size_t hash) { +size_t modifier::getFieldIndexForClass(size_t hash) { return s_nextIndex[hash]++; } From 7cc5fb14059297a722541e64752d958920ed1a8d Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Sat, 3 Dec 2022 17:00:39 +0300 Subject: [PATCH 4/4] Move getFieldIndex outside class --- loader/include/Geode/modify/Field.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loader/include/Geode/modify/Field.hpp b/loader/include/Geode/modify/Field.hpp index ee0ed13d..99824404 100644 --- a/loader/include/Geode/modify/Field.hpp +++ b/loader/include/Geode/modify/Field.hpp @@ -41,14 +41,14 @@ namespace geode::modifier { return node->getFieldContainer(); } }; + + GEODE_DLL size_t getFieldIndexForClass(size_t hash); template class FieldIntermediate { // Padding used for guaranteeing any member of parents // will be in between sizeof(Intermediate) and sizeof(Parent) uintptr_t m_padding; - - GEODE_DLL static size_t getFieldIndexForClass(size_t hash); public: static void fieldConstructor(void* offsetField) {