From cc3863d1fe5f904a71106a7cd402fe8a7cb62342 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 10 Jul 2024 00:05:30 +0200 Subject: [PATCH] cleaned up paths for MUSIC, SOUND, and other --- sound.cpp | 22 ++++++---------------- sysconfig.h | 8 -------- util.cpp | 2 ++ 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/sound.cpp b/sound.cpp index 254a622f..43c32cac 100644 --- a/sound.cpp +++ b/sound.cpp @@ -197,16 +197,10 @@ EX bool loadMusicInfo(string dir) { EX bool loadMusicInfo() { return - loadMusicInfo(musicfile) - || loadMusicInfo(HYPERPATH "hyperrogue-music.txt") - || loadMusicInfo("./hyperrogue-music.txt") - || loadMusicInfo("music/hyperrogue-music.txt") -// Destination set by ./configure (in the GitHub repository) -#ifdef MUSICDESTDIR - || loadMusicInfo(MUSICDESTDIR) -#endif + loadMusicInfo(find_file(musicfile)) + || loadMusicInfo(find_file("hyperrogue-music.txt") ) + || loadMusicInfo(find_file("music/hyperrogue-music.txt") ) #ifdef FHS - || loadMusicInfo("/usr/share/hyperrogue/hyperrogue-music.txt") || (getenv("HOME") && loadMusicInfo(s0 + getenv("HOME") + "/.hyperrogue-music.txt")) #endif ; @@ -229,21 +223,17 @@ EX void initAudio() { map chunks; -#ifdef SOUNDDESTDIR -string wheresounds = SOUNDDESTDIR; -#else -string wheresounds = HYPERPATH "sounds/"; -#endif - hookset hooks_sound; +EX string wheresounds = "sounds/"; + EX void playSound(cell *c, const string& fname, int vol) { LATE( hr::playSound(c, fname, vol); ) if(effvolume == 0) return; if(callhandlers(false, hooks_sound, fname, vol)) return; // printf("Play sound: %s\n", fname.c_str()); if(!chunks.count(fname)) { - string s = wheresounds+fname+".ogg"; + string s = find_file(wheresounds + fname + ".ogg"); if(memory_issues()) return; memory_for_lib(); chunks[fname] = Mix_LoadWAV(s.c_str()); diff --git a/sysconfig.h b/sysconfig.h index 718c7a30..968e3ab8 100644 --- a/sysconfig.h +++ b/sysconfig.h @@ -346,14 +346,6 @@ #undef XEXTRALICENSE #endif -#ifndef HYPERPATH -#define HYPERPATH "" -#endif - -#ifndef HYPERFONTPATH -#define HYPERFONTPATH HYPERPATH -#endif - #if ISWINDOWS #define hyper fake_hyper // avoid "hyper" typedef in <_mingw.h> #define WIN32_LEAN_AND_MEAN // avoid "rad1" macro in diff --git a/util.cpp b/util.cpp index 629a8d31..ada5f08b 100644 --- a/util.cpp +++ b/util.cpp @@ -975,7 +975,9 @@ EX string find_file(string s) { if(file_exists(s)) return s; char *p = getenv("HYPERPATH"); if(p && file_exists(s1 = s0 + p + s)) return s1; +#ifdef HYPERPATH if(file_exists(s1 = HYPERPATH + s)) return s1; +#endif #ifdef FHS if(file_exists(s1 = "/usr/share/hyperrogue/" + s)) return s1; #endif