From 03d3fb0c715574b7135b9c965f836330b07b8888 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 10 Dec 2017 19:04:09 +0100 Subject: [PATCH] cleaned up last commit --- src/engine/client/client.cpp | 43 ++++++++++++++++++------------------ src/engine/client/client.h | 3 ++- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 60a4d0919..775d07391 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -239,8 +239,7 @@ void CSmoothTime::Update(CGraph *pGraph, int64 Target, int TimeLeft, int AdjustD UpdateInt(Target); } - -CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta), m_DemoRecorder(&m_SnapshotDelta) +CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta), m_DemoRecorder(&m_SnapshotDelta), m_pConLinkIdentifier("teeworlds:") { m_pEditor = 0; m_pInput = 0; @@ -2325,22 +2324,9 @@ static CClient *CreateClient() return new(pClient) CClient; } -static bool IsTeeworldsConnectLink(const char *str) +void CClient::HandleTeeworldsConnectLink(const char *pConLink) { - const char *starter = "teeworlds:"; - - while(*str && *starter && *str == *starter) - { - str++; - starter++; - } - - return *starter == '\0'; -} - -void CClient::HandleTeeworldsConnectLink(const char *clink) -{ - str_copy(m_aCmdConnect, clink + sizeof("teeworlds:") - 1, sizeof(m_aCmdConnect)); + str_copy(m_aCmdConnect, pConLink, sizeof(m_aCmdConnect)); } /* @@ -2447,10 +2433,25 @@ int main(int argc, const char **argv) // ignore_convention pConsole->ExecuteFile("autoexec.cfg"); // parse the command line arguments - if(argc == 2 && IsTeeworldsConnectLink(argv[1])) - pClient->HandleTeeworldsConnectLink(argv[1]); - else if(argc > 1) // ignore_convention - pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention + if(argc > 1) // ignore_convention + { + switch(argc) // ignore_convention + { + case 2: + { + // handle Teeworlds connect link + const int Length = str_length(pClient->m_pConLinkIdentifier); + if(str_comp_num(pClient->m_pConLinkIdentifier, argv[1], Length) == 0) // ignore_convention + { + pClient->HandleTeeworldsConnectLink(argv[1] + Length); // ignore_convention + break; + } + } + default: + pConsole->ParseArguments(argc - 1, &argv[1]); // ignore_convention + } + + } } // restore empty config strings to their defaults diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 5e21422eb..f0247a5e9 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -317,6 +317,7 @@ public: void ToggleWindowVSync(); // Teeworlds connect link - void HandleTeeworldsConnectLink(const char *clink); + const char * const m_pConLinkIdentifier; + void HandleTeeworldsConnectLink(const char *pConLink); }; #endif