From b868352951acee0e556d702e5e90aa67d9a2b39e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 11 Sep 2008 21:03:48 +0000 Subject: Refactor configuration file system to allow configuration file variables to be bound in a distributed fashion around the program. Remove dependency of m_config.c on doom/. Subversion-branch: /branches/raven-branch Subversion-revision: 1222 --- src/doom/d_main.c | 44 ++++++++++++++++++++++++++++++++++++++++---- src/doom/g_game.h | 3 +++ src/doom/hu_stuff.c | 2 +- src/doom/hu_stuff.h | 2 ++ src/doom/s_sound.c | 22 +++++++++++----------- src/doom/s_sound.h | 1 + 6 files changed, 58 insertions(+), 16 deletions(-) (limited to 'src/doom') diff --git a/src/doom/d_main.c b/src/doom/d_main.c index c84783bc..ef5c4317 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -55,6 +55,7 @@ #include "m_argv.h" #include "m_config.h" +#include "m_controls.h" #include "m_misc.h" #include "m_menu.h" #include "p_saveg.h" @@ -335,6 +336,39 @@ void D_Display (void) } while (!done); } +// +// Add configuration file variable bindings. +// + +void D_BindVariables(void) +{ + int i; + + I_BindVariables(); + M_BindBaseControls(); + NET_BindVariables(); + + M_BindVariable("mouse_sensitivity", &mouseSensitivity); + M_BindVariable("sfx_volume", &sfxVolume); + M_BindVariable("music_volume", &musicVolume); + M_BindVariable("show_messages", &showMessages); + M_BindVariable("screenblocks", &screenblocks); + M_BindVariable("detaillevel", &detailLevel); + M_BindVariable("snd_channels", &snd_channels); + M_BindVariable("vanilla_savegame_limit", &vanilla_savegame_limit); + M_BindVariable("vanilla_demo_limit", &vanilla_demo_limit); + + // Multiplayer chat macros + + for (i=0; i<10; ++i) + { + char buf[12]; + + sprintf(buf, "chatmacro%i", i); + M_BindVariable(buf, &chat_macros[i]); + } +} + // // D_GrabMouseCallback // @@ -944,11 +978,13 @@ void D_DoomMain (void) } // init subsystems - printf (DEH_String("V_Init: allocate screens.\n")); - V_Init (); + printf(DEH_String("V_Init: allocate screens.\n")); + V_Init(); - printf (DEH_String("M_LoadDefaults: Load system defaults.\n")); - M_LoadDefaults (); // load before initing other systems + // Load configuration files before initialising other subsystems. + printf(DEH_String("M_LoadDefaults: Load system defaults.\n")); + D_BindVariables(); + M_LoadDefaults(); // Save configuration at exit. I_AtExit(M_SaveDefaults, false); diff --git a/src/doom/g_game.h b/src/doom/g_game.h index 65fb06b0..8cf5b068 100644 --- a/src/doom/g_game.h +++ b/src/doom/g_game.h @@ -81,4 +81,7 @@ void G_ScreenShot (void); void G_DrawMouseSpeedBox(void); +extern int vanilla_savegame_limit; +extern int vanilla_demo_limit; #endif + diff --git a/src/doom/hu_stuff.c b/src/doom/hu_stuff.c index ace4cef2..d31b8ce8 100644 --- a/src/doom/hu_stuff.c +++ b/src/doom/hu_stuff.c @@ -67,7 +67,7 @@ -char* chat_macros[] = +char *chat_macros[10] = { HUSTR_CHATMACRO0, HUSTR_CHATMACRO1, diff --git a/src/doom/hu_stuff.h b/src/doom/hu_stuff.h index 310201f6..26bc92ee 100644 --- a/src/doom/hu_stuff.h +++ b/src/doom/hu_stuff.h @@ -62,5 +62,7 @@ void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); +extern char *chat_macros[10]; #endif + diff --git a/src/doom/s_sound.c b/src/doom/s_sound.c index fa236970..e78f763a 100644 --- a/src/doom/s_sound.c +++ b/src/doom/s_sound.c @@ -110,7 +110,7 @@ static musicinfo_t *mus_playing = NULL; // Number of channels to use -int numChannels = 8; +int snd_channels = 8; // // Initializes sound stuff, including volume @@ -131,10 +131,10 @@ void S_Init(int sfxVolume, int musicVolume) // Allocating the internal channels for mixing // (the maximum numer of sounds rendered // simultaneously) within zone memory. - channels = Z_Malloc(numChannels*sizeof(channel_t), PU_STATIC, 0); + channels = Z_Malloc(snd_channels*sizeof(channel_t), PU_STATIC, 0); // Free all channels for use - for (i=0 ; isfxinfo == channels[i].sfxinfo) { @@ -203,7 +203,7 @@ void S_Start(void) // kill all playing sounds at start of level // (trust me - a good idea) - for (cnum=0 ; cnumpriority >= sfxinfo->priority) { @@ -300,7 +300,7 @@ static int S_GetChannel(mobj_t *origin, sfxinfo_t *sfxinfo) } } - if (cnum == numChannels) + if (cnum == snd_channels) { // FUCK! No lower priority. Sorry, Charlie. return -1; @@ -524,7 +524,7 @@ void S_UpdateSounds(mobj_t *listener) sfxinfo_t* sfx; channel_t* c; - for (cnum=0; cnumsfxinfo; diff --git a/src/doom/s_sound.h b/src/doom/s_sound.h index d2af9e88..7bb0a605 100644 --- a/src/doom/s_sound.h +++ b/src/doom/s_sound.h @@ -91,6 +91,7 @@ void S_UpdateSounds(mobj_t *listener); void S_SetMusicVolume(int volume); void S_SetSfxVolume(int volume); +extern int snd_channels; #endif -- cgit v1.2.3