mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
- Backend update.
This commit is contained in:
parent
ef7a7cc39d
commit
65c52b9825
8 changed files with 89 additions and 6 deletions
|
@ -1536,6 +1536,7 @@ int SoundEngine::AddSoundLump(const char* logicalname, int lump, int CurrentPitc
|
|||
newsfx.PitchMask = CurrentPitchMask;
|
||||
newsfx.NearLimit = nearlimit;
|
||||
newsfx.ResourceId = resid;
|
||||
newsfx.bTentative = false;
|
||||
|
||||
if (resid >= 0) ResIdMap[resid] = S_sfx.Size() - 1;
|
||||
return (int)S_sfx.Size()-1;
|
||||
|
|
|
@ -125,6 +125,12 @@ public:
|
|||
return Serialize(*this, key, obj, save_full? nullptr : &def);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
FSerializer& operator()(const char* key, T& obj, T* def)
|
||||
{
|
||||
return Serialize(*this, key, obj, !def || save_full ? nullptr : def);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
FSerializer &Array(const char *key, T *obj, int count, bool fullcompare = false)
|
||||
{
|
||||
|
@ -172,6 +178,29 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<class T, class Map>
|
||||
FSerializer &SparseArray(const char *key, T *obj, int count, const Map &map, bool fullcompare = false)
|
||||
{
|
||||
if (BeginArray(key))
|
||||
{
|
||||
int max = count;
|
||||
if (isReading())
|
||||
{
|
||||
max = ArraySize();
|
||||
}
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (map[i])
|
||||
{
|
||||
Serialize(*this, nullptr, obj[i], (T*)nullptr);
|
||||
if (--max < 0) break;
|
||||
}
|
||||
}
|
||||
EndArray();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
FSerializer &Enum(const char *key, T &obj)
|
||||
{
|
||||
|
|
|
@ -1446,7 +1446,7 @@ const char *FileSystem::GetResourceFileName (int rfnum) const noexcept
|
|||
|
||||
name = Files[rfnum]->FileName;
|
||||
slash = strrchr (name, '/');
|
||||
return slash != NULL ? slash+1 : name;
|
||||
return (slash != NULL && slash[1] != 0) ? slash+1 : name;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -57,6 +57,11 @@ FImageTexture::FImageTexture(FImageSource *img) noexcept
|
|||
}
|
||||
}
|
||||
|
||||
FImageTexture::~FImageTexture()
|
||||
{
|
||||
delete mImage;
|
||||
}
|
||||
|
||||
void FImageTexture::SetFromImage()
|
||||
{
|
||||
auto img = mImage;
|
||||
|
|
|
@ -357,6 +357,7 @@ protected:
|
|||
void SetFromImage();
|
||||
public:
|
||||
FImageTexture(FImageSource* image) noexcept;
|
||||
~FImageTexture();
|
||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
||||
|
||||
void SetImage(FImageSource* img)
|
||||
|
|
2
src/common/thirdparty/m_crc32.h
vendored
2
src/common/thirdparty/m_crc32.h
vendored
|
@ -31,7 +31,7 @@
|
|||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <zlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include <unistd.h>
|
||||
#include <fnmatch.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "cmdlib.h"
|
||||
|
||||
|
@ -203,6 +204,52 @@ bool D_AddFile(TArray<FString>& wadfiles, const char* file, bool check, int posi
|
|||
{
|
||||
return false;
|
||||
}
|
||||
#ifdef __unix__
|
||||
// Confirm file exists in filesystem.
|
||||
struct stat info;
|
||||
bool found = stat(file, &info) == 0;
|
||||
if (!found)
|
||||
{
|
||||
// File not found, so split file into path and filename so we can enumerate the path for the file.
|
||||
FString fullpath = file;
|
||||
auto lastindex = fullpath.LastIndexOf("/");
|
||||
FString basepath = fullpath.Left(lastindex);
|
||||
FString filename = fullpath.Right(fullpath.Len() - lastindex - 1);
|
||||
|
||||
// Proceed only if locating a file (i.e. `file` isn't a path to just a directory.)
|
||||
if (filename.IsNotEmpty())
|
||||
{
|
||||
DIR *d;
|
||||
struct dirent *dir;
|
||||
d = opendir(basepath.GetChars());
|
||||
if (d)
|
||||
{
|
||||
while ((dir = readdir(d)) != NULL)
|
||||
{
|
||||
if (filename.CompareNoCase(dir->d_name) == 0)
|
||||
{
|
||||
found = true;
|
||||
filename = dir->d_name;
|
||||
fullpath = basepath << "/" << filename;
|
||||
file = fullpath.GetChars();
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
if (!found)
|
||||
{
|
||||
Printf("Can't find file '%s' in '%s'\n", filename.GetChars(), basepath.GetChars());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf("Can't open directory '%s'\n", basepath.GetChars());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (check && !DirEntryExists(file))
|
||||
{
|
||||
|
|
|
@ -136,11 +136,11 @@ const T MAX (const T a, const T b)
|
|||
// Clamps in to the range [min,max].
|
||||
//==========================================================================
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
T clamp (const T in, const T min, const T max)
|
||||
template<typename T, typename X, typename Y>
|
||||
inline constexpr
|
||||
T clamp (const T in, const X min, const Y max)
|
||||
{
|
||||
return in <= min ? min : in >= max ? max : in;
|
||||
return in <= (T) min ? (T) min : in >= (T) max ? (T) max : in;
|
||||
}
|
||||
|
||||
#endif //__TEMPLATES_H__
|
||||
|
|
Loading…
Reference in a new issue