Skip to content

Commit ed249cc

Browse files
committed
Revert Typelist reimplementation and try a simpler approach
This reverts commit 7119e15. This reverts commit cace3a3. This reverts commit d5d013d. This reverts commit daf0085. This reverts commit d14b08d.
1 parent 71c3a08 commit ed249cc

15 files changed

+1192
-141
lines changed

sdk/include/loki/HierarchyGenerators.h

Lines changed: 369 additions & 10 deletions
Large diffs are not rendered by default.

sdk/include/loki/TypeManip.h

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,7 @@ namespace Loki
6060
template <bool flag, typename T, typename U>
6161
struct Select
6262
{
63-
private:
64-
template<bool>
65-
struct In
66-
{ typedef T Result; };
67-
68-
template<>
69-
struct In<false>
70-
{ typedef U Result; };
71-
72-
public:
73-
typedef typename In<flag>::Result Result;
63+
using Result = std::conditional_t<flag, T, U>;
7464
};
7565

7666

@@ -84,20 +74,8 @@ namespace Loki
8474
////////////////////////////////////////////////////////////////////////////////
8575

8676
template <typename T, typename U>
87-
struct IsSameType
88-
{
89-
private:
90-
template<typename>
91-
struct In
92-
{ enum { value = false }; };
93-
94-
template<>
95-
struct In<T>
96-
{ enum { value = true }; };
97-
98-
public:
99-
enum { value = In<U>::value };
100-
};
77+
struct IsSameType : std::is_same<T, U>
78+
{};
10179

10280
////////////////////////////////////////////////////////////////////////////////
10381
// Helper types Small and Big - guarantee that sizeof(Small) < sizeof(Big)

sdk/include/loki/Typelist.h

Lines changed: 755 additions & 58 deletions
Large diffs are not rendered by default.

src/xrGame/accumulative_states.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ struct accumulative_pair_t
5656
}; // struct accumulative_pair_t
5757
} // namespace detail
5858

59-
#define ACCUMULATIVE_STATE_LIST Loki::Typelist<>
60-
#define ADD_ACCUMULATIVE_STATE(id, type) using Accumulative_State_Type_##type = \
61-
Loki::TL::Prepend<detail::accumulative_pair_t<id, type>, ACCUMULATIVE_STATE_LIST>::result
59+
#define ACCUMULATIVE_STATE_LIST Loki::NullType
60+
#define ADD_ACCUMULATIVE_STATE(id, type) \
61+
typedef Loki::Typelist<detail::accumulative_pair_t<id, type>, ACCUMULATIVE_STATE_LIST> \
62+
Accumulative_State_Type_##type;
6263
#define SAVE_TYPE_LIST(id, type) Accumulative_State_Type_##type
6364

6465
} // namespace award_system

src/xrGame/alife_registry_container.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,35 @@
1212
#include "alife_space.h"
1313
#include "Common/object_type_traits.h"
1414

15-
template <typename, typename>
15+
template <typename TContainer, typename TList>
1616
struct RegistryHelper;
1717

1818
template <typename TContainer>
19-
struct RegistryHelper<TContainer, Loki::Typelist<>>
19+
struct RegistryHelper<TContainer, Loki::NullType>
2020
{
2121
static void Save(TContainer*, IWriter&) {};
2222
static void Load(TContainer*, IReader&) {};
2323
};
2424

25-
template <typename TContainer, typename T, typename... Ts>
26-
struct RegistryHelper<TContainer, Loki::Typelist<T, Ts...>>
25+
template <typename TContainer, typename Head, typename Tail>
26+
struct RegistryHelper<TContainer, Loki::Typelist<Head, Tail>>
2727
{
28-
static constexpr bool isSerializable = object_type_traits::is_base_and_derived<ISerializable, T>::value;
28+
static constexpr bool isSerializable =
29+
object_type_traits::is_base_and_derived<ISerializable, Head>::value;
2930

3031
static void Save(TContainer* self, IWriter& writer)
3132
{
3233
if constexpr (isSerializable)
33-
self->T::save(writer);
34-
RegistryHelper<TContainer, Loki::Typelist<Ts...>>::Save(self, writer);
34+
self->Head::save(writer);
35+
RegistryHelper<TContainer, Tail>::Save(self, writer);
3536
};
3637

3738
static void Load(TContainer* self, IReader& reader)
3839
{
3940
if constexpr (isSerializable)
40-
self->T::load(reader);
41-
RegistryHelper<TContainer, Loki::Typelist<Ts...>>::Load(self, reader);
41+
self->Head::load(reader);
42+
RegistryHelper<TContainer, Tail>::Load(self, reader);
4243
}
43-
4444
};
4545

4646
void CALifeRegistryContainer::load(IReader& file_stream)

src/xrGame/alife_registry_container.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct CLinearRegistryType : public _base, public _type
1717
{
1818
};
1919

20-
class CALifeRegistryContainer : public Loki::GenLinearHierarchy<registry_type_list, CLinearRegistryType>
20+
class CALifeRegistryContainer : public Loki::GenLinearHierarchy<registry_type_list, CLinearRegistryType>::LinBase
2121
{
2222
private:
2323
typedef registry_type_list TYPE_LIST;

src/xrGame/alife_registry_container_space.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#pragma once
1010

1111
#include <loki/HierarchyGenerators.h>
12-
#define registry_type_list Loki::Typelist<>
13-
#define add_to_registry_type_list(a) using registry_##a = Loki::TL::Prepend<a, registry_type_list>::result;
12+
#define registry_type_list Loki::NullType
13+
#define add_to_registry_type_list(a) typedef Loki::Typelist<a, registry_type_list> registry_##a;
1414
#define define_constant(a) (a*)0
1515
#define save_registry_type_list(a) registry_##a

src/xrGame/base_client_classes_wrappers.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ struct linear_registrator<_type, Loki::EmptyType> : public _type
3434
template <typename _1, typename _2>
3535
struct heritage
3636
{
37-
using tl = Loki::Typelist<_1, _2>;
38-
using result = Loki::GenLinearHierarchy<tl, linear_registrator>;
37+
typedef Loki::Typelist<_1, Loki::Typelist<_2, Loki::NullType>> tl;
38+
typedef typename Loki::TL::Erase<tl, Loki::EmptyType>::Result pure_tl;
39+
typedef typename Loki::GenLinearHierarchy<pure_tl, linear_registrator>::LinBase result;
3940
};
4041

4142
template <typename base>

src/xrGame/game_state_accumulator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class game_state_accumulator : public game_events_handler
8181
bool check_accumulative_value(enum_accumulative_player_values param_id, u32_binary_function* func, u32 right_arg);
8282

8383
using accumulative_values_collection_t = AssociativeVector<enum_accumulative_player_values, player_state_param*>;
84-
8584
private:
8685
// average_values_collection_t m_average_values;
8786
accumulative_values_collection_t m_accumulative_values;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
template <typename TypeListElement>
2+
void game_state_accumulator::init_acpv_list()
3+
{
4+
static_assert(Loki::TL::is_Typelist<TypeListElement>::value,
5+
"Type must have a Loki Type List type use ADD_ACCUMULATIVE_STATE macro define.");
6+
init_acpv_list<TypeListElement::Tail>();
7+
8+
player_state_param* tmp_obj_inst = new typename TypeListElement::Head::value_type(this);
9+
10+
m_accumulative_values.insert(std::make_pair(TypeListElement::Head::value_id, tmp_obj_inst));
11+
}

0 commit comments

Comments
 (0)