Skip to content

Commit 7119e15

Browse files
committed
xrGame: Adapt game state accumulator to new Typelist
1 parent 1a56f03 commit 7119e15

File tree

5 files changed

+25
-26
lines changed

5 files changed

+25
-26
lines changed

src/xrGame/game_state_accumulator.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ class game_state_accumulator : public game_events_handler
8080

8181
bool check_accumulative_value(enum_accumulative_player_values param_id, u32_binary_function* func, u32 right_arg);
8282

83-
private:
84-
typedef AssociativeVector<enum_accumulative_player_values, player_state_param*> accumulative_values_collection_t;
83+
using accumulative_values_collection_t = AssociativeVector<enum_accumulative_player_values, player_state_param*>;
8584

85+
private:
8686
// average_values_collection_t m_average_values;
8787
accumulative_values_collection_t m_accumulative_values;
8888
CItemMgr const* m_item_mngr;
@@ -93,11 +93,6 @@ class game_state_accumulator : public game_events_handler
9393
void init_accumulative_values();
9494
void init_player_accum_values(game_PlayerState* new_local_player);
9595

96-
template <typename TypeListElement>
97-
void init_acpv_list();
98-
template <>
99-
void init_acpv_list<Loki::EmptyType>(){};
100-
10196
void update_average_values();
10297
void update_accumulative_values();
10398

@@ -107,9 +102,6 @@ class game_state_accumulator : public game_events_handler
107102
ammunition_group m_amm_groups;
108103
bone_group m_bone_groups;
109104
}; // class game_state_accumulator
110-
111-
#include "game_state_accumulator_inline.h"
112-
113105
} // namespace award_system
114106

115107
#endif //#ifndef GAME_STATE_ACCUMULATOR_INCLUDED

src/xrGame/game_state_accumulator_inline.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/xrGame/game_state_accumulator_state_register.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,33 @@
3232

3333
namespace award_system
3434
{
35+
template <typename>
36+
struct AccumulatorHelper;
37+
38+
template <>
39+
struct AccumulatorHelper<Loki::Typelist<>> {
40+
static void init_acpv(game_state_accumulator*,
41+
game_state_accumulator::accumulative_values_collection_t&)
42+
{
43+
}
44+
};
45+
46+
template <typename T, typename... Ts>
47+
struct AccumulatorHelper<Loki::Typelist<T, Ts...>> {
48+
static void init_acpv(game_state_accumulator* self,
49+
game_state_accumulator::accumulative_values_collection_t& accumulative_values)
50+
{
51+
AccumulatorHelper<Loki::Typelist<Ts...>>::init_acpv(self, accumulative_values);
52+
player_state_param* tmp_obj_inst = new typename T::value_type(self);
53+
accumulative_values.insert(std::make_pair(T::value_id, tmp_obj_inst));
54+
}
55+
};
56+
3557
void game_state_accumulator::init_accumulative_values()
3658
{
3759
static_assert(Loki::TL::Length<ACCUMULATIVE_STATE_LIST>::value == acpv_count,
3860
"Not all accumulative values has been added to a ACCUMULATIVE_STATE_LIST type list.");
3961

40-
init_acpv_list<ACCUMULATIVE_STATE_LIST>();
62+
AccumulatorHelper<ACCUMULATIVE_STATE_LIST>::init_acpv(this, m_accumulative_values);
4163
}
4264
} // namespace award_system

src/xrGame/xrGame.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@
856856
<ClInclude Include="game_path_manager.h" />
857857
<ClInclude Include="game_path_manager_inline.h" />
858858
<ClInclude Include="game_state_accumulator.h" />
859-
<ClInclude Include="game_state_accumulator_inline.h" />
860859
<ClInclude Include="game_sv_artefacthunt.h" />
861860
<ClInclude Include="game_sv_base.h" />
862861
<ClInclude Include="game_sv_base_console_vars.h" />

src/xrGame/xrGame.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5682,9 +5682,6 @@
56825682
<ClInclude Include="game_state_accumulator.h">
56835683
<Filter>Core\Server\Games\client\mp\award_system\player_state</Filter>
56845684
</ClInclude>
5685-
<ClInclude Include="game_state_accumulator_inline.h">
5686-
<Filter>Core\Server\Games\client\mp\award_system\player_state</Filter>
5687-
</ClInclude>
56885685
<ClInclude Include="hits_store.h">
56895686
<Filter>Core\Server\Games\client\mp\award_system\player_state</Filter>
56905687
</ClInclude>

0 commit comments

Comments
 (0)