From 2f3658432036760243250846f4d62156e8acac45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Sat, 28 Mar 2020 14:50:20 -0400 Subject: [PATCH] remove `struct` in variable declarations It was needed in C, but is useless in C++. --- include/audio/audio.h | 24 +++++----- include/audio/library.h | 32 +++++++------- include/audio/sample.h | 4 +- include/audio/stream.h | 8 ++-- include/audio/track.h | 8 ++-- include/beatmap/beatmap.h | 46 ++++++++++---------- include/beatmap/path.h | 14 +++--- include/game/base.h | 18 ++++---- include/game/clock.h | 4 +- include/game/osu.h | 2 +- include/game/tty.h | 6 +-- include/ui/audio.h | 10 ++--- include/ui/background.h | 10 ++--- include/ui/cursor.h | 10 ++--- include/ui/metadata.h | 16 +++---- include/ui/osu.h | 24 +++++----- include/ui/score.h | 10 ++--- include/video/display.h | 2 +- include/video/paint.h | 10 ++--- include/video/texture.h | 8 ++-- include/video/view.h | 12 ++--- lib/audio/audio.cc | 30 ++++++------- lib/audio/library.cc | 50 ++++++++++----------- lib/audio/sample.cc | 6 +-- lib/audio/stream.cc | 20 ++++----- lib/audio/track.cc | 6 +-- lib/beatmap/helpers.cc | 4 +- lib/beatmap/parser.cc | 92 +++++++++++++++++++-------------------- lib/beatmap/parser.h | 34 +++++++-------- lib/beatmap/path.cc | 32 +++++++------- lib/game/base.cc | 4 +- lib/game/clock.cc | 6 +-- lib/game/helpers.cc | 16 +++---- lib/game/osu.cc | 24 +++++----- lib/game/tty.cc | 12 ++--- lib/ui/audio.cc | 6 +-- lib/ui/background.cc | 12 ++--- lib/ui/cursor.cc | 10 ++--- lib/ui/metadata.cc | 30 ++++++------- lib/ui/osu.cc | 26 +++++------ lib/ui/osu_paint.cc | 40 ++++++++--------- lib/ui/score.cc | 8 ++-- lib/ui/screens/pause.cc | 2 +- lib/ui/screens/screens.h | 6 +-- lib/ui/shell.cc | 2 +- lib/video/display.cc | 4 +- lib/video/paint.cc | 6 +-- lib/video/texture.cc | 8 ++-- lib/video/view.cc | 12 ++--- 49 files changed, 393 insertions(+), 393 deletions(-) diff --git a/include/audio/audio.h b/include/audio/audio.h index bfb170d..4ca1ce1 100644 --- a/include/audio/audio.h +++ b/include/audio/audio.h @@ -119,7 +119,7 @@ namespace oshu { * * ```c * SDL_Init(SDL_AUDIO|...); - * struct oshu::audio audio; + * oshu::audio audio; * memset(&audio, 0, sizeof(audio)); * oshu::open_audio("file.ogg", &audio); * oshu::play_audio(&audio); @@ -162,7 +162,7 @@ struct audio { /** * The background music. */ - struct oshu::stream music; + oshu::stream music; /** * Tracks for playing sound effects on top of the music. * @@ -173,7 +173,7 @@ struct audio { * * \sa oshu::play_sample */ - struct oshu::track effects[16]; + oshu::track effects[16]; /** * Special track for the looping sample. * @@ -181,7 +181,7 @@ struct audio { * * \sa oshu::play_loop */ - struct oshu::track looping; + oshu::track looping; /** * A device ID returned by SDL, and required by most SDL audio * functions. @@ -206,7 +206,7 @@ struct audio { * * \sa oshu_audio_close */ -int open_audio(const char *url, struct oshu::audio *audio); +int open_audio(const char *url, oshu::audio *audio); /** * Start playing! @@ -216,7 +216,7 @@ int open_audio(const char *url, struct oshu::audio *audio); * * \sa oshu::pause_audio */ -void play_audio(struct oshu::audio *audio); +void play_audio(oshu::audio *audio); /** * Pause the stream. @@ -224,7 +224,7 @@ void play_audio(struct oshu::audio *audio); * Calling #oshu::play_audio will resume the audio playback where it was * left playing. */ -void pause_audio(struct oshu::audio *audio); +void pause_audio(oshu::audio *audio); /** * Play a sample on top of the background music. @@ -234,7 +234,7 @@ void pause_audio(struct oshu::audio *audio); * reached because all the effects tracks are used, the playback of one of * the samples is stopped to play the new sample. */ -void play_sample(struct oshu::audio *audio, struct oshu::sample *sample, float volume); +void play_sample(oshu::audio *audio, oshu::sample *sample, float volume); /** * Play a looping sample. @@ -245,7 +245,7 @@ void play_sample(struct oshu::audio *audio, struct oshu::sample *sample, float v * \sa oshu::play_sample * \sa oshu::stop_loop */ -void play_loop(struct oshu::audio *audio, struct oshu::sample *sample, float volume); +void play_loop(oshu::audio *audio, oshu::sample *sample, float volume); /** * Seek the music stream to the specifed target position in seconds. @@ -256,7 +256,7 @@ void play_loop(struct oshu::audio *audio, struct oshu::sample *sample, float vol * locks the audio thread, and stops all the currently playing sound effects, * which is definitely what you want. */ -int seek_music(struct oshu::audio *audio, double target); +int seek_music(oshu::audio *audio, double target); /** * Stop the looping sample. @@ -267,12 +267,12 @@ int seek_music(struct oshu::audio *audio, double target); * * \sa oshu::play_loop */ -void stop_loop(struct oshu::audio *audio); +void stop_loop(oshu::audio *audio); /** * Close the audio stream and free everything associated to it. */ -void close_audio(struct oshu::audio *audio); +void close_audio(oshu::audio *audio); /** \} */ diff --git a/include/audio/library.h b/include/audio/library.h index 947bf81..308d087 100644 --- a/include/audio/library.h +++ b/include/audio/library.h @@ -75,12 +75,12 @@ enum sound_shelf_index { * These pointers are NULL when no sample is available. */ struct sound_shelf { - struct oshu::sample *hit_normal; - struct oshu::sample *hit_whistle; - struct oshu::sample *hit_finish; - struct oshu::sample *hit_clap; - struct oshu::sample *slider_slide; - struct oshu::sample *slider_whistle; + oshu::sample *hit_normal; + oshu::sample *hit_whistle; + oshu::sample *hit_finish; + oshu::sample *hit_clap; + oshu::sample *slider_slide; + oshu::sample *slider_whistle; }; /** @@ -100,7 +100,7 @@ struct sound_room { * * \sa size */ - struct oshu::sound_shelf *shelves; + oshu::sound_shelf *shelves; /** * Indices of the shelves. * @@ -157,9 +157,9 @@ struct sound_library { * Format of the samples in the library. */ struct SDL_AudioSpec *format; - struct oshu::sound_room normal; - struct oshu::sound_room soft; - struct oshu::sound_room drum; + oshu::sound_room normal; + oshu::sound_room soft; + oshu::sound_room drum; }; /** @@ -173,12 +173,12 @@ struct sound_library { * * \sa oshu::close_sound_library */ -void open_sound_library(struct oshu::sound_library *library, struct SDL_AudioSpec *format); +void open_sound_library(oshu::sound_library *library, struct SDL_AudioSpec *format); /** * Delete all the loaded samples from the library. */ -void close_sound_library(struct oshu::sound_library *library); +void close_sound_library(oshu::sound_library *library); /** * Locate a sample on the filesystem and insert it into the library. @@ -187,7 +187,7 @@ void close_sound_library(struct oshu::sound_library *library); * * \sa oshu::register_sound */ -int register_sample(struct oshu::sound_library *library, enum oshu::sample_set_family set, int index, int type); +int register_sample(oshu::sound_library *library, enum oshu::sample_set_family set, int index, int type); /** * Load every sample required to play a hit sound effect. @@ -195,14 +195,14 @@ int register_sample(struct oshu::sound_library *library, enum oshu::sample_set_f * \sa oshu::register_sample * \sa oshu::populate_library */ -void register_sound(struct oshu::sound_library *library, struct oshu::hit_sound *sound); +void register_sound(oshu::sound_library *library, oshu::hit_sound *sound); /** * Find every sample reference into a beatmap and load them into the library. * * \sa oshu::register_sound */ -void populate_library(struct oshu::sound_library *library, struct oshu::beatmap *beatmap); +void populate_library(oshu::sound_library *library, oshu::beatmap *beatmap); /** * Play all the samples associated to the hit sound. @@ -213,7 +213,7 @@ void populate_library(struct oshu::sound_library *library, struct oshu::beatmap * * \sa oshu_find_sample */ -void play_sound(struct oshu::sound_library *library, struct oshu::hit_sound *sound, struct oshu::audio *audio); +void play_sound(oshu::sound_library *library, oshu::hit_sound *sound, oshu::audio *audio); /** \} */ diff --git a/include/audio/sample.h b/include/audio/sample.h index 1370efe..5325872 100644 --- a/include/audio/sample.h +++ b/include/audio/sample.h @@ -76,14 +76,14 @@ struct sample { * * \sa oshu::destroy_sample */ -int load_sample(const char *path, struct SDL_AudioSpec *spec, struct oshu::sample *sample); +int load_sample(const char *path, struct SDL_AudioSpec *spec, oshu::sample *sample); /** * Free the sample's PCM samples buffer. * * The sample object is left in an unspecified state. */ -void destroy_sample(struct oshu::sample *sample); +void destroy_sample(oshu::sample *sample); /** \} */ diff --git a/include/audio/stream.h b/include/audio/stream.h index 3450ec4..71ae67d 100644 --- a/include/audio/stream.h +++ b/include/audio/stream.h @@ -167,7 +167,7 @@ struct stream { * * \sa oshu::close_stream */ -int open_stream(const char *url, struct oshu::stream *stream); +int open_stream(const char *url, oshu::stream *stream); /** * Read *nb_samples* float samples from an audio stream. @@ -186,7 +186,7 @@ int open_stream(const char *url, struct oshu::stream *stream); * * \sa oshu::stream::finished */ -int read_stream(struct oshu::stream *stream, float *samples, int nb_samples); +int read_stream(oshu::stream *stream, float *samples, int nb_samples); /** * Seek the stream to the specifed target position in seconds. @@ -202,12 +202,12 @@ int read_stream(struct oshu::stream *stream, float *samples, int nb_samples); * There's often some kind of audio distortion glitch right after seeking. * */ -int seek_stream(struct oshu::stream *stream, double target); +int seek_stream(oshu::stream *stream, double target); /** * Close an audio stream, and free everything we can. */ -void close_stream(struct oshu::stream *stream); +void close_stream(oshu::stream *stream); /** \} */ diff --git a/include/audio/track.h b/include/audio/track.h index fe36a31..f9f1633 100644 --- a/include/audio/track.h +++ b/include/audio/track.h @@ -42,7 +42,7 @@ struct track { * This pointer is automatically reset to NULL when the sample is done * playing. */ - struct oshu::sample *sample; + oshu::sample *sample; /** * The position in the #sample buffer, in samples per channel. * @@ -71,7 +71,7 @@ struct track { * * \sa oshu::track */ -void start_track(struct oshu::track *track, struct oshu::sample *sample, float volume, int loop); +void start_track(oshu::track *track, oshu::sample *sample, float volume, int loop); /** * Stop the playback on a track. @@ -79,7 +79,7 @@ void start_track(struct oshu::track *track, struct oshu::sample *sample, float v * It gets useful when a sample is looping, as it wouldn't stop by itself * otherwise. */ -void stop_track(struct oshu::track *track); +void stop_track(oshu::track *track); /** * Mix a track on top of an audio stream. @@ -99,7 +99,7 @@ void stop_track(struct oshu::track *track); * when the stream is inactive, or less than *nb_samples* when the sample has * reached an end. */ -int mix_track(struct oshu::track *track, float *samples, int nb_samples); +int mix_track(oshu::track *track, float *samples, int nb_samples); /** \} */ diff --git a/include/beatmap/beatmap.h b/include/beatmap/beatmap.h index 36f80d6..e552009 100644 --- a/include/beatmap/beatmap.h +++ b/include/beatmap/beatmap.h @@ -148,7 +148,7 @@ struct color { double red; double green; double blue; - struct oshu::color *next; + oshu::color *next; }; /** @@ -230,7 +230,7 @@ struct timing_point { * * NULL for the last item. */ - struct oshu::timing_point *next; + oshu::timing_point *next; }; /** @@ -367,7 +367,7 @@ struct slider { /** * Path the slider follows. */ - struct oshu::path path; + oshu::path path; /** * > repeat (Integer) is the number of times a player will go over the * > slider. A value of 1 will not repeat, 2 will repeat once, 3 twice, @@ -399,7 +399,7 @@ struct slider { * have 2 sounds. For a repeating slider, it implies the sound for the * same circle will change every time it is repeated. */ - struct oshu::hit_sound *sounds; + oshu::hit_sound *sounds; }; /** @@ -485,14 +485,14 @@ struct hit { * * Sliders have some more sounds on the edges, don't forget them. */ - struct oshu::hit_sound sound; + oshu::hit_sound sound; /** * Type-specific properties. */ union { - struct oshu::slider slider; - struct oshu::spinner spinner; - struct oshu::hold_note hold_note; + oshu::slider slider; + oshu::spinner spinner; + oshu::hold_note hold_note; }; /** * \brief Timing point in effect when the hit object should be clicked. @@ -501,7 +501,7 @@ struct hit { * also be needed by the game or graphics module to handle the slider * ticks, using the #oshu::timing_point::beat_duration property. */ - struct oshu::timing_point *timing_point; + oshu::timing_point *timing_point; /** * \brief Combo identifier. * @@ -528,7 +528,7 @@ struct hit { * It's closely linked to #combo, and increases in the same way, taking * into account combo skips. */ - struct oshu::color *color; + oshu::color *color; /** * Dynamic state of the hit. Whether it was clicked or not. * @@ -544,19 +544,19 @@ struct hit { * \todo * The GUI module should manage its own texture cache. */ - struct oshu::texture *texture; + oshu::texture *texture; /** * Pointer to the previous element of the linked list. * * NULL if it's the first element. */ - struct oshu::hit *previous; + oshu::hit *previous; /** * Pointer to the next element of the linked list. * * NULL if it's the last element. */ - struct oshu::hit *next; + oshu::hit *next; }; /** @@ -565,7 +565,7 @@ struct hit { * For a circle, that's the same as #oshu::hit::time, but for a slider, spinner * or hold note, it's that offset plus the duration of the hit. */ -double hit_end_time(struct oshu::hit *hit); +double hit_end_time(oshu::hit *hit); /** * Compute the last point of a hit object. @@ -574,7 +574,7 @@ double hit_end_time(struct oshu::hit *hit); * the position at the end of the slide. If the slider repeats, it may be the * same as the starting point though. */ -oshu::point end_point(struct oshu::hit *hit); +oshu::point end_point(oshu::hit *hit); /** * \brief Complete definition of the [Metadata] section. @@ -863,11 +863,11 @@ struct beatmap { /** * \brief [Metadata] section. */ - struct oshu::metadata metadata; + oshu::metadata metadata; /** * \brief [Difficulty] section. */ - struct oshu::difficulty difficulty; + oshu::difficulty difficulty; /** * \brief Path to the background picture. * @@ -885,7 +885,7 @@ struct beatmap { * * It's a linked list, in chronological order. */ - struct oshu::timing_point *timing_points; + oshu::timing_point *timing_points; /** * \brief [Colours] section. * @@ -893,7 +893,7 @@ struct beatmap { * * \sa color_count */ - struct oshu::color *colors; + oshu::color *colors; /** * Number of colors in the #colors list. */ @@ -909,7 +909,7 @@ struct beatmap { * *next* and *previous* pointers. This lets you ensure your hit cursor * is never null. */ - struct oshu::hit *hits; + oshu::hit *hits; }; /** @@ -918,7 +918,7 @@ struct beatmap { * On failure, the content of *beatmap* is undefined, but any dynamically * allocated internal memory is freed. */ -int load_beatmap(const char *path, struct oshu::beatmap *beatmap); +int load_beatmap(const char *path, oshu::beatmap *beatmap); /** * Parse the first sections of a beatmap to get the metadata and difficulty @@ -939,12 +939,12 @@ int load_beatmap(const char *path, struct oshu::beatmap *beatmap); * timing points, colors, and hit objects, which contain most of the beatmap's * data. */ -int load_beatmap_headers(const char *path, struct oshu::beatmap *beatmap); +int load_beatmap_headers(const char *path, oshu::beatmap *beatmap); /** * Free any object dynamically allocated inside the beatmap. */ -void destroy_beatmap(struct oshu::beatmap *beatmap); +void destroy_beatmap(oshu::beatmap *beatmap); /** \} */ diff --git a/include/beatmap/path.h b/include/beatmap/path.h index fe45956..b9407d9 100644 --- a/include/beatmap/path.h +++ b/include/beatmap/path.h @@ -95,7 +95,7 @@ struct arc { * * \return 0 on success, -1 if the arc computation failed. */ -int build_arc(oshu::point a, oshu::point b, oshu::point c, struct oshu::arc *arc); +int build_arc(oshu::point a, oshu::point b, oshu::point c, oshu::arc *arc); /** * A Bézier path, made up of one or many Bézier segments. @@ -230,9 +230,9 @@ enum path_type { struct path { enum oshu::path_type type; union { - struct oshu::line line; /**< For #oshu::LINEAR_PATH. */ - struct oshu::arc arc; /**< For #oshu::PERFECT_PATH. */ - struct oshu::bezier bezier; /**< For #oshu::BEZIER_PATH. */ + oshu::line line; /**< For #oshu::LINEAR_PATH. */ + oshu::arc arc; /**< For #oshu::PERFECT_PATH. */ + oshu::bezier bezier; /**< For #oshu::BEZIER_PATH. */ }; }; @@ -246,7 +246,7 @@ struct path { * In most case, this function will shrink the path, because the actual length * is greater than the one specified in the beatmap. */ -void normalize_path(struct oshu::path *path, double length); +void normalize_path(oshu::path *path, double length); /** * Express the path in floating t-coordinates. @@ -286,7 +286,7 @@ void normalize_path(struct oshu::path *path, double length); * defined in the C standard library, by 2. * */ -oshu::point path_at(struct oshu::path *path, double t); +oshu::point path_at(oshu::path *path, double t); /** * Compute the smallest box such that the path fits in. @@ -300,7 +300,7 @@ oshu::point path_at(struct oshu::path *path, double t); * 2. ∀t imag(top_left) ≤ imag(at(t)) ≤ imag(bottom_right) * */ -void path_bounding_box(struct oshu::path *path, oshu::point *top_left, oshu::point *bottom_right); +void path_bounding_box(oshu::path *path, oshu::point *top_left, oshu::point *bottom_right); /** \} */ diff --git a/include/game/base.h b/include/game/base.h index 1314b0c..2c6ea86 100644 --- a/include/game/base.h +++ b/include/game/base.h @@ -64,10 +64,10 @@ class game_base : public game_mode { * \todo * Take the beatmap by reference when the game state is constructed. */ - struct oshu::beatmap beatmap {}; - struct oshu::audio audio {}; - struct oshu::sound_library library {}; - struct oshu::clock clock {}; + oshu::beatmap beatmap {}; + oshu::audio audio {}; + oshu::sound_library library {}; + oshu::clock clock {}; int autoplay {}; bool paused {}; /** @@ -89,7 +89,7 @@ class game_base : public game_mode { * With the two sentinels in the beatmap's hits linked list, this * cursor is never null, even after the last hit was played. */ - struct oshu::hit *hit_cursor {}; + oshu::hit *hit_cursor {}; }; /** @@ -112,14 +112,14 @@ class game_base : public game_mode { * * \sa oshu::look_hit_up */ -struct oshu::hit* look_hit_back(struct oshu::game_base *game, double offset); +oshu::hit* look_hit_back(oshu::game_base *game, double offset); /** * Find the last hit object before *now + offset*. * * This is analogous to #oshu::look_hit_back. */ -struct oshu::hit* look_hit_up(struct oshu::game_base *game, double offset); +oshu::hit* look_hit_up(oshu::game_base *game, double offset); /** * Return the next relevant hit. @@ -129,12 +129,12 @@ struct oshu::hit* look_hit_up(struct oshu::game_base *game, double offset); * The final null hit is considered relevant in order to ensure this function * always return something. */ -struct oshu::hit* next_hit(struct oshu::game_base *game); +oshu::hit* next_hit(oshu::game_base *game); /** * Like #oshu::next_hit, but in the other direction. */ -struct oshu::hit* previous_hit(struct oshu::game_base *game); +oshu::hit* previous_hit(oshu::game_base *game); /** \} */ diff --git a/include/game/clock.h b/include/game/clock.h index 3acc8bc..656def4 100644 --- a/include/game/clock.h +++ b/include/game/clock.h @@ -64,7 +64,7 @@ struct clock { double system; }; -void initialize_clock(struct oshu::game_base *game); +void initialize_clock(oshu::game_base *game); /** * Update the game clock. @@ -83,7 +83,7 @@ void initialize_clock(struct oshu::game_base *game); * lead-in phase, because the audio starts when the *now* clock becomes * positive, while the audio clock will be null at that moment. */ -void update_clock(struct oshu::game_base *game); +void update_clock(oshu::game_base *game); /** \} */ diff --git a/include/game/osu.h b/include/game/osu.h index 5d8abe8..4a3614d 100644 --- a/include/game/osu.h +++ b/include/game/osu.h @@ -29,7 +29,7 @@ struct osu_game : public oshu::game_base { * * NULL most of the time. */ - struct oshu::hit *current_slider {}; + oshu::hit *current_slider {}; /** * Keyboard key or mouse button associated to the #current_slider. * diff --git a/include/game/tty.h b/include/game/tty.h index fd095e8..1776517 100644 --- a/include/game/tty.h +++ b/include/game/tty.h @@ -37,7 +37,7 @@ class game_base; * * Show the beatmap's metadata and difficulty information. */ -void welcome(struct oshu::game_base *game); +void welcome(oshu::game_base *game); /** * Show the state of the game (paused/playing) and the current song position. @@ -49,14 +49,14 @@ void welcome(struct oshu::game_base *game); * glitches. If you write `foo\rx`, you get `xoo`. This is the reason the * Paused string literal has an extra space. */ -void print_state(struct oshu::game_base *game); +void print_state(oshu::game_base *game); /** * Congratulate the user when the beatmap is over. * * Show the number of good hits and bad hits. */ -void congratulate(struct oshu::game_base *game); +void congratulate(oshu::game_base *game); /** \} */ diff --git a/include/ui/audio.h b/include/ui/audio.h index 30cc566..b2a9fcf 100644 --- a/include/ui/audio.h +++ b/include/ui/audio.h @@ -30,8 +30,8 @@ struct stream; * \sa oshu::show_audio_progress_bar */ struct audio_progress_bar { - struct oshu::display *display; - struct oshu::stream *stream; + oshu::display *display; + oshu::stream *stream; }; /** @@ -41,12 +41,12 @@ struct audio_progress_bar { * * The stream must have a non-zero duration. */ -int create_audio_progress_bar(struct oshu::display *display, struct oshu::stream *stream, struct oshu::audio_progress_bar *bar); +int create_audio_progress_bar(oshu::display *display, oshu::stream *stream, oshu::audio_progress_bar *bar); /** * Display the progress bar at the bottom of the screen. */ -void show_audio_progress_bar(struct oshu::audio_progress_bar *bar); +void show_audio_progress_bar(oshu::audio_progress_bar *bar); /** * Destroy an audio progress bar. @@ -54,7 +54,7 @@ void show_audio_progress_bar(struct oshu::audio_progress_bar *bar); * Today, this is a no-op. It is still provided for interface consistency with * the other widgets. */ -void destroy_audio_progress_bar(struct oshu::audio_progress_bar *bar); +void destroy_audio_progress_bar(oshu::audio_progress_bar *bar); /** \} */ diff --git a/include/ui/background.h b/include/ui/background.h index 99c55d6..ff99f88 100644 --- a/include/ui/background.h +++ b/include/ui/background.h @@ -44,7 +44,7 @@ struct background { * \todo * Implement the #oshu::SHOW_BACKGROUND flag. */ - struct oshu::display *display; + oshu::display *display; /** * The background picture. * @@ -57,7 +57,7 @@ struct background { * When no texture is loaded, #oshu::show_background is a no-op, so you * can safely assume the background is a valid object. */ - struct oshu::texture picture; + oshu::texture picture; }; /** @@ -76,7 +76,7 @@ struct background { * because the pre-scale algorithm is fancier than that, thanks to cairo. * */ -int load_background(struct oshu::display *display, const char *filename, struct oshu::background *background); +int load_background(oshu::display *display, const char *filename, oshu::background *background); /** * Display the background such that it fills the whole screen. @@ -97,12 +97,12 @@ int load_background(struct oshu::display *display, const char *filename, struct * You may use #oshu::trapezium for the brightness to implement a fading-in * fading-out effect. */ -void show_background(struct oshu::background *background, double brightness); +void show_background(oshu::background *background, double brightness); /** * Free the background picture. */ -void destroy_background(struct oshu::background *background); +void destroy_background(oshu::background *background); /** \} */ diff --git a/include/ui/cursor.h b/include/ui/cursor.h index 856b268..b7c3453 100644 --- a/include/ui/cursor.h +++ b/include/ui/cursor.h @@ -32,7 +32,7 @@ struct cursor_widget { * It is used both to retrieve the mouse position, and to render the * cursor. */ - struct oshu::display *display; + oshu::display *display; /** * Keep track of the previous positions of the mouse to display a * fancier cursor, with a trail. @@ -51,7 +51,7 @@ struct cursor_widget { * It's a white disc, which is scaled and whose opacity is adjusted for * the main cursor and all the trailing particles. */ - struct oshu::texture mouse; + oshu::texture mouse; }; /** @@ -59,7 +59,7 @@ struct cursor_widget { * * You must free the cursor with #oshu::destroy_cursor. */ -int create_cursor(struct oshu::display *display, struct oshu::cursor_widget *cursor); +int create_cursor(oshu::display *display, oshu::cursor_widget *cursor); /** * Render the cursor on the display it was created on. @@ -71,7 +71,7 @@ int create_cursor(struct oshu::display *display, struct oshu::cursor_widget *cur * Every call to this function update the mouse position history, affecting the * cursor trail. */ -void show_cursor(struct oshu::cursor_widget *cursor); +void show_cursor(oshu::cursor_widget *cursor); /** * Free the cursor's texture. @@ -79,7 +79,7 @@ void show_cursor(struct oshu::cursor_widget *cursor); * It is safe to call this function on a destroyed cursor, or on a * zero-initialized cursor. */ -void destroy_cursor(struct oshu::cursor_widget *cursor); +void destroy_cursor(oshu::cursor_widget *cursor); /** \} */ diff --git a/include/ui/metadata.h b/include/ui/metadata.h index 7a97619..492dc02 100644 --- a/include/ui/metadata.h +++ b/include/ui/metadata.h @@ -34,11 +34,11 @@ struct metadata_frame { /** * The display storing the textures. */ - struct oshu::display *display; + oshu::display *display; /** * The metadata source. */ - struct oshu::beatmap *beatmap; + oshu::beatmap *beatmap; /** * The clock points to an ever-increasing continuous time value, in * seconds. The game clock's #oshu::clock::system is a good fit for this @@ -55,21 +55,21 @@ struct metadata_frame { * 2 lines of text: the first with the title, the second with the * artist name. */ - struct oshu::texture ascii; + oshu::texture ascii; /** * Unicode variant of #ascii. * * When the Unicode metadata is missing, or identical to the ASCII * ones, this texture is left null. */ - struct oshu::texture unicode; + oshu::texture unicode; /** * Show difficulty information. * * The first line is the #oshu::metadata::version, and the second the * difficulty value in stars. */ - struct oshu::texture stars; + oshu::texture stars; }; /** @@ -81,7 +81,7 @@ struct metadata_frame { * * When done, please destroy the frame with #oshu::destroy_metadata_frame. */ -int create_metadata_frame(struct oshu::display *display, struct oshu::beatmap *beatmap, double *clock, struct oshu::metadata_frame *frame); +int create_metadata_frame(oshu::display *display, oshu::beatmap *beatmap, double *clock, oshu::metadata_frame *frame); /** * Display the metadata frame on the configured display with the given opacity. @@ -95,12 +95,12 @@ int create_metadata_frame(struct oshu::display *display, struct oshu::beatmap *b * Every 3.5 second, the display is switched between Unicode and ASCII, with a * 0.2-second fade transititon. */ -void show_metadata_frame(struct oshu::metadata_frame *frame, double opacity); +void show_metadata_frame(oshu::metadata_frame *frame, double opacity); /** * Free the allocated textures. */ -void destroy_metadata_frame(struct oshu::metadata_frame *frame); +void destroy_metadata_frame(oshu::metadata_frame *frame); /** \} */ diff --git a/include/ui/osu.h b/include/ui/osu.h index 6b03fe6..729adc9 100644 --- a/include/ui/osu.h +++ b/include/ui/osu.h @@ -44,56 +44,56 @@ struct osu_ui : public widget { * * There are as many textures as there are colors in the beatmap. */ - struct oshu::texture *circles {}; + oshu::texture *circles {}; /** * Full-size approach circle. * * Its size is the `radius + approach_size` from the beatmap. */ - struct oshu::texture approach_circle {}; + oshu::texture approach_circle {}; /** * The slider ball and its tolerance circle. */ - struct oshu::texture slider_ball {}; + oshu::texture slider_ball {}; /** * Symbol to indicate a note was successfully hit. * * A green circle. */ - struct oshu::texture good_mark {}; + oshu::texture good_mark {}; /** * Symbol for early hits. * * A yellow half-circle, on the left. */ - struct oshu::texture early_mark {}; + oshu::texture early_mark {}; /** * Symbol for early hits. * * A yellow half-circle, on the right. */ - struct oshu::texture late_mark {}; + oshu::texture late_mark {}; /** * Symbol to indicate a note was missed. * * A red X. */ - struct oshu::texture bad_mark {}; + oshu::texture bad_mark {}; /** * Symbol to indicate a note was skipped. * * A blue triangle pointing right. */ - struct oshu::texture skip_mark {}; + oshu::texture skip_mark {}; /** * Little tick mark for the dotted line between two consecutive hits. */ - struct oshu::texture connector {}; + oshu::texture connector {}; /** * Use a fancy software cursor for the osu!standard mode, because the * mouse is a central part of the gameplay. */ - struct oshu::cursor_widget cursor {}; + oshu::cursor_widget cursor {}; }; /** @@ -116,7 +116,7 @@ int osu_paint_resources(oshu::osu_ui&); * * Slider textures are freed with #oshu::osu_free_resources. */ -int osu_paint_slider(oshu::osu_ui&, struct oshu::hit *hit); +int osu_paint_slider(oshu::osu_ui&, oshu::hit *hit); /** * Free the dynamic resources of the game mode. @@ -132,7 +132,7 @@ void osu_free_resources(oshu::osu_ui&); * It is the caller's responsibility to reset the view, preferably such that * the #oshu::osu_view/#oshu::reset_view pairing looks obvious. */ -void osu_view(struct oshu::display *display); +void osu_view(oshu::display *display); /** \} */ diff --git a/include/ui/score.h b/include/ui/score.h index c9ec247..b907e02 100644 --- a/include/ui/score.h +++ b/include/ui/score.h @@ -24,8 +24,8 @@ struct display; */ struct score_frame { - struct oshu::display *display; - struct oshu::beatmap *beatmap; + oshu::display *display; + oshu::beatmap *beatmap; int good; int bad; }; @@ -38,7 +38,7 @@ struct score_frame { * Maybe in a future version, this widget could be permanently shown and * updated on every action. */ -int create_score_frame(struct oshu::display *display, struct oshu::beatmap *beatmap, struct oshu::score_frame *frame); +int create_score_frame(oshu::display *display, oshu::beatmap *beatmap, oshu::score_frame *frame); /** * Show the score frame. @@ -47,14 +47,14 @@ int create_score_frame(struct oshu::display *display, struct oshu::beatmap *beat * * The opacity argument lets you fade in the bar with #oshu::fade_in. */ -void show_score_frame(struct oshu::score_frame *frame, double opacity); +void show_score_frame(oshu::score_frame *frame, double opacity); /** * Destroy a score frame. * * In fact, it does nothing, but is there for consistency. */ -void destroy_score_frame(struct oshu::score_frame *frame); +void destroy_score_frame(oshu::score_frame *frame); /** \} */ diff --git a/include/video/display.h b/include/video/display.h index d94a546..10ab640 100644 --- a/include/video/display.h +++ b/include/video/display.h @@ -169,7 +169,7 @@ struct display { * When the window is resized, make sure you reset it with * #oshu::reset_view and recreate your view from it. */ - struct oshu::view view; + oshu::view view; /** * Bitmap of visual features, defined in #oshu::visual_feature. * diff --git a/include/video/paint.h b/include/video/paint.h index e773c1a..236d740 100644 --- a/include/video/paint.h +++ b/include/video/paint.h @@ -33,8 +33,8 @@ struct texture; * upload the texture with #oshu::finish_painting. * * ```c - * struct oshu::texture t; - * struct oshu::painter p; + * oshu::texture t; + * oshu::painter p; * oshu::start_painting(128 + 128 * I, 64 + 64 * I, &p); * // call cairo with p->cr * oshu::finish_painting(&p, display, &t); @@ -46,7 +46,7 @@ struct texture; */ struct painter { - struct oshu::display *display; + oshu::display *display; oshu::size size; struct SDL_Surface *destination; cairo_surface_t *surface; @@ -73,7 +73,7 @@ struct painter { * * The painter object needs not be initialized before calling this function. */ -int start_painting(struct oshu::display *display, oshu::size size, struct oshu::painter *painter); +int start_painting(oshu::display *display, oshu::size size, oshu::painter *painter); /** * Load the drawn texture onto the GPU as a texture, and free everything else. @@ -86,7 +86,7 @@ int start_painting(struct oshu::display *display, oshu::size size, struct oshu:: * * You must destroy the texture later with #oshu::destroy_texture. */ -int finish_painting(struct oshu::painter *painter, struct oshu::texture *texture); +int finish_painting(oshu::painter *painter, oshu::texture *texture); /** \} */ diff --git a/include/video/texture.h b/include/video/texture.h index a340efa..750b454 100644 --- a/include/video/texture.h +++ b/include/video/texture.h @@ -92,7 +92,7 @@ struct texture { * * Log an error and return -1 on failure. */ -int load_texture(struct oshu::display *display, const char *filename, struct oshu::texture *texture); +int load_texture(oshu::display *display, const char *filename, oshu::texture *texture); /** * Destroy an SDL texture with `SDL_DestroyTexture`. @@ -103,7 +103,7 @@ int load_texture(struct oshu::display *display, const char *filename, struct osh * It is safe to destroy a texture more than once, or destroy a * null-initialized texture object. */ -void destroy_texture(struct oshu::texture *texture); +void destroy_texture(oshu::texture *texture); /** * Draw a texture at the specified position. @@ -114,7 +114,7 @@ void destroy_texture(struct oshu::texture *texture); * The logical size of the texture is preserved, according to the display's * current view. */ -void draw_texture(struct oshu::display *display, struct oshu::texture *texture, oshu::point p); +void draw_texture(oshu::display *display, oshu::texture *texture, oshu::point p); /** * Draw a texture with a customizable scale factor. @@ -126,7 +126,7 @@ void draw_texture(struct oshu::display *display, struct oshu::texture *texture, * The texture is scaled relative to its origin, preserving the property that * *p* always represents the same texture pixel (the origin), for any ratio. */ -void draw_scaled_texture(struct oshu::display *display, struct oshu::texture *texture, oshu::point p, double ratio); +void draw_scaled_texture(oshu::display *display, oshu::texture *texture, oshu::point p, double ratio); /** \} */ diff --git a/include/video/view.h b/include/video/view.h index f3449f8..ac362b3 100644 --- a/include/video/view.h +++ b/include/video/view.h @@ -144,7 +144,7 @@ struct view { * - `v(logical width / 2) = physical width / 2` * */ -void resize_view(struct oshu::view *view, oshu::size size); +void resize_view(oshu::view *view, oshu::size size); /** * Scale the coordinate system. @@ -164,7 +164,7 @@ void resize_view(struct oshu::view *view, oshu::size size); * - `v(logical width) = physical width` * */ -void scale_view(struct oshu::view *view, double factor); +void scale_view(oshu::view *view, double factor); /** * Scale and resize the view while preserving the aspect ratio. @@ -178,7 +178,7 @@ void scale_view(struct oshu::view *view, double factor); * - The view is not cut: * `0 ≤ v(0) ≤ v(logical width) ≤ physical width` */ -void fit_view(struct oshu::view *view, oshu::size size); +void fit_view(oshu::view *view, oshu::size size); /** * Reset the display's view to the identity view. @@ -187,7 +187,7 @@ void fit_view(struct oshu::view *view, oshu::size size); * * The resulting view is stored in the display's #oshu::display::view attribute. */ -void reset_view(struct oshu::display *display); +void reset_view(oshu::display *display); /** * Project a point from logical coordinates to physical coordinates. @@ -196,7 +196,7 @@ void reset_view(struct oshu::display *display); * * \sa oshu::unproject */ -oshu::point project(struct oshu::view *view, oshu::point p); +oshu::point project(oshu::view *view, oshu::point p); /** * Unproject a point from physical coordinates to logical coordinates. @@ -206,7 +206,7 @@ oshu::point project(struct oshu::view *view, oshu::point p); * From the definition of the view, `v(p) = z p + o`, * we deduce `p = (v(p) - o) / z`. */ -oshu::point unproject(struct oshu::view *view, oshu::point p); +oshu::point unproject(oshu::view *view, oshu::point p); /** \} */ diff --git a/lib/audio/audio.cc b/lib/audio/audio.cc index aa1bf5e..6bfdf00 100644 --- a/lib/audio/audio.cc +++ b/lib/audio/audio.cc @@ -52,8 +52,8 @@ static void clip(float *samples, int nb_samples, int channels) */ static void audio_callback(void *userdata, Uint8 *buffer, int len) { - struct oshu::audio *audio; - audio = (struct oshu::audio*) userdata; + oshu::audio *audio; + audio = (oshu::audio*) userdata; int unit = audio->device_spec.channels * sizeof(float); assert (len % unit == 0); int nb_samples = len / unit; @@ -80,7 +80,7 @@ static void audio_callback(void *userdata, Uint8 *buffer, int len) * Initialize the SDL audio device. * \return 0 on success, -1 on error. */ -static int open_device(struct oshu::audio *audio) +static int open_device(oshu::audio *audio) { SDL_AudioSpec want; SDL_zero(want); @@ -101,7 +101,7 @@ static int open_device(struct oshu::audio *audio) return 0; } -int oshu::open_audio(const char *url, struct oshu::audio *audio) +int oshu::open_audio(const char *url, oshu::audio *audio) { assert (sizeof(float) == 4); if (oshu::open_stream(url, &audio->music) < 0) @@ -114,17 +114,17 @@ int oshu::open_audio(const char *url, struct oshu::audio *audio) return -1; } -void oshu::play_audio(struct oshu::audio *audio) +void oshu::play_audio(oshu::audio *audio) { SDL_PauseAudioDevice(audio->device_id, 0); } -void oshu::pause_audio(struct oshu::audio *audio) +void oshu::pause_audio(oshu::audio *audio) { SDL_PauseAudioDevice(audio->device_id, 1); } -void oshu::close_audio(struct oshu::audio *audio) +void oshu::close_audio(oshu::audio *audio) { if (audio->device_id) SDL_CloseAudioDevice(audio->device_id); @@ -141,13 +141,13 @@ void oshu::close_audio(struct oshu::audio *audio) * Make sure you lock the audio device when calling this function, in order to * ensure predictable results. */ -static struct oshu::track *select_track(struct oshu::audio *audio) +static oshu::track *select_track(oshu::audio *audio) { int max_cursor = 0; - struct oshu::track *best_track = &audio->effects[0]; + oshu::track *best_track = &audio->effects[0]; int tracks = sizeof(audio->effects) / sizeof(*audio->effects); for (int i = 0; i < tracks; ++i) { - struct oshu::track *c = &audio->effects[i]; + oshu::track *c = &audio->effects[i]; if (c->sample == NULL) { return c; } else if (c->cursor > max_cursor) { @@ -158,31 +158,31 @@ static struct oshu::track *select_track(struct oshu::audio *audio) return best_track; } -void oshu::play_sample(struct oshu::audio *audio, struct oshu::sample *sample, float volume) +void oshu::play_sample(oshu::audio *audio, oshu::sample *sample, float volume) { SDL_LockAudioDevice(audio->device_id); - struct oshu::track *track = select_track(audio); + oshu::track *track = select_track(audio); if (track->sample != NULL) oshu_log_debug("all the effect tracks are taken, stealing one"); oshu::start_track(track, sample, volume, 0); SDL_UnlockAudioDevice(audio->device_id); } -void oshu::play_loop(struct oshu::audio *audio, struct oshu::sample *sample, float volume) +void oshu::play_loop(oshu::audio *audio, oshu::sample *sample, float volume) { SDL_LockAudioDevice(audio->device_id); oshu::start_track(&audio->looping, sample, volume, 1); SDL_UnlockAudioDevice(audio->device_id); } -void oshu::stop_loop(struct oshu::audio *audio) +void oshu::stop_loop(oshu::audio *audio) { SDL_LockAudioDevice(audio->device_id); oshu::stop_track(&audio->looping); SDL_UnlockAudioDevice(audio->device_id); } -int oshu::seek_music(struct oshu::audio *audio, double target) +int oshu::seek_music(oshu::audio *audio, double target) { SDL_LockAudioDevice(audio->device_id); int rc = oshu::seek_stream(&audio->music, target); diff --git a/lib/audio/library.cc b/lib/audio/library.cc index 23db7aa..ef8f5f8 100644 --- a/lib/audio/library.cc +++ b/lib/audio/library.cc @@ -46,14 +46,14 @@ static std::string skin_directory() return OSHU_SKINS_DIRECTORY "/" OSHU_DEFAULT_SKIN; } -void oshu::open_sound_library(struct oshu::sound_library *library, struct SDL_AudioSpec *format) +void oshu::open_sound_library(oshu::sound_library *library, struct SDL_AudioSpec *format) { library->skin_directory = skin_directory(); oshu_log_debug("using skin directory %s", library->skin_directory.c_str()); library->format = format; } -static void free_sample(struct oshu::sample **sample) +static void free_sample(oshu::sample **sample) { if (*sample) { oshu::destroy_sample(*sample); @@ -62,7 +62,7 @@ static void free_sample(struct oshu::sample **sample) } } -static void free_shelf(struct oshu::sound_shelf *shelf) +static void free_shelf(oshu::sound_shelf *shelf) { free_sample(&shelf->hit_normal); free_sample(&shelf->hit_whistle); @@ -72,7 +72,7 @@ static void free_shelf(struct oshu::sound_shelf *shelf) free_sample(&shelf->slider_whistle); } -static void free_room(struct oshu::sound_room *room) +static void free_room(oshu::sound_room *room) { if (room->shelves) { for (int i = 0; i < room->size; ++i) @@ -84,7 +84,7 @@ static void free_room(struct oshu::sound_room *room) room->indices = NULL; } -void oshu::close_sound_library(struct oshu::sound_library *library) +void oshu::close_sound_library(oshu::sound_library *library) { free_room(&library->normal); free_room(&library->soft); @@ -96,7 +96,7 @@ void oshu::close_sound_library(struct oshu::sound_library *library) * * Return NULL if the shelf wasn't found. */ -static struct oshu::sound_shelf* find_shelf(struct oshu::sound_room *room, int index) +static oshu::sound_shelf* find_shelf(oshu::sound_room *room, int index) { for (int i = 0; i < room->size; ++i) { if (room->indices[i] == index) @@ -114,7 +114,7 @@ static struct oshu::sound_shelf* find_shelf(struct oshu::sound_room *room, int i * After calling this function, you are guaranteed that there is the capacity * for at least one new shelf (i.e. `room->size < room->capacity`). */ -static void grow_room(struct oshu::sound_room *room) +static void grow_room(oshu::sound_room *room) { assert (room->size <= room->capacity); if (room->size < room->capacity) @@ -131,7 +131,7 @@ static void grow_room(struct oshu::sound_room *room) * * Return the pointer to the new shelf. */ -static struct oshu::sound_shelf* new_shelf(struct oshu::sound_room *room, int index) +static oshu::sound_shelf* new_shelf(oshu::sound_room *room, int index) { grow_room(room); int position = room->size++; @@ -145,7 +145,7 @@ static struct oshu::sound_shelf* new_shelf(struct oshu::sound_room *room, int in * * If the room wasnn't found, return NULL. */ -static struct oshu::sound_room* get_room(struct oshu::sound_library *library, enum oshu::sample_set_family set) +static oshu::sound_room* get_room(oshu::sound_library *library, enum oshu::sample_set_family set) { switch (set) { case oshu::NORMAL_SAMPLE_SET: return &library->normal; @@ -162,7 +162,7 @@ static struct oshu::sound_room* get_room(struct oshu::sound_library *library, en * * If the sample wasnn't found because its type doesn't exist, return NULL. */ -static struct oshu::sample** get_sample(struct oshu::sound_shelf *shelf, int type) +static oshu::sample** get_sample(oshu::sound_shelf *shelf, int type) { switch (type) { case oshu::HIT_SOUND|oshu::NORMAL_SOUND: return &shelf->hit_normal; @@ -247,17 +247,17 @@ static std::string locate_sample(oshu::sound_library *library, enum oshu::sample return {}; } -int oshu::register_sample(struct oshu::sound_library *library, enum oshu::sample_set_family set, int index, int type) +int oshu::register_sample(oshu::sound_library *library, enum oshu::sample_set_family set, int index, int type) { - struct oshu::sound_room *room = get_room(library, set); + oshu::sound_room *room = get_room(library, set); if (!room) return -1; - struct oshu::sound_shelf *shelf = find_shelf(room, index); + oshu::sound_shelf *shelf = find_shelf(room, index); if (!shelf) shelf = new_shelf(room, index); if (!shelf) return -1; - struct oshu::sample **sample = get_sample(shelf, type); + oshu::sample **sample = get_sample(shelf, type); if (!sample) return -1; if (*sample) /* already loaded */ @@ -275,7 +275,7 @@ int oshu::register_sample(struct oshu::sound_library *library, enum oshu::sample return 0; } -void oshu::register_sound(struct oshu::sound_library *library, struct oshu::hit_sound *sound) +void oshu::register_sound(oshu::sound_library *library, oshu::hit_sound *sound) { int target = sound->additions & oshu::SOUND_TARGET; if (sound->additions & oshu::NORMAL_SOUND) @@ -288,7 +288,7 @@ void oshu::register_sound(struct oshu::sound_library *library, struct oshu::hit_ oshu::register_sample(library, sound->additions_set, sound->index, target | oshu::CLAP_SOUND); } -static void populate_default(struct oshu::sound_library *library, enum oshu::sample_set_family set) +static void populate_default(oshu::sound_library *library, enum oshu::sample_set_family set) { oshu::register_sample(library, set, oshu::DEFAULT_SHELF, oshu::HIT_SOUND|oshu::NORMAL_SOUND); oshu::register_sample(library, set, oshu::DEFAULT_SHELF, oshu::HIT_SOUND|oshu::WHISTLE_SOUND); @@ -298,14 +298,14 @@ static void populate_default(struct oshu::sound_library *library, enum oshu::sam oshu::register_sample(library, set, oshu::DEFAULT_SHELF, oshu::SLIDER_SOUND|oshu::WHISTLE_SOUND); } -void oshu::populate_library(struct oshu::sound_library *library, struct oshu::beatmap *beatmap) +void oshu::populate_library(oshu::sound_library *library, oshu::beatmap *beatmap) { int start = SDL_GetTicks(); oshu_log_debug("loading the sample library"); populate_default(library, oshu::NORMAL_SAMPLE_SET); populate_default(library, oshu::SOFT_SAMPLE_SET); populate_default(library, oshu::DRUM_SAMPLE_SET); - for (struct oshu::hit *hit = beatmap->hits; hit; hit = hit->next) { + for (oshu::hit *hit = beatmap->hits; hit; hit = hit->next) { if (hit->type & oshu::SLIDER_HIT) { for (int i = 0; i <= hit->slider.repeat; ++i) oshu::register_sound(library, &hit->slider.sounds[i]); @@ -324,13 +324,13 @@ void oshu::populate_library(struct oshu::sound_library *library, struct oshu::be * * \sa oshu::play_sound */ -struct oshu::sample* find_sample(struct oshu::sound_library *library, enum oshu::sample_set_family set, int index, int type) +oshu::sample* find_sample(oshu::sound_library *library, enum oshu::sample_set_family set, int index, int type) { - struct oshu::sample **sample {nullptr}; - struct oshu::sound_room *room = get_room(library, set); + oshu::sample **sample {nullptr}; + oshu::sound_room *room = get_room(library, set); if (!room) return NULL; - struct oshu::sound_shelf *shelf = find_shelf(room, index); + oshu::sound_shelf *shelf = find_shelf(room, index); if (!shelf) goto round2; sample = get_sample(shelf, type); @@ -346,12 +346,12 @@ struct oshu::sample* find_sample(struct oshu::sound_library *library, enum oshu: return *sample; } -static void try_sound(struct oshu::sound_library *library, struct oshu::hit_sound *sound, struct oshu::audio *audio, enum oshu::sound_type flag) +static void try_sound(oshu::sound_library *library, oshu::hit_sound *sound, oshu::audio *audio, enum oshu::sound_type flag) { if (sound->additions & flag) { int target = sound->additions & oshu::SOUND_TARGET; oshu::sample_set_family set = (flag == oshu::NORMAL_SOUND) ? sound->sample_set : sound->additions_set; - struct oshu::sample *sample = find_sample(library, set, sound->index, target | flag); + oshu::sample *sample = find_sample(library, set, sound->index, target | flag); if (!sample) return; else if (sound->additions & oshu::SLIDER_SOUND) @@ -361,7 +361,7 @@ static void try_sound(struct oshu::sound_library *library, struct oshu::hit_soun } } -void oshu::play_sound(struct oshu::sound_library *library, struct oshu::hit_sound *sound, struct oshu::audio *audio) +void oshu::play_sound(oshu::sound_library *library, oshu::hit_sound *sound, oshu::audio *audio) { try_sound(library, sound, audio, oshu::NORMAL_SOUND); try_sound(library, sound, audio, oshu::WHISTLE_SOUND); diff --git a/lib/audio/sample.cc b/lib/audio/sample.cc index c2615a1..7979e45 100644 --- a/lib/audio/sample.cc +++ b/lib/audio/sample.cc @@ -19,7 +19,7 @@ static const int channels = 2; * * Trust me, your ears don't want you to overlap two incompatible streams. */ -static int convert_audio(SDL_AudioSpec *device_spec, SDL_AudioSpec *wav_spec, struct oshu::sample *sample) +static int convert_audio(SDL_AudioSpec *device_spec, SDL_AudioSpec *wav_spec, oshu::sample *sample) { SDL_AudioCVT converter; int rc = SDL_BuildAudioCVT(&converter, @@ -51,7 +51,7 @@ static int convert_audio(SDL_AudioSpec *device_spec, SDL_AudioSpec *wav_spec, st return 0; } -int oshu::load_sample(const char *path, SDL_AudioSpec *spec, struct oshu::sample *sample) +int oshu::load_sample(const char *path, SDL_AudioSpec *spec, oshu::sample *sample) { assert (spec->format == AUDIO_F32); assert (spec->channels == channels); @@ -70,7 +70,7 @@ int oshu::load_sample(const char *path, SDL_AudioSpec *spec, struct oshu::sample return -1; } -void oshu::destroy_sample(struct oshu::sample *sample) +void oshu::destroy_sample(oshu::sample *sample) { if (sample->samples) { SDL_FreeWAV((Uint8*) sample->samples); diff --git a/lib/audio/stream.cc b/lib/audio/stream.cc index 10c7c0a..0fee980 100644 --- a/lib/audio/stream.cc +++ b/lib/audio/stream.cc @@ -41,7 +41,7 @@ static void log_av_error(int rc) * * \return 0 on success, -1 on error. */ -static int next_page(struct oshu::stream *stream) +static int next_page(oshu::stream *stream) { int rc; AVPacket packet; @@ -74,7 +74,7 @@ static int next_page(struct oshu::stream *stream) * When the end of file is reached, or when an error occurs, set * #oshu::stream::finished to true. */ -static int next_frame(struct oshu::stream *stream) +static int next_frame(oshu::stream *stream) { for (;;) { int rc = avcodec_receive_frame(stream->decoder, stream->frame); @@ -134,7 +134,7 @@ static int convert_frame(struct SwrContext *converter, AVFrame *frame, int index return rc; } -int oshu::read_stream(struct oshu::stream *stream, float *samples, int nb_samples) +int oshu::read_stream(oshu::stream *stream, float *samples, int nb_samples) { int left = nb_samples; while (left > 0 && !stream->finished) { @@ -158,7 +158,7 @@ int oshu::read_stream(struct oshu::stream *stream, float *samples, int nb_sample * Log some helpful information about the decoded audio stream. * Meant for debugging more than anything else. */ -static void dump_stream_info(struct oshu::stream *stream) +static void dump_stream_info(oshu::stream *stream) { oshu_log_info("============ Audio information ============"); oshu_log_info(" Codec: %s.", stream->codec->long_name); @@ -176,7 +176,7 @@ static void dump_stream_info(struct oshu::stream *stream) * * \return 0 on success, -1 on error. */ -static int open_demuxer(const char *url, struct oshu::stream *stream) +static int open_demuxer(const char *url, oshu::stream *stream) { int rc = avformat_open_input(&stream->demuxer, url, NULL, NULL); if (rc < 0) { @@ -215,7 +215,7 @@ static int open_demuxer(const char *url, struct oshu::stream *stream) * * \return 0 on success, and a negative ffmpeg error code on failure. */ -static int open_decoder(struct oshu::stream *stream) +static int open_decoder(oshu::stream *stream) { stream->decoder = avcodec_alloc_context3(stream->codec); int rc = avcodec_parameters_to_context( @@ -250,7 +250,7 @@ static int open_decoder(struct oshu::stream *stream) * * The output sample rate must be defined in #oshu::stream::sample_rate. */ -static int open_converter(struct oshu::stream *stream) +static int open_converter(oshu::stream *stream) { assert (channels == 2); stream->converter = swr_alloc_set_opts( @@ -278,7 +278,7 @@ static int open_converter(struct oshu::stream *stream) return 0; } -int oshu::open_stream(const char *url, struct oshu::stream *stream) +int oshu::open_stream(const char *url, oshu::stream *stream) { /* * av_register_all() got deprecated in lavf 58.9.100 @@ -305,7 +305,7 @@ int oshu::open_stream(const char *url, struct oshu::stream *stream) return -1; } -void oshu::close_stream(struct oshu::stream *stream) +void oshu::close_stream(oshu::stream *stream) { /* the av routines set the pointers to NULL */ if (stream->frame) @@ -318,7 +318,7 @@ void oshu::close_stream(struct oshu::stream *stream) swr_free(&stream->converter); } -int oshu::seek_stream(struct oshu::stream *stream, double target) +int oshu::seek_stream(oshu::stream *stream, double target) { if (target < 0.) { target = 0.; diff --git a/lib/audio/track.cc b/lib/audio/track.cc index bba9e70..7d4c0d0 100644 --- a/lib/audio/track.cc +++ b/lib/audio/track.cc @@ -13,7 +13,7 @@ /** Work in stereo. */ static const int channels = 2; -void oshu::start_track(struct oshu::track *track, struct oshu::sample *sample, float volume, int loop) +void oshu::start_track(oshu::track *track, oshu::sample *sample, float volume, int loop) { if (sample && sample->nb_samples == 0) sample = NULL; @@ -23,12 +23,12 @@ void oshu::start_track(struct oshu::track *track, struct oshu::sample *sample, f track->loop = loop; } -void oshu::stop_track(struct oshu::track *track) +void oshu::stop_track(oshu::track *track) { track->sample = NULL; } -int oshu::mix_track(struct oshu::track *track, float *samples, int nb_samples) +int oshu::mix_track(oshu::track *track, float *samples, int nb_samples) { int wanted = nb_samples; while (wanted > 0 && track->sample) { diff --git a/lib/beatmap/helpers.cc b/lib/beatmap/helpers.cc index 0b39dac..dc9185a 100644 --- a/lib/beatmap/helpers.cc +++ b/lib/beatmap/helpers.cc @@ -8,7 +8,7 @@ #include "beatmap/beatmap.h" -double oshu::hit_end_time(struct oshu::hit *hit) +double oshu::hit_end_time(oshu::hit *hit) { if (hit->type & oshu::SLIDER_HIT) return hit->time + hit->slider.duration * hit->slider.repeat; @@ -16,7 +16,7 @@ double oshu::hit_end_time(struct oshu::hit *hit) return hit->time; } -oshu::point oshu::end_point(struct oshu::hit *hit) +oshu::point oshu::end_point(oshu::hit *hit) { if (hit->type & oshu::SLIDER_HIT) return oshu::path_at(&hit->slider.path, hit->slider.repeat); diff --git a/lib/beatmap/parser.cc b/lib/beatmap/parser.cc index 7867dfb..eb80416 100644 --- a/lib/beatmap/parser.cc +++ b/lib/beatmap/parser.cc @@ -27,7 +27,7 @@ static const char *osu_file_header = "osu file format v"; * This is especially handy for the difficulty section where many values are * not 0 by default. */ -static const struct oshu::beatmap default_beatmap = { +static const oshu::beatmap default_beatmap = { .version = 0, .audio_filename = nullptr, .audio_lead_in = 0, @@ -404,7 +404,7 @@ static int process_section(struct parser_state *parser) static int process_general(struct parser_state *parser) { - struct oshu::beatmap *beatmap = parser->beatmap; + oshu::beatmap *beatmap = parser->beatmap; int rc; enum token key; int i; @@ -503,7 +503,7 @@ static int parse_sample_set(struct parser_state *parser, enum oshu::sample_set_f static int process_metadata(struct parser_state *parser) { - struct oshu::metadata *meta = &parser->beatmap->metadata; + oshu::metadata *meta = &parser->beatmap->metadata; enum token key; if (parse_key(parser, &key) < 0) return -1; @@ -528,7 +528,7 @@ static int process_metadata(struct parser_state *parser) static int process_difficulty(struct parser_state *parser) { - struct oshu::difficulty *difficulty = &parser->beatmap->difficulty; + oshu::difficulty *difficulty = &parser->beatmap->difficulty; enum token key; double value; if (parse_key(parser, &key) < 0) @@ -604,7 +604,7 @@ static int process_event(struct parser_state *parser) */ static int process_timing_point(struct parser_state *parser) { - struct oshu::timing_point *timing; + oshu::timing_point *timing; if (parse_timing_point(parser, &timing) < 0) return -1; if (parser->last_timing_point && timing->offset < parser->last_timing_point->offset) { @@ -621,7 +621,7 @@ static int process_timing_point(struct parser_state *parser) return 0; } -static int parse_timing_point(struct parser_state *parser, struct oshu::timing_point **timing) +static int parse_timing_point(struct parser_state *parser, oshu::timing_point **timing) { int value; *timing = (oshu::timing_point*) calloc(1, sizeof(**timing)); @@ -723,7 +723,7 @@ static int process_color_combo(struct parser_state *parser) } /* Parse everything else. */ - struct oshu::color *color; + oshu::color *color; consume_spaces(parser); if (consume_char(parser, ':') < 0) return -1; @@ -743,7 +743,7 @@ static int process_color_combo(struct parser_state *parser) return 0; } -static int parse_color(struct parser_state *parser, struct oshu::color **color) +static int parse_color(struct parser_state *parser, oshu::color **color) { *color = (oshu::color*) calloc(1, sizeof(**color)); assert (color != NULL); @@ -802,12 +802,12 @@ static void validate_colors(struct parser_state *parser) * results on further calls, assuming you'd never seek to a point before the * last seek. */ -static struct oshu::timing_point* seek_timing_point(double offset, struct parser_state *parser) +static oshu::timing_point* seek_timing_point(double offset, struct parser_state *parser) { if (parser->current_timing_point == NULL) parser->current_timing_point = parser->beatmap->timing_points; /* update the parser state as we loop */ - struct oshu::timing_point **tp = &parser->current_timing_point; + oshu::timing_point **tp = &parser->current_timing_point; for (; *tp && (*tp)->next; *tp = (*tp)->next) { if ((*tp)->next->offset > offset) break; @@ -829,7 +829,7 @@ static struct oshu::timing_point* seek_timing_point(double offset, struct parser * - What if the initial hit has a combo skip? * - What if the combo skip is non-zero but the new combo flag is unset? */ -static void compute_hit_combo(struct parser_state *parser, struct oshu::hit *hit) +static void compute_hit_combo(struct parser_state *parser, oshu::hit *hit) { assert (parser->last_hit != NULL); if (parser->last_hit->time < 0.) { @@ -858,11 +858,11 @@ static void compute_hit_combo(struct parser_state *parser, struct oshu::hit *hit * Therefore, we need to re-process the slider's sounds after the hit is * completely parser. */ -static void fill_slider_additions(struct oshu::hit *hit) +static void fill_slider_additions(oshu::hit *hit) { assert (hit->type & oshu::SLIDER_HIT); for (int i = 0; i <= hit->slider.repeat; ++i) { - struct oshu::hit_sound *s = &hit->slider.sounds[i]; + oshu::hit_sound *s = &hit->slider.sounds[i]; s->additions |= oshu::NORMAL_SOUND; if (!s->sample_set) s->sample_set = hit->sound.sample_set; @@ -875,7 +875,7 @@ static void fill_slider_additions(struct oshu::hit *hit) static int process_hit_object(struct parser_state *parser) { - struct oshu::hit *hit; + oshu::hit *hit; if (parse_hit_object(parser, &hit) < 0) return -1; compute_hit_combo(parser, hit); @@ -900,7 +900,7 @@ static int process_hit_object(struct parser_state *parser) * Consumes: * `288,256,8538,2,0,P|254:261|219:255,1,70,8|0,0:0|0:0,0:0:0:0:` */ -static int parse_hit_object(struct parser_state *parser, struct oshu::hit **hit) +static int parse_hit_object(struct parser_state *parser, oshu::hit **hit) { *hit = (oshu::hit*) calloc(1, sizeof(**hit)); assert (*hit != NULL); @@ -945,7 +945,7 @@ static int parse_hit_object(struct parser_state *parser, struct oshu::hit **hit) * Consumes: * `288,256,8538,2,0` */ -static int parse_common_hit(struct parser_state *parser, struct oshu::hit *hit) +static int parse_common_hit(struct parser_state *parser, oshu::hit *hit) { double x, y; if (parse_double_sep(parser, &x, ',') < 0) @@ -977,7 +977,7 @@ static int parse_common_hit(struct parser_state *parser, struct oshu::hit *hit) * Some sliders are shorter and omit the slider additions, like that: * `160,76,142685,6,0,B|156:120|116:152,1,70,8|0` */ -static int parse_slider(struct parser_state *parser, struct oshu::hit *hit) +static int parse_slider(struct parser_state *parser, oshu::hit *hit) { char type; if (parse_char(parser, &type) < 0) @@ -1032,9 +1032,9 @@ static int parse_point(struct parser_state *parser, oshu::point *p) * \todo * Parse polyline paths, like `L|X:Y|X:Y`. */ -static int parse_linear_slider(struct parser_state *parser, struct oshu::hit *hit) +static int parse_linear_slider(struct parser_state *parser, oshu::hit *hit) { - struct oshu::path *path = &hit->slider.path; + oshu::path *path = &hit->slider.path; path->type = oshu::LINEAR_PATH; path->line.start = hit->p; if (parse_point(parser, &path->line.end) < 0) @@ -1051,7 +1051,7 @@ static int parse_linear_slider(struct parser_state *parser, struct oshu::hit *hi * Consumes: * `396:140|448:80' */ -static int parse_perfect_slider(struct parser_state *parser, struct oshu::hit *hit) +static int parse_perfect_slider(struct parser_state *parser, oshu::hit *hit) { oshu::point a, b, c; a = hit->p; @@ -1092,7 +1092,7 @@ static int parse_perfect_slider(struct parser_state *parser, struct oshu::hit *h * \todo * Reclaim the unused memory in the indices aray. */ -static int parse_bezier_slider(struct parser_state *parser, struct oshu::hit *hit) +static int parse_bezier_slider(struct parser_state *parser, oshu::hit *hit) { int count = 2; for (char *c = parser->input; *c != '\0' && *c != ','; ++c) { @@ -1101,7 +1101,7 @@ static int parse_bezier_slider(struct parser_state *parser, struct oshu::hit *hi } hit->slider.path.type = oshu::BEZIER_PATH; - struct oshu::bezier *bezier = &hit->slider.path.bezier; + oshu::bezier *bezier = &hit->slider.path.bezier; bezier->control_points = (oshu::point*) calloc(count, sizeof(*bezier->control_points)); assert (bezier->control_points != NULL); bezier->control_points[0] = hit->p; @@ -1141,7 +1141,7 @@ static int parse_bezier_slider(struct parser_state *parser, struct oshu::hit *hi * Consumes: * `4|2,1:2|0:3 */ -static int parse_slider_additions(struct parser_state *parser, struct oshu::hit *hit) +static int parse_slider_additions(struct parser_state *parser, oshu::hit *hit) { hit->slider.sounds = (oshu::hit_sound*) calloc(hit->slider.repeat + 1, sizeof(*hit->slider.sounds)); assert (hit->slider.sounds != NULL); @@ -1187,7 +1187,7 @@ static int parse_slider_additions(struct parser_state *parser, struct oshu::hit * Consumes: * - `16620` */ -static int parse_spinner(struct parser_state *parser, struct oshu::hit *hit) +static int parse_spinner(struct parser_state *parser, oshu::hit *hit) { if (parse_double(parser, &hit->spinner.end_time) < 0) return -1; @@ -1201,7 +1201,7 @@ static int parse_spinner(struct parser_state *parser, struct oshu::hit *hit) * Consumes: * `16620` */ -static int parse_hold_note(struct parser_state *parser, struct oshu::hit *hit) +static int parse_hold_note(struct parser_state *parser, oshu::hit *hit) { if (parse_double(parser, &hit->hold_note.end_time) < 0) return -1; @@ -1222,7 +1222,7 @@ static int parse_hold_note(struct parser_state *parser, struct oshu::hit *hit) * \todo * Store the optional filename at the end when present. */ -static int parse_additions(struct parser_state *parser, struct oshu::hit *hit) +static int parse_additions(struct parser_state *parser, oshu::hit *hit) { /* 0. Fill defaults. */ hit->sound.sample_set = hit->timing_point->sample_set; @@ -1284,7 +1284,7 @@ static int parse_additions(struct parser_state *parser, struct oshu::hit *hit) * Stop reading the file if the header is incorrect. It's no use printing a * mega list of warnings if the file clearly looks nothing like text. */ -static int parse_file(FILE *input, const char *name, struct oshu::beatmap *beatmap, bool headers_only) +static int parse_file(FILE *input, const char *name, oshu::beatmap *beatmap, bool headers_only) { struct parser_state parser; memset(&parser, 0, sizeof(parser)); @@ -1315,7 +1315,7 @@ static int parse_file(FILE *input, const char *name, struct oshu::beatmap *beatm } free(line); /* Finalize the hits sequence. */ - struct oshu::hit *end; + oshu::hit *end; end = (oshu::hit*) calloc(1, sizeof(*end)); assert (end != NULL); end->time = INFINITY; @@ -1328,7 +1328,7 @@ static int parse_file(FILE *input, const char *name, struct oshu::beatmap *beatm * Initialize the beatmap to its defaults, and add the first unreachable hit * object. */ -void initialize(struct oshu::beatmap *beatmap) +void initialize(oshu::beatmap *beatmap) { memcpy(beatmap, &default_beatmap, sizeof(*beatmap)); beatmap->hits = (oshu::hit*) calloc(1, sizeof(*beatmap->hits)); @@ -1336,7 +1336,7 @@ void initialize(struct oshu::beatmap *beatmap) beatmap->hits->time = -INFINITY; } -static int validate_metadata(struct oshu::metadata *meta) +static int validate_metadata(oshu::metadata *meta) { if (!meta->title) return -1; @@ -1351,7 +1351,7 @@ static int validate_metadata(struct oshu::metadata *meta) * Perform a variety of checks on a beatmap file to ensure it was parsed well * enough to be played. */ -static int validate(struct oshu::beatmap *beatmap) +static int validate(oshu::beatmap *beatmap) { if (!beatmap->audio_filename) { oshu_log_error("no audio file mentionned"); @@ -1364,7 +1364,7 @@ static int validate(struct oshu::beatmap *beatmap) return 0; } -static int load_beatmap(const char *path, struct oshu::beatmap *beatmap, bool headers_only) +static int load_beatmap(const char *path, oshu::beatmap *beatmap, bool headers_only) { oshu_log_debug("loading beatmap %s", path); @@ -1396,17 +1396,17 @@ static int load_beatmap(const char *path, struct oshu::beatmap *beatmap, bool he return -1; } -int oshu::load_beatmap(const char *path, struct oshu::beatmap *beatmap) +int oshu::load_beatmap(const char *path, oshu::beatmap *beatmap) { return ::load_beatmap(path, beatmap, false); } -int oshu::load_beatmap_headers(const char *path, struct oshu::beatmap *beatmap) +int oshu::load_beatmap_headers(const char *path, oshu::beatmap *beatmap) { return ::load_beatmap(path, beatmap, true); } -static void free_metadata(struct oshu::metadata *meta) +static void free_metadata(oshu::metadata *meta) { free(meta->title); free(meta->title_unicode); @@ -1417,7 +1417,7 @@ static void free_metadata(struct oshu::metadata *meta) free(meta->source); } -static void free_path(struct oshu::path *path) +static void free_path(oshu::path *path) { if (path->type == oshu::BEZIER_PATH) { free(path->bezier.control_points); @@ -1425,11 +1425,11 @@ static void free_path(struct oshu::path *path) } } -static void free_hits(struct oshu::hit *hits) +static void free_hits(oshu::hit *hits) { - struct oshu::hit *current = hits; + oshu::hit *current = hits; while (current != NULL) { - struct oshu::hit *next = current->next; + oshu::hit *next = current->next; if (current->type & oshu::SLIDER_HIT) { free_path(¤t->slider.path); free(current->slider.sounds); @@ -1439,29 +1439,29 @@ static void free_hits(struct oshu::hit *hits) } } -static void free_timing_points(struct oshu::timing_point *t) +static void free_timing_points(oshu::timing_point *t) { - struct oshu::timing_point *current = t; + oshu::timing_point *current = t; while (current != NULL) { - struct oshu::timing_point *next = current->next; + oshu::timing_point *next = current->next; free(current); current = next; } } -static void free_colors(struct oshu::color *colors) +static void free_colors(oshu::color *colors) { if (!colors) return; - struct oshu::color *current = colors; + oshu::color *current = colors; do { - struct oshu::color *next = current->next; + oshu::color *next = current->next; free(current); current = next; } while (current != colors); } -void oshu::destroy_beatmap(struct oshu::beatmap *beatmap) +void oshu::destroy_beatmap(oshu::beatmap *beatmap) { free(beatmap->audio_filename); free(beatmap->background_filename); diff --git a/lib/beatmap/parser.h b/lib/beatmap/parser.h index 8e37f9a..211e9c2 100644 --- a/lib/beatmap/parser.h +++ b/lib/beatmap/parser.h @@ -161,7 +161,7 @@ struct parser_state { * * Its memory isn't handled by us. */ - struct oshu::beatmap *beatmap; + oshu::beatmap *beatmap; /** * The current section. * @@ -177,11 +177,11 @@ struct parser_state { /** * Keep track of the last timing point to build the linked list. */ - struct oshu::timing_point *last_timing_point; + oshu::timing_point *last_timing_point; /** * Keep track of the last color to build the circular linked list. */ - struct oshu::color *last_color; + oshu::color *last_color; /** * When parsing hit objects, we need to figure out what its timing * point is, notably to compute slider durations. @@ -190,7 +190,7 @@ struct parser_state { * It must not become NULL at the end of the chain, because otherwise * we're back to the first case and will trigger an infinite loop. */ - struct oshu::timing_point *current_timing_point; + oshu::timing_point *current_timing_point; /** * This is the #oshu::timing_point::beat_duration of the last * non-inherited timing point. @@ -199,7 +199,7 @@ struct parser_state { /** * Keep track of the last hit object to build the linked list. */ - struct oshu::hit *last_hit; + oshu::hit *last_hit; }; /** @@ -243,24 +243,24 @@ static int process_input(P*); static int process_difficulty(P*); static int process_event(P*); static int process_timing_point(P*); - static int parse_timing_point(P*, struct oshu::timing_point**); + static int parse_timing_point(P*, oshu::timing_point**); static int process_color(P*); static int process_color_combo(P*); - static int parse_color(P*, struct oshu::color**); + static int parse_color(P*, oshu::color**); static int parse_color_channel(P*, double*); static void validate_colors(P*); static int process_hit_object(P*); - static int parse_hit_object(P*, struct oshu::hit**); - static int parse_common_hit(P*, struct oshu::hit*); - static int parse_slider(P*, struct oshu::hit*); + static int parse_hit_object(P*, oshu::hit**); + static int parse_common_hit(P*, oshu::hit*); + static int parse_slider(P*, oshu::hit*); static int parse_point(P*, oshu::point*); - static int parse_linear_slider(P*, struct oshu::hit*); - static int parse_perfect_slider(P*, struct oshu::hit*); - static int parse_bezier_slider(P*, struct oshu::hit*); - static int parse_slider_additions(P*, struct oshu::hit*); - static int parse_spinner(P*, struct oshu::hit*); - static int parse_hold_note(P*, struct oshu::hit*); - static int parse_additions(P*, struct oshu::hit*); + static int parse_linear_slider(P*, oshu::hit*); + static int parse_perfect_slider(P*, oshu::hit*); + static int parse_bezier_slider(P*, oshu::hit*); + static int parse_slider_additions(P*, oshu::hit*); + static int parse_spinner(P*, oshu::hit*); + static int parse_hold_note(P*, oshu::hit*); + static int parse_additions(P*, oshu::hit*); namespace oshu { diff --git a/lib/beatmap/path.cc b/lib/beatmap/path.cc index 7526667..78ab248 100644 --- a/lib/beatmap/path.cc +++ b/lib/beatmap/path.cc @@ -102,7 +102,7 @@ static int focus(double *t, int n) * * \sa focus */ -static void bezier_map(struct oshu::bezier *path, double *t, int *degree, oshu::point **control_points) +static void bezier_map(oshu::bezier *path, double *t, int *degree, oshu::point **control_points) { int segment = focus(t, path->segment_count); *degree = path->indices[segment+1] - path->indices[segment] - 1; @@ -119,7 +119,7 @@ static void bezier_map(struct oshu::bezier *path, double *t, int *degree, oshu:: * super high-degree Bézier curves on some beatmaps, and the factorial was at * its limits. */ -static oshu::point bezier_at(struct oshu::bezier *path, double t) +static oshu::point bezier_at(oshu::bezier *path, double t) { int degree; oshu::point *points; @@ -153,7 +153,7 @@ static oshu::point bezier_at(struct oshu::bezier *path, double t) * The memory reallocation implies the memory must have been dynamically * allocated. You won't be able to grow a static path. */ -static int grow_bezier(struct oshu::bezier *bezier, double extension) +static int grow_bezier(oshu::bezier *bezier, double extension) { assert (bezier->segment_count >= 1); assert (bezier->indices != NULL); @@ -211,7 +211,7 @@ static int grow_bezier(struct oshu::bezier *bezier, double extension) * Finally, let `anchors[j] = (1-k) * t_i + k * t_(i+1)`. * */ -void normalize_bezier(struct oshu::bezier *bezier, double target_length) +void normalize_bezier(oshu::bezier *bezier, double target_length) { /* 1. Prepare the field. */ int n = 64; /* arbitrary */ @@ -266,7 +266,7 @@ void normalize_bezier(struct oshu::bezier *bezier, double target_length) * * \sa normalize_bezier */ -static double l_to_t(struct oshu::bezier *bezier, double l) +static double l_to_t(oshu::bezier *bezier, double l) { int n = sizeof(bezier->anchors) / sizeof(*bezier->anchors) - 1; int i = focus(&l, n); @@ -277,7 +277,7 @@ static double l_to_t(struct oshu::bezier *bezier, double l) * Every point on a Bézier line is an average of all the control points, so * it's safe to compute the bounding box of the polyline defined by them. */ -void bezier_bounding_box(struct oshu::bezier *bezier, oshu::point *top_left, oshu::point *bottom_right) +void bezier_bounding_box(oshu::bezier *bezier, oshu::point *top_left, oshu::point *bottom_right) { assert (bezier->segment_count > 0); *top_left = *bottom_right = bezier->control_points[0]; @@ -291,12 +291,12 @@ void bezier_bounding_box(struct oshu::bezier *bezier, oshu::point *top_left, osh /** * Simple weighted average of the starting point and end point. */ -static oshu::point line_at(struct oshu::line *line, double t) +static oshu::point line_at(oshu::line *line, double t) { return (1 - t) * line->start + t * line->end; } -static void normalize_line(struct oshu::line *line, double target_length) +static void normalize_line(oshu::line *line, double target_length) { double actual_length = std::abs(line->start - line->end); assert (target_length > 0); @@ -305,7 +305,7 @@ static void normalize_line(struct oshu::line *line, double target_length) line->end = line->start + (line->end - line->start) * factor; } -void line_bounding_box(struct oshu::line *line, oshu::point *top_left, oshu::point *bottom_right) +void line_bounding_box(oshu::line *line, oshu::point *top_left, oshu::point *bottom_right) { *top_left = *bottom_right = line->start; extend_box(line->start, top_left, bottom_right); @@ -314,7 +314,7 @@ void line_bounding_box(struct oshu::line *line, oshu::point *top_left, oshu::poi /* Perfect circle arcs ********************************************************/ -static oshu::point arc_at(struct oshu::arc *arc, double t) +static oshu::point arc_at(oshu::arc *arc, double t) { double angle = (1 - t) * arc->start_angle + t * arc->end_angle; return arc->center + std::polar(arc->radius, angle); @@ -344,7 +344,7 @@ int arc_center(oshu::point a, oshu::point b, oshu::point c, oshu::point *center) return 0; } -int oshu::build_arc(oshu::point a, oshu::point b, oshu::point c, struct oshu::arc *arc) +int oshu::build_arc(oshu::point a, oshu::point b, oshu::point c, oshu::arc *arc) { if (arc_center(a, b, c, &arc->center) < 0) return -1; @@ -361,7 +361,7 @@ int oshu::build_arc(oshu::point a, oshu::point b, oshu::point c, struct oshu::ar return 0; } -static void normalize_arc(struct oshu::arc *arc, double target_length) +static void normalize_arc(oshu::arc *arc, double target_length) { double target_angle = target_length / arc->radius; double diff = copysign(target_angle, arc->end_angle - arc->start_angle); @@ -377,7 +377,7 @@ static void normalize_arc(struct oshu::arc *arc, double target_length) * Then, add the two extremities of the arc, and, for any side of the circle * reached, extend the box. */ -void arc_bounding_box(struct oshu::arc *arc, oshu::point *top_left, oshu::point *bottom_right) +void arc_bounding_box(oshu::arc *arc, oshu::point *top_left, oshu::point *bottom_right) { double min = arc->start_angle < arc->end_angle ? arc->start_angle : arc->end_angle; double max = arc->start_angle > arc->end_angle ? arc->start_angle : arc->end_angle; @@ -408,7 +408,7 @@ void arc_bounding_box(struct oshu::arc *arc, oshu::point *top_left, oshu::point /* Generic interface **********************************************************/ -void oshu::normalize_path(struct oshu::path *path, double length) +void oshu::normalize_path(oshu::path *path, double length) { switch (path->type) { case oshu::LINEAR_PATH: @@ -422,7 +422,7 @@ void oshu::normalize_path(struct oshu::path *path, double length) } } -oshu::point oshu::path_at(struct oshu::path *path, double t) +oshu::point oshu::path_at(oshu::path *path, double t) { /* map t from ℝ to [0,1] */ t = fabs(remainder(t, 2.)); @@ -443,7 +443,7 @@ oshu::point oshu::path_at(struct oshu::path *path, double t) return 0; } -void oshu::path_bounding_box(struct oshu::path *path, oshu::point *top_left, oshu::point *bottom_right) +void oshu::path_bounding_box(oshu::path *path, oshu::point *top_left, oshu::point *bottom_right) { switch (path->type) { case oshu::LINEAR_PATH: diff --git a/lib/game/base.cc b/lib/game/base.cc index deeaf21..2ae83a1 100644 --- a/lib/game/base.cc +++ b/lib/game/base.cc @@ -16,7 +16,7 @@ #include -static int open_beatmap(const char *beatmap_path, struct oshu::game_base *game) +static int open_beatmap(const char *beatmap_path, oshu::game_base *game) { if (oshu::load_beatmap(beatmap_path, &game->beatmap) < 0) { oshu_log_error("no beatmap, aborting"); @@ -31,7 +31,7 @@ static int open_beatmap(const char *beatmap_path, struct oshu::game_base *game) return 0; } -static int open_audio(struct oshu::game_base *game) +static int open_audio(oshu::game_base *game) { assert (game->beatmap.audio_filename != NULL); if (oshu::open_audio(game->beatmap.audio_filename, &game->audio) < 0) { diff --git a/lib/game/clock.cc b/lib/game/clock.cc index 387d5ba..629d777 100644 --- a/lib/game/clock.cc +++ b/lib/game/clock.cc @@ -8,7 +8,7 @@ #include "core/log.h" #include "game/base.h" -void oshu::initialize_clock(struct oshu::game_base *game) +void oshu::initialize_clock(oshu::game_base *game) { if (game->beatmap.audio_lead_in > 0.) { game->clock.now = - game->beatmap.audio_lead_in; @@ -25,9 +25,9 @@ void oshu::initialize_clock(struct oshu::game_base *game) * Find a better way to determine if the music is playing. The clock shouldn't * take the game screen into consideration. */ -void oshu::update_clock(struct oshu::game_base *game) +void oshu::update_clock(oshu::game_base *game) { - struct oshu::clock *clock = &game->clock; + oshu::clock *clock = &game->clock; double system = SDL_GetTicks() / 1000.; double diff = system - clock->system; double prev_audio = clock->audio; diff --git a/lib/game/helpers.cc b/lib/game/helpers.cc index 6a7b738..c614819 100644 --- a/lib/game/helpers.cc +++ b/lib/game/helpers.cc @@ -5,9 +5,9 @@ #include "game/base.h" -struct oshu::hit* oshu::look_hit_back(struct oshu::game_base *game, double offset) +oshu::hit* oshu::look_hit_back(oshu::game_base *game, double offset) { - struct oshu::hit *hit = game->hit_cursor; + oshu::hit *hit = game->hit_cursor; double target = game->clock.now - offset; /* seek backward */ while (oshu::hit_end_time(hit) > target) @@ -19,9 +19,9 @@ struct oshu::hit* oshu::look_hit_back(struct oshu::game_base *game, double offse return hit; } -struct oshu::hit* oshu::look_hit_up(struct oshu::game_base *game, double offset) +oshu::hit* oshu::look_hit_up(oshu::game_base *game, double offset) { - struct oshu::hit *hit = game->hit_cursor; + oshu::hit *hit = game->hit_cursor; double target = game->clock.now + offset; /* seek forward */ while (hit->time < target) @@ -33,9 +33,9 @@ struct oshu::hit* oshu::look_hit_up(struct oshu::game_base *game, double offset) return hit; } -struct oshu::hit* oshu::next_hit(struct oshu::game_base *game) +oshu::hit* oshu::next_hit(oshu::game_base *game) { - struct oshu::hit *hit = game->hit_cursor; + oshu::hit *hit = game->hit_cursor; for (; hit->next; hit = hit->next) { if (hit->type & (oshu::CIRCLE_HIT | oshu::SLIDER_HIT)) break; @@ -43,9 +43,9 @@ struct oshu::hit* oshu::next_hit(struct oshu::game_base *game) return hit; } -struct oshu::hit* oshu::previous_hit(struct oshu::game_base *game) +oshu::hit* oshu::previous_hit(oshu::game_base *game) { - struct oshu::hit *hit = game->hit_cursor; + oshu::hit *hit = game->hit_cursor; if (!hit->previous) return hit; for (hit = hit->previous; hit->previous; hit = hit->previous) { diff --git a/lib/game/osu.cc b/lib/game/osu.cc index f2e99c1..d991730 100644 --- a/lib/game/osu.cc +++ b/lib/game/osu.cc @@ -25,11 +25,11 @@ oshu::osu_game::osu_game(const char *beatmap_path) * * If two hit objects overlap, yield the oldest unclicked one. */ -static struct oshu::hit* find_hit(struct oshu::osu_game *game, oshu::point p) +static oshu::hit* find_hit(oshu::osu_game *game, oshu::point p) { - struct oshu::hit *start = oshu::look_hit_back(game, game->beatmap.difficulty.approach_time); + oshu::hit *start = oshu::look_hit_back(game, game->beatmap.difficulty.approach_time); double max_time = game->clock.now + game->beatmap.difficulty.approach_time; - for (struct oshu::hit *hit = start; hit->time <= max_time; hit = hit->next) { + for (oshu::hit *hit = start; hit->time <= max_time; hit = hit->next) { if (!(hit->type & (oshu::CIRCLE_HIT | oshu::SLIDER_HIT))) continue; if (hit->state != oshu::INITIAL_HIT) @@ -46,7 +46,7 @@ static struct oshu::hit* find_hit(struct oshu::osu_game *game, oshu::point p) * It is unlikely that once a slider is marked as good or missed, it will ever * be shown once again. The main exception is when the user seeks. */ -static void jettison_hit(struct oshu::hit *hit) +static void jettison_hit(oshu::hit *hit) { if (hit->texture) { oshu::destroy_texture(hit->texture); @@ -59,9 +59,9 @@ static void jettison_hit(struct oshu::hit *hit) * Release the held slider, either because the held key is released, or because * a new slider is activated (somehow). */ -static void release_slider(struct oshu::osu_game *game) +static void release_slider(oshu::osu_game *game) { - struct oshu::hit *hit = game->current_slider; + oshu::hit *hit = game->current_slider; if (!hit) return; assert (hit->type & oshu::SLIDER_HIT); @@ -81,9 +81,9 @@ static void release_slider(struct oshu::osu_game *game) * * When the last one is reached, release the slider. */ -static void sonorize_slider(struct oshu::osu_game *game) +static void sonorize_slider(oshu::osu_game *game) { - struct oshu::hit *hit = game->current_slider; + oshu::hit *hit = game->current_slider; if (!hit) return; assert (hit->type & oshu::SLIDER_HIT); @@ -111,7 +111,7 @@ int oshu::osu_game::check() /* Ensure the mouse follows the slider. */ sonorize_slider(this); /* < may release the slider! */ if (this->current_slider && mouse) { - struct oshu::hit *hit = this->current_slider; + oshu::hit *hit = this->current_slider; double t = (this->clock.now - hit->time) / hit->slider.duration; oshu::point ball = oshu::path_at(&hit->slider.path, t); oshu::point m = mouse->position(); @@ -125,7 +125,7 @@ int oshu::osu_game::check() /* Mark dead notes as missed. */ double left_wall = this->clock.now - this->beatmap.difficulty.leniency; while (this->hit_cursor->time < left_wall) { - struct oshu::hit *hit = this->hit_cursor; + oshu::hit *hit = this->hit_cursor; if (!(hit->type & (oshu::CIRCLE_HIT | oshu::SLIDER_HIT))) { hit->state = oshu::UNKNOWN_HIT; } else if (hit->state == oshu::INITIAL_HIT) { @@ -146,7 +146,7 @@ int oshu::osu_game::check() * The key is the held key, relevant only for sliders. In autoplay mode, it's * value doesn't matter. */ -static void activate_hit(struct oshu::osu_game *game, struct oshu::hit *hit, enum oshu::finger key) +static void activate_hit(oshu::osu_game *game, oshu::hit *hit, enum oshu::finger key) { if (hit->type & oshu::SLIDER_HIT) { release_slider(game); @@ -186,7 +186,7 @@ int oshu::osu_game::press(enum oshu::finger key) if (!mouse) return 0; oshu::point m = mouse->position(); - struct oshu::hit *hit = find_hit(this, m); + oshu::hit *hit = find_hit(this, m); if (!hit) return 0; if (fabs(hit->time - this->clock.now) < this->beatmap.difficulty.leniency) { diff --git a/lib/game/tty.cc b/lib/game/tty.cc index 1d22c7b..6f1ba20 100644 --- a/lib/game/tty.cc +++ b/lib/game/tty.cc @@ -21,10 +21,10 @@ void print_dual(const char *ascii, const char *unicode) printf(" Unknown\n"); } -void oshu::welcome(struct oshu::game_base *game) +void oshu::welcome(oshu::game_base *game) { - struct oshu::beatmap *beatmap = &game->beatmap; - struct oshu::metadata *meta = &beatmap->metadata; + oshu::beatmap *beatmap = &game->beatmap; + oshu::metadata *meta = &beatmap->metadata; printf("\n"); print_dual(meta->title, meta->title_unicode); print_dual(meta->artist, meta->artist_unicode); @@ -53,7 +53,7 @@ void oshu::welcome(struct oshu::game_base *game) * \todo * This function should be deleted once the window can display the time. */ -void oshu::print_state(struct oshu::game_base *game) +void oshu::print_state(oshu::game_base *game) { if (!isatty(fileno(stdout))) return; @@ -70,14 +70,14 @@ void oshu::print_state(struct oshu::game_base *game) fflush(stdout); } -void oshu::congratulate(struct oshu::game_base *game) +void oshu::congratulate(oshu::game_base *game) { /* Clear the status line. */ printf("\r \r"); /* Compute the score. */ int good = 0; int missed = 0; - for (struct oshu::hit *hit = game->beatmap.hits; hit; hit = hit->next) { + for (oshu::hit *hit = game->beatmap.hits; hit; hit = hit->next) { if (hit->state == oshu::MISSED_HIT) missed++; else if (hit->state == oshu::GOOD_HIT) diff --git a/lib/ui/audio.cc b/lib/ui/audio.cc index 8f4edb9..e0051b8 100644 --- a/lib/ui/audio.cc +++ b/lib/ui/audio.cc @@ -11,14 +11,14 @@ #include #include -int oshu::create_audio_progress_bar(struct oshu::display *display, struct oshu::stream *stream, struct oshu::audio_progress_bar *bar) +int oshu::create_audio_progress_bar(oshu::display *display, oshu::stream *stream, oshu::audio_progress_bar *bar) { bar->display = display; bar->stream = stream; return 0; } -void oshu::show_audio_progress_bar(struct oshu::audio_progress_bar *bar) +void oshu::show_audio_progress_bar(oshu::audio_progress_bar *bar) { assert (bar->stream->duration != 0); double progression = bar->stream->current_timestamp / bar->stream->duration; @@ -39,6 +39,6 @@ void oshu::show_audio_progress_bar(struct oshu::audio_progress_bar *bar) SDL_RenderFillRect(bar->display->renderer, &shape); } -void oshu::destroy_audio_progress_bar(struct oshu::audio_progress_bar *bar) +void oshu::destroy_audio_progress_bar(oshu::audio_progress_bar *bar) { } diff --git a/lib/ui/background.cc b/lib/ui/background.cc index 9c0d8bc..cc46e40 100644 --- a/lib/ui/background.cc +++ b/lib/ui/background.cc @@ -25,7 +25,7 @@ * The result is written in *dest*, such that the rectangle covers the whole * window while possibly being cropped. */ -static void fit(struct oshu::display *display, oshu::size size, SDL_Rect *dest) +static void fit(oshu::display *display, oshu::size size, SDL_Rect *dest) { oshu::size vsize = display->view.size; double window_ratio = oshu::ratio(vsize);; @@ -76,7 +76,7 @@ static void fit(struct oshu::display *display, oshu::size size, SDL_Rect *dest) * \todo * Handle cairo errors. */ -static int scale_background(struct oshu::display *display, SDL_Surface **pic) +static int scale_background(oshu::display *display, SDL_Surface **pic) { SDL_Rect target_rect; fit(display, oshu::size((*pic)->w, (*pic)->h), &target_rect); @@ -120,7 +120,7 @@ static int scale_background(struct oshu::display *display, SDL_Surface **pic) return 0; } -int oshu::load_background(struct oshu::display *display, const char *filename, struct oshu::background *background) +int oshu::load_background(oshu::display *display, const char *filename, oshu::background *background) { memset(background, 0, sizeof(*background)); background->display = display; @@ -155,14 +155,14 @@ int oshu::load_background(struct oshu::display *display, const char *filename, s * When the aspects don't match, crop the picture to ensure the window is * filled. */ -static void fill_screen(struct oshu::display *display, struct oshu::texture *pic) +static void fill_screen(oshu::display *display, oshu::texture *pic) { SDL_Rect dest; fit(display, pic->size, &dest); SDL_RenderCopy(display->renderer, pic->texture, NULL, &dest); } -void oshu::show_background(struct oshu::background *background, double brightness) +void oshu::show_background(oshu::background *background, double brightness) { if (!background->picture.texture) return; @@ -175,7 +175,7 @@ void oshu::show_background(struct oshu::background *background, double brightnes fill_screen(background->display, &background->picture); } -void oshu::destroy_background(struct oshu::background *background) +void oshu::destroy_background(oshu::background *background) { if (!background->display) /* uninitialized background */ return; diff --git a/lib/ui/cursor.cc b/lib/ui/cursor.cc index b76b962..09d2f8e 100644 --- a/lib/ui/cursor.cc +++ b/lib/ui/cursor.cc @@ -11,12 +11,12 @@ #include #include -static int paint_cursor(struct oshu::cursor_widget *cursor) +static int paint_cursor(oshu::cursor_widget *cursor) { double radius = 14; oshu::size size = oshu::size{1, 1} * radius * 2.; - struct oshu::painter p; + oshu::painter p; oshu::start_painting(cursor->display, size, &p); cairo_translate(p.cr, radius, radius); @@ -38,7 +38,7 @@ static int paint_cursor(struct oshu::cursor_widget *cursor) return rc; } -int oshu::create_cursor(struct oshu::display *display, struct oshu::cursor_widget *cursor) +int oshu::create_cursor(oshu::display *display, oshu::cursor_widget *cursor) { memset(cursor, 0, sizeof(*cursor)); cursor->display = display; @@ -54,7 +54,7 @@ int oshu::create_cursor(struct oshu::display *display, struct oshu::cursor_widge return paint_cursor(cursor); } -void oshu::show_cursor(struct oshu::cursor_widget *cursor) +void oshu::show_cursor(oshu::cursor_widget *cursor) { if (!(cursor->display->features & oshu::FANCY_CURSOR)) return; @@ -75,7 +75,7 @@ void oshu::show_cursor(struct oshu::cursor_widget *cursor) } } -void oshu::destroy_cursor(struct oshu::cursor_widget *cursor) +void oshu::destroy_cursor(oshu::cursor_widget *cursor) { if (!cursor->display) return; diff --git a/lib/ui/metadata.cc b/lib/ui/metadata.cc index 00abb3c..5216858 100644 --- a/lib/ui/metadata.cc +++ b/lib/ui/metadata.cc @@ -20,7 +20,7 @@ static const double padding = 10; -static PangoLayout* setup_layout(struct oshu::painter *p) +static PangoLayout* setup_layout(oshu::painter *p) { cairo_set_operator(p->cr, CAIRO_OPERATOR_SOURCE); @@ -41,10 +41,10 @@ static PangoLayout* setup_layout(struct oshu::painter *p) * \todo * Handle errors. */ -static int paint_stars(struct oshu::metadata_frame *frame) +static int paint_stars(oshu::metadata_frame *frame) { oshu::size size {360, 60}; - struct oshu::painter p; + oshu::painter p; oshu::start_painting(frame->display, size, &p); const char *sky = " ★ ★ ★ ★ ★ ★ ★ ★ ★ ★"; @@ -54,7 +54,7 @@ static int paint_stars(struct oshu::metadata_frame *frame) int star_length = strlen(sky) / 10; std::string difficulty (sky, star_length * stars); - struct oshu::metadata *meta = &frame->beatmap->metadata; + oshu::metadata *meta = &frame->beatmap->metadata; const char *version = meta->version; assert (version != NULL); std::ostringstream os; @@ -70,7 +70,7 @@ static int paint_stars(struct oshu::metadata_frame *frame) pango_cairo_show_layout(p.cr, layout); g_object_unref(layout); - struct oshu::texture *texture = &frame->stars; + oshu::texture *texture = &frame->stars; int rc = oshu::finish_painting(&p, texture); texture->origin = std::real(size); return rc; @@ -80,13 +80,13 @@ static int paint_stars(struct oshu::metadata_frame *frame) * \todo * Handle errors. */ -static int paint_metadata(struct oshu::metadata_frame *frame, int unicode) +static int paint_metadata(oshu::metadata_frame *frame, int unicode) { oshu::size size {640, 60}; - struct oshu::painter p; + oshu::painter p; oshu::start_painting(frame->display, size, &p); - struct oshu::metadata *meta = &frame->beatmap->metadata; + oshu::metadata *meta = &frame->beatmap->metadata; const char *title = unicode ? meta->title_unicode : meta->title; const char *artist = unicode ? meta->artist_unicode : meta->artist; std::ostringstream os; @@ -101,7 +101,7 @@ static int paint_metadata(struct oshu::metadata_frame *frame, int unicode) pango_cairo_show_layout(p.cr, layout); g_object_unref(layout); - struct oshu::texture *texture = unicode ? &frame->unicode : &frame->ascii; + oshu::texture *texture = unicode ? &frame->unicode : &frame->ascii; int rc = oshu::finish_painting(&p, texture); texture->origin = 0; return rc; @@ -111,9 +111,9 @@ static int paint_metadata(struct oshu::metadata_frame *frame, int unicode) * \todo * Handle errors. */ -static int paint(struct oshu::metadata_frame *frame) +static int paint(oshu::metadata_frame *frame) { - struct oshu::metadata *meta = &frame->beatmap->metadata; + oshu::metadata *meta = &frame->beatmap->metadata; int title_difference = meta->title && meta->title_unicode && strcmp(meta->title, meta->title_unicode); int artist_difference = meta->artist && meta->artist_unicode && strcmp(meta->artist, meta->artist_unicode); @@ -125,7 +125,7 @@ static int paint(struct oshu::metadata_frame *frame) return 0; } -int oshu::create_metadata_frame(struct oshu::display *display, struct oshu::beatmap *beatmap, double *clock, struct oshu::metadata_frame *frame) +int oshu::create_metadata_frame(oshu::display *display, oshu::beatmap *beatmap, double *clock, oshu::metadata_frame *frame) { memset(frame, 0, sizeof(*frame)); frame->display = display; @@ -134,7 +134,7 @@ int oshu::create_metadata_frame(struct oshu::display *display, struct oshu::beat return paint(frame); } -void oshu::show_metadata_frame(struct oshu::metadata_frame *frame, double opacity) +void oshu::show_metadata_frame(oshu::metadata_frame *frame, double opacity) { SDL_Rect back = { .x = 0, @@ -154,7 +154,7 @@ void oshu::show_metadata_frame(struct oshu::metadata_frame *frame, double opacit if (progression > .9 && has_unicode) transition = 1. - (progression - .9) * 10.; - struct oshu::texture *meta = unicode ? &frame->unicode : &frame->ascii; + oshu::texture *meta = unicode ? &frame->unicode : &frame->ascii; SDL_SetTextureAlphaMod(meta->texture, opacity * transition * 255); oshu::draw_texture(frame->display, meta, 0); @@ -162,7 +162,7 @@ void oshu::show_metadata_frame(struct oshu::metadata_frame *frame, double opacit oshu::draw_texture(frame->display, &frame->stars, std::real(frame->display->view.size)); } -void oshu::destroy_metadata_frame(struct oshu::metadata_frame *frame) +void oshu::destroy_metadata_frame(oshu::metadata_frame *frame) { oshu::destroy_texture(&frame->ascii); oshu::destroy_texture(&frame->unicode); diff --git a/lib/ui/osu.cc b/lib/ui/osu.cc index 5f3ff29..ed987fb 100644 --- a/lib/ui/osu.cc +++ b/lib/ui/osu.cc @@ -14,7 +14,7 @@ #include -static void draw_hint(oshu::osu_ui &view, struct oshu::hit *hit) +static void draw_hint(oshu::osu_ui &view, oshu::hit *hit) { oshu::game_base *game = &view.game; double now = game->clock.now; @@ -30,12 +30,12 @@ static void draw_hint(oshu::osu_ui &view, struct oshu::hit *hit) } } -static void draw_hit_mark(oshu::osu_ui &view, struct oshu::hit *hit) +static void draw_hit_mark(oshu::osu_ui &view, oshu::hit *hit) { oshu::game_base *game = &view.game; if (hit->state == oshu::GOOD_HIT) { double leniency = game->beatmap.difficulty.leniency; - struct oshu::texture *mark = &view.good_mark; + oshu::texture *mark = &view.good_mark; if (hit->offset < - leniency / 2) mark = &view.early_mark; else if (hit->offset > leniency / 2) @@ -48,10 +48,10 @@ static void draw_hit_mark(oshu::osu_ui &view, struct oshu::hit *hit) } } -static void draw_hit_circle(oshu::osu_ui &view, struct oshu::hit *hit) +static void draw_hit_circle(oshu::osu_ui &view, oshu::hit *hit) { oshu::game_base *game = &view.game; - struct oshu::display *display = view.display; + oshu::display *display = view.display; if (hit->state == oshu::INITIAL_HIT) { assert (hit->color != NULL); oshu::draw_texture(display, &view.circles[hit->color->index], hit->p); @@ -61,10 +61,10 @@ static void draw_hit_circle(oshu::osu_ui &view, struct oshu::hit *hit) } } -static void draw_slider(oshu::osu_ui &view, struct oshu::hit *hit) +static void draw_slider(oshu::osu_ui &view, oshu::hit *hit) { oshu::game_base *game = &view.game; - struct oshu::display *display = view.display; + oshu::display *display = view.display; double now = game->clock.now; if (hit->state == oshu::INITIAL_HIT || hit->state == oshu::SLIDING_HIT) { if (!hit->texture) { @@ -84,7 +84,7 @@ static void draw_slider(oshu::osu_ui &view, struct oshu::hit *hit) } } -static void draw_hit(oshu::osu_ui &view, struct oshu::hit *hit) +static void draw_hit(oshu::osu_ui &view, oshu::hit *hit) { oshu::game_base *game = &view.game; if (hit->type & oshu::SLIDER_HIT) @@ -118,7 +118,7 @@ static void draw_hit(oshu::osu_ui &view, struct oshu::hit *hit) * Voilà! * */ -static void connect_hits(oshu::osu_ui &view, struct oshu::hit *a, struct oshu::hit *b) +static void connect_hits(oshu::osu_ui &view, oshu::hit *a, oshu::hit *b) { oshu::game_base *game = &view.game; if (a->state != oshu::INITIAL_HIT && a->state != oshu::SLIDING_HIT) @@ -173,10 +173,10 @@ osu_ui::~osu_ui() void osu_ui::draw() { oshu::osu_view(display); - struct oshu::hit *cursor = oshu::look_hit_up(&game, game.beatmap.difficulty.approach_time); - struct oshu::hit *next = NULL; + oshu::hit *cursor = oshu::look_hit_up(&game, game.beatmap.difficulty.approach_time); + oshu::hit *next = NULL; double now = game.clock.now; - for (struct oshu::hit *hit = cursor; hit; hit = hit->previous) { + for (oshu::hit *hit = cursor; hit; hit = hit->previous) { if (!(hit->type & (oshu::CIRCLE_HIT | oshu::SLIDER_HIT))) continue; if (oshu::hit_end_time(hit) < now - game.beatmap.difficulty.approach_time) @@ -205,7 +205,7 @@ oshu::point osu_mouse::position() } -void oshu::osu_view(struct oshu::display *display) +void oshu::osu_view(oshu::display *display) { oshu::fit_view(&display->view, oshu::size{640, 480}); oshu::resize_view(&display->view, oshu::size{512, 384}); diff --git a/lib/ui/osu_paint.cc b/lib/ui/osu_paint.cc index b8cf305..b1199f4 100644 --- a/lib/ui/osu_paint.cc +++ b/lib/ui/osu_paint.cc @@ -24,7 +24,7 @@ static int paint_approach_circle(oshu::osu_ui &view) double radius = game->beatmap.difficulty.circle_radius + game->beatmap.difficulty.approach_size; oshu::size size = oshu::size(radius * 2., radius * 2.); - struct oshu::painter p; + oshu::painter p; oshu::start_painting(view.display, size, &p); cairo_translate(p.cr, radius, radius); @@ -33,19 +33,19 @@ static int paint_approach_circle(oshu::osu_ui &view) cairo_set_line_width(p.cr, 4); cairo_stroke(p.cr); - struct oshu::texture *texture = &view.approach_circle; + oshu::texture *texture = &view.approach_circle; int rc = oshu::finish_painting(&p, texture); texture->origin = size / 2.; return rc; } -static int paint_circle(oshu::osu_ui &view, struct oshu::color *color, struct oshu::texture *texture) +static int paint_circle(oshu::osu_ui &view, oshu::color *color, oshu::texture *texture) { oshu::game_base *game = &view.game; double radius = game->beatmap.difficulty.circle_radius; oshu::size size = oshu::size(radius * 2., radius * 2.); - struct oshu::painter p; + oshu::painter p; oshu::start_painting(view.display, size, &p); cairo_translate(p.cr, radius, radius); cairo_set_operator(p.cr, CAIRO_OPERATOR_SOURCE); @@ -76,13 +76,13 @@ static int paint_circle(oshu::osu_ui &view, struct oshu::color *color, struct os return rc; } -static void build_path(cairo_t *cr, struct oshu::slider *slider) +static void build_path(cairo_t *cr, oshu::slider *slider) { if (slider->path.type == oshu::LINEAR_PATH) { cairo_move_to(cr, std::real(slider->path.line.start), std::imag(slider->path.line.start)); cairo_line_to(cr, std::real(slider->path.line.end), std::imag(slider->path.line.end)); } else if (slider->path.type == oshu::PERFECT_PATH) { - struct oshu::arc *arc = &slider->path.arc; + oshu::arc *arc = &slider->path.arc; if (arc->start_angle < arc->end_angle) cairo_arc(cr, std::real(arc->center), std::imag(arc->center), arc->radius, arc->start_angle, arc->end_angle); else @@ -108,7 +108,7 @@ static void build_path(cairo_t *cr, struct oshu::slider *slider) * Paint the slider ticks. Preferably updating the ticks every time the slider * repeats. Also, clear the ticks as the slider rolls over them. */ -int oshu::osu_paint_slider(oshu::osu_ui &view, struct oshu::hit *hit) +int oshu::osu_paint_slider(oshu::osu_ui &view, oshu::hit *hit) { oshu::game_base *game = &view.game; int start = SDL_GetTicks(); @@ -118,7 +118,7 @@ int oshu::osu_paint_slider(oshu::osu_ui &view, struct oshu::hit *hit) oshu::path_bounding_box(&hit->slider.path, &top_left, &bottom_right); oshu::size size = bottom_right - top_left + oshu::vector{2, 2} * radius; - struct oshu::painter p; + oshu::painter p; oshu::start_painting(view.display, size, &p); cairo_translate(p.cr, - std::real(top_left) + radius, - std::imag(top_left) + radius); @@ -194,7 +194,7 @@ static int paint_slider_ball(oshu::osu_ui &view) { double radius = game->beatmap.difficulty.slider_tolerance; oshu::size size = oshu::size{1, 1} * radius * 2.; - struct oshu::painter p; + oshu::painter p; oshu::start_painting(view.display, size, &p); cairo_translate(p.cr, radius, radius); @@ -219,19 +219,19 @@ static int paint_slider_ball(oshu::osu_ui &view) { cairo_fill(p.cr); cairo_pattern_destroy(pattern); - struct oshu::texture *texture = &view.slider_ball; + oshu::texture *texture = &view.slider_ball; int rc = oshu::finish_painting(&p, texture); texture->origin = size / 2.; return rc; } -static int paint_good_mark(oshu::osu_ui &view, int offset, struct oshu::texture *texture) +static int paint_good_mark(oshu::osu_ui &view, int offset, oshu::texture *texture) { oshu::game_base *game = &view.game; double radius = game->beatmap.difficulty.circle_radius / 3.5; oshu::size size = oshu::size{1, 1} * radius * 2.; - struct oshu::painter p; + oshu::painter p; oshu::start_painting(view.display, size, &p); cairo_translate(p.cr, radius, radius); @@ -262,7 +262,7 @@ static int paint_bad_mark(oshu::osu_ui &view) double half = game->beatmap.difficulty.circle_radius / 4.7; oshu::size size = oshu::size{1, 1} * (half + 2) * 2.; - struct oshu::painter p; + oshu::painter p; oshu::start_painting(view.display, size, &p); cairo_translate(p.cr, half + 2, half + 2); @@ -277,7 +277,7 @@ static int paint_bad_mark(oshu::osu_ui &view) cairo_stroke(p.cr); - struct oshu::texture *texture = &view.bad_mark; + oshu::texture *texture = &view.bad_mark; int rc = oshu::finish_painting(&p, texture); texture->origin = size / 2.; return rc; @@ -289,7 +289,7 @@ static int paint_skip_mark(oshu::osu_ui &view) double radius = game->beatmap.difficulty.circle_radius / 4.7; oshu::size size = oshu::size{1, 1} * (radius + 2) * 2.; - struct oshu::painter p; + oshu::painter p; oshu::start_painting(view.display, size, &p); cairo_translate(p.cr, radius + 2, radius + 2); @@ -306,7 +306,7 @@ static int paint_skip_mark(oshu::osu_ui &view) cairo_stroke(p.cr); - struct oshu::texture *texture = &view.skip_mark; + oshu::texture *texture = &view.skip_mark; int rc = oshu::finish_painting(&p, texture); texture->origin = size / 2.; return rc; @@ -318,7 +318,7 @@ static int paint_connector(oshu::osu_ui &view) double radius = 3; oshu::size size = oshu::size{1, 1} * radius * 2.; - struct oshu::painter p; + oshu::painter p; oshu::start_painting(view.display, size, &p); cairo_translate(p.cr, radius, radius); @@ -326,7 +326,7 @@ static int paint_connector(oshu::osu_ui &view) cairo_arc(p.cr, 0, 0, radius - 1, 0, 2. * M_PI); cairo_fill(p.cr); - struct oshu::texture *texture = &view.connector; + oshu::texture *texture = &view.connector; int rc = oshu::finish_painting(&p, texture); texture->origin = size / 2.; return rc; @@ -347,7 +347,7 @@ int oshu::osu_paint_resources(oshu::osu_ui &view) assert (game->beatmap.colors != NULL); view.circles = (oshu::texture*) calloc(game->beatmap.color_count, sizeof(*view.circles)); assert (view.circles != NULL); - struct oshu::color *color = game->beatmap.colors; + oshu::color *color = game->beatmap.colors; for (int i = 0; i < game->beatmap.color_count; ++i) { oshu_log_verbose("painting circle for combo color #%d", i); assert (color->index == i); @@ -377,7 +377,7 @@ void oshu::osu_free_resources(oshu::osu_ui &view) oshu::destroy_texture(&view.circles[i]); free(view.circles); } - for (struct oshu::hit *hit = game->beatmap.hits; hit; hit = hit->next) { + for (oshu::hit *hit = game->beatmap.hits; hit; hit = hit->next) { if (hit->texture) { oshu::destroy_texture(hit->texture); free(hit->texture); diff --git a/lib/ui/score.cc b/lib/ui/score.cc index 05844f5..ace2124 100644 --- a/lib/ui/score.cc +++ b/lib/ui/score.cc @@ -12,13 +12,13 @@ #include -int oshu::create_score_frame(struct oshu::display *display, struct oshu::beatmap *beatmap, struct oshu::score_frame *frame) +int oshu::create_score_frame(oshu::display *display, oshu::beatmap *beatmap, oshu::score_frame *frame) { memset(frame, 0, sizeof(*frame)); frame->display = display; frame->beatmap = beatmap; - for (struct oshu::hit *hit = beatmap->hits; hit; hit = hit->next) { + for (oshu::hit *hit = beatmap->hits; hit; hit = hit->next) { if (hit->state == oshu::MISSED_HIT) ++frame->bad; else if (hit->state == oshu::GOOD_HIT) @@ -28,7 +28,7 @@ int oshu::create_score_frame(struct oshu::display *display, struct oshu::beatmap return 0; } -void oshu::show_score_frame(struct oshu::score_frame *frame, double opacity) +void oshu::show_score_frame(oshu::score_frame *frame, double opacity) { int notes = frame->good + frame->bad; if (notes == 0) @@ -62,6 +62,6 @@ void oshu::show_score_frame(struct oshu::score_frame *frame, double opacity) SDL_RenderFillRect(frame->display->renderer, &bad); } -void oshu::destroy_score_frame(struct oshu::score_frame *frame) +void oshu::destroy_score_frame(oshu::score_frame *frame) { } diff --git a/lib/ui/screens/pause.cc b/lib/ui/screens/pause.cc index 8d977ec..d7ba4e4 100644 --- a/lib/ui/screens/pause.cc +++ b/lib/ui/screens/pause.cc @@ -58,7 +58,7 @@ static int update(oshu::shell &w) return 0; } -static void draw_pause(struct oshu::display *display) +static void draw_pause(oshu::display *display) { const double size = 100; const double thickness = 40; diff --git a/lib/ui/screens/screens.h b/lib/ui/screens/screens.h index 667c14b..bfaac68 100644 --- a/lib/ui/screens/screens.h +++ b/lib/ui/screens/screens.h @@ -85,13 +85,13 @@ struct game_screen { }; /* Defined in play.c */ -extern struct oshu::game_screen play_screen; +extern oshu::game_screen play_screen; /* Defined in pause.c */ -extern struct oshu::game_screen pause_screen; +extern oshu::game_screen pause_screen; /* Defined in score.c */ -extern struct oshu::game_screen score_screen; +extern oshu::game_screen score_screen; /** \} */ diff --git a/lib/ui/shell.cc b/lib/ui/shell.cc index dfbaf12..c83f0e4 100644 --- a/lib/ui/shell.cc +++ b/lib/ui/shell.cc @@ -15,7 +15,7 @@ static void set_title(oshu::shell &w) { - struct oshu::metadata *meta = &w.game.beatmap.metadata; + oshu::metadata *meta = &w.game.beatmap.metadata; std::ostringstream title; title << meta->artist << " - " << meta->title << " ♯ " << meta->version << " 𝄞 oshu!"; SDL_SetWindowTitle(w.display.window, title.str().c_str()); diff --git a/lib/video/display.cc b/lib/video/display.cc index 966da99..f970d7e 100644 --- a/lib/video/display.cc +++ b/lib/video/display.cc @@ -80,7 +80,7 @@ int get_features() * The default window size, 960x720 is arbitrary but proportional the the game * area. It's just a saner default for most screens. */ -int create_window(struct oshu::display *display) +int create_window(oshu::display *display) { memset(display, 0, sizeof(*display)); display->features = get_features(); @@ -138,7 +138,7 @@ oshu::display::~display() close_display(this); } -oshu::point oshu::get_mouse(struct oshu::display *display) +oshu::point oshu::get_mouse(oshu::display *display) { int x, y; SDL_GetMouseState(&x, &y); diff --git a/lib/video/paint.cc b/lib/video/paint.cc index ce034fa..91c9f01 100644 --- a/lib/video/paint.cc +++ b/lib/video/paint.cc @@ -12,7 +12,7 @@ #include #include -static void destroy_painter(struct oshu::painter *painter) +static void destroy_painter(oshu::painter *painter) { if (painter->cr) { cairo_destroy(painter->cr); @@ -28,7 +28,7 @@ static void destroy_painter(struct oshu::painter *painter) } } -int oshu::start_painting(struct oshu::display *display, oshu::size size, struct oshu::painter *painter) +int oshu::start_painting(oshu::display *display, oshu::size size, oshu::painter *painter) { cairo_status_t s; memset(painter, 0, sizeof(*painter)); @@ -101,7 +101,7 @@ static void unpremultiply(SDL_Surface *surface) } } -int oshu::finish_painting(struct oshu::painter *painter, struct oshu::texture *texture) +int oshu::finish_painting(oshu::painter *painter, oshu::texture *texture) { int rc = 0; unpremultiply(painter->destination); diff --git a/lib/video/texture.cc b/lib/video/texture.cc index 5738651..7039e45 100644 --- a/lib/video/texture.cc +++ b/lib/video/texture.cc @@ -10,7 +10,7 @@ #include -int oshu::load_texture(struct oshu::display *display, const char *filename, struct oshu::texture *texture) +int oshu::load_texture(oshu::display *display, const char *filename, oshu::texture *texture) { texture->texture = IMG_LoadTexture(display->renderer, filename); if (!texture->texture) { @@ -24,7 +24,7 @@ int oshu::load_texture(struct oshu::display *display, const char *filename, stru return 0; } -void oshu::destroy_texture(struct oshu::texture *texture) +void oshu::destroy_texture(oshu::texture *texture) { if (texture->texture) { SDL_DestroyTexture(texture->texture); @@ -32,7 +32,7 @@ void oshu::destroy_texture(struct oshu::texture *texture) } } -void oshu::draw_scaled_texture(struct oshu::display *display, struct oshu::texture *texture, oshu::point p, double ratio) +void oshu::draw_scaled_texture(oshu::display *display, oshu::texture *texture, oshu::point p, double ratio) { oshu::point top_left = oshu::project(&display->view, p - texture->origin * ratio); oshu::size size = texture->size * ratio * display->view.zoom; @@ -43,7 +43,7 @@ void oshu::draw_scaled_texture(struct oshu::display *display, struct oshu::textu SDL_RenderCopy(display->renderer, texture->texture, NULL, &dest); } -void oshu::draw_texture(struct oshu::display *display, struct oshu::texture *texture, oshu::point p) +void oshu::draw_texture(oshu::display *display, oshu::texture *texture, oshu::point p) { oshu::draw_scaled_texture(display, texture, p, 1.); } diff --git a/lib/video/view.cc b/lib/video/view.cc index 597cb17..f018693 100644 --- a/lib/video/view.cc +++ b/lib/video/view.cc @@ -9,19 +9,19 @@ #include -void oshu::scale_view(struct oshu::view *view, double factor) +void oshu::scale_view(oshu::view *view, double factor) { view->zoom *= factor; view->size /= factor; } -void oshu::resize_view(struct oshu::view *view, oshu::size size) +void oshu::resize_view(oshu::view *view, oshu::size size) { view->origin += view->zoom * (view->size - size) / 2.; view->size = size; } -void oshu::fit_view(struct oshu::view *view, oshu::size size) +void oshu::fit_view(oshu::view *view, oshu::size size) { double wanted_ratio = oshu::ratio(size); double current_ratio = oshu::ratio(view->size); @@ -35,17 +35,17 @@ void oshu::fit_view(struct oshu::view *view, oshu::size size) oshu::resize_view(view, size); } -oshu::point oshu::project(struct oshu::view *view, oshu::point p) +oshu::point oshu::project(oshu::view *view, oshu::point p) { return p * view->zoom + view->origin; } -oshu::point oshu::unproject(struct oshu::view *view, oshu::point p) +oshu::point oshu::unproject(oshu::view *view, oshu::point p) { return (p - view->origin) / view->zoom; } -void oshu::reset_view(struct oshu::display *display) +void oshu::reset_view(oshu::display *display) { int w, h; SDL_GetWindowSize(display->window, &w, &h);