Merge branch 'master' into reverbedit

This commit is contained in:
Christoph Oelckers 2017-12-03 21:04:14 +01:00
commit 4c799af293
11 changed files with 106 additions and 68 deletions

View file

@ -534,7 +534,7 @@ bool FCajunMaster::LoadBots ()
}
if (!sc.OpenFile(tmp))
{
Printf("Unable to open %s. So no bots\n");
Printf("Unable to open %s. So no bots\n", tmp.GetChars());
return false;
}

View file

@ -544,18 +544,13 @@ void CreatePath(const char *fn)
{
*p = '\0';
}
struct stat info;
if (DirEntryExists(copy))
if (!DirEntryExists(copy) && mkdir(copy, 0755) == -1)
{
if (info.st_mode & S_IFDIR)
goto exists;
}
if (mkdir(copy, 0755) == -1)
{ // failed
// failed
free(copy);
return;
}
exists: if (p != NULL)
if (p != NULL)
{
*p = '/';
}

View file

@ -2978,7 +2978,7 @@ bool G_CheckDemoStatus (void)
bool saved = false;
if (fw != nullptr)
{
auto size = long(demo_p - demobuffer);
const size_t size = demo_p - demobuffer;
saved = fw->Write(demobuffer, size) == size;
delete fw;
if (!saved) remove(demoname);

View file

@ -800,8 +800,8 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
GLRenderer->mAngles.Roll.Degrees = r_viewpoint.Angles.Roll.Degrees;
// Scroll the sky
GLRenderer->mSky1Pos = (double)fmod(screen->FrameTime * level.skyspeed1, 1024.f) * 90./256.;
GLRenderer->mSky2Pos = (double)fmod(screen->FrameTime * level.skyspeed2, 1024.f) * 90./256.;
GLRenderer->mSky1Pos = (double)fmod((double)screen->FrameTime * (double)level.skyspeed1, 1024.f) * 90./256.;
GLRenderer->mSky2Pos = (double)fmod((double)screen->FrameTime * (double)level.skyspeed2, 1024.f) * 90./256.;

View file

@ -60,5 +60,6 @@ FString M_GetCajunPath(const char *filename);
FString M_GetConfigPath(bool for_reading);
FString M_GetScreenshotsPath();
FString M_GetSavegamesPath();
FString M_GetDocumentsPath();
#endif

View file

@ -215,3 +215,24 @@ FString M_GetSavegamesPath()
return path;
}
//===========================================================================
//
// M_GetDocumentsPath Unix
//
// Returns the path to the default documents directory.
//
//===========================================================================
FString M_GetDocumentsPath()
{
FString path;
char cpath[PATH_MAX];
FSRef folder;
if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
{
path << cpath << "/" GAME_DIR "/";
}
return path;
}

View file

@ -218,3 +218,16 @@ FString M_GetSavegamesPath()
{
return NicePath("~/" GAME_DIR);
}
//===========================================================================
//
// M_GetDocumentsPath Unix
//
// Returns the path to the default documents directory.
//
//===========================================================================
FString M_GetDocumentsPath()
{
return NicePath("~/" GAME_DIR);
}

View file

@ -166,6 +166,8 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le
for (int i = 0; i < s->numSkins; i++)
{
// [BB] According to the MD3 spec, Name is supposed to include the full path.
// ... and since some tools seem to output backslashes, these need to be replaced with forward slashes to work.
FixPathSeperator(shader[i].Name);
s->skins[i] = LoadSkin("", shader[i].Name);
// [BB] Fall back and check if Name is relative.
if (!s->skins[i].isValid())

View file

@ -35,27 +35,13 @@
#include <sys/stat.h>
#include <sys/types.h>
#ifdef _WIN32
#include <io.h>
#define stat _stat
#else
#include <dirent.h>
#ifndef __sun
#include <fts.h>
#endif
#endif
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <time.h>
#include "doomtype.h"
#include "tarray.h"
#include "resourcefile.h"
#include "zstring.h"
#include "cmdlib.h"
#include "doomerrors.h"
@ -185,43 +171,6 @@ int FDirectory::AddDirectory(const char *dirpath)
return count;
}
#elif defined(__sun) || defined(__APPLE__)
int FDirectory::AddDirectory(const char *dirpath)
{
int count = 0;
TArray<FString> scanDirectories;
scanDirectories.Push(dirpath);
for(unsigned int i = 0;i < scanDirectories.Size();i++)
{
DIR* directory = opendir(scanDirectories[i].GetChars());
if (directory == NULL)
{
Printf("Could not read directory: %s\n", strerror(errno));
return 0;
}
struct dirent *file;
while((file = readdir(directory)) != NULL)
{
if(file->d_name[0] == '.') //File is hidden or ./.. directory so ignore it.
continue;
FString fullFileName = scanDirectories[i] + file->d_name;
if(DirExists(fullFileName.GetChars()))
{
scanDirectories.Push(scanDirectories[i] + file->d_name + "/");
continue;
}
AddEntry(scanDirectories[i] + file->d_name, fileStat.st_size);
count++;
}
closedir(directory);
}
return count;
}
#else
//==========================================================================
@ -246,6 +195,10 @@ int FDirectory::AddDirectory(const char *dirpath)
Printf("Failed to start directory traversal: %s\n", strerror(errno));
return 0;
}
const size_t namepos = strlen(Filename);
FString pathfix;
while ((ent = fts_read(fts)) != NULL)
{
if (ent->fts_info == FTS_D && ent->fts_name[0] == '.')
@ -263,7 +216,22 @@ int FDirectory::AddDirectory(const char *dirpath)
// We're only interested in remembering files.
continue;
}
AddEntry(ent->fts_path, ent->fts_statp->st_size);
// Some implementations add an extra separator between
// root of the hierarchy and entity's path.
// It needs to be removed in order to resolve
// lumps' relative paths properly.
const char* path = ent->fts_path;
if ('/' == path[namepos])
{
pathfix = FString(path, namepos);
pathfix.AppendCStrPart(&path[namepos + 1], ent->fts_pathlen - namepos - 1);
path = pathfix.GetChars();
}
AddEntry(path, ent->fts_statp->st_size);
count++;
}
fts_close(fts);

View file

@ -139,8 +139,8 @@ static FILE *mktempfile_internal(const char *tmpdir, const char *pfx, FString *t
int oflag, pmode;
/* In Windows, we use the _O_TEMPORARY flag with `open` to ensure the file is deleted when closed.
* In Unix, we use the unlink function after opening the file. (This does not work in Windows,
* which does not allow an open file to be unlinked.)
* In Unix, we use the remove function after opening the file. (This does not work in Windows,
* which does not allow an open file to be deleted.)
*/
#ifdef _WIN32
/* MSVC flags */
@ -175,7 +175,7 @@ static FILE *mktempfile_internal(const char *tmpdir, const char *pfx, FString *t
#ifndef _WIN32
/* [Unix only] And make sure the file will be deleted once closed */
if (!keep) remove(tmpname);
if (!keep) remove(tempname);
#endif
}

View file

@ -380,3 +380,41 @@ FString M_GetSavegamesPath()
}
return path;
}
//===========================================================================
//
// M_GetDocumentsPath Windows
//
// Returns the path to the default documents directory.
//
//===========================================================================
FString M_GetDocumentsPath()
{
FString path;
// A portable INI means that this storage location should also be portable.
path.Format("%s" GAMENAME "_portable.ini", progdir.GetChars());
if (FileExists(path))
{
return progdir;
}
if (!UseKnownFolders())
{
return progdir;
}
// Try defacto My Documents/My Games folder
else if (GetKnownFolder(CSIDL_PERSONAL, FOLDERID_Documents, true, path))
{
// I assume since this isn't a standard folder, it doesn't have
// a localized name either.
path << "/My Games/" GAMENAME;
CreatePath(path);
}
else
{
path = progdir;
}
return path;
}