Updated client netplay rom requests to only send extracted archive files as well.

This commit is contained in:
harry 2024-05-05 06:29:47 -04:00
parent 0ea2670ae0
commit c4dd4f5153
2 changed files with 13 additions and 13 deletions

View File

@ -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<const char*>(&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;
}

View File

@ -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)