refactor: remove a bunch of linux-specific ifndefs

Now that we're stubbing winapi through stdafx, these need to go.
This commit is contained in:
Tropical
2026-03-03 18:16:42 -06:00
parent 4d9a1c73e6
commit 7abf08a804
12 changed files with 98 additions and 199 deletions

View File

@@ -25,7 +25,6 @@ void Socket::Initialise(ServerConnection *serverConnection)
// Only initialise everything else once - just setting up static data, one time xrnm things, thread for ticking sockets
static bool init = false;
#if !defined(__linux__)
if( init )
{
for( int i = 0; i < 2; i++ )
@@ -42,14 +41,11 @@ void Socket::Initialise(ServerConnection *serverConnection)
}
return;
}
#endif
init = true;
for( int i = 0; i < 2; i++ )
{
#if !defined(__linux__)
InitializeCriticalSection(&Socket::s_hostQueueLock[i]);
#endif
s_hostOutStream[i] = new SocketOutputStreamLocal(i);
s_hostInStream[i] = new SocketInputStreamLocal(i);
}
@@ -86,9 +82,7 @@ Socket::Socket(INetworkPlayer *player, bool response /* = false*/, bool hostLoca
for( int i = 0; i < 2; i++ )
{
#if !defined(__linux__)
InitializeCriticalSection(&m_queueLockNetwork[i]);
#endif // __linux__
m_inputStream[i] = NULL;
m_outputStream[i] = NULL;
m_endClosed[i] = false;
@@ -136,7 +130,6 @@ void Socket::setPlayer(INetworkPlayer *player)
void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHost /*= true*/)
{
#ifndef __linux__
int queueIdx = SOCKET_CLIENT_END;
if(!fromHost)
queueIdx = SOCKET_SERVER_END;
@@ -153,7 +146,6 @@ void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHos
m_queueNetwork[queueIdx].push(*pbData++);
}
LeaveCriticalSection(&m_queueLockNetwork[queueIdx]);
#endif // __linux__
}
void Socket::addIncomingSocket(Socket *socket)
@@ -270,7 +262,6 @@ Socket::SocketInputStreamLocal::SocketInputStreamLocal(int queueIdx)
// Try and get an input byte, blocking until one is available
int Socket::SocketInputStreamLocal::read()
{
#if !defined(__linux__)
while(m_streamOpen && ShutdownManager::ShouldRun(ShutdownManager::eConnectionReadThreads))
{
if(TryEnterCriticalSection(&s_hostQueueLock[m_queueIdx]))
@@ -286,8 +277,6 @@ int Socket::SocketInputStreamLocal::read()
}
Sleep(1);
}
#endif // __linux__
return -1;
}
// Try and get an input array of bytes, blocking until enough bytes are available
@@ -299,7 +288,6 @@ int Socket::SocketInputStreamLocal::read(byteArray b)
// Try and get an input range of bytes, blocking until enough bytes are available
int Socket::SocketInputStreamLocal::read(byteArray b, unsigned int offset, unsigned int length)
{
#ifndef __linux__
while(m_streamOpen)
{
if(TryEnterCriticalSection(&s_hostQueueLock[m_queueIdx]))
@@ -318,18 +306,14 @@ int Socket::SocketInputStreamLocal::read(byteArray b, unsigned int offset, unsig
}
Sleep(1);
}
#endif // __linux__
return -1;
}
void Socket::SocketInputStreamLocal::close()
{
#ifndef __linux__
m_streamOpen = false;
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
s_hostQueue[m_queueIdx].empty();
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
#endif // __linux__
}
/////////////////////////////////// Socket for output, on local connection ////////////////////
@@ -342,7 +326,6 @@ Socket::SocketOutputStreamLocal::SocketOutputStreamLocal(int queueIdx)
void Socket::SocketOutputStreamLocal::write(unsigned int b)
{
#ifndef __linux__
if( m_streamOpen != true )
{
return;
@@ -350,7 +333,6 @@ void Socket::SocketOutputStreamLocal::write(unsigned int b)
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
s_hostQueue[m_queueIdx].push((byte)b);
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
#endif // __linux__
}
void Socket::SocketOutputStreamLocal::write(byteArray b)
@@ -360,7 +342,6 @@ void Socket::SocketOutputStreamLocal::write(byteArray b)
void Socket::SocketOutputStreamLocal::write(byteArray b, unsigned int offset, unsigned int length)
{
#ifndef __linux__
if( m_streamOpen != true )
{
return;
@@ -373,17 +354,14 @@ void Socket::SocketOutputStreamLocal::write(byteArray b, unsigned int offset, un
}
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
MemSect(0);
#endif // __linux__
}
void Socket::SocketOutputStreamLocal::close()
{
#ifndef __linux__
m_streamOpen = false;
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
s_hostQueue[m_queueIdx].empty();
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
#endif // __linux__
}
/////////////////////////////////// Socket for input, on network connection ////////////////////
@@ -398,7 +376,6 @@ Socket::SocketInputStreamNetwork::SocketInputStreamNetwork(Socket *socket, int q
// Try and get an input byte, blocking until one is available
int Socket::SocketInputStreamNetwork::read()
{
#ifndef __linux__
while(m_streamOpen && ShutdownManager::ShouldRun(ShutdownManager::eConnectionReadThreads))
{
if(TryEnterCriticalSection(&m_socket->m_queueLockNetwork[m_queueIdx]))
@@ -414,8 +391,6 @@ int Socket::SocketInputStreamNetwork::read()
}
Sleep(1);
}
#endif // __linux__
return -1;
}
// Try and get an input array of bytes, blocking until enough bytes are available
@@ -427,7 +402,6 @@ int Socket::SocketInputStreamNetwork::read(byteArray b)
// Try and get an input range of bytes, blocking until enough bytes are available
int Socket::SocketInputStreamNetwork::read(byteArray b, unsigned int offset, unsigned int length)
{
#ifndef __linux__
while(m_streamOpen)
{
if(TryEnterCriticalSection(&m_socket->m_queueLockNetwork[m_queueIdx]))
@@ -446,8 +420,6 @@ int Socket::SocketInputStreamNetwork::read(byteArray b, unsigned int offset, uns
}
Sleep(1);
}
#endif // __linux__
return -1;
}
void Socket::SocketInputStreamNetwork::close()