Skip to content

Commit

Permalink
xrGame: Adapt game state accumulator to new Typelist
Browse files Browse the repository at this point in the history
  • Loading branch information
Zegeri committed Sep 16, 2018
1 parent 1a56f03 commit 7119e15
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
12 changes: 2 additions & 10 deletions src/xrGame/game_state_accumulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class game_state_accumulator : public game_events_handler

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

private:
typedef AssociativeVector<enum_accumulative_player_values, player_state_param*> accumulative_values_collection_t;
using accumulative_values_collection_t = AssociativeVector<enum_accumulative_player_values, player_state_param*>;

private:
// average_values_collection_t m_average_values;
accumulative_values_collection_t m_accumulative_values;
CItemMgr const* m_item_mngr;
Expand All @@ -93,11 +93,6 @@ class game_state_accumulator : public game_events_handler
void init_accumulative_values();
void init_player_accum_values(game_PlayerState* new_local_player);

template <typename TypeListElement>
void init_acpv_list();
template <>
void init_acpv_list<Loki::EmptyType>(){};

void update_average_values();
void update_accumulative_values();

Expand All @@ -107,9 +102,6 @@ class game_state_accumulator : public game_events_handler
ammunition_group m_amm_groups;
bone_group m_bone_groups;
}; // class game_state_accumulator

#include "game_state_accumulator_inline.h"

} // namespace award_system

#endif //#ifndef GAME_STATE_ACCUMULATOR_INCLUDED
11 changes: 0 additions & 11 deletions src/xrGame/game_state_accumulator_inline.h

This file was deleted.

24 changes: 23 additions & 1 deletion src/xrGame/game_state_accumulator_state_register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,33 @@

namespace award_system
{
template <typename>
struct AccumulatorHelper;

template <>
struct AccumulatorHelper<Loki::Typelist<>> {
static void init_acpv(game_state_accumulator*,
game_state_accumulator::accumulative_values_collection_t&)
{
}
};

template <typename T, typename... Ts>
struct AccumulatorHelper<Loki::Typelist<T, Ts...>> {
static void init_acpv(game_state_accumulator* self,
game_state_accumulator::accumulative_values_collection_t& accumulative_values)
{
AccumulatorHelper<Loki::Typelist<Ts...>>::init_acpv(self, accumulative_values);
player_state_param* tmp_obj_inst = new typename T::value_type(self);
accumulative_values.insert(std::make_pair(T::value_id, tmp_obj_inst));
}
};

void game_state_accumulator::init_accumulative_values()
{
static_assert(Loki::TL::Length<ACCUMULATIVE_STATE_LIST>::value == acpv_count,
"Not all accumulative values has been added to a ACCUMULATIVE_STATE_LIST type list.");

init_acpv_list<ACCUMULATIVE_STATE_LIST>();
AccumulatorHelper<ACCUMULATIVE_STATE_LIST>::init_acpv(this, m_accumulative_values);
}
} // namespace award_system
1 change: 0 additions & 1 deletion src/xrGame/xrGame.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,6 @@
<ClInclude Include="game_path_manager.h" />
<ClInclude Include="game_path_manager_inline.h" />
<ClInclude Include="game_state_accumulator.h" />
<ClInclude Include="game_state_accumulator_inline.h" />
<ClInclude Include="game_sv_artefacthunt.h" />
<ClInclude Include="game_sv_base.h" />
<ClInclude Include="game_sv_base_console_vars.h" />
Expand Down
3 changes: 0 additions & 3 deletions src/xrGame/xrGame.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -5682,9 +5682,6 @@
<ClInclude Include="game_state_accumulator.h">
<Filter>Core\Server\Games\client\mp\award_system\player_state</Filter>
</ClInclude>
<ClInclude Include="game_state_accumulator_inline.h">
<Filter>Core\Server\Games\client\mp\award_system\player_state</Filter>
</ClInclude>
<ClInclude Include="hits_store.h">
<Filter>Core\Server\Games\client\mp\award_system\player_state</Filter>
</ClInclude>
Expand Down

0 comments on commit 7119e15

Please sign in to comment.