diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 3f8b29934..2096afc25 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -7,7 +7,6 @@ set(common_sources
classes.cpp
cli/eqemu_command_handler.cpp
compression.cpp
- condition.cpp
content/world_content_service.cpp
crash.cpp
crc16.cpp
@@ -61,7 +60,6 @@ set(common_sources
memory_mapped_file.cpp
misc.cpp
misc_functions.cpp
- mutex.cpp
mysql_request_result.cpp
mysql_request_row.cpp
mysql_stmt.cpp
@@ -548,7 +546,6 @@ set(common_headers
cli/terminal_color.hpp
classes.h
compression.h
- condition.h
content/world_content_service.h
crash.h
crc16.h
@@ -627,7 +624,6 @@ set(common_headers
memory_mapped_file.h
misc.h
misc_functions.h
- mutex.h
mysql_request_result.h
mysql_request_row.h
mysql_stmt.h
diff --git a/common/condition.cpp b/common/condition.cpp
deleted file mode 100644
index 657bc610d..000000000
--- a/common/condition.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/* EQEmu: EQEmulator
-
- Copyright (C) 2001-2026 EQEmu Development Team
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-#include "condition.h"
-
-#ifdef _WINDOWS
-
- Condition::Condition()
- {
- m_events[SignalEvent] = CreateEvent (nullptr, // security
- FALSE, // is auto-reset event?
- FALSE, // is signaled initially?
- nullptr); // name
- m_events[BroadcastEvent] = CreateEvent (nullptr, // security
- TRUE, // is auto-reset event?
- FALSE, // is signaled initially?
- nullptr); // name
- m_waiters = 0;
- InitializeCriticalSection(&CSMutex);
- }
-
- Condition::~Condition()
- {
- DeleteCriticalSection(&CSMutex);
- CloseHandle(m_events[SignalEvent]);
- CloseHandle(m_events[BroadcastEvent]);
- }
-
- void Condition::Signal()
- {
- EnterCriticalSection(&CSMutex);
- if(m_waiters > 0)
- SetEvent(m_events[SignalEvent]);
- LeaveCriticalSection(&CSMutex);
- }
-
- void Condition::SignalAll()
- {
- EnterCriticalSection(&CSMutex);
- if(m_waiters > 0)
- SetEvent(m_events[BroadcastEvent]);
- LeaveCriticalSection(&CSMutex);
- }
-
- void Condition::Wait()
- {
- EnterCriticalSection(&CSMutex);
-
- m_waiters++;
-
-
- LeaveCriticalSection(&CSMutex);
- int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE);
- EnterCriticalSection(&CSMutex);
-
- m_waiters--;
-
- //see if we are the last person waiting on the condition, and there was a broadcast
- //if so, we need to reset the broadcast event.
- if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent))
- ResetEvent(m_events[BroadcastEvent]);
-
- LeaveCriticalSection(&CSMutex);
- }
-
-#else
- #include
- #include
- #include
-
- Condition::Condition()
- {
- pthread_cond_init(&cond,nullptr);
- pthread_mutex_init(&mutex,nullptr);
- }
-
- void Condition::Signal()
- {
- pthread_mutex_lock(&mutex);
- pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
- }
-
- void Condition::SignalAll()
- {
- pthread_mutex_lock(&mutex);
- pthread_cond_broadcast(&cond);
- pthread_mutex_unlock(&mutex);
- }
-
- void Condition::Wait()
- {
- pthread_mutex_lock(&mutex);
- pthread_cond_wait(&cond,&mutex);
- pthread_mutex_unlock(&mutex);
- }
-
- /*
- I commented this specifically because I think it might be very
- difficult to write a windows counterpart to it, so I would like
- to discourage its use until we can confirm that it can be reasonably
- implemented on windows.
-
- bool Condition::TimedWait(unsigned long usec)
- {
- struct timeval now;
- struct timespec timeout;
- int retcode=0;
- pthread_mutex_lock(&mutex);
- gettimeofday(&now,nullptr);
- now.tv_usec+=usec;
- timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000);
- timeout.tv_nsec = (now.tv_usec%1000000) *1000;
- //cout << "now=" << now.tv_sec << "."<.
-*/
-#pragma once
-
-#include "common/mutex.h"
-#include "common/platform/posix/include_pthreads.h"
-#include "common/platform/win/include_windows.h"
-
-//Sombody, someday needs to figure out how to implement a condition
-//system on windows...
-
-
-class Condition {
- private:
-#ifdef WIN32
- enum {
- SignalEvent = 0,
- BroadcastEvent,
- _eventCount
- };
-
- HANDLE m_events[_eventCount];
- uint32 m_waiters;
- CRITICAL_SECTION CSMutex;
-#else
- pthread_cond_t cond;
- pthread_mutex_t mutex;
-#endif
- public:
- Condition();
- void Signal();
- void SignalAll();
- void Wait();
-// bool TimedWait(unsigned long usec);
- ~Condition();
-};
diff --git a/common/database.cpp b/common/database.cpp
index 83ed14c90..7376cb0da 100644
--- a/common/database.cpp
+++ b/common/database.cpp
@@ -728,7 +728,7 @@ bool Database::LoadVariables()
return true;
}
- LockMutex lock(&Mvarcache);
+ std::scoped_lock lock(Mvarcache);
for (const auto& e : l) {
varcache.last_update = std::time(nullptr);
@@ -747,7 +747,7 @@ bool Database::LoadVariables()
bool Database::GetVariable(const std::string& name, std::string& value)
{
- LockMutex lock(&Mvarcache);
+ std::scoped_lock lock(Mvarcache);
if (name.empty()) {
return false;
diff --git a/common/database.h b/common/database.h
index fdb3154b2..ab5d6c271 100644
--- a/common/database.h
+++ b/common/database.h
@@ -20,13 +20,12 @@
#include "common/dbcore.h"
#include "common/eq_packet_structs.h"
#include "common/eqemu_logsys.h"
-#include "common/linked_list.h"
#include "common/types.h"
-#include
+#include