/* Search for flights within the fixes */ unsigned Times(std::vector<FlightTimeResult> &results) { DebugReplay *replay = Replay(); FlightTimes(*replay, results); delete replay; return results.size(); };
/* Analyse flight */ bool Analyse(const BrokenDateTime takeoff_time, const BrokenDateTime scoring_start_time, const BrokenDateTime scoring_end_time, const BrokenDateTime landing_time, ContestStatistics &olc_plus, ContestStatistics &dmst, PhaseList &phase_list, PhaseTotals &phase_totals, WindList &wind_list, const unsigned full = 512, const unsigned triangle = 1024, const unsigned sprint = 96, const unsigned max_iterations = 20e6, const unsigned max_tree_size = 5e6) { DebugReplay *replay = Replay(); if (replay == nullptr) return false; ComputerSettings computer_settings; computer_settings.SetDefaults(); AnalyseFlight(*replay, takeoff_time, scoring_start_time, scoring_end_time, landing_time, olc_plus, dmst, phase_list, phase_totals, wind_list, computer_settings, full, triangle, sprint, max_iterations, max_tree_size); delete replay; if (!qnh_available && computer_settings.pressure_available) { qnh = computer_settings.pressure; qnh_available = computer_settings.pressure_available; } return true; };
virtual void OnJoin(const CNick& cNick, CChan& cChannel) { if (cNick.GetNick().Equals(m_pUser->GetNick()) && cChannel.GetBuffer().empty()) { BootStrap((CChan *)&cChannel); if (!cChannel.GetBuffer().empty()) Replay(cChannel.GetName()); } AddBuffer(cChannel, SpoofChanMsg(cChannel.GetName(), cNick.GetNickMask() + " JOIN")); }
void Close() { _is_init = false; _replay = Replay(); Utilities::RestoreSettings(); if(_mcd_backup.size()) { Utilities::WriteMCD(0,0,_mcd_backup); _mcd_backup.clear(); } Utilities::ExecuteOnMainThread([&]() { UI_EnableEverything(); Console_SetActiveHandler(_console); }); }
void CaptureContext::SaveNotes() { QVariantMap root; for(const QString &key : m_Notes.keys()) root[key] = m_Notes[key]; QString json = VariantToJSON(root); SectionProperties props; props.type = SectionType::Notes; props.version = 1; ANALYTIC_SET(UIFeatures.CaptureComments, true); Replay().GetCaptureAccess()->WriteSection(props, json.toUtf8()); }
void CaptureContext::SaveRenames() { QVariantMap resources; for(ResourceId id : m_CustomNames.keys()) { resources[ToQStr(id)] = m_CustomNames[id]; } QVariantMap root; root[lit("CustomResourceNames")] = resources; QString json = VariantToJSON(root); SectionProperties props; props.type = SectionType::ResourceRenames; props.version = 1; Replay().GetCaptureAccess()->WriteSection(props, json.toUtf8()); }
/* Analyse flight */ void Analyse(const BrokenDateTime takeoff_time, const BrokenDateTime release_time, const BrokenDateTime landing_time, ContestStatistics &olc_plus, ContestStatistics &dmst, PhaseList &phase_list, PhaseTotals &phase_totals, WindList &wind_list, const unsigned full = 512, const unsigned triangle = 1024, const unsigned sprint = 96, const unsigned max_iterations = 20e6, const unsigned max_tree_size = 5e6) { DebugReplay *replay = Replay(); AnalyseFlight(*replay, takeoff_time, release_time, landing_time, olc_plus, dmst, phase_list, phase_totals, wind_list, full, triangle, sprint, max_iterations, max_tree_size); delete replay; };
virtual void OnModCommand(const CString& sCmdLine) { CString sCommand = sCmdLine.Token(0); CString sArgs = sCmdLine.Token(1, true); if (sCommand.Equals("setpass")) { PutModule("Password set to [" + sArgs + "]"); m_sPassword = CBlowfish::MD5(sArgs); } else if (sCommand.Equals("dumpbuff")) { CString sFile; if (DecryptChannel(sArgs, sFile)) { VCString vsLines; VCString::iterator it; sFile.Split("\n", vsLines); for (it = vsLines.begin(); it != vsLines.end(); ++it) { CString sLine(*it); sLine.Trim(); PutModule("[" + sLine + "]"); } } PutModule("//!-- EOF " + sArgs); } else if (sCommand.Equals("replay")) { Replay(sArgs); PutModule("Replayed " + sArgs); } else if (sCommand.Equals("save")) { SaveBufferToDisk(); PutModule("Done."); } else PutModule("Unknown command [" + sCommand + "]"); }
void CaptureContext::SaveBookmarks() { QVariantList bookmarks; for(const EventBookmark &mark : m_Bookmarks) { QVariantMap variantmark; variantmark[lit("eventId")] = mark.eventId; variantmark[lit("text")] = mark.text; bookmarks.push_back(variantmark); } QVariantMap root; root[lit("Bookmarks")] = bookmarks; QString json = VariantToJSON(root); SectionProperties props; props.type = SectionType::Bookmarks; props.version = 1; Replay().GetCaptureAccess()->WriteSection(props, json.toUtf8()); }
const char* eSpeccyHandler::OnLoop() { const char* error = NULL; if(FullSpeed() || !video_paused) { if(macro) { if(!macro->Update()) SAFE_DELETE(macro); } if(replay) { int icount = 0; inside_replay_update = true; eRZX::eError err = replay->Update(&icount); inside_replay_update = false; if(err == eRZX::E_OK) { speccy->Update(&icount); err = replay->CheckSync(); } if(err != eRZX::E_OK) { Replay(NULL); error = RZXErrorDesc(err); } } else speccy->Update(NULL); ++video_frame; } #ifdef USE_UI ui_desktop->Update(); #endif//USE_UI return error; }
bool CaptureContext::SaveCaptureTo(const rdcstr &captureFile) { bool success = false; QString error; if(IsCaptureLocal()) { if(QFileInfo(GetCaptureFilename()).exists()) { if(GetCaptureFilename() == captureFile) { success = true; } else { ICaptureFile *capFile = Replay().GetCaptureFile(); if(capFile) { // this will overwrite success = capFile->CopyFileTo(captureFile.c_str()); } else { // QFile::copy won't overwrite, so remove the destination first (the save dialog already // prompted for overwrite) QFile::remove(captureFile); success = QFile::copy(GetCaptureFilename(), captureFile); } error = tr("Couldn't save to %1").arg(captureFile); } } else { RDDialog::critical( NULL, tr("File not found"), error = tr("Capture '%1' couldn't be found on disk, cannot save.").arg(GetCaptureFilename())); success = false; } } else { Replay().CopyCaptureFromRemote(GetCaptureFilename(), captureFile, m_MainWindow); success = QFile::exists(captureFile); error = tr("File couldn't be transferred from remote host"); } if(!success) { RDDialog::critical(NULL, tr("Error Saving"), error); return false; } // if it was a temporary capture, remove the old instnace if(m_CaptureTemporary) QFile::remove(m_CaptureFile); // Update the filename, and mark that it's local and not temporary now. m_CaptureFile = captureFile; m_CaptureLocal = true; m_CaptureTemporary = false; Replay().ReopenCaptureFile(captureFile); SaveChanges(); return true; }
void CaptureContext::RecompressCapture() { QString destFilename = GetCaptureFilename(); QString tempFilename; ICaptureFile *cap = NULL; ICaptureFile *tempCap = NULL; bool inplace = false; if(IsCaptureTemporary() || !IsCaptureLocal()) { QMessageBox::StandardButton res = RDDialog::question(m_MainWindow, tr("Unsaved capture"), tr("To recompress a capture you must save it first. Save this capture?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); if(res == QMessageBox::Cancel || res == QMessageBox::No) return; destFilename = m_MainWindow->GetSavePath(); // if it's already local, we'll do the save as part of the recompression convert. If it's // remote, we need to copy it first, but we copy it to a temporary so we can do the conversion // to the target location if(IsCaptureLocal()) { tempFilename = GetCaptureFilename(); } else { tempFilename = TempCaptureFilename(lit("recompress")); Replay().CopyCaptureFromRemote(GetCaptureFilename(), tempFilename, m_MainWindow); if(!QFile::exists(tempFilename)) { RDDialog::critical(m_MainWindow, tr("Failed to save capture"), tr("Capture couldn't be saved from remote.")); return; } } } else { // if we're doing this inplace on an already saved capture, then we need to recompress to a // temporary and close/move it afterwards. inplace = true; destFilename = TempCaptureFilename(lit("recompress")); } if(IsCaptureLocal()) { // for local files we already have a handle. We'll reuse it, then re-open cap = Replay().GetCaptureFile(); } else { // for remote files we open a new short-lived handle on the temporary file tempCap = cap = RENDERDOC_OpenCaptureFile(); cap->OpenFile(tempFilename.toUtf8().data(), "rdc"); } if(!cap) { RDDialog::critical(m_MainWindow, tr("Unexpected missing handle"), tr("Couldn't get open handle to file for recompression.")); return; } int index = cap->FindSectionByType(SectionType::FrameCapture); SectionProperties props = cap->GetSectionProperties(index); if(props.flags & SectionFlags::ZstdCompressed) { RDDialog::information(m_MainWindow, tr("Capture already compressed"), tr("This capture is already compressed as much as is possible.")); if(tempCap) tempCap->Shutdown(); if(!tempFilename.isEmpty()) QFile::remove(tempFilename); return; } // convert from the currently open cap to the destination float progress = 0.0f; LambdaThread *th = new LambdaThread([this, cap, destFilename, &progress]() { cap->Convert(destFilename.toUtf8().data(), "rdc", [&progress](float p) { progress = p; }); }); th->start(); // wait a few ms before popping up a progress bar th->wait(500); if(th->isRunning()) { ShowProgressDialog(m_MainWindow, tr("Recompressing file."), [th]() { return !th->isRunning(); }, [&progress]() { return progress; }); } th->deleteLater(); if(inplace) { // if we're recompressing "in place", we need to close our capture, move the temporary over // the original, then re-open. // this releases the hold over the real desired location. cap->OpenFile("", ""); // now remove the old capture QFile::remove(GetCaptureFilename()); // move the recompressed one over QFile::rename(destFilename, GetCaptureFilename()); // and re-open cap->OpenFile(GetCaptureFilename().c_str(), "rdc"); } else { // we've converted into the desired location. We don't have to do anything else but mark our // new locally saved non-temporary status. m_CaptureFile = destFilename; m_CaptureLocal = true; m_CaptureTemporary = false; // open the saved capture file. This will let us remove the old file too Replay().ReopenCaptureFile(m_CaptureFile); m_CaptureMods = CaptureModifications::All; SaveChanges(); } // close any temporary resources if(tempCap) tempCap->Shutdown(); if(!tempFilename.isEmpty()) QFile::remove(tempFilename); }
void CaptureContext::LoadCaptureThreaded(const QString &captureFile, const QString &origFilename, bool temporary, bool local) { m_CaptureFile = origFilename; m_CaptureLocal = local; Config().Save(); m_LoadProgress = 0.0f; m_PostloadProgress = 0.0f; // this function call will block until the capture is either loaded, or there's some failure m_Renderer.OpenCapture(captureFile, [this](float p) { m_LoadProgress = p; }); // if the renderer isn't running, we hit a failure case so display an error message if(!m_Renderer.IsRunning()) { QString errmsg = ToQStr(m_Renderer.GetCreateStatus()); QString messageText = tr("%1\nFailed to open capture for replay: %2.\n\n" "Check diagnostic log in Help menu for more details.") .arg(captureFile) .arg(errmsg); RDDialog::critical(NULL, tr("Error opening capture"), messageText); m_LoadInProgress = false; return; } if(!temporary) { AddRecentFile(Config().RecentCaptureFiles, origFilename, 10); Config().Save(); } m_EventID = 0; m_FirstDrawcall = m_LastDrawcall = NULL; // fetch initial data like drawcalls, textures and buffers m_Renderer.BlockInvoke([this](IReplayController *r) { m_FrameInfo = r->GetFrameInfo(); m_APIProps = r->GetAPIProperties(); m_PostloadProgress = 0.2f; m_Drawcalls = r->GetDrawcalls(); AddFakeProfileMarkers(); m_FirstDrawcall = &m_Drawcalls[0]; while(!m_FirstDrawcall->children.empty()) m_FirstDrawcall = &m_FirstDrawcall->children[0]; m_LastDrawcall = &m_Drawcalls.back(); while(!m_LastDrawcall->children.empty()) m_LastDrawcall = &m_LastDrawcall->children.back(); m_PostloadProgress = 0.4f; m_WinSystems = r->GetSupportedWindowSystems(); #if defined(RENDERDOC_PLATFORM_WIN32) m_CurWinSystem = WindowingSystem::Win32; #elif defined(RENDERDOC_PLATFORM_LINUX) m_CurWinSystem = WindowingSystem::Xlib; // prefer XCB, if supported for(WindowingSystem sys : m_WinSystems) { if(sys == WindowingSystem::XCB) { m_CurWinSystem = WindowingSystem::XCB; break; } } if(m_CurWinSystem == WindowingSystem::XCB) m_XCBConnection = QX11Info::connection(); else m_X11Display = QX11Info::display(); #endif m_StructuredFile = &r->GetStructuredFile(); m_ResourceList = r->GetResources(); for(ResourceDescription &res : m_ResourceList) m_Resources[res.resourceId] = &res; m_BufferList = r->GetBuffers(); for(BufferDescription &b : m_BufferList) m_Buffers[b.resourceId] = &b; m_PostloadProgress = 0.8f; m_TextureList = r->GetTextures(); for(TextureDescription &t : m_TextureList) m_Textures[t.resourceId] = &t; m_PostloadProgress = 0.9f; m_CurD3D11PipelineState = &r->GetD3D11PipelineState(); m_CurD3D12PipelineState = &r->GetD3D12PipelineState(); m_CurGLPipelineState = &r->GetGLPipelineState(); m_CurVulkanPipelineState = &r->GetVulkanPipelineState(); m_CurPipelineState.SetStates(m_APIProps, m_CurD3D11PipelineState, m_CurD3D12PipelineState, m_CurGLPipelineState, m_CurVulkanPipelineState); m_UnreadMessageCount = 0; AddMessages(m_FrameInfo.debugMessages); m_PostloadProgress = 1.0f; }); QThread::msleep(20); QDateTime today = QDateTime::currentDateTimeUtc(); QDateTime compare = today.addDays(-21); if(compare > Config().DegradedCapture_LastUpdate && m_APIProps.degraded) { Config().DegradedCapture_LastUpdate = today; RDDialog::critical( NULL, tr("Degraded support of capture"), tr("%1\nThis capture opened with degraded support - " "this could mean missing hardware support caused a fallback to software rendering.\n\n" "This warning will not appear every time this happens, " "check debug errors/warnings window for more details.") .arg(origFilename)); } ICaptureAccess *access = Replay().GetCaptureAccess(); if(access) { int idx = access->FindSectionByType(SectionType::ResourceRenames); if(idx >= 0) { bytebuf buf = access->GetSectionContents(idx); LoadRenames(QString::fromUtf8((const char *)buf.data(), buf.count())); } idx = access->FindSectionByType(SectionType::Bookmarks); if(idx >= 0) { bytebuf buf = access->GetSectionContents(idx); LoadBookmarks(QString::fromUtf8((const char *)buf.data(), buf.count())); } idx = access->FindSectionByType(SectionType::Notes); if(idx >= 0) { bytebuf buf = access->GetSectionContents(idx); LoadNotes(QString::fromUtf8((const char *)buf.data(), buf.count())); } } m_LoadInProgress = false; m_CaptureLoaded = true; }