Skip to content

Commit

Permalink
Updated client netplay rom requests to only send extracted archive fi…
Browse files Browse the repository at this point in the history
…les as well.
  • Loading branch information
thor2016 committed May 5, 2024
1 parent 0ea2670 commit c4dd4f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/drivers/Qt/NetPlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/Qt/fceuWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c4dd4f5

Please sign in to comment.