Skip to content

Commit 3c6b904

Browse files
committed
CRoundStatistics::CPlayerStats: Turn per-class scores into array
1 parent 3b3250f commit 3c6b904

File tree

2 files changed

+51
-138
lines changed

2 files changed

+51
-138
lines changed

src/engine/server/roundstatistics.cpp

Lines changed: 49 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -9,125 +9,59 @@ int CRoundStatistics::CPlayerStats::OnScoreEvent(int EventType, EPlayerClass Cla
99
int Points = 0;
1010
switch(EventType)
1111
{
12-
case SCOREEVENT_HUMAN_SURVIVE:
13-
Points = 50;
14-
break;
15-
case SCOREEVENT_HUMAN_SUICIDE:
16-
Points = -10;
17-
break;
18-
case SCOREEVENT_INFECTION:
19-
Points = 30;
20-
break;
21-
case SCOREEVENT_KILL_INFECTED:
22-
Points = 10;
23-
break;
24-
case SCOREEVENT_KILL_TARGET:
25-
Points = 20;
26-
break;
27-
case SCOREEVENT_KILL_WITCH:
28-
Points = 50;
29-
break;
30-
case SCOREEVENT_KILL_UNDEAD:
31-
Points = 50;
32-
break;
33-
case SCOREEVENT_DESTROY_TURRET:
34-
Points = 10;
35-
break;
36-
case SCOREEVENT_HELP_FREEZE:
37-
Points = 10;
38-
break;
39-
case SCOREEVENT_HELP_HOOK_BARRIER:
40-
Points = 10;
41-
break;
42-
case SCOREEVENT_HELP_HOOK_INFECTION:
43-
Points = 10;
44-
break;
45-
case SCOREEVENT_HUMAN_HEALING:
46-
Points = 10;
47-
break;
48-
case SCOREEVENT_HERO_FLAG:
49-
Points = 10;
50-
break;
51-
case SCOREEVENT_BONUS:
52-
Points = 50;
53-
break;
54-
case SCOREEVENT_MEDIC_REVIVE:
55-
Points = 50;
56-
break;
12+
case SCOREEVENT_HUMAN_SURVIVE:
13+
Points = 50;
14+
break;
15+
case SCOREEVENT_HUMAN_SUICIDE:
16+
Points = -10;
17+
break;
18+
case SCOREEVENT_INFECTION:
19+
Points = 30;
20+
break;
21+
case SCOREEVENT_KILL_INFECTED:
22+
Points = 10;
23+
break;
24+
case SCOREEVENT_KILL_TARGET:
25+
Points = 20;
26+
break;
27+
case SCOREEVENT_KILL_WITCH:
28+
Points = 50;
29+
break;
30+
case SCOREEVENT_KILL_UNDEAD:
31+
Points = 50;
32+
break;
33+
case SCOREEVENT_DESTROY_TURRET:
34+
Points = 10;
35+
break;
36+
case SCOREEVENT_HELP_FREEZE:
37+
Points = 10;
38+
break;
39+
case SCOREEVENT_HELP_HOOK_BARRIER:
40+
Points = 10;
41+
break;
42+
case SCOREEVENT_HELP_HOOK_INFECTION:
43+
Points = 10;
44+
break;
45+
case SCOREEVENT_HUMAN_HEALING:
46+
Points = 10;
47+
break;
48+
case SCOREEVENT_HERO_FLAG:
49+
Points = 10;
50+
break;
51+
case SCOREEVENT_BONUS:
52+
Points = 50;
53+
break;
54+
case SCOREEVENT_MEDIC_REVIVE:
55+
Points = 50;
56+
break;
5757
}
5858

5959
m_Score += Points;
60-
61-
switch(Class)
60+
61+
int ClassIndex = static_cast<int>(Class);
62+
if(ClassIndex > 0 && ClassIndex < NB_PLAYERCLASS)
6263
{
63-
case EPlayerClass::Engineer:
64-
m_EngineerScore += Points;
65-
break;
66-
case EPlayerClass::Soldier:
67-
m_SoldierScore += Points;
68-
break;
69-
case EPlayerClass::Scientist:
70-
m_ScientistScore += Points;
71-
break;
72-
case EPlayerClass::Biologist:
73-
m_BiologistScore += Points;
74-
break;
75-
case EPlayerClass::Looper:
76-
m_LooperScore += Points;
77-
break;
78-
case EPlayerClass::Medic:
79-
m_MedicScore += Points;
80-
break;
81-
case EPlayerClass::Hero:
82-
m_HeroScore += Points;
83-
break;
84-
case EPlayerClass::Ninja:
85-
m_NinjaScore += Points;
86-
break;
87-
case EPlayerClass::Mercenary:
88-
m_MercenaryScore += Points;
89-
break;
90-
case EPlayerClass::Sniper:
91-
m_SniperScore += Points;
92-
break;
93-
case EPlayerClass::Smoker:
94-
m_SmokerScore += Points;
95-
break;
96-
case EPlayerClass::Hunter:
97-
m_HunterScore += Points;
98-
break;
99-
case EPlayerClass::Bat:
100-
m_BatScore += Points;
101-
break;
102-
case EPlayerClass::Boomer:
103-
m_BoomerScore += Points;
104-
break;
105-
case EPlayerClass::Ghost:
106-
m_GhostScore += Points;
107-
break;
108-
case EPlayerClass::Spider:
109-
m_SpiderScore += Points;
110-
break;
111-
case EPlayerClass::Ghoul:
112-
m_GhoulScore += Points;
113-
break;
114-
case EPlayerClass::Slug:
115-
m_SlugScore += Points;
116-
break;
117-
case EPlayerClass::Voodoo:
118-
m_VoodooScore += Points;
119-
break;
120-
case EPlayerClass::Undead:
121-
m_UndeadScore += Points;
122-
break;
123-
case EPlayerClass::Witch:
124-
m_WitchScore += Points;
125-
break;
126-
127-
case EPlayerClass::Invalid:
128-
case EPlayerClass::None:
129-
case EPlayerClass::Count:
130-
break;
64+
m_ClassScore[ClassIndex] += Points;
13165
}
13266

13367
return Points;

src/engine/server/roundstatistics.h

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <engine/console.h>
55
#include <engine/shared/protocol.h>
66

7-
enum class EPlayerClass;
7+
#include <game/infclass/classes.h>
88

99
enum
1010
{
@@ -32,28 +32,7 @@ class CRoundStatistics
3232
{
3333
public:
3434
int m_Score{};
35-
int m_EngineerScore{};
36-
int m_SoldierScore{};
37-
int m_ScientistScore{};
38-
int m_BiologistScore{};
39-
int m_LooperScore{};
40-
int m_MedicScore{};
41-
int m_HeroScore{};
42-
int m_NinjaScore{};
43-
int m_MercenaryScore{};
44-
int m_SniperScore{};
45-
46-
int m_SmokerScore{};
47-
int m_HunterScore{};
48-
int m_BatScore{};
49-
int m_BoomerScore{};
50-
int m_GhostScore{};
51-
int m_SpiderScore{};
52-
int m_GhoulScore{};
53-
int m_SlugScore{};
54-
int m_VoodooScore{};
55-
int m_UndeadScore{};
56-
int m_WitchScore{};
35+
int m_ClassScore[NB_PLAYERCLASS]{};
5736

5837
bool m_WasSpectator{};
5938
bool m_Won{};

0 commit comments

Comments
 (0)