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>
|
|
|
|
#include <engine/server/server.h>
|
|
|
|
#include <game/server/teams.h>
|
|
|
|
#include <game/server/gamemodes/DDRace.h>
|
|
|
|
#include <game/version.h>
|
2011-05-09 19:03:40 +00:00
|
|
|
#include <game/generated/nethash.cpp>
|
2011-02-13 18:45:17 +00:00
|
|
|
#if defined(CONF_SQL)
|
2011-12-25 13:51:04 +00:00
|
|
|
#include <game/server/score/sql_score.h>
|
2011-02-13 18:45:17 +00:00
|
|
|
#endif
|
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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
return;
|
|
|
|
pSelf->MoveCharacter(pResult->m_ClientID, pResult->GetInteger(0),
|
|
|
|
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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
return;
|
|
|
|
pSelf->MoveCharacter(pResult->m_ClientID, pResult->GetInteger(0),
|
|
|
|
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
|
|
|
{
|
2011-08-13 00:11:06 +00:00
|
|
|
CCharacter* pChr = GetPlayerChar(ClientID);
|
2011-02-13 04:45:17 +00:00
|
|
|
|
2011-12-25 13:51:04 +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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
return;
|
2011-09-25 16:04:29 +00:00
|
|
|
int Victim = pResult->GetVictim();
|
2010-11-13 15:31:13 +00:00
|
|
|
|
2011-12-25 13:51:04 +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",
|
|
|
|
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
|
|
|
{
|
2011-12-25 13:51:04 +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
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
return;
|
2011-08-26 18:03:30 +00:00
|
|
|
CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
2011-12-25 13:51:04 +00:00
|
|
|
if (pChr && !pChr->m_Super)
|
2011-01-26 21:09:54 +00:00
|
|
|
{
|
|
|
|
pChr->m_Super = true;
|
|
|
|
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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
return;
|
2011-08-26 18:03:30 +00:00
|
|
|
CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
2011-12-25 13:51:04 +00:00
|
|
|
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;
|
2011-12-25 13:51:04 +00:00
|
|
|
pChr->Teams()->SetForceCharacterTeam(pResult->m_ClientID,
|
|
|
|
pChr->m_TeamBeforeSuper);
|
2010-11-13 15:31:13 +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
|
|
|
{
|
2011-12-25 13:51:04 +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
|
|
|
{
|
2011-12-25 13:51:04 +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
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConRifle(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_RIFLE, false);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConWeapons(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +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
|
|
|
{
|
2011-12-25 13:51:04 +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
|
|
|
{
|
2011-12-25 13:51:04 +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
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConUnRifle(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
2011-08-13 00:11:06 +00:00
|
|
|
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_RIFLE, true);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConUnWeapons(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
2011-08-13 00:11:06 +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
|
|
|
{
|
2011-12-25 13:51:04 +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
|
|
|
{
|
2011-12-25 13:51:04 +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,
|
|
|
|
int Weapon, bool Remove)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
return;
|
2011-08-26 18:03:30 +00:00
|
|
|
int ClientID = pResult->m_ClientID;
|
2011-12-25 13:51:04 +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",
|
|
|
|
"invalid weapon id");
|
2010-11-13 15:31:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-02-13 04:45:17 +00:00
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
CCharacter* pChr = GetPlayerChar(ClientID);
|
2011-12-25 13:51:04 +00:00
|
|
|
if (!pChr)
|
2010-11-13 15:31:13 +00:00
|
|
|
return;
|
2011-02-13 04:45:17 +00:00
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Weapon == -1)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Remove
|
|
|
|
&& (pChr->GetActiveWeapon() == WEAPON_SHOTGUN
|
|
|
|
|| pChr->GetActiveWeapon() == WEAPON_GRENADE
|
|
|
|
|| pChr->GetActiveWeapon() == WEAPON_RIFLE))
|
2011-01-29 00:59:50 +00:00
|
|
|
pChr->SetActiveWeapon(WEAPON_GUN);
|
2011-02-13 04:45:17 +00:00
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Remove)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-01-29 00:59:50 +00:00
|
|
|
pChr->SetWeaponGot(WEAPON_SHOTGUN, false);
|
|
|
|
pChr->SetWeaponGot(WEAPON_GRENADE, false);
|
|
|
|
pChr->SetWeaponGot(WEAPON_RIFLE, false);
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
|
|
|
else
|
2011-02-13 04:45:17 +00:00
|
|
|
pChr->GiveAllWeapons();
|
2010-11-13 15:31:13 +00:00
|
|
|
}
|
2011-12-25 13:51:04 +00:00
|
|
|
else if (Weapon != WEAPON_NINJA)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Remove && pChr->GetActiveWeapon() == Weapon)
|
2011-01-29 00:59:50 +00:00
|
|
|
pChr->SetActiveWeapon(WEAPON_GUN);
|
2011-02-13 04:45:17 +00:00
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Remove)
|
2011-01-29 00:59:50 +00:00
|
|
|
pChr->SetWeaponGot(Weapon, false);
|
2010-11-13 15:31:13 +00:00
|
|
|
else
|
|
|
|
pChr->GiveWeapon(Weapon, -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Remove)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info",
|
|
|
|
"you can't remove ninja");
|
2010-11-13 15:31:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-02-13 04:45:17 +00:00
|
|
|
|
2010-11-13 15:31:13 +00:00
|
|
|
pChr->GiveNinja();
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
unsigned int TeleTo = pResult->GetInteger(0);
|
|
|
|
|
|
|
|
if (((CGameControllerDDRace*)pSelf->m_pController)->m_TeleOuts[TeleTo-1].size())
|
|
|
|
{
|
|
|
|
int Num = ((CGameControllerDDRace*)pSelf->m_pController)->m_TeleOuts[TeleTo-1].size();
|
|
|
|
vec2 TelePos = ((CGameControllerDDRace*)pSelf->m_pController)->m_TeleOuts[TeleTo-1][(!Num)?Num:rand() % Num];
|
|
|
|
CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if (pChr)
|
|
|
|
{
|
|
|
|
pChr->Core()->m_Pos = TelePos;
|
|
|
|
pChr->m_DDRaceState = DDRACE_CHEAT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 21:36:55 +00:00
|
|
|
void CGameContext::ConToCheckTeleporter(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
unsigned int TeleTo = pResult->GetInteger(0);
|
|
|
|
|
|
|
|
if (((CGameControllerDDRace*)pSelf->m_pController)->m_TeleCheckOuts[TeleTo-1].size())
|
|
|
|
{
|
|
|
|
int Num = ((CGameControllerDDRace*)pSelf->m_pController)->m_TeleCheckOuts[TeleTo-1].size();
|
|
|
|
vec2 TelePos = ((CGameControllerDDRace*)pSelf->m_pController)->m_TeleCheckOuts[TeleTo-1][(!Num)?Num:rand() % Num];
|
|
|
|
CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
|
|
|
if (pChr)
|
|
|
|
{
|
|
|
|
pChr->Core()->m_Pos = TelePos;
|
|
|
|
pChr->m_DDRaceState = DDRACE_CHEAT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConTeleport(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
2013-07-29 19:25:10 +00:00
|
|
|
int TeleTo = pResult->GetInteger(0);
|
|
|
|
int Tele = pResult->m_ClientID;
|
|
|
|
if (pResult->NumArguments() > 0)
|
|
|
|
Tele = pResult->GetVictim();
|
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
if (pSelf->m_apPlayers[TeleTo])
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2013-07-29 19:25:10 +00:00
|
|
|
CCharacter* pChr = pSelf->GetPlayerChar(Tele);
|
|
|
|
if (pChr && pSelf->GetPlayerChar(TeleTo))
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-09-25 16:04:29 +00:00
|
|
|
pChr->Core()->m_Pos = pSelf->m_apPlayers[TeleTo]->m_ViewPos;
|
2014-05-07 02:13:59 +00:00
|
|
|
pChr->m_Pos = pSelf->m_apPlayers[TeleTo]->m_ViewPos;
|
|
|
|
pChr->m_PrevPos = pSelf->m_apPlayers[TeleTo]->m_ViewPos;
|
2011-09-25 16:04:29 +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::ConKill(IConsole::IResult *pResult, void *pUserData)
|
2010-11-13 15:31:13 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
if (!CheckClientID(pResult->m_ClientID))
|
|
|
|
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
|
|
|
|
2011-12-25 13:51:04 +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;
|
|
|
|
CServer* pServ = (CServer*)pSelf->Server();
|
2011-11-08 21:08:37 +00:00
|
|
|
int Victim = pResult->GetVictim();
|
2011-06-06 23:01:35 +00:00
|
|
|
int Seconds = 0;
|
2011-12-29 13:58:39 +00:00
|
|
|
if (pResult->NumArguments() > 0)
|
|
|
|
Seconds = clamp(pResult->GetInteger(0), 0, 360);
|
2011-06-06 20:18:37 +00:00
|
|
|
|
|
|
|
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
|
2011-12-29 13:58:39 +00:00
|
|
|
if (!pPlayer)
|
2011-06-06 20:18:37 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-29 13:58:39 +00:00
|
|
|
pPlayer->m_ForcePauseTime = Seconds*pServ->TickSpeed();
|
|
|
|
pPlayer->m_Paused = CPlayer::PAUSED_FORCE;
|
2011-06-06 20:18:37 +00:00
|
|
|
}
|
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
void CGameContext::Mute(IConsole::IResult *pResult, NETADDR *Addr, int Secs,
|
|
|
|
const char *pDisplayName)
|
2011-02-08 12:44:59 +00:00
|
|
|
{
|
|
|
|
char aBuf[128];
|
2011-02-23 21:39:53 +00:00
|
|
|
int Found = 0;
|
2011-02-08 12:44:59 +00:00
|
|
|
// find a matching mute for this ip, update expiration time if found
|
2011-12-25 13:51:04 +00:00
|
|
|
for (int i = 0; i < m_NumMutes; i++)
|
2011-02-23 21:39:53 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
if (net_addr_comp(&m_aMutes[i].m_Addr, Addr) == 0)
|
2011-02-23 21:39:53 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
m_aMutes[i].m_Expire = Server()->Tick()
|
|
|
|
+ Secs * Server()->TickSpeed();
|
2011-02-23 21:39:53 +00:00
|
|
|
Found = 1;
|
|
|
|
}
|
|
|
|
}
|
2011-02-08 12:44:59 +00:00
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
if (!Found) // nothing found so far, find a free slot..
|
2011-02-23 21:39:53 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
if (m_NumMutes < MAX_MUTES)
|
2011-02-23 21:39:53 +00:00
|
|
|
{
|
|
|
|
m_aMutes[m_NumMutes].m_Addr = *Addr;
|
2011-12-25 13:51:04 +00:00
|
|
|
m_aMutes[m_NumMutes].m_Expire = Server()->Tick()
|
|
|
|
+ Secs * Server()->TickSpeed();
|
2011-02-25 22:13:14 +00:00
|
|
|
m_NumMutes++;
|
2011-02-23 21:39:53 +00:00
|
|
|
Found = 1;
|
|
|
|
}
|
|
|
|
}
|
2011-12-25 13:51:04 +00:00
|
|
|
if (Found)
|
2011-02-08 12:44:59 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
str_format(aBuf, sizeof aBuf, "'%s' has been muted for %d seconds.",
|
|
|
|
pDisplayName, Secs);
|
2011-02-08 12:44:59 +00:00
|
|
|
SendChat(-1, CHAT_ALL, aBuf);
|
|
|
|
}
|
2011-12-26 09:15:43 +00:00
|
|
|
else // no free slot found
|
|
|
|
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", "mute array is full");
|
2011-02-08 12:44:59 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData)
|
2011-02-08 12:44:59 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
|
|
|
pSelf->Console()->Print(
|
|
|
|
IConsole::OUTPUT_LEVEL_STANDARD,
|
|
|
|
"mutes",
|
|
|
|
"Use either 'muteid <client_id> <seconds>' or 'muteip <ip> <seconds>'");
|
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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
2011-09-25 16:04:29 +00:00
|
|
|
int Victim = pResult->GetVictim();
|
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
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
pSelf->Mute(pResult, &Addr, clamp(pResult->GetInteger(0), 1, 86400),
|
|
|
|
pSelf->Server()->ClientName(Victim));
|
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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
2011-02-23 21:39:53 +00:00
|
|
|
NETADDR Addr;
|
2011-12-25 13:51:04 +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",
|
|
|
|
"Invalid network address to mute");
|
2011-02-23 21:39:53 +00:00
|
|
|
}
|
2011-12-25 13:51:04 +00:00
|
|
|
pSelf->Mute(pResult, &Addr, clamp(pResult->GetInteger(1), 1, 86400),
|
|
|
|
pResult->GetString(0));
|
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
|
|
|
{
|
2011-12-25 13:51:04 +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
|
|
|
|
2011-12-25 13:51:04 +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
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
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",
|
|
|
|
"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);
|
2011-12-25 13:51:04 +00:00
|
|
|
str_format(
|
|
|
|
aBuf,
|
|
|
|
sizeof aBuf,
|
|
|
|
"%d: \"%s\", %d seconds left",
|
|
|
|
i,
|
|
|
|
aIpBuf,
|
|
|
|
(pSelf->m_aMutes[i].m_Expire - pSelf->Server()->Tick())
|
|
|
|
/ pSelf->Server()->TickSpeed());
|
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
|
|
|
|
|
|
|
void CGameContext::ConList(IConsole::IResult *pResult, void *pUserData)
|
|
|
|
{
|
|
|
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
|
|
|
int ClientID = pResult->m_ClientID;
|
|
|
|
if(!CheckClientID(ClientID)) return;
|
|
|
|
|
|
|
|
char zerochar = 0;
|
|
|
|
if(pResult->NumArguments() > 0)
|
|
|
|
pSelf->List(ClientID, pResult->GetString(0));
|
|
|
|
else
|
|
|
|
pSelf->List(ClientID, &zerochar);
|
|
|
|
}
|