134 void HWGame::SendTrainingConfig() |
134 void HWGame::SendTrainingConfig() |
135 { |
135 { |
136 QByteArray traincfg; |
136 QByteArray traincfg; |
137 HWProto::addStringToBuffer(traincfg, "TL"); |
137 HWProto::addStringToBuffer(traincfg, "TL"); |
138 |
138 |
139 HWTeam team1; |
|
140 team1.difficulty = 0; |
|
141 team1.teamColor = *color1; |
|
142 team1.numHedgehogs = 1; |
|
143 HWProto::addStringListToBuffer(traincfg, |
|
144 team1.TeamGameConfig(100)); |
|
145 |
|
146 QFile file(datadir->absolutePath() + "/Trainings/" + training + ".txt"); |
139 QFile file(datadir->absolutePath() + "/Trainings/" + training + ".txt"); |
147 if(!file.open(QFile::ReadOnly)) |
140 if(!file.open(QFile::ReadOnly)) |
148 { |
141 { |
149 emit ErrorMessage(tr("Error reading training config file")); |
142 emit ErrorMessage(tr("Error reading training config file")); |
150 return; |
143 return; |
151 } |
144 } |
152 |
145 |
153 QTextStream stream(&file); |
146 QTextStream stream(&file); |
154 while(!stream.atEnd()) |
147 while(!stream.atEnd()) |
155 { |
148 { |
156 HWProto::addStringToBuffer(traincfg, "e" + stream.readLine()); |
149 QString line = stream.readLine(); |
|
150 if(!line.isEmpty() && !line.startsWith("#")) |
|
151 if(line != "<binds>") |
|
152 HWProto::addStringToBuffer(traincfg, "e" + line); |
|
153 else |
|
154 for(int i = 0; i < BINDS_NUMBER; i++) |
|
155 if(!cbinds[i].strbind.isEmpty()) |
|
156 HWProto::addStringToBuffer(traincfg, "ebind " + cbinds[i].strbind + " " + cbinds[i].action); |
157 } |
157 } |
158 |
158 |
159 RawSendIPC(traincfg); |
159 RawSendIPC(traincfg); |
160 } |
160 } |
161 |
161 |