Skip to content

Commit c4dd4f5

Browse files
committed
Updated client netplay rom requests to only send extracted archive files as well.
1 parent 0ea2670 commit c4dd4f5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/drivers/Qt/NetPlay.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,44 +1590,44 @@ void NetPlayClient::onSocketError(QAbstractSocket::SocketError error)
15901590
emit errorOccurred(errorMsg);
15911591
}
15921592
//-----------------------------------------------------------------------------
1593-
int NetPlayClient::requestRomLoad( const char *romPath )
1593+
int NetPlayClient::requestRomLoad( const char *romPathIn )
15941594
{
15951595
constexpr size_t BufferSize = 32 * 1024;
15961596
char buf[BufferSize];
15971597
size_t bytesRead;
15981598
long fileSize = 0;
1599+
int userCancel = 0;
1600+
const int archiveIndex = -1;
1601+
std::string romPath(romPathIn);
15991602
netPlayLoadRomReq msg;
1600-
QFileInfo fi( romPath );
1603+
const char* romextensions[] = { "nes", "fds", "nsf", 0 };
16011604

1602-
printf("Prep ROM Load Request: %s \n", romPath );
1603-
FILE *fp = ::fopen( romPath, "rb");
1605+
printf("Prep ROM Load Request: %s \n", romPath.c_str() );
1606+
FCEUFILE* fp = FCEU_fopen( romPath.c_str(), nullptr, "rb", 0, archiveIndex, romextensions, &userCancel);
16041607

16051608
if (fp == nullptr)
16061609
{
16071610
return -1;
16081611
}
1609-
fseek( fp, 0, SEEK_END);
1610-
1611-
fileSize = ftell(fp);
1612-
1613-
rewind(fp);
1612+
QFileInfo fi( fp->filename.c_str() );
1613+
fileSize = fp->size;
16141614

16151615
msg.hdr.msgSize += fileSize;
16161616
msg.fileSize = fileSize;
16171617
Strlcpy( msg.fileName, fi.fileName().toLocal8Bit().constData(), sizeof(msg.fileName) );
16181618

1619-
printf("Sending ROM Load Request: %s %lu\n", romPath, fileSize );
1619+
printf("Sending ROM Load Request: %s %lu\n", msg.fileName, fileSize );
16201620

16211621
msg.toNetworkByteOrder();
16221622
sock->write( reinterpret_cast<const char*>(&msg), sizeof(netPlayLoadRomReq) );
16231623

1624-
while ( (bytesRead = fread( buf, 1, sizeof(buf), fp )) > 0 )
1624+
while ( (bytesRead = FCEU_fread( buf, 1, sizeof(buf), fp )) > 0 )
16251625
{
16261626
sock->write( buf, bytesRead );
16271627
}
16281628
sock->flush();
16291629

1630-
::fclose(fp);
1630+
FCEU_fclose(fp);
16311631

16321632
return 0;
16331633
}

src/drivers/Qt/fceuWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ static FCEUFILE* libarchive_OpenArchive( ArchiveScanRecord& asr, std::string& fn
18521852
filename = archive_entry_pathname(entry);
18531853
fileSize = archive_entry_size(entry);
18541854

1855-
printf("ArchiveFile:%i %s\n", idx, filename);
1855+
//printf("ArchiveFile:%i %s\n", idx, filename);
18561856
if ( (searchFile != nullptr) && !searchFile->empty())
18571857
{
18581858
if (strcmp( filename, searchFile->c_str() ) == 0)

0 commit comments

Comments
 (0)