summaryrefslogtreecommitdiff
path: root/src/setup
diff options
context:
space:
mode:
authorSimon Howard2015-02-20 00:31:09 -0500
committerSimon Howard2015-02-20 00:33:12 -0500
commitb39121c6a682eb8ae5efd29a875bd7c098185f04 (patch)
treec6a8b42412682c49d73aff7c794e333e55c807bc /src/setup
parent1f5ce047ad6cb709f746b794b4a2dea9e2f89fb6 (diff)
downloadchocolate-doom-b39121c6a682eb8ae5efd29a875bd7c098185f04.tar.gz
chocolate-doom-b39121c6a682eb8ae5efd29a875bd7c098185f04.tar.bz2
chocolate-doom-b39121c6a682eb8ae5efd29a875bd7c098185f04.zip
Refactor config file API.
The config file API previously relied on binding config variables using M_BindVariable() which took a void pointer. It occurred to me that if used on a boolean variable, this would be erroneous, but the void pointer would make it impossible to tell. Split this into separate M_Bind{Foo}Variable() functions based on type, which allows for proper type checking on the pointers that are passed. Vaguely related to #509.
Diffstat (limited to 'src/setup')
-rw-r--r--src/setup/compatibility.c4
-rw-r--r--src/setup/display.c26
-rw-r--r--src/setup/joystick.c18
-rw-r--r--src/setup/keyboard.c2
-rw-r--r--src/setup/mode.c19
-rw-r--r--src/setup/mouse.c12
-rw-r--r--src/setup/multiplayer.c4
-rw-r--r--src/setup/sound.c50
8 files changed, 69 insertions, 66 deletions
diff --git a/src/setup/compatibility.c b/src/setup/compatibility.c
index 83dabdc8..df202117 100644
--- a/src/setup/compatibility.c
+++ b/src/setup/compatibility.c
@@ -43,8 +43,8 @@ void BindCompatibilityVariables(void)
{
if (gamemission == doom || gamemission == strife)
{
- M_BindVariable("vanilla_savegame_limit", &vanilla_savegame_limit);
- M_BindVariable("vanilla_demo_limit", &vanilla_demo_limit);
+ M_BindIntVariable("vanilla_savegame_limit", &vanilla_savegame_limit);
+ M_BindIntVariable("vanilla_demo_limit", &vanilla_demo_limit);
}
}
diff --git a/src/setup/display.c b/src/setup/display.c
index 090fd445..1398aaf0 100644
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -700,28 +700,28 @@ void ConfigDisplay(void)
void BindDisplayVariables(void)
{
- M_BindVariable("autoadjust_video_settings", &autoadjust_video_settings);
- M_BindVariable("aspect_ratio_correct", &aspect_ratio_correct);
- M_BindVariable("fullscreen", &fullscreen);
- M_BindVariable("screen_width", &screen_width);
- M_BindVariable("screen_height", &screen_height);
- M_BindVariable("screen_bpp", &screen_bpp);
- M_BindVariable("startup_delay", &startup_delay);
- M_BindVariable("video_driver", &video_driver);
- M_BindVariable("window_position", &window_position);
- M_BindVariable("usegamma", &usegamma);
- M_BindVariable("png_screenshots", &png_screenshots);
+ M_BindIntVariable("autoadjust_video_settings", &autoadjust_video_settings);
+ M_BindIntVariable("aspect_ratio_correct", &aspect_ratio_correct);
+ M_BindIntVariable("fullscreen", &fullscreen);
+ M_BindIntVariable("screen_width", &screen_width);
+ M_BindIntVariable("screen_height", &screen_height);
+ M_BindIntVariable("screen_bpp", &screen_bpp);
+ M_BindIntVariable("startup_delay", &startup_delay);
+ M_BindStringVariable("video_driver", &video_driver);
+ M_BindStringVariable("window_position", &window_position);
+ M_BindIntVariable("usegamma", &usegamma);
+ M_BindIntVariable("png_screenshots", &png_screenshots);
if (gamemission == doom || gamemission == heretic
|| gamemission == strife)
{
- M_BindVariable("show_endoom", &show_endoom);
+ M_BindIntVariable("show_endoom", &show_endoom);
}
if (gamemission == heretic || gamemission == hexen || gamemission == strife)
{
- M_BindVariable("graphical_startup", &graphical_startup);
+ M_BindIntVariable("graphical_startup", &graphical_startup);
}
// Windows Vista or later? Set screen color depth to
diff --git a/src/setup/joystick.c b/src/setup/joystick.c
index 49931312..dc94b2f0 100644
--- a/src/setup/joystick.c
+++ b/src/setup/joystick.c
@@ -757,20 +757,20 @@ void BindJoystickVariables(void)
{
int i;
- M_BindVariable("use_joystick", &usejoystick);
- M_BindVariable("joystick_index", &joystick_index);
- M_BindVariable("joystick_x_axis", &joystick_x_axis);
- M_BindVariable("joystick_y_axis", &joystick_y_axis);
- M_BindVariable("joystick_strafe_axis", &joystick_strafe_axis);
- M_BindVariable("joystick_x_invert", &joystick_x_invert);
- M_BindVariable("joystick_y_invert", &joystick_y_invert);
- M_BindVariable("joystick_strafe_invert",&joystick_strafe_invert);
+ M_BindIntVariable("use_joystick", &usejoystick);
+ M_BindIntVariable("joystick_index", &joystick_index);
+ M_BindIntVariable("joystick_x_axis", &joystick_x_axis);
+ M_BindIntVariable("joystick_y_axis", &joystick_y_axis);
+ M_BindIntVariable("joystick_strafe_axis", &joystick_strafe_axis);
+ M_BindIntVariable("joystick_x_invert", &joystick_x_invert);
+ M_BindIntVariable("joystick_y_invert", &joystick_y_invert);
+ M_BindIntVariable("joystick_strafe_invert", &joystick_strafe_invert);
for (i = 0; i < NUM_VIRTUAL_BUTTONS; ++i)
{
char name[32];
M_snprintf(name, sizeof(name), "joystick_physical_button%i", i);
- M_BindVariable(name, &joystick_physical_buttons[i]);
+ M_BindIntVariable(name, &joystick_physical_buttons[i]);
}
}
diff --git a/src/setup/keyboard.c b/src/setup/keyboard.c
index 2964606b..0d672436 100644
--- a/src/setup/keyboard.c
+++ b/src/setup/keyboard.c
@@ -408,5 +408,5 @@ void ConfigKeyboard(void)
void BindKeyboardVariables(void)
{
- M_BindVariable("vanilla_keyboard_mapping", &vanilla_keyboard_mapping);
+ M_BindIntVariable("vanilla_keyboard_mapping", &vanilla_keyboard_mapping);
}
diff --git a/src/setup/mode.c b/src/setup/mode.c
index d0e1f201..ed637849 100644
--- a/src/setup/mode.c
+++ b/src/setup/mode.c
@@ -115,14 +115,14 @@ static void BindMiscVariables(void)
{
if (gamemission == doom)
{
- M_BindVariable("detaillevel", &detailLevel);
- M_BindVariable("show_messages", &showMessages);
+ M_BindIntVariable("detaillevel", &detailLevel);
+ M_BindIntVariable("show_messages", &showMessages);
}
if (gamemission == hexen)
{
- M_BindVariable("savedir", &savedir);
- M_BindVariable("messageson", &showMessages);
+ M_BindStringVariable("savedir", &savedir);
+ M_BindIntVariable("messageson", &showMessages);
// Hexen has a variable to control the savegame directory
// that is used.
@@ -140,14 +140,15 @@ static void BindMiscVariables(void)
if (gamemission == strife)
{
- M_BindVariable("back_flat", &back_flat);
- M_BindVariable("screensize" , &screenblocks);
- M_BindVariable("comport", &comport);
- M_BindVariable("nickname", &nickname);
+ M_BindStringVariable("back_flat", &back_flat);
+ M_BindStringVariable("nickname", &nickname);
+
+ M_BindIntVariable("screensize", &screenblocks);
+ M_BindIntVariable("comport", &comport);
}
else
{
- M_BindVariable("screenblocks", &screenblocks);
+ M_BindIntVariable("screenblocks", &screenblocks);
}
}
diff --git a/src/setup/mouse.c b/src/setup/mouse.c
index 1d7ed68e..9fdfc833 100644
--- a/src/setup/mouse.c
+++ b/src/setup/mouse.c
@@ -153,10 +153,10 @@ void ConfigMouse(void)
void BindMouseVariables(void)
{
- M_BindVariable("use_mouse", &usemouse);
- M_BindVariable("novert", &novert);
- M_BindVariable("mouse_sensitivity", &mouseSensitivity);
- M_BindVariable("mouse_acceleration", &mouse_acceleration);
- M_BindVariable("mouse_threshold", &mouse_threshold);
- M_BindVariable("grabmouse", &grabmouse);
+ M_BindIntVariable("use_mouse", &usemouse);
+ M_BindIntVariable("novert", &novert);
+ M_BindIntVariable("grabmouse", &grabmouse);
+ M_BindIntVariable("mouse_sensitivity", &mouseSensitivity);
+ M_BindIntVariable("mouse_threshold", &mouse_threshold);
+ M_BindFloatVariable("mouse_acceleration", &mouse_acceleration);
}
diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c
index 8e123b03..6b294077 100644
--- a/src/setup/multiplayer.c
+++ b/src/setup/multiplayer.c
@@ -1127,13 +1127,13 @@ void BindMultiplayerVariables(void)
int i;
#ifdef FEATURE_MULTIPLAYER
- M_BindVariable("player_name", &net_player_name);
+ M_BindStringVariable("player_name", &net_player_name);
#endif
for (i=0; i<10; ++i)
{
M_snprintf(buf, sizeof(buf), "chatmacro%i", i);
- M_BindVariable(buf, &chat_macros[i]);
+ M_BindStringVariable(buf, &chat_macros[i]);
}
switch (gamemission)
diff --git a/src/setup/sound.c b/src/setup/sound.c
index 2b9bfcbb..e7670feb 100644
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -81,7 +81,7 @@ static float libsamplerate_scale = 0.65;
static char *timidity_cfg_path = NULL;
static char *gus_patch_path = NULL;
-static unsigned int gus_ram_kb = 1024;
+static int gus_ram_kb = 1024;
// DOS specific variables: these are unused but should be maintained
// so that the config file can be shared between chocolate
@@ -297,32 +297,34 @@ void ConfigSound(void)
void BindSoundVariables(void)
{
- M_BindVariable("snd_sfxdevice", &snd_sfxdevice);
- M_BindVariable("snd_musicdevice", &snd_musicdevice);
- M_BindVariable("snd_channels", &numChannels);
- M_BindVariable("sfx_volume", &sfxVolume);
- M_BindVariable("music_volume", &musicVolume);
- M_BindVariable("snd_samplerate", &snd_samplerate);
- M_BindVariable("use_libsamplerate", &use_libsamplerate);
- M_BindVariable("libsamplerate_scale", &libsamplerate_scale);
- M_BindVariable("timidity_cfg_path", &timidity_cfg_path);
- M_BindVariable("gus_patch_path", &gus_patch_path);
- M_BindVariable("gus_ram_kb", &gus_ram_kb);
-
- M_BindVariable("snd_sbport", &snd_sbport);
- M_BindVariable("snd_sbirq", &snd_sbirq);
- M_BindVariable("snd_sbdma", &snd_sbdma);
- M_BindVariable("snd_mport", &snd_mport);
- M_BindVariable("snd_maxslicetime_ms", &snd_maxslicetime_ms);
- M_BindVariable("snd_musiccmd", &snd_musiccmd);
-
- M_BindVariable("snd_cachesize", &snd_cachesize);
- M_BindVariable("opl_io_port", &opl_io_port);
+ M_BindIntVariable("snd_sfxdevice", &snd_sfxdevice);
+ M_BindIntVariable("snd_musicdevice", &snd_musicdevice);
+ M_BindIntVariable("snd_channels", &numChannels);
+ M_BindIntVariable("snd_samplerate", &snd_samplerate);
+ M_BindIntVariable("sfx_volume", &sfxVolume);
+ M_BindIntVariable("music_volume", &musicVolume);
+
+ M_BindIntVariable("use_libsamplerate", &use_libsamplerate);
+ M_BindFloatVariable("libsamplerate_scale", &libsamplerate_scale);
+
+ M_BindIntVariable("gus_ram_kb", &gus_ram_kb);
+ M_BindStringVariable("gus_patch_path", &gus_patch_path);
+ M_BindStringVariable("timidity_cfg_path", &timidity_cfg_path);
+
+ M_BindIntVariable("snd_sbport", &snd_sbport);
+ M_BindIntVariable("snd_sbirq", &snd_sbirq);
+ M_BindIntVariable("snd_sbdma", &snd_sbdma);
+ M_BindIntVariable("snd_mport", &snd_mport);
+ M_BindIntVariable("snd_maxslicetime_ms", &snd_maxslicetime_ms);
+ M_BindStringVariable("snd_musiccmd", &snd_musiccmd);
+
+ M_BindIntVariable("snd_cachesize", &snd_cachesize);
+ M_BindIntVariable("opl_io_port", &opl_io_port);
if (gamemission == strife)
{
- M_BindVariable("voice_volume", &voiceVolume);
- M_BindVariable("show_talk", &show_talk);
+ M_BindIntVariable("voice_volume", &voiceVolume);
+ M_BindIntVariable("show_talk", &show_talk);
}
timidity_cfg_path = M_StringDuplicate("");