Переглянути джерело

Update configs

Use appropriate syntax and names for config logic.
master
TheoryOfNekomata 1 рік тому
джерело
коміт
8ea5d36a6b
9 змінених файлів з 55 додано та 59 видалено
  1. +1
    -1
      src/packages/config/IZ_config_guid.h
  2. +8
    -4
      src/packages/game/input/IZ_joystick.c
  3. +1
    -1
      src/packages/game/input/IZ_keyboard.c
  4. +5
    -11
      src/packages/game/input/IZ_midi.c
  5. +9
    -3
      src/packages/game/output/video/IZ_video.c
  6. +25
    -21
      src/packages/net/IZ_net_client.c
  7. +4
    -13
      src/packages/net/IZ_net_server.c
  8. +1
    -4
      src/packages/server/db/IZ_repo.c
  9. +1
    -1
      subprojects/ini-config

+ 1
- 1
src/packages/config/IZ_config_guid.h Переглянути файл

@@ -8,7 +8,7 @@ void INI_ConfigLoadGuid(INI_ConfigItem*, const char*);
INI_ConfigSaveItemResult INI_ConfigSaveGuid(INI_ConfigItem*, const char*);
void INI_ConfigOverrideGuid(INI_ConfigItem*, uint8_t, const char*[]);

#define INI_CONFIG_TYPE_FNS_GUID (INI_ConfigTypeFns) { \
#define INI_CONFIG_TYPE_GUID (INI_ConfigType) { \
.size = sizeof(SDL_GUID), \
.load = INI_ConfigLoadGuid, \
.save = INI_ConfigSaveGuid, \


+ 8
- 4
src/packages/game/input/IZ_joystick.c Переглянути файл

@@ -204,32 +204,35 @@ void IZ_JoystickInitializeConfigItems(INI_ConfigItem config_items[]) {
sprintf(main_section_name, "Joystick.%d", player_index);
u8 base_index = (player_index * (IZ_CONTROLS - 4 + 2));
config_items[base_index] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_I32,
INI_CONFIG_TYPE_I32,
main_section_name,
"DeviceID",
NULL,
&IZ_JOYSTICK_DEFAULT_STATE[player_index].config.device_id,
NULL,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};

config_items[base_index + 1] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_U16,
INI_CONFIG_TYPE_U16,
main_section_name,
"AxisThreshold",
NULL,
&IZ_JOYSTICK_DEFAULT_STATE[player_index].config.axis_threshold,
IZ_JoystickIsValidAxisThreshold,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};

config_items[base_index + 2] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_GUID,
INI_CONFIG_TYPE_GUID,
main_section_name,
"GUID",
NULL,
&IZ_JOYSTICK_DEFAULT_STATE[player_index].config.guid,
NULL,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};

@@ -239,12 +242,13 @@ void IZ_JoystickInitializeConfigItems(INI_ConfigItem config_items[]) {
sprintf(control_mapping_section_name, "Joystick.%d.ControlMapping", player_index);
for (control_index = 4; control_index < IZ_CONTROLS; control_index += 1) {
config_items[base_index + 3 + (control_index - 4)] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_U8,
INI_CONFIG_TYPE_U8,
control_mapping_section_name,
IZ_ACTION_NAMES[control_index],
NULL,
&IZ_JOYSTICK_DEFAULT_STATE[player_index].config.control_mapping[control_index],
NULL,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};
}


+ 1
- 1
src/packages/game/input/IZ_keyboard.c Переглянути файл

@@ -58,7 +58,7 @@ void IZ_KeyboardInitializeConfigItems(INI_ConfigItem config_items[]) {
sprintf(control_mapping_section_name, "Keyboard.%d.ControlMapping", player_index);
for (control_index = 0; control_index < IZ_CONTROLS; control_index += 1) {
config_items[player_index * IZ_CONTROLS + control_index] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_I32,
INI_CONFIG_TYPE_I32,
control_mapping_section_name,
IZ_ACTION_NAMES[control_index],
NULL,


+ 5
- 11
src/packages/game/input/IZ_midi.c Переглянути файл

@@ -81,30 +81,24 @@ void IZ_MIDIInputInitializeConfigItems(INI_ConfigItem config_items[]) {

u16 base_index = (player_index * (IZ_CONTROLS + 2));
config_items[base_index] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_I32,
INI_CONFIG_TYPE_I32,
main_section_name,
"DeviceID",
NULL,
&IZ_MIDI_INPUT_DEFAULT_STATE[player_index].config.device_id,
NULL,
{
.serialize = NULL,
.deserialize = NULL,
},
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};

config_items[base_index + 1] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_U8,
INI_CONFIG_TYPE_U8,
main_section_name,
"Channel",
NULL,
&IZ_MIDI_INPUT_DEFAULT_STATE[player_index].config.channel,
IZ_MIDIInputIsValidChannel,
{
.serialize = NULL,
.deserialize = NULL,
},
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};

@@ -112,7 +106,7 @@ void IZ_MIDIInputInitializeConfigItems(INI_ConfigItem config_items[]) {
sprintf(control_mapping_section_name, "MIDIInput.%d.ControlMapping", player_index);
for (control_index = 0; control_index < IZ_CONTROLS; control_index += 1) {
config_items[base_index + 2 + control_index] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_U8,
INI_CONFIG_TYPE_U8,
control_mapping_section_name,
IZ_ACTION_NAMES[control_index],
NULL,


+ 9
- 3
src/packages/game/output/video/IZ_video.c Переглянути файл

@@ -16,28 +16,34 @@ bool IZ_VideoIsValidMaxFPS(u8 max_fps) {

static INI_ConfigItem video_config_items[] = {
{
INI_CONFIG_TYPE_FNS_U16,
INI_CONFIG_TYPE_U16,
"Video",
"Width",
NULL,
&IZ_VIDEO_DEFAULT_STATE.config.width,
IZ_VideoIsValidWidth,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
},
{
INI_CONFIG_TYPE_FNS_U16,
INI_CONFIG_TYPE_U16,
"Video",
"Height",
NULL,
&IZ_VIDEO_DEFAULT_STATE.config.height,
IZ_VideoIsValidHeight,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
},
{
INI_CONFIG_TYPE_FNS_U8,
INI_CONFIG_TYPE_U8,
"Video",
"MaxFps",
"-f",
&IZ_VIDEO_DEFAULT_STATE.config.max_fps,
IZ_VideoIsValidMaxFPS,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
},
INI_CONFIG_ITEM_NULL,
};


+ 25
- 21
src/packages/net/IZ_net_client.c Переглянути файл

@@ -16,31 +16,34 @@ static INI_ConfigItem net_client_config_items[IZ_PLAYERS + 3 + 1];

void IZ_NetClientInitializeConfigItems(INI_ConfigItem config_items[]) {
config_items[0] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_U16,
"Network",
"PacketIntervalMs",
"-i",
&IZ_NET_CLIENT_DEFAULT_STATE.config.packet_interval_ms,
IZ_NetClientIsValidPacketIntervalMs,
NULL,
INI_CONFIG_TYPE_U16,
"Network",
"PacketIntervalMs",
"-i",
&IZ_NET_CLIENT_DEFAULT_STATE.config.packet_interval_ms,
IZ_NetClientIsValidPacketIntervalMs,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};
config_items[1] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_U8,
"Network",
"MaxReconnectRetries",
NULL,
&IZ_NET_CLIENT_DEFAULT_STATE.config.max_reconnect_retries,
IZ_NetClientIsValidMaxReconnectRetries,
NULL,
INI_CONFIG_TYPE_U8,
"Network",
"MaxReconnectRetries",
NULL,
&IZ_NET_CLIENT_DEFAULT_STATE.config.max_reconnect_retries,
IZ_NetClientIsValidMaxReconnectRetries,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};
config_items[2] = (INI_ConfigItem) {
INI_CONFIG_TYPE_FNS_U8,
"Network",
"ReconnectIntervalSeconds",
NULL,
&IZ_NET_CLIENT_DEFAULT_STATE.config.reconnect_interval_secs,
IZ_NetClientIsValidReconnectIntervalSeconds,
NULL,
INI_CONFIG_TYPE_U8,
"Network",
"ReconnectIntervalSeconds",
NULL,
&IZ_NET_CLIENT_DEFAULT_STATE.config.reconnect_interval_secs,
IZ_NetClientIsValidReconnectIntervalSeconds,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};

u8 player_index;
@@ -55,6 +58,7 @@ void IZ_NetClientInitializeConfigItems(INI_ConfigItem config_items[]) {
NULL,
&IZ_NET_CLIENT_DEFAULT_STATE.config.usernames[player_index],
NULL,
INI_CONFIG_TRANSFORMER_NONE,
NULL,
};
}


+ 4
- 13
src/packages/net/IZ_net_server.c Переглянути файл

@@ -12,10 +12,7 @@ static INI_ConfigItem net_server_config_items[] = {
"-n",
&IZ_NET_SERVER_DEFAULT_STATE.config.name,
NULL,
{
.serialize = NULL,
.deserialize = NULL,
},
INI_CONFIG_TRANSFORMER_NONE,
NULL,
},
{
@@ -25,23 +22,17 @@ static INI_ConfigItem net_server_config_items[] = {
"-m",
&IZ_NET_SERVER_DEFAULT_STATE.config.motd,
NULL,
{
.serialize = NULL,
.deserialize = NULL,
},
INI_CONFIG_TRANSFORMER_NONE,
NULL,
},
{
INI_CONFIG_TYPE_FNS_U16,
INI_CONFIG_TYPE_U16,
"Network",
"Port",
"-p",
&IZ_NET_SERVER_DEFAULT_STATE.config.port,
IZ_NetServerIsValidPort,
{
.serialize = NULL,
.deserialize = NULL,
},
INI_CONFIG_TRANSFORMER_NONE,
NULL,
},
INI_CONFIG_ITEM_NULL,


+ 1
- 4
src/packages/server/db/IZ_repo.c Переглянути файл

@@ -8,10 +8,7 @@ static INI_ConfigItem repo_config_items[] = {
"-d",
&IZ_REPO_DEFAULT_STATE.config.path,
NULL,
{
.serialize = NULL,
.deserialize = NULL,
},
INI_CONFIG_TRANSFORMER_NONE,
NULL,
},
INI_CONFIG_ITEM_NULL,


+ 1
- 1
subprojects/ini-config

@@ -1 +1 @@
Subproject commit 6dbbef47a430649aec60a327512379b8dc0719a3
Subproject commit 482c2faf41a8dd2c2a65acf0c41649d310dba3c8

Завантаження…
Відмінити
Зберегти