-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMPXmlTeams.hpp
81 lines (61 loc) · 1.56 KB
/
MPXmlTeams.hpp
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
#ifndef MPXMLTEAMS_HPP
#define MPXMLTEAMS_HPP
#include "types.h"
#include "XML.h"
#include "expat.h"
#include <vector>
#define NUM_RANDOM_MERC_TEAMS 4
#define RANDOM_MERC_TEAM_SIZE 7
/* MPTeams.xml structure:
- name attribute is optional and not used anywhere yet
<mp_teams>
<team name="team1">
<id>42</id>
<id>23</id>
...
</team>
<team>
<id>97</id>
...
</team>
...
</mp_teams>
*/
class MultiplayerTeams
{
private:
struct MPTeam
{
std::string name;
std::vector<int> members;
};
public:
BOOLEAN ReadInMPTeams(STR fileName);
void HandleServerStarted();
MultiplayerTeams();
~MultiplayerTeams();
void SerializeProfiles(int* dest);
void SerializeProfiles(int* dest, int teamID);
private:
std::vector< MPTeam > teams;
std::vector<bool> teamsTaken;
bool initialized;
BOOLEAN ReadXMLFile(STR fileName);
void UseFallbackDataIfNecessary();
void TrashTeams();
static void XMLCALL teamsStartElementHandler(void *userData, const XML_Char *name, const XML_Char **atts);
static void XMLCALL teamsEndElementHandler(void *userData, const XML_Char *name);
static void XMLCALL teamsCharacterDataHandler(void *userData, const XML_Char *s, int len);
struct teamsParseData
{
PARSE_STAGE curElement;
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1];
UINT32 currentDepth;
UINT32 maxReadDepth;
MultiplayerTeams *mpTeams;
};
static const int random_merc_teams[NUM_RANDOM_MERC_TEAMS][RANDOM_MERC_TEAM_SIZE];
};
// make global
extern MultiplayerTeams mpTeams;
#endif