Skip to content

Commit

Permalink
CRoundStatistics::CPlayerStats: Turn per-class scores into array
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Dec 16, 2024
1 parent 3b3250f commit 3c6b904
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 138 deletions.
164 changes: 49 additions & 115 deletions src/engine/server/roundstatistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,125 +9,59 @@ int CRoundStatistics::CPlayerStats::OnScoreEvent(int EventType, EPlayerClass Cla
int Points = 0;
switch(EventType)
{
case SCOREEVENT_HUMAN_SURVIVE:
Points = 50;
break;
case SCOREEVENT_HUMAN_SUICIDE:
Points = -10;
break;
case SCOREEVENT_INFECTION:
Points = 30;
break;
case SCOREEVENT_KILL_INFECTED:
Points = 10;
break;
case SCOREEVENT_KILL_TARGET:
Points = 20;
break;
case SCOREEVENT_KILL_WITCH:
Points = 50;
break;
case SCOREEVENT_KILL_UNDEAD:
Points = 50;
break;
case SCOREEVENT_DESTROY_TURRET:
Points = 10;
break;
case SCOREEVENT_HELP_FREEZE:
Points = 10;
break;
case SCOREEVENT_HELP_HOOK_BARRIER:
Points = 10;
break;
case SCOREEVENT_HELP_HOOK_INFECTION:
Points = 10;
break;
case SCOREEVENT_HUMAN_HEALING:
Points = 10;
break;
case SCOREEVENT_HERO_FLAG:
Points = 10;
break;
case SCOREEVENT_BONUS:
Points = 50;
break;
case SCOREEVENT_MEDIC_REVIVE:
Points = 50;
break;
case SCOREEVENT_HUMAN_SURVIVE:
Points = 50;
break;
case SCOREEVENT_HUMAN_SUICIDE:
Points = -10;
break;
case SCOREEVENT_INFECTION:
Points = 30;
break;
case SCOREEVENT_KILL_INFECTED:
Points = 10;
break;
case SCOREEVENT_KILL_TARGET:
Points = 20;
break;
case SCOREEVENT_KILL_WITCH:
Points = 50;
break;
case SCOREEVENT_KILL_UNDEAD:
Points = 50;
break;
case SCOREEVENT_DESTROY_TURRET:
Points = 10;
break;
case SCOREEVENT_HELP_FREEZE:
Points = 10;
break;
case SCOREEVENT_HELP_HOOK_BARRIER:
Points = 10;
break;
case SCOREEVENT_HELP_HOOK_INFECTION:
Points = 10;
break;
case SCOREEVENT_HUMAN_HEALING:
Points = 10;
break;
case SCOREEVENT_HERO_FLAG:
Points = 10;
break;
case SCOREEVENT_BONUS:
Points = 50;
break;
case SCOREEVENT_MEDIC_REVIVE:
Points = 50;
break;
}

m_Score += Points;

switch(Class)

int ClassIndex = static_cast<int>(Class);
if(ClassIndex > 0 && ClassIndex < NB_PLAYERCLASS)
{
case EPlayerClass::Engineer:
m_EngineerScore += Points;
break;
case EPlayerClass::Soldier:
m_SoldierScore += Points;
break;
case EPlayerClass::Scientist:
m_ScientistScore += Points;
break;
case EPlayerClass::Biologist:
m_BiologistScore += Points;
break;
case EPlayerClass::Looper:
m_LooperScore += Points;
break;
case EPlayerClass::Medic:
m_MedicScore += Points;
break;
case EPlayerClass::Hero:
m_HeroScore += Points;
break;
case EPlayerClass::Ninja:
m_NinjaScore += Points;
break;
case EPlayerClass::Mercenary:
m_MercenaryScore += Points;
break;
case EPlayerClass::Sniper:
m_SniperScore += Points;
break;
case EPlayerClass::Smoker:
m_SmokerScore += Points;
break;
case EPlayerClass::Hunter:
m_HunterScore += Points;
break;
case EPlayerClass::Bat:
m_BatScore += Points;
break;
case EPlayerClass::Boomer:
m_BoomerScore += Points;
break;
case EPlayerClass::Ghost:
m_GhostScore += Points;
break;
case EPlayerClass::Spider:
m_SpiderScore += Points;
break;
case EPlayerClass::Ghoul:
m_GhoulScore += Points;
break;
case EPlayerClass::Slug:
m_SlugScore += Points;
break;
case EPlayerClass::Voodoo:
m_VoodooScore += Points;
break;
case EPlayerClass::Undead:
m_UndeadScore += Points;
break;
case EPlayerClass::Witch:
m_WitchScore += Points;
break;

case EPlayerClass::Invalid:
case EPlayerClass::None:
case EPlayerClass::Count:
break;
m_ClassScore[ClassIndex] += Points;
}

return Points;
Expand Down
25 changes: 2 additions & 23 deletions src/engine/server/roundstatistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <engine/console.h>
#include <engine/shared/protocol.h>

enum class EPlayerClass;
#include <game/infclass/classes.h>

enum
{
Expand Down Expand Up @@ -32,28 +32,7 @@ class CRoundStatistics
{
public:
int m_Score{};
int m_EngineerScore{};
int m_SoldierScore{};
int m_ScientistScore{};
int m_BiologistScore{};
int m_LooperScore{};
int m_MedicScore{};
int m_HeroScore{};
int m_NinjaScore{};
int m_MercenaryScore{};
int m_SniperScore{};

int m_SmokerScore{};
int m_HunterScore{};
int m_BatScore{};
int m_BoomerScore{};
int m_GhostScore{};
int m_SpiderScore{};
int m_GhoulScore{};
int m_SlugScore{};
int m_VoodooScore{};
int m_UndeadScore{};
int m_WitchScore{};
int m_ClassScore[NB_PLAYERCLASS]{};

bool m_WasSpectator{};
bool m_Won{};
Expand Down

0 comments on commit 3c6b904

Please sign in to comment.