Merge branch 'master' of github.com:TrinityCore/TrinityCore

This commit is contained in:
Rat
2011-11-23 20:23:26 +01:00
33 changed files with 243 additions and 237 deletions
+2 -1
View File
@@ -309,8 +309,9 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
return false; return false;
} }
else if (flags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast else if (spellFlags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast
return true; return true;
break;
} }
case DISABLE_TYPE_MAP: case DISABLE_TYPE_MAP:
if (Player const* player = unit->ToPlayer()) if (Player const* player = unit->ToPlayer())
+22 -23
View File
@@ -2244,10 +2244,11 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!sMapMgr->CanPlayerEnter(mapid, this, false)) if (!sMapMgr->CanPlayerEnter(mapid, this, false))
return false; return false;
//I think this always returns true. Correct me if I am wrong.
// If the map is not created, assume it is possible to enter it. // If the map is not created, assume it is possible to enter it.
// It will be created in the WorldPortAck. // It will be created in the WorldPortAck.
Map* map = sMapMgr->FindBaseMap(mapid); //Map* map = sMapMgr->FindBaseNonInstanceMap(mapid);
if (!map || map->CanEnter(this)) //if (!map || map->CanEnter(this))
{ {
//lets reset near teleport flag if it wasn't reset during chained teleports //lets reset near teleport flag if it wasn't reset during chained teleports
SetSemaphoreTeleportNear(false); SetSemaphoreTeleportNear(false);
@@ -2356,8 +2357,8 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// code for finish transfer to new map called in WorldSession::HandleMoveWorldportAckOpcode at client packet // code for finish transfer to new map called in WorldSession::HandleMoveWorldportAckOpcode at client packet
SetSemaphoreTeleportFar(true); SetSemaphoreTeleportFar(true);
} }
else //else
return false; // return false;
} }
return true; return true;
} }
@@ -3523,7 +3524,7 @@ bool Player::AddTalent(uint32 spell_id, uint8 spec, bool learning)
if (!rankSpellId || rankSpellId == spell_id) if (!rankSpellId || rankSpellId == spell_id)
continue; continue;
PlayerTalentMap::iterator itr = m_talents[spec]->find(rankSpellId); itr = m_talents[spec]->find(rankSpellId);
if (itr != m_talents[spec]->end()) if (itr != m_talents[spec]->end())
itr->second->state = PLAYERSPELL_REMOVED; itr->second->state = PLAYERSPELL_REMOVED;
} }
@@ -4133,8 +4134,6 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
if (uint32 prev_id = sSpellMgr->GetPrevSpellInChain(spell_id)) if (uint32 prev_id = sSpellMgr->GetPrevSpellInChain(spell_id))
{ {
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id);
// if talent then lesser rank also talent and need learn // if talent then lesser rank also talent and need learn
if (talentCosts) if (talentCosts)
{ {
@@ -4282,8 +4281,8 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns)
if (Pet* pet = GetPet()) if (Pet* pet = GetPet())
{ {
// notify player // notify player
for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr) for (CreatureSpellCooldowns::const_iterator itr2 = pet->m_CreatureSpellCooldowns.begin(); itr2 != pet->m_CreatureSpellCooldowns.end(); ++itr2)
SendClearCooldown(itr->first, pet); SendClearCooldown(itr2->first, pet);
// actually clear cooldowns // actually clear cooldowns
pet->m_CreatureSpellCooldowns.clear(); pet->m_CreatureSpellCooldowns.clear();
@@ -4436,9 +4435,9 @@ bool Player::resetTalents(bool no_cost)
RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
{ {
TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
if (!talentInfo) if (!talentInfo)
continue; continue;
@@ -4874,14 +4873,14 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
{ {
do do
{ {
Field* fields = resultItems->Fetch(); Field* fields2 = resultItems->Fetch();
uint32 item_guidlow = fields[11].GetUInt32(); uint32 item_guidlow = fields2[11].GetUInt32();
uint32 item_template = fields[12].GetUInt32(); uint32 item_template = fields2[12].GetUInt32();
ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_template); ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_template);
if (!itemProto) if (!itemProto)
{ {
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, item_guidlow); stmt->setUInt32(0, item_guidlow);
trans->Append(stmt); trans->Append(stmt);
continue; continue;
@@ -16081,9 +16080,9 @@ void Player::CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id)
if (reqTarget != entry) // if entry doesn't match, check for killcredits referenced in template if (reqTarget != entry) // if entry doesn't match, check for killcredits referenced in template
{ {
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry); CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i) for (uint8 j = 0; j < MAX_KILL_CREDIT; ++j)
if (cinfo->KillCredit[i] == reqTarget) if (cinfo->KillCredit[j] == reqTarget)
entry = cinfo->KillCredit[i]; entry = cinfo->KillCredit[j];
} }
} }
} }
@@ -17720,7 +17719,7 @@ void Player::_LoadMailedItems(Mail* mail)
{ {
sLog->outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template, mail->messageID); sLog->outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template, mail->messageID);
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, item_guid_low); stmt->setUInt32(0, item_guid_low);
CharacterDatabase.Execute(stmt); CharacterDatabase.Execute(stmt);
continue; continue;
@@ -20307,9 +20306,9 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
if (sWorld->getBoolConfig(CONFIG_INSTANT_TAXI)) if (sWorld->getBoolConfig(CONFIG_INSTANT_TAXI))
{ {
TaxiNodesEntry const* lastnode = sTaxiNodesStore.LookupEntry(nodes[nodes.size()-1]); TaxiNodesEntry const* lastPathNode = sTaxiNodesStore.LookupEntry(nodes[nodes.size()-1]);
m_taxi.ClearTaxiDestinations(); m_taxi.ClearTaxiDestinations();
TeleportTo(lastnode->map_id, lastnode->x, lastnode->y, lastnode->z, GetOrientation()); TeleportTo(lastPathNode->map_id, lastPathNode->x, lastPathNode->y, lastPathNode->z, GetOrientation());
return false; return false;
} }
else else
@@ -24498,9 +24497,9 @@ void Player::ActivateSpec(uint8 spec)
// Let client clear his current Actions // Let client clear his current Actions
SendActionButtons(2); SendActionButtons(2);
// m_actionButtons.clear() is called in the next _LoadActionButtons // m_actionButtons.clear() is called in the next _LoadActionButtons
for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
{ {
TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
if (!talentInfo) if (!talentInfo)
continue; continue;
+22 -23
View File
@@ -1514,8 +1514,8 @@ uint32 Unit::CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo
if (GetTypeId() == TYPEID_PLAYER) if (GetTypeId() == TYPEID_PLAYER)
{ {
AuraEffectList const& ResIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT); AuraEffectList const& ArPenAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT);
for (AuraEffectList::const_iterator itr = ResIgnoreAuras.begin(); itr != ResIgnoreAuras.end(); ++itr) for (AuraEffectList::const_iterator itr = ArPenAuras.begin(); itr != ArPenAuras.end(); ++itr)
{ {
// item neutral spell // item neutral spell
if ((*itr)->GetSpellInfo()->EquippedItemClass == -1) if ((*itr)->GetSpellInfo()->EquippedItemClass == -1)
@@ -1687,12 +1687,12 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
if (currentAbsorb < 0) if (currentAbsorb < 0)
currentAbsorb = 0; currentAbsorb = 0;
uint32 absorb = currentAbsorb; uint32 tempAbsorb = uint32(currentAbsorb);
bool defaultPrevented = false; bool defaultPrevented = false;
absorbAurEff->GetBase()->CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, absorb, defaultPrevented); absorbAurEff->GetBase()->CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented);
currentAbsorb = absorb; currentAbsorb = tempAbsorb;
if (defaultPrevented) if (defaultPrevented)
continue; continue;
@@ -1705,8 +1705,8 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
dmgInfo.AbsorbDamage(currentAbsorb); dmgInfo.AbsorbDamage(currentAbsorb);
absorb = currentAbsorb; tempAbsorb = currentAbsorb;
absorbAurEff->GetBase()->CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, absorb); absorbAurEff->GetBase()->CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb);
// Check if our aura is using amount to count damage // Check if our aura is using amount to count damage
if (absorbAurEff->GetAmount() >= 0) if (absorbAurEff->GetAmount() >= 0)
@@ -1738,12 +1738,12 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
if (currentAbsorb < 0) if (currentAbsorb < 0)
currentAbsorb = 0; currentAbsorb = 0;
uint32 absorb = currentAbsorb; uint32 tempAbsorb = currentAbsorb;
bool defaultPrevented = false; bool defaultPrevented = false;
absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, absorb, defaultPrevented); absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented);
currentAbsorb = absorb; currentAbsorb = tempAbsorb;
if (defaultPrevented) if (defaultPrevented)
continue; continue;
@@ -1766,8 +1766,8 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe
dmgInfo.AbsorbDamage(currentAbsorb); dmgInfo.AbsorbDamage(currentAbsorb);
absorb = currentAbsorb; tempAbsorb = currentAbsorb;
absorbAurEff->GetBase()->CallScriptEffectAfterManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, absorb); absorbAurEff->GetBase()->CallScriptEffectAfterManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb);
// Check if our aura is using amount to count damage // Check if our aura is using amount to count damage
if (absorbAurEff->GetAmount() >= 0) if (absorbAurEff->GetAmount() >= 0)
@@ -3744,13 +3744,13 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit*
// Cast duration to unsigned to prevent permanent aura's such as Righteous Fury being permanently added to caster // Cast duration to unsigned to prevent permanent aura's such as Righteous Fury being permanently added to caster
uint32 dur = std::min(2u * MINUTE * IN_MILLISECONDS, uint32(aura->GetDuration())); uint32 dur = std::min(2u * MINUTE * IN_MILLISECONDS, uint32(aura->GetDuration()));
if (Aura* newAura = stealer->GetAura(aura->GetId(), aura->GetCasterGUID())) if (Aura* oldAura = stealer->GetAura(aura->GetId(), aura->GetCasterGUID()))
{ {
if (stealCharge) if (stealCharge)
newAura->ModCharges(1); oldAura->ModCharges(1);
else else
newAura->ModStackAmount(1); oldAura->ModStackAmount(1);
newAura->SetDuration(int32(dur)); oldAura->SetDuration(int32(dur));
} }
else else
{ {
@@ -11970,7 +11970,7 @@ void Unit::Unmount()
if (GetTypeId() == TYPEID_PLAYER && GetVehicleKit()) if (GetTypeId() == TYPEID_PLAYER && GetVehicleKit())
{ {
// Send other players that we are no longer a vehicle // Send other players that we are no longer a vehicle
WorldPacket data(SMSG_PLAYER_VEHICLE_DATA, 8+4); data.Initialize(SMSG_PLAYER_VEHICLE_DATA, 8+4);
data.appendPackGUID(GetGUID()); data.appendPackGUID(GetGUID());
data << uint32(0); data << uint32(0);
ToPlayer()->SendMessageToSet(&data, true); ToPlayer()->SendMessageToSet(&data, true);
@@ -14378,8 +14378,8 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", triggeredByAura->GetAmount(), spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId()); sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", triggeredByAura->GetAmount(), spellInfo->Id, (isVictim?"a victim's":"an attacker's"), triggeredByAura->GetId());
SpellNonMeleeDamage damageInfo(this, target, spellInfo->Id, spellInfo->SchoolMask); SpellNonMeleeDamage damageInfo(this, target, spellInfo->Id, spellInfo->SchoolMask);
uint32 damage = SpellDamageBonus(target, spellInfo, triggeredByAura->GetAmount(), SPELL_DIRECT_DAMAGE); uint32 newDamage = SpellDamageBonus(target, spellInfo, triggeredByAura->GetAmount(), SPELL_DIRECT_DAMAGE);
CalculateSpellDamageTaken(&damageInfo, damage, spellInfo); CalculateSpellDamageTaken(&damageInfo, newDamage, spellInfo);
DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
SendSpellNonMeleeDamageLog(&damageInfo); SendSpellNonMeleeDamageLog(&damageInfo);
DealSpellDamage(&damageInfo, true); DealSpellDamage(&damageInfo, true);
@@ -16589,10 +16589,9 @@ float Unit::GetCombatRatingReduction(CombatRating cr) const
if (Player const* player = ToPlayer()) if (Player const* player = ToPlayer())
return player->GetRatingBonusValue(cr); return player->GetRatingBonusValue(cr);
// Player's pet get resilience from owner // Player's pet get resilience from owner
else if (isPet()) else if (isPet() && GetOwner())
if (Unit* owner = GetOwner()) if (Player* owner = GetOwner()->ToPlayer())
if (Player* player = owner->ToPlayer()) return owner->GetRatingBonusValue(cr);
return player->GetRatingBonusValue(cr);
return 0.0f; return 0.0f;
} }
+4 -4
View File
@@ -5394,7 +5394,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
// mail open and then not returned // mail open and then not returned
for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
{ {
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, itr2->item_guid); stmt->setUInt32(0, itr2->item_guid);
CharacterDatabase.Execute(stmt); CharacterDatabase.Execute(stmt);
} }
@@ -7086,13 +7086,13 @@ void ObjectMgr::LoadQuestPOI()
{ {
// The first result should have the highest questId // The first result should have the highest questId
Field* fields = points->Fetch(); Field* fields = points->Fetch();
uint32 questId = fields[0].GetUInt32(); uint32 questIdMax = fields[0].GetUInt32();
POIs.resize(questId + 1); POIs.resize(questIdMax + 1);
do do
{ {
Field* fields = points->Fetch(); fields = points->Fetch();
uint32 questId = fields[0].GetUInt32(); uint32 questId = fields[0].GetUInt32();
uint32 id = fields[1].GetUInt32(); uint32 id = fields[1].GetUInt32();
@@ -309,11 +309,11 @@ void InstanceSaveManager::LoadResetTimes()
while (result->NextRow()); while (result->NextRow());
// update reset time for normal instances with the max creature respawn time + X hours // update reset time for normal instances with the max creature respawn time + X hours
if (PreparedQueryResult result = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_GET_MAX_CREATURE_RESPAWNS))) if (PreparedQueryResult result2 = CharacterDatabase.Query(CharacterDatabase.GetPreparedStatement(CHAR_GET_MAX_CREATURE_RESPAWNS)))
{ {
do do
{ {
Field* fields = result->Fetch(); Field* fields = result2->Fetch();
uint32 instance = fields[1].GetUInt32(); uint32 instance = fields[1].GetUInt32();
time_t resettime = time_t(fields[0].GetUInt32() + 2 * HOUR); time_t resettime = time_t(fields[0].GetUInt32() + 2 * HOUR);
InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance); InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance);
@@ -305,7 +305,6 @@ void InstanceScript::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData)
void InstanceScript::DoSendNotifyToInstance(const char *format, ...) void InstanceScript::DoSendNotifyToInstance(const char *format, ...)
{ {
InstanceMap::PlayerList const &PlayerList = instance->GetPlayers(); InstanceMap::PlayerList const &PlayerList = instance->GetPlayers();
InstanceMap::PlayerList::const_iterator i;
if (!PlayerList.isEmpty()) if (!PlayerList.isEmpty())
{ {
+3 -3
View File
@@ -2451,7 +2451,7 @@ bool InstanceMap::Reset(uint8 method)
return m_mapRefManager.isEmpty(); return m_mapRefManager.isEmpty();
} }
void InstanceMap::PermBindAllPlayers(Player* player) void InstanceMap::PermBindAllPlayers(Player* source)
{ {
if (!IsDungeon()) if (!IsDungeon())
return; return;
@@ -2459,11 +2459,11 @@ void InstanceMap::PermBindAllPlayers(Player* player)
InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId()); InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId());
if (!save) if (!save)
{ {
sLog->outError("Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", player->GetGUIDLow(), player->GetName(), player->GetMap()->GetMapName(), player->GetMapId(), GetInstanceId()); sLog->outError("Cannot bind player (GUID: %u, Name: %s), because no instance save is available for instance map (Name: %s, Entry: %u, InstanceId: %u)!", source->GetGUIDLow(), source->GetName(), source->GetMap()->GetMapName(), source->GetMapId(), GetInstanceId());
return; return;
} }
Group* group = player->GetGroup(); Group* group = source->GetGroup();
// group members outside the instance group don't get bound // group members outside the instance group don't get bound
for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
{ {
+1 -1
View File
@@ -574,7 +574,7 @@ class InstanceMap : public Map
bool Reset(uint8 method); bool Reset(uint8 method);
uint32 GetScriptId() { return i_script_id; } uint32 GetScriptId() { return i_script_id; }
InstanceScript* GetInstanceScript() { return i_data; } InstanceScript* GetInstanceScript() { return i_data; }
void PermBindAllPlayers(Player* player); void PermBindAllPlayers(Player* source);
void UnloadAll(); void UnloadAll();
bool CanEnter(Player* player); bool CanEnter(Player* player);
void SendResetWarnings(uint32 timeLeft) const; void SendResetWarnings(uint32 timeLeft) const;
+12 -4
View File
@@ -119,6 +119,14 @@ Map* MapManager::CreateBaseMap(uint32 id)
return m; return m;
} }
Map* MapManager::FindBaseNonInstanceMap(uint32 mapId) const
{
Map* map = FindBaseMap(mapId);
if(map && map->Instanceable())
return NULL;
return map;
}
Map* MapManager::CreateMap(uint32 id, Player* player) Map* MapManager::CreateMap(uint32 id, Player* player)
{ {
Map* m = CreateBaseMap(id); Map* m = CreateBaseMap(id);
@@ -200,8 +208,8 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
if (corpseMap == mapid) if (corpseMap == mapid)
break; break;
InstanceTemplate const* instance = sObjectMgr->GetInstanceTemplate(corpseMap); InstanceTemplate const* corpseInstance = sObjectMgr->GetInstanceTemplate(corpseMap);
corpseMap = instance ? instance->Parent : 0; corpseMap = corpseInstance ? corpseInstance->Parent : 0;
} while (corpseMap); } while (corpseMap);
if (!corpseMap) if (!corpseMap)
@@ -279,8 +287,8 @@ void MapManager::Update(uint32 diff)
iter->second->DelayedUpdate(uint32(i_timer.GetCurrent())); iter->second->DelayedUpdate(uint32(i_timer.GetCurrent()));
sObjectAccessor->Update(uint32(i_timer.GetCurrent())); sObjectAccessor->Update(uint32(i_timer.GetCurrent()));
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter) for (TransportSet::iterator itr = m_Transports.begin(); itr != m_Transports.end(); ++itr)
(*iter)->Update(uint32(i_timer.GetCurrent())); (*itr)->Update(uint32(i_timer.GetCurrent()));
i_timer.SetCurrent(0); i_timer.SetCurrent(0);
} }
+7 -5
View File
@@ -36,11 +36,7 @@ class MapManager
public: public:
Map* CreateBaseMap(uint32 mapId); Map* CreateBaseMap(uint32 mapId);
Map* FindBaseMap(uint32 mapId) const Map* FindBaseNonInstanceMap(uint32 mapId) const;
{
MapMapType::const_iterator iter = i_maps.find(mapId);
return (iter == i_maps.end() ? NULL : iter->second);
}
Map* CreateMap(uint32 mapId, Player* player); Map* CreateMap(uint32 mapId, Player* player);
Map* FindMap(uint32 mapId, uint32 instanceId) const; Map* FindMap(uint32 mapId, uint32 instanceId) const;
@@ -164,6 +160,12 @@ class MapManager
MapManager(); MapManager();
~MapManager(); ~MapManager();
Map* FindBaseMap(uint32 mapId) const
{
MapMapType::const_iterator iter = i_maps.find(mapId);
return (iter == i_maps.end() ? NULL : iter->second);
}
MapManager(const MapManager &); MapManager(const MapManager &);
MapManager& operator=(const MapManager &); MapManager& operator=(const MapManager &);
@@ -351,7 +351,7 @@ void FlightPathMovementGenerator::InitEndGridInfo()
void FlightPathMovementGenerator::PreloadEndGrid() void FlightPathMovementGenerator::PreloadEndGrid()
{ {
// used to preload the final grid where the flightmaster is // used to preload the final grid where the flightmaster is
Map* endMap = sMapMgr->FindBaseMap(m_endMapId); Map* endMap = sMapMgr->FindBaseNonInstanceMap(m_endMapId);
// Load the grid // Load the grid
if (endMap) if (endMap)
+3 -3
View File
@@ -321,11 +321,11 @@ void Map::ScriptsProcess()
source = HashMapHolder<Corpse>::Find(step.sourceGUID); source = HashMapHolder<Corpse>::Find(step.sourceGUID);
break; break;
case HIGHGUID_MO_TRANSPORT: case HIGHGUID_MO_TRANSPORT:
for (MapManager::TransportSet::iterator iter = sMapMgr->m_Transports.begin(); iter != sMapMgr->m_Transports.end(); ++iter) for (MapManager::TransportSet::iterator itr2 = sMapMgr->m_Transports.begin(); itr2 != sMapMgr->m_Transports.end(); ++itr2)
{ {
if ((*iter)->GetGUID() == step.sourceGUID) if ((*itr2)->GetGUID() == step.sourceGUID)
{ {
source = *iter; source = *itr2;
break; break;
} }
} }
@@ -107,9 +107,9 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target)
*Target << uint8(unk1); *Target << uint8(unk1);
if (unk1) if (unk1)
{ {
uint8 unk2 = (crc != 0x4c1c776d); // If addon is Standard addon CRC uint8 unk = (crc != 0x4c1c776d); // If addon is Standard addon CRC
*Target << uint8(unk2); *Target << uint8(unk);
if (unk2) if (unk)
Target->append(tdata, sizeof(tdata)); Target->append(tdata, sizeof(tdata));
*Target << uint32(0); *Target << uint32(0);
@@ -1480,9 +1480,9 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
} }
CharacterDatabase.EscapeString(newname); CharacterDatabase.EscapeString(newname);
if (QueryResult result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid ='%u'", GUID_LOPART(guid))) if (QueryResult oldNameResult = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid ='%u'", GUID_LOPART(guid)))
{ {
std::string oldname = result->Fetch()[0].GetString(); std::string oldname = oldNameResult->Fetch()[0].GetString();
std::string IP_str = GetRemoteAddress(); std::string IP_str = GetRemoteAddress();
sLog->outChar("Account: %d (IP: %s), Character[%s] (guid:%u) Customized to: %s", GetAccountId(), IP_str.c_str(), oldname.c_str(), GUID_LOPART(guid), newname.c_str()); sLog->outChar("Account: %d (IP: %s), Character[%s] (guid:%u) Customized to: %s", GetAccountId(), IP_str.c_str(), oldname.c_str(), GUID_LOPART(guid), newname.c_str());
} }
@@ -563,10 +563,10 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
amount += (int32)DoneActualBenefit; amount += (int32)DoneActualBenefit;
// Arena - Dampening // Arena - Dampening
if (AuraEffect const* pAurEff = caster->GetAuraEffect(74410, 0)) AuraEffect const* pAurEff = caster->GetAuraEffect(74410, 0);
AddPctN(amount, pAurEff->GetAmount()); if (!pAurEff)
// Battleground - Dampening pAurEff = caster->GetAuraEffect(74411, 0); // Battleground - Dampening
else if (AuraEffect const* pAurEff = caster->GetAuraEffect(74411, 0)) if (pAurEff)
AddPctN(amount, pAurEff->GetAmount()); AddPctN(amount, pAurEff->GetAmount());
return amount; return amount;
@@ -1508,15 +1508,15 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const
// Nurturing Instinct // Nurturing Instinct
if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT, SPELLFAMILY_DRUID, 2254, 0)) if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT, SPELLFAMILY_DRUID, 2254, 0))
{ {
uint32 spellId = 0; uint32 spellId3 = 0;
switch (aurEff->GetId()) switch (aurEff->GetId())
{ {
case 33872: case 33872:
spellId = 47179; spellId3 = 47179;
break; break;
case 33873: case 33873:
spellId = 47180; spellId3 = 47180;
break; break;
} }
target->CastSpell(target, spellId, true, NULL, this); target->CastSpell(target, spellId, true, NULL, this);
} }
@@ -4892,8 +4892,8 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
// Living Bomb // Living Bomb
if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) if (m_spellInfo->SpellFamilyFlags[1] & 0x20000)
{ {
AuraRemoveMode mode = aurApp->GetRemoveMode(); AuraRemoveMode removeMode = aurApp->GetRemoveMode();
if (caster && (mode == AURA_REMOVE_BY_ENEMY_SPELL || mode == AURA_REMOVE_BY_EXPIRE)) if (caster && (removeMode == AURA_REMOVE_BY_ENEMY_SPELL || removeMode == AURA_REMOVE_BY_EXPIRE))
caster->CastSpell(target, GetAmount(), true); caster->CastSpell(target, GetAmount(), true);
} }
break; break;
@@ -6019,13 +6019,15 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
case 65923: case 65923:
{ {
Unit* permafrostCaster = NULL; Unit* permafrostCaster = NULL;
if (Aura* permafrostAura = target->GetAura(66193)) Aura* permafrostAura = target->GetAura(66193);
permafrostCaster = permafrostAura->GetCaster(); if (!permafrostAura)
else if (Aura* permafrostAura = target->GetAura(67855)) permafrostAura = target->GetAura(67855);
permafrostCaster = permafrostAura->GetCaster(); if (!permafrostAura)
else if (Aura* permafrostAura = target->GetAura(67856)) permafrostAura = target->GetAura(67856);
permafrostCaster = permafrostAura->GetCaster(); if (!permafrostAura)
else if (Aura* permafrostAura = target->GetAura(67857)) permafrostAura = target->GetAura(67857);
if (permafrostAura)
permafrostCaster = permafrostAura->GetCaster(); permafrostCaster = permafrostAura->GetCaster();
if (permafrostCaster) if (permafrostCaster)
@@ -6461,15 +6463,15 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
// damage caster for heal amount // damage caster for heal amount
if (target != caster && GetSpellInfo()->AttributesEx2 & SPELL_ATTR2_HEALTH_FUNNEL) if (target != caster && GetSpellInfo()->AttributesEx2 & SPELL_ATTR2_HEALTH_FUNNEL)
{ {
uint32 damage = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); // damage is not affected by spell power uint32 funnelDamage = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); // damage is not affected by spell power
if ((int32)damage > gain) if ((int32)funnelDamage > gain)
damage = gain; funnelDamage = gain;
uint32 absorb = 0; uint32 funnelAbsorb = 0;
caster->DealDamageMods(caster, damage, &absorb); caster->DealDamageMods(caster, funnelDamage, &funnelAbsorb);
caster->SendSpellNonMeleeDamageLog(caster, GetId(), damage, GetSpellInfo()->GetSchoolMask(), absorb, 0, false, 0, false); caster->SendSpellNonMeleeDamageLog(caster, GetId(), funnelDamage, GetSpellInfo()->GetSchoolMask(), funnelAbsorb, 0, false, 0, false);
CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL); CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
caster->DealDamage(caster, damage, &cleanDamage, NODAMAGE, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true); caster->DealDamage(caster, funnelDamage, &cleanDamage, NODAMAGE, GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), true);
} }
uint32 procAttacker = PROC_FLAG_DONE_PERIODIC; uint32 procAttacker = PROC_FLAG_DONE_PERIODIC;
+24 -17
View File
@@ -642,23 +642,24 @@ void Spell::InitExplicitTargets(SpellCastTargets const& targets)
// try to select correct unit target if not provided by client or by serverside cast // try to select correct unit target if not provided by client or by serverside cast
if (neededTargets & (TARGET_FLAG_UNIT_MASK)) if (neededTargets & (TARGET_FLAG_UNIT_MASK))
{ {
Unit* target = NULL; Unit* unit = NULL;
// try to use player selection as a target // try to use player selection as a target
if (Player* playerCaster = m_caster->ToPlayer()) if (Player* playerCaster = m_caster->ToPlayer())
{ {
// selection has to be found and to be valid target for the spell // selection has to be found and to be valid target for the spell
if (Unit* selectedUnit = ObjectAccessor::GetUnit(*m_caster, playerCaster->GetSelection())) if (Unit* selectedUnit = ObjectAccessor::GetUnit(*m_caster, playerCaster->GetSelection()))
if (m_spellInfo->CheckExplicitTarget(m_caster, selectedUnit) == SPELL_CAST_OK) if (m_spellInfo->CheckExplicitTarget(m_caster, selectedUnit) == SPELL_CAST_OK)
target = selectedUnit; unit = selectedUnit;
} }
// try to use attacked unit as a target // try to use attacked unit as a target
else if ((m_caster->GetTypeId() == TYPEID_UNIT) && neededTargets & (TARGET_FLAG_UNIT_ENEMY | TARGET_FLAG_UNIT)) else if ((m_caster->GetTypeId() == TYPEID_UNIT) && neededTargets & (TARGET_FLAG_UNIT_ENEMY | TARGET_FLAG_UNIT))
target = m_caster->getVictim(); unit = m_caster->getVictim();
// didn't find anything - let's use self as target
if (!target && neededTargets & (TARGET_FLAG_UNIT_RAID | TARGET_FLAG_UNIT_PARTY | TARGET_FLAG_UNIT_ALLY))
target = m_caster;
m_targets.SetUnitTarget(target); // didn't find anything - let's use self as target
if (!unit && neededTargets & (TARGET_FLAG_UNIT_RAID | TARGET_FLAG_UNIT_PARTY | TARGET_FLAG_UNIT_ALLY))
unit = m_caster;
m_targets.SetUnitTarget(unit);
} }
} }
@@ -1219,11 +1220,11 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
if (spellHitTarget) if (spellHitTarget)
{ {
SpellMissInfo missInfo = DoSpellHitOnUnit(spellHitTarget, mask, target->scaleAura); SpellMissInfo missInfo2 = DoSpellHitOnUnit(spellHitTarget, mask, target->scaleAura);
if (missInfo != SPELL_MISS_NONE) if (missInfo2 != SPELL_MISS_NONE)
{ {
if (missInfo != SPELL_MISS_MISS) if (missInfo2 != SPELL_MISS_MISS)
m_caster->SendSpellMiss(unit, m_spellInfo->Id, missInfo); m_caster->SendSpellMiss(unit, m_spellInfo->Id, missInfo2);
m_damage = 0; m_damage = 0;
spellHitTarget = NULL; spellHitTarget = NULL;
} }
@@ -6799,7 +6800,7 @@ void Spell::SelectTrajTargets()
if (!dist2d) if (!dist2d)
return; return;
float dz = m_targets.GetDst()->m_positionZ - m_targets.GetSrc()->m_positionZ; float srcToDestDelta = m_targets.GetDst()->m_positionZ - m_targets.GetSrc()->m_positionZ;
UnitList unitList; UnitList unitList;
SearchAreaTarget(unitList, dist2d, PUSH_IN_THIN_LINE, SPELL_TARGETS_ANY); SearchAreaTarget(unitList, dist2d, PUSH_IN_THIN_LINE, SPELL_TARGETS_ANY);
@@ -6809,8 +6810,9 @@ void Spell::SelectTrajTargets()
unitList.sort(Trinity::ObjectDistanceOrderPred(m_caster)); unitList.sort(Trinity::ObjectDistanceOrderPred(m_caster));
float b = tangent(m_targets.GetElevation()); float b = tangent(m_targets.GetElevation());
float a = (dz - dist2d * b) / (dist2d * dist2d); float a = (srcToDestDelta - dist2d * b) / (dist2d * dist2d);
if (a > -0.0001f) a = 0; if (a > -0.0001f)
a = 0;
DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: a %f b %f", a, b);) DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: a %f b %f", a, b);)
float bestDist = m_spellInfo->GetMaxRange(false); float bestDist = m_spellInfo->GetMaxRange(false);
@@ -6838,9 +6840,14 @@ void Spell::SelectTrajTargets()
} }
#define CHECK_DIST {\ #define CHECK_DIST {\
DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\ DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\
if (dist > bestDist) continue;\ if (dist > bestDist)\
if (dist < objDist2d + size && dist > objDist2d - size) { bestDist = dist; break; }\ continue;\
if (dist < objDist2d + size && dist > objDist2d - size)\
{\
bestDist = dist;\
break;\
}\
} }
if (!a) if (!a)
+16 -12
View File
@@ -923,7 +923,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (m_caster->GetTypeId() != TYPEID_PLAYER)
return; return;
uint32 spell_id = roll_chance_i(50) spell_id = roll_chance_i(50)
? 29277 // Summon Purified Helboar Meat ? 29277 // Summon Purified Helboar Meat
: 29278; // Summon Toxic Helboar Meat : 29278; // Summon Toxic Helboar Meat
@@ -951,12 +951,16 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
return; return;
case 35745: // Socrethar's Stone case 35745: // Socrethar's Stone
{ {
uint32 spell_id;
switch (m_caster->GetAreaId()) switch (m_caster->GetAreaId())
{ {
case 3900: spell_id = 35743; break; // Socrethar Portal case 3900:
case 3742: spell_id = 35744; break; // Socrethar Portal spell_id = 35743;
default: return; break; // Socrethar Portal
case 3742:
spell_id = 35744;
break; // Socrethar Portal
default:
return;
} }
m_caster->CastSpell(m_caster, spell_id, true); m_caster->CastSpell(m_caster, spell_id, true);
@@ -1453,7 +1457,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_DK_DEATH_STRIKE) if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_DK_DEATH_STRIKE)
{ {
uint32 count = unitTarget->GetDiseasesByCaster(m_caster->GetGUID()); uint32 count = unitTarget->GetDiseasesByCaster(m_caster->GetGUID());
int32 bp = int32(count * m_caster->CountPctFromMaxHealth(int32(m_spellInfo->Effects[EFFECT_0].DamageMultiplier))); bp = int32(count * m_caster->CountPctFromMaxHealth(int32(m_spellInfo->Effects[EFFECT_0].DamageMultiplier)));
// Improved Death Strike // Improved Death Strike
if (AuraEffect const* aurEff = m_caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2751, 0)) if (AuraEffect const* aurEff = m_caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2751, 0))
AddPctN(bp, m_caster->CalculateSpellDamage(m_caster, aurEff->GetSpellInfo(), 2)); AddPctN(bp, m_caster->CalculateSpellDamage(m_caster, aurEff->GetSpellInfo(), 2));
@@ -1465,12 +1469,12 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
{ {
if (m_caster->IsFriendlyTo(unitTarget)) if (m_caster->IsFriendlyTo(unitTarget))
{ {
int32 bp = int32(damage * 1.5f); bp = int32(damage * 1.5f);
m_caster->CastCustomSpell(unitTarget, 47633, &bp, NULL, NULL, true); m_caster->CastCustomSpell(unitTarget, 47633, &bp, NULL, NULL, true);
} }
else else
{ {
int32 bp = damage; bp = damage;
m_caster->CastCustomSpell(unitTarget, 47632, &bp, NULL, NULL, true); m_caster->CastCustomSpell(unitTarget, 47632, &bp, NULL, NULL, true);
} }
return; return;
@@ -6348,13 +6352,13 @@ void Spell::EffectQuestClear(SpellEffIndex effIndex)
// remove all quest entries for 'entry' from quest log // remove all quest entries for 'entry' from quest log
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{ {
uint32 quest = player->GetQuestSlotQuestId(slot); uint32 logQuest = player->GetQuestSlotQuestId(slot);
if (quest == quest_id) if (logQuest == quest_id)
{ {
player->SetQuestSlot(slot, 0); player->SetQuestSlot(slot, 0);
// we ignore unequippable quest items in this case, its' still be equipped // we ignore unequippable quest items in this case, it's still be equipped
player->TakeQuestSourceItem(quest, false); player->TakeQuestSourceItem(logQuest, false);
} }
} }
+1 -1
View File
@@ -1005,7 +1005,7 @@ SpellThreatEntry const* SpellMgr::GetSpellThreatEntry(uint32 spellID) const
else else
{ {
uint32 firstSpell = GetFirstSpellInChain(spellID); uint32 firstSpell = GetFirstSpellInChain(spellID);
SpellThreatMap::const_iterator itr = mSpellThreatMap.find(firstSpell); itr = mSpellThreatMap.find(firstSpell);
if (itr != mSpellThreatMap.end()) if (itr != mSpellThreatMap.end())
return &itr->second; return &itr->second;
} }
+3 -3
View File
@@ -128,13 +128,13 @@ public:
// remove all quest entries for 'entry' from quest log // remove all quest entries for 'entry' from quest log
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
{ {
uint32 quest = player->GetQuestSlotQuestId(slot); uint32 logQuest = player->GetQuestSlotQuestId(slot);
if (quest == entry) if (logQuest == entry)
{ {
player->SetQuestSlot(slot, 0); player->SetQuestSlot(slot, 0);
// we ignore unequippable quest items in this case, its' still be equipped // we ignore unequippable quest items in this case, its' still be equipped
player->TakeQuestSourceItem(quest, false); player->TakeQuestSourceItem(logQuest, false);
} }
} }
+5 -5
View File
@@ -210,8 +210,8 @@ public:
if (!*args) if (!*args)
return false; return false;
Player* player = handler->getSelectedPlayer(); Player* target = handler->getSelectedPlayer();
if (!player) if (!target)
{ {
handler->SendSysMessage(LANG_NO_CHAR_SELECTED); handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true); handler->SetSentErrorMessage(true);
@@ -219,7 +219,7 @@ public:
} }
// check online security // check online security
if (handler->HasLowerSecurity(player, 0)) if (handler->HasLowerSecurity(target, 0))
return false; return false;
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
@@ -239,9 +239,9 @@ public:
return false; return false;
} }
std::string nameLink = handler->GetNameLink(player); std::string nameLink = handler->GetNameLink(target);
Group* grp = player->GetGroup(); Group* grp = target->GetGroup();
if (!grp) if (!grp)
{ {
handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str()); handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
+29 -41
View File
@@ -480,56 +480,44 @@ public:
} }
// The visual waypoint // The visual waypoint
Creature* wpCreature = NULL;
wpGuid = target->GetGUIDLow(); wpGuid = target->GetGUIDLow();
// Did the user select a visual spawnpoint?
if (wpGuid)
wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
// attempt check creature existence by DB data
else
{
handler->PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, wpGuid);
return false;
}
// User did select a visual waypoint? // User did select a visual waypoint?
// Check the creature
if (wpCreature->GetEntry() == VISUAL_WAYPOINT)
{
QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid);
// Check the creature
QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow());
// Select waypoint number from database
// Since we compare float values, we have to deal with
// some difficulties.
// Here we search for all waypoints that only differ in one from 1 thousand
// (0.001) - There is no other way to compare C++ floats with mySQL floats
// See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
const char* maxDIFF = "0.01";
result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)",
target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF);
if (!result) if (!result)
{ {
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow()); handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
// Select waypoint number from database return true;
// Since we compare float values, we have to deal with
// some difficulties.
// Here we search for all waypoints that only differ in one from 1 thousand
// (0.001) - There is no other way to compare C++ floats with mySQL floats
// See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
const char* maxDIFF = "0.01";
result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)",
wpCreature->GetPositionX(), maxDIFF, wpCreature->GetPositionY(), maxDIFF, wpCreature->GetPositionZ(), maxDIFF);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
return true;
}
} }
do
{
Field* fields = result->Fetch();
pathid = fields[0].GetUInt32();
point = fields[1].GetUInt32();
}
while (result->NextRow());
// We have the waypoint number and the GUID of the "master npc"
// Text is enclosed in "<>", all other arguments not
arg_str = strtok((char*)NULL, " ");
} }
do
{
Field* fields = result->Fetch();
pathid = fields[0].GetUInt32();
point = fields[1].GetUInt32();
}
while (result->NextRow());
// We have the waypoint number and the GUID of the "master npc"
// Text is enclosed in "<>", all other arguments not
arg_str = strtok((char*)NULL, " ");
// Check for argument // Check for argument
if (show != "del" && show != "move" && arg_str == NULL) if (show != "del" && show != "move" && arg_str == NULL)
{ {
@@ -201,7 +201,8 @@ public:
//object already removed, not exist //object already removed, not exist
if (!pAdd) if (!pAdd)
{ {
if (Creature* pAdd = me->SummonCreature((*itr), LackeyLocations[j][0], LackeyLocations[j][1], fZLocation, fOrientation, TEMPSUMMON_CORPSE_DESPAWN, 0)) pAdd = me->SummonCreature((*itr), LackeyLocations[j][0], LackeyLocations[j][1], fZLocation, fOrientation, TEMPSUMMON_CORPSE_DESPAWN, 0);
if (pAdd)
m_auiLackeyGUID[j] = pAdd->GetGUID(); m_auiLackeyGUID[j] = pAdd->GetGUID();
} }
++j; ++j;
@@ -497,9 +497,9 @@ public:
SetEscortPaused(bOnHold); SetEscortPaused(bOnHold);
} }
void WaypointReached(uint32 i) void WaypointReached(uint32 wpId)
{ {
switch (i) switch (wpId)
{ {
case 0: case 0:
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
@@ -1173,8 +1173,8 @@ public:
temp->SetSpeed(MOVE_RUN, 3.0f); // workarounds, make Tirion still running temp->SetSpeed(MOVE_RUN, 3.0f); // workarounds, make Tirion still running
temp->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); temp->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[2].x, LightofDawnLoc[2].y, LightofDawnLoc[2].z); temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[2].x, LightofDawnLoc[2].y, LightofDawnLoc[2].z);
if (Creature* temp = Unit::GetCreature(*me, uiLichKingGUID)) if (Creature* lktemp = Unit::GetCreature(*me, uiLichKingGUID))
temp->Relocate(LightofDawnLoc[28].x, LightofDawnLoc[28].y, LightofDawnLoc[28].z); // workarounds, he should kick back by Tirion, but here we relocate him lktemp->Relocate(LightofDawnLoc[28].x, LightofDawnLoc[28].y, LightofDawnLoc[28].z); // workarounds, he should kick back by Tirion, but here we relocate him
} }
JumpToNextStep(1500); JumpToNextStep(1500);
break; break;
@@ -504,15 +504,14 @@ public:
Player* SelectRandomPlayer(float range = 0.0f, bool checkLoS = true) Player* SelectRandomPlayer(float range = 0.0f, bool checkLoS = true)
{ {
Map* map = me->GetMap(); Map* map = me->GetMap();
if (!map->IsDungeon()) return NULL; if (!map->IsDungeon())
return NULL;
Map::PlayerList const &PlayerList = map->GetPlayers(); Map::PlayerList const &PlayerList = map->GetPlayers();
Map::PlayerList::const_iterator i; if (PlayerList.isEmpty())
if (PlayerList.isEmpty()) return NULL; return NULL;
std::list<Player*> temp; std::list<Player*> temp;
std::list<Player*>::const_iterator j;
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if ((me->IsWithinLOSInMap(i->getSource()) || !checkLoS) && me->getVictim() != i->getSource() && if ((me->IsWithinLOSInMap(i->getSource()) || !checkLoS) && me->getVictim() != i->getSource() &&
me->IsWithinDistInMap(i->getSource(), range) && i->getSource()->isAlive()) me->IsWithinDistInMap(i->getSource(), range) && i->getSource()->isAlive())
@@ -520,7 +519,7 @@ public:
if (!temp.empty()) if (!temp.empty())
{ {
j = temp.begin(); std::list<Player*>::const_iterator j = temp.begin();
advance(j, rand()%temp.size()); advance(j, rand()%temp.size());
return (*j); return (*j);
} }
@@ -662,11 +662,13 @@ public:
{ {
float x, y, z; float x, y, z;
Unit* target = NULL; Unit* target = NULL;
for (uint8 z = 0; z < 6; ++z) for (uint8 i = 0; i < 6; ++i)
{ {
target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true); target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
if (!target || !target->HasAura(SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT, 0))break; if (!target || !target->HasAura(SPELL_VENGEANCE_OF_THE_BLUE_FLIGHT, 0))
break;
} }
if (target) if (target)
{ {
target->GetPosition(x, y, z); target->GetPosition(x, y, z);
@@ -330,14 +330,14 @@ public:
else else
{ {
DarkFiend = false; DarkFiend = false;
for (uint8 i = 0; i < 8; ++i) for (uint8 j = 0; j < 8; ++j)
me->SummonCreature(CREATURE_DARK_FIENDS, DarkFiends[i][0], DarkFiends[i][1], DarkFiends[i][2], DarkFiends[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0); me->SummonCreature(CREATURE_DARK_FIENDS, DarkFiends[j][0], DarkFiends[j][1], DarkFiends[j][2], DarkFiends[j][3], TEMPSUMMON_CORPSE_DESPAWN, 0);
Timer[TIMER_DARKNESS] = 42000; Timer[TIMER_DARKNESS] = 42000;
} }
break; break;
case TIMER_HUMANOIDES: case TIMER_HUMANOIDES:
for (uint8 i = 0; i < 6; ++i) for (uint8 j = 0; j < 6; ++j)
me->SummonCreature(uint32(Humanoides[i][0]), Humanoides[i][1], Humanoides[i][2], Humanoides[i][3], Humanoides[i][4], TEMPSUMMON_CORPSE_DESPAWN, 0); me->SummonCreature(uint32(Humanoides[j][0]), Humanoides[j][1], Humanoides[j][2], Humanoides[j][3], Humanoides[j][4], TEMPSUMMON_CORPSE_DESPAWN, 0);
Timer[TIMER_HUMANOIDES] = 60000; Timer[TIMER_HUMANOIDES] = 60000;
break; break;
case TIMER_PHASE: case TIMER_PHASE:
@@ -205,9 +205,9 @@ public:
{ {
if (i->getSource()) if (i->getSource())
{ {
WorldPacket data(SMSG_MESSAGECHAT, 200); WorldPacket packet(SMSG_MESSAGECHAT, 200);
unit->BuildMonsterChat(&data, CHAT_MSG_MONSTER_YELL, YELL_EFFORTS, 0, YELL_EFFORTS_NAME, i->getSource()->GetGUID()); unit->BuildMonsterChat(&packet, CHAT_MSG_MONSTER_YELL, YELL_EFFORTS, 0, YELL_EFFORTS_NAME, i->getSource()->GetGUID());
i->getSource()->GetSession()->SendPacket(&data); i->getSource()->GetSession()->SendPacket(&packet);
WorldPacket data2(SMSG_PLAY_SOUND, 4); WorldPacket data2(SMSG_PLAY_SOUND, 4);
data2 << 10986; data2 << 10986;
@@ -579,13 +579,16 @@ public:
{ {
//After reset //After reset
case 0: case 0:
if (Unit* pJaina = GetClosestCreatureWithEntry(me, NPC_JAINA, 50.0f)) {
uiJainaGUID = pJaina->GetGUID(); Unit* pJaina = GetClosestCreatureWithEntry(me, NPC_JAINA, 50.0f);
else if (Unit* pJaina = me->SummonCreature(NPC_JAINA, 1895.48f, 1292.66f, 143.706f, 0.023475f, TEMPSUMMON_DEAD_DESPAWN, 180000)) if (!pJaina)
pJaina = pJaina = me->SummonCreature(NPC_JAINA, 1895.48f, 1292.66f, 143.706f, 0.023475f, TEMPSUMMON_DEAD_DESPAWN, 180000);
if (pJaina)
uiJainaGUID = pJaina->GetGUID(); uiJainaGUID = pJaina->GetGUID();
bStepping = false; bStepping = false;
JumpToNextStep(0); JumpToNextStep(0);
break; break;
}
//After waypoint 0 //After waypoint 0
case 1: case 1:
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
@@ -829,9 +832,10 @@ public:
case 37: case 37:
if (Creature* pMalganis = Unit::GetCreature(*me, uiMalganisGUID)) if (Creature* pMalganis = Unit::GetCreature(*me, uiMalganisGUID))
{ {
if (Creature* pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN, 100.0f)) Creature* pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN, 100.0f);
pZombie->UpdateEntry(NPC_ZOMBIE, 0); if (!pZombie)
else if (Creature* pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN2, 100.0f)) pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN2, 100.0f);
if (pZombie)
pZombie->UpdateEntry(NPC_ZOMBIE, 0); pZombie->UpdateEntry(NPC_ZOMBIE, 0);
else //There's no one else to transform else //There's no one else to transform
uiStep++; uiStep++;
@@ -680,12 +680,8 @@ public:
//Place all units in threat list on outside of stomach //Place all units in threat list on outside of stomach
Stomach_Map.clear(); Stomach_Map.clear();
std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); for (std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); i != me->getThreatManager().getThreatList().end(); ++i)
for (; i != me->getThreatManager().getThreatList().end(); ++i) Stomach_Map[(*i)->getUnitGuid()] = false; //Outside stomach
{
//Outside stomach
Stomach_Map[(*i)->getUnitGuid()] = false;
}
//Spawn 2 flesh tentacles //Spawn 2 flesh tentacles
FleshTentaclesKilled = 0; FleshTentaclesKilled = 0;
@@ -221,10 +221,9 @@ public:
{ {
uiVehicle1GUID = pBoss->GetGUID(); uiVehicle1GUID = pBoss->GetGUID();
uint64 uiGrandChampionBoss1 = 0; uint64 uiGrandChampionBoss1 = 0;
if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle1GUID)) if (Vehicle* pVehicle = pBoss->GetVehicleKit())
if (Vehicle* pVehicle = pBoss->GetVehicleKit()) if (Unit* unit = pVehicle->GetPassenger(0))
if (Unit* unit = pVehicle->GetPassenger(0)) uiGrandChampionBoss1 = unit->GetGUID();
uiGrandChampionBoss1 = unit->GetGUID();
if (instance) if (instance)
{ {
instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_1, uiVehicle1GUID); instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_1, uiVehicle1GUID);
@@ -237,10 +236,9 @@ public:
{ {
uiVehicle2GUID = pBoss->GetGUID(); uiVehicle2GUID = pBoss->GetGUID();
uint64 uiGrandChampionBoss2 = 0; uint64 uiGrandChampionBoss2 = 0;
if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle2GUID)) if (Vehicle* pVehicle = pBoss->GetVehicleKit())
if (Vehicle* pVehicle = pBoss->GetVehicleKit()) if (Unit* unit = pVehicle->GetPassenger(0))
if (Unit* unit = pVehicle->GetPassenger(0)) uiGrandChampionBoss2 = unit->GetGUID();
uiGrandChampionBoss2 = unit->GetGUID();
if (instance) if (instance)
{ {
instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_2, uiVehicle2GUID); instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_2, uiVehicle2GUID);
@@ -253,10 +251,9 @@ public:
{ {
uiVehicle3GUID = pBoss->GetGUID(); uiVehicle3GUID = pBoss->GetGUID();
uint64 uiGrandChampionBoss3 = 0; uint64 uiGrandChampionBoss3 = 0;
if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle3GUID)) if (Vehicle* pVehicle = pBoss->GetVehicleKit())
if (Vehicle* pVehicle = pBoss->GetVehicleKit()) if (Unit* unit = pVehicle->GetPassenger(0))
if (Unit* unit = pVehicle->GetPassenger(0)) uiGrandChampionBoss3 = unit->GetGUID();
uiGrandChampionBoss3 = unit->GetGUID();
if (instance) if (instance)
{ {
instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_3, uiVehicle3GUID); instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_3, uiVehicle3GUID);
@@ -348,10 +348,10 @@ public:
m_bTargetDied = true; m_bTargetDied = true;
me->GetMotionMaster()->MoveJump(gormok->GetPositionX(), gormok->GetPositionY(), gormok->GetPositionZ(), 15.0f, 15.0f); me->GetMotionMaster()->MoveJump(gormok->GetPositionX(), gormok->GetPositionY(), gormok->GetPositionZ(), 15.0f, 15.0f);
} }
else if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) else if (Unit* target2 = SelectTarget(SELECT_TARGET_RANDOM, 0))
{ {
m_uiTargetGUID = target->GetGUID(); m_uiTargetGUID = target2->GetGUID();
me->GetMotionMaster()->MoveJump(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 15.0f, 15.0f); me->GetMotionMaster()->MoveJump(target2->GetPositionX(), target2->GetPositionY(), target2->GetPositionZ(), 15.0f, 15.0f);
} }
} }
} }
@@ -98,8 +98,7 @@ public:
me->SetUnitMovementFlags(MOVEMENTFLAG_JUMPING); me->SetUnitMovementFlags(MOVEMENTFLAG_JUMPING);
break; break;
case 28: case 28:
if (Player* player = GetPlayerForEscort()) player->GroupEventHappens(QUEST_FORTUNATE_MISUNDERSTANDINGS, me);
player->GroupEventHappens(QUEST_FORTUNATE_MISUNDERSTANDINGS, me);
// me->RestoreFaction(); // me->RestoreFaction();
DoScriptText(SAY_END_IRO, me); DoScriptText(SAY_END_IRO, me);
SetRun(false); SetRun(false);
@@ -998,8 +998,7 @@ public:
case 50: case 50:
DoScriptText(SAY_WIL_END, me, player); DoScriptText(SAY_WIL_END, me, player);
if (Player* player = GetPlayerForEscort()) player->GroupEventHappens(QUEST_ESCAPE_COILSCAR, me);
player->GroupEventHappens(QUEST_ESCAPE_COILSCAR, me);
break; break;
} }
} }