diff options
Diffstat (limited to 'src')
72 files changed, 1229 insertions, 1141 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 29340660435..ffe21536de4 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -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 3005f1f2672..0d76759e1be 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -914,43 +914,43 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId GroupsQueueType::iterator itr_teams[BG_TEAMS_COUNT]; uint8 found = 0; uint8 team = 0; - + for (uint8 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++) { // take the group that joined first - GroupsQueueType::iterator itr = m_QueuedGroups[bracket_id][i].begin(); - for (; itr != m_QueuedGroups[bracket_id][i].end(); ++itr) + 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)->IsInvitedToBGInstanceGUID - && (((*itr)->ArenaMatchmakerRating >= arenaMinRating && (*itr)->ArenaMatchmakerRating <= arenaMaxRating) - || (*itr)->JoinTime < discardTime)) + if (!(*itr2)->IsInvitedToBGInstanceGUID + && (((*itr2)->ArenaMatchmakerRating >= arenaMinRating && (*itr2)->ArenaMatchmakerRating <= arenaMaxRating) + || (*itr2)->JoinTime < discardTime)) { - itr_teams[found++] = itr; + itr_teams[found++] = itr2; team = i; break; } } } - + if (!found) return; - + if (found == 1) { - for (GroupsQueueType::iterator itr = itr_teams[0]; itr != m_QueuedGroups[bracket_id][team].end(); ++itr) + for (GroupsQueueType::iterator itr3 = itr_teams[0]; itr3 != m_QueuedGroups[bracket_id][team].end(); ++itr3) { - if (!(*itr)->IsInvitedToBGInstanceGUID - && (((*itr)->ArenaMatchmakerRating >= arenaMinRating && (*itr)->ArenaMatchmakerRating <= arenaMaxRating) - || (*itr)->JoinTime < discardTime) - && (*itr_teams[0])->ArenaTeamId != (*itr)->ArenaTeamId) + if (!(*itr3)->IsInvitedToBGInstanceGUID + && (((*itr3)->ArenaMatchmakerRating >= arenaMinRating && (*itr3)->ArenaMatchmakerRating <= arenaMaxRating) + || (*itr3)->JoinTime < discardTime) + && (*itr_teams[0])->ArenaTeamId != (*itr3)->ArenaTeamId) { - itr_teams[found++] = itr; + itr_teams[found++] = itr3; break; } } - } - + } + //if we have 2 teams, then start new arena and invite players! if (found == 2) { @@ -962,14 +962,14 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId sLog->outError("BattlegroundQueue::Update couldn't create arena instance for rated arena match!"); return; } - + 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 (aTeam->Team != ALLIANCE) { @@ -981,12 +981,12 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId 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, 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/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/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/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 82e4ffe6769..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); @@ -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; @@ -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 "; + } + + stmt->setString(index++, ss.str()); + stmt->setUInt32(index++, GetUInt32Value(PLAYER_AMMO_ID)); - ss << "',"; + ss.str(""); + for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i) + ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' '; - ss << GetUInt32Value(PLAYER_AMMO_ID) << ", '"; - for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i) - ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' '; + stmt->setString(index++, ss.str()); + stmt->setUInt8(index++, GetByteValue(PLAYER_FIELD_BYTES, 2)); + stmt->setUInt32(index++, m_grantableLevels); - ss << "',"; - ss << uint32(GetByteValue(PLAYER_FIELD_BYTES, 2)); - ss << ","; - ss << uint32(m_grantableLevels); - ss << ')'; + 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 9aad63ccb1b..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; 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 0d7dbf92e50..5a9456be6c8 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1514,8 +1514,8 @@ uint32 Unit::CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo if (GetTypeId() == TYPEID_PLAYER) { - AuraEffectList const& ResIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT); - for (AuraEffectList::const_iterator itr = ResIgnoreAuras.begin(); itr != ResIgnoreAuras.end(); ++itr) + AuraEffectList const& ArPenAuras = GetAuraEffectsByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT); + for (AuraEffectList::const_iterator itr = ArPenAuras.begin(); itr != ArPenAuras.end(); ++itr) { // item neutral spell if ((*itr)->GetSpellInfo()->EquippedItemClass == -1) @@ -1687,12 +1687,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 +1705,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 +1738,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 +1766,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) @@ -3744,13 +3744,13 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* // Cast duration to unsigned to prevent permanent aura's such as Righteous Fury being permanently added to caster 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 { @@ -5242,7 +5242,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: + case CLASS_DEATH_KNIGHT: triggered_spell_id = RAND(39511, 40997, 40998, 41002, 41005, 41011); cooldown_spell_id = 39511; break; @@ -11942,7 +11942,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); @@ -14350,8 +14350,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); @@ -16561,10 +16561,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; } 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 3a1b81b044d..82532e6ae29 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -212,6 +212,7 @@ void ObjectAccessor::RemoveCorpse(Corpse* corpse) } } else + corpse->RemoveFromWorld(); // Critical section @@ -292,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/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index c4df7d647c3..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; 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 9c395a2319c..bd419482b5b 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2451,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; @@ -2459,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) { diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 58db314deaf..9caef8457b8 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -574,7 +574,7 @@ class InstanceMap : public Map 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; diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index 2533096cc22..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,21 +119,27 @@ 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)->CreateInstanceForPlayer(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; @@ -202,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) @@ -281,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/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 6863ef17685..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(); @@ -1409,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()); } 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 90368ae3011..4e45eb2d6c6 100755 --- a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp @@ -72,7 +72,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() } // 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())) 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/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/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 db48f2b8693..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; @@ -6348,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 c85758c3897..c382cb56a62 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -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 bdb912aa8b0..0c3fd957165 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -443,9 +443,10 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s typedef PetIds::value_type PetIdsPair; PetIds petids; - uint8 gender; - uint8 race; - uint8 playerClass; + uint8 gender = GENDER_NONE; + uint8 race = RACE_NONE; + uint8 playerClass = 0; + SQLTransaction trans = CharacterDatabase.BeginTransaction(); while (!feof(fin)) { 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 8bfa010463a..ef4ddf17476 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -126,7 +126,7 @@ public: 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 @@ -140,11 +140,11 @@ public: 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; } @@ -210,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); @@ -219,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 @@ -239,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/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/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/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/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); } } |