Skip to content

Commit 02891e5

Browse files
authored
Merge pull request #255 from drug007/award_system_refactoring
Award system refactoring
2 parents 3f1178e + 7ea7d33 commit 02891e5

29 files changed

+39
-187
lines changed

src/xrGame/accumulative_states.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef ACCUMULATIVE_STATES_INCLUDED
22
#define ACCUMULATIVE_STATES_INCLUDED
33

4-
#include <loki/Typelist.h>
5-
64
namespace award_system
75
{
86
enum enum_accumulative_player_values
@@ -46,22 +44,6 @@ enum enum_accumulative_player_values
4644
acpv_count,
4745
}; // enum enum_accumulative_player_values
4846

49-
namespace detail
50-
{
51-
template <enum_accumulative_player_values ValueId, typename T>
52-
struct accumulative_pair_t
53-
{
54-
static enum_accumulative_player_values const value_id = ValueId;
55-
typedef T value_type;
56-
}; // struct accumulative_pair_t
57-
} // namespace detail
58-
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;
63-
#define SAVE_TYPE_LIST(id, type) Accumulative_State_Type_##type
64-
6547
} // namespace award_system
6648

6749
#endif //#ifndef ACCUMULATIVE_STATES_INCLUDED

src/xrGame/black_list.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ class black_list : public player_state_param
2828
AssociativeVector<shared_str, u32> m_victims;
2929
}; // class black_list
3030

31-
ADD_ACCUMULATIVE_STATE(acpv_black_list, black_list);
32-
#undef ACCUMULATIVE_STATE_LIST
33-
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_black_list, black_list)
34-
3531
} // namespace award_system
3632

3733
#endif //#ifndef BLACK_LIST_INCLUDED

src/xrGame/command_switch_counter.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ class command_switch_counter : public player_state_param
2323
u32 m_counter;
2424
}; // class command_switch_counter
2525

26-
ADD_ACCUMULATIVE_STATE(acpv_command_switch_count, command_switch_counter);
27-
#undef ACCUMULATIVE_STATE_LIST
28-
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_command_switch_count, command_switch_counter)
29-
3026
} // namespace award_system
3127

3228
#endif //#ifndef COMMAND_SWITCH_COUNTER_INCLUDED

src/xrGame/double_shot_double_kill.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ class double_shot_double_kill : public player_state_param
3737
u32 m_shot_count;
3838
}; // class double_shot_double_kill
3939

40-
ADD_ACCUMULATIVE_STATE(acpv_double_shot_double_kill_time, double_shot_double_kill);
41-
#undef ACCUMULATIVE_STATE_LIST
42-
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_double_shot_double_kill_time, double_shot_double_kill)
43-
4440
} // namespace award_system
4541

4642
#endif //#ifndef DOUBLE_SHOT_DOUBLE_KILL_INCLUDED

src/xrGame/faster_than_bullets_time.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ class faster_than_bullets_time : public player_state_param
2626
u32 m_no_demag_time;
2727
}; // class faster_than_bullets_time
2828

29-
ADD_ACCUMULATIVE_STATE(acpv_faster_than_bullets_time, faster_than_bullets_time);
30-
#undef ACCUMULATIVE_STATE_LIST
31-
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_faster_than_bullets_time, faster_than_bullets_time)
32-
3329
} // namespace award_system
3430

3531
#endif //#ifndef FASTER_THAN_BULLETS_INCLUDED

src/xrGame/game_state_accumulator_state_register.cpp

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,49 @@
3030
#include "silent_shots.h"
3131
#include "killer_victim_velocity_angle.h"
3232

33+
#define INIT_ACCUMULATIVE_VALUE(Kind, SomeClass) \
34+
m_accumulative_values.insert(std::make_pair(Kind, new SomeClass(this)));
35+
3336
namespace award_system
3437
{
3538

36-
template <typename>
37-
struct AccumulatorHelper;
38-
39-
template <>
40-
struct AccumulatorHelper<Loki::NullType> {
41-
static void init_acpv(game_state_accumulator*,
42-
game_state_accumulator::accumulative_values_collection_t&)
43-
{
44-
}
45-
};
46-
47-
template <typename Head, typename Tail>
48-
struct AccumulatorHelper<Loki::Typelist<Head, Tail>> {
49-
static void init_acpv(game_state_accumulator* self,
50-
game_state_accumulator::accumulative_values_collection_t& accumulative_values)
51-
{
52-
AccumulatorHelper<Tail>::init_acpv(self, accumulative_values);
53-
player_state_param* tmp_obj_inst = new typename Head::value_type(self);
54-
accumulative_values.insert(std::make_pair(Head::value_id, tmp_obj_inst));
55-
}
56-
};
57-
5839
void game_state_accumulator::init_accumulative_values()
5940
{
60-
static_assert(Loki::TL::Length<ACCUMULATIVE_STATE_LIST>::value == acpv_count,
61-
"Not all accumulative values has been added to a ACCUMULATIVE_STATE_LIST type list.");
62-
63-
AccumulatorHelper<ACCUMULATIVE_STATE_LIST>::init_acpv(this, m_accumulative_values);
41+
INIT_ACCUMULATIVE_VALUE(acpv_mad, player_state_mad);
42+
INIT_ACCUMULATIVE_VALUE(acpv_spots, player_spots_counter);
43+
INIT_ACCUMULATIVE_VALUE(acpv_toughy, player_state_toughy);
44+
INIT_ACCUMULATIVE_VALUE(acpv_avenger, player_state_avenger);
45+
INIT_ACCUMULATIVE_VALUE(acpv_climber, player_state_climber);
46+
INIT_ACCUMULATIVE_VALUE(acpv_move_state, player_state_move);
47+
INIT_ACCUMULATIVE_VALUE(acpv_ambassador, player_state_ambassador);
48+
INIT_ACCUMULATIVE_VALUE(acpv_black_list, black_list);
49+
INIT_ACCUMULATIVE_VALUE(acpv_kill_in_raw, player_rawkill_counter);
50+
INIT_ACCUMULATIVE_VALUE(acpv_death_count, player_death_counter);
51+
INIT_ACCUMULATIVE_VALUE(acpv_remembrance, player_state_remembrance);
52+
INIT_ACCUMULATIVE_VALUE(acpv_cherub_ready, player_state_cherub);
53+
INIT_ACCUMULATIVE_VALUE(acpv_ammo_elapsed, player_state_ammo_elapsed);
54+
INIT_ACCUMULATIVE_VALUE(acpv_opener_ready, player_state_opener);
55+
INIT_ACCUMULATIVE_VALUE(acpv_skewer_count, player_state_skewer);
56+
INIT_ACCUMULATIVE_VALUE(acpv_stalker_flair, stalker_flair);
57+
INIT_ACCUMULATIVE_VALUE(acpv_thunder_count, silent_shots);
58+
INIT_ACCUMULATIVE_VALUE(acpv_move_velocity, player_state_velocity);
59+
INIT_ACCUMULATIVE_VALUE(acpv_harvest_count, harvest_time);
60+
INIT_ACCUMULATIVE_VALUE(acpv_marksman_count, player_state_marksman);
61+
INIT_ACCUMULATIVE_VALUE(acpv_multi_champion, player_multichampion);
62+
INIT_ACCUMULATIVE_VALUE(acpv_invincible_fury, player_state_invincible_fury);
63+
INIT_ACCUMULATIVE_VALUE(acpv_blitzkrieg_time, player_blitzkrieg);
64+
INIT_ACCUMULATIVE_VALUE(acpv_enemy_team_score, player_enemy_team_score);
65+
INIT_ACCUMULATIVE_VALUE(acpv_artdeliver_count, player_artdeliver_counter);
66+
INIT_ACCUMULATIVE_VALUE(acpv_my_team_win_score, player_team_win_score);
67+
INIT_ACCUMULATIVE_VALUE(acpv_move_ang_velocity, player_state_ang_velocity);
68+
INIT_ACCUMULATIVE_VALUE(acpv_achilles_heel_ready, achilles_heel_kill);
69+
INIT_ACCUMULATIVE_VALUE(acpv_killer_victim_angle, killer_victim_angle);
70+
INIT_ACCUMULATIVE_VALUE(acpv_enemy_top_player_div, player_spots_with_top_enemy_divider);
71+
INIT_ACCUMULATIVE_VALUE(acpv_command_switch_count, command_switch_counter);
72+
INIT_ACCUMULATIVE_VALUE(acpv_enemy_team_score_now, player_runtime_enemy_team_score);
73+
INIT_ACCUMULATIVE_VALUE(acpv_my_team_win_score_now, player_runtime_win_score);
74+
INIT_ACCUMULATIVE_VALUE(acpv_sprinter_victim_velocity, spritnter_stopper);
75+
INIT_ACCUMULATIVE_VALUE(acpv_faster_than_bullets_time, faster_than_bullets_time);
76+
INIT_ACCUMULATIVE_VALUE(acpv_double_shot_double_kill_time, double_shot_double_kill);
6477
}
6578
} // namespace award_system

src/xrGame/harvest_time.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ class harvest_time : public player_state_param
2828
u32 m_spawn_time;
2929
}; // class harvest_time
3030

31-
ADD_ACCUMULATIVE_STATE(acpv_harvest_count, harvest_time);
32-
#undef ACCUMULATIVE_STATE_LIST
33-
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_harvest_count, harvest_time)
34-
3531
} // namespace award_system
3632

3733
#endif //#ifndef HARVEST_TIME_INCLUDED

src/xrGame/invincible_fury.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ class player_state_invincible_fury : public player_state_param
2828
u32 m_last_kills;
2929
}; // class player_state_invincible_fury
3030

31-
ADD_ACCUMULATIVE_STATE(acpv_invincible_fury, player_state_invincible_fury);
32-
#undef ACCUMULATIVE_STATE_LIST
33-
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_invincible_fury, player_state_invincible_fury)
34-
3531
} // namespace award_system
3632

3733
#endif //#ifndef INVINCIBLE_FURY_INCLUDED

src/xrGame/killer_victim_velocity_angle.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ class killer_victim_angle : public player_state_param
2525
float m_killer_victim_angle_cos;
2626
}; // class killer_victim_angle
2727

28-
ADD_ACCUMULATIVE_STATE(acpv_killer_victim_angle, killer_victim_angle);
29-
#undef ACCUMULATIVE_STATE_LIST
30-
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_killer_victim_angle, killer_victim_angle)
31-
3228
} // namespace award_system
3329

3430
#endif //#ifndef KILLER_VICTIM_VELOCITY_ANGLE_INCLUDED

src/xrGame/player_spot_params.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ class player_spots_counter : public player_state_param
2222
virtual void reset_game(){};
2323
}; // class player_spots_counter
2424

25-
ADD_ACCUMULATIVE_STATE(acpv_spots, player_spots_counter);
26-
#undef ACCUMULATIVE_STATE_LIST
27-
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_spots, player_spots_counter)
28-
2925
class player_spots_with_top_enemy_divider : public player_spots_counter
3026
{
3127
typedef player_spots_counter inherited;
@@ -40,10 +36,6 @@ class player_spots_with_top_enemy_divider : public player_spots_counter
4036
u32 const get_top_enemy_player_score();
4137
}; // player_spots_with_top_enemy_divider
4238

43-
ADD_ACCUMULATIVE_STATE(acpv_enemy_top_player_div, player_spots_with_top_enemy_divider);
44-
#undef ACCUMULATIVE_STATE_LIST
45-
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_enemy_top_player_div, player_spots_with_top_enemy_divider)
46-
4739
} // namespace award_system
4840

4941
#endif //#ifndef PLAYER_SPOT_PARAMS_INCLUDED

0 commit comments

Comments
 (0)