diff options
| author | manuel <manuel@mausz.at> | 2013-03-05 17:39:48 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-03-05 17:39:48 +0100 |
| commit | 310a2c101b32a5e71a616027b6a1b788a341bc02 (patch) | |
| tree | a871e1dda8b1de141ae1400ba666fe3b1de96361 /tscommand.cpp | |
| download | tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.tar.gz tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.tar.bz2 tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.zip | |
Diffstat (limited to 'tscommand.cpp')
| -rw-r--r-- | tscommand.cpp | 1519 |
1 files changed, 1519 insertions, 0 deletions
diff --git a/tscommand.cpp b/tscommand.cpp new file mode 100644 index 0000000..881ce70 --- /dev/null +++ b/tscommand.cpp | |||
| @@ -0,0 +1,1519 @@ | |||
| 1 | /* | ||
| 2 | * This program is free software; you can redistribute it and/or modify | ||
| 3 | * it under the terms of the GNU General Public License as published by | ||
| 4 | * the Free Software Foundation; version 2 of the License. | ||
| 5 | * | ||
| 6 | * This program is distributed in the hope that it will be useful, | ||
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 9 | * GNU General Public License for more details. | ||
| 10 | * | ||
| 11 | * You should have received a copy of the GNU General Public License | ||
| 12 | * along with this program; if not, write to the Free Software | ||
| 13 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 14 | * | ||
| 15 | * Authors: Manuel Mausz (manuel@mausz.at) | ||
| 16 | * Christian Raschko (c.raschko@netcore.at) | ||
| 17 | */ | ||
| 18 | |||
| 19 | // Header | ||
| 20 | #include "tscommand.h" | ||
| 21 | #include "wxstreamex.h" | ||
| 22 | #include "wxbufferex.h" | ||
| 23 | #include "crc32.h" | ||
| 24 | |||
| 25 | //Libraries | ||
| 26 | #include <wx/tokenzr.h> | ||
| 27 | #include <wx/memory.h> | ||
| 28 | #include <wx/wfstream.h> | ||
| 29 | #include <wx/sstream.h> | ||
| 30 | |||
| 31 | IMPLEMENT_CLASS(TSCommand, wxObject) | ||
| 32 | |||
| 33 | //class variable | ||
| 34 | wxUint32 TSCommand::m_Cnt = 0; | ||
| 35 | |||
| 36 | //------------------------------------------------------------------------------ | ||
| 37 | // Send User | ||
| 38 | bool TSCmdSendLogin::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 39 | { | ||
| 40 | TSClient *client = cmd->client; | ||
| 41 | wxByte buf[1024]; | ||
| 42 | wxUint32 len = 0; | ||
| 43 | wxMemoryOutputStream tmpstrm; | ||
| 44 | wxDataOutputStreamEx out(tmpstrm); | ||
| 45 | |||
| 46 | TSCommand::m_Cnt = 0; | ||
| 47 | |||
| 48 | out.Write32(m_Id); | ||
| 49 | out.Write32(0); //SessionId | ||
| 50 | out.Write32(0); //PlayerId | ||
| 51 | out.Write32(m_Cnt++); //Counter | ||
| 52 | out.Write32(0); //CRC | ||
| 53 | out.WriteFixedString(_T("TeamSpeak")); //TeamSpeak | ||
| 54 | out.WriteFixedString(client->GetPlatform()); //Platform | ||
| 55 | |||
| 56 | //Write version number | ||
| 57 | wxStringTokenizer tkz(client->GetVersionNumber(), _T(".")); | ||
| 58 | if(tkz.CountTokens() != 4) | ||
| 59 | { | ||
| 60 | SetLastError(_T("invalid version number, check format")); | ||
| 61 | return false; | ||
| 62 | } | ||
| 63 | |||
| 64 | //some conversions | ||
| 65 | long i; | ||
| 66 | tkz.GetNextToken().ToLong(&i); | ||
| 67 | out.Write16(wxUint16(i)); | ||
| 68 | tkz.GetNextToken().ToLong(&i); | ||
| 69 | out.Write16(wxUint16(i)); | ||
| 70 | tkz.GetNextToken().ToLong(&i); | ||
| 71 | out.Write16(wxUint16(i)); | ||
| 72 | tkz.GetNextToken().ToLong(&i); | ||
| 73 | out.Write16(wxUint16(i)); | ||
| 74 | |||
| 75 | out.Write8(client->GetPlayer()->GetServerAssingnsNickname()); //Allow server assing nick | ||
| 76 | |||
| 77 | out.Write8(client->GetPlayer()->GetAnonymous()); //Anonymous login | ||
| 78 | out.WriteFixedString(client->GetPlayer()->GetLoginName()); //Login name | ||
| 79 | out.WriteFixedString(client->GetPlayer()->GetLoginPassword()); //Login password | ||
| 80 | out.WriteFixedString(client->GetPlayer()->GetNickname()); //Nickname | ||
| 81 | |||
| 82 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 83 | CRC32 myCRC32; | ||
| 84 | myCRC32.update(buf, len); | ||
| 85 | |||
| 86 | tmpstrm.SeekO(16); | ||
| 87 | out.Write32(myCRC32.getUint32Value()); | ||
| 88 | len = tmpstrm.CopyTo(buf, len); | ||
| 89 | |||
| 90 | ostrm.Write(buf, len); | ||
| 91 | |||
| 92 | //only for reducing warnings | ||
| 93 | wxUnusedVar(istrm); | ||
| 94 | return true; | ||
| 95 | } | ||
| 96 | |||
| 97 | //------------------------------------------------------------------------------ | ||
| 98 | // Recv Server | ||
| 99 | bool TSCmdRecvServer::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 100 | { | ||
| 101 | TSClient *client = cmd->client; | ||
| 102 | wxString str; | ||
| 103 | wxUint32 crc = 0; | ||
| 104 | wxUint32 id; | ||
| 105 | wxDataInputStreamEx in(istrm); | ||
| 106 | |||
| 107 | //read id | ||
| 108 | if(in.Read32() != m_Id) | ||
| 109 | { | ||
| 110 | SetLastError(_T("invalid command")); | ||
| 111 | return false; | ||
| 112 | } | ||
| 113 | |||
| 114 | in.Read32(); //Session id | ||
| 115 | client->GetPlayer()->SetId(in.Read32()); //Player id | ||
| 116 | in.Read32(); //Packet count | ||
| 117 | crc = in.Read32(); //CRC | ||
| 118 | in.ReadFixedString(str); | ||
| 119 | client->GetServer()->SetServerMessage(str); //Server message | ||
| 120 | str.Clear(); | ||
| 121 | in.ReadFixedString(str); | ||
| 122 | client->GetServer()->SetPlatform(str); //Platform string | ||
| 123 | str.Clear(); | ||
| 124 | str.Append(wxString::Format(_T("%d."), in.Read16())); | ||
| 125 | str.Append(wxString::Format(_T("%d."), in.Read16())); | ||
| 126 | str.Append(wxString::Format(_T("%d."), in.Read16())); | ||
| 127 | str.Append(wxString::Format(_T("%d"), in.Read16())); | ||
| 128 | client->GetServer()->SetVersionNumber(str); | ||
| 129 | id = in.Read32(); | ||
| 130 | if(id == 0xffffffff) | ||
| 131 | { | ||
| 132 | SetLastError(_T("Bad Login (name and/or password wrong)")); | ||
| 133 | return false; | ||
| 134 | } | ||
| 135 | if(id == 0xfffffff9) | ||
| 136 | { | ||
| 137 | SetLastError(_T("This user is already logged in on the server")); | ||
| 138 | return false; | ||
| 139 | } | ||
| 140 | if(id > 100) | ||
| 141 | { | ||
| 142 | SetLastError(_T("Undefined user login error, check user data/permission")); | ||
| 143 | return false; | ||
| 144 | } | ||
| 145 | client->GetServer()->SetId(id); | ||
| 146 | |||
| 147 | in.Read32(); //unknown | ||
| 148 | in.Read32(); //unknown | ||
| 149 | client->GetServer()->SetServerType(in.Read16()); // servertype | ||
| 150 | |||
| 151 | //more unknown data | ||
| 152 | for(int i = 0; i < 70; i++) | ||
| 153 | in.Read8(); | ||
| 154 | |||
| 155 | client->SetSessionId(in.Read32()); //Session id | ||
| 156 | client->GetPlayer()->SetId(in.Read32()); //Player id | ||
| 157 | str.Clear(); | ||
| 158 | in.ReadFixedString(str, 255); | ||
| 159 | client->GetServer()->SetWelcomeMessage(str); //Welcome message | ||
| 160 | |||
| 161 | //only for reducing warnings | ||
| 162 | wxUnusedVar(ostrm); | ||
| 163 | wxUnusedVar(crc); | ||
| 164 | return true; | ||
| 165 | } | ||
| 166 | |||
| 167 | //------------------------------------------------------------------------------ | ||
| 168 | // Send default channel | ||
| 169 | bool TSCmdSendDefault::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 170 | { | ||
| 171 | TSClient *client = cmd->client; | ||
| 172 | wxByte buf[1024]; | ||
| 173 | wxUint32 len = 0; | ||
| 174 | wxMemoryOutputStream tmpstrm; | ||
| 175 | wxDataOutputStreamEx out(tmpstrm); | ||
| 176 | |||
| 177 | out.Write32(m_Id); | ||
| 178 | out.Write32(client->GetSessionId()); //SessionId | ||
| 179 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 180 | out.Write32(m_Cnt++); //Counter | ||
| 181 | out.Write32(0); //unknown | ||
| 182 | out.Write32(0); //CRC | ||
| 183 | out.Write16(1); | ||
| 184 | out.WriteFixedString(client->GetPlayer()->GetDefaultChannel()); | ||
| 185 | out.WriteFixedString(client->GetPlayer()->GetDefaultSubchannel()); | ||
| 186 | out.WriteFixedString(client->GetPlayer()->GetDefaultChannelPassword()); | ||
| 187 | out.Write32(0); //unknown | ||
| 188 | |||
| 189 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 190 | CRC32 myCRC32; | ||
| 191 | myCRC32.update(buf, len); | ||
| 192 | |||
| 193 | tmpstrm.SeekO(20); | ||
| 194 | out.Write32(myCRC32.getUint32Value()); | ||
| 195 | len = tmpstrm.CopyTo(buf, len); | ||
| 196 | |||
| 197 | ostrm.Write(buf, len); | ||
| 198 | |||
| 199 | //only for reducing warnings | ||
| 200 | wxUnusedVar(istrm); | ||
| 201 | return true; | ||
| 202 | } | ||
| 203 | |||
| 204 | //------------------------------------------------------------------------------ | ||
| 205 | // TSRecvChannel | ||
| 206 | bool TSCmdRecvChannel::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 207 | { | ||
| 208 | TSClient *client = cmd->client; | ||
| 209 | wxString str; | ||
| 210 | wxUint32 crc = 0; | ||
| 211 | wxUint32 channels = 0; | ||
| 212 | TSChannel *chl = NULL; | ||
| 213 | wxDataInputStreamEx in(istrm); | ||
| 214 | |||
| 215 | //read id | ||
| 216 | if(in.Read32() != m_Id) | ||
| 217 | { | ||
| 218 | SetLastError(_T("invalid command")); | ||
| 219 | return false; | ||
| 220 | } | ||
| 221 | |||
| 222 | in.Read32(); //Session id | ||
| 223 | in.Read32(); //Player id | ||
| 224 | cmd->pktid = in.Read32(); //Packet count | ||
| 225 | in.Read32(); //read unknown | ||
| 226 | crc = in.Read32(); //CRC | ||
| 227 | channels = in.Read32(); //read channel count | ||
| 228 | |||
| 229 | for(size_t i = 0; i < channels; i++) | ||
| 230 | { | ||
| 231 | wxUint32 chlid = in.Read32(); | ||
| 232 | chl = client->FindChannel(chlid); | ||
| 233 | if(chl == NULL) | ||
| 234 | { | ||
| 235 | chl = new TSChannel; | ||
| 236 | client->GetChannels()->Add(chl); | ||
| 237 | } | ||
| 238 | |||
| 239 | chl->SetId(chlid); | ||
| 240 | chl->SetFlags(in.Read16()); | ||
| 241 | chl->SetCodec(in.Read16()); | ||
| 242 | chl->SetParent(in.Read32()); | ||
| 243 | chl->SetOrder(in.Read16()); | ||
| 244 | chl->SetMaxUsers(in.Read16()); | ||
| 245 | str.Clear(); | ||
| 246 | in.ReadZeroString(str); | ||
| 247 | chl->SetName(str); | ||
| 248 | str.Clear(); | ||
| 249 | in.ReadZeroString(str); | ||
| 250 | chl->SetTopic(str); | ||
| 251 | str.Clear(); | ||
| 252 | in.ReadZeroString(str); | ||
| 253 | chl->SetDescription(str); | ||
| 254 | } | ||
| 255 | |||
| 256 | //only for reducing warnings | ||
| 257 | wxUnusedVar(ostrm); | ||
| 258 | wxUnusedVar(crc); | ||
| 259 | return true; | ||
| 260 | } | ||
| 261 | |||
| 262 | //------------------------------------------------------------------------------ | ||
| 263 | // TSRecvUser | ||
| 264 | bool TSCmdRecvUser::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 265 | { | ||
| 266 | TSClient *client = cmd->client; | ||
| 267 | wxString str; | ||
| 268 | wxUint32 crc = 0; | ||
| 269 | wxUint32 players = 0; | ||
| 270 | TSPlayer *ply = NULL; | ||
| 271 | wxDataInputStreamEx in(istrm); | ||
| 272 | |||
| 273 | //read id | ||
| 274 | if(in.Read32() != m_Id) | ||
| 275 | { | ||
| 276 | SetLastError(_T("invalid command")); | ||
| 277 | return false; | ||
| 278 | } | ||
| 279 | |||
| 280 | in.Read32(); //Session id | ||
| 281 | in.Read32(); //Player id | ||
| 282 | cmd->pktid = in.Read32(); //Packet count | ||
| 283 | in.Read32(); //read unknown | ||
| 284 | crc = in.Read32(); //CRC | ||
| 285 | players = in.Read32(); | ||
| 286 | |||
| 287 | for(size_t i = 0; i < players; i++) | ||
| 288 | { | ||
| 289 | wxUint32 plyid = in.Read32(); | ||
| 290 | ply = client->FindPlayer(plyid); | ||
| 291 | if(ply == NULL) | ||
| 292 | { | ||
| 293 | ply = new TSPlayer; | ||
| 294 | client->GetPlayers()->Add(ply); | ||
| 295 | } | ||
| 296 | |||
| 297 | ply->SetId(plyid); | ||
| 298 | ply->SetChannelId(in.Read32()); | ||
| 299 | ply->SetChannelPrivileges(in.Read16()); | ||
| 300 | ply->SetPrivileges(in.Read16()); | ||
| 301 | ply->SetFlags(in.Read16()); | ||
| 302 | str.Clear(); | ||
| 303 | in.ReadFixedString(str); | ||
| 304 | ply->SetNickname(str); | ||
| 305 | } | ||
| 306 | |||
| 307 | //only for reducing warnings | ||
| 308 | wxUnusedVar(ostrm); | ||
| 309 | wxUnusedVar(crc); | ||
| 310 | return true; | ||
| 311 | } | ||
| 312 | |||
| 313 | //------------------------------------------------------------------------------ | ||
| 314 | // TSRecvAck | ||
| 315 | bool TSCmdRecvAck::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 316 | { | ||
| 317 | wxUint32 crc = 0; | ||
| 318 | wxDataInputStreamEx in(istrm); | ||
| 319 | |||
| 320 | //read id | ||
| 321 | if(in.Read32() != m_Id) | ||
| 322 | { | ||
| 323 | SetLastError(_T("invalid command")); | ||
| 324 | return false; | ||
| 325 | } | ||
| 326 | |||
| 327 | in.Read32(); //Session id | ||
| 328 | in.Read32(); //Player id | ||
| 329 | cmd->pktid = in.Read32(); //Packet count | ||
| 330 | crc = in.Read32(); //CRC | ||
| 331 | |||
| 332 | //only for reducing warnings | ||
| 333 | wxUnusedVar(ostrm); | ||
| 334 | wxUnusedVar(crc); | ||
| 335 | return true; | ||
| 336 | } | ||
| 337 | |||
| 338 | |||
| 339 | //------------------------------------------------------------------------------ | ||
| 340 | // TSSendAck | ||
| 341 | |||
| 342 | bool TSCmdSendAck::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 343 | { | ||
| 344 | TSClient *client = cmd->client; | ||
| 345 | wxByte buf[1024]; | ||
| 346 | wxUint32 len = 0; | ||
| 347 | wxMemoryOutputStream tmpstrm; | ||
| 348 | wxDataOutputStreamEx out(tmpstrm); | ||
| 349 | |||
| 350 | out.Write32(TS_CMD_RECV_ACK); //same id as recv | ||
| 351 | out.Write32(client->GetSessionId()); //SessionId | ||
| 352 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 353 | out.Write32(cmd->pktid); //Counter | ||
| 354 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 355 | ostrm.Write(buf, len); | ||
| 356 | |||
| 357 | //only for reducing warnings | ||
| 358 | wxUnusedVar(istrm); | ||
| 359 | return true; | ||
| 360 | } | ||
| 361 | |||
| 362 | //------------------------------------------------------------------------------ | ||
| 363 | // TSRecvUrl | ||
| 364 | bool TSCmdRecvUrl::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 365 | { | ||
| 366 | wxUint32 crc = 0; | ||
| 367 | wxDataInputStreamEx in(istrm); | ||
| 368 | |||
| 369 | //read id | ||
| 370 | if(in.Read32() != m_Id) | ||
| 371 | { | ||
| 372 | SetLastError(_T("invalid command")); | ||
| 373 | return false; | ||
| 374 | } | ||
| 375 | |||
| 376 | in.Read32(); //Session id | ||
| 377 | in.Read32(); //Player id | ||
| 378 | cmd->pktid = in.Read32(); //Packet count | ||
| 379 | crc = in.Read32(); //CRC | ||
| 380 | |||
| 381 | //only for reducing warnings | ||
| 382 | wxUnusedVar(ostrm); | ||
| 383 | wxUnusedVar(crc); | ||
| 384 | return true; | ||
| 385 | } | ||
| 386 | |||
| 387 | //------------------------------------------------------------------------------ | ||
| 388 | // TSSendPing | ||
| 389 | bool TSCmdSendPing::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 390 | { | ||
| 391 | TSClient *client = cmd->client; | ||
| 392 | wxByte buf[1024]; | ||
| 393 | wxUint32 len = 0; | ||
| 394 | static wxUint32 cnt = 2; | ||
| 395 | wxMemoryOutputStream tmpstrm; | ||
| 396 | wxDataOutputStreamEx out(tmpstrm); | ||
| 397 | |||
| 398 | out.Write32(m_Id); | ||
| 399 | out.Write32(client->GetSessionId()); //SessionId | ||
| 400 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 401 | out.Write32(cnt++); //Counter | ||
| 402 | out.Write32(0); | ||
| 403 | |||
| 404 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 405 | CRC32 myCRC32; | ||
| 406 | myCRC32.update(buf, len); | ||
| 407 | |||
| 408 | tmpstrm.SeekO(16); | ||
| 409 | out.Write32(myCRC32.getUint32Value()); | ||
| 410 | len = tmpstrm.CopyTo(buf, len); | ||
| 411 | |||
| 412 | ostrm.Write(buf, len); | ||
| 413 | |||
| 414 | //only for reducing warnings | ||
| 415 | wxUnusedVar(istrm); | ||
| 416 | return true; | ||
| 417 | } | ||
| 418 | |||
| 419 | //------------------------------------------------------------------------------ | ||
| 420 | // TSRecvPing | ||
| 421 | bool TSCmdRecvPing::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 422 | { | ||
| 423 | //only for reducing warnings | ||
| 424 | wxUnusedVar(istrm); | ||
| 425 | wxUnusedVar(ostrm); | ||
| 426 | wxUnusedVar(cmd); | ||
| 427 | return true; | ||
| 428 | } | ||
| 429 | |||
| 430 | //------------------------------------------------------------------------------ | ||
| 431 | // SendLogout | ||
| 432 | bool TSCmdSendLogout::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 433 | { | ||
| 434 | TSClient *client = cmd->client; | ||
| 435 | wxByte buf[1024]; | ||
| 436 | wxUint32 len = 0; | ||
| 437 | wxMemoryOutputStream tmpstrm; | ||
| 438 | wxDataOutputStreamEx out(tmpstrm); | ||
| 439 | |||
| 440 | out.Write32(m_Id); | ||
| 441 | out.Write32(client->GetSessionId()); //SessionId | ||
| 442 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 443 | out.Write32(m_Cnt++); //Counter | ||
| 444 | out.Write32(0); | ||
| 445 | out.Write32(0); | ||
| 446 | |||
| 447 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 448 | CRC32 myCRC32; | ||
| 449 | myCRC32.update(buf, len); | ||
| 450 | |||
| 451 | tmpstrm.SeekO(20); | ||
| 452 | out.Write32(myCRC32.getUint32Value()); | ||
| 453 | len = tmpstrm.CopyTo(buf, len); | ||
| 454 | |||
| 455 | ostrm.Write(buf, len); | ||
| 456 | |||
| 457 | //only for reducing warnings | ||
| 458 | wxUnusedVar(istrm); | ||
| 459 | return true; | ||
| 460 | } | ||
| 461 | |||
| 462 | //------------------------------------------------------------------------------ | ||
| 463 | // RecvLogoutInfo | ||
| 464 | bool TSCmdRecvLogout::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 465 | { | ||
| 466 | TSClient *client = cmd->client; | ||
| 467 | wxUint32 crc = 0; | ||
| 468 | wxUint32 id; | ||
| 469 | wxDataInputStreamEx in(istrm); | ||
| 470 | |||
| 471 | //read id | ||
| 472 | if(in.Read32() != m_Id) | ||
| 473 | { | ||
| 474 | SetLastError(_T("invalid command")); | ||
| 475 | return false; | ||
| 476 | } | ||
| 477 | |||
| 478 | in.Read32(); //Session id | ||
| 479 | in.Read32(); //Player id | ||
| 480 | cmd->pktid = in.Read32(); //Packet count | ||
| 481 | in.Read32(); | ||
| 482 | crc = in.Read32(); //CRC | ||
| 483 | id = in.Read32(); | ||
| 484 | |||
| 485 | for(size_t i = 0; i < client->GetPlayers()->GetCount(); i++) | ||
| 486 | { | ||
| 487 | if(id == client->GetPlayers()->Item(i)->GetId()) | ||
| 488 | { | ||
| 489 | delete client->GetPlayers()->Item(i); | ||
| 490 | client->GetPlayers()->RemoveAt(i); | ||
| 491 | return true; | ||
| 492 | } | ||
| 493 | } | ||
| 494 | |||
| 495 | //only for reducing warnings | ||
| 496 | wxUnusedVar(ostrm); | ||
| 497 | wxUnusedVar(crc); | ||
| 498 | |||
| 499 | SetLastError(_T("unknown player, not found in list, can't remove")); | ||
| 500 | return false; | ||
| 501 | } | ||
| 502 | |||
| 503 | //------------------------------------------------------------------------------ | ||
| 504 | // TSCmdRecvAddPlayer | ||
| 505 | bool TSCmdRecvAddPlayer::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 506 | { | ||
| 507 | TSClient *client = cmd->client; | ||
| 508 | wxString str; | ||
| 509 | wxUint32 crc = 0; | ||
| 510 | wxUint32 id = 0; | ||
| 511 | TSPlayer *ply = NULL; | ||
| 512 | wxDataInputStreamEx in(istrm); | ||
| 513 | |||
| 514 | //read id | ||
| 515 | if(in.Read32() != m_Id) | ||
| 516 | { | ||
| 517 | SetLastError(_T("invalid command")); | ||
| 518 | return false; | ||
| 519 | } | ||
| 520 | |||
| 521 | in.Read32(); //Session id | ||
| 522 | in.Read32(); //Player id | ||
| 523 | cmd->pktid = in.Read32(); //Packet count | ||
| 524 | in.Read32(); //read unknown | ||
| 525 | crc = in.Read32(); //CRC | ||
| 526 | id = in.Read32(); //Player id | ||
| 527 | ply = client->FindPlayer(id); | ||
| 528 | |||
| 529 | if(ply == NULL) | ||
| 530 | { | ||
| 531 | ply = new TSPlayer; | ||
| 532 | client->GetPlayers()->Add(ply); | ||
| 533 | } | ||
| 534 | |||
| 535 | ply->SetId(id); | ||
| 536 | ply->SetChannelId(in.Read32()); | ||
| 537 | ply->SetChannelPrivileges(in.Read16()); | ||
| 538 | ply->SetPrivileges(in.Read16()); | ||
| 539 | ply->SetFlags(in.Read16()); | ||
| 540 | str.Clear(); | ||
| 541 | in.ReadFixedString(str); | ||
| 542 | ply->SetNickname(str); | ||
| 543 | |||
| 544 | //only for reducing warnings | ||
| 545 | wxUnusedVar(ostrm); | ||
| 546 | wxUnusedVar(crc); | ||
| 547 | return true; | ||
| 548 | } | ||
| 549 | |||
| 550 | //------------------------------------------------------------------------------ | ||
| 551 | // TSCmdRecvPlayerFlags | ||
| 552 | bool TSCmdRecvPlayerFlags::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 553 | { | ||
| 554 | TSClient *client = cmd->client; | ||
| 555 | TSPlayer *ply = NULL; | ||
| 556 | wxUint32 crc = 0; | ||
| 557 | wxUint32 plyid = 0; | ||
| 558 | wxUint32 plyflags = 0; | ||
| 559 | wxDataInputStreamEx in(istrm); | ||
| 560 | |||
| 561 | //read id | ||
| 562 | if(in.Read32() != m_Id) | ||
| 563 | { | ||
| 564 | SetLastError(_T("invalid command")); | ||
| 565 | return false; | ||
| 566 | } | ||
| 567 | |||
| 568 | in.Read32(); //Session id | ||
| 569 | in.Read32(); //Player id | ||
| 570 | cmd->pktid = in.Read32(); //Packet count | ||
| 571 | in.Read32(); //read unknown | ||
| 572 | crc = in.Read32(); //CRC | ||
| 573 | plyid = in.Read32(); | ||
| 574 | plyflags = in.Read16(); | ||
| 575 | |||
| 576 | ply = client->FindPlayer(plyid); | ||
| 577 | if(ply != NULL) | ||
| 578 | { | ||
| 579 | ply->SetFlags(plyflags); | ||
| 580 | return true; | ||
| 581 | } | ||
| 582 | |||
| 583 | //only for reducing warnings | ||
| 584 | wxUnusedVar(ostrm); | ||
| 585 | wxUnusedVar(crc); | ||
| 586 | |||
| 587 | SetLastError(_T("unknown player, not found in list, flags not set")); | ||
| 588 | return false; | ||
| 589 | } | ||
| 590 | |||
| 591 | //------------------------------------------------------------------------------ | ||
| 592 | // TSCmdRecvAddChannel | ||
| 593 | bool TSCmdRecvAddChannel::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 594 | { | ||
| 595 | TSClient *client = cmd->client; | ||
| 596 | TSChannel *chl = NULL; | ||
| 597 | wxString str; | ||
| 598 | wxUint32 crc = 0; | ||
| 599 | wxUint32 chlid = 0; | ||
| 600 | wxDataInputStreamEx in(istrm); | ||
| 601 | |||
| 602 | //read id | ||
| 603 | if(in.Read32() != m_Id) | ||
| 604 | { | ||
| 605 | SetLastError(_T("invalid command")); | ||
| 606 | return false; | ||
| 607 | } | ||
| 608 | |||
| 609 | in.Read32(); //Session id | ||
| 610 | in.Read32(); //Player id | ||
| 611 | cmd->pktid = in.Read32(); //Packet count | ||
| 612 | in.Read32(); //read unknown | ||
| 613 | crc = in.Read32(); //CRC | ||
| 614 | in.Read32(); //user | ||
| 615 | chlid = in.Read32(); | ||
| 616 | chl = client->FindChannel(chlid); | ||
| 617 | if(chl == NULL) | ||
| 618 | { | ||
| 619 | chl = new TSChannel; | ||
| 620 | client->GetChannels()->Add(chl); | ||
| 621 | } | ||
| 622 | |||
| 623 | chl->SetId(chlid); | ||
| 624 | chl->SetFlags(in.Read16()); | ||
| 625 | chl->SetCodec(in.Read16()); | ||
| 626 | chl->SetParent(in.Read32()); | ||
| 627 | chl->SetOrder(in.Read16()); | ||
| 628 | chl->SetMaxUsers(in.Read16()); | ||
| 629 | str.Clear(); | ||
| 630 | in.ReadZeroString(str); | ||
| 631 | chl->SetName(str); | ||
| 632 | str.Clear(); | ||
| 633 | in.ReadZeroString(str); | ||
| 634 | chl->SetTopic(str); | ||
| 635 | str.Clear(); | ||
| 636 | in.ReadZeroString(str); | ||
| 637 | chl->SetDescription(str); | ||
| 638 | |||
| 639 | //only for reducing warnings | ||
| 640 | wxUnusedVar(ostrm); | ||
| 641 | wxUnusedVar(crc); | ||
| 642 | return true; | ||
| 643 | } | ||
| 644 | |||
| 645 | //------------------------------------------------------------------------------ | ||
| 646 | // TSCmdRecvMovePlayer | ||
| 647 | bool TSCmdRecvMovePlayer::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 648 | { | ||
| 649 | TSClient *client = cmd->client; | ||
| 650 | TSPlayer *ply = NULL; | ||
| 651 | wxUint32 crc = 0; | ||
| 652 | wxUint32 plyid = 0; | ||
| 653 | wxUint32 chlid = 0; | ||
| 654 | wxDataInputStreamEx in(istrm); | ||
| 655 | |||
| 656 | //read id | ||
| 657 | if(in.Read32() != m_Id) | ||
| 658 | { | ||
| 659 | SetLastError(_T("invalid command")); | ||
| 660 | return false; | ||
| 661 | } | ||
| 662 | |||
| 663 | in.Read32(); //Session id | ||
| 664 | in.Read32(); //Player id | ||
| 665 | cmd->pktid = in.Read32(); //Packet count | ||
| 666 | in.Read32(); //read unknown | ||
| 667 | crc = in.Read32(); //CRC | ||
| 668 | plyid = in.Read32(); | ||
| 669 | in.Read32(); //old channel | ||
| 670 | chlid = in.Read32(); //new channel | ||
| 671 | in.Read16(); //unknown | ||
| 672 | |||
| 673 | ply = client->FindPlayer(plyid); | ||
| 674 | if(ply != NULL) | ||
| 675 | { | ||
| 676 | ply->SetChannelId(chlid); | ||
| 677 | return true; | ||
| 678 | } | ||
| 679 | |||
| 680 | //only for reducing warnings | ||
| 681 | wxUnusedVar(ostrm); | ||
| 682 | wxUnusedVar(crc); | ||
| 683 | |||
| 684 | SetLastError(_T("unknown player, not found in list, channel not set")); | ||
| 685 | return false; | ||
| 686 | } | ||
| 687 | |||
| 688 | //------------------------------------------------------------------------------ | ||
| 689 | // TSCmdRecvMovePlayer | ||
| 690 | bool TSCmdRecvMovePlayer2::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 691 | { | ||
| 692 | TSClient *client = cmd->client; | ||
| 693 | TSPlayer *ply = NULL; | ||
| 694 | wxUint32 crc = 0; | ||
| 695 | wxUint32 plyid = 0; | ||
| 696 | wxUint32 chlid = 0; | ||
| 697 | wxDataInputStreamEx in(istrm); | ||
| 698 | |||
| 699 | //read id | ||
| 700 | if(in.Read32() != m_Id) | ||
| 701 | { | ||
| 702 | SetLastError(_T("invalid command")); | ||
| 703 | return false; | ||
| 704 | } | ||
| 705 | |||
| 706 | in.Read32(); //Session id | ||
| 707 | in.Read32(); //Player id | ||
| 708 | cmd->pktid = in.Read32(); //Packet count | ||
| 709 | in.Read32(); //read unknown | ||
| 710 | crc = in.Read32(); //CRC | ||
| 711 | plyid = in.Read32(); | ||
| 712 | in.Read32(); //old channel | ||
| 713 | chlid = in.Read32(); //new channel | ||
| 714 | in.Read16(); //unknown | ||
| 715 | |||
| 716 | ply = client->FindPlayer(plyid); | ||
| 717 | if(ply != NULL) | ||
| 718 | { | ||
| 719 | ply->SetChannelId(chlid); | ||
| 720 | return true; | ||
| 721 | } | ||
| 722 | |||
| 723 | //only for reducing warnings | ||
| 724 | wxUnusedVar(ostrm); | ||
| 725 | wxUnusedVar(crc); | ||
| 726 | |||
| 727 | SetLastError(_T("unknown player, not found in list, channel not set")); | ||
| 728 | return false; | ||
| 729 | } | ||
| 730 | |||
| 731 | //------------------------------------------------------------------------------ | ||
| 732 | // TSCmdRecvDelChannel | ||
| 733 | bool TSCmdRecvDelChannel::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 734 | { | ||
| 735 | TSClient *client = cmd->client; | ||
| 736 | wxUint32 crc = 0; | ||
| 737 | wxUint32 plyid = 0; | ||
| 738 | wxUint16 chlid = 0; | ||
| 739 | wxDataInputStreamEx in(istrm); | ||
| 740 | |||
| 741 | //read id | ||
| 742 | if(in.Read32() != m_Id) | ||
| 743 | { | ||
| 744 | SetLastError(_T("invalid command")); | ||
| 745 | return false; | ||
| 746 | } | ||
| 747 | |||
| 748 | in.Read32(); //Session id | ||
| 749 | in.Read32(); //Player id | ||
| 750 | cmd->pktid = in.Read32(); //Packet count | ||
| 751 | in.Read32(); //read unknown | ||
| 752 | crc = in.Read32(); //CRC | ||
| 753 | chlid = in.Read16(); // channel | ||
| 754 | plyid = in.Read32(); | ||
| 755 | |||
| 756 | for(size_t i = 0; i < client->GetChannels()->GetCount(); i++) | ||
| 757 | { | ||
| 758 | if(chlid == client->GetChannels()->Item(i)->GetId()) | ||
| 759 | { | ||
| 760 | delete client->GetChannels()->Item(i); | ||
| 761 | client->GetChannels()->RemoveAt(i); | ||
| 762 | return true; | ||
| 763 | } | ||
| 764 | } | ||
| 765 | |||
| 766 | //only for reducing warnings | ||
| 767 | wxUnusedVar(ostrm); | ||
| 768 | wxUnusedVar(crc); | ||
| 769 | wxUnusedVar(plyid); | ||
| 770 | |||
| 771 | SetLastError(_T("unknown channel, not found in list")); | ||
| 772 | return false; | ||
| 773 | } | ||
| 774 | |||
| 775 | //------------------------------------------------------------------------------ | ||
| 776 | // TSCmdRecvServerUpdate | ||
| 777 | bool TSCmdRecvServerUpdate::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 778 | { | ||
| 779 | wxUint32 crc = 0; | ||
| 780 | wxDataInputStreamEx in(istrm); | ||
| 781 | |||
| 782 | //read id | ||
| 783 | if(in.Read32() != m_Id) | ||
| 784 | { | ||
| 785 | SetLastError(_T("invalid command")); | ||
| 786 | return false; | ||
| 787 | } | ||
| 788 | |||
| 789 | in.Read32(); //Session id | ||
| 790 | in.Read32(); //Player id | ||
| 791 | cmd->pktid = in.Read32(); //Packet count | ||
| 792 | in.Read32(); //read unknown | ||
| 793 | crc = in.Read32(); //CRC | ||
| 794 | |||
| 795 | // in.Read32(); //unknown | ||
| 796 | // in.Read32(); //unknown | ||
| 797 | // servertype = in.Read16(); //clan=05, public=06 | ||
| 798 | // more unknown data | ||
| 799 | // all over 80 byte (so 62 left or so) | ||
| 800 | |||
| 801 | //only for reducing warnings | ||
| 802 | wxUnusedVar(ostrm); | ||
| 803 | wxUnusedVar(crc); | ||
| 804 | |||
| 805 | return true; | ||
| 806 | } | ||
| 807 | |||
| 808 | //------------------------------------------------------------------------------ | ||
| 809 | // TSCmdSendAddChannel | ||
| 810 | bool TSCmdSendAddChannel::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 811 | { | ||
| 812 | TSClient *client = cmd->client; | ||
| 813 | wxByte buf[1024]; | ||
| 814 | wxUint32 len = 0; | ||
| 815 | wxMemoryOutputStream tmpstrm; | ||
| 816 | wxDataOutputStreamEx out(tmpstrm); | ||
| 817 | |||
| 818 | out.Write32(m_Id); | ||
| 819 | out.Write32(client->GetSessionId()); //SessionId | ||
| 820 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 821 | out.Write32(m_Cnt++); //Counter | ||
| 822 | out.Write32(0); //unknown | ||
| 823 | out.Write32(0); //crc | ||
| 824 | |||
| 825 | out.Write32(0); //must be null | ||
| 826 | |||
| 827 | out.Write16(cmd->param1.pChannel->GetFlags()); | ||
| 828 | out.Write16(cmd->param1.pChannel->GetCodec()); | ||
| 829 | out.Write32(cmd->param1.pChannel->GetParent()); | ||
| 830 | out.Write16(cmd->param1.pChannel->GetOrder()); | ||
| 831 | out.Write16(cmd->param1.pChannel->GetMaxUsers()); | ||
| 832 | out.WriteZeroString(cmd->param1.pChannel->GetName()); | ||
| 833 | out.WriteZeroString(cmd->param1.pChannel->GetTopic()); | ||
| 834 | out.WriteZeroString(cmd->param1.pChannel->GetDescription()); | ||
| 835 | if (cmd->param1.pChannel->GetPassword().Length() > 0) | ||
| 836 | out.WriteZeroString(cmd->param1.pChannel->GetPassword()); | ||
| 837 | else | ||
| 838 | out.Write8(0); | ||
| 839 | |||
| 840 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 841 | CRC32 myCRC32; | ||
| 842 | myCRC32.update(buf, len); | ||
| 843 | |||
| 844 | tmpstrm.SeekO(20); | ||
| 845 | out.Write32(myCRC32.getUint32Value()); | ||
| 846 | len = tmpstrm.CopyTo(buf, len); | ||
| 847 | |||
| 848 | ostrm.Write(buf, len); | ||
| 849 | |||
| 850 | //only for reducing warnings | ||
| 851 | wxUnusedVar(istrm); | ||
| 852 | return true; | ||
| 853 | } | ||
| 854 | |||
| 855 | //------------------------------------------------------------------------------ | ||
| 856 | // TSCmdSendDelChannel | ||
| 857 | bool TSCmdSendDelChannel::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 858 | { | ||
| 859 | TSClient *client = cmd->client; | ||
| 860 | wxByte buf[1024]; | ||
| 861 | wxUint32 len = 0; | ||
| 862 | wxMemoryOutputStream tmpstrm; | ||
| 863 | wxDataOutputStreamEx out(tmpstrm); | ||
| 864 | |||
| 865 | out.Write32(m_Id); | ||
| 866 | out.Write32(client->GetSessionId()); //SessionId | ||
| 867 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 868 | out.Write32(m_Cnt++); //Counter | ||
| 869 | out.Write32(0); //unknown | ||
| 870 | out.Write32(0); //crc | ||
| 871 | |||
| 872 | out.Write32(cmd->param1.pChannel->GetId()); | ||
| 873 | |||
| 874 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 875 | CRC32 myCRC32; | ||
| 876 | myCRC32.update(buf, len); | ||
| 877 | |||
| 878 | tmpstrm.SeekO(20); | ||
| 879 | out.Write32(myCRC32.getUint32Value()); | ||
| 880 | len = tmpstrm.CopyTo(buf, len); | ||
| 881 | |||
| 882 | ostrm.Write(buf, len); | ||
| 883 | |||
| 884 | //only for reducing warnings | ||
| 885 | wxUnusedVar(istrm); | ||
| 886 | return true; | ||
| 887 | } | ||
| 888 | |||
| 889 | //------------------------------------------------------------------------------ | ||
| 890 | // TSCmdSendMovePlayer | ||
| 891 | bool TSCmdSendMovePlayer::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 892 | { | ||
| 893 | TSClient *client = cmd->client; | ||
| 894 | wxByte buf[1024]; | ||
| 895 | wxUint32 len = 0; | ||
| 896 | wxMemoryOutputStream tmpstrm; | ||
| 897 | wxDataOutputStreamEx out(tmpstrm); | ||
| 898 | |||
| 899 | out.Write32(m_Id); | ||
| 900 | out.Write32(client->GetSessionId()); //SessionId | ||
| 901 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 902 | out.Write32(m_Cnt++); //Counter | ||
| 903 | out.Write32(0); //unknown | ||
| 904 | out.Write32(0); //crc | ||
| 905 | |||
| 906 | out.Write32(cmd->param1.pPlayer->GetId()); | ||
| 907 | out.Write32(cmd->param1.pPlayer->GetChannelId()); | ||
| 908 | |||
| 909 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 910 | CRC32 myCRC32; | ||
| 911 | myCRC32.update(buf, len); | ||
| 912 | |||
| 913 | tmpstrm.SeekO(20); | ||
| 914 | out.Write32(myCRC32.getUint32Value()); | ||
| 915 | len = tmpstrm.CopyTo(buf, len); | ||
| 916 | |||
| 917 | ostrm.Write(buf, len); | ||
| 918 | |||
| 919 | //only for reducing warnings | ||
| 920 | wxUnusedVar(istrm); | ||
| 921 | return true; | ||
| 922 | } | ||
| 923 | |||
| 924 | //------------------------------------------------------------------------------ | ||
| 925 | // TSCmdSendSetChannelPassword | ||
| 926 | bool TSCmdSendSetChannelPassword::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 927 | { | ||
| 928 | TSClient *client = cmd->client; | ||
| 929 | wxByte buf[1024]; | ||
| 930 | wxUint32 len = 0; | ||
| 931 | wxMemoryOutputStream tmpstrm; | ||
| 932 | wxDataOutputStreamEx out(tmpstrm); | ||
| 933 | |||
| 934 | out.Write32(m_Id); | ||
| 935 | out.Write32(client->GetSessionId()); //SessionId | ||
| 936 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 937 | out.Write32(m_Cnt++); //Counter | ||
| 938 | out.Write32(0); //unknown | ||
| 939 | out.Write32(0); //crc | ||
| 940 | |||
| 941 | out.Write32(cmd->param1.pChannel->GetId()); | ||
| 942 | out.WriteFixedString(cmd->param1.pChannel->GetPassword()); | ||
| 943 | |||
| 944 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 945 | CRC32 myCRC32; | ||
| 946 | myCRC32.update(buf, len); | ||
| 947 | |||
| 948 | tmpstrm.SeekO(20); | ||
| 949 | out.Write32(myCRC32.getUint32Value()); | ||
| 950 | len = tmpstrm.CopyTo(buf, len); | ||
| 951 | |||
| 952 | ostrm.Write(buf, len); | ||
| 953 | |||
| 954 | //only for reducing warnings | ||
| 955 | wxUnusedVar(istrm); | ||
| 956 | return true; | ||
| 957 | } | ||
| 958 | |||
| 959 | //------------------------------------------------------------------------------ | ||
| 960 | // TSCmdSendSetChannelName | ||
| 961 | bool TSCmdSendSetChannelName::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 962 | { | ||
| 963 | TSClient *client = cmd->client; | ||
| 964 | wxByte buf[1024]; | ||
| 965 | wxUint32 len = 0; | ||
| 966 | wxMemoryOutputStream tmpstrm; | ||
| 967 | wxDataOutputStreamEx out(tmpstrm); | ||
| 968 | |||
| 969 | out.Write32(m_Id); | ||
| 970 | out.Write32(client->GetSessionId()); //SessionId | ||
| 971 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 972 | out.Write32(m_Cnt++); //Counter | ||
| 973 | out.Write32(0); //unknown | ||
| 974 | out.Write32(0); //crc | ||
| 975 | |||
| 976 | out.Write32(cmd->param1.pChannel->GetId()); | ||
| 977 | out.WriteZeroString(cmd->param1.pChannel->GetName()); | ||
| 978 | |||
| 979 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 980 | CRC32 myCRC32; | ||
| 981 | myCRC32.update(buf, len); | ||
| 982 | |||
| 983 | tmpstrm.SeekO(20); | ||
| 984 | out.Write32(myCRC32.getUint32Value()); | ||
| 985 | len = tmpstrm.CopyTo(buf, len); | ||
| 986 | |||
| 987 | ostrm.Write(buf, len); | ||
| 988 | |||
| 989 | //only for reducing warnings | ||
| 990 | wxUnusedVar(istrm); | ||
| 991 | wxUnusedVar(ostrm); | ||
| 992 | return true; | ||
| 993 | } | ||
| 994 | |||
| 995 | //------------------------------------------------------------------------------ | ||
| 996 | // TSCmdSendSetChannelTopic | ||
| 997 | bool TSCmdSendSetChannelTopic::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 998 | { | ||
| 999 | TSClient *client = cmd->client; | ||
| 1000 | wxByte buf[1024]; | ||
| 1001 | wxUint32 len = 0; | ||
| 1002 | wxMemoryOutputStream tmpstrm; | ||
| 1003 | wxDataOutputStreamEx out(tmpstrm); | ||
| 1004 | |||
| 1005 | out.Write32(m_Id); | ||
| 1006 | out.Write32(client->GetSessionId()); //SessionId | ||
| 1007 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 1008 | out.Write32(m_Cnt++); //Counter | ||
| 1009 | out.Write32(0); //unknown | ||
| 1010 | out.Write32(0); //crc | ||
| 1011 | |||
| 1012 | out.Write32(cmd->param1.pChannel->GetId()); | ||
| 1013 | out.WriteZeroString(cmd->param1.pChannel->GetTopic()); | ||
| 1014 | |||
| 1015 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 1016 | CRC32 myCRC32; | ||
| 1017 | myCRC32.update(buf, len); | ||
| 1018 | |||
| 1019 | tmpstrm.SeekO(20); | ||
| 1020 | out.Write32(myCRC32.getUint32Value()); | ||
| 1021 | len = tmpstrm.CopyTo(buf, len); | ||
| 1022 | |||
| 1023 | ostrm.Write(buf, len); | ||
| 1024 | |||
| 1025 | //only for reducing warnings | ||
| 1026 | wxUnusedVar(istrm); | ||
| 1027 | return true; | ||
| 1028 | } | ||
| 1029 | |||
| 1030 | //------------------------------------------------------------------------------ | ||
| 1031 | // TSCmdSendSetChannelDescription | ||
| 1032 | bool TSCmdSendSetChannelDescription::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1033 | { | ||
| 1034 | TSClient *client = cmd->client; | ||
| 1035 | wxByte buf[1024]; | ||
| 1036 | wxUint32 len = 0; | ||
| 1037 | wxMemoryOutputStream tmpstrm; | ||
| 1038 | wxDataOutputStreamEx out(tmpstrm); | ||
| 1039 | |||
| 1040 | out.Write32(m_Id); | ||
| 1041 | out.Write32(client->GetSessionId()); //SessionId | ||
| 1042 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 1043 | out.Write32(m_Cnt++); //Counter | ||
| 1044 | out.Write32(0); //unknown | ||
| 1045 | out.Write32(0); //crc | ||
| 1046 | |||
| 1047 | out.Write32(cmd->param1.pChannel->GetId()); | ||
| 1048 | out.WriteZeroString(cmd->param1.pChannel->GetDescription()); | ||
| 1049 | |||
| 1050 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 1051 | CRC32 myCRC32; | ||
| 1052 | myCRC32.update(buf, len); | ||
| 1053 | |||
| 1054 | tmpstrm.SeekO(20); | ||
| 1055 | out.Write32(myCRC32.getUint32Value()); | ||
| 1056 | len = tmpstrm.CopyTo(buf, len); | ||
| 1057 | |||
| 1058 | ostrm.Write(buf, len); | ||
| 1059 | |||
| 1060 | //only for reducing warnings | ||
| 1061 | wxUnusedVar(istrm); | ||
| 1062 | return true; | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | //------------------------------------------------------------------------------ | ||
| 1066 | // TSCmdSendSetChannelMaxPlayers | ||
| 1067 | bool TSCmdSendSetChannelMaxPlayers::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1068 | { | ||
| 1069 | TSClient *client = cmd->client; | ||
| 1070 | wxByte buf[1024]; | ||
| 1071 | wxUint32 len = 0; | ||
| 1072 | wxMemoryOutputStream tmpstrm; | ||
| 1073 | wxDataOutputStreamEx out(tmpstrm); | ||
| 1074 | |||
| 1075 | out.Write32(m_Id); | ||
| 1076 | out.Write32(client->GetSessionId()); //SessionId | ||
| 1077 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 1078 | out.Write32(m_Cnt++); //Counter | ||
| 1079 | out.Write32(0); //unknown | ||
| 1080 | out.Write32(0); //crc | ||
| 1081 | |||
| 1082 | out.Write32(cmd->param1.pChannel->GetId()); | ||
| 1083 | out.Write16(cmd->param1.pChannel->GetMaxUsers()); | ||
| 1084 | |||
| 1085 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 1086 | CRC32 myCRC32; | ||
| 1087 | myCRC32.update(buf, len); | ||
| 1088 | |||
| 1089 | tmpstrm.SeekO(20); | ||
| 1090 | out.Write32(myCRC32.getUint32Value()); | ||
| 1091 | len = tmpstrm.CopyTo(buf, len); | ||
| 1092 | |||
| 1093 | ostrm.Write(buf, len); | ||
| 1094 | |||
| 1095 | //only for reducing warnings | ||
| 1096 | wxUnusedVar(istrm); | ||
| 1097 | wxUnusedVar(ostrm); | ||
| 1098 | return true; | ||
| 1099 | } | ||
| 1100 | |||
| 1101 | //------------------------------------------------------------------------------ | ||
| 1102 | // TSCmdSendSetChannelFlagsCodec | ||
| 1103 | bool TSCmdSendSetChannelFlagsCodec::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1104 | { | ||
| 1105 | TSClient *client = cmd->client; | ||
| 1106 | wxByte buf[1024]; | ||
| 1107 | wxUint32 len = 0; | ||
| 1108 | wxMemoryOutputStream tmpstrm; | ||
| 1109 | wxDataOutputStreamEx out(tmpstrm); | ||
| 1110 | |||
| 1111 | out.Write32(m_Id); | ||
| 1112 | out.Write32(client->GetSessionId()); //SessionId | ||
| 1113 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 1114 | out.Write32(m_Cnt++); //Counter | ||
| 1115 | out.Write32(0); //unknown | ||
| 1116 | out.Write32(0); //crc | ||
| 1117 | |||
| 1118 | out.Write32(cmd->param1.pChannel->GetId()); | ||
| 1119 | out.Write16(cmd->param1.pChannel->GetFlags()); | ||
| 1120 | out.Write16(cmd->param1.pChannel->GetCodec()); | ||
| 1121 | |||
| 1122 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 1123 | CRC32 myCRC32; | ||
| 1124 | myCRC32.update(buf, len); | ||
| 1125 | |||
| 1126 | tmpstrm.SeekO(20); | ||
| 1127 | out.Write32(myCRC32.getUint32Value()); | ||
| 1128 | len = tmpstrm.CopyTo(buf, len); | ||
| 1129 | |||
| 1130 | ostrm.Write(buf, len); | ||
| 1131 | |||
| 1132 | //only for reducing warnings | ||
| 1133 | wxUnusedVar(istrm); | ||
| 1134 | return true; | ||
| 1135 | } | ||
| 1136 | |||
| 1137 | //------------------------------------------------------------------------------ | ||
| 1138 | // TSCmdSendSetChannelOrder | ||
| 1139 | bool TSCmdSendSetChannelOrder::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1140 | { | ||
| 1141 | TSClient *client = cmd->client; | ||
| 1142 | wxByte buf[1024]; | ||
| 1143 | wxUint32 len = 0; | ||
| 1144 | wxMemoryOutputStream tmpstrm; | ||
| 1145 | wxDataOutputStreamEx out(tmpstrm); | ||
| 1146 | |||
| 1147 | out.Write32(m_Id); | ||
| 1148 | out.Write32(client->GetSessionId()); //SessionId | ||
| 1149 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 1150 | out.Write32(m_Cnt++); //Counter | ||
| 1151 | out.Write32(0); //unknown | ||
| 1152 | out.Write32(0); //crc | ||
| 1153 | |||
| 1154 | out.Write32(cmd->param1.pChannel->GetId()); | ||
| 1155 | out.Write16(cmd->param1.pChannel->GetOrder()); | ||
| 1156 | |||
| 1157 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 1158 | CRC32 myCRC32; | ||
| 1159 | myCRC32.update(buf, len); | ||
| 1160 | |||
| 1161 | tmpstrm.SeekO(20); | ||
| 1162 | out.Write32(myCRC32.getUint32Value()); | ||
| 1163 | len = tmpstrm.CopyTo(buf, len); | ||
| 1164 | |||
| 1165 | ostrm.Write(buf, len); | ||
| 1166 | |||
| 1167 | //only for reducing warnings | ||
| 1168 | wxUnusedVar(istrm); | ||
| 1169 | return true; | ||
| 1170 | } | ||
| 1171 | |||
| 1172 | //------------------------------------------------------------------------------ | ||
| 1173 | // TSCmdRecvSetChannelName | ||
| 1174 | bool TSCmdRecvSetChannelName::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1175 | { | ||
| 1176 | TSClient *client = cmd->client; | ||
| 1177 | TSChannel *chl = NULL; | ||
| 1178 | wxString str; | ||
| 1179 | wxUint32 crc = 0; | ||
| 1180 | wxUint32 chlid = 0; | ||
| 1181 | wxDataInputStreamEx in(istrm); | ||
| 1182 | |||
| 1183 | //read id | ||
| 1184 | if(in.Read32() != m_Id) | ||
| 1185 | { | ||
| 1186 | SetLastError(_T("invalid command")); | ||
| 1187 | return false; | ||
| 1188 | } | ||
| 1189 | |||
| 1190 | in.Read32(); //Session id | ||
| 1191 | in.Read32(); //Player id | ||
| 1192 | cmd->pktid = in.Read32(); //Packet count | ||
| 1193 | in.Read32(); //read unknown | ||
| 1194 | crc = in.Read32(); //CRC | ||
| 1195 | chlid = in.Read32(); | ||
| 1196 | |||
| 1197 | chl = client->FindChannel(chlid); | ||
| 1198 | if(chl == NULL) | ||
| 1199 | { | ||
| 1200 | SetLastError(_T("can't find channel")); | ||
| 1201 | return false; | ||
| 1202 | } | ||
| 1203 | |||
| 1204 | in.Read32(); //user id | ||
| 1205 | |||
| 1206 | str.Clear(); | ||
| 1207 | in.ReadZeroString(str); | ||
| 1208 | chl->SetName(str); | ||
| 1209 | |||
| 1210 | //only for reducing warnings | ||
| 1211 | wxUnusedVar(ostrm); | ||
| 1212 | wxUnusedVar(crc); | ||
| 1213 | return true; | ||
| 1214 | } | ||
| 1215 | |||
| 1216 | //------------------------------------------------------------------------------ | ||
| 1217 | // TSCmdRecvSetChannelTopic | ||
| 1218 | bool TSCmdRecvSetChannelTopic::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1219 | { | ||
| 1220 | TSClient *client = cmd->client; | ||
| 1221 | TSChannel *chl = NULL; | ||
| 1222 | wxString str; | ||
| 1223 | wxUint32 crc = 0; | ||
| 1224 | wxUint32 chlid = 0; | ||
| 1225 | wxDataInputStreamEx in(istrm); | ||
| 1226 | |||
| 1227 | //read id | ||
| 1228 | if(in.Read32() != m_Id) | ||
| 1229 | { | ||
| 1230 | SetLastError(_T("invalid command")); | ||
| 1231 | return false; | ||
| 1232 | } | ||
| 1233 | |||
| 1234 | in.Read32(); //Session id | ||
| 1235 | in.Read32(); //Player id | ||
| 1236 | cmd->pktid = in.Read32(); //Packet count | ||
| 1237 | in.Read32(); //read unknown | ||
| 1238 | crc = in.Read32(); //CRC | ||
| 1239 | chlid = in.Read32(); | ||
| 1240 | |||
| 1241 | chl = client->FindChannel(chlid); | ||
| 1242 | if(chl == NULL) | ||
| 1243 | { | ||
| 1244 | SetLastError(_T("can't find channel")); | ||
| 1245 | return false; | ||
| 1246 | } | ||
| 1247 | |||
| 1248 | in.Read32(); //user id | ||
| 1249 | |||
| 1250 | str.Clear(); | ||
| 1251 | in.ReadZeroString(str); | ||
| 1252 | chl->SetTopic(str); | ||
| 1253 | |||
| 1254 | //only for reducing warnings | ||
| 1255 | wxUnusedVar(ostrm); | ||
| 1256 | wxUnusedVar(crc); | ||
| 1257 | return true; | ||
| 1258 | } | ||
| 1259 | |||
| 1260 | //------------------------------------------------------------------------------ | ||
| 1261 | // TSCmdRecvSetChannelDescription | ||
| 1262 | bool TSCmdRecvSetChannelDescription::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1263 | { | ||
| 1264 | TSClient *client = cmd->client; | ||
| 1265 | TSChannel *chl = NULL; | ||
| 1266 | wxString str; | ||
| 1267 | wxUint32 crc = 0; | ||
| 1268 | wxUint32 chlid = 0; | ||
| 1269 | wxDataInputStreamEx in(istrm); | ||
| 1270 | |||
| 1271 | //read id | ||
| 1272 | if(in.Read32() != m_Id) | ||
| 1273 | { | ||
| 1274 | SetLastError(_T("invalid command")); | ||
| 1275 | return false; | ||
| 1276 | } | ||
| 1277 | |||
| 1278 | in.Read32(); //Session id | ||
| 1279 | in.Read32(); //Player id | ||
| 1280 | cmd->pktid = in.Read32(); //Packet count | ||
| 1281 | in.Read32(); //read unknown | ||
| 1282 | crc = in.Read32(); //CRC | ||
| 1283 | chlid = in.Read32(); | ||
| 1284 | |||
| 1285 | chl = client->FindChannel(chlid); | ||
| 1286 | if(chl == NULL) | ||
| 1287 | { | ||
| 1288 | SetLastError(_T("can't find channel")); | ||
| 1289 | return false; | ||
| 1290 | } | ||
| 1291 | |||
| 1292 | in.Read32(); //user id | ||
| 1293 | |||
| 1294 | str.Clear(); | ||
| 1295 | in.ReadZeroString(str); | ||
| 1296 | chl->SetDescription(str); | ||
| 1297 | |||
| 1298 | //only for reducing warnings | ||
| 1299 | wxUnusedVar(ostrm); | ||
| 1300 | wxUnusedVar(crc); | ||
| 1301 | return true; | ||
| 1302 | } | ||
| 1303 | |||
| 1304 | //------------------------------------------------------------------------------ | ||
| 1305 | // TSCmdRecvSetChannelMaxPlayers | ||
| 1306 | bool TSCmdRecvSetChannelMaxPlayers::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1307 | { | ||
| 1308 | TSClient *client = cmd->client; | ||
| 1309 | TSChannel *chl = NULL; | ||
| 1310 | wxUint32 crc = 0; | ||
| 1311 | wxUint32 chlid = 0; | ||
| 1312 | wxDataInputStreamEx in(istrm); | ||
| 1313 | |||
| 1314 | //read id | ||
| 1315 | if(in.Read32() != m_Id) | ||
| 1316 | { | ||
| 1317 | SetLastError(_T("invalid command")); | ||
| 1318 | return false; | ||
| 1319 | } | ||
| 1320 | |||
| 1321 | in.Read32(); //Session id | ||
| 1322 | in.Read32(); //Player id | ||
| 1323 | cmd->pktid = in.Read32(); //Packet count | ||
| 1324 | in.Read32(); //read unknown | ||
| 1325 | crc = in.Read32(); //CRC | ||
| 1326 | chlid = in.Read32(); | ||
| 1327 | |||
| 1328 | chl = client->FindChannel(chlid); | ||
| 1329 | if(chl == NULL) | ||
| 1330 | { | ||
| 1331 | SetLastError(_T("can't find channel")); | ||
| 1332 | return false; | ||
| 1333 | } | ||
| 1334 | |||
| 1335 | chl->SetMaxUsers(in.Read16()); | ||
| 1336 | |||
| 1337 | //only for reducing warnings | ||
| 1338 | wxUnusedVar(ostrm); | ||
| 1339 | wxUnusedVar(crc); | ||
| 1340 | return true; | ||
| 1341 | } | ||
| 1342 | |||
| 1343 | //------------------------------------------------------------------------------ | ||
| 1344 | // TSCmdRecvSetChannelFlagsCodec | ||
| 1345 | bool TSCmdRecvSetChannelFlagsCodec::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1346 | { | ||
| 1347 | TSClient *client = cmd->client; | ||
| 1348 | TSChannel *chl = NULL; | ||
| 1349 | wxUint32 crc = 0; | ||
| 1350 | wxUint32 chlid = 0; | ||
| 1351 | wxDataInputStreamEx in(istrm); | ||
| 1352 | |||
| 1353 | //read id | ||
| 1354 | if(in.Read32() != m_Id) | ||
| 1355 | { | ||
| 1356 | SetLastError(_T("invalid command")); | ||
| 1357 | return false; | ||
| 1358 | } | ||
| 1359 | |||
| 1360 | in.Read32(); //Session id | ||
| 1361 | in.Read32(); //Player id | ||
| 1362 | cmd->pktid = in.Read32(); //Packet count | ||
| 1363 | in.Read32(); //read unknown | ||
| 1364 | crc = in.Read32(); //CRC | ||
| 1365 | chlid = in.Read32(); | ||
| 1366 | |||
| 1367 | chl = client->FindChannel(chlid); | ||
| 1368 | if(chl == NULL) | ||
| 1369 | { | ||
| 1370 | SetLastError(_T("can't find channel")); | ||
| 1371 | return false; | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | chl->SetFlags(in.Read16()); | ||
| 1375 | chl->SetCodec(in.Read16()); | ||
| 1376 | |||
| 1377 | //only for reducing warnings | ||
| 1378 | wxUnusedVar(ostrm); | ||
| 1379 | wxUnusedVar(crc); | ||
| 1380 | return true; | ||
| 1381 | } | ||
| 1382 | |||
| 1383 | //------------------------------------------------------------------------------ | ||
| 1384 | // TSCmdRecvSetChannelOrder | ||
| 1385 | bool TSCmdRecvSetChannelOrder::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1386 | { | ||
| 1387 | TSClient *client = cmd->client; | ||
| 1388 | TSChannel *chl = NULL; | ||
| 1389 | wxUint32 crc = 0; | ||
| 1390 | wxUint32 chlid = 0; | ||
| 1391 | wxDataInputStreamEx in(istrm); | ||
| 1392 | |||
| 1393 | //read id | ||
| 1394 | if(in.Read32() != m_Id) | ||
| 1395 | { | ||
| 1396 | SetLastError(_T("invalid command")); | ||
| 1397 | return false; | ||
| 1398 | } | ||
| 1399 | |||
| 1400 | in.Read32(); //Session id | ||
| 1401 | in.Read32(); //Player id | ||
| 1402 | cmd->pktid = in.Read32(); //Packet count | ||
| 1403 | in.Read32(); //read unknown | ||
| 1404 | crc = in.Read32(); //CRC | ||
| 1405 | chlid = in.Read32(); | ||
| 1406 | |||
| 1407 | chl = client->FindChannel(chlid); | ||
| 1408 | if(chl == NULL) | ||
| 1409 | { | ||
| 1410 | SetLastError(_T("can't find channel")); | ||
| 1411 | return false; | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | chl->SetOrder(in.Read32()); | ||
| 1415 | |||
| 1416 | //only for reducing warnings | ||
| 1417 | wxUnusedVar(ostrm); | ||
| 1418 | wxUnusedVar(crc); | ||
| 1419 | return true; | ||
| 1420 | } | ||
| 1421 | |||
| 1422 | //------------------------------------------------------------------------------ | ||
| 1423 | // TSCmdSendKickPlayer | ||
| 1424 | bool TSCmdSendKickPlayer::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1425 | { | ||
| 1426 | TSClient *client = cmd->client; | ||
| 1427 | wxByte buf[1024]; | ||
| 1428 | wxUint32 len = 0; | ||
| 1429 | wxMemoryOutputStream tmpstrm; | ||
| 1430 | wxDataOutputStreamEx out(tmpstrm); | ||
| 1431 | |||
| 1432 | out.Write32(m_Id); | ||
| 1433 | out.Write32(client->GetSessionId()); //SessionId | ||
| 1434 | out.Write32(client->GetPlayer()->GetId()); //PlayerId | ||
| 1435 | out.Write32(m_Cnt++); //Counter | ||
| 1436 | out.Write32(0); //unknown | ||
| 1437 | out.Write32(0); //crc | ||
| 1438 | |||
| 1439 | out.Write32(cmd->param1.pPlayer->GetId()); | ||
| 1440 | out.WriteFixedString(*cmd->param2.pString); | ||
| 1441 | |||
| 1442 | |||
| 1443 | len = tmpstrm.CopyTo(buf, 1024); | ||
| 1444 | CRC32 myCRC32; | ||
| 1445 | myCRC32.update(buf, len); | ||
| 1446 | |||
| 1447 | tmpstrm.SeekO(20); | ||
| 1448 | out.Write32(myCRC32.getUint32Value()); | ||
| 1449 | len = tmpstrm.CopyTo(buf, len); | ||
| 1450 | |||
| 1451 | ostrm.Write(buf, len); | ||
| 1452 | |||
| 1453 | //only for reducing warnings | ||
| 1454 | wxUnusedVar(istrm); | ||
| 1455 | return true; | ||
| 1456 | } | ||
| 1457 | |||
| 1458 | //------------------------------------------------------------------------------ | ||
| 1459 | // TSCmdRecvChannelPasswordChanged | ||
| 1460 | bool TSCmdRecvChannelPasswordChanged::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1461 | { | ||
| 1462 | wxUint32 crc = 0; | ||
| 1463 | wxDataInputStreamEx in(istrm); | ||
| 1464 | |||
| 1465 | //read id | ||
| 1466 | if(in.Read32() != m_Id) | ||
| 1467 | { | ||
| 1468 | SetLastError(_T("invalid command")); | ||
| 1469 | return false; | ||
| 1470 | } | ||
| 1471 | |||
| 1472 | in.Read32(); //Session id | ||
| 1473 | in.Read32(); //Player id | ||
| 1474 | cmd->pktid = in.Read32(); //Packet count | ||
| 1475 | in.Read32(); //read unknown | ||
| 1476 | crc = in.Read32(); //CRC | ||
| 1477 | |||
| 1478 | //do nothing | ||
| 1479 | |||
| 1480 | //only for reducing warnings | ||
| 1481 | wxUnusedVar(ostrm); | ||
| 1482 | wxUnusedVar(crc); | ||
| 1483 | return true; | ||
| 1484 | } | ||
| 1485 | |||
| 1486 | //------------------------------------------------------------------------------ | ||
| 1487 | // TSCmdRecvUnknown | ||
| 1488 | bool TSCmdRecvUnknown::ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd) | ||
| 1489 | { | ||
| 1490 | wxMemoryBufferEx buf(1024); | ||
| 1491 | wxUint32 cnt = 0; | ||
| 1492 | |||
| 1493 | while(!istrm.Eof()) | ||
| 1494 | { | ||
| 1495 | cnt++; | ||
| 1496 | buf.AppendByte(istrm.GetC()); | ||
| 1497 | } | ||
| 1498 | buf.SetDataLen(cnt); | ||
| 1499 | wxMemoryInputStream tmp(buf.GetData(), buf.GetDataLen()); | ||
| 1500 | wxDataInputStreamEx in(tmp); | ||
| 1501 | |||
| 1502 | wxLogVerbose(_T("dumping unknown command...")); | ||
| 1503 | |||
| 1504 | wxLogVerbose(_T("Id: %#x"), in.Read32()); //read id | ||
| 1505 | wxLogVerbose(_T("SessionId: %#x"), in.Read32()); //Session id | ||
| 1506 | wxLogVerbose(_T("PlayerId: %#x"), in.Read32()); //Player id | ||
| 1507 | |||
| 1508 | cmd->pktid = in.Read32(); //Packet count | ||
| 1509 | wxLogVerbose(_T("PacketId: %#x"), cmd->pktid); | ||
| 1510 | |||
| 1511 | wxStringOutputStream so; | ||
| 1512 | buf.HexDump(so); | ||
| 1513 | wxLogVerbose(_T("Hex dump:\n%s"), so.GetString().c_str()); | ||
| 1514 | |||
| 1515 | //only for reducing warnings | ||
| 1516 | wxUnusedVar(ostrm); | ||
| 1517 | return true; | ||
| 1518 | } | ||
| 1519 | |||
