/////////////////////////////////////////////////////////////////////
| 1407 | |
| 1408 | ////////////////////////////////////////////////////////////////////////// |
| 1409 | bool CXGame::Load(string sFileName) |
| 1410 | { |
| 1411 | m_pSystem->VTuneResume(); |
| 1412 | |
| 1413 | assert(g_playerprofile); |
| 1414 | |
| 1415 | string tmp( g_playerprofile->GetString() ); |
| 1416 | SaveName(sFileName, tmp); |
| 1417 | |
| 1418 | CDefaultStreamAllocator sa; |
| 1419 | CStream stm(300, &sa); |
| 1420 | |
| 1421 | int bitslen=m_pSystem->GetCompressedFileSize((char *)sFileName.c_str()); |
| 1422 | if(bitslen==0) |
| 1423 | { |
| 1424 | return false; |
| 1425 | } |
| 1426 | |
| 1427 | IInput *pInput=GetSystem()->GetIInput(); |
| 1428 | if(pInput) |
| 1429 | pInput->SetMouseExclusive(false); |
| 1430 | |
| 1431 | stm.Resize(bitslen); |
| 1432 | int bitsread = m_pSystem->ReadCompressedFile((char *)sFileName.c_str(), stm.GetPtr(), stm.GetAllocatedSize()); |
| 1433 | if(!bitsread) |
| 1434 | { |
| 1435 | m_pLog->Log("No such savegame: %s", sFileName.c_str()); |
| 1436 | if(pInput) |
| 1437 | pInput->SetMouseExclusive(true); |
| 1438 | |
| 1439 | return false; |
| 1440 | }; |
| 1441 | |
| 1442 | stm.SetSize(bitsread); |
| 1443 | |
| 1444 | if (m_pUISystem) |
| 1445 | { |
| 1446 | m_pUISystem->StopAllVideo(); |
| 1447 | } |
| 1448 | |
| 1449 | ////////////////////////////////////////////////////////////////////////// |
| 1450 | // Lock resources before loading checkpoint. |
| 1451 | // Speed ups loading a lot. |
| 1452 | m_pSystem->GetI3DEngine()->LockCGFResources(); |
| 1453 | m_pSystem->GetIAnimationSystem()->LockResources(); |
| 1454 | m_pSystem->GetISoundSystem()->LockResources(); |
| 1455 | ////////////////////////////////////////////////////////////////////////// |
| 1456 | |
| 1457 | bool ok = LoadFromStream(stm, false); |
| 1458 | |
| 1459 | ////////////////////////////////////////////////////////////////////////// |
| 1460 | // Unlock resources after loading checkpoint. |
| 1461 | // Some uneeded resources that were locked before may get released here. |
| 1462 | m_pSystem->GetISoundSystem()->UnlockResources(); |
| 1463 | m_pSystem->GetIAnimationSystem()->UnlockResources(); |
| 1464 | m_pSystem->GetI3DEngine()->UnlockCGFResources(); |
| 1465 | ////////////////////////////////////////////////////////////////////////// |
| 1466 |
no test coverage detected