Skip to content

Commit

Permalink
Merge pull request ddnet#7282 from furo321/tele-cursor
Browse files Browse the repository at this point in the history
Teleport the player to their cursor if they aren't in pause
  • Loading branch information
def- authored Oct 2, 2023
2 parents 161a256 + 7e045d4 commit 78b70eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/game/server/ddracechat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
10 changes: 8 additions & 2 deletions src/game/server/ddracecommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 78b70eb

Please sign in to comment.