mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-06-03 10:41:12 +00:00
Update to ZDoom r1784:
- Added directory detection to the -file parameter. This obsoletes -dir, so that parameter is now gone. - Removed automatic ".wad" appending from FWadCollection::InitMultipleFiles() since it isn't needed and prevented files without extensions from being loaded. D_AddFile() already takes care of adding the extension if the name as-given does not exist. - Fixed: Loading single files did not print a newline in the startup text. - Fixed: A_JumpIf(InTarget)Inventory jumped if the check amount was greater than the item's max amount and the item was maxed. - Fixed: Some dmadds wads used zero-length sprites as placeholders. When you ran dmadds to combine it with the IWAD's sprites, they would be replaced by the IWAD's sprites, so when loading such wads, we should ignore those as valid sprites. (Thanks to entryway for finding this.) See 22ventry's 22sprite.wad for an example. - Replaced the use of autoconf's WORDS_BIGENDIAN with __BIG_ENDIAN__, since latter comes predefined by GCC. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@433 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
061394c3d9
commit
b8a584f65f
45 changed files with 461 additions and 158 deletions
179
src/cmdlib.cpp
179
src/cmdlib.cpp
|
@ -28,6 +28,14 @@ gamedir will hold progdir + the game directory (id1, id2, etc)
|
|||
|
||||
FString progdir;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// IsSeperator
|
||||
//
|
||||
// Returns true if the character is a path seperator.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static inline bool IsSeperator (int c)
|
||||
{
|
||||
if (c == '/')
|
||||
|
@ -39,6 +47,14 @@ static inline bool IsSeperator (int c)
|
|||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FixPathSeperator
|
||||
//
|
||||
// Convert backslashes to forward slashes.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FixPathSeperator (char *path)
|
||||
{
|
||||
while (*path)
|
||||
|
@ -49,6 +65,14 @@ void FixPathSeperator (char *path)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// copystring
|
||||
//
|
||||
// Replacement for strdup that uses new instead of malloc.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
char *copystring (const char *s)
|
||||
{
|
||||
char *b;
|
||||
|
@ -66,6 +90,13 @@ char *copystring (const char *s)
|
|||
return b;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// ReplaceString
|
||||
//
|
||||
// Do not use in new code.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void ReplaceString (char **ptr, const char *str)
|
||||
{
|
||||
|
@ -87,11 +118,12 @@ void ReplaceString (char **ptr, const char *str)
|
|||
*/
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Q_filelength
|
||||
================
|
||||
*/
|
||||
//==========================================================================
|
||||
//
|
||||
// Q_filelength
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int Q_filelength (FILE *f)
|
||||
{
|
||||
int pos;
|
||||
|
@ -106,17 +138,20 @@ int Q_filelength (FILE *f)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
FileExists
|
||||
==============
|
||||
*/
|
||||
//==========================================================================
|
||||
//
|
||||
// FileExists
|
||||
//
|
||||
// Returns true if the given path exists and is a readable file.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FileExists (const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
// [RH] Empty filenames are never there
|
||||
if (*filename == 0)
|
||||
if (filename == NULL || *filename == 0)
|
||||
return false;
|
||||
|
||||
f = fopen (filename, "r");
|
||||
|
@ -126,6 +161,31 @@ bool FileExists (const char *filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DirEntryExists
|
||||
//
|
||||
// Returns true if the given path exists, be it a directory or a file.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool DirEntryExists(const char *pathname)
|
||||
{
|
||||
if (pathname == NULL || *pathname == 0)
|
||||
return false;
|
||||
|
||||
struct stat info;
|
||||
return stat(pathname, &info) == 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DefaultExtension -- char array version
|
||||
//
|
||||
// Appends the extension to a pathname if it does not already have one.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DefaultExtension (char *path, const char *extension)
|
||||
{
|
||||
char *src;
|
||||
|
@ -145,6 +205,14 @@ void DefaultExtension (char *path, const char *extension)
|
|||
strcat (path, extension);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DefaultExtension -- FString version
|
||||
//
|
||||
// Appends the extension to a pathname if it does not already have one.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DefaultExtension (FString &path, const char *extension)
|
||||
{
|
||||
const char *src = &path[int(path.Len())-1];
|
||||
|
@ -160,13 +228,17 @@ void DefaultExtension (FString &path, const char *extension)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
Extract file parts
|
||||
====================
|
||||
*/
|
||||
//==========================================================================
|
||||
//
|
||||
// ExtractFilePath
|
||||
//
|
||||
// Returns the directory part of a pathname.
|
||||
//
|
||||
// FIXME: should include the slash, otherwise
|
||||
// backing to an empty path will be wrong when appending a slash
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FString ExtractFilePath (const char *path)
|
||||
{
|
||||
const char *src;
|
||||
|
@ -182,6 +254,14 @@ FString ExtractFilePath (const char *path)
|
|||
return FString(path, src - path);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// ExtractFileBase
|
||||
//
|
||||
// Returns the file part of a pathname, optionally including the extension.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FString ExtractFileBase (const char *path, bool include_extension)
|
||||
{
|
||||
const char *src, *dot;
|
||||
|
@ -221,11 +301,12 @@ FString ExtractFileBase (const char *path, bool include_extension)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
ParseNum / ParseHex
|
||||
==============
|
||||
*/
|
||||
//==========================================================================
|
||||
//
|
||||
// ParseHex
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int ParseHex (const char *hex)
|
||||
{
|
||||
const char *str;
|
||||
|
@ -253,6 +334,11 @@ int ParseHex (const char *hex)
|
|||
return num;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// ParseNum
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int ParseNum (const char *str)
|
||||
{
|
||||
|
@ -263,8 +349,13 @@ int ParseNum (const char *str)
|
|||
return atol (str);
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// IsNum
|
||||
//
|
||||
// [RH] Returns true if the specified string is a valid decimal number
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool IsNum (const char *str)
|
||||
{
|
||||
|
@ -279,7 +370,13 @@ bool IsNum (const char *str)
|
|||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CheckWildcards
|
||||
//
|
||||
// [RH] Checks if text matches the wildcard pattern using ? or *
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool CheckWildcards (const char *pattern, const char *text)
|
||||
{
|
||||
|
@ -317,7 +414,13 @@ bool CheckWildcards (const char *pattern, const char *text)
|
|||
return (*pattern | *text) == 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FormatGUID
|
||||
//
|
||||
// [RH] Print a GUID to a text buffer using the standard format.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FormatGUID (char *buffer, size_t buffsize, const GUID &guid)
|
||||
{
|
||||
|
@ -329,7 +432,14 @@ void FormatGUID (char *buffer, size_t buffsize, const GUID &guid)
|
|||
guid.Data4[6], guid.Data4[7]);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// myasctime
|
||||
//
|
||||
// [RH] Returns the current local time as ASCII, even if it's too early
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
const char *myasctime ()
|
||||
{
|
||||
time_t clock;
|
||||
|
@ -347,10 +457,13 @@ const char *myasctime ()
|
|||
}
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* CreatePath: creates a directory including all levels necessary */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
//==========================================================================
|
||||
//
|
||||
// CreatePath
|
||||
//
|
||||
// Creates a directory including all levels necessary
|
||||
//
|
||||
//==========================================================================
|
||||
#ifdef _WIN32
|
||||
void DoCreatePath(const char *fn)
|
||||
{
|
||||
|
@ -413,8 +526,14 @@ void CreatePath(const char *fn)
|
|||
}
|
||||
#endif
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// strbin1 -- In-place version
|
||||
//
|
||||
// [RH] Replaces the escape sequences in a string with actual escaped characters.
|
||||
// This operation is done in-place. The result is the new length of the string.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int strbin (char *str)
|
||||
{
|
||||
|
@ -504,8 +623,14 @@ int strbin (char *str)
|
|||
return int(str - start);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// strbin1 -- String-creating version
|
||||
//
|
||||
// [RH] Replaces the escape sequences in a string with actual escaped characters.
|
||||
// This operation is done in-place. The result is the new length of the string.
|
||||
// This operation is done in-place.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FString strbin1 (const char *start)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue