diff options
Diffstat (limited to 'src')
122 files changed, 1709 insertions, 1213 deletions
diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp index 81b97f5f352..62abc31831a 100644 --- a/src/server/collision/Management/VMapManager2.cpp +++ b/src/server/collision/Management/VMapManager2.cpp @@ -245,7 +245,7 @@ namespace VMAP return false; } - WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename, uint32 flags/* Only used when creating the model */) + WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename) { //! Critical section, thread safe access to iLoadedModelFiles TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock); @@ -261,7 +261,6 @@ namespace VMAP return NULL; } sLog->outDebug(LOG_FILTER_MAPS, "VMapManager2: loading file '%s%s'", basepath.c_str(), filename.c_str()); - worldmodel->Flags = flags; model = iLoadedModelFiles.insert(std::pair<std::string, ManagedModel>(filename, ManagedModel())).first; model->second.setModel(worldmodel); } diff --git a/src/server/collision/Management/VMapManager2.h b/src/server/collision/Management/VMapManager2.h index 4b66a2e9fc7..1fba108388a 100755 --- a/src/server/collision/Management/VMapManager2.h +++ b/src/server/collision/Management/VMapManager2.h @@ -103,7 +103,7 @@ namespace VMAP bool getAreaInfo(unsigned int pMapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const; bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type) const; - WorldModel* acquireModelInstance(const std::string& basepath, const std::string& filename, uint32 flags = 0); + WorldModel* acquireModelInstance(const std::string& basepath, const std::string& filename); void releaseModelInstance(const std::string& filename); // what's the use of this? o.O diff --git a/src/server/collision/Maps/MapTree.cpp b/src/server/collision/Maps/MapTree.cpp index f94f9bbf52b..f4a3f1c7b30 100644 --- a/src/server/collision/Maps/MapTree.cpp +++ b/src/server/collision/Maps/MapTree.cpp @@ -309,7 +309,7 @@ namespace VMAP #endif if (!iIsTiled && ModelSpawn::readFromFile(rf, spawn)) { - WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name, spawn.flags); + WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name); sLog->outDebug(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : loading %s", spawn.name.c_str()); if (model) { @@ -380,7 +380,7 @@ namespace VMAP if (result) { // acquire model instance - WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name, spawn.flags); + WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name); if (!model) sLog->outError("StaticMapTree::LoadMapTile() : could not acquire WorldModel pointer [%u, %u]", tileX, tileY); diff --git a/src/server/collision/Models/GameObjectModel.cpp b/src/server/collision/Models/GameObjectModel.cpp index 1c3a0aa639e..84c736c22e8 100644 --- a/src/server/collision/Models/GameObjectModel.cpp +++ b/src/server/collision/Models/GameObjectModel.cpp @@ -83,7 +83,7 @@ void LoadGameObjectModelList() } fclose(model_list_file); - sLog->outString(">> Loaded %u GameObject models in %u ms", model_list.size(), GetMSTimeDiffToNow(oldMSTime)); + sLog->outString(">> Loaded %u GameObject models in %u ms", uint32(model_list.size()), GetMSTimeDiffToNow(oldMSTime)); sLog->outString(); } diff --git a/src/server/collision/Models/WorldModel.cpp b/src/server/collision/Models/WorldModel.cpp index cda34510058..d4b08dde5dd 100644 --- a/src/server/collision/Models/WorldModel.cpp +++ b/src/server/collision/Models/WorldModel.cpp @@ -421,9 +421,6 @@ namespace VMAP bool WorldModel::IntersectRay(const G3D::Ray &ray, float &distance, bool stopAtFirstHit) const { - // M2 models are not taken into account for LoS calculation - if (Flags & MOD_M2) - return false; // small M2 workaround, maybe better make separate class with virtual intersection funcs // in any case, there's no need to use a bound tree if we only have one submodel if (groupModels.size() == 1) diff --git a/src/server/collision/Models/WorldModel.h b/src/server/collision/Models/WorldModel.h index dbaccb58573..ebf828e4935 100755 --- a/src/server/collision/Models/WorldModel.h +++ b/src/server/collision/Models/WorldModel.h @@ -113,7 +113,6 @@ namespace VMAP bool GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, LocationInfo &info) const; bool writeFile(const std::string &filename); bool readFile(const std::string &filename); - uint32 Flags; protected: uint32 RootWMOID; std::vector<GroupModel> groupModels; diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 30ebd06745f..eedba4d8b7e 100755 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -174,7 +174,7 @@ void PetAI::UpdateAI(const uint32 diff) if (spell->CanAutoCast(target)) { - targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(target, spell)); + targetSpellStore.push_back(std::make_pair(target, spell)); spellUsed = true; break; } @@ -186,7 +186,7 @@ void PetAI::UpdateAI(const uint32 diff) { Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0); if (spell->CanAutoCast(me->getVictim())) - targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(me->getVictim(), spell)); + targetSpellStore.push_back(std::make_pair(me->getVictim(), spell)); else delete spell; } diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index c8818f84e5b..9c236cbd039 100755 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -25,6 +25,7 @@ #include "Log.h" #include "MapReference.h" #include "Player.h" +#include "CreatureTextMgr.h" //Disable CreatureAI when charmed void CreatureAI::OnCharmed(bool /*apply*/) diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h index dafd3e4e137..423b00291e7 100755 --- a/src/server/game/AI/CreatureAI.h +++ b/src/server/game/AI/CreatureAI.h @@ -19,9 +19,9 @@ #ifndef TRINITY_CREATUREAI_H #define TRINITY_CREATUREAI_H +#include "Creature.h" #include "UnitAI.h" #include "Common.h" -#include "CreatureTextMgr.h" class WorldObject; class Unit; diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp index ab616d78a8c..f64bb320542 100755 --- a/src/server/game/AI/CreatureAISelector.cpp +++ b/src/server/game/AI/CreatureAISelector.cpp @@ -102,7 +102,7 @@ namespace FactorySelector MovementGenerator* selectMovementGenerator(Creature* creature) { MovementGeneratorRegistry& mv_registry(*MovementGeneratorRepository::instance()); - ASSERT(creature->GetCreatureInfo() != NULL); + ASSERT(creature->GetCreatureTemplate() != NULL); const MovementGeneratorCreator* mv_factory = mv_registry.GetRegistryItem(creature->GetDefaultMovementType()); /* if (mv_factory == NULL) diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 01e13b29f19..1e0c3f5c1fc 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -57,7 +57,7 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* who) return false; //experimental (unknown) flag not present - if (!(me->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS)) + if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS)) return false; //not a player @@ -150,7 +150,7 @@ void npc_escortAI::JustRespawned() //add a small delay before going to first waypoint, normal in near all cases m_uiWPWaitTimer = 2500; - if (me->getFaction() != me->GetCreatureInfo()->faction_A) + if (me->getFaction() != me->GetCreatureTemplate()->faction_A) me->RestoreFaction(); Reset(); diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index d83ad9b756c..e0fe12082f1 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -55,7 +55,7 @@ bool FollowerAI::AssistPlayerInCombat(Unit* who) return false; //experimental (unknown) flag not present - if (!(me->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS)) + if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS)) return false; //not a player @@ -150,8 +150,8 @@ void FollowerAI::JustRespawned() if (!IsCombatMovementAllowed()) SetCombatMovement(true); - if (me->getFaction() != me->GetCreatureInfo()->faction_A) - me->setFaction(me->GetCreatureInfo()->faction_A); + if (me->getFaction() != me->GetCreatureTemplate()->faction_A) + me->setFaction(me->GetCreatureTemplate()->faction_A); Reset(); } diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 8776090c86f..50c7aba0360 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -524,7 +524,7 @@ bool SmartAI::AssistPlayerInCombat(Unit* who) return false; //experimental (unknown) flag not present - if (!(me->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS)) + if (!(me->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS)) return false; //not a player @@ -561,7 +561,7 @@ void SmartAI::JustRespawned() mDespawnState = 0; mEscortState = SMART_ESCORT_NONE; me->SetVisible(true); - if (me->getFaction() != me->GetCreatureInfo()->faction_A) + if (me->getFaction() != me->GetCreatureTemplate()->faction_A) me->RestoreFaction(); GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN); Reset(); diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index e82b35ec87a..c2501199f77 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -23,7 +23,6 @@ #include "CreatureAI.h" #include "Unit.h" #include "ConditionMgr.h" -#include "CreatureTextMgr.h" #include "Spell.h" #include "SmartScript.h" diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 67d26ea06dd..0523f59da5d 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -33,6 +33,47 @@ #include "Group.h" #include "Vehicle.h" #include "ScriptedGossip.h" +#include "CreatureTextMgr.h" + +class TrinityStringTextBuilder +{ + public: + TrinityStringTextBuilder(WorldObject* obj, ChatMsg msgtype, int32 id, uint32 language, uint64 targetGUID) + : _source(obj), _msgType(msgtype), _textId(id), _language(language), _targetGUID(targetGUID) + { + } + + size_t operator()(WorldPacket* data, LocaleConstant locale) const + { + std::string text = sObjectMgr->GetTrinityString(_textId, locale); + char const* localizedName = _source->GetNameForLocaleIdx(locale); + + *data << uint8(_msgType); + *data << uint32(_language); + *data << uint64(_source->GetGUID()); + *data << uint32(1); // 2.1.0 + *data << uint32(strlen(localizedName)+1); + *data << localizedName; + size_t whisperGUIDpos = data->wpos(); + *data << uint64(_targetGUID); // Unit Target + if (_targetGUID && !IS_PLAYER_GUID(_targetGUID)) + { + *data << uint32(1); // target name length + *data << uint8(0); // target name + } + *data << uint32(text.length() + 1); + *data << text; + *data << uint8(0); // ChatTag + + return whisperGUIDpos; + } + + WorldObject* _source; + ChatMsg _msgType; + int32 _textId; + uint32 _language; + uint64 _targetGUID; +}; SmartScript::SmartScript() { @@ -695,7 +736,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u me->DoFleeToGetAssistance(); if (e.action.flee.withEmote) - sCreatureTextMgr->SendChatString(me, sObjectMgr->GetTrinityStringForDBCLocale(LANG_FLEE), CHAT_MSG_MONSTER_EMOTE); + { + TrinityStringTextBuilder builder(me, CHAT_MSG_MONSTER_EMOTE, LANG_FLEE, LANG_UNIVERSAL, 0); + sCreatureTextMgr->SendChatPacket(me, builder, CHAT_MSG_MONSTER_EMOTE); + } sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_FLEE_FOR_ASSIST: Creature %u DoFleeToGetAssistance", me->GetGUIDLow()); break; } @@ -1329,10 +1373,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u target = targets->front(); } - if(!target) - me->GetMotionMaster()->MovePoint(0, e.target.x, e.target.y, e.target.z); + if (!target) + me->GetMotionMaster()->MovePoint(e.action.MoveToPos.pointId, e.target.x, e.target.y, e.target.z); else - me->GetMotionMaster()->MovePoint(0, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()); + me->GetMotionMaster()->MovePoint(e.action.MoveToPos.pointId, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()); break; } case SMART_ACTION_RESPAWN_TARGET: diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index f7524582ab7..faba3c05394 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -23,7 +23,6 @@ #include "CreatureAI.h" #include "Unit.h" #include "ConditionMgr.h" -#include "CreatureTextMgr.h" #include "Spell.h" #include "GridNotifiers.h" diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 4105012ac86..fe2a89de9aa 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -27,6 +27,7 @@ #include "InstanceScript.h" #include "ScriptedCreature.h" #include "GameEventMgr.h" +#include "CreatureTextMgr.h" #include "SmartScriptMgr.h" @@ -48,7 +49,6 @@ void SmartWaypointMgr::LoadFromDB() uint32 count = 0; uint32 total = 0; - WPPath* path = NULL; uint32 last_entry = 0; uint32 last_id = 1; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 0d182e1beb3..007b57b52d7 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -23,7 +23,6 @@ #include "CreatureAI.h" #include "Unit.h" #include "ConditionMgr.h" -#include "CreatureTextMgr.h" #include "Spell.h" //#include "SmartScript.h" @@ -442,7 +441,7 @@ enum SMART_ACTION SMART_ACTION_CREATE_TIMED_EVENT = 67, // id, InitialMin, InitialMax, RepeatMin(only if it repeats), RepeatMax(only if it repeats), chance SMART_ACTION_PLAYMOVIE = 68, // entry - SMART_ACTION_MOVE_TO_POS = 69, // xyz + SMART_ACTION_MOVE_TO_POS = 69, // PointId, xyz SMART_ACTION_RESPAWN_TARGET = 70, // SMART_ACTION_EQUIP = 71, // entry, slotmask slot1, slot2, slot3 , only slots with mask set will be sent to client, bits are 1, 2, 4, leaving mask 0 is defaulted to mask 7 (send all), slots1-3 are only used if no entry is set SMART_ACTION_CLOSE_GOSSIP = 72, // none @@ -875,6 +874,11 @@ struct SmartAction struct { + uint8 pointId; + } MoveToPos; + + struct + { uint32 gossipMenuId; uint32 gossipNpcTextId; } sendGossipMenu; diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index a5c34e4b7ee..05fef44f676 100755 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -154,18 +154,18 @@ bool ArenaTeam::AddMember(uint64 playerGuid) Player::RemovePetitionsAndSigns(playerGuid, GetType()); // Feed data to the struct - ArenaTeamMember newmember; - newmember.Name = playerName; - newmember.Guid = playerGuid; - newmember.Class = playerClass; - newmember.SeasonGames = 0; - newmember.WeekGames = 0; - newmember.SeasonWins = 0; - newmember.WeekWins = 0; - newmember.PersonalRating = personalRating; - newmember.MatchMakerRating = matchMakerRating; - - Members.push_back(newmember); + ArenaTeamMember newMember; + newMember.Name = playerName; + newMember.Guid = playerGuid; + newMember.Class = playerClass; + newMember.SeasonGames = 0; + newMember.WeekGames = 0; + newMember.SeasonWins = 0; + newMember.WeekWins = 0; + newMember.PersonalRating = personalRating; + newMember.MatchMakerRating = matchMakerRating; + + Members.push_back(newMember); // Save player's arena team membership to db stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp index d24058cdd8a..7db03381407 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp @@ -27,6 +27,7 @@ BattlegroundDS::BattlegroundDS() { BgObjects.resize(BG_DS_OBJECT_MAX); + BgCreatures.resize(BG_DS_NPC_MAX); StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_1M; StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S; @@ -49,6 +50,21 @@ void BattlegroundDS::PostUpdateImpl(uint32 diff) if (GetStatus() != STATUS_IN_PROGRESS) return; + if (getPipeKnockBackCount() < BG_DS_PIPE_KNOCKBACK_TOTAL_COUNT) + { + if (getPipeKnockBackTimer() < diff) + { + for (uint32 i = BG_DS_NPC_PIPE_KNOCKBACK_1; i <= BG_DS_NPC_PIPE_KNOCKBACK_2; ++i) + if (Creature* waterSpout = GetBgMap()->GetCreature(BgCreatures[i])) + waterSpout->CastSpell(waterSpout, BG_DS_SPELL_FLUSH, true); + + setPipeKnockBackCount(getPipeKnockBackCount() + 1); + setPipeKnockBackTimer(BG_DS_PIPE_KNOCKBACK_DELAY); + } + else + setPipeKnockBackTimer(getPipeKnockBackTimer() - diff); + } + if (getWaterFallTimer() < diff) { if (getWaterFallStatus() == BG_DS_WATERFALL_STATUS_OFF) // Add the water @@ -57,8 +73,11 @@ void BattlegroundDS::PostUpdateImpl(uint32 diff) setWaterFallTimer(BG_DS_WATERFALL_WARNING_DURATION); setWaterFallStatus(BG_DS_WATERFALL_STATUS_WARNING); } - else if (getWaterFallStatus() == BG_DS_WATERFALL_STATUS_WARNING) // Active collision + else if (getWaterFallStatus() == BG_DS_WATERFALL_STATUS_WARNING) // Active collision and perform knockback { + if (Creature* waterSpout = GetBgMap()->GetCreature(BgCreatures[BG_DS_NPC_WATERFALL_KNOCKBACK])) + waterSpout->CastSpell(waterSpout, BG_DS_SPELL_WATER_SPOUT, true); + if (GameObject* gob = GetBgMap()->GetGameObject(BgObjects[BG_DS_OBJECT_WATER_1])) gob->SetGoState(GO_STATE_READY); @@ -97,6 +116,9 @@ void BattlegroundDS::StartingEventOpenDoors() setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX)); setWaterFallStatus(BG_DS_WATERFALL_STATUS_OFF); + setPipeKnockBackTimer(BG_DS_PIPE_KNOCKBACK_FIRST_DELAY); + setPipeKnockBackCount(0); + SpawnBGObject(BG_DS_OBJECT_WATER_2, RESPAWN_IMMEDIATELY); DoorOpen(BG_DS_OBJECT_WATER_2); @@ -151,6 +173,10 @@ void BattlegroundDS::HandleAreaTrigger(Player* Source, uint32 Trigger) { case 5347: case 5348: + // Someone has get back into the pipes and the knockback has already been performed, + // so we reset the knockback count for kicking the player again into the arena. + if (getPipeKnockBackCount() >= BG_DS_PIPE_KNOCKBACK_TOTAL_COUNT) + setPipeKnockBackCount(0); break; default: sLog->outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger); @@ -187,7 +213,11 @@ bool BattlegroundDS::SetupBattleground() || !AddObject(BG_DS_OBJECT_WATER_2, BG_DS_OBJECT_TYPE_WATER_2, 1291.56f, 790.837f, 7.1f, 3.14238f, 0, 0, 0.694215f, -0.719768f, 120) // buffs || !AddObject(BG_DS_OBJECT_BUFF_1, BG_DS_OBJECT_TYPE_BUFF_1, 1291.7f, 813.424f, 7.11472f, 4.64562f, 0, 0, 0.730314f, -0.683111f, 120) - || !AddObject(BG_DS_OBJECT_BUFF_2, BG_DS_OBJECT_TYPE_BUFF_2, 1291.7f, 768.911f, 7.11472f, 1.55194f, 0, 0, 0.700409f, 0.713742f, 120)) + || !AddObject(BG_DS_OBJECT_BUFF_2, BG_DS_OBJECT_TYPE_BUFF_2, 1291.7f, 768.911f, 7.11472f, 1.55194f, 0, 0, 0.700409f, 0.713742f, 120) + // knockback creatures + || !AddCreature(BG_DS_NPC_TYPE_WATER_SPOUT, BG_DS_NPC_WATERFALL_KNOCKBACK, 0, 1292.587f, 790.2205f, 7.19796f, 3.054326f, RESPAWN_IMMEDIATELY) + || !AddCreature(BG_DS_NPC_TYPE_WATER_SPOUT, BG_DS_NPC_PIPE_KNOCKBACK_1, 0, 1369.977f, 817.2882f, 16.08718f, 3.106686f, RESPAWN_IMMEDIATELY) + || !AddCreature(BG_DS_NPC_TYPE_WATER_SPOUT, BG_DS_NPC_PIPE_KNOCKBACK_2, 0, 1212.833f, 765.3871f, 16.09484f, 0.0f, RESPAWN_IMMEDIATELY)) { sLog->outErrorDb("BatteGroundDS: Failed to spawn some object!"); return false; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h index 7efc6e1caa7..a10e75eb6f4 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h @@ -42,12 +42,35 @@ enum BattlegroundDSObjects BG_DS_OBJECT_TYPE_BUFF_2 = 184664 }; +enum BattlegroundDSCreatureTypes +{ + BG_DS_NPC_WATERFALL_KNOCKBACK = 0, + BG_DS_NPC_PIPE_KNOCKBACK_1 = 1, + BG_DS_NPC_PIPE_KNOCKBACK_2 = 2, + BG_DS_NPC_MAX = 3 +}; + +enum BattlegroundDSCreatures +{ + BG_DS_NPC_TYPE_WATER_SPOUT = 28567, +}; + +enum BattlegroundDSSpells +{ + BG_DS_SPELL_FLUSH = 57405, // Visual and target selector for the starting knockback from the pipe + BG_DS_SPELL_FLUSH_KNOCKBACK = 61698, // Knockback effect for previous spell (triggered, not need to be casted) + BG_DS_SPELL_WATER_SPOUT = 58873, // Knockback effect of the central waterfall +}; + enum BattlegroundDSData { // These values are NOT blizzlike... need the correct data! BG_DS_WATERFALL_TIMER_MIN = 30000, BG_DS_WATERFALL_TIMER_MAX = 60000, BG_DS_WATERFALL_WARNING_DURATION = 7000, BG_DS_WATERFALL_DURATION = 10000, + BG_DS_PIPE_KNOCKBACK_FIRST_DELAY = 5000, + BG_DS_PIPE_KNOCKBACK_DELAY = 3000, + BG_DS_PIPE_KNOCKBACK_TOTAL_COUNT = 2, BG_DS_WATERFALL_STATUS_WARNING = 1, // Water starting to fall, but no LoS Blocking nor movement blocking BG_DS_WATERFALL_STATUS_ON = 2, // LoS and Movement blocking active @@ -83,12 +106,18 @@ class BattlegroundDS : public Battleground private: uint32 _waterfallTimer; uint8 _waterfallStatus; + uint32 _pipeKnockBackTimer; + uint8 _pipeKnockBackCount; virtual void PostUpdateImpl(uint32 diff); protected: uint32 getWaterFallStatus() { return _waterfallStatus; }; - void setWaterFallStatus(uint32 status) { _waterfallStatus = status; }; - void setWaterFallTimer(uint32 timer) { _waterfallTimer = timer; }; + void setWaterFallStatus(uint8 status) { _waterfallStatus = status; }; uint32 getWaterFallTimer() { return _waterfallTimer; }; + void setWaterFallTimer(uint32 timer) { _waterfallTimer = timer; }; + uint8 getPipeKnockBackCount() { return _pipeKnockBackCount; }; + void setPipeKnockBackCount(uint8 count) { _pipeKnockBackCount = count; }; + uint32 getPipeKnockBackTimer() { return _pipeKnockBackTimer; }; + void setPipeKnockBackTimer(uint32 timer) { _pipeKnockBackTimer = timer; }; }; #endif diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 43a29e93c55..034de38fd9c 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -437,8 +437,8 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target ChatMsg type = CHAT_MSG_BG_SYSTEM_NEUTRAL; //alliance flag picked up from base - if (Source->GetTeam() == HORDE && this->GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE - && this->BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID()) + if (Source->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE + && BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID()) { message_id = LANG_BG_WS_PICKEDUP_AF; type = CHAT_MSG_BG_SYSTEM_HORDE; @@ -456,8 +456,8 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target } //horde flag picked up from base - if (Source->GetTeam() == ALLIANCE && this->GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE - && this->BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID()) + if (Source->GetTeam() == ALLIANCE && GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE + && BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID()) { message_id = LANG_BG_WS_PICKEDUP_HF; type = CHAT_MSG_BG_SYSTEM_ALLIANCE; @@ -475,7 +475,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target } //Alliance flag on ground(not in base) (returned or picked up again from ground!) - if (GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10)) + if (GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID()) { if (Source->GetTeam() == ALLIANCE) { @@ -509,7 +509,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target } //Horde flag on ground(not in base) (returned or picked up again) - if (GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10)) + if (GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID()) { if (Source->GetTeam() == HORDE) { diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index ea420d88516..761bbb9b496 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -309,7 +309,7 @@ void CalendarMgr::AddAction(CalendarAction const& action) case CALENDAR_ACTION_REMOVE_EVENT: { uint64 eventId = action.Event.GetEventId(); - uint32 flags = action.Event.GetFlags(); + //uint32 flags = action.Event.GetFlags(); // FIXME - Use of Flags here! CalendarEvent* calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER); @@ -375,7 +375,7 @@ void CalendarMgr::AddAction(CalendarAction const& action) uint64 eventId = action.Invite.GetEventId(); uint64 inviteId = action.Invite.GetInviteId(); - CalendarEvent* calendarEvent; + CalendarEvent* calendarEvent = NULL; if (action.GetInviteId() != action.Invite.GetInviteId()) calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); else @@ -395,7 +395,7 @@ void CalendarMgr::AddAction(CalendarAction const& action) uint64 eventId = action.Invite.GetEventId(); uint64 inviteId = action.Invite.GetInviteId(); - CalendarEvent* calendarEvent; + CalendarEvent* calendarEvent = NULL; if (action.GetInviteId() != action.Invite.GetInviteId()) calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER); else @@ -420,6 +420,9 @@ void CalendarMgr::AddAction(CalendarAction const& action) // already checked in CheckPermisions CalendarInvite* invite = GetInvite(inviteId); + if (!invite) + return; + if (calendarEvent->GetCreatorGUID() == invite->GetInvitee()) { action.GetPlayer()->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_DELETE_CREATOR_FAILED); diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index b6e9dd30d28..92cf4d750a8 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -671,7 +671,7 @@ void Channel::Invite(uint64 p, const char *newname) } Player* newp = sObjectAccessor->FindPlayerByName(newname); - if (!newp) + if (!newp || !newp->isGMVisible()) { WorldPacket data; MakePlayerNotFound(&data, newname); diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 7d21f94f372..755b9299352 100755 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -114,7 +114,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) case CONDITION_QUESTREWARDED: { if (Player* player = object->ToPlayer()) - condMeets = (player->GetQuestRewardStatus(ConditionValue1) == !ConditionValue2); + condMeets = player->GetQuestRewardStatus(ConditionValue1); break; } case CONDITION_QUESTTAKEN: @@ -122,7 +122,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) if (Player* player = object->ToPlayer()) { QuestStatus status = player->GetQuestStatus(ConditionValue1); - condMeets = ((status == QUEST_STATUS_INCOMPLETE) == !ConditionValue2); + condMeets = (status == QUEST_STATUS_INCOMPLETE); } break; } @@ -131,7 +131,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) if (Player* player = object->ToPlayer()) { QuestStatus status = player->GetQuestStatus(ConditionValue1); - condMeets = ((status == QUEST_STATUS_COMPLETE && !player->GetQuestRewardStatus(ConditionValue1)) == !ConditionValue2); + condMeets = (status == QUEST_STATUS_COMPLETE && !player->GetQuestRewardStatus(ConditionValue1)); } break; } @@ -140,7 +140,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) if (Player* player = object->ToPlayer()) { QuestStatus status = player->GetQuestStatus(ConditionValue1); - condMeets = ((status == QUEST_STATUS_NONE) == !ConditionValue2); + condMeets = (status == QUEST_STATUS_NONE); } break; } @@ -515,7 +515,9 @@ bool ConditionMgr::IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, sLog->outDebug(LOG_FILTER_CONDITIONSYS, "ConditionMgr::IsPlayerMeetToConditionList condType: %u val1: %u", (*i)->ConditionType, (*i)->ConditionValue1); if ((*i)->isLoaded()) { + //! Find ElseGroup in ElseGroupStore std::map<uint32, bool>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup); + //! If not found, add an entry in the store and set to true (placeholder) if (itr == ElseGroupStore.end()) ElseGroupStore[(*i)->ElseGroup] = true; else if (!(*itr).second) @@ -854,18 +856,6 @@ void ConditionMgr::LoadConditions(bool isReload) break; case CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT: { - //if no list for npc create one - if (SpellClickEventConditionStore.find(cond->SourceGroup) == SpellClickEventConditionStore.end()) - { - ConditionTypeContainer cmap; - SpellClickEventConditionStore[cond->SourceGroup] = cmap; - } - //if no list for spellclick spell create one - if (SpellClickEventConditionStore[cond->SourceGroup].find(cond->SourceEntry) == SpellClickEventConditionStore[cond->SourceGroup].end()) - { - ConditionList clist; - SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry] = clist; - } SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond); valid = true; ++count; @@ -877,18 +867,6 @@ void ConditionMgr::LoadConditions(bool isReload) break; case CONDITION_SOURCE_TYPE_VEHICLE_SPELL: { - //if no list for vehicle create one - if (VehicleSpellConditionStore.find(cond->SourceGroup) == VehicleSpellConditionStore.end()) - { - ConditionTypeContainer cmap; - VehicleSpellConditionStore[cond->SourceGroup] = cmap; - } - //if no list for vehicle's spell create one - if (VehicleSpellConditionStore[cond->SourceGroup].find(cond->SourceEntry) == VehicleSpellConditionStore[cond->SourceGroup].end()) - { - ConditionList clist; - VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry] = clist; - } VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond); valid = true; ++count; @@ -896,18 +874,8 @@ void ConditionMgr::LoadConditions(bool isReload) } case CONDITION_SOURCE_TYPE_SMART_EVENT: { - // If the entry does not exist, create a new list + //! TODO: PAIR_32 ? std::pair<int32, uint32> key = std::make_pair(cond->SourceEntry, cond->SourceId); - if (SmartEventConditionStore.find(key) == SmartEventConditionStore.end()) - { - ConditionTypeContainer cmap; - SmartEventConditionStore[key] = cmap; - } - if (SmartEventConditionStore[key].find(cond->SourceGroup) == SmartEventConditionStore[key].end()) - { - ConditionList clist; - SmartEventConditionStore[key][cond->SourceGroup] = clist; - } SmartEventConditionStore[key][cond->SourceGroup].push_back(cond); valid = true; ++count; @@ -1929,6 +1897,19 @@ void ConditionMgr::Clean() SmartEventConditionStore.clear(); + for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr) + { + for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it) + { + for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) + delete *i; + it->second.clear(); + } + itr->second.clear(); + } + + SpellClickEventConditionStore.clear(); + // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;) for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr; diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 5a5e2dd1c2e..ec6d6dd8453 100755 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -72,6 +72,33 @@ enum ConditionTypes CONDITION_MAX = 39 // MAX }; +/*! Documentation on implementing a new ConditionSourceType: + Step 1: Check for the lowest free ID. Look for CONDITION_SOURCE_TYPE_UNUSED_XX in the enum. + Then define the new source type. + + Step 2: Determine and map the parameters for the new condition type. + + Step 3: Add a case block to ConditionMgr::isSourceTypeValid with the new condition type + and validate the parameters. + + Step 4: If your condition can be grouped (determined in step 2), add a rule for it in + ConditionMgr::CanHaveSourceGroupSet, following the example of the existing types. + + Step 5: Define the maximum available condition targets in ConditionMgr::GetMaxAvailableConditionTargets. + + The following steps only apply if your condition can be grouped: + + Step 6: Determine how you are going to store your conditions. You need to add a new storage container + for it in ConditionMgr class, along with a function like: + ConditionList GetConditionsForXXXYourNewSourceTypeXXX(parameters...) + + The above function should be placed in upper level (practical) code that actually + checks the conditions. + + Step 7: Implement loading for your source type in ConditionMgr::LoadConditions. + + Step 8: Implement memory cleaning for your source type in ConditionMgr::Clean. +*/ enum ConditionSourceType { CONDITION_SOURCE_TYPE_NONE = 0, diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index da5975aafbe..5b7c40e5494 100755 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -32,7 +32,7 @@ Corpse::Corpse(CorpseType type) : WorldObject(type != CORPSE_BONES) m_objectType |= TYPEMASK_CORPSE; m_objectTypeId = TYPEID_CORPSE; - m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION); + m_updateFlag = (UPDATEFLAG_LOWGUID | UPDATEFLAG_STATIONARY_POSITION | UPDATEFLAG_POSITION); m_valuesCount = CORPSE_END; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 20bcfc8f41c..0fe2016950b 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -303,7 +303,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData* data return false; } - uint32 displayID = sObjectMgr->ChooseDisplayId(0, GetCreatureInfo(), data); + uint32 displayID = sObjectMgr->ChooseDisplayId(0, GetCreatureTemplate(), data); CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID); if (!minfo) // Cancel load if no model defined { @@ -342,7 +342,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData* data m_defaultMovementType = IDLE_MOTION_TYPE; for (uint8 i=0; i < CREATURE_MAX_SPELLS; ++i) - m_spells[i] = GetCreatureInfo()->spells[i]; + m_spells[i] = GetCreatureTemplate()->spells[i]; return true; } @@ -352,14 +352,14 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData* data) if (!InitEntry(Entry, team, data)) return false; - CreatureTemplate const* cInfo = GetCreatureInfo(); + CreatureTemplate const* cInfo = GetCreatureTemplate(); m_regenHealth = cInfo->RegenHealth; // creatures always have melee weapon ready if any SetSheath(SHEATH_STATE_MELEE); - SelectLevel(GetCreatureInfo()); + SelectLevel(GetCreatureTemplate()); if (team == HORDE) setFaction(cInfo->faction_H); else @@ -754,7 +754,7 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, if (!CreateFromProto(guidlow, Entry, vehId, team, data)) return false; - switch (GetCreatureInfo()->rank) + switch (GetCreatureTemplate()->rank) { case CREATURE_ELITE_RARE: m_corpseDelay = sWorld->getIntConfig(CONFIG_CORPSE_DECAY_RARE); @@ -783,7 +783,7 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender); } - if (GetCreatureInfo()->InhabitType & INHABIT_AIR) + if (GetCreatureTemplate()->InhabitType & INHABIT_AIR) { if (GetDefaultMovementType() == IDLE_MOTION_TYPE) AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); @@ -791,10 +791,10 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, SetFlying(true); } - if (GetCreatureInfo()->InhabitType & INHABIT_WATER) + if (GetCreatureTemplate()->InhabitType & INHABIT_WATER) AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING); - LastUsedScriptID = GetCreatureInfo()->ScriptID; + LastUsedScriptID = GetCreatureTemplate()->ScriptID; // TODO: Replace with spell, handle from DB if (isSpiritHealer() || isSpiritGuide()) @@ -816,22 +816,22 @@ bool Creature::isCanTrainingOf(Player* player, bool msg) const TrainerSpellData const* trainer_spells = GetTrainerSpells(); - if ((!trainer_spells || trainer_spells->spellList.empty()) && GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS) + if ((!trainer_spells || trainer_spells->spellList.empty()) && GetCreatureTemplate()->trainer_type != TRAINER_TYPE_PETS) { sLog->outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.", GetGUIDLow(), GetEntry()); return false; } - switch (GetCreatureInfo()->trainer_type) + switch (GetCreatureTemplate()->trainer_type) { case TRAINER_TYPE_CLASS: - if (player->getClass() != GetCreatureInfo()->trainer_class) + if (player->getClass() != GetCreatureTemplate()->trainer_class) { if (msg) { player->PlayerTalkClass->ClearMenus(); - switch (GetCreatureInfo()->trainer_class) + switch (GetCreatureTemplate()->trainer_class) { case CLASS_DRUID: player->PlayerTalkClass->SendGossipMenu(4913, GetGUID()); break; case CLASS_HUNTER: player->PlayerTalkClass->SendGossipMenu(10090, GetGUID()); break; @@ -856,12 +856,12 @@ bool Creature::isCanTrainingOf(Player* player, bool msg) const } break; case TRAINER_TYPE_MOUNTS: - if (GetCreatureInfo()->trainer_race && player->getRace() != GetCreatureInfo()->trainer_race) + if (GetCreatureTemplate()->trainer_race && player->getRace() != GetCreatureTemplate()->trainer_race) { if (msg) { player->PlayerTalkClass->ClearMenus(); - switch (GetCreatureInfo()->trainer_class) + switch (GetCreatureTemplate()->trainer_class) { case RACE_DWARF: player->PlayerTalkClass->SendGossipMenu(5865, GetGUID()); break; case RACE_GNOME: player->PlayerTalkClass->SendGossipMenu(4881, GetGUID()); break; @@ -879,7 +879,7 @@ bool Creature::isCanTrainingOf(Player* player, bool msg) const } break; case TRAINER_TYPE_TRADESKILLS: - if (GetCreatureInfo()->trainer_spell && !player->HasSpell(GetCreatureInfo()->trainer_spell)) + if (GetCreatureTemplate()->trainer_spell && !player->HasSpell(GetCreatureTemplate()->trainer_spell)) { if (msg) { @@ -930,8 +930,8 @@ bool Creature::isCanInteractWithBattleMaster(Player* player, bool msg) const bool Creature::isCanTrainingAndResetTalentsOf(Player* player) const { return player->getLevel() >= 10 - && GetCreatureInfo()->trainer_type == TRAINER_TYPE_CLASS - && player->getClass() == GetCreatureInfo()->trainer_class; + && GetCreatureTemplate()->trainer_type == TRAINER_TYPE_CLASS + && player->getClass() == GetCreatureTemplate()->trainer_class; } void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 /*MovementFlags*/, uint8 /*type*/) @@ -1040,7 +1040,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) uint32 dynamicflags = GetUInt32Value(UNIT_DYNAMIC_FLAGS); // check if it's a custom model and if not, use 0 for displayId - CreatureTemplate const* cinfo = GetCreatureInfo(); + CreatureTemplate const* cinfo = GetCreatureTemplate(); if (cinfo) { if (displayId == cinfo->Modelid1 || displayId == cinfo->Modelid2 || @@ -1302,7 +1302,7 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap) curhealth = data->curhealth; if (curhealth) { - curhealth = uint32(curhealth*_GetHealthMod(GetCreatureInfo()->rank)); + curhealth = uint32(curhealth*_GetHealthMod(GetCreatureTemplate()->rank)); if (curhealth < 1) curhealth = 1; } @@ -1502,8 +1502,8 @@ void Creature::setDeathState(DeathState s) setActive(false); - if (!isPet() && GetCreatureInfo()->SkinLootId) - if (LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId)) + if (!isPet() && GetCreatureTemplate()->SkinLootId) + if (LootTemplates_Skinning.HaveLootFor(GetCreatureTemplate()->SkinLootId)) if (hasLootRecipient()) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); @@ -1529,11 +1529,11 @@ void Creature::setDeathState(DeathState s) SetFullHealth(); SetLootRecipient(NULL); ResetPlayerDamageReq(); - CreatureTemplate const* cinfo = GetCreatureInfo(); + CreatureTemplate const* cinfo = GetCreatureTemplate(); SetWalk(true); - if (GetCreatureInfo()->InhabitType & INHABIT_AIR) + if (GetCreatureTemplate()->InhabitType & INHABIT_AIR) AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING); - if (GetCreatureInfo()->InhabitType & INHABIT_WATER) + if (GetCreatureTemplate()->InhabitType & INHABIT_WATER) AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING); SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag); ClearUnitState(uint32(UNIT_STATE_ALL_STATE)); @@ -1573,7 +1573,7 @@ void Creature::Respawn(bool force) if (m_originalEntry != GetEntry()) UpdateEntry(m_originalEntry); - CreatureTemplate const* cinfo = GetCreatureInfo(); + CreatureTemplate const* cinfo = GetCreatureTemplate(); SelectLevel(cinfo); setDeathState(JUST_ALIVED); @@ -1634,11 +1634,11 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) return false; // Spells that don't have effectMechanics. - if (!spellInfo->HasAnyEffectMechanic() && GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1))) + if (!spellInfo->HasAnyEffectMechanic() && GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1))) return true; - // This check must be done instead of 'if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))' for not break - // the check of mechanic immunity on DB (tested) because GetCreatureInfo()->MechanicImmuneMask and m_spellImmune[IMMUNITY_MECHANIC] don't have same data. + // This check must be done instead of 'if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))' for not break + // the check of mechanic immunity on DB (tested) because GetCreatureTemplate()->MechanicImmuneMask and m_spellImmune[IMMUNITY_MECHANIC] don't have same data. bool immunedToAllEffects = true; for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (!IsImmunedToSpellEffect(spellInfo, i)) @@ -1654,10 +1654,10 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const { - if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Effects[index].Mechanic - 1))) + if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Effects[index].Mechanic - 1))) return true; - if (GetCreatureInfo()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effects[index].Effect == SPELL_EFFECT_HEAL) + if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effects[index].Effect == SPELL_EFFECT_HEAL) return true; return Unit::IsImmunedToSpellEffect(spellInfo, index); @@ -2015,7 +2015,7 @@ CreatureAddon const* Creature::GetCreatureAddon() const } // dependent from difficulty mode entry - return sObjectMgr->GetCreatureTemplateAddon(GetCreatureInfo()->Entry); + return sObjectMgr->GetCreatureTemplateAddon(GetCreatureTemplate()->Entry); } //creature_addon table @@ -2236,7 +2236,7 @@ void Creature::AllLootRemovedFromCorpse() return; float decayRate; - CreatureTemplate const* cinfo = GetCreatureInfo(); + CreatureTemplate const* cinfo = GetCreatureTemplate(); decayRate = sWorld->getRate(RATE_CORPSE_DECAY_LOOTED); uint32 diff = uint32((m_corpseRemoveTime - now) * decayRate); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 40477de7c75..f986e09e7cb 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -457,17 +457,17 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature void Update(uint32 time); // overwrited Unit::Update void GetRespawnPosition(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; - uint32 GetEquipmentId() const { return GetCreatureInfo()->equipmentId; } + uint32 GetEquipmentId() const { return GetCreatureTemplate()->equipmentId; } void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } uint32 GetCorpseDelay() const { return m_corpseDelay; } - bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; } - bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; } - bool isTrigger() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; } - bool isGuard() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; } - bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; } - bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } - //bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } + bool isRacialLeader() const { return GetCreatureTemplate()->RacialLeader; } + bool isCivilian() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; } + bool isTrigger() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; } + bool isGuard() const { return GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; } + bool canWalk() const { return GetCreatureTemplate()->InhabitType & INHABIT_GROUND; } + bool canSwim() const { return GetCreatureTemplate()->InhabitType & INHABIT_WATER; } + //bool canFly() const { return GetCreatureTemplate()->InhabitType & INHABIT_AIR; } void SetReactState(ReactStates st) { m_reactState = st; } ReactStates GetReactState() { return m_reactState; } @@ -496,7 +496,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature if (isPet()) return false; - uint32 rank = GetCreatureInfo()->rank; + uint32 rank = GetCreatureTemplate()->rank; return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE; } @@ -505,7 +505,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature if (isPet()) return false; - return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS; + return GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS; } bool IsDungeonBoss() const; @@ -558,7 +558,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature TrainerSpellData const* GetTrainerSpells() const; - CreatureTemplate const* GetCreatureInfo() const { return m_creatureInfo; } + CreatureTemplate const* GetCreatureTemplate() const { return m_creatureInfo; } CreatureData const* GetCreatureData() const { return m_creatureData; } CreatureAddon const* GetCreatureAddon() const; diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.cpp b/src/server/game/Entities/DynamicObject/DynamicObject.cpp index fa975e0cd39..0a4e4c73f42 100755 --- a/src/server/game/Entities/DynamicObject/DynamicObject.cpp +++ b/src/server/game/Entities/DynamicObject/DynamicObject.cpp @@ -33,7 +33,7 @@ DynamicObject::DynamicObject(bool isWorldObject) : WorldObject(isWorldObject), m_objectType |= TYPEMASK_DYNAMICOBJECT; m_objectTypeId = TYPEID_DYNAMICOBJECT; - m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION); + m_updateFlag = (UPDATEFLAG_LOWGUID | UPDATEFLAG_STATIONARY_POSITION | UPDATEFLAG_POSITION); m_valuesCount = DYNAMICOBJECT_END; } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index a06cee891e7..c7101e918ba 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -38,7 +38,7 @@ GameObject::GameObject() : WorldObject(false), m_model(NULL), m_goValue(new Game m_objectType |= TYPEMASK_GAMEOBJECT; m_objectTypeId = TYPEID_GAMEOBJECT; - m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION | UPDATEFLAG_ROTATION); + m_updateFlag = (UPDATEFLAG_LOWGUID | UPDATEFLAG_STATIONARY_POSITION | UPDATEFLAG_POSITION | UPDATEFLAG_ROTATION); m_valuesCount = GAMEOBJECT_END; m_respawnTime = 0; diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 70b81593b56..90f6f4a217c 100755 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -56,8 +56,7 @@ void AddItemsSetItem(Player* player, Item* item) if (!eff) { - eff = new ItemSetEffect; - memset(eff, 0, sizeof(ItemSetEffect)); + eff = new ItemSetEffect(); eff->setid = setid; size_t x = 0; @@ -238,7 +237,7 @@ Item::Item() m_objectType |= TYPEMASK_ITEM; m_objectTypeId = TYPEID_ITEM; - m_updateFlag = UPDATEFLAG_HIGHGUID; + m_updateFlag = UPDATEFLAG_LOWGUID; m_valuesCount = ITEM_END; m_slot = 0; @@ -780,20 +779,18 @@ bool Item::CanBeTraded(bool mail, bool trade) const bool Item::HasEnchantRequiredSkill(const Player* player) const { - - // Check all enchants for required skill - for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot) - if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot))) - if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id)) - if (enchantEntry->requiredSkill && player->GetSkillValue(enchantEntry->requiredSkill) < enchantEntry->requiredSkillValue) - return false; + // Check all enchants for required skill + for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot) + if (uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot))) + if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id)) + if (enchantEntry->requiredSkill && player->GetSkillValue(enchantEntry->requiredSkill) < enchantEntry->requiredSkillValue) + return false; return true; } uint32 Item::GetEnchantRequiredLevel() const { - uint32 level = 0; // Check all enchants for required level @@ -861,7 +858,7 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const // Special case - accept weapon type for main and offhand requirements if (proto->InventoryType == INVTYPE_WEAPON && (spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONMAINHAND) || - spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONOFFHAND))) + spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONOFFHAND))) return true; else if ((spellInfo->EquippedItemInventoryTypeMask & (1 << proto->InventoryType)) == 0) return false; // inventory type not present in mask @@ -1001,12 +998,13 @@ bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) cons // time. void Item::SendTimeUpdate(Player* owner) { - if (!GetUInt32Value(ITEM_FIELD_DURATION)) + uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION); + if (!duration) return; WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8+4)); - data << (uint64)GetGUID(); - data << (uint32)GetUInt32Value(ITEM_FIELD_DURATION); + data << uint64(GetGUID()); + data << uint32(duration); owner->GetSession()->SendPacket(&data); } diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index c98364ecb2d..2a2b78f4630 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -209,7 +209,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c if (target == this) // building packet for yourself flags |= UPDATEFLAG_SELF; - if (flags & UPDATEFLAG_HAS_POSITION) + if (flags & UPDATEFLAG_STATIONARY_POSITION) { // UPDATETYPE_CREATE_OBJECT2 dynamic objects, corpses... if (isType(TYPEMASK_DYNAMICOBJECT) || isType(TYPEMASK_CORPSE) || isType(TYPEMASK_PLAYER)) @@ -293,19 +293,21 @@ void Object::BuildOutOfRangeUpdateBlock(UpdateData* data) const data->AddOutOfRangeGUID(GetGUID()); } -void Object::DestroyForPlayer(Player* target, bool anim) const +void Object::DestroyForPlayer(Player* target, bool onDeath) const { ASSERT(target); WorldPacket data(SMSG_DESTROY_OBJECT, 8 + 1); data << uint64(GetGUID()); - data << uint8(anim ? 1 : 0); // WotLK (bool), may be despawn animation + //! If the following bool is true, the client will call "void CGUnit_C::OnDeath()" for this object. + //! OnDeath() does for eg trigger death animation and interrupts certain spells/missiles/auras/sounds... + data << uint8(onDeath ? 1 : 0); target->GetSession()->SendPacket(&data); } -void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const +void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const { - *data << (uint16)flags; // update flags + *data << uint16(flags); // update flags // 0x20 if (flags & UPDATEFLAG_LIVING) @@ -330,13 +332,29 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const { if (flags & UPDATEFLAG_POSITION) { - *data << uint8(0); // unk PGUID! - *data << ((WorldObject*)this)->GetPositionX(); - *data << ((WorldObject*)this)->GetPositionY(); - *data << ((WorldObject*)this)->GetPositionZ(); + Transport* transport = ((WorldObject*)this)->GetTransport(); + if (transport) + data->append(transport->GetPackGUID()); + else + *data << uint8(0); + *data << ((WorldObject*)this)->GetPositionX(); *data << ((WorldObject*)this)->GetPositionY(); *data << ((WorldObject*)this)->GetPositionZ(); + + if (transport) + { + *data << ((WorldObject*)this)->GetTransOffsetX(); + *data << ((WorldObject*)this)->GetTransOffsetY(); + *data << ((WorldObject*)this)->GetTransOffsetZ(); + } + else + { + *data << ((WorldObject*)this)->GetPositionX(); + *data << ((WorldObject*)this)->GetPositionY(); + *data << ((WorldObject*)this)->GetPositionZ(); + } + *data << ((WorldObject*)this)->GetOrientation(); if (GetTypeId() == TYPEID_CORPSE) @@ -347,28 +365,23 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const else { // 0x40 - if (flags & UPDATEFLAG_HAS_POSITION) + if (flags & UPDATEFLAG_STATIONARY_POSITION) { - // 0x02 - if (flags & UPDATEFLAG_TRANSPORT && ((GameObject*)this)->GetGoType() == GAMEOBJECT_TYPE_MO_TRANSPORT) - { - *data << (float)0; - *data << (float)0; - *data << (float)0; - *data << ((WorldObject*)this)->GetOrientation(); - } - else - { - *data << ((WorldObject*)this)->GetPositionX(); - *data << ((WorldObject*)this)->GetPositionY(); - *data << ((WorldObject*)this)->GetPositionZ(); - *data << ((WorldObject*)this)->GetOrientation(); - } + *data << ((WorldObject*)this)->GetPositionX(); + *data << ((WorldObject*)this)->GetPositionY(); + *data << ((WorldObject*)this)->GetPositionZ(); + *data << ((WorldObject*)this)->GetOrientation(); } } } // 0x8 + if (flags & UPDATEFLAG_UNKNOWN) + { + *data << uint32(0); + } + + // 0x10 if (flags & UPDATEFLAG_LOWGUID) { switch (GetTypeId()) @@ -381,14 +394,16 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const case TYPEID_CORPSE: *data << uint32(GetGUIDLow()); // GetGUIDLow() break; + //! Unit, Player and default here are sending wrong values. + //! TODO: Research the proper formula case TYPEID_UNIT: - *data << uint32(0x0000000B); // unk, can be 0xB or 0xC + *data << uint32(0x0000000B); // unk break; case TYPEID_PLAYER: if (flags & UPDATEFLAG_SELF) - *data << uint32(0x0000002F); // unk, can be 0x15 or 0x22 + *data << uint32(0x0000002F); // unk else - *data << uint32(0x00000008); // unk, can be 0x7 or 0x8 + *data << uint32(0x00000008); // unk break; default: *data << uint32(0x00000000); // unk @@ -396,15 +411,8 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const } } - // 0x10 - if (flags & UPDATEFLAG_HIGHGUID) - { - // not high guid - *data << uint32(GetUInt32Value(OBJECT_FIELD_GUID)); // unk - } - // 0x4 - if (flags & UPDATEFLAG_HAS_TARGET) // packed guid (current target guid) + if (flags & UPDATEFLAG_HAS_TARGET) { if (Unit* victim = ((Unit*)this)->getVictim()) data->append(victim->GetPackGUID()); @@ -415,14 +423,15 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const // 0x2 if (flags & UPDATEFLAG_TRANSPORT) { - *data << uint32(getMSTime()); // ms time + *data << uint32(getMSTime()); // Unknown - getMSTime is wrong. } // 0x80 - if (flags & UPDATEFLAG_VEHICLE) // unused for now + if (flags & UPDATEFLAG_VEHICLE) { - *data << uint32(((Unit*)this)->GetVehicleKit()->GetVehicleInfo()->m_ID); // vehicle id - *data << float(((Creature*)this)->GetOrientation()); // facing adjustment + // TODO: Allow players to aquire this updateflag. + *data << uint32(((Unit*)this)->GetVehicleKit()->GetVehicleInfo()->m_ID); + *data << float(((Creature*)this)->GetOrientation()); } // 0x200 @@ -541,7 +550,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask* { if (GetTypeId() == TYPEID_UNIT) { - CreatureTemplate const* cinfo = ToCreature()->GetCreatureInfo(); + CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate(); // this also applies for transform auras if (SpellInfo const* transform = sSpellMgr->GetSpellInfo(ToUnit()->getTransForm())) @@ -581,7 +590,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask* { uint32 dynamicFlags = m_uint32Values[index]; - if (const Creature* creature = ToCreature()) + if (Creature const* creature = ToCreature()) { if (creature->hasLootRecipient()) { diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 7b3fcc4a337..c243527570b 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -147,7 +147,7 @@ class Object void BuildOutOfRangeUpdateBlock(UpdateData* data) const; void BuildMovementUpdateBlock(UpdateData* data, uint32 flags = 0) const; - virtual void DestroyForPlayer(Player* target, bool anim = false) const; + virtual void DestroyForPlayer(Player* target, bool onDeath = false) const; int32 GetInt32Value(uint16 index) const { @@ -299,18 +299,18 @@ class Object // FG: some hacky helpers void ForceValuesUpdateAtIndex(uint32); - Player* ToPlayer(){ if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player*>(this); else return NULL; } - const Player* ToPlayer() const { if (GetTypeId() == TYPEID_PLAYER) return (const Player*)((Player*)this); else return NULL; } - Creature* ToCreature(){ if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return NULL; } - const Creature* ToCreature() const {if (GetTypeId() == TYPEID_UNIT) return (const Creature*)((Creature*)this); else return NULL; } + Player* ToPlayer() { if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player*>(this); else return NULL; } + Player const* ToPlayer() const { if (GetTypeId() == TYPEID_PLAYER) return (Player const*)((Player*)this); else return NULL; } + Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return NULL; } + Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return (Creature const*)((Creature*)this); else return NULL; } - Unit* ToUnit(){ if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Unit*>(this); else return NULL; } - const Unit* ToUnit() const {if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return (const Unit*)((Unit*)this); else return NULL; } - GameObject* ToGameObject(){ if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject*>(this); else return NULL; } - const GameObject* ToGameObject() const {if (GetTypeId() == TYPEID_GAMEOBJECT) return (const GameObject*)((GameObject*)this); else return NULL; } + Unit* ToUnit() { if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Unit*>(this); else return NULL; } + Unit const* ToUnit() const { if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return (const Unit*)((Unit*)this); else return NULL; } + GameObject* ToGameObject() { if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject*>(this); else return NULL; } + GameObject const* ToGameObject() const { if (GetTypeId() == TYPEID_GAMEOBJECT) return (const GameObject*)((GameObject*)this); else return NULL; } - Corpse* ToCorpse(){ if (GetTypeId() == TYPEID_CORPSE) return reinterpret_cast<Corpse*>(this); else return NULL; } - const Corpse* ToCorpse() const {if (GetTypeId() == TYPEID_CORPSE) return (const Corpse*)((Corpse*)this); else return NULL; } + Corpse* ToCorpse() { if (GetTypeId() == TYPEID_CORPSE) return reinterpret_cast<Corpse*>(this); else return NULL; } + Corpse const* ToCorpse() const { if (GetTypeId() == TYPEID_CORPSE) return (const Corpse*)((Corpse*)this); else return NULL; } protected: Object (); diff --git a/src/server/game/Entities/Object/Updates/UpdateData.h b/src/server/game/Entities/Object/Updates/UpdateData.h index e4caaec3117..ff649b7cb2f 100755 --- a/src/server/game/Entities/Object/Updates/UpdateData.h +++ b/src/server/game/Entities/Object/Updates/UpdateData.h @@ -34,17 +34,17 @@ enum OBJECT_UPDATE_TYPE enum OBJECT_UPDATE_FLAGS { - UPDATEFLAG_NONE = 0x0000, - UPDATEFLAG_SELF = 0x0001, - UPDATEFLAG_TRANSPORT = 0x0002, - UPDATEFLAG_HAS_TARGET = 0x0004, - UPDATEFLAG_LOWGUID = 0x0008, - UPDATEFLAG_HIGHGUID = 0x0010, - UPDATEFLAG_LIVING = 0x0020, - UPDATEFLAG_HAS_POSITION = 0x0040, - UPDATEFLAG_VEHICLE = 0x0080, - UPDATEFLAG_POSITION = 0x0100, - UPDATEFLAG_ROTATION = 0x0200 + UPDATEFLAG_NONE = 0x0000, + UPDATEFLAG_SELF = 0x0001, + UPDATEFLAG_TRANSPORT = 0x0002, + UPDATEFLAG_HAS_TARGET = 0x0004, + UPDATEFLAG_UNKNOWN = 0x0008, + UPDATEFLAG_LOWGUID = 0x0010, + UPDATEFLAG_LIVING = 0x0020, + UPDATEFLAG_STATIONARY_POSITION = 0x0040, + UPDATEFLAG_VEHICLE = 0x0080, + UPDATEFLAG_POSITION = 0x0100, + UPDATEFLAG_ROTATION = 0x0200 }; class UpdateData diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 566ee06218e..e7103e2cb70 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -180,7 +180,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c setFaction(owner->getFaction()); SetUInt32Value(UNIT_CREATED_BY_SPELL, summon_spell_id); - CreatureTemplate const* cinfo = GetCreatureInfo(); + CreatureTemplate const* cinfo = GetCreatureTemplate(); if (cinfo->type == CREATURE_TYPE_CRITTER) { map->AddToMap(this->ToCreature()); @@ -692,7 +692,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) { ASSERT(creature); - if (!CreateBaseAtTamed(creature->GetCreatureInfo(), creature->GetMap(), creature->GetPhaseMask())) + if (!CreateBaseAtTamed(creature->GetCreatureTemplate(), creature->GetMap(), creature->GetPhaseMask())) return false; Relocate(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation()); @@ -704,7 +704,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) return false; } - CreatureTemplate const* cinfo = GetCreatureInfo(); + CreatureTemplate const* cinfo = GetCreatureTemplate(); if (!cinfo) { sLog->outError("CreateBaseAtCreature() failed, creatureInfo is missing!"); @@ -763,7 +763,7 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phas // TODO: Move stat mods code to pet passive auras bool Guardian::InitStatsForLevel(uint8 petlevel) { - CreatureTemplate const* cinfo = GetCreatureInfo(); + CreatureTemplate const* cinfo = GetCreatureTemplate(); ASSERT(cinfo); SetLevel(petlevel); @@ -997,7 +997,7 @@ bool Pet::HaveInDiet(ItemTemplate const* item) const if (!item->FoodType) return false; - CreatureTemplate const* cInfo = GetCreatureInfo(); + CreatureTemplate const* cInfo = GetCreatureTemplate(); if (!cInfo) return false; @@ -1405,7 +1405,7 @@ void Pet::InitLevelupSpellsForLevel() { uint8 level = getLevel(); - if (PetLevelupSpellSet const* levelupSpells = GetCreatureInfo()->family ? sSpellMgr->GetPetLevelupSpellList(GetCreatureInfo()->family) : NULL) + if (PetLevelupSpellSet const* levelupSpells = GetCreatureTemplate()->family ? sSpellMgr->GetPetLevelupSpellList(GetCreatureTemplate()->family) : NULL) { // PetLevelupSpellSet ordered by levels, process in reversed order for (PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr) @@ -1419,7 +1419,7 @@ void Pet::InitLevelupSpellsForLevel() } } - int32 petSpellsId = GetCreatureInfo()->PetSpellDataId ? -(int32)GetCreatureInfo()->PetSpellDataId : GetEntry(); + int32 petSpellsId = GetCreatureTemplate()->PetSpellDataId ? -(int32)GetCreatureTemplate()->PetSpellDataId : GetEntry(); // default spells (can be not learned if pet level (as owner level decrease result for example) less first possible in normal game) if (PetDefaultSpellsEntry const* defSpells = sSpellMgr->GetPetDefaultSpellsEntry(petSpellsId)) @@ -1543,7 +1543,7 @@ bool Pet::resetTalents() if (owner->ToPlayer()->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) owner->ToPlayer()->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS, true); - CreatureTemplate const* ci = GetCreatureInfo(); + CreatureTemplate const* ci = GetCreatureTemplate(); if (!ci) return false; // Check pet talent type @@ -1771,9 +1771,9 @@ bool Pet::IsPermanentPetFor(Player* owner) switch (owner->getClass()) { case CLASS_WARLOCK: - return GetCreatureInfo()->type == CREATURE_TYPE_DEMON; + return GetCreatureTemplate()->type == CREATURE_TYPE_DEMON; case CLASS_DEATH_KNIGHT: - return GetCreatureInfo()->type == CREATURE_TYPE_UNDEAD; + return GetCreatureTemplate()->type == CREATURE_TYPE_UNDEAD; default: return false; } @@ -1812,7 +1812,7 @@ bool Pet::HasSpell(uint32 spell) const // Get all passive spells in our skill line void Pet::LearnPetPassives() { - CreatureTemplate const* cInfo = GetCreatureInfo(); + CreatureTemplate const* cInfo = GetCreatureTemplate(); if (!cInfo) return; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index f5b7d487219..870b6f683b8 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -144,7 +144,6 @@ static uint32 copseReclaimDelay[MAX_DEATH_COUNT] = { 30, 60, 120 }; PlayerTaxi::PlayerTaxi() { - // Taxi nodes memset(m_taximask, 0, sizeof(m_taximask)); } @@ -540,7 +539,7 @@ inline void KillRewarder::_RewardKillCredit(Player* player) // 4.4. Give kill credit (player must not be in group, or he must be alive or without corpse). if (!_group || player->isAlive() || !player->GetCorpse()) if (_victim->GetTypeId() == TYPEID_UNIT) - player->KilledMonster(_victim->ToCreature()->GetCreatureInfo(), _victim->GetGUID()); + player->KilledMonster(_victim->ToCreature()->GetCreatureTemplate(), _victim->GetGUID()); } void KillRewarder::_RewardPlayer(Player* player, bool isDungeon) @@ -1123,10 +1122,10 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo) if (oEntry->ItemId[j] <= 0) continue; - uint32 item_id = oEntry->ItemId[j]; + uint32 itemId = oEntry->ItemId[j]; // just skip, reported in ObjectMgr::LoadItemTemplates - ItemTemplate const* iProto = sObjectMgr->GetItemTemplate(item_id); + ItemTemplate const* iProto = sObjectMgr->GetItemTemplate(itemId); if (!iProto) continue; @@ -1148,7 +1147,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo) if (iProto->GetMaxStackSize() < count) count = iProto->GetMaxStackSize(); } - StoreNewItemInBestSlots(item_id, count); + StoreNewItemInBestSlots(itemId, count); } } @@ -1589,14 +1588,14 @@ void Player::Update(uint32 p_time) if (HasUnitState(UNIT_STATE_MELEE_ATTACKING) && !HasUnitState(UNIT_STATE_CASTING)) { - if (Unit* pVictim = getVictim()) + if (Unit* victim = getVictim()) { // default combat reach 10 // TODO add weapon, skill check if (isAttackReady(BASE_ATTACK)) { - if (!IsWithinMeleeRange(pVictim)) + if (!IsWithinMeleeRange(victim)) { setAttackTimer(BASE_ATTACK, 100); if (m_swingErrorMsg != 1) // send single time (client auto repeat) @@ -1606,7 +1605,7 @@ void Player::Update(uint32 p_time) } } //120 degrees of radiant range - else if (!HasInArc(2*M_PI/3, pVictim)) + else if (!HasInArc(2*M_PI/3, victim)) { setAttackTimer(BASE_ATTACK, 100); if (m_swingErrorMsg != 2) // send single time (client auto repeat) @@ -1625,16 +1624,16 @@ void Player::Update(uint32 p_time) setAttackTimer(OFF_ATTACK, ATTACK_DISPLAY_DELAY); // do attack - AttackerStateUpdate(pVictim, BASE_ATTACK); + AttackerStateUpdate(victim, BASE_ATTACK); resetAttackTimer(BASE_ATTACK); } } if (haveOffhandWeapon() && isAttackReady(OFF_ATTACK)) { - if (!IsWithinMeleeRange(pVictim)) + if (!IsWithinMeleeRange(victim)) setAttackTimer(OFF_ATTACK, 100); - else if (!HasInArc(2*M_PI/3, pVictim)) + else if (!HasInArc(2*M_PI/3, victim)) setAttackTimer(OFF_ATTACK, 100); else { @@ -1643,13 +1642,13 @@ void Player::Update(uint32 p_time) setAttackTimer(BASE_ATTACK, ATTACK_DISPLAY_DELAY); // do attack - AttackerStateUpdate(pVictim, OFF_ATTACK); + AttackerStateUpdate(victim, OFF_ATTACK); resetAttackTimer(OFF_ATTACK); } } - /*Unit* owner = pVictim->GetOwner(); - Unit* u = owner ? owner : pVictim; + /*Unit* owner = victim->GetOwner(); + Unit* u = owner ? owner : victim; if (u->IsPvP() && (!duel || duel->opponent != u)) { UpdatePvP(true); @@ -2687,11 +2686,11 @@ Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask) return NULL; // Deathstate checks - if (!isAlive() && !(creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_GHOST)) + if (!isAlive() && !(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_GHOST)) return NULL; // alive or spirit healer - if (!creature->isAlive() && !(creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_DEAD_INTERACT)) + if (!creature->isAlive() && !(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_DEAD_INTERACT)) return NULL; // appropriate npc type @@ -4458,7 +4457,7 @@ bool Player::resetTalents(bool no_cost) /* when prev line will dropped use next line if (Pet* pet = GetPet()) { - if (pet->getPetType() == HUNTER_PET && !pet->GetCreatureInfo()->isTameable(CanTameExoticPets())) + if (pet->getPetType() == HUNTER_PET && !pet->GetCreatureTemplate()->isTameable(CanTameExoticPets())) RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); } */ @@ -4625,9 +4624,9 @@ void Player::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c Unit::BuildCreateUpdateBlockForPlayer(data, target); } -void Player::DestroyForPlayer(Player* target, bool anim) const +void Player::DestroyForPlayer(Player* target, bool onDeath) const { - Unit::DestroyForPlayer(target, anim); + Unit::DestroyForPlayer(target, onDeath); for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i) { @@ -6222,7 +6221,7 @@ void Player::UpdateWeaponSkill(WeaponAttackType attType) if (GetShapeshiftForm() == FORM_TREE) return; // use weapon but not skill up - if (victim && victim->GetTypeId() == TYPEID_UNIT && (victim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_SKILLGAIN)) + if (victim && victim->GetTypeId() == TYPEID_UNIT && (victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_SKILLGAIN)) return; uint32 weapon_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_WEAPON); @@ -6922,7 +6921,7 @@ void Player::RewardReputation(Unit* pVictim, float rate) if (pVictim->ToCreature()->IsReputationGainDisabled()) return; - ReputationOnKillEntry const* Rep = sObjectMgr->GetReputationOnKilEntry(pVictim->ToCreature()->GetCreatureInfo()->Entry); + ReputationOnKillEntry const* Rep = sObjectMgr->GetReputationOnKilEntry(pVictim->ToCreature()->GetCreatureTemplate()->Entry); if (!Rep) return; @@ -7422,6 +7421,8 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) } } + sScriptMgr->OnPlayerUpdateZone(this, newZone, newArea); + // in PvP, any not controlled zone (except zone->team == 6, default case) // in PvE, only opposition team capital switch (zone->team) @@ -8845,7 +8846,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) creature->lootForPickPocketed = true; loot->clear(); - if (uint32 lootid = creature->GetCreatureInfo()->pickpocketLootId) + if (uint32 lootid = creature->GetCreatureTemplate()->pickpocketLootId) loot->FillLoot(lootid, LootTemplates_Pickpocketing, this, true); // Generate extra money for pick pocket loot @@ -8892,7 +8893,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) if (loot_type == LOOT_SKINNING) { loot->clear(); - loot->FillLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, this, true); + loot->FillLoot(creature->GetCreatureTemplate()->SkinLootId, LootTemplates_Skinning, this, true); permission = OWNER_PERMISSION; } // set group rights only for loot_type != LOOT_SKINNING @@ -12007,7 +12008,7 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update { pItem->SetSoulboundTradeable(allowedLooters); pItem->SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, GetTotalPlayedTime()); - m_itemSoulboundTradeable.push_back(pItem); + AddTradeableItem(pItem); // save data std::ostringstream ss; @@ -12450,7 +12451,7 @@ void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool } if (pLastItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE)) - m_itemSoulboundTradeable.push_back(pLastItem); + AddTradeableItem(pLastItem); } void Player::DestroyItem(uint8 bag, uint8 slot, bool update) @@ -13449,6 +13450,11 @@ void Player::UpdateSoulboundTradeItems() } } +void Player::AddTradeableItem(Item* item) +{ + m_itemSoulboundTradeable.push_back(item); +} + //TODO: should never allow an item to be added to m_itemSoulboundTradeable twice void Player::RemoveTradeableItem(Item* item) { @@ -14133,7 +14139,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool canTalk = false; break; case GOSSIP_OPTION_UNLEARNPETTALENTS: - if (!GetPet() || GetPet()->getPetType() != HUNTER_PET || GetPet()->m_spells.size() <= 1 || creature->GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS || creature->GetCreatureInfo()->trainer_class != CLASS_HUNTER) + if (!GetPet() || GetPet()->getPetType() != HUNTER_PET || GetPet()->m_spells.size() <= 1 || creature->GetCreatureTemplate()->trainer_type != TRAINER_TYPE_PETS || creature->GetCreatureTemplate()->trainer_class != CLASS_HUNTER) canTalk = false; break; case GOSSIP_OPTION_TAXIVENDOR: @@ -14406,7 +14412,7 @@ uint32 Player::GetDefaultGossipMenuForSource(WorldObject* source) switch (source->GetTypeId()) { case TYPEID_UNIT: - return source->ToCreature()->GetCreatureInfo()->GossipMenuId; + return source->ToCreature()->GetCreatureTemplate()->GossipMenuId; case TYPEID_GAMEOBJECT: return source->ToGameObject()->GetGOInfo()->GetGossipMenuId(); default: @@ -17578,7 +17584,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F for (Tokens::iterator itr = GUIDlist.begin(); itr != GUIDlist.end(); ++itr) looters.insert(atol(*itr)); item->SetSoulboundTradeable(looters); - m_itemSoulboundTradeable.push_back(item); + AddTradeableItem(item); } else { @@ -17777,12 +17783,19 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) QuestStatusData& questStatusData = m_QuestStatus[quest_id]; uint8 qstatus = fields[1].GetUInt8(); - if (qstatus < MAX_QUEST_STATUS) + if (qstatus < MAX_QUEST_STATUS && qstatus > QUEST_STATUS_NONE) questStatusData.Status = QuestStatus(qstatus); + else if (qstatus == QUEST_STATUS_NONE) + { + sLog->outError("Player %s (GUID: %u) has QUEST_STATUS_NONE for quest %u and should be removed from character_queststatus.", + GetName(), GetGUIDLow(), quest_id); + continue; + } else { questStatusData.Status = QUEST_STATUS_INCOMPLETE; - sLog->outError("Player %s have invalid quest %d status (%u), replaced by QUEST_STATUS_INCOMPLETE(3).", GetName(), quest_id, qstatus); + sLog->outError("Player %s (GUID: %u) has invalid quest %d status (%u), replaced by QUEST_STATUS_INCOMPLETE(3).", + GetName(), GetGUIDLow(), quest_id, qstatus); } questStatusData.Explored = (fields[2].GetUInt8() > 0); @@ -19759,7 +19772,7 @@ void Player::PetSpellInitialize() WorldPacket data(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+1); data << uint64(pet->GetGUID()); - data << uint16(pet->GetCreatureInfo()->family); // creature family (required for pet talents) + data << uint16(pet->GetCreatureTemplate()->family); // creature family (required for pet talents) data << uint32(0); data << uint8(pet->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0); @@ -19853,7 +19866,7 @@ void Player::VehicleSpellInitialize() WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * 10 + 1 + 1 + cooldownCount * (4 + 2 + 4 + 4)); data << uint64(veh->GetGUID()); - data << uint16(veh->GetCreatureInfo()->family); + data << uint16(veh->GetCreatureTemplate()->family); data << uint32(0); // The following three segments are read as one uint32 data << uint8(veh->GetReactState()); @@ -19939,7 +19952,7 @@ void Player::CharmSpellInitialize() uint8 addlist = 0; if (charm->GetTypeId() != TYPEID_PLAYER) { - //CreatureInfo const* cinfo = charm->ToCreature()->GetCreatureInfo(); + //CreatureInfo const* cinfo = charm->ToCreature()->GetCreatureTemplate(); //if (cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK) { for (uint32 i = 0; i < MAX_SPELL_CHARM; ++i) @@ -22641,7 +22654,7 @@ bool Player::isHonorOrXPTarget(Unit* pVictim) { if (pVictim->ToCreature()->isTotem() || pVictim->ToCreature()->isPet() || - pVictim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) + pVictim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) return false; } return true; @@ -24001,7 +24014,7 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank) if (!talentTabInfo) return; - CreatureTemplate const* ci = pet->GetCreatureInfo(); + CreatureTemplate const* ci = pet->GetCreatureTemplate(); if (!ci) return; @@ -24262,7 +24275,7 @@ void Player::BuildPetTalentsInfoData(WorldPacket* data) data->put<uint32>(pointsPos, unspentTalentPoints); // put real points - CreatureTemplate const* ci = pet->GetCreatureInfo(); + CreatureTemplate const* ci = pet->GetCreatureTemplate(); if (!ci) return; diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 82bbd1b38d5..3d510148aa4 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -687,9 +687,9 @@ enum TransferAbortReason TRANSFER_ABORT_UNIQUE_MESSAGE = 0x09, // Until you've escaped TLK's grasp, you cannot leave this place! TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 0x0A, // Additional instances cannot be launched, please try again later. TRANSFER_ABORT_NEED_GROUP = 0x0B, // 3.1 - TRANSFER_ABORT_NOT_FOUND2 = 0x0C, // 3.1 - TRANSFER_ABORT_NOT_FOUND3 = 0x0D, // 3.1 - TRANSFER_ABORT_NOT_FOUND4 = 0x0E, // 3.2 + TRANSFER_ABORT_NOT_FOUND1 = 0x0C, // 3.1 + TRANSFER_ABORT_NOT_FOUND2 = 0x0D, // 3.1 + TRANSFER_ABORT_NOT_FOUND3 = 0x0E, // 3.2 TRANSFER_ABORT_REALM_ONLY = 0x0F, // All players on party must be from the same realm. TRANSFER_ABORT_MAP_NOT_ALLOWED = 0x10, // Map can't be entered at this time. }; @@ -1337,6 +1337,7 @@ class Player : public Unit, public GridObject<Player> void UpdateEnchantTime(uint32 time); void UpdateSoulboundTradeItems(); + void AddTradeableItem(Item* item); void RemoveTradeableItem(Item* item); void UpdateItemDuration(uint32 time, bool realtimeonly = false); void AddEnchantmentDurations(Item* item); @@ -1914,7 +1915,7 @@ class Player : public Unit, public GridObject<Player> WorldSession* GetSession() const { return m_session; } void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const; - void DestroyForPlayer(Player* target, bool anim = false) const; + void DestroyForPlayer(Player* target, bool onDeath = false) const; void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend = false, float group_rate=1.0f); // notifiers @@ -1982,7 +1983,7 @@ class Player : public Unit, public GridObject<Player> void UpdateDefense(); void UpdateWeaponSkill (WeaponAttackType attType); - void UpdateCombatSkills(Unit* pVictim, WeaponAttackType attType, bool defence); + void UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defence); void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal); uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus @@ -2015,9 +2016,9 @@ class Player : public Unit, public GridObject<Player> bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const; bool IsAtRecruitAFriendDistance(WorldObject const* pOther) const; - void RewardPlayerAndGroupAtKill(Unit* pVictim, bool isBattleGround); + void RewardPlayerAndGroupAtKill(Unit* victim, bool isBattleGround); void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource); - bool isHonorOrXPTarget(Unit* pVictim); + bool isHonorOrXPTarget(Unit* victim); bool GetsRecruitAFriendBonus(bool forXP); uint8 GetGrantableLevels() { return m_grantableLevels; } @@ -2026,7 +2027,7 @@ class Player : public Unit, public GridObject<Player> ReputationMgr& GetReputationMgr() { return m_reputationMgr; } ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; } ReputationRank GetReputationRank(uint32 faction_id) const; - void RewardReputation(Unit* pVictim, float rate); + void RewardReputation(Unit* victim, float rate); void RewardReputation(Quest const* quest); void UpdateSkillsForLevel(); @@ -2037,7 +2038,7 @@ class Player : public Unit, public GridObject<Player> /*** PVP SYSTEM ***/ /*********************************************************/ void UpdateHonorFields(); - bool RewardHonor(Unit* pVictim, uint32 groupsize, int32 honor = -1, bool pvptoken = false); + bool RewardHonor(Unit* victim, uint32 groupsize, int32 honor = -1, bool pvptoken = false); uint32 GetHonorPoints() const { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); } uint32 GetArenaPoints() const { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); } void ModifyHonorPoints(int32 value, SQLTransaction* trans = NULL); //! If trans is specified, honor save query will be added to trans @@ -2331,7 +2332,7 @@ class Player : public Unit, public GridObject<Player> void UpdateTriggerVisibility(); template<class T> - void UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& visibleNow); + void UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& visibleNow); uint8 m_forced_speed_changes[MAX_MOVE_TYPE]; @@ -2414,6 +2415,7 @@ class Player : public Unit, public GridObject<Player> void SetAuraUpdateMaskForRaid(uint8 slot) { m_auraRaidUpdateMask |= (uint64(1) << slot); } Player* GetNextRandomRaidMember(float radius); PartyResult CanUninviteFromGroup() const; + // Battleground Group System void SetBattlegroundRaid(Group* group, int8 subgroup = -1); void RemoveFromBattlegroundRaid(); diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index a425640e36d..24fe75605d2 100755 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -173,7 +173,7 @@ void MapManager::LoadTransportNPCs() Transport::Transport(uint32 period, uint32 script) : GameObject(), m_pathTime(0), m_timer(0), currenttguid(0), m_period(period), ScriptId(script), m_nextNodeTime(0) { - m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_ROTATION); + m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_LOWGUID | UPDATEFLAG_STATIONARY_POSITION | UPDATEFLAG_ROTATION); } Transport::~Transport() diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index c0bd5cb95a6..283ab2c9cf6 100755 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -1019,12 +1019,12 @@ void Creature::UpdateDamagePhysical(WeaponAttackType attType) float weapon_maxdamage = GetWeaponDamageRange(attType, MAXDAMAGE); /* difference in AP between current attack power and base value from DB */ - float att_pwr_change = GetTotalAttackPowerValue(attType) - GetCreatureInfo()->attackpower; + float att_pwr_change = GetTotalAttackPowerValue(attType) - GetCreatureTemplate()->attackpower; float base_value = GetModifierValue(unitMod, BASE_VALUE) + (att_pwr_change * GetAPMultiplier(attType, false) / 14.0f); float base_pct = GetModifierValue(unitMod, BASE_PCT); float total_value = GetModifierValue(unitMod, TOTAL_VALUE); float total_pct = GetModifierValue(unitMod, TOTAL_PCT); - float dmg_multiplier = GetCreatureInfo()->dmg_multiplier; + float dmg_multiplier = GetCreatureTemplate()->dmg_multiplier; if (!CanUseAttackType(attType)) { diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index f006b4c07c0..dbbb8acf759 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -158,7 +158,7 @@ m_HostileRefManager(this) m_objectType |= TYPEMASK_UNIT; m_objectTypeId = TYPEID_UNIT; - m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION); + m_updateFlag = (UPDATEFLAG_LIVING | UPDATEFLAG_STATIONARY_POSITION); m_attackTimer[BASE_ATTACK] = 0; m_attackTimer[OFF_ATTACK] = 0; @@ -430,7 +430,7 @@ void Unit::SendMonsterMoveTransport(Unit* vehicleOwner) data.append(GetPackGUID()); data.append(vehicleOwner->GetPackGUID()); data << int8(GetTransSeat()); - data << uint8(GetTypeId() == TYPEID_PLAYER ? 1 : 0); // boolean + data << uint8(0); data << GetPositionX() - vehicleOwner->GetPositionX(); data << GetPositionY() - vehicleOwner->GetPositionY(); data << GetPositionZ() - vehicleOwner->GetPositionZ(); @@ -784,20 +784,9 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam // last damage from duel opponent if (duel_hasEnded) { - Player* he; + Player* he = duel_wasMounted ? victim->GetCharmer()->ToPlayer() : victim->ToPlayer(); - if (duel_wasMounted) - { - ASSERT(victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER); - he = victim->GetCharmer()->ToPlayer(); - } - else - { - ASSERT(victim->GetTypeId() == TYPEID_PLAYER); - he = victim->ToPlayer(); - } - - ASSERT(he->duel); + ASSERT(he && he->duel); if (duel_wasMounted) // In this case victim==mount victim->SetHealth(1); @@ -2014,7 +2003,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackT else parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25; - if (victim->GetTypeId() == TYPEID_PLAYER || !(victim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY)) + if (victim->GetTypeId() == TYPEID_PLAYER || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY)) { int32 tmp2 = int32(parry_chance); if (tmp2 > 0 // check if unit _can_ parry @@ -2026,7 +2015,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackT } } - if (victim->GetTypeId() == TYPEID_PLAYER || !(victim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)) + if (victim->GetTypeId() == TYPEID_PLAYER || !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)) { tmp = block_chance; if (tmp > 0 // check if unit _can_ block @@ -2045,7 +2034,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackT if (tmp > 0 && roll < (sum += tmp)) { sLog->outStaticDebug ("RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum); - if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) + if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) sLog->outStaticDebug ("RollMeleeOutcomeAgainst: CRIT DISABLED)"); else return MELEE_HIT_CRIT; @@ -2075,7 +2064,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit* victim, WeaponAttackT if (getLevelForTarget(victim) >= victim->getLevelForTarget(this) + 4 && // can be from by creature (if can) or from controlled player that considered as creature !IsControlledByPlayer() && - !(GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH)) + !(GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH)) { // when their weapon skill is 15 or more above victim's defense skill tmp = victimDefenseSkill; @@ -2189,7 +2178,7 @@ bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttac { // Check creatures flags_extra for disable block if (victim->GetTypeId() == TYPEID_UNIT && - victim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) + victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) return false; float blockChance = victim->GetUnitBlockChance(); @@ -2327,7 +2316,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spell) // Check creatures flags_extra for disable parry if (victim->GetTypeId() == TYPEID_UNIT) { - uint32 flagEx = victim->ToCreature()->GetCreatureInfo()->flags_extra; + uint32 flagEx = victim->ToCreature()->GetCreatureTemplate()->flags_extra; if (flagEx & CREATURE_FLAG_EXTRA_NO_PARRY) canParry = false; // Check creatures flags_extra for disable block @@ -9178,7 +9167,7 @@ FactionTemplateEntry const* Unit::getFactionTemplateEntry() const if (Player const* player = ToPlayer()) sLog->outError("Player %s has invalid faction (faction template id) #%u", player->GetName(), getFaction()); else if (Creature const* creature = ToCreature()) - sLog->outError("Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureInfo()->Entry, getFaction()); + sLog->outError("Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, getFaction()); else sLog->outError("Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName(), uint32(GetTypeId()), getFaction()); @@ -10235,7 +10224,7 @@ uint32 Unit::SpellDamageBonus(Unit* victim, SpellInfo const* spellProto, uint32 // ..done // Pet damage? if (GetTypeId() == TYPEID_UNIT && !ToCreature()->isPet()) - DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureInfo()->rank); + DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank); AuraEffectList const& mModDamagePercentDone = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) @@ -12032,7 +12021,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy) UpdateSpeed(MOVE_FLIGHT, true); } - if (!(creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT)) + if (!(creature->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT)) Dismount(); } @@ -12051,12 +12040,12 @@ void Unit::ClearInCombat() // Player's state will be cleared in Player::UpdateContestedPvP if (Creature* creature = ToCreature()) { - if (creature->GetCreatureInfo() && creature->GetCreatureInfo()->unit_flags & UNIT_FLAG_IMMUNE_TO_PC) + if (creature->GetCreatureTemplate() && creature->GetCreatureTemplate()->unit_flags & UNIT_FLAG_IMMUNE_TO_PC) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); // set immunity state to the one from db on evade ClearUnitState(UNIT_STATE_ATTACK_PLAYER); if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED)) - SetUInt32Value(UNIT_DYNAMIC_FLAGS, creature->GetCreatureInfo()->dynamicflags); + SetUInt32Value(UNIT_DYNAMIC_FLAGS, creature->GetCreatureTemplate()->dynamicflags); if (creature->isPet()) { @@ -12171,7 +12160,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell) co } Creature const* creatureAttacker = ToCreature(); - if (creatureAttacker && creatureAttacker->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK26) + if (creatureAttacker && creatureAttacker->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_UNK26) return false; Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) ? GetAffectingPlayer() : NULL; @@ -12258,7 +12247,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co // can't assist non-friendly targets if (GetReactionTo(target) <= REP_NEUTRAL && target->GetReactionTo(this) <= REP_NEUTRAL - && (!ToCreature() || !(ToCreature()->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK26))) + && (!ToCreature() || !(ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_UNK26))) return false; // PvP case @@ -12292,7 +12281,7 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co && !((target->GetByteValue(UNIT_FIELD_BYTES_2, 1) & UNIT_BYTE2_FLAG_PVP))) { if (Creature const* creatureTarget = target->ToCreature()) - return creatureTarget->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_UNK26 || creatureTarget->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS; + return creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_UNK26 || creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPEFLAGS_AID_PLAYERS; } return true; } @@ -12514,7 +12503,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) { // Set creature speed rate from CreatureInfo if (GetTypeId() == TYPEID_UNIT) - speed *= ToCreature()->GetCreatureInfo()->speed_walk; + speed *= ToCreature()->GetCreatureTemplate()->speed_walk; // Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need // TODO: possible affect only on MOVE_RUN @@ -13200,7 +13189,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, Unit const* source = casterOwner ? casterOwner : caster; if ((target->GetTypeId() == TYPEID_PLAYER - || ((Creature*)target)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH) + || ((Creature*)target)->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH) && source->GetTypeId() == TYPEID_PLAYER) duration = limitduration; } @@ -13209,7 +13198,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, if (group == DIMINISHING_TAUNT) { - if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TAUNT_DIMINISH)) + if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TAUNT_DIMINISH)) { DiminishingLevels diminish = Level; switch (diminish) @@ -13226,7 +13215,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, // Some diminishings applies to mobs too (for example, Stun) else if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && ((targetOwner ? (targetOwner->GetTypeId() == TYPEID_PLAYER) : (GetTypeId() == TYPEID_PLAYER)) - || (GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))) + || (GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL) { DiminishingLevels diminish = Level; @@ -13310,7 +13299,7 @@ uint32 Unit::GetCreatureType() const return CREATURE_TYPE_HUMANOID; } else - return ToCreature()->GetCreatureInfo()->type; + return ToCreature()->GetCreatureTemplate()->type; } /*####################################### @@ -15393,10 +15382,10 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) creature->lootForPickPocketed = false; loot->clear(); - if (uint32 lootid = creature->GetCreatureInfo()->lootid) + if (uint32 lootid = creature->GetCreatureTemplate()->lootid) loot->FillLoot(lootid, LootTemplates_Creature, looter, false, false, creature->GetLootMode()); - loot->generateMoneyLoot(creature->GetCreatureInfo()->mingold, creature->GetCreatureInfo()->maxgold); + loot->generateMoneyLoot(creature->GetCreatureTemplate()->mingold, creature->GetCreatureTemplate()->maxgold); } player->RewardPlayerAndGroupAtKill(victim, false); @@ -15497,7 +15486,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) if (!creature->isPet()) { creature->DeleteThreatList(); - CreatureTemplate const* cInfo = creature->GetCreatureInfo(); + CreatureTemplate const* cInfo = creature->GetCreatureTemplate(); if (cInfo && (cInfo->lootid || cInfo->maxgold > 0)) creature->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); } @@ -15526,7 +15515,7 @@ void Unit::Kill(Unit* victim, bool durabilityLoss) { if (instanceMap->IsRaidOrHeroicDungeon()) { - if (creature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) + if (creature->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) ((InstanceMap*)instanceMap)->PermBindAllPlayers(creditedPlayer); } else @@ -15935,7 +15924,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au case CHARM_TYPE_CHARM: if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) { - CreatureTemplate const* cinfo = ToCreature()->GetCreatureInfo(); + CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate(); if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) { // to prevent client crash @@ -16039,7 +16028,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) case CHARM_TYPE_CHARM: if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) { - CreatureTemplate const* cinfo = ToCreature()->GetCreatureInfo(); + CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate(); if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) { SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class)); @@ -16078,7 +16067,7 @@ void Unit::RestoreFaction() } } - if (CreatureTemplate const* cinfo = ToCreature()->GetCreatureInfo()) // normal creature + if (CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate()) // normal creature { FactionTemplateEntry const* faction = getFactionTemplateEntry(); setFaction((faction && faction->friendlyMask & 0x004) ? cinfo->faction_H : cinfo->faction_A); @@ -17171,14 +17160,18 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel GetMap()->CreatureRelocation(ToCreature(), x, y, z, orientation); } else if (turn) - SetOrientation(orientation); - - if ((relocated || turn) && IsVehicle()) - GetVehicleKit()->RelocatePassengers(x, y, z, orientation); + UpdateOrientation(orientation); return (relocated || turn); } +void Unit::UpdateOrientation(float orientation) +{ + SetOrientation(orientation); + if (IsVehicle()) + GetVehicleKit()->RelocatePassengers(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); +} + void Unit::SendThreatListUpdate() { if (!getThreatManager().isThreatListEmpty()) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 0fe5f3d8ca3..b07f2ae1c16 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1614,6 +1614,7 @@ class Unit : public WorldObject virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false); // returns true if unit's position really changed bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } + void UpdateOrientation(float orientation); void KnockbackFrom(float x, float y, float speedXY, float speedZ); void JumpTo(float speedXY, float speedZ, bool forward = true); diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 348ce132da8..2f552eddb9f 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -146,7 +146,7 @@ void Vehicle::ApplyAllImmunities() _me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK_DEST, true); // Mechanical units & vehicles ( which are not Bosses, they have own immunities in DB ) should be also immune on healing ( exceptions in switch below ) - if (_me->ToCreature() && _me->ToCreature()->GetCreatureInfo()->type == CREATURE_TYPE_MECHANICAL && !_me->ToCreature()->isWorldBoss()) + if (_me->ToCreature() && _me->ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && !_me->ToCreature()->isWorldBoss()) { // Heal & dispel ... _me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_HEAL, true); @@ -431,6 +431,7 @@ void Vehicle::RemovePassenger(Unit* unit) sScriptMgr->OnRemovePassenger(this, unit); } +//! Must be called after m_base::Relocate void Vehicle::RelocatePassengers(float x, float y, float z, float ang) { ASSERT(_me->GetMap()); @@ -440,8 +441,6 @@ void Vehicle::RelocatePassengers(float x, float y, float z, float ang) if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger)) { ASSERT(passenger->IsInWorld()); - ASSERT(passenger->IsOnVehicle(GetBase())); - ASSERT(GetSeatForPassenger(passenger)); float px = x + passenger->m_movementInfo.t_pos.m_positionX; float py = y + passenger->m_movementInfo.t_pos.m_positionY; diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 6f5dc0e511e..808da1ac791 100755 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -1174,7 +1174,7 @@ void GameEventMgr::UpdateEventNPCFlags(uint16 event_id) if (cr) { uint32 npcflag = GetNPCFlag(cr); - if (const CreatureTemplate* ci = cr->GetCreatureInfo()) + if (const CreatureTemplate* ci = cr->GetCreatureTemplate()) npcflag |= ci->npcflag; cr->SetUInt32Value(UNIT_NPC_FLAGS, npcflag); // reset gossip options, since the flag change might have added / removed some diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index 1a069a27825..dd5e6189b44 100755 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -400,4 +400,4 @@ template Pet* ObjectAccessor::GetObjectInWorld<Pet>(uint32 mapid, float x, float template Creature* ObjectAccessor::GetObjectInWorld<Creature>(uint32 mapid, float x, float y, uint64 guid, Creature* /*fake*/); template Corpse* ObjectAccessor::GetObjectInWorld<Corpse>(uint32 mapid, float x, float y, uint64 guid, Corpse* /*fake*/); template GameObject* ObjectAccessor::GetObjectInWorld<GameObject>(uint32 mapid, float x, float y, uint64 guid, GameObject* /*fake*/); -template DynamicObject* ObjectAccessor::GetObjectInWorld<DynamicObject>(uint32 mapid, float x, float y, uint64 guid, DynamicObject* /*fake*/);
\ No newline at end of file +template DynamicObject* ObjectAccessor::GetObjectInWorld<DynamicObject>(uint32 mapid, float x, float y, uint64 guid, DynamicObject* /*fake*/); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index f31ce74d896..11977280177 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -701,7 +701,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) else if (!displayScaleEntry) displayScaleEntry = displayEntry; - CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid2);; + CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid2); if (!modelInfo) sLog->outErrorDb("No model data exist for `Modelid2` = %u listed by creature (Entry: %u).", cInfo->Modelid2, cInfo->Entry); } @@ -733,7 +733,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo) else if (!displayScaleEntry) displayScaleEntry = displayEntry; - CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid4);; + CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid4); if (!modelInfo) sLog->outErrorDb("No model data exist for `Modelid4` = %u listed by creature (Entry: %u).", cInfo->Modelid4, cInfo->Entry); } @@ -992,7 +992,7 @@ void ObjectMgr::LoadEquipmentTemplates() if (!equipmentInfo.ItemEntry[i]) continue; - ItemEntry const* dbcItem = sItemStore.LookupEntry(equipmentInfo.ItemEntry[i]); + ItemEntry const* dbcItem = sItemStore.LookupEntry(equipmentInfo.ItemEntry[i]); if (!dbcItem) { @@ -1071,25 +1071,25 @@ void ObjectMgr::ChooseCreatureFlags(const CreatureTemplate* cinfo, uint32& npcfl CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32* displayID) { - CreatureModelInfo const* minfo = GetCreatureModelInfo(*displayID); - if (!minfo) + CreatureModelInfo const* modelInfo = GetCreatureModelInfo(*displayID); + if (!modelInfo) return NULL; // If a model for another gender exists, 50% chance to use it - if (minfo->modelid_other_gender != 0 && urand(0, 1) == 0) + if (modelInfo->modelid_other_gender != 0 && urand(0, 1) == 0) { - CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(minfo->modelid_other_gender); + CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(modelInfo->modelid_other_gender); if (!minfo_tmp) - sLog->outErrorDb("Model (Entry: %u) has modelid_other_gender %u not found in table `creature_model_info`. ", *displayID, minfo->modelid_other_gender); + sLog->outErrorDb("Model (Entry: %u) has modelid_other_gender %u not found in table `creature_model_info`. ", *displayID, modelInfo->modelid_other_gender); else { // Model ID changed - *displayID = minfo->modelid_other_gender; + *displayID = modelInfo->modelid_other_gender; return minfo_tmp; } } - return minfo; + return modelInfo; } void ObjectMgr::LoadCreatureModelInfo() @@ -1327,7 +1327,6 @@ void ObjectMgr::LoadLinkedRespawn() if (!error) _linkedRespawnStore[guid] = linkedGuid; - } while (result->NextRow()); @@ -1381,9 +1380,9 @@ void ObjectMgr::LoadCreatures() { uint32 oldMSTime = getMSTime(); - // 0 1 2 3 4 5 6 7 8 9 10 + // 0 1 2 3 4 5 6 7 8 9 10 QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, " - // 11 12 13 14 15 16 17 18 19 20 21 + // 11 12 13 14 15 16 17 18 19 20 21 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags " "FROM creature " "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid " @@ -1694,7 +1693,7 @@ void ObjectMgr::LoadGameobjects() // 0 1 2 3 4 5 6 QueryResult result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation, " - // 7 8 9 10 11 12 13 14 15 16 17 + // 7 8 9 10 11 12 13 14 15 16 17 "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, eventEntry, pool_entry " "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid " "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid"); @@ -1821,7 +1820,6 @@ void ObjectMgr::LoadGameobjects() if (gameEvent == 0 && PoolId == 0) // if not this is to be managed by GameEvent System or Pool system AddGameobjectToGrid(guid, &data); ++count; - } while (result->NextRow()); sLog->outString(">> Loaded %lu gameobjects in %u ms", (unsigned long)_gameObjectDataStore.size(), GetMSTimeDiffToNow(oldMSTime)); @@ -2628,7 +2626,7 @@ void ObjectMgr::LoadItemTemplates() uint32 item_id = entry->ItemId[j]; - if (!sObjectMgr->GetItemTemplate(item_id)) + if (!GetItemTemplate(item_id)) notFoundOutfit.insert(item_id); } } @@ -3131,7 +3129,7 @@ void ObjectMgr::LoadPlayerInfo() uint32 item_id = fields[2].GetUInt32(); - if (!sObjectMgr->GetItemTemplate(item_id)) + if (!GetItemTemplate(item_id)) { sLog->outErrorDb("Item id %u (race %u class %u) in `playercreateinfo_item` table but not listed in `item_template`, ignoring.", item_id, current_race, current_class); continue; @@ -3694,7 +3692,7 @@ void ObjectMgr::LoadQuests() { Field* fields = result->Fetch(); - Quest * newQuest = new Quest(fields); + Quest* newQuest = new Quest(fields); _questTemplates[newQuest->GetQuestId()] = newQuest; } while (result->NextRow()); @@ -3712,9 +3710,7 @@ void ObjectMgr::LoadQuests() // additional quest integrity checks (GO, creature_template and item_template must be loaded already) if (qinfo->GetQuestMethod() >= 3) - { sLog->outErrorDb("Quest %u has `Method` = %u, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestMethod()); - } if (qinfo->Flags & ~QUEST_TRINITY_FLAGS_DB_ALLOWED) { @@ -4401,7 +4397,6 @@ void ObjectMgr::LoadScripts(ScriptsType type) do { - Field* fields = result->Fetch(); ScriptInfo tmp; tmp.type = type; @@ -4810,8 +4805,8 @@ void ObjectMgr::LoadWaypointScripts() uint32 action = fields[0].GetUInt32(); actionSet.erase(action); - - } while (result->NextRow()); + } + while (result->NextRow()); } for (std::set<uint32>::iterator itr = actionSet.begin(); itr != actionSet.end(); ++itr) @@ -5164,7 +5159,6 @@ void ObjectMgr::LoadGossipText() int count = 0; if (!result) { - sLog->outString(">> Loaded %u npc texts", count); sLog->outString(); return; @@ -5299,7 +5293,6 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) uint32 returnedCount = 0; do { - Field* fields = result->Fetch(); Mail* m = new Mail; m->messageID = fields[0].GetUInt32(); @@ -5618,7 +5611,7 @@ uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt } // minfo is not actually used but the mount_id was updated - sObjectMgr->GetCreatureModelRandomGender(&mount_id); + GetCreatureModelRandomGender(&mount_id); return mount_id; } @@ -5766,10 +5759,10 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float if (MapId != entry->map_id) { // if find graveyard at different map from where entrance placed (or no entrance data), use any first - if (!mapEntry || - mapEntry->entrance_map < 0 || - uint32(mapEntry->entrance_map) != entry->map_id || - (mapEntry->entrance_x == 0 && mapEntry->entrance_y == 0)) + if (!mapEntry + || mapEntry->entrance_map < 0 + || uint32(mapEntry->entrance_map) != entry->map_id + || (mapEntry->entrance_x == 0 && mapEntry->entrance_y == 0)) { // not have any corrdinates for check distance anyway entryFar = entry; @@ -5914,8 +5907,6 @@ void ObjectMgr::RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool WorldDatabase.Execute(stmt); } - - return; } void ObjectMgr::LoadAreaTriggerTeleports() @@ -5985,7 +5976,7 @@ void ObjectMgr::LoadAccessRequirements() _accessRequirementStore.clear(); // need for reload case - // 0 1 2 3 4 5 6 7 8 9 + // 0 1 2 3 4 5 6 7 8 9 QueryResult result = WorldDatabase.Query("SELECT mapid, difficulty, level_min, level_max, item, item2, quest_done_A, quest_done_H, completed_achievement, quest_failed_text FROM access_requirement"); if (!result) { @@ -6019,7 +6010,7 @@ void ObjectMgr::LoadAccessRequirements() if (ar.item) { - ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(ar.item); + ItemTemplate const* pProto = GetItemTemplate(ar.item); if (!pProto) { sLog->outError("Key item %u does not exist for map %u difficulty %u, removing key requirement.", ar.item, mapid, difficulty); @@ -6029,7 +6020,7 @@ void ObjectMgr::LoadAccessRequirements() if (ar.item2) { - ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(ar.item2); + ItemTemplate const* pProto = GetItemTemplate(ar.item2); if (!pProto) { sLog->outError("Second item %u does not exist for map %u difficulty %u, removing key requirement.", ar.item2, mapid, difficulty); @@ -6136,10 +6127,10 @@ void ObjectMgr::SetHighestGuids() _hiItemGuid = (*result)[0].GetUInt32()+1; // Cleanup other tables from not existed guids ( >= _hiItemGuid) - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", _hiItemGuid); // One-time query - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", _hiItemGuid); // One-time query - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", _hiItemGuid); // One-time query - CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", _hiItemGuid); // One-time query + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", _hiItemGuid); + CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", _hiItemGuid); + CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", _hiItemGuid); + CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", _hiItemGuid); result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject"); if (result) @@ -6416,14 +6407,10 @@ void ObjectMgr::LoadGameObjectTemplate() got.size = fields[9].GetFloat(); for (uint8 i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; ++i) - { got.questItems[i] = fields[10 + i].GetUInt32(); - } for (uint8 i = 0; i < MAX_GAMEOBJECT_DATA; ++i) - { got.raw.data[i] = fields[16 + i].GetUInt32(); - } got.AIName = fields[40].GetString(); got.ScriptId = GetScriptId(fields[41].GetCString()); @@ -6432,28 +6419,28 @@ void ObjectMgr::LoadGameObjectTemplate() switch (got.type) { - case GAMEOBJECT_TYPE_DOOR: //0 + case GAMEOBJECT_TYPE_DOOR: //0 { if (got.door.lockId) CheckGOLockId(&got, got.door.lockId, 1); - CheckGONoDamageImmuneId(&got, got.door.noDamageImmune, 3); + CheckGONoDamageImmuneId(&got, got.door.noDamageImmune, 3); break; } - case GAMEOBJECT_TYPE_BUTTON: //1 + case GAMEOBJECT_TYPE_BUTTON: //1 { if (got.button.lockId) - CheckGOLockId(&got, got.button.lockId, 1); + CheckGOLockId(&got, got.button.lockId, 1); CheckGONoDamageImmuneId(&got, got.button.noDamageImmune, 4); break; } - case GAMEOBJECT_TYPE_QUESTGIVER: //2 + case GAMEOBJECT_TYPE_QUESTGIVER: //2 { if (got.questgiver.lockId) CheckGOLockId(&got, got.questgiver.lockId, 0); CheckGONoDamageImmuneId(&got, got.questgiver.noDamageImmune, 5); break; } - case GAMEOBJECT_TYPE_CHEST: //3 + case GAMEOBJECT_TYPE_CHEST: //3 { if (got.chest.lockId) CheckGOLockId(&got, got.chest.lockId, 0); @@ -6464,16 +6451,16 @@ void ObjectMgr::LoadGameObjectTemplate() CheckGOLinkedTrapId(&got, got.chest.linkedTrapId, 7); break; } - case GAMEOBJECT_TYPE_TRAP: //6 + case GAMEOBJECT_TYPE_TRAP: //6 { if (got.trap.lockId) CheckGOLockId(&got, got.trap.lockId, 0); break; } - case GAMEOBJECT_TYPE_CHAIR: //7 - CheckAndFixGOChairHeightId(&got, got.chair.height, 1); - break; - case GAMEOBJECT_TYPE_SPELL_FOCUS: //8 + case GAMEOBJECT_TYPE_CHAIR: //7 + CheckAndFixGOChairHeightId(&got, got.chair.height, 1); + break; + case GAMEOBJECT_TYPE_SPELL_FOCUS: //8 { if (got.spellFocus.focusId) { @@ -6486,7 +6473,7 @@ void ObjectMgr::LoadGameObjectTemplate() CheckGOLinkedTrapId(&got, got.spellFocus.linkedTrapId, 2); break; } - case GAMEOBJECT_TYPE_GOOBER: //10 + case GAMEOBJECT_TYPE_GOOBER: //10 { if (got.goober.lockId) CheckGOLockId(&got, got.goober.lockId, 0); @@ -6504,19 +6491,19 @@ void ObjectMgr::LoadGameObjectTemplate() CheckGOLinkedTrapId(&got, got.goober.linkedTrapId, 12); break; } - case GAMEOBJECT_TYPE_AREADAMAGE: //12 + case GAMEOBJECT_TYPE_AREADAMAGE: //12 { if (got.areadamage.lockId) CheckGOLockId(&got, got.areadamage.lockId, 0); break; } - case GAMEOBJECT_TYPE_CAMERA: //13 + case GAMEOBJECT_TYPE_CAMERA: //13 { if (got.camera.lockId) CheckGOLockId(&got, got.camera.lockId, 0); break; } - case GAMEOBJECT_TYPE_MO_TRANSPORT: //15 + case GAMEOBJECT_TYPE_MO_TRANSPORT: //15 { if (got.moTransport.taxiPathId) { @@ -6526,37 +6513,37 @@ void ObjectMgr::LoadGameObjectTemplate() } break; } - case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18 - break; - case GAMEOBJECT_TYPE_SPELLCASTER: //22 + case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18 + break; + case GAMEOBJECT_TYPE_SPELLCASTER: //22 { // always must have spell CheckGOSpellId(&got, got.spellcaster.spellId, 0); break; } - case GAMEOBJECT_TYPE_FLAGSTAND: //24 + case GAMEOBJECT_TYPE_FLAGSTAND: //24 { if (got.flagstand.lockId) CheckGOLockId(&got, got.flagstand.lockId, 0); CheckGONoDamageImmuneId(&got, got.flagstand.noDamageImmune, 5); break; } - case GAMEOBJECT_TYPE_FISHINGHOLE: //25 + case GAMEOBJECT_TYPE_FISHINGHOLE: //25 { if (got.fishinghole.lockId) CheckGOLockId(&got, got.fishinghole.lockId, 4); break; } - case GAMEOBJECT_TYPE_FLAGDROP: //26 + case GAMEOBJECT_TYPE_FLAGDROP: //26 { if (got.flagdrop.lockId) CheckGOLockId(&got, got.flagdrop.lockId, 0); CheckGONoDamageImmuneId(&got, got.flagdrop.noDamageImmune, 3); break; } - case GAMEOBJECT_TYPE_BARBER_CHAIR: //32 - CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0); - break; + case GAMEOBJECT_TYPE_BARBER_CHAIR: //32 + CheckAndFixGOChairHeightId(&got, got.barberChair.chairheight, 0); + break; } ++count; @@ -6584,7 +6571,6 @@ void ObjectMgr::LoadExplorationBaseXP() do { - Field* fields = result->Fetch(); uint8 level = fields[0].GetUInt8(); uint32 basexp = fields[1].GetUInt32(); @@ -6626,7 +6612,6 @@ void ObjectMgr::LoadPetNames() do { - Field* fields = result->Fetch(); std::string word = fields[0].GetString(); uint32 entry = fields[1].GetUInt32(); @@ -6739,7 +6724,6 @@ void ObjectMgr::LoadReputationRewardRate() do { - Field* fields = result->Fetch(); uint32 factionId = fields[0].GetUInt32(); @@ -6877,7 +6861,6 @@ void ObjectMgr::LoadReputationSpilloverTemplate() do { - Field* fields = result->Fetch(); uint32 factionId = fields[0].GetUInt32(); @@ -6997,12 +6980,12 @@ void ObjectMgr::LoadPointsOfInterest() uint32 point_id = fields[0].GetUInt32(); PointOfInterest POI; - POI.x = fields[1].GetFloat(); - POI.y = fields[2].GetFloat(); - POI.icon = fields[3].GetUInt32(); - POI.flags = fields[4].GetUInt32(); - POI.data = fields[5].GetUInt32(); - POI.icon_name = fields[6].GetString(); + POI.x = fields[1].GetFloat(); + POI.y = fields[2].GetFloat(); + POI.icon = fields[3].GetUInt32(); + POI.flags = fields[4].GetUInt32(); + POI.data = fields[5].GetUInt32(); + POI.icon_name = fields[6].GetString(); if (!Trinity::IsValidMapCoord(POI.x, POI.y)) { @@ -7051,7 +7034,6 @@ void ObjectMgr::LoadQuestPOI() do { - fields = points->Fetch(); uint32 questId = fields[0].GetUInt32(); @@ -7097,7 +7079,7 @@ void ObjectMgr::LoadNPCSpellClickSpells() uint32 oldMSTime = getMSTime(); _spellClickInfoStore.clear(); - // 0 1 2 3 + // 0 1 2 3 QueryResult result = WorldDatabase.Query("SELECT npc_entry, spell_id, cast_flags, user_type FROM npc_spellclick_spells"); if (!result) @@ -7176,7 +7158,7 @@ void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t _creatureRespawnTimesMutex.release(); } - PreparedStatement *stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CREATURE_RESPAWN); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CREATURE_RESPAWN); stmt->setUInt32(0, loguid); stmt->setUInt64(1, uint64(t)); stmt->setUInt32(2, instance); @@ -7330,7 +7312,6 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map, std::string table, do { - uint32 id = result->Fetch()[0].GetUInt32(); uint32 quest = result->Fetch()[1].GetUInt32(); uint32 poolId = result->Fetch()[2].GetUInt32(); @@ -7653,7 +7634,7 @@ void ObjectMgr::LoadGameObjectForQuests() sLog->outString(); } -bool ObjectMgr::LoadTrinityStrings(char const* table, int32 min_value, int32 max_value) +bool ObjectMgr::LoadTrinityStrings(const char* table, int32 min_value, int32 max_value) { uint32 oldMSTime = getMSTime(); @@ -7695,7 +7676,6 @@ bool ObjectMgr::LoadTrinityStrings(char const* table, int32 min_value, int32 max if (!result) { - if (min_value == MIN_TRINITY_STRING_ID) // error only in case internal strings sLog->outErrorDb(">> Loaded 0 trinity strings. DB table `%s` is empty. Cannot continue.", table); else @@ -7783,7 +7763,6 @@ void ObjectMgr::LoadFishingBaseSkillLevel() do { - Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); int32 skill = fields[1].GetInt32(); @@ -7813,7 +7792,7 @@ bool ObjectMgr::CheckDeclinedNames(std::wstring w_ownname, DeclinedName const& n bool y = true; // check declined names - for (uint8 i =0; i < MAX_DECLINED_NAME_CASES; ++i) + for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i) { std::wstring wname; if (!Utf8toWStr(names.name[i], wname)) @@ -7892,7 +7871,6 @@ void ObjectMgr::LoadGameTele() do { - Field* fields = result->Fetch(); uint32 id = fields[0].GetUInt32(); @@ -7935,7 +7913,7 @@ GameTele const* ObjectMgr::GetGameTele(const std::string& name) const // explicit name case std::wstring wname; if (!Utf8toWStr(name, wname)) - return false; + return NULL; // converting string that we try to find to lower case wstrToLower(wname); @@ -8033,7 +8011,6 @@ void ObjectMgr::LoadMailLevelRewards() do { - Field* fields = result->Fetch(); uint8 level = fields[0].GetUInt8(); @@ -8177,7 +8154,6 @@ void ObjectMgr::LoadTrainerSpell() do { - Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); @@ -8189,8 +8165,7 @@ void ObjectMgr::LoadTrainerSpell() AddSpellToTrainer(entry, spell, spellCost, reqSkill, reqSkillValue, reqLevel); - count++; - + ++count; } while (result->NextRow()); @@ -8229,7 +8204,6 @@ int ObjectMgr::LoadReferenceVendor(int32 vendor, int32 item, std::set<uint32> *s vList.AddItem(item_id, maxcount, incrtime, ExtendedCost); ++count; } - } while (result->NextRow()); return count; @@ -8280,7 +8254,6 @@ void ObjectMgr::LoadVendors() vList.AddItem(item_id, maxcount, incrtime, ExtendedCost); ++count; } - } while (result->NextRow()); @@ -8307,7 +8280,6 @@ void ObjectMgr::LoadGossipMenu() do { - Field* fields = result->Fetch(); GossipMenus gMenu; @@ -8626,7 +8598,7 @@ void ObjectMgr::LoadDbScriptStrings() sLog->outErrorDb("Table `db_script_string` has unused string id %u", *itr); } -bool LoadTrinityStrings(char const* table, int32 start_value, int32 end_value) +bool LoadTrinityStrings(const char* table, int32 start_value, int32 end_value) { // MAX_DB_SCRIPT_STRING_ID is max allowed negative value for scripts (scrpts can use only more deep negative values // start/end reversed for negative values diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 1172f04241d..0f2b2382007 100755 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -385,7 +385,6 @@ struct TrinityStringLocale StringVector Content; }; - typedef std::map<uint64, uint64> LinkedRespawnContainer; typedef UNORDERED_MAP<uint32, CreatureData> CreatureDataContainer; typedef UNORDERED_MAP<uint32, GameObjectData> GameObjectDataContainer; @@ -527,6 +526,7 @@ struct GraveYardData uint32 safeLocId; uint32 team; }; + typedef std::multimap<uint32, GraveYardData> GraveYardContainer; typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemContainer; @@ -641,7 +641,7 @@ class ObjectMgr return NULL; } - InstanceTemplate const* GetInstanceTemplate(uint32 mapID); + InstanceTemplate const* GetInstanceTemplate(uint32 mapId); PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint8 level) const; @@ -1334,7 +1334,6 @@ class ObjectMgr GO_TO_GO, GO_TO_CREATURE, // GO is dependant on creature }; - }; #define sObjectMgr ACE_Singleton<ObjectMgr, ACE_Null_Mutex>::instance() diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index b24b5be014a..9879ef7ff3b 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -41,6 +41,7 @@ totalPlayersRolling(0), totalNeed(0), totalGreed(0), totalPass(0), itemSlot(0), rollVoteMask(ROLL_ALL_TYPE_NO_DISENCHANT) { } + Roll::~Roll() { } @@ -1727,7 +1728,7 @@ bool Group::InCombatToInstance(uint32 instanceId) Player* player = itr->getSource(); if (player && !player->getAttackers().empty() && player->GetInstanceId() == instanceId && (player->GetMap()->IsRaidOrHeroicDungeon())) for (std::set<Unit*>::const_iterator i = player->getAttackers().begin(); i != player->getAttackers().end(); ++i) - if ((*i) && (*i)->GetTypeId() == TYPEID_UNIT && (*i)->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) + if ((*i) && (*i)->GetTypeId() == TYPEID_UNIT && (*i)->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) return true; } return false; diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 223bb7dd5c7..f82c52204fb 100755 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -241,6 +241,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) else AH->auctioneer = GUID_LOPART(auctioneer); + // Required stack size of auction matches to current item stack size, just move item to auctionhouse if (itemsCount == 1 && item->GetCount() == count[i]) { if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE)) @@ -278,7 +279,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1); return; } - else + else // Required stack size of auction does not match to current item stack size, clone item and set correct stack size { Item* newItem = item->CloneItem(finalCount, _player); if (!newItem) @@ -313,16 +314,17 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) { Item* item2 = items[j]; + // Item stack count equals required count, ready to delete item - cloned item will be used for auction if (item2->GetCount() == count[j]) { _player->MoveItemFromInventory(item2->GetBagSlot(), item2->GetSlot(), true); SQLTransaction trans = CharacterDatabase.BeginTransaction(); item2->DeleteFromInventoryDB(trans); - item2->SaveToDB(trans); + item2->DeleteFromDB(trans); CharacterDatabase.CommitTransaction(trans); } - else + else // Item stack count is bigger than required count, update item stack count and save to database - cloned item will be used for auction { item2->SetCount(item2->GetCount() - count[j]); item2->SetState(ITEM_CHANGED, _player); diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 467a84be186..c9e99af6fed 100755 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -227,7 +227,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) uint32 unkPackedTime; uint32 flags; uint64 inviteId = 0; - uint64 invitee; + uint64 invitee = 0; uint8 status; uint8 rank; diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 802597e14eb..2434ba6eaa7 100755 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -1262,7 +1262,6 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) } } } - } } diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp index 6508f08dc22..496eae34133 100755 --- a/src/server/game/Handlers/LootHandler.cpp +++ b/src/server/game/Handlers/LootHandler.cpp @@ -386,8 +386,8 @@ void WorldSession::DoLootRelease(uint64 lguid) { Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid); - bool ok_loot = creature && creature->isAlive() == (player->getClass() == CLASS_ROGUE && creature->lootForPickPocketed); - if (!ok_loot || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) + bool lootAllowed = creature && creature->isAlive() == (player->getClass() == CLASS_ROGUE && creature->lootForPickPocketed); + if (!lootAllowed || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) return; loot = &creature->loot; @@ -448,7 +448,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) if (_player->GetLootGUID() != lootguid) return; - Loot* pLoot = NULL; + Loot* loot = NULL; if (IS_CRE_OR_VEH_GUID(GetPlayer()->GetLootGUID())) { @@ -456,7 +456,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) if (!creature) return; - pLoot = &creature->loot; + loot = &creature->loot; } else if (IS_GAMEOBJECT_GUID(GetPlayer()->GetLootGUID())) { @@ -464,19 +464,19 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) if (!pGO) return; - pLoot = &pGO->loot; + loot = &pGO->loot; } - if (!pLoot) + if (!loot) return; - if (slotid > pLoot->items.size()) + if (slotid > loot->items.size()) { - sLog->outDebug(LOG_FILTER_LOOT, "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)", GetPlayer()->GetName(), slotid, (unsigned long)pLoot->items.size()); + sLog->outDebug(LOG_FILTER_LOOT, "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)", GetPlayer()->GetName(), slotid, (unsigned long)loot->items.size()); return; } - LootItem& item = pLoot->items[slotid]; + LootItem& item = loot->items[slotid]; ItemPosCountVec dest; InventoryResult msg = target->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item.itemid, item.count); @@ -495,14 +495,13 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket & recv_data) Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId, looters); target->SendNewItem(newitem, uint32(item.count), false, false, true); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count); - target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, pLoot->loot_type, item.count); + target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, loot->loot_type, item.count); target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count); // mark as looted item.count=0; item.is_looted=true; - pLoot->NotifyItemRemoved(slotid); - --pLoot->unlootedCount; + loot->NotifyItemRemoved(slotid); + --loot->unlootedCount; } - diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index f220be7d2b5..aaa41ec3519 100755 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -125,11 +125,11 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data) if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - if ((unit && unit->GetCreatureInfo()->ScriptID != unit->LastUsedScriptID) || (go && go->GetGOInfo()->ScriptId != go->LastUsedScriptID)) + if ((unit && unit->GetCreatureTemplate()->ScriptID != unit->LastUsedScriptID) || (go && go->GetGOInfo()->ScriptId != go->LastUsedScriptID)) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - Script reloaded while in use, ignoring and set new scipt id"); if (unit) - unit->LastUsedScriptID = unit->GetCreatureInfo()->ScriptID; + unit->LastUsedScriptID = unit->GetCreatureTemplate()->ScriptID; if (go) go->LastUsedScriptID = go->GetGOInfo()->ScriptId; _player->PlayerTalkClass->SendCloseGossip(); @@ -811,7 +811,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) Player* player = GetPlayer(); if (player->isInFlight()) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u", + sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) in flight, ignore Area Trigger ID:%u", player->GetName(), player->GetGUIDLow(), triggerId); return; } @@ -819,14 +819,14 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(triggerId); if (!atEntry) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u", + sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) send unknown (by DBC) Area Trigger ID:%u", player->GetName(), player->GetGUIDLow(), triggerId); return; } if (player->GetMapId() != atEntry->mapid) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u", + sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u", player->GetName(), atEntry->mapid, player->GetMapId(), player->GetGUIDLow(), triggerId); return; } @@ -840,7 +840,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) float dist = player->GetDistance(atEntry->x, atEntry->y, atEntry->z); if (dist > atEntry->radius + delta) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u", + sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (radius: %f distance: %f), ignore Area Trigger ID: %u", player->GetName(), player->GetGUIDLow(), atEntry->radius, dist, triggerId); return; } @@ -871,7 +871,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) (fabs(dy) > atEntry->box_y / 2 + delta) || (fabs(dz) > atEntry->box_z / 2 + delta)) { - sLog->outDebug(LOG_FILTER_NETWORKIO, "Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotatedPlayerX: %f rotatedPlayerY: %f dZ:%f), ignore Area Trigger ID: %u", + sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (1/2 box X: %f 1/2 box Y: %f 1/2 box Z: %f rotatedPlayerX: %f rotatedPlayerY: %f dZ:%f), ignore Area Trigger ID: %u", player->GetName(), player->GetGUIDLow(), atEntry->box_x/2, atEntry->box_y/2, atEntry->box_z/2, rotPlayerX, rotPlayerY, dz, triggerId); return; } @@ -1325,7 +1325,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) WorldPacket data(SMSG_WHOIS, msg.size()+1); data << msg; - _player->GetSession()->SendPacket(&data); + SendPacket(&data); sLog->outDebug(LOG_FILTER_NETWORKIO, "Received whois command from player %s for character %s", GetPlayer()->GetName(), charname.c_str()); } @@ -1501,16 +1501,16 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket & recv_data) { for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pGroupGuy = itr->getSource(); - if (!pGroupGuy) + Player* groupGuy = itr->getSource(); + if (!groupGuy) continue; - if (!pGroupGuy->IsInMap(pGroupGuy)) + if (!groupGuy->IsInMap(groupGuy)) return; - if (pGroupGuy->GetMap()->IsNonRaidDungeon()) + if (groupGuy->GetMap()->IsNonRaidDungeon()) { - sLog->outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!", _player->GetGUIDLow(), pGroupGuy->GetName(), pGroupGuy->GetGUIDLow()); + sLog->outError("WorldSession::HandleSetDungeonDifficultyOpcode: player %d tried to reset the instance while group member (Name: %s, GUID: %u) is inside!", _player->GetGUIDLow(), groupGuy->GetName(), groupGuy->GetGUIDLow()); return; } } @@ -1558,14 +1558,14 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket & recv_data) { for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* pGroupGuy = itr->getSource(); - if (!pGroupGuy) + Player* groupGuy = itr->getSource(); + if (!groupGuy) continue; - if (!pGroupGuy->IsInMap(pGroupGuy)) + if (!groupGuy->IsInMap(groupGuy)) return; - if (pGroupGuy->GetMap()->IsRaid()) + if (groupGuy->GetMap()->IsRaid()) { sLog->outError("WorldSession::HandleSetRaidDifficultyOpcode: player %d tried to reset the instance while inside!", _player->GetGUIDLow()); return; diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index 6a44c7ae5e2..5479791d341 100755 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -135,7 +135,7 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle) if (!unit->isCanTrainingOf(_player, true)) return; - CreatureTemplate const* ci = unit->GetCreatureInfo(); + CreatureTemplate const* ci = unit->GetCreatureTemplate(); if (!ci) { @@ -337,7 +337,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data) if (!sScriptMgr->OnGossipHello(_player, unit)) { // _player->TalkedToCreature(unit->GetEntry(), unit->GetGUID()); - _player->PrepareGossipMenu(unit, unit->GetCreatureInfo()->GossipMenuId, true); + _player->PrepareGossipMenu(unit, unit->GetCreatureTemplate()->GossipMenuId, true); _player->SendPreparedGossip(unit); } unit->AI()->sGossipHello(_player); diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 05d945d3a93..6725992b48a 100755 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -103,7 +103,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data) if (sScriptMgr->OnGossipHello(_player, creature)) return; - _player->PrepareGossipMenu(creature, creature->GetCreatureInfo()->GossipMenuId, true); + _player->PrepareGossipMenu(creature, creature->GetCreatureTemplate()->GossipMenuId, true); _player->SendPreparedGossip(creature); creature->AI()->sGossipHello(_player); diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 64e9b9a27e4..3522571775c 100755 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -147,7 +147,6 @@ uint32 LootStore::LoadLootTable() // Adds current row to the template tab->second->AddEntry(storeitem); ++count; - } while (result->NextRow()); @@ -205,12 +204,12 @@ LootTemplate* LootStore::GetLootForConditionFill(uint32 loot_id) return tab->second; } -uint32 LootStore::LoadAndCollectLootIds(LootIdSet& ids_set) +uint32 LootStore::LoadAndCollectLootIds(LootIdSet& lootIdSet) { uint32 count = LoadLootTable(); for (LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab) - ids_set.insert(tab->first); + lootIdSet.insert(tab->first); return count; } @@ -221,16 +220,16 @@ void LootStore::CheckLootRefs(LootIdSet* ref_set) const ltItr->second->CheckLootRefs(m_LootTemplates, ref_set); } -void LootStore::ReportUnusedIds(LootIdSet const& ids_set) const +void LootStore::ReportUnusedIds(LootIdSet const& lootIdSet) const { // all still listed ids isn't referenced - for (LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr) + for (LootIdSet::const_iterator itr = lootIdSet.begin(); itr != lootIdSet.end(); ++itr) sLog->outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr, GetEntryName()); } void LootStore::ReportNotExistedId(uint32 id) const { - sLog->outErrorDb("Table '%s' entry %d (%s) not exist but used as loot id in DB.", GetName(), id, GetEntryName()); + sLog->outErrorDb("Table '%s' entry %d (%s) does not exist but used as loot id in DB.", GetName(), id, GetEntryName()); } // @@ -296,7 +295,6 @@ bool LootStoreItem::IsValid(LootStore const& store, uint32 entry) const sLog->outErrorDb("Table '%s' entry %d item %d: max count (%u) less that min count (%i) - skipped", store.GetName(), entry, itemid, int32(maxcount), mincountOrRef); return false; } - } else // mincountOrRef < 0 { @@ -1420,8 +1418,8 @@ void LoadLootTemplates_Creature() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set, ids_setUsed; - uint32 count = LootTemplates_Creature.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet, lootIdSetUsed; + uint32 count = LootTemplates_Creature.LoadAndCollectLootIds(lootIdSet); // Remove real entries and check loot existence CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates(); @@ -1429,18 +1427,18 @@ void LoadLootTemplates_Creature() { if (uint32 lootid = itr->second.lootid) { - if (ids_set.find(lootid) == ids_set.end()) + if (lootIdSet.find(lootid) == lootIdSet.end()) LootTemplates_Creature.ReportNotExistedId(lootid); else - ids_setUsed.insert(lootid); + lootIdSetUsed.insert(lootid); } } - for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) - ids_set.erase(*itr); + for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr) + lootIdSet.erase(*itr); // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Creature.ReportUnusedIds(ids_set); + LootTemplates_Creature.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u creature loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1456,7 +1454,7 @@ void LoadLootTemplates_Disenchant() uint32 oldMSTime = getMSTime(); - LootIdSet lootIdSet, loodIdSetUsed; + LootIdSet lootIdSet, lootIdSetUsed; uint32 count = LootTemplates_Disenchant.LoadAndCollectLootIds(lootIdSet); ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); @@ -1467,11 +1465,11 @@ void LoadLootTemplates_Disenchant() if (lootIdSet.find(lootid) == lootIdSet.end()) LootTemplates_Disenchant.ReportNotExistedId(lootid); else - loodIdSetUsed.insert(lootid); + lootIdSetUsed.insert(lootid); } } - for (LootIdSet::const_iterator itr = loodIdSetUsed.begin(); itr != loodIdSetUsed.end(); ++itr) + for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr) lootIdSet.erase(*itr); // output error for any still listed (not referenced from appropriate table) ids @@ -1490,17 +1488,17 @@ void LoadLootTemplates_Fishing() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set; - uint32 count = LootTemplates_Fishing.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet; + uint32 count = LootTemplates_Fishing.LoadAndCollectLootIds(lootIdSet); // remove real entries and check existence loot for (uint32 i = 1; i < sAreaStore.GetNumRows(); ++i) if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i)) - if (ids_set.find(areaEntry->ID) != ids_set.end()) - ids_set.erase(areaEntry->ID); + if (lootIdSet.find(areaEntry->ID) != lootIdSet.end()) + lootIdSet.erase(areaEntry->ID); // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Fishing.ReportUnusedIds(ids_set); + LootTemplates_Fishing.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u fishing loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1516,8 +1514,8 @@ void LoadLootTemplates_Gameobject() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set, ids_setUsed; - uint32 count = LootTemplates_Gameobject.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet, lootIdSetUsed; + uint32 count = LootTemplates_Gameobject.LoadAndCollectLootIds(lootIdSet); // remove real entries and check existence loot GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates(); @@ -1525,18 +1523,18 @@ void LoadLootTemplates_Gameobject() { if (uint32 lootid = itr->second.GetLootId()) { - if (sObjectMgr->IsGoOfSpecificEntrySpawned(itr->second.entry) && ids_set.find(lootid) == ids_set.end()) + if (sObjectMgr->IsGoOfSpecificEntrySpawned(itr->second.entry) && lootIdSet.find(lootid) == lootIdSet.end()) LootTemplates_Gameobject.ReportNotExistedId(lootid); else - ids_setUsed.insert(lootid); + lootIdSetUsed.insert(lootid); } } - for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) - ids_set.erase(*itr); + for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr) + lootIdSet.erase(*itr); // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Gameobject.ReportUnusedIds(ids_set); + LootTemplates_Gameobject.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u gameobject loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1552,17 +1550,17 @@ void LoadLootTemplates_Item() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set; - uint32 count = LootTemplates_Item.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet; + uint32 count = LootTemplates_Item.LoadAndCollectLootIds(lootIdSet); // remove real entries and check existence loot ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr) - if (ids_set.find(itr->second.ItemId) != ids_set.end() && itr->second.Flags & ITEM_PROTO_FLAG_OPENABLE) - ids_set.erase(itr->second.ItemId); + if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end() && itr->second.Flags & ITEM_PROTO_FLAG_OPENABLE) + lootIdSet.erase(itr->second.ItemId); // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Item.ReportUnusedIds(ids_set); + LootTemplates_Item.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u prospecting loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1578,8 +1576,8 @@ void LoadLootTemplates_Milling() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set; - uint32 count = LootTemplates_Milling.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet; + uint32 count = LootTemplates_Milling.LoadAndCollectLootIds(lootIdSet); // remove real entries and check existence loot ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); @@ -1588,12 +1586,12 @@ void LoadLootTemplates_Milling() if (!(itr->second.Flags & ITEM_PROTO_FLAG_MILLABLE)) continue; - if (ids_set.find(itr->second.ItemId) != ids_set.end()) - ids_set.erase(itr->second.ItemId); + if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end()) + lootIdSet.erase(itr->second.ItemId); } // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Milling.ReportUnusedIds(ids_set); + LootTemplates_Milling.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u milling loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1609,8 +1607,8 @@ void LoadLootTemplates_Pickpocketing() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set, ids_setUsed; - uint32 count = LootTemplates_Pickpocketing.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet, lootIdSetUsed; + uint32 count = LootTemplates_Pickpocketing.LoadAndCollectLootIds(lootIdSet); // Remove real entries and check loot existence CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates(); @@ -1618,18 +1616,18 @@ void LoadLootTemplates_Pickpocketing() { if (uint32 lootid = itr->second.pickpocketLootId) { - if (ids_set.find(lootid) == ids_set.end()) + if (lootIdSet.find(lootid) == lootIdSet.end()) LootTemplates_Pickpocketing.ReportNotExistedId(lootid); else - ids_setUsed.insert(lootid); + lootIdSetUsed.insert(lootid); } } - for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) - ids_set.erase(*itr); + for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr) + lootIdSet.erase(*itr); // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Pickpocketing.ReportUnusedIds(ids_set); + LootTemplates_Pickpocketing.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u pickpocketing loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1645,8 +1643,8 @@ void LoadLootTemplates_Prospecting() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set; - uint32 count = LootTemplates_Prospecting.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet; + uint32 count = LootTemplates_Prospecting.LoadAndCollectLootIds(lootIdSet); // remove real entries and check existence loot ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore(); @@ -1655,12 +1653,12 @@ void LoadLootTemplates_Prospecting() if (!(itr->second.Flags & ITEM_PROTO_FLAG_PROSPECTABLE)) continue; - if (ids_set.find(itr->second.ItemId) != ids_set.end()) - ids_set.erase(itr->second.ItemId); + if (lootIdSet.find(itr->second.ItemId) != lootIdSet.end()) + lootIdSet.erase(itr->second.ItemId); } // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Prospecting.ReportUnusedIds(ids_set); + LootTemplates_Prospecting.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u prospecting loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1676,17 +1674,17 @@ void LoadLootTemplates_Mail() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set; - uint32 count = LootTemplates_Mail.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet; + uint32 count = LootTemplates_Mail.LoadAndCollectLootIds(lootIdSet); // remove real entries and check existence loot for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i) if (sMailTemplateStore.LookupEntry(i)) - if (ids_set.find(i) != ids_set.end()) - ids_set.erase(i); + if (lootIdSet.find(i) != lootIdSet.end()) + lootIdSet.erase(i); // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Mail.ReportUnusedIds(ids_set); + LootTemplates_Mail.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u mail loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1702,8 +1700,8 @@ void LoadLootTemplates_Skinning() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set, ids_setUsed; - uint32 count = LootTemplates_Skinning.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet, lootIdSetUsed; + uint32 count = LootTemplates_Skinning.LoadAndCollectLootIds(lootIdSet); // remove real entries and check existence loot CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates(); @@ -1711,18 +1709,18 @@ void LoadLootTemplates_Skinning() { if (uint32 lootid = itr->second.SkinLootId) { - if (ids_set.find(lootid) == ids_set.end()) + if (lootIdSet.find(lootid) == lootIdSet.end()) LootTemplates_Skinning.ReportNotExistedId(lootid); else - ids_setUsed.insert(lootid); + lootIdSetUsed.insert(lootid); } } - for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) - ids_set.erase(*itr); + for (LootIdSet::const_iterator itr = lootIdSetUsed.begin(); itr != lootIdSetUsed.end(); ++itr) + lootIdSet.erase(*itr); // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Skinning.ReportUnusedIds(ids_set); + LootTemplates_Skinning.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u skinning loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1738,8 +1736,8 @@ void LoadLootTemplates_Spell() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set; - uint32 count = LootTemplates_Spell.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet; + uint32 count = LootTemplates_Spell.LoadAndCollectLootIds(lootIdSet); // remove real entries and check existence loot for (uint32 spell_id = 1; spell_id < sSpellMgr->GetSpellInfoStoreSize(); ++spell_id) @@ -1752,7 +1750,7 @@ void LoadLootTemplates_Spell() if (!spellInfo->IsLootCrafting()) continue; - if (ids_set.find(spell_id) == ids_set.end()) + if (lootIdSet.find(spell_id) == lootIdSet.end()) { // not report about not trainable spells (optionally supported by DB) // ignore 61756 (Northrend Inscription Research (FAST QA VERSION) for example @@ -1762,11 +1760,11 @@ void LoadLootTemplates_Spell() } } else - ids_set.erase(spell_id); + lootIdSet.erase(spell_id); } // output error for any still listed (not referenced from appropriate table) ids - LootTemplates_Spell.ReportUnusedIds(ids_set); + LootTemplates_Spell.ReportUnusedIds(lootIdSet); if (count) sLog->outString(">> Loaded %u spell loot templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); @@ -1781,24 +1779,24 @@ void LoadLootTemplates_Reference() uint32 oldMSTime = getMSTime(); - LootIdSet ids_set; - LootTemplates_Reference.LoadAndCollectLootIds(ids_set); + LootIdSet lootIdSet; + LootTemplates_Reference.LoadAndCollectLootIds(lootIdSet); // check references and remove used - LootTemplates_Creature.CheckLootRefs(&ids_set); - LootTemplates_Fishing.CheckLootRefs(&ids_set); - LootTemplates_Gameobject.CheckLootRefs(&ids_set); - LootTemplates_Item.CheckLootRefs(&ids_set); - LootTemplates_Milling.CheckLootRefs(&ids_set); - LootTemplates_Pickpocketing.CheckLootRefs(&ids_set); - LootTemplates_Skinning.CheckLootRefs(&ids_set); - LootTemplates_Disenchant.CheckLootRefs(&ids_set); - LootTemplates_Prospecting.CheckLootRefs(&ids_set); - LootTemplates_Mail.CheckLootRefs(&ids_set); - LootTemplates_Reference.CheckLootRefs(&ids_set); + LootTemplates_Creature.CheckLootRefs(&lootIdSet); + LootTemplates_Fishing.CheckLootRefs(&lootIdSet); + LootTemplates_Gameobject.CheckLootRefs(&lootIdSet); + LootTemplates_Item.CheckLootRefs(&lootIdSet); + LootTemplates_Milling.CheckLootRefs(&lootIdSet); + LootTemplates_Pickpocketing.CheckLootRefs(&lootIdSet); + LootTemplates_Skinning.CheckLootRefs(&lootIdSet); + LootTemplates_Disenchant.CheckLootRefs(&lootIdSet); + LootTemplates_Prospecting.CheckLootRefs(&lootIdSet); + LootTemplates_Mail.CheckLootRefs(&lootIdSet); + LootTemplates_Reference.CheckLootRefs(&lootIdSet); // output error for any still listed ids (not referenced from any loot table) - LootTemplates_Reference.ReportUnusedIds(ids_set); + LootTemplates_Reference.ReportUnusedIds(lootIdSet); sLog->outString(">> Loaded refence loot templates in %u ms", GetMSTimeDiffToNow(oldMSTime)); sLog->outString(); diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 31dc622a724..00b52bf746b 100755 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -32,6 +32,7 @@ #include "Group.h" #include "LFGMgr.h" #include "DynamicTree.h" +#include "Vehicle.h" union u_map_magic { @@ -702,6 +703,8 @@ void Map::PlayerRelocation(Player* player, float x, float y, float z, float orie Cell new_cell(x, y); player->Relocate(x, y, z, orientation); + if (player->IsVehicle()) + player->GetVehicleKit()->RelocatePassengers(x, y, z, orientation); if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell)) { @@ -740,6 +743,8 @@ void Map::CreatureRelocation(Creature* creature, float x, float y, float z, floa else { creature->Relocate(x, y, z, ang); + if (creature->IsVehicle()) + creature->GetVehicleKit()->RelocatePassengers(x, y, z, ang); creature->UpdateObjectVisibility(false); RemoveCreatureFromMoveList(creature); } diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp index fbe609bee23..5543251e115 100755 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -116,19 +116,21 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player) return NULL; Map* map = NULL; - uint32 NewInstanceId = 0; // instanceId of the resulting map + uint32 newInstanceId = 0; // instanceId of the resulting map if (IsBattlegroundOrArena()) { // instantiate or find existing bg map for player // the instance id is set in battlegroundid - NewInstanceId = player->GetBattlegroundId(); - if (!NewInstanceId) return NULL; - map = sMapMgr->FindMap(mapId, NewInstanceId); + newInstanceId = player->GetBattlegroundId(); + if (!newInstanceId) + return NULL; + + map = sMapMgr->FindMap(mapId, newInstanceId); if (!map) { if (Battleground* bg = player->GetBattleground()) - map = CreateBattleground(NewInstanceId, bg); + map = CreateBattleground(newInstanceId, bg); else { player->TeleportToBGEntryPoint(); @@ -158,24 +160,24 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player) if (pSave) { // solo/perm/group - NewInstanceId = pSave->GetInstanceId(); - map = FindInstanceMap(NewInstanceId); + newInstanceId = pSave->GetInstanceId(); + map = FindInstanceMap(newInstanceId); // it is possible that the save exists but the map doesn't if (!map) - map = CreateInstance(NewInstanceId, pSave, pSave->GetDifficulty()); + map = CreateInstance(newInstanceId, pSave, pSave->GetDifficulty()); } else { // if no instanceId via group members or instance saves is found // the instance will be created for the first time - NewInstanceId = sMapMgr->GenerateInstanceId(); + newInstanceId = sMapMgr->GenerateInstanceId(); Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid()); //Seems it is now possible, but I do not know if it should be allowed //ASSERT(!FindInstanceMap(NewInstanceId)); - map = FindInstanceMap(NewInstanceId); + map = FindInstanceMap(newInstanceId); if (!map) - map = CreateInstance(NewInstanceId, NULL, diff); + map = CreateInstance(newInstanceId, NULL, diff); } } diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h index 4faacc1f7b7..bf00514000e 100755 --- a/src/server/game/Miscellaneous/Formulas.h +++ b/src/server/game/Miscellaneous/Formulas.h @@ -162,8 +162,8 @@ namespace Trinity if (u->GetTypeId() == TYPEID_UNIT && (((Creature*)u)->isTotem() || ((Creature*)u)->isPet() || - (((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) || - ((Creature*)u)->GetCreatureInfo()->type == CREATURE_TYPE_CRITTER)) + (((Creature*)u)->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) || + ((Creature*)u)->GetCreatureTemplate()->type == CREATURE_TYPE_CRITTER)) gain = 0; else { diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index e751dbf92fe..547f1679b61 100755 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -811,7 +811,9 @@ enum TrinityStrings LANG_MOVEGENS_FOLLOW_CREATURE = 1140, LANG_MOVEGENS_FOLLOW_NULL = 1141, LANG_MOVEGENS_EFFECT = 1142, - // Room for more level 3 1143-1199 not used + LANG_MOVEFLAGS_GET = 1143, + LANG_MOVEFLAGS_SET = 1144, + // Room for more level 3 1144-1199 not used // Debug commands LANG_CINEMATIC_NOT_EXIST = 1200, diff --git a/src/server/game/Movement/MovementGenerator.h b/src/server/game/Movement/MovementGenerator.h index dd9ba32f337..0a2ebcfaeee 100755 --- a/src/server/game/Movement/MovementGenerator.h +++ b/src/server/game/Movement/MovementGenerator.h @@ -38,7 +38,7 @@ class MovementGenerator virtual void Reset(Unit &) = 0; - virtual bool Update(Unit &, const uint32 time_diff) = 0; + virtual bool Update(Unit &, const uint32& time_diff) = 0; virtual MovementGeneratorType GetMovementGeneratorType() = 0; @@ -64,7 +64,7 @@ class MovementGeneratorMedium : public MovementGenerator //u->AssertIsType<T>(); (static_cast<D*>(this))->Reset(*((T*)&u)); } - bool Update(Unit &u, const uint32 time_diff) + bool Update(Unit &u, const uint32& time_diff) { //u->AssertIsType<T>(); return (static_cast<D*>(this))->Update(*((T*)&u), time_diff); @@ -74,7 +74,7 @@ class MovementGeneratorMedium : public MovementGenerator void Initialize(T &u); void Finalize(T &u); void Reset(T &u); - bool Update(T &u, const uint32 time_diff); + bool Update(T &u, const uint32& time_diff); }; struct SelectableMovement : public FactoryHolder<MovementGenerator, MovementGeneratorType> diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp index 216afbb2b20..ecf314c8bbc 100755 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp @@ -399,7 +399,7 @@ void TimedFleeingMovementGenerator::Finalize(Unit &owner) } } -bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32 time_diff) +bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32& time_diff) { if (!owner.isAlive()) return false; diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h index 750db52bb5a..f795a002821 100755 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.h @@ -64,7 +64,7 @@ class TimedFleeingMovementGenerator i_totalFleeTime(time) {} MovementGeneratorType GetMovementGeneratorType() { return TIMED_FLEEING_MOTION_TYPE; } - bool Update(Unit &, const uint32); + bool Update(Unit &, const uint32&); void Finalize(Unit &); private: diff --git a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp index 36561e00b93..9f4568df113 100755 --- a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp @@ -49,7 +49,7 @@ void RotateMovementGenerator::Initialize(Unit& owner) owner.AttackStop(); } -bool RotateMovementGenerator::Update(Unit& owner, const uint32 diff) +bool RotateMovementGenerator::Update(Unit& owner, const uint32& diff) { float angle = owner.GetOrientation(); if (m_direction == ROTATE_DIRECTION_LEFT) @@ -93,7 +93,7 @@ DistractMovementGenerator::Finalize(Unit& owner) } bool -DistractMovementGenerator::Update(Unit& /*owner*/, const uint32 time_diff) +DistractMovementGenerator::Update(Unit& /*owner*/, const uint32& time_diff) { if (time_diff > m_timer) return false; diff --git a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h index 8180a86c49b..7acec82af98 100755 --- a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.h @@ -28,7 +28,7 @@ class IdleMovementGenerator : public MovementGenerator void Initialize(Unit &); void Finalize(Unit &) { } void Reset(Unit &); - bool Update(Unit &, const uint32) { return true; } + bool Update(Unit &, const uint32&) { return true; } MovementGeneratorType GetMovementGeneratorType() { return IDLE_MOTION_TYPE; } }; @@ -42,7 +42,7 @@ class RotateMovementGenerator : public MovementGenerator void Initialize(Unit& owner); void Finalize(Unit& owner); void Reset(Unit& owner) { Initialize(owner); } - bool Update(Unit& owner, const uint32 time_diff); + bool Update(Unit& owner, const uint32& time_diff); MovementGeneratorType GetMovementGeneratorType() { return ROTATE_MOTION_TYPE; } private: @@ -58,7 +58,7 @@ class DistractMovementGenerator : public MovementGenerator void Initialize(Unit& owner); void Finalize(Unit& owner); void Reset(Unit& owner) { Initialize(owner); } - bool Update(Unit& owner, const uint32 time_diff); + bool Update(Unit& owner, const uint32& time_diff); MovementGeneratorType GetMovementGeneratorType() { return DISTRACT_MOTION_TYPE; } private: diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index c565e150740..fddfe5f8fb0 100755 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -107,7 +107,7 @@ void AssistanceMovementGenerator::Finalize(Unit &unit) unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY)); } -bool EffectMovementGenerator::Update(Unit &unit, const uint32) +bool EffectMovementGenerator::Update(Unit &unit, const uint32&) { return !unit.movespline->Finalized(); } @@ -117,7 +117,7 @@ void EffectMovementGenerator::Finalize(Unit &unit) if (unit.GetTypeId() != TYPEID_UNIT) return; - if (((Creature&)unit).AI() && unit.movespline->Finalized()) + if (((Creature&)unit).AI()) ((Creature&)unit).AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id); // Need restore previous movement since we have no proper states system //if (unit.isAlive() && !unit.HasUnitState(UNIT_STATE_CONFUSED|UNIT_STATE_FLEEING)) diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h index e47f3d93450..82578da5f9b 100755 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h @@ -65,7 +65,7 @@ class EffectMovementGenerator : public MovementGenerator void Initialize(Unit &) {} void Finalize(Unit &unit); void Reset(Unit &) {} - bool Update(Unit &u, const uint32); + bool Update(Unit &u, const uint32&); MovementGeneratorType GetMovementGeneratorType() { return EFFECT_MOTION_TYPE; } private: uint32 m_Id; diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index a8602153de3..8458232c336 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -240,7 +240,7 @@ void FlightPathMovementGenerator::Reset(Player & player) init.Launch(); } -bool FlightPathMovementGenerator::Update(Player &player, const uint32 /*diff*/) +bool FlightPathMovementGenerator::Update(Player &player, const uint32& /*diff*/) { uint32 pointId = (uint32)player.movespline->currentPathIdx(); if (pointId > i_currentNode) diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h index 9c2475267f6..b5b43fcae64 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h @@ -123,7 +123,7 @@ public PathMovementBase<Player, TaxiPathNodeList const*> void Initialize(Player &); void Reset(Player &); void Finalize(Player &); - bool Update(Player &, const uint32); + bool Update(Player &, const uint32&); MovementGeneratorType GetMovementGeneratorType() { return FLIGHT_MOTION_TYPE; } TaxiPathNodeList const& GetPath() { return *i_path; } diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 47751338d66..ac15bd5c985 100755 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -1295,6 +1295,11 @@ void ScriptMgr::OnPlayerBindToInstance(Player* player, Difficulty difficulty, ui FOREACH_SCRIPT(PlayerScript)->OnBindToInstance(player, difficulty, mapid, permanent); } +void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea) +{ + FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea); +} + // Guild void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank) { diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 048a7581215..3b65a5cf256 100755 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -724,6 +724,9 @@ class PlayerScript : public ScriptObject // Called when a player is bound to an instance virtual void OnBindToInstance(Player* /*player*/, Difficulty /*difficulty*/, uint32 /*mapId*/, bool /*permanent*/) { } + + // Called when a player switches to a new zone + virtual void OnUpdateZone(Player* /*player*/, uint32 /*newZone*/, uint32 /*newArea*/) { } }; class GuildScript : public ScriptObject @@ -993,6 +996,7 @@ class ScriptMgr void OnPlayerCreate(Player* player); void OnPlayerDelete(uint64 guid); void OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent); + void OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea); public: /* GuildScript */ diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index e2e6772f230..e5b5b20dcfa 100755 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -769,7 +769,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x2E4*/ { "SMSG_AREA_SPIRIT_HEALER_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x2E5*/ { "CMSG_GM_UNTEACH", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x2E6*/ { "SMSG_WARDEN_DATA", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x2E7*/ { "CMSG_WARDEN_DATA", STATUS_AUTHED, PROCESS_THREADUNSAFE, &WorldSession::HandleWardenDataOpcode }, + /*0x2E7*/ { "CMSG_WARDEN_DATA", STATUS_AUTHED, PROCESS_THREADSAFE, &WorldSession::HandleWardenDataOpcode }, /*0x2E8*/ { "SMSG_GROUP_JOINED_BATTLEGROUND", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x2E9*/ { "MSG_BATTLEGROUND_PLAYER_POSITIONS", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlegroundPlayerPositionsOpcode}, /*0x2EA*/ { "CMSG_PET_STOP_ATTACK", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandlePetStopAttack }, diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index cb79bd00776..56bca65788c 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -5668,27 +5668,6 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const target->CastSpell((Unit*)NULL, m_spellInfo->Effects[m_effIndex].TriggerSpell, true); break; } - case SPELLFAMILY_WARLOCK: - { - switch (GetSpellInfo()->Id) - { - // Demonic Circle - case 48018: - if (GameObject* obj = target->GetGameObject(GetSpellInfo()->Id)) - { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(48020); - if (target->IsWithinDist(obj, spellInfo->GetMaxRange(true))) - { - if (!target->HasAura(62388)) - target->CastSpell(target, 62388, true); - } - else - target->RemoveAura(62388); - } - break; - } - break; - } case SPELLFAMILY_DRUID: { switch (GetSpellInfo()->Id) @@ -5912,15 +5891,15 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) // move loot to player inventory and despawn target if (caster && caster->GetTypeId() == TYPEID_PLAYER && target->GetTypeId() == TYPEID_UNIT && - target->ToCreature()->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD) + target->ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_GAS_CLOUD) { Player* player = caster->ToPlayer(); Creature* creature = target->ToCreature(); // missing lootid has been reported on startup - just return - if (!creature->GetCreatureInfo()->SkinLootId) + if (!creature->GetCreatureTemplate()->SkinLootId) return; - player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, true); + player->AutoStoreLoot(creature->GetCreatureTemplate()->SkinLootId, LootTemplates_Skinning, true); creature->DespawnOrUnsummon(); } diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 5329c1a0914..32473a93a26 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1202,19 +1202,6 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b break; } break; - case SPELLFAMILY_WARLOCK: - switch (GetId()) - { - case 48020: // Demonic Circle - if (target->GetTypeId() == TYPEID_PLAYER) - if (GameObject* obj = target->GetGameObject(48018)) - { - target->NearTeleportTo(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation()); - target->RemoveMovementImpairingAuras(); - } - break; - } - break; case SPELLFAMILY_PRIEST: if (!caster) break; @@ -1418,17 +1405,6 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b caster->CastSpell(target, spellId, true); } } - switch (GetId()) - { - case 48018: // Demonic Circle - // Do not remove GO when aura is removed by stack - // to prevent remove GO added by new spell - // old one is already removed - if (!onReapply) - target->RemoveGameObject(GetId(), true); - target->RemoveAura(62388); - break; - } break; case SPELLFAMILY_PRIEST: if (!caster) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index e2cd360b844..2ffa94371f9 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -56,6 +56,35 @@ extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS]; +SpellDestination::SpellDestination() +{ + _position.Relocate(0, 0, 0, 0); + _transportGUID = 0; + _transportOffset.Relocate(0, 0, 0, 0); +} + +SpellDestination::SpellDestination(float x, float y, float z, float orientation, uint32 mapId) +{ + _position.Relocate(x, y, z, orientation); + _transportGUID = 0; + _position.m_mapId = mapId; +} + +SpellDestination::SpellDestination(Position const& pos) +{ + _position.Relocate(pos); + _transportGUID = 0; +} + +SpellDestination::SpellDestination(WorldObject const& wObj) +{ + _transportGUID = wObj.GetTransGUID(); + _transportOffset.Relocate(wObj.GetTransOffsetX(), wObj.GetTransOffsetY(), wObj.GetTransOffsetZ(), wObj.GetTransOffsetO()); + _position.Relocate(wObj); + _position.SetOrientation(wObj.GetOrientation()); +} + + SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0) { m_objectTarget = NULL; @@ -65,12 +94,6 @@ SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0) m_itemTargetGUID = 0; m_itemTargetEntry = 0; - m_srcTransGUID = 0; - m_srcTransOffset.Relocate(0, 0, 0, 0); - m_srcPos.Relocate(0, 0, 0, 0); - m_dstTransGUID = 0; - m_dstTransOffset.Relocate(0, 0, 0, 0); - m_dstPos.Relocate(0, 0, 0, 0); m_strTarget = ""; m_targetMask = 0; } @@ -94,36 +117,36 @@ void SpellCastTargets::Read(ByteBuffer& data, Unit* caster) if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION) { - data.readPackGUID(m_srcTransGUID); - if (m_srcTransGUID) - data >> m_srcTransOffset.PositionXYZStream(); + data.readPackGUID(m_src._transportGUID); + if (m_src._transportGUID) + data >> m_src._transportOffset.PositionXYZStream(); else - data >> m_srcPos.PositionXYZStream(); + data >> m_src._position.PositionXYZStream(); } else { - m_srcTransGUID = caster->GetTransGUID(); - if (m_srcTransGUID) - m_srcTransOffset.Relocate(caster->GetTransOffsetX(), caster->GetTransOffsetY(), caster->GetTransOffsetZ(), caster->GetTransOffsetO()); + m_src._transportGUID = caster->GetTransGUID(); + if (m_src._transportGUID) + m_src._transportOffset.Relocate(caster->GetTransOffsetX(), caster->GetTransOffsetY(), caster->GetTransOffsetZ(), caster->GetTransOffsetO()); else - m_srcPos.Relocate(caster); + m_src._position.Relocate(caster); } if (m_targetMask & TARGET_FLAG_DEST_LOCATION) { - data.readPackGUID(m_dstTransGUID); - if (m_dstTransGUID) - data >> m_dstTransOffset.PositionXYZStream(); + data.readPackGUID(m_dst._transportGUID); + if (m_dst._transportGUID) + data >> m_dst._transportOffset.PositionXYZStream(); else - data >> m_dstPos.PositionXYZStream(); + data >> m_dst._position.PositionXYZStream(); } else { - m_dstTransGUID = caster->GetTransGUID(); - if (m_dstTransGUID) - m_dstTransOffset.Relocate(caster->GetTransOffsetX(), caster->GetTransOffsetY(), caster->GetTransOffsetZ(), caster->GetTransOffsetO()); + m_dst._transportGUID = caster->GetTransGUID(); + if (m_dst._transportGUID) + m_dst._transportOffset.Relocate(caster->GetTransOffsetX(), caster->GetTransOffsetY(), caster->GetTransOffsetZ(), caster->GetTransOffsetO()); else - m_dstPos.Relocate(caster); + m_dst._position.Relocate(caster); } if (m_targetMask & TARGET_FLAG_STRING) @@ -149,20 +172,20 @@ void SpellCastTargets::Write(ByteBuffer& data) if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION) { - data.appendPackGUID(m_srcTransGUID); // relative position guid here - transport for example - if (m_srcTransGUID) - data << m_srcTransOffset.PositionXYZStream(); + data.appendPackGUID(m_src._transportGUID); // relative position guid here - transport for example + if (m_src._transportGUID) + data << m_src._transportOffset.PositionXYZStream(); else - data << m_srcPos.PositionXYZStream(); + data << m_src._position.PositionXYZStream(); } if (m_targetMask & TARGET_FLAG_DEST_LOCATION) { - data.appendPackGUID(m_dstTransGUID); // relative position guid here - transport for example - if (m_dstTransGUID) - data << m_dstTransOffset.PositionXYZStream(); + data.appendPackGUID(m_dst._transportGUID); // relative position guid here - transport for example + if (m_dst._transportGUID) + data << m_dst._transportOffset.PositionXYZStream(); else - data << m_dstPos.PositionXYZStream(); + data << m_dst._position.PositionXYZStream(); } if (m_targetMask & TARGET_FLAG_STRING) @@ -295,31 +318,31 @@ void SpellCastTargets::UpdateTradeSlotItem() } } -Position const* SpellCastTargets::GetSrc() const +SpellDestination const* SpellCastTargets::GetSrc() const { - return &m_srcPos; + return &m_src; +} + +Position const* SpellCastTargets::GetSrcPos() const +{ + return &m_src._position; } void SpellCastTargets::SetSrc(float x, float y, float z) { - m_srcPos.Relocate(x, y, z); - m_srcTransGUID = 0; + m_src = SpellDestination(x, y, z); m_targetMask |= TARGET_FLAG_SOURCE_LOCATION; } void SpellCastTargets::SetSrc(Position const& pos) { - m_srcPos.Relocate(pos); - m_srcTransGUID = 0; + m_src = SpellDestination(pos); m_targetMask |= TARGET_FLAG_SOURCE_LOCATION; } void SpellCastTargets::SetSrc(WorldObject const& wObj) { - uint64 guid = wObj.GetTransGUID(); - m_srcTransGUID = guid; - m_srcTransOffset.Relocate(wObj.GetTransOffsetX(), wObj.GetTransOffsetY(), wObj.GetTransOffsetZ(), wObj.GetTransOffsetO()); - m_srcPos.Relocate(wObj); + m_src = SpellDestination(wObj); m_targetMask |= TARGET_FLAG_SOURCE_LOCATION; } @@ -327,13 +350,13 @@ void SpellCastTargets::ModSrc(Position const& pos) { ASSERT(m_targetMask & TARGET_FLAG_SOURCE_LOCATION); - if (m_srcTransGUID) + if (m_src._transportGUID) { Position offset; - m_srcPos.GetPositionOffsetTo(pos, offset); - m_srcTransOffset.RelocateOffset(offset); + m_src._position.GetPositionOffsetTo(pos, offset); + m_src._transportOffset.RelocateOffset(offset); } - m_srcPos.Relocate(pos); + m_src._position.Relocate(pos); } void SpellCastTargets::RemoveSrc() @@ -341,41 +364,37 @@ void SpellCastTargets::RemoveSrc() m_targetMask &= ~(TARGET_FLAG_SOURCE_LOCATION); } -WorldLocation const* SpellCastTargets::GetDst() const +SpellDestination const* SpellCastTargets::GetDst() const { - return &m_dstPos; + return &m_dst; +} + +WorldLocation const* SpellCastTargets::GetDstPos() const +{ + return &m_dst._position; } void SpellCastTargets::SetDst(float x, float y, float z, float orientation, uint32 mapId) { - m_dstPos.Relocate(x, y, z, orientation); - m_dstTransGUID = 0; + m_dst = SpellDestination(x, y, z, orientation, mapId); m_targetMask |= TARGET_FLAG_DEST_LOCATION; - if (mapId != MAPID_INVALID) - m_dstPos.m_mapId = mapId; } void SpellCastTargets::SetDst(Position const& pos) { - m_dstPos.Relocate(pos); - m_dstTransGUID = 0; + m_dst = SpellDestination(pos); m_targetMask |= TARGET_FLAG_DEST_LOCATION; } void SpellCastTargets::SetDst(WorldObject const& wObj) { - uint64 guid = wObj.GetTransGUID(); - m_dstTransGUID = guid; - m_dstTransOffset.Relocate(wObj.GetTransOffsetX(), wObj.GetTransOffsetY(), wObj.GetTransOffsetZ(), wObj.GetTransOffsetO()); - m_dstPos.Relocate(wObj); + m_dst = SpellDestination(wObj); m_targetMask |= TARGET_FLAG_DEST_LOCATION; } void SpellCastTargets::SetDst(SpellCastTargets const& spellTargets) { - m_dstTransGUID = spellTargets.m_dstTransGUID; - m_dstTransOffset.Relocate(spellTargets.m_dstTransOffset); - m_dstPos.Relocate(spellTargets.m_dstPos); + m_dst = spellTargets.m_dst; m_targetMask |= TARGET_FLAG_DEST_LOCATION; } @@ -383,13 +402,13 @@ void SpellCastTargets::ModDst(Position const& pos) { ASSERT(m_targetMask & TARGET_FLAG_DEST_LOCATION); - if (m_dstTransGUID) + if (m_dst._transportGUID) { Position offset; - m_dstPos.GetPositionOffsetTo(pos, offset); - m_dstTransOffset.RelocateOffset(offset); + m_dst._position.GetPositionOffsetTo(pos, offset); + m_dst._transportOffset.RelocateOffset(offset); } - m_dstPos.Relocate(pos); + m_dst._position.Relocate(pos); } void SpellCastTargets::RemoveDst() @@ -417,21 +436,21 @@ void SpellCastTargets::Update(Unit* caster) } // update positions by transport move - if (HasSrc() && m_srcTransGUID) + if (HasSrc() && m_src._transportGUID) { - if (WorldObject* transport = ObjectAccessor::GetWorldObject(*caster, m_srcTransGUID)) + if (WorldObject* transport = ObjectAccessor::GetWorldObject(*caster, m_src._transportGUID)) { - m_srcPos.Relocate(transport); - m_srcPos.RelocateOffset(m_srcTransOffset); + m_src._position.Relocate(transport); + m_src._position.RelocateOffset(m_src._transportOffset); } } - if (HasDst() && m_dstTransGUID) + if (HasDst() && m_dst._transportGUID) { - if (WorldObject* transport = ObjectAccessor::GetWorldObject(*caster, m_dstTransGUID)) + if (WorldObject* transport = ObjectAccessor::GetWorldObject(*caster, m_dst._transportGUID)) { - m_dstPos.Relocate(transport); - m_dstPos.RelocateOffset(m_dstTransOffset); + m_dst._position.Relocate(transport); + m_dst._position.RelocateOffset(m_dst._transportOffset); } } } @@ -449,9 +468,9 @@ void SpellCastTargets::OutDebug() const if (m_targetMask & TARGET_FLAG_TRADE_ITEM) sLog->outString("Trade item target: " UI64FMTD, m_itemTargetGUID); if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION) - sLog->outString("Source location: transport guid:" UI64FMTD " trans offset: %s position: %s", m_srcTransGUID, m_srcTransOffset.ToString().c_str(), m_srcPos.ToString().c_str()); + sLog->outString("Source location: transport guid:" UI64FMTD " trans offset: %s position: %s", m_src._transportGUID, m_src._transportOffset.ToString().c_str(), m_src._position.ToString().c_str()); if (m_targetMask & TARGET_FLAG_DEST_LOCATION) - sLog->outString("Destination location: transport guid:" UI64FMTD " trans offset: %s position: %s", m_dstTransGUID, m_dstTransOffset.ToString().c_str(), m_dstPos.ToString().c_str()); + sLog->outString("Destination location: transport guid:" UI64FMTD " trans offset: %s position: %s", m_dst._transportGUID, m_dst._transportOffset.ToString().c_str(), m_dst._position.ToString().c_str()); if (m_targetMask & TARGET_FLAG_STRING) sLog->outString("String: %s", m_strTarget.c_str()); sLog->outString("speed: %f", m_speed); @@ -564,6 +583,11 @@ m_caster((info->AttributesEx6 & SPELL_ATTR6_CAST_BY_CHARMER && caster->GetCharme CleanupTargetList(); CleanupEffectExecuteData(); + + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + m_destTargets[i] = SpellDestination(*m_caster); + } } Spell::~Spell() @@ -720,6 +744,9 @@ void Spell::SelectSpellTargets() // some spell effects don't add anything to target map (confirmed with sniffs) (like SPELL_EFFECT_DESTROY_ALL_TOTEMS) SelectEffectTypeImplicitTargets(i); + if (m_targets.HasDst()) + AddDestTarget(*m_targets.GetDst(), i); + if (m_spellInfo->IsChanneled()) { uint8 mask = (1 << i); @@ -767,7 +794,7 @@ void Spell::SelectSpellTargets() } else if (m_spellInfo->Speed > 0.0f) { - float dist = m_caster->GetDistance(*m_targets.GetDst()); + float dist = m_caster->GetDistance(*m_targets.GetDstPos()); m_delayMoment = (uint64) floor(dist / m_spellInfo->Speed * 1000.0f); } } @@ -826,7 +853,7 @@ void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTar m_targets.SetSrc(*m_caster); break; default: - ASSERT("Spell::SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_SRC"); + ASSERT(false && "Spell::SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_SRC"); break; } break; @@ -843,7 +870,7 @@ void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTar SelectImplicitDestDestTargets(effIndex, targetType); break; default: - ASSERT("Spell::SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_DEST"); + ASSERT(false && "Spell::SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT_DEST"); break; } break; @@ -857,7 +884,7 @@ void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTar SelectImplicitTargetObjectTargets(effIndex, targetType); break; default: - ASSERT("Spell::SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT"); + ASSERT(false && "Spell::SelectEffectImplicitTargets: received not implemented select target reference type for TARGET_TYPE_OBJECT"); break; } break; @@ -1092,10 +1119,10 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge switch (targetType.GetReferenceType()) { case TARGET_REFERENCE_TYPE_SRC: - center = m_targets.GetSrc(); + center = m_targets.GetSrcPos(); break; case TARGET_REFERENCE_TYPE_DEST: - center = m_targets.GetDst(); + center = m_targets.GetDstPos(); break; case TARGET_REFERENCE_TYPE_CASTER: case TARGET_REFERENCE_TYPE_TARGET: @@ -1467,7 +1494,7 @@ void Spell::SelectImplicitDestDestTargets(SpellEffIndex effIndex, SpellImplicitT if (targetType.GetTarget() == TARGET_DEST_DEST_RANDOM) dist *= (float)rand_norm(); - Position pos = *m_targets.GetDst(); + Position pos = *m_targets.GetDstPos(); m_caster->MovePosition(pos, dist, angle); m_targets.ModDst(pos); } @@ -1581,12 +1608,12 @@ void Spell::SelectImplicitTrajTargets() if (!dist2d) return; - float srcToDestDelta = m_targets.GetDst()->m_positionZ - m_targets.GetSrc()->m_positionZ; + float srcToDestDelta = m_targets.GetDstPos()->m_positionZ - m_targets.GetSrcPos()->m_positionZ; std::list<WorldObject*> targets; - Trinity::WorldObjectSpellTrajTargetCheck check(dist2d, m_targets.GetSrc(), m_caster, m_spellInfo); + Trinity::WorldObjectSpellTrajTargetCheck check(dist2d, m_targets.GetSrcPos(), m_caster, m_spellInfo); Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellTrajTargetCheck> searcher(m_caster, targets, check, GRID_MAP_TYPE_MASK_ALL); - SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellTrajTargetCheck> > (searcher, GRID_MAP_TYPE_MASK_ALL, m_caster, m_targets.GetSrc(), dist2d); + SearchTargets<Trinity::WorldObjectListSearcher<Trinity::WorldObjectSpellTrajTargetCheck> > (searcher, GRID_MAP_TYPE_MASK_ALL, m_caster, m_targets.GetSrcPos(), dist2d); if (targets.empty()) return; @@ -1609,8 +1636,8 @@ void Spell::SelectImplicitTrajTargets() const float size = std::max((*itr)->GetObjectSize() * 0.7f, 1.0f); // 1/sqrt(3) // TODO: all calculation should be based on src instead of m_caster - const float objDist2d = m_targets.GetSrc()->GetExactDist2d(*itr) * cos(m_targets.GetSrc()->GetRelativeAngle(*itr)); - const float dz = (*itr)->GetPositionZ() - m_targets.GetSrc()->m_positionZ; + const float objDist2d = m_targets.GetSrcPos()->GetExactDist2d(*itr) * cos(m_targets.GetSrcPos()->GetRelativeAngle(*itr)); + const float dz = (*itr)->GetPositionZ() - m_targets.GetSrcPos()->m_positionZ; DEBUG_TRAJ(sLog->outError("Spell::SelectTrajTargets: check %u, dist between %f %f, height between %f %f.", (*itr)->GetEntry(), objDist2d - size, objDist2d + size, dz - size, dz + size);) @@ -1675,11 +1702,11 @@ void Spell::SelectImplicitTrajTargets() } } - if (m_targets.GetSrc()->GetExactDist2d(m_targets.GetDst()) > bestDist) + if (m_targets.GetSrcPos()->GetExactDist2d(m_targets.GetDstPos()) > bestDist) { - float x = m_targets.GetSrc()->m_positionX + cos(m_caster->GetOrientation()) * bestDist; - float y = m_targets.GetSrc()->m_positionY + sin(m_caster->GetOrientation()) * bestDist; - float z = m_targets.GetSrc()->m_positionZ + bestDist * (a * bestDist + b); + float x = m_targets.GetSrcPos()->m_positionX + cos(m_caster->GetOrientation()) * bestDist; + float y = m_targets.GetSrcPos()->m_positionY + sin(m_caster->GetOrientation()) * bestDist; + float z = m_targets.GetSrcPos()->m_positionZ + bestDist * (a * bestDist + b); if (itr != targets.end()) { @@ -2216,12 +2243,6 @@ void Spell::AddGOTarget(GameObject* go, uint32 effectMask) m_UniqueGOTargetInfo.push_back(target); } -void Spell::AddGOTarget(uint64 goGUID, uint32 effectMask) -{ - if (GameObject* go = m_caster->GetMap()->GetGameObject(goGUID)) - AddGOTarget(go, effectMask); -} - void Spell::AddItemTarget(Item* item, uint32 effectMask) { for (uint32 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex) @@ -2251,6 +2272,11 @@ void Spell::AddItemTarget(Item* item, uint32 effectMask) m_UniqueItemInfo.push_back(target); } +void Spell::AddDestTarget(SpellDestination const& dest, uint32 effIndex) +{ + m_destTargets[effIndex] = dest; +} + void Spell::DoAllEffectOnTarget(TargetInfo* target) { if (!target || target->processed) @@ -2861,34 +2887,6 @@ bool Spell::UpdateChanneledTargetList() return channelTargetEffectMask == 0; } -// Helper for Chain Healing -// Spell target first -// Raidmates then descending by injury suffered (MaxHealth - Health) -// Other players/mobs then descending by injury suffered (MaxHealth - Health) -struct ChainHealingOrder : public std::binary_function<const Unit*, const Unit*, bool> -{ - const Unit* MainTarget; - ChainHealingOrder(Unit const* Target) : MainTarget(Target) {}; - // functor for operator ">" - bool operator()(Unit const* _Left, Unit const* _Right) const - { - return (ChainHealingHash(_Left) < ChainHealingHash(_Right)); - } - - int32 ChainHealingHash(Unit const* Target) const - { - if (Target->GetTypeId() == TYPEID_PLAYER && MainTarget->GetTypeId() == TYPEID_PLAYER && Target->ToPlayer()->IsInSameRaidWith(MainTarget->ToPlayer())) - { - if (Target->IsFullHealth()) - return 40000; - else - return 20000 - Target->GetMaxHealth() + Target->GetHealth(); - } - else - return 40000 - Target->GetMaxHealth() + Target->GetHealth(); - } -}; - void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggeredByAura) { if (m_CastItem) @@ -4605,6 +4603,7 @@ void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOT unitTarget = pUnitTarget; itemTarget = pItemTarget; gameObjTarget = pGOTarget; + destTarget = &m_destTargets[i]._position; uint8 eff = m_spellInfo->Effects[i].Effect; @@ -4845,7 +4844,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_targets.HasDst()) { float x, y, z; - m_targets.GetDst()->GetPosition(x, y, z); + m_targets.GetDstPos()->GetPosition(x, y, z); if (!(m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOS(x, y, z)) return SPELL_FAILED_LINE_OF_SIGHT; @@ -5098,7 +5097,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (creature->GetCreatureType() != CREATURE_TYPE_CRITTER && !creature->loot.isLooted()) return SPELL_FAILED_TARGET_NOT_LOOTED; - uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); + uint32 skill = creature->GetCreatureTemplate()->GetRequiredLootSkill(); int32 skillValue = m_caster->ToPlayer()->GetSkillValue(skill); int32 TargetLevel = m_targets.GetUnitTarget()->getLevel(); @@ -5366,7 +5365,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_HIGHLEVEL; // use SMSG_PET_TAME_FAILURE? - if (!target->GetCreatureInfo()->isTameable (m_caster->ToPlayer()->CanTameExoticPets())) + if (!target->GetCreatureTemplate()->isTameable (m_caster->ToPlayer()->CanTameExoticPets())) return SPELL_FAILED_BAD_TARGETS; if (m_caster->GetPetGUID()) @@ -5782,9 +5781,9 @@ SpellCastResult Spell::CheckRange(bool strict) if (m_targets.HasDst() && !m_targets.HasTraj()) { - if (!m_caster->IsWithinDist3d(m_targets.GetDst(), max_range)) + if (!m_caster->IsWithinDist3d(m_targets.GetDstPos(), max_range)) return SPELL_FAILED_OUT_OF_RANGE; - if (min_range && m_caster->IsWithinDist3d(m_targets.GetDst(), min_range)) + if (min_range && m_caster->IsWithinDist3d(m_targets.GetDstPos(), min_range)) return SPELL_FAILED_TOO_CLOSE; } @@ -6431,6 +6430,30 @@ void Spell::UpdatePointers() m_CastItem = m_caster->ToPlayer()->GetItemByGuid(m_castItemGUID); m_targets.Update(m_caster); + + // further actions done only for dest targets + if (!m_targets.HasDst()) + return; + + // cache last transport + WorldObject* transport = NULL; + + // update effect destinations (in case of moved transport dest target) + for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex) + { + SpellDestination& dest = m_destTargets[effIndex]; + if (!dest._transportGUID) + continue; + + if (!transport || transport->GetGUID() != dest._transportGUID) + transport = ObjectAccessor::GetWorldObject(*m_caster, dest._transportGUID); + + if (transport) + { + dest._position.Relocate(transport); + dest._position.RelocateOffset(dest._transportOffset); + } + } } CurrentSpellTypes Spell::GetCurrentContainer() const diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 971bc1989ab..f897092e519 100755 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -79,6 +79,18 @@ enum SpellRangeFlag SPELL_RANGE_RANGED = 2, //hunter range and ranged weapon }; +struct SpellDestination +{ + SpellDestination(); + SpellDestination(float x, float y, float z, float orientation = 0.0f, uint32 mapId = MAPID_INVALID); + SpellDestination(Position const& pos); + SpellDestination(WorldObject const& wObj); + + WorldLocation _position; + uint64 _transportGUID; + Position _transportOffset; +}; + class SpellCastTargets { public: @@ -115,14 +127,16 @@ class SpellCastTargets void SetTradeItemTarget(Player* caster); void UpdateTradeSlotItem(); - Position const* GetSrc() const; + SpellDestination const* GetSrc() const; + Position const* GetSrcPos() const; void SetSrc(float x, float y, float z); void SetSrc(Position const& pos); void SetSrc(WorldObject const& wObj); void ModSrc(Position const& pos); void RemoveSrc(); - WorldLocation const* GetDst() const; + SpellDestination const* GetDst() const; + WorldLocation const* GetDstPos() const; void SetDst(float x, float y, float z, float orientation, uint32 mapId = MAPID_INVALID); void SetDst(Position const& pos); void SetDst(WorldObject const& wObj); @@ -139,7 +153,7 @@ class SpellCastTargets float GetSpeed() const { return m_speed; } void SetSpeed(float speed) { m_speed = speed; } - float GetDist2d() const { return m_srcPos.GetExactDist2d(&m_dstPos); } + float GetDist2d() const { return m_src._position.GetExactDist2d(&m_dst._position); } float GetSpeedXY() const { return m_speed * cos(m_elevation); } float GetSpeedZ() const { return m_speed * sin(m_elevation); } @@ -158,13 +172,8 @@ class SpellCastTargets uint64 m_itemTargetGUID; uint32 m_itemTargetEntry; - uint64 m_srcTransGUID; - Position m_srcTransOffset; - Position m_srcPos; - - uint64 m_dstTransGUID; - Position m_dstTransOffset; - WorldLocation m_dstPos; + SpellDestination m_src; + SpellDestination m_dst; float m_elevation, m_speed; std::string m_strTarget; @@ -197,11 +206,6 @@ enum SpellEffectHandleMode SPELL_EFFECT_HANDLE_HIT_TARGET, }; -namespace Trinity -{ - struct SpellNotifierCreatureAndPlayer; -} - class Spell { friend void Unit::SetCurrentCastedSpell(Spell* pSpell); @@ -529,6 +533,7 @@ class Spell Unit* unitTarget; Item* itemTarget; GameObject* gameObjTarget; + WorldLocation* destTarget; int32 damage; SpellEffectHandleMode effectHandleMode; // used in effects handlers @@ -589,10 +594,13 @@ class Spell }; std::list<ItemTargetInfo> m_UniqueItemInfo; + SpellDestination m_destTargets[MAX_SPELL_EFFECTS]; + void AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid = true); void AddGOTarget(GameObject* target, uint32 effectMask); - void AddGOTarget(uint64 goGUID, uint32 effectMask); void AddItemTarget(Item* item, uint32 effectMask); + void AddDestTarget(SpellDestination const& dest, uint32 effIndex); + void DoAllEffectOnTarget(TargetInfo* target); SpellMissInfo DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleAura); void DoTriggersOnSpellHit(Unit* unit, uint8 effMask); @@ -631,7 +639,6 @@ class Spell HitTriggerSpells m_hitTriggerSpells; // effect helpers - void GetSummonPosition(uint32 i, Position &pos, float radius = 0.0f, uint32 count = 0); void SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numSummons); void CalculateJumpSpeeds(uint8 i, float dist, float & speedxy, float & speedz); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 2f04099f86b..59b6d8971cf 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -800,7 +800,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) bp = 46585; if (m_targets.HasDst()) - targets.SetDst(*m_targets.GetDst()); + targets.SetDst(*m_targets.GetDstPos()); else { targets.SetDst(*m_caster); @@ -814,8 +814,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) // Raise dead - take reagents and trigger summon spells case 48289: if (m_targets.HasDst()) - targets.SetDst(*m_targets.GetDst()); - + targets.SetDst(*m_targets.GetDstPos()); spell_id = CalculateDamage(0, NULL); break; } @@ -1177,7 +1176,7 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex) // Init dest coordinates float x, y, z; - m_targets.GetDst()->GetPosition(x, y, z); + destTarget->GetPosition(x, y, z); float speedXY, speedZ; CalculateJumpSpeeds(effIndex, m_caster->GetExactDist2d(x, y), speedXY, speedZ); @@ -1250,11 +1249,11 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/) } // Init dest coordinates - uint32 mapid = m_targets.GetDst()->GetMapId(); + uint32 mapid = destTarget->GetMapId(); if (mapid == MAPID_INVALID) mapid = unitTarget->GetMapId(); float x, y, z, orientation; - m_targets.GetDst()->GetPosition(x, y, z, orientation); + destTarget->GetPosition(x, y, z, orientation); if (!orientation && m_targets.GetUnitTarget()) orientation = m_targets.GetUnitTarget()->GetOrientation(); sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Spell::EffectTeleportUnits - teleport unit to %u %f %f %f %f\n", mapid, x, y, z, orientation); @@ -1883,7 +1882,7 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex) if (!caster->IsInWorld()) return; DynamicObject* dynObj = new DynamicObject(false); - if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, *m_targets.GetDst(), radius, DYNAMIC_OBJECT_AREA_SPELL)) + if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, *destTarget, radius, DYNAMIC_OBJECT_AREA_SPELL)) { delete dynObj; return; @@ -2357,9 +2356,6 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) if (Player* modOwner = m_originalCaster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration); - Position pos; - GetSummonPosition(effIndex, pos); - TempSummon* summon = NULL; // determine how many units should be summoned @@ -2413,11 +2409,11 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) // Summons a vehicle, but doesn't force anyone to enter it (see SUMMON_CATEGORY_VEHICLE) case SUMMON_TYPE_VEHICLE: case SUMMON_TYPE_VEHICLE2: - summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, m_spellInfo->Id); + summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id); break; case SUMMON_TYPE_TOTEM: { - summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, m_spellInfo->Id); + summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id); if (!summon || !summon->isTotem()) return; @@ -2434,12 +2430,12 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) } case SUMMON_TYPE_MINIPET: { - summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, m_spellInfo->Id); + summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id); if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION)) return; - summon->SelectLevel(summon->GetCreatureInfo()); // some summoned creaters have different from 1 DB data for level/hp - summon->SetUInt32Value(UNIT_NPC_FLAGS, summon->GetCreatureInfo()->npcflag); + summon->SelectLevel(summon->GetCreatureTemplate()); // some summoned creaters have different from 1 DB data for level/hp + summon->SetUInt32Value(UNIT_NPC_FLAGS, summon->GetCreatureTemplate()->npcflag); summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC); @@ -2454,9 +2450,14 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) for (uint32 count = 0; count < numSummons; ++count) { - GetSummonPosition(effIndex, pos, radius, count); + Position pos; + if (count == 0) + pos = *destTarget; + else + // randomize position for multiple summons + m_caster->GetRandomPoint(*destTarget, radius, pos); - summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration); + summon = m_originalCaster->SummonCreature(entry, *destTarget, summonType, duration); if (!summon) continue; @@ -2477,14 +2478,14 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) SummonGuardian(effIndex, entry, properties, numSummons); break; case SUMMON_CATEGORY_PUPPET: - summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, m_spellInfo->Id); + summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id); break; case SUMMON_CATEGORY_VEHICLE: // Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker // to cast a ride vehicle spell on the summoned unit. float x, y, z; m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); - summon = m_originalCaster->GetMap()->SummonCreature(entry, pos, properties, duration, m_caster, m_spellInfo->Id); + summon = m_originalCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_caster, m_spellInfo->Id); if (!summon || !summon->IsVehicle()) return; @@ -2706,7 +2707,7 @@ void Spell::EffectDistract(SpellEffIndex /*effIndex*/) if (unitTarget->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING)) return; - unitTarget->SetFacingTo(unitTarget->GetAngle(m_targets.GetDst())); + unitTarget->SetFacingTo(unitTarget->GetAngle(destTarget)); unitTarget->ClearUnitState(UNIT_STATE_MOVING); if (unitTarget->GetTypeId() == TYPEID_UNIT) @@ -2745,7 +2746,7 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex) return; DynamicObject* dynObj = new DynamicObject(true); - if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, *m_targets.GetDst(), radius, DYNAMIC_OBJECT_FARSIGHT_FOCUS)) + if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, *destTarget, radius, DYNAMIC_OBJECT_FARSIGHT_FOCUS)) { delete dynObj; return; @@ -3689,7 +3690,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) float x, y, z; if (m_targets.HasDst()) - m_targets.GetDst()->GetPosition(x, y, z); + destTarget->GetPosition(x, y, z); else m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); @@ -4232,7 +4233,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) float radius = m_spellInfo->Effects[effIndex].CalcRadius(); for (uint8 i = 0; i < 15; ++i) { - m_caster->GetRandomPoint(*m_targets.GetDst(), radius, x, y, z); + m_caster->GetRandomPoint(*destTarget, radius, x, y, z); m_caster->CastSpell(x, y, z, 54522, true); } break; @@ -5268,7 +5269,7 @@ void Spell::EffectSummonObject(SpellEffIndex effIndex) float x, y, z; // If dest location if present if (m_targets.HasDst()) - m_targets.GetDst()->GetPosition(x, y, z); + destTarget->GetPosition(x, y, z); // Summon in random point all other units if location present else m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); @@ -5398,7 +5399,7 @@ void Spell::EffectLeap(SpellEffIndex /*effIndex*/) return; Position pos; - m_targets.GetDst()->GetPosition(&pos); + destTarget->GetPosition(&pos); unitTarget->GetFirstCollisionPosition(pos, unitTarget->GetDistance(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + 2.0f), 0.0f); unitTarget->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), unitTarget == m_caster); } @@ -5521,7 +5522,7 @@ void Spell::EffectSkinning(SpellEffIndex /*effIndex*/) Creature* creature = unitTarget->ToCreature(); int32 targetLevel = creature->getLevel(); - uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); + uint32 skill = creature->GetCreatureTemplate()->GetRequiredLootSkill(); m_caster->ToPlayer()->SendLoot(creature->GetGUID(), LOOT_SKINNING); creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); @@ -5569,7 +5570,7 @@ void Spell::EffectChargeDest(SpellEffIndex /*effIndex*/) if (m_targets.HasDst()) { Position pos; - m_targets.GetDst()->GetPosition(&pos); + destTarget->GetPosition(&pos); float angle = m_caster->GetRelativeAngle(pos.GetPositionX(), pos.GetPositionY()); float dist = m_caster->GetDistance(pos); m_caster->GetFirstCollisionPosition(pos, dist, angle); @@ -5620,7 +5621,7 @@ void Spell::EffectKnockBack(SpellEffIndex effIndex) if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_KNOCK_BACK_DEST) { if (m_targets.HasDst()) - m_targets.GetDst()->GetPosition(x, y); + destTarget->GetPosition(x, y); else return; } @@ -5708,7 +5709,7 @@ void Spell::EffectPullTowards(SpellEffIndex effIndex) if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_PULL_TOWARDS_DEST) { if (m_targets.HasDst()) - pos.Relocate(*m_targets.GetDst()); + pos.Relocate(*destTarget); else return; } @@ -5895,7 +5896,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) float fx, fy, fz; if (m_targets.HasDst()) - m_targets.GetDst()->GetPosition(fx, fy, fz); + destTarget->GetPosition(fx, fy, fz); //FIXME: this can be better check for most objects but still hack else if (m_spellInfo->Effects[effIndex].HasRadius() && m_spellInfo->Speed == 0) { @@ -6476,7 +6477,11 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* for (uint32 count = 0; count < numGuardians; ++count) { Position pos; - GetSummonPosition(i, pos, radius, count); + if (count == 0) + pos = *destTarget; + else + // randomize position for multiple summons + m_caster->GetRandomPoint(*destTarget, radius, pos); TempSummon* summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id); if (!summon) @@ -6507,44 +6512,6 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* } } -void Spell::GetSummonPosition(uint32 i, Position &pos, float radius, uint32 count) -{ - pos.SetOrientation(m_caster->GetOrientation()); - - if (m_targets.HasDst()) - { - // Summon 1 unit in dest location - if (count == 0) - pos.Relocate(*m_targets.GetDst()); - // Summon in random point all other units if location present - else - { - //This is a workaround. Do not have time to write much about it - switch (m_spellInfo->Effects[i].TargetA.GetTarget()) - { - case TARGET_DEST_CASTER_SUMMON: - case TARGET_DEST_CASTER_RANDOM: - m_caster->GetNearPosition(pos, radius * (float)rand_norm(), (float)rand_norm()*static_cast<float>(2*M_PI)); - break; - case TARGET_DEST_DEST_RANDOM: - case TARGET_DEST_TARGET_RANDOM: - m_caster->GetRandomPoint(*m_targets.GetDst(), radius, pos); - break; - default: - pos.Relocate(*m_targets.GetDst()); - break; - } - } - } - // Summon if dest location not present near caster - else - { - float x, y, z; - m_caster->GetClosePoint(x, y, z, 3.0f); - pos.Relocate(x, y, z); - } -} - void Spell::EffectRenamePet(SpellEffIndex /*effIndex*/) { if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 626e0a3653e..b95ee766f38 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -99,7 +99,7 @@ float SpellImplicitTargetInfo::CalcDirectionAngle() const case TARGET_DIR_LEFT: return static_cast<float>(M_PI/2); case TARGET_DIR_FRONT_RIGHT: - return static_cast<float>(M_PI/4); + return static_cast<float>(-M_PI/4); case TARGET_DIR_BACK_RIGHT: return static_cast<float>(-3*M_PI/4); case TARGET_DIR_BACK_LEFT: @@ -614,7 +614,7 @@ SpellEffectInfo::StaticData SpellEffectInfo::_data[TOTAL_SPELL_EFFECTS] = {EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 66 SPELL_EFFECT_CREATE_MANA_GEM {EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 67 SPELL_EFFECT_HEAL_MAX_HEALTH {EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 68 SPELL_EFFECT_INTERRUPT_CAST - {EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 69 SPELL_EFFECT_DISTRACT + {EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT_AND_DEST}, // 69 SPELL_EFFECT_DISTRACT {EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 70 SPELL_EFFECT_PULL {EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 71 SPELL_EFFECT_PICKPOCKET {EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_DEST}, // 72 SPELL_EFFECT_ADD_FARSIGHT @@ -1192,7 +1192,6 @@ bool SpellInfo::IsAuraExclusiveBySpecificWith(SpellInfo const* spellInfo) const SpellSpecificType spellSpec2 = spellInfo->GetSpellSpecific(); switch (spellSpec1) { - case SPELL_SPECIFIC_PHASE: case SPELL_SPECIFIC_TRACKER: case SPELL_SPECIFIC_WARLOCK_ARMOR: case SPELL_SPECIFIC_MAGE_ARMOR: @@ -1911,8 +1910,6 @@ SpellSpecificType SpellInfo::GetSpellSpecific() const case SPELL_AURA_TRACK_RESOURCES: case SPELL_AURA_TRACK_STEALTHED: return SPELL_SPECIFIC_TRACKER; - case SPELL_AURA_PHASE: - return SPELL_SPECIFIC_PHASE; } } } diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 9c33db7f708..b82f7dbd61d 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -166,7 +166,6 @@ enum SpellSpecificType SPELL_SPECIFIC_WARRIOR_ENRAGE = 26, SPELL_SPECIFIC_PRIEST_DIVINE_SPIRIT = 27, SPELL_SPECIFIC_HAND = 28, - SPELL_SPECIFIC_PHASE = 29, }; enum SpellCustomAttributes diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index 03fea614c0d..81f8bbd78c5 100755 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -323,7 +323,7 @@ SpellInfo const* SpellScript::GetSpellInfo() WorldLocation const* SpellScript::GetTargetDest() { if (m_spell->m_targets.HasDst()) - return m_spell->m_targets.GetDst(); + return m_spell->m_targets.GetDstPos(); return NULL; } @@ -403,6 +403,16 @@ GameObject* SpellScript::GetHitGObj() return m_spell->gameObjTarget; } +WorldLocation const* SpellScript::GetHitDest() +{ + if (!IsInEffectHook()) + { + sLog->outError("TSCR: Script: `%s` Spell: `%u`: function SpellScript::GetHitGObj was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId); + return NULL; + } + return m_spell->destTarget; +} + int32 SpellScript::GetHitDamage() { if (!IsInTargetHook()) @@ -468,11 +478,6 @@ void SpellScript::PreventHitAura() m_spell->m_spellAura->Remove(); } -void SpellScript::GetSummonPosition(uint32 i, Position &pos, float radius = 0.0f, uint32 count = 0) -{ - m_spell->GetSummonPosition(i, pos, radius, count); -} - void SpellScript::PreventHitEffect(SpellEffIndex effIndex) { if (!IsInHitPhase() && !IsInEffectHook()) diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index 1bf8d25adef..e84a56c8dbb 100755 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -324,6 +324,8 @@ class SpellScript : public _SpellScript Item* GetHitItem(); // returns: target of current effect if it was GameObject otherwise NULL GameObject* GetHitGObj(); + // returns: destination of current effect + WorldLocation const* GetHitDest(); // setter/getter for for damage done by spell to target of spell hit // returns damage calculated before hit, and real dmg done after hit int32 GetHitDamage(); @@ -335,7 +337,6 @@ class SpellScript : public _SpellScript void SetHitHeal(int32 heal); void PreventHitHeal() { SetHitHeal(0); } Spell* GetSpell() { return m_spell; } - void GetSummonPosition(uint32 i, Position &pos, float radius, uint32 count); // returns current spell hit target aura Aura* GetHitAura(); // prevents applying aura on current spell hit target diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index e5a12693aa7..f1088f54007 100755 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -17,8 +17,53 @@ #include "Common.h" #include "DatabaseEnv.h" -#include "CreatureTextMgr.h" #include "ObjectMgr.h" +#include "Cell.h" +#include "CellImpl.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" +#include "CreatureTextMgr.h" + +class CreatureTextBuilder +{ + public: + CreatureTextBuilder(WorldObject* obj, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, uint64 targetGUID) + : _source(obj), _msgType(msgtype), _textGroup(textGroup), _textId(id), _language(language), _targetGUID(targetGUID) + { + } + + size_t operator()(WorldPacket* data, LocaleConstant locale) const + { + std::string text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale); + char const* localizedName = _source->GetNameForLocaleIdx(locale); + + *data << uint8(_msgType); + *data << uint32(_language); + *data << uint64(_source->GetGUID()); + *data << uint32(1); // 2.1.0 + *data << uint32(strlen(localizedName)+1); + *data << localizedName; + size_t whisperGUIDpos = data->wpos(); + *data << uint64(_targetGUID); // Unit Target + if (_targetGUID && !IS_PLAYER_GUID(_targetGUID)) + { + *data << uint32(1); // target name length + *data << uint8(0); // target name + } + *data << uint32(text.length() + 1); + *data << text; + *data << uint8(0); // ChatTag + + return whisperGUIDpos; + } + + WorldObject* _source; + ChatMsg _msgType; + uint8 _textGroup; + uint32 _textId; + uint32 _language; + uint64 _targetGUID; +}; void CreatureTextMgr::LoadCreatureTexts() { @@ -83,17 +128,8 @@ void CreatureTextMgr::LoadCreatureTexts() } //entry not yet added, add empty TextHolder (list of groups) if (mTextMap.find(temp.entry) == mTextMap.end()) - { ++creatureCount; - CreatureTextHolder TextHolder; - mTextMap[temp.entry] = TextHolder; - } - //group not yet added, add empty TextGroup (list of texts) - if (mTextMap[temp.entry].find(temp.group) == mTextMap[temp.entry].end()) - { - CreatureTextGroup TextGroup; - mTextMap[temp.entry][temp.group] = TextGroup; - } + //add the text into our entry's group mTextMap[temp.entry][temp.group].push_back(temp); @@ -104,42 +140,76 @@ void CreatureTextMgr::LoadCreatureTexts() sLog->outString(); } +void CreatureTextMgr::LoadCreatureTextLocales() +{ + uint32 oldMSTime = getMSTime(); + + mLocaleTextMap.clear(); // for reload case + + QueryResult result = WorldDatabase.Query("SELECT entry, textGroup, id, text_loc1, text_loc2, text_loc3, text_loc4, text_loc5, text_loc6, text_loc7, text_loc8 FROM locales_creature_text"); + + if (!result) + return; + + uint32 textCount = 0; + + do + { + Field* fields = result->Fetch(); + CreatureTextLocale& loc = mLocaleTextMap[CreatureTextId(fields[0].GetUInt32(), uint32(fields[1].GetUInt8()), fields[2].GetUInt32())]; + for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + { + LocaleConstant locale = LocaleConstant(i); + ObjectMgr::AddLocaleString(fields[2 + i - 1].GetString(), locale, loc.Text); + } + + ++textCount; + } while (result->NextRow()); + + sLog->outString(">> Loaded %u creature localized texts in %u ms", textCount, GetMSTimeDiffToNow(oldMSTime)); + sLog->outString(); +} + uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid /*= 0*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, TextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, Player* srcPlr /*= NULL*/) { if (!source) return 0; + CreatureTextMap::const_iterator sList = mTextMap.find(source->GetEntry()); if (sList == mTextMap.end()) { sLog->outErrorDb("CreatureTextMgr: Could not find Text for Creature(%s) Entry %u in 'creature_text' table. Ignoring.", source->GetName(), source->GetEntry()); return 0; } - CreatureTextHolder TextHolder = (*sList).second; - CreatureTextHolder::const_iterator itr = TextHolder.find(textGroup); - if (itr == TextHolder.end()) + + CreatureTextHolder const& textHolder = sList->second; + CreatureTextHolder::const_iterator itr = textHolder.find(textGroup); + if (itr == textHolder.end()) { sLog->outErrorDb("CreatureTextMgr: Could not find TextGroup %u for Creature(%s) GuidLow %u Entry %u. Ignoring.", uint32(textGroup), source->GetName(), source->GetGUIDLow(), source->GetEntry()); return 0; } - CreatureTextGroup TextGroup = (*itr).second;//has all texts in the group + + CreatureTextGroup const& textGroupContainer = itr->second; //has all texts in the group CreatureTextRepeatIds repeatGroup = GetRepeatGroup(source, textGroup);//has all textIDs from the group that were already said CreatureTextGroup tempGroup;//will use this to talk after sorting repeatGroup - for (CreatureTextGroup::const_iterator giter = TextGroup.begin(); giter != TextGroup.end(); ++giter) - { - if (std::find(repeatGroup.begin(), repeatGroup.end(), (*giter).id) == repeatGroup.end()) - tempGroup.push_back((*giter)); - } + for (CreatureTextGroup::const_iterator giter = textGroupContainer.begin(); giter != textGroupContainer.end(); ++giter) + if (std::find(repeatGroup.begin(), repeatGroup.end(), giter->id) == repeatGroup.end()) + tempGroup.push_back(*giter); + if (tempGroup.empty()) { CreatureTextRepeatMap::iterator mapItr = mTextRepeatMap.find(source->GetGUID()); if (mapItr != mTextRepeatMap.end()) { - CreatureTextRepeatGroup::iterator groupItr = (*mapItr).second.find(textGroup); - (*groupItr).second.clear(); + CreatureTextRepeatGroup::iterator groupItr = mapItr->second.find(textGroup); + groupItr->second.clear(); } - tempGroup = TextGroup; + + tempGroup = textGroupContainer; } + uint8 count = 0; float lastChance = -1; bool isEqualChanced = true; @@ -148,173 +218,92 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisp for (CreatureTextGroup::const_iterator iter = tempGroup.begin(); iter != tempGroup.end(); ++iter) { - if (lastChance >= 0 && lastChance != (*iter).probability) + if (lastChance >= 0 && lastChance != iter->probability) isEqualChanced = false; - lastChance = (*iter).probability; - totalChance += (*iter).probability; - count++; + lastChance = iter->probability; + totalChance += iter->probability; + ++count; } + int32 offset = -1; if (!isEqualChanced) { for (CreatureTextGroup::const_iterator iter = tempGroup.begin(); iter != tempGroup.end(); ++iter) { - uint32 chance = uint32((*iter).probability); + uint32 chance = uint32(iter->probability); uint32 r = urand(0, 100); - offset++; + ++offset; if (r <= chance) break; } } + uint32 pos = 0; if (isEqualChanced || offset < 0) pos = urand(0, count - 1); else if (offset >= 0) pos = offset; + CreatureTextGroup::const_iterator iter = tempGroup.begin() + pos; - ChatMsg finalType = (msgType == CHAT_MSG_ADDON) ? (*iter).type : msgType; - Language finalLang = (language == LANG_ADDON) ? (*iter).lang : language; - uint32 finalSound = sound ? sound : (*iter).sound; + ChatMsg finalType = (msgType == CHAT_MSG_ADDON) ? iter->type : msgType; + Language finalLang = (language == LANG_ADDON) ? iter->lang : language; + uint32 finalSound = sound ? sound : iter->sound; if (finalSound) SendSound(source, finalSound, finalType, whisperGuid, range, team, gmOnly); - if ((*iter).emote) - SendEmote(srcPlr ? srcPlr->ToUnit() : source, (*iter).emote); - - SendChatString(srcPlr ? srcPlr->ToUnit() : source, (*iter).text.c_str(), finalType, finalLang, whisperGuid, range, team, gmOnly); - if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f)) - SetRepeatId(source, textGroup, (*iter).id); - - return (*iter).duration; -} - -void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) -{ - if (!sound || !source) - return; - WorldPacket data(SMSG_PLAY_SOUND, 4); - data << uint32(sound); - SendChatPacket(&data, source, msgType, whisperGuid, range, team, gmOnly); -} - -void CreatureTextMgr::SendEmote(Unit* source, uint32 emote) -{ - if (!source) return; - source->HandleEmoteCommand(emote); -} - -void CreatureTextMgr::SetRepeatId(Creature* source, uint8 textGroup, uint8 id) -{ - if (!source) - return; - - if (mTextRepeatMap.find(source->GetGUID()) == mTextRepeatMap.end()) - { - CreatureTextRepeatGroup TextGroup; - mTextRepeatMap[source->GetGUID()] = TextGroup; - } - if (mTextRepeatMap[source->GetGUID()].find(textGroup) == mTextRepeatMap[source->GetGUID()].end()) - { - CreatureTextRepeatIds ids; - mTextRepeatMap[source->GetGUID()][textGroup] = ids; - } - if (std::find(mTextRepeatMap[source->GetGUID()][textGroup].begin(), mTextRepeatMap[source->GetGUID()][textGroup].end(), id) == mTextRepeatMap[source->GetGUID()][textGroup].end()) - { - mTextRepeatMap[source->GetGUID()][textGroup].push_back(id); - } - else - sLog->outErrorDb("CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), source->GetName(), source->GetGUIDLow(), source->GetEntry(), uint32(id)); -} - -CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 textGroup) -{ - ASSERT(source);//should never happen - CreatureTextRepeatIds ids; + Unit* finalSource = source; + if (srcPlr) + finalSource = srcPlr; - CreatureTextRepeatMap::const_iterator mapItr = mTextRepeatMap.find(source->GetGUID()); - if (mapItr != mTextRepeatMap.end()) - { - CreatureTextRepeatGroup::const_iterator groupItr = (*mapItr).second.find(textGroup); - if (groupItr != (*mapItr).second.end()) - { - ids = (*groupItr).second; - } - } - return ids; -} + if (iter->emote) + SendEmote(finalSource, iter->emote); -void CreatureTextMgr::SendChatString(WorldObject* source, char const* text, ChatMsg msgtype /*= CHAT_MSG_MONSTER_SAY*/, Language language /*= LANG_UNIVERSAL*/, uint64 whisperGuid /*= 0*/, TextRange range /*= TEXT_RANGE_NORMAL*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/) const -{ - if (!source) - return; + CreatureTextBuilder builder(finalSource, finalType, iter->group, iter->id, finalLang, whisperGuid); + SendChatPacket(finalSource, builder, finalType, whisperGuid, range, team, gmOnly); + if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f)) + SetRepeatId(source, textGroup, iter->id); - WorldPacket data(SMSG_MESSAGECHAT, 200); - BuildMonsterChat(&data, source, msgtype, text, language, whisperGuid);//build our packet - SendChatPacket(&data, source, msgtype, whisperGuid, range, team, gmOnly);//send our packet + return iter->duration; } -void CreatureTextMgr::BuildMonsterChat(WorldPacket* data, WorldObject* source, ChatMsg msgType, char const* text, Language language, uint64 whisperGuid) const +float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType) const { - if (!source) - return; - + float dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY); switch (msgType) { - case CHAT_MSG_MONSTER_WHISPER: - if (!whisperGuid) - { - sLog->outError("CreatureTextMgr: WorldObject(%s) TypeId %u GuidLow %u sent CHAT_TYPE_WHISPER with targetGuid 0. Ignoring.", source->GetName(), uint32(source->GetTypeId()), source->GetGUIDLow()); - return; - } + case CHAT_MSG_MONSTER_YELL: + dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL); break; - case CHAT_MSG_RAID_BOSS_WHISPER: - if (!whisperGuid) - { - sLog->outError("CreatureTextMgr: WorldObject(%s) TypeId %u GuidLow %u sent CHAT_TYPE_BOSS_WHISPER with targetGuid 0. Ignoring.", source->GetName(), uint32(source->GetTypeId()), source->GetGUIDLow()); - return; - } + case CHAT_MSG_MONSTER_EMOTE: + case CHAT_MSG_RAID_BOSS_EMOTE: + dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE); break; default: break; } - *data << uint8(msgType); - *data << uint32(language); - *data << uint64(source->GetGUID()); - *data << uint32(0); // 2.1.0 - *data << uint32(strlen(source->GetName()) + 1); - *data << source->GetName(); - *data << uint64(whisperGuid); // Unit Target - if (whisperGuid && !IS_PLAYER_GUID(whisperGuid)) //can only whisper players - { - sLog->outError("CreatureTextMgr: WorldObject(%s) TypeId %u GuidLow %u sent WHISPER msg to Non-Player target. Ignoring.", source->GetName(), uint32(source->GetTypeId()), source->GetGUIDLow()); - return; - // *data << (uint32)1; // target name length - // *data << (uint8)0; // target name - } - *data << uint32(strlen(text) + 1); - *data << text; - *data << uint8(0); // ChatTag + + return dist; } -void CreatureTextMgr::SendChatPacket(WorldPacket* data, WorldObject* source, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const +void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) { - if (!source) + if (!sound || !source) return; - float dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY); + WorldPacket data(SMSG_PLAY_SOUND, 4); + data << uint32(sound); + SendNonChatPacket(source, &data, msgType, whisperGuid, range, team, gmOnly); +} + +void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const +{ + float dist = GetRangeForChatType(msgType); switch (msgType) { - case CHAT_MSG_MONSTER_YELL: - dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL); - break; - case CHAT_MSG_MONSTER_EMOTE: - case CHAT_MSG_RAID_BOSS_EMOTE: - dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE); - break; case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: { @@ -337,83 +326,135 @@ void CreatureTextMgr::SendChatPacket(WorldPacket* data, WorldObject* source, Cha case TEXT_RANGE_AREA: { uint32 areaId = source->GetAreaId(); - Map::PlayerList const& pList = source->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) - { + Map::PlayerList const& players = source->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) if (itr->getSource()->GetAreaId() == areaId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster())) - { - if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid - data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID())); - (itr->getSource())->GetSession()->SendPacket(data); - } - } + itr->getSource()->GetSession()->SendPacket(data); return; } case TEXT_RANGE_ZONE: { uint32 zoneId = source->GetZoneId(); - Map::PlayerList const& pList = source->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) - { + Map::PlayerList const& players = source->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) if (itr->getSource()->GetZoneId() == zoneId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster())) - { - if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid - data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID())); - (itr->getSource())->GetSession()->SendPacket(data); - } - } + itr->getSource()->GetSession()->SendPacket(data); return; } case TEXT_RANGE_MAP: { - Map::PlayerList const& pList = source->GetMap()->GetPlayers(); - for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) - { - if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid - data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID())); + Map::PlayerList const& players = source->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) if ((!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster())) - (itr->getSource())->GetSession()->SendPacket(data); - } + itr->getSource()->GetSession()->SendPacket(data); return; } case TEXT_RANGE_WORLD: { - const SessionMap smap = sWorld->GetAllSessions(); + SessionMap const& smap = sWorld->GetAllSessions(); for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) - { - if (Player* player = (*iter).second->GetPlayer()) - { - if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid - data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(player->GetGUID())); + if (Player* player = iter->second->GetPlayer()) if (player->GetSession() && (!team || Team(player->GetTeam()) == team) && (!gmOnly || player->isGameMaster())) player->GetSession()->SendPacket(data); - } - } return; } case TEXT_RANGE_NORMAL: default: break; } + source->SendMessageToSetInRange(data, dist, true); } +void CreatureTextMgr::SendEmote(Unit* source, uint32 emote) +{ + if (!source) + return; + + source->HandleEmoteCommand(emote); +} + +void CreatureTextMgr::SetRepeatId(Creature* source, uint8 textGroup, uint8 id) +{ + if (!source) + return; + + CreatureTextRepeatIds& repeats = mTextRepeatMap[source->GetGUID()][textGroup]; + if (std::find(repeats.begin(), repeats.end(), id) == repeats.end()) + repeats.push_back(id); + else + sLog->outErrorDb("CreatureTextMgr: TextGroup %u for Creature(%s) GuidLow %u Entry %u, id %u already added", uint32(textGroup), source->GetName(), source->GetGUIDLow(), source->GetEntry(), uint32(id)); +} + +CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 textGroup) +{ + ASSERT(source);//should never happen + CreatureTextRepeatIds ids; + + CreatureTextRepeatMap::const_iterator mapItr = mTextRepeatMap.find(source->GetGUID()); + if (mapItr != mTextRepeatMap.end()) + { + CreatureTextRepeatGroup::const_iterator groupItr = (*mapItr).second.find(textGroup); + if (groupItr != mapItr->second.end()) + ids = groupItr->second; + } + return ids; +} + bool CreatureTextMgr::TextExist(uint32 sourceEntry, uint8 textGroup) { if (!sourceEntry) return false; + CreatureTextMap::const_iterator sList = mTextMap.find(sourceEntry); if (sList == mTextMap.end()) { sLog->outDebug(LOG_FILTER_UNITS, "CreatureTextMgr::TextExist: Could not find Text for Creature (entry %u) in 'creature_text' table.", sourceEntry); return false; } - CreatureTextHolder TextHolder = (*sList).second; - CreatureTextHolder::const_iterator itr = TextHolder.find(textGroup); - if (itr == TextHolder.end()) + + CreatureTextHolder const& textHolder = sList->second; + CreatureTextHolder::const_iterator itr = textHolder.find(textGroup); + if (itr == textHolder.end()) { sLog->outDebug(LOG_FILTER_UNITS, "CreatureTextMgr::TextExist: Could not find TextGroup %u for Creature (entry %u).", uint32(textGroup), sourceEntry); return false; } + return true; } + +std::string CreatureTextMgr::GetLocalizedChatString(uint32 entry, uint8 textGroup, uint32 id, LocaleConstant locale) const +{ + CreatureTextMap::const_iterator mapitr = mTextMap.find(entry); + if (mapitr == mTextMap.end()) + return ""; + + CreatureTextHolder::const_iterator holderItr = mapitr->second.find(textGroup); + if (holderItr == mapitr->second.end()) + return ""; + + CreatureTextGroup::const_iterator groupItr = holderItr->second.begin(); + for (; groupItr != holderItr->second.end(); ++groupItr) + if (groupItr->id == id) + break; + + if (groupItr == holderItr->second.end()) + return ""; + + std::string baseText = groupItr->text; + if (locale == DEFAULT_LOCALE) + return baseText; + + if (locale > MAX_LOCALES) + return baseText; + + LocaleCreatureTextMap::const_iterator locItr = mLocaleTextMap.find(CreatureTextId(entry, uint32(textGroup), id)); + if (locItr == mLocaleTextMap.end()) + return baseText; + + if (locItr->second.Text[locale].length()) + return locItr->second.Text[locale]; + + return baseText; +} diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h index 0c80e2d568f..ddf10568411 100755 --- a/src/server/game/Texts/CreatureTextMgr.h +++ b/src/server/game/Texts/CreatureTextMgr.h @@ -19,6 +19,8 @@ #define TRINITY_CREATURE_TEXT_MGR_H #include "Creature.h" +#include "GridNotifiers.h" +#include "ObjectAccessor.h" #include "SharedDefines.h" struct CreatureTextEntry @@ -44,10 +46,33 @@ enum TextRange TEXT_RANGE_WORLD = 4 }; +struct CreatureTextLocale +{ + StringVector Text; +}; + +struct CreatureTextId +{ + CreatureTextId(uint32 e, uint32 g, uint32 i) : entry(e), textGroup(g), textId(i) + { + } + + bool operator<(CreatureTextId const& right) const + { + return memcmp(this, &right, sizeof(CreatureTextId)) < 0; + } + + uint32 entry; + uint32 textGroup; + uint32 textId; +}; + typedef std::vector<CreatureTextEntry> CreatureTextGroup; //texts in a group typedef UNORDERED_MAP<uint8, CreatureTextGroup> CreatureTextHolder; //groups for a creature by groupid typedef UNORDERED_MAP<uint32, CreatureTextHolder> CreatureTextMap; //all creatures by entry +typedef std::map<CreatureTextId, CreatureTextLocale> LocaleCreatureTextMap; + //used for handling non-repeatable random texts typedef std::vector<uint8> CreatureTextRepeatIds; typedef UNORDERED_MAP<uint8, CreatureTextRepeatIds> CreatureTextRepeatGroup; @@ -57,9 +82,11 @@ class CreatureTextMgr { friend class ACE_Singleton<CreatureTextMgr, ACE_Null_Mutex>; CreatureTextMgr() {}; + public: ~CreatureTextMgr() {}; void LoadCreatureTexts(); + void LoadCreatureTextLocales(); CreatureTextMap const& GetTextMap() const { return mTextMap; } void SendSound(Creature* source, uint32 sound, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly); @@ -67,17 +94,154 @@ class CreatureTextMgr //if sent, returns the 'duration' of the text else 0 if error uint32 SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid = 0, ChatMsg msgType = CHAT_MSG_ADDON, Language language = LANG_ADDON, TextRange range = TEXT_RANGE_NORMAL, uint32 sound = 0, Team team = TEAM_OTHER, bool gmOnly = false, Player* srcPlr = NULL); - void SendChatString(WorldObject* source, char const* text, ChatMsg msgtype = CHAT_MSG_MONSTER_SAY, Language language = LANG_UNIVERSAL, uint64 whisperGuid = 0, TextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false) const; bool TextExist(uint32 sourceEntry, uint8 textGroup); + std::string GetLocalizedChatString(uint32 entry, uint8 textGroup, uint32 id, LocaleConstant locale) const; + + template<class Builder> + void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, uint64 whisperGuid = 0, TextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false) const; private: CreatureTextRepeatIds GetRepeatGroup(Creature* source, uint8 textGroup); void SetRepeatId(Creature* source, uint8 textGroup, uint8 id); - void BuildMonsterChat(WorldPacket* data, WorldObject* source, ChatMsg msgType, char const* text, Language language, uint64 whisperGuid) const; - void SendChatPacket(WorldPacket* data, WorldObject* source, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const; + + void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const; + float GetRangeForChatType(ChatMsg msgType) const; CreatureTextMap mTextMap; CreatureTextRepeatMap mTextRepeatMap; + LocaleCreatureTextMap mLocaleTextMap; }; #define sCreatureTextMgr ACE_Singleton<CreatureTextMgr, ACE_Null_Mutex>::instance() + +template<class Builder> +class CreatureTextLocalizer +{ + public: + CreatureTextLocalizer(Builder const& builder, ChatMsg msgType) : _builder(builder), _msgType(msgType) + { + _packetCache.resize(TOTAL_LOCALES, NULL); + } + + ~CreatureTextLocalizer() + { + for (size_t i = 0; i < _packetCache.size(); ++i) + { + if (_packetCache[i]) + delete _packetCache[i]->first; + delete _packetCache[i]; + } + } + + void operator()(Player* player) + { + LocaleConstant loc_idx = player->GetSession()->GetSessionDbLocaleIndex(); + WorldPacket* messageTemplate; + size_t whisperGUIDpos; + + // create if not cached yet + if (!_packetCache[loc_idx]) + { + messageTemplate = new WorldPacket(SMSG_MESSAGECHAT, 200); + whisperGUIDpos = _builder(messageTemplate, loc_idx); + _packetCache[loc_idx] = new std::pair<WorldPacket*, size_t>(messageTemplate, whisperGUIDpos); + } + else + { + messageTemplate = _packetCache[loc_idx]->first; + whisperGUIDpos = _packetCache[loc_idx]->second; + } + + WorldPacket data(*messageTemplate); + switch (_msgType) + { + case CHAT_MSG_MONSTER_WHISPER: + case CHAT_MSG_RAID_BOSS_WHISPER: + data.put<uint64>(whisperGUIDpos, player->GetGUID()); + break; + } + + player->SendDirectMessage(&data); + } + + private: + std::vector<std::pair<WorldPacket*, size_t>* > _packetCache; + Builder const& _builder; + ChatMsg _msgType; +}; + +template<class Builder> +void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const +{ + if (!source) + return; + + CreatureTextLocalizer<Builder> localizer(builder, msgType); + + switch (msgType) + { + case CHAT_MSG_MONSTER_WHISPER: + case CHAT_MSG_RAID_BOSS_WHISPER: + { + if (range == TEXT_RANGE_NORMAL) //ignores team and gmOnly + { + Player* player = ObjectAccessor::FindPlayer(whisperGuid); + if (!player || !player->GetSession()) + return; + + localizer(player); + return; + } + break; + } + default: + break; + } + + switch (range) + { + case TEXT_RANGE_AREA: + { + uint32 areaId = source->GetAreaId(); + Map::PlayerList const& players = source->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + if (itr->getSource()->GetAreaId() == areaId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster())) + localizer(itr->getSource()); + return; + } + case TEXT_RANGE_ZONE: + { + uint32 zoneId = source->GetZoneId(); + Map::PlayerList const& players = source->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + if (itr->getSource()->GetZoneId() == zoneId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster())) + localizer(itr->getSource()); + return; + } + case TEXT_RANGE_MAP: + { + Map::PlayerList const& players = source->GetMap()->GetPlayers(); + for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + if ((!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster())) + localizer(itr->getSource()); + return; + } + case TEXT_RANGE_WORLD: + { + SessionMap const& smap = sWorld->GetAllSessions(); + for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) + if (Player* player = iter->second->GetPlayer()) + if (player->GetSession() && (!team || Team(player->GetTeam()) == team) && (!gmOnly || player->isGameMaster())) + localizer(player); + return; + } + case TEXT_RANGE_NORMAL: + default: + break; + } + + float dist = GetRangeForChatType(msgType); + Trinity::PlayerDistWorker<CreatureTextLocalizer<Builder> > worker(source, dist, localizer); + source->VisitNearbyWorldObject(dist, worker); +} + #endif diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index 3d625df63d0..f2fe3c4ad67 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -203,7 +203,7 @@ void WorldSession::HandleWardenDataOpcode(WorldPacket& recvData) _warden->DecryptData(const_cast<uint8*>(recvData.contents()), recvData.size()); uint8 opcode; recvData >> opcode; - sLog->outDebug(LOG_FILTER_WARDEN, "Got packet, opcode %02X, size %u", opcode, recvData.size()); + sLog->outDebug(LOG_FILTER_WARDEN, "Got packet, opcode %02X, size %u", opcode, uint32(recvData.size())); recvData.hexlike(); switch(opcode) @@ -228,7 +228,7 @@ void WorldSession::HandleWardenDataOpcode(WorldPacket& recvData) sLog->outDebug(LOG_FILTER_WARDEN, "NYI WARDEN_CMSG_MODULE_FAILED received!"); break; default: - sLog->outDebug(LOG_FILTER_WARDEN, "Got unknown warden opcode %02X of size %u.", opcode, recvData.size() - 1); + sLog->outDebug(LOG_FILTER_WARDEN, "Got unknown warden opcode %02X of size %u.", opcode, uint32(recvData.size() - 1)); break; } } diff --git a/src/server/game/Warden/WardenCheckMgr.cpp b/src/server/game/Warden/WardenCheckMgr.cpp index 29f29fe5b88..7567b3976db 100644 --- a/src/server/game/Warden/WardenCheckMgr.cpp +++ b/src/server/game/Warden/WardenCheckMgr.cpp @@ -25,7 +25,6 @@ #include "WardenCheckMgr.h" #include "Warden.h" - WardenCheckMgr::WardenCheckMgr() { } @@ -49,17 +48,6 @@ void WardenCheckMgr::LoadWardenChecks() return; } - // For reload case - for (uint16 i = 0; i < CheckStore.size(); ++i) - delete CheckStore[i]; - - CheckStore.clear(); - - for (CheckResultContainer::iterator itr = CheckResultStore.begin(); itr != CheckResultStore.end(); ++itr) - delete itr->second; - CheckResultStore.clear(); - - QueryResult result = WorldDatabase.Query("SELECT MAX(id) FROM warden_checks"); if (!result) @@ -166,13 +154,13 @@ void WardenCheckMgr::LoadWardenOverrides() return; } - Field* fields = result->Fetch(); - uint32 count = 0; + ACE_WRITE_GUARD(ACE_RW_Mutex, g, _checkStoreLock); + do { - fields = result->Fetch(); + Field* fields = result->Fetch(); uint16 checkId = fields[0].GetUInt16(); uint8 action = fields[1].GetUInt8(); diff --git a/src/server/game/Warden/WardenCheckMgr.h b/src/server/game/Warden/WardenCheckMgr.h index 1b790d16716..45de18081c2 100644 --- a/src/server/game/Warden/WardenCheckMgr.h +++ b/src/server/game/Warden/WardenCheckMgr.h @@ -64,6 +64,8 @@ class WardenCheckMgr void LoadWardenChecks(); void LoadWardenOverrides(); + ACE_RW_Mutex _checkStoreLock; + private: CheckContainer CheckStore; CheckResultContainer CheckResultStore; diff --git a/src/server/game/Warden/WardenWin.cpp b/src/server/game/Warden/WardenWin.cpp index 53d167082d6..3e028254f28 100644 --- a/src/server/game/Warden/WardenWin.cpp +++ b/src/server/game/Warden/WardenWin.cpp @@ -212,6 +212,8 @@ void WardenWin::RequestData() ByteBuffer buff; buff << uint8(WARDEN_SMSG_CHEAT_CHECKS_REQUEST); + ACE_READ_GUARD(ACE_RW_Mutex, g, sWardenCheckMgr->_checkStoreLock); + for (uint32 i = 0; i < sWorld->getIntConfig(CONFIG_WARDEN_NUM_OTHER_CHECKS); ++i) { // If todo list is done break loop (will be filled on next Update() run) @@ -377,6 +379,8 @@ void WardenWin::HandleData(ByteBuffer &buff) uint8 type; uint16 checkFailed = 0; + ACE_READ_GUARD(ACE_RW_Mutex, g, sWardenCheckMgr->_checkStoreLock); + for (std::list<uint16>::iterator itr = _currentChecks.begin(); itr != _currentChecks.end(); ++itr) { rd = sWardenCheckMgr->GetWardenDataById(*itr); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index fcdb6b7fcd6..3efa976e1d3 100755 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1651,6 +1651,9 @@ void World::SetInitialWorldSettings() sLog->outString("Loading Creature Texts..."); sCreatureTextMgr->LoadCreatureTexts(); + sLog->outString("Loading Creature Text Locales..."); + sCreatureTextMgr->LoadCreatureTextLocales(); + sLog->outString("Initializing Scripts..."); sScriptMgr->Initialize(); diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 8ca40231090..9646a881fc0 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -89,6 +89,7 @@ public: { "itemexpire", SEC_ADMINISTRATOR, false, &HandleDebugItemExpireCommand, "", NULL }, { "areatriggers", SEC_ADMINISTRATOR, false, &HandleDebugAreaTriggersCommand, "", NULL }, { "los", SEC_MODERATOR, false, &HandleDebugLoSCommand, "", NULL }, + { "moveflags", SEC_ADMINISTRATOR, false, &HandleDebugMoveflagsCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; static ChatCommand commandTable[] = @@ -1283,6 +1284,41 @@ public: handler->PSendSysMessage(LANG_SET_32BIT_FIELD, opcode, value); return true; } + + static bool HandleDebugMoveflagsCommand(ChatHandler* handler, char const* args) + { + Unit* target = handler->getSelectedUnit(); + if (!target) + target = handler->GetSession()->GetPlayer(); + + if (!*args) + { + //! Display case + handler->PSendSysMessage(LANG_MOVEFLAGS_GET, target->GetUnitMovementFlags(), target->GetExtraUnitMovementFlags()); + } + else + { + char* mask1 = strtok((char*)args, " "); + if (!mask1) + return false; + + char* mask2 = strtok(NULL, " \n"); + + uint32 moveFlags = (uint32)atoi(mask1); + target->SetUnitMovementFlags(moveFlags); + + if (mask2) + { + uint32 moveFlagsExtra = uint32(atoi(mask2)); + target->SetExtraUnitMovementFlags(moveFlagsExtra); + } + + target->SendMovementFlagUpdate(); + handler->PSendSysMessage(LANG_MOVEFLAGS_SET, target->GetUnitMovementFlags(), target->GetExtraUnitMovementFlags()); + } + + return true; + } }; void AddSC_debug_commandscript() diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index fcabaaa7e5b..ae573577d7e 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -248,7 +248,7 @@ public: return false; } - CreatureTemplate const* creatureInfo = pet->GetCreatureInfo(); + CreatureTemplate const* creatureInfo = pet->GetCreatureTemplate(); if (!creatureInfo) { handler->SendSysMessage(LANG_WRONG_PET_TYPE); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 57932ef56c6..67ac6f8ff76 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -462,7 +462,7 @@ public: // Faction is set in creature_template - not inside creature // Update in memory.. - if (CreatureTemplate const* cinfo = creature->GetCreatureInfo()) + if (CreatureTemplate const* cinfo = creature->GetCreatureTemplate()) { const_cast<CreatureTemplate*>(cinfo)->faction_A = factionId; const_cast<CreatureTemplate*>(cinfo)->faction_H = factionId; @@ -547,7 +547,7 @@ public: uint32 displayid = target->GetDisplayId(); uint32 nativeid = target->GetNativeDisplayId(); uint32 Entry = target->GetEntry(); - CreatureTemplate const* cInfo = target->GetCreatureInfo(); + CreatureTemplate const* cInfo = target->GetCreatureTemplate(); int64 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); if (curRespawnDelay < 0) @@ -1148,7 +1148,7 @@ public: return false; } - CreatureTemplate const* cInfo = creatureTarget->GetCreatureInfo(); + CreatureTemplate const* cInfo = creatureTarget->GetCreatureTemplate(); if (!cInfo->isTameable (player->CanTameExoticPets())) { diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 8f5e862555c..9249cb3fdbc 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -223,6 +223,7 @@ public: sWaypointMgr->ReloadPath(id); return true; } + static bool HandleWpUnLoadCommand(ChatHandler* handler, const char* /*args*/) { @@ -605,7 +606,7 @@ public: return false; } - if (show == "del" && target) + if (show == "del") { handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); @@ -615,9 +616,12 @@ public: if (wpGuid != 0) { wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - wpCreature->CombatStop(); - wpCreature->DeleteFromDB(); - wpCreature->AddObjectToRemoveList(); + if (wpCreature) + { + wpCreature->CombatStop(); + wpCreature->DeleteFromDB(); + wpCreature->AddObjectToRemoveList(); + } } PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA); @@ -638,7 +642,7 @@ public: return true; } // del - if (show == "move" && target) + if (show == "move") { handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid); @@ -652,16 +656,20 @@ public: // Respawn the owner of the waypoints if (wpGuid != 0) { - wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - wpCreature->CombatStop(); - wpCreature->DeleteFromDB(); - wpCreature->AddObjectToRemoveList(); + wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); + if (wpCreature) + { + wpCreature->CombatStop(); + wpCreature->DeleteFromDB(); + wpCreature->AddObjectToRemoveList(); + } // re-create Creature* wpCreature2 = new Creature; if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation())) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); delete wpCreature2; + wpCreature2 = NULL; return false; } @@ -672,6 +680,7 @@ public: { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); delete wpCreature2; + wpCreature2 = NULL; return false; } //sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2); diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp index 0d8cabcf89c..22f3513b157 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp @@ -117,7 +117,7 @@ public: // Interrupt any spell casting me->InterruptNonMeleeSpells(false); // Gyth model - me->SetDisplayId(me->GetCreatureInfo()->Modelid1); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid1); me->SummonCreature(NPC_WARCHIEF_REND_BLACKHAND, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 900 * IN_MILLISECONDS); events.ScheduleEvent(EVENT_CORROSIVE_ACID, 8 * IN_MILLISECONDS); events.ScheduleEvent(EVENT_FREEZE, 11 * IN_MILLISECONDS); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index 14add92fd16..35a9f854d58 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -297,7 +297,7 @@ public: SetEquipmentSlots(false, EQUIP_UNEQUIP, EQUIP_UNEQUIP, EQUIP_NO_CHANGE); //damage - const CreatureTemplate* cinfo = me->GetCreatureInfo(); + const CreatureTemplate* cinfo = me->GetCreatureTemplate(); me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, cinfo->mindmg); me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, cinfo->maxdmg); me->UpdateDamagePhysical(BASE_ATTACK); @@ -420,7 +420,7 @@ public: SetEquipmentSlots(false, EQUIP_ID_AXE, EQUIP_ID_AXE, EQUIP_NO_CHANGE); //damage - const CreatureTemplate* cinfo = me->GetCreatureInfo(); + const CreatureTemplate* cinfo = me->GetCreatureTemplate(); me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, 2*cinfo->mindmg); me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, 2*cinfo->maxdmg); me->UpdateDamagePhysical(BASE_ATTACK); diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index 342c0d18dc9..a264c7afa98 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -108,7 +108,7 @@ public: if (!me->GetEquipmentId()) if (const CreatureTemplate* info = sObjectMgr->GetCreatureTemplate(28406)) if (info->equipmentId) - const_cast<CreatureTemplate*>(me->GetCreatureInfo())->equipmentId = info->equipmentId; + const_cast<CreatureTemplate*>(me->GetCreatureTemplate())->equipmentId = info->equipmentId; } uint64 playerGUID; @@ -878,7 +878,7 @@ public: npc_scarlet_miner_cartAI(Creature* c) : PassiveAI(c), minerGUID(0) { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - me->SetDisplayId(me->GetCreatureInfo()->Modelid1); // Modelid2 is a horse. + me->SetDisplayId(me->GetCreatureTemplate()->Modelid1); // Modelid2 is a horse. } uint64 minerGUID; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp index 27ddc215543..737a8fade57 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_arlokk.cpp @@ -237,7 +237,7 @@ class boss_arlokk : public CreatureScript me->SetDisplayId(MODEL_ID_PANTHER); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - const CreatureTemplate* cinfo = me->GetCreatureInfo(); + const CreatureTemplate* cinfo = me->GetCreatureTemplate(); me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35))); me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35))); me->UpdateDamagePhysical(BASE_ATTACK); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp index 38d9be78f2a..d0f1aea21ba 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp @@ -156,7 +156,7 @@ class boss_marli : public CreatureScript { DoScriptText(SAY_TRANSFORM, me); DoCast(me, SPELL_SPIDER_FORM); - const CreatureTemplate* cinfo = me->GetCreatureInfo(); + const CreatureTemplate* cinfo = me->GetCreatureTemplate(); me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35))); me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35))); me->UpdateDamagePhysical(BASE_ATTACK); @@ -196,7 +196,7 @@ class boss_marli : public CreatureScript if (TransformBack_Timer <= diff) { me->SetDisplayId(15220); - const CreatureTemplate* cinfo = me->GetCreatureInfo(); + const CreatureTemplate* cinfo = me->GetCreatureTemplate(); me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 1))); me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 1))); me->UpdateDamagePhysical(BASE_ATTACK); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp index 4185ba2f3e7..dc9521b028b 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp @@ -201,7 +201,7 @@ class boss_thekal : public CreatureScript me->SetStandState(UNIT_STAND_STATE_STAND); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetFullHealth(); - const CreatureTemplate* cinfo = me->GetCreatureInfo(); + const CreatureTemplate* cinfo = me->GetCreatureTemplate(); me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 40))); me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 40))); me->UpdateDamagePhysical(BASE_ATTACK); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp index 9a91e1e232b..b232cae4657 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp @@ -16,6 +16,7 @@ */ #include "ScriptPCH.h" +#include "CreatureTextMgr.h" #include "culling_of_stratholme.h" #define MAX_ENCOUNTER 5 diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index a9e41d90899..7dcdaa28879 100755 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -572,7 +572,7 @@ class mob_frost_sphere : public CreatureScript _isFalling = false; me->SetReactState(REACT_PASSIVE); me->SetFlying(true); - me->SetDisplayId(me->GetCreatureInfo()->Modelid2); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid2); me->SetSpeed(MOVE_RUN, 0.5f, false); me->GetMotionMaster()->MoveRandom(20.0f); DoCast(SPELL_FROST_SPHERE); @@ -604,7 +604,7 @@ class mob_frost_sphere : public CreatureScript { case POINT_FALL_GROUND: me->RemoveAurasDueToSpell(SPELL_FROST_SPHERE); - me->SetDisplayId(me->GetCreatureInfo()->Modelid1); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid1); DoCast(SPELL_PERMAFROST_VISUAL); DoCast(SPELL_PERMAFROST); me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.0f); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 7ca371d1c82..19a8e42e14b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -26,6 +26,7 @@ #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" +#include "CreatureTextMgr.h" #include "icecrown_citadel.h" enum Texts @@ -1222,7 +1223,7 @@ class npc_tirion_fordring_tft : public CreatureScript void sGossipSelect(Player* /*player*/, uint32 sender, uint32 action) { - if (me->GetCreatureInfo()->GossipMenuId == sender && !action) + if (me->GetCreatureTemplate()->GossipMenuId == sender && !action) { _events.SetPhase(PHASE_INTRO); me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp index c6f72890d1f..284babb7193 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp @@ -29,17 +29,15 @@ EndScriptData */ enum eEnums { //Yell - SAY_AGGRO = -1602000, - SAY_SLAY_1 = -1602001, - SAY_SLAY_2 = -1602002, - SAY_SLAY_3 = -1602003, - SAY_DEATH = -1602004, - SAY_BATTLE_STANCE = -1602005, - EMOTE_BATTLE_STANCE = -1602006, - SAY_BERSEKER_STANCE = -1602007, - EMOTE_BERSEKER_STANCE = -1602008, - SAY_DEFENSIVE_STANCE = -1602009, - EMOTE_DEFENSIVE_STANCE = -1602010, + SAY_AGGRO = 0, + SAY_DEFENSIVE_STANCE = 1, + SAY_BATTLE_STANCE = 2, + SAY_BERSEKER_STANCE = 3, + SAY_SLAY = 4, + SAY_DEATH = 5, + EMOTE_DEFENSIVE_STANCE = 6, + EMOTE_BATTLE_STANCE = 7, + EMOTE_BERSEKER_STANCE = 8, SPELL_DEFENSIVE_STANCE = 53790, //SPELL_DEFENSIVE_AURA = 41105, @@ -185,7 +183,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); //must get both lieutenants here and make sure they are with him me->CallForHelp(30.0f); @@ -196,12 +194,12 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3), me); + Talk(SAY_SLAY); } void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); if (m_instance) m_instance->SetData(TYPE_BJARNGRIM, DONE); @@ -249,20 +247,20 @@ public: switch (m_uiStance) { case STANCE_DEFENSIVE: - DoScriptText(SAY_DEFENSIVE_STANCE, me); - DoScriptText(EMOTE_DEFENSIVE_STANCE, me); + Talk(SAY_DEFENSIVE_STANCE); + Talk(EMOTE_DEFENSIVE_STANCE); DoCast(me, SPELL_DEFENSIVE_STANCE); SetEquipmentSlots(false, EQUIP_SWORD, EQUIP_SHIELD, EQUIP_NO_CHANGE); break; case STANCE_BERSERKER: - DoScriptText(SAY_BERSEKER_STANCE, me); - DoScriptText(EMOTE_BERSEKER_STANCE, me); + Talk(SAY_BERSEKER_STANCE); + Talk(EMOTE_BERSEKER_STANCE); DoCast(me, SPELL_BERSEKER_STANCE); SetEquipmentSlots(false, EQUIP_SWORD, EQUIP_SWORD, EQUIP_NO_CHANGE); break; case STANCE_BATTLE: - DoScriptText(SAY_BATTLE_STANCE, me); - DoScriptText(EMOTE_BATTLE_STANCE, me); + Talk(SAY_BATTLE_STANCE); + Talk(EMOTE_BATTLE_STANCE); DoCast(me, SPELL_BATTLE_STANCE); SetEquipmentSlots(false, EQUIP_MACE, EQUIP_UNEQUIP, EQUIP_NO_CHANGE); break; diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp index 016c4d27cfa..abdf5ecb1e1 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp @@ -41,13 +41,10 @@ enum Spells enum Yells { - SAY_AGGRO = -1602011, - SAY_SLAY_1 = -1602012, - SAY_SLAY_2 = -1602013, - SAY_SLAY_3 = -1602014, - SAY_DEATH = -1602015, - SAY_SPLIT_1 = -1602016, - SAY_SPLIT_2 = -1602017 + SAY_AGGRO = 0, + SAY_SPLIT = 1, + SAY_SLAY = 2, + SAY_DEATH = 3 }; enum Creatures @@ -122,7 +119,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); if (instance) instance->SetData(TYPE_IONAR, IN_PROGRESS); @@ -130,7 +127,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); lSparkList.DespawnAll(); @@ -140,7 +137,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3), me); + Talk(SAY_SLAY); } void SpellHit(Unit* /*caster*/, const SpellInfo* spell) @@ -278,7 +275,7 @@ public: { bHasDispersed = true; - DoScriptText(RAND(SAY_SPLIT_1, SAY_SPLIT_2), me); + Talk(SAY_SPLIT); if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp index 171215c605a..e4f2bb5ce01 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp @@ -30,20 +30,16 @@ enum eEnums { ACHIEV_TIMELY_DEATH_START_EVENT = 20384, - SAY_AGGRO = -1602018, - SAY_INTRO_1 = -1602019, - SAY_INTRO_2 = -1602020, - SAY_SLAY_1 = -1602021, - SAY_SLAY_2 = -1602022, - SAY_SLAY_3 = -1602023, - SAY_DEATH = -1602024, - SAY_NOVA_1 = -1602025, - SAY_NOVA_2 = -1602026, - SAY_NOVA_3 = -1602027, - SAY_75HEALTH = -1602028, - SAY_50HEALTH = -1602029, - SAY_25HEALTH = -1602030, - EMOTE_NOVA = -1602031, + SAY_INTRO_1 = 0, + SAY_INTRO_2 = 1, + SAY_AGGRO = 2, + SAY_NOVA = 3, + SAY_SLAY = 4, + SAY_75HEALTH = 5, + SAY_50HEALTH = 6, + SAY_25HEALTH = 7, + SAY_DEATH = 8, + EMOTE_NOVA = 9, SPELL_ARC_LIGHTNING = 52921, SPELL_LIGHTNING_NOVA_N = 52960, @@ -106,7 +102,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); if (m_instance) { @@ -117,7 +113,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); if (m_instance) m_instance->SetData(TYPE_LOKEN, DONE); @@ -125,7 +121,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3), me); + Talk(SAY_SLAY); } void UpdateAI(const uint32 uiDiff) @@ -190,8 +186,8 @@ public: if (m_uiLightningNova_Timer <= uiDiff) { - DoScriptText(RAND(SAY_NOVA_1, SAY_NOVA_2, SAY_NOVA_3), me); - DoScriptText(EMOTE_NOVA, me); + Talk(SAY_NOVA); + Talk(EMOTE_NOVA); DoCast(me, SPELL_LIGHTNING_NOVA_N); m_bIsAura = false; @@ -206,9 +202,9 @@ public: { switch (m_uiHealthAmountModifier) { - case 1: DoScriptText(SAY_75HEALTH, me); break; - case 2: DoScriptText(SAY_50HEALTH, me); break; - case 3: DoScriptText(SAY_25HEALTH, me); break; + case 1: Talk(SAY_75HEALTH); break; + case 2: Talk(SAY_50HEALTH); break; + case 3: Talk(SAY_25HEALTH); break; } ++m_uiHealthAmountModifier; diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp index 1fc724c8b6c..83604ed4153 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp @@ -28,17 +28,13 @@ EndScriptData */ enum eEnums { - SAY_AGGRO = -1602032, - SAY_SLAY_1 = -1602033, - SAY_SLAY_2 = -1602034, - SAY_SLAY_3 = -1602035, - SAY_DEATH = -1602036, - SAY_STOMP_1 = -1602037, - SAY_STOMP_2 = -1602038, - SAY_FORGE_1 = -1602039, - SAY_FORGE_2 = -1602040, - EMOTE_TO_ANVIL = -1602041, - EMOTE_SHATTER = -1602042, + SAY_AGGRO = 0, + SAY_FORGE = 1, + SAY_STOMP = 2, + SAY_SLAY = 3, + SAY_DEATH = 4, + EMOTE_TO_ANVIL = 5, + EMOTE_SHATTER = 6, SPELL_HEAT_N = 52387, SPELL_HEAT_H = 59528, @@ -127,7 +123,7 @@ public: void EnterCombat(Unit* /*who*/) { - DoScriptText(SAY_AGGRO, me); + Talk(SAY_AGGRO); if (m_instance) m_instance->SetData(TYPE_VOLKHAN, IN_PROGRESS); @@ -148,7 +144,7 @@ public: void JustDied(Unit* /*killer*/) { - DoScriptText(SAY_DEATH, me); + Talk(SAY_DEATH); DespawnGolem(); if (m_instance) @@ -172,7 +168,7 @@ public: void KilledUnit(Unit* /*victim*/) { - DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3), me); + Talk(SAY_SLAY); } void DespawnGolem() @@ -263,11 +259,11 @@ public: if (m_uiShatteringStomp_Timer <= uiDiff) { // Should he stomp even if he has no brittle golem to shatter? - DoScriptText(RAND(SAY_STOMP_1, SAY_STOMP_2), me); + Talk(SAY_STOMP); DoCast(me, SPELL_SHATTERING_STOMP_N); - DoScriptText(EMOTE_SHATTER, me); + Talk(EMOTE_SHATTER); m_uiShatteringStomp_Timer = 30000; m_bCanShatterGolem = true; @@ -297,7 +293,7 @@ public: if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); - DoScriptText(RAND(SAY_FORGE_1, SAY_FORGE_2), me); + Talk(SAY_FORGE); m_bHasTemper = true; @@ -308,7 +304,7 @@ public: { case 1: // 1 - Start run to Anvil - DoScriptText(EMOTE_TO_ANVIL, me); + Talk(EMOTE_TO_ANVIL); me->GetMotionMaster()->MoveTargetedHome(); m_uiSummonPhase = 2; // Set Next Phase break; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index aae1995e204..98b20f1c424 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -577,7 +577,7 @@ class boss_flame_leviathan_seat : public CreatureScript { ASSERT(vehicle); me->SetReactState(REACT_PASSIVE); - me->SetDisplayId(me->GetCreatureInfo()->Modelid2); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid2); instance = creature->GetInstanceScript(); } @@ -1756,7 +1756,7 @@ class spell_vehicle_throw_passenger : public SpellScriptLoader if (Unit* device = seat->GetPassenger(2)) if (!device->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) { - float dist = unit->GetExactDistSq(targets.GetDst()); + float dist = unit->GetExactDistSq(targets.GetDstPos()); if (dist < minDist) { minDist = dist; @@ -1764,13 +1764,13 @@ class spell_vehicle_throw_passenger : public SpellScriptLoader } } } - if (target && target->IsWithinDist2d(targets.GetDst(), GetSpellInfo()->Effects[effIndex].CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct + if (target && target->IsWithinDist2d(targets.GetDstPos(), GetSpellInfo()->Effects[effIndex].CalcRadius() * 2)) // now we use *2 because the location of the seat is not correct passenger->EnterVehicle(target, 0); else { passenger->ExitVehicle(); float x, y, z; - targets.GetDst()->GetPosition(x, y, z); + targets.GetDstPos()->GetPosition(x, y, z); passenger->GetMotionMaster()->MoveJump(x, y, z, targets.GetSpeedXY(), targets.GetSpeedZ()); } } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp index 33f50d0b3de..60c4ec68e82 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp @@ -179,7 +179,7 @@ class npc_flash_freeze : public CreatureScript npc_flash_freezeAI(Creature* creature) : ScriptedAI(creature) { instance = me->GetInstanceScript(); - me->SetDisplayId(me->GetCreatureInfo()->Modelid2); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid2); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_STUNNED | UNIT_FLAG_PACIFIED); } @@ -246,7 +246,7 @@ class npc_ice_block : public CreatureScript npc_ice_blockAI(Creature* creature) : ScriptedAI(creature) { instance = me->GetInstanceScript(); - me->SetDisplayId(me->GetCreatureInfo()->Modelid2); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid2); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_STUNNED | UNIT_FLAG_PACIFIED); targetGUID = 0; } @@ -512,7 +512,7 @@ class npc_icicle : public CreatureScript { npc_icicleAI(Creature* creature) : ScriptedAI(creature) { - me->SetDisplayId(me->GetCreatureInfo()->Modelid1); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid1); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PACIFIED | UNIT_FLAG_NOT_SELECTABLE); me->SetReactState(REACT_PASSIVE); } @@ -560,7 +560,7 @@ class npc_snowpacked_icicle : public CreatureScript { npc_snowpacked_icicleAI(Creature* creature) : ScriptedAI(creature) { - me->SetDisplayId(me->GetCreatureInfo()->Modelid2); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid2); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED); me->SetReactState(REACT_PASSIVE); } @@ -881,7 +881,7 @@ class npc_toasty_fire : public CreatureScript { npc_toasty_fireAI(Creature* creature) : ScriptedAI(creature) { - me->SetDisplayId(me->GetCreatureInfo()->Modelid2); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid2); } void Reset() diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp index 7ad859e3e8d..d245c77b9df 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp @@ -177,7 +177,7 @@ class boss_razorscale_controller : public CreatureScript { boss_razorscale_controllerAI(Creature* creature) : BossAI(creature, DATA_RAZORSCALE_CONTROL) { - me->SetDisplayId(me->GetCreatureInfo()->Modelid2); + me->SetDisplayId(me->GetCreatureTemplate()->Modelid2); } void Reset() diff --git a/src/server/scripts/Northrend/borean_tundra.cpp b/src/server/scripts/Northrend/borean_tundra.cpp index a8fcd6139da..e97cc5e205b 100644 --- a/src/server/scripts/Northrend/borean_tundra.cpp +++ b/src/server/scripts/Northrend/borean_tundra.cpp @@ -139,7 +139,7 @@ public: case 7: DoCast(me, SPELL_EXPLODE_CART, true); if (Player* caster = Unit::GetPlayer(*me, casterGuid)) - caster->KilledMonster(me->GetCreatureInfo(), me->GetGUID()); + caster->KilledMonster(me->GetCreatureTemplate(), me->GetGUID()); uiPhaseTimer = 5000; Phase = 8; break; diff --git a/src/server/scripts/Northrend/zuldrak.cpp b/src/server/scripts/Northrend/zuldrak.cpp index 1bf04bc624c..4cea6d8d8aa 100644 --- a/src/server/scripts/Northrend/zuldrak.cpp +++ b/src/server/scripts/Northrend/zuldrak.cpp @@ -92,7 +92,7 @@ public: if (Creature* pRageclaw = Unit::GetCreature(*me, RageclawGUID)) { UnlockRageclaw(pCaster); - pCaster->ToPlayer()->KilledMonster(pRageclaw->GetCreatureInfo(), RageclawGUID); + pCaster->ToPlayer()->KilledMonster(pRageclaw->GetCreatureTemplate(), RageclawGUID); me->DisappearAndDie(); } else @@ -156,7 +156,7 @@ public: me->RemoveAurasDueToSpell(SPELL_KNEEL); - me->setFaction(me->GetCreatureInfo()->faction_H); + me->setFaction(me->GetCreatureTemplate()->faction_H); DoCast(me, SPELL_UNSHACKLED, true); me->MonsterSay(SAY_RAGECLAW, LANG_UNIVERSAL, 0); @@ -617,9 +617,9 @@ public: pWhisker->RemoveFromWorld(); } - void MovementInform(uint32 uiType, uint32 /*uiId*/) + void MovementInform(uint32 type, uint32 /*pointId*/) { - if (uiType != POINT_MOTION_TYPE) + if (type != EFFECT_MOTION_TYPE) return; me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index b0a42614ee3..de9ef5cd67f 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -502,7 +502,7 @@ public: void SummonedCreatureDespawn(Creature* summon) { - if (summon->GetCreatureInfo()->Entry == FLAME_OF_AZZINOTH) + if (summon->GetCreatureTemplate()->Entry == FLAME_OF_AZZINOTH) { for (uint8 i = 0; i < 2; ++i) if (summon->GetGUID() == FlameGUID[i]) diff --git a/src/server/scripts/Outland/blades_edge_mountains.cpp b/src/server/scripts/Outland/blades_edge_mountains.cpp index f99851f013e..bd23b06a5ea 100644 --- a/src/server/scripts/Outland/blades_edge_mountains.cpp +++ b/src/server/scripts/Outland/blades_edge_mountains.cpp @@ -523,7 +523,7 @@ public: me->GetMotionMaster()->MoveTargetedHome(); Creature* Credit = me->FindNearestCreature(NPC_QUEST_CREDIT, 50, true); if (player && Credit) - player->KilledMonster(Credit->GetCreatureInfo(), Credit->GetGUID()); + player->KilledMonster(Credit->GetCreatureTemplate(), Credit->GetGUID()); } } diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index eb42b377128..a6128591e71 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -341,7 +341,7 @@ class spell_dk_death_pact : public SpellScriptLoader { if ((*itr)->GetTypeId() == TYPEID_UNIT && (*itr)->GetOwnerGUID() == GetCaster()->GetGUID() - && (*itr)->ToCreature()->GetCreatureInfo()->type == CREATURE_TYPE_UNDEAD) + && (*itr)->ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_UNDEAD) { unit_to_add = (*itr); break; @@ -772,13 +772,11 @@ class spell_dk_death_grip : public SpellScriptLoader void HandleDummy(SpellEffIndex effIndex) { int32 damage = GetEffectValue(); - Position pos; + Position const* pos = GetTargetDest(); if (Unit* target = GetHitUnit()) { - GetSummonPosition(effIndex, pos, 0.0f, 0); - if (!target->HasAuraType(SPELL_AURA_DEFLECT_SPELLS)) // Deterrence - target->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), damage, true); + target->CastSpell(pos->GetPositionX(), pos->GetPositionY(), pos->GetPositionZ(), damage, true); } } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index db33a9e0332..f2a48b0f9d2 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -2548,6 +2548,43 @@ class spell_gen_chaos_blast : public SpellScriptLoader }; +class spell_gen_ds_flush_knockback : public SpellScriptLoader +{ + public: + spell_gen_ds_flush_knockback() : SpellScriptLoader("spell_gen_ds_flush_knockback") {} + + class spell_gen_ds_flush_knockback_SpellScript : public SpellScript + { + PrepareSpellScript(spell_gen_ds_flush_knockback_SpellScript); + + void HandleScript(SpellEffIndex /*effIndex*/) + { + // Here the target is the water spout and determines the position where the player is knocked from + if (Unit* target = GetHitUnit()) + { + if (Player* player = GetCaster()->ToPlayer()) + { + float horizontalSpeed = 20.0f + (40.0f - GetCaster()->GetDistance(target)); + float verticalSpeed = 8.0f; + // This method relies on the Dalaran Sewer map disposition and Water Spout position + // What we do is knock the player from a position exactly behind him and at the end of the pipe + player->KnockbackFrom(target->GetPositionX(), player->GetPositionY(), horizontalSpeed, verticalSpeed); + } + } + } + + void Register() + { + OnEffectHitTarget += SpellEffectFn(spell_gen_ds_flush_knockback_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY); + } + }; + + SpellScript* GetSpellScript() const + { + return new spell_gen_ds_flush_knockback_SpellScript(); + } +}; + void AddSC_generic_spell_scripts() { new spell_gen_absorb0_hitlimit1(); @@ -2597,4 +2634,5 @@ void AddSC_generic_spell_scripts() new spell_gen_on_tournament_mount(); new spell_gen_tournament_pennant(); new spell_gen_chaos_blast(); + new spell_gen_ds_flush_knockback(); } diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 1e2e9459ccb..533fd8a2e5c 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -34,6 +34,9 @@ enum WarlockSpells WARLOCK_DEMONIC_EMPOWERMENT_IMP = 54444, WARLOCK_IMPROVED_HEALTHSTONE_R1 = 18692, WARLOCK_IMPROVED_HEALTHSTONE_R2 = 18693, + WARLOCK_DEMONIC_CIRCLE_SUMMON = 48018, + WARLOCK_DEMONIC_CIRCLE_TELEPORT = 48020, + WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST = 62388, }; class spell_warl_banish : public SpellScriptLoader @@ -439,6 +442,90 @@ class spell_warl_life_tap : public SpellScriptLoader } }; +class spell_warl_demonic_circle_summon : public SpellScriptLoader +{ + public: + spell_warl_demonic_circle_summon() : SpellScriptLoader("spell_warl_demonic_circle_summon") { } + + class spell_warl_demonic_circle_summon_AuraScript : public AuraScript + { + PrepareAuraScript(spell_warl_demonic_circle_summon_AuraScript); + + void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes mode) + { + // If effect is removed by expire remove the summoned demonic circle too. + if (!(mode & AURA_EFFECT_HANDLE_REAPPLY)) + GetTarget()->RemoveGameObject(GetId(), true); + + GetTarget()->RemoveAura(WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST); + } + + void HandleDummyTick(AuraEffect const* /*aurEff*/) + { + if (GameObject* circle = GetTarget()->GetGameObject(GetId())) + { + // Here we check if player is in demonic circle teleport range, if so add + // WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST; allowing him to cast the WARLOCK_DEMONIC_CIRCLE_TELEPORT. + // If not in range remove the WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST. + + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(WARLOCK_DEMONIC_CIRCLE_TELEPORT); + + if (GetTarget()->IsWithinDist(circle, spellInfo->GetMaxRange(true))) + { + if (!GetTarget()->HasAura(WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST)) + GetTarget()->CastSpell(GetTarget(), WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST, true); + } + else + GetTarget()->RemoveAura(WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST); + } + } + + void Register() + { + OnEffectRemove += AuraEffectApplyFn(spell_warl_demonic_circle_summon_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK); + OnEffectPeriodic += AuraEffectPeriodicFn(spell_warl_demonic_circle_summon_AuraScript::HandleDummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_warl_demonic_circle_summon_AuraScript(); + } +}; + +class spell_warl_demonic_circle_teleport : public SpellScriptLoader +{ + public: + spell_warl_demonic_circle_teleport() : SpellScriptLoader("spell_warl_demonic_circle_teleport") { } + + class spell_warl_demonic_circle_teleport_AuraScript : public AuraScript + { + PrepareAuraScript(spell_warl_demonic_circle_teleport_AuraScript); + + void HandleTeleport(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Player* player = GetTarget()->ToPlayer()) + { + if (GameObject* circle = player->GetGameObject(WARLOCK_DEMONIC_CIRCLE_SUMMON)) + { + player->NearTeleportTo(circle->GetPositionX(), circle->GetPositionY(), circle->GetPositionZ(), circle->GetOrientation()); + player->RemoveMovementImpairingAuras(); + } + } + } + + void Register() + { + OnEffectApply += AuraEffectApplyFn(spell_warl_demonic_circle_teleport_AuraScript::HandleTeleport, EFFECT_0, SPELL_AURA_MECHANIC_IMMUNITY, AURA_EFFECT_HANDLE_REAL); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_warl_demonic_circle_teleport_AuraScript(); + } +}; + void AddSC_warlock_spell_scripts() { new spell_warl_banish(); @@ -449,4 +536,6 @@ void AddSC_warlock_spell_scripts() new spell_warl_seed_of_corruption(); new spell_warl_soulshatter(); new spell_warl_life_tap(); + new spell_warl_demonic_circle_summon(); + new spell_warl_demonic_circle_teleport(); } diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index 8f86f760775..77f3a64a13f 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -32,6 +32,7 @@ at_sholazar_waygate q12548 at_nats_landing q11209 at_bring_your_orphan_to q910 q910 q1800 q1479 q1687 q1558 q10951 q10952 at_brewfest +at_area_52_entrance EndContentData */ #include "ScriptPCH.h" @@ -420,6 +421,47 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript std::map<uint32, time_t> _triggerTimes; }; +/*###### +## at_area_52_entrance +######*/ + +enum Area52Entrance +{ + NPC_SPOTLIGHT = 19913, + SUMMON_COOLDOWN = 5, + + AT_AREA_52_SOUTH = 4472, + AT_AREA_52_NORTH = 4466, + AT_AREA_52_WEST = 4471, + AT_AREA_52_EAST = 4422, +}; + +class AreaTrigger_at_area_52_entrance : public AreaTriggerScript +{ + public: + AreaTrigger_at_area_52_entrance() : AreaTriggerScript("at_area_52_entrance") + { + _triggerTimes[AT_AREA_52_SOUTH] = _triggerTimes[AT_AREA_52_NORTH] = _triggerTimes[AT_AREA_52_WEST] = _triggerTimes[AT_AREA_52_EAST] = 0; + } + + bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) + { + if (!player->isAlive()) + return false; + + if (sWorld->GetGameTime() - _triggerTimes[trigger->id] < SUMMON_COOLDOWN) + return false; + + player->SummonCreature(NPC_SPOTLIGHT, trigger->x, trigger->y, trigger->z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 5000); + + _triggerTimes[trigger->id] = sWorld->GetGameTime(); + return false; + } + + private: + std::map<uint32, time_t> _triggerTimes; +}; + void AddSC_areatrigger_scripts() { new AreaTrigger_at_coilfang_waterfall(); @@ -431,4 +473,5 @@ void AddSC_areatrigger_scripts() new AreaTrigger_at_nats_landing(); new AreaTrigger_at_bring_your_orphan_to(); new AreaTrigger_at_brewfest(); + new AreaTrigger_at_area_52_entrance(); } diff --git a/src/server/scripts/World/mob_generic_creature.cpp b/src/server/scripts/World/mob_generic_creature.cpp index 3a61b9f9e18..ce8b0a2de14 100644 --- a/src/server/scripts/World/mob_generic_creature.cpp +++ b/src/server/scripts/World/mob_generic_creature.cpp @@ -105,7 +105,7 @@ public: else info = SelectSpell(me->getVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE); //50% chance if elite or higher, 20% chance if not, to replace our white hit with a spell - if (info && (rand() % (me->GetCreatureInfo()->rank > 1 ? 2 : 5) == 0) && !GlobalCooldown) + if (info && (rand() % (me->GetCreatureTemplate()->rank > 1 ? 2 : 5) == 0) && !GlobalCooldown) { //Cast the spell if (Healing)DoCastSpell(me, info); diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 8513eae5876..10bc722fc1b 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -1650,7 +1650,7 @@ public: { SpellTimer = 0; - CreatureTemplate const* Info = me->GetCreatureInfo(); + CreatureTemplate const* Info = me->GetCreatureTemplate(); IsViper = Info->Entry == C_VIPER ? true : false; diff --git a/src/server/shared/Cryptography/HMACSHA1.cpp b/src/server/shared/Cryptography/HMACSHA1.cpp index 447d0b58efc..c9de1191464 100755 --- a/src/server/shared/Cryptography/HMACSHA1.cpp +++ b/src/server/shared/Cryptography/HMACSHA1.cpp @@ -31,19 +31,9 @@ HmacHash::~HmacHash() HMAC_CTX_cleanup(&m_ctx); } -void HmacHash::UpdateBigNumber(BigNumber* bn) -{ - UpdateData(bn->AsByteArray(), bn->GetNumBytes()); -} - -void HmacHash::UpdateData(const uint8 *data, int length) -{ - HMAC_Update(&m_ctx, data, length); -} - void HmacHash::UpdateData(const std::string &str) { - UpdateData((uint8 const*)str.c_str(), str.length()); + HMAC_Update(&m_ctx, (uint8 const*)str.c_str(), str.length()); } void HmacHash::Finalize() diff --git a/src/server/shared/Cryptography/HMACSHA1.h b/src/server/shared/Cryptography/HMACSHA1.h index bd0418b600e..4b7667968ca 100755 --- a/src/server/shared/Cryptography/HMACSHA1.h +++ b/src/server/shared/Cryptography/HMACSHA1.h @@ -33,8 +33,6 @@ class HmacHash public: HmacHash(uint32 len, uint8 *seed); ~HmacHash(); - void UpdateBigNumber(BigNumber* bn); - void UpdateData(const uint8 *data, int length); void UpdateData(const std::string &str); void Finalize(); uint8 *ComputeHash(BigNumber* bn); diff --git a/src/server/shared/Cryptography/SHA1.h b/src/server/shared/Cryptography/SHA1.h index b5bf97fd7d9..7c77defebfa 100755 --- a/src/server/shared/Cryptography/SHA1.h +++ b/src/server/shared/Cryptography/SHA1.h @@ -31,7 +31,6 @@ class SHA1Hash SHA1Hash(); ~SHA1Hash(); - void UpdateFinalizeBigNumbers(BigNumber* bn0, ...); void UpdateBigNumbers(BigNumber* bn0, ...); void UpdateData(const uint8 *dta, int len); diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 6b99b79625d..f018eb31bb4 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -27,22 +27,53 @@ class ByteBufferException { public: - ByteBufferException(bool _add, size_t _pos, size_t _esize, size_t _size) - : add(_add), pos(_pos), esize(_esize), size(_size) + ByteBufferException(size_t pos, size_t size, size_t valueSize) + : Pos(pos), Size(size), ValueSize(valueSize) { - PrintPosError(); } - void PrintPosError() const + protected: + + size_t Pos; + size_t Size; + size_t ValueSize; +}; + +class ByteBufferPositionException : public ByteBufferException +{ + public: + ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize) + : ByteBufferException(pos, size, valueSize), _add(add) + { + PrintError(); + } + + protected: + void PrintError() const { - sLog->outError("Attempted to %s in ByteBuffer (pos: " SIZEFMTD " size: "SIZEFMTD") value with size: " SIZEFMTD, - (add ? "put" : "get"), pos, size, esize); + sLog->outError("Attempted to %s value with size: "SIZEFMTD" in ByteBuffer (pos: " SIZEFMTD " size: "SIZEFMTD") " , + ValueSize, (_add ? "put" : "get"), Pos, Size); } + private: - bool add; - size_t pos; - size_t esize; - size_t size; + bool _add; +}; + +class ByteBufferSourceException : public ByteBufferException +{ + public: + ByteBufferSourceException(size_t pos, size_t size, size_t valueSize) + : ByteBufferException(pos, size, valueSize) + { + PrintError(); + } + + protected: + void PrintError() const + { + sLog->outError("Attempted to put a %s in ByteBuffer (pos: "SIZEFMTD" size: "SIZEFMTD")", + (ValueSize > 0 ? "NULL-pointer" : "zero-sized value"), Pos, Size); + } }; class ByteBuffer @@ -147,14 +178,17 @@ class ByteBuffer ByteBuffer &operator<<(const std::string &value) { - append((uint8 const*)value.c_str(), value.length()); + if (size_t len = value.length()) + append((uint8 const*)value.c_str(), len); append((uint8)0); return *this; } ByteBuffer &operator<<(const char *str) { - append((uint8 const*)str, str ? strlen(str) : 0); + size_t len = 0; + if (str && (len = strlen(str))) + append((uint8 const*)str, len); append((uint8)0); return *this; } @@ -271,7 +305,7 @@ class ByteBuffer void read_skip(size_t skip) { if (_rpos + skip > size()) - throw ByteBufferException(false, _rpos, skip, size()); + throw ByteBufferPositionException(false, _rpos, skip, size()); _rpos += skip; } @@ -285,7 +319,7 @@ class ByteBuffer template <typename T> T read(size_t pos) const { if (pos + sizeof(T) > size()) - throw ByteBufferException(false, pos, sizeof(T), size()); + throw ByteBufferPositionException(false, pos, sizeof(T), size()); T val = *((T const*)&_storage[pos]); EndianConvert(val); return val; @@ -294,7 +328,7 @@ class ByteBuffer void read(uint8 *dest, size_t len) { if (_rpos + len > size()) - throw ByteBufferException(false, _rpos, len, size()); + throw ByteBufferPositionException(false, _rpos, len, size()); memcpy(dest, &_storage[_rpos], len); _rpos += len; } @@ -302,7 +336,7 @@ class ByteBuffer void readPackGUID(uint64& guid) { if (rpos() + 1 > size()) - throw ByteBufferException(false, _rpos, 1, size()); + throw ByteBufferPositionException(false, _rpos, 1, size()); guid = 0; @@ -314,7 +348,7 @@ class ByteBuffer if (guidmark & (uint8(1) << i)) { if (rpos() + 1 > size()) - throw ByteBufferException(false, _rpos, 1, size()); + throw ByteBufferPositionException(false, _rpos, 1, size()); uint8 bit; (*this) >> bit; @@ -341,11 +375,6 @@ class ByteBuffer _storage.reserve(ressize); } - void append(const std::string& str) - { - append((uint8 const*)str.c_str(), str.size() + 1); - } - void append(const char *src, size_t cnt) { return append((const uint8 *)src, cnt); @@ -359,7 +388,10 @@ class ByteBuffer void append(const uint8 *src, size_t cnt) { if (!cnt) - return; + throw ByteBufferSourceException(_wpos, size(), cnt); + + if (!src) + throw ByteBufferSourceException(_wpos, size(), cnt); ASSERT(size() < 10000000); @@ -407,7 +439,11 @@ class ByteBuffer void put(size_t pos, const uint8 *src, size_t cnt) { if (pos + cnt > size()) - throw ByteBufferException(true, pos, cnt, size()); + throw ByteBufferPositionException(true, pos, cnt, size()); + + if (!src) + throw ByteBufferSourceException(_wpos, size(), cnt); + memcpy(&_storage[pos], src, cnt); } |