From c122bff122e7da2fc1ab2f4e394e0a9d8bd8a62c Mon Sep 17 00:00:00 2001 From: zukrmn Date: Sat, 7 Mar 2026 04:57:43 +0000 Subject: [PATCH] fix: address PR reviewer feedback regarding random_shuffle and queue.empty() --- Minecraft.World/Entities/Mobs/Villager.cpp | 3 +-- Minecraft.World/Network/Socket.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Minecraft.World/Entities/Mobs/Villager.cpp b/Minecraft.World/Entities/Mobs/Villager.cpp index e6568fe54..732283c73 100644 --- a/Minecraft.World/Entities/Mobs/Villager.cpp +++ b/Minecraft.World/Entities/Mobs/Villager.cpp @@ -530,8 +530,7 @@ void Villager::addOffers(int addCount) } // shuffle the list to make it more interesting - std::random_device rd; - std::mt19937 g(rd()); + static thread_local std::mt19937 g(std::random_device{}()); std::shuffle(newOffers->begin(), newOffers->end(), g); if (offers == NULL) diff --git a/Minecraft.World/Network/Socket.cpp b/Minecraft.World/Network/Socket.cpp index 1933eccd2..a76421732 100644 --- a/Minecraft.World/Network/Socket.cpp +++ b/Minecraft.World/Network/Socket.cpp @@ -344,7 +344,7 @@ void Socket::SocketInputStreamLocal::close() { m_streamOpen = false; EnterCriticalSection(&s_hostQueueLock[m_queueIdx]); - while(!s_hostQueue[m_queueIdx].empty()) s_hostQueue[m_queueIdx].pop(); + std::queue().swap(s_hostQueue[m_queueIdx]); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); } @@ -392,7 +392,7 @@ void Socket::SocketOutputStreamLocal::close() { m_streamOpen = false; EnterCriticalSection(&s_hostQueueLock[m_queueIdx]); - while(!s_hostQueue[m_queueIdx].empty()) s_hostQueue[m_queueIdx].pop(); + std::queue().swap(s_hostQueue[m_queueIdx]); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); }