30 #include "DataManager.h" |
30 #include "DataManager.h" |
31 |
31 |
32 HWTeam::HWTeam(const QString & teamname, QObject *parent) : |
32 HWTeam::HWTeam(const QString & teamname, QObject *parent) : |
33 QObject(parent) |
33 QObject(parent) |
34 { |
34 { |
|
35 QList<QByteArray> baList; |
|
36 |
35 flib_team team; |
37 flib_team team; |
36 bzero(&team, sizeof(team)); |
38 bzero(&team, sizeof(team)); |
37 team.name = teamname.toUtf8().data(); |
39 baList << teamname.toUtf8(); |
|
40 team.name = baList.last().data(); |
38 team.grave = "Statue"; |
41 team.grave = "Statue"; |
39 team.fort = "Plane"; |
42 team.fort = "Plane"; |
40 team.voicepack = "Default"; |
43 team.voicepack = "Default"; |
41 team.flag = "hedgewars"; |
44 team.flag = "hedgewars"; |
42 |
45 |
43 for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
46 for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
44 { |
47 { |
45 team.hogs[i].name = QLineEdit::tr("hedgehog %1").arg(i+1).toUtf8().data(); |
48 baList << QLineEdit::tr("hedgehog %1").arg(i+1).toUtf8(); |
|
49 team.hogs[i].name = baList.last().data(); |
46 team.hogs[i].hat = "NoHat"; |
50 team.hogs[i].hat = "NoHat"; |
47 } |
51 } |
48 |
52 |
49 m_oldTeamName = teamname; |
53 m_oldTeamName = teamname; |
50 |
54 |
51 QVector<flib_binding> binds(BINDS_NUMBER); |
55 QVector<flib_binding> binds(BINDS_NUMBER); |
52 for(int i = 0; i < BINDS_NUMBER; i++) |
56 for(int i = 0; i < BINDS_NUMBER; i++) |
53 { |
57 { |
54 binds[i].action = cbinds[i].action.toUtf8().data(); |
58 baList << cbinds[i].action.toUtf8(); |
55 binds[i].binding = cbinds[i].strbind.toUtf8().data(); |
59 binds[i].action = baList.last().data(); |
|
60 baList << cbinds[i].strbind.toUtf8(); |
|
61 binds[i].binding = baList.last().data(); |
56 } |
62 } |
57 team.bindings = binds.data(); |
63 team.bindings = binds.data(); |
58 team.bindingCount = binds.size(); |
64 team.bindingCount = binds.size(); |
59 |
65 |
60 team.remoteDriven = false; |
|
61 team.hogsInGame = 4; |
|
62 |
|
63 m_team = flib_team_copy(&team); |
66 m_team = flib_team_copy(&team); |
|
67 |
|
68 m_team->remoteDriven = false; |
|
69 m_team->hogsInGame = 4; |
64 } |
70 } |
65 |
71 |
66 HWTeam::HWTeam(const QStringList& strLst, QObject *parent) : |
72 HWTeam::HWTeam(const QStringList& strLst, QObject *parent) : |
67 QObject(parent) |
73 QObject(parent) |
68 { |
74 { |
|
75 QList<QByteArray> baList; |
|
76 |
69 // net teams are configured from QStringList |
77 // net teams are configured from QStringList |
70 if(strLst.size() != 23) throw HWTeamConstructException(); |
78 if(strLst.size() != 23) throw HWTeamConstructException(); |
71 flib_team team; |
79 flib_team team; |
72 bzero(&team, sizeof(team)); |
80 bzero(&team, sizeof(team)); |
73 team.name = strLst[0].toUtf8().data(); |
81 |
|
82 for(int i = 0; i < 6; ++i) |
|
83 baList << strLst[i].toUtf8(); |
|
84 team.name = baList[0].data(); |
74 m_oldTeamName = strLst[0]; |
85 m_oldTeamName = strLst[0]; |
75 team.grave = strLst[1].toUtf8().data(); |
86 team.grave = baList[1].data(); |
76 team.fort = strLst[2].toUtf8().data(); |
87 team.fort = baList[2].data(); |
77 team.voicepack = strLst[3].toUtf8().data(); |
88 team.voicepack = baList[3].data(); |
78 team.flag = strLst[4].toUtf8().data(); |
89 team.flag = baList[4].data(); |
79 team.ownerName = strLst[5].toUtf8().data(); |
90 team.ownerName = baList[5].data(); |
80 int difficulty = strLst[6].toUInt(); |
91 int difficulty = strLst[6].toUInt(); |
81 |
92 |
82 for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
93 for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
83 { |
94 { |
84 team.hogs[i].name = strLst[i * 2 + 7].toUtf8().data(); |
95 baList << strLst[i * 2 + 7].toUtf8(); |
|
96 team.hogs[i].name = baList.last().data(); |
85 |
97 |
86 QString hat = strLst[i * 2 + 8]; |
98 QString hat = strLst[i * 2 + 8]; |
87 if (hat.isEmpty()) |
99 if (hat.isEmpty()) |
88 team.hogs[i].hat = "NoHat"; |
100 team.hogs[i].hat = "NoHat"; |
89 else |
101 else |
90 team.hogs[i].hat = hat.toUtf8().data(); |
102 { |
|
103 baList << hat.toUtf8(); |
|
104 team.hogs[i].hat = baList.last().data(); |
|
105 } |
91 |
106 |
92 team.hogs[i].difficulty = difficulty; |
107 team.hogs[i].difficulty = difficulty; |
93 } |
108 } |
94 |
109 |
95 m_oldTeamName = strLst[0]; |
110 m_oldTeamName = strLst[0]; |
96 |
111 |
97 QVector<flib_binding> binds(BINDS_NUMBER); |
112 QVector<flib_binding> binds(BINDS_NUMBER); |
98 for(int i = 0; i < BINDS_NUMBER; i++) |
113 for(int i = 0; i < BINDS_NUMBER; i++) |
99 { |
114 { |
100 binds[i].action = cbinds[i].action.toUtf8().data(); |
115 baList << cbinds[i].action.toUtf8(); |
101 binds[i].binding = cbinds[i].strbind.toUtf8().data(); |
116 binds[i].action = baList.last().data(); |
|
117 baList << cbinds[i].strbind.toUtf8(); |
|
118 binds[i].binding = baList.last().data(); |
102 } |
119 } |
103 team.bindings = binds.data(); |
120 team.bindings = binds.data(); |
104 team.bindingCount = binds.size(); |
121 team.bindingCount = binds.size(); |
105 |
122 |
106 team.remoteDriven = true; |
|
107 team.hogsInGame = 4; |
|
108 |
|
109 m_team = flib_team_copy(&team); |
123 m_team = flib_team_copy(&team); |
|
124 m_team->remoteDriven = true; |
|
125 m_team->hogsInGame = 4; |
110 } |
126 } |
111 |
127 |
112 |
128 |
113 HWTeam::HWTeam(const HWTeam & other) : |
129 HWTeam::HWTeam(const HWTeam & other) : |
114 QObject(other.parent()) |
130 QObject(other.parent()) |
115 , m_oldTeamName(other.m_oldTeamName) |
131 , m_oldTeamName(other.m_oldTeamName) |
116 , m_team(flib_team_copy(other.m_team)) |
132 , m_team(flib_team_copy(other.m_team)) |
117 { |
133 { |
118 |
134 m_team->hogsInGame = other.m_team->hogsInGame; |
|
135 m_team->remoteDriven = other.m_team->remoteDriven; |
119 } |
136 } |
120 |
137 |
121 HWTeam & HWTeam::operator = (const HWTeam & other) |
138 HWTeam & HWTeam::operator = (const HWTeam & other) |
122 { |
139 { |
123 if(this != &other) |
140 if(this != &other) |
124 { |
141 { |
125 m_oldTeamName = other.m_oldTeamName; |
142 m_oldTeamName = other.m_oldTeamName; |
126 m_team = flib_team_copy(other.m_team); |
143 m_team = flib_team_copy(other.m_team); |
|
144 |
|
145 m_team->hogsInGame = other.m_team->hogsInGame; |
|
146 m_team->remoteDriven = other.m_team->remoteDriven; |
127 } |
147 } |
128 |
148 |
129 return *this; |
149 return *this; |
130 } |
150 } |
131 |
151 |