Move array_size into valptridx_specialized_types
This commit is contained in:
parent
dad504cfef
commit
db77622f0e
|
@ -6,7 +6,7 @@
|
|||
#include "segnum.h"
|
||||
|
||||
template <typename managed_type>
|
||||
class valptridx_specialized_types;
|
||||
using valptridx_specialized_types = decltype(valptridx_specialized_type(static_cast<managed_type *>(nullptr)));
|
||||
|
||||
template <typename managed_type>
|
||||
class valptridx :
|
||||
|
@ -34,8 +34,9 @@ protected:
|
|||
using const_pointer_type = const managed_type *;
|
||||
using const_reference_type = const managed_type &;
|
||||
using mutable_pointer_type = managed_type *;
|
||||
using index_type = typename specialized_types::index_type;
|
||||
using typename specialized_types::integral_type;
|
||||
using index_type = integral_type; // deprecated; should be dedicated UDT
|
||||
using specialized_types::array_size;
|
||||
|
||||
template <typename policy, unsigned>
|
||||
class basic_idx;
|
||||
|
@ -52,10 +53,6 @@ protected:
|
|||
{
|
||||
return get_global_array(p);
|
||||
}
|
||||
static constexpr std::size_t get_array_size()
|
||||
{
|
||||
return get_array().size();
|
||||
}
|
||||
static inline void check_index_match(const_reference_type, index_type, const array_managed_type &);
|
||||
static inline index_type check_index_range(index_type, const array_managed_type &);
|
||||
static inline void check_explicit_index_range_ref(const_reference_type, std::size_t, const array_managed_type &);
|
||||
|
@ -106,15 +103,18 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
template <typename INTEGRAL_TYPE, std::size_t array_size_value>
|
||||
class valptridx_specialized_type_parameters
|
||||
{
|
||||
public:
|
||||
using integral_type = INTEGRAL_TYPE;
|
||||
static constexpr std::size_t array_size = array_size_value;
|
||||
};
|
||||
|
||||
#define DXX_VALPTRIDX_DEFINE_SUBTYPE_TYPEDEF(managed_type,derived_type_prefix,vcprefix,suffix) \
|
||||
typedef valptridx<managed_type>::vcprefix##suffix vcprefix##derived_type_prefix##suffix##_t
|
||||
#define DXX_VALPTRIDX_DECLARE_GLOBAL_SUBTYPE(managed_type,derived_type_prefix,global_array) \
|
||||
#define DXX_VALPTRIDX_DECLARE_GLOBAL_SUBTYPE(managed_type,derived_type_prefix,global_array,array_size_value) \
|
||||
struct managed_type; \
|
||||
template <> \
|
||||
class valptridx_specialized_types<managed_type> { \
|
||||
public: \
|
||||
using index_type = derived_type_prefix##num_t; \
|
||||
using integral_type = derived_type_prefix##num_t; \
|
||||
}; \
|
||||
valptridx_specialized_type_parameters<derived_type_prefix##num_t, array_size_value> valptridx_specialized_type(managed_type *); \
|
||||
extern valptridx<managed_type>::array_managed_type global_array; \
|
||||
DXX_VALPTRIDX_SUBTYPE(DXX_VALPTRIDX_DEFINE_SUBTYPE_TYPEDEF, managed_type, derived_type_prefix)
|
||||
|
|
|
@ -259,7 +259,7 @@ public:
|
|||
basic_idx(const magic_constant<v> &) :
|
||||
m_idx(v)
|
||||
{
|
||||
static_assert(allow_nullptr || static_cast<std::size_t>(v) < get_array_size(), "invalid magic index not allowed for this policy");
|
||||
static_assert(allow_nullptr || static_cast<std::size_t>(v) < array_size, "invalid magic index not allowed for this policy");
|
||||
}
|
||||
template <typename rpolicy, unsigned ru>
|
||||
bool operator==(const basic_idx<rpolicy, ru> &rhs) const
|
||||
|
@ -273,7 +273,7 @@ public:
|
|||
template <integral_type v>
|
||||
bool operator==(const magic_constant<v> &) const
|
||||
{
|
||||
static_assert(allow_nullptr || static_cast<std::size_t>(v) < get_array_size(), "invalid magic index not allowed for this policy");
|
||||
static_assert(allow_nullptr || static_cast<std::size_t>(v) < array_size, "invalid magic index not allowed for this policy");
|
||||
return m_idx == v;
|
||||
}
|
||||
template <typename R>
|
||||
|
@ -322,14 +322,14 @@ public:
|
|||
basic_ptr(const magic_constant<v> &) :
|
||||
m_ptr(nullptr)
|
||||
{
|
||||
static_assert(static_cast<std::size_t>(v) >= get_array_size(), "valid magic index requires an array");
|
||||
static_assert(allow_nullptr || static_cast<std::size_t>(v) < get_array_size(), "invalid magic index not allowed for this policy");
|
||||
static_assert(static_cast<std::size_t>(v) >= array_size, "valid magic index requires an array");
|
||||
static_assert(allow_nullptr || static_cast<std::size_t>(v) < array_size, "invalid magic index not allowed for this policy");
|
||||
}
|
||||
template <integral_type v>
|
||||
basic_ptr(const magic_constant<v> &, array_managed_type &a) :
|
||||
m_ptr(static_cast<std::size_t>(v) < get_array_size() ? &(a[v]) : nullptr)
|
||||
m_ptr(static_cast<std::size_t>(v) < array_size ? &(a[v]) : nullptr)
|
||||
{
|
||||
static_assert(allow_nullptr || static_cast<std::size_t>(v) < get_array_size(), "invalid magic index not allowed for this policy");
|
||||
static_assert(allow_nullptr || static_cast<std::size_t>(v) < array_size, "invalid magic index not allowed for this policy");
|
||||
}
|
||||
template <typename rpolicy, unsigned ru>
|
||||
basic_ptr(const basic_ptr<rpolicy, ru> &rhs) :
|
||||
|
@ -520,10 +520,10 @@ public:
|
|||
};
|
||||
|
||||
template <typename managed_type>
|
||||
class valptridx<managed_type>::array_managed_type : public array<managed_type, get_array_size()>
|
||||
class valptridx<managed_type>::array_managed_type : public array<managed_type, array_size>
|
||||
{
|
||||
using containing_type = valptridx<managed_type>;
|
||||
using array_type = array<managed_type, get_array_size()>;
|
||||
using array_type = array<managed_type, array_size>;
|
||||
public:
|
||||
using typename array_type::reference;
|
||||
using typename array_type::const_reference;
|
||||
|
|
|
@ -20,21 +20,15 @@ struct bitmap_index;
|
|||
struct vms_vector;
|
||||
struct vms_matrix;
|
||||
|
||||
DXX_VALPTRIDX_DECLARE_GLOBAL_SUBTYPE(object, obj, Objects);
|
||||
constexpr std::size_t MAX_OBJECTS = 350;
|
||||
DXX_VALPTRIDX_DECLARE_GLOBAL_SUBTYPE(object, obj, Objects, MAX_OBJECTS);
|
||||
|
||||
static constexpr valptridx<object>::magic_constant<0xfffe> object_guidebot_cannot_reach{};
|
||||
static constexpr valptridx<object>::magic_constant<0xffff> object_none{};
|
||||
static constexpr valptridx<object>::magic_constant<0> object_first{};
|
||||
|
||||
const unsigned MAX_OBJECTS = 350;
|
||||
const unsigned MAX_USED_OBJECTS = MAX_OBJECTS - 20;
|
||||
|
||||
template <>
|
||||
constexpr std::size_t valptridx<object>::get_array_size()
|
||||
{
|
||||
return MAX_OBJECTS;
|
||||
}
|
||||
|
||||
enum object_type_t : int;
|
||||
|
||||
#if defined(DXX_BUILD_DESCENT_I)
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
#include "dxxsconf.h"
|
||||
#include "compiler-array.h"
|
||||
|
||||
DXX_VALPTRIDX_DECLARE_GLOBAL_SUBTYPE(segment, seg, Segments);
|
||||
constexpr std::size_t MAX_SEGMENTS = 9000;
|
||||
DXX_VALPTRIDX_DECLARE_GLOBAL_SUBTYPE(segment, seg, Segments, MAX_SEGMENTS);
|
||||
|
||||
static constexpr valptridx<segment>::magic_constant<0xfffe> segment_exit{};
|
||||
static constexpr valptridx<segment>::magic_constant<0xffff> segment_none{};
|
||||
|
@ -30,15 +31,8 @@ const std::size_t MAX_VERTICES_PER_POLY = 4;
|
|||
|
||||
const std::size_t MAX_SEGMENTS_ORIGINAL = 900;
|
||||
const std::size_t MAX_SEGMENT_VERTICES_ORIGINAL = 4*MAX_SEGMENTS_ORIGINAL;
|
||||
const std::size_t MAX_SEGMENTS = 9000;
|
||||
const std::size_t MAX_SEGMENT_VERTICES = 4*MAX_SEGMENTS;
|
||||
|
||||
template <>
|
||||
constexpr std::size_t valptridx<segment>::get_array_size()
|
||||
{
|
||||
return MAX_SEGMENTS;
|
||||
}
|
||||
|
||||
typedef uint_fast32_t sidenum_fast_t;
|
||||
|
||||
enum sidenum_t : uint8_t
|
||||
|
|
|
@ -240,8 +240,8 @@ static void info_display_default(int show_all)
|
|||
//---------------- Number of objects -----------------
|
||||
|
||||
if ( old_Num_objects != num_objects ) {
|
||||
gr_uprintf( 0, 32, "Objs: %3d/%3d", num_objects, MAX_OBJECTS );
|
||||
old_Num_objects = num_objects;
|
||||
gr_uprintf( 0, 32, "Objs: %3d/%3lu", num_objects, static_cast<unsigned long>(MAX_OBJECTS));
|
||||
}
|
||||
|
||||
//--------------- Current_segment_number -------------
|
||||
|
|
Loading…
Reference in a new issue