Skip to content

Commit f8f4567

Browse files
committed
Fixed CResourceStartPacket not being parsed correctly if a clientfile is empty
1 parent e17985e commit f8f4567

File tree

1 file changed

+40
-44
lines changed

1 file changed

+40
-44
lines changed

MTA10/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4883,62 +4883,58 @@ void CPacketHandler::Packet_ResourceStart ( NetBitStreamInterface& bitStream )
48834883
if ( uiTotalSizeProcessed / 1024 / 1024 > 50 )
48844884
g_pCore->UpdateDummyProgress( uiTotalSizeProcessed / 1024 / 1024, " MB" );
48854885

4886-
// Don't bother with empty files
4887-
if ( dChunkDataSize > 0 )
4886+
// Create the resource downloadable
4887+
CDownloadableResource* pDownloadableResource = NULL;
4888+
switch ( ucChunkSubType )
48884889
{
4889-
// Create the resource downloadable
4890-
CDownloadableResource* pDownloadableResource = NULL;
4891-
switch ( ucChunkSubType )
4892-
{
4893-
case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_FILE:
4894-
{
4895-
bool bDownload = bitStream.ReadBit ();
4896-
pDownloadableResource = pResource->QueueFile ( CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_FILE, szChunkData, chunkChecksum, bDownload );
4897-
4898-
break;
4899-
}
4900-
case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_SCRIPT:
4901-
pDownloadableResource = pResource->QueueFile ( CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_SCRIPT, szChunkData, chunkChecksum );
4890+
case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_FILE:
4891+
{
4892+
bool bDownload = bitStream.ReadBit ();
4893+
pDownloadableResource = pResource->QueueFile ( CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_FILE, szChunkData, chunkChecksum, bDownload );
49024894

49034895
break;
4904-
case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_CONFIG:
4905-
pDownloadableResource = pResource->AddConfigFile ( szChunkData, chunkChecksum );
4896+
}
4897+
case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_SCRIPT:
4898+
pDownloadableResource = pResource->QueueFile ( CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_SCRIPT, szChunkData, chunkChecksum );
49064899

4907-
break;
4908-
default:
4900+
break;
4901+
case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_CONFIG:
4902+
pDownloadableResource = pResource->AddConfigFile ( szChunkData, chunkChecksum );
49094903

4910-
break;
4904+
break;
4905+
default:
4906+
4907+
break;
4908+
}
4909+
4910+
// Does the Client and Server checksum differ?
4911+
if ( pDownloadableResource && !pDownloadableResource->DoesClientAndServerChecksumMatch () )
4912+
{
4913+
// Delete the file that already exists
4914+
FileDelete ( pDownloadableResource->GetName () );
4915+
if ( FileExists( pDownloadableResource->GetName () ) )
4916+
{
4917+
SString strMessage( "Unable to delete old file %s", *ConformResourcePath( pDownloadableResource->GetName () ) );
4918+
g_pClientGame->TellServerSomethingImportant( 1009, strMessage, false );
49114919
}
49124920

4913-
// Does the Client and Server checksum differ?
4914-
if ( pDownloadableResource && !pDownloadableResource->DoesClientAndServerChecksumMatch () )
4921+
// Is it downloadable now?
4922+
if ( pDownloadableResource->IsAutoDownload() )
49154923
{
4916-
// Delete the file that already exists
4917-
FileDelete ( pDownloadableResource->GetName () );
4918-
if ( FileExists( pDownloadableResource->GetName () ) )
4924+
// Make sure the directory exists
4925+
const char* szTempName = pDownloadableResource->GetName ();
4926+
if ( szTempName )
49194927
{
4920-
SString strMessage( "Unable to delete old file %s", *ConformResourcePath( pDownloadableResource->GetName () ) );
4921-
g_pClientGame->TellServerSomethingImportant( 1009, strMessage, false );
4928+
// Make sure its directory exists
4929+
MakeSureDirExists ( szTempName );
49224930
}
49234931

4924-
// Is it downloadable now?
4925-
if ( pDownloadableResource->IsAutoDownload() )
4926-
{
4927-
// Make sure the directory exists
4928-
const char* szTempName = pDownloadableResource->GetName ();
4929-
if ( szTempName )
4930-
{
4931-
// Make sure its directory exists
4932-
MakeSureDirExists ( szTempName );
4933-
}
4932+
// Combine the HTTP Download URL, the Resource Name and the Resource File
4933+
SString strHTTPDownloadURLFull ( "%s/%s/%s", g_pClientGame->m_strHTTPDownloadURL.c_str (), pResource->GetName (), pDownloadableResource->GetShortName () );
49344934

4935-
// Combine the HTTP Download URL, the Resource Name and the Resource File
4936-
SString strHTTPDownloadURLFull ( "%s/%s/%s", g_pClientGame->m_strHTTPDownloadURL.c_str (), pResource->GetName (), pDownloadableResource->GetShortName () );
4937-
4938-
// Queue the file to be downloaded
4939-
pResource->AddPendingFileDownload( strHTTPDownloadURLFull, pDownloadableResource->GetName (), dChunkDataSize );
4940-
}
4941-
}
4935+
// Queue the file to be downloaded
4936+
pResource->AddPendingFileDownload( strHTTPDownloadURLFull, pDownloadableResource->GetName (), dChunkDataSize );
4937+
}
49424938
}
49434939
}
49444940

0 commit comments

Comments
 (0)