From 7e045d4f32f74f704e669f276a09baac87f52c0e Mon Sep 17 00:00:00 2001 From: furo Date: Mon, 2 Oct 2023 11:58:50 +0200 Subject: [PATCH] Teleport the player to their cursor if no argument is specified. Check for `NumArguments()` --- src/game/server/ddracechat.cpp | 7 +++++-- src/game/server/ddracecommands.cpp | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index 935ade688c2..557731c0387 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -1518,8 +1518,11 @@ void CGameContext::ConTele(IConsole::IResult *pResult, void *pUserData) } vec2 Pos = pPlayer->m_ViewPos; - - if(pResult->NumArguments() > 0) + if(pResult->NumArguments() == 0 && !pPlayer->IsPaused()) + { + Pos = Pos + vec2(pChr->Core()->m_Input.m_TargetX, pChr->Core()->m_Input.m_TargetY); + } + else if(pResult->NumArguments() > 0) { int ClientID; for(ClientID = 0; ClientID < MAX_CLIENTS; ClientID++) diff --git a/src/game/server/ddracecommands.cpp b/src/game/server/ddracecommands.cpp index 19977b557ab..8481a975d9e 100644 --- a/src/game/server/ddracecommands.cpp +++ b/src/game/server/ddracecommands.cpp @@ -383,9 +383,15 @@ void CGameContext::ConTeleport(IConsole::IResult *pResult, void *pUserData) } CCharacter *pChr = pSelf->GetPlayerChar(Tele); - if(pChr && pSelf->GetPlayerChar(TeleTo)) + CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID]; + + if(pChr && pPlayer && pSelf->GetPlayerChar(TeleTo)) { - pSelf->Teleport(pChr, pSelf->m_apPlayers[TeleTo]->m_ViewPos); + vec2 Pos = pSelf->m_apPlayers[TeleTo]->m_ViewPos; + if(!pPlayer->IsPaused() && !pResult->NumArguments()) + Pos = Pos + vec2(pChr->Core()->m_Input.m_TargetX, pChr->Core()->m_Input.m_TargetY); + + pSelf->Teleport(pChr, Pos); pChr->UnFreeze(); pChr->Core()->m_Vel = vec2(0, 0); }