summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-08-09 19:50:44 +0000
committerrubidium <rubidium@openttd.org>2009-08-09 19:50:44 +0000
commit9ee2a66c8620d2f47c0d7792847c90146dfc4f8e (patch)
treedae5e6c7eac84bc443fc16ebb012bb7697923649 /src/openttd.cpp
parent35d5a197d6f93e05eb358ed0a30db9ab2645911b (diff)
downloadopenttd-9ee2a66c8620d2f47c0d7792847c90146dfc4f8e.tar.xz
(svn r17139) -Change: add the concept of sound sets
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index e77a781a1..0ef73a140 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -177,6 +177,7 @@ static void ShowHelp()
" Default value (2) lets OpenTTD use the palette\n"
" specified in graphics set file (see below)\n"
" -I graphics_set = Force the graphics set (see below)\n"
+ " -S sounds_set = Force the sounds set (see below)\n"
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n"
" -x = Do not automatically save to config file on exit\n"
"\n",
@@ -186,6 +187,9 @@ static void ShowHelp()
/* List the graphics packs */
p = BaseGraphics::GetSetsList(p, lastof(buf));
+ /* List the sounds packs */
+ p = BaseSounds::GetSetsList(p, lastof(buf));
+
/* List the drivers */
p = VideoDriverFactoryBase::GetDriversInfo(p, lastof(buf));
@@ -401,6 +405,7 @@ int ttd_main(int argc, char *argv[])
char *videodriver = NULL;
char *blitter = NULL;
char *graphics_set = NULL;
+ char *sounds_set = NULL;
Dimension resolution = {0, 0};
Year startyear = INVALID_YEAR;
uint generation_seed = GENERATE_NEW_SEED;
@@ -426,7 +431,7 @@ int ttd_main(int argc, char *argv[])
* a letter means: it accepts that param (e.g.: -h)
* a ':' behind it means: it need a param (e.g.: -m<driver>)
* a '::' behind it means: it can optional have a param (e.g.: -d<debug>) */
- optformat = "m:s:v:b:hD::n::ei::I:t:d::r:g::G:c:xl:p:P:"
+ optformat = "m:s:v:b:hD::n::ei::I:S:t:d::r:g::G:c:xl:p:P:"
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
"f"
#endif
@@ -437,6 +442,7 @@ int ttd_main(int argc, char *argv[])
while ((i = MyGetOpt(&mgo)) != -1) {
switch (i) {
case 'I': free(graphics_set); graphics_set = strdup(mgo.opt); break;
+ case 'S': free(sounds_set); sounds_set = strdup(mgo.opt); break;
case 'm': free(musicdriver); musicdriver = strdup(mgo.opt); break;
case 's': free(sounddriver); sounddriver = strdup(mgo.opt); break;
case 'v': free(videodriver); videodriver = strdup(mgo.opt); break;
@@ -526,6 +532,7 @@ int ttd_main(int argc, char *argv[])
* the debug console as that hasn't been configured yet. */
DeterminePaths(argv[0]);
BaseGraphics::FindSets();
+ BaseSounds::FindSets();
ShowHelp();
return 0;
}
@@ -538,6 +545,7 @@ int ttd_main(int argc, char *argv[])
DeterminePaths(argv[0]);
BaseGraphics::FindSets();
+ BaseSounds::FindSets();
#if defined(UNIX) && !defined(__MORPHOS__)
/* We must fork here, or we'll end up without some resources we need (like sockets) */
@@ -584,16 +592,23 @@ int ttd_main(int argc, char *argv[])
/* initialize all variables that are allocated dynamically */
InitializeDynamicVariables();
- /* Sample catalogue */
- DEBUG(misc, 1, "Loading sound effects...");
- SoundInitialize("sample.cat");
-
/* Initialize FreeType */
InitFreeType();
/* This must be done early, since functions use the InvalidateWindow* calls */
InitWindowSystem();
+ /* Look for the sounds before the graphics. Otherwise none would be set and
+ * the first initialisation of the video happens on the wrong data. Now it
+ * can do the first initialisation right. */
+ if (sounds_set == NULL && BaseSounds::ini_set != NULL) sounds_set = strdup(BaseSounds::ini_set);
+ if (!BaseSounds::SetSet(sounds_set)) {
+ StrEmpty(sounds_set) ?
+ usererror("Failed to find a sounds set. Please acquire a sounds set for OpenTTD.") :
+ usererror("Failed to select requested sounds set '%s'", sounds_set);
+ }
+ free(sounds_set);
+
if (graphics_set == NULL && BaseGraphics::ini_set != NULL) graphics_set = strdup(BaseGraphics::ini_set);
if (!BaseGraphics::SetSet(graphics_set)) {
StrEmpty(graphics_set) ?
@@ -729,6 +744,7 @@ int ttd_main(int argc, char *argv[])
ShutdownGame();
free(const_cast<char *>(BaseGraphics::ini_set));
+ free(const_cast<char *>(BaseSounds::ini_set));
free(_ini_musicdriver);
free(_ini_sounddriver);
free(_ini_videodriver);