mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
- cleanup of -map setup.
This commit is contained in:
parent
cb051b44ea
commit
ec96ae8992
4 changed files with 37 additions and 37 deletions
|
@ -47,6 +47,7 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -757,3 +758,17 @@ bool IsAbsPath(const char *name)
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void NormalizeFileName(FString &str)
|
||||||
|
{
|
||||||
|
auto strp = str.LockBuffer();
|
||||||
|
Bcorrectfilename(strp, false);
|
||||||
|
str.UnlockBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ bool DirEntryExists (const char *pathname, bool *isdir = nullptr);
|
||||||
extern FString progdir;
|
extern FString progdir;
|
||||||
|
|
||||||
void DefaultExtension (FString &path, const char *extension);
|
void DefaultExtension (FString &path, const char *extension);
|
||||||
|
void NormalizeFileName(FString &str);
|
||||||
|
|
||||||
FString ExtractFilePath (const char *path);
|
FString ExtractFilePath (const char *path);
|
||||||
FString ExtractFileBase (const char *path, bool keep_extension=false);
|
FString ExtractFileBase (const char *path, bool keep_extension=false);
|
||||||
|
|
|
@ -5656,38 +5656,30 @@ static void G_Startup(void)
|
||||||
|
|
||||||
if (userConfig.CommandMap.IsNotEmpty())
|
if (userConfig.CommandMap.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
FString startupMap;
|
||||||
if (VOLUMEONE)
|
if (VOLUMEONE)
|
||||||
{
|
{
|
||||||
initprintf("The -map option is available in the registered version only!\n");
|
initprintf("The -map option is available in the registered version only!\n");
|
||||||
boardfilename[0] = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *dot, *slash;
|
startupMap = userConfig.CommandMap;
|
||||||
|
if (startupMap.IndexOfAny("/\\") < 0) startupMap.Insert(0, "/");
|
||||||
|
DefaultExtension(startupMap, ".map");
|
||||||
|
startupMap.Substitute("\\", "/");
|
||||||
|
NormalizeFileName(startupMap);
|
||||||
|
|
||||||
boardfilename[0] = '/';
|
if (fileSystem.FileExists(startupMap))
|
||||||
boardfilename[1] = 0;
|
|
||||||
Bstrcat(boardfilename, userConfig.CommandMap);
|
|
||||||
|
|
||||||
dot = Bstrrchr(boardfilename,'.');
|
|
||||||
slash = Bstrrchr(boardfilename,'/');
|
|
||||||
if (!slash) slash = Bstrrchr(boardfilename,'\\');
|
|
||||||
|
|
||||||
if ((!slash && !dot) || (slash && dot < slash))
|
|
||||||
Bstrcat(boardfilename,".map");
|
|
||||||
|
|
||||||
Bcorrectfilename(boardfilename,0);
|
|
||||||
|
|
||||||
if (fileSystem.FileExists(boardfilename))
|
|
||||||
{
|
{
|
||||||
initprintf("Using level: \"%s\".\n",boardfilename);
|
initprintf("Using level: \"%s\".\n",startupMap.GetChars());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
initprintf("Level \"%s\" not found.\n",boardfilename);
|
initprintf("Level \"%s\" not found.\n",startupMap.GetChars());
|
||||||
boardfilename[0] = 0;
|
boardfilename[0] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
strncpy(boardfilename, startupMap, BMAX_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<MAXPLAYERS; i++)
|
for (i=0; i<MAXPLAYERS; i++)
|
||||||
|
|
|
@ -7094,38 +7094,30 @@ static void G_Startup(void)
|
||||||
|
|
||||||
if (userConfig.CommandMap.IsNotEmpty())
|
if (userConfig.CommandMap.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
FString startupMap;
|
||||||
if (VOLUMEONE)
|
if (VOLUMEONE)
|
||||||
{
|
{
|
||||||
initprintf("The -map option is available in the registered version only!\n");
|
initprintf("The -map option is available in the registered version only!\n");
|
||||||
boardfilename[0] = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *dot, *slash;
|
startupMap = userConfig.CommandMap;
|
||||||
|
if (startupMap.IndexOfAny("/\\") < 0) startupMap.Insert(0, "/");
|
||||||
|
DefaultExtension(startupMap, ".map");
|
||||||
|
startupMap.Substitute("\\", "/");
|
||||||
|
NormalizeFileName(startupMap);
|
||||||
|
|
||||||
boardfilename[0] = '/';
|
if (fileSystem.FileExists(startupMap))
|
||||||
boardfilename[1] = 0;
|
{
|
||||||
Bstrcat(boardfilename, userConfig.CommandMap);
|
initprintf("Using level: \"%s\".\n",startupMap.GetChars());
|
||||||
|
|
||||||
dot = Bstrrchr(boardfilename,'.');
|
|
||||||
slash = Bstrrchr(boardfilename,'/');
|
|
||||||
if (!slash) slash = Bstrrchr(boardfilename,'\\');
|
|
||||||
|
|
||||||
if ((!slash && !dot) || (slash && dot < slash))
|
|
||||||
Bstrcat(boardfilename,".map");
|
|
||||||
|
|
||||||
Bcorrectfilename(boardfilename,0);
|
|
||||||
|
|
||||||
if (fileSystem.FileExists(boardfilename))
|
|
||||||
{
|
|
||||||
initprintf("Using level: \"%s\".\n",boardfilename);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
initprintf("Level \"%s\" not found.\n",boardfilename);
|
initprintf("Level \"%s\" not found.\n",startupMap.GetChars());
|
||||||
boardfilename[0] = 0;
|
boardfilename[0] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
strncpy(boardfilename, startupMap, BMAX_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<MAXPLAYERS; i++)
|
for (i=0; i<MAXPLAYERS; i++)
|
||||||
|
|
Loading…
Reference in a new issue