Skip to content

Feature/macro#21

Merged
Glubus merged 6 commits intomasterfrom
feature/macro
Jul 13, 2025
Merged

Feature/macro#21
Glubus merged 6 commits intomasterfrom
feature/macro

Conversation

@Glubus
Copy link
Copy Markdown
Owner

@Glubus Glubus commented Jul 13, 2025

Feature: Macro-based OSU Accessor Implementation

Overview

Introduced a powerful macro system that eliminates ~1000+ lines of boilerplate code while providing consistent, type-safe OSU memory accessors across all client types.

Key Changes

  • impl_osu_accessor! macro for generating client-specific accessor methods
  • generate_reader_fn! and generate_offset_getter! macros for standardized memory operations
  • Consistent API across Stable and Lazer clients
  • Reduced maintenance burden - changes now only need to be made in one place

Before vs After

// Before: Manual implementation for each accessor
impl<'a> CommonReader<'a> {
    pub fn game_state(&mut self) -> Result<GameState, Error> {
        match self.osu_type {
            OsuClientKind::Stable => stable::memory::game_state(self.process, self.state),
            _ => Err(Error::Unsupported("Unsupported osu type".to_string())),
        }
    }
    // ... repeat for every accessor
}

// After: Clean macro-driven approach
impl<'a> CommonReader<'a> {
    impl_osu_accessor! {
        fn game_state() -> GameState => stable::memory::game_state,
        fn menu_game_mode() -> GameMode => stable::memory::menu_game_mode,
        fn path_folder() -> PathBuf => stable::memory::path_folder,
        fn check_game_state() -> bool => stable::memory::check_game_state
    }
}

Impact

  • ~1000+ lines eliminated through code generation
  • Future-proof design for new OSU client types
  • Enhanced PP calculator with improved mod detection
  • Consistent error handling across all accessors

This refactoring significantly accelerates development and reduces bugs through consistent, generated code patterns.

@Glubus Glubus merged commit 641fddf into master Jul 13, 2025
0 of 3 checks passed
@Glubus Glubus deleted the feature/macro branch July 13, 2025 11:12
Glubus added a commit that referenced this pull request Feb 28, 2026
* refactor: now full use of potential macros :) only for beatmap for now

* feat: passed common in macro

* feat: gameplay now using macro too

* fix: bug from me :)

* refactor & fix: passed everything in macros, added a new macro for reader won 1K line of code wow

* refactor: MACROS FEATURE IS DONE POG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant