diff options
author | bjarni <bjarni@openttd.org> | 2004-12-07 17:16:57 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2004-12-07 17:16:57 +0000 |
commit | 051134ac9f88ec88bfd7bbd1bc209ccd42dffbcc (patch) | |
tree | 44291cabe320182bb12c67a353076ac2f256f475 | |
parent | a3a2f0617c0eebe63980b2057214fb4e9f76c41d (diff) | |
download | openttd-051134ac9f88ec88bfd7bbd1bc209ccd42dffbcc.tar.xz |
(svn r970) Added 2nd data path for all non-windows OSes
added completely customizable lang path (all non-Windows OSes)
-rw-r--r-- | Makefile | 28 | ||||
-rw-r--r-- | fileio.c | 10 | ||||
-rw-r--r-- | makefiledir/Makefile.config_writer | 2 | ||||
-rw-r--r-- | ttd.c | 11 | ||||
-rw-r--r-- | unix.c | 22 | ||||
-rw-r--r-- | variables.h | 1 |
6 files changed, 65 insertions, 9 deletions
@@ -89,6 +89,10 @@ # stored. You cannot use ~ here, define USE_HOMEDIR for that. # USE_HOMEDIR: If this variable is set, PERSONAL_DIR will be prefixed with # ~/ at runtime (the user's homedir) +# SECOND_DATA_PATH Use this data dir if a file is not found in the data dir in the data path +# CUSTOM_LANG_PATH If this is set, it will use the path given to search for lng files +# instead of the lang dir in the data path +# NOTE: both SECOND_DATA_PATH and CUSTOM_LANG_PATH uses paths relative to where OTTD is opened # # DEST_DIR: make install will use this directory instead of the filesystem # root to install its files. This should normally not be used by @@ -113,7 +117,7 @@ # Makefile version tag # it checks if the version tag in makefile.config is the same and force update outdated config files -MAKEFILE_VERSION:=4 +MAKEFILE_VERSION:=5 # CONFIG_WRITER have to be found even for manual configuration CONFIG_WRITER=makefiledir/Makefile.config_writer @@ -444,6 +448,12 @@ ifdef OSX ifndef MIDI MIDI:=$(OSXAPP)/contents/macos/track_starter endif +ifndef SECOND_DATA_PATH +SECOND_DATA_PATH:="$(OSXAPP)/contents/data/" +endif +ifndef CUSTOM_LANG_DIR +CUSTOM_LANG_DIR:="$(OSXAPP)/contents/lang/" +endif endif ifdef MIDI @@ -469,6 +479,15 @@ endif endif endif + +ifdef SECOND_DATA_PATH +CDEFS += -DSECOND_DATA_DIR=\"$(SECOND_DATA_PATH)/\" +endif + +ifdef CUSTOM_LANG_DIR +CDEFS += -DCUSTOM_LANG_DIR=\"$(CUSTOM_LANG_DIR)/\" +endif + ifdef WITH_DIRECTMUSIC CDEFS += -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT endif @@ -604,8 +623,11 @@ $(TTD): table/strings.h $(ttd_OBJS) $(MAKE_CONFIG) $(C_LINK) $@ $(TTDLDFLAGS) $(ttd_OBJS) $(LIBS) $(VERBOSE_FILTER) $(OSX): + @rm -fr $(OSXAPP) @mkdir -p $(OSXAPP)/Contents/MacOS @mkdir -p $(OSXAPP)/Contents/Resources + @mkdir -p $(OSXAPP)/Contents/Data + @mkdir -p $(OSXAPP)/Contents/Lang @echo "APPL????" > $(OSXAPP)/Contents/PkgInfo @cp os/macos/ttd.icns $(OSXAPP)/Contents/Resources/openttd.icns @os/macos/plistgen.sh $(OSXAPP) $(REV) @@ -613,7 +635,11 @@ $(OSX): @ls os/macos | grep -q "\.class" || \ javac os/macos/OpenTTDMidi.java @cp os/macos/OpenTTDMidi.class $(OSXAPP)/contents/macos + @cp data/* $(OSXAPP)/Contents/data/ + @cp lang/*.lng $(OSXAPP)/Contents/lang/ @cp $(TTD) $(OSXAPP)/Contents/MacOS/$(TTD) + + $(endwarnings): $(64_bit_warnings) @@ -110,6 +110,16 @@ void FioOpenFile(int slot, const char *filename) for(s=buf + strlen(_path.data_dir) - 1; *s != 0; s++) *s = tolower(*s); f = fopen(buf, "rb"); + +#if defined SECOND_DATA_DIR + // tries in the 2nd data directory + if (f == NULL) { + sprintf(buf, "%s%s", _path.second_data_dir, filename); + for(s=buf + strlen(_path.second_data_dir) - 1; *s != 0; s++) + *s = tolower(*s); + f = fopen(buf, "rb"); + } +#endif } #endif diff --git a/makefiledir/Makefile.config_writer b/makefiledir/Makefile.config_writer index c138945c1..046256fa7 100644 --- a/makefiledir/Makefile.config_writer +++ b/makefiledir/Makefile.config_writer @@ -39,6 +39,8 @@ $(MAKE_CONFIG): $(call CONFIG_LINE,DATA_DIR:=$(DATA_DIR)) $(call CONFIG_LINE,USE_HOMEDIR:=$(USE_HOMEDIR)) $(call CONFIG_LINE,PERSONAL_DIR:=$(PERSONAL_DIR)) + $(call CONFIG_LINE,SECOND_DATA_PATH:=$(SECOND_DATA_PATH)) + $(call CONFIG_LINE,CUSTOM_LANG_PATH:=$(CUSTOM_LANG_PATH)) $(call CONFIG_LINE,) $(call CONFIG_LINE,\# Experimental) @@ -496,8 +496,15 @@ void LoadIntroGame() // Generate a world. sprintf(filename, "%sopntitle.dat", _path.data_dir); if (SaveOrLoad(filename, SL_LOAD) != SL_OK) - GenerateWorld(1); // if failed loading, make empty world. - +#if defined SECOND_DATA_DIR + { + sprintf(filename, "%sopntitle.dat", _path.second_data_dir); + if (SaveOrLoad(filename, SL_LOAD) != SL_OK) +#endif + GenerateWorld(1); // if failed loading, make empty world. +#if defined SECOND_DATA_DIR + } +#endif _opt.currency = _new_opt.currency; _pause = 0; @@ -424,7 +424,7 @@ void ShowOSErrorBox(const char *buf) // this creates an error in the console and then opens the console. // Colourcodes are not used in the console, so they are skipped here fprintf(stderr, "Error: %s", buf); - system("/Applications/Utilities/Console.app/Contents/MacOS/Console"); + system("/Applications/Utilities/Console.app/Contents/MacOS/Console &"); #else // all systems, but OSX fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf); @@ -452,7 +452,11 @@ void DeterminePaths() char *s; _path.game_data_dir = malloc( MAX_PATH ); - strcpy(_path.game_data_dir, GAME_DATA_DIR); + ttd_strlcpy(_path.game_data_dir, GAME_DATA_DIR, MAX_PATH); + #if defined SECOND_DATA_DIR + _path.second_data_dir = malloc( MAX_PATH ); + ttd_strlcpy( _path.second_data_dir, SECOND_DATA_DIR, MAX_PATH); + #endif #if defined(USE_HOMEDIR) { @@ -470,7 +474,7 @@ void DeterminePaths() #else /* not defined(USE_HOMEDIR) */ _path.personal_dir = malloc( MAX_PATH ); - strcpy(_path.personal_dir, PERSONAL_DIR); + ttd_strlcpy(_path.personal_dir, PERSONAL_DIR, MAX_PATH); // check if absolute or relative path s = strchr(_path.personal_dir, '/'); @@ -480,7 +484,7 @@ void DeterminePaths() getcwd(_path.personal_dir, MAX_PATH); s = strchr(_path.personal_dir, 0); *s++ = '/'; - strcpy(s, PERSONAL_DIR); + ttd_strlcpy(s, PERSONAL_DIR, MAX_PATH); } #endif /* defined(USE_HOMEDIR) */ @@ -495,9 +499,15 @@ void DeterminePaths() _path.scenario_dir = str_fmt("%sscenario", _path.personal_dir); _path.gm_dir = str_fmt("%sgm/", _path.game_data_dir); _path.data_dir = str_fmt("%sdata/", _path.game_data_dir); - _path.lang_dir = str_fmt("%slang/", _path.game_data_dir); - _config_file = str_fmt("%sopenttd.cfg", _path.personal_dir); + +#if defined CUSTOM_LANG_DIR + // sets the search path for lng files to the custom one + _path.lang_dir = malloc( MAX_PATH ); + ttd_strlcpy( _path.lang_dir, CUSTOM_LANG_DIR, MAX_PATH); +#else + _path.lang_dir = str_fmt("%slang/", _path.game_data_dir); +#endif // create necessary folders mkdir(_path.personal_dir, 0755); diff --git a/variables.h b/variables.h index 672bd73dd..61cba06e7 100644 --- a/variables.h +++ b/variables.h @@ -199,6 +199,7 @@ typedef struct Paths { char *save_dir; char *autosave_dir; char *scenario_dir; + char *second_data_dir; } Paths; VARDEF Paths _path; |