DebugInfo::DebugInfo() : Socket() { Connect("debug.rttr.info", 4123, false, (Socket::PROXY_TYPE)SETTINGS.proxy.typ, SETTINGS.proxy.proxy, SETTINGS.proxy.port); //-V807 Send("RTTRDBG", 7); // Protocol Version SendUnsigned(0x00000001); // OS #ifdef _WIN32 SendString("WIN"); // TODO: These should be based on uname(3) output. #elif defined __APPLE__ SendString("MAC"); #elif defined __FreeBSD__ SendString("BSD"); #else SendString("LNX"); #endif // Bits SendUnsigned(sizeof(void*) << 3); SendString(GetWindowVersion()); SendString(GetWindowRevision()); SendUnsigned(GAMECLIENT.GetGFNumber()); }
bool DebugInfo::SendString(const std::string& str) { if (!SendUnsigned(str.length())) { return(false); } return(Send(str.c_str(), str.length())); }
bool DebugInfo::SendString(const char* str, unsigned len) { if (len == 0) len = strlen(str) + 1; if (!SendUnsigned(len)) return(false); return(Send(str, len)); }
bool DebugInfo::SendAsyncLog(std::list<RandomEntry>::iterator first_a, std::list<RandomEntry>::iterator first_b, std::list<RandomEntry> &a, std::list<RandomEntry> &b, unsigned identical) { if (!SendString("AsyncLog")) { return(false); } // calculate size unsigned len = 4; unsigned cnt = 0; std::list<RandomEntry>::iterator it_a = first_a; std::list<RandomEntry>::iterator it_b = first_b; // if there were any identical lines, include only the last one if (identical) { len += 4 + 4 + 4 + it_a->src_name.length() + 1 + 4 + 4 + 4; ++cnt; ++it_a; ++it_b; } while ((it_a != a.end()) && (it_b != b.end())) { len += 4 + 4 + 4 + it_a->src_name.length() + 1 + 4 + 4 + 4; len += 4 + 4 + 4 + it_a->src_name.length() + 1 + 4 + 4 + 4; cnt += 2; ++it_a; ++it_b; } if (!SendUnsigned(len)) return(false); if (!SendUnsigned(identical)) return(false); if (!SendUnsigned(cnt)) return(false); it_a = first_a; it_b = first_b; // if there were any identical lines, include only the last one if (identical) { if (!SendUnsigned(it_a->counter)) return(false); if (!SendSigned(it_a->max)) return(false); if (!SendSigned(it_a->value)) return(false); if (!SendString(it_a->src_name)) return(false); if (!SendUnsigned(it_a->src_line)) return(false); if (!SendUnsigned(it_a->obj_id)) return(false); ++it_a; ++it_b; } while ((it_a != a.end()) && (it_b != b.end())) { if (!SendUnsigned(it_a->counter)) return(false); if (!SendSigned(it_a->max)) return(false); if (!SendSigned(it_a->value)) return(false); if (!SendString(it_a->src_name)) return(false); if (!SendUnsigned(it_a->src_line)) return(false); if (!SendUnsigned(it_a->obj_id)) return(false); if (!SendUnsigned(it_b->counter)) return(false); if (!SendSigned(it_b->max)) return(false); if (!SendSigned(it_b->value)) return(false); if (!SendString(it_b->src_name)) return(false); if (!SendUnsigned(it_b->src_line)) return(false); if (!SendUnsigned(it_b->obj_id)) return(false); ++it_a; ++it_b; } return(true); }
bool DebugInfo::SendReplay() { LOG.lprintf("Sending replay...\n"); // Replay mode is on, no recording of replays active if (!GAMECLIENT.IsReplayModeOn()) { Replay rpl = GAMECLIENT.GetReplay(); if(!rpl.IsValid()) return true; BinaryFile* f = rpl.GetFile(); if(!f) // no replay to send return true; f->Flush(); unsigned replay_len = f->Tell(); LOG.lprintf("- Replay length: %u\n", replay_len); boost::interprocess::unique_ptr<char, Deleter<char[]> > replay(new char[replay_len]); f->Seek(0, SEEK_SET); f->ReadRawData(replay.get(), replay_len); unsigned int compressed_len = replay_len * 2 + 600; boost::interprocess::unique_ptr<char, Deleter<char[]> > compressed(new char[compressed_len]); // send size of replay via socket if (!SendString("Replay")) { return false; } LOG.lprintf("- Compressing...\n"); if (BZ2_bzBuffToBuffCompress(compressed.get(), (unsigned int*) &compressed_len, replay.get(), replay_len, 9, 0, 250) == BZ_OK) { LOG.lprintf("- Sending...\n"); if (SendString(compressed.get(), compressed_len)) { LOG.lprintf("-> success\n"); return true; } LOG.lprintf("-> Sending replay failed :(\n"); } else { LOG.lprintf("-> BZ2 compression failed.\n"); } SendUnsigned(0); return false; } else { LOG.lprintf("-> Already in replay mode, do not send replay\n"); } return true; }
bool DebugInfo::SendAsyncLog(std::vector<RandomEntry>::const_iterator first_a, std::vector<RandomEntry>::const_iterator first_b, const std::vector<RandomEntry> &a, const std::vector<RandomEntry> &b, unsigned identical) { if (!SendString("AsyncLog")) { return(false); } // calculate size unsigned len = 4; unsigned cnt = 0; std::vector<RandomEntry>::const_iterator it_a = first_a; std::vector<RandomEntry>::const_iterator it_b = first_b; // if there were any identical lines, include only the last one if (identical) { // sizes of: counter, max, rngState // string = length Bytes + 1 NULL terminator + 4B length // srcLine, objId len += 4 + 4 + 4 + it_a->src_name.length() + 1 + 4 + 4 + 4; ++cnt; ++it_a; ++it_b; } while ((it_a != a.end()) && (it_b != b.end())) { len += 4 + 4 + 4 + it_a->src_name.length() + 1 + 4 + 4 + 4; len += 4 + 4 + 4 + it_b->src_name.length() + 1 + 4 + 4 + 4; cnt += 2; ++it_a; ++it_b; } if (!SendUnsigned(len)) return(false); if (!SendUnsigned(identical)) return(false); if (!SendUnsigned(cnt)) return(false); it_a = first_a; it_b = first_b; // if there were any identical lines, send only one each for(unsigned i = 0; i< identical; i++) { if (!SendUnsigned(it_a->counter)) return(false); if (!SendSigned(it_a->max)) return(false); if (!SendSigned(it_a->rngState)) return(false); if (!SendString(it_a->src_name)) return(false); if (!SendUnsigned(it_a->src_line)) return(false); if (!SendUnsigned(it_a->obj_id)) return(false); ++it_a; ++it_b; } while ((it_a != a.end()) && (it_b != b.end())) { if (!SendUnsigned(it_a->counter)) return(false); if (!SendSigned(it_a->max)) return(false); if (!SendSigned(it_a->rngState)) return(false); if (!SendString(it_a->src_name)) return(false); if (!SendUnsigned(it_a->src_line)) return(false); if (!SendUnsigned(it_a->obj_id)) return(false); if (!SendUnsigned(it_b->counter)) return(false); if (!SendSigned(it_b->max)) return(false); if (!SendSigned(it_b->rngState)) return(false); if (!SendString(it_b->src_name)) return(false); if (!SendUnsigned(it_b->src_line)) return(false); if (!SendUnsigned(it_b->obj_id)) return(false); ++it_a; ++it_b; } return(true); }