mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-03-10 03:02:21 +00:00
Merge remote-tracking branch 'gzdoom/master' into qz-master-2021-10-27
This commit is contained in:
commit
356756a1a7
21 changed files with 349 additions and 30 deletions
|
@ -245,7 +245,7 @@ if( MSVC )
|
||||||
set( DEB_C_FLAGS "/D _CRTDBG_MAP_ALLOC /MTd" )
|
set( DEB_C_FLAGS "/D _CRTDBG_MAP_ALLOC /MTd" )
|
||||||
|
|
||||||
# Disable warnings for unsecure CRT functions from VC8+
|
# Disable warnings for unsecure CRT functions from VC8+
|
||||||
set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4996 /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600" )
|
set( ALL_C_FLAGS "${ALL_C_FLAGS} /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS" )
|
||||||
|
|
||||||
# The CMake configurations set /GR and /MD by default, which conflict with our settings.
|
# The CMake configurations set /GR and /MD by default, which conflict with our settings.
|
||||||
string(REPLACE "/MD " " " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )
|
string(REPLACE "/MD " " " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )
|
||||||
|
|
|
@ -132,7 +132,7 @@ public:
|
||||||
|
|
||||||
RenderCommand()
|
RenderCommand()
|
||||||
{
|
{
|
||||||
memset(this, 0, sizeof(*this));
|
memset((void*)this, 0, sizeof(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If these fields match, two draw commands can be batched.
|
// If these fields match, two draw commands can be batched.
|
||||||
|
|
|
@ -686,6 +686,17 @@ void ReadBindings(int lump, bool override)
|
||||||
FKeyBindings* dest = &Bindings;
|
FKeyBindings* dest = &Bindings;
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
|
if (sc.Compare("unbind"))
|
||||||
|
{
|
||||||
|
sc.MustGetString();
|
||||||
|
if (override)
|
||||||
|
{
|
||||||
|
// This is only for games to clear unsuitable base defaults, not for mods.
|
||||||
|
dest->UnbindKey(sc.String);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// bind destination is optional and is the same as the console command
|
// bind destination is optional and is the same as the console command
|
||||||
if (sc.Compare("bind"))
|
if (sc.Compare("bind"))
|
||||||
{
|
{
|
||||||
|
@ -722,7 +733,18 @@ void ReadBindings(int lump, bool override)
|
||||||
void C_SetDefaultKeys(const char* baseconfig)
|
void C_SetDefaultKeys(const char* baseconfig)
|
||||||
{
|
{
|
||||||
auto lump = fileSystem.CheckNumForFullName("engine/commonbinds.txt");
|
auto lump = fileSystem.CheckNumForFullName("engine/commonbinds.txt");
|
||||||
if (lump >= 0) ReadBindings(lump, true);
|
if (lump >= 0)
|
||||||
|
{
|
||||||
|
// Bail out if a mod tries to override this. Main game resources are allowed to do this, though.
|
||||||
|
auto fileno2 = fileSystem.GetFileContainer(lump);
|
||||||
|
if (fileno2 > fileSystem.GetMaxIwadNum())
|
||||||
|
{
|
||||||
|
I_FatalError("File %s is overriding core lump %s.",
|
||||||
|
fileSystem.GetResourceFileFullName(fileno2), "engine/commonbinds.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadBindings(lump, true);
|
||||||
|
}
|
||||||
int lastlump = 0;
|
int lastlump = 0;
|
||||||
|
|
||||||
while ((lump = fileSystem.FindLumpFullName(baseconfig, &lastlump)) != -1)
|
while ((lump = fileSystem.FindLumpFullName(baseconfig, &lastlump)) != -1)
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
struct GrpInfo
|
struct GrpHeader
|
||||||
{
|
{
|
||||||
uint32_t Magic[3];
|
uint32_t Magic[3];
|
||||||
uint32_t NumLumps;
|
uint32_t NumLumps;
|
||||||
|
@ -95,7 +95,7 @@ FGrpFile::FGrpFile(const char *filename, FileReader &file)
|
||||||
|
|
||||||
bool FGrpFile::Open(bool quiet, LumpFilterInfo*)
|
bool FGrpFile::Open(bool quiet, LumpFilterInfo*)
|
||||||
{
|
{
|
||||||
GrpInfo header;
|
GrpHeader header;
|
||||||
|
|
||||||
Reader.Read(&header, sizeof(header));
|
Reader.Read(&header, sizeof(header));
|
||||||
NumLumps = LittleLong(header.NumLumps);
|
NumLumps = LittleLong(header.NumLumps);
|
||||||
|
@ -105,7 +105,7 @@ bool FGrpFile::Open(bool quiet, LumpFilterInfo*)
|
||||||
|
|
||||||
Lumps.Resize(NumLumps);
|
Lumps.Resize(NumLumps);
|
||||||
|
|
||||||
int Position = sizeof(GrpInfo) + NumLumps * sizeof(GrpLump);
|
int Position = sizeof(GrpHeader) + NumLumps * sizeof(GrpLump);
|
||||||
|
|
||||||
for(uint32_t i = 0; i < NumLumps; i++)
|
for(uint32_t i = 0; i < NumLumps; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,9 +111,9 @@ void I_InitGraphics ()
|
||||||
// todo: implement ATI version of this. this only works for nvidia notebooks, for now.
|
// todo: implement ATI version of this. this only works for nvidia notebooks, for now.
|
||||||
currentgpuswitch = vid_gpuswitch;
|
currentgpuswitch = vid_gpuswitch;
|
||||||
if (currentgpuswitch == 1)
|
if (currentgpuswitch == 1)
|
||||||
putenv("SHIM_MCCOMPAT=0x800000001"); // discrete
|
_putenv("SHIM_MCCOMPAT=0x800000001"); // discrete
|
||||||
else if (currentgpuswitch == 2)
|
else if (currentgpuswitch == 2)
|
||||||
putenv("SHIM_MCCOMPAT=0x800000000"); // integrated
|
_putenv("SHIM_MCCOMPAT=0x800000000"); // integrated
|
||||||
|
|
||||||
// If the focus window is destroyed, it doesn't go back to the active window.
|
// If the focus window is destroyed, it doesn't go back to the active window.
|
||||||
// (e.g. because the net pane was up, and a button on it had focus)
|
// (e.g. because the net pane was up, and a button on it had focus)
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
// HEADER FILES ------------------------------------------------------------
|
// HEADER FILES ------------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma warning(disable:4996)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <richedit.h>
|
#include <richedit.h>
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
// HEADER FILES ------------------------------------------------------------
|
// HEADER FILES ------------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma warning(disable:4996)
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -25,6 +25,17 @@
|
||||||
</Expand>
|
</Expand>
|
||||||
</Type>
|
</Type>
|
||||||
|
|
||||||
|
<Type Name="TSparseArrayView<*>">
|
||||||
|
<DisplayString>Size = {Count}</DisplayString>
|
||||||
|
<Expand>
|
||||||
|
<Item Name="Size">Count</Item>
|
||||||
|
<ArrayItems>
|
||||||
|
<Size>Count</Size>
|
||||||
|
<ValuePointer>(value_type*)Array</ValuePointer>
|
||||||
|
</ArrayItems>
|
||||||
|
</Expand>
|
||||||
|
</Type>
|
||||||
|
|
||||||
<Type Name="TStaticPointedArray<*>">
|
<Type Name="TStaticPointedArray<*>">
|
||||||
<DisplayString>Size = {Count}</DisplayString>
|
<DisplayString>Size = {Count}</DisplayString>
|
||||||
<Expand>
|
<Expand>
|
||||||
|
|
|
@ -12,10 +12,7 @@ struct HWSkyPortal;
|
||||||
struct HWDrawInfo;
|
struct HWDrawInfo;
|
||||||
|
|
||||||
// 57 world units roughly represent one sky texel for the glTranslate call.
|
// 57 world units roughly represent one sky texel for the glTranslate call.
|
||||||
enum
|
const int skyoffsetfactor = 57;
|
||||||
{
|
|
||||||
skyoffsetfactor = 57
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FSkyVertex
|
struct FSkyVertex
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "poly_thread.h"
|
#include "poly_thread.h"
|
||||||
#include "screen_scanline_setup.h"
|
#include "screen_scanline_setup.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "poly_triangle.h"
|
#include "poly_triangle.h"
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "flatvertices.h"
|
#include "flatvertices.h"
|
||||||
#include "r_videoscale.h"
|
#include "r_videoscale.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "templates.h"
|
|
||||||
|
|
||||||
EXTERN_CVAR(Int, gl_dither_bpc)
|
EXTERN_CVAR(Int, gl_dither_bpc)
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "vulkan/system/vk_builders.h"
|
#include "vulkan/system/vk_builders.h"
|
||||||
#include "vulkan/system/vk_framebuffer.h"
|
#include "vulkan/system/vk_framebuffer.h"
|
||||||
#include "hw_cvars.h"
|
#include "hw_cvars.h"
|
||||||
#include "templates.h"
|
|
||||||
|
|
||||||
VkRenderBuffers::VkRenderBuffers()
|
VkRenderBuffers::VkRenderBuffers()
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "vulkan/renderer/vk_renderpass.h"
|
#include "vulkan/renderer/vk_renderpass.h"
|
||||||
#include "vulkan/renderer/vk_renderbuffers.h"
|
#include "vulkan/renderer/vk_renderbuffers.h"
|
||||||
#include "vulkan/textures/vk_hwtexture.h"
|
#include "vulkan/textures/vk_hwtexture.h"
|
||||||
#include "templates.h"
|
|
||||||
#include "hw_skydome.h"
|
#include "hw_skydome.h"
|
||||||
#include "hw_viewpointuniforms.h"
|
#include "hw_viewpointuniforms.h"
|
||||||
#include "hw_lightbuffer.h"
|
#include "hw_lightbuffer.h"
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "m_png.h"
|
#include "m_png.h"
|
||||||
#include "templates.h"
|
|
||||||
#include "r_videoscale.h"
|
#include "r_videoscale.h"
|
||||||
#include "i_time.h"
|
#include "i_time.h"
|
||||||
#include "v_text.h"
|
#include "v_text.h"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "templates.h"
|
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
#include "hw_material.h"
|
#include "hw_material.h"
|
||||||
#include "hw_cvars.h"
|
#include "hw_cvars.h"
|
||||||
|
|
|
@ -572,7 +572,7 @@ void FMultipatchTextureBuilder::ParsePatch(FScanner &sc, BuildInfo &info, TexPar
|
||||||
else if (sc.Compare("alpha"))
|
else if (sc.Compare("alpha"))
|
||||||
{
|
{
|
||||||
sc.MustGetFloat();
|
sc.MustGetFloat();
|
||||||
part.Alpha = clamp<blend_t>(int(sc.Float * BLENDUNIT), 0, BLENDUNIT);
|
part.Alpha = clamp<blend_t>(int(sc.Float * +BLENDUNIT), 0, BLENDUNIT);
|
||||||
// bComplex is not set because it is only needed when the style is not OP_COPY.
|
// bComplex is not set because it is only needed when the style is not OP_COPY.
|
||||||
}
|
}
|
||||||
else if (sc.Compare("style"))
|
else if (sc.Compare("style"))
|
||||||
|
|
1
src/common/thirdparty/rapidjson/document.h
vendored
1
src/common/thirdparty/rapidjson/document.h
vendored
|
@ -29,6 +29,7 @@ RAPIDJSON_DIAG_PUSH
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
|
RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant
|
||||||
RAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible loss of data
|
RAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible loss of data
|
||||||
|
RAPIDJSON_DIAG_OFF(4996) // deprecation of std::iterator
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
|
|
@ -248,7 +248,7 @@ bool GetFileInfo(const char* pathname, size_t *size, time_t *time)
|
||||||
bool res = _wstat64(wstr.c_str(), &info) == 0;
|
bool res = _wstat64(wstr.c_str(), &info) == 0;
|
||||||
#endif
|
#endif
|
||||||
if (!res || (info.st_mode & S_IFDIR)) return false;
|
if (!res || (info.st_mode & S_IFDIR)) return false;
|
||||||
if (size) *size = (size_t)info.st_size;
|
if (size) *size = info.st_size;
|
||||||
if (time) *time = info.st_mtime;
|
if (time) *time = info.st_mtime;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,14 +63,14 @@
|
||||||
|
|
||||||
#include "m_alloc.h"
|
#include "m_alloc.h"
|
||||||
|
|
||||||
template<typename T> class TIterator : public std::iterator<std::random_access_iterator_tag, T>
|
template<typename T> class TIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename TIterator::value_type value_type;
|
using iterator_category = std::random_access_iterator_tag;
|
||||||
typedef typename TIterator::difference_type difference_type;
|
using value_type = T;
|
||||||
typedef typename TIterator::pointer pointer;
|
using difference_type = ptrdiff_t;
|
||||||
typedef typename TIterator::reference reference;
|
using pointer = value_type*;
|
||||||
typedef typename TIterator::iterator_category iterator_category;
|
using reference = value_type&;
|
||||||
|
|
||||||
TIterator(T* ptr = nullptr) { m_ptr = ptr; }
|
TIterator(T* ptr = nullptr) { m_ptr = ptr; }
|
||||||
|
|
||||||
|
@ -125,6 +125,8 @@ public:
|
||||||
|
|
||||||
typedef TIterator<T> iterator;
|
typedef TIterator<T> iterator;
|
||||||
typedef TIterator<const T> const_iterator;
|
typedef TIterator<const T> const_iterator;
|
||||||
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
|
||||||
iterator begin()
|
iterator begin()
|
||||||
|
@ -153,6 +155,31 @@ public:
|
||||||
return &Array[Count];
|
return &Array[Count];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reverse_iterator rbegin()
|
||||||
|
{
|
||||||
|
return reverse_iterator(end());
|
||||||
|
}
|
||||||
|
const_reverse_iterator rbegin() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(end());
|
||||||
|
}
|
||||||
|
const_reverse_iterator crbegin() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(cend());
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse_iterator rend()
|
||||||
|
{
|
||||||
|
return reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
const_reverse_iterator rend() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
const_reverse_iterator crend() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(cbegin());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////
|
////////
|
||||||
|
@ -636,6 +663,8 @@ public:
|
||||||
|
|
||||||
typedef TIterator<T> iterator;
|
typedef TIterator<T> iterator;
|
||||||
typedef TIterator<const T> const_iterator;
|
typedef TIterator<const T> const_iterator;
|
||||||
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
|
||||||
iterator begin()
|
iterator begin()
|
||||||
|
@ -664,6 +693,32 @@ public:
|
||||||
return &Array[Count];
|
return &Array[Count];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reverse_iterator rbegin()
|
||||||
|
{
|
||||||
|
return reverse_iterator(end());
|
||||||
|
}
|
||||||
|
const_reverse_iterator rbegin() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(end());
|
||||||
|
}
|
||||||
|
const_reverse_iterator crbegin() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(cend());
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse_iterator rend()
|
||||||
|
{
|
||||||
|
return reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
const_reverse_iterator rend() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
const_reverse_iterator crend() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(cbegin());
|
||||||
|
}
|
||||||
|
|
||||||
void Init(T *ptr, unsigned cnt)
|
void Init(T *ptr, unsigned cnt)
|
||||||
{
|
{
|
||||||
Array = ptr;
|
Array = ptr;
|
||||||
|
@ -1579,7 +1634,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
BitArray(unsigned elem)
|
BitArray(unsigned elem)
|
||||||
: bytes((elem + 7) / 8, true)
|
: bytes((elem + 7) / 8, true), size(elem)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1637,6 +1692,11 @@ public:
|
||||||
{
|
{
|
||||||
memset(&bytes[0], 0, bytes.Size());
|
memset(&bytes[0], 0, bytes.Size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TArray<uint8_t> &Storage()
|
||||||
|
{
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1704,6 +1764,8 @@ public:
|
||||||
|
|
||||||
typedef TIterator<T> iterator;
|
typedef TIterator<T> iterator;
|
||||||
typedef TIterator<const T> const_iterator;
|
typedef TIterator<const T> const_iterator;
|
||||||
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
|
||||||
iterator begin()
|
iterator begin()
|
||||||
|
@ -1732,6 +1794,32 @@ public:
|
||||||
return &Array[Count];
|
return &Array[Count];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reverse_iterator rbegin()
|
||||||
|
{
|
||||||
|
return reverse_iterator(end());
|
||||||
|
}
|
||||||
|
const_reverse_iterator rbegin() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(end());
|
||||||
|
}
|
||||||
|
const_reverse_iterator crbegin() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(cend());
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse_iterator rend()
|
||||||
|
{
|
||||||
|
return reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
const_reverse_iterator rend() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
const_reverse_iterator crend() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(cbegin());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////
|
////////
|
||||||
TArrayView() = default; // intended to keep this type trivial.
|
TArrayView() = default; // intended to keep this type trivial.
|
||||||
|
@ -1807,3 +1895,203 @@ private:
|
||||||
T *Array;
|
T *Array;
|
||||||
unsigned int Count;
|
unsigned int Count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T> class TSparseIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using iterator_category = std::random_access_iterator_tag;
|
||||||
|
using value_type = T;
|
||||||
|
using difference_type = ptrdiff_t;
|
||||||
|
using pointer = value_type*;
|
||||||
|
using reference = value_type&;
|
||||||
|
|
||||||
|
TSparseIterator(unsigned char* ptr = nullptr, unsigned stride = 0) { m_Ptr = ptr; Stride = stride; }
|
||||||
|
|
||||||
|
// Comparison operators
|
||||||
|
bool operator==(const TSparseIterator &other) const { return m_Ptr == other.m_Ptr; }
|
||||||
|
bool operator!=(const TSparseIterator &other) const { return m_Ptr != other.m_Ptr; }
|
||||||
|
bool operator< (const TSparseIterator &other) const { return m_Ptr < other.m_Ptr; }
|
||||||
|
bool operator<=(const TSparseIterator &other) const { return m_Ptr <= other.m_Ptr; }
|
||||||
|
bool operator> (const TSparseIterator &other) const { return m_Ptr > other.m_Ptr; }
|
||||||
|
bool operator>=(const TSparseIterator &other) const { return m_Ptr >= other.m_Ptr; }
|
||||||
|
|
||||||
|
// Arithmetic operators
|
||||||
|
TSparseIterator &operator++() { m_Ptr += Stride; return *this; }
|
||||||
|
TSparseIterator operator++(int) { auto tmp = *this; ++*this; return tmp; }
|
||||||
|
TSparseIterator &operator--() { m_Ptr -= Stride; return *this; }
|
||||||
|
TSparseIterator operator--(int) { auto tmp = *this; --*this; return tmp; }
|
||||||
|
TSparseIterator &operator+=(difference_type offset) { m_Ptr += offset * Stride; return *this; }
|
||||||
|
TSparseIterator operator+(difference_type offset) const { return TSparseIterator(m_Ptr + offset * Stride, Stride); }
|
||||||
|
friend TSparseIterator operator+(difference_type offset, const TSparseIterator &other) { return TSparseIterator(offset*other.Stride + other.m_Ptr, other.Stride); }
|
||||||
|
TSparseIterator &operator-=(difference_type offset) { m_Ptr -= offset * Stride; return *this; }
|
||||||
|
TSparseIterator operator-(difference_type offset) const { return TSparseIterator(m_Ptr - offset * Stride, Stride); }
|
||||||
|
difference_type operator-(const TSparseIterator &other) const { return (m_Ptr - other.m_Ptr) / Stride; }
|
||||||
|
|
||||||
|
// Random access operators
|
||||||
|
T& operator[](difference_type i) { return *(T*)(m_Ptr + i * Stride); }
|
||||||
|
const T& operator[](difference_type i) const { return *(T*)(m_Ptr + i * Stride); }
|
||||||
|
|
||||||
|
T &operator*() const { return (T*)m_Ptr; }
|
||||||
|
T* operator->() { return (T*)m_Ptr; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
unsigned char* m_Ptr;
|
||||||
|
unsigned Stride;
|
||||||
|
};
|
||||||
|
|
||||||
|
// A wrapper to externally stored data.
|
||||||
|
// Like the above but with a customizable stride
|
||||||
|
template <class T>
|
||||||
|
class TSparseArrayView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef TSparseIterator<T> iterator;
|
||||||
|
typedef TSparseIterator<const T> const_iterator;
|
||||||
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
|
typedef T value_type;
|
||||||
|
|
||||||
|
iterator begin()
|
||||||
|
{
|
||||||
|
return iterator(Array, Stride);
|
||||||
|
}
|
||||||
|
const_iterator begin() const
|
||||||
|
{
|
||||||
|
return const_iterator(Array, Stride);
|
||||||
|
}
|
||||||
|
const_iterator cbegin() const
|
||||||
|
{
|
||||||
|
return const_iterator(Array, Stride);
|
||||||
|
}
|
||||||
|
|
||||||
|
iterator end()
|
||||||
|
{
|
||||||
|
return iterator(Array + Count * Stride, Stride);
|
||||||
|
}
|
||||||
|
const_iterator end() const
|
||||||
|
{
|
||||||
|
return const_iterator(Array + Count * Stride, Stride);
|
||||||
|
}
|
||||||
|
const_iterator cend() const
|
||||||
|
{
|
||||||
|
return const_iterator(Array + Count * Stride, Stride);
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse_iterator rbegin()
|
||||||
|
{
|
||||||
|
return reverse_iterator(end());
|
||||||
|
}
|
||||||
|
const_reverse_iterator rbegin() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(end());
|
||||||
|
}
|
||||||
|
const_reverse_iterator crbegin() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(cend());
|
||||||
|
}
|
||||||
|
|
||||||
|
reverse_iterator rend()
|
||||||
|
{
|
||||||
|
return reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
const_reverse_iterator rend() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(begin());
|
||||||
|
}
|
||||||
|
const_reverse_iterator crend() const
|
||||||
|
{
|
||||||
|
return const_reverse_iterator(cbegin());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////
|
||||||
|
TSparseArrayView() = default; // intended to keep this type trivial.
|
||||||
|
TSparseArrayView(T *data, unsigned stride, unsigned count = 0)
|
||||||
|
{
|
||||||
|
Count = count;
|
||||||
|
Array = data;
|
||||||
|
Stride = stride;
|
||||||
|
}
|
||||||
|
TSparseArrayView(const TSparseArrayView<T> &other) = default;
|
||||||
|
TSparseArrayView<T> &operator= (const TSparseArrayView<T> &other) = default;
|
||||||
|
|
||||||
|
// Check equality of two arrays
|
||||||
|
bool operator==(const TArrayView<T> &other) const
|
||||||
|
{
|
||||||
|
if (Count != other.Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (unsigned int i = 0; i < Count; ++i)
|
||||||
|
{
|
||||||
|
if (Element(i) != other.Element(i))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
T &Element(size_t index)
|
||||||
|
{
|
||||||
|
return (T*)Array[index*Stride];
|
||||||
|
}
|
||||||
|
// Return a reference to an element
|
||||||
|
T &operator[] (size_t index) const
|
||||||
|
{
|
||||||
|
return Element(index);
|
||||||
|
}
|
||||||
|
// Returns a reference to the last element
|
||||||
|
T &Last() const
|
||||||
|
{
|
||||||
|
return Element(Count - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns address of first element
|
||||||
|
T *Data() const
|
||||||
|
{
|
||||||
|
return &Element(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Size() const
|
||||||
|
{
|
||||||
|
return Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Find(const T& item) const
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
for (i = 0; i < Count; ++i)
|
||||||
|
{
|
||||||
|
if (Element(i) == item)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(T *data, unsigned stride, unsigned count)
|
||||||
|
{
|
||||||
|
Array = reinterpret_cast<unsigned char*>(data);
|
||||||
|
Count = count;
|
||||||
|
Stride = stride;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(void *data, unsigned stride, unsigned count)
|
||||||
|
{
|
||||||
|
Array = reinterpret_cast<unsigned char*>(data);
|
||||||
|
Count = count;
|
||||||
|
Stride = stride;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
Count = 0;
|
||||||
|
Stride = 0;
|
||||||
|
Array = nullptr;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
unsigned char* Array;
|
||||||
|
unsigned int Count;
|
||||||
|
unsigned int Stride;
|
||||||
|
};
|
||||||
|
|
|
@ -621,7 +621,7 @@ class Actor : Thinker native
|
||||||
native static int GetSpriteIndex(name sprt);
|
native static int GetSpriteIndex(name sprt);
|
||||||
native clearscope static double GetDefaultSpeed(class<Actor> type);
|
native clearscope static double GetDefaultSpeed(class<Actor> type);
|
||||||
native static class<Actor> GetSpawnableType(int spawnnum);
|
native static class<Actor> GetSpawnableType(int spawnnum);
|
||||||
native static int ApplyDamageFactors(class<Inventory> itemcls, Name damagetype, int damage, int defdamage);
|
native clearscope static int ApplyDamageFactors(class<Inventory> itemcls, Name damagetype, int damage, int defdamage);
|
||||||
native void RemoveFromHash();
|
native void RemoveFromHash();
|
||||||
native void ChangeTid(int newtid);
|
native void ChangeTid(int newtid);
|
||||||
deprecated("3.8", "Use Level.FindUniqueTid() instead") static int FindUniqueTid(int start = 0, int limit = 0)
|
deprecated("3.8", "Use Level.FindUniqueTid() instead") static int FindUniqueTid(int start = 0, int limit = 0)
|
||||||
|
|
Loading…
Reference in a new issue