-
Notifications
You must be signed in to change notification settings - Fork 2
/
COD5LogFileReader.cpp
153 lines (125 loc) · 3.53 KB
/
COD5LogFileReader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// wxWindows includes
#include <wx/wx.h>
#include <wx/string.h>
#include <wx/file.h>
#include <wx/wfstream.h>
#include <wx/datetime.h>
#include <wx/tokenzr.h>
// statsgen includes
#include "COD5LogFileReader.h"
#include "GlobalStatistics.h"
#include "ErrorData.h"
void COD5LogFileReader::AddDefaultNonAction(const char *action)
{
wxString key;
key=action;
if (nonActions.Index(key)==wxNOT_FOUND)
{
nonActions.Add(key);
}
}
COD5LogFileReader::COD5LogFileReader(wxArrayString &filenameIn,wxString &serverTypeIn) : LogFileReader(filenameIn,serverTypeIn)
{
STATSGEN_DEBUG_FUNCTION_START("COD5LogFileReader","Constructor");
wxString configGroup;
configGroup="COD5NonActions";
globalStatistics.configData.ReadList(configGroup,nonActions);
AddDefaultNonAction("J"); // Join
AddDefaultNonAction("Q"); // Quit
AddDefaultNonAction("W"); // Team Win
AddDefaultNonAction("L"); // Team Loss
AddDefaultNonAction("T"); // Team Tie
globalStatistics.configData.WriteList(configGroup,nonActions);
STATSGEN_DEBUG_FUNCTION_END
}
bool COD5LogFileReader::DecodeAction(wxString &line,DecodedAction &decode)
{
bool retVal=false;
int tokenCount;
wxString msg;
STATSGEN_DEBUG_FUNCTION_START("COD5LogFileReader","DecodeAction")
decode.action=GetLineToken(line,";",1,&tokenCount).Upper();
if (tokenCount == 4)
{
decode.playerID=GetLineToken(line,";",2,&tokenCount);
decode.playerRoundID=GetLineToken(line,";",3,&tokenCount);
decode.playerName=GetLineToken(line,";",4,&tokenCount);
decode.playerTeam="";
UpdatePlayerRoundInfo2(decode.playerID,
playerIDs,
playerTeamList,
decode.playerTeam);
retVal=(nonActions.Index(decode.action)==wxNOT_FOUND);
}
STATSGEN_DEBUG_FUNCTION_END
return(retVal);
}
bool COD5LogFileReader::DecodeTeamWin(wxString &line,DecodedTeamWin &decode)
{
bool retVal=false;
int tokenCount;
int tokenIndex=0;
wxString name;
wxString id;
wxString roundID;
wxString msg;
STATSGEN_DEBUG_FUNCTION_START("LogFileReader","DecodeTeamWin");
roundID="";
retVal=DecodeTeamWinLoss("W;",line,id,roundID,name,decode.teamName);
if (retVal)
{
STATSGEN_DEBUG(DEBUG_RARELY,"Normal Team Win Found")
decode.Clear();
decode.playerIDs.Add(id);
decode.playerRoundIDs.Add(roundID);
decode.playerNames.Add(name);
}
STATSGEN_DEBUG_FUNCTION_END
return(retVal);
}
bool COD5LogFileReader::DecodeTeamWinLoss(const char *key,wxString &line,wxString &id, wxString &roundID,wxString &name, wxString &team)
{
bool retVal=false;
int tokenCount;
STATSGEN_DEBUG_FUNCTION_START("COD5LogFileReader","DecodeTeamWinLoss");
if (line.StartsWith(key))
{
STATSGEN_DEBUG(DEBUG_RARELY,"Team Win or Loss Found")
id=GetLineToken(line,";",2,&tokenCount);
if (tokenCount == 4)
{
roundID=GetLineToken(line,";",3,&tokenCount);
name=GetLineToken(line,";",4,&tokenCount);
UpdatePlayerRoundInfo2(id,
playerIDs,
playerTeamList,
team);
retVal=true;
}
}
STATSGEN_DEBUG_FUNCTION_END
return(retVal);
}
bool COD5LogFileReader::DecodeTeamLoss(wxString &line,DecodedTeamLoss &decode)
{
bool retVal=false;
int tokenCount;
int tokenIndex=0;
wxString name;
wxString id;
wxString roundID;
wxString msg;
STATSGEN_DEBUG_FUNCTION_START("LogFileReader","DecodeTeamLoss");
roundID="";
retVal=DecodeTeamWinLoss("L;",line,id,roundID,name,decode.teamName);
if (retVal)
{
STATSGEN_DEBUG(DEBUG_RARELY,"Normal Team Loss Found")
decode.Clear();
decode.playerIDs.Add(id);
decode.playerRoundIDs.Add(roundID);
decode.playerNames.Add(name);
}
STATSGEN_DEBUG_FUNCTION_END
return(retVal);
}