Remove macros STRATAGUS_HOME_PATH and STRATAGUS_LIB_PATH

Use instead global std::string variables UserDirectory and StratagusLibPath (they are initialized and updated after parsing command line arguments)
Update manpage
Change default config directory:
 * windows: user profile application data folder/Stratagus
 * mac: ~/Library/Stratagus
 * other: ~/.stratagus
This commit is contained in:
Pali Rohár 2011-10-05 16:30:48 +02:00
parent 808bcf7460
commit 3a84142457
5 changed files with 38 additions and 52 deletions

View file

@ -1,4 +1,4 @@
.TH STRATAGUS 6 "May 2011" "Stratagus v2.2.6"
.TH STRATAGUS 6 "Oct 2011" "Stratagus v2.2.6"
.SH NAME
stratagus \- Strategy Gaming Engine
.SH SYNOPSIS
@ -16,7 +16,7 @@ is a powerful game engine for building realtime strategy games, a la AoE or Warc
A summary of options is included below.
.TP
.B \-c file.lua
Choose a different stratagus config file.
Choose a different stratagus start config file.
.TP
.B \-d datapath
Choose a different directory to use for game data files.
@ -80,14 +80,26 @@ With this option you can specify video mode resolution in format \fB<xres>\fRx\f
With this option you can start Stratagus in windowed video mode.
.SH "FILES"
.TP
.B /usr/share/games/stratagus/default
.B ./
Default directory for Stratagus data files
.TP
.B /usr/share/games/stratagus/default/scripts/stratagus.lua
Default start file.
.B ./scripts/stratagus.lua
Default start config file.
.TP
.B /usr/share/games/stratagus/default/scripts/editor.lua
.B ./scripts/editor.lua
Default editor file.
.TP
.B ./scripts/guichan.lua
Default menu file.
.TP
.B ~/.stratagus/<data>/preferences.lua
User preferences configuration file for <data>
.TP
.B ~/.stratagus/<data>/logs/
User directory with replays/logs for <data>
.TP
.B ~/.stratagus/<data>/save/
User directory with saved games for <data>
.SH "SEE ALSO"
More complete documentation is available in /usr/share/doc/stratagus.
.SH NOTES
@ -97,9 +109,9 @@ in the Warcraft II CD, thanks to the Wargus dataset.
.PP
Warcraft II is a registered trademark of Blizzard Entertainment.
.SH AUTHOR
Stratagus is written by Nehal Mistry, Russell Smith Pali Rohár and others.
Stratagus is written by Nehal Mistry, Russell Smith, Pali Rohár and others.
.PP
This manual page was written by Anthony Towns <ajt@debian.org> ,
This manual page was written by Anthony Towns <ajt@debian.org>,
David Martínez Moreno <ender@debian.org> and
Pali Rohár <pali.rohar@gmail.com> for the Debian GNU/Linux
system (but may be used by others).

View file

@ -175,20 +175,6 @@ inline char *new_strdup(const char *str)
/// Text string: Name, Version, Copyright
extern const char NameLine[];
#ifndef STRATAGUS_LIB_PATH
#define STRATAGUS_LIB_PATH "." /// Where to find the data files
#endif
#ifndef STRATAGUS_HOME_PATH
#ifdef __APPLE__
#define STRATAGUS_HOME_PATH "Library/Stratagus"
#else
#define _VERSION_STRING1(m,n,p) m "-" #n "." #p
#define _VERSION_STRING(m,n,p) _VERSION_STRING1(m,n,p)
#define STRATAGUS_HOME_PATH _VERSION_STRING(".stratagus",StratagusMajorVersion,StratagusMinorVersion)
#endif
#endif
/*----------------------------------------------------------------------------
-- Some limits
----------------------------------------------------------------------------*/

View file

@ -536,25 +536,13 @@ char *LibraryFileName(const char *file, char *buffer, size_t buffersize)
}
}
#ifdef USE_WIN32
// In user home directory
// In user home directory
if (!GameName.empty()) {
sprintf(buffer, "%s/%s/%s", STRATAGUS_HOME_PATH, GameName.c_str(), file);
sprintf(buffer, "%s/%s/%s", UserDirectory.c_str(), GameName.c_str(), file);
if (FindFileWithExtension(buffer, buffersize)) {
return buffer;
}
}
#endif
#ifndef USE_WIN32
// In user home directory
if ((s = getenv("HOME")) && !GameName.empty()) {
sprintf(buffer, "%s/%s/%s/%s", s, STRATAGUS_HOME_PATH, GameName.c_str(), file);
if (FindFileWithExtension(buffer, buffersize)) {
return buffer;
}
}
#endif
// In global shared directory
sprintf(buffer, "%s/%s", StratagusLibPath.c_str(), file);

View file

@ -2708,28 +2708,28 @@ std::string SaveGlobal(lua_State *l, bool is_root)
*/
void CreateUserDirectories()
{
std::string directory;
UserDirectory = "";
#ifndef USE_WIN32
std::string s;
#ifdef USE_WIN32
s = getenv("APPDATA");
#else
s = getenv("HOME");
if (!s.empty()) {
UserDirectory = s + "/";
}
#endif
UserDirectory += STRATAGUS_HOME_PATH;
UserDirectory += "/";
UserDirectory = "";
//DebugPrint("Creating User Directories: %s\n" _C_ UserDirectory.c_str());
if (!s.empty())
UserDirectory = s + "/";
#ifdef USE_WIN32
UserDirectory += "Stratagus";
#elif defined(USE_MAC)
UserDirectory += "Library/Stratagus";
#else
UserDirectory += ".stratagus";
#endif
makedir(UserDirectory.c_str(), 0777);
// Create specific subdirectories
//directory = UserDirectory + "patches/";
//makedir(directory.c_str(), 0777);
}
/**

View file

@ -664,7 +664,7 @@ static void Usage(void)
printf(
"\n\nUsage: %s [OPTIONS] [map.smp|map.smp.gz]\n\
\t-c file.lua\tConfiguration start file (default stratagus.lua)\n\
\t-d datapath\tPath to stratagus data\n\
\t-d datapath\tPath to stratagus data (default current directory)\n\
\t-D depth\tVideo mode depth = pixel per point (for Win32/TNT)\n\
\t-e\t\tStart editor (instead of game)\n\
\t-E file.lua\tEditor configuration start file (default editor.lua)\n\
@ -801,7 +801,7 @@ int main(int argc, char **argv)
// Setup some defaults.
//
#ifndef MAC_BUNDLE
StratagusLibPath = STRATAGUS_LIB_PATH;
StratagusLibPath = ".";
#else
freopen("/tmp/stdout.txt", "w", stdout);
freopen("/tmp/stderr.txt", "w", stderr);