Enable dragging demo file into client to play it directly

This commit is contained in:
def 2019-04-08 21:42:49 +02:00
parent a4e2130342
commit cca80da554
2 changed files with 19 additions and 3 deletions

View file

@ -2859,6 +2859,13 @@ void CClient::Run()
m_aCmdConnect[0] = 0;
}
// handle pending demo play
if(m_aCmdPlayDemo[0])
{
DemoPlayer_Play(m_aCmdPlayDemo, IStorage::TYPE_ABSOLUTE);
m_aCmdPlayDemo[0] = 0;
}
// progress on dummy connect if security token handshake skipped/passed
if(m_DummySendConnInfo && !m_NetClient[1].SecurityTokenUnknown())
{
@ -3622,9 +3629,14 @@ static CClient *CreateClient()
return new(pClient) CClient;
}
void CClient::HandleConnectLink(const char *pArg)
void CClient::HandleConnectLink(const char *pLink)
{
str_copy(m_aCmdConnect, pArg + sizeof(CONNECTLINK) - 1, sizeof(m_aCmdConnect));
str_copy(m_aCmdConnect, pLink + sizeof(CONNECTLINK) - 1, sizeof(m_aCmdConnect));
}
void CClient::HandleDemoLink(const char *pLink)
{
str_copy(m_aCmdPlayDemo, pLink, sizeof(m_aCmdPlayDemo));
}
/*
@ -3775,7 +3787,9 @@ int main(int argc, const char **argv) // ignore_convention
// parse the command line arguments
if(argc == 2 && str_startswith(argv[1], CONNECTLINK))
pClient->HandleConnectLink(argv[1]);
else if(argc > 1) // ignore_convention
if(argc == 2 && str_endswith(argv[1], ".demo"))
pClient->HandleDemoLink(argv[1]);
if(argc > 1) // ignore_convention
pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention
pClient->Engine()->InitLogfile();

View file

@ -132,6 +132,7 @@ class CClient : public IClient, public CDemoPlayer::IListener
//
char m_aCmdConnect[256];
char m_aCmdPlayDemo[MAX_PATH_LENGTH];
// map download
std::shared_ptr<CGetFile> m_pMapdownloadTask;
@ -385,6 +386,7 @@ public:
void ServerBrowserUpdate();
void HandleConnectLink(const char *pLink);
void HandleDemoLink(const char *pLink);
// gfx
void SwitchWindowScreen(int Index);