SvShotgunBulletSound

also added protection to shotgun stucks, needs to be tested when a random crazy shotgun bullet gets stuck
loaded the score file before saving to avoid corruption
added freeze and unfreeze in rcon
added protection in some rcon commands

Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
GreYFoXGTi 2010-08-23 23:40:23 +02:00
parent 05f8edb880
commit 51c6af1303
11 changed files with 166 additions and 48 deletions

View file

@ -933,14 +933,14 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
}
if(level != -1)
{
char buf[128]="Authentication successful. Remote console access granted, with level=%d";
char buf[128]="Authentication successful. Remote console access grantedfor cid=%d with level=%d";
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
Msg.AddInt(1);
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientId, true);
m_aClients[ClientId].m_Authed = level;
GameServer()->OnSetAuthed(ClientId, m_aClients[ClientId].m_Authed);
str_format(buf,sizeof(buf),buf,level);
str_format(buf,sizeof(buf),buf,ClientId,level);
SendRconLine(ClientId, buf);
dbg_msg("server", "ClientId=%d authed with Level=%d", ClientId, level);
m_aClients[ClientId].m_PwTries = 0;

View file

@ -8,6 +8,7 @@
//===============================
/* DDRace */
//MACRO_CONFIG_STR(SvEntities, sv_entities, 64, "Latest", CFGFLAG_SERVER, "The type of entities used") still need to think of a way
MACRO_CONFIG_INT(SvShotgunBulletSound, sv_shotgun_bullet_sound, 1, 0, 1, CFGFLAG_SERVER, "Annoying Shotgun sound on/off")
MACRO_CONFIG_INT(SvEndlessSuperHook, sv_endless_super_hook, 0, 0, 1, CFGFLAG_SERVER, "Endless hook for super players on/off")
MACRO_CONFIG_INT(SvEmotionalTees, sv_emotional_tees, 1, 0, 1, CFGFLAG_SERVER, "Emotional Tees on/off")
MACRO_CONFIG_INT(SvOldShotgun, sv_old_shotgun, 0, 0, 1, CFGFLAG_SERVER, "Makes Shotgun laser pull towards the shooter, rather than the last bounce origin")

View file

@ -61,7 +61,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_ActiveWeapon = WEAPON_GUN;
m_LastWeapon = WEAPON_HAMMER;
m_QueuedWeapon = -1;
m_pPlayer = pPlayer;
m_Pos = Pos;
m_OlderPos = Pos;
@ -79,7 +79,8 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
GameServer()->m_World.InsertEntity(this);
m_Alive = true;
dbg_msg("m_RconFreeze","%d",m_pPlayer->m_RconFreeze);
if(m_pPlayer->m_RconFreeze) Freeze(-1);
GameServer()->m_pController->OnCharacterSpawn(this);
return true;
@ -559,19 +560,24 @@ void CCharacter::Tick()
m_pPlayer->m_ForceBalanced = false;
}
m_Armor=10-(m_FreezeTime/15);
m_Armor=(m_FreezeTime != -1)?10-(m_FreezeTime/15):0;
if(m_Input.m_Direction != 0 || m_Input.m_Jump != 0)
m_LastMove = Server()->Tick();
if(m_FreezeTime > 0) {
if (m_FreezeTime % Server()->TickSpeed() == 0)
if(m_FreezeTime > 0 || m_FreezeTime == -1)
{
if (m_FreezeTime % Server()->TickSpeed() == 0 || m_FreezeTime == -1)
{
GameServer()->CreateDamageInd(m_Pos, 0, m_FreezeTime / Server()->TickSpeed());
}
m_FreezeTime--;
(m_FreezeTime != -1)?m_FreezeTime--:0;
m_Input.m_Direction = 0;
m_Input.m_Jump = 0;
m_Input.m_Hook = 0;
m_Ninja.m_ActivationTick = Server()->Tick();
m_aWeapons[WEAPON_NINJA].m_Got=true;
m_aWeapons[WEAPON_NINJA].m_Ammo =0;
m_ActiveWeapon=WEAPON_NINJA;
//m_Input.m_Fire = 0;
if (m_FreezeTime == 1) {
UnFreeze();
@ -944,7 +950,7 @@ void CCharacter::TickDefered()
bool CCharacter::Freeze(int Time)
{
if (Time <= 1 || m_Super)
if ((Time <= 1 || m_Super || m_FreezeTime == -1) && Time != -1)
return false;
if (m_FreezeTick < Server()->Tick() - Server()->TickSpeed())
{
@ -964,7 +970,7 @@ bool CCharacter::Freeze(int Time)
bool CCharacter::Freeze()
{
int Time = Server()->TickSpeed()*3;
if (Time <= 1 || m_Super)
if (Time <= 1 || m_Super || m_FreezeTime == -1)
return false;
if (m_FreezeTick < Server()->Tick() - Server()->TickSpeed())
{

View file

@ -72,9 +72,12 @@ void CPickup::Tick()
{
if (pChr->m_aWeapons[i].m_Got)
{
pChr->m_aWeapons[i].m_Got = false;
pChr->m_aWeapons[i].m_Ammo = 0;
sound = true;
if(!(pChr->m_FreezeTime && i == WEAPON_NINJA))
{
pChr->m_aWeapons[i].m_Got = false;
pChr->m_aWeapons[i].m_Ammo = 0;
sound = true;
}
}
if(pChr->m_FreezeTime)
{
@ -90,7 +93,7 @@ void CPickup::Tick()
pChr->m_LastWeapon = WEAPON_GUN;
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
}
pChr->m_ActiveWeapon = WEAPON_HAMMER;
if(!pChr->m_FreezeTime) pChr->m_ActiveWeapon = WEAPON_HAMMER;
break;
case POWERUP_WEAPON:
@ -117,7 +120,7 @@ void CPickup::Tick()
case POWERUP_NINJA:
{
// activate ninja on target player
pChr->GiveNinja();
if(!pChr->m_FreezeTime) pChr->GiveNinja();
//RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
break;

View file

@ -3,8 +3,18 @@
#include <engine/shared/config.h>
#include "projectile.h"
CProjectile::CProjectile(CGameWorld *pGameWorld, int Type, int Owner, vec2 Pos, vec2 Dir, int Span,
bool Freeze, bool Explosive, float Force, int SoundImpact, int Weapon)
CProjectile::CProjectile(
CGameWorld *pGameWorld,
int Type,
int Owner,
vec2 Pos,
vec2 Dir,
int Span,
bool Freeze,
bool Explosive,
float Force,
int SoundImpact,
int Weapon)
: CEntity(pGameWorld, NETOBJTYPE_PROJECTILE)
{
m_Type = Type;
@ -19,6 +29,11 @@ CProjectile::CProjectile(CGameWorld *pGameWorld, int Type, int Owner, vec2 Pos,
m_Weapon = Weapon;
m_StartTick = Server()->Tick();
m_Explosive = Explosive;
m_BouncePos=vec2(0,0);
m_ReBouncePos=vec2(0,0);
m_AvgPos=vec2(0,0);
m_LastBounce=vec2(0,0);
m_PrevLastBounce=vec2(0,0);
GameWorld()->InsertEntity(this);
}
@ -55,7 +70,8 @@ vec2 CProjectile::GetPos(float Time)
return CalcPos(m_Pos, m_Direction, Curvature, Speed, Time);
}
void CProjectile::SetBouncing(int Value) {
void CProjectile::SetBouncing(int Value)
{
m_Bouncing = Value;
}
@ -96,9 +112,27 @@ void CProjectile::Tick()
m_StartTick = Server()->Tick();
m_Pos = NewPos;
if (m_Bouncing == 1)
{
m_Direction.x = -m_Direction.x;
m_LastBounce = m_Pos;
if(!m_BouncePos.x)
m_BouncePos=m_Pos;
else if (!m_ReBouncePos.x)
m_ReBouncePos=m_Pos;
else if(!m_AvgPos.x)
m_AvgPos = vec2((m_BouncePos.x+m_ReBouncePos.x)/2,(m_BouncePos.y+m_ReBouncePos.y)/2);
}
else if (m_Bouncing == 2)
{
m_LastBounce = m_Pos;
m_Direction.y =- m_Direction.y;
if(!m_BouncePos.y)
m_BouncePos=m_Pos;
else if (!m_ReBouncePos.y)
m_ReBouncePos=m_Pos;
else if(!m_AvgPos.y)
m_AvgPos = vec2((m_BouncePos.x+m_ReBouncePos.x)/2,(m_BouncePos.y+m_ReBouncePos.y)/2);
}
m_Pos += m_Direction;
}
else if (m_Weapon == WEAPON_GUN)
@ -114,6 +148,10 @@ void CProjectile::Tick()
{
GameServer()->m_World.DestroyEntity(this);
}
if((!(m_PrevLastBounce == m_BouncePos && m_LastBounce == m_ReBouncePos) && !(m_LastBounce == m_BouncePos && m_PrevLastBounce == m_ReBouncePos))&&m_AvgPos.x)
m_Pos=m_AvgPos;
m_PrevLastBounce=m_LastBounce;
}
void CProjectile::FillInfo(CNetObj_Projectile *pProj)

View file

@ -29,6 +29,11 @@ private:
int m_Bouncing;
bool m_Freeze;
bool m_Collised;
vec2 m_AvgPos;
vec2 m_BouncePos;
vec2 m_ReBouncePos;
vec2 m_LastBounce;
vec2 m_PrevLastBounce;
};
#endif

View file

@ -1350,7 +1350,7 @@ void CGameContext::ConSetlvl(IConsole::IResult *pResult, void *pUserData, int c
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
int level = clamp(pResult->GetInteger(1), 0, 3);
if (pSelf->m_apPlayers[cid1] && (pSelf->m_apPlayers[cid1]->m_Authed > level) && (compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1])))
if (pSelf->m_apPlayers[cid1] && (pSelf->m_apPlayers[cid1]->m_Authed > level) && (compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]) || cid == cid1))
{
pSelf->m_apPlayers[cid1]->m_Authed = level;
}
@ -1388,10 +1388,14 @@ void CGameContext::ConNinja(IConsole::IResult *pResult, void *pUserData, int cid
if(!pSelf->CheatsAvailable(cid)) return;
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if(chr) {
chr->GiveNinja();
if(!g_Config.m_SvCheatTime)
chr->m_RaceState = RACE_CHEAT;
if(chr)
{
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
{
chr->GiveNinja();
if(!g_Config.m_SvCheatTime)
chr->m_RaceState = RACE_CHEAT;
}
}
}
@ -1414,11 +1418,14 @@ void CGameContext::ConHammer(IConsole::IResult *pResult, void *pUserData, int ci
}
else
{
chr->m_HammerType = type;
if(!g_Config.m_SvCheatTime)
chr->m_RaceState = RACE_CHEAT;
str_format(buf, sizeof(buf), "Hammer of cid=%d setted to %d",cid1,type);
serv->SendRconLine(cid1, buf);
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
{
chr->m_HammerType = type;
if(!g_Config.m_SvCheatTime)
chr->m_RaceState = RACE_CHEAT;
str_format(buf, sizeof(buf), "Hammer of cid=%d setted to %d",cid1,type);
serv->SendRconLine(cid1, buf);
}
}
}
@ -1458,6 +1465,7 @@ void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData, int cid
if(chr)
{
chr->m_Super = true;
chr->UnFreeze();
if(!g_Config.m_SvCheatTime)
chr->m_RaceState = RACE_CHEAT;
}
@ -1489,6 +1497,7 @@ void CGameContext::ConSuperMe(IConsole::IResult *pResult, void *pUserData, int c
if(chr)
{
chr->m_Super = true;
chr->UnFreeze();
if(!g_Config.m_SvCheatTime)
chr->m_RaceState = RACE_CHEAT;
}
@ -1573,9 +1582,12 @@ void CGameContext::ConTimerStop(IConsole::IResult *pResult, void *pUserData, int
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
chr->m_RaceState=RACE_CHEAT;
str_format(buf, sizeof(buf), "Cid=%d Hasn't time now (Timer Stopped)",cid1);
serv->SendRconLine(cid1, buf);
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
{
chr->m_RaceState=RACE_CHEAT;
str_format(buf, sizeof(buf), "Cid=%d Hasn't time now (Timer Stopped)",cid1);
serv->SendRconLine(cid1, buf);
}
}
else
{
@ -1596,9 +1608,12 @@ void CGameContext::ConTimerStart(IConsole::IResult *pResult, void *pUserData, in
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
chr->m_RaceState = RACE_STARTED;
str_format(buf, sizeof(buf), "Cid=%d Has time now (Timer Started)",cid1);
serv->SendRconLine(cid1, buf);
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
{
chr->m_RaceState = RACE_STARTED;
str_format(buf, sizeof(buf), "Cid=%d Has time now (Timer Started)",cid1);
serv->SendRconLine(cid1, buf);
}
}
else
{
@ -1618,12 +1633,15 @@ void CGameContext::ConTimerZero(IConsole::IResult *pResult, void *pUserData, int
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
chr->m_StartTime = pSelf->Server()->Tick();
chr->m_RefreshTime = pSelf->Server()->Tick();
chr->m_RaceState=RACE_CHEAT;
str_format(buf, sizeof(buf), "Cid=%d time has been reset & stopped.",cid1);
CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf);
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
{
chr->m_StartTime = pSelf->Server()->Tick();
chr->m_RefreshTime = pSelf->Server()->Tick();
chr->m_RaceState=RACE_CHEAT;
str_format(buf, sizeof(buf), "Cid=%d time has been reset & stopped.",cid1);
CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf);
}
}
@ -1638,10 +1656,53 @@ void CGameContext::ConTimerReStart(IConsole::IResult *pResult, void *pUserData,
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
chr->m_StartTime = pSelf->Server()->Tick();
chr->m_RefreshTime = pSelf->Server()->Tick();
chr->m_RaceState=RACE_STARTED;
str_format(buf, sizeof(buf), "Cid=%d time has been reset & stopped.",cid1);
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
{
chr->m_StartTime = pSelf->Server()->Tick();
chr->m_RefreshTime = pSelf->Server()->Tick();
chr->m_RaceState=RACE_STARTED;
str_format(buf, sizeof(buf), "Cid=%d time has been reset & stopped.",cid1);
CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf);
}
}
void CGameContext::ConFreeze(IConsole::IResult *pResult, void *pUserData, int cid)
{
CGameContext *pSelf = (CGameContext *)pUserData;
//if(!pSelf->CheatsAvailable(cid)) return;
char buf[128];
int time=-1;
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
if(pResult->NumArguments()>1)
time = clamp(pResult->GetInteger(1), -1, 29999);
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
{
chr->Freeze(((time!=0&&time!=-1)?(pSelf->Server()->TickSpeed()*time):(-1)));
chr->m_pPlayer->m_RconFreeze = true;
str_format(buf, sizeof(buf), "Cid=%d has been Frozen.",cid1);
CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf);
}
}
void CGameContext::ConUnFreeze(IConsole::IResult *pResult, void *pUserData, int cid)
{
CGameContext *pSelf = (CGameContext *)pUserData;
//if(!pSelf->CheatsAvailable(cid)) return;
char buf[128];
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
chr->m_FreezeTime=2;
chr->m_pPlayer->m_RconFreeze = false;
str_format(buf, sizeof(buf), "Cid=%d has been UnFreezed.",cid1);
CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf);
@ -1651,7 +1712,8 @@ void CGameContext::OnConsoleInit()
{
m_pServer = Kernel()->RequestInterface<IServer>();
m_pConsole = Kernel()->RequestInterface<IConsole>();
Console()->Register("freeze", "i?i", CFGFLAG_SERVER, ConFreeze, this, "Freezes Player i1 for i2 seconds Default Infinity",2);
Console()->Register("unfreeze", "i", CFGFLAG_SERVER, ConUnFreeze, this, "UnFreezes Player i",2);
Console()->Register("timerstop", "i", CFGFLAG_SERVER, ConTimerStop, this, "Stops The Timer of Player i",2);
Console()->Register("timerstart", "i", CFGFLAG_SERVER, ConTimerStart, this, "Starts The Timer of Player i",2);
Console()->Register("timerrestart", "i", CFGFLAG_SERVER, ConTimerReStart, this, "Starts The Timer of Player i with the time of 00:00:00",2);

View file

@ -68,6 +68,8 @@ class CGameContext : public IGameServer
static void ConPhook(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConFreeze(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConUnFreeze(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerStop(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerStart(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerReStart(IConsole::IResult *pResult, void *pUserData, int cid);

View file

@ -179,7 +179,7 @@ bool IGameController::OnEntity(int Index, vec2 Pos, bool Front)
true, //Freeze
true, //Explosive
0,
SOUND_GRENADE_EXPLODE,
(g_Config.m_SvShotgunBulletSound)?SOUND_GRENADE_EXPLODE:-1,
WEAPON_SHOTGUN);
bullet->SetBouncing(2 - (i % 2));

View file

@ -120,7 +120,7 @@ public:
int m_SentAfkWarning; // afk timer's 1st warning after 50% of sv_max_afk_time
int m_SentAfkWarning2; // afk timer's 2nd warning after 90% of sv_max_afk_time
char m_pAfkMsg[160];
bool m_RconFreeze;
private:
CCharacter *Character;
CGameContext *m_pGameServer;

View file

@ -106,6 +106,7 @@ CPlayerScore *CScore::SearchName(const char *name)
void CScore::ParsePlayer(const char *name, float score)
{
Load();
CPlayerScore *player = SearchName(name);
if (player)
{
@ -131,7 +132,7 @@ std::list<std::string> CScore::Top5Draw(int id, int debut) //Thanks nevi
//char buf[512];
res.push_back("----------- Top 5 -----------");
for (std::list<CPlayerScore>::iterator i = top.begin(); i != top.end() && pos <= 5+debut; i++)
for (std::list<CPlayerScore>::iterator i = top.begin(); i != top.end() && pos <= ((debut)?4:5)+debut; i++)
{
if(i->m_Score < 0)
continue;