@@ -4999,6 +4999,8 @@ void CPacketHandler::Packet_ResourceStart(NetBitStreamInterface& bitStream)
4999
4999
return ;
5000
5000
}
5001
5001
5002
+ bool bFatalError = false ;
5003
+
5002
5004
CResource* pResource = g_pClientGame->m_pResourceManager ->Add (usResourceID, szResourceName, pResourceEntity, pResourceDynamicEntity, strMinServerReq,
5003
5005
strMinClientReq, bEnableOOP);
5004
5006
if (pResource)
@@ -5047,61 +5049,80 @@ void CPacketHandler::Packet_ResourceStart(NetBitStreamInterface& bitStream)
5047
5049
}
5048
5050
szChunkData[ucChunkSize] = NULL ;
5049
5051
5050
- bitStream.Read (ucChunkSubType);
5051
- bitStream.Read (chunkChecksum.ulCRC );
5052
- bitStream.Read ((char *)chunkChecksum.md5 .data , sizeof (chunkChecksum.md5 .data ));
5053
- bitStream.Read (dChunkDataSize);
5054
-
5055
- uint uiDownloadSize = (uint)dChunkDataSize;
5056
- uiTotalSizeProcessed += uiDownloadSize;
5057
- if (uiTotalSizeProcessed / 1024 / 1024 > 50 )
5058
- g_pCore->UpdateDummyProgress (uiTotalSizeProcessed / 1024 / 1024 , " MB" );
5059
-
5060
- // Create the resource downloadable
5061
- CDownloadableResource* pDownloadableResource = NULL ;
5062
- switch (ucChunkSubType)
5052
+ std::string strChunkData = szChunkData;
5053
+ // make the full file path (c:/path/to/mods/deathmatch/resources/resource/)
5054
+ std::string strMetaPathTemp;
5055
+ std::string strResPathTemp = pResource->GetResourceDirectoryPath (ACCESS_PUBLIC, strMetaPathTemp);
5056
+ std::filesystem::path fsResPath = std::filesystem::path (strResPathTemp).lexically_normal ();
5057
+ std::string strResPath = fsResPath.string ();
5058
+ // make the full file path (c:/path/to/mods/deathmatch/resources/resource/file.lua)
5059
+ std::string strResFilePathTemp = strResPath + static_cast <char >(std::filesystem::path::preferred_separator) + strChunkData;
5060
+ std::filesystem::path fsResFilePath = std::filesystem::path (strResFilePathTemp).lexically_normal ();
5061
+ std::string strResFilePath = fsResFilePath.string ();
5062
+ // check that full file path contains full resource path
5063
+ if (strResFilePath.rfind (strResPath.c_str (), 0 ) != 0 )
5064
+ {
5065
+ bFatalError = true ;
5066
+ AddReportLog (2081 , SString (" Path %s (expected %s)" , strResFilePath.c_str (), strResPath.c_str ()));
5067
+ }
5068
+ else
5063
5069
{
5064
- case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_FILE:
5070
+ bitStream.Read (ucChunkSubType);
5071
+ bitStream.Read (chunkChecksum.ulCRC );
5072
+ bitStream.Read ((char *)chunkChecksum.md5 .data , sizeof (chunkChecksum.md5 .data ));
5073
+ bitStream.Read (dChunkDataSize);
5074
+
5075
+ uint uiDownloadSize = (uint)dChunkDataSize;
5076
+ uiTotalSizeProcessed += uiDownloadSize;
5077
+ if (uiTotalSizeProcessed / 1024 / 1024 > 50 )
5078
+ g_pCore->UpdateDummyProgress (uiTotalSizeProcessed / 1024 / 1024 , " MB" );
5079
+
5080
+ // Create the resource downloadable
5081
+ CDownloadableResource* pDownloadableResource = NULL ;
5082
+ switch (ucChunkSubType)
5065
5083
{
5066
- bool bDownload = bitStream.ReadBit ();
5067
- pDownloadableResource = pResource->AddResourceFile (CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_FILE, szChunkData,
5068
- uiDownloadSize, chunkChecksum, bDownload);
5069
-
5070
- break ;
5071
- }
5072
- case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_SCRIPT:
5073
- pDownloadableResource = pResource->AddResourceFile (CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_SCRIPT, szChunkData,
5074
- uiDownloadSize, chunkChecksum, true );
5084
+ case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_FILE:
5085
+ {
5086
+ bool bDownload = bitStream.ReadBit ();
5087
+ pDownloadableResource = pResource->AddResourceFile (CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_FILE, szChunkData,
5088
+ uiDownloadSize, chunkChecksum, bDownload);
5075
5089
5076
- break ;
5077
- case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_CONFIG:
5078
- pDownloadableResource = pResource->AddConfigFile (szChunkData, uiDownloadSize, chunkChecksum);
5090
+ break ;
5091
+ }
5092
+ case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_SCRIPT:
5093
+ pDownloadableResource = pResource->AddResourceFile (CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_SCRIPT, szChunkData,
5094
+ uiDownloadSize, chunkChecksum, true );
5079
5095
5080
- break ;
5081
- default :
5096
+ break ;
5097
+ case CDownloadableResource::RESOURCE_FILE_TYPE_CLIENT_CONFIG:
5098
+ pDownloadableResource = pResource->AddConfigFile (szChunkData, uiDownloadSize, chunkChecksum);
5082
5099
5083
- break ;
5084
- }
5100
+ break ;
5101
+ default :
5085
5102
5086
- // Does the Client and Server checksum differ?
5087
- if (pDownloadableResource && !pDownloadableResource->DoesClientAndServerChecksumMatch ())
5088
- {
5089
- // Delete the file that already exists
5090
- FileDelete (pDownloadableResource->GetName ());
5091
- if (FileExists (pDownloadableResource->GetName ()))
5092
- {
5093
- SString strMessage (" Unable to delete old file %s" , *ConformResourcePath (pDownloadableResource->GetName ()));
5094
- g_pClientGame->TellServerSomethingImportant (1009 , strMessage);
5103
+ break ;
5095
5104
}
5096
5105
5097
- // Is it downloadable now ?
5098
- if (pDownloadableResource-> IsAutoDownload ())
5106
+ // Does the Client and Server checksum differ ?
5107
+ if (pDownloadableResource && !pDownloadableResource-> DoesClientAndServerChecksumMatch ())
5099
5108
{
5100
- // Make sure the directory exists
5101
- MakeSureDirExists (pDownloadableResource->GetName ());
5109
+ // Delete the file that already exists
5110
+ FileDelete (pDownloadableResource->GetName ());
5111
+ if (FileExists (pDownloadableResource->GetName ()))
5112
+ {
5113
+ SString strMessage (" Unable to delete old file %s" , *ConformResourcePath (pDownloadableResource->GetName ()));
5114
+ g_pClientGame->TellServerSomethingImportant (1009 , strMessage);
5115
+ }
5102
5116
5103
- // Queue the file to be downloaded
5104
- g_pClientGame->GetResourceFileDownloadManager ()->AddPendingFileDownload (pDownloadableResource);
5117
+ // Is it downloadable now?
5118
+ if (pDownloadableResource->IsAutoDownload ())
5119
+ {
5120
+ // Make sure the directory exists
5121
+ MakeSureDirExists (pDownloadableResource->GetName ());
5122
+
5123
+ // Queue the file to be downloaded
5124
+ g_pClientGame->GetResourceFileDownloadManager ()->AddPendingFileDownload (pDownloadableResource);
5125
+ }
5105
5126
}
5106
5127
}
5107
5128
}
@@ -5116,17 +5137,25 @@ void CPacketHandler::Packet_ResourceStart(NetBitStreamInterface& bitStream)
5116
5137
delete[] szChunkData;
5117
5138
szChunkData = NULL ;
5118
5139
}
5119
- }
5120
5140
5121
- g_pClientGame->GetResourceFileDownloadManager ()->UpdatePendingDownloads ();
5141
+ if (bFatalError)
5142
+ {
5143
+ break ;
5144
+ }
5145
+ }
5122
5146
5123
- // Are there any resources to being downloaded?
5124
- if (!g_pClientGame->GetResourceFileDownloadManager ()->IsTransferringInitialFiles ())
5147
+ if (!bFatalError)
5125
5148
{
5126
- // Load the resource now
5127
- if (pResource->CanBeLoaded ())
5149
+ g_pClientGame->GetResourceFileDownloadManager ()->UpdatePendingDownloads ();
5150
+
5151
+ // Are there any resources to being downloaded?
5152
+ if (!g_pClientGame->GetResourceFileDownloadManager ()->IsTransferringInitialFiles ())
5128
5153
{
5129
- pResource->Load ();
5154
+ // Load the resource now
5155
+ if (pResource->CanBeLoaded ())
5156
+ {
5157
+ pResource->Load ();
5158
+ }
5130
5159
}
5131
5160
}
5132
5161
}
@@ -5136,6 +5165,11 @@ void CPacketHandler::Packet_ResourceStart(NetBitStreamInterface& bitStream)
5136
5165
5137
5166
g_pCore->UpdateDummyProgress (0 );
5138
5167
totalSizeProcessedResetTimer.Reset ();
5168
+
5169
+ if (bFatalError)
5170
+ {
5171
+ RaiseFatalError (2081 );
5172
+ }
5139
5173
}
5140
5174
5141
5175
void CPacketHandler::Packet_ResourceStop (NetBitStreamInterface& bitStream)
0 commit comments