diff options
Diffstat (limited to 'src')
43 files changed, 257 insertions, 322 deletions
diff --git a/src/server/authserver/Authentication/AuthCodes.cpp b/src/server/authserver/Authentication/AuthCodes.cpp index bb278dd6653..55517884b8e 100644 --- a/src/server/authserver/Authentication/AuthCodes.cpp +++ b/src/server/authserver/Authentication/AuthCodes.cpp @@ -79,4 +79,4 @@ namespace AuthHelper return NULL; } -}; +} diff --git a/src/server/authserver/Authentication/AuthCodes.h b/src/server/authserver/Authentication/AuthCodes.h index 5e6522f8981..97b4779da0e 100644 --- a/src/server/authserver/Authentication/AuthCodes.h +++ b/src/server/authserver/Authentication/AuthCodes.h @@ -92,6 +92,6 @@ namespace AuthHelper bool IsAcceptedClientBuild(int build); bool IsPostBCAcceptedClientBuild(int build); bool IsPreBCAcceptedClientBuild(int build); -}; +} #endif diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 098f3130fed..e769b7c22a5 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -618,10 +618,7 @@ void SmartAI::DamageTaken(Unit* doneBy, uint32& damage) { GetScript()->ProcessEventsFor(SMART_EVENT_DAMAGED, doneBy, damage); if (mInvincibilityHpLevel && (damage >= me->GetHealth() - mInvincibilityHpLevel)) - { - damage = 0; - me->SetHealth(mInvincibilityHpLevel); - } + damage = me->GetHealth() - mInvincibilityHpLevel; // damage should not be nullified, because of player damage req. } void SmartAI::HealReceived(Unit* doneBy, uint32& addhealth) diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index 52ed50f3948..a4cb972e625 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -17,7 +17,6 @@ #include "CalendarMgr.h" #include "QueryResult.h" -#include "DatabaseEnv.h" #include "Log.h" #include "Player.h" #include "GuildMgr.h" @@ -128,6 +127,12 @@ void CalendarMgr::AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType s void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite) { + SQLTransaction dummy; + AddInvite(calendarEvent, invite, dummy); +} + +void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite, SQLTransaction& trans) +{ if (!calendarEvent->IsGuildAnnouncement()) SendCalendarEventInvite(*invite); @@ -137,7 +142,7 @@ void CalendarMgr::AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite if (!calendarEvent->IsGuildAnnouncement()) { _invites[invite->GetEventId()].push_back(invite); - UpdateInvite(invite); + UpdateInvite(invite, trans); } } @@ -221,7 +226,6 @@ void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, uint64 /*remover void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent) { - SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_EVENT); stmt->setUInt64(0, calendarEvent->GetEventId()); stmt->setUInt32(1, GUID_LOPART(calendarEvent->GetCreatorGUID())); @@ -232,13 +236,17 @@ void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent) stmt->setUInt32(6, uint32(calendarEvent->GetEventTime())); stmt->setUInt32(7, calendarEvent->GetFlags()); stmt->setUInt32(8, calendarEvent->GetTimeZoneTime()); // correct? - trans->Append(stmt); - CharacterDatabase.CommitTransaction(trans); + CharacterDatabase.Execute(stmt); } void CalendarMgr::UpdateInvite(CalendarInvite* invite) { - SQLTransaction trans = CharacterDatabase.BeginTransaction(); + SQLTransaction dummy; + UpdateInvite(invite, dummy); +} + +void CalendarMgr::UpdateInvite(CalendarInvite* invite, SQLTransaction& trans) +{ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE); stmt->setUInt64(0, invite->GetInviteId()); stmt->setUInt64(1, invite->GetEventId()); @@ -248,8 +256,7 @@ void CalendarMgr::UpdateInvite(CalendarInvite* invite) stmt->setUInt32(5, uint32(invite->GetStatusTime())); stmt->setUInt8(6, invite->GetRank()); stmt->setString(7, invite->GetText()); - trans->Append(stmt); - CharacterDatabase.CommitTransaction(trans); + CharacterDatabase.ExecuteOrAppend(trans, stmt); } void CalendarMgr::RemoveAllPlayerEventsAndInvites(uint64 guid) diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index da185d519d5..8f44b013e5c 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -20,6 +20,7 @@ #include <ace/Singleton.h> #include "Common.h" +#include "DatabaseEnv.h" #include "WorldPacket.h" enum CalendarMailAnswers @@ -305,8 +306,10 @@ class CalendarMgr void UpdateEvent(CalendarEvent* calendarEvent); void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite); + void AddInvite(CalendarEvent* calendarEvent, CalendarInvite* invite, SQLTransaction& trans); void RemoveInvite(uint64 inviteId, uint64 eventId, uint64 remover); void UpdateInvite(CalendarInvite* invite); + void UpdateInvite(CalendarInvite* invite, SQLTransaction& trans); void RemoveAllPlayerEventsAndInvites(uint64 guid); void RemovePlayerGuildEventsAndSignups(uint64 guid, uint32 guildId); diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index 9b0465a4536..44f03b6978d 100644 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -139,6 +139,7 @@ DBCStorage <MovieEntry> sMovieStore(MovieEntryfmt); DBCStorage <OverrideSpellDataEntry> sOverrideSpellDataStore(OverrideSpellDatafmt); +DBCStorage <PowerDisplayEntry> sPowerDisplayStore(PowerDisplayfmt); DBCStorage <PvPDifficultyEntry> sPvPDifficultyStore(PvPDifficultyfmt); DBCStorage <QuestSortEntry> sQuestSortStore(QuestSortEntryfmt); @@ -391,6 +392,7 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales, bad_dbc_files, sOverrideSpellDataStore, dbcPath, "OverrideSpellData.dbc"); + LoadDBC(availableDbcLocales, bad_dbc_files, sPowerDisplayStore, dbcPath, "PowerDisplay.dbc"); LoadDBC(availableDbcLocales, bad_dbc_files, sPvPDifficultyStore, dbcPath, "PvpDifficulty.dbc"); for (uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i) if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i)) diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h index b77db950541..fe775dfda19 100644 --- a/src/server/game/DataStores/DBCStores.h +++ b/src/server/game/DataStores/DBCStores.h @@ -141,6 +141,7 @@ extern DBCStorage <MapEntry> sMapStore; extern MapDifficultyMap sMapDifficultyMap; extern DBCStorage <MovieEntry> sMovieStore; extern DBCStorage <OverrideSpellDataEntry> sOverrideSpellDataStore; +extern DBCStorage <PowerDisplayEntry> sPowerDisplayStore; extern DBCStorage <QuestSortEntry> sQuestSortStore; extern DBCStorage <QuestXPEntry> sQuestXPStore; extern DBCStorage <QuestFactionRewEntry> sQuestFactionRewardStore; diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index abe7bde4bf5..5d6c8c7aa89 100644 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -1398,6 +1398,16 @@ struct OverrideSpellDataEntry //uint32 unk0; // 11 }; +struct PowerDisplayEntry +{ + uint32 Id; // 0 + uint32 PowerType; // 1 + //char* Name; // 2 + //uint32 R; // 3 + //uint32 G; // 4 + //uint32 B; // 5 +}; + struct PvPDifficultyEntry { //uint32 id; // 0 m_ID @@ -1982,7 +1992,7 @@ struct VehicleEntry uint32 m_uiLocomotionType; // 34 float m_msslTrgtImpactTexRadius; // 35 uint32 m_uiSeatIndicatorType; // 36 - uint32 m_powerType; // 37, new in 3.1 + uint32 m_powerDisplayId; // 37, new in 3.1 // 38, new in 3.1 // 39, new in 3.1 }; diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h index 35a8eecb708..222353467f4 100644 --- a/src/server/game/DataStores/DBCfmt.h +++ b/src/server/game/DataStores/DBCfmt.h @@ -91,6 +91,7 @@ char const OverrideSpellDatafmt[] = "niiiiiiiiiix"; char const QuestFactionRewardfmt[] = "niiiiiiiiii"; char const QuestSortEntryfmt[] = "nxxxxxxxxxxxxxxxxx"; char const QuestXPfmt[] = "niiiiiiiiii"; +char const PowerDisplayfmt[] = "nixxxx"; char const PvPDifficultyfmt[] = "diiiii"; char const RandomPropertiesPointsfmt[] = "niiiiiiiiiiiiiii"; char const ScalingStatDistributionfmt[] = "niiiiiiiiiiiiiiiiiiiii"; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 36997eb884a..01621637985 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -569,7 +569,7 @@ void Creature::Update(uint32 diff) if (getPowerType() == POWER_ENERGY) { - if (!IsVehicle() || GetVehicleKit()->GetVehicleInfo()->m_powerType != POWER_PYRITE) + if (!IsVehicle() || GetVehicleKit()->GetVehicleInfo()->m_powerDisplayId != POWER_PYRITE) Regenerate(POWER_ENERGY); } else diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 40488df9ef3..306e4209e4d 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1100,7 +1100,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f SwitchDoorOrButton(true, alternative); SetLootState(GO_ACTIVATED, user); - m_cooldownTime = time(NULL) + time_to_restore; + m_cooldownTime = time_to_restore ? (time(NULL) + time_to_restore) : 0; } void GameObject::SetGoArtKit(uint8 kit) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index e7d14d68377..563d7fed107 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -144,6 +144,8 @@ enum CharacterCustomizeFlags static uint32 copseReclaimDelay[MAX_DEATH_COUNT] = { 30, 60, 120 }; +uint32 const MAX_MONEY_AMOUNT = static_cast<uint32>(std::numeric_limits<int32>::max()); + // == PlayerTaxi ================================================ PlayerTaxi::PlayerTaxi() @@ -22645,7 +22647,7 @@ bool Player::ModifyMoney(int32 amount, bool sendError /*= true*/) SetMoney (GetMoney() > uint32(-amount) ? GetMoney() + amount : 0); else { - if (GetMoney() < uint32(MAX_MONEY_AMOUNT - amount)) + if (GetMoney() < MAX_MONEY_AMOUNT - static_cast<uint32>(amount)) SetMoney(GetMoney() + amount); else { diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 92691c3fd45..0826f533df7 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -29,6 +29,7 @@ #include "SpellMgr.h" #include "Unit.h" +#include <limits> #include <string> #include <vector> @@ -824,7 +825,8 @@ enum PlayerDelayedOperations // Player summoning auto-decline time (in secs) #define MAX_PLAYER_SUMMON_DELAY (2*MINUTE) -#define MAX_MONEY_AMOUNT (0x7FFFFFFF-1) +// Maximum money amount : 2^31 - 1 +extern uint32 const MAX_MONEY_AMOUNT; struct InstancePlayerBind { diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index fae4f0c6b6a..4c3724a8860 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -76,42 +76,9 @@ Vehicle::~Vehicle() void Vehicle::Install() { - if (Creature* creature = _me->ToCreature()) - { - switch (_vehicleInfo->m_powerType) - { - case POWER_STEAM: - case POWER_HEAT: - case POWER_BLOOD: - case POWER_OOZE: - case POWER_WRATH: - _me->setPowerType(POWER_ENERGY); - _me->SetMaxPower(POWER_ENERGY, 100); - break; - case POWER_PYRITE: - _me->setPowerType(POWER_ENERGY); - _me->SetMaxPower(POWER_ENERGY, 50); - break; - default: - for (uint32 i = 0; i < MAX_SPELL_VEHICLE; ++i) - { - if (!creature->m_spells[i]) - continue; - - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(creature->m_spells[i]); - if (!spellInfo) - continue; - - if (spellInfo->PowerType == POWER_ENERGY && spellInfo->CalcPowerCost(_me, spellInfo->GetSchoolMask()) > 0) - { - _me->setPowerType(POWER_ENERGY); - _me->SetMaxPower(POWER_ENERGY, 100); - break; - } - } - break; - } - } + if (_me->GetTypeId() == TYPEID_UNIT) + if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(_vehicleInfo->m_powerDisplayId)) + _me->setPowerType(Powers(powerDisplay->PowerType)); _status = STATUS_INSTALLED; if (GetBase()->GetTypeId() == TYPEID_UNIT) diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index f448fbb9f19..db0a196dec6 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -754,7 +754,7 @@ int32 Guild::Member::GetBankWithdrawValue(uint8 tabId) const { // Guild master has unlimited amount. if (IsRank(GR_GUILDMASTER)) - return tabId == GUILD_BANK_MAX_TABS ? GUILD_WITHDRAW_MONEY_UNLIMITED : GUILD_WITHDRAW_SLOT_UNLIMITED; + return static_cast<int32>(tabId == GUILD_BANK_MAX_TABS ? GUILD_WITHDRAW_MONEY_UNLIMITED : GUILD_WITHDRAW_SLOT_UNLIMITED); return m_bankWithdraw[tabId]; } @@ -1760,7 +1760,7 @@ void Guild::HandleMemberDepositMoney(WorldSession* session, uint32 amount) bool Guild::HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool repair) { //clamp amount to MAX_MONEY_AMOUNT, Players can't hold more than that anyway - amount = std::min(amount, uint32(MAX_MONEY_AMOUNT)); + amount = std::min(amount, MAX_MONEY_AMOUNT); if (m_bankMoney < amount) // Not enough money in bank return false; @@ -2581,7 +2581,7 @@ inline int32 Guild::_GetMemberRemainingSlots(Member const* member, uint8 tabId) { uint8 rankId = member->GetRankId(); if (rankId == GR_GUILDMASTER) - return GUILD_WITHDRAW_SLOT_UNLIMITED; + return static_cast<int32>(GUILD_WITHDRAW_SLOT_UNLIMITED); if ((_GetRankBankTabRights(rankId, tabId) & GUILD_BANK_RIGHT_VIEW_TAB) != 0) { int32 remaining = _GetRankBankTabSlotsPerDay(rankId, tabId) - member->GetBankWithdrawValue(tabId); @@ -2598,7 +2598,7 @@ inline int32 Guild::_GetMemberRemainingMoney(Member const* member) const { uint8 rankId = member->GetRankId(); if (rankId == GR_GUILDMASTER) - return GUILD_WITHDRAW_MONEY_UNLIMITED; + return static_cast<int32>(GUILD_WITHDRAW_MONEY_UNLIMITED); if ((_GetRankRights(rankId) & (GR_RIGHT_WITHDRAW_REPAIR | GR_RIGHT_WITHDRAW_GOLD)) != 0) { diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 45d4d221d06..278c180c380 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -255,7 +255,14 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) uint32 inviteCount; recvData >> inviteCount; - for (uint32 i = 0; i < inviteCount; ++i) + SQLTransaction trans; + if (inviteCount > 1) + trans = CharacterDatabase.BeginTransaction(); + + // client limits the amount of players to be invited to 100 + const uint32 MaxPlayerInvites = 100; + + for (uint32 i = 0; i < inviteCount && i < MaxPlayerInvites; ++i) { uint64 invitee = 0; uint8 status = 0; @@ -265,8 +272,11 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) // 946684800 is 01/01/2000 00:00:00 - default response time CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent.GetEventId(), invitee, guid, 946684800, CalendarInviteStatus(status), CalendarModerationRank(rank), ""); - sCalendarMgr->AddInvite(&calendarEvent, invite); + sCalendarMgr->AddInvite(&calendarEvent, invite, trans); } + + if (inviteCount > 1) + CharacterDatabase.CommitTransaction(trans); } sCalendarMgr->AddEvent(new CalendarEvent(calendarEvent, calendarEvent.GetEventId()), CALENDAR_SENDTYPE_ADD); @@ -350,10 +360,15 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY); CalendarInviteStore invites = sCalendarMgr->GetEventInvites(eventId); + SQLTransaction trans; + if (invites.size() > 1) + trans = CharacterDatabase.BeginTransaction(); for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr) - sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId())); + sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId()), trans); + if (invites.size() > 1) + CharacterDatabase.CommitTransaction(trans); // should we change owner when somebody makes a copy of event owned by another person? } else diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp index e0b29523a3a..eccf7a6fd38 100644 --- a/src/server/game/Handlers/ChatHandler.cpp +++ b/src/server/game/Handlers/ChatHandler.cpp @@ -269,7 +269,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) } Player* receiver = sObjectAccessor->FindPlayerByName(to); - if (!receiver || (!receiver->isAcceptWhispers() && receiver->GetSession()->HasPermission(rbac::RBAC_PERM_CAN_FILTER_WHISPERS) && !receiver->IsInWhisperWhiteList(sender->GetGUID()))) + if (!receiver || (lang != LANG_ADDON && !receiver->isAcceptWhispers() && receiver->GetSession()->HasPermission(rbac::RBAC_PERM_CAN_FILTER_WHISPERS) && !receiver->IsInWhisperWhiteList(sender->GetGUID()))) { SendPlayerNotFoundNotice(to); return; diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp index 1fe4718d7ae..884c4a83b15 100644 --- a/src/server/game/Handlers/TradeHandler.cpp +++ b/src/server/game/Handlers/TradeHandler.cpp @@ -299,14 +299,14 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) return; } - if (_player->GetMoney() >= uint32(MAX_MONEY_AMOUNT) - his_trade->GetMoney()) + if (_player->GetMoney() >= MAX_MONEY_AMOUNT - his_trade->GetMoney()) { _player->SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, NULL, NULL); my_trade->SetAccepted(false, true); return; } - if (trader->GetMoney() >= uint32(MAX_MONEY_AMOUNT) - my_trade->GetMoney()) + if (trader->GetMoney() >= MAX_MONEY_AMOUNT - my_trade->GetMoney()) { trader->SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, NULL, NULL); his_trade->SetAccepted(false, true); diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h index 3050443edc0..9e11c566c22 100644 --- a/src/server/game/Instances/InstanceScript.h +++ b/src/server/game/Instances/InstanceScript.h @@ -243,7 +243,7 @@ AI* GetInstanceAI(T* obj, char const* scriptName) return new AI(obj); return NULL; -}; +} template<class AI, class T> AI* GetInstanceAI(T* obj) @@ -253,6 +253,6 @@ AI* GetInstanceAI(T* obj) return new AI(obj); return NULL; -}; +} #endif // TRINITY_INSTANCE_DATA_H diff --git a/src/server/game/Maps/MapUpdater.cpp b/src/server/game/Maps/MapUpdater.cpp index f3a5a66bf66..dd697719d54 100644 --- a/src/server/game/Maps/MapUpdater.cpp +++ b/src/server/game/Maps/MapUpdater.cpp @@ -6,34 +6,6 @@ #include <ace/Guard_T.h> #include <ace/Method_Request.h> -class WDBThreadStartReq1 : public ACE_Method_Request -{ - public: - - WDBThreadStartReq1() - { - } - - virtual int call() - { - return 0; - } -}; - -class WDBThreadEndReq1 : public ACE_Method_Request -{ - public: - - WDBThreadEndReq1() - { - } - - virtual int call() - { - return 0; - } -}; - class MapUpdateRequest : public ACE_Method_Request { private: @@ -67,7 +39,7 @@ MapUpdater::~MapUpdater() int MapUpdater::activate(size_t num_threads) { - return m_executor.start((int)num_threads, new WDBThreadStartReq1, new WDBThreadEndReq1); + return m_executor.start((int)num_threads); } int MapUpdater::deactivate() diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index 75a191a9801..32b8781fb89 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -249,7 +249,7 @@ class SpellScript : public _SpellScript class HitHandlerFunction : public SpellScript::HitHandler { public: HitHandlerFunction(SpellHitFnType _pHitHandlerScript) : SpellScript::HitHandler((SpellScript::SpellHitFnType)_pHitHandlerScript) { } }; \ class ObjectAreaTargetSelectHandlerFunction : public SpellScript::ObjectAreaTargetSelectHandler { public: ObjectAreaTargetSelectHandlerFunction(SpellObjectAreaTargetSelectFnType _pObjectAreaTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::ObjectAreaTargetSelectHandler((SpellScript::SpellObjectAreaTargetSelectFnType)_pObjectAreaTargetSelectHandlerScript, _effIndex, _targetType) { } }; \ class ObjectTargetSelectHandlerFunction : public SpellScript::ObjectTargetSelectHandler { public: ObjectTargetSelectHandlerFunction(SpellObjectTargetSelectFnType _pObjectTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::ObjectTargetSelectHandler((SpellScript::SpellObjectTargetSelectFnType)_pObjectTargetSelectHandlerScript, _effIndex, _targetType) { } }; \ - class DestinationTargetSelectHandlerFunction : public SpellScript::DestinationTargetSelectHandler { public: DestinationTargetSelectHandlerFunction(SpellDestinationTargetSelectFnType _DestinationTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::DestinationTargetSelectHandler((SpellScript::SpellDestinationTargetSelectFnType)_DestinationTargetSelectHandlerScript, _effIndex, _targetType) { } }; + class DestinationTargetSelectHandlerFunction : public SpellScript::DestinationTargetSelectHandler { public: DestinationTargetSelectHandlerFunction(SpellDestinationTargetSelectFnType _DestinationTargetSelectHandlerScript, uint8 _effIndex, uint16 _targetType) : SpellScript::DestinationTargetSelectHandler((SpellScript::SpellDestinationTargetSelectFnType)_DestinationTargetSelectHandlerScript, _effIndex, _targetType) { } } #define PrepareSpellScript(CLASSNAME) SPELLSCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) SPELLSCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) public: @@ -623,7 +623,7 @@ class AuraScript : public _SpellScript class EffectSplitFunction : public AuraScript::EffectSplitHandler { public: EffectSplitFunction(AuraEffectSplitFnType _pEffectHandlerScript, uint8 _effIndex) : AuraScript::EffectSplitHandler((AuraScript::AuraEffectSplitFnType)_pEffectHandlerScript, _effIndex) { } }; \ class CheckProcHandlerFunction : public AuraScript::CheckProcHandler { public: CheckProcHandlerFunction(AuraCheckProcFnType handlerScript) : AuraScript::CheckProcHandler((AuraScript::AuraCheckProcFnType)handlerScript) { } }; \ class AuraProcHandlerFunction : public AuraScript::AuraProcHandler { public: AuraProcHandlerFunction(AuraProcFnType handlerScript) : AuraScript::AuraProcHandler((AuraScript::AuraProcFnType)handlerScript) { } }; \ - class EffectProcHandlerFunction : public AuraScript::EffectProcHandler { public: EffectProcHandlerFunction(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName) : AuraScript::EffectProcHandler((AuraScript::AuraEffectProcFnType)effectHandlerScript, effIndex, effName) { } }; \ + class EffectProcHandlerFunction : public AuraScript::EffectProcHandler { public: EffectProcHandlerFunction(AuraEffectProcFnType effectHandlerScript, uint8 effIndex, uint16 effName) : AuraScript::EffectProcHandler((AuraScript::AuraEffectProcFnType)effectHandlerScript, effIndex, effName) { } } #define PrepareAuraScript(CLASSNAME) AURASCRIPT_FUNCTION_TYPE_DEFINES(CLASSNAME) AURASCRIPT_FUNCTION_CAST_DEFINES(CLASSNAME) diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index b9ecfffb8c3..71d51153b4c 100644 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -233,7 +233,7 @@ void GmTicket::SetChatLog(std::list<uint32> time, std::string const& log) std::stringstream ss(log); std::stringstream newss; std::string line; - while (std::getline(ss, line)) + while (std::getline(ss, line) && !time.empty()) { newss << secsToTimeString(time.front()) << ": " << line << "\n"; time.pop_front(); diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index 42872bba22e..0810295c0cc 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -223,7 +223,7 @@ std::string Warden::Penalty(WardenCheck* check /*= NULL*/) void WorldSession::HandleWardenDataOpcode(WorldPacket& recvData) { - if (!_warden) + if (!_warden || recvData.empty()) return; _warden->DecryptData(recvData.contents(), recvData.size()); diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index f2f11801229..5dbe95b3e54 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -1020,7 +1020,7 @@ public: } else { - if (newmoney > MAX_MONEY_AMOUNT) + if (newmoney > static_cast<int32>(MAX_MONEY_AMOUNT)) newmoney = MAX_MONEY_AMOUNT; handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(moneyToAdd), handler->GetNameLink(target).c_str()); @@ -1035,10 +1035,7 @@ public: if (handler->needReportToTarget(target)) ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), moneyToAdd); - if (moneyToAdd >= MAX_MONEY_AMOUNT) - moneyToAdd = MAX_MONEY_AMOUNT; - - if (targetMoney >= uint32(MAX_MONEY_AMOUNT) - moneyToAdd) + if (targetMoney >= MAX_MONEY_AMOUNT - moneyToAdd) moneyToAdd -= targetMoney; target->ModifyMoney(moneyToAdd); diff --git a/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp b/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp index 83b716728ea..354e1204a50 100644 --- a/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp +++ b/src/server/scripts/EasternKingdoms/AlteracValley/boss_balinda.cpp @@ -212,4 +212,4 @@ void AddSC_boss_balinda() { new boss_balinda; new npc_water_elemental; -}; +} diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index 010e06d67cb..870ae370366 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -109,7 +109,7 @@ void SummonCroneIfReady(InstanceScript* instance, Creature* creature) pCrone->AI()->AttackStart(creature->GetVictim()); } } -}; +} class boss_dorothee : public CreatureScript { diff --git a/src/server/scripts/Kalimdor/zone_durotar.cpp b/src/server/scripts/Kalimdor/zone_durotar.cpp index 8d6ae347b85..358814d440a 100644 --- a/src/server/scripts/Kalimdor/zone_durotar.cpp +++ b/src/server/scripts/Kalimdor/zone_durotar.cpp @@ -447,7 +447,7 @@ class spell_mount_check : public SpellScriptLoader class spell_mount_check_AuraScript : public AuraScript { - PrepareAuraScript(spell_mount_check_AuraScript) + PrepareAuraScript(spell_mount_check_AuraScript); bool Validate(SpellInfo const* /*spellInfo*/) override { @@ -495,7 +495,7 @@ class spell_voljin_war_drums : public SpellScriptLoader class spell_voljin_war_drums_SpellScript : public SpellScript { - PrepareSpellScript(spell_voljin_war_drums_SpellScript) + PrepareSpellScript(spell_voljin_war_drums_SpellScript); bool Validate(SpellInfo const* /*spellInfo*/) override { @@ -552,7 +552,7 @@ class spell_voodoo : public SpellScriptLoader class spell_voodoo_SpellScript : public SpellScript { - PrepareSpellScript(spell_voodoo_SpellScript) + PrepareSpellScript(spell_voodoo_SpellScript); bool Validate(SpellInfo const* /*spellInfo*/) override { diff --git a/src/server/scripts/Kalimdor/zone_silithus.cpp b/src/server/scripts/Kalimdor/zone_silithus.cpp index 3f4fb31a11d..42ab3d8d9cf 100644 --- a/src/server/scripts/Kalimdor/zone_silithus.cpp +++ b/src/server/scripts/Kalimdor/zone_silithus.cpp @@ -1006,7 +1006,7 @@ void npc_qiraj_war_spawn::npc_qiraj_war_spawnAI::JustDied(Unit* /*slayer*/) if (npc_anachronos_quest_trigger::npc_anachronos_quest_triggerAI* triggerAI = CAST_AI(npc_anachronos_quest_trigger::npc_anachronos_quest_triggerAI, mob->AI())) triggerAI->LiveCounter(); -}; +} /*##### # go_crystalline_tear diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp index abeafe156ad..c0f7b2f1856 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp @@ -553,7 +553,7 @@ class spell_mistress_kiss_area : public SpellScriptLoader class spell_mistress_kiss_area_SpellScript : public SpellScript { - PrepareSpellScript(spell_mistress_kiss_area_SpellScript) + PrepareSpellScript(spell_mistress_kiss_area_SpellScript); void FilterTargets(std::list<WorldObject*>& targets) { diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp index 00eb970b57b..5fa52c1eb53 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp @@ -673,8 +673,7 @@ class spell_powering_up : public SpellScriptLoader class spell_powering_up_SpellScript : public SpellScript { - public: - PrepareSpellScript(spell_powering_up_SpellScript) + PrepareSpellScript(spell_powering_up_SpellScript); uint32 spellId; uint32 poweringUp; diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 3f0fb2f93b1..192249955cf 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -1810,7 +1810,7 @@ public: class spell_malygos_vortex_dummy_SpellScript : public SpellScript { - PrepareSpellScript(spell_malygos_vortex_dummy_SpellScript) + PrepareSpellScript(spell_malygos_vortex_dummy_SpellScript); bool Load() override { @@ -2282,7 +2282,7 @@ class spell_malygos_surge_of_power_warning_selector_25 : public SpellScriptLoade class spell_malygos_surge_of_power_warning_selector_25_SpellScript : public SpellScript { - PrepareSpellScript(spell_malygos_surge_of_power_warning_selector_25_SpellScript) + PrepareSpellScript(spell_malygos_surge_of_power_warning_selector_25_SpellScript); bool Load() override { @@ -2348,7 +2348,7 @@ class spell_malygos_surge_of_power_25 : public SpellScriptLoader class spell_malygos_surge_of_power_25_SpellScript : public SpellScript { - PrepareSpellScript(spell_malygos_surge_of_power_25_SpellScript) + PrepareSpellScript(spell_malygos_surge_of_power_25_SpellScript); bool Load() override { diff --git a/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp b/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp index 0870614ba78..585da8e28d3 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/boss_varos.cpp @@ -299,7 +299,7 @@ class spell_varos_energize_core_area_enemy : public SpellScriptLoader class spell_varos_energize_core_area_enemySpellScript : public SpellScript { - PrepareSpellScript(spell_varos_energize_core_area_enemySpellScript) + PrepareSpellScript(spell_varos_energize_core_area_enemySpellScript); void FilterTargets(std::list<WorldObject*>& targets) { @@ -343,7 +343,7 @@ class spell_varos_energize_core_area_entry : public SpellScriptLoader class spell_varos_energize_core_area_entrySpellScript : public SpellScript { - PrepareSpellScript(spell_varos_energize_core_area_entrySpellScript) + PrepareSpellScript(spell_varos_energize_core_area_entrySpellScript); void FilterTargets(std::list<WorldObject*>& targets) { diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp index c81cd0b0b80..07cdfa3353c 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/boss_krystallus.cpp @@ -15,14 +15,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* Script Data Start -SDName: Boss krystallus -SDAuthor: LordVanMartin -SD%Complete: -SDComment: -SDCategory: -Script Data End */ - #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" @@ -30,17 +22,13 @@ Script Data End */ enum Spells { - SPELL_BOULDER_TOSS = 50843, - H_SPELL_BOULDER_TOSS = 59742, - SPELL_GROUND_SPIKE = 59750, - SPELL_GROUND_SLAM = 50827, - SPELL_SHATTER = 50810, - H_SPELL_SHATTER = 61546, - SPELL_SHATTER_EFFECT = 50811, - H_SPELL_SHATTER_EFFECT = 61547, - SPELL_STONED = 50812, - SPELL_STOMP = 48131, - H_SPELL_STOMP = 59744 + SPELL_BOULDER_TOSS = 50843, + SPELL_GROUND_SPIKE = 59750, + SPELL_GROUND_SLAM = 50827, + SPELL_SHATTER = 50810, + SPELL_SHATTER_EFFECT = 50811, + SPELL_STONED = 50812, + SPELL_STOMP = 48131 }; enum Yells @@ -51,133 +39,103 @@ enum Yells SAY_SHATTER = 3 }; -class boss_krystallus : public CreatureScript +enum Events { -public: - boss_krystallus() : CreatureScript("boss_krystallus") { } - - struct boss_krystallusAI : public ScriptedAI - { - boss_krystallusAI(Creature* creature) : ScriptedAI(creature) - { - instance = creature->GetInstanceScript(); - } - - uint32 uiBoulderTossTimer; - uint32 uiGroundSpikeTimer; - uint32 uiGroundSlamTimer; - uint32 uiShatterTimer; - uint32 uiStompTimer; - - bool bIsSlam; - - InstanceScript* instance; - - void Reset() override - { - bIsSlam = false; - - uiBoulderTossTimer = urand(3000, 9000); - uiGroundSpikeTimer = urand(9000, 14000); - uiGroundSlamTimer = urand(15000, 18000); - uiStompTimer = urand(20000, 29000); - uiShatterTimer = 0; - - instance->SetBossState(DATA_KRYSTALLUS, NOT_STARTED); - } - void EnterCombat(Unit* /*who*/) override - { - Talk(SAY_AGGRO); + EVENT_BOULDER_TOSS = 1, + EVENT_GROUND_SPIKE, + EVENT_GROUND_SLAM, + EVENT_STOMP, + EVENT_SHATTER +}; - instance->SetBossState(DATA_KRYSTALLUS, IN_PROGRESS); - } +class boss_krystallus : public CreatureScript +{ + public: + boss_krystallus() : CreatureScript("boss_krystallus") { } - void UpdateAI(uint32 diff) override + struct boss_krystallusAI : public BossAI { - //Return since we have no target - if (!UpdateVictim()) - return; + boss_krystallusAI(Creature* creature) : BossAI(creature, DATA_KRYSTALLUS) { } - if (uiBoulderTossTimer <= diff) + void Reset() override { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - DoCast(target, SPELL_BOULDER_TOSS); - uiBoulderTossTimer = urand(9000, 15000); - } else uiBoulderTossTimer -= diff; - - if (uiGroundSpikeTimer <= diff) - { - if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - DoCast(target, SPELL_GROUND_SPIKE); - uiGroundSpikeTimer = urand(12000, 17000); - } else uiGroundSpikeTimer -= diff; - - if (uiStompTimer <= diff) - { - DoCast(me, SPELL_STOMP); - uiStompTimer = urand(20000, 29000); - } else uiStompTimer -= diff; - - if (uiGroundSlamTimer <= diff) - { - DoCast(me, SPELL_GROUND_SLAM); - bIsSlam = true; - uiShatterTimer = 10000; - uiGroundSlamTimer = urand(15000, 18000); - } else uiGroundSlamTimer -= diff; + _Reset(); + } - if (bIsSlam) + void EnterCombat(Unit* /*who*/) override { - if (uiShatterTimer <= diff) - { - DoCast(me, DUNGEON_MODE(SPELL_SHATTER, H_SPELL_SHATTER)); - } else uiShatterTimer -= diff; + Talk(SAY_AGGRO); + _EnterCombat(); + + events.ScheduleEvent(EVENT_BOULDER_TOSS, urand(3000, 9000)); + events.ScheduleEvent(EVENT_GROUND_SLAM, urand(15000, 18000)); + events.ScheduleEvent(EVENT_STOMP, urand(20000, 29000)); + if (IsHeroic()) + events.ScheduleEvent(EVENT_GROUND_SPIKE, urand(9000, 14000)); } - DoMeleeAttackIfReady(); - } - - void JustDied(Unit* /*killer*/) override - { - Talk(SAY_DEATH); - - instance->SetBossState(DATA_KRYSTALLUS, DONE); - } + void UpdateAI(uint32 diff) override + { + // Return since we have no target + if (!UpdateVictim()) + return; - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() != TYPEID_PLAYER) - return; + events.Update(diff); - Talk(SAY_KILL); - } + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - void SpellHitTarget(Unit* /*target*/, const SpellInfo* pSpell) override - { - //this part should be in the core - if (pSpell->Id == SPELL_SHATTER || pSpell->Id == H_SPELL_SHATTER) - { - /// @todo we need eventmap to kill this stuff - //clear this, if we are still performing - if (bIsSlam) + while (uint32 eventId = events.ExecuteEvent()) { - bIsSlam = false; - - //and correct movement, if not already - if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) + switch (eventId) { - if (me->GetVictim()) - me->GetMotionMaster()->MoveChase(me->GetVictim()); + case EVENT_BOULDER_TOSS: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50.0f, true)) + DoCast(target, SPELL_BOULDER_TOSS); + events.ScheduleEvent(EVENT_BOULDER_TOSS, urand(9000, 15000)); + break; + case EVENT_GROUND_SPIKE: + if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true)) + DoCast(target, SPELL_GROUND_SPIKE); + events.ScheduleEvent(EVENT_GROUND_SPIKE, urand(12000, 17000)); + break; + case EVENT_GROUND_SLAM: + DoCast(me, SPELL_GROUND_SLAM); + events.ScheduleEvent(EVENT_SHATTER, 10000); + events.ScheduleEvent(EVENT_GROUND_SLAM, urand(15000, 18000)); + break; + case EVENT_STOMP: + DoCast(me, SPELL_STOMP); + events.ScheduleEvent(EVENT_STOMP, urand(20000, 29000)); + break; + case EVENT_SHATTER: + DoCast(me, SPELL_SHATTER); + break; + default: + break; } } + + DoMeleeAttackIfReady(); + } + + void JustDied(Unit* /*killer*/) override + { + Talk(SAY_DEATH); + _JustDied(); } - } - }; - CreatureAI* GetAI(Creature* creature) const override - { - return GetHallsOfStoneAI<boss_krystallusAI>(creature); - } + void KilledUnit(Unit* victim) override + { + if (victim->GetTypeId() == TYPEID_PLAYER) + Talk(SAY_KILL); + } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return GetHallsOfStoneAI<boss_krystallusAI>(creature); + } }; class spell_krystallus_shatter : public SpellScriptLoader diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index cfa5429ea79..f284aacf996 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -89,7 +89,7 @@ class spell_ulduar_proximity_mines : public SpellScriptLoader class spell_ulduar_proximity_minesSpellScript : public SpellScript { - PrepareSpellScript(spell_ulduar_proximity_minesSpellScript) + PrepareSpellScript(spell_ulduar_proximity_minesSpellScript); void HandleScript(SpellEffIndex effIndex) { diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 77a4faa7e8c..4c72d790059 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -509,7 +509,7 @@ class spell_gen_break_shield: public SpellScriptLoader class spell_gen_break_shield_SpellScript : public SpellScript { - PrepareSpellScript(spell_gen_break_shield_SpellScript) + PrepareSpellScript(spell_gen_break_shield_SpellScript); void HandleScriptEffect(SpellEffIndex effIndex) { @@ -671,7 +671,7 @@ class spell_gen_chaos_blast : public SpellScriptLoader class spell_gen_chaos_blast_SpellScript : public SpellScript { - PrepareSpellScript(spell_gen_chaos_blast_SpellScript) + PrepareSpellScript(spell_gen_chaos_blast_SpellScript); bool Validate(SpellInfo const* /*spellInfo*/) override { @@ -895,7 +895,7 @@ class spell_gen_count_pct_from_max_hp : public SpellScriptLoader class spell_gen_count_pct_from_max_hp_SpellScript : public SpellScript { - PrepareSpellScript(spell_gen_count_pct_from_max_hp_SpellScript) + PrepareSpellScript(spell_gen_count_pct_from_max_hp_SpellScript); public: spell_gen_count_pct_from_max_hp_SpellScript(int32 damagePct) : SpellScript(), _damagePct(damagePct) { } @@ -1446,6 +1446,7 @@ class spell_gen_elune_candle : public SpellScriptLoader class spell_gen_elune_candle_SpellScript : public SpellScript { PrepareSpellScript(spell_gen_elune_candle_SpellScript); + bool Validate(SpellInfo const* /*spellInfo*/) override { if (!sSpellMgr->GetSpellInfo(SPELL_ELUNE_CANDLE_OMEN_HEAD) || @@ -1511,7 +1512,7 @@ class spell_gen_gadgetzan_transporter_backfire : public SpellScriptLoader class spell_gen_gadgetzan_transporter_backfire_SpellScript : public SpellScript { - PrepareSpellScript(spell_gen_gadgetzan_transporter_backfire_SpellScript) + PrepareSpellScript(spell_gen_gadgetzan_transporter_backfire_SpellScript); bool Validate(SpellInfo const* /*spellInfo*/) override { @@ -1612,7 +1613,7 @@ class spell_gen_gnomish_transporter : public SpellScriptLoader class spell_gen_gnomish_transporter_SpellScript : public SpellScript { - PrepareSpellScript(spell_gen_gnomish_transporter_SpellScript) + PrepareSpellScript(spell_gen_gnomish_transporter_SpellScript); bool Validate(SpellInfo const* /*spellInfo*/) override { @@ -2093,7 +2094,7 @@ class spell_gen_mounted_charge: public SpellScriptLoader class spell_gen_mounted_charge_SpellScript : public SpellScript { - PrepareSpellScript(spell_gen_mounted_charge_SpellScript) + PrepareSpellScript(spell_gen_mounted_charge_SpellScript); void HandleScriptEffect(SpellEffIndex effIndex) { @@ -2794,7 +2795,7 @@ class spell_gen_parachute_ic : public SpellScriptLoader class spell_gen_parachute_ic_AuraScript : public AuraScript { - PrepareAuraScript(spell_gen_parachute_ic_AuraScript) + PrepareAuraScript(spell_gen_parachute_ic_AuraScript); void HandleTriggerSpell(AuraEffect const* /*aurEff*/) { @@ -2842,30 +2843,28 @@ class spell_gen_pet_summoned : public SpellScriptLoader if (player->GetLastPetNumber()) { PetType newPetType = (player->getClass() == CLASS_HUNTER) ? HUNTER_PET : SUMMON_PET; - if (Pet* newPet = new Pet(player, newPetType)) + Pet* newPet = new Pet(player, newPetType); + if (newPet->LoadPetFromDB(player, 0, player->GetLastPetNumber(), true)) { - if (newPet->LoadPetFromDB(player, 0, player->GetLastPetNumber(), true)) - { - // revive the pet if it is dead - if (newPet->getDeathState() == DEAD) - newPet->setDeathState(ALIVE); + // revive the pet if it is dead + if (newPet->getDeathState() == DEAD) + newPet->setDeathState(ALIVE); - newPet->SetFullHealth(); - newPet->SetPower(newPet->getPowerType(), newPet->GetMaxPower(newPet->getPowerType())); + newPet->SetFullHealth(); + newPet->SetPower(newPet->getPowerType(), newPet->GetMaxPower(newPet->getPowerType())); - switch (newPet->GetEntry()) - { - case NPC_DOOMGUARD: - case NPC_INFERNAL: - newPet->SetEntry(NPC_IMP); - break; - default: - break; - } + switch (newPet->GetEntry()) + { + case NPC_DOOMGUARD: + case NPC_INFERNAL: + newPet->SetEntry(NPC_IMP); + break; + default: + break; } - else - delete newPet; } + else + delete newPet; } } @@ -3123,7 +3122,7 @@ class spell_gen_spectator_cheer_trigger : public SpellScriptLoader class spell_gen_spectator_cheer_trigger_SpellScript : public SpellScript { - PrepareSpellScript(spell_gen_spectator_cheer_trigger_SpellScript) + PrepareSpellScript(spell_gen_spectator_cheer_trigger_SpellScript); void HandleDummy(SpellEffIndex /*effIndex*/) { @@ -3615,7 +3614,7 @@ class spell_gen_vendor_bark_trigger : public SpellScriptLoader class spell_gen_vendor_bark_trigger_SpellScript : public SpellScript { - PrepareSpellScript(spell_gen_vendor_bark_trigger_SpellScript) + PrepareSpellScript(spell_gen_vendor_bark_trigger_SpellScript); void HandleDummy(SpellEffIndex /* effIndex */) { diff --git a/src/server/scripts/Spells/spell_holiday.cpp b/src/server/scripts/Spells/spell_holiday.cpp index dc0c70975dd..85bf85fa2d2 100644 --- a/src/server/scripts/Spells/spell_holiday.cpp +++ b/src/server/scripts/Spells/spell_holiday.cpp @@ -296,7 +296,7 @@ class spell_pilgrims_bounty_buff_food : public SpellScriptLoader class spell_pilgrims_bounty_buff_food_AuraScript : public AuraScript { - PrepareAuraScript(spell_pilgrims_bounty_buff_food_AuraScript) + PrepareAuraScript(spell_pilgrims_bounty_buff_food_AuraScript); private: uint32 const _triggeredSpellId; diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index 590cad7007f..61ff79c505e 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -775,7 +775,7 @@ class spell_sha_lava_lash : public SpellScriptLoader class spell_sha_lava_lash_SpellScript : public SpellScript { - PrepareSpellScript(spell_sha_lava_lash_SpellScript) + PrepareSpellScript(spell_sha_lava_lash_SpellScript); bool Load() override { diff --git a/src/server/scripts/World/boss_emerald_dragons.cpp b/src/server/scripts/World/boss_emerald_dragons.cpp index 362c02e1af5..950b4cd10e9 100644 --- a/src/server/scripts/World/boss_emerald_dragons.cpp +++ b/src/server/scripts/World/boss_emerald_dragons.cpp @@ -781,4 +781,4 @@ void AddSC_emerald_dragons() // dragon spellscripts new spell_dream_fog_sleep(); new spell_mark_of_nature(); -}; +} diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h index c60458323f7..3665a388854 100644 --- a/src/server/shared/Database/DatabaseWorkerPool.h +++ b/src/server/shared/Database/DatabaseWorkerPool.h @@ -49,8 +49,10 @@ class DatabaseWorkerPool { public: /* Activity state */ - DatabaseWorkerPool() : _queue(new ACE_Activation_Queue()), _connectionInfo(NULL) + DatabaseWorkerPool() : _connectionInfo(NULL) { + _messageQueue = new ACE_Message_Queue<ACE_SYNCH>(8 * 1024 * 1024, 8 * 1024 * 1024); + _queue = new ACE_Activation_Queue(_messageQueue); memset(_connectionCount, 0, sizeof(_connectionCount)); _connections.resize(IDX_SIZE); @@ -131,6 +133,7 @@ class DatabaseWorkerPool //! Deletes the ACE_Activation_Queue object and its underlying ACE_Message_Queue delete _queue; + delete _messageQueue; TC_LOG_INFO("sql.driver", "All connections on DatabasePool '%s' closed.", GetDatabaseName()); @@ -520,6 +523,7 @@ class DatabaseWorkerPool IDX_SIZE }; + ACE_Message_Queue<ACE_SYNCH>* _messageQueue; //! Message Queue used by ACE_Activation_Queue ACE_Activation_Queue* _queue; //! Queue shared by async worker threads. std::vector< std::vector<T*> > _connections; uint32 _connectionCount[2]; //! Counter of MySQL connections; diff --git a/src/server/shared/Logging/Log.cpp b/src/server/shared/Logging/Log.cpp index bc002668b3b..dc9bda62bfb 100644 --- a/src/server/shared/Logging/Log.cpp +++ b/src/server/shared/Logging/Log.cpp @@ -250,13 +250,13 @@ void Log::ReadLoggersFromConfig() AppenderConsole* appender = new AppenderConsole(NextAppenderId(), "Console", LOG_LEVEL_DEBUG, APPENDER_FLAGS_NONE); appenders[appender->getId()] = appender; - Logger& rootLogger = loggers[LOGGER_ROOT]; - rootLogger.Create(LOGGER_ROOT, LOG_LEVEL_ERROR); - rootLogger.addAppender(appender->getId(), appender); + Logger& logger = loggers[LOGGER_ROOT]; + logger.Create(LOGGER_ROOT, LOG_LEVEL_ERROR); + logger.addAppender(appender->getId(), appender); - Logger& serverLogger = loggers["server"]; - serverLogger.Create("server", LOG_LEVEL_INFO); - serverLogger.addAppender(appender->getId(), appender); + logger = loggers["server"]; + logger.Create("server", LOG_LEVEL_ERROR); + logger.addAppender(appender->getId(), appender); } } @@ -267,7 +267,7 @@ void Log::vlog(std::string const& filter, LogLevel level, char const* str, va_li write(new LogMessage(level, filter, text)); } -void Log::write(LogMessage* msg) +void Log::write(LogMessage* msg) const { Logger const* logger = GetLoggerByType(msg->type); msg->text.append("\n"); @@ -376,7 +376,6 @@ void Log::Close() delete worker; worker = NULL; loggers.clear(); - cachedLoggers.clear(); for (AppenderMap::iterator it = appenders.begin(); it != appenders.end(); ++it) { delete it->second; diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h index 5fa638e2f40..a118e6e8773 100644 --- a/src/server/shared/Logging/Log.h +++ b/src/server/shared/Logging/Log.h @@ -35,7 +35,6 @@ class Log friend class ACE_Singleton<Log, ACE_Thread_Mutex>; typedef std::unordered_map<std::string, Logger> LoggerMap; - typedef std::unordered_map<std::string, Logger const*> CachedLoggerContainer; private: Log(); @@ -44,7 +43,7 @@ class Log public: void LoadFromConfig(); void Close(); - bool ShouldLog(std::string const& type, LogLevel level); + bool ShouldLog(std::string const& type, LogLevel level) const; bool SetLogLevel(std::string const& name, char const* level, bool isLogger = true); void outMessage(std::string const& f, LogLevel level, char const* str, ...) ATTR_PRINTF(4, 5); @@ -57,9 +56,9 @@ class Log private: static std::string GetTimestampStr(); void vlog(std::string const& f, LogLevel level, char const* str, va_list argptr); - void write(LogMessage* msg); + void write(LogMessage* msg) const; - Logger const* GetLoggerByType(std::string const& type); + Logger const* GetLoggerByType(std::string const& type) const; Appender* GetAppenderByName(std::string const& name); uint8 NextAppenderId(); void CreateAppenderFromConfig(std::string const& name); @@ -69,7 +68,6 @@ class Log AppenderMap appenders; LoggerMap loggers; - CachedLoggerContainer cachedLoggers; uint8 AppenderId; std::string m_logsDir; @@ -78,37 +76,29 @@ class Log LogWorker* worker; }; -inline Logger const* Log::GetLoggerByType(std::string const& originalType) +inline Logger const* Log::GetLoggerByType(std::string const& type) const { - // Check if already cached - CachedLoggerContainer::const_iterator itCached = cachedLoggers.find(originalType); - if (itCached != cachedLoggers.end()) - return itCached->second; - - Logger const* logger = NULL; - std::string type(originalType); - - do - { - // Search for the logger "type.subtype" - LoggerMap::const_iterator it = loggers.find(type); - if (it == loggers.end()) - { - // Search for the logger "type", if our logger contains '.', otherwise search for LOGGER_ROOT - size_t found = type.find_last_of("."); - type = found != std::string::npos ? type.substr(0, found) : LOGGER_ROOT; - } - else - logger = &(it->second); - } - while (!logger); - - cachedLoggers[originalType] = logger; - return logger; + LoggerMap::const_iterator it = loggers.find(type); + if (it != loggers.end()) + return &(it->second); + + if (type == LOGGER_ROOT) + return NULL; + + std::string parentLogger = LOGGER_ROOT; + size_t found = type.find_last_of("."); + if (found != std::string::npos) + parentLogger = type.substr(0,found); + + return GetLoggerByType(parentLogger); } -inline bool Log::ShouldLog(std::string const& type, LogLevel level) +inline bool Log::ShouldLog(std::string const& type, LogLevel level) const { + // TODO: Use cache to store "Type.sub1.sub2": "Type" equivalence, should + // Speed up in cases where requesting "Type.sub1.sub2" but only configured + // Logger "Type" + Logger const* logger = GetLoggerByType(type); if (!logger) return false; diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index bc46b87fa27..dd0a9d5fdf4 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -377,9 +377,19 @@ class ByteBuffer return *this; } - uint8 * contents() { return &_storage[0]; } + uint8 * contents() + { + if (_storage.empty()) + throw ByteBufferException(); + return &_storage[0]; + } - const uint8 *contents() const { return &_storage[0]; } + const uint8 *contents() const + { + if (_storage.empty()) + throw ByteBufferException(); + return &_storage[0]; + } size_t size() const { return _storage.size(); } bool empty() const { return _storage.empty(); } diff --git a/src/tools/mmaps_generator/TerrainBuilder.cpp b/src/tools/mmaps_generator/TerrainBuilder.cpp index 19112d84266..7832cef18de 100644 --- a/src/tools/mmaps_generator/TerrainBuilder.cpp +++ b/src/tools/mmaps_generator/TerrainBuilder.cpp @@ -906,7 +906,7 @@ namespace MMAP float p0[3], p1[3]; uint32 mid, tx, ty; float size; - if (sscanf(buf, "%d %d,%d (%f %f %f) (%f %f %f) %f", &mid, &tx, &ty, + if (sscanf(buf, "%u %u,%u (%f %f %f) (%f %f %f) %f", &mid, &tx, &ty, &p0[0], &p0[1], &p0[2], &p1[0], &p1[1], &p1[2], &size) != 10) continue; |