From c4dd4f5153d9c1cd51065659cdf1cc39a6afb61e Mon Sep 17 00:00:00 2001 From: harry Date: Sun, 5 May 2024 06:29:47 -0400 Subject: [PATCH] Updated client netplay rom requests to only send extracted archive files as well. --- src/drivers/Qt/NetPlay.cpp | 24 ++++++++++++------------ src/drivers/Qt/fceuWrapper.cpp | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/drivers/Qt/NetPlay.cpp b/src/drivers/Qt/NetPlay.cpp index 83add75db..aed5148a6 100644 --- a/src/drivers/Qt/NetPlay.cpp +++ b/src/drivers/Qt/NetPlay.cpp @@ -1590,44 +1590,44 @@ void NetPlayClient::onSocketError(QAbstractSocket::SocketError error) emit errorOccurred(errorMsg); } //----------------------------------------------------------------------------- -int NetPlayClient::requestRomLoad( const char *romPath ) +int NetPlayClient::requestRomLoad( const char *romPathIn ) { constexpr size_t BufferSize = 32 * 1024; char buf[BufferSize]; size_t bytesRead; long fileSize = 0; + int userCancel = 0; + const int archiveIndex = -1; + std::string romPath(romPathIn); netPlayLoadRomReq msg; - QFileInfo fi( romPath ); + const char* romextensions[] = { "nes", "fds", "nsf", 0 }; - printf("Prep ROM Load Request: %s \n", romPath ); - FILE *fp = ::fopen( romPath, "rb"); + printf("Prep ROM Load Request: %s \n", romPath.c_str() ); + FCEUFILE* fp = FCEU_fopen( romPath.c_str(), nullptr, "rb", 0, archiveIndex, romextensions, &userCancel); if (fp == nullptr) { return -1; } - fseek( fp, 0, SEEK_END); - - fileSize = ftell(fp); - - rewind(fp); + QFileInfo fi( fp->filename.c_str() ); + fileSize = fp->size; msg.hdr.msgSize += fileSize; msg.fileSize = fileSize; Strlcpy( msg.fileName, fi.fileName().toLocal8Bit().constData(), sizeof(msg.fileName) ); - printf("Sending ROM Load Request: %s %lu\n", romPath, fileSize ); + printf("Sending ROM Load Request: %s %lu\n", msg.fileName, fileSize ); msg.toNetworkByteOrder(); sock->write( reinterpret_cast(&msg), sizeof(netPlayLoadRomReq) ); - while ( (bytesRead = fread( buf, 1, sizeof(buf), fp )) > 0 ) + while ( (bytesRead = FCEU_fread( buf, 1, sizeof(buf), fp )) > 0 ) { sock->write( buf, bytesRead ); } sock->flush(); - ::fclose(fp); + FCEU_fclose(fp); return 0; } diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 060b97e57..8d2412584 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -1852,7 +1852,7 @@ static FCEUFILE* libarchive_OpenArchive( ArchiveScanRecord& asr, std::string& fn filename = archive_entry_pathname(entry); fileSize = archive_entry_size(entry); - printf("ArchiveFile:%i %s\n", idx, filename); + //printf("ArchiveFile:%i %s\n", idx, filename); if ( (searchFile != nullptr) && !searchFile->empty()) { if (strcmp( filename, searchFile->c_str() ) == 0)