Skip to content

Commit

Permalink
make member check and size check less confusing
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Dec 20, 2023
1 parent 3aa3ae7 commit 7c0d7ba
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 167 deletions.
44 changes: 23 additions & 21 deletions loader/test/members/Android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,38 @@

// Add known android struct members here

GEODE_SIZE_CHECK(CCObject, 0x34);

// needed classes are ones in the ids folder and some generic ones (i think they are already done though so only ids)

GEODE_MEMBER_CHECK(GameManager, m_playLayer, 0x138);
GEODE_MEMBER_CHECK(GameManager, m_levelEditorLayer, 0x13c);
GEODE_MEMBER_CHECK(GameManager, m_canGetLevelSaveData, 0x28c);
// GEODE_MEMBER_CHECK(GameManager, m_playLayer, 0x138);
// GEODE_MEMBER_CHECK(GameManager, m_levelEditorLayer, 0x13c);
// GEODE_MEMBER_CHECK(GameManager, m_canGetLevelSaveData, 0x28c);

static_assert(sizeof(GJBaseGameLayer) == 0x2cc);
// static_assert(sizeof(GJBaseGameLayer) == 0x2cc);

GEODE_MEMBER_CHECK(PlayLayer, unknown4e8, 0x2e8);
GEODE_MEMBER_CHECK(PlayLayer, m_endPortal, 0x324);
GEODE_MEMBER_CHECK(PlayLayer, m_bottomGround, 0x37c);
GEODE_MEMBER_CHECK(PlayLayer, m_topGround, 0x380);
GEODE_MEMBER_CHECK(PlayLayer, m_level, 0x470);
GEODE_MEMBER_CHECK(PlayLayer, m_shouldTryToKick, 0x4e0);
// GEODE_MEMBER_CHECK(PlayLayer, unknown4e8, 0x2e8);
// GEODE_MEMBER_CHECK(PlayLayer, m_endPortal, 0x324);
// GEODE_MEMBER_CHECK(PlayLayer, m_bottomGround, 0x37c);
// GEODE_MEMBER_CHECK(PlayLayer, m_topGround, 0x380);
// GEODE_MEMBER_CHECK(PlayLayer, m_level, 0x470);
// GEODE_MEMBER_CHECK(PlayLayer, m_shouldTryToKick, 0x4e0);

static_assert(sizeof(GameObject) == 0x42c);
// static_assert(sizeof(GameObject) == 0x42c);

GEODE_MEMBER_CHECK(GameStatsManager, m_dailyChests, 0x110);
GEODE_MEMBER_CHECK(GameStatsManager, m_completedLevels, 0x164);
// GEODE_MEMBER_CHECK(GameStatsManager, m_dailyChests, 0x110);
// GEODE_MEMBER_CHECK(GameStatsManager, m_completedLevels, 0x164);

GEODE_MEMBER_CHECK(DailyLevelPage, m_weekly, 0x1ed);
// GEODE_MEMBER_CHECK(DailyLevelPage, m_weekly, 0x1ed);

GEODE_MEMBER_CHECK(TeleportPortalObject, m_orangePortal, 0x430);
// GEODE_MEMBER_CHECK(TeleportPortalObject, m_orangePortal, 0x430);

GEODE_MEMBER_CHECK(EditorUI, m_rotationControl, 0x16c);
GEODE_MEMBER_CHECK(EditorUI, m_updateTimeMarkers, 0x1a4);
GEODE_MEMBER_CHECK(EditorUI, m_selectedObjects, 0x1bc);
GEODE_MEMBER_CHECK(EditorUI, m_selectedObject, 0x2c4);
// GEODE_MEMBER_CHECK(EditorUI, m_rotationControl, 0x16c);
// GEODE_MEMBER_CHECK(EditorUI, m_updateTimeMarkers, 0x1a4);
// GEODE_MEMBER_CHECK(EditorUI, m_selectedObjects, 0x1bc);
// GEODE_MEMBER_CHECK(EditorUI, m_selectedObject, 0x2c4);

GEODE_MEMBER_CHECK(MoreSearchLayer, m_enterSongID, 0x1E4);
GEODE_MEMBER_CHECK(MoreSearchLayer, m_songLeftBtn, 0x1D4);
// GEODE_MEMBER_CHECK(MoreSearchLayer, m_enterSongID, 0x1E4);
// GEODE_MEMBER_CHECK(MoreSearchLayer, m_songLeftBtn, 0x1D4);

#endif
29 changes: 23 additions & 6 deletions loader/test/members/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,36 @@ struct False {
static constexpr auto value = false;
};

template<int Difference, class Class, class Member, bool Predicate>
template<int Difference, int Expected, int Current, class Class, class Member, bool Predicate>
struct MemberIsOffsetBy {
static_assert(False<Difference>::value, "Member is offset by this value");
static_assert(False<Difference, Expected, Current>::value, "Member is offset by this value (Difference, Expected, Current)");
};

template<int Difference, class Class, class Member>
template<int Difference, int Expected, int Current, class Class, bool Predicate>
struct SizeIsOffsetBy {
static_assert(False<Difference, Expected, Current>::value, "Size is offset by this value (Difference, Expected, Current)");
};

template<int Difference, int Expected, int Current, class Class, class Member>
struct MemberIsOffsetBy<Difference, Class, Member, true> {

};

template<int Difference, int Expected, int Current, class Class>
struct SizeIsOffsetBy<Difference, Class, true> {

};

template <class Member, class Class, int Offset, int Expected>
struct SingleChecker {
using IsOffsetBy = MemberIsOffsetBy<Offset - Expected, Class, Member, Expected == Offset>;
struct SingleMemberChecker {
using IsOffsetBy = MemberIsOffsetBy<Offset - Expected, Expected, Offset, Class, Member, Expected == Offset>;
};

template <class Class, int Offset, int Expected>
struct SingleSizeChecker {
using IsOffsetBy = MemberIsOffsetBy<Offset - Expected, Expected, Offset, Class, Member, Expected == Offset>;
};

#define GEODE_MEMBER_CHECK(Class_, Member_, Offset_) class Member_; SingleChecker<Member_, Class_, offsetof(Class_, Member_), Offset_>::IsOffsetBy GEODE_CONCAT(OffsetBy, __LINE__)
#define GEODE_MEMBER_CHECK(Class_, Member_, Offset_) class Member_; SingleMemberChecker<Member_, Class_, offsetof(Class_, Member_), Offset_>::IsOffsetBy GEODE_CONCAT(OffsetBy, __LINE__)

#define GEODE_SIZE_CHECK(Class_, Offset_) class Class_; SingleMemberChecker<Class_, sizeof(Class_), Offset_>::IsOffsetBy GEODE_CONCAT(OffsetBy, __LINE__)
184 changes: 92 additions & 92 deletions loader/test/members/MacOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,97 @@

#ifdef GEODE_IS_MACOS

// PlayerObject
GEODE_MEMBER_CHECK(PlayerObject, m_collisionLog, 0x518);
GEODE_MEMBER_CHECK(PlayerObject, m_particleSystems, 0x590);
GEODE_MEMBER_CHECK(PlayerObject, m_waveTrail, 0x600);
GEODE_MEMBER_CHECK(PlayerObject, m_objectSnappedTo, 0x690);
GEODE_MEMBER_CHECK(PlayerObject, m_playerColor1, 0x7c2);

// EditorUI
GEODE_MEMBER_CHECK(EditorUI, m_buttonBar, 0x1a0);
GEODE_MEMBER_CHECK(EditorUI, m_scaleControl, 0x208);
GEODE_MEMBER_CHECK(EditorUI, m_swipeEnabled, 0x23c);
GEODE_MEMBER_CHECK(EditorUI, m_updateTimeMarkers, 0x244);
GEODE_MEMBER_CHECK(EditorUI, m_selectedObjects, 0x260);
GEODE_MEMBER_CHECK(EditorUI, m_selectedObject, 0x440);

// LevelEditorLayer
GEODE_MEMBER_CHECK(LevelEditorLayer, m_editorUI, 0x5d8);
GEODE_MEMBER_CHECK(LevelEditorLayer, m_level, 0x618);

// PlayLayer
GEODE_MEMBER_CHECK(PlayLayer, unknown518, 0x518);
GEODE_MEMBER_CHECK(PlayLayer, unknown5f4, 0x5f4);
GEODE_MEMBER_CHECK(PlayLayer, unknown680, 0x680);
GEODE_MEMBER_CHECK(PlayLayer, m_replayInputs, 0x6a8);
GEODE_MEMBER_CHECK(PlayLayer, m_level, 0x728);
GEODE_MEMBER_CHECK(PlayLayer, m_shouldTryToKick, 0x7a8);

// GameManager
GEODE_MEMBER_CHECK(GameManager, m_playLayer, 0x180);
GEODE_MEMBER_CHECK(GameManager, m_levelEditorLayer, 0x188);
GEODE_MEMBER_CHECK(GameManager, m_menuLayer, 0x198);
GEODE_MEMBER_CHECK(GameManager, m_playerUDID, 0x1b8);
GEODE_MEMBER_CHECK(GameManager, m_playerUserID, 0x1cc);
GEODE_MEMBER_CHECK(GameManager, m_playerFrame, 0x200);
GEODE_MEMBER_CHECK(GameManager, m_clickedGarage, 0x2a2); // todo: find why this is not 0x2a2

// GameObject
GEODE_MEMBER_CHECK(GameObject, m_baseColorID, 0x27c);
GEODE_MEMBER_CHECK(GameObject, m_detailColorID, 0x280);
GEODE_MEMBER_CHECK(GameObject, m_active, 0x2e5);
GEODE_MEMBER_CHECK(GameObject, m_baseSprite, 0x348);
GEODE_MEMBER_CHECK(GameObject, m_startPosition, 0x37c);
GEODE_MEMBER_CHECK(GameObject, m_baseColor, 0x410);
GEODE_MEMBER_CHECK(GameObject, m_groups, 0x458);
GEODE_MEMBER_CHECK(GameObject, m_effectManager, 0x4d8);

// EffectGameObject
GEODE_MEMBER_CHECK(EffectGameObject, m_duration, 0x4f0);
GEODE_MEMBER_CHECK(EffectGameObject, m_followMod, 0x530);
GEODE_MEMBER_CHECK(EffectGameObject, m_hsvValue, 0x560);
GEODE_MEMBER_CHECK(EffectGameObject, m_spawnDelay, 0x588);
GEODE_MEMBER_CHECK(EffectGameObject, m_itemBlockAID, 0x5b0);

// TeleportPortalObject
GEODE_MEMBER_CHECK(TeleportPortalObject, m_orangePortal, 0x4f8);

// StartPosObject
GEODE_MEMBER_CHECK(StartPosObject, m_levelSettings, 0x5e0);

// SetupPulsePopup
GEODE_MEMBER_CHECK(SetupPulsePopup, m_currentColorSpr, 0x2d0);
GEODE_MEMBER_CHECK(SetupPulsePopup, m_pulseMode, 0x38c);

// ColorSelectPopup
GEODE_MEMBER_CHECK(ColorSelectPopup, m_copyColor, 0x372);

// LevelInfoLayer
GEODE_MEMBER_CHECK(LevelInfoLayer, m_level, 0x1c0);

// LevelBrowserLayer
GEODE_MEMBER_CHECK(LevelBrowserLayer, m_rightArrow, 0x1a8);
GEODE_MEMBER_CHECK(LevelBrowserLayer, m_leftArrow, 0x1b0);
GEODE_MEMBER_CHECK(LevelBrowserLayer, m_searchObject, 0x1d8);
GEODE_MEMBER_CHECK(LevelBrowserLayer, m_itemCount, 0x208);

// LocalLevelManager
GEODE_MEMBER_CHECK(LocalLevelManager, m_localLevels, 0x140);

// GameStatsManager
GEODE_MEMBER_CHECK(GameStatsManager, m_dailyChests, 0x170);
GEODE_MEMBER_CHECK(GameStatsManager, m_completedLevels, 0x200);
GEODE_MEMBER_CHECK(GameStatsManager, m_weeklyChest, 0x278);

// DailyLevelPage
GEODE_MEMBER_CHECK(DailyLevelPage, m_weekly, 0x291);

// GameLevelManager
GEODE_MEMBER_CHECK(GameLevelManager, m_weeklyID, 0x1a8);
GEODE_MEMBER_CHECK(GameLevelManager, m_gauntletLevels, 0x1b0);
GEODE_MEMBER_CHECK(GameLevelManager, m_timerDict, 0x1e8);
GEODE_MEMBER_CHECK(GameLevelManager, m_accountIDtoUserIDDict, 0x1f8);
GEODE_MEMBER_CHECK(GameLevelManager, m_userIDtoAccountIDDict, 0x200);
// // PlayerObject
// GEODE_MEMBER_CHECK(PlayerObject, m_collisionLog, 0x518);
// GEODE_MEMBER_CHECK(PlayerObject, m_particleSystems, 0x590);
// GEODE_MEMBER_CHECK(PlayerObject, m_waveTrail, 0x600);
// GEODE_MEMBER_CHECK(PlayerObject, m_objectSnappedTo, 0x690);
// GEODE_MEMBER_CHECK(PlayerObject, m_playerColor1, 0x7c2);

// // EditorUI
// GEODE_MEMBER_CHECK(EditorUI, m_buttonBar, 0x1a0);
// GEODE_MEMBER_CHECK(EditorUI, m_scaleControl, 0x208);
// GEODE_MEMBER_CHECK(EditorUI, m_swipeEnabled, 0x23c);
// GEODE_MEMBER_CHECK(EditorUI, m_updateTimeMarkers, 0x244);
// GEODE_MEMBER_CHECK(EditorUI, m_selectedObjects, 0x260);
// GEODE_MEMBER_CHECK(EditorUI, m_selectedObject, 0x440);

// // LevelEditorLayer
// GEODE_MEMBER_CHECK(LevelEditorLayer, m_editorUI, 0x5d8);
// GEODE_MEMBER_CHECK(LevelEditorLayer, m_level, 0x618);

// // PlayLayer
// GEODE_MEMBER_CHECK(PlayLayer, unknown518, 0x518);
// GEODE_MEMBER_CHECK(PlayLayer, unknown5f4, 0x5f4);
// GEODE_MEMBER_CHECK(PlayLayer, unknown680, 0x680);
// GEODE_MEMBER_CHECK(PlayLayer, m_replayInputs, 0x6a8);
// GEODE_MEMBER_CHECK(PlayLayer, m_level, 0x728);
// GEODE_MEMBER_CHECK(PlayLayer, m_shouldTryToKick, 0x7a8);

// // GameManager
// GEODE_MEMBER_CHECK(GameManager, m_playLayer, 0x180);
// GEODE_MEMBER_CHECK(GameManager, m_levelEditorLayer, 0x188);
// GEODE_MEMBER_CHECK(GameManager, m_menuLayer, 0x198);
// GEODE_MEMBER_CHECK(GameManager, m_playerUDID, 0x1b8);
// GEODE_MEMBER_CHECK(GameManager, m_playerUserID, 0x1cc);
// GEODE_MEMBER_CHECK(GameManager, m_playerFrame, 0x200);
// GEODE_MEMBER_CHECK(GameManager, m_clickedGarage, 0x2a2); // todo: find why this is not 0x2a2

// // GameObject
// GEODE_MEMBER_CHECK(GameObject, m_baseColorID, 0x27c);
// GEODE_MEMBER_CHECK(GameObject, m_detailColorID, 0x280);
// GEODE_MEMBER_CHECK(GameObject, m_active, 0x2e5);
// GEODE_MEMBER_CHECK(GameObject, m_baseSprite, 0x348);
// GEODE_MEMBER_CHECK(GameObject, m_startPosition, 0x37c);
// GEODE_MEMBER_CHECK(GameObject, m_baseColor, 0x410);
// GEODE_MEMBER_CHECK(GameObject, m_groups, 0x458);
// GEODE_MEMBER_CHECK(GameObject, m_effectManager, 0x4d8);

// // EffectGameObject
// GEODE_MEMBER_CHECK(EffectGameObject, m_duration, 0x4f0);
// GEODE_MEMBER_CHECK(EffectGameObject, m_followMod, 0x530);
// GEODE_MEMBER_CHECK(EffectGameObject, m_hsvValue, 0x560);
// GEODE_MEMBER_CHECK(EffectGameObject, m_spawnDelay, 0x588);
// GEODE_MEMBER_CHECK(EffectGameObject, m_itemBlockAID, 0x5b0);

// // TeleportPortalObject
// GEODE_MEMBER_CHECK(TeleportPortalObject, m_orangePortal, 0x4f8);

// // StartPosObject
// GEODE_MEMBER_CHECK(StartPosObject, m_levelSettings, 0x5e0);

// // SetupPulsePopup
// GEODE_MEMBER_CHECK(SetupPulsePopup, m_currentColorSpr, 0x2d0);
// GEODE_MEMBER_CHECK(SetupPulsePopup, m_pulseMode, 0x38c);

// // ColorSelectPopup
// GEODE_MEMBER_CHECK(ColorSelectPopup, m_copyColor, 0x372);

// // LevelInfoLayer
// GEODE_MEMBER_CHECK(LevelInfoLayer, m_level, 0x1c0);

// // LevelBrowserLayer
// GEODE_MEMBER_CHECK(LevelBrowserLayer, m_rightArrow, 0x1a8);
// GEODE_MEMBER_CHECK(LevelBrowserLayer, m_leftArrow, 0x1b0);
// GEODE_MEMBER_CHECK(LevelBrowserLayer, m_searchObject, 0x1d8);
// GEODE_MEMBER_CHECK(LevelBrowserLayer, m_itemCount, 0x208);

// // LocalLevelManager
// GEODE_MEMBER_CHECK(LocalLevelManager, m_localLevels, 0x140);

// // GameStatsManager
// GEODE_MEMBER_CHECK(GameStatsManager, m_dailyChests, 0x170);
// GEODE_MEMBER_CHECK(GameStatsManager, m_completedLevels, 0x200);
// GEODE_MEMBER_CHECK(GameStatsManager, m_weeklyChest, 0x278);

// // DailyLevelPage
// GEODE_MEMBER_CHECK(DailyLevelPage, m_weekly, 0x291);

// // GameLevelManager
// GEODE_MEMBER_CHECK(GameLevelManager, m_weeklyID, 0x1a8);
// GEODE_MEMBER_CHECK(GameLevelManager, m_gauntletLevels, 0x1b0);
// GEODE_MEMBER_CHECK(GameLevelManager, m_timerDict, 0x1e8);
// GEODE_MEMBER_CHECK(GameLevelManager, m_accountIDtoUserIDDict, 0x1f8);
// GEODE_MEMBER_CHECK(GameLevelManager, m_userIDtoAccountIDDict, 0x200);

#endif
Loading

0 comments on commit 7c0d7ba

Please sign in to comment.