diff options
Diffstat (limited to 'src')
106 files changed, 1686 insertions, 1601 deletions
diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index 7b2ad044eb9..c24012efcef 100755 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -616,8 +616,8 @@ bool AuthSocket::_HandleLogonProof() memcpy(proof.M2, sha.GetDigest(), 20); proof.cmd = AUTH_LOGON_PROOF; proof.error = 0; - proof.unk1 = 0x00800000; - proof.unk2 = 0x00; + proof.unk1 = 0x00800000; // Accountflags. 0x01 = GM, 0x08 = Trial, 0x00800000 = Pro pass (arena tournament) + proof.unk2 = 0x00; // SurveyId proof.unk3 = 0x00; socket().send((char *)&proof, sizeof(proof)); } diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp index 9f32c749c5c..0632542f82e 100644 --- a/src/server/collision/Management/VMapManager2.cpp +++ b/src/server/collision/Management/VMapManager2.cpp @@ -247,6 +247,9 @@ namespace VMAP WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename) { + //! Critical section, thread safe access to iLoadedModelFiles + TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock); + ModelFileMap::iterator model = iLoadedModelFiles.find(filename); if (model == iLoadedModelFiles.end()) { @@ -267,6 +270,9 @@ namespace VMAP void VMapManager2::releaseModelInstance(const std::string &filename) { + //! Critical section, thread safe access to iLoadedModelFiles + TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock); + ModelFileMap::iterator model = iLoadedModelFiles.find(filename); if (model == iLoadedModelFiles.end()) { diff --git a/src/server/collision/Management/VMapManager2.h b/src/server/collision/Management/VMapManager2.h index ac293e2071b..83fec0f0d11 100755 --- a/src/server/collision/Management/VMapManager2.h +++ b/src/server/collision/Management/VMapManager2.h @@ -22,6 +22,7 @@ #include "IVMapManager.h" #include "Dynamic/UnorderedMap.h" #include "Define.h" +#include <ace/Thread_Mutex.h> //=========================================================== @@ -71,6 +72,8 @@ namespace VMAP // Tree to check collision ModelFileMap iLoadedModelFiles; InstanceTreeMap iInstanceMapTrees; + // Mutex for iLoadedModelFiles + ACE_Thread_Mutex LoadedModelFilesLock; bool _loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY); /* void _unloadMap(uint32 pMapId, uint32 x, uint32 y); */ diff --git a/src/server/collision/Maps/TileAssembler.cpp b/src/server/collision/Maps/TileAssembler.cpp index 594e1a9382b..533a7ca825c 100644 --- a/src/server/collision/Maps/TileAssembler.cpp +++ b/src/server/collision/Maps/TileAssembler.cpp @@ -500,10 +500,10 @@ namespace VMAP { model.setGroupModels(groupsArray); - std::string filename(iSrcDir); - filename.push_back('/'); - filename.append(pModelFilename).append(".vmo"); - success = model.writeFile(filename); + std::string worldModelFileName(iSrcDir); + worldModelFileName.push_back('/'); + worldModelFileName.append(pModelFilename).append(".vmo"); + success = model.writeFile(worldModelFileName); } //std::cout << "readRawFile2: '" << pModelFilename << "' tris: " << nElements << " nodes: " << nNodes << std::endl; diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 329a2d004a5..5752fcede7b 100755 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -59,8 +59,8 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/, float maxRangeToN if (!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim()) { - if (Unit* target = creature->SelectNearestTarget(maxRangeToNearestTarget)) - creature->AI()->AttackStart(target); + if (Unit* nearTarget = creature->SelectNearestTarget(maxRangeToNearestTarget)) + creature->AI()->AttackStart(nearTarget); else if (creature->isSummon()) { if (Unit* summoner = creature->ToTempSummon()->GetSummoner()) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 9563a5d3b4c..ffe21536de4 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -224,7 +224,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsPlayer(*itr)) + if (IsUnit(*itr)) { (*itr)->SendPlaySound(e.action.sound.sound, e.action.sound.range > 0 ? true : false); sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (GuidLow: %u), sound: %u, onlyself: %u", @@ -1490,9 +1490,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (IsSmart(target)) CAST_AI(SmartAI, target->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker()); } - else if (GameObject* target = (*itr)->ToGameObject()) + else if (GameObject* goTarget = (*itr)->ToGameObject()) { - if (IsSmartGO(target)) + if (IsSmartGO(goTarget)) CAST_AI(SmartGameObjectAI, target->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker()); } } @@ -1607,9 +1607,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (IsSmart(target)) CAST_AI(SmartAI, target->AI())->SetScript9(e, id, GetLastInvoker()); } - else if (GameObject* target = (*itr)->ToGameObject()) + else if (GameObject* goTarget = (*itr)->ToGameObject()) { - if (IsSmartGO(target)) + if (IsSmartGO(goTarget)) CAST_AI(SmartGameObjectAI, target->AI())->SetScript9(e, id, GetLastInvoker()); } } @@ -1637,9 +1637,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (IsSmart(target)) CAST_AI(SmartAI, target->AI())->SetScript9(e, id, GetLastInvoker()); } - else if (GameObject* target = (*itr)->ToGameObject()) + else if (GameObject* goTarget = (*itr)->ToGameObject()) { - if (IsSmartGO(target)) + if (IsSmartGO(goTarget)) CAST_AI(SmartGameObjectAI, target->AI())->SetScript9(e, id, GetLastInvoker()); } } @@ -2298,10 +2298,10 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui if (!me || !me->isInCombat()) return; - Unit* unit = DoSelectLowestHpFriendly((float)e.event.friendlyHealt.radius, e.event.friendlyHealt.hpDeficit); - if (!unit) + Unit* target = DoSelectLowestHpFriendly((float)e.event.friendlyHealt.radius, e.event.friendlyHealt.hpDeficit); + if (!target) return; - ProcessAction(e, unit); + ProcessAction(e, target); RecalcTimer(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax); break; } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index fc3db7a0fe6..011ed75205d 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -68,10 +68,12 @@ void SmartWaypointMgr::LoadFromDB() path = new WPPath; last_id = 1; } + if (last_id != id) { sLog->outErrorDb("SmartWaypointMgr::LoadFromDB: Path entry %u, unexpected point id %u, expected %u.", entry, id, last_id); } + last_id++; (*path)[id] = wp; diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index b2842025127..af350ac39d6 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1759,12 +1759,12 @@ void Battleground::HandleKillPlayer(Player* player, Player* killer) for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - Player* player = ObjectAccessor::FindPlayer(itr->first); - if (!player || player == killer) + Player* creditedPlayer = ObjectAccessor::FindPlayer(itr->first); + if (!creditedPlayer || creditedPlayer == killer) continue; - if (player->GetTeam() == killer->GetTeam() && player->IsAtGroupRewardDistance(player)) - UpdatePlayerScore(player, SCORE_HONORABLE_KILLS, 1); + if (creditedPlayer->GetTeam() == killer->GetTeam() && creditedPlayer->IsAtGroupRewardDistance(player)) + UpdatePlayerScore(creditedPlayer, SCORE_HONORABLE_KILLS, 1); } } diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index ed5c6df16c9..0d76759e1be 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -911,68 +911,51 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId uint32 discardTime = getMSTime() - sBattlegroundMgr->GetRatingDiscardTimer(); // we need to find 2 teams which will play next game + GroupsQueueType::iterator itr_teams[BG_TEAMS_COUNT]; + uint8 found = 0; + uint8 team = 0; - GroupsQueueType::iterator itr_team[BG_TEAMS_COUNT]; - - //optimalization : --- we dont need to use selection_pools - each update we select max 2 groups - for (uint32 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++) + for (uint8 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++) { // take the group that joined first - itr_team[i] = m_QueuedGroups[bracket_id][i].begin(); - for (; itr_team[i] != m_QueuedGroups[bracket_id][i].end(); ++(itr_team[i])) + GroupsQueueType::iterator itr2 = m_QueuedGroups[bracket_id][i].begin(); + for (; itr2 != m_QueuedGroups[bracket_id][i].end(); ++itr2) { // if group match conditions, then add it to pool - if (!(*itr_team[i])->IsInvitedToBGInstanceGUID - && (((*itr_team[i])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[i])->ArenaMatchmakerRating <= arenaMaxRating) - || (*itr_team[i])->JoinTime < discardTime)) + if (!(*itr2)->IsInvitedToBGInstanceGUID + && (((*itr2)->ArenaMatchmakerRating >= arenaMinRating && (*itr2)->ArenaMatchmakerRating <= arenaMaxRating) + || (*itr2)->JoinTime < discardTime)) { - m_SelectionPools[i].AddGroup((*itr_team[i]), MaxPlayersPerTeam); - // break for cycle to be able to start selecting another group from same faction queue + itr_teams[found++] = itr2; + team = i; break; } } } - // now we are done if we have 2 groups - ali vs horde! - // if we don't have, we must try to continue search in same queue - // tmp variables are correctly set - // this code isn't much userfriendly - but it is supposed to continue search for mathing group in HORDE queue - if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() == 0 && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount()) - { - itr_team[BG_TEAM_ALLIANCE] = itr_team[BG_TEAM_HORDE]; - ++itr_team[BG_TEAM_ALLIANCE]; - for (; itr_team[BG_TEAM_ALLIANCE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++(itr_team[BG_TEAM_ALLIANCE])) - { - if (!(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID - && (((*itr_team[BG_TEAM_ALLIANCE])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[BG_TEAM_ALLIANCE])->ArenaMatchmakerRating <= arenaMaxRating) - || (*itr_team[BG_TEAM_ALLIANCE])->JoinTime < discardTime)) - { - m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*itr_team[BG_TEAM_ALLIANCE]), MaxPlayersPerTeam); - break; - } - } - } + if (!found) + return; - // this code isn't much userfriendly - but it is supposed to continue search for mathing group in ALLIANCE queue - if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == 0 && m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount()) + if (found == 1) { - itr_team[BG_TEAM_HORDE] = itr_team[BG_TEAM_ALLIANCE]; - ++itr_team[BG_TEAM_HORDE]; - for (; itr_team[BG_TEAM_HORDE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++(itr_team[BG_TEAM_HORDE])) + for (GroupsQueueType::iterator itr3 = itr_teams[0]; itr3 != m_QueuedGroups[bracket_id][team].end(); ++itr3) { - if (!(*itr_team[BG_TEAM_HORDE])->IsInvitedToBGInstanceGUID - && (((*itr_team[BG_TEAM_HORDE])->ArenaMatchmakerRating >= arenaMinRating && (*itr_team[BG_TEAM_HORDE])->ArenaMatchmakerRating <= arenaMaxRating) - || (*itr_team[BG_TEAM_HORDE])->JoinTime < discardTime)) + if (!(*itr3)->IsInvitedToBGInstanceGUID + && (((*itr3)->ArenaMatchmakerRating >= arenaMinRating && (*itr3)->ArenaMatchmakerRating <= arenaMaxRating) + || (*itr3)->JoinTime < discardTime) + && (*itr_teams[0])->ArenaTeamId != (*itr3)->ArenaTeamId) { - m_SelectionPools[BG_TEAM_HORDE].AddGroup((*itr_team[BG_TEAM_HORDE]), MaxPlayersPerTeam); + itr_teams[found++] = itr3; break; } } } //if we have 2 teams, then start new arena and invite players! - if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount()) + if (found == 2) { + GroupQueueInfo* aTeam = *itr_teams[BG_TEAM_ALLIANCE]; + GroupQueueInfo* hTeam = *itr_teams[BG_TEAM_HORDE]; Battleground* arena = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenaType, true); if (!arena) { @@ -980,35 +963,31 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId return; } - (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamRating; - (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsMatchmakerRating = (*(itr_team[BG_TEAM_HORDE]))->ArenaMatchmakerRating; - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamId, (*(itr_team[BG_TEAM_ALLIANCE]))->OpponentsTeamRating); - (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaTeamRating; - (*(itr_team[BG_TEAM_HORDE]))->OpponentsMatchmakerRating = (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaMatchmakerRating; - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", (*(itr_team[BG_TEAM_HORDE]))->ArenaTeamId, (*(itr_team[BG_TEAM_HORDE]))->OpponentsTeamRating); + aTeam->OpponentsTeamRating = hTeam->ArenaTeamRating; + hTeam->OpponentsTeamRating = aTeam->ArenaTeamRating; + aTeam->OpponentsMatchmakerRating = hTeam->ArenaMatchmakerRating; + hTeam->OpponentsMatchmakerRating = aTeam->ArenaMatchmakerRating; + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", aTeam->ArenaTeamId, aTeam->OpponentsTeamRating); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "setting oposite teamrating for team %u to %u", hTeam->ArenaTeamId, hTeam->OpponentsTeamRating); + // now we must move team if we changed its faction to another faction queue, because then we will spam log by errors in Queue::RemovePlayer - if ((*(itr_team[BG_TEAM_ALLIANCE]))->Team != ALLIANCE) + if (aTeam->Team != ALLIANCE) { - // add to alliance queue - m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(*(itr_team[BG_TEAM_ALLIANCE])); - // erase from horde queue - m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_team[BG_TEAM_ALLIANCE]); - itr_team[BG_TEAM_ALLIANCE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin(); + m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(aTeam); + m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_teams[BG_TEAM_ALLIANCE]); } - if ((*(itr_team[BG_TEAM_HORDE]))->Team != HORDE) + if (hTeam->Team != HORDE) { - m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(*(itr_team[BG_TEAM_HORDE])); - m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_team[BG_TEAM_HORDE]); - itr_team[BG_TEAM_HORDE] = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].begin(); + m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(hTeam); + m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_teams[BG_TEAM_HORDE]); } - arena->SetArenaMatchmakerRating(ALLIANCE, (*(itr_team[BG_TEAM_ALLIANCE]))->ArenaMatchmakerRating); - arena->SetArenaMatchmakerRating(HORDE, (*(itr_team[BG_TEAM_HORDE]))->ArenaMatchmakerRating); - InviteGroupToBG(*(itr_team[BG_TEAM_ALLIANCE]), arena, ALLIANCE); - InviteGroupToBG(*(itr_team[BG_TEAM_HORDE]), arena, HORDE); + arena->SetArenaMatchmakerRating(ALLIANCE, aTeam->ArenaMatchmakerRating); + arena->SetArenaMatchmakerRating( HORDE, hTeam->ArenaMatchmakerRating); + InviteGroupToBG(aTeam, arena, ALLIANCE); + InviteGroupToBG(hTeam, arena, HORDE); sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Starting rated arena match!"); - arena->StartBattleground(); } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 491584557a3..fe570930870 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -1348,23 +1348,23 @@ bool BattlegroundAV::SetupBattleground() //creatures sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV start poputlating nodes"); - for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) + for (i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) { if (m_Nodes[i].Owner) - PopulateNode(i); + PopulateNode(BG_AV_Nodes(i)); } //all creatures which don't get despawned through the script are static sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV: start spawning static creatures"); - for (i=0; i < AV_STATICCPLACE_MAX; i++) - AddAVCreature(0, i+AV_CPLACE_MAX); + for (i = 0; i < AV_STATICCPLACE_MAX; i++) + AddAVCreature(0, i + AV_CPLACE_MAX); //mainspiritguides: sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV: start spawning spiritguides creatures"); AddSpiritGuide(7, BG_AV_CreaturePos[7][0], BG_AV_CreaturePos[7][1], BG_AV_CreaturePos[7][2], BG_AV_CreaturePos[7][3], ALLIANCE); AddSpiritGuide(8, BG_AV_CreaturePos[8][0], BG_AV_CreaturePos[8][1], BG_AV_CreaturePos[8][2], BG_AV_CreaturePos[8][3], HORDE); //spawn the marshals (those who get deleted, if a tower gets destroyed) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV: start spawning marshal creatures"); - for (i=AV_NPC_A_MARSHAL_SOUTH; i <= AV_NPC_H_MARSHAL_WTOWER; i++) - AddAVCreature(i, AV_CPLACE_A_MARSHAL_SOUTH+(i-AV_NPC_A_MARSHAL_SOUTH)); + for (i = AV_NPC_A_MARSHAL_SOUTH; i <= AV_NPC_H_MARSHAL_WTOWER; i++) + AddAVCreature(i, AV_CPLACE_A_MARSHAL_SOUTH + (i - AV_NPC_A_MARSHAL_SOUTH)); AddAVCreature(AV_NPC_HERALD, AV_CPLACE_HERALD); return true; } diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 7717d319bb0..1968de70f46 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -85,7 +85,7 @@ Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) } else // save { - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHANNEL); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHANNEL); stmt->setString(0, name); stmt->setUInt32(1, m_Team); CharacterDatabase.Execute(stmt); @@ -563,12 +563,12 @@ void Channel::List(Player* player) uint32 count = 0; for (PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) { - Player* player = ObjectAccessor::FindPlayer(i->first); + Player* member = ObjectAccessor::FindPlayer(i->first); // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all - if (player && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || player->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && - player->IsVisibleGloballyFor(player)) + if (member && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || member->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && + member->IsVisibleGloballyFor(player)) { data << uint64(i->first); data << uint8(i->second.flags); // flags seems to be changed... diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index 763f3654860..1dd603094f6 100755 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -349,18 +349,18 @@ bool ChatHandler::HandlePInfoCommand(const char* args) std::string bannedby = "unknown"; std::string banreason = ""; - if (QueryResult result = LoginDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM account_banned " + if (QueryResult result2 = LoginDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM account_banned " "WHERE id = '%u' AND active ORDER BY bandate ASC LIMIT 1", accId)) { - Field* fields = result->Fetch(); + Field* fields = result2->Fetch(); banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64(); bannedby = fields[2].GetString(); banreason = fields[3].GetString(); } - else if (QueryResult result = CharacterDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM character_banned " + else if (QueryResult result3 = CharacterDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM character_banned " "WHERE guid = '%u' AND active ORDER BY bandate ASC LIMIT 1", GUID_LOPART(target_guid))) { - Field* fields = result->Fetch(); + Field* fields = result3->Fetch(); banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64(); bannedby = fields[2].GetString(); banreason = fields[3].GetString(); diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index dafb0ebc11f..07febf889d0 100755 --- a/src/server/game/Conditions/DisableMgr.cpp +++ b/src/server/game/Conditions/DisableMgr.cpp @@ -277,26 +277,25 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags { case DISABLE_TYPE_SPELL: { - uint8 flags = itr->second.flags; + uint8 spellFlags = itr->second.flags; if (unit) { - - if ((flags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) || - (unit->GetTypeId() == TYPEID_UNIT && ((unit->ToCreature()->isPet() && flags & SPELL_DISABLE_PET) || flags & SPELL_DISABLE_CREATURE))) + if ((spellFlags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) || + (unit->GetTypeId() == TYPEID_UNIT && ((unit->ToCreature()->isPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE))) { - if (flags & SPELL_DISABLE_MAP) + if (spellFlags & SPELL_DISABLE_MAP) { std::set<uint32> const& mapIds = itr->second.params[0]; if (mapIds.find(unit->GetMapId()) != mapIds.end()) return true; // Spell is disabled on current map - if (!(flags & SPELL_DISABLE_AREA)) + if (!(spellFlags & SPELL_DISABLE_AREA)) return false; // Spell is disabled on another map, but not this one, return false // Spell is disabled in an area, but not explicitly our current mapId. Continue processing. } - if (flags & SPELL_DISABLE_AREA) + if (spellFlags & SPELL_DISABLE_AREA) { std::set<uint32> const& areaIds = itr->second.params[1]; if (areaIds.find(unit->GetAreaId()) != areaIds.end()) @@ -309,8 +308,10 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags 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; + + break; } case DISABLE_TYPE_MAP: if (Player const* player = unit->ToPlayer()) diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index faa73cefb11..6815d73d1b3 100755 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -71,6 +71,7 @@ DBCStorage <ChrRacesEntry> sChrRacesStore(ChrRacesEntryfmt); DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore(CinematicSequencesEntryfmt); DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore(CreatureDisplayInfofmt); DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore(CreatureFamilyfmt); +DBCStorage <CreatureModelDataEntry> sCreatureModelDataStore(CreatureModelDatafmt); DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore(CreatureSpellDatafmt); DBCStorage <CreatureTypeEntry> sCreatureTypeStore(CreatureTypefmt); DBCStorage <CurrencyTypesEntry> sCurrencyTypesStore(CurrencyTypesfmt); @@ -292,6 +293,7 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales, bad_dbc_files, sCinematicSequencesStore, dbcPath, "CinematicSequences.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureDisplayInfoStore, dbcPath, "CreatureDisplayInfo.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureFamilyStore, dbcPath, "CreatureFamily.dbc"); + LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureModelDataStore, dbcPath, "CreatureModelData.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureSpellDataStore, dbcPath, "CreatureSpellData.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCreatureTypeStore, dbcPath, "CreatureType.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sCurrencyTypesStore, dbcPath, "CurrencyTypes.dbc"); diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h index 367746616d1..7edfaad03f1 100755 --- a/src/server/game/DataStores/DBCStores.h +++ b/src/server/game/DataStores/DBCStores.h @@ -81,6 +81,7 @@ extern DBCStorage <ChrRacesEntry> sChrRacesStore; extern DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore; extern DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore; extern DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore; +extern DBCStorage <CreatureModelDataEntry> sCreatureModelDataStore; extern DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore; extern DBCStorage <CreatureTypeEntry> sCreatureTypeStore; extern DBCStorage <CurrencyTypesEntry> sCurrencyTypesStore; diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index e01acd2e03d..ba7be495c77 100755 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -723,7 +723,7 @@ struct CinematicSequencesEntry struct CreatureDisplayInfoEntry { uint32 Displayid; // 0 m_ID - // 1 m_modelID + uint32 ModelId; // 1 m_modelID // 2 m_soundID // 3 m_extendedDisplayInfoID float scale; // 4 m_creatureModelScale @@ -754,6 +754,28 @@ struct CreatureFamilyEntry // 27 m_iconFile }; +struct CreatureModelDataEntry +{ + uint32 Id; + //uint32 Flags; + //char* ModelPath[16] + //uint32 Unk1; + float Scale; // Used in calculation of unit collision data + //int32 Unk2 + //int32 Unk3 + //uint32 Unk4 + //uint32 Unk5 + //float Unk6 + //uint32 Unk7 + //float Unk8 + //uint32 Unk9 + //uint32 Unk10 + //float CollisionWidth; + float CollisionHeight; + float MountHeight; // Used in calculation of unit collision data when mounted + //float Unks[11] +}; + #define MAX_CREATURE_SPELL_DATA_SLOT 4 struct CreatureSpellDataEntry diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h index 5d33a3011ab..ac0b60d7f80 100755 --- a/src/server/game/DataStores/DBCfmt.h +++ b/src/server/game/DataStores/DBCfmt.h @@ -38,8 +38,9 @@ const char ChatChannelsEntryfmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxx"; const char ChrClassesEntryfmt[]="nxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii"; const char ChrRacesEntryfmt[]="nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi"; const char CinematicSequencesEntryfmt[]="nxxxxxxxxx"; -const char CreatureDisplayInfofmt[]="nxxxfxxxxxxxxxxx"; +const char CreatureDisplayInfofmt[]="nixxfxxxxxxxxxxx"; const char CreatureFamilyfmt[]="nfifiiiiixssssssssssssssssxx"; +const char CreatureModelDatafmt[]="nxxxfxxxxxxxxxxffxxxxxxxxxxx"; const char CreatureSpellDatafmt[]="niiiixxxx"; const char CreatureTypefmt[]="nxxxxxxxxxxxxxxxxxx"; const char CurrencyTypesfmt[]="xnxi"; diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 1364f739663..55f798204db 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -254,7 +254,7 @@ void LFGMgr::Update(uint32 diff) if (m_QueueTimer > LFG_QUEUEUPDATE_INTERVAL) { m_QueueTimer = 0; - time_t currTime = time(NULL); + currTime = time(NULL); for (LfgQueueInfoMap::const_iterator itQueue = m_QueueInfoMap.begin(); itQueue != m_QueueInfoMap.end(); ++itQueue) { LfgQueueInfo* queue = itQueue->second; @@ -689,10 +689,9 @@ void LFGMgr::Leave(Player* player, Group* grp /* = NULL*/) { // Remove from Proposals LfgProposalMap::iterator it = m_Proposals.begin(); - uint64 guid = player ? player->GetGUID() : grp->GetLeaderGUID(); while (it != m_Proposals.end()) { - LfgProposalPlayerMap::iterator itPlayer = it->second->players.find(guid); + LfgProposalPlayerMap::iterator itPlayer = it->second->players.find(player ? player->GetGUID() : grp->GetLeaderGUID()); if (itPlayer != it->second->players.end()) { // Mark the player/leader of group who left as didn't accept the proposal @@ -1069,10 +1068,10 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /* // Set queue roles needed - As we are using check_roles will not have more that 1 tank, 1 healer, 3 dps for (LfgRolesMap::const_iterator it = check_roles.begin(); it != check_roles.end(); ++it) { - uint8 roles = it->second; - if (roles & ROLE_TANK) + uint8 roles2 = it->second; + if (roles2 & ROLE_TANK) --pqInfo->tanks; - else if (roles & ROLE_HEALER) + else if (roles2 & ROLE_HEALER) --pqInfo->healers; else --pqInfo->dps; @@ -1152,14 +1151,14 @@ void LFGMgr::GetCompatibleDungeons(LfgDungeonSet& dungeons, const PlayerSet& pla { uint64 guid = (*it)->GetGUID(); LfgLockMap cachedLockMap = GetLockedDungeons(guid); - for (LfgLockMap::const_iterator it = cachedLockMap.begin(); it != cachedLockMap.end() && dungeons.size(); ++it) + for (LfgLockMap::const_iterator it2 = cachedLockMap.begin(); it2 != cachedLockMap.end() && dungeons.size(); ++it2) { - uint32 dungeonId = (it->first & 0x00FFFFFF); // Compare dungeon ids + uint32 dungeonId = (it2->first & 0x00FFFFFF); // Compare dungeon ids LfgDungeonSet::iterator itDungeon = dungeons.find(dungeonId); if (itDungeon != dungeons.end()) { dungeons.erase(itDungeon); - lockMap[guid][dungeonId] = it->second; + lockMap[guid][dungeonId] = it2->second; } } } @@ -1313,8 +1312,8 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) if (player->groupLowGuid != lowgroupguid) sLog->outError("LFGMgr::UpdateProposal: [" UI64FMTD "] group mismatch: actual (%u) - queued (%u)", (*it)->GetGUID(), lowgroupguid, player->groupLowGuid); - uint64 guid = player->groupLowGuid ? MAKE_NEW_GUID(player->groupLowGuid, 0, HIGHGUID_GROUP) : (*it)->GetGUID(); - LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid); + uint64 guid2 = player->groupLowGuid ? MAKE_NEW_GUID(player->groupLowGuid, 0, HIGHGUID_GROUP) : (*it)->GetGUID(); + LfgQueueInfoMap::iterator itQueue = m_QueueInfoMap.find(guid2); if (itQueue == m_QueueInfoMap.end()) { sLog->outError("LFGMgr::UpdateProposal: Queue info for guid [" UI64FMTD "] not found!", guid); @@ -1399,10 +1398,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) // Remove players/groups from Queue for (LfgGuidList::const_iterator it = pProposal->queues.begin(); it != pProposal->queues.end(); ++it) - { - uint64 guid = (*it); - RemoveFromQueue(guid); - } + RemoveFromQueue(*it); // Teleport Player for (LfgPlayerList::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it) diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index 0d11405789d..95cb2e81869 100755 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -292,6 +292,7 @@ class LFGMgr LfgState GetState(uint64 guid); const LfgDungeonSet& GetSelectedDungeons(uint64 guid); uint32 GetDungeon(uint64 guid, bool asId = true); + void SetState(uint64 guid, LfgState state); void ClearState(uint64 guid); void RemovePlayerData(uint64 guid); void RemoveGroupData(uint64 guid); @@ -304,7 +305,6 @@ class LFGMgr uint8 GetRoles(uint64 guid); const std::string& GetComment(uint64 gguid); void RestoreState(uint64 guid); - void SetState(uint64 guid, LfgState state); void SetDungeon(uint64 guid, uint32 dungeon); void SetSelectedDungeons(uint64 guid, const LfgDungeonSet& dungeons); void SetLockedDungeons(uint64 guid, const LfgLockMap& lock); diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index f553b069162..42119a02ef8 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -82,6 +82,7 @@ void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, } sLFGMgr->ClearState(guid); + sLFGMgr->SetState(guid, LFG_STATE_NONE); if (Player* player = ObjectAccessor::FindPlayer(guid)) { /* diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 90011dbae22..5bf7910466c 100755 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -337,13 +337,13 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, data << uint32(quest->GetRewChoiceItemsCount()); for (uint32 i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i) { - if (!quest->RewChoiceItemId[i]) + if (!quest->RewardChoiceItemId[i]) continue; - data << uint32(quest->RewChoiceItemId[i]); - data << uint32(quest->RewChoiceItemCount[i]); + data << uint32(quest->RewardChoiceItemId[i]); + data << uint32(quest->RewardChoiceItemCount[i]); - if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewChoiceItemId[i])) + if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i])) data << uint32(itemTemplate->DisplayInfoID); else data << uint32(0x00); @@ -353,13 +353,13 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, for (uint32 i=0; i < QUEST_REWARDS_COUNT; ++i) { - if (!quest->RewItemId[i]) + if (!quest->RewardItemId[i]) continue; - data << uint32(quest->RewItemId[i]); - data << uint32(quest->RewItemCount[i]); + data << uint32(quest->RewardItemId[i]); + data << uint32(quest->RewardItemIdCount[i]); - if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewItemId[i])) + if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardItemId[i])) data << uint32(itemTemplate->DisplayInfoID); else data << uint32(0); @@ -380,13 +380,13 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, data << uint32(0); // unk for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - data << uint32(quest->RewRepFaction[i]); + data << uint32(quest->RewardFactionId[i]); for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - data << int32(quest->RewRepValueId[i]); + data << int32(quest->RewardFactionValueId[i]); for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - data << int32(quest->RewRepValue[i]); + data << int32(quest->RewardFactionValueIdOverride[i]); data << uint32(QUEST_EMOTE_COUNT); for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i) @@ -478,24 +478,24 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const { for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i) { - data << uint32(quest->RewItemId[i]); - data << uint32(quest->RewItemCount[i]); + data << uint32(quest->RewardItemId[i]); + data << uint32(quest->RewardItemIdCount[i]); } for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) { - data << uint32(quest->RewChoiceItemId[i]); - data << uint32(quest->RewChoiceItemCount[i]); + data << uint32(quest->RewardChoiceItemId[i]); + data << uint32(quest->RewardChoiceItemCount[i]); } } for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids - data << uint32(quest->RewRepFaction[i]); + data << uint32(quest->RewardFactionId[i]); for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid+1 QuestFactionReward.dbc? - data << int32(quest->RewRepValueId[i]); + data << int32(quest->RewardFactionValueId[i]); for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // unk (0) - data << int32(quest->RewRepValue[i]); + data << int32(quest->RewardFactionValueIdOverride[i]); data << quest->GetPointMapId(); data << quest->GetPointX(); @@ -510,20 +510,20 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { - if (quest->ReqCreatureOrGOId[i] < 0) - data << uint32((quest->ReqCreatureOrGOId[i] * (-1)) | 0x80000000); // client expects gameobject template id in form (id|0x80000000) + if (quest->RequiredNpcOrGo[i] < 0) + data << uint32((quest->RequiredNpcOrGo[i] * (-1)) | 0x80000000); // client expects gameobject template id in form (id|0x80000000) else - data << uint32(quest->ReqCreatureOrGOId[i]); + data << uint32(quest->RequiredNpcOrGo[i]); - data << uint32(quest->ReqCreatureOrGOCount[i]); - data << uint32(quest->ReqSourceId[i]); + data << uint32(quest->RequiredNpcOrGoCount[i]); + data << uint32(quest->RequiredSourceItemid[i]); data << uint32(0); // req source count? } for (uint32 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { - data << uint32(quest->ReqItemId[i]); - data << uint32(quest->ReqItemCount[i]); + data << uint32(quest->RequiredItemId[i]); + data << uint32(quest->RequiredItemCount[i]); } for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) @@ -576,10 +576,10 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b data << uint32(quest->GetRewChoiceItemsCount()); for (uint32 i=0; i < quest->GetRewChoiceItemsCount(); ++i) { - data << uint32(quest->RewChoiceItemId[i]); - data << uint32(quest->RewChoiceItemCount[i]); + data << uint32(quest->RewardChoiceItemId[i]); + data << uint32(quest->RewardChoiceItemCount[i]); - if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewChoiceItemId[i])) + if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i])) data << uint32(itemTemplate->DisplayInfoID); else data << uint32(0); @@ -588,10 +588,10 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b data << uint32(quest->GetRewItemsCount()); for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i) { - data << uint32(quest->RewItemId[i]); - data << uint32(quest->RewItemCount[i]); + data << uint32(quest->RewardItemId[i]); + data << uint32(quest->RewardItemIdCount[i]); - if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewItemId[i])) + if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardItemId[i])) data << uint32(itemTemplate->DisplayInfoID); else data << uint32(0); @@ -612,13 +612,13 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b data << uint32(0); for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids - data << uint32(quest->RewRepFaction[i]); + data << uint32(quest->RewardFactionId[i]); for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (zero based)? - data << int32(quest->RewRepValueId[i]); + data << int32(quest->RewardFactionValueId[i]); for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override? - data << uint32(quest->RewRepValue[i]); + data << uint32(quest->RewardFactionValueIdOverride[i]); _session->SendPacket(&data); sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId()); @@ -676,13 +676,13 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, data << uint32(quest->GetReqItemsCount()); for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { - if (!quest->ReqItemId[i]) + if (!quest->RequiredItemId[i]) continue; - data << uint32(quest->ReqItemId[i]); - data << uint32(quest->ReqItemCount[i]); + data << uint32(quest->RequiredItemId[i]); + data << uint32(quest->RequiredItemCount[i]); - if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->ReqItemId[i])) + if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i])) data << uint32(itemTemplate->DisplayInfoID); else data << uint32(0); diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index a354422c9ae..978d9accb64 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1273,6 +1273,8 @@ void WorldObject::setActive(bool on) void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/) { + if (IsInWorld()) + RemoveFromWorld(); } void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask) diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index dfcf6a3cfa4..eab4dbeba99 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -527,9 +527,11 @@ template<class T> class GridObject { public: - GridReference<T> &GetGridRef() { return m_gridRef; } - protected: - GridReference<T> m_gridRef; + bool IsInGrid() const { return _gridRef.isValid(); } + void AddToGrid(GridRefManager<T>& m) { ASSERT(!IsInGrid()); _gridRef.link(&m, (T*)this); } + void RemoveFromGrid() { ASSERT(IsInGrid()); _gridRef.unlink(); } + private: + GridReference<T> _gridRef; }; template <class T_VALUES, class T_FLAGS, class FLAG_TYPE, uint8 ARRAY_SIZE> @@ -667,12 +669,17 @@ class WorldObject : public Object, public WorldLocation } float GetDistanceZ(const WorldObject* obj) const; + bool IsSelfOrInSameMap(const WorldObject* obj) const + { + if (this == obj) + return true; + return IsInMap(obj); + } bool IsInMap(const WorldObject* obj) const { if (obj) return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap()) && InSamePhase(obj); - else - return false; + return false; } bool IsWithinDist3d(float x, float y, float z, float dist) const { return IsInDist(x, y, z, dist + GetObjectSize()); } diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 82c551c2374..404fe24d467 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -382,29 +382,29 @@ void Pet::SavePetToDB(PetSaveMode mode) // current/stable/not_in_slot if (mode >= PET_SAVE_AS_CURRENT) { - uint32 owner = GUID_LOPART(GetOwnerGUID()); + uint32 ownerLowGUID = GUID_LOPART(GetOwnerGUID()); std::string name = m_name; CharacterDatabase.EscapeString(name); - SQLTransaction trans = CharacterDatabase.BeginTransaction(); + trans = CharacterDatabase.BeginTransaction(); // remove current data - trans->PAppend("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", owner, m_charmInfo->GetPetNumber()); + trans->PAppend("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", ownerLowGUID, m_charmInfo->GetPetNumber()); // prevent duplicate using slot (except PET_SAVE_NOT_IN_SLOT) if (mode <= PET_SAVE_LAST_STABLE_SLOT) trans->PAppend("UPDATE character_pet SET slot = '%u' WHERE owner = '%u' AND slot = '%u'", - PET_SAVE_NOT_IN_SLOT, owner, uint32(mode)); + PET_SAVE_NOT_IN_SLOT, ownerLowGUID, uint32(mode)); // prevent existence another hunter pet in PET_SAVE_AS_CURRENT and PET_SAVE_NOT_IN_SLOT - if (getPetType() == HUNTER_PET && (mode == PET_SAVE_AS_CURRENT||mode > PET_SAVE_LAST_STABLE_SLOT)) + if (getPetType() == HUNTER_PET && (mode == PET_SAVE_AS_CURRENT || mode > PET_SAVE_LAST_STABLE_SLOT)) trans->PAppend("DELETE FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u')", - owner, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT); + ownerLowGUID, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT); // save pet std::ostringstream ss; ss << "INSERT INTO character_pet (id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, CreatedBySpell, PetType) " << "VALUES (" << m_charmInfo->GetPetNumber() << ',' << GetEntry() << ',' - << owner << ',' + << ownerLowGUID << ',' << GetNativeDisplayId() << ',' << uint32(getLevel()) << ',' << GetUInt32Value(UNIT_FIELD_PETEXPERIENCE) << ',' diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index adcefdddab2..401e965f816 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -279,10 +279,8 @@ uint32 PlayerTaxi::GetCurrentTaxiPath() const std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi) { - ss << '\''; for (uint8 i = 0; i < TaxiMaskSize; ++i) ss << taxi.m_taximask[i] << ' '; - ss << '\''; return ss; } @@ -940,7 +938,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo) return false; } - SetMap(sMapMgr->CreateMap(info->mapId, this, 0)); + SetMap(sMapMgr->CreateMap(info->mapId, this)); uint8 powertype = cEntry->powerType; @@ -2205,8 +2203,11 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (!sMapMgr->CanPlayerEnter(mapid, this, false)) return false; - Map* map = sMapMgr->CreateMap(mapid, this, 0); - if (!map || map->CanEnter(this)) + //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. + // It will be created in the WorldPortAck. + //Map* map = sMapMgr->FindBaseNonInstanceMap(mapid); + //if (!map || map->CanEnter(this)) { //lets reset near teleport flag if it wasn't reset during chained teleports SetSemaphoreTeleportNear(false); @@ -2277,7 +2278,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // remove from old map now if (oldmap) - oldmap->RemoveFromMap(this, false); + oldmap->RemovePlayerFromMap(this, false); // new final coordinates float final_x = x; @@ -2315,8 +2316,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 SetSemaphoreTeleportFar(true); } - else - return false; + //else + // return false; } return true; } @@ -3087,7 +3088,8 @@ void Player::GiveLevel(uint8 level) // Refer-A-Friend if (GetSession()->GetRecruiterId()) if (level < sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL)) - if (level % 2 == 0) { + if (level % 2 == 0) + { ++m_grantableLevels; if (!HasByteFlag(PLAYER_FIELD_BYTES, 1, 0x01)) @@ -3482,7 +3484,7 @@ bool Player::AddTalent(uint32 spell_id, uint8 spec, bool learning) if (!rankSpellId || rankSpellId == spell_id) continue; - PlayerTalentMap::iterator itr = m_talents[spec]->find(rankSpellId); + itr = m_talents[spec]->find(rankSpellId); if (itr != m_talents[spec]->end()) itr->second->state = PLAYERSPELL_REMOVED; } @@ -4092,8 +4094,6 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank) 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 (talentCosts) { @@ -4241,8 +4241,8 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns) if (Pet* pet = GetPet()) { // notify player - for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr) - SendClearCooldown(itr->first, pet); + for (CreatureSpellCooldowns::const_iterator itr2 = pet->m_CreatureSpellCooldowns.begin(); itr2 != pet->m_CreatureSpellCooldowns.end(); ++itr2) + SendClearCooldown(itr2->first, pet); // actually clear cooldowns pet->m_CreatureSpellCooldowns.clear(); @@ -4395,9 +4395,9 @@ bool Player::resetTalents(bool no_cost) 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) continue; @@ -4833,14 +4833,14 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC { do { - Field* fields = resultItems->Fetch(); - uint32 item_guidlow = fields[11].GetUInt32(); - uint32 item_template = fields[12].GetUInt32(); + Field* fields2 = resultItems->Fetch(); + uint32 item_guidlow = fields2[11].GetUInt32(); + uint32 item_template = fields2[12].GetUInt32(); ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(item_template); if (!itemProto) { - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); stmt->setUInt32(0, item_guidlow); trans->Append(stmt); continue; @@ -5087,8 +5087,6 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0)) SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND); - setDeathState(ALIVE); - SetMovement(MOVE_LAND_WALK); SetMovement(MOVE_UNROOT); @@ -5118,6 +5116,8 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) // update visibility UpdateObjectVisibility(); + setDeathState(ALIVE); + if (!applySickness) return; @@ -7016,22 +7016,22 @@ void Player::RewardReputation(Quest const* quest) // quest reputation reward/loss for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) { - if (!quest->RewRepFaction[i]) + if (!quest->RewardFactionId[i]) continue; - if (quest->RewRepValue[i]) + if (quest->RewardFactionValueIdOverride[i]) { - int32 rep = CalculateReputationGain(GetQuestLevel(quest), quest->RewRepValue[i]/100, quest->RewRepFaction[i], true, true); + int32 rep = CalculateReputationGain(GetQuestLevel(quest), quest->RewardFactionValueIdOverride[i]/100, quest->RewardFactionId[i], true, true); if (recruitAFriend) rep = int32(rep * (1 + sWorld->getRate(RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS))); - if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewRepFaction[i])) + if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i])) GetReputationMgr().ModifyReputation(factionEntry, rep); } else { - uint32 row = ((quest->RewRepValueId[i] < 0) ? 1 : 0) + 1; - uint32 field = abs(quest->RewRepValueId[i]); + uint32 row = ((quest->RewardFactionValueId[i] < 0) ? 1 : 0) + 1; + uint32 field = abs(quest->RewardFactionValueId[i]); if (const QuestFactionRewEntry* pRow = sQuestFactionRewardStore.LookupEntry(row)) { @@ -7040,12 +7040,12 @@ void Player::RewardReputation(Quest const* quest) if (!repPoints) continue; - repPoints = CalculateReputationGain(GetQuestLevel(quest), repPoints, quest->RewRepFaction[i], true); + repPoints = CalculateReputationGain(GetQuestLevel(quest), repPoints, quest->RewardFactionId[i], true); if (recruitAFriend) repPoints = int32(repPoints * (1 + sWorld->getRate(RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS))); - if (const FactionEntry* factionEntry = sFactionStore.LookupEntry(quest->RewRepFaction[i])) + if (const FactionEntry* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i])) GetReputationMgr().ModifyReputation(factionEntry, repPoints); } } @@ -14514,7 +14514,7 @@ Quest const* Player::GetNextQuest(uint64 guid, Quest const* quest) bool Player::CanSeeStartQuest(Quest const* quest) { - if (SatisfyQuestRace(quest, false) && SatisfyQuestSkillOrClass(quest, false) && + if (SatisfyQuestClass(quest, false) && SatisfyQuestRace(quest, false) && SatisfyQuestSkill(quest, false) && SatisfyQuestExclusiveGroup(quest, false) && SatisfyQuestReputation(quest, false) && SatisfyQuestPreviousQuest(quest, false) && SatisfyQuestNextChain(quest, false) && SatisfyQuestPrevChain(quest, false) && SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) && @@ -14529,8 +14529,8 @@ bool Player::CanSeeStartQuest(Quest const* quest) bool Player::CanTakeQuest(Quest const* quest, bool msg) { return SatisfyQuestStatus(quest, msg) && SatisfyQuestExclusiveGroup(quest, msg) - && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg) - && SatisfyQuestSkillOrClass(quest, msg) && SatisfyQuestReputation(quest, msg) + && SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg) + && SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg) && SatisfyQuestPreviousQuest(quest, msg) && SatisfyQuestTimed(quest, msg) && SatisfyQuestNextChain(quest, msg) && SatisfyQuestPrevChain(quest, msg) && SatisfyQuestDay(quest, msg) && SatisfyQuestWeek(quest, msg) @@ -14589,7 +14589,7 @@ bool Player::CanCompleteQuest(uint32 quest_id) { for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++) { - if (qInfo->ReqItemCount[i]!= 0 && q_status.m_itemcount[i] < qInfo->ReqItemCount[i]) + if (qInfo->RequiredItemCount[i]!= 0 && q_status.m_itemcount[i] < qInfo->RequiredItemCount[i]) return false; } } @@ -14598,10 +14598,10 @@ bool Player::CanCompleteQuest(uint32 quest_id) { for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) { - if (qInfo->ReqCreatureOrGOId[i] == 0) + if (qInfo->RequiredNpcOrGo[i] == 0) continue; - if (qInfo->ReqCreatureOrGOCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->ReqCreatureOrGOCount[i]) + if (qInfo->RequiredNpcOrGoCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->RequiredNpcOrGoCount[i]) return false; } } @@ -14642,7 +14642,7 @@ bool Player::CanCompleteRepeatableQuest(Quest const* quest) if (quest->HasFlag(QUEST_TRINITY_FLAGS_DELIVER)) for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++) - if (quest->ReqItemId[i] && quest->ReqItemCount[i] && !HasItemCount(quest->ReqItemId[i], quest->ReqItemCount[i])) + if (quest->RequiredItemId[i] && quest->RequiredItemCount[i] && !HasItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i])) return false; if (!CanRewardQuest(quest, false)) @@ -14670,11 +14670,11 @@ bool Player::CanRewardQuest(Quest const* quest, bool msg) { for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++) { - if (quest->ReqItemCount[i]!= 0 && - GetItemCount(quest->ReqItemId[i]) < quest->ReqItemCount[i]) + if (quest->RequiredItemCount[i]!= 0 && + GetItemCount(quest->RequiredItemId[i]) < quest->RequiredItemCount[i]) { if (msg) - SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL, quest->ReqItemId[i]); + SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL, quest->RequiredItemId[i]); return false; } } @@ -14695,13 +14695,13 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg) if (quest->GetRewChoiceItemsCount() > 0) { - if (quest->RewChoiceItemId[reward]) + if (quest->RewardChoiceItemId[reward]) { ItemPosCountVec dest; - InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewChoiceItemId[reward], quest->RewChoiceItemCount[reward]); + InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardChoiceItemId[reward], quest->RewardChoiceItemCount[reward]); if (res != EQUIP_ERR_OK) { - SendEquipError(res, NULL, NULL, quest->RewChoiceItemId[reward]); + SendEquipError(res, NULL, NULL, quest->RewardChoiceItemId[reward]); return false; } } @@ -14711,13 +14711,13 @@ bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg) { for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i) { - if (quest->RewItemId[i]) + if (quest->RewardItemId[i]) { ItemPosCountVec dest; - InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewItemId[i], quest->RewItemCount[i]); + InventoryResult res = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, quest->RewardItemId[i], quest->RewardItemIdCount[i]); if (res != EQUIP_ERR_OK) { - SendEquipError(res, NULL, NULL, quest->RewItemId[i]); + SendEquipError(res, NULL, NULL, quest->RewardItemId[i]); return false; } } @@ -14850,15 +14850,15 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, uint32 quest_id = quest->GetQuestId(); for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) - if (quest->ReqItemId[i]) - DestroyItemCount(quest->ReqItemId[i], quest->ReqItemCount[i], true); + if (quest->RequiredItemId[i]) + DestroyItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i], true); for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) { - if (quest->ReqSourceId[i]) + if (quest->RequiredSourceItemid[i]) { - uint32 count = quest->ReqSourceCount[i]; - DestroyItemCount(quest->ReqSourceId[i], count ? count : 9999, true); + uint32 count = quest->RequiredSourceItemId[i]; + DestroyItemCount(quest->RequiredSourceItemid[i], count ? count : 9999, true); } } @@ -14866,13 +14866,13 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, if (quest->GetRewChoiceItemsCount() > 0) { - if (uint32 itemId = quest->RewChoiceItemId[reward]) + if (uint32 itemId = quest->RewardChoiceItemId[reward]) { ItemPosCountVec dest; - if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, quest->RewChoiceItemCount[reward]) == EQUIP_ERR_OK) + if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, quest->RewardChoiceItemCount[reward]) == EQUIP_ERR_OK) { Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); - SendNewItem(item, quest->RewChoiceItemCount[reward], true, false); + SendNewItem(item, quest->RewardChoiceItemCount[reward], true, false); } } } @@ -14881,13 +14881,13 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, { for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i) { - if (uint32 itemId = quest->RewItemId[i]) + if (uint32 itemId = quest->RewardItemId[i]) { ItemPosCountVec dest; - if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, quest->RewItemCount[i]) == EQUIP_ERR_OK) + if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, quest->RewardItemIdCount[i]) == EQUIP_ERR_OK) { Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); - SendNewItem(item, quest->RewItemCount[i], true, false); + SendNewItem(item, quest->RewardItemIdCount[i], true, false); } } } @@ -15051,57 +15051,31 @@ void Player::FailQuest(uint32 questId) // Destroy quest items on quest failure. for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - if (quest->ReqItemId[i] > 0 && quest->ReqItemCount[i] > 0) + if (quest->RequiredItemId[i] > 0 && quest->RequiredItemCount[i] > 0) // Destroy items recieved on starting the quest. - DestroyItemCount(quest->ReqItemId[i], quest->ReqItemCount[i], true, true); + DestroyItemCount(quest->RequiredItemId[i], quest->RequiredItemCount[i], true, true); for (uint8 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - if (quest->ReqSourceId[i] > 0 && quest->ReqSourceCount[i] > 0) + if (quest->RequiredSourceItemid[i] > 0 && quest->RequiredSourceItemId[i] > 0) // Destroy items recieved during the quest. - DestroyItemCount(quest->ReqSourceId[i], quest->ReqSourceCount[i], true, true); + DestroyItemCount(quest->RequiredSourceItemid[i], quest->RequiredSourceItemId[i], true, true); } } -bool Player::SatisfyQuestSkillOrClass(Quest const* qInfo, bool msg) +bool Player::SatisfyQuestSkill(Quest const* qInfo, bool msg) const { - int32 zoneOrSort = qInfo->GetZoneOrSort(); - int32 skillOrClassMask = qInfo->GetSkillOrClassMask(); + uint32 skill = qInfo->GetRequiredSkill(); - // skip zone zoneOrSort and 0 case skillOrClass - if (zoneOrSort >= 0 && skillOrClassMask == 0) + // skip 0 case RequiredSkill + if (skill == 0) return true; - int32 questSort = -zoneOrSort; - uint8 reqSortClass = ClassByQuestSort(questSort); - - // check class sort cases in zoneOrSort - if (reqSortClass != 0 && getClass() != reqSortClass) + // check skill value + if (GetSkillValue(skill) < qInfo->GetRequiredSkillValue()) { if (msg) SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); - return false; - } - // check class - if (skillOrClassMask < 0) - { - uint32 reqClassMask = -int32(skillOrClassMask); - if (!(reqClassMask & getClassMask())) - { - if (msg) - SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); - return false; - } - } - // check skill - else if (skillOrClassMask > 0) - { - uint32 reqSkill = skillOrClassMask; - if (GetSkillValue(reqSkill) < qInfo->GetRequiredSkillValue()) - { - if (msg) - SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); - return false; - } + return false; } return true; @@ -15229,6 +15203,24 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) return false; } +bool Player::SatisfyQuestClass(Quest const* qInfo, bool msg) const +{ + uint32 reqClass = qInfo->GetRequiredClasses(); + + if (reqClass == 0) + return true; + + if ((reqClass & getClassMask()) == 0) + { + if (msg) + SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); + + return false; + } + + return true; +} + bool Player::SatisfyQuestRace(Quest const* qInfo, bool msg) { uint32 reqraces = qInfo->GetRequiredRaces(); @@ -15486,7 +15478,7 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg) // exist two cases when destroy source quest item not possible: // a) non un-equippable item (equipped non-empty bag, for example) // b) when quest is started from an item and item also is needed in - // the end as ReqItemId + // the end as RequiredItemId InventoryResult res = CanUnequipItems(srcItemId, count); if (res != EQUIP_ERR_OK) { @@ -15496,7 +15488,7 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg) } for (uint8 n = 0; n < QUEST_ITEM_OBJECTIVES_COUNT; ++n) - if (item->StartQuest == questId && srcItemId == quest->ReqItemId[n]) + if (item->StartQuest == questId && srcItemId == quest->RequiredItemId[n]) destroyItem = false; if (destroyItem) @@ -15588,7 +15580,7 @@ uint16 Player::GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) return 0; for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) - if (qInfo->ReqCreatureOrGOId[j] == entry) + if (qInfo->RequiredNpcOrGo[j] == entry) return m_QuestStatus[quest_id].m_creatureOrGOcount[j]; return 0; @@ -15600,10 +15592,10 @@ void Player::AdjustQuestReqItemCount(Quest const* quest, QuestStatusData& questS { for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { - uint32 reqitemcount = quest->ReqItemCount[i]; + uint32 reqitemcount = quest->RequiredItemCount[i]; if (reqitemcount != 0) { - uint32 curitemcount = GetItemCount(quest->ReqItemId[i], true); + uint32 curitemcount = GetItemCount(quest->RequiredItemId[i], true); questStatusData.m_itemcount[i] = std::min(curitemcount, reqitemcount); m_QuestStatusSave[quest->GetQuestId()] = true; @@ -15678,10 +15670,10 @@ void Player::ItemAddedQuestCheck(uint32 entry, uint32 count) for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { - uint32 reqitem = qInfo->ReqItemId[j]; + uint32 reqitem = qInfo->RequiredItemId[j]; if (reqitem == entry) { - uint32 reqitemcount = qInfo->ReqItemCount[j]; + uint32 reqitemcount = qInfo->RequiredItemCount[j]; uint16 curitemcount = q_status.m_itemcount[j]; if (curitemcount < reqitemcount) { @@ -15716,12 +15708,12 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count) for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { - uint32 reqitem = qInfo->ReqItemId[j]; + uint32 reqitem = qInfo->RequiredItemId[j]; if (reqitem == entry) { QuestStatusData& q_status = m_QuestStatus[questid]; - uint32 reqitemcount = qInfo->ReqItemCount[j]; + uint32 reqitemcount = qInfo->RequiredItemCount[j]; uint16 curitemcount; if (q_status.m_status != QUEST_STATUS_COMPLETE) curitemcount = q_status.m_itemcount[j]; @@ -15785,18 +15777,18 @@ void Player::KilledMonsterCredit(uint32 entry, uint64 guid) for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { // skip GO activate objective or none - if (qInfo->ReqCreatureOrGOId[j] <= 0) + if (qInfo->RequiredNpcOrGo[j] <= 0) continue; // skip Cast at creature objective - if (qInfo->ReqSpell[j] != 0) + if (qInfo->RequiredSpellCast[j] != 0) continue; - uint32 reqkill = qInfo->ReqCreatureOrGOId[j]; + uint32 reqkill = qInfo->RequiredNpcOrGo[j]; if (reqkill == real_entry) { - uint32 reqkillcount = qInfo->ReqCreatureOrGOCount[j]; + uint32 reqkillcount = qInfo->RequiredNpcOrGoCount[j]; uint16 curkillcount = q_status.m_creatureOrGOcount[j]; if (curkillcount < reqkillcount) { @@ -15882,7 +15874,7 @@ void Player::CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id) for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { // skip kill creature objective (0) or wrong spell casts - if (qInfo->ReqSpell[j] != spell_id) + if (qInfo->RequiredSpellCast[j] != spell_id) continue; uint32 reqTarget = 0; @@ -15890,32 +15882,32 @@ void Player::CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id) if (isCreature) { // creature activate objectives - if (qInfo->ReqCreatureOrGOId[j] > 0) + if (qInfo->RequiredNpcOrGo[j] > 0) { // checked at quest_template loading - reqTarget = qInfo->ReqCreatureOrGOId[j]; + reqTarget = qInfo->RequiredNpcOrGo[j]; if (reqTarget != entry) // if entry doesn't match, check for killcredits referenced in template { CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry); - for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i) - if (cinfo->KillCredit[i] == reqTarget) - entry = cinfo->KillCredit[i]; + for (uint8 j = 0; j < MAX_KILL_CREDIT; ++j) + if (cinfo->KillCredit[j] == reqTarget) + entry = cinfo->KillCredit[j]; } } } else { // GO activate objective - if (qInfo->ReqCreatureOrGOId[j] < 0) + if (qInfo->RequiredNpcOrGo[j] < 0) // checked at quest_template loading - reqTarget = - qInfo->ReqCreatureOrGOId[j]; + reqTarget = - qInfo->RequiredNpcOrGo[j]; } // other not this creature/GO related objectives if (reqTarget != entry) continue; - uint32 reqCastCount = qInfo->ReqCreatureOrGOCount[j]; + uint32 reqCastCount = qInfo->RequiredNpcOrGoCount[j]; uint16 curCastCount = q_status.m_creatureOrGOcount[j]; if (curCastCount < reqCastCount) { @@ -15959,20 +15951,20 @@ void Player::TalkedToCreature(uint32 entry, uint64 guid) for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { // skip spell casts and Gameobject objectives - if (qInfo->ReqSpell[j] > 0 || qInfo->ReqCreatureOrGOId[j] < 0) + if (qInfo->RequiredSpellCast[j] > 0 || qInfo->RequiredNpcOrGo[j] < 0) continue; uint32 reqTarget = 0; - if (qInfo->ReqCreatureOrGOId[j] > 0) // creature activate objectives + if (qInfo->RequiredNpcOrGo[j] > 0) // creature activate objectives // checked at quest_template loading - reqTarget = qInfo->ReqCreatureOrGOId[j]; + reqTarget = qInfo->RequiredNpcOrGo[j]; else continue; if (reqTarget == entry) { - uint32 reqTalkCount = qInfo->ReqCreatureOrGOCount[j]; + uint32 reqTalkCount = qInfo->RequiredNpcOrGoCount[j]; uint16 curTalkCount = q_status.m_creatureOrGOcount[j]; if (curTalkCount < reqTalkCount) { @@ -16109,14 +16101,14 @@ bool Player::HasQuestForItem(uint32 itemid) const // This part for ReqItem drop for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { - if (itemid == qinfo->ReqItemId[j] && q_status.m_itemcount[j] < qinfo->ReqItemCount[j]) + if (itemid == qinfo->RequiredItemId[j] && q_status.m_itemcount[j] < qinfo->RequiredItemCount[j]) return true; } // This part - for ReqSource for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j) { // examined item is a source item - if (qinfo->ReqSourceId[j] == itemid) + if (qinfo->RequiredSourceItemid[j] == itemid) { ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(itemid); @@ -16125,9 +16117,9 @@ bool Player::HasQuestForItem(uint32 itemid) const return true; // allows custom amount drop when not 0 - if (qinfo->ReqSourceCount[j]) + if (qinfo->RequiredSourceItemId[j]) { - if (GetItemCount(itemid, true) < qinfo->ReqSourceCount[j]) + if (GetItemCount(itemid, true) < qinfo->RequiredSourceItemId[j]) return true; } else if (GetItemCount(itemid, true) < pProto->GetMaxStackSize()) return true; @@ -16200,7 +16192,7 @@ void Player::SendQuestTimerFailed(uint32 quest_id) } } -void Player::SendCanTakeQuestResponse(uint32 msg) +void Player::SendCanTakeQuestResponse(uint32 msg) const { WorldPacket data(SMSG_QUESTGIVER_QUEST_INVALID, 4); data << uint32(msg); @@ -16245,7 +16237,7 @@ void Player::SendQuestUpdateAddItem(Quest const* /*quest*/, uint32 /*item_idx*/, { WorldPacket data(SMSG_QUESTUPDATE_ADD_ITEM, 0); sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTUPDATE_ADD_ITEM"); - //data << quest->ReqItemId[item_idx]; + //data << quest->RequiredItemId[item_idx]; //data << count; GetSession()->SendPacket(&data); } @@ -16254,7 +16246,7 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uin { ASSERT(old_count + add_count < 65536 && "mob/GO count store in 16 bits 2^16 = 65536 (0..65536)"); - int32 entry = quest->ReqCreatureOrGOId[ creatureOrGO_idx ]; + int32 entry = quest->RequiredNpcOrGo[ creatureOrGO_idx ]; if (entry < 0) // client expected gameobject template id in form (id|0x80000000) entry = (-entry) | 0x80000000; @@ -16264,7 +16256,7 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uin data << uint32(quest->GetQuestId()); data << uint32(entry); data << uint32(old_count + add_count); - data << uint32(quest->ReqCreatureOrGOCount[ creatureOrGO_idx ]); + data << uint32(quest->RequiredNpcOrGoCount[ creatureOrGO_idx ]); data << uint64(guid); GetSession()->SendPacket(&data); @@ -16790,7 +16782,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) // NOW player must have valid map // load the player's map here if it's not already loaded - Map* map = sMapMgr->CreateMap(mapId, this, instanceId); + Map* map = sMapMgr->CreateMap(mapId, this); if (!map) { @@ -16808,14 +16800,14 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) RelocateToHomebind(); } - map = sMapMgr->CreateMap(mapId, this, 0); + map = sMapMgr->CreateMap(mapId, this); if (!map) { PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); mapId = info->mapId; Relocate(info->positionX, info->positionY, info->positionZ, 0.0f); sLog->outError("Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", guid, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); - map = sMapMgr->CreateMap(mapId, this, 0); + map = sMapMgr->CreateMap(mapId, this); if (!map) { sLog->outError("Player (guidlow %d) has invalid default map coordinates (X: %f Y: %f Z: %f O: %f). or instance couldn't be created", guid, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); @@ -17536,7 +17528,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); 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); CharacterDatabase.Execute(stmt); continue; @@ -18263,7 +18255,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) /*** SAVE SYSTEM ***/ /*********************************************************/ -void Player::SaveToDB() +void Player::SaveToDB(bool create /*=false*/) { // delay auto save at any saves (manual, in code, or autosave) m_nextSave = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE); @@ -18281,156 +18273,228 @@ void Player::SaveToDB() sLog->outDebug(LOG_FILTER_UNITS, "The value of player %s at save: ", m_name.c_str()); outDebugValues(); - std::string sql_name = m_name; - CharacterDatabase.EscapeString(sql_name); + PreparedStatement* stmt = NULL; + uint16 index = 0; - std::ostringstream ss; - ss << "REPLACE INTO characters (guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, " - "map, instance_id, instance_mode_mask, position_x, position_y, position_z, orientation, " - "taximask, online, cinematic, " - "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, " - "trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, " - "death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, " - "todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, " - "power4, power5, power6, power7, latency, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, grantableLevels) VALUES (" - << GetGUIDLow() << ',' - << GetSession()->GetAccountId() << ", '" - << sql_name << "', " - << uint32(getRace()) << ',' - << uint32(getClass()) << ',' - << uint32(getGender()) << ',' - << uint32(getLevel()) << ',' - << GetUInt32Value(PLAYER_XP) << ',' - << GetMoney() << ',' - << GetUInt32Value(PLAYER_BYTES) << ',' - << GetUInt32Value(PLAYER_BYTES_2) << ',' - << GetUInt32Value(PLAYER_FLAGS) << ','; - - if (!IsBeingTeleported()) - { - ss << GetMapId() << ',' - << (uint32)GetInstanceId() << ',' - << uint32(uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4) << ',' - << finiteAlways(GetPositionX()) << ',' - << finiteAlways(GetPositionY()) << ',' - << finiteAlways(GetPositionZ()) << ',' - << finiteAlways(GetOrientation()) << ','; - } - else + if (create) { - ss << GetTeleportDest().GetMapId() << ',' - << (uint32)0 << ',' - << uint32(uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4) << ',' - << finiteAlways(GetTeleportDest().GetPositionX()) << ',' - << finiteAlways(GetTeleportDest().GetPositionY()) << ',' - << finiteAlways(GetTeleportDest().GetPositionZ()) << ',' - << finiteAlways(GetTeleportDest().GetOrientation()) << ','; - } - - ss << m_taxi << ','; // string with TaxiMaskSize numbers - - ss << (IsInWorld() ? 1 : 0) << ','; - - ss << uint32(m_cinematic) << ','; + //! Insert query + //! TO DO: Filter out more redundant fields that can take their default value at player create + stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHARACTER); + stmt->setUInt32(index++, GetGUIDLow()); + stmt->setUInt32(index++, GetSession()->GetAccountId()); + stmt->setString(index++, GetName()); + stmt->setUInt8(index++, getRace()); + stmt->setUInt8(index++, getClass()); + stmt->setUInt8(index++, getGender()); + stmt->setUInt8(index++, getLevel()); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP)); + stmt->setUInt32(index++, GetMoney()); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_BYTES)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_BYTES_2)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS)); + stmt->setUInt16(index++, (uint16)GetMapId()); + stmt->setUInt32(index++, (uint32)GetInstanceId()); + stmt->setUInt8(index++, (uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4)); + stmt->setFloat(index++, finiteAlways(GetPositionX())); + stmt->setFloat(index++, finiteAlways(GetPositionY())); + stmt->setFloat(index++, finiteAlways(GetPositionZ())); + stmt->setFloat(index++, finiteAlways(GetOrientation())); + + std::ostringstream ss; + ss << m_taxi; + stmt->setString(index++, ss.str()); + stmt->setUInt8(index++, m_cinematic); + stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]); + stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]); + stmt->setFloat(index++, finiteAlways(m_rest_bonus)); + stmt->setUInt32(index++, uint32(time(NULL))); + stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0)); + //save, far from tavern/city + //save, but in tavern/city + stmt->setUInt32(index++, m_resetTalentsCost); + stmt->setUInt32(index++, m_resetTalentsTime); + stmt->setUInt16(index++, (uint16)m_ExtraFlags); + stmt->setUInt8(index++, m_stableSlots); + stmt->setUInt16(index++, (uint16)m_atLoginFlags); + stmt->setUInt16(index++, GetZoneId()); + stmt->setUInt32(index++, m_deathExpireTime); + + ss.str(""); + ss << m_taxi.SaveTaxiDestinationsToString(); + + stmt->setString(index++, ss.str()); + stmt->setUInt32(index++, GetArenaPoints()); + stmt->setUInt32(index++, GetHonorPoints()); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)); + stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 0)); + stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 1)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_CHOSEN_TITLE)); + stmt->setUInt64(index++, GetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX)); + stmt->setUInt16(index++, (uint16)(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE)); + stmt->setUInt32(index++, GetHealth()); + + for (uint32 i = 0; i < MAX_POWERS; ++i) + stmt->setUInt32(index++, GetPower(Powers(i))); + + stmt->setUInt32(index++, GetSession()->GetLatency()); + + stmt->setUInt8(index++, m_specsCount); + stmt->setUInt8(index++, m_activeSpec); + + ss.str(""); + for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i) + ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' '; + stmt->setString(index++, ss.str()); + + ss.str(""); + // cache equipment... + for (uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i) + ss << GetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + i) << ' '; + + // ...and bags for enum opcode + for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + { + if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + ss << item->GetEntry(); + else + ss << '0'; + ss << " 0 "; + } - ss << m_Played_time[PLAYED_TIME_TOTAL] << ','; - ss << m_Played_time[PLAYED_TIME_LEVEL] << ','; + stmt->setString(index++, ss.str()); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_AMMO_ID)); - ss << finiteAlways(m_rest_bonus) << ','; - ss << uint32(time(NULL)) << ','; - ss << (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0) << ','; - //save, far from tavern/city - //save, but in tavern/city - ss << m_resetTalentsCost << ','; - ss << uint32(m_resetTalentsTime) << ','; + ss.str(""); + for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i) + ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' '; - ss << finiteAlways(m_movementInfo.t_pos.GetPositionX()) << ','; - ss << finiteAlways(m_movementInfo.t_pos.GetPositionY()) << ','; - ss << finiteAlways(m_movementInfo.t_pos.GetPositionZ()) << ','; - ss << finiteAlways(m_movementInfo.t_pos.GetOrientation()) << ','; - if (m_transport) - ss << m_transport->GetGUIDLow(); + stmt->setString(index++, ss.str()); + stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, 2)); + stmt->setUInt32(index++, m_grantableLevels); + } else - ss << '0'; - ss << ','; - - ss << m_ExtraFlags << ','; - - ss << uint32(m_stableSlots) << ','; // to prevent save uint8 as char - - ss << uint32(m_atLoginFlags) << ','; - - ss << GetZoneId() << ','; - - ss << uint32(m_deathExpireTime) << ", '"; - - ss << m_taxi.SaveTaxiDestinationsToString() << "', "; - - ss << GetArenaPoints() << ','; - - ss << GetHonorPoints() << ','; - - ss << GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION) << ','; - - ss << GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION) << ','; - - ss << GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS) << ','; - - ss << GetUInt16Value(PLAYER_FIELD_KILLS, 0) << ','; - - ss << GetUInt16Value(PLAYER_FIELD_KILLS, 1) << ','; - - ss << GetUInt32Value(PLAYER_CHOSEN_TITLE) << ','; - - ss << GetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES) << ','; - - ss << GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX) << ','; - - ss << (uint16)(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE) << ','; - - ss << GetHealth(); - - for (uint32 i = 0; i < MAX_POWERS; ++i) - ss << ',' << GetPower(Powers(i)); - ss << ','; - ss << GetSession()->GetLatency(); - ss << ','; - ss << uint32(m_specsCount); - ss << ','; - ss << uint32(m_activeSpec) << ", '"; - for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i) - ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' '; - - // cache equipment... - ss << "', '"; - for (uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i) - ss << GetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + i) << ' '; - - // ...and bags for enum opcode - for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - ss << item->GetEntry(); + // Update query + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER); + stmt->setString(index++, GetName()); + stmt->setUInt8(index++, getRace()); + stmt->setUInt8(index++, getClass()); + stmt->setUInt8(index++, getGender()); + stmt->setUInt8(index++, getLevel()); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_XP)); + stmt->setUInt32(index++, GetMoney()); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_BYTES)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_BYTES_2)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FLAGS)); + + if (!IsBeingTeleported()) + { + stmt->setUInt16(index++, (uint16)GetMapId()); + stmt->setUInt32(index++, (uint32)GetInstanceId()); + stmt->setUInt8(index++, (uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4)); + stmt->setFloat(index++, finiteAlways(GetPositionX())); + stmt->setFloat(index++, finiteAlways(GetPositionY())); + stmt->setFloat(index++, finiteAlways(GetPositionZ())); + stmt->setFloat(index++, finiteAlways(GetOrientation())); + } else - ss << '0'; - ss << " 0 "; - } + { + stmt->setUInt16(index++, (uint16)GetTeleportDest().GetMapId()); + stmt->setUInt32(index++, (uint32)0); + stmt->setUInt8(index++, (uint8(GetDungeonDifficulty()) | uint8(GetRaidDifficulty()) << 4)); + stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetPositionX())); + stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetPositionY())); + stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetPositionZ())); + stmt->setFloat(index++, finiteAlways(GetTeleportDest().GetOrientation())); + } + + std::ostringstream ss; + ss << m_taxi; + stmt->setString(index++, ss.str()); + stmt->setUInt8(index++, m_cinematic); + stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]); + stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]); + stmt->setFloat(index++, finiteAlways(m_rest_bonus)); + stmt->setUInt32(index++, uint32(time(NULL))); + stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0)); + //save, far from tavern/city + //save, but in tavern/city + stmt->setUInt32(index++, m_resetTalentsCost); + stmt->setUInt32(index++, m_resetTalentsTime); + stmt->setUInt16(index++, (uint16)m_ExtraFlags); + stmt->setUInt8(index++, m_stableSlots); + stmt->setUInt16(index++, (uint16)m_atLoginFlags); + stmt->setUInt16(index++, GetZoneId()); + stmt->setUInt32(index++, m_deathExpireTime); + + ss.str(""); + ss << m_taxi.SaveTaxiDestinationsToString(); + + stmt->setString(index++, ss.str()); + stmt->setUInt32(index++, GetArenaPoints()); + stmt->setUInt32(index++, GetHonorPoints()); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)); + stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 0)); + stmt->setUInt16(index++, GetUInt16Value(PLAYER_FIELD_KILLS, 1)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_CHOSEN_TITLE)); + stmt->setUInt64(index++, GetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES)); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX)); + stmt->setUInt16(index++, (uint16)(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE)); + stmt->setUInt32(index++, GetHealth()); + + for (uint32 i = 0; i < MAX_POWERS; ++i) + stmt->setUInt32(index++, GetPower(Powers(i))); + + stmt->setUInt32(index++, GetSession()->GetLatency()); + + stmt->setUInt8(index++, m_specsCount); + stmt->setUInt8(index++, m_activeSpec); + + ss.str(""); + for (uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i) + ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << ' '; + stmt->setString(index++, ss.str()); + + ss.str(""); + // cache equipment... + for (uint32 i = 0; i < EQUIPMENT_SLOT_END * 2; ++i) + ss << GetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + i) << ' '; + + // ...and bags for enum opcode + for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + { + if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + ss << item->GetEntry(); + else + ss << '0'; + ss << " 0 "; + } - ss << "',"; + stmt->setString(index++, ss.str()); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_AMMO_ID)); - ss << GetUInt32Value(PLAYER_AMMO_ID) << ", '"; - for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i) - ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' '; + ss.str(""); + for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i) + ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' '; - ss << "',"; - ss << uint32(GetByteValue(PLAYER_FIELD_BYTES, 2)); - ss << ","; - ss << uint32(m_grantableLevels); - ss << ')'; + stmt->setString(index++, ss.str()); + stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, 2)); + stmt->setUInt32(index++, m_grantableLevels); + + stmt->setUInt8(index++, IsInWorld() ? 1 : 0); + // Index + stmt->setUInt32(index++, GetGUIDLow()); + } SQLTransaction trans = CharacterDatabase.BeginTransaction(); - trans->Append(ss.str().c_str()); + trans->Append(stmt); if (m_mailsUpdated) //save mails only when needed _SaveMail(trans); @@ -20123,9 +20187,9 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc 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(); - TeleportTo(lastnode->map_id, lastnode->x, lastnode->y, lastnode->z, GetOrientation()); + TeleportTo(lastPathNode->map_id, lastPathNode->x, lastPathNode->y, lastPathNode->z, GetOrientation()); return false; } else @@ -22000,10 +22064,10 @@ bool Player::HasQuestForGO(int32 GOId) const for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { - if (qinfo->ReqCreatureOrGOId[j] >= 0) //skip non GO case + if (qinfo->RequiredNpcOrGo[j] >= 0) //skip non GO case continue; - if ((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]) + if ((-1)*GOId == qinfo->RequiredNpcOrGo[j] && qs.m_creatureOrGOcount[j] < qinfo->RequiredNpcOrGoCount[j]) return true; } } @@ -22850,7 +22914,6 @@ bool Player::CanCaptureTowerPoint() } uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin) - { uint8 level = getLevel(); @@ -24328,9 +24391,9 @@ void Player::ActivateSpec(uint8 spec) // Let client clear his current Actions SendActionButtons(2); // 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) continue; diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index bb39d902ae7..651b99e7cb4 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -395,10 +395,10 @@ enum PlayerFlags PLAYER_FLAGS_NO_XP_GAIN = 0x02000000, PLAYER_FLAGS_UNK26 = 0x04000000, PLAYER_FLAGS_UNK27 = 0x08000000, - PLAYER_FLAGS_UNK28 = 0x01000000, - PLAYER_FLAGS_UNK29 = 0x02000000, - PLAYER_FLAGS_UNK30 = 0x04000000, - PLAYER_FLAGS_UNK31 = 0x08000000, + PLAYER_FLAGS_UNK28 = 0x10000000, + PLAYER_FLAGS_UNK29 = 0x20000000, + PLAYER_FLAGS_UNK30 = 0x40000000, + PLAYER_FLAGS_UNK31 = 0x80000000, }; // used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1<<bit_index) without (-1) @@ -774,7 +774,7 @@ enum PlayerChatTag CHAT_TAG_AFK = 0x01, CHAT_TAG_DND = 0x02, CHAT_TAG_GM = 0x04, - CHAT_TAG_UNK = 0x08, // Probably battleground commentator + CHAT_TAG_COM = 0x08, // Commentator CHAT_TAG_DEV = 0x10, }; @@ -1410,10 +1410,11 @@ class Player : public Unit, public GridObject<Player> void IncompleteQuest(uint32 quest_id); void RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, bool announce = true); void FailQuest(uint32 quest_id); - bool SatisfyQuestSkillOrClass(Quest const* qInfo, bool msg); + bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const; bool SatisfyQuestLevel(Quest const* qInfo, bool msg); bool SatisfyQuestLog(bool msg); bool SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg); + bool SatisfyQuestClass(Quest const* qInfo, bool msg) const; bool SatisfyQuestRace(Quest const* qInfo, bool msg); bool SatisfyQuestReputation(Quest const* qInfo, bool msg); bool SatisfyQuestStatus(Quest const* qInfo, bool msg); @@ -1493,7 +1494,7 @@ class Player : public Unit, public GridObject<Player> void SendQuestReward(Quest const* quest, uint32 XP, Object* questGiver); void SendQuestFailed(uint32 questId, InventoryResult reason = EQUIP_ERR_OK); void SendQuestTimerFailed(uint32 quest_id); - void SendCanTakeQuestResponse(uint32 msg); + void SendCanTakeQuestResponse(uint32 msg) const; void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver); void SendPushToPartyResponse(Player* player, uint32 msg); void SendQuestUpdateAddItem(Quest const* quest, uint32 item_idx, uint16 count); @@ -1530,7 +1531,7 @@ class Player : public Unit, public GridObject<Player> /*** SAVE SYSTEM ***/ /*********************************************************/ - void SaveToDB(); + void SaveToDB(bool create = false); void SaveInventoryAndGoldToDB(SQLTransaction& trans); // fast save function for item/money cheating preventing void SaveGoldToDB(SQLTransaction& trans); @@ -2300,6 +2301,7 @@ class Player : public Unit, public GridObject<Player> m_mover = target; m_mover->m_movedPlayer = this; } + void SetSeer(WorldObject* target) { m_seer = target; } void SetViewpoint(WorldObject* target, bool apply); WorldObject* GetViewpoint() const; @@ -2493,6 +2495,41 @@ class Player : public Unit, public GridObject<Player> void AddWhisperWhiteList(uint64 guid) { WhisperList.push_back(guid); } bool IsInWhisperWhiteList(uint64 guid); + //! Return collision height sent to client + float GetCollisionHeight(bool mounted) + { + if (mounted) + { + CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID)); + if (!mountDisplayInfo) + return GetCollisionHeight(false); + + CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelId); + if (!mountModelData) + return GetCollisionHeight(false); + + CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()); + ASSERT(displayInfo); + CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId); + ASSERT(modelData); + + float scaleMod = GetFloatValue(OBJECT_FIELD_SCALE_X); // 99% sure about this + + return scaleMod * mountModelData->MountHeight + modelData->CollisionHeight * 0.5f; + } + else + { + //! Dismounting case - use basic default model data + CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()); + ASSERT(displayInfo); + CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId); + ASSERT(modelData); + + return modelData->CollisionHeight; + } + //! TODO: Need a proper calculation for collision height when mounted + } + protected: // Gamemaster whisper whitelist WhisperListContainer WhisperList; diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index e9798b61a60..dbb18496515 100755 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -130,7 +130,7 @@ void PlayerSocial::SendSocialList(Player* player) sSocialMgr->GetFriendInfo(player, itr->first, itr->second); data << uint64(itr->first); // player guid - data << uint32(itr->second.Flags); // player flag (0x1-friend?, 0x2-ignored?, 0x4-muted?) + data << uint32(itr->second.Flags); // player flag (0x1 = Friend, 0x2 = Ignored, 0x4 = Muted) data << itr->second.Note; // string note if (itr->second.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend() { diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 28895cff35e..b92e1ad21dc 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -98,7 +98,7 @@ void MapManager::LoadTransports() m_TransportsByMap[*i].insert(t); //If we someday decide to use the grid to track transports, here: - t->SetMap(sMapMgr->CreateMap(mapid, t, 0)); + t->SetMap(sMapMgr->CreateBaseMap(mapid)); t->AddToWorld(); ++count; @@ -365,9 +365,9 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids) if (keyFrames[keyFrames.size() - 1].node->mapid != keyFrames[0].node->mapid) teleport = true; - WayPoint pos(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport, 0, + m_WayPoints[0] = WayPoint(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport, 0, keyFrames[0].node->arrivalEventID, keyFrames[0].node->departureEventID); - m_WayPoints[0] = pos; + t += keyFrames[0].node->delay * 1000; uint32 cM = keyFrames[0].node->mapid; @@ -387,12 +387,11 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids) if (d > 0) { - float newX, newY, newZ; - newX = keyFrames[i].node->x + (keyFrames[i + 1].node->x - keyFrames[i].node->x) * d / keyFrames[i + 1].distFromPrev; - newY = keyFrames[i].node->y + (keyFrames[i + 1].node->y - keyFrames[i].node->y) * d / keyFrames[i + 1].distFromPrev; - newZ = keyFrames[i].node->z + (keyFrames[i + 1].node->z - keyFrames[i].node->z) * d / keyFrames[i + 1].distFromPrev; + float newX = keyFrames[i].node->x + (keyFrames[i + 1].node->x - keyFrames[i].node->x) * d / keyFrames[i + 1].distFromPrev; + float newY = keyFrames[i].node->y + (keyFrames[i + 1].node->y - keyFrames[i].node->y) * d / keyFrames[i + 1].distFromPrev; + float newZ = keyFrames[i].node->z + (keyFrames[i + 1].node->z - keyFrames[i].node->z) * d / keyFrames[i + 1].distFromPrev; - bool teleport = false; + teleport = false; if (keyFrames[i].node->mapid != cM) { teleport = true; @@ -400,9 +399,8 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids) } // sLog->outString("T: %d, D: %f, x: %f, y: %f, z: %f", t, d, newX, newY, newZ); - WayPoint pos(keyFrames[i].node->mapid, newX, newY, newZ, teleport, 0); if (teleport) - m_WayPoints[t] = pos; + m_WayPoints[t] = WayPoint(keyFrames[i].node->mapid, newX, newY, newZ, teleport, 0); } if (tFrom < tTo) // caught in tFrom dock's "gravitational pull" @@ -439,25 +437,18 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids) else t += (long)keyFrames[i + 1].tTo % 100; - bool teleport = false; + teleport = false; if ((keyFrames[i + 1].node->actionFlag == 1) || (keyFrames[i + 1].node->mapid != keyFrames[i].node->mapid)) { teleport = true; cM = keyFrames[i + 1].node->mapid; } - WayPoint pos(keyFrames[i + 1].node->mapid, keyFrames[i + 1].node->x, keyFrames[i + 1].node->y, keyFrames[i + 1].node->z, teleport, + m_WayPoints[t] = WayPoint(keyFrames[i + 1].node->mapid, keyFrames[i + 1].node->x, keyFrames[i + 1].node->y, keyFrames[i + 1].node->z, teleport, 0, keyFrames[i + 1].node->arrivalEventID, keyFrames[i + 1].node->departureEventID); // sLog->outString("T: %d, x: %f, y: %f, z: %f, t:%d", t, pos.x, pos.y, pos.z, teleport); -/* - if (keyFrames[i+1].delay > 5) - pos.delayed = true; -*/ - //if (teleport) - m_WayPoints[t] = pos; t += keyFrames[i + 1].node->delay * 1000; - // sLog->outString("------"); } uint32 timer = t; @@ -503,7 +494,7 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) RemoveFromWorld(); ResetMap(); - Map* newMap = sMapMgr->CreateMap(newMapid, this, 0); + Map* newMap = sMapMgr->CreateBaseMap(newMapid); SetMap(newMap); ASSERT (GetMap()); AddToWorld(); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 109479c3fe6..2e2f5591a5d 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1512,44 +1512,36 @@ uint32 Unit::CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo armor = floor(AddPctN(armor, -(*j)->GetAmount())); } + // Apply Player CR_ARMOR_PENETRATION rating and buffs from stances\specializations etc. if (GetTypeId() == TYPEID_PLAYER) { + float bonusPct = 0; AuraEffectList const& ResIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT); for (AuraEffectList::const_iterator itr = ResIgnoreAuras.begin(); itr != ResIgnoreAuras.end(); ++itr) { - // item neutral spell if ((*itr)->GetSpellInfo()->EquippedItemClass == -1) { - armor = floor(AddPctN(armor, -(*itr)->GetAmount())); - continue; + if (!spellInfo || (*itr)->IsAffectedOnSpell(spellInfo) || (*itr)->GetMiscValue() & spellInfo->GetSchoolMask()) + bonusPct += (*itr)->GetAmount(); + else if (!(*itr)->GetMiscValue() && !(*itr)->HasSpellClassMask()) + bonusPct += (*itr)->GetAmount(); } - - // item dependent spell - check current weapons - for (int i = 0; i < MAX_ATTACK; ++i) + else { - Item* weapon = ToPlayer()->GetWeaponForAttack(WeaponAttackType(i), true); - - if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellInfo())) - { - armor = floor(AddPctN(armor, -(*itr)->GetAmount())); - break; - } + if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*itr)->GetSpellInfo())) + bonusPct += (*itr)->GetAmount(); } } - } - // Apply Player CR_ARMOR_PENETRATION rating - if (GetTypeId() == TYPEID_PLAYER) - { float maxArmorPen = 0; - if (getLevel() < 60) + if (victim->getLevel() < 60) maxArmorPen = float(400 + 85 * victim->getLevel()); else maxArmorPen = 400 + 85 * victim->getLevel() + 4.5f * 85 * (victim->getLevel() - 59); // Cap armor penetration to this number maxArmorPen = std::min((armor + maxArmorPen) / 3, armor); // Figure out how much armor do we ignore - float armorPen = CalculatePctF(maxArmorPen, ToPlayer()->GetRatingBonusValue(CR_ARMOR_PENETRATION)); + float armorPen = CalculatePctF(maxArmorPen, bonusPct + ToPlayer()->GetRatingBonusValue(CR_ARMOR_PENETRATION)); // Got the value, apply it armor -= std::min(armorPen, maxArmorPen); } @@ -1584,7 +1576,7 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe // Magic damage, check for resists if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0) { - float victimResistance = float(victim->GetResistance(GetFirstSchoolInMask(schoolMask))); + float victimResistance = float(victim->GetResistance(schoolMask)); victimResistance += float(GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask)); if (Player* player = ToPlayer()) @@ -1687,12 +1679,12 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe if (currentAbsorb < 0) currentAbsorb = 0; - uint32 absorb = currentAbsorb; + uint32 tempAbsorb = uint32(currentAbsorb); bool defaultPrevented = false; - absorbAurEff->GetBase()->CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, absorb, defaultPrevented); - currentAbsorb = absorb; + absorbAurEff->GetBase()->CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented); + currentAbsorb = tempAbsorb; if (defaultPrevented) continue; @@ -1705,8 +1697,8 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe dmgInfo.AbsorbDamage(currentAbsorb); - absorb = currentAbsorb; - absorbAurEff->GetBase()->CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, absorb); + tempAbsorb = currentAbsorb; + absorbAurEff->GetBase()->CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb); // Check if our aura is using amount to count damage if (absorbAurEff->GetAmount() >= 0) @@ -1738,12 +1730,12 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe if (currentAbsorb < 0) currentAbsorb = 0; - uint32 absorb = currentAbsorb; + uint32 tempAbsorb = currentAbsorb; bool defaultPrevented = false; - absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, absorb, defaultPrevented); - currentAbsorb = absorb; + absorbAurEff->GetBase()->CallScriptEffectManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb, defaultPrevented); + currentAbsorb = tempAbsorb; if (defaultPrevented) continue; @@ -1766,8 +1758,8 @@ void Unit::CalcAbsorbResist(Unit* victim, SpellSchoolMask schoolMask, DamageEffe dmgInfo.AbsorbDamage(currentAbsorb); - absorb = currentAbsorb; - absorbAurEff->GetBase()->CallScriptEffectAfterManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, absorb); + tempAbsorb = currentAbsorb; + absorbAurEff->GetBase()->CallScriptEffectAfterManaShieldHandlers(absorbAurEff, aurApp, dmgInfo, tempAbsorb); // Check if our aura is using amount to count damage if (absorbAurEff->GetAmount() >= 0) @@ -2220,22 +2212,23 @@ void Unit::SendMeleeAttackStart(Unit* victim) WorldPacket data(SMSG_ATTACKSTART, 8 + 8); data << uint64(GetGUID()); data << uint64(victim->GetGUID()); - SendMessageToSet(&data, true); sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTART"); } void Unit::SendMeleeAttackStop(Unit* victim) { - if (!victim) - return; - WorldPacket data(SMSG_ATTACKSTOP, (8+8+4)); // we guess size data.append(GetPackGUID()); - data.append(victim->GetPackGUID()); // can be 0x00... - data << uint32(0); // can be 0x1 + data.append(victim ? victim->GetPackGUID() : 0); // can be 0x00... + data << uint32(0); // can be 0x1 SendMessageToSet(&data, true); - sLog->outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow()); + sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTART"); + + if (victim) + sLog->outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow()); + else + sLog->outDetail("%s %u stopped attacking", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow()); } bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttackType attackType) @@ -3743,13 +3736,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 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) - newAura->ModCharges(1); + oldAura->ModCharges(1); else - newAura->ModStackAmount(1); - newAura->SetDuration(int32(dur)); + oldAura->ModStackAmount(1); + oldAura->SetDuration(int32(dur)); } else { @@ -5241,6 +5234,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere break; case CLASS_ROGUE: // 39511, 40997, 40998, 41002, 41005, 41011 case CLASS_WARRIOR: // 39511, 40997, 40998, 41002, 41005, 41011 + case CLASS_DEATH_KNIGHT: triggered_spell_id = RAND(39511, 40997, 40998, 41002, 41005, 41011); cooldown_spell_id = 39511; break; @@ -6289,7 +6283,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere { if (procSpell->SpellVisual[0] == 750 && procSpell->Effects[1].ApplyAuraName == 3) { - if (target->GetTypeId() == TYPEID_UNIT) + if (target && target->GetTypeId() == TYPEID_UNIT) { triggered_spell_id = 54820; break; @@ -7249,7 +7243,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Item - Shaman T10 Elemental 4P Bonus case 70817: { - if(!target) + if (!target) return false; // try to find spell Flame Shock on the target if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, 0x10000000, 0x0, 0x0, GetGUID())) @@ -8000,11 +7994,8 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp else if (dummySpell->SpellIconID == 3015) { *handled = true; - if (procSpell->Category == SPELLCATEGORY_JUDGEMENT) - { - CastSpell(victim, 68055, true); - return true; - } + CastSpell(victim, 68055, true); + return true; } // Glyph of Divinity else if (dummySpell->Id == 54939) @@ -8409,6 +8400,13 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg basepoints0 += victim->GetRemainingPeriodicAmount(GetGUID(), trigger_spell_id, SPELL_AURA_PERIODIC_DAMAGE); break; } + // Item - Hunter T9 4P Bonus + if (auraSpellInfo->Id == 67151) + { + trigger_spell_id = 68130; + target = this; + break; + } break; } case SPELLFAMILY_PALADIN: @@ -10895,12 +10893,6 @@ bool Unit::isSpellCrit(Unit* victim, SpellInfo const* spellProto, SpellSchoolMas if (victim->HasAura(6788)) crit_chance+=(*i)->GetAmount(); break; - case 21: // Test of Faith - case 6935: - case 6918: - if (victim->HealthBelowPct(50)) - crit_chance+=(*i)->GetAmount(); - break; default: break; } @@ -11125,11 +11117,6 @@ uint32 Unit::SpellHealingBonus(Unit* victim, SpellInfo const* spellProto, uint32 case 3736: // Hateful Totem of the Third Wind / Increased Lesser Healing Wave / LK Arena (4/5/6) Totem of the Third Wind / Savage Totem of the Third Wind DoneTotal += (*i)->GetAmount(); break; - case 7997: // Renewed Hope - case 7998: - if (victim->HasAura(6788)) - AddPctN(DoneTotalMod, (*i)->GetAmount()); - break; case 21: // Test of Faith case 6935: case 6918: @@ -11754,23 +11741,6 @@ void Unit::MeleeDamageBonus(Unit* victim, uint32 *pdamage, WeaponAttackType attT AddPctF(TakenTotalMod, std::max(mod, float((*i)->GetAmount()))); } break; - // Blessing of Sanctuary - // Greater Blessing of Sanctuary - case 19: - case 1804: - { - if ((*i)->GetSpellInfo()->SpellFamilyName != SPELLFAMILY_PALADIN) - continue; - - if ((*i)->GetMiscValue() & (spellProto ? spellProto->GetSchoolMask() : 0)) - AddPctN(TakenTotalMod, (*i)->GetAmount()); - break; - } - // Ebon Plague - case 1933: - if ((*i)->GetMiscValue() & (spellProto ? spellProto->GetSchoolMask() : 0)) - AddPctN(TakenTotalMod, (*i)->GetAmount()); - break; } } @@ -11928,6 +11898,12 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) else player->UnsummonPetTemporaryIfAny(); } + + WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4); + data.append(GetPackGUID()); + data << uint32(sWorld->GetGameTime()); // Packet counter + data << player->GetCollisionHeight(true); + player->GetSession()->SendPacket(&data); } RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT); @@ -11941,6 +11917,15 @@ void Unit::Unmount() SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); + if (Player* thisPlayer = ToPlayer()) + { + WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4); + data.append(GetPackGUID()); + data << uint32(sWorld->GetGameTime()); // Packet counter + data << thisPlayer->GetCollisionHeight(false); + thisPlayer->GetSession()->SendPacket(&data); + } + WorldPacket data(SMSG_DISMOUNT, 8); data.appendPackGUID(GetGUID()); SendMessageToSet(&data, true); @@ -11949,7 +11934,7 @@ void Unit::Unmount() if (GetTypeId() == TYPEID_PLAYER && GetVehicleKit()) { // 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 << uint32(0); ToPlayer()->SendMessageToSet(&data, true); @@ -14331,7 +14316,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u } if (!handled) - for (uint8 effIndex = 0; effIndex<MAX_SPELL_EFFECTS; ++effIndex) + for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex) { if (!(i->effMask & (1<<effIndex))) continue; @@ -14357,8 +14342,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()); SpellNonMeleeDamage damageInfo(this, target, spellInfo->Id, spellInfo->SchoolMask); - uint32 damage = SpellDamageBonus(target, spellInfo, triggeredByAura->GetAmount(), SPELL_DIRECT_DAMAGE); - CalculateSpellDamageTaken(&damageInfo, damage, spellInfo); + uint32 newDamage = SpellDamageBonus(target, spellInfo, triggeredByAura->GetAmount(), SPELL_DIRECT_DAMAGE); + CalculateSpellDamageTaken(&damageInfo, newDamage, spellInfo); DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); SendSpellNonMeleeDamageLog(&damageInfo); DealSpellDamage(&damageInfo, true); @@ -15638,6 +15623,9 @@ void Unit::SetControlled(bool apply, UnitState state) case UNIT_STAT_CONFUSED: if (!HasUnitState(UNIT_STAT_STUNNED)) { + ClearUnitState(UNIT_STAT_MELEE_ATTACKING); + SendMeleeAttackStop(); + // SendAutoRepeatCancel ? SetConfused(true); CastStop(); } @@ -15645,6 +15633,9 @@ void Unit::SetControlled(bool apply, UnitState state) case UNIT_STAT_FLEEING: if (!HasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED)) { + ClearUnitState(UNIT_STAT_MELEE_ATTACKING); + SendMeleeAttackStop(); + // SendAutoRepeatCancel ? SetFeared(true); CastStop(); } @@ -16562,10 +16553,9 @@ float Unit::GetCombatRatingReduction(CombatRating cr) const if (Player const* player = ToPlayer()) return player->GetRatingBonusValue(cr); // Player's pet get resilience from owner - else if (isPet()) - if (Unit* owner = GetOwner()) - if (Player* player = owner->ToPlayer()) - return player->GetRatingBonusValue(cr); + else if (isPet() && GetOwner()) + if (Player* owner = GetOwner()->ToPlayer()) + return owner->GetRatingBonusValue(cr); return 0.0f; } @@ -17389,7 +17379,7 @@ uint32 Unit::GetRemainingPeriodicAmount(uint64 caster, uint32 spellId, AuraType AuraEffectList const& periodicAuras = GetAuraEffectsByType(auraType); for (AuraEffectList::const_iterator i = periodicAuras.begin(); i != periodicAuras.end(); ++i) { - if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || (*i)->GetTotalTicks() == 0) + if ((*i)->GetCasterGUID() != caster || (*i)->GetId() != spellId || (*i)->GetEffIndex() != effectIndex || !(*i)->GetTotalTicks()) continue; amount += uint32(((*i)->GetAmount() * std::max<int32>((*i)->GetTotalTicks() - int32((*i)->GetTickNumber()), 0)) / (*i)->GetTotalTicks()); break; @@ -17405,6 +17395,17 @@ void Unit::SendClearTarget() SendMessageToSet(&data, false); } +uint32 Unit::GetResistance(SpellSchoolMask mask) const +{ + int32 resist = -1; + for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) + if (mask & (1 << i) && (resist < 0 || resist > int32(GetResistance(SpellSchools(i))))) + resist = int32(GetResistance(SpellSchools(i))); + + // resist value will never be negative here + return uint32(resist); +} + void CharmInfo::SetIsCommandAttack(bool val) { m_isCommandAttack = val; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 36844d97b67..5906a7f3a2b 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1310,7 +1310,7 @@ class Unit : public WorldObject void CombatStopWithPets(bool includingCast = false); void StopAttackFaction(uint32 faction_id); Unit* SelectNearbyTarget(float dist = NOMINAL_MELEE_RANGE) const; - void SendMeleeAttackStop(Unit* victim); + void SendMeleeAttackStop(Unit* victim = NULL); void SendMeleeAttackStart(Unit* pVictim); void AddUnitState(uint32 f) { m_state |= f; } @@ -1346,6 +1346,7 @@ class Unit : public WorldObject void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); } uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); } + uint32 GetResistance(SpellSchoolMask mask) const; void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school, val); } uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); } @@ -1517,7 +1518,7 @@ class Unit : public WorldObject { value = soft_cap + ((value - soft_cap) / 2); } - + return value; } uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 107e275d47b..fe018ec78ce 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -172,8 +172,12 @@ void Vehicle::ApplyAllImmunities() // Different immunities for vehicles goes below switch (GetVehicleInfo()->m_ID) { - case 160: + // code below prevents a bug with movable cannons + case 160: // Strand of the Ancients + case 244: // Wintergrasp + case 510: // Isle of Conquest _me->SetControlled(true, UNIT_STAT_ROOT); + // why we need to apply this? we can simple add immunities to slow mechanic in DB _me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_DECREASE_SPEED, true); break; default: diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 4cc735a98d7..dbcb07e88f5 100755 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -1170,7 +1170,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) sObjectMgr->AddCreatureToGrid(*itr, data); // Spawn if necessary (loaded grids only) - Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid)); + Map* map = sMapMgr->CreateBaseMap(data->mapid); // We use spawn coords to spawn if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { @@ -1199,7 +1199,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) sObjectMgr->AddGameobjectToGrid(*itr, data); // Spawn if necessary (loaded grids only) // this base map checked as non-instanced and then only existed - Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid)); + Map* map = sMapMgr->CreateBaseMap(data->mapid); // We use current coords to unspawn, not spawn coords since creature can have changed grid if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index 28dcd64e3b7..82532e6ae29 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -199,12 +199,20 @@ void ObjectAccessor::RemoveCorpse(Corpse* corpse) { ASSERT(corpse && corpse->GetType() != CORPSE_BONES); + //TODO: more works need to be done for corpse and other world object if (Map* map = corpse->FindMap()) { corpse->DestroyForNearbyPlayers(); - map->RemoveFromMap(corpse, false); + if (corpse->IsInGrid()) + map->RemoveFromMap(corpse, false); + else + { + corpse->RemoveFromWorld(); + corpse->ResetMap(); + } } else + corpse->RemoveFromWorld(); // Critical section @@ -250,6 +258,10 @@ void ObjectAccessor::AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter) { + // We need this check otherwise a corpose may be added to a grid twice + if (iter->second->IsInGrid()) + continue; + if (iter->second->GetGridCoord() == gridpair) { // verify, if the corpse in our instance (add only corpses which are) @@ -281,6 +293,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia // remove corpse from player_guid -> corpse map and from current map RemoveCorpse(corpse); + // remove corpse from DB SQLTransaction trans = CharacterDatabase.BeginTransaction(); corpse->DeleteFromDB(trans); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 287ce288a88..6b0601d9663 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1599,7 +1599,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float if (!goinfo) return 0; - Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(mapId)); + Map* map = sMapMgr->CreateBaseMap(mapId); if (!map) return 0; @@ -1660,7 +1660,7 @@ bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos) AddCreatureToGrid(guid, &data); // Spawn if necessary (loaded grids only) - if (Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(mapId))) + if (Map* map = sMapMgr->CreateBaseMap(mapId)) { // We use spawn coords to spawn if (!map->Instanceable() && map->IsGridLoaded(data.posX, data.posY)) @@ -1713,7 +1713,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float AddCreatureToGrid(guid, &data); // Spawn if necessary (loaded grids only) - if (Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(mapId))) + if (Map* map = sMapMgr->CreateBaseMap(mapId)) { // We use spawn coords to spawn if (!map->Instanceable() && !map->IsRemovalGrid(x, y)) @@ -3691,42 +3691,41 @@ void ObjectMgr::LoadQuests() mExclusiveQuestGroups.clear(); - // 0 1 2 3 4 5 6 7 8 9 - QueryResult result = WorldDatabase.Query("SELECT entry, Method, ZoneOrSort, SkillOrClassMask, MinLevel, MaxLevel, QuestLevel, Type, RequiredRaces, RequiredSkillValue, " - // 10 11 12 13 14 15 16 17 18 19 - "RepObjectiveFaction, RepObjectiveValue, RepObjectiveFaction2, RepObjectiveValue2, RequiredMinRepFaction, RequiredMinRepValue, RequiredMaxRepFaction, RequiredMaxRepValue, SuggestedPlayers, LimitTime, " - // 20 21 22 23 24 25 26 27 28 29 30 31 32 33 - "QuestFlags, SpecialFlags, CharTitleId, PlayersSlain, BonusTalents, RewardArenaPoints, PrevQuestId, NextQuestId, ExclusiveGroup, NextQuestInChain, RewXPId, SrcItemId, SrcItemCount, SrcSpell, " - // 34 35 36 37 38 39 40 41 42 43 44 - "Title, Details, Objectives, OfferRewardText, RequestItemsText, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4, " - // 45 46 47 48 49 50 51 52 53 54 55 56 - "ReqItemId1, ReqItemId2, ReqItemId3, ReqItemId4, ReqItemId5, ReqItemId6, ReqItemCount1, ReqItemCount2, ReqItemCount3, ReqItemCount4, ReqItemCount5, ReqItemCount6, " - // 57 58 59 60 61 62 63 64 - "ReqSourceId1, ReqSourceId2, ReqSourceId3, ReqSourceId4, ReqSourceCount1, ReqSourceCount2, ReqSourceCount3, ReqSourceCount4, " - // 65 66 67 68 69 70 71 72 - "ReqCreatureOrGOId1, ReqCreatureOrGOId2, ReqCreatureOrGOId3, ReqCreatureOrGOId4, ReqCreatureOrGOCount1, ReqCreatureOrGOCount2, ReqCreatureOrGOCount3, ReqCreatureOrGOCount4, " - // 73 74 75 76 - "ReqSpellCast1, ReqSpellCast2, ReqSpellCast3, ReqSpellCast4, " - // 77 78 79 80 81 82 - "RewChoiceItemId1, RewChoiceItemId2, RewChoiceItemId3, RewChoiceItemId4, RewChoiceItemId5, RewChoiceItemId6, " - // 83 84 85 86 87 88 - "RewChoiceItemCount1, RewChoiceItemCount2, RewChoiceItemCount3, RewChoiceItemCount4, RewChoiceItemCount5, RewChoiceItemCount6, " - // 89 90 91 92 93 94 95 96 - "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4, " - // 97 98 99 100 101 102 103 104 105 106 - "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5, RewRepValueId1, RewRepValueId2, RewRepValueId3, RewRepValueId4, RewRepValueId5, " - // 107 108 109 110 111 - "RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5, " - // 112 113 114 115 116 117 118 119 120 121 122 123 - "RewHonorAddition, RewHonorMultiplier, RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast, RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt, " - // 124 125 126 127 128 129 130 131 - "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4, DetailsEmoteDelay1, DetailsEmoteDelay2, DetailsEmoteDelay3, DetailsEmoteDelay4, " - // 132 133 134 135 136 137 - "IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4, " - // 138 139 140 141 - "OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4, " - // 142 143 - "StartScript, CompleteScript" + QueryResult result = WorldDatabase.Query("SELECT " + //0 1 2 3 4 5 6 7 8 9 10 11 12 + "Id, Method, Level, MinLevel, MaxLevel, ZoneOrSort, Type, SuggestedPlayers, LimitTime, RequiredClasses, RequiredRaces, RequiredSkillId, RequiredSkillPoints, " + // 13 14 15 16 17 18 19 20 + "RequiredFactionId1, RequiredFactionId2, RequiredFactionValue1, RequiredFactionValue2, RequiredMinRepFaction, RequiredMaxRepFaction, RequiredMinRepValue, RequiredMaxRepValue, " + // 21 22 23 24 25 26 27 28 29 30 31 + "PrevQuestId, NextQuestId, ExclusiveGroup, NextQuestIdChain, RewardXPId, RewardOrRequiredMoney, RewardMoneyMaxLevel, RewardSpell, RewardSpellCast, RewardHonor, RewardHonorMultiplier, " + // 32 33 34 35 36 37 38 39 40 41 42 + "RewardMailTemplateId, RewardMailDelay, SourceItemId, SourceItemCount, SourceSpellId, Flags, SpecialFlags, RewardTitleId, RequiredPlayerKills, RewardTalents, RewardArenaPoints, " + // 43 44 45 46 47 48 49 50 + "RewardItemId1, RewardItemId2, RewardItemId3, RewardItemId4, RewardItemCount1, RewardItemCount2, RewardItemCount3, RewardItemCount4, " + // 51 52 53 54 55 56 57 58 59 60 61 62 + "RewardChoiceItemId1, RewardChoiceItemId2, RewardChoiceItemId3, RewardChoiceItemId4, RewardChoiceItemId5, RewardChoiceItemId6, RewardChoiceItemCount1, RewardChoiceItemCount2, RewardChoiceItemCount3, RewardChoiceItemCount4, RewardChoiceItemCount5, RewardChoiceItemCount6, " + // 63 64 65 66 67 68 69 70 71 72 + "RewardFactionId1, RewardFactionId2, RewardFactionId3, RewardFactionId4, RewardFactionId5, RewardFactionValueId1, RewardFactionValueId2, RewardFactionValueId3, RewardFactionValueId4, RewardFactionValueId5, " + // 73 74 75 76 77 + "RewardFactionValueIdOverride1, RewardFactionValueIdOverride2, RewardFactionValueIdOverride3, RewardFactionValueIdOverride4, RewardFactionValueIdOverride5, " + // 78 79 80 81 + "PointMapId, PointX, PointY, PointOption, " + // 82 83 84 85 86 87 88 + "Title, Objectives, Details, EndText, OfferRewardText, RequestItemsText, CompletedText, " + // 89 90 91 92 93 94 95 96 + "RequiredNpcOrGo1, RequiredNpcOrGo2, RequiredNpcOrGo3, RequiredNpcOrGo4, RequiredNpcOrGoCount1, RequiredNpcOrGoCount2, RequiredNpcOrGoCount3, RequiredNpcOrGoCount4, " + // 97 98 99 100 101 102 103 104 + "RequiredSourceItemId1, RequiredSourceItemId2, RequiredSourceItemId3, RequiredSourceItemId4, RequiredSourceItemCount1, RequiredSourceItemCount2, RequiredSourceItemCount3, RequiredSourceItemCount4, " + // 105 106 107 108 109 110 111 112 113 114 115 116 + "RequiredItemId1, RequiredItemId2, RequiredItemId3, RequiredItemId4, RequiredItemId5, RequiredItemId6, RequiredItemCount1, RequiredItemCount2, RequiredItemCount3, RequiredItemCount4, RequiredItemCount5, RequiredItemCount6, " + // 117 118 119 120 121 122 123 124 125 + "RequiredSpellCast1, RequiredSpellCast2, RequiredSpellCast3, RequiredSpellCast4, Unknown0, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4, " + // 126 127 128 129 130 131 132 133 134 135 + "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4, DetailsEmoteDelay1, DetailsEmoteDelay2, DetailsEmoteDelay3, DetailsEmoteDelay4, EmoteOnIncomplete, EmoteOnComplete, " + // 136 137 138 139 140 141 142 143 + "OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4, OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4, " + // 144 145 146 + "StartScript, CompleteScript, WDBVerified" " FROM quest_template"); if (!result) { @@ -3764,45 +3763,45 @@ void ObjectMgr::LoadQuests() sLog->outErrorDb("Quest %u has `Method` = %u, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestMethod()); } - if (qinfo->QuestFlags & ~QUEST_TRINITY_FLAGS_DB_ALLOWED) + if (qinfo->Flags & ~QUEST_TRINITY_FLAGS_DB_ALLOWED) { sLog->outErrorDb("Quest %u has `SpecialFlags` = %u > max allowed value. Correct `SpecialFlags` to value <= %u", - qinfo->GetQuestId(), qinfo->QuestFlags >> 20, QUEST_TRINITY_FLAGS_DB_ALLOWED >> 20); - qinfo->QuestFlags &= QUEST_TRINITY_FLAGS_DB_ALLOWED; + qinfo->GetQuestId(), qinfo->Flags >> 20, QUEST_TRINITY_FLAGS_DB_ALLOWED >> 20); + qinfo->Flags &= QUEST_TRINITY_FLAGS_DB_ALLOWED; } - if (qinfo->QuestFlags & QUEST_FLAGS_DAILY && qinfo->QuestFlags & QUEST_FLAGS_WEEKLY) + if (qinfo->Flags & QUEST_FLAGS_DAILY && qinfo->Flags & QUEST_FLAGS_WEEKLY) { - sLog->outErrorDb("Weekly Quest %u is marked as daily quest in `QuestFlags`, removed daily flag.", qinfo->GetQuestId()); - qinfo->QuestFlags &= ~QUEST_FLAGS_DAILY; + sLog->outErrorDb("Weekly Quest %u is marked as daily quest in `Flags`, removed daily flag.", qinfo->GetQuestId()); + qinfo->Flags &= ~QUEST_FLAGS_DAILY; } - if (qinfo->QuestFlags & QUEST_FLAGS_DAILY) + if (qinfo->Flags & QUEST_FLAGS_DAILY) { - if (!(qinfo->QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE)) + if (!(qinfo->Flags & QUEST_TRINITY_FLAGS_REPEATABLE)) { sLog->outErrorDb("Daily Quest %u not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId()); - qinfo->QuestFlags |= QUEST_TRINITY_FLAGS_REPEATABLE; + qinfo->Flags |= QUEST_TRINITY_FLAGS_REPEATABLE; } } - if (qinfo->QuestFlags & QUEST_FLAGS_WEEKLY) + if (qinfo->Flags & QUEST_FLAGS_WEEKLY) { - if (!(qinfo->QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE)) + if (!(qinfo->Flags & QUEST_TRINITY_FLAGS_REPEATABLE)) { sLog->outErrorDb("Weekly Quest %u not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId()); - qinfo->QuestFlags |= QUEST_TRINITY_FLAGS_REPEATABLE; + qinfo->Flags |= QUEST_TRINITY_FLAGS_REPEATABLE; } } - if (qinfo->QuestFlags & QUEST_FLAGS_AUTO_REWARDED) + if (qinfo->Flags & QUEST_FLAGS_AUTO_REWARDED) { - // at auto-reward can be rewarded only RewChoiceItemId[0] + // at auto-reward can be rewarded only RewardChoiceItemId[0] for (int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j ) { - if (uint32 id = qinfo->RewChoiceItemId[j]) + if (uint32 id = qinfo->RewardChoiceItemId[j]) { - sLog->outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item from `RewChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.", + sLog->outErrorDb("Quest %u has `RewardChoiceItemId%d` = %u but item from `RewardChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.", qinfo->GetQuestId(), j+1, id, j+1); // no changes, quest ignore this data } @@ -3829,77 +3828,68 @@ void ObjectMgr::LoadQuests() qinfo->GetQuestId(), qinfo->ZoneOrSort); // no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check) } - //check SkillOrClass value (class case). - if (ClassByQuestSort(-int32(qinfo->ZoneOrSort))) - { - // SkillOrClass should not have class case when class case already set in ZoneOrSort. - if (qinfo->SkillOrClassMask < 0) - { - sLog->outErrorDb("Quest %u has `ZoneOrSort` = %i (class sort case) and `SkillOrClassMask` = %i (class case), redundant.", - qinfo->GetQuestId(), qinfo->ZoneOrSort, qinfo->SkillOrClassMask); - } - } - //check for proper SkillOrClass value (skill case) + //check for proper RequiredSkillId value (skill case) if (int32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort))) { - // skill is positive value in SkillOrClass - if (qinfo->SkillOrClassMask != skill_id) + if (qinfo->RequiredSkillId != skill_id) { - sLog->outErrorDb("Quest %u has `ZoneOrSort` = %i (skill sort case) but `SkillOrClassMask` does not have a corresponding value (%i).", + sLog->outErrorDb("Quest %u has `ZoneOrSort` = %i but `RequiredSkillId` does not have a corresponding value (%i).", qinfo->GetQuestId(), qinfo->ZoneOrSort, skill_id); //override, and force proper value here? } } } - // SkillOrClassMask (class case) - if (qinfo->SkillOrClassMask < 0) + // RequiredClasses, can be 0/CLASSMASK_ALL_PLAYABLE to allow any class + if (qinfo->RequiredClasses) { - if (!(-int32(qinfo->SkillOrClassMask) & CLASSMASK_ALL_PLAYABLE)) + if (!(qinfo->RequiredClasses & CLASSMASK_ALL_PLAYABLE)) { - sLog->outErrorDb("Quest %u has `SkillOrClassMask` = %i (class case) but classmask does not have valid class", - qinfo->GetQuestId(), qinfo->SkillOrClassMask); + sLog->outErrorDb("Quest %u does not contain any playable classes in `RequiredClasses` (%u), value set to 0 (all classes).", qinfo->GetQuestId(), qinfo->RequiredClasses); + qinfo->RequiredClasses = 0; } } - // SkillOrClassMask (skill case) - if (qinfo->SkillOrClassMask > 0) + // RequiredRaces, can be 0/RACEMASK_ALL_PLAYABLE to allow any race + if (qinfo->RequiredRaces) + { + if (!(qinfo->RequiredRaces & RACEMASK_ALL_PLAYABLE)) + { + sLog->outErrorDb("Quest %u does not contain any playable races in `RequiredRaces` (%u), value set to 0 (all races).", qinfo->GetQuestId(), qinfo->RequiredRaces); + qinfo->RequiredRaces = 0; + } + } + // RequiredSkillId, can be 0 + if (qinfo->RequiredSkillId) { - if (!sSkillLineStore.LookupEntry(qinfo->SkillOrClassMask)) + if (!sSkillLineStore.LookupEntry(qinfo->RequiredSkillId)) { - sLog->outErrorDb("Quest %u has `SkillOrClass` = %u (skill case) but skill (%i) does not exist", - qinfo->GetQuestId(), qinfo->SkillOrClassMask, qinfo->SkillOrClassMask); + sLog->outErrorDb("Quest %u has `RequiredSkillId` = %u but this skill does not exist", + qinfo->GetQuestId(), qinfo->RequiredSkillId); } } - if (qinfo->RequiredSkillValue) + if (qinfo->RequiredSkillPoints) { - if (qinfo->RequiredSkillValue > sWorld->GetConfigMaxSkillValue()) + if (qinfo->RequiredSkillPoints > sWorld->GetConfigMaxSkillValue()) { - sLog->outErrorDb("Quest %u has `RequiredSkillValue` = %u but max possible skill is %u, quest can't be done.", - qinfo->GetQuestId(), qinfo->RequiredSkillValue, sWorld->GetConfigMaxSkillValue()); + sLog->outErrorDb("Quest %u has `RequiredSkillPoints` = %u but max possible skill is %u, quest can't be done.", + qinfo->GetQuestId(), qinfo->RequiredSkillPoints, sWorld->GetConfigMaxSkillValue()); // no changes, quest can't be done for this requirement } - - if (qinfo->SkillOrClassMask <= 0) - { - sLog->outErrorDb("Quest %u has `RequiredSkillValue` = %u but `SkillOrClass` = %i (class case), value ignored.", - qinfo->GetQuestId(), qinfo->RequiredSkillValue, qinfo->SkillOrClassMask); - // no changes, quest can't be done for this requirement (fail at wrong skill id) - } } // else Skill quests can have 0 skill level, this is ok - if (qinfo->RepObjectiveFaction2 && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction2)) + if (qinfo->RequiredFactionId2 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId2)) { - sLog->outErrorDb("Quest %u has `RepObjectiveFaction2` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->RepObjectiveFaction2, qinfo->RepObjectiveFaction2); + sLog->outErrorDb("Quest %u has `RequiredFactionId2` = %u but faction template %u does not exist, quest can't be done.", + qinfo->GetQuestId(), qinfo->RequiredFactionId2, qinfo->RequiredFactionId2); // no changes, quest can't be done for this requirement } - if (qinfo->RepObjectiveFaction && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction)) + if (qinfo->RequiredFactionId1 && !sFactionStore.LookupEntry(qinfo->RequiredFactionId1)) { - sLog->outErrorDb("Quest %u has `RepObjectiveFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->RepObjectiveFaction, qinfo->RepObjectiveFaction); + sLog->outErrorDb("Quest %u has `RequiredFactionId1` = %u but faction template %u does not exist, quest can't be done.", + qinfo->GetQuestId(), qinfo->RequiredFactionId1, qinfo->RequiredFactionId1); // no changes, quest can't be done for this requirement } @@ -3931,17 +3921,17 @@ void ObjectMgr::LoadQuests() // no changes, quest can't be done for this requirement } - if (!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue != 0) + if (!qinfo->RequiredFactionId1 && qinfo->RequiredFactionValue1 != 0) { - sLog->outErrorDb("Quest %u has `RepObjectiveValue` = %d but `RepObjectiveFaction` is 0, value has no effect", - qinfo->GetQuestId(), qinfo->RepObjectiveValue); + sLog->outErrorDb("Quest %u has `RequiredFactionValue1` = %d but `RequiredFactionId1` is 0, value has no effect", + qinfo->GetQuestId(), qinfo->RequiredFactionValue1); // warning } - if (!qinfo->RepObjectiveFaction2 && qinfo->RepObjectiveValue2 != 0) + if (!qinfo->RequiredFactionId2 && qinfo->RequiredFactionValue2 != 0) { - sLog->outErrorDb("Quest %u has `RepObjectiveValue2` = %d but `RepObjectiveFaction2` is 0, value has no effect", - qinfo->GetQuestId(), qinfo->RepObjectiveValue2); + sLog->outErrorDb("Quest %u has `RequiredFactionValue2` = %d but `RequiredFactionId2` is 0, value has no effect", + qinfo->GetQuestId(), qinfo->RequiredFactionValue2); // warning } @@ -3959,61 +3949,61 @@ void ObjectMgr::LoadQuests() // warning } - if (qinfo->CharTitleId && !sCharTitlesStore.LookupEntry(qinfo->CharTitleId)) + if (qinfo->RewardTitleId && !sCharTitlesStore.LookupEntry(qinfo->RewardTitleId)) { - sLog->outErrorDb("Quest %u has `CharTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.", + sLog->outErrorDb("Quest %u has `RewardTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.", qinfo->GetQuestId(), qinfo->GetCharTitleId(), qinfo->GetCharTitleId()); - qinfo->CharTitleId = 0; + qinfo->RewardTitleId = 0; // quest can't reward this title } - if (qinfo->SrcItemId) + if (qinfo->SourceItemId) { - if (!sObjectMgr->GetItemTemplate(qinfo->SrcItemId)) + if (!sObjectMgr->GetItemTemplate(qinfo->SourceItemId)) { - sLog->outErrorDb("Quest %u has `SrcItemId` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->SrcItemId, qinfo->SrcItemId); - qinfo->SrcItemId = 0; // quest can't be done for this requirement + sLog->outErrorDb("Quest %u has `SourceItemId` = %u but item with entry %u does not exist, quest can't be done.", + qinfo->GetQuestId(), qinfo->SourceItemId, qinfo->SourceItemId); + qinfo->SourceItemId = 0; // quest can't be done for this requirement } - else if (qinfo->SrcItemCount == 0) + else if (qinfo->SourceItemIdCount == 0) { - sLog->outErrorDb("Quest %u has `SrcItemId` = %u but `SrcItemCount` = 0, set to 1 but need fix in DB.", - qinfo->GetQuestId(), qinfo->SrcItemId); - qinfo->SrcItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB + sLog->outErrorDb("Quest %u has `SourceItemId` = %u but `SourceItemIdCount` = 0, set to 1 but need fix in DB.", + qinfo->GetQuestId(), qinfo->SourceItemId); + qinfo->SourceItemIdCount = 1; // update to 1 for allow quest work for backward compatibility with DB } } - else if (qinfo->SrcItemCount>0) + else if (qinfo->SourceItemIdCount>0) { - sLog->outErrorDb("Quest %u has `SrcItemId` = 0 but `SrcItemCount` = %u, useless value.", - qinfo->GetQuestId(), qinfo->SrcItemCount); - qinfo->SrcItemCount=0; // no quest work changes in fact + sLog->outErrorDb("Quest %u has `SourceItemId` = 0 but `SourceItemIdCount` = %u, useless value.", + qinfo->GetQuestId(), qinfo->SourceItemIdCount); + qinfo->SourceItemIdCount=0; // no quest work changes in fact } - if (qinfo->SrcSpell) + if (qinfo->SourceSpellid) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SrcSpell); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SourceSpellid); if (!spellInfo) { - sLog->outErrorDb("Quest %u has `SrcSpell` = %u but spell %u doesn't exist, quest can't be done.", - qinfo->GetQuestId(), qinfo->SrcSpell, qinfo->SrcSpell); - qinfo->SrcSpell = 0; // quest can't be done for this requirement + sLog->outErrorDb("Quest %u has `SourceSpellid` = %u but spell %u doesn't exist, quest can't be done.", + qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid); + qinfo->SourceSpellid = 0; // quest can't be done for this requirement } else if (!SpellMgr::IsSpellValid(spellInfo)) { - sLog->outErrorDb("Quest %u has `SrcSpell` = %u but spell %u is broken, quest can't be done.", - qinfo->GetQuestId(), qinfo->SrcSpell, qinfo->SrcSpell); - qinfo->SrcSpell = 0; // quest can't be done for this requirement + sLog->outErrorDb("Quest %u has `SourceSpellid` = %u but spell %u is broken, quest can't be done.", + qinfo->GetQuestId(), qinfo->SourceSpellid, qinfo->SourceSpellid); + qinfo->SourceSpellid = 0; // quest can't be done for this requirement } } for (uint8 j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { - uint32 id = qinfo->ReqItemId[j]; + uint32 id = qinfo->RequiredItemId[j]; if (id) { - if (qinfo->ReqItemCount[j] == 0) + if (qinfo->RequiredItemCount[j] == 0) { - sLog->outErrorDb("Quest %u has `ReqItemId%d` = %u but `ReqItemCount%d` = 0, quest can't be done.", + sLog->outErrorDb("Quest %u has `RequiredItemId%d` = %u but `RequiredItemCount%d` = 0, quest can't be done.", qinfo->GetQuestId(), j+1, id, j+1); // no changes, quest can't be done for this requirement } @@ -4022,37 +4012,37 @@ void ObjectMgr::LoadQuests() if (!sObjectMgr->GetItemTemplate(id)) { - sLog->outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.", + sLog->outErrorDb("Quest %u has `RequiredItemId%d` = %u but item with entry %u does not exist, quest can't be done.", qinfo->GetQuestId(), j+1, id, id); - qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest + qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest } } - else if (qinfo->ReqItemCount[j]>0) + else if (qinfo->RequiredItemCount[j]>0) { - sLog->outErrorDb("Quest %u has `ReqItemId%d` = 0 but `ReqItemCount%d` = %u, quest can't be done.", - qinfo->GetQuestId(), j+1, j+1, qinfo->ReqItemCount[j]); - qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest + sLog->outErrorDb("Quest %u has `RequiredItemId%d` = 0 but `RequiredItemCount%d` = %u, quest can't be done.", + qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredItemCount[j]); + qinfo->RequiredItemCount[j] = 0; // prevent incorrect work of quest } } for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j) { - uint32 id = qinfo->ReqSourceId[j]; + uint32 id = qinfo->RequiredSourceItemid[j]; if (id) { if (!sObjectMgr->GetItemTemplate(id)) { - sLog->outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.", + sLog->outErrorDb("Quest %u has `RequiredSourceItemid%d` = %u but item with entry %u does not exist, quest can't be done.", qinfo->GetQuestId(), j+1, id, id); // no changes, quest can't be done for this requirement } } else { - if (qinfo->ReqSourceCount[j]>0) + if (qinfo->RequiredSourceItemId[j]>0) { - sLog->outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceCount%d` = %u.", - qinfo->GetQuestId(), j+1, j+1, qinfo->ReqSourceCount[j]); + sLog->outErrorDb("Quest %u has `RequiredSourceItemid%d` = 0 but `RequiredSourceItemId%d` = %u.", + qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredSourceItemId[j]); // no changes, quest ignore this data } } @@ -4060,7 +4050,7 @@ void ObjectMgr::LoadQuests() for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { - uint32 id = qinfo->ReqSpell[j]; + uint32 id = qinfo->RequiredSpellCast[j]; if (id) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id); @@ -4071,12 +4061,12 @@ void ObjectMgr::LoadQuests() continue; } - if (!qinfo->ReqCreatureOrGOId[j]) + if (!qinfo->RequiredNpcOrGo[j]) { bool found = false; for (uint8 k = 0; k < MAX_SPELL_EFFECTS; ++k) { - if ((spellInfo->Effects[k].Effect == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->Effects[k].MiscValue) == qinfo->QuestId) || + if ((spellInfo->Effects[k].Effect == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->Effects[k].MiscValue) == qinfo->Id) || spellInfo->Effects[k].Effect == SPELL_EFFECT_SEND_EVENT) { found = true; @@ -4088,7 +4078,7 @@ void ObjectMgr::LoadQuests() { if (!qinfo->HasFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT)) { - sLog->outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and ReqCreatureOrGOId%d = 0, but quest not have flag QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT. Quest flags or ReqCreatureOrGOId%d must be fixed, quest modified to enable objective.", spellInfo->Id, qinfo->QuestId, j+1, j+1); + sLog->outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and RequiredNpcOrGo%d = 0, but quest not have flag QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT. Quest flags or RequiredNpcOrGo%d must be fixed, quest modified to enable objective.", spellInfo->Id, qinfo->Id, j+1, j+1); // this will prevent quest completing without objective const_cast<Quest*>(qinfo)->SetFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT); @@ -4096,7 +4086,7 @@ void ObjectMgr::LoadQuests() } else { - sLog->outErrorDb("Quest %u has `ReqSpellCast%d` = %u and ReqCreatureOrGOId%d = 0 but spell %u does not have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT effect for this quest, quest can't be done.", + sLog->outErrorDb("Quest %u has `ReqSpellCast%d` = %u and RequiredNpcOrGo%d = 0 but spell %u does not have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT effect for this quest, quest can't be done.", qinfo->GetQuestId(), j+1, id, j+1, id); // no changes, quest can't be done for this requirement } @@ -4106,19 +4096,19 @@ void ObjectMgr::LoadQuests() for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { - int32 id = qinfo->ReqCreatureOrGOId[j]; + int32 id = qinfo->RequiredNpcOrGo[j]; if (id < 0 && !sObjectMgr->GetGameObjectTemplate(-id)) { - sLog->outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but gameobject %u does not exist, quest can't be done.", + sLog->outErrorDb("Quest %u has `RequiredNpcOrGo%d` = %i but gameobject %u does not exist, quest can't be done.", qinfo->GetQuestId(), j+1, id, uint32(-id)); - qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement + qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement } if (id > 0 && !sObjectMgr->GetCreatureTemplate(id)) { - sLog->outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.", + sLog->outErrorDb("Quest %u has `RequiredNpcOrGo%d` = %i but creature with entry %u does not exist, quest can't be done.", qinfo->GetQuestId(), j+1, id, uint32(id)); - qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement + qinfo->RequiredNpcOrGo[j] = 0; // quest can't be done for this requirement } if (id) @@ -4127,179 +4117,179 @@ void ObjectMgr::LoadQuests() qinfo->SetFlag(QUEST_TRINITY_FLAGS_KILL_OR_CAST | QUEST_TRINITY_FLAGS_SPEAKTO); - if (!qinfo->ReqCreatureOrGOCount[j]) + if (!qinfo->RequiredNpcOrGoCount[j]) { - sLog->outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %u but `ReqCreatureOrGOCount%d` = 0, quest can't be done.", + sLog->outErrorDb("Quest %u has `RequiredNpcOrGo%d` = %u but `RequiredNpcOrGoCount%d` = 0, quest can't be done.", qinfo->GetQuestId(), j+1, id, j+1); // no changes, quest can be incorrectly done, but we already report this } } - else if (qinfo->ReqCreatureOrGOCount[j]>0) + else if (qinfo->RequiredNpcOrGoCount[j]>0) { - sLog->outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = 0 but `ReqCreatureOrGOCount%d` = %u.", - qinfo->GetQuestId(), j+1, j+1, qinfo->ReqCreatureOrGOCount[j]); + sLog->outErrorDb("Quest %u has `RequiredNpcOrGo%d` = 0 but `RequiredNpcOrGoCount%d` = %u.", + qinfo->GetQuestId(), j+1, j+1, qinfo->RequiredNpcOrGoCount[j]); // no changes, quest ignore this data } } for (uint8 j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j) { - uint32 id = qinfo->RewChoiceItemId[j]; + uint32 id = qinfo->RewardChoiceItemId[j]; if (id) { if (!sObjectMgr->GetItemTemplate(id)) { - sLog->outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", + sLog->outErrorDb("Quest %u has `RewardChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", qinfo->GetQuestId(), j+1, id, id); - qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this + qinfo->RewardChoiceItemId[j] = 0; // no changes, quest will not reward this } - if (!qinfo->RewChoiceItemCount[j]) + if (!qinfo->RewardChoiceItemCount[j]) { - sLog->outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but `RewChoiceItemCount%d` = 0, quest can't be done.", + sLog->outErrorDb("Quest %u has `RewardChoiceItemId%d` = %u but `RewardChoiceItemCount%d` = 0, quest can't be done.", qinfo->GetQuestId(), j+1, id, j+1); // no changes, quest can't be done } } - else if (qinfo->RewChoiceItemCount[j]>0) + else if (qinfo->RewardChoiceItemCount[j]>0) { - sLog->outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemCount%d` = %u.", - qinfo->GetQuestId(), j+1, j+1, qinfo->RewChoiceItemCount[j]); + sLog->outErrorDb("Quest %u has `RewardChoiceItemId%d` = 0 but `RewardChoiceItemCount%d` = %u.", + qinfo->GetQuestId(), j+1, j+1, qinfo->RewardChoiceItemCount[j]); // no changes, quest ignore this data } } for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j) { - uint32 id = qinfo->RewItemId[j]; + uint32 id = qinfo->RewardItemId[j]; if (id) { if (!sObjectMgr->GetItemTemplate(id)) { - sLog->outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", + sLog->outErrorDb("Quest %u has `RewardItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", qinfo->GetQuestId(), j+1, id, id); - qinfo->RewItemId[j] = 0; // no changes, quest will not reward this item + qinfo->RewardItemId[j] = 0; // no changes, quest will not reward this item } - if (!qinfo->RewItemCount[j]) + if (!qinfo->RewardItemIdCount[j]) { - sLog->outErrorDb("Quest %u has `RewItemId%d` = %u but `RewItemCount%d` = 0, quest will not reward this item.", + sLog->outErrorDb("Quest %u has `RewardItemId%d` = %u but `RewardItemIdCount%d` = 0, quest will not reward this item.", qinfo->GetQuestId(), j+1, id, j+1); // no changes } } - else if (qinfo->RewItemCount[j]>0) + else if (qinfo->RewardItemIdCount[j]>0) { - sLog->outErrorDb("Quest %u has `RewItemId%d` = 0 but `RewItemCount%d` = %u.", - qinfo->GetQuestId(), j+1, j+1, qinfo->RewItemCount[j]); + sLog->outErrorDb("Quest %u has `RewardItemId%d` = 0 but `RewardItemIdCount%d` = %u.", + qinfo->GetQuestId(), j+1, j+1, qinfo->RewardItemIdCount[j]); // no changes, quest ignore this data } } for (uint8 j = 0; j < QUEST_REPUTATIONS_COUNT; ++j) { - if (qinfo->RewRepFaction[j]) + if (qinfo->RewardFactionId[j]) { - if (abs(qinfo->RewRepValueId[j]) > 9) + if (abs(qinfo->RewardFactionValueId[j]) > 9) { - sLog->outErrorDb("Quest %u has RewRepValueId%d = %i. That is outside the range of valid values (-9 to 9).", qinfo->GetQuestId(), j+1, qinfo->RewRepValueId[j]); + sLog->outErrorDb("Quest %u has RewardFactionValueId%d = %i. That is outside the range of valid values (-9 to 9).", qinfo->GetQuestId(), j+1, qinfo->RewardFactionValueId[j]); } - if (!sFactionStore.LookupEntry(qinfo->RewRepFaction[j])) + if (!sFactionStore.LookupEntry(qinfo->RewardFactionId[j])) { - sLog->outErrorDb("Quest %u has `RewRepFaction%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.", qinfo->GetQuestId(), j+1, qinfo->RewRepFaction[j], qinfo->RewRepFaction[j]); - qinfo->RewRepFaction[j] = 0; // quest will not reward this + sLog->outErrorDb("Quest %u has `RewardFactionId%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.", qinfo->GetQuestId(), j+1, qinfo->RewardFactionId[j], qinfo->RewardFactionId[j]); + qinfo->RewardFactionId[j] = 0; // quest will not reward this } } - else if (qinfo->RewRepValue[j] != 0) + else if (qinfo->RewardFactionValueIdOverride[j] != 0) { - sLog->outErrorDb("Quest %u has `RewRepFaction%d` = 0 but `RewRepValue%d` = %i.", - qinfo->GetQuestId(), j+1, j+1, qinfo->RewRepValue[j]); + sLog->outErrorDb("Quest %u has `RewardFactionId%d` = 0 but `RewardFactionValueIdOverride%d` = %i.", + qinfo->GetQuestId(), j+1, j+1, qinfo->RewardFactionValueIdOverride[j]); // no changes, quest ignore this data } } - if (qinfo->RewSpell) + if (qinfo->RewardSpell) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewSpell); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardSpell); if (!spellInfo) { - sLog->outErrorDb("Quest %u has `RewSpell` = %u but spell %u does not exist, spell removed as display reward.", - qinfo->GetQuestId(), qinfo->RewSpell, qinfo->RewSpell); - qinfo->RewSpell = 0; // no spell reward will display for this quest + sLog->outErrorDb("Quest %u has `RewardSpell` = %u but spell %u does not exist, spell removed as display reward.", + qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell); + qinfo->RewardSpell = 0; // no spell reward will display for this quest } else if (!SpellMgr::IsSpellValid(spellInfo)) { - sLog->outErrorDb("Quest %u has `RewSpell` = %u but spell %u is broken, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewSpell, qinfo->RewSpell); - qinfo->RewSpell = 0; // no spell reward will display for this quest + sLog->outErrorDb("Quest %u has `RewardSpell` = %u but spell %u is broken, quest will not have a spell reward.", + qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell); + qinfo->RewardSpell = 0; // no spell reward will display for this quest } - else if (GetTalentSpellCost(qinfo->RewSpell)) + else if (GetTalentSpellCost(qinfo->RewardSpell)) { - sLog->outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewSpell, qinfo->RewSpell); - qinfo->RewSpell = 0; // no spell reward will display for this quest + sLog->outErrorDb("Quest %u has `RewardSpell` = %u but spell %u is talent, quest will not have a spell reward.", + qinfo->GetQuestId(), qinfo->RewardSpell, qinfo->RewardSpell); + qinfo->RewardSpell = 0; // no spell reward will display for this quest } } - if (qinfo->RewSpellCast > 0) + if (qinfo->RewardSpellCast > 0) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewSpellCast); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardSpellCast); if (!spellInfo) { - sLog->outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewSpellCast, qinfo->RewSpellCast); - qinfo->RewSpellCast = 0; // no spell will be casted on player + sLog->outErrorDb("Quest %u has `RewardSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.", + qinfo->GetQuestId(), qinfo->RewardSpellCast, qinfo->RewardSpellCast); + qinfo->RewardSpellCast = 0; // no spell will be casted on player } else if (!SpellMgr::IsSpellValid(spellInfo)) { - sLog->outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u is broken, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewSpellCast, qinfo->RewSpellCast); - qinfo->RewSpellCast = 0; // no spell will be casted on player + sLog->outErrorDb("Quest %u has `RewardSpellCast` = %u but spell %u is broken, quest will not have a spell reward.", + qinfo->GetQuestId(), qinfo->RewardSpellCast, qinfo->RewardSpellCast); + qinfo->RewardSpellCast = 0; // no spell will be casted on player } - else if (GetTalentSpellCost(qinfo->RewSpellCast)) + else if (GetTalentSpellCost(qinfo->RewardSpellCast)) { - sLog->outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.", - qinfo->GetQuestId(), qinfo->RewSpellCast, qinfo->RewSpellCast); - qinfo->RewSpellCast = 0; // no spell will be casted on player + sLog->outErrorDb("Quest %u has `RewardSpell` = %u but spell %u is talent, quest will not have a spell reward.", + qinfo->GetQuestId(), qinfo->RewardSpellCast, qinfo->RewardSpellCast); + qinfo->RewardSpellCast = 0; // no spell will be casted on player } } - if (qinfo->RewMailTemplateId) + if (qinfo->RewardMailTemplateId) { - if (!sMailTemplateStore.LookupEntry(qinfo->RewMailTemplateId)) + if (!sMailTemplateStore.LookupEntry(qinfo->RewardMailTemplateId)) { - sLog->outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.", - qinfo->GetQuestId(), qinfo->RewMailTemplateId, qinfo->RewMailTemplateId); - qinfo->RewMailTemplateId = 0; // no mail will send to player - qinfo->RewMailDelaySecs = 0; // no mail will send to player + sLog->outErrorDb("Quest %u has `RewardMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.", + qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId); + qinfo->RewardMailTemplateId = 0; // no mail will send to player + qinfo->RewardMailDelay = 0; // no mail will send to player } - else if (usedMailTemplates.find(qinfo->RewMailTemplateId) != usedMailTemplates.end()) + else if (usedMailTemplates.find(qinfo->RewardMailTemplateId) != usedMailTemplates.end()) { - std::map<uint32, uint32>::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewMailTemplateId); - sLog->outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u already used for quest %u, quest will not have a mail reward.", - qinfo->GetQuestId(), qinfo->RewMailTemplateId, qinfo->RewMailTemplateId, used_mt_itr->second); - qinfo->RewMailTemplateId = 0; // no mail will send to player - qinfo->RewMailDelaySecs = 0; // no mail will send to player + std::map<uint32, uint32>::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewardMailTemplateId); + sLog->outErrorDb("Quest %u has `RewardMailTemplateId` = %u but mail template %u already used for quest %u, quest will not have a mail reward.", + qinfo->GetQuestId(), qinfo->RewardMailTemplateId, qinfo->RewardMailTemplateId, used_mt_itr->second); + qinfo->RewardMailTemplateId = 0; // no mail will send to player + qinfo->RewardMailDelay = 0; // no mail will send to player } else - usedMailTemplates[qinfo->RewMailTemplateId] = qinfo->GetQuestId(); + usedMailTemplates[qinfo->RewardMailTemplateId] = qinfo->GetQuestId(); } - if (qinfo->NextQuestInChain) + if (qinfo->NextQuestIdChain) { - QuestMap::iterator qNextItr = mQuestTemplates.find(qinfo->NextQuestInChain); + QuestMap::iterator qNextItr = mQuestTemplates.find(qinfo->NextQuestIdChain); if (qNextItr == mQuestTemplates.end()) { - sLog->outErrorDb("Quest %u has `NextQuestInChain` = %u but quest %u does not exist, quest chain will not work.", - qinfo->GetQuestId(), qinfo->NextQuestInChain, qinfo->NextQuestInChain); - qinfo->NextQuestInChain = 0; + sLog->outErrorDb("Quest %u has `NextQuestIdChain` = %u but quest %u does not exist, quest chain will not work.", + qinfo->GetQuestId(), qinfo->NextQuestIdChain, qinfo->NextQuestIdChain); + qinfo->NextQuestIdChain = 0; } else qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId()); @@ -4336,7 +4326,7 @@ void ObjectMgr::LoadQuests() mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId())); if (qinfo->LimitTime) qinfo->SetFlag(QUEST_TRINITY_FLAGS_TIMED); - if (qinfo->PlayersSlain) + if (qinfo->RequiredPlayerKills) qinfo->SetFlag(QUEST_TRINITY_FLAGS_PLAYER_KILL); } @@ -5392,7 +5382,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) // mail open and then not returned 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); CharacterDatabase.Execute(stmt); } @@ -7084,13 +7074,13 @@ void ObjectMgr::LoadQuestPOI() { // The first result should have the highest questId Field* fields = points->Fetch(); - uint32 questId = fields[0].GetUInt32(); - POIs.resize(questId + 1); + uint32 questIdMax = fields[0].GetUInt32(); + POIs.resize(questIdMax + 1); do { - Field* fields = points->Fetch(); + fields = points->Fetch(); uint32 questId = fields[0].GetUInt32(); uint32 id = fields[1].GetUInt32(); diff --git a/src/server/game/Grids/Grid.h b/src/server/game/Grids/Grid.h index a90915d49f0..448c4cb35fd 100755 --- a/src/server/game/Grids/Grid.h +++ b/src/server/game/Grids/Grid.h @@ -58,17 +58,19 @@ class Grid */ template<class SPECIFIC_OBJECT> void AddWorldObject(SPECIFIC_OBJECT *obj) { - if (!i_objects.template insert<SPECIFIC_OBJECT>(obj)) - ASSERT(false); + i_objects.template insert<SPECIFIC_OBJECT>(obj); + ASSERT(obj->IsInGrid()); } /** an object of interested exits the grid */ - template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj) - { - if (!i_objects.template remove<SPECIFIC_OBJECT>(obj)) - ASSERT(false); - } + //Actually an unlink is enough, no need to go through the container + //template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj) + //{ + // ASSERT(obj->GetGridRef().isValid()); + // i_objects.template remove<SPECIFIC_OBJECT>(obj); + // ASSERT(!obj->GetGridRef().isValid()); + //} /** Refreshes/update the grid. This required for remote grids. */ @@ -104,17 +106,18 @@ class Grid */ template<class SPECIFIC_OBJECT> void AddGridObject(SPECIFIC_OBJECT *obj) { - if (!i_container.template insert<SPECIFIC_OBJECT>(obj)) - ASSERT(false); + i_container.template insert<SPECIFIC_OBJECT>(obj); + ASSERT(obj->IsInGrid()); } /** Removes a containter type object from the grid */ - template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj) - { - if (!i_container.template remove<SPECIFIC_OBJECT>(obj)) - ASSERT(false); - } + //template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj) + //{ + // ASSERT(obj->GetGridRef().isValid()); + // i_container.template remove<SPECIFIC_OBJECT>(obj); + // ASSERT(!obj->GetGridRef().isValid()); + //} /*bool NoWorldObjectInGrid() const { diff --git a/src/server/game/Grids/NGrid.h b/src/server/game/Grids/NGrid.h index b814fd386a5..97a47f7d272 100755 --- a/src/server/game/Grids/NGrid.h +++ b/src/server/game/Grids/NGrid.h @@ -120,6 +120,7 @@ class NGrid void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); } void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); } + /* template<class SPECIFIC_OBJECT> void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { GetGridType(x, y).AddWorldObject(obj); @@ -139,6 +140,7 @@ class NGrid { GetGridType(x, y).RemoveGridObject(obj); } + */ // Visit all Grids (cells) in NGrid (grid) template<class T, class TT> diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index e38c74dd8e4..56c6410e6d7 100755 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -77,7 +77,7 @@ template<> void ObjectGridLoader::SetObjectCell(Creature* obj, CellCoord const& template <class T> void AddObjectHelper(CellCoord &cell, GridRefManager<T> &m, uint32 &count, Map* map, T *obj) { - obj->GetGridRef().link(&m, obj); + obj->AddToGrid(m); ObjectGridLoader::SetObjectCell(obj, cell); obj->AddToWorld(); if (obj->isActiveObject()) @@ -126,6 +126,12 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellCoord &cell, CorpseMapTyp // in that case map == currMap obj->SetMap(map); + if (obj->IsInGrid()) + { + obj->AddToWorld(); + continue; + } + AddObjectHelper(cell, m, count, map, obj); } } @@ -205,6 +211,11 @@ void ObjectGridUnloader::Visit(GridRefManager<T> &m) // if option set then object already saved at this moment if (!sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY)) obj->SaveRespawnTime(); + //Some creatures may summon other temp summons in CleanupsBeforeDelete() + //So we need this even after cleaner (maybe we can remove cleaner) + //Example: Flame Leviathan Turret 33139 is summoned when a creature is deleted + //TODO: Check if that script has the correct logic. Do we really need to summons something before deleting? + obj->CleanupsBeforeDelete(); ///- object will get delinked from the manager when deleted delete obj; } @@ -225,23 +236,18 @@ void ObjectGridStoper::Visit(CreatureMapType &m) } } -void ObjectGridCleaner::Visit(CreatureMapType &m) -{ - for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) - iter->getSource()->CleanupsBeforeDelete(); -} - template<class T> void ObjectGridCleaner::Visit(GridRefManager<T> &m) { for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter) - iter->getSource()->RemoveFromWorld(); + iter->getSource()->CleanupsBeforeDelete(); } template void ObjectGridUnloader::Visit(CreatureMapType &); template void ObjectGridUnloader::Visit(GameObjectMapType &); template void ObjectGridUnloader::Visit(DynamicObjectMapType &); template void ObjectGridUnloader::Visit(CorpseMapType &); +template void ObjectGridCleaner::Visit(CreatureMapType &); template void ObjectGridCleaner::Visit<GameObject>(GameObjectMapType &); template void ObjectGridCleaner::Visit<DynamicObject>(DynamicObjectMapType &); template void ObjectGridCleaner::Visit<Corpse>(CorpseMapType &); diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h index 411cae10a90..09a8fb2af9c 100755 --- a/src/server/game/Grids/ObjectGridLoader.h +++ b/src/server/game/Grids/ObjectGridLoader.h @@ -74,7 +74,6 @@ class ObjectGridEvacuator class ObjectGridCleaner { public: - void Visit(CreatureMapType &m); template<class T> void Visit(GridRefManager<T> &); }; diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index bc2648ed02b..7a2368161d8 100755 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -309,11 +309,11 @@ void InstanceSaveManager::LoadResetTimes() while (result->NextRow()); // 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 { - Field* fields = result->Fetch(); + Field* fields = result2->Fetch(); uint32 instance = fields[1].GetUInt32(); time_t resettime = time_t(fields[0].GetUInt32() + 2 * HOUR); InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance); @@ -511,7 +511,7 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr) void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId) { sLog->outDebug(LOG_FILTER_MAPS, "InstanceSaveMgr::_ResetInstance %u, %u", mapid, instanceId); - Map* map = (MapInstanced*)sMapMgr->CreateBaseMap(mapid); + Map const* map = sMapMgr->CreateBaseMap(mapid); if (!map->Instanceable()) return; @@ -521,7 +521,7 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId) DeleteInstanceFromDB(instanceId); // even if save not loaded - Map* iMap = ((MapInstanced*)map)->FindMap(instanceId); + Map* iMap = ((MapInstanced*)map)->FindInstanceMap(instanceId); if (iMap && iMap->IsDungeon()) ((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY); diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index f0e21f7f709..b8987be9adb 100755 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -305,7 +305,6 @@ void InstanceScript::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData) void InstanceScript::DoSendNotifyToInstance(const char *format, ...) { InstanceMap::PlayerList const &PlayerList = instance->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; if (!PlayerList.isEmpty()) { diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index e193325b72e..bd419482b5b 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -256,16 +256,6 @@ void Map::AddToGrid(Creature* obj, Cell const& cell) } template<class T> -void Map::RemoveFromGrid(T* obj, Cell const& cell) -{ - NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); - if (obj->m_isWorldObject) - grid->GetGridType(cell.CellX(), cell.CellY()).template RemoveWorldObject<T>(obj); - else - grid->GetGridType(cell.CellX(), cell.CellY()).template RemoveGridObject<T>(obj); -} - -template<class T> void Map::SwitchGridContainers(T* obj, bool on) { CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); @@ -285,16 +275,11 @@ void Map::SwitchGridContainers(T* obj, bool on) GridType &grid = ngrid->GetGridType(cell.CellX(), cell.CellY()); + obj->RemoveFromGrid(); //This step is not really necessary but we want to do ASSERT in remove/add if (on) - { - grid.RemoveGridObject<T>(obj); grid.AddWorldObject<T>(obj); - } else - { - grid.RemoveWorldObject<T>(obj); grid.AddGridObject<T>(obj); - } obj->m_isWorldObject = on; } @@ -390,23 +375,22 @@ void Map::LoadGrid(float x, float y) EnsureGridLoaded(Cell(x, y)); } -bool Map::AddToMap(Player* player) +bool Map::AddPlayerToMap(Player* player) { - // Check if we are adding to correct map - ASSERT (player->GetMap() == this); - CellCoord p = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()); - if (!p.IsCoordValid()) + CellCoord cellCoord = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()); + if (!cellCoord.IsCoordValid()) { - sLog->outError("Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord); + sLog->outError("Map::Add: Player (GUID: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); return false; } - player->SetMap(this); - - Cell cell(p); + Cell cell(cellCoord); EnsureGridLoadedForActiveObject(cell, player); AddToGrid(player, cell); + // Check if we are adding to correct map + ASSERT (player->GetMap() == this); + player->SetMap(this); player->AddToWorld(); SendInitSelf(player); @@ -431,38 +415,40 @@ void Map::InitializeObject(Creature* obj) } template<class T> -void -Map::AddToMap(T *obj) +void Map::AddToMap(T *obj) { - CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); - if (!p.IsCoordValid()) + //TODO: Needs clean up. An object should not be added to map twice. + if (obj->IsInWorld()) { - sLog->outError("Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); + ASSERT(obj->IsInGrid()); + obj->UpdateObjectVisibility(true); return; } - Cell cell(p); - if (obj->IsInWorld()) // need some clean up later + CellCoord cellCoord = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); + if (!cellCoord.IsCoordValid()) { - obj->UpdateObjectVisibility(true); + sLog->outError("Map::Add: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord); return; } + Cell cell(cellCoord); if (obj->isActiveObject()) EnsureGridLoadedForActiveObject(cell, obj); else EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY())); - AddToGrid(obj, cell); + sLog->outStaticDebug("Object %u enters grid[%u, %u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY()); + + //Must already be set before AddToMap. Usually during obj->Create. //obj->SetMap(this); obj->AddToWorld(); + InitializeObject(obj); if (obj->isActiveObject()) AddToActive(obj); - sLog->outStaticDebug("Object %u enters grid[%u, %u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY()); - //something, such as vehicle, needs to be update immediately //also, trigger needs to cast spell, if not update, cannot see visual obj->UpdateObjectVisibility(true); @@ -656,26 +642,16 @@ void Map::ProcessRelocationNotifies(const uint32 diff) } } -void Map::RemoveFromMap(Player* player, bool remove) +void Map::RemovePlayerFromMap(Player* player, bool remove) { player->RemoveFromWorld(); SendRemoveTransports(player); - CellCoord p = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()); - if (!p.IsCoordValid()) - sLog->outCrash("Map::Remove: Player is in invalid cell!"); + player->UpdateObjectVisibility(true); + if (player->IsInGrid()) + player->RemoveFromGrid(); else - { - Cell cell(p); - if (!getNGrid(cell.data.Part.grid_x, cell.data.Part.grid_y)) - sLog->outError("Map::Remove() i_grids was NULL x:%d, y:%d", cell.data.Part.grid_x, cell.data.Part.grid_y); - else - { - sLog->outStaticDebug("Remove player %s from grid[%u, %u]", player->GetName(), cell.GridX(), cell.GridY()); - player->UpdateObjectVisibility(true); - RemoveFromGrid(player, cell); - } - } + ASSERT(remove); //maybe deleted in logoutplayer when player is not in a map if (remove) DeleteFromWorld(player); @@ -691,19 +667,8 @@ Map::RemoveFromMap(T *obj, bool remove) if (obj->isActiveObject()) RemoveFromActive(obj); - CellCoord p = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); - if (!p.IsCoordValid()) - sLog->outError("Map::Remove: Object " UI64FMTD " has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); - else - { - Cell cell(p); - if (IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y))) - { - sLog->outStaticDebug("Remove object " UI64FMTD " from grid[%u, %u]", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y); - obj->UpdateObjectVisibility(true); - RemoveFromGrid(obj, cell); - } - } + obj->UpdateObjectVisibility(true); + obj->RemoveFromGrid(); obj->ResetMap(); @@ -730,7 +695,7 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati { sLog->outStaticDebug("Player %s relocation grid[%u, %u]cell[%u, %u]->grid[%u, %u]cell[%u, %u]", player->GetName(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); - RemoveFromGrid(player, old_cell); + player->RemoveFromGrid(); if (old_cell.DiffGrid(new_cell)) EnsureGridLoadedForActiveObject(new_cell, player); @@ -856,7 +821,7 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY()); #endif - RemoveFromGrid(c, old_cell); + c->RemoveFromGrid(); AddToGrid(c, new_cell); } else @@ -878,7 +843,7 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) sLog->outDebug(LOG_FILTER_MAPS, "Active creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); #endif - RemoveFromGrid(c, old_cell); + c->RemoveFromGrid(); AddToGrid(c, new_cell); return true; @@ -891,7 +856,7 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) sLog->outDebug(LOG_FILTER_MAPS, "Creature (GUID: %u Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); #endif - RemoveFromGrid(c, old_cell); + c->RemoveFromGrid(); EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY())); AddToGrid(c, new_cell); @@ -2275,7 +2240,7 @@ bool InstanceMap::CanEnter(Player* player) /* Do map specific checks and add the player to the map if successful. */ -bool InstanceMap::AddToMap(Player* player) +bool InstanceMap::AddPlayerToMap(Player* player) { // TODO: Not sure about checking player level: already done in HandleAreaTriggerOpcode // GMs still can teleport player in instance. @@ -2385,7 +2350,7 @@ bool InstanceMap::AddToMap(Player* player) } // this will acquire the same mutex so it cannot be in the previous block - Map::AddToMap(player); + Map::AddPlayerToMap(player); if (i_data) i_data->OnPlayerEnter(player); @@ -2401,13 +2366,13 @@ void InstanceMap::Update(const uint32 t_diff) i_data->Update(t_diff); } -void InstanceMap::RemoveFromMap(Player* player, bool remove) +void InstanceMap::RemovePlayerFromMap(Player* player, bool remove) { sLog->outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); //if last player set unload timer if (!m_unloadTimer && m_mapRefManager.getSize() == 1) m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); - Map::RemoveFromMap(player, remove); + Map::RemovePlayerFromMap(player, remove); // for normal instances schedule the reset after all players have left SetResetSchedule(true); } @@ -2486,7 +2451,7 @@ bool InstanceMap::Reset(uint8 method) return m_mapRefManager.isEmpty(); } -void InstanceMap::PermBindAllPlayers(Player* player) +void InstanceMap::PermBindAllPlayers(Player* source) { if (!IsDungeon()) return; @@ -2494,11 +2459,11 @@ void InstanceMap::PermBindAllPlayers(Player* player) InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(GetInstanceId()); 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; } - Group* group = player->GetGroup(); + Group* group = source->GetGroup(); // group members outside the instance group don't get bound for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) { @@ -2621,7 +2586,7 @@ bool BattlegroundMap::CanEnter(Player* player) return Map::CanEnter(player); } -bool BattlegroundMap::AddToMap(Player* player) +bool BattlegroundMap::AddPlayerToMap(Player* player) { { TRINITY_GUARD(ACE_Thread_Mutex, Lock); @@ -2631,13 +2596,13 @@ bool BattlegroundMap::AddToMap(Player* player) // reset instance validity, battleground maps do not homebind player->m_InstanceValid = true; } - return Map::AddToMap(player); + return Map::AddPlayerToMap(player); } -void BattlegroundMap::RemoveFromMap(Player* player, bool remove) +void BattlegroundMap::RemovePlayerFromMap(Player* player, bool remove) { sLog->outDetail("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to another map", player->GetName(), GetInstanceId(), GetMapName()); - Map::RemoveFromMap(player, remove); + Map::RemovePlayerFromMap(player, remove); } void BattlegroundMap::SetUnload() diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 053759a3ab3..9caef8457b8 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -244,8 +244,8 @@ class Map : public GridRefManager<NGridType> return false; } - virtual bool AddToMap(Player*); - virtual void RemoveFromMap(Player*, bool); + virtual bool AddPlayerToMap(Player*); + virtual void RemovePlayerFromMap(Player*, bool); template<class T> void AddToMap(T *); template<class T> void RemoveFromMap(T *, bool); @@ -526,9 +526,6 @@ class Map : public GridRefManager<NGridType> void AddToGrid(T* object, Cell const& cell); template<class T> - void RemoveFromGrid(T* object, Cell const& cell); - - template<class T> void DeleteFromWorld(T*); template<class T> @@ -570,14 +567,14 @@ class InstanceMap : public Map public: InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent); ~InstanceMap(); - bool AddToMap(Player*); - void RemoveFromMap(Player*, bool); + bool AddPlayerToMap(Player*); + void RemovePlayerFromMap(Player*, bool); void Update(const uint32); void CreateInstanceData(bool load); bool Reset(uint8 method); uint32 GetScriptId() { return i_script_id; } InstanceScript* GetInstanceScript() { return i_data; } - void PermBindAllPlayers(Player* player); + void PermBindAllPlayers(Player* source); void UnloadAll(); bool CanEnter(Player* player); void SendResetWarnings(uint32 timeLeft) const; @@ -600,8 +597,8 @@ class BattlegroundMap : public Map BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode); ~BattlegroundMap(); - bool AddToMap(Player*); - void RemoveFromMap(Player*, bool); + bool AddPlayerToMap(Player*); + void RemovePlayerFromMap(Player*, bool); bool CanEnter(Player* player); void SetUnload(); //void UnloadAll(bool pForce); diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp index bbade4c9dc3..a56a193ba64 100755 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -110,7 +110,7 @@ void MapInstanced::UnloadAll() - create the instance if it's not created already - the player is not actually added to the instance (only in InstanceMap::Add) */ -Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player) +Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player) { if (GetId() != mapId || !player) return NULL; @@ -124,7 +124,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player) // the instance id is set in battlegroundid NewInstanceId = player->GetBattlegroundId(); if (!NewInstanceId) return NULL; - map = _FindMap(NewInstanceId); + map = FindInstanceMap(NewInstanceId); if (!map) map = CreateBattleground(NewInstanceId, player->GetBattleground()); } @@ -151,7 +151,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player) { // solo/perm/group NewInstanceId = pSave->GetInstanceId(); - map = _FindMap(NewInstanceId); + map = FindInstanceMap(NewInstanceId); // it is possible that the save exists but the map doesn't if (!map) map = CreateInstance(NewInstanceId, pSave, pSave->GetDifficulty()); @@ -163,7 +163,11 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player) NewInstanceId = sMapMgr->GenerateInstanceId(); Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid()); - map = CreateInstance(NewInstanceId, NULL, diff); + //Seems it is now possible, but I do not know if it should be allowed + //ASSERT(!FindInstanceMap(NewInstanceId)); + map = FindInstanceMap(NewInstanceId); + if (!map) + map = CreateInstance(NewInstanceId, NULL, diff); } } diff --git a/src/server/game/Maps/MapInstanced.h b/src/server/game/Maps/MapInstanced.h index af303ed0e9e..9b714cb7fb3 100755 --- a/src/server/game/Maps/MapInstanced.h +++ b/src/server/game/Maps/MapInstanced.h @@ -39,8 +39,12 @@ class MapInstanced : public Map void UnloadAll(); bool CanEnter(Player* player); - Map* CreateInstance(const uint32 mapId, Player* player); - Map* FindMap(uint32 InstanceId) const { return _FindMap(InstanceId); } + Map* CreateInstanceForPlayer(const uint32 mapId, Player* player); + Map* FindInstanceMap(uint32 instanceId) const + { + InstancedMaps::const_iterator i = m_InstancedMaps.find(instanceId); + return(i == m_InstancedMaps.end() ? NULL : i->second); + } bool DestroyInstance(InstancedMaps::iterator &itr); void AddGridMapReference(const GridCoord &p) @@ -60,18 +64,11 @@ class MapInstanced : public Map virtual void InitVisibilityDistance(); private: - InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty); BattlegroundMap* CreateBattleground(uint32 InstanceId, Battleground* bg); InstancedMaps m_InstancedMaps; - Map* _FindMap(uint32 InstanceId) const - { - InstancedMaps::const_iterator i = m_InstancedMaps.find(InstanceId); - return(i == m_InstancedMaps.end() ? NULL : i->second); - } - uint16 GridMapReference[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; }; #endif diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index 78aeb32ab2d..f31f1348b44 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -95,9 +95,9 @@ void MapManager::checkAndCorrectGridStatesArray() ++i_GridStateErrorCount; } -Map* MapManager::_createBaseMap(uint32 id) +Map* MapManager::CreateBaseMap(uint32 id) { - Map* m = _findMap(id); + Map* m = FindBaseMap(id); if (m == NULL) { @@ -119,27 +119,34 @@ Map* MapManager::_createBaseMap(uint32 id) return m; } -Map* MapManager::CreateMap(uint32 id, const WorldObject* obj, uint32 /*instanceId*/) +Map* MapManager::FindBaseNonInstanceMap(uint32 mapId) const { - ASSERT(obj); - //if (!obj->IsInWorld()) sLog->outError("GetMap: called for map %d with object (typeid %d, guid %d, mapid %d, instanceid %d) who is not in world!", id, obj->GetTypeId(), obj->GetGUIDLow(), obj->GetMapId(), obj->GetInstanceId()); - Map* m = _createBaseMap(id); + Map* map = FindBaseMap(mapId); + if(map && map->Instanceable()) + return NULL; + return map; +} + +Map* MapManager::CreateMap(uint32 id, Player* player) +{ + Map* m = CreateBaseMap(id); - if (m && (obj->GetTypeId() == TYPEID_PLAYER) && m->Instanceable()) m = ((MapInstanced*)m)->CreateInstance(id, (Player*)obj); + if (m && m->Instanceable()) + m = ((MapInstanced*)m)->CreateInstanceForPlayer(id, player); return m; } Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const { - Map* map = _findMap(mapid); + Map* map = FindBaseMap(mapid); if (!map) return NULL; if (!map->Instanceable()) return instanceId == 0 ? map : NULL; - return ((MapInstanced*)map)->FindMap(instanceId); + return ((MapInstanced*)map)->FindInstanceMap(instanceId); } bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) @@ -201,8 +208,8 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) if (corpseMap == mapid) break; - InstanceTemplate const* instance = sObjectMgr->GetInstanceTemplate(corpseMap); - corpseMap = instance ? instance->Parent : 0; + InstanceTemplate const* corpseInstance = sObjectMgr->GetInstanceTemplate(corpseMap); + corpseMap = corpseInstance ? corpseInstance->Parent : 0; } while (corpseMap); if (!corpseMap) @@ -248,7 +255,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) instaceIdToCheck = save->GetInstanceId(); // instanceId can never be 0 - will not be found - if (!player->CheckInstanceCount(instaceIdToCheck)) + if (!player->CheckInstanceCount(instaceIdToCheck) && !player->isDead()) { player->SendTransferAborted(mapid, TRANSFER_ABORT_TOO_MANY_INSTANCES); return false; @@ -280,8 +287,8 @@ void MapManager::Update(uint32 diff) iter->second->DelayedUpdate(uint32(i_timer.GetCurrent())); sObjectAccessor->Update(uint32(i_timer.GetCurrent())); - for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter) - (*iter)->Update(uint32(i_timer.GetCurrent())); + for (TransportSet::iterator itr = m_Transports.begin(); itr != m_Transports.end(); ++itr) + (*itr)->Update(uint32(i_timer.GetCurrent())); i_timer.SetCurrent(0); } diff --git a/src/server/game/Maps/MapManager.h b/src/server/game/Maps/MapManager.h index 926ff2c8051..3b168a57cd5 100755 --- a/src/server/game/Maps/MapManager.h +++ b/src/server/game/Maps/MapManager.h @@ -35,14 +35,14 @@ class MapManager friend class ACE_Singleton<MapManager, ACE_Thread_Mutex>; public: - - Map* CreateMap(uint32, const WorldObject* obj, uint32 instanceId); - Map const* CreateBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_createBaseMap(id); } - Map* FindMap(uint32 mapid, uint32 instanceId = 0) const; + Map* CreateBaseMap(uint32 mapId); + Map* FindBaseNonInstanceMap(uint32 mapId) const; + Map* CreateMap(uint32 mapId, Player* player); + Map* FindMap(uint32 mapId, uint32 instanceId) const; uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const { - Map const* m = CreateBaseMap(mapid); + Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid); return m->GetAreaFlag(x, y, z); } uint32 GetAreaId(uint32 mapid, float x, float y, float z) const @@ -160,16 +160,15 @@ class MapManager MapManager(); ~MapManager(); - MapManager(const MapManager &); - MapManager& operator=(const MapManager &); - - Map* _createBaseMap(uint32 id); - Map* _findMap(uint32 id) const + Map* FindBaseMap(uint32 mapId) const { - MapMapType::const_iterator iter = i_maps.find(id); + MapMapType::const_iterator iter = i_maps.find(mapId); return (iter == i_maps.end() ? NULL : iter->second); } + MapManager(const MapManager &); + MapManager& operator=(const MapManager &); + ACE_Thread_Mutex Lock; uint32 i_gridCleanUpDelay; MapMapType i_maps; diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 1eba2fea1a2..a99d0f37c02 100755 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -2816,7 +2816,8 @@ enum DiminishingGroup DIMINISHING_SILENCE = 16, DIMINISHING_SLEEP = 17, DIMINISHING_TAUNT = 18, - DIMINISHING_LIMITONLY = 19 + DIMINISHING_LIMITONLY = 19, + DIMINISHING_DRAGONS_BREATH = 20, }; enum SummonCategory diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp index 991b03c44e4..7c3b26c2646 100755 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp @@ -29,10 +29,9 @@ #endif template<class T> -void -ConfusedMovementGenerator<T>::Initialize(T &unit) +void ConfusedMovementGenerator<T>::Initialize(T &unit) { - const float wander_distance = 11; + float const wanderDistance = 4; float x, y, z; x = unit.GetPositionX(); y = unit.GetPositionY(); @@ -47,8 +46,8 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx) { - float wanderX = x + wander_distance*(float)rand_norm() - wander_distance/2; - float wanderY = y + wander_distance*(float)rand_norm() - wander_distance/2; + float wanderX = x + wanderDistance * (float)rand_norm() - wanderDistance/2; + float wanderY = y + wanderDistance * (float)rand_norm() - wanderDistance/2; Trinity::NormalizeMapCoord(wanderX); Trinity::NormalizeMapCoord(wanderY); @@ -68,7 +67,7 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) } // Taken from FleeingMovementGenerator - if (!(new_z - z) || wander_distance / fabs(new_z - z) > 1.0f) + if (!(new_z - z) || wanderDistance / fabs(new_z - z) > 1.0f) { i_waypoints[idx][0] = wanderX; i_waypoints[idx][1] = wanderY; @@ -89,29 +88,26 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); unit.CastStop(); unit.StopMoving(); - unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); + unit.AddUnitMovementFlag(MOVEMENTFLAG_WALKING); // Should actually be splineflag unit.AddUnitState(UNIT_STAT_CONFUSED); } template<> -void -ConfusedMovementGenerator<Creature>::_InitSpecific(Creature &creature, bool &is_water_ok, bool &is_land_ok) +void ConfusedMovementGenerator<Creature>::_InitSpecific(Creature &creature, bool &is_water_ok, bool &is_land_ok) { is_water_ok = creature.canSwim(); is_land_ok = creature.canWalk(); } template<> -void -ConfusedMovementGenerator<Player>::_InitSpecific(Player &, bool &is_water_ok, bool &is_land_ok) +void ConfusedMovementGenerator<Player>::_InitSpecific(Player &, bool &is_water_ok, bool &is_land_ok) { is_water_ok = true; is_land_ok = true; } template<class T> -void -ConfusedMovementGenerator<T>::Reset(T &unit) +void ConfusedMovementGenerator<T>::Reset(T &unit) { i_nextMove = 1; i_nextMoveTime.Reset(0); @@ -120,8 +116,7 @@ ConfusedMovementGenerator<T>::Reset(T &unit) } template<class T> -bool -ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff) +bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff) { if (!&unit) return true; @@ -141,7 +136,7 @@ ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff) unit.ClearUnitState(UNIT_STAT_MOVE); i_nextMove = urand(1, MAX_CONF_WAYPOINTS); - i_nextMoveTime.Reset(urand(0, 1500-1)); // TODO: check the minimum reset time, should be probably higher + i_nextMoveTime.Reset(urand(100, 1000)); } } } @@ -164,11 +159,11 @@ ConfusedMovementGenerator<T>::Update(T &unit, const uint32 diff) } template<class T> -void -ConfusedMovementGenerator<T>::Finalize(T &unit) +void ConfusedMovementGenerator<T>::Finalize(T &unit) { unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); unit.ClearUnitState(UNIT_STAT_CONFUSED); + if (unit.GetTypeId() == TYPEID_UNIT && unit.getVictim()) unit.SetTarget(unit.getVictim()->GetGUID()); } diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index 808d8318ea9..396b0c489f2 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -351,7 +351,7 @@ void FlightPathMovementGenerator::InitEndGridInfo() void FlightPathMovementGenerator::PreloadEndGrid() { // used to preload the final grid where the flightmaster is - Map* endMap = sMapMgr->FindMap(m_endMapId); + Map* endMap = sMapMgr->FindBaseNonInstanceMap(m_endMapId); // Load the grid if (endMap) diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index bbef60aa5e7..bd8840ff8a8 100755 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -359,7 +359,7 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj) sObjectMgr->AddCreatureToGrid(obj->guid, data); // Spawn if necessary (loaded grids only) - Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid)); + Map* map = sMapMgr->CreateBaseMap(data->mapid); // We use spawn coords to spawn if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { @@ -385,7 +385,7 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj) sObjectMgr->AddGameobjectToGrid(obj->guid, data); // Spawn if necessary (loaded grids only) // this base map checked as non-instanced and then only existed - Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(data->mapid)); + Map* map = sMapMgr->CreateBaseMap(data->mapid); // We use current coords to unspawn, not spawn coords since creature can have changed grid if (!map->Instanceable() && map->IsGridLoaded(data->posX, data->posY)) { diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index 9650afb60e2..29bd95a73a3 100755 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -22,127 +22,132 @@ Quest::Quest(Field* questRecord) { - QuestId = questRecord[0].GetUInt32(); - QuestMethod = questRecord[1].GetUInt32(); - ZoneOrSort = questRecord[2].GetInt32(); - SkillOrClassMask = questRecord[3].GetInt32(); - MinLevel = questRecord[4].GetUInt32(); - MaxLevel = questRecord[5].GetUInt32(); - QuestLevel = questRecord[6].GetInt32(); - Type = questRecord[7].GetUInt32(); - RequiredRaces = questRecord[8].GetUInt32(); - RequiredSkillValue = questRecord[9].GetUInt32(); - RepObjectiveFaction = questRecord[10].GetUInt32(); - RepObjectiveValue = questRecord[11].GetInt32(); - RepObjectiveFaction2 = questRecord[12].GetUInt32(); - RepObjectiveValue2 = questRecord[13].GetInt32(); - RequiredMinRepFaction = questRecord[14].GetUInt32(); - RequiredMinRepValue = questRecord[15].GetInt32(); - RequiredMaxRepFaction = questRecord[16].GetUInt32(); - RequiredMaxRepValue = questRecord[17].GetInt32(); - SuggestedPlayers = questRecord[18].GetUInt32(); - LimitTime = questRecord[19].GetUInt32(); - QuestFlags = questRecord[20].GetUInt32(); - uint32 SpecialFlags = questRecord[21].GetUInt16(); - CharTitleId = questRecord[22].GetUInt32(); - PlayersSlain = questRecord[23].GetUInt32(); - BonusTalents = questRecord[24].GetUInt32(); - RewArenaPoints = questRecord[25].GetInt32(); - PrevQuestId = questRecord[26].GetInt32(); - NextQuestId = questRecord[27].GetInt32(); - ExclusiveGroup = questRecord[28].GetInt32(); - NextQuestInChain = questRecord[29].GetUInt32(); - XPId = questRecord[30].GetUInt32(); - SrcItemId = questRecord[31].GetUInt32(); - SrcItemCount = questRecord[32].GetUInt32(); - SrcSpell = questRecord[33].GetUInt32(); - Title = questRecord[34].GetString(); - Details = questRecord[35].GetString(); - Objectives = questRecord[36].GetString(); - OfferRewardText = questRecord[37].GetString(); - RequestItemsText = questRecord[38].GetString(); - EndText = questRecord[39].GetString(); - CompletedText = questRecord[40].GetString(); + Id = questRecord[0].GetUInt32(); + Method = questRecord[1].GetUInt32(); + Level = questRecord[2].GetInt32(); + MinLevel = questRecord[3].GetUInt32(); + MaxLevel = questRecord[4].GetUInt32(); + ZoneOrSort = questRecord[5].GetInt32(); + Type = questRecord[6].GetUInt32(); + SuggestedPlayers = questRecord[7].GetUInt32(); + LimitTime = questRecord[8].GetUInt32(); + RequiredClasses = questRecord[9].GetUInt32(); + RequiredRaces = questRecord[10].GetUInt32(); + RequiredSkillId = questRecord[11].GetUInt32(); + RequiredSkillPoints = questRecord[12].GetUInt32(); + RequiredFactionId1 = questRecord[13].GetUInt32(); + RequiredFactionId2 = questRecord[14].GetUInt32(); + RequiredFactionValue1 = questRecord[15].GetInt32(); + RequiredFactionValue2 = questRecord[16].GetInt32(); + RequiredMinRepFaction = questRecord[17].GetUInt32(); + RequiredMaxRepFaction = questRecord[18].GetUInt32(); + RequiredMinRepValue = questRecord[19].GetInt32(); + RequiredMaxRepValue = questRecord[20].GetInt32(); + PrevQuestId = questRecord[21].GetInt32(); + NextQuestId = questRecord[22].GetInt32(); + ExclusiveGroup = questRecord[23].GetInt32(); + NextQuestIdChain = questRecord[24].GetUInt32(); + RewardXPId = questRecord[25].GetUInt32(); + RewardOrRequiredMoney = questRecord[26].GetInt32(); + RewardMoneyMaxLevel = questRecord[27].GetUInt32(); + RewardSpell = questRecord[28].GetUInt32(); + RewardSpellCast = questRecord[29].GetInt32(); + RewardHonor = questRecord[30].GetUInt32(); + RewardHonorMultiplier = questRecord[31].GetFloat(); + RewardMailTemplateId = questRecord[32].GetUInt32(); + RewardMailDelay = questRecord[33].GetUInt32(); + SourceItemId = questRecord[34].GetUInt32(); + SourceItemIdCount = questRecord[35].GetUInt32(); + SourceSpellid = questRecord[36].GetUInt32(); + Flags = questRecord[37].GetUInt32(); + uint32 SpecialFlags = questRecord[38].GetUInt16(); + RewardTitleId = questRecord[39].GetUInt32(); + RequiredPlayerKills = questRecord[40].GetUInt32(); + RewardTalents = questRecord[41].GetUInt32(); + RewardArenaPoints = questRecord[42].GetInt32(); - for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ObjectiveText[i] = questRecord[41+i].GetString(); + for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) + RewardItemId[i] = questRecord[43+i].GetUInt32(); - for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) - ReqItemId[i] = questRecord[45+i].GetUInt32(); + for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) + RewardItemIdCount[i] = questRecord[47+i].GetUInt32(); - for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) - ReqItemCount[i] = questRecord[51+i].GetUInt32(); + for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) + RewardChoiceItemId[i] = questRecord[51+i].GetUInt32(); - for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - ReqSourceId[i] = questRecord[57+i].GetUInt32(); + for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) + RewardChoiceItemCount[i] = questRecord[57+i].GetUInt32(); + + for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) + RewardFactionId[i] = questRecord[63+i].GetUInt32(); - for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - ReqSourceCount[i] = questRecord[61+i].GetUInt32(); + for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) + RewardFactionValueId[i] = questRecord[68+i].GetInt32(); - for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ReqCreatureOrGOId[i] = questRecord[65+i].GetInt32(); + for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) + RewardFactionValueIdOverride[i] = questRecord[73+i].GetInt32(); + + PointMapId = questRecord[78].GetUInt32(); + PointX = questRecord[79].GetFloat(); + PointY = questRecord[80].GetFloat(); + PointOption = questRecord[81].GetUInt32(); + Title = questRecord[82].GetString(); + Objectives = questRecord[83].GetString(); + Details = questRecord[84].GetString(); + EndText = questRecord[85].GetString(); + OfferRewardText = questRecord[86].GetString(); + RequestItemsText = questRecord[87].GetString(); + CompletedText = questRecord[88].GetString(); for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ReqCreatureOrGOCount[i] = questRecord[69+i].GetUInt32(); + RequiredNpcOrGo[i] = questRecord[89+i].GetInt32(); for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ReqSpell[i] = questRecord[73+i].GetUInt32(); + RequiredNpcOrGoCount[i] = questRecord[93+i].GetUInt32(); - for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) - RewChoiceItemId[i] = questRecord[77+i].GetUInt32(); + for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) + RequiredSourceItemid[i] = questRecord[97+i].GetUInt32(); - for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) - RewChoiceItemCount[i] = questRecord[83+i].GetUInt32(); + for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) + RequiredSourceItemId[i] = questRecord[101+i].GetUInt32(); - for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) - RewItemId[i] = questRecord[89+i].GetUInt32(); + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + RequiredItemId[i] = questRecord[105+i].GetUInt32(); - for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) - RewItemCount[i] = questRecord[93+i].GetUInt32(); + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + RequiredItemCount[i] = questRecord[111+i].GetUInt32(); - for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - RewRepFaction[i] = questRecord[97+i].GetUInt32(); + for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + RequiredSpellCast[i] = questRecord[117+i].GetUInt32(); - for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - RewRepValueId[i] = questRecord[102+i].GetInt32(); + // int8 Unknown0 = questRecord[121].GetUInt32(); - for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - RewRepValue[i] = questRecord[107+i].GetInt32(); - - RewHonorAddition = questRecord[112].GetUInt32(); - RewHonorMultiplier = questRecord[113].GetFloat(); - RewOrReqMoney = questRecord[114].GetInt32(); - RewMoneyMaxLevel = questRecord[115].GetUInt32(); - RewSpell = questRecord[116].GetUInt32(); - RewSpellCast = questRecord[117].GetInt32(); - RewMailTemplateId = questRecord[118].GetUInt32(); - RewMailDelaySecs = questRecord[119].GetUInt32(); - PointMapId = questRecord[120].GetUInt32(); - PointX = questRecord[121].GetFloat(); - PointY = questRecord[122].GetFloat(); - PointOpt = questRecord[123].GetUInt32(); + for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + ObjectiveText[i] = questRecord[122+i].GetString(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - DetailsEmote[i] = questRecord[124+i].GetUInt32(); + DetailsEmote[i] = questRecord[126+i].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - DetailsEmoteDelay[i] = questRecord[128+i].GetUInt32(); + DetailsEmoteDelay[i] = questRecord[130+i].GetUInt32(); - IncompleteEmote = questRecord[132].GetUInt32(); - CompleteEmote = questRecord[133].GetUInt32(); + EmoteOnIncomplete = questRecord[134].GetUInt32(); + EmoteOnComplete = questRecord[135].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - OfferRewardEmote[i] = questRecord[134+i].GetInt32(); + OfferRewardEmote[i] = questRecord[136+i].GetInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - OfferRewardEmoteDelay[i] = questRecord[138+i].GetInt32(); + OfferRewardEmoteDelay[i] = questRecord[140+i].GetInt32(); + + StartScript = questRecord[144].GetUInt32(); + CompleteScript = questRecord[145].GetUInt32(); - QuestStartScript = questRecord[142].GetUInt32(); - QuestCompleteScript = questRecord[143].GetUInt32(); + // int32 WDBVerified = questRecord[146].GetInt32(); - QuestFlags |= SpecialFlags << 20; - if (QuestFlags & QUEST_TRINITY_FLAGS_AUTO_ACCEPT) - QuestFlags |= QUEST_FLAGS_AUTO_ACCEPT; + Flags |= SpecialFlags << 20; + if (Flags & QUEST_TRINITY_FLAGS_AUTO_ACCEPT) + Flags |= QUEST_FLAGS_AUTO_ACCEPT; m_reqitemscount = 0; m_reqCreatureOrGOcount = 0; @@ -150,19 +155,19 @@ Quest::Quest(Field* questRecord) m_rewchoiceitemscount = 0; for (int i=0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) - if (ReqItemId[i]) + if (RequiredItemId[i]) ++m_reqitemscount; for (int i=0; i < QUEST_OBJECTIVES_COUNT; ++i) - if (ReqCreatureOrGOId[i]) + if (RequiredNpcOrGo[i]) ++m_reqCreatureOrGOcount; for (int i=0; i < QUEST_REWARDS_COUNT; ++i) - if (RewItemId[i]) + if (RewardItemId[i]) ++m_rewitemscount; for (int i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i) - if (RewChoiceItemId[i]) + if (RewardChoiceItemId[i]) ++m_rewchoiceitemscount; } @@ -170,7 +175,7 @@ uint32 Quest::XPValue(Player* player) const { if (player) { - int32 quest_level = (QuestLevel == -1 ? player->getLevel() : QuestLevel); + int32 quest_level = (Level == -1 ? player->getLevel() : Level); const QuestXPEntry* xpentry = sQuestXPStore.LookupEntry(quest_level); if (!xpentry) return 0; @@ -181,7 +186,7 @@ uint32 Quest::XPValue(Player* player) const else if (diffFactor > 10) diffFactor = 10; - uint32 xp = diffFactor * xpentry->Exp[XPId] / 10; + uint32 xp = diffFactor * xpentry->Exp[RewardXPId] / 10; if (xp <= 100) xp = 5 * ((xp + 2) / 5); else if (xp <= 500) @@ -199,15 +204,15 @@ uint32 Quest::XPValue(Player* player) const int32 Quest::GetRewOrReqMoney() const { - if (RewOrReqMoney <= 0) - return RewOrReqMoney; + if (RewardOrRequiredMoney <= 0) + return RewardOrRequiredMoney; - return int32(RewOrReqMoney * sWorld->getRate(RATE_DROP_MONEY)); + return int32(RewardOrRequiredMoney * sWorld->getRate(RATE_DROP_MONEY)); } bool Quest::IsAutoComplete() const { - return QuestMethod == 0 || HasFlag(QUEST_FLAGS_AUTOCOMPLETE); + return Method == 0 || HasFlag(QUEST_FLAGS_AUTOCOMPLETE); } bool Quest::IsAllowedInRaid() const diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 90e52660160..fc9a432a11b 100755 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -141,7 +141,7 @@ enum __QuestFlags QUEST_FLAGS_UNAVAILABLE = 0x00004000, // Used on quests that are not generically available QUEST_FLAGS_WEEKLY = 0x00008000, QUEST_FLAGS_AUTOCOMPLETE = 0x00010000, // auto complete - QUEST_FLAGS_SPECIAL_ITEM = 0x00020000, // has something to do with ReqItemId and SrcItemId + QUEST_FLAGS_SPECIAL_ITEM = 0x00020000, // has something to do with RequiredItemId and SourceItemId QUEST_FLAGS_OBJ_TEXT = 0x00040000, // use Objective text as Complete text QUEST_FLAGS_AUTO_ACCEPT = 0x00080000, // The client recognizes this flag as auto-accept. However, NONE of the current quests (3.3.5a) have this flag. Maybe blizz used to use it, or will use it in the future. @@ -185,24 +185,25 @@ class Quest Quest(Field* questRecord); uint32 XPValue(Player* player) const; - bool HasFlag(uint32 flag) const { return (QuestFlags & flag) != 0; } - void SetFlag(uint32 flag) { QuestFlags |= flag; } + bool HasFlag(uint32 flag) const { return (Flags & flag) != 0; } + void SetFlag(uint32 flag) { Flags |= flag; } // table data accessors: - uint32 GetQuestId() const { return QuestId; } - uint32 GetQuestMethod() const { return QuestMethod; } + uint32 GetQuestId() const { return Id; } + uint32 GetQuestMethod() const { return Method; } int32 GetZoneOrSort() const { return ZoneOrSort; } - int32 GetSkillOrClassMask() const { return SkillOrClassMask; } uint32 GetMinLevel() const { return MinLevel; } uint32 GetMaxLevel() const { return MaxLevel; } - uint32 GetQuestLevel() const { return QuestLevel; } + uint32 GetQuestLevel() const { return Level; } uint32 GetType() const { return Type; } + uint32 GetRequiredClasses() const { return RequiredClasses; } uint32 GetRequiredRaces() const { return RequiredRaces; } - uint32 GetRequiredSkillValue() const { return RequiredSkillValue; } - uint32 GetRepObjectiveFaction() const { return RepObjectiveFaction; } - int32 GetRepObjectiveValue() const { return RepObjectiveValue; } - uint32 GetRepObjectiveFaction2() const { return RepObjectiveFaction2; } - int32 GetRepObjectiveValue2() const { return RepObjectiveValue2; } + uint32 GetRequiredSkill() const { return RequiredSkillId; } + uint32 GetRequiredSkillValue() const { return RequiredSkillPoints; } + uint32 GetRepObjectiveFaction() const { return RequiredFactionId1; } + int32 GetRepObjectiveValue() const { return RequiredFactionValue1; } + uint32 GetRepObjectiveFaction2() const { return RequiredFactionId2; } + int32 GetRepObjectiveValue2() const { return RequiredFactionValue2; } uint32 GetRequiredMinRepFaction() const { return RequiredMinRepFaction; } int32 GetRequiredMinRepValue() const { return RequiredMinRepValue; } uint32 GetRequiredMaxRepFaction() const { return RequiredMaxRepFaction; } @@ -212,15 +213,15 @@ class Quest int32 GetPrevQuestId() const { return PrevQuestId; } int32 GetNextQuestId() const { return NextQuestId; } int32 GetExclusiveGroup() const { return ExclusiveGroup; } - uint32 GetNextQuestInChain() const { return NextQuestInChain; } - uint32 GetCharTitleId() const { return CharTitleId; } - uint32 GetPlayersSlain() const { return PlayersSlain; } - uint32 GetBonusTalents() const { return BonusTalents; } - int32 GetRewArenaPoints() const {return RewArenaPoints; } - uint32 GetXPId() const { return XPId; } - uint32 GetSrcItemId() const { return SrcItemId; } - uint32 GetSrcItemCount() const { return SrcItemCount; } - uint32 GetSrcSpell() const { return SrcSpell; } + uint32 GetNextQuestInChain() const { return NextQuestIdChain; } + uint32 GetCharTitleId() const { return RewardTitleId; } + uint32 GetPlayersSlain() const { return RequiredPlayerKills; } + uint32 GetBonusTalents() const { return RewardTalents; } + int32 GetRewArenaPoints() const {return RewardArenaPoints; } + uint32 GetXPId() const { return RewardXPId; } + uint32 GetSrcItemId() const { return SourceItemId; } + uint32 GetSrcItemCount() const { return SourceItemIdCount; } + uint32 GetSrcSpell() const { return SourceSpellid; } std::string GetTitle() const { return Title; } std::string GetDetails() const { return Details; } std::string GetObjectives() const { return Objectives; } @@ -229,50 +230,50 @@ class Quest std::string GetEndText() const { return EndText; } std::string GetCompletedText() const { return CompletedText; } int32 GetRewOrReqMoney() const; - uint32 GetRewHonorAddition() const { return RewHonorAddition; } - float GetRewHonorMultiplier() const { return RewHonorMultiplier; } - uint32 GetRewMoneyMaxLevel() const { return RewMoneyMaxLevel; } + uint32 GetRewHonorAddition() const { return RewardHonor; } + float GetRewHonorMultiplier() const { return RewardHonorMultiplier; } + uint32 GetRewMoneyMaxLevel() const { return RewardMoneyMaxLevel; } // use in XP calculation at client - uint32 GetRewSpell() const { return RewSpell; } - int32 GetRewSpellCast() const { return RewSpellCast; } - uint32 GetRewMailTemplateId() const { return RewMailTemplateId; } - uint32 GetRewMailDelaySecs() const { return RewMailDelaySecs; } + uint32 GetRewSpell() const { return RewardSpell; } + int32 GetRewSpellCast() const { return RewardSpellCast; } + uint32 GetRewMailTemplateId() const { return RewardMailTemplateId; } + uint32 GetRewMailDelaySecs() const { return RewardMailDelay; } uint32 GetPointMapId() const { return PointMapId; } float GetPointX() const { return PointX; } float GetPointY() const { return PointY; } - uint32 GetPointOpt() const { return PointOpt; } - uint32 GetIncompleteEmote() const { return IncompleteEmote; } - uint32 GetCompleteEmote() const { return CompleteEmote; } - uint32 GetQuestStartScript() const { return QuestStartScript; } - uint32 GetQuestCompleteScript() const { return QuestCompleteScript; } - bool IsRepeatable() const { return QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE; } + uint32 GetPointOpt() const { return PointOption; } + uint32 GetIncompleteEmote() const { return EmoteOnIncomplete; } + uint32 GetCompleteEmote() const { return EmoteOnComplete; } + uint32 GetQuestStartScript() const { return StartScript; } + uint32 GetQuestCompleteScript() const { return CompleteScript; } + bool IsRepeatable() const { return Flags & QUEST_TRINITY_FLAGS_REPEATABLE; } bool IsAutoComplete() const; - uint32 GetFlags() const { return QuestFlags; } - bool IsDaily() const { return QuestFlags & QUEST_FLAGS_DAILY; } - bool IsWeekly() const { return QuestFlags & QUEST_FLAGS_WEEKLY; } - bool IsDailyOrWeekly() const { return QuestFlags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY); } - bool IsAutoAccept() const { return QuestFlags & QUEST_FLAGS_AUTO_ACCEPT; } + uint32 GetFlags() const { return Flags; } + bool IsDaily() const { return Flags & QUEST_FLAGS_DAILY; } + bool IsWeekly() const { return Flags & QUEST_FLAGS_WEEKLY; } + bool IsDailyOrWeekly() const { return Flags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY); } + bool IsAutoAccept() const { return Flags & QUEST_FLAGS_AUTO_ACCEPT; } bool IsRaidQuest() const { return Type == QUEST_TYPE_RAID || Type == QUEST_TYPE_RAID_10 || Type == QUEST_TYPE_RAID_25; } bool IsAllowedInRaid() const; - bool IsDFQuest() const { return QuestFlags & QUEST_TRINITY_FLAGS_DF_QUEST; } + bool IsDFQuest() const { return Flags & QUEST_TRINITY_FLAGS_DF_QUEST; } uint32 CalculateHonorGain(uint8 level) const; // multiple values std::string ObjectiveText[QUEST_OBJECTIVES_COUNT]; - uint32 ReqItemId[QUEST_ITEM_OBJECTIVES_COUNT]; - uint32 ReqItemCount[QUEST_ITEM_OBJECTIVES_COUNT]; - uint32 ReqSourceId[QUEST_SOURCE_ITEM_IDS_COUNT]; - uint32 ReqSourceCount[QUEST_SOURCE_ITEM_IDS_COUNT]; - int32 ReqCreatureOrGOId[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject - uint32 ReqCreatureOrGOCount[QUEST_OBJECTIVES_COUNT]; - uint32 ReqSpell[QUEST_OBJECTIVES_COUNT]; - uint32 RewChoiceItemId[QUEST_REWARD_CHOICES_COUNT]; - uint32 RewChoiceItemCount[QUEST_REWARD_CHOICES_COUNT]; - uint32 RewItemId[QUEST_REWARDS_COUNT]; - uint32 RewItemCount[QUEST_REWARDS_COUNT]; - uint32 RewRepFaction[QUEST_REPUTATIONS_COUNT]; - int32 RewRepValueId[QUEST_REPUTATIONS_COUNT]; - int32 RewRepValue[QUEST_REPUTATIONS_COUNT]; + uint32 RequiredItemId[QUEST_ITEM_OBJECTIVES_COUNT]; + uint32 RequiredItemCount[QUEST_ITEM_OBJECTIVES_COUNT]; + uint32 RequiredSourceItemid[QUEST_SOURCE_ITEM_IDS_COUNT]; + uint32 RequiredSourceItemId[QUEST_SOURCE_ITEM_IDS_COUNT]; + int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject + uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]; + uint32 RequiredSpellCast[QUEST_OBJECTIVES_COUNT]; + uint32 RewardChoiceItemId[QUEST_REWARD_CHOICES_COUNT]; + uint32 RewardChoiceItemCount[QUEST_REWARD_CHOICES_COUNT]; + uint32 RewardItemId[QUEST_REWARDS_COUNT]; + uint32 RewardItemIdCount[QUEST_REWARDS_COUNT]; + uint32 RewardFactionId[QUEST_REPUTATIONS_COUNT]; + int32 RewardFactionValueId[QUEST_REPUTATIONS_COUNT]; + int32 RewardFactionValueIdOverride[QUEST_REPUTATIONS_COUNT]; uint32 DetailsEmote[QUEST_EMOTE_COUNT]; uint32 DetailsEmoteDelay[QUEST_EMOTE_COUNT]; uint32 OfferRewardEmote[QUEST_EMOTE_COUNT]; @@ -297,39 +298,40 @@ class Quest // table data protected: - uint32 QuestId; - uint32 QuestMethod; + uint32 Id; + uint32 Method; int32 ZoneOrSort; - int32 SkillOrClassMask; uint32 MinLevel; uint32 MaxLevel; - int32 QuestLevel; + int32 Level; uint32 Type; + uint32 RequiredClasses; uint32 RequiredRaces; - uint32 RequiredSkillValue; - uint32 RepObjectiveFaction; - int32 RepObjectiveValue; - uint32 RepObjectiveFaction2; - int32 RepObjectiveValue2; + uint32 RequiredSkillId; + uint32 RequiredSkillPoints; + uint32 RequiredFactionId1; + int32 RequiredFactionValue1; + uint32 RequiredFactionId2; + int32 RequiredFactionValue2; uint32 RequiredMinRepFaction; int32 RequiredMinRepValue; uint32 RequiredMaxRepFaction; int32 RequiredMaxRepValue; uint32 SuggestedPlayers; uint32 LimitTime; - uint32 QuestFlags; - uint32 CharTitleId; - uint32 PlayersSlain; - uint32 BonusTalents; - int32 RewArenaPoints; + uint32 Flags; + uint32 RewardTitleId; + uint32 RequiredPlayerKills; + uint32 RewardTalents; + int32 RewardArenaPoints; int32 PrevQuestId; int32 NextQuestId; int32 ExclusiveGroup; - uint32 NextQuestInChain; - uint32 XPId; - uint32 SrcItemId; - uint32 SrcItemCount; - uint32 SrcSpell; + uint32 NextQuestIdChain; + uint32 RewardXPId; + uint32 SourceItemId; + uint32 SourceItemIdCount; + uint32 SourceSpellid; std::string Title; std::string Details; std::string Objectives; @@ -337,22 +339,22 @@ class Quest std::string RequestItemsText; std::string EndText; std::string CompletedText; - uint32 RewHonorAddition; - float RewHonorMultiplier; - int32 RewOrReqMoney; - uint32 RewMoneyMaxLevel; - uint32 RewSpell; - int32 RewSpellCast; - uint32 RewMailTemplateId; - uint32 RewMailDelaySecs; + uint32 RewardHonor; + float RewardHonorMultiplier; + int32 RewardOrRequiredMoney; + uint32 RewardMoneyMaxLevel; + uint32 RewardSpell; + int32 RewardSpellCast; + uint32 RewardMailTemplateId; + uint32 RewardMailDelay; uint32 PointMapId; float PointX; float PointY; - uint32 PointOpt; - uint32 IncompleteEmote; - uint32 CompleteEmote; - uint32 QuestStartScript; - uint32 QuestCompleteScript; + uint32 PointOption; + uint32 EmoteOnIncomplete; + uint32 EmoteOnComplete; + uint32 StartScript; + uint32 CompleteScript; }; struct QuestStatusData diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 88c9795e896..4236ef49212 100755 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -321,11 +321,11 @@ void Map::ScriptsProcess() source = HashMapHolder<Corpse>::Find(step.sourceGUID); break; 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; } } diff --git a/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp b/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp index 9bbf98ce3fc..c7299eb0caa 100755 --- a/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/AddonHandler.cpp @@ -107,9 +107,9 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target) *Target << uint8(unk1); if (unk1) { - uint8 unk2 = (crc != 0x4c1c776d); // If addon is Standard addon CRC - *Target << uint8(unk2); - if (unk2) + uint8 unk = (crc != 0x4c1c776d); // If addon is Standard addon CRC + *Target << uint8(unk); + if (unk) Target->append(tdata, sizeof(tdata)); *Target << uint32(0); diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp index a468d05bcdf..83b9ab048ad 100755 --- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp @@ -658,7 +658,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte newChar.SetAtLoginFlag(AT_LOGIN_FIRST); // First login // Player created, save it now - newChar.SaveToDB(); + newChar.SaveToDB(true); createInfo->CharCount += 1; SQLTransaction trans = LoginDatabase.BeginTransaction(); @@ -920,7 +920,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) } } - if (!pCurrChar->GetMap()->AddToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) + if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid()) { AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId()); if (at) @@ -1170,6 +1170,8 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult result, std: data << uint64(guid); data << newname; SendPacket(&data); + + sWorld->UpdateCharacterNameData(guidLow, newname); } void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data) @@ -1407,9 +1409,9 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data) } 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(); 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()); } @@ -1634,7 +1636,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) SQLTransaction trans = CharacterDatabase.BeginTransaction(); trans->PAppend("UPDATE `characters` SET name='%s', race='%u', at_login=at_login & ~ %u WHERE guid='%u'", newname.c_str(), race, used_loginFlag, lowGuid); trans->PAppend("DELETE FROM character_declinedname WHERE guid ='%u'", lowGuid); - sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender, race); + sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender, race); BattlegroundTeamId team = BG_TEAM_ALLIANCE; diff --git a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp index 1ff1181bc6a..3df59b9bba1 100755 --- a/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/LFGHandler.cpp @@ -205,14 +205,14 @@ void WorldSession::HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& /*recv_data ItemTemplate const* iProto = NULL; for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i) { - if (!qRew->RewItemId[i]) + if (!qRew->RewardItemId[i]) continue; - iProto = sObjectMgr->GetItemTemplate(qRew->RewItemId[i]); + iProto = sObjectMgr->GetItemTemplate(qRew->RewardItemId[i]); - data << uint32(qRew->RewItemId[i]); + data << uint32(qRew->RewardItemId[i]); data << uint32(iProto ? iProto->DisplayInfoID : 0); - data << uint32(qRew->RewItemCount[i]); + data << uint32(qRew->RewardItemIdCount[i]); } } } @@ -495,14 +495,14 @@ void WorldSession::SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntr ItemTemplate const* iProto = NULL; for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i) { - if (!qRew->RewItemId[i]) + if (!qRew->RewardItemId[i]) continue; - iProto = sObjectMgr->GetItemTemplate(qRew->RewItemId[i]); + iProto = sObjectMgr->GetItemTemplate(qRew->RewardItemId[i]); - data << uint32(qRew->RewItemId[i]); + data << uint32(qRew->RewardItemId[i]); data << uint32(iProto ? iProto->DisplayInfoID : 0); - data << uint32(qRew->RewItemCount[i]); + data << uint32(qRew->RewardItemIdCount[i]); } } SendPacket(&data); diff --git a/src/server/game/Server/Protocol/Handlers/MailHandler.cpp b/src/server/game/Server/Protocol/Handlers/MailHandler.cpp index 785fcdbf067..2dee8e3ae15 100755 --- a/src/server/game/Server/Protocol/Handlers/MailHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MailHandler.cpp @@ -596,11 +596,11 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data) data << uint32(0); // probably changed in 3.3.3 data << uint32((*itr)->stationery); // stationery (Stationery.dbc) data << uint32((*itr)->money); // Gold - data << uint32((*itr)->checked); // flags + data << uint32((*itr)->checked); // flags data << float(((*itr)->expire_time-time(NULL))/DAY); // Time data << uint32((*itr)->mailTemplateId); // mail template (MailTemplate.dbc) - data << (*itr)->subject; // Subject string - once 00, when mail type = 3, max 256 - data << (*itr)->body; // message? max 8000 + data << (*itr)->subject; // Subject string - once 00, when mail type = 3, max 256 + data << (*itr)->body; // message? max 8000 data << uint8(item_count); // client limit is 0x10 for (uint8 i = 0; i < item_count; ++i) diff --git a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp index 0e96d22310d..4e45eb2d6c6 100755 --- a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp @@ -68,11 +68,11 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (GetPlayer()->IsInWorld()) { sLog->outCrash("Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName(), oldMap->GetId(), loc.GetMapId()); - oldMap->RemoveFromMap(GetPlayer(), false); + oldMap->RemovePlayerFromMap(GetPlayer(), false); } // relocate the player to the teleport destination - Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer(), 0); + Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer()); // the CanEnter checks are done in TeleporTo but conditions may change // while the player is in transit, for example the map may get full if (!newMap || !newMap->CanEnter(GetPlayer())) @@ -88,7 +88,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SetMap(newMap); GetPlayer()->SendInitialPacketsBeforeAddToMap(); - if (!GetPlayer()->GetMap()->AddToMap(GetPlayer())) + if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer())) { sLog->outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId()); GetPlayer()->ResetMap(); diff --git a/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp b/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp index fbd6c23d20f..e0bcadc89e9 100755 --- a/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/QuestHandler.cpp @@ -200,7 +200,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data) bool destroyItem = true; for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { - if ((qInfo->ReqItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetTemplate()->MaxCount > 0)) + if ((qInfo->RequiredItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetTemplate()->MaxCount > 0)) { destroyItem = false; break; diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index df7816f7cb9..311a94d4217 100755 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -1329,7 +1329,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x514*/ { "SMSG_SEND_ALL_COMBAT_LOG", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x515*/ { "SMSG_OPEN_LFG_DUNGEON_FINDER", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x516*/ { "SMSG_MOVE_SET_COLLISION_HGT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x517*/ { "CMSG_MOVE_SET_COLLISION_HGT_ACK", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x517*/ { "CMSG_MOVE_SET_COLLISION_HGT_ACK", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x518*/ { "MSG_MOVE_SET_COLLISION_HGT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x519*/ { "CMSG_CLEAR_RANDOM_BG_WIN_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x51A*/ { "CMSG_CLEAR_HOLIDAY_BG_WIN_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index dccb320328d..14c86286718 100755 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -494,7 +494,7 @@ void WorldSession::LogoutPlayer(bool Save) _player->CleanupsBeforeDelete(); sLog->outChar("Account: %d (IP: %s) Logout Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName(), _player->GetGUIDLow()); Map* _map = _player->GetMap(); - _map->RemoveFromMap(_player, true); + _map->RemovePlayerFromMap(_player, true); SetPlayer(NULL); // deleted in Remove call ///- Send the 'logout complete' packet to the client diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 152f94ad420..c4487fbd950 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -563,10 +563,10 @@ int32 AuraEffect::CalculateAmount(Unit* caster) amount += (int32)DoneActualBenefit; // Arena - Dampening - if (AuraEffect const* pAurEff = caster->GetAuraEffect(74410, 0)) - AddPctN(amount, pAurEff->GetAmount()); - // Battleground - Dampening - else if (AuraEffect const* pAurEff = caster->GetAuraEffect(74411, 0)) + AuraEffect const* pAurEff = caster->GetAuraEffect(74410, 0); + if (!pAurEff) + pAurEff = caster->GetAuraEffect(74411, 0); // Battleground - Dampening + if (pAurEff) AddPctN(amount, pAurEff->GetAmount()); return amount; @@ -1508,15 +1508,15 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const // Nurturing Instinct 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()) { - case 33872: - spellId = 47179; - break; - case 33873: - spellId = 47180; - break; + case 33872: + spellId3 = 47179; + break; + case 33873: + spellId3 = 47180; + break; } target->CastSpell(target, spellId, true, NULL, this); } @@ -4892,8 +4892,8 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool // Living Bomb if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) { - AuraRemoveMode mode = aurApp->GetRemoveMode(); - if (caster && (mode == AURA_REMOVE_BY_ENEMY_SPELL || mode == AURA_REMOVE_BY_EXPIRE)) + AuraRemoveMode removeMode = aurApp->GetRemoveMode(); + if (caster && (removeMode == AURA_REMOVE_BY_ENEMY_SPELL || removeMode == AURA_REMOVE_BY_EXPIRE)) caster->CastSpell(target, GetAmount(), true); } break; @@ -6019,13 +6019,15 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) case 65923: { Unit* permafrostCaster = NULL; - if (Aura* permafrostAura = target->GetAura(66193)) - permafrostCaster = permafrostAura->GetCaster(); - else if (Aura* permafrostAura = target->GetAura(67855)) - permafrostCaster = permafrostAura->GetCaster(); - else if (Aura* permafrostAura = target->GetAura(67856)) - permafrostCaster = permafrostAura->GetCaster(); - else if (Aura* permafrostAura = target->GetAura(67857)) + Aura* permafrostAura = target->GetAura(66193); + if (!permafrostAura) + permafrostAura = target->GetAura(67855); + if (!permafrostAura) + permafrostAura = target->GetAura(67856); + if (!permafrostAura) + permafrostAura = target->GetAura(67857); + + if (permafrostAura) permafrostCaster = permafrostAura->GetCaster(); if (permafrostCaster) @@ -6461,15 +6463,15 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const // damage caster for heal amount if (target != caster && GetSpellInfo()->AttributesEx2 & SPELL_ATTR2_HEALTH_FUNNEL) { - uint32 damage = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); // damage is not affected by spell power - if ((int32)damage > gain) - damage = gain; - uint32 absorb = 0; - caster->DealDamageMods(caster, damage, &absorb); - caster->SendSpellNonMeleeDamageLog(caster, GetId(), damage, GetSpellInfo()->GetSchoolMask(), absorb, 0, false, 0, false); + uint32 funnelDamage = GetSpellInfo()->Effects[EFFECT_0].CalcValue(); // damage is not affected by spell power + if ((int32)funnelDamage > gain) + funnelDamage = gain; + uint32 funnelAbsorb = 0; + caster->DealDamageMods(caster, funnelDamage, &funnelAbsorb); + caster->SendSpellNonMeleeDamageLog(caster, GetId(), funnelDamage, GetSpellInfo()->GetSchoolMask(), funnelAbsorb, 0, false, 0, false); 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; diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index c34391471d7..7f754253719 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -80,6 +80,7 @@ class AuraEffect bool IsPeriodic() const { return m_isPeriodic; } void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; } bool IsAffectedOnSpell(SpellInfo const* spell) const; + bool HasSpellClassMask() const { return m_spellInfo->Effects[m_effIndex].SpellClassMask; } void SendTickImmune(Unit* target, Unit* caster) const; void PeriodicTick(AuraApplication * aurApp, Unit* caster) const; diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index df6ac44f2cc..525084a70ed 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -557,7 +557,14 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply) else { // owner has to be in world, or effect has to be applied to self - ASSERT((!GetOwner()->IsInWorld() && GetOwner() == itr->first) || GetOwner()->IsInMap(itr->first)); + if (!GetOwner()->IsSelfOrInSameMap(itr->first)) + { + //TODO: There is a crash caused by shadowfiend load addon + sLog->outCrash("Aura %u: Owner %s (map %u) is not in the same map as target %s (map %u).", GetSpellInfo()->Id, + GetOwner()->GetName(), GetOwner()->IsInWorld() ? GetOwner()->GetMap()->GetId() : uint32(-1), + itr->first->GetName(), itr->first->IsInWorld() ? itr->first->GetMap()->GetId() : uint32(-1)); + ASSERT(false); + } itr->first->_CreateAuraApplication(this, itr->second); ++itr; } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index dc56e04c3b5..8a4c0a768d8 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -641,23 +641,24 @@ void Spell::InitExplicitTargets(SpellCastTargets const& targets) // try to select correct unit target if not provided by client or by serverside cast if (neededTargets & (TARGET_FLAG_UNIT_MASK)) { - Unit* target = NULL; + Unit* unit = NULL; // try to use player selection as a target if (Player* playerCaster = m_caster->ToPlayer()) { // selection has to be found and to be valid target for the spell if (Unit* selectedUnit = ObjectAccessor::GetUnit(*m_caster, playerCaster->GetSelection())) if (m_spellInfo->CheckExplicitTarget(m_caster, selectedUnit) == SPELL_CAST_OK) - target = selectedUnit; + unit = selectedUnit; } // try to use attacked unit as a target 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; + if (!unit && neededTargets & (TARGET_FLAG_UNIT_RAID | TARGET_FLAG_UNIT_PARTY | TARGET_FLAG_UNIT_ALLY)) + unit = m_caster; - m_targets.SetUnitTarget(target); + m_targets.SetUnitTarget(unit); } } @@ -1218,11 +1219,11 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) if (spellHitTarget) { - SpellMissInfo missInfo = DoSpellHitOnUnit(spellHitTarget, mask, target->scaleAura); - if (missInfo != SPELL_MISS_NONE) + SpellMissInfo missInfo2 = DoSpellHitOnUnit(spellHitTarget, mask, target->scaleAura); + if (missInfo2 != SPELL_MISS_NONE) { - if (missInfo != SPELL_MISS_MISS) - m_caster->SendSpellMiss(unit, m_spellInfo->Id, missInfo); + if (missInfo2 != SPELL_MISS_MISS) + m_caster->SendSpellMiss(unit, m_spellInfo->Id, missInfo2); m_damage = 0; spellHitTarget = NULL; } @@ -6798,7 +6799,7 @@ void Spell::SelectTrajTargets() if (!dist2d) 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; SearchAreaTarget(unitList, dist2d, PUSH_IN_THIN_LINE, SPELL_TARGETS_ANY); @@ -6808,8 +6809,9 @@ void Spell::SelectTrajTargets() unitList.sort(Trinity::ObjectDistanceOrderPred(m_caster)); float b = tangent(m_targets.GetElevation()); - float a = (dz - dist2d * b) / (dist2d * dist2d); - if (a > -0.0001f) a = 0; + float a = (srcToDestDelta - dist2d * b) / (dist2d * dist2d); + if (a > -0.0001f) + a = 0; DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: a %f b %f", a, b);) float bestDist = m_spellInfo->GetMaxRange(false); @@ -6837,9 +6839,14 @@ void Spell::SelectTrajTargets() } #define CHECK_DIST {\ - DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\ - if (dist > bestDist) continue;\ - if (dist < objDist2d + size && dist > objDist2d - size) { bestDist = dist; break; }\ + DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: dist %f, height %f.", dist, height);)\ + if (dist > bestDist)\ + continue;\ + if (dist < objDist2d + size && dist > objDist2d - size)\ + {\ + bestDist = dist;\ + break;\ + }\ } if (!a) @@ -7027,7 +7034,7 @@ bool Spell::CallScriptEffectHandlers(SpellEffIndex effIndex, SpellEffectHandleMo break; default: ASSERT(false); - break; + return false; } (*scritr)->_PrepareScriptCall(hookType); for (; effItr != effEndItr ; ++effItr) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 26ef498b6ff..a4cf8e6a469 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -923,7 +923,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) if (m_caster->GetTypeId() != TYPEID_PLAYER) return; - uint32 spell_id = roll_chance_i(50) + spell_id = roll_chance_i(50) ? 29277 // Summon Purified Helboar Meat : 29278; // Summon Toxic Helboar Meat @@ -951,12 +951,16 @@ void Spell::EffectDummy(SpellEffIndex effIndex) return; case 35745: // Socrethar's Stone { - uint32 spell_id; switch (m_caster->GetAreaId()) { - case 3900: spell_id = 35743; break; // Socrethar Portal - case 3742: spell_id = 35744; break; // Socrethar Portal - default: return; + case 3900: + spell_id = 35743; + break; // Socrethar Portal + case 3742: + spell_id = 35744; + break; // Socrethar Portal + default: + return; } 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) { 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 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)); @@ -1465,12 +1469,12 @@ void Spell::EffectDummy(SpellEffIndex effIndex) { 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); } else { - int32 bp = damage; + bp = damage; m_caster->CastCustomSpell(unitTarget, 47632, &bp, NULL, NULL, true); } return; @@ -2141,6 +2145,16 @@ void Spell::EffectSendEvent(SpellEffIndex effIndex) && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; + //! it's possible for spells with this spell effect to either have a target or no target + //! in case of a target, we will execute this handler on SPELL_EFFECT_HANDLE_HIT_TARGET + //! with all relevant variables, and we will skip SPELL_EFFECT_HANDLE_HIT + if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT) + { + if (GetSpellInfo()->Effects[effIndex].TargetA.GetTarget() != 0 || + GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() != 0) + return; + } + WorldObject* target = NULL; // call events for target if present @@ -4953,6 +4967,25 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) } return; } + case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + unitTarget->ToCreature()->DespawnOrUnsummon(); + + return; + } + case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell) + { + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + // Delete item from inventory at death + m_caster->ToPlayer()->DestroyItemCount(damage, 5, true); + + return; + } case 58418: // Portal to Orgrimmar case 58420: // Portal to Stormwind { @@ -6319,13 +6352,13 @@ void Spell::EffectQuestClear(SpellEffIndex effIndex) // remove all quest entries for 'entry' from quest log for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) { - uint32 quest = player->GetQuestSlotQuestId(slot); - if (quest == quest_id) + uint32 logQuest = player->GetQuestSlotQuestId(slot); + if (logQuest == quest_id) { player->SetQuestSlot(slot, 0); - // we ignore unequippable quest items in this case, its' still be equipped - player->TakeQuestSourceItem(quest, false); + // we ignore unequippable quest items in this case, it's still be equipped + player->TakeQuestSourceItem(logQuest, false); } } diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index b669f8fe866..c382cb56a62 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -96,7 +96,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto, return DIMINISHING_CONTROLLED_ROOT; // Dragon's Breath else if (spellproto->SpellFamilyFlags[0] & 0x800000) - return DIMINISHING_DISORIENT; + return DIMINISHING_DRAGONS_BREATH; break; } case SPELLFAMILY_WARRIOR: @@ -167,7 +167,7 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto, } case SPELLFAMILY_HUNTER: { - // Hunter's mark + // Hunter's Mark if ((spellproto->SpellFamilyFlags[0] & 0x400) && spellproto->SpellIconID == 538) return DIMINISHING_LIMITONLY; // Scatter Shot (own diminishing) @@ -321,20 +321,20 @@ bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group) { switch (group) { + case DIMINISHING_BANISH: case DIMINISHING_CONTROLLED_STUN: - case DIMINISHING_STUN: - case DIMINISHING_ENTRAPMENT: case DIMINISHING_CONTROLLED_ROOT: - case DIMINISHING_ROOT: + case DIMINISHING_CYCLONE: + case DIMINISHING_DISORIENT: + case DIMINISHING_ENTRAPMENT: case DIMINISHING_FEAR: + case DIMINISHING_HORROR: case DIMINISHING_MIND_CONTROL: - case DIMINISHING_DISORIENT: - case DIMINISHING_CYCLONE: - case DIMINISHING_BANISH: - case DIMINISHING_LIMITONLY: case DIMINISHING_OPENING_STUN: - case DIMINISHING_HORROR: + case DIMINISHING_ROOT: + case DIMINISHING_STUN: case DIMINISHING_SLEEP: + case DIMINISHING_LIMITONLY: return true; default: return false; @@ -1005,7 +1005,7 @@ SpellThreatEntry const* SpellMgr::GetSpellThreatEntry(uint32 spellID) const else { uint32 firstSpell = GetFirstSpellInChain(spellID); - SpellThreatMap::const_iterator itr = mSpellThreatMap.find(firstSpell); + itr = mSpellThreatMap.find(firstSpell); if (itr != mSpellThreatMap.end()) return &itr->second; } diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index 92fa001fe46..0c3fd957165 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -443,6 +443,10 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s typedef PetIds::value_type PetIdsPair; PetIds petids; + uint8 gender = GENDER_NONE; + uint8 race = RACE_NONE; + uint8 playerClass = 0; + SQLTransaction trans = CharacterDatabase.BeginTransaction(); while (!feof(fin)) { @@ -512,6 +516,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (!changenth(line, 2, chraccount)) // characters.account update ROLLBACK(DUMP_FILE_BROKEN); + race = uint8(atol(getnth(line, 4).c_str())); + playerClass = uint8(atol(getnth(line, 5).c_str())); + gender = uint8(atol(getnth(line, 6).c_str())); if (name == "") { // check if the original name already exists @@ -520,10 +527,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s result = CharacterDatabase.PQuery("SELECT 1 FROM characters WHERE name = '%s'", name.c_str()); if (result) - { if (!changenth(line, 37, "1")) // characters.at_login set to "rename on login" ROLLBACK(DUMP_FILE_BROKEN); - } } else if (!changenth(line, 3, name.c_str())) // characters.name ROLLBACK(DUMP_FILE_BROKEN); @@ -654,6 +659,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s CharacterDatabase.CommitTransaction(trans); + // in case of name conflict player has to rename at login anyway + sWorld->AddCharacterNameData(guid, name, gender, race, playerClass); + sObjectMgr->m_hiItemGuid += items.size(); sObjectMgr->m_mailid += mails.size(); @@ -664,4 +672,3 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s return DUMP_SUCCESS; } - diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 408db187aae..8aca4563b91 100755 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -2869,7 +2869,7 @@ void World::LoadCharacterNameData() sLog->outString("Loaded name data for %u characters", count); } -void World::AddCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race, uint8 playerClass) +void World::AddCharacterNameData(uint32 guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass) { CharacterNameData& data = _characterNameDataMap[guid]; data.m_name = name; @@ -2878,18 +2878,22 @@ void World::AddCharacterNameData(uint32 guid, const std::string& name, uint8 gen data.m_class = playerClass; } -void World::UpdateCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race) +void World::UpdateCharacterNameData(uint32 guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/) { std::map<uint32, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid); if (itr == _characterNameDataMap.end()) return; + itr->second.m_name = name; - itr->second.m_gender = gender; - if(race != RACE_NONE) + + if (gender != GENDER_NONE) + itr->second.m_gender = gender; + + if (race != RACE_NONE) itr->second.m_race = race; } -const CharacterNameData* World::GetCharacterNameData(uint32 guid) const +CharacterNameData const* World::GetCharacterNameData(uint32 guid) const { std::map<uint32, CharacterNameData>::const_iterator itr = _characterNameDataMap.find(guid); if (itr != _characterNameDataMap.end()) diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index b493b8b0c7b..f643ae60287 100755 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -738,9 +738,9 @@ class World bool isEventKillStart; - const CharacterNameData* GetCharacterNameData(uint32 guid) const; - void AddCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race, uint8 playerClass); - void UpdateCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race = RACE_NONE); + CharacterNameData const* GetCharacterNameData(uint32 guid) const; + void AddCharacterNameData(uint32 guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass); + void UpdateCharacterNameData(uint32 guid, std::string const& name, uint8 gender = GENDER_NONE, uint8 race = RACE_NONE); void DeleteCharaceterNameData(uint32 guid) { _characterNameDataMap.erase(guid); } uint32 GetCleaningFlags() const { return m_CleaningFlags; } diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 80dd2dc366a..ae3250ad7b7 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -473,7 +473,7 @@ public: LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND (RealmID = '%d' OR RealmID = '-1')", targetAccountId, realmID); if (gm != 0) - LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, realmID); + LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, gmRealmID); handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); return true; diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 31d8cd3c8f2..3d437e473f7 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -128,13 +128,13 @@ public: // remove all quest entries for 'entry' from quest log for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) { - uint32 quest = player->GetQuestSlotQuestId(slot); - if (quest == entry) + uint32 logQuest = player->GetQuestSlotQuestId(slot); + if (logQuest == entry) { player->SetQuestSlot(slot, 0); // we ignore unequippable quest items in this case, its' still be equipped - player->TakeQuestSourceItem(quest, false); + player->TakeQuestSourceItem(logQuest, false); } } @@ -176,8 +176,8 @@ public: // Add quest items for quests that require items for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x) { - uint32 id = quest->ReqItemId[x]; - uint32 count = quest->ReqItemCount[x]; + uint32 id = quest->RequiredItemId[x]; + uint32 count = quest->RequiredItemCount[x]; if (!id || !count) continue; @@ -195,10 +195,10 @@ public: // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { - int32 creature = quest->ReqCreatureOrGOId[i]; - uint32 creaturecount = quest->ReqCreatureOrGOCount[i]; + int32 creature = quest->RequiredNpcOrGo[i]; + uint32 creaturecount = quest->RequiredNpcOrGoCount[i]; - if (uint32 spell_id = quest->ReqSpell[i]) + if (uint32 spell_id = quest->RequiredSpellCast[i]) { for (uint16 z = 0; z < creaturecount; ++z) player->CastedCreatureOrGO(creature, 0, spell_id); diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index 85e0ff2390b..ef4ddf17476 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -125,6 +125,29 @@ public: if (!handler->extractPlayerTarget(nameStr, &target, &target_guid, &target_name)) return false; + if (strcmp(teleStr, "$home") == 0) // References target's homebind + { + if (target) + target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation()); + else + { + QueryResult resultDB = CharacterDatabase.PQuery("SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = %u", target_guid); + if (resultDB) + { + Field* fieldsDB = resultDB->Fetch(); + uint32 mapId = fieldsDB[0].GetUInt32(); + uint32 zoneId = fieldsDB[1].GetUInt32(); + float posX = fieldsDB[2].GetFloat(); + float posY = fieldsDB[3].GetFloat(); + float posZ = fieldsDB[4].GetFloat(); + + Player::SavePositionInDB(mapId, posX, posY, posZ, 0, zoneId, target_guid); + } + } + + return true; + } + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r GameTele const* tele = handler->extractGameTeleFromLink(teleStr); if (!tele) @@ -187,8 +210,8 @@ public: if (!*args) return false; - Player* player = handler->getSelectedPlayer(); - if (!player) + Player* target = handler->getSelectedPlayer(); + if (!target) { handler->SendSysMessage(LANG_NO_CHAR_SELECTED); handler->SetSentErrorMessage(true); @@ -196,7 +219,7 @@ public: } // check online security - if (handler->HasLowerSecurity(player, 0)) + if (handler->HasLowerSecurity(target, 0)) return false; // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r @@ -216,9 +239,9 @@ public: return false; } - std::string nameLink = handler->GetNameLink(player); + std::string nameLink = handler->GetNameLink(target); - Group* grp = player->GetGroup(); + Group* grp = target->GetGroup(); if (!grp) { handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str()); diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index f754a32fbfc..ebeb7b8f4f4 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -480,55 +480,43 @@ public: } // The visual waypoint - Creature* wpCreature = NULL; 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? + // Check the creature - if (wpCreature->GetEntry() == VISUAL_WAYPOINT) - { - QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid); + 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) { - 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)", - 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(); + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid); + return true; } - 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 if (show != "del" && show != "move" && arg_str == NULL) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index 2bcfab80056..aa0fee873e1 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -136,9 +136,9 @@ public: { uint8 r = rand()%4; uint8 pos[3]; - pos[RED_PORTAL] = (r%2 ? (r>1 ? 2: 1): 0); - pos[GREEN_PORTAL] = (r%2 ? 0: (r>1 ? 2: 1)); - pos[BLUE_PORTAL] = (r>1 ? 1: 2); // Blue Portal not on the left side (0) + pos[RED_PORTAL] = ((r % 2) ? (r > 1 ? 2 : 1) : 0); + pos[GREEN_PORTAL] = ((r % 2) ? 0 : (r > 1 ? 2 : 1)); + pos[BLUE_PORTAL] = (r > 1 ? 1 : 2); // Blue Portal not on the left side (0) for (int i=0; i<3; ++i) if (Creature* portal = me->SummonCreature(PortalID[i], PortalCoord[pos[i]][0], PortalCoord[pos[i]][1], PortalCoord[pos[i]][2], 0, TEMPSUMMON_TIMED_DESPAWN, 60000)) diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index 719c42c0a57..55254a3b8ee 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -201,7 +201,8 @@ public: //object already removed, not exist 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(); } ++j; diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp index 592e0054fa4..4bc3da16651 100644 --- a/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp +++ b/src/server/scripts/EasternKingdoms/MoltenCore/boss_ragnaros.cpp @@ -110,7 +110,7 @@ class boss_ragnaros : public CreatureScript void KilledUnit(Unit* /*victim*/) { - if (urand(0, 99 < 25)) + if (urand(0, 99) < 25) DoScriptText(SAY_KILL, me); } diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index aea25af87bf..18316d67cd4 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -497,9 +497,9 @@ public: SetEscortPaused(bOnHold); } - void WaypointReached(uint32 i) + void WaypointReached(uint32 wpId) { - switch (i) + switch (wpId) { case 0: me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); @@ -1173,8 +1173,8 @@ public: temp->SetSpeed(MOVE_RUN, 3.0f); // workarounds, make Tirion still running temp->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); temp->GetMotionMaster()->MovePoint(0, LightofDawnLoc[2].x, LightofDawnLoc[2].y, LightofDawnLoc[2].z); - if (Creature* temp = 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 + if (Creature* lktemp = Unit::GetCreature(*me, uiLichKingGUID)) + 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); break; diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index 9afbeaa0172..c9ab9084d22 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -504,15 +504,14 @@ public: Player* SelectRandomPlayer(float range = 0.0f, bool checkLoS = true) { Map* map = me->GetMap(); - if (!map->IsDungeon()) return NULL; + if (!map->IsDungeon()) + return NULL; Map::PlayerList const &PlayerList = map->GetPlayers(); - Map::PlayerList::const_iterator i; - if (PlayerList.isEmpty()) return NULL; + if (PlayerList.isEmpty()) + return NULL; std::list<Player*> temp; - std::list<Player*>::const_iterator j; - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) if ((me->IsWithinLOSInMap(i->getSource()) || !checkLoS) && me->getVictim() != i->getSource() && me->IsWithinDistInMap(i->getSource(), range) && i->getSource()->isAlive()) @@ -520,7 +519,7 @@ public: if (!temp.empty()) { - j = temp.begin(); + std::list<Player*>::const_iterator j = temp.begin(); advance(j, rand()%temp.size()); return (*j); } diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp index 3b788c72cd8..d0ea617b734 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp @@ -102,7 +102,7 @@ public: { if (m_instance) { - if (m_instance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT != NOT_STARTED)) + if (m_instance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT) != NOT_STARTED) m_instance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, FAIL); } } diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index b29a0c491cc..ca853d5684e 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -662,11 +662,13 @@ public: { float x, y, z; 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); - 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) { target->GetPosition(x, y, z); diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index fd11b4a4985..7c14845f060 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -330,14 +330,14 @@ public: else { DarkFiend = false; - for (uint8 i = 0; i < 8; ++i) - me->SummonCreature(CREATURE_DARK_FIENDS, DarkFiends[i][0], DarkFiends[i][1], DarkFiends[i][2], DarkFiends[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0); + for (uint8 j = 0; j < 8; ++j) + 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; } break; case TIMER_HUMANOIDES: - for (uint8 i = 0; i < 6; ++i) - me->SummonCreature(uint32(Humanoides[i][0]), Humanoides[i][1], Humanoides[i][2], Humanoides[i][3], Humanoides[i][4], TEMPSUMMON_CORPSE_DESPAWN, 0); + for (uint8 j = 0; j < 6; ++j) + 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; break; case TIMER_PHASE: diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp index 0e5233d6620..338f320dcc2 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/instance_hyjal.cpp @@ -205,9 +205,9 @@ public: { if (i->getSource()) { - WorldPacket data(SMSG_MESSAGECHAT, 200); - unit->BuildMonsterChat(&data, CHAT_MSG_MONSTER_YELL, YELL_EFFORTS, 0, YELL_EFFORTS_NAME, i->getSource()->GetGUID()); - i->getSource()->GetSession()->SendPacket(&data); + WorldPacket packet(SMSG_MESSAGECHAT, 200); + unit->BuildMonsterChat(&packet, CHAT_MSG_MONSTER_YELL, YELL_EFFORTS, 0, YELL_EFFORTS_NAME, i->getSource()->GetGUID()); + i->getSource()->GetSession()->SendPacket(&packet); WorldPacket data2(SMSG_PLAY_SOUND, 4); data2 << 10986; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp index 02f9435db49..82f16dd7784 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp @@ -579,13 +579,16 @@ public: { //After reset case 0: - if (Unit* pJaina = GetClosestCreatureWithEntry(me, NPC_JAINA, 50.0f)) - uiJainaGUID = pJaina->GetGUID(); - else if (Unit* pJaina = me->SummonCreature(NPC_JAINA, 1895.48f, 1292.66f, 143.706f, 0.023475f, TEMPSUMMON_DEAD_DESPAWN, 180000)) + { + Unit* pJaina = GetClosestCreatureWithEntry(me, NPC_JAINA, 50.0f); + 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(); bStepping = false; JumpToNextStep(0); break; + } //After waypoint 0 case 1: me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING); @@ -829,9 +832,10 @@ public: case 37: if (Creature* pMalganis = Unit::GetCreature(*me, uiMalganisGUID)) { - if (Creature* pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN, 100.0f)) - pZombie->UpdateEntry(NPC_ZOMBIE, 0); - else if (Creature* pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN2, 100.0f)) + Creature* pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN, 100.0f); + if (!pZombie) + pZombie = GetClosestCreatureWithEntry(pMalganis, NPC_CITY_MAN2, 100.0f); + if (pZombie) pZombie->UpdateEntry(NPC_ZOMBIE, 0); else //There's no one else to transform uiStep++; diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index 4cc1069b838..43265cb4430 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -680,12 +680,8 @@ public: //Place all units in threat list on outside of stomach Stomach_Map.clear(); - std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); - for (; i != me->getThreatManager().getThreatList().end(); ++i) - { - //Outside stomach - Stomach_Map[(*i)->getUnitGuid()] = false; - } + for (std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin(); i != me->getThreatManager().getThreatList().end(); ++i) + Stomach_Map[(*i)->getUnitGuid()] = false; //Outside stomach //Spawn 2 flesh tentacles FleshTentaclesKilled = 0; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp index 2688005ee22..a1e906e214a 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/trial_of_the_champion.cpp @@ -221,10 +221,9 @@ public: { uiVehicle1GUID = pBoss->GetGUID(); uint64 uiGrandChampionBoss1 = 0; - if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle1GUID)) - if (Vehicle* pVehicle = pBoss->GetVehicleKit()) - if (Unit* unit = pVehicle->GetPassenger(0)) - uiGrandChampionBoss1 = unit->GetGUID(); + if (Vehicle* pVehicle = pBoss->GetVehicleKit()) + if (Unit* unit = pVehicle->GetPassenger(0)) + uiGrandChampionBoss1 = unit->GetGUID(); if (instance) { instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_1, uiVehicle1GUID); @@ -237,10 +236,9 @@ public: { uiVehicle2GUID = pBoss->GetGUID(); uint64 uiGrandChampionBoss2 = 0; - if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle2GUID)) - if (Vehicle* pVehicle = pBoss->GetVehicleKit()) - if (Unit* unit = pVehicle->GetPassenger(0)) - uiGrandChampionBoss2 = unit->GetGUID(); + if (Vehicle* pVehicle = pBoss->GetVehicleKit()) + if (Unit* unit = pVehicle->GetPassenger(0)) + uiGrandChampionBoss2 = unit->GetGUID(); if (instance) { instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_2, uiVehicle2GUID); @@ -253,10 +251,9 @@ public: { uiVehicle3GUID = pBoss->GetGUID(); uint64 uiGrandChampionBoss3 = 0; - if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle3GUID)) - if (Vehicle* pVehicle = pBoss->GetVehicleKit()) - if (Unit* unit = pVehicle->GetPassenger(0)) - uiGrandChampionBoss3 = unit->GetGUID(); + if (Vehicle* pVehicle = pBoss->GetVehicleKit()) + if (Unit* unit = pVehicle->GetPassenger(0)) + uiGrandChampionBoss3 = unit->GetGUID(); if (instance) { instance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_3, uiVehicle3GUID); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp index d4514dd547e..1ee7bcb4120 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp @@ -348,10 +348,10 @@ public: m_bTargetDied = true; 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(); - me->GetMotionMaster()->MoveJump(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 15.0f, 15.0f); + m_uiTargetGUID = target2->GetGUID(); + me->GetMotionMaster()->MoveJump(target2->GetPositionX(), target2->GetPositionY(), target2->GetPositionZ(), 15.0f, 15.0f); } } } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 5b612942435..29c3276467b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -242,6 +242,9 @@ class boss_sindragosa : public CreatureScript { if (action == ACTION_START_FROSTWYRM) { + if (TempSummon* summon = me->ToTempSummon()) + summon->SetTempSummonType(TEMPSUMMON_DEAD_DESPAWN); + instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, 255); if (me->isDead()) return; @@ -971,7 +974,7 @@ class spell_sindragosa_s_fury : public SpellScriptLoader if (!GetHitUnit()->isAlive() || !_targetCount) return; - float resistance = float(GetHitUnit()->GetResistance(GetFirstSchoolInMask(SpellSchoolMask(GetSpellInfo()->SchoolMask)))); + float resistance = float(GetHitUnit()->GetResistance(SpellSchoolMask(GetSpellInfo()->SchoolMask))); uint32 minResistFactor = uint32((resistance / (resistance + 510.0f))* 10.0f) * 2; uint32 randomResist = urand(0, (9 - minResistFactor) * 100)/100 + minResistFactor; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 38f334058b8..2f4f225561c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -1335,7 +1335,7 @@ class npc_shambling_horror_icc : public CreatureScript void DamageTaken(Unit* /*attacker*/, uint32& damage) { - if (IsHeroic() && me->HealthBelowPctDamaged(20, damage)) + if (!_frenzied && IsHeroic() && me->HealthBelowPctDamaged(20, damage)) { _frenzied = true; DoCast(me, SPELL_FRENZY, true); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp index 10f1b809694..3b87dea025c 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp @@ -91,7 +91,7 @@ public: _EnterCombat(); Enraged = false; DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2), me); - events.ScheduleEvent(EVENT_HATEFUL, 1200); + events.ScheduleEvent(EVENT_HATEFUL, 1000); events.ScheduleEvent(EVENT_BERSERK, 360000); if (instance) @@ -131,7 +131,7 @@ public: DoCast(pMostHPTarget, RAID_MODE(SPELL_HATEFUL_STRIKE, H_SPELL_HATEFUL_STRIKE), true); - events.ScheduleEvent(EVENT_HATEFUL, 1200); + events.ScheduleEvent(EVENT_HATEFUL, 1000); break; } case EVENT_BERSERK: @@ -140,7 +140,7 @@ public: events.ScheduleEvent(EVENT_SLIME, 2000); break; case EVENT_SLIME: - DoCast(me->getVictim(), SPELL_SLIME_BOLT); + DoCast(me->getVictim(), SPELL_SLIME_BOLT, true); events.ScheduleEvent(EVENT_SLIME, 2000); break; } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp index d620289a72f..ed1bbd1971a 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_sapphiron.cpp @@ -271,14 +271,18 @@ public: break; } case EVENT_FLIGHT: - phase = PHASE_FLIGHT; - events.SetPhase(PHASE_FLIGHT); - me->SetReactState(REACT_PASSIVE); - me->AttackStop(); - float x, y, z, o; - me->GetHomePosition(x, y, z, o); - me->GetMotionMaster()->MovePoint(1, x, y, z); - return; + if (HealthAbovePct(10)) + { + phase = PHASE_FLIGHT; + events.SetPhase(PHASE_FLIGHT); + me->SetReactState(REACT_PASSIVE); + me->AttackStop(); + float x, y, z, o; + me->GetHomePosition(x, y, z, o); + me->GetMotionMaster()->MovePoint(1, x, y, z); + return; + } + break; } } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index f59ef8afe10..e7d8b070e53 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -321,35 +321,12 @@ class boss_freya : public CreatureScript DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me); } - void DamageTaken(Unit* /*who*/, uint32& damage) + void DamageTaken(Unit* who, uint32& damage) { if (damage >= me->GetHealth()) { damage = 0; - DoScriptText(SAY_DEATH, me); - me->SetReactState(REACT_PASSIVE); - _JustDied(); - me->RemoveAllAuras(); - me->AttackStop(); - me->setFaction(35); - me->DeleteThreatList(); - me->CombatStop(true); - me->DespawnOrUnsummon(7500); - me->CastSpell(me, SPELL_KNOCK_ON_WOOD_CREDIT, true); - - Creature* Elder[3]; - for (uint8 n = 0; n < 3; ++n) - { - Elder[n] = ObjectAccessor::GetCreature(*me, instance->GetData64(BOSS_BRIGHTLEAF + n)); - if (Elder[n] && Elder[n]->isAlive()) - { - Elder[n]->RemoveAllAuras(); - Elder[n]->AttackStop(); - Elder[n]->CombatStop(true); - Elder[n]->DeleteThreatList(); - Elder[n]->GetAI()->DoAction(ACTION_ELDER_FREYA_KILLED); - } - } + JustDied(who); } } @@ -625,7 +602,30 @@ class boss_freya : public CreatureScript me->CastSpell((Unit*)NULL, summonSpell[me->GetMap()->GetDifficulty()][elderCount], true); + DoScriptText(SAY_DEATH, me); + me->SetReactState(REACT_PASSIVE); _JustDied(); + me->RemoveAllAuras(); + me->AttackStop(); + me->setFaction(35); + me->DeleteThreatList(); + me->CombatStop(true); + me->DespawnOrUnsummon(7500); + me->CastSpell(me, SPELL_KNOCK_ON_WOOD_CREDIT, true); + + Creature* Elder[3]; + for (uint8 n = 0; n < 3; ++n) + { + Elder[n] = ObjectAccessor::GetCreature(*me, instance->GetData64(BOSS_BRIGHTLEAF + n)); + if (Elder[n] && Elder[n]->isAlive()) + { + Elder[n]->RemoveAllAuras(); + Elder[n]->AttackStop(); + Elder[n]->CombatStop(true); + Elder[n]->DeleteThreatList(); + Elder[n]->GetAI()->DoAction(ACTION_ELDER_FREYA_KILLED); + } + } } void JustSummoned(Creature* summoned) diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp index 55211f3f047..dc2d34326a7 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_ingvar_the_plunderer.cpp @@ -130,7 +130,7 @@ public: me->SetHealth(0); me->InterruptNonMeleeSpells(true); me->RemoveAllAuras(); - me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); + me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->GetMotionMaster()->MovementExpired(false); me->GetMotionMaster()->MoveIdle(); me->SetStandState(UNIT_STAND_STATE_DEAD); @@ -152,7 +152,7 @@ public: { bIsUndead = true; bEventInProgress = false; - me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); + me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->UpdateEntry(MOB_INGVAR_UNDEAD); me->SetInCombatWith(me->getVictim()); me->GetMotionMaster()->MoveChase(me->getVictim()); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index e06da5bb7ea..45534824860 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -136,7 +136,6 @@ public: if (Creature* pArthas = me->SummonCreature(CREATURE_ARTHAS, ArthasPos, TEMPSUMMON_MANUAL_DESPAWN)) { pArthas->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE); - pArthas->SetFloatValue(OBJECT_FIELD_SCALE_X, 5); uiArthasGUID = pArthas->GetGUID(); } } diff --git a/src/server/scripts/Northrend/borean_tundra.cpp b/src/server/scripts/Northrend/borean_tundra.cpp index 9c40fbb3f82..96f1cb49b84 100644 --- a/src/server/scripts/Northrend/borean_tundra.cpp +++ b/src/server/scripts/Northrend/borean_tundra.cpp @@ -2125,7 +2125,7 @@ public: { Quest const* qInfo = sObjectMgr->GetQuestTemplate(QUEST_YOU_RE_NOT_SO_BIG_NOW); if (qInfo) - CAST_PLR(killer)->KilledMonsterCredit(qInfo->ReqCreatureOrGOId[0], 0); + CAST_PLR(killer)->KilledMonsterCredit(qInfo->RequiredNpcOrGo[0], 0); } } }; diff --git a/src/server/scripts/Northrend/sholazar_basin.cpp b/src/server/scripts/Northrend/sholazar_basin.cpp index b3f1fb1b8b0..6f9481ec226 100644 --- a/src/server/scripts/Northrend/sholazar_basin.cpp +++ b/src/server/scripts/Northrend/sholazar_basin.cpp @@ -98,8 +98,7 @@ public: me->SetUnitMovementFlags(MOVEMENTFLAG_JUMPING); break; case 28: - if (Player* player = GetPlayerForEscort()) - player->GroupEventHappens(QUEST_FORTUNATE_MISUNDERSTANDINGS, me); + player->GroupEventHappens(QUEST_FORTUNATE_MISUNDERSTANDINGS, me); // me->RestoreFaction(); DoScriptText(SAY_END_IRO, me); SetRun(false); diff --git a/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp b/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp index 1f603699060..6bf26e795ca 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_warlord_najentus.cpp @@ -94,7 +94,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(rand()%2 ? SAY_SLAY1 : SAY_SLAY2, me); + DoScriptText(urand(0, 1) ? SAY_SLAY1 : SAY_SLAY2, me); events.DelayEvents(5000, GCD_YELL); } @@ -175,7 +175,7 @@ public: SpineTargetGUID = target->GetGUID(); //must let target summon, otherwise you cannot click the spine target->SummonGameObject(GOBJECT_SPINE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), me->GetOrientation(), 0, 0, 0, 0, 30); - DoScriptText(rand()%2 ? SAY_NEEDLE1 : SAY_NEEDLE2, me); + DoScriptText(urand(0, 1) ? SAY_NEEDLE1 : SAY_NEEDLE2, me); events.DelayEvents(1500, GCD_CAST); events.DelayEvents(15000, GCD_YELL); } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp index f69aa1f0757..f8ed96632df 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lurker_below.cpp @@ -234,7 +234,7 @@ public: { me->MonsterTextEmote(EMOTE_SPOUT, 0, true); me->SetReactState(REACT_PASSIVE); - me->GetMotionMaster()->MoveRotate(20000, rand()%2 ? ROTATE_DIRECTION_LEFT : ROTATE_DIRECTION_RIGHT); + me->GetMotionMaster()->MoveRotate(20000, urand(0, 1) ? ROTATE_DIRECTION_LEFT : ROTATE_DIRECTION_RIGHT); SpoutTimer = 45000; WhirlTimer = 20000;//whirl directly after spout RotTimer = 20000; diff --git a/src/server/scripts/Outland/shadowmoon_valley.cpp b/src/server/scripts/Outland/shadowmoon_valley.cpp index 31aea5ea576..610cf684a77 100644 --- a/src/server/scripts/Outland/shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/shadowmoon_valley.cpp @@ -998,8 +998,7 @@ public: case 50: DoScriptText(SAY_WIL_END, me, player); - if (Player* player = GetPlayerForEscort()) - player->GroupEventHappens(QUEST_ESCAPE_COILSCAR, me); + player->GroupEventHappens(QUEST_ESCAPE_COILSCAR, me); break; } } diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index a9ed794ab45..517746dac55 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -24,14 +24,8 @@ SDCategory: Areatrigger EndScriptData */ /* ContentData -at_aldurthar_gate q13315/q13351 at_coilfang_waterfall 4591 at_legion_teleporter 4560 Teleporter TO Invasion Point: Cataclysm -at_ravenholdt -at_warsong_slaughterhouse -at_warsong_grainery -at_torp_farm -at_warsong_farms q11686 at_stormwright_shelf q12741 at_last_rites q12019 at_sholazar_waygate q12548 @@ -40,46 +34,6 @@ EndContentData */ #include "ScriptPCH.h" /*###### -## AreaTrigger_at_aldurthar_gate -######*/ - -enum eAldurtharGate -{ - TRIGGER_SOUTH = 5284, - - TRIGGER_CENTRAL = 5285, - TRIGGER_NORTH = 5286, - TRIGGER_NORTHWEST = 5287, - - NPC_SOUTH_GATE = 32195, - NPC_CENTRAL_GATE = 32196, - NPC_NORTH_GATE = 32197, - NPC_NORTHWEST_GATE = 32199 -}; - -class AreaTrigger_at_aldurthar_gate : public AreaTriggerScript -{ - public: - - AreaTrigger_at_aldurthar_gate() - : AreaTriggerScript("at_aldurthar_gate") - { - } - - bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) - { - switch (trigger->id) - { - case TRIGGER_SOUTH: player->KilledMonsterCredit(NPC_SOUTH_GATE, 0); break; - case TRIGGER_CENTRAL: player->KilledMonsterCredit(NPC_CENTRAL_GATE, 0); break; - case TRIGGER_NORTH: player->KilledMonsterCredit(NPC_NORTH_GATE, 0); break; - case TRIGGER_NORTHWEST: player->KilledMonsterCredit(NPC_NORTHWEST_GATE, 0); break; - } - return true; - } -}; - -/*###### ## at_coilfang_waterfall ######*/ @@ -151,71 +105,6 @@ class AreaTrigger_at_legion_teleporter : public AreaTriggerScript } }; -enum eRavenholdt -{ - QUEST_MANOR_RAVENHOLDT = 6681, - NPC_RAVENHOLDT = 13936 -}; - -class AreaTrigger_at_ravenholdt : public AreaTriggerScript -{ - public: - - AreaTrigger_at_ravenholdt() - : AreaTriggerScript("at_ravenholdt") - { - } - - bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) - { - if (player->GetQuestStatus(QUEST_MANOR_RAVENHOLDT) == QUEST_STATUS_INCOMPLETE) - player->KilledMonsterCredit(NPC_RAVENHOLDT, 0); - - return false; - } -}; - -/*###### -## at_warsong_farms -######*/ - -enum eWarsongFarms -{ - QUEST_THE_WARSONG_FARMS = 11686, - - NPC_CREDIT_SLAUGHTERHOUSE = 25672, - NPC_CREDIT_GRAINERY = 25669, - NPC_CREDIT_TORP_FARM = 25671, - - AT_SLAUGHTERHOUSE = 4873, - AT_GRAINERY = 4871, - AT_TORP_FARM = 4872 -}; - -class AreaTrigger_at_warsong_farms : public AreaTriggerScript -{ - public: - - AreaTrigger_at_warsong_farms() - : AreaTriggerScript("at_warsong_farms") - { - } - - bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) - { - if (!player->isDead() && player->GetQuestStatus(QUEST_THE_WARSONG_FARMS) == QUEST_STATUS_INCOMPLETE) - { - switch (trigger->id) - { - case AT_SLAUGHTERHOUSE: player->KilledMonsterCredit(NPC_CREDIT_SLAUGHTERHOUSE, 0); break; - case AT_GRAINERY: player->KilledMonsterCredit(NPC_CREDIT_GRAINERY, 0); break; - case AT_TORP_FARM: player->KilledMonsterCredit(NPC_CREDIT_TORP_FARM, 0); break; - } - } - return true; - } -}; - /*###### ## at_stormwright_shelf ######*/ @@ -370,11 +259,8 @@ class AreaTrigger_at_sholazar_waygate : public AreaTriggerScript void AddSC_areatrigger_scripts() { - new AreaTrigger_at_aldurthar_gate(); new AreaTrigger_at_coilfang_waterfall(); new AreaTrigger_at_legion_teleporter(); - new AreaTrigger_at_ravenholdt(); - new AreaTrigger_at_warsong_farms(); new AreaTrigger_at_stormwright_shelf(); new AreaTrigger_at_scent_larkorwi(); new AreaTrigger_at_last_rites(); diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index f83b728ee01..3bb969977b6 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -1009,7 +1009,7 @@ public: if (qInfo) { //TODO: prisoner should help player for a short period of time - player->KilledMonsterCredit(qInfo->ReqCreatureOrGOId[0], 0); + player->KilledMonsterCredit(qInfo->RequiredNpcOrGo[0], 0); pPrisoner->DisappearAndDie(); } return true; diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index 816dc25f1b3..f93c4a70d7c 100755 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -300,4 +300,20 @@ void CharacterDatabaseConnection::DoPrepareStatements() // For loading and deleting expired auctions at startup PREPARE_STATEMENT(CHAR_LOAD_EXPIRED_AUCTIONS, "SELECT id, auctioneerguid, itemguid, itemEntry, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid WHERE ah.time <= ?", CONNECTION_SYNCH) + // Player saving + PREPARE_STATEMENT(CHAR_ADD_CHARACTER, "INSERT INTO characters (guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, " + "map, instance_id, instance_mode_mask, position_x, position_y, position_z, orientation, " + "taximask, cinematic, " + "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, " + "extra_flags, stable_slots, at_login, zone, " + "death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, " + "todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, " + "power4, power5, power6, power7, latency, speccount, activespec, exploredZones, equipmentCache, ammoId, knownTitles, actionBars, grantableLevels) VALUES " + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", CONNECTION_ASYNC); + PREPARE_STATEMENT(CHAR_UPD_CHARACTER, "UPDATE characters SET name=?,race=?,class=?,gender=?,level=?,xp=?,money=?,playerBytes=?,playerBytes2=?,playerFlags=?," + "map=?,instance_id=?,instance_mode_mask=?,position_x=?,position_y=?,position_z=?,orientation=?,taximask=?,cinematic=?,totaltime=?,leveltime=?,rest_bonus=?," + "logout_time=?,is_logout_resting=?,resettalents_cost=?,resettalents_time=?,extra_flags=?,stable_slots=?,at_login=?,zone=?,death_expire_time=?,taxi_path=?," + "arenaPoints=?,totalHonorPoints=?,todayHonorPoints=?,yesterdayHonorPoints=?,totalKills=?,todayKills=?,yesterdayKills=?,chosenTitle=?,knownCurrencies=?," + "watchedFaction=?,drunk=?,health=?,power1=?,power2=?,power3=?,power4=?,power5=?,power6=?,power7=?,latency=?,speccount=?,activespec=?,exploredZones=?," + "equipmentCache=?,ammoId=?,knownTitles=?,actionBars=?,grantableLevels=?,online=? WHERE guid=?", CONNECTION_ASYNC); } diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h index dd752914138..f06a17aa924 100755 --- a/src/server/shared/Database/Implementation/CharacterDatabase.h +++ b/src/server/shared/Database/Implementation/CharacterDatabase.h @@ -275,6 +275,9 @@ enum CharacterDatabaseStatements CHAR_LOAD_EXPIRED_AUCTIONS, + CHAR_ADD_CHARACTER, + CHAR_UPD_CHARACTER, + MAX_CHARACTERDATABASE_STATEMENTS, }; diff --git a/src/server/shared/Dynamic/TypeContainer.h b/src/server/shared/Dynamic/TypeContainer.h index 0fb3eb25347..7f6f5fa661c 100755 --- a/src/server/shared/Dynamic/TypeContainer.h +++ b/src/server/shared/Dynamic/TypeContainer.h @@ -108,11 +108,11 @@ class TypeMapContainer } /// Removes the object from the container, and returns the removed object - template<class SPECIFIC_TYPE> bool remove(SPECIFIC_TYPE* obj) - { - SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj); - return (t != NULL); - } + //template<class SPECIFIC_TYPE> bool remove(SPECIFIC_TYPE* obj) + //{ + // SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj); + // return (t != NULL); + //} ContainerMapList<OBJECT_TYPES> & GetElements(void) { return i_elements; } const ContainerMapList<OBJECT_TYPES> & GetElements(void) const { return i_elements;} diff --git a/src/server/shared/Dynamic/TypeContainerFunctions.h b/src/server/shared/Dynamic/TypeContainerFunctions.h index 981cd82197f..9bfbf47da93 100755 --- a/src/server/shared/Dynamic/TypeContainerFunctions.h +++ b/src/server/shared/Dynamic/TypeContainerFunctions.h @@ -62,7 +62,7 @@ namespace Trinity template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Insert(ContainerMapList<SPECIFIC_TYPE> &elements, SPECIFIC_TYPE *obj) { //elements._element[hdl] = obj; - obj->GetGridRef().link(&elements._element, obj); + obj->AddToGrid(elements._element); return obj; }; @@ -84,31 +84,30 @@ namespace Trinity return (t != NULL ? t : Insert(elements._TailElements, obj)); } - // non-const remove method - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<SPECIFIC_TYPE> & /*elements*/, SPECIFIC_TYPE *obj) - { - obj->GetGridRef().unlink(); - return obj; - } - - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/) - { - return NULL; - } - - // this is a missed - template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Remove(ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE * /*obj*/) - { - return NULL; // a missed - } - - template<class SPECIFIC_TYPE, class T, class H> SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T> > &elements, SPECIFIC_TYPE *obj) - { - // The head element is bad - SPECIFIC_TYPE* t = Remove(elements._elements, obj); - return ( t != NULL ? t : Remove(elements._TailElements, obj) ); - } - + //// non-const remove method + //template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<SPECIFIC_TYPE> & /*elements*/, SPECIFIC_TYPE *obj) + //{ + // obj->GetGridRef().unlink(); + // return obj; + //} + + //template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/) + //{ + // return NULL; + //} + + //// this is a missed + //template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Remove(ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE * /*obj*/) + //{ + // return NULL; // a missed + //} + + //template<class SPECIFIC_TYPE, class T, class H> SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T> > &elements, SPECIFIC_TYPE *obj) + //{ + // // The head element is bad + // SPECIFIC_TYPE* t = Remove(elements._elements, obj); + // return ( t != NULL ? t : Remove(elements._TailElements, obj) ); + //} } #endif diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp index 15008f13c10..697e7616c40 100755 --- a/src/server/shared/Logging/Log.cpp +++ b/src/server/shared/Logging/Log.cpp @@ -556,10 +556,10 @@ void Log::outSQLDriver(const char* str, ...) { outTimestamp(sqlLogFile); - va_list ap; - va_start(ap, str); - vfprintf(sqlLogFile, str, ap); - va_end(ap); + va_list apSQL; + va_start(apSQL, str); + vfprintf(sqlLogFile, str, apSQL); + va_end(apSQL); fprintf(sqlLogFile, "\n"); fflush(sqlLogFile); @@ -646,11 +646,11 @@ void Log::outBasic(const char * str, ...) if (logfile) { outTimestamp(logfile); - va_list ap; - va_start(ap, str); - vfprintf(logfile, str, ap); + va_list ap2; + va_start(ap2, str); + vfprintf(logfile, str, ap2); fprintf(logfile, "\n" ); - va_end(ap); + va_end(ap2); fflush(logfile); } } @@ -690,10 +690,10 @@ void Log::outDetail(const char * str, ...) if (logfile) { outTimestamp(logfile); - va_list ap; - va_start(ap, str); - vfprintf(logfile, str, ap); - va_end(ap); + va_list ap2; + va_start(ap2, str); + vfprintf(logfile, str, ap2); + va_end(ap2); fprintf(logfile, "\n"); fflush(logfile); @@ -720,10 +720,10 @@ void Log::outDebugInLine(const char * str, ...) if (logfile) { - va_list ap; - va_start(ap, str); - vfprintf(logfile, str, ap); - va_end(ap); + va_list ap2; + va_start(ap2, str); + vfprintf(logfile, str, ap2); + va_end(ap2); } } } @@ -742,10 +742,10 @@ void Log::outSQLDev(const char* str, ...) if (sqlDevLogFile) { - va_list ap; - va_start(ap, str); - vfprintf(sqlDevLogFile, str, ap); - va_end(ap); + va_list ap2; + va_start(ap2, str); + vfprintf(sqlDevLogFile, str, ap2); + va_end(ap2); fprintf(sqlDevLogFile, "\n"); fflush(sqlDevLogFile); @@ -790,10 +790,10 @@ void Log::outDebug(DebugLogFilters f, const char * str, ...) if (logfile) { outTimestamp(logfile); - va_list ap; - va_start(ap, str); - vfprintf(logfile, str, ap); - va_end(ap); + va_list ap2; + va_start(ap2, str); + vfprintf(logfile, str, ap2); + va_end(ap2); fprintf(logfile, "\n" ); fflush(logfile); @@ -835,10 +835,10 @@ void Log::outStaticDebug(const char * str, ...) if (logfile) { outTimestamp(logfile); - va_list ap; - va_start(ap, str); - vfprintf(logfile, str, ap); - va_end(ap); + va_list ap2; + va_start(ap2, str); + vfprintf(logfile, str, ap2); + va_end(ap2); fprintf(logfile, "\n" ); fflush(logfile); @@ -900,11 +900,11 @@ void Log::outCommand(uint32 account, const char * str, ...) if (logfile) { outTimestamp(logfile); - va_list ap; - va_start(ap, str); - vfprintf(logfile, str, ap); + va_list ap2; + va_start(ap2, str); + vfprintf(logfile, str, ap2); fprintf(logfile, "\n" ); - va_end(ap); + va_end(ap2); fflush(logfile); } } |