From 107af9c9022ebc3f6970556a42af796a81c6b319 Mon Sep 17 00:00:00 2001 From: furo Date: Sun, 17 Sep 2023 15:24:53 +0200 Subject: [PATCH] Add optional argument tiles to movement commands Add optional argument to movement and console page commands Remove optional argument to console page commands --- src/game/ddracecommands.h | 8 ++++---- src/game/server/ddracecommands.cpp | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/game/ddracecommands.h b/src/game/ddracecommands.h index 36b30be20..7e17a7803 100644 --- a/src/game/ddracecommands.h +++ b/src/game/ddracecommands.h @@ -36,10 +36,10 @@ CONSOLE_COMMAND("deep", "", CFGFLAG_SERVER | CMDFLAG_TEST, ConDeep, this, "Puts CONSOLE_COMMAND("undeep", "", CFGFLAG_SERVER | CMDFLAG_TEST, ConUnDeep, this, "Puts you out of deep freeze") CONSOLE_COMMAND("livefreeze", "", CFGFLAG_SERVER | CMDFLAG_TEST, ConLiveFreeze, this, "Makes you live frozen") CONSOLE_COMMAND("unlivefreeze", "", CFGFLAG_SERVER | CMDFLAG_TEST, ConUnLiveFreeze, this, "Puts you out of live freeze") -CONSOLE_COMMAND("left", "", CFGFLAG_SERVER | CMDFLAG_TEST, ConGoLeft, this, "Makes you move 1 tile left") -CONSOLE_COMMAND("right", "", CFGFLAG_SERVER | CMDFLAG_TEST, ConGoRight, this, "Makes you move 1 tile right") -CONSOLE_COMMAND("up", "", CFGFLAG_SERVER | CMDFLAG_TEST, ConGoUp, this, "Makes you move 1 tile up") -CONSOLE_COMMAND("down", "", CFGFLAG_SERVER | CMDFLAG_TEST, ConGoDown, this, "Makes you move 1 tile down") +CONSOLE_COMMAND("left", "?i[tiles]", CFGFLAG_SERVER | CMDFLAG_TEST, ConGoLeft, this, "Makes you move 1 tile left") +CONSOLE_COMMAND("right", "?i[tiles]", CFGFLAG_SERVER | CMDFLAG_TEST, ConGoRight, this, "Makes you move 1 tile right") +CONSOLE_COMMAND("up", "?i[tiles]", CFGFLAG_SERVER | CMDFLAG_TEST, ConGoUp, this, "Makes you move 1 tile up") +CONSOLE_COMMAND("down", "?i[tiles]", CFGFLAG_SERVER | CMDFLAG_TEST, ConGoDown, this, "Makes you move 1 tile down") CONSOLE_COMMAND("move", "i[x] i[y]", CFGFLAG_SERVER | CMDFLAG_TEST, ConMove, this, "Moves to the tile with x/y-number ii") CONSOLE_COMMAND("move_raw", "i[x] i[y]", CFGFLAG_SERVER | CMDFLAG_TEST, ConMoveRaw, this, "Moves to the point with x/y-coordinates ii") diff --git a/src/game/server/ddracecommands.cpp b/src/game/server/ddracecommands.cpp index 156b6ae23..ea8037650 100644 --- a/src/game/server/ddracecommands.cpp +++ b/src/game/server/ddracecommands.cpp @@ -15,33 +15,41 @@ bool CheckClientID(int ClientID); void CGameContext::ConGoLeft(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; + int Tiles = pResult->NumArguments() == 1 ? pResult->GetInteger(0) : 1; + if(!CheckClientID(pResult->m_ClientID)) return; - pSelf->MoveCharacter(pResult->m_ClientID, -1, 0); + pSelf->MoveCharacter(pResult->m_ClientID, -1 * Tiles, 0); } void CGameContext::ConGoRight(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; + int Tiles = pResult->NumArguments() == 1 ? pResult->GetInteger(0) : 1; + if(!CheckClientID(pResult->m_ClientID)) return; - pSelf->MoveCharacter(pResult->m_ClientID, 1, 0); + pSelf->MoveCharacter(pResult->m_ClientID, Tiles, 0); } void CGameContext::ConGoDown(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; + int Tiles = pResult->NumArguments() == 1 ? pResult->GetInteger(0) : 1; + if(!CheckClientID(pResult->m_ClientID)) return; - pSelf->MoveCharacter(pResult->m_ClientID, 0, 1); + pSelf->MoveCharacter(pResult->m_ClientID, 0, Tiles); } void CGameContext::ConGoUp(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; + int Tiles = pResult->NumArguments() == 1 ? pResult->GetInteger(0) : 1; + if(!CheckClientID(pResult->m_ClientID)) return; - pSelf->MoveCharacter(pResult->m_ClientID, 0, -1); + pSelf->MoveCharacter(pResult->m_ClientID, 0, -1 * Tiles); } void CGameContext::ConMove(IConsole::IResult *pResult, void *pUserData)