<commit_before>#include "game/utils/settings.h"
#include "controller/controller.h"
#include "utils/config.h"
#include "utils/log.h"
#include <stddef.h> //offsetof
#include <stdlib.h>
#include <string.h>

#define F_INT(struct_, var, def) {#var, TYPE_INT, {.i=def}, offsetof(struct_, var)}
#define F_BOOL(struct_, var, def) {#var, TYPE_BOOL, {.b=def}, offsetof(struct_, var)}
#define F_FLOAT(struct_, var, def) {#var, TYPE_FLOAT, {.f=def}, offsetof(struct_, var)}
#define F_STRING(struct_, var, def) {#var, TYPE_STRING, {.s=def}, offsetof(struct_, var)}

#define NFIELDS(struct_) sizeof(struct_)/sizeof(field)

#define S_2_F(struct_, field) {struct_, field, NFIELDS(field)}

static settings _settings;
static const char *settings_path;

typedef enum field_type_t {
    TYPE_INT,
    TYPE_FLOAT,
    TYPE_BOOL,
    TYPE_STRING
} field_type;

typedef union field_default_u {
    char *s;
    int i;
    int b;
    double f;
} field_default;

typedef struct field_t {
    char *name;
    field_type type;
    field_default def;
    int offset;
} field;

typedef struct struct_to_field_t {
    void *_struct;
    const field *fields;
    int num_fields;
} struct_to_field;

const field f_video[] = {
    F_INT(settings_video,  screen_w,       640),
    F_INT(settings_video,  screen_h,       400),
    F_BOOL(settings_video, vsync,            0),
    F_BOOL(settings_video, fullscreen,       0),
    F_INT(settings_video,  scaling,          0),
    F_BOOL(settings_video, instant_console,  0),
    F_BOOL(settings_video, crossfade_on,     1),
    F_STRING(settings_video, scaler, "Nearest"),
    F_INT(settings_video,  scale_factor,     1),
};

const field f_sound[] = {
    F_STRING(settings_sound, sink,            "openal"),
    F_BOOL(settings_sound, music_mono,        0),
    F_INT(settings_sound,  sound_vol,         5),
    F_INT(settings_sound,  music_vol,         5),
    F_INT(settings_sound,  music_frequency,   44100),
#if USE_DUMB
    F_INT(settings_sound, music_library,      0),
    F_INT(settings_sound, music_resampler,    1),
#elif USE_MODPLUG
    F_INT(settings_sound, music_library,      1),
    F_INT(settings_sound, music_resampler,    0),
#elif USE_XMP
    F_INT(settings_sound, music_library,      2),
    F_INT(settings_sound, music_resampler,    1),
#endif
    F_STRING(settings_sound, music_arena0,    ""),
    F_STRING(settings_sound, music_arena1,    ""),
    F_STRING(settings_sound, music_arena2,    ""),
    F_STRING(settings_sound, music_arena3,    ""),
    F_STRING(settings_sound, music_arena4,    ""),
    F_STRING(settings_sound, music_end,       ""),
    F_STRING(settings_sound, music_menu,      "")
};

const field f_gameplay[] = {
    F_INT(settings_gameplay,  speed,       5),
    F_INT(settings_gameplay,  fight_mode,  0),
    F_INT(settings_gameplay,  power1,      5),
    F_INT(settings_gameplay,  power2,      5),
    F_BOOL(settings_gameplay, hazards_on,  1),
    F_INT(settings_gameplay,  difficulty,  1),
    F_INT(settings_gameplay,  rounds,      1)
};
<commit_msg>Change preferred module player order<commit_after>#include "game/utils/settings.h"
#include "controller/controller.h"
#include "utils/config.h"
#include "utils/log.h"
#include <stddef.h> //offsetof
#include <stdlib.h>
#include <string.h>

#define F_INT(struct_, var, def) {#var, TYPE_INT, {.i=def}, offsetof(struct_, var)}
#define F_BOOL(struct_, var, def) {#var, TYPE_BOOL, {.b=def}, offsetof(struct_, var)}
#define F_FLOAT(struct_, var, def) {#var, TYPE_FLOAT, {.f=def}, offsetof(struct_, var)}
#define F_STRING(struct_, var, def) {#var, TYPE_STRING, {.s=def}, offsetof(struct_, var)}

#define NFIELDS(struct_) sizeof(struct_)/sizeof(field)

#define S_2_F(struct_, field) {struct_, field, NFIELDS(field)}

static settings _settings;
static const char *settings_path;

typedef enum field_type_t {
    TYPE_INT,
    TYPE_FLOAT,
    TYPE_BOOL,
    TYPE_STRING
} field_type;

typedef union field_default_u {
    char *s;
    int i;
    int b;
    double f;
} field_default;

typedef struct field_t {
    char *name;
    field_type type;
    field_default def;
    int offset;
} field;

typedef struct struct_to_field_t {
    void *_struct;
    const field *fields;
    int num_fields;
} struct_to_field;

const field f_video[] = {
    F_INT(settings_video,  screen_w,       640),
    F_INT(settings_video,  screen_h,       400),
    F_BOOL(settings_video, vsync,            0),
    F_BOOL(settings_video, fullscreen,       0),
    F_INT(settings_video,  scaling,          0),
    F_BOOL(settings_video, instant_console,  0),
    F_BOOL(settings_video, crossfade_on,     1),
    F_STRING(settings_video, scaler, "Nearest"),
    F_INT(settings_video,  scale_factor,     1),
};

const field f_sound[] = {
    F_STRING(settings_sound, sink,            "openal"),
    F_BOOL(settings_sound, music_mono,        0),
    F_INT(settings_sound,  sound_vol,         5),
    F_INT(settings_sound,  music_vol,         5),
    F_INT(settings_sound,  music_frequency,   44100),
#if USE_DUMB
    F_INT(settings_sound, music_library,      0),
    F_INT(settings_sound, music_resampler,    1),
#elif USE_XMP
    F_INT(settings_sound, music_library,      2),
    F_INT(settings_sound, music_resampler,    1),
#elif USE_MODPLUG
    F_INT(settings_sound, music_library,      1),
    F_INT(settings_sound, music_resampler,    0),
#endif
    F_STRING(settings_sound, music_arena0,    ""),
    F_STRING(settings_sound, music_arena1,    ""),
    F_STRING(settings_sound, music_arena2,    ""),
    F_STRING(settings_sound, music_arena3,    ""),
    F_STRING(settings_sound, music_arena4,    ""),
    F_STRING(settings_sound, music_end,       ""),
    F_STRING(settings_sound, music_menu,      "")
};

const field f_gameplay[] = {
    F_INT(settings_gameplay,  speed,       5),
    F_INT(settings_gameplay,  fight_mode,  0),
    F_INT(settings_gameplay,  power1,      5),
    F_INT(settings_gameplay,  power2,      5),
    F_BOOL(settings_gameplay, hazards_on,  1),
    F_INT(settings_gameplay,  difficulty,  1),
    F_INT(settings_gameplay,  rounds,      1)
};

{'fraction_non_alphanumeric': 0.12212477246400795, 'fraction_numerical': 0.013569419162667549, 'mean_word_length': 3.6961926961926963, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '484997', 'n_tokens_mistral': 2237, 'n_tokens_neox': 2194, 'n_words': 446}