Updated client netplay rom requests to only send extracted archive files as well.
This commit is contained in:
parent
0ea2670ae0
commit
c4dd4f5153
|
@ -1590,44 +1590,44 @@ void NetPlayClient::onSocketError(QAbstractSocket::SocketError error)
|
||||||
emit errorOccurred(errorMsg);
|
emit errorOccurred(errorMsg);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int NetPlayClient::requestRomLoad( const char *romPath )
|
int NetPlayClient::requestRomLoad( const char *romPathIn )
|
||||||
{
|
{
|
||||||
constexpr size_t BufferSize = 32 * 1024;
|
constexpr size_t BufferSize = 32 * 1024;
|
||||||
char buf[BufferSize];
|
char buf[BufferSize];
|
||||||
size_t bytesRead;
|
size_t bytesRead;
|
||||||
long fileSize = 0;
|
long fileSize = 0;
|
||||||
|
int userCancel = 0;
|
||||||
|
const int archiveIndex = -1;
|
||||||
|
std::string romPath(romPathIn);
|
||||||
netPlayLoadRomReq msg;
|
netPlayLoadRomReq msg;
|
||||||
QFileInfo fi( romPath );
|
const char* romextensions[] = { "nes", "fds", "nsf", 0 };
|
||||||
|
|
||||||
printf("Prep ROM Load Request: %s \n", romPath );
|
printf("Prep ROM Load Request: %s \n", romPath.c_str() );
|
||||||
FILE *fp = ::fopen( romPath, "rb");
|
FCEUFILE* fp = FCEU_fopen( romPath.c_str(), nullptr, "rb", 0, archiveIndex, romextensions, &userCancel);
|
||||||
|
|
||||||
if (fp == nullptr)
|
if (fp == nullptr)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fseek( fp, 0, SEEK_END);
|
QFileInfo fi( fp->filename.c_str() );
|
||||||
|
fileSize = fp->size;
|
||||||
fileSize = ftell(fp);
|
|
||||||
|
|
||||||
rewind(fp);
|
|
||||||
|
|
||||||
msg.hdr.msgSize += fileSize;
|
msg.hdr.msgSize += fileSize;
|
||||||
msg.fileSize = fileSize;
|
msg.fileSize = fileSize;
|
||||||
Strlcpy( msg.fileName, fi.fileName().toLocal8Bit().constData(), sizeof(msg.fileName) );
|
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();
|
msg.toNetworkByteOrder();
|
||||||
sock->write( reinterpret_cast<const char*>(&msg), sizeof(netPlayLoadRomReq) );
|
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->write( buf, bytesRead );
|
||||||
}
|
}
|
||||||
sock->flush();
|
sock->flush();
|
||||||
|
|
||||||
::fclose(fp);
|
FCEU_fclose(fp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1852,7 +1852,7 @@ static FCEUFILE* libarchive_OpenArchive( ArchiveScanRecord& asr, std::string& fn
|
||||||
filename = archive_entry_pathname(entry);
|
filename = archive_entry_pathname(entry);
|
||||||
fileSize = archive_entry_size(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 ( (searchFile != nullptr) && !searchFile->empty())
|
||||||
{
|
{
|
||||||
if (strcmp( filename, searchFile->c_str() ) == 0)
|
if (strcmp( filename, searchFile->c_str() ) == 0)
|
||||||
|
|
Loading…
Reference in New Issue