aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/AI/CoreAI/UnitAI.cpp24
-rwxr-xr-xsrc/server/game/Scripting/MapScripts.cpp1
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/CharacterHandler.cpp22
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp5
4 files changed, 23 insertions, 29 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp
index b6517e3396b..39bdf219880 100755
--- a/src/server/game/AI/CoreAI/UnitAI.cpp
+++ b/src/server/game/AI/CoreAI/UnitAI.cpp
@@ -43,27 +43,17 @@ void UnitAI::DoMeleeAttackIfReady()
return;
Unit *victim = me->getVictim();
- if (!victim || !victim->IsInWorld())
- return;
-
//Make sure our attack is ready and we aren't currently casting before checking distance
- if (me->isAttackReady())
+ if (me->isAttackReady() && me->IsWithinMeleeRange(victim))
{
- //If we are within range melee the target
- if (me->IsWithinMeleeRange(victim))
- {
- me->AttackerStateUpdate(victim);
- me->resetAttackTimer();
- }
+ me->AttackerStateUpdate(victim);
+ me->resetAttackTimer();
}
- if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK))
+
+ if (me->haveOffhandWeapon() && me->isAttackReady(OFF_ATTACK) && me->IsWithinMeleeRange(victim))
{
- //If we are within range melee the target
- if (me->IsWithinMeleeRange(victim))
- {
- me->AttackerStateUpdate(victim, OFF_ATTACK);
- me->resetAttackTimer(OFF_ATTACK);
- }
+ me->AttackerStateUpdate(victim, OFF_ATTACK);
+ me->resetAttackTimer(OFF_ATTACK);
}
}
diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp
index f5e6f3f320e..8efca3a8658 100755
--- a/src/server/game/Scripting/MapScripts.cpp
+++ b/src/server/game/Scripting/MapScripts.cpp
@@ -306,6 +306,7 @@ void Map::ScriptsProcess()
source = player->GetItemByGuid(step.sourceGUID);
break;
case HIGHGUID_UNIT:
+ case HIGHGUID_VEHICLE:
source = HashMapHolder<Creature>::Find(step.sourceGUID);
break;
case HIGHGUID_PET:
diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
index 69024837d61..1d6e9bf5722 100755
--- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
@@ -636,12 +636,11 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
sLog->outDebug(LOG_FILTER_NETWORKIO, "Character creation %s (account %u) has unhandled tail data: [%u]", createInfo->Name.c_str(), GetAccountId(), unk);
}
- Player* pNewChar = new Player(this);
- if (!pNewChar->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PLAYER), createInfo))
+ Player newChar(this);
+ if (!newChar.Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PLAYER), createInfo))
{
// Player not create (race/class/etc problem?)
- pNewChar->CleanupsBeforeDelete();
- delete pNewChar;
+ newChar.CleanupsBeforeDelete();
WorldPacket data(SMSG_CHAR_CREATE, 1);
data << uint8(CHAR_CREATE_ERROR);
@@ -653,12 +652,12 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
}
if ((haveSameRace && skipCinematics == 1) || skipCinematics == 2)
- pNewChar->setCinematic(1); // not show intro
+ newChar.setCinematic(1); // not show intro
- pNewChar->SetAtLoginFlag(AT_LOGIN_FIRST); // First login
+ newChar.SetAtLoginFlag(AT_LOGIN_FIRST); // First login
// Player created, save it now
- pNewChar->SaveToDB();
+ newChar.SaveToDB();
createInfo->CharCount += 1;
SQLTransaction trans = LoginDatabase.BeginTransaction();
@@ -676,18 +675,17 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
LoginDatabase.CommitTransaction(trans);
- pNewChar->CleanupsBeforeDelete();
+ newChar.CleanupsBeforeDelete();
WorldPacket data(SMSG_CHAR_CREATE, 1);
data << uint8(CHAR_CREATE_SUCCESS);
SendPacket(&data);
std::string IP_str = GetRemoteAddress();
- sLog->outDetail("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), pNewChar->GetGUIDLow());
- sLog->outChar("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), pNewChar->GetGUIDLow());
- sScriptMgr->OnPlayerCreate(pNewChar);
+ sLog->outDetail("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
+ sLog->outChar("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
+ sScriptMgr->OnPlayerCreate(&newChar);
- delete pNewChar; // created only to call SaveToDB()
delete createInfo;
_charCreateCallback.SetParam(NULL);
_charCreateCallback.FreeResult();
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 6d10f40ae58..d456cfdcf47 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4752,6 +4752,11 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_DONT_REPORT;
}
+ // Don't check explicit target for passive spells (workaround) (check should be skipped only for learn case)
+ // those spells may have incorrect target entries or not filled at all (for example 15332)
+ // such spells when learned are not targeting anyone using targeting system, they should apply directly to caster instead
+ // also, such casts shouldn't be sent to client
+ if (!((m_spellInfo->Attributes & SPELL_ATTR0_PASSIVE) && !m_targets.GetUnitTarget() || m_targets.GetUnitTarget() == m_caster))
{
// Check explicit target for m_originalCaster - todo: get rid of such workarounds
SpellCastResult castResult = m_spellInfo->CheckExplicitTarget(m_originalCaster ? m_originalCaster : m_caster, m_targets.GetObjectTarget(), m_targets.GetItemTarget());