diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/files.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 14 | ||||
-rw-r--r-- | crawl-ref/source/libgui.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/macro.cc | 11 |
4 files changed, 32 insertions, 15 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index c906a36123..f00a8cf58a 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -527,19 +527,19 @@ std::string datafile_path(std::string basename, #endif for (unsigned b = 0, size = bases.size(); b < size; ++b) - { for (unsigned p = 0; p < sizeof(prefixes) / sizeof(*prefixes); ++p) { std::string name = bases[b] + prefixes[p] + basename; if (file_exists(name)) return (name); } - } // Die horribly. if (croak_on_fail) + { end(1, false, "Cannot find data file '%s' anywhere, aborting\n", basename.c_str()); + } return (""); } diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 098db26920..08ca799cb2 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -1134,10 +1134,10 @@ static std::string _find_crawlrc() } // Check all possibilities for init.txt - for ( int i = 0; locations_data[i][1] != NULL; ++i ) + for (int i = 0; locations_data[i][1] != NULL; ++i) { // Don't look at unset options - if ( locations_data[i][0] != NULL ) + if (locations_data[i][0] != NULL) { const std::string rc = catpath(locations_data[i][0], locations_data[i][1]); @@ -1808,7 +1808,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) // Keep unlowercased field around const std::string orig_field = field; - if (key != "name" && key != "crawl_dir" + if (key != "name" && key != "crawl_dir" && key != "macro_dir" && key != "race" && key != "class" && key != "ban_pickup" && key != "autopickup_exceptions" && key != "stop_travel" && key != "sound" @@ -2174,6 +2174,10 @@ void game_options::read_option_line(const std::string &str, bool runscript) // if the user puts two crawl_dir lines in the init file. SysEnv.crawl_dir = field; } + else if (key == "macro_dir") + { + macro_dir = field; + } #endif else if (key == "race") { @@ -3039,10 +3043,10 @@ void get_system_environment(void) } #endif - // The full path to the init file -- this over-rides CRAWL_DIR + // The full path to the init file -- this overrides CRAWL_DIR. SysEnv.crawl_rc = check_string( getenv("CRAWL_RC") ); - // rename giant and giant spiked clubs + // Rename giant and giant spiked clubs. SysEnv.board_with_nail = (getenv("BOARD_WITH_NAIL") != NULL); #ifdef MULTIUSER diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc index 8b5ae1db7f..6fb7c56f7e 100644 --- a/crawl-ref/source/libgui.cc +++ b/crawl-ref/source/libgui.cc @@ -28,6 +28,7 @@ #include "it_use2.h" #include "externs.h" #include "guic.h" +#include "initfile.h" #include "message.h" #include "misc.h" #include "mon-util.h" @@ -804,8 +805,23 @@ static void _libgui_save_prefs() strncpy(dummy_str[pref_mode][idx], (char *)p->ptr, MAX_PREF_CHAR); } + // Use the same directory as for macros. + // (Yes, this is an arbitrary decision.) + std::string dir = !Options.macro_dir.empty() ? Options.macro_dir : + !SysEnv.crawl_dir.empty() ? SysEnv.crawl_dir : ""; + + if (!dir.empty()) + { +#ifndef DGL_MACRO_ABSOLUTE_PATH + if (dir[dir.length() - 1] != FILE_SEPARATOR) + dir += FILE_SEPARATOR; +#endif + } + const char *baseTxt = "wininit.txt"; - std::string winTxtString = datafile_path(baseTxt, false, true); + std::string winTxtString = dir + baseTxt; + if ( (fp = fopen(winTxtString.c_str(), "w")) == NULL ) + winTxtString = datafile_path(baseTxt, false, true); const char *winTxt = winTxtString.c_str()[0] == 0 ? baseTxt : winTxtString.c_str(); diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index 5f2542bf39..712cd8c39d 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -158,7 +158,7 @@ static int userfunc_getindex(const std::string &fname) return (i); } - // Pass 2 to hunt for gaps + // Pass 2 to hunt for gaps. for (int i = 0, count = userfunctions.size(); i < count; ++i) { if (userfunctions[i].empty()) @@ -172,14 +172,11 @@ static int userfunc_getindex(const std::string &fname) return (userfunctions.size() - 1); } -/* - * Returns the name of the file that contains macros. - */ +// Returns the name of the file that contains macros. static std::string get_macro_file() { - std::string dir = - !Options.macro_dir.empty()? Options.macro_dir : - !SysEnv.crawl_dir.empty()? SysEnv.crawl_dir : ""; + std::string dir = !Options.macro_dir.empty() ? Options.macro_dir : + !SysEnv.crawl_dir.empty() ? SysEnv.crawl_dir : ""; if (!dir.empty()) { |