@@ -142,6 +142,7 @@ void CClientResManager::OnMessage(int MsgType, void *pRawMsg)
142142 Resource.m_Sample = ISound::CSampleHandle ();
143143 Resource.m_Texture = IGraphics::CTextureHandle ();
144144 Resource.m_Type = pMsg->m_Type ;
145+ Resource.m_ChunkPerRequest = pMsg->m_ChunkPerRequest ;
145146 mem_copy (&Resource.m_Sha256 , pMsg->m_Sha256 , sizeof (SHA256_DIGEST));
146147 FormatResourcePath (Resource.m_aPath , sizeof (Resource.m_aPath ), Resource.m_aName , false , &Resource.m_Sha256 , &Resource.m_Crc );
147148 FormatResourcePath (Resource.m_aTempPath , sizeof (Resource.m_aTempPath ), Resource.m_aName , true , &Resource.m_Sha256 , &Resource.m_Crc );
@@ -191,11 +192,34 @@ void CClientResManager::OnMessage(int MsgType, void *pRawMsg)
191192 return ; // invalid!
192193 }
193194 }
194- else
195+ else if ((pMsg-> m_ChunkIndex + 1 ) % Resource. m_ChunkPerRequest == 0 )
195196 RequestDownload (&TargetResource);
196197 }
197198}
198199
200+ void CClientResManager::OnStateChange (int NewState, int OldState)
201+ {
202+ if (NewState == IClient::STATE_OFFLINE)
203+ {
204+ if (OldState >= IClient::STATE_CONNECTING && NewState <= IClient::STATE_ONLINE)
205+ {
206+ for (int i = 0 ; i < m_lResources.size (); i++)
207+ {
208+ if (m_lResources[i].m_Sample .IsValid ())
209+ m_pClient->m_pSounds ->UnloadSample (&m_lResources[i].m_Sample );
210+ if (m_lResources[i].m_Texture .IsValid ())
211+ Graphics ()->UnloadTexture (&m_lResources[i].m_Texture );
212+ if (m_lResources[i].m_DownloadTemp )
213+ {
214+ io_close (m_lResources[i].m_DownloadTemp );
215+ Storage ()->RemoveFile (m_lResources[i].m_aTempPath , IStorage::TYPE_SAVE);
216+ }
217+ }
218+ m_lResources.clear ();
219+ }
220+ }
221+ }
222+
199223bool CClientResManager::IsResourceSound (Uuid ResID)
200224{
201225 CClientResource Res;
0 commit comments