2011-02-02 10:49:19 +00:00
|
|
|
/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
|
2010-11-13 15:31:13 +00:00
|
|
|
#include "gamecontext.h"
|
2010-11-13 15:41:43 +00:00
|
|
|
#include <engine/shared/config.h>
|
2021-01-09 14:18:52 +00:00
|
|
|
#include <game/server/entities/character.h>
|
2010-11-13 15:41:43 +00:00
|
|
|
#include <game/server/gamemodes/DDRace.h>
|
2021-01-09 14:37:02 +00:00
|
|
|
#include <game/server/player.h>
|
2020-02-13 15:16:35 +00:00
|
|
|
#include <game/server/save.h>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <game/server/teams.h>
|
2010-11-13 15:41:43 +00:00
|
|
|
#include <game/version.h>
|
2010-11-13 15:31:13 +00:00
|
|
|
|
2011-08-26 18:03:30 +00:00
|
|
|
bool CheckClientID(int ClientID);
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConGoLeft(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
2011-08-26 18:03:30 +00:00
|
|
|
pSelf->MoveCharacter(pResult->m_ClientID, -1, 0);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConGoRight(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
2011-08-26 18:03:30 +00:00
|
|
|
pSelf->MoveCharacter(pResult->m_ClientID, 1, 0);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConGoDown(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
2011-08-26 18:03:30 +00:00
|
|
|
pSelf->MoveCharacter(pResult->m_ClientID, 0, 1);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConGoUp(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
2011-08-26 18:03:30 +00:00
|
|
|
pSelf->MoveCharacter(pResult->m_ClientID, 0, -1);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConMove(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
|
|
|
pSelf->MoveCharacter(pResult->m_ClientID, pResult->GetInteger(0),
|
2020-09-26 19:41:58 +00:00
|
|
|
pResult->GetInteger(1));
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConMoveRaw(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
|
|
|
pSelf->MoveCharacter(pResult->m_ClientID, pResult->GetInteger(0),
|
2020-09-26 19:41:58 +00:00
|
|
|
pResult->GetInteger(1), true);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::MoveCharacter(int ClientID, int X, int Y, bool Raw)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = GetPlayerChar(ClientID);
|
2011-02-13 04:45:17 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(!pChr)
|
2010-11-13 15:31:13 +00:00
|
|
|
return;
|
|
|
|
|
2011-01-29 00:59:50 +00:00
|
|
|
pChr->Core()->m_Pos.x += ((Raw) ? 1 : 32) * X;
|
|
|
|
pChr->Core()->m_Pos.y += ((Raw) ? 1 : 32) * Y;
|
2011-04-09 06:41:31 +00:00
|
|
|
pChr->m_DDRaceState = DDRACE_CHEAT;
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConKillPlayer(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
2011-09-25 16:04:29 +00:00
|
|
|
int Victim = pResult->GetVictim();
|
2010-11-13 15:31:13 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(pSelf->m_apPlayers[Victim])
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
|
|
|
pSelf->m_apPlayers[Victim]->KillCharacter(WEAPON_GAME);
|
2011-01-26 21:09:54 +00:00
|
|
|
char aBuf[512];
|
2011-12-25 13:51:04 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%s was killed by %s",
|
2020-09-26 19:41:58 +00:00
|
|
|
pSelf->Server()->ClientName(Victim),
|
|
|
|
pSelf->Server()->ClientName(pResult->m_ClientID));
|
2011-01-26 21:09:54 +00:00
|
|
|
pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConNinja(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_NINJA, false);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2020-12-26 22:09:33 +00:00
|
|
|
void CGameContext::ConEndlessHook(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
|
|
|
return;
|
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr)
|
|
|
|
{
|
|
|
|
pChr->SetEndlessHook(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameContext::ConUnEndlessHook(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
|
|
|
return;
|
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr)
|
|
|
|
{
|
|
|
|
pChr->SetEndlessHook(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr && !pChr->m_Super)
|
2011-01-26 21:09:54 +00:00
|
|
|
{
|
|
|
|
pChr->m_Super = true;
|
2020-06-14 13:56:15 +00:00
|
|
|
pChr->Core()->m_Super = true;
|
2011-01-26 21:09:54 +00:00
|
|
|
pChr->UnFreeze();
|
|
|
|
pChr->m_TeamBeforeSuper = pChr->Team();
|
2011-08-26 18:03:30 +00:00
|
|
|
pChr->Teams()->SetCharacterTeam(pResult->m_ClientID, TEAM_SUPER);
|
2011-04-09 06:41:31 +00:00
|
|
|
pChr->m_DDRaceState = DDRACE_CHEAT;
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConUnSuper(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr && pChr->m_Super)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-01-26 21:09:54 +00:00
|
|
|
pChr->m_Super = false;
|
2020-06-14 13:56:15 +00:00
|
|
|
pChr->Core()->m_Super = false;
|
2011-12-25 13:51:04 +00:00
|
|
|
pChr->Teams()->SetForceCharacterTeam(pResult->m_ClientID,
|
2020-09-26 19:41:58 +00:00
|
|
|
pChr->m_TeamBeforeSuper);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-11 15:53:59 +00:00
|
|
|
void CGameContext::ConUnSolo(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2014-06-11 15:53:59 +00:00
|
|
|
return;
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr)
|
2014-12-25 10:37:44 +00:00
|
|
|
pChr->SetSolo(false);
|
2014-06-11 15:53:59 +00:00
|
|
|
}
|
|
|
|
|
2014-06-13 21:49:34 +00:00
|
|
|
void CGameContext::ConUnDeep(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2014-06-13 21:49:34 +00:00
|
|
|
return;
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr)
|
2014-06-14 07:27:27 +00:00
|
|
|
pChr->m_DeepFreeze = false;
|
2014-06-13 21:49:34 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConShotgun(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_SHOTGUN, false);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConGrenade(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_GRENADE, false);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2019-11-22 14:37:18 +00:00
|
|
|
void CGameContext::ConLaser(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2019-11-22 14:37:18 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_LASER, false);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2016-10-08 17:42:42 +00:00
|
|
|
void CGameContext::ConJetpack(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr)
|
2016-10-08 17:42:42 +00:00
|
|
|
pChr->m_Jetpack = true;
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConWeapons(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, -1, false);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConUnShotgun(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_SHOTGUN, true);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConUnGrenade(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_GRENADE, true);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2019-11-22 14:37:18 +00:00
|
|
|
void CGameContext::ConUnLaser(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2019-11-22 14:37:18 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_LASER, true);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2016-10-08 17:42:42 +00:00
|
|
|
void CGameContext::ConUnJetpack(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr)
|
2016-10-08 17:42:42 +00:00
|
|
|
pChr->m_Jetpack = false;
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConUnWeapons(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2017-05-18 18:04:29 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, -1, true);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConAddWeapon(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, pResult->GetInteger(0), false);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConRemoveWeapon(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, pResult->GetInteger(0), true);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
void CGameContext::ModifyWeapons(IConsole::IResult *pResult, void *pUserData,
|
2020-09-26 19:41:58 +00:00
|
|
|
int Weapon, bool Remove)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2016-10-08 17:42:42 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(!pChr)
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
2016-10-08 17:42:42 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(clamp(Weapon, -1, NUM_WEAPONS - 1) != Weapon)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
|
2020-09-26 19:41:58 +00:00
|
|
|
"invalid weapon id");
|
2010-11-13 15:31:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-02-13 04:45:17 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(Weapon == -1)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2017-05-18 18:04:29 +00:00
|
|
|
pChr->GiveWeapon(WEAPON_SHOTGUN, Remove);
|
|
|
|
pChr->GiveWeapon(WEAPON_GRENADE, Remove);
|
2019-11-22 14:37:18 +00:00
|
|
|
pChr->GiveWeapon(WEAPON_LASER, Remove);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-08 17:42:42 +00:00
|
|
|
pChr->GiveWeapon(Weapon, Remove);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-09-25 16:04:29 +00:00
|
|
|
pChr->m_DDRaceState = DDRACE_CHEAT;
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2013-07-23 21:37:00 +00:00
|
|
|
void CGameContext::ConToTeleporter(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2013-07-23 21:37:00 +00:00
|
|
|
unsigned int TeleTo = pResult->GetInteger(0);
|
2020-05-25 13:08:24 +00:00
|
|
|
CGameControllerDDRace *pGameControllerDDRace = (CGameControllerDDRace *)pSelf->m_pController;
|
2013-07-23 21:37:00 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(pGameControllerDDRace->m_TeleOuts[TeleTo - 1].size())
|
2013-07-23 21:37:00 +00:00
|
|
|
{
|
2020-05-25 13:08:24 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr)
|
2013-07-23 21:37:00 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
int TeleOut = pSelf->m_World.m_Core.RandomOr0(pGameControllerDDRace->m_TeleOuts[TeleTo - 1].size());
|
|
|
|
vec2 TelePos = pGameControllerDDRace->m_TeleOuts[TeleTo - 1][TeleOut];
|
2013-07-23 21:37:00 +00:00
|
|
|
pChr->Core()->m_Pos = TelePos;
|
2014-05-07 17:22:57 +00:00
|
|
|
pChr->m_Pos = TelePos;
|
|
|
|
pChr->m_PrevPos = TelePos;
|
2013-07-23 21:37:00 +00:00
|
|
|
pChr->m_DDRaceState = DDRACE_CHEAT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 21:36:55 +00:00
|
|
|
void CGameContext::ConToCheckTeleporter(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2014-02-11 21:36:55 +00:00
|
|
|
unsigned int TeleTo = pResult->GetInteger(0);
|
2020-05-25 13:08:24 +00:00
|
|
|
CGameControllerDDRace *pGameControllerDDRace = (CGameControllerDDRace *)pSelf->m_pController;
|
2014-02-11 21:36:55 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(pGameControllerDDRace->m_TeleCheckOuts[TeleTo - 1].size())
|
2014-02-11 21:36:55 +00:00
|
|
|
{
|
2020-05-25 13:08:24 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if(pChr)
|
2014-02-11 21:36:55 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
int TeleOut = pSelf->m_World.m_Core.RandomOr0(pGameControllerDDRace->m_TeleCheckOuts[TeleTo - 1].size());
|
|
|
|
vec2 TelePos = pGameControllerDDRace->m_TeleCheckOuts[TeleTo - 1][TeleOut];
|
2014-02-11 21:36:55 +00:00
|
|
|
pChr->Core()->m_Pos = TelePos;
|
2014-05-07 17:22:57 +00:00
|
|
|
pChr->m_Pos = TelePos;
|
|
|
|
pChr->m_PrevPos = TelePos;
|
2014-02-11 21:36:55 +00:00
|
|
|
pChr->m_DDRaceState = DDRACE_CHEAT;
|
2015-02-21 18:48:22 +00:00
|
|
|
pChr->m_TeleCheckpoint = TeleTo;
|
2014-02-11 21:36:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConTeleport(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2019-02-09 18:32:45 +00:00
|
|
|
int Tele = pResult->NumArguments() == 2 ? pResult->GetInteger(0) : pResult->m_ClientID;
|
|
|
|
int TeleTo = pResult->NumArguments() ? pResult->GetInteger(pResult->NumArguments() - 1) : pResult->m_ClientID;
|
2020-06-14 16:03:45 +00:00
|
|
|
int AuthLevel = pSelf->Server()->GetAuthedState(pResult->m_ClientID);
|
|
|
|
|
|
|
|
if(Tele != pResult->m_ClientID && AuthLevel < g_Config.m_SvTeleOthersAuthLevel)
|
|
|
|
{
|
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tele", "you aren't allowed to tele others");
|
|
|
|
return;
|
|
|
|
}
|
2013-07-29 19:25:10 +00:00
|
|
|
|
2019-02-09 18:32:45 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(Tele);
|
|
|
|
if(pChr && pSelf->GetPlayerChar(TeleTo))
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2017-04-02 17:05:28 +00:00
|
|
|
pChr->Core()->m_Pos = pSelf->m_apPlayers[TeleTo]->m_ViewPos;
|
|
|
|
pChr->m_Pos = pSelf->m_apPlayers[TeleTo]->m_ViewPos;
|
|
|
|
pChr->m_PrevPos = pSelf->m_apPlayers[TeleTo]->m_ViewPos;
|
|
|
|
pChr->m_DDRaceState = DDRACE_CHEAT;
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConKill(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2011-12-25 13:51:04 +00:00
|
|
|
return;
|
2011-08-26 18:03:30 +00:00
|
|
|
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
2010-11-13 15:31:13 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(!pPlayer || (pPlayer->m_LastKill && pPlayer->m_LastKill + pSelf->Server()->TickSpeed() * g_Config.m_SvKillDelay > pSelf->Server()->Tick()))
|
2010-11-13 15:31:13 +00:00
|
|
|
return;
|
|
|
|
|
2011-04-09 06:41:31 +00:00
|
|
|
pPlayer->m_LastKill = pSelf->Server()->Tick();
|
2010-11-13 15:31:13 +00:00
|
|
|
pPlayer->KillCharacter(WEAPON_SELF);
|
2011-04-09 06:41:31 +00:00
|
|
|
//pPlayer->m_RespawnTick = pSelf->Server()->Tick() + pSelf->Server()->TickSpeed() * g_Config.m_SvSuicidePenalty;
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConForcePause(IConsole::IResult *pResult, void *pUserData)
|
2011-06-06 20:18:37 +00:00
|
|
|
{
|
2011-12-29 13:58:39 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-11-08 21:08:37 +00:00
|
|
|
int Victim = pResult->GetVictim();
|
2011-06-06 23:01:35 +00:00
|
|
|
int Seconds = 0;
|
2020-09-26 19:41:58 +00:00
|
|
|
if(pResult->NumArguments() > 1)
|
2017-09-13 20:35:09 +00:00
|
|
|
Seconds = clamp(pResult->GetInteger(1), 0, 360);
|
2011-06-06 20:18:37 +00:00
|
|
|
|
|
|
|
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
|
2020-09-26 19:41:58 +00:00
|
|
|
if(!pPlayer)
|
2011-06-06 20:18:37 +00:00
|
|
|
return;
|
|
|
|
|
2017-04-08 22:20:41 +00:00
|
|
|
pPlayer->ForcePause(Seconds);
|
2011-06-06 20:18:37 +00:00
|
|
|
}
|
|
|
|
|
2019-04-12 17:50:02 +00:00
|
|
|
bool CGameContext::TryVoteMute(const NETADDR *pAddr, int Secs)
|
2018-04-18 17:26:49 +00:00
|
|
|
{
|
2018-04-19 09:49:18 +00:00
|
|
|
// find a matching vote mute for this ip, update expiration time if found
|
|
|
|
for(int i = 0; i < m_NumVoteMutes; i++)
|
2018-04-18 17:26:49 +00:00
|
|
|
{
|
2018-10-08 18:04:04 +00:00
|
|
|
if(net_addr_comp_noport(&m_aVoteMutes[i].m_Addr, pAddr) == 0)
|
2018-04-18 17:26:49 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
m_aVoteMutes[i].m_Expire = Server()->Tick() + Secs * Server()->TickSpeed();
|
2019-04-12 17:50:02 +00:00
|
|
|
return true;
|
2018-04-18 17:26:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-11 18:08:33 +00:00
|
|
|
// nothing to update create new one
|
|
|
|
if(m_NumVoteMutes < MAX_VOTE_MUTES)
|
2018-04-18 17:26:49 +00:00
|
|
|
{
|
2019-04-11 18:08:33 +00:00
|
|
|
m_aVoteMutes[m_NumVoteMutes].m_Addr = *pAddr;
|
2020-09-26 19:41:58 +00:00
|
|
|
m_aVoteMutes[m_NumVoteMutes].m_Expire = Server()->Tick() + Secs * Server()->TickSpeed();
|
2019-04-11 18:08:33 +00:00
|
|
|
m_NumVoteMutes++;
|
2019-04-12 17:50:02 +00:00
|
|
|
return true;
|
2018-04-18 17:26:49 +00:00
|
|
|
}
|
2019-04-11 18:08:33 +00:00
|
|
|
// no free slot found
|
|
|
|
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemute", "vote mute array is full");
|
|
|
|
return false;
|
2019-04-12 17:50:02 +00:00
|
|
|
}
|
2019-04-11 18:08:33 +00:00
|
|
|
|
2019-04-12 17:50:02 +00:00
|
|
|
bool CGameContext::VoteMute(const NETADDR *pAddr, int Secs, const char *pDisplayName, int AuthedID)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
if(!TryVoteMute(pAddr, Secs))
|
2019-04-12 17:50:02 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if(!pDisplayName)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof aBuf, "'%s' banned '%s' for %d seconds from voting.",
|
|
|
|
Server()->ClientName(AuthedID), pDisplayName, Secs);
|
|
|
|
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemute", aBuf);
|
2019-04-11 18:08:33 +00:00
|
|
|
return true;
|
2019-03-19 19:07:33 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 19:18:11 +00:00
|
|
|
bool CGameContext::VoteUnmute(const NETADDR *pAddr, const char *pDisplayName, int AuthedID)
|
2019-03-19 19:07:33 +00:00
|
|
|
{
|
|
|
|
for(int i = 0; i < m_NumVoteMutes; i++)
|
|
|
|
{
|
|
|
|
if(net_addr_comp_noport(&m_aVoteMutes[i].m_Addr, pAddr) == 0)
|
|
|
|
{
|
|
|
|
m_NumVoteMutes--;
|
|
|
|
m_aVoteMutes[i] = m_aVoteMutes[m_NumVoteMutes];
|
|
|
|
if(pDisplayName)
|
|
|
|
{
|
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof aBuf, "'%s' unbanned '%s' from voting.",
|
2020-09-26 19:41:58 +00:00
|
|
|
Server()->ClientName(AuthedID), pDisplayName);
|
2019-03-19 19:07:33 +00:00
|
|
|
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "voteunmute", aBuf);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2018-04-18 17:26:49 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 21:51:58 +00:00
|
|
|
bool CGameContext::TryMute(const NETADDR *pAddr, int Secs, const char *pReason)
|
2011-02-08 12:44:59 +00:00
|
|
|
{
|
|
|
|
// find a matching mute for this ip, update expiration time if found
|
2019-04-11 18:08:33 +00:00
|
|
|
for(int i = 0; i < m_NumMutes; i++)
|
2011-02-23 21:39:53 +00:00
|
|
|
{
|
2019-04-11 18:08:33 +00:00
|
|
|
if(net_addr_comp_noport(&m_aMutes[i].m_Addr, pAddr) == 0)
|
2011-02-23 21:39:53 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
m_aMutes[i].m_Expire = Server()->Tick() + Secs * Server()->TickSpeed();
|
2020-03-30 21:51:58 +00:00
|
|
|
str_copy(m_aMutes[i].m_aReason, pReason, sizeof(m_aMutes[i].m_aReason));
|
2019-04-12 17:50:02 +00:00
|
|
|
return true;
|
2011-02-23 21:39:53 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-08 12:44:59 +00:00
|
|
|
|
2019-04-11 18:08:33 +00:00
|
|
|
// nothing to update create new one
|
|
|
|
if(m_NumMutes < MAX_MUTES)
|
2011-02-23 21:39:53 +00:00
|
|
|
{
|
2019-04-11 18:08:33 +00:00
|
|
|
m_aMutes[m_NumMutes].m_Addr = *pAddr;
|
2020-09-26 19:41:58 +00:00
|
|
|
m_aMutes[m_NumMutes].m_Expire = Server()->Tick() + Secs * Server()->TickSpeed();
|
2020-06-14 16:03:45 +00:00
|
|
|
str_copy(m_aMutes[m_NumMutes].m_aReason, pReason, sizeof(m_aMutes[m_NumMutes].m_aReason));
|
2019-04-11 18:08:33 +00:00
|
|
|
m_NumMutes++;
|
2019-04-12 17:50:02 +00:00
|
|
|
return true;
|
2011-02-23 21:39:53 +00:00
|
|
|
}
|
2019-04-11 18:08:33 +00:00
|
|
|
// no free slot found
|
|
|
|
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", "mute array is full");
|
2019-04-12 17:50:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-04-11 18:08:33 +00:00
|
|
|
|
2020-03-30 21:51:58 +00:00
|
|
|
void CGameContext::Mute(const NETADDR *pAddr, int Secs, const char *pDisplayName, const char *pReason)
|
2019-04-12 17:50:02 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
if(!TryMute(pAddr, Secs, pReason))
|
2019-04-12 17:50:02 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if(!pDisplayName)
|
|
|
|
return;
|
|
|
|
|
|
|
|
char aBuf[128];
|
2020-09-26 19:41:58 +00:00
|
|
|
if(pReason[0])
|
2020-03-30 22:16:42 +00:00
|
|
|
str_format(aBuf, sizeof aBuf, "'%s' has been muted for %d seconds (%s)", pDisplayName, Secs, pReason);
|
|
|
|
else
|
2020-03-31 01:29:45 +00:00
|
|
|
str_format(aBuf, sizeof aBuf, "'%s' has been muted for %d seconds", pDisplayName, Secs);
|
2019-04-12 17:50:02 +00:00
|
|
|
SendChat(-1, CHAT_ALL, aBuf);
|
2011-02-08 12:44:59 +00:00
|
|
|
}
|
|
|
|
|
2018-04-19 09:49:18 +00:00
|
|
|
void CGameContext::ConVoteMute(IConsole::IResult *pResult, void *pUserData)
|
2018-04-18 17:26:49 +00:00
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
int Victim = pResult->GetVictim();
|
|
|
|
|
2018-04-21 16:45:33 +00:00
|
|
|
if(Victim < 0 || Victim > MAX_CLIENTS || !pSelf->m_apPlayers[Victim])
|
2018-04-18 17:26:49 +00:00
|
|
|
{
|
2018-04-21 16:45:33 +00:00
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemute", "Client ID not found");
|
2018-04-18 17:26:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NETADDR Addr;
|
|
|
|
pSelf->Server()->GetClientAddr(Victim, &Addr);
|
|
|
|
|
2019-03-19 19:07:33 +00:00
|
|
|
int Seconds = clamp(pResult->GetInteger(1), 1, 86400);
|
|
|
|
bool Found = pSelf->VoteMute(&Addr, Seconds, pSelf->Server()->ClientName(Victim), pResult->m_ClientID);
|
|
|
|
|
|
|
|
if(Found)
|
|
|
|
{
|
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof aBuf, "'%s' banned '%s' for %d seconds from voting.",
|
2020-09-26 19:41:58 +00:00
|
|
|
pSelf->Server()->ClientName(pResult->m_ClientID), pSelf->Server()->ClientName(Victim), Seconds);
|
2019-03-19 19:07:33 +00:00
|
|
|
pSelf->SendChat(-1, 0, aBuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 19:18:11 +00:00
|
|
|
void CGameContext::ConVoteUnmute(IConsole::IResult *pResult, void *pUserData)
|
2019-03-19 19:07:33 +00:00
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
int Victim = pResult->GetVictim();
|
|
|
|
|
|
|
|
if(Victim < 0 || Victim > MAX_CLIENTS || !pSelf->m_apPlayers[Victim])
|
|
|
|
{
|
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "voteunmute", "Client ID not found");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NETADDR Addr;
|
|
|
|
pSelf->Server()->GetClientAddr(Victim, &Addr);
|
|
|
|
|
2019-03-19 19:18:11 +00:00
|
|
|
bool Found = pSelf->VoteUnmute(&Addr, pSelf->Server()->ClientName(Victim), pResult->m_ClientID);
|
2019-03-19 19:07:33 +00:00
|
|
|
if(Found)
|
|
|
|
{
|
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof aBuf, "'%s' unbanned '%s' from voting.",
|
2020-09-26 19:41:58 +00:00
|
|
|
pSelf->Server()->ClientName(pResult->m_ClientID), pSelf->Server()->ClientName(Victim));
|
2019-03-19 19:07:33 +00:00
|
|
|
pSelf->SendChat(-1, 0, aBuf);
|
|
|
|
}
|
2018-04-18 17:26:49 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 19:25:21 +00:00
|
|
|
void CGameContext::ConVoteMutes(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2019-03-19 19:25:21 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(pSelf->m_NumVoteMutes <= 0)
|
2019-03-19 19:25:21 +00:00
|
|
|
{
|
|
|
|
// Just to make sure.
|
|
|
|
pSelf->m_NumVoteMutes = 0;
|
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemutes",
|
2020-09-26 19:41:58 +00:00
|
|
|
"There are no active vote mutes.");
|
2019-03-19 19:25:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char aIpBuf[64];
|
|
|
|
char aBuf[128];
|
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemutes",
|
2020-09-26 19:41:58 +00:00
|
|
|
"Active vote mutes:");
|
|
|
|
for(int i = 0; i < pSelf->m_NumVoteMutes; i++)
|
2019-03-19 19:25:21 +00:00
|
|
|
{
|
|
|
|
net_addr_str(&pSelf->m_aVoteMutes[i].m_Addr, aIpBuf, sizeof(aIpBuf), false);
|
2019-03-19 19:32:01 +00:00
|
|
|
str_format(aBuf, sizeof aBuf, "%d: \"%s\", %d seconds left", i,
|
2020-09-26 19:41:58 +00:00
|
|
|
aIpBuf, (pSelf->m_aVoteMutes[i].m_Expire - pSelf->Server()->Tick()) / pSelf->Server()->TickSpeed());
|
2019-03-19 19:25:21 +00:00
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "votemutes", aBuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData)
|
2011-02-08 12:44:59 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-12-25 13:51:04 +00:00
|
|
|
pSelf->Console()->Print(
|
2020-09-26 19:41:58 +00:00
|
|
|
IConsole::OUTPUT_LEVEL_STANDARD,
|
|
|
|
"mutes",
|
|
|
|
"Use either 'muteid <client_id> <seconds> <reason>' or 'muteip <ip> <seconds> <reason>'");
|
2011-02-08 12:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// mute through client id
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConMuteID(IConsole::IResult *pResult, void *pUserData)
|
2011-02-08 12:44:59 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-09-25 16:04:29 +00:00
|
|
|
int Victim = pResult->GetVictim();
|
2018-10-08 18:04:04 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(Victim < 0 || Victim > MAX_CLIENTS || !pSelf->m_apPlayers[Victim])
|
2018-01-15 18:31:14 +00:00
|
|
|
{
|
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "muteid", "Client id not found.");
|
|
|
|
return;
|
|
|
|
}
|
2011-02-08 12:44:59 +00:00
|
|
|
|
2011-02-23 21:39:53 +00:00
|
|
|
NETADDR Addr;
|
|
|
|
pSelf->Server()->GetClientAddr(Victim, &Addr);
|
2011-02-08 12:44:59 +00:00
|
|
|
|
2020-03-30 22:16:42 +00:00
|
|
|
const char *pReason = pResult->NumArguments() > 2 ? pResult->GetString(2) : "";
|
2020-03-30 21:51:58 +00:00
|
|
|
|
2018-10-08 18:29:33 +00:00
|
|
|
pSelf->Mute(&Addr, clamp(pResult->GetInteger(1), 1, 86400),
|
2020-09-26 19:41:58 +00:00
|
|
|
pSelf->Server()->ClientName(Victim), pReason);
|
2011-02-08 12:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// mute through ip, arguments reversed to workaround parsing
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConMuteIP(IConsole::IResult *pResult, void *pUserData)
|
2011-02-08 12:44:59 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-02-23 21:39:53 +00:00
|
|
|
NETADDR Addr;
|
2020-09-26 19:41:58 +00:00
|
|
|
if(net_addr_from_str(&Addr, pResult->GetString(0)))
|
2011-02-23 21:39:53 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes",
|
2020-09-26 19:41:58 +00:00
|
|
|
"Invalid network address to mute");
|
2011-02-23 21:39:53 +00:00
|
|
|
}
|
2020-03-30 22:16:42 +00:00
|
|
|
const char *pReason = pResult->NumArguments() > 2 ? pResult->GetString(2) : "";
|
2020-03-30 21:51:58 +00:00
|
|
|
pSelf->Mute(&Addr, clamp(pResult->GetInteger(1), 1, 86400), NULL, pReason);
|
2011-02-08 12:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// unmute by mute list index
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConUnmute(IConsole::IResult *pResult, void *pUserData)
|
2011-02-08 12:44:59 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2011-02-23 21:39:53 +00:00
|
|
|
char aIpBuf[64];
|
|
|
|
char aBuf[64];
|
2011-09-25 16:04:29 +00:00
|
|
|
int Victim = pResult->GetVictim();
|
2011-02-08 12:44:59 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(Victim < 0 || Victim >= pSelf->m_NumMutes)
|
2011-02-08 12:44:59 +00:00
|
|
|
return;
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2011-02-23 21:39:53 +00:00
|
|
|
pSelf->m_NumMutes--;
|
2011-04-14 02:38:03 +00:00
|
|
|
pSelf->m_aMutes[Victim] = pSelf->m_aMutes[pSelf->m_NumMutes];
|
2011-02-08 12:44:59 +00:00
|
|
|
|
2011-12-31 22:00:00 +00:00
|
|
|
net_addr_str(&pSelf->m_aMutes[Victim].m_Addr, aIpBuf, sizeof(aIpBuf), false);
|
2011-12-25 13:51:04 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "Unmuted %s", aIpBuf);
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", aBuf);
|
2011-02-08 12:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// list mutes
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConMutes(IConsole::IResult *pResult, void *pUserData)
|
2011-02-08 12:44:59 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2018-10-08 18:04:04 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(pSelf->m_NumMutes <= 0)
|
2018-01-15 18:31:14 +00:00
|
|
|
{
|
|
|
|
// Just to make sure.
|
|
|
|
pSelf->m_NumMutes = 0;
|
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes",
|
|
|
|
"There are no active mutes.");
|
|
|
|
return;
|
|
|
|
}
|
2018-10-08 18:04:04 +00:00
|
|
|
|
2011-02-23 21:39:53 +00:00
|
|
|
char aIpBuf[64];
|
|
|
|
char aBuf[128];
|
2011-12-25 13:51:04 +00:00
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes",
|
2020-09-26 19:41:58 +00:00
|
|
|
"Active mutes:");
|
|
|
|
for(int i = 0; i < pSelf->m_NumMutes; i++)
|
2011-02-23 21:39:53 +00:00
|
|
|
{
|
2011-12-31 22:00:00 +00:00
|
|
|
net_addr_str(&pSelf->m_aMutes[i].m_Addr, aIpBuf, sizeof(aIpBuf), false);
|
2020-03-30 21:51:58 +00:00
|
|
|
str_format(aBuf, sizeof aBuf, "%d: \"%s\", %d seconds left (%s)", i, aIpBuf,
|
2020-09-26 19:41:58 +00:00
|
|
|
(pSelf->m_aMutes[i].m_Expire - pSelf->Server()->Tick()) / pSelf->Server()->TickSpeed(), pSelf->m_aMutes[i].m_aReason);
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", aBuf);
|
2011-02-23 21:39:53 +00:00
|
|
|
}
|
2011-11-08 21:08:37 +00:00
|
|
|
}
|
2013-12-31 05:13:57 +00:00
|
|
|
|
2018-01-05 11:04:06 +00:00
|
|
|
void CGameContext::ConModerate(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2020-09-26 19:41:58 +00:00
|
|
|
if(!CheckClientID(pResult->m_ClientID))
|
2018-01-05 11:04:06 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
bool HadModerator = pSelf->PlayerModerating();
|
|
|
|
|
2018-06-24 07:57:30 +00:00
|
|
|
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
|
|
|
pPlayer->m_Moderating = !pPlayer->m_Moderating;
|
|
|
|
|
2018-01-05 11:04:06 +00:00
|
|
|
char aBuf[256];
|
|
|
|
|
2018-06-24 07:57:30 +00:00
|
|
|
if(!HadModerator && pPlayer->m_Moderating)
|
2018-01-05 11:04:06 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "Server kick/spec votes will now be actively moderated.");
|
|
|
|
|
2018-06-24 07:57:30 +00:00
|
|
|
if(!pSelf->PlayerModerating())
|
2018-01-05 11:04:06 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "Server kick/spec votes are no longer actively moderated.");
|
|
|
|
|
|
|
|
pSelf->SendChat(-1, CHAT_ALL, aBuf, 0);
|
2018-10-08 18:04:04 +00:00
|
|
|
|
2018-06-24 07:57:30 +00:00
|
|
|
if(pPlayer->m_Moderating)
|
|
|
|
pSelf->SendChatTarget(pResult->m_ClientID, "Active moderator mode enabled for you.");
|
2018-01-05 11:04:06 +00:00
|
|
|
else
|
|
|
|
pSelf->SendChatTarget(pResult->m_ClientID, "Active moderator mode disabled for you.");
|
|
|
|
}
|
|
|
|
|
2017-04-25 17:10:22 +00:00
|
|
|
void CGameContext::ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
CGameControllerDDRace *pController = (CGameControllerDDRace *)pSelf->m_pController;
|
|
|
|
|
2020-06-30 18:22:17 +00:00
|
|
|
if(g_Config.m_SvTeam == 0 || g_Config.m_SvTeam == 3)
|
|
|
|
{
|
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join",
|
2020-09-26 19:41:58 +00:00
|
|
|
"Teams are disabled");
|
2020-06-30 18:22:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-25 18:27:23 +00:00
|
|
|
int Target = pResult->GetVictim();
|
2017-09-13 20:35:09 +00:00
|
|
|
int Team = pResult->GetInteger(1);
|
2017-04-25 17:10:22 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(Team < TEAM_FLOCK || Team >= TEAM_SUPER)
|
2019-08-04 21:38:08 +00:00
|
|
|
return;
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(Target);
|
2020-05-28 19:50:35 +00:00
|
|
|
|
|
|
|
if((pController->m_Teams.m_Core.Team(Target) && pController->m_Teams.GetDDRaceState(pSelf->m_apPlayers[Target]) == DDRACE_STARTED) || (pChr && pController->m_Teams.IsPractice(pChr->Team())))
|
2020-10-31 10:32:37 +00:00
|
|
|
pSelf->m_apPlayers[Target]->KillCharacter(WEAPON_GAME);
|
2017-04-25 18:27:23 +00:00
|
|
|
|
2019-03-01 21:11:00 +00:00
|
|
|
pController->m_Teams.SetForceCharacterTeam(Target, Team);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameContext::ConUninvite(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
CGameControllerDDRace *pController = (CGameControllerDDRace *)pSelf->m_pController;
|
|
|
|
|
|
|
|
pController->m_Teams.SetClientInvited(pResult->GetInteger(1), pResult->GetVictim(), false);
|
2017-04-25 17:10:22 +00:00
|
|
|
}
|
|
|
|
|
2014-07-16 00:59:39 +00:00
|
|
|
void CGameContext::ConFreezeHammer(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2014-07-16 00:59:39 +00:00
|
|
|
int Victim = pResult->GetVictim();
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(Victim);
|
2014-07-16 00:59:39 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(!pChr)
|
2014-07-16 00:59:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof aBuf, "'%s' got freeze hammer!",
|
2020-09-26 19:41:58 +00:00
|
|
|
pSelf->Server()->ClientName(Victim));
|
2014-07-16 00:59:39 +00:00
|
|
|
pSelf->SendChat(-1, CHAT_ALL, aBuf);
|
|
|
|
|
|
|
|
pChr->m_FreezeHammer = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameContext::ConUnFreezeHammer(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2014-07-16 00:59:39 +00:00
|
|
|
int Victim = pResult->GetVictim();
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacter *pChr = pSelf->GetPlayerChar(Victim);
|
2014-07-16 00:59:39 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(!pChr)
|
2014-07-16 00:59:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof aBuf, "'%s' lost freeze hammer!",
|
2020-09-26 19:41:58 +00:00
|
|
|
pSelf->Server()->ClientName(Victim));
|
2014-07-16 00:59:39 +00:00
|
|
|
pSelf->SendChat(-1, CHAT_ALL, aBuf);
|
|
|
|
|
|
|
|
pChr->m_FreezeHammer = false;
|
|
|
|
}
|
2018-01-18 06:56:07 +00:00
|
|
|
void CGameContext::ConVoteNo(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
2018-10-08 18:04:04 +00:00
|
|
|
|
2018-01-18 15:17:23 +00:00
|
|
|
pSelf->ForceVote(pResult->m_ClientID, false);
|
2018-01-18 06:58:22 +00:00
|
|
|
}
|
2020-02-13 15:16:35 +00:00
|
|
|
|
|
|
|
void CGameContext::ConDrySave(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
|
|
|
|
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
|
|
|
|
|
|
|
|
if(!pPlayer || pSelf->Server()->GetAuthedState(pResult->m_ClientID) != AUTHED_ADMIN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
CSaveTeam SavedTeam(pSelf->m_pController);
|
2021-02-16 17:15:50 +00:00
|
|
|
int Result = SavedTeam.Save(pPlayer->GetTeam());
|
2020-02-13 16:04:58 +00:00
|
|
|
if(CSaveTeam::HandleSaveError(Result, pResult->m_ClientID, pSelf))
|
|
|
|
return;
|
|
|
|
|
2020-06-29 11:57:08 +00:00
|
|
|
char aTimestamp[32];
|
|
|
|
str_timestamp(aTimestamp, sizeof(aTimestamp));
|
2020-02-13 23:03:49 +00:00
|
|
|
char aBuf[64];
|
2020-06-29 11:57:08 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%s_%s_%s.save", pSelf->Server()->GetMapName(), aTimestamp, pSelf->Server()->GetAuthName(pResult->m_ClientID));
|
2020-02-13 23:03:49 +00:00
|
|
|
IOHANDLE File = pSelf->Storage()->OpenFile(aBuf, IOFLAG_WRITE, IStorage::TYPE_ALL);
|
|
|
|
if(!File)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int Len = str_length(SavedTeam.GetString());
|
|
|
|
io_write(File, SavedTeam.GetString(), Len);
|
|
|
|
io_close(File);
|
2020-02-13 15:16:35 +00:00
|
|
|
}
|
2020-03-11 00:58:50 +00:00
|
|
|
|
|
|
|
void CGameContext::ConDumpAntibot(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
pSelf->Antibot()->Dump();
|
|
|
|
}
|