diff options
author | Nay <dnpd.dd@gmail.com> | 2012-08-30 23:06:19 +0100 |
---|---|---|
committer | Nay <dnpd.dd@gmail.com> | 2012-08-30 23:06:19 +0100 |
commit | d61f3131fb3b149c5c075dee5507cbed29927a80 (patch) | |
tree | 9ef1d57bbcdcf9ab8f255f7349036f3ef5fb50ff /src | |
parent | 872c239dbe0a0a289ed72b3204986df2a612f546 (diff) | |
parent | e3d9768a50a3b2b700d65e0cc96e697a5c9d22dc (diff) |
Merge remote-tracking branch 'origin/master' into 4.3.4
Conflicts:
src/server/game/Entities/Creature/Creature.cpp
src/server/game/Entities/Player/Player.cpp
src/server/game/Globals/ObjectMgr.cpp
src/server/game/Server/Protocol/Opcodes.h
src/server/scripts/EasternKingdoms/silverpine_forest.cpp
src/server/scripts/Kalimdor/silithus.cpp
src/server/shared/DataStores/DBCFileLoader.h
src/server/shared/Database/Implementation/WorldDatabase.cpp
src/tools/map_extractor/System.cpp
src/tools/map_extractor/dbcfile.cpp
src/tools/vmap4_extractor/adtfile.cpp
src/tools/vmap4_extractor/dbcfile.cpp
src/tools/vmap4_extractor/wdtfile.cpp
Diffstat (limited to 'src')
68 files changed, 447 insertions, 437 deletions
diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index 2ad80c7f62d..d55d2cf02b3 100644 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -196,7 +196,7 @@ const AuthHandler table[] = Patcher PatchesCache; // Constructor - set the N and g values for SRP6 -AuthSocket::AuthSocket(RealmSocket& socket) : socket_(socket) +AuthSocket::AuthSocket(RealmSocket& socket) : socket_(socket), pPatch(NULL) { N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); g.SetDword(7); @@ -946,7 +946,7 @@ bool AuthSocket::_HandleXferResume() { sLog->outDebug(LOG_FILTER_AUTHSERVER, "Entering _HandleXferResume"); // Check packet length and patch existence - if (socket().recv_len() < 9 || !pPatch) + if (socket().recv_len() < 9 || !pPatch) // FIXME: pPatch is never used { sLog->outError(LOG_FILTER_AUTHSERVER, "Error while resuming patch transfer (wrong packet)"); return false; diff --git a/src/server/collision/Maps/MapTree.cpp b/src/server/collision/Maps/MapTree.cpp index 6489ddd7a4f..f35e36d92fd 100644 --- a/src/server/collision/Maps/MapTree.cpp +++ b/src/server/collision/Maps/MapTree.cpp @@ -124,8 +124,8 @@ namespace VMAP return intersectionCallBack.result; } - StaticMapTree::StaticMapTree(uint32 mapID, const std::string &basePath): - iMapID(mapID), iTreeValues(0), iBasePath(basePath) + StaticMapTree::StaticMapTree(uint32 mapID, const std::string &basePath) + : iMapID(mapID), iTreeValues(0), iBasePath(basePath), iIsTiled(false) { if (iBasePath.length() > 0 && iBasePath[iBasePath.length()-1] != '/' && iBasePath[iBasePath.length()-1] != '\\') { diff --git a/src/server/collision/Maps/TileAssembler.cpp b/src/server/collision/Maps/TileAssembler.cpp index 207b652a4d6..8458ffdd5d3 100644 --- a/src/server/collision/Maps/TileAssembler.cpp +++ b/src/server/collision/Maps/TileAssembler.cpp @@ -54,11 +54,8 @@ namespace VMAP //================================================================= TileAssembler::TileAssembler(const std::string& pSrcDirName, const std::string& pDestDirName) + : iSrcDir(pSrcDirName), iDestDir(pDestDirName), iCurrentUniqueNameId(0), iFilterMethod(NULL) { - iCurrentUniqueNameId = 0; - iFilterMethod = NULL; - iSrcDir = pSrcDirName; - iDestDir = pDestDirName; //mkdir(iDestDir); //init(); } diff --git a/src/server/collision/Models/ModelInstance.h b/src/server/collision/Models/ModelInstance.h index 1118b654578..2745628ac7e 100755 --- a/src/server/collision/Models/ModelInstance.h +++ b/src/server/collision/Models/ModelInstance.h @@ -63,7 +63,7 @@ namespace VMAP class ModelInstance: public ModelSpawn { public: - ModelInstance(): iModel(0) {} + ModelInstance(): iModel(0), iInvScale(0.0f) {} ModelInstance(const ModelSpawn &spawn, WorldModel* model); void setUnloaded() { iModel = 0; } bool intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit) const; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 6e5a34e8c33..69ecb1ef581 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -79,6 +79,7 @@ SmartScript::SmartScript() { go = NULL; me = NULL; + trigger = NULL; mEventPhase = 0; mPathId = 0; mTargetStorage = new ObjectListMap(); @@ -92,6 +93,7 @@ SmartScript::SmartScript() meOrigGUID = 0; goOrigGUID = 0; mLastInvoker = 0; + mScriptType = SMART_SCRIPT_TYPE_CREATURE; } SmartScript::~SmartScript() @@ -1117,10 +1119,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } case SMART_ACTION_SUMMON_CREATURE: { - float x, y, z, o; ObjectList* targets = GetTargets(e, unit); if (targets) { + float x, y, z, o; for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { (*itr)->GetPosition(x, y, z, o); @@ -1149,10 +1151,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!GetBaseObject()) break; - float x, y, z, o; ObjectList* targets = GetTargets(e, unit); if (targets) { + float x, y, z, o; for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { if (!IsUnit(*itr)) diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index a40024a81cd..37fd91fcc1b 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -913,7 +913,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) return true; } -bool SmartAIMgr::IsTextValid(SmartScriptHolder const& e, uint32 id) +/*bool SmartAIMgr::IsTextValid(SmartScriptHolder const& e, uint32 id) // unused { bool error = false; uint32 entry = 0; @@ -938,4 +938,4 @@ bool SmartAIMgr::IsTextValid(SmartScriptHolder const& e, uint32 id) return false; } return true; -} +}*/ diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 2a81339a930..b0a3c5b6bb6 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1216,16 +1216,9 @@ enum SmartCastFlags // one line in DB is one event struct SmartScriptHolder { - SmartScriptHolder() - { - timer = 0; - active = false; - runOnce = false; - link = 0; - entryOrGuid = 0; - event_id = 0; - enableTimed = false; - } + SmartScriptHolder() : timer(0), active(false), runOnce(false), link(0), entryOrGuid(0), + event_id(0), enableTimed(false), source_type(SMART_SCRIPT_TYPE_CREATURE) {} + int32 entryOrGuid; SmartScriptType source_type; uint32 event_id; @@ -1437,7 +1430,7 @@ class SmartAIMgr return true; } - bool IsTextValid(SmartScriptHolder const& e, uint32 id); + //bool IsTextValid(SmartScriptHolder const& e, uint32 id); }; #define sSmartScriptMgr ACE_Singleton<SmartAIMgr, ACE_Null_Mutex>::instance() diff --git a/src/server/game/Addons/AddonMgr.h b/src/server/game/Addons/AddonMgr.h index 38338b3980f..fd227b258c5 100755 --- a/src/server/game/Addons/AddonMgr.h +++ b/src/server/game/Addons/AddonMgr.h @@ -25,13 +25,7 @@ struct AddonInfo { AddonInfo(const std::string& name, uint8 enabled, uint32 crc, uint8 state, bool crcOrPubKey) - { - Name = name; - Enabled = enabled; - CRC = crc; - State = state; - UsePublicKeyOrCRC = crcOrPubKey; - } + : Name(name), Enabled(enabled), CRC(crc), State(state), UsePublicKeyOrCRC(crcOrPubKey) {} std::string Name; uint8 Enabled; diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 8ed4375bc41..ee976e0f704 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -157,13 +157,13 @@ bool Battlefield::Update(uint32 diff) if (m_uiKickDontAcceptTimer <= diff) { for (int team = 0; team < 2; team++) - for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); itr++) + for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); ++itr) if ((*itr).second <= time(NULL)) KickPlayerFromBattlefield((*itr).first); InvitePlayersInZoneToWar(); for (int team = 0; team < 2; team++) - for (PlayerTimerMap::iterator itr = m_PlayersWillBeKick[team].begin(); itr != m_PlayersWillBeKick[team].end(); itr++) + for (PlayerTimerMap::iterator itr = m_PlayersWillBeKick[team].begin(); itr != m_PlayersWillBeKick[team].end(); ++itr) if ((*itr).second <= time(NULL)) KickPlayerFromBattlefield((*itr).first); @@ -864,7 +864,8 @@ BfCapturePoint::BfCapturePoint(Battlefield* battlefield) : m_Bf(battlefield), m_ { m_team = TEAM_NEUTRAL; m_value = 0; - m_maxValue = 0; + m_minValue = 0.0f; + m_maxValue = 0.0f; m_State = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL; m_OldState = BF_CAPTUREPOINT_OBJECTIVESTATE_NEUTRAL; m_capturePointEntry = 0; diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 97e7bb5bef2..09783176094 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -1084,10 +1084,12 @@ WintergraspCapturePoint::WintergraspCapturePoint(BattlefieldWG* battlefield, Tea { m_Bf = battlefield; m_team = teamInControl; + m_Workshop = NULL; } void WintergraspCapturePoint::ChangeTeam(TeamId /*oldTeam*/) { + ASSERT(m_Workshop); m_Workshop->GiveControlTo(m_team, false); } diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index 61b15bdd182..e88c501398e 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -24,16 +24,9 @@ #include "ArenaTeamMgr.h" ArenaTeam::ArenaTeam() + : TeamId(0), Type(0), TeamName(), CaptainGuid(0), BackgroundColor(0), EmblemStyle(0), EmblemColor(0), + BorderStyle(0), BorderColor(0) { - TeamId = 0; - Type = 0; - TeamName = ""; - CaptainGuid = 0; - BackgroundColor = 0; - EmblemStyle = 0; - EmblemColor = 0; - BorderStyle = 0; - BorderColor = 0; Stats.WeekGames = 0; Stats.SeasonGames = 0; Stats.Rank = 0; @@ -343,7 +336,7 @@ void ArenaTeam::Disband(WorldSession* session) // Broadcast update if (session) { - BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName().c_str(), GetName(), ""); + BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName(), GetName(), ""); if (Player* player = session->GetPlayer()) sLog->outInfo(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", player->GetName(), player->GetGUIDLow(), GetType(), GetId()); diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index c0560ee0e27..bbb9870338c 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -47,8 +47,8 @@ class ChatHandler { public: WorldSession* GetSession() { return m_session; } - explicit ChatHandler(WorldSession* session) : m_session(session) {} - explicit ChatHandler(Player* player) : m_session(player->GetSession()) {} + explicit ChatHandler(WorldSession* session) : m_session(session), sentErrorMessage(false) {} + explicit ChatHandler(Player* player) : m_session(player->GetSession()), sentErrorMessage(false) {} virtual ~ChatHandler() {} static void FillMessageData(WorldPacket* data, WorldSession* session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit* speaker, const char* addonPrefix = NULL); @@ -126,7 +126,7 @@ class ChatHandler bool ShowHelpForCommand(ChatCommand* table, const char* cmd); protected: - explicit ChatHandler() : m_session(NULL) {} // for CLI subclass + explicit ChatHandler() : m_session(NULL), sentErrorMessage(false) {} // for CLI subclass static bool SetDataForCommandInTable(ChatCommand* table, const char* text, uint32 security, std::string const& help, std::string const& fullcommand); bool ExecuteCommandInTable(ChatCommand* table, const char* text, const std::string& fullcmd); bool ShowHelpForSubCommands(ChatCommand* table, char const* cmd, char const* subcmd); diff --git a/src/server/game/Combat/UnitEvents.h b/src/server/game/Combat/UnitEvents.h index de60491de89..07d8b20af52 100755 --- a/src/server/game/Combat/UnitEvents.h +++ b/src/server/game/Combat/UnitEvents.h @@ -123,8 +123,8 @@ class ThreatManagerEvent : public ThreatRefStatusChangeEvent private: ThreatContainer* iThreatContainer; public: - ThreatManagerEvent(uint32 pType) : ThreatRefStatusChangeEvent(pType) {} - ThreatManagerEvent(uint32 pType, HostileReference* pHostileReference) : ThreatRefStatusChangeEvent(pType, pHostileReference) {} + ThreatManagerEvent(uint32 pType) : ThreatRefStatusChangeEvent(pType), iThreatContainer(NULL) {} + ThreatManagerEvent(uint32 pType, HostileReference* pHostileReference) : ThreatRefStatusChangeEvent(pType, pHostileReference), iThreatContainer(NULL) {} void setThreatContainer(ThreatContainer* pThreatContainer) { iThreatContainer = pThreatContainer; } diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index ab3c6aba791..d1db3d9577c 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -867,7 +867,6 @@ void ConditionMgr::LoadConditions(bool isReload) valid = true; ++count; continue; // do not add to m_AllocatedMemory to avoid double deleting - break; } case CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET: valid = addToSpellImplicitTargetConditions(cond); diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index 653a731b5b2..3e7dfc125f9 100755 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -26,8 +26,7 @@ #include "GossipDef.h" #include "World.h" -Corpse::Corpse(CorpseType type) : WorldObject(type != CORPSE_BONES) -, m_type(type) +Corpse::Corpse(CorpseType type) : WorldObject(type != CORPSE_BONES), m_type(type) { m_objectType |= TYPEMASK_CORPSE; m_objectTypeId = TYPEID_CORPSE; @@ -39,6 +38,7 @@ Corpse::Corpse(CorpseType type) : WorldObject(type != CORPSE_BONES) m_time = time(NULL); lootForBody = false; + lootRecipient = NULL; } Corpse::~Corpse() diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 6e2fc197a5f..6270b3b64c0 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -381,7 +381,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData* data) SetAttackTime(RANGED_ATTACK, cInfo->rangeattacktime); SetUInt32Value(UNIT_FIELD_FLAGS, unit_flags); - SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); + SetUInt32Value(UNIT_FIELD_FLAGS_2, cInfo->unit_flags2); SetUInt32Value(UNIT_DYNAMIC_FLAGS, dynamicflags); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 14a680d62d1..669d8461d34 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -112,6 +112,7 @@ struct CreatureTemplate uint32 rangeattacktime; uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures. uint32 unit_flags; // enum UnitFlags mask values + uint32 unit_flags2; // enum UnitFlags2 mask values uint32 dynamicflags; uint32 family; // enum CreatureFamily values (optional) uint32 trainer_type; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 18ed5632793..db0903832c0 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1419,7 +1419,8 @@ void GameObject::Use(Unit* user) // full amount unique participants including original summoner if (GetUniqueUseCount() == info->summoningRitual.reqParticipants) { - spellCaster = m_ritualOwner ? m_ritualOwner : spellCaster; + if (m_ritualOwner) + spellCaster = m_ritualOwner; spellId = info->summoningRitual.spellId; diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 3eb9aabab14..faa91c2672a 100755 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -1039,7 +1039,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player) if (count > pProto->GetMaxStackSize()) count = pProto->GetMaxStackSize(); - ASSERT(count !=0 && "pProto->Stackable == 0 but checked at loading already"); + ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already"); Item* pItem = NewItemOrBag(pProto); if (pItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), item, player)) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 2ccb5b68bca..4b4bcfd019a 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1916,10 +1916,10 @@ bool WorldObject::canSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo if (obj->IsAlwaysVisibleFor(this) || CanAlwaysSee(obj)) return true; - bool corpseCheck = false; bool corpseVisibility = false; if (distanceCheck) { + bool corpseCheck = false; if (Player const* thisPlayer = ToPlayer()) { if (thisPlayer->isDead() && thisPlayer->GetHealth() > 0 && // Cheap way to check for ghost state diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index b79ecff7f96..9edf161b8de 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7336,7 +7336,6 @@ bool Player::HasCurrency(uint32 id, uint32 count) const PlayerCurrenciesMap::const_iterator itr = m_currencies.find(id); return itr != m_currencies.end() && itr->second.totalCount >= count; } - void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/) { if (!count) @@ -7378,7 +7377,6 @@ void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/) newTotalCount = int32(currency->TotalCap); newWeekCount -= delta; } - // TODO: fix conquest points uint32 weekCap = _GetCurrencyWeekCap(currency); if (weekCap && int32(weekCap) < newTotalCount) @@ -15552,7 +15550,6 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg) { uint32 srcItemId = quest->GetSrcItemId(); ItemTemplate const* item = sObjectMgr->GetItemTemplate(srcItemId); - bool destroyItem = true; if (srcItemId > 0) { @@ -15572,6 +15569,7 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg) return false; } + bool destroyItem = true; for (uint8 n = 0; n < QUEST_ITEM_OBJECTIVES_COUNT; ++n) if (item->StartQuest == questId && srcItemId == quest->RequiredItemId[n]) destroyItem = false; @@ -16990,7 +16988,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) SetUInt64Value(PLAYER_FARSIGHT, 0); SetCreatorGUID(0); - RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); + RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVEMENT); // reset some aura modifiers before aura apply SetUInt32Value(PLAYER_TRACK_CREATURES, 0); @@ -17416,8 +17414,8 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) { uint32 zoneId = GetZoneId(); - std::map<uint64, Bag*> bagMap; // fast guid lookup for bags - std::map<uint64, Item*> invalidBagMap; // fast guid lookup for bags + std::map<uint32, Bag*> bagMap; // fast guid lookup for bags + std::map<uint32, Item*> invalidBagMap; // fast guid lookup for bags std::list<Item*> problematicItems; SQLTransaction trans = CharacterDatabase.BeginTransaction(); @@ -17476,7 +17474,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) { item->SetSlot(NULL_SLOT); // Item is in the bag, find the bag - std::map<uint64, Bag*>::iterator itr = bagMap.find(bagGuid); + std::map<uint32, Bag*>::iterator itr = bagMap.find(bagGuid); if (itr != bagMap.end()) { ItemPosCountVec dest; @@ -17486,8 +17484,8 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) } else if (invalidBagMap.find(bagGuid) != invalidBagMap.end()) { - std::map<uint64, Item*>::iterator itr = invalidBagMap.find(bagGuid); - if (std::find(problematicItems.begin(),problematicItems.end(),itr->second) != problematicItems.end()) + std::map<uint32, Item*>::iterator itr = invalidBagMap.find(bagGuid); + if (std::find(problematicItems.begin(), problematicItems.end(), itr->second) != problematicItems.end()) err = EQUIP_ERR_INTERNAL_BAG_ERROR; } else @@ -17583,7 +17581,6 @@ void Player::_LoadVoidStorage(PreparedQueryResult result) Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields) { - PreparedStatement* stmt = NULL; Item* item = NULL; uint32 itemGuid = fields[13].GetUInt32(); uint32 itemEntry = fields[14].GetUInt32(); @@ -17593,6 +17590,8 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F item = NewItemOrBag(proto); if (item->LoadFromDB(itemGuid, GetGUID(), fields, itemEntry)) { + PreparedStatement* stmt = NULL; + // Do not allow to have item limited to another map/zone in alive state if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(), zoneId)) { diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 09c7e0ff2a1..f058b35fb5a 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -115,7 +115,7 @@ struct PlayerTalent // Spell modifier (used for modify other spells) struct SpellModifier { - SpellModifier(Aura* _ownerAura = NULL) : charges(0), ownerAura(_ownerAura) {} + SpellModifier(Aura* _ownerAura = NULL) : op(SPELLMOD_DAMAGE), type(SPELLMOD_FLAT), charges(0), value(0), mask(), spellId(0), ownerAura(_ownerAura) {} SpellModOp op : 8; SpellModType type : 8; int16 charges : 16; diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 3c7d13070fa..99a40d6110f 100755 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -54,24 +54,12 @@ struct FriendInfo uint8 Class; std::string Note; - FriendInfo() + FriendInfo() : Status(FRIEND_STATUS_OFFLINE), Flags(0), Area(0), Level(0), Class(0), Note() { - Status = FRIEND_STATUS_OFFLINE; - Flags = 0; - Area = 0; - Level = 0; - Class = 0; - Note = ""; } - FriendInfo(uint8 flags, const std::string& note) + FriendInfo(uint8 flags, const std::string& note) : Status(FRIEND_STATUS_OFFLINE), Flags(flags), Area(0), Level(0), Class(0), Note(note) { - Status = FRIEND_STATUS_OFFLINE; - Flags = flags; - Area = 0; - Level = 0; - Class = 0; - Note = note; } }; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 76644b1aa99..1db8b93f9ee 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -159,7 +159,7 @@ m_movedPlayer(NULL), m_lastSanctuaryTime(0), IsAIEnabled(false), NeedChangeAI(fa m_ControlledByPlayer(false), movespline(new Movement::MoveSpline()), i_AI(NULL), i_disabledAI(NULL), m_procDeep(0), m_removedAurasCount(0), i_motionMaster(this), m_ThreatManager(this), m_vehicle(NULL), m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), -m_HostileRefManager(this) +m_HostileRefManager(this), m_TempSpeed(0.0f), m_AutoRepeatFirstCast(false) { #ifdef _MSC_VER #pragma warning(default:4355) @@ -13066,7 +13066,8 @@ void Unit::DeleteCharmInfo() CharmInfo::CharmInfo(Unit* unit) : m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_petnumber(0), m_barInit(false), - m_isCommandAttack(false), m_isAtStay(false), m_isFollowing(false), m_isReturning(false) + m_isCommandAttack(false), m_isAtStay(false), m_isFollowing(false), m_isReturning(false), + m_stayX(0.0f), m_stayY(0.0f), m_stayZ(0.0f) { for (uint8 i = 0; i < MAX_SPELL_CHARM; ++i) m_charmspells[i].SetActionAndType(0, ACT_DISABLED); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 9dcb981c95a..d5bfaff5e87 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -623,17 +623,24 @@ enum UnitFlags // Value masks for UNIT_FIELD_FLAGS_2 enum UnitFlags2 { - UNIT_FLAG2_FEIGN_DEATH = 0x00000001, - UNIT_FLAG2_UNK1 = 0x00000002, // Hide unit model (show only player equip) - UNIT_FLAG2_IGNORE_REPUTATION = 0x00000004, - UNIT_FLAG2_COMPREHEND_LANG = 0x00000008, - UNIT_FLAG2_MIRROR_IMAGE = 0x00000010, - UNIT_FLAG2_FORCE_MOVE = 0x00000040, - UNIT_FLAG2_DISARM_OFFHAND = 0x00000080, - UNIT_FLAG2_DISARM_RANGED = 0x00000400, // this does not disable ranged weapon display (maybe additional flag needed?) - UNIT_FLAG2_REGENERATE_POWER = 0x00000800, - UNIT_FLAG2_ALLOW_ENEMY_INTERACT = 0x00004000, - UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000, // allows casting spells with AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL + UNIT_FLAG2_FEIGN_DEATH = 0x00000001, + UNIT_FLAG2_UNK1 = 0x00000002, // Hide unit model (show only player equip) + UNIT_FLAG2_IGNORE_REPUTATION = 0x00000004, + UNIT_FLAG2_COMPREHEND_LANG = 0x00000008, + UNIT_FLAG2_MIRROR_IMAGE = 0x00000010, + UNIT_FLAG2_INSTANTLY_APPEAR_MODEL = 0x00000020, // Unit model instantly appears when summoned (does not fade in) + UNIT_FLAG2_FORCE_MOVEMENT = 0x00000040, + UNIT_FLAG2_DISARM_OFFHAND = 0x00000080, + UNIT_FLAG2_DISABLE_PRED_STATS = 0x00000100, // Player has disabled predicted stats (Used by raid frames) + UNIT_FLAG2_DISARM_RANGED = 0x00000400, // this does not disable ranged weapon display (maybe additional flag needed?) + UNIT_FLAG2_REGENERATE_POWER = 0x00000800, + UNIT_FLAG2_RESTRICT_PARTY_INTERACTION = 0x00001000, // Restrict interaction to party or raid + UNIT_FLAG2_PREVENT_SPELL_CLICK = 0x00002000, // Prevent spellclick + UNIT_FLAG2_ALLOW_ENEMY_INTERACT = 0x00004000, + UNIT_FLAG2_DISABLE_TURN = 0x00008000, + UNIT_FLAG2_UNK2 = 0x00010000, + UNIT_FLAG2_PLAY_DEATH_ANIM = 0x00020000, // Plays special death animation upon death + UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000, // Allows casting spells with AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL }; /// Non Player Character flags diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index b87cb2d7fbf..8a0242fe865 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -369,17 +369,17 @@ void ObjectMgr::LoadCreatureTemplates() QueryResult result = WorldDatabase.Query("SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, " // 9 10 11 12 13 14 15 16 17 18 19 20 21 "modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, exp_unk, faction_A, faction_H, npcflag, speed_walk, " - // 22 23 24 25 26 27 28 29 30 31 32 33 - "speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, " - // 34 35 36 37 38 39 40 41 42 43 + // 22 23 24 25 26 27 28 29 30 31 32 33 34 + "speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, unit_flags2 " + // 35 36 37 38 39 40 41 42 43 44 "dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, " - // 44 45 46 47 48 49 50 51 52 53 54 + // 45 46 47 48 49 50 51 52 53 54 55 "type_flags, type_flags2, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, " - // 55 56 57 58 59 60 61 62 63 64 65 66 67 68 + // 56 57 58 59 60 61 62 63 64 65 66 67 68 69 "spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, " - // 69 70 71 72 73 74 75 76 77 78 79 80 + // 70 71 72 73 74 75 76 77 78 79 80 81 "InhabitType, HoverHeight, Health_mod, Mana_mod, Mana_mod_extra, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, " - // 81 82 83 84 85 86 87 + // 82 83 84 85 86 87 88 " questItem6, movementId, RegenHealth, equipment_id, mechanic_immune_mask, flags_extra, ScriptName " "FROM creature_template;"); @@ -436,51 +436,52 @@ void ObjectMgr::LoadCreatureTemplates() creatureTemplate.rangeattacktime = fields[31].GetUInt32(); creatureTemplate.unit_class = uint32(fields[32].GetUInt8()); creatureTemplate.unit_flags = fields[33].GetUInt32(); - creatureTemplate.dynamicflags = fields[34].GetUInt32(); - creatureTemplate.family = uint32(fields[35].GetUInt8()); - creatureTemplate.trainer_type = uint32(fields[36].GetUInt8()); - creatureTemplate.trainer_spell = fields[37].GetUInt32(); - creatureTemplate.trainer_class = uint32(fields[38].GetUInt8()); - creatureTemplate.trainer_race = uint32(fields[39].GetUInt8()); - creatureTemplate.minrangedmg = fields[40].GetFloat(); - creatureTemplate.maxrangedmg = fields[41].GetFloat(); - creatureTemplate.rangedattackpower = uint32(fields[42].GetUInt16()); - creatureTemplate.type = uint32(fields[43].GetUInt8()); - creatureTemplate.type_flags = fields[44].GetUInt32(); - creatureTemplate.type_flags2 = fields[45].GetUInt32(); - creatureTemplate.lootid = fields[46].GetUInt32(); - creatureTemplate.pickpocketLootId = fields[47].GetUInt32(); - creatureTemplate.SkinLootId = fields[48].GetUInt32(); + creatureTemplate.unit_flags2 = fields[34].GetUInt32(); + creatureTemplate.dynamicflags = fields[35].GetUInt32(); + creatureTemplate.family = uint32(fields[36].GetUInt8()); + creatureTemplate.trainer_type = uint32(fields[37].GetUInt8()); + creatureTemplate.trainer_spell = fields[38].GetUInt32(); + creatureTemplate.trainer_class = uint32(fields[39].GetUInt8()); + creatureTemplate.trainer_race = uint32(fields[40].GetUInt8()); + creatureTemplate.minrangedmg = fields[41].GetFloat(); + creatureTemplate.maxrangedmg = fields[42].GetFloat(); + creatureTemplate.rangedattackpower = uint32(fields[43].GetUInt16()); + creatureTemplate.type = uint32(fields[44].GetUInt8()); + creatureTemplate.type_flags = fields[45].GetUInt32(); + creatureTemplate.type_flags2 = fields[46].GetUInt32(); + creatureTemplate.lootid = fields[47].GetUInt32(); + creatureTemplate.pickpocketLootId = fields[48].GetUInt32(); + creatureTemplate.SkinLootId = fields[49].GetUInt32(); for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) - creatureTemplate.resistance[i] = fields[49 + i - 1].GetInt16(); + creatureTemplate.resistance[i] = fields[50 + i - 1].GetInt16(); for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i) - creatureTemplate.spells[i] = fields[55 + i].GetUInt32(); - - creatureTemplate.PetSpellDataId = fields[63].GetUInt32(); - creatureTemplate.VehicleId = fields[64].GetUInt32(); - creatureTemplate.mingold = fields[65].GetUInt32(); - creatureTemplate.maxgold = fields[66].GetUInt32(); - creatureTemplate.AIName = fields[67].GetString(); - creatureTemplate.MovementType = uint32(fields[68].GetUInt8()); - creatureTemplate.InhabitType = uint32(fields[69].GetUInt8()); - creatureTemplate.HoverHeight = fields[70].GetFloat(); - creatureTemplate.ModHealth = fields[71].GetFloat(); - creatureTemplate.ModMana = fields[72].GetFloat(); - creatureTemplate.ModManaExtra = fields[73].GetFloat(); - creatureTemplate.ModArmor = fields[74].GetFloat(); - creatureTemplate.RacialLeader = fields[75].GetBool(); + creatureTemplate.spells[i] = fields[56 + i].GetUInt32(); + + creatureTemplate.PetSpellDataId = fields[64].GetUInt32(); + creatureTemplate.VehicleId = fields[65].GetUInt32(); + creatureTemplate.mingold = fields[66].GetUInt32(); + creatureTemplate.maxgold = fields[67].GetUInt32(); + creatureTemplate.AIName = fields[68].GetString(); + creatureTemplate.MovementType = uint32(fields[69].GetUInt8()); + creatureTemplate.InhabitType = uint32(fields[70].GetUInt8()); + creatureTemplate.HoverHeight = fields[71].GetFloat(); + creatureTemplate.ModHealth = fields[72].GetFloat(); + creatureTemplate.ModMana = fields[73].GetFloat(); + creatureTemplate.ModManaExtra = fields[74].GetFloat(); + creatureTemplate.ModArmor = fields[75].GetFloat(); + creatureTemplate.RacialLeader = fields[76].GetBool(); for (uint8 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i) - creatureTemplate.questItems[i] = fields[76 + i].GetUInt32(); + creatureTemplate.questItems[i] = fields[77 + i].GetUInt32(); - creatureTemplate.movementId = fields[82].GetUInt32(); - creatureTemplate.RegenHealth = fields[83].GetBool(); - creatureTemplate.equipmentId = fields[84].GetUInt32(); - creatureTemplate.MechanicImmuneMask = fields[85].GetUInt32(); - creatureTemplate.flags_extra = fields[86].GetUInt32(); - creatureTemplate.ScriptID = GetScriptId(fields[87].GetCString()); + creatureTemplate.movementId = fields[83].GetUInt32(); + creatureTemplate.RegenHealth = fields[84].GetBool(); + creatureTemplate.equipmentId = fields[85].GetUInt32(); + creatureTemplate.MechanicImmuneMask = fields[86].GetUInt32(); + creatureTemplate.flags_extra = fields[87].GetUInt32(); + creatureTemplate.ScriptID = GetScriptId(fields[88].GetCString()); ++count; } @@ -7875,8 +7876,6 @@ void ObjectMgr::LoadTrainerSpell() // For reload case _cacheTrainerSpellStore.clear(); - std::set<uint32> skip_trainers; - QueryResult result = WorldDatabase.Query("SELECT b.entry, a.spell, a.spellcost, a.reqskill, a.reqskillvalue, a.reqlevel FROM npc_trainer AS a " "INNER JOIN npc_trainer AS b ON a.entry = -(b.spell) " "UNION SELECT * FROM npc_trainer WHERE spell > 0"); diff --git a/src/server/game/Grids/NGrid.h b/src/server/game/Grids/NGrid.h index b5701a7a590..6bf558a4d5e 100755 --- a/src/server/game/Grids/NGrid.h +++ b/src/server/game/Grids/NGrid.h @@ -79,9 +79,8 @@ class NGrid public: typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> GridType; NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true) - : i_gridId(id), i_x(x), i_y(y), i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false) + : i_gridId(id), i_x(x), i_y(y), i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false), i_GridInfo(GridInfo(expiry, unload)) { - i_GridInfo = GridInfo(expiry, unload); } GridType& GetGridType(const uint32 x, const uint32 y) diff --git a/src/server/game/Handlers/AddonHandler.cpp b/src/server/game/Handlers/AddonHandler.cpp index f86dacbc55e..c3ffeace3fb 100755 --- a/src/server/game/Handlers/AddonHandler.cpp +++ b/src/server/game/Handlers/AddonHandler.cpp @@ -37,26 +37,6 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target) uint32 CurrentPosition; uint32 TempValue; - unsigned char tdata[256] = - { - 0xC3, 0x5B, 0x50, 0x84, 0xB9, 0x3E, 0x32, 0x42, 0x8C, 0xD0, 0xC7, 0x48, 0xFA, 0x0E, 0x5D, 0x54, - 0x5A, 0xA3, 0x0E, 0x14, 0xBA, 0x9E, 0x0D, 0xB9, 0x5D, 0x8B, 0xEE, 0xB6, 0x84, 0x93, 0x45, 0x75, - 0xFF, 0x31, 0xFE, 0x2F, 0x64, 0x3F, 0x3D, 0x6D, 0x07, 0xD9, 0x44, 0x9B, 0x40, 0x85, 0x59, 0x34, - 0x4E, 0x10, 0xE1, 0xE7, 0x43, 0x69, 0xEF, 0x7C, 0x16, 0xFC, 0xB4, 0xED, 0x1B, 0x95, 0x28, 0xA8, - 0x23, 0x76, 0x51, 0x31, 0x57, 0x30, 0x2B, 0x79, 0x08, 0x50, 0x10, 0x1C, 0x4A, 0x1A, 0x2C, 0xC8, - 0x8B, 0x8F, 0x05, 0x2D, 0x22, 0x3D, 0xDB, 0x5A, 0x24, 0x7A, 0x0F, 0x13, 0x50, 0x37, 0x8F, 0x5A, - 0xCC, 0x9E, 0x04, 0x44, 0x0E, 0x87, 0x01, 0xD4, 0xA3, 0x15, 0x94, 0x16, 0x34, 0xC6, 0xC2, 0xC3, - 0xFB, 0x49, 0xFE, 0xE1, 0xF9, 0xDA, 0x8C, 0x50, 0x3C, 0xBE, 0x2C, 0xBB, 0x57, 0xED, 0x46, 0xB9, - 0xAD, 0x8B, 0xC6, 0xDF, 0x0E, 0xD6, 0x0F, 0xBE, 0x80, 0xB3, 0x8B, 0x1E, 0x77, 0xCF, 0xAD, 0x22, - 0xCF, 0xB7, 0x4B, 0xCF, 0xFB, 0xF0, 0x6B, 0x11, 0x45, 0x2D, 0x7A, 0x81, 0x18, 0xF2, 0x92, 0x7E, - 0x98, 0x56, 0x5D, 0x5E, 0x69, 0x72, 0x0A, 0x0D, 0x03, 0x0A, 0x85, 0xA2, 0x85, 0x9C, 0xCB, 0xFB, - 0x56, 0x6E, 0x8F, 0x44, 0xBB, 0x8F, 0x02, 0x22, 0x68, 0x63, 0x97, 0xBC, 0x85, 0xBA, 0xA8, 0xF7, - 0xB5, 0x40, 0x68, 0x3C, 0x77, 0x86, 0x6F, 0x4B, 0xD7, 0x88, 0xCA, 0x8A, 0xD7, 0xCE, 0x36, 0xF0, - 0x45, 0x6E, 0xD5, 0x64, 0x79, 0x0F, 0x17, 0xFC, 0x64, 0xDD, 0x10, 0x6F, 0xF3, 0xF5, 0xE0, 0xA6, - 0xC3, 0xFB, 0x1B, 0x8C, 0x29, 0xEF, 0x8E, 0xE5, 0x34, 0xCB, 0xD1, 0x2A, 0xCE, 0x79, 0xC3, 0x9A, - 0x0D, 0x36, 0xEA, 0x01, 0xE0, 0xAA, 0x91, 0x20, 0x54, 0xF0, 0x72, 0xD8, 0x1E, 0xC7, 0x89, 0xD2 - }; - // broken addon packet, can't be received from real client if (Source->rpos() + 4 > Source->size()) return false; @@ -110,7 +90,28 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target) uint8 unk = (crc != 0x4c1c776d); // If addon is Standard addon CRC *Target << uint8(unk); if (unk) + { + unsigned char tdata[256] = + { + 0xC3, 0x5B, 0x50, 0x84, 0xB9, 0x3E, 0x32, 0x42, 0x8C, 0xD0, 0xC7, 0x48, 0xFA, 0x0E, 0x5D, 0x54, + 0x5A, 0xA3, 0x0E, 0x14, 0xBA, 0x9E, 0x0D, 0xB9, 0x5D, 0x8B, 0xEE, 0xB6, 0x84, 0x93, 0x45, 0x75, + 0xFF, 0x31, 0xFE, 0x2F, 0x64, 0x3F, 0x3D, 0x6D, 0x07, 0xD9, 0x44, 0x9B, 0x40, 0x85, 0x59, 0x34, + 0x4E, 0x10, 0xE1, 0xE7, 0x43, 0x69, 0xEF, 0x7C, 0x16, 0xFC, 0xB4, 0xED, 0x1B, 0x95, 0x28, 0xA8, + 0x23, 0x76, 0x51, 0x31, 0x57, 0x30, 0x2B, 0x79, 0x08, 0x50, 0x10, 0x1C, 0x4A, 0x1A, 0x2C, 0xC8, + 0x8B, 0x8F, 0x05, 0x2D, 0x22, 0x3D, 0xDB, 0x5A, 0x24, 0x7A, 0x0F, 0x13, 0x50, 0x37, 0x8F, 0x5A, + 0xCC, 0x9E, 0x04, 0x44, 0x0E, 0x87, 0x01, 0xD4, 0xA3, 0x15, 0x94, 0x16, 0x34, 0xC6, 0xC2, 0xC3, + 0xFB, 0x49, 0xFE, 0xE1, 0xF9, 0xDA, 0x8C, 0x50, 0x3C, 0xBE, 0x2C, 0xBB, 0x57, 0xED, 0x46, 0xB9, + 0xAD, 0x8B, 0xC6, 0xDF, 0x0E, 0xD6, 0x0F, 0xBE, 0x80, 0xB3, 0x8B, 0x1E, 0x77, 0xCF, 0xAD, 0x22, + 0xCF, 0xB7, 0x4B, 0xCF, 0xFB, 0xF0, 0x6B, 0x11, 0x45, 0x2D, 0x7A, 0x81, 0x18, 0xF2, 0x92, 0x7E, + 0x98, 0x56, 0x5D, 0x5E, 0x69, 0x72, 0x0A, 0x0D, 0x03, 0x0A, 0x85, 0xA2, 0x85, 0x9C, 0xCB, 0xFB, + 0x56, 0x6E, 0x8F, 0x44, 0xBB, 0x8F, 0x02, 0x22, 0x68, 0x63, 0x97, 0xBC, 0x85, 0xBA, 0xA8, 0xF7, + 0xB5, 0x40, 0x68, 0x3C, 0x77, 0x86, 0x6F, 0x4B, 0xD7, 0x88, 0xCA, 0x8A, 0xD7, 0xCE, 0x36, 0xF0, + 0x45, 0x6E, 0xD5, 0x64, 0x79, 0x0F, 0x17, 0xFC, 0x64, 0xDD, 0x10, 0x6F, 0xF3, 0xF5, 0xE0, 0xA6, + 0xC3, 0xFB, 0x1B, 0x8C, 0x29, 0xEF, 0x8E, 0xE5, 0x34, 0xCB, 0xD1, 0x2A, 0xCE, 0x79, 0xC3, 0x9A, + 0x0D, 0x36, 0xEA, 0x01, 0xE0, 0xAA, 0x91, 0x20, 0x54, 0xF0, 0x72, 0xD8, 0x1E, 0xC7, 0x89, 0xD2 + }; Target->append(tdata, sizeof(tdata)); + } *Target << uint32(0); } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index c1510bef543..6b115878135 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2689,7 +2689,7 @@ uint32 InstanceMap::GetMaxResetDelay() const /* ******* Battleground Instance Maps ******* */ BattlegroundMap::BattlegroundMap(uint32 id, time_t expiry, uint32 InstanceId, Map* _parent, uint8 spawnMode) - : Map(id, expiry, InstanceId, spawnMode, _parent) + : Map(id, expiry, InstanceId, spawnMode, _parent), m_bg(NULL) { //lets initialize visibility distance for BG/Arenas BattlegroundMap::InitVisibilityDistance(); diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp index 08e27abf050..7e130a2c143 100755 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp @@ -407,10 +407,6 @@ bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32& time_diff if (i_totalFleeTime.Passed()) return false; - i_totalFleeTime.Update(time_diff); - if (i_totalFleeTime.Passed()) - return false; - // This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, const uint32 &) version // This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly return MovementGeneratorMedium< Creature, FleeingMovementGenerator<Creature> >::Update(owner, time_diff); diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index 4db35d5bc79..5a4d5734929 100755 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -29,8 +29,8 @@ #include "GridNotifiersImpl.h" #include "CellImpl.h" -OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp): -m_capturePointGUID(0), m_capturePoint(NULL), m_maxValue(0), m_maxSpeed(0), +OPvPCapturePoint::OPvPCapturePoint(OutdoorPvP* pvp) : +m_capturePointGUID(0), m_capturePoint(NULL), m_minValue(0.0f), m_maxValue(0.0f), m_maxSpeed(0), m_value(0), m_team(TEAM_NEUTRAL), m_OldState(OBJECTIVESTATE_NEUTRAL), m_State(OBJECTIVESTATE_NEUTRAL), m_neutralValuePct(0), m_PvP(pvp) { diff --git a/src/server/game/Reputation/ReputationMgr.h b/src/server/game/Reputation/ReputationMgr.h index a073845ea73..f950cbb82c2 100755 --- a/src/server/game/Reputation/ReputationMgr.h +++ b/src/server/game/Reputation/ReputationMgr.h @@ -65,7 +65,7 @@ class ReputationMgr { public: // constructors and global modifiers explicit ReputationMgr(Player* owner) : _player(owner), - _visibleFactionCount(0), _honoredFactionCount(0), _reveredFactionCount(0), _exaltedFactionCount(0) {} + _visibleFactionCount(0), _honoredFactionCount(0), _reveredFactionCount(0), _exaltedFactionCount(0), _sendFactionIncreased(false) {} ~ReputationMgr() {} void SaveToDB(SQLTransaction& trans); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index be18785e76e..30614c655fa 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -2913,13 +2913,13 @@ void AuraEffect::HandleForceMoveForward(AuraApplication const* aurApp, uint8 mod Unit* target = aurApp->GetTarget(); if (apply) - target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); + target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVEMENT); else { // do not remove unit flag if there are more than this auraEffect of that kind on unit on unit if (target->HasAuraType(GetAuraType())) return; - target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); + target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVEMENT); } } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 5c5faf9944e..9dd1d30f3ac 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -88,7 +88,7 @@ SpellDestination::SpellDestination(WorldObject const& wObj) } -SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0) +SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0), m_strTarget() { m_objectTarget = NULL; m_itemTarget = NULL; @@ -97,7 +97,6 @@ SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0) m_itemTargetGUID = 0; m_itemTargetEntry = 0; - m_strTarget = ""; m_targetMask = 0; } diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 8840161971a..8396cd8b94c 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -330,10 +330,9 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET) return; - bool apply_direct_bonus = true; - if (unitTarget && unitTarget->isAlive()) { + bool apply_direct_bonus = true; switch (m_spellInfo->SpellFamilyName) { case SPELLFAMILY_GENERIC: diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index dcf3c38fe4f..9c5619ef5f6 100755 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -441,7 +441,7 @@ class PetAura typedef UNORDERED_MAP<uint32, uint32> PetAuraMap; public: - PetAura() + PetAura() : removeOnChangePet(false), damage(0) { auras.clear(); } diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 99ec263b8f9..e3cd185e4a3 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -642,19 +642,13 @@ public: { handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); - // wpCreature - Creature* wpCreature = NULL; - if (wpGuid != 0) - { - wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - if (wpCreature) + if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT))) { wpCreature->CombatStop(); wpCreature->DeleteFromDB(); wpCreature->AddObjectToRemoveList(); } - } PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA); @@ -681,15 +675,12 @@ public: Player* chr = handler->GetSession()->GetPlayer(); Map* map = chr->GetMap(); { - // wpCreature - Creature* wpCreature = NULL; // What to do: // Move the visual spawnpoint // Respawn the owner of the waypoints if (wpGuid != 0) { - wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - if (wpCreature) + if (Creature* wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT))) { wpCreature->CombatStop(); wpCreature->DeleteFromDB(); diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp index 204fbe5223b..25c3f2e41e3 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp @@ -243,11 +243,9 @@ public: std::list<HostileReference*> threatlist = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) { - Unit* unit; if ((*i) && (*i)->getSource()) { - unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); - if (unit) + if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { //Cast affliction DoCast(unit, RAND(SPELL_BROODAF_BLUE, SPELL_BROODAF_BLACK, diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 06c1243645c..533a1aac2f0 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -201,12 +201,11 @@ public: { for (uint8 i = 0; i < 4; ++i) { - Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Creature::GetCreature((*me), AddGUID[i]); - if (Temp && Temp->isAlive()) - Temp->DisappearAndDie(); + Creature* temp = Creature::GetCreature((*me), AddGUID[i]); + if (temp && temp->isAlive()) + temp->DisappearAndDie(); } } } @@ -215,14 +214,13 @@ public: { for (uint8 i = 0; i < 4; ++i) { - Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Creature::GetCreature((*me), AddGUID[i]); - if (Temp && Temp->isAlive()) + Creature* temp = Creature::GetCreature((*me), AddGUID[i]); + if (temp && temp->isAlive()) { - Temp->AI()->AttackStart(me->getVictim()); - DoZoneInCombat(Temp); + temp->AI()->AttackStart(me->getVictim()); + DoZoneInCombat(temp); } else EnterEvadeMode(); } @@ -250,13 +248,12 @@ public: { for (uint8 i = 0; i < 4; ++i) { - Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Unit::GetCreature((*me), AddGUID[i]); - if (Temp && Temp->isAlive()) - if (!Temp->getVictim()) - Temp->AI()->AttackStart(me->getVictim()); + Creature* temp = Unit::GetCreature((*me), AddGUID[i]); + if (temp && temp->isAlive()) + if (!temp->getVictim()) + temp->AI()->AttackStart(me->getVictim()); } } CheckAdds_Timer = 5000; diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp index d4c037d45c3..b405f9eba85 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp @@ -240,7 +240,6 @@ public: return; Creature* pArchmage = instance->GetCreature(uiArchmageArugalGUID); - Creature* summon = NULL; if (!pArchmage || !pArchmage->isAlive()) return; @@ -252,7 +251,8 @@ public: switch (uiPhase) { case 1: - summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000); + { + Creature* summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000); summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); summon->SetReactState(REACT_DEFENSIVE); summon->CastSpell(summon, SPELL_ASHCROMBE_TELEPORT, true); @@ -260,13 +260,16 @@ public: uiTimer = 2000; uiPhase = 2; break; + } case 2: + { pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); uiPhase = 0; break; + } } } else uiTimer -= uiDiff; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp index 1009d3e0a0a..8fb3dd55077 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp @@ -315,14 +315,12 @@ class boss_zuljin : public CreatureScript { for (uint8 i = 0; i < 4; ++i) { - Unit* Temp = NULL; if (SpiritGUID[i]) { - Temp = Unit::GetUnit(*me, SpiritGUID[i]); - if (Temp) + if (Unit* temp = Unit::GetUnit(*me, SpiritGUID[i])) { - Temp->SetVisible(false); - Temp->setDeathState(DEAD); + temp->SetVisible(false); + temp->setDeathState(DEAD); } } SpiritGUID[i] = 0; diff --git a/src/server/scripts/EasternKingdoms/wetlands.cpp b/src/server/scripts/EasternKingdoms/wetlands.cpp index fac8fb51c2d..34e6e7c9ddf 100644 --- a/src/server/scripts/EasternKingdoms/wetlands.cpp +++ b/src/server/scripts/EasternKingdoms/wetlands.cpp @@ -60,12 +60,12 @@ public: { npc_tapoke_slim_jahnAI(Creature* creature) : npc_escortAI(creature) { } - bool m_bFriendSummoned; + bool IsFriendSummoned; void Reset() { if (!HasEscortState(STATE_ESCORT_ESCORTING)) - m_bFriendSummoned = false; + IsFriendSummoned = false; } void WaypointReached(uint32 waypointId) @@ -83,14 +83,12 @@ public: void EnterCombat(Unit* /*who*/) { - Player* player = GetPlayerForEscort(); - - if (HasEscortState(STATE_ESCORT_ESCORTING) && !m_bFriendSummoned && player) + if (HasEscortState(STATE_ESCORT_ESCORTING) && !IsFriendSummoned && GetPlayerForEscort()) { for (uint8 i = 0; i < 3; ++i) DoCast(me, SPELL_CALL_FRIENDS, true); - m_bFriendSummoned = true; + IsFriendSummoned = true; } } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp index 5b6dc784113..ee7ef383603 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp @@ -222,11 +222,9 @@ public: ItemPosCountVec dest; uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, ITEM_TEAR_OF_GODDESS, 1); if (msg == EQUIP_ERR_OK) - { - Item* item = player->StoreNewItem(dest, ITEM_TEAR_OF_GODDESS, true); - if (item && player) + if (Item* item = player->StoreNewItem(dest, ITEM_TEAR_OF_GODDESS, true)) player->SendNewItem(item, 1, true, false, true); - } + player->SEND_GOSSIP_MENU(907, creature->GetGUID()); } return true; diff --git a/src/server/scripts/Kalimdor/silithus.cpp b/src/server/scripts/Kalimdor/silithus.cpp index 1636c867b30..44a68355a4e 100644 --- a/src/server/scripts/Kalimdor/silithus.cpp +++ b/src/server/scripts/Kalimdor/silithus.cpp @@ -224,6 +224,8 @@ public: }; + Unit* mob = NULL; + Unit* target = NULL; /*### ## go_wind_stone diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp index 2ea234775c0..d335d36e112 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp @@ -314,15 +314,14 @@ class boss_gothik : public CreatureScript bool CheckGroupSplitted() { - bool checklife = false; - bool checkdead = false; - Map* map = me->GetMap(); if (map && map->IsDungeon()) { Map::PlayerList const &PlayerList = map->GetPlayers(); if (!PlayerList.isEmpty()) { + bool checklife = false; + bool checkdead = false; for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { if (i->getSource() && i->getSource()->isAlive() && diff --git a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp index 1b2fe61e87c..ec25a8f9f60 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp @@ -248,11 +248,9 @@ public: { for (uint8 i = 0; i < 3; ++i) { - Unit* unit = NULL; if (TargetGUID[i]) { - unit = Unit::GetUnit(*me, TargetGUID[i]); - if (unit) + if (Unit* unit = Unit::GetUnit(*me, TargetGUID[i])) unit->CastSpell(unit, SPELL_ATTRACTION, true); TargetGUID[i] = 0; } diff --git a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp index 710f5c82fab..673d4bcc96f 100644 --- a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp +++ b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp @@ -299,12 +299,11 @@ public: for (uint8 i = 0; i < 4; ++i) { - Unit* Member = NULL; if (Council[i]) { - Member = Unit::GetUnit(*me, Council[i]); - if (Member && Member->isAlive()) - CAST_CRE(Member)->AI()->AttackStart(target); + Unit* member = Unit::GetUnit(*me, Council[i]); + if (member && member->isAlive()) + CAST_CRE(member)->AI()->AttackStart(target); } } diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp index b9d0d101c07..893f97fe711 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "InstanceScript.h" #include "blood_furnace.h" +#include "CreatureAI.h" #define ENTRY_SEWER1 181823 #define ENTRY_SEWER2 181766 diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 170f00d4111..2aed2517975 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -950,14 +950,14 @@ class spell_generic_clone : public SpellScriptLoader enum CloneWeaponSpells { - SPELL_COPY_WEAPON = 41055, - SPELL_COPY_WEAPON_2 = 63416, - SPELL_COPY_WEAPON_3 = 69891, + SPELL_COPY_WEAPON_AURA = 41054, + SPELL_COPY_WEAPON_2_AURA = 63418, + SPELL_COPY_WEAPON_3_AURA = 69893, - SPELL_COPY_OFFHAND = 45206, - SPELL_COPY_OFFHAND_2 = 69892, + SPELL_COPY_OFFHAND_AURA = 45205, + SPELL_COPY_OFFHAND_2_AURA = 69896, - SPELL_COPY_RANGED = 57593 + SPELL_COPY_RANGED_AURA = 57594 }; class spell_generic_clone_weapon : public SpellScriptLoader @@ -969,80 +969,147 @@ class spell_generic_clone_weapon : public SpellScriptLoader { PrepareSpellScript(spell_generic_clone_weapon_SpellScript); - bool Validate(SpellInfo const* /*spellEntry*/) - { - if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_2) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_3) || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND) - || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_2) || !sSpellMgr->GetSpellInfo(SPELL_COPY_RANGED)) - return false; - return true; - } - void HandleScriptEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); Unit* caster = GetCaster(); + if (Unit* target = GetHitUnit()) { uint32 spellId = uint32(GetSpellInfo()->Effects[EFFECT_0].CalcValue()); - target->CastSpell(caster, spellId, true); + caster->CastSpell(target, spellId, true); + } + } - if (target->GetTypeId() == TYPEID_PLAYER) - return; + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_generic_clone_weapon_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_generic_clone_weapon_SpellScript(); + } +}; + +class spell_gen_clone_weapon_aura : public SpellScriptLoader +{ + public: + spell_gen_clone_weapon_aura() : SpellScriptLoader("spell_gen_clone_weapon_aura") { } + + class spell_gen_clone_weapon_auraScript : public AuraScript + { + PrepareAuraScript(spell_gen_clone_weapon_auraScript); + + uint32 prevItem; + + bool Validate(SpellInfo const* /*spellEntry*/) + { + if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_2_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_3_AURA) + || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_2_AURA) || !sSpellMgr->GetSpellInfo(SPELL_COPY_RANGED_AURA)) + return false; + return true; + } + + void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* caster = GetCaster(); + Unit* target = GetTarget(); - switch (GetSpellInfo()->Id) + if (!caster) + return; + + switch (GetSpellInfo()->Id) + { + case SPELL_COPY_WEAPON_AURA: + case SPELL_COPY_WEAPON_2_AURA: + case SPELL_COPY_WEAPON_3_AURA: { - case SPELL_COPY_WEAPON: - case SPELL_COPY_WEAPON_2: - case SPELL_COPY_WEAPON_3: + prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID); + + if (Player* player = caster->ToPlayer()) { - if (Player* player = caster->ToPlayer()) - { - if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, mainItem->GetEntry()); - } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)); - break; + if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, mainItem->GetEntry()); } - case SPELL_COPY_OFFHAND: - case SPELL_COPY_OFFHAND_2: + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)); + break; + } + case SPELL_COPY_OFFHAND_AURA: + case SPELL_COPY_OFFHAND_2_AURA: + { + prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID) + 1; + + if (Player* player = caster->ToPlayer()) { - if (Player* player = caster->ToPlayer()) - { - if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, offItem->GetEntry()); - } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)); - break; + if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, offItem->GetEntry()); } - case SPELL_COPY_RANGED: + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)); + break; + } + case SPELL_COPY_RANGED_AURA: + { + prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID) + 2; + + if (Player* player = caster->ToPlayer()) { - if (Player* player = caster->ToPlayer()) - { - if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, rangedItem->GetEntry()); - } - else - target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2)); - break; + if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, rangedItem->GetEntry()); } - default: - break; + else + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2)); + break; + } + default: + break; + } + } + + void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + Unit* target = GetTarget(); + + switch (GetSpellInfo()->Id) + { + case SPELL_COPY_WEAPON_AURA: + case SPELL_COPY_WEAPON_2_AURA: + case SPELL_COPY_WEAPON_3_AURA: + { + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, prevItem); + break; + } + case SPELL_COPY_OFFHAND_AURA: + case SPELL_COPY_OFFHAND_2_AURA: + { + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, prevItem); + break; } + case SPELL_COPY_RANGED_AURA: + { + target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, prevItem); + break; + } + default: + break; } } void Register() { - OnEffectHitTarget += SpellEffectFn(spell_generic_clone_weapon_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + OnEffectApply += AuraEffectApplyFn(spell_gen_clone_weapon_auraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + OnEffectRemove += AuraEffectRemoveFn(spell_gen_clone_weapon_auraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); } + }; - SpellScript* GetSpellScript() const + AuraScript* GetAuraScript() const { - return new spell_generic_clone_weapon_SpellScript(); + return new spell_gen_clone_weapon_auraScript(); } }; @@ -1844,16 +1911,18 @@ class spell_gen_break_shield: public SpellScriptLoader Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - Aura* aura = itr->second->GetBase(); - SpellInfo const* auraInfo = aura->GetSpellInfo(); - if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + if (Aura* aura = itr->second->GetBase()) { - aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - // Remove dummys from rider (Necessary for updating visual shields) - if (Unit* rider = target->GetCharmer()) - if (Aura* defend = rider->GetAura(aura->GetId())) - defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - break; + SpellInfo const* auraInfo = aura->GetSpellInfo(); + if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + { + aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + // Remove dummys from rider (Necessary for updating visual shields) + if (Unit* rider = target->GetCharmer()) + if (Aura* defend = rider->GetAura(aura->GetId())) + defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + break; + } } } break; @@ -1972,16 +2041,18 @@ class spell_gen_mounted_charge: public SpellScriptLoader Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - Aura* aura = itr->second->GetBase(); - SpellInfo const* auraInfo = aura->GetSpellInfo(); - if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + if (Aura* aura = itr->second->GetBase()) { - aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - // Remove dummys from rider (Necessary for updating visual shields) - if (Unit* rider = target->GetCharmer()) - if (Aura* defend = rider->GetAura(aura->GetId())) - defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - break; + SpellInfo const* auraInfo = aura->GetSpellInfo(); + if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + { + aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + // Remove dummys from rider (Necessary for updating visual shields) + if (Unit* rider = target->GetCharmer()) + if (Aura* defend = rider->GetAura(aura->GetId())) + defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + break; + } } } break; @@ -3190,6 +3261,7 @@ void AddSC_generic_spell_scripts() new spell_gen_profession_research(); new spell_generic_clone(); new spell_generic_clone_weapon(); + new spell_gen_clone_weapon_aura(); new spell_gen_seaforium_blast(); new spell_gen_turkey_marker(); new spell_gen_lifeblood(); diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 3cb2300cadf..cbf45910495 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -1291,7 +1291,7 @@ class spell_q12372_destabilize_azure_dragonshrine_dummy : public SpellScriptLoad class spell_q12372_destabilize_azure_dragonshrine_dummy_SpellScript : public SpellScript { PrepareSpellScript(spell_q12372_destabilize_azure_dragonshrine_dummy_SpellScript); - + void HandleDummy(SpellEffIndex /*effIndex*/) { if (GetHitCreature()) diff --git a/src/server/scripts/World/achievement_scripts.cpp b/src/server/scripts/World/achievement_scripts.cpp index 60572ee3e6a..a6f4f7f64f9 100755 --- a/src/server/scripts/World/achievement_scripts.cpp +++ b/src/server/scripts/World/achievement_scripts.cpp @@ -278,6 +278,9 @@ class achievement_tilted : public AchievementCriteriaScript bool OnCheck(Player* player, Unit* /*target*/) { + if (!player) + return false; + bool checkArea = player->GetAreaId() == AREA_ARGENT_TOURNAMENT_FIELDS || player->GetAreaId() == AREA_RING_OF_ASPIRANTS || player->GetAreaId() == AREA_RING_OF_ARGENT_VALIANTS || @@ -285,7 +288,7 @@ class achievement_tilted : public AchievementCriteriaScript player->GetAreaId() == AREA_RING_OF_HORDE_VALIANTS || player->GetAreaId() == AREA_RING_OF_CHAMPIONS; - return player && checkArea && player->duel && player->duel->isMounted; + return checkArea && player->duel && player->duel->isMounted; } }; diff --git a/src/server/shared/Cryptography/BigNumber.cpp b/src/server/shared/Cryptography/BigNumber.cpp index 364ee76ec75..146b2c37ad3 100755 --- a/src/server/shared/Cryptography/BigNumber.cpp +++ b/src/server/shared/Cryptography/BigNumber.cpp @@ -75,7 +75,7 @@ void BigNumber::SetRand(int numbits) BN_rand(_bn, numbits, 0, 1); } -BigNumber BigNumber::operator=(const BigNumber &bn) +BigNumber& BigNumber::operator=(const BigNumber &bn) { if (this == &bn) return *this; diff --git a/src/server/shared/Cryptography/BigNumber.h b/src/server/shared/Cryptography/BigNumber.h index 6646245a6a0..a27d74fb5c7 100755 --- a/src/server/shared/Cryptography/BigNumber.h +++ b/src/server/shared/Cryptography/BigNumber.h @@ -39,7 +39,7 @@ class BigNumber void SetRand(int numbits); - BigNumber operator=(const BigNumber &bn); + BigNumber& operator=(const BigNumber &bn); BigNumber operator+=(const BigNumber &bn); BigNumber operator+(const BigNumber &bn) diff --git a/src/server/shared/DataStores/DBCFileLoader.cpp b/src/server/shared/DataStores/DBCFileLoader.cpp index f909c8566bb..85b61c4f143 100755 --- a/src/server/shared/DataStores/DBCFileLoader.cpp +++ b/src/server/shared/DataStores/DBCFileLoader.cpp @@ -23,10 +23,8 @@ #include "DBCFileLoader.h" #include "Errors.h" -DBCFileLoader::DBCFileLoader() +DBCFileLoader::DBCFileLoader() : stringTable(NULL), data(NULL), fieldsOffset(NULL) { - data = NULL; - fieldsOffset = NULL; } bool DBCFileLoader::Load(const char* filename, const char* fmt) diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp index 74cd57f74c0..95c888249cd 100755 --- a/src/server/shared/Database/Implementation/WorldDatabase.cpp +++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp @@ -78,7 +78,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PREPARE_STATEMENT(WORLD_INS_CREATURE_TRANSPORT, "INSERT INTO creature_transport (guid, npc_entry, transport_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO) values (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PREPARE_STATEMENT(WORLD_UPD_CREATURE_TRANSPORT_EMOTE, "UPDATE creature_transport SET emote = ? WHERE transport_entry = ? AND guid = ?", CONNECTION_ASYNC); PREPARE_STATEMENT(WORLD_SEL_COMMANDS, "SELECT name, security, help FROM command", CONNECTION_SYNCH); - PREPARE_STATEMENT(WORLD_SEL_CREATURE_TEMPLATE, "SELECT difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction_A, faction_H, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, Health_mod, Mana_mod, Mana_mod_extra, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, equipment_id, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?", CONNECTION_SYNCH); + PREPARE_STATEMENT(WORLD_SEL_CREATURE_TEMPLATE, "SELECT difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction_A, faction_H, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, Health_mod, Mana_mod, Mana_mod_extra, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, equipment_id, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?", CONNECTION_SYNCH); PREPARE_STATEMENT(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?", CONNECTION_SYNCH); PREPARE_STATEMENT(WORLD_SEL_IP2NATION_COUNTRY, "SELECT c.country FROM ip2nationCountries c, ip2nation i WHERE i.ip < ? AND c.code = i.country ORDER BY i.ip DESC LIMIT 0,1", CONNECTION_SYNCH); PREPARE_STATEMENT(WORLD_SEL_ITEM_TEMPLATE_BY_NAME, "SELECT entry FROM item_template WHERE name = ?", CONNECTION_SYNCH); diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp index 6e17a32c78b..0b2bbb3122a 100644 --- a/src/server/shared/Logging/Log.cpp +++ b/src/server/shared/Logging/Log.cpp @@ -103,7 +103,7 @@ void Log::CreateAppenderFromConfig(const char* name) LogLevel level = LogLevel(atoi(*iter)); if (level > LOG_LEVEL_FATAL) { - fprintf(stderr, "Log::CreateAppenderFromConfig: Wrong Log Level %u for appender %s\n", level, name); + fprintf(stderr, "Log::CreateAppenderFromConfig: Wrong Log Level %d for appender %s\n", level, name); return; } @@ -158,7 +158,7 @@ void Log::CreateAppenderFromConfig(const char* name) break; } default: - fprintf(stderr, "Log::CreateAppenderFromConfig: Unknown type %u for appender %s\n", type, name); + fprintf(stderr, "Log::CreateAppenderFromConfig: Unknown type %d for appender %s\n", type, name); break; } } diff --git a/src/server/shared/Utilities/ServiceWin32.cpp b/src/server/shared/Utilities/ServiceWin32.cpp index c6e9d385be3..91a78af1adc 100755 --- a/src/server/shared/Utilities/ServiceWin32.cpp +++ b/src/server/shared/Utilities/ServiceWin32.cpp @@ -52,8 +52,6 @@ typedef WINADVAPI BOOL (WINAPI *CSD_T)(SC_HANDLE, DWORD, LPCVOID); bool WinServiceInstall() { - CSD_T ChangeService_Config2; - HMODULE advapi32; SC_HANDLE serviceControlManager = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE); if (serviceControlManager) @@ -79,7 +77,7 @@ bool WinServiceInstall() 0); // no password if (service) { - advapi32 = GetModuleHandle("ADVAPI32.DLL"); + HMODULE advapi32 = GetModuleHandle("ADVAPI32.DLL"); if (!advapi32) { CloseServiceHandle(service); @@ -87,7 +85,7 @@ bool WinServiceInstall() return false; } - ChangeService_Config2 = (CSD_T) GetProcAddress(advapi32, "ChangeServiceConfig2A"); + CSD_T ChangeService_Config2 = (CSD_T) GetProcAddress(advapi32, "ChangeServiceConfig2A"); if (!ChangeService_Config2) { CloseServiceHandle(service); diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index 7bedf9690ca..9917bbb5309 100755 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -217,7 +217,7 @@ uint32 CreatePIDFile(const std::string& filename) pid_t pid = getpid(); #endif - fprintf(pid_file, "%d", pid ); + fprintf(pid_file, "%u", pid ); fclose(pid_file); return (uint32)pid; diff --git a/src/server/worldserver/TCSoap/TCSoap.h b/src/server/worldserver/TCSoap/TCSoap.h index 285adaaaf4b..51ffb3a91c8 100755 --- a/src/server/worldserver/TCSoap/TCSoap.h +++ b/src/server/worldserver/TCSoap/TCSoap.h @@ -51,7 +51,7 @@ class SOAPCommand { public: SOAPCommand(): - pendingCommands(0, USYNC_THREAD, "pendingCommands") + pendingCommands(0, USYNC_THREAD, "pendingCommands"), m_success(false) { } diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index 448cf2320b2..e3e3b8c7d74 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -957,7 +957,7 @@ void ExtractMapsFromMpq(uint32 build) printf("Convert map files\n"); for (uint32 z = 0; z < map_count; ++z) { - printf("Extract %s (%d/%d) \n", map_ids[z].name, z+1, map_count); + printf("Extract %s (%d/%u) \n", map_ids[z].name, z+1, map_count); // Loadup map grid data sprintf(mpq_map_name, "World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name); WDT_file wdt; diff --git a/src/tools/vmap4_extractor/adtfile.cpp b/src/tools/vmap4_extractor/adtfile.cpp index c53b63ffa5e..d2ad71b8179 100644 --- a/src/tools/vmap4_extractor/adtfile.cpp +++ b/src/tools/vmap4_extractor/adtfile.cpp @@ -26,7 +26,7 @@ #define snprintf _snprintf #endif -const char * GetPlainName(const char * FileName) +char const* GetPlainName(char const* FileName) { const char * szTemp; @@ -35,7 +35,7 @@ const char * GetPlainName(const char * FileName) return FileName; } -char * GetPlainName(char * FileName) +char* GetPlainName(char* FileName) { char * szTemp; @@ -44,24 +44,21 @@ char * GetPlainName(char * FileName) return FileName; } -void fixnamen(char *name, size_t len) +void fixnamen(char* name, size_t len) { - for (size_t i=0; i<len-3; i++) + for (size_t i = 0; i < len-3; i++) { - if (i>0 && name[i]>='A' && name[i]<='Z' && isalpha(name[i-1])) - { + if (i > 0 && name[i] >= 'A' && name[i] <= 'Z' && isalpha(name[i-1])) name[i] |= 0x20; - } else if ((i==0 || !isalpha(name[i-1])) && name[i]>='a' && name[i]<='z') - { + else if ((i == 0 || !isalpha(name[i-1])) && name[i]>='a' && name[i]<='z') name[i] &= ~0x20; - } } //extension in lowercase - for(size_t i=len-3; i<len; i++) + for (size_t i = len - 3; i < len; i++) name[i] |= 0x20; } -void fixname2(char *name, size_t len) +void fixname2(char* name, size_t len) { for (size_t i=0; i<len-3; i++) { @@ -70,10 +67,10 @@ void fixname2(char *name, size_t len) } } -char * GetExtension(char * FileName) +char* GetExtension(char* FileName) { - char * szTemp; - if((szTemp = strrchr(FileName, '.')) != NULL) + char* szTemp; + if (szTemp = strrchr(FileName, '.')) return szTemp; return NULL; } @@ -101,7 +98,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY) xMap = TempMapNumber.substr(TempMapNumber.find("_")+1,(TempMapNumber.find_last_of("_")-1) - (TempMapNumber.find("_"))); yMap = TempMapNumber.substr(TempMapNumber.find_last_of("_")+1,(TempMapNumber.length()) - (TempMapNumber.find_last_of("_"))); Adtfilename.erase((Adtfilename.length()-xMap.length()-yMap.length()-2), (xMap.length()+yMap.length()+2)); - string AdtMapNumber = xMap + ' ' + yMap + ' ' + GetPlainName((char*)Adtfilename.c_str()); + //string AdtMapNumber = xMap + ' ' + yMap + ' ' + GetPlainName((char*)Adtfilename.c_str()); //printf("Processing map %s...\n", AdtMapNumber.c_str()); //printf("MapNumber = %s\n", TempMapNumber.c_str()); //printf("xMap = %s\n", xMap.c_str()); @@ -161,18 +158,17 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY) { if (size) { - char *buf = new char[size]; + char* buf = new char[size]; ADT.read(buf, size); - char *p=buf; + char* p=buf; int q = 0; WmoInstansName = new string[size]; while (p<buf+size) { - string path(p); - char* s=GetPlainName(p); - fixnamen(s,strlen(s)); - fixname2(s,strlen(s)); - p=p+strlen(p)+1; + char* s = GetPlainName(p); + fixnamen(s, strlen(s)); + fixname2(s, strlen(s)); + p += strlen(p) + 1; WmoInstansName[q++] = s; } delete[] buf; diff --git a/src/tools/vmap4_extractor/model.cpp b/src/tools/vmap4_extractor/model.cpp index d98dca9001b..7a03cea23c0 100644 --- a/src/tools/vmap4_extractor/model.cpp +++ b/src/tools/vmap4_extractor/model.cpp @@ -28,15 +28,14 @@ extern HANDLE WorldMpq; Model::Model(std::string &filename) : filename(filename), vertices(0), indices(0) { + memset(&header, 0, sizeof(header)); } bool Model::open() { MPQFile f(WorldMpq, filename.c_str()); - ok = !f.isEof(); - - if (!ok) + if (f.isEof()) { f.close(); // Do not show this error on console to avoid confusion, the extractor can continue working even if some models fail to load @@ -54,9 +53,7 @@ bool Model::open() vertices = new Vec3D[header.nBoundingVertices]; f.read(vertices,header.nBoundingVertices*12); for (uint32 i=0; i<header.nBoundingVertices; i++) - { vertices[i] = fixCoordSystem(vertices[i]); - } f.seek(0); f.seekRelative(header.ofsBoundingTriangles); indices = new uint16[header.nBoundingTriangles]; @@ -75,13 +72,13 @@ bool Model::open() bool Model::ConvertToVMAPModel(const char * outfilename) { int N[12] = {0,0,0,0,0,0,0,0,0,0,0,0}; - FILE * output=fopen(outfilename,"wb"); - if(!output) + FILE* output=fopen(outfilename, "wb"); + if (!output) { printf("Can't create the output file '%s'\n",outfilename); return false; } - fwrite(szRawVMAPMagic,8,1,output); + fwrite(szRawVMAPMagic, 8, 1, output); uint32 nVertices = 0; nVertices = header.nBoundingVertices; fwrite(&nVertices, sizeof(int), 1, output); @@ -103,20 +100,18 @@ bool Model::ConvertToVMAPModel(const char * outfilename) wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes; fwrite(&wsize, sizeof(int), 1, output); fwrite(&nIndexes, sizeof(uint32), 1, output); - if(nIndexes >0) - { + if (nIndexes >0) fwrite(indices, sizeof(unsigned short), nIndexes, output); - } - fwrite("VERT",4, 1, output); + + fwrite("VERT", 4, 1, output); wsize = sizeof(int) + sizeof(float) * 3 * nVertices; fwrite(&wsize, sizeof(int), 1, output); fwrite(&nVertices, sizeof(int), 1, output); - if(nVertices >0) + if (nVertices >0) { for(uint32 vpos=0; vpos <nVertices; ++vpos) - { std::swap(vertices[vpos].y, vertices[vpos].z); - } + fwrite(vertices, sizeof(float)*3, nVertices, output); } @@ -136,24 +131,24 @@ Vec3D fixCoordSystem2(Vec3D v) return Vec3D(v.x, v.z, v.y); } -ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile) +ModelInstance::ModelInstance(MPQFile& f, char const* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile) + : model(NULL), d1(0), w(0.0f) { float ff[3]; f.read(&id, 4); - f.read(ff,12); - pos = fixCoords(Vec3D(ff[0],ff[1],ff[2])); - f.read(ff,12); - rot = Vec3D(ff[0],ff[1],ff[2]); - f.read(&scale,4); + f.read(ff, 12); + pos = fixCoords(Vec3D(ff[0], ff[1], ff[2])); + f.read(ff, 12); + rot = Vec3D(ff[0], ff[1], ff[2]); + f.read(&scale, 4); // scale factor - divide by 1024. blizzard devs must be on crack, why not just use a float? sc = scale / 1024.0f; char tempname[512]; sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName); - FILE *input; - input = fopen(tempname, "r+b"); + FILE* input = fopen(tempname, "r+b"); - if(!input) + if (!input) { //printf("ModelInstance::ModelInstance couldn't open %s\n", tempname); return; @@ -169,7 +164,9 @@ ModelInstance::ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID, uint16 adtId = 0;// not used for models uint32 flags = MOD_M2; - if(tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN; + if (tileX == 65 && tileY == 65) + flags |= MOD_WORLDSPAWN; + //write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, name fwrite(&mapID, sizeof(uint32), 1, pDirfile); fwrite(&tileX, sizeof(uint32), 1, pDirfile); diff --git a/src/tools/vmap4_extractor/model.h b/src/tools/vmap4_extractor/model.h index 9000d7e4822..acd31d58ec9 100644 --- a/src/tools/vmap4_extractor/model.h +++ b/src/tools/vmap4_extractor/model.h @@ -20,12 +20,9 @@ #define MODEL_H #include "vec3d.h" -//#include "mpq.h" #include "modelheaders.h" #include <vector> -class Model; -class WMOInstance; class MPQFile; Vec3D fixCoordSystem(Vec3D v); @@ -34,18 +31,14 @@ class Model { public: ModelHeader header; - uint32 offsBB_vertices, offsBB_indices; - Vec3D *BB_vertices, *vertices; - uint16 *BB_indices, *indices; - size_t nIndices; + Vec3D* vertices; + uint16* indices; bool open(); - bool ConvertToVMAPModel(const char * outfilename); + bool ConvertToVMAPModel(char const* outfilename); - bool ok; - - Model(std::string &filename); - ~Model() {_unload();} + Model(std::string& filename); + ~Model() { _unload(); } private: void _unload() @@ -55,22 +48,22 @@ private: vertices = NULL; indices = NULL; } + std::string filename; - char outfilename; }; class ModelInstance { public: - Model *model; + Model* model; uint32 id; Vec3D pos, rot; unsigned int d1, scale; - float w,sc; + float w, sc; - ModelInstance() {} - ModelInstance(MPQFile &f,const char* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile); + ModelInstance() : model(NULL), d1(0), scale(0), w(0.0f), sc(0.0f), id(0) {} + ModelInstance(MPQFile& f, char const* ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile); }; diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp index 489655659c3..eebc763f2f2 100644 --- a/src/tools/vmap4_extractor/vmapexport.cpp +++ b/src/tools/vmap4_extractor/vmapexport.cpp @@ -334,12 +334,12 @@ bool ExtractSingleWmo(std::string& fname) int p = 0; //Select root wmo files - const char * rchr = strrchr(plain_name, '_'); + char const* rchr = strrchr(plain_name, '_'); if(rchr != NULL) { char cpy[4]; - strncpy((char*)cpy,rchr,4); - for (int i=0;i < 4; ++i) + strncpy((char*)cpy, rchr, 4); + for (int i = 0; i < 4; ++i) { int m = cpy[i]; if(isdigit(m)) @@ -375,7 +375,7 @@ bool ExtractSingleWmo(std::string& fname) strcpy(temp, fname.c_str()); temp[fname.length()-4] = 0; char groupFileName[1024]; - sprintf(groupFileName,"%s_%03d.wmo",temp, i); + sprintf(groupFileName, "%s_%03u.wmo", temp, i); //printf("Trying to open groupfile %s\n",groupFileName); string s = groupFileName; diff --git a/src/tools/vmap4_extractor/wdtfile.cpp b/src/tools/vmap4_extractor/wdtfile.cpp index 2dd7396ae7d..9e208dac8dc 100644 --- a/src/tools/vmap4_extractor/wdtfile.cpp +++ b/src/tools/vmap4_extractor/wdtfile.cpp @@ -80,9 +80,8 @@ bool WDTFile::init(char *map_id, unsigned int mapID) char *p=buf; int q = 0; gWmoInstansName = new string[size]; - while (p<buf+size) + while (p < buf + size) { - string path(p); char* s=wdtGetPlainName(p); fixnamen(s,strlen(s)); p=p+strlen(p)+1; @@ -91,23 +90,20 @@ bool WDTFile::init(char *map_id, unsigned int mapID) delete[] buf; } } - else if (!strcmp(fourcc,"MODF")) + else if (!strcmp(fourcc, "MODF")) { // global wmo instance data if (size) { gnWMO = (int)size / 64; - string gWMO_mapname; - string fake_mapname; - fake_mapname = "65 65 "; - //gWMO_mapname = fake_mapname + filename; - gWMO_mapname = fake_mapname + std::string(map_id); - for (int i=0; i<gnWMO; ++i) + + for (int i = 0; i < gnWMO; ++i) { int id; WDT.read(&id, 4); - WMOInstance inst(WDT,gWmoInstansName[id].c_str(),mapID, 65, 65, dirfile); + WMOInstance inst(WDT,gWmoInstansName[id].c_str(), mapID, 65, 65, dirfile); } + delete[] gWmoInstansName; } } diff --git a/src/tools/vmap4_extractor/wdtfile.h b/src/tools/vmap4_extractor/wdtfile.h index ef3ec6db98c..b085965343a 100644 --- a/src/tools/vmap4_extractor/wdtfile.h +++ b/src/tools/vmap4_extractor/wdtfile.h @@ -13,16 +13,15 @@ class WDTFile public: WDTFile(char* file_name, char* file_name1); ~WDTFile(void); - bool init(char *map_id, unsigned int mapID); + bool init(char* map_id, unsigned int mapID); string* gWmoInstansName; - int gnWMO, nMaps; + int gnWMO; ADTFile* GetMap(int x, int z); private: MPQFile WDT; - bool maps[64][64]; string filename; }; diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp index 8bba5610c88..85cae02e41c 100644 --- a/src/tools/vmap4_extractor/wmo.cpp +++ b/src/tools/vmap4_extractor/wmo.cpp @@ -31,8 +31,12 @@ using namespace std; extern uint16 *LiqType; -WMORoot::WMORoot(std::string &filename) : filename(filename) +WMORoot::WMORoot(std::string &filename) + : filename(filename), col(0), nTextures(0), nGroups(0), nP(0), nLights(0), + nModels(0), nDoodads(0), nDoodadSets(0), RootWMOID(0), liquidType(0) { + memset(bbcorn1, 0, sizeof(bbcorn1)); + memset(bbcorn2, 0, sizeof(bbcorn2)); } extern HANDLE WorldMpq; @@ -59,7 +63,7 @@ bool WMORoot::open() size_t nextpos = f.getPos() + size; - if (!strcmp(fourcc,"MOHD"))//header + if (!strcmp(fourcc,"MOHD")) // header { f.read(&nTextures, 4); f.read(&nGroups, 4); @@ -70,8 +74,8 @@ bool WMORoot::open() f.read(&nDoodadSets, 4); f.read(&col, 4); f.read(&RootWMOID, 4); - f.read(bbcorn1,12); - f.read(bbcorn2,12); + f.read(bbcorn1, 12); + f.read(bbcorn2, 12); f.read(&liquidType, 4); break; } @@ -122,15 +126,15 @@ bool WMORoot::open() return true; } -bool WMORoot::ConvertToVMAPRootWmo(FILE *pOutfile) +bool WMORoot::ConvertToVMAPRootWmo(FILE* pOutfile) { //printf("Convert RootWmo...\n"); - fwrite(szRawVMAPMagic,1,8,pOutfile); + fwrite(szRawVMAPMagic, 1, 8, pOutfile); unsigned int nVectors = 0; - fwrite(&nVectors,sizeof(nVectors),1,pOutfile); // will be filled later - fwrite(&nGroups,4,1,pOutfile); - fwrite(&RootWMOID,4,1,pOutfile); + fwrite(&nVectors,sizeof(nVectors), 1, pOutfile); // will be filled later + fwrite(&nGroups, 4, 1, pOutfile); + fwrite(&RootWMOID, 4, 1, pOutfile); return true; } @@ -138,9 +142,13 @@ WMORoot::~WMORoot() { } -WMOGroup::WMOGroup(std::string &filename) : filename(filename), - MOPY(0), MOVI(0), MoviEx(0), MOVT(0), MOBA(0), MobaEx(0), hlq(0), LiquEx(0), LiquBytes(0) +WMOGroup::WMOGroup(const std::string &filename) : + filename(filename), MOPY(0), MOVI(0), MoviEx(0), MOVT(0), MOBA(0), MobaEx(0), + hlq(0), LiquEx(0), LiquBytes(0), groupName(0), descGroupName(0), mogpFlags(0), + mopy_size(0), moba_size(0), LiquEx_size(0), nVertices(0), nTriangles(0) { + memset(bbcorn1, 0, sizeof(bbcorn1)); + memset(bbcorn2, 0, sizeof(bbcorn2)); } bool WMOGroup::open() @@ -239,7 +247,7 @@ bool WMOGroup::open() return true; } -int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool pPreciseVectorData) +int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool preciseVectorData) { fwrite(&mogpFlags,sizeof(uint32),1,output); fwrite(&groupWMOID,sizeof(uint32),1,output); @@ -248,7 +256,7 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool pPrecis fwrite(bbcorn2, sizeof(float), 3, output); fwrite(&liquflags,sizeof(uint32),1,output); int nColTriangles = 0; - if(pPreciseVectorData) + if (preciseVectorData) { char GRP[] = "GRP "; fwrite(GRP,1,4,output); @@ -481,10 +489,9 @@ WMOGroup::~WMOGroup() delete [] LiquBytes; } -WMOInstance::WMOInstance(MPQFile &f,const char* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile) +WMOInstance::WMOInstance(MPQFile& f, char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile) + : currx(0), curry(0), wmo(NULL), doodadset(0), pos(), indx(0), d3(0) { - pos = Vec3D(0,0,0); - float ff[3]; f.read(&id, 4); f.read(ff,12); diff --git a/src/tools/vmap4_extractor/wmo.h b/src/tools/vmap4_extractor/wmo.h index 7020bb90f12..02e4be4aa79 100644 --- a/src/tools/vmap4_extractor/wmo.h +++ b/src/tools/vmap4_extractor/wmo.h @@ -50,14 +50,13 @@ public: float bbcorn1[3]; float bbcorn2[3]; - WMORoot(std::string &filename); + WMORoot(std::string& filename); ~WMORoot(); bool open(); - bool ConvertToVMAPRootWmo(FILE *output); + bool ConvertToVMAPRootWmo(FILE* output); private: std::string filename; - char outfilename; }; struct WMOLiquidHeader @@ -89,30 +88,29 @@ public: uint16 nBatchB; uint32 nBatchC, fogIdx, liquidType, groupWMOID; - int mopy_size,moba_size; + int mopy_size, moba_size; int LiquEx_size; unsigned int nVertices; // number when loaded int nTriangles; // number when loaded - char *MOPY; - uint16 *MOVI; - uint16 *MoviEx; - float *MOVT; - uint16 *MOBA; - int *MobaEx; - WMOLiquidHeader *hlq; - WMOLiquidVert *LiquEx; - char *LiquBytes; + char* MOPY; + uint16* MOVI; + uint16* MoviEx; + float* MOVT; + uint16* MOBA; + int* MobaEx; + WMOLiquidHeader* hlq; + WMOLiquidVert* LiquEx; + char* LiquBytes; uint32 liquflags; - WMOGroup(std::string &filename); + WMOGroup(std::string const& filename); ~WMOGroup(); bool open(); - int ConvertToVMAPGroupWmo(FILE *output, WMORoot *rootWMO, bool pPreciseVectorData); + int ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool preciseVectorData); private: std::string filename; - char outfilename; }; class WMOInstance @@ -122,13 +120,13 @@ public: std::string MapName; int currx; int curry; - WMOGroup *wmo; + WMOGroup* wmo; Vec3D pos; Vec3D pos2, pos3, rot; - uint32 indx,id, d2, d3; + uint32 indx, id, d2, d3; int doodadset; - WMOInstance(MPQFile &f,const char* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile); + WMOInstance(MPQFile&f , char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile); static void reset(); }; |