- Specifying non-existent directories with -savedir or the save_dir cvar now

attempts to create them.


SVN r1607 (trunk)
This commit is contained in:
Randy Heit 2009-05-26 01:05:01 +00:00
parent e95be7eff7
commit 2f7498214b
3 changed files with 23 additions and 15 deletions

View file

@ -1,4 +1,6 @@
May 25, 2009 May 25, 2009
- Specifiying non-existant directories with -savedir or the save_dir cvar now
attempts to create them.
- I_CheckNativeMouse() now checks the foreground window to determine if the - I_CheckNativeMouse() now checks the foreground window to determine if the
mouse should be grabbed. This fixes the case where you start the game in mouse should be grabbed. This fixes the case where you start the game in
the background and it grabs the mouse anyway. the background and it grabs the mouse anyway.

View file

@ -352,7 +352,7 @@ const char *myasctime ()
/* */ /* */
/************************************************************************/ /************************************************************************/
#ifdef _WIN32 #ifdef _WIN32
void DoCreatePath(const char * fn) void DoCreatePath(const char *fn)
{ {
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
char path[PATH_MAX]; char path[PATH_MAX];
@ -367,17 +367,20 @@ void DoCreatePath(const char * fn)
_mkdir(p); _mkdir(p);
} }
void CreatePath(const char * fn) void CreatePath(const char *fn)
{ {
char name[PATH_MAX];
char c = fn[strlen(fn)-1]; char c = fn[strlen(fn)-1];
if (c!='\\' && c!='/') if (c != '\\' && c != '/')
{ {
mysnprintf(name, countof(name), "%s/", fn); FString name(fn);
name += '/';
DoCreatePath(name); DoCreatePath(name);
} }
else DoCreatePath(fn); else
{
DoCreatePath(fn);
}
} }
#else #else
void CreatePath(const char *fn) void CreatePath(const char *fn)

View file

@ -1777,24 +1777,27 @@ FString G_BuildSaveName (const char *prefix, int slot)
{ {
leader = save_dir; leader = save_dir;
} }
#ifdef unix
if (leader.IsEmpty())
{
leader = "~" GAME_DIR;
}
#endif
} }
size_t len = leader.Len(); size_t len = leader.Len();
if (leader[0] != '\0' && leader[len-1] != '\\' && leader[len-1] != '/') if (leader[0] != '\0' && leader[len-1] != '\\' && leader[len-1] != '/')
{ {
slash = "/"; slash = "/";
} }
name.Format("%s%s%s", leader.GetChars(), slash, prefix); name << leader << slash;
name = NicePath(name);
CreatePath(name);
name << prefix;
if (slot >= 0) if (slot >= 0)
{ {
name.AppendFormat("%d.zds", slot); name.AppendFormat("%d.zds", slot);
} }
#ifdef unix return name;
if (leader[0] == 0)
{
return GetUserFile (name);
}
#endif
return NicePath(name);
} }
CVAR (Int, autosavenum, 0, CVAR_NOSET|CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Int, autosavenum, 0, CVAR_NOSET|CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
@ -1911,7 +1914,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
insave = true; insave = true;
G_SnapshotLevel (); G_SnapshotLevel ();
FILE *stdfile = fopen (filename.GetChars(), "wb"); FILE *stdfile = fopen (filename, "wb");
if (stdfile == NULL) if (stdfile == NULL)
{ {