mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-28 13:52:07 -04:00
fix field containers for separate modify classes in which one of them is a base of another, causing shared indices
This commit is contained in:
parent
318a7f2921
commit
00e971a274
5 changed files with 20 additions and 4 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.0.0-beta.23
|
||||
2.0.0-beta.24
|
|
@ -862,7 +862,9 @@ public:
|
|||
private:
|
||||
friend class geode::modifier::FieldContainer;
|
||||
|
||||
[[deprecated("Will be removed, it's an ABI break")]]
|
||||
GEODE_DLL geode::modifier::FieldContainer* getFieldContainer();
|
||||
GEODE_DLL geode::modifier::FieldContainer* getFieldContainer(char const* forClass);
|
||||
GEODE_DLL void addEventListenerInternal(
|
||||
std::string const& id,
|
||||
geode::EventListenerProtocol* protocol
|
||||
|
|
|
@ -44,8 +44,8 @@ namespace geode::modifier {
|
|||
return m_containedFields.at(index);
|
||||
}
|
||||
|
||||
static FieldContainer* from(cocos2d::CCNode* node) {
|
||||
return node->getFieldContainer();
|
||||
static FieldContainer* from(cocos2d::CCNode* node, char const* forClass) {
|
||||
return node->getFieldContainer(forClass);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -97,7 +97,7 @@ namespace geode::modifier {
|
|||
static_assert(sizeof(Base) == offsetof(Parent, m_fields), "offsetof not correct");
|
||||
|
||||
// generating the container if it doesn't exist
|
||||
auto container = FieldContainer::from(node);
|
||||
auto container = FieldContainer::from(node, typeid(Base).name());
|
||||
|
||||
// the index is global across all mods, so the
|
||||
// function is defined in the loader source
|
||||
|
|
|
@ -17,6 +17,7 @@ struct ProxyCCNode;
|
|||
class GeodeNodeMetadata final : public cocos2d::CCObject {
|
||||
private:
|
||||
FieldContainer* m_fieldContainer;
|
||||
std::unordered_map<std::string, FieldContainer*> m_classFieldContainers;
|
||||
std::string m_id = "";
|
||||
Ref<Layout> m_layout = nullptr;
|
||||
Ref<LayoutOptions> m_layoutOptions = nullptr;
|
||||
|
@ -62,6 +63,13 @@ public:
|
|||
FieldContainer* getFieldContainer() {
|
||||
return m_fieldContainer;
|
||||
}
|
||||
|
||||
FieldContainer* getFieldContainer(char const* forClass) {
|
||||
if (!m_classFieldContainers.count(forClass)) {
|
||||
m_classFieldContainers[forClass] = new FieldContainer();
|
||||
}
|
||||
return m_classFieldContainers[forClass];
|
||||
}
|
||||
};
|
||||
|
||||
// proxy forwards
|
||||
|
@ -99,6 +107,10 @@ FieldContainer* CCNode::getFieldContainer() {
|
|||
return GeodeNodeMetadata::set(this)->getFieldContainer();
|
||||
}
|
||||
|
||||
FieldContainer* CCNode::getFieldContainer(char const* forClass) {
|
||||
return GeodeNodeMetadata::set(this)->getFieldContainer(forClass);
|
||||
}
|
||||
|
||||
std::string CCNode::getID() {
|
||||
return GeodeNodeMetadata::set(this)->m_id;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <Geode/binding/LevelTools.hpp>
|
||||
#include <Geode/binding/LevelInfoLayer.hpp>
|
||||
#include <Geode/binding/CCContentLayer.hpp>
|
||||
#include <Geode/binding/GJSearchObject.hpp>
|
||||
#include <Geode/binding/LevelBrowserLayer.hpp>
|
||||
#include <Geode/loader/Mod.hpp>
|
||||
#include <Geode/loader/Loader.hpp>
|
||||
#include <Geode/loader/Index.hpp>
|
||||
|
|
Loading…
Add table
Reference in a new issue