Skip to content

Commit

Permalink
Implement item sell delay and enable/disable option to config. close #35
Browse files Browse the repository at this point in the history
  • Loading branch information
digz6666 committed Jan 31, 2014
1 parent 443d8a7 commit a4c1c89
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 13 deletions.
14 changes: 9 additions & 5 deletions src/server/game/Handlers/ItemHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "Common.h"
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "Opcodes.h"
Expand Down Expand Up @@ -489,11 +490,14 @@ void WorldSession::HandleSellItemOpcode(WorldPacket & recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_SELL_ITEM");

time_t now = time(NULL);
if (now - timeLastSellItemOpcode < 5)
return;
else
timeLastSellItemOpcode = now;
if(sWorld->getBoolConfig(CONFIG_ANTISPAM_VENDOR_ENABLE))
{
time_t now = time(NULL);
if (now - timeLastSellItemOpcode < sWorld->getIntConfig(CONFIG_ANTISPAM_VENDOR_DELAY))
return;
else
timeLastSellItemOpcode = now;
}

uint64 vendorguid = 0;
uint64 itemguid = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/server/game/World/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,10 @@ void World::LoadConfigSettings(bool reload)
m_int_configs[CONFIG_ANTISPAM_MAIL_TIMER] = ConfigMgr::GetIntDefault("Antispam.Mail.Timer", 3600) * IN_MILLISECONDS;
m_int_configs[CONFIG_ANTISPAM_MAIL_COUNT] = ConfigMgr::GetIntDefault("Antispam.Mail.Count", 10);

// Vendor sell item anti spam
m_bool_configs[CONFIG_ANTISPAM_VENDOR_ENABLE] = ConfigMgr::GetBoolDefault("Antispam.Vendor.Enable", false);
m_int_configs[CONFIG_ANTISPAM_VENDOR_DELAY] = ConfigMgr::GetIntDefault("Antispam.Vendor.Delay", 5);

if (reload)
sScriptMgr->OnConfigLoad(reload);
}
Expand Down
2 changes: 2 additions & 0 deletions src/server/game/World/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ enum WorldBoolConfigs
CONFIG_VIP_EXCHANGE_FROST_COMMAND,
CONFIG_ANTISPAM_ENABLED,
CONFIG_DISABLE_RESTART,
CONFIG_ANTISPAM_VENDOR_ENABLE,
BOOL_CONFIG_VALUE_COUNT
};

Expand Down Expand Up @@ -381,6 +382,7 @@ enum WorldIntConfigs
CONFIG_ANTISPAM_MAIL_TIMER,
CONFIG_ANTISPAM_MAIL_COUNT,
CONFIG_AUTO_SERVER_RESTART_HOUR,
CONFIG_ANTISPAM_VENDOR_DELAY,
INT_CONFIG_VALUE_COUNT
};

Expand Down
12 changes: 4 additions & 8 deletions src/server/scripts/Spells/spell_warrior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,11 @@ class spell_warr_storm_bolt : public SpellScriptLoader
{
if (Player* _player = GetCaster()->ToPlayer())
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(WARRIOR_SPELL_STORM_BOLT_STUN);
if (spellInfo)
if (Unit* unitTarget = GetHitUnit())
{
if (Unit* unitTarget = GetHitUnit())
{
if (unitTarget->IsImmunedToSpellEffect(spellInfo, 0))
SetHitDamage(GetHitDamage() * 4);
_player->CastSpell(unitTarget, WARRIOR_SPELL_STORM_BOLT_STUN, true);
}
if (unitTarget->IsImmunedToSpellEffect(sSpellMgr->GetSpellInfo(WARRIOR_SPELL_STORM_BOLT_STUN), 0))
SetHitDamage(GetHitDamage() * 4);
_player->CastSpell(unitTarget, WARRIOR_SPELL_STORM_BOLT_STUN, true);
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/server/worldserver/worldserver.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3049,6 +3049,21 @@ Antispam.Mail.Timer = 3600

Antispam.Mail.Count = 12

#
# Antispam.Vendor.Enable
# Description: Enable or disable vendor item sell anti spam system
# Default: 0 - (Disabled)
# 1 - (Enabled)

Antispam.Vendor.Enable = 1

#
# Antispam.Vendor.Delay
# Description: Number of seconds to wait until next item sell
# Default: 5

Antispam.Vendor.Delay = 5

#
# DisableRestart
# Description: Disable server restart.
Expand Down

2 comments on commit a4c1c89

@3DViking
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you update -> src/server/scripts/Spells/spell_warrior.cpp

@Kittnz
Copy link
Contributor

@Kittnz Kittnz commented on a4c1c89 Mar 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this should be a seperate commit. There isn't much change in it tho.

Please sign in to comment.