| 3927 | } |
| 3928 | |
| 3929 | const char *CClient::DemoPlayer_Play(const char *pFilename, int StorageType) |
| 3930 | { |
| 3931 | // Don't disconnect unless the file exists (only for play command) |
| 3932 | if(!Storage()->FileExists(pFilename, StorageType)) |
| 3933 | return Localize("No demo with this filename exists"); |
| 3934 | |
| 3935 | Disconnect(); |
| 3936 | m_aNetClient[CONN_MAIN].ResetErrorString(); |
| 3937 | |
| 3938 | SetState(IClient::STATE_LOADING); |
| 3939 | SetLoadingStateDetail(IClient::LOADING_STATE_DETAIL_LOADING_DEMO); |
| 3940 | if((bool)m_LoadingCallback) |
| 3941 | m_LoadingCallback(IClient::LOADING_CALLBACK_DETAIL_DEMO); |
| 3942 | |
| 3943 | // try to start playback |
| 3944 | m_DemoPlayer.SetListener(this); |
| 3945 | if(m_DemoPlayer.Load(Storage(), m_pConsole, pFilename, StorageType)) |
| 3946 | { |
| 3947 | DisconnectWithReason(m_DemoPlayer.ErrorMessage()); |
| 3948 | return m_DemoPlayer.ErrorMessage(); |
| 3949 | } |
| 3950 | |
| 3951 | m_Sixup = m_DemoPlayer.IsSixup(); |
| 3952 | |
| 3953 | // load map |
| 3954 | const CMapInfo *pMapInfo = m_DemoPlayer.GetMapInfo(); |
| 3955 | const char *pError = LoadMapSearch(pMapInfo->m_aName, pMapInfo->m_Sha256, pMapInfo->m_Crc); |
| 3956 | if(pError) |
| 3957 | { |
| 3958 | if(!m_DemoPlayer.ExtractMap(Storage())) |
| 3959 | { |
| 3960 | DisconnectWithReason(pError); |
| 3961 | return pError; |
| 3962 | } |
| 3963 | |
| 3964 | pError = LoadMapSearch(pMapInfo->m_aName, pMapInfo->m_Sha256, pMapInfo->m_Crc); |
| 3965 | if(pError) |
| 3966 | { |
| 3967 | DisconnectWithReason(pError); |
| 3968 | return pError; |
| 3969 | } |
| 3970 | } |
| 3971 | |
| 3972 | // setup current server info |
| 3973 | mem_zero(&m_CurrentServerInfo, sizeof(m_CurrentServerInfo)); |
| 3974 | str_copy(m_CurrentServerInfo.m_aMap, pMapInfo->m_aName); |
| 3975 | m_CurrentServerInfo.m_MapCrc = pMapInfo->m_Crc; |
| 3976 | m_CurrentServerInfo.m_MapSize = pMapInfo->m_Size; |
| 3977 | |
| 3978 | // enter demo playback state |
| 3979 | SetState(IClient::STATE_DEMOPLAYBACK); |
| 3980 | |
| 3981 | GameClient()->OnConnected(); |
| 3982 | |
| 3983 | // setup buffers |
| 3984 | mem_zero(m_aaaDemorecSnapshotData, sizeof(m_aaaDemorecSnapshotData)); |
| 3985 | |
| 3986 | for(int SnapshotType = 0; SnapshotType < NUM_SNAPSHOT_TYPES; SnapshotType++) |
no test coverage detected