aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Utilities/Util.cpp7
-rw-r--r--src/common/Utilities/Util.h3
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h2
-rw-r--r--src/server/game/Achievements/AchievementMgr.cpp2
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp2
-rw-r--r--src/server/game/Entities/Player/Player.cpp30
-rw-r--r--src/server/game/Entities/Player/Player.h3
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp36
-rw-r--r--src/server/game/Entities/Unit/Unit.h3
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp12
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp10
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp2
-rw-r--r--src/server/game/Miscellaneous/Language.h3
-rw-r--r--src/server/game/Server/WorldSession.cpp2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp53
-rw-r--r--src/server/game/Spells/Spell.cpp13
-rw-r--r--src/server/game/Spells/SpellHistory.cpp2
-rw-r--r--src/server/game/Spells/SpellInfo.h2
-rw-r--r--src/server/game/Spells/SpellMgr.cpp29
-rw-r--r--src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp140
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp2
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_noth.cpp2
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp28
-rw-r--r--src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp9
-rw-r--r--src/server/scripts/Northrend/Naxxramas/naxxramas.h2
-rw-r--r--src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp5
-rw-r--r--src/tools/map_extractor/CMakeLists.txt18
-rw-r--r--src/tools/map_extractor/System.cpp201
-rw-r--r--src/tools/map_extractor/loadlib.cpp8
-rw-r--r--src/tools/map_extractor/loadlib/loadlib.h30
-rw-r--r--src/tools/map_extractor/mpq_libmpq04.h6
-rw-r--r--src/tools/mmaps_generator/IntermediateValues.h1
-rw-r--r--src/tools/mmaps_generator/MapBuilder.cpp22
-rw-r--r--src/tools/mmaps_generator/MapBuilder.h16
-rw-r--r--src/tools/mmaps_generator/PathCommon.h5
-rw-r--r--src/tools/mmaps_generator/TerrainBuilder.cpp8
-rw-r--r--src/tools/mmaps_generator/TerrainBuilder.h11
-rw-r--r--src/tools/vmap4_extractor/adtfile.cpp10
-rw-r--r--src/tools/vmap4_extractor/mpq_libmpq04.h15
-rw-r--r--src/tools/vmap4_extractor/vmapexport.cpp50
-rw-r--r--src/tools/vmap4_extractor/wdtfile.cpp5
-rw-r--r--src/tools/vmap4_extractor/wdtfile.h13
-rw-r--r--src/tools/vmap4_extractor/wmo.cpp6
43 files changed, 314 insertions, 515 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp
index 33c273fb05f..9f61dd12e4c 100644
--- a/src/common/Utilities/Util.cpp
+++ b/src/common/Utilities/Util.cpp
@@ -58,6 +58,13 @@ uint32 urand(uint32 min, uint32 max)
return GetRng()->URandom(min, max);
}
+uint32 urandms(uint32 min, uint32 max)
+{
+ ASSERT(max >= min);
+ ASSERT(INT_MAX/IN_MILLISECONDS >= max);
+ return GetRng()->URandom(min * IN_MILLISECONDS, max * IN_MILLISECONDS);
+}
+
float frand(float min, float max)
{
ASSERT(max >= min);
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index 6a872b44a60..b748e83408b 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -82,6 +82,9 @@ int32 irand(int32 min, int32 max);
/* Return a random number in the range min..max (inclusive). */
uint32 urand(uint32 min, uint32 max);
+/* Return a random millisecond value between min and max seconds. Functionally equivalent to urand(min*IN_MILLISECONDS, max*IN_MILLISECONDS). */
+uint32 urandms(uint32 min, uint32 max);
+
/* Return a random number in the range 0 .. UINT32_MAX. */
uint32 rand32();
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index 6f9046520b0..1c4b9a51ece 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -248,7 +248,7 @@ class SmartScript
void DecPhase(int32 p = 1)
{
- if(mEventPhase > (uint32)p)
+ if (mEventPhase > (uint32)p)
mEventPhase -= (uint32)p;
else
mEventPhase = 0;
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index 2bacaff496f..a6359a353eb 100644
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -1533,7 +1533,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
//! Since no common attributes were found, (not even in titleRewardFlags field)
//! we explicitly check by ID. Maybe in the future we could move the achievement_reward
//! condition fields to the condition system.
- if (uint32 titleId = reward->titleId[achievement->ID == 1793 ? GetPlayer()->getGender() : (GetPlayer()->GetTeam() == ALLIANCE ? 0 : 1)])
+ if (uint32 titleId = reward->titleId[achievement->ID == 1793 ? GetPlayer()->GetByteValue(PLAYER_BYTES_3, 0) : (GetPlayer()->GetTeam() == ALLIANCE ? 0 : 1)])
if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId))
GetPlayer()->SetTitle(titleEntry);
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 9173d44ae86..ea10ce7988b 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -440,8 +440,8 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/)
ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
}
- LoadCreaturesAddon();
UpdateMovementFlags();
+ LoadCreaturesAddon();
return true;
}
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 1a9c0fbce4b..58a9626776b 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -2561,6 +2561,11 @@ void Player::SetGameMaster(bool on)
UpdateObjectVisibility();
}
+bool Player::CanBeGameMaster() const
+{
+ return GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_GM);
+}
+
void Player::SetGMVisible(bool on)
{
if (on)
@@ -4759,7 +4764,7 @@ Corpse* Player::CreateCorpse()
// prevent existence 2 corpse for player
SpawnCorpseBones();
- uint32 _uf, _pb, _pb2, _cfb1, _cfb2;
+ uint32 _pb, _pb2, _cfb1, _cfb2;
Corpse* corpse = new Corpse((m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE);
SetPvPDeath(false);
@@ -4772,18 +4777,16 @@ Corpse* Player::CreateCorpse()
_corpseLocation.WorldRelocate(*this);
- _uf = GetUInt32Value(UNIT_FIELD_BYTES_0);
_pb = GetUInt32Value(PLAYER_BYTES);
_pb2 = GetUInt32Value(PLAYER_BYTES_2);
- uint8 race = (uint8)(_uf);
uint8 skin = (uint8)(_pb);
uint8 face = (uint8)(_pb >> 8);
uint8 hairstyle = (uint8)(_pb >> 16);
uint8 haircolor = (uint8)(_pb >> 24);
uint8 facialhair = (uint8)(_pb2);
- _cfb1 = ((0x00) | (race << 8) | (getGender() << 16) | (skin << 24));
+ _cfb1 = ((0x00) | (getRace() << 8) | (GetByteValue(PLAYER_BYTES_3, 0) << 16) | (skin << 24));
_cfb2 = ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24));
corpse->SetUInt32Value(CORPSE_FIELD_BYTES_1, _cfb1);
@@ -18674,17 +18677,28 @@ bool Player::CheckInstanceLoginValid(Map* map)
{
// cannot be in raid instance without a group
if (!GetGroup())
- return false;
+ return IsInstanceLoginGameMasterException();
}
else
{
// cannot be in normal instance without a group and more players than 1 in instance
if (!GetGroup() && map->GetPlayersCountExceptGMs() > 1)
- return false;
+ return IsInstanceLoginGameMasterException();
}
// do checks for satisfy accessreqs, instance full, encounter in progress (raid), perm bind group != perm bind player
- return sMapMgr->CanPlayerEnter(map->GetId(), this, true);
+ return sMapMgr->CanPlayerEnter(map->GetId(), this, true) || IsInstanceLoginGameMasterException();
+}
+
+bool Player::IsInstanceLoginGameMasterException() const
+{
+ if (CanBeGameMaster())
+ {
+ ChatHandler(GetSession()).SendSysMessage(LANG_INSTANCE_LOGIN_GAMEMASTER_EXCEPTION);
+ return true;
+ }
+ else
+ return false;
}
bool Player::CheckInstanceCount(uint32 instanceId) const
@@ -21069,7 +21083,7 @@ void Player::InitDisplayIds()
return;
}
- uint8 gender = getGender();
+ uint8 gender = GetByteValue(PLAYER_BYTES_3, 0);
switch (gender)
{
case GENDER_FEMALE:
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 2a9dfc49280..8057a4ee54d 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1072,6 +1072,7 @@ class Player : public Unit, public GridObject<Player>
bool isAcceptWhispers() const { return (m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS) != 0; }
void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
bool IsGameMaster() const { return (m_ExtraFlags & PLAYER_EXTRA_GM_ON) != 0; }
+ bool CanBeGameMaster() const;
void SetGameMaster(bool on);
bool isGMChat() const { return (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT) != 0; }
void SetGMChat(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
@@ -2500,6 +2501,8 @@ class Player : public Unit, public GridObject<Player>
bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport; }
void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; }
void ScheduleDelayedOperation(uint32 operation) { if (operation < DELAYED_END) m_DelayedOperations |= operation; }
+
+ bool IsInstanceLoginGameMasterException() const;
MapReference m_mapRef;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 6b234df5860..92fb04b4831 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -12987,9 +12987,6 @@ void Unit::ModSpellCastTime(SpellInfo const* spellInfo, int32 & castTime, Spell*
if (!spellInfo || castTime < 0)
return;
- if (spellInfo->IsChanneled() && !spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))
- return;
-
// called from caster
if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, castTime, spell);
@@ -13003,6 +13000,25 @@ void Unit::ModSpellCastTime(SpellInfo const* spellInfo, int32 & castTime, Spell*
castTime = 500;
}
+void Unit::ModSpellDurationTime(SpellInfo const* spellInfo, int32 & duration, Spell* spell)
+{
+ if (!spellInfo || duration < 0)
+ return;
+
+ if (spellInfo->IsChanneled() && !spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))
+ return;
+
+ // called from caster
+ if (Player* modOwner = GetSpellModOwner())
+ modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, duration, spell);
+
+ if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) &&
+ ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT))
+ duration = int32(float(duration) * GetFloatValue(UNIT_MOD_CAST_SPEED));
+ else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG))
+ duration = int32(float(duration) * m_modAttackSpeedPct[RANGED_ATTACK]);
+}
+
DiminishingLevels Unit::GetDiminishing(DiminishingGroup group)
{
for (Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i)
@@ -13772,7 +13788,7 @@ void CharmInfo::InitPossessCreateSpells()
break;
}
- for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
+ for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
{
uint32 spellId = _unit->ToCreature()->m_spells[i];
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
@@ -13781,7 +13797,7 @@ void CharmInfo::InitPossessCreateSpells()
if (spellInfo->IsPassive())
_unit->CastSpell(_unit, spellInfo, true);
else
- AddSpellToActionBar(spellInfo, ACT_PASSIVE);
+ AddSpellToActionBar(spellInfo, ACT_PASSIVE, i % MAX_UNIT_ACTION_BAR_INDEX);
}
}
}
@@ -13839,11 +13855,12 @@ void CharmInfo::InitCharmCreateSpells()
}
}
-bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate)
+bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate, uint8 preferredSlot)
{
uint32 spell_id = spellInfo->Id;
uint32 first_id = spellInfo->GetFirstRankSpell()->Id;
+ ASSERT(preferredSlot < MAX_UNIT_ACTION_BAR_INDEX);
// new spell rank can be already listed
for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
{
@@ -13860,9 +13877,10 @@ bool CharmInfo::AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates new
// or use empty slot in other case
for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
{
- if (!PetActionBar[i].GetAction() && PetActionBar[i].IsActionBarForSpell())
+ uint8 j = (preferredSlot + i) % MAX_UNIT_ACTION_BAR_INDEX;
+ if (!PetActionBar[j].GetAction() && PetActionBar[j].IsActionBarForSpell())
{
- SetActionBar(i, spell_id, newstate == ACT_DECIDE ? spellInfo->IsAutocastable() ? ACT_DISABLED : ACT_PASSIVE : newstate);
+ SetActionBar(j, spell_id, newstate == ACT_DECIDE ? spellInfo->IsAutocastable() ? ACT_DISABLED : ACT_PASSIVE : newstate);
return true;
}
}
@@ -15802,7 +15820,7 @@ void Unit::SetFeared(bool apply)
}
if (Player* player = ToPlayer())
- if(!player->HasUnitState(UNIT_STATE_POSSESSED))
+ if (!player->HasUnitState(UNIT_STATE_POSSESSED))
player->SetClientControl(this, !apply);
}
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 39b1c34be55..72f3a6682fa 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1119,7 +1119,7 @@ struct CharmInfo
void InitEmptyActionBar(bool withAttack = true);
//return true if successful
- bool AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate = ACT_DECIDE);
+ bool AddSpellToActionBar(SpellInfo const* spellInfo, ActiveStates newstate = ACT_DECIDE, uint8 preferredSlot = 0);
bool RemoveSpellFromActionBar(uint32 spell_id);
void LoadPetActionBar(const std::string& data);
void BuildActionBar(WorldPacket* data);
@@ -1982,6 +1982,7 @@ class Unit : public WorldObject
int32 CalcSpellDuration(SpellInfo const* spellProto);
int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask);
void ModSpellCastTime(SpellInfo const* spellProto, int32& castTime, Spell* spell = NULL);
+ void ModSpellDurationTime(SpellInfo const* spellProto, int32& castTime, Spell* spell = NULL);
float CalculateLevelPenalty(SpellInfo const* spellProto) const;
void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); }
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 046ce422cd2..b2be5c49b91 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -2347,6 +2347,12 @@ void ObjectMgr::LoadItemTemplates()
itemTemplate.ContainerSlots = uint32(fields[26].GetUInt8());
itemTemplate.StatsCount = uint32(fields[27].GetUInt8());
+ if (itemTemplate.StatsCount > MAX_ITEM_PROTO_STATS)
+ {
+ TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).", entry, itemTemplate.StatsCount, MAX_ITEM_PROTO_STATS);
+ itemTemplate.StatsCount = MAX_ITEM_PROTO_STATS;
+ }
+
for (uint8 i = 0; i < itemTemplate.StatsCount; ++i)
{
itemTemplate.ItemStat[i].ItemStatType = uint32(fields[28 + i*2].GetUInt8());
@@ -2594,12 +2600,6 @@ void ObjectMgr::LoadItemTemplates()
itemTemplate.ContainerSlots = MAX_BAG_SIZE;
}
- if (itemTemplate.StatsCount > MAX_ITEM_PROTO_STATS)
- {
- TC_LOG_ERROR("sql.sql", "Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).", entry, itemTemplate.StatsCount, MAX_ITEM_PROTO_STATS);
- itemTemplate.StatsCount = MAX_ITEM_PROTO_STATS;
- }
-
for (uint8 j = 0; j < itemTemplate.StatsCount; ++j)
{
// for ItemStatValue != 0
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index e5b32f548f9..60ec60443d6 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -642,7 +642,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), createInfo->Name.c_str(), newChar.GetGUID().GetCounter());
sScriptMgr->OnPlayerCreate(&newChar);
- sWorld->AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel());
+ sWorld->AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.GetByteValue(PLAYER_BYTES_3, 0), newChar.getRace(), newChar.getClass(), newChar.getLevel());
newChar.CleanupsBeforeDelete();
delete createInfo;
@@ -1242,20 +1242,20 @@ void WorldSession::HandleAlterAppearance(WorldPacket& recvData)
BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair);
- if (!bs_hair || bs_hair->type != 0 || bs_hair->race != _player->getRace() || bs_hair->gender != _player->getGender())
+ if (!bs_hair || bs_hair->type != 0 || bs_hair->race != _player->getRace() || bs_hair->gender != _player->GetByteValue(PLAYER_BYTES_3, 0))
return;
BarberShopStyleEntry const* bs_facialHair = sBarberShopStyleStore.LookupEntry(FacialHair);
- if (!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->getGender())
+ if (!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->GetByteValue(PLAYER_BYTES_3, 0))
return;
BarberShopStyleEntry const* bs_skinColor = sBarberShopStyleStore.LookupEntry(SkinColor);
- if (bs_skinColor && (bs_skinColor->type != 3 || bs_skinColor->race != _player->getRace() || bs_skinColor->gender != _player->getGender()))
+ if (bs_skinColor && (bs_skinColor->type != 3 || bs_skinColor->race != _player->getRace() || bs_skinColor->gender != _player->GetByteValue(PLAYER_BYTES_3, 0)))
return;
- if (!Player::ValidateAppearance(_player->getRace(), _player->getClass(), _player->getGender(), bs_hair->hair_id, Color, _player->GetByteValue(PLAYER_BYTES, 1), bs_facialHair->hair_id, bs_skinColor ? bs_skinColor->hair_id : _player->GetByteValue(PLAYER_BYTES, 0)))
+ if (!Player::ValidateAppearance(_player->getRace(), _player->getClass(), _player->GetByteValue(PLAYER_BYTES_3, 0), bs_hair->hair_id, Color, _player->GetByteValue(PLAYER_BYTES, 1), bs_facialHair->hair_id, bs_skinColor ? bs_skinColor->hair_id : _player->GetByteValue(PLAYER_BYTES, 0)))
return;
GameObject* go = _player->FindNearestGameObjectOfType(GAMEOBJECT_TYPE_BARBER_CHAIR, 5.0f);
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 2eebbfc1004..6dcd3242a6c 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -283,7 +283,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData)
continue;
uint32 pzoneid = target->GetZoneId();
- uint8 gender = target->getGender();
+ uint8 gender = target->GetByteValue(PLAYER_BYTES_3, 0);
bool z_show = true;
for (uint32 i = 0; i < zones_count; ++i)
diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h
index de117905b3d..85971396619 100644
--- a/src/server/game/Miscellaneous/Language.h
+++ b/src/server/game/Miscellaneous/Language.h
@@ -1202,7 +1202,8 @@ enum TrinityStrings
LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD = 11007,
LANG_NPCINFO_INHABIT_TYPE = 11008,
- LANG_NPCINFO_FLAGS_EXTRA = 11009
+ LANG_NPCINFO_FLAGS_EXTRA = 11009,
+ LANG_INSTANCE_LOGIN_GAMEMASTER_EXCEPTION = 11010
};
#endif
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index b1a043c4b5b..1ccd6a4151f 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -341,7 +341,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player has not logged in yet");
else if (_player->IsInWorld())
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world");
- else if(AntiDOS.EvaluateOpcode(*packet, currentTime))
+ else if (AntiDOS.EvaluateOpcode(*packet, currentTime))
{
sScriptMgr->OnPacketReceive(this, *packet);
(this->*opHandle.handler)(*packet);
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 5e70d953be9..200e16a9666 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -541,10 +541,7 @@ void AuraEffect::CalculatePeriodic(Unit* caster, bool create, bool load)
{
// Haste modifies periodic time of channeled spells
if (m_spellInfo->IsChanneled())
- {
- if (m_spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))
- caster->ModSpellCastTime(m_spellInfo, m_amplitude);
- }
+ caster->ModSpellDurationTime(m_spellInfo, m_amplitude);
// and periodic time of auras affected by SPELL_AURA_PERIODIC_HASTE
else if (caster->HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, m_spellInfo) || m_spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))
m_amplitude = int32(m_amplitude * caster->GetFloatValue(UNIT_MOD_CAST_SPEED));
@@ -1866,43 +1863,43 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
{
// Blood Elf
case RACE_BLOODELF:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 17829 : 17830);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 17830 : 17829);
break;
// Orc
case RACE_ORC:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 10139 : 10140);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 10140 : 10139);
break;
// Troll
case RACE_TROLL:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 10135 : 10134);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 10134 : 10135);
break;
// Tauren
case RACE_TAUREN:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 10136 : 10147);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 10147 : 10136);
break;
// Undead
case RACE_UNDEAD_PLAYER:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 10146 : 10145);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 10145 : 10146);
break;
// Draenei
case RACE_DRAENEI:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 17827 : 17828);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 17828 : 17827);
break;
// Dwarf
case RACE_DWARF:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 10141 : 10142);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 10142 : 10141);
break;
// Gnome
case RACE_GNOME:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 10148 : 10149);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 10149 : 10148);
break;
// Human
case RACE_HUMAN:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 10137 : 10138);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 10138 : 10137);
break;
// Night Elf
case RACE_NIGHTELF:
- target->SetDisplayId(target->getGender() == GENDER_MALE ? 10143 : 10144);
+ target->SetDisplayId(target->getGender() == GENDER_FEMALE ? 10144 : 10143);
break;
default:
break;
@@ -4646,17 +4643,10 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
{
if (caster)
{
- switch (caster->getGender())
- {
- case GENDER_FEMALE:
- caster->CastSpell(target, 37095, true, NULL, this); // Blood Elf Disguise
- break;
- case GENDER_MALE:
- caster->CastSpell(target, 37093, true, NULL, this);
- break;
- default:
- break;
- }
+ if (caster->getGender() == GENDER_FEMALE)
+ caster->CastSpell(target, 37095, true, NULL, this); // Blood Elf Disguise
+ else
+ caster->CastSpell(target, 37093, true, NULL, this);
}
break;
}
@@ -4686,15 +4676,10 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
case 46354: // Blood Elf Illusion
if (caster)
{
- switch (caster->getGender())
- {
- case GENDER_FEMALE:
- caster->CastSpell(target, 46356, true, NULL, this);
- break;
- case GENDER_MALE:
- caster->CastSpell(target, 46355, true, NULL, this);
- break;
- }
+ if (caster->getGender() == GENDER_FEMALE)
+ caster->CastSpell(target, 46356, true, NULL, this);
+ else
+ caster->CastSpell(target, 46355, true, NULL, this);
}
break;
case 46361: // Reinforced Net
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 7c9d956edd2..4f3b60d6f37 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2429,9 +2429,8 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
{
m_caster->CombatStart(unit, !m_spellInfo->HasAttribute(SPELL_ATTR3_NO_INITIAL_AGGRO));
- if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_AURA_CC))
- if (!unit->IsStandState())
- unit->SetStandState(UNIT_STAND_STATE_STAND);
+ if (!unit->IsStandState())
+ unit->SetStandState(UNIT_STAND_STATE_STAND);
}
if (spellHitTarget)
@@ -2515,8 +2514,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
if (m_caster->_IsValidAttackTarget(unit, m_spellInfo))
{
unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL);
- /// @todo This is a hack. But we do not know what types of stealth should be interrupted by CC
- if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_AURA_CC) && unit->IsControlledByPlayer())
+
+ if (!m_spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH))
unit->RemoveAurasByType(SPELL_AURA_MOD_STEALTH);
}
else if (m_caster->IsFriendlyTo(unit))
@@ -2625,7 +2624,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
// Haste modifies duration of channeled spells
if (m_spellInfo->IsChanneled())
- m_originalCaster->ModSpellCastTime(aurSpellInfo, duration, this);
+ m_originalCaster->ModSpellDurationTime(aurSpellInfo, duration, this);
// and duration of auras affected by SPELL_AURA_PERIODIC_HASTE
else if (m_originalCaster->HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, aurSpellInfo) || m_spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))
duration = int32(duration * m_originalCaster->GetFloatValue(UNIT_MOD_CAST_SPEED));
@@ -3259,7 +3258,7 @@ void Spell::handle_immediate()
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
// Apply haste mods
- m_caster->ModSpellCastTime(m_spellInfo, duration, this);
+ m_caster->ModSpellDurationTime(m_spellInfo, duration, this);
m_spellState = SPELL_STATE_CASTING;
m_caster->AddInterruptMask(m_spellInfo->ChannelInterruptFlags);
diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp
index 0dd4ff8c100..ed5c31c25c6 100644
--- a/src/server/game/Spells/SpellHistory.cpp
+++ b/src/server/game/Spells/SpellHistory.cpp
@@ -471,7 +471,7 @@ bool SpellHistory::HasCooldown(SpellInfo const* spellInfo, uint32 itemId /*= 0*/
return true;
uint32 category = 0;
- GetCooldownDurations(spellInfo, itemId, nullptr, &itemId, nullptr);
+ GetCooldownDurations(spellInfo, itemId, nullptr, &category, nullptr);
if (!category)
return false;
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index 241e7df9544..d042f926d02 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -176,7 +176,7 @@ enum SpellCustomAttributes
SPELL_ATTR0_CU_CONE_LINE = 0x00000004,
SPELL_ATTR0_CU_SHARE_DAMAGE = 0x00000008,
SPELL_ATTR0_CU_NO_INITIAL_THREAT = 0x00000010,
- SPELL_ATTR0_CU_AURA_CC = 0x00000040,
+ SPELL_ATTR0_CU_DONT_BREAK_STEALTH = 0x00000040,
SPELL_ATTR0_CU_DIRECT_DAMAGE = 0x00000100,
SPELL_ATTR0_CU_CHARGE = 0x00000200,
SPELL_ATTR0_CU_PICKPOCKET = 0x00000400,
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 6305d0a456f..ec616c1d4c6 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -2801,14 +2801,6 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
{
switch (spellInfo->Effects[j].ApplyAuraName)
{
- case SPELL_AURA_MOD_POSSESS:
- case SPELL_AURA_MOD_CONFUSE:
- case SPELL_AURA_MOD_CHARM:
- case SPELL_AURA_AOE_CHARM:
- case SPELL_AURA_MOD_FEAR:
- case SPELL_AURA_MOD_STUN:
- spellInfo->AttributesCu |= SPELL_ATTR0_CU_AURA_CC;
- break;
case SPELL_AURA_PERIODIC_HEAL:
case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
@@ -2901,22 +2893,6 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
if (spellInfo->SpellVisual[0] == 3879)
spellInfo->AttributesCu |= SPELL_ATTR0_CU_CONE_BACK;
- switch (spellInfo->SpellFamilyName)
- {
- case SPELLFAMILY_WARRIOR:
- // Shout
- if (spellInfo->SpellFamilyFlags[0] & 0x20000 || spellInfo->SpellFamilyFlags[1] & 0x20)
- spellInfo->AttributesCu |= SPELL_ATTR0_CU_AURA_CC;
- break;
- case SPELLFAMILY_DRUID:
- // Roar
- if (spellInfo->SpellFamilyFlags[0] & 0x8)
- spellInfo->AttributesCu |= SPELL_ATTR0_CU_AURA_CC;
- break;
- default:
- break;
- }
-
spellInfo->_InitializeExplicitTargetMask();
}
@@ -2947,6 +2923,11 @@ void SpellMgr::LoadSpellInfoCorrections()
spellInfo->Speed = SPEED_CHARGE;
break;
}
+
+ // Passive talent auras cannot target pets
+ if (spellInfo->IsPassive() && GetTalentSpellCost(i))
+ if (spellInfo->Effects[j].TargetA.GetTarget() == TARGET_UNIT_PET)
+ spellInfo->Effects[j].TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER);
}
if (spellInfo->ActiveIconID == 2158) // flight
diff --git a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp
index 9cecbc31665..9af23f17dca 100644
--- a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp
+++ b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp
@@ -277,145 +277,6 @@ public:
};
/*######
-## npc_anchorite_truuen
-######*/
-
-enum Truuen
-{
- NPC_GHOST_UTHER = 17233,
- NPC_THEL_DANIS = 1854,
- NPC_GHOUL = 1791, //ambush
-
- QUEST_TOMB_LIGHTBRINGER = 9446,
-
- SAY_WP_0 = 0, //Beware! We are attacked!
- SAY_WP_1 = 1, //It must be the purity of the Mark of the Lightbringer that is drawing forth the Scourge to attack us. We must proceed with caution lest we be overwhelmed!
- SAY_WP_2 = 2, //This land truly needs to be cleansed by the Light! Let us continue on to the tomb. It isn't far now...
- SAY_WP_3 = 0, //Be welcome, friends!
- SAY_WP_4 = 0, //Thank you for coming here in remembrance of me. Your efforts in recovering that symbol, while unnecessary, are certainly touching to an old man's heart.
- SAY_WP_5 = 1, //Please, rise my friend. Keep the Blessing as a symbol of the strength of the Light and how heroes long gone might once again rise in each of us to inspire.
- SAY_WP_6 = 2 //Thank you my friend for making this possible. This is a day that I shall never forget! I think I will stay a while. Please return to High Priestess MacDonnell at the camp. I know that she'll be keenly interested to know of what has transpired here.
-};
-
-class npc_anchorite_truuen : public CreatureScript
-{
-public:
- npc_anchorite_truuen() : CreatureScript("npc_anchorite_truuen") { }
-
- bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override
- {
- if (quest->GetQuestId() == QUEST_TOMB_LIGHTBRINGER)
- {
- npc_escortAI* pEscortAI = ENSURE_AI(npc_anchorite_truuen::npc_anchorite_truuenAI, creature->AI());
- pEscortAI->Start(true, true, player->GetGUID());
- }
- return false;
- }
-
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npc_anchorite_truuenAI(creature);
- }
-
- struct npc_anchorite_truuenAI : public npc_escortAI
- {
- npc_anchorite_truuenAI(Creature* creature) : npc_escortAI(creature)
- {
- Initialize();
- }
-
- void Initialize()
- {
- m_uiChatTimer = 7000;
- }
-
- uint32 m_uiChatTimer;
-
- ObjectGuid UghostGUID;
-
- void Reset() override
- {
- Initialize();
- }
-
- void JustSummoned(Creature* summoned) override
- {
- if (summoned->GetEntry() == NPC_GHOUL)
- summoned->AI()->AttackStart(me);
- }
-
- void WaypointReached(uint32 waypointId) override
- {
- Player* player = GetPlayerForEscort();
-
- switch (waypointId)
- {
- case 8:
- Talk(SAY_WP_0);
- me->SummonCreature(NPC_GHOUL, me->GetPositionX()+7.0f, me->GetPositionY()+7.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000);
- me->SummonCreature(NPC_GHOUL, me->GetPositionX()+5.0f, me->GetPositionY()+5.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000);
- break;
- case 9:
- Talk(SAY_WP_1);
- break;
- case 14:
- me->SummonCreature(NPC_GHOUL, me->GetPositionX()+7.0f, me->GetPositionY()+7.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000);
- me->SummonCreature(NPC_GHOUL, me->GetPositionX()+5.0f, me->GetPositionY()+5.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000);
- me->SummonCreature(NPC_GHOUL, me->GetPositionX()+10.0f, me->GetPositionY()+10.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000);
- me->SummonCreature(NPC_GHOUL, me->GetPositionX()+8.0f, me->GetPositionY()+8.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000);
- break;
- case 15:
- Talk(SAY_WP_2);
- break;
- case 21:
- if (Creature* Theldanis = GetClosestCreatureWithEntry(me, NPC_THEL_DANIS, 150))
- Theldanis->AI()->Talk(SAY_WP_3);
- break;
- case 23:
- if (Creature* Ughost = me->SummonCreature(NPC_GHOST_UTHER, 971.86f, -1825.42f, 81.99f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000))
- {
- UghostGUID = Ughost->GetGUID();
- Ughost->SetDisableGravity(true);
- Ughost->AI()->Talk(SAY_WP_4, me);
- }
- m_uiChatTimer = 4000;
- break;
- case 24:
- if (Creature* Ughost = ObjectAccessor::GetCreature(*me, UghostGUID))
- Ughost->AI()->Talk(SAY_WP_5, me);
- m_uiChatTimer = 4000;
- break;
- case 25:
- if (Creature* Ughost = ObjectAccessor::GetCreature(*me, UghostGUID))
- Ughost->AI()->Talk(SAY_WP_6, me);
- m_uiChatTimer = 4000;
- break;
- case 26:
- if (player)
- player->GroupEventHappens(QUEST_TOMB_LIGHTBRINGER, me);
- break;
- }
- }
-
- void EnterCombat(Unit* /*who*/) override { }
-
- void JustDied(Unit* /*killer*/) override
- {
- if (Player* player = GetPlayerForEscort())
- player->FailQuest(QUEST_TOMB_LIGHTBRINGER);
- }
-
- void UpdateAI(uint32 uiDiff) override
- {
- npc_escortAI::UpdateAI(uiDiff);
- DoMeleeAttackIfReady();
- if (HasEscortState(STATE_ESCORT_ESCORTING))
- m_uiChatTimer = 6000;
- }
- };
-};
-
-/*######
##
######*/
@@ -425,5 +286,4 @@ void AddSC_western_plaguelands()
new npc_myranda_the_hag();
new npc_the_scourge_cauldron();
new npc_andorhal_tower();
- new npc_anchorite_truuen();
}
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
index 47569a6b85f..11fe5f41455 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
@@ -197,7 +197,7 @@ public:
if (!guardCorpses.empty())
{
if (ObjectGuid target = Trinity::Containers::SelectRandomContainerElement(guardCorpses))
- if(Creature* creatureTarget = ObjectAccessor::GetCreature(*me, target))
+ if (Creature* creatureTarget = ObjectAccessor::GetCreature(*me, target))
{
creatureTarget->CastSpell(creatureTarget, SPELL_SUMMON_CORPSE_SCARABS_MOB, true, nullptr, nullptr, me->GetGUID());
creatureTarget->AI()->Talk(EMOTE_SCARAB);
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp
index 106661b70bf..7b3a9f8ac74 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp
@@ -155,7 +155,7 @@ public:
void KilledUnit(Unit* victim) override
{
- if(victim->GetTypeId() == TYPEID_PLAYER)
+ if (victim->GetTypeId() == TYPEID_PLAYER)
Talk(SAY_SLAY);
}
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
index 50077fe9dc1..5d9ef449168 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
@@ -173,7 +173,8 @@ public:
events.SetPhase(PHASE_NOT_ENGAGED);
SetCombatMovement(false);
- BeginResetEncounter(); // initialize everything properly, and ensure that the coils are loaded by the time we initialize
+ // initialize everything properly, and ensure that the coils are loaded by the time we initialize
+ BeginResetEncounter(true);
}
}
@@ -185,7 +186,7 @@ public:
void Reset() override
{
- if(events.IsInPhase(PHASE_TRANSITION) || events.IsInPhase(PHASE_THADDIUS))
+ if (events.IsInPhase(PHASE_TRANSITION) || (events.IsInPhase(PHASE_THADDIUS) && me->IsAlive()))
BeginResetEncounter();
}
@@ -278,15 +279,16 @@ public:
events.ScheduleEvent(EVENT_TRANSITION_3, 14 * IN_MILLISECONDS, 0, PHASE_TRANSITION);
}
- void BeginResetEncounter()
+ void BeginResetEncounter(bool initial = false)
{
- if (!me->IsAlive())
+ if (instance->GetBossState(BOSS_THADDIUS) == DONE)
return;
if (events.IsInPhase(PHASE_RESETTING))
return;
-
- instance->ProcessEvent(me, EVENT_THADDIUS_BEGIN_RESET);
+ if (initial) // signal shorter spawn timer to instance script
+ instance->SetBossState(BOSS_THADDIUS, SPECIAL);
+ instance->ProcessEvent(me, EVENT_THADDIUS_BEGIN_RESET);
instance->SetBossState(BOSS_THADDIUS, NOT_STARTED);
// remove polarity shift debuffs on reset
@@ -307,17 +309,19 @@ public:
void ResetEncounter()
{
- events.SetPhase(PHASE_NOT_ENGAGED);
feugenAlive = true;
stalaggAlive = true;
+
me->Respawn(true);
- me->CastSpell(me, SPELL_THADDIUS_INACTIVE_VISUAL);
+ _Reset();
+ events.SetPhase(PHASE_NOT_ENGAGED);
+
+ me->CastSpell(me, SPELL_THADDIUS_INACTIVE_VISUAL, true);
if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
feugen->AI()->DoAction(ACTION_RESET_ENCOUNTER);
if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
stalagg->AI()->DoAction(ACTION_RESET_ENCOUNTER);
- _Reset();
}
void UpdateAI(uint32 diff) override
@@ -636,7 +640,7 @@ public:
void UpdateAI(uint32 uiDiff) override
{
- if(!isFeignDeath)
+ if (!isFeignDeath)
if (!UpdateVictim())
return;
@@ -653,7 +657,7 @@ public:
else
powerSurgeTimer -= uiDiff;
- if(!isFeignDeath)
+ if (!isFeignDeath)
DoMeleeAttackIfReady();
}
@@ -821,7 +825,7 @@ public:
void KilledUnit(Unit* victim) override
{
- if(victim->GetTypeId() == TYPEID_PLAYER)
+ if (victim->GetTypeId() == TYPEID_PLAYER)
Talk(SAY_FEUGEN_SLAY);
}
diff --git a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
index 60999d1d883..53ce68d3efc 100644
--- a/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
@@ -188,14 +188,15 @@ class instance_naxxramas : public InstanceMapScript
AddMinion(creature, false);
}
- void ProcessEvent(WorldObject* source, uint32 eventId) override
+ void ProcessEvent(WorldObject* /*source*/, uint32 eventId) override
{
switch (eventId)
{
case EVENT_THADDIUS_BEGIN_RESET:
- if (!source->ToCreature() || source->ToCreature()->GetEntry() != NPC_THADDIUS)
- return;
- events.ScheduleEvent(EVENT_THADDIUS_RESET, 30 * IN_MILLISECONDS);
+ if (GetBossState(BOSS_THADDIUS) == SPECIAL) // this is the initial spawn, we want a shorter spawn time
+ events.ScheduleEvent(EVENT_THADDIUS_RESET, 5 * IN_MILLISECONDS);
+ else
+ events.ScheduleEvent(EVENT_THADDIUS_RESET, 30 * IN_MILLISECONDS);
break;
}
}
diff --git a/src/server/scripts/Northrend/Naxxramas/naxxramas.h b/src/server/scripts/Northrend/Naxxramas/naxxramas.h
index 9c5a4afba91..d2b99784953 100644
--- a/src/server/scripts/Northrend/Naxxramas/naxxramas.h
+++ b/src/server/scripts/Northrend/Naxxramas/naxxramas.h
@@ -175,7 +175,7 @@ enum InstanceEvents
EVENT_DIALOGUE_GOTHIK_KORTHAZZ2,
EVENT_DIALOGUE_GOTHIK_RIVENDARE2,
- // Thaddius AI requesting timed encounter respawn
+ // Thaddius AI requesting timed encounter (re-)spawn
EVENT_THADDIUS_BEGIN_RESET,
EVENT_THADDIUS_RESET,
diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
index cc9af9413e5..33ffea4993b 100644
--- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
+++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
@@ -1244,8 +1244,9 @@ public:
++_wpCount;
}
else if (Vehicle* hoverDisk = me->GetVehicleKit())
- if (Unit* lordPassenger = hoverDisk->GetPassenger(0))
- lordPassenger->ToCreature()->AI()->DoAction(ACTION_SET_DISK_VICTIM_CHASE);
+ if (Unit* passenger = hoverDisk->GetPassenger(0))
+ if (Creature* lordPassenger = passenger->ToCreature())
+ lordPassenger->AI()->DoAction(ACTION_SET_DISK_VICTIM_CHASE);
}
private:
diff --git a/src/tools/map_extractor/CMakeLists.txt b/src/tools/map_extractor/CMakeLists.txt
index 87d68cc7a2f..b10956b3264 100644
--- a/src/tools/map_extractor/CMakeLists.txt
+++ b/src/tools/map_extractor/CMakeLists.txt
@@ -9,13 +9,16 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-file(GLOB_RECURSE sources *.cpp *.h)
+file(GLOB_RECURSE mapextractor_SRCS *.cpp *.h)
set(include_Dirs
- ${CMAKE_SOURCE_DIR}/src/server/shared
- ${CMAKE_SOURCE_DIR}/dep/libmpq
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/loadlib
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/dep/cppformat
+ ${CMAKE_SOURCE_DIR}/dep/libmpq
+ ${CMAKE_SOURCE_DIR}/src/common
+ ${CMAKE_SOURCE_DIR}/src/common/Utilities
+ ${CMAKE_SOURCE_DIR}/src/server/shared
+ ${CMAKE_CURRENT_SOURCE_DIR}/loadlib
)
if( WIN32 )
@@ -28,13 +31,16 @@ endif()
include_directories(${include_Dirs})
add_executable(mapextractor
- ${sources}
+ ${mapextractor_SRCS}
)
target_link_libraries(mapextractor
+ common
+ format
mpq
${BZIP2_LIBRARIES}
${ZLIB_LIBRARIES}
+ ${Boost_LIBRARIES}
)
if( UNIX )
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index dcaa3ba0a76..c0497a1cefb 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -22,36 +22,17 @@
#include <deque>
#include <set>
#include <cstdlib>
-
-#ifdef _WIN32
-#include "direct.h"
-#else
-#include <sys/stat.h>
-#include <unistd.h>
-#endif
+#include <fstream>
#include "dbcfile.h"
#include "mpq_libmpq04.h"
+#include "StringFormat.h"
#include "adt.h"
#include "wdt.h"
-#include <fcntl.h>
-
-#if defined( __GNUC__ )
- #define _open open
- #define _close close
- #ifndef O_BINARY
- #define O_BINARY 0
- #endif
-#else
- #include <io.h>
-#endif
-
-#ifdef O_LARGEFILE
- #define OPEN_FLAGS (O_RDONLY | O_BINARY | O_LARGEFILE)
-#else
- #define OPEN_FLAGS (O_RDONLY | O_BINARY)
-#endif
+
+#include <boost/filesystem.hpp>
+
extern ArchiveSet gOpenArchives;
typedef struct
@@ -106,37 +87,14 @@ const char *CONF_mpq_list[]={
static const char* const langs[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" };
#define LANG_COUNT 12
-void CreateDir( const std::string& Path )
-{
- if(chdir(Path.c_str()) == 0)
- {
- chdir("../");
- return;
- }
-
- int ret;
- #ifdef _WIN32
- ret = _mkdir( Path.c_str());
- #else
- ret = mkdir( Path.c_str(), 0777 );
- #endif
- if (ret != 0)
- {
- printf("Fatal Error: Could not create directory %s check your permissions", Path.c_str());
- exit(1);
- }
-}
-
-bool FileExists( const char* FileName )
+void CreateDir(boost::filesystem::path const& path)
{
- int fp = _open(FileName, OPEN_FLAGS);
- if(fp != -1)
- {
- _close(fp);
- return true;
- }
+ namespace fs = boost::filesystem;
+ if (fs::exists(path))
+ return;
- return false;
+ if (!fs::create_directory(path))
+ throw new std::runtime_error("Unable to create directory" + path.string());
}
void Usage(char* prg)
@@ -207,7 +165,7 @@ void HandleArgs(int argc, char * arg[])
uint32 ReadBuild(int locale)
{
// include build info file also
- std::string filename = std::string("component.wow-")+langs[locale]+".txt";
+ std::string filename = Trinity::StringFormat("component.wow-%s.txt", langs[locale]);
//printf("Read %s file... ", filename.c_str());
MPQFile m(filename.c_str());
@@ -269,7 +227,7 @@ uint32 ReadMapDBC()
strncpy(map_ids[x].name, map_name, max_map_name_length);
map_ids[x].name[max_map_name_length - 1] = '\0';
}
- printf("Done! (%u maps loaded)\n", (uint32)map_count);
+ printf("Done! (" SZFMTD "maps loaded)\n", map_count);
return map_count;
}
@@ -294,7 +252,7 @@ void ReadAreaTableDBC()
maxAreaId = dbc.getMaxId();
- printf("Done! (%u areas loaded)\n", (uint32)area_count);
+ printf("Done! (" SZFMTD " areas loaded)\n", area_count);
}
void ReadLiquidTypeTableDBC()
@@ -315,7 +273,7 @@ void ReadLiquidTypeTableDBC()
for(uint32 x = 0; x < liqTypeCount; ++x)
LiqType[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
- printf("Done! (%u LiqTypes loaded)\n", (uint32)liqTypeCount);
+ printf("Done! (" SZFMTD " LiqTypes loaded)\n", liqTypeCount);
}
//
@@ -414,17 +372,17 @@ uint8 liquid_flags[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
bool liquid_show[ADT_GRID_SIZE][ADT_GRID_SIZE];
float liquid_height[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
-bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/, uint32 build)
+bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int /*cell_y*/, int /*cell_x*/, uint32 build)
{
ADT_file adt;
- if (!adt.loadFile(filename))
+ if (!adt.loadFile(inputPath))
return false;
adt_MCIN *cells = adt.a_grid->getMCIN();
if (!cells)
{
- printf("Can't find cells in '%s'\n", filename);
+ printf("Can't find cells in '%s'\n", inputPath.c_str());
return false;
}
@@ -434,8 +392,8 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
// Prepare map header
map_fileheader map;
- map.mapMagic = *(uint32 const*)MAP_MAGIC;
- map.versionMagic = *(uint32 const*)MAP_VERSION_MAGIC;
+ map.mapMagic = *reinterpret_cast<uint32 const*>(MAP_MAGIC);
+ map.versionMagic = *reinterpret_cast<uint32 const*>(MAP_VERSION_MAGIC);
map.buildMagic = build;
// Get area flags data
@@ -452,7 +410,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
area_flags[i][j] = areas[areaid];
continue;
}
- printf("File: %s\nCan't find area flag for areaid %u [%d, %d].\n", filename, areaid, cell->ix, cell->iy);
+ printf("File: %s\nCan't find area flag for areaid %u [%d, %d].\n", inputPath.c_str(), areaid, cell->ix, cell->iy);
}
area_flags[i][j] = 0xffff;
}
@@ -478,7 +436,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
map.areaMapSize = sizeof(map_areaHeader);
map_areaHeader areaHeader;
- areaHeader.fourcc = *(uint32 const*)MAP_AREA_MAGIC;
+ areaHeader.fourcc = *reinterpret_cast<uint32 const*>(MAP_AREA_MAGIC);
areaHeader.flags = 0;
if (fullAreaData)
{
@@ -488,7 +446,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
else
{
areaHeader.flags |= MAP_AREA_NO_AREA;
- areaHeader.gridArea = (uint16)areaflag;
+ areaHeader.gridArea = static_cast<uint16>(areaflag);
}
//
@@ -607,7 +565,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
map.heightMapSize = sizeof(map_heightHeader);
map_heightHeader heightHeader;
- heightHeader.fourcc = *(uint32 const*)MAP_HEIGHT_MAGIC;
+ heightHeader.fourcc = *reinterpret_cast<uint32 const*>(MAP_HEIGHT_MAGIC);
heightHeader.flags = 0;
heightHeader.gridHeight = minHeight;
heightHeader.gridMaxHeight = maxHeight;
@@ -763,7 +721,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
case LIQUID_TYPE_MAGMA: liquid_flags[i][j] |= MAP_LIQUID_TYPE_MAGMA; break;
case LIQUID_TYPE_SLIME: liquid_flags[i][j] |= MAP_LIQUID_TYPE_SLIME; break;
default:
- printf("\nCan't find Liquid type %u for map %s\nchunk %d,%d\n", h->liquidType, filename, i, j);
+ printf("\nCan't find Liquid type %u for map %s\nchunk %d,%d\n", h->liquidType, inputPath.c_str(), i, j);
break;
}
// Dark water detect
@@ -848,7 +806,7 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
}
map.liquidMapOffset = map.heightMapOffset + map.heightMapSize;
map.liquidMapSize = sizeof(map_liquidHeader);
- liquidHeader.fourcc = *(uint32 const*)MAP_LIQUID_MAGIC;
+ liquidHeader.fourcc = *reinterpret_cast<uint32 const*>(MAP_LIQUID_MAGIC);
liquidHeader.flags = 0;
liquidHeader.liquidType = 0;
liquidHeader.offsetX = minX;
@@ -906,69 +864,72 @@ bool ConvertADT(char *filename, char *filename2, int /*cell_y*/, int /*cell_x*/,
map.holesSize = 0;
// Ok all data prepared - store it
- FILE* output = fopen(filename2, "wb");
- if (!output)
+
+ std::ofstream outFile(outputPath, std::ofstream::out | std::ofstream::binary);
+ if (!outFile)
{
- printf("Can't create the output file '%s'\n", filename2);
+ printf("Can't create the output file '%s'\n", outputPath.c_str());
return false;
}
- fwrite(&map, sizeof(map), 1, output);
+
+ outFile.write(reinterpret_cast<const char*>(&map), sizeof(map));
// Store area data
- fwrite(&areaHeader, sizeof(areaHeader), 1, output);
+ outFile.write(reinterpret_cast<const char*>(&areaHeader), sizeof(areaHeader));
if (!(areaHeader.flags&MAP_AREA_NO_AREA))
- fwrite(area_flags, sizeof(area_flags), 1, output);
+ outFile.write(reinterpret_cast<const char*>(area_flags), sizeof(area_flags));
// Store height data
- fwrite(&heightHeader, sizeof(heightHeader), 1, output);
+ outFile.write(reinterpret_cast<const char*>(&heightHeader), sizeof(heightHeader));
if (!(heightHeader.flags & MAP_HEIGHT_NO_HEIGHT))
{
if (heightHeader.flags & MAP_HEIGHT_AS_INT16)
{
- fwrite(uint16_V9, sizeof(uint16_V9), 1, output);
- fwrite(uint16_V8, sizeof(uint16_V8), 1, output);
+ outFile.write(reinterpret_cast<const char*>(uint16_V9), sizeof(uint16_V9));
+ outFile.write(reinterpret_cast<const char*>(uint16_V8), sizeof(uint16_V8));
}
else if (heightHeader.flags & MAP_HEIGHT_AS_INT8)
{
- fwrite(uint8_V9, sizeof(uint8_V9), 1, output);
- fwrite(uint8_V8, sizeof(uint8_V8), 1, output);
+ outFile.write(reinterpret_cast<const char*>(uint8_V9), sizeof(uint8_V9));
+ outFile.write(reinterpret_cast<const char*>(uint8_V8), sizeof(uint8_V8));
}
else
{
- fwrite(V9, sizeof(V9), 1, output);
- fwrite(V8, sizeof(V8), 1, output);
+ outFile.write(reinterpret_cast<const char*>(V9), sizeof(V9));
+ outFile.write(reinterpret_cast<const char*>(V8), sizeof(V8));
}
}
// Store liquid data if need
if (map.liquidMapOffset)
{
- fwrite(&liquidHeader, sizeof(liquidHeader), 1, output);
+ outFile.write(reinterpret_cast<const char*>(&liquidHeader), sizeof(liquidHeader));
+
if (!(liquidHeader.flags&MAP_LIQUID_NO_TYPE))
{
- fwrite(liquid_entry, sizeof(liquid_entry), 1, output);
- fwrite(liquid_flags, sizeof(liquid_flags), 1, output);
+ outFile.write(reinterpret_cast<const char*>(liquid_entry), sizeof(liquid_entry));
+ outFile.write(reinterpret_cast<const char*>(liquid_flags), sizeof(liquid_flags));
}
+
if (!(liquidHeader.flags&MAP_LIQUID_NO_HEIGHT))
{
- for (int y=0; y<liquidHeader.height;y++)
- fwrite(&liquid_height[y+liquidHeader.offsetY][liquidHeader.offsetX], sizeof(float), liquidHeader.width, output);
+ for (int y = 0; y < liquidHeader.height; y++)
+ outFile.write(reinterpret_cast<const char*>(&liquid_height[y + liquidHeader.offsetY][liquidHeader.offsetX]), sizeof(float) * liquidHeader.width);
}
}
// store hole data
if (hasHoles)
- fwrite(holes, map.holesSize, 1, output);
-
- fclose(output);
+ outFile.write(reinterpret_cast<const char*>(holes), map.holesSize);
+ outFile.close();
return true;
}
void ExtractMapsFromMpq(uint32 build)
{
- char mpq_filename[1024];
- char output_filename[1024];
- char mpq_map_name[1024];
+ std::string mpqFileName;
+ std::string outputFileName;
+ std::string mpqMapName;
printf("Extracting maps...\n");
@@ -986,9 +947,10 @@ void ExtractMapsFromMpq(uint32 build)
{
printf("Extract %s (%d/%u) \n", map_ids[z].name, z+1, map_count);
// Loadup map grid data
- sprintf(mpq_map_name, "World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name);
+
+ mpqMapName = Trinity::StringFormat("World\\Maps\\%s\\%s.wdt", map_ids[z].name, map_ids[z].name);
WDT_file wdt;
- if (!wdt.loadFile(mpq_map_name, false))
+ if (!wdt.loadFile(mpqMapName, false))
{
// printf("Error loading %s map wdt data\n", map_ids[z].name);
continue;
@@ -1000,9 +962,10 @@ void ExtractMapsFromMpq(uint32 build)
{
if (!wdt.main->adt_list[y][x].exist)
continue;
- sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y);
- sprintf(output_filename, "%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x);
- ConvertADT(mpq_filename, output_filename, y, x, build);
+
+ mpqFileName = Trinity::StringFormat("World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y);
+ outputFileName = Trinity::StringFormat("%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x);
+ ConvertADT(mpqFileName, outputFileName, y, x, build);
}
// draw progress bar
printf("Processing........................%d%%\r", (100 * (y+1)) / WDT_MAP_SIZE);
@@ -1038,9 +1001,9 @@ void ExtractDBCFiles(int locale, bool basicLocale)
// get DBC file list
for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i)
{
- vector<string> files;
+ std::vector<std::string> files;
(*i)->GetFileListTo(files);
- for (vector<string>::iterator iter = files.begin(); iter != files.end(); ++iter)
+ for (std::vector<std::string>::iterator iter = files.begin(); iter != files.end(); ++iter)
if (iter->rfind(".dbc") == iter->length() - strlen(".dbc"))
dbcfiles.insert(*iter);
}
@@ -1057,20 +1020,20 @@ void ExtractDBCFiles(int locale, bool basicLocale)
// extract Build info file
{
- string mpq_name = std::string("component.wow-") + langs[locale] + ".txt";
- string filename = path + mpq_name;
+ std::string mpq_name = std::string("component.wow-") + langs[locale] + ".txt";
+ std::string filename = path + mpq_name;
ExtractFile(mpq_name.c_str(), filename);
}
// extract DBCs
uint32 count = 0;
- for (set<string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter)
+ for (std::set<std::string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter)
{
- string filename = path;
+ std::string filename = path;
filename += (iter->c_str() + strlen("DBFilesClient\\"));
- if(FileExists(filename.c_str()))
+ if (boost::filesystem::exists(filename))
continue;
if (ExtractFile(iter->c_str(), filename))
@@ -1081,32 +1044,31 @@ void ExtractDBCFiles(int locale, bool basicLocale)
void LoadLocaleMPQFiles(int const locale)
{
- char filename[512];
+ std::string fileName = Trinity::StringFormat("%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]);
- sprintf(filename,"%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]);
- new MPQArchive(filename);
+ new MPQArchive(fileName.c_str());
for(int i = 1; i < 5; ++i)
{
- char ext[3] = "";
- if(i > 1)
- sprintf(ext, "-%i", i);
+ std::string ext;
+ if (i > 1)
+ ext = Trinity::StringFormat("-%i", i);
- sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ", input_path, langs[locale], langs[locale], ext);
- if(FileExists(filename))
- new MPQArchive(filename);
+ fileName = Trinity::StringFormat("%s/Data/%s/patch-%s%s.MPQ", input_path, langs[locale], langs[locale], ext.c_str());
+ if (boost::filesystem::exists(fileName))
+ new MPQArchive(fileName.c_str());
}
}
void LoadCommonMPQFiles()
{
- char filename[512];
+ std::string fileName;
int count = sizeof(CONF_mpq_list)/sizeof(char*);
for(int i = 0; i < count; ++i)
{
- sprintf(filename, "%s/Data/%s", input_path, CONF_mpq_list[i]);
- if(FileExists(filename))
- new MPQArchive(filename);
+ fileName = Trinity::StringFormat("%s/Data/%s", input_path, CONF_mpq_list[i]);
+ if (boost::filesystem::exists(fileName))
+ new MPQArchive(fileName.c_str());
}
}
@@ -1128,9 +1090,8 @@ int main(int argc, char * arg[])
for (int i = 0; i < LANG_COUNT; i++)
{
- char tmp1[512];
- sprintf(tmp1, "%s/Data/%s/locale-%s.MPQ", input_path, langs[i], langs[i]);
- if (FileExists(tmp1))
+ std::string filename = Trinity::StringFormat("%s/Data/%s/locale-%s.MPQ", input_path, langs[i], langs[i]);
+ if (boost::filesystem::exists(filename))
{
printf("Detected locale: %s\n", langs[i]);
diff --git a/src/tools/map_extractor/loadlib.cpp b/src/tools/map_extractor/loadlib.cpp
index 936cdb72cfd..2f31b472b56 100644
--- a/src/tools/map_extractor/loadlib.cpp
+++ b/src/tools/map_extractor/loadlib.cpp
@@ -38,14 +38,14 @@ FileLoader::~FileLoader()
free();
}
-bool FileLoader::loadFile(char *filename, bool log)
+bool FileLoader::loadFile(std::string const& fileName, bool log)
{
free();
- MPQFile mf(filename);
+ MPQFile mf(fileName.c_str());
if(mf.isEof())
{
if (log)
- printf("No such file %s\n", filename);
+ printf("No such file %s\n", fileName.c_str());
return false;
}
@@ -57,7 +57,7 @@ bool FileLoader::loadFile(char *filename, bool log)
if (prepareLoadedData())
return true;
- printf("Error loading %s", filename);
+ printf("Error loading %s", fileName.c_str());
mf.close();
free();
return false;
diff --git a/src/tools/map_extractor/loadlib/loadlib.h b/src/tools/map_extractor/loadlib/loadlib.h
index a0b62a85983..6547704d885 100644
--- a/src/tools/map_extractor/loadlib/loadlib.h
+++ b/src/tools/map_extractor/loadlib/loadlib.h
@@ -19,31 +19,9 @@
#ifndef LOAD_LIB_H
#define LOAD_LIB_H
-#ifdef _WIN32
-typedef __int64 int64;
-typedef __int32 int32;
-typedef __int16 int16;
-typedef __int8 int8;
-typedef unsigned __int64 uint64;
-typedef unsigned __int32 uint32;
-typedef unsigned __int16 uint16;
-typedef unsigned __int8 uint8;
-#else
-#include <stdint.h>
-#ifndef uint64_t
-#ifdef __linux__
-#include <linux/types.h>
-#endif
-#endif
-typedef int64_t int64;
-typedef int32_t int32;
-typedef int16_t int16;
-typedef int8_t int8;
-typedef uint64_t uint64;
-typedef uint32_t uint32;
-typedef uint16_t uint16;
-typedef uint8_t uint8;
-#endif
+#include "Define.h"
+
+#include <string>
#define FILE_FORMAT_VERSION 18
@@ -79,7 +57,7 @@ public:
file_MVER *version;
FileLoader();
~FileLoader();
- bool loadFile(char *filename, bool log = true);
+ bool loadFile(std::string const& fileName, bool log = true);
virtual void free();
};
diff --git a/src/tools/map_extractor/mpq_libmpq04.h b/src/tools/map_extractor/mpq_libmpq04.h
index c6fe36a8221..b9b332f95b0 100644
--- a/src/tools/map_extractor/mpq_libmpq04.h
+++ b/src/tools/map_extractor/mpq_libmpq04.h
@@ -27,8 +27,6 @@
#include <iostream>
#include <deque>
-using namespace std;
-
class MPQArchive
{
@@ -39,7 +37,7 @@ public:
~MPQArchive() { close(); }
void close();
- void GetFileListTo(vector<string>& filelist) {
+ void GetFileListTo(std::vector<std::string>& filelist) {
uint32_t filenum;
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
libmpq__off_t size, transferred;
@@ -58,7 +56,7 @@ public:
while ((token != NULL) && (counter < size)) {
//cout << token << endl;
token[strlen(token) - 1] = 0;
- string s = token;
+ std::string s = token;
filelist.push_back(s);
counter += strlen(token) + 2;
token = strtok(NULL, seps);
diff --git a/src/tools/mmaps_generator/IntermediateValues.h b/src/tools/mmaps_generator/IntermediateValues.h
index 95a651a2df8..580e9e43139 100644
--- a/src/tools/mmaps_generator/IntermediateValues.h
+++ b/src/tools/mmaps_generator/IntermediateValues.h
@@ -22,7 +22,6 @@
#include "PathCommon.h"
#include "TerrainBuilder.h"
#include "Recast.h"
-#include "DetourNavMesh.h"
namespace MMAP
{
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp
index 69ca5297024..0c41be65cf7 100644
--- a/src/tools/mmaps_generator/MapBuilder.cpp
+++ b/src/tools/mmaps_generator/MapBuilder.cpp
@@ -15,17 +15,15 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <limits.h>
#include "PathCommon.h"
#include "MapBuilder.h"
-
#include "MapTree.h"
-#include "ModelInstance.h"
-
#include "DetourNavMeshBuilder.h"
#include "DetourNavMesh.h"
-#include "DetourCommon.h"
+#include "IntermediateValues.h"
+
+#include <limits.h>
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
#define MMAP_VERSION 5
@@ -164,7 +162,7 @@ namespace MMAP
{
while (1)
{
- uint32 mapId;
+ uint32 mapId = 0;
_queue.WaitAndPop(mapId);
@@ -215,12 +213,14 @@ namespace MMAP
}
/**************************************************************************/
- void MapBuilder::getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY)
+ void MapBuilder::getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY) const
{
- maxX = INT_MAX;
- maxY = INT_MAX;
- minX = INT_MIN;
- minY = INT_MIN;
+ // min and max are initialized to invalid values so the caller iterating the [min, max] range
+ // will never enter the loop unless valid min/max values are found
+ maxX = 0;
+ maxY = 0;
+ minX = std::numeric_limits<uint32>::max();
+ minY = std::numeric_limits<uint32>::max();
float bmin[3] = { 0, 0, 0 };
float bmax[3] = { 0, 0, 0 };
diff --git a/src/tools/mmaps_generator/MapBuilder.h b/src/tools/mmaps_generator/MapBuilder.h
index ced03d1dde8..432a0ee7489 100644
--- a/src/tools/mmaps_generator/MapBuilder.h
+++ b/src/tools/mmaps_generator/MapBuilder.h
@@ -19,20 +19,18 @@
#ifndef _MAP_BUILDER_H
#define _MAP_BUILDER_H
-#include <vector>
-#include <set>
-#include <map>
-#include <list>
-#include <atomic>
-#include <thread>
-
#include "TerrainBuilder.h"
-#include "IntermediateValues.h"
#include "Recast.h"
#include "DetourNavMesh.h"
#include "ProducerConsumerQueue.h"
+#include <vector>
+#include <set>
+#include <list>
+#include <atomic>
+#include <thread>
+
using namespace VMAP;
namespace MMAP
@@ -120,7 +118,7 @@ namespace MMAP
void getTileBounds(uint32 tileX, uint32 tileY,
float* verts, int vertCount,
float* bmin, float* bmax);
- void getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY);
+ void getGridBounds(uint32 mapID, uint32 &minX, uint32 &minY, uint32 &maxX, uint32 &maxY) const;
bool shouldSkipMap(uint32 mapID);
bool isTransportMap(uint32 mapID);
diff --git a/src/tools/mmaps_generator/PathCommon.h b/src/tools/mmaps_generator/PathCommon.h
index 9451e9d03ba..aa9591fba22 100644
--- a/src/tools/mmaps_generator/PathCommon.h
+++ b/src/tools/mmaps_generator/PathCommon.h
@@ -19,11 +19,10 @@
#ifndef _MMAP_COMMON_H
#define _MMAP_COMMON_H
-#include <string>
-#include <vector>
-
#include "Common.h"
+#include <vector>
+
#ifndef _WIN32
#include <stddef.h>
#include <dirent.h>
diff --git a/src/tools/mmaps_generator/TerrainBuilder.cpp b/src/tools/mmaps_generator/TerrainBuilder.cpp
index 9043627994b..e525f24fced 100644
--- a/src/tools/mmaps_generator/TerrainBuilder.cpp
+++ b/src/tools/mmaps_generator/TerrainBuilder.cpp
@@ -764,12 +764,12 @@ namespace MMAP
}
uint32 liqOffset = meshData.liquidVerts.size() / 3;
- for (uint32 i = 0; i < liqVerts.size(); ++i)
- meshData.liquidVerts.append(liqVerts[i].y, liqVerts[i].z, liqVerts[i].x);
+ for (uint32 j = 0; j < liqVerts.size(); ++j)
+ meshData.liquidVerts.append(liqVerts[j].y, liqVerts[j].z, liqVerts[j].x);
- for (uint32 i = 0; i < liqTris.size() / 3; ++i)
+ for (uint32 j = 0; j < liqTris.size() / 3; ++j)
{
- meshData.liquidTris.append(liqTris[i*3+1] + liqOffset, liqTris[i*3+2] + liqOffset, liqTris[i*3] + liqOffset);
+ meshData.liquidTris.append(liqTris[j*3+1] + liqOffset, liqTris[j*3+2] + liqOffset, liqTris[j*3] + liqOffset);
meshData.liquidType.append(type);
}
}
diff --git a/src/tools/mmaps_generator/TerrainBuilder.h b/src/tools/mmaps_generator/TerrainBuilder.h
index 6c66ae45f46..f305bf0bd48 100644
--- a/src/tools/mmaps_generator/TerrainBuilder.h
+++ b/src/tools/mmaps_generator/TerrainBuilder.h
@@ -81,11 +81,13 @@ namespace MMAP
TerrainBuilder(bool skipLiquid);
~TerrainBuilder();
+ TerrainBuilder(const TerrainBuilder &tb) = delete;
+
void loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData);
bool loadVMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData);
void loadOffMeshConnections(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData, const char* offMeshFilePath);
- bool usesLiquids() { return !m_skipLiquid; }
+ bool usesLiquids() const { return !m_skipLiquid; }
// vert and triangle methods
static void transform(std::vector<G3D::Vector3> &original, std::vector<G3D::Vector3> &transformed,
@@ -104,9 +106,6 @@ namespace MMAP
/// Controls whether liquids are loaded
bool m_skipLiquid;
- /// Load the map terrain from file
- bool loadHeightMap(uint32 mapID, uint32 tileX, uint32 tileY, G3D::Array<float> &vertices, G3D::Array<int> &triangles, Spot portion);
-
/// Get the vector coordinate for a specific position
void getHeightCoord(int index, Grid grid, float xOffset, float yOffset, float* coord, float* v);
@@ -121,10 +120,6 @@ namespace MMAP
/// Get the liquid type for a specific position
uint8 getLiquidType(int square, const uint8 liquid_type[16][16]);
-
- // hide parameterless and copy constructor
- TerrainBuilder();
- TerrainBuilder(const TerrainBuilder &tb);
};
}
diff --git a/src/tools/vmap4_extractor/adtfile.cpp b/src/tools/vmap4_extractor/adtfile.cpp
index 557511f6d1e..3a8b3495655 100644
--- a/src/tools/vmap4_extractor/adtfile.cpp
+++ b/src/tools/vmap4_extractor/adtfile.cpp
@@ -86,11 +86,11 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
uint32 size;
- string xMap;
- string yMap;
+ std::string xMap;
+ std::string yMap;
Adtfilename.erase(Adtfilename.find(".adt"),4);
- string TempMapNumber;
+ std::string TempMapNumber;
TempMapNumber = Adtfilename.substr(Adtfilename.length()-6,6);
xMap = TempMapNumber.substr(TempMapNumber.find("_")+1,(TempMapNumber.find_last_of("_")-1) - (TempMapNumber.find("_")));
yMap = TempMapNumber.substr(TempMapNumber.find_last_of("_")+1,(TempMapNumber.length()) - (TempMapNumber.find_last_of("_")));
@@ -134,7 +134,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
ADT.read(buf, size);
char *p=buf;
int t=0;
- ModelInstansName = new string[size];
+ ModelInstansName = new std::string[size];
while (p<buf+size)
{
fixnamen(p,strlen(p));
@@ -143,7 +143,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
ModelInstansName[t++] = s;
- string path(p);
+ std::string path(p);
ExtractSingleModel(path);
p = p+strlen(p)+1;
diff --git a/src/tools/vmap4_extractor/mpq_libmpq04.h b/src/tools/vmap4_extractor/mpq_libmpq04.h
index 6196285627d..4c8b4d376ca 100644
--- a/src/tools/vmap4_extractor/mpq_libmpq04.h
+++ b/src/tools/vmap4_extractor/mpq_libmpq04.h
@@ -21,14 +21,12 @@
#include "loadlib/loadlib.h"
#include "libmpq/mpq.h"
+
#include <string.h>
-#include <ctype.h>
+#include <string>
#include <vector>
-#include <iostream>
#include <deque>
-using namespace std;
-
class MPQArchive
{
@@ -38,7 +36,7 @@ public:
MPQArchive(const char* filename);
~MPQArchive() { close(); }
- void GetFileListTo(vector<string>& filelist) {
+ void GetFileListTo(std::vector<std::string>& filelist) {
uint32_t filenum;
if(libmpq__file_number(mpq_a, "(listfile)", &filenum)) return;
libmpq__off_t size, transferred;
@@ -57,7 +55,7 @@ public:
while ((token != NULL) && (counter < size)) {
//cout << token << endl;
token[strlen(token) - 1] = 0;
- string s = token;
+ std::string s = token;
filelist.push_back(s);
counter += strlen(token) + 2;
token = strtok(NULL, seps);
@@ -78,9 +76,8 @@ class MPQFile
char *buffer;
libmpq__off_t pointer,size;
- // disable copying
- MPQFile(const MPQFile& /*f*/) {}
- void operator=(const MPQFile& /*f*/) {}
+ MPQFile(const MPQFile& /*f*/) = delete;
+ void operator=(const MPQFile& /*f*/) = delete;
public:
MPQFile(const char* filename); // filenames are not case sensitive
diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp
index 7a12897563e..78d6e86358f 100644
--- a/src/tools/vmap4_extractor/vmapexport.cpp
+++ b/src/tools/vmap4_extractor/vmapexport.cpp
@@ -17,14 +17,15 @@
*/
#define _CRT_SECURE_NO_DEPRECATE
-#include <cstdio>
-#include <iostream>
-#include <vector>
-#include <list>
-#include <errno.h>
+
+#include "adtfile.h"
+#include "wdtfile.h"
+#include "dbcfile.h"
+#include "wmo.h"
+#include "mpq_libmpq04.h"
+#include "vmapexport.h"
#ifdef WIN32
- #include <Windows.h>
#include <sys/stat.h>
#include <direct.h>
#define mkdir _mkdir
@@ -32,23 +33,14 @@
#include <sys/stat.h>
#endif
+#include <cstdio>
+#include <iostream>
+#include <vector>
+#include <errno.h>
+
#undef min
#undef max
-//#pragma warning(disable : 4505)
-//#pragma comment(lib, "Winmm.lib")
-
-#include <map>
-
-//From Extractor
-#include "adtfile.h"
-#include "wdtfile.h"
-#include "dbcfile.h"
-#include "wmo.h"
-#include "mpq_libmpq04.h"
-
-#include "vmapexport.h"
-
//------------------------------------------------------------------------------
// Defines
@@ -129,12 +121,12 @@ bool ExtractWmo()
for (ArchiveSet::const_iterator ar_itr = gOpenArchives.begin(); ar_itr != gOpenArchives.end() && success; ++ar_itr)
{
- vector<string> filelist;
+ std::vector<std::string> filelist;
(*ar_itr)->GetFileListTo(filelist);
- for (vector<string>::iterator fname = filelist.begin(); fname != filelist.end() && success; ++fname)
+ for (std::vector<std::string>::iterator fname = filelist.begin(); fname != filelist.end() && success; ++fname)
{
- if (fname->find(".wmo") != string::npos)
+ if (fname->find(".wmo") != std::string::npos)
success = ExtractSingleWmo(*fname);
}
}
@@ -203,7 +195,7 @@ bool ExtractSingleWmo(std::string& fname)
sprintf(groupFileName, "%s_%03u.wmo", temp, i);
//printf("Trying to open groupfile %s\n",groupFileName);
- string s = groupFileName;
+ std::string s = groupFileName;
WMOGroup fgroup(s);
if(!fgroup.open())
{
@@ -305,7 +297,7 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
printf("\nGame path: %s\n", input_path);
char path[512];
- string in_path(input_path);
+ std::string in_path(input_path);
std::vector<std::string> locales, searchLocales;
searchLocales.push_back("enGB");
@@ -345,10 +337,10 @@ bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames)
}
// open expansion and common files
- pArchiveNames.push_back(input_path + string("common.MPQ"));
- pArchiveNames.push_back(input_path + string("common-2.MPQ"));
- pArchiveNames.push_back(input_path + string("expansion.MPQ"));
- pArchiveNames.push_back(input_path + string("lichking.MPQ"));
+ pArchiveNames.push_back(input_path + std::string("common.MPQ"));
+ pArchiveNames.push_back(input_path + std::string("common-2.MPQ"));
+ pArchiveNames.push_back(input_path + std::string("expansion.MPQ"));
+ pArchiveNames.push_back(input_path + std::string("lichking.MPQ"));
// now, scan for the patch levels in the core dir
printf("Scanning patch levels from data directory.\n");
diff --git a/src/tools/vmap4_extractor/wdtfile.cpp b/src/tools/vmap4_extractor/wdtfile.cpp
index 877f49ce371..4e0b7b97705 100644
--- a/src/tools/vmap4_extractor/wdtfile.cpp
+++ b/src/tools/vmap4_extractor/wdtfile.cpp
@@ -19,6 +19,7 @@
#include "vmapexport.h"
#include "wdtfile.h"
#include "adtfile.h"
+
#include <cstdio>
char * wdtGetPlainName(char * FileName)
@@ -30,7 +31,7 @@ char * wdtGetPlainName(char * FileName)
return FileName;
}
-WDTFile::WDTFile(char* file_name, char* file_name1) : WDT(file_name), gWmoInstansName(NULL), gnWMO(0)
+WDTFile::WDTFile(char* file_name, char* file_name1) : gWmoInstansName(NULL), gnWMO(0), WDT(file_name)
{
filename.append(file_name1,strlen(file_name1));
}
@@ -77,7 +78,7 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
WDT.read(buf, size);
char *p=buf;
int q = 0;
- gWmoInstansName = new string[size];
+ gWmoInstansName = new std::string[size];
while (p < buf + size)
{
char* s=wdtGetPlainName(p);
diff --git a/src/tools/vmap4_extractor/wdtfile.h b/src/tools/vmap4_extractor/wdtfile.h
index 22702133b95..81e84b36d1e 100644
--- a/src/tools/vmap4_extractor/wdtfile.h
+++ b/src/tools/vmap4_extractor/wdtfile.h
@@ -20,26 +20,25 @@
#define WDTFILE_H
#include "mpq_libmpq04.h"
-#include "wmo.h"
#include <string>
-#include "stdlib.h"
class ADTFile;
class WDTFile
{
-private:
- MPQFile WDT;
- string filename;
public:
WDTFile(char* file_name, char* file_name1);
~WDTFile(void);
+
bool init(char* map_id, unsigned int mapID);
+ ADTFile* GetMap(int x, int z);
- string* gWmoInstansName;
+ std::string* gWmoInstansName;
int gnWMO;
- ADTFile* GetMap(int x, int z);
+private:
+ MPQFile WDT;
+ std::string filename;
};
#endif
diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp
index f6f59bbc475..80dfbb97c5a 100644
--- a/src/tools/vmap4_extractor/wmo.cpp
+++ b/src/tools/vmap4_extractor/wmo.cpp
@@ -19,16 +19,14 @@
#include "vmapexport.h"
#include "wmo.h"
#include "vec3d.h"
+#include "mpq_libmpq04.h"
+
#include <cstdio>
#include <cstdlib>
#include <cassert>
-#include <map>
-#include <fstream>
#undef min
#undef max
-#include "mpq_libmpq04.h"
-using namespace std;
extern uint16 *LiqType;
WMORoot::WMORoot(std::string &filename)