diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/authserver/Server/AuthSocket.cpp | 12 | ||||
-rw-r--r-- | src/server/game/DataStores/DBCEnums.h | 6 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 2 | ||||
-rw-r--r-- | src/server/game/Handlers/MiscHandler.cpp | 1 | ||||
-rw-r--r-- | src/server/game/Handlers/NPCHandler.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Movement/MotionMaster.cpp | 5 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 74 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 2 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 61 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 198 | ||||
-rw-r--r-- | src/server/game/Spells/SpellScript.cpp | 16 | ||||
-rw-r--r-- | src/server/game/Spells/SpellScript.h | 3 | ||||
-rw-r--r-- | src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp | 1 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_dk.cpp | 160 | ||||
-rw-r--r-- | src/server/shared/CompilerDefs.h | 2 | ||||
-rw-r--r-- | src/server/shared/Utilities/ByteConverter.h | 4 | ||||
-rw-r--r-- | src/server/shared/Utilities/Util.cpp | 3 |
18 files changed, 239 insertions, 317 deletions
diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index 8a2a6c67496..c7bb600024a 100644 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -321,7 +321,7 @@ bool AuthSocket::_HandleLogonChallenge() socket().recv((char *)&buf[0], 4); - EndianConvert(*((uint16*)(buf[0]))); + EndianConvertPtr<uint16>(&buf[0]); uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size; TC_LOG_DEBUG("server.authserver", "[AuthChallenge] got header, body is %#04x bytes", remaining); @@ -341,11 +341,11 @@ bool AuthSocket::_HandleLogonChallenge() // BigEndian code, nop in little endian case // size already converted - EndianConvert(*((uint32*)(&ch->gamename[0]))); + EndianConvertPtr<uint32>(&ch->gamename[0]); EndianConvert(ch->build); - EndianConvert(*((uint32*)(&ch->platform[0]))); - EndianConvert(*((uint32*)(&ch->os[0]))); - EndianConvert(*((uint32*)(&ch->country[0]))); + EndianConvertPtr<uint32>(&ch->platform[0]); + EndianConvertPtr<uint32>(&ch->os[0]); + EndianConvertPtr<uint32>(&ch->country[0]); EndianConvert(ch->timezone_bias); EndianConvert(ch->ip); @@ -779,7 +779,7 @@ bool AuthSocket::_HandleReconnectChallenge() socket().recv((char *)&buf[0], 4); - EndianConvert(*((uint16*)(buf[0]))); + EndianConvertPtr<uint16>(&buf[0]); uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size; TC_LOG_DEBUG("server.authserver", "[ReconnectChallenge] got header, body is %#04x bytes", remaining); diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h index 73319d5eefd..c650da7c83b 100644 --- a/src/server/game/DataStores/DBCEnums.h +++ b/src/server/game/DataStores/DBCEnums.h @@ -151,9 +151,9 @@ enum AchievementCriteriaFlags { ACHIEVEMENT_CRITERIA_FLAG_SHOW_PROGRESS_BAR = 0x00000001, // Show progress as bar ACHIEVEMENT_CRITERIA_FLAG_HIDDEN = 0x00000002, // Not show criteria in client - ACHIEVEMENT_CRITERIA_FLAG_UNK3 = 0x00000004, // BG related?? - ACHIEVEMENT_CRITERIA_FLAG_UNK4 = 0x00000008, // - ACHIEVEMENT_CRITERIA_FLAG_UNK5 = 0x00000010, // not used + ACHIEVEMENT_CRITERIA_FLAG_FAIL_ACHIEVEMENT = 0x00000004, // BG related?? + ACHIEVEMENT_CRITERIA_FLAG_RESET_ON_START = 0x00000008, // + ACHIEVEMENT_CRITERIA_FLAG_IS_DATE = 0x00000010, // not used ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER = 0x00000020 // Displays counter as money }; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 2324057169a..84d3b4de2fb 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -706,7 +706,7 @@ Player::Player(WorldSession* session): Unit(true), phaseMgr(this) m_focusRegenTimerCount = 0; m_weaponChangeTimer = 0; - m_zoneUpdateId = 0; + m_zoneUpdateId = uint32(-1); m_zoneUpdateTimer = 0; m_areaUpdateId = 0; @@ -24198,7 +24198,7 @@ uint32 Player::GetResurrectionSpellId() } // Used in triggers for check "Only to targets that grant experience or honor" req -bool Player::isHonorOrXPTarget(Unit const* victim) +bool Player::isHonorOrXPTarget(Unit const* victim) const { uint8 v_level = victim->getLevel(); uint8 k_grey = Trinity::XP::GetGrayLevel(getLevel()); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 0c4ce8b2c6e..5e159ef16d3 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2108,7 +2108,7 @@ class Player : public Unit, public GridObject<Player> bool IsAtRecruitAFriendDistance(WorldObject const* pOther) const; void RewardPlayerAndGroupAtKill(Unit* victim, bool isBattleGround); void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource); - bool isHonorOrXPTarget(Unit const* victim); + bool isHonorOrXPTarget(Unit const* victim) const; bool GetsRecruitAFriendBonus(bool forXP); uint8 GetGrantableLevels() { return m_grantableLevels; } diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 8c9cc9c1338..b0514467667 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -1164,7 +1164,6 @@ void WorldSession::HandleMoveRootAck(WorldPacket& recvData) void WorldSession::HandleSetActionBarToggles(WorldPacket& recvData) { uint8 actionBar; - recvData >> actionBar; if (!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED) diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index 48079c9c630..59ab27968f4 100644 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -406,7 +406,6 @@ void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket& recvData) TC_LOG_DEBUG("network", "WORLD: CMSG_SPIRIT_HEALER_ACTIVATE"); uint64 guid; - recvData >> guid; Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_SPIRITHEALER); @@ -426,7 +425,6 @@ void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket& recvData) void WorldSession::SendSpiritResurrect() { _player->ResurrectPlayer(0.5f, true); - _player->DurabilityLossAll(0.25f, true); // get corpse nearest graveyard diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index d8dee6dbe25..72bb0e1d56e 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -337,6 +337,9 @@ void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, floa if (_owner->GetTypeId() == TYPEID_PLAYER) return; + if (speedXY <= 0.1f) + return; + float x, y, z; float moveTimeHalf = speedZ / Movement::gravity; float dist = 2 * moveTimeHalf * speedXY; @@ -370,6 +373,8 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ) void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id) { TC_LOG_DEBUG("misc", "Unit (GUID: %u) jump to point (X: %f Y: %f Z: %f)", _owner->GetGUIDLow(), x, y, z); + if (speedXY <= 0.1f) + return; float moveTimeHalf = speedZ / Movement::gravity; float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index f1a58cb7e91..f5396daef51 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1171,77 +1171,6 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge float radius = m_spellInfo->Effects[effIndex].CalcRadius(m_caster) * m_spellValue->RadiusMod; SearchAreaTargets(targets, radius, center, referer, targetType.GetObjectType(), targetType.GetCheckType(), m_spellInfo->Effects[effIndex].ImplicitTargetConditions); - // Custom entries - /// @todo remove those - switch (m_spellInfo->Id) - { - case 46584: // Raise Dead - { - if (Player* playerCaster = m_caster->ToPlayer()) - { - for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr) - { - switch ((*itr)->GetTypeId()) - { - case TYPEID_UNIT: - case TYPEID_PLAYER: - { - Unit* unitTarget = (*itr)->ToUnit(); - if (unitTarget->IsAlive() || !playerCaster->isHonorOrXPTarget(unitTarget) - || ((unitTarget->GetCreatureTypeMask() & (1 << (CREATURE_TYPE_HUMANOID-1))) == 0) - || (unitTarget->GetDisplayId() != unitTarget->GetNativeDisplayId())) - break; - AddUnitTarget(unitTarget, effMask, false); - // no break; - } - case TYPEID_CORPSE: // wont work until corpses are allowed in target lists, but at least will send dest in packet - m_targets.SetDst(*(*itr)); - return; // nothing more to do here - default: - break; - } - } - } - return; // don't add targets to target map - } - // Corpse Explosion - case 49158: - case 51325: - case 51326: - case 51327: - case 51328: - // check if our target is not valid (spell can target ghoul or dead unit) - if (!(m_targets.GetUnitTarget() && m_targets.GetUnitTarget()->GetDisplayId() == m_targets.GetUnitTarget()->GetNativeDisplayId() && - ((m_targets.GetUnitTarget()->GetEntry() == 26125 && m_targets.GetUnitTarget()->GetOwnerGUID() == m_caster->GetGUID()) - || m_targets.GetUnitTarget()->isDead()))) - { - // remove existing targets - CleanupTargetList(); - - for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr) - { - switch ((*itr)->GetTypeId()) - { - case TYPEID_UNIT: - case TYPEID_PLAYER: - if (!(*itr)->ToUnit()->isDead()) - break; - AddUnitTarget((*itr)->ToUnit(), 1 << effIndex, false); - return; - default: - break; - } - } - if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true); - SendCastResult(SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW); - finish(false); - } - return; - default: - break; - } - CallScriptObjectAreaTargetSelectHandlers(targets, effIndex); if (!targets.empty()) @@ -4930,8 +4859,7 @@ SpellCastResult Spell::CheckCast(bool strict) uint32 zone, area; m_caster->GetZoneAndAreaId(zone, area); - SpellCastResult locRes= m_spellInfo->CheckLocation(m_caster->GetMapId(), zone, area, - m_caster->GetTypeId() == TYPEID_PLAYER ? m_caster->ToPlayer() : NULL); + SpellCastResult locRes = m_spellInfo->CheckLocation(m_caster->GetMapId(), zone, area, m_caster->ToPlayer()); if (locRes != SPELL_CAST_OK) return locRes; } diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 1b415cd6cb8..0fa162f06c7 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -562,7 +562,7 @@ class Spell GameObject* focusObject; // Damage and healing in effects need just calculate - int32 m_damage; // Damge in effects count here + int32 m_damage; // Damage in effects count here int32 m_healing; // Healing in effects count here // ****************************************** diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index f152e4f5976..ba8fd63f853 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -559,11 +559,6 @@ void Spell::EffectDummy(SpellEffIndex effIndex) if (!unitTarget && !gameObjTarget && !itemTarget) return; - uint32 spell_id = 0; - int32 bp = 0; - bool triggered = true; - SpellCastTargets targets; - // selection by spell family switch (m_spellInfo->SpellFamilyName) { @@ -600,60 +595,10 @@ void Spell::EffectDummy(SpellEffIndex effIndex) } } break; - case SPELLFAMILY_DEATHKNIGHT: - switch (m_spellInfo->Id) - { - case 46584: // Raise Dead - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - // Do we have talent Master of Ghouls? - if (m_caster->HasAura(52143)) - // summon as pet - bp = 52150; - else - // or guardian - bp = 46585; - - if (m_targets.HasDst()) - targets.SetDst(*m_targets.GetDstPos()); - else - { - targets.SetDst(*m_caster); - // Corpse not found - take reagents (only not triggered cast can take them) - triggered = false; - } - // Remove cooldown - summon spellls have category - m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true); - spell_id = 48289; - break; - // Raise dead - take reagents and trigger summon spells - case 48289: - if (m_targets.HasDst()) - targets.SetDst(*m_targets.GetDstPos()); - spell_id = CalculateDamage(0, NULL); - break; - } + default: break; } - //spells triggered by dummy effect should not miss - if (spell_id) - { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id); - - if (!spellInfo) - { - TC_LOG_ERROR("spells", "EffectDummy of spell %u: triggering unknown spell id %i\n", m_spellInfo->Id, spell_id); - return; - } - - targets.SetUnitTarget(unitTarget); - Spell* spell = new Spell(m_caster, spellInfo, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE, m_originalCasterGUID, true); - if (bp) spell->SetSpellValue(SPELLVALUE_BASE_POINT0, bp); - spell->prepare(&targets); - } - // pet auras if (PetAura const* petSpell = sSpellMgr->GetPetAura(m_spellInfo->Id, effIndex)) { @@ -774,7 +719,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id); if (!spellInfo) { - TC_LOG_DEBUG("spells", "Spell::EffectTriggerSpell spell %u tried to trigger unknown spell %u", m_spellInfo->Id, triggered_spell_id); + TC_LOG_ERROR("spells", "Spell::EffectTriggerSpell spell %u tried to trigger unknown spell %u", m_spellInfo->Id, triggered_spell_id); return; } @@ -826,7 +771,7 @@ void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex) SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(triggered_spell_id); if (!spellInfo) { - TC_LOG_DEBUG("spells", "Spell::EffectTriggerMissileSpell spell %u tried to trigger unknown spell %u", m_spellInfo->Id, triggered_spell_id); + TC_LOG_ERROR("spells", "Spell::EffectTriggerMissileSpell spell %u tried to trigger unknown spell %u", m_spellInfo->Id, triggered_spell_id); return; } diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 104d9feb5fd..7f3b44a6f9d 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2793,8 +2793,39 @@ void SpellMgr::UnloadSpellInfoImplicitTargetConditionLists() void SpellMgr::LoadSpellInfoCustomAttributes() { uint32 oldMSTime = getMSTime(); - + uint32 oldMSTime2 = oldMSTime; SpellInfo* spellInfo = NULL; + + QueryResult result = WorldDatabase.Query("SELECT entry, attributes FROM spell_custom_attr"); + + if (!result) + TC_LOG_INFO("server.loading", ">> Loaded 0 spell custom attributes from DB. DB table `spell_custom_attr` is empty."); + else + { + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint32 spellId = fields[0].GetUInt32(); + uint32 attributes = fields[1].GetUInt32(); + + spellInfo = mSpellInfoMap[spellId]; + if (!spellInfo) + { + TC_LOG_ERROR("sql.sql", "Table `spell_custom_attr` has wrong spell (entry: %u), ignored.", spellId); + continue; + } + + // TODO: validate attributes + + spellInfo->AttributesCu |= attributes; + ++count; + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u spell custom attributes from DB in %u ms", count, GetMSTimeDiffToNow(oldMSTime2)); + } + for (uint32 i = 0; i < GetSpellInfoStoreSize(); ++i) { spellInfo = mSpellInfoMap[i]; @@ -2905,171 +2936,6 @@ void SpellMgr::LoadSpellInfoCustomAttributes() if (spellInfo->SpellVisual[0] == 3879) spellInfo->AttributesCu |= SPELL_ATTR0_CU_CONE_BACK; - switch (spellInfo->Id) - { - case 1776: // Gouge - case 1777: - case 8629: - case 11285: - case 11286: - case 12540: - case 13579: - case 24698: - case 28456: - case 29425: - case 34940: - case 36862: - case 38764: - case 38863: - case 52743: // Head Smack - spellInfo->AttributesCu |= SPELL_ATTR0_CU_REQ_TARGET_FACING_CASTER; - break; - case 53: // Backstab - case 2589: - case 2590: - case 2591: - case 7159: - case 8627: - case 8721: - case 11279: - case 11280: - case 11281: - case 15582: - case 15657: - case 22416: - case 25300: - case 26863: - case 37685: - case 48656: - case 48657: - case 703: // Garrote - case 8631: - case 8632: - case 8633: - case 11289: - case 11290: - case 26839: - case 26884: - case 48675: - case 48676: - case 5221: // Shred - case 6800: - case 8992: - case 9829: - case 9830: - case 27001: - case 27002: - case 48571: - case 48572: - case 8676: // Ambush - case 8724: - case 8725: - case 11267: - case 11268: - case 11269: - case 27441: - case 48689: - case 48690: - case 48691: - case 6785: // Ravage - case 6787: - case 9866: - case 9867: - case 27005: - case 48578: - case 48579: - case 21987: // Lash of Pain - case 23959: // Test Stab R50 - case 24825: // Test Backstab - case 58563: // Assassinate Restless Lookout - spellInfo->AttributesCu |= SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET; - break; - case 26029: // Dark Glare - case 37433: // Spout - case 43140: // Flame Breath - case 43215: // Flame Breath - case 70461: // Coldflame Trap - case 72133: // Pain and Suffering - case 73788: // Pain and Suffering - case 73789: // Pain and Suffering - case 73790: // Pain and Suffering - spellInfo->AttributesCu |= SPELL_ATTR0_CU_CONE_LINE; - break; - case 24340: // Meteor - case 26558: // Meteor - case 28884: // Meteor - case 36837: // Meteor - case 38903: // Meteor - case 41276: // Meteor - case 57467: // Meteor - case 26789: // Shard of the Fallen Star - case 31436: // Malevolent Cleave - case 35181: // Dive Bomb - case 40810: // Saber Lash - case 43267: // Saber Lash - case 43268: // Saber Lash - case 42384: // Brutal Swipe - case 45150: // Meteor Slash - case 64688: // Sonic Screech - case 72373: // Shared Suffering - case 71904: // Chaos Bane - case 70492: // Ooze Eruption - case 72505: // Ooze Eruption - case 72624: // Ooze Eruption - case 72625: // Ooze Eruption - // ONLY SPELLS WITH SPELLFAMILY_GENERIC and EFFECT_SCHOOL_DAMAGE - spellInfo->AttributesCu |= SPELL_ATTR0_CU_SHARE_DAMAGE; - break; - case 18500: // Wing Buffet - case 33086: // Wild Bite - case 49749: // Piercing Blow - case 52890: // Penetrating Strike - case 53454: // Impale - case 59446: // Impale - case 62383: // Shatter - case 64777: // Machine Gun - case 65239: // Machine Gun - case 65919: // Impale - case 67858: // Impale - case 67859: // Impale - case 67860: // Impale - case 69293: // Wing Buffet - case 74439: // Machine Gun - case 63278: // Mark of the Faceless (General Vezax) - case 62544: // Thrust (Argent Tournament) - case 64588: // Thrust (Argent Tournament) - case 66479: // Thrust (Argent Tournament) - case 68505: // Thrust (Argent Tournament) - case 62709: // Counterattack! (Argent Tournament) - case 62626: // Break-Shield (Argent Tournament, Player) - case 64590: // Break-Shield (Argent Tournament, Player) - case 64342: // Break-Shield (Argent Tournament, NPC) - case 64686: // Break-Shield (Argent Tournament, NPC) - case 65147: // Break-Shield (Argent Tournament, NPC) - case 68504: // Break-Shield (Argent Tournament, NPC) - case 62874: // Charge (Argent Tournament, Player) - case 68498: // Charge (Argent Tournament, Player) - case 64591: // Charge (Argent Tournament, Player) - case 63003: // Charge (Argent Tournament, NPC) - case 63010: // Charge (Argent Tournament, NPC) - case 68321: // Charge (Argent Tournament, NPC) - case 72255: // Mark of the Fallen Champion (Deathbringer Saurfang) - case 72444: // Mark of the Fallen Champion (Deathbringer Saurfang) - case 72445: // Mark of the Fallen Champion (Deathbringer Saurfang) - case 72446: // Mark of the Fallen Champion (Deathbringer Saurfang) - spellInfo->AttributesCu |= SPELL_ATTR0_CU_IGNORE_ARMOR; - break; - case 64422: // Sonic Screech (Auriaya) - spellInfo->AttributesCu |= SPELL_ATTR0_CU_SHARE_DAMAGE; - spellInfo->AttributesCu |= SPELL_ATTR0_CU_IGNORE_ARMOR; - break; - case 72293: // Mark of the Fallen Champion (Deathbringer Saurfang) - spellInfo->AttributesCu |= SPELL_ATTR0_CU_NEGATIVE_EFF0; - break; - default: - break; - } - switch (spellInfo->SpellFamilyName) { case SPELLFAMILY_WARRIOR: diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index c7eebb495c0..c0bcd477e5b 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -576,16 +576,28 @@ void SpellScript::PreventHitDefaultEffect(SpellEffIndex effIndex) m_hitPreventDefaultEffectMask |= 1 << effIndex; } -int32 SpellScript::GetEffectValue() +int32 SpellScript::GetEffectValue() const { if (!IsInEffectHook()) { - TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::PreventHitDefaultEffect was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId); + TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetEffectValue was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId); return 0; } + return m_spell->damage; } +void SpellScript::SetEffectValue(int32 value) +{ + if (!IsInEffectHook()) + { + TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::SetEffectValue was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId); + return; + } + + m_spell->damage = value; +} + Item* SpellScript::GetCastItem() { return m_spell->m_CastItem; diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index dfa494e38e6..6378a8bed9b 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -411,7 +411,8 @@ class SpellScript : public _SpellScript void PreventHitDefaultEffect(SpellEffIndex effIndex); // method avalible only in EffectHandler method - int32 GetEffectValue(); + int32 GetEffectValue() const; + void SetEffectValue(int32 value); // returns: cast item if present. Item* GetCastItem(); diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp index 027a6843c87..1f4713415ac 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp @@ -1837,7 +1837,6 @@ public: void IsSummonedBy(Unit*) OVERRIDE { DoCast(me, SPELL_EMERGE_VISUAL); - DoZoneInCombat(me, 100.00f); } void JustDied(Unit* /*killer*/) OVERRIDE diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 76f2461bb28..d08623888b3 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -53,6 +53,8 @@ enum DeathKnightSpells SPELL_DK_IMPROVED_UNHOLY_PRESENCE_TRIGGERED = 63622, SPELL_DK_ITEM_SIGIL_VENGEFUL_HEART = 64962, SPELL_DK_ITEM_T8_MELEE_4P_BONUS = 64736, + SPELL_DK_MASTER_OF_GHOULS = 52143, + SPELL_DK_RAISE_DEAD_USE_REAGENT = 48289, SPELL_DK_RUNIC_POWER_ENERGIZE = 49088, SPELL_DK_RUNE_TAP = 48982, SPELL_DK_SCENT_OF_BLOOD = 50422, @@ -1031,6 +1033,163 @@ class spell_dk_presence : public SpellScriptLoader } }; +class RaiseDeadCheck +{ +public: + explicit RaiseDeadCheck(Player const* caster) : _caster(caster) { } + + bool operator()(WorldObject* obj) const + { + if (Unit* target = obj->ToUnit()) + { + if (!target->IsAlive() + && _caster->isHonorOrXPTarget(target) + && target->GetCreatureType() == CREATURE_TYPE_HUMANOID + && target->GetDisplayId() == target->GetNativeDisplayId()) + return false; + } + + return true; + } + +private: + Player const* _caster; +}; + + +// 46584 - Raise Dead +class spell_dk_raise_dead : public SpellScriptLoader +{ + public: + spell_dk_raise_dead() : SpellScriptLoader("spell_dk_raise_dead") { } + + class spell_dk_raise_dead_SpellScript : public SpellScript + { + PrepareSpellScript(spell_dk_raise_dead_SpellScript); + + bool Validate(SpellInfo const* spellInfo) OVERRIDE + { + if (!sSpellMgr->GetSpellInfo(spellInfo->Effects[EFFECT_1].CalcValue()) + || !sSpellMgr->GetSpellInfo(spellInfo->Effects[EFFECT_2].CalcValue()) + || !sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_DEAD_USE_REAGENT) + || !sSpellMgr->GetSpellInfo(SPELL_DK_MASTER_OF_GHOULS)) + return false; + return true; + } + + bool Load() OVERRIDE + { + _result = SPELL_CAST_OK; + _corpse = false; + return GetCaster()->GetTypeId() == TYPEID_PLAYER; + } + + SpellCastResult CheckCast() + { + /// process spell target selection before cast starts + /// targets of effect_1 are used to check cast + GetSpell()->SelectSpellTargets(); + /// cleanup spell target map, and fill it again on normal way + GetSpell()->CleanupTargetList(); + /// _result is set in spell target selection + return _result; + } + + SpellCastResult CheckReagents() + { + /// @workaround: there is no access to castresult of other spells, check it manually + SpellInfo const* reagentSpell = sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_DEAD_USE_REAGENT); + Player* player = GetCaster()->ToPlayer(); + if (!player->CanNoReagentCast(reagentSpell)) + { + for (uint32 i = 0; i < MAX_SPELL_REAGENTS; i++) + { + if (reagentSpell->Reagent[i] <= 0) + continue; + + if (!player->HasItemCount(reagentSpell->Reagent[i], reagentSpell->ReagentCount[i])) + { + Spell::SendCastResult(player, reagentSpell, 0, SPELL_FAILED_REAGENTS); + return SPELL_FAILED_DONT_REPORT; + } + } + } + return SPELL_CAST_OK; + } + + void CheckTargets(std::list<WorldObject*>& targets) + { + targets.remove_if(RaiseDeadCheck(GetCaster()->ToPlayer())); + + if (targets.empty()) + { + if (GetSpell()->getState() == SPELL_STATE_PREPARING) + _result = CheckReagents(); + + return; + } + + WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets); + targets.clear(); + targets.push_back(target); + _corpse = true; + } + + void CheckTarget(WorldObject*& target) + { + // Don't add caster to target map, if we found a corpse to raise dead + if (_corpse) + target = NULL; + } + + void ConsumeReagents() + { + // No corpse found, take reagents + if (!_corpse) + GetCaster()->CastSpell(GetCaster(), SPELL_DK_RAISE_DEAD_USE_REAGENT, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)); + } + + uint32 GetGhoulSpellId() + { + // Do we have talent Master of Ghouls? + if (GetCaster()->HasAura(SPELL_DK_MASTER_OF_GHOULS)) + // summon as pet + return GetSpellInfo()->Effects[EFFECT_2].CalcValue(); + + // or guardian + return GetSpellInfo()->Effects[EFFECT_1].CalcValue(); + } + + void HandleRaiseDead(SpellEffIndex /*effIndex*/) + { + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(GetGhoulSpellId()); + SpellCastTargets targets; + targets.SetDst(*GetHitUnit()); + + GetCaster()->CastSpell(targets, spellInfo, NULL, TRIGGERED_FULL_MASK); + } + + void Register() OVERRIDE + { + OnCheckCast += SpellCheckCastFn(spell_dk_raise_dead_SpellScript::CheckCast); + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dk_raise_dead_SpellScript::CheckTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ENTRY); + OnObjectTargetSelect += SpellObjectTargetSelectFn(spell_dk_raise_dead_SpellScript::CheckTarget, EFFECT_2, TARGET_UNIT_CASTER); + OnCast += SpellCastFn(spell_dk_raise_dead_SpellScript::ConsumeReagents); + OnEffectHitTarget += SpellEffectFn(spell_dk_raise_dead_SpellScript::HandleRaiseDead, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT); + OnEffectHitTarget += SpellEffectFn(spell_dk_raise_dead_SpellScript::HandleRaiseDead, EFFECT_2, SPELL_EFFECT_DUMMY); + } + + private: + SpellCastResult _result; + bool _corpse; + }; + + SpellScript* GetSpellScript() const OVERRIDE + { + return new spell_dk_raise_dead_SpellScript(); + } +}; + // 59754 Rune Tap - Party class spell_dk_rune_tap_party : public SpellScriptLoader { @@ -1256,6 +1415,7 @@ void AddSC_deathknight_spell_scripts() new spell_dk_improved_unholy_presence(); new spell_dk_necrotic_strike(); new spell_dk_presence(); + new spell_dk_raise_dead(); new spell_dk_rune_tap_party(); new spell_dk_scent_of_blood(); new spell_dk_scourge_strike(); diff --git a/src/server/shared/CompilerDefs.h b/src/server/shared/CompilerDefs.h index 71b20a4d175..8a557328af4 100644 --- a/src/server/shared/CompilerDefs.h +++ b/src/server/shared/CompilerDefs.h @@ -57,6 +57,8 @@ #if defined(__cplusplus) && __cplusplus == 201103L # define COMPILER_HAS_CPP11_SUPPORT 1 +#elif _MSC_VER >= 1700 +# define COMPILER_HAS_CPP11_SUPPORT 1 #else # define COMPILER_HAS_CPP11_SUPPORT 0 #endif diff --git a/src/server/shared/Utilities/ByteConverter.h b/src/server/shared/Utilities/ByteConverter.h index bf1342a10e4..8eebb05bb13 100644 --- a/src/server/shared/Utilities/ByteConverter.h +++ b/src/server/shared/Utilities/ByteConverter.h @@ -47,9 +47,13 @@ namespace ByteConverter #if TRINITY_ENDIAN == TRINITY_BIGENDIAN template<typename T> inline void EndianConvert(T& val) { ByteConverter::apply<T>(&val); } template<typename T> inline void EndianConvertReverse(T&) { } +template<typename T> inline void EndianConvertPtr(void* val) { ByteConverter::apply<T>(val); } +template<typename T> inline void EndianConvertPtrReverse(void*) { } #else template<typename T> inline void EndianConvert(T&) { } template<typename T> inline void EndianConvertReverse(T& val) { ByteConverter::apply<T>(&val); } +template<typename T> inline void EndianConvertPtr(void*) { } +template<typename T> inline void EndianConvertPtrReverse(void* val) { ByteConverter::apply<T>(val); } #endif template<typename T> void EndianConvert(T*); // will generate link error diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 2149956c19f..f2a6f1b7622 100644 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -510,6 +510,9 @@ void vutf8printf(FILE* out, const char *str, va_list* ap) wchar_t wtemp_buf[32*1024]; size_t temp_len = vsnprintf(temp_buf, 32*1024, str, *ap); + //vsnprintf returns -1 if the buffer is too small + if (temp_len == size_t(-1)) + temp_len = 32*1024-1; size_t wtemp_len = 32*1024-1; Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len); |