mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 08:33:47 +00:00
Merge branch 'master' into Playerbot
This commit is contained in:
@@ -3516,20 +3516,20 @@ void ObjectMgr::LoadVehicleSeatAddon()
|
||||
|
||||
if (!sVehicleSeatStore.LookupEntry(seatID))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: %u does not exist in VehicleSeat.dbc. Skipping entry.", seatID);
|
||||
LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} does not exist in VehicleSeat.dbc. Skipping entry.", seatID);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Sanitizing values
|
||||
if (orientation > float(M_PI * 2))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: %u is using invalid angle offset value (%f). Set Value to 0.", seatID, orientation);
|
||||
LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid angle offset value ({}). Set Value to 0.", seatID, orientation);
|
||||
orientation = 0.0f;
|
||||
}
|
||||
|
||||
if (exitParam >= AsUnderlyingType(VehicleExitParameters::VehicleExitParamMax))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: %u is using invalid exit parameter value (%u). Setting to 0 (none).", seatID, exitParam);
|
||||
LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: {} is using invalid exit parameter value ({}). Setting to 0 (none).", seatID, exitParam);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3538,7 +3538,7 @@ void ObjectMgr::LoadVehicleSeatAddon()
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded %u Vehicle Seat Addon entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", ">> Loaded {} Vehicle Seat Addon entries in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadPetLevelInfo()
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
uint32 m_diff;
|
||||
};
|
||||
|
||||
MapUpdater::MapUpdater(): pending_requests(0)
|
||||
MapUpdater::MapUpdater() : pending_requests(0), _cancelationToken(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -84,10 +84,11 @@ void MapUpdater::deactivate()
|
||||
{
|
||||
_cancelationToken = true;
|
||||
|
||||
wait();
|
||||
wait(); // This is where we wait for tasks to complete
|
||||
|
||||
_queue.Cancel();
|
||||
_queue.Cancel(); // Cancel the queue to prevent further task processing
|
||||
|
||||
// Join all worker threads
|
||||
for (auto& thread : _workerThreads)
|
||||
{
|
||||
if (thread.joinable())
|
||||
@@ -99,44 +100,45 @@ void MapUpdater::deactivate()
|
||||
|
||||
void MapUpdater::wait()
|
||||
{
|
||||
std::unique_lock<std::mutex> guard(_lock);
|
||||
std::unique_lock<std::mutex> guard(_lock); // Guard lock for safe waiting
|
||||
|
||||
while (pending_requests > 0)
|
||||
_condition.wait(guard);
|
||||
// Wait until there are no pending requests
|
||||
_condition.wait(guard, [this] {
|
||||
return pending_requests.load(std::memory_order_acquire) == 0;
|
||||
});
|
||||
}
|
||||
|
||||
guard.unlock();
|
||||
void MapUpdater::schedule_task(UpdateRequest* request)
|
||||
{
|
||||
// Atomic increment for pending_requests
|
||||
pending_requests.fetch_add(1, std::memory_order_release);
|
||||
_queue.Push(request);
|
||||
}
|
||||
|
||||
void MapUpdater::schedule_update(Map& map, uint32 diff, uint32 s_diff)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(_lock);
|
||||
|
||||
++pending_requests;
|
||||
|
||||
_queue.Push(new MapUpdateRequest(map, *this, diff, s_diff));
|
||||
schedule_task(new MapUpdateRequest(map, *this, diff, s_diff));
|
||||
}
|
||||
|
||||
void MapUpdater::schedule_lfg_update(uint32 diff)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(_lock);
|
||||
|
||||
++pending_requests;
|
||||
|
||||
_queue.Push(new LFGUpdateRequest(*this, diff));
|
||||
schedule_task(new LFGUpdateRequest(*this, diff));
|
||||
}
|
||||
|
||||
bool MapUpdater::activated()
|
||||
{
|
||||
return _workerThreads.size() > 0;
|
||||
return !_workerThreads.empty();
|
||||
}
|
||||
|
||||
void MapUpdater::update_finished()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_lock);
|
||||
|
||||
--pending_requests;
|
||||
|
||||
_condition.notify_all();
|
||||
// Atomic decrement for pending_requests
|
||||
if (pending_requests.fetch_sub(1, std::memory_order_acquire) == 1)
|
||||
{
|
||||
// Only notify when pending_requests becomes 0 (i.e., all tasks are finished)
|
||||
std::lock_guard<std::mutex> lock(_lock); // Lock only for condition variable notification
|
||||
_condition.notify_all(); // Notify waiting threads that all requests are complete
|
||||
}
|
||||
}
|
||||
|
||||
void MapUpdater::WorkerThread()
|
||||
@@ -145,16 +147,16 @@ void MapUpdater::WorkerThread()
|
||||
CharacterDatabase.WarnAboutSyncQueries(true);
|
||||
WorldDatabase.WarnAboutSyncQueries(true);
|
||||
|
||||
while (1)
|
||||
while (!_cancelationToken)
|
||||
{
|
||||
UpdateRequest* request = nullptr;
|
||||
|
||||
_queue.WaitAndPop(request);
|
||||
if (_cancelationToken)
|
||||
return;
|
||||
_queue.WaitAndPop(request); // Wait for and pop a request from the queue
|
||||
|
||||
request->call();
|
||||
|
||||
delete request;
|
||||
if (!_cancelationToken && request)
|
||||
{
|
||||
request->call(); // Execute the request
|
||||
delete request; // Clean up after processing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "PCQueue.h"
|
||||
#include <condition_variable>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
|
||||
class Map;
|
||||
class UpdateRequest;
|
||||
@@ -32,6 +33,7 @@ public:
|
||||
MapUpdater();
|
||||
~MapUpdater() = default;
|
||||
|
||||
void schedule_task(UpdateRequest* request);
|
||||
void schedule_update(Map& map, uint32 diff, uint32 s_diff);
|
||||
void schedule_lfg_update(uint32 diff);
|
||||
void wait();
|
||||
@@ -42,15 +44,12 @@ public:
|
||||
|
||||
private:
|
||||
void WorkerThread();
|
||||
|
||||
ProducerConsumerQueue<UpdateRequest*> _queue;
|
||||
|
||||
std::atomic<int> pending_requests; // Use std::atomic for pending_requests to avoid lock contention
|
||||
std::atomic<bool> _cancelationToken; // Atomic flag for cancellation to avoid race conditions
|
||||
std::vector<std::thread> _workerThreads;
|
||||
std::atomic<bool> _cancelationToken;
|
||||
|
||||
std::mutex _lock;
|
||||
std::mutex _lock; // Mutex and condition variable for synchronization
|
||||
std::condition_variable _condition;
|
||||
std::size_t pending_requests;
|
||||
};
|
||||
|
||||
#endif //_MAP_UPDATER_H_INCLUDED
|
||||
|
||||
@@ -139,7 +139,7 @@ void MotdMgr::LoadLocalizedMotds(uint32 realmId) {
|
||||
|
||||
if (!baseResult)
|
||||
{
|
||||
LOG_ERROR("server.loading", "No base MOTD found for realm %u. Localized MOTDs will not be loaded.", realmId);
|
||||
LOG_ERROR("server.loading", "No base MOTD found for realm {}. Localized MOTDs will not be loaded.", realmId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1275,7 +1275,7 @@ public:
|
||||
|
||||
if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid))
|
||||
{
|
||||
handler->SendErrorMessage("Selected creature can't link with guid '%u'", linkguid);
|
||||
handler->SendErrorMessage("Selected creature can't link with guid '{}'", linkguid);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
|
||||
/// - Send the message
|
||||
// Use SendAreaTriggerMessage for fastest delivery.
|
||||
player->GetSession()->SendAreaTriggerMessage("%s", msg.c_str());
|
||||
player->GetSession()->SendAreaTriggerMessage("{}", msg);
|
||||
player->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
|
||||
|
||||
// Confirmation message
|
||||
|
||||
@@ -342,7 +342,7 @@ class spell_entropius_negative_energy_periodic : public AuraScript
|
||||
void PeriodicTick(AuraEffect const* aurEff)
|
||||
{
|
||||
PreventDefaultAction();
|
||||
uint32 targetCount = aurEff->GetTickNumber() > 12 ? 1 : aurEff->GetTickNumber() / 12;
|
||||
uint32 targetCount = (aurEff->GetTickNumber() + 11) / 12;
|
||||
GetTarget()->CastCustomSpell(aurEff->GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, SPELLVALUE_MAX_TARGETS, targetCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ struct boss_akilzon : public BossAI
|
||||
});
|
||||
|
||||
ScheduleTimedEvent(20s, 30s, [&] {
|
||||
if (scheduler.GetNextGroupOcurrence(GROUP_ELECTRICAL_STORM) > 5s)
|
||||
if (scheduler.GetNextGroupOccurrence(GROUP_ELECTRICAL_STORM) > 5s)
|
||||
DoCastRandomTarget(SPELL_GUST_OF_WIND, 1);
|
||||
}, 20s, 30s);
|
||||
|
||||
|
||||
@@ -135,7 +135,8 @@ enum Misc
|
||||
MAX_ADD_COUNT = 4,
|
||||
ADDITIONAL_CLASS_SPRIEST = 11,
|
||||
AURA_SHADOW_FORM = 15473,
|
||||
GROUP_CLASS_ABILITY = 1
|
||||
GROUP_CLASS_ABILITY = 1,
|
||||
GROUP_DRAIN_POWER = 2
|
||||
};
|
||||
|
||||
enum AbilityTarget
|
||||
@@ -242,12 +243,15 @@ struct boss_hexlord_malacrass : public BossAI
|
||||
BossAI::Reset();
|
||||
_currentClass = CLASS_NONE;
|
||||
_classAbilityTimer = 10000ms;
|
||||
_timeUntilNextDrainPower = 0ms;
|
||||
SpawnAdds();
|
||||
ScheduleHealthCheckEvent(80, [&] {
|
||||
ScheduleTimedEvent(1s, [&] {
|
||||
scheduler.Schedule(1s, GROUP_DRAIN_POWER, [this](TaskContext context)
|
||||
{
|
||||
DoCastSelf(SPELL_DRAIN_POWER, true);
|
||||
Talk(SAY_DRAIN_POWER);
|
||||
}, 30s);
|
||||
context.Repeat(30s);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -282,6 +286,14 @@ struct boss_hexlord_malacrass : public BossAI
|
||||
ScheduleTimedEvent(30s, [&]{
|
||||
scheduler.CancelGroup(GROUP_CLASS_ABILITY);
|
||||
DoCastSelf(SPELL_SPIRIT_BOLTS);
|
||||
// Delay Drain Power if it's currently within 10s of being cast
|
||||
// TODO: see what is wrong with GetNextGroupOccurrence as the timers don't seem correct on resets
|
||||
_timeUntilNextDrainPower = scheduler.GetNextGroupOccurrence(GROUP_DRAIN_POWER);
|
||||
if (_timeUntilNextDrainPower > 0s && _timeUntilNextDrainPower < 10s)
|
||||
{
|
||||
std::chrono::milliseconds delayTime = 10s - _timeUntilNextDrainPower + 1s;
|
||||
scheduler.DelayGroup(GROUP_DRAIN_POWER, delayTime);
|
||||
}
|
||||
scheduler.Schedule(10s, [this](TaskContext)
|
||||
{
|
||||
if (Creature* siphonTrigger = me->SummonCreature(NPC_TEMP_TRIGGER, me->GetPosition(), TEMPSUMMON_TIMED_DESPAWN, 30000))
|
||||
@@ -354,6 +366,7 @@ struct boss_hexlord_malacrass : public BossAI
|
||||
private:
|
||||
uint8 _currentClass;
|
||||
std::chrono::milliseconds _classAbilityTimer;
|
||||
std::chrono::milliseconds _timeUntilNextDrainPower;
|
||||
std::vector<uint8> _creatureIndex;
|
||||
};
|
||||
|
||||
|
||||
@@ -464,7 +464,7 @@ class spell_summon_all_players_dummy: public SpellScript
|
||||
Position pos = GetCaster()->GetPosition();
|
||||
targets.remove_if([&, pos](WorldObject* target) -> bool
|
||||
{
|
||||
return target->IsWithinBox(pos, 18.0f, 18.0f, 18.0f);
|
||||
return target->IsWithinBox(pos, 22.0f, 28.0f, 28.0f);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -682,22 +682,6 @@ private:
|
||||
SummonList _summons;
|
||||
};
|
||||
|
||||
struct WorldTriggerHutPred
|
||||
{
|
||||
bool operator()(Creature* trigger) const
|
||||
{
|
||||
return trigger->GetOrientation() > 2.7f || (trigger->GetOrientation() < 2.7f && 1270.0f < trigger->GetPositionY() && trigger->GetPositionY() < 1280.0f);
|
||||
}
|
||||
};
|
||||
|
||||
struct WorldTriggerDrumPred
|
||||
{
|
||||
bool operator()(Creature* trigger) const
|
||||
{
|
||||
return !WorldTriggerHutPred()(trigger);
|
||||
}
|
||||
};
|
||||
|
||||
enum AmanishiScout
|
||||
{
|
||||
NPC_WORLD_TRIGGER = 22515,
|
||||
@@ -708,6 +692,18 @@ enum AmanishiScout
|
||||
SPELL_SHOOT = 16496
|
||||
};
|
||||
|
||||
inline bool IsHut(Creature* trigger)
|
||||
{
|
||||
return trigger->GetPositionX() < -90.0f // South of Jan'alai area
|
||||
&& ((trigger->GetOrientation() > 2.7f) || (trigger->GetOrientation() < 2.7f && 1270.0f < trigger->GetPositionY() && trigger->GetPositionY() < 1280.0f));
|
||||
}
|
||||
|
||||
inline bool IsDrum(Creature* trigger)
|
||||
{
|
||||
return trigger->GetPositionX() < -90.0f // South of Jan'alai area
|
||||
&& !IsHut(trigger);
|
||||
}
|
||||
|
||||
struct npc_amanishi_scout : public ScriptedAI
|
||||
{
|
||||
npc_amanishi_scout(Creature* creature) : ScriptedAI(creature) { }
|
||||
@@ -725,7 +721,7 @@ struct npc_amanishi_scout : public ScriptedAI
|
||||
// Move to Drum
|
||||
std::list<Creature*> triggers;
|
||||
GetCreatureListWithEntryInGrid(triggers, me, NPC_WORLD_TRIGGER, 50.0f);
|
||||
triggers.remove_if(WorldTriggerHutPred());
|
||||
triggers.remove_if([](Creature* trigger) {return !IsDrum(trigger);});
|
||||
triggers.sort(Acore::ObjectDistanceOrderPred(me));
|
||||
if (!triggers.empty())
|
||||
{
|
||||
@@ -826,7 +822,7 @@ class spell_summon_amanishi_sentries : public SpellScript
|
||||
{
|
||||
std::list<Creature*> triggers;
|
||||
GetCreatureListWithEntryInGrid(triggers, GetHitUnit(), NPC_WORLD_TRIGGER, 50.0f);
|
||||
triggers.remove_if(WorldTriggerDrumPred());
|
||||
triggers.remove_if([](Creature* trigger) {return !IsHut(trigger);});
|
||||
if (triggers.empty())
|
||||
return;
|
||||
Creature* trigger = Acore::Containers::SelectRandomContainerElement(triggers);
|
||||
|
||||
@@ -268,7 +268,7 @@ public:
|
||||
Map::PlayerList const& playerList = me->GetMap()->GetPlayers();
|
||||
for(Map::PlayerList::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
|
||||
if (Player* player = itr->GetSource())
|
||||
if (!player->IsGameMaster() && player->IsAlive() && me->GetHomePosition().GetExactDist2d(player) < 52.0f && me->IsWithinLOSInMap(player) && !player->HasInvisibilityAura() && !player->HasStealthAura() && !player->HasUnattackableAura())
|
||||
if (!player->IsGameMaster() && player->IsAlive() && me->GetHomePosition().GetExactDist2d(player) < 52.0f && me->IsWithinLOSInMap(player) && !player->HasInvisibilityAura() && !player->HasStealthAura() && !player->HasUnattackableAura() && !player->HasAura(5384))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user