mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Server: Fix a spammy warning in WorldSession and move code to .cpp
This commit is contained in:
@@ -1221,3 +1221,40 @@ void WorldSession::InvalidateRBACData()
|
||||
delete _RBACData;
|
||||
_RBACData = NULL;
|
||||
}
|
||||
|
||||
bool WorldSession::DosProtection::EvaluateOpcode(WorldPacket& p) const
|
||||
{
|
||||
if (IsOpcodeAllowed(p.GetOpcode()))
|
||||
return true;
|
||||
|
||||
// Opcode not allowed, let the punishment begin
|
||||
TC_LOG_INFO(LOG_FILTER_NETWORKIO, "AntiDOS: Account %u, IP: %s, sent unacceptable packet (opc: %u, size: %u)",
|
||||
Session->GetAccountId(), Session->GetRemoteAddress().c_str(), p.GetOpcode(), (uint32)p.size());
|
||||
|
||||
switch (_policy)
|
||||
{
|
||||
case POLICY_LOG:
|
||||
return true;
|
||||
case POLICY_KICK:
|
||||
TC_LOG_INFO(LOG_FILTER_NETWORKIO, "AntiDOS: Player kicked!");
|
||||
return false;
|
||||
case POLICY_BAN:
|
||||
{
|
||||
BanMode bm = (BanMode)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_BANMODE);
|
||||
uin32 duration = sWorld->getIntConfig(CONFIG_PACKET_SPOOF_BANDURATION); // in seconds
|
||||
std::string nameOrIp = "";
|
||||
switch (bm)
|
||||
{
|
||||
case BAN_CHARACTER: // not supported, ban account
|
||||
case BAN_ACCOUNT: (void)sAccountMgr->GetName(Session->GetAccountId(), nameOrIp); break;
|
||||
case BAN_IP: nameOrIp = Session->GetRemoteAddress(); break;
|
||||
}
|
||||
sWorld->BanAccount(bm, nameOrIp, duration, "DOS (Packet Flooding/Spoofing", "Server: AutoDOS");
|
||||
sLog->outInfo(LOG_FILTER_NETWORKIO, "AntiDOS: Player automatically banned for %u seconds.", duration);
|
||||
|
||||
return false;
|
||||
}
|
||||
default: // invalid policy
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -919,49 +919,8 @@ class WorldSession
|
||||
friend class World;
|
||||
public:
|
||||
DosProtection(WorldSession* s) : Session(s), _policy((Policy)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_POLICY)) {}
|
||||
|
||||
bool EvaluateOpcode(WorldPacket& p) const
|
||||
{
|
||||
if (IsOpcodeAllowed(p.GetOpcode()))
|
||||
return true;
|
||||
|
||||
// Opcode not allowed, let the punishment begin
|
||||
TC_LOG_INFO(LOG_FILTER_NETWORKIO, "AntiDOS: Account %u, IP: %s, sent unacceptable packet (opc: %u, size: %u)",
|
||||
Session->GetAccountId(), Session->GetRemoteAddress().c_str(), p.GetOpcode(), (uint32)p.size());
|
||||
|
||||
switch (_policy)
|
||||
{
|
||||
case POLICY_LOG:
|
||||
return true;
|
||||
case POLICY_KICK:
|
||||
TC_LOG_INFO(LOG_FILTER_NETWORKIO, "AntiDOS: Player kicked!");
|
||||
return false;
|
||||
case POLICY_BAN:
|
||||
{
|
||||
BanMode bm = (BanMode)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_BANMODE);
|
||||
int64 duration = (int64)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_BANDURATION); // in seconds
|
||||
std::string nameOrIp = "";
|
||||
switch (bm)
|
||||
{
|
||||
case BAN_CHARACTER: // not supported, ban account
|
||||
case BAN_ACCOUNT: (void)sAccountMgr->GetName(Session->GetAccountId(), nameOrIp); break;
|
||||
case BAN_IP: nameOrIp = Session->GetRemoteAddress(); break;
|
||||
}
|
||||
sWorld->BanAccount(bm, nameOrIp, duration, "DOS (Packet Flooding/Spoofing", "Server: AutoDOS");
|
||||
sLog->outInfo(LOG_FILTER_NETWORKIO, "AntiDOS: Player automatically banned for "I64FMT" seconds.", duration);
|
||||
|
||||
return false;
|
||||
}
|
||||
default: // invalid policy
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void AllowOpcode(uint16 opcode, bool allow)
|
||||
{
|
||||
_isOpcodeAllowed[opcode] = allow;
|
||||
}
|
||||
|
||||
bool EvaluateOpcode(WorldPacket& p) const;
|
||||
void AllowOpcode(uint16 opcode, bool allow) { _isOpcodeAllowed[opcode] = allow; }
|
||||
protected:
|
||||
enum Policy
|
||||
{
|
||||
|
||||
@@ -1967,67 +1967,67 @@ enum EscapeFromSilverbrook
|
||||
{
|
||||
SPELL_SUMMON_WORGEN = 48681
|
||||
};
|
||||
|
||||
|
||||
// 48682 - Escape from Silverbrook - Periodic Dummy
|
||||
class spell_q12308_escape_from_silverbrook : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_q12308_escape_from_silverbrook() : SpellScriptLoader("spell_q12308_escape_from_silverbrook") { }
|
||||
|
||||
|
||||
class spell_q12308_escape_from_silverbrook_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_q12308_escape_from_silverbrook_SpellScript);
|
||||
|
||||
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
|
||||
{
|
||||
if (!sSpellMgr->GetSpellInfo(SPELL_SUMMON_WORGEN))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
GetCaster()->CastSpell(GetCaster(), SPELL_SUMMON_WORGEN, true);
|
||||
}
|
||||
|
||||
|
||||
void Register() OVERRIDE
|
||||
{
|
||||
OnEffectHit += SpellEffectFn(spell_q12308_escape_from_silverbrook_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
SpellScript* GetSpellScript() const OVERRIDE
|
||||
{
|
||||
return new spell_q12308_escape_from_silverbrook_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 48681 - Summon Silverbrook Worgen
|
||||
class spell_q12308_escape_from_silverbrook_summon_worgen : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_q12308_escape_from_silverbrook_summon_worgen() : SpellScriptLoader("spell_q12308_escape_from_silverbrook_summon_worgen") { }
|
||||
|
||||
|
||||
class spell_q12308_escape_from_silverbrook_summon_worgen_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_q12308_escape_from_silverbrook_summon_worgen_SpellScript);
|
||||
|
||||
|
||||
void ModDest(SpellEffIndex effIndex)
|
||||
{
|
||||
float dist = GetSpellInfo()->Effects[effIndex].CalcRadius(GetCaster());
|
||||
float angle = (urand(0, 1) ? -1 : 1) * (frand(0.75f, 1.0f) * M_PI);
|
||||
|
||||
|
||||
Position pos;
|
||||
GetCaster()->GetNearPosition(pos, dist, angle);
|
||||
GetHitDest()->Relocate(&pos);
|
||||
}
|
||||
|
||||
|
||||
void Register() OVERRIDE
|
||||
{
|
||||
OnEffectHit += SpellEffectFn(spell_q12308_escape_from_silverbrook_summon_worgen_SpellScript::ModDest, EFFECT_0, SPELL_EFFECT_SUMMON);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
SpellScript* GetSpellScript() const OVERRIDE
|
||||
{
|
||||
return new spell_q12308_escape_from_silverbrook_summon_worgen_SpellScript();
|
||||
|
||||
@@ -58,7 +58,7 @@ void BigNumber::SetQword(uint64 val)
|
||||
void BigNumber::SetBinary(uint8 const* bytes, int32 len)
|
||||
{
|
||||
uint8* array = new uint8[len];
|
||||
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
array[i] = bytes[len - 1 - i];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user