Skip to content

Commit

Permalink
Merge branch 'master' into UnitOnShapeShift
Browse files Browse the repository at this point in the history
  • Loading branch information
iThorgrim authored Jan 25, 2025
2 parents 5d69c76 + f692ae9 commit cbd08fe
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 107 deletions.
13 changes: 13 additions & 0 deletions data/sql/updates/db_world/2025_01_23_00.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- DB update 2025_01_22_02 -> 2025_01_23_00

-- Phoenix
UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 24674;

DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 24674);
INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
(24674, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 0, 0, 11, 44196, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Phoenix - On Initialize - Cast \'Rebirth\''),
(24674, 0, 1, 0, 60, 0, 100, 257, 2000, 2000, 0, 0, 0, 0, 11, 44197, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Phoenix - On Update - Cast \'Burn\' (No Repeat)'),
(24674, 0, 2, 0, 24, 0, 100, 0, 44226, 1, 5000, 5000, 0, 0, 11, 44202, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Phoenix - On Target Buffed With \'Gravity Lapse\' - Cast \'Fireball\''),
(24674, 0, 3, 0, 25, 0, 100, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 21, 40, 0, 0, 0, 0, 0, 0, 0, 'Phoenix - On Reset - Start Attacking'),
(24674, 0, 4, 5, 6, 0, 100, 0, 0, 0, 0, 0, 0, 0, 12, 24675, 3, 20000, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Phoenix - On Just Died - Summon Creature \'Phoenix Egg\''),
(24674, 0, 5, 0, 61, 0, 100, 512, 0, 0, 0, 0, 0, 0, 41, 1000, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Phoenix - On Just Died - Despawn In 1000 ms');
3 changes: 3 additions & 0 deletions data/sql/updates/db_world/2025_01_23_01.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- DB update 2025_01_23_00 -> 2025_01_23_01
--
UPDATE `creature_template` SET `flags_extra` = `flags_extra`|2147483648 WHERE `entry` IN (24664, 24857);
5 changes: 5 additions & 0 deletions data/sql/updates/db_world/2025_01_23_02.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DB update 2025_01_23_01 -> 2025_01_23_02
--
DELETE FROM `creature_text` WHERE `CreatureID` = 24664 AND `GroupID` = 7;
INSERT INTO `creature_text` (`CreatureID`, `GroupID`, `ID`, `Text`, `Type`, `Language`, `Probability`, `BroadcastTextId`, `TextRange`, `comment`) VALUES
(24664, 7, 0, 'Oh no, he was merely an instrument, a stepping stone to a much larger plan! It has all led to this... and this time you will not interfere!', 14, 0, 100, 25387, 0, 'kaelthas MT SAY_AGGRO_2');
5 changes: 5 additions & 0 deletions data/sql/updates/db_world/2025_01_23_03.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DB update 2025_01_23_02 -> 2025_01_23_03
--
UPDATE `creature_template` SET `AIName` = '' WHERE `entry` = 24777;
DELETE FROM `smart_scripts` WHERE (`entryorguid` = 24777) AND (`source_type` = 0);
UPDATE `creature_addon` SET `auras` = '44537' WHERE `guid` IN (96944, 96945, 96946);
3 changes: 3 additions & 0 deletions data/sql/updates/db_world/2025_01_23_04.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- DB update 2025_01_23_03 -> 2025_01_23_04
--
UPDATE `creature_template_movement` SET `Rooted`= 1, `Flight` = 1 WHERE `CreatureId` = 24666;
22 changes: 22 additions & 0 deletions data/sql/updates/db_world/2025_01_24_00.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- DB update 2025_01_23_04 -> 2025_01_24_00
-- Fix Kaelthas HC
DELETE FROM `creature_loot_template` WHERE (`Entry` = 24857) AND (`Item` IN (23572, 25028, 25029, 34609, 34610, 34611, 34612, 34613, 34614, 34615, 34616));
INSERT INTO `creature_loot_template` (`Entry`, `Item`, `Reference`, `Chance`, `QuestRequired`, `LootMode`, `GroupId`, `MinCount`, `MaxCount`, `Comment`) VALUES
(24857, 23572, 0, 100, 0, 1, 0, 1, 1, 'Kael\'thas Sunstrider (1) - Primal Nether'),
(24857, 34612, 0, 0, 0, 1, 1, 1, 1, 'Kael\'thas Sunstrider (1) - Greaves of the Penitent Knight'),
(24857, 34609, 0, 0, 0, 1, 1, 1, 1, 'Kael\'thas Sunstrider (1) - Quickening Blade of the Prince'),
(24857, 34611, 0, 0, 0, 1, 1, 1, 1, 'Kael\'thas Sunstrider (1) - Cudgel of Consecration'),
(24857, 34610, 0, 0, 0, 1, 1, 1, 1, 'Kael\'thas Sunstrider (1) - Scarlet Sin\'dorei Robes'),
(24857, 34614, 0, 0, 0, 1, 2, 1, 1, 'Kael\'thas Sunstrider (1) - Tunic of the Ranger Lord'),
(24857, 34615, 0, 0, 0, 1, 2, 1, 1, 'Kael\'thas Sunstrider (1) - Netherforce Chestplate'),
(24857, 34616, 0, 0, 0, 1, 2, 1, 1, 'Kael\'thas Sunstrider (1) - Breeching Comet'),
(24857, 34613, 0, 0, 0, 1, 2, 1, 1, 'Kael\'thas Sunstrider (1) - Shoulderpads of the Silvermoon Retainer');

-- Remove normal loot from Delrissa HC
DELETE FROM `creature_loot_template` WHERE (`Entry` = 25560) AND (`Item` IN (25027));

-- Remove normal loot from Vexallus HC
DELETE FROM `creature_loot_template` WHERE (`Entry` = 25573) AND (`Item` IN (25026));

-- Remove normal loot from Selin Fireheart HC
DELETE FROM `creature_loot_template` WHERE (`Entry` = 25562) AND (`Item` IN (25025));
4 changes: 4 additions & 0 deletions data/sql/updates/db_world/2025_01_24_01.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- DB update 2025_01_24_00 -> 2025_01_24_01
--
-- Remove extra Sanctum Planetarium
DELETE FROM `gameobject` WHERE (`id` = 188081) AND (`guid` IN (27809));
128 changes: 70 additions & 58 deletions src/common/Threading/LockedQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,74 +18,92 @@
#ifndef LOCKEDQUEUE_H
#define LOCKEDQUEUE_H

#include <atomic>
#include <deque>
#include <memory>
#include <mutex>

template <class T, typename StorageType = std::deque<T>>
class LockedQueue
{
//! Lock access to the queue.
std::mutex _lock;
mutable std::mutex _lock; ///< Mutex to protect access to the queue

//! Storage backing the queue.
StorageType _queue;
std::atomic<bool> _canceled{false}; ///< Flag indicating if the queue is canceled

//! Cancellation flag.
volatile bool _canceled{false};
StorageType _queue; ///< Storage container for the queue

public:

//! Create a LockedQueue.
/**
* @brief Default constructor to create an empty LockedQueue.
*/
LockedQueue() = default;

//! Destroy a LockedQueue.
/**
* @brief Destructor for LockedQueue.
*/
virtual ~LockedQueue() = default;

//! Adds an item to the queue.
/**
* @brief Adds an item to the back of the queue.
*
* @param item The item to be added to the queue.
*/
void add(const T& item)
{
lock();

_queue.push_back(item);

unlock();
std::lock_guard<std::mutex> lock(_lock);
_queue.push_back(std::move(item));
}

//! Adds items back to front of the queue
/**
* @brief Adds a range of items to the front of the queue.
*
* @param begin Iterator pointing to the beginning of the range of items to be added.
* @param end Iterator pointing to the end of the range of items to be added.
*/
template<class Iterator>
void readd(Iterator begin, Iterator end)
{
std::lock_guard<std::mutex> lock(_lock);
_queue.insert(_queue.begin(), begin, end);
}

//! Gets the next result in the queue, if any.
/**
* @brief Gets the next item in the queue and removes it.
*
* @param result The variable where the next item will be stored.
* @return true if an item was retrieved and removed, false if the queue is empty.
*/
bool next(T& result)
{
std::lock_guard<std::mutex> lock(_lock);

if (_queue.empty())
{
return false;
}

result = _queue.front();
result = std::move(_queue.front());
_queue.pop_front();

return true;
}

/**
* @brief Retrieves the next item from the queue if it satisfies the provided checker.
*
* @param result The variable where the next item will be stored.
* @param check A checker object that will be used to validate the item.
* @return true if an item was retrieved, checked, and removed; false otherwise.
*/
template<class Checker>
bool next(T& result, Checker& check)
{
std::lock_guard<std::mutex> lock(_lock);

if (_queue.empty())
{
return false;
}

result = _queue.front();
result = std::move(_queue.front());
if (!check.Process(result))
{
return false;
Expand All @@ -95,60 +113,54 @@ class LockedQueue
return true;
}

//! Peeks at the top of the queue. Check if the queue is empty before calling! Remember to unlock after use if autoUnlock == false.
T& peek(bool autoUnlock = false)
{
lock();

T& result = _queue.front();

if (autoUnlock)
{
unlock();
}

return result;
}

//! Cancels the queue.
void cancel()
/**
* @brief Peeks at the top of the queue without removing it.
*
* @return A reference to the item at the front of the queue, assuming there's an item in the queue (as per previous implementation)
*/
T& peek()
{
std::lock_guard<std::mutex> lock(_lock);

_canceled = true;
return _queue.front();
}

//! Checks if the queue is cancelled.
bool cancelled()
/**
* @brief Cancels the queue, preventing further processing of items.
*/
void cancel()
{
std::lock_guard<std::mutex> lock(_lock);
return _canceled;
_canceled.store(true, std::memory_order_release);
}

//! Locks the queue for access.
void lock()
/**
* @brief Checks if the queue has been canceled.
*
* @return true if the queue is canceled, false otherwise.
*/
bool cancelled() const
{
this->_lock.lock();
return _canceled.load(std::memory_order_acquire);
}

//! Unlocks the queue.
void unlock()
/**
* @brief Checks if the queue is empty.
*
* @return true if the queue is empty, false otherwise.
*/
bool empty() const
{
this->_lock.unlock();
std::lock_guard<std::mutex> lock(_lock);
return _queue.empty();
}

///! Calls pop_front of the queue
/**
* @brief Removes the item at the front of the queue.
*/
void pop_front()
{
std::lock_guard<std::mutex> lock(_lock);
_queue.pop_front();
}

///! Checks if we're empty or not with locks held
bool empty()
{
std::lock_guard<std::mutex> lock(_lock);
return _queue.empty();
}
};

#endif
Loading

0 comments on commit cbd08fe

Please sign in to comment.