Skip to content

Commit

Permalink
Merge pull request #255 from drug007/award_system_refactoring
Browse files Browse the repository at this point in the history
Award system refactoring
  • Loading branch information
Xottab-DUTY committed Oct 19, 2018
2 parents 3f1178e + 7ea7d33 commit 02891e5
Show file tree
Hide file tree
Showing 29 changed files with 39 additions and 187 deletions.
18 changes: 0 additions & 18 deletions src/xrGame/accumulative_states.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef ACCUMULATIVE_STATES_INCLUDED
#define ACCUMULATIVE_STATES_INCLUDED

#include <loki/Typelist.h>

namespace award_system
{
enum enum_accumulative_player_values
Expand Down Expand Up @@ -46,22 +44,6 @@ enum enum_accumulative_player_values
acpv_count,
}; // enum enum_accumulative_player_values

namespace detail
{
template <enum_accumulative_player_values ValueId, typename T>
struct accumulative_pair_t
{
static enum_accumulative_player_values const value_id = ValueId;
typedef T value_type;
}; // struct accumulative_pair_t
} // namespace detail

#define ACCUMULATIVE_STATE_LIST Loki::NullType
#define ADD_ACCUMULATIVE_STATE(id, type) \
typedef Loki::Typelist<detail::accumulative_pair_t<id, type>, ACCUMULATIVE_STATE_LIST> \
Accumulative_State_Type_##type;
#define SAVE_TYPE_LIST(id, type) Accumulative_State_Type_##type

} // namespace award_system

#endif //#ifndef ACCUMULATIVE_STATES_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/black_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class black_list : public player_state_param
AssociativeVector<shared_str, u32> m_victims;
}; // class black_list

ADD_ACCUMULATIVE_STATE(acpv_black_list, black_list);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_black_list, black_list)

} // namespace award_system

#endif //#ifndef BLACK_LIST_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/command_switch_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ class command_switch_counter : public player_state_param
u32 m_counter;
}; // class command_switch_counter

ADD_ACCUMULATIVE_STATE(acpv_command_switch_count, command_switch_counter);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_command_switch_count, command_switch_counter)

} // namespace award_system

#endif //#ifndef COMMAND_SWITCH_COUNTER_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/double_shot_double_kill.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ class double_shot_double_kill : public player_state_param
u32 m_shot_count;
}; // class double_shot_double_kill

ADD_ACCUMULATIVE_STATE(acpv_double_shot_double_kill_time, double_shot_double_kill);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_double_shot_double_kill_time, double_shot_double_kill)

} // namespace award_system

#endif //#ifndef DOUBLE_SHOT_DOUBLE_KILL_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/faster_than_bullets_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ class faster_than_bullets_time : public player_state_param
u32 m_no_demag_time;
}; // class faster_than_bullets_time

ADD_ACCUMULATIVE_STATE(acpv_faster_than_bullets_time, faster_than_bullets_time);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_faster_than_bullets_time, faster_than_bullets_time)

} // namespace award_system

#endif //#ifndef FASTER_THAN_BULLETS_INCLUDED
65 changes: 39 additions & 26 deletions src/xrGame/game_state_accumulator_state_register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,49 @@
#include "silent_shots.h"
#include "killer_victim_velocity_angle.h"

#define INIT_ACCUMULATIVE_VALUE(Kind, SomeClass) \
m_accumulative_values.insert(std::make_pair(Kind, new SomeClass(this)));

namespace award_system
{

template <typename>
struct AccumulatorHelper;

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

template <typename Head, typename Tail>
struct AccumulatorHelper<Loki::Typelist<Head, Tail>> {
static void init_acpv(game_state_accumulator* self,
game_state_accumulator::accumulative_values_collection_t& accumulative_values)
{
AccumulatorHelper<Tail>::init_acpv(self, accumulative_values);
player_state_param* tmp_obj_inst = new typename Head::value_type(self);
accumulative_values.insert(std::make_pair(Head::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.");

AccumulatorHelper<ACCUMULATIVE_STATE_LIST>::init_acpv(this, m_accumulative_values);
INIT_ACCUMULATIVE_VALUE(acpv_mad, player_state_mad);
INIT_ACCUMULATIVE_VALUE(acpv_spots, player_spots_counter);
INIT_ACCUMULATIVE_VALUE(acpv_toughy, player_state_toughy);
INIT_ACCUMULATIVE_VALUE(acpv_avenger, player_state_avenger);
INIT_ACCUMULATIVE_VALUE(acpv_climber, player_state_climber);
INIT_ACCUMULATIVE_VALUE(acpv_move_state, player_state_move);
INIT_ACCUMULATIVE_VALUE(acpv_ambassador, player_state_ambassador);
INIT_ACCUMULATIVE_VALUE(acpv_black_list, black_list);
INIT_ACCUMULATIVE_VALUE(acpv_kill_in_raw, player_rawkill_counter);
INIT_ACCUMULATIVE_VALUE(acpv_death_count, player_death_counter);
INIT_ACCUMULATIVE_VALUE(acpv_remembrance, player_state_remembrance);
INIT_ACCUMULATIVE_VALUE(acpv_cherub_ready, player_state_cherub);
INIT_ACCUMULATIVE_VALUE(acpv_ammo_elapsed, player_state_ammo_elapsed);
INIT_ACCUMULATIVE_VALUE(acpv_opener_ready, player_state_opener);
INIT_ACCUMULATIVE_VALUE(acpv_skewer_count, player_state_skewer);
INIT_ACCUMULATIVE_VALUE(acpv_stalker_flair, stalker_flair);
INIT_ACCUMULATIVE_VALUE(acpv_thunder_count, silent_shots);
INIT_ACCUMULATIVE_VALUE(acpv_move_velocity, player_state_velocity);
INIT_ACCUMULATIVE_VALUE(acpv_harvest_count, harvest_time);
INIT_ACCUMULATIVE_VALUE(acpv_marksman_count, player_state_marksman);
INIT_ACCUMULATIVE_VALUE(acpv_multi_champion, player_multichampion);
INIT_ACCUMULATIVE_VALUE(acpv_invincible_fury, player_state_invincible_fury);
INIT_ACCUMULATIVE_VALUE(acpv_blitzkrieg_time, player_blitzkrieg);
INIT_ACCUMULATIVE_VALUE(acpv_enemy_team_score, player_enemy_team_score);
INIT_ACCUMULATIVE_VALUE(acpv_artdeliver_count, player_artdeliver_counter);
INIT_ACCUMULATIVE_VALUE(acpv_my_team_win_score, player_team_win_score);
INIT_ACCUMULATIVE_VALUE(acpv_move_ang_velocity, player_state_ang_velocity);
INIT_ACCUMULATIVE_VALUE(acpv_achilles_heel_ready, achilles_heel_kill);
INIT_ACCUMULATIVE_VALUE(acpv_killer_victim_angle, killer_victim_angle);
INIT_ACCUMULATIVE_VALUE(acpv_enemy_top_player_div, player_spots_with_top_enemy_divider);
INIT_ACCUMULATIVE_VALUE(acpv_command_switch_count, command_switch_counter);
INIT_ACCUMULATIVE_VALUE(acpv_enemy_team_score_now, player_runtime_enemy_team_score);
INIT_ACCUMULATIVE_VALUE(acpv_my_team_win_score_now, player_runtime_win_score);
INIT_ACCUMULATIVE_VALUE(acpv_sprinter_victim_velocity, spritnter_stopper);
INIT_ACCUMULATIVE_VALUE(acpv_faster_than_bullets_time, faster_than_bullets_time);
INIT_ACCUMULATIVE_VALUE(acpv_double_shot_double_kill_time, double_shot_double_kill);
}
} // namespace award_system
4 changes: 0 additions & 4 deletions src/xrGame/harvest_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class harvest_time : public player_state_param
u32 m_spawn_time;
}; // class harvest_time

ADD_ACCUMULATIVE_STATE(acpv_harvest_count, harvest_time);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_harvest_count, harvest_time)

} // namespace award_system

#endif //#ifndef HARVEST_TIME_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/invincible_fury.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class player_state_invincible_fury : public player_state_param
u32 m_last_kills;
}; // class player_state_invincible_fury

ADD_ACCUMULATIVE_STATE(acpv_invincible_fury, player_state_invincible_fury);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_invincible_fury, player_state_invincible_fury)

} // namespace award_system

#endif //#ifndef INVINCIBLE_FURY_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/killer_victim_velocity_angle.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ class killer_victim_angle : public player_state_param
float m_killer_victim_angle_cos;
}; // class killer_victim_angle

ADD_ACCUMULATIVE_STATE(acpv_killer_victim_angle, killer_victim_angle);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_killer_victim_angle, killer_victim_angle)

} // namespace award_system

#endif //#ifndef KILLER_VICTIM_VELOCITY_ANGLE_INCLUDED
8 changes: 0 additions & 8 deletions src/xrGame/player_spot_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class player_spots_counter : public player_state_param
virtual void reset_game(){};
}; // class player_spots_counter

ADD_ACCUMULATIVE_STATE(acpv_spots, player_spots_counter);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_spots, player_spots_counter)

class player_spots_with_top_enemy_divider : public player_spots_counter
{
typedef player_spots_counter inherited;
Expand All @@ -40,10 +36,6 @@ class player_spots_with_top_enemy_divider : public player_spots_counter
u32 const get_top_enemy_player_score();
}; // player_spots_with_top_enemy_divider

ADD_ACCUMULATIVE_STATE(acpv_enemy_top_player_div, player_spots_with_top_enemy_divider);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_enemy_top_player_div, player_spots_with_top_enemy_divider)

} // namespace award_system

#endif //#ifndef PLAYER_SPOT_PARAMS_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/player_state_achilles_heel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ class achilles_heel_kill : public player_state_param
bool m_achilles_kill_was;
}; // class achilles_heel_kill

ADD_ACCUMULATIVE_STATE(acpv_achilles_heel_ready, achilles_heel_kill);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_achilles_heel_ready, achilles_heel_kill)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_ACHILLES_HEEL_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/player_state_ambassador.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class player_state_ambassador : public player_state_param
bool m_delivered;
}; // class player_state_ambassador

ADD_ACCUMULATIVE_STATE(acpv_ambassador, player_state_ambassador);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_ambassador, player_state_ambassador)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_AMBASSADOR_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/player_state_ammo_elapsed.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class player_state_ammo_elapsed : public player_state_param
virtual void reset_game(){};
}; // class player_state_ammo_elapsed

ADD_ACCUMULATIVE_STATE(acpv_ammo_elapsed, player_state_ammo_elapsed);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_ammo_elapsed, player_state_ammo_elapsed)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_AMMO_ELAPSED_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/player_state_avenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class player_state_avenger : public player_state_param
u32 m_aveng_count;
}; // class player_state_avenger

ADD_ACCUMULATIVE_STATE(acpv_avenger, player_state_avenger);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_avenger, player_state_avenger)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_AVENGER
4 changes: 0 additions & 4 deletions src/xrGame/player_state_blitzkrieg.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class player_blitzkrieg : public player_state_param
u32 m_art_drop_count;
}; // class player_blitzkrieg

ADD_ACCUMULATIVE_STATE(acpv_blitzkrieg_time, player_blitzkrieg);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_blitzkrieg_time, player_blitzkrieg)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_BLITZKRIEG_INCLUDED
3 changes: 0 additions & 3 deletions src/xrGame/player_state_cherub.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class player_state_cherub : public player_state_param
shared_str m_bearer_name;
}; // class player_state_cherub

ADD_ACCUMULATIVE_STATE(acpv_cherub_ready, player_state_cherub);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_cherub_ready, player_state_cherub)
}

#endif //#ifndef PLAYER_STATE_CHERUB_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/player_state_climber.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class player_state_climber : public player_state_param
bool m_player_is_climber;
}; // class player_state_climber

ADD_ACCUMULATIVE_STATE(acpv_climber, player_state_climber);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_climber, player_state_climber)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_CLIMBER_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/player_state_mad.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class player_state_mad : public player_state_param
void clear_old_kills();
}; // class player_state_mad

ADD_ACCUMULATIVE_STATE(acpv_mad, player_state_mad);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_mad, player_state_mad)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_MAD_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/player_state_marksman.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ class player_state_marksman : public player_state_param
u32 m_spawn_time;
}; // class player_state_marksman

ADD_ACCUMULATIVE_STATE(acpv_marksman_count, player_state_marksman);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_marksman_count, player_state_marksman)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_MARKSMAN
4 changes: 0 additions & 4 deletions src/xrGame/player_state_multichampion.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ class player_multichampion : public player_state_param
bool m_can_be_multichampion;
}; // class player_multichampion

ADD_ACCUMULATIVE_STATE(acpv_multi_champion, player_multichampion);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_multi_champion, player_multichampion)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_MULTICHAMPION_INCLUDED
4 changes: 0 additions & 4 deletions src/xrGame/player_state_opener.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ class player_state_opener : public player_state_param
bool m_opener_ready;
}; // class player_state_opener

ADD_ACCUMULATIVE_STATE(acpv_opener_ready, player_state_opener);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_opener_ready, player_state_opener)

} // namespace award_system

#endif //#ifndef PLAYER_STATE_OPENER_INCLUDED
24 changes: 0 additions & 24 deletions src/xrGame/player_state_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class player_death_counter : public player_state_param
virtual void reset_game(){};
}; // class player_death_counter

ADD_ACCUMULATIVE_STATE(acpv_death_count, player_death_counter);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_death_count, player_death_counter)

class player_artdeliver_counter : public player_state_param
{
typedef player_state_param inherited;
Expand All @@ -38,10 +34,6 @@ class player_artdeliver_counter : public player_state_param
virtual void reset_game(){};
}; // class player_artdeliver_counter

ADD_ACCUMULATIVE_STATE(acpv_artdeliver_count, player_artdeliver_counter);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_artdeliver_count, player_artdeliver_counter)

class player_rawkill_counter : public player_state_param
{
typedef player_state_param inherited;
Expand All @@ -63,10 +55,6 @@ class player_rawkill_counter : public player_state_param
u32 m_raw_kills;
}; // class player_rawkill_counter

ADD_ACCUMULATIVE_STATE(acpv_kill_in_raw, player_rawkill_counter);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_kill_in_raw, player_rawkill_counter)

class player_state_move : public player_state_param
{
typedef player_state_param inherited;
Expand All @@ -81,10 +69,6 @@ class player_state_move : public player_state_param
virtual void reset_game(){};
}; // class player_state_move

ADD_ACCUMULATIVE_STATE(acpv_move_state, player_state_move);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_move_state, player_state_move)

class player_state_velocity : public player_state_param
{
typedef player_state_param inherited;
Expand All @@ -99,10 +83,6 @@ class player_state_velocity : public player_state_param
virtual void reset_game(){};
}; // class player_state_velocity

ADD_ACCUMULATIVE_STATE(acpv_move_velocity, player_state_velocity);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_move_velocity, player_state_velocity)

class player_state_ang_velocity : public player_state_param
{
typedef player_state_param inherited;
Expand All @@ -117,10 +97,6 @@ class player_state_ang_velocity : public player_state_param
virtual void reset_game(){};
}; // class player_state_ang_velocity

ADD_ACCUMULATIVE_STATE(acpv_move_ang_velocity, player_state_ang_velocity);
#undef ACCUMULATIVE_STATE_LIST
#define ACCUMULATIVE_STATE_LIST SAVE_TYPE_LIST(acpv_move_ang_velocity, player_state_ang_velocity)

} // namespace award_system

#endif //#ifndef DEATH_COUNT_INCLUDED
Loading

0 comments on commit 02891e5

Please sign in to comment.