- 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
- 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
mouse should be grabbed. This fixes the case where you start the game in
the background and it grabs the mouse anyway.

View file

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

View file

@ -1777,24 +1777,27 @@ FString G_BuildSaveName (const char *prefix, int slot)
{
leader = save_dir;
}
#ifdef unix
if (leader.IsEmpty())
{
leader = "~" GAME_DIR;
}
#endif
}
size_t len = leader.Len();
if (leader[0] != '\0' && leader[len-1] != '\\' && leader[len-1] != '/')
{
slash = "/";
}
name.Format("%s%s%s", leader.GetChars(), slash, prefix);
name << leader << slash;
name = NicePath(name);
CreatePath(name);
name << prefix;
if (slot >= 0)
{
name.AppendFormat("%d.zds", slot);
}
#ifdef unix
if (leader[0] == 0)
{
return GetUserFile (name);
}
#endif
return NicePath(name);
return name;
}
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;
G_SnapshotLevel ();
FILE *stdfile = fopen (filename.GetChars(), "wb");
FILE *stdfile = fopen (filename, "wb");
if (stdfile == NULL)
{