From 5ecee87e1ccf724f8aae02e3a9f1c36583339783 Mon Sep 17 00:00:00 2001 From: ninXout <58670749+ninXout@users.noreply.github.com> Date: Wed, 1 Mar 2023 11:26:51 -0500 Subject: [PATCH 01/18] Some MacOS bindings (#140) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [CreatorLayer] onGauntlets() * [LevelTools] base64EncodeString(), verifyLevelIntegrity(), xPosForTime(), timeForXPos(), getAudioFilename(), getAudioTitle(), getArtistForAudio(), getURLForAudio(). * [LevelTools] getLevel() * [LocalLevelManager] init() * [LeaderboardsLayer] init(), [LevelLeaderboard] init() --------- Co-authored-by: Nosu♡ <93537876+Nosu-u@users.noreply.github.com> --- bindings/GeometryDash.bro | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/bindings/GeometryDash.bro b/bindings/GeometryDash.bro index 6fb6f127..f43b79ee 100644 --- a/bindings/GeometryDash.bro +++ b/bindings/GeometryDash.bro @@ -866,7 +866,7 @@ class CreatorLayer : cocos2d::CCLayer { void onFameLevels(cocos2d::CCObject*) = win 0x4ee70; void onMapPacks(cocos2d::CCObject*) = win 0x4efb0; void onOnlineLevels(cocos2d::CCObject*) = win 0x4ef60; - void onGauntlets(cocos2d::CCObject*) = win 0x4f0a0; + void onGauntlets(cocos2d::CCObject*) = mac 0x142b20, win 0x4f0a0; void onSecretVault(cocos2d::CCObject*) = win 0x4f1d0; void onTreasureRoom(cocos2d::CCObject*) = win 0x4f540; virtual void sceneWillResume() = win 0x4fb50; @@ -3476,7 +3476,7 @@ class LeaderboardManagerDelegate {} class LeaderboardsLayer : cocos2d::CCLayer { static LeaderboardsLayer* create(LeaderboardState state) = win 0x158710; - bool init(LeaderboardState state) = win 0x1587b0; + bool init(LeaderboardState state) = mac 0x29f6d0, win 0x1587b0; } class LevelBrowserLayer : cocos2d::CCLayer { @@ -3763,7 +3763,7 @@ class LevelInfoLayer : cocos2d::CCLayer, LevelDownloadDelegate, LevelUpdateDeleg class LevelLeaderboard : FLAlertLayer { void onChangeType(cocos2d::CCObject* sender) = win 0x17d090; void onGarage(cocos2d::CCObject* sender) = win 0x17d1b0; - bool init(GJGameLevel* level, int type) = win 0x17c4f0; + bool init(GJGameLevel* level, int type) = mac 0x20d710, win 0x17c4f0; static LevelLeaderboard* create(GJGameLevel* level, LevelLeaderboardType leaderboardType) = win 0x17c440; } @@ -3929,6 +3929,7 @@ class LocalLevelManager : cocos2d::CCNode { inline static LocalLevelManager* get() { return LocalLevelManager::sharedState(); } + bool init() = mac 0x2384e0; PAD = mac 0x10, win 0x1C; cocos2d::CCDictionary* m_loadData; @@ -5406,11 +5407,15 @@ class VideoOptionsLayer : FLAlertLayer { } class LevelTools { - static gd::string base64EncodeString(gd::string) = win 0x18b310; + static gd::string base64EncodeString(gd::string) = mac 0x294470, win 0x18b310; static gd::string base64DecodeString(gd::string) = mac 0x294510, win 0x18b3b0; - static GJGameLevel *getLevel(int, bool) = win 0x189370; - static bool verifyLevelIntegrity(gd::string, int) = win 0x18b180; - static float xPosForTime(float, cocos2d::CCArray*, int) = win 0x18acd0; - static float timeForXPos(float, cocos2d::CCArray*, int) = win 0x18ae70; + static GJGameLevel* getLevel(int, bool) = mac 0x2908c0, win 0x189370; + static bool verifyLevelIntegrity(gd::string, int) = mac 0x294360, win 0x18b180; + static float xPosForTime(float, cocos2d::CCArray*, int) = mac 0x293d90, win 0x18acd0; + static float timeForXPos(float, cocos2d::CCArray*, int) = mac 0x293eb0, win 0x18ae70; + static gd::string getAudioFilename(int) = mac 0x292840; + static gd::string getAudioTitle(int) = mac 0x2922f0; + static gd::string getArtistForAudio(int) = mac 0x292d90; + static gd::string getURLForAudio(int) = mac 0x292f10; } // clang-format on From 7710fa91b8dd5a964e365580c0ae650e4b233683 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Thu, 2 Mar 2023 01:02:09 +0300 Subject: [PATCH 02/18] Fix field index, allow Parent* conversion of field --- loader/include/Geode/modify/Field.hpp | 16 +++++++++++----- loader/src/hooks/GeodeNodeMetadata.cpp | 6 +++--- loader/src/ids/EditorPauseLayer.cpp | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/loader/include/Geode/modify/Field.hpp b/loader/include/Geode/modify/Field.hpp index c87b59d4..adf88321 100644 --- a/loader/include/Geode/modify/Field.hpp +++ b/loader/include/Geode/modify/Field.hpp @@ -32,8 +32,8 @@ namespace geode::modifier { void* getField(size_t index) { if (m_containedFields.size() <= index) { - m_containedFields.resize(index + 1); - m_destructorFunctions.resize(index + 1); + m_containedFields.push_back(nullptr); + m_destructorFunctions.push_back(nullptr); } return m_containedFields.at(index); } @@ -49,7 +49,7 @@ namespace geode::modifier { } }; - GEODE_DLL size_t getFieldIndexForClass(size_t hash); + GEODE_DLL size_t getFieldIndexForClass(char const* name); template class FieldIntermediate { @@ -90,7 +90,7 @@ namespace geode::modifier { } template > - Parent* operator->() { + operator Parent*() { // get the this pointer of the base // field intermediate is the first member of Modify // meaning we canget the base from ourself @@ -102,7 +102,7 @@ namespace geode::modifier { // the index is global across all mods, so the // function is defined in the loader source - static size_t index = getFieldIndexForClass(typeid(Base).hash_code()); + static size_t index = getFieldIndexForClass(typeid(Base).name()); // the fields are actually offset from their original // offset, this is done to save on allocation and space @@ -119,6 +119,12 @@ namespace geode::modifier { reinterpret_cast(offsetField) - sizeof(Intermediate) ); } + + + template > + Parent* operator->() { + return this->operator Parent*(); + } }; } diff --git a/loader/src/hooks/GeodeNodeMetadata.cpp b/loader/src/hooks/GeodeNodeMetadata.cpp index f520a98b..4abf24f5 100644 --- a/loader/src/hooks/GeodeNodeMetadata.cpp +++ b/loader/src/hooks/GeodeNodeMetadata.cpp @@ -79,9 +79,9 @@ struct ProxyCCNode : Modify { } }; -static inline std::unordered_map s_nextIndex; -size_t modifier::getFieldIndexForClass(size_t hash) { - return s_nextIndex[hash]++; +static inline std::unordered_map s_nextIndex; +size_t modifier::getFieldIndexForClass(char const* name) { + return s_nextIndex[name]++; } // not const because might modify contents diff --git a/loader/src/ids/EditorPauseLayer.cpp b/loader/src/ids/EditorPauseLayer.cpp index 6b43b69b..ebba86d0 100644 --- a/loader/src/ids/EditorPauseLayer.cpp +++ b/loader/src/ids/EditorPauseLayer.cpp @@ -251,7 +251,7 @@ $register_ids(EditorPauseLayer) { ); } menu->setContentSize({ 165.f, 100.f }); - menu->setPosition(75.f, winSize.height - 55.f); + menu->setPosition(70.f, winSize.height - 55.f); menu->updateLayout(); } } From 534b20d3dfaa6dade185d3212aa448c34dc1c618 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Thu, 2 Mar 2023 01:06:16 +0300 Subject: [PATCH 03/18] Update changelog.md --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf26c84f..879594fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,16 @@ # Geode Changelog +## v1.0.0-beta.9 + * Fix multiple modifiers not being able to have fields on same class due to having same field index (7710fa9) + * Add `Result::ok` and `Result::err` for converting the `Result` into `std::optional` (4a15afc) + ## v1.0.0-beta.8 * Unload the mod even when first time warning pops up (63b4774) - * Make log not throw, but warn on invalid format (6aba7cf) * Error when address of a function returns nullptr when hooking (724a9d3) + * Add support for Geode CLI v2.0.0 (which has not been released yet) (088ac7b, deadb58) + * Logging no longer causes a crash on invalid formats, but instead just warns (6aba7cf) + * `file::pickFile` now uses the last item in the default path as the default filename to save/open (5c9ee08) + * Fix `EditorPauseLayer` crashing constantly due to some members being accidentally set to `nullptr` (33a91d6) ## v1.0.0-beta.7 * Add `Mod::getResourcesDir` for getting the mod resources directory (0055032) From ceeea0bd51631ed58f3a78aa1c405b1a730cf233 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Thu, 2 Mar 2023 01:08:25 +0300 Subject: [PATCH 04/18] Make the field fix only a minor change --- loader/include/Geode/modify/Field.hpp | 2 ++ loader/src/hooks/GeodeNodeMetadata.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/loader/include/Geode/modify/Field.hpp b/loader/include/Geode/modify/Field.hpp index adf88321..0b503f4f 100644 --- a/loader/include/Geode/modify/Field.hpp +++ b/loader/include/Geode/modify/Field.hpp @@ -49,6 +49,8 @@ namespace geode::modifier { } }; + [[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 diff --git a/loader/src/hooks/GeodeNodeMetadata.cpp b/loader/src/hooks/GeodeNodeMetadata.cpp index 4abf24f5..8efc1818 100644 --- a/loader/src/hooks/GeodeNodeMetadata.cpp +++ b/loader/src/hooks/GeodeNodeMetadata.cpp @@ -84,6 +84,10 @@ size_t modifier::getFieldIndexForClass(char const* name) { return s_nextIndex[name]++; } +size_t modifier::getFieldIndexForClass(size_t hash) { + return s_nextIndex[std::string(hash)]++; +} + // not const because might modify contents FieldContainer* CCNode::getFieldContainer() { return GeodeNodeMetadata::set(this)->getFieldContainer(); From e89a7922935a705ee95291d73660b9e3fef6114e Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Thu, 2 Mar 2023 01:09:07 +0300 Subject: [PATCH 05/18] Fix conversion of integer to string --- 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 8efc1818..cf2777ac 100644 --- a/loader/src/hooks/GeodeNodeMetadata.cpp +++ b/loader/src/hooks/GeodeNodeMetadata.cpp @@ -85,7 +85,7 @@ size_t modifier::getFieldIndexForClass(char const* name) { } size_t modifier::getFieldIndexForClass(size_t hash) { - return s_nextIndex[std::string(hash)]++; + return s_nextIndex[std::to_string(hash)]++; } // not const because might modify contents From abad98f9514a4422b47b53d76c440496088773a8 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Thu, 2 Mar 2023 01:13:32 +0300 Subject: [PATCH 06/18] Fix autoEnableHook not affecting mod enabling --- loader/src/loader/ModImpl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/loader/src/loader/ModImpl.cpp b/loader/src/loader/ModImpl.cpp index d5e8f359..6c0146d4 100644 --- a/loader/src/loader/ModImpl.cpp +++ b/loader/src/loader/ModImpl.cpp @@ -356,7 +356,9 @@ Result<> Mod::Impl::enable() { } for (auto const& hook : m_hooks) { - GEODE_UNWRAP(this->enableHook(hook)); + if (hook->getAutoEnable()) { + GEODE_UNWRAP(this->enableHook(hook)); + } } for (auto const& patch : m_patches) { From c71890c179577a246e73ab07c7dc045f58f1276e Mon Sep 17 00:00:00 2001 From: mat <26722564+matcool@users.noreply.github.com> Date: Wed, 1 Mar 2023 20:09:37 -0300 Subject: [PATCH 07/18] remove unecessary templates --- loader/include/Geode/modify/Field.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/loader/include/Geode/modify/Field.hpp b/loader/include/Geode/modify/Field.hpp index 0b503f4f..181657b6 100644 --- a/loader/include/Geode/modify/Field.hpp +++ b/loader/include/Geode/modify/Field.hpp @@ -91,7 +91,6 @@ namespace geode::modifier { static_cast(parent)->Parent::~Parent(); } - template > operator Parent*() { // get the this pointer of the base // field intermediate is the first member of Modify @@ -122,8 +121,6 @@ namespace geode::modifier { ); } - - template > Parent* operator->() { return this->operator Parent*(); } From 0706e52c81fc9f204e28b2c8e7c8676249ace073 Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:08:56 +0300 Subject: [PATCH 08/18] Add m_fields.self() --- loader/include/Geode/modify/Field.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loader/include/Geode/modify/Field.hpp b/loader/include/Geode/modify/Field.hpp index 181657b6..f9374022 100644 --- a/loader/include/Geode/modify/Field.hpp +++ b/loader/include/Geode/modify/Field.hpp @@ -120,6 +120,10 @@ namespace geode::modifier { reinterpret_cast(offsetField) - sizeof(Intermediate) ); } + + Parent* self() { + return this->operator Parent*(); + } Parent* operator->() { return this->operator Parent*(); From c89df7b99223bd48e32f4bc8151cf1a4f79b00c3 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Mon, 6 Mar 2023 00:52:39 +0300 Subject: [PATCH 09/18] rename monostate ctors to zero ctors & make it platform independent --- codegen/src/BindingGen.cpp | 9 +- codegen/src/SourceGen.cpp | 4 +- loader/include/Geode/DefaultInclude.hpp | 31 ++-- loader/include/Geode/cocos/CCDirector.h | 9 +- loader/include/Geode/cocos/CCScheduler.h | 1 + .../include/Geode/cocos/base_nodes/CCNode.h | 4 +- loader/include/Geode/cocos/cocoa/CCObject.h | 2 +- loader/include/Geode/cocos/cocoa/CCSet.h | 2 +- loader/include/Geode/cocos/cocoa/CCString.h | 1 + .../Geode/cocos/draw_nodes/CCDrawNode.h | 2 +- .../GUI/CCControlExtension/CCControl.h | 2 +- .../CCControlColourPicker.h | 2 +- .../GUI/CCControlExtension/CCScale9Sprite.h | 2 +- .../GUI/CCScrollView/CCScrollView.h | 2 +- .../keypad_dispatcher/CCKeypadDelegate.h | 2 +- .../Geode/cocos/label_nodes/CCLabelBMFont.h | 2 +- .../Geode/cocos/label_nodes/CCLabelTTF.h | 1 + .../layers_scenes_transitions_nodes/CCLayer.h | 6 +- .../layers_scenes_transitions_nodes/CCScene.h | 2 +- .../include/Geode/cocos/menu_nodes/CCMenu.h | 2 +- .../Geode/cocos/menu_nodes/CCMenuItem.h | 8 +- .../cocos/platform/CCApplicationProtocol.h | 14 +- .../Geode/cocos/platform/CCFileUtils.h | 10 +- loader/include/Geode/cocos/platform/CCImage.h | 2 +- .../Geode/cocos/platform/ios/CCApplication.h | 2 +- .../Geode/cocos/platform/mac/CCApplication.h | 2 +- .../cocos/platform/win32/CCApplication.h | 2 +- .../Geode/cocos/platform/win32/CCEGLView.h | 1 + .../keyboard_dispatcher/CCKeyboardDelegate.h | 2 +- .../robtop/mouse_dispatcher/CCMouseDelegate.h | 2 +- .../Geode/cocos/sprite_nodes/CCSprite.h | 2 +- .../cocos/sprite_nodes/CCSpriteBatchNode.h | 2 +- .../cocos/text_input_node/CCIMEDelegate.h | 1 + .../Geode/cocos/textures/CCTexture2D.h | 2 +- .../cocos/touch_dispatcher/CCTouchHandler.h | 6 +- loader/include/Geode/modify/Modify.hpp | 4 +- loader/include/Geode/utils/addresser.hpp | 171 ++++++------------ loader/include/link/gdstring.lib | Bin 35350 -> 35422 bytes 38 files changed, 129 insertions(+), 192 deletions(-) diff --git a/codegen/src/BindingGen.cpp b/codegen/src/BindingGen.cpp index c87fb974..527b43ef 100644 --- a/codegen/src/BindingGen.cpp +++ b/codegen/src/BindingGen.cpp @@ -34,10 +34,7 @@ public: static constexpr auto CLASS_NAME = "{class_name}"; )GEN"; - char const* monostate_constructor = R"GEN( GEODE_MONOSTATE_CONSTRUCTOR_GD({class_name}, {first_base}) -)GEN"; - - char const* monostate_constructor_cutoff = R"GEN( GEODE_MONOSTATE_CONSTRUCTOR_CUTOFF({class_name}, {first_base}) + char const* zero_constructor = R"GEN( GEODE_ZERO_CONSTRUCTOR({class_name}, {first_base}) )GEN"; char const* function_definition = R"GEN( @@ -180,9 +177,7 @@ std::string generateBindingHeader(Root& root, ghc::filesystem::path const& singl // what. if (!cls.superclasses.empty()) { single_output += fmt::format( - can_find(cls.superclasses[0], "cocos2d") - ? format_strings::monostate_constructor_cutoff - : format_strings::monostate_constructor, + format_strings::zero_constructor, fmt::arg("class_name", cls.name), fmt::arg("first_base", cls.superclasses[0]) ); diff --git a/codegen/src/SourceGen.cpp b/codegen/src/SourceGen.cpp index 0ce659c8..2de69924 100644 --- a/codegen/src/SourceGen.cpp +++ b/codegen/src/SourceGen.cpp @@ -85,13 +85,13 @@ auto {class_name}::{function_name}({parameters}){const} -> decltype({function_na reinterpret_cast(func)(this{parameter_comma}{arguments}); // we need to construct it back so that it uhhh ummm doesnt crash // while going to the child destructors - auto thing = new (this) {class_name}(std::monostate(), sizeof({class_name})); + auto thing = new (this) {class_name}(geode::ZeroConstructor); CCDestructor::lock(this) = true; }} )GEN"; char const* declare_constructor = R"GEN( -{class_name}::{function_name}({parameters}) : {class_name}(std::monostate(), sizeof({class_name})) {{ +{class_name}::{function_name}({parameters}) : {class_name}(geode::ZeroConstructor) {{ // here we construct it as normal as we can, then destruct it // using the generated functions. this ensures no memory gets leaked // no crashes :pray: diff --git a/loader/include/Geode/DefaultInclude.hpp b/loader/include/Geode/DefaultInclude.hpp index 90c48f47..70d8e2e4 100644 --- a/loader/include/Geode/DefaultInclude.hpp +++ b/loader/include/Geode/DefaultInclude.hpp @@ -69,28 +69,21 @@ namespace cocos2d::extension {} #define GEODE_EXPAND(x) x #define GEODE_INVOKE(macro, ...) GEODE_EXPAND(macro(__VA_ARGS__)) -#define GEODE_FILL_CONSTRUCTOR(Class_, Offset_) \ - Class_(std::monostate, size_t fill) : \ - Class_({}, std::memset(reinterpret_cast(this) + Offset_, 0, fill - Offset_)) {} \ - Class_(std::monostate, void*) +namespace geode { + struct ZeroConstructorType {}; -#define GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(Class_) \ - GEODE_MACOS(GEODE_FILL_CONSTRUCTOR(Class_, 0){}) \ - GEODE_IOS(GEODE_FILL_CONSTRUCTOR(Class_, 0){}) + static constexpr auto ZeroConstructor = ZeroConstructorType(); +} -#define GEODE_MONOSTATE_CONSTRUCTOR_COCOS(Class_, Base_) \ - GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \ - GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) +#define GEODE_ZERO_CONSTRUCTOR_BEGIN(Class_) \ + Class_(geode::ZeroConstructorType, void*) {} \ + Class_(geode::ZeroConstructorType, size_t fill) : \ + Class_(geode::ZeroConstructor, std::memset(static_cast(this), 0, fill)) {} \ + Class_(geode::ZeroConstructorType) : Class_(geode::ZeroConstructor, nullptr) {} -#define GEODE_MONOSTATE_CONSTRUCTOR_GD(Class_, Base_) \ - GEODE_WINDOWS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \ - GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \ - GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) - -#define GEODE_MONOSTATE_CONSTRUCTOR_CUTOFF(Class_, Base_) \ - GEODE_WINDOWS(GEODE_FILL_CONSTRUCTOR(Class_, sizeof(Base_)) : Base_(){}) \ - GEODE_MACOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) \ - GEODE_IOS(Class_(std::monostate, size_t fill) : Base_({}, fill){}) +#define GEODE_ZERO_CONSTRUCTOR(Class_, Base_) \ + Class_(geode::ZeroConstructorType, size_t fill) : Base_(geode::ZeroConstructor, fill) {} \ + Class_(geode::ZeroConstructorType) : Base_(geode::ZeroConstructor, sizeof(Class_)) {} #define GEODE_NUMBER_OF_ARGS(...) \ GEODE_EXPAND(GEODE_NUMBER_OF_ARGS_(__VA_ARGS__, GEODE_NUMBER_SEQUENCE(), )) diff --git a/loader/include/Geode/cocos/CCDirector.h b/loader/include/Geode/cocos/CCDirector.h index 093415ed..dce5623c 100644 --- a/loader/include/Geode/cocos/CCDirector.h +++ b/loader/include/Geode/cocos/CCDirector.h @@ -121,6 +121,7 @@ public: * @js ctor */ CCDirector(void); + GEODE_ZERO_CONSTRUCTOR(CCDirector, CCObject) /** * @js NA * @lua NA @@ -146,7 +147,7 @@ public: /** Get the FPS value */ inline double getAnimationInterval(void) { return m_dAnimationInterval; } /** Set the FPS value. */ - virtual void setAnimationInterval(double dValue) = 0; + virtual void setAnimationInterval(double dValue) {} /** Whether or not to display the FPS on the bottom-left corner */ inline bool isDisplayStats(void) { return m_bDisplayStats; } @@ -308,13 +309,13 @@ protected: /** Stops the animation. Nothing will be drawn. The main loop won't be triggered anymore. If you don't want to pause your animation call [pause] instead. */ - virtual void stopAnimation(void) = 0; + virtual void stopAnimation(void) {} /** The main loop is triggered again. Call this function only if [stopAnimation] was called earlier @warning Don't call this function to start the main loop. To run the main loop call runWithScene */ - virtual void startAnimation(void) = 0; + virtual void startAnimation(void) {} public: /** Draw the scene. @@ -345,7 +346,7 @@ public: void setDepthTest(bool bOn); protected: - virtual void mainLoop(void) = 0; + virtual void mainLoop(void) {} /** The size in pixels of the surface. It could be different than the screen size. High-res devices might have a higher surface size than the screen size. diff --git a/loader/include/Geode/cocos/CCScheduler.h b/loader/include/Geode/cocos/CCScheduler.h index bbfdb9bc..4c1c4d96 100644 --- a/loader/include/Geode/cocos/CCScheduler.h +++ b/loader/include/Geode/cocos/CCScheduler.h @@ -141,6 +141,7 @@ class CC_DLL CCScheduler : public CCObject GEODE_FRIEND_MODIFY public: CCScheduler(); + GEODE_ZERO_CONSTRUCTOR(CCScheduler, CCObject) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/base_nodes/CCNode.h b/loader/include/Geode/cocos/base_nodes/CCNode.h index 809f4e97..e2388ba1 100644 --- a/loader/include/Geode/cocos/base_nodes/CCNode.h +++ b/loader/include/Geode/cocos/base_nodes/CCNode.h @@ -140,7 +140,7 @@ public: * @js ctor */ CCNode(void); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCNode, CCObject) + GEODE_ZERO_CONSTRUCTOR(CCNode, CCObject) /** * Default destructor @@ -1638,7 +1638,7 @@ public: * @js ctor */ CCNodeRGBA(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCNodeRGBA, CCNode) + GEODE_ZERO_CONSTRUCTOR(CCNodeRGBA, CCNode) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/cocoa/CCObject.h b/loader/include/Geode/cocos/cocoa/CCObject.h index 1f7adfae..4719faa0 100644 --- a/loader/include/Geode/cocos/cocoa/CCObject.h +++ b/loader/include/Geode/cocos/cocoa/CCObject.h @@ -112,7 +112,7 @@ protected: int m_nUnknown; ) public: - GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(CCObject) + GEODE_ZERO_CONSTRUCTOR_BEGIN(CCObject) CCObject(void); /** * @lua NA diff --git a/loader/include/Geode/cocos/cocoa/CCSet.h b/loader/include/Geode/cocos/cocoa/CCSet.h index 49784576..366955f2 100644 --- a/loader/include/Geode/cocos/cocoa/CCSet.h +++ b/loader/include/Geode/cocos/cocoa/CCSet.h @@ -46,7 +46,7 @@ public: * @lua NA */ CCSet(void); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCSet, CCObject) + GEODE_ZERO_CONSTRUCTOR(CCSet, CCObject) /** * @lua NA */ diff --git a/loader/include/Geode/cocos/cocoa/CCString.h b/loader/include/Geode/cocos/cocoa/CCString.h index 21bc709f..9cdc2371 100644 --- a/loader/include/Geode/cocos/cocoa/CCString.h +++ b/loader/include/Geode/cocos/cocoa/CCString.h @@ -47,6 +47,7 @@ class CC_DLL CCString : public CCObject { GEODE_FRIEND_MODIFY public: + GEODE_ZERO_CONSTRUCTOR(CCString, CCObject) /** * @lua NA */ diff --git a/loader/include/Geode/cocos/draw_nodes/CCDrawNode.h b/loader/include/Geode/cocos/draw_nodes/CCDrawNode.h index e6659267..fc64ab99 100644 --- a/loader/include/Geode/cocos/draw_nodes/CCDrawNode.h +++ b/loader/include/Geode/cocos/draw_nodes/CCDrawNode.h @@ -94,7 +94,7 @@ public: void setBlendFunc(const ccBlendFunc &blendFunc); CCDrawNode(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCDrawNode, CCNodeRGBA) + GEODE_ZERO_CONSTRUCTOR(CCDrawNode, CCNodeRGBA) /** listen the event that coming to foreground on Android * @js NA diff --git a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControl.h b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControl.h index 3ad32bc7..d6fc4b50 100644 --- a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControl.h +++ b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControl.h @@ -139,7 +139,7 @@ public: * @js ctor */ CCControl(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCControl, CCLayerRGBA) + GEODE_ZERO_CONSTRUCTOR(CCControl, CCLayerRGBA) virtual bool init(void); /** diff --git a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h index d1c6fa25..9c7d2ca6 100644 --- a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h +++ b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h @@ -58,7 +58,7 @@ public: virtual void setColorValue(ccColor3B const&); ) - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCControlColourPicker, CCControl) + GEODE_ZERO_CONSTRUCTOR(CCControlColourPicker, CCControl) CCControlColourPicker(); virtual ~CCControlColourPicker(); diff --git a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCScale9Sprite.h index d3176597..76ec289a 100644 --- a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -54,7 +54,7 @@ class CC_DLL CCScale9Sprite : public CCNodeRGBA { public: CCScale9Sprite(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCScale9Sprite, CCNodeRGBA) + GEODE_ZERO_CONSTRUCTOR(CCScale9Sprite, CCNodeRGBA) virtual ~CCScale9Sprite(); public: diff --git a/loader/include/Geode/cocos/extensions/GUI/CCScrollView/CCScrollView.h b/loader/include/Geode/cocos/extensions/GUI/CCScrollView/CCScrollView.h index 3e5bfeef..8476bdec 100644 --- a/loader/include/Geode/cocos/extensions/GUI/CCScrollView/CCScrollView.h +++ b/loader/include/Geode/cocos/extensions/GUI/CCScrollView/CCScrollView.h @@ -69,7 +69,7 @@ public: * @js ctor */ CCScrollView(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCScrollView, CCLayer) + GEODE_ZERO_CONSTRUCTOR(CCScrollView, CCLayer) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/keypad_dispatcher/CCKeypadDelegate.h b/loader/include/Geode/cocos/keypad_dispatcher/CCKeypadDelegate.h index cf588eba..e812dac6 100644 --- a/loader/include/Geode/cocos/keypad_dispatcher/CCKeypadDelegate.h +++ b/loader/include/Geode/cocos/keypad_dispatcher/CCKeypadDelegate.h @@ -59,7 +59,7 @@ class CC_DLL CCKeypadHandler : public CCObject { GEODE_FRIEND_MODIFY public: - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCKeypadHandler, CCObject) + GEODE_ZERO_CONSTRUCTOR(CCKeypadHandler, CCObject) inline CCKeypadHandler() = default; virtual ~CCKeypadHandler(void); diff --git a/loader/include/Geode/cocos/label_nodes/CCLabelBMFont.h b/loader/include/Geode/cocos/label_nodes/CCLabelBMFont.h index d7a90866..5d36195a 100644 --- a/loader/include/Geode/cocos/label_nodes/CCLabelBMFont.h +++ b/loader/include/Geode/cocos/label_nodes/CCLabelBMFont.h @@ -198,7 +198,7 @@ public: * @js ctor */ CCLabelBMFont(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCLabelBMFont, CCSpriteBatchNode) + GEODE_ZERO_CONSTRUCTOR(CCLabelBMFont, CCSpriteBatchNode) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/label_nodes/CCLabelTTF.h b/loader/include/Geode/cocos/label_nodes/CCLabelTTF.h index 721d8b60..fdea5e53 100644 --- a/loader/include/Geode/cocos/label_nodes/CCLabelTTF.h +++ b/loader/include/Geode/cocos/label_nodes/CCLabelTTF.h @@ -63,6 +63,7 @@ public: * @js ctor */ CCLabelTTF(); + GEODE_ZERO_CONSTRUCTOR(CCLabelTTF, CCSprite) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCLayer.h b/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCLayer.h index 512fdf6a..7305cfb3 100644 --- a/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCLayer.h +++ b/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCLayer.h @@ -75,7 +75,7 @@ public: * @js ctor */ CCLayer(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCLayer, CCNode) + GEODE_ZERO_CONSTRUCTOR(CCLayer, CCNode) /** * @js NA * @lua NA @@ -233,7 +233,7 @@ public: * @js ctor */ CCLayerRGBA(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCLayerRGBA, CCLayer) + GEODE_ZERO_CONSTRUCTOR(CCLayerRGBA, CCLayer) /** * @js NA * @lua NA @@ -290,7 +290,7 @@ public: * @js ctor */ CCLayerColor(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCLayerColor, CCLayerRGBA) + GEODE_ZERO_CONSTRUCTOR(CCLayerColor, CCLayerRGBA) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCScene.h b/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCScene.h index 21003355..ed00cdda 100644 --- a/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCScene.h +++ b/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCScene.h @@ -63,7 +63,7 @@ public: * @js ctor */ CCScene(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCScene, CCNode) + GEODE_ZERO_CONSTRUCTOR(CCScene, CCNode) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/menu_nodes/CCMenu.h b/loader/include/Geode/cocos/menu_nodes/CCMenu.h index dedd67f0..23e10daa 100644 --- a/loader/include/Geode/cocos/menu_nodes/CCMenu.h +++ b/loader/include/Geode/cocos/menu_nodes/CCMenu.h @@ -64,7 +64,7 @@ public: * @js ctor */ CCMenu() : m_pSelectedItem(NULL) {} - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCMenu, CCLayerRGBA) + GEODE_ZERO_CONSTRUCTOR(CCMenu, CCLayerRGBA) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/menu_nodes/CCMenuItem.h b/loader/include/Geode/cocos/menu_nodes/CCMenuItem.h index 4a44c453..be49aa44 100644 --- a/loader/include/Geode/cocos/menu_nodes/CCMenuItem.h +++ b/loader/include/Geode/cocos/menu_nodes/CCMenuItem.h @@ -71,7 +71,7 @@ public: , m_pfnSelector(NULL) , m_nScriptTapHandler(0) {} - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCMenuItem, CCNodeRGBA) + GEODE_ZERO_CONSTRUCTOR(CCMenuItem, CCNodeRGBA) /** * @js NA * @lua NA @@ -139,7 +139,7 @@ public: : m_pLabel(NULL) , m_fOriginalScale(0.0) {} - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCMenuItemLabel, CCMenuItem) + GEODE_ZERO_CONSTRUCTOR(CCMenuItemLabel, CCMenuItem) /** * @js NA * @lua NA @@ -292,7 +292,7 @@ public: ,m_pSelectedImage(NULL) ,m_pDisabledImage(NULL) {} - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCMenuItemSprite, CCMenuItem) + GEODE_ZERO_CONSTRUCTOR(CCMenuItemSprite, CCMenuItem) /** creates a menu item with a normal, selected and disabled image*/ static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); @@ -337,7 +337,7 @@ public: * @lua NA */ CCMenuItemImage(){} - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCMenuItemImage, CCMenuItemSprite) + GEODE_ZERO_CONSTRUCTOR(CCMenuItemImage, CCMenuItemSprite) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/platform/CCApplicationProtocol.h b/loader/include/Geode/cocos/platform/CCApplicationProtocol.h index 1acca89e..4aeb1001 100644 --- a/loader/include/Geode/cocos/platform/CCApplicationProtocol.h +++ b/loader/include/Geode/cocos/platform/CCApplicationProtocol.h @@ -62,24 +62,24 @@ public: @return true Initialize success, app continue. @return false Initialize failed, app terminate. */ - virtual bool applicationDidFinishLaunching() = 0; + virtual bool applicationDidFinishLaunching() { return true; } /** @brief The function be called when the application enter background @param the pointer of the application */ - virtual void applicationDidEnterBackground() = 0; + virtual void applicationDidEnterBackground() {} /** @brief The function be called when the application enter foreground @param the pointer of the application */ - virtual void applicationWillEnterForeground() = 0; + virtual void applicationWillEnterForeground() {} RT_ADD( virtual void applicationWillBecomeActive() {} virtual void applicationWillResignActive() {} - virtual void trySaveGame() = 0; + virtual void trySaveGame() {} virtual void gameDidSave() {} ) @@ -87,18 +87,18 @@ public: @brief Callback by CCDirector for limit FPS. @interval The time, expressed in seconds, between current frame and next. */ - virtual void setAnimationInterval(double interval) = 0; + virtual void setAnimationInterval(double interval) {} /** @brief Get current language config @return Current language config */ - virtual ccLanguageType getCurrentLanguage() = 0; + virtual ccLanguageType getCurrentLanguage() { return kLanguageEnglish; } /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform() = 0; + virtual TargetPlatform getTargetPlatform() { return kTargetWindows; } RT_ADD( virtual void openURL(const char* url) {} ) }; diff --git a/loader/include/Geode/cocos/platform/CCFileUtils.h b/loader/include/Geode/cocos/platform/CCFileUtils.h index 98341239..9af4ad8e 100644 --- a/loader/include/Geode/cocos/platform/CCFileUtils.h +++ b/loader/include/Geode/cocos/platform/CCFileUtils.h @@ -41,8 +41,8 @@ class CCArray; */ struct CCTexturePack { - std::string m_id; - std::vector m_paths; + std::string m_id; + std::vector m_paths; }; //! @brief Helper class to handle file operations @@ -52,6 +52,8 @@ class CC_DLL CCFileUtils : public TypeInfo friend class CCArray; friend class CCDictionary; public: + + GEODE_ZERO_CONSTRUCTOR_BEGIN(CCFileUtils) /** * Returns an unique ID for this class. * @note It's only used for JSBindings now. @@ -339,7 +341,7 @@ public: * @return The path that can be write/read a file in * @lua NA */ - virtual gd::string getWritablePath() = 0; + virtual gd::string getWritablePath() { return ""; } RT_ADD(virtual gd::string getWritablePath2();) @@ -351,7 +353,7 @@ public: * @return true if the file exists, otherwise it will return false. * @lua NA */ - virtual bool isFileExist(const gd::string& strFilePath) = 0; + virtual bool isFileExist(const gd::string& strFilePath) { return false; } /** * Checks whether the path is an absolute path. diff --git a/loader/include/Geode/cocos/platform/CCImage.h b/loader/include/Geode/cocos/platform/CCImage.h index 131cfe1b..6d13d6ae 100644 --- a/loader/include/Geode/cocos/platform/CCImage.h +++ b/loader/include/Geode/cocos/platform/CCImage.h @@ -46,7 +46,7 @@ public: @js ctor */ CCImage(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCImage, CCObject) + GEODE_ZERO_CONSTRUCTOR(CCImage, CCObject) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/platform/ios/CCApplication.h b/loader/include/Geode/cocos/platform/ios/CCApplication.h index 85467639..f0c4dff0 100644 --- a/loader/include/Geode/cocos/platform/ios/CCApplication.h +++ b/loader/include/Geode/cocos/platform/ios/CCApplication.h @@ -36,7 +36,7 @@ class CC_DLL CCApplication : public CCApplicationProtocol { GEODE_FRIEND_MODIFY public: - GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(CCApplication) + GEODE_ZERO_CONSTRUCTOR_BEGIN(CCApplication) CCApplication(); /** * @js NA diff --git a/loader/include/Geode/cocos/platform/mac/CCApplication.h b/loader/include/Geode/cocos/platform/mac/CCApplication.h index 57562274..139396d9 100644 --- a/loader/include/Geode/cocos/platform/mac/CCApplication.h +++ b/loader/include/Geode/cocos/platform/mac/CCApplication.h @@ -35,7 +35,7 @@ class CC_DLL CCApplication : public CCApplicationProtocol { GEODE_FRIEND_MODIFY public: - GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(CCApplication) + GEODE_ZERO_CONSTRUCTOR_BEGIN(CCApplication) CCApplication(); virtual ~CCApplication(); diff --git a/loader/include/Geode/cocos/platform/win32/CCApplication.h b/loader/include/Geode/cocos/platform/win32/CCApplication.h index 86756c2e..a6466499 100644 --- a/loader/include/Geode/cocos/platform/win32/CCApplication.h +++ b/loader/include/Geode/cocos/platform/win32/CCApplication.h @@ -15,7 +15,7 @@ class CC_DLL CCApplication : public CCApplicationProtocol { GEODE_FRIEND_MODIFY public: - GEODE_MONOSTATE_CONSTRUCTOR_BEGIN(CCApplication) + GEODE_ZERO_CONSTRUCTOR_BEGIN(CCApplication) CCApplication(); virtual ~CCApplication(); diff --git a/loader/include/Geode/cocos/platform/win32/CCEGLView.h b/loader/include/Geode/cocos/platform/win32/CCEGLView.h index a8a7b838..91ff5e32 100644 --- a/loader/include/Geode/cocos/platform/win32/CCEGLView.h +++ b/loader/include/Geode/cocos/platform/win32/CCEGLView.h @@ -45,6 +45,7 @@ protected: RT_ADD( virtual ~CCEGLView(); ) public: CCEGLView(); + GEODE_ZERO_CONSTRUCTOR(CCEGLView, CCObject) RT_REMOVE( virtual ~CCEGLView(); ) /* override functions */ diff --git a/loader/include/Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDelegate.h b/loader/include/Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDelegate.h index 094bf047..e4597085 100644 --- a/loader/include/Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDelegate.h +++ b/loader/include/Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDelegate.h @@ -207,7 +207,7 @@ RT_ADD( class CC_DLL CCKeyboardHandler : public CCObject { public: - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCKeyboardHandler, CCObject) + GEODE_ZERO_CONSTRUCTOR(CCKeyboardHandler, CCObject) inline CCKeyboardHandler() = default; virtual ~CCKeyboardHandler(); diff --git a/loader/include/Geode/cocos/robtop/mouse_dispatcher/CCMouseDelegate.h b/loader/include/Geode/cocos/robtop/mouse_dispatcher/CCMouseDelegate.h index 0f98200c..5f1e8be2 100644 --- a/loader/include/Geode/cocos/robtop/mouse_dispatcher/CCMouseDelegate.h +++ b/loader/include/Geode/cocos/robtop/mouse_dispatcher/CCMouseDelegate.h @@ -22,7 +22,7 @@ RT_ADD( class CC_DLL CCMouseHandler : public CCObject { public: - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCMouseHandler, CCObject) + GEODE_ZERO_CONSTRUCTOR(CCMouseHandler, CCObject) inline CCMouseHandler() = default; virtual ~CCMouseHandler(); diff --git a/loader/include/Geode/cocos/sprite_nodes/CCSprite.h b/loader/include/Geode/cocos/sprite_nodes/CCSprite.h index e633b358..636e7a41 100644 --- a/loader/include/Geode/cocos/sprite_nodes/CCSprite.h +++ b/loader/include/Geode/cocos/sprite_nodes/CCSprite.h @@ -168,7 +168,7 @@ public: * @js ctor */ CCSprite(void); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCSprite, CCNodeRGBA) + GEODE_ZERO_CONSTRUCTOR(CCSprite, CCNodeRGBA) /** * Default destructor diff --git a/loader/include/Geode/cocos/sprite_nodes/CCSpriteBatchNode.h b/loader/include/Geode/cocos/sprite_nodes/CCSpriteBatchNode.h index 619eae92..3233c913 100644 --- a/loader/include/Geode/cocos/sprite_nodes/CCSpriteBatchNode.h +++ b/loader/include/Geode/cocos/sprite_nodes/CCSpriteBatchNode.h @@ -68,7 +68,7 @@ public: * @js ctor */ CCSpriteBatchNode(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCSpriteBatchNode, CCNode) + GEODE_ZERO_CONSTRUCTOR(CCSpriteBatchNode, CCNode) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/text_input_node/CCIMEDelegate.h b/loader/include/Geode/cocos/text_input_node/CCIMEDelegate.h index adff3b12..6a83a4a3 100644 --- a/loader/include/Geode/cocos/text_input_node/CCIMEDelegate.h +++ b/loader/include/Geode/cocos/text_input_node/CCIMEDelegate.h @@ -50,6 +50,7 @@ class CC_DLL CCIMEDelegate { GEODE_FRIEND_MODIFY public: + GEODE_ZERO_CONSTRUCTOR_BEGIN(CCIMEDelegate) virtual ~CCIMEDelegate(); virtual bool attachWithIME(); diff --git a/loader/include/Geode/cocos/textures/CCTexture2D.h b/loader/include/Geode/cocos/textures/CCTexture2D.h index 6a107a48..f83c5171 100644 --- a/loader/include/Geode/cocos/textures/CCTexture2D.h +++ b/loader/include/Geode/cocos/textures/CCTexture2D.h @@ -117,7 +117,7 @@ public: * @js ctor */ CCTexture2D(); - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCTexture2D, CCObject) + GEODE_ZERO_CONSTRUCTOR(CCTexture2D, CCObject) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/touch_dispatcher/CCTouchHandler.h b/loader/include/Geode/cocos/touch_dispatcher/CCTouchHandler.h index fb818ae4..1671092d 100644 --- a/loader/include/Geode/cocos/touch_dispatcher/CCTouchHandler.h +++ b/loader/include/Geode/cocos/touch_dispatcher/CCTouchHandler.h @@ -48,7 +48,7 @@ class CC_DLL CCTouchHandler : public CCObject { GEODE_FRIEND_MODIFY public: - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCTouchHandler, CCObject) + GEODE_ZERO_CONSTRUCTOR(CCTouchHandler, CCObject) inline CCTouchHandler() = default; virtual ~CCTouchHandler(void); @@ -86,7 +86,7 @@ class CC_DLL CCStandardTouchHandler : public CCTouchHandler { GEODE_FRIEND_MODIFY public: - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCStandardTouchHandler, CCTouchHandler) + GEODE_ZERO_CONSTRUCTOR(CCStandardTouchHandler, CCTouchHandler) inline CCStandardTouchHandler() = default; ~CCStandardTouchHandler(void); @@ -110,7 +110,7 @@ class CC_DLL CCTargetedTouchHandler : public CCTouchHandler { GEODE_FRIEND_MODIFY public: - GEODE_MONOSTATE_CONSTRUCTOR_COCOS(CCTargetedTouchHandler, CCTouchHandler) + GEODE_ZERO_CONSTRUCTOR(CCTargetedTouchHandler, CCTouchHandler) inline CCTargetedTouchHandler() = default; ~CCTargetedTouchHandler(void); diff --git a/loader/include/Geode/modify/Modify.hpp b/loader/include/Geode/modify/Modify.hpp index 925b6757..e3e3efcd 100644 --- a/loader/include/Geode/modify/Modify.hpp +++ b/loader/include/Geode/modify/Modify.hpp @@ -134,8 +134,8 @@ namespace geode { // abusing the internal stuff // basically we dont want modify to invoke base ctors and dtors // we already have utilities for these, which are ccdestructor - // and the monostate constructor - Modify() : Base(std::monostate(), sizeof(Base)) {} + // and the zero constructor + Modify() : Base(ZeroConstructor) {} ~Modify() { cocos2d::CCDestructor::lock(this) = true; diff --git a/loader/include/Geode/utils/addresser.hpp b/loader/include/Geode/utils/addresser.hpp index ec09837d..f8f0ffc2 100644 --- a/loader/include/Geode/utils/addresser.hpp +++ b/loader/include/Geode/utils/addresser.hpp @@ -9,36 +9,24 @@ #include #include +#include #include #include #include -#include namespace geode::addresser { - template - inline intptr_t getVirtual(T func); + template + intptr_t getVirtual(Function func); - template - inline intptr_t getNonVirtual(T func); + template + intptr_t getNonVirtual(Function func); - template - inline F thunkAdjust(T func, F self); + template + Class thunkAdjust(Function func, Class self); - template - inline F rthunkAdjust(T func, F self); - - template - Class* friendCreate(typename std::void_t(&Class::create))>*) { - auto ret = Class::create(); - ret->retain(); - return ret; - } - - template - concept HasCreate = requires() { - { friendCreate(nullptr) } -> std::same_as; - }; + template + Class rthunkAdjust(Function func, Class self); class GEODE_DLL Addresser final { template @@ -76,57 +64,20 @@ namespace geode::addresser { return thunk; } - // I gave up - // template - // static Class* generateInstance(Class*) { - // return friendCreate(nullptr); - // } - - // I extra gave up - template - static cocos2d::extension::CCScrollView* generateInstance(cocos2d::extension::CCScrollView*) { - return cocos2d::extension::CCScrollView::create({0.0f, 0.0f}, cocos2d::CCLayer::create()); - } - - template - static cocos2d::CCFileUtils* generateInstance(cocos2d::CCFileUtils*) { - return cocos2d::CCFileUtils::sharedFileUtils(); - } - - template - static Class* generateInstance(Class*) { - if constexpr (std::is_abstract_v) { - // Cant construct abstract classes, so fail early - return nullptr; - } else { - // Create a random memory block with the size of Class - // Assign a pointer to that block and cast it to type Class* - uint8_t dum[sizeof(Class)]{}; - auto ptr = reinterpret_cast(dum); - // Now you have a object of Class that actually isn't an object of Class and is just a - // random memory But C++ doesn't know that of course So now you can copy an object - // that wasn't there in the first place - // ((oh also get the offsets of the virtual tables)) - auto ins = new Class(*ptr); - // this is how the first human was made - return ins; - } - } - template static Class* cachedInstance() { - static auto ret = generateInstance(static_cast(nullptr)); + static auto ret = new Class(ZeroConstructor); return ret; } /** * Specialized functionss */ - template - static intptr_t addressOfVirtual(R (T::*func)(Ps...)) { + template + static intptr_t addressOfVirtual(Return (Class::*func)(Parameters...)) { using geode::cast::reference_cast; - auto ins = cachedInstance(); + auto ins = cachedInstance(); // generateInstance will return nullptr on most abstract classes, // so dont bother getting the address if (ins == nullptr) { @@ -136,97 +87,87 @@ namespace geode::addresser { auto thunk = thunkOf(func); // [[this + thunk] + offset] is the function we want - auto address = *reinterpret_cast(*reinterpret_cast(reinterpret_cast(ins) + thunk) + index); + auto address = *reinterpret_cast( + *reinterpret_cast(reinterpret_cast(ins) + thunk) + index + ); address = followThunkFunction(address); return address; } - template - static intptr_t addressOfVirtual(R (T::*func)(Ps...) const) { - return addressOfVirtual(reinterpret_cast(func)); + template + static intptr_t addressOfVirtual(Return (Class::*func)(Parameters...) const) { + return addressOfVirtual(reinterpret_cast(func)); } - template - static intptr_t addressOfNonVirtual(R (T::*func)(Ps...) const) { - return addressOfNonVirtual(reinterpret_cast(func)); + template + static intptr_t addressOfNonVirtual(Return (Class::*func)(Parameters...) const) { + return addressOfNonVirtual(reinterpret_cast(func)); } static intptr_t followThunkFunction(intptr_t address); - template - static intptr_t addressOfNonVirtual(R (T::*func)(Ps...)) { + template + static intptr_t addressOfNonVirtual(Return (Class::*func)(Parameters...)) { return followThunkFunction(geode::cast::reference_cast(func)); } - template - static intptr_t addressOfNonVirtual(R (*func)(Ps...)) { + template + static intptr_t addressOfNonVirtual(Return (*func)(Parameters...)) { return followThunkFunction(geode::cast::reference_cast(func)); } - template - friend intptr_t getVirtual(T func); + template + friend intptr_t getVirtual(Function func); - template - friend intptr_t getNonVirtual(T func); + template + friend intptr_t getNonVirtual(Function func); - template - friend F thunkAdjust(T func, F self); + template + friend Class thunkAdjust(Function func, Class self); - template - friend F rthunkAdjust(T func, F self); + template + friend Class rthunkAdjust(Function func, Class self); }; -#ifdef GEODE_ADDRESSER_TEST - template - inline intptr_t getVirtual(T func) { + /** + * Gets the real address of a virtual function + */ + template + inline intptr_t getVirtual(Function func) { return Addresser::addressOfVirtual(func); } - template - inline intptr_t getNonVirtual(T func) { + /** + * Gets the real address of a non-virtual function + */ + template + inline intptr_t getNonVirtual(Function func) { return Addresser::addressOfNonVirtual(func); } -#else - template - inline intptr_t getVirtual(T func) { - // log::debug( - // "Get virtual function address from {}", - // utils::intToHex(geode::cast::reference_cast(func)) - // ); - auto addr = Addresser::addressOfVirtual(func); - // log::debug("The address is: {}", utils::intToHex(addr)); - return addr; - } - template - inline intptr_t getNonVirtual(T func) { - // log::debug( - // "Get non-virtual function address from {}", - // utils::intToHex(geode::cast::reference_cast(func)) - // ); - auto addr = Addresser::addressOfNonVirtual(func); - // log::debug("The address is: {}", utils::intToHex(addr)); - return addr; - } - - template - inline F thunkAdjust(T func, F self) { + /** + * Adjusts a class instance to its appropriate base for the given virtual function + */ + template + inline Class thunkAdjust(Function func, Class self) { // do NOT delete the line below. // doing so breaks thunk adjusting on windows. // why? bruh idk auto _ = *geode::cast::template union_cast(&func); - return (F)((intptr_t)self + Addresser::thunkOf(func)); + return (Class)((intptr_t)self + Addresser::thunkOf(func)); } - template - inline F rthunkAdjust(T func, F self) { + /** + * Adjusts a class instance back from its appropriate base for the given virtual function to the original base + */ + template + inline Class rthunkAdjust(Function func, Class self) { // do NOT delete the line below. // doing so breaks thunk adjusting on windows. // why? bruh idk auto _ = *geode::cast::template union_cast(&func); - return (F)((intptr_t)self - Addresser::thunkOf(func)); + return (Class)((intptr_t)self - Addresser::thunkOf(func)); } -#endif } diff --git a/loader/include/link/gdstring.lib b/loader/include/link/gdstring.lib index 11aac0c56f23fb1b342d6c4c8a3a6e3488ed0fff..d422bb31c4e54ad97444800b3a90a35cb202fc2d 100644 GIT binary patch delta 1924 zcmciCPe>GD7zXfXR?}_GHnRVbEkP(`w!7nwnq_KEkQ;PaN-wpNfrVR;K?uo^K^^p9 zjCrVo9qLdJ6;nb4fe8IM7}6mLqVgh98+56I5%uJ5$paAx*1*TS?~j-7duQHZ1_ykv z2Ymf&ovLswYMRlIT;XhH#j3MmG5}y7U^dV1a^`!(Iqv7o`xDKr0spVp>9+1#?Z)k5 zZ^HPJm)m)=t*%PosMO{6YtH6;+*oo556L5Wxj!Az~JPYy-jQ0=Fe>PFWV}}aZAmj$RAsa zgu|A_rlQekq-v(OWMGeBAYHJa&Fe6a7CJ9YpqtJ9Y}m&IEUf@~c%PNsl=C7zls=Ic zlnWxh7%(VOOSvp^)*)RH8lzkjDYSqaA~xlg$W6*!kx(UYU*s_5p~!fp1B?mFih=Db7Nn9@1iwdz2!Puas3H`?mq>M209EMBY(KM9Q}VWsXoMDI)TKVu?&sYDBDB zpibl%#TNNSX%dO;0QMT3KQ;U1caaiOG)id^$*ltph@>coL?$WiA|>@eO2nm{FgSl| z_IRTKI3-2(l+z+zlrth8<($YArB@`r6X+Kird*`db7hZDlP*b7X(KQslA>G{8FqvA PdLL{rY(F*s!@uqa4{#3r delta 1831 zcmb`{Pe>F|90%~-+Dk!Q+Qx$F zPzU909#pmtO4P+*f+(R&9V*DIq#z{l5=D@8D8df*)mG#SU4$KY{ANBp-uumbAM-J% z_vG}hO4|%YOw$Ojrz=o+vP{eRcbj&L$bJ!{rnti{_JRvs&o25KEvy08+~-u?&8wZ# z%9SNr$a(D=)m835i<(^ONA;+zzZYDU?RP2jq(_ZjZbx0A;#=~lNj0*{uk=%KmGL&I zgg4^c^B&bp3c;#1zKZfdXf8z!G1eHfQK~(@L6!EooL|1p#o4u0R|k!<;D3))Fc7e2 z4pS%;jMmL|lXmaYG^rZ<(BbqOCzjdo&{h`h&9tavh?LfeTtc0fX2?|%8*-iGEu@=d z8qz}&Ge!DHI&IJ`q8E@s61OFCm!uIgL~$pqv(N&QxlpCp}-DUxBxG|3;xVq`iW zYa}LOFCjV$T268YQbsZfsUT_DCbE`9L8?i{Asa}lw~K7DiH?DSBtsC39 z3)_DIouf&$jUwks+94N7`XE Date: Mon, 6 Mar 2023 14:34:47 -0300 Subject: [PATCH 10/18] rename Nightly to nightly --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3467d692..2ca671fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: os_identifier: "win" os: windows-2019 prefixes: '' - extra_flags: '-G "Visual Studio 16 2019" -T host=x86 -A win32 -DGEODE_DEBUG=On' + extra_flags: '-T host=x86 -A win32 -DGEODE_DEBUG=On' out_paths: './bin/nightly/Geode.dll ./bin/nightly/GeodeBootstrapper.dll ./bin/nightly/Geode.lib ./bin/nightly/XInput9_1_0.dll' cli_cmd: '' @@ -141,5 +141,6 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} files: ./geode-nightly-mac.zip ./geode-nightly-win.zip - release: Nightly + release: nightly + tag: nightly prerelease: true From 2e485d88a921b9263c44c64d1b07a413d55aa611 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 6 Mar 2023 19:52:49 +0200 Subject: [PATCH 11/18] add CurrencyRewardLayer::create and its related enums --- bindings/GeometryDash.bro | 9 ++++++++- loader/include/Geode/Enums.hpp | 8 ++++++++ loader/include/Geode/utils/Result.hpp | 9 +++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/bindings/GeometryDash.bro b/bindings/GeometryDash.bro index 6fb6f127..3b50b4fa 100644 --- a/bindings/GeometryDash.bro +++ b/bindings/GeometryDash.bro @@ -878,6 +878,13 @@ class CurrencyRewardLayer : cocos2d::CCLayer { inline CurrencyRewardLayer() {} ~CurrencyRewardLayer() = mac 0x447950, win 0x4ffb0; virtual void update(float) = mac 0x44a5c0, win 0x52350; + + static CurrencyRewardLayer* create( + int, int, int, + CurrencySpriteType, int, + CurrencySpriteType, int, + cocos2d::CCPoint, CurrencyRewardType, float + ) = win 0x50050; } class CurrencyRewardDelegate { @@ -4284,7 +4291,7 @@ class PlayLayer : GJBaseGameLayer, CCCircleWaveDelegate, CurrencyRewardDelegate, void shouldBlend(int) = mac 0x771b0; void showCompleteEffect() = mac 0x738e0, win 0x1fe060; void showCompleteText() = mac 0x73be0, win 0x1fda90; - void showEndLayer() = mac 0x74450; + void showEndLayer() = mac 0x74450, win 0x1ffd00; void showHint() = mac 0x7deb0; void showNewBest(bool, int, int, bool, bool, bool) = mac 0x74580, win 0x1fe3a0; void showRetryLayer() = mac 0x75ba0; diff --git a/loader/include/Geode/Enums.hpp b/loader/include/Geode/Enums.hpp index 42eb3bc3..f7a052d5 100644 --- a/loader/include/Geode/Enums.hpp +++ b/loader/include/Geode/Enums.hpp @@ -122,6 +122,14 @@ enum class BoomListType { Artist = 0x14, }; +enum class CurrencySpriteType { + // todo +}; + +enum class CurrencyRewardType { + // todo +}; + enum class MenuAnimationType { Scale = 0, Move = 1, diff --git a/loader/include/Geode/utils/Result.hpp b/loader/include/Geode/utils/Result.hpp index 7f95750a..b4f02cb3 100644 --- a/loader/include/Geode/utils/Result.hpp +++ b/loader/include/Geode/utils/Result.hpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace geode { namespace impl { @@ -209,7 +210,7 @@ namespace geode { * Convert the result into an optional containing the value if Ok, and * nullopt if Err */ - [[nodiscard]] constexpr decltype(auto) ok() const& { + [[nodiscard]] constexpr std::optional ok() const& { if (this->isOk()) { return std::optional(this->unwrap()); } @@ -220,7 +221,7 @@ namespace geode { * Convert the result into an optional containing the value if Ok, and * nullopt if Err */ - [[nodiscard]] constexpr decltype(auto) ok() && { + [[nodiscard]] constexpr std::optional ok() && { if (this->isOk()) { return std::optional(this->unwrap()); } @@ -231,7 +232,7 @@ namespace geode { * Convert the result into an optional containing the error if Err, and * nullopt if Ok */ - [[nodiscard]] constexpr decltype(auto) err() const& { + [[nodiscard]] constexpr std::optional err() const& { if (this->isErr()) { return std::optional(this->unwrapErr()); } @@ -242,7 +243,7 @@ namespace geode { * Convert the result into an optional containing the error if Err, and * nullopt if Ok */ - [[nodiscard]] constexpr decltype(auto) err() && { + [[nodiscard]] constexpr std::optional err() && { if (this->isErr()) { return std::optional(this->unwrapErr()); } From 29fde5fac51483186f77b5a956a7d6b59df06c3d Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 6 Mar 2023 19:58:51 +0200 Subject: [PATCH 12/18] bump version to 1.0.0!! --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 73ff4a6f..afaf360d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0-beta.9 \ No newline at end of file +1.0.0 \ No newline at end of file From 7dba804969cba4a3c244c182fb9385388218c30a Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Mon, 6 Mar 2023 21:17:08 +0300 Subject: [PATCH 13/18] Half revert constructors, having two types --- codegen/src/BindingGen.cpp | 9 +++- codegen/src/SourceGen.cpp | 4 +- loader/include/Geode/DefaultInclude.hpp | 53 +++++++++++++++++++ loader/include/Geode/cocos/CCDirector.h | 2 +- loader/include/Geode/cocos/CCScheduler.h | 2 +- .../include/Geode/cocos/base_nodes/CCNode.h | 4 +- loader/include/Geode/cocos/cocoa/CCObject.h | 2 +- loader/include/Geode/cocos/cocoa/CCSet.h | 2 +- loader/include/Geode/cocos/cocoa/CCString.h | 2 +- .../Geode/cocos/draw_nodes/CCDrawNode.h | 2 +- .../GUI/CCControlExtension/CCControl.h | 2 +- .../CCControlColourPicker.h | 2 +- .../GUI/CCControlExtension/CCScale9Sprite.h | 2 +- .../GUI/CCScrollView/CCScrollView.h | 2 +- .../keypad_dispatcher/CCKeypadDelegate.h | 2 +- .../Geode/cocos/label_nodes/CCLabelBMFont.h | 2 +- .../Geode/cocos/label_nodes/CCLabelTTF.h | 2 +- .../layers_scenes_transitions_nodes/CCLayer.h | 6 +-- .../layers_scenes_transitions_nodes/CCScene.h | 2 +- .../include/Geode/cocos/menu_nodes/CCMenu.h | 2 +- .../Geode/cocos/menu_nodes/CCMenuItem.h | 8 +-- .../Geode/cocos/platform/CCFileUtils.h | 2 +- loader/include/Geode/cocos/platform/CCImage.h | 2 +- .../Geode/cocos/platform/ios/CCApplication.h | 2 +- .../Geode/cocos/platform/mac/CCApplication.h | 2 +- .../cocos/platform/win32/CCApplication.h | 2 +- .../Geode/cocos/platform/win32/CCEGLView.h | 2 +- .../keyboard_dispatcher/CCKeyboardDelegate.h | 2 +- .../robtop/mouse_dispatcher/CCMouseDelegate.h | 2 +- .../Geode/cocos/sprite_nodes/CCSprite.h | 2 +- .../cocos/sprite_nodes/CCSpriteBatchNode.h | 2 +- .../cocos/text_input_node/CCIMEDelegate.h | 2 +- .../Geode/cocos/textures/CCTexture2D.h | 2 +- .../cocos/touch_dispatcher/CCTouchHandler.h | 6 +-- 34 files changed, 101 insertions(+), 43 deletions(-) diff --git a/codegen/src/BindingGen.cpp b/codegen/src/BindingGen.cpp index 527b43ef..17f8de11 100644 --- a/codegen/src/BindingGen.cpp +++ b/codegen/src/BindingGen.cpp @@ -34,7 +34,10 @@ public: static constexpr auto CLASS_NAME = "{class_name}"; )GEN"; - char const* zero_constructor = R"GEN( GEODE_ZERO_CONSTRUCTOR({class_name}, {first_base}) + char const* custom_constructor = R"GEN( GEODE_CUSTOM_CONSTRUCTOR_GD({class_name}, {first_base}) +)GEN"; + + char const* custom_constructor_cutoff = R"GEN( GEODE_CUSTOM_CONSTRUCTOR_CUTOFF({class_name}, {first_base}) )GEN"; char const* function_definition = R"GEN( @@ -177,7 +180,9 @@ std::string generateBindingHeader(Root& root, ghc::filesystem::path const& singl // what. if (!cls.superclasses.empty()) { single_output += fmt::format( - format_strings::zero_constructor, + can_find(cls.superclasses[0], "cocos2d") + ? format_strings::custom_constructor_cutoff + : format_strings::custom_constructor, fmt::arg("class_name", cls.name), fmt::arg("first_base", cls.superclasses[0]) ); diff --git a/codegen/src/SourceGen.cpp b/codegen/src/SourceGen.cpp index 2de69924..83b3f380 100644 --- a/codegen/src/SourceGen.cpp +++ b/codegen/src/SourceGen.cpp @@ -85,13 +85,13 @@ auto {class_name}::{function_name}({parameters}){const} -> decltype({function_na reinterpret_cast(func)(this{parameter_comma}{arguments}); // we need to construct it back so that it uhhh ummm doesnt crash // while going to the child destructors - auto thing = new (this) {class_name}(geode::ZeroConstructor); + auto thing = new (this) {class_name}(geode::CutoffConstructor, sizeof({class_name})); CCDestructor::lock(this) = true; }} )GEN"; char const* declare_constructor = R"GEN( -{class_name}::{function_name}({parameters}) : {class_name}(geode::ZeroConstructor) {{ +{class_name}::{function_name}({parameters}) : {class_name}(geode::CutoffConstructor, sizeof({class_name})) {{ // here we construct it as normal as we can, then destruct it // using the generated functions. this ensures no memory gets leaked // no crashes :pray: diff --git a/loader/include/Geode/DefaultInclude.hpp b/loader/include/Geode/DefaultInclude.hpp index 70d8e2e4..6956f302 100644 --- a/loader/include/Geode/DefaultInclude.hpp +++ b/loader/include/Geode/DefaultInclude.hpp @@ -73,8 +73,28 @@ namespace geode { struct ZeroConstructorType {}; static constexpr auto ZeroConstructor = ZeroConstructorType(); + + struct CutoffConstructorType {}; + + static constexpr auto CutoffConstructor = CutoffConstructorType(); } +#define GEODE_CUSTOM_CONSTRUCTOR_BEGIN(Class_) \ + GEODE_ZERO_CONSTRUCTOR_BEGIN(Class_) \ + GEODE_CUTOFF_CONSTRUCTOR_BEGIN(Class_) + +#define GEODE_CUSTOM_CONSTRUCTOR_COCOS(Class_, Base_) \ + GEODE_ZERO_CONSTRUCTOR(Class_, Base_) \ + GEODE_CUTOFF_CONSTRUCTOR_COCOS(Class_, Base_) + +#define GEODE_CUSTOM_CONSTRUCTOR_GD(Class_, Base_) \ + GEODE_ZERO_CONSTRUCTOR(Class_, Base_) \ + GEODE_CUTOFF_CONSTRUCTOR_GD(Class_, Base_) + +#define GEODE_CUSTOM_CONSTRUCTOR_CUTOFF(Class_, Base_) \ + GEODE_ZERO_CONSTRUCTOR(Class_, Base_) \ + GEODE_CUTOFF_CONSTRUCTOR_CUTOFF(Class_, Base_) + #define GEODE_ZERO_CONSTRUCTOR_BEGIN(Class_) \ Class_(geode::ZeroConstructorType, void*) {} \ Class_(geode::ZeroConstructorType, size_t fill) : \ @@ -85,6 +105,39 @@ namespace geode { Class_(geode::ZeroConstructorType, size_t fill) : Base_(geode::ZeroConstructor, fill) {} \ Class_(geode::ZeroConstructorType) : Base_(geode::ZeroConstructor, sizeof(Class_)) {} +#define GEODE_FILL_CONSTRUCTOR(Class_, Offset_) \ + Class_(geode::CutoffConstructorType, size_t fill) : \ + Class_( \ + geode::CutoffConstructor, \ + std::memset(reinterpret_cast(this) + Offset_, 0, fill - Offset_) \ + ) {} \ + Class_(geode::CutoffConstructorType, void*) + +#define GEODE_CUTOFF_CONSTRUCTOR_BEGIN(Class_) \ + GEODE_MACOS(GEODE_FILL_CONSTRUCTOR(Class_, 0){}) \ + GEODE_IOS(GEODE_FILL_CONSTRUCTOR(Class_, 0){}) + +#define GEODE_CUTOFF_CONSTRUCTOR_COCOS(Class_, Base_) \ + GEODE_MACOS(Class_(geode::CutoffConstructorType, size_t fill) \ + : Base_(geode::CutoffConstructor, fill){}) \ + GEODE_IOS(Class_(geode::CutoffConstructorType, size_t fill) \ + : Base_(geode::CutoffConstructor, fill){}) + +#define GEODE_CUTOFF_CONSTRUCTOR_GD(Class_, Base_) \ + GEODE_WINDOWS(Class_(geode::CutoffConstructorType, size_t fill) \ + : Base_(geode::CutoffConstructor, fill){}) \ + GEODE_MACOS(Class_(geode::CutoffConstructorType, size_t fill) \ + : Base_(geode::CutoffConstructor, fill){}) \ + GEODE_IOS(Class_(geode::CutoffConstructorType, size_t fill) \ + : Base_(geode::CutoffConstructor, fill){}) + +#define GEODE_CUTOFF_CONSTRUCTOR_CUTOFF(Class_, Base_) \ + GEODE_WINDOWS(GEODE_FILL_CONSTRUCTOR(Class_, sizeof(Base_)) : Base_(){}) \ + GEODE_MACOS(Class_(geode::CutoffConstructorType, size_t fill) \ + : Base_(geode::CutoffConstructor, fill){}) \ + GEODE_IOS(Class_(geode::CutoffConstructorType, size_t fill) \ + : Base_(geode::CutoffConstructor, fill){}) + #define GEODE_NUMBER_OF_ARGS(...) \ GEODE_EXPAND(GEODE_NUMBER_OF_ARGS_(__VA_ARGS__, GEODE_NUMBER_SEQUENCE(), )) #define GEODE_NUMBER_OF_ARGS_(...) GEODE_EXPAND(GEODE_NUMBER_OF_ARGS_N(__VA_ARGS__)) diff --git a/loader/include/Geode/cocos/CCDirector.h b/loader/include/Geode/cocos/CCDirector.h index dce5623c..385a137a 100644 --- a/loader/include/Geode/cocos/CCDirector.h +++ b/loader/include/Geode/cocos/CCDirector.h @@ -121,7 +121,7 @@ public: * @js ctor */ CCDirector(void); - GEODE_ZERO_CONSTRUCTOR(CCDirector, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCDirector, CCObject) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/CCScheduler.h b/loader/include/Geode/cocos/CCScheduler.h index 4c1c4d96..59547521 100644 --- a/loader/include/Geode/cocos/CCScheduler.h +++ b/loader/include/Geode/cocos/CCScheduler.h @@ -141,7 +141,7 @@ class CC_DLL CCScheduler : public CCObject GEODE_FRIEND_MODIFY public: CCScheduler(); - GEODE_ZERO_CONSTRUCTOR(CCScheduler, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCScheduler, CCObject) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/base_nodes/CCNode.h b/loader/include/Geode/cocos/base_nodes/CCNode.h index e2388ba1..eb73462f 100644 --- a/loader/include/Geode/cocos/base_nodes/CCNode.h +++ b/loader/include/Geode/cocos/base_nodes/CCNode.h @@ -140,7 +140,7 @@ public: * @js ctor */ CCNode(void); - GEODE_ZERO_CONSTRUCTOR(CCNode, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCNode, CCObject) /** * Default destructor @@ -1638,7 +1638,7 @@ public: * @js ctor */ CCNodeRGBA(); - GEODE_ZERO_CONSTRUCTOR(CCNodeRGBA, CCNode) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCNodeRGBA, CCNode) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/cocoa/CCObject.h b/loader/include/Geode/cocos/cocoa/CCObject.h index 4719faa0..daeb19bf 100644 --- a/loader/include/Geode/cocos/cocoa/CCObject.h +++ b/loader/include/Geode/cocos/cocoa/CCObject.h @@ -112,7 +112,7 @@ protected: int m_nUnknown; ) public: - GEODE_ZERO_CONSTRUCTOR_BEGIN(CCObject) + GEODE_CUSTOM_CONSTRUCTOR_BEGIN(CCObject) CCObject(void); /** * @lua NA diff --git a/loader/include/Geode/cocos/cocoa/CCSet.h b/loader/include/Geode/cocos/cocoa/CCSet.h index 366955f2..4ec1c0bf 100644 --- a/loader/include/Geode/cocos/cocoa/CCSet.h +++ b/loader/include/Geode/cocos/cocoa/CCSet.h @@ -46,7 +46,7 @@ public: * @lua NA */ CCSet(void); - GEODE_ZERO_CONSTRUCTOR(CCSet, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCSet, CCObject) /** * @lua NA */ diff --git a/loader/include/Geode/cocos/cocoa/CCString.h b/loader/include/Geode/cocos/cocoa/CCString.h index 9cdc2371..713aa0d0 100644 --- a/loader/include/Geode/cocos/cocoa/CCString.h +++ b/loader/include/Geode/cocos/cocoa/CCString.h @@ -47,7 +47,7 @@ class CC_DLL CCString : public CCObject { GEODE_FRIEND_MODIFY public: - GEODE_ZERO_CONSTRUCTOR(CCString, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCString, CCObject) /** * @lua NA */ diff --git a/loader/include/Geode/cocos/draw_nodes/CCDrawNode.h b/loader/include/Geode/cocos/draw_nodes/CCDrawNode.h index fc64ab99..495c52d0 100644 --- a/loader/include/Geode/cocos/draw_nodes/CCDrawNode.h +++ b/loader/include/Geode/cocos/draw_nodes/CCDrawNode.h @@ -94,7 +94,7 @@ public: void setBlendFunc(const ccBlendFunc &blendFunc); CCDrawNode(); - GEODE_ZERO_CONSTRUCTOR(CCDrawNode, CCNodeRGBA) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCDrawNode, CCNodeRGBA) /** listen the event that coming to foreground on Android * @js NA diff --git a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControl.h b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControl.h index d6fc4b50..1db66ae5 100644 --- a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControl.h +++ b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControl.h @@ -139,7 +139,7 @@ public: * @js ctor */ CCControl(); - GEODE_ZERO_CONSTRUCTOR(CCControl, CCLayerRGBA) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCControl, CCLayerRGBA) virtual bool init(void); /** diff --git a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h index 9c7d2ca6..2c0a7418 100644 --- a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h +++ b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCControlColourPicker.h @@ -58,7 +58,7 @@ public: virtual void setColorValue(ccColor3B const&); ) - GEODE_ZERO_CONSTRUCTOR(CCControlColourPicker, CCControl) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCControlColourPicker, CCControl) CCControlColourPicker(); virtual ~CCControlColourPicker(); diff --git a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCScale9Sprite.h index 76ec289a..43d9c136 100644 --- a/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/loader/include/Geode/cocos/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -54,7 +54,7 @@ class CC_DLL CCScale9Sprite : public CCNodeRGBA { public: CCScale9Sprite(); - GEODE_ZERO_CONSTRUCTOR(CCScale9Sprite, CCNodeRGBA) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCScale9Sprite, CCNodeRGBA) virtual ~CCScale9Sprite(); public: diff --git a/loader/include/Geode/cocos/extensions/GUI/CCScrollView/CCScrollView.h b/loader/include/Geode/cocos/extensions/GUI/CCScrollView/CCScrollView.h index 8476bdec..30918b1d 100644 --- a/loader/include/Geode/cocos/extensions/GUI/CCScrollView/CCScrollView.h +++ b/loader/include/Geode/cocos/extensions/GUI/CCScrollView/CCScrollView.h @@ -69,7 +69,7 @@ public: * @js ctor */ CCScrollView(); - GEODE_ZERO_CONSTRUCTOR(CCScrollView, CCLayer) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCScrollView, CCLayer) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/keypad_dispatcher/CCKeypadDelegate.h b/loader/include/Geode/cocos/keypad_dispatcher/CCKeypadDelegate.h index e812dac6..987c2f99 100644 --- a/loader/include/Geode/cocos/keypad_dispatcher/CCKeypadDelegate.h +++ b/loader/include/Geode/cocos/keypad_dispatcher/CCKeypadDelegate.h @@ -59,7 +59,7 @@ class CC_DLL CCKeypadHandler : public CCObject { GEODE_FRIEND_MODIFY public: - GEODE_ZERO_CONSTRUCTOR(CCKeypadHandler, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCKeypadHandler, CCObject) inline CCKeypadHandler() = default; virtual ~CCKeypadHandler(void); diff --git a/loader/include/Geode/cocos/label_nodes/CCLabelBMFont.h b/loader/include/Geode/cocos/label_nodes/CCLabelBMFont.h index 5d36195a..1fa7e2ac 100644 --- a/loader/include/Geode/cocos/label_nodes/CCLabelBMFont.h +++ b/loader/include/Geode/cocos/label_nodes/CCLabelBMFont.h @@ -198,7 +198,7 @@ public: * @js ctor */ CCLabelBMFont(); - GEODE_ZERO_CONSTRUCTOR(CCLabelBMFont, CCSpriteBatchNode) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCLabelBMFont, CCSpriteBatchNode) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/label_nodes/CCLabelTTF.h b/loader/include/Geode/cocos/label_nodes/CCLabelTTF.h index fdea5e53..6bb86c77 100644 --- a/loader/include/Geode/cocos/label_nodes/CCLabelTTF.h +++ b/loader/include/Geode/cocos/label_nodes/CCLabelTTF.h @@ -63,7 +63,7 @@ public: * @js ctor */ CCLabelTTF(); - GEODE_ZERO_CONSTRUCTOR(CCLabelTTF, CCSprite) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCLabelTTF, CCSprite) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCLayer.h b/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCLayer.h index 7305cfb3..7ea96fd0 100644 --- a/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCLayer.h +++ b/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCLayer.h @@ -75,7 +75,7 @@ public: * @js ctor */ CCLayer(); - GEODE_ZERO_CONSTRUCTOR(CCLayer, CCNode) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCLayer, CCNode) /** * @js NA * @lua NA @@ -233,7 +233,7 @@ public: * @js ctor */ CCLayerRGBA(); - GEODE_ZERO_CONSTRUCTOR(CCLayerRGBA, CCLayer) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCLayerRGBA, CCLayer) /** * @js NA * @lua NA @@ -290,7 +290,7 @@ public: * @js ctor */ CCLayerColor(); - GEODE_ZERO_CONSTRUCTOR(CCLayerColor, CCLayerRGBA) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCLayerColor, CCLayerRGBA) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCScene.h b/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCScene.h index ed00cdda..433cb390 100644 --- a/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCScene.h +++ b/loader/include/Geode/cocos/layers_scenes_transitions_nodes/CCScene.h @@ -63,7 +63,7 @@ public: * @js ctor */ CCScene(); - GEODE_ZERO_CONSTRUCTOR(CCScene, CCNode) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCScene, CCNode) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/menu_nodes/CCMenu.h b/loader/include/Geode/cocos/menu_nodes/CCMenu.h index 23e10daa..faecdc79 100644 --- a/loader/include/Geode/cocos/menu_nodes/CCMenu.h +++ b/loader/include/Geode/cocos/menu_nodes/CCMenu.h @@ -64,7 +64,7 @@ public: * @js ctor */ CCMenu() : m_pSelectedItem(NULL) {} - GEODE_ZERO_CONSTRUCTOR(CCMenu, CCLayerRGBA) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCMenu, CCLayerRGBA) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/menu_nodes/CCMenuItem.h b/loader/include/Geode/cocos/menu_nodes/CCMenuItem.h index be49aa44..83761988 100644 --- a/loader/include/Geode/cocos/menu_nodes/CCMenuItem.h +++ b/loader/include/Geode/cocos/menu_nodes/CCMenuItem.h @@ -71,7 +71,7 @@ public: , m_pfnSelector(NULL) , m_nScriptTapHandler(0) {} - GEODE_ZERO_CONSTRUCTOR(CCMenuItem, CCNodeRGBA) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCMenuItem, CCNodeRGBA) /** * @js NA * @lua NA @@ -139,7 +139,7 @@ public: : m_pLabel(NULL) , m_fOriginalScale(0.0) {} - GEODE_ZERO_CONSTRUCTOR(CCMenuItemLabel, CCMenuItem) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCMenuItemLabel, CCMenuItem) /** * @js NA * @lua NA @@ -292,7 +292,7 @@ public: ,m_pSelectedImage(NULL) ,m_pDisabledImage(NULL) {} - GEODE_ZERO_CONSTRUCTOR(CCMenuItemSprite, CCMenuItem) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCMenuItemSprite, CCMenuItem) /** creates a menu item with a normal, selected and disabled image*/ static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); @@ -337,7 +337,7 @@ public: * @lua NA */ CCMenuItemImage(){} - GEODE_ZERO_CONSTRUCTOR(CCMenuItemImage, CCMenuItemSprite) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCMenuItemImage, CCMenuItemSprite) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/platform/CCFileUtils.h b/loader/include/Geode/cocos/platform/CCFileUtils.h index 9af4ad8e..0df6c7fc 100644 --- a/loader/include/Geode/cocos/platform/CCFileUtils.h +++ b/loader/include/Geode/cocos/platform/CCFileUtils.h @@ -53,7 +53,7 @@ class CC_DLL CCFileUtils : public TypeInfo friend class CCDictionary; public: - GEODE_ZERO_CONSTRUCTOR_BEGIN(CCFileUtils) + GEODE_CUSTOM_CONSTRUCTOR_BEGIN(CCFileUtils) /** * Returns an unique ID for this class. * @note It's only used for JSBindings now. diff --git a/loader/include/Geode/cocos/platform/CCImage.h b/loader/include/Geode/cocos/platform/CCImage.h index 6d13d6ae..a71af4e8 100644 --- a/loader/include/Geode/cocos/platform/CCImage.h +++ b/loader/include/Geode/cocos/platform/CCImage.h @@ -46,7 +46,7 @@ public: @js ctor */ CCImage(); - GEODE_ZERO_CONSTRUCTOR(CCImage, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCImage, CCObject) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/platform/ios/CCApplication.h b/loader/include/Geode/cocos/platform/ios/CCApplication.h index f0c4dff0..76b17efd 100644 --- a/loader/include/Geode/cocos/platform/ios/CCApplication.h +++ b/loader/include/Geode/cocos/platform/ios/CCApplication.h @@ -36,7 +36,7 @@ class CC_DLL CCApplication : public CCApplicationProtocol { GEODE_FRIEND_MODIFY public: - GEODE_ZERO_CONSTRUCTOR_BEGIN(CCApplication) + GEODE_CUSTOM_CONSTRUCTOR_BEGIN(CCApplication) CCApplication(); /** * @js NA diff --git a/loader/include/Geode/cocos/platform/mac/CCApplication.h b/loader/include/Geode/cocos/platform/mac/CCApplication.h index 139396d9..79c3fc88 100644 --- a/loader/include/Geode/cocos/platform/mac/CCApplication.h +++ b/loader/include/Geode/cocos/platform/mac/CCApplication.h @@ -35,7 +35,7 @@ class CC_DLL CCApplication : public CCApplicationProtocol { GEODE_FRIEND_MODIFY public: - GEODE_ZERO_CONSTRUCTOR_BEGIN(CCApplication) + GEODE_CUSTOM_CONSTRUCTOR_BEGIN(CCApplication) CCApplication(); virtual ~CCApplication(); diff --git a/loader/include/Geode/cocos/platform/win32/CCApplication.h b/loader/include/Geode/cocos/platform/win32/CCApplication.h index a6466499..dd5152da 100644 --- a/loader/include/Geode/cocos/platform/win32/CCApplication.h +++ b/loader/include/Geode/cocos/platform/win32/CCApplication.h @@ -15,7 +15,7 @@ class CC_DLL CCApplication : public CCApplicationProtocol { GEODE_FRIEND_MODIFY public: - GEODE_ZERO_CONSTRUCTOR_BEGIN(CCApplication) + GEODE_CUSTOM_CONSTRUCTOR_BEGIN(CCApplication) CCApplication(); virtual ~CCApplication(); diff --git a/loader/include/Geode/cocos/platform/win32/CCEGLView.h b/loader/include/Geode/cocos/platform/win32/CCEGLView.h index 91ff5e32..15a0f65f 100644 --- a/loader/include/Geode/cocos/platform/win32/CCEGLView.h +++ b/loader/include/Geode/cocos/platform/win32/CCEGLView.h @@ -45,7 +45,7 @@ protected: RT_ADD( virtual ~CCEGLView(); ) public: CCEGLView(); - GEODE_ZERO_CONSTRUCTOR(CCEGLView, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCEGLView, CCObject) RT_REMOVE( virtual ~CCEGLView(); ) /* override functions */ diff --git a/loader/include/Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDelegate.h b/loader/include/Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDelegate.h index e4597085..10005f4e 100644 --- a/loader/include/Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDelegate.h +++ b/loader/include/Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDelegate.h @@ -207,7 +207,7 @@ RT_ADD( class CC_DLL CCKeyboardHandler : public CCObject { public: - GEODE_ZERO_CONSTRUCTOR(CCKeyboardHandler, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCKeyboardHandler, CCObject) inline CCKeyboardHandler() = default; virtual ~CCKeyboardHandler(); diff --git a/loader/include/Geode/cocos/robtop/mouse_dispatcher/CCMouseDelegate.h b/loader/include/Geode/cocos/robtop/mouse_dispatcher/CCMouseDelegate.h index 5f1e8be2..4d1f1846 100644 --- a/loader/include/Geode/cocos/robtop/mouse_dispatcher/CCMouseDelegate.h +++ b/loader/include/Geode/cocos/robtop/mouse_dispatcher/CCMouseDelegate.h @@ -22,7 +22,7 @@ RT_ADD( class CC_DLL CCMouseHandler : public CCObject { public: - GEODE_ZERO_CONSTRUCTOR(CCMouseHandler, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCMouseHandler, CCObject) inline CCMouseHandler() = default; virtual ~CCMouseHandler(); diff --git a/loader/include/Geode/cocos/sprite_nodes/CCSprite.h b/loader/include/Geode/cocos/sprite_nodes/CCSprite.h index 636e7a41..0b4d1702 100644 --- a/loader/include/Geode/cocos/sprite_nodes/CCSprite.h +++ b/loader/include/Geode/cocos/sprite_nodes/CCSprite.h @@ -168,7 +168,7 @@ public: * @js ctor */ CCSprite(void); - GEODE_ZERO_CONSTRUCTOR(CCSprite, CCNodeRGBA) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCSprite, CCNodeRGBA) /** * Default destructor diff --git a/loader/include/Geode/cocos/sprite_nodes/CCSpriteBatchNode.h b/loader/include/Geode/cocos/sprite_nodes/CCSpriteBatchNode.h index 3233c913..3d2531b3 100644 --- a/loader/include/Geode/cocos/sprite_nodes/CCSpriteBatchNode.h +++ b/loader/include/Geode/cocos/sprite_nodes/CCSpriteBatchNode.h @@ -68,7 +68,7 @@ public: * @js ctor */ CCSpriteBatchNode(); - GEODE_ZERO_CONSTRUCTOR(CCSpriteBatchNode, CCNode) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCSpriteBatchNode, CCNode) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/text_input_node/CCIMEDelegate.h b/loader/include/Geode/cocos/text_input_node/CCIMEDelegate.h index 6a83a4a3..786d30d4 100644 --- a/loader/include/Geode/cocos/text_input_node/CCIMEDelegate.h +++ b/loader/include/Geode/cocos/text_input_node/CCIMEDelegate.h @@ -50,7 +50,7 @@ class CC_DLL CCIMEDelegate { GEODE_FRIEND_MODIFY public: - GEODE_ZERO_CONSTRUCTOR_BEGIN(CCIMEDelegate) + GEODE_CUSTOM_CONSTRUCTOR_BEGIN(CCIMEDelegate) virtual ~CCIMEDelegate(); virtual bool attachWithIME(); diff --git a/loader/include/Geode/cocos/textures/CCTexture2D.h b/loader/include/Geode/cocos/textures/CCTexture2D.h index f83c5171..3ad811ea 100644 --- a/loader/include/Geode/cocos/textures/CCTexture2D.h +++ b/loader/include/Geode/cocos/textures/CCTexture2D.h @@ -117,7 +117,7 @@ public: * @js ctor */ CCTexture2D(); - GEODE_ZERO_CONSTRUCTOR(CCTexture2D, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCTexture2D, CCObject) /** * @js NA * @lua NA diff --git a/loader/include/Geode/cocos/touch_dispatcher/CCTouchHandler.h b/loader/include/Geode/cocos/touch_dispatcher/CCTouchHandler.h index 1671092d..08b29f9d 100644 --- a/loader/include/Geode/cocos/touch_dispatcher/CCTouchHandler.h +++ b/loader/include/Geode/cocos/touch_dispatcher/CCTouchHandler.h @@ -48,7 +48,7 @@ class CC_DLL CCTouchHandler : public CCObject { GEODE_FRIEND_MODIFY public: - GEODE_ZERO_CONSTRUCTOR(CCTouchHandler, CCObject) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCTouchHandler, CCObject) inline CCTouchHandler() = default; virtual ~CCTouchHandler(void); @@ -86,7 +86,7 @@ class CC_DLL CCStandardTouchHandler : public CCTouchHandler { GEODE_FRIEND_MODIFY public: - GEODE_ZERO_CONSTRUCTOR(CCStandardTouchHandler, CCTouchHandler) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCStandardTouchHandler, CCTouchHandler) inline CCStandardTouchHandler() = default; ~CCStandardTouchHandler(void); @@ -110,7 +110,7 @@ class CC_DLL CCTargetedTouchHandler : public CCTouchHandler { GEODE_FRIEND_MODIFY public: - GEODE_ZERO_CONSTRUCTOR(CCTargetedTouchHandler, CCTouchHandler) + GEODE_CUSTOM_CONSTRUCTOR_COCOS(CCTargetedTouchHandler, CCTouchHandler) inline CCTargetedTouchHandler() = default; ~CCTargetedTouchHandler(void); From ed02c8a893f82ae8902dccc49707cc4752d480b3 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Mon, 6 Mar 2023 21:24:38 +0300 Subject: [PATCH 14/18] actually fix fields lol --- loader/include/Geode/modify/Modify.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loader/include/Geode/modify/Modify.hpp b/loader/include/Geode/modify/Modify.hpp index e3e3efcd..e5cd1dd1 100644 --- a/loader/include/Geode/modify/Modify.hpp +++ b/loader/include/Geode/modify/Modify.hpp @@ -134,8 +134,8 @@ namespace geode { // abusing the internal stuff // basically we dont want modify to invoke base ctors and dtors // we already have utilities for these, which are ccdestructor - // and the zero constructor - Modify() : Base(ZeroConstructor) {} + // and the cutoff constructor + Modify() : Base(CutoffConstructor, sizeof(Base)) {} ~Modify() { cocos2d::CCDestructor::lock(this) = true; From 0f19f09a3211933895b7c9b2ff559d8db5afefc9 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:59:30 +0200 Subject: [PATCH 15/18] fix version comparisons --- loader/include/Geode/utils/VersionInfo.hpp | 36 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/loader/include/Geode/utils/VersionInfo.hpp b/loader/include/Geode/utils/VersionInfo.hpp index d9df8c88..af63f04c 100644 --- a/loader/include/Geode/utils/VersionInfo.hpp +++ b/loader/include/Geode/utils/VersionInfo.hpp @@ -56,8 +56,8 @@ namespace geode { constexpr bool operator>(VersionTag const& other) const { if (value == other.value) { if (number && other.number) return number > other.number; - if (number) return true; - if (other.number) return false; + if (number) return false; + if (other.number) return true; return false; } return value > other.value; @@ -65,8 +65,8 @@ namespace geode { constexpr bool operator>=(VersionTag const& other) const { if (value == other.value) { if (number && other.number) return number >= other.number; - if (number) return true; - if (other.number) return false; + if (number) return false; + if (other.number) return true; return true; } return value >= other.value; @@ -77,6 +77,34 @@ namespace geode { std::string toString() const; }; + constexpr bool operator<(std::optional const& a, std::optional const& b) { + if (a && b) return a < b; + if (a) return true; + if (b) return false; + return false; + } + + constexpr bool operator<=(std::optional const& a, std::optional const& b) { + if (a && b) return a <= b; + if (a) return true; + if (b) return false; + return true; + } + + constexpr bool operator>(std::optional const& a, std::optional const& b) { + if (a && b) return a > b; + if (a) return false; + if (b) return true; + return false; + } + + constexpr bool operator>=(std::optional const& a, std::optional const& b) { + if (a && b) return a >= b; + if (a) return false; + if (b) return true; + return true; + } + /** * Class representing version information. Uses a limited subset of SemVer; * identifiers are restricted to a few predefined ones, and only one From 00852654ad8f301450fdf975902456772dadc23c Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 6 Mar 2023 21:55:02 +0200 Subject: [PATCH 16/18] fix layout infinite recursion issue + EditorPauseLayer object labels --- .../include/Geode/cocos/base_nodes/Layout.hpp | 3 +- loader/src/cocos2d-ext/Layout.cpp | 47 +++++++++++-------- loader/src/ids/EditorPauseLayer.cpp | 5 +- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/loader/include/Geode/cocos/base_nodes/Layout.hpp b/loader/include/Geode/cocos/base_nodes/Layout.hpp index afc1d19b..bd4e23ac 100644 --- a/loader/include/Geode/cocos/base_nodes/Layout.hpp +++ b/loader/include/Geode/cocos/base_nodes/Layout.hpp @@ -234,7 +234,8 @@ protected: CCNode* on, CCArray* nodes, std::pair const& minMaxPrios, bool doAutoScale, - float scale, float squish, int prio + float scale, float squish, int prio, + size_t depth ) const; AxisLayout(Axis); diff --git a/loader/src/cocos2d-ext/Layout.cpp b/loader/src/cocos2d-ext/Layout.cpp index e829754e..c4e64a5f 100644 --- a/loader/src/cocos2d-ext/Layout.cpp +++ b/loader/src/cocos2d-ext/Layout.cpp @@ -9,6 +9,9 @@ USE_GEODE_NAMESPACE(); #pragma warning(disable: 4273) +// if 5k iterations isn't enough to fit the layout, then something is wrong +static size_t RECURSION_DEPTH_LIMIT = 5000; + void CCNode::swapChildIndices(CCNode* first, CCNode* second) { m_pChildren->exchangeObject(first, second); std::swap(first->m_nZOrder, second->m_nZOrder); @@ -277,11 +280,10 @@ AxisLayout::Row* AxisLayout::fitInRow( // also force at least one object to be added to this row, because if // it's too large for this row it's gonna be too large for all rows if ( - m_growCrossAxis && (( + m_growCrossAxis && ( (nextAxisScalableLength + nextAxisUnscalableLength > available.axisLength) && - ix != 0 && - !isOptsSameLine(opts) - )) + ix != 0 && !isOptsSameLine(opts) + ) ) { break; } @@ -323,16 +325,17 @@ AxisLayout::Row* AxisLayout::fitInRow( nodes->removeFirstObject(); } - auto scaleDownFactor = scale - .025f; + // todo: make this calculation more smart to avoid so much unnecessary recursion + auto scaleDownFactor = scale - .0125f; auto squishFactor = available.axisLength / (axisUnsquishedLength + .01f) * squish; // calculate row scale, squish, and prio int tries = 1000; while (axisLength > available.axisLength) { if (this->canTryScalingDown( - res, prio, scale, scale - .025f, minMaxPrios + res, prio, scale, scale - .0125f, minMaxPrios )) { - scale -= .025f; + scale -= .0125f; } else { squish = available.axisLength / (axisUnsquishedLength + .01f) * squish; @@ -366,7 +369,6 @@ AxisLayout::Row* AxisLayout::fitInRow( // the .01f is because floating point arithmetic is imprecise and you // end up in a situation where it confidently tells you that // 241 > 241 == true - // todo: make this calculation more smart to avoid so much unnecessary recursion scaleDownFactor, // how much should the nodes be squished to fit the next item in this // row @@ -389,9 +391,9 @@ bool AxisLayout::canTryScalingDown( // if the scale is less than the lowest min scale allowed, then // trying to scale will have no effect and not help anywmore crossScaleDownFactor < minScaleForPrio || - // if the scale down factor is the same as before, then we've - // entered an infinite loop - crossScaleDownFactor == scale + // if the scale down factor is really close to the same as before, + // then we've entered an infinite loop (float == float is unreliable) + (fabsf(crossScaleDownFactor - scale) < .001f) ) { // is there still some lower priority nodes we could try scaling? if (prio > minMaxPrios.first) { @@ -414,6 +416,7 @@ bool AxisLayout::canTryScalingDown( // otherwise scale as usual else { attemptRescale = true; + scale = crossScaleDownFactor; } return attemptRescale; } @@ -422,7 +425,8 @@ void AxisLayout::tryFitLayout( CCNode* on, CCArray* nodes, std::pair const& minMaxPrios, bool doAutoScale, - float scale, float squish, int prio + float scale, float squish, int prio, + size_t depth ) const { // where do all of these magical calculations come from? // idk i got tired of doing the math but they work so ¯\_(ツ)_/¯ @@ -447,13 +451,13 @@ void AxisLayout::tryFitLayout( rows->addObject(row); if ( row->nextOverflowScaleDownFactor > crossScaleDownFactor && - row->nextOverflowScaleDownFactor <= scale + row->nextOverflowScaleDownFactor < scale ) { crossScaleDownFactor = row->nextOverflowScaleDownFactor; } if ( row->nextOverflowSquishFactor > crossSquishFactor && - row->nextOverflowSquishFactor <= squish + row->nextOverflowSquishFactor < squish ) { crossSquishFactor = row->nextOverflowSquishFactor; } @@ -484,7 +488,8 @@ void AxisLayout::tryFitLayout( if ( !m_allowCrossAxisOverflow && doAutoScale && - totalRowCrossLength > available.crossLength + totalRowCrossLength > available.crossLength && + depth < RECURSION_DEPTH_LIMIT ) { if (this->canTryScalingDown( nodes, prio, scale, crossScaleDownFactor, minMaxPrios @@ -493,7 +498,8 @@ void AxisLayout::tryFitLayout( return this->tryFitLayout( on, nodes, minMaxPrios, doAutoScale, - scale, squish, prio + scale, squish, prio, + depth + 1 ); } } @@ -501,7 +507,8 @@ void AxisLayout::tryFitLayout( // if we're still overflowing, squeeze nodes closer together if ( !m_allowCrossAxisOverflow && - totalRowCrossLength > available.crossLength + totalRowCrossLength > available.crossLength && + depth < RECURSION_DEPTH_LIMIT ) { // if squishing rows would take less squishing that squishing columns, // then squish rows @@ -513,7 +520,8 @@ void AxisLayout::tryFitLayout( return this->tryFitLayout( on, nodes, minMaxPrios, doAutoScale, - scale, crossSquishFactor, prio + scale, crossSquishFactor, prio, + depth + 1 ); } } @@ -719,7 +727,8 @@ void AxisLayout::apply(CCNode* on) { this->tryFitLayout( on, nodes, minMaxPrio, doAutoScale, - this->maxScaleForPrio(nodes, minMaxPrio.second), 1.f, minMaxPrio.second + this->maxScaleForPrio(nodes, minMaxPrio.second), 1.f, minMaxPrio.second, + 0 ); } diff --git a/loader/src/ids/EditorPauseLayer.cpp b/loader/src/ids/EditorPauseLayer.cpp index ebba86d0..00b96c68 100644 --- a/loader/src/ids/EditorPauseLayer.cpp +++ b/loader/src/ids/EditorPauseLayer.cpp @@ -237,6 +237,7 @@ $register_ids(EditorPauseLayer) { ->setAxisAlignment(AxisAlignment::End) ->setAxisReverse(true) ->setCrossAxisOverflow(false) + ->setCrossAxisAlignment(AxisAlignment::Start) ->setCrossAxisLineAlignment(AxisAlignment::Start), this->getChildByID("object-count-label"), this->getChildByID("length-label"), @@ -250,8 +251,8 @@ $register_ids(EditorPauseLayer) { ->setBreakLine(true) ); } - menu->setContentSize({ 165.f, 100.f }); - menu->setPosition(70.f, winSize.height - 55.f); + menu->setContentSize({ 180.f, 100.f }); + menu->setPosition(100.f, winSize.height - 55.f); menu->updateLayout(); } } From 530be4cfbb4731af11c3f5021b771a1acf942698 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 6 Mar 2023 22:04:59 +0200 Subject: [PATCH 17/18] unbump version back to 1.0.0-beta.9 because apparently we still gotta do crash testing --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index afaf360d..73ff4a6f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 \ No newline at end of file +1.0.0-beta.9 \ No newline at end of file From 1b2c7606b63f77fd284554c312bcc8b29054ccea Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Tue, 7 Mar 2023 11:56:36 +0300 Subject: [PATCH 18/18] Fix recursive comparison in VersionTag --- loader/include/Geode/utils/VersionInfo.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/loader/include/Geode/utils/VersionInfo.hpp b/loader/include/Geode/utils/VersionInfo.hpp index af63f04c..3fce41e8 100644 --- a/loader/include/Geode/utils/VersionInfo.hpp +++ b/loader/include/Geode/utils/VersionInfo.hpp @@ -78,28 +78,28 @@ namespace geode { }; constexpr bool operator<(std::optional const& a, std::optional const& b) { - if (a && b) return a < b; + if (a && b) return *a < *b; if (a) return true; if (b) return false; return false; } constexpr bool operator<=(std::optional const& a, std::optional const& b) { - if (a && b) return a <= b; + if (a && b) return *a <= *b; if (a) return true; if (b) return false; return true; } constexpr bool operator>(std::optional const& a, std::optional const& b) { - if (a && b) return a > b; + if (a && b) return *a > *b; if (a) return false; if (b) return true; return false; } constexpr bool operator>=(std::optional const& a, std::optional const& b) { - if (a && b) return a >= b; + if (a && b) return *a >= *b; if (a) return false; if (b) return true; return true; @@ -230,4 +230,4 @@ struct json::Serialize { } return ver.unwrap(); } -}; \ No newline at end of file +};